LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/app - scmod.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 274 1124 24.4 %
Date: 2013-07-09 Functions: 48 97 49.5 %
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 <config_features.h>
      21             : 
      22             : #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
      23             : #include <comphelper/processfactory.hxx>
      24             : 
      25             : #include "scitems.hxx"
      26             : #include <sfx2/app.hxx>
      27             : #include <editeng/eeitem.hxx>
      28             : 
      29             : #include <editeng/flditem.hxx>
      30             : #include <editeng/outliner.hxx>
      31             : #include <basic/sbstar.hxx>
      32             : 
      33             : #include <sfx2/sfxdlg.hxx>
      34             : #include <sfx2/viewfrm.hxx>
      35             : #include <sfx2/objface.hxx>
      36             : 
      37             : #include "IAnyRefDialog.hxx"
      38             : #include "anyrefdg.hxx"
      39             : 
      40             : #include <svtools/ehdl.hxx>
      41             : #include <svtools/accessibilityoptions.hxx>
      42             : #include <svl/ctloptions.hxx>
      43             : #include <unotools/useroptions.hxx>
      44             : #include <vcl/status.hxx>
      45             : #include <sfx2/bindings.hxx>
      46             : #include <sfx2/request.hxx>
      47             : #include <sfx2/printer.hxx>
      48             : #include <editeng/langitem.hxx>
      49             : #include <svtools/colorcfg.hxx>
      50             : 
      51             : #include <svl/whiter.hxx>
      52             : #include <svx/selctrl.hxx>
      53             : #include <svx/insctrl.hxx>
      54             : #include <svx/zoomctrl.hxx>
      55             : #include <svx/modctrl.hxx>
      56             : #include <svx/pszctrl.hxx>
      57             : #include <svx/zoomsliderctrl.hxx>
      58             : #include <vcl/msgbox.hxx>
      59             : #include <svl/inethist.hxx>
      60             : #include <vcl/waitobj.hxx>
      61             : #include <svx/svxerr.hxx>
      62             : #include <tools/diagnose_ex.h>
      63             : 
      64             : 
      65             : #include "scmod.hxx"
      66             : #include "global.hxx"
      67             : #include "viewopti.hxx"
      68             : #include "docoptio.hxx"
      69             : #include "appoptio.hxx"
      70             : #include "defaultsoptions.hxx"
      71             : #include "formulaopt.hxx"
      72             : #include "inputopt.hxx"
      73             : #include "printopt.hxx"
      74             : #include "navicfg.hxx"
      75             : #include "addincfg.hxx"
      76             : #include "tabvwsh.hxx"
      77             : #include "prevwsh.hxx"
      78             : #include "docsh.hxx"
      79             : #include "drwlayer.hxx"
      80             : #include "uiitems.hxx"
      81             : #include "sc.hrc"
      82             : #include "cfgids.hxx"
      83             : #include "inputhdl.hxx"
      84             : #include "inputwin.hxx"
      85             : #include "msgpool.hxx"
      86             : #include "scresid.hxx"
      87             : #include "dwfunctr.hxx"
      88             : #include "formdata.hxx"
      89             : #include "tpprint.hxx"
      90             : #include "tpdefaults.hxx"
      91             : #include "transobj.hxx"
      92             : #include "detfunc.hxx"
      93             : #include "preview.hxx"
      94             : #include "dragdata.hxx"
      95             : #include "clipdata.hxx"
      96             : #include "markdata.hxx"
      97             : 
      98             : #include <svx/xmlsecctrl.hxx>
      99             : 
     100             : #define ScModule
     101             : #include "scslots.hxx"
     102             : 
     103             : #include "scabstdlg.hxx"
     104             : #include "formula/errorcodes.hxx"
     105             : #include "formulagroup.hxx"
     106             : 
     107             : #define SC_IDLE_MIN     150
     108             : #define SC_IDLE_MAX     3000
     109             : #define SC_IDLE_STEP    75
     110             : #define SC_IDLE_COUNT   50
     111             : 
     112             : static sal_uInt16 nIdleCount = 0;
     113             : 
     114             : //------------------------------------------------------------------
     115             : 
     116        6777 : SFX_IMPL_INTERFACE( ScModule, SfxShell, ScResId(RID_APPTITLE) )
     117             : {
     118          62 :     SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_APPLICATION | SFX_VISIBILITY_DESKTOP | SFX_VISIBILITY_STANDARD | SFX_VISIBILITY_CLIENT | SFX_VISIBILITY_VIEWER,
     119          31 :                                 ScResId(RID_OBJECTBAR_APP) );
     120          31 :     SFX_STATUSBAR_REGISTRATION( ScResId(SCCFG_STATUSBAR) );     // nur ID wichtig
     121          31 : }
     122             : 
     123             : //------------------------------------------------------------------
     124             : 
     125          31 : ScModule::ScModule( SfxObjectFactory* pFact ) :
     126             :     SfxModule( SfxApplication::CreateResManager( "sc" ), false, pFact, NULL ),
     127          31 :     mpDragData(new ScDragData),
     128          31 :     mpClipData(new ScClipData),
     129             :     pSelTransfer( NULL ),
     130             :     pMessagePool( NULL ),
     131             :     pRefInputHandler( NULL ),
     132             :     pViewCfg( NULL ),
     133             :     pDocCfg( NULL ),
     134             :     pAppCfg( NULL ),
     135             :     pDefaultsCfg( NULL ),
     136             :     pFormulaCfg( NULL ),
     137             :     pInputCfg( NULL ),
     138             :     pPrintCfg( NULL ),
     139             :     pNavipiCfg( NULL ),
     140             :     pAddInCfg( NULL ),
     141             :     pColorConfig( NULL ),
     142             :     pAccessOptions( NULL ),
     143             :     pCTLOptions( NULL ),
     144             :     pUserOptions( NULL ),
     145             :     pErrorHdl( NULL ),
     146             :     pFormEditData( NULL ),
     147             :     nCurRefDlgId( 0 ),
     148             :     bIsWaterCan( false ),
     149             :     bIsInEditCommand( false ),
     150             :     bIsInExecuteDrop( false ),
     151             :     mbIsInSharedDocLoading( false ),
     152          93 :     mbIsInSharedDocSaving( false )
     153             : {
     154             :     //  im ctor ist der ResManager (DLL-Daten) noch nicht initialisiert!
     155          31 :     SetName(OUString("StarCalc"));       // for Basic
     156             : 
     157          31 :     ResetDragObject();
     158          31 :     SetClipObject( NULL, NULL );
     159             : 
     160             :     //  InputHandler braucht nicht mehr angelegt zu werden
     161             : 
     162             :     //  ErrorHandler anlegen - war in Init()
     163             :     //  zwischen OfficeApplication::Init und ScGlobal::Init
     164          31 :     SvxErrorHandler::ensure();
     165             :     pErrorHdl    = new SfxErrorHandler( RID_ERRHDLSC,
     166             :                                         ERRCODE_AREA_SC,
     167             :                                         ERRCODE_AREA_APP2-1,
     168          31 :                                         GetResMgr() );
     169             : 
     170          31 :     aSpellTimer.SetTimeout(10);
     171          31 :     aSpellTimer.SetTimeoutHdl( LINK( this, ScModule, SpellTimerHdl ) );
     172          31 :     aIdleTimer.SetTimeout(SC_IDLE_MIN);
     173          31 :     aIdleTimer.SetTimeoutHdl( LINK( this, ScModule, IdleHandler ) );
     174          31 :     aIdleTimer.Start();
     175             : 
     176          31 :     pMessagePool = new ScMessagePool;
     177          31 :     pMessagePool->FreezeIdRanges();
     178          31 :     SetPool( pMessagePool );
     179          31 :     ScGlobal::InitTextHeight( pMessagePool );
     180             : 
     181          31 :     StartListening( *SFX_APP() );       // for SFX_HINT_DEINITIALIZING
     182             : 
     183             :     // initialize formula grouping
     184          31 :     sc::FormulaGroupInterpreter::getStatic();
     185          31 : }
     186             : 
     187          27 : ScModule::~ScModule()
     188             : {
     189             :     OSL_ENSURE( !pSelTransfer, "Selection Transfer object not deleted" );
     190             : 
     191             :     //  InputHandler braucht nicht mehr geloescht zu werden (gibt keinen an der App mehr)
     192             : 
     193           9 :     SfxItemPool::Free(pMessagePool);
     194             : 
     195           9 :     DELETEZ( pFormEditData );
     196             : 
     197           9 :     delete mpDragData;
     198           9 :     delete mpClipData;
     199           9 :     delete pErrorHdl;
     200             : 
     201           9 :     ScGlobal::Clear();      // ruft auch ScDocumentPool::DeleteVersionMaps();
     202             : 
     203           9 :     DeleteCfg();            // wurde mal aus Exit() gerufen
     204          18 : }
     205             : 
     206             : //------------------------------------------------------------------
     207           0 : void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster* p, sal_uInt32 )
     208             : {
     209           0 :     if ( p == pColorConfig || p == pAccessOptions )
     210             :     {
     211             :         //  Test if detective objects have to be updated with new colors
     212             :         //  (if the detective colors haven't been used yet, there's nothing to update)
     213           0 :         if ( ScDetectiveFunc::IsColorsInitialized() )
     214             :         {
     215           0 :             const svtools::ColorConfig& rColors = GetColorConfig();
     216             :             sal_Bool bArrows =
     217           0 :                 ( ScDetectiveFunc::GetArrowColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVE).nColor ||
     218           0 :                   ScDetectiveFunc::GetErrorColor() != (ColorData)rColors.GetColorValue(svtools::CALCDETECTIVEERROR).nColor );
     219             :             sal_Bool bComments =
     220           0 :                 ( ScDetectiveFunc::GetCommentColor() != (ColorData)rColors.GetColorValue(svtools::CALCNOTESBACKGROUND).nColor );
     221           0 :             if ( bArrows || bComments )
     222             :             {
     223           0 :                 ScDetectiveFunc::InitializeColors();        // get the new colors
     224             : 
     225             :                 //  update detective objects in all open documents
     226           0 :                 SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
     227           0 :                 while ( pObjSh )
     228             :                 {
     229           0 :                     if ( pObjSh->Type() == TYPE(ScDocShell) )
     230             :                     {
     231           0 :                         ScDocShell* pDocSh = ((ScDocShell*)pObjSh);
     232           0 :                         if ( bArrows )
     233           0 :                             ScDetectiveFunc( pDocSh->GetDocument(), 0 ).UpdateAllArrowColors();
     234           0 :                         if ( bComments )
     235           0 :                             ScDetectiveFunc::UpdateAllComments( *pDocSh->GetDocument() );
     236             :                     }
     237           0 :                     pObjSh = SfxObjectShell::GetNext( *pObjSh );
     238             :                 }
     239             :             }
     240             :         }
     241             : 
     242             :         //  force all views to repaint, using the new options
     243             : 
     244           0 :         SfxViewShell* pViewShell = SfxViewShell::GetFirst();
     245           0 :         while(pViewShell)
     246             :         {
     247           0 :             if ( pViewShell->ISA(ScTabViewShell) )
     248             :             {
     249           0 :                 ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell;
     250           0 :                 pViewSh->PaintGrid();
     251           0 :                 pViewSh->PaintTop();
     252           0 :                 pViewSh->PaintLeft();
     253           0 :                 pViewSh->PaintExtras();
     254             : 
     255           0 :                 ScInputHandler* pHdl = pViewSh->GetInputHandler();
     256           0 :                 if ( pHdl )
     257           0 :                     pHdl->ForgetLastPattern();  // EditEngine BackgroundColor may change
     258             :             }
     259           0 :             else if ( pViewShell->ISA(ScPreviewShell) )
     260             :             {
     261           0 :                 Window* pWin = pViewShell->GetWindow();
     262           0 :                 if (pWin)
     263           0 :                     pWin->Invalidate();
     264             :             }
     265           0 :             pViewShell = SfxViewShell::GetNext( *pViewShell );
     266           0 :         }
     267             :     }
     268           0 :     else if ( p == pCTLOptions )
     269             :     {
     270             :         //  for all documents: set digit language for printer, recalc output factor, update row heights
     271           0 :         SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
     272           0 :         while ( pObjSh )
     273             :         {
     274           0 :             if ( pObjSh->Type() == TYPE(ScDocShell) )
     275             :             {
     276           0 :                 ScDocShell* pDocSh = ((ScDocShell*)pObjSh);
     277           0 :                 OutputDevice* pPrinter = pDocSh->GetPrinter();
     278           0 :                 if ( pPrinter )
     279           0 :                     pPrinter->SetDigitLanguage( GetOptDigitLanguage() );
     280             : 
     281           0 :                 pDocSh->CalcOutputFactor();
     282             : 
     283           0 :                 SCTAB nTabCount = pDocSh->GetDocument()->GetTableCount();
     284           0 :                 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
     285           0 :                     pDocSh->AdjustRowHeight( 0, MAXROW, nTab );
     286             :             }
     287           0 :             pObjSh = SfxObjectShell::GetNext( *pObjSh );
     288             :         }
     289             : 
     290             :         //  for all views (table and preview): update digit language
     291           0 :         SfxViewShell* pSh = SfxViewShell::GetFirst();
     292           0 :         while ( pSh )
     293             :         {
     294           0 :             if ( pSh->ISA( ScTabViewShell ) )
     295             :             {
     296           0 :                 ScTabViewShell* pViewSh = (ScTabViewShell*)pSh;
     297             : 
     298             :                 //  set ref-device for EditEngine (re-evaluates digit settings)
     299           0 :                 ScInputHandler* pHdl = GetInputHdl(pViewSh);
     300           0 :                 if (pHdl)
     301           0 :                     pHdl->UpdateRefDevice();
     302             : 
     303           0 :                 pViewSh->DigitLanguageChanged();
     304           0 :                 pViewSh->PaintGrid();
     305             :             }
     306           0 :             else if ( pSh->ISA( ScPreviewShell ) )
     307             :             {
     308           0 :                 ScPreviewShell* pPreviewSh = (ScPreviewShell*)pSh;
     309           0 :                 ScPreview* pPreview = pPreviewSh->GetPreview();
     310             : 
     311           0 :                 pPreview->SetDigitLanguage( GetOptDigitLanguage() );
     312           0 :                 pPreview->Invalidate();
     313             :             }
     314             : 
     315           0 :             pSh = SfxViewShell::GetNext( *pSh );
     316             :         }
     317             :     }
     318           0 : }
     319             : 
     320       13517 : void ScModule::Notify( SfxBroadcaster&, const SfxHint& rHint )
     321             : {
     322       13517 :     if ( rHint.ISA(SfxSimpleHint) )
     323             :     {
     324       11182 :         sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId();
     325       11182 :         if ( nHintId == SFX_HINT_DEINITIALIZING )
     326             :         {
     327             :             //  ConfigItems must be removed before ConfigManager
     328           9 :             DeleteCfg();
     329             :         }
     330             :     }
     331       13517 : }
     332             : 
     333             : //------------------------------------------------------------------
     334             : 
     335          18 : void ScModule::DeleteCfg()
     336             : {
     337          18 :     DELETEZ( pViewCfg ); // Speichern passiert vor Exit() automatisch
     338          18 :     DELETEZ( pDocCfg );
     339          18 :     DELETEZ( pAppCfg );
     340          18 :     DELETEZ( pDefaultsCfg );
     341          18 :     DELETEZ( pFormulaCfg );
     342          18 :     DELETEZ( pInputCfg );
     343          18 :     DELETEZ( pPrintCfg );
     344          18 :     DELETEZ( pNavipiCfg );
     345          18 :     DELETEZ( pAddInCfg );
     346             : 
     347          18 :     if ( pColorConfig )
     348             :     {
     349           9 :         pColorConfig->RemoveListener(this);
     350           9 :         DELETEZ( pColorConfig );
     351             :     }
     352          18 :     if ( pAccessOptions )
     353             :     {
     354           9 :         pAccessOptions->RemoveListener(this);
     355           9 :         DELETEZ( pAccessOptions );
     356             :     }
     357          18 :     if ( pCTLOptions )
     358             :     {
     359           9 :         pCTLOptions->RemoveListener(this);
     360           9 :         DELETEZ( pCTLOptions );
     361             :     }
     362          18 :     if( pUserOptions )
     363             :     {
     364           0 :         DELETEZ( pUserOptions );
     365             :     }
     366          18 : }
     367             : 
     368             : //------------------------------------------------------------------
     369             : //
     370             : //      von der Applikation verschoben:
     371             : //
     372             : //------------------------------------------------------------------
     373             : 
     374           2 : void ScModule::Execute( SfxRequest& rReq )
     375             : {
     376           2 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     377           2 :     SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : NULL;
     378             : 
     379           2 :     const SfxItemSet*   pReqArgs    = rReq.GetArgs();
     380           2 :     sal_uInt16              nSlot       = rReq.GetSlot();
     381             : 
     382           2 :     switch ( nSlot )
     383             :     {
     384             :         case SID_CHOOSE_DESIGN:
     385             :             {
     386           0 :                 OUString aMacroName("Template.Samples.ShowStyles");
     387           0 :                 SfxApplication::CallAppBasic( aMacroName );
     388             :             }
     389           0 :             break;
     390             :         case SID_EURO_CONVERTER:
     391             :             {
     392           0 :                 OUString aMacroName("Euro.ConvertRun.Main");
     393           0 :                 SfxApplication::CallAppBasic( aMacroName );
     394             :             }
     395           0 :             break;
     396             :         case SID_AUTOSPELL_CHECK:
     397             :             {
     398             :                 sal_Bool bSet;
     399             :                 const SfxPoolItem* pItem;
     400           0 :                 if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, sal_True, &pItem ) )
     401           0 :                     bSet = ((const SfxBoolItem*)pItem)->GetValue();
     402             :                 else
     403             :                 {                       //  Toggle
     404           0 :                     ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
     405           0 :                     if ( pDocSh )
     406           0 :                         bSet = !pDocSh->GetDocument()->GetDocOptions().IsAutoSpell();
     407             :                     else
     408           0 :                         bSet = !GetDocOptions().IsAutoSpell();
     409             :                 }
     410             : 
     411           0 :                 SfxItemSet aSet( GetPool(), SID_AUTOSPELL_CHECK, SID_AUTOSPELL_CHECK );
     412           0 :                 aSet.Put( SfxBoolItem( SID_AUTOSPELL_CHECK, bSet ) );
     413           0 :                 ModifyOptions( aSet );
     414           0 :                 rReq.Done();
     415             :             }
     416           0 :             break;
     417             : 
     418             :         case SID_ATTR_METRIC:
     419             :             {
     420             :                 const SfxPoolItem* pItem;
     421           0 :                 if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( nSlot, sal_True, &pItem ) )
     422             :                 {
     423           0 :                     FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue();
     424           0 :                     switch( eUnit )
     425             :                     {
     426             :                         case FUNIT_MM:      // nur die Einheiten, die auch im Dialog stehen
     427             :                         case FUNIT_CM:
     428             :                         case FUNIT_INCH:
     429             :                         case FUNIT_PICA:
     430             :                         case FUNIT_POINT:
     431             :                             {
     432           0 :                                 PutItem( *pItem );
     433           0 :                                 ScAppOptions aNewOpts( GetAppOptions() );
     434           0 :                                 aNewOpts.SetAppMetric( eUnit );
     435           0 :                                 SetAppOptions( aNewOpts );
     436           0 :                                 rReq.Done();
     437             :                             }
     438           0 :                             break;
     439             :                         default:
     440             :                         {
     441             :                             // added to avoid warnings
     442             :                         }
     443             :                     }
     444             :                 }
     445             :             }
     446           0 :             break;
     447             : 
     448             :         case FID_AUTOCOMPLETE:
     449             :             {
     450           0 :                 ScAppOptions aNewOpts( GetAppOptions() );
     451           0 :                 sal_Bool bNew = !aNewOpts.GetAutoComplete();
     452           0 :                 aNewOpts.SetAutoComplete( bNew );
     453           0 :                 SetAppOptions( aNewOpts );
     454           0 :                 ScInputHandler::SetAutoComplete( bNew );
     455           0 :                 if (pBindings)
     456           0 :                     pBindings->Invalidate( FID_AUTOCOMPLETE );
     457           0 :                 rReq.Done();
     458             :             }
     459           0 :             break;
     460             : 
     461             :         case SID_DETECTIVE_AUTO:
     462             :             {
     463           2 :                 ScAppOptions aNewOpts( GetAppOptions() );
     464           2 :                 sal_Bool bNew = !aNewOpts.GetDetectiveAuto();
     465           2 :                 SFX_REQUEST_ARG( rReq, pAuto, SfxBoolItem, SID_DETECTIVE_AUTO, false );
     466           2 :                 if ( pAuto )
     467           2 :                     bNew = pAuto->GetValue();
     468             : 
     469           2 :                 aNewOpts.SetDetectiveAuto( bNew );
     470           2 :                 SetAppOptions( aNewOpts );
     471           2 :                 if (pBindings)
     472           2 :                     pBindings->Invalidate( SID_DETECTIVE_AUTO );
     473           2 :                 rReq.AppendItem( SfxBoolItem( SID_DETECTIVE_AUTO, bNew ) );
     474           2 :                 rReq.Done();
     475             :             }
     476           2 :             break;
     477             : 
     478             :         case SID_PSZ_FUNCTION:
     479           0 :             if (pReqArgs)
     480             :             {
     481           0 :                 const SfxUInt16Item& rItem = (const SfxUInt16Item&)pReqArgs->Get(SID_PSZ_FUNCTION);
     482             :                 OSL_ENSURE(rItem.ISA(SfxUInt16Item),"falscher Parameter");
     483             : 
     484           0 :                 ScAppOptions aNewOpts( GetAppOptions() );
     485           0 :                 aNewOpts.SetStatusFunc( rItem.GetValue() );
     486           0 :                 SetAppOptions( aNewOpts );
     487             : 
     488           0 :                 if (pBindings)
     489             :                 {
     490           0 :                     pBindings->Invalidate( SID_TABLE_CELL );
     491           0 :                     pBindings->Update( SID_TABLE_CELL );            // sofort
     492             : 
     493           0 :                     pBindings->Invalidate( SID_PSZ_FUNCTION );
     494           0 :                     pBindings->Update( SID_PSZ_FUNCTION );
     495             :                     // falls Menue gleich wieder aufgeklappt wird
     496           0 :                 }
     497             :             }
     498           0 :             break;
     499             : 
     500             :         case SID_ATTR_LANGUAGE:
     501             :         case SID_ATTR_CHAR_CJK_LANGUAGE:
     502             :         case SID_ATTR_CHAR_CTL_LANGUAGE:
     503             :             {
     504             :                 const SfxPoolItem* pItem;
     505           0 :                 if ( pReqArgs && SFX_ITEM_SET == pReqArgs->GetItemState( GetPool().GetWhich(nSlot), sal_True, &pItem ) )
     506             :                 {
     507           0 :                     ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
     508           0 :                     ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : NULL;
     509           0 :                     if ( pDoc )
     510             :                     {
     511           0 :                         LanguageType eNewLang = ((SvxLanguageItem*)pItem)->GetLanguage();
     512             :                         LanguageType eLatin, eCjk, eCtl;
     513           0 :                         pDoc->GetLanguage( eLatin, eCjk, eCtl );
     514             :                         LanguageType eOld = ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE ) ? eCjk :
     515           0 :                                             ( ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE ) ? eCtl : eLatin );
     516           0 :                         if ( eNewLang != eOld )
     517             :                         {
     518           0 :                             if ( nSlot == SID_ATTR_CHAR_CJK_LANGUAGE )
     519           0 :                                 eCjk = eNewLang;
     520           0 :                             else if ( nSlot == SID_ATTR_CHAR_CTL_LANGUAGE )
     521           0 :                                 eCtl = eNewLang;
     522             :                             else
     523           0 :                                 eLatin = eNewLang;
     524             : 
     525           0 :                             pDoc->SetLanguage( eLatin, eCjk, eCtl );
     526             : 
     527           0 :                             ScInputHandler* pInputHandler = GetInputHdl();
     528           0 :                             if ( pInputHandler )
     529           0 :                                 pInputHandler->UpdateSpellSettings();   // EditEngine-Flags
     530           0 :                             ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
     531           0 :                             if ( pViewSh )
     532           0 :                                 pViewSh->UpdateDrawTextOutliner();      // EditEngine-Flags
     533             : 
     534           0 :                             pDocSh->SetDocumentModified();
     535             :                         }
     536             :                     }
     537             :                 }
     538             :             }
     539           0 :             break;
     540             : 
     541             :         case FID_FOCUS_POSWND:
     542             :             {
     543           0 :                 ScInputHandler* pHdl = GetInputHdl();
     544           0 :                 if (pHdl)
     545             :                 {
     546           0 :                     ScInputWindow* pWin = pHdl->GetInputWindow();
     547           0 :                     if (pWin)
     548           0 :                         pWin->PosGrabFocus();
     549             :                 }
     550           0 :                 rReq.Done();
     551             :             }
     552           0 :             break;
     553             : 
     554             :         case SID_OPEN_XML_FILTERSETTINGS:
     555             :         {
     556             :             try
     557             :             {
     558           0 :                 css::uno::Reference < css::ui::dialogs::XExecutableDialog > xDialog = css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext());
     559           0 :                 xDialog->execute();
     560             :             }
     561           0 :             catch( ::com::sun::star::uno::RuntimeException& )
     562             :             {
     563             :                 DBG_UNHANDLED_EXCEPTION();
     564             :             }
     565             :         }
     566           0 :         break;
     567             : 
     568             :         default:
     569             :             OSL_FAIL( "ScApplication: Unknown Message." );
     570           0 :             break;
     571             :     }
     572           2 : }
     573             : 
     574         359 : void ScModule::GetState( SfxItemSet& rSet )
     575             : {
     576         359 :     ScDocShell* pDocSh = PTR_CAST(ScDocShell, SfxObjectShell::Current());
     577         359 :     bool bTabView = pDocSh && (pDocSh->GetBestViewShell(true) != NULL);
     578             : 
     579         359 :     SfxWhichIter aIter(rSet);
     580         752 :     for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich; nWhich = aIter.NextWhich())
     581             :     {
     582         393 :         if (!bTabView)
     583             :         {
     584             :             // Not in the normal calc view shell (most likely in preview shell).  Disable all actions.
     585         175 :             rSet.DisableItem(nWhich);
     586         175 :             continue;
     587             :         }
     588             : 
     589         218 :         switch ( nWhich )
     590             :         {
     591             :             case FID_AUTOCOMPLETE:
     592           0 :                 rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetAutoComplete() ) );
     593           0 :                 break;
     594             :             case SID_DETECTIVE_AUTO:
     595           2 :                 rSet.Put( SfxBoolItem( nWhich, GetAppOptions().GetDetectiveAuto() ) );
     596           2 :                 break;
     597             :             case SID_PSZ_FUNCTION:
     598          36 :                 rSet.Put( SfxUInt16Item( nWhich, GetAppOptions().GetStatusFunc() ) );
     599          36 :                 break;
     600             :             case SID_ATTR_METRIC:
     601           0 :                 rSet.Put( SfxUInt16Item( nWhich, sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) );
     602           0 :                 break;
     603             :             case SID_AUTOSPELL_CHECK:
     604         180 :                 rSet.Put( SfxBoolItem( nWhich, pDocSh->GetDocument()->GetDocOptions().IsAutoSpell()) );
     605         180 :                 break;
     606             :             case SID_ATTR_LANGUAGE:
     607             :             case ATTR_CJK_FONT_LANGUAGE:        // WID for SID_ATTR_CHAR_CJK_LANGUAGE
     608             :             case ATTR_CTL_FONT_LANGUAGE:        // WID for SID_ATTR_CHAR_CTL_LANGUAGE
     609             :                 {
     610           0 :                     ScDocument* pDoc = pDocSh->GetDocument();
     611           0 :                     if ( pDoc )
     612             :                     {
     613             :                         LanguageType eLatin, eCjk, eCtl;
     614           0 :                         pDoc->GetLanguage( eLatin, eCjk, eCtl );
     615             :                         LanguageType eLang = ( nWhich == ATTR_CJK_FONT_LANGUAGE ) ? eCjk :
     616           0 :                                             ( ( nWhich == ATTR_CTL_FONT_LANGUAGE ) ? eCtl : eLatin );
     617           0 :                         rSet.Put( SvxLanguageItem( eLang, nWhich ) );
     618             :                     }
     619             :                 }
     620           0 :                 break;
     621             :         }
     622         359 :     }
     623         359 : }
     624             : 
     625             : 
     626           0 : void ScModule::HideDisabledSlots( SfxItemSet& rSet )
     627             : {
     628           0 :     if( SfxViewFrame* pViewFrm = SfxViewFrame::Current() )
     629             :     {
     630           0 :         SfxBindings& rBindings = pViewFrm->GetBindings();
     631           0 :         SfxWhichIter aIter( rSet );
     632           0 :         for( sal_uInt16 nWhich = aIter.FirstWhich(); nWhich != 0; nWhich = aIter.NextWhich() )
     633             :         {
     634           0 :             ScViewUtil::HideDisabledSlot( rSet, rBindings, nWhich );
     635             :             // always disable the slots
     636           0 :             rSet.DisableItem( nWhich );
     637           0 :         }
     638             :     }
     639           0 : }
     640             : 
     641             : 
     642             : //------------------------------------------------------------------
     643             : 
     644          31 : void ScModule::ResetDragObject()
     645             : {
     646          31 :     mpDragData->pCellTransfer = NULL;
     647          31 :     mpDragData->pDrawTransfer = NULL;
     648          31 :     mpDragData->pJumpLocalDoc = NULL;
     649          31 :     mpDragData->aLinkDoc = OUString();
     650          31 :     mpDragData->aLinkTable = OUString();
     651          31 :     mpDragData->aLinkArea = OUString();
     652          31 :     mpDragData->aJumpTarget = OUString();
     653          31 :     mpDragData->aJumpText = OUString();
     654          31 : }
     655             : 
     656          11 : const ScDragData& ScModule::GetDragData() const
     657             : {
     658          11 :     return *mpDragData;
     659             : }
     660             : 
     661           0 : void ScModule::SetDragObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj )
     662             : {
     663           0 :     ResetDragObject();
     664           0 :     mpDragData->pCellTransfer = pCellObj;
     665           0 :     mpDragData->pDrawTransfer = pDrawObj;
     666           0 : }
     667             : 
     668           0 : void ScModule::SetDragLink(
     669             :     const OUString& rDoc, const OUString& rTab, const OUString& rArea )
     670             : {
     671           0 :     ResetDragObject();
     672           0 :     mpDragData->aLinkDoc   = rDoc;
     673           0 :     mpDragData->aLinkTable = rTab;
     674           0 :     mpDragData->aLinkArea  = rArea;
     675           0 : }
     676             : 
     677           0 : void ScModule::SetDragJump(
     678             :     ScDocument* pLocalDoc, const OUString& rTarget, const OUString& rText )
     679             : {
     680           0 :     ResetDragObject();
     681             : 
     682           0 :     mpDragData->pJumpLocalDoc = pLocalDoc;
     683           0 :     mpDragData->aJumpTarget = rTarget;
     684           0 :     mpDragData->aJumpText = rText;
     685           0 : }
     686             : 
     687        1150 : const ScClipData& ScModule::GetClipData() const
     688             : {
     689        1150 :     return *mpClipData;
     690             : }
     691             : 
     692          53 : void ScModule::SetClipObject( ScTransferObj* pCellObj, ScDrawTransferObj* pDrawObj )
     693             : {
     694             :     OSL_ENSURE( !pCellObj || !pDrawObj, "SetClipObject: not allowed to set both objects" );
     695             : 
     696          53 :     mpClipData->pCellClipboard = pCellObj;
     697          53 :     mpClipData->pDrawClipboard = pDrawObj;
     698          53 : }
     699             : 
     700         809 : ScDocument* ScModule::GetClipDoc()
     701             : {
     702             :     //  called from document
     703             : 
     704         809 :     ScTransferObj* pObj = ScTransferObj::GetOwnClipboard( NULL );
     705         809 :     if (pObj)
     706           0 :         return pObj->GetDocument();
     707             : 
     708         809 :     return NULL;
     709             : }
     710             : 
     711             : //------------------------------------------------------------------
     712             : 
     713         353 : void ScModule::SetSelectionTransfer( ScSelectionTransferObj* pNew )
     714             : {
     715         353 :     pSelTransfer = pNew;
     716         353 : }
     717             : 
     718             : //------------------------------------------------------------------
     719             : 
     720           0 : void ScModule::InitFormEditData()
     721             : {
     722           0 :     pFormEditData = new ScFormEditData;
     723           0 : }
     724             : 
     725           0 : void ScModule::ClearFormEditData()
     726             : {
     727           0 :     DELETEZ( pFormEditData );
     728           0 : }
     729             : 
     730             : //------------------------------------------------------------------
     731             : 
     732           0 : void ScModule::SetViewOptions( const ScViewOptions& rOpt )
     733             : {
     734           0 :     if ( !pViewCfg )
     735           0 :         pViewCfg = new ScViewCfg;
     736             : 
     737           0 :     pViewCfg->SetOptions( rOpt );
     738           0 : }
     739             : 
     740         313 : const ScViewOptions& ScModule::GetViewOptions()
     741             : {
     742         313 :     if ( !pViewCfg )
     743          30 :         pViewCfg = new ScViewCfg;
     744             : 
     745         313 :     return *pViewCfg;
     746             : }
     747             : 
     748           0 : void ScModule::SetDocOptions( const ScDocOptions& rOpt )
     749             : {
     750           0 :     if ( !pDocCfg )
     751           0 :         pDocCfg = new ScDocCfg;
     752             : 
     753           0 :     pDocCfg->SetOptions( rOpt );
     754           0 : }
     755             : 
     756         313 : const ScDocOptions& ScModule::GetDocOptions()
     757             : {
     758         313 :     if ( !pDocCfg )
     759          30 :         pDocCfg = new ScDocCfg;
     760             : 
     761         313 :     return *pDocCfg;
     762             : }
     763             : 
     764             : #ifndef LRU_MAX
     765             : #define LRU_MAX 10
     766             : #endif
     767             : 
     768           0 : void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex)
     769             : {
     770           0 :     if(nFIndex != 0)
     771             :     {
     772           0 :         const ScAppOptions& rAppOpt = GetAppOptions();
     773           0 :         sal_uInt16 nLRUFuncCount = std::min( rAppOpt.GetLRUFuncListCount(), (sal_uInt16)LRU_MAX );
     774           0 :         sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList();
     775             : 
     776             :         sal_uInt16  aIdxList[LRU_MAX];
     777           0 :         sal_uInt16  n = 0;
     778           0 :         sal_Bool    bFound = false;
     779             : 
     780           0 :         while ((n < LRU_MAX) && n<nLRUFuncCount)                        // alte Liste abklappern
     781             :         {
     782           0 :             if (!bFound && (pLRUListIds[n]== nFIndex))
     783           0 :                 bFound = sal_True;                                          // erster! Treffer
     784           0 :             else if (bFound)
     785           0 :                 aIdxList[n  ] = pLRUListIds[n];                         // hinter Treffer kopieren
     786           0 :             else if ((n+1) < LRU_MAX)
     787           0 :                 aIdxList[n+1] = pLRUListIds[n];                         // vor Treffer verschieben
     788           0 :             n++;
     789             :         }
     790           0 :         if (!bFound && (n < LRU_MAX))                                   // Eintrag nicht gefunden?
     791           0 :             n++;                                                        //  einen mehr
     792           0 :         aIdxList[0] = nFIndex;                                          // Current on Top
     793             : 
     794           0 :         ScAppOptions aNewOpts(rAppOpt);                                 // an App melden
     795           0 :         aNewOpts.SetLRUFuncList(aIdxList, n);
     796           0 :         SetAppOptions(aNewOpts);
     797             : 
     798           0 :         RecentFunctionsChanged();
     799             :     }
     800           0 : }
     801             : 
     802           0 : void ScModule::RecentFunctionsChanged()
     803             : {
     804             :     //  update function list window
     805           0 :     sal_uInt16 nFuncListID = ScFunctionChildWindow::GetChildWindowId();
     806             : 
     807             :     //! notify all views
     808           0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     809           0 :     if ( pViewFrm && pViewFrm->HasChildWindow(nFuncListID) )
     810             :     {
     811           0 :         ScFunctionChildWindow* pWnd =(ScFunctionChildWindow*)pViewFrm->GetChildWindow( nFuncListID );
     812             : 
     813           0 :         ScFunctionDockWin* pFuncList=(ScFunctionDockWin*)pWnd->GetWindow();
     814             : 
     815           0 :         pFuncList->InitLRUList();
     816             :     }
     817           0 : }
     818             : 
     819          20 : void ScModule::SetAppOptions( const ScAppOptions& rOpt )
     820             : {
     821          20 :     if ( !pAppCfg )
     822           0 :         pAppCfg = new ScAppCfg;
     823             : 
     824          20 :     pAppCfg->SetOptions( rOpt );
     825          20 : }
     826             : 
     827          12 : void global_InitAppOptions()
     828             : {
     829          12 :     SC_MOD()->GetAppOptions();
     830          12 : }
     831             : 
     832         738 : const ScAppOptions& ScModule::GetAppOptions()
     833             : {
     834         738 :     if ( !pAppCfg )
     835          31 :         pAppCfg = new ScAppCfg;
     836             : 
     837         738 :     return *pAppCfg;
     838             : }
     839             : 
     840           0 : void ScModule::SetDefaultsOptions( const ScDefaultsOptions& rOpt )
     841             : {
     842           0 :     if ( !pDefaultsCfg )
     843           0 :         pDefaultsCfg = new ScDefaultsCfg;
     844             : 
     845           0 :     pDefaultsCfg->SetOptions( rOpt );
     846           0 : }
     847             : 
     848         601 : const ScDefaultsOptions& ScModule::GetDefaultsOptions()
     849             : {
     850         601 :     if ( !pDefaultsCfg )
     851          30 :         pDefaultsCfg = new ScDefaultsCfg;
     852             : 
     853         601 :     return *pDefaultsCfg;
     854             : }
     855             : 
     856           0 : void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt )
     857             : {
     858           0 :     if ( !pFormulaCfg )
     859           0 :         pFormulaCfg = new ScFormulaCfg;
     860             : 
     861           0 :     pFormulaCfg->SetOptions( rOpt );
     862           0 : }
     863             : 
     864         511 : const ScFormulaOptions& ScModule::GetFormulaOptions()
     865             : {
     866         511 :     if ( !pFormulaCfg )
     867          30 :         pFormulaCfg = new ScFormulaCfg;
     868             : 
     869         511 :     return *pFormulaCfg;
     870             : }
     871             : 
     872          60 : void ScModule::SetInputOptions( const ScInputOptions& rOpt )
     873             : {
     874          60 :     if ( !pInputCfg )
     875           0 :         pInputCfg = new ScInputCfg;
     876             : 
     877          60 :     pInputCfg->SetOptions( rOpt );
     878          60 : }
     879             : 
     880        9129 : const ScInputOptions& ScModule::GetInputOptions()
     881             : {
     882        9129 :     if ( !pInputCfg )
     883          30 :         pInputCfg = new ScInputCfg;
     884             : 
     885        9129 :     return *pInputCfg;
     886             : }
     887             : 
     888           6 : void ScModule::SetPrintOptions( const ScPrintOptions& rOpt )
     889             : {
     890           6 :     if ( !pPrintCfg )
     891           0 :         pPrintCfg = new ScPrintCfg;
     892             : 
     893           6 :     pPrintCfg->SetOptions( rOpt );
     894           6 : }
     895             : 
     896          94 : const ScPrintOptions& ScModule::GetPrintOptions()
     897             : {
     898          94 :     if ( !pPrintCfg )
     899           1 :         pPrintCfg = new ScPrintCfg;
     900             : 
     901          94 :     return *pPrintCfg;
     902             : }
     903             : 
     904           0 : ScNavipiCfg& ScModule::GetNavipiCfg()
     905             : {
     906           0 :     if ( !pNavipiCfg )
     907           0 :         pNavipiCfg = new ScNavipiCfg;
     908             : 
     909           0 :     return *pNavipiCfg;
     910             : }
     911             : 
     912          23 : ScAddInCfg& ScModule::GetAddInCfg()
     913             : {
     914          23 :     if ( !pAddInCfg )
     915          23 :         pAddInCfg = new ScAddInCfg;
     916             : 
     917          23 :     return *pAddInCfg;
     918             : }
     919             : 
     920        8503 : svtools::ColorConfig& ScModule::GetColorConfig()
     921             : {
     922        8503 :     if ( !pColorConfig )
     923             :     {
     924          28 :         pColorConfig = new svtools::ColorConfig;
     925          28 :         pColorConfig->AddListener(this);
     926             :     }
     927             : 
     928        8503 :     return *pColorConfig;
     929             : }
     930             : 
     931        9500 : SvtAccessibilityOptions& ScModule::GetAccessOptions()
     932             : {
     933        9500 :     if ( !pAccessOptions )
     934             :     {
     935          24 :         pAccessOptions = new SvtAccessibilityOptions;
     936          24 :         pAccessOptions->AddListener(this);
     937             :     }
     938             : 
     939        9500 :     return *pAccessOptions;
     940             : }
     941             : 
     942        1358 : SvtCTLOptions& ScModule::GetCTLOptions()
     943             : {
     944        1358 :     if ( !pCTLOptions )
     945             :     {
     946          30 :         pCTLOptions = new SvtCTLOptions;
     947          30 :         pCTLOptions->AddListener(this);
     948             :     }
     949             : 
     950        1358 :     return *pCTLOptions;
     951             : }
     952             : 
     953           0 : SvtUserOptions&  ScModule::GetUserOptions()
     954             : {
     955           0 :     if( !pUserOptions )
     956             :     {
     957           0 :         pUserOptions = new SvtUserOptions;
     958             :     }
     959           0 :     return *pUserOptions;
     960             : }
     961             : 
     962        1358 : sal_uInt16 ScModule::GetOptDigitLanguage()
     963             : {
     964        1358 :     SvtCTLOptions::TextNumerals eNumerals = GetCTLOptions().GetCTLTextNumerals();
     965             :     return ( eNumerals == SvtCTLOptions::NUMERALS_ARABIC ) ? LANGUAGE_ENGLISH_US :
     966             :            ( eNumerals == SvtCTLOptions::NUMERALS_HINDI)   ? LANGUAGE_ARABIC_SAUDI_ARABIA :
     967        1358 :                                                              LANGUAGE_SYSTEM;
     968             : }
     969             : 
     970             : //------------------------------------------------------------------
     971             : //
     972             : //                          Optionen
     973             : //
     974             : //------------------------------------------------------------------
     975             : 
     976             : //
     977             : //      ModifyOptions - Items aus Calc-Options-Dialog
     978             : //                      und SID_AUTOSPELL_CHECK
     979             : //
     980             : 
     981           0 : void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     982             : {
     983             :     sal_uInt16 nOldSpellLang, nOldCjkLang, nOldCtlLang;
     984             :     sal_Bool bOldAutoSpell;
     985           0 :     GetSpellSettings( nOldSpellLang, nOldCjkLang, nOldCtlLang, bOldAutoSpell );
     986             : 
     987           0 :     if (!pAppCfg)
     988           0 :         GetAppOptions();
     989             :     OSL_ENSURE( pAppCfg, "AppOptions not initialised :-(" );
     990             : 
     991           0 :     if (!pInputCfg)
     992           0 :         GetInputOptions();
     993             :     OSL_ENSURE( pInputCfg, "InputOptions not initialised :-(" );
     994             : 
     995             :     //--------------------------------------------------------------
     996             : 
     997           0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
     998           0 :     SfxBindings* pBindings = pViewFrm ? &pViewFrm->GetBindings() : NULL;
     999             : 
    1000           0 :     ScTabViewShell*         pViewSh = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
    1001           0 :     ScDocShell*             pDocSh  = PTR_CAST(ScDocShell, SfxObjectShell::Current());
    1002           0 :     ScDocument*             pDoc    = pDocSh ? pDocSh->GetDocument() : NULL;
    1003           0 :     const SfxPoolItem*      pItem   = NULL;
    1004           0 :     bool bRepaint = false;
    1005           0 :     bool bUpdateMarks = false;
    1006           0 :     bool bUpdateRefDev = false;
    1007           0 :     bool bCalcAll = false;
    1008           0 :     bool bSaveAppOptions = false;
    1009           0 :     bool bSaveInputOptions = false;
    1010           0 :     bool bCompileErrorCells = false;
    1011             : 
    1012             :     //--------------------------------------------------------------------------
    1013             : 
    1014             :     //  SFX_APP()->SetOptions( rOptSet );
    1015             : 
    1016             :     //  Linguistik nicht mehr
    1017             : 
    1018           0 :     if (rOptSet.HasItem(SID_ATTR_METRIC, &pItem))
    1019             :     {
    1020           0 :         PutItem( *pItem );
    1021           0 :         pAppCfg->SetAppMetric( (FieldUnit)((const SfxUInt16Item*)pItem)->GetValue() );
    1022           0 :         bSaveAppOptions = sal_True;
    1023             :     }
    1024             : 
    1025           0 :     if (rOptSet.HasItem(SCITEM_USERLIST, &pItem))
    1026             :     {
    1027           0 :         ScGlobal::SetUserList( ((const ScUserListItem*)pItem)->GetUserList() );
    1028           0 :         bSaveAppOptions = sal_True;
    1029             :     }
    1030             : 
    1031           0 :     if (rOptSet.HasItem(SID_SC_OPT_SYNCZOOM, &pItem))
    1032             :     {
    1033           0 :         pAppCfg->SetSynchronizeZoom( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
    1034           0 :         bSaveAppOptions = sal_True;
    1035             :     }
    1036             : 
    1037           0 :     if (rOptSet.HasItem(SID_SC_OPT_KEY_BINDING_COMPAT, &pItem))
    1038             :     {
    1039           0 :         sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
    1040           0 :         ScOptionsUtil::KeyBindingType eOld = pAppCfg->GetKeyBindingType();
    1041           0 :         ScOptionsUtil::KeyBindingType eNew = static_cast<ScOptionsUtil::KeyBindingType>(nVal);
    1042           0 :         if (eOld != eNew)
    1043             :         {
    1044           0 :             pAppCfg->SetKeyBindingType(eNew);
    1045           0 :             bSaveAppOptions = true;
    1046           0 :             pDocSh->ResetKeyBindings(eNew);
    1047             :         }
    1048             :     }
    1049             : 
    1050             :     //============================================
    1051             :     // DefaultsOptions
    1052             :     //============================================
    1053             : 
    1054           0 :     if (rOptSet.HasItem(SID_SCDEFAULTSOPTIONS, &pItem))
    1055             :     {
    1056           0 :         const ScDefaultsOptions& rOpt = ((const ScTpDefaultsItem*)pItem)->GetDefaultsOptions();
    1057           0 :         SetDefaultsOptions( rOpt );
    1058             :     }
    1059             : 
    1060             :     //============================================
    1061             :     // FormulaOptions
    1062             :     //============================================
    1063             : 
    1064           0 :     if (rOptSet.HasItem(SID_SCFORMULAOPTIONS, &pItem))
    1065             :     {
    1066           0 :         const ScFormulaOptions& rOpt = ((const ScTpFormulaItem*)pItem)->GetFormulaOptions();
    1067             : 
    1068           0 :         if (!pFormulaCfg || (*pFormulaCfg != rOpt))
    1069             :             // Formula options have changed. Repaint the column headers.
    1070           0 :             bRepaint = true;
    1071             : 
    1072           0 :         if (pFormulaCfg && pFormulaCfg->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName())
    1073             :         {
    1074             :             // Re-compile formula cells with error as the error may have been
    1075             :             // caused by unresolved function names.
    1076           0 :             bCompileErrorCells = true;
    1077             :         }
    1078             : 
    1079           0 :         SetFormulaOptions( rOpt );
    1080             : 
    1081           0 :         if ( pDocSh )
    1082             :         {
    1083           0 :             pDocSh->SetFormulaOptions( rOpt );
    1084           0 :             pDocSh->SetDocumentModified();
    1085             :         }
    1086             :     }
    1087             : 
    1088             :     //============================================
    1089             :     // ViewOptions
    1090             :     //============================================
    1091             : 
    1092           0 :     if (rOptSet.HasItem(SID_SCVIEWOPTIONS, &pItem))
    1093             :     {
    1094           0 :         const ScViewOptions& rNewOpt = ((const ScTpViewItem*)pItem)->GetViewOptions();
    1095             : 
    1096           0 :         if ( pViewSh )
    1097             :         {
    1098           0 :             ScViewData*             pViewData = pViewSh->GetViewData();
    1099           0 :             const ScViewOptions&    rOldOpt   = pViewData->GetOptions();
    1100             : 
    1101           0 :             sal_Bool bAnchorList = ( rOldOpt.GetOption( VOPT_ANCHOR ) !=
    1102           0 :                                  rNewOpt.GetOption( VOPT_ANCHOR ) );
    1103             : 
    1104           0 :             if ( rOldOpt != rNewOpt )
    1105             :             {
    1106           0 :                 pViewData->SetOptions( rNewOpt );   // veraendert rOldOpt
    1107           0 :                 pViewData->GetDocument()->SetViewOptions( rNewOpt );
    1108           0 :                 pDocSh->SetDocumentModified();
    1109           0 :                 bRepaint = sal_True;
    1110             :             }
    1111           0 :             if ( bAnchorList )
    1112           0 :                 pViewSh->UpdateAnchorHandles();
    1113             :         }
    1114           0 :         SetViewOptions( rNewOpt );
    1115           0 :         if (pBindings)
    1116             :         {
    1117           0 :             pBindings->Invalidate(SID_HELPLINES_MOVE);
    1118           0 :             pBindings->Invalidate(SID_SCGRIDSHOW);
    1119             :         }
    1120             :     }
    1121             : 
    1122             :     //============================================
    1123             :     // GridOptions, Auswertung nach ViewOptions,
    1124             :     // da GridOptions Member der ViewOptions ist!
    1125             :     //============================================
    1126             : 
    1127           0 :     if ( rOptSet.HasItem(SID_ATTR_GRID_OPTIONS,&pItem) )
    1128             :     {
    1129           0 :         ScGridOptions aNewGridOpt( (const SvxOptionsGrid&)((const SvxGridItem&)*pItem) );
    1130             : 
    1131           0 :         if ( pViewSh )
    1132             :         {
    1133           0 :             ScViewData*          pViewData = pViewSh->GetViewData();
    1134           0 :             ScViewOptions        aNewViewOpt( pViewData->GetOptions() );
    1135           0 :             const ScGridOptions& rOldGridOpt = aNewViewOpt.GetGridOptions();
    1136             : 
    1137           0 :             if ( rOldGridOpt != aNewGridOpt )
    1138             :             {
    1139           0 :                 aNewViewOpt.SetGridOptions( aNewGridOpt );
    1140           0 :                 pViewData->SetOptions( aNewViewOpt );
    1141           0 :                 pViewData->GetDocument()->SetViewOptions( aNewViewOpt );
    1142           0 :                 pDocSh->SetDocumentModified();
    1143           0 :                 bRepaint = sal_True;
    1144           0 :             }
    1145             :         }
    1146           0 :         ScViewOptions aNewViewOpt ( GetViewOptions() );
    1147           0 :         aNewViewOpt.SetGridOptions( aNewGridOpt );
    1148           0 :         SetViewOptions( aNewViewOpt );
    1149           0 :         if (pBindings)
    1150             :         {
    1151           0 :             pBindings->Invalidate(SID_GRID_VISIBLE);
    1152           0 :             pBindings->Invalidate(SID_GRID_USE);
    1153           0 :         }
    1154             :     }
    1155             : 
    1156             : 
    1157             :     //============================================
    1158             :     // DocOptions
    1159             :     //============================================
    1160             : 
    1161           0 :     if ( rOptSet.HasItem(SID_SCDOCOPTIONS,&pItem) )
    1162             :     {
    1163           0 :         const ScDocOptions& rNewOpt = ((const ScTpCalcItem*)pItem)->GetDocOptions();
    1164             : 
    1165           0 :         if ( pDoc )
    1166             :         {
    1167           0 :             const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
    1168             : 
    1169           0 :             bRepaint = ( bRepaint || ( rOldOpt != rNewOpt )   );
    1170           0 :             bCalcAll =   bRepaint &&
    1171           0 :                          (  rOldOpt.IsIter()       != rNewOpt.IsIter()
    1172           0 :                          || rOldOpt.GetIterCount() != rNewOpt.GetIterCount()
    1173           0 :                          || rOldOpt.GetIterEps()   != rNewOpt.GetIterEps()
    1174           0 :                          || rOldOpt.IsIgnoreCase() != rNewOpt.IsIgnoreCase()
    1175           0 :                          || rOldOpt.IsCalcAsShown() != rNewOpt.IsCalcAsShown()
    1176           0 :                          || (rNewOpt.IsCalcAsShown() &&
    1177           0 :                             rOldOpt.GetStdPrecision() != rNewOpt.GetStdPrecision())
    1178           0 :                          || rOldOpt.IsMatchWholeCell() != rNewOpt.IsMatchWholeCell()
    1179           0 :                          || rOldOpt.GetYear2000()   != rNewOpt.GetYear2000()
    1180           0 :                          || rOldOpt.IsFormulaRegexEnabled() != rNewOpt.IsFormulaRegexEnabled()
    1181           0 :                          );
    1182           0 :             pDoc->SetDocOptions( rNewOpt );
    1183           0 :             pDocSh->SetDocumentModified();
    1184             :         }
    1185           0 :         SetDocOptions( rNewOpt );
    1186             :     }
    1187             : 
    1188             :     // nach den eigentlichen DocOptions auch noch die TabDistance setzen
    1189           0 :     if ( rOptSet.HasItem(SID_ATTR_DEFTABSTOP,&pItem) )
    1190             :     {
    1191           0 :         sal_uInt16 nTabDist = ((SfxUInt16Item*)pItem)->GetValue();
    1192           0 :         ScDocOptions aOpt(GetDocOptions());
    1193           0 :         aOpt.SetTabDistance(nTabDist);
    1194           0 :         SetDocOptions( aOpt );
    1195             : 
    1196           0 :         if ( pDoc )
    1197             :         {
    1198           0 :             ScDocOptions aDocOpt(pDoc->GetDocOptions());
    1199           0 :             aDocOpt.SetTabDistance(nTabDist);
    1200           0 :             pDoc->SetDocOptions( aDocOpt );
    1201           0 :             pDocSh->SetDocumentModified();
    1202           0 :             if(pDoc->GetDrawLayer())
    1203           0 :                 pDoc->GetDrawLayer()->SetDefaultTabulator(nTabDist);
    1204           0 :         }
    1205             :     }
    1206             : 
    1207             :     //  AutoSpell nach den Doc-Options (weil Member)
    1208             : 
    1209           0 :     if ( rOptSet.HasItem(SID_AUTOSPELL_CHECK,&pItem) )              // an Doc-Options
    1210             :     {
    1211           0 :         sal_Bool bDoAutoSpell = ((const SfxBoolItem*)pItem)->GetValue();
    1212             : 
    1213           0 :         if (pDoc)
    1214             :         {
    1215           0 :             ScDocOptions aNewOpt = pDoc->GetDocOptions();
    1216           0 :             if ( aNewOpt.IsAutoSpell() != bDoAutoSpell )
    1217             :             {
    1218           0 :                 aNewOpt.SetAutoSpell( bDoAutoSpell );
    1219           0 :                 pDoc->SetDocOptions( aNewOpt );
    1220             : 
    1221           0 :                 if (bDoAutoSpell)
    1222           0 :                     pDoc->SetOnlineSpellPos( ScAddress(0,0,0) );    // vorne anfangen
    1223             :                 else
    1224             :                 {
    1225           0 :                     WaitObject aWait( pDocSh->GetActiveDialogParent() );
    1226           0 :                     pDoc->RemoveAutoSpellObj();     //  Edit-Text-Objekte wieder zurueckwandeln
    1227             :                 }
    1228             : 
    1229             :                 //#92038#; don't set document modified, because this flag is no longer saved
    1230             : //              pDocSh->SetDocumentModified();
    1231             : 
    1232           0 :                 bRepaint = sal_True;            //  weil HideAutoSpell evtl. ungueltig
    1233             :                                             //! alle Views painten ???
    1234           0 :             }
    1235             :         }
    1236             : 
    1237           0 :         if ( bOldAutoSpell != bDoAutoSpell )
    1238           0 :             SetAutoSpellProperty( bDoAutoSpell );
    1239           0 :         if ( pDocSh )
    1240           0 :             pDocSh->PostPaintGridAll();                     // wegen Markierungen
    1241           0 :         ScInputHandler* pInputHandler = GetInputHdl();
    1242           0 :         if ( pInputHandler )
    1243           0 :             pInputHandler->UpdateSpellSettings();           // EditEngine-Flags
    1244           0 :         if ( pViewSh )
    1245           0 :             pViewSh->UpdateDrawTextOutliner();              // EditEngine-Flags
    1246             : 
    1247           0 :         if (pBindings)
    1248           0 :             pBindings->Invalidate( SID_AUTOSPELL_CHECK );
    1249             :     }
    1250             : 
    1251             :     //============================================
    1252             :     // InputOptions
    1253             :     //============================================
    1254             : 
    1255           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_SELECTIONPOS,&pItem) )
    1256             :     {
    1257           0 :         pInputCfg->SetMoveDir( ((const SfxUInt16Item*)pItem)->GetValue() );
    1258           0 :         bSaveInputOptions = sal_True;
    1259             :     }
    1260           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_SELECTION,&pItem) )
    1261             :     {
    1262           0 :         pInputCfg->SetMoveSelection( ((const SfxBoolItem*)pItem)->GetValue() );
    1263           0 :         bSaveInputOptions = sal_True;
    1264             :     }
    1265           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_EDITMODE,&pItem) )
    1266             :     {
    1267           0 :         pInputCfg->SetEnterEdit( ((const SfxBoolItem*)pItem)->GetValue() );
    1268           0 :         bSaveInputOptions = sal_True;
    1269             :     }
    1270           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_FMT_EXPAND,&pItem) )
    1271             :     {
    1272           0 :         pInputCfg->SetExtendFormat( ((const SfxBoolItem*)pItem)->GetValue() );
    1273           0 :         bSaveInputOptions = sal_True;
    1274             :     }
    1275           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_RANGEFINDER,&pItem) )
    1276             :     {
    1277           0 :         pInputCfg->SetRangeFinder( ((const SfxBoolItem*)pItem)->GetValue() );
    1278           0 :         bSaveInputOptions = sal_True;
    1279             :     }
    1280           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_REF_EXPAND,&pItem) )
    1281             :     {
    1282           0 :         pInputCfg->SetExpandRefs( ((const SfxBoolItem*)pItem)->GetValue() );
    1283           0 :         bSaveInputOptions = sal_True;
    1284             :     }
    1285           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_MARK_HEADER,&pItem) )
    1286             :     {
    1287           0 :         pInputCfg->SetMarkHeader( ((const SfxBoolItem*)pItem)->GetValue() );
    1288           0 :         bSaveInputOptions = sal_True;
    1289           0 :         bUpdateMarks = sal_True;
    1290             :     }
    1291           0 :     if ( rOptSet.HasItem(SID_SC_INPUT_TEXTWYSIWYG,&pItem) )
    1292             :     {
    1293           0 :         sal_Bool bNew = ((const SfxBoolItem*)pItem)->GetValue();
    1294           0 :         if ( bNew != pInputCfg->GetTextWysiwyg() )
    1295             :         {
    1296           0 :             pInputCfg->SetTextWysiwyg( bNew );
    1297           0 :             bSaveInputOptions = sal_True;
    1298           0 :             bUpdateRefDev = sal_True;
    1299             :         }
    1300             :     }
    1301           0 :     if( rOptSet.HasItem( SID_SC_INPUT_REPLCELLSWARN, &pItem ) )
    1302             :     {
    1303           0 :         pInputCfg->SetReplaceCellsWarn( ((const SfxBoolItem*)pItem)->GetValue() );
    1304           0 :         bSaveInputOptions = sal_True;
    1305             :     }
    1306             : 
    1307             :     //============================================
    1308             :     // PrintOptions
    1309             :     //============================================
    1310             : 
    1311           0 :     if ( rOptSet.HasItem(SID_SCPRINTOPTIONS,&pItem) )
    1312             :     {
    1313           0 :         const ScPrintOptions& rNewOpt = ((const ScTpPrintItem*)pItem)->GetPrintOptions();
    1314           0 :         SetPrintOptions( rNewOpt );
    1315             : 
    1316             :         //  broadcast causes all previews to recalc page numbers
    1317           0 :         SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS ) );
    1318             :     }
    1319             : 
    1320             :     //----------------------------------------------------------
    1321             : 
    1322           0 :     if ( bSaveAppOptions )
    1323           0 :         pAppCfg->OptionsChanged();
    1324             : 
    1325           0 :     if ( bSaveInputOptions )
    1326           0 :         pInputCfg->OptionsChanged();
    1327             : 
    1328             :     // Neuberechnung anstossen?
    1329             : 
    1330           0 :     if (pDoc && bCompileErrorCells)
    1331             :     {
    1332             :         // Re-compile cells with name error, and recalc if at least one cell
    1333             :         // has been re-compiled.  In the future we may want to find a way to
    1334             :         // recalc only those that are affected.
    1335           0 :         if (pDoc->CompileErrorCells(ScErrorCodes::errNoName))
    1336           0 :             bCalcAll = true;
    1337             :     }
    1338             : 
    1339           0 :     if ( pDoc && bCalcAll )
    1340             :     {
    1341           0 :         WaitObject aWait( pDocSh->GetActiveDialogParent() );
    1342           0 :         pDoc->CalcAll();
    1343           0 :         if ( pViewSh )
    1344           0 :             pViewSh->UpdateCharts( sal_True );
    1345             :         else
    1346           0 :             ScDBFunc::DoUpdateCharts( ScAddress(), pDoc, sal_True );
    1347           0 :         if (pBindings)
    1348           0 :             pBindings->Invalidate( SID_ATTR_SIZE ); //SvxPosSize-StatusControl-Update
    1349             :     }
    1350             : 
    1351           0 :     if ( pViewSh && bUpdateMarks )
    1352           0 :         pViewSh->UpdateAutoFillMark();
    1353             : 
    1354             :     // View neuzeichnen?
    1355             : 
    1356           0 :     if ( pViewSh && bRepaint )
    1357             :     {
    1358           0 :         pViewSh->UpdateFixPos();
    1359           0 :         pViewSh->PaintGrid();
    1360           0 :         pViewSh->PaintTop();
    1361           0 :         pViewSh->PaintLeft();
    1362           0 :         pViewSh->PaintExtras();
    1363           0 :         pViewSh->InvalidateBorder();
    1364           0 :         if (pBindings)
    1365             :         {
    1366           0 :             pBindings->Invalidate( FID_TOGGLEHEADERS ); // -> Checks im Menue
    1367           0 :             pBindings->Invalidate( FID_TOGGLESYNTAX );
    1368             :         }
    1369             :     }
    1370             : 
    1371             :     // update ref device (for all documents)
    1372             : 
    1373           0 :     if ( bUpdateRefDev )
    1374             :     {
    1375             :         //  for all documents: recalc output factor, update row heights
    1376           0 :         SfxObjectShell* pObjSh = SfxObjectShell::GetFirst();
    1377           0 :         while ( pObjSh )
    1378             :         {
    1379           0 :             if ( pObjSh->Type() == TYPE(ScDocShell) )
    1380             :             {
    1381           0 :                 ScDocShell* pOneDocSh = ((ScDocShell*)pObjSh);
    1382           0 :                 pOneDocSh->CalcOutputFactor();
    1383           0 :                 SCTAB nTabCount = pOneDocSh->GetDocument()->GetTableCount();
    1384           0 :                 for (SCTAB nTab=0; nTab<nTabCount; nTab++)
    1385           0 :                     pOneDocSh->AdjustRowHeight( 0, MAXROW, nTab );
    1386             :             }
    1387           0 :             pObjSh = SfxObjectShell::GetNext( *pObjSh );
    1388             :         }
    1389             : 
    1390             :         //  for all (tab-) views:
    1391           0 :         TypeId aScType = TYPE(ScTabViewShell);
    1392           0 :         SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
    1393           0 :         while ( pSh )
    1394             :         {
    1395           0 :             ScTabViewShell* pOneViewSh = (ScTabViewShell*)pSh;
    1396             : 
    1397             :             //  set ref-device for EditEngine
    1398           0 :             ScInputHandler* pHdl = GetInputHdl(pOneViewSh);
    1399           0 :             if (pHdl)
    1400           0 :                 pHdl->UpdateRefDevice();
    1401             : 
    1402             :             //  update view scale
    1403           0 :             ScViewData* pViewData = pOneViewSh->GetViewData();
    1404           0 :             pOneViewSh->SetZoom( pViewData->GetZoomX(), pViewData->GetZoomY(), false );
    1405             : 
    1406             :             //  repaint
    1407           0 :             pOneViewSh->PaintGrid();
    1408           0 :             pOneViewSh->PaintTop();
    1409           0 :             pOneViewSh->PaintLeft();
    1410             : 
    1411           0 :             pSh = SfxViewShell::GetNext( *pSh, &aScType );
    1412             :         }
    1413             :     }
    1414           0 : }
    1415             : 
    1416             : //------------------------------------------------------------------
    1417             : //
    1418             : //                      Input-Handler
    1419             : //
    1420             : //------------------------------------------------------------------
    1421             : 
    1422       15167 : ScInputHandler* ScModule::GetInputHdl( ScTabViewShell* pViewSh, sal_Bool bUseRef )
    1423             : {
    1424       15167 :     if ( pRefInputHandler && bUseRef )
    1425           0 :         return pRefInputHandler;
    1426             : 
    1427       15167 :     ScInputHandler* pHdl = NULL;
    1428       15167 :     if ( !pViewSh )
    1429             :     {
    1430             :         // in case a UIActive embedded object has no ViewShell ( UNO component )
    1431             :         // the own calc view shell will be set as current, but no handling should happen
    1432             : 
    1433       12112 :         ScTabViewShell* pCurViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() );
    1434       12112 :         if ( pCurViewSh && !pCurViewSh->GetUIActiveClient() )
    1435       11326 :             pViewSh = pCurViewSh;
    1436             :     }
    1437             : 
    1438       15167 :     if ( pViewSh )
    1439       14381 :         pHdl = pViewSh->GetInputHandler();      // Viewshell hat jetzt immer einen
    1440             : 
    1441             :     //  wenn keine ViewShell uebergeben oder aktiv, kann NULL herauskommen
    1442             :     OSL_ENSURE( pHdl || !pViewSh, "GetInputHdl: kein InputHandler gefunden" );
    1443       15167 :     return pHdl;
    1444             : }
    1445             : 
    1446         203 : void ScModule::ViewShellChanged()
    1447             : {
    1448         203 :     ScInputHandler* pHdl   = GetInputHdl();
    1449         203 :     ScTabViewShell* pShell = ScTabViewShell::GetActiveViewShell();
    1450         203 :     if ( pShell && pHdl )
    1451         203 :         pShell->UpdateInputHandler();
    1452         203 : }
    1453             : 
    1454           0 : void ScModule::SetInputMode( ScInputMode eMode )
    1455             : {
    1456           0 :     ScInputHandler* pHdl = GetInputHdl();
    1457           0 :     if (pHdl)
    1458           0 :         pHdl->SetMode( eMode );
    1459           0 : }
    1460             : 
    1461          47 : sal_Bool ScModule::IsEditMode()
    1462             : {
    1463          47 :     ScInputHandler* pHdl = GetInputHdl();
    1464          47 :     return pHdl && pHdl->IsEditMode();
    1465             : }
    1466             : 
    1467           0 : sal_Bool ScModule::IsInputMode()
    1468             : {
    1469           0 :     ScInputHandler* pHdl = GetInputHdl();
    1470           0 :     return pHdl && pHdl->IsInputMode();
    1471             : }
    1472             : 
    1473           0 : sal_Bool ScModule::InputKeyEvent( const KeyEvent& rKEvt, sal_Bool bStartEdit )
    1474             : {
    1475           0 :     ScInputHandler* pHdl = GetInputHdl();
    1476           0 :     return ( pHdl ? pHdl->KeyInput( rKEvt, bStartEdit ) : false );
    1477             : }
    1478             : 
    1479          97 : void ScModule::InputEnterHandler( sal_uInt8 nBlockMode )
    1480             : {
    1481          97 :     if ( !SFX_APP()->IsDowning() )                                  // nicht beim Programmende
    1482             :     {
    1483          97 :         ScInputHandler* pHdl = GetInputHdl();
    1484          97 :         if (pHdl)
    1485          97 :             pHdl->EnterHandler( nBlockMode );
    1486             :     }
    1487          97 : }
    1488             : 
    1489           0 : void ScModule::InputCancelHandler()
    1490             : {
    1491           0 :     ScInputHandler* pHdl = GetInputHdl();
    1492           0 :     if (pHdl)
    1493           0 :         pHdl->CancelHandler();
    1494           0 : }
    1495             : 
    1496           0 : void ScModule::InputSelection( EditView* pView )
    1497             : {
    1498           0 :     ScInputHandler* pHdl = GetInputHdl();
    1499           0 :     if (pHdl)
    1500           0 :         pHdl->InputSelection( pView );
    1501           0 : }
    1502             : 
    1503           0 : void ScModule::InputChanged( EditView* pView )
    1504             : {
    1505           0 :     ScInputHandler* pHdl = GetInputHdl();
    1506           0 :     if (pHdl)
    1507           0 :         pHdl->InputChanged( pView );
    1508           0 : }
    1509             : 
    1510         201 : void ScModule::ViewShellGone( ScTabViewShell* pViewSh )
    1511             : {
    1512         201 :     ScInputHandler* pHdl = GetInputHdl();
    1513         201 :     if (pHdl)
    1514           8 :         pHdl->ViewShellGone( pViewSh );
    1515         201 : }
    1516             : 
    1517           0 : void ScModule::SetRefInputHdl( ScInputHandler* pNew )
    1518             : {
    1519           0 :     pRefInputHandler = pNew;
    1520           0 : }
    1521             : 
    1522         201 : ScInputHandler* ScModule::GetRefInputHdl()
    1523             : {
    1524         201 :     return pRefInputHandler;
    1525             : }
    1526             : 
    1527             : //------------------------------------------------------------------------
    1528             : //  Olk's Krempel:
    1529             : 
    1530           0 : void ScModule::InputGetSelection( xub_StrLen& rStart, xub_StrLen& rEnd )
    1531             : {
    1532           0 :     ScInputHandler* pHdl = GetInputHdl();
    1533           0 :     if (pHdl)
    1534           0 :         pHdl->InputGetSelection( rStart, rEnd );
    1535           0 : }
    1536             : 
    1537           0 : void ScModule::InputSetSelection( xub_StrLen nStart, xub_StrLen nEnd )
    1538             : {
    1539           0 :     ScInputHandler* pHdl = GetInputHdl();
    1540           0 :     if (pHdl)
    1541           0 :         pHdl->InputSetSelection( nStart, nEnd );
    1542           0 : }
    1543             : 
    1544           0 : void ScModule::InputReplaceSelection( const String& rStr )
    1545             : {
    1546           0 :     ScInputHandler* pHdl = GetInputHdl();
    1547           0 :     if (pHdl)
    1548           0 :         pHdl->InputReplaceSelection( rStr );
    1549           0 : }
    1550             : 
    1551           0 : String ScModule::InputGetFormulaStr()
    1552             : {
    1553           0 :     ScInputHandler* pHdl = GetInputHdl();
    1554           0 :     String aStr;
    1555           0 :     if ( pHdl )
    1556           0 :         aStr = pHdl->GetFormString();
    1557           0 :     return aStr;
    1558             : }
    1559             : 
    1560           0 : void ScModule::ActivateInputWindow( const String* pStrFormula, sal_Bool bMatrix )
    1561             : {
    1562           0 :     ScInputHandler* pHdl = GetInputHdl();
    1563           0 :     if ( pHdl )
    1564             :     {
    1565           0 :         ScInputWindow* pWin = pHdl->GetInputWindow();
    1566           0 :         if ( pStrFormula )
    1567             :         {
    1568             :             // Formel uebernehmen
    1569           0 :             if ( pWin )
    1570             :             {
    1571           0 :                 pWin->SetFuncString( *pStrFormula, false );
    1572             :                 // SetSumAssignMode wegen sal_False nicht noetig
    1573             :             }
    1574           0 :             sal_uInt8 nMode = bMatrix ? SC_ENTER_MATRIX : SC_ENTER_NORMAL;
    1575           0 :             pHdl->EnterHandler( nMode );
    1576             : 
    1577             :             //  ohne Invalidate bleibt die Selektion stehen, wenn die Formel unveraendert ist
    1578           0 :             if (pWin)
    1579           0 :                 pWin->TextInvalidate();
    1580             :         }
    1581             :         else
    1582             :         {
    1583             :             // Abbrechen
    1584           0 :             if ( pWin )
    1585             :             {
    1586           0 :                 pWin->SetFuncString( EMPTY_STRING, false );
    1587             :                 // SetSumAssignMode wegen sal_False nicht noetig
    1588             :             }
    1589           0 :             pHdl->CancelHandler();
    1590             :         }
    1591             :     }
    1592           0 : }
    1593             : 
    1594             : //------------------------------------------------------------------
    1595             : //
    1596             : //                  Referenz - Dialoge
    1597             : //
    1598             : //------------------------------------------------------------------
    1599             : 
    1600           0 : void ScModule::SetRefDialog( sal_uInt16 nId, sal_Bool bVis, SfxViewFrame* pViewFrm )
    1601             : {
    1602             :     //! move reference dialog handling to view
    1603             :     //! (only keep function autopilot here for references to other documents)
    1604             : 
    1605           0 :     if(nCurRefDlgId==0 || (nId==nCurRefDlgId && !bVis))
    1606             :     {
    1607           0 :         if ( !pViewFrm )
    1608           0 :             pViewFrm = SfxViewFrame::Current();
    1609             : 
    1610             :         // bindings update causes problems with update of stylist if
    1611             :         // current style family has changed
    1612             :         //if ( pViewFrm )
    1613             :         //  pViewFrm->GetBindings().Update();       // to avoid trouble in LockDispatcher
    1614             : 
    1615           0 :         nCurRefDlgId = bVis ? nId : 0 ;             // before SetChildWindow
    1616             : 
    1617           0 :         if ( pViewFrm )
    1618             :         {
    1619             :             //  store the dialog id also in the view shell
    1620           0 :             SfxViewShell* pViewSh = pViewFrm->GetViewShell();
    1621           0 :             if ( pViewSh && pViewSh->ISA( ScTabViewShell ) )
    1622           0 :                 ((ScTabViewShell*)pViewSh)->SetCurRefDlgId( nCurRefDlgId );
    1623             :             else
    1624             :             {
    1625             :                 // no ScTabViewShell - possible for example from a Basic macro
    1626           0 :                 bVis = false;
    1627           0 :                 nCurRefDlgId = 0;   // don't set nCurRefDlgId if no dialog is created
    1628             :             }
    1629             : 
    1630           0 :             pViewFrm->SetChildWindow( nId, bVis );
    1631             :         }
    1632             : 
    1633           0 :         SfxApplication* pSfxApp = SFX_APP();
    1634           0 :         pSfxApp->Broadcast( SfxSimpleHint( FID_REFMODECHANGED ) );
    1635             :     }
    1636           0 : }
    1637             : 
    1638           0 : static SfxChildWindow* lcl_GetChildWinFromAnyView( sal_uInt16 nId )
    1639             : {
    1640             :     //  first try the current view
    1641             : 
    1642           0 :     SfxViewFrame* pViewFrm = SfxViewFrame::Current();
    1643             :     // #i46999# current view frame can be null (for example, when closing help)
    1644           0 :     SfxChildWindow* pChildWnd = pViewFrm ? pViewFrm->GetChildWindow( nId ) : NULL;
    1645           0 :     if ( pChildWnd )
    1646           0 :         return pChildWnd;           // found in the current view
    1647             : 
    1648             :     //  if not found there, get the child window from any open view
    1649             :     //  it can be open only in one view because nCurRefDlgId is global
    1650             : 
    1651           0 :     pViewFrm = SfxViewFrame::GetFirst();
    1652           0 :     while ( pViewFrm )
    1653             :     {
    1654           0 :         pChildWnd = pViewFrm->GetChildWindow( nId );
    1655           0 :         if ( pChildWnd )
    1656           0 :             return pChildWnd;       // found in any view
    1657             : 
    1658           0 :         pViewFrm = SfxViewFrame::GetNext( *pViewFrm );
    1659             :     }
    1660             : 
    1661           0 :     return NULL;                    // none found
    1662             : }
    1663             : 
    1664           0 : sal_Bool ScModule::IsModalMode(SfxObjectShell* pDocSh)
    1665             : {
    1666             :     //! move reference dialog handling to view
    1667             :     //! (only keep function autopilot here for references to other documents)
    1668             : 
    1669           0 :     sal_Bool bIsModal = false;
    1670             : 
    1671           0 :     if ( nCurRefDlgId )
    1672             :     {
    1673           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1674           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1675           0 :         if ( pChildWnd )
    1676             :         {
    1677           0 :             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
    1678           0 :             bIsModal = pChildWnd->IsVisible() &&
    1679           0 :                 !( pRefDlg->IsRefInputMode() && pRefDlg->IsDocAllowed(pDocSh) );
    1680             :         }
    1681           0 :         else if(pModalDlg)
    1682             :         {
    1683           0 :             bIsModal = pModalDlg->IsVisible() && !(pModalDlg->IsRefInputMode() && pModalDlg->IsDocAllowed(pDocSh) );
    1684             :         }
    1685             :         else
    1686             :         {
    1687             :             // in 592 and above, the dialog isn't visible in other views
    1688             :             //  if the dialog is open but can't be accessed, disable input
    1689             : 
    1690           0 :             bIsModal = sal_True;
    1691             :         }
    1692             : 
    1693             :         //  pChildWnd kann 0 sein, wenn der Dialog nach dem Umschalten
    1694             :         //  von einer anderen Shell noch nicht erzeugt wurde (z.B. in GetFocus)
    1695             :     }
    1696           0 :     else if (pDocSh)
    1697             :     {
    1698           0 :         ScInputHandler* pHdl = GetInputHdl();
    1699           0 :         if ( pHdl )
    1700           0 :             bIsModal = pHdl->IsModalMode(pDocSh);
    1701             :     }
    1702             : 
    1703           0 :     return bIsModal;
    1704             : }
    1705             : 
    1706           0 : sal_Bool ScModule::IsTableLocked()
    1707             : {
    1708             :     //! move reference dialog handling to view
    1709             :     //! (only keep function autopilot here for references to other documents)
    1710             : 
    1711           0 :     sal_Bool bLocked = false;
    1712             : 
    1713             :     //  bisher nur bei ScAnyRefDlg
    1714             : 
    1715           0 :     if ( nCurRefDlgId )
    1716             :     {
    1717           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1718           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1719           0 :         if ( pChildWnd )
    1720           0 :             bLocked = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow())->IsTableLocked();
    1721           0 :         else if( pModalDlg )
    1722           0 :             bLocked = pModalDlg->IsTableLocked();
    1723             :         else
    1724           0 :             bLocked = sal_True;     // for other views, see IsModalMode
    1725             :     }
    1726             : 
    1727           0 :     return bLocked;
    1728             : }
    1729             : 
    1730        2073 : sal_Bool ScModule::IsRefDialogOpen()
    1731             : {
    1732             :     //! move reference dialog handling to view
    1733             :     //! (only keep function autopilot here for references to other documents)
    1734             : 
    1735        2073 :     sal_Bool bIsOpen = false;
    1736             : 
    1737        2073 :     if ( nCurRefDlgId )
    1738             :     {
    1739           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1740           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1741           0 :         if ( pChildWnd )
    1742           0 :             bIsOpen = pChildWnd->IsVisible();
    1743           0 :         else if(pModalDlg)
    1744           0 :             bIsOpen = pModalDlg->IsVisible();
    1745             :         else
    1746           0 :             bIsOpen = sal_True;     // for other views, see IsModalMode
    1747             :     }
    1748             : 
    1749        2073 :     return bIsOpen;
    1750             : }
    1751             : 
    1752        2928 : sal_Bool ScModule::IsFormulaMode()
    1753             : {
    1754             :     //! move reference dialog handling to view
    1755             :     //! (only keep function autopilot here for references to other documents)
    1756             : 
    1757        2928 :     sal_Bool bIsFormula = false;
    1758             : 
    1759        2928 :     if ( nCurRefDlgId )
    1760             :     {
    1761           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1762           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1763           0 :         if ( pChildWnd )
    1764             :         {
    1765           0 :             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
    1766           0 :             bIsFormula = pChildWnd->IsVisible() && pRefDlg->IsRefInputMode();
    1767             :         }
    1768           0 :         else if(pModalDlg)
    1769             :         {
    1770           0 :             bIsFormula = pModalDlg->IsVisible() && pModalDlg->IsRefInputMode();
    1771             :         }
    1772             :         else
    1773           0 :             bIsFormula = true;
    1774             :     }
    1775             :     else
    1776             :     {
    1777        2928 :         ScInputHandler* pHdl = GetInputHdl();
    1778        2928 :         if ( pHdl )
    1779        2538 :             bIsFormula = pHdl->IsFormulaMode();
    1780             :     }
    1781             : 
    1782        2928 :     if (bIsInEditCommand)
    1783           0 :         bIsFormula = sal_True;
    1784             : 
    1785        2928 :     return bIsFormula;
    1786             : }
    1787             : 
    1788           0 : static void lcl_MarkedTabs( const ScMarkData& rMark, SCTAB& rStartTab, SCTAB& rEndTab )
    1789             : {
    1790           0 :     if (rMark.GetSelectCount() > 1)
    1791             :     {
    1792           0 :         rEndTab = rMark.GetLastSelected();
    1793           0 :         rStartTab = rMark.GetFirstSelected();
    1794             :     }
    1795           0 : }
    1796             : 
    1797           0 : void ScModule::SetReference( const ScRange& rRef, ScDocument* pDoc,
    1798             :                                     const ScMarkData* pMarkData )
    1799             : {
    1800             :     //! move reference dialog handling to view
    1801             :     //! (only keep function autopilot here for references to other documents)
    1802             : 
    1803             :     //  in Ref-Dialogen wird hiermit auch das Zoom-In ausgeloest,
    1804             :     //  wenn Start und Ende der Ref unterschiedlich sind
    1805             : 
    1806           0 :     ScRange aNew = rRef;
    1807           0 :     aNew.Justify();                 // immer "richtig herum"
    1808             : 
    1809           0 :     if( nCurRefDlgId )
    1810             :     {
    1811           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1812           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1813             :         OSL_ENSURE( pChildWnd || pModalDlg, "NoChildWin" );
    1814           0 :         if ( pChildWnd )
    1815             :         {
    1816           0 :             if ( nCurRefDlgId == SID_OPENDLG_CONSOLIDATE && pMarkData )
    1817             :             {
    1818           0 :                 SCTAB nStartTab = aNew.aStart.Tab();
    1819           0 :                 SCTAB nEndTab   = aNew.aEnd.Tab();
    1820           0 :                 lcl_MarkedTabs( *pMarkData, nStartTab, nEndTab );
    1821           0 :                 aNew.aStart.SetTab(nStartTab);
    1822           0 :                 aNew.aEnd.SetTab(nEndTab);
    1823             :             }
    1824             : 
    1825           0 :             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
    1826             : 
    1827             :             //  hide the (color) selection now instead of later from LoseFocus,
    1828             :             //  don't abort the ref input that causes this call (bDoneRefMode = sal_False)
    1829           0 :             pRefDlg->HideReference( false );
    1830           0 :             pRefDlg->SetReference( aNew, pDoc );
    1831             :         }
    1832           0 :         else if(pModalDlg)
    1833             :         {
    1834             :             //  hide the (color) selection now instead of later from LoseFocus,
    1835             :             //  don't abort the ref input that causes this call (bDoneRefMode = sal_False)
    1836           0 :             pModalDlg->HideReference( false );
    1837           0 :             pModalDlg->SetReference( aNew, pDoc );
    1838             :         }
    1839             :     }
    1840             :     else
    1841             :     {
    1842           0 :         ScInputHandler* pHdl = GetInputHdl();
    1843           0 :         if (pHdl)
    1844           0 :             pHdl->SetReference( aNew, pDoc );
    1845             :         else
    1846             :         {
    1847             :             OSL_FAIL("SetReference ohne Empfaenger");
    1848             :         }
    1849             :     }
    1850           0 : }
    1851             : 
    1852           0 : void ScModule::AddRefEntry()                        // "Mehrfachselektion"
    1853             : {
    1854             :     //! move reference dialog handling to view
    1855             :     //! (only keep function autopilot here for references to other documents)
    1856             : 
    1857           0 :     if ( nCurRefDlgId )
    1858             :     {
    1859           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1860           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1861             :         OSL_ENSURE( pChildWnd || pModalDlg, "NoChildWin" );
    1862           0 :         if ( pChildWnd )
    1863             :         {
    1864           0 :             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
    1865           0 :             pRefDlg->AddRefEntry();
    1866             :         }
    1867           0 :         else if(pModalDlg)
    1868           0 :             pModalDlg->AddRefEntry();
    1869             :     }
    1870             :     else
    1871             :     {
    1872           0 :         ScInputHandler* pHdl = GetInputHdl();
    1873           0 :         if (pHdl)
    1874           0 :             pHdl->AddRefEntry();
    1875             :     }
    1876           0 : }
    1877             : 
    1878           0 : void ScModule::EndReference()
    1879             : {
    1880             :     //! move reference dialog handling to view
    1881             :     //! (only keep function autopilot here for references to other documents)
    1882             : 
    1883             :     //  in Ref-Dialogen wird hiermit auch das Zoom-In wieder aufgehoben
    1884             : 
    1885             :     //! ShowRefFrame am InputHdl, wenn der Funktions-AP offen ist ???
    1886             : 
    1887           0 :     if ( nCurRefDlgId )
    1888             :     {
    1889           0 :         SfxChildWindow* pChildWnd = lcl_GetChildWinFromAnyView( nCurRefDlgId );
    1890           0 :         ScAnyRefModalDlg* pModalDlg = GetCurrentAnyRefDlg();
    1891             :         OSL_ENSURE( pChildWnd || pModalDlg, "NoChildWin" );
    1892           0 :         if ( pChildWnd )
    1893             :         {
    1894           0 :             IAnyRefDialog* pRefDlg = dynamic_cast<IAnyRefDialog*>(pChildWnd->GetWindow());
    1895           0 :             pRefDlg->SetActive();
    1896             :         }
    1897             :         else
    1898           0 :             pModalDlg->SetActive();
    1899             :     }
    1900           0 : }
    1901             : 
    1902             : //------------------------------------------------------------------
    1903             : //
    1904             : //                  Idle / Online-Spelling
    1905             : //
    1906             : //------------------------------------------------------------------
    1907             : 
    1908        9013 : void ScModule::AnythingChanged()
    1909             : {
    1910        9013 :     sal_uLong nOldTime = aIdleTimer.GetTimeout();
    1911        9013 :     if ( nOldTime != SC_IDLE_MIN )
    1912           2 :         aIdleTimer.SetTimeout( SC_IDLE_MIN );
    1913             : 
    1914        9013 :     nIdleCount = 0;
    1915        9013 : }
    1916             : 
    1917           0 : static void lcl_CheckNeedsRepaint( ScDocShell* pDocShell )
    1918             : {
    1919           0 :     SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
    1920           0 :     while ( pFrame )
    1921             :     {
    1922           0 :         SfxViewShell* p = pFrame->GetViewShell();
    1923           0 :         ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
    1924           0 :         if ( pViewSh )
    1925           0 :             pViewSh->CheckNeedsRepaint();
    1926           0 :         pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
    1927             :     }
    1928           0 : }
    1929             : 
    1930        6480 : IMPL_LINK_NOARG(ScModule, IdleHandler)
    1931             : {
    1932        3240 :     if ( Application::AnyInput( VCL_INPUT_MOUSEANDKEYBOARD ) )
    1933             :     {
    1934           0 :         aIdleTimer.Start();         // Timeout unveraendert
    1935           0 :         return 0;
    1936             :     }
    1937             : 
    1938        3240 :     sal_Bool bMore = false;
    1939        3240 :     ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
    1940        3240 :     if ( pDocSh )
    1941             :     {
    1942        1590 :         ScDocument* pDoc = pDocSh->GetDocument();
    1943             : 
    1944        1590 :         sal_Bool bLinks = pDoc->IdleCheckLinks();
    1945        1590 :         sal_Bool bWidth = pDoc->IdleCalcTextWidth();
    1946        1590 :         sal_Bool bSpell = pDoc->ContinueOnlineSpelling();
    1947        1590 :         if ( bSpell )
    1948         192 :             aSpellTimer.Start();                    // da ist noch was
    1949             : 
    1950        1590 :         bMore = bLinks || bWidth || bSpell;         // ueberhaupt noch was?
    1951             : 
    1952             :         //  While calculating a Basic formula, a paint event may have occurred,
    1953             :         //  so check the bNeedsRepaint flags for this document's views
    1954        1590 :         if (bWidth)
    1955           0 :             lcl_CheckNeedsRepaint( pDocSh );
    1956             :     }
    1957             : 
    1958        3240 :     sal_uLong nOldTime = aIdleTimer.GetTimeout();
    1959        3240 :     sal_uLong nNewTime = nOldTime;
    1960        3240 :     if ( bMore )
    1961             :     {
    1962         192 :         nNewTime = SC_IDLE_MIN;
    1963         192 :         nIdleCount = 0;
    1964             :     }
    1965             :     else
    1966             :     {
    1967             :         //  SC_IDLE_COUNT mal mit initialem Timeout, dann hochzaehlen
    1968             : 
    1969        3048 :         if ( nIdleCount < SC_IDLE_COUNT )
    1970        2926 :             ++nIdleCount;
    1971             :         else
    1972             :         {
    1973         122 :             nNewTime += SC_IDLE_STEP;
    1974         122 :             if ( nNewTime > SC_IDLE_MAX )
    1975          16 :                 nNewTime = SC_IDLE_MAX;
    1976             :         }
    1977             :     }
    1978        3240 :     if ( nNewTime != nOldTime )
    1979         106 :         aIdleTimer.SetTimeout( nNewTime );
    1980             : 
    1981        3240 :     aIdleTimer.Start();
    1982        3240 :     return 0;
    1983             : }
    1984             : 
    1985         544 : IMPL_LINK_NOARG(ScModule, SpellTimerHdl)
    1986             : {
    1987         272 :     if ( Application::AnyInput( VCL_INPUT_KEYBOARD ) )
    1988             :     {
    1989           0 :         aSpellTimer.Start();
    1990           0 :         return 0;                   // dann spaeter wieder...
    1991             :     }
    1992             : 
    1993         272 :     ScDocShell* pDocSh = PTR_CAST( ScDocShell, SfxObjectShell::Current() );
    1994         272 :     if ( pDocSh )
    1995             :     {
    1996         266 :         ScDocument* pDoc = pDocSh->GetDocument();
    1997         266 :         if ( pDoc->ContinueOnlineSpelling() )
    1998         169 :             aSpellTimer.Start();
    1999             :     }
    2000         272 :     return 0;
    2001             : }
    2002             : 
    2003             :     //virtuelle Methoden fuer den Optionendialog
    2004           0 : SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
    2005             : {
    2006           0 :     SfxItemSet*  pRet = 0;
    2007           0 :     if(SID_SC_EDITOPTIONS == nId)
    2008             :     {
    2009           0 :         pRet = new SfxItemSet( GetPool(),
    2010             :                             // TP_CALC:
    2011             :                             SID_SCDOCOPTIONS,       SID_SCDOCOPTIONS,
    2012             :                             // TP_VIEW:
    2013             :                             SID_SCVIEWOPTIONS,      SID_SCVIEWOPTIONS,
    2014             :                             SID_SC_OPT_SYNCZOOM,    SID_SC_OPT_SYNCZOOM,
    2015             :                             // TP_INPUT:
    2016             :                             SID_SC_INPUT_SELECTION,SID_SC_INPUT_MARK_HEADER,
    2017             :                             SID_SC_INPUT_TEXTWYSIWYG,SID_SC_INPUT_TEXTWYSIWYG,
    2018             :                             SID_SC_INPUT_REPLCELLSWARN,SID_SC_INPUT_REPLCELLSWARN,
    2019             :                             // TP_USERLISTS:
    2020             :                             SCITEM_USERLIST,        SCITEM_USERLIST,
    2021             :                             // TP_PRINT:
    2022             :                             SID_SCPRINTOPTIONS, SID_SCPRINTOPTIONS,
    2023             :                             // TP_GRID:
    2024             :                             SID_ATTR_GRID_OPTIONS, SID_ATTR_GRID_OPTIONS,
    2025             :                             //
    2026             :                             SID_ATTR_METRIC,        SID_ATTR_METRIC,
    2027             :                             SID_ATTR_DEFTABSTOP,    SID_ATTR_DEFTABSTOP,
    2028             :                             // TP_COMPATIBILITY
    2029             :                             SID_SC_OPT_KEY_BINDING_COMPAT, SID_SC_OPT_KEY_BINDING_COMPAT,
    2030             :                             // TP_DEFAULTS
    2031             :                             SID_SCDEFAULTSOPTIONS, SID_SCDEFAULTSOPTIONS,
    2032             :                             // TP_FORMULA
    2033             :                             SID_SCFORMULAOPTIONS, SID_SCFORMULAOPTIONS,
    2034           0 :                             0 );
    2035             : 
    2036           0 :         const ScAppOptions& rAppOpt = GetAppOptions();
    2037             : 
    2038           0 :         ScDocShell*     pDocSh = PTR_CAST(ScDocShell,
    2039             :                                             SfxObjectShell::Current());
    2040             :         ScDocOptions    aCalcOpt = pDocSh
    2041           0 :                             ? pDocSh->GetDocument()->GetDocOptions()
    2042           0 :                             : GetDocOptions();
    2043             : 
    2044           0 :         ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,
    2045             :                                             SfxViewShell::Current());
    2046             :         ScViewOptions   aViewOpt = pViewSh
    2047           0 :                             ? pViewSh->GetViewData()->GetOptions()
    2048           0 :                             : GetViewOptions();
    2049             : 
    2050           0 :         ScUserListItem  aULItem( SCITEM_USERLIST );
    2051           0 :         ScUserList*     pUL = ScGlobal::GetUserList();
    2052             : 
    2053             :         //  SFX_APP()->GetOptions( aSet );
    2054             : 
    2055             :         pRet->Put( SfxUInt16Item( SID_ATTR_METRIC,
    2056           0 :                         sal::static_int_cast<sal_uInt16>(rAppOpt.GetAppMetric()) ) );
    2057             : 
    2058             :         // TP_CALC
    2059             :         pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP,
    2060           0 :                         aCalcOpt.GetTabDistance()));
    2061           0 :         pRet->Put( ScTpCalcItem( SID_SCDOCOPTIONS, aCalcOpt ) );
    2062             : 
    2063             :         // TP_VIEW
    2064           0 :         pRet->Put( ScTpViewItem( SID_SCVIEWOPTIONS, aViewOpt ) );
    2065           0 :         pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, rAppOpt.GetSynchronizeZoom() ) );
    2066             : 
    2067             :         // TP_INPUT
    2068           0 :         const ScInputOptions& rInpOpt = GetInputOptions();
    2069             :         pRet->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS,
    2070           0 :                     rInpOpt.GetMoveDir() ) );
    2071             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_SELECTION,
    2072           0 :                     rInpOpt.GetMoveSelection() ) );
    2073             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE,
    2074           0 :                     rInpOpt.GetEnterEdit() ) );
    2075             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND,
    2076           0 :                     rInpOpt.GetExtendFormat() ) );
    2077             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER,
    2078           0 :                     rInpOpt.GetRangeFinder() ) );
    2079             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND,
    2080           0 :                     rInpOpt.GetExpandRefs() ) );
    2081             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER,
    2082           0 :                     rInpOpt.GetMarkHeader() ) );
    2083             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG,
    2084           0 :                     rInpOpt.GetTextWysiwyg() ) );
    2085             :         pRet->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN,
    2086           0 :                     rInpOpt.GetReplaceCellsWarn() ) );
    2087             : 
    2088             :         // RID_SC_TP_PRINT
    2089           0 :         pRet->Put( ScTpPrintItem( SID_SCPRINTOPTIONS, GetPrintOptions() ) );
    2090             : 
    2091             :         // TP_GRID
    2092           0 :         SvxGridItem* pSvxGridItem = aViewOpt.CreateGridItem();
    2093           0 :         pRet->Put( *pSvxGridItem );
    2094           0 :         delete pSvxGridItem;
    2095             : 
    2096             :         // TP_USERLISTS
    2097           0 :         if ( pUL )
    2098             :         {
    2099           0 :             aULItem.SetUserList( *pUL );
    2100           0 :             pRet->Put(aULItem);
    2101             :         }
    2102             : 
    2103             :         // TP_COMPATIBILITY
    2104             :         pRet->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT,
    2105           0 :                                    rAppOpt.GetKeyBindingType() ) );
    2106             : 
    2107             :         // TP_DEFAULTS
    2108           0 :         pRet->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, GetDefaultsOptions() ) );
    2109             : 
    2110             :         // TP_FORMULA
    2111           0 :         pRet->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, GetFormulaOptions() ) );
    2112             :     }
    2113           0 :     return pRet;
    2114             : }
    2115             : 
    2116           0 : void ScModule::ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet )
    2117             : {
    2118           0 :     if(SID_SC_EDITOPTIONS == nId)
    2119             :     {
    2120           0 :         ModifyOptions( rSet );
    2121             :     }
    2122           0 : }
    2123             : 
    2124           0 : SfxTabPage*  ScModule::CreateTabPage( sal_uInt16 nId, Window* pParent, const SfxItemSet& rSet )
    2125             : {
    2126           0 :     SfxTabPage* pRet = NULL;
    2127           0 :     ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
    2128             :     OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
    2129           0 :     switch(nId)
    2130             :     {
    2131             :         case SID_SC_TP_LAYOUT:
    2132             :                                 {
    2133           0 :                                     ::CreateTabPage ScTpLayoutOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_LAYOUT );
    2134           0 :                                     if ( ScTpLayoutOptionsCreate )
    2135           0 :                                         pRet =  (*ScTpLayoutOptionsCreate) (pParent, rSet);
    2136             :                                 }
    2137           0 :                                 break;
    2138             :         case SID_SC_TP_CONTENT:
    2139             :                                 {
    2140           0 :                                     ::CreateTabPage ScTpContentOptionsCreate = pFact->GetTabPageCreatorFunc(RID_SCPAGE_CONTENT);
    2141           0 :                                     if ( ScTpContentOptionsCreate )
    2142           0 :                                         pRet = (*ScTpContentOptionsCreate)(pParent, rSet);
    2143             :                                 }
    2144           0 :                                 break;
    2145           0 :         case SID_SC_TP_GRID:            pRet = SvxGridTabPage::Create(pParent, rSet); break;
    2146             :         case SID_SC_TP_USERLISTS:
    2147             :                                 {
    2148           0 :                                     ::CreateTabPage ScTpUserListsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_USERLISTS );
    2149           0 :                                     if ( ScTpUserListsCreate )
    2150           0 :                                             pRet = (*ScTpUserListsCreate)( pParent, rSet);
    2151             :                                 }
    2152           0 :                                 break;
    2153             :         case SID_SC_TP_CALC:
    2154             :                                 {
    2155           0 :                                                     ::CreateTabPage ScTpCalcOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_CALC );
    2156           0 :                                                     if ( ScTpCalcOptionsCreate )
    2157           0 :                                                         pRet = (*ScTpCalcOptionsCreate)(pParent, rSet);
    2158             :                                 }
    2159           0 :                                 break;
    2160             :         case SID_SC_TP_FORMULA:
    2161             :         {
    2162           0 :             ::CreateTabPage ScTpFormulaOptionsCreate = pFact->GetTabPageCreatorFunc (RID_SCPAGE_FORMULA);
    2163           0 :             if (ScTpFormulaOptionsCreate)
    2164           0 :                 pRet = (*ScTpFormulaOptionsCreate)(pParent, rSet);
    2165             :         }
    2166           0 :         break;
    2167             :         case SID_SC_TP_COMPATIBILITY:
    2168             :         {
    2169           0 :             ::CreateTabPage ScTpCompatOptionsCreate = pFact->GetTabPageCreatorFunc (RID_SCPAGE_COMPATIBILITY);
    2170           0 :             if (ScTpCompatOptionsCreate)
    2171           0 :                 pRet = (*ScTpCompatOptionsCreate)(pParent, rSet);
    2172             :         }
    2173           0 :         break;
    2174             :         case SID_SC_TP_CHANGES:
    2175             :                                 {
    2176           0 :                                             ::CreateTabPage ScRedlineOptionsTabPageCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE );
    2177           0 :                                             if ( ScRedlineOptionsTabPageCreate )
    2178           0 :                                                     pRet =(*ScRedlineOptionsTabPageCreate)(pParent, rSet);
    2179             :                                 }
    2180           0 :                         break;
    2181             :         case RID_SC_TP_PRINT:
    2182             :                                 {
    2183           0 :                                     ::CreateTabPage ScTpPrintOptionsCreate =    pFact->GetTabPageCreatorFunc( RID_SCPAGE_PRINT );
    2184           0 :                                     if ( ScTpPrintOptionsCreate )
    2185           0 :                                         pRet = (*ScTpPrintOptionsCreate)( pParent, rSet);
    2186             :                                 }
    2187           0 :             break;
    2188             :         case RID_SC_TP_DEFAULTS:
    2189             :             {
    2190           0 :                 ::CreateTabPage ScTpDefaultsOptionsCreate = pFact->GetTabPageCreatorFunc( RID_SCPAGE_DEFAULTS );
    2191           0 :                 if ( ScTpDefaultsOptionsCreate )
    2192           0 :                     pRet = (*ScTpDefaultsOptionsCreate)( pParent, rSet);
    2193             :             }
    2194           0 :             break;
    2195             : 
    2196             :         case RID_OFA_TP_INTERNATIONAL:
    2197             :         {
    2198           0 :             SfxAbstractDialogFactory* pSfxFact = SfxAbstractDialogFactory::Create();
    2199           0 :             if ( pSfxFact )
    2200             :             {
    2201           0 :                 ::CreateTabPage fnCreatePage = pSfxFact->GetTabPageCreatorFunc( nId );
    2202           0 :                 if ( fnCreatePage )
    2203           0 :                     pRet = (*fnCreatePage)( pParent, rSet );
    2204             :             }
    2205             :         }
    2206             :     }
    2207             : 
    2208             :     OSL_ENSURE( pRet, "ScModule::CreateTabPage(): no valid ID for TabPage!" );
    2209             : 
    2210           0 :     return pRet;
    2211             : }
    2212             : 
    2213             : //------------------------------------------------------------------
    2214             : 
    2215           0 : IMPL_LINK( ScModule, CalcFieldValueHdl, EditFieldInfo*, pInfo )
    2216             : {
    2217             :     //! mit ScFieldEditEngine zusammenfassen !!!
    2218             : 
    2219           0 :     if (pInfo)
    2220             :     {
    2221           0 :         const SvxFieldItem& rField = pInfo->GetField();
    2222           0 :         const SvxFieldData* pField = rField.GetField();
    2223             : 
    2224           0 :         if (pField && pField->ISA(SvxURLField))
    2225             :         {
    2226             :             /******************************************************************
    2227             :             * URL-Field
    2228             :             ******************************************************************/
    2229             : 
    2230           0 :             const SvxURLField* pURLField = (const SvxURLField*) pField;
    2231           0 :             String aURL = pURLField->GetURL();
    2232             : 
    2233           0 :             switch ( pURLField->GetFormat() )
    2234             :             {
    2235             :                 case SVXURLFORMAT_APPDEFAULT: //!!! einstellbar an App???
    2236             :                 case SVXURLFORMAT_REPR:
    2237             :                 {
    2238           0 :                     pInfo->SetRepresentation( pURLField->GetRepresentation() );
    2239             :                 }
    2240           0 :                 break;
    2241             : 
    2242             :                 case SVXURLFORMAT_URL:
    2243             :                 {
    2244           0 :                     pInfo->SetRepresentation( aURL );
    2245             :                 }
    2246           0 :                 break;
    2247             :             }
    2248             : 
    2249             :             svtools::ColorConfigEntry eEntry =
    2250           0 :                 INetURLHistory::GetOrCreate()->QueryUrl( aURL ) ? svtools::LINKSVISITED : svtools::LINKS;
    2251           0 :             pInfo->SetTxtColor( GetColorConfig().GetColorValue(eEntry).nColor );
    2252             :         }
    2253             :         else
    2254             :         {
    2255             :             OSL_FAIL("unbekannter Feldbefehl");
    2256           0 :             pInfo->SetRepresentation(OUString('?'));
    2257             :         }
    2258             :     }
    2259             : 
    2260           0 :     return 0;
    2261             : }
    2262             : 
    2263           0 : sal_Bool ScModule::RegisterRefWindow( sal_uInt16 nSlotId, Window *pWnd )
    2264             : {
    2265           0 :     std::list<Window*> & rlRefWindow = m_mapRefWindow[nSlotId];
    2266             : 
    2267           0 :     if( std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd ) == rlRefWindow.end() )
    2268             :     {
    2269           0 :         rlRefWindow.push_back( pWnd );
    2270           0 :         return sal_True;
    2271             :     }
    2272             : 
    2273           0 :     return false;
    2274             : }
    2275             : 
    2276           0 : sal_Bool  ScModule::UnregisterRefWindow( sal_uInt16 nSlotId, Window *pWnd )
    2277             : {
    2278           0 :     std::map<sal_uInt16, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId );
    2279             : 
    2280           0 :     if( iSlot == m_mapRefWindow.end() )
    2281           0 :         return false;
    2282             : 
    2283           0 :     std::list<Window*> & rlRefWindow = iSlot->second;
    2284             : 
    2285           0 :     std::list<Window*>::iterator i = std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd );
    2286             : 
    2287           0 :     if( i == rlRefWindow.end() )
    2288           0 :         return false;
    2289             : 
    2290           0 :     rlRefWindow.erase( i );
    2291             : 
    2292           0 :     if( rlRefWindow.empty() )
    2293           0 :         m_mapRefWindow.erase( nSlotId );
    2294             : 
    2295           0 :     return sal_True;
    2296             : }
    2297             : 
    2298           0 : sal_Bool  ScModule::IsAliveRefDlg( sal_uInt16 nSlotId, Window *pWnd )
    2299             : {
    2300           0 :     std::map<sal_uInt16, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId );
    2301             : 
    2302           0 :     if( iSlot == m_mapRefWindow.end() )
    2303           0 :         return false;
    2304             : 
    2305           0 :     std::list<Window*> & rlRefWindow = iSlot->second;
    2306             : 
    2307           0 :     return rlRefWindow.end() != std::find( rlRefWindow.begin(), rlRefWindow.end(), pWnd );
    2308             : }
    2309             : 
    2310           0 : Window *  ScModule::Find1RefWindow( sal_uInt16 nSlotId, Window *pWndAncestor )
    2311             : {
    2312           0 :     if (!pWndAncestor)
    2313           0 :         return NULL;
    2314             : 
    2315           0 :     std::map<sal_uInt16, std::list<Window*> >::iterator iSlot = m_mapRefWindow.find( nSlotId );
    2316             : 
    2317           0 :     if( iSlot == m_mapRefWindow.end() )
    2318           0 :         return NULL;
    2319             : 
    2320           0 :     std::list<Window*> & rlRefWindow = iSlot->second;
    2321             : 
    2322           0 :     while( Window *pParent = pWndAncestor->GetParent() ) pWndAncestor = pParent;
    2323             : 
    2324           0 :     for( std::list<Window*>::iterator i = rlRefWindow.begin(); i!=rlRefWindow.end(); ++i )
    2325           0 :         if ( pWndAncestor->IsWindowOrChild( *i, (*i)->IsSystemWindow() ) )
    2326           0 :             return *i;
    2327             : 
    2328           0 :     return NULL;
    2329             : }
    2330             : 
    2331           0 : ScAnyRefModalDlg* ScModule::GetCurrentAnyRefDlg()
    2332             : {
    2333           0 :     if(!maAnyRefDlgStack.empty())
    2334           0 :         return maAnyRefDlgStack.top();
    2335             : 
    2336           0 :     return NULL;
    2337             : }
    2338             : 
    2339           0 : void ScModule::PushNewAnyRefDlg( ScAnyRefModalDlg* pNewDlg )
    2340             : {
    2341           0 :     maAnyRefDlgStack.push( pNewDlg );
    2342             : 
    2343             :     // prevent mismatch between calls to
    2344             :     // SetInRefMode(true) and SetInRefMode(false)
    2345           0 :     if(maAnyRefDlgStack.size() != 1)
    2346           0 :         return;
    2347             : 
    2348           0 :     SfxViewShell* pViewShell = SfxViewShell::GetFirst();
    2349           0 :     while(pViewShell)
    2350             :     {
    2351           0 :         if ( pViewShell->ISA(ScTabViewShell) )
    2352             :         {
    2353           0 :             ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell;
    2354           0 :             pViewSh->SetInRefMode( true );
    2355             :         }
    2356           0 :         pViewShell = SfxViewShell::GetNext( *pViewShell );
    2357             :     }
    2358             : }
    2359             : 
    2360           0 : void ScModule::PopAnyRefDlg()
    2361             : {
    2362           0 :     maAnyRefDlgStack.pop();
    2363             : 
    2364           0 :     if(maAnyRefDlgStack.empty())
    2365             :     {
    2366             :         // no modal ref dlg any more
    2367             :         // disable the flag in ScGridWindow
    2368             : 
    2369           0 :         SfxViewShell* pViewShell = SfxViewShell::GetFirst();
    2370           0 :         while(pViewShell)
    2371             :         {
    2372           0 :             if ( pViewShell->ISA(ScTabViewShell) )
    2373             :             {
    2374           0 :                 ScTabViewShell* pViewSh = (ScTabViewShell*)pViewShell;
    2375           0 :                 pViewSh->SetInRefMode( false );
    2376             :             }
    2377           0 :             pViewShell = SfxViewShell::GetNext( *pViewShell );
    2378             :         }
    2379             : 
    2380             :     }
    2381          93 : }
    2382             : 
    2383             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10