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 <cppuhelper/interfacecontainer.h>
33 #include <cppuhelper/implbase.hxx>
34 #include <cppuhelper/basemutex.hxx>
36 #include <svl/style.hxx>
40 #include "prlayout.hxx"
42 class ModifyListenerForwarder
;
43 struct SfxItemPropertyMapEntry
;
45 typedef cppu::ImplInheritanceHelper
< SfxUnoStyleSheet
,
46 css::beans::XPropertySet
,
47 css::beans::XMultiPropertySet
,
48 css::lang::XServiceInfo
,
49 css::beans::XPropertyState
,
50 css::util::XModifyBroadcaster
,
51 css::lang::XComponent
> SdStyleSheetBase
;
53 class SdStyleSheet final
: public SdStyleSheetBase
, private ::cppu::BaseMutex
56 SdStyleSheet( const OUString
& rDisplayName
, SfxStyleSheetBasePool
& rPool
, SfxStyleFamily eFamily
, SfxStyleSearchBits nMask
);
58 virtual bool SetParent (const OUString
& rParentName
) override
;
59 virtual SfxItemSet
& GetItemSet() override
;
60 virtual bool IsUsed() const override
;
61 virtual bool HasFollowSupport() const override
;
62 virtual bool HasParentSupport() const override
;
63 virtual bool HasClearParentSupport() const override
;
64 virtual void SetHelpId( const OUString
& r
, sal_uLong nId
) override
;
66 void AdjustToFontHeight(SfxItemSet
& rSet
, bool bOnlyMissingItems
= true);
68 SdStyleSheet
* GetRealStyleSheet() const;
69 SdStyleSheet
* GetPseudoStyleSheet() const;
71 void SetApiName( const OUString
& rApiName
);
72 OUString
const & GetApiName() const;
74 static OUString
GetFamilyString( SfxStyleFamily eFamily
);
76 static rtl::Reference
<SdStyleSheet
> CreateEmptyUserStyle( SfxStyleSheetBasePool
& rPool
, SfxStyleFamily eFamily
);
78 //Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
79 //which need to be explicitly broadcast as changing if their parent style was
80 //the one that changed
81 static void BroadcastSdStyleSheetChange(SfxStyleSheetBase
const * pStyleSheet
, PresentationObjects ePO
,
82 SfxStyleSheetBasePool
* pSSPool
);
85 virtual bool SetName(const OUString
& rNewName
, bool bReindexNow
= true) override
;
88 virtual void SAL_CALL
release( ) noexcept 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
;
96 virtual OUString SAL_CALL
getName( ) override
;
97 virtual void SAL_CALL
setName( const OUString
& aName
) override
;
100 virtual sal_Bool SAL_CALL
isUserDefined( ) override
;
101 virtual sal_Bool SAL_CALL
isInUse( ) override
;
102 virtual OUString SAL_CALL
getParentStyle( ) override
;
103 virtual void SAL_CALL
setParentStyle( const OUString
& aParentStyle
) override
;
106 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
107 virtual void SAL_CALL
setPropertyValue( const OUString
& aPropertyName
, const css::uno::Any
& aValue
) override
;
108 virtual css::uno::Any SAL_CALL
getPropertyValue( const OUString
& PropertyName
) override
;
109 virtual void SAL_CALL
addPropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
) override
;
110 virtual void SAL_CALL
removePropertyChangeListener( const OUString
& aPropertyName
, const css::uno::Reference
< css::beans::XPropertyChangeListener
>& aListener
) override
;
111 virtual void SAL_CALL
addVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
112 virtual void SAL_CALL
removeVetoableChangeListener( const OUString
& PropertyName
, const css::uno::Reference
< css::beans::XVetoableChangeListener
>& aListener
) override
;
115 virtual void SAL_CALL
setPropertyValues(const css::uno::Sequence
<OUString
>& aPropertyNames
, const css::uno::Sequence
<css::uno::Any
>& aValues
) override
;
116 virtual css::uno::Sequence
<css::uno::Any
> SAL_CALL
getPropertyValues(const css::uno::Sequence
<OUString
>& aPropertyNames
) override
;
117 virtual void SAL_CALL
addPropertiesChangeListener(const css::uno::Sequence
<OUString
>& aPropertyNames
, const css::uno::Reference
<css::beans::XPropertiesChangeListener
>& xListener
) override
;
118 virtual void SAL_CALL
removePropertiesChangeListener(const css::uno::Reference
<css::beans::XPropertiesChangeListener
>& xListener
) override
;
119 virtual void SAL_CALL
firePropertiesChangeEvent(const css::uno::Sequence
<OUString
>& aPropertyNames
, const css::uno::Reference
<css::beans::XPropertiesChangeListener
>& xListener
) override
;
122 virtual css::beans::PropertyState SAL_CALL
getPropertyState( const OUString
& PropertyName
) override
;
123 virtual css::uno::Sequence
< css::beans::PropertyState
> SAL_CALL
getPropertyStates( const css::uno::Sequence
< OUString
>& aPropertyName
) override
;
124 virtual void SAL_CALL
setPropertyToDefault( const OUString
& PropertyName
) override
;
125 virtual css::uno::Any SAL_CALL
getPropertyDefault( const OUString
& aPropertyName
) override
;
127 // XModifyBroadcaster
128 virtual void SAL_CALL
addModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
129 virtual void SAL_CALL
removeModifyListener( const css::uno::Reference
< css::util::XModifyListener
>& aListener
) override
;
132 virtual void SAL_CALL
dispose( ) override
;
133 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
134 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
136 void notifyModifyListener();
139 /// @throws css::uno::RuntimeException
140 static const SfxItemPropertyMapEntry
* getPropertyMapEntry( std::u16string_view rPropertyName
);
142 void setPropertyValue_Impl(const OUString
& aPropertyName
, const css::uno::Any
& aValue
);
143 css::uno::Any
getPropertyValue_Impl(const OUString
& PropertyName
);
145 virtual void Notify(SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
146 virtual ~SdStyleSheet() override
;
148 /// @throws css::uno::RuntimeException
149 void throwIfDisposed();
154 rtl::Reference
< SfxStyleSheetBasePool
> mxPool
;
156 /** broadcast helper for events */
157 ::cppu::OBroadcastHelper mrBHelper
;
159 std::unique_ptr
< ModifyListenerForwarder
> mpModifyListenerForwarder
;
161 SdStyleSheet( const SdStyleSheet
& ) = delete;
162 SdStyleSheet
& operator=( const SdStyleSheet
& ) = delete;
165 typedef std::vector
< rtl::Reference
< SdStyleSheet
> > SdStyleSheetVector
;
167 struct StyleSheetCopyResult
169 rtl::Reference
<SdStyleSheet
> m_xStyleSheet
;
170 bool m_bCreatedByCopy
;
171 StyleSheetCopyResult(SdStyleSheet
* pStyleSheet
, bool bCreatedByCopy
)
172 : m_xStyleSheet(pStyleSheet
)
173 , m_bCreatedByCopy(bCreatedByCopy
)
178 typedef std::vector
<StyleSheetCopyResult
> StyleSheetCopyResultVector
;
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */