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:536
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: styleuno.cxx:503
virtual sal_Bool SAL_CALL hasElements() override
Definition: styleuno.cxx:518
rtl::Reference< ScStyleFamilyObj > GetObjectByName_Impl(std::u16string_view aName) const
Definition: styleuno.cxx:481
virtual css::uno::Type SAL_CALL getElementType() override
Definition: styleuno.cxx:513
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: styleuno.cxx:541
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ~ScStyleFamiliesObj() override
Definition: styleuno.cxx:438
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:595
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: styleuno.cxx:526
rtl::Reference< ScStyleFamilyObj > GetObjectByIndex_Impl(sal_uInt32 nIndex) const
Definition: styleuno.cxx:473
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL getStyleLoaderOptions() override
Definition: styleuno.cxx:583
ScDocShell * pDocShell
Definition: styleuno.hxx:55
virtual sal_Int32 SAL_CALL getCount() override
Definition: styleuno.cxx:498
void loadStylesFromDocShell(ScDocShell *pSource, const css::uno::Sequence< css::beans::PropertyValue > &aOptions)
Definition: styleuno.cxx:609
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ScStyleFamiliesObj(ScDocShell *pDocSh)
Definition: styleuno.cxx:432
virtual void SAL_CALL loadStylesFromURL(const OUString &URL, const css::uno::Sequence< css::beans::PropertyValue > &aOptions) override
Definition: styleuno.cxx:548
rtl::Reference< ScStyleFamilyObj > GetObjectByType_Impl(SfxStyleFamily nType) const
Definition: styleuno.cxx:458
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: styleuno.cxx:446
SfxStyleFamily eFamily
Definition: styleuno.hxx:109
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: styleuno.cxx:906
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: styleuno.cxx:963
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: styleuno.cxx:912
ScStyleFamilyObj(ScDocShell *pDocSh, SfxStyleFamily eFam)
Definition: styleuno.cxx:638
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: styleuno.cxx:861
virtual sal_Int32 SAL_CALL getCount() override
Definition: styleuno.cxx:813
rtl::Reference< ScStyleObj > GetObjectByIndex_Impl(sal_Int32 nIndex)
Definition: styleuno.cxx:665
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: styleuno.cxx:653
virtual sal_Bool SAL_CALL hasElements() override
Definition: styleuno.cxx:842
virtual OUString SAL_CALL getImplementationName() override
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: styleuno.cxx:697
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: styleuno.cxx:741
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: styleuno.cxx:850
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: styleuno.cxx:827
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:948
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: styleuno.cxx:889
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:958
virtual ~ScStyleFamilyObj() override
Definition: styleuno.cxx:645
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: styleuno.cxx:917
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: styleuno.cxx:749
rtl::Reference< ScStyleObj > GetObjectByName_Impl(const OUString &Name)
Definition: styleuno.cxx:685
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: styleuno.cxx:953
virtual css::uno::Type SAL_CALL getElementType() override
Definition: styleuno.cxx:837
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:1399
ScStyleObj()=delete
OUString aStyleName
Definition: styleuno.hxx:170
css::beans::PropertyState getPropertyState_Impl(std::u16string_view PropertyName)
Definition: styleuno.cxx:1198
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:2053
virtual OUString SAL_CALL getParentStyle() override
Definition: styleuno.cxx:1052
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:1061
virtual sal_Bool SAL_CALL isUserDefined() override
Definition: styleuno.cxx:1034
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: styleuno.cxx:2058
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:1534
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: styleuno.cxx:1522
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:1259
const SfxItemPropertySet * pPropSet
Definition: styleuno.hxx:167
virtual void SAL_CALL setAllPropertiesToDefault() override
Definition: styleuno.cxx:1450
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: styleuno.cxx:1435
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: styleuno.cxx:1418
SfxStyleFamily GetFamily() const
Definition: styleuno.hxx:198
virtual OUString SAL_CALL getName() override
Definition: styleuno.cxx:1112
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: styleuno.cxx:1007
const SfxItemSet * GetStyleItemSet_Impl(std::u16string_view rPropName, const SfxItemPropertyMapEntry *&rpEntry)
Definition: styleuno.cxx:1164
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: styleuno.cxx:1429
virtual sal_Bool SAL_CALL isInUse() override
Definition: styleuno.cxx:1043
virtual ~ScStyleObj() override
Definition: styleuno.cxx:999
static css::uno::Reference< css::container::XIndexReplace > CreateEmptyNumberingRules()
Definition: styleuno.cxx:1156
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: styleuno.cxx:1378
SfxStyleSheetBase * GetStyle_Impl(bool bUseCachedValue=false)
Definition: styleuno.cxx:1017
virtual void SAL_CALL setName(const OUString &aName) override
Definition: styleuno.cxx:1121
SfxStyleSheetBase * pStyle_cached
Definition: styleuno.hxx:171
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: styleuno.cxx:1251
virtual void SAL_CALL setPropertiesToDefault(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: styleuno.cxx:1501
void InitDoc(ScDocShell *pNewDocSh, const OUString &rNewName)
Definition: styleuno.cxx:989
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: styleuno.cxx:1270
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: styleuno.cxx:1386
css::uno::Any getPropertyValue_Impl(std::u16string_view aPropertyName)
Definition: styleuno.cxx:1875
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: styleuno.cxx:1441
SfxStyleFamily eFamily
Definition: styleuno.hxx:169
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: styleuno.cxx:1516
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: styleuno.cxx:2036
css::uno::Any getPropertyDefault_Impl(std::u16string_view aPropertyName)
Definition: styleuno.cxx:1282
virtual OUString SAL_CALL getImplementationName() override
Definition: styleuno.cxx:2048
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
SfxStyleFamily
unsigned char sal_Bool