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

Generated by: LCOV version 1.10