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