LibreOffice Module writerfilter (master) 1
NumberingManager.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 "PropertyMap.hxx"
23
24#include "DomainMapper.hxx"
25#include "LoggedResources.hxx"
26#include "StyleSheetTable.hxx"
27
28#include <editeng/numitem.hxx>
29
30#include <com/sun/star/container/XIndexReplace.hpp>
31#include <com/sun/star/awt/XBitmap.hpp>
32
33namespace writerfilter::dmapper {
34
35class DomainMapper;
36class StyleSheetEntry;
37
38
41class ListLevel : public PropertyMap
42{
43 sal_Int32 m_nIStartAt; //LN_CT_Lvl_start
45 sal_Int32 m_nNFC; //LN_CT_Lvl_numFmt
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;
54 bool m_bHasValues = false;
55 bool m_bIsLegal = false;
56
57public:
58
60
62 m_nIStartAt(-1)
64 ,m_nNFC(-1)
66 {}
67
68 // Setters for the import
69 void SetValue( Id nId, sal_Int32 nValue );
70 void SetCustomNumberFormat(const OUString& rValue);
71 void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
72 void SetGraphicSize( const css::awt::Size& aValue ) { m_aGraphicSize = aValue; };
73
74 void SetGraphicBitmap(css::uno::Reference<css::awt::XBitmap> const& xGraphicBitmap)
75 { m_xGraphicBitmap = xGraphicBitmap; }
77
78 // Getters
79 sal_Int16 GetNumberingType(sal_Int16 nDefault) const;
80 bool HasBulletChar() const { return m_sBulletChar.has_value(); };
81 OUString GetBulletChar( ) const { return m_sBulletChar.has_value()? *m_sBulletChar : OUString(); };
83 sal_Int32 GetStartOverride() const { return m_nStartOverride; };
85 bool HasValues() const;
86
87 // UNO mapping functions
88 css::uno::Sequence<css::beans::PropertyValue> GetProperties(bool bDefaults);
89
90 css::uno::Sequence<css::beans::PropertyValue> GetCharStyleProperties();
91private:
92
93 css::uno::Sequence<css::beans::PropertyValue> GetLevelProperties(bool bDefaults);
94
95 void AddParaProperties(css::uno::Sequence<css::beans::PropertyValue>* pProps);
96};
97
99class NumPicBullet final : public virtual SvRefBase
100{
101public:
103 NumPicBullet();
104 ~NumPicBullet() override;
105
106 void SetId(sal_Int32 nId);
107 sal_Int32 GetId() const { return m_nId;}
108 void SetShape(css::uno::Reference<css::drawing::XShape> const& xShape);
109 const css::uno::Reference<css::drawing::XShape>& GetShape() const { return m_xShape; }
110private:
111 sal_Int32 m_nId;
112 css::uno::Reference<css::drawing::XShape> m_xShape;
113};
114
115class AbstractListDef : public virtual SvRefBase
116{
117private:
118 // The ID member reflects either the abstractNumId or the numId
119 // depending on the use of the class
120 sal_Int32 m_nId;
121
122 // Properties of each level. This can also reflect the overridden
123 // levels of a numbering.
124 ::std::vector< ListLevel::Pointer > m_aLevels;
125
126 // Only used during the numbering import
128
129 // The style name linked to.
131
132 // This abstract numbering is a base definition for this style
133 OUString m_sStyleLink;
134
136 std::optional<OUString> m_oListId;
137
138public:
140
142 virtual ~AbstractListDef( ) override;
143
144 // Setters using during the import
145 void SetId( sal_Int32 nId ) { m_nId = nId; };
146 static void SetValue( sal_uInt32 nSprmId );
147
148 // Accessors
149 sal_Int32 GetId( ) const { return m_nId; };
150
151 sal_Int16 Size( ) { return sal_Int16( m_aLevels.size( ) ); };
152 ListLevel::Pointer GetLevel( sal_uInt16 nLvl );
153 void AddLevel( sal_uInt16 nLvl );
154
156
157 css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetPropertyValues(bool bDefaults);
158
159 void SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
160 const OUString& GetNumStyleLink() const { return m_sNumStyleLink; };
161
162 void SetStyleLink(const OUString& sValue) { m_sStyleLink = sValue; };
163 const OUString& GetStyleLink() const { return m_sStyleLink; };
164
165 const OUString& MapListId(OUString const& rId);
166};
167
169{
170private:
171 // Pointer to the abstract numbering
173
174 // Cache for the UNO numbering rules
175 css::uno::Reference< css::container::XIndexReplace > m_xNumRules;
176
178 OUString m_StyleName;
179
180public:
182
183 ListDef( );
184 virtual ~ListDef( ) override;
185
186 // Accessors
189
190 // Mapping functions
191 const OUString & GetStyleName() const { return m_StyleName; };
192 const OUString & GetStyleName(sal_Int32 nId, css::uno::Reference<css::container::XNameContainer> const& xStyles);
193
194 css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetMergedPropertyValues();
195
196 sal_uInt16 GetChapterNumberingWeight() const;
197 void CreateNumberingRules(DomainMapper& rDMapper, css::uno::Reference<css::lang::XMultiServiceFactory> const& xFactory, sal_Int16 nOutline);
198
199 const css::uno::Reference<css::container::XIndexReplace>& GetNumberingRules() const { return m_xNumRules; }
200
201};
202
206 public LoggedProperties,
207 public LoggedTable
208{
209private:
210
212 css::uno::Reference<css::lang::XMultiServiceFactory> m_xFactory;
213
214 // The numbering entries
215 std::vector< NumPicBullet::Pointer > m_aNumPicBullets;
216 std::vector< AbstractListDef::Pointer > m_aAbstractLists;
217 std::vector< ListDef::Pointer > m_aLists;
218
219
220 // These members are used for import only
223
225
226 // Properties
227 virtual void lcl_attribute( Id nName, Value & rVal ) override;
228 virtual void lcl_sprm(Sprm & sprm) override;
229
230 // Table
232
233public:
234
235 ListsManager(DomainMapper& rDMapper, css::uno::Reference<css::lang::XMultiServiceFactory> xFactory);
236 virtual ~ListsManager() override;
237
239
240 ListDef::Pointer GetList( sal_Int32 nId );
241
242 // Mapping methods
243 void CreateNumberingRules( );
244
245 // Dispose the NumPicBullets
246 void DisposeNumPicBullets( );
247};
248
249}
250
251/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void sprm(Sprm &sprm) override
Receives a SPRM.
An SPRM: Section, Paragraph and Run Modifier.
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetPropertyValues(bool bDefaults)
static void SetValue(sal_uInt32 nSprmId)
void SetNumStyleLink(const OUString &sValue)
tools::SvRef< AbstractListDef > Pointer
void SetStyleLink(const OUString &sValue)
::std::vector< ListLevel::Pointer > m_aLevels
ListLevel::Pointer GetLevel(sal_uInt16 nLvl)
std::optional< OUString > m_oListId
list id to use for all derived numbering definitions
const ListLevel::Pointer & GetCurrentLevel() const
const OUString & MapListId(OUString const &rId)
void SetAbstractDefinition(AbstractListDef::Pointer pAbstract)
sal_uInt16 GetChapterNumberingWeight() const
Rank the list in terms of suitability for becoming the Outline numbering rule in LO.
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetMergedPropertyValues()
void CreateNumberingRules(DomainMapper &rDMapper, css::uno::Reference< css::lang::XMultiServiceFactory > const &xFactory, sal_Int16 nOutline)
const OUString & GetStyleName(sal_Int32 nId, css::uno::Reference< css::container::XNameContainer > const &xStyles)
tools::SvRef< ListDef > Pointer
const OUString & GetStyleName() const
AbstractListDef::Pointer m_pAbstractDef
const css::uno::Reference< css::container::XIndexReplace > & GetNumberingRules() const
css::uno::Reference< css::container::XIndexReplace > m_xNumRules
const AbstractListDef::Pointer & GetAbstractDefinition() const
OUString m_StyleName
mapped list style name
Class representing the numbering level properties.
tools::SvRef< StyleSheetEntry > m_pParaStyle
css::uno::Reference< css::awt::XBitmap > m_xGraphicBitmap
std::optional< sal_Int32 > m_nTabstop
sal_Int16 GetNumberingType(sal_Int16 nDefault) const
void SetCustomNumberFormat(const OUString &rValue)
css::uno::Sequence< css::beans::PropertyValue > GetProperties(bool bDefaults)
css::uno::Sequence< css::beans::PropertyValue > GetCharStyleProperties()
void SetBulletChar(const OUString &sValue)
css::uno::Sequence< css::beans::PropertyValue > GetLevelProperties(bool bDefaults)
OUString m_aCustomNumberFormat
LN_CT_NumFmt_format, in case m_nNFC is custom.
void SetGraphicBitmap(css::uno::Reference< css::awt::XBitmap > const &xGraphicBitmap)
const tools::SvRef< StyleSheetEntry > & GetParaStyle() const
void SetParaStyle(const tools::SvRef< StyleSheetEntry > &pStyle)
tools::SvRef< ListLevel > Pointer
void AddParaProperties(css::uno::Sequence< css::beans::PropertyValue > *pProps)
std::optional< OUString > m_sBulletChar
void SetValue(Id nId, sal_Int32 nValue)
void SetGraphicSize(const css::awt::Size &aValue)
bool HasValues() const
Determines if SetValue() was called at least once.
This class provides access to the defined numbering styles.
virtual void lcl_attribute(Id nName, Value &rVal) override
std::vector< NumPicBullet::Pointer > m_aNumPicBullets
NumPicBullet::Pointer m_pCurrentNumPicBullet
std::vector< AbstractListDef::Pointer > m_aAbstractLists
std::vector< ListDef::Pointer > m_aLists
ListDef::Pointer GetList(sal_Int32 nId)
AbstractListDef::Pointer m_pCurrentDefinition
virtual void lcl_sprm(Sprm &sprm) override
ListsManager(DomainMapper &rDMapper, css::uno::Reference< css::lang::XMultiServiceFactory > xFactory)
AbstractListDef::Pointer GetAbstractList(sal_Int32 nId)
tools::SvRef< ListsManager > Pointer
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory
virtual void lcl_entry(writerfilter::Reference< Properties >::Pointer_t ref) override
Represents a numbering picture bullet: an id and a graphic.
const css::uno::Reference< css::drawing::XShape > & GetShape() const
css::uno::Reference< css::drawing::XShape > m_xShape
tools::SvRef< NumPicBullet > Pointer
void SetShape(css::uno::Reference< css::drawing::XShape > const &xShape)
sal_Int16 nId
sal_uInt32 Id