LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/unoidl - unomodel.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 807 1466 55.0 %
Date: 2013-07-09 Functions: 74 117 63.2 %
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 <com/sun/star/presentation/XPresentation2.hpp>
      22             : 
      23             : #include <com/sun/star/lang/DisposedException.hpp>
      24             : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
      25             : #include <com/sun/star/lang/Locale.hpp>
      26             : #include <com/sun/star/style/XStyle.hpp>
      27             : #include <com/sun/star/awt/XDevice.hpp>
      28             : #include <com/sun/star/document/IndexedPropertyValues.hpp>
      29             : 
      30             : #include <com/sun/star/embed/Aspects.hpp>
      31             : 
      32             : #include <osl/mutex.hxx>
      33             : #include <comphelper/sequence.hxx>
      34             : #include <comphelper/servicehelper.hxx>
      35             : #include <comphelper/serviceinfohelper.hxx>
      36             : 
      37             : #include <editeng/unofield.hxx>
      38             : #include <unomodel.hxx>
      39             : #include <sfx2/dispatch.hxx>
      40             : #include <sfx2/bindings.hxx>
      41             : #include <vcl/svapp.hxx>
      42             : #include <editeng/UnoForbiddenCharsTable.hxx>
      43             : #include <svx/svdoutl.hxx>
      44             : #include <editeng/forbiddencharacterstable.hxx>
      45             : #include <svx/UnoNamespaceMap.hxx>
      46             : #include <svx/svdlayer.hxx>
      47             : #include <svx/svdsob.hxx>
      48             : #include <svx/unoapi.hxx>
      49             : #include <svx/unofill.hxx>
      50             : #include <svx/unopool.hxx>
      51             : #include <svx/svdorect.hxx>
      52             : #include <editeng/flditem.hxx>
      53             : #include <editeng/fontitem.hxx>
      54             : #include <toolkit/awt/vclxdevice.hxx>
      55             : #include <svx/svdpool.hxx>
      56             : #include <editeng/unolingu.hxx>
      57             : #include <svx/svdpagv.hxx>
      58             : #include <svtools/unoimap.hxx>
      59             : #include <svx/unoshape.hxx>
      60             : #include <editeng/unonrule.hxx>
      61             : #include <editeng/eeitem.hxx>
      62             : 
      63             : // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
      64             : #include <svx/xmleohlp.hxx>
      65             : #include <svx/xmlgrhlp.hxx>
      66             : #include "DrawDocShell.hxx"
      67             : #include "ViewShellBase.hxx"
      68             : #include <UnoDocumentSettings.hxx>
      69             : 
      70             : #include <drawdoc.hxx>
      71             : #include <glob.hrc>
      72             : #include <sdresid.hxx>
      73             : #include <sdpage.hxx>
      74             : 
      75             : #include <strings.hrc>
      76             : #include "unohelp.hxx"
      77             : #include <unolayer.hxx>
      78             : #include <unoprnms.hxx>
      79             : #include <unopage.hxx>
      80             : #include <unocpres.hxx>
      81             : #include <unoobj.hxx>
      82             : #include <stlpool.hxx>
      83             : #include <unopback.hxx>
      84             : #include <unokywds.hxx>
      85             : #include "FrameView.hxx"
      86             : #include "ClientView.hxx"
      87             : #include "ViewShell.hxx"
      88             : #include "app.hrc"
      89             : #include <vcl/pdfextoutdevdata.hxx>
      90             : #include <com/sun/star/presentation/AnimationEffect.hpp>
      91             : #include <com/sun/star/presentation/AnimationSpeed.hpp>
      92             : #include <com/sun/star/presentation/ClickAction.hpp>
      93             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      94             : #include <svx/sdr/contact/viewcontact.hxx>
      95             : #include <svx/sdr/contact/displayinfo.hxx>
      96             : 
      97             : #include <com/sun/star/office/XAnnotation.hpp>
      98             : #include <com/sun/star/office/XAnnotationAccess.hpp>
      99             : #include <com/sun/star/office/XAnnotationEnumeration.hpp>
     100             : #include <com/sun/star/geometry/RealPoint2D.hpp>
     101             : #include <com/sun/star/util/DateTime.hpp>
     102             : 
     103             : 
     104             : #include <drawinglayer/primitive2d/structuretagprimitive2d.hxx>
     105             : 
     106             : using namespace ::osl;
     107             : using namespace ::cppu;
     108             : using namespace ::com::sun::star;
     109             : 
     110             : extern uno::Reference< uno::XInterface > SdUnoCreatePool( SdDrawDocument* pDrawModel );
     111             : 
     112             : class SdUnoForbiddenCharsTable : public SvxUnoForbiddenCharsTable,
     113             :                                  public SfxListener
     114             : {
     115             : public:
     116             :     SdUnoForbiddenCharsTable( SdrModel* pModel );
     117             :     ~SdUnoForbiddenCharsTable();
     118             : 
     119             :     // SfxListener
     120             :     virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) throw ();
     121             : protected:
     122             :     virtual void onChange();
     123             : 
     124             : private:
     125             :     SdrModel*   mpModel;
     126             : };
     127             : 
     128          11 : SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel )
     129          11 : : SvxUnoForbiddenCharsTable( pModel->GetForbiddenCharsTable() ), mpModel( pModel )
     130             : {
     131          11 :     StartListening( *pModel );
     132          11 : }
     133             : 
     134           6 : void SdUnoForbiddenCharsTable::onChange()
     135             : {
     136           6 :     if( mpModel )
     137             :     {
     138           6 :         mpModel->ReformatAllTextObjects();
     139             :     }
     140           6 : }
     141             : 
     142          33 : SdUnoForbiddenCharsTable::~SdUnoForbiddenCharsTable()
     143             : {
     144          11 :     if( mpModel )
     145          11 :         EndListening( *mpModel );
     146          22 : }
     147             : 
     148           0 : void SdUnoForbiddenCharsTable::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
     149             : {
     150           0 :     const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
     151             : 
     152           0 :     if( pSdrHint )
     153             :     {
     154           0 :         if( HINT_MODELCLEARED == pSdrHint->GetKind() )
     155             :         {
     156           0 :             mpModel = NULL;
     157             :         }
     158             :     }
     159           0 : }
     160             : 
     161             : ///////////////////////////////////////////////////////////////////////
     162             : 
     163             : const sal_Int32 WID_MODEL_LANGUAGE = 1;
     164             : const sal_Int32 WID_MODEL_TABSTOP  = 2;
     165             : const sal_Int32 WID_MODEL_VISAREA  = 3;
     166             : const sal_Int32 WID_MODEL_MAPUNIT  = 4;
     167             : const sal_Int32 WID_MODEL_FORBCHARS= 5;
     168             : const sal_Int32 WID_MODEL_CONTFOCUS = 6;
     169             : const sal_Int32 WID_MODEL_DSGNMODE  = 7;
     170             : const sal_Int32 WID_MODEL_BASICLIBS = 8;
     171             : const sal_Int32 WID_MODEL_RUNTIMEUID = 9;
     172             : const sal_Int32 WID_MODEL_BUILDID = 10;
     173             : const sal_Int32 WID_MODEL_HASVALIDSIGNATURES = 11;
     174             : const sal_Int32 WID_MODEL_DIALOGLIBS = 12;
     175             : const sal_Int32 WID_MODEL_FONTS = 13;
     176             : 
     177             : #ifndef SEQTYPE
     178             :  #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
     179             :   #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
     180             :  #else
     181             :   #define SEQTYPE(x) &(x)
     182             :  #endif
     183             : #endif
     184             : 
     185          89 : const SvxItemPropertySet* ImplGetDrawModelPropertySet()
     186             : {
     187             :     // Attention: the first parameter HAS TO BE sorted!!!
     188             :     const static SfxItemPropertyMapEntry aDrawModelPropertyMap_Impl[] =
     189             :     {
     190          10 :         { MAP_CHAR_LEN("BuildId"),                      WID_MODEL_BUILDID,  &::getCppuType(static_cast< const OUString * >(0)), 0, 0},
     191          10 :         { MAP_CHAR_LEN(sUNO_Prop_CharLocale),           WID_MODEL_LANGUAGE, &::getCppuType((const lang::Locale*)0),     0,  0},
     192          10 :         { MAP_CHAR_LEN(sUNO_Prop_TabStop),              WID_MODEL_TABSTOP,  &::getCppuType((const sal_Int32*)0),        0,  0},
     193          10 :         { MAP_CHAR_LEN(sUNO_Prop_VisibleArea),          WID_MODEL_VISAREA,  &::getCppuType((const awt::Rectangle*)0),   0,  0},
     194          10 :         { MAP_CHAR_LEN(sUNO_Prop_MapUnit),              WID_MODEL_MAPUNIT,  &::getCppuType((const sal_Int16*)0),        beans::PropertyAttribute::READONLY, 0},
     195          10 :         { MAP_CHAR_LEN(sUNO_Prop_ForbiddenCharacters),  WID_MODEL_FORBCHARS,&::getCppuType((const uno::Reference< i18n::XForbiddenCharacters > *)0), beans::PropertyAttribute::READONLY, 0 },
     196          10 :         { MAP_CHAR_LEN(sUNO_Prop_AutomContFocus ),  WID_MODEL_CONTFOCUS,    &::getBooleanCppuType(),                    0,  0},
     197          10 :         { MAP_CHAR_LEN(sUNO_Prop_ApplyFrmDsgnMode), WID_MODEL_DSGNMODE,     &::getBooleanCppuType(),                    0,  0},
     198          10 :         { MAP_CHAR_LEN("BasicLibraries"),               WID_MODEL_BASICLIBS,&::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 },
     199          10 :         { MAP_CHAR_LEN("DialogLibraries"),              WID_MODEL_DIALOGLIBS,   &::getCppuType((const uno::Reference< script::XLibraryContainer > *)0), beans::PropertyAttribute::READONLY, 0 },
     200          10 :         { MAP_CHAR_LEN(sUNO_Prop_RuntimeUID),           WID_MODEL_RUNTIMEUID,   &::getCppuType(static_cast< const OUString * >(0)), beans::PropertyAttribute::READONLY, 0 },
     201          10 :         { MAP_CHAR_LEN(sUNO_Prop_HasValidSignatures),   WID_MODEL_HASVALIDSIGNATURES, &::getCppuType(static_cast< const sal_Bool * >(0)), beans::PropertyAttribute::READONLY, 0 },
     202          10 :         { MAP_CHAR_LEN("Fonts"),                        WID_MODEL_FONTS,   SEQTYPE(::getCppuType((uno::Sequence<uno::Any>*)0)), beans::PropertyAttribute::READONLY, 0},
     203             :         { 0,0,0,0,0,0 }
     204         219 :     };
     205          89 :     static SvxItemPropertySet aDrawModelPropertySet_Impl( aDrawModelPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() );
     206          89 :     return &aDrawModelPropertySet_Impl;
     207             : }
     208             : 
     209             : // this ctor is used from the DocShell
     210          89 : SdXImpressDocument::SdXImpressDocument (::sd::DrawDocShell* pShell, bool bClipBoard ) throw()
     211             : :   SfxBaseModel( pShell ),
     212             :     mpDocShell( pShell ),
     213             :     mpDoc( pShell ? pShell->GetDoc() : NULL ),
     214             :     mbDisposed(false),
     215          89 :     mbImpressDoc( pShell && pShell->GetDoc() && pShell->GetDoc()->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ),
     216             :     mbClipBoard( bClipBoard ),
     217         178 :     mpPropSet( ImplGetDrawModelPropertySet() )
     218             : {
     219          89 :     if( mpDoc )
     220             :     {
     221          89 :         StartListening( *mpDoc );
     222             :     }
     223             :     else
     224             :     {
     225             :         OSL_FAIL("DocShell is invalid");
     226             :     }
     227          89 : }
     228             : 
     229           0 : SdXImpressDocument::SdXImpressDocument( SdDrawDocument* pDoc, bool bClipBoard ) throw()
     230             : :   SfxBaseModel( NULL ),
     231             :     mpDocShell( NULL ),
     232             :     mpDoc( pDoc ),
     233             :     mbDisposed(false),
     234           0 :     mbImpressDoc( pDoc && pDoc->GetDocumentType() == DOCUMENT_TYPE_IMPRESS ),
     235             :     mbClipBoard( bClipBoard ),
     236           0 :     mpPropSet( ImplGetDrawModelPropertySet() )
     237             : {
     238           0 :     if( mpDoc )
     239             :     {
     240           0 :         StartListening( *mpDoc );
     241             :     }
     242             :     else
     243             :     {
     244             :         OSL_FAIL("SdDrawDocument is invalid");
     245             :     }
     246           0 : }
     247             : 
     248             : /***********************************************************************
     249             : *                                                                      *
     250             : ***********************************************************************/
     251         160 : SdXImpressDocument::~SdXImpressDocument() throw()
     252             : {
     253         160 : }
     254             : 
     255             : // XInterface
     256       40851 : uno::Any SAL_CALL SdXImpressDocument::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
     257             : {
     258       40851 :     uno::Any aAny;
     259             : 
     260       40851 :     QUERYINT(lang::XServiceInfo);
     261       40585 :     else QUERYINT(beans::XPropertySet);
     262       40282 :     else QUERYINT(lang::XMultiServiceFactory);
     263       39579 :     else QUERYINT(drawing::XDrawPageDuplicator);
     264       39579 :     else QUERYINT(drawing::XLayerSupplier);
     265       39564 :     else QUERYINT(drawing::XMasterPagesSupplier);
     266       39488 :     else QUERYINT(drawing::XDrawPagesSupplier);
     267       39296 :     else QUERYINT(presentation::XHandoutMasterSupplier);
     268       39272 :     else QUERYINT(document::XLinkTargetSupplier);
     269       39271 :     else QUERYINT(style::XStyleFamiliesSupplier);
     270       39025 :     else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
     271       38876 :     else QUERYINT(view::XRenderable);
     272       38876 :     else if( mbImpressDoc && rType == ITYPE(presentation::XPresentationSupplier) )
     273           7 :             aAny <<= uno::Reference< presentation::XPresentationSupplier >(this);
     274       38869 :     else if( mbImpressDoc && rType == ITYPE(presentation::XCustomPresentationSupplier) )
     275           8 :             aAny <<= uno::Reference< presentation::XCustomPresentationSupplier >(this);
     276             :     else
     277       38861 :         return SfxBaseModel::queryInterface( rType );
     278             : 
     279        1990 :     return aAny;
     280             : }
     281             : 
     282      102115 : void SAL_CALL SdXImpressDocument::acquire() throw ( )
     283             : {
     284      102115 :     SfxBaseModel::acquire();
     285      102115 : }
     286             : 
     287      102090 : void SAL_CALL SdXImpressDocument::release() throw ( )
     288             : {
     289      102090 :     if (osl_atomic_decrement( &m_refCount ) == 0)
     290             :     {
     291             :         // restore reference count:
     292          80 :         osl_atomic_increment( &m_refCount );
     293          80 :         if(!mbDisposed)
     294             :         {
     295             :             try
     296             :             {
     297           0 :                 dispose();
     298             :             }
     299           0 :             catch (const uno::RuntimeException& exc)
     300             :             { // don't break throw ()
     301             :                 OSL_FAIL(
     302             :                     OUStringToOString(
     303             :                         exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
     304             :                 static_cast<void>(exc);
     305             :             }
     306             :         }
     307          80 :         SfxBaseModel::release();
     308             :     }
     309      102090 : }
     310             : 
     311             : namespace
     312             : {
     313             :     class theSdXImpressDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdXImpressDocumentUnoTunnelId> {};
     314             : }
     315             : 
     316             : // XUnoTunnel
     317        6128 : const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw()
     318             : {
     319        6128 :     return theSdXImpressDocumentUnoTunnelId::get().getSeq();
     320             : }
     321             : 
     322         331 : SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt )
     323             : {
     324         331 :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUT( xInt, ::com::sun::star::uno::UNO_QUERY );
     325         331 :     if( xUT.is() )
     326         331 :         return reinterpret_cast<SdXImpressDocument*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething( SdXImpressDocument::getUnoTunnelId() )));
     327             :     else
     328           0 :         return NULL;
     329             : }
     330             : 
     331        5797 : sal_Int64 SAL_CALL SdXImpressDocument::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rIdentifier ) throw(::com::sun::star::uno::RuntimeException)
     332             : {
     333        5797 :     if( rIdentifier.getLength() == 16 )
     334             :     {
     335        5797 :         if( (0 == memcmp( SdXImpressDocument::getUnoTunnelId().getConstArray(), rIdentifier.getConstArray(), 16 )) )
     336         331 :             return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
     337             : 
     338        5466 :         if( (0 == memcmp( SdrModel::getUnoTunnelImplementationId().getConstArray(), rIdentifier.getConstArray(), 16 )) )
     339           0 :             return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(mpDoc));
     340             :     }
     341             : 
     342        5466 :     return SfxBaseModel::getSomething( rIdentifier );
     343             : }
     344             : 
     345             : // XTypeProvider
     346          73 : uno::Sequence< uno::Type > SAL_CALL SdXImpressDocument::getTypes(  ) throw(uno::RuntimeException)
     347             : {
     348          73 :     ::SolarMutexGuard aGuard;
     349             : 
     350          73 :     if( maTypeSequence.getLength() == 0 )
     351             :     {
     352          65 :         const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
     353          65 :         const sal_Int32 nBaseTypes = aBaseTypes.getLength();
     354          65 :         const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
     355             : 
     356          65 :         const sal_Int32 nOwnTypes = mbImpressDoc ? 14 : 11;     // !DANGER! Keep this updated!
     357             : 
     358          65 :         maTypeSequence.realloc(  nBaseTypes + nOwnTypes );
     359          65 :         uno::Type* pTypes = maTypeSequence.getArray();
     360             : 
     361          65 :         *pTypes++ = ITYPE(beans::XPropertySet);
     362          65 :         *pTypes++ = ITYPE(lang::XServiceInfo);
     363          65 :         *pTypes++ = ITYPE(lang::XMultiServiceFactory);
     364          65 :         *pTypes++ = ITYPE(drawing::XDrawPageDuplicator);
     365          65 :         *pTypes++ = ITYPE(drawing::XLayerSupplier);
     366          65 :         *pTypes++ = ITYPE(drawing::XMasterPagesSupplier);
     367          65 :         *pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
     368          65 :         *pTypes++ = ITYPE(document::XLinkTargetSupplier);
     369          65 :         *pTypes++ = ITYPE(style::XStyleFamiliesSupplier);
     370          65 :         *pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
     371          65 :         *pTypes++ = ITYPE(view::XRenderable);
     372          65 :         if( mbImpressDoc )
     373             :         {
     374          13 :             *pTypes++ = ITYPE(presentation::XPresentationSupplier);
     375          13 :             *pTypes++ = ITYPE(presentation::XCustomPresentationSupplier);
     376          13 :             *pTypes++ = ITYPE(presentation::XHandoutMasterSupplier);
     377             :         }
     378             : 
     379        2275 :         for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
     380        2275 :             *pTypes++ = *pBaseTypes++;
     381             :     }
     382             : 
     383          73 :     return maTypeSequence;
     384             : }
     385             : 
     386             : namespace
     387             : {
     388             :     class theSdXImpressDocumentImplementationId : public rtl::Static< UnoTunnelIdInit, theSdXImpressDocumentImplementationId > {};
     389             : }
     390             : 
     391          73 : uno::Sequence< sal_Int8 > SAL_CALL SdXImpressDocument::getImplementationId(  ) throw(uno::RuntimeException)
     392             : {
     393          73 :     return theSdXImpressDocumentImplementationId::get().getSeq();
     394             : }
     395             : 
     396             : /***********************************************************************
     397             : *                                                                      *
     398             : ***********************************************************************/
     399       10759 : void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     400             : {
     401       10759 :     if( mpDoc )
     402             :     {
     403       10663 :         const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint );
     404             : 
     405       10663 :         if( pSdrHint )
     406             :         {
     407        4363 :             if( hasEventListeners() )
     408             :             {
     409        1695 :                 document::EventObject aEvent;
     410        1695 :                 if( SvxUnoDrawMSFactory::createEvent( mpDoc, pSdrHint, aEvent ) )
     411        1693 :                     notifyEvent( aEvent );
     412             :             }
     413             : 
     414        4363 :             if( pSdrHint->GetKind() == HINT_MODELCLEARED )
     415             :             {
     416           0 :                 if( mpDoc )
     417           0 :                     EndListening( *mpDoc );
     418           0 :                 mpDoc = NULL;
     419           0 :                 mpDocShell = NULL;
     420             :             }
     421             :         }
     422             :         else
     423             :         {
     424        6300 :             const SfxSimpleHint* pSfxHint = PTR_CAST(SfxSimpleHint, &rHint );
     425             : 
     426             :             // did our SdDrawDocument just died?
     427        6300 :             if(pSfxHint && pSfxHint->GetId() == SFX_HINT_DYING)
     428             :             {
     429             :                 // yes, so we ask for a new one
     430           0 :                 if( mpDocShell )
     431             :                 {
     432           0 :                     SdDrawDocument *pNewDoc = mpDocShell->GetDoc();
     433             : 
     434             :                     // is there a new one?
     435           0 :                     if( pNewDoc != mpDoc )
     436             :                     {
     437           0 :                         mpDoc = pNewDoc;
     438           0 :                         if(mpDoc)
     439           0 :                             StartListening( *mpDoc );
     440             :                     }
     441             :                 }
     442             :             }
     443             :         }
     444             :     }
     445       10759 :     SfxBaseModel::Notify( rBC, rHint );
     446       10759 : }
     447             : 
     448             : /******************************************************************************
     449             : *                                                                             *
     450             : ******************************************************************************/
     451          18 : SdPage* SdXImpressDocument::InsertSdPage( sal_uInt16 nPage, sal_Bool bDuplicate ) throw()
     452             : {
     453          18 :     sal_uInt16 nPageCount = mpDoc->GetSdPageCount( PK_STANDARD );
     454          18 :     SdrLayerAdmin& rLayerAdmin = mpDoc->GetLayerAdmin();
     455          18 :     sal_uInt8 aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
     456          18 :     sal_uInt8 aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
     457             : 
     458          18 :     SdPage* pStandardPage = NULL;
     459             : 
     460          18 :     if( 0 == nPageCount )
     461             :     {
     462             :         // this is only used for clipboard where we only have one page
     463           0 :         pStandardPage = (SdPage*) mpDoc->AllocPage(sal_False);
     464             : 
     465           0 :         Size aDefSize(21000, 29700);   // A4-Hochformat
     466           0 :         pStandardPage->SetSize( aDefSize );
     467           0 :         mpDoc->InsertPage(pStandardPage, 0);
     468             :     }
     469             :     else
     470             :     {
     471             :         // here we determine the page after which we should insert
     472          18 :         SdPage* pPreviousStandardPage = mpDoc->GetSdPage( std::min( (sal_uInt16)(nPageCount - 1), nPage ), PK_STANDARD );
     473          18 :         SetOfByte aVisibleLayers = pPreviousStandardPage->TRG_GetMasterPageVisibleLayers();
     474          18 :         sal_Bool bIsPageBack = aVisibleLayers.IsSet( aBckgrnd );
     475          18 :         sal_Bool bIsPageObj = aVisibleLayers.IsSet( aBckgrndObj );
     476             : 
     477             :         // AutoLayouts must be ready
     478          18 :         mpDoc->StopWorkStartupDelay();
     479             : 
     480             :         /* First we create a standard page and then a notes page. It is
     481             :            guaranteed, that after a standard page the corresponding notes page
     482             :            follows. */
     483             : 
     484          18 :         sal_uInt16 nStandardPageNum = pPreviousStandardPage->GetPageNum() + 2;
     485          18 :         SdPage* pPreviousNotesPage = (SdPage*) mpDoc->GetPage( nStandardPageNum - 1 );
     486          18 :         sal_uInt16 nNotesPageNum = nStandardPageNum + 1;
     487          18 :         String aStandardPageName;
     488          36 :         String aNotesPageName;
     489             : 
     490             :         /**************************************************************
     491             :         * standard page
     492             :         **************************************************************/
     493          18 :         if( bDuplicate )
     494           0 :             pStandardPage = (SdPage*) pPreviousStandardPage->Clone();
     495             :         else
     496          18 :             pStandardPage = (SdPage*) mpDoc->AllocPage(sal_False);
     497             : 
     498          18 :         pStandardPage->SetSize( pPreviousStandardPage->GetSize() );
     499          18 :         pStandardPage->SetBorder( pPreviousStandardPage->GetLftBorder(),
     500          18 :                                     pPreviousStandardPage->GetUppBorder(),
     501          18 :                                     pPreviousStandardPage->GetRgtBorder(),
     502          72 :                                     pPreviousStandardPage->GetLwrBorder() );
     503          18 :         pStandardPage->SetOrientation( pPreviousStandardPage->GetOrientation() );
     504          18 :         pStandardPage->SetName(aStandardPageName);
     505             : 
     506             :         // insert page after current page
     507          18 :         mpDoc->InsertPage(pStandardPage, nStandardPageNum);
     508             : 
     509          18 :         if( !bDuplicate )
     510             :         {
     511             :             // use MasterPage of the current page
     512          18 :             pStandardPage->TRG_SetMasterPage(pPreviousStandardPage->TRG_GetMasterPage());
     513          18 :             pStandardPage->SetLayoutName( pPreviousStandardPage->GetLayoutName() );
     514          18 :             pStandardPage->SetAutoLayout(AUTOLAYOUT_NONE, sal_True );
     515             :         }
     516             : 
     517          18 :         aBckgrnd = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRND)), sal_False);
     518          18 :         aBckgrndObj = rLayerAdmin.GetLayerID(String(SdResId(STR_LAYER_BCKGRNDOBJ)), sal_False);
     519          18 :         aVisibleLayers.Set(aBckgrnd, bIsPageBack);
     520          18 :         aVisibleLayers.Set(aBckgrndObj, bIsPageObj);
     521          18 :         pStandardPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
     522             : 
     523             :         /**************************************************************
     524             :         * notes page
     525             :         **************************************************************/
     526          18 :         SdPage* pNotesPage = NULL;
     527             : 
     528          18 :         if( bDuplicate )
     529           0 :             pNotesPage = (SdPage*) pPreviousNotesPage->Clone();
     530             :         else
     531          18 :             pNotesPage = (SdPage*) mpDoc->AllocPage(sal_False);
     532             : 
     533          18 :         pNotesPage->SetSize( pPreviousNotesPage->GetSize() );
     534          18 :         pNotesPage->SetBorder( pPreviousNotesPage->GetLftBorder(),
     535          18 :                                 pPreviousNotesPage->GetUppBorder(),
     536          18 :                                 pPreviousNotesPage->GetRgtBorder(),
     537          72 :                                 pPreviousNotesPage->GetLwrBorder() );
     538          18 :         pNotesPage->SetOrientation( pPreviousNotesPage->GetOrientation() );
     539          18 :         pNotesPage->SetName(aNotesPageName);
     540          18 :         pNotesPage->SetPageKind(PK_NOTES);
     541             : 
     542             :         // insert page after current page
     543          18 :         mpDoc->InsertPage(pNotesPage, nNotesPageNum);
     544             : 
     545          18 :         if( !bDuplicate )
     546             :         {
     547             :             // use MasterPage of the current page
     548          18 :             pNotesPage->TRG_SetMasterPage(pPreviousNotesPage->TRG_GetMasterPage());
     549          18 :             pNotesPage->SetLayoutName( pPreviousNotesPage->GetLayoutName() );
     550          18 :             pNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True );
     551          18 :         }
     552             :     }
     553             : 
     554          18 :     SetModified();
     555             : 
     556          18 :     return( pStandardPage );
     557             : }
     558             : 
     559        4156 : void SdXImpressDocument::SetModified( sal_Bool bModified /* = sal_True */ ) throw()
     560             : {
     561        4156 :     if( mpDoc )
     562        4156 :         mpDoc->SetChanged( bModified );
     563        4156 : }
     564             : 
     565             : // XModel
     566          18 : void SAL_CALL SdXImpressDocument    ::lockControllers(  )
     567             :     throw(uno::RuntimeException)
     568             : {
     569          18 :     ::SolarMutexGuard aGuard;
     570             : 
     571          18 :     if( NULL == mpDoc )
     572           0 :         throw lang::DisposedException();
     573             : 
     574          18 :     mpDoc->setLock(true);
     575          18 : }
     576             : 
     577          18 : void SAL_CALL SdXImpressDocument::unlockControllers(  )
     578             :     throw(uno::RuntimeException)
     579             : {
     580          18 :     ::SolarMutexGuard aGuard;
     581             : 
     582          18 :     if( NULL == mpDoc )
     583           0 :         throw lang::DisposedException();
     584             : 
     585          18 :     if( mpDoc->isLocked() )
     586             :     {
     587          18 :         mpDoc->setLock(false);
     588          18 :     }
     589          18 : }
     590             : 
     591          75 : sal_Bool SAL_CALL SdXImpressDocument::hasControllersLocked(  )
     592             :     throw(uno::RuntimeException)
     593             : {
     594          75 :     ::SolarMutexGuard aGuard;
     595             : 
     596          75 :     if( NULL == mpDoc )
     597           0 :         throw lang::DisposedException();
     598             : 
     599          75 :     return mpDoc && mpDoc->isLocked();
     600             : }
     601             : 
     602             : #include <comphelper/processfactory.hxx>
     603             : 
     604         149 : uno::Reference < container::XIndexAccess > SAL_CALL SdXImpressDocument::getViewData() throw( uno::RuntimeException )
     605             : {
     606         149 :     ::SolarMutexGuard aGuard;
     607             : 
     608         149 :     if( NULL == mpDoc )
     609           0 :         throw lang::DisposedException();
     610             : 
     611         149 :     uno::Reference < container::XIndexAccess > xRet( SfxBaseModel::getViewData() );
     612             : 
     613         149 :     if( !xRet.is() )
     614             :     {
     615          72 :         const std::vector<sd::FrameView*> &rList = mpDoc->GetFrameViewList();
     616             : 
     617          72 :         if( !rList.empty() )
     618             :         {
     619           0 :             xRet = uno::Reference< container::XIndexAccess >(document::IndexedPropertyValues::create( ::comphelper::getProcessComponentContext() ), uno::UNO_QUERY);
     620             : 
     621             : 
     622           0 :             uno::Reference < container::XIndexContainer > xCont( xRet, uno::UNO_QUERY );
     623             :             DBG_ASSERT( xCont.is(), "SdXImpressDocument::getViewData() failed for OLE object" );
     624           0 :             if( xCont.is() )
     625             :             {
     626           0 :                 for( sal_uInt32 i = 0, n = rList.size(); i < n; i++ )
     627             :                 {
     628           0 :                     ::sd::FrameView* pFrameView = rList[ i ];
     629             : 
     630           0 :                     uno::Sequence< beans::PropertyValue > aSeq;
     631           0 :                     pFrameView->WriteUserDataSequence( aSeq );
     632           0 :                     xCont->insertByIndex( i, uno::makeAny( aSeq ) );
     633           0 :                 }
     634           0 :             }
     635             :         }
     636             :     }
     637             : 
     638         149 :     return xRet;
     639             : }
     640             : 
     641          13 : void SAL_CALL SdXImpressDocument::setViewData( const uno::Reference < container::XIndexAccess >& xData ) throw(::com::sun::star::uno::RuntimeException)
     642             : {
     643          13 :     ::SolarMutexGuard aGuard;
     644             : 
     645          13 :     if( NULL == mpDoc )
     646           0 :         throw lang::DisposedException();
     647             : 
     648          13 :     SfxBaseModel::setViewData( xData );
     649          13 :     if( mpDocShell && (mpDocShell->GetCreateMode() == SFX_CREATE_MODE_EMBEDDED) && xData.is() )
     650             :     {
     651           3 :         const sal_Int32 nCount = xData->getCount();
     652             : 
     653           3 :         std::vector<sd::FrameView*>::iterator pIter;
     654           3 :         std::vector<sd::FrameView*> &rViews = mpDoc->GetFrameViewList();
     655             : 
     656           3 :         for ( pIter = rViews.begin(); pIter != rViews.end(); ++pIter )
     657           0 :             delete *pIter;
     658             : 
     659           3 :         rViews.clear();
     660             : 
     661             :         ::sd::FrameView* pFrameView;
     662           3 :         uno::Sequence< beans::PropertyValue > aSeq;
     663           6 :         for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
     664             :         {
     665           3 :             if( xData->getByIndex( nIndex ) >>= aSeq )
     666             :             {
     667           3 :                 pFrameView = new ::sd::FrameView( mpDoc );
     668             : 
     669           3 :                 pFrameView->ReadUserDataSequence( aSeq );
     670           3 :                 rViews.push_back( pFrameView );
     671             :             }
     672           3 :         }
     673          13 :     }
     674          13 : }
     675             : 
     676             : // XDrawPageDuplicator
     677           0 : uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::duplicate( const uno::Reference< drawing::XDrawPage >& xPage )
     678             :     throw(uno::RuntimeException)
     679             : {
     680           0 :     ::SolarMutexGuard aGuard;
     681             : 
     682           0 :     if( NULL == mpDoc )
     683           0 :         throw lang::DisposedException();
     684             : 
     685             :     // get pPage from xPage and determine the Id (nPos ) afterwards
     686           0 :     SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
     687           0 :     if( pSvxPage )
     688             :     {
     689           0 :         SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
     690           0 :         sal_uInt16 nPos = pPage->GetPageNum();
     691           0 :         nPos = ( nPos - 1 ) / 2;
     692           0 :         pPage = InsertSdPage( nPos, sal_True );
     693           0 :         if( pPage )
     694             :         {
     695           0 :             uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
     696           0 :             return xDrawPage;
     697             :         }
     698             :     }
     699             : 
     700           0 :     uno::Reference< drawing::XDrawPage > xDrawPage;
     701           0 :     return xDrawPage;
     702             : }
     703             : 
     704             : 
     705             : // XDrawPagesSupplier
     706         225 : uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getDrawPages()
     707             :     throw(uno::RuntimeException)
     708             : {
     709         225 :     ::SolarMutexGuard aGuard;
     710             : 
     711         225 :     if( NULL == mpDoc )
     712           0 :         throw lang::DisposedException();
     713             : 
     714         225 :     uno::Reference< drawing::XDrawPages >  xDrawPages( mxDrawPagesAccess );
     715             : 
     716         225 :     if( !xDrawPages.is() )
     717             :     {
     718         110 :         initializeDocument();
     719         110 :         mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SdDrawPagesAccess(*this);
     720             :     }
     721             : 
     722         225 :     return xDrawPages;
     723             : }
     724             : 
     725             : // XMasterPagesSupplier
     726          96 : uno::Reference< drawing::XDrawPages > SAL_CALL SdXImpressDocument::getMasterPages()
     727             :     throw(uno::RuntimeException)
     728             : {
     729          96 :     ::SolarMutexGuard aGuard;
     730             : 
     731          96 :     if( NULL == mpDoc )
     732           0 :         throw lang::DisposedException();
     733             : 
     734          96 :     uno::Reference< drawing::XDrawPages >  xMasterPages( mxMasterPagesAccess );
     735             : 
     736          96 :     if( !xMasterPages.is() )
     737             :     {
     738          71 :         if ( !hasControllersLocked() )
     739          19 :             initializeDocument();
     740          71 :         mxMasterPagesAccess = xMasterPages = new SdMasterPagesAccess(*this);
     741             :     }
     742             : 
     743          96 :     return xMasterPages;
     744             : }
     745             : 
     746             : // XLayerManagerSupplier
     747          15 : uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLayerManager(  )
     748             :     throw(uno::RuntimeException)
     749             : {
     750          15 :     ::SolarMutexGuard aGuard;
     751             : 
     752          15 :     if( NULL == mpDoc )
     753           0 :         throw lang::DisposedException();
     754             : 
     755          15 :     uno::Reference< container::XNameAccess >  xLayerManager( mxLayerManager );
     756             : 
     757          15 :     if( !xLayerManager.is() )
     758          15 :         mxLayerManager = xLayerManager = new SdLayerManager(*this);
     759             : 
     760          15 :     return xLayerManager;
     761             : }
     762             : 
     763             : // XCustomPresentationSupplier
     764           8 : uno::Reference< container::XNameContainer > SAL_CALL SdXImpressDocument::getCustomPresentations()
     765             :     throw(uno::RuntimeException)
     766             : {
     767           8 :     ::SolarMutexGuard aGuard;
     768             : 
     769           8 :     if( NULL == mpDoc )
     770           0 :         throw lang::DisposedException();
     771             : 
     772           8 :     uno::Reference< container::XNameContainer >  xCustomPres( mxCustomPresentationAccess );
     773             : 
     774           8 :     if( !xCustomPres.is() )
     775           8 :         mxCustomPresentationAccess = xCustomPres = new SdXCustomPresentationAccess(*this);
     776             : 
     777           8 :     return xCustomPres;
     778             : }
     779             : 
     780             : extern uno::Reference< presentation::XPresentation > createPresentation( SdXImpressDocument& rModel );
     781             : 
     782             : // XPresentationSupplier
     783           7 : uno::Reference< presentation::XPresentation > SAL_CALL SdXImpressDocument::getPresentation()
     784             :     throw(uno::RuntimeException)
     785             : {
     786           7 :     ::SolarMutexGuard aGuard;
     787             : 
     788           7 :     if( NULL == mpDoc )
     789           0 :         throw lang::DisposedException();
     790             : 
     791           7 :     return uno::Reference< presentation::XPresentation >( mpDoc->getPresentation().get() );
     792             : }
     793             : 
     794             : // XHandoutMasterSupplier
     795          24 : uno::Reference< drawing::XDrawPage > SAL_CALL SdXImpressDocument::getHandoutMasterPage()
     796             :     throw (uno::RuntimeException)
     797             : {
     798          24 :     ::SolarMutexGuard aGuard;
     799             : 
     800          24 :     if( NULL == mpDoc )
     801           0 :         throw lang::DisposedException();
     802             : 
     803          24 :     uno::Reference< drawing::XDrawPage > xPage;
     804             : 
     805          24 :     if( mpDoc )
     806             :     {
     807          24 :         initializeDocument();
     808          24 :         SdPage* pPage = mpDoc->GetMasterSdPage( 0, PK_HANDOUT );
     809          24 :         if( pPage )
     810          24 :             xPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
     811             :     }
     812          24 :     return xPage;
     813             : }
     814             : 
     815             : // XMultiServiceFactory ( SvxFmMSFactory )
     816         645 : uno::Reference< uno::XInterface > SAL_CALL SdXImpressDocument::createInstance( const OUString& aServiceSpecifier )
     817             :     throw(uno::Exception, uno::RuntimeException)
     818             : {
     819         645 :     ::SolarMutexGuard aGuard;
     820             : 
     821         645 :     if( NULL == mpDoc )
     822           0 :         throw lang::DisposedException();
     823             : 
     824         645 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.DashTable" ) )
     825             :     {
     826          14 :         if( !mxDashTable.is() )
     827          10 :             mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
     828             : 
     829          14 :         return mxDashTable;
     830             :     }
     831         631 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.GradientTable" ) )
     832             :     {
     833          14 :         if( !mxGradientTable.is() )
     834          10 :             mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
     835             : 
     836          14 :         return mxGradientTable;
     837             :     }
     838         617 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.HatchTable" ) )
     839             :     {
     840          14 :         if( !mxHatchTable.is() )
     841          10 :             mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
     842             : 
     843          14 :         return mxHatchTable;
     844             :     }
     845         603 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.BitmapTable" ) )
     846             :     {
     847          13 :         if( !mxBitmapTable.is() )
     848          10 :             mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
     849             : 
     850          13 :         return mxBitmapTable;
     851             :     }
     852         590 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.TransparencyGradientTable" ) )
     853             :     {
     854          14 :         if( !mxTransGradientTable.is() )
     855          11 :             mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
     856             : 
     857          14 :         return mxTransGradientTable;
     858             :     }
     859         576 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.MarkerTable" ) )
     860             :     {
     861          21 :         if( !mxMarkerTable.is() )
     862          11 :             mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
     863             : 
     864          21 :         return mxMarkerTable;
     865             :     }
     866         555 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.text.NumberingRules" ) )
     867             :     {
     868          22 :         return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
     869             :     }
     870         533 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.Background" ) )
     871             :     {
     872             :         return uno::Reference< uno::XInterface >(
     873          21 :             static_cast<uno::XWeak*>(new SdUnoPageBackground( mpDoc )));
     874             :     }
     875             : 
     876         512 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.Defaults" ) )
     877             :     {
     878          13 :         if( !mxDrawingPool.is() )
     879          10 :             mxDrawingPool = SdUnoCreatePool( mpDoc );
     880             : 
     881          13 :         return mxDrawingPool;
     882             : 
     883             :     }
     884             : 
     885         499 :     if ( aServiceSpecifier == sUNO_Service_ImageMapRectangleObject )
     886             :     {
     887           0 :         return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
     888             :     }
     889             : 
     890         499 :     if ( aServiceSpecifier == sUNO_Service_ImageMapCircleObject )
     891             :     {
     892           0 :         return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
     893             :     }
     894             : 
     895         499 :     if ( aServiceSpecifier == sUNO_Service_ImageMapPolygonObject )
     896             :     {
     897           0 :         return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
     898             :     }
     899             : 
     900        1474 :     if( ( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.document.Settings" ) ) ||
     901         631 :         ( !mbImpressDoc && ( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.drawing.DocumentSettings" ) ) ) ||
     902         367 :         ( mbImpressDoc && ( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.DocumentSettings" ) ) ) )
     903             :     {
     904          23 :         return sd::DocumentSettings_createInstance( this );
     905             :     }
     906             : 
     907         945 :     if( ( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.text.TextField.DateTime" ) ) ||
     908         469 :         ( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.text.textfield.DateTime" ) ) )
     909             :     {
     910           7 :         return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::DATE );
     911             :     }
     912             : 
     913         932 :     if( (0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.TextField.Header")) ||
     914         463 :         (0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.textfield.Header")) )
     915             :     {
     916           6 :         return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::PRESENTATION_HEADER );
     917             :     }
     918             : 
     919         917 :     if( (0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.TextField.Footer")) ||
     920         454 :         (0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.textfield.Footer")) )
     921             :     {
     922           9 :         return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::PRESENTATION_FOOTER );
     923             :     }
     924             : 
     925         899 :     if( (0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.TextField.DateTime")) ||
     926         445 :         (0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.presentation.textfield.DateTime")) )
     927             :     {
     928           9 :         return (::cppu::OWeakObject * )new SvxUnoTextField( text::textfield::Type::PRESENTATION_DATE_TIME );
     929             :     }
     930             : 
     931         445 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.xml.NamespaceMap" ) )
     932             :     {
     933             :         static sal_uInt16 aWhichIds[] = { SDRATTR_XMLATTRIBUTES, EE_CHAR_XMLATTRIBS, EE_PARA_XMLATTRIBS, 0 };
     934             : 
     935          29 :         return svx::NamespaceMap_createInstance( aWhichIds, &mpDoc->GetItemPool() );
     936             :     }
     937             : 
     938             :     // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
     939         416 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.document.ExportGraphicObjectResolver" ) )
     940             :     {
     941           1 :         return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE );
     942             :     }
     943             : 
     944         415 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.document.ImportGraphicObjectResolver" ) )
     945             :     {
     946           7 :         return (::cppu::OWeakObject * )new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ );
     947             :     }
     948             : 
     949         408 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.document.ExportEmbeddedObjectResolver" ) )
     950             :     {
     951           1 :         ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL;
     952           1 :         if( NULL == pPersist )
     953           0 :             throw lang::DisposedException();
     954             : 
     955           1 :         return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_WRITE );
     956             :     }
     957             : 
     958         407 :     if( 0 == aServiceSpecifier.reverseCompareTo( "com.sun.star.document.ImportEmbeddedObjectResolver" ) )
     959             :     {
     960           7 :         ::comphelper::IEmbeddedHelper *pPersist = mpDoc ? mpDoc->GetPersist() : NULL;
     961           7 :         if( NULL == pPersist )
     962           0 :             throw lang::DisposedException();
     963             : 
     964           7 :         return (::cppu::OWeakObject * )new SvXMLEmbeddedObjectHelper( *pPersist, EMBEDDEDOBJECTHELPER_MODE_READ );
     965             :     }
     966             : 
     967         800 :     uno::Reference< uno::XInterface > xRet;
     968             : 
     969         800 :     const String aType( aServiceSpecifier );
     970         400 :     if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
     971             :     {
     972         132 :         SvxShape* pShape = NULL;
     973             : 
     974         132 :         sal_uInt16 nType = OBJ_TEXT;
     975             :         // create a shape wrapper
     976         132 :         if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
     977             :         {
     978          13 :             nType = OBJ_TEXT;
     979             :         }
     980         119 :         else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
     981             :         {
     982           8 :             nType = OBJ_TEXT;
     983             :         }
     984         111 :         else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
     985             :         {
     986           2 :             nType = OBJ_TEXT;
     987             :         }
     988         109 :         else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
     989             :         {
     990           1 :             nType = OBJ_GRAF;
     991             :         }
     992         108 :         else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
     993             :         {
     994          17 :             nType = OBJ_PAGE;
     995             :         }
     996          91 :         else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
     997             :         {
     998           0 :             nType = OBJ_OLE2;
     999             :         }
    1000          91 :         else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
    1001             :         {
    1002           0 :             nType = OBJ_OLE2;
    1003             :         }
    1004          91 :         else if( aType.EqualsAscii( "CalcShape", 26, 9 ) )
    1005             :         {
    1006           0 :             nType = OBJ_OLE2;
    1007             :         }
    1008          91 :         else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
    1009             :         {
    1010           0 :             nType = OBJ_TABLE;
    1011             :         }
    1012          91 :         else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
    1013             :         {
    1014           0 :             nType = OBJ_OLE2;
    1015             :         }
    1016          91 :         else if( aType.EqualsAscii( "NotesShape", 26, 13 ) )
    1017             :         {
    1018          17 :             nType = OBJ_TEXT;
    1019             :         }
    1020          74 :         else if( aType.EqualsAscii( "HandoutShape", 26, 13 ) )
    1021             :         {
    1022          24 :             nType = OBJ_PAGE;
    1023             :         }
    1024          50 :         else if( aType.EqualsAscii( "FooterShape", 26, 12 ) )
    1025             :         {
    1026          14 :             nType = OBJ_TEXT;
    1027             :         }
    1028          36 :         else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) )
    1029             :         {
    1030           6 :             nType = OBJ_TEXT;
    1031             :         }
    1032          30 :         else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) )
    1033             :         {
    1034          17 :             nType = OBJ_TEXT;
    1035             :         }
    1036          13 :         else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) )
    1037             :         {
    1038          13 :             nType = OBJ_TEXT;
    1039             :         }
    1040           0 :         else if( aType.EqualsAscii( "MediaShape", 26, 10 ) )
    1041             :         {
    1042           0 :             nType = OBJ_MEDIA;
    1043             :         }
    1044             :         else
    1045             :         {
    1046           0 :             throw lang::ServiceNotRegisteredException();
    1047             :         }
    1048             : 
    1049             :         // create the API wrapper
    1050         132 :         pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
    1051             : 
    1052             :         // set shape type
    1053         132 :         if( pShape && !mbClipBoard )
    1054         132 :             pShape->SetShapeType(aServiceSpecifier);
    1055             : 
    1056         132 :         xRet = (uno::XWeak*)pShape;
    1057             :     }
    1058         268 :     else if ( aServiceSpecifier == "com.sun.star.drawing.TableShape" )
    1059             :     {
    1060           2 :         SvxShape* pShape = CreateSvxShapeByTypeAndInventor( OBJ_TABLE, SdrInventor );
    1061           2 :         if( pShape && !mbClipBoard )
    1062           2 :             pShape->SetShapeType(aServiceSpecifier);
    1063             : 
    1064           2 :         xRet = (uno::XWeak*)pShape;
    1065             :     }
    1066             :     else
    1067             :     {
    1068         266 :         xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
    1069             :     }
    1070             : 
    1071         790 :     uno::Reference< drawing::XShape > xShape( xRet, uno::UNO_QUERY );
    1072         395 :     if( xShape.is() )
    1073             :     {
    1074         371 :         xRet.clear();
    1075         371 :         new SdXShape( SvxShape::getImplementation( xShape ), (SdXImpressDocument*)this );
    1076         371 :         xRet = xShape;
    1077         371 :         xShape.clear();
    1078             :     }
    1079             : 
    1080        1040 :     return xRet;
    1081             : }
    1082             : 
    1083          58 : uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getAvailableServiceNames()
    1084             :     throw(uno::RuntimeException)
    1085             : {
    1086          58 :     ::SolarMutexGuard aGuard;
    1087             : 
    1088          58 :     if( NULL == mpDoc )
    1089           0 :         throw lang::DisposedException();
    1090             : 
    1091         116 :     const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
    1092             : 
    1093         116 :     uno::Sequence< OUString > aSNS( mbImpressDoc ? (36) : (19) );
    1094             : 
    1095          58 :     sal_uInt16 i(0);
    1096             : 
    1097          58 :     aSNS[i++] = "com.sun.star.drawing.DashTable";
    1098          58 :     aSNS[i++] = "com.sun.star.drawing.GradientTable";
    1099          58 :     aSNS[i++] = "com.sun.star.drawing.HatchTable";
    1100          58 :     aSNS[i++] = "com.sun.star.drawing.BitmapTable";
    1101          58 :     aSNS[i++] = "com.sun.star.drawing.TransparencyGradientTable";
    1102          58 :     aSNS[i++] = "com.sun.star.drawing.MarkerTable";
    1103          58 :     aSNS[i++] = "com.sun.star.text.NumberingRules";
    1104          58 :     aSNS[i++] = "com.sun.star.drawing.Background";
    1105          58 :     aSNS[i++] = "com.sun.star.document.Settings";
    1106          58 :     aSNS[i++] = sUNO_Service_ImageMapRectangleObject;
    1107          58 :     aSNS[i++] = sUNO_Service_ImageMapCircleObject;
    1108          58 :     aSNS[i++] = sUNO_Service_ImageMapPolygonObject;
    1109          58 :     aSNS[i++] = "com.sun.star.xml.NamespaceMap";
    1110             : 
    1111             :     // Support creation of GraphicObjectResolver and EmbeddedObjectResolver
    1112          58 :     aSNS[i++] = "com.sun.star.document.ExportGraphicObjectResolver";
    1113          58 :     aSNS[i++] = "com.sun.star.document.ImportGraphicObjectResolver";
    1114          58 :     aSNS[i++] = "com.sun.star.document.ExportEmbeddedObjectResolver";
    1115          58 :     aSNS[i++] = "com.sun.star.document.ImportEmbeddedObjectResolver";
    1116          58 :     aSNS[i++] = "com.sun.star.drawing.TableShape";
    1117             : 
    1118          58 :     if(mbImpressDoc)
    1119             :     {
    1120          33 :         aSNS[i++] = "com.sun.star.presentation.TitleTextShape";
    1121          33 :         aSNS[i++] = "com.sun.star.presentation.OutlinerShape";
    1122          33 :         aSNS[i++] = "com.sun.star.presentation.SubtitleShape";
    1123          33 :         aSNS[i++] = "com.sun.star.presentation.GraphicObjectShape";
    1124          33 :         aSNS[i++] = "com.sun.star.presentation.ChartShape";
    1125          33 :         aSNS[i++] = "com.sun.star.presentation.PageShape";
    1126          33 :         aSNS[i++] = "com.sun.star.presentation.OLE2Shape";
    1127          33 :         aSNS[i++] = "com.sun.star.presentation.TableShape";
    1128          33 :         aSNS[i++] = "com.sun.star.presentation.OrgChartShape";
    1129          33 :         aSNS[i++] = "com.sun.star.presentation.NotesShape";
    1130          33 :         aSNS[i++] = "com.sun.star.presentation.HandoutShape";
    1131          33 :         aSNS[i++] = "com.sun.star.presentation.DocumentSettings";
    1132          33 :         aSNS[i++] = "com.sun.star.presentation.FooterShape";
    1133          33 :         aSNS[i++] = "com.sun.star.presentation.HeaderShape";
    1134          33 :         aSNS[i++] = "com.sun.star.presentation.SlideNumberShape";
    1135          33 :         aSNS[i++] = "com.sun.star.presentation.DateTimeShape";
    1136          33 :         aSNS[i++] = "com.sun.star.presentation.CalcShape";
    1137          33 :         aSNS[i++] = "com.sun.star.presentation.MediaShape";
    1138             :     }
    1139             :     else
    1140             :     {
    1141          25 :         aSNS[i++] = "com.sun.star.drawing.DocumentSettings";
    1142             :     }
    1143             : 
    1144             :     DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
    1145             : 
    1146         116 :     return comphelper::concatSequences( aSNS_ORG, aSNS );
    1147             : }
    1148             : 
    1149             : // lang::XServiceInfo
    1150           0 : OUString SAL_CALL SdXImpressDocument::getImplementationName()
    1151             :     throw(uno::RuntimeException)
    1152             : {
    1153           0 :     return OUString( "SdXImpressDocument" );
    1154             : }
    1155             : 
    1156         200 : sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName )
    1157             :     throw(uno::RuntimeException)
    1158             : {
    1159         200 :     ::SolarMutexGuard aGuard;
    1160             : 
    1161         400 :     if ( ServiceName == "com.sun.star.document.OfficeDocument"
    1162         115 :       || ServiceName == "com.sun.star.drawing.GenericDrawingDocument"
    1163         311 :       || ServiceName == "com.sun.star.drawing.DrawingDocumentFactory" )
    1164             :     {
    1165          89 :         return sal_True;
    1166             :     }
    1167             : 
    1168          76 :     return ( ( mbImpressDoc && ServiceName == "com.sun.star.presentation.PresentationDocument" )
    1169         159 :          || ( !mbImpressDoc && ServiceName == "com.sun.star.drawing.DrawingDocument" ) );
    1170             : }
    1171             : 
    1172          94 : uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException)
    1173             : {
    1174          94 :     ::SolarMutexGuard aGuard;
    1175             : 
    1176          94 :     uno::Sequence< OUString > aSeq( 4 );
    1177          94 :     OUString* pServices = aSeq.getArray();
    1178             : 
    1179          94 :     *pServices++ = "com.sun.star.document.OfficeDocument";
    1180          94 :     *pServices++ = "com.sun.star.drawing.GenericDrawingDocument";
    1181          94 :     *pServices++ = "com.sun.star.drawing.DrawingDocumentFactory";
    1182             : 
    1183          94 :     if( mbImpressDoc )
    1184          24 :         *pServices++ = "com.sun.star.presentation.PresentationDocument";
    1185             :     else
    1186          70 :         *pServices++ = "com.sun.star.drawing.DrawingDocument";
    1187             : 
    1188          94 :     return aSeq;
    1189             : }
    1190             : 
    1191             : // XPropertySet
    1192          82 : uno::Reference< beans::XPropertySetInfo > SAL_CALL SdXImpressDocument::getPropertySetInfo(  )
    1193             :     throw(uno::RuntimeException)
    1194             : {
    1195          82 :     ::SolarMutexGuard aGuard;
    1196          82 :     return mpPropSet->getPropertySetInfo();
    1197             : }
    1198             : 
    1199          25 : void SAL_CALL SdXImpressDocument::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue )
    1200             :     throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
    1201             : {
    1202          25 :     ::SolarMutexGuard aGuard;
    1203             : 
    1204          25 :     if( NULL == mpDoc )
    1205           0 :         throw lang::DisposedException();
    1206             : 
    1207          25 :     const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(aPropertyName);
    1208             : 
    1209          25 :     switch( pEntry ? pEntry->nWID : -1 )
    1210             :     {
    1211             :         case WID_MODEL_LANGUAGE:
    1212             :         {
    1213           0 :             lang::Locale aLocale;
    1214           0 :             if(!(aValue >>= aLocale))
    1215           0 :                 throw lang::IllegalArgumentException();
    1216             : 
    1217           0 :             mpDoc->SetLanguage( LanguageTag(aLocale).getLanguageType(), EE_CHAR_LANGUAGE );
    1218           0 :             break;
    1219             :         }
    1220             :         case WID_MODEL_TABSTOP:
    1221             :         {
    1222           0 :             sal_Int32 nValue = 0;
    1223           0 :             if(!(aValue >>= nValue) || nValue < 0 )
    1224           0 :                 throw lang::IllegalArgumentException();
    1225             : 
    1226           0 :             mpDoc->SetDefaultTabulator((sal_uInt16)nValue);
    1227           0 :             break;
    1228             :         }
    1229             :         case WID_MODEL_VISAREA:
    1230             :             {
    1231           7 :                 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
    1232           7 :                 if( !pEmbeddedObj )
    1233           0 :                     break;
    1234             : 
    1235           7 :                 awt::Rectangle aVisArea;
    1236           7 :                 if( !(aValue >>= aVisArea) || (aVisArea.Width < 0) || (aVisArea.Height < 0) )
    1237           0 :                     throw lang::IllegalArgumentException();
    1238             : 
    1239           7 :                 pEmbeddedObj->SetVisArea( Rectangle( aVisArea.X, aVisArea.Y, aVisArea.X + aVisArea.Width - 1, aVisArea.Y + aVisArea.Height - 1 ) );
    1240             :             }
    1241           7 :             break;
    1242             :         case WID_MODEL_CONTFOCUS:
    1243             :             {
    1244           2 :                 sal_Bool bFocus = sal_False;
    1245           2 :                 if( !(aValue >>= bFocus ) )
    1246           0 :                     throw lang::IllegalArgumentException();
    1247           2 :                 mpDoc->SetAutoControlFocus( bFocus );
    1248             :             }
    1249           2 :             break;
    1250             :         case WID_MODEL_DSGNMODE:
    1251             :             {
    1252           2 :                 sal_Bool bMode = sal_False;
    1253           2 :                 if( !(aValue >>= bMode ) )
    1254           0 :                     throw lang::IllegalArgumentException();
    1255           2 :                 mpDoc->SetOpenInDesignMode( bMode );
    1256             :             }
    1257           2 :             break;
    1258             :         case WID_MODEL_BUILDID:
    1259           7 :             aValue >>= maBuildId;
    1260          25 :             return;
    1261             :         case WID_MODEL_MAPUNIT:
    1262             :         case WID_MODEL_BASICLIBS:
    1263             :         case WID_MODEL_RUNTIMEUID: // is read-only
    1264             :         case WID_MODEL_DIALOGLIBS:
    1265             :         case WID_MODEL_FONTS:
    1266           0 :             throw beans::PropertyVetoException();
    1267             :         default:
    1268           7 :             throw beans::UnknownPropertyException();
    1269             :     }
    1270             : 
    1271          18 :     SetModified();
    1272             : }
    1273             : 
    1274         207 : uno::Any SAL_CALL SdXImpressDocument::getPropertyValue( const OUString& PropertyName )
    1275             :     throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException)
    1276             : {
    1277         207 :     ::SolarMutexGuard aGuard;
    1278             : 
    1279         414 :     uno::Any aAny;
    1280         207 :     if( NULL == mpDoc )
    1281          65 :         throw lang::DisposedException();
    1282             : 
    1283         142 :     const SfxItemPropertySimpleEntry* pEntry = mpPropSet->getPropertyMapEntry(PropertyName);
    1284             : 
    1285         142 :     switch( pEntry ? pEntry->nWID : -1 )
    1286             :     {
    1287             :         case WID_MODEL_LANGUAGE:
    1288             :         {
    1289           0 :             LanguageType eLang = mpDoc->GetLanguage( EE_CHAR_LANGUAGE );
    1290           0 :             aAny <<= LanguageTag( eLang).getLocale();
    1291           0 :             break;
    1292             :         }
    1293             :         case WID_MODEL_TABSTOP:
    1294           0 :             aAny <<= (sal_Int32)mpDoc->GetDefaultTabulator();
    1295           0 :             break;
    1296             :         case WID_MODEL_VISAREA:
    1297             :             {
    1298           6 :                 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
    1299           6 :                 if( !pEmbeddedObj )
    1300           0 :                     break;
    1301             : 
    1302           6 :                 const Rectangle& aRect = pEmbeddedObj->GetVisArea();
    1303           6 :                 awt::Rectangle aVisArea( aRect.Left(), aRect.Top(), aRect.getWidth(), aRect.getHeight() );
    1304           6 :                 aAny <<= aVisArea;
    1305             :             }
    1306           6 :             break;
    1307             :         case WID_MODEL_MAPUNIT:
    1308             :             {
    1309           0 :                 SfxObjectShell* pEmbeddedObj = mpDoc->GetDocSh();
    1310           0 :                 if( !pEmbeddedObj )
    1311           0 :                     break;
    1312             : 
    1313           0 :                 sal_Int16 nMeasureUnit = 0;
    1314           0 :                 SvxMapUnitToMeasureUnit( (const short)pEmbeddedObj->GetMapUnit(), nMeasureUnit );
    1315           0 :                 aAny <<= (sal_Int16)nMeasureUnit;
    1316             :         }
    1317           0 :         break;
    1318             :         case WID_MODEL_FORBCHARS:
    1319             :         {
    1320           0 :             aAny <<= getForbiddenCharsTable();
    1321             :         }
    1322           0 :         break;
    1323             :         case WID_MODEL_CONTFOCUS:
    1324           0 :             aAny <<= (sal_Bool)mpDoc->GetAutoControlFocus();
    1325           0 :             break;
    1326             :         case WID_MODEL_DSGNMODE:
    1327           0 :             aAny <<= mpDoc->GetOpenInDesignMode();
    1328           0 :             break;
    1329             :         case WID_MODEL_BASICLIBS:
    1330           2 :             aAny <<= mpDocShell->GetBasicContainer();
    1331           2 :             break;
    1332             :         case WID_MODEL_DIALOGLIBS:
    1333           0 :             aAny <<= mpDocShell->GetDialogContainer();
    1334           0 :             break;
    1335             :         case WID_MODEL_RUNTIMEUID:
    1336          60 :             aAny <<= getRuntimeUID();
    1337          60 :             break;
    1338             :         case WID_MODEL_BUILDID:
    1339           0 :             return uno::Any( maBuildId );
    1340             :         case WID_MODEL_HASVALIDSIGNATURES:
    1341           0 :             aAny <<= hasValidSignatures();
    1342           0 :             break;
    1343             :         case WID_MODEL_FONTS:
    1344             :             {
    1345           9 :                 uno::Sequence<uno::Any> aSeq;
    1346           9 :                 int nSeqIndex = 0;
    1347             : 
    1348             :                 sal_uInt16 aWhichIds[3] = { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK,
    1349           9 :                                             EE_CHAR_FONTINFO_CTL };
    1350             : 
    1351           9 :                 const SfxItemPool& rPool = mpDoc->GetPool();
    1352             :                 const SfxPoolItem* pItem;
    1353             : 
    1354          36 :                 for( sal_uInt16 i=0; i<3; i++ )
    1355             :                 {
    1356          27 :                     sal_uInt16 nWhichId = aWhichIds[i];
    1357          27 :                     sal_uInt32 nItems = rPool.GetItemCount2( nWhichId );
    1358             : 
    1359          27 :                     aSeq.realloc( aSeq.getLength() + nItems*5 + 5 );
    1360             : 
    1361          54 :                     for( sal_uInt32 j = 0; j < nItems; ++j )
    1362             :                     {
    1363          27 :                         if( 0 != (pItem = rPool.GetItem2( nWhichId, j ) ) )
    1364             :                         {
    1365          27 :                             const SvxFontItem *pFont = (const SvxFontItem *)pItem;
    1366             : 
    1367          27 :                             aSeq[nSeqIndex++] <<= OUString(pFont->GetFamilyName());
    1368          27 :                             aSeq[nSeqIndex++] <<= OUString(pFont->GetStyleName());
    1369          27 :                             aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetFamily());
    1370          27 :                             aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetPitch());
    1371          27 :                             aSeq[nSeqIndex++] <<= sal_Int16(pFont->GetCharSet());
    1372             :                         }
    1373             :                     }
    1374             : 
    1375          27 :                     const SvxFontItem& rFont = (const SvxFontItem&)rPool.GetDefaultItem( nWhichId );
    1376             : 
    1377          27 :                     aSeq[nSeqIndex++] <<= OUString(rFont.GetFamilyName());
    1378          27 :                     aSeq[nSeqIndex++] <<= OUString(rFont.GetStyleName());
    1379          27 :                     aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetFamily());
    1380          27 :                     aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetPitch());
    1381          27 :                     aSeq[nSeqIndex++] <<= sal_Int16(rFont.GetCharSet());
    1382             : 
    1383             :                 }
    1384             : 
    1385           9 :                 aSeq.realloc( nSeqIndex );
    1386           9 :                 aAny <<= aSeq;
    1387           9 :             break;
    1388             :             }
    1389             :         default:
    1390          65 :             throw beans::UnknownPropertyException();
    1391             :     }
    1392             : 
    1393         284 :     return aAny;
    1394             : }
    1395             : 
    1396           0 : void SAL_CALL SdXImpressDocument::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
    1397           0 : void SAL_CALL SdXImpressDocument::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
    1398           0 : void SAL_CALL SdXImpressDocument::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
    1399           0 : void SAL_CALL SdXImpressDocument::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {}
    1400             : 
    1401             : // XLinkTargetSupplier
    1402           1 : uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getLinks()
    1403             :     throw(uno::RuntimeException)
    1404             : {
    1405           1 :     ::SolarMutexGuard aGuard;
    1406             : 
    1407           1 :     if( NULL == mpDoc )
    1408           0 :         throw lang::DisposedException();
    1409             : 
    1410           1 :     uno::Reference< container::XNameAccess > xLinks( mxLinks );
    1411           1 :     if( !xLinks.is() )
    1412           1 :         mxLinks = xLinks = new SdDocLinkTargets( *this );
    1413           1 :     return xLinks;
    1414             : }
    1415             : 
    1416             : // XStyleFamiliesSupplier
    1417         260 : uno::Reference< container::XNameAccess > SAL_CALL SdXImpressDocument::getStyleFamilies(  )
    1418             :     throw(uno::RuntimeException)
    1419             : {
    1420         260 :     ::SolarMutexGuard aGuard;
    1421             : 
    1422         260 :     if( NULL == mpDoc )
    1423           0 :         throw lang::DisposedException();
    1424             : 
    1425         260 :     uno::Reference< container::XNameAccess > xStyles( dynamic_cast< container::XNameAccess* >( mpDoc->GetStyleSheetPool()) );
    1426         260 :     return xStyles;
    1427             : }
    1428             : 
    1429             : // XAnyCompareFactory
    1430         149 : uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCompareByName( const OUString& )
    1431             :     throw (uno::RuntimeException)
    1432             : {
    1433         149 :     return SvxCreateNumRuleCompare();
    1434             : }
    1435             : 
    1436             : // XRenderable
    1437           0 : sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection,
    1438             :                                                          const uno::Sequence< beans::PropertyValue >&  )
    1439             :     throw (lang::IllegalArgumentException, uno::RuntimeException)
    1440             : {
    1441           0 :     ::SolarMutexGuard aGuard;
    1442           0 :     sal_Int32   nRet = 0;
    1443             : 
    1444           0 :     if( NULL == mpDoc )
    1445           0 :         throw lang::DisposedException();
    1446             : 
    1447           0 :     uno::Sequence< beans::PropertyValue > aRenderer;
    1448             : 
    1449           0 :     if( mpDocShell && mpDoc )
    1450             :     {
    1451           0 :         uno::Reference< frame::XModel > xModel;
    1452             : 
    1453           0 :         rSelection >>= xModel;
    1454             : 
    1455           0 :         if( xModel == mpDocShell->GetModel() )
    1456           0 :             nRet = mpDoc->GetSdPageCount( PK_STANDARD );
    1457             :         else
    1458             :         {
    1459           0 :             uno::Reference< drawing::XShapes > xShapes;
    1460             : 
    1461           0 :             rSelection >>= xShapes;
    1462             : 
    1463           0 :             if( xShapes.is() && xShapes->getCount() )
    1464           0 :                 nRet = 1;
    1465           0 :         }
    1466             :     }
    1467           0 :     return nRet;
    1468             : }
    1469             : 
    1470           0 : uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer( sal_Int32 , const uno::Any& ,
    1471             :                                                                                 const uno::Sequence< beans::PropertyValue >& rxOptions )
    1472             :     throw (lang::IllegalArgumentException, uno::RuntimeException)
    1473             : {
    1474           0 :     ::SolarMutexGuard aGuard;
    1475             : 
    1476           0 :     if( NULL == mpDoc )
    1477           0 :         throw lang::DisposedException();
    1478             : 
    1479           0 :     sal_Bool bExportNotesPages = sal_False;
    1480           0 :     for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
    1481             :     {
    1482           0 :         if ( rxOptions[ nProperty ].Name == "ExportNotesPages" )
    1483           0 :             rxOptions[ nProperty].Value >>= bExportNotesPages;
    1484             :     }
    1485           0 :     uno::Sequence< beans::PropertyValue > aRenderer;
    1486           0 :     if( mpDocShell && mpDoc )
    1487             :     {
    1488           0 :         awt::Size aPageSize;
    1489           0 :         if ( bExportNotesPages )
    1490             :         {
    1491           0 :             Size aNotesPageSize = mpDoc->GetSdPage( 0, PK_NOTES )->GetSize();
    1492           0 :             aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() );
    1493             :         }
    1494             :         else
    1495             :         {
    1496           0 :             const Rectangle aVisArea( mpDocShell->GetVisArea( embed::Aspects::MSOLE_DOCPRINT ) );
    1497           0 :             aPageSize = awt::Size( aVisArea.GetWidth(), aVisArea.GetHeight() );
    1498             :         }
    1499           0 :         aRenderer.realloc( 1 );
    1500             : 
    1501           0 :         aRenderer[ 0 ].Name = "PageSize" ;
    1502           0 :         aRenderer[ 0 ].Value <<= aPageSize;
    1503             :     }
    1504           0 :     return aRenderer;
    1505             : }
    1506             : 
    1507             : class ImplRenderPaintProc : public ::sdr::contact::ViewObjectContactRedirector
    1508             : {
    1509             :     const SdrLayerAdmin&    rLayerAdmin;
    1510             :     SdrPageView*            pSdrPageView;
    1511             :     vcl::PDFExtOutDevData*  pPDFExtOutDevData;
    1512             : 
    1513             :     vcl::PDFWriter::StructElement ImplBegStructureTag( SdrObject& rObject );
    1514             : 
    1515             : public:
    1516             :     sal_Bool IsVisible  ( const SdrObject* pObj ) const;
    1517             :     sal_Bool IsPrintable( const SdrObject* pObj ) const;
    1518             : 
    1519             :     ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData );
    1520             :     virtual ~ImplRenderPaintProc();
    1521             : 
    1522             :     // all default implementations just call the same methods at the original. To do something
    1523             :     // different, overload the method and at least do what the method does.
    1524             :     virtual drawinglayer::primitive2d::Primitive2DSequence createRedirectedPrimitive2DSequence(
    1525             :         const sdr::contact::ViewObjectContact& rOriginal,
    1526             :         const sdr::contact::DisplayInfo& rDisplayInfo);
    1527             : };
    1528             : 
    1529           0 : ImplRenderPaintProc::ImplRenderPaintProc( const SdrLayerAdmin& rLA, SdrPageView* pView, vcl::PDFExtOutDevData* pData )
    1530             : :   ViewObjectContactRedirector(),
    1531             :     rLayerAdmin         ( rLA ),
    1532             :     pSdrPageView        ( pView ),
    1533           0 :     pPDFExtOutDevData   ( pData )
    1534             : {
    1535           0 : }
    1536             : 
    1537           0 : ImplRenderPaintProc::~ImplRenderPaintProc()
    1538             : {
    1539           0 : }
    1540             : 
    1541           0 : sal_Int32 ImplPDFGetBookmarkPage( const String& rBookmark, SdDrawDocument& rDoc )
    1542             : {
    1543           0 :     sal_Int32 nPage = -1;
    1544             : 
    1545             :     OSL_TRACE("GotoBookmark %s",
    1546             :         OUStringToOString(rBookmark, RTL_TEXTENCODING_UTF8).getStr());
    1547             : 
    1548           0 :     String aBookmark( rBookmark );
    1549             : 
    1550           0 :     if( rBookmark.Len() && rBookmark.GetChar( 0 ) == sal_Unicode('#') )
    1551           0 :         aBookmark = rBookmark.Copy( 1 );
    1552             : 
    1553             :     // is the bookmark a page ?
    1554             :     sal_Bool        bIsMasterPage;
    1555           0 :     sal_uInt16      nPgNum = rDoc.GetPageByName( aBookmark, bIsMasterPage );
    1556           0 :     SdrObject*  pObj = NULL;
    1557             : 
    1558           0 :     if ( nPgNum == SDRPAGE_NOTFOUND )
    1559             :     {
    1560             :         // is the bookmark a object ?
    1561           0 :         pObj = rDoc.GetObj( aBookmark );
    1562           0 :         if (pObj)
    1563           0 :             nPgNum = pObj->GetPage()->GetPageNum();
    1564             :     }
    1565           0 :     if ( nPgNum != SDRPAGE_NOTFOUND )
    1566           0 :         nPage = ( nPgNum - 1 ) / 2;
    1567           0 :     return nPage;
    1568             : }
    1569             : 
    1570           0 : void ImplPDFExportComments( uno::Reference< drawing::XDrawPage > xPage, vcl::PDFExtOutDevData& rPDFExtOutDevData )
    1571             : {
    1572             :     try
    1573             :     {
    1574           0 :         uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, uno::UNO_QUERY_THROW );
    1575           0 :         uno::Reference< office::XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
    1576             : 
    1577           0 :         LanguageType eLanguage = Application::GetSettings().GetLanguageTag().getLanguageType();
    1578           0 :         while( xAnnotationEnumeration->hasMoreElements() )
    1579             :         {
    1580           0 :             uno::Reference< office::XAnnotation > xAnnotation( xAnnotationEnumeration->nextElement() );
    1581             : 
    1582           0 :             geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
    1583           0 :             uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
    1584           0 :             util::DateTime aDateTime( xAnnotation->getDateTime() );
    1585             : 
    1586           0 :             Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
    1587           0 :             Time aTime( Time::EMPTY );
    1588           0 :             String aStr( SvxDateTimeField::GetFormatted( aDate, aTime, SVXDATEFORMAT_B, *(SD_MOD()->GetNumberFormatter()), eLanguage ) );
    1589             : 
    1590           0 :             vcl::PDFNote aNote;
    1591           0 :             String sTitle( xAnnotation->getAuthor() );
    1592           0 :             sTitle.AppendAscii( ", " );
    1593           0 :             sTitle += aStr;
    1594           0 :             aNote.Title = sTitle;
    1595           0 :             aNote.Contents = xText->getString();
    1596           0 :             rPDFExtOutDevData.CreateNote( Rectangle( Point( static_cast< long >( aRealPoint2D.X * 100 ),
    1597           0 :                 static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 1000 ) ), aNote );
    1598           0 :         }
    1599             :     }
    1600           0 :     catch (const uno::Exception&)
    1601             :     {
    1602             :     }
    1603           0 : }
    1604             : 
    1605           0 : void ImplPDFExportShapeInteraction( uno::Reference< drawing::XShape > xShape, SdDrawDocument& rDoc, vcl::PDFExtOutDevData& rPDFExtOutDevData )
    1606             : {
    1607           0 :     const OUString sGroup   ( "com.sun.star.drawing.GroupShape");
    1608           0 :     const OUString sOnClick ( "OnClick" );
    1609           0 :     const OUString sBookmark( "Bookmark" );
    1610             : 
    1611           0 :     if ( xShape->getShapeType().equals( sGroup ) )
    1612             :     {
    1613           0 :         uno::Reference< container::XIndexAccess > xIndexAccess( xShape, uno::UNO_QUERY );
    1614           0 :         if ( xIndexAccess.is() )
    1615             :         {
    1616           0 :             sal_Int32 i, nCount = xIndexAccess->getCount();
    1617           0 :             for ( i = 0; i < nCount; i++ )
    1618             :             {
    1619           0 :                 uno::Reference< drawing::XShape > xSubShape( xIndexAccess->getByIndex( i ), uno::UNO_QUERY );
    1620           0 :                 if ( xSubShape.is() )
    1621           0 :                     ImplPDFExportShapeInteraction( xSubShape, rDoc, rPDFExtOutDevData );
    1622           0 :             }
    1623           0 :         }
    1624             :     }
    1625             :     else
    1626             :     {
    1627           0 :         uno::Reference< beans::XPropertySet > xShapePropSet( xShape, uno::UNO_QUERY );
    1628           0 :         if( xShapePropSet.is() )
    1629             :         {
    1630           0 :             Size        aPageSize( rDoc.GetSdPage( 0, PK_STANDARD )->GetSize() );
    1631           0 :             Point aPoint( 0, 0 );
    1632           0 :             Rectangle   aPageRect( aPoint, aPageSize );
    1633             : 
    1634           0 :             awt::Point  aShapePos( xShape->getPosition() );
    1635           0 :             awt::Size   aShapeSize( xShape->getSize() );
    1636           0 :             Rectangle   aLinkRect( Point( aShapePos.X, aShapePos.Y ), Size( aShapeSize.Width, aShapeSize.Height ) );
    1637             : 
    1638             :             presentation::ClickAction eCa;
    1639           0 :             uno::Any aAny( xShapePropSet->getPropertyValue( sOnClick ) );
    1640           0 :             if ( aAny >>= eCa )
    1641             :             {
    1642           0 :                 switch ( eCa )
    1643             :                 {
    1644             :                     case presentation::ClickAction_LASTPAGE :
    1645             :                     {
    1646           0 :                         sal_Int32 nCount = rDoc.GetSdPageCount( PK_STANDARD );
    1647           0 :                         sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nCount - 1, vcl::PDFWriter::FitRectangle );
    1648           0 :                         sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
    1649           0 :                         rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
    1650             :                     }
    1651           0 :                     break;
    1652             :                     case presentation::ClickAction_FIRSTPAGE :
    1653             :                     {
    1654           0 :                         sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, 0, vcl::PDFWriter::FitRectangle );
    1655           0 :                         sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
    1656           0 :                         rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
    1657             :                     }
    1658           0 :                     break;
    1659             :                     case presentation::ClickAction_PREVPAGE :
    1660             :                     {
    1661           0 :                         sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber();
    1662           0 :                         if ( nDestPage )
    1663           0 :                             nDestPage--;
    1664           0 :                         sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
    1665           0 :                         sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
    1666           0 :                         rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
    1667             :                     }
    1668           0 :                     break;
    1669             :                     case presentation::ClickAction_NEXTPAGE :
    1670             :                     {
    1671           0 :                         sal_Int32 nDestPage = rPDFExtOutDevData.GetCurrentPageNumber() + 1;
    1672           0 :                         sal_Int32 nLastPage = rDoc.GetSdPageCount( PK_STANDARD ) - 1;
    1673           0 :                         if ( nDestPage > nLastPage )
    1674           0 :                             nDestPage = nLastPage;
    1675           0 :                         sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nDestPage, vcl::PDFWriter::FitRectangle );
    1676           0 :                         sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
    1677           0 :                         rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
    1678             :                     }
    1679           0 :                     break;
    1680             : 
    1681             :                     case presentation::ClickAction_PROGRAM :
    1682             :                     case presentation::ClickAction_BOOKMARK :
    1683             :                     case presentation::ClickAction_DOCUMENT :
    1684             :                     {
    1685           0 :                         OUString aBookmark;
    1686           0 :                         xShapePropSet->getPropertyValue( sBookmark ) >>= aBookmark;
    1687           0 :                         if( !aBookmark.isEmpty() )
    1688             :                         {
    1689           0 :                             switch( eCa )
    1690             :                             {
    1691             :                                 case presentation::ClickAction_DOCUMENT :
    1692             :                                 case presentation::ClickAction_PROGRAM :
    1693             :                                 {
    1694           0 :                                     sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
    1695           0 :                                     rPDFExtOutDevData.SetLinkURL( nLinkId, aBookmark );
    1696             :                                 }
    1697           0 :                                 break;
    1698             :                                 case presentation::ClickAction_BOOKMARK :
    1699             :                                 {
    1700           0 :                                     sal_Int32 nPage = ImplPDFGetBookmarkPage( aBookmark, rDoc );
    1701           0 :                                     if ( nPage != -1 )
    1702             :                                     {
    1703           0 :                                         sal_Int32 nDestId = rPDFExtOutDevData.CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle );
    1704           0 :                                         sal_Int32 nLinkId = rPDFExtOutDevData.CreateLink( aLinkRect, -1 );
    1705           0 :                                         rPDFExtOutDevData.SetLinkDest( nLinkId, nDestId );
    1706             :                                     }
    1707             :                                 }
    1708           0 :                                 break;
    1709             :                                 default:
    1710           0 :                                     break;
    1711             :                             }
    1712           0 :                         }
    1713             :                     }
    1714           0 :                     break;
    1715             : 
    1716             :                     case presentation::ClickAction_STOPPRESENTATION :
    1717             :                     case presentation::ClickAction_SOUND :
    1718             :                     case presentation::ClickAction_INVISIBLE :
    1719             :                     case presentation::ClickAction_VERB :
    1720             :                     case presentation::ClickAction_VANISH :
    1721             :                     case presentation::ClickAction_MACRO :
    1722             :                     default :
    1723           0 :                     break;
    1724             :                 }
    1725           0 :             }
    1726           0 :         }
    1727           0 :     }
    1728           0 : }
    1729             : 
    1730           0 : vcl::PDFWriter::StructElement ImplRenderPaintProc::ImplBegStructureTag( SdrObject& rObject )
    1731             : {
    1732           0 :     vcl::PDFWriter::StructElement eElement(vcl::PDFWriter::NonStructElement);
    1733             : 
    1734           0 :     if ( pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportTaggedPDF() )
    1735             :     {
    1736           0 :         sal_uInt32 nInventor   = rObject.GetObjInventor();
    1737           0 :         sal_uInt16 nIdentifier = rObject.GetObjIdentifier();
    1738           0 :         sal_Bool   bIsTextObj  = rObject.ISA( SdrTextObj );
    1739             : 
    1740           0 :         if ( nInventor == SdrInventor )
    1741             :         {
    1742           0 :             if ( nIdentifier == OBJ_GRUP )
    1743           0 :                 eElement = vcl::PDFWriter::Section;
    1744           0 :             else if ( nIdentifier == OBJ_TITLETEXT )
    1745           0 :                 eElement = vcl::PDFWriter::Heading;
    1746           0 :             else if ( nIdentifier == OBJ_OUTLINETEXT )
    1747           0 :                 eElement = vcl::PDFWriter::Division;
    1748           0 :             else if ( !bIsTextObj || !((SdrTextObj&)rObject).HasText() )
    1749           0 :                 eElement = vcl::PDFWriter::Figure;
    1750             :         }
    1751             :     }
    1752             : 
    1753           0 :     return eElement;
    1754             : }
    1755             : 
    1756           0 : drawinglayer::primitive2d::Primitive2DSequence ImplRenderPaintProc::createRedirectedPrimitive2DSequence(
    1757             :     const sdr::contact::ViewObjectContact& rOriginal,
    1758             :     const sdr::contact::DisplayInfo& rDisplayInfo)
    1759             : {
    1760           0 :     SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
    1761             : 
    1762           0 :     if(pObject)
    1763             :     {
    1764           0 :         drawinglayer::primitive2d::Primitive2DSequence xRetval;
    1765             : 
    1766           0 :         if(pObject->GetPage())
    1767             :         {
    1768           0 :             if(pObject->GetPage()->checkVisibility(rOriginal, rDisplayInfo, false))
    1769             :             {
    1770           0 :                 if(IsVisible(pObject) && IsPrintable(pObject))
    1771             :                 {
    1772           0 :                     const vcl::PDFWriter::StructElement eElement(ImplBegStructureTag( *pObject ));
    1773           0 :                     const bool bTagUsed(vcl::PDFWriter::NonStructElement != eElement);
    1774             : 
    1775           0 :                     xRetval = ::sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
    1776             : 
    1777           0 :                     if(xRetval.hasElements() && bTagUsed)
    1778             :                     {
    1779             :                         // embed Primitive2DSequence in a structure tag element for
    1780             :                         // exactly this purpose (StructureTagPrimitive2D)
    1781           0 :                         const drawinglayer::primitive2d::Primitive2DReference xReference(new drawinglayer::primitive2d::StructureTagPrimitive2D(eElement, xRetval));
    1782           0 :                         xRetval = drawinglayer::primitive2d::Primitive2DSequence(&xReference, 1);
    1783             :                     }
    1784             :                 }
    1785             :             }
    1786             :         }
    1787             : 
    1788           0 :         return xRetval;
    1789             :     }
    1790             :     else
    1791             :     {
    1792             :         // not an object, maybe a page
    1793           0 :         return sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
    1794             :     }
    1795             : }
    1796             : 
    1797           0 : sal_Bool ImplRenderPaintProc::IsVisible( const SdrObject* pObj ) const
    1798             : {
    1799           0 :     sal_Bool bVisible = sal_True;
    1800           0 :     SdrLayerID nLayerId = pObj->GetLayer();
    1801           0 :     if( pSdrPageView )
    1802             :     {
    1803           0 :         const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
    1804           0 :         if ( pSdrLayer )
    1805             :         {
    1806           0 :             String aLayerName = pSdrLayer->GetName();
    1807           0 :             bVisible = pSdrPageView->IsLayerVisible( aLayerName );
    1808             :         }
    1809             :     }
    1810           0 :     return bVisible;
    1811             : }
    1812           0 : sal_Bool ImplRenderPaintProc::IsPrintable( const SdrObject* pObj ) const
    1813             : {
    1814           0 :     sal_Bool bPrintable = sal_True;
    1815           0 :     SdrLayerID nLayerId = pObj->GetLayer();
    1816           0 :     if( pSdrPageView )
    1817             :     {
    1818           0 :         const SdrLayer* pSdrLayer = rLayerAdmin.GetLayer( nLayerId );
    1819           0 :         if ( pSdrLayer )
    1820             :         {
    1821           0 :             String aLayerName = pSdrLayer->GetName();
    1822           0 :             bPrintable = pSdrPageView->IsLayerPrintable( aLayerName );
    1823             :         }
    1824             :     }
    1825           0 :     return bPrintable;
    1826             : 
    1827             : }
    1828           0 : void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& rSelection,
    1829             :                                           const uno::Sequence< beans::PropertyValue >& rxOptions )
    1830             :     throw (lang::IllegalArgumentException, uno::RuntimeException)
    1831             : {
    1832           0 :     ::SolarMutexGuard aGuard;
    1833             : 
    1834           0 :     if( NULL == mpDoc )
    1835           0 :         throw lang::DisposedException();
    1836             : 
    1837           0 :     if( mpDocShell && mpDoc )
    1838             :     {
    1839           0 :         uno::Reference< awt::XDevice >  xRenderDevice;
    1840           0 :         const sal_Int32                 nPageNumber = nRenderer + 1;
    1841           0 :         PageKind                        ePageKind = PK_STANDARD;
    1842           0 :         sal_Bool                        bExportNotesPages = sal_False;
    1843             : 
    1844           0 :         for( sal_Int32 nProperty = 0, nPropertyCount = rxOptions.getLength(); nProperty < nPropertyCount; ++nProperty )
    1845             :         {
    1846           0 :             if ( rxOptions[ nProperty ].Name == "RenderDevice" )
    1847           0 :                 rxOptions[ nProperty ].Value >>= xRenderDevice;
    1848           0 :             else if ( rxOptions[ nProperty ].Name == "ExportNotesPages" )
    1849             :             {
    1850           0 :                 rxOptions[ nProperty].Value >>= bExportNotesPages;
    1851           0 :                 if ( bExportNotesPages )
    1852           0 :                     ePageKind = PK_NOTES;
    1853             :             }
    1854             :         }
    1855             : 
    1856           0 :         if( xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) ) )
    1857             :         {
    1858           0 :             VCLXDevice*     pDevice = VCLXDevice::GetImplementation( xRenderDevice );
    1859           0 :             OutputDevice*   pOut = pDevice ? pDevice->GetOutputDevice() : NULL;
    1860             : 
    1861           0 :             if( pOut )
    1862             :             {
    1863           0 :                 vcl::PDFExtOutDevData* pPDFExtOutDevData = PTR_CAST( vcl::PDFExtOutDevData, pOut->GetExtOutDevData() );
    1864             : 
    1865           0 :                 if ( !( (mpDoc->GetSdPage((sal_Int16) nPageNumber-1, PK_STANDARD))->IsExcluded() ) ||
    1866           0 :                     pPDFExtOutDevData->GetIsExportHiddenSlides() )
    1867             :                 {
    1868           0 :                     ::sd::ClientView* pView = new ::sd::ClientView( mpDocShell, pOut, NULL );
    1869           0 :                     Rectangle               aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )->GetSize() );
    1870           0 :                     Region                  aRegion( aVisArea );
    1871             : 
    1872           0 :                     ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
    1873           0 :                     ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : NULL;
    1874             : 
    1875           0 :                     if  ( pOldSdView )
    1876           0 :                         pOldSdView->SdrEndTextEdit();
    1877             : 
    1878           0 :                     pView->SetHlplVisible( sal_False );
    1879           0 :                     pView->SetGridVisible( sal_False );
    1880           0 :                     pView->SetBordVisible( sal_False );
    1881           0 :                     pView->SetPageVisible( sal_False );
    1882           0 :                     pView->SetGlueVisible( sal_False );
    1883             : 
    1884           0 :                     pOut->SetMapMode( MAP_100TH_MM );
    1885           0 :                     pOut->IntersectClipRegion( aVisArea );
    1886             : 
    1887             : 
    1888             : 
    1889           0 :                     uno::Reference< frame::XModel > xModel;
    1890           0 :                     rSelection >>= xModel;
    1891             : 
    1892           0 :                     if( xModel == mpDocShell->GetModel() )
    1893             :                     {
    1894           0 :                         pView->ShowSdrPage( mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind ));
    1895           0 :                         SdrPageView* pPV = pView->GetSdrPageView();
    1896             : 
    1897           0 :                         if( pOldSdView )
    1898             :                         {
    1899           0 :                             SdrPageView* pOldPV = pOldSdView->GetSdrPageView();
    1900           0 :                             if( pPV && pOldPV )
    1901             :                             {
    1902           0 :                                 pPV->SetVisibleLayers( pOldPV->GetVisibleLayers() );
    1903           0 :                                 pPV->SetPrintableLayers( pOldPV->GetPrintableLayers() );
    1904             :                             }
    1905             :                         }
    1906             : 
    1907           0 :                         ImplRenderPaintProc aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
    1908           0 :                             pPV, pPDFExtOutDevData );
    1909             : 
    1910             :                         // background color for outliner :o
    1911           0 :                         SdPage* pPage = (SdPage*)pPV->GetPage();
    1912           0 :                         if( pPage )
    1913             :                         {
    1914           0 :                             SdrOutliner& rOutl = mpDoc->GetDrawOutliner( NULL );
    1915           0 :                             bool bScreenDisplay(true);
    1916             : 
    1917           0 :                             if(bScreenDisplay && pOut && OUTDEV_PRINTER == pOut->GetOutDevType())
    1918             :                             {
    1919             :                                 // #i75566# printing; suppress AutoColor BackgroundColor generation
    1920             :                                 // for visibility reasons by giving GetPageBackgroundColor()
    1921             :                                 // the needed hint
    1922           0 :                                 bScreenDisplay = false;
    1923             :                             }
    1924             : 
    1925           0 :                             if(bScreenDisplay && pOut && pOut->GetPDFWriter())
    1926             :                             {
    1927             :                                 // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see above)
    1928           0 :                                 bScreenDisplay = false;
    1929             :                             }
    1930             : 
    1931             :                             // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
    1932             :                             // hint value if screen display. Only then the AutoColor mechanisms shall be applied
    1933           0 :                             rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor( pPV, bScreenDisplay ) );
    1934             :                         }
    1935           0 :                         pView->SdrPaintView::CompleteRedraw( pOut, aRegion, &aImplRenderPaintProc );
    1936             : 
    1937           0 :                         if ( pPDFExtOutDevData )
    1938             :                         {
    1939             :                             try
    1940             :                             {
    1941           0 :                                 uno::Any aAny;
    1942           0 :                                 uno::Reference< drawing::XDrawPage > xPage( uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() ) );
    1943           0 :                                 if ( xPage.is() )
    1944             :                                 {
    1945           0 :                                     if ( pPDFExtOutDevData->GetIsExportNotes() )
    1946           0 :                                         ImplPDFExportComments( xPage, *pPDFExtOutDevData );
    1947           0 :                                     uno::Reference< beans::XPropertySet > xPagePropSet( xPage, uno::UNO_QUERY );
    1948           0 :                                     if( xPagePropSet.is() )
    1949             :                                     {
    1950             :                                         // exporting object interactions to pdf
    1951             : 
    1952             :                                         // if necessary, the master page interactions will be exported first
    1953           0 :                                         sal_Bool bIsBackgroundObjectsVisible = sal_False;   // #i39428# IsBackgroundObjectsVisible not available for Draw
    1954           0 :                                         if ( mbImpressDoc && xPagePropSet->getPropertySetInfo()->hasPropertyByName( "IsBackgroundObjectsVisible" ) )
    1955           0 :                                             xPagePropSet->getPropertyValue( "IsBackgroundObjectsVisible" ) >>= bIsBackgroundObjectsVisible;
    1956           0 :                                         if ( bIsBackgroundObjectsVisible && !pPDFExtOutDevData->GetIsExportNotesPages() )
    1957             :                                         {
    1958           0 :                                             uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( xPage, uno::UNO_QUERY );
    1959           0 :                                             if ( xMasterPageTarget.is() )
    1960             :                                             {
    1961           0 :                                                 uno::Reference< drawing::XDrawPage > xMasterPage = xMasterPageTarget->getMasterPage();
    1962           0 :                                                 if ( xMasterPage.is() )
    1963             :                                                 {
    1964           0 :                                                     uno::Reference< drawing::XShapes> xShapes( xMasterPage, uno::UNO_QUERY );
    1965           0 :                                                     sal_Int32 i, nCount = xShapes->getCount();
    1966           0 :                                                     for ( i = 0; i < nCount; i++ )
    1967             :                                                     {
    1968           0 :                                                         aAny = xShapes->getByIndex( i );
    1969           0 :                                                         uno::Reference< drawing::XShape > xShape;
    1970           0 :                                                         if ( aAny >>= xShape )
    1971           0 :                                                             ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
    1972           0 :                                                     }
    1973           0 :                                                 }
    1974           0 :                                             }
    1975             :                                         }
    1976             : 
    1977             :                                         // exporting slide page object interactions
    1978           0 :                                         uno::Reference< drawing::XShapes> xShapes( xPage, uno::UNO_QUERY );
    1979           0 :                                         sal_Int32 i, nCount = xShapes->getCount();
    1980           0 :                                         for ( i = 0; i < nCount; i++ )
    1981             :                                         {
    1982           0 :                                             aAny = xShapes->getByIndex( i );
    1983           0 :                                             uno::Reference< drawing::XShape > xShape;
    1984           0 :                                             if ( aAny >>= xShape )
    1985           0 :                                                 ImplPDFExportShapeInteraction( xShape, *mpDoc, *pPDFExtOutDevData );
    1986           0 :                                         }
    1987             : 
    1988             :                                         // exporting transition effects to pdf
    1989           0 :                                         if ( mbImpressDoc && !pPDFExtOutDevData->GetIsExportNotesPages() && pPDFExtOutDevData->GetIsExportTransitionEffects() )
    1990             :                                         {
    1991           0 :                                             const OUString sEffect( "Effect" );
    1992           0 :                                             const OUString sSpeed ( "Speed" );
    1993           0 :                                             sal_Int32 nTime = 800;
    1994             :                                             presentation::AnimationSpeed aAs;
    1995           0 :                                             if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) )
    1996             :                                             {
    1997           0 :                                                 aAny = xPagePropSet->getPropertyValue( sSpeed );
    1998           0 :                                                 if ( aAny >>= aAs )
    1999             :                                                 {
    2000           0 :                                                     switch( aAs )
    2001             :                                                     {
    2002           0 :                                                         case presentation::AnimationSpeed_SLOW : nTime = 1500; break;
    2003           0 :                                                         case presentation::AnimationSpeed_FAST : nTime = 300; break;
    2004             :                                                         default:
    2005           0 :                                                         case presentation::AnimationSpeed_MEDIUM : nTime = 800;
    2006             :                                                     }
    2007             :                                                 }
    2008             :                                             }
    2009             :                                             presentation::FadeEffect eFe;
    2010           0 :                                             vcl::PDFWriter::PageTransition eType = vcl::PDFWriter::Regular;
    2011           0 :                                             if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) )
    2012             :                                             {
    2013           0 :                                                 aAny = xPagePropSet->getPropertyValue( sEffect );
    2014           0 :                                                 if ( aAny >>= eFe )
    2015             :                                                 {
    2016           0 :                                                     switch( eFe )
    2017             :                                                     {
    2018             :                                                         case presentation::FadeEffect_HORIZONTAL_LINES :
    2019             :                                                         case presentation::FadeEffect_HORIZONTAL_CHECKERBOARD :
    2020           0 :                                                         case presentation::FadeEffect_HORIZONTAL_STRIPES : eType = vcl::PDFWriter::BlindsHorizontal; break;
    2021             : 
    2022             :                                                         case presentation::FadeEffect_VERTICAL_LINES :
    2023             :                                                         case presentation::FadeEffect_VERTICAL_CHECKERBOARD :
    2024           0 :                                                         case presentation::FadeEffect_VERTICAL_STRIPES : eType = vcl::PDFWriter::BlindsVertical; break;
    2025             : 
    2026             :                                                         case presentation::FadeEffect_UNCOVER_TO_RIGHT :
    2027             :                                                         case presentation::FadeEffect_UNCOVER_TO_UPPERRIGHT :
    2028             :                                                         case presentation::FadeEffect_ROLL_FROM_LEFT :
    2029             :                                                         case presentation::FadeEffect_FADE_FROM_UPPERLEFT :
    2030             :                                                         case presentation::FadeEffect_MOVE_FROM_UPPERLEFT :
    2031             :                                                         case presentation::FadeEffect_FADE_FROM_LEFT :
    2032           0 :                                                         case presentation::FadeEffect_MOVE_FROM_LEFT : eType = vcl::PDFWriter::WipeLeftToRight; break;
    2033             : 
    2034             :                                                         case presentation::FadeEffect_UNCOVER_TO_BOTTOM :
    2035             :                                                         case presentation::FadeEffect_UNCOVER_TO_LOWERRIGHT :
    2036             :                                                         case presentation::FadeEffect_ROLL_FROM_TOP :
    2037             :                                                         case presentation::FadeEffect_FADE_FROM_UPPERRIGHT :
    2038             :                                                         case presentation::FadeEffect_MOVE_FROM_UPPERRIGHT :
    2039             :                                                         case presentation::FadeEffect_FADE_FROM_TOP :
    2040           0 :                                                         case presentation::FadeEffect_MOVE_FROM_TOP : eType = vcl::PDFWriter::WipeTopToBottom; break;
    2041             : 
    2042             :                                                         case presentation::FadeEffect_UNCOVER_TO_LEFT :
    2043             :                                                         case presentation::FadeEffect_UNCOVER_TO_LOWERLEFT :
    2044             :                                                         case presentation::FadeEffect_ROLL_FROM_RIGHT :
    2045             : 
    2046             :                                                         case presentation::FadeEffect_FADE_FROM_LOWERRIGHT :
    2047             :                                                         case presentation::FadeEffect_MOVE_FROM_LOWERRIGHT :
    2048             :                                                         case presentation::FadeEffect_FADE_FROM_RIGHT :
    2049           0 :                                                         case presentation::FadeEffect_MOVE_FROM_RIGHT : eType = vcl::PDFWriter::WipeRightToLeft; break;
    2050             : 
    2051             :                                                         case presentation::FadeEffect_UNCOVER_TO_TOP :
    2052             :                                                         case presentation::FadeEffect_UNCOVER_TO_UPPERLEFT :
    2053             :                                                         case presentation::FadeEffect_ROLL_FROM_BOTTOM :
    2054             :                                                         case presentation::FadeEffect_FADE_FROM_LOWERLEFT :
    2055             :                                                         case presentation::FadeEffect_MOVE_FROM_LOWERLEFT :
    2056             :                                                         case presentation::FadeEffect_FADE_FROM_BOTTOM :
    2057           0 :                                                         case presentation::FadeEffect_MOVE_FROM_BOTTOM : eType = vcl::PDFWriter::WipeBottomToTop; break;
    2058             : 
    2059           0 :                                                         case presentation::FadeEffect_OPEN_VERTICAL : eType = vcl::PDFWriter::SplitHorizontalInward; break;
    2060           0 :                                                         case presentation::FadeEffect_CLOSE_HORIZONTAL : eType = vcl::PDFWriter::SplitHorizontalOutward; break;
    2061             : 
    2062           0 :                                                         case presentation::FadeEffect_OPEN_HORIZONTAL : eType = vcl::PDFWriter::SplitVerticalInward; break;
    2063           0 :                                                         case presentation::FadeEffect_CLOSE_VERTICAL : eType = vcl::PDFWriter::SplitVerticalOutward; break;
    2064             : 
    2065           0 :                                                         case presentation::FadeEffect_FADE_TO_CENTER : eType = vcl::PDFWriter::BoxInward; break;
    2066           0 :                                                         case presentation::FadeEffect_FADE_FROM_CENTER : eType = vcl::PDFWriter::BoxOutward; break;
    2067             : 
    2068           0 :                                                         case presentation::FadeEffect_NONE : eType = vcl::PDFWriter::Regular; break;
    2069             : 
    2070             :                                                         case presentation::FadeEffect_RANDOM :
    2071             :                                                         case presentation::FadeEffect_DISSOLVE :
    2072           0 :                                                         default: eType = vcl::PDFWriter::Dissolve; break;
    2073             :                                                     }
    2074             :                                                 }
    2075             :                                             }
    2076             : 
    2077           0 :                                             if ( xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sEffect ) ||
    2078           0 :                                                 xPagePropSet->getPropertySetInfo( )->hasPropertyByName( sSpeed ) )
    2079             :                                             {
    2080           0 :                                                 pPDFExtOutDevData->SetPageTransition( eType, nTime, -1 );
    2081           0 :                                             }
    2082           0 :                                         }
    2083           0 :                                     }
    2084             :                                 }
    2085             : 
    2086           0 :                                 Size        aPageSize( mpDoc->GetSdPage( 0, PK_STANDARD )->GetSize() );
    2087           0 :                                 Point aPoint( 0, 0 );
    2088           0 :                                 Rectangle   aPageRect( aPoint, aPageSize );
    2089             : 
    2090             :                                 // resolving links found in this page by the method ImpEditEngine::Paint
    2091           0 :                                 std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFExtOutDevData->GetBookmarks();
    2092           0 :                                 std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIBeg = rBookmarks.begin();
    2093           0 :                                 std::vector< vcl::PDFExtOutDevBookmarkEntry >::iterator aIEnd = rBookmarks.end();
    2094           0 :                                 while ( aIBeg != aIEnd )
    2095             :                                 {
    2096           0 :                                     sal_Int32 nPage = ImplPDFGetBookmarkPage( aIBeg->aBookmark, *mpDoc );
    2097           0 :                                     if ( nPage != -1 )
    2098             :                                     {
    2099           0 :                                         if ( aIBeg->nLinkId != -1 )
    2100           0 :                                             pPDFExtOutDevData->SetLinkDest( aIBeg->nLinkId, pPDFExtOutDevData->CreateDest( aPageRect, nPage, vcl::PDFWriter::FitRectangle ) );
    2101             :                                         else
    2102           0 :                                             pPDFExtOutDevData->DescribeRegisteredDest( aIBeg->nDestId, aPageRect, nPage, vcl::PDFWriter::FitRectangle );
    2103             :                                     }
    2104             :                                     else
    2105           0 :                                         pPDFExtOutDevData->SetLinkURL( aIBeg->nLinkId, aIBeg->aBookmark );
    2106           0 :                                     ++aIBeg;
    2107             :                                 }
    2108           0 :                                 rBookmarks.clear();
    2109             :                                 //---> #i56629, #i40318
    2110             :                                 //get the page name, will be used as outline element in PDF bookmark pane
    2111           0 :                                 String aPageName = mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1 , PK_STANDARD )->GetName();
    2112           0 :                                 if( aPageName.Len() > 0 )
    2113             :                                 {
    2114             :                                     // insert the bookmark to this page into the NamedDestinations
    2115           0 :                                     if( pPDFExtOutDevData->GetIsExportNamedDestinations() )
    2116           0 :                                         pPDFExtOutDevData->CreateNamedDest( aPageName, aPageRect,  nPageNumber - 1 );
    2117             :                                     //
    2118             :                                     // add the name to the outline, (almost) same code as in sc/source/ui/unoobj/docuno.cxx
    2119             :                                     // issue #i40318.
    2120             :                                     //
    2121           0 :                                     if( pPDFExtOutDevData->GetIsExportBookmarks() )
    2122             :                                     {
    2123             :                                         // Destination Export
    2124             :                                         const sal_Int32 nDestId =
    2125           0 :                                             pPDFExtOutDevData->CreateDest( aPageRect , nPageNumber - 1 );
    2126             : 
    2127             :                                         // Create a new outline item:
    2128           0 :                                         pPDFExtOutDevData->CreateOutlineItem( -1 , aPageName, nDestId );
    2129             :                                     }
    2130           0 :                                 }
    2131             :                                 //<--- #i56629, #i40318
    2132             :                             }
    2133           0 :                             catch (const uno::Exception&)
    2134             :                             {
    2135             :                             }
    2136             : 
    2137           0 :                         }
    2138             :                     }
    2139             :                     else
    2140             :                     {
    2141           0 :                         uno::Reference< drawing::XShapes > xShapes;
    2142           0 :                         rSelection >>= xShapes;
    2143             : 
    2144           0 :                         if( xShapes.is() && xShapes->getCount() )
    2145             :                         {
    2146           0 :                         SdrPageView* pPV = NULL;
    2147             : 
    2148           0 :                         ImplRenderPaintProc  aImplRenderPaintProc( mpDoc->GetLayerAdmin(),
    2149           0 :                                             pOldSdView ? pOldSdView->GetSdrPageView() : NULL, pPDFExtOutDevData );
    2150             : 
    2151           0 :                             for( sal_uInt32 i = 0, nCount = xShapes->getCount(); i < nCount; i++ )
    2152             :                             {
    2153           0 :                                 uno::Reference< drawing::XShape > xShape;
    2154           0 :                                 xShapes->getByIndex( i ) >>= xShape;
    2155             : 
    2156           0 :                                 if( xShape.is() )
    2157             :                                 {
    2158           0 :                                     SvxShape* pShape = SvxShape::getImplementation( xShape );
    2159             : 
    2160           0 :                                     if( pShape )
    2161             :                                     {
    2162           0 :                                         SdrObject* pObj = pShape->GetSdrObject();
    2163           0 :                                         if( pObj && pObj->GetPage()
    2164           0 :                                             && aImplRenderPaintProc.IsVisible( pObj )
    2165           0 :                                                 && aImplRenderPaintProc.IsPrintable( pObj ) )
    2166             :                                         {
    2167           0 :                                             if( !pPV )
    2168           0 :                                                 pPV = pView->ShowSdrPage( pObj->GetPage() );
    2169             : 
    2170           0 :                                             if( pPV )
    2171           0 :                                                 pView->MarkObj( pObj, pPV );
    2172             :                                         }
    2173             :                                     }
    2174             :                                 }
    2175           0 :                             }
    2176           0 :                             pView->DrawMarkedObj(*pOut);
    2177           0 :                         }
    2178             :                     }
    2179             : 
    2180           0 :                     delete pView;
    2181             :                 }
    2182             :             }
    2183           0 :         }
    2184           0 :     }
    2185           0 : }
    2186             : 
    2187          11 : uno::Reference< i18n::XForbiddenCharacters > SdXImpressDocument::getForbiddenCharsTable()
    2188             : {
    2189          11 :     uno::Reference< i18n::XForbiddenCharacters > xForb(mxForbidenCharacters);
    2190             : 
    2191          11 :     if( !xForb.is() )
    2192          11 :         mxForbidenCharacters = xForb = new SdUnoForbiddenCharsTable( mpDoc );
    2193             : 
    2194          11 :     return xForb;
    2195             : }
    2196             : 
    2197         153 : void SdXImpressDocument::initializeDocument()
    2198             : {
    2199         153 :     if( !mbClipBoard )
    2200             :     {
    2201         153 :         switch( mpDoc->GetPageCount() )
    2202             :         {
    2203             :         case 1:
    2204             :         {
    2205             :             // nasty hack to detect clipboard document
    2206           0 :             mbClipBoard = true;
    2207           0 :             break;
    2208             :         }
    2209             :         case 0:
    2210             :         {
    2211           7 :             mpDoc->CreateFirstPages();
    2212           7 :             mpDoc->StopWorkStartupDelay();
    2213           7 :             break;
    2214             :         }
    2215             :         }
    2216             :     }
    2217         153 : }
    2218             : 
    2219         110 : void SAL_CALL SdXImpressDocument::dispose() throw (::com::sun::star::uno::RuntimeException)
    2220             : {
    2221         110 :     if( !mbDisposed )
    2222             :     {
    2223             :         {
    2224         110 :             ::SolarMutexGuard aGuard;
    2225             : 
    2226         110 :             if( mpDoc )
    2227             :             {
    2228          86 :                 EndListening( *mpDoc );
    2229          86 :                 mpDoc = NULL;
    2230             :             }
    2231             : 
    2232             :             // Call the base class dispose() before setting the mbDisposed flag
    2233             :             // to true.  The reason for this is that if close() has not yet been
    2234             :             // called this is done in SfxBaseModel::dispose().  At the end of
    2235             :             // that dispose() is called again.  It is important to forward this
    2236             :             // second dispose() to the base class, too.
    2237             :             // As a consequence the following code has to be able to be run twice.
    2238         110 :             SfxBaseModel::dispose();
    2239         110 :             mbDisposed = true;
    2240             : 
    2241         220 :             uno::Reference< container::XNameAccess > xStyles(mxStyleFamilies);
    2242         110 :             if( xStyles.is() )
    2243             :             {
    2244           0 :                 uno::Reference< lang::XComponent > xComp( xStyles, uno::UNO_QUERY );
    2245           0 :                 if( xComp.is() )
    2246           0 :                     xComp->dispose();
    2247             : 
    2248           0 :                 xStyles = 0;
    2249             :             }
    2250             : 
    2251         220 :             uno::Reference< presentation::XPresentation > xPresentation( mxPresentation );
    2252         110 :             if( xPresentation.is() )
    2253             :             {
    2254           0 :                 uno::Reference< ::com::sun::star::presentation::XPresentation2 > xPres( mpDoc->getPresentation().get() );
    2255           0 :                 uno::Reference< lang::XComponent > xPresComp( xPres, uno::UNO_QUERY );
    2256           0 :                 if( xPresComp.is() )
    2257           0 :                     xPresComp->dispose();
    2258             :             }
    2259             : 
    2260         220 :             uno::Reference< container::XNameAccess > xLinks( mxLinks );
    2261         110 :             if( xLinks.is() )
    2262             :             {
    2263           1 :                 uno::Reference< lang::XComponent > xComp( xLinks, uno::UNO_QUERY );
    2264           1 :                 if( xComp.is() )
    2265           1 :                     xComp->dispose();
    2266             : 
    2267           1 :                 xLinks = 0;
    2268             :             }
    2269             : 
    2270         220 :             uno::Reference< drawing::XDrawPages > xDrawPagesAccess( mxDrawPagesAccess );
    2271         110 :             if( xDrawPagesAccess.is() )
    2272             :             {
    2273          68 :                 uno::Reference< lang::XComponent > xComp( xDrawPagesAccess, uno::UNO_QUERY );
    2274          68 :                 if( xComp.is() )
    2275          68 :                     xComp->dispose();
    2276             : 
    2277          68 :                 xDrawPagesAccess = 0;
    2278             :             }
    2279             : 
    2280         220 :             uno::Reference< drawing::XDrawPages > xMasterPagesAccess( mxMasterPagesAccess );
    2281         110 :             if( xDrawPagesAccess.is() )
    2282             :             {
    2283           0 :                 uno::Reference< lang::XComponent > xComp( xMasterPagesAccess, uno::UNO_QUERY );
    2284           0 :                 if( xComp.is() )
    2285           0 :                     xComp->dispose();
    2286             : 
    2287           0 :                 xDrawPagesAccess = 0;
    2288             :             }
    2289             : 
    2290         220 :             uno::Reference< container::XNameAccess > xLayerManager( mxLayerManager );
    2291         110 :             if( xLayerManager.is() )
    2292             :             {
    2293           2 :                 uno::Reference< lang::XComponent > xComp( xLayerManager, uno::UNO_QUERY );
    2294           2 :                 if( xComp.is() )
    2295           2 :                     xComp->dispose();
    2296             : 
    2297           2 :                 xLayerManager = 0;
    2298             :             }
    2299             : 
    2300         220 :             uno::Reference< container::XNameContainer > xCustomPresentationAccess( mxCustomPresentationAccess );
    2301         110 :             if( xCustomPresentationAccess.is() )
    2302             :             {
    2303           2 :                 uno::Reference< lang::XComponent > xComp( xCustomPresentationAccess, uno::UNO_QUERY );
    2304           2 :                 if( xComp.is() )
    2305           0 :                     xComp->dispose();
    2306             : 
    2307           2 :                 xCustomPresentationAccess = 0;
    2308             :             }
    2309             : 
    2310         110 :             mxDashTable = 0;
    2311         110 :             mxGradientTable = 0;
    2312         110 :             mxHatchTable = 0;
    2313         110 :             mxBitmapTable = 0;
    2314         110 :             mxTransGradientTable = 0;
    2315         110 :             mxMarkerTable = 0;
    2316         220 :             mxDrawingPool = 0;
    2317             :         }
    2318             :     }
    2319         110 : }
    2320             : 
    2321             : //=============================================================================
    2322             : // class SdDrawPagesAccess
    2323             : //=============================================================================
    2324             : 
    2325         110 : SdDrawPagesAccess::SdDrawPagesAccess( SdXImpressDocument& rMyModel )  throw()
    2326         110 : :   mpModel( &rMyModel)
    2327             : {
    2328         110 : }
    2329             : 
    2330         220 : SdDrawPagesAccess::~SdDrawPagesAccess() throw()
    2331             : {
    2332         220 : }
    2333             : 
    2334             : // XIndexAccess
    2335         171 : sal_Int32 SAL_CALL SdDrawPagesAccess::getCount()
    2336             :     throw(uno::RuntimeException)
    2337             : {
    2338         171 :     ::SolarMutexGuard aGuard;
    2339             : 
    2340         171 :     if( NULL == mpModel )
    2341           0 :         throw lang::DisposedException();
    2342             : 
    2343         171 :     return mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
    2344             : }
    2345             : 
    2346         279 : uno::Any SAL_CALL SdDrawPagesAccess::getByIndex( sal_Int32 Index )
    2347             :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
    2348             : {
    2349         279 :     ::SolarMutexGuard aGuard;
    2350             : 
    2351         279 :     if( NULL == mpModel )
    2352           0 :         throw lang::DisposedException();
    2353             : 
    2354         279 :     uno::Any aAny;
    2355             : 
    2356         279 :     if( (Index < 0) || (Index >= mpModel->mpDoc->GetSdPageCount( PK_STANDARD ) ) )
    2357           1 :         throw lang::IndexOutOfBoundsException();
    2358             : 
    2359         278 :     SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)Index, PK_STANDARD );
    2360         278 :     if( pPage )
    2361             :     {
    2362         278 :         uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
    2363         278 :         aAny <<= xDrawPage;
    2364             :     }
    2365             : 
    2366         279 :     return aAny;
    2367             : }
    2368             : 
    2369             : // XNameAccess
    2370           0 : uno::Any SAL_CALL SdDrawPagesAccess::getByName( const OUString& aName ) throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
    2371             : {
    2372           0 :     ::SolarMutexGuard aGuard;
    2373             : 
    2374           0 :     if( NULL == mpModel )
    2375           0 :         throw lang::DisposedException();
    2376             : 
    2377           0 :     if( !aName.isEmpty() )
    2378             :     {
    2379           0 :         const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
    2380             :         sal_uInt16 nPage;
    2381           0 :         for( nPage = 0; nPage < nCount; nPage++ )
    2382             :         {
    2383           0 :             SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
    2384           0 :             if(NULL == pPage)
    2385           0 :                 continue;
    2386             : 
    2387           0 :             if( aName == SdDrawPage::getPageApiName( pPage ) )
    2388             :             {
    2389           0 :                 uno::Any aAny;
    2390           0 :                 uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
    2391           0 :                 aAny <<= xDrawPage;
    2392           0 :                 return aAny;
    2393             :             }
    2394             :         }
    2395             :     }
    2396             : 
    2397           0 :     throw container::NoSuchElementException();
    2398             : }
    2399             : 
    2400           0 : uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getElementNames() throw(uno::RuntimeException)
    2401             : {
    2402           0 :     ::SolarMutexGuard aGuard;
    2403             : 
    2404           0 :     if( NULL == mpModel )
    2405           0 :         throw lang::DisposedException();
    2406             : 
    2407           0 :     const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
    2408           0 :     uno::Sequence< OUString > aNames( nCount );
    2409           0 :     OUString* pNames = aNames.getArray();
    2410             : 
    2411             :     sal_uInt16 nPage;
    2412           0 :     for( nPage = 0; nPage < nCount; nPage++ )
    2413             :     {
    2414           0 :         SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
    2415           0 :         *pNames++ = SdDrawPage::getPageApiName( pPage );
    2416             :     }
    2417             : 
    2418           0 :     return aNames;
    2419             : }
    2420             : 
    2421           0 : sal_Bool SAL_CALL SdDrawPagesAccess::hasByName( const OUString& aName ) throw(uno::RuntimeException)
    2422             : {
    2423           0 :     ::SolarMutexGuard aGuard;
    2424             : 
    2425           0 :     if( NULL == mpModel )
    2426           0 :         throw lang::DisposedException();
    2427             : 
    2428           0 :     const sal_uInt16 nCount = mpModel->mpDoc->GetSdPageCount( PK_STANDARD );
    2429             :     sal_uInt16 nPage;
    2430           0 :     for( nPage = 0; nPage < nCount; nPage++ )
    2431             :     {
    2432           0 :         SdPage* pPage = mpModel->mpDoc->GetSdPage( nPage, PK_STANDARD );
    2433           0 :         if(NULL == pPage)
    2434           0 :             continue;
    2435             : 
    2436           0 :         if( aName == SdDrawPage::getPageApiName( pPage ) )
    2437           0 :             return sal_True;
    2438             :     }
    2439             : 
    2440           0 :     return sal_False;
    2441             : }
    2442             : 
    2443             : // XElementAccess
    2444           1 : uno::Type SAL_CALL SdDrawPagesAccess::getElementType()
    2445             :     throw(uno::RuntimeException)
    2446             : {
    2447           1 :     return ITYPE( drawing::XDrawPage );
    2448             : }
    2449             : 
    2450           1 : sal_Bool SAL_CALL SdDrawPagesAccess::hasElements()
    2451             :     throw(uno::RuntimeException)
    2452             : {
    2453           1 :     return getCount() > 0;
    2454             : }
    2455             : 
    2456             : // XDrawPages
    2457             : 
    2458             : /**
    2459             :  * Creates a new page with model at the specified position.
    2460             :  * @returns corresponding SdDrawPage
    2461             :  */
    2462          18 : uno::Reference< drawing::XDrawPage > SAL_CALL SdDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
    2463             :     throw(uno::RuntimeException)
    2464             : {
    2465          18 :     ::SolarMutexGuard aGuard;
    2466             : 
    2467          18 :     if( NULL == mpModel )
    2468           0 :         throw lang::DisposedException();
    2469             : 
    2470          18 :     if( mpModel->mpDoc )
    2471             :     {
    2472          18 :         SdPage* pPage = mpModel->InsertSdPage( (sal_uInt16)nIndex );
    2473          18 :         if( pPage )
    2474             :         {
    2475          18 :             uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
    2476          18 :             return xDrawPage;
    2477             :         }
    2478             :     }
    2479           0 :     uno::Reference< drawing::XDrawPage > xDrawPage;
    2480          18 :     return xDrawPage;
    2481             : }
    2482             : 
    2483             : /**
    2484             :  * Removes the specified SdDrawPage from the model and the internal list. It
    2485             :  * only works, if there is at least one *normal* page in the model after
    2486             :  * removing this page.
    2487             :  */
    2488           1 : void SAL_CALL SdDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
    2489             :         throw(uno::RuntimeException)
    2490             : {
    2491           1 :     ::SolarMutexGuard aGuard;
    2492             : 
    2493           1 :     if( NULL == mpModel || mpModel->mpDoc == NULL )
    2494           0 :         throw lang::DisposedException();
    2495             : 
    2496           1 :     SdDrawDocument& rDoc = *mpModel->mpDoc;
    2497             : 
    2498           1 :     sal_uInt16 nPageCount = rDoc.GetSdPageCount( PK_STANDARD );
    2499           1 :     if( nPageCount > 1 )
    2500             :     {
    2501             :         // get pPage from xPage and determine the Id (nPos ) afterwards
    2502           1 :         SdDrawPage* pSvxPage = SdDrawPage::getImplementation( xPage );
    2503           1 :         if( pSvxPage )
    2504             :         {
    2505           1 :             SdPage* pPage = (SdPage*) pSvxPage->GetSdrPage();
    2506           1 :             if(pPage && ( pPage->GetPageKind() == PK_STANDARD ) )
    2507             :             {
    2508           1 :                 sal_uInt16 nPage = pPage->GetPageNum();
    2509             : 
    2510           1 :                 SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetPage( nPage+1 ) );
    2511             : 
    2512           1 :                 bool bUndo = rDoc.IsUndoEnabled();
    2513           1 :                 if( bUndo )
    2514             :                 {
    2515             :                     // Add undo actions and delete the pages.  The order of adding
    2516             :                     // the undo actions is important.
    2517           1 :                     rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
    2518           1 :                     rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
    2519           1 :                     rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
    2520             :                 }
    2521             : 
    2522           1 :                 rDoc.RemovePage( nPage ); // the page
    2523           1 :                 rDoc.RemovePage( nPage ); // the notes page
    2524             : 
    2525           1 :                 if( bUndo )
    2526             :                 {
    2527           1 :                     rDoc.EndUndo();
    2528             :                 }
    2529             :                 else
    2530             :                 {
    2531           0 :                     delete pNotesPage;
    2532           0 :                     delete pPage;
    2533             :                 }
    2534             :             }
    2535             :         }
    2536             :     }
    2537             : 
    2538           1 :     mpModel->SetModified();
    2539           1 : }
    2540             : 
    2541             : // XServiceInfo
    2542             : const char pSdDrawPagesAccessService[] = "com.sun.star.drawing.DrawPages";
    2543             : 
    2544           0 : OUString SAL_CALL SdDrawPagesAccess::getImplementationName(  ) throw(uno::RuntimeException)
    2545             : {
    2546           0 :     return OUString( "SdDrawPagesAccess" );
    2547             : }
    2548             : 
    2549           0 : sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
    2550             : {
    2551           0 :     return ServiceName == pSdDrawPagesAccessService;
    2552             : }
    2553             : 
    2554           0 : uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames(  ) throw(uno::RuntimeException)
    2555             : {
    2556           0 :     OUString aService( pSdDrawPagesAccessService );
    2557           0 :     uno::Sequence< OUString > aSeq( &aService, 1 );
    2558           0 :     return aSeq;
    2559             : }
    2560             : 
    2561             : // XComponent
    2562          68 : void SAL_CALL SdDrawPagesAccess::dispose(  ) throw (uno::RuntimeException)
    2563             : {
    2564          68 :     mpModel = NULL;
    2565          68 : }
    2566             : 
    2567           0 : void SAL_CALL SdDrawPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
    2568             : {
    2569             :     OSL_FAIL( "not implemented!" );
    2570           0 : }
    2571             : 
    2572           0 : void SAL_CALL SdDrawPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
    2573             : {
    2574             :     OSL_FAIL( "not implemented!" );
    2575           0 : }
    2576             : 
    2577             : //=============================================================================
    2578             : // class SdMasterPagesAccess
    2579             : //=============================================================================
    2580             : 
    2581          71 : SdMasterPagesAccess::SdMasterPagesAccess( SdXImpressDocument& rMyModel ) throw()
    2582          71 : :   mpModel(&rMyModel)
    2583             : {
    2584          71 : }
    2585             : 
    2586         142 : SdMasterPagesAccess::~SdMasterPagesAccess() throw()
    2587             : {
    2588         142 : }
    2589             : 
    2590             : // XComponent
    2591           0 : void SAL_CALL SdMasterPagesAccess::dispose(  ) throw (uno::RuntimeException)
    2592             : {
    2593           0 :     mpModel = NULL;
    2594           0 : }
    2595             : 
    2596           0 : void SAL_CALL SdMasterPagesAccess::addEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
    2597             : {
    2598             :     OSL_FAIL( "not implemented!" );
    2599           0 : }
    2600             : 
    2601           0 : void SAL_CALL SdMasterPagesAccess::removeEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
    2602             : {
    2603             :     OSL_FAIL( "not implemented!" );
    2604           0 : }
    2605             : 
    2606             : // XIndexAccess
    2607          58 : sal_Int32 SAL_CALL SdMasterPagesAccess::getCount()
    2608             :     throw(uno::RuntimeException)
    2609             : {
    2610          58 :     ::SolarMutexGuard aGuard;
    2611             : 
    2612          58 :     if( NULL == mpModel->mpDoc )
    2613           0 :         throw lang::DisposedException();
    2614             : 
    2615          58 :     return mpModel->mpDoc->GetMasterSdPageCount(PK_STANDARD);
    2616             : }
    2617             : 
    2618             : /**
    2619             :  * Provides a drawing::XDrawPage interface for accessing the Masterpage at the
    2620             :  * specified position in the model.
    2621             :  */
    2622          88 : uno::Any SAL_CALL SdMasterPagesAccess::getByIndex( sal_Int32 Index )
    2623             :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
    2624             : {
    2625          88 :     ::SolarMutexGuard aGuard;
    2626             : 
    2627          88 :     if( NULL == mpModel )
    2628           0 :         throw lang::DisposedException();
    2629             : 
    2630          88 :     uno::Any aAny;
    2631             : 
    2632          88 :     if( (Index < 0) || (Index >= mpModel->mpDoc->GetMasterSdPageCount( PK_STANDARD ) ) )
    2633           1 :         throw lang::IndexOutOfBoundsException();
    2634             : 
    2635          87 :     SdPage* pPage = mpModel->mpDoc->GetMasterSdPage( (sal_uInt16)Index, PK_STANDARD );
    2636          87 :     if( pPage )
    2637             :     {
    2638          87 :         uno::Reference< drawing::XDrawPage >  xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
    2639          87 :         aAny <<= xDrawPage;
    2640             :     }
    2641             : 
    2642          88 :     return aAny;
    2643             : }
    2644             : 
    2645             : // XElementAccess
    2646           1 : uno::Type SAL_CALL SdMasterPagesAccess::getElementType()
    2647             :     throw(uno::RuntimeException)
    2648             : {
    2649           1 :     return ITYPE(drawing::XDrawPage);
    2650             : }
    2651             : 
    2652           1 : sal_Bool SAL_CALL SdMasterPagesAccess::hasElements()
    2653             :     throw(uno::RuntimeException)
    2654             : {
    2655           1 :     return getCount() > 0;
    2656             : }
    2657             : 
    2658             : // XDrawPages
    2659           5 : uno::Reference< drawing::XDrawPage > SAL_CALL SdMasterPagesAccess::insertNewByIndex( sal_Int32 nInsertPos )
    2660             :     throw(uno::RuntimeException)
    2661             : {
    2662           5 :     ::SolarMutexGuard aGuard;
    2663             : 
    2664           5 :     if( NULL == mpModel )
    2665           0 :         throw lang::DisposedException();
    2666             : 
    2667           5 :     uno::Reference< drawing::XDrawPage > xDrawPage;
    2668             : 
    2669           5 :     SdDrawDocument* mpDoc = mpModel->mpDoc;
    2670           5 :     if( mpDoc )
    2671             :     {
    2672             :         // calculate internal index and check for range errors
    2673           5 :         const sal_Int32 nMPageCount = mpDoc->GetMasterPageCount();
    2674           5 :         nInsertPos = nInsertPos * 2 + 1;
    2675           5 :         if( nInsertPos < 0 || nInsertPos > nMPageCount )
    2676           0 :             nInsertPos = nMPageCount;
    2677             : 
    2678             :         // now generate a unique name for the new masterpage
    2679           5 :         const String aStdPrefix( SdResId(STR_LAYOUT_DEFAULT_NAME) );
    2680          10 :         String aPrefix( aStdPrefix );
    2681             : 
    2682           5 :         sal_Bool bUnique = sal_True;
    2683           5 :         sal_Int32 i = 0;
    2684          12 :         do
    2685             :         {
    2686          12 :             bUnique = sal_True;
    2687          36 :             for( sal_Int32 nMaster = 1; nMaster < nMPageCount; nMaster++ )
    2688             :             {
    2689          31 :                 SdPage* pPage = (SdPage*)mpDoc->GetMasterPage((sal_uInt16)nMaster);
    2690          31 :                 if( pPage && pPage->GetName() == aPrefix )
    2691             :                 {
    2692           7 :                     bUnique = sal_False;
    2693           7 :                     break;
    2694             :                 }
    2695             :             }
    2696             : 
    2697          12 :             if( !bUnique )
    2698             :             {
    2699           7 :                 i++;
    2700           7 :                 aPrefix = aStdPrefix;
    2701           7 :                 aPrefix += sal_Unicode( ' ' );
    2702           7 :                 aPrefix += OUString::number( i );
    2703             :             }
    2704             : 
    2705             :         } while( !bUnique );
    2706             : 
    2707          10 :         String aLayoutName( aPrefix );
    2708           5 :         aLayoutName.AppendAscii( SD_LT_SEPARATOR );
    2709           5 :         aLayoutName += String(SdResId(STR_LAYOUT_OUTLINE));
    2710             : 
    2711             :         // create styles
    2712           5 :         ((SdStyleSheetPool*)mpDoc->GetStyleSheetPool())->CreateLayoutStyleSheets( aPrefix );
    2713             : 
    2714             :         // get the first page for initial size and border settings
    2715           5 :         SdPage* pPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_STANDARD );
    2716           5 :         SdPage* pRefNotesPage = mpModel->mpDoc->GetSdPage( (sal_uInt16)0, PK_NOTES);
    2717             : 
    2718             :         // create and instert new draw masterpage
    2719           5 :         SdPage* pMPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True);
    2720           5 :         pMPage->SetSize( pPage->GetSize() );
    2721           5 :         pMPage->SetBorder( pPage->GetLftBorder(),
    2722           5 :                            pPage->GetUppBorder(),
    2723           5 :                            pPage->GetRgtBorder(),
    2724          20 :                            pPage->GetLwrBorder() );
    2725           5 :         pMPage->SetLayoutName( aLayoutName );
    2726           5 :         mpDoc->InsertMasterPage(pMPage,  (sal_uInt16)nInsertPos);
    2727             : 
    2728             :         {
    2729             :             // ensure default MasterPage fill
    2730           5 :             pMPage->EnsureMasterPageDefaultBackground();
    2731             :         }
    2732             : 
    2733           5 :         xDrawPage = uno::Reference< drawing::XDrawPage >::query( pMPage->getUnoPage() );
    2734             : 
    2735             :         // create and instert new notes masterpage
    2736           5 :         SdPage* pMNotesPage = (SdPage*)mpModel->mpDoc->AllocPage(sal_True);
    2737           5 :         pMNotesPage->SetSize( pRefNotesPage->GetSize() );
    2738           5 :         pMNotesPage->SetPageKind(PK_NOTES);
    2739           5 :         pMNotesPage->SetBorder( pRefNotesPage->GetLftBorder(),
    2740           5 :                                 pRefNotesPage->GetUppBorder(),
    2741           5 :                                 pRefNotesPage->GetRgtBorder(),
    2742          20 :                                 pRefNotesPage->GetLwrBorder() );
    2743           5 :         pMNotesPage->SetLayoutName( aLayoutName );
    2744           5 :         mpDoc->InsertMasterPage(pMNotesPage,  (sal_uInt16)nInsertPos + 1);
    2745           5 :         pMNotesPage->SetAutoLayout(AUTOLAYOUT_NOTES, sal_True, sal_True);
    2746          10 :         mpModel->SetModified();
    2747             :     }
    2748             : 
    2749           5 :     return( xDrawPage );
    2750             : }
    2751             : 
    2752             : /**
    2753             :  * Removes the specified SdMasterPage from the model and the internal list. It
    2754             :  * only works, if there is no *normal* page using this page as MasterPage in
    2755             :  * the model.
    2756             :  */
    2757           1 : void SAL_CALL SdMasterPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
    2758             :     throw(uno::RuntimeException)
    2759             : {
    2760           1 :     ::SolarMutexGuard aGuard;
    2761             : 
    2762           1 :     if( NULL == mpModel || mpModel->mpDoc == NULL )
    2763           0 :         throw lang::DisposedException();
    2764             : 
    2765           1 :     SdDrawDocument& rDoc = *mpModel->mpDoc;
    2766             : 
    2767           1 :     SdMasterPage* pSdPage = SdMasterPage::getImplementation( xPage );
    2768           1 :     if(pSdPage == NULL)
    2769           0 :         return;
    2770             : 
    2771           1 :     SdPage* pPage = dynamic_cast< SdPage* > (pSdPage->GetSdrPage());
    2772             : 
    2773             :     DBG_ASSERT( pPage && pPage->IsMasterPage(), "SdMasterPage is not masterpage?");
    2774             : 
    2775           1 :     if( !pPage || !pPage->IsMasterPage() || (mpModel->mpDoc->GetMasterPageUserCount(pPage) > 0))
    2776           0 :         return; //Todo: this should be excepted
    2777             : 
    2778             :     // only standard pages can be removed directly
    2779           1 :     if( pPage->GetPageKind() == PK_STANDARD )
    2780             :     {
    2781           1 :         sal_uInt16 nPage = pPage->GetPageNum();
    2782             : 
    2783           1 :         SdPage* pNotesPage = static_cast< SdPage* >( rDoc.GetMasterPage( nPage+1 ) );
    2784             : 
    2785           1 :         bool bUndo = rDoc.IsUndoEnabled();
    2786           1 :         if( bUndo )
    2787             :         {
    2788             :             // Add undo actions and delete the pages.  The order of adding
    2789             :             // the undo actions is important.
    2790           1 :             rDoc.BegUndo( SdResId( STR_UNDO_DELETEPAGES ) );
    2791           1 :             rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pNotesPage));
    2792           1 :             rDoc.AddUndo(rDoc.GetSdrUndoFactory().CreateUndoDeletePage(*pPage));
    2793             :         }
    2794             : 
    2795             :         // remove both pages
    2796           1 :         rDoc.RemoveMasterPage( nPage );
    2797           1 :         rDoc.RemoveMasterPage( nPage );
    2798             : 
    2799           1 :         if( bUndo )
    2800             :         {
    2801           1 :             rDoc.EndUndo();
    2802             :         }
    2803             :         else
    2804             :         {
    2805           0 :             delete pNotesPage;
    2806           0 :             delete pPage;
    2807             :         }
    2808           1 :     }
    2809             : }
    2810             : 
    2811             : // XServiceInfo
    2812             : const char pSdMasterPagesAccessService[] = "com.sun.star.drawing.MasterPages";
    2813             : 
    2814           0 : OUString SAL_CALL SdMasterPagesAccess::getImplementationName(  ) throw(uno::RuntimeException)
    2815             : {
    2816           0 :     return OUString( "SdMasterPagesAccess" );
    2817             : }
    2818             : 
    2819           0 : sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
    2820             : {
    2821           0 :     return ServiceName == pSdMasterPagesAccessService;
    2822             : }
    2823             : 
    2824           0 : uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames(  ) throw(uno::RuntimeException)
    2825             : {
    2826           0 :     OUString aService( pSdMasterPagesAccessService );
    2827           0 :     uno::Sequence< OUString > aSeq( &aService, 1 );
    2828           0 :     return aSeq;
    2829             : }
    2830             : 
    2831             : //=============================================================================
    2832             : // class SdDocLinkTargets
    2833             : //=============================================================================
    2834             : 
    2835           1 : SdDocLinkTargets::SdDocLinkTargets( SdXImpressDocument& rMyModel ) throw()
    2836           1 : : mpModel( &rMyModel )
    2837             : {
    2838           1 : }
    2839             : 
    2840           2 : SdDocLinkTargets::~SdDocLinkTargets() throw()
    2841             : {
    2842           2 : }
    2843             : 
    2844             : // XComponent
    2845           1 : void SAL_CALL SdDocLinkTargets::dispose(  ) throw (uno::RuntimeException)
    2846             : {
    2847           1 :     mpModel = NULL;
    2848           1 : }
    2849             : 
    2850           0 : void SAL_CALL SdDocLinkTargets::addEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
    2851             : {
    2852             :     OSL_FAIL( "not implemented!" );
    2853           0 : }
    2854             : 
    2855           0 : void SAL_CALL SdDocLinkTargets::removeEventListener( const uno::Reference< lang::XEventListener >&  ) throw (uno::RuntimeException)
    2856             : {
    2857             :     OSL_FAIL( "not implemented!" );
    2858           0 : }
    2859             : 
    2860             : // XNameAccess
    2861           2 : uno::Any SAL_CALL SdDocLinkTargets::getByName( const OUString& aName )
    2862             :     throw(container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
    2863             : {
    2864           2 :     ::SolarMutexGuard aGuard;
    2865             : 
    2866           2 :     if( NULL == mpModel )
    2867           0 :         throw lang::DisposedException();
    2868             : 
    2869           2 :     SdPage* pPage = FindPage( aName );
    2870             : 
    2871           2 :     if( pPage == NULL )
    2872           1 :         throw container::NoSuchElementException();
    2873             : 
    2874           1 :     uno::Any aAny;
    2875             : 
    2876           2 :     uno::Reference< beans::XPropertySet > xProps( pPage->getUnoPage(), uno::UNO_QUERY );
    2877           1 :     if( xProps.is() )
    2878           1 :         aAny <<= xProps;
    2879             : 
    2880           3 :     return aAny;
    2881             : }
    2882             : 
    2883           1 : uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getElementNames()
    2884             :     throw(uno::RuntimeException)
    2885             : {
    2886           1 :     ::SolarMutexGuard aGuard;
    2887             : 
    2888           1 :     if( NULL == mpModel )
    2889           0 :         throw lang::DisposedException();
    2890             : 
    2891           1 :     SdDrawDocument* mpDoc = mpModel->GetDoc();
    2892           1 :     if( mpDoc == NULL )
    2893             :     {
    2894           0 :         uno::Sequence< OUString > aSeq;
    2895           0 :         return aSeq;
    2896             :     }
    2897             : 
    2898           1 :     if( mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW )
    2899             :     {
    2900           1 :         const sal_uInt16 nMaxPages = mpDoc->GetSdPageCount( PK_STANDARD );
    2901           1 :         const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterSdPageCount( PK_STANDARD );
    2902             : 
    2903           1 :         uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
    2904           1 :         OUString* pStr = aSeq.getArray();
    2905             : 
    2906             :         sal_uInt16 nPage;
    2907             :         // standard pages
    2908           2 :         for( nPage = 0; nPage < nMaxPages; nPage++ )
    2909           1 :             *pStr++ = mpDoc->GetSdPage( nPage, PK_STANDARD )->GetName();
    2910             : 
    2911             :         // master pages
    2912           2 :         for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
    2913           1 :             *pStr++ = mpDoc->GetMasterSdPage( nPage, PK_STANDARD )->GetName();
    2914           1 :         return aSeq;
    2915             :     }
    2916             :     else
    2917             :     {
    2918           0 :         const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
    2919           0 :         const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
    2920             : 
    2921           0 :         uno::Sequence< OUString > aSeq( nMaxPages + nMaxMasterPages );
    2922           0 :         OUString* pStr = aSeq.getArray();
    2923             : 
    2924             :         sal_uInt16 nPage;
    2925             :         // standard pages
    2926           0 :         for( nPage = 0; nPage < nMaxPages; nPage++ )
    2927           0 :             *pStr++ = ((SdPage*)mpDoc->GetPage( nPage ))->GetName();
    2928             : 
    2929             :         // master pages
    2930           0 :         for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
    2931           0 :             *pStr++ = ((SdPage*)mpDoc->GetMasterPage( nPage ))->GetName();
    2932           0 :         return aSeq;
    2933           1 :     }
    2934             : }
    2935             : 
    2936           2 : sal_Bool SAL_CALL SdDocLinkTargets::hasByName( const OUString& aName )
    2937             :     throw(uno::RuntimeException)
    2938             : {
    2939           2 :     ::SolarMutexGuard aGuard;
    2940             : 
    2941           2 :     if( NULL == mpModel )
    2942           0 :         throw lang::DisposedException();
    2943             : 
    2944           2 :     return FindPage( aName ) != NULL;
    2945             : }
    2946             : 
    2947             : // container::XElementAccess
    2948           1 : uno::Type SAL_CALL SdDocLinkTargets::getElementType()
    2949             :     throw(uno::RuntimeException)
    2950             : {
    2951           1 :     return ITYPE(beans::XPropertySet);
    2952             : }
    2953             : 
    2954           1 : sal_Bool SAL_CALL SdDocLinkTargets::hasElements()
    2955             :     throw(uno::RuntimeException)
    2956             : {
    2957           1 :     ::SolarMutexGuard aGuard;
    2958             : 
    2959           1 :     if( NULL == mpModel )
    2960           0 :         throw lang::DisposedException();
    2961             : 
    2962           1 :     return mpModel->GetDoc() != NULL;
    2963             : }
    2964             : 
    2965           4 : SdPage* SdDocLinkTargets::FindPage( const OUString& rName ) const throw()
    2966             : {
    2967           4 :     SdDrawDocument* mpDoc = mpModel->GetDoc();
    2968           4 :     if( mpDoc == NULL )
    2969           0 :         return NULL;
    2970             : 
    2971           4 :     const sal_uInt16 nMaxPages = mpDoc->GetPageCount();
    2972           4 :     const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount();
    2973             : 
    2974             :     sal_uInt16 nPage;
    2975             :     SdPage* pPage;
    2976             : 
    2977           4 :     const String aName( rName );
    2978             : 
    2979           4 :     const bool bDraw = mpDoc->GetDocumentType() == DOCUMENT_TYPE_DRAW;
    2980             : 
    2981             :     // standard pages
    2982          12 :     for( nPage = 0; nPage < nMaxPages; nPage++ )
    2983             :     {
    2984          10 :         pPage = (SdPage*)mpDoc->GetPage( nPage );
    2985          10 :         if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
    2986           2 :             return pPage;
    2987             :     }
    2988             : 
    2989             :     // master pages
    2990           8 :     for( nPage = 0; nPage < nMaxMasterPages; nPage++ )
    2991             :     {
    2992           6 :         pPage = (SdPage*)mpDoc->GetMasterPage( nPage );
    2993           6 :         if( (pPage->GetName() == aName) && (!bDraw || (pPage->GetPageKind() == PK_STANDARD)) )
    2994           0 :             return pPage;
    2995             :     }
    2996             : 
    2997           2 :     return NULL;
    2998             : }
    2999             : 
    3000             : // XServiceInfo
    3001           0 : OUString SAL_CALL SdDocLinkTargets::getImplementationName()
    3002             :     throw(uno::RuntimeException)
    3003             : {
    3004           0 :     return OUString( "SdDocLinkTargets" );
    3005             : }
    3006             : 
    3007           0 : sal_Bool SAL_CALL SdDocLinkTargets::supportsService( const OUString& ServiceName )
    3008             :     throw(uno::RuntimeException)
    3009             : {
    3010           0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
    3011             : }
    3012             : 
    3013           0 : uno::Sequence< OUString > SAL_CALL SdDocLinkTargets::getSupportedServiceNames()
    3014             :     throw(uno::RuntimeException)
    3015             : {
    3016           0 :     const OUString aSN( "com.sun.star.document.LinkTargets" );
    3017           0 :     uno::Sequence< OUString > aSeq( &aSN, 1 );
    3018           0 :     return aSeq;
    3019             : }
    3020             : 
    3021           0 : rtl::Reference< SdXImpressDocument > SdXImpressDocument::GetModel( SdDrawDocument* pDocument )
    3022             : {
    3023           0 :     rtl::Reference< SdXImpressDocument > xRet;
    3024           0 :     if( pDocument )
    3025             :     {
    3026           0 :         ::sd::DrawDocShell* pDocShell = pDocument->GetDocSh();
    3027           0 :         if( pDocShell )
    3028             :         {
    3029           0 :             uno::Reference<frame::XModel> xModel(pDocShell->GetModel());
    3030             : 
    3031           0 :             xRet.set( dynamic_cast< SdXImpressDocument* >( xModel.get() ) );
    3032             :         }
    3033             :     }
    3034             : 
    3035           0 :     return xRet;
    3036             : }
    3037             : 
    3038           0 : void NotifyDocumentEvent( SdDrawDocument* pDocument, const OUString& rEventName )
    3039             : {
    3040           0 :     rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
    3041             : 
    3042           0 :     if( xModel.is() )
    3043             :     {
    3044           0 :         uno::Reference< uno::XInterface > xSource( static_cast<uno::XWeak*>( xModel.get() ) );
    3045           0 :         ::com::sun::star::document::EventObject aEvent( xSource, rEventName );
    3046           0 :         xModel->notifyEvent(aEvent );
    3047           0 :     }
    3048           0 : }
    3049             : 
    3050           0 : void NotifyDocumentEvent( SdDrawDocument* pDocument, const OUString& rEventName, const uno::Reference< uno::XInterface >& xSource )
    3051             : {
    3052           0 :     rtl::Reference< SdXImpressDocument > xModel( SdXImpressDocument::GetModel( pDocument ) );
    3053             : 
    3054           0 :     if( xModel.is() )
    3055             :     {
    3056           0 :         ::com::sun::star::document::EventObject aEvent( xSource, rEventName );
    3057           0 :         xModel->notifyEvent(aEvent );
    3058           0 :     }
    3059          33 : }
    3060             : 
    3061             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10