LibreOffice Module sw (master) 1
docsh.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_SW_INC_DOCSH_HXX
20#define INCLUDED_SW_INC_DOCSH_HXX
21
22#include <memory>
23#include <vector>
24#include <rtl/ref.hxx>
25#include <com/sun/star/uno/Sequence.h>
26#include <sfx2/docfac.hxx>
27#include <sfx2/objsh.hxx>
28#include "swdllapi.h"
29#include "shellid.hxx"
30
31#include <svl/lstner.hxx>
32#include <sfx2/StyleManager.hxx>
33#include <o3tl/deleter.hxx>
34
35class SwDoc;
38class FontList;
39class SwEditShell;
40class SwView;
41class SwWrtShell;
42class SwFEShell;
43class Reader;
44class SwReader;
45typedef std::unique_ptr<SwReader, o3tl::default_delete<SwReader>> SwReaderPtr;
46class SwCursorShell;
47class SwSrcView;
48class SwPaM;
49class SwgReaderOption;
52class SwDocShell;
53class SwDrawModel;
54class SwViewShell;
55namespace svt
56{
57class EmbeddedObjectRef;
58}
59namespace com::sun::star::frame { class XController; }
60namespace ooo::vba { class XSinkCaller; }
61namespace ooo::vba::word { class XDocument; }
62
63// initialize DrawModel (in form of a SwDrawModel) and DocShell (in form of a SwDocShell)
64// as needed, one or both parameters may be zero
65void InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawModel);
66
68 : public SfxObjectShell
69 , public SfxListener
70{
73 std::unique_ptr<FontList> m_pFontList;
75
76 std::unique_ptr<sfx2::StyleManager> m_pStyleManager;
77
85
86 std::unique_ptr<comphelper::EmbeddedObjectContainer> m_pOLEChildList;
87 sal_Int16 m_nUpdateDocMode;
89
93
94 css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationDocumentEventsCaller;
95 css::uno::Reference< ooo::vba::word::XDocument> mxAutomationDocumentObject;
96
98 SAL_DLLPRIVATE void AddLink();
99 SAL_DLLPRIVATE void RemoveLink();
100
102 SAL_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
103
105 SAL_DLLPRIVATE virtual bool InitNew( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
106 SAL_DLLPRIVATE virtual bool Load( SfxMedium& rMedium ) override;
107 SAL_DLLPRIVATE virtual bool LoadFrom( SfxMedium& rMedium ) override;
108 SAL_DLLPRIVATE virtual bool ConvertFrom( SfxMedium &rMedium ) override;
109 SAL_DLLPRIVATE virtual bool ConvertTo( SfxMedium &rMedium ) override;
110 SAL_DLLPRIVATE virtual bool SaveAs( SfxMedium& rMedium ) override;
111 SAL_DLLPRIVATE virtual bool SaveCompleted( const css::uno::Reference< css::embed::XStorage >& xStorage ) override;
112
113 SAL_DLLPRIVATE virtual bool PrepareClose( bool bUI = true ) override;
114
115 SAL_DLLPRIVATE virtual bool InsertGeneratedStream(SfxMedium& rMedium,
116 css::uno::Reference<css::text::XTextRange> const& xInsertPosition)
117 override;
118
120 SAL_DLLPRIVATE virtual std::shared_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent,
121 const SfxItemSet &rSet) override;
123 SAL_DLLPRIVATE virtual void Draw(OutputDevice*, const JobSetup&, sal_uInt16 nAspect, bool bOutputToWindow) override;
124
126
130 SAL_DLLPRIVATE void Edit(
131 weld::Window* pDialogParent,
132 const OUString &rName,
133 const OUString& rParent,
134 const SfxStyleFamily nFamily,
135 SfxStyleSearchBits nMask,
136 const bool bNew,
137 const OUString& sPageId,
138 SwWrtShell* pActShell,
139 SfxRequest* pRequest = nullptr,
140 sal_uInt16 nSlot = 0);
141
142 SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily);
143 SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden);
144 SAL_DLLPRIVATE SfxStyleFamily ApplyStyles(const OUString &rName,
145 const SfxStyleFamily nFamily,
146 SwWrtShell* pShell,
147 sal_uInt16 nMode);
148 SAL_DLLPRIVATE SfxStyleFamily DoWaterCan( const OUString &rName, SfxStyleFamily nFamily);
149 SAL_DLLPRIVATE void UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWrtShell* pShell);
150 SAL_DLLPRIVATE void MakeByExample(const OUString &rName,
151 SfxStyleFamily nFamily, SfxStyleSearchBits nMask, SwWrtShell* pShell);
152
153 SAL_DLLPRIVATE void SubInitNew();
154
155 SAL_DLLPRIVATE void RemoveOLEObjects();
156 SAL_DLLPRIVATE void CalcLayoutForOLEObjects();
157
158 SAL_DLLPRIVATE void Init_Impl();
159
161
162protected:
164 virtual void DoFlushDocInfo() override;
165
166public:
170
171private:
173 static void InitInterface_Impl();
174
175public:
176 static OUString GetEventName( sal_Int32 nId );
177
180 SwDocShell( SfxModelFlags i_nSfxCreationFlags );
181 SwDocShell( SwDoc& rDoc, SfxObjectCreateMode eMode );
182 virtual ~SwDocShell() override;
183
185 DECL_DLLPRIVATE_LINK( Ole2ModifiedHdl, bool, void );
186
188 virtual void SetVisArea( const tools::Rectangle &rRect ) override;
189 virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const override;
190 virtual Printer *GetDocumentPrinter() override;
191 virtual OutputDevice* GetDocumentRefDev() override;
192 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ) override;
193
194 virtual void SetModified( bool = true ) override;
195
197 void Execute(SfxRequest &);
198 void ExecStyleSheet(SfxRequest&);
199
200 void GetState(SfxItemSet &);
201 void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = nullptr );
202
204 SwDoc* GetDoc() { return m_xDoc.get(); }
205 const SwDoc* GetDoc() const { return m_xDoc.get(); }
206 IDocumentDeviceAccess& getIDocumentDeviceAccess();
207 IDocumentChartDataProviderAccess& getIDocumentChartDataProviderAccess();
208
209 void UpdateFontList();
210 void UpdateChildWindows();
211
213 virtual bool Save() override;
214
216 virtual SfxStyleSheetBasePool* GetStyleSheetPool() override;
217 virtual sfx2::StyleManager* GetStyleManager() override;
218
220 void SetView(SwView* pVw);
221 const SwView *GetView() const { return m_pView; }
222 SwView *GetView() { return m_pView; }
223
225 SwWrtShell *GetWrtShell() { return m_pWrtShell; }
226 const SwWrtShell *GetWrtShell() const { return m_pWrtShell; }
227 // Same as GetWrtShell, but return pointer to SwEditShell base of
228 // (potentially incomplete) SwWrtShell:
229 SwEditShell * GetEditShell();
230
232 SwFEShell *GetFEShell();
233 const SwFEShell *GetFEShell() const
234 { return const_cast<SwDocShell*>(this)->GetFEShell(); }
235
237 Reader* StartConvertFrom(SfxMedium& rMedium, SwReaderPtr& rpRdr,
238 SwCursorShell const * pCursorSh = nullptr, SwPaM* pPaM = nullptr);
239
240#if defined(_WIN32)
241 virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType,
242 css::uno::Any & rValue ) override;
243 virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType,
244 const css::uno::Any & rValue ) override;
245#endif
246 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) override;
247 virtual void ReconnectDdeLink(SfxObjectShell& rServer) override;
248
249 virtual void FillClass( SvGlobalName * pClassName,
250 SotClipboardFormatId * pClipFormat,
251 OUString * pLongUserName,
252 sal_Int32 nFileFormat,
253 bool bTemplate = false ) const override;
254
255 virtual std::set<Color> GetDocColors() override;
256
257 virtual std::shared_ptr<model::ColorSet> GetThemeColors() override;
258
260
261 virtual void LoadStyles( SfxObjectShell& rSource ) override;
262
263 void LoadStyles_( SfxObjectShell& rSource, bool bPreserveCurrentDocument );
264
268 void FormatPage(
269 weld::Window* pDialogParent,
270 const OUString& rPage,
271 const OUString& rPageId,
272 SwWrtShell& rActShell,
273 SfxRequest* pRequest = nullptr);
274
275 // #i59688#
280 void LoadingFinished();
281
283 virtual void CancelTransfers() override;
284
286 void ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView );
287
288 sal_Int16 GetUpdateDocMode() const { return m_nUpdateDocMode; }
289
290 void ToggleLayoutMode(SwView* pView);
291
292 ErrCode LoadStylesFromFile(const OUString& rURL, SwgReaderOption& rOpt, bool bUnoCall);
293 void InvalidateModel();
294 void ReactivateModel();
295
296 virtual css::uno::Sequence< OUString > GetEventNames() override;
297
300
304 virtual void UpdateLinks() override;
305
306 css::uno::Reference< css::frame::XController >
308
309 SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
310 SAL_DLLPRIVATE bool IsTemplate() const { return m_IsATemplate; }
311 SAL_DLLPRIVATE void SetIsTemplate( bool bValue ) { m_IsATemplate = bValue; }
312
313 virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const override;
314
317 virtual bool IsChangeRecording() const override;
318 virtual bool HasChangeRecordProtection() const override;
319 virtual void SetChangeRecording( bool bActivate, bool bLockAllViews = false ) override;
320 virtual void SetProtectionPassword( const OUString &rPassword ) override;
321 virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override;
322
323 void RegisterAutomationDocumentEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
324 void CallAutomationDocumentEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
325 void RegisterAutomationDocumentObject(css::uno::Reference< ooo::vba::word::XDocument > const& xDocument);
326
327 // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
328 virtual std::unique_ptr<LockAllViewsGuard> LockAllViews() override;
329
330protected:
331 class LockAllViewsGuard_Impl final : public LockAllViewsGuard
332 {
333 std::vector<SwViewShell*> m_aViewWasUnLocked;
334
335 public:
336 explicit LockAllViewsGuard_Impl(SwViewShell* pViewShell);
338 };
339
340};
341
350 SfxObjectShellLock& xLockRef,
351 std::u16string_view rFileName,
352 const OUString& rPasswd,
353 const OUString& rFilter,
354 sal_Int16 nVersion,
355 SwDocShell* pDestSh );
356
357#endif
358
359/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Give access to the data-provider for chart.
Provides access to the formatting devices of a document.
virtual bool HasChangeRecordProtection() const
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual bool PrepareClose(bool bUI=true)
virtual bool ConvertFrom(SfxMedium &rMedium)
virtual void ReconnectDdeLink(SfxObjectShell &rServer)
virtual void CancelTransfers()
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem)
virtual sfx::AccessibilityIssueCollection runAccessibilityCheck()
virtual bool GetProtectionHash(css::uno::Sequence< sal_Int8 > &rPasswordHash)
virtual bool LoadFrom(SfxMedium &rMedium)
virtual bool Load(SfxMedium &rMedium)
virtual sfx2::StyleManager * GetStyleManager()
virtual css::uno::Sequence< OUString > GetEventNames()
virtual std::shared_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rItemSet)
virtual bool SaveAs(SfxMedium &rMedium)
virtual std::shared_ptr< model::ColorSet > GetThemeColors()
virtual bool SaveCompleted(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual std::unique_ptr< LockAllViewsGuard > LockAllViews()
virtual bool IsChangeRecording() const
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect, bool bOutputForScreen)=0
virtual bool ConvertTo(SfxMedium &rMedium)
virtual bool Save()
virtual void SetProtectionPassword(const OUString &rPassword)
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
virtual std::set< Color > GetDocColors()
virtual void LoadStyles(SfxObjectShell &rSource)
virtual void DoFlushDocInfo()
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates)
const tools::Rectangle & GetVisArea() const
virtual void SetChangeRecording(bool bActivate, bool bLockAllViews=false)
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const=0
virtual void UpdateLinks()
virtual bool InsertGeneratedStream(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
std::vector< SwViewShell * > m_aViewWasUnLocked
Definition: docsh.hxx:333
bool m_IsRemovedInvisibleContent
whether SID_MAIL_PREPAREEXPORT removed content that SID_MAIL_EXPORT_FINISHED needs to restore
Definition: docsh.hxx:90
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
rtl::Reference< SfxStyleSheetBasePool > m_xBasePool
Passing through for formats.
Definition: docsh.hxx:72
SwWrtShell * m_pWrtShell
Definition: docsh.hxx:84
std::unique_ptr< comphelper::EmbeddedObjectContainer > m_pOLEChildList
Definition: docsh.hxx:86
SAL_DLLPRIVATE bool IsTemplate() const
Definition: docsh.hxx:310
SAL_DLLPRIVATE void SetIsTemplate(bool bValue)
Definition: docsh.hxx:311
bool m_IsInUpdateFontList
prevent nested calls of UpdateFontList
Definition: docsh.hxx:74
const SwFEShell * GetFEShell() const
Definition: docsh.hxx:233
const SwDoc * GetDoc() const
Definition: docsh.hxx:205
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationDocumentEventsCaller
Definition: docsh.hxx:94
const SwView * GetView() const
Definition: docsh.hxx:221
sal_Int16 m_nUpdateDocMode
contains the css::document::UpdateDocMode
Definition: docsh.hxx:87
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:225
bool m_IsATemplate
prevent nested calls of UpdateFontList
Definition: docsh.hxx:88
SwView * GetView()
Definition: docsh.hxx:222
const SwWrtShell * GetWrtShell() const
Definition: docsh.hxx:226
SwView * m_pView
For "historical reasons" nothing can be done without the WrtShell.
Definition: docsh.hxx:83
std::unique_ptr< FontList > m_pFontList
Current Fontlist.
Definition: docsh.hxx:73
sal_Int16 GetUpdateDocMode() const
Definition: docsh.hxx:288
std::unique_ptr< sfx2::StyleManager > m_pStyleManager
Definition: docsh.hxx:76
css::uno::Reference< ooo::vba::word::XDocument > mxAutomationDocumentObject
Definition: docsh.hxx:95
Definition: doc.hxx:197
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
Definition: view.hxx:146
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
virtual std::shared_ptr< SfxDialogController > GetController() override
#define SFX_DECL_OBJECTFACTORY()
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
void InitDrawModelAndDocShell(SwDocShell *pSwDocShell, SwDrawModel *pSwDrawModel)
Definition: docshdrw.cxx:32
int SwFindDocShell(SfxObjectShellRef &xDocSh, SfxObjectShellLock &xLockRef, std::u16string_view rFileName, const OUString &rPasswd, const OUString &rFilter, sal_Int16 nVersion, SwDocShell *pDestSh)
Find the right DocShell and create a new one: The return value specifies what should happen to the Sh...
Definition: docsh2.cxx:1705
SotClipboardFormatId
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3254
HiddenInformation
SfxObjectCreateMode
SfxModelFlags
#define SFX_DECL_INTERFACE(nId)
#define SW_DOCSHELL
Definition: shellid.hxx:37
SfxStyleFamily
SfxStyleSearchBits
#define SW_DLLPUBLIC
Definition: swdllapi.h:28