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 INCLUDED_SD_SOURCE_UI_UNOIDL_UNOLAYER_HXX
20 : #define INCLUDED_SD_SOURCE_UI_UNOIDL_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 OUString convertToInternalName( const OUString& rName );
58 : static OUString convertToExternalName( const OUString& rName );
59 :
60 : // uno helper
61 : UNO3_GETIMPLEMENTATION_DECL( SdLayer )
62 :
63 : // XServiceInfo
64 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
65 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
66 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
70 : virtual void SAL_CALL setPropertyValue( const 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, std::exception) SAL_OVERRIDE;
71 : virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 : virtual void SAL_CALL addPropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
73 : virtual void SAL_CALL removePropertyChangeListener( const 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, std::exception) SAL_OVERRIDE;
74 : virtual void SAL_CALL addVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
75 : virtual void SAL_CALL removeVetoableChangeListener( const 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, std::exception) SAL_OVERRIDE;
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, std::exception) SAL_OVERRIDE;
82 :
83 : // XComponent
84 : virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
85 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
87 :
88 : /** Not implemented. Always 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, std::exception) SAL_OVERRIDE;
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 : bool get( LayerAttribute what ) throw();
101 : void set( LayerAttribute what, bool flag ) throw();
102 :
103 : };
104 :
105 : /***********************************************************************
106 : * *
107 : ***********************************************************************/
108 :
109 : class SdLayerManager : public ::cppu::WeakImplHelper5< ::com::sun::star::drawing::XLayerManager,
110 : ::com::sun::star::container::XNameAccess,
111 : ::com::sun::star::lang::XServiceInfo,
112 : ::com::sun::star::lang::XUnoTunnel,
113 : ::com::sun::star::lang::XComponent >
114 : {
115 : friend class SdLayer;
116 :
117 : public:
118 : SdLayerManager( SdXImpressDocument& rMyModel ) throw();
119 : virtual ~SdLayerManager() throw();
120 :
121 : // uno helper
122 : UNO3_GETIMPLEMENTATION_DECL( SdLayerManager )
123 :
124 : // XServiceInfo
125 : virtual OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
126 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
127 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
128 :
129 : // XLayerManager
130 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer > SAL_CALL insertNewByIndex( sal_Int32 nIndex ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
131 : 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, std::exception) SAL_OVERRIDE;
132 : 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, std::exception) SAL_OVERRIDE;
133 : 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, std::exception) SAL_OVERRIDE;
134 :
135 : // XIndexAccess
136 : virtual sal_Int32 SAL_CALL getCount() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE ;
137 : 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, std::exception) SAL_OVERRIDE;
138 :
139 : // XNameAccess
140 : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
141 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 : virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
143 :
144 : // XElementAccess
145 : virtual ::com::sun::star::uno::Type SAL_CALL getElementType() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : virtual sal_Bool SAL_CALL hasElements() throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 :
148 : /** Return the <type>XLayer</type> object that is associated with the
149 : given <type>SdrLayer</type> object. If the requested object does
150 : not yet exist it is created. All calls with the same argument
151 : return the same object.
152 : @param pLayer
153 : The <type>SdrLayer</type> object for which to return the
154 : associated <type>XLayer</type> object.
155 : @return
156 : The returned value is the unique <type>XLayer</type> object
157 : associated with the specified argument. If no layer can be
158 : created for the argument than an empty reference is returned.
159 : */
160 : ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer> GetLayer (SdrLayer* pLayer);
161 :
162 : // XComponent
163 : virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
165 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
166 :
167 : private:
168 : SdXImpressDocument* mpModel;
169 : SvUnoWeakContainer* mpLayers;
170 :
171 : ::sd::View* GetView() const throw();
172 720 : ::sd::DrawDocShell* GetDocShell() const throw() { return mpModel->mpDocShell; }
173 : void UpdateLayerView( bool modify = true ) const throw();
174 : };
175 :
176 : #endif
177 :
178 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|