LCOV - code coverage report
Current view: top level - sd/source/ui/unoidl - unomodel.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1472 0.0 %
Date: 2014-04-14 Functions: 0 118 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10