LCOV - code coverage report
Current view: top level - svx/source/unodraw - unomod.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 308 0.0 %
Date: 2014-04-14 Functions: 0 39 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10