Line data Source code
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 _SWDOCSH_HXX
20 : #define _SWDOCSH_HXX
21 :
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>
31 :
32 : #include <svl/lstner.hxx>
33 : #include <svtools/embedhlp.hxx>
34 :
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;
54 :
55 :
56 : class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener
57 : {
58 : SwDoc* pDoc; ///< Document.
59 : rtl::Reference< SfxStyleSheetBasePool > mxBasePool; ///< Passing through for formats.
60 : FontList* pFontList; ///< Current Fontlist.
61 :
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. */
66 :
67 : SwView* pView;
68 : SwWrtShell* pWrtShell;
69 :
70 : Timer aFinishedTimer; /**< Timer for checking graphics-links.
71 : If all are present, the doc is loaded completely. */
72 :
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
77 :
78 : /// Methods for access to doc.
79 : SW_DLLPRIVATE void AddLink();
80 : SW_DLLPRIVATE void RemoveLink();
81 :
82 : /// Catch hint for DocInfo.
83 : SW_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
84 :
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 );
93 :
94 : SW_DLLPRIVATE virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
95 :
96 :
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);
102 :
103 : /// Methods for StyleSheets
104 : SW_DLLPRIVATE sal_uInt16 Edit( const String &rName, const String& rParent, sal_uInt16 nFamily,
105 : sal_uInt16 nMask, sal_Bool bNew,
106 : sal_uInt16 nPageId = 0,
107 : SwWrtShell* pActShell = 0,
108 : sal_Bool bBasic = sal_False );
109 : SW_DLLPRIVATE sal_uInt16 Delete(const String &rName, sal_uInt16 nFamily);
110 : SW_DLLPRIVATE sal_uInt16 Hide(const String &rName, sal_uInt16 nFamily, bool bHidden);
111 : SW_DLLPRIVATE sal_uInt16 ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0,
112 : sal_uInt16 nMode = 0 );
113 : SW_DLLPRIVATE sal_uInt16 DoWaterCan( const String &rName, sal_uInt16 nFamily);
114 : SW_DLLPRIVATE sal_uInt16 UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
115 : SW_DLLPRIVATE sal_uInt16 MakeByExample(const String &rName,
116 : sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
117 :
118 : SW_DLLPRIVATE void InitDraw();
119 : SW_DLLPRIVATE void SubInitNew(); ///< for InitNew and HtmlSourceMode.
120 :
121 : SW_DLLPRIVATE void RemoveOLEObjects();
122 : SW_DLLPRIVATE void CalcLayoutForOLEObjects();
123 :
124 : SW_DLLPRIVATE void Init_Impl();
125 : SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
126 :
127 :
128 : using SfxObjectShell::GetVisArea;
129 : using SfxObjectShell::GetStyleFamilyBitmap;
130 :
131 : protected:
132 : /// override to update text fields
133 : virtual void DoFlushDocInfo();
134 :
135 : public:
136 : using SotObject::GetInterface;
137 :
138 : /// but we implement this ourselves.
139 10 : SFX_DECL_INTERFACE(SW_DOCSHELL)
140 41587 : SFX_DECL_OBJECTFACTORY()
141 : TYPEINFO();
142 :
143 : static SfxInterface *_GetInterface() { return GetStaticInterface(); }
144 :
145 : static rtl::OUString GetEventName( sal_Int32 nId );
146 :
147 : /// Doc is required for SO data exchange!
148 : SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
149 : SwDocShell( const sal_uInt64 i_nSfxCreationFlags );
150 : SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD );
151 : ~SwDocShell();
152 :
153 : /// OLE 2.0-notification.
154 : DECL_LINK( Ole2ModifiedHdl, void * );
155 :
156 : /// OLE-stuff.
157 : virtual void SetVisArea( const Rectangle &rRect );
158 : virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
159 : virtual Printer *GetDocumentPrinter();
160 : virtual OutputDevice* GetDocumentRefDev();
161 : virtual void OnDocumentPrinterChanged( Printer * pNewPrinter );
162 : virtual sal_uLong GetMiscStatus() const;
163 :
164 : virtual void PrepareReload();
165 : virtual void SetModified( sal_Bool = sal_True );
166 :
167 : /// Dispatcher
168 : void Execute(SfxRequest &);
169 : void ExecStyleSheet(SfxRequest&);
170 : void ExecDB(SfxRequest&);
171 :
172 : void GetState(SfxItemSet &);
173 : void StateAlways(SfxItemSet &);
174 : void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
175 :
176 : /// returns Doc. But be careful!
177 14030 : inline SwDoc* GetDoc() { return pDoc; }
178 : inline const SwDoc* GetDoc() const { return pDoc; }
179 : IDocumentDeviceAccess* getIDocumentDeviceAccess();
180 : const IDocumentSettingAccess* getIDocumentSettingAccess() const;
181 : IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess();
182 :
183 :
184 : void UpdateFontList();
185 : void UpdateChildWindows();
186 :
187 : /// global IO.
188 : virtual sal_Bool Save();
189 :
190 : /// For Style PI.
191 : virtual SfxStyleSheetBasePool* GetStyleSheetPool();
192 :
193 : /// For Organizer.
194 : virtual sal_Bool Insert(SfxObjectShell &rSource,
195 : sal_uInt16 nSourceIdx1,
196 : sal_uInt16 nSourceIdx2,
197 : sal_uInt16 nSourceIdx3,
198 : sal_uInt16& nIdx1,
199 : sal_uInt16& nIdx2,
200 : sal_uInt16& nIdx3,
201 : sal_uInt16& nRemovedIdx);
202 :
203 : virtual sal_Bool Remove(sal_uInt16 nIdx1,
204 : sal_uInt16 nIdx2 = INDEX_IGNORE,
205 : sal_uInt16 nIdx3 = INDEX_IGNORE);
206 :
207 : virtual Bitmap GetStyleFamilyBitmap( SfxStyleFamily eFamily );
208 :
209 : /// Set View for actions via Shell.
210 : void SetView(SwView* pVw);
211 0 : const SwView *GetView() const { return pView; }
212 7158 : SwView *GetView() { return pView; }
213 :
214 : /// Accress to the SwWrtShell belonging to SwView.
215 4899 : SwWrtShell *GetWrtShell() { return pWrtShell; }
216 : const SwWrtShell *GetWrtShell() const { return pWrtShell; }
217 :
218 : /// For Core - it knows the DocShell but not the WrtShell!
219 : SwFEShell *GetFEShell();
220 : const SwFEShell *GetFEShell() const
221 : { return ((SwDocShell*)this)->GetFEShell(); }
222 :
223 :
224 : /// For inserting document.
225 : Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
226 : SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
227 :
228 : virtual long DdeGetData( const String& rItem, const String& rMimeType,
229 : ::com::sun::star::uno::Any & rValue );
230 : virtual long DdeSetData( const String& rItem, const String& rMimeType,
231 : const ::com::sun::star::uno::Any & rValue );
232 : virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
233 : virtual void ReconnectDdeLink(SfxObjectShell& rServer);
234 :
235 : virtual void FillClass( SvGlobalName * pClassName,
236 : sal_uInt32 * pClipFormat,
237 : String * pAppName,
238 : String * pLongUserName,
239 : String * pUserName,
240 : sal_Int32 nFileFormat,
241 : sal_Bool bTemplate = sal_False ) const;
242 :
243 : virtual void LoadStyles( SfxObjectShell& rSource );
244 :
245 : void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument );
246 :
247 : /// Display dialog for page style. If required display column page.
248 : void FormatPage( const String& rPage,
249 : sal_uInt16 nPageId = 0,
250 : SwWrtShell* pActShell = 0 );
251 :
252 : // #i59688#
253 : /** linked graphics are now loaded on demand.
254 : Thus, loading of linked graphics no longer needed and necessary for
255 : the load of document being finished. */
256 :
257 : void LoadingFinished();
258 :
259 : /// Cancel transfer (called from SFX).
260 : virtual void CancelTransfers();
261 :
262 : /// Re-read Doc from Html-source.
263 : void ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView );
264 :
265 267 : sal_Int16 GetUpdateDocMode() const {return nUpdateDocMode;}
266 :
267 : /** Activate wait cursor for all windows of this document
268 : Optionally all dispatcher could be Locked
269 : Usually locking should be done using the class: SwWaitObject! */
270 : void EnterWait( sal_Bool bLockDispatcher );
271 : void LeaveWait( sal_Bool bLockDispatcher );
272 :
273 : void ToggleBrowserMode(sal_Bool bOn, SwView* pView);
274 :
275 : sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt,
276 : sal_Bool bUnoCall );
277 : void InvalidateModel();
278 : void ReactivateModel();
279 :
280 : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > GetEventNames();
281 :
282 : /// #i20883# Digital Signatures and Encryption
283 : virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
284 :
285 :
286 : /** #i42634# Overwrites SfxObjectShell::UpdateLinks
287 : This new function is necessary to trigger update of links in docs
288 : read by the binary filter: */
289 : virtual void UpdateLinks();
290 :
291 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
292 : GetController();
293 :
294 : SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
295 0 : SW_DLLPRIVATE sal_Bool IsTemplate() { return bIsATemplate; }
296 37 : SW_DLLPRIVATE void SetIsTemplate( bool bValue ) { bIsATemplate = bValue; }
297 :
298 : virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const;
299 :
300 : /** passwword protection for Writer (derived from SfxObjectShell)
301 : see also: FN_REDLINE_ON, FN_REDLINE_ON */
302 : virtual bool IsChangeRecording() const;
303 : virtual bool HasChangeRecordProtection() const;
304 : virtual void SetChangeRecording( bool bActivate );
305 : virtual bool SetProtectionPassword( const String &rPassword );
306 : virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
307 : };
308 :
309 : class Graphic;
310 : /// implemented in source/ui/docvw/romenu.cxx
311 : String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
312 :
313 : #endif
314 :
315 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|