Line data Source code
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 : #ifndef INCLUDED_NUMBERINGMANAGER_HXX
21 : #define INCLUDED_NUMBERINGMANAGER_HXX
22 :
23 : #include "PropertyMap.hxx"
24 :
25 : #include <dmapper/DomainMapper.hxx>
26 : #include <resourcemodel/LoggedResources.hxx>
27 :
28 : #include <editeng/numitem.hxx>
29 :
30 : #include <com/sun/star/container/XIndexReplace.hpp>
31 : #include <com/sun/star/graphic/XGraphic.hpp>
32 :
33 : namespace writerfilter {
34 : namespace dmapper {
35 :
36 : class DomainMapper;
37 : class StyleSheetEntry;
38 :
39 :
40 : /** Class representing the numbering level properties.
41 : */
42 : class ListLevel : public PropertyMap
43 : {
44 : sal_Int32 m_nIStartAt; //LN_CT_Lvl_start
45 : sal_Int32 m_nNFC; //LN_CT_Lvl_numFmt
46 : sal_Int32 m_nJC; //LN_JC
47 : sal_Int32 m_nFLegal; //LN_FLEGAL
48 : sal_Int32 m_nFPrev; //LN_FPREV
49 : sal_Int32 m_nFPrevSpace; //LN_FPREVSPACE
50 : sal_Int32 m_nFWord6; //LN_FWORD6
51 : OUString m_sRGBXchNums; //LN_RGBXCHNUMS
52 : sal_Int16 m_nXChFollow; //LN_IXCHFOLLOW
53 : OUString m_sBulletChar;
54 : OUString m_sGraphicURL;
55 : com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > m_sGraphicBitmap;
56 : sal_Int32 m_nTabstop;
57 : boost::shared_ptr< StyleSheetEntry > m_pParaStyle;
58 : bool m_outline;
59 :
60 : public:
61 :
62 : typedef boost::shared_ptr< ListLevel > Pointer;
63 :
64 0 : ListLevel() :
65 : m_nIStartAt(-1)
66 : ,m_nNFC(-1)
67 : ,m_nJC(-1)
68 : ,m_nFLegal(-1)
69 : ,m_nFPrev(-1)
70 : ,m_nFPrevSpace(-1)
71 : ,m_nFWord6(-1)
72 : ,m_nXChFollow(SvxNumberFormat::LISTTAB)
73 : ,m_nTabstop( 0 )
74 0 : ,m_outline(false)
75 0 : {}
76 :
77 0 : virtual ~ListLevel( ){ }
78 :
79 : // Setters for the import
80 : void SetValue( Id nId, sal_Int32 nValue );
81 0 : void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
82 0 : void SetGraphicURL( const OUString& sValue ) { m_sGraphicURL = sValue; };
83 0 : void SetGraphicBitmap( com::sun::star::uno::Reference< com::sun::star::graphic::XGraphic > sValue )
84 0 : { m_sGraphicBitmap = sValue; }
85 : void SetParaStyle( boost::shared_ptr< StyleSheetEntry > pStyle );
86 : void AddRGBXchNums( const OUString& sValue ) { m_sRGBXchNums += sValue; };
87 :
88 : // Getters
89 0 : OUString GetBulletChar( ) { return m_sBulletChar; };
90 0 : boost::shared_ptr< StyleSheetEntry > GetParaStyle( ) { return m_pParaStyle; };
91 0 : bool isOutlineNumbering() const { return m_outline; }
92 :
93 : // UNO mapping functions
94 :
95 : // rPrefix and rSuffix are out parameters
96 : static sal_Int16 GetParentNumbering( const OUString& sText, sal_Int16 nLevel,
97 : OUString& rPrefix, OUString& rSuffix );
98 :
99 : com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
100 : GetProperties( );
101 :
102 : com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue>
103 : GetCharStyleProperties( );
104 : private:
105 :
106 : com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >
107 : GetLevelProperties( );
108 :
109 : void AddParaProperties( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* props );
110 : };
111 :
112 : /// Represents a numbering picture bullet: an id and a graphic.
113 : class NumPicBullet
114 : {
115 : public:
116 : typedef boost::shared_ptr<NumPicBullet> Pointer;
117 : NumPicBullet();
118 : virtual ~NumPicBullet();
119 :
120 : void SetId(sal_Int32 nId);
121 : sal_Int32 GetId();
122 : void SetShape(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape);
123 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> GetShape();
124 : private:
125 : sal_Int32 m_nId;
126 : com::sun::star::uno::Reference<com::sun::star::drawing::XShape> m_xShape;
127 : };
128 :
129 : class AbstractListDef
130 : {
131 : private:
132 : sal_Int32 m_nTmpl;
133 : OUString m_sRGISTD; //LN_RGISTD
134 :
135 : // The ID member reflects either the abstractNumId or the numId
136 : // depending on the use of the class
137 : sal_Int32 m_nId;
138 :
139 : // Properties of each level. This can also reflect the overridden
140 : // levels of a numbering.
141 : ::std::vector< ListLevel::Pointer > m_aLevels;
142 :
143 : // Only used during the numberings import
144 : ListLevel::Pointer m_pCurrentLevel;
145 :
146 : // The style name linked to.
147 : ::rtl::OUString m_sNumStyleLink;
148 :
149 : public:
150 : typedef boost::shared_ptr< AbstractListDef > Pointer;
151 :
152 : AbstractListDef( );
153 : virtual ~AbstractListDef( );
154 :
155 : // Setters using during the import
156 0 : void SetId( sal_Int32 nId ) { m_nId = nId; };
157 : void SetValue( sal_uInt32 nSprmId, sal_Int32 nValue );
158 : void AddRGISTD( const OUString& sValue ) { m_sRGISTD += sValue; };
159 :
160 : // Accessors
161 0 : sal_Int32 GetId( ) { return m_nId; };
162 :
163 0 : sal_Int16 Size( ) { return sal_Int16( m_aLevels.size( ) ); };
164 : ListLevel::Pointer GetLevel( sal_uInt16 nLvl );
165 : void AddLevel( );
166 :
167 0 : ListLevel::Pointer GetCurrentLevel( ) { return m_pCurrentLevel; };
168 :
169 : virtual com::sun::star::uno::Sequence<
170 : com::sun::star::uno::Sequence<
171 : com::sun::star::beans::PropertyValue > > GetPropertyValues( );
172 :
173 0 : void SetNumStyleLink(const OUString& sValue) { m_sNumStyleLink = sValue; };
174 0 : OUString GetNumStyleLink() { return m_sNumStyleLink; };
175 : };
176 :
177 : class ListDef : public AbstractListDef
178 : {
179 : private:
180 : // Pointer to the abstract numbering
181 : AbstractListDef::Pointer m_pAbstractDef;
182 :
183 : // Cache for the UNO numbering rules
184 : uno::Reference< container::XIndexReplace > m_xNumRules;
185 :
186 : public:
187 : typedef boost::shared_ptr< ListDef > Pointer;
188 :
189 : ListDef( );
190 : virtual ~ListDef( );
191 :
192 : // Accessors
193 0 : void SetAbstractDefinition( AbstractListDef::Pointer pAbstract ) { m_pAbstractDef = pAbstract; };
194 0 : AbstractListDef::Pointer GetAbstractDefinition( ) { return m_pAbstractDef; };
195 :
196 : // Mapping functions
197 : static OUString GetStyleName( sal_Int32 nId );
198 :
199 : com::sun::star::uno::Sequence<
200 : com::sun::star::uno::Sequence<
201 : com::sun::star::beans::PropertyValue > > GetPropertyValues( ) SAL_OVERRIDE;
202 :
203 : void CreateNumberingRules(
204 : DomainMapper& rDMapper,
205 : com::sun::star::uno::Reference<
206 : com::sun::star::lang::XMultiServiceFactory> xFactory );
207 :
208 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexReplace >
209 0 : GetNumberingRules( ) { return m_xNumRules; };
210 :
211 : };
212 :
213 : /** This class provides access to the defined numbering styles.
214 : */
215 : class ListsManager :
216 : public LoggedProperties,
217 : public LoggedTable
218 : {
219 : private:
220 :
221 : DomainMapper& m_rDMapper;
222 : com::sun::star::uno::Reference<
223 : com::sun::star::lang::XMultiServiceFactory > m_xFactory;
224 :
225 : // The numbering entries
226 : std::vector< NumPicBullet::Pointer > m_aNumPicBullets;
227 : std::vector< AbstractListDef::Pointer > m_aAbstractLists;
228 : std::vector< ListDef::Pointer > m_aLists;
229 :
230 :
231 : // These members are used for import only
232 : AbstractListDef::Pointer m_pCurrentDefinition;
233 : NumPicBullet::Pointer m_pCurrentNumPicBullet;
234 : bool m_bIsLFOImport;
235 :
236 : AbstractListDef::Pointer GetAbstractList( sal_Int32 nId );
237 :
238 : // Properties
239 : virtual void lcl_attribute( Id nName, Value & rVal ) SAL_OVERRIDE;
240 : virtual void lcl_sprm(Sprm & sprm) SAL_OVERRIDE;
241 :
242 : // Table
243 : virtual void lcl_entry(int pos, writerfilter::Reference<Properties>::Pointer_t ref) SAL_OVERRIDE;
244 :
245 : public:
246 :
247 : ListsManager(
248 : DomainMapper& rDMapper,
249 : const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory);
250 : virtual ~ListsManager();
251 :
252 : typedef boost::shared_ptr< ListsManager > Pointer;
253 :
254 : // Config methods
255 : void SetLFOImport( bool bLFOImport ) { m_bIsLFOImport = bLFOImport; };
256 :
257 : // Numberings accessors
258 : AbstractListDef::Pointer GetCurrentDef( ) { return m_pCurrentDefinition; };
259 :
260 : sal_uInt32 Size() const
261 : { return sal_uInt32( m_aLists.size( ) ); };
262 : ListDef::Pointer GetList( sal_Int32 nId );
263 :
264 : // Mapping methods
265 : void CreateNumberingRules( );
266 : };
267 :
268 : } }
269 :
270 : #endif
271 :
272 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|