xref: /AOO41X/main/sw/inc/docsh.hxx (revision 03c97e340010506c11d4ffaab7f577e5f7050fe6)
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     SW_DLLPRIVATE sal_uInt16                    Edit( const String &rName, const String& rParent, sal_uInt16 nFamily,
109                                     sal_uInt16 nMask, sal_Bool bNew,
110                                     sal_Bool bColumn = sal_False,
111                                     SwWrtShell* pActShell = 0,
112                                     sal_Bool bBasic = sal_False );
113     SW_DLLPRIVATE sal_uInt16                    Delete(const String &rName, sal_uInt16 nFamily);
114     SW_DLLPRIVATE sal_uInt16                    ApplyStyles(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0,
115                                         sal_uInt16 nMode = 0 );
116     SW_DLLPRIVATE sal_uInt16                    DoWaterCan( const String &rName, sal_uInt16 nFamily);
117     SW_DLLPRIVATE sal_uInt16                    UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0);
118     SW_DLLPRIVATE sal_uInt16                    MakeByExample(const String &rName,
119                                             sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0);
120 
121     SW_DLLPRIVATE void                  InitDraw();
122     SW_DLLPRIVATE void                  SubInitNew();   // fuer InitNew und HtmlSourceModus
123 
124     SW_DLLPRIVATE void                  RemoveOLEObjects();
125     SW_DLLPRIVATE void                  CalcLayoutForOLEObjects();
126 
127     SW_DLLPRIVATE void                    Init_Impl();
128     SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* );
129 
130 
131     using SfxObjectShell::GetVisArea;
132     using SfxObjectShell::GetStyleFamilyBitmap;
133 
134 protected:
135     /// override to update text fields
136     virtual void                DoFlushDocInfo();
137 
138 public:
139     using SotObject::GetInterface;
140 
141     // aber selbst implementieren
142     SFX_DECL_INTERFACE(SW_DOCSHELL)
143     SFX_DECL_OBJECTFACTORY()
144     TYPEINFO();
145 
146     static SfxInterface *_GetInterface() { return GetStaticInterface(); }
147 
148     static rtl::OUString GetEventName( sal_Int32 nId );
149 
150     static void InitDefaultFontAttr( SwDoc* pDoc ); //#115580# added at 2011/11/28
151 
152     //Das Doc wird fuer SO-Datenaustausch benoetigt!
153     SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED );
154     SwDocShell( const sal_uInt64 i_nSfxCreationFlags );
155     SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD );
156     ~SwDocShell();
157 
158     // OLE 2.0-Benachrichtigung
159     DECL_LINK( Ole2ModifiedHdl, void * );
160 
161     // OLE-Geraffel
162     virtual void      SetVisArea( const Rectangle &rRect );
163     virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const;
164     virtual Printer  *GetDocumentPrinter();
165     virtual OutputDevice* GetDocumentRefDev();
166     virtual void      OnDocumentPrinterChanged( Printer * pNewPrinter );
167     virtual sal_uLong     GetMiscStatus() const;
168 
169     virtual void            PrepareReload();
170     virtual void            SetModified( sal_Bool = sal_True );
171 
172     // Dispatcher
173     void                    Execute(SfxRequest &);
174     void                    ExecStyleSheet(SfxRequest&);
175     void                    ExecDB(SfxRequest&);
176 
177     void                    GetState(SfxItemSet &);
178     void                    StateAlways(SfxItemSet &);
179     void                    StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 );
180 
181     // Doc rausreichen aber VORSICHT
182     inline SwDoc*                   GetDoc() { return pDoc; }
183     inline const SwDoc*             GetDoc() const { return pDoc; }
184     IDocumentDeviceAccess*          getIDocumentDeviceAccess();
185     const IDocumentSettingAccess*   getIDocumentSettingAccess() const;
186     IDocumentChartDataProviderAccess*       getIDocumentChartDataProviderAccess();
187 
188 
189     void                    UpdateFontList();
190     void                    UpdateChildWindows();
191 
192     // globaler IO
193     virtual sal_Bool            Save();
194 
195     // fuer VorlagenPI
196     virtual SfxStyleSheetBasePool*  GetStyleSheetPool();
197 
198     // Fuer Organizer
199     virtual sal_Bool Insert(SfxObjectShell &rSource,
200                         sal_uInt16  nSourceIdx1,
201                         sal_uInt16  nSourceIdx2,
202                         sal_uInt16  nSourceIdx3,
203                         sal_uInt16& nIdx1,
204                         sal_uInt16& nIdx2,
205                         sal_uInt16& nIdx3,
206                         sal_uInt16& nRemovedIdx);
207 
208     virtual sal_Bool Remove(sal_uInt16 nIdx1,
209                         sal_uInt16 nIdx2 = INDEX_IGNORE,
210                         sal_uInt16 nIdx3 = INDEX_IGNORE);
211 
212     virtual Bitmap      GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode );
213 
214     // View setzen fuer Aktionen ueber Shell
215     void          SetView(SwView* pVw);
216     const SwView *GetView() const { return pView; }
217     SwView       *GetView()       { return pView; }
218 
219     // Zugriff auf die zur SwView gehoerige SwWrtShell
220           SwWrtShell *GetWrtShell()       { return pWrtShell; }
221     const SwWrtShell *GetWrtShell() const { return pWrtShell; }
222 
223     // fuer die Core - die kennt die DocShell aber keine WrtShell!
224           SwFEShell *GetFEShell();
225     const SwFEShell *GetFEShell() const
226                 { return ((SwDocShell*)this)->GetFEShell(); }
227 
228 
229     // Fuer Einfuegen Dokument
230     Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr,
231                             SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0);
232 
233     virtual long DdeGetData( const String& rItem, const String& rMimeType,
234                              ::com::sun::star::uno::Any & rValue );
235     virtual long DdeSetData( const String& rItem, const String& rMimeType,
236                                 const ::com::sun::star::uno::Any & rValue );
237     virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem );
238     virtual void FillClass( SvGlobalName * pClassName,
239                                    sal_uInt32 * pClipFormat,
240                                    String * pAppName,
241                                    String * pLongUserName,
242                                    String * pUserName,
243                                    sal_Int32 nFileFormat,
244                                    sal_Bool bTemplate = sal_False ) const;
245 
246     virtual void LoadStyles( SfxObjectShell& rSource );
247 
248     void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument );
249 
250     // Seitenvorlagedialog anzeigen, ggf. auf Spaltenpage
251     void FormatPage( const String& rPage,
252                         sal_Bool bColumn = sal_False,
253                         SwWrtShell*     pActShell = 0 );
254 
255     // --> OD 2006-11-07 #i59688#
256     // linked graphics are now loaded on demand.
257     // Thus, loading of linked graphics no longer needed and necessary for
258     // the load of document being finished.
259 //    // Timer starten fuers ueberpruefen der Grafik-Links. Sind alle
260 //    // vollstaendig geladen, dann ist das Doc fertig
261 //    void StartLoadFinishedTimer();
262     void LoadingFinished();
263     // <--
264 
265     // eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen)
266     virtual void CancelTransfers();
267 
268     // Doc aus Html-Source neu laden
269     void    ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView );
270 
271     sal_Int16   GetUpdateDocMode() const {return nUpdateDocMode;}
272 
273     //Activate wait cursor for all windows of this document
274     //Optionally all dispatcher could be Locked
275     //Usually locking should be done using the class: SwWaitObject!
276     void EnterWait( sal_Bool bLockDispatcher );
277     void LeaveWait( sal_Bool bLockDispatcher );
278 
279     void ToggleBrowserMode(sal_Bool bOn, SwView* pView);
280 
281     sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt,
282                                 sal_Bool bUnoCall );
283     void InvalidateModel();
284     void ReactivateModel();
285 
286     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >  GetEventNames();
287 
288     // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption
289     virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates );
290     // <--
291 
292     // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks
293     // This new function is necessary to trigger update of links in docs
294     // read by the binary filter:
295     virtual void UpdateLinks();
296     // <--
297 
298     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >
299                                 GetController();
300 
301     SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef );
302 
303     virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const;
304 
305     // passwword protection for Writer (derived from SfxObjectShell)
306     // see also:    FN_REDLINE_ON, FN_REDLINE_ON
307     virtual bool    IsChangeRecording() const;
308     virtual bool    HasChangeRecordProtection() const;
309     virtual void    SetChangeRecording( bool bActivate );
310     virtual bool    SetProtectionPassword( const String &rPassword );
311     virtual bool    GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash );
312 };
313 
314 class Graphic;
315 //implemented in source/ui/docvw/romenu.cxx
316 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName );
317 
318 #endif
319