/src/libreoffice/sc/source/ui/inc/docsh.hxx
Line | Count | Source |
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 | | #pragma once |
21 | | |
22 | | #include <sfx2/objsh.hxx> |
23 | | #include <unotools/resmgr.hxx> |
24 | | #include <sfx2/docfac.hxx> |
25 | | #include <sfx2/sfxmodelfactory.hxx> |
26 | | #include <sfx2/viewsh.hxx> |
27 | | #include <o3tl/deleter.hxx> |
28 | | #include <comphelper/lok.hxx> |
29 | | #include <comphelper/servicehelper.hxx> |
30 | | |
31 | | #include <scdllapi.h> |
32 | | #include <document.hxx> |
33 | | #include <shellids.hxx> |
34 | | #include <optutil.hxx> |
35 | | #include <docuno.hxx> |
36 | | |
37 | | #include <memory> |
38 | | #include <string_view> |
39 | | #include <unordered_map> |
40 | | #include <map> |
41 | | |
42 | | class ScRefreshTimerProtector; |
43 | | class ScEditEngineDefaulter; |
44 | | class SfxStyleSheetHint; |
45 | | class INetURLObject; |
46 | | |
47 | | class ScViewData; |
48 | | class ScDocFunc; |
49 | | class ScDrawLayer; |
50 | | class ScTabViewShell; |
51 | | class ScAutoStyleList; |
52 | | class ScMarkData; |
53 | | class ScPaintLockData; |
54 | | class ScChangeAction; |
55 | | class ScImportOptions; |
56 | | class ScDocShellModificator; |
57 | | class ScSheetSaveData; |
58 | | class ScFlatBoolRowSegments; |
59 | | struct ScColWidthParam; |
60 | | class ScFormulaOptions; |
61 | | namespace com::sun::star::script::vba { class XVBAScriptListener; } |
62 | | namespace ooo::vba::excel { class XWorkbook; } |
63 | | namespace com::sun::star::datatransfer { class XTransferable2; } |
64 | | namespace sfx2 { class FileDialogHelper; } |
65 | | struct DocShell_Impl; |
66 | | |
67 | | typedef std::unordered_map< sal_uLong, sal_uLong > ScChangeActionMergeMap; |
68 | | |
69 | | //enum ScDBFormat { SC_FORMAT_SDF, SC_FORMAT_DBF }; |
70 | | |
71 | | enum class LOKCommentNotificationType { Add, Modify, Remove }; |
72 | | |
73 | | extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportDBF(SvStream &rStream); |
74 | | |
75 | | // Extra flags for Repaint |
76 | 4.12k | #define SC_PF_LINES 1 |
77 | 3.88k | #define SC_PF_TESTMERGE 2 |
78 | 271 | #define SC_PF_WHOLEROWS 4 |
79 | | |
80 | | class SAL_DLLPUBLIC_RTTI ScDocShell final: public SfxObjectShell, public SfxListener |
81 | | { |
82 | | std::shared_ptr<ScDocument> m_pDocument; |
83 | | |
84 | | OUString m_aDdeTextFmt; |
85 | | |
86 | | double m_nPrtToScreenFactor; |
87 | | std::unique_ptr<DocShell_Impl> m_pImpl; |
88 | | std::unique_ptr<ScDocFunc> m_pDocFunc; |
89 | | |
90 | | bool m_bIsInplace:1; // Is set by the View |
91 | | bool m_bIsEmpty:1; |
92 | | bool m_bIsInUndo:1; |
93 | | bool m_bDocumentModifiedPending:1; |
94 | | bool m_bUpdateEnabled:1; |
95 | | bool m_bAreasChangedNeedBroadcast:1; |
96 | | sal_uInt16 m_nDocumentLock; |
97 | | sal_Int16 m_nCanUpdate; // stores the UpdateDocMode from loading a document till update links |
98 | | |
99 | | std::unique_ptr<ScDBData> m_pOldAutoDBRange; |
100 | | |
101 | | std::unique_ptr<ScAutoStyleList> m_pAutoStyleList; |
102 | | std::unique_ptr<ScPaintLockData> m_pPaintLockData; |
103 | | std::unique_ptr<ScSheetSaveData> m_pSheetSaveData; |
104 | | std::unique_ptr<ScFormatSaveData> m_pFormatSaveData; |
105 | | |
106 | | std::unique_ptr<ScDocShellModificator, o3tl::default_delete<ScDocShellModificator>> m_pModificator; // #109979#; is used to load XML (created in BeforeXMLLoading and destroyed in AfterXMLLoading) |
107 | | |
108 | | css::uno::Reference< ooo::vba::excel::XWorkbook> mxAutomationWorkbookObject; |
109 | | |
110 | | // Only used by Vba helper functions |
111 | | css::uno::Reference<css::script::vba::XVBAScriptListener> m_xVBAListener; |
112 | | css::uno::Reference<css::datatransfer::XTransferable2> m_xClipData; |
113 | | |
114 | | void InitItems(); |
115 | | void DoEnterHandler(); |
116 | | void InitOptions(bool bForLoading); |
117 | | void ResetDrawObjectShell(); |
118 | | |
119 | | /** Do things that need to be done before saving to our own format and |
120 | | necessary clean ups in dtor. */ |
121 | | class PrepareSaveGuard |
122 | | { |
123 | | public: |
124 | | explicit PrepareSaveGuard( ScDocShell & rDocShell ); |
125 | | ~PrepareSaveGuard(); |
126 | | private: |
127 | | ScDocShell & mrDocShell; |
128 | | }; |
129 | | |
130 | | bool ImportFrom(SfxMedium&, const css::uno::Reference<css::text::XTextRange>&) override; |
131 | | |
132 | | bool LoadXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& ); |
133 | | bool SaveXML( SfxMedium* pMedium, const css::uno::Reference< css::embed::XStorage >& ); |
134 | | SCTAB GetSaveTab(); |
135 | | |
136 | | friend bool TestImportDBF(SvStream &rStream); |
137 | | |
138 | | ErrCode DBaseImport( const OUString& rFullFileName, rtl_TextEncoding eCharSet, |
139 | | std::map<SCCOL, ScColWidthParam>& aColWidthParam, ScFlatBoolRowSegments& rRowHeightsRecalc ); |
140 | | ErrCodeMsg DBaseExport( |
141 | | const OUString& rFullFileName, rtl_TextEncoding eCharSet, bool& bHasMemo ); |
142 | | |
143 | | static bool MoveFile( const INetURLObject& rSource, const INetURLObject& rDest ); |
144 | | static bool KillFile( const INetURLObject& rURL ); |
145 | | static bool IsDocument( const INetURLObject& rURL ); |
146 | | |
147 | | void LockPaint_Impl(bool bDoc); |
148 | | void UnlockPaint_Impl(bool bDoc); |
149 | | void LockDocument_Impl(sal_uInt16 nNew); |
150 | | void UnlockDocument_Impl(sal_uInt16 nNew); |
151 | | |
152 | | void EnableSharedSettings( bool bEnable ); |
153 | | css::uno::Reference< css::frame::XModel > LoadSharedDocument(); |
154 | | |
155 | | void UseSheetSaveEntries(); |
156 | | |
157 | | std::unique_ptr<ScDocFunc> CreateDocFunc(); |
158 | | |
159 | | virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; |
160 | | |
161 | | public: |
162 | | SFX_DECL_INTERFACE(SCID_DOC_SHELL) |
163 | | SC_DLLPUBLIC static SfxObjectFactory& Factory(); |
164 | 140k | virtual SfxObjectFactory& GetFactory() const override { return Factory(); } |
165 | | |
166 | | private: |
167 | | /// SfxInterface initializer. |
168 | | static void InitInterface_Impl(); |
169 | | |
170 | | public: |
171 | | explicit ScDocShell( const ScDocShell& rDocShell ) = delete; |
172 | | SC_DLLPUBLIC explicit ScDocShell( const SfxModelFlags i_nSfxCreationFlags = SfxModelFlags::EMBEDDED_OBJECT, const std::shared_ptr<ScDocument>& pDoc = {} ); |
173 | | explicit ScDocShell(const SfxModelFlags i_nSfxCreationFlags, ScDocumentMode); |
174 | | virtual ~ScDocShell() override; |
175 | | |
176 | | SC_DLLPUBLIC virtual SfxUndoManager* GetUndoManager() override; |
177 | | |
178 | | virtual void FillClass( SvGlobalName * pClassName, |
179 | | SotClipboardFormatId * pFormat, |
180 | | OUString * pFullTypeName, |
181 | | sal_Int32 nFileFormat, |
182 | | bool bTemplate = false ) const override; |
183 | | |
184 | | std::shared_ptr<sfx::IDocumentModelAccessor> GetDocumentModelAccessor() const override; |
185 | | virtual std::set<Color> GetDocColors() override; |
186 | | virtual std::shared_ptr<model::ColorSet> GetThemeColors() override; |
187 | | |
188 | | virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& ) override; |
189 | | virtual bool Load( SfxMedium& rMedium ) override; |
190 | | virtual bool LoadFrom( SfxMedium& rMedium ) override; |
191 | | virtual bool ConvertFrom( SfxMedium &rMedium ) override; |
192 | | virtual bool LoadExternal( SfxMedium& rMedium ) override; |
193 | | virtual bool Save() override; |
194 | | virtual bool SaveAs( SfxMedium& rMedium ) override; |
195 | | virtual bool ConvertTo( SfxMedium &rMedium ) override; |
196 | | virtual bool PrepareClose( bool bUI = true ) override; |
197 | | virtual void LoadStyles( SfxObjectShell &rSource ) override; |
198 | | |
199 | | virtual bool DoSaveCompleted( SfxMedium * pNewStor=nullptr, bool bRegisterRecent=true ) override; // SfxObjectShell |
200 | | virtual bool QuerySlotExecutable( sal_uInt16 nSlotId ) override; |
201 | | |
202 | | virtual void Draw(OutputDevice *, const JobSetup & rSetup, sal_uInt16 nAspect, bool bOutputForScreen) override; |
203 | | |
204 | | SC_DLLPUBLIC virtual void SetVisArea( const tools::Rectangle & rVisArea ) override; |
205 | | |
206 | | virtual void TerminateEditing() override; |
207 | | |
208 | | using SfxObjectShell::GetVisArea; |
209 | | virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const override; |
210 | | |
211 | | virtual Printer* GetDocumentPrinter() override; |
212 | | |
213 | | virtual void SetModified( bool = true ) override; |
214 | | |
215 | | void SetVisAreaOrSize( const tools::Rectangle& rVisArea ); |
216 | | |
217 | | virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, const SfxItemSet &rSet) override; |
218 | | |
219 | | SC_DLLPUBLIC void GetDocStat( ScDocStat& rDocStat ); |
220 | | |
221 | 0 | const ScDocument& GetDocument() const { return *m_pDocument; } |
222 | 1.33M | ScDocument& GetDocument() { return *m_pDocument; } |
223 | 45.8k | ScDocFunc& GetDocFunc() { return *m_pDocFunc; } |
224 | | |
225 | 0 | css::uno::Reference<css::datatransfer::XTransferable2> const & GetClipData() const { return m_xClipData; } |
226 | 0 | void SetClipData(const css::uno::Reference<css::datatransfer::XTransferable2>& xTransferable) { m_xClipData = xTransferable; } |
227 | | |
228 | | SfxPrinter* GetPrinter( bool bCreateIfNotExist = true ); |
229 | | sal_uInt16 SetPrinter( VclPtr<SfxPrinter> const & pNewPrinter, SfxPrinterChangeFlags nDiffFlags = SFX_PRINTER_ALL ); |
230 | | |
231 | | void UpdateFontList(); |
232 | | |
233 | | ScDrawLayer* MakeDrawLayer(); |
234 | | |
235 | | void AsciiSave( SvStream& rStream, const ScImportOptions& rOpt, SCTAB nTab ); |
236 | | |
237 | | void Execute( SfxRequest& rReq ); |
238 | | void GetState( SfxItemSet &rSet ); |
239 | | void ExecutePageStyle ( const SfxViewShell& rCaller, SfxRequest& rReq, SCTAB nCurTab ); |
240 | | void GetStatePageStyle( SfxItemSet& rSet, SCTAB nCurTab ); |
241 | | |
242 | | void CompareDocument( ScDocument& rOtherDoc ); |
243 | | void MergeDocument( ScDocument& rOtherDoc, bool bShared = false, bool bCheckDuplicates = false, sal_uLong nOffset = 0, ScChangeActionMergeMap* pMergeMap = nullptr, bool bInverseMap = false ); |
244 | | bool MergeSharedDocument( ScDocShell* pSharedDocShell ); |
245 | | |
246 | | ScChangeAction* GetChangeAction( const ScAddress& rPos ); |
247 | | void SetChangeComment( ScChangeAction* pAction, const OUString& rComment ); |
248 | | void ExecuteChangeCommentDialog( ScChangeAction* pAction, weld::Window* pParent, bool bPrevNext = true ); |
249 | | /// Protect/unprotect ChangeTrack and return <TRUE/> if |
250 | | /// protection was successfully changed. |
251 | | /// If bJustQueryIfProtected==sal_True protection is not |
252 | | /// changed and <TRUE/> is returned if not protected or |
253 | | /// password was entered correctly. |
254 | | bool ExecuteChangeProtectionDialog( bool bJustQueryIfProtected = false ); |
255 | | |
256 | | void SetPrintZoom( SCTAB nTab, sal_uInt16 nScale, sal_uInt16 nPages ); |
257 | | bool AdjustPrintZoom( const ScRange& rRange ); |
258 | | |
259 | | void LoadStylesArgs( ScDocShell& rSource, bool bReplace, bool bCellStyles, bool bPageStyles ); |
260 | | |
261 | | void PageStyleModified( std::u16string_view rStyleName, bool bApi ); |
262 | | |
263 | | void NotifyStyle( const SfxStyleSheetHint& rHint ); |
264 | | void DoAutoStyle( const ScRange& rRange, const OUString& rStyle ); |
265 | | |
266 | | SC_DLLPUBLIC static weld::Window* GetActiveDialogParent(); |
267 | | void ErrorMessage(TranslateId pGlobStrId); |
268 | | bool IsEditable() const; |
269 | | |
270 | | /// check config if on file-open optimal row heights should run, or if the user should be asked |
271 | | SC_DLLPUBLIC bool GetRecalcRowHeightsMode(); |
272 | | bool AdjustRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ); |
273 | | SC_DLLPUBLIC void UpdateAllRowHeights( const ScMarkData* pTabMark = nullptr ); |
274 | | SC_DLLPUBLIC void UpdateAllRowHeights(const bool bOnlyUsedRows); |
275 | | void UpdatePendingRowHeights( SCTAB nUpdateTab, bool bBefore = false ); |
276 | | |
277 | | void RefreshPivotTables( const ScRange& rSource ); |
278 | | SC_DLLPUBLIC void ResolveSpilledOutputs(); |
279 | | void DoConsolidate( const ScConsolidateParam& rParam, bool bRecord = true ); |
280 | | void UseScenario( SCTAB nTab, const OUString& rName, bool bRecord = true ); |
281 | | SCTAB MakeScenario(SCTAB nTab, const OUString& rName, const OUString& rComment, |
282 | | const Color& rColor, ScScenarioFlags nFlags, |
283 | | ScMarkData& rMark, bool bRecord = true); |
284 | | void ModifyScenario(SCTAB nTab, const OUString& rName, const OUString& rComment, |
285 | | const Color& rColor, ScScenarioFlags nFlags); |
286 | | SC_DLLPUBLIC bool TransferTab( ScDocShell& rSrcDocShell, SCTAB nSrcPos, |
287 | | SCTAB nDestPos, bool bInsertNew, |
288 | | bool bNotifyAndPaint ); |
289 | | |
290 | | bool MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRecord ); |
291 | | |
292 | | SC_DLLPUBLIC void DoRecalc( bool bApi ); |
293 | | SC_DLLPUBLIC void DoHardRecalc(); |
294 | | |
295 | | void UpdateOle(const ScViewData& rViewData, bool bSnapSize = false); |
296 | | bool IsOle() const; |
297 | | |
298 | | void DBAreaDeleted( SCTAB nTab, SCCOL nX1, SCROW nY1, SCCOL nX2 ); |
299 | | ScDBData* GetDBData( const ScRange& rMarked, ScGetDBMode eMode, ScGetDBSelection eSel ); |
300 | | ScDBData* GetAnonymousDBData(const ScRange& rRange); |
301 | | std::unique_ptr<ScDBData> GetOldAutoDBRange(); |
302 | | void CancelAutoDBRange(); // called when dialog is cancelled |
303 | | |
304 | | virtual void ReconnectDdeLink(SfxObjectShell& rServer) override; |
305 | | void UpdateLinks() override; |
306 | | void PerformLinkUpdate() override; |
307 | | /** The document's HasExternalLinks together with the deferred form-control |
308 | | images the shell keeps itself. */ |
309 | | bool HasExternalLinks() const; |
310 | | SC_DLLPUBLIC void SetInitialLinkUpdate( const SfxMedium* pMedium ); |
311 | | void AllowLinkUpdate(); |
312 | | SC_DLLPUBLIC void ReloadAllLinks(); |
313 | | void ReloadTabLinks(); |
314 | | ScLkUpdMode GetLinkUpdateModeState() const; |
315 | | |
316 | | SC_DLLPUBLIC void SetFormulaOptions( const ScFormulaOptions& rOpt, bool bForLoading = false ); |
317 | | /** |
318 | | * Called when the Options dialog is dismissed with the OK button, to |
319 | | * handle potentially conflicting option settings. |
320 | | */ |
321 | | void CheckConfigOptions(); |
322 | | |
323 | | void PostEditView(ScEditEngineDefaulter& rEditEngine, const ScAddress& rCursorPos); |
324 | | |
325 | | tools::Long GetTwipWidthHint(const ScAddress& rPos); |
326 | | |
327 | | void PostPaint( SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, |
328 | | SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab, PaintPartFlags nPart, |
329 | | sal_uInt16 nExtFlags = 0, tools::Long nMaxWidthAffectedHint = -1 ); |
330 | | SC_DLLPUBLIC void PostPaint( const ScRangeList& rRanges, PaintPartFlags nPart, sal_uInt16 nExtFlags = 0, |
331 | | tools::Long nMaxWidthAffectedHint = -1 ); |
332 | | |
333 | | void PostPaintCell( SCCOL nCol, SCROW nRow, SCTAB nTab, tools::Long nMaxWidthAffectedHint = -1); |
334 | | void PostPaintCell( const ScAddress& rPos, tools::Long nMaxWidthAffectedHint = -1); |
335 | | SC_DLLPUBLIC void PostPaintGridAll(); |
336 | | void PostPaintExtras(); |
337 | | |
338 | 0 | bool IsPaintLocked() const { return m_pPaintLockData != nullptr; } |
339 | | |
340 | | void PostDataChanged(); |
341 | | |
342 | | void UpdatePaintExt( sal_uInt16& rExtFlags, SCCOL nStartCol, SCROW nStartRow, SCTAB nStartTab, |
343 | | SCCOL nEndCol, SCROW nEndRow, SCTAB nEndTab ); |
344 | | void UpdatePaintExt( sal_uInt16& rExtFlags, const ScRange& rRange ); |
345 | | |
346 | | SC_DLLPUBLIC void SetDocumentModified(); |
347 | | void SetDrawModified(); |
348 | | |
349 | | SC_DLLPUBLIC void LockPaint(); |
350 | | SC_DLLPUBLIC void UnlockPaint(); |
351 | 0 | sal_uInt16 GetLockCount() const { return m_nDocumentLock;} |
352 | | void SetLockCount(sal_uInt16 nNew); |
353 | | |
354 | | void LockDocument(); |
355 | | void UnlockDocument(); |
356 | | |
357 | | DECL_LINK( DialogClosedHdl, sfx2::FileDialogHelper*, void ); |
358 | | |
359 | | virtual SfxStyleSheetBasePool* GetStyleSheetPool() override; |
360 | | |
361 | | void SetInplace( bool bInplace ); |
362 | 0 | bool IsEmpty() const { return m_bIsEmpty; } |
363 | | SC_DLLPUBLIC void SetEmpty(bool bSet); |
364 | | |
365 | 0 | bool IsInUndo() const { return m_bIsInUndo; } |
366 | | void SetInUndo(bool bSet); |
367 | | |
368 | | void CalcOutputFactor(); |
369 | 3.86k | double GetOutputFactor() const { return m_nPrtToScreenFactor;} |
370 | | |
371 | | #if defined(_WIN32) |
372 | | virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType, |
373 | | css::uno::Any & rValue ) override; |
374 | | virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType, |
375 | | const css::uno::Any & rValue ) override; |
376 | | #endif |
377 | | |
378 | | virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) override; |
379 | | |
380 | 0 | const OUString& GetDdeTextFmt() const { return m_aDdeTextFmt; } |
381 | | |
382 | | SAL_RET_MAYBENULL SfxBindings* GetViewBindings(); |
383 | | |
384 | | SAL_RET_MAYBENULL SC_DLLPUBLIC ScTabViewShell* GetBestViewShell( bool bOnlyVisible = true ); |
385 | | |
386 | | void SetDocumentModifiedPending( bool bVal ) |
387 | 3.77k | { m_bDocumentModifiedPending = bVal; } |
388 | | bool IsDocumentModifiedPending() const |
389 | 166k | { return m_bDocumentModifiedPending; } |
390 | | |
391 | | bool IsUpdateEnabled() const |
392 | 0 | { return m_bUpdateEnabled; } |
393 | | void SetUpdateEnabled(bool bValue) |
394 | 0 | { m_bUpdateEnabled = bValue; } |
395 | | |
396 | | void SetAreasChangedNeedBroadcast() |
397 | 0 | { m_bAreasChangedNeedBroadcast = true; } |
398 | | |
399 | | OutputDevice* GetRefDevice(); // WYSIWYG: Printer, otherwise VirtualDevice... |
400 | | |
401 | | SAL_RET_MAYBENULL SC_DLLPUBLIC static ScViewData* GetViewData(); |
402 | | SC_DLLPUBLIC static SCTAB GetCurTab(); |
403 | | |
404 | | SAL_RET_MAYBENULL static ScDocShell* GetShellByNum( sal_uInt16 nDocNo ); |
405 | | static bool HasAutomaticTableName( std::u16string_view rFilter ); |
406 | | static void LOKCommentNotify(LOKCommentNotificationType nType, const ScDocument& rDocument, const ScAddress& rPos, const ScPostIt* pNote); |
407 | | |
408 | | DECL_LINK( RefreshDBDataHdl, Timer*, void ); |
409 | | |
410 | | void BeforeXMLLoading(); |
411 | | void AfterXMLLoading(bool bRet); |
412 | | |
413 | | virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates ) override; |
414 | | |
415 | | ScSheetSaveData* GetSheetSaveData(); |
416 | | ScFormatSaveData* GetFormatSaveData(); |
417 | | |
418 | | static void ResetKeyBindings( ScOptionsUtil::KeyBindingType eType ); |
419 | | |
420 | | // password protection for Calc (derived from SfxObjectShell) |
421 | | // see also: FID_CHG_RECORD, SID_CHG_PROTECT |
422 | | virtual bool IsChangeRecording(SfxViewShell* pViewShell = nullptr, bool bRecordAllViews = true) const override; |
423 | | virtual bool HasChangeRecordProtection() const override; |
424 | | virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic) override; |
425 | | virtual void SetProtectionPassword( const OUString &rPassword ) override; |
426 | | virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override; |
427 | | |
428 | | void SnapVisArea( tools::Rectangle& rRect ) const; |
429 | | |
430 | | SC_DLLPUBLIC void RegisterAutomationWorkbookObject(css::uno::Reference< ooo::vba::excel::XWorkbook > const& xWorkbook); |
431 | | |
432 | 45.1k | ScModelObj* GetModel() const { return static_cast<ScModelObj*>(SfxObjectShell::GetModel().get()); } |
433 | | |
434 | | void AddDelayedInfobarEntry(const OUString& sId, const OUString& sPrimaryMessage, |
435 | | const OUString& sSecondaryMessage, InfobarType aInfobarType, |
436 | | bool bShowCloseButton); |
437 | | |
438 | | private: |
439 | | void ExecuteChartSource(SfxRequest& rReq); |
440 | | void ExecuteChartSourcePost( bool bUndo, bool bMultiRange, |
441 | | const OUString& rChartName, const ScRangeListRef& rRangeListRef, |
442 | | bool bColHeaders, bool bRowHeaders, bool bAddRange, |
443 | | SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, SCTAB nTab); |
444 | | |
445 | | void SetLanguage(LanguageType eLatin, LanguageType eCjk, LanguageType eCtl); |
446 | | }; |
447 | | |
448 | | void UpdateAcceptChangesDialog(); |
449 | | |
450 | | typedef rtl::Reference<ScDocShell> ScDocShellRef; |
451 | | |
452 | | /** Create before modifications of the document and destroy thereafter. |
453 | | Call SetDocumentModified() at an instance of this class instead of at |
454 | | ScDocShell. |
455 | | |
456 | | Remembers in the ctor ScDocument's AutoCalcShellDisabled and IdleDisabled, |
457 | | switches them off and restores them in the dtor, AutoCalcShellDisabled |
458 | | also before a ScDocShell::SetDocumentModified() call if necessary. |
459 | | In the dtor, if ScDocShell's bDocumentModifiedPending is set and |
460 | | bAutoCalcShellDisabled is not set, then ScDocShell::SetDocumentModified() |
461 | | is called. |
462 | | |
463 | | Several instances can be used in nested calls to ScDocFunc or ScDocShell |
464 | | methods to avoid multiple modified status changes, only the last instance |
465 | | destroyed calls ScDocShell::SetDocumentModified(). |
466 | | */ |
467 | | class ScDocShellModificator |
468 | | { |
469 | | ScDocShell& rDocShell; |
470 | | std::unique_ptr<ScRefreshTimerProtector> mpProtector; |
471 | | bool bAutoCalcShellDisabled; |
472 | | bool bIdleEnabled; |
473 | | |
474 | | ScDocShellModificator( const ScDocShellModificator& ) = delete; |
475 | | ScDocShellModificator& operator=( const ScDocShellModificator& ) = delete; |
476 | | |
477 | | void ImplDestroy(); |
478 | | |
479 | | public: |
480 | | explicit ScDocShellModificator( ScDocShell& ); |
481 | | ~ScDocShellModificator(); |
482 | | void SetDocumentModified(); |
483 | | }; |
484 | | |
485 | | //#i97876# Spreadsheet data changes are not notified |
486 | | namespace HelperNotifyChanges |
487 | | { |
488 | | inline bool isDataAreaInvalidateType(std::u16string_view rType) |
489 | 21.8k | { |
490 | 21.8k | if (rType == u"delete-content") |
491 | 0 | return true; |
492 | 21.8k | if (rType == u"delete-rows") |
493 | 0 | return true; |
494 | 21.8k | if (rType == u"delete-columns") |
495 | 0 | return true; |
496 | 21.8k | if (rType == u"undo") |
497 | 0 | return true; |
498 | 21.8k | if (rType == u"redo") |
499 | 0 | return true; |
500 | 21.8k | if (rType == u"paste") |
501 | 0 | return true; |
502 | 21.8k | if (rType == u"note") |
503 | 21.8k | return true; |
504 | | |
505 | 0 | return false; |
506 | 21.8k | } |
507 | | |
508 | | inline bool getMustPropagateChangesModel(const ScModelObj* pModelObj) |
509 | 21.8k | { |
510 | 21.8k | return pModelObj && pModelObj->HasChangesListeners(); |
511 | 21.8k | } |
512 | | |
513 | | inline void Notify(ScModelObj &rModelObj, const ScRangeList &rChangeRanges, |
514 | | const OUString &rType = u"cell-change"_ustr, |
515 | | const css::uno::Sequence< css::beans::PropertyValue >& rProperties = |
516 | | css::uno::Sequence< css::beans::PropertyValue >()) |
517 | 21.8k | { |
518 | 21.8k | rModelObj.NotifyChanges(rType, rChangeRanges, rProperties); |
519 | 21.8k | } |
520 | | |
521 | | inline void NotifyIfChangesListeners(const ScDocShell &rDocShell, const ScRange &rRange, |
522 | | const OUString &rType = u"cell-change"_ustr) |
523 | 21.8k | { |
524 | 21.8k | ScModelObj* pModelObj = rDocShell.GetModel(); |
525 | 21.8k | ScRangeList aChangeRanges(rRange); |
526 | | |
527 | 21.8k | if (getMustPropagateChangesModel(pModelObj)) |
528 | 0 | Notify(*pModelObj, aChangeRanges, rType); |
529 | 21.8k | else if (pModelObj) // possibly need to invalidate getCellArea results |
530 | 21.8k | { |
531 | 21.8k | Notify(*pModelObj, aChangeRanges, isDataAreaInvalidateType(rType) |
532 | 21.8k | ? u"data-area-invalidate"_ustr : u"data-area-extend"_ustr); |
533 | 21.8k | } |
534 | 21.8k | } |
535 | | }; |
536 | | |
537 | | void VBA_InsertModule( ScDocument& rDoc, SCTAB nTab, const OUString& sModuleSource ); |
538 | | |
539 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |