LibreOffice Module sc (master) 1
styleuno.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
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>
35
36namespace com::sun::star::container { class XIndexReplace; }
37namespace com::sun::star::lang { class XComponent; }
38
39class ScDocShell;
41class SfxItemSet;
42
44class ScStyleObj;
46
47class ScStyleFamiliesObj final : public ::cppu::WeakImplHelper<
48 css::container::XIndexAccess,
49 css::container::XNameAccess,
50 css::style::XStyleLoader2,
51 css::lang::XServiceInfo >,
52 public SfxListener
53{
54private:
56
59 rtl::Reference<ScStyleFamilyObj> GetObjectByName_Impl(std::u16string_view aName) const;
60
61public:
63 virtual ~ScStyleFamiliesObj() override;
64
65 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
66
67 // XIndexAccess
68 virtual sal_Int32 SAL_CALL getCount() override;
69 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
70
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;
75
76 // XElementAccess
77 virtual css::uno::Type SAL_CALL getElementType() override;
78 virtual sal_Bool SAL_CALL hasElements() override;
79
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;
85
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;
93private:
97 const css::uno::Sequence< css::beans::PropertyValue>& aOptions );
98};
99
100class ScStyleFamilyObj final : public ::cppu::WeakImplHelper<
101 css::container::XNameContainer,
102 css::container::XIndexAccess,
103 css::beans::XPropertySet,
104 css::lang::XServiceInfo >,
105 public SfxListener
106{
107private:
110
113
114public:
116 virtual ~ScStyleFamilyObj() override;
117
118 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
119
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;
124
125 // XNameReplace
126 virtual void SAL_CALL replaceByName( const OUString& aName,
127 const css::uno::Any& aElement ) override;
128
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;
133
134 // XIndexAccess
135 virtual sal_Int32 SAL_CALL getCount() override;
136 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
137
138 // XElementAccess
139 virtual css::uno::Type SAL_CALL getElementType() override;
140 virtual sal_Bool SAL_CALL hasElements() override;
141
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;
150
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;
155};
156
157class 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
165{
166private:
170 OUString aStyleName;
172
173 const SfxItemSet* GetStyleItemSet_Impl( std::u16string_view rPropName, const SfxItemPropertyMapEntry*& rpEntry );
176 css::beans::PropertyState getPropertyState_Impl( std::u16string_view PropertyName );
180 css::uno::Any getPropertyDefault_Impl( std::u16string_view aPropertyName );
184 css::uno::Any getPropertyValue_Impl( std::u16string_view aPropertyName );
187 void setPropertyValue_Impl( std::u16string_view rPropertyName,
188 const SfxItemPropertyMapEntry* pEntry,
189 const css::uno::Any* pValue );
190
191public:
192 ScStyleObj() = delete;
193 ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, OUString aName);
194 virtual ~ScStyleObj() override;
195
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 );
201
202 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
203
204 static css::uno::Reference< css::container::XIndexReplace >
206
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;
212
213 // XNamed
214 virtual OUString SAL_CALL getName() override;
215 virtual void SAL_CALL setName( const OUString& aName ) override;
216
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;
232
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;
243
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;
251
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;
258
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;
263};
264
265/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: styleuno.cxx:542
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: styleuno.cxx:509
virtual sal_Bool SAL_CALL hasElements() override
Definition: styleuno.cxx:524
rtl::Reference< ScStyleFamilyObj > GetObjectByName_Impl(std::u16string_view aName) const
Definition: styleuno.cxx:487
virtual css::uno::Type SAL_CALL getElementType() override
Definition: styleuno.cxx:519
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: styleuno.cxx:547
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ~ScStyleFamiliesObj() override
Definition: styleuno.cxx:444
virtual void SAL_CALL loadStylesFromDocument(const css::uno::Reference< css::lang::XComponent > &aSourceComponent, const css::uno::Sequence< css::beans::PropertyValue > &aOptions) override
Definition: styleuno.cxx:601
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: styleuno.cxx:532
rtl::Reference< ScStyleFamilyObj > GetObjectByIndex_Impl(sal_uInt32 nIndex) const
Definition: styleuno.cxx:479
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getStyleLoaderOptions() override
Definition: styleuno.cxx:589
ScDocShell * pDocShell
Definition: styleuno.hxx:55
virtual sal_Int32 SAL_CALL getCount() override
Definition: styleuno.cxx:504
void loadStylesFromDocShell(ScDocShell *pSource, const css::uno::Sequence< css::beans::PropertyValue > &aOptions)
Definition: styleuno.cxx:615
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ScStyleFamiliesObj(ScDocShell *pDocSh)
Definition: styleuno.cxx:438
virtual void SAL_CALL loadStylesFromURL(const OUString &URL, const css::uno::Sequence< css::beans::PropertyValue > &aOptions) override
Definition: styleuno.cxx:554
rtl::Reference< ScStyleFamilyObj > GetObjectByType_Impl(SfxStyleFamily nType) const
Definition: styleuno.cxx:464
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: styleuno.cxx:452
SfxStyleFamily eFamily
Definition: styleuno.hxx:109
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: styleuno.cxx:912
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: styleuno.cxx:969
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: styleuno.cxx:918
ScStyleFamilyObj(ScDocShell *pDocSh, SfxStyleFamily eFam)
Definition: styleuno.cxx:644
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: styleuno.cxx:867
virtual sal_Int32 SAL_CALL getCount() override
Definition: styleuno.cxx:819
rtl::Reference< ScStyleObj > GetObjectByIndex_Impl(sal_Int32 nIndex)
Definition: styleuno.cxx:671
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: styleuno.cxx:659
virtual sal_Bool SAL_CALL hasElements() override
Definition: styleuno.cxx:848
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: styleuno.cxx:703
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: styleuno.cxx:747
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: styleuno.cxx:856
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: styleuno.cxx:833
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: styleuno.cxx:954
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: styleuno.cxx:895
ScDocShell * pDocShell
Definition: styleuno.hxx:108
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: styleuno.cxx:964
virtual ~ScStyleFamilyObj() override
Definition: styleuno.cxx:651
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: styleuno.cxx:923
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: styleuno.cxx:755
rtl::Reference< ScStyleObj > GetObjectByName_Impl(const OUString &Name)
Definition: styleuno.cxx:691
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: styleuno.cxx:959
virtual css::uno::Type SAL_CALL getElementType() override
Definition: styleuno.cxx:843
ScDocShell * pDocShell
Definition: styleuno.hxx:168
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: styleuno.cxx:1405
ScStyleObj()=delete
OUString aStyleName
Definition: styleuno.hxx:170
css::beans::PropertyState getPropertyState_Impl(std::u16string_view PropertyName)
Definition: styleuno.cxx:1204
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: styleuno.cxx:2052
virtual OUString SAL_CALL getParentStyle() override
Definition: styleuno.cxx:1058
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL setParentStyle(const OUString &aParentStyle) override
Definition: styleuno.cxx:1067
virtual sal_Bool SAL_CALL isUserDefined() override
Definition: styleuno.cxx:1040
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: styleuno.cxx:2057
bool IsInserted() const
Definition: styleuno.hxx:197
void setPropertyValue_Impl(std::u16string_view rPropertyName, const SfxItemPropertyMapEntry *pEntry, const css::uno::Any *pValue)
Definition: styleuno.cxx:1540
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: styleuno.cxx:1528
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: styleuno.cxx:1265
const SfxItemPropertySet * pPropSet
Definition: styleuno.hxx:167
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: styleuno.cxx:1456
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: styleuno.cxx:1441
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: styleuno.cxx:1424
SfxStyleFamily GetFamily() const
Definition: styleuno.hxx:198
virtual OUString SAL_CALL getName() override
Definition: styleuno.cxx:1118
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: styleuno.cxx:1013
const SfxItemSet * GetStyleItemSet_Impl(std::u16string_view rPropName, const SfxItemPropertyMapEntry *&rpEntry)
Definition: styleuno.cxx:1170
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: styleuno.cxx:1435
virtual sal_Bool SAL_CALL isInUse() override
Definition: styleuno.cxx:1049
virtual ~ScStyleObj() override
Definition: styleuno.cxx:1005
static css::uno::Reference< css::container::XIndexReplace > CreateEmptyNumberingRules()
Definition: styleuno.cxx:1162
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: styleuno.cxx:1384
SfxStyleSheetBase * GetStyle_Impl(bool bUseCachedValue=false)
Definition: styleuno.cxx:1023
virtual void SAL_CALL setName(const OUString &aName) override
Definition: styleuno.cxx:1127
SfxStyleSheetBase * pStyle_cached
Definition: styleuno.hxx:171
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: styleuno.cxx:1257
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: styleuno.cxx:1507
void InitDoc(ScDocShell *pNewDocSh, const OUString &rNewName)
Definition: styleuno.cxx:995
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: styleuno.cxx:1276
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: styleuno.cxx:1392
css::uno::Any getPropertyValue_Impl(std::u16string_view aPropertyName)
Definition: styleuno.cxx:1881
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: styleuno.cxx:1447
SfxStyleFamily eFamily
Definition: styleuno.hxx:169
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: styleuno.cxx:1522
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: styleuno.cxx:2035
css::uno::Any getPropertyDefault_Impl(std::u16string_view aPropertyName)
Definition: styleuno.cxx:1288
virtual OUString SAL_CALL getImplementationName() override
Definition: styleuno.cxx:2047
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
SfxStyleFamily
unsigned char sal_Bool