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

Generated by: LCOV version 1.10