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-17 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       27710 : UNO3_GETIMPLEMENTATION_IMPL( SvxDrawPage );
      64             : DBG_NAME(SvxDrawPage)
      65         792 : SvxDrawPage::SvxDrawPage( SdrPage* pInPage ) throw()
      66         792 : : mrBHelper( getMutex() )
      67             : , mpPage( pInPage )
      68        1584 : , mpModel( 0 )
      69             : {
      70             :     DBG_CTOR(SvxDrawPage,NULL);
      71             :     // Am Broadcaster anmelden
      72         792 :     if( mpPage )
      73         792 :         mpModel = mpPage->GetModel();
      74         792 :     if( mpModel )
      75         792 :         StartListening( *mpModel );
      76             : 
      77             : 
      78             :     // Erzeugen der (hidden) ::com::sun::star::sdbcx::View
      79         792 :     mpView = new SdrView( mpModel );
      80         792 :     if( mpView )
      81         792 :         mpView->SetDesignMode(sal_True);
      82         792 : }
      83             : 
      84             : //----------------------------------------------------------------------
      85         732 : SvxDrawPage::~SvxDrawPage() throw()
      86             : {
      87             :     DBG_ASSERT( mrBHelper.bDisposed, "SvxDrawPage must be disposed!" );
      88         366 :     if( !mrBHelper.bDisposed )
      89             :     {
      90           4 :         acquire();
      91           4 :         dispose();
      92             :     }
      93             :     DBG_DTOR(SvxDrawPage,NULL);
      94         366 : }
      95             : 
      96             : //----------------------------------------------------------------------
      97             : 
      98             : // XInterface
      99       38314 : void SvxDrawPage::release() throw()
     100             : {
     101       38314 :     OWeakAggObject::release();
     102       38314 : }
     103             : 
     104             : // XComponent
     105         366 : void SvxDrawPage::disposing() throw()
     106             : {
     107         366 :     if( mpModel )
     108             :     {
     109         366 :         EndListening( *mpModel );
     110         366 :         mpModel = NULL;
     111             :     }
     112             : 
     113         366 :     if( mpView )
     114             :     {
     115         366 :         delete mpView;
     116         366 :         mpView = NULL;
     117             :     }
     118         366 :     mpPage = 0;
     119         366 : }
     120             : 
     121             : //----------------------------------------------------------------------
     122             : // XComponent
     123             : //----------------------------------------------------------------------
     124             : 
     125         418 : void SvxDrawPage::dispose()
     126             :     throw(::com::sun::star::uno::RuntimeException)
     127             : {
     128         418 :     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         418 :     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         418 :     sal_Bool bDoDispose = sal_False;
     138             :     {
     139         418 :     osl::MutexGuard aGuard( mrBHelper.rMutex );
     140         418 :     if( !mrBHelper.bDisposed && !mrBHelper.bInDispose )
     141             :     {
     142             :         // only one call go into this section
     143         366 :         mrBHelper.bInDispose = sal_True;
     144         366 :         bDoDispose = sal_True;
     145         418 :     }
     146             :     }
     147             : 
     148             :     // Do not hold the mutex because we are broadcasting
     149         418 :     if( bDoDispose )
     150             :     {
     151             :         // Create an event with this as sender
     152             :         try
     153             :         {
     154         366 :             uno::Reference< uno::XInterface > xSource( uno::Reference< uno::XInterface >::query( (lang::XComponent *)this ) );
     155         366 :             ::com::sun::star::document::EventObject aEvt;
     156         366 :             aEvt.Source = xSource;
     157             :             // inform all listeners to release this object
     158             :             // The listener container are automaticly cleared
     159         366 :             mrBHelper.aLC.disposeAndClear( aEvt );
     160             :             // notify subclasses to do their dispose
     161         366 :             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         366 :         mrBHelper.bDisposed = sal_True;
     176         366 :         mrBHelper.bInDispose = sal_False;
     177         418 :     }
     178             : 
     179         418 : }
     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       28556 : void SvxDrawPage::Notify( SfxBroadcaster&, const SfxHint& /*rHint*/ )
     210             : {
     211       28556 : }
     212             : 
     213             : //----------------------------------------------------------------------
     214             : // ::com::sun::star::drawing::XShapes
     215             : //----------------------------------------------------------------------
     216             : 
     217         502 : void SAL_CALL SvxDrawPage::add( const uno::Reference< drawing::XShape >& xShape )
     218             :     throw( uno::RuntimeException )
     219             : {
     220         502 :     SolarMutexGuard aGuard;
     221             : 
     222         502 :     if ( ( mpModel == NULL ) || ( mpPage == NULL ) )
     223           0 :         throw lang::DisposedException();
     224             : 
     225         502 :     SvxShape* pShape = SvxShape::getImplementation( xShape );
     226             : 
     227         502 :     if( NULL == pShape )
     228             :         return;
     229             : 
     230         502 :     SdrObject *pObj = pShape->GetSdrObject();
     231             : 
     232         502 :     if(!pObj)
     233             :     {
     234         494 :         pObj = CreateSdrObject( xShape );
     235         494 :         ENSURE_OR_RETURN_VOID( pObj != NULL, "SvxDrawPage::add: no SdrObject was created!" );
     236             :     }
     237           8 :     else if ( !pObj->IsInserted() )
     238             :     {
     239           8 :         pObj->SetModel(mpModel);
     240           8 :         mpPage->InsertObject( pObj );
     241             :     }
     242             : 
     243         502 :     pShape->Create( pObj, this );
     244             :     OSL_ENSURE( pShape->GetSdrObject() == pObj, "SvxDrawPage::add: shape does not know about its newly created SdrObject!" );
     245             : 
     246         502 :     mpModel->SetChanged();
     247             : }
     248             : 
     249             : //----------------------------------------------------------------------
     250         178 : void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape )
     251             :     throw( uno::RuntimeException )
     252             : {
     253         178 :     SolarMutexGuard aGuard;
     254             : 
     255         178 :     if( (mpModel == 0) || (mpPage == 0) )
     256           0 :         throw lang::DisposedException();
     257             : 
     258         178 :     SvxShape* pShape = SvxShape::getImplementation( xShape );
     259             : 
     260         178 :     if(pShape)
     261             :     {
     262         178 :         SdrObject*  pObj = pShape->GetSdrObject();
     263         178 :         if(pObj)
     264             :         {
     265             :             // SdrObject aus der Page loeschen
     266         178 :             sal_uInt32 nCount = mpPage->GetObjCount();
     267         178 :             for( sal_uInt32 nNum = 0; nNum < nCount; nNum++ )
     268             :             {
     269         178 :                 if(mpPage->GetObj(nNum) == pObj)
     270             :                 {
     271         178 :                     OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj );
     272         178 :                     SdrObject::Free( pObj );
     273         178 :                     break;
     274             :                 }
     275             :             }
     276             :         }
     277             :     }
     278             : 
     279         178 :     if( mpModel )
     280         178 :         mpModel->SetChanged();
     281         178 : }
     282             : 
     283             : //----------------------------------------------------------------------
     284             : // ::com::sun::star::container::XIndexAccess
     285             : //----------------------------------------------------------------------
     286             : 
     287        1171 : sal_Int32 SAL_CALL SvxDrawPage::getCount()
     288             :     throw( uno::RuntimeException )
     289             : {
     290        1171 :     SolarMutexGuard aGuard;
     291             : 
     292        1171 :     if( (mpModel == 0) || (mpPage == 0) )
     293           0 :         throw lang::DisposedException();
     294             : 
     295        1171 :     return( (sal_Int32) mpPage->GetObjCount() );
     296             : }
     297             : 
     298             : //----------------------------------------------------------------------
     299        1032 : uno::Any SAL_CALL SvxDrawPage::getByIndex( sal_Int32 Index )
     300             :     throw( lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException)
     301             : {
     302        1032 :     SolarMutexGuard aGuard;
     303             : 
     304        1032 :     if( (mpModel == 0) || (mpPage == 0) )
     305           0 :         throw lang::DisposedException();
     306             : 
     307        1032 :     if ( Index < 0 || Index >= (sal_Int32)mpPage->GetObjCount() )
     308           0 :         throw lang::IndexOutOfBoundsException();
     309             : 
     310        1032 :     SdrObject* pObj = mpPage->GetObj( Index );
     311        1032 :     if( pObj == NULL )
     312           0 :         throw uno::RuntimeException();
     313             : 
     314             : 
     315        1032 :     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        6970 : SdrObject *SvxDrawPage::_CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
     465             : {
     466             :     sal_uInt16 nType;
     467             :     sal_uInt32 nInventor;
     468             : 
     469        6970 :     GetTypeAndInventor( nType, nInventor, xShape->getShapeType() );
     470        6970 :     SdrObject* pNewObj = 0;
     471             : 
     472        6970 :     if( nType != 0 )
     473             :     {
     474        6970 :         awt::Size aSize = xShape->getSize();
     475        6970 :         aSize.Width += 1;
     476        6970 :         aSize.Height += 1;
     477        6970 :         awt::Point aPos = xShape->getPosition();
     478        6970 :         Rectangle aRect( Point( aPos.X, aPos.Y ), Size( aSize.Width, aSize.Height ) );
     479             : 
     480             :         // special cases
     481        6970 :         if( nInventor == SdrInventor )
     482             :         {
     483        6970 :             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           8 :                     basegfx::B2DPolygon aPoly;
     493           8 :                     aPoly.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
     494           8 :                     aPoly.append(basegfx::B2DPoint(aRect.Right(), aRect.Bottom()));
     495           8 :                     pNewObj = new SdrPathObj(OBJ_LINE, basegfx::B2DPolyPolygon(aPoly));
     496           8 :                     break;
     497             :                 }
     498             :             }
     499             :         }
     500             : 
     501        6970 :         if( pNewObj == NULL )
     502        6962 :             pNewObj = SdrObjFactory::MakeNewObject( nInventor, nType, mpPage );
     503             : 
     504        6970 :         if(pNewObj)
     505             :         {
     506        6970 :             pNewObj->SetSnapRect(aRect);
     507             : 
     508        6970 :             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        6970 :             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        6970 :             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        6970 :     return pNewObj;
     558             : }
     559             : 
     560             : //----------------------------------------------------------------------
     561        6970 : void SvxDrawPage::GetTypeAndInventor( sal_uInt16& rType, sal_uInt32& rInventor, const OUString& aName ) const throw()
     562             : {
     563        6970 :     sal_uInt32 nTempType = UHashMap::getId( aName );
     564             : 
     565        6970 :     if( nTempType == UHASHMAP_NOTFOUND )
     566             :     {
     567           4 :         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           4 :             rInventor = SdrInventor;
     571           4 :             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        6966 :     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        6966 :         rInventor = SdrInventor;
     587        6966 :         rType = (sal_uInt16)nTempType;
     588             : 
     589        6966 :         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        6970 : }
     599             : 
     600             : //----------------------------------------------------------------------
     601       20410 : SvxShape* SvxDrawPage::CreateShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor, SdrObject *pObj, SvxDrawPage *mpPage ) throw()
     602             : {
     603       20410 :     SvxShape* pRet = NULL;
     604       20410 :     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       20410 :             switch( nType )
     638             :             {
     639             : //              case OBJ_NONE:
     640             : //                  break;
     641             :                 case OBJ_GRUP:
     642        4276 :                     pRet = new SvxShapeGroup( pObj, mpPage );
     643        4276 :                     break;
     644             :                 case OBJ_LINE:
     645         182 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_LINE );
     646         182 :                     break;
     647             :                 case OBJ_RECT:
     648        1666 :                     pRet = new SvxShapeRect( pObj );
     649        1666 :                     break;
     650             :                 case OBJ_CIRC:
     651             :                 case OBJ_SECT:
     652             :                 case OBJ_CARC:
     653             :                 case OBJ_CCUT:
     654           6 :                     pRet = new SvxShapeCircle( pObj );
     655           6 :                     break;
     656             :                 case OBJ_POLY:
     657        1982 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_POLY );
     658        1982 :                     break;
     659             :                 case OBJ_PLIN:
     660         838 :                     pRet = new SvxShapePolyPolygon( pObj , PolygonKind_PLIN );
     661         838 :                     break;
     662             :                 case OBJ_SPLNLINE:
     663             :                 case OBJ_PATHLINE:
     664          12 :                     pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHLINE );
     665          12 :                     break;
     666             :                 case OBJ_SPLNFILL:
     667             :                 case OBJ_PATHFILL:
     668           8 :                     pRet = new SvxShapePolyPolygonBezier( pObj , PolygonKind_PATHFILL );
     669           8 :                     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           4 :                     pRet = new SvxShapeCaption( pObj );
     678           4 :                     break;
     679             :                 case OBJ_TITLETEXT:
     680             :                 case OBJ_OUTLINETEXT:
     681             :                 case OBJ_TEXT:
     682        2214 :                     pRet = new SvxShapeText( pObj );
     683        2214 :                     break;
     684             :                 case OBJ_GRAF:
     685          74 :                     pRet = new SvxGraphicObject( pObj );
     686          74 :                     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          10 :                         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          10 :                         if( pRet == NULL )
     742             :                         {
     743          10 :                             SvxUnoPropertyMapProvider& rSvxMapProvider = getSvxMapProvider();
     744          10 :                             pRet = new SvxOle2Shape( pObj, rSvxMapProvider.GetMap(SVXMAP_OLE2),  rSvxMapProvider.GetPropertySet(SVXMAP_OLE2, SdrObject::GetGlobalDrawObjectItemPool()) );
     745             :                         }
     746             :                      }
     747          10 :                     break;
     748             :                 case OBJ_EDGE:
     749           8 :                     pRet = new SvxShapeConnector( pObj );
     750           8 :                     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          62 :                     SvxUnoPropertyMapProvider& rSvxMapProvider = getSvxMapProvider();
     760          62 :                     pRet = new SvxShape( pObj, rSvxMapProvider.GetMap(SVXMAP_PAGE),  rSvxMapProvider.GetPropertySet(SVXMAP_PAGE, SdrObject::GetGlobalDrawObjectItemPool()) );
     761             :                 }
     762          62 :                     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        9060 :                     pRet = new SvxCustomShape( pObj );
     773        9060 :                     break;
     774             :                 case OBJ_MEDIA:
     775           0 :                     pRet = new SvxMediaShape( pObj );
     776           0 :                     break;
     777             :                 case OBJ_TABLE:
     778           8 :                     pRet = new SvxTableShape( pObj );
     779           8 :                     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       20410 :             break;
     786             :         }
     787             :         default: // Unbekannter Inventor
     788             :         {
     789             :             OSL_FAIL("AW: Unknown Inventor in SvxDrawPage::_CreateShape()");
     790           0 :             break;
     791             :         }
     792             :     }
     793             : 
     794       20410 :     if(pRet)
     795             :     {
     796       20410 :         sal_uInt32 nObjId = nType;
     797             : 
     798       20410 :         if( nInventor == E3dInventor )
     799           0 :             nObjId |= E3D_INVENTOR_FLAG;
     800             : 
     801       20410 :         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       20410 :         pRet->setShapeKind(nObjId);
     820             :     }
     821             : 
     822       20410 :     return pRet;
     823             : }
     824             : 
     825             : //----------------------------------------------------------------------
     826        6544 : Reference< drawing::XShape >  SvxDrawPage::_CreateShape( SdrObject *pObj ) const throw()
     827             : {
     828        6544 :     Reference< drawing::XShape > xShape( CreateShapeByTypeAndInventor(pObj->GetObjIdentifier(),
     829        6544 :                                               pObj->GetObjInventor(),
     830             :                                               pObj,
     831       13088 :                                               (SvxDrawPage*)this));
     832        6544 :     return xShape;
     833             : }
     834             : 
     835             : //----------------------------------------------------------------------
     836         494 : SdrObject *SvxDrawPage::CreateSdrObject( const Reference< drawing::XShape > & xShape ) throw()
     837             : {
     838         494 :     SdrObject* pObj = _CreateSdrObject( xShape );
     839         494 :     if( pObj && !pObj->IsInserted() )
     840         384 :         mpPage->InsertObject( pObj );
     841             : 
     842         494 :     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          30 : sal_Bool SAL_CALL SvxDrawPage::supportsService( const OUString& ServiceName )
     854             :     throw(::com::sun::star::uno::RuntimeException)
     855             : {
     856          30 :     return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() );
     857             : }
     858             : 
     859          30 : uno::Sequence< OUString > SAL_CALL SvxDrawPage::getSupportedServiceNames() throw( uno::RuntimeException )
     860             : {
     861          30 :     uno::Sequence< OUString > aSeq( 1 );
     862          30 :     aSeq.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ShapeCollection" ));
     863          30 :     return aSeq;
     864             : }
     865             : 
     866         114 : SvxShape* CreateSvxShapeByTypeAndInventor( sal_uInt16 nType, sal_uInt32 nInventor ) throw()
     867             : {
     868         114 :     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        4465 : uno::Reference< drawing::XDrawPage > GetXDrawPageForSdrPage( SdrPage* pPage ) throw ()
     895             : {
     896        4465 :     if(pPage)
     897             :     {
     898        4465 :         uno::Reference< drawing::XDrawPage > xDrawPage( pPage->getUnoPage(), uno::UNO_QUERY );
     899             : 
     900        4465 :         return xDrawPage;
     901             :     }
     902             : 
     903           0 :     return uno::Reference< drawing::XDrawPage >();
     904             : }
     905             : 
     906             : /** returns the SdrObject from the given StarOffice API wrapper */
     907         282 : SdrPage* GetSdrPageFromXDrawPage( uno::Reference< drawing::XDrawPage > xDrawPage ) throw()
     908             : {
     909         282 :     if(xDrawPage.is())
     910             :     {
     911          78 :         SvxDrawPage* pDrawPage = SvxDrawPage::getImplementation( xDrawPage );
     912             : 
     913          78 :         if(pDrawPage)
     914             :         {
     915          78 :             return pDrawPage->GetSdrPage();
     916             :         }
     917             :     }
     918             : 
     919         204 :     return NULL;
     920             : }
     921             : 
     922             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10