android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / dmapper / StyleSheetTable.hxx
blob5cffd7d9d2a5071233892279e6502601ce0c59d2
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 .
19 #pragma once
21 #include <memory>
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
37 enum StyleType
39 STYLE_TYPE_UNKNOWN,
40 STYLE_TYPE_PARA,
41 STYLE_TYPE_CHAR,
42 STYLE_TYPE_TABLE,
43 STYLE_TYPE_LIST
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;
52 public:
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);
76 StyleSheetEntry();
77 StyleSheetEntry(StyleSheetEntry const&) = default;
78 virtual ~StyleSheetEntry() override;
81 typedef tools::SvRef<StyleSheetEntry> StyleSheetEntryPtr;
83 class DomainMapper;
84 class StyleSheetTable :
85 public LoggedProperties,
86 public LoggedTable
88 std::unique_ptr<StyleSheetTable_Impl> m_pImpl;
90 public:
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 ConvertStyleName( const OUString& rWWName, bool bExtendedSearch = false );
102 OUString CloneTOCStyle(FontTablePtr const& rFontTable, StyleSheetEntryPtr const pStyle, OUString const& rName);
103 void ApplyClonedTOCStyles();
105 OUString getOrCreateCharStyle( PropertyValueVector_t& rCharProperties, bool bAlwaysCreate );
107 void SetDefaultParaProps(PropertyIds eId, const css::uno::Any& rAny);
108 PropertyMapPtr const & GetDefaultParaProps() const;
109 /// Returns the default character properties.
110 PropertyMapPtr const & GetDefaultCharProps() const;
112 const StyleSheetEntryPtr & GetCurrentEntry() const;
114 private:
115 // Properties
116 virtual void lcl_attribute(Id Name, Value & val) override;
117 virtual void lcl_sprm(Sprm & sprm) override;
119 // Table
120 virtual void lcl_entry(writerfilter::Reference<Properties>::Pointer_t ref) override;
122 void applyDefaults(bool bParaProperties);
124 void ApplyStyleSheetsImpl(const FontTablePtr& rFontTable, std::vector<StyleSheetEntryPtr> const& rEntries);
128 class TableStyleSheetEntry :
129 public StyleSheetEntry
131 public:
132 // Adds a new tblStylePr to the table style entry. This method
133 // fixes some possible properties conflicts, like borders ones.
134 void AddTblStylePr( TblStyleType nType, const PropertyMapPtr& pProps );
136 // Gets all the properties
137 // + corresponding to the mask,
138 // + from the parent styles
140 // @param mask mask describing which properties to return
141 PropertyMapPtr GetProperties( sal_Int32 nMask);
143 TableStyleSheetEntry( StyleSheetEntry const & aEntry );
144 virtual ~TableStyleSheetEntry( ) override;
146 private:
147 typedef std::map<TblStyleType, PropertyMapPtr> TblStylePrs;
148 TblStylePrs m_aStyles;
149 PropertyMapPtr GetLocalPropertiesFromMask( sal_Int32 nMask );
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */