Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_DOCSH_HXX
22 :
23 : #include <sfx2/objsh.hxx>
24 :
25 : #include <sfx2/docfac.hxx>
26 : #include <sfx2/sfxmodelfactory.hxx>
27 : #include <sfx2/viewsh.hxx>
28 :
29 : #include "scdllapi.h"
30 : #include "scdll.hxx"
31 : #include "document.hxx"
32 : #include "appoptio.hxx"
33 : #include "formulaopt.hxx"
34 : #include "shellids.hxx"
35 : #include "optutil.hxx"
36 : #include "docuno.hxx"
37 :
38 : #include <boost/unordered_map.hpp>
39 : #include <boost/scoped_ptr.hpp>
40 : #include <cppuhelper/implbase1.hxx>
41 :
42 : #include <config_telepathy.h>
43 :
44 : class ScRefreshTimerProtector;
45 : class ScEditEngineDefaulter;
46 : class SfxStyleSheetBasePool;
47 : class SfxStyleSheetHint;
48 : class INetURLObject;
49 :
50 : class ScViewData;
51 : class ScDocFunc;
52 : class ScDrawLayer;
53 : class ScTabViewShell;
54 : class ScSbxDocHelper;
55 : class ScAutoStyleList;
56 : class ScRange;
57 : class ScMarkData;
58 : class ScPaintLockData;
59 : class ScChangeAction;
60 : class VirtualDevice;
61 : class ScImportOptions;
62 : class ScDocShellModificator;
63 : class ScOptSolverSave;
64 : class ScRefreshTimer;
65 : class ScSheetSaveData;
66 : class ScFlatBoolRowSegments;
67 : class HelperModelObj;
68 : struct ScColWidthParam;
69 : #if ENABLE_TELEPATHY
70 : class ScCollaboration;
71 : #endif
72 :
73 : namespace sfx2 { class FileDialogHelper; }
74 : struct DocShell_Impl;
75 :
76 : typedef ::boost::unordered_map< sal_uLong, sal_uLong > ScChangeActionMergeMap;
77 :
78 : //enum ScDBFormat { SC_FORMAT_SDF, SC_FORMAT_DBF };
79 :
80 : // Extra flags for Repaint
81 : #define SC_PF_LINES 1
82 : #define SC_PF_TESTMERGE 2
83 : #define SC_PF_WHOLEROWS 4
84 :
85 : class SC_DLLPUBLIC ScDocShell: public SfxObjectShell, public SfxListener
86 : {
87 : ScDocument aDocument;
88 :
89 : OUString aDdeTextFmt;
90 :
91 : double nPrtToScreenFactor;
92 : DocShell_Impl* pImpl;
93 : ScDocFunc* pDocFunc;
94 :
95 : bool bHeaderOn;
96 : bool bFooterOn;
97 : bool bIsInplace:1; // Is set by the View
98 : bool bIsEmpty:1;
99 : bool bIsInUndo:1;
100 : bool bDocumentModifiedPending:1;
101 : bool bUpdateEnabled:1;
102 : sal_uInt16 nDocumentLock;
103 : sal_Int16 nCanUpdate; // stores the UpdateDocMode from loading a document till update links
104 :
105 : ScDBData* pOldAutoDBRange;
106 :
107 : ScSbxDocHelper* pDocHelper;
108 :
109 : ScAutoStyleList* pAutoStyleList;
110 : ScPaintLockData* pPaintLockData;
111 : ScOptSolverSave* pSolverSaveData;
112 : ScSheetSaveData* pSheetSaveData;
113 :
114 : ScDocShellModificator* pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading)
115 : #if ENABLE_TELEPATHY
116 : ScCollaboration* mpCollaboration;
117 : #endif
118 :
119 : SAL_DLLPRIVATE void InitItems();
120 : SAL_DLLPRIVATE void DoEnterHandler();
121 : SAL_DLLPRIVATE void InitOptions(bool bForLoading);
122 : SAL_DLLPRIVATE void ResetDrawObjectShell();
123 :
124 : // SUNWS needs a forward declared friend, otherwise types and members
125 : // of the outer class are not accessible.
126 : class PrepareSaveGuard;
127 : friend class ScDocShell::PrepareSaveGuard;
128 : /** Do things that need to be done before saving to our own format and
129 : necessary clean ups in dtor. */
130 : class PrepareSaveGuard
131 : {
132 : public:
133 : explicit PrepareSaveGuard( ScDocShell & rDocShell );
134 : ~PrepareSaveGuard();
135 : private:
136 : ScDocShell & mrDocShell;
137 : };
138 :
139 : SAL_DLLPRIVATE bool LoadXML( SfxMedium* pMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& );
140 : SAL_DLLPRIVATE bool SaveXML( SfxMedium* pMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& );
141 : SAL_DLLPRIVATE SCTAB GetSaveTab();
142 :
143 : SAL_DLLPRIVATE bool SaveCurrentChart( SfxMedium& rMedium );
144 :
145 : SAL_DLLPRIVATE sal_uLong DBaseImport( const OUString& rFullFileName, rtl_TextEncoding eCharSet,
146 : ScColWidthParam aColWidthParam[MAXCOLCOUNT], ScFlatBoolRowSegments& rRowHeightsRecalc );
147 : SAL_DLLPRIVATE sal_uLong DBaseExport(
148 : const OUString& rFullFileName, rtl_TextEncoding eCharSet, bool& bHasMemo );
149 :
150 : SAL_DLLPRIVATE static bool MoveFile( const INetURLObject& rSource, const INetURLObject& rDest );
151 : SAL_DLLPRIVATE static bool KillFile( const INetURLObject& rURL );
152 : SAL_DLLPRIVATE static bool IsDocument( const INetURLObject& rURL );
153 :
154 : SAL_DLLPRIVATE void LockPaint_Impl(bool bDoc);
155 : SAL_DLLPRIVATE void UnlockPaint_Impl(bool bDoc);
156 : SAL_DLLPRIVATE void LockDocument_Impl(sal_uInt16 nNew);
157 : SAL_DLLPRIVATE void UnlockDocument_Impl(sal_uInt16 nNew);
158 :
159 : SAL_DLLPRIVATE void EnableSharedSettings( bool bEnable );
160 : SAL_DLLPRIVATE ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > LoadSharedDocument();
161 :
162 : SAL_DLLPRIVATE void UseSheetSaveEntries();
163 :
164 : SAL_DLLPRIVATE ScDocFunc *CreateDocFunc();
165 :
166 : protected:
167 :
168 : virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) SAL_OVERRIDE;
169 :
170 : public:
171 : TYPEINFO_OVERRIDE();
172 76 : SFX_DECL_INTERFACE(SCID_DOC_SHELL)
173 229401 : SFX_DECL_OBJECTFACTORY();
174 :
175 : private:
176 : /// SfxInterface initializer.
177 : static void InitInterface_Impl();
178 :
179 : public:
180 : ScDocShell( const ScDocShell& rDocShell );
181 : ScDocShell( const sal_uInt64 i_nSfxCreationFlags = SFXMODEL_EMBEDDED_OBJECT );
182 : virtual ~ScDocShell();
183 :
184 : using SotObject::GetInterface;
185 : using SfxShell::Activate; // with sal_Bool bMDI
186 : using SfxShell::Deactivate; // with sal_Bool bMDI
187 :
188 : #if ENABLE_TELEPATHY
189 : SAL_DLLPRIVATE ScCollaboration* GetCollaboration();
190 : #endif
191 : virtual void Activate();
192 : virtual void Deactivate();
193 :
194 : virtual ::svl::IUndoManager*
195 : GetUndoManager() SAL_OVERRIDE;
196 :
197 : virtual void FillClass( SvGlobalName * pClassName,
198 : sal_uInt32 * pFormat,
199 : OUString * pAppName,
200 : OUString * pFullTypeName,
201 : OUString * pShortTypeName,
202 : sal_Int32 nFileFormat,
203 : bool bTemplate = false ) const SAL_OVERRIDE;
204 :
205 : virtual std::vector<Color> GetDocColors() SAL_OVERRIDE;
206 :
207 : virtual bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ) SAL_OVERRIDE;
208 : virtual bool Load( SfxMedium& rMedium ) SAL_OVERRIDE;
209 : virtual bool LoadFrom( SfxMedium& rMedium ) SAL_OVERRIDE;
210 : virtual bool ConvertFrom( SfxMedium &rMedium ) SAL_OVERRIDE;
211 : virtual bool LoadExternal( SfxMedium& rMedium ) SAL_OVERRIDE;
212 : virtual bool Save() SAL_OVERRIDE;
213 : virtual bool SaveAs( SfxMedium& rMedium ) SAL_OVERRIDE;
214 : virtual bool ConvertTo( SfxMedium &rMedium ) SAL_OVERRIDE;
215 : virtual bool PrepareClose( bool bUI = true ) SAL_OVERRIDE;
216 : virtual void PrepareReload() SAL_OVERRIDE;
217 : virtual bool IsInformationLost() SAL_OVERRIDE;
218 : virtual void LoadStyles( SfxObjectShell &rSource ) SAL_OVERRIDE;
219 :
220 : virtual bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ) SAL_OVERRIDE; // SfxInPlaceObject
221 : virtual bool DoSaveCompleted( SfxMedium * pNewStor) SAL_OVERRIDE; // SfxObjectShell
222 : virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ) SAL_OVERRIDE;
223 :
224 : virtual void Draw( OutputDevice *, const JobSetup & rSetup,
225 : sal_uInt16 nAspect = ASPECT_CONTENT ) SAL_OVERRIDE;
226 :
227 : virtual void SetVisArea( const Rectangle & rVisArea ) SAL_OVERRIDE;
228 :
229 : using SfxObjectShell::GetVisArea;
230 : virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const SAL_OVERRIDE;
231 :
232 : virtual Printer* GetDocumentPrinter() SAL_OVERRIDE;
233 :
234 : virtual void SetModified( bool = true ) SAL_OVERRIDE;
235 :
236 : void SetVisAreaOrSize( const Rectangle& rVisArea, bool bModifyStart );
237 :
238 : virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog( vcl::Window *pParent,
239 : const SfxItemSet &rSet ) SAL_OVERRIDE;
240 :
241 : void GetDocStat( ScDocStat& rDocStat );
242 :
243 891775 : ScDocument& GetDocument() { return aDocument; }
244 36942 : ScDocFunc& GetDocFunc() { return *pDocFunc; }
245 : void SetDocFunc( ScDocFunc *pDF ) { pDocFunc = pDF; }
246 :
247 : SfxPrinter* GetPrinter( bool bCreateIfNotExist = true );
248 : sal_uInt16 SetPrinter( SfxPrinter* pNewPrinter, sal_uInt16 nDiffFlags = SFX_PRINTER_ALL );
249 :
250 : void UpdateFontList();
251 :
252 : OUString CreateObjectName( const OUString& rPrefix );
253 :
254 : ScDrawLayer* MakeDrawLayer();
255 :
256 : void AsciiSave( SvStream& rStream, const ScImportOptions& rOpt );
257 :
258 : void GetSbxState( SfxItemSet &rSet );
259 : void GetDrawObjState( SfxItemSet &rSet );
260 :
261 : void Execute( SfxRequest& rReq );
262 : void GetState( SfxItemSet &rSet );
263 : void ExecutePageStyle ( SfxViewShell& rCaller, SfxRequest& rReq, SCTAB nCurTab );
264 : void GetStatePageStyle( SfxViewShell& rCaller, SfxItemSet& rSet, SCTAB nCurTab );
265 :
266 : void CompareDocument( ScDocument& rOtherDoc );
267 : void MergeDocument( ScDocument& rOtherDoc, bool bShared = false, bool bCheckDuplicates = false, sal_uLong nOffset = 0, ScChangeActionMergeMap* pMergeMap = NULL, bool bInverseMap = false );
268 : bool MergeSharedDocument( ScDocShell* pSharedDocShell );
269 :
270 : ScChangeAction* GetChangeAction( const ScAddress& rPos );
271 : void SetChangeComment( ScChangeAction* pAction, const OUString& rComment );
272 : void ExecuteChangeCommentDialog( ScChangeAction* pAction, vcl::Window* pParent, bool bPrevNext = true );
273 : /// Protect/unprotect ChangeTrack and return <TRUE/> if
274 : /// protection was successfully changed.
275 : /// If bJustQueryIfProtected==sal_True protection is not
276 : /// changed and <TRUE/> is returned if not protected or
277 : /// password was entered correctly.
278 : bool ExecuteChangeProtectionDialog( vcl::Window* _pParent, bool bJustQueryIfProtected = false );
279 :
280 : void SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages );
281 : bool AdjustPrintZoom( const ScRange& rRange );
282 :
283 : void LoadStylesArgs( ScDocShell& rSource, bool bReplace, bool bCellStyles, bool bPageStyles );
284 :
285 : void PageStyleModified( const OUString& rStyleName, bool bApi );
286 :
287 : void NotifyStyle( const SfxStyleSheetHint& rHint );
288 : void DoAutoStyle( const ScRange& rRange, const OUString& rStyle );
289 :
290 : vcl::Window* GetActiveDialogParent();
291 : void ErrorMessage( sal_uInt16 nGlobStrId );
292 : bool IsEditable() const;
293 :
294 : bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab );
295 : void UpdateAllRowHeights( const ScMarkData* pTabMark = NULL );
296 : void UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore = false );
297 :
298 : void RefreshPivotTables( const ScRange& rSource );
299 : void DoConsolidate( const ScConsolidateParam& rParam, bool bRecord = true );
300 : void UseScenario( SCTAB nTab, const OUString& rName, bool bRecord = true );
301 : SCTAB MakeScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
302 : const Color& rColor, sal_uInt16 nFlags,
303 : ScMarkData& rMark, bool bRecord = true );
304 : void ModifyScenario( SCTAB nTab, const OUString& rName, const OUString& rComment,
305 : const Color& rColor, sal_uInt16 nFlags );
306 : sal_uLong TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos,
307 : SCTAB nDestPos, bool bInsertNew,
308 : bool bNotifyAndPaint );
309 :
310 : bool MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord );
311 :
312 : void DoRecalc( bool bApi );
313 : void DoHardRecalc( bool bApi );
314 :
315 : void UpdateOle( const ScViewData* pViewData, bool bSnapSize = false);
316 : bool IsOle();
317 :
318 : void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2 );
319 : ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel );
320 : ScDBData* GetAnonymousDBData(const ScRange& rRange);
321 : ScDBData* GetOldAutoDBRange(); // has to be deleted by caller!
322 : void CancelAutoDBRange(); // called when dialog is cancelled
323 :
324 : virtual void ReconnectDdeLink(SfxObjectShell& rServer) SAL_OVERRIDE;
325 : void UpdateLinks() SAL_OVERRIDE;
326 : bool ReloadTabLinks();
327 :
328 : void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false );
329 : void SetCalcConfig( const ScCalcConfig& rConfig );
330 : virtual void CheckConfigOptions() SAL_OVERRIDE;
331 :
332 : void PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos );
333 :
334 : void PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
335 : SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, sal_uInt16 nPart,
336 : sal_uInt16 nExtFlags = 0 );
337 : void PostPaint( const ScRangeList& rRanges, sal_uInt16 nPart, sal_uInt16 nExtFlags = 0 );
338 :
339 : void PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab );
340 : void PostPaintCell( const ScAddress& rPos );
341 : void PostPaintGridAll();
342 : void PostPaintExtras();
343 :
344 82 : bool IsPaintLocked() const { return pPaintLockData != NULL; }
345 :
346 : void PostDataChanged();
347 :
348 : void UpdatePaintExt( sal_uInt16& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab,
349 : SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab );
350 : void UpdatePaintExt( sal_uInt16& rExtFlags, const ScRange& rRange );
351 :
352 : void SetDocumentModified( bool bIsModified = true );
353 : void SetDrawModified( bool bIsModified = true );
354 :
355 : void LockPaint();
356 : void UnlockPaint();
357 8 : sal_uInt16 GetLockCount() const { return nDocumentLock;}
358 : void SetLockCount(sal_uInt16 nNew);
359 :
360 : void LockDocument();
361 : void UnlockDocument();
362 :
363 : DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper* );
364 :
365 : virtual SfxStyleSheetBasePool* GetStyleSheetPool() SAL_OVERRIDE;
366 :
367 : void SetInplace( bool bInplace );
368 564 : bool IsEmpty() const { return bIsEmpty; }
369 : void SetEmpty(bool bSet);
370 :
371 8 : bool IsInUndo() const { return bIsInUndo; }
372 : void SetInUndo(bool bSet);
373 :
374 : void CalcOutputFactor();
375 6277 : double GetOutputFactor() const { return nPrtToScreenFactor;}
376 : void GetPageOnFromPageStyleSet( const SfxItemSet* pStyleSet,
377 : SCTAB nCurTab,
378 : bool& rbHeader,
379 : bool& rbFooter );
380 :
381 : virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType,
382 : ::com::sun::star::uno::Any & rValue ) SAL_OVERRIDE;
383 : virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType,
384 : const ::com::sun::star::uno::Any & rValue ) SAL_OVERRIDE;
385 : virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) SAL_OVERRIDE;
386 :
387 10 : const OUString& GetDdeTextFmt() const { return aDdeTextFmt; }
388 :
389 : SfxBindings* GetViewBindings();
390 :
391 : ScTabViewShell* GetBestViewShell( bool bOnlyVisible = true );
392 : ScSbxDocHelper* GetDocHelperObject() { return pDocHelper; }
393 :
394 15866 : void SetDocumentModifiedPending( bool bVal )
395 15866 : { bDocumentModifiedPending = bVal; }
396 21390 : bool IsDocumentModifiedPending() const
397 21390 : { return bDocumentModifiedPending; }
398 :
399 544 : bool IsUpdateEnabled() const
400 544 : { return bUpdateEnabled; }
401 546 : void SetUpdateEnabled(bool bValue)
402 546 : { bUpdateEnabled = bValue; }
403 :
404 : OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice...
405 :
406 : static ScViewData* GetViewData();
407 : static SCTAB GetCurTab();
408 :
409 : static ScDocShell* GetShellByNum( sal_uInt16 nDocNo );
410 : static OUString GetOwnFilterName();
411 : static OUString GetHtmlFilterName();
412 : static OUString GetWebQueryFilterName();
413 : static OUString GetAsciiFilterName();
414 : static OUString GetLotusFilterName();
415 : static OUString GetDBaseFilterName();
416 : static OUString GetDifFilterName();
417 : static bool HasAutomaticTableName( const OUString& rFilter );
418 :
419 : DECL_LINK( RefreshDBDataHdl, ScRefreshTimer* );
420 :
421 : void BeforeXMLLoading();
422 : void AfterXMLLoading(bool bRet);
423 :
424 : virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates ) SAL_OVERRIDE;
425 :
426 0 : const ScOptSolverSave* GetSolverSaveData() const { return pSolverSaveData; } // may be null
427 : void SetSolverSaveData( const ScOptSolverSave& rData );
428 : ScSheetSaveData* GetSheetSaveData();
429 :
430 : void ResetKeyBindings( ScOptionsUtil::KeyBindingType eType );
431 :
432 : // password protection for Calc (derived from SfxObjectShell)
433 : // see also: FID_CHG_RECORD, SID_CHG_PROTECT
434 : virtual bool IsChangeRecording() const SAL_OVERRIDE;
435 : virtual bool HasChangeRecordProtection() const SAL_OVERRIDE;
436 : virtual void SetChangeRecording( bool bActivate ) SAL_OVERRIDE;
437 : virtual bool SetProtectionPassword( const OUString &rPassword ) SAL_OVERRIDE;
438 : virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ) SAL_OVERRIDE;
439 :
440 : void SnapVisArea( Rectangle& rRect ) const;
441 : };
442 :
443 : void UpdateAcceptChangesDialog();
444 :
445 : class ScDocShell;
446 : typedef tools::SvRef<ScDocShell> ScDocShellRef;
447 :
448 : /** Create before modifications of the document and destroy thereafter.
449 : Call SetDocumentModified() at an instance of this class instead of at
450 : ScDocShell.
451 :
452 : Remembers in the ctor ScDocument's AutoCalcShellDisabled and IdleDisabled,
453 : switches them off and restores them in the dtor, AutoCalcShellDisabled
454 : also before a ScDocShell::SetDocumentModified() call if necessary.
455 : In the dtor, if ScDocShell's bDocumentModifiedPending is set and
456 : bAutoCalcShellDisabled is not set, then ScDocShell::SetDocumentModified()
457 : is called.
458 :
459 : Several instances can be used in nested calls to ScDocFunc or ScDocShell
460 : methods to avoid multiple modified status changes, only the last instance
461 : destroyed calls ScDocShell::SetDocumentModified().
462 : */
463 : class SC_DLLPUBLIC ScDocShellModificator
464 : {
465 : ScDocShell& rDocShell;
466 : boost::scoped_ptr<ScRefreshTimerProtector> mpProtector;
467 : bool bAutoCalcShellDisabled;
468 : bool bIdleEnabled;
469 :
470 : // not implemented
471 : ScDocShellModificator( const ScDocShellModificator& );
472 : ScDocShellModificator& operator=( const ScDocShellModificator& );
473 :
474 : public:
475 : ScDocShellModificator( ScDocShell& );
476 : ~ScDocShellModificator();
477 : void SetDocumentModified();
478 : };
479 :
480 : //#i97876# Spreadsheet data changes are not notified
481 : namespace HelperNotifyChanges
482 : {
483 42 : inline ScModelObj* getMustPropagateChangesModel(ScDocShell &rDocShell)
484 : {
485 42 : ScModelObj* pModelObj = ScModelObj::getImplementation(rDocShell.GetModel());
486 42 : if (pModelObj && pModelObj->HasChangesListeners())
487 0 : return pModelObj;
488 42 : return NULL;
489 : }
490 :
491 0 : inline void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges,
492 : const OUString &rType = OUString("cell-change"),
493 : const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rProperties =
494 : ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >())
495 : {
496 0 : rModelObj.NotifyChanges(rType, rChangeRanges, rProperties);
497 0 : }
498 :
499 10 : inline void NotifyIfChangesListeners(ScDocShell &rDocShell, const ScRange &rRange,
500 : const OUString &rType = OUString("cell-change"))
501 : {
502 10 : if (ScModelObj* pModelObj = getMustPropagateChangesModel(rDocShell))
503 : {
504 0 : ScRangeList aChangeRanges;
505 0 : aChangeRanges.Append(rRange);
506 0 : Notify(*pModelObj, aChangeRanges, rType);
507 : }
508 10 : }
509 : };
510 :
511 : void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const OUString& sModuleName, const OUString& sModuleSource );
512 :
513 : #endif
514 :
515 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|