android: Update app-specific/MIME type icons
[LibreOffice.git] / writerfilter / source / dmapper / NumberingManager.hxx
blob4bae58b8e51c6f507cfd1b479b174cd64adfbabb
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 "PropertyMap.hxx"
24 #include "DomainMapper.hxx"
25 #include "LoggedResources.hxx"
26 #include "StyleSheetTable.hxx"
28 #include <editeng/numitem.hxx>
30 #include <com/sun/star/container/XIndexReplace.hpp>
31 #include <com/sun/star/awt/XBitmap.hpp>
33 namespace writerfilter::dmapper {
35 class DomainMapper;
36 class StyleSheetEntry;
39 /** Class representing the numbering level properties.
41 class ListLevel : public PropertyMap
43 sal_Int32 m_nIStartAt; //LN_CT_Lvl_start
44 sal_Int32 m_nStartOverride;
45 sal_Int32 m_nNFC; //LN_CT_Lvl_numFmt
46 /// LN_CT_NumFmt_format, in case m_nNFC is custom.
47 OUString m_aCustomNumberFormat;
48 sal_Int16 m_nXChFollow; //LN_IXCHFOLLOW
49 std::optional<OUString> m_sBulletChar;
50 css::awt::Size m_aGraphicSize;
51 css::uno::Reference<css::awt::XBitmap> m_xGraphicBitmap;
52 std::optional<sal_Int32> m_nTabstop;
53 tools::SvRef< StyleSheetEntry > m_pParaStyle;
54 bool m_bHasValues = false;
56 public:
58 typedef tools::SvRef< ListLevel > Pointer;
60 ListLevel() :
61 m_nIStartAt(-1)
62 ,m_nStartOverride(-1)
63 ,m_nNFC(-1)
64 ,m_nXChFollow(SvxNumberFormat::LISTTAB)
67 // Setters for the import
68 void SetValue( Id nId, sal_Int32 nValue );
69 void SetCustomNumberFormat(const OUString& rValue);
70 void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
71 void SetGraphicSize( const css::awt::Size& aValue ) { m_aGraphicSize = aValue; };
73 void SetGraphicBitmap(css::uno::Reference<css::awt::XBitmap> const& xGraphicBitmap)
74 { m_xGraphicBitmap = xGraphicBitmap; }
75 void SetParaStyle( const tools::SvRef< StyleSheetEntry >& pStyle );
77 // Getters
78 sal_Int16 GetNumberingType(sal_Int16 nDefault) const;
79 bool HasBulletChar() const { return m_sBulletChar.has_value(); };
80 OUString GetBulletChar( ) const { return m_sBulletChar.has_value()? *m_sBulletChar : OUString(); };
81 const tools::SvRef< StyleSheetEntry >& GetParaStyle( ) const { return m_pParaStyle; };
82 sal_Int32 GetStartOverride() const { return m_nStartOverride; };
83 /// Determines if SetValue() was called at least once.
84 bool HasValues() const;
86 // UNO mapping functions
87 css::uno::Sequence<css::beans::PropertyValue> GetProperties(bool bDefaults);
89 css::uno::Sequence<css::beans::PropertyValue> GetCharStyleProperties();
90 private:
92 css::uno::Sequence<css::beans::PropertyValue> GetLevelProperties(bool bDefaults);
94 void AddParaProperties(css::uno::Sequence<css::beans::PropertyValue>* pProps);
97 /// Represents a numbering picture bullet: an id and a graphic.
98 class NumPicBullet final : public virtual SvRefBase
100 public:
101 typedef tools::SvRef<NumPicBullet> Pointer;
102 NumPicBullet();
103 ~NumPicBullet() override;
105 void SetId(sal_Int32 nId);
106 sal_Int32 GetId() const { return m_nId;}
107 void SetShape(css::uno::Reference<css::drawing::XShape> const& xShape);
108 const css::uno::Reference<css::drawing::XShape>& GetShape() const { return m_xShape; }
109 private:
110 sal_Int32 m_nId;
111 css::uno::Reference<css::drawing::XShape> m_xShape;
114 class AbstractListDef : public virtual SvRefBase
116 private:
117 // The ID member reflects either the abstractNumId or the numId
118 // depending on the use of the class
119 sal_Int32 m_nId;
121 // Properties of each level. This can also reflect the overridden
122 // levels of a numbering.
123 ::std::vector< ListLevel::Pointer > m_aLevels;
125 // Only used during the numbering import
126 ListLevel::Pointer m_pCurrentLevel;
128 // The style name linked to.
129 OUString m_sNumStyleLink;
131 // This abstract numbering is a base definition for this style
132 OUString m_sStyleLink;
134 /// list id to use for all derived numbering definitions
135 std::optional<OUString> m_oListId;
137 public:
138 typedef tools::SvRef< AbstractListDef > Pointer;
140 AbstractListDef( );
141 virtual ~AbstractListDef( ) override;
143 // Setters using during the import
144 void SetId( sal_Int32 nId ) { m_nId = nId; };
145 static void SetValue( sal_uInt32 nSprmId );
147 // Accessors
148 sal_Int32 GetId( ) const { return m_nId; };
150 sal_Int16 Size( ) { return sal_Int16( m_aLevels.size( ) ); };
151 ListLevel::Pointer GetLevel( sal_uInt16 nLvl );
152 void AddLevel( sal_uInt16 nLvl );
154 const ListLevel::Pointer& GetCurrentLevel( ) const { return m_pCurrentLevel; };
156 css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetPropertyValues(bool bDefaults);
158 void SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
159 const OUString& GetNumStyleLink() const { return m_sNumStyleLink; };
161 void SetStyleLink(const OUString& sValue) { m_sStyleLink = sValue; };
162 const OUString& GetStyleLink() const { return m_sStyleLink; };
164 const OUString& MapListId(OUString const& rId);
167 class ListDef : public AbstractListDef
169 private:
170 // Pointer to the abstract numbering
171 AbstractListDef::Pointer m_pAbstractDef;
173 // Cache for the UNO numbering rules
174 css::uno::Reference< css::container::XIndexReplace > m_xNumRules;
176 /// mapped list style name
177 OUString m_StyleName;
179 public:
180 typedef tools::SvRef< ListDef > Pointer;
182 ListDef( );
183 virtual ~ListDef( ) override;
185 // Accessors
186 void SetAbstractDefinition( AbstractListDef::Pointer pAbstract ) { m_pAbstractDef = pAbstract; };
187 const AbstractListDef::Pointer& GetAbstractDefinition( ) const { return m_pAbstractDef; };
189 // Mapping functions
190 const OUString & GetStyleName() const { return m_StyleName; };
191 const OUString & GetStyleName(sal_Int32 nId, css::uno::Reference<css::container::XNameContainer> const& xStyles);
193 css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetMergedPropertyValues();
195 sal_uInt16 GetChapterNumberingWeight() const;
196 void CreateNumberingRules(DomainMapper& rDMapper, css::uno::Reference<css::lang::XMultiServiceFactory> const& xFactory, sal_Int16 nOutline);
198 const css::uno::Reference<css::container::XIndexReplace>& GetNumberingRules() const { return m_xNumRules; }
202 /** This class provides access to the defined numbering styles.
204 class ListsManager :
205 public LoggedProperties,
206 public LoggedTable
208 private:
210 DomainMapper& m_rDMapper;
211 css::uno::Reference<css::lang::XMultiServiceFactory> m_xFactory;
213 // The numbering entries
214 std::vector< NumPicBullet::Pointer > m_aNumPicBullets;
215 std::vector< AbstractListDef::Pointer > m_aAbstractLists;
216 std::vector< ListDef::Pointer > m_aLists;
219 // These members are used for import only
220 AbstractListDef::Pointer m_pCurrentDefinition;
221 NumPicBullet::Pointer m_pCurrentNumPicBullet;
223 AbstractListDef::Pointer GetAbstractList( sal_Int32 nId );
225 // Properties
226 virtual void lcl_attribute( Id nName, Value & rVal ) override;
227 virtual void lcl_sprm(Sprm & sprm) override;
229 // Table
230 virtual void lcl_entry(writerfilter::Reference<Properties>::Pointer_t ref) override;
232 public:
234 ListsManager(DomainMapper& rDMapper, css::uno::Reference<css::lang::XMultiServiceFactory> xFactory);
235 virtual ~ListsManager() override;
237 typedef tools::SvRef< ListsManager > Pointer;
239 ListDef::Pointer GetList( sal_Int32 nId );
241 // Mapping methods
242 void CreateNumberingRules( );
244 // Dispose the NumPicBullets
245 void DisposeNumPicBullets( );
250 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */