Bump version to 6.4-15
[LibreOffice.git] / sc / inc / styleuno.hxx
blob71f92fc91b81c8240713bf618a11621d9ef4d1b6
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 #ifndef INCLUDED_SC_INC_STYLEUNO_HXX
21 #define INCLUDED_SC_INC_STYLEUNO_HXX
23 #include <svl/lstner.hxx>
24 #include <svl/style.hxx>
25 #include <com/sun/star/container/XIndexAccess.hpp>
26 #include <com/sun/star/style/XStyle.hpp>
27 #include <com/sun/star/style/XStyleLoader2.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/container/XNameContainer.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/beans/XMultiPropertySet.hpp>
32 #include <com/sun/star/beans/XPropertyState.hpp>
33 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
34 #include <com/sun/star/lang/XUnoTunnel.hpp>
35 #include <comphelper/servicehelper.hxx>
36 #include <cppuhelper/implbase.hxx>
38 namespace com { namespace sun { namespace star { namespace container { class XIndexReplace; } } } }
39 namespace com { namespace sun { namespace star { namespace lang { class XComponent; } } } }
41 class ScDocShell;
42 class SfxItemPropertySet;
43 class SfxItemSet;
45 class ScStyleFamilyObj;
46 class ScStyleObj;
47 struct SfxItemPropertySimpleEntry;
49 class ScStyleFamiliesObj final : public ::cppu::WeakImplHelper<
50 css::container::XIndexAccess,
51 css::container::XNameAccess,
52 css::style::XStyleLoader2,
53 css::lang::XServiceInfo >,
54 public SfxListener
56 private:
57 ScDocShell* pDocShell;
59 ScStyleFamilyObj* GetObjectByType_Impl(SfxStyleFamily nType) const;
60 ScStyleFamilyObj* GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
61 ScStyleFamilyObj* GetObjectByName_Impl(const OUString& aName) const;
63 public:
64 ScStyleFamiliesObj(ScDocShell* pDocSh);
65 virtual ~ScStyleFamiliesObj() override;
67 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
69 // XIndexAccess
70 virtual sal_Int32 SAL_CALL getCount() override;
71 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
73 // XNameAccess
74 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
75 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
76 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
78 // XElementAccess
79 virtual css::uno::Type SAL_CALL getElementType() override;
80 virtual sal_Bool SAL_CALL hasElements() override;
82 // XStyleLoader
83 virtual void SAL_CALL loadStylesFromURL( const OUString& URL,
84 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
85 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
86 getStyleLoaderOptions() override;
88 //XStyleLoader2
89 virtual void SAL_CALL loadStylesFromDocument( const css::uno::Reference < css::lang::XComponent > & aSourceComponent,
90 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
91 // XServiceInfo
92 virtual OUString SAL_CALL getImplementationName() override;
93 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
94 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
95 private:
96 /// @throws css::io::IOException
97 /// @throws css::uno::RuntimeException
98 void loadStylesFromDocShell( ScDocShell* pSource,
99 const css::uno::Sequence< css::beans::PropertyValue>& aOptions );
102 class ScStyleFamilyObj : public ::cppu::WeakImplHelper<
103 css::container::XNameContainer,
104 css::container::XIndexAccess,
105 css::beans::XPropertySet,
106 css::lang::XServiceInfo >,
107 public SfxListener
109 private:
110 ScDocShell* pDocShell;
111 SfxStyleFamily const eFamily; // Family
113 ScStyleObj* GetObjectByIndex_Impl(sal_uInt32 nIndex);
114 ScStyleObj* GetObjectByName_Impl(const OUString& Name);
116 public:
117 ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
118 virtual ~ScStyleFamilyObj() override;
120 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
122 // XNameContainer
123 virtual void SAL_CALL insertByName( const OUString& aName,
124 const css::uno::Any& aElement ) override;
125 virtual void SAL_CALL removeByName( const OUString& Name ) override;
127 // XNameReplace
128 virtual void SAL_CALL replaceByName( const OUString& aName,
129 const css::uno::Any& aElement ) override;
131 // XNameAccess
132 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
133 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
134 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
136 // XIndexAccess
137 virtual sal_Int32 SAL_CALL getCount() override;
138 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
140 // XElementAccess
141 virtual css::uno::Type SAL_CALL getElementType() override;
142 virtual sal_Bool SAL_CALL hasElements() override;
144 // XPropertySet
145 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
146 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
147 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
148 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
149 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
150 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
151 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
153 // XServiceInfo
154 virtual OUString SAL_CALL getImplementationName() override;
155 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
156 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
159 class ScStyleObj : public ::cppu::WeakImplHelper<
160 css::style::XStyle,
161 css::beans::XPropertySet,
162 css::beans::XMultiPropertySet,
163 css::beans::XPropertyState,
164 css::beans::XMultiPropertyStates,
165 css::lang::XUnoTunnel,
166 css::lang::XServiceInfo >,
167 public SfxListener
169 private:
170 const SfxItemPropertySet* pPropSet;
171 ScDocShell* pDocShell;
172 SfxStyleFamily const eFamily; // Family
173 OUString aStyleName;
174 SfxStyleSheetBase* pStyle_cached;
176 SfxStyleSheetBase* GetStyle_Impl( bool bUseCachedValue = false );
177 const SfxItemSet* GetStyleItemSet_Impl( const OUString& rPropName, const SfxItemPropertySimpleEntry*& rpEntry );
178 /// @throws css::beans::UnknownPropertyException
179 /// @throws css::uno::RuntimeException
180 css::beans::PropertyState getPropertyState_Impl( const OUString& PropertyName );
181 /// @throws css::beans::UnknownPropertyException
182 /// @throws css::lang::WrappedTargetException
183 /// @throws css::uno::RuntimeException
184 css::uno::Any getPropertyDefault_Impl( const OUString& aPropertyName );
185 /// @throws css::beans::UnknownPropertyException
186 /// @throws css::lang::WrappedTargetException
187 /// @throws css::uno::RuntimeException
188 css::uno::Any getPropertyValue_Impl( const OUString& aPropertyName );
189 /// @throws css::lang::IllegalArgumentException
190 /// @throws css::uno::RuntimeException
191 void setPropertyValue_Impl( const OUString& rPropertyName,
192 const SfxItemPropertySimpleEntry* pEntry,
193 const css::uno::Any* pValue );
195 public:
196 ScStyleObj() = delete;
197 ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, const OUString& rName);
198 virtual ~ScStyleObj() override;
200 // created by getImplementation:
201 bool IsInserted() const { return pDocShell != nullptr; }
202 SfxStyleFamily GetFamily() const { return eFamily; }
203 void InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName );
205 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
207 static css::uno::Reference< css::container::XIndexReplace >
208 CreateEmptyNumberingRules();
210 // XStyle
211 virtual sal_Bool SAL_CALL isUserDefined() override;
212 virtual sal_Bool SAL_CALL isInUse() override;
213 virtual OUString SAL_CALL getParentStyle() override;
214 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) override;
216 // XNamed
217 virtual OUString SAL_CALL getName() override;
218 virtual void SAL_CALL setName( const OUString& aName ) override;
220 // XPropertySet
221 virtual css::uno::Reference< css::beans::XPropertySetInfo >
222 SAL_CALL getPropertySetInfo() override;
223 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
224 const css::uno::Any& aValue ) override;
225 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
226 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
227 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
228 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
229 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
230 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
231 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
232 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
233 const css::uno::Reference<
234 css::beans::XVetoableChangeListener >& aListener ) override;
236 // XMultiPropertySet
237 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames,
238 const css::uno::Sequence< css::uno::Any >& aValues ) override;
239 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
240 getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
241 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames,
242 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
243 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
244 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames,
245 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
247 // XPropertyState
248 virtual css::beans::PropertyState SAL_CALL getPropertyState(
249 const OUString& PropertyName ) override;
250 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
251 getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
252 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
253 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
255 // XMultiPropertyStates
256 // getPropertyStates already defined for XPropertyState
257 virtual void SAL_CALL setAllPropertiesToDefault() override;
258 virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override;
259 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
260 getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override;
262 // XServiceInfo
263 virtual OUString SAL_CALL getImplementationName() override;
264 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
265 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
267 // XUnoTunnel
268 UNO3_GETIMPLEMENTATION_DECL(ScStyleObj)
271 #endif
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */