1*5b190011SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5b190011SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5b190011SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5b190011SAndrew Rist * distributed with this work for additional information 6*5b190011SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5b190011SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5b190011SAndrew Rist * "License"); you may not use this file except in compliance 9*5b190011SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*5b190011SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*5b190011SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5b190011SAndrew Rist * software distributed under the License is distributed on an 15*5b190011SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5b190011SAndrew Rist * KIND, either express or implied. See the License for the 17*5b190011SAndrew Rist * specific language governing permissions and limitations 18*5b190011SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*5b190011SAndrew Rist *************************************************************/ 21*5b190011SAndrew Rist 22*5b190011SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sd.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "DrawDocShell.hxx" 28cdf0e10cSrcweir #include <com/sun/star/document/PrinterIndependentLayout.hpp> 29cdf0e10cSrcweir #include <tools/urlobj.hxx> 30cdf0e10cSrcweir #include <sfx2/progress.hxx> 31cdf0e10cSrcweir #include <vcl/waitobj.hxx> 32cdf0e10cSrcweir #ifndef _SVXIDS_HRC 33cdf0e10cSrcweir #include <svx/svxids.hrc> 34cdf0e10cSrcweir #endif 35cdf0e10cSrcweir #include <editeng/flstitem.hxx> 36cdf0e10cSrcweir #include <editeng/eeitem.hxx> 37cdf0e10cSrcweir #include <svl/aeitem.hxx> 38cdf0e10cSrcweir #include <svl/flagitem.hxx> 39cdf0e10cSrcweir #include <sot/storage.hxx> 40cdf0e10cSrcweir #include <sfx2/docfile.hxx> 41cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 42cdf0e10cSrcweir #ifndef _DISPATCH_HXX //autogen 43cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 44cdf0e10cSrcweir #endif 45cdf0e10cSrcweir #include <svx/svdotext.hxx> 46cdf0e10cSrcweir #include <svl/style.hxx> 47cdf0e10cSrcweir #include <sfx2/printer.hxx> 48cdf0e10cSrcweir #include <svtools/ctrltool.hxx> 49cdf0e10cSrcweir #ifndef _SFX_ECODE_HXX //autogen 50cdf0e10cSrcweir #include <svtools/sfxecode.hxx> 51cdf0e10cSrcweir #endif 52cdf0e10cSrcweir #include <sot/clsids.hxx> 53cdf0e10cSrcweir #include <sot/formats.hxx> 54cdf0e10cSrcweir #include <sfx2/request.hxx> 55cdf0e10cSrcweir #ifdef TF_STARONE 56cdf0e10cSrcweir #include "unomodel.hxx" 57cdf0e10cSrcweir #endif 58cdf0e10cSrcweir 59cdf0e10cSrcweir #include <unotools/fltrcfg.hxx> 60cdf0e10cSrcweir #include <sfx2/frame.hxx> 61cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 62cdf0e10cSrcweir //#include <svx/svxmsbas.hxx> 63cdf0e10cSrcweir #include <unotools/saveopt.hxx> 64cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawPage.hpp> 65cdf0e10cSrcweir #include <com/sun/star/drawing/XDrawView.hpp> 66cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 67cdf0e10cSrcweir 68cdf0e10cSrcweir #include "app.hrc" 69cdf0e10cSrcweir #include "glob.hrc" 70cdf0e10cSrcweir #include "strings.hrc" 71cdf0e10cSrcweir #include "strmname.h" 72cdf0e10cSrcweir #ifndef SD_FRAMW_VIEW_HXX 73cdf0e10cSrcweir #include "FrameView.hxx" 74cdf0e10cSrcweir #endif 75cdf0e10cSrcweir #include "optsitem.hxx" 76cdf0e10cSrcweir #include "Outliner.hxx" 77cdf0e10cSrcweir #include "sdattr.hxx" 78cdf0e10cSrcweir #include "drawdoc.hxx" 79cdf0e10cSrcweir #include "ViewShell.hxx" 80cdf0e10cSrcweir #include "app.hxx" 81cdf0e10cSrcweir #include "View.hxx" 82cdf0e10cSrcweir #include "sdpage.hxx" 83cdf0e10cSrcweir #include "sdresid.hxx" 84cdf0e10cSrcweir #include "DrawViewShell.hxx" 85cdf0e10cSrcweir #include "ViewShellBase.hxx" 86cdf0e10cSrcweir #include "Window.hxx" 87cdf0e10cSrcweir #include "sdmod.hxx" 88cdf0e10cSrcweir #include "OutlineViewShell.hxx" 89cdf0e10cSrcweir #include "sdxmlwrp.hxx" 90cdf0e10cSrcweir #include "sdpptwrp.hxx" 91cdf0e10cSrcweir #include "sdcgmfilter.hxx" 92cdf0e10cSrcweir #include "sdgrffilter.hxx" 93cdf0e10cSrcweir #include "sdhtmlfilter.hxx" 94cdf0e10cSrcweir #include "framework/FrameworkHelper.hxx" 95cdf0e10cSrcweir 96cdf0e10cSrcweir using namespace ::com::sun::star; 97cdf0e10cSrcweir using namespace ::com::sun::star::uno; 98cdf0e10cSrcweir using ::sd::framework::FrameworkHelper; 99cdf0e10cSrcweir 100cdf0e10cSrcweir 101cdf0e10cSrcweir namespace sd { 102cdf0e10cSrcweir 103cdf0e10cSrcweir /************************************************************************* 104cdf0e10cSrcweir |* 105cdf0e10cSrcweir |* SfxPrinter ggf. erzeugen und zurueckgeben 106cdf0e10cSrcweir |* 107cdf0e10cSrcweir \************************************************************************/ 108cdf0e10cSrcweir 109cdf0e10cSrcweir SfxPrinter* DrawDocShell::GetPrinter(sal_Bool bCreate) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir if (bCreate && !mpPrinter) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir // ItemSet mit speziellem Poolbereich anlegen 114cdf0e10cSrcweir SfxItemSet* pSet = new SfxItemSet( GetPool(), 115cdf0e10cSrcweir SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN, 116cdf0e10cSrcweir SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC, 117cdf0e10cSrcweir ATTR_OPTIONS_PRINT, ATTR_OPTIONS_PRINT, 118cdf0e10cSrcweir 0 ); 119cdf0e10cSrcweir // PrintOptionsSet setzen 120cdf0e10cSrcweir SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT, 121cdf0e10cSrcweir SD_MOD()->GetSdOptions(mpDoc->GetDocumentType())); 122cdf0e10cSrcweir SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC ); 123cdf0e10cSrcweir sal_uInt16 nFlags = 0; 124cdf0e10cSrcweir 125cdf0e10cSrcweir nFlags = (aPrintItem.GetOptionsPrint().IsWarningSize() ? SFX_PRINTER_CHG_SIZE : 0) | 126cdf0e10cSrcweir (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SFX_PRINTER_CHG_ORIENTATION : 0); 127cdf0e10cSrcweir aFlagItem.SetValue( nFlags ); 128cdf0e10cSrcweir 129cdf0e10cSrcweir pSet->Put( aPrintItem ); 130cdf0e10cSrcweir pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) ); 131cdf0e10cSrcweir pSet->Put( aFlagItem ); 132cdf0e10cSrcweir 133cdf0e10cSrcweir mpPrinter = new SfxPrinter(pSet); 134cdf0e10cSrcweir mbOwnPrinter = sal_True; 135cdf0e10cSrcweir 136cdf0e10cSrcweir // Ausgabequalitaet setzen 137cdf0e10cSrcweir sal_uInt16 nQuality = aPrintItem.GetOptionsPrint().GetOutputQuality(); 138cdf0e10cSrcweir 139cdf0e10cSrcweir sal_uLong nMode = DRAWMODE_DEFAULT; 140cdf0e10cSrcweir 141cdf0e10cSrcweir if( nQuality == 1 ) 142cdf0e10cSrcweir nMode = DRAWMODE_GRAYLINE | DRAWMODE_GRAYFILL | DRAWMODE_BLACKTEXT | DRAWMODE_GRAYBITMAP | DRAWMODE_GRAYGRADIENT; 143cdf0e10cSrcweir else if( nQuality == 2 ) 144cdf0e10cSrcweir nMode = DRAWMODE_BLACKLINE | DRAWMODE_BLACKTEXT | DRAWMODE_WHITEFILL | DRAWMODE_GRAYBITMAP | DRAWMODE_WHITEGRADIENT; 145cdf0e10cSrcweir 146cdf0e10cSrcweir mpPrinter->SetDrawMode( nMode ); 147cdf0e10cSrcweir 148cdf0e10cSrcweir MapMode aMM (mpPrinter->GetMapMode()); 149cdf0e10cSrcweir aMM.SetMapUnit(MAP_100TH_MM); 150cdf0e10cSrcweir mpPrinter->SetMapMode(aMM); 151cdf0e10cSrcweir UpdateRefDevice(); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir return mpPrinter; 154cdf0e10cSrcweir } 155cdf0e10cSrcweir 156cdf0e10cSrcweir /************************************************************************* 157cdf0e10cSrcweir |* 158cdf0e10cSrcweir |* neuen SfxPrinter setzen (Eigentuemeruebergang) 159cdf0e10cSrcweir |* 160cdf0e10cSrcweir \************************************************************************/ 161cdf0e10cSrcweir 162cdf0e10cSrcweir void DrawDocShell::SetPrinter(SfxPrinter *pNewPrinter) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir if ( mpViewShell ) 165cdf0e10cSrcweir { 166cdf0e10cSrcweir ::sd::View* pView = mpViewShell->GetView(); 167cdf0e10cSrcweir if ( pView->IsTextEdit() ) 168cdf0e10cSrcweir pView->SdrEndTextEdit(); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir if ( mpPrinter && mbOwnPrinter && (mpPrinter != pNewPrinter) ) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir delete mpPrinter; 174cdf0e10cSrcweir } 175cdf0e10cSrcweir 176cdf0e10cSrcweir mpPrinter = pNewPrinter; 177cdf0e10cSrcweir mbOwnPrinter = sal_True; 178cdf0e10cSrcweir if ( mpDoc->GetPrinterIndependentLayout() == ::com::sun::star::document::PrinterIndependentLayout::DISABLED ) 179cdf0e10cSrcweir UpdateFontList(); 180cdf0e10cSrcweir UpdateRefDevice(); 181cdf0e10cSrcweir } 182cdf0e10cSrcweir 183cdf0e10cSrcweir void DrawDocShell::UpdateFontList() 184cdf0e10cSrcweir { 185cdf0e10cSrcweir delete mpFontList; 186cdf0e10cSrcweir OutputDevice* pRefDevice = NULL; 187cdf0e10cSrcweir if ( mpDoc->GetPrinterIndependentLayout() == ::com::sun::star::document::PrinterIndependentLayout::DISABLED ) 188cdf0e10cSrcweir pRefDevice = GetPrinter(sal_True); 189cdf0e10cSrcweir else 190cdf0e10cSrcweir pRefDevice = SD_MOD()->GetVirtualRefDevice(); 191cdf0e10cSrcweir mpFontList = new FontList( pRefDevice, NULL, sal_False ); 192cdf0e10cSrcweir SvxFontListItem aFontListItem( mpFontList, SID_ATTR_CHAR_FONTLIST ); 193cdf0e10cSrcweir PutItem( aFontListItem ); 194cdf0e10cSrcweir } 195cdf0e10cSrcweir 196cdf0e10cSrcweir /************************************************************************* 197cdf0e10cSrcweir |* 198cdf0e10cSrcweir |* 199cdf0e10cSrcweir |* 200cdf0e10cSrcweir \************************************************************************/ 201cdf0e10cSrcweir Printer* DrawDocShell::GetDocumentPrinter() 202cdf0e10cSrcweir { 203cdf0e10cSrcweir return GetPrinter(sal_False); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir /************************************************************************* 207cdf0e10cSrcweir |* 208cdf0e10cSrcweir |* 209cdf0e10cSrcweir |* 210cdf0e10cSrcweir \************************************************************************/ 211cdf0e10cSrcweir void DrawDocShell::OnDocumentPrinterChanged(Printer* pNewPrinter) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir // if we already have a printer, see if its the same 214cdf0e10cSrcweir if( mpPrinter ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir // easy case 217cdf0e10cSrcweir if( mpPrinter == pNewPrinter ) 218cdf0e10cSrcweir return; 219cdf0e10cSrcweir 220cdf0e10cSrcweir // compare if its the same printer with the same job setup 221cdf0e10cSrcweir if( (mpPrinter->GetName() == pNewPrinter->GetName()) && 222cdf0e10cSrcweir (mpPrinter->GetJobSetup() == pNewPrinter->GetJobSetup())) 223cdf0e10cSrcweir return; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir // if (mpPrinter->IsA(SfxPrinter)) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir // Da kein RTTI verfuegbar, wird hart gecasted (...) 229cdf0e10cSrcweir SetPrinter((SfxPrinter*) pNewPrinter); 230cdf0e10cSrcweir 231cdf0e10cSrcweir // Printer gehoert dem Container 232cdf0e10cSrcweir mbOwnPrinter = sal_False; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir 236cdf0e10cSrcweir /************************************************************************* 237cdf0e10cSrcweir |* 238cdf0e10cSrcweir |* 239cdf0e10cSrcweir |* 240cdf0e10cSrcweir \************************************************************************/ 241cdf0e10cSrcweir void DrawDocShell::UpdateRefDevice() 242cdf0e10cSrcweir { 243cdf0e10cSrcweir if( mpDoc ) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir // Determine the device for which the output will be formatted. 246cdf0e10cSrcweir OutputDevice* pRefDevice = NULL; 247cdf0e10cSrcweir switch (mpDoc->GetPrinterIndependentLayout()) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir case ::com::sun::star::document::PrinterIndependentLayout::DISABLED: 250cdf0e10cSrcweir pRefDevice = mpPrinter; 251cdf0e10cSrcweir break; 252cdf0e10cSrcweir 253cdf0e10cSrcweir case ::com::sun::star::document::PrinterIndependentLayout::ENABLED: 254cdf0e10cSrcweir pRefDevice = SD_MOD()->GetVirtualRefDevice(); 255cdf0e10cSrcweir break; 256cdf0e10cSrcweir 257cdf0e10cSrcweir default: 258cdf0e10cSrcweir // We are confronted with an invalid or un-implemented 259cdf0e10cSrcweir // layout mode. Use the printer as formatting device 260cdf0e10cSrcweir // as a fall-back. 261cdf0e10cSrcweir DBG_ASSERT(false, "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode"); 262cdf0e10cSrcweir 263cdf0e10cSrcweir pRefDevice = mpPrinter; 264cdf0e10cSrcweir break; 265cdf0e10cSrcweir } 266cdf0e10cSrcweir mpDoc->SetRefDevice( pRefDevice ); 267cdf0e10cSrcweir 268cdf0e10cSrcweir ::sd::Outliner* pOutl = mpDoc->GetOutliner( sal_False ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir if( pOutl ) 271cdf0e10cSrcweir pOutl->SetRefDevice( pRefDevice ); 272cdf0e10cSrcweir 273cdf0e10cSrcweir ::sd::Outliner* pInternalOutl = mpDoc->GetInternalOutliner( sal_False ); 274cdf0e10cSrcweir 275cdf0e10cSrcweir if( pInternalOutl ) 276cdf0e10cSrcweir pInternalOutl->SetRefDevice( pRefDevice ); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir } 279cdf0e10cSrcweir 280cdf0e10cSrcweir /************************************************************************* 281cdf0e10cSrcweir |* 282cdf0e10cSrcweir |* InitNew, (Dokument wird neu erzeugt): Streams oeffnen 283cdf0e10cSrcweir |* 284cdf0e10cSrcweir \************************************************************************/ 285cdf0e10cSrcweir 286cdf0e10cSrcweir sal_Bool DrawDocShell::InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir sal_Bool bRet = sal_False; 289cdf0e10cSrcweir 290cdf0e10cSrcweir bRet = SfxObjectShell::InitNew( xStorage ); 291cdf0e10cSrcweir 292cdf0e10cSrcweir Rectangle aVisArea( Point(0, 0), Size(14100, 10000) ); 293cdf0e10cSrcweir SetVisArea(aVisArea); 294cdf0e10cSrcweir 295cdf0e10cSrcweir if (bRet) 296cdf0e10cSrcweir { 297cdf0e10cSrcweir mpDoc->SetDrawingLayerPoolDefaults(); 298cdf0e10cSrcweir if( !mbSdDataObj ) 299cdf0e10cSrcweir mpDoc->NewOrLoadCompleted(NEW_DOC); // otherwise calling 300cdf0e10cSrcweir // NewOrLoadCompleted(NEW_LOADED) in 301cdf0e10cSrcweir // SdDrawDocument::AllocModel() 302cdf0e10cSrcweir } 303cdf0e10cSrcweir return bRet; 304cdf0e10cSrcweir } 305cdf0e10cSrcweir 306cdf0e10cSrcweir /************************************************************************* 307cdf0e10cSrcweir |* 308cdf0e10cSrcweir |* Load: Pools und Dokument laden 309cdf0e10cSrcweir |* 310cdf0e10cSrcweir \************************************************************************/ 311cdf0e10cSrcweir 312cdf0e10cSrcweir sal_Bool DrawDocShell::Load( SfxMedium& rMedium ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir mbNewDocument = sal_False; 315cdf0e10cSrcweir 316cdf0e10cSrcweir sal_Bool bRet = sal_False; 317cdf0e10cSrcweir bool bStartPresentation = false; 318cdf0e10cSrcweir ErrCode nError = ERRCODE_NONE; 319cdf0e10cSrcweir 320cdf0e10cSrcweir SfxItemSet* pSet = rMedium.GetItemSet(); 321cdf0e10cSrcweir 322cdf0e10cSrcweir 323cdf0e10cSrcweir if( pSet ) 324cdf0e10cSrcweir { 325cdf0e10cSrcweir if( ( SFX_ITEM_SET == pSet->GetItemState(SID_PREVIEW ) ) && ( (SfxBoolItem&) ( pSet->Get( SID_PREVIEW ) ) ).GetValue() ) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir mpDoc->SetStarDrawPreviewMode( sal_True ); 328cdf0e10cSrcweir } 329cdf0e10cSrcweir 330cdf0e10cSrcweir if( SFX_ITEM_SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&& 331cdf0e10cSrcweir ( (SfxBoolItem&) ( pSet->Get( SID_DOC_STARTPRESENTATION ) ) ).GetValue() ) 332cdf0e10cSrcweir { 333cdf0e10cSrcweir bStartPresentation = true; 334cdf0e10cSrcweir mpDoc->SetStartWithPresentation( true ); 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir bRet = SfxObjectShell::Load( rMedium ); 339cdf0e10cSrcweir if( bRet ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError ); 342cdf0e10cSrcweir } 343cdf0e10cSrcweir 344cdf0e10cSrcweir if( bRet ) 345cdf0e10cSrcweir { 346cdf0e10cSrcweir UpdateTablePointers(); 347cdf0e10cSrcweir 348cdf0e10cSrcweir // #108451# If we're an embedded OLE object, use tight bounds 349cdf0e10cSrcweir // for our visArea. No point in showing the user lots of empty 350cdf0e10cSrcweir // space. Had to remove the check for empty VisArea below, 351cdf0e10cSrcweir // since XML load always sets a VisArea before. 352cdf0e10cSrcweir //TODO/LATER: looks a little bit strange! 353cdf0e10cSrcweir if( ( GetCreateMode() == SFX_CREATE_MODE_EMBEDDED ) && SfxObjectShell::GetVisArea( ASPECT_CONTENT ).IsEmpty() ) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir SdPage* pPage = mpDoc->GetSdPage( 0, PK_STANDARD ); 356cdf0e10cSrcweir 357cdf0e10cSrcweir if( pPage ) 358cdf0e10cSrcweir SetVisArea( Rectangle( pPage->GetAllObjBoundRect() ) ); 359cdf0e10cSrcweir } 360cdf0e10cSrcweir 361cdf0e10cSrcweir FinishedLoading( SFX_LOADED_ALL ); 362cdf0e10cSrcweir 363cdf0e10cSrcweir const INetURLObject aUrl; 364cdf0e10cSrcweir SfxObjectShell::SetAutoLoad( aUrl, 0, sal_False ); 365cdf0e10cSrcweir } 366cdf0e10cSrcweir else 367cdf0e10cSrcweir { 368cdf0e10cSrcweir if( nError == ERRCODE_IO_BROKENPACKAGE ) 369cdf0e10cSrcweir SetError( ERRCODE_IO_BROKENPACKAGE, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 370cdf0e10cSrcweir 371cdf0e10cSrcweir // TODO/LATER: correct error handling?! 372cdf0e10cSrcweir //pStore->SetError( SVSTREAM_WRONGVERSION, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 373cdf0e10cSrcweir else 374cdf0e10cSrcweir SetError( ERRCODE_ABORT, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir 377cdf0e10cSrcweir // tell SFX to change viewshell when in preview mode 378cdf0e10cSrcweir if( IsPreview() || bStartPresentation ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir SfxItemSet *pMediumSet = GetMedium()->GetItemSet(); 381cdf0e10cSrcweir if( pMediumSet ) 382cdf0e10cSrcweir pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) ); 383cdf0e10cSrcweir } 384cdf0e10cSrcweir 385cdf0e10cSrcweir return bRet; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir 388cdf0e10cSrcweir /************************************************************************* 389cdf0e10cSrcweir |* 390cdf0e10cSrcweir |* LoadFrom: Inhalte fuer Organizer laden 391cdf0e10cSrcweir |* 392cdf0e10cSrcweir \************************************************************************/ 393cdf0e10cSrcweir 394cdf0e10cSrcweir sal_Bool DrawDocShell::LoadFrom( SfxMedium& rMedium ) 395cdf0e10cSrcweir { 396cdf0e10cSrcweir mbNewDocument = sal_False; 397cdf0e10cSrcweir 398cdf0e10cSrcweir WaitObject* pWait = NULL; 399cdf0e10cSrcweir if( mpViewShell ) 400cdf0e10cSrcweir pWait = new WaitObject( (Window*) mpViewShell->GetActiveWindow() ); 401cdf0e10cSrcweir 402cdf0e10cSrcweir sal_Bool bRet = sal_False; 403cdf0e10cSrcweir 404cdf0e10cSrcweir /* 405cdf0e10cSrcweir // #90691# return to old behaviour (before #80365#): construct own medium 406cdf0e10cSrcweir SfxMedium aMedium(xStorage); 407cdf0e10cSrcweir 408cdf0e10cSrcweir // #90691# for having a progress bar nonetheless for XML copy it 409cdf0e10cSrcweir // from the local DocShell medium (GetMedium()) to the constructed one 410cdf0e10cSrcweir SfxMedium* pLocalMedium = GetMedium(); 411cdf0e10cSrcweir if(pLocalMedium) 412cdf0e10cSrcweir { 413cdf0e10cSrcweir SfxItemSet* pLocalItemSet = pLocalMedium->GetItemSet(); 414cdf0e10cSrcweir SfxItemSet* pDestItemSet = aMedium.GetItemSet(); 415cdf0e10cSrcweir 416cdf0e10cSrcweir if(pLocalItemSet && pDestItemSet) 417cdf0e10cSrcweir { 418cdf0e10cSrcweir const SfxUnoAnyItem* pItem = static_cast< 419cdf0e10cSrcweir const SfxUnoAnyItem*>( 420cdf0e10cSrcweir pLocalItemSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL)); 421cdf0e10cSrcweir 422cdf0e10cSrcweir if(pItem) 423cdf0e10cSrcweir { 424cdf0e10cSrcweir pDestItemSet->Put(*pItem); 425cdf0e10cSrcweir } 426cdf0e10cSrcweir } 427cdf0e10cSrcweir } */ 428cdf0e10cSrcweir 429cdf0e10cSrcweir mpDoc->NewOrLoadCompleted( NEW_DOC ); 430cdf0e10cSrcweir mpDoc->CreateFirstPages(); 431cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 432cdf0e10cSrcweir 433cdf0e10cSrcweir // TODO/LATER: nobody is interested in the error code?! 434cdf0e10cSrcweir ErrCode nError = ERRCODE_NONE; 435cdf0e10cSrcweir bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Organizer, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError ); 436cdf0e10cSrcweir 437cdf0e10cSrcweir 438cdf0e10cSrcweir // tell SFX to change viewshell when in preview mode 439cdf0e10cSrcweir if( IsPreview() ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir SfxItemSet *pSet = GetMedium()->GetItemSet(); 442cdf0e10cSrcweir 443cdf0e10cSrcweir if( pSet ) 444cdf0e10cSrcweir pSet->Put( SfxUInt16Item( SID_VIEW_ID, 5 ) ); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir delete pWait; 448cdf0e10cSrcweir 449cdf0e10cSrcweir return bRet; 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir /************************************************************************* 453cdf0e10cSrcweir |* 454cdf0e10cSrcweir |* ConvertFrom: aus Fremdformat laden 455cdf0e10cSrcweir |* 456cdf0e10cSrcweir \************************************************************************/ 457cdf0e10cSrcweir 458cdf0e10cSrcweir sal_Bool DrawDocShell::ConvertFrom( SfxMedium& rMedium ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir mbNewDocument = sal_False; 461cdf0e10cSrcweir 462cdf0e10cSrcweir const String aFilterName( rMedium.GetFilter()->GetFilterName() ); 463cdf0e10cSrcweir sal_Bool bRet = sal_False; 464cdf0e10cSrcweir bool bStartPresentation = false; 465cdf0e10cSrcweir 466cdf0e10cSrcweir SetWaitCursor( sal_True ); 467cdf0e10cSrcweir 468cdf0e10cSrcweir SfxItemSet* pSet = rMedium.GetItemSet(); 469cdf0e10cSrcweir if( pSet ) 470cdf0e10cSrcweir { 471cdf0e10cSrcweir if( ( SFX_ITEM_SET == pSet->GetItemState(SID_PREVIEW ) ) && ( (SfxBoolItem&) ( pSet->Get( SID_PREVIEW ) ) ).GetValue() ) 472cdf0e10cSrcweir { 473cdf0e10cSrcweir mpDoc->SetStarDrawPreviewMode( sal_True ); 474cdf0e10cSrcweir } 475cdf0e10cSrcweir 476cdf0e10cSrcweir if( SFX_ITEM_SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&& 477cdf0e10cSrcweir ( (SfxBoolItem&) ( pSet->Get( SID_DOC_STARTPRESENTATION ) ) ).GetValue() ) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir bStartPresentation = true; 480cdf0e10cSrcweir mpDoc->SetStartWithPresentation( true ); 481cdf0e10cSrcweir } 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir if( aFilterName == pFilterPowerPoint97 || aFilterName == pFilterPowerPoint97Template) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 487cdf0e10cSrcweir bRet = SdPPTFilter( rMedium, *this, sal_True ).Import(); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir else if (aFilterName.SearchAscii("impress8" ) != STRING_NOTFOUND || 490cdf0e10cSrcweir aFilterName.SearchAscii("draw8") != STRING_NOTFOUND ) 491cdf0e10cSrcweir { 492cdf0e10cSrcweir // TODO/LATER: nobody is interested in the error code?! 493cdf0e10cSrcweir mpDoc->CreateFirstPages(); 494cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 495cdf0e10cSrcweir ErrCode nError = ERRCODE_NONE; 496cdf0e10cSrcweir bRet = SdXMLFilter( rMedium, *this, sal_True ).Import( nError ); 497cdf0e10cSrcweir 498cdf0e10cSrcweir } 499cdf0e10cSrcweir else if (aFilterName.SearchAscii("StarOffice XML (Draw)" ) != STRING_NOTFOUND || aFilterName.SearchAscii("StarOffice XML (Impress)") != STRING_NOTFOUND ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir // TODO/LATER: nobody is interested in the error code?! 502cdf0e10cSrcweir mpDoc->CreateFirstPages(); 503cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 504cdf0e10cSrcweir ErrCode nError = ERRCODE_NONE; 505cdf0e10cSrcweir bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 ).Import( nError ); 506cdf0e10cSrcweir } 507cdf0e10cSrcweir else if( aFilterName.EqualsAscii( "CGM - Computer Graphics Metafile" ) ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir mpDoc->CreateFirstPages(); 510cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 511cdf0e10cSrcweir bRet = SdCGMFilter( rMedium, *this, sal_True ).Import(); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir else 514cdf0e10cSrcweir { 515cdf0e10cSrcweir mpDoc->CreateFirstPages(); 516cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 517cdf0e10cSrcweir bRet = SdGRFFilter( rMedium, *this ).Import(); 518cdf0e10cSrcweir } 519cdf0e10cSrcweir 520cdf0e10cSrcweir FinishedLoading( SFX_LOADED_MAINDOCUMENT | SFX_LOADED_IMAGES ); 521cdf0e10cSrcweir 522cdf0e10cSrcweir // tell SFX to change viewshell when in preview mode 523cdf0e10cSrcweir if( IsPreview() ) 524cdf0e10cSrcweir { 525cdf0e10cSrcweir SfxItemSet *pMediumSet = GetMedium()->GetItemSet(); 526cdf0e10cSrcweir 527cdf0e10cSrcweir if( pMediumSet ) 528cdf0e10cSrcweir pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, 5 ) ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir SetWaitCursor( sal_False ); 531cdf0e10cSrcweir 532cdf0e10cSrcweir // tell SFX to change viewshell when in preview mode 533cdf0e10cSrcweir if( IsPreview() || bStartPresentation ) 534cdf0e10cSrcweir { 535cdf0e10cSrcweir SfxItemSet *pMediumSet = GetMedium()->GetItemSet(); 536cdf0e10cSrcweir if( pMediumSet ) 537cdf0e10cSrcweir pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) ); 538cdf0e10cSrcweir } 539cdf0e10cSrcweir 540cdf0e10cSrcweir return bRet; 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir /************************************************************************* 544cdf0e10cSrcweir |* 545cdf0e10cSrcweir |* Save: Pools und Dokument in die offenen Streams schreiben 546cdf0e10cSrcweir |* 547cdf0e10cSrcweir \************************************************************************/ 548cdf0e10cSrcweir 549cdf0e10cSrcweir sal_Bool DrawDocShell::Save() 550cdf0e10cSrcweir { 551cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 552cdf0e10cSrcweir 553cdf0e10cSrcweir //TODO/LATER: why this?! 554cdf0e10cSrcweir if( GetCreateMode() == SFX_CREATE_MODE_STANDARD ) 555cdf0e10cSrcweir SfxObjectShell::SetVisArea( Rectangle() ); 556cdf0e10cSrcweir 557cdf0e10cSrcweir sal_Bool bRet = SfxObjectShell::Save(); 558cdf0e10cSrcweir 559cdf0e10cSrcweir if( bRet ) 560cdf0e10cSrcweir { 561cdf0e10cSrcweir // #86834# Call UpdateDocInfoForSave() before export 562cdf0e10cSrcweir UpdateDocInfoForSave(); 563cdf0e10cSrcweir 564cdf0e10cSrcweir bRet = SdXMLFilter( *GetMedium(), *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( GetMedium()->GetStorage() ) ).Export(); 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir return bRet; 568cdf0e10cSrcweir } 569cdf0e10cSrcweir 570cdf0e10cSrcweir /************************************************************************* 571cdf0e10cSrcweir |* 572cdf0e10cSrcweir |* SaveAs: Pools und Dokument in den angegebenen Storage sichern 573cdf0e10cSrcweir |* 574cdf0e10cSrcweir \************************************************************************/ 575cdf0e10cSrcweir 576cdf0e10cSrcweir sal_Bool DrawDocShell::SaveAs( SfxMedium& rMedium ) 577cdf0e10cSrcweir { 578cdf0e10cSrcweir mpDoc->StopWorkStartupDelay(); 579cdf0e10cSrcweir 580cdf0e10cSrcweir //TODO/LATER: why this?! 581cdf0e10cSrcweir if( GetCreateMode() == SFX_CREATE_MODE_STANDARD ) 582cdf0e10cSrcweir SfxObjectShell::SetVisArea( Rectangle() ); 583cdf0e10cSrcweir 584cdf0e10cSrcweir sal_uInt32 nVBWarning = ERRCODE_NONE; 585cdf0e10cSrcweir sal_Bool bRet = SfxObjectShell::SaveAs( rMedium ); 586cdf0e10cSrcweir 587cdf0e10cSrcweir if( bRet ) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir // #86834# Call UpdateDocInfoForSave() before export 590cdf0e10cSrcweir UpdateDocInfoForSave(); 591cdf0e10cSrcweir bRet = SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export(); 592cdf0e10cSrcweir } 593cdf0e10cSrcweir 594cdf0e10cSrcweir if( GetError() == ERRCODE_NONE ) 595cdf0e10cSrcweir SetError( nVBWarning, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); 596cdf0e10cSrcweir 597cdf0e10cSrcweir return bRet; 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir /************************************************************************* 601cdf0e10cSrcweir |* 602cdf0e10cSrcweir |* ConvertTo: im Fremdformat speichern 603cdf0e10cSrcweir |* 604cdf0e10cSrcweir \************************************************************************/ 605cdf0e10cSrcweir 606cdf0e10cSrcweir sal_Bool DrawDocShell::ConvertTo( SfxMedium& rMedium ) 607cdf0e10cSrcweir { 608cdf0e10cSrcweir sal_Bool bRet = sal_False; 609cdf0e10cSrcweir 610cdf0e10cSrcweir if( mpDoc->GetPageCount() ) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir const SfxFilter* pMediumFilter = rMedium.GetFilter(); 613cdf0e10cSrcweir const String aTypeName( pMediumFilter->GetTypeName() ); 614cdf0e10cSrcweir SdFilter* pFilter = NULL; 615cdf0e10cSrcweir 616cdf0e10cSrcweir if( aTypeName.SearchAscii( "graphic_HTML" ) != STRING_NOTFOUND ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir pFilter = new SdHTMLFilter( rMedium, *this, sal_True ); 619cdf0e10cSrcweir } 620cdf0e10cSrcweir else if( aTypeName.SearchAscii( "MS_PowerPoint_97" ) != STRING_NOTFOUND ) 621cdf0e10cSrcweir { 622cdf0e10cSrcweir pFilter = new SdPPTFilter( rMedium, *this, sal_True ); 623cdf0e10cSrcweir ((SdPPTFilter*)pFilter)->PreSaveBasic(); 624cdf0e10cSrcweir } 625cdf0e10cSrcweir else if ( aTypeName.SearchAscii( "CGM_Computer_Graphics_Metafile" ) != STRING_NOTFOUND ) 626cdf0e10cSrcweir { 627cdf0e10cSrcweir pFilter = new SdCGMFilter( rMedium, *this, sal_True ); 628cdf0e10cSrcweir } 629cdf0e10cSrcweir else if( ( aTypeName.SearchAscii( "draw8" ) != STRING_NOTFOUND ) || 630cdf0e10cSrcweir ( aTypeName.SearchAscii( "impress8" ) != STRING_NOTFOUND ) ) 631cdf0e10cSrcweir { 632cdf0e10cSrcweir pFilter = new SdXMLFilter( rMedium, *this, sal_True ); 633cdf0e10cSrcweir UpdateDocInfoForSave(); 634cdf0e10cSrcweir } 635cdf0e10cSrcweir else if( ( aTypeName.SearchAscii( "StarOffice_XML_Impress" ) != STRING_NOTFOUND ) || 636cdf0e10cSrcweir ( aTypeName.SearchAscii( "StarOffice_XML_Draw" ) != STRING_NOTFOUND ) ) 637cdf0e10cSrcweir { 638cdf0e10cSrcweir pFilter = new SdXMLFilter( rMedium, *this, sal_True, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 ); 639cdf0e10cSrcweir UpdateDocInfoForSave(); 640cdf0e10cSrcweir } 641cdf0e10cSrcweir else 642cdf0e10cSrcweir { 643cdf0e10cSrcweir pFilter = new SdGRFFilter( rMedium, *this ); 644cdf0e10cSrcweir } 645cdf0e10cSrcweir 646cdf0e10cSrcweir if( pFilter ) 647cdf0e10cSrcweir { 648cdf0e10cSrcweir const sal_uLong nOldSwapMode = mpDoc->GetSwapGraphicsMode(); 649cdf0e10cSrcweir 650cdf0e10cSrcweir mpDoc->SetSwapGraphicsMode( SDR_SWAPGRAPHICSMODE_TEMP ); 651cdf0e10cSrcweir 652cdf0e10cSrcweir bRet = pFilter->Export(); 653cdf0e10cSrcweir if( !bRet ) 654cdf0e10cSrcweir mpDoc->SetSwapGraphicsMode( nOldSwapMode ); 655cdf0e10cSrcweir 656cdf0e10cSrcweir delete pFilter; 657cdf0e10cSrcweir } 658cdf0e10cSrcweir } 659cdf0e10cSrcweir 660cdf0e10cSrcweir return bRet; 661cdf0e10cSrcweir } 662cdf0e10cSrcweir 663cdf0e10cSrcweir /************************************************************************* 664cdf0e10cSrcweir |* 665cdf0e10cSrcweir |* SaveCompleted: die eigenen Streams wieder oeffnen, damit kein anderer 666cdf0e10cSrcweir |* sie "besetzt" 667cdf0e10cSrcweir |* 668cdf0e10cSrcweir \************************************************************************/ 669cdf0e10cSrcweir 670cdf0e10cSrcweir sal_Bool DrawDocShell::SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir sal_Bool bRet = sal_False; 673cdf0e10cSrcweir 674cdf0e10cSrcweir if( SfxObjectShell::SaveCompleted(xStorage) ) 675cdf0e10cSrcweir { 676cdf0e10cSrcweir mpDoc->NbcSetChanged( sal_False ); 677cdf0e10cSrcweir 678cdf0e10cSrcweir if( mpViewShell ) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir if( mpViewShell->ISA( OutlineViewShell ) ) 681cdf0e10cSrcweir static_cast<OutlineView*>(mpViewShell->GetView()) 682cdf0e10cSrcweir ->GetOutliner()->ClearModifyFlag(); 683cdf0e10cSrcweir 684cdf0e10cSrcweir SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner(); 685cdf0e10cSrcweir if( pOutl ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir SdrObject* pObj = mpViewShell->GetView()->GetTextEditObject(); 688cdf0e10cSrcweir if( pObj ) 689cdf0e10cSrcweir pObj->NbcSetOutlinerParaObject( pOutl->CreateParaObject() ); 690cdf0e10cSrcweir 691cdf0e10cSrcweir pOutl->ClearModifyFlag(); 692cdf0e10cSrcweir } 693cdf0e10cSrcweir } 694cdf0e10cSrcweir 695cdf0e10cSrcweir bRet = sal_True; 696cdf0e10cSrcweir 697cdf0e10cSrcweir SfxViewFrame* pFrame = ( mpViewShell && mpViewShell->GetViewFrame() ) ? 698cdf0e10cSrcweir mpViewShell->GetViewFrame() : 699cdf0e10cSrcweir SfxViewFrame::Current(); 700cdf0e10cSrcweir 701cdf0e10cSrcweir if( pFrame ) 702cdf0e10cSrcweir pFrame->GetBindings().Invalidate( SID_NAVIGATOR_STATE, sal_True, sal_False ); 703cdf0e10cSrcweir } 704cdf0e10cSrcweir return bRet; 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir /************************************************************************* 708cdf0e10cSrcweir |* 709cdf0e10cSrcweir |* Referenz auf Dokument 710cdf0e10cSrcweir |* 711cdf0e10cSrcweir \************************************************************************/ 712cdf0e10cSrcweir 713cdf0e10cSrcweir SdDrawDocument* DrawDocShell::GetDoc() 714cdf0e10cSrcweir { 715cdf0e10cSrcweir return mpDoc; 716cdf0e10cSrcweir } 717cdf0e10cSrcweir 718cdf0e10cSrcweir /************************************************************************* 719cdf0e10cSrcweir |* 720cdf0e10cSrcweir |* Referenz auf Dokument 721cdf0e10cSrcweir |* 722cdf0e10cSrcweir \************************************************************************/ 723cdf0e10cSrcweir 724cdf0e10cSrcweir SfxStyleSheetBasePool* DrawDocShell::GetStyleSheetPool() 725cdf0e10cSrcweir { 726cdf0e10cSrcweir return( (SfxStyleSheetBasePool*) mpDoc->GetStyleSheetPool() ); 727cdf0e10cSrcweir } 728cdf0e10cSrcweir 729cdf0e10cSrcweir /************************************************************************* 730cdf0e10cSrcweir |* 731cdf0e10cSrcweir |* Sprung zu Bookmark 732cdf0e10cSrcweir |* 733cdf0e10cSrcweir \************************************************************************/ 734cdf0e10cSrcweir 735cdf0e10cSrcweir sal_Bool DrawDocShell::GotoBookmark(const String& rBookmark) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir sal_Bool bFound = sal_False; 738cdf0e10cSrcweir 739cdf0e10cSrcweir if (mpViewShell && mpViewShell->ISA(DrawViewShell)) 740cdf0e10cSrcweir { 741cdf0e10cSrcweir DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(mpViewShell); 742cdf0e10cSrcweir ViewShellBase& rBase (mpViewShell->GetViewShellBase()); 743cdf0e10cSrcweir 744cdf0e10cSrcweir sal_Bool bIsMasterPage = sal_False; 745cdf0e10cSrcweir sal_uInt16 nPageNumber = SDRPAGE_NOTFOUND; 746cdf0e10cSrcweir SdrObject* pObj = NULL; 747cdf0e10cSrcweir 748cdf0e10cSrcweir rtl::OUString sBookmark( rBookmark ); 749cdf0e10cSrcweir const rtl::OUString sInteraction( RTL_CONSTASCII_USTRINGPARAM( "action?" ) ); 750cdf0e10cSrcweir if ( sBookmark.match( sInteraction ) ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir const rtl::OUString sJump( RTL_CONSTASCII_USTRINGPARAM( "jump=" ) ); 753cdf0e10cSrcweir if ( sBookmark.match( sJump, sInteraction.getLength() ) ) 754cdf0e10cSrcweir { 755cdf0e10cSrcweir rtl::OUString aDestination( sBookmark.copy( sInteraction.getLength() + sJump.getLength() ) ); 756cdf0e10cSrcweir if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "firstslide" ) ) ) ) 757cdf0e10cSrcweir { 758cdf0e10cSrcweir nPageNumber = 1; 759cdf0e10cSrcweir } 760cdf0e10cSrcweir else if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "lastslide" ) ) ) ) 761cdf0e10cSrcweir { 762cdf0e10cSrcweir nPageNumber = mpDoc->GetPageCount() - 2; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir else if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "previousslide" ) ) ) ) 765cdf0e10cSrcweir { 766cdf0e10cSrcweir SdPage* pPage = pDrawViewShell->GetActualPage(); 767cdf0e10cSrcweir nPageNumber = pPage->GetPageNum(); 768cdf0e10cSrcweir nPageNumber = nPageNumber > 2 ? nPageNumber - 2 : SDRPAGE_NOTFOUND; 769cdf0e10cSrcweir } 770cdf0e10cSrcweir else if ( aDestination.match( String( RTL_CONSTASCII_USTRINGPARAM( "nextslide" ) ) ) ) 771cdf0e10cSrcweir { 772cdf0e10cSrcweir SdPage* pPage = pDrawViewShell->GetActualPage(); 773cdf0e10cSrcweir nPageNumber = pPage->GetPageNum() + 2; 774cdf0e10cSrcweir if ( nPageNumber >= mpDoc->GetPageCount() ) 775cdf0e10cSrcweir nPageNumber = SDRPAGE_NOTFOUND; 776cdf0e10cSrcweir } 777cdf0e10cSrcweir } 778cdf0e10cSrcweir } 779cdf0e10cSrcweir else 780cdf0e10cSrcweir { 781cdf0e10cSrcweir String aBookmark( rBookmark ); 782cdf0e10cSrcweir 783cdf0e10cSrcweir // Ist das Bookmark eine Seite? 784cdf0e10cSrcweir nPageNumber = mpDoc->GetPageByName( aBookmark, bIsMasterPage ); 785cdf0e10cSrcweir 786cdf0e10cSrcweir if (nPageNumber == SDRPAGE_NOTFOUND) 787cdf0e10cSrcweir { 788cdf0e10cSrcweir // Ist das Bookmark ein Objekt? 789cdf0e10cSrcweir pObj = mpDoc->GetObj(aBookmark); 790cdf0e10cSrcweir 791cdf0e10cSrcweir if (pObj) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir nPageNumber = pObj->GetPage()->GetPageNum(); 794cdf0e10cSrcweir } 795cdf0e10cSrcweir } 796cdf0e10cSrcweir } 797cdf0e10cSrcweir if (nPageNumber != SDRPAGE_NOTFOUND) 798cdf0e10cSrcweir { 799cdf0e10cSrcweir // Jump to the bookmarked page. This is done in three steps. 800cdf0e10cSrcweir 801cdf0e10cSrcweir bFound = sal_True; 802cdf0e10cSrcweir SdPage* pPage; 803cdf0e10cSrcweir if (bIsMasterPage) 804cdf0e10cSrcweir pPage = (SdPage*) mpDoc->GetMasterPage(nPageNumber); 805cdf0e10cSrcweir else 806cdf0e10cSrcweir pPage = (SdPage*) mpDoc->GetPage(nPageNumber); 807cdf0e10cSrcweir 808cdf0e10cSrcweir // 1.) Change the view shell to the edit view, the notes view, 809cdf0e10cSrcweir // or the handout view. 810cdf0e10cSrcweir PageKind eNewPageKind = pPage->GetPageKind(); 811cdf0e10cSrcweir 812cdf0e10cSrcweir if( (eNewPageKind != PK_STANDARD) && (mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) ) 813cdf0e10cSrcweir return sal_False; 814cdf0e10cSrcweir 815cdf0e10cSrcweir if (eNewPageKind != pDrawViewShell->GetPageKind()) 816cdf0e10cSrcweir { 817cdf0e10cSrcweir // Arbeitsbereich wechseln 818cdf0e10cSrcweir GetFrameView()->SetPageKind(eNewPageKind); 819cdf0e10cSrcweir ::rtl::OUString sViewURL; 820cdf0e10cSrcweir switch (eNewPageKind) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir case PK_STANDARD: 823cdf0e10cSrcweir sViewURL = FrameworkHelper::msImpressViewURL; 824cdf0e10cSrcweir break; 825cdf0e10cSrcweir case PK_NOTES: 826cdf0e10cSrcweir sViewURL = FrameworkHelper::msNotesViewURL; 827cdf0e10cSrcweir break; 828cdf0e10cSrcweir case PK_HANDOUT: 829cdf0e10cSrcweir sViewURL = FrameworkHelper::msHandoutViewURL; 830cdf0e10cSrcweir break; 831cdf0e10cSrcweir default: 832cdf0e10cSrcweir break; 833cdf0e10cSrcweir } 834cdf0e10cSrcweir if (sViewURL.getLength() > 0) 835cdf0e10cSrcweir { 836cdf0e10cSrcweir ::boost::shared_ptr<FrameworkHelper> pHelper ( 837cdf0e10cSrcweir FrameworkHelper::Instance(rBase)); 838cdf0e10cSrcweir pHelper->RequestView( 839cdf0e10cSrcweir sViewURL, 840cdf0e10cSrcweir FrameworkHelper::msCenterPaneURL); 841cdf0e10cSrcweir pHelper->WaitForUpdate(); 842cdf0e10cSrcweir 843cdf0e10cSrcweir // Get the new DrawViewShell. 844cdf0e10cSrcweir mpViewShell = pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get(); 845cdf0e10cSrcweir pDrawViewShell = dynamic_cast<sd::DrawViewShell*>(mpViewShell); 846cdf0e10cSrcweir } 847cdf0e10cSrcweir else 848cdf0e10cSrcweir { 849cdf0e10cSrcweir pDrawViewShell = NULL; 850cdf0e10cSrcweir } 851cdf0e10cSrcweir } 852cdf0e10cSrcweir 853cdf0e10cSrcweir if (pDrawViewShell != NULL) 854cdf0e10cSrcweir { 855cdf0e10cSrcweir // Set the edit mode to either the normal edit mode or the 856cdf0e10cSrcweir // master page mode. 857cdf0e10cSrcweir EditMode eNewEditMode = EM_PAGE; 858cdf0e10cSrcweir if (bIsMasterPage) 859cdf0e10cSrcweir { 860cdf0e10cSrcweir eNewEditMode = EM_MASTERPAGE; 861cdf0e10cSrcweir } 862cdf0e10cSrcweir 863cdf0e10cSrcweir if (eNewEditMode != pDrawViewShell->GetEditMode()) 864cdf0e10cSrcweir { 865cdf0e10cSrcweir // EditMode setzen 866cdf0e10cSrcweir pDrawViewShell->ChangeEditMode(eNewEditMode, sal_False); 867cdf0e10cSrcweir } 868cdf0e10cSrcweir 869cdf0e10cSrcweir // Make the bookmarked page the current page. This is done 870cdf0e10cSrcweir // by using the API because this takes care of all the 871cdf0e10cSrcweir // little things to be done. Especially writing the view 872cdf0e10cSrcweir // data to the frame view (see bug #107803#). 873cdf0e10cSrcweir sal_uInt16 nSdPgNum = (nPageNumber - 1) / 2; 874cdf0e10cSrcweir Reference<drawing::XDrawView> xController (rBase.GetController(), UNO_QUERY); 875cdf0e10cSrcweir if (xController.is()) 876cdf0e10cSrcweir { 877cdf0e10cSrcweir Reference<drawing::XDrawPage> xDrawPage (pPage->getUnoPage(), UNO_QUERY); 878cdf0e10cSrcweir xController->setCurrentPage (xDrawPage); 879cdf0e10cSrcweir } 880cdf0e10cSrcweir else 881cdf0e10cSrcweir { 882cdf0e10cSrcweir // As a fall back switch to the page via the core. 883cdf0e10cSrcweir DBG_ASSERT (xController.is(), 884cdf0e10cSrcweir "DrawDocShell::GotoBookmark: can't switch page via API"); 885cdf0e10cSrcweir pDrawViewShell->SwitchPage(nSdPgNum); 886cdf0e10cSrcweir } 887cdf0e10cSrcweir 888cdf0e10cSrcweir if (pObj != NULL) 889cdf0e10cSrcweir { 890cdf0e10cSrcweir // Objekt einblenden und selektieren 891cdf0e10cSrcweir pDrawViewShell->MakeVisible(pObj->GetLogicRect(), 892cdf0e10cSrcweir *pDrawViewShell->GetActiveWindow()); 893cdf0e10cSrcweir pDrawViewShell->GetView()->UnmarkAll(); 894cdf0e10cSrcweir pDrawViewShell->GetView()->MarkObj( 895cdf0e10cSrcweir pObj, 896cdf0e10cSrcweir pDrawViewShell->GetView()->GetSdrPageView(), sal_False); 897cdf0e10cSrcweir } 898cdf0e10cSrcweir } 899cdf0e10cSrcweir } 900cdf0e10cSrcweir 901cdf0e10cSrcweir SfxBindings& rBindings = (pDrawViewShell->GetViewFrame()!=NULL 902cdf0e10cSrcweir ? pDrawViewShell->GetViewFrame() 903cdf0e10cSrcweir : SfxViewFrame::Current() )->GetBindings(); 904cdf0e10cSrcweir 905cdf0e10cSrcweir rBindings.Invalidate(SID_NAVIGATOR_STATE, sal_True, sal_False); 906cdf0e10cSrcweir rBindings.Invalidate(SID_NAVIGATOR_PAGENAME); 907cdf0e10cSrcweir } 908cdf0e10cSrcweir 909cdf0e10cSrcweir return (bFound); 910cdf0e10cSrcweir } 911cdf0e10cSrcweir 912cdf0e10cSrcweir /************************************************************************* 913cdf0e10cSrcweir |* 914cdf0e10cSrcweir |* SaveAsOwnFormat: wenn es eine Dokumentvorlage werden soll, 915cdf0e10cSrcweir |* 916cdf0e10cSrcweir \************************************************************************/ 917cdf0e10cSrcweir #include <tools/urlobj.hxx> 918cdf0e10cSrcweir 919cdf0e10cSrcweir sal_Bool DrawDocShell::SaveAsOwnFormat( SfxMedium& rMedium ) 920cdf0e10cSrcweir { 921cdf0e10cSrcweir 922cdf0e10cSrcweir const SfxFilter* pFilter = rMedium.GetFilter(); 923cdf0e10cSrcweir 924cdf0e10cSrcweir if (pFilter->IsOwnTemplateFormat()) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir // jetzt die StarDraw-Spezialitaeten: 927cdf0e10cSrcweir // die Layoutvorlagen der ersten Seite werden mit dem jetzt 928cdf0e10cSrcweir // bekannten Layoutnamen versehen, die Layoutnamen der betroffenen 929cdf0e10cSrcweir // Masterpages und Seiten werden gesetzt; 930cdf0e10cSrcweir // alle Textobjekte der betroffenen Standard-, Notiz- und 931cdf0e10cSrcweir // Masterpages werden ueber die Namensaenderung informiert 932cdf0e10cSrcweir 933cdf0e10cSrcweir String aLayoutName; 934cdf0e10cSrcweir 935cdf0e10cSrcweir SfxStringItem* pLayoutItem; 936cdf0e10cSrcweir if( rMedium.GetItemSet()->GetItemState(SID_TEMPLATE_NAME, sal_False, (const SfxPoolItem**) & pLayoutItem ) == SFX_ITEM_SET ) 937cdf0e10cSrcweir { 938cdf0e10cSrcweir aLayoutName = pLayoutItem->GetValue(); 939cdf0e10cSrcweir } 940cdf0e10cSrcweir else 941cdf0e10cSrcweir { 942cdf0e10cSrcweir INetURLObject aURL( rMedium.GetName() ); 943cdf0e10cSrcweir aURL.removeExtension(); 944cdf0e10cSrcweir aLayoutName = aURL.getName(); 945cdf0e10cSrcweir } 946cdf0e10cSrcweir 947cdf0e10cSrcweir if( aLayoutName.Len() ) 948cdf0e10cSrcweir { 949cdf0e10cSrcweir String aOldPageLayoutName = mpDoc->GetSdPage(0, PK_STANDARD)->GetLayoutName(); 950cdf0e10cSrcweir mpDoc->RenameLayoutTemplate(aOldPageLayoutName, aLayoutName); 951cdf0e10cSrcweir } 952cdf0e10cSrcweir } 953cdf0e10cSrcweir 954cdf0e10cSrcweir return SfxObjectShell::SaveAsOwnFormat(rMedium); 955cdf0e10cSrcweir } 956cdf0e10cSrcweir 957cdf0e10cSrcweir /************************************************************************* 958cdf0e10cSrcweir |* 959cdf0e10cSrcweir |* FillClass 960cdf0e10cSrcweir |* 961cdf0e10cSrcweir \************************************************************************/ 962cdf0e10cSrcweir 963cdf0e10cSrcweir void DrawDocShell::FillClass(SvGlobalName* pClassName, 964cdf0e10cSrcweir sal_uInt32* pFormat, 965cdf0e10cSrcweir String* , 966cdf0e10cSrcweir String* pFullTypeName, 967cdf0e10cSrcweir String* pShortTypeName, 968cdf0e10cSrcweir sal_Int32 nFileFormat, 969cdf0e10cSrcweir sal_Bool bTemplate /* = sal_False */) const 970cdf0e10cSrcweir { 971cdf0e10cSrcweir if (nFileFormat == SOFFICE_FILEFORMAT_60) 972cdf0e10cSrcweir { 973cdf0e10cSrcweir if ( meDocType == DOCUMENT_TYPE_DRAW ) 974cdf0e10cSrcweir { 975cdf0e10cSrcweir *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60); 976cdf0e10cSrcweir *pFormat = SOT_FORMATSTR_ID_STARDRAW_60; 977cdf0e10cSrcweir *pFullTypeName = String(SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_60)); 978cdf0e10cSrcweir } 979cdf0e10cSrcweir else 980cdf0e10cSrcweir { 981cdf0e10cSrcweir *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60); 982cdf0e10cSrcweir *pFormat = SOT_FORMATSTR_ID_STARIMPRESS_60; 983cdf0e10cSrcweir *pFullTypeName = String(SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_60)); 984cdf0e10cSrcweir } 985cdf0e10cSrcweir } 986cdf0e10cSrcweir else if (nFileFormat == SOFFICE_FILEFORMAT_8) 987cdf0e10cSrcweir { 988cdf0e10cSrcweir if ( meDocType == DOCUMENT_TYPE_DRAW ) 989cdf0e10cSrcweir { 990cdf0e10cSrcweir *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60); 991cdf0e10cSrcweir *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARDRAW_8_TEMPLATE : SOT_FORMATSTR_ID_STARDRAW_8; 992cdf0e10cSrcweir *pFullTypeName = String(RTL_CONSTASCII_USTRINGPARAM("Draw 8")); // HACK: method will be removed with new storage API 993cdf0e10cSrcweir } 994cdf0e10cSrcweir else 995cdf0e10cSrcweir { 996cdf0e10cSrcweir *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60); 997cdf0e10cSrcweir *pFormat = bTemplate ? SOT_FORMATSTR_ID_STARIMPRESS_8_TEMPLATE : SOT_FORMATSTR_ID_STARIMPRESS_8; 998cdf0e10cSrcweir *pFullTypeName = String(RTL_CONSTASCII_USTRINGPARAM("Impress 8")); // HACK: method will be removed with new storage API 999cdf0e10cSrcweir } 1000cdf0e10cSrcweir } 1001cdf0e10cSrcweir 1002cdf0e10cSrcweir *pShortTypeName = String(SdResId( (meDocType == DOCUMENT_TYPE_DRAW) ? 1003cdf0e10cSrcweir STR_GRAPHIC_DOCUMENT : STR_IMPRESS_DOCUMENT )); 1004cdf0e10cSrcweir } 1005cdf0e10cSrcweir 1006cdf0e10cSrcweir OutputDevice* DrawDocShell::GetDocumentRefDev (void) 1007cdf0e10cSrcweir { 1008cdf0e10cSrcweir OutputDevice* pReferenceDevice = SfxObjectShell::GetDocumentRefDev (); 1009cdf0e10cSrcweir // Only when our parent does not have a reference device then we return 1010cdf0e10cSrcweir // our own. 1011cdf0e10cSrcweir if (pReferenceDevice == NULL && mpDoc != NULL) 1012cdf0e10cSrcweir pReferenceDevice = mpDoc->GetRefDevice (); 1013cdf0e10cSrcweir return pReferenceDevice; 1014cdf0e10cSrcweir } 1015cdf0e10cSrcweir 1016cdf0e10cSrcweir /** executes the SID_OPENDOC slot to let the framework open a document 1017cdf0e10cSrcweir with the given URL and this document as a referer */ 1018cdf0e10cSrcweir void DrawDocShell::OpenBookmark( const String& rBookmarkURL ) 1019cdf0e10cSrcweir { 1020cdf0e10cSrcweir SfxStringItem aStrItem( SID_FILE_NAME, rBookmarkURL ); 1021cdf0e10cSrcweir SfxStringItem aReferer( SID_REFERER, GetMedium()->GetName() ); 1022cdf0e10cSrcweir const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, 0 }; 1023cdf0e10cSrcweir ( mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs ); 1024cdf0e10cSrcweir } 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir } // end of namespace sd 1027