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