LCOV - code coverage report
Current view: top level - svx/source/unodraw - unomod.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 145 309 46.9 %
Date: 2015-06-13 12:38:46 Functions: 25 41 61.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11