xref: /aoo41x/main/sd/source/ui/unoidl/unolayer.hxx (revision 67e470da)
1*c45d927aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*c45d927aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*c45d927aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*c45d927aSAndrew Rist  * distributed with this work for additional information
6*c45d927aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*c45d927aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*c45d927aSAndrew Rist  * "License"); you may not use this file except in compliance
9*c45d927aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*c45d927aSAndrew Rist  *
11*c45d927aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*c45d927aSAndrew Rist  *
13*c45d927aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*c45d927aSAndrew Rist  * software distributed under the License is distributed on an
15*c45d927aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*c45d927aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*c45d927aSAndrew Rist  * specific language governing permissions and limitations
18*c45d927aSAndrew Rist  * under the License.
19*c45d927aSAndrew Rist  *
20*c45d927aSAndrew Rist  *************************************************************/
21*c45d927aSAndrew Rist 
22*c45d927aSAndrew Rist 
23cdf0e10cSrcweir #ifndef SD_UNOLAYER_HXX
24cdf0e10cSrcweir #define SD_UNOLAYER_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
27cdf0e10cSrcweir #include <com/sun/star/drawing/XLayer.hpp>
28cdf0e10cSrcweir #include <com/sun/star/drawing/XLayerManager.hpp>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx>
31cdf0e10cSrcweir #include <comphelper/servicehelper.hxx>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <unomodel.hxx>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir class SdrLayer;
36cdf0e10cSrcweir class SdLayerManager;
37cdf0e10cSrcweir class SdXImpressDocument;
38cdf0e10cSrcweir class SvUnoWeakContainer;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir namespace sd {
41cdf0e10cSrcweir class View;
42cdf0e10cSrcweir }
43cdf0e10cSrcweir enum LayerAttribute { VISIBLE, PRINTABLE, LOCKED };
44cdf0e10cSrcweir 
45cdf0e10cSrcweir /***********************************************************************
46cdf0e10cSrcweir *                                                                      *
47cdf0e10cSrcweir ***********************************************************************/
48cdf0e10cSrcweir class SdLayer : public ::cppu::WeakImplHelper5< ::com::sun::star::drawing::XLayer,
49cdf0e10cSrcweir 												::com::sun::star::lang::XServiceInfo,
50cdf0e10cSrcweir                                                 ::com::sun::star::container::XChild,
51cdf0e10cSrcweir 												::com::sun::star::lang::XUnoTunnel,
52cdf0e10cSrcweir 												::com::sun::star::lang::XComponent >
53cdf0e10cSrcweir {
54cdf0e10cSrcweir public:
55cdf0e10cSrcweir 	SdLayer( SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_ ) throw();
56cdf0e10cSrcweir 	virtual ~SdLayer() throw();
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	// intern
GetSdrLayer() const59cdf0e10cSrcweir 	SdrLayer* GetSdrLayer() const throw() { return pLayer; }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	static String convertToInternalName( const ::rtl::OUString& rName );
62cdf0e10cSrcweir 	static ::rtl::OUString convertToExternalName( const String& rName );
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	// uno helper
65cdf0e10cSrcweir 	UNO3_GETIMPLEMENTATION_DECL( SdLayer )
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 	// XServiceInfo
68cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
69cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
70cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir 	// ::com::sun::star::beans::XPropertySet
73cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
74cdf0e10cSrcweir     virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
75cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
76cdf0e10cSrcweir     virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
77cdf0e10cSrcweir     virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
78cdf0e10cSrcweir     virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
79cdf0e10cSrcweir     virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     // ::com::sun::star::container::XChild
82cdf0e10cSrcweir 
83cdf0e10cSrcweir     /** Returns the layer manager that manages this layer.
84cdf0e10cSrcweir     */
85cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	// XComponent
88cdf0e10cSrcweir     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
89cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
90cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     /** Not implemented.  Allways throws an exception.
93cdf0e10cSrcweir         @raises NoSupportException.
94cdf0e10cSrcweir     */
95cdf0e10cSrcweir     virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& Parent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
96cdf0e10cSrcweir 
97cdf0e10cSrcweir private:
98cdf0e10cSrcweir 	SdLayerManager*		pLayerManager;
99cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayerManager > mxLayerManager;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	SdrLayer*			pLayer;
102cdf0e10cSrcweir 	const SvxItemPropertySet*	pPropSet;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	sal_Bool get( LayerAttribute what ) throw();
105cdf0e10cSrcweir 	void set( LayerAttribute what, sal_Bool flag ) throw();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir };
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 
112cdf0e10cSrcweir /***********************************************************************
113cdf0e10cSrcweir *                                                                      *
114cdf0e10cSrcweir ***********************************************************************/
115cdf0e10cSrcweir 
116cdf0e10cSrcweir //#include <cppuhelper/implbase4.hxx>
117cdf0e10cSrcweir 
118cdf0e10cSrcweir class SdLayerManager : public ::cppu::WeakImplHelper5< ::com::sun::star::drawing::XLayerManager,
119cdf0e10cSrcweir 													   ::com::sun::star::container::XNameAccess,
120cdf0e10cSrcweir 													   ::com::sun::star::lang::XServiceInfo,
121cdf0e10cSrcweir 													   ::com::sun::star::lang::XUnoTunnel,
122cdf0e10cSrcweir 													   ::com::sun::star::lang::XComponent >
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	friend class SdLayer;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir public:
127cdf0e10cSrcweir 	SdLayerManager( SdXImpressDocument& rMyModel ) throw();
128cdf0e10cSrcweir 	virtual ~SdLayerManager() throw();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	// uno helper
131cdf0e10cSrcweir 	UNO3_GETIMPLEMENTATION_DECL( SdLayerManager )
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	// XServiceInfo
134cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
136cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 	// XLayerManager
139cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException);
140cdf0e10cSrcweir     virtual void SAL_CALL remove( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer >& xLayer ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
141cdf0e10cSrcweir     virtual void SAL_CALL attachShapeToLayer( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape, const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer >& xLayer ) throw(::com::sun::star::uno::RuntimeException);
142cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL getLayerForShape( const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& xShape ) throw(::com::sun::star::uno::RuntimeException);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	// XIndexAccess
145cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException) ;
146cdf0e10cSrcweir     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);
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	// XNameAccess
149cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
150cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException);
151cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	// XElementAccess
154cdf0e10cSrcweir     virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir     virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     /** Return the <type>XLayer</type> object that is associated with the
158cdf0e10cSrcweir         given <type>SdrLayer</type> object.  If the requested object does
159cdf0e10cSrcweir         not yet exist it is created.  All calls with the same argument
160cdf0e10cSrcweir         return the same object.
161cdf0e10cSrcweir         @param pLayer
162cdf0e10cSrcweir             The <type>SdrLayer</type> object for which to return the
163cdf0e10cSrcweir             associated <type>XLayer</type> object.
164cdf0e10cSrcweir         @return
165cdf0e10cSrcweir             The returned value is the unique <type>XLayer</type> object
166cdf0e10cSrcweir             associated with the specified argument.  If no layer can be
167cdf0e10cSrcweir             created for the argument than an empty reference is returned.
168cdf0e10cSrcweir     */
169cdf0e10cSrcweir     ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer> GetLayer (SdrLayer* pLayer);
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	// XComponent
172cdf0e10cSrcweir     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
174cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
175cdf0e10cSrcweir 
176cdf0e10cSrcweir private:
177cdf0e10cSrcweir 	SdXImpressDocument* mpModel;
178cdf0e10cSrcweir 	SvUnoWeakContainer*	mpLayers;
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	::sd::View* GetView() const throw();
GetDocShell() const181cdf0e10cSrcweir 	::sd::DrawDocShell*	GetDocShell() const throw() { return mpModel->mpDocShell; }
182cdf0e10cSrcweir 	void UpdateLayerView( sal_Bool modify = sal_True ) const throw();
183cdf0e10cSrcweir };
184cdf0e10cSrcweir 
185cdf0e10cSrcweir #endif
186