tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sd / source / ui / unoidl / unolayer.hxx
blobf96634f536ff0b54810813e3602dbd8b42b6faba
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
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>
30 class SdrLayer;
31 class SdLayerManager;
32 class SvUnoWeakContainer;
34 namespace sd {
35 class View;
37 enum LayerAttribute { VISIBLE, PRINTABLE, LOCKED };
39 /***********************************************************************
40 * *
41 ***********************************************************************/
42 class SdLayer : public ::cppu::WeakImplHelper< css::drawing::XLayer,
43 css::lang::XServiceInfo,
44 css::container::XChild,
45 css::lang::XComponent >
47 public:
48 SdLayer(SdLayerManager* pLayerManager_, SdrLayer* pSdrLayer_);
49 virtual ~SdLayer() noexcept override;
51 // internal
52 SdrLayer* GetSdrLayer() const noexcept { return pLayer; }
54 // XServiceInfo
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;
74 // XComponent
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;
84 private:
85 rtl::Reference<SdLayerManager> mxLayerManager;
86 SdrLayer* pLayer;
87 const SvxItemPropertySet* pPropSet;
89 bool get( LayerAttribute what ) noexcept;
90 void set( LayerAttribute what, bool flag ) noexcept;
94 /***********************************************************************
95 * *
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;
105 public:
106 explicit SdLayerManager( SdXImpressDocument& rMyModel ) noexcept;
107 virtual ~SdLayerManager() noexcept override;
109 // XServiceInfo
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;
114 // XLayerManager
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;
120 // XIndexAccess
121 virtual sal_Int32 SAL_CALL getCount() override ;
122 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
124 // XNameAccess
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;
129 // XElementAccess
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.
137 @param pLayer
138 The <type>SdrLayer</type> object for which to return the
139 associated <type>XLayer</type> object.
140 @return
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);
147 // XComponent
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;
152 private:
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: */