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