lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / writerfilter / source / dmapper / NumberingManager.hxx
blobf8e67f0fd6384e016b1cf5439b607c8b2354bb9f
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 #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_NUMBERINGMANAGER_HXX
21 #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_NUMBERINGMANAGER_HXX
23 #include "PropertyMap.hxx"
25 #include "DomainMapper.hxx"
26 #include "LoggedResources.hxx"
28 #include <editeng/numitem.hxx>
30 #include <com/sun/star/container/XIndexReplace.hpp>
31 #include <com/sun/star/graphic/XGraphic.hpp>
32 #include <com/sun/star/awt/XBitmap.hpp>
34 namespace writerfilter {
35 namespace dmapper {
37 class DomainMapper;
38 class StyleSheetEntry;
41 /** Class representing the numbering level properties.
43 class ListLevel : public PropertyMap
45 sal_Int32 m_nIStartAt; //LN_CT_Lvl_start
46 sal_Int32 m_nNFC; //LN_CT_Lvl_numFmt
47 sal_Int16 m_nXChFollow; //LN_IXCHFOLLOW
48 OUString m_sBulletChar;
49 css::awt::Size m_aGraphicSize;
50 css::uno::Reference<css::awt::XBitmap> m_xGraphicBitmap;
51 sal_Int32 m_nTabstop;
52 tools::SvRef< StyleSheetEntry > m_pParaStyle;
53 bool m_outline;
54 bool m_bHasValues = false;
56 public:
58 typedef tools::SvRef< ListLevel > Pointer;
60 ListLevel() :
61 m_nIStartAt(-1)
62 ,m_nNFC(-1)
63 ,m_nXChFollow(SvxNumberFormat::LISTTAB)
64 ,m_nTabstop( 0 )
65 ,m_outline(false)
68 // Setters for the import
69 void SetValue( Id nId, sal_Int32 nValue );
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 const OUString& GetBulletChar( ) { return m_sBulletChar; };
79 const tools::SvRef< StyleSheetEntry >& GetParaStyle( ) { return m_pParaStyle; };
80 bool isOutlineNumbering() const { return m_outline; }
81 /// Determines if SetValue() was called at least once.
82 bool HasValues() const;
84 // UNO mapping functions
86 // rPrefix and rSuffix are out parameters
87 static sal_Int16 GetParentNumbering( const OUString& sText, sal_Int16 nLevel,
88 OUString& rPrefix, OUString& rSuffix );
90 css::uno::Sequence<css::beans::PropertyValue> GetProperties(bool bDefaults);
92 css::uno::Sequence<css::beans::PropertyValue> GetCharStyleProperties();
93 private:
95 css::uno::Sequence<css::beans::PropertyValue> GetLevelProperties(bool bDefaults);
97 void AddParaProperties(css::uno::Sequence<css::beans::PropertyValue>* pProps);
100 /// Represents a numbering picture bullet: an id and a graphic.
101 class NumPicBullet final : public virtual SvRefBase
103 public:
104 typedef tools::SvRef<NumPicBullet> Pointer;
105 NumPicBullet();
106 ~NumPicBullet() override;
108 void SetId(sal_Int32 nId);
109 sal_Int32 GetId() { return m_nId;}
110 void SetShape(css::uno::Reference<css::drawing::XShape> const& xShape);
111 const css::uno::Reference<css::drawing::XShape>& GetShape() { return m_xShape; }
112 private:
113 sal_Int32 m_nId;
114 css::uno::Reference<css::drawing::XShape> m_xShape;
117 class AbstractListDef : public virtual SvRefBase
119 private:
120 // The ID member reflects either the abstractNumId or the numId
121 // depending on the use of the class
122 sal_Int32 m_nId;
124 // Properties of each level. This can also reflect the overridden
125 // levels of a numbering.
126 ::std::vector< ListLevel::Pointer > m_aLevels;
128 // Only used during the numberings import
129 ListLevel::Pointer m_pCurrentLevel;
131 // The style name linked to.
132 OUString m_sNumStyleLink;
134 public:
135 typedef tools::SvRef< AbstractListDef > Pointer;
137 AbstractListDef( );
138 virtual ~AbstractListDef( ) override;
140 // Setters using during the import
141 void SetId( sal_Int32 nId ) { m_nId = nId; };
142 static void SetValue( sal_uInt32 nSprmId );
144 // Accessors
145 sal_Int32 GetId( ) { return m_nId; };
147 sal_Int16 Size( ) { return sal_Int16( m_aLevels.size( ) ); };
148 ListLevel::Pointer GetLevel( sal_uInt16 nLvl );
149 void AddLevel( );
151 const ListLevel::Pointer& GetCurrentLevel( ) { return m_pCurrentLevel; };
153 css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetPropertyValues(bool bDefaults);
155 void SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
156 const OUString& GetNumStyleLink() { return m_sNumStyleLink; };
159 class ListDef : public AbstractListDef
161 private:
162 // Pointer to the abstract numbering
163 AbstractListDef::Pointer m_pAbstractDef;
165 // Cache for the UNO numbering rules
166 css::uno::Reference< css::container::XIndexReplace > m_xNumRules;
168 public:
169 typedef tools::SvRef< ListDef > Pointer;
171 ListDef( );
172 virtual ~ListDef( ) override;
174 // Accessors
175 void SetAbstractDefinition( AbstractListDef::Pointer pAbstract ) { m_pAbstractDef = pAbstract; };
176 const AbstractListDef::Pointer& GetAbstractDefinition( ) { return m_pAbstractDef; };
178 // Mapping functions
179 static OUString GetStyleName( sal_Int32 nId );
181 css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValue> > GetMergedPropertyValues();
183 void CreateNumberingRules(DomainMapper& rDMapper, css::uno::Reference<css::lang::XMultiServiceFactory> const& xFactory);
185 const css::uno::Reference<css::container::XIndexReplace>& GetNumberingRules() { return m_xNumRules; }
189 /** This class provides access to the defined numbering styles.
191 class ListsManager :
192 public LoggedProperties,
193 public LoggedTable
195 private:
197 DomainMapper& m_rDMapper;
198 css::uno::Reference<css::lang::XMultiServiceFactory> m_xFactory;
200 // The numbering entries
201 std::vector< NumPicBullet::Pointer > m_aNumPicBullets;
202 std::vector< AbstractListDef::Pointer > m_aAbstractLists;
203 std::vector< ListDef::Pointer > m_aLists;
206 // These members are used for import only
207 AbstractListDef::Pointer m_pCurrentDefinition;
208 NumPicBullet::Pointer m_pCurrentNumPicBullet;
210 AbstractListDef::Pointer GetAbstractList( sal_Int32 nId );
212 // Properties
213 virtual void lcl_attribute( Id nName, Value & rVal ) override;
214 virtual void lcl_sprm(Sprm & sprm) override;
216 // Table
217 virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) override;
219 public:
221 ListsManager(DomainMapper& rDMapper, const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory);
222 virtual ~ListsManager() override;
224 typedef tools::SvRef< ListsManager > Pointer;
226 ListDef::Pointer GetList( sal_Int32 nId );
228 // Mapping methods
229 void CreateNumberingRules( );
231 // Dispose the NumPicBullets
232 void DisposeNumPicBullets( );
237 #endif
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */