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 .
20 #ifndef INCLUDED_SC_INC_STYLEUNO_HXX
21 #define INCLUDED_SC_INC_STYLEUNO_HXX
23 #include <svl/itemprop.hxx>
24 #include <svl/lstner.hxx>
25 #include <svl/style.hxx>
26 #include <com/sun/star/container/XIndexAccess.hpp>
27 #include <com/sun/star/style/XStyle.hpp>
28 #include <com/sun/star/style/XStyleLoader2.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/container/XNameContainer.hpp>
31 #include <com/sun/star/container/XIndexReplace.hpp>
32 #include <com/sun/star/beans/XPropertySet.hpp>
33 #include <com/sun/star/beans/XMultiPropertySet.hpp>
34 #include <com/sun/star/beans/XPropertyState.hpp>
35 #include <com/sun/star/beans/XMultiPropertyStates.hpp>
36 #include <com/sun/star/lang/XUnoTunnel.hpp>
37 #include <cppuhelper/implbase.hxx>
38 #include <com/sun/star/lang/XComponent.hpp>
41 class SfxStyleSheetBase
;
45 class ScStyleFamilyObj
;
48 class ScStyleFamiliesObj
: public ::cppu::WeakImplHelper
<
49 css::container::XIndexAccess
,
50 css::container::XNameAccess
,
51 css::style::XStyleLoader2
,
52 css::lang::XServiceInfo
>,
56 ScDocShell
* pDocShell
;
58 ScStyleFamilyObj
* GetObjectByType_Impl(SfxStyleFamily nType
) const;
59 ScStyleFamilyObj
* GetObjectByIndex_Impl(sal_uInt32 nIndex
) const;
60 ScStyleFamilyObj
* GetObjectByName_Impl(const OUString
& aName
) const;
63 ScStyleFamiliesObj(ScDocShell
* pDocSh
);
64 virtual ~ScStyleFamiliesObj() override
;
66 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
69 virtual sal_Int32 SAL_CALL
getCount() override
;
70 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
73 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
74 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
75 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
78 virtual css::uno::Type SAL_CALL
getElementType() override
;
79 virtual sal_Bool SAL_CALL
hasElements() override
;
82 virtual void SAL_CALL
loadStylesFromURL( const OUString
& URL
,
83 const css::uno::Sequence
< css::beans::PropertyValue
>& aOptions
) override
;
84 virtual css::uno::Sequence
< css::beans::PropertyValue
> SAL_CALL
85 getStyleLoaderOptions() override
;
88 virtual void SAL_CALL
loadStylesFromDocument( const css::uno::Reference
< css::lang::XComponent
> & aSourceComponent
,
89 const css::uno::Sequence
< css::beans::PropertyValue
>& aOptions
) override
;
91 virtual OUString SAL_CALL
getImplementationName() override
;
92 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
93 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
95 /// @throws css::io::IOException
96 /// @throws css::uno::RuntimeException
97 void loadStylesFromDocShell( ScDocShell
* pSource
,
98 const css::uno::Sequence
< css::beans::PropertyValue
>& aOptions
);
101 class ScStyleFamilyObj
: public ::cppu::WeakImplHelper
<
102 css::container::XNameContainer
,
103 css::container::XIndexAccess
,
104 css::beans::XPropertySet
,
105 css::lang::XServiceInfo
>,
109 ScDocShell
* pDocShell
;
110 SfxStyleFamily eFamily
; // Family
112 ScStyleObj
* GetObjectByIndex_Impl(sal_uInt32 nIndex
);
113 ScStyleObj
* GetObjectByName_Impl(const OUString
& Name
);
116 ScStyleFamilyObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
);
117 virtual ~ScStyleFamilyObj() override
;
119 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
122 virtual void SAL_CALL
insertByName( const OUString
& aName
,
123 const css::uno::Any
& aElement
) override
;
124 virtual void SAL_CALL
removeByName( const OUString
& Name
) override
;
127 virtual void SAL_CALL
replaceByName( const OUString
& aName
,
128 const css::uno::Any
& aElement
) override
;
131 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
132 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames() override
;
133 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
136 virtual sal_Int32 SAL_CALL
getCount() override
;
137 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
140 virtual css::uno::Type SAL_CALL
getElementType() override
;
141 virtual sal_Bool SAL_CALL
hasElements() override
;
144 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
145 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
146 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
147 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
148 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
149 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
150 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
153 virtual OUString SAL_CALL
getImplementationName() override
;
154 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
155 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
158 class ScStyleObj
: public ::cppu::WeakImplHelper
<
160 css::beans::XPropertySet
,
161 css::beans::XMultiPropertySet
,
162 css::beans::XPropertyState
,
163 css::beans::XMultiPropertyStates
,
164 css::lang::XUnoTunnel
,
165 css::lang::XServiceInfo
>,
169 const SfxItemPropertySet
* pPropSet
;
170 ScDocShell
* pDocShell
;
171 SfxStyleFamily eFamily
; // Family
173 SfxStyleSheetBase
* pStyle_cached
;
175 SfxStyleSheetBase
* GetStyle_Impl( bool bUseCachedValue
= false );
176 const SfxItemSet
* GetStyleItemSet_Impl( const OUString
& rPropName
, const SfxItemPropertySimpleEntry
*& rpEntry
);
177 /// @throws css::beans::UnknownPropertyException
178 /// @throws css::uno::RuntimeException
179 css::beans::PropertyState
getPropertyState_Impl( const OUString
& PropertyName
);
180 /// @throws css::beans::UnknownPropertyException
181 /// @throws css::lang::WrappedTargetException
182 /// @throws css::uno::RuntimeException
183 css::uno::Any
getPropertyDefault_Impl( const OUString
& aPropertyName
);
184 /// @throws css::beans::UnknownPropertyException
185 /// @throws css::lang::WrappedTargetException
186 /// @throws css::uno::RuntimeException
187 css::uno::Any
getPropertyValue_Impl( const OUString
& aPropertyName
);
188 /// @throws css::lang::IllegalArgumentException
189 /// @throws css::uno::RuntimeException
190 void setPropertyValue_Impl( const OUString
& rPropertyName
,
191 const SfxItemPropertySimpleEntry
* pEntry
,
192 const css::uno::Any
* pValue
);
195 ScStyleObj() = delete;
196 ScStyleObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
, const OUString
& rName
);
197 virtual ~ScStyleObj() override
;
199 // created by getImplementation:
200 bool IsInserted() const { return pDocShell
!= nullptr; }
201 SfxStyleFamily
GetFamily() const { return eFamily
; }
202 void InitDoc( ScDocShell
* pNewDocSh
, const OUString
& rNewName
);
204 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
206 static css::uno::Reference
< css::container::XIndexReplace
>
207 CreateEmptyNumberingRules();
210 virtual sal_Bool SAL_CALL
isUserDefined() override
;
211 virtual sal_Bool SAL_CALL
isInUse() override
;
212 virtual OUString SAL_CALL
getParentStyle() override
;
213 virtual void SAL_CALL
setParentStyle( const OUString
& aParentStyle
) override
;
216 virtual OUString SAL_CALL
getName() override
;
217 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
220 virtual css::uno::Reference
< css::beans::XPropertySetInfo
>
221 SAL_CALL
getPropertySetInfo() override
;
222 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
,
223 const css::uno::Any
& aValue
) override
;
224 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
225 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
,
226 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
227 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
,
228 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
229 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
,
230 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
231 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
,
232 const css::uno::Reference
<
233 css::beans::XVetoableChangeListener
>& aListener
) override
;
236 virtual void SAL_CALL
setPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
,
237 const css::uno::Sequence
< css::uno::Any
>& aValues
) override
;
238 virtual css::uno::Sequence
< css::uno::Any
> SAL_CALL
239 getPropertyValues( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
240 virtual void SAL_CALL
addPropertiesChangeListener( const css::uno::Sequence
< OUString
>& aPropertyNames
,
241 const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
242 virtual void SAL_CALL
removePropertiesChangeListener( const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
243 virtual void SAL_CALL
firePropertiesChangeEvent( const css::uno::Sequence
< OUString
>& aPropertyNames
,
244 const css::uno::Reference
< css::beans::XPropertiesChangeListener
>& xListener
) override
;
247 virtual css::beans::PropertyState SAL_CALL
getPropertyState(
248 const OUString
& PropertyName
) override
;
249 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
250 getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
251 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
252 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
254 // XMultiPropertyStates
255 // getPropertyStates already defined for XPropertyState
256 virtual void SAL_CALL
setAllPropertiesToDefault() override
;
257 virtual void SAL_CALL
setPropertiesToDefault( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
258 virtual css::uno::Sequence
< css::uno::Any
> SAL_CALL
259 getPropertyDefaults( const css::uno::Sequence
< OUString
>& aPropertyNames
) override
;
262 virtual OUString SAL_CALL
getImplementationName() override
;
263 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
264 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
267 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
269 static const css::uno::Sequence
<sal_Int8
>& getUnoTunnelId();
270 static ScStyleObj
* getImplementation(const css::uno::Reference
<css::uno::XInterface
>& rObj
);
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */