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
)
124 void ScModule::InitInterface_Impl()
126 GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION
| SFX_VISIBILITY_DESKTOP
| SFX_VISIBILITY_STANDARD
| SFX_VISIBILITY_CLIENT
| SFX_VISIBILITY_VIEWER
,
129 GetStaticInterface()->RegisterStatusBar(ScResId(SCCFG_STATUSBAR
));
132 ScModule::ScModule( SfxObjectFactory
* pFact
) :
133 SfxModule( ResMgr::CreateResMgr( "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 aSpellIdle
.SetPriority(SchedulerPriority::LOWER
);
178 aSpellIdle
.SetIdleHdl( 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( *SfxGetpApp() ); // 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()
210 void ScModule::ConfigurationChanged( utl::ConfigurationBroadcaster
* p
, sal_uInt32
)
212 if ( p
== pColorConfig
|| p
== pAccessOptions
)
214 // Test if detective objects have to be updated with new colors
215 // (if the detective colors haven't been used yet, there's nothing to update)
216 if ( ScDetectiveFunc::IsColorsInitialized() )
218 const svtools::ColorConfig
& rColors
= GetColorConfig();
220 ( ScDetectiveFunc::GetArrowColor() != (ColorData
)rColors
.GetColorValue(svtools::CALCDETECTIVE
).nColor
||
221 ScDetectiveFunc::GetErrorColor() != (ColorData
)rColors
.GetColorValue(svtools::CALCDETECTIVEERROR
).nColor
);
223 ( ScDetectiveFunc::GetCommentColor() != (ColorData
)rColors
.GetColorValue(svtools::CALCNOTESBACKGROUND
).nColor
);
224 if ( bArrows
|| bComments
)
226 ScDetectiveFunc::InitializeColors(); // get the new colors
228 // update detective objects in all open documents
229 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
232 if ( pObjSh
->Type() == TYPE(ScDocShell
) )
234 ScDocShell
* pDocSh
= static_cast<ScDocShell
*>(pObjSh
);
236 ScDetectiveFunc( &pDocSh
->GetDocument(), 0 ).UpdateAllArrowColors();
238 ScDetectiveFunc::UpdateAllComments( pDocSh
->GetDocument() );
240 pObjSh
= SfxObjectShell::GetNext( *pObjSh
);
245 // force all views to repaint, using the new options
246 SfxViewShell
* pViewShell
= SfxViewShell::GetFirst();
249 if ( pViewShell
->ISA(ScTabViewShell
) )
251 ScTabViewShell
* pViewSh
= static_cast<ScTabViewShell
*>(pViewShell
);
252 pViewSh
->PaintGrid();
254 pViewSh
->PaintLeft();
255 pViewSh
->PaintExtras();
257 ScInputHandler
* pHdl
= pViewSh
->GetInputHandler();
259 pHdl
->ForgetLastPattern(); // EditEngine BackgroundColor may change
261 else if ( pViewShell
->ISA(ScPreviewShell
) )
263 vcl::Window
* pWin
= pViewShell
->GetWindow();
267 pViewShell
= SfxViewShell::GetNext( *pViewShell
);
270 else if ( p
== pCTLOptions
)
272 // for all documents: set digit language for printer, recalc output factor, update row heights
273 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
276 if ( pObjSh
->Type() == TYPE(ScDocShell
) )
278 ScDocShell
* pDocSh
= static_cast<ScDocShell
*>(pObjSh
);
279 OutputDevice
* pPrinter
= pDocSh
->GetPrinter();
281 pPrinter
->SetDigitLanguage( GetOptDigitLanguage() );
283 pDocSh
->CalcOutputFactor();
285 SCTAB nTabCount
= pDocSh
->GetDocument().GetTableCount();
286 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
287 pDocSh
->AdjustRowHeight( 0, MAXROW
, nTab
);
289 pObjSh
= SfxObjectShell::GetNext( *pObjSh
);
292 // for all views (table and preview): update digit language
293 SfxViewShell
* pSh
= SfxViewShell::GetFirst();
296 if ( pSh
->ISA( ScTabViewShell
) )
298 ScTabViewShell
* pViewSh
= static_cast<ScTabViewShell
*>(pSh
);
300 // set ref-device for EditEngine (re-evaluates digit settings)
301 ScInputHandler
* pHdl
= GetInputHdl(pViewSh
);
303 pHdl
->UpdateRefDevice();
305 pViewSh
->DigitLanguageChanged();
306 pViewSh
->PaintGrid();
308 else if ( pSh
->ISA( ScPreviewShell
) )
310 ScPreviewShell
* pPreviewSh
= static_cast<ScPreviewShell
*>(pSh
);
311 ScPreview
* pPreview
= pPreviewSh
->GetPreview();
313 pPreview
->SetDigitLanguage( GetOptDigitLanguage() );
314 pPreview
->Invalidate();
317 pSh
= SfxViewShell::GetNext( *pSh
);
322 void ScModule::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
324 const SfxSimpleHint
* pSimpleHint
= dynamic_cast<const SfxSimpleHint
*>(&rHint
);
327 sal_uLong nHintId
= pSimpleHint
->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
&& SfxItemState::SET
== pReqArgs
->GetItemState( nSlot
, true, &pItem
) )
398 bSet
= static_cast<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
&& SfxItemState::SET
== pReqArgs
->GetItemState( nSlot
, true, &pItem
) )
420 FieldUnit eUnit
= (FieldUnit
)static_cast<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
= static_cast<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
&& SfxItemState::SET
== pReqArgs
->GetItemState( GetPool().GetWhich(nSlot
), true, &pItem
) )
504 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
507 ScDocument
& rDoc
= pDocSh
->GetDocument();
508 LanguageType eNewLang
= static_cast<const SvxLanguageItem
*>(pItem
)->GetLanguage();
509 LanguageType eLatin
, eCjk
, eCtl
;
510 rDoc
.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 rDoc
.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 LanguageType eLatin
, eCjk
, eCtl
;
608 pDocSh
->GetDocument().GetLanguage( eLatin
, eCjk
, eCtl
);
609 LanguageType eLang
= ( nWhich
== ATTR_CJK_FONT_LANGUAGE
) ? eCjk
:
610 ( ( nWhich
== ATTR_CTL_FONT_LANGUAGE
) ? eCtl
: eLatin
);
611 rSet
.Put( SvxLanguageItem( eLang
, nWhich
) );
618 void ScModule::HideDisabledSlots( SfxItemSet
& rSet
)
620 if( SfxViewFrame
* pViewFrm
= SfxViewFrame::Current() )
622 SfxBindings
& rBindings
= pViewFrm
->GetBindings();
623 SfxWhichIter
aIter( rSet
);
624 for( sal_uInt16 nWhich
= aIter
.FirstWhich(); nWhich
!= 0; nWhich
= aIter
.NextWhich() )
626 ScViewUtil::HideDisabledSlot( rSet
, rBindings
, nWhich
);
627 // always disable the slots
628 rSet
.DisableItem( nWhich
);
633 void ScModule::ResetDragObject()
635 mpDragData
->pCellTransfer
= NULL
;
636 mpDragData
->pDrawTransfer
= NULL
;
637 mpDragData
->pJumpLocalDoc
= NULL
;
638 (mpDragData
->aLinkDoc
).clear();
639 (mpDragData
->aLinkTable
).clear();
640 (mpDragData
->aLinkArea
).clear();
641 (mpDragData
->aJumpTarget
).clear();
642 (mpDragData
->aJumpText
).clear();
645 void ScModule::SetDragObject( ScTransferObj
* pCellObj
, ScDrawTransferObj
* pDrawObj
)
648 mpDragData
->pCellTransfer
= pCellObj
;
649 mpDragData
->pDrawTransfer
= pDrawObj
;
652 void ScModule::SetDragLink(
653 const OUString
& rDoc
, const OUString
& rTab
, const OUString
& rArea
)
656 mpDragData
->aLinkDoc
= rDoc
;
657 mpDragData
->aLinkTable
= rTab
;
658 mpDragData
->aLinkArea
= rArea
;
661 void ScModule::SetDragJump(
662 ScDocument
* pLocalDoc
, const OUString
& rTarget
, const OUString
& rText
)
666 mpDragData
->pJumpLocalDoc
= pLocalDoc
;
667 mpDragData
->aJumpTarget
= rTarget
;
668 mpDragData
->aJumpText
= rText
;
671 void ScModule::SetClipObject( ScTransferObj
* pCellObj
, ScDrawTransferObj
* pDrawObj
)
673 OSL_ENSURE( !pCellObj
|| !pDrawObj
, "SetClipObject: not allowed to set both objects" );
675 mpClipData
->pCellClipboard
= pCellObj
;
676 mpClipData
->pDrawClipboard
= pDrawObj
;
679 ScDocument
* ScModule::GetClipDoc()
681 // called from document
682 ScTransferObj
* pObj
= ScTransferObj::GetOwnClipboard( NULL
);
684 return pObj
->GetDocument();
689 void ScModule::SetSelectionTransfer( ScSelectionTransferObj
* pNew
)
694 void ScModule::InitFormEditData()
696 pFormEditData
= new ScFormEditData
;
699 void ScModule::ClearFormEditData()
701 DELETEZ( pFormEditData
);
704 void ScModule::SetViewOptions( const ScViewOptions
& rOpt
)
707 pViewCfg
= new ScViewCfg
;
709 pViewCfg
->SetOptions( rOpt
);
712 const ScViewOptions
& ScModule::GetViewOptions()
715 pViewCfg
= new ScViewCfg
;
720 void ScModule::SetDocOptions( const ScDocOptions
& rOpt
)
723 pDocCfg
= new ScDocCfg
;
725 pDocCfg
->SetOptions( rOpt
);
728 const ScDocOptions
& ScModule::GetDocOptions()
731 pDocCfg
= new ScDocCfg
;
740 void ScModule::InsertEntryToLRUList(sal_uInt16 nFIndex
)
744 const ScAppOptions
& rAppOpt
= GetAppOptions();
745 sal_uInt16 nLRUFuncCount
= std::min( rAppOpt
.GetLRUFuncListCount(), (sal_uInt16
)LRU_MAX
);
746 sal_uInt16
* pLRUListIds
= rAppOpt
.GetLRUFuncList();
748 sal_uInt16 aIdxList
[LRU_MAX
];
752 while ((n
< LRU_MAX
) && n
<nLRUFuncCount
) // Iterate through old list
754 if (!bFound
&& (pLRUListIds
[n
]== nFIndex
))
755 bFound
= true; // First hit!
757 aIdxList
[n
] = pLRUListIds
[n
]; // Copy after hit
758 else if ((n
+1) < LRU_MAX
)
759 aIdxList
[n
+1] = pLRUListIds
[n
]; // Move before hit
762 if (!bFound
&& (n
< LRU_MAX
)) // Entry not found?
764 aIdxList
[0] = nFIndex
; // Current on Top
766 ScAppOptions
aNewOpts(rAppOpt
); // Let App know
767 aNewOpts
.SetLRUFuncList(aIdxList
, n
);
768 SetAppOptions(aNewOpts
);
770 RecentFunctionsChanged();
774 void ScModule::RecentFunctionsChanged()
776 // update function list window
777 sal_uInt16 nFuncListID
= ScFunctionChildWindow::GetChildWindowId();
780 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
781 if (pViewFrm
&& pViewFrm
->HasChildWindow(nFuncListID
))
783 ScFunctionChildWindow
* pWnd
= static_cast<ScFunctionChildWindow
*>(pViewFrm
->GetChildWindow(nFuncListID
));
786 ScFunctionDockWin
* pFuncList
= static_cast<ScFunctionDockWin
*>(pWnd
->GetWindow());
787 pFuncList
->InitLRUList();
791 void ScModule::SetAppOptions( const ScAppOptions
& rOpt
)
794 pAppCfg
= new ScAppCfg
;
796 pAppCfg
->SetOptions( rOpt
);
799 void global_InitAppOptions()
801 SC_MOD()->GetAppOptions();
804 const ScAppOptions
& ScModule::GetAppOptions()
807 pAppCfg
= new ScAppCfg
;
812 void ScModule::SetDefaultsOptions( const ScDefaultsOptions
& rOpt
)
815 pDefaultsCfg
= new ScDefaultsCfg
;
817 pDefaultsCfg
->SetOptions( rOpt
);
820 const ScDefaultsOptions
& ScModule::GetDefaultsOptions()
823 pDefaultsCfg
= new ScDefaultsCfg
;
825 return *pDefaultsCfg
;
828 void ScModule::SetFormulaOptions( const ScFormulaOptions
& rOpt
)
831 pFormulaCfg
= new ScFormulaCfg
;
833 pFormulaCfg
->SetOptions( rOpt
);
836 const ScFormulaOptions
& ScModule::GetFormulaOptions()
839 pFormulaCfg
= new ScFormulaCfg
;
844 void ScModule::SetInputOptions( const ScInputOptions
& rOpt
)
847 pInputCfg
= new ScInputCfg
;
849 pInputCfg
->SetOptions( rOpt
);
852 const ScInputOptions
& ScModule::GetInputOptions()
855 pInputCfg
= new ScInputCfg
;
860 void ScModule::SetPrintOptions( const ScPrintOptions
& rOpt
)
863 pPrintCfg
= new ScPrintCfg
;
865 pPrintCfg
->SetOptions( rOpt
);
868 const ScPrintOptions
& ScModule::GetPrintOptions()
871 pPrintCfg
= new ScPrintCfg
;
876 ScNavipiCfg
& ScModule::GetNavipiCfg()
879 pNavipiCfg
= new ScNavipiCfg
;
884 ScAddInCfg
& ScModule::GetAddInCfg()
887 pAddInCfg
= new ScAddInCfg
;
892 svtools::ColorConfig
& ScModule::GetColorConfig()
896 pColorConfig
= new svtools::ColorConfig
;
897 pColorConfig
->AddListener(this);
900 return *pColorConfig
;
903 SvtAccessibilityOptions
& ScModule::GetAccessOptions()
905 if ( !pAccessOptions
)
907 pAccessOptions
= new SvtAccessibilityOptions
;
908 pAccessOptions
->AddListener(this);
911 return *pAccessOptions
;
914 SvtCTLOptions
& ScModule::GetCTLOptions()
918 pCTLOptions
= new SvtCTLOptions
;
919 pCTLOptions
->AddListener(this);
925 SvtUserOptions
& ScModule::GetUserOptions()
929 pUserOptions
= new SvtUserOptions
;
931 return *pUserOptions
;
934 sal_uInt16
ScModule::GetOptDigitLanguage()
936 SvtCTLOptions::TextNumerals eNumerals
= GetCTLOptions().GetCTLTextNumerals();
937 return ( eNumerals
== SvtCTLOptions::NUMERALS_ARABIC
) ? LANGUAGE_ENGLISH_US
:
938 ( eNumerals
== SvtCTLOptions::NUMERALS_HINDI
) ? LANGUAGE_ARABIC_SAUDI_ARABIA
:
945 * Items from Calc options dialog and SID_AUTOSPELL_CHECK
947 void ScModule::ModifyOptions( const SfxItemSet
& rOptSet
)
949 sal_uInt16 nOldSpellLang
, nOldCjkLang
, nOldCtlLang
;
951 GetSpellSettings( nOldSpellLang
, nOldCjkLang
, nOldCtlLang
, bOldAutoSpell
);
955 OSL_ENSURE( pAppCfg
, "AppOptions not initialised :-(" );
959 OSL_ENSURE( pInputCfg
, "InputOptions not initialised :-(" );
961 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
962 SfxBindings
* pBindings
= pViewFrm
? &pViewFrm
->GetBindings() : NULL
;
964 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
, SfxViewShell::Current());
965 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
, SfxObjectShell::Current());
966 ScDocument
* pDoc
= pDocSh
? &pDocSh
->GetDocument() : NULL
;
967 const SfxPoolItem
* pItem
= NULL
;
968 bool bRepaint
= false;
969 bool bUpdateMarks
= false;
970 bool bUpdateRefDev
= false;
971 bool bCalcAll
= false;
972 bool bSaveAppOptions
= false;
973 bool bSaveInputOptions
= false;
974 bool bCompileErrorCells
= false;
976 // SfxGetpApp()->SetOptions( rOptSet );
978 // No more linguistics
979 if (rOptSet
.HasItem(SID_ATTR_METRIC
, &pItem
))
982 pAppCfg
->SetAppMetric( (FieldUnit
)static_cast<const SfxUInt16Item
*>(pItem
)->GetValue() );
983 bSaveAppOptions
= true;
986 if (rOptSet
.HasItem(SCITEM_USERLIST
, &pItem
))
988 ScGlobal::SetUserList( static_cast<const ScUserListItem
*>(pItem
)->GetUserList() );
989 bSaveAppOptions
= true;
992 if (rOptSet
.HasItem(SID_SC_OPT_SYNCZOOM
, &pItem
))
994 pAppCfg
->SetSynchronizeZoom( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
995 bSaveAppOptions
= true;
998 if (rOptSet
.HasItem(SID_SC_OPT_KEY_BINDING_COMPAT
, &pItem
))
1000 sal_uInt16 nVal
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1001 ScOptionsUtil::KeyBindingType eOld
= pAppCfg
->GetKeyBindingType();
1002 ScOptionsUtil::KeyBindingType eNew
= static_cast<ScOptionsUtil::KeyBindingType
>(nVal
);
1005 pAppCfg
->SetKeyBindingType(eNew
);
1006 bSaveAppOptions
= true;
1007 ScDocShell::ResetKeyBindings(eNew
);
1012 if (rOptSet
.HasItem(SID_SCDEFAULTSOPTIONS
, &pItem
))
1014 const ScDefaultsOptions
& rOpt
= static_cast<const ScTpDefaultsItem
*>(pItem
)->GetDefaultsOptions();
1015 SetDefaultsOptions( rOpt
);
1019 if (rOptSet
.HasItem(SID_SCFORMULAOPTIONS
, &pItem
))
1021 const ScFormulaOptions
& rOpt
= static_cast<const ScTpFormulaItem
*>(pItem
)->GetFormulaOptions();
1023 if (!pFormulaCfg
|| (*pFormulaCfg
!= rOpt
))
1024 // Formula options have changed. Repaint the column headers.
1027 if (pFormulaCfg
&& pFormulaCfg
->GetUseEnglishFuncName() != rOpt
.GetUseEnglishFuncName())
1029 // Re-compile formula cells with error as the error may have been
1030 // caused by unresolved function names.
1031 bCompileErrorCells
= true;
1034 // Recalc for interpreter options changes.
1035 if (pFormulaCfg
&& pFormulaCfg
->GetCalcConfig() != rOpt
.GetCalcConfig())
1040 pDocSh
->SetFormulaOptions( rOpt
);
1041 pDocSh
->SetDocumentModified();
1044 // ScDocShell::SetFormulaOptions() may check for changed settings, so
1045 // set the new options here after that has been called.
1046 SetFormulaOptions( rOpt
);
1050 if (rOptSet
.HasItem(SID_SCVIEWOPTIONS
, &pItem
))
1052 const ScViewOptions
& rNewOpt
= static_cast<const ScTpViewItem
*>(pItem
)->GetViewOptions();
1056 ScViewData
& rViewData
= pViewSh
->GetViewData();
1057 const ScViewOptions
& rOldOpt
= rViewData
.GetOptions();
1059 bool bAnchorList
= ( rOldOpt
.GetOption( VOPT_ANCHOR
) !=
1060 rNewOpt
.GetOption( VOPT_ANCHOR
) );
1062 if ( rOldOpt
!= rNewOpt
)
1064 rViewData
.SetOptions( rNewOpt
); // Changes rOldOpt
1065 rViewData
.GetDocument()->SetViewOptions( rNewOpt
);
1067 pDocSh
->SetDocumentModified();
1071 pViewSh
->UpdateAnchorHandles();
1073 SetViewOptions( rNewOpt
);
1076 pBindings
->Invalidate(SID_HELPLINES_MOVE
);
1081 // Evaluate after ViewOptions, as GridOptions is a member of ViewOptions
1082 if ( rOptSet
.HasItem(SID_ATTR_GRID_OPTIONS
,&pItem
) )
1084 ScGridOptions
aNewGridOpt( static_cast<const SvxGridItem
&>(*pItem
));
1088 ScViewData
& rViewData
= pViewSh
->GetViewData();
1089 ScViewOptions
aNewViewOpt( rViewData
.GetOptions() );
1090 const ScGridOptions
& rOldGridOpt
= aNewViewOpt
.GetGridOptions();
1092 if ( rOldGridOpt
!= aNewGridOpt
)
1094 aNewViewOpt
.SetGridOptions( aNewGridOpt
);
1095 rViewData
.SetOptions( aNewViewOpt
);
1096 rViewData
.GetDocument()->SetViewOptions( aNewViewOpt
);
1097 pDocSh
->SetDocumentModified();
1101 ScViewOptions
aNewViewOpt ( GetViewOptions() );
1102 aNewViewOpt
.SetGridOptions( aNewGridOpt
);
1103 SetViewOptions( aNewViewOpt
);
1106 pBindings
->Invalidate(SID_GRID_VISIBLE
);
1107 pBindings
->Invalidate(SID_GRID_USE
);
1112 if ( rOptSet
.HasItem(SID_SCDOCOPTIONS
,&pItem
) )
1114 const ScDocOptions
& rNewOpt
= static_cast<const ScTpCalcItem
*>(pItem
)->GetDocOptions();
1118 const ScDocOptions
& rOldOpt
= pDoc
->GetDocOptions();
1120 bRepaint
= ( bRepaint
|| ( rOldOpt
!= rNewOpt
) );
1121 bCalcAll
= bRepaint
&&
1122 ( rOldOpt
.IsIter() != rNewOpt
.IsIter()
1123 || rOldOpt
.GetIterCount() != rNewOpt
.GetIterCount()
1124 || rOldOpt
.GetIterEps() != rNewOpt
.GetIterEps()
1125 || rOldOpt
.IsIgnoreCase() != rNewOpt
.IsIgnoreCase()
1126 || rOldOpt
.IsCalcAsShown() != rNewOpt
.IsCalcAsShown()
1127 || (rNewOpt
.IsCalcAsShown() &&
1128 rOldOpt
.GetStdPrecision() != rNewOpt
.GetStdPrecision())
1129 || rOldOpt
.IsMatchWholeCell() != rNewOpt
.IsMatchWholeCell()
1130 || rOldOpt
.GetYear2000() != rNewOpt
.GetYear2000()
1131 || rOldOpt
.IsFormulaRegexEnabled() != rNewOpt
.IsFormulaRegexEnabled()
1133 pDoc
->SetDocOptions( rNewOpt
);
1134 pDocSh
->SetDocumentModified();
1136 SetDocOptions( rNewOpt
);
1139 // Set TabDistance after the actual DocOptions
1140 if ( rOptSet
.HasItem(SID_ATTR_DEFTABSTOP
,&pItem
) )
1142 sal_uInt16 nTabDist
= static_cast<const SfxUInt16Item
*>(pItem
)->GetValue();
1143 ScDocOptions
aOpt(GetDocOptions());
1144 aOpt
.SetTabDistance(nTabDist
);
1145 SetDocOptions( aOpt
);
1149 ScDocOptions
aDocOpt(pDoc
->GetDocOptions());
1150 aDocOpt
.SetTabDistance(nTabDist
);
1151 pDoc
->SetDocOptions( aDocOpt
);
1152 pDocSh
->SetDocumentModified();
1153 if(pDoc
->GetDrawLayer())
1154 pDoc
->GetDrawLayer()->SetDefaultTabulator(nTabDist
);
1158 // AutoSpell after the DocOptions (due to being a member)
1159 if ( rOptSet
.HasItem(SID_AUTOSPELL_CHECK
,&pItem
) ) // At DocOptions
1161 bool bDoAutoSpell
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1165 ScDocOptions aNewOpt
= pDoc
->GetDocOptions();
1166 if ( aNewOpt
.IsAutoSpell() != bDoAutoSpell
)
1168 aNewOpt
.SetAutoSpell( bDoAutoSpell
);
1169 pDoc
->SetDocOptions( aNewOpt
);
1172 pViewSh
->EnableAutoSpell(bDoAutoSpell
);
1174 bRepaint
= true; // Because HideAutoSpell might be invalid
1175 //TODO: Paint all Views?
1179 if ( bOldAutoSpell
!= bDoAutoSpell
)
1180 SetAutoSpellProperty( bDoAutoSpell
);
1182 pDocSh
->PostPaintGridAll(); // Due to marks
1183 ScInputHandler
* pInputHandler
= GetInputHdl();
1184 if ( pInputHandler
)
1185 pInputHandler
->UpdateSpellSettings(); // EditEngine flags
1187 pViewSh
->UpdateDrawTextOutliner(); // EditEngine flags
1190 pBindings
->Invalidate( SID_AUTOSPELL_CHECK
);
1194 if ( rOptSet
.HasItem(SID_SC_INPUT_SELECTIONPOS
,&pItem
) )
1196 pInputCfg
->SetMoveDir( static_cast<const SfxUInt16Item
*>(pItem
)->GetValue() );
1197 bSaveInputOptions
= true;
1199 if ( rOptSet
.HasItem(SID_SC_INPUT_SELECTION
,&pItem
) )
1201 pInputCfg
->SetMoveSelection( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1202 bSaveInputOptions
= true;
1204 if ( rOptSet
.HasItem(SID_SC_INPUT_EDITMODE
,&pItem
) )
1206 pInputCfg
->SetEnterEdit( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1207 bSaveInputOptions
= true;
1209 if ( rOptSet
.HasItem(SID_SC_INPUT_FMT_EXPAND
,&pItem
) )
1211 pInputCfg
->SetExtendFormat( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1212 bSaveInputOptions
= true;
1214 if ( rOptSet
.HasItem(SID_SC_INPUT_RANGEFINDER
,&pItem
) )
1216 pInputCfg
->SetRangeFinder( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1217 bSaveInputOptions
= true;
1219 if ( rOptSet
.HasItem(SID_SC_INPUT_REF_EXPAND
,&pItem
) )
1221 pInputCfg
->SetExpandRefs( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1222 bSaveInputOptions
= true;
1224 if (rOptSet
.HasItem(SID_SC_OPT_SORT_REF_UPDATE
, &pItem
))
1226 pInputCfg
->SetSortRefUpdate(static_cast<const SfxBoolItem
*>(pItem
)->GetValue());
1227 bSaveInputOptions
= true;
1230 if ( rOptSet
.HasItem(SID_SC_INPUT_MARK_HEADER
,&pItem
) )
1232 pInputCfg
->SetMarkHeader( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1233 bSaveInputOptions
= true;
1234 bUpdateMarks
= true;
1236 if ( rOptSet
.HasItem(SID_SC_INPUT_TEXTWYSIWYG
,&pItem
) )
1238 bool bNew
= static_cast<const SfxBoolItem
*>(pItem
)->GetValue();
1239 if ( bNew
!= pInputCfg
->GetTextWysiwyg() )
1241 pInputCfg
->SetTextWysiwyg( bNew
);
1242 bSaveInputOptions
= true;
1243 bUpdateRefDev
= true;
1246 if( rOptSet
.HasItem( SID_SC_INPUT_REPLCELLSWARN
, &pItem
) )
1248 pInputCfg
->SetReplaceCellsWarn( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1249 bSaveInputOptions
= true;
1252 if( rOptSet
.HasItem( SID_SC_INPUT_LEGACY_CELL_SELECTION
, &pItem
) )
1254 pInputCfg
->SetLegacyCellSelection( static_cast<const SfxBoolItem
*>(pItem
)->GetValue() );
1255 bSaveInputOptions
= true;
1259 if ( rOptSet
.HasItem(SID_SCPRINTOPTIONS
,&pItem
) )
1261 const ScPrintOptions
& rNewOpt
= static_cast<const ScTpPrintItem
*>(pItem
)->GetPrintOptions();
1262 SetPrintOptions( rNewOpt
);
1264 // broadcast causes all previews to recalc page numbers
1265 SfxGetpApp()->Broadcast( SfxSimpleHint( SID_SCPRINTOPTIONS
) );
1268 if ( bSaveAppOptions
)
1269 pAppCfg
->OptionsChanged();
1271 if ( bSaveInputOptions
)
1272 pInputCfg
->OptionsChanged();
1274 // Kick off recalculation?
1275 if (pDoc
&& bCompileErrorCells
)
1277 // Re-compile cells with name error, and recalc if at least one cell
1278 // has been re-compiled. In the future we may want to find a way to
1279 // recalc only those that are affected.
1280 if (pDoc
->CompileErrorCells(ScErrorCodes::errNoName
))
1284 if ( pDoc
&& bCalcAll
)
1286 WaitObject
aWait( ScDocShell::GetActiveDialogParent() );
1289 pViewSh
->UpdateCharts( true );
1291 ScDBFunc::DoUpdateCharts( ScAddress(), pDoc
, true );
1293 pBindings
->Invalidate( SID_ATTR_SIZE
); //SvxPosSize StatusControl Update
1296 if ( pViewSh
&& bUpdateMarks
)
1297 pViewSh
->UpdateAutoFillMark();
1300 if ( pViewSh
&& bRepaint
)
1302 pViewSh
->UpdateFixPos();
1303 pViewSh
->PaintGrid();
1304 pViewSh
->PaintTop();
1305 pViewSh
->PaintLeft();
1306 pViewSh
->PaintExtras();
1307 pViewSh
->InvalidateBorder();
1310 pBindings
->Invalidate( FID_TOGGLEHEADERS
); // -> Checks in menu
1311 pBindings
->Invalidate( FID_TOGGLESYNTAX
);
1315 // update ref device (for all documents)
1316 if ( bUpdateRefDev
)
1318 // for all documents: recalc output factor, update row heights
1319 SfxObjectShell
* pObjSh
= SfxObjectShell::GetFirst();
1322 if ( pObjSh
->Type() == TYPE(ScDocShell
) )
1324 ScDocShell
* pOneDocSh
= static_cast<ScDocShell
*>(pObjSh
);
1325 pOneDocSh
->CalcOutputFactor();
1326 SCTAB nTabCount
= pOneDocSh
->GetDocument().GetTableCount();
1327 for (SCTAB nTab
=0; nTab
<nTabCount
; nTab
++)
1328 pOneDocSh
->AdjustRowHeight( 0, MAXROW
, nTab
);
1330 pObjSh
= SfxObjectShell::GetNext( *pObjSh
);
1333 // for all (tab-) views:
1334 TypeId aScType
= TYPE(ScTabViewShell
);
1335 SfxViewShell
* pSh
= SfxViewShell::GetFirst( &aScType
);
1338 ScTabViewShell
* pOneViewSh
= static_cast<ScTabViewShell
*>(pSh
);
1340 // set ref-device for EditEngine
1341 ScInputHandler
* pHdl
= GetInputHdl(pOneViewSh
);
1343 pHdl
->UpdateRefDevice();
1345 // update view scale
1346 ScViewData
& rViewData
= pOneViewSh
->GetViewData();
1347 pOneViewSh
->SetZoom( rViewData
.GetZoomX(), rViewData
.GetZoomY(), false );
1350 pOneViewSh
->PaintGrid();
1351 pOneViewSh
->PaintTop();
1352 pOneViewSh
->PaintLeft();
1354 pSh
= SfxViewShell::GetNext( *pSh
, &aScType
);
1362 ScInputHandler
* ScModule::GetInputHdl( ScTabViewShell
* pViewSh
, bool bUseRef
)
1364 if ( pRefInputHandler
&& bUseRef
)
1365 return pRefInputHandler
;
1367 ScInputHandler
* pHdl
= NULL
;
1370 // in case a UIActive embedded object has no ViewShell (UNO component)
1371 // the own calc view shell will be set as current, but no handling should happen
1372 ScTabViewShell
* pCurViewSh
= PTR_CAST( ScTabViewShell
, SfxViewShell::Current() );
1373 if ( pCurViewSh
&& !pCurViewSh
->GetUIActiveClient() )
1374 pViewSh
= pCurViewSh
;
1378 pHdl
= pViewSh
->GetInputHandler(); // Viewshell always has one, from now on
1380 // If no ViewShell passed or active, we can get NULL
1381 OSL_ENSURE( pHdl
|| !pViewSh
, "GetInputHdl: no InputHandler found!" );
1385 void ScModule::ViewShellChanged()
1387 ScInputHandler
* pHdl
= GetInputHdl();
1388 ScTabViewShell
* pShell
= ScTabViewShell::GetActiveViewShell();
1389 if ( pShell
&& pHdl
)
1390 pShell
->UpdateInputHandler();
1393 void ScModule::SetInputMode( ScInputMode eMode
, const OUString
* pInitText
)
1395 ScInputHandler
* pHdl
= GetInputHdl();
1397 pHdl
->SetMode(eMode
, pInitText
);
1400 bool ScModule::IsEditMode()
1402 ScInputHandler
* pHdl
= GetInputHdl();
1403 return pHdl
&& pHdl
->IsEditMode();
1406 bool ScModule::IsInputMode()
1408 ScInputHandler
* pHdl
= GetInputHdl();
1409 return pHdl
&& pHdl
->IsInputMode();
1412 bool ScModule::InputKeyEvent( const KeyEvent
& rKEvt
, bool bStartEdit
)
1414 ScInputHandler
* pHdl
= GetInputHdl();
1415 return pHdl
&& pHdl
->KeyInput( rKEvt
, bStartEdit
);
1418 void ScModule::InputEnterHandler( sal_uInt8 nBlockMode
)
1420 if ( !SfxGetpApp()->IsDowning() ) // Not when quitting the program
1422 ScInputHandler
* pHdl
= GetInputHdl();
1424 pHdl
->EnterHandler( nBlockMode
);
1428 void ScModule::InputCancelHandler()
1430 ScInputHandler
* pHdl
= GetInputHdl();
1432 pHdl
->CancelHandler();
1435 void ScModule::InputSelection( EditView
* pView
)
1437 ScInputHandler
* pHdl
= GetInputHdl();
1439 pHdl
->InputSelection( pView
);
1442 void ScModule::InputChanged( EditView
* pView
)
1444 ScInputHandler
* pHdl
= GetInputHdl();
1446 pHdl
->InputChanged( pView
);
1449 void ScModule::ViewShellGone( ScTabViewShell
* pViewSh
)
1451 ScInputHandler
* pHdl
= GetInputHdl();
1453 pHdl
->ViewShellGone( pViewSh
);
1456 void ScModule::SetRefInputHdl( ScInputHandler
* pNew
)
1458 pRefInputHandler
= pNew
;
1461 void ScModule::InputGetSelection( sal_Int32
& rStart
, sal_Int32
& rEnd
)
1463 ScInputHandler
* pHdl
= GetInputHdl();
1465 pHdl
->InputGetSelection( rStart
, rEnd
);
1468 void ScModule::InputSetSelection( sal_Int32 nStart
, sal_Int32 nEnd
)
1470 ScInputHandler
* pHdl
= GetInputHdl();
1472 pHdl
->InputSetSelection( nStart
, nEnd
);
1475 void ScModule::InputReplaceSelection( const OUString
& rStr
)
1477 ScInputHandler
* pHdl
= GetInputHdl();
1479 pHdl
->InputReplaceSelection( rStr
);
1482 void ScModule::InputTurnOffWinEngine()
1484 ScInputHandler
* pHdl
= GetInputHdl();
1486 pHdl
->InputTurnOffWinEngine();
1489 OUString
ScModule::InputGetFormulaStr()
1491 ScInputHandler
* pHdl
= GetInputHdl();
1494 aStr
= pHdl
->GetFormString();
1498 void ScModule::ActivateInputWindow( const OUString
* pStrFormula
, bool bMatrix
)
1500 ScInputHandler
* pHdl
= GetInputHdl();
1503 ScInputWindow
* pWin
= pHdl
->GetInputWindow();
1506 // Take over formula
1509 pWin
->SetFuncString( *pStrFormula
, false );
1510 // SetSumAssignMode due to sal_False not necessary
1512 sal_uInt8 nMode
= bMatrix
? SC_ENTER_MATRIX
: SC_ENTER_NORMAL
;
1513 pHdl
->EnterHandler( nMode
);
1515 // Without Invalidate the selection remains active, if the formula has not changed
1517 pWin
->TextInvalidate();
1524 pWin
->SetFuncString( EMPTY_OUSTRING
, false );
1525 // SetSumAssignMode due to sal_False no necessary
1527 pHdl
->CancelHandler();
1535 void ScModule::SetRefDialog( sal_uInt16 nId
, bool bVis
, SfxViewFrame
* pViewFrm
)
1537 //TODO: Move reference dialog handling to view
1538 // Just keep function autopilot here for references to other documents
1539 if(nCurRefDlgId
==0 || (nId
==nCurRefDlgId
&& !bVis
))
1542 pViewFrm
= SfxViewFrame::Current();
1544 // bindings update causes problems with update of stylist if
1545 // current style family has changed
1547 // pViewFrm->GetBindings().Update(); // to avoid trouble in LockDispatcher
1549 nCurRefDlgId
= bVis
? nId
: 0 ; // before SetChildWindow
1553 // store the dialog id also in the view shell
1554 SfxViewShell
* pViewSh
= pViewFrm
->GetViewShell();
1555 if ( pViewSh
&& pViewSh
->ISA( ScTabViewShell
) )
1556 static_cast<ScTabViewShell
*>(pViewSh
)->SetCurRefDlgId( nCurRefDlgId
);
1559 // no ScTabViewShell - possible for example from a Basic macro
1561 nCurRefDlgId
= 0; // don't set nCurRefDlgId if no dialog is created
1564 pViewFrm
->SetChildWindow( nId
, bVis
);
1567 SfxApplication
* pSfxApp
= SfxGetpApp();
1568 pSfxApp
->Broadcast( SfxSimpleHint( FID_REFMODECHANGED
) );
1572 static SfxChildWindow
* lcl_GetChildWinFromAnyView( sal_uInt16 nId
)
1574 // First, try the current view
1575 SfxViewFrame
* pViewFrm
= SfxViewFrame::Current();
1577 // #i46999# current view frame can be null (for example, when closing help)
1578 SfxChildWindow
* pChildWnd
= pViewFrm
? pViewFrm
->GetChildWindow( nId
) : NULL
;
1580 return pChildWnd
; // found in the current view
1582 // if not found there, get the child window from any open view
1583 // it can be open only in one view because nCurRefDlgId is global
1585 pViewFrm
= SfxViewFrame::GetFirst();
1588 pChildWnd
= pViewFrm
->GetChildWindow( nId
);
1590 return pChildWnd
; // found in any view
1592 pViewFrm
= SfxViewFrame::GetNext( *pViewFrm
);
1595 return NULL
; // none found
1598 bool ScModule::IsModalMode(SfxObjectShell
* pDocSh
)
1600 //TODO: Move reference dialog handling to view
1601 // Just keep function autopilot here for references to other documents
1602 bool bIsModal
= false;
1606 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1609 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1611 bIsModal
= pChildWnd
->IsVisible() && pRefDlg
&&
1612 !( pRefDlg
->IsRefInputMode() && pRefDlg
->IsDocAllowed(pDocSh
) );
1616 // in 592 and above, the dialog isn't visible in other views
1617 // if the dialog is open but can't be accessed, disable input
1621 // pChildWnd can be 0 if the dialog has not been created by another Shell yet after
1622 // switching over(e.g. in GetFocus())
1626 ScInputHandler
* pHdl
= GetInputHdl();
1628 bIsModal
= pHdl
->IsModalMode(pDocSh
);
1634 bool ScModule::IsTableLocked()
1636 //TODO: Move reference dialog handling to view
1637 // Just keep function autopilot here for references to other documents
1638 bool bLocked
= false;
1640 // Up until now just for ScAnyRefDlg
1643 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1646 IAnyRefDialog
* pRefDlg(dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow()));
1650 bLocked
= pRefDlg
->IsTableLocked();
1654 bLocked
= true; // for other views, see IsModalMode
1660 bool ScModule::IsRefDialogOpen()
1662 //TODO: Move reference dialog handling to view
1663 // Just keep function autopilot here for references to other documents
1664 bool bIsOpen
= false;
1668 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1670 bIsOpen
= pChildWnd
->IsVisible();
1672 bIsOpen
= true; // for other views, see IsModalMode
1678 bool ScModule::IsFormulaMode()
1680 //TODO: Move reference dialog handling to view
1681 // Just keep function autopilot here for references to other documents
1682 bool bIsFormula
= false;
1686 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1689 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1691 bIsFormula
= pChildWnd
->IsVisible() && pRefDlg
&& pRefDlg
->IsRefInputMode();
1698 ScInputHandler
* pHdl
= GetInputHdl();
1700 bIsFormula
= pHdl
->IsFormulaMode();
1703 if (bIsInEditCommand
)
1709 static void lcl_MarkedTabs( const ScMarkData
& rMark
, SCTAB
& rStartTab
, SCTAB
& rEndTab
)
1711 if (rMark
.GetSelectCount() > 1)
1713 rEndTab
= rMark
.GetLastSelected();
1714 rStartTab
= rMark
.GetFirstSelected();
1718 void ScModule::SetReference( const ScRange
& rRef
, ScDocument
* pDoc
,
1719 const ScMarkData
* pMarkData
)
1721 //TODO: Move reference dialog handling to view
1722 // Just keep function autopilot here for references to other documents
1724 // In RefDialogs we also trigger the ZoomIn, if the Ref's Start and End are different
1725 ScRange aNew
= rRef
;
1726 aNew
.Justify(); // Always in the right direction
1730 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1731 OSL_ENSURE( pChildWnd
, "NoChildWin" );
1734 if ( nCurRefDlgId
== SID_OPENDLG_CONSOLIDATE
&& pMarkData
)
1736 SCTAB nStartTab
= aNew
.aStart
.Tab();
1737 SCTAB nEndTab
= aNew
.aEnd
.Tab();
1738 lcl_MarkedTabs( *pMarkData
, nStartTab
, nEndTab
);
1739 aNew
.aStart
.SetTab(nStartTab
);
1740 aNew
.aEnd
.SetTab(nEndTab
);
1743 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1747 // hide the (color) selection now instead of later from LoseFocus,
1748 // don't abort the ref input that causes this call (bDoneRefMode = sal_False)
1749 pRefDlg
->HideReference( false );
1750 pRefDlg
->SetReference( aNew
, pDoc
);
1756 ScInputHandler
* pHdl
= GetInputHdl();
1758 pHdl
->SetReference( aNew
, pDoc
);
1761 OSL_FAIL("SetReference without receiver");
1769 void ScModule::AddRefEntry()
1771 //TODO: Move reference dialog handling to view
1772 // Just keep function autopilot here for references to other documents
1775 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1776 OSL_ENSURE( pChildWnd
, "NoChildWin" );
1779 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1783 pRefDlg
->AddRefEntry();
1789 ScInputHandler
* pHdl
= GetInputHdl();
1791 pHdl
->AddRefEntry();
1795 void ScModule::EndReference()
1797 //TODO: Move reference dialog handling to view
1798 // Just keep function autopilot here for references to other documents
1800 // We also annul the ZoomIn again in RefDialogs
1802 //FIXME: ShowRefFrame at InputHdl, if the Function AutoPilot is open?
1805 SfxChildWindow
* pChildWnd
= lcl_GetChildWinFromAnyView( nCurRefDlgId
);
1806 OSL_ENSURE( pChildWnd
, "NoChildWin" );
1809 IAnyRefDialog
* pRefDlg
= dynamic_cast<IAnyRefDialog
*>(pChildWnd
->GetWindow());
1813 pRefDlg
->SetActive();
1820 * Idle/OnlineSpelling
1822 void ScModule::AnythingChanged()
1824 sal_uLong nOldTime
= aIdleTimer
.GetTimeout();
1825 if ( nOldTime
!= SC_IDLE_MIN
)
1826 aIdleTimer
.SetTimeout( SC_IDLE_MIN
);
1831 static void lcl_CheckNeedsRepaint( ScDocShell
* pDocShell
)
1833 SfxViewFrame
* pFrame
= SfxViewFrame::GetFirst( pDocShell
);
1836 SfxViewShell
* p
= pFrame
->GetViewShell();
1837 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
,p
);
1839 pViewSh
->CheckNeedsRepaint();
1840 pFrame
= SfxViewFrame::GetNext( *pFrame
, pDocShell
);
1844 IMPL_LINK_NOARG_TYPED(ScModule
, IdleHandler
, Timer
*, void)
1846 if ( Application::AnyInput( VCL_INPUT_MOUSEANDKEYBOARD
) )
1848 aIdleTimer
.Start(); // Timeout unchanged
1853 bool bAutoSpell
= false;
1854 ScDocShell
* pDocSh
= dynamic_cast<ScDocShell
*>(SfxObjectShell::Current());
1858 ScDocument
& rDoc
= pDocSh
->GetDocument();
1859 bAutoSpell
= rDoc
.GetDocOptions().IsAutoSpell();
1860 if (pDocSh
->IsReadOnly())
1863 sc::DocumentLinkManager
& rLinkMgr
= rDoc
.GetDocLinkManager();
1864 bool bLinks
= rLinkMgr
.idleCheckLinks();
1865 bool bWidth
= rDoc
.IdleCalcTextWidth();
1867 bMore
= bLinks
|| bWidth
; // Still something at all?
1869 // While calculating a Basic formula, a paint event may have occurred,
1870 // so check the bNeedsRepaint flags for this document's views
1872 lcl_CheckNeedsRepaint( pDocSh
);
1877 ScTabViewShell
* pViewSh
= dynamic_cast<ScTabViewShell
*>(SfxViewShell::Current());
1880 bool bSpell
= pViewSh
->ContinueOnlineSpelling();
1889 sal_uLong nOldTime
= aIdleTimer
.GetTimeout();
1890 sal_uLong nNewTime
= nOldTime
;
1893 nNewTime
= SC_IDLE_MIN
;
1898 // Set SC_IDLE_COUNT to initial Timeout - increase afterwards
1899 if ( nIdleCount
< SC_IDLE_COUNT
)
1903 nNewTime
+= SC_IDLE_STEP
;
1904 if ( nNewTime
> SC_IDLE_MAX
)
1905 nNewTime
= SC_IDLE_MAX
;
1908 if ( nNewTime
!= nOldTime
)
1909 aIdleTimer
.SetTimeout( nNewTime
);
1915 IMPL_LINK_NOARG_TYPED(ScModule
, SpellTimerHdl
, Idle
*, void)
1917 if ( Application::AnyInput( VclInputFlags::KEYBOARD
) )
1920 return; // Later again ...
1923 ScTabViewShell
* pViewSh
= dynamic_cast<ScTabViewShell
*>(SfxViewShell::Current());
1926 if (pViewSh
->ContinueOnlineSpelling())
1932 * Virtual methods for the OptionsDialog
1934 SfxItemSet
* ScModule::CreateItemSet( sal_uInt16 nId
)
1936 SfxItemSet
* pRet
= 0;
1937 if(SID_SC_EDITOPTIONS
== nId
)
1939 pRet
= new SfxItemSet( GetPool(),
1941 SID_SCDOCOPTIONS
, SID_SCDOCOPTIONS
,
1943 SID_SCVIEWOPTIONS
, SID_SCVIEWOPTIONS
,
1944 SID_SC_OPT_SYNCZOOM
, SID_SC_OPT_SYNCZOOM
,
1946 SID_SC_INPUT_SELECTION
,SID_SC_INPUT_MARK_HEADER
,
1947 SID_SC_INPUT_TEXTWYSIWYG
,SID_SC_INPUT_TEXTWYSIWYG
,
1948 SID_SC_INPUT_REPLCELLSWARN
,SID_SC_INPUT_REPLCELLSWARN
,
1949 SID_SC_INPUT_LEGACY_CELL_SELECTION
,SID_SC_OPT_SORT_REF_UPDATE
,
1951 SCITEM_USERLIST
, SCITEM_USERLIST
,
1953 SID_SCPRINTOPTIONS
, SID_SCPRINTOPTIONS
,
1955 SID_ATTR_GRID_OPTIONS
, SID_ATTR_GRID_OPTIONS
,
1957 SID_ATTR_METRIC
, SID_ATTR_METRIC
,
1958 SID_ATTR_DEFTABSTOP
, SID_ATTR_DEFTABSTOP
,
1960 SID_SC_OPT_KEY_BINDING_COMPAT
, SID_SC_OPT_KEY_BINDING_COMPAT
,
1962 SID_SCDEFAULTSOPTIONS
, SID_SCDEFAULTSOPTIONS
,
1964 SID_SCFORMULAOPTIONS
, SID_SCFORMULAOPTIONS
,
1967 const ScAppOptions
& rAppOpt
= GetAppOptions();
1969 ScDocShell
* pDocSh
= PTR_CAST(ScDocShell
,
1970 SfxObjectShell::Current());
1971 ScDocOptions aCalcOpt
= pDocSh
1972 ? pDocSh
->GetDocument().GetDocOptions()
1975 ScTabViewShell
* pViewSh
= PTR_CAST(ScTabViewShell
,
1976 SfxViewShell::Current());
1977 ScViewOptions aViewOpt
= pViewSh
1978 ? pViewSh
->GetViewData().GetOptions()
1981 ScUserListItem
aULItem( SCITEM_USERLIST
);
1982 ScUserList
* pUL
= ScGlobal::GetUserList();
1984 // SfxGetpApp()->GetOptions( aSet );
1986 pRet
->Put( SfxUInt16Item( SID_ATTR_METRIC
,
1987 sal::static_int_cast
<sal_uInt16
>(rAppOpt
.GetAppMetric()) ) );
1990 pRet
->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP
,
1991 aCalcOpt
.GetTabDistance()));
1992 pRet
->Put( ScTpCalcItem( SID_SCDOCOPTIONS
, aCalcOpt
) );
1995 pRet
->Put( ScTpViewItem( SID_SCVIEWOPTIONS
, aViewOpt
) );
1996 pRet
->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM
, rAppOpt
.GetSynchronizeZoom() ) );
1999 const ScInputOptions
& rInpOpt
= GetInputOptions();
2000 pRet
->Put( SfxUInt16Item( SID_SC_INPUT_SELECTIONPOS
,
2001 rInpOpt
.GetMoveDir() ) );
2002 pRet
->Put( SfxBoolItem( SID_SC_INPUT_SELECTION
,
2003 rInpOpt
.GetMoveSelection() ) );
2004 pRet
->Put( SfxBoolItem( SID_SC_INPUT_EDITMODE
,
2005 rInpOpt
.GetEnterEdit() ) );
2006 pRet
->Put( SfxBoolItem( SID_SC_INPUT_FMT_EXPAND
,
2007 rInpOpt
.GetExtendFormat() ) );
2008 pRet
->Put( SfxBoolItem( SID_SC_INPUT_RANGEFINDER
,
2009 rInpOpt
.GetRangeFinder() ) );
2010 pRet
->Put( SfxBoolItem( SID_SC_INPUT_REF_EXPAND
,
2011 rInpOpt
.GetExpandRefs() ) );
2012 pRet
->Put( SfxBoolItem(SID_SC_OPT_SORT_REF_UPDATE
, rInpOpt
.GetSortRefUpdate()));
2013 pRet
->Put( SfxBoolItem( SID_SC_INPUT_MARK_HEADER
,
2014 rInpOpt
.GetMarkHeader() ) );
2015 pRet
->Put( SfxBoolItem( SID_SC_INPUT_TEXTWYSIWYG
,
2016 rInpOpt
.GetTextWysiwyg() ) );
2017 pRet
->Put( SfxBoolItem( SID_SC_INPUT_REPLCELLSWARN
,
2018 rInpOpt
.GetReplaceCellsWarn() ) );
2019 pRet
->Put( SfxBoolItem( SID_SC_INPUT_LEGACY_CELL_SELECTION
,
2020 rInpOpt
.GetLegacyCellSelection() ) );
2023 pRet
->Put( ScTpPrintItem( SID_SCPRINTOPTIONS
, GetPrintOptions() ) );
2026 SvxGridItem
* pSvxGridItem
= aViewOpt
.CreateGridItem();
2027 pRet
->Put( *pSvxGridItem
);
2028 delete pSvxGridItem
;
2033 aULItem
.SetUserList( *pUL
);
2038 pRet
->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT
,
2039 rAppOpt
.GetKeyBindingType() ) );
2042 pRet
->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS
, GetDefaultsOptions() ) );
2045 ScFormulaOptions aOptions
= GetFormulaOptions();
2048 ScCalcConfig
aConfig( aOptions
.GetCalcConfig());
2049 aConfig
.MergeDocumentSpecific( pDocSh
->GetDocument().GetCalcConfig());
2050 aOptions
.SetCalcConfig( aConfig
);
2052 pRet
->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS
, aOptions
) );
2057 void ScModule::ApplyItemSet( sal_uInt16 nId
, const SfxItemSet
& rSet
)
2059 if(SID_SC_EDITOPTIONS
== nId
)
2061 ModifyOptions( rSet
);
2065 VclPtr
<SfxTabPage
> ScModule::CreateTabPage( sal_uInt16 nId
, vcl::Window
* pParent
, const SfxItemSet
& rSet
)
2067 VclPtr
<SfxTabPage
> pRet
;
2068 ScAbstractDialogFactory
* pFact
= ScAbstractDialogFactory::Create();
2069 OSL_ENSURE(pFact
, "ScAbstractFactory create fail!");
2072 case SID_SC_TP_LAYOUT
:
2074 ::CreateTabPage ScTpLayoutOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_LAYOUT
);
2075 if ( ScTpLayoutOptionsCreate
)
2076 pRet
= (*ScTpLayoutOptionsCreate
) (pParent
, &rSet
);
2079 case SID_SC_TP_CONTENT
:
2081 ::CreateTabPage ScTpContentOptionsCreate
= pFact
->GetTabPageCreatorFunc(RID_SCPAGE_CONTENT
);
2082 if ( ScTpContentOptionsCreate
)
2083 pRet
= (*ScTpContentOptionsCreate
)(pParent
, &rSet
);
2086 case SID_SC_TP_GRID
: pRet
= SvxGridTabPage::Create(pParent
, rSet
); break;
2087 case SID_SC_TP_USERLISTS
:
2089 ::CreateTabPage ScTpUserListsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_USERLISTS
);
2090 if ( ScTpUserListsCreate
)
2091 pRet
= (*ScTpUserListsCreate
)( pParent
, &rSet
);
2094 case SID_SC_TP_CALC
:
2096 ::CreateTabPage ScTpCalcOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_CALC
);
2097 if ( ScTpCalcOptionsCreate
)
2098 pRet
= (*ScTpCalcOptionsCreate
)(pParent
, &rSet
);
2101 case SID_SC_TP_FORMULA
:
2103 ::CreateTabPage ScTpFormulaOptionsCreate
= pFact
->GetTabPageCreatorFunc (RID_SCPAGE_FORMULA
);
2104 if (ScTpFormulaOptionsCreate
)
2105 pRet
= (*ScTpFormulaOptionsCreate
)(pParent
, &rSet
);
2108 case SID_SC_TP_COMPATIBILITY
:
2110 ::CreateTabPage ScTpCompatOptionsCreate
= pFact
->GetTabPageCreatorFunc (RID_SCPAGE_COMPATIBILITY
);
2111 if (ScTpCompatOptionsCreate
)
2112 pRet
= (*ScTpCompatOptionsCreate
)(pParent
, &rSet
);
2115 case SID_SC_TP_CHANGES
:
2117 ::CreateTabPage ScRedlineOptionsTabPageCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_OPREDLINE
);
2118 if ( ScRedlineOptionsTabPageCreate
)
2119 pRet
=(*ScRedlineOptionsTabPageCreate
)(pParent
, &rSet
);
2122 case RID_SC_TP_PRINT
:
2124 ::CreateTabPage ScTpPrintOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_PRINT
);
2125 if ( ScTpPrintOptionsCreate
)
2126 pRet
= (*ScTpPrintOptionsCreate
)( pParent
, &rSet
);
2129 case RID_SC_TP_DEFAULTS
:
2131 ::CreateTabPage ScTpDefaultsOptionsCreate
= pFact
->GetTabPageCreatorFunc( RID_SCPAGE_DEFAULTS
);
2132 if ( ScTpDefaultsOptionsCreate
)
2133 pRet
= (*ScTpDefaultsOptionsCreate
)( pParent
, &rSet
);
2138 OSL_ENSURE( pRet
, "ScModule::CreateTabPage(): no valid ID for TabPage!" );
2143 IMPL_LINK( ScModule
, CalcFieldValueHdl
, EditFieldInfo
*, pInfo
)
2145 //TODO: Merge with ScFieldEditEngine!
2148 const SvxFieldItem
& rField
= pInfo
->GetField();
2149 const SvxFieldData
* pField
= rField
.GetField();
2151 if (pField
&& pField
->ISA(SvxURLField
))
2154 const SvxURLField
* pURLField
= static_cast<const SvxURLField
*>(pField
);
2155 OUString aURL
= pURLField
->GetURL();
2157 switch ( pURLField
->GetFormat() )
2159 case SVXURLFORMAT_APPDEFAULT
: //TODO: Settable in the App?
2160 case SVXURLFORMAT_REPR
:
2162 pInfo
->SetRepresentation( pURLField
->GetRepresentation() );
2166 case SVXURLFORMAT_URL
:
2168 pInfo
->SetRepresentation( aURL
);
2173 svtools::ColorConfigEntry eEntry
=
2174 INetURLHistory::GetOrCreate()->QueryUrl( aURL
) ? svtools::LINKSVISITED
: svtools::LINKS
;
2175 pInfo
->SetTextColor( GetColorConfig().GetColorValue(eEntry
).nColor
);
2179 OSL_FAIL("Unknown Field");
2180 pInfo
->SetRepresentation(OUString('?'));
2187 bool ScModule::RegisterRefWindow( sal_uInt16 nSlotId
, vcl::Window
*pWnd
)
2189 std::list
<VclPtr
<vcl::Window
> > & rlRefWindow
= m_mapRefWindow
[nSlotId
];
2191 if( std::find( rlRefWindow
.begin(), rlRefWindow
.end(), pWnd
) == rlRefWindow
.end() )
2193 rlRefWindow
.push_back( pWnd
);
2200 bool ScModule::UnregisterRefWindow( sal_uInt16 nSlotId
, vcl::Window
*pWnd
)
2202 auto iSlot
= m_mapRefWindow
.find( nSlotId
);
2204 if( iSlot
== m_mapRefWindow
.end() )
2207 std::list
<VclPtr
<vcl::Window
> > & rlRefWindow
= iSlot
->second
;
2209 auto i
= std::find( rlRefWindow
.begin(), rlRefWindow
.end(), pWnd
);
2211 if( i
== rlRefWindow
.end() )
2214 rlRefWindow
.erase( i
);
2216 if( rlRefWindow
.empty() )
2217 m_mapRefWindow
.erase( nSlotId
);
2222 vcl::Window
* ScModule::Find1RefWindow( sal_uInt16 nSlotId
, vcl::Window
*pWndAncestor
)
2227 auto iSlot
= m_mapRefWindow
.find( nSlotId
);
2229 if( iSlot
== m_mapRefWindow
.end() )
2232 std::list
<VclPtr
<vcl::Window
> > & rlRefWindow
= iSlot
->second
;
2234 while( vcl::Window
*pParent
= pWndAncestor
->GetParent() ) pWndAncestor
= pParent
;
2236 for( auto i
= rlRefWindow
.begin(); i
!=rlRefWindow
.end(); ++i
)
2237 if ( pWndAncestor
->IsWindowOrChild( *i
, (*i
)->IsSystemWindow() ) )
2243 using namespace com::sun::star
;
2245 #define LINGUPROP_AUTOSPELL "IsSpellAuto"
2247 void ScModule::GetSpellSettings( sal_uInt16
& rDefLang
, sal_uInt16
& rCjkLang
, sal_uInt16
& rCtlLang
,
2250 // use SvtLinguConfig instead of service LinguProperties to avoid
2251 // loading the linguistic component
2252 SvtLinguConfig aConfig
;
2254 SvtLinguOptions aOptions
;
2255 aConfig
.GetOptions( aOptions
);
2257 rDefLang
= MsLangId::resolveSystemLanguageByScriptType(aOptions
.nDefaultLanguage
, ::com::sun::star::i18n::ScriptType::LATIN
);
2258 rCjkLang
= MsLangId::resolveSystemLanguageByScriptType(aOptions
.nDefaultLanguage_CJK
, ::com::sun::star::i18n::ScriptType::ASIAN
);
2259 rCtlLang
= MsLangId::resolveSystemLanguageByScriptType(aOptions
.nDefaultLanguage_CTL
, ::com::sun::star::i18n::ScriptType::COMPLEX
);
2260 rAutoSpell
= aOptions
.bIsSpellAuto
;
2263 void ScModule::SetAutoSpellProperty( bool bSet
)
2265 // use SvtLinguConfig instead of service LinguProperties to avoid
2266 // loading the linguistic component
2267 SvtLinguConfig aConfig
;
2271 aConfig
.SetProperty( OUString( LINGUPROP_AUTOSPELL
), aAny
);
2274 bool ScModule::HasThesaurusLanguage( sal_uInt16 nLang
)
2276 if ( nLang
== LANGUAGE_NONE
)
2279 bool bHasLang
= false;
2282 uno::Reference
< linguistic2::XThesaurus
> xThes(LinguMgr::GetThesaurus());
2284 bHasLang
= xThes
->hasLocale( LanguageTag::convertToLocale( nLang
) );
2286 catch( uno::Exception
& )
2288 OSL_FAIL("Error in Thesaurus");
2294 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */