Revert "tdf#110987: type detection, binary Office formats > templates"
[LibreOffice.git] / sc / inc / styleuno.hxx
blob4d076df46d51c5d46823f470f5786c4b16fd950c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <cppuhelper/implbase.hxx>
37 namespace com { namespace sun { namespace star { namespace container { class XIndexReplace; } } } }
38 namespace com { namespace sun { namespace star { namespace lang { class XComponent; } } } }
40 class ScDocShell;
41 class SfxItemPropertySet;
42 class SfxItemSet;
44 class ScStyleFamilyObj;
45 class ScStyleObj;
46 struct SfxItemPropertySimpleEntry;
48 class ScStyleFamiliesObj : public ::cppu::WeakImplHelper<
49 css::container::XIndexAccess,
50 css::container::XNameAccess,
51 css::style::XStyleLoader2,
52 css::lang::XServiceInfo >,
53 public SfxListener
55 private:
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;
62 public:
63 ScStyleFamiliesObj(ScDocShell* pDocSh);
64 virtual ~ScStyleFamiliesObj() override;
66 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
68 // XIndexAccess
69 virtual sal_Int32 SAL_CALL getCount() override;
70 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
72 // XNameAccess
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;
77 // XElementAccess
78 virtual css::uno::Type SAL_CALL getElementType() override;
79 virtual sal_Bool SAL_CALL hasElements() override;
81 // XStyleLoader
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;
87 //XStyleLoader2
88 virtual void SAL_CALL loadStylesFromDocument( const css::uno::Reference < css::lang::XComponent > & aSourceComponent,
89 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
90 // XServiceInfo
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;
94 private:
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 >,
106 public SfxListener
108 private:
109 ScDocShell* pDocShell;
110 SfxStyleFamily eFamily; // Family
112 ScStyleObj* GetObjectByIndex_Impl(sal_uInt32 nIndex);
113 ScStyleObj* GetObjectByName_Impl(const OUString& Name);
115 public:
116 ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
117 virtual ~ScStyleFamilyObj() override;
119 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
121 // XNameContainer
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;
126 // XNameReplace
127 virtual void SAL_CALL replaceByName( const OUString& aName,
128 const css::uno::Any& aElement ) override;
130 // XNameAccess
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;
135 // XIndexAccess
136 virtual sal_Int32 SAL_CALL getCount() override;
137 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
139 // XElementAccess
140 virtual css::uno::Type SAL_CALL getElementType() override;
141 virtual sal_Bool SAL_CALL hasElements() override;
143 // XPropertySet
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;
152 // XServiceInfo
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<
159 css::style::XStyle,
160 css::beans::XPropertySet,
161 css::beans::XMultiPropertySet,
162 css::beans::XPropertyState,
163 css::beans::XMultiPropertyStates,
164 css::lang::XUnoTunnel,
165 css::lang::XServiceInfo >,
166 public SfxListener
168 private:
169 const SfxItemPropertySet* pPropSet;
170 ScDocShell* pDocShell;
171 SfxStyleFamily eFamily; // Family
172 OUString aStyleName;
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 );
194 public:
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();
209 // XStyle
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;
215 // XNamed
216 virtual OUString SAL_CALL getName() override;
217 virtual void SAL_CALL setName( const OUString& aName ) override;
219 // XPropertySet
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;
235 // XMultiPropertySet
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;
246 // XPropertyState
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;
261 // XServiceInfo
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;
266 // XUnoTunnel
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);
274 #endif
276 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */