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 <rtl/ref.hxx>
24 #include <com/sun/star/style/XStyle.hpp>
25 #include <com/sun/star/beans/XMultiPropertySet.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/beans/XPropertyState.hpp>
29 #include <com/sun/star/lang/XComponent.hpp>
30 #include <com/sun/star/util/XModifyBroadcaster.hpp>
32 #include <comphelper/interfacecontainer4.hxx>
33 #include <cppuhelper/interfacecontainer.h>
34 #include <cppuhelper/implbase.hxx>
36 #include <svl/style.hxx>
41 #include "prlayout.hxx"
43 class ModifyListenerForwarder
;
44 struct SfxItemPropertyMapEntry
;
46 typedef cppu::ImplInheritanceHelper
< SfxUnoStyleSheet
,
47 css::beans::XPropertySet
,
48 css::beans::XMultiPropertySet
,
49 css::lang::XServiceInfo
,
50 css::beans::XPropertyState
,
51 css::util::XModifyBroadcaster
,
52 css::lang::XComponent
> SdStyleSheetBase
;
54 class SdStyleSheet final
: public SdStyleSheetBase
57 SdStyleSheet( const OUString
& rDisplayName
, SfxStyleSheetBasePool
& rPool
, SfxStyleFamily eFamily
,
58 SfxStyleSearchBits nMask
, const OUString
& rParentStyleSheetName
= u
""_ustr
);
60 virtual bool SetParent (const OUString
& rParentName
) override
;
61 virtual SfxItemSet
& GetItemSet() override
;
62 virtual bool IsUsed() const override
;
63 virtual bool HasFollowSupport() const override
;
64 virtual bool HasParentSupport() const override
;
65 virtual bool HasClearParentSupport() const override
;
66 virtual void SetHelpId( const OUString
& r
, sal_uInt32 nId
) override
;
70 void AdjustToFontHeight(SfxItemSet
& rSet
, bool bOnlyMissingItems
= true);
72 SdStyleSheet
* GetRealStyleSheet() const;
73 SdStyleSheet
* GetPseudoStyleSheet() const;
75 void SetApiName( const OUString
& rApiName
);
76 OUString
const & GetApiName() const;
78 static OUString
GetFamilyString( SfxStyleFamily eFamily
);
80 static rtl::Reference
<SdStyleSheet
> CreateEmptyUserStyle( SfxStyleSheetBasePool
& rPool
, SfxStyleFamily eFamily
);
82 //Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
83 //which need to be explicitly broadcast as changing if their parent style was
84 //the one that changed
85 static void BroadcastSdStyleSheetChange(SfxStyleSheetBase
const * pStyleSheet
, PresentationObjects ePO
,
86 SfxStyleSheetBasePool
* pSSPool
);
89 virtual bool SetName(const OUString
& rNewName
, bool bReindexNow
= true) 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
;
97 virtual OUString SAL_CALL
getName( ) override
;
98 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
101 virtual sal_Bool SAL_CALL
isUserDefined( ) override
;
102 virtual sal_Bool SAL_CALL
isInUse( ) override
;
103 virtual OUString SAL_CALL
getParentStyle( ) override
;
104 virtual void SAL_CALL
setParentStyle( const OUString
& aParentStyle
) override
;
107 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
108 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
109 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
110 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
111 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
112 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
113 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
116 virtual void SAL_CALL
setPropertyValues(const css::uno::Sequence
<OUString
>& aPropertyNames
, const css::uno::Sequence
<css::uno::Any
>& aValues
) override
;
117 virtual css::uno::Sequence
<css::uno::Any
> SAL_CALL
getPropertyValues(const css::uno::Sequence
<OUString
>& aPropertyNames
) override
;
118 virtual void SAL_CALL
addPropertiesChangeListener(const css::uno::Sequence
<OUString
>& aPropertyNames
, const css::uno::Reference
<css::beans::XPropertiesChangeListener
>& xListener
) override
;
119 virtual void SAL_CALL
removePropertiesChangeListener(const css::uno::Reference
<css::beans::XPropertiesChangeListener
>& xListener
) override
;
120 virtual void SAL_CALL
firePropertiesChangeEvent(const css::uno::Sequence
<OUString
>& aPropertyNames
, const css::uno::Reference
<css::beans::XPropertiesChangeListener
>& xListener
) override
;
123 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
124 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
125 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
126 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
128 // XModifyBroadcaster
129 virtual void SAL_CALL
addModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
130 virtual void SAL_CALL
removeModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
133 virtual void SAL_CALL
dispose( ) override
;
134 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
135 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
137 void notifyModifyListener();
140 /// @throws css::uno::RuntimeException
141 static const SfxItemPropertyMapEntry
* getPropertyMapEntry( const OUString
& rPropertyName
);
143 void setPropertyValue_Impl(const OUString
& aPropertyName
, const css::uno::Any
& aValue
);
144 css::uno::Any
getPropertyValue_Impl(const OUString
& PropertyName
);
146 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
147 virtual ~SdStyleSheet() override
;
149 /// @throws css::uno::RuntimeException
150 void throwIfDisposed();
154 mutable std::mutex m_aMutex
;
155 bool m_bDisposed
= false;
156 bool m_bInDispose
= false;
157 comphelper::OInterfaceContainerHelper4
<css::util::XModifyListener
> maModifyListeners
;
158 comphelper::OInterfaceContainerHelper4
<css::lang::XEventListener
> maEventListeners
;
160 rtl::Reference
< SfxStyleSheetBasePool
> mxPool
;
162 std::unique_ptr
< ModifyListenerForwarder
> mpModifyListenerForwarder
;
164 SdStyleSheet( const SdStyleSheet
& ) = delete;
165 SdStyleSheet
& operator=( const SdStyleSheet
& ) = delete;
168 typedef std::vector
< rtl::Reference
< SdStyleSheet
> > SdStyleSheetVector
;
169 typedef std::vector
< css::uno::Reference
< css::style::XStyle
> > XStyleVector
;
171 struct StyleSheetCopyResult
173 rtl::Reference
<SdStyleSheet
> m_xStyleSheet
;
174 bool m_bCreatedByCopy
;
175 StyleSheetCopyResult(SdStyleSheet
* pStyleSheet
, bool bCreatedByCopy
)
176 : m_xStyleSheet(pStyleSheet
)
177 , m_bCreatedByCopy(bCreatedByCopy
)
182 typedef std::vector
<StyleSheetCopyResult
> StyleSheetCopyResultVector
;
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */