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