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 
35 class SwDoc;
37 class SfxInPlaceClient;
38 class FontList;
39 class SwEditShell;
40 class SwView;
41 class SwWrtShell;
42 class SwFEShell;
43 class Reader;
44 class SwReader;
45 typedef std::unique_ptr<SwReader, o3tl::default_delete<SwReader>> SwReaderPtr;
46 class SwCursorShell;
47 class SwSrcView;
48 class SwPaM;
49 class SwgReaderOption;
52 class SwDocShell;
53 class SwDrawModel;
54 class SwViewShell;
55 namespace svt
56 {
57 class EmbeddedObjectRef;
58 }
59 namespace com { namespace sun { namespace star { namespace frame { class XController; } } } }
60 namespace ooo { namespace vba { class XSinkCaller; } }
61 namespace ooo { namespace vba { namespace 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
65 void 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::unique_ptr<SfxDocumentInfoDialog> CreateDocumentInfoDialog(weld::Window* pParent,
121  const SfxItemSet &rSet) override;
123  SAL_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16 nAspect) override;
124 
126 
130  SAL_DLLPRIVATE void Edit(
131  const OUString &rName,
132  const OUString& rParent,
133  const SfxStyleFamily nFamily,
134  SfxStyleSearchBits nMask,
135  const bool bNew,
136  const OString& sPageId,
137  SwWrtShell* pActShell,
138  SfxRequest* pRequest = nullptr,
139  sal_uInt16 nSlot = 0);
140 
141  SAL_DLLPRIVATE void Delete(const OUString &rName, SfxStyleFamily nFamily);
142  SAL_DLLPRIVATE void Hide(const OUString &rName, SfxStyleFamily nFamily, bool bHidden);
143  SAL_DLLPRIVATE SfxStyleFamily ApplyStyles(const OUString &rName,
144  const SfxStyleFamily nFamily,
145  SwWrtShell* pShell,
146  sal_uInt16 nMode);
147  SAL_DLLPRIVATE SfxStyleFamily DoWaterCan( const OUString &rName, SfxStyleFamily nFamily);
148  SAL_DLLPRIVATE void UpdateStyle(const OUString &rName, SfxStyleFamily nFamily, SwWrtShell* pShell);
149  SAL_DLLPRIVATE void MakeByExample(const OUString &rName,
150  SfxStyleFamily nFamily, SfxStyleSearchBits nMask, SwWrtShell* pShell);
151 
152  SAL_DLLPRIVATE void SubInitNew();
153 
154  SAL_DLLPRIVATE void RemoveOLEObjects();
155  SAL_DLLPRIVATE void CalcLayoutForOLEObjects();
156 
157  SAL_DLLPRIVATE void Init_Impl();
158 
160 
161 protected:
163  virtual void DoFlushDocInfo() override;
164 
165 public:
168  SFX_DECL_OBJECTFACTORY()
169 
170 private:
172  static void InitInterface_Impl();
173 
174 public:
175  static OUString GetEventName( sal_Int32 nId );
176 
179  SwDocShell( SfxModelFlags i_nSfxCreationFlags );
180  SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode );
181  virtual ~SwDocShell() override;
182 
184  DECL_LINK( Ole2ModifiedHdl, bool, void );
185 
187  virtual void SetVisArea( const tools::Rectangle &rRect ) override;
188  virtual tools::Rectangle GetVisArea( sal_uInt16 nAspect ) const override;
189  virtual Printer *GetDocumentPrinter() override;
190  virtual OutputDevice* GetDocumentRefDev() override;
191  virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ) override;
192 
193  virtual void SetModified( bool = true ) override;
194 
196  void Execute(SfxRequest &);
197  void ExecStyleSheet(SfxRequest&);
198 
199  void GetState(SfxItemSet &);
200  void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = nullptr );
201 
203  SwDoc* GetDoc() { return m_xDoc.get(); }
204  const SwDoc* GetDoc() const { return m_xDoc.get(); }
205  IDocumentDeviceAccess& getIDocumentDeviceAccess();
206  IDocumentChartDataProviderAccess& getIDocumentChartDataProviderAccess();
207 
208  void UpdateFontList();
209  void UpdateChildWindows();
210 
212  virtual bool Save() override;
213 
215  virtual SfxStyleSheetBasePool* GetStyleSheetPool() override;
216  virtual sfx2::StyleManager* GetStyleManager() override;
217 
219  void SetView(SwView* pVw);
220  const SwView *GetView() const { return m_pView; }
221  SwView *GetView() { return m_pView; }
222 
224  SwWrtShell *GetWrtShell() { return m_pWrtShell; }
225  const SwWrtShell *GetWrtShell() const { return m_pWrtShell; }
226  // Same as GetWrtShell, but return pointer to SwEditShell base of
227  // (potentially incomplete) SwWrtShell:
228  SwEditShell * GetEditShell();
229 
231  SwFEShell *GetFEShell();
232  const SwFEShell *GetFEShell() const
233  { return const_cast<SwDocShell*>(this)->GetFEShell(); }
234 
236  Reader* StartConvertFrom(SfxMedium& rMedium, SwReaderPtr& rpRdr,
237  SwCursorShell const * pCursorSh = nullptr, SwPaM* pPaM = nullptr);
238 
239 #if defined(_WIN32)
240  virtual bool DdeGetData( const OUString& rItem, const OUString& rMimeType,
241  css::uno::Any & rValue ) override;
242  virtual bool DdeSetData( const OUString& rItem, const OUString& rMimeType,
243  const css::uno::Any & rValue ) override;
244 #endif
245  virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const OUString& rItem ) override;
246  virtual void ReconnectDdeLink(SfxObjectShell& rServer) override;
247 
248  virtual void FillClass( SvGlobalName * pClassName,
249  SotClipboardFormatId * pClipFormat,
250  OUString * pLongUserName,
251  sal_Int32 nFileFormat,
252  bool bTemplate = false ) const override;
253 
254  virtual std::set<Color> GetDocColors() override;
255 
256  virtual void LoadStyles( SfxObjectShell& rSource ) override;
257 
258  void LoadStyles_( SfxObjectShell& rSource, bool bPreserveCurrentDocument );
259 
263  void FormatPage(
264  const OUString& rPage,
265  const OString& rPageId,
266  SwWrtShell& rActShell,
267  SfxRequest* pRequest = nullptr);
268 
269  // #i59688#
274  void LoadingFinished();
275  virtual void SetFormatSpecificCompatibilityOptions( const OUString& rFilterTypeName ) override;
276 
278  virtual void CancelTransfers() override;
279 
281  void ReloadFromHtml( const OUString& rStreamName, SwSrcView* pSrcView );
282 
283  sal_Int16 GetUpdateDocMode() const { return m_nUpdateDocMode; }
284 
285  void ToggleLayoutMode(SwView* pView);
286 
287  ErrCode LoadStylesFromFile( const OUString& rURL, SwgReaderOption const & rOpt,
288  bool bUnoCall );
289  void InvalidateModel();
290  void ReactivateModel();
291 
292  virtual css::uno::Sequence< OUString > GetEventNames() override;
293 
296 
300  virtual void UpdateLinks() override;
301 
302  css::uno::Reference< css::frame::XController >
303  GetController();
304 
305  SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
306  SAL_DLLPRIVATE bool IsTemplate() const { return m_IsATemplate; }
307  SAL_DLLPRIVATE void SetIsTemplate( bool bValue ) { m_IsATemplate = bValue; }
308 
309  virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const override;
310 
313  virtual bool IsChangeRecording() const override;
314  virtual bool HasChangeRecordProtection() const override;
315  virtual void SetChangeRecording( bool bActivate ) override;
316  virtual void SetProtectionPassword( const OUString &rPassword ) override;
317  virtual bool GetProtectionHash( /*out*/ css::uno::Sequence< sal_Int8 > &rPasswordHash ) override;
318 
319  void RegisterAutomationDocumentEventsCaller(css::uno::Reference< ooo::vba::XSinkCaller > const& xCaller);
320  void CallAutomationDocumentEventSinks(const OUString& Method, css::uno::Sequence< css::uno::Any >& Arguments);
321  void RegisterAutomationDocumentObject(css::uno::Reference< ooo::vba::word::XDocument > const& xDocument);
322 
324  {
325  std::vector<SwViewShell*> m_aViewWasUnLocked;
326 
327  public:
328  explicit LockAllViewsGuard(SwViewShell* pViewShell);
330  };
331  // Lock all unlocked views, and returns a guard object which unlocks those views when destructed
332  std::unique_ptr<LockAllViewsGuard> LockAllViews();
333 };
334 
342 int SwFindDocShell( SfxObjectShellRef& xDocSh,
343  SfxObjectShellLock& xLockRef,
344  const OUString& rFileName,
345  const OUString& rPasswd,
346  const OUString& rFilter,
347  sal_Int16 nVersion,
348  SwDocShell* pDestSh );
349 
350 #endif
351 
352 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int16 GetUpdateDocMode() const
Definition: docsh.hxx:283
const SwDoc * GetDoc() const
Definition: docsh.hxx:204
virtual bool Load(SfxMedium &rMedium)
std::unique_ptr< comphelper::EmbeddedObjectContainer > m_pOLEChildList
Definition: docsh.hxx:86
virtual void FillClass(SvGlobalName *pClassName, SotClipboardFormatId *pFormat, OUString *pFullTypeName, sal_Int32 nVersion, bool bTemplate=false) const =0
css::uno::Reference< ooo::vba::XSinkCaller > mxAutomationDocumentEventsCaller
Definition: docsh.hxx:94
Definition: doc.hxx:185
virtual bool SaveCompleted(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual bool SaveAs(SfxMedium &rMedium)
#define SW_DOCSHELL
Definition: shellid.hxx:37
void InitDrawModelAndDocShell(SwDocShell *pSwDocShell, SwDrawModel *pSwDrawModel)
Definition: docshdrw.cxx:36
std::unique_ptr< sfx2::StyleManager > m_pStyleManager
Definition: docsh.hxx:76
virtual sfx2::StyleManager * GetStyleManager()
virtual SfxStyleSheetBasePool * GetStyleSheetPool()
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
virtual bool PrepareClose(bool bUI=true)
virtual void DoFlushDocInfo()
virtual void CancelTransfers()
virtual bool Save()
SAL_DLLPRIVATE bool IsTemplate() const
Definition: docsh.hxx:306
UpdateLinks
Definition: linkenum.hxx:22
virtual void SetChangeRecording(bool bActivate)
SfxStyleFamily
SotClipboardFormatId
std::unique_ptr< SwReader, o3tl::default_delete< SwReader > > SwReaderPtr
Definition: docsh.hxx:44
virtual void ReconnectDdeLink(SfxObjectShell &rServer)
virtual bool IsChangeRecording() const
virtual const sfx2::IXmlIdRegistry * GetXmlIdRegistry() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual std::unique_ptr< SfxDocumentInfoDialog > CreateDocumentInfoDialog(weld::Window *pParent, const SfxItemSet &rItemSet)
virtual bool HasChangeRecordProtection() const
int SwFindDocShell(SfxObjectShellRef &xDocSh, SfxObjectShellLock &xLockRef, const OUString &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:1664
SfxObjectCreateMode
virtual css::uno::Sequence< OUString > GetEventNames()
std::vector< SwViewShell * > m_aViewWasUnLocked
Definition: docsh.hxx:325
virtual bool LoadFrom(SfxMedium &rMedium)
virtual void SetFormatSpecificCompatibilityOptions(const OUString &)
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:224
virtual ::sfx2::SvLinkSource * DdeCreateLinkSource(const OUString &rItem)
SwView * GetView()
Definition: docsh.hxx:221
rtl::Reference< SwDoc > m_xDoc
Document.
Definition: docsh.hxx:71
std::unique_ptr< FontList > m_pFontList
Current Fontlist.
Definition: docsh.hxx:73
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool m_IsATemplate
prevent nested calls of UpdateFontList
Definition: docsh.hxx:88
const tools::Rectangle & GetVisArea() const
virtual HiddenInformation GetHiddenInformationState(HiddenInformation nStates)
SAL_DLLPRIVATE void SetIsTemplate(bool bValue)
Definition: docsh.hxx:307
virtual bool InitNew(const css::uno::Reference< css::embed::XStorage > &xStorage)
virtual void LoadStyles(SfxObjectShell &rSource)
bool m_IsRemovedInvisibleContent
whether SID_MAIL_PREPAREEXPORT removed content that SID_MAIL_EXPORT_FINISHED needs to restore ...
Definition: docsh.hxx:90
virtual bool ConvertTo(SfxMedium &rMedium)
rtl::Reference< SfxStyleSheetBasePool > m_xBasePool
Passing through for formats.
Definition: docsh.hxx:72
Provides access to the formatting devices of a document.
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
virtual std::set< Color > GetDocColors()
virtual void Draw(OutputDevice *, const JobSetup &rSetup, sal_uInt16 nAspect)=0
SwView * m_pView
For "historical reasons" nothing can be done without the WrtShell.
Definition: docsh.hxx:83
bool m_IsInUpdateFontList
prevent nested calls of UpdateFontList
Definition: docsh.hxx:74
virtual bool GetProtectionHash(css::uno::Sequence< sal_Int8 > &rPasswordHash)
const SwFEShell * GetFEShell() const
Definition: docsh.hxx:232
SfxModelFlags
SwWrtShell * m_pWrtShell
Definition: docsh.hxx:84
virtual void SetProtectionPassword(const OUString &rPassword)
const SwWrtShell * GetWrtShell() const
Definition: docsh.hxx:225
sal_Int16 m_nUpdateDocMode
contains the css::document::UpdateDocMode
Definition: docsh.hxx:87
Give access to the data-provider for chart.
const SwView * GetView() const
Definition: docsh.hxx:220
virtual bool InsertGeneratedStream(SfxMedium &rMedium, css::uno::Reference< css::text::XTextRange > const &xInsertPosition)
HiddenInformation
virtual bool ConvertFrom(SfxMedium &rMedium)
SfxStyleSearchBits
Definition: view.hxx:146
css::uno::Reference< ooo::vba::word::XDocument > mxAutomationDocumentObject
Definition: docsh.hxx:95
#define SFX_DECL_INTERFACE(nId)