LCOV - code coverage report
Current view: top level - reportdesign/source/ui/dlg - Formula.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 125 0.0 %
Date: 2014-04-11 Functions: 0 31 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <vcl/svapp.hxx>
      21             : #include <vcl/mnemonic.hxx>
      22             : #include <vcl/msgbox.hxx>
      23             : #include <unotools/charclass.hxx>
      24             : #include <unotools/viewoptions.hxx>
      25             : #include <formula/formdata.hxx>
      26             : #include <formula/funcutl.hxx>
      27             : #include <formula/tokenarray.hxx>
      28             : 
      29             : #include <boost/scoped_ptr.hpp>
      30             : 
      31             : #include "Formula.hxx"
      32             : #include "AddField.hxx"
      33             : #include "helpids.hrc"
      34             : 
      35             : 
      36             : namespace rptui
      37             : {
      38             :     using namespace formula;
      39             :     using namespace ::com::sun::star;
      40             : 
      41             : 
      42             : //      Initialisierung / gemeinsame Funktionen  fuer Dialog
      43             : 
      44             : 
      45           0 : FormulaDialog::FormulaDialog(Window* pParent
      46             :                              , const uno::Reference<lang::XMultiServiceFactory>& _xServiceFactory
      47             :                              , const ::boost::shared_ptr< IFunctionManager >&  _pFunctionMgr
      48             :                              , const OUString& _sFormula
      49             :                              , const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet >& _xRowSet)
      50             :     : FormulaModalDialog( pParent, false,false,false,_pFunctionMgr.get(),this)
      51             :     ,m_aFunctionManager(_pFunctionMgr)
      52           0 :     ,m_pFormulaData(new FormEditData())
      53             :     ,m_pAddField(NULL)
      54             :     ,m_xRowSet(_xRowSet)
      55             :     ,m_pEdit(NULL)
      56             :     ,m_sFormula("=")
      57             :     ,m_nStart(0)
      58           0 :     ,m_nEnd(1)
      59             : {
      60           0 :     if ( !_sFormula.isEmpty() )
      61             :     {
      62           0 :         if ( _sFormula[0] != '=' )
      63           0 :             m_sFormula += _sFormula;
      64             :         else
      65           0 :             m_sFormula = _sFormula;
      66             :     }
      67           0 :     m_xParser.set(_xServiceFactory->createInstance("org.libreoffice.report.pentaho.SOFormulaParser"),uno::UNO_QUERY);
      68           0 :     if ( m_xParser.is() )
      69           0 :         m_xOpCodeMapper = m_xParser->getFormulaOpCodeMapper();
      70           0 :     fill();
      71           0 : }
      72             : 
      73           0 : void FormulaDialog::notifyChange()
      74             : {
      75           0 : }
      76             : 
      77           0 : void FormulaDialog::fill()
      78             : {
      79           0 :     SetMeText(m_sFormula);
      80           0 :     Update(m_sFormula);
      81           0 :     CheckMatrix(m_sFormula);
      82           0 :     Update();
      83           0 : }
      84             : 
      85           0 : FormulaDialog::~FormulaDialog()
      86             : {
      87           0 :     if ( m_pAddField )
      88             :     {
      89           0 :         SvtViewOptions aDlgOpt( E_WINDOW, OUString( HID_RPT_FIELD_SEL_WIN ) );
      90           0 :         aDlgOpt.SetWindowState(OStringToOUString(m_pAddField->GetWindowState((WINDOWSTATE_MASK_X | WINDOWSTATE_MASK_Y | WINDOWSTATE_MASK_STATE | WINDOWSTATE_MASK_MINIMIZED)), RTL_TEXTENCODING_ASCII_US));
      91             : 
      92           0 :         boost::scoped_ptr<Window> aTemp2(m_pAddField);
      93           0 :         m_pAddField = NULL;
      94             :     }
      95             : 
      96           0 :     StoreFormEditData( m_pFormulaData );
      97           0 : }
      98             : 
      99             : 
     100             : //                          Funktionen fuer rechte Seite
     101             : 
     102           0 : bool FormulaDialog::calculateValue( const OUString& rStrExp, OUString& rStrResult )
     103             : {
     104           0 :     rStrResult = rStrExp;
     105           0 :     return false;
     106             : }
     107           0 : void FormulaDialog::doClose(bool _bOk)
     108             : {
     109           0 :     EndDialog(_bOk ? RET_OK : RET_CANCEL);
     110           0 : }
     111           0 : void FormulaDialog::insertEntryToLRUList(const IFunctionDescription*    /*_pDesc*/)
     112             : {
     113           0 : }
     114           0 : void FormulaDialog::showReference(const OUString& /*_sFormula*/)
     115             : {
     116           0 : }
     117           0 : void FormulaDialog::dispatch(bool /*_bOK*/, bool /*_bMatrixChecked*/)
     118             : {
     119           0 : }
     120           0 : void FormulaDialog::setDispatcherLock( bool /*bLock*/ )
     121             : {
     122           0 : }
     123           0 : void FormulaDialog::setReferenceInput(const FormEditData* /*_pData*/)
     124             : {
     125           0 : }
     126           0 : void FormulaDialog::deleteFormData()
     127             : {
     128           0 : }
     129           0 : void FormulaDialog::clear()
     130             : {
     131           0 : }
     132           0 : void FormulaDialog::switchBack()
     133             : {
     134           0 : }
     135           0 : FormEditData* FormulaDialog::getFormEditData() const
     136             : {
     137           0 :     return m_pFormulaData;
     138             : }
     139           0 : void FormulaDialog::setCurrentFormula(const OUString& _sReplacement)
     140             : {
     141           0 :     const sal_Int32 nOldLen = m_nEnd - m_nStart;
     142           0 :     const sal_Int32 nNewLen = _sReplacement.getLength();
     143           0 :     if (nOldLen)
     144           0 :         m_sFormula = m_sFormula.replaceAt( m_nStart, nOldLen, "" );
     145           0 :     if (nNewLen)
     146           0 :         m_sFormula = m_sFormula.replaceAt( m_nStart, 0, _sReplacement );
     147           0 :     m_nEnd = m_nStart + nNewLen;
     148           0 : }
     149           0 : void FormulaDialog::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
     150             : {
     151           0 :     if ( _nStart <= _nEnd )
     152             :     {
     153           0 :         m_nStart = _nStart;
     154           0 :         m_nEnd = _nEnd;
     155             :     }
     156             :     else
     157             :     {
     158           0 :         m_nEnd = _nStart;
     159           0 :         m_nStart = _nEnd;
     160             :     }
     161           0 : }
     162           0 : void FormulaDialog::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
     163             : {
     164           0 :     _nStart = m_nStart;
     165           0 :     _nEnd = m_nEnd;
     166           0 : }
     167           0 : OUString FormulaDialog::getCurrentFormula() const
     168             : {
     169           0 :     return m_sFormula;
     170             : }
     171           0 : IFunctionManager* FormulaDialog::getFunctionManager()
     172             : {
     173           0 :     return m_aFunctionManager.get();
     174             : }
     175             : 
     176           0 : void FormulaDialog::ShowReference(const OUString& /*_sRef*/)
     177             : {
     178           0 : }
     179             : 
     180           0 : void FormulaDialog::HideReference( bool /*bDoneRefMode*/)
     181             : {
     182           0 : }
     183             : 
     184           0 : void FormulaDialog::ReleaseFocus( RefEdit* /*pEdit*/, RefButton* /*pButton*/)
     185             : {
     186           0 : }
     187             : 
     188           0 : void FormulaDialog::ToggleCollapsed( RefEdit* _pEdit, RefButton* _pButton)
     189             : {
     190           0 :     ::std::pair<RefButton*,RefEdit*> aPair = RefInputStartBefore( _pEdit, _pButton );
     191           0 :     m_pEdit = aPair.second;
     192           0 :     if ( m_pEdit )
     193           0 :         m_pEdit->Hide();
     194           0 :     if ( aPair.first )
     195           0 :         aPair.first->Hide();
     196             : 
     197           0 :     if ( !m_pAddField )
     198             :     {
     199           0 :         m_pAddField = new OAddFieldWindow(this,m_xRowSet);
     200           0 :         m_pAddField->SetCreateHdl(LINK( this, FormulaDialog, OnClickHdl ) );
     201           0 :         SvtViewOptions aDlgOpt( E_WINDOW, OUString( HID_RPT_FIELD_SEL_WIN ) );
     202           0 :         if ( aDlgOpt.Exists() )
     203             :         {
     204           0 :             m_pAddField->SetWindowState(OUStringToOString(aDlgOpt.GetWindowState().getStr(), RTL_TEXTENCODING_ASCII_US));
     205             : 
     206             :         }
     207             : 
     208           0 :         m_pAddField->Update();
     209             :     }
     210           0 :     RefInputStartAfter( aPair.second, aPair.first );
     211           0 :     m_pAddField->Show();
     212             : 
     213           0 : }
     214             : 
     215           0 : IMPL_LINK( FormulaDialog, OnClickHdl, OAddFieldWindow* ,_pAddFieldDlg)
     216             : {
     217           0 :     const uno::Sequence< beans::PropertyValue > aArgs = _pAddFieldDlg->getSelectedFieldDescriptors();
     218             :     // we use this way to create undo actions
     219           0 :     if ( m_pEdit && aArgs.getLength() == 1)
     220             :     {
     221           0 :         uno::Sequence< beans::PropertyValue > aValue;
     222           0 :         aArgs[0].Value >>= aValue;
     223           0 :         ::svx::ODataAccessDescriptor aDescriptor(aValue);
     224           0 :         OUString sName;
     225           0 :         aDescriptor[ ::svx::daColumnName ] >>= sName;
     226           0 :         if ( !sName.isEmpty() )
     227             :         {
     228           0 :             sName = "[" + sName + "]";
     229           0 :             m_pEdit->SetText(sName);
     230           0 :         }
     231             :     }
     232           0 :     m_pEdit = NULL;
     233           0 :     _pAddFieldDlg->Hide();
     234           0 :     RefInputDoneAfter( true );
     235             : 
     236           0 :     return 0L;
     237             : }
     238             : 
     239           0 : uno::Reference< sheet::XFormulaParser> FormulaDialog::getFormulaParser() const
     240             : {
     241           0 :     return m_xParser.get();
     242             : }
     243             : 
     244           0 : uno::Reference< sheet::XFormulaOpCodeMapper> FormulaDialog::getFormulaOpCodeMapper() const
     245             : {
     246           0 :     return m_xOpCodeMapper;
     247             : }
     248             : 
     249           0 : table::CellAddress FormulaDialog::getReferencePosition() const
     250             : {
     251           0 :     return table::CellAddress();
     252             : }
     253             : 
     254             : SAL_WNODEPRECATED_DECLARATIONS_PUSH
     255           0 : ::std::auto_ptr<formula::FormulaTokenArray> FormulaDialog::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
     256             : {
     257           0 :     ::std::auto_ptr<formula::FormulaTokenArray> pArray(new FormulaTokenArray());
     258           0 :     pArray->Fill(_aTokenList, NULL);
     259           0 :     return pArray;
     260             : }
     261             : 
     262             : } // rptui
     263             : 
     264             : // for mysterious reasons Apple llvm-g++ 4.2.1 needs these explicit
     265             : // template instantiations; otherwise linking fails with unresolved symbols
     266             : template class ::std::auto_ptr<formula::FormulaTokenArray>;
     267             : template std::auto_ptr<formula::FormulaTokenArray>::operator std::auto_ptr_ref<formula::FormulaTokenArray>();
     268             : SAL_WNODEPRECATED_DECLARATIONS_POP
     269             : 
     270             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10