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 class SwDocShell; 59 class SwDrawModel; 60 61 // initialize DrawModel (in form of a SwDrawModel) and DocShell (in form of a SwDocShell) 62 // as needed, one or both parameters may be zero 63 void SW_DLLPRIVATE InitDrawModelAndDocShell(SwDocShell* pSwDocShell, SwDrawModel* pSwDrawModel); 64 65 class SW_DLLPUBLIC SwDocShell: public SfxObjectShell, public SfxListener 66 { 67 SwDoc* mpDoc; // Document 68 69 rtl::Reference< SfxStyleSheetBasePool > mxBasePool; // Durchreiche fuer Formate 70 71 FontList* mpFontList; // aktuelle FontListe 72 bool mbInUpdateFontList; //prevent nested calls of UpdateFontList 73 74 // Nix geht ohne die WrtShell (historische Gruende) 75 // RuekwaertsPointer auf die View (historische Gruende) 76 // Dieser gilt solange bis im Activate ein neuer gesetzt wird 77 // oder dieser im Dtor der View geloescht wird 78 // 79 SwView* mpView; 80 SwWrtShell* mpWrtShell; 81 82 Timer aFinishedTimer; // Timer fuers ueberpriefen der 83 // Grafik-Links. Sind alle da, 84 // dann ist Doc voll. geladen 85 86 comphelper::EmbeddedObjectContainer* mpOLEChildList; 87 sal_Int16 mnUpdateDocMode; // contains the com::sun::star::document::UpdateDocMode 88 89 // Methoden fuer den Zugriff aufs Doc 90 SW_DLLPRIVATE void AddLink(); 91 SW_DLLPRIVATE void RemoveLink(); 92 93 // Hint abfangen fuer DocInfo 94 SW_DLLPRIVATE virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 95 96 // FileIO 97 SW_DLLPRIVATE virtual sal_Bool InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); 98 SW_DLLPRIVATE virtual sal_Bool Load( SfxMedium& rMedium ); 99 SW_DLLPRIVATE virtual sal_Bool LoadFrom( SfxMedium& rMedium ); 100 SW_DLLPRIVATE virtual sal_Bool ConvertFrom( SfxMedium &rMedium ); 101 SW_DLLPRIVATE virtual sal_Bool ConvertTo( SfxMedium &rMedium ); 102 SW_DLLPRIVATE virtual sal_Bool SaveAs( SfxMedium& rMedium ); 103 SW_DLLPRIVATE virtual sal_Bool SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); 104 105 SW_DLLPRIVATE virtual sal_uInt16 PrepareClose( sal_Bool bUI = sal_True, sal_Bool bForBrowsing = sal_False ); 106 107 // DocInfo dem Doc melden 108 // 109 SW_DLLPRIVATE virtual SfxDocumentInfoDialog* CreateDocumentInfoDialog( 110 Window *pParent, const SfxItemSet &); 111 // OLE-Geraffel 112 SW_DLLPRIVATE virtual void Draw( OutputDevice*, const JobSetup&, sal_uInt16); 113 114 // Methoden fuer StyleSheets 115 116 // @param nSlot 117 // Only used for nFamily == SFX_STYLE_FAMILY_PAGE. Identifies optional Slot by which the edit is triggered. 118 // Used to activate certain dialog pane 119 SW_DLLPRIVATE sal_uInt16 Edit( 120 const String &rName, 121 const String& rParent, 122 const sal_uInt16 nFamily, 123 sal_uInt16 nMask, 124 const sal_Bool bNew, 125 const sal_uInt16 nSlot = 0, 126 SwWrtShell* pActShell = 0, 127 const sal_Bool bBasic = sal_False ); 128 129 SW_DLLPRIVATE sal_uInt16 Delete(const String &rName, sal_uInt16 nFamily); 130 131 SW_DLLPRIVATE sal_uInt16 ApplyStyles( 132 const String &rName, 133 const sal_uInt16 nFamily, 134 SwWrtShell* pShell = 0, 135 const sal_uInt16 nMode = 0 ); 136 137 SW_DLLPRIVATE sal_uInt16 DoWaterCan( const String &rName, sal_uInt16 nFamily); 138 SW_DLLPRIVATE sal_uInt16 UpdateStyle(const String &rName, sal_uInt16 nFamily, SwWrtShell* pShell = 0); 139 SW_DLLPRIVATE sal_uInt16 MakeByExample(const String &rName, 140 sal_uInt16 nFamily, sal_uInt16 nMask, SwWrtShell* pShell = 0); 141 142 SW_DLLPRIVATE void SubInitNew(); // fuer InitNew und HtmlSourceModus 143 144 SW_DLLPRIVATE void RemoveOLEObjects(); 145 SW_DLLPRIVATE void CalcLayoutForOLEObjects(); 146 147 SW_DLLPRIVATE void Init_Impl(); 148 SW_DLLPRIVATE DECL_STATIC_LINK( SwDocShell, IsLoadFinished, void* ); 149 150 151 using SfxObjectShell::GetVisArea; 152 using SfxObjectShell::GetStyleFamilyBitmap; 153 154 protected: 155 /// override to update text fields 156 virtual void DoFlushDocInfo(); 157 158 // override <SfxObjectShell>'s method which is called in <SfxObjectShell::ImportFrom(..)>. 159 // <SfxObjectShell::ImportFrom(..)> is used by current import of Microsoft Word documents in OOXML file format. 160 virtual void BeforeLoading( SfxMedium&, const ::rtl::OUString &, const ::rtl::OUString & ); 161 162 public: 163 using SotObject::GetInterface; 164 165 // aber selbst implementieren 166 SFX_DECL_INTERFACE(SW_DOCSHELL) 167 SFX_DECL_OBJECTFACTORY() 168 TYPEINFO(); 169 _GetInterface()170 static SfxInterface *_GetInterface() { return GetStaticInterface(); } 171 172 static rtl::OUString GetEventName( sal_Int32 nId ); 173 174 //Das Doc wird fuer SO-Datenaustausch benoetigt! 175 SwDocShell( SfxObjectCreateMode eMode = SFX_CREATE_MODE_EMBEDDED ); 176 SwDocShell( const sal_uInt64 i_nSfxCreationFlags ); 177 SwDocShell( SwDoc *pDoc, SfxObjectCreateMode eMode = SFX_CREATE_MODE_STANDARD ); 178 ~SwDocShell(); 179 180 // OLE 2.0-Benachrichtigung 181 DECL_LINK( Ole2ModifiedHdl, void * ); 182 183 // OLE-Geraffel 184 virtual void SetVisArea( const Rectangle &rRect ); 185 virtual Rectangle GetVisArea( sal_uInt16 nAspect ) const; 186 virtual Printer *GetDocumentPrinter(); 187 virtual OutputDevice* GetDocumentRefDev(); 188 virtual void OnDocumentPrinterChanged( Printer * pNewPrinter ); 189 virtual sal_uLong GetMiscStatus() const; 190 191 virtual void PrepareReload(); 192 virtual void SetModified( sal_Bool = sal_True ); 193 194 // Dispatcher 195 void Execute(SfxRequest &); 196 void ExecStyleSheet(SfxRequest&); 197 void ExecDB(SfxRequest&); 198 199 void GetState(SfxItemSet &); 200 void StateAlways(SfxItemSet &); 201 void StateStyleSheet(SfxItemSet&, SwWrtShell* pSh = 0 ); 202 203 // Doc rausreichen aber VORSICHT GetDoc()204 inline SwDoc* GetDoc() { return mpDoc; } GetDoc() const205 inline const SwDoc* GetDoc() const { return mpDoc; } 206 IDocumentDeviceAccess* getIDocumentDeviceAccess(); 207 const IDocumentSettingAccess* getIDocumentSettingAccess() const; 208 IDocumentChartDataProviderAccess* getIDocumentChartDataProviderAccess(); 209 210 211 void UpdateFontList(); 212 void UpdateChildWindows(); 213 214 // globaler IO 215 virtual sal_Bool Save(); 216 217 // fuer VorlagenPI 218 virtual SfxStyleSheetBasePool* GetStyleSheetPool(); 219 220 // Fuer Organizer 221 virtual sal_Bool Insert(SfxObjectShell &rSource, 222 sal_uInt16 nSourceIdx1, 223 sal_uInt16 nSourceIdx2, 224 sal_uInt16 nSourceIdx3, 225 sal_uInt16& nIdx1, 226 sal_uInt16& nIdx2, 227 sal_uInt16& nIdx3, 228 sal_uInt16& nRemovedIdx); 229 230 virtual sal_Bool Remove(sal_uInt16 nIdx1, 231 sal_uInt16 nIdx2 = INDEX_IGNORE, 232 sal_uInt16 nIdx3 = INDEX_IGNORE); 233 234 virtual Bitmap GetStyleFamilyBitmap( SfxStyleFamily eFamily, BmpColorMode eColorMode ); 235 236 // View setzen fuer Aktionen ueber Shell 237 void SetView(SwView* pVw); GetView() const238 const SwView *GetView() const { return mpView; } GetView()239 SwView *GetView() { return mpView; } 240 241 // Zugriff auf die zur SwView gehoerige SwWrtShell GetWrtShell()242 SwWrtShell *GetWrtShell() { return mpWrtShell; } GetWrtShell() const243 const SwWrtShell *GetWrtShell() const { return mpWrtShell; } 244 245 // fuer die Core - die kennt die DocShell aber keine WrtShell! 246 SwFEShell *GetFEShell(); GetFEShell() const247 const SwFEShell *GetFEShell() const 248 { return ((SwDocShell*)this)->GetFEShell(); } 249 250 251 // Fuer Einfuegen Dokument 252 Reader* StartConvertFrom(SfxMedium& rMedium, SwReader** ppRdr, 253 SwCrsrShell* pCrsrSh = 0, SwPaM* pPaM = 0); 254 255 virtual long DdeGetData( const String& rItem, const String& rMimeType, 256 ::com::sun::star::uno::Any & rValue ); 257 virtual long DdeSetData( const String& rItem, const String& rMimeType, 258 const ::com::sun::star::uno::Any & rValue ); 259 virtual ::sfx2::SvLinkSource* DdeCreateLinkSource( const String& rItem ); 260 virtual void FillClass( SvGlobalName * pClassName, 261 sal_uInt32 * pClipFormat, 262 String * pAppName, 263 String * pLongUserName, 264 String * pUserName, 265 sal_Int32 nFileFormat, 266 sal_Bool bTemplate = sal_False ) const; 267 268 virtual void LoadStyles( SfxObjectShell& rSource ); 269 270 void _LoadStyles( SfxObjectShell& rSource, sal_Bool bPreserveCurrentDocument ); 271 272 // Show page style format dialog 273 // @param nSlot 274 // Identifies slot by which the dialog is triggered. Used to activate certain dialog pane 275 void FormatPage( 276 const String& rPage, 277 const sal_uInt16 nSlot, 278 SwWrtShell& rActShell ); 279 280 // --> OD 2006-11-07 #i59688# 281 // linked graphics are now loaded on demand. 282 // Thus, loading of linked graphics no longer needed and necessary for 283 // the load of document being finished. 284 // // Timer starten fuers ueberpruefen der Grafik-Links. Sind alle 285 // // vollstaendig geladen, dann ist das Doc fertig 286 // void StartLoadFinishedTimer(); 287 void LoadingFinished(); 288 // <-- 289 290 // eine Uebertragung wird abgebrochen (wird aus dem SFX gerufen) 291 virtual void CancelTransfers(); 292 293 // Doc aus Html-Source neu laden 294 void ReloadFromHtml( const String& rStreamName, SwSrcView* pSrcView ); 295 GetUpdateDocMode() const296 sal_Int16 GetUpdateDocMode() const {return mnUpdateDocMode;} 297 298 void ToggleBrowserMode(sal_Bool bOn, SwView* pView); 299 300 sal_uLong LoadStylesFromFile( const String& rURL, SwgReaderOption& rOpt, 301 sal_Bool bUnoCall ); 302 void InvalidateModel(); 303 void ReactivateModel(); 304 305 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > GetEventNames(); 306 307 // --> FME 2004-08-05 #i20883# Digital Signatures and Encryption 308 virtual sal_uInt16 GetHiddenInformationState( sal_uInt16 nStates ); 309 // <-- 310 311 // --> FME 2005-02-25 #i42634# Overwrites SfxObjectShell::UpdateLinks 312 // This new function is necessary to trigger update of links in docs 313 // read by the binary filter: 314 virtual void UpdateLinks(); 315 // <-- 316 virtual void setDocAccTitle( const String& rTitle ); 317 virtual const String getDocAccTitle() const; 318 319 void setDocReadOnly( sal_Bool bReadOnly); 320 sal_Bool getDocReadOnly() const; 321 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > 322 GetController(); 323 324 SfxInPlaceClient* GetIPClient( const ::svt::EmbeddedObjectRef& xObjRef ); 325 326 virtual const ::sfx2::IXmlIdRegistry* GetXmlIdRegistry() const; 327 328 // passwword protection for Writer (derived from SfxObjectShell) 329 // see also: FN_REDLINE_ON, FN_REDLINE_ON 330 virtual bool IsChangeRecording() const; 331 virtual bool HasChangeRecordProtection() const; 332 virtual void SetChangeRecording( bool bActivate ); 333 virtual bool SetProtectionPassword( const String &rPassword ); 334 virtual bool GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal_Int8 > &rPasswordHash ); 335 }; 336 337 class Graphic; 338 //implemented in source/ui/docvw/romenu.cxx 339 String ExportGraphic( const Graphic &rGraphic, const String &rGrfName ); 340 341 #endif 342