/src/libreoffice/sw/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 | | #pragma once |
20 | | |
21 | | #include <memory> |
22 | | #include <vector> |
23 | | #include <rtl/ref.hxx> |
24 | | #include <com/sun/star/uno/Sequence.h> |
25 | | #include <sfx2/docfac.hxx> |
26 | | #include <sfx2/objsh.hxx> |
27 | | #include "swdllapi.h" |
28 | | #include "shellid.hxx" |
29 | | |
30 | | #include <svl/lstner.hxx> |
31 | | #include <svl/style.hxx> |
32 | | #include <sfx2/StyleManager.hxx> |
33 | | #include <o3tl/deleter.hxx> |
34 | | |
35 | | class SwDoc; |
36 | | class SfxInPlaceClient; |
37 | | class FontList; |
38 | | class SwEditShell; |
39 | | class SwView; |
40 | | class SwWrtShell; |
41 | | class SwFEShell; |
42 | | class Reader; |
43 | | class SwReader; |
44 | | typedef std::unique_ptr<SwReader, o3tl::default_delete<SwReader>> SwReaderPtr; |
45 | | class SwCursorShell; |
46 | | class SwSrcView; |
47 | | class SwPaM; |
48 | | class SwgReaderOption; |
49 | | class IDocumentDeviceAccess; |
50 | | class IDocumentChartDataProviderAccess; |
51 | | class SwDocShell; |
52 | | class SwDrawModel; |
53 | | class SwViewShell; |
54 | | class SwDocStyleSheetPool; |
55 | | class SwXTextDocument; |
56 | | class SwTextFormatColl; |
57 | | class UIName; |
58 | | namespace svt |
59 | | { |
60 | | class EmbeddedObjectRef; |
61 | | } |
62 | | namespace com::sun::star::frame { class XController; } |
63 | | namespace ooo::vba { class XSinkCaller; } |
64 | | namespace ooo::vba::word { class XDocument; } |
65 | | |
66 | | // initialize DrawModel (in form of a SwDrawModel) and DocShell (in form of a SwDocShell) |
67 | | // as needed, one or both parameters may be zero |
68 | | void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawModel); |
69 | | |
70 | | class SW_DLLPUBLIC SwDocShell |
71 | | : public SfxObjectShell |
72 | | , public SfxListener |
73 | | { |
74 | | rtl::Reference< SwDoc > m_xDoc; ///< Document. |
75 | | rtl::Reference< SwDocStyleSheetPool > m_xBasePool; ///< Passing through for formats. |
76 | | std::unique_ptr<FontList> m_pFontList; ///< Current Fontlist. |
77 | | bool m_IsInUpdateFontList; ///< prevent nested calls of UpdateFontList |
78 | | |
79 | | std::unique_ptr<sfx2::StyleManager> m_pStyleManager; |
80 | | |
81 | | /** For "historical reasons" nothing can be done without the WrtShell. |
82 | | Back-pointer on View (again "for historical reasons"). |
83 | | Back-pointer is valid until in Activate a new one is set |
84 | | or until it is deleted in the View's Dtor. */ |
85 | | |
86 | | SwView* m_pView; |
87 | | SwWrtShell* m_pWrtShell; |
88 | | |
89 | | std::unique_ptr<comphelper::EmbeddedObjectContainer> m_pOLEChildList; |
90 | | sal_Int16 m_nUpdateDocMode; ///< contains the css::document::UpdateDocMode |
91 | | bool m_IsATemplate; ///< prevent nested calls of UpdateFontList |
92 | | |
93 | | bool m_IsRemovedInvisibleContent; |
94 | | ///< whether SID_MAIL_PREPAREEXPORT removed content that |
95 | | ///< SID_MAIL_EXPORT_FINISHED needs to restore |
96 | | |
97 | | css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationDocumentEventsCaller; |
98 | | css::uno::Reference< ooo::vba::word::XDocument> mxAutomationDocumentObject; |
99 | | |
100 | | /// Methods for access to doc. |
101 | | SAL_DLLPRIVATE void AddLink(); |
102 | | SAL_DLLPRIVATE void RemoveLink(); |
103 | | |
104 | | /// Catch hint for DocInfo. |
105 | | SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override; |
106 | | |
107 | | /// FileIO |
108 | | SAL_DLLPRIVATE virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override; |
109 | | SAL_DLLPRIVATE virtual bool Load( SfxMedium& rMedium ) override; |
110 | | SAL_DLLPRIVATE virtual bool LoadFrom( SfxMedium& rMedium ) override; |
111 | | SAL_DLLPRIVATE virtual bool ConvertFrom( SfxMedium &rMedium ) override; |
112 | | SAL_DLLPRIVATE virtual bool ConvertTo( SfxMedium &rMedium ) override; |
113 | | SAL_DLLPRIVATE virtual bool SaveAs( SfxMedium& rMedium ) override; |
114 | | SAL_DLLPRIVATE virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ) override; |
115 | | |
116 | | SAL_DLLPRIVATE virtual bool PrepareClose( bool bUI = true ) override; |
117 | | |
118 | | SAL_DLLPRIVATE virtual bool InsertGeneratedStream(SfxMedium& rMedium, |
119 | | css::uno::Reference<css::text::XTextRange> const& xInsertPosition) |
120 | | override; |
121 | | |
122 | | /// Make DocInfo known to the Doc. |
123 | | SAL_DLLPRIVATE virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent, |
124 | | const SfxItemSet &rSet) override; |
125 | | /// OLE-stuff |
126 | | SAL_DLLPRIVATE virtual void Draw(OutputDevice*, const JobSetup&, sal_uInt16 nAspect, bool bOutputToWindow) override; |
127 | | |
128 | | /// Methods for StyleSheets |
129 | | |
130 | | /// @param nSlot |
131 | | /// Only used for nFamily == SfxStyleFamily::Page. Identifies optional Slot by which the edit is triggered. |
132 | | /// Used to activate certain dialog pane |
133 | | SAL_DLLPRIVATE void Edit( |
134 | | weld::Window* pDialogParent, |
135 | | const UIName& rName, |
136 | | const UIName& rParent, |
137 | | const SfxStyleFamily nFamily, |
138 | | SfxStyleSearchBits nMask, |
139 | | const bool bNew, |
140 | | const OUString& sPageId, |
141 | | SwWrtShell* pActShell, |
142 | | SfxRequest* pRequest = nullptr, |
143 | | sal_uInt16 nSlot = 0); |
144 | | |
145 | | SAL_DLLPRIVATE void ApplyStyleSheetRequest(const OUString& aParam, sal_uInt16 nSlot, SfxRequest& rReq, SfxStyleFamily nFamily, |
146 | | SfxStyleSearchBits nMask, SwWrtShell* pActShell); |
147 | | |
148 | | SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily); |
149 | | SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden); |
150 | | SAL_DLLPRIVATE bool MakeInlineHeading(SwWrtShell *pSh, SwTextFormatColl* pColl, |
151 | | const sal_uInt16 nMode); |
152 | | SAL_DLLPRIVATE SfxStyleFamily ApplyStyles(const OUString &rName, |
153 | | const SfxStyleFamily nFamily, |
154 | | SwWrtShell* pShell, |
155 | | sal_uInt16 nMode); |
156 | | SAL_DLLPRIVATE SfxStyleFamily DoWaterCan( const OUString &rName, SfxStyleFamily nFamily); |
157 | | SAL_DLLPRIVATE void UpdateStyle(const UIName &rName, SfxStyleFamily nFamily, SwWrtShell* pShell); |
158 | | SAL_DLLPRIVATE void MakeByExample(const UIName &rName, |
159 | | SfxStyleFamily nFamily, SfxStyleSearchBits nMask, SwWrtShell* pShell); |
160 | | |
161 | | SAL_DLLPRIVATE void SubInitNew(); ///< for InitNew and HtmlSourceMode. |
162 | | |
163 | | SAL_DLLPRIVATE void RemoveOLEObjects(); |
164 | | SAL_DLLPRIVATE void CalcLayoutForOLEObjects(); |
165 | | |
166 | | SAL_DLLPRIVATE void Init_Impl(); |
167 | | |
168 | | using SfxObjectShell::GetVisArea; |
169 | | |
170 | | protected: |
171 | | /// override to update text fields |
172 | | virtual void DoFlushDocInfo() override; |
173 | | |
174 | | public: |
175 | | /// but we implement this ourselves. |
176 | | SFX_DECL_INTERFACE(SW_DOCSHELL) |
177 | | SFX_DECL_OBJECTFACTORY() |
178 | | |
179 | | private: |
180 | | /// SfxInterface initializer. |
181 | | static void InitInterface_Impl(); |
182 | | |
183 | | public: |
184 | | static const OUString & GetEventName( sal_Int32 nId ); |
185 | | |
186 | | /// Doc is required for SO data exchange! |
187 | | SwDocShell( SfxObjectCreateMode eMode = SfxObjectCreateMode::EMBEDDED ); |
188 | | SwDocShell( SfxModelFlags i_nSfxCreationFlags ); |
189 | | SwDocShell( SwDoc& rDoc, SfxObjectCreateMode eMode ); |
190 | | virtual ~SwDocShell() override; |
191 | | |
192 | | /// OLE 2.0-notification. |
193 | | DECL_DLLPRIVATE_LINK( Ole2ModifiedHdl, bool, void ); |
194 | | |
195 | | /// Override SfxObjectShell::GetBaseModel and return a more accurate type |
196 | | rtl::Reference<SwXTextDocument> GetBaseModel() const; |
197 | | |
198 | | /// OLE-stuff. |
199 | | virtual void SetVisArea( const tools::Rectangle &rRect ) override; |
200 | | virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const override; |
201 | | virtual Printer *GetDocumentPrinter() override; |
202 | | virtual OutputDevice* GetDocumentRefDev() override; |
203 | | virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ) override; |
204 | | |
205 | | virtual void SetModified( bool = true ) override; |
206 | | |
207 | | /// Dispatcher |
208 | | void Execute(SfxRequest &); |
209 | | void ExecStyleSheet(SfxRequest&); |
210 | | |
211 | | void GetState(SfxItemSet &); |
212 | | void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = nullptr ); |
213 | | |
214 | | /// returns Doc. But be careful! |
215 | 2.43M | SwDoc* GetDoc() { return m_xDoc.get(); } |
216 | 14 | const SwDoc* GetDoc() const { return m_xDoc.get(); } |
217 | | IDocumentDeviceAccess& getIDocumentDeviceAccess(); |
218 | | IDocumentChartDataProviderAccess& getIDocumentChartDataProviderAccess(); |
219 | | |
220 | | void UpdateFontList(); |
221 | | void UpdateChildWindows(); |
222 | | |
223 | | /// global IO. |
224 | | virtual bool Save() override; |
225 | | |
226 | | /// For Style PI. |
227 | | virtual SfxStyleSheetBasePool* GetStyleSheetPool() override; |
228 | | virtual sfx2::StyleManager* GetStyleManager() override; |
229 | | |
230 | | /// Set View for actions via Shell. |
231 | | void SetView(SwView* pVw); |
232 | 19.5k | const SwView *GetView() const { return m_pView; } |
233 | 3.68M | SwView *GetView() { return m_pView; } |
234 | | |
235 | | /// Access to the SwWrtShell belonging to SwView. |
236 | 153M | SwWrtShell *GetWrtShell() { return m_pWrtShell; } |
237 | 433 | const SwWrtShell *GetWrtShell() const { return m_pWrtShell; } |
238 | | // Same as GetWrtShell, but return pointer to SwEditShell base of |
239 | | // (potentially incomplete) SwWrtShell: |
240 | | SwEditShell * GetEditShell(); |
241 | | |
242 | | /// For Core - it knows the DocShell but not the WrtShell! |
243 | | SwFEShell *GetFEShell(); |
244 | | const SwFEShell *GetFEShell() const |
245 | 0 | { return const_cast<SwDocShell*>(this)->GetFEShell(); } |
246 | | |
247 | | /// For inserting document. |
248 | | Reader* StartConvertFrom(SfxMedium& rMedium, SwReaderPtr& rpRdr, |
249 | | SwCursorShell const * pCursorSh = nullptr, SwPaM* pPaM = nullptr); |
250 | | |
251 | | #if defined(_WIN32) |
252 | | virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType, |
253 | | css::uno::Any & rValue ) override; |
254 | | virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType, |
255 | | const css::uno::Any & rValue ) override; |
256 | | #endif |
257 | | virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) override; |
258 | | virtual void ReconnectDdeLink(SfxObjectShell& rServer) override; |
259 | | |
260 | | virtual void FillClass( SvGlobalName * pClassName, |
261 | | SotClipboardFormatId * pClipFormat, |
262 | | OUString * pLongUserName, |
263 | | sal_Int32 nFileFormat, |
264 | | bool bTemplate = false ) const override; |
265 | | |
266 | | virtual std::set<Color> GetDocColors() override; |
267 | | |
268 | | virtual std::shared_ptr<model::ColorSet> GetThemeColors() override; |
269 | | |
270 | | sfx::AccessibilityIssueCollection runAccessibilityCheck() override; |
271 | | |
272 | | virtual void LoadStyles( SfxObjectShell& rSource ) override; |
273 | | |
274 | | void LoadStyles_( SfxObjectShell& rSource, bool bPreserveCurrentDocument ); |
275 | | |
276 | | /// Show page style format dialog |
277 | | /// @param nSlot |
278 | | /// Identifies slot by which the dialog is triggered. Used to activate certain dialog pane |
279 | | void FormatPage( |
280 | | weld::Window* pDialogParent, |
281 | | const UIName& rPage, |
282 | | const OUString& rPageId, |
283 | | SwWrtShell& rActShell, |
284 | | SfxRequest* pRequest = nullptr); |
285 | | |
286 | | // #i59688# |
287 | | /** linked graphics are now loaded on demand. |
288 | | Thus, loading of linked graphics no longer needed and necessary for |
289 | | the load of document being finished. */ |
290 | | |
291 | | void LoadingFinished(); |
292 | | |
293 | | /// Cancel transfer (called from SFX). |
294 | | virtual void CancelTransfers() override; |
295 | | |
296 | | /// Re-read Doc from Html-source. |
297 | | void ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView ); |
298 | | |
299 | 0 | sal_Int16 GetUpdateDocMode() const { return m_nUpdateDocMode; } |
300 | | |
301 | | void ToggleLayoutMode(SwView* pView); |
302 | | |
303 | | ErrCodeMsg LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, bool bUnoCall); |
304 | | void InvalidateModel(); |
305 | | void ReactivateModel(); |
306 | | |
307 | | virtual css::uno::Sequence< OUString > GetEventNames() override; |
308 | | |
309 | | /// #i20883# Digital Signatures and Encryption |
310 | | virtual HiddenInformation GetHiddenInformationState( HiddenInformation nStates ) override; |
311 | | |
312 | | /** #i42634# Overwrites SfxObjectShell::UpdateLinks |
313 | | This new function is necessary to trigger update of links in docs |
314 | | read by the binary filter: */ |
315 | | virtual void UpdateLinks() override; |
316 | | |
317 | | css::uno::Reference< css::frame::XController > |
318 | | GetController(); |
319 | | |
320 | | SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ); |
321 | 0 | SAL_DLLPRIVATE bool IsTemplate() const { return m_IsATemplate; } |
322 | 17.9k | SAL_DLLPRIVATE void SetIsTemplate( bool bValue ) { m_IsATemplate = bValue; } |
323 | | |
324 | | virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const override; |
325 | | |
326 | | /** passwword protection for Writer (derived from SfxObjectShell) |
327 | | see also: FN_REDLINE_ON, FN_REDLINE_ON */ |
328 | | virtual bool IsChangeRecording(SfxViewShell* pViewShell = nullptr, bool bRecordAllViews = true) const override; |
329 | | virtual bool HasChangeRecordProtection() const override; |
330 | | virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false, SfxRedlineRecordingMode eRedlineRecordingMode = SfxRedlineRecordingMode::ViewAgnostic) override; |
331 | | virtual void SetProtectionPassword( const OUString &rPassword ) override; |
332 | | virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override; |
333 | | |
334 | | void RegisterAutomationDocumentEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller); |
335 | | void CallAutomationDocumentEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments); |
336 | | void RegisterAutomationDocumentObject(css::uno::Reference< ooo::vba::word::XDocument > const& xDocument); |
337 | | |
338 | | // Lock all unlocked views, and returns a guard object which unlocks those views when destructed |
339 | | virtual std::unique_ptr<LockAllViewsGuard> LockAllViews() override; |
340 | | |
341 | | protected: |
342 | | class LockAllViewsGuard_Impl final : public LockAllViewsGuard |
343 | | { |
344 | | std::vector<SwViewShell*> m_aViewWasUnLocked; |
345 | | |
346 | | public: |
347 | | explicit LockAllViewsGuard_Impl(SwViewShell* pViewShell); |
348 | | ~LockAllViewsGuard_Impl(); |
349 | | }; |
350 | | |
351 | | }; |
352 | | |
353 | | /** Find the right DocShell and create a new one: |
354 | | The return value specifies what should happen to the Shell |
355 | | 0 - Error, could not find the DocShell |
356 | | 1 - DocShell is an existing Document |
357 | | 2 - DocShell was created anew, thus it needs to be closed again |
358 | | (will be assigned to xLockRef additionally) |
359 | | */ |
360 | | int SwFindDocShell( SfxObjectShellRef& xDocSh, |
361 | | SfxObjectShellLock& xLockRef, |
362 | | std::u16string_view rFileName, |
363 | | const OUString& rPasswd, |
364 | | const OUString& rFilter, |
365 | | sal_Int16 nVersion, |
366 | | SwDocShell* pDestSh, |
367 | | const css::uno::Reference<css::task::XInteractionHandler>& xIHandler); |
368 | | |
369 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |