android: Update app-specific/MIME type icons
[LibreOffice.git] / sc / inc / styleuno.hxx
blob07bf2cb7b12d5f38e1555584868158f55f833cce
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 .
20 #pragma once
22 #include <svl/lstner.hxx>
23 #include <svl/style.hxx>
24 #include <com/sun/star/container/XIndexAccess.hpp>
25 #include <com/sun/star/style/XStyle.hpp>
26 #include <com/sun/star/style/XStyleLoader2.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/container/XNameContainer.hpp>
29 #include <com/sun/star/beans/XPropertySet.hpp>
30 #include <com/sun/star/beans/XMultiPropertySet.hpp>
31 #include <com/sun/star/beans/XPropertyState.hpp>
32 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
33 #include <comphelper/servicehelper.hxx>
34 #include <cppuhelper/implbase.hxx>
36 namespace com::sun::star::container { class XIndexReplace; }
37 namespace com::sun::star::lang { class XComponent; }
39 class ScDocShell;
40 class SfxItemPropertySet;
41 class SfxItemSet;
43 class ScStyleFamilyObj;
44 class ScStyleObj;
45 struct SfxItemPropertyMapEntry;
47 class ScStyleFamiliesObj final : public ::cppu::WeakImplHelper<
48 css::container::XIndexAccess,
49 css::container::XNameAccess,
50 css::style::XStyleLoader2,
51 css::lang::XServiceInfo >,
52 public SfxListener
54 private:
55 ScDocShell* pDocShell;
57 rtl::Reference<ScStyleFamilyObj> GetObjectByType_Impl(SfxStyleFamily nType) const;
58 rtl::Reference<ScStyleFamilyObj> GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
59 rtl::Reference<ScStyleFamilyObj> GetObjectByName_Impl(std::u16string_view aName) const;
61 public:
62 ScStyleFamiliesObj(ScDocShell* pDocSh);
63 virtual ~ScStyleFamiliesObj() override;
65 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
67 // XIndexAccess
68 virtual sal_Int32 SAL_CALL getCount() override;
69 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
71 // XNameAccess
72 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
73 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
74 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
76 // XElementAccess
77 virtual css::uno::Type SAL_CALL getElementType() override;
78 virtual sal_Bool SAL_CALL hasElements() override;
80 // XStyleLoader
81 virtual void SAL_CALL loadStylesFromURL( const OUString& URL,
82 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
83 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
84 getStyleLoaderOptions() override;
86 //XStyleLoader2
87 virtual void SAL_CALL loadStylesFromDocument( const css::uno::Reference < css::lang::XComponent > & aSourceComponent,
88 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
89 // XServiceInfo
90 virtual OUString SAL_CALL getImplementationName() override;
91 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
92 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
93 private:
94 /// @throws css::io::IOException
95 /// @throws css::uno::RuntimeException
96 void loadStylesFromDocShell( ScDocShell* pSource,
97 const css::uno::Sequence< css::beans::PropertyValue>& aOptions );
100 class ScStyleFamilyObj final : public ::cppu::WeakImplHelper<
101 css::container::XNameContainer,
102 css::container::XIndexAccess,
103 css::beans::XPropertySet,
104 css::lang::XServiceInfo >,
105 public SfxListener
107 private:
108 ScDocShell* pDocShell;
109 SfxStyleFamily eFamily; // Family
111 rtl::Reference<ScStyleObj> GetObjectByIndex_Impl(sal_Int32 nIndex);
112 rtl::Reference<ScStyleObj> GetObjectByName_Impl(const OUString& Name);
114 public:
115 ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
116 virtual ~ScStyleFamilyObj() override;
118 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
120 // XNameContainer
121 virtual void SAL_CALL insertByName( const OUString& aName,
122 const css::uno::Any& aElement ) override;
123 virtual void SAL_CALL removeByName( const OUString& Name ) override;
125 // XNameReplace
126 virtual void SAL_CALL replaceByName( const OUString& aName,
127 const css::uno::Any& aElement ) override;
129 // XNameAccess
130 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
131 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
132 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
134 // XIndexAccess
135 virtual sal_Int32 SAL_CALL getCount() override;
136 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
138 // XElementAccess
139 virtual css::uno::Type SAL_CALL getElementType() override;
140 virtual sal_Bool SAL_CALL hasElements() override;
142 // XPropertySet
143 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
144 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
145 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
146 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
147 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
148 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
149 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
151 // XServiceInfo
152 virtual OUString SAL_CALL getImplementationName() override;
153 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
154 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
157 class ScStyleObj final : public ::cppu::WeakImplHelper<
158 css::style::XStyle,
159 css::beans::XPropertySet,
160 css::beans::XMultiPropertySet,
161 css::beans::XPropertyState,
162 css::beans::XMultiPropertyStates,
163 css::lang::XServiceInfo >,
164 public SfxListener
166 private:
167 const SfxItemPropertySet* pPropSet;
168 ScDocShell* pDocShell;
169 SfxStyleFamily eFamily; // Family
170 OUString aStyleName;
171 SfxStyleSheetBase* pStyle_cached;
173 const SfxItemSet* GetStyleItemSet_Impl( std::u16string_view rPropName, const SfxItemPropertyMapEntry*& rpEntry );
174 /// @throws css::beans::UnknownPropertyException
175 /// @throws css::uno::RuntimeException
176 css::beans::PropertyState getPropertyState_Impl( std::u16string_view PropertyName );
177 /// @throws css::beans::UnknownPropertyException
178 /// @throws css::lang::WrappedTargetException
179 /// @throws css::uno::RuntimeException
180 css::uno::Any getPropertyDefault_Impl( std::u16string_view aPropertyName );
181 /// @throws css::beans::UnknownPropertyException
182 /// @throws css::lang::WrappedTargetException
183 /// @throws css::uno::RuntimeException
184 css::uno::Any getPropertyValue_Impl( std::u16string_view aPropertyName );
185 /// @throws css::lang::IllegalArgumentException
186 /// @throws css::uno::RuntimeException
187 void setPropertyValue_Impl( std::u16string_view rPropertyName,
188 const SfxItemPropertyMapEntry* pEntry,
189 const css::uno::Any* pValue );
191 public:
192 ScStyleObj() = delete;
193 ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, OUString aName);
194 virtual ~ScStyleObj() override;
196 // created by getImplementation:
197 bool IsInserted() const { return pDocShell != nullptr; }
198 SfxStyleFamily GetFamily() const { return eFamily; }
199 void InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName );
200 SfxStyleSheetBase* GetStyle_Impl( bool bUseCachedValue = false );
202 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
204 static css::uno::Reference< css::container::XIndexReplace >
205 CreateEmptyNumberingRules();
207 // XStyle
208 virtual sal_Bool SAL_CALL isUserDefined() override;
209 virtual sal_Bool SAL_CALL isInUse() override;
210 virtual OUString SAL_CALL getParentStyle() override;
211 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) override;
213 // XNamed
214 virtual OUString SAL_CALL getName() override;
215 virtual void SAL_CALL setName( const OUString& aName ) override;
217 // XPropertySet
218 virtual css::uno::Reference< css::beans::XPropertySetInfo >
219 SAL_CALL getPropertySetInfo() override;
220 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
221 const css::uno::Any& aValue ) override;
222 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
223 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
224 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
225 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
226 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
227 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
228 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
229 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
230 const css::uno::Reference<
231 css::beans::XVetoableChangeListener >& aListener ) override;
233 // XMultiPropertySet
234 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames,
235 const css::uno::Sequence< css::uno::Any >& aValues ) override;
236 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
237 getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
238 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames,
239 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
240 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
241 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames,
242 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
244 // XPropertyState
245 virtual css::beans::PropertyState SAL_CALL getPropertyState(
246 const OUString& PropertyName ) override;
247 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
248 getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
249 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
250 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
252 // XMultiPropertyStates
253 // getPropertyStates already defined for XPropertyState
254 virtual void SAL_CALL setAllPropertiesToDefault() override;
255 virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override;
256 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
257 getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override;
259 // XServiceInfo
260 virtual OUString SAL_CALL getImplementationName() override;
261 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
262 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
265 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */