LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - anyrefdg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 458 0.0 %
Date: 2012-08-25 Functions: 0 45 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 668 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "rangelst.hxx"
      30                 :            : #include <comphelper/string.hxx>
      31                 :            : #include <sfx2/app.hxx>
      32                 :            : #include <sfx2/viewsh.hxx>
      33                 :            : #include <vcl/wrkwin.hxx>
      34                 :            : #include <vcl/mnemonic.hxx>
      35                 :            : #include <tools/shl.hxx>
      36                 :            : #include <sfx2/bindings.hxx>
      37                 :            : #include <sfx2/dispatch.hxx>
      38                 :            : 
      39                 :            : #include "anyrefdg.hxx"
      40                 :            : #include "sc.hrc"
      41                 :            : #include "inputhdl.hxx"
      42                 :            : #include "scmod.hxx"
      43                 :            : #include "scresid.hxx"
      44                 :            : #include "inputwin.hxx"
      45                 :            : #include "tabvwsh.hxx"
      46                 :            : #include "docsh.hxx"
      47                 :            : #include "rfindlst.hxx"
      48                 :            : #include "compiler.hxx"
      49                 :            : #include "cell.hxx"
      50                 :            : #include "global.hxx"
      51                 :            : #include "inputopt.hxx"
      52                 :            : #include "rangeutl.hxx"
      53                 :            : 
      54                 :            : 
      55                 :          0 : ScFormulaReferenceHelper::ScFormulaReferenceHelper(IAnyRefDialog* _pDlg,SfxBindings* _pBindings)
      56                 :            :  : m_pDlg(_pDlg)
      57                 :            :  , pRefEdit (NULL)
      58                 :            :  , m_pWindow(NULL)
      59                 :            :  , m_pBindings(_pBindings)
      60                 :            :  , pAccel( NULL )
      61                 :            :  , pHiddenMarks(NULL)
      62                 :            :  , nRefTab(0)
      63                 :            :  , bHighLightRef( false )
      64         [ #  # ]:          0 :  , bAccInserted( false )
      65                 :            : {
      66 [ #  # ][ #  # ]:          0 :     ScInputOptions aInputOption=SC_MOD()->GetInputOptions();
                 [ #  # ]
      67         [ #  # ]:          0 :     bEnableColorRef=aInputOption.GetRangeFinder();
      68                 :          0 : }
      69                 :            : // -----------------------------------------------------------------------------
      70 [ #  # ][ #  # ]:          0 : ScFormulaReferenceHelper::~ScFormulaReferenceHelper()
                 [ #  # ]
      71                 :            : {
      72         [ #  # ]:          0 :     if (bAccInserted)
      73         [ #  # ]:          0 :         Application::RemoveAccel( pAccel.get() );
      74                 :            : 
      75                 :            :     // common cleanup for ScAnyRefDlg and ScFormulaDlg is done here
      76                 :            : 
      77         [ #  # ]:          0 :     HideReference();
      78         [ #  # ]:          0 :     enableInput( sal_True );
      79                 :            : 
      80 [ #  # ][ #  # ]:          0 :     ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl();
      81         [ #  # ]:          0 :     if ( pInputHdl )
      82         [ #  # ]:          0 :         pInputHdl->ResetDelayTimer();   // stop the timer for disabling the input line
      83                 :          0 : }
      84                 :            : // -----------------------------------------------------------------------------
      85                 :          0 : void ScFormulaReferenceHelper::enableInput( sal_Bool bEnable )
      86                 :            : {
      87         [ #  # ]:          0 :     TypeId aType(TYPE(ScDocShell));
      88         [ #  # ]:          0 :     ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
      89         [ #  # ]:          0 :     while( pDocShell )
      90                 :            :     {
      91         [ #  # ]:          0 :         SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
      92         [ #  # ]:          0 :         while( pFrame )
      93                 :            :         {
      94                 :            :             //  enable everything except InPlace, including bean frames
      95 [ #  # ][ #  # ]:          0 :             if ( !pFrame->GetFrame().IsInPlace() )
                 [ #  # ]
      96                 :            :             {
      97         [ #  # ]:          0 :                 SfxViewShell* p = pFrame->GetViewShell();
      98 [ #  # ][ #  # ]:          0 :                 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
         [ #  # ][ #  # ]
      99         [ #  # ]:          0 :                 if(pViewSh!=NULL)
     100                 :            :                 {
     101                 :          0 :                     Window *pWin=pViewSh->GetWindow();
     102         [ #  # ]:          0 :                     if(pWin)
     103                 :            :                     {
     104         [ #  # ]:          0 :                         Window *pParent=pWin->GetParent();
     105         [ #  # ]:          0 :                         if(pParent)
     106                 :            :                         {
     107         [ #  # ]:          0 :                             pParent->EnableInput(bEnable,sal_True /* sal_False */);
     108                 :            :                             if(sal_True /*bChildren*/)
     109         [ #  # ]:          0 :                                 pViewSh->EnableRefInput(bEnable);
     110                 :            :                         }
     111                 :            :                     }
     112                 :            :                 }
     113                 :            :             }
     114         [ #  # ]:          0 :             pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
     115                 :            :         }
     116                 :            : 
     117         [ #  # ]:          0 :         pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
     118                 :            :     }
     119                 :          0 : }
     120                 :            : // -----------------------------------------------------------------------------
     121                 :          0 : void ScFormulaReferenceHelper::ShowSimpleReference( const XubString& rStr )
     122                 :            : {
     123         [ #  # ]:          0 :     if( bEnableColorRef )
     124                 :            :     {
     125                 :          0 :         bHighLightRef=sal_True;
     126                 :          0 :         ScViewData* pViewData=ScDocShell::GetViewData();
     127         [ #  # ]:          0 :         if ( pViewData )
     128                 :            :         {
     129         [ #  # ]:          0 :             ScDocument* pDoc=pViewData->GetDocument();
     130                 :          0 :             ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
     131                 :            : 
     132         [ #  # ]:          0 :             ScRangeList aRangeList;
     133                 :            : 
     134         [ #  # ]:          0 :             pTabViewShell->DoneRefMode( false );
     135         [ #  # ]:          0 :             pTabViewShell->ClearHighlightRanges();
     136                 :            : 
     137 [ #  # ][ #  # ]:          0 :             if( ParseWithNames( aRangeList, rStr, pDoc ) )
     138                 :            :             {
     139 [ #  # ][ #  # ]:          0 :                 for ( size_t i = 0, nRanges = aRangeList.size(); i < nRanges; ++i )
     140                 :            :                 {
     141         [ #  # ]:          0 :                     ScRange* pRangeEntry = aRangeList[ i ];
     142         [ #  # ]:          0 :                     ColorData aColName = ScRangeFindList::GetColorName( i );
     143         [ #  # ]:          0 :                     pTabViewShell->AddHighlightRange( *pRangeEntry, aColName );
     144                 :            :                }
     145         [ #  # ]:          0 :             }
     146                 :            :         }
     147                 :            :     }
     148                 :          0 : }
     149                 :            : // -----------------------------------------------------------------------------
     150                 :          0 : bool ScFormulaReferenceHelper::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
     151                 :            : {
     152                 :          0 :     bool bError = false;
     153         [ #  # ]:          0 :     rRanges.RemoveAll();
     154                 :            : 
     155         [ #  # ]:          0 :     ScAddress::Details aDetails(pDoc->GetAddressConvention(), 0, 0);
     156                 :          0 :     ScRangeUtil aRangeUtil;
     157 [ #  # ][ #  # ]:          0 :     xub_StrLen nTokenCnt = comphelper::string::getTokenCount(rStr, ';');
     158         [ #  # ]:          0 :     for( xub_StrLen nToken = 0; nToken < nTokenCnt; ++nToken )
     159                 :            :     {
     160                 :          0 :         ScRange aRange;
     161         [ #  # ]:          0 :         String aRangeStr( rStr.GetToken( nToken ) );
     162                 :            : 
     163         [ #  # ]:          0 :         sal_uInt16 nFlags = aRange.ParseAny( aRangeStr, pDoc, aDetails );
     164         [ #  # ]:          0 :         if ( nFlags & SCA_VALID )
     165                 :            :         {
     166         [ #  # ]:          0 :             if ( (nFlags & SCA_TAB_3D) == 0 )
     167                 :          0 :                 aRange.aStart.SetTab( nRefTab );
     168         [ #  # ]:          0 :             if ( (nFlags & SCA_TAB2_3D) == 0 )
     169                 :          0 :                 aRange.aEnd.SetTab( aRange.aStart.Tab() );
     170         [ #  # ]:          0 :             rRanges.Append( aRange );
     171                 :            :         }
     172 [ #  # ][ #  # ]:          0 :         else if ( aRangeUtil.MakeRangeFromName( aRangeStr, pDoc, nRefTab, aRange, RUTL_NAMES, aDetails ) )
     173         [ #  # ]:          0 :             rRanges.Append( aRange );
     174                 :            :         else
     175                 :          0 :             bError = true;
     176         [ #  # ]:          0 :     }
     177                 :            : 
     178                 :          0 :     return !bError;
     179                 :            : }
     180                 :            : // -----------------------------------------------------------------------------
     181                 :          0 : void ScFormulaReferenceHelper::ShowFormulaReference( const XubString& rStr )
     182                 :            : {
     183         [ #  # ]:          0 :     if( /*!pRefEdit &&*/ bEnableColorRef)
     184                 :            :     {
     185                 :          0 :         bHighLightRef=sal_True;
     186                 :          0 :         ScViewData* pViewData=ScDocShell::GetViewData();
     187 [ #  # ][ #  # ]:          0 :         if ( pViewData && pRefComp.get() )
                 [ #  # ]
     188                 :            :         {
     189                 :          0 :             ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
     190                 :          0 :             SCCOL nCol = pViewData->GetCurX();
     191                 :          0 :             SCROW nRow = pViewData->GetCurY();
     192                 :          0 :             SCTAB nTab = pViewData->GetTabNo();
     193                 :          0 :             ScAddress aPos( nCol, nRow, nTab );
     194                 :            : 
     195         [ #  # ]:          0 :             ScTokenArray* pScTokA=pRefComp->CompileString(rStr);
     196                 :            :             //pRefComp->CompileTokenArray();
     197                 :            : 
     198 [ #  # ][ #  # ]:          0 :             if(pTabViewShell!=NULL && pScTokA!=NULL)
     199                 :            :             {
     200         [ #  # ]:          0 :                 pTabViewShell->DoneRefMode( false );
     201         [ #  # ]:          0 :                 pTabViewShell->ClearHighlightRanges();
     202                 :            : 
     203                 :          0 :                 pScTokA->Reset();
     204         [ #  # ]:          0 :                 const ScToken* pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
     205                 :            : 
     206                 :          0 :                 sal_uInt16 nIndex=0;
     207                 :            : 
     208         [ #  # ]:          0 :                 while(pToken!=NULL)
     209                 :            :                 {
     210                 :          0 :                     sal_Bool bDoubleRef=(pToken->GetType()==formula::svDoubleRef);
     211                 :            : 
     212                 :            : 
     213 [ #  # ][ #  # ]:          0 :                     if(pToken->GetType()==formula::svSingleRef || bDoubleRef)
                 [ #  # ]
     214                 :            :                     {
     215                 :          0 :                         ScRange aRange;
     216         [ #  # ]:          0 :                         if(bDoubleRef)
     217                 :            :                         {
     218         [ #  # ]:          0 :                             ScComplexRefData aRef( pToken->GetDoubleRef() );
     219         [ #  # ]:          0 :                             aRef.CalcAbsIfRel( aPos );
     220                 :          0 :                             aRange.aStart.Set( aRef.Ref1.nCol, aRef.Ref1.nRow, aRef.Ref1.nTab );
     221                 :          0 :                             aRange.aEnd.Set( aRef.Ref2.nCol, aRef.Ref2.nRow, aRef.Ref2.nTab );
     222                 :            :                         }
     223                 :            :                         else
     224                 :            :                         {
     225         [ #  # ]:          0 :                             ScSingleRefData aRef( pToken->GetSingleRef() );
     226         [ #  # ]:          0 :                             aRef.CalcAbsIfRel( aPos );
     227                 :          0 :                             aRange.aStart.Set( aRef.nCol, aRef.nRow, aRef.nTab );
     228                 :          0 :                             aRange.aEnd = aRange.aStart;
     229                 :            :                         }
     230         [ #  # ]:          0 :                         ColorData aColName=ScRangeFindList::GetColorName(nIndex++);
     231         [ #  # ]:          0 :                         pTabViewShell->AddHighlightRange(aRange, aColName);
     232                 :            :                     }
     233                 :            : 
     234         [ #  # ]:          0 :                     pToken = static_cast<const ScToken*>(pScTokA->GetNextReference());
     235                 :            :                 }
     236                 :            :             }
     237 [ #  # ][ #  # ]:          0 :             if(pScTokA!=NULL) delete pScTokA;
                 [ #  # ]
     238                 :            :         }
     239                 :            :     }
     240                 :          0 : }
     241                 :            : // -----------------------------------------------------------------------------
     242                 :          0 : void ScFormulaReferenceHelper::HideReference( sal_Bool bDoneRefMode )
     243                 :            : {
     244                 :          0 :     ScViewData* pViewData=ScDocShell::GetViewData();
     245                 :            : 
     246 [ #  # ][ #  # ]:          0 :     if( pViewData && /*!pRefEdit &&*/ bHighLightRef && bEnableColorRef)
                 [ #  # ]
     247                 :            :     {
     248                 :          0 :         ScTabViewShell* pTabViewShell=pViewData->GetViewShell();
     249                 :            : 
     250         [ #  # ]:          0 :         if(pTabViewShell!=NULL)
     251                 :            :         {
     252                 :            :             //  bDoneRefMode is sal_False when called from before SetReference.
     253                 :            :             //  In that case, RefMode was just started and must not be ended now.
     254                 :            : 
     255         [ #  # ]:          0 :             if ( bDoneRefMode )
     256                 :          0 :                 pTabViewShell->DoneRefMode( false );
     257                 :          0 :             pTabViewShell->ClearHighlightRanges();
     258                 :            :         }
     259                 :          0 :         bHighLightRef=false;
     260                 :            :     }
     261                 :          0 : }
     262                 :            : // -----------------------------------------------------------------------------
     263                 :          0 : void ScFormulaReferenceHelper::ShowReference( const XubString& rStr )
     264                 :            : {
     265         [ #  # ]:          0 :     if( /*!pRefEdit &&*/ bEnableColorRef )
     266                 :            :     {
     267   [ #  #  #  #  :          0 :         if( rStr.Search('(')!=STRING_NOTFOUND ||
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
              # ][ #  # ]
     268                 :          0 :             rStr.Search('+')!=STRING_NOTFOUND ||
     269                 :          0 :             rStr.Search('*')!=STRING_NOTFOUND ||
     270                 :          0 :             rStr.Search('-')!=STRING_NOTFOUND ||
     271                 :          0 :             rStr.Search('/')!=STRING_NOTFOUND ||
     272                 :          0 :             rStr.Search('&')!=STRING_NOTFOUND ||
     273                 :          0 :             rStr.Search('<')!=STRING_NOTFOUND ||
     274                 :          0 :             rStr.Search('>')!=STRING_NOTFOUND ||
     275                 :          0 :             rStr.Search('=')!=STRING_NOTFOUND ||
     276                 :          0 :             rStr.Search('^')!=STRING_NOTFOUND)
     277                 :            :         {
     278                 :          0 :             ShowFormulaReference(rStr);
     279                 :            :         }
     280                 :            :         else
     281                 :            :         {
     282                 :          0 :             ShowSimpleReference(rStr);
     283                 :            :         }
     284                 :            :     }
     285                 :          0 : }
     286                 :            : // -----------------------------------------------------------------------------
     287                 :          0 : void ScFormulaReferenceHelper::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton )
     288                 :            : {
     289 [ #  # ][ #  # ]:          0 :     if( !pRefEdit && pEdit )
     290                 :            :     {
     291                 :          0 :         m_pDlg->RefInputStart( pEdit, pButton );
     292                 :            :     }
     293                 :            : 
     294                 :          0 :     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     295         [ #  # ]:          0 :     if( pViewShell )
     296                 :            :     {
     297                 :          0 :         pViewShell->ActiveGrabFocus();
     298         [ #  # ]:          0 :         if( pRefEdit )
     299                 :            :         {
     300                 :          0 :             const ScViewData* pViewData = pViewShell->GetViewData();
     301         [ #  # ]:          0 :             ScDocument* pDoc = pViewData->GetDocument();
     302         [ #  # ]:          0 :             ScRangeList aRangeList;
     303 [ #  # ][ #  # ]:          0 :             if( ParseWithNames( aRangeList, pRefEdit->GetText(), pDoc ) )
         [ #  # ][ #  # ]
     304                 :            :             {
     305 [ #  # ][ #  # ]:          0 :                 if ( !aRangeList.empty() )
     306                 :            :                 {
     307         [ #  # ]:          0 :                     const ScRange* pRange = aRangeList.front();
     308         [ #  # ]:          0 :                     pViewShell->SetTabNo( pRange->aStart.Tab() );
     309                 :          0 :                     pViewShell->MoveCursorAbs(  pRange->aStart.Col(),
     310         [ #  # ]:          0 :                         pRange->aStart.Row(), SC_FOLLOW_JUMP, false, false );
     311                 :          0 :                     pViewShell->MoveCursorAbs( pRange->aEnd.Col(),
     312         [ #  # ]:          0 :                         pRange->aEnd.Row(), SC_FOLLOW_JUMP, sal_True, false );
     313         [ #  # ]:          0 :                     m_pDlg->SetReference( *pRange, pDoc );
     314                 :            :                 }
     315         [ #  # ]:          0 :             }
     316                 :            :         }
     317                 :            :     }
     318                 :          0 : }
     319                 :            : // -----------------------------------------------------------------------------
     320                 :          0 : void ScFormulaReferenceHelper::Init()
     321                 :            : {
     322                 :          0 :     ScViewData* pViewData=ScDocShell::GetViewData();    //! use pScViewShell?
     323         [ #  # ]:          0 :     if ( pViewData )
     324                 :            :     {
     325         [ #  # ]:          0 :         ScDocument* pDoc = pViewData->GetDocument();
     326                 :          0 :         SCCOL nCol = pViewData->GetCurX();
     327                 :          0 :         SCROW nRow = pViewData->GetCurY();
     328                 :          0 :         SCTAB nTab = pViewData->GetTabNo();
     329                 :          0 :         ScAddress aCursorPos( nCol, nRow, nTab );
     330                 :            : 
     331         [ #  # ]:          0 :         String rStrExp;
     332 [ #  # ][ #  # ]:          0 :         pRefCell.reset( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
                 [ #  # ]
     333 [ #  # ][ #  # ]:          0 :         pRefComp.reset( new ScCompiler( pDoc, aCursorPos) );
     334 [ #  # ][ #  # ]:          0 :         pRefComp->SetGrammar( pDoc->GetGrammar() );
     335                 :          0 :         pRefComp->SetCompileForFAP(sal_True);
     336                 :            : 
     337         [ #  # ]:          0 :         nRefTab = nTab;
     338                 :            :     }
     339                 :          0 : }
     340                 :            : // -----------------------------------------------------------------------------
     341                 :          0 : IMPL_LINK( ScFormulaReferenceHelper, AccelSelectHdl, Accelerator *, pSelAccel )
     342                 :            : {
     343         [ #  # ]:          0 :     if ( !pSelAccel )
     344                 :          0 :         return 0;
     345                 :            : 
     346         [ #  # ]:          0 :     switch ( pSelAccel->GetCurKeyCode().GetCode() )
     347                 :            :     {
     348                 :            :         case KEY_RETURN:
     349                 :            :         case KEY_ESCAPE:
     350         [ #  # ]:          0 :             if( pRefEdit )
     351                 :          0 :                 pRefEdit->GrabFocus();
     352                 :          0 :             m_pDlg->RefInputDone( sal_True );
     353                 :          0 :         break;
     354                 :            :     }
     355                 :          0 :     return sal_True;
     356                 :            : }
     357                 :            : //----------------------------------------------------------------------------
     358                 :          0 : void ScFormulaReferenceHelper::RefInputDone( sal_Bool bForced )
     359                 :            : {
     360         [ #  # ]:          0 :     if ( CanInputDone( bForced ) )
     361                 :            :     {
     362         [ #  # ]:          0 :         if (bAccInserted)           // Accelerator wieder abschalten
     363                 :            :         {
     364                 :          0 :             Application::RemoveAccel( pAccel.get() );
     365                 :          0 :             bAccInserted = false;
     366                 :            :         }
     367                 :            : 
     368                 :            :         // Fenstertitel anpassen
     369                 :          0 :         m_pWindow->SetText(sOldDialogText);
     370                 :            : 
     371                 :            :         // Fenster wieder gross
     372                 :          0 :         m_pWindow->SetOutputSizePixel(aOldDialogSize);
     373                 :            : 
     374                 :            :         // pEditCell an alte Position
     375                 :          0 :         pRefEdit->SetPosSizePixel(aOldEditPos, aOldEditSize);
     376                 :            : 
     377                 :            :         // set button position and image
     378         [ #  # ]:          0 :         if( pRefBtn )
     379                 :            :         {
     380                 :          0 :             pRefBtn->SetPosPixel( aOldButtonPos );
     381                 :          0 :             pRefBtn->SetStartImage();
     382                 :            :         }
     383                 :            : 
     384                 :            :         // Alle anderen: Show();
     385                 :          0 :         sal_uInt16 nChildren = m_pWindow->GetChildCount();
     386         [ #  # ]:          0 :         for ( sal_uInt16 i = 0; i < nChildren; i++ )
     387         [ #  # ]:          0 :             if (pHiddenMarks[i])
     388                 :            :             {
     389                 :          0 :                 m_pWindow->GetChild(i)->GetWindow( WINDOW_CLIENT )->Show();
     390                 :            :             }
     391         [ #  # ]:          0 :         delete [] pHiddenMarks;
     392                 :            : 
     393                 :          0 :         pRefEdit = NULL;
     394                 :          0 :         pRefBtn = NULL;
     395                 :            :     }
     396                 :          0 : }
     397                 :            : // -----------------------------------------------------------------------------
     398                 :          0 : void ScFormulaReferenceHelper::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
     399                 :            : {
     400         [ #  # ]:          0 :     if (!pRefEdit)
     401                 :            :     {
     402                 :          0 :         pRefEdit = pEdit;
     403                 :          0 :         pRefBtn  = pButton;
     404                 :            : 
     405                 :            :         // Neuen Fenstertitel basteln
     406         [ #  # ]:          0 :         String sNewDialogText;
     407 [ #  # ][ #  # ]:          0 :         sOldDialogText = m_pWindow->GetText();
                 [ #  # ]
     408         [ #  # ]:          0 :         sNewDialogText  = sOldDialogText;
     409         [ #  # ]:          0 :         sNewDialogText.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
     410                 :            : 
     411                 :            :         // Alle Elemente ausser EditCell und Button verstecken
     412         [ #  # ]:          0 :         sal_uInt16 nChildren = m_pWindow->GetChildCount();
     413         [ #  # ]:          0 :         pHiddenMarks = new sal_Bool [nChildren];
     414         [ #  # ]:          0 :         for (sal_uInt16 i = 0; i < nChildren; i++)
     415                 :            :         {
     416                 :          0 :             pHiddenMarks[i] = false;
     417         [ #  # ]:          0 :             Window* pWin = m_pWindow->GetChild(i);
     418         [ #  # ]:          0 :             pWin = pWin->GetWindow( WINDOW_CLIENT );
     419         [ #  # ]:          0 :             if (pWin == (Window*)pRefEdit)
     420                 :            :             {
     421 [ #  # ][ #  # ]:          0 :                 sNewDialogText += m_pWindow->GetChild(i-1)->GetWindow( WINDOW_CLIENT )->GetText();
         [ #  # ][ #  # ]
                 [ #  # ]
     422                 :            :             }
     423         [ #  # ]:          0 :             else if (pWin == (Window*)pRefBtn)
     424                 :            :                 ;   // do nothing
     425 [ #  # ][ #  # ]:          0 :             else if (pWin->IsVisible())
     426                 :            :             {
     427                 :          0 :                 pHiddenMarks[i] = sal_True;
     428         [ #  # ]:          0 :                 pWin->Hide();
     429                 :            :             }
     430                 :            :         }
     431                 :            : 
     432                 :            :         // Alte Daten merken
     433                 :          0 :         aOldDialogSize = m_pWindow->GetOutputSizePixel();
     434         [ #  # ]:          0 :         aOldEditPos = pRefEdit->GetPosPixel();
     435         [ #  # ]:          0 :         aOldEditSize = pRefEdit->GetSizePixel();
     436         [ #  # ]:          0 :         if (pRefBtn)
     437         [ #  # ]:          0 :             aOldButtonPos = pRefBtn->GetPosPixel();
     438                 :            : 
     439                 :            :         // Edit-Feld verschieben und anpassen
     440                 :          0 :         Size aNewDlgSize(aOldDialogSize.Width(), aOldEditSize.Height());
     441                 :          0 :         Size aNewEditSize(aNewDlgSize);
     442                 :          0 :         long nOffset = 0;
     443         [ #  # ]:          0 :         if (pRefBtn)
     444                 :            :         {
     445         [ #  # ]:          0 :             aNewEditSize.Width() -= pRefBtn->GetSizePixel().Width();
     446                 :          0 :             aNewEditSize.Width() -= aOldButtonPos.X() - (aOldEditPos.X()+aOldEditSize.Width());
     447                 :            : 
     448         [ #  # ]:          0 :             long nHeight = pRefBtn->GetSizePixel().Height();
     449         [ #  # ]:          0 :             if ( nHeight > aOldEditSize.Height() )
     450                 :            :             {
     451                 :          0 :                 aNewDlgSize.Height() = nHeight;
     452                 :          0 :                 nOffset = (nHeight-aOldEditSize.Height()) / 2;
     453                 :            :             }
     454                 :          0 :             aNewEditSize.Width() -= nOffset;
     455                 :            :         }
     456         [ #  # ]:          0 :         pRefEdit->SetPosSizePixel(Point(nOffset, nOffset), aNewEditSize);
     457                 :            : 
     458                 :            :         // set button position and image
     459         [ #  # ]:          0 :         if( pRefBtn )
     460                 :            :         {
     461 [ #  # ][ #  # ]:          0 :             pRefBtn->SetPosPixel( Point( aOldDialogSize.Width() - pRefBtn->GetSizePixel().Width(), 0 ) );
     462         [ #  # ]:          0 :             pRefBtn->SetEndImage();
     463                 :            :         }
     464                 :            : 
     465                 :            :         // Fenster verkleinern
     466         [ #  # ]:          0 :         m_pWindow->SetOutputSizePixel(aNewDlgSize);
     467                 :            : 
     468                 :            :         // Fenstertitel anpassen
     469 [ #  # ][ #  # ]:          0 :         m_pWindow->SetText( MnemonicGenerator::EraseAllMnemonicChars( sNewDialogText ) );
                 [ #  # ]
     470                 :            : 
     471         [ #  # ]:          0 :         if (!pAccel.get())
     472                 :            :         {
     473 [ #  # ][ #  # ]:          0 :             pAccel.reset( new Accelerator );
     474         [ #  # ]:          0 :             pAccel->InsertItem( 1, KeyCode( KEY_RETURN ) );
     475         [ #  # ]:          0 :             pAccel->InsertItem( 2, KeyCode( KEY_ESCAPE ) );
     476         [ #  # ]:          0 :             pAccel->SetSelectHdl( LINK( this, ScFormulaReferenceHelper, AccelSelectHdl ) );
     477                 :            :         }
     478         [ #  # ]:          0 :         Application::InsertAccel( pAccel.get() );
     479         [ #  # ]:          0 :         bAccInserted = true;
     480                 :            :     }
     481                 :          0 : }
     482                 :            : // -----------------------------------------------------------------------------
     483                 :          0 : void ScFormulaReferenceHelper::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton )
     484                 :            : {
     485         [ #  # ]:          0 :     if( pEdit )
     486                 :            :     {
     487         [ #  # ]:          0 :         if( pRefEdit == pEdit )                 // is this the active ref edit field?
     488                 :            :         {
     489                 :          0 :             pRefEdit->GrabFocus();              // before RefInputDone()
     490                 :          0 :             m_pDlg->RefInputDone( sal_True );               // finish ref input
     491                 :            :         }
     492                 :            :         else
     493                 :            :         {
     494                 :          0 :             m_pDlg->RefInputDone( sal_True );               // another active ref edit?
     495                 :          0 :             m_pDlg->RefInputStart( pEdit, pButton );    // start ref input
     496                 :            :             // pRefEdit might differ from pEdit after RefInputStart() (i.e. ScFormulaDlg)
     497         [ #  # ]:          0 :             if( pRefEdit )
     498                 :          0 :                 pRefEdit->GrabFocus();
     499                 :            :         }
     500                 :            :     }
     501                 :          0 : }
     502                 :            : // -----------------------------------------------------------------------------
     503                 :          0 : sal_Bool ScFormulaReferenceHelper::DoClose( sal_uInt16 nId )
     504                 :            : {
     505                 :          0 :     SfxApplication* pSfxApp = SFX_APP();
     506                 :            : 
     507                 :          0 :     SetDispatcherLock( false );         //! here and in dtor ?
     508                 :            : 
     509                 :          0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     510 [ #  # ][ #  # ]:          0 :     if ( pViewFrm && pViewFrm->HasChildWindow(FID_INPUTLINE_STATUS) )
                 [ #  # ]
     511                 :            :     {
     512                 :            :         //  Die Eingabezeile wird per ToolBox::Disable disabled, muss darum auch
     513                 :            :         //  per ToolBox::Enable wieder aktiviert werden (vor dem Enable des AppWindow),
     514                 :            :         //  damit die Buttons auch wieder enabled gezeichnet werden.
     515                 :          0 :         SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_INPUTLINE_STATUS);
     516         [ #  # ]:          0 :         if (pChild)
     517                 :            :         {
     518                 :          0 :             ScInputWindow* pWin = (ScInputWindow*)pChild->GetWindow();
     519                 :          0 :             pWin->Enable();
     520                 :            :         }
     521                 :            :     }
     522                 :            : 
     523                 :            :     // find parent view frame to close dialog
     524                 :          0 :     SfxViewFrame* pMyViewFrm = NULL;
     525         [ #  # ]:          0 :     if ( m_pBindings )
     526                 :            :     {
     527                 :          0 :         SfxDispatcher* pMyDisp = m_pBindings->GetDispatcher();
     528         [ #  # ]:          0 :         if (pMyDisp)
     529                 :          0 :             pMyViewFrm = pMyDisp->GetFrame();
     530                 :            :     }
     531                 :          0 :     SC_MOD()->SetRefDialog( nId, false, pMyViewFrm );
     532                 :            : 
     533         [ #  # ]:          0 :     pSfxApp->Broadcast( SfxSimpleHint( FID_KILLEDITVIEW ) );
     534                 :            : 
     535                 :          0 :     ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
     536         [ #  # ]:          0 :     if ( pScViewShell )
     537                 :          0 :         pScViewShell->UpdateInputHandler(sal_True);
     538                 :            : 
     539                 :          0 :     return sal_True;
     540                 :            : }
     541                 :          0 : void ScFormulaReferenceHelper::SetDispatcherLock( sal_Bool bLock )
     542                 :            : {
     543                 :            :     //  lock / unlock only the dispatchers of Calc documents
     544                 :            : 
     545         [ #  # ]:          0 :     TypeId aType(TYPE(ScDocShell));
     546         [ #  # ]:          0 :     ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
     547         [ #  # ]:          0 :     while( pDocShell )
     548                 :            :     {
     549         [ #  # ]:          0 :         SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
     550         [ #  # ]:          0 :         while( pFrame )
     551                 :            :         {
     552                 :          0 :             SfxDispatcher* pDisp = pFrame->GetDispatcher();
     553         [ #  # ]:          0 :             if (pDisp)
     554         [ #  # ]:          0 :                 pDisp->Lock( bLock );
     555                 :            : 
     556         [ #  # ]:          0 :             pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
     557                 :            :         }
     558         [ #  # ]:          0 :         pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
     559                 :            :     }
     560                 :            : 
     561                 :            :     //  if a new view is created while the dialog is open,
     562                 :            :     //  that view's dispatcher is locked when trying to create the dialog
     563                 :            :     //  for that view (ScTabViewShell::CreateRefDialog)
     564                 :          0 : }
     565                 :            : // -----------------------------------------------------------------------------
     566                 :          0 : void ScFormulaReferenceHelper::ViewShellChanged(ScTabViewShell* /* pScViewShell */)
     567                 :            : {
     568                 :          0 :     enableInput( false );
     569                 :            : 
     570                 :          0 :     EnableSpreadsheets();
     571                 :          0 : }
     572                 :          0 : void ScFormulaReferenceHelper::EnableSpreadsheets(sal_Bool bFlag, sal_Bool bChildren)
     573                 :            : {
     574         [ #  # ]:          0 :     TypeId aType(TYPE(ScDocShell));
     575         [ #  # ]:          0 :     ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
     576         [ #  # ]:          0 :     while( pDocShell )
     577                 :            :     {
     578         [ #  # ]:          0 :         SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
     579         [ #  # ]:          0 :         while( pFrame )
     580                 :            :         {
     581                 :            :             //  enable everything except InPlace, including bean frames
     582 [ #  # ][ #  # ]:          0 :             if ( !pFrame->GetFrame().IsInPlace() )
                 [ #  # ]
     583                 :            :             {
     584         [ #  # ]:          0 :                 SfxViewShell* p = pFrame->GetViewShell();
     585 [ #  # ][ #  # ]:          0 :                 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
         [ #  # ][ #  # ]
     586         [ #  # ]:          0 :                 if(pViewSh!=NULL)
     587                 :            :                 {
     588                 :          0 :                     Window *pWin=pViewSh->GetWindow();
     589         [ #  # ]:          0 :                     if(pWin)
     590                 :            :                     {
     591         [ #  # ]:          0 :                         Window *pParent=pWin->GetParent();
     592         [ #  # ]:          0 :                         if(pParent)
     593                 :            :                         {
     594         [ #  # ]:          0 :                             pParent->EnableInput(bFlag,false);
     595         [ #  # ]:          0 :                             if(bChildren)
     596         [ #  # ]:          0 :                                 pViewSh->EnableRefInput(bFlag);
     597                 :            :                         }
     598                 :            :                     }
     599                 :            :                 }
     600                 :            :             }
     601         [ #  # ]:          0 :             pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
     602                 :            :         }
     603                 :            : 
     604         [ #  # ]:          0 :         pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
     605                 :            :     }
     606                 :          0 : }
     607                 :            : 
     608                 :            : //----------------------------------------------------------------------------
     609                 :            : 
     610                 :            : 
     611                 :            : 
     612                 :          0 : void lcl_InvalidateWindows()
     613                 :            : {
     614         [ #  # ]:          0 :     TypeId aType(TYPE(ScDocShell));
     615         [ #  # ]:          0 :     ScDocShell* pDocShell = (ScDocShell*)SfxObjectShell::GetFirst(&aType);
     616         [ #  # ]:          0 :     while( pDocShell )
     617                 :            :     {
     618         [ #  # ]:          0 :         SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
     619         [ #  # ]:          0 :         while( pFrame )
     620                 :            :         {
     621                 :            :             //  enable everything except InPlace, including bean frames
     622 [ #  # ][ #  # ]:          0 :             if ( !pFrame->GetFrame().IsInPlace() )
                 [ #  # ]
     623                 :            :             {
     624         [ #  # ]:          0 :                 SfxViewShell* p = pFrame->GetViewShell();
     625 [ #  # ][ #  # ]:          0 :                 ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
         [ #  # ][ #  # ]
     626         [ #  # ]:          0 :                 if(pViewSh!=NULL)
     627                 :            :                 {
     628                 :          0 :                     Window *pWin=pViewSh->GetWindow();
     629         [ #  # ]:          0 :                     if(pWin)
     630                 :            :                     {
     631         [ #  # ]:          0 :                         Window *pParent=pWin->GetParent();
     632         [ #  # ]:          0 :                         if(pParent)
     633         [ #  # ]:          0 :                             pParent->Invalidate();
     634                 :            :                     }
     635                 :            :                 }
     636                 :            :             }
     637         [ #  # ]:          0 :             pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
     638                 :            :         }
     639                 :            : 
     640         [ #  # ]:          0 :         pDocShell = (ScDocShell*)SfxObjectShell::GetNext(*pDocShell, &aType);
     641                 :            :     }
     642                 :          0 : }
     643                 :            : //----------------------------------------------------------------------------
     644                 :            : 
     645                 :          0 : void lcl_HideAllReferences()
     646                 :            : {
     647         [ #  # ]:          0 :     TypeId aScType = TYPE(ScTabViewShell);
     648         [ #  # ]:          0 :     SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
     649         [ #  # ]:          0 :     while ( pSh )
     650                 :            :     {
     651         [ #  # ]:          0 :         ((ScTabViewShell*)pSh)->ClearHighlightRanges();
     652         [ #  # ]:          0 :         pSh = SfxViewShell::GetNext( *pSh, &aScType );
     653                 :            :     }
     654                 :          0 : }
     655                 :            : 
     656                 :            : //============================================================================
     657                 :            : //The class of ScAnyRefDlg is rewritten by PengYunQuan for Validity Cell Range Picker
     658                 :            : //  class ScRefHandler
     659                 :            : //----------------------------------------------------------------------------
     660                 :            : 
     661                 :          0 : ScRefHandler::ScRefHandler( Window &rWindow, SfxBindings* pB/*, SfxChildWindow* pCW,
     662                 :            :                           Window* pParent, sal_uInt16 nResId*/, bool bBindRef )
     663                 :            :     :   //SfxModelessDialog ( pB, pCW, pParent, ScResId( nResId ) ),
     664                 :            :         m_rWindow( rWindow ),
     665                 :            :         m_bInRefMode( false ),
     666                 :            :         m_aHelper(this,pB),
     667                 :            :         pMyBindings( pB ),
     668 [ #  # ][ #  # ]:          0 :         pActiveWin(NULL)
                 [ #  # ]
     669                 :            : {
     670                 :          0 :     m_aHelper.SetWindow(/*this*/&m_rWindow);
     671 [ #  # ][ #  # ]:          0 :     if(m_rWindow.GetHelpId().isEmpty())                //Hack, da im SfxModelessDialog die HelpId
     672 [ #  # ][ #  # ]:          0 :         m_rWindow.SetHelpId(m_rWindow.GetUniqueId());   //fuer einen ModelessDialog entfernt und
     673                 :            :                                     //in eine UniqueId gewandelt wird, machen
     674                 :            :                                     //wir das an dieser Stelle rueckgaengig.
     675         [ #  # ]:          0 :     aTimer.SetTimeout(200);
     676         [ #  # ]:          0 :     aTimer.SetTimeoutHdl(LINK( this, ScRefHandler, UpdateFocusHdl));
     677                 :            : 
     678 [ #  # ][ #  # ]:          0 :     if( bBindRef ) EnterRefMode();
     679                 :          0 : }
     680                 :            : 
     681                 :          0 : bool ScRefHandler::EnterRefMode()
     682                 :            : {
     683         [ #  # ]:          0 :     if( m_bInRefMode ) return false;
     684                 :            : 
     685                 :          0 :     SC_MOD()->InputEnterHandler();
     686                 :            : 
     687                 :          0 :     ScTabViewShell* pScViewShell = NULL;
     688                 :            : 
     689                 :            :     // title has to be from the view that opened the dialog,
     690                 :            :     // even if it's not the current view
     691                 :            : 
     692                 :          0 :     SfxObjectShell* pParentDoc = NULL;
     693         [ #  # ]:          0 :     if ( pMyBindings )
     694                 :            :     {
     695                 :          0 :         SfxDispatcher* pMyDisp = pMyBindings->GetDispatcher();
     696         [ #  # ]:          0 :         if (pMyDisp)
     697                 :            :         {
     698                 :          0 :             SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
     699         [ #  # ]:          0 :             if (pMyViewFrm)
     700                 :            :             {
     701 [ #  # ][ #  # ]:          0 :                 pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() );
     702         [ #  # ]:          0 :                 if( pScViewShell )
     703                 :          0 :                     pScViewShell->UpdateInputHandler(sal_True);
     704                 :          0 :                 pParentDoc = pMyViewFrm->GetObjectShell();
     705                 :            :             }
     706                 :            :         }
     707                 :            :     }
     708 [ #  # ][ #  # ]:          0 :     if ( !pParentDoc && pScViewShell )                  // use current only if above fails
     709                 :          0 :         pParentDoc = pScViewShell->GetObjectShell();
     710         [ #  # ]:          0 :     if ( pParentDoc )
     711         [ #  # ]:          0 :         aDocName = pParentDoc->GetTitle();
     712                 :            : 
     713                 :          0 :     ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
     714                 :            : 
     715                 :            :     OSL_ENSURE( pInputHdl, "Missing input handler :-/" );
     716                 :            : 
     717         [ #  # ]:          0 :     if ( pInputHdl )
     718                 :          0 :         pInputHdl->NotifyChange( NULL );
     719                 :            : 
     720                 :          0 :     m_aHelper.enableInput( false );
     721                 :            : 
     722                 :          0 :     m_aHelper.EnableSpreadsheets();
     723                 :            : 
     724                 :          0 :     m_aHelper.Init();
     725                 :            : 
     726                 :          0 :     m_aHelper.SetDispatcherLock( true );
     727                 :            : 
     728                 :          0 :     return m_bInRefMode = true;
     729                 :            : }
     730                 :            : 
     731                 :            : //----------------------------------------------------------------------------
     732                 :            : 
     733 [ #  # ][ #  # ]:          0 : ScRefHandler::~ScRefHandler()
                 [ #  # ]
     734                 :            : {
     735         [ #  # ]:          0 :     LeaveRefMode();
     736         [ #  # ]:          0 : }
     737                 :            : 
     738                 :          0 : bool ScRefHandler::LeaveRefMode()
     739                 :            : {
     740         [ #  # ]:          0 :     if( !m_bInRefMode ) return false;
     741                 :            : 
     742                 :          0 :     lcl_HideAllReferences();
     743                 :            : 
     744 [ #  # ][ #  # ]:          0 :     if( Dialog *pDlg = dynamic_cast<Dialog*>( static_cast<Window*>(*this) ) )
     745                 :          0 :         pDlg->SetModalInputMode(false);
     746                 :          0 :     SetDispatcherLock( false );         //! here and in DoClose ?
     747                 :            : 
     748                 :          0 :     ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell();
     749         [ #  # ]:          0 :     if( pScViewShell )
     750                 :          0 :         pScViewShell->UpdateInputHandler(sal_True);
     751                 :            : 
     752                 :          0 :     lcl_InvalidateWindows();
     753                 :            : 
     754                 :          0 :     m_bInRefMode = false;
     755                 :          0 :     return true;
     756                 :            : }
     757                 :            : 
     758                 :            : //----------------------------------------------------------------------------
     759                 :            : 
     760                 :          0 : void ScRefHandler::SwitchToDocument()
     761                 :            : {
     762         [ #  # ]:          0 :     ScTabViewShell* pCurrent = ScTabViewShell::GetActiveViewShell();
     763         [ #  # ]:          0 :     if (pCurrent)
     764                 :            :     {
     765         [ #  # ]:          0 :         SfxObjectShell* pObjSh = pCurrent->GetObjectShell();
     766 [ #  # ][ #  # ]:          0 :         if ( pObjSh && pObjSh->GetTitle() == aDocName )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     767                 :            :         {
     768                 :            :             //  right document already visible -> nothing to do
     769                 :            :             return;
     770                 :            :         }
     771                 :            :     }
     772                 :            : 
     773         [ #  # ]:          0 :     TypeId aScType = TYPE(ScTabViewShell);
     774         [ #  # ]:          0 :     SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
     775         [ #  # ]:          0 :     while ( pSh )
     776                 :            :     {
     777         [ #  # ]:          0 :         SfxObjectShell* pObjSh = pSh->GetObjectShell();
     778 [ #  # ][ #  # ]:          0 :         if ( pObjSh && pObjSh->GetTitle() == aDocName )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     779                 :            :         {
     780                 :            :             //  switch to first TabViewShell for document
     781         [ #  # ]:          0 :             ((ScTabViewShell*)pSh)->SetActive();
     782                 :            :             return;
     783                 :            :         }
     784         [ #  # ]:          0 :         pSh = SfxViewShell::GetNext( *pSh, &aScType );
     785                 :            :     }
     786                 :            : }
     787                 :            : 
     788                 :            : //----------------------------------------------------------------------------
     789                 :            : 
     790                 :          0 : sal_Bool ScRefHandler::IsDocAllowed(SfxObjectShell* pDocSh) const   // pDocSh may be 0
     791                 :            : {
     792                 :            :     //  default: allow only same document (overridden in function dialog)
     793         [ #  # ]:          0 :     String aCmpName;
     794         [ #  # ]:          0 :     if ( pDocSh )
     795 [ #  # ][ #  # ]:          0 :         aCmpName = pDocSh->GetTitle();
                 [ #  # ]
     796                 :            : 
     797                 :            :     //  if aDocName isn't initialized, allow
     798 [ #  # ][ #  # ]:          0 :     return ( aDocName.Len() == 0 || aDocName == aCmpName );
         [ #  # ][ #  # ]
     799                 :            : }
     800                 :            : 
     801                 :            : //----------------------------------------------------------------------------
     802                 :            : 
     803                 :          0 : sal_Bool ScRefHandler::IsRefInputMode() const
     804                 :            : {
     805                 :          0 :     return m_rWindow.IsVisible(); // nur wer sichtbar ist kann auch Referenzen bekommen
     806                 :            : }
     807                 :            : 
     808                 :            : //----------------------------------------------------------------------------
     809                 :            : 
     810                 :          0 : sal_Bool ScRefHandler::DoClose( sal_uInt16 nId )
     811                 :            : {
     812                 :          0 :     m_aHelper.DoClose(nId);
     813                 :          0 :     return sal_True;
     814                 :            : }
     815                 :            : 
     816                 :          0 : void ScRefHandler::SetDispatcherLock( sal_Bool bLock )
     817                 :            : {
     818                 :          0 :     m_aHelper.SetDispatcherLock( bLock );
     819                 :          0 : }
     820                 :            : 
     821                 :            : //----------------------------------------------------------------------------
     822                 :            : 
     823                 :          0 : void ScRefHandler::ViewShellChanged(ScTabViewShell*  pScViewShell )
     824                 :            : {
     825                 :          0 :     m_aHelper.ViewShellChanged(pScViewShell);
     826                 :          0 : }
     827                 :            : 
     828                 :            : //----------------------------------------------------------------------------
     829                 :            : 
     830                 :          0 : void ScRefHandler::AddRefEntry()
     831                 :            : {
     832                 :            :     //  wenn nicht ueberladen, gibt es keine Mehrfach-Referenzen
     833                 :          0 : }
     834                 :            : 
     835                 :            : //----------------------------------------------------------------------------
     836                 :            : 
     837                 :          0 : sal_Bool ScRefHandler::IsTableLocked() const
     838                 :            : {
     839                 :            :     // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
     840                 :            : 
     841                 :          0 :     return false;
     842                 :            : }
     843                 :            : 
     844                 :            : //----------------------------------------------------------------------------
     845                 :            : //
     846                 :            : //  RefInputStart/Done: Zoom-In (AutoHide) auf einzelnes Feld
     847                 :            : //  (per Button oder Bewegung)
     848                 :            : //
     849                 :            : //----------------------------------------------------------------------------
     850                 :            : 
     851                 :          0 : void ScRefHandler::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
     852                 :            : {
     853                 :          0 :     m_aHelper.RefInputStart( pEdit, pButton );
     854                 :          0 : }
     855                 :            : 
     856                 :            : 
     857                 :          0 : void ScRefHandler::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton )
     858                 :            : {
     859                 :          0 :     m_aHelper.ToggleCollapsed( pEdit, pButton );
     860                 :          0 : }
     861                 :            : 
     862                 :          0 : void ScRefHandler::preNotify(const NotifyEvent& rNEvt, const bool bBindRef)
     863                 :            : {
     864 [ #  # ][ #  # ]:          0 :     if( bBindRef || m_bInRefMode )
     865                 :            :     {
     866                 :          0 :         sal_uInt16 nSwitch=rNEvt.GetType();
     867         [ #  # ]:          0 :         if(nSwitch==EVENT_GETFOCUS)
     868                 :            :         {
     869                 :          0 :             pActiveWin=rNEvt.GetWindow();
     870                 :            :         }
     871                 :            :     }
     872                 :          0 : }
     873                 :            : 
     874                 :          0 : void ScRefHandler::stateChanged(const StateChangedType nStateChange, const bool bBindRef)
     875                 :            : {
     876 [ #  # ][ #  # ]:          0 :     if( !bBindRef && !m_bInRefMode ) return;
     877                 :            : 
     878         [ #  # ]:          0 :     if(nStateChange == STATE_CHANGE_VISIBLE)
     879                 :            :     {
     880         [ #  # ]:          0 :         if(m_rWindow.IsVisible())
     881                 :            :         {
     882                 :          0 :             m_aHelper.enableInput( false );
     883                 :          0 :             m_aHelper.EnableSpreadsheets();
     884                 :          0 :             m_aHelper.SetDispatcherLock( sal_True );
     885                 :          0 :             aTimer.Start();
     886                 :            :         }
     887                 :            :         else
     888                 :            :         {
     889                 :          0 :             m_aHelper.enableInput( sal_True );
     890                 :          0 :             m_aHelper.SetDispatcherLock( false );           /*//! here and in DoClose ?*/
     891                 :            :         }
     892                 :            :     }
     893                 :            : }
     894                 :            : 
     895                 :          0 : IMPL_LINK_NOARG(ScRefHandler, UpdateFocusHdl)
     896                 :            : {
     897         [ #  # ]:          0 :     if (pActiveWin)
     898                 :            :     {
     899                 :          0 :         pActiveWin->GrabFocus();
     900                 :            :     }
     901                 :          0 :     return 0;
     902                 :            : }
     903                 :            : // -----------------------------------------------------------------------------
     904                 :          0 : bool ScRefHandler::ParseWithNames( ScRangeList& rRanges, const String& rStr, ScDocument* pDoc )
     905                 :            : {
     906                 :          0 :     return m_aHelper.ParseWithNames( rRanges, rStr, pDoc );
     907                 :            : }
     908                 :            : // -----------------------------------------------------------------------------
     909                 :          0 : void ScRefHandler::HideReference( sal_Bool bDoneRefMode )
     910                 :            : {
     911                 :          0 :     m_aHelper.HideReference( bDoneRefMode );
     912                 :          0 : }
     913                 :            : // -----------------------------------------------------------------------------
     914                 :          0 : void ScRefHandler::ShowReference( const XubString& rStr )
     915                 :            : {
     916                 :          0 :     m_aHelper.ShowReference( rStr );
     917                 :          0 : }
     918                 :            : // -----------------------------------------------------------------------------
     919                 :          0 : void ScRefHandler::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton )
     920                 :            : {
     921                 :          0 :     m_aHelper.ReleaseFocus( pEdit,pButton );
     922                 :          0 : }
     923                 :            : //----------------------------------------------------------------------------
     924                 :          0 : void ScRefHandler::RefInputDone( sal_Bool bForced )
     925                 :            : {
     926                 :          0 :     m_aHelper.RefInputDone( bForced );
     927                 :          0 : }
     928                 :            : 
     929                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10