xref: /AOO41X/main/sw/inc/docsh.hxx (revision 9dcd2d78ee6377e8ad1e2e01efd517f26f4562c3)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SWDOCSH_HXX
24 #define _SWDOCSH_HXX
25 
26 #include <rtl/ref.hxx>
27 #include <com/sun/star/frame/XController.hpp>
28 #include <com/sun/star/uno/Sequence.h>
29 #include <vcl/timer.hxx>
30 #include <sfx2/docfac.hxx>
31 #include <sfx2/objsh.hxx>
32 #include "swdllapi.h"
33 #include <swdll.hxx>
34 #include <shellid.hxx>
35 
36 #include <svl/lstner.hxx>
37 #include <svtools/embedhlp.hxx>
38 
39 class SwDoc;
40 class SfxDocumentInfoDialog;
41 class SfxStyleSheetBasePool;
42 class SfxInPlaceClient;
43 class FontList;
44 class SwView;
45 class SwWrtShell;
46 class SwFEShell;
47 class Reader;
48 class SwReader;
49 class SwCrsrShell;
50 class SwSrcView;
51 class SwPaM;
52 class SwgReaderOption;
53 class SwOLEObj;
54 class IDocumentDeviceAccess;
55 class IDocumentSettingAccess;
56 class IDocumentTimerAccess;
57 class IDocumentChartDataProviderAccess;
58 
59 
60 class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener
61 {
62     SwDoc*                  pDoc;           // Document
63     rtl::Reference< SfxStyleSheetBasePool > mxBasePool;     // Durchreiche fuer Formate
64     FontList*               pFontList;      // aktuelle FontListe
65 
66     // Nix geht ohne die WrtShell (historische Gruende)
67     // RuekwaertsPointer auf die View (historische Gruende)
68     // Dieser gilt solange bis im Activate ein neuer gesetzt wird
69     // oder dieser im Dtor der View geloescht wird
70     //
71     SwView*                 pView;
72     SwWrtShell*             pWrtShell;
73 
74     Timer                   aFinishedTimer; // Timer fuers ueberpriefen der
75                                             // Grafik-Links. Sind alle da,
76                                             // dann ist Doc voll. geladen
77 
78     //SvPersistRef            xOLEChildList;  // fuers RemoveOLEObjects
79     comphelper::EmbeddedObjectContainer*    pOLEChildList;
80     sal_Int16               nUpdateDocMode; // contains the com::sun::star::document::UpdateDocMode
81     bool                    bInUpdateFontList; //prevent nested calls of UpdateFontList
82     // Methoden fuer den Zugriff aufs Doc
83     SW_DLLPRIVATE void                  AddLink();
84     SW_DLLPRIVATE void                  RemoveLink();
85 
86     // Hint abfangen fuer DocInfo
87     SW_DLLPRIVATE virtual void          Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
88 
89     // FileIO
90     SW_DLLPRIVATE virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
91     SW_DLLPRIVATE virtual sal_Bool Load( SfxMedium& rMedium );
92     SW_DLLPRIVATE virtual sal_Bool LoadFrom( SfxMedium& rMedium );
93     SW_DLLPRIVATE virtual sal_Bool            ConvertFrom( SfxMedium &rMedium );
94     SW_DLLPRIVATE virtual sal_Bool            ConvertTo( SfxMedium &rMedium );
95     SW_DLLPRIVATE virtual sal_Bool SaveAs( SfxMedium& rMedium );
96     SW_DLLPRIVATE virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage );
97 
98     SW_DLLPRIVATE virtual sal_uInt16            PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False );
99 
100     // DocInfo dem Doc melden
101     //
102     SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog(
103                                     Window *pParent, const SfxItemSet &);
104     // OLE-Geraffel
105     SW_DLLPRIVATE virtual void          Draw( OutputDevice*, const JobSetup&, sal_uInt16);
106 
107     // Methoden fuer StyleSheets
108 
109     // @param nSlot
110     // Only used for nFamily == SFX_STYLE_FAMILY_PAGE. Identifies optional Slot by which the edit is triggered.
111     // Used to activate certain dialog pane
112     SW_DLLPRIVATE sal_uInt16 Edit(
113         const String &rName,
114         const String& rParent,
115         const sal_uInt16 nFamily,
116         sal_uInt16 nMask,
117         const sal_Bool bNew,
118         const sal_uInt16 nSlot = 0,
119         SwWrtShell* pActShell = 0,
120         const sal_Bool bBasic = sal_False );
121 
122     SW_DLLPRIVATE sal_uInt16                    Delete(const String &rName, sal_uInt16 nFamily);
123     SW_DLLPRIVATE sal_uInt16                    ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0,
124                                         sal_uInt16 nMode = 0 );
125     SW_DLLPRIVATE sal_uInt16                    DoWaterCan( const String &rName, sal_uInt16 nFamily);
126     SW_DLLPRIVATE sal_uInt16                    UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
127     SW_DLLPRIVATE sal_uInt16                    MakeByExample(const String &rName,
128                                             sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
129 
130     SW_DLLPRIVATE void                  InitDraw();
131     SW_DLLPRIVATE void                  SubInitNew();   // fuer InitNew und HtmlSourceModus
132 
133     SW_DLLPRIVATE void                  RemoveOLEObjects();
134     SW_DLLPRIVATE void                  CalcLayoutForOLEObjects();
135 
136     SW_DLLPRIVATE void                    Init_Impl();
137     SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
138 
139 
140     using SfxObjectShell::GetVisArea;
141     using SfxObjectShell::GetStyleFamilyBitmap;
142 
143 protected:
144     /// override to update text fields
145     virtual void                DoFlushDocInfo();
146 
147 public:
148     using SotObject::GetInterface;
149 
150     // aber selbst implementieren
151     SFX_DECL_INTERFACE(SW_DOCSHELL)
152     SFX_DECL_OBJECTFACTORY()
153     TYPEINFO();
154 
155     static SfxInterface *_GetInterface() { return GetStaticInterface(); }
156 
157     static rtl::OUString GetEventName( sal_Int32 nId );
158 
159     //Das Doc wird fuer SO-Datenaustausch benoetigt!
160     SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
161     SwDocShell( const sal_uInt64 i_nSfxCreationFlags );
162     SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD );
163     ~SwDocShell();
164 
165     // OLE 2.0-Benachrichtigung
166     DECL_LINK( Ole2ModifiedHdl, void * );
167 
168     // OLE-Geraffel
169     virtual void      SetVisArea( const Rectangle &rRect );
170     virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
171     virtual Printer  *GetDocumentPrinter();
172     virtual OutputDevice* GetDocumentRefDev();
173     virtual void      OnDocumentPrinterChanged( Printer * pNewPrinter );
174     virtual sal_uLong     GetMiscStatus() const;
175 
176     virtual void            PrepareReload();
177     virtual void            SetModified( sal_Bool = sal_True );
178 
179     // Dispatcher
180     void                    Execute(SfxRequest &);
181     void                    ExecStyleSheet(SfxRequest&);
182     void                    ExecDB(SfxRequest&);
183 
184     void                    GetState(SfxItemSet &);
185     void                    StateAlways(SfxItemSet &);
186     void                    StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
187 
188     // Doc rausreichen aber VORSICHT
189     inline SwDoc*                   GetDoc() { return pDoc; }
190     inline const SwDoc*             GetDoc() const { return pDoc; }
191     IDocumentDeviceAccess*          getIDocumentDeviceAccess();
192     const IDocumentSettingAccess*   getIDocumentSettingAccess() const;
193     IDocumentChartDataProviderAccess*       getIDocumentChartDataProviderAccess();
194 
195 
196     void                    UpdateFontList();
197     void                    UpdateChildWindows();
198 
199     // globaler IO
200     virtual sal_Bool            Save();
201 
202     // fuer VorlagenPI
203     virtual SfxStyleSheetBasePool*  GetStyleSheetPool();
204 
205     // Fuer Organizer
206     virtual sal_Bool Insert(SfxObjectShell &rSource,
207                         sal_uInt16  nSourceIdx1,
208                         sal_uInt16  nSourceIdx2,
209                         sal_uInt16  nSourceIdx3,
210                         sal_uInt16& nIdx1,
211                         sal_uInt16& nIdx2,
212                         sal_uInt16& nIdx3,
213                         sal_uInt16& nRemovedIdx);
214 
215     virtual sal_Bool Remove(sal_uInt16 nIdx1,
216                         sal_uInt16 nIdx2 = INDEX_IGNORE,
217                         sal_uInt16 nIdx3 = INDEX_IGNORE);
218 
219     virtual Bitmap      GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode );
220 
221     // View setzen fuer Aktionen ueber Shell
222     void          SetView(SwView* pVw);
223     const SwView *GetView() const { return pView; }
224     SwView       *GetView()       { return pView; }
225 
226     // Zugriff auf die zur SwView gehoerige SwWrtShell
227           SwWrtShell *GetWrtShell()       { return pWrtShell; }
228     const SwWrtShell *GetWrtShell() const { return pWrtShell; }
229 
230     // fuer die Core - die kennt die DocShell aber keine WrtShell!
231           SwFEShell *GetFEShell();
232     const SwFEShell *GetFEShell() const
233                 { return ((SwDocShell*)this)->GetFEShell(); }
234 
235 
236     // Fuer Einfuegen Dokument
237     Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
238                             SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
239 
240     virtual long DdeGetData( const String& rItem, const String& rMimeType,
241                              ::com::sun::star::uno::Any & rValue );
242     virtual long DdeSetData( const String& rItem, const String& rMimeType,
243                                 const ::com::sun::star::uno::Any & rValue );
244     virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
245     virtual void FillClass( SvGlobalName * pClassName,
246                                    sal_uInt32 * pClipFormat,
247                                    String * pAppName,
248                                    String * pLongUserName,
249                                    String * pUserName,
250                                    sal_Int32 nFileFormat,
251                                    sal_Bool bTemplate = sal_False ) const;
252 
253     virtual void LoadStyles( SfxObjectShell& rSource );
254 
255     void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument );
256 
257     // Show page style format dialog
258     // @param nSlot
259     // Identifies slot by which the dialog is triggered. Used to activate certain dialog pane
260     void FormatPage(
261         const String& rPage,
262         const sal_uInt16 nSlot,
263         SwWrtShell& rActShell );
264 
265     // --> OD 2006-11-07 #i59688#
266     // linked graphics are now loaded on demand.
267     // Thus, loading of linked graphics no longer needed and necessary for
268     // the load of document being finished.
269 //    // Timer starten fuers ueberpruefen der Grafik-Links. Sind alle
270 //    // vollstaendig geladen, dann ist das Doc fertig
271 //    void StartLoadFinishedTimer();
272     void LoadingFinished();
273     // <--
274 
275     // eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen)
276     virtual void CancelTransfers();
277 
278     // Doc aus Html-Source neu laden
279     void    ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView );
280 
281     sal_Int16   GetUpdateDocMode() const {return nUpdateDocMode;}
282 
283     //Activate wait cursor for all windows of this document
284     //Optionally all dispatcher could be Locked
285     //Usually locking should be done using the class: SwWaitObject!
286     void EnterWait( sal_Bool bLockDispatcher );
287     void LeaveWait( sal_Bool bLockDispatcher );
288 
289     void ToggleBrowserMode(sal_Bool bOn, SwView* pView);
290 
291     sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt,
292                                 sal_Bool bUnoCall );
293     void InvalidateModel();
294     void ReactivateModel();
295 
296     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  GetEventNames();
297 
298     // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption
299     virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
300     // <--
301 
302     // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks
303     // This new function is necessary to trigger update of links in docs
304     // read by the binary filter:
305     virtual void UpdateLinks();
306     // <--
307 
308     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
309                                 GetController();
310 
311     SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
312 
313     virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const;
314 
315     // passwword protection for Writer (derived from SfxObjectShell)
316     // see also:    FN_REDLINE_ON, FN_REDLINE_ON
317     virtual bool    IsChangeRecording() const;
318     virtual bool    HasChangeRecordProtection() const;
319     virtual void    SetChangeRecording( bool bActivate );
320     virtual bool    SetProtectionPassword( const String &rPassword );
321     virtual bool    GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
322 };
323 
324 class Graphic;
325 //implemented in source/ui/docvw/romenu.cxx
326 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
327 
328 #endif
329