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