1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SD_SOURCE_UI_UNOIDL_UNOLAYER_HXX
20 #define INCLUDED_SD_SOURCE_UI_UNOIDL_UNOLAYER_HXX
22 #include <com/sun/star/drawing/XLayer.hpp>
23 #include <com/sun/star/drawing/XLayerManager.hpp>
25 #include <cppuhelper/implbase.hxx>
26 #include <comphelper/servicehelper.hxx>
27 #include <rtl/ref.hxx>
29 #include <unomodel.hxx>
33 class SvUnoWeakContainer
;
38 enum LayerAttribute
{ VISIBLE
, PRINTABLE
, LOCKED
};
40 /***********************************************************************
42 ***********************************************************************/
43 class SdLayer
: public ::cppu::WeakImplHelper
< css::drawing::XLayer
,
44 css::lang::XServiceInfo
,
45 css::container::XChild
,
46 css::lang::XUnoTunnel
,
47 css::lang::XComponent
>
50 SdLayer(SdLayerManager
* pLayerManager_
, SdrLayer
* pSdrLayer_
);
51 virtual ~SdLayer() throw() override
;
54 SdrLayer
* GetSdrLayer() const throw() { return pLayer
; }
57 UNO3_GETIMPLEMENTATION_DECL( SdLayer
)
60 virtual OUString SAL_CALL
getImplementationName() override
;
61 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
62 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
64 // css::beans::XPropertySet
65 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
66 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
67 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
68 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
69 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
70 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
71 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
73 // css::container::XChild
75 /** Returns the layer manager that manages this layer.
77 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) override
;
80 virtual void SAL_CALL
dispose( ) override
;
81 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
82 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
84 /** Not implemented. Always throws an exception.
85 @throws NoSupportException.
87 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) override
;
90 rtl::Reference
<SdLayerManager
> mxLayerManager
;
92 const SvxItemPropertySet
* pPropSet
;
94 bool get( LayerAttribute what
) throw();
95 void set( LayerAttribute what
, bool flag
) throw();
99 /***********************************************************************
101 ***********************************************************************/
103 class SdLayerManager
: public ::cppu::WeakImplHelper
< css::drawing::XLayerManager
,
104 css::container::XNameAccess
,
105 css::lang::XServiceInfo
,
106 css::lang::XUnoTunnel
,
107 css::lang::XComponent
>
109 friend class SdLayer
;
112 explicit SdLayerManager( SdXImpressDocument
& rMyModel
) throw();
113 virtual ~SdLayerManager() throw() override
;
116 UNO3_GETIMPLEMENTATION_DECL( SdLayerManager
)
119 virtual OUString SAL_CALL
getImplementationName() override
;
120 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
121 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
124 virtual css::uno::Reference
< css::drawing::XLayer
> SAL_CALL
insertNewByIndex( sal_Int32 nIndex
) override
;
125 virtual void SAL_CALL
remove( const css::uno::Reference
< css::drawing::XLayer
>& xLayer
) override
;
126 virtual void SAL_CALL
attachShapeToLayer( const css::uno::Reference
< css::drawing::XShape
>& xShape
, const css::uno::Reference
< css::drawing::XLayer
>& xLayer
) override
;
127 virtual css::uno::Reference
< css::drawing::XLayer
> SAL_CALL
getLayerForShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
130 virtual sal_Int32 SAL_CALL
getCount() override
;
131 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
134 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
135 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
136 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
139 virtual css::uno::Type SAL_CALL
getElementType() override
;
140 virtual sal_Bool SAL_CALL
hasElements() override
;
142 /** Return the <type>XLayer</type> object that is associated with the
143 given <type>SdrLayer</type> object. If the requested object does
144 not yet exist it is created. All calls with the same argument
145 return the same object.
147 The <type>SdrLayer</type> object for which to return the
148 associated <type>XLayer</type> object.
150 The returned value is the unique <type>XLayer</type> object
151 associated with the specified argument. If no layer can be
152 created for the argument than an empty reference is returned.
154 css::uno::Reference
< css::drawing::XLayer
> GetLayer (SdrLayer
* pLayer
);
157 virtual void SAL_CALL
dispose( ) override
;
158 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
159 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
162 SdXImpressDocument
* mpModel
;
163 std::unique_ptr
<SvUnoWeakContainer
> mpLayers
;
165 ::sd::View
* GetView() const throw();
166 ::sd::DrawDocShell
* GetDocShell() const throw() { return mpModel
->mpDocShell
; }
167 void UpdateLayerView() const throw();
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */