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

Generated by: LCOV version 1.10