LibreOffice Module sd (master) 1
stlsheet.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <rtl/ref.hxx>
23
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>
31
35
36#include <svl/style.hxx>
37
38#include <memory>
39#include <mutex>
40
41#include "prlayout.hxx"
42
45
46typedef 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 ;
53
54class SdStyleSheet final : public SdStyleSheetBase
55{
56public:
57 SdStyleSheet( const OUString& rDisplayName, SfxStyleSheetBasePool& rPool, SfxStyleFamily eFamily, SfxStyleSearchBits nMask );
58
59 virtual bool SetParent (const OUString& rParentName) override;
60 virtual SfxItemSet& GetItemSet() override;
61 virtual bool IsUsed() const override;
62 virtual bool HasFollowSupport() const override;
63 virtual bool HasParentSupport() const override;
64 virtual bool HasClearParentSupport() const override;
65 virtual void SetHelpId( const OUString& r, sal_uLong nId ) override;
66
67 bool IsEditable();
68
69 void AdjustToFontHeight(SfxItemSet& rSet, bool bOnlyMissingItems = true);
70
73
74 void SetApiName( const OUString& rApiName );
75 OUString const & GetApiName() const;
76
77 static OUString GetFamilyString( SfxStyleFamily eFamily );
78
80
81 //Broadcast that a SdStyleSheet has changed, taking into account outline sublevels
82 //which need to be explicitly broadcast as changing if their parent style was
83 //the one that changed
84 static void BroadcastSdStyleSheetChange(SfxStyleSheetBase const * pStyleSheet, PresentationObjects ePO,
85 SfxStyleSheetBasePool* pSSPool);
86
87 // SfxStyleSheetBase
88 virtual bool SetName(const OUString& rNewName, bool bReindexNow = true) override;
89
90 // XInterface
91 virtual void SAL_CALL release( ) noexcept override;
92
93 // XServiceInfo
94 virtual OUString SAL_CALL getImplementationName() override;
95 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
96 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
97
98 // XNamed
99 virtual OUString SAL_CALL getName( ) override;
100 virtual void SAL_CALL setName( const OUString& aName ) override;
101
102 // XStyle
103 virtual sal_Bool SAL_CALL isUserDefined( ) override;
104 virtual sal_Bool SAL_CALL isInUse( ) override;
105 virtual OUString SAL_CALL getParentStyle( ) override;
106 virtual void SAL_CALL setParentStyle( const OUString& aParentStyle ) override;
107
108 // XPropertySet
109 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
110 virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName, const css::uno::Any& aValue ) override;
111 virtual css::uno::Any SAL_CALL getPropertyValue( const OUString& PropertyName ) override;
112 virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
113 virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
114 virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
115 virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
116
117 // XMultiPropertySet
118 virtual void SAL_CALL setPropertyValues(const css::uno::Sequence<OUString>& aPropertyNames, const css::uno::Sequence<css::uno::Any>& aValues) override;
119 virtual css::uno::Sequence<css::uno::Any> SAL_CALL getPropertyValues(const css::uno::Sequence<OUString>& aPropertyNames) override;
120 virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence<OUString>& aPropertyNames, const css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
121 virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
122 virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence<OUString>& aPropertyNames, const css::uno::Reference<css::beans::XPropertiesChangeListener>& xListener) override;
123
124 // XPropertyState
125 virtual css::beans::PropertyState SAL_CALL getPropertyState( const OUString& PropertyName ) override;
126 virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates( const css::uno::Sequence< OUString >& aPropertyName ) override;
127 virtual void SAL_CALL setPropertyToDefault( const OUString& PropertyName ) override;
128 virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
129
130 // XModifyBroadcaster
131 virtual void SAL_CALL addModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
132 virtual void SAL_CALL removeModifyListener( const css::uno::Reference< css::util::XModifyListener >& aListener ) override;
133
134 // XComponent
135 virtual void SAL_CALL dispose( ) override;
136 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
137 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
138
140
141private:
143 static const SfxItemPropertyMapEntry* getPropertyMapEntry( std::u16string_view rPropertyName );
144
145 void setPropertyValue_Impl(const OUString& aPropertyName, const css::uno::Any& aValue);
146 css::uno::Any getPropertyValue_Impl(const OUString& PropertyName);
147
148 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
149 virtual ~SdStyleSheet() override;
150
152 void throwIfDisposed();
153
154 void disposing();
155
156 mutable std::mutex m_aMutex;
157 bool m_bDisposed = false;
158 bool m_bInDispose = false;
161 OUString msApiName;
163
164 std::unique_ptr< ModifyListenerForwarder > mpModifyListenerForwarder;
165
166 SdStyleSheet( const SdStyleSheet& ) = delete;
168};
169
170typedef std::vector< rtl::Reference< SdStyleSheet > > SdStyleSheetVector;
171typedef std::vector< css::uno::Reference< css::style::XStyle > > XStyleVector;
172
174{
177 StyleSheetCopyResult(SdStyleSheet* pStyleSheet, bool bCreatedByCopy)
178 : m_xStyleSheet(pStyleSheet)
179 , m_bCreatedByCopy(bCreatedByCopy)
180 {
181 }
182};
183
184typedef std::vector<StyleSheetCopyResult> StyleSheetCopyResultVector;
185
186/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: stlsheet.cxx:832
virtual OUString SAL_CALL getImplementationName() override
Definition: stlsheet.cxx:867
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: stlsheet.cxx:877
void disposing()
Definition: stlsheet.cxx:797
OUString msApiName
Definition: stlsheet.hxx:161
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &PropertyName) override
Definition: stlsheet.cxx:1285
bool m_bInDispose
Definition: stlsheet.hxx:158
void notifyModifyListener()
Definition: stlsheet.cxx:855
virtual void SAL_CALL addPropertiesChangeListener(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: stlsheet.cxx:1279
SdStyleSheet(const SdStyleSheet &)=delete
OUString const & GetApiName() const
Definition: stlsheet.cxx:161
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: stlsheet.cxx:849
virtual OUString SAL_CALL getName() override
Definition: stlsheet.cxx:904
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: stlsheet.cxx:1219
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: stlsheet.cxx:809
void throwIfDisposed()
Definition: stlsheet.cxx:710
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: stlsheet.cxx:872
SdStyleSheet * GetRealStyleSheet() const
Determine the style sheet for which this dummy is for.
Definition: stlsheet.cxx:360
virtual void SAL_CALL setName(const OUString &aName) override
Definition: stlsheet.cxx:911
virtual void SAL_CALL setPropertyToDefault(const OUString &PropertyName) override
Definition: stlsheet.cxx:1447
virtual void SetHelpId(const OUString &r, sal_uLong nId) override
Definition: stlsheet.cxx:687
virtual void SAL_CALL firePropertiesChangeEvent(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: stlsheet.cxx:1281
SdStyleSheet * GetPseudoStyleSheet() const
Determine pseudo style sheet which stands for this style sheet.
Definition: stlsheet.cxx:466
SdStyleSheet(const OUString &rDisplayName, SfxStyleSheetBasePool &rPool, SfxStyleFamily eFamily, SfxStyleSearchBits nMask)
Definition: stlsheet.cxx:143
static OUString GetFamilyString(SfxStyleFamily eFamily)
Definition: stlsheet.cxx:696
virtual bool SetParent(const OUString &rParentName) override
Definition: stlsheet.cxx:169
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: stlsheet.cxx:1229
virtual bool HasParentSupport() const override
Definition: stlsheet.cxx:600
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition: stlsheet.cxx:1264
virtual void SAL_CALL setParentStyle(const OUString &aParentStyle) override
Definition: stlsheet.cxx:948
bool IsEditable()
Checks if a cell style is used in two places at once.
Definition: stlsheet.cxx:331
comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > maEventListeners
Definition: stlsheet.hxx:160
virtual bool SetName(const OUString &rNewName, bool bReindexNow=true) override
Definition: stlsheet.cxx:891
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: stlsheet.cxx:515
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &aPropertyName) override
Definition: stlsheet.cxx:1431
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: stlsheet.cxx:1210
virtual void SAL_CALL removePropertiesChangeListener(const css::uno::Reference< css::beans::XPropertiesChangeListener > &xListener) override
Definition: stlsheet.cxx:1280
virtual SfxItemSet & GetItemSet() override
create if necessary and return ItemSets
Definition: stlsheet.cxx:207
virtual void SAL_CALL setPropertyValues(const css::uno::Sequence< OUString > &aPropertyNames, const css::uno::Sequence< css::uno::Any > &aValues) override
Definition: stlsheet.cxx:1234
virtual void SAL_CALL dispose() override
Definition: stlsheet.cxx:753
comphelper::OInterfaceContainerHelper4< css::util::XModifyListener > maModifyListeners
Definition: stlsheet.hxx:159
virtual sal_Bool SAL_CALL isUserDefined() override
Definition: stlsheet.cxx:920
void AdjustToFontHeight(SfxItemSet &rSet, bool bOnlyMissingItems=true)
Adjust the bullet width and the left text indent of the provided ItemSets to their font height.
Definition: stlsheet.cxx:541
std::mutex m_aMutex
Definition: stlsheet.hxx:156
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: stlsheet.cxx:1230
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: stlsheet.cxx:1203
static rtl::Reference< SdStyleSheet > CreateEmptyUserStyle(SfxStyleSheetBasePool &rPool, SfxStyleFamily eFamily)
Definition: stlsheet.cxx:716
virtual ~SdStyleSheet() override
Definition: stlsheet.cxx:150
void setPropertyValue_Impl(const OUString &aPropertyName, const css::uno::Any &aValue)
Definition: stlsheet.cxx:990
css::uno::Any getPropertyValue_Impl(const OUString &PropertyName)
Definition: stlsheet.cxx:1088
SdStyleSheet & operator=(const SdStyleSheet &)=delete
void SetApiName(const OUString &rApiName)
Definition: stlsheet.cxx:156
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: stlsheet.cxx:1228
virtual bool HasFollowSupport() const override
Definition: stlsheet.cxx:595
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: stlsheet.cxx:824
virtual bool IsUsed() const override
A template is used when it is referenced by inserted object or by a used template.
Definition: stlsheet.cxx:282
rtl::Reference< SfxStyleSheetBasePool > mxPool
Definition: stlsheet.hxx:162
virtual OUString SAL_CALL getParentStyle() override
Definition: stlsheet.cxx:934
virtual bool HasClearParentSupport() const override
Definition: stlsheet.cxx:605
virtual sal_Bool SAL_CALL isInUse() override
Definition: stlsheet.cxx:927
static void BroadcastSdStyleSheetChange(SfxStyleSheetBase const *pStyleSheet, PresentationObjects ePO, SfxStyleSheetBasePool *pSSPool)
Definition: stlsheet.cxx:1512
std::unique_ptr< ModifyListenerForwarder > mpModifyListenerForwarder
Definition: stlsheet.hxx:164
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: stlsheet.cxx:1227
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &aPropertyName) override
Definition: stlsheet.cxx:1471
static const SfxItemPropertyMapEntry * getPropertyMapEntry(std::u16string_view rPropertyName)
this is used because our property map is not sorted yet
Definition: stlsheet.cxx:1504
virtual void SAL_CALL release() noexcept override
Definition: stlsheet.cxx:731
bool m_bDisposed
Definition: stlsheet.hxx:157
OUString aName
sal_Int16 nId
PresentationObjects
Definition: prlayout.hxx:29
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
std::vector< css::uno::Reference< css::style::XStyle > > XStyleVector
Definition: stlsheet.hxx:171
std::vector< rtl::Reference< SdStyleSheet > > SdStyleSheetVector
Definition: stlsheet.hxx:170
std::vector< StyleSheetCopyResult > StyleSheetCopyResultVector
Definition: stlsheet.hxx:184
cppu::ImplInheritanceHelper< SfxUnoStyleSheet, css::beans::XPropertySet, css::beans::XMultiPropertySet, css::lang::XServiceInfo, css::beans::XPropertyState, css::util::XModifyBroadcaster, css::lang::XComponent > SdStyleSheetBase
Definition: stlsheet.hxx:44
rtl::Reference< SdStyleSheet > m_xStyleSheet
Definition: stlsheet.hxx:175
StyleSheetCopyResult(SdStyleSheet *pStyleSheet, bool bCreatedByCopy)
Definition: stlsheet.hxx:177
SfxStyleFamily
SfxStyleSearchBits
unsigned char sal_Bool