LCOV - code coverage report
Current view: top level - libreoffice/svx/source/unodraw - unomod.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 108 295 36.6 %
Date: 2012-12-17 Functions: 20 38 52.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
      21             : #include <com/sun/star/lang/NoSupportException.hpp>
      22             : #include <com/sun/star/drawing/XShape.hpp>
      23             : #include <osl/mutex.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <svl/itemprop.hxx>
      26             : #include <svtools/unoevent.hxx>
      27             : #include <comphelper/sequence.hxx>
      28             : #include <comphelper/servicehelper.hxx>
      29             : #include <comphelper/serviceinfohelper.hxx>
      30             : 
      31             : #include <cppuhelper/implbase2.hxx>
      32             : #include <svx/unofill.hxx>
      33             : #include <editeng/unonrule.hxx>
      34             : #include <svtools/unoimap.hxx>
      35             : #include <svx/fmdpage.hxx>
      36             : #include <svx/fmmodel.hxx>
      37             : #include <svx/fmpage.hxx>
      38             : #include <sfx2/sfx.hrc>
      39             : #include <svx/unoapi.hxx>
      40             : 
      41             : #include <svx/svdmodel.hxx>
      42             : #include "svx/globl3d.hxx"
      43             : #include <svx/svdtypes.hxx>
      44             : #include <svx/unoprov.hxx>
      45             : #include <svx/unopage.hxx>
      46             : #include <editeng/unofield.hxx>
      47             : #include <svx/unomod.hxx>
      48             : #include <svx/unomodel.hxx>
      49             : #include <svx/svdobj.hxx>
      50             : #include <svx/svdpage.hxx>
      51             : #include <svx/unoshape.hxx>
      52             : 
      53             : #include <com/sun/star/text/textfield/Type.hpp>
      54             : 
      55             : //-////////////////////////////////////////////////////////////////////
      56             : 
      57             : using namespace ::rtl;
      58             : using namespace ::osl;
      59             : using namespace ::com::sun::star;
      60             : 
      61             : //-////////////////////////////////////////////////////////////////////
      62             : 
      63             : #define QUERYINT( xint ) \
      64             :     if( rType == ::getCppuType((const uno::Reference< xint >*)0) ) \
      65             :         aAny <<= uno::Reference< xint >(this)
      66             : 
      67             : #define ITYPE( xint ) \
      68             :     ::getCppuType((const uno::Reference< xint >*)0)
      69             : 
      70             : //-////////////////////////////////////////////////////////////////////
      71             : 
      72             : class SvxUnoDrawPagesAccess : public ::cppu::WeakImplHelper2< ::com::sun::star::drawing::XDrawPages, ::com::sun::star::lang::XServiceInfo >
      73             : {
      74             : private:
      75             :     SvxUnoDrawingModel& mrModel;
      76             : 
      77             : public:
      78             :     SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel ) throw();
      79             :     virtual ~SvxUnoDrawPagesAccess() throw();
      80             : 
      81             :     // XDrawPages
      82             :     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException);
      83             :     virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& xPage ) throw(::com::sun::star::uno::RuntimeException);
      84             : 
      85             :     // XIndexAccess
      86             :     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
      87             :     virtual ::com::sun::star::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) throw(::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
      88             : 
      89             :     // XElementAccess
      90             :     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
      91             :     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
      92             : 
      93             :     // XServiceInfo
      94             :     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
      95             :     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
      96             :     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
      97             : };
      98             : //-////////////////////////////////////////////////////////////////////
      99             : 
     100           0 : static const SvEventDescription* ImplGetSupportedMacroItems()
     101             : {
     102             :     static const SvEventDescription aMacroDescriptionsImpl[] =
     103             :     {
     104             :         { SFX_EVENT_MOUSEOVER_OBJECT, "OnMouseOver" },
     105             :         { SFX_EVENT_MOUSEOUT_OBJECT, "OnMouseOut" },
     106             :         { 0, NULL }
     107             :     };
     108             : 
     109           0 :     return aMacroDescriptionsImpl;
     110             : }
     111             : 
     112             : //-////////////////////////////////////////////////////////////////////
     113             : 
     114             : /** fills the given EventObject from the given SdrHint.
     115             :     @returns
     116             :         true    if the SdrHint could be translated to an EventObject<br>
     117             :         false   if not
     118             : */
     119           0 : sal_Bool SvxUnoDrawMSFactory::createEvent( const SdrModel* pDoc, const SdrHint* pSdrHint, ::com::sun::star::document::EventObject& aEvent )
     120             : {
     121           0 :     const SdrObject* pObj = NULL;
     122           0 :     const SdrPage* pPage = NULL;
     123             : 
     124           0 :     switch( pSdrHint->GetKind() )
     125             :     {
     126             : //              case HINT_LAYERCHG:             // Layerdefinition geaendert
     127             : //              case HINT_LAYERORDERCHG:        // Layerreihenfolge geaendert (Insert/Remove/ChangePos)
     128             : //              case HINT_LAYERSETCHG:          // Layerset geaendert
     129             : //              case HINT_LAYERSETORDERCHG:     // Layersetreihenfolge geaendert (Insert/Remove/ChangePos)
     130             : 
     131             : // #115423#
     132             : //      case HINT_PAGECHG:              // Page geaendert
     133             : //          aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageModified" ) );
     134             : //          pPage = pSdrHint->GetPage();
     135             : //          break;
     136             :         case HINT_PAGEORDERCHG:         // Reihenfolge der Seiten (Zeichenseiten oder Masterpages) geaendert (Insert/Remove/ChangePos)
     137           0 :             aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageOrderModified" ) );
     138           0 :             pPage = pSdrHint->GetPage();
     139           0 :             break;
     140             :         case HINT_OBJCHG:               // Objekt geaendert
     141           0 :             aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeModified" ) );
     142           0 :             pObj = pSdrHint->GetObject();
     143           0 :             break;
     144             :         case HINT_OBJINSERTED:          // Neues Zeichenobjekt eingefuegt
     145           0 :             aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeInserted" ) );
     146           0 :             pObj = pSdrHint->GetObject();
     147           0 :             break;
     148             :         case HINT_OBJREMOVED:           // Zeichenobjekt aus Liste entfernt
     149           0 :             aEvent.EventName = OUString( RTL_CONSTASCII_USTRINGPARAM( "ShapeRemoved" ) );
     150           0 :             pObj = pSdrHint->GetObject();
     151           0 :             break;
     152             : //                HINT_DEFAULTTABCHG,   // Default Tabulatorweite geaendert
     153             : //                HINT_DEFFONTHGTCHG,   // Default FontHeight geaendert
     154             : //                HINT_SWITCHTOPAGE,    // #94278# UNDO/REDO at an object evtl. on another page
     155             : //                HINT_OBJLISTCLEAR     // Is called before an SdrObjList will be cleared
     156             :         default:
     157           0 :             return sal_False;
     158             :     }
     159             : 
     160           0 :     if( pObj )
     161           0 :         aEvent.Source = const_cast<SdrObject*>(pObj)->getUnoShape();
     162           0 :     else if( pPage )
     163           0 :         aEvent.Source = const_cast<SdrPage*>(pPage)->getUnoPage();
     164             :     else
     165           0 :         aEvent.Source = (const_cast<SdrModel*>(pDoc))->getUnoModel();
     166             : 
     167           0 :     return sal_True;
     168             : }
     169             : 
     170        7057 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstance( const OUString& rServiceSpecifier )
     171             :     throw( uno::Exception, uno::RuntimeException )
     172             : {
     173        7057 :     const OUString aDrawingPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.") );
     174             : 
     175        7057 :     if( rServiceSpecifier.compareTo( aDrawingPrefix, aDrawingPrefix.getLength() ) == 0 )
     176             :     {
     177        6974 :         sal_uInt32 nType = UHashMap::getId( rServiceSpecifier );
     178        6974 :         if( nType != UHASHMAP_NOTFOUND )
     179             :         {
     180        6974 :             sal_uInt16 nT = (sal_uInt16)(nType & ~E3D_INVENTOR_FLAG);
     181        6974 :             sal_uInt32 nI = (nType & E3D_INVENTOR_FLAG)?E3dInventor:SdrInventor;
     182             : 
     183        6974 :             return uno::Reference< uno::XInterface >( (drawing::XShape*) SvxDrawPage::CreateShapeByTypeAndInventor( nT, nI ) );
     184             :         }
     185             :     }
     186             : 
     187          83 :     uno::Reference< uno::XInterface > xRet( createTextField( rServiceSpecifier ) );
     188          83 :     if( !xRet.is() )
     189          69 :         throw lang::ServiceNotRegisteredException();
     190             : 
     191          83 :     return xRet;
     192             : }
     193             : 
     194          83 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createTextField( const ::rtl::OUString& ServiceSpecifier ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
     195             : {
     196          83 :     return SvxUnoTextCreateTextField( ServiceSpecifier );
     197             : }
     198             : 
     199           0 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawMSFactory::createInstanceWithArguments( const OUString&, const uno::Sequence< ::com::sun::star::uno::Any >& )
     200             :     throw( uno::Exception, uno::RuntimeException )
     201             : {
     202           0 :     throw lang::NoSupportException();
     203             : }
     204             : 
     205          26 : uno::Sequence< OUString > SAL_CALL SvxUnoDrawMSFactory::getAvailableServiceNames()
     206             :     throw( uno::RuntimeException )
     207             : {
     208          26 :     return UHashMap::getServiceNames();
     209             : }
     210             : 
     211          36 : uno::Sequence< OUString > SvxUnoDrawMSFactory::concatServiceNames( uno::Sequence< OUString >& rServices1, uno::Sequence< OUString >& rServices2 ) throw()
     212             : {
     213          36 :     const sal_Int32 nLen1 = rServices1.getLength();
     214          36 :     const sal_Int32 nLen2 = rServices2.getLength();
     215             : 
     216          36 :     uno::Sequence< OUString > aSeq( nLen1+nLen2 );
     217          36 :     OUString* pStrings = aSeq.getArray();
     218             : 
     219             :     sal_Int32 nIdx;
     220          36 :     OUString* pStringDst = pStrings;
     221          36 :     const OUString* pStringSrc = rServices1.getArray();
     222             : 
     223        1372 :     for( nIdx = 0; nIdx < nLen1; nIdx++ )
     224        1336 :         *pStringDst++ = *pStringSrc++;
     225             : 
     226          36 :     pStringSrc = rServices2.getArray();
     227             : 
     228        1244 :     for( nIdx = 0; nIdx < nLen2; nIdx++ )
     229        1208 :         *pStringDst++ = *pStringSrc++;
     230             : 
     231          36 :     return aSeq;
     232             : }
     233             : 
     234             : 
     235             : ///
     236          82 : SvxUnoDrawingModel::SvxUnoDrawingModel( SdrModel* pDoc ) throw()
     237          82 : : mpDoc( pDoc )
     238             : {
     239          82 : }
     240             : 
     241         164 : SvxUnoDrawingModel::~SvxUnoDrawingModel() throw()
     242             : {
     243         164 : }
     244             : 
     245        1218 : uno::Any SAL_CALL SvxUnoDrawingModel::queryInterface( const uno::Type & rType ) throw(uno::RuntimeException)
     246             : {
     247        1218 :     uno::Any aAny;
     248             : 
     249        1218 :     QUERYINT(lang::XServiceInfo);
     250        1218 :     else QUERYINT(lang::XMultiServiceFactory);
     251         814 :     else QUERYINT(drawing::XDrawPagesSupplier);
     252         732 :     else QUERYINT(com::sun::star::ucb::XAnyCompareFactory);
     253             :     else
     254         732 :         return SfxBaseModel::queryInterface( rType );
     255             : 
     256         486 :     return aAny;
     257             : }
     258             : 
     259       10460 : void SAL_CALL SvxUnoDrawingModel::acquire() throw ( )
     260             : {
     261       10460 :     SfxBaseModel::acquire();
     262       10460 : }
     263             : 
     264       10460 : void SAL_CALL SvxUnoDrawingModel::release() throw ( )
     265             : {
     266       10460 :     SfxBaseModel::release();
     267       10460 : }
     268             : 
     269             : // XTypeProvider
     270           0 : uno::Sequence< uno::Type > SAL_CALL SvxUnoDrawingModel::getTypes(  ) throw(uno::RuntimeException)
     271             : {
     272           0 :     if( maTypeSequence.getLength() == 0 )
     273             :     {
     274           0 :         const uno::Sequence< uno::Type > aBaseTypes( SfxBaseModel::getTypes() );
     275           0 :         const sal_Int32 nBaseTypes = aBaseTypes.getLength();
     276           0 :         const uno::Type* pBaseTypes = aBaseTypes.getConstArray();
     277             : 
     278           0 :         const sal_Int32 nOwnTypes = 4;      // !DANGER! Keep this updated!
     279             : 
     280           0 :         maTypeSequence.realloc(  nBaseTypes + nOwnTypes );
     281           0 :         uno::Type* pTypes = maTypeSequence.getArray();
     282             : 
     283           0 :         *pTypes++ = ITYPE(lang::XServiceInfo);
     284           0 :         *pTypes++ = ITYPE(lang::XMultiServiceFactory);
     285           0 :         *pTypes++ = ITYPE(drawing::XDrawPagesSupplier);
     286           0 :         *pTypes++ = ITYPE(com::sun::star::ucb::XAnyCompareFactory);
     287             : 
     288           0 :         for( sal_Int32 nType = 0; nType < nBaseTypes; nType++ )
     289           0 :             *pTypes++ = *pBaseTypes++;
     290             :     }
     291             : 
     292           0 :     return maTypeSequence;
     293             : }
     294             : 
     295             : namespace
     296             : {
     297             :     class theSvxUnoDrawingModelImplementationId : public rtl::Static< UnoTunnelIdInit, theSvxUnoDrawingModelImplementationId > {};
     298             : }
     299             : 
     300           0 : uno::Sequence< sal_Int8 > SAL_CALL SvxUnoDrawingModel::getImplementationId(  ) throw(uno::RuntimeException)
     301             : {
     302           0 :     return theSvxUnoDrawingModelImplementationId::get().getSeq();
     303             : }
     304             : 
     305          82 : void SAL_CALL SvxUnoDrawingModel::lockControllers(  )
     306             :     throw(uno::RuntimeException)
     307             : {
     308          82 :     if( mpDoc )
     309          82 :         mpDoc->setLock(true);
     310          82 : }
     311             : 
     312          82 : void SAL_CALL SvxUnoDrawingModel::unlockControllers(  )
     313             :     throw(uno::RuntimeException)
     314             : {
     315          82 :     if( mpDoc && mpDoc->isLocked() )
     316             :     {
     317          82 :         mpDoc->setLock(false);
     318             :     }
     319          82 : }
     320             : 
     321           0 : sal_Bool SAL_CALL SvxUnoDrawingModel::hasControllersLocked(  )
     322             :     throw(uno::RuntimeException)
     323             : {
     324           0 :     return mpDoc && mpDoc->isLocked();
     325             : }
     326             : 
     327             : // XDrawPagesSupplier
     328          82 : uno::Reference< drawing::XDrawPages > SAL_CALL SvxUnoDrawingModel::getDrawPages()
     329             :     throw(uno::RuntimeException)
     330             : {
     331          82 :     ::SolarMutexGuard aGuard;
     332             : 
     333          82 :     uno::Reference< drawing::XDrawPages >  xDrawPages( mxDrawPagesAccess );
     334             : 
     335          82 :     if( !xDrawPages.is() )
     336          82 :         mxDrawPagesAccess = xDrawPages = (drawing::XDrawPages*)new SvxUnoDrawPagesAccess(*this);
     337             : 
     338          82 :     return xDrawPages;
     339             : }
     340             : 
     341             : // XMultiServiceFactory ( SvxFmMSFactory )
     342        6642 : uno::Reference< uno::XInterface > SAL_CALL SvxUnoDrawingModel::createInstance( const OUString& aServiceSpecifier )
     343             :     throw(uno::Exception, uno::RuntimeException)
     344             : {
     345        6642 :     ::SolarMutexGuard aGuard;
     346             : 
     347        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.DashTable") ) )
     348             :     {
     349           0 :         if( !mxDashTable.is() )
     350           0 :             mxDashTable = SvxUnoDashTable_createInstance( mpDoc );
     351           0 :         return mxDashTable;
     352             :     }
     353        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.GradientTable") ) )
     354             :     {
     355           0 :         if( !mxGradientTable.is() )
     356           0 :             mxGradientTable = SvxUnoGradientTable_createInstance( mpDoc );
     357           0 :         return mxGradientTable;
     358             :     }
     359        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.HatchTable") ) )
     360             :     {
     361           0 :         if( !mxHatchTable.is() )
     362           0 :             mxHatchTable = SvxUnoHatchTable_createInstance( mpDoc );
     363           0 :         return mxHatchTable;
     364             :     }
     365        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.BitmapTable") ) )
     366             :     {
     367           0 :         if( !mxBitmapTable.is() )
     368           0 :             mxBitmapTable = SvxUnoBitmapTable_createInstance( mpDoc );
     369           0 :         return mxBitmapTable;
     370             :     }
     371        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TransparencyGradientTable") ) )
     372             :     {
     373           0 :         if( !mxTransGradientTable.is() )
     374           0 :             mxTransGradientTable = SvxUnoTransGradientTable_createInstance( mpDoc );
     375           0 :         return mxTransGradientTable;
     376             :     }
     377        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.MarkerTable") ) )
     378             :     {
     379           0 :         if( !mxMarkerTable.is() )
     380           0 :             mxMarkerTable = SvxUnoMarkerTable_createInstance( mpDoc );
     381           0 :         return mxMarkerTable;
     382             :     }
     383        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.NumberingRules" ) ) )
     384             :     {
     385           0 :         return uno::Reference< uno::XInterface >( SvxCreateNumRule( mpDoc ), uno::UNO_QUERY );
     386             :     }
     387             : 
     388        6642 :     if ( aServiceSpecifier == "com.sun.star.image.ImageMapRectangleObject" )
     389             :     {
     390           0 :         return SvUnoImageMapRectangleObject_createInstance( ImplGetSupportedMacroItems() );
     391             :     }
     392             : 
     393        6642 :     if ( aServiceSpecifier == "com.sun.star.image.ImageMapCircleObject" )
     394             :     {
     395           0 :         return SvUnoImageMapCircleObject_createInstance( ImplGetSupportedMacroItems() );
     396             :     }
     397             : 
     398        6642 :     if ( aServiceSpecifier == "com.sun.star.image.ImageMapPolygonObject" )
     399             :     {
     400           0 :         return SvUnoImageMapPolygonObject_createInstance( ImplGetSupportedMacroItems() );
     401             :     }
     402             : 
     403        6642 :     if( 0 == aServiceSpecifier.reverseCompareToAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.text.TextField.DateTime") ) )
     404             :     {
     405           0 :         return (::cppu::OWeakObject * )new SvxUnoTextField(text::textfield::Type::DATE);
     406             :     }
     407             : 
     408        6642 :     uno::Reference< uno::XInterface > xRet;
     409             : 
     410        6642 :     const String aType( aServiceSpecifier );
     411        6642 :     if( aType.EqualsAscii( "com.sun.star.presentation.", 0, 26 ) )
     412             :     {
     413           0 :         SvxShape* pShape = NULL;
     414             : 
     415           0 :         sal_uInt16 nType = OBJ_TEXT;
     416             :         // create a shape wrapper
     417           0 :         if( aType.EqualsAscii( "TitleTextShape", 26, 14 ) )
     418             :         {
     419           0 :             nType = OBJ_TEXT;
     420             :         }
     421           0 :         else if( aType.EqualsAscii( "OutlinerShape", 26, 13 ) )
     422             :         {
     423           0 :             nType = OBJ_TEXT;
     424             :         }
     425           0 :         else if( aType.EqualsAscii( "SubtitleShape", 26, 13 ) )
     426             :         {
     427           0 :             nType = OBJ_TEXT;
     428             :         }
     429           0 :         else if( aType.EqualsAscii( "GraphicObjectShape", 26, 18 ) )
     430             :         {
     431           0 :             nType = OBJ_GRAF;
     432             :         }
     433           0 :         else if( aType.EqualsAscii( "PageShape", 26, 9 ) )
     434             :         {
     435           0 :             nType = OBJ_PAGE;
     436             :         }
     437           0 :         else if( aType.EqualsAscii( "OLE2Shape", 26, 9 ) )
     438             :         {
     439           0 :             nType = OBJ_OLE2;
     440             :         }
     441           0 :         else if( aType.EqualsAscii( "ChartShape", 26, 10 ) )
     442             :         {
     443           0 :             nType = OBJ_OLE2;
     444             :         }
     445           0 :         else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
     446             :         {
     447           0 :             nType = OBJ_OLE2;
     448             :         }
     449           0 :         else if( aType.EqualsAscii( "OrgChartShape", 26, 13 ) )
     450             :         {
     451           0 :             nType = OBJ_OLE2;
     452             :         }
     453           0 :         else if( aType.EqualsAscii( "NotesShape", 26, 10 ) )
     454             :         {
     455           0 :             nType = OBJ_TEXT;
     456             :         }
     457           0 :         else if( aType.EqualsAscii( "HandoutShape", 26, 12 ) )
     458             :         {
     459           0 :             nType = OBJ_PAGE;
     460             :         }
     461           0 :         else if( aType.EqualsAscii( "FooterShape", 26, 12 ) )
     462             :         {
     463           0 :             nType = OBJ_TEXT;
     464             :         }
     465           0 :         else if( aType.EqualsAscii( "HeaderShape", 26, 12 ) )
     466             :         {
     467           0 :             nType = OBJ_TEXT;
     468             :         }
     469           0 :         else if( aType.EqualsAscii( "SlideNumberShape", 26, 17 ) )
     470             :         {
     471           0 :             nType = OBJ_TEXT;
     472             :         }
     473           0 :         else if( aType.EqualsAscii( "DateTimeShape", 26, 17 ) )
     474             :         {
     475           0 :             nType = OBJ_TEXT;
     476             :         }
     477           0 :         else if( aType.EqualsAscii( "TableShape", 26, 10 ) )
     478             :         {
     479           0 :             nType = OBJ_TABLE;
     480             :         }
     481             :         else
     482             :         {
     483           0 :             throw lang::ServiceNotRegisteredException();
     484             :         }
     485             : 
     486             :         // create the API wrapper
     487           0 :         pShape = CreateSvxShapeByTypeAndInventor( nType, SdrInventor );
     488             : 
     489             :         // set shape type
     490           0 :         if( pShape )
     491           0 :             pShape->SetShapeType(aServiceSpecifier);
     492             : 
     493           0 :         xRet = (uno::XWeak*)pShape;
     494             :     }
     495             :     else
     496             :     {
     497        6642 :         xRet = SvxFmMSFactory::createInstance( aServiceSpecifier );
     498             :     }
     499             : 
     500        6642 :     return xRet;
     501             : }
     502             : 
     503           0 : uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getAvailableServiceNames()
     504             :     throw(uno::RuntimeException)
     505             : {
     506           0 :     const uno::Sequence< OUString > aSNS_ORG( SvxFmMSFactory::getAvailableServiceNames() );
     507             : 
     508           0 :     uno::Sequence< OUString > aSNS( 21 );
     509             : 
     510           0 :     sal_uInt16 i = 0;
     511             : 
     512           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DashTable"));
     513           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.GradientTable"));
     514           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.HatchTable"));
     515           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.BitmapTable"));
     516           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.TransparencyGradientTable"));
     517           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.MarkerTable"));
     518           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.NumberingRules"));
     519           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapRectangleObject"));
     520           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapCircleObject"));
     521           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.image.ImageMapPolygonObject"));
     522             : 
     523           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TitleTextShape"));
     524           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OutlinerShape"));
     525           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.SubtitleShape"));
     526           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.GraphicObjectShape"));
     527           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.ChartShape"));
     528           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PageShape"));
     529           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OLE2Shape"));
     530           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.TableShape"));
     531           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.OrgChartShape"));
     532           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.NotesShape"));
     533           0 :     aSNS[i++] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.HandoutShape"));
     534             : 
     535             :     DBG_ASSERT( i == aSNS.getLength(), "Sequence overrun!" );
     536             : 
     537           0 :     return comphelper::concatSequences( aSNS_ORG, aSNS );
     538             : }
     539             : 
     540             : // lang::XServiceInfo
     541           0 : OUString SAL_CALL SvxUnoDrawingModel::getImplementationName()
     542             :     throw(uno::RuntimeException)
     543             : {
     544           0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM("SvxUnoDrawingModel"));
     545             : }
     546             : 
     547           0 : sal_Bool SAL_CALL SvxUnoDrawingModel::supportsService( const OUString& ServiceName )
     548             :     throw(uno::RuntimeException)
     549             : {
     550           0 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     551             : }
     552             : 
     553           0 : uno::Sequence< OUString > SAL_CALL SvxUnoDrawingModel::getSupportedServiceNames() throw(uno::RuntimeException)
     554             : {
     555           0 :     OUString aSN( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocument"));
     556           0 :     uno::Sequence< OUString > aSeq( &aSN, 1 );
     557           0 :     return aSeq;
     558             : }
     559             : 
     560             : // XAnyCompareFactory
     561           0 : uno::Reference< com::sun::star::ucb::XAnyCompare > SAL_CALL SvxUnoDrawingModel::createAnyCompareByName( const OUString& )
     562             :     throw(uno::RuntimeException)
     563             : {
     564           0 :     return SvxCreateNumRuleCompare();
     565             : }
     566             : 
     567             : //=============================================================================
     568             : // class SvxUnoDrawPagesAccess
     569             : //=============================================================================
     570             : 
     571          82 : SvxUnoDrawPagesAccess::SvxUnoDrawPagesAccess( SvxUnoDrawingModel& rMyModel )  throw()
     572          82 : :   mrModel(rMyModel)
     573             : {
     574          82 : }
     575             : 
     576         164 : SvxUnoDrawPagesAccess::~SvxUnoDrawPagesAccess() throw()
     577             : {
     578         164 : }
     579             : 
     580             : // XIndexAccess
     581          82 : sal_Int32 SAL_CALL SvxUnoDrawPagesAccess::getCount()
     582             :     throw(uno::RuntimeException)
     583             : {
     584          82 :     ::SolarMutexGuard aGuard;
     585             : 
     586          82 :     sal_Int32 nCount = 0;
     587             : 
     588          82 :     if( mrModel.mpDoc )
     589          82 :         nCount = mrModel.mpDoc->GetPageCount();
     590             : 
     591          82 :     return( nCount );
     592             : }
     593             : 
     594           0 : uno::Any SAL_CALL SvxUnoDrawPagesAccess::getByIndex( sal_Int32 Index )
     595             :     throw(lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     596             : {
     597           0 :     ::SolarMutexGuard aGuard;
     598             : 
     599           0 :     uno::Any aAny;
     600             : 
     601           0 :     if( mrModel.mpDoc )
     602             :     {
     603           0 :         if( (Index < 0) || (Index >= mrModel.mpDoc->GetPageCount() ) )
     604           0 :             throw lang::IndexOutOfBoundsException();
     605             : 
     606           0 :         SdrPage* pPage = mrModel.mpDoc->GetPage( (sal_uInt16)Index );
     607           0 :         if( pPage )
     608             :         {
     609           0 :             uno::Reference< uno::XInterface > xPage( pPage->mxUnoPage );
     610             : 
     611           0 :             if( !xPage.is() )
     612             :             {
     613           0 :                 if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
     614           0 :                     xPage = (drawing::XDrawPage*)new SvxFmDrawPage( pPage );
     615             :                 else
     616           0 :                     xPage = (drawing::XDrawPage*)new SvxDrawPage( pPage );
     617             : 
     618           0 :                 pPage->mxUnoPage = xPage;
     619             :             }
     620             : 
     621           0 :             aAny <<= xPage;
     622             :         }
     623             :     }
     624           0 :     return aAny;
     625             : }
     626             : 
     627             : // XElementAccess
     628           0 : uno::Type SAL_CALL SvxUnoDrawPagesAccess::getElementType()
     629             :     throw(uno::RuntimeException)
     630             : {
     631           0 :     return ITYPE( drawing::XDrawPage );
     632             : }
     633             : 
     634           0 : sal_Bool SAL_CALL SvxUnoDrawPagesAccess::hasElements()
     635             :     throw(uno::RuntimeException)
     636             : {
     637           0 :     return getCount() > 0;
     638             : }
     639             : 
     640             : // XDrawPages
     641             : 
     642             : /******************************************************************************
     643             : * Erzeugt eine neue Seite mit Model an der angegebennen Position und gibt die *
     644             : * dazugehoerige SdDrawPage zurueck.                                           *
     645             : ******************************************************************************/
     646          82 : uno::Reference< drawing::XDrawPage > SAL_CALL SvxUnoDrawPagesAccess::insertNewByIndex( sal_Int32 nIndex )
     647             :     throw(uno::RuntimeException)
     648             : {
     649          82 :     ::SolarMutexGuard aGuard;
     650             : 
     651          82 :     uno::Reference< drawing::XDrawPage > xDrawPage;
     652             : 
     653          82 :     if( mrModel.mpDoc )
     654             :     {
     655             :         SdrPage* pPage;
     656             : 
     657          82 :         if( PTR_CAST( FmFormModel, mrModel.mpDoc ) )
     658           0 :             pPage = new FmFormPage(*(FmFormModel*)mrModel.mpDoc, NULL);
     659             :         else
     660          82 :             pPage = new SdrPage(*mrModel.mpDoc);
     661             : 
     662          82 :         mrModel.mpDoc->InsertPage( pPage, (sal_uInt16)nIndex );
     663          82 :         xDrawPage = uno::Reference< drawing::XDrawPage >::query( pPage->getUnoPage() );
     664             :     }
     665             : 
     666          82 :     return xDrawPage;
     667             : }
     668             : 
     669           0 : void SAL_CALL SvxUnoDrawPagesAccess::remove( const uno::Reference< drawing::XDrawPage >& xPage )
     670             :         throw(uno::RuntimeException)
     671             : {
     672           0 :     ::SolarMutexGuard aGuard;
     673             : 
     674           0 :     sal_uInt16 nPageCount = mrModel.mpDoc->GetPageCount();
     675           0 :     if( nPageCount > 1 )
     676             :     {
     677             :         // pPage von xPage besorgen und dann die Id (nPos )ermitteln
     678           0 :         SvxDrawPage* pSvxPage = SvxDrawPage::getImplementation( xPage );
     679           0 :         if( pSvxPage )
     680             :         {
     681           0 :             SdrPage* pPage = pSvxPage->GetSdrPage();
     682           0 :             if(pPage)
     683             :             {
     684           0 :                 sal_uInt16 nPage = pPage->GetPageNum();
     685           0 :                 mrModel.mpDoc->DeletePage( nPage );
     686             :             }
     687             :         }
     688           0 :     }
     689           0 : }
     690             : 
     691             : // XServiceInfo
     692             : const char pSvxUnoDrawPagesAccessService[] = "com.sun.star.drawing.DrawPages";
     693             : 
     694           0 : OUString SAL_CALL SvxUnoDrawPagesAccess::getImplementationName(  ) throw(uno::RuntimeException)
     695             : {
     696           0 :     return OUString( RTL_CONSTASCII_USTRINGPARAM( "SvxUnoDrawPagesAccess" ) );
     697             : }
     698             : 
     699           0 : sal_Bool SAL_CALL SvxUnoDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
     700             : {
     701           0 :     return ServiceName == pSvxUnoDrawPagesAccessService;
     702             : }
     703             : 
     704           0 : uno::Sequence< OUString > SAL_CALL SvxUnoDrawPagesAccess::getSupportedServiceNames(  ) throw(uno::RuntimeException)
     705             : {
     706           0 :     OUString aService( RTL_CONSTASCII_USTRINGPARAM( pSvxUnoDrawPagesAccessService ) );
     707           0 :     uno::Sequence< OUString > aSeq( &aService, 1 );
     708           0 :     return aSeq;
     709             : }
     710             : 
     711          14 : com::sun::star::uno::Reference< com::sun::star::container::XIndexReplace > SvxCreateNumRule( SdrModel* pModel ) throw()
     712             : {
     713          14 :     SvxNumRule* pDefaultRule = NULL;
     714          14 :     if( pModel )
     715             :     {
     716          14 :         SvxNumBulletItem* pItem = (SvxNumBulletItem*) pModel->GetItemPool().GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET);
     717          14 :         if( pItem )
     718             :         {
     719          14 :             pDefaultRule = pItem->GetNumRule();
     720             :         }
     721             :     }
     722             : 
     723          14 :     if( pDefaultRule )
     724             :     {
     725          14 :         return SvxCreateNumRule( pDefaultRule );
     726             :     }
     727             :     else
     728             :     {
     729           0 :         SvxNumRule aTempRule( 0, 10, false );
     730           0 :         return SvxCreateNumRule( &aTempRule );
     731             :     }
     732             : }
     733             : 
     734             : ///////////////////////////////////////////////////////////////////////
     735             : 
     736             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10