1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unolayer.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef SD_UNOLAYER_HXX
31 #define SD_UNOLAYER_HXX
33 #include <com/sun/star/container/XIndexAccess.hpp>
34 #include <com/sun/star/drawing/XLayer.hpp>
35 #include <com/sun/star/drawing/XLayerManager.hpp>
37 #include <cppuhelper/implbase5.hxx>
38 #include <comphelper/servicehelper.hxx>
40 #include <unomodel.hxx>
44 class SdXImpressDocument
;
45 class SvUnoWeakContainer
;
50 enum LayerAttribute
{ VISIBLE
, PRINTABLE
, LOCKED
};
52 /***********************************************************************
54 ***********************************************************************/
55 class SdLayer
: public ::cppu::WeakImplHelper5
< ::com::sun::star::drawing::XLayer
,
56 ::com::sun::star::lang::XServiceInfo
,
57 ::com::sun::star::container::XChild
,
58 ::com::sun::star::lang::XUnoTunnel
,
59 ::com::sun::star::lang::XComponent
>
62 SdLayer( SdLayerManager
* pLayerManager_
, SdrLayer
* pSdrLayer_
) throw();
63 virtual ~SdLayer() throw();
66 SdrLayer
* GetSdrLayer() const throw() { return pLayer
; }
68 static String
convertToInternalName( const ::rtl::OUString
& rName
);
69 static ::rtl::OUString
convertToExternalName( const String
& rName
);
72 UNO3_GETIMPLEMENTATION_DECL( SdLayer
)
75 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
);
76 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
77 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
79 // ::com::sun::star::beans::XPropertySet
80 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
);
81 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
);
82 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
);
83 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
);
84 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
);
85 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
);
86 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
);
88 // ::com::sun::star::container::XChild
90 /** Returns the layer manager that manages this layer.
92 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getParent( ) throw (::com::sun::star::uno::RuntimeException
);
95 virtual void SAL_CALL
dispose( ) throw (::com::sun::star::uno::RuntimeException
);
96 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
97 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
99 /** Not implemented. Allways throws an exception.
100 @raises NoSupportException.
102 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
);
105 SdLayerManager
* pLayerManager
;
106 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XLayerManager
> mxLayerManager
;
109 const SvxItemPropertySet
* pPropSet
;
111 sal_Bool
get( LayerAttribute what
) throw();
112 void set( LayerAttribute what
, sal_Bool flag
) throw();
119 /***********************************************************************
121 ***********************************************************************/
123 //#include <cppuhelper/implbase4.hxx>
125 class SdLayerManager
: public ::cppu::WeakImplHelper5
< ::com::sun::star::drawing::XLayerManager
,
126 ::com::sun::star::container::XNameAccess
,
127 ::com::sun::star::lang::XServiceInfo
,
128 ::com::sun::star::lang::XUnoTunnel
,
129 ::com::sun::star::lang::XComponent
>
131 friend class SdLayer
;
134 SdLayerManager( SdXImpressDocument
& rMyModel
) throw();
135 virtual ~SdLayerManager() throw();
138 UNO3_GETIMPLEMENTATION_DECL( SdLayerManager
)
141 virtual ::rtl::OUString SAL_CALL
getImplementationName() throw(::com::sun::star::uno::RuntimeException
);
142 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
143 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException
);
146 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XLayer
> SAL_CALL
insertNewByIndex( sal_Int32 nIndex
) throw(::com::sun::star::uno::RuntimeException
);
147 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
);
148 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
);
149 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
);
152 virtual sal_Int32 SAL_CALL
getCount() throw(::com::sun::star::uno::RuntimeException
) ;
153 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
);
156 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
);
157 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames() throw(::com::sun::star::uno::RuntimeException
);
158 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
);
161 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType() throw(::com::sun::star::uno::RuntimeException
);
162 virtual sal_Bool SAL_CALL
hasElements() throw(::com::sun::star::uno::RuntimeException
);
164 /** Return the <type>XLayer</type> object that is associated with the
165 given <type>SdrLayer</type> object. If the requested object does
166 not yet exist it is created. All calls with the same argument
167 return the same object.
169 The <type>SdrLayer</type> object for which to return the
170 associated <type>XLayer</type> object.
172 The returned value is the unique <type>XLayer</type> object
173 associated with the specified argument. If no layer can be
174 created for the argument than an empty reference is returned.
176 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XLayer
> GetLayer (SdrLayer
* pLayer
);
179 virtual void SAL_CALL
dispose( ) throw (::com::sun::star::uno::RuntimeException
);
180 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
184 SdXImpressDocument
* mpModel
;
185 SvUnoWeakContainer
* mpLayers
;
187 ::sd::View
* GetView() const throw();
188 ::sd::DrawDocShell
* GetDocShell() const throw() { return mpModel
->mpDocShell
; }
189 void UpdateLayerView( sal_Bool modify
= sal_True
) const throw();