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