LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - unomodel.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 903 1624 55.6 %
Date: 2015-06-13 12:38:46 Functions: 85 135 63.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11