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/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
; } } } }
42 class SfxItemPropertySet
;
45 class ScStyleFamilyObj
;
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
>,
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;
64 ScStyleFamiliesObj(ScDocShell
* pDocSh
);
65 virtual ~ScStyleFamiliesObj() override
;
67 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
70 virtual sal_Int32 SAL_CALL
getCount() override
;
71 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
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
;
79 virtual css::uno::Type SAL_CALL
getElementType() override
;
80 virtual sal_Bool SAL_CALL
hasElements() override
;
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
;
89 virtual void SAL_CALL
loadStylesFromDocument( const css::uno::Reference
< css::lang::XComponent
> & aSourceComponent
,
90 const css::uno::Sequence
< css::beans::PropertyValue
>& aOptions
) override
;
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
;
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
>,
110 ScDocShell
* pDocShell
;
111 SfxStyleFamily
const eFamily
; // Family
113 ScStyleObj
* GetObjectByIndex_Impl(sal_uInt32 nIndex
);
114 ScStyleObj
* GetObjectByName_Impl(const OUString
& Name
);
117 ScStyleFamilyObj(ScDocShell
* pDocSh
, SfxStyleFamily eFam
);
118 virtual ~ScStyleFamilyObj() override
;
120 virtual void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
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
;
128 virtual void SAL_CALL
replaceByName( const OUString
& aName
,
129 const css::uno::Any
& aElement
) override
;
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
;
137 virtual sal_Int32 SAL_CALL
getCount() override
;
138 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 Index
) override
;
141 virtual css::uno::Type SAL_CALL
getElementType() override
;
142 virtual sal_Bool SAL_CALL
hasElements() override
;
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
;
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
<
161 css::beans::XPropertySet
,
162 css::beans::XMultiPropertySet
,
163 css::beans::XPropertyState
,
164 css::beans::XMultiPropertyStates
,
165 css::lang::XUnoTunnel
,
166 css::lang::XServiceInfo
>,
170 const SfxItemPropertySet
* pPropSet
;
171 ScDocShell
* pDocShell
;
172 SfxStyleFamily
const eFamily
; // Family
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
);
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();
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
;
217 virtual OUString SAL_CALL
getName() override
;
218 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
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
;
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
;
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
;
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
;
268 UNO3_GETIMPLEMENTATION_DECL(ScStyleObj
)
273 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */