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 "TblStylePrHandler.hxx"
24 #include "DomainMapper.hxx"
25 #include <com/sun/star/beans/PropertyValues.hpp>
26 #include "PropertyMap.hxx"
27 #include "FontTable.hxx"
28 #include "LoggedResources.hxx"
30 namespace com::sun::star::text
{ class XTextDocument
; }
33 namespace writerfilter::dmapper
45 class StyleSheetTable
;
46 typedef tools::SvRef
<StyleSheetTable
> StyleSheetTablePtr
;
48 struct StyleSheetTable_Impl
;
49 class StyleSheetEntry
: public virtual SvRefBase
51 std::vector
<css::beans::PropertyValue
> m_aInteropGrabBag
;
53 OUString m_sStyleIdentifierD
; // WW8 name
54 bool m_bIsDefaultStyle
;
55 bool m_bAssignedAsChapterNumbering
;
56 bool m_bInvalidHeight
;
57 bool m_bHasUPE
; //universal property expansion
58 StyleType m_nStyleTypeCode
; //sgc
59 OUString m_sBaseStyleIdentifier
;
60 OUString m_sNextStyleIdentifier
;
61 OUString m_sLinkStyleIdentifier
;
62 OUString m_sStyleName
;
63 const tools::SvRef
<StyleSheetPropertyMap
> m_pProperties
;
64 OUString m_sConvertedStyleName
;
65 std::vector
<css::beans::PropertyValue
> m_aLatentStyles
; ///< Attributes of latentStyles
66 std::vector
<css::beans::PropertyValue
> m_aLsdExceptions
; ///< List of lsdException attribute lists
67 bool m_bAutoRedefine
; ///< Writer calls this auto-update.
69 void AppendInteropGrabBag(const css::beans::PropertyValue
& rValue
);
70 css::beans::PropertyValue
GetInteropGrabBag(); ///< Used for table styles, has a name.
71 css::beans::PropertyValues
GetInteropGrabBagSeq() const; ///< Used for existing styles, just a list of properties.
73 // Get all properties, merged with the all of the parent's properties
74 PropertyMapPtr
GetMergedInheritedProperties(const StyleSheetTablePtr
& pStyleSheetTable
);
77 StyleSheetEntry(StyleSheetEntry
const&) = default;
78 virtual ~StyleSheetEntry() override
;
81 typedef tools::SvRef
<StyleSheetEntry
> StyleSheetEntryPtr
;
84 class StyleSheetTable
:
85 public LoggedProperties
,
88 std::unique_ptr
<StyleSheetTable_Impl
> m_pImpl
;
91 StyleSheetTable(DomainMapper
& rDMapper
, css::uno::Reference
<css::text::XTextDocument
> const& xTextDocument
, bool bIsNewDoc
);
92 virtual ~StyleSheetTable() override
;
94 void ReApplyInheritedOutlineLevelFromChapterNumbering();
95 void ApplyNumberingStyleNameToParaStyles();
96 void ApplyStyleSheets( const FontTablePtr
& rFontTable
);
97 StyleSheetEntryPtr
FindStyleSheetByISTD(const OUString
& sIndex
);
98 StyleSheetEntryPtr
FindStyleSheetByConvertedStyleName(std::u16string_view rIndex
);
99 StyleSheetEntryPtr
FindDefaultParaStyle();
101 OUString
ConvertStyleNameExt(const OUString
& rWWName
);
102 static std::pair
<OUString
, bool> ConvertStyleName(const OUString
& rWWName
);
103 OUString
CloneTOCStyle(FontTablePtr
const& rFontTable
, StyleSheetEntryPtr
const pStyle
, OUString
const& rName
);
104 void ApplyClonedTOCStyles();
106 OUString
getOrCreateCharStyle( PropertyValueVector_t
& rCharProperties
, bool bAlwaysCreate
);
108 void SetDefaultParaProps(PropertyIds eId
, const css::uno::Any
& rAny
);
109 PropertyMapPtr
const & GetDefaultParaProps() const;
110 /// Returns the default character properties.
111 PropertyMapPtr
const & GetDefaultCharProps() const;
113 const StyleSheetEntryPtr
& GetCurrentEntry() const;
117 virtual void lcl_attribute(Id Name
, Value
& val
) override
;
118 virtual void lcl_sprm(Sprm
& sprm
) override
;
121 virtual void lcl_entry(writerfilter::Reference
<Properties
>::Pointer_t ref
) override
;
123 void applyDefaults(bool bParaProperties
);
125 void ApplyStyleSheetsImpl(const FontTablePtr
& rFontTable
, std::vector
<StyleSheetEntryPtr
> const& rEntries
);
129 class TableStyleSheetEntry
:
130 public StyleSheetEntry
133 // Adds a new tblStylePr to the table style entry. This method
134 // fixes some possible properties conflicts, like borders ones.
135 void AddTblStylePr( TblStyleType nType
, const PropertyMapPtr
& pProps
);
137 // Gets all the properties
138 // + corresponding to the mask,
139 // + from the parent styles
141 // @param mask mask describing which properties to return
142 PropertyMapPtr
GetProperties( sal_Int32 nMask
);
144 TableStyleSheetEntry( StyleSheetEntry
const & aEntry
);
145 virtual ~TableStyleSheetEntry( ) override
;
148 typedef std::map
<TblStyleType
, PropertyMapPtr
> TblStylePrs
;
149 TblStylePrs m_aStyles
;
150 PropertyMapPtr
GetLocalPropertiesFromMask( sal_Int32 nMask
);
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */