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