Version 7.5.1.1, tag libreoffice-7.5.1.1
[LibreOffice.git] / sd / inc / stlsheet.hxx
blobe830c097e990bafa25c47be7394154fe8d7c6f84
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 <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>
38 #include <memory>
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
55 public:
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 bool IsEditable();
68 void AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems = true);
70 SdStyleSheet* GetRealStyleSheet() const;
71 SdStyleSheet* GetPseudoStyleSheet() const;
73 void SetApiName( const OUString& rApiName );
74 OUString const & GetApiName() const;
76 static OUString GetFamilyString( SfxStyleFamily eFamily );
78 static rtl::Reference<SdStyleSheet> CreateEmptyUserStyle( SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily );
80 //Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
81 //which need to be explicitly broadcast as changing if their parent style was
82 //the one that changed
83 static void BroadcastSdStyleSheetChange(SfxStyleSheetBase const * pStyleSheet, PresentationObjects ePO,
84 SfxStyleSheetBasePool* pSSPool);
86 // SfxStyleSheetBase
87 virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
89 // XInterface
90 virtual void SAL_CALL release( ) noexcept override;
92 // XServiceInfo
93 virtual OUString SAL_CALL getImplementationName() override;
94 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
95 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
97 // XNamed
98 virtual OUString SAL_CALL getName( ) override;
99 virtual void SAL_CALL setName( const OUString& aName ) override;
101 // XStyle
102 virtual sal_Bool SAL_CALL isUserDefined( ) override;
103 virtual sal_Bool SAL_CALL isInUse( ) override;
104 virtual OUString SAL_CALL getParentStyle( ) override;
105 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) override;
107 // XPropertySet
108 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
109 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
110 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
111 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
112 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
113 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
114 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
116 // XMultiPropertySet
117 virtual void SAL_CALL setPropertyValues(const css::uno::Sequence<OUString>& aPropertyNames, const css::uno::Sequence<css::uno::Any>& aValues) override;
118 virtual css::uno::Sequence<css::uno::Any> SAL_CALL getPropertyValues(const css::uno::Sequence<OUString>& aPropertyNames) override;
119 virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence<OUString>& aPropertyNames, const css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
120 virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
121 virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence<OUString>& aPropertyNames, const css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
123 // XPropertyState
124 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
125 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
126 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
127 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
129 // XModifyBroadcaster
130 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
131 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
133 // XComponent
134 virtual void SAL_CALL dispose( ) override;
135 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
136 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
138 void notifyModifyListener();
140 private:
141 /// @throws css::uno::RuntimeException
142 static const SfxItemPropertyMapEntry* getPropertyMapEntry( std::u16string_view rPropertyName );
144 void setPropertyValue_Impl(const OUString& aPropertyName, const css::uno::Any& aValue);
145 css::uno::Any getPropertyValue_Impl(const OUString& PropertyName);
147 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
148 virtual ~SdStyleSheet() override;
150 /// @throws css::uno::RuntimeException
151 void throwIfDisposed();
153 void disposing();
155 OUString msApiName;
156 rtl::Reference< SfxStyleSheetBasePool > mxPool;
158 /** broadcast helper for events */
159 ::cppu::OBroadcastHelper mrBHelper;
161 std::unique_ptr< ModifyListenerForwarder > mpModifyListenerForwarder;
163 SdStyleSheet( const SdStyleSheet& ) = delete;
164 SdStyleSheet& operator=( const SdStyleSheet& ) = delete;
167 typedef std::vector< rtl::Reference< SdStyleSheet > > SdStyleSheetVector;
168 typedef std::vector< css::uno::Reference< css::style::XStyle > > XStyleVector;
170 struct StyleSheetCopyResult
172 rtl::Reference<SdStyleSheet> m_xStyleSheet;
173 bool m_bCreatedByCopy;
174 StyleSheetCopyResult(SdStyleSheet* pStyleSheet, bool bCreatedByCopy)
175 : m_xStyleSheet(pStyleSheet)
176 , m_bCreatedByCopy(bCreatedByCopy)
181 typedef std::vector<StyleSheetCopyResult> StyleSheetCopyResultVector;
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */