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

Generated by: LCOV version 1.10