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 .
21 #include <com/sun/star/drawing/XLayer.hpp>
22 #include <com/sun/star/drawing/XLayerManager.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <comphelper/servicehelper.hxx>
26 #include <rtl/ref.hxx>
28 #include <unomodel.hxx>
32 class SvUnoWeakContainer
;
37 enum LayerAttribute
{ VISIBLE
, PRINTABLE
, LOCKED
};
39 /***********************************************************************
41 ***********************************************************************/
42 class SdLayer
: public ::cppu::WeakImplHelper
< css::drawing::XLayer
,
43 css::lang::XServiceInfo
,
44 css::container::XChild
,
45 css::lang::XComponent
>
48 SdLayer(SdLayerManager
* pLayerManager_
, SdrLayer
* pSdrLayer_
);
49 virtual ~SdLayer() noexcept override
;
52 SdrLayer
* GetSdrLayer() const noexcept
{ return pLayer
; }
55 virtual OUString SAL_CALL
getImplementationName() override
;
56 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
57 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
59 // css::beans::XPropertySet
60 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
61 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
62 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
63 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
64 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
65 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
66 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
68 // css::container::XChild
70 /** Returns the layer manager that manages this layer.
72 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) override
;
75 virtual void SAL_CALL
dispose( ) override
;
76 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
77 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
79 /** Not implemented. Always throws an exception.
80 @throws NoSupportException.
82 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) override
;
85 rtl::Reference
<SdLayerManager
> mxLayerManager
;
87 const SvxItemPropertySet
* pPropSet
;
89 bool get( LayerAttribute what
) noexcept
;
90 void set( LayerAttribute what
, bool flag
) noexcept
;
94 /***********************************************************************
96 ***********************************************************************/
98 class SdLayerManager
: public ::cppu::WeakImplHelper
< css::drawing::XLayerManager
,
99 css::container::XNameAccess
,
100 css::lang::XServiceInfo
,
101 css::lang::XComponent
>
103 friend class SdLayer
;
106 explicit SdLayerManager( SdXImpressDocument
& rMyModel
) noexcept
;
107 virtual ~SdLayerManager() noexcept override
;
110 virtual OUString SAL_CALL
getImplementationName() override
;
111 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
112 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
115 virtual css::uno::Reference
< css::drawing::XLayer
> SAL_CALL
insertNewByIndex( sal_Int32 nIndex
) override
;
116 virtual void SAL_CALL
remove( const css::uno::Reference
< css::drawing::XLayer
>& xLayer
) override
;
117 virtual void SAL_CALL
attachShapeToLayer( const css::uno::Reference
< css::drawing::XShape
>& xShape
, const css::uno::Reference
< css::drawing::XLayer
>& xLayer
) override
;
118 virtual css::uno::Reference
< css::drawing::XLayer
> SAL_CALL
getLayerForShape( const css::uno::Reference
< css::drawing::XShape
>& xShape
) override
;
121 virtual sal_Int32 SAL_CALL
getCount() override
;
122 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
125 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
126 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
127 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
130 virtual css::uno::Type SAL_CALL
getElementType() override
;
131 virtual sal_Bool SAL_CALL
hasElements() override
;
133 /** Return the <type>XLayer</type> object that is associated with the
134 given <type>SdrLayer</type> object. If the requested object does
135 not yet exist it is created. All calls with the same argument
136 return the same object.
138 The <type>SdrLayer</type> object for which to return the
139 associated <type>XLayer</type> object.
141 The returned value is the unique <type>XLayer</type> object
142 associated with the specified argument. If no layer can be
143 created for the argument than an empty reference is returned.
145 rtl::Reference
<SdLayer
> GetLayer (SdrLayer
* pLayer
);
148 virtual void SAL_CALL
dispose( ) override
;
149 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
150 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
153 SdXImpressDocument
* mpModel
;
154 std::unique_ptr
<SvUnoWeakContainer
> mpLayers
;
156 ::sd::View
* GetView() const noexcept
;
157 ::sd::DrawDocShell
* GetDocShell() const noexcept
{ return mpModel
->mpDocShell
; }
158 void UpdateLayerView() const noexcept
;
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */