LCOV - code coverage report
Current view: top level - sd/source/ui/docshell - docshel4.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 189 513 36.8 %
Date: 2015-06-13 12:38:46 Functions: 15 28 53.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "DrawDocShell.hxx"
      21             : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      22             : #include <tools/urlobj.hxx>
      23             : #include <sfx2/progress.hxx>
      24             : #include <vcl/waitobj.hxx>
      25             : #include <svx/svxids.hrc>
      26             : #include <editeng/editeng.hxx>
      27             : #include <editeng/editstat.hxx>
      28             : #include <editeng/flstitem.hxx>
      29             : #include <editeng/eeitem.hxx>
      30             : #include <svl/aeitem.hxx>
      31             : #include <svl/flagitem.hxx>
      32             : #include <sot/storage.hxx>
      33             : #include <sfx2/dinfdlg.hxx>
      34             : #include <sfx2/docfile.hxx>
      35             : #include <sfx2/docfilt.hxx>
      36             : #include <sfx2/dispatch.hxx>
      37             : #include <svx/svdotext.hxx>
      38             : #include <svl/style.hxx>
      39             : #include <sfx2/printer.hxx>
      40             : #include <svtools/ctrltool.hxx>
      41             : #include <svtools/sfxecode.hxx>
      42             : #include <comphelper/classids.hxx>
      43             : #include <sot/formats.hxx>
      44             : #include <sfx2/request.hxx>
      45             : #include <unotools/fltrcfg.hxx>
      46             : #include <sfx2/frame.hxx>
      47             : #include <sfx2/viewfrm.hxx>
      48             : #include <unotools/saveopt.hxx>
      49             : #include <com/sun/star/drawing/XDrawPage.hpp>
      50             : #include <com/sun/star/drawing/XDrawView.hpp>
      51             : #include <comphelper/processfactory.hxx>
      52             : 
      53             : #include "app.hrc"
      54             : #include "glob.hrc"
      55             : #include "strings.hrc"
      56             : #include "strmname.h"
      57             : #include "FrameView.hxx"
      58             : #include "optsitem.hxx"
      59             : #include "Outliner.hxx"
      60             : #include "sdattr.hxx"
      61             : #include "drawdoc.hxx"
      62             : #include "ViewShell.hxx"
      63             : #include "sdmod.hxx"
      64             : #include "View.hxx"
      65             : #include "sdpage.hxx"
      66             : #include "sdresid.hxx"
      67             : #include "DrawViewShell.hxx"
      68             : #include "ViewShellBase.hxx"
      69             : #include "Window.hxx"
      70             : #include "OutlineViewShell.hxx"
      71             : #include "sdxmlwrp.hxx"
      72             : #include "sdpptwrp.hxx"
      73             : #include "sdcgmfilter.hxx"
      74             : #include "sdgrffilter.hxx"
      75             : #include "sdhtmlfilter.hxx"
      76             : #include "framework/FrameworkHelper.hxx"
      77             : 
      78             : #include "SdUnoDrawView.hxx"
      79             : 
      80             : using namespace ::com::sun::star;
      81             : using namespace ::com::sun::star::uno;
      82             : using ::sd::framework::FrameworkHelper;
      83             : 
      84             : namespace sd {
      85             : 
      86             : /**
      87             :  * Creates (if necessary) and returns a SfxPrinter
      88             :  */
      89        2589 : SfxPrinter* DrawDocShell::GetPrinter(bool bCreate)
      90             : {
      91        2589 :     if (bCreate && !mpPrinter)
      92             :     {
      93             :         // create ItemSet with special pool area
      94           0 :         SfxItemSet* pSet = new SfxItemSet( GetPool(),
      95             :                             SID_PRINTER_NOTFOUND_WARN,  SID_PRINTER_NOTFOUND_WARN,
      96             :                             SID_PRINTER_CHANGESTODOC,   SID_PRINTER_CHANGESTODOC,
      97             :                             ATTR_OPTIONS_PRINT,         ATTR_OPTIONS_PRINT,
      98           0 :                             0 );
      99             :         // set PrintOptionsSet
     100             :         SdOptionsPrintItem aPrintItem( ATTR_OPTIONS_PRINT,
     101           0 :                             SD_MOD()->GetSdOptions(mpDoc->GetDocumentType()));
     102           0 :         SfxFlagItem aFlagItem( SID_PRINTER_CHANGESTODOC );
     103             :         SfxPrinterChangeFlags nFlags =
     104           0 :                 (aPrintItem.GetOptionsPrint().IsWarningSize() ? SfxPrinterChangeFlags::CHG_SIZE : SfxPrinterChangeFlags::NONE) |
     105           0 :                 (aPrintItem.GetOptionsPrint().IsWarningOrientation() ? SfxPrinterChangeFlags::CHG_ORIENTATION : SfxPrinterChangeFlags::NONE);
     106           0 :         aFlagItem.SetValue( static_cast<int>(nFlags) );
     107             : 
     108           0 :         pSet->Put( aPrintItem );
     109           0 :         pSet->Put( SfxBoolItem( SID_PRINTER_NOTFOUND_WARN, aPrintItem.GetOptionsPrint().IsWarningPrinter() ) );
     110           0 :         pSet->Put( aFlagItem );
     111             : 
     112           0 :         mpPrinter = VclPtr<SfxPrinter>::Create(pSet);
     113           0 :         mbOwnPrinter = true;
     114             : 
     115             :         // set output quality
     116           0 :         sal_uInt16 nQuality = aPrintItem.GetOptionsPrint().GetOutputQuality();
     117             : 
     118           0 :         DrawModeFlags nMode = DrawModeFlags::Default;
     119             :         // 1 == Grayscale, 2 == Black & White (with grayscale images)
     120           0 :         if( nQuality == 1 )
     121           0 :             nMode = DrawModeFlags::GrayLine | DrawModeFlags::GrayFill | DrawModeFlags::GrayText | DrawModeFlags::GrayBitmap | DrawModeFlags::GrayGradient;
     122           0 :         else if( nQuality == 2 )
     123           0 :             nMode = DrawModeFlags::BlackLine | DrawModeFlags::WhiteFill | DrawModeFlags::BlackText | DrawModeFlags::GrayBitmap | DrawModeFlags::WhiteGradient;
     124             : 
     125           0 :         mpPrinter->SetDrawMode( nMode );
     126             : 
     127           0 :         MapMode aMM (mpPrinter->GetMapMode());
     128           0 :         aMM.SetMapUnit(MAP_100TH_MM);
     129           0 :         mpPrinter->SetMapMode(aMM);
     130           0 :         UpdateRefDevice();
     131             :     }
     132        2589 :     return mpPrinter;
     133             : }
     134             : 
     135             : /**
     136             :  * Set new SfxPrinter (transfer of ownership)
     137             :  */
     138          15 : void DrawDocShell::SetPrinter(SfxPrinter *pNewPrinter)
     139             : {
     140          15 :     if ( mpViewShell )
     141             :     {
     142           0 :         ::sd::View* pView = mpViewShell->GetView();
     143           0 :         if ( pView->IsTextEdit() )
     144           0 :             pView->SdrEndTextEdit();
     145             :     }
     146             : 
     147          15 :     if ( mpPrinter && mbOwnPrinter && (mpPrinter.get() != pNewPrinter) )
     148           0 :         mpPrinter.disposeAndClear();
     149             : 
     150          15 :     mpPrinter = pNewPrinter;
     151          15 :     mbOwnPrinter = true;
     152          15 :     if ( mpDoc->GetPrinterIndependentLayout() == ::com::sun::star::document::PrinterIndependentLayout::DISABLED )
     153           1 :         UpdateFontList();
     154          15 :     UpdateRefDevice();
     155          15 : }
     156             : 
     157         360 : void DrawDocShell::UpdateFontList()
     158             : {
     159         360 :     delete mpFontList;
     160         360 :     OutputDevice* pRefDevice = NULL;
     161         360 :     if ( mpDoc->GetPrinterIndependentLayout() == ::com::sun::star::document::PrinterIndependentLayout::DISABLED )
     162           1 :         pRefDevice = GetPrinter(true);
     163             :     else
     164         359 :         pRefDevice = SD_MOD()->GetVirtualRefDevice();
     165         360 :     mpFontList = new FontList( pRefDevice, NULL, false );
     166         360 :     SvxFontListItem aFontListItem( mpFontList, SID_ATTR_CHAR_FONTLIST );
     167         360 :     PutItem( aFontListItem );
     168         360 : }
     169             : 
     170           0 : Printer* DrawDocShell::GetDocumentPrinter()
     171             : {
     172           0 :     return GetPrinter(false);
     173             : }
     174             : 
     175           0 : void DrawDocShell::OnDocumentPrinterChanged(Printer* pNewPrinter)
     176             : {
     177             :     // if we already have a printer, see if its the same
     178           0 :     if( mpPrinter )
     179             :     {
     180             :         // easy case
     181           0 :         if( mpPrinter == pNewPrinter )
     182           0 :             return;
     183             : 
     184             :         // compare if its the same printer with the same job setup
     185           0 :         if( (mpPrinter->GetName() == pNewPrinter->GetName()) &&
     186           0 :             (mpPrinter->GetJobSetup() == pNewPrinter->GetJobSetup()))
     187           0 :             return;
     188             :     }
     189             : 
     190             :     //  if (mpPrinter->IsA(SfxPrinter))
     191             :     {
     192             :         // Since we do not have RTTI we use a hard cast (...)
     193           0 :         SetPrinter(static_cast<SfxPrinter*>(pNewPrinter));
     194             : 
     195             :         // container owns printer
     196           0 :         mbOwnPrinter = false;
     197             :     }
     198             : }
     199             : 
     200         695 : void DrawDocShell::UpdateRefDevice()
     201             : {
     202         695 :     if( mpDoc )
     203             :     {
     204             :         // Determine the device for which the output will be formatted.
     205         377 :         VclPtr< OutputDevice > pRefDevice;
     206         377 :         switch (mpDoc->GetPrinterIndependentLayout())
     207             :         {
     208             :             case ::com::sun::star::document::PrinterIndependentLayout::DISABLED:
     209           2 :                 pRefDevice = mpPrinter.get();
     210           2 :                 break;
     211             : 
     212             :             case ::com::sun::star::document::PrinterIndependentLayout::ENABLED:
     213         375 :                 pRefDevice = SD_MOD()->GetVirtualRefDevice();
     214         375 :                 break;
     215             : 
     216             :             default:
     217             :                 // We are confronted with an invalid or un-implemented
     218             :                 // layout mode.  Use the printer as formatting device
     219             :                 // as a fall-back.
     220             :                 DBG_ASSERT(false, "DrawDocShell::UpdateRefDevice(): Unexpected printer layout mode");
     221             : 
     222           0 :                 pRefDevice = mpPrinter.get();
     223           0 :                 break;
     224             :         }
     225         377 :         mpDoc->SetRefDevice( pRefDevice.get() );
     226             : 
     227         377 :         ::sd::Outliner* pOutl = mpDoc->GetOutliner( false );
     228             : 
     229         377 :         if( pOutl )
     230           0 :             pOutl->SetRefDevice( pRefDevice );
     231             : 
     232         377 :         ::sd::Outliner* pInternalOutl = mpDoc->GetInternalOutliner( false );
     233             : 
     234         377 :         if( pInternalOutl )
     235          59 :             pInternalOutl->SetRefDevice( pRefDevice );
     236             :     }
     237         695 : }
     238             : 
     239             : /**
     240             :  * Creates new document, opens streams
     241             :  */
     242         211 : bool DrawDocShell::InitNew( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
     243             : {
     244         211 :     bool bRet = SfxObjectShell::InitNew( xStorage );
     245             : 
     246         211 :     Rectangle aVisArea( Point(0, 0), Size(14100, 10000) );
     247         211 :     SetVisArea(aVisArea);
     248             : 
     249         211 :     if (bRet)
     250             :     {
     251         211 :         if( !mbSdDataObj )
     252         211 :             mpDoc->NewOrLoadCompleted(NEW_DOC);  // otherwise calling
     253             :                                                 // NewOrLoadCompleted(NEW_LOADED) in
     254             :                                                 // SdDrawDocument::AllocModel()
     255             :     }
     256         211 :     return bRet;
     257             : }
     258             : 
     259             : /**
     260             :  * loads pools and document
     261             :  */
     262          41 : bool DrawDocShell::Load( SfxMedium& rMedium )
     263             : {
     264          41 :     mbNewDocument = false;
     265             : 
     266          41 :     bool       bRet = false;
     267          41 :     bool       bStartPresentation = false;
     268          41 :     ErrCode nError = ERRCODE_NONE;
     269             : 
     270          41 :     SfxItemSet* pSet = rMedium.GetItemSet();
     271             : 
     272          41 :     if( pSet )
     273             :     {
     274          41 :         if( (  SfxItemState::SET == pSet->GetItemState(SID_PREVIEW ) ) && static_cast<const SfxBoolItem&>( pSet->Get( SID_PREVIEW ) ).GetValue() )
     275             :         {
     276           0 :             mpDoc->SetStarDrawPreviewMode( true );
     277             :         }
     278             : 
     279          41 :         if( SfxItemState::SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&&
     280           0 :             static_cast<const SfxBoolItem&>( pSet->Get( SID_DOC_STARTPRESENTATION ) ).GetValue() )
     281             :         {
     282           0 :             bStartPresentation = true;
     283           0 :             mpDoc->SetStartWithPresentation( true );
     284             :         }
     285             :     }
     286             : 
     287          41 :     bRet = SfxObjectShell::Load( rMedium );
     288          41 :     if( bRet )
     289             :     {
     290          41 :         bRet = SdXMLFilter( rMedium, *this, true, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
     291             :     }
     292             : 
     293          41 :     if( bRet )
     294             :     {
     295          41 :         UpdateTablePointers();
     296             : 
     297             :         // If we're an embedded OLE object, use tight bounds
     298             :         // for our visArea. No point in showing the user lots of empty
     299             :         // space. Had to remove the check for empty VisArea below,
     300             :         // since XML load always sets a VisArea before.
     301             :         //TODO/LATER: looks a little bit strange!
     302          41 :         if( ( GetCreateMode() == SfxObjectCreateMode::EMBEDDED ) && SfxObjectShell::GetVisArea( ASPECT_CONTENT ).IsEmpty() )
     303             :         {
     304           1 :             SdPage* pPage = mpDoc->GetSdPage( 0, PK_STANDARD );
     305             : 
     306           1 :             if( pPage )
     307           1 :                 SetVisArea( Rectangle( pPage->GetAllObjBoundRect() ) );
     308             :         }
     309             : 
     310          41 :         FinishedLoading( SfxLoadedFlags::ALL );
     311             : 
     312          41 :         const INetURLObject aUrl;
     313          41 :         SfxObjectShell::SetAutoLoad( aUrl, 0, false );
     314             :     }
     315             :     else
     316             :     {
     317           0 :         if( nError == ERRCODE_IO_BROKENPACKAGE )
     318           0 :             SetError( ERRCODE_IO_BROKENPACKAGE, OSL_LOG_PREFIX );
     319             : 
     320             :         // TODO/LATER: correct error handling?!
     321             :         //pStore->SetError( SVSTREAM_WRONGVERSION, OUString( OSL_LOG_PREFIX ) );
     322             :         else
     323           0 :             SetError( ERRCODE_ABORT, OSL_LOG_PREFIX );
     324             :     }
     325             : 
     326             :     // tell SFX to change viewshell when in preview mode
     327          41 :     if( IsPreview() || bStartPresentation )
     328             :     {
     329           0 :         SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
     330           0 :         if( pMediumSet )
     331           0 :             pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) );
     332             :     }
     333             : 
     334          41 :     return bRet;
     335             : }
     336             : 
     337             : /**
     338             :  * loads content for organizer
     339             :  */
     340           0 : bool DrawDocShell::LoadFrom( SfxMedium& rMedium )
     341             : {
     342           0 :     mbNewDocument = false;
     343             : 
     344           0 :     WaitObject* pWait = NULL;
     345           0 :     if( mpViewShell )
     346           0 :         pWait = new WaitObject( static_cast<vcl::Window*>(mpViewShell->GetActiveWindow()) );
     347             : 
     348           0 :     mpDoc->NewOrLoadCompleted( NEW_DOC );
     349           0 :     mpDoc->CreateFirstPages();
     350           0 :     mpDoc->StopWorkStartupDelay();
     351             : 
     352             :     // TODO/LATER: nobody is interested in the error code?!
     353           0 :     ErrCode nError = ERRCODE_NONE;
     354           0 :     bool bRet = SdXMLFilter( rMedium, *this, true, SDXMLMODE_Organizer, SotStorage::GetVersion( rMedium.GetStorage() ) ).Import( nError );
     355             : 
     356             :     // tell SFX to change viewshell when in preview mode
     357           0 :     if( IsPreview() )
     358             :     {
     359           0 :         SfxItemSet *pSet = GetMedium()->GetItemSet();
     360             : 
     361           0 :         if( pSet )
     362           0 :             pSet->Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
     363             :     }
     364             : 
     365           0 :     delete pWait;
     366             : 
     367           0 :     return bRet;
     368             : }
     369             : 
     370             : /**
     371             :  * load from 3rd party format
     372             :  */
     373          86 : bool DrawDocShell::ImportFrom(SfxMedium &rMedium,
     374             :         uno::Reference<text::XTextRange> const& xInsertPosition)
     375             : {
     376          86 :     const OUString aFilterName( rMedium.GetFilter()->GetFilterName() );
     377         166 :     if( aFilterName == "Impress MS PowerPoint 2007 XML" ||
     378          80 :         aFilterName == "Impress MS PowerPoint 2007 XML AutoPlay" )
     379             :     {
     380             :         // As this is a MSFT format, we should use the "MS Compat"
     381             :         // mode for spacing before and after paragraphs.
     382             : 
     383             :         // This is copied from what is done for .ppt import in
     384             :         // ImplSdPPTImport::Import() in sd/source/filter/ppt/pptin.cxx
     385             :         // in. We need to tell both the edit engine of the draw outliner,
     386             :         // and the document, to do "summation of paragraphs".
     387           6 :         SdrOutliner& rOutl = mpDoc->GetDrawOutliner();
     388           6 :         EEControlBits nControlWord = rOutl.GetEditEngine().GetControlWord();
     389           6 :         nControlWord |=  EEControlBits::ULSPACESUMMATION;
     390           6 :         nControlWord &=~ EEControlBits::ULSPACEFIRSTPARA;
     391           6 :         ((EditEngine&)rOutl.GetEditEngine()).SetControlWord( nControlWord );
     392             : 
     393           6 :         mpDoc->SetSummationOfParagraphs( true );
     394             :     }
     395             : 
     396          86 :     const bool bRet = SfxObjectShell::ImportFrom(rMedium, xInsertPosition);
     397             : 
     398          86 :     SfxItemSet* pSet = rMedium.GetItemSet();
     399          86 :     if( pSet )
     400             :     {
     401          86 :         if( SfxItemState::SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&&
     402           0 :             static_cast<const SfxBoolItem&>( pSet->Get( SID_DOC_STARTPRESENTATION ) ).GetValue() )
     403             :         {
     404           0 :             mpDoc->SetStartWithPresentation( true );
     405             : 
     406             :             // tell SFX to change viewshell when in preview mode
     407           0 :             if( IsPreview() )
     408             :             {
     409           0 :                 SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
     410           0 :                 if( pMediumSet )
     411           0 :                     pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, 1 ) );
     412             :             }
     413             :         }
     414             :     }
     415             : 
     416          86 :     return bRet;
     417             : }
     418             : 
     419             : /**
     420             :  * load from a foreign format
     421             :  */
     422          19 : bool DrawDocShell::ConvertFrom( SfxMedium& rMedium )
     423             : {
     424          19 :     mbNewDocument = false;
     425             : 
     426          19 :     const OUString  aFilterName( rMedium.GetFilter()->GetFilterName() );
     427          19 :     bool            bRet = false;
     428          19 :     bool            bStartPresentation = false;
     429             : 
     430          19 :     SetWaitCursor( true );
     431             : 
     432          19 :     SfxItemSet* pSet = rMedium.GetItemSet();
     433          19 :     if( pSet )
     434             :     {
     435          19 :         if( (  SfxItemState::SET == pSet->GetItemState(SID_PREVIEW ) ) && static_cast<const SfxBoolItem&>( pSet->Get( SID_PREVIEW ) ).GetValue() )
     436             :         {
     437           0 :             mpDoc->SetStarDrawPreviewMode( true );
     438             :         }
     439             : 
     440          19 :         if( SfxItemState::SET == pSet->GetItemState(SID_DOC_STARTPRESENTATION)&&
     441           0 :             static_cast<const SfxBoolItem&>( pSet->Get( SID_DOC_STARTPRESENTATION ) ).GetValue() )
     442             :         {
     443           0 :             bStartPresentation = true;
     444           0 :             mpDoc->SetStartWithPresentation( true );
     445             :         }
     446             :     }
     447             : 
     448          38 :     if( aFilterName == pFilterPowerPoint97
     449           6 :         || aFilterName == pFilterPowerPoint97Template
     450          25 :         || aFilterName == pFilterPowerPoint97AutoPlay)
     451             :     {
     452          13 :         mpDoc->StopWorkStartupDelay();
     453          13 :         bRet = SdPPTFilter( rMedium, *this, true ).Import();
     454             :     }
     455          10 :     else if (aFilterName.indexOf("impress8") >= 0 ||
     456           4 :              aFilterName.indexOf("draw8") >= 0)
     457             :     {
     458             :         // TODO/LATER: nobody is interested in the error code?!
     459           3 :         mpDoc->CreateFirstPages();
     460           3 :         mpDoc->StopWorkStartupDelay();
     461           3 :         ErrCode nError = ERRCODE_NONE;
     462           3 :         bRet = SdXMLFilter( rMedium, *this, true ).Import( nError );
     463             : 
     464             :     }
     465           6 :     else if (aFilterName.indexOf("StarOffice XML (Draw)") >= 0 ||
     466           3 :              aFilterName.indexOf("StarOffice XML (Impress)") >= 0)
     467             :     {
     468             :         // TODO/LATER: nobody is interested in the error code?!
     469           0 :         mpDoc->CreateFirstPages();
     470           0 :         mpDoc->StopWorkStartupDelay();
     471           0 :         ErrCode nError = ERRCODE_NONE;
     472           0 :         bRet = SdXMLFilter( rMedium, *this, true, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 ).Import( nError );
     473             :     }
     474           3 :     else if( aFilterName == "CGM - Computer Graphics Metafile" )
     475             :     {
     476           2 :         mpDoc->CreateFirstPages();
     477           2 :         mpDoc->StopWorkStartupDelay();
     478           2 :         bRet = SdCGMFilter( rMedium, *this, true ).Import();
     479             :     }
     480             :     else
     481             :     {
     482           1 :         mpDoc->CreateFirstPages();
     483           1 :         mpDoc->StopWorkStartupDelay();
     484           1 :         bRet = SdGRFFilter( rMedium, *this ).Import();
     485             :     }
     486             : 
     487          19 :     FinishedLoading( SfxLoadedFlags::ALL );
     488             : 
     489             :     // tell SFX to change viewshell when in preview mode
     490          19 :     if( IsPreview() )
     491             :     {
     492           0 :         SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
     493             : 
     494           0 :         if( pMediumSet )
     495           0 :             pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, 5 ) );
     496             :     }
     497          19 :     SetWaitCursor( false );
     498             : 
     499             :     // tell SFX to change viewshell when in preview mode
     500          19 :     if( IsPreview() || bStartPresentation )
     501             :     {
     502           0 :         SfxItemSet *pMediumSet = GetMedium()->GetItemSet();
     503           0 :         if( pMediumSet )
     504           0 :             pMediumSet->Put( SfxUInt16Item( SID_VIEW_ID, bStartPresentation ? 1 : 5 ) );
     505             :     }
     506             : 
     507          19 :     return bRet;
     508             : }
     509             : 
     510             : /**
     511             :  * Writes pools and document to the open streams
     512             :  */
     513           0 : bool DrawDocShell::Save()
     514             : {
     515           0 :     mpDoc->StopWorkStartupDelay();
     516             : 
     517             :     //TODO/LATER: why this?!
     518           0 :     if( GetCreateMode() == SfxObjectCreateMode::STANDARD )
     519           0 :         SfxObjectShell::SetVisArea( Rectangle() );
     520             : 
     521           0 :     bool bRet = SfxObjectShell::Save();
     522             : 
     523           0 :     if( bRet )
     524           0 :         bRet = SdXMLFilter( *GetMedium(), *this, true, SDXMLMODE_Normal, SotStorage::GetVersion( GetMedium()->GetStorage() ) ).Export();
     525             : 
     526           0 :     return bRet;
     527             : }
     528             : 
     529             : /**
     530             :  * Writes pools and document to the provided storage
     531             :  */
     532          13 : bool DrawDocShell::SaveAs( SfxMedium& rMedium )
     533             : {
     534          13 :     mpDoc->setDocAccTitle(OUString());
     535          13 :     SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this );
     536          13 :     if (pFrame1)
     537             :     {
     538           2 :         vcl::Window* pWindow = &pFrame1->GetWindow();
     539           2 :         if ( pWindow )
     540             :         {
     541           2 :             vcl::Window* pSysWin = pWindow->GetSystemWindow();
     542           2 :             if ( pSysWin )
     543             :             {
     544           2 :                 pSysWin->SetAccessibleName(OUString());
     545             :             }
     546             :         }
     547             :     }
     548          13 :     mpDoc->StopWorkStartupDelay();
     549             : 
     550             :     //TODO/LATER: why this?!
     551          13 :     if( GetCreateMode() == SfxObjectCreateMode::STANDARD )
     552           2 :         SfxObjectShell::SetVisArea( Rectangle() );
     553             : 
     554          13 :     sal_uInt32  nVBWarning = ERRCODE_NONE;
     555          13 :     bool    bRet = SfxObjectShell::SaveAs( rMedium );
     556             : 
     557          13 :     if( bRet )
     558          13 :         bRet = SdXMLFilter( rMedium, *this, true, SDXMLMODE_Normal, SotStorage::GetVersion( rMedium.GetStorage() ) ).Export();
     559             : 
     560          13 :     if( GetError() == ERRCODE_NONE )
     561           8 :         SetError( nVBWarning, OSL_LOG_PREFIX );
     562             : 
     563          13 :     return bRet;
     564             : }
     565             : 
     566             : /**
     567             :  * save to foreign format
     568             :  */
     569           4 : bool DrawDocShell::ConvertTo( SfxMedium& rMedium )
     570             : {
     571           4 :     bool bRet = false;
     572             : 
     573           4 :     if( mpDoc->GetPageCount() )
     574             :     {
     575           4 :         const SfxFilter*    pMediumFilter = rMedium.GetFilter();
     576           4 :         const OUString aTypeName( pMediumFilter->GetTypeName() );
     577           4 :         SdFilter*           pFilter = NULL;
     578             : 
     579           4 :         if( aTypeName.indexOf( "graphic_HTML" ) >= 0 )
     580             :         {
     581           1 :             pFilter = new SdHTMLFilter( rMedium, *this, true );
     582             :         }
     583           3 :         else if( aTypeName.indexOf( "MS_PowerPoint_97" ) >= 0 )
     584             :         {
     585           3 :             pFilter = new SdPPTFilter( rMedium, *this, true );
     586           3 :             static_cast<SdPPTFilter*>(pFilter)->PreSaveBasic();
     587             :         }
     588           0 :         else if ( aTypeName.indexOf( "CGM_Computer_Graphics_Metafile" ) >= 0 )
     589             :         {
     590           0 :             pFilter = new SdCGMFilter( rMedium, *this, true );
     591             :         }
     592           0 :         else if( aTypeName.indexOf( "draw8" ) >= 0 ||
     593           0 :                  aTypeName.indexOf( "impress8" ) >= 0 )
     594             :         {
     595           0 :             pFilter = new SdXMLFilter( rMedium, *this, true );
     596             :         }
     597           0 :         else if( aTypeName.indexOf( "StarOffice_XML_Impress" ) >= 0 ||
     598           0 :                  aTypeName.indexOf( "StarOffice_XML_Draw" ) >= 0 )
     599             :         {
     600           0 :             pFilter = new SdXMLFilter( rMedium, *this, true, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 );
     601             :         }
     602             :         else
     603             :         {
     604           0 :             pFilter = new SdGRFFilter( rMedium, *this );
     605             :         }
     606             : 
     607           4 :         if( pFilter )
     608             :         {
     609           4 :             const SdrSwapGraphicsMode nOldSwapMode = mpDoc->GetSwapGraphicsMode();
     610             : 
     611           4 :             mpDoc->SetSwapGraphicsMode( SdrSwapGraphicsMode::TEMP );
     612             : 
     613           4 :             bRet = pFilter->Export();
     614           4 :             if( !bRet )
     615           0 :                 mpDoc->SetSwapGraphicsMode( nOldSwapMode );
     616             : 
     617           4 :             delete pFilter;
     618           4 :         }
     619             :     }
     620             : 
     621           4 :     return  bRet;
     622             : }
     623             : 
     624             : /**
     625             :  * Reopen own streams to ensure that nobody else can prevent use from opening
     626             :  * them.
     627             :  */
     628          21 : bool DrawDocShell::SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage )
     629             : {
     630          21 :     bool bRet = false;
     631             : 
     632          21 :     if( SfxObjectShell::SaveCompleted(xStorage) )
     633             :     {
     634          21 :         mpDoc->NbcSetChanged( false );
     635             : 
     636          21 :         if( mpViewShell )
     637             :         {
     638           2 :             if( mpViewShell->ISA( OutlineViewShell ) )
     639           0 :                 static_cast<OutlineView*>(mpViewShell->GetView())
     640           0 :                     ->GetOutliner().ClearModifyFlag();
     641             : 
     642           2 :             SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner();
     643           2 :             if( pOutl )
     644             :             {
     645           0 :                 SdrObject* pObj = mpViewShell->GetView()->GetTextEditObject();
     646           0 :                 if( pObj )
     647           0 :                     pObj->NbcSetOutlinerParaObject( pOutl->CreateParaObject() );
     648             : 
     649           0 :                 pOutl->ClearModifyFlag();
     650             :             }
     651             :         }
     652             : 
     653          21 :         bRet = true;
     654             : 
     655           2 :         SfxViewFrame* pFrame = ( mpViewShell && mpViewShell->GetViewFrame() ) ?
     656           2 :                                mpViewShell->GetViewFrame() :
     657          23 :                                SfxViewFrame::Current();
     658             : 
     659          21 :         if( pFrame )
     660          12 :             pFrame->GetBindings().Invalidate( SID_NAVIGATOR_STATE, true, false );
     661             :     }
     662          21 :     return bRet;
     663             : }
     664             : 
     665           0 : SfxStyleSheetBasePool* DrawDocShell::GetStyleSheetPool()
     666             : {
     667           0 :     return mpDoc->GetStyleSheetPool();
     668             : }
     669             : 
     670           0 : bool DrawDocShell::GotoBookmark(const OUString& rBookmark)
     671             : {
     672           0 :     bool bFound = false;
     673             : 
     674           0 :     if (mpViewShell && mpViewShell->ISA(DrawViewShell))
     675             :     {
     676           0 :         DrawViewShell* pDrawViewShell = static_cast<DrawViewShell*>(mpViewShell);
     677           0 :         ViewShellBase& rBase (mpViewShell->GetViewShellBase());
     678             : 
     679           0 :         bool bIsMasterPage = false;
     680           0 :         sal_uInt16 nPageNumber = SDRPAGE_NOTFOUND;
     681           0 :         SdrObject* pObj = NULL;
     682             : 
     683           0 :         OUString sBookmark( rBookmark );
     684           0 :         const OUString sInteraction( "action?" );
     685           0 :         if ( sBookmark.match( sInteraction ) )
     686             :         {
     687           0 :             const OUString sJump( "jump=" );
     688           0 :             if ( sBookmark.match( sJump, sInteraction.getLength() ) )
     689             :             {
     690           0 :                 OUString aDestination( sBookmark.copy( sInteraction.getLength() + sJump.getLength() ) );
     691           0 :                 if ( aDestination.match( "firstslide" ) )
     692             :                 {
     693           0 :                     nPageNumber = 1;
     694             :                 }
     695           0 :                 else if ( aDestination.match( "lastslide" ) )
     696             :                 {
     697           0 :                     nPageNumber = mpDoc->GetPageCount() - 2;
     698             :                 }
     699           0 :                 else if ( aDestination.match( "previousslide" ) )
     700             :                 {
     701           0 :                     SdPage* pPage = pDrawViewShell->GetActualPage();
     702           0 :                     nPageNumber = pPage->GetPageNum();
     703           0 :                     nPageNumber = nPageNumber > 2 ? nPageNumber - 2 : SDRPAGE_NOTFOUND;
     704             :                 }
     705           0 :                 else if ( aDestination.match( "nextslide" ) )
     706             :                 {
     707           0 :                     SdPage* pPage = pDrawViewShell->GetActualPage();
     708           0 :                     nPageNumber = pPage->GetPageNum() + 2;
     709           0 :                     if ( nPageNumber >= mpDoc->GetPageCount() )
     710           0 :                         nPageNumber = SDRPAGE_NOTFOUND;
     711           0 :                 }
     712           0 :             }
     713             :         }
     714             :         else
     715             :         {
     716           0 :             OUString aBookmark( rBookmark );
     717             : 
     718             :             // Is the bookmark a page?
     719           0 :             nPageNumber = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
     720             : 
     721           0 :             if (nPageNumber == SDRPAGE_NOTFOUND)
     722             :             {
     723             :                 // Is the bookmark a object?
     724           0 :                 pObj = mpDoc->GetObj(aBookmark);
     725             : 
     726           0 :                 if (pObj)
     727             :                 {
     728           0 :                     nPageNumber = pObj->GetPage()->GetPageNum();
     729             :                 }
     730           0 :             }
     731             :         }
     732           0 :         if (nPageNumber != SDRPAGE_NOTFOUND)
     733             :         {
     734             :             // Jump to the bookmarked page.  This is done in three steps.
     735             : 
     736           0 :             bFound = true;
     737             :             SdPage* pPage;
     738           0 :             if (bIsMasterPage)
     739           0 :                 pPage = static_cast<SdPage*>( mpDoc->GetMasterPage(nPageNumber) );
     740             :             else
     741           0 :                 pPage = static_cast<SdPage*>( mpDoc->GetPage(nPageNumber) );
     742             : 
     743             :             // 1.) Change the view shell to the edit view, the notes view,
     744             :             // or the handout view.
     745           0 :             PageKind eNewPageKind = pPage->GetPageKind();
     746             : 
     747           0 :             if( (eNewPageKind != PK_STANDARD) && (mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW) )
     748           0 :                 return false;
     749             : 
     750           0 :             if (eNewPageKind != pDrawViewShell->GetPageKind())
     751             :             {
     752             :                 // change work area
     753           0 :                 GetFrameView()->SetPageKind(eNewPageKind);
     754           0 :                 OUString sViewURL;
     755           0 :                 switch (eNewPageKind)
     756             :                 {
     757             :                     case PK_STANDARD:
     758           0 :                         sViewURL = FrameworkHelper::msImpressViewURL;
     759           0 :                         break;
     760             :                     case PK_NOTES:
     761           0 :                         sViewURL = FrameworkHelper::msNotesViewURL;
     762           0 :                         break;
     763             :                     case PK_HANDOUT:
     764           0 :                         sViewURL = FrameworkHelper::msHandoutViewURL;
     765           0 :                         break;
     766             :                     default:
     767           0 :                         break;
     768             :                 }
     769           0 :                 if (!sViewURL.isEmpty())
     770             :                 {
     771             :                     ::boost::shared_ptr<FrameworkHelper> pHelper (
     772           0 :                         FrameworkHelper::Instance(rBase));
     773             :                     pHelper->RequestView(
     774             :                         sViewURL,
     775           0 :                         FrameworkHelper::msCenterPaneURL);
     776           0 :                     pHelper->WaitForUpdate();
     777             : 
     778             :                     // Get the new DrawViewShell.
     779           0 :                     mpViewShell = pHelper->GetViewShell(FrameworkHelper::msCenterPaneURL).get();
     780           0 :                     pDrawViewShell = dynamic_cast<sd::DrawViewShell*>(mpViewShell);
     781             :                 }
     782             :                 else
     783             :                 {
     784           0 :                     pDrawViewShell = NULL;
     785           0 :                 }
     786             :             }
     787             : 
     788           0 :             if (pDrawViewShell != NULL)
     789             :             {
     790           0 :                 setEditMode(pDrawViewShell, bIsMasterPage);
     791             : 
     792             :                 // Make the bookmarked page the current page.  This is done
     793             :                 // by using the API because this takes care of all the
     794             :                 // little things to be done.  Especially writing the view
     795             :                 // data to the frame view.
     796           0 :                 sal_uInt16 nSdPgNum = (nPageNumber - 1) / 2;
     797           0 :                 Reference<drawing::XDrawView> xController (rBase.GetController(), UNO_QUERY);
     798           0 :                 if (xController.is())
     799             :                 {
     800           0 :                     Reference<drawing::XDrawPage> xDrawPage (pPage->getUnoPage(), UNO_QUERY);
     801           0 :                     xController->setCurrentPage (xDrawPage);
     802             :                 }
     803             :                 else
     804             :                 {
     805             :                     // As a fall back switch to the page via the core.
     806             :                     DBG_ASSERT (xController.is(),
     807             :                         "DrawDocShell::GotoBookmark: can't switch page via API");
     808           0 :                     pDrawViewShell->SwitchPage(nSdPgNum);
     809             :                 }
     810             : 
     811           0 :                 if (pObj != NULL)
     812             :                 {
     813             :                     // show and select object
     814           0 :                     pDrawViewShell->MakeVisible(pObj->GetLogicRect(),
     815           0 :                         *pDrawViewShell->GetActiveWindow());
     816           0 :                     pDrawViewShell->GetView()->UnmarkAll();
     817           0 :                     pDrawViewShell->GetView()->MarkObj(
     818             :                         pObj,
     819           0 :                         pDrawViewShell->GetView()->GetSdrPageView(), false);
     820           0 :                 }
     821             :             }
     822             :         }
     823             : 
     824           0 :         SfxBindings& rBindings = ((pDrawViewShell && pDrawViewShell->GetViewFrame()!=NULL)
     825           0 :             ? pDrawViewShell->GetViewFrame()
     826           0 :             : SfxViewFrame::Current() )->GetBindings();
     827             : 
     828           0 :         rBindings.Invalidate(SID_NAVIGATOR_STATE, true, false);
     829           0 :         rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
     830             :     }
     831             : 
     832           0 :     return (bFound);
     833             : }
     834             : 
     835             : // If object is marked return true else return false.
     836           0 : bool DrawDocShell::IsMarked( SdrObject* pObject )
     837             : {
     838           0 :     bool bisMarked =false;
     839             : 
     840           0 :     if (mpViewShell && mpViewShell->ISA(DrawViewShell))
     841             :     {
     842           0 :         DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
     843           0 :         if (pObject )
     844             :         {
     845           0 :               bisMarked = pDrViewSh->GetView()->IsObjMarked(pObject);
     846             :         }
     847             :      }
     848           0 :     return  bisMarked;
     849             : }
     850             : 
     851             : // If object is marked return true else return false.
     852           0 : bool DrawDocShell::GetObjectIsmarked(const OUString& rBookmark)
     853             : {
     854             :     OSL_TRACE("GotoBookmark %s",
     855             :         OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
     856           0 :     bool bUnMark = false;
     857             : 
     858           0 :     if (mpViewShell && mpViewShell->ISA(DrawViewShell))
     859             :     {
     860           0 :         DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
     861             : 
     862           0 :         OUString aBookmark( rBookmark );
     863             : 
     864           0 :         if( rBookmark.startsWith("#") )
     865           0 :             aBookmark = rBookmark.copy( 1 );
     866             : 
     867             :         // Is the bookmark a page ?
     868             :         bool        bIsMasterPage;
     869           0 :         sal_uInt16  nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
     870           0 :         SdrObject*  pObj = NULL;
     871             : 
     872           0 :         if (nPgNum == SDRPAGE_NOTFOUND)
     873             :         {
     874             :             // Is the bookmark an object ?
     875           0 :             pObj = mpDoc->GetObj(aBookmark);
     876             : 
     877           0 :             if (pObj)
     878             :             {
     879           0 :                 nPgNum = pObj->GetPage()->GetPageNum();
     880             :             }
     881             :         }
     882             : 
     883           0 :         if (nPgNum != SDRPAGE_NOTFOUND)
     884             :         {
     885             :             /********************
     886             :              * Skip to the page *
     887             :              ********************/
     888           0 :             SdPage* pPage = static_cast<SdPage*>( mpDoc->GetPage(nPgNum) );
     889             : 
     890           0 :             PageKind eNewPageKind = pPage->GetPageKind();
     891             : 
     892           0 :             if (eNewPageKind != pDrViewSh->GetPageKind())
     893             :             {
     894             :                 // change workspace
     895           0 :                 GetFrameView()->SetPageKind(eNewPageKind);
     896           0 :                 ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
     897           0 :                   mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->
     898           0 :                   GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
     899             : 
     900             :                 // The current ViewShell changed
     901           0 :                 pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
     902             :             }
     903             : 
     904           0 :             setEditMode(pDrViewSh, bIsMasterPage);
     905             : 
     906             :             // Jump to the page.  This is done by using the API because this
     907             :             // takes care of all the little things to be done.  Especially
     908             :             // writing the view data to the frame view (see bug #107803#).
     909             :             SdUnoDrawView* pUnoDrawView = new SdUnoDrawView (
     910             :                 *pDrViewSh,
     911           0 :                 *pDrViewSh->GetView());
     912             :             ::com::sun::star::uno::Reference<
     913             :                   ::com::sun::star::drawing::XDrawPage> xDrawPage (
     914           0 :                       pPage->getUnoPage(), ::com::sun::star::uno::UNO_QUERY);
     915           0 :             pUnoDrawView->setCurrentPage (xDrawPage);
     916           0 :             delete pUnoDrawView;
     917             : 
     918           0 :             if (pObj)
     919             :             {
     920             :                 // Show and select object
     921           0 :                 pDrViewSh->MakeVisible(pObj->GetLogicRect(),
     922           0 :                                        *pDrViewSh->GetActiveWindow());
     923             : 
     924           0 :                 bUnMark = pDrViewSh->GetView()->IsObjMarked(pObj);
     925           0 :             }
     926           0 :         }
     927             :     }
     928             : 
     929           0 :     return ( bUnMark);
     930             : }
     931             : 
     932             : // realize multi-selection of objects
     933           0 : bool DrawDocShell::GotoTreeBookmark(const OUString& rBookmark)
     934             : {
     935             :     OSL_TRACE("GotoBookmark %s",
     936             :         OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
     937           0 :     bool bFound = false;
     938             : 
     939           0 :     if (mpViewShell && mpViewShell->ISA(DrawViewShell))
     940             :     {
     941           0 :         DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
     942             : 
     943           0 :         OUString aBookmark( rBookmark );
     944             : 
     945           0 :         if( rBookmark.startsWith("#") )
     946           0 :             aBookmark = rBookmark.copy( 1 );
     947             : 
     948             :         // is the bookmark a page ?
     949             :         bool        bIsMasterPage;
     950           0 :         sal_uInt16  nPgNum = mpDoc->GetPageByName( aBookmark, bIsMasterPage );
     951           0 :         SdrObject*  pObj = NULL;
     952             : 
     953           0 :         if (nPgNum == SDRPAGE_NOTFOUND)
     954             :         {
     955             :             // is the bookmark an object ?
     956           0 :             pObj = mpDoc->GetObj(aBookmark);
     957             : 
     958           0 :             if (pObj)
     959             :             {
     960           0 :                 nPgNum = pObj->GetPage()->GetPageNum();
     961             :             }
     962             :         }
     963             : 
     964           0 :         if (nPgNum != SDRPAGE_NOTFOUND)
     965             :         {
     966             :             /********************
     967             :              * Skip to the page *
     968             :              ********************/
     969           0 :             bFound = true;
     970           0 :             SdPage* pPage = static_cast<SdPage*>( mpDoc->GetPage(nPgNum) );
     971             : 
     972           0 :             PageKind eNewPageKind = pPage->GetPageKind();
     973             : 
     974           0 :             if (eNewPageKind != pDrViewSh->GetPageKind())
     975             :             {
     976             :                 // change workspace
     977           0 :                 GetFrameView()->SetPageKind(eNewPageKind);
     978           0 :                 ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
     979           0 :                   mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->
     980           0 :                   GetDispatcher()->Execute( SID_VIEWSHELL0, SfxCallMode::SYNCHRON | SfxCallMode::RECORD );
     981             : 
     982             :                 // The current ViewShell changed
     983           0 :                 pDrViewSh = static_cast<DrawViewShell*>( mpViewShell );
     984             :             }
     985             : 
     986           0 :             setEditMode(pDrViewSh, bIsMasterPage);
     987             : 
     988             :             // Jump to the page.  This is done by using the API because this
     989             :             // takes care of all the little things to be done.  Especially
     990             :             // writing the view data to the frame view (see bug #107803#).
     991             :             SdUnoDrawView* pUnoDrawView = new SdUnoDrawView (
     992             :                 *pDrViewSh,
     993           0 :                 *pDrViewSh->GetView());
     994             :             ::com::sun::star::uno::Reference<
     995             :                   ::com::sun::star::drawing::XDrawPage> xDrawPage (
     996           0 :                       pPage->getUnoPage(), ::com::sun::star::uno::UNO_QUERY);
     997           0 :             pUnoDrawView->setCurrentPage (xDrawPage);
     998           0 :             delete pUnoDrawView;
     999             : 
    1000           0 :             if (pObj)
    1001             :             {
    1002             :                 // Show and select object
    1003           0 :                 pDrViewSh->MakeVisible(pObj->GetLogicRect(),
    1004           0 :                                        *pDrViewSh->GetActiveWindow());
    1005           0 :                 bool bUnMark = pDrViewSh->GetView()->IsObjMarked(pObj);
    1006           0 :                 pDrViewSh->GetView()->MarkObj(pObj, pDrViewSh->GetView()->GetSdrPageView(), bUnMark);
    1007           0 :             }
    1008             :         }
    1009             : 
    1010           0 :         SfxBindings& rBindings = ( ( mpViewShell && mpViewShell->GetViewFrame() ) ?
    1011           0 :                                  mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings();
    1012             : 
    1013           0 :         rBindings.Invalidate(SID_NAVIGATOR_STATE, true, false);
    1014           0 :         rBindings.Invalidate(SID_NAVIGATOR_PAGENAME);
    1015             :     }
    1016             : 
    1017           0 :     return (bFound);
    1018             : }
    1019             : 
    1020             : /**
    1021             :  * If it should become a document template.
    1022             :  */
    1023          13 : bool DrawDocShell::SaveAsOwnFormat( SfxMedium& rMedium )
    1024             : {
    1025             : 
    1026          13 :     const SfxFilter* pFilter = rMedium.GetFilter();
    1027             : 
    1028          13 :     if (pFilter->IsOwnTemplateFormat())
    1029             :     {
    1030             :         /* now the StarDraw specialty:
    1031             :            we assign known layout names to the layout template of the first
    1032             :            page, we set the layout names of the affected masterpages and pages.
    1033             :            We inform all text objects of the affected standard, note and
    1034             :            masterpages about the name change.
    1035             :         */
    1036             : 
    1037           0 :         OUString aLayoutName;
    1038             : 
    1039             :         SfxStringItem const * pLayoutItem;
    1040           0 :         if( rMedium.GetItemSet()->GetItemState(SID_TEMPLATE_NAME, false, reinterpret_cast<const SfxPoolItem**>(& pLayoutItem) ) == SfxItemState::SET )
    1041             :         {
    1042           0 :             aLayoutName = pLayoutItem->GetValue();
    1043             :         }
    1044             :         else
    1045             :         {
    1046           0 :             INetURLObject aURL( rMedium.GetName() );
    1047           0 :             aURL.removeExtension();
    1048           0 :             aLayoutName = aURL.getName();
    1049             :         }
    1050             : 
    1051           0 :         if (!aLayoutName.isEmpty())
    1052             :         {
    1053           0 :             sal_uInt32 nCount = mpDoc->GetMasterSdPageCount(PK_STANDARD);
    1054           0 :             for (sal_uInt32 i = 0; i < nCount; ++i)
    1055             :             {
    1056           0 :                 OUString aOldPageLayoutName = mpDoc->GetMasterSdPage(i, PK_STANDARD)->GetLayoutName();
    1057           0 :                 OUString aNewLayoutName = aLayoutName;
    1058             :                 // Don't add suffix for the first master page
    1059           0 :                 if( i > 0 )
    1060           0 :                     aNewLayoutName += OUString::number(i);
    1061             : 
    1062           0 :                 mpDoc->RenameLayoutTemplate(aOldPageLayoutName, aNewLayoutName);
    1063           0 :             }
    1064           0 :         }
    1065             :     }
    1066             : 
    1067          13 :     return SfxObjectShell::SaveAsOwnFormat(rMedium);
    1068             : }
    1069             : 
    1070         234 : void DrawDocShell::FillClass(SvGlobalName* pClassName,
    1071             :                                         SotClipboardFormatId* pFormat,
    1072             :                                         OUString* ,
    1073             :                                         OUString* pFullTypeName,
    1074             :                                         OUString* pShortTypeName,
    1075             :                                         sal_Int32 nFileFormat,
    1076             :                                         bool bTemplate /* = false */) const
    1077             : {
    1078         234 :     if (nFileFormat == SOFFICE_FILEFORMAT_60)
    1079             :     {
    1080           0 :         if ( meDocType == DOCUMENT_TYPE_DRAW )
    1081             :         {
    1082           0 :             *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
    1083           0 :             *pFormat = SotClipboardFormatId::STARDRAW_60;
    1084           0 :             *pFullTypeName = OUString(SdResId(STR_GRAPHIC_DOCUMENT_FULLTYPE_60));
    1085             :         }
    1086             :         else
    1087             :         {
    1088           0 :             *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60);
    1089           0 :             *pFormat = SotClipboardFormatId::STARIMPRESS_60;
    1090           0 :             *pFullTypeName = OUString(SdResId(STR_IMPRESS_DOCUMENT_FULLTYPE_60));
    1091             :         }
    1092             :     }
    1093         234 :     else if (nFileFormat == SOFFICE_FILEFORMAT_8)
    1094             :     {
    1095         234 :         if ( meDocType == DOCUMENT_TYPE_DRAW )
    1096             :         {
    1097         101 :             *pClassName = SvGlobalName(SO3_SDRAW_CLASSID_60);
    1098         101 :             *pFormat = bTemplate ? SotClipboardFormatId::STARDRAW_8_TEMPLATE : SotClipboardFormatId::STARDRAW_8;
    1099         101 :             *pFullTypeName = "Draw 8"; // HACK: method will be removed with new storage API
    1100             :         }
    1101             :         else
    1102             :         {
    1103         133 :             *pClassName = SvGlobalName(SO3_SIMPRESS_CLASSID_60);
    1104         133 :             *pFormat = bTemplate ? SotClipboardFormatId::STARIMPRESS_8_TEMPLATE : SotClipboardFormatId::STARIMPRESS_8;
    1105         133 :             *pFullTypeName = "Impress 8"; // HACK: method will be removed with new storage API
    1106             :         }
    1107             :     }
    1108             : 
    1109         468 :     *pShortTypeName = OUString(SdResId( (meDocType == DOCUMENT_TYPE_DRAW) ?
    1110         234 :                                       STR_GRAPHIC_DOCUMENT : STR_IMPRESS_DOCUMENT ));
    1111         234 : }
    1112             : 
    1113           0 : OutputDevice* DrawDocShell::GetDocumentRefDev()
    1114             : {
    1115           0 :     OutputDevice* pReferenceDevice = SfxObjectShell::GetDocumentRefDev ();
    1116             :     // Only when our parent does not have a reference device then we return
    1117             :     // our own.
    1118           0 :     if (pReferenceDevice == NULL && mpDoc != NULL)
    1119           0 :         pReferenceDevice = mpDoc->GetRefDevice ();
    1120           0 :     return pReferenceDevice;
    1121             : }
    1122             : 
    1123             : /** executes the SID_OPENDOC slot to let the framework open a document
    1124             :     with the given URL and this document as a referer */
    1125           0 : void DrawDocShell::OpenBookmark( const OUString& rBookmarkURL )
    1126             : {
    1127           0 :     SfxStringItem   aStrItem( SID_FILE_NAME, rBookmarkURL );
    1128           0 :     SfxStringItem   aReferer( SID_REFERER, GetMedium()->GetName() );
    1129           0 :     const SfxPoolItem* ppArgs[] = { &aStrItem, &aReferer, 0 };
    1130           0 :     ( mpViewShell ? mpViewShell->GetViewFrame() : SfxViewFrame::Current() )->GetBindings().Execute( SID_OPENHYPERLINK, ppArgs );
    1131           0 : }
    1132             : 
    1133           0 : VclPtr<SfxDocumentInfoDialog> DrawDocShell::CreateDocumentInfoDialog( vcl::Window *pParent, const SfxItemSet &rSet )
    1134             : {
    1135           0 :     VclPtr<SfxDocumentInfoDialog> pDlg   = VclPtr<SfxDocumentInfoDialog>::Create( pParent, rSet );
    1136           0 :     DrawDocShell*          pDocSh = PTR_CAST(DrawDocShell,SfxObjectShell::Current());
    1137             : 
    1138           0 :     if( pDocSh == this )
    1139             :     {
    1140           0 :         pDlg->AddFontTabPage();
    1141             :     }
    1142           0 :     return pDlg;
    1143             : }
    1144             : 
    1145           0 : void DrawDocShell::setEditMode(DrawViewShell* pDrawViewShell, bool isMasterPage)
    1146             : {
    1147             :     // Set the edit mode to either the normal edit mode or the
    1148             :     // master page mode.
    1149           0 :     EditMode eNewEditMode = EM_PAGE;
    1150           0 :     if (isMasterPage)
    1151             :     {
    1152           0 :         eNewEditMode = EM_MASTERPAGE;
    1153             :     }
    1154             : 
    1155           0 :     if (eNewEditMode != pDrawViewShell->GetEditMode())
    1156             :     {
    1157             :         // Set EditMode
    1158           0 :         pDrawViewShell->ChangeEditMode(eNewEditMode, false);
    1159             :     }
    1160           0 : }
    1161          66 : } // end of namespace sd
    1162             : 
    1163             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11