tdf#48459 sw inline heading: don't apply inside frames or over 120 chars
[LibreOffice.git] / sc / inc / styleuno.hxx
blob550e712fe9faf6088dc57fc6c4846916c1c5bbad
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 #pragma once
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 <cppuhelper/implbase.hxx>
35 namespace com::sun::star::container { class XIndexReplace; }
36 namespace com::sun::star::lang { class XComponent; }
38 class ScDocShell;
39 class SfxItemPropertySet;
40 class SfxItemSet;
42 class ScStyleFamilyObj;
43 class ScStyleObj;
44 struct SfxItemPropertyMapEntry;
46 class ScStyleFamiliesObj final : public ::cppu::WeakImplHelper<
47 css::container::XIndexAccess,
48 css::container::XNameAccess,
49 css::style::XStyleLoader2,
50 css::lang::XServiceInfo >,
51 public SfxListener
53 private:
54 ScDocShell* pDocShell;
56 rtl::Reference<ScStyleFamilyObj> GetObjectByType_Impl(SfxStyleFamily nType) const;
57 rtl::Reference<ScStyleFamilyObj> GetObjectByIndex_Impl(sal_uInt32 nIndex) const;
58 rtl::Reference<ScStyleFamilyObj> GetObjectByName_Impl(std::u16string_view aName) const;
60 public:
61 ScStyleFamiliesObj(ScDocShell* pDocSh);
62 virtual ~ScStyleFamiliesObj() override;
64 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
66 // XIndexAccess
67 virtual sal_Int32 SAL_CALL getCount() override;
68 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
70 // XNameAccess
71 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
72 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
73 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
75 // XElementAccess
76 virtual css::uno::Type SAL_CALL getElementType() override;
77 virtual sal_Bool SAL_CALL hasElements() override;
79 // XStyleLoader
80 virtual void SAL_CALL loadStylesFromURL( const OUString& URL,
81 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
82 virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL
83 getStyleLoaderOptions() override;
85 //XStyleLoader2
86 virtual void SAL_CALL loadStylesFromDocument( const css::uno::Reference < css::lang::XComponent > & aSourceComponent,
87 const css::uno::Sequence< css::beans::PropertyValue >& aOptions ) override;
88 // XServiceInfo
89 virtual OUString SAL_CALL getImplementationName() override;
90 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
91 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
92 private:
93 /// @throws css::io::IOException
94 /// @throws css::uno::RuntimeException
95 void loadStylesFromDocShell( ScDocShell* pSource,
96 const css::uno::Sequence< css::beans::PropertyValue>& aOptions );
99 class ScStyleFamilyObj final : public ::cppu::WeakImplHelper<
100 css::container::XNameContainer,
101 css::container::XIndexAccess,
102 css::beans::XPropertySet,
103 css::lang::XServiceInfo >,
104 public SfxListener
106 private:
107 ScDocShell* pDocShell;
108 SfxStyleFamily eFamily; // Family
110 rtl::Reference<ScStyleObj> GetObjectByIndex_Impl(sal_Int32 nIndex);
111 rtl::Reference<ScStyleObj> GetObjectByName_Impl(const OUString& Name);
113 public:
114 ScStyleFamilyObj(ScDocShell* pDocSh, SfxStyleFamily eFam);
115 virtual ~ScStyleFamilyObj() override;
117 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
119 // XNameContainer
120 virtual void SAL_CALL insertByName( const OUString& aName,
121 const css::uno::Any& aElement ) override;
122 virtual void SAL_CALL removeByName( const OUString& Name ) override;
124 // XNameReplace
125 virtual void SAL_CALL replaceByName( const OUString& aName,
126 const css::uno::Any& aElement ) override;
128 // XNameAccess
129 virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
130 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
131 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
133 // XIndexAccess
134 virtual sal_Int32 SAL_CALL getCount() override;
135 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
137 // XElementAccess
138 virtual css::uno::Type SAL_CALL getElementType() override;
139 virtual sal_Bool SAL_CALL hasElements() override;
141 // XPropertySet
142 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
143 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
144 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
145 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
146 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
147 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
148 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
150 // XServiceInfo
151 virtual OUString SAL_CALL getImplementationName() override;
152 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
153 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
156 class ScStyleObj final : public ::cppu::WeakImplHelper<
157 css::style::XStyle,
158 css::beans::XPropertySet,
159 css::beans::XMultiPropertySet,
160 css::beans::XPropertyState,
161 css::beans::XMultiPropertyStates,
162 css::lang::XServiceInfo >,
163 public SfxListener
165 private:
166 const SfxItemPropertySet* pPropSet;
167 ScDocShell* pDocShell;
168 SfxStyleFamily eFamily; // Family
169 OUString aStyleName;
170 SfxStyleSheetBase* pStyle_cached;
172 const SfxItemSet* GetStyleItemSet_Impl( const OUString& rPropName, const SfxItemPropertyMapEntry*& rpEntry );
173 /// @throws css::beans::UnknownPropertyException
174 /// @throws css::uno::RuntimeException
175 css::beans::PropertyState getPropertyState_Impl( const OUString& PropertyName );
176 /// @throws css::beans::UnknownPropertyException
177 /// @throws css::lang::WrappedTargetException
178 /// @throws css::uno::RuntimeException
179 css::uno::Any getPropertyDefault_Impl( const OUString& aPropertyName );
180 /// @throws css::beans::UnknownPropertyException
181 /// @throws css::lang::WrappedTargetException
182 /// @throws css::uno::RuntimeException
183 css::uno::Any getPropertyValue_Impl( const OUString& aPropertyName );
184 /// @throws css::lang::IllegalArgumentException
185 /// @throws css::uno::RuntimeException
186 void setPropertyValue_Impl( const OUString& rPropertyName,
187 const SfxItemPropertyMapEntry* pEntry,
188 const css::uno::Any* pValue );
190 public:
191 ScStyleObj() = delete;
192 ScStyleObj(ScDocShell* pDocSh, SfxStyleFamily eFam, OUString aName);
193 virtual ~ScStyleObj() override;
195 // created by getImplementation:
196 bool IsInserted() const { return pDocShell != nullptr; }
197 SfxStyleFamily GetFamily() const { return eFamily; }
198 void InitDoc( ScDocShell* pNewDocSh, const OUString& rNewName );
199 SfxStyleSheetBase* GetStyle_Impl( bool bUseCachedValue = false );
201 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
203 static css::uno::Reference< css::container::XIndexReplace >
204 CreateEmptyNumberingRules();
206 // XStyle
207 virtual sal_Bool SAL_CALL isUserDefined() override;
208 virtual sal_Bool SAL_CALL isInUse() override;
209 virtual OUString SAL_CALL getParentStyle() override;
210 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) override;
212 // XNamed
213 virtual OUString SAL_CALL getName() override;
214 virtual void SAL_CALL setName( const OUString& aName ) override;
216 // XPropertySet
217 virtual css::uno::Reference< css::beans::XPropertySetInfo >
218 SAL_CALL getPropertySetInfo() override;
219 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
220 const css::uno::Any& aValue ) override;
221 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
222 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
223 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
224 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
225 const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
226 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
227 const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
228 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
229 const css::uno::Reference<
230 css::beans::XVetoableChangeListener >& aListener ) override;
232 // XMultiPropertySet
233 virtual void SAL_CALL setPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames,
234 const css::uno::Sequence< css::uno::Any >& aValues ) override;
235 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
236 getPropertyValues( const css::uno::Sequence< OUString >& aPropertyNames ) override;
237 virtual void SAL_CALL addPropertiesChangeListener( const css::uno::Sequence< OUString >& aPropertyNames,
238 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
239 virtual void SAL_CALL removePropertiesChangeListener( const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
240 virtual void SAL_CALL firePropertiesChangeEvent( const css::uno::Sequence< OUString >& aPropertyNames,
241 const css::uno::Reference< css::beans::XPropertiesChangeListener >& xListener ) override;
243 // XPropertyState
244 virtual css::beans::PropertyState SAL_CALL getPropertyState(
245 const OUString& PropertyName ) override;
246 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL
247 getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
248 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
249 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
251 // XMultiPropertyStates
252 // getPropertyStates already defined for XPropertyState
253 virtual void SAL_CALL setAllPropertiesToDefault() override;
254 virtual void SAL_CALL setPropertiesToDefault( const css::uno::Sequence< OUString >& aPropertyNames ) override;
255 virtual css::uno::Sequence< css::uno::Any > SAL_CALL
256 getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override;
258 // XServiceInfo
259 virtual OUString SAL_CALL getImplementationName() override;
260 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
261 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
264 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */