LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/unodraw - unopage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 350 419 83.5 %
Date: 2013-07-09 Functions: 34 37 91.9 %
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/document/EventObject.hpp>
      21             : #include <com/sun/star/lang/DisposedException.hpp>
      22             : #include <osl/mutex.hxx>
      23             : #include <sfx2/dispatch.hxx>
      24             : #include <comphelper/classids.hxx>
      25             : #include <comphelper/serviceinfohelper.hxx>
      26             : 
      27             : #include <sfx2/objsh.hxx>
      28             : #include <svx/svdpool.hxx>
      29             : #include <svx/svdobj.hxx>
      30             : #include <svx/svdoole2.hxx>
      31             : #include <svx/svdpage.hxx>
      32             : #include <svx/svdmodel.hxx>
      33             : #include <svx/svdview.hxx>
      34             : #include <svx/svdpagv.hxx>
      35             : #include <svx/unopage.hxx>
      36             : #include "shapeimpl.hxx"
      37             : #include "svx/globl3d.hxx"
      38             : #include <svx/polysc3d.hxx>
      39             : #include <svx/unoprov.hxx>
      40             : #include <svx/svdopath.hxx>
      41             : #include "svx/unoapi.hxx"
      42             : #include <svx/svdomeas.hxx>
      43             : #include <svx/extrud3d.hxx>
      44             : #include <svx/lathe3d.hxx>
      45             : #include <vcl/svapp.hxx>
      46             : #include <tools/diagnose_ex.h>
      47             : 
      48             : using namespace ::cppu;
      49             : using namespace ::com::sun::star;
      50             : using namespace ::com::sun::star::uno;
      51             : using namespace ::com::sun::star::lang;
      52             : using namespace ::com::sun::star::container;
      53             : using namespace ::com::sun::star::drawing;
      54             : 
      55             : #define INTERFACE_TYPE( xint ) \
      56             :     ::getCppuType((const Reference< xint >*)0)
      57             : 
      58             : /**********************************************************************
      59             : * class SvxDrawPage                                                   *
      60             : **********************************************************************/
      61             : 
      62      151764 : UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage );
      63             : DBG_NAME(SvxDrawPage)
      64        1524 : SvxDrawPage::SvxDrawPage( SdrPage* pInPage ) throw()
      65        1524 : : mrBHelper( getMutex() )
      66             : , mpPage( pInPage )
      67        3048 : , mpModel( 0 )
      68             : {
      69             :     DBG_CTOR(SvxDrawPage,NULL);
      70             :     // Am Broadcaster anmelden
      71        1524 :     if( mpPage )
      72        1524 :         mpModel = mpPage->GetModel();
      73        1524 :     if( mpModel )
      74        1524 :         StartListening( *mpModel );
      75             : 
      76             : 
      77             :     // Erzeugen der (hidden) ::com::sun::star::sdbcx::View
      78        1524 :     mpView = new SdrView( mpModel );
      79        1524 :     if( mpView )
      80        1524 :         mpView->SetDesignMode(sal_True);
      81        1524 : }
      82             : 
      83             : //----------------------------------------------------------------------
      84        3008 : SvxDrawPage::~SvxDrawPage() throw()
      85             : {
      86             :     DBG_ASSERT( mrBHelper.bDisposed, "SvxDrawPage must be disposed!" );
      87        1504 :     if( !mrBHelper.bDisposed )
      88             :     {
      89          15 :         acquire();
      90          15 :         dispose();
      91             :     }
      92             :     DBG_DTOR(SvxDrawPage,NULL);
      93        1504 : }
      94             : 
      95             : //----------------------------------------------------------------------
      96             : 
      97             : // XInterface
      98      223726 : void SvxDrawPage::release() throw()
      99             : {
     100      223726 :     OWeakAggObject::release();
     101      223726 : }
     102             : 
     103             : // XComponent
     104        1505 : void SvxDrawPage::disposing() throw()
     105             : {
     106        1505 :     if( mpModel )
     107             :     {
     108        1505 :         EndListening( *mpModel );
     109        1505 :         mpModel = NULL;
     110             :     }
     111             : 
     112        1505 :     if( mpView )
     113             :     {
     114        1505 :         delete mpView;
     115        1505 :         mpView = NULL;
     116             :     }
     117        1505 :     mpPage = 0;
     118        1505 : }
     119             : 
     120             : //----------------------------------------------------------------------
     121             : // XComponent
     122             : //----------------------------------------------------------------------
     123             : 
     124        2031 : void SvxDrawPage::dispose()
     125             :     throw(::com::sun::star::uno::RuntimeException)
     126             : {
     127        2031 :     SolarMutexGuard aSolarGuard;
     128             : 
     129             :     // An frequently programming error is to release the last
     130             :     // reference to this object in the disposing message.
     131             :     // Make it rubust, hold a self Reference.
     132        4062 :     uno::Reference< lang::XComponent > xSelf( this );
     133             : 
     134             :     // Guard dispose against multible threading
     135             :     // Remark: It is an error to call dispose more than once
     136        2031 :     bool bDoDispose = false;
     137             :     {
     138        2031 :     osl::MutexGuard aGuard( mrBHelper.rMutex );
     139        2031 :     if( !mrBHelper.bDisposed && !mrBHelper.bInDispose )
     140             :     {
     141             :         // only one call go into this section
     142        1505 :         mrBHelper.bInDispose = sal_True;
     143        1505 :         bDoDispose = true;
     144        2031 :     }
     145             :     }
     146             : 
     147             :     // Do not hold the mutex because we are broadcasting
     148        2031 :     if( bDoDispose )
     149             :     {
     150             :         // Create an event with this as sender
     151             :         try
     152             :         {
     153        1505 :             uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( (lang::XComponent *)this ) );
     154        3010 :             ::com::sun::star::document::EventObject aEvt;
     155        1505 :             aEvt.Source = xSource;
     156             :             // inform all listeners to release this object
     157             :             // The listener container are automaticly cleared
     158        1505 :             mrBHelper.aLC.disposeAndClear( aEvt );
     159             :             // notify subclasses to do their dispose
     160        3010 :             disposing();
     161             :         }
     162           0 :         catch(const ::com::sun::star::uno::Exception&)
     163             :         {
     164             :             // catch exception and throw again but signal that
     165             :             // the object was disposed. Dispose should be called
     166             :             // only once.
     167           0 :             mrBHelper.bDisposed = sal_True;
     168           0 :             mrBHelper.bInDispose = sal_False;
     169           0 :             throw;
     170             :         }
     171             : 
     172             :         // the values bDispose and bInDisposing must set in this order.
     173             :         // No multithread call overcome the "!rBHelper.bDisposed && !rBHelper.bInDispose" guard.
     174        1505 :         mrBHelper.bDisposed = sal_True;
     175        1505 :         mrBHelper.bInDispose = sal_False;
     176        2031 :     }
     177             : 
     178        2031 : }
     179             : 
     180             : //----------------------------------------------------------------------
     181             : 
     182          35 : void SAL_CALL SvxDrawPage::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException)
     183             : {
     184          35 :     SolarMutexGuard aGuard;
     185             : 
     186          35 :     if( mpModel == 0 )
     187           0 :         throw lang::DisposedException();
     188             : 
     189          35 :     mrBHelper.addListener( ::getCppuType( &aListener ) , aListener );
     190          35 : }
     191             : 
     192             : //----------------------------------------------------------------------
     193             : 
     194          35 : void SAL_CALL SvxDrawPage::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw(::com::sun::star::uno::RuntimeException)
     195             : {
     196          35 :     SolarMutexGuard aGuard;
     197             : 
     198          35 :     if( mpModel == 0 )
     199           0 :         throw lang::DisposedException();
     200             : 
     201          35 :     mrBHelper.removeListener( ::getCppuType( &aListener ) , aListener );
     202          35 : }
     203             : 
     204             : //----------------------------------------------------------------------
     205             : // SfxListener
     206             : //----------------------------------------------------------------------
     207             : 
     208       74728 : void SvxDrawPage::Notify( SfxBroadcaster&, const SfxHint& /*rHint*/ )
     209             : {
     210       74728 : }
     211             : 
     212             : //----------------------------------------------------------------------
     213             : // ::com::sun::star::drawing::XShapes
     214             : //----------------------------------------------------------------------
     215             : 
     216         864 : void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape )
     217             :     throw( uno::RuntimeException )
     218             : {
     219         864 :     SolarMutexGuard aGuard;
     220             : 
     221         864 :     if ( ( mpModel == NULL ) || ( mpPage == NULL ) )
     222           0 :         throw lang::DisposedException();
     223             : 
     224         864 :     SvxShape* pShape = SvxShape::getImplementation( xShape );
     225             : 
     226         864 :     if( NULL == pShape )
     227           0 :         return;
     228             : 
     229         864 :     SdrObject *pObj = pShape->GetSdrObject();
     230             : 
     231         864 :     if(!pObj)
     232             :     {
     233         602 :         pObj = CreateSdrObject( xShape );
     234         602 :         ENSURE_OR_RETURN_VOID( pObj != NULL, "SvxDrawPage::add: no SdrObject was created!" );
     235             :     }
     236         262 :     else if ( !pObj->IsInserted() )
     237             :     {
     238         262 :         pObj->SetModel(mpModel);
     239         262 :         mpPage->InsertObject( pObj );
     240             :     }
     241             : 
     242         864 :     pShape->Create( pObj, this );
     243             :     OSL_ENSURE( pShape->GetSdrObject() == pObj, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
     244             : 
     245         864 :     if ( !pObj->IsInserted() )
     246             :     {
     247           0 :         pObj->SetModel(mpModel);
     248           0 :         mpPage->InsertObject( pObj );
     249             :     }
     250             : 
     251         864 :     mpModel->SetChanged();
     252             : }
     253             : 
     254             : //----------------------------------------------------------------------
     255         211 : void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape )
     256             :     throw( uno::RuntimeException )
     257             : {
     258         211 :     SolarMutexGuard aGuard;
     259             : 
     260         211 :     if( (mpModel == 0) || (mpPage == 0) )
     261           0 :         throw lang::DisposedException();
     262             : 
     263         211 :     SvxShape* pShape = SvxShape::getImplementation( xShape );
     264             : 
     265         211 :     if(pShape)
     266             :     {
     267         211 :         SdrObject*  pObj = pShape->GetSdrObject();
     268         211 :         if(pObj)
     269             :         {
     270             :             // SdrObject aus der Page loeschen
     271         211 :             sal_uInt32 nCount = mpPage->GetObjCount();
     272         306 :             for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ )
     273             :             {
     274         306 :                 if(mpPage->GetObj(nNum) == pObj)
     275             :                 {
     276         211 :                     OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
     277         211 :                     SdrObject::Free( pObj );
     278         211 :                     break;
     279             :                 }
     280             :             }
     281             :         }
     282             :     }
     283             : 
     284         211 :     if( mpModel )
     285         211 :         mpModel->SetChanged();
     286         211 : }
     287             : 
     288             : //----------------------------------------------------------------------
     289             : // ::com::sun::star::container::XIndexAccess
     290             : //----------------------------------------------------------------------
     291             : 
     292        2832 : sal_Int32 SAL_CALL SvxDrawPage::getCount()
     293             :     throw( uno::RuntimeException )
     294             : {
     295        2832 :     SolarMutexGuard aGuard;
     296             : 
     297        2832 :     if( (mpModel == 0) || (mpPage == 0) )
     298           0 :         throw lang::DisposedException();
     299             : 
     300        2832 :     return( (sal_Int32) mpPage->GetObjCount() );
     301             : }
     302             : 
     303             : //----------------------------------------------------------------------
     304        2865 : uno::Any SAL_CALL SvxDrawPage::getByIndex( sal_Int32 Index )
     305             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     306             : {
     307        2865 :     SolarMutexGuard aGuard;
     308             : 
     309        2865 :     if( (mpModel == 0) || (mpPage == 0) )
     310           0 :         throw lang::DisposedException();
     311             : 
     312        2865 :     if ( Index < 0 || Index >= (sal_Int32)mpPage->GetObjCount() )
     313           6 :         throw lang::IndexOutOfBoundsException();
     314             : 
     315        2859 :     SdrObject* pObj = mpPage->GetObj( Index );
     316        2859 :     if( pObj == NULL )
     317           0 :         throw uno::RuntimeException();
     318             : 
     319             : 
     320        2859 :     return makeAny(Reference< drawing::XShape >( pObj->getUnoShape(), uno::UNO_QUERY ));
     321             : }
     322             : 
     323             : 
     324             : //----------------------------------------------------------------------
     325             : // ::com::sun::star::container::XElementAccess
     326             : //----------------------------------------------------------------------
     327             : 
     328           5 : uno::Type SAL_CALL SvxDrawPage::getElementType()
     329             :     throw( uno::RuntimeException )
     330             : {
     331           5 :     return INTERFACE_TYPE( drawing::XShape );
     332             : }
     333             : 
     334             : //----------------------------------------------------------------------
     335           6 : sal_Bool SAL_CALL SvxDrawPage::hasElements()
     336             :     throw( uno::RuntimeException )
     337             : {
     338           6 :     SolarMutexGuard aGuard;
     339             : 
     340           6 :     if( (mpModel == 0) || (mpPage == 0) )
     341           0 :         throw lang::DisposedException();
     342             : 
     343           6 :     return mpPage && mpPage->GetObjCount()>0;
     344             : }
     345             : 
     346             : namespace
     347             : {
     348          46 :     void lcl_markSdrObjectOfShape( const Reference< drawing::XShape >& _rxShape, SdrView& _rView, SdrPageView& _rPageView )
     349             :     {
     350          46 :         SvxShape* pShape = SvxShape::getImplementation( _rxShape );
     351          46 :         if ( !pShape )
     352           0 :             return;
     353             : 
     354          46 :         SdrObject* pObj = pShape->GetSdrObject();
     355          46 :         if ( !pObj )
     356           0 :             return;
     357             : 
     358          46 :         _rView.MarkObj( pObj, &_rPageView );
     359             :     }
     360             : }
     361             : 
     362             : //----------------------------------------------------------------------
     363             : // ACHTUNG: _SelectObjectsInView selektiert die ::com::sun::star::drawing::Shapes nur in der angegebennen
     364             : //         SdrPageView. Dies mu� nicht die sichtbare SdrPageView sein.
     365             : //----------------------------------------------------------------------
     366          11 : void SvxDrawPage::_SelectObjectsInView( const Reference< drawing::XShapes > & aShapes, SdrPageView* pPageView ) throw ()
     367             : {
     368             :     DBG_ASSERT(pPageView,"SdrPageView ist NULL! [CL]");
     369             :     DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
     370             : 
     371          11 :     if(pPageView!=NULL && mpView!=NULL)
     372             :     {
     373          11 :         mpView->UnmarkAllObj( pPageView );
     374             : 
     375          11 :         long nCount = aShapes->getCount();
     376          46 :         for( long i = 0; i < nCount; i++ )
     377             :         {
     378          35 :             uno::Any aAny( aShapes->getByIndex(i) );
     379          70 :             Reference< drawing::XShape > xShape;
     380          35 :             if( aAny >>= xShape )
     381          35 :                 lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView );
     382          35 :         }
     383             :     }
     384          11 : }
     385             : 
     386             : //----------------------------------------------------------------------
     387             : // ACHTUNG: _SelectObjectInView selektiert das Shape *nur* in der angegebennen
     388             : //         SdrPageView. Dies mu� nicht die sichtbare SdrPageView sein.
     389             : //----------------------------------------------------------------------
     390          11 : void SvxDrawPage::_SelectObjectInView( const Reference< drawing::XShape > & xShape, SdrPageView* pPageView ) throw()
     391             : {
     392             :     DBG_ASSERT(pPageView,"SdrPageView ist NULL! [CL]");
     393             :     DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
     394             : 
     395          11 :     if(pPageView!=NULL && mpView != NULL)
     396             :     {
     397          11 :         mpView->UnmarkAllObj( pPageView );
     398          11 :         lcl_markSdrObjectOfShape( xShape, *mpView, *pPageView );
     399             :     }
     400          11 : }
     401             : 
     402             : //----------------------------------------------------------------------
     403           5 : Reference< drawing::XShapeGroup > SAL_CALL SvxDrawPage::group( const Reference< drawing::XShapes >& xShapes )
     404             :     throw( uno::RuntimeException )
     405             : {
     406           5 :     SolarMutexGuard aGuard;
     407             : 
     408           5 :     if( (mpModel == 0) || (mpPage == 0) )
     409           0 :         throw lang::DisposedException();
     410             : 
     411             :     DBG_ASSERT(mpPage,"SdrPage ist NULL! [CL]");
     412             :     DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
     413             : 
     414           5 :     Reference< ::com::sun::star::drawing::XShapeGroup >  xShapeGroup;
     415           5 :     if(mpPage==NULL||mpView==NULL||!xShapes.is())
     416           0 :         return xShapeGroup;
     417             : 
     418           5 :     SdrPageView* pPageView = mpView->ShowSdrPage( mpPage );
     419             : 
     420           5 :     _SelectObjectsInView( xShapes, pPageView );
     421             : 
     422           5 :     mpView->GroupMarked();
     423             : 
     424           5 :     mpView->AdjustMarkHdl();
     425           5 :     const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
     426           5 :     if( rMarkList.GetMarkCount() == 1 )
     427             :     {
     428           5 :         SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
     429           5 :         if( pObj )
     430           5 :              xShapeGroup = Reference< drawing::XShapeGroup >::query( pObj->getUnoShape() );
     431             :     }
     432             : 
     433           5 :     mpView->HideSdrPage();
     434             : 
     435           5 :     if( mpModel )
     436           5 :         mpModel->SetChanged();
     437             : 
     438           5 :     return xShapeGroup;
     439             : }
     440             : 
     441             : //----------------------------------------------------------------------
     442           5 : void SAL_CALL SvxDrawPage::ungroup( const Reference< drawing::XShapeGroup >& aGroup )
     443             :     throw( uno::RuntimeException )
     444             : {
     445           5 :     SolarMutexGuard aGuard;
     446             : 
     447           5 :     if( (mpModel == 0) || (mpPage == 0) )
     448           0 :         throw lang::DisposedException();
     449             : 
     450             :     DBG_ASSERT(mpPage,"SdrPage ist NULL! [CL]");
     451             :     DBG_ASSERT(mpView, "SdrView ist NULL! [CL]");
     452             : 
     453           5 :     if(mpPage==NULL||mpView==NULL||!aGroup.is())
     454           5 :         return;
     455             : 
     456           5 :     SdrPageView* pPageView = mpView->ShowSdrPage( mpPage );
     457             : 
     458          10 :     Reference< drawing::XShape > xShape( aGroup, UNO_QUERY );
     459           5 :     _SelectObjectInView( xShape, pPageView );
     460           5 :     mpView->UnGroupMarked();
     461             : 
     462           5 :     mpView->HideSdrPage();
     463             : 
     464           5 :     if( mpModel )
     465          10 :         mpModel->SetChanged();
     466             : }
     467             : 
     468             : //----------------------------------------------------------------------
     469       47489 : SdrObject *SvxDrawPage::_CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
     470             : {
     471             :     sal_uInt16 nType;
     472             :     sal_uInt32 nInventor;
     473             : 
     474       47489 :     GetTypeAndInventor( nType, nInventor, xShape->getShapeType() );
     475       47489 :     SdrObject* pNewObj = 0;
     476             : 
     477       47489 :     if( nType != 0 )
     478             :     {
     479       47489 :         awt::Size aSize = xShape->getSize();
     480       47489 :         aSize.Width += 1;
     481       47489 :         aSize.Height += 1;
     482       47489 :         awt::Point aPos = xShape->getPosition();
     483       47489 :         Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
     484             : 
     485             :         // special cases
     486       47489 :         if( nInventor == SdrInventor )
     487             :         {
     488       45999 :             switch( nType )
     489             :             {
     490             :             case OBJ_MEASURE:
     491             :                 {
     492           1 :                     pNewObj = new SdrMeasureObj( aRect.TopLeft(), aRect.BottomRight() );
     493           1 :                     break;
     494             :                 }
     495             :             case OBJ_LINE:
     496             :                 {
     497         177 :                     basegfx::B2DPolygon aPoly;
     498         177 :                     aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
     499         177 :                     aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
     500         177 :                     pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
     501         177 :                     break;
     502             :                 }
     503             :             }
     504             :         }
     505             : 
     506       47489 :         if( pNewObj == NULL )
     507       47311 :             pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
     508             : 
     509       47489 :         if(pNewObj)
     510             :         {
     511       47489 :             pNewObj->SetSnapRect(aRect);
     512             : 
     513       47489 :             if( pNewObj->ISA(E3dPolyScene))
     514             :             {
     515             :                 // Szene initialisieren
     516         408 :                 E3dScene* pScene = (E3dScene*)pNewObj;
     517             : 
     518         408 :                 double fW = (double)aSize.Width;
     519         408 :                 double fH = (double)aSize.Height;
     520             : 
     521         408 :                 Camera3D aCam(pScene->GetCamera());
     522         408 :                 aCam.SetAutoAdjustProjection(sal_False);
     523         408 :                 aCam.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
     524         816 :                 basegfx::B3DPoint aLookAt;
     525         816 :                 basegfx::B3DPoint aCamPos(0.0, 0.0, 10000.0);
     526         408 :                 aCam.SetPosAndLookAt(aCamPos, aLookAt);
     527         408 :                 aCam.SetFocalLength(100.0);
     528         408 :                 aCam.SetDefaults(aCamPos, aLookAt, 10000.0);
     529         408 :                 pScene->SetCamera(aCam);
     530             : 
     531         816 :                 pScene->SetRectsDirty();
     532             :             }
     533       47081 :             else if(pNewObj->ISA(E3dExtrudeObj))
     534             :             {
     535         842 :                 E3dExtrudeObj* pObj = (E3dExtrudeObj*)pNewObj;
     536         842 :                 basegfx::B2DPolygon aNewPolygon;
     537         842 :                 aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
     538         842 :                 aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
     539         842 :                 aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
     540         842 :                 aNewPolygon.setClosed(true);
     541         842 :                 pObj->SetExtrudePolygon(basegfx::B2DPolyPolygon(aNewPolygon));
     542             : 
     543             :                 // #107245# pObj->SetExtrudeCharacterMode(sal_True);
     544         842 :                 pObj->SetMergedItem(Svx3DCharacterModeItem(sal_True));
     545             :             }
     546       46239 :             else if(pNewObj->ISA(E3dLatheObj))
     547             :             {
     548           0 :                 E3dLatheObj* pObj = (E3dLatheObj*)pNewObj;
     549           0 :                 basegfx::B2DPolygon aNewPolygon;
     550           0 :                 aNewPolygon.append(basegfx::B2DPoint(0.0, 0.0));
     551           0 :                 aNewPolygon.append(basegfx::B2DPoint(0.0, 1.0));
     552           0 :                 aNewPolygon.append(basegfx::B2DPoint(1.0, 0.0));
     553           0 :                 aNewPolygon.setClosed(true);
     554           0 :                 pObj->SetPolyPoly2D(basegfx::B2DPolyPolygon(aNewPolygon));
     555             : 
     556             :                 // #107245# pObj->SetLatheCharacterMode(sal_True);
     557           0 :                 pObj->SetMergedItem(Svx3DCharacterModeItem(sal_True));
     558             :             }
     559             :         }
     560             :     }
     561             : 
     562       47489 :     return pNewObj;
     563             : }
     564             : 
     565             : //----------------------------------------------------------------------
     566       47489 : void SvxDrawPage::GetTypeAndInventor( sal_uInt16& rType, sal_uInt32& rInventor, const OUString& aName ) const throw()
     567             : {
     568       47489 :     sal_uInt32 nTempType = UHashMap::getId( aName );
     569             : 
     570       47489 :     if( nTempType == UHASHMAP_NOTFOUND )
     571             :     {
     572           2 :         if( aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.drawing.TableShape")) ||
     573           0 :             aName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("com.sun.star.presentation.TableShape")) )
     574             :         {
     575           2 :             rInventor = SdrInventor;
     576           2 :             rType = OBJ_TABLE;
     577             :         }
     578           0 :         else if ( aName == "com.sun.star.presentation.MediaShape" )
     579             :         {
     580           0 :             rInventor = SdrInventor;
     581           0 :             rType = OBJ_MEDIA;
     582             :         }
     583             :     }
     584       47487 :     else if(nTempType & E3D_INVENTOR_FLAG)
     585             :     {
     586        1490 :         rInventor = E3dInventor;
     587        1490 :         rType = (sal_uInt16)(nTempType & ~E3D_INVENTOR_FLAG);
     588             :     }
     589             :     else
     590             :     {
     591       45997 :         rInventor = SdrInventor;
     592       45997 :         rType = (sal_uInt16)nTempType;
     593             : 
     594       45997 :         switch( rType )
     595             :         {
     596             :             case OBJ_FRAME:
     597             :             case OBJ_OLE2_PLUGIN:
     598             :             case OBJ_OLE2_APPLET:
     599           0 :                 rType = OBJ_OLE2;
     600           0 :                 break;
     601             :         }
     602             :     }
     603       47489 : }
     604             : 
     605             : //----------------------------------------------------------------------
     606       85652 : SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor, SdrObject *pObj, SvxDrawPage *mpPage ) throw()
     607             : {
     608       85652 :     SvxShape* pRet = NULL;
     609       85652 :     switch( nInventor )
     610             :     {
     611             :         case E3dInventor:
     612             :         {
     613        1504 :             switch( nType )
     614             :             {
     615             :                 case E3D_SCENE_ID :
     616             :                 case E3D_POLYSCENE_ID :
     617         417 :                     pRet = new Svx3DSceneObject( pObj, mpPage );
     618         417 :                     break;
     619             :                 case E3D_CUBEOBJ_ID :
     620           1 :                     pRet = new Svx3DCubeObject( pObj );
     621           1 :                     break;
     622             :                 case E3D_SPHEREOBJ_ID :
     623           1 :                     pRet = new Svx3DSphereObject( pObj );
     624           1 :                     break;
     625             :                 case E3D_LATHEOBJ_ID :
     626           1 :                     pRet = new Svx3DLatheObject( pObj );
     627           1 :                     break;
     628             :                 case E3D_EXTRUDEOBJ_ID :
     629         843 :                     pRet = new Svx3DExtrudeObject( pObj );
     630         843 :                     break;
     631             :                 case E3D_POLYGONOBJ_ID :
     632         241 :                     pRet = new Svx3DPolygonObject( pObj );
     633         241 :                     break;
     634             :                 default: // unbekanntes 3D-Objekt auf der Page
     635           0 :                     pRet = new SvxShape( pObj );
     636           0 :                     break;
     637             :             }
     638        1504 :             break;
     639             :         }
     640             :         case SdrInventor:
     641             :         {
     642       84148 :             switch( nType )
     643             :             {
     644             : //              case OBJ_NONE:
     645             : //                  break;
     646             :                 case OBJ_GRUP:
     647       30490 :                     pRet = new SvxShapeGroup( pObj, mpPage );
     648       30490 :                     break;
     649             :                 case OBJ_LINE:
     650        1526 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_LINE );
     651        1526 :                     break;
     652             :                 case OBJ_RECT:
     653       11559 :                     pRet = new SvxShapeRect( pObj );
     654       11559 :                     break;
     655             :                 case OBJ_CIRC:
     656             :                 case OBJ_SECT:
     657             :                 case OBJ_CARC:
     658             :                 case OBJ_CCUT:
     659          69 :                     pRet = new SvxShapeCircle( pObj );
     660          69 :                     break;
     661             :                 case OBJ_POLY:
     662       12205 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_POLY );
     663       12205 :                     break;
     664             :                 case OBJ_PLIN:
     665        5236 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PLIN );
     666        5236 :                     break;
     667             :                 case OBJ_SPLNLINE:
     668             :                 case OBJ_PATHLINE:
     669          56 :                     pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHLINE );
     670          56 :                     break;
     671             :                 case OBJ_SPLNFILL:
     672             :                 case OBJ_PATHFILL:
     673         246 :                     pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHFILL );
     674         246 :                     break;
     675             :                 case OBJ_FREELINE:
     676           1 :                     pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_FREELINE );
     677           1 :                     break;
     678             :                 case OBJ_FREEFILL:
     679           1 :                     pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_FREEFILL );
     680           1 :                     break;
     681             :                 case OBJ_CAPTION:
     682          10 :                     pRet = new SvxShapeCaption( pObj );
     683          10 :                     break;
     684             :                 case OBJ_TITLETEXT:
     685             :                 case OBJ_OUTLINETEXT:
     686             :                 case OBJ_TEXT:
     687       16583 :                     pRet = new SvxShapeText( pObj );
     688       16583 :                     break;
     689             :                 case OBJ_GRAF:
     690          76 :                     pRet = new SvxGraphicObject( pObj );
     691          76 :                     break;
     692             :                 case OBJ_FRAME:
     693           1 :                     pRet = new SvxFrameShape( pObj );
     694           1 :                     break;
     695             :                 case OBJ_OLE2_APPLET:
     696           1 :                     pRet = new SvxAppletShape( pObj );
     697           1 :                     break;
     698             :                 case OBJ_OLE2_PLUGIN:
     699           1 :                     pRet = new SvxPluginShape( pObj );
     700           1 :                     break;
     701             :                  case OBJ_OLE2:
     702             :                      {
     703          32 :                         if( pObj && !pObj->IsEmptyPresObj() && mpPage )
     704             :                         {
     705           3 :                             SdrPage* pSdrPage = mpPage->GetSdrPage();
     706           3 :                             if( pSdrPage )
     707             :                             {
     708           3 :                                 SdrModel* pSdrModel = pSdrPage->GetModel();
     709           3 :                                 if( pSdrModel )
     710             :                                 {
     711           3 :                                     ::comphelper::IEmbeddedHelper *pPersist = pSdrModel->GetPersist();
     712           3 :                                     if( pPersist )
     713             :                                     {
     714           3 :                                         uno::Reference < embed::XEmbeddedObject > xObject = pPersist->getEmbeddedObjectContainer().
     715           6 :                                                 GetEmbeddedObject( static_cast< SdrOle2Obj* >( pObj )->GetPersistName() );
     716             : 
     717             :                                         // TODO CL->KA: Why is this not working anymore?
     718           3 :                                         if( xObject.is() )
     719             :                                         {
     720           2 :                                             SvGlobalName aClassId( xObject->getClassID() );
     721             : 
     722           4 :                                             const SvGlobalName aAppletClassId( SO3_APPLET_CLASSID );
     723           4 :                                             const SvGlobalName aPluginClassId( SO3_PLUGIN_CLASSID );
     724           4 :                                             const SvGlobalName aIFrameClassId( SO3_IFRAME_CLASSID );
     725             : 
     726           2 :                                             if( aPluginClassId == aClassId )
     727             :                                             {
     728           0 :                                                 pRet = new SvxPluginShape( pObj );
     729           0 :                                                 nType = OBJ_OLE2_PLUGIN;
     730             :                                             }
     731           2 :                                             else if( aAppletClassId == aClassId )
     732             :                                             {
     733           0 :                                                 pRet = new SvxAppletShape( pObj );
     734           0 :                                                 nType = OBJ_OLE2_APPLET;
     735             :                                             }
     736           2 :                                             else if( aIFrameClassId == aClassId )
     737             :                                             {
     738           0 :                                                 pRet = new SvxFrameShape( pObj );
     739           0 :                                                 nType = OBJ_FRAME;
     740           2 :                                             }
     741           3 :                                         }
     742             :                                     }
     743             :                                 }
     744             :                             }
     745             :                         }
     746          32 :                         if( pRet == NULL )
     747             :                         {
     748          32 :                             SvxUnoPropertyMapProvider& rSvxMapProvider = getSvxMapProvider();
     749          32 :                             pRet = new SvxOle2Shape( pObj, rSvxMapProvider.GetMap(SVXMAP_OLE2),  rSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) );
     750             :                         }
     751             :                      }
     752          32 :                     break;
     753             :                 case OBJ_EDGE:
     754           7 :                     pRet = new SvxShapeConnector( pObj );
     755           7 :                     break;
     756             :                 case OBJ_PATHPOLY:
     757           1 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PATHPOLY );
     758           1 :                     break;
     759             :                 case OBJ_PATHPLIN:
     760           1 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PATHPLIN );
     761           1 :                     break;
     762             :                 case OBJ_PAGE:
     763             :                 {
     764         453 :                     SvxUnoPropertyMapProvider& rSvxMapProvider = getSvxMapProvider();
     765         453 :                     pRet = new SvxShape( pObj, rSvxMapProvider.GetMap(SVXMAP_PAGE),  rSvxMapProvider.GetPropertySet(SVXMAP_PAGE, SdrObject::GetGlobalDrawObjectItemPool()) );
     766             :                 }
     767         453 :                     break;
     768             :                 case OBJ_MEASURE:
     769           3 :                     pRet = new SvxShapeDimensioning( pObj );
     770           3 :                     break;
     771             : //              case OBJ_DUMMY:
     772             : //                  break;
     773             :                 case OBJ_UNO:
     774           0 :                     pRet = new SvxShapeControl( pObj );
     775           0 :                     break;
     776             :                 case OBJ_CUSTOMSHAPE:
     777        5579 :                     pRet = new SvxCustomShape( pObj );
     778        5579 :                     break;
     779             :                 case OBJ_MEDIA:
     780           1 :                     pRet = new SvxMediaShape( pObj );
     781           1 :                     break;
     782             :                 case OBJ_TABLE:
     783          10 :                     pRet = new SvxTableShape( pObj );
     784          10 :                     break;
     785             :                 default: // unbekanntes 2D-Objekt auf der Page
     786             :                     OSL_FAIL("Nicht implementierter Starone-Shape erzeugt! [CL]");
     787           0 :                     pRet = new SvxShapeText( pObj );
     788           0 :                     break;
     789             :             }
     790       84148 :             break;
     791             :         }
     792             :         default: // Unbekannter Inventor
     793             :         {
     794             :             OSL_FAIL("AW: Unknown Inventor in SvxDrawPage::_CreateShape()");
     795           0 :             break;
     796             :         }
     797             :     }
     798             : 
     799       85652 :     if(pRet)
     800             :     {
     801       85652 :         sal_uInt32 nObjId = nType;
     802             : 
     803       85652 :         if( nInventor == E3dInventor )
     804        1504 :             nObjId |= E3D_INVENTOR_FLAG;
     805             : 
     806       85652 :         switch(nObjId)
     807             :         {
     808             :         case OBJ_CCUT:          // Kreisabschnitt
     809             :         case OBJ_CARC:          // Kreisbogen
     810             :         case OBJ_SECT:          // Kreissektor
     811           0 :             nObjId = OBJ_CIRC;
     812           0 :             break;
     813             : 
     814             :         case E3D_SCENE_ID | E3D_INVENTOR_FLAG:
     815           0 :             nObjId = E3D_POLYSCENE_ID | E3D_INVENTOR_FLAG;
     816           0 :             break;
     817             : 
     818             :         case OBJ_TITLETEXT:
     819             :         case OBJ_OUTLINETEXT:
     820           0 :             nObjId = OBJ_TEXT;
     821           0 :             break;
     822             :         }
     823             : 
     824       85652 :         pRet->setShapeKind(nObjId);
     825             :     }
     826             : 
     827       85652 :     return pRet;
     828             : }
     829             : 
     830             : //----------------------------------------------------------------------
     831       34442 : Reference< drawing::XShape >  SvxDrawPage::_CreateShape( SdrObject *pObj ) const throw()
     832             : {
     833       34442 :     Reference< drawing::XShape > xShape( CreateShapeByTypeAndInventor(pObj->GetObjIdentifier(),
     834       34442 :                                               pObj->GetObjInventor(),
     835             :                                               pObj,
     836       68884 :                                               (SvxDrawPage*)this));
     837       34442 :     return xShape;
     838             : }
     839             : 
     840             : //----------------------------------------------------------------------
     841         602 : SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
     842             : {
     843         602 :     SdrObject* pObj = _CreateSdrObject( xShape );
     844         602 :     if( pObj)
     845             :     {
     846         602 :         pObj->SetModel(mpModel);
     847         602 :         if ( !pObj->IsInserted() && !pObj->IsDoNotInsertIntoPageAutomatically() )
     848         470 :             mpPage->InsertObject( pObj );
     849             :     }
     850             : 
     851         602 :     return pObj;
     852             : }
     853             : 
     854             : //----------------------------------------------------------------------
     855             : // ::com::sun::star::lang::XServiceInfo
     856             : //----------------------------------------------------------------------
     857           0 : OUString SAL_CALL SvxDrawPage::getImplementationName() throw( uno::RuntimeException )
     858             : {
     859           0 :     return OUString("SvxDrawPage");
     860             : }
     861             : 
     862          45 : sal_Bool SAL_CALL SvxDrawPage::supportsService( const OUString& ServiceName )
     863             :     throw(::com::sun::star::uno::RuntimeException)
     864             : {
     865          45 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     866             : }
     867             : 
     868          51 : uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException )
     869             : {
     870          51 :     uno::Sequence< OUString > aSeq( 1 );
     871          51 :     aSeq.getArray()[0] = OUString("com.sun.star.drawing.ShapeCollection" );
     872          51 :     return aSeq;
     873             : }
     874             : 
     875         134 : SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor ) throw()
     876             : {
     877         134 :     return SvxDrawPage::CreateShapeByTypeAndInventor( nType, nInventor );
     878             : }
     879             : 
     880           0 : void SvxDrawPage::ChangeModel( SdrModel* pNewModel )
     881             : {
     882           0 :     if( pNewModel != mpModel )
     883             :     {
     884           0 :         if( mpModel )
     885           0 :             EndListening( *mpModel );
     886             : 
     887           0 :         if( pNewModel )
     888           0 :             StartListening( *pNewModel );
     889             : 
     890           0 :         mpModel = pNewModel;
     891             : 
     892           0 :         if( mpView )
     893             :         {
     894           0 :             delete mpView;
     895           0 :             mpView = new SdrView( mpModel );
     896           0 :             if( mpView )
     897           0 :                 mpView->SetDesignMode(sal_True);
     898             :         }
     899             :     }
     900           0 : }
     901             : 
     902             : /** returns a StarOffice API wrapper for the given SdrPage */
     903       40740 : uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage( SdrPage* pPage ) throw ()
     904             : {
     905       40740 :     if(pPage)
     906             :     {
     907       40740 :         uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
     908             : 
     909       40740 :         return xDrawPage;
     910             :     }
     911             : 
     912           0 :     return uno::Reference< drawing::XDrawPage >();
     913             : }
     914             : 
     915             : /** returns the SdrObject from the given StarOffice API wrapper */
     916        9167 : SdrPage* GetSdrPageFromXDrawPage( uno::Reference< drawing::XDrawPage > xDrawPage ) throw()
     917             : {
     918        9167 :     if(xDrawPage.is())
     919             :     {
     920        2502 :         SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xDrawPage );
     921             : 
     922        2502 :         if(pDrawPage)
     923             :         {
     924        2502 :             return pDrawPage->GetSdrPage();
     925             :         }
     926             :     }
     927             : 
     928        6665 :     return NULL;
     929         258 : }
     930             : 
     931             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10