1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
; }
40 class SfxItemPropertySet
;
43 class ScStyleFamilyObj
;
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
>,
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;
62 ScStyleFamiliesObj(ScDocShell
* pDocSh
);
63 virtual ~ScStyleFamiliesObj() override
;
65 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
68 virtual sal_Int32 SAL_CALL
getCount() override
;
69 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
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
;
77 virtual css::uno::Type SAL_CALL
getElementType() override
;
78 virtual sal_Bool SAL_CALL
hasElements() override
;
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
;
87 virtual void SAL_CALL
loadStylesFromDocument( const css::uno::Reference
< css::lang::XComponent
> & aSourceComponent
,
88 const css::uno::Sequence
< css::beans::PropertyValue
>& aOptions
) override
;
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
;
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
>,
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
);
115 ScStyleFamilyObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
);
116 virtual ~ScStyleFamilyObj() override
;
118 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
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
;
126 virtual void SAL_CALL
replaceByName( const OUString
& aName
,
127 const css::uno::Any
& aElement
) override
;
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
;
135 virtual sal_Int32 SAL_CALL
getCount() override
;
136 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
139 virtual css::uno::Type SAL_CALL
getElementType() override
;
140 virtual sal_Bool SAL_CALL
hasElements() override
;
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
;
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
<
159 css::beans::XPropertySet
,
160 css::beans::XMultiPropertySet
,
161 css::beans::XPropertyState
,
162 css::beans::XMultiPropertyStates
,
163 css::lang::XServiceInfo
>,
167 const SfxItemPropertySet
* pPropSet
;
168 ScDocShell
* pDocShell
;
169 SfxStyleFamily eFamily
; // Family
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
);
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();
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
;
214 virtual OUString SAL_CALL
getName() override
;
215 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
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
;
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
;
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
;
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: */