1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
22 #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
23 #include <comphelper/processfactory.hxx>
25 #include "scitems.hxx"
26 #include <sfx2/app.hxx>
27 #include <editeng/eeitem.hxx>
29 #include <editeng/flditem.hxx>
30 #include <editeng/outliner.hxx>
31 #include <basic/sbstar.hxx>
33 #include <sfx2/sfxdlg.hxx>
34 #include <sfx2/viewfrm.hxx>
35 #include <sfx2/objface.hxx>
37 #include "IAnyRefDialog.hxx"
38 #include "anyrefdg.hxx"
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>
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>
64 #include <editeng/unolingu.hxx>
65 #include <unotools/lingucfg.hxx>
66 #include <i18nlangtag/mslangid.hxx>
67 #include <i18nlangtag/languagetag.hxx>
68 #include <com/sun/star/i18n/ScriptType.hpp>
69 #include <com/sun/star/linguistic2/XThesaurus.hpp>
70 #include <com/sun/star/lang/Locale.hpp>
74 #include "viewopti.hxx"
75 #include "docoptio.hxx"
76 #include "appoptio.hxx"
77 #include "defaultsoptions.hxx"
78 #include "formulaopt.hxx"
79 #include "inputopt.hxx"
80 #include "printopt.hxx"
81 #include "navicfg.hxx"
82 #include "addincfg.hxx"
83 #include "tabvwsh.hxx"
84 #include "prevwsh.hxx"
86 #include "drwlayer.hxx"
87 #include "uiitems.hxx"
90 #include "inputhdl.hxx"
91 #include "inputwin.hxx"
92 #include "msgpool.hxx"
93 #include "scresid.hxx"
94 #include "dwfunctr.hxx"
95 #include "formdata.hxx"
96 #include "tpprint.hxx"
97 #include "tpdefaults.hxx"
98 #include "transobj.hxx"
99 #include "detfunc.hxx"
100 #include "preview.hxx"
101 #include "dragdata.hxx"
102 #include "clipdata.hxx"
103 #include "markdata.hxx"
105 #include <svx/xmlsecctrl.hxx>
108 #include "scslots.hxx"
110 #include "scabstdlg.hxx"
111 #include <formula/errorcodes.hxx>
112 #include "formulagroup.hxx"
113 #include <documentlinkmgr.hxx>
115 #define SC_IDLE_MIN 150
116 #define SC_IDLE_MAX 3000
117 #define SC_IDLE_STEP 75
118 #define SC_IDLE_COUNT 50
120 static sal_uInt16 nIdleCount
= 0;
122 SFX_IMPL_INTERFACE(ScModule
, SfxShell
, ScResId(RID_APPTITLE
))
124 void ScModule::InitInterface_Impl()
126 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION
| SFX_VISIBILITY_DESKTOP
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_CLIENT
| SFX_VISIBILITY_VIEWER
,
127 ScResId(RID_OBJECTBAR_APP
));
129 GetStaticInterface()->RegisterStatusBar(ScResId(SCCFG_STATUSBAR
));
132 ScModule::ScModule( SfxObjectFactory
* pFact
) :
133 SfxModule( SfxApplication::CreateResManager( "sc" ), false, pFact
, NULL
),
134 mpDragData(new ScDragData
),
135 mpClipData(new ScClipData
),
136 pSelTransfer( NULL
),
137 pMessagePool( NULL
),
138 pRefInputHandler( NULL
),
142 pDefaultsCfg( NULL
),
148 pColorConfig( NULL
),
149 pAccessOptions( NULL
),
151 pUserOptions( NULL
),
153 pFormEditData( NULL
),
155 bIsWaterCan( false ),
156 bIsInEditCommand( false ),
157 bIsInExecuteDrop( false ),
158 mbIsInSharedDocLoading( false ),
159 mbIsInSharedDocSaving( false )
161 // The ResManager (DLL data) is not yet initalized in the ctor!
162 SetName(OUString("StarCalc")); // for Basic
165 SetClipObject( NULL
, NULL
);
167 // InputHandler does not need to be created
169 // Create ErrorHandler - was in Init()
170 // Between OfficeApplication::Init and ScGlobal::Init
171 SvxErrorHandler::ensure();
172 pErrorHdl
= new SfxErrorHandler( RID_ERRHDLSC
,
177 aSpellTimer
.SetTimeout(10);
178 aSpellTimer
.SetTimeoutHdl( LINK( this, ScModule
, SpellTimerHdl
) );
179 aIdleTimer
.SetTimeout(SC_IDLE_MIN
);
180 aIdleTimer
.SetTimeoutHdl( LINK( this, ScModule
, IdleHandler
) );
183 pMessagePool
= new ScMessagePool
;
184 pMessagePool
->FreezeIdRanges();
185 SetPool( pMessagePool
);
186 ScGlobal::InitTextHeight( pMessagePool
);
188 StartListening( *SFX_APP() ); // for SFX_HINT_DEINITIALIZING
191 ScModule::~ScModule()
193 OSL_ENSURE( !pSelTransfer
, "Selection Transfer object not deleted" );
195 // InputHandler does not need to be deleted (there's none in the App anymore)
197 SfxItemPool::Free(pMessagePool
);
199 DELETEZ( pFormEditData
);
205 ScGlobal::Clear(); // Also calls ScDocumentPool::DeleteVersionMaps();
207 DeleteCfg(); // Called from Exit()
211 void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster
* p
, sal_uInt32
)
213 if ( p
== pColorConfig
|| p
== pAccessOptions
)
215 // Test if detective objects have to be updated with new colors
216 // (if the detective colors haven't been used yet, there's nothing to update)
217 if ( ScDetectiveFunc::IsColorsInitialized() )
219 const svtools::ColorConfig
& rColors
= GetColorConfig();
221 ( ScDetectiveFunc::GetArrowColor() != (ColorData
)rColors
.GetColorValue(svtools::CALCDETECTIVE
).nColor
||
222 ScDetectiveFunc::GetErrorColor() != (ColorData
)rColors
.GetColorValue(svtools::CALCDETECTIVEERROR
).nColor
);
224 ( ScDetectiveFunc::GetCommentColor() != (ColorData
)rColors
.GetColorValue(svtools::CALCNOTESBACKGROUND
).nColor
);
225 if ( bArrows
|| bComments
)
227 ScDetectiveFunc::InitializeColors(); // get the new colors
229 // update detective objects in all open documents
230 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
233 if ( pObjSh
->Type() == TYPE(ScDocShell
) )
235 ScDocShell
* pDocSh
= ((ScDocShell
*)pObjSh
);
237 ScDetectiveFunc( pDocSh
->GetDocument(), 0 ).UpdateAllArrowColors();
239 ScDetectiveFunc::UpdateAllComments( *pDocSh
->GetDocument() );
241 pObjSh
= SfxObjectShell::GetNext( *pObjSh
);
246 // force all views to repaint, using the new options
247 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
250 if ( pViewShell
->ISA(ScTabViewShell
) )
252 ScTabViewShell
* pViewSh
= (ScTabViewShell
*)pViewShell
;
253 pViewSh
->PaintGrid();
255 pViewSh
->PaintLeft();
256 pViewSh
->PaintExtras();
258 ScInputHandler
* pHdl
= pViewSh
->GetInputHandler();
260 pHdl
->ForgetLastPattern(); // EditEngine BackgroundColor may change
262 else if ( pViewShell
->ISA(ScPreviewShell
) )
264 Window
* pWin
= pViewShell
->GetWindow();
268 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
271 else if ( p
== pCTLOptions
)
273 // for all documents: set digit language for printer, recalc output factor, update row heights
274 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
277 if ( pObjSh
->Type() == TYPE(ScDocShell
) )
279 ScDocShell
* pDocSh
= ((ScDocShell
*)pObjSh
);
280 OutputDevice
* pPrinter
= pDocSh
->GetPrinter();
282 pPrinter
->SetDigitLanguage( GetOptDigitLanguage() );
284 pDocSh
->CalcOutputFactor();
286 SCTAB nTabCount
= pDocSh
->GetDocument()->GetTableCount();
287 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
288 pDocSh
->AdjustRowHeight( 0, MAXROW
, nTab
);
290 pObjSh
= SfxObjectShell::GetNext( *pObjSh
);
293 // for all views (table and preview): update digit language
294 SfxViewShell
* pSh
= SfxViewShell::GetFirst();
297 if ( pSh
->ISA( ScTabViewShell
) )
299 ScTabViewShell
* pViewSh
= (ScTabViewShell
*)pSh
;
301 // set ref-device for EditEngine (re-evaluates digit settings)
302 ScInputHandler
* pHdl
= GetInputHdl(pViewSh
);
304 pHdl
->UpdateRefDevice();
306 pViewSh
->DigitLanguageChanged();
307 pViewSh
->PaintGrid();
309 else if ( pSh
->ISA( ScPreviewShell
) )
311 ScPreviewShell
* pPreviewSh
= (ScPreviewShell
*)pSh
;
312 ScPreview
* pPreview
= pPreviewSh
->GetPreview();
314 pPreview
->SetDigitLanguage( GetOptDigitLanguage() );
315 pPreview
->Invalidate();
318 pSh
= SfxViewShell::GetNext( *pSh
);
323 void ScModule::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
325 if ( rHint
.ISA(SfxSimpleHint
) )
327 sal_uLong nHintId
= ((SfxSimpleHint
&)rHint
).GetId();
328 if ( nHintId
== SFX_HINT_DEINITIALIZING
)
330 // ConfigItems must be removed before ConfigManager
336 void ScModule::DeleteCfg()
338 DELETEZ( pViewCfg
); // Saving happens automatically before Exit()
341 DELETEZ( pDefaultsCfg
);
342 DELETEZ( pFormulaCfg
);
343 DELETEZ( pInputCfg
);
344 DELETEZ( pPrintCfg
);
345 DELETEZ( pNavipiCfg
);
346 DELETEZ( pAddInCfg
);
350 pColorConfig
->RemoveListener(this);
351 DELETEZ( pColorConfig
);
353 if ( pAccessOptions
)
355 pAccessOptions
->RemoveListener(this);
356 DELETEZ( pAccessOptions
);
360 pCTLOptions
->RemoveListener(this);
361 DELETEZ( pCTLOptions
);
365 DELETEZ( pUserOptions
);
369 // Moved here from the App
371 void ScModule::Execute( SfxRequest
& rReq
)
373 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
374 SfxBindings
* pBindings
= pViewFrm
? &pViewFrm
->GetBindings() : NULL
;
376 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
377 sal_uInt16 nSlot
= rReq
.GetSlot();
381 case SID_CHOOSE_DESIGN
:
383 OUString
aMacroName("Template.Samples.ShowStyles");
384 SfxApplication::CallAppBasic( aMacroName
);
387 case SID_EURO_CONVERTER
:
389 OUString
aMacroName("Euro.ConvertRun.Main");
390 SfxApplication::CallAppBasic( aMacroName
);
393 case SID_AUTOSPELL_CHECK
:
396 const SfxPoolItem
* pItem
;
397 if ( pReqArgs
&& SFX_ITEM_SET
== pReqArgs
->GetItemState( nSlot
, true, &pItem
) )
398 bSet
= ((const SfxBoolItem
*)pItem
)->GetValue();
401 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
403 bSet
= !pDocSh
->GetDocument()->GetDocOptions().IsAutoSpell();
405 bSet
= !GetDocOptions().IsAutoSpell();
408 SfxItemSet
aSet( GetPool(), SID_AUTOSPELL_CHECK
, SID_AUTOSPELL_CHECK
);
409 aSet
.Put( SfxBoolItem( SID_AUTOSPELL_CHECK
, bSet
) );
410 ModifyOptions( aSet
);
415 case SID_ATTR_METRIC
:
417 const SfxPoolItem
* pItem
;
418 if ( pReqArgs
&& SFX_ITEM_SET
== pReqArgs
->GetItemState( nSlot
, true, &pItem
) )
420 FieldUnit eUnit
= (FieldUnit
)((const SfxUInt16Item
*)pItem
)->GetValue();
423 case FUNIT_MM
: // Just the units that are also in the dialog
430 ScAppOptions
aNewOpts( GetAppOptions() );
431 aNewOpts
.SetAppMetric( eUnit
);
432 SetAppOptions( aNewOpts
);
438 // added to avoid warnings
445 case FID_AUTOCOMPLETE
:
447 ScAppOptions
aNewOpts( GetAppOptions() );
448 bool bNew
= !aNewOpts
.GetAutoComplete();
449 aNewOpts
.SetAutoComplete( bNew
);
450 SetAppOptions( aNewOpts
);
451 ScInputHandler::SetAutoComplete( bNew
);
453 pBindings
->Invalidate( FID_AUTOCOMPLETE
);
458 case SID_DETECTIVE_AUTO
:
460 ScAppOptions
aNewOpts( GetAppOptions() );
461 bool bNew
= !aNewOpts
.GetDetectiveAuto();
462 SFX_REQUEST_ARG( rReq
, pAuto
, SfxBoolItem
, SID_DETECTIVE_AUTO
, false );
464 bNew
= pAuto
->GetValue();
466 aNewOpts
.SetDetectiveAuto( bNew
);
467 SetAppOptions( aNewOpts
);
469 pBindings
->Invalidate( SID_DETECTIVE_AUTO
);
470 rReq
.AppendItem( SfxBoolItem( SID_DETECTIVE_AUTO
, bNew
) );
475 case SID_PSZ_FUNCTION
:
478 const SfxUInt16Item
& rItem
= (const SfxUInt16Item
&)pReqArgs
->Get(SID_PSZ_FUNCTION
);
479 OSL_ENSURE(rItem
.ISA(SfxUInt16Item
),"wrong Parameter");
481 ScAppOptions
aNewOpts( GetAppOptions() );
482 aNewOpts
.SetStatusFunc( rItem
.GetValue() );
483 SetAppOptions( aNewOpts
);
487 pBindings
->Invalidate( SID_TABLE_CELL
);
488 pBindings
->Update( SID_TABLE_CELL
); // Immediately
490 pBindings
->Invalidate( SID_PSZ_FUNCTION
);
491 pBindings
->Update( SID_PSZ_FUNCTION
);
492 // If the menu is opened again immediately
497 case SID_ATTR_LANGUAGE
:
498 case SID_ATTR_CHAR_CJK_LANGUAGE
:
499 case SID_ATTR_CHAR_CTL_LANGUAGE
:
501 const SfxPoolItem
* pItem
;
502 if ( pReqArgs
&& SFX_ITEM_SET
== pReqArgs
->GetItemState( GetPool().GetWhich(nSlot
), true, &pItem
) )
504 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
505 ScDocument
* pDoc
= pDocSh
? pDocSh
->GetDocument() : NULL
;
508 LanguageType eNewLang
= ((SvxLanguageItem
*)pItem
)->GetLanguage();
509 LanguageType eLatin
, eCjk
, eCtl
;
510 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
511 LanguageType eOld
= ( nSlot
== SID_ATTR_CHAR_CJK_LANGUAGE
) ? eCjk
:
512 ( ( nSlot
== SID_ATTR_CHAR_CTL_LANGUAGE
) ? eCtl
: eLatin
);
513 if ( eNewLang
!= eOld
)
515 if ( nSlot
== SID_ATTR_CHAR_CJK_LANGUAGE
)
517 else if ( nSlot
== SID_ATTR_CHAR_CTL_LANGUAGE
)
522 pDoc
->SetLanguage( eLatin
, eCjk
, eCtl
);
524 ScInputHandler
* pInputHandler
= GetInputHdl();
526 pInputHandler
->UpdateSpellSettings(); // EditEngine flags
527 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
, SfxViewShell::Current());
529 pViewSh
->UpdateDrawTextOutliner(); // EditEngine flags
531 pDocSh
->SetDocumentModified();
538 case FID_FOCUS_POSWND
:
540 ScInputHandler
* pHdl
= GetInputHdl();
543 ScInputWindow
* pWin
= pHdl
->GetInputWindow();
545 pWin
->PosGrabFocus();
551 case SID_OPEN_XML_FILTERSETTINGS
:
555 css::uno::Reference
< css::ui::dialogs::XExecutableDialog
> xDialog
= css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext());
558 catch( ::com::sun::star::uno::RuntimeException
& )
560 DBG_UNHANDLED_EXCEPTION();
566 OSL_FAIL( "ScApplication: Unknown Message." );
571 void ScModule::GetState( SfxItemSet
& rSet
)
573 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
574 bool bTabView
= pDocSh
&& (pDocSh
->GetBestViewShell(true) != NULL
);
576 SfxWhichIter
aIter(rSet
);
577 for (sal_uInt16 nWhich
= aIter
.FirstWhich(); nWhich
; nWhich
= aIter
.NextWhich())
581 // Not in the normal calc view shell (most likely in preview shell). Disable all actions.
582 rSet
.DisableItem(nWhich
);
588 case FID_AUTOCOMPLETE
:
589 rSet
.Put( SfxBoolItem( nWhich
, GetAppOptions().GetAutoComplete() ) );
591 case SID_DETECTIVE_AUTO
:
592 rSet
.Put( SfxBoolItem( nWhich
, GetAppOptions().GetDetectiveAuto() ) );
594 case SID_PSZ_FUNCTION
:
595 rSet
.Put( SfxUInt16Item( nWhich
, GetAppOptions().GetStatusFunc() ) );
597 case SID_ATTR_METRIC
:
598 rSet
.Put( SfxUInt16Item( nWhich
, sal::static_int_cast
<sal_uInt16
>(GetAppOptions().GetAppMetric()) ) );
600 case SID_AUTOSPELL_CHECK
:
601 rSet
.Put( SfxBoolItem( nWhich
, pDocSh
->GetDocument()->GetDocOptions().IsAutoSpell()) );
603 case SID_ATTR_LANGUAGE
:
604 case ATTR_CJK_FONT_LANGUAGE
: // WID for SID_ATTR_CHAR_CJK_LANGUAGE
605 case ATTR_CTL_FONT_LANGUAGE
: // WID for SID_ATTR_CHAR_CTL_LANGUAGE
607 ScDocument
* pDoc
= pDocSh
->GetDocument();
610 LanguageType eLatin
, eCjk
, eCtl
;
611 pDoc
->GetLanguage( eLatin
, eCjk
, eCtl
);
612 LanguageType eLang
= ( nWhich
== ATTR_CJK_FONT_LANGUAGE
) ? eCjk
:
613 ( ( nWhich
== ATTR_CTL_FONT_LANGUAGE
) ? eCtl
: eLatin
);
614 rSet
.Put( SvxLanguageItem( eLang
, nWhich
) );
623 void ScModule::HideDisabledSlots( SfxItemSet
& rSet
)
625 if( SfxViewFrame
* pViewFrm
= SfxViewFrame::Current() )
627 SfxBindings
& rBindings
= pViewFrm
->GetBindings();
628 SfxWhichIter
aIter( rSet
);
629 for( sal_uInt16 nWhich
= aIter
.FirstWhich(); nWhich
!= 0; nWhich
= aIter
.NextWhich() )
631 ScViewUtil::HideDisabledSlot( rSet
, rBindings
, nWhich
);
632 // always disable the slots
633 rSet
.DisableItem( nWhich
);
639 void ScModule::ResetDragObject()
641 mpDragData
->pCellTransfer
= NULL
;
642 mpDragData
->pDrawTransfer
= NULL
;
643 mpDragData
->pJumpLocalDoc
= NULL
;
644 mpDragData
->aLinkDoc
= OUString();
645 mpDragData
->aLinkTable
= OUString();
646 mpDragData
->aLinkArea
= OUString();
647 mpDragData
->aJumpTarget
= OUString();
648 mpDragData
->aJumpText
= OUString();
651 const ScDragData
& ScModule::GetDragData() const
656 void ScModule::SetDragObject( ScTransferObj
* pCellObj
, ScDrawTransferObj
* pDrawObj
)
659 mpDragData
->pCellTransfer
= pCellObj
;
660 mpDragData
->pDrawTransfer
= pDrawObj
;
663 void ScModule::SetDragLink(
664 const OUString
& rDoc
, const OUString
& rTab
, const OUString
& rArea
)
667 mpDragData
->aLinkDoc
= rDoc
;
668 mpDragData
->aLinkTable
= rTab
;
669 mpDragData
->aLinkArea
= rArea
;
672 void ScModule::SetDragJump(
673 ScDocument
* pLocalDoc
, const OUString
& rTarget
, const OUString
& rText
)
677 mpDragData
->pJumpLocalDoc
= pLocalDoc
;
678 mpDragData
->aJumpTarget
= rTarget
;
679 mpDragData
->aJumpText
= rText
;
682 const ScClipData
& ScModule::GetClipData() const
687 void ScModule::SetClipObject( ScTransferObj
* pCellObj
, ScDrawTransferObj
* pDrawObj
)
689 OSL_ENSURE( !pCellObj
|| !pDrawObj
, "SetClipObject: not allowed to set both objects" );
691 mpClipData
->pCellClipboard
= pCellObj
;
692 mpClipData
->pDrawClipboard
= pDrawObj
;
695 ScDocument
* ScModule::GetClipDoc()
697 // called from document
698 ScTransferObj
* pObj
= ScTransferObj::GetOwnClipboard( NULL
);
700 return pObj
->GetDocument();
705 void ScModule::SetSelectionTransfer( ScSelectionTransferObj
* pNew
)
710 void ScModule::InitFormEditData()
712 pFormEditData
= new ScFormEditData
;
715 void ScModule::ClearFormEditData()
717 DELETEZ( pFormEditData
);
720 void ScModule::SetViewOptions( const ScViewOptions
& rOpt
)
723 pViewCfg
= new ScViewCfg
;
725 pViewCfg
->SetOptions( rOpt
);
728 const ScViewOptions
& ScModule::GetViewOptions()
731 pViewCfg
= new ScViewCfg
;
736 void ScModule::SetDocOptions( const ScDocOptions
& rOpt
)
739 pDocCfg
= new ScDocCfg
;
741 pDocCfg
->SetOptions( rOpt
);
744 const ScDocOptions
& ScModule::GetDocOptions()
747 pDocCfg
= new ScDocCfg
;
756 void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex
)
760 const ScAppOptions
& rAppOpt
= GetAppOptions();
761 sal_uInt16 nLRUFuncCount
= std::min( rAppOpt
.GetLRUFuncListCount(), (sal_uInt16
)LRU_MAX
);
762 sal_uInt16
* pLRUListIds
= rAppOpt
.GetLRUFuncList();
764 sal_uInt16 aIdxList
[LRU_MAX
];
768 while ((n
< LRU_MAX
) && n
<nLRUFuncCount
) // Iterate through old list
770 if (!bFound
&& (pLRUListIds
[n
]== nFIndex
))
771 bFound
= true; // First hit!
773 aIdxList
[n
] = pLRUListIds
[n
]; // Copy after hit
774 else if ((n
+1) < LRU_MAX
)
775 aIdxList
[n
+1] = pLRUListIds
[n
]; // Move before hit
778 if (!bFound
&& (n
< LRU_MAX
)) // Entry not found?
780 aIdxList
[0] = nFIndex
; // Current on Top
782 ScAppOptions
aNewOpts(rAppOpt
); // Let App know
783 aNewOpts
.SetLRUFuncList(aIdxList
, n
);
784 SetAppOptions(aNewOpts
);
786 RecentFunctionsChanged();
790 void ScModule::RecentFunctionsChanged()
792 // update function list window
793 sal_uInt16 nFuncListID
= ScFunctionChildWindow::GetChildWindowId();
796 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
797 if ( pViewFrm
&& pViewFrm
->HasChildWindow(nFuncListID
) )
799 ScFunctionChildWindow
* pWnd
=(ScFunctionChildWindow
*)pViewFrm
->GetChildWindow( nFuncListID
);
801 ScFunctionDockWin
* pFuncList
=(ScFunctionDockWin
*)pWnd
->GetWindow();
803 pFuncList
->InitLRUList();
807 void ScModule::SetAppOptions( const ScAppOptions
& rOpt
)
810 pAppCfg
= new ScAppCfg
;
812 pAppCfg
->SetOptions( rOpt
);
815 void global_InitAppOptions()
817 SC_MOD()->GetAppOptions();
820 const ScAppOptions
& ScModule::GetAppOptions()
823 pAppCfg
= new ScAppCfg
;
828 void ScModule::SetDefaultsOptions( const ScDefaultsOptions
& rOpt
)
831 pDefaultsCfg
= new ScDefaultsCfg
;
833 pDefaultsCfg
->SetOptions( rOpt
);
836 const ScDefaultsOptions
& ScModule::GetDefaultsOptions()
839 pDefaultsCfg
= new ScDefaultsCfg
;
841 return *pDefaultsCfg
;
844 void ScModule::SetFormulaOptions( const ScFormulaOptions
& rOpt
)
847 pFormulaCfg
= new ScFormulaCfg
;
849 pFormulaCfg
->SetOptions( rOpt
);
852 const ScFormulaOptions
& ScModule::GetFormulaOptions()
855 pFormulaCfg
= new ScFormulaCfg
;
860 void ScModule::SetInputOptions( const ScInputOptions
& rOpt
)
863 pInputCfg
= new ScInputCfg
;
865 pInputCfg
->SetOptions( rOpt
);
868 const ScInputOptions
& ScModule::GetInputOptions()
871 pInputCfg
= new ScInputCfg
;
876 void ScModule::SetPrintOptions( const ScPrintOptions
& rOpt
)
879 pPrintCfg
= new ScPrintCfg
;
881 pPrintCfg
->SetOptions( rOpt
);
884 const ScPrintOptions
& ScModule::GetPrintOptions()
887 pPrintCfg
= new ScPrintCfg
;
892 ScNavipiCfg
& ScModule::GetNavipiCfg()
895 pNavipiCfg
= new ScNavipiCfg
;
900 ScAddInCfg
& ScModule::GetAddInCfg()
903 pAddInCfg
= new ScAddInCfg
;
908 svtools::ColorConfig
& ScModule::GetColorConfig()
912 pColorConfig
= new svtools::ColorConfig
;
913 pColorConfig
->AddListener(this);
916 return *pColorConfig
;
919 SvtAccessibilityOptions
& ScModule::GetAccessOptions()
921 if ( !pAccessOptions
)
923 pAccessOptions
= new SvtAccessibilityOptions
;
924 pAccessOptions
->AddListener(this);
927 return *pAccessOptions
;
930 SvtCTLOptions
& ScModule::GetCTLOptions()
934 pCTLOptions
= new SvtCTLOptions
;
935 pCTLOptions
->AddListener(this);
941 SvtUserOptions
& ScModule::GetUserOptions()
945 pUserOptions
= new SvtUserOptions
;
947 return *pUserOptions
;
950 sal_uInt16
ScModule::GetOptDigitLanguage()
952 SvtCTLOptions::TextNumerals eNumerals
= GetCTLOptions().GetCTLTextNumerals();
953 return ( eNumerals
== SvtCTLOptions::NUMERALS_ARABIC
) ? LANGUAGE_ENGLISH_US
:
954 ( eNumerals
== SvtCTLOptions::NUMERALS_HINDI
) ? LANGUAGE_ARABIC_SAUDI_ARABIA
:
961 * Items from Calc options dialog and SID_AUTOSPELL_CHECK
963 void ScModule::ModifyOptions( const SfxItemSet
& rOptSet
)
965 sal_uInt16 nOldSpellLang
, nOldCjkLang
, nOldCtlLang
;
967 GetSpellSettings( nOldSpellLang
, nOldCjkLang
, nOldCtlLang
, bOldAutoSpell
);
971 OSL_ENSURE( pAppCfg
, "AppOptions not initialised :-(" );
975 OSL_ENSURE( pInputCfg
, "InputOptions not initialised :-(" );
977 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
978 SfxBindings
* pBindings
= pViewFrm
? &pViewFrm
->GetBindings() : NULL
;
980 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
, SfxViewShell::Current());
981 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
982 ScDocument
* pDoc
= pDocSh
? pDocSh
->GetDocument() : NULL
;
983 const SfxPoolItem
* pItem
= NULL
;
984 bool bRepaint
= false;
985 bool bUpdateMarks
= false;
986 bool bUpdateRefDev
= false;
987 bool bCalcAll
= false;
988 bool bSaveAppOptions
= false;
989 bool bSaveInputOptions
= false;
990 bool bCompileErrorCells
= false;
992 // SFX_APP()->SetOptions( rOptSet );
994 // No more linguistics
995 if (rOptSet
.HasItem(SID_ATTR_METRIC
, &pItem
))
998 pAppCfg
->SetAppMetric( (FieldUnit
)((const SfxUInt16Item
*)pItem
)->GetValue() );
999 bSaveAppOptions
= true;
1002 if (rOptSet
.HasItem(SCITEM_USERLIST
, &pItem
))
1004 ScGlobal::SetUserList( ((const ScUserListItem
*)pItem
)->GetUserList() );
1005 bSaveAppOptions
= true;
1008 if (rOptSet
.HasItem(SID_SC_OPT_SYNCZOOM
, &pItem
))
1010 pAppCfg
->SetSynchronizeZoom( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1011 bSaveAppOptions
= true;
1014 if (rOptSet
.HasItem(SID_SC_OPT_KEY_BINDING_COMPAT
, &pItem
))
1016 sal_uInt16 nVal
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1017 ScOptionsUtil::KeyBindingType eOld
= pAppCfg
->GetKeyBindingType();
1018 ScOptionsUtil::KeyBindingType eNew
= static_cast<ScOptionsUtil::KeyBindingType
>(nVal
);
1021 pAppCfg
->SetKeyBindingType(eNew
);
1022 bSaveAppOptions
= true;
1023 pDocSh
->ResetKeyBindings(eNew
);
1029 if (rOptSet
.HasItem(SID_SCDEFAULTSOPTIONS
, &pItem
))
1031 const ScDefaultsOptions
& rOpt
= ((const ScTpDefaultsItem
*)pItem
)->GetDefaultsOptions();
1032 SetDefaultsOptions( rOpt
);
1037 if (rOptSet
.HasItem(SID_SCFORMULAOPTIONS
, &pItem
))
1039 const ScFormulaOptions
& rOpt
= ((const ScTpFormulaItem
*)pItem
)->GetFormulaOptions();
1041 if (!pFormulaCfg
|| (*pFormulaCfg
!= rOpt
))
1042 // Formula options have changed. Repaint the column headers.
1045 if (pFormulaCfg
&& pFormulaCfg
->GetUseEnglishFuncName() != rOpt
.GetUseEnglishFuncName())
1047 // Re-compile formula cells with error as the error may have been
1048 // caused by unresolved function names.
1049 bCompileErrorCells
= true;
1052 // Recalc for interpreter options changes.
1053 if (pFormulaCfg
&& pFormulaCfg
->GetCalcConfig() != rOpt
.GetCalcConfig())
1058 pDocSh
->SetFormulaOptions( rOpt
);
1059 pDocSh
->SetDocumentModified();
1062 // ScDocShell::SetFormulaOptions() may check for changed settings, so
1063 // set the new options here after that has been called.
1064 SetFormulaOptions( rOpt
);
1069 if (rOptSet
.HasItem(SID_SCVIEWOPTIONS
, &pItem
))
1071 const ScViewOptions
& rNewOpt
= ((const ScTpViewItem
*)pItem
)->GetViewOptions();
1075 ScViewData
* pViewData
= pViewSh
->GetViewData();
1076 const ScViewOptions
& rOldOpt
= pViewData
->GetOptions();
1078 bool bAnchorList
= ( rOldOpt
.GetOption( VOPT_ANCHOR
) !=
1079 rNewOpt
.GetOption( VOPT_ANCHOR
) );
1081 if ( rOldOpt
!= rNewOpt
)
1083 pViewData
->SetOptions( rNewOpt
); // Changes rOldOpt
1084 pViewData
->GetDocument()->SetViewOptions( rNewOpt
);
1086 pDocSh
->SetDocumentModified();
1090 pViewSh
->UpdateAnchorHandles();
1092 SetViewOptions( rNewOpt
);
1095 pBindings
->Invalidate(SID_HELPLINES_MOVE
);
1101 // Evaluate after ViewOptions, as GridOptions is a member of ViewOptions
1102 if ( rOptSet
.HasItem(SID_ATTR_GRID_OPTIONS
,&pItem
) )
1104 ScGridOptions
aNewGridOpt( (const SvxGridItem
&)*pItem
);
1108 ScViewData
* pViewData
= pViewSh
->GetViewData();
1109 ScViewOptions
aNewViewOpt( pViewData
->GetOptions() );
1110 const ScGridOptions
& rOldGridOpt
= aNewViewOpt
.GetGridOptions();
1112 if ( rOldGridOpt
!= aNewGridOpt
)
1114 aNewViewOpt
.SetGridOptions( aNewGridOpt
);
1115 pViewData
->SetOptions( aNewViewOpt
);
1116 pViewData
->GetDocument()->SetViewOptions( aNewViewOpt
);
1117 pDocSh
->SetDocumentModified();
1121 ScViewOptions
aNewViewOpt ( GetViewOptions() );
1122 aNewViewOpt
.SetGridOptions( aNewGridOpt
);
1123 SetViewOptions( aNewViewOpt
);
1126 pBindings
->Invalidate(SID_GRID_VISIBLE
);
1127 pBindings
->Invalidate(SID_GRID_USE
);
1132 if ( rOptSet
.HasItem(SID_SCDOCOPTIONS
,&pItem
) )
1134 const ScDocOptions
& rNewOpt
= ((const ScTpCalcItem
*)pItem
)->GetDocOptions();
1138 const ScDocOptions
& rOldOpt
= pDoc
->GetDocOptions();
1140 bRepaint
= ( bRepaint
|| ( rOldOpt
!= rNewOpt
) );
1141 bCalcAll
= bRepaint
&&
1142 ( rOldOpt
.IsIter() != rNewOpt
.IsIter()
1143 || rOldOpt
.GetIterCount() != rNewOpt
.GetIterCount()
1144 || rOldOpt
.GetIterEps() != rNewOpt
.GetIterEps()
1145 || rOldOpt
.IsIgnoreCase() != rNewOpt
.IsIgnoreCase()
1146 || rOldOpt
.IsCalcAsShown() != rNewOpt
.IsCalcAsShown()
1147 || (rNewOpt
.IsCalcAsShown() &&
1148 rOldOpt
.GetStdPrecision() != rNewOpt
.GetStdPrecision())
1149 || rOldOpt
.IsMatchWholeCell() != rNewOpt
.IsMatchWholeCell()
1150 || rOldOpt
.GetYear2000() != rNewOpt
.GetYear2000()
1151 || rOldOpt
.IsFormulaRegexEnabled() != rNewOpt
.IsFormulaRegexEnabled()
1153 pDoc
->SetDocOptions( rNewOpt
);
1154 pDocSh
->SetDocumentModified();
1156 SetDocOptions( rNewOpt
);
1159 // Set TabDistance after the actual DocOptions
1160 if ( rOptSet
.HasItem(SID_ATTR_DEFTABSTOP
,&pItem
) )
1162 sal_uInt16 nTabDist
= ((SfxUInt16Item
*)pItem
)->GetValue();
1163 ScDocOptions
aOpt(GetDocOptions());
1164 aOpt
.SetTabDistance(nTabDist
);
1165 SetDocOptions( aOpt
);
1169 ScDocOptions
aDocOpt(pDoc
->GetDocOptions());
1170 aDocOpt
.SetTabDistance(nTabDist
);
1171 pDoc
->SetDocOptions( aDocOpt
);
1172 pDocSh
->SetDocumentModified();
1173 if(pDoc
->GetDrawLayer())
1174 pDoc
->GetDrawLayer()->SetDefaultTabulator(nTabDist
);
1178 // AutoSpell after the DocOptions (due to being a member)
1179 if ( rOptSet
.HasItem(SID_AUTOSPELL_CHECK
,&pItem
) ) // At DocOptions
1181 bool bDoAutoSpell
= ((const SfxBoolItem
*)pItem
)->GetValue();
1185 ScDocOptions aNewOpt
= pDoc
->GetDocOptions();
1186 if ( aNewOpt
.IsAutoSpell() != bDoAutoSpell
)
1188 aNewOpt
.SetAutoSpell( bDoAutoSpell
);
1189 pDoc
->SetDocOptions( aNewOpt
);
1192 pViewSh
->EnableAutoSpell(bDoAutoSpell
);
1194 bRepaint
= true; // Because HideAutoSpell might be invalid
1195 //TODO: Paint all Views?
1199 if ( bOldAutoSpell
!= bDoAutoSpell
)
1200 SetAutoSpellProperty( bDoAutoSpell
);
1202 pDocSh
->PostPaintGridAll(); // Due to marks
1203 ScInputHandler
* pInputHandler
= GetInputHdl();
1204 if ( pInputHandler
)
1205 pInputHandler
->UpdateSpellSettings(); // EditEngine flags
1207 pViewSh
->UpdateDrawTextOutliner(); // EditEngine flags
1210 pBindings
->Invalidate( SID_AUTOSPELL_CHECK
);
1215 if ( rOptSet
.HasItem(SID_SC_INPUT_SELECTIONPOS
,&pItem
) )
1217 pInputCfg
->SetMoveDir( ((const SfxUInt16Item
*)pItem
)->GetValue() );
1218 bSaveInputOptions
= true;
1220 if ( rOptSet
.HasItem(SID_SC_INPUT_SELECTION
,&pItem
) )
1222 pInputCfg
->SetMoveSelection( ((const SfxBoolItem
*)pItem
)->GetValue() );
1223 bSaveInputOptions
= true;
1225 if ( rOptSet
.HasItem(SID_SC_INPUT_EDITMODE
,&pItem
) )
1227 pInputCfg
->SetEnterEdit( ((const SfxBoolItem
*)pItem
)->GetValue() );
1228 bSaveInputOptions
= true;
1230 if ( rOptSet
.HasItem(SID_SC_INPUT_FMT_EXPAND
,&pItem
) )
1232 pInputCfg
->SetExtendFormat( ((const SfxBoolItem
*)pItem
)->GetValue() );
1233 bSaveInputOptions
= true;
1235 if ( rOptSet
.HasItem(SID_SC_INPUT_RANGEFINDER
,&pItem
) )
1237 pInputCfg
->SetRangeFinder( ((const SfxBoolItem
*)pItem
)->GetValue() );
1238 bSaveInputOptions
= true;
1240 if ( rOptSet
.HasItem(SID_SC_INPUT_REF_EXPAND
,&pItem
) )
1242 pInputCfg
->SetExpandRefs( ((const SfxBoolItem
*)pItem
)->GetValue() );
1243 bSaveInputOptions
= true;
1245 if (rOptSet
.HasItem(SID_SC_OPT_SORT_REF_UPDATE
, &pItem
))
1247 pInputCfg
->SetSortRefUpdate(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
1248 bSaveInputOptions
= true;
1251 if ( rOptSet
.HasItem(SID_SC_INPUT_MARK_HEADER
,&pItem
) )
1253 pInputCfg
->SetMarkHeader( ((const SfxBoolItem
*)pItem
)->GetValue() );
1254 bSaveInputOptions
= true;
1255 bUpdateMarks
= true;
1257 if ( rOptSet
.HasItem(SID_SC_INPUT_TEXTWYSIWYG
,&pItem
) )
1259 bool bNew
= ((const SfxBoolItem
*)pItem
)->GetValue();
1260 if ( bNew
!= pInputCfg
->GetTextWysiwyg() )
1262 pInputCfg
->SetTextWysiwyg( bNew
);
1263 bSaveInputOptions
= true;
1264 bUpdateRefDev
= true;
1267 if( rOptSet
.HasItem( SID_SC_INPUT_REPLCELLSWARN
, &pItem
) )
1269 pInputCfg
->SetReplaceCellsWarn( ((const SfxBoolItem
*)pItem
)->GetValue() );
1270 bSaveInputOptions
= true;
1273 if( rOptSet
.HasItem( SID_SC_INPUT_LEGACY_CELL_SELECTION
, &pItem
) )
1275 pInputCfg
->SetLegacyCellSelection( ((const SfxBoolItem
*)pItem
)->GetValue() );
1276 bSaveInputOptions
= true;
1281 if ( rOptSet
.HasItem(SID_SCPRINTOPTIONS
,&pItem
) )
1283 const ScPrintOptions
& rNewOpt
= ((const ScTpPrintItem
*)pItem
)->GetPrintOptions();
1284 SetPrintOptions( rNewOpt
);
1286 // broadcast causes all previews to recalc page numbers
1287 SFX_APP()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS
) );
1290 if ( bSaveAppOptions
)
1291 pAppCfg
->OptionsChanged();
1293 if ( bSaveInputOptions
)
1294 pInputCfg
->OptionsChanged();
1296 // Kick off recalculation?
1297 if (pDoc
&& bCompileErrorCells
)
1299 // Re-compile cells with name error, and recalc if at least one cell
1300 // has been re-compiled. In the future we may want to find a way to
1301 // recalc only those that are affected.
1302 if (pDoc
->CompileErrorCells(ScErrorCodes::errNoName
))
1306 if ( pDoc
&& bCalcAll
)
1308 WaitObject
aWait( pDocSh
->GetActiveDialogParent() );
1311 pViewSh
->UpdateCharts( true );
1313 ScDBFunc::DoUpdateCharts( ScAddress(), pDoc
, true );
1315 pBindings
->Invalidate( SID_ATTR_SIZE
); //SvxPosSize StatusControl Update
1318 if ( pViewSh
&& bUpdateMarks
)
1319 pViewSh
->UpdateAutoFillMark();
1322 if ( pViewSh
&& bRepaint
)
1324 pViewSh
->UpdateFixPos();
1325 pViewSh
->PaintGrid();
1326 pViewSh
->PaintTop();
1327 pViewSh
->PaintLeft();
1328 pViewSh
->PaintExtras();
1329 pViewSh
->InvalidateBorder();
1332 pBindings
->Invalidate( FID_TOGGLEHEADERS
); // -> Checks in menu
1333 pBindings
->Invalidate( FID_TOGGLESYNTAX
);
1337 // update ref device (for all documents)
1338 if ( bUpdateRefDev
)
1340 // for all documents: recalc output factor, update row heights
1341 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
1344 if ( pObjSh
->Type() == TYPE(ScDocShell
) )
1346 ScDocShell
* pOneDocSh
= ((ScDocShell
*)pObjSh
);
1347 pOneDocSh
->CalcOutputFactor();
1348 SCTAB nTabCount
= pOneDocSh
->GetDocument()->GetTableCount();
1349 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
1350 pOneDocSh
->AdjustRowHeight( 0, MAXROW
, nTab
);
1352 pObjSh
= SfxObjectShell::GetNext( *pObjSh
);
1355 // for all (tab-) views:
1356 TypeId aScType
= TYPE(ScTabViewShell
);
1357 SfxViewShell
* pSh
= SfxViewShell::GetFirst( &aScType
);
1360 ScTabViewShell
* pOneViewSh
= (ScTabViewShell
*)pSh
;
1362 // set ref-device for EditEngine
1363 ScInputHandler
* pHdl
= GetInputHdl(pOneViewSh
);
1365 pHdl
->UpdateRefDevice();
1367 // update view scale
1368 ScViewData
* pViewData
= pOneViewSh
->GetViewData();
1369 pOneViewSh
->SetZoom( pViewData
->GetZoomX(), pViewData
->GetZoomY(), false );
1372 pOneViewSh
->PaintGrid();
1373 pOneViewSh
->PaintTop();
1374 pOneViewSh
->PaintLeft();
1376 pSh
= SfxViewShell::GetNext( *pSh
, &aScType
);
1384 ScInputHandler
* ScModule::GetInputHdl( ScTabViewShell
* pViewSh
, bool bUseRef
)
1386 if ( pRefInputHandler
&& bUseRef
)
1387 return pRefInputHandler
;
1389 ScInputHandler
* pHdl
= NULL
;
1392 // in case a UIActive embedded object has no ViewShell (UNO component)
1393 // the own calc view shell will be set as current, but no handling should happen
1394 ScTabViewShell
* pCurViewSh
= PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
1395 if ( pCurViewSh
&& !pCurViewSh
->GetUIActiveClient() )
1396 pViewSh
= pCurViewSh
;
1400 pHdl
= pViewSh
->GetInputHandler(); // Viewshell always has one, from now on
1402 // If no ViewShell passed or active, we can get NULL
1403 OSL_ENSURE( pHdl
|| !pViewSh
, "GetInputHdl: no InputHandler found!" );
1407 void ScModule::ViewShellChanged()
1409 ScInputHandler
* pHdl
= GetInputHdl();
1410 ScTabViewShell
* pShell
= ScTabViewShell::GetActiveViewShell();
1411 if ( pShell
&& pHdl
)
1412 pShell
->UpdateInputHandler();
1415 void ScModule::SetInputMode( ScInputMode eMode
, const OUString
* pInitText
)
1417 ScInputHandler
* pHdl
= GetInputHdl();
1419 pHdl
->SetMode(eMode
, pInitText
);
1422 bool ScModule::IsEditMode()
1424 ScInputHandler
* pHdl
= GetInputHdl();
1425 return pHdl
&& pHdl
->IsEditMode();
1428 bool ScModule::IsInputMode()
1430 ScInputHandler
* pHdl
= GetInputHdl();
1431 return pHdl
&& pHdl
->IsInputMode();
1434 bool ScModule::InputKeyEvent( const KeyEvent
& rKEvt
, bool bStartEdit
)
1436 ScInputHandler
* pHdl
= GetInputHdl();
1437 return pHdl
&& pHdl
->KeyInput( rKEvt
, bStartEdit
);
1440 void ScModule::InputEnterHandler( sal_uInt8 nBlockMode
)
1442 if ( !SFX_APP()->IsDowning() ) // Not when quitting the program
1444 ScInputHandler
* pHdl
= GetInputHdl();
1446 pHdl
->EnterHandler( nBlockMode
);
1450 void ScModule::InputCancelHandler()
1452 ScInputHandler
* pHdl
= GetInputHdl();
1454 pHdl
->CancelHandler();
1457 void ScModule::InputSelection( EditView
* pView
)
1459 ScInputHandler
* pHdl
= GetInputHdl();
1461 pHdl
->InputSelection( pView
);
1464 void ScModule::InputChanged( EditView
* pView
)
1466 ScInputHandler
* pHdl
= GetInputHdl();
1468 pHdl
->InputChanged( pView
);
1471 void ScModule::ViewShellGone( ScTabViewShell
* pViewSh
)
1473 ScInputHandler
* pHdl
= GetInputHdl();
1475 pHdl
->ViewShellGone( pViewSh
);
1478 void ScModule::SetRefInputHdl( ScInputHandler
* pNew
)
1480 pRefInputHandler
= pNew
;
1483 ScInputHandler
* ScModule::GetRefInputHdl()
1485 return pRefInputHandler
;
1489 void ScModule::InputGetSelection( sal_Int32
& rStart
, sal_Int32
& rEnd
)
1491 ScInputHandler
* pHdl
= GetInputHdl();
1493 pHdl
->InputGetSelection( rStart
, rEnd
);
1496 void ScModule::InputSetSelection( sal_Int32 nStart
, sal_Int32 nEnd
)
1498 ScInputHandler
* pHdl
= GetInputHdl();
1500 pHdl
->InputSetSelection( nStart
, nEnd
);
1503 void ScModule::InputReplaceSelection( const OUString
& rStr
)
1505 ScInputHandler
* pHdl
= GetInputHdl();
1507 pHdl
->InputReplaceSelection( rStr
);
1510 void ScModule::InputTurnOffWinEngine()
1512 ScInputHandler
* pHdl
= GetInputHdl();
1514 pHdl
->InputTurnOffWinEngine();
1517 OUString
ScModule::InputGetFormulaStr()
1519 ScInputHandler
* pHdl
= GetInputHdl();
1522 aStr
= pHdl
->GetFormString();
1526 void ScModule::ActivateInputWindow( const OUString
* pStrFormula
, bool bMatrix
)
1528 ScInputHandler
* pHdl
= GetInputHdl();
1531 ScInputWindow
* pWin
= pHdl
->GetInputWindow();
1534 // Take over formula
1537 pWin
->SetFuncString( *pStrFormula
, false );
1538 // SetSumAssignMode due to sal_False not necessary
1540 sal_uInt8 nMode
= bMatrix
? SC_ENTER_MATRIX
: SC_ENTER_NORMAL
;
1541 pHdl
->EnterHandler( nMode
);
1543 // Without Invalidate the selection remains active, if the formula has not changed
1545 pWin
->TextInvalidate();
1552 pWin
->SetFuncString( EMPTY_OUSTRING
, false );
1553 // SetSumAssignMode due to sal_False no necessary
1555 pHdl
->CancelHandler();
1563 void ScModule::SetRefDialog( sal_uInt16 nId
, bool bVis
, SfxViewFrame
* pViewFrm
)
1565 //TODO: Move reference dialog handling to view
1566 // Just keep function autopilot here for references to other documents
1567 if(nCurRefDlgId
==0 || (nId
==nCurRefDlgId
&& !bVis
))
1570 pViewFrm
= SfxViewFrame::Current();
1572 // bindings update causes problems with update of stylist if
1573 // current style family has changed
1575 // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher
1577 nCurRefDlgId
= bVis
? nId
: 0 ; // before SetChildWindow
1581 // store the dialog id also in the view shell
1582 SfxViewShell
* pViewSh
= pViewFrm
->GetViewShell();
1583 if ( pViewSh
&& pViewSh
->ISA( ScTabViewShell
) )
1584 ((ScTabViewShell
*)pViewSh
)->SetCurRefDlgId( nCurRefDlgId
);
1587 // no ScTabViewShell - possible for example from a Basic macro
1589 nCurRefDlgId
= 0; // don't set nCurRefDlgId if no dialog is created
1592 pViewFrm
->SetChildWindow( nId
, bVis
);
1595 SfxApplication
* pSfxApp
= SFX_APP();
1596 pSfxApp
->Broadcast( SfxSimpleHint( FID_REFMODECHANGED
) );
1600 static SfxChildWindow
* lcl_GetChildWinFromAnyView( sal_uInt16 nId
)
1602 // First, try the current view
1603 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
1605 // #i46999# current view frame can be null (for example, when closing help)
1606 SfxChildWindow
* pChildWnd
= pViewFrm
? pViewFrm
->GetChildWindow( nId
) : NULL
;
1608 return pChildWnd
; // found in the current view
1610 // if not found there, get the child window from any open view
1611 // it can be open only in one view because nCurRefDlgId is global
1613 pViewFrm
= SfxViewFrame::GetFirst();
1616 pChildWnd
= pViewFrm
->GetChildWindow( nId
);
1618 return pChildWnd
; // found in any view
1620 pViewFrm
= SfxViewFrame::GetNext( *pViewFrm
);
1623 return NULL
; // none found
1626 bool ScModule::IsModalMode(SfxObjectShell
* pDocSh
)
1628 //TODO: Move reference dialog handling to view
1629 // Just keep function autopilot here for references to other documents
1630 bool bIsModal
= false;
1634 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1635 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1638 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1640 bIsModal
= pChildWnd
->IsVisible() && pRefDlg
&&
1641 !( pRefDlg
->IsRefInputMode() && pRefDlg
->IsDocAllowed(pDocSh
) );
1645 bIsModal
= pModalDlg
->IsVisible() && !(pModalDlg
->IsRefInputMode() && pModalDlg
->IsDocAllowed(pDocSh
) );
1649 // in 592 and above, the dialog isn't visible in other views
1650 // if the dialog is open but can't be accessed, disable input
1654 // pChildWnd can be 0 if the dialog has not been created by another Shell yet after
1655 // switching over(e.g. in GetFocus())
1659 ScInputHandler
* pHdl
= GetInputHdl();
1661 bIsModal
= pHdl
->IsModalMode(pDocSh
);
1667 bool ScModule::IsTableLocked()
1669 //TODO: Move reference dialog handling to view
1670 // Just keep function autopilot here for references to other documents
1671 bool bLocked
= false;
1673 // Up until now just for ScAnyRefDlg
1676 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1677 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1680 IAnyRefDialog
* pRefDlg(dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow()));
1684 bLocked
= pRefDlg
->IsTableLocked();
1687 else if( pModalDlg
)
1688 bLocked
= pModalDlg
->IsTableLocked();
1690 bLocked
= true; // for other views, see IsModalMode
1696 bool ScModule::IsRefDialogOpen()
1698 //TODO: Move reference dialog handling to view
1699 // Just keep function autopilot here for references to other documents
1700 bool bIsOpen
= false;
1704 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1705 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1707 bIsOpen
= pChildWnd
->IsVisible();
1709 bIsOpen
= pModalDlg
->IsVisible();
1711 bIsOpen
= true; // for other views, see IsModalMode
1717 bool ScModule::IsFormulaMode()
1719 //TODO: Move reference dialog handling to view
1720 // Just keep function autopilot here for references to other documents
1721 bool bIsFormula
= false;
1725 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1726 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1729 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1731 bIsFormula
= pChildWnd
->IsVisible() && pRefDlg
&& pRefDlg
->IsRefInputMode();
1735 bIsFormula
= pModalDlg
->IsVisible() && pModalDlg
->IsRefInputMode();
1742 ScInputHandler
* pHdl
= GetInputHdl();
1744 bIsFormula
= pHdl
->IsFormulaMode();
1747 if (bIsInEditCommand
)
1753 static void lcl_MarkedTabs( const ScMarkData
& rMark
, SCTAB
& rStartTab
, SCTAB
& rEndTab
)
1755 if (rMark
.GetSelectCount() > 1)
1757 rEndTab
= rMark
.GetLastSelected();
1758 rStartTab
= rMark
.GetFirstSelected();
1762 void ScModule::SetReference( const ScRange
& rRef
, ScDocument
* pDoc
,
1763 const ScMarkData
* pMarkData
)
1765 //TODO: Move reference dialog handling to view
1766 // Just keep function autopilot here for references to other documents
1768 // In RefDialogs we also trigger the ZoomIn, if the Ref's Start and End are different
1769 ScRange aNew
= rRef
;
1770 aNew
.Justify(); // Always in the right direction
1774 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1775 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1776 OSL_ENSURE( pChildWnd
|| pModalDlg
, "NoChildWin" );
1779 if ( nCurRefDlgId
== SID_OPENDLG_CONSOLIDATE
&& pMarkData
)
1781 SCTAB nStartTab
= aNew
.aStart
.Tab();
1782 SCTAB nEndTab
= aNew
.aEnd
.Tab();
1783 lcl_MarkedTabs( *pMarkData
, nStartTab
, nEndTab
);
1784 aNew
.aStart
.SetTab(nStartTab
);
1785 aNew
.aEnd
.SetTab(nEndTab
);
1788 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1792 // hide the (color) selection now instead of later from LoseFocus,
1793 // don't abort the ref input that causes this call (bDoneRefMode = sal_False)
1794 pRefDlg
->HideReference( false );
1795 pRefDlg
->SetReference( aNew
, pDoc
);
1800 // hide the (color) selection now instead of later from LoseFocus,
1801 // don't abort the ref input that causes this call (bDoneRefMode = sal_False)
1802 pModalDlg
->HideReference( false );
1803 pModalDlg
->SetReference( aNew
, pDoc
);
1808 ScInputHandler
* pHdl
= GetInputHdl();
1810 pHdl
->SetReference( aNew
, pDoc
);
1813 OSL_FAIL("SetReference without receiver");
1821 void ScModule::AddRefEntry()
1823 //TODO: Move reference dialog handling to view
1824 // Just keep function autopilot here for references to other documents
1827 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1828 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1829 OSL_ENSURE( pChildWnd
|| pModalDlg
, "NoChildWin" );
1832 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1836 pRefDlg
->AddRefEntry();
1840 pModalDlg
->AddRefEntry();
1844 ScInputHandler
* pHdl
= GetInputHdl();
1846 pHdl
->AddRefEntry();
1850 void ScModule::EndReference()
1852 //TODO: Move reference dialog handling to view
1853 // Just keep function autopilot here for references to other documents
1855 // We also annul the ZoomIn again in RefDialogs
1857 //FIXME: ShowRefFrame at InputHdl, if the Function AutoPilot is open?
1860 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1861 ScAnyRefModalDlg
* pModalDlg
= GetCurrentAnyRefDlg();
1862 OSL_ENSURE( pChildWnd
|| pModalDlg
, "NoChildWin" );
1865 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1869 pRefDlg
->SetActive();
1873 pModalDlg
->SetActive();
1878 * Idle/OnlineSpelling
1880 void ScModule::AnythingChanged()
1882 sal_uLong nOldTime
= aIdleTimer
.GetTimeout();
1883 if ( nOldTime
!= SC_IDLE_MIN
)
1884 aIdleTimer
.SetTimeout( SC_IDLE_MIN
);
1889 static void lcl_CheckNeedsRepaint( ScDocShell
* pDocShell
)
1891 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( pDocShell
);
1894 SfxViewShell
* p
= pFrame
->GetViewShell();
1895 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
,p
);
1897 pViewSh
->CheckNeedsRepaint();
1898 pFrame
= SfxViewFrame::GetNext( *pFrame
, pDocShell
);
1902 IMPL_LINK_NOARG(ScModule
, IdleHandler
)
1904 if ( Application::AnyInput( VCL_INPUT_MOUSEANDKEYBOARD
) )
1906 aIdleTimer
.Start(); // Timeout unchanged
1911 bool bAutoSpell
= false;
1912 ScDocShell
* pDocSh
= dynamic_cast<ScDocShell
*>(SfxObjectShell::Current());
1916 ScDocument
* pDoc
= pDocSh
->GetDocument();
1917 bAutoSpell
= pDoc
->GetDocOptions().IsAutoSpell();
1918 if (pDocSh
->IsReadOnly())
1921 sc::DocumentLinkManager
& rLinkMgr
= pDoc
->GetDocLinkManager();
1922 bool bLinks
= rLinkMgr
.idleCheckLinks();
1923 bool bWidth
= pDoc
->IdleCalcTextWidth();
1925 bMore
= bLinks
|| bWidth
; // Still something at all?
1927 // While calculating a Basic formula, a paint event may have occurred,
1928 // so check the bNeedsRepaint flags for this document's views
1930 lcl_CheckNeedsRepaint( pDocSh
);
1935 ScTabViewShell
* pViewSh
= dynamic_cast<ScTabViewShell
*>(SfxViewShell::Current());
1938 bool bSpell
= pViewSh
->ContinueOnlineSpelling();
1941 aSpellTimer
.Start();
1947 sal_uLong nOldTime
= aIdleTimer
.GetTimeout();
1948 sal_uLong nNewTime
= nOldTime
;
1951 nNewTime
= SC_IDLE_MIN
;
1956 // Set SC_IDLE_COUNT to initial Timeout - increase afterwards
1957 if ( nIdleCount
< SC_IDLE_COUNT
)
1961 nNewTime
+= SC_IDLE_STEP
;
1962 if ( nNewTime
> SC_IDLE_MAX
)
1963 nNewTime
= SC_IDLE_MAX
;
1966 if ( nNewTime
!= nOldTime
)
1967 aIdleTimer
.SetTimeout( nNewTime
);
1973 IMPL_LINK_NOARG(ScModule
, SpellTimerHdl
)
1975 if ( Application::AnyInput( VCL_INPUT_KEYBOARD
) )
1977 aSpellTimer
.Start();
1978 return 0; // Later again ...
1981 ScTabViewShell
* pViewSh
= dynamic_cast<ScTabViewShell
*>(SfxViewShell::Current());
1984 if (pViewSh
->ContinueOnlineSpelling())
1985 aSpellTimer
.Start();
1991 * Virtual methods for the OptionsDialog
1993 SfxItemSet
* ScModule::CreateItemSet( sal_uInt16 nId
)
1995 SfxItemSet
* pRet
= 0;
1996 if(SID_SC_EDITOPTIONS
== nId
)
1998 pRet
= new SfxItemSet( GetPool(),
2000 SID_SCDOCOPTIONS
, SID_SCDOCOPTIONS
,
2002 SID_SCVIEWOPTIONS
, SID_SCVIEWOPTIONS
,
2003 SID_SC_OPT_SYNCZOOM
, SID_SC_OPT_SYNCZOOM
,
2005 SID_SC_INPUT_SELECTION
,SID_SC_INPUT_MARK_HEADER
,
2006 SID_SC_INPUT_TEXTWYSIWYG
,SID_SC_INPUT_TEXTWYSIWYG
,
2007 SID_SC_INPUT_REPLCELLSWARN
,SID_SC_INPUT_REPLCELLSWARN
,
2008 SID_SC_INPUT_LEGACY_CELL_SELECTION
,SID_SC_OPT_SORT_REF_UPDATE
,
2010 SCITEM_USERLIST
, SCITEM_USERLIST
,
2012 SID_SCPRINTOPTIONS
, SID_SCPRINTOPTIONS
,
2014 SID_ATTR_GRID_OPTIONS
, SID_ATTR_GRID_OPTIONS
,
2016 SID_ATTR_METRIC
, SID_ATTR_METRIC
,
2017 SID_ATTR_DEFTABSTOP
, SID_ATTR_DEFTABSTOP
,
2019 SID_SC_OPT_KEY_BINDING_COMPAT
, SID_SC_OPT_KEY_BINDING_COMPAT
,
2021 SID_SCDEFAULTSOPTIONS
, SID_SCDEFAULTSOPTIONS
,
2023 SID_SCFORMULAOPTIONS
, SID_SCFORMULAOPTIONS
,
2026 const ScAppOptions
& rAppOpt
= GetAppOptions();
2028 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
,
2029 SfxObjectShell::Current());
2030 ScDocOptions aCalcOpt
= pDocSh
2031 ? pDocSh
->GetDocument()->GetDocOptions()
2034 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
,
2035 SfxViewShell::Current());
2036 ScViewOptions aViewOpt
= pViewSh
2037 ? pViewSh
->GetViewData()->GetOptions()
2040 ScUserListItem
aULItem( SCITEM_USERLIST
);
2041 ScUserList
* pUL
= ScGlobal::GetUserList();
2043 // SFX_APP()->GetOptions( aSet );
2045 pRet
->Put( SfxUInt16Item( SID_ATTR_METRIC
,
2046 sal::static_int_cast
<sal_uInt16
>(rAppOpt
.GetAppMetric()) ) );
2049 pRet
->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP
,
2050 aCalcOpt
.GetTabDistance()));
2051 pRet
->Put( ScTpCalcItem( SID_SCDOCOPTIONS
, aCalcOpt
) );
2054 pRet
->Put( ScTpViewItem( SID_SCVIEWOPTIONS
, aViewOpt
) );
2055 pRet
->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM
, rAppOpt
.GetSynchronizeZoom() ) );
2058 const ScInputOptions
& rInpOpt
= GetInputOptions();
2059 pRet
->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS
,
2060 rInpOpt
.GetMoveDir() ) );
2061 pRet
->Put( SfxBoolItem( SID_SC_INPUT_SELECTION
,
2062 rInpOpt
.GetMoveSelection() ) );
2063 pRet
->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE
,
2064 rInpOpt
.GetEnterEdit() ) );
2065 pRet
->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND
,
2066 rInpOpt
.GetExtendFormat() ) );
2067 pRet
->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER
,
2068 rInpOpt
.GetRangeFinder() ) );
2069 pRet
->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND
,
2070 rInpOpt
.GetExpandRefs() ) );
2071 pRet
->Put( SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE
, rInpOpt
.GetSortRefUpdate()));
2072 pRet
->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER
,
2073 rInpOpt
.GetMarkHeader() ) );
2074 pRet
->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG
,
2075 rInpOpt
.GetTextWysiwyg() ) );
2076 pRet
->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN
,
2077 rInpOpt
.GetReplaceCellsWarn() ) );
2078 pRet
->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION
,
2079 rInpOpt
.GetLegacyCellSelection() ) );
2083 pRet
->Put( ScTpPrintItem( SID_SCPRINTOPTIONS
, GetPrintOptions() ) );
2086 SvxGridItem
* pSvxGridItem
= aViewOpt
.CreateGridItem();
2087 pRet
->Put( *pSvxGridItem
);
2088 delete pSvxGridItem
;
2093 aULItem
.SetUserList( *pUL
);
2098 pRet
->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT
,
2099 rAppOpt
.GetKeyBindingType() ) );
2102 pRet
->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS
, GetDefaultsOptions() ) );
2105 ScFormulaOptions aOptions
= GetFormulaOptions();
2108 ScCalcConfig
aConfig( aOptions
.GetCalcConfig());
2109 aConfig
.MergeDocumentSpecific( pDocSh
->GetDocument()->GetCalcConfig());
2110 aOptions
.SetCalcConfig( aConfig
);
2112 pRet
->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS
, aOptions
) );
2117 void ScModule::ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
)
2119 if(SID_SC_EDITOPTIONS
== nId
)
2121 ModifyOptions( rSet
);
2125 SfxTabPage
* ScModule::CreateTabPage( sal_uInt16 nId
, Window
* pParent
, const SfxItemSet
& rSet
)
2127 SfxTabPage
* pRet
= NULL
;
2128 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2129 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2132 case SID_SC_TP_LAYOUT
:
2134 ::CreateTabPage ScTpLayoutOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_LAYOUT
);
2135 if ( ScTpLayoutOptionsCreate
)
2136 pRet
= (*ScTpLayoutOptionsCreate
) (pParent
, rSet
);
2139 case SID_SC_TP_CONTENT
:
2141 ::CreateTabPage ScTpContentOptionsCreate
= pFact
->GetTabPageCreatorFunc(RID_SCPAGE_CONTENT
);
2142 if ( ScTpContentOptionsCreate
)
2143 pRet
= (*ScTpContentOptionsCreate
)(pParent
, rSet
);
2146 case SID_SC_TP_GRID
: pRet
= SvxGridTabPage::Create(pParent
, rSet
); break;
2147 case SID_SC_TP_USERLISTS
:
2149 ::CreateTabPage ScTpUserListsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_USERLISTS
);
2150 if ( ScTpUserListsCreate
)
2151 pRet
= (*ScTpUserListsCreate
)( pParent
, rSet
);
2154 case SID_SC_TP_CALC
:
2156 ::CreateTabPage ScTpCalcOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_CALC
);
2157 if ( ScTpCalcOptionsCreate
)
2158 pRet
= (*ScTpCalcOptionsCreate
)(pParent
, rSet
);
2161 case SID_SC_TP_FORMULA
:
2163 ::CreateTabPage ScTpFormulaOptionsCreate
= pFact
->GetTabPageCreatorFunc (RID_SCPAGE_FORMULA
);
2164 if (ScTpFormulaOptionsCreate
)
2165 pRet
= (*ScTpFormulaOptionsCreate
)(pParent
, rSet
);
2168 case SID_SC_TP_COMPATIBILITY
:
2170 ::CreateTabPage ScTpCompatOptionsCreate
= pFact
->GetTabPageCreatorFunc (RID_SCPAGE_COMPATIBILITY
);
2171 if (ScTpCompatOptionsCreate
)
2172 pRet
= (*ScTpCompatOptionsCreate
)(pParent
, rSet
);
2175 case SID_SC_TP_CHANGES
:
2177 ::CreateTabPage ScRedlineOptionsTabPageCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE
);
2178 if ( ScRedlineOptionsTabPageCreate
)
2179 pRet
=(*ScRedlineOptionsTabPageCreate
)(pParent
, rSet
);
2182 case RID_SC_TP_PRINT
:
2184 ::CreateTabPage ScTpPrintOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_PRINT
);
2185 if ( ScTpPrintOptionsCreate
)
2186 pRet
= (*ScTpPrintOptionsCreate
)( pParent
, rSet
);
2189 case RID_SC_TP_DEFAULTS
:
2191 ::CreateTabPage ScTpDefaultsOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_DEFAULTS
);
2192 if ( ScTpDefaultsOptionsCreate
)
2193 pRet
= (*ScTpDefaultsOptionsCreate
)( pParent
, rSet
);
2198 OSL_ENSURE( pRet
, "ScModule::CreateTabPage(): no valid ID for TabPage!" );
2203 IMPL_LINK( ScModule
, CalcFieldValueHdl
, EditFieldInfo
*, pInfo
)
2205 //TODO: Merge with ScFieldEditEngine!
2208 const SvxFieldItem
& rField
= pInfo
->GetField();
2209 const SvxFieldData
* pField
= rField
.GetField();
2211 if (pField
&& pField
->ISA(SvxURLField
))
2214 const SvxURLField
* pURLField
= (const SvxURLField
*) pField
;
2215 OUString aURL
= pURLField
->GetURL();
2217 switch ( pURLField
->GetFormat() )
2219 case SVXURLFORMAT_APPDEFAULT
: //TODO: Settable in the App?
2220 case SVXURLFORMAT_REPR
:
2222 pInfo
->SetRepresentation( pURLField
->GetRepresentation() );
2226 case SVXURLFORMAT_URL
:
2228 pInfo
->SetRepresentation( aURL
);
2233 svtools::ColorConfigEntry eEntry
=
2234 INetURLHistory::GetOrCreate()->QueryUrl( aURL
) ? svtools::LINKSVISITED
: svtools::LINKS
;
2235 pInfo
->SetTxtColor( GetColorConfig().GetColorValue(eEntry
).nColor
);
2239 OSL_FAIL("Unknown Field");
2240 pInfo
->SetRepresentation(OUString('?'));
2247 bool ScModule::RegisterRefWindow( sal_uInt16 nSlotId
, Window
*pWnd
)
2249 std::list
<Window
*> & rlRefWindow
= m_mapRefWindow
[nSlotId
];
2251 if( std::find( rlRefWindow
.begin(), rlRefWindow
.end(), pWnd
) == rlRefWindow
.end() )
2253 rlRefWindow
.push_back( pWnd
);
2260 bool ScModule::UnregisterRefWindow( sal_uInt16 nSlotId
, Window
*pWnd
)
2262 std::map
<sal_uInt16
, std::list
<Window
*> >::iterator iSlot
= m_mapRefWindow
.find( nSlotId
);
2264 if( iSlot
== m_mapRefWindow
.end() )
2267 std::list
<Window
*> & rlRefWindow
= iSlot
->second
;
2269 std::list
<Window
*>::iterator i
= std::find( rlRefWindow
.begin(), rlRefWindow
.end(), pWnd
);
2271 if( i
== rlRefWindow
.end() )
2274 rlRefWindow
.erase( i
);
2276 if( rlRefWindow
.empty() )
2277 m_mapRefWindow
.erase( nSlotId
);
2282 Window
* ScModule::Find1RefWindow( sal_uInt16 nSlotId
, Window
*pWndAncestor
)
2287 std::map
<sal_uInt16
, std::list
<Window
*> >::iterator iSlot
= m_mapRefWindow
.find( nSlotId
);
2289 if( iSlot
== m_mapRefWindow
.end() )
2292 std::list
<Window
*> & rlRefWindow
= iSlot
->second
;
2294 while( Window
*pParent
= pWndAncestor
->GetParent() ) pWndAncestor
= pParent
;
2296 for( std::list
<Window
*>::iterator i
= rlRefWindow
.begin(); i
!=rlRefWindow
.end(); ++i
)
2297 if ( pWndAncestor
->IsWindowOrChild( *i
, (*i
)->IsSystemWindow() ) )
2303 ScAnyRefModalDlg
* ScModule::GetCurrentAnyRefDlg()
2305 if(!maAnyRefDlgStack
.empty())
2306 return maAnyRefDlgStack
.top();
2311 void ScModule::PushNewAnyRefDlg( ScAnyRefModalDlg
* pNewDlg
)
2313 maAnyRefDlgStack
.push( pNewDlg
);
2315 // prevent mismatch between calls to
2316 // SetInRefMode(true) and SetInRefMode(false)
2317 if(maAnyRefDlgStack
.size() != 1)
2320 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
2323 if ( pViewShell
->ISA(ScTabViewShell
) )
2325 ScTabViewShell
* pViewSh
= (ScTabViewShell
*)pViewShell
;
2326 pViewSh
->SetInRefMode( true );
2328 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
2332 void ScModule::PopAnyRefDlg()
2334 maAnyRefDlgStack
.pop();
2336 if(maAnyRefDlgStack
.empty())
2338 // no modal ref dlg any more
2339 // disable the flag in ScGridWindow
2340 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
2343 if ( pViewShell
->ISA(ScTabViewShell
) )
2345 ScTabViewShell
* pViewSh
= (ScTabViewShell
*)pViewShell
;
2346 pViewSh
->SetInRefMode( false );
2348 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
2354 using namespace com::sun::star
;
2356 #define LINGUPROP_AUTOSPELL "IsSpellAuto"
2358 void ScModule::GetSpellSettings( sal_uInt16
& rDefLang
, sal_uInt16
& rCjkLang
, sal_uInt16
& rCtlLang
,
2361 // use SvtLinguConfig instead of service LinguProperties to avoid
2362 // loading the linguistic component
2363 SvtLinguConfig aConfig
;
2365 SvtLinguOptions aOptions
;
2366 aConfig
.GetOptions( aOptions
);
2368 rDefLang
= MsLangId::resolveSystemLanguageByScriptType(aOptions
.nDefaultLanguage
, ::com::sun::star::i18n::ScriptType::LATIN
);
2369 rCjkLang
= MsLangId::resolveSystemLanguageByScriptType(aOptions
.nDefaultLanguage_CJK
, ::com::sun::star::i18n::ScriptType::ASIAN
);
2370 rCtlLang
= MsLangId::resolveSystemLanguageByScriptType(aOptions
.nDefaultLanguage_CTL
, ::com::sun::star::i18n::ScriptType::COMPLEX
);
2371 rAutoSpell
= aOptions
.bIsSpellAuto
;
2374 void ScModule::SetAutoSpellProperty( bool bSet
)
2376 // use SvtLinguConfig instead of service LinguProperties to avoid
2377 // loading the linguistic component
2378 SvtLinguConfig aConfig
;
2382 aConfig
.SetProperty( OUString( LINGUPROP_AUTOSPELL
), aAny
);
2385 bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang
)
2387 if ( nLang
== LANGUAGE_NONE
)
2390 bool bHasLang
= false;
2393 uno::Reference
< linguistic2::XThesaurus
> xThes(LinguMgr::GetThesaurus());
2395 bHasLang
= xThes
->hasLocale( LanguageTag::convertToLocale( nLang
) );
2397 catch( uno::Exception
& )
2399 OSL_FAIL("Error in Thesaurus");
2405 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */