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

Generated by: LCOV version 1.10