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