bump product version to 4.1.6.2
[LibreOffice.git] / sw / inc / docsh.hxx
blob4f1a43d5324331dc1dc3e6800c23ad26f4f9428e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef _SWDOCSH_HXX
20 #define _SWDOCSH_HXX
22 #include <rtl/ref.hxx>
23 #include <com/sun/star/frame/XController.hpp>
24 #include <com/sun/star/uno/Sequence.h>
25 #include <vcl/timer.hxx>
26 #include <sfx2/docfac.hxx>
27 #include <sfx2/objsh.hxx>
28 #include "swdllapi.h"
29 #include <swdll.hxx>
30 #include <shellid.hxx>
32 #include <svl/lstner.hxx>
33 #include <svtools/embedhlp.hxx>
35 class SwDoc;
36 class SfxDocumentInfoDialog;
37 class SfxStyleSheetBasePool;
38 class SfxInPlaceClient;
39 class FontList;
40 class SwView;
41 class SwWrtShell;
42 class SwFEShell;
43 class Reader;
44 class SwReader;
45 class SwCrsrShell;
46 class SwSrcView;
47 class SwPaM;
48 class SwgReaderOption;
49 class SwOLEObj;
50 class IDocumentDeviceAccess;
51 class IDocumentSettingAccess;
52 class IDocumentTimerAccess;
53 class IDocumentChartDataProviderAccess;
56 class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener
58 SwDoc* pDoc; ///< Document.
59 rtl::Reference< SfxStyleSheetBasePool > mxBasePool; ///< Passing through for formats.
60 FontList* pFontList; ///< Current Fontlist.
62 /** For "historical reasons" nothing can be done without the WrtShell.
63 Back-pointer on View (again "for historical reasons").
64 Back-pointer is valid until in Activate a new one is set
65 or until it is deleted in the View's Dtor. */
67 SwView* pView;
68 SwWrtShell* pWrtShell;
70 Timer aFinishedTimer; /**< Timer for checking graphics-links.
71 If all are present, the doc is loaded completely. */
73 comphelper::EmbeddedObjectContainer* pOLEChildList;
74 sal_Int16 nUpdateDocMode; ///< contains the com::sun::star::document::UpdateDocMode
75 bool bInUpdateFontList; ///< prevent nested calls of UpdateFontList
76 bool bIsATemplate; ///< prevent nested calls of UpdateFontList
78 /// Methods for access to doc.
79 SW_DLLPRIVATE void AddLink();
80 SW_DLLPRIVATE void RemoveLink();
82 /// Catch hint for DocInfo.
83 SW_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
85 /// FileIO
86 SW_DLLPRIVATE virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
87 SW_DLLPRIVATE virtual sal_Bool Load( SfxMedium& rMedium );
88 SW_DLLPRIVATE virtual sal_Bool LoadFrom( SfxMedium& rMedium );
89 SW_DLLPRIVATE virtual sal_Bool ConvertFrom( SfxMedium &rMedium );
90 SW_DLLPRIVATE virtual sal_Bool ConvertTo( SfxMedium &rMedium );
91 SW_DLLPRIVATE virtual sal_Bool SaveAs( SfxMedium& rMedium );
92 SW_DLLPRIVATE virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
94 SW_DLLPRIVATE virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
97 /// Make DocInfo known to the Doc.
98 SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog(
99 Window *pParent, const SfxItemSet &);
100 /// OLE-stuff
101 SW_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16);
103 /// Methods for StyleSheets
105 // @param nSlot
106 // Only used for nFamily == SFX_STYLE_FAMILY_PAGE. Identifies optional Slot by which the edit is triggered.
107 // Used to activate certain dialog pane
108 SW_DLLPRIVATE sal_uInt16 Edit(
109 const String &rName,
110 const String& rParent,
111 const sal_uInt16 nFamily,
112 sal_uInt16 nMask,
113 const sal_Bool bNew,
114 const sal_uInt16 nSlot = 0,
115 SwWrtShell* pActShell = 0,
116 const sal_Bool bBasic = sal_False );
118 SW_DLLPRIVATE sal_uInt16 Delete(const String &rName, sal_uInt16 nFamily);
119 SW_DLLPRIVATE sal_uInt16 Hide(const String &rName, sal_uInt16 nFamily, bool bHidden);
120 SW_DLLPRIVATE sal_uInt16 ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0,
121 sal_uInt16 nMode = 0 );
122 SW_DLLPRIVATE sal_uInt16 DoWaterCan( const String &rName, sal_uInt16 nFamily);
123 SW_DLLPRIVATE sal_uInt16 UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
124 SW_DLLPRIVATE sal_uInt16 MakeByExample(const String &rName,
125 sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
127 SW_DLLPRIVATE void InitDraw();
128 SW_DLLPRIVATE void SubInitNew(); ///< for InitNew and HtmlSourceMode.
130 SW_DLLPRIVATE void RemoveOLEObjects();
131 SW_DLLPRIVATE void CalcLayoutForOLEObjects();
133 SW_DLLPRIVATE void Init_Impl();
134 SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
137 using SfxObjectShell::GetVisArea;
138 using SfxObjectShell::GetStyleFamilyBitmap;
140 protected:
141 /// override to update text fields
142 virtual void DoFlushDocInfo();
144 public:
145 using SotObject::GetInterface;
147 /// but we implement this ourselves.
148 SFX_DECL_INTERFACE(SW_DOCSHELL)
149 SFX_DECL_OBJECTFACTORY()
150 TYPEINFO();
152 static SfxInterface *_GetInterface() { return GetStaticInterface(); }
154 static OUString GetEventName( sal_Int32 nId );
156 /// Doc is required for SO data exchange!
157 SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
158 SwDocShell( const sal_uInt64 i_nSfxCreationFlags );
159 SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD );
160 ~SwDocShell();
162 /// OLE 2.0-notification.
163 DECL_LINK( Ole2ModifiedHdl, void * );
165 /// OLE-stuff.
166 virtual void SetVisArea( const Rectangle &rRect );
167 virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
168 virtual Printer *GetDocumentPrinter();
169 virtual OutputDevice* GetDocumentRefDev();
170 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
171 virtual sal_uLong GetMiscStatus() const;
173 virtual void PrepareReload();
174 virtual void SetModified( sal_Bool = sal_True );
176 /// Dispatcher
177 void Execute(SfxRequest &);
178 void ExecStyleSheet(SfxRequest&);
179 void ExecDB(SfxRequest&);
181 void GetState(SfxItemSet &);
182 void StateAlways(SfxItemSet &);
183 void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
185 /// returns Doc. But be careful!
186 inline SwDoc* GetDoc() { return pDoc; }
187 inline const SwDoc* GetDoc() const { return pDoc; }
188 IDocumentDeviceAccess* getIDocumentDeviceAccess();
189 const IDocumentSettingAccess* getIDocumentSettingAccess() const;
190 IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
193 void UpdateFontList();
194 void UpdateChildWindows();
196 /// global IO.
197 virtual sal_Bool Save();
199 /// For Style PI.
200 virtual SfxStyleSheetBasePool* GetStyleSheetPool();
202 /// For Organizer.
203 virtual sal_Bool Insert(SfxObjectShell &rSource,
204 sal_uInt16 nSourceIdx1,
205 sal_uInt16 nSourceIdx2,
206 sal_uInt16 nSourceIdx3,
207 sal_uInt16& nIdx1,
208 sal_uInt16& nIdx2,
209 sal_uInt16& nIdx3,
210 sal_uInt16& nRemovedIdx);
212 virtual sal_Bool Remove(sal_uInt16 nIdx1,
213 sal_uInt16 nIdx2 = INDEX_IGNORE,
214 sal_uInt16 nIdx3 = INDEX_IGNORE);
216 virtual Bitmap GetStyleFamilyBitmap( SfxStyleFamily eFamily );
218 /// Set View for actions via Shell.
219 void SetView(SwView* pVw);
220 const SwView *GetView() const { return pView; }
221 SwView *GetView() { return pView; }
223 /// Accress to the SwWrtShell belonging to SwView.
224 SwWrtShell *GetWrtShell() { return pWrtShell; }
225 const SwWrtShell *GetWrtShell() const { return pWrtShell; }
227 /// For Core - it knows the DocShell but not the WrtShell!
228 SwFEShell *GetFEShell();
229 const SwFEShell *GetFEShell() const
230 { return ((SwDocShell*)this)->GetFEShell(); }
233 /// For inserting document.
234 Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
235 SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
237 virtual long DdeGetData( const String& rItem, const String& rMimeType,
238 ::com::sun::star::uno::Any & rValue );
239 virtual long DdeSetData( const String& rItem, const String& rMimeType,
240 const ::com::sun::star::uno::Any & rValue );
241 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
242 virtual void ReconnectDdeLink(SfxObjectShell& rServer);
244 virtual void FillClass( SvGlobalName * pClassName,
245 sal_uInt32 * pClipFormat,
246 OUString * pAppName,
247 OUString * pLongUserName,
248 OUString * pUserName,
249 sal_Int32 nFileFormat,
250 sal_Bool bTemplate = sal_False ) const;
252 virtual void LoadStyles( SfxObjectShell& rSource );
254 void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument );
256 // Show page style format dialog
257 // @param nSlot
258 // Identifies slot by which the dialog is triggered. Used to activate certain dialog pane
259 void FormatPage(
260 const String& rPage,
261 const sal_uInt16 nSlot,
262 SwWrtShell& rActShell );
264 // #i59688#
265 /** linked graphics are now loaded on demand.
266 Thus, loading of linked graphics no longer needed and necessary for
267 the load of document being finished. */
269 void LoadingFinished();
271 /// Cancel transfer (called from SFX).
272 virtual void CancelTransfers();
274 /// Re-read Doc from Html-source.
275 void ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView );
277 sal_Int16 GetUpdateDocMode() const {return nUpdateDocMode;}
279 /** Activate wait cursor for all windows of this document
280 Optionally all dispatcher could be Locked
281 Usually locking should be done using the class: SwWaitObject! */
282 void EnterWait( sal_Bool bLockDispatcher );
283 void LeaveWait( sal_Bool bLockDispatcher );
285 void ToggleBrowserMode(sal_Bool bOn, SwView* pView);
287 sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt,
288 sal_Bool bUnoCall );
289 void InvalidateModel();
290 void ReactivateModel();
292 virtual ::com::sun::star::uno::Sequence< OUString > GetEventNames();
294 /// #i20883# Digital Signatures and Encryption
295 virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
298 /** #i42634# Overwrites SfxObjectShell::UpdateLinks
299 This new function is necessary to trigger update of links in docs
300 read by the binary filter: */
301 virtual void UpdateLinks();
303 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
304 GetController();
306 SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
307 SW_DLLPRIVATE sal_Bool IsTemplate() { return bIsATemplate; }
308 SW_DLLPRIVATE void SetIsTemplate( bool bValue ) { bIsATemplate = bValue; }
310 virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const;
312 /** passwword protection for Writer (derived from SfxObjectShell)
313 see also: FN_REDLINE_ON, FN_REDLINE_ON */
314 virtual bool IsChangeRecording() const;
315 virtual bool HasChangeRecordProtection() const;
316 virtual void SetChangeRecording( bool bActivate );
317 virtual bool SetProtectionPassword( const String &rPassword );
318 virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
321 class Graphic;
322 /// implemented in source/ui/docvw/romenu.cxx
323 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
325 #endif
327 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */