/src/libreoffice/oox/source/drawingml/textparagraphproperties.cxx
Line | Count | Source |
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 | | #include <drawingml/textparagraphproperties.hxx> |
21 | | #include <drawingml/textliststyle.hxx> |
22 | | |
23 | | #include <com/sun/star/text/XNumberingRulesSupplier.hpp> |
24 | | #include <com/sun/star/container/XIndexReplace.hpp> |
25 | | #include <com/sun/star/text/HoriOrientation.hpp> |
26 | | #include <com/sun/star/awt/FontDescriptor.hpp> |
27 | | #include <com/sun/star/awt/FontWeight.hpp> |
28 | | #include <com/sun/star/awt/XBitmap.hpp> |
29 | | #include <com/sun/star/graphic/XGraphic.hpp> |
30 | | #include <com/sun/star/beans/PropertyValue.hpp> |
31 | | #include <com/sun/star/style/NumberingType.hpp> |
32 | | #include <com/sun/star/style/TabStop.hpp> |
33 | | #include <com/sun/star/style/ParagraphAdjust.hpp> |
34 | | #include <com/sun/star/drawing/XDrawPage.hpp> |
35 | | |
36 | | #include <osl/diagnose.h> |
37 | | |
38 | | #include <oox/helper/propertyset.hxx> |
39 | | #include <oox/core/xmlfilterbase.hxx> |
40 | | #include <oox/token/properties.hxx> |
41 | | #include <oox/token/tokens.hxx> |
42 | | |
43 | | #if OSL_DEBUG_LEVEL > 0 |
44 | | #include <com/sun/star/lang/XMultiServiceFactory.hpp> |
45 | | #include <com/sun/star/text/XText.hpp> |
46 | | #include <com/sun/star/drawing/XShape.hpp> |
47 | | #include <oox/ppt/pptimport.hxx> |
48 | | #include <oox/ppt/slidepersist.hxx> |
49 | | #endif |
50 | | |
51 | | using namespace ::oox::core; |
52 | | using namespace ::com::sun::star::uno; |
53 | | using namespace ::com::sun::star::beans; |
54 | | using namespace ::com::sun::star::style; |
55 | | using namespace ::com::sun::star::text; |
56 | | using namespace ::com::sun::star::container; |
57 | | using ::com::sun::star::awt::FontDescriptor; |
58 | | |
59 | | namespace oox::drawingml { |
60 | | |
61 | | BulletList::BulletList( ) |
62 | 11.6M | : maBulletColorPtr( std::make_shared<Color>() ), |
63 | 11.6M | mbBulletColorFollowText ( false ), |
64 | 11.6M | mbBulletFontFollowText ( false ), |
65 | 11.6M | mbBulletSizeFollowText ( false ) |
66 | 11.6M | { |
67 | 11.6M | } |
68 | | |
69 | | bool BulletList::is() const |
70 | 263k | { |
71 | 263k | return mnNumberingType.hasValue(); |
72 | 263k | } |
73 | | |
74 | | void BulletList::setBulletChar( const OUString & sChar ) |
75 | 74.7k | { |
76 | 74.7k | mnNumberingType <<= NumberingType::CHAR_SPECIAL; |
77 | 74.7k | msBulletChar <<= sChar; |
78 | 74.7k | } |
79 | | |
80 | | void BulletList::setGraphic( css::uno::Reference< css::graphic::XGraphic > const & rXGraphic ) |
81 | 0 | { |
82 | 0 | mnNumberingType <<= NumberingType::BITMAP; |
83 | 0 | maGraphic <<= rXGraphic; |
84 | 0 | } |
85 | | |
86 | | void BulletList::setNone( ) |
87 | 31.3k | { |
88 | 31.3k | mnNumberingType <<= NumberingType::NUMBER_NONE; |
89 | 31.3k | } |
90 | | |
91 | | void BulletList::setSuffixParenBoth() |
92 | 0 | { |
93 | 0 | msNumberingSuffix <<= u")"_ustr; |
94 | 0 | msNumberingPrefix <<= u"("_ustr; |
95 | 0 | } |
96 | | |
97 | | void BulletList::setSuffixParenRight() |
98 | 10 | { |
99 | 10 | msNumberingSuffix <<= u")"_ustr; |
100 | 10 | msNumberingPrefix <<= OUString(); |
101 | 10 | } |
102 | | |
103 | | void BulletList::setSuffixPeriod() |
104 | 40 | { |
105 | 40 | msNumberingSuffix <<= u"."_ustr; |
106 | 40 | msNumberingPrefix <<= OUString(); |
107 | 40 | } |
108 | | |
109 | | void BulletList::setSuffixNone() |
110 | 74.7k | { |
111 | 74.7k | msNumberingSuffix <<= OUString(); |
112 | 74.7k | msNumberingPrefix <<= OUString(); |
113 | 74.7k | } |
114 | | |
115 | | void BulletList::setSuffixMinusRight() |
116 | 0 | { |
117 | 0 | msNumberingSuffix <<= u"-"_ustr; |
118 | 0 | msNumberingPrefix <<= OUString(); |
119 | 0 | } |
120 | | |
121 | | void BulletList::setType( sal_Int32 nType ) |
122 | 50 | { |
123 | 50 | OSL_ASSERT((nType & sal_Int32(0xFFFF0000))==0); |
124 | 50 | switch( nType ) |
125 | 50 | { |
126 | 0 | case XML_alphaLcParenBoth: |
127 | 0 | mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER; |
128 | 0 | setSuffixParenBoth(); |
129 | 0 | break; |
130 | 10 | case XML_alphaLcParenR: |
131 | 10 | mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER; |
132 | 10 | setSuffixParenRight(); |
133 | 10 | break; |
134 | 0 | case XML_alphaLcPeriod: |
135 | 0 | mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER; |
136 | 0 | setSuffixPeriod(); |
137 | 0 | break; |
138 | 0 | case XML_alphaUcParenBoth: |
139 | 0 | mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER; |
140 | 0 | setSuffixParenBoth(); |
141 | 0 | break; |
142 | 0 | case XML_alphaUcParenR: |
143 | 0 | mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER; |
144 | 0 | setSuffixParenRight(); |
145 | 0 | break; |
146 | 10 | case XML_alphaUcPeriod: |
147 | 10 | mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER; |
148 | 10 | setSuffixPeriod(); |
149 | 10 | break; |
150 | 0 | case XML_arabic1Minus: |
151 | 0 | case XML_arabic2Minus: |
152 | 0 | case XML_arabicDbPeriod: |
153 | 0 | case XML_arabicDbPlain: |
154 | | // TODO |
155 | 0 | break; |
156 | 0 | case XML_arabicParenBoth: |
157 | 0 | mnNumberingType <<= NumberingType::ARABIC; |
158 | 0 | setSuffixParenBoth(); |
159 | 0 | break; |
160 | 0 | case XML_arabicParenR: |
161 | 0 | mnNumberingType <<= NumberingType::ARABIC; |
162 | 0 | setSuffixParenRight(); |
163 | 0 | break; |
164 | 10 | case XML_arabicPeriod: |
165 | 10 | mnNumberingType <<= NumberingType::ARABIC; |
166 | 10 | setSuffixPeriod(); |
167 | 10 | break; |
168 | 0 | case XML_arabicPlain: |
169 | 0 | mnNumberingType <<= NumberingType::ARABIC; |
170 | 0 | setSuffixNone(); |
171 | 0 | break; |
172 | 0 | case XML_circleNumDbPlain: |
173 | 0 | case XML_circleNumWdBlackPlain: |
174 | 0 | case XML_circleNumWdWhitePlain: |
175 | 0 | mnNumberingType <<= NumberingType::CIRCLE_NUMBER; |
176 | 0 | break; |
177 | 0 | case XML_ea1ChsPeriod: |
178 | 0 | mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH; |
179 | 0 | setSuffixPeriod(); |
180 | 0 | break; |
181 | 0 | case XML_ea1ChsPlain: |
182 | 0 | mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH; |
183 | 0 | setSuffixNone(); |
184 | 0 | break; |
185 | 0 | case XML_ea1ChtPeriod: |
186 | 0 | mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH_TW; |
187 | 0 | setSuffixPeriod(); |
188 | 0 | break; |
189 | 0 | case XML_ea1ChtPlain: |
190 | 0 | mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH_TW; |
191 | 0 | setSuffixNone(); |
192 | 0 | break; |
193 | 0 | case XML_ea1JpnChsDbPeriod: |
194 | 0 | case XML_ea1JpnKorPeriod: |
195 | 0 | case XML_ea1JpnKorPlain: |
196 | 0 | break; |
197 | 0 | case XML_hebrew2Minus: |
198 | 0 | mnNumberingType <<= NumberingType::CHARS_HEBREW; |
199 | 0 | setSuffixMinusRight(); |
200 | 0 | break; |
201 | 0 | case XML_hindiAlpha1Period: |
202 | 0 | case XML_hindiAlphaPeriod: |
203 | 0 | case XML_hindiNumParenR: |
204 | 0 | case XML_hindiNumPeriod: |
205 | | // TODO |
206 | 0 | break; |
207 | 0 | case XML_romanLcParenBoth: |
208 | 0 | mnNumberingType <<= NumberingType::ROMAN_LOWER; |
209 | 0 | setSuffixParenBoth(); |
210 | 0 | break; |
211 | 0 | case XML_romanLcParenR: |
212 | 0 | mnNumberingType <<= NumberingType::ROMAN_LOWER; |
213 | 0 | setSuffixParenRight(); |
214 | 0 | break; |
215 | 10 | case XML_romanLcPeriod: |
216 | 10 | mnNumberingType <<= NumberingType::ROMAN_LOWER; |
217 | 10 | setSuffixPeriod(); |
218 | 10 | break; |
219 | 0 | case XML_romanUcParenBoth: |
220 | 0 | mnNumberingType <<= NumberingType::ROMAN_UPPER; |
221 | 0 | setSuffixParenBoth(); |
222 | 0 | break; |
223 | 0 | case XML_romanUcParenR: |
224 | 0 | mnNumberingType <<= NumberingType::ROMAN_UPPER; |
225 | 0 | setSuffixParenRight(); |
226 | 0 | break; |
227 | 10 | case XML_romanUcPeriod: |
228 | 10 | mnNumberingType <<= NumberingType::ROMAN_UPPER; |
229 | 10 | setSuffixPeriod(); |
230 | 10 | break; |
231 | 0 | case XML_thaiAlphaParenBoth: |
232 | 0 | case XML_thaiNumParenBoth: |
233 | 0 | mnNumberingType <<= NumberingType::CHARS_THAI; |
234 | 0 | setSuffixParenBoth(); |
235 | 0 | break; |
236 | 0 | case XML_thaiAlphaParenR: |
237 | 0 | case XML_thaiNumParenR: |
238 | 0 | mnNumberingType <<= NumberingType::CHARS_THAI; |
239 | 0 | setSuffixParenRight(); |
240 | 0 | break; |
241 | 0 | case XML_thaiAlphaPeriod: |
242 | 0 | case XML_thaiNumPeriod: |
243 | 0 | mnNumberingType <<= NumberingType::CHARS_THAI; |
244 | 0 | setSuffixPeriod(); |
245 | 0 | break; |
246 | 50 | } |
247 | 50 | } |
248 | | |
249 | | void BulletList::setBulletSize(sal_Int16 nSize) |
250 | 30.6k | { |
251 | 30.6k | mnSize <<= nSize; |
252 | 30.6k | } |
253 | | |
254 | | void BulletList::setBulletAspectRatio(double nAspectRatio) |
255 | 0 | { |
256 | 0 | mnAspectRatio <<= nAspectRatio; |
257 | 0 | } |
258 | | |
259 | | void BulletList::setFontSize(sal_Int16 nSize) |
260 | 0 | { |
261 | 0 | mnFontSize <<= nSize; |
262 | 0 | } |
263 | | |
264 | | void BulletList::apply( const BulletList& rSource ) |
265 | 8.86M | { |
266 | 8.86M | if ( rSource.maBulletColorPtr->isUsed() ) |
267 | 9.62k | maBulletColorPtr = rSource.maBulletColorPtr; |
268 | 8.86M | if ( rSource.mbBulletColorFollowText.hasValue() ) |
269 | 8.86M | mbBulletColorFollowText = rSource.mbBulletColorFollowText; |
270 | 8.86M | if ( rSource.mbBulletFontFollowText.hasValue() ) |
271 | 8.86M | mbBulletFontFollowText = rSource.mbBulletFontFollowText; |
272 | 8.86M | if ( rSource.mbBulletSizeFollowText.hasValue() ) |
273 | 8.86M | mbBulletSizeFollowText = rSource.mbBulletSizeFollowText; |
274 | 8.86M | maBulletFont.assignIfUsed( rSource.maBulletFont ); |
275 | 8.86M | if ( rSource.msBulletChar.hasValue() ) |
276 | 498k | msBulletChar = rSource.msBulletChar; |
277 | 8.86M | if ( rSource.mnStartAt.hasValue() ) |
278 | 50 | mnStartAt = rSource.mnStartAt; |
279 | 8.86M | if ( rSource.mnNumberingType.hasValue() ) |
280 | 622k | mnNumberingType = rSource.mnNumberingType; |
281 | 8.86M | if ( rSource.msNumberingPrefix.hasValue() ) |
282 | 498k | msNumberingPrefix = rSource.msNumberingPrefix; |
283 | 8.86M | if ( rSource.msNumberingSuffix.hasValue() ) |
284 | 498k | msNumberingSuffix = rSource.msNumberingSuffix; |
285 | 8.86M | if ( rSource.mnSize.hasValue() ) |
286 | 1.87k | mnSize = rSource.mnSize; |
287 | 8.86M | if ( rSource.mnAspectRatio.hasValue() ) |
288 | 0 | mnAspectRatio = rSource.mnAspectRatio; |
289 | 8.86M | if ( rSource.mnFontSize.hasValue() ) |
290 | 0 | mnFontSize = rSource.mnFontSize; |
291 | 8.86M | if ( rSource.maStyleName.hasValue() ) |
292 | 1.23M | maStyleName = rSource.maStyleName; |
293 | 8.86M | if ( rSource.maGraphic.hasValue() ) |
294 | 0 | maGraphic = rSource.maGraphic; |
295 | 8.86M | } |
296 | | |
297 | | void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase* pFilterBase, PropertyMap& rPropMap ) const |
298 | 154k | { |
299 | 154k | if( msNumberingPrefix.hasValue() ) |
300 | 46.5k | rPropMap.setAnyProperty( PROP_Prefix, msNumberingPrefix); |
301 | 154k | if( msNumberingSuffix.hasValue() ) |
302 | 46.5k | rPropMap.setAnyProperty( PROP_Suffix, msNumberingSuffix); |
303 | 154k | if( mnStartAt.hasValue() ) |
304 | 50 | rPropMap.setAnyProperty( PROP_StartWith, mnStartAt); |
305 | 154k | rPropMap.setProperty( PROP_Adjust, HoriOrientation::LEFT); |
306 | | |
307 | 154k | if( mnNumberingType.hasValue() ) |
308 | 59.1k | rPropMap.setAnyProperty( PROP_NumberingType, mnNumberingType); |
309 | | |
310 | 154k | OUString aBulletFontName; |
311 | 154k | sal_Int16 nBulletFontPitch = 0; |
312 | 154k | sal_Int16 nBulletFontFamily = 0; |
313 | 154k | float nBulletFontWeight = css::awt::FontWeight::NORMAL; |
314 | 154k | bool bSymbolFont = false; |
315 | 154k | if( pFilterBase) { |
316 | 154k | bool bFollowTextFont = false; |
317 | 154k | mbBulletFontFollowText >>= bFollowTextFont; |
318 | 154k | if (!bFollowTextFont && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, &bSymbolFont, *pFilterBase ) ) |
319 | 46.0k | { |
320 | 46.0k | FontDescriptor aFontDesc; |
321 | 46.0k | sal_Int16 nFontSize = 0; |
322 | 46.0k | if( mnFontSize >>= nFontSize ) |
323 | 0 | aFontDesc.Height = nFontSize; |
324 | | |
325 | | // TODO It is likely that bSymbolFont from getFontData is sufficient to check here |
326 | | // and looking at the font name is not necessary, if it is necessary then moving |
327 | | // the name lookup into getFontData is likely the best fix |
328 | 46.0k | aFontDesc.Name = aBulletFontName; |
329 | 46.0k | aFontDesc.Pitch = nBulletFontPitch; |
330 | 46.0k | aFontDesc.Family = nBulletFontFamily; |
331 | 46.0k | aFontDesc.Weight = nBulletFontWeight; |
332 | 46.0k | if ( bSymbolFont || |
333 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("Wingdings") || |
334 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("Wingdings 2") || |
335 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("Wingdings 3") || |
336 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("Monotype Sorts") || |
337 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("Monotype Sorts 2") || |
338 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("Webdings") || |
339 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("StarBats") || |
340 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("StarMath") || |
341 | 45.4k | aBulletFontName.equalsIgnoreAsciiCase("ZapfDingbats") ) { |
342 | 550 | aFontDesc.CharSet = RTL_TEXTENCODING_SYMBOL; |
343 | 550 | bSymbolFont = true; |
344 | 550 | } |
345 | 46.0k | rPropMap.setProperty( PROP_BulletFont, aFontDesc); |
346 | 46.0k | rPropMap.setProperty( PROP_BulletFontName, aBulletFontName); |
347 | 46.0k | } |
348 | 154k | } |
349 | 154k | if ( msBulletChar.hasValue() ) { |
350 | 46.4k | OUString sBuChar; |
351 | | |
352 | 46.4k | msBulletChar >>= sBuChar; |
353 | | |
354 | 46.4k | if( pFilterBase && sBuChar.getLength() == 1 && maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, nullptr, *pFilterBase ) && bSymbolFont ) |
355 | 543 | { |
356 | 543 | sal_Unicode nBuChar = sBuChar.toChar(); |
357 | 543 | nBuChar &= 0x00ff; |
358 | 543 | nBuChar |= 0xf000; |
359 | 543 | sBuChar = OUString( &nBuChar, 1 ); |
360 | 543 | } |
361 | | |
362 | 46.4k | rPropMap.setProperty( PROP_BulletChar, sBuChar); |
363 | 46.4k | } |
364 | 154k | if ( maGraphic.hasValue() ) |
365 | 0 | { |
366 | 0 | Reference<css::awt::XBitmap> xBitmap(maGraphic, UNO_QUERY); |
367 | 0 | if (xBitmap.is()) |
368 | 0 | rPropMap.setProperty(PROP_GraphicBitmap, xBitmap); |
369 | 0 | } |
370 | 154k | bool bFollowTextSize = false; |
371 | 154k | mbBulletSizeFollowText >>= bFollowTextSize; |
372 | 154k | if( !bFollowTextSize && mnSize.hasValue() ) |
373 | 1.21k | rPropMap.setAnyProperty( PROP_BulletRelSize, mnSize); |
374 | 154k | if ( maStyleName.hasValue() ) |
375 | 92.3k | rPropMap.setAnyProperty( PROP_CharStyleName, maStyleName); |
376 | 154k | if (pFilterBase ) { |
377 | 154k | bool bFollowTextColor = false; |
378 | 154k | mbBulletColorFollowText >>= bFollowTextColor; |
379 | 154k | if ( maBulletColorPtr->isUsed() && !bFollowTextColor ) |
380 | 923 | rPropMap.setProperty( PROP_BulletColor, maBulletColorPtr->getColor( pFilterBase->getGraphicHelper() )); |
381 | 154k | } |
382 | 154k | } |
383 | | |
384 | | TextParagraphProperties::TextParagraphProperties() |
385 | 11.6M | : mnLevel( 0 ), mbRestartNumbering( false ) |
386 | 11.6M | { |
387 | 11.6M | } |
388 | | |
389 | | void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps ) |
390 | 8.86M | { |
391 | 8.86M | maTextParagraphPropertyMap.assignAll( rSourceProps.maTextParagraphPropertyMap ); |
392 | 8.86M | maBulletList.apply( rSourceProps.maBulletList ); |
393 | 8.86M | maTextCharacterProperties.assignUsed( rSourceProps.maTextCharacterProperties ); |
394 | 8.86M | if ( rSourceProps.maParaTopMargin.bHasValue ) |
395 | 579k | maParaTopMargin = rSourceProps.maParaTopMargin; |
396 | 8.86M | if ( rSourceProps.maParaBottomMargin.bHasValue ) |
397 | 681k | maParaBottomMargin = rSourceProps.maParaBottomMargin; |
398 | 8.86M | if ( rSourceProps.moParaLeftMargin ) |
399 | 1.00M | moParaLeftMargin = rSourceProps.moParaLeftMargin; |
400 | 8.86M | if ( rSourceProps.moFirstLineIndentation ) |
401 | 613k | moFirstLineIndentation = rSourceProps.moFirstLineIndentation; |
402 | 8.86M | if ( rSourceProps.moDefaultTabSize ) |
403 | 883k | moDefaultTabSize = rSourceProps.moDefaultTabSize; |
404 | 8.86M | if( rSourceProps.mnLevel ) |
405 | 13.9k | mnLevel = rSourceProps.mnLevel; |
406 | 8.86M | if( rSourceProps.moParaAdjust ) |
407 | 1.00M | moParaAdjust = rSourceProps.moParaAdjust; |
408 | 8.86M | if( rSourceProps.maLineSpacing.bHasValue ) |
409 | 393k | maLineSpacing = rSourceProps.maLineSpacing; |
410 | 8.86M | if( rSourceProps.mbRestartNumbering ) |
411 | 50 | mbRestartNumbering = rSourceProps.mbRestartNumbering; |
412 | 8.86M | } |
413 | | |
414 | | void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, |
415 | | const Reference < XPropertySet >& xPropSet, PropertyMap& rioBulletMap, const BulletList* pMasterBuList, bool bApplyBulletMap, float fCharacterSize, |
416 | | bool bPushDefaultValues, TextListStyle* pTextListStyle ) const |
417 | 154k | { |
418 | 154k | PropertySet aPropSet( xPropSet ); |
419 | 154k | aPropSet.setProperties( maTextParagraphPropertyMap ); |
420 | | |
421 | 154k | sal_Int32 nNumberingType = NumberingType::NUMBER_NONE; |
422 | 154k | if ( maBulletList.mnNumberingType.hasValue() ) |
423 | 59.1k | { |
424 | 59.1k | maBulletList.mnNumberingType >>= nNumberingType; |
425 | 59.1k | if (aPropSet.hasProperty(PROP_NumberingLevel)) |
426 | 20.5k | aPropSet.setProperty< sal_Int16 >( PROP_NumberingLevel, getLevel() ); |
427 | 59.1k | } |
428 | 95.5k | else if ( pMasterBuList && pMasterBuList->mnNumberingType.hasValue() ) |
429 | 0 | pMasterBuList->mnNumberingType >>= nNumberingType; |
430 | 154k | if ( nNumberingType == NumberingType::NUMBER_NONE |
431 | 111k | && aPropSet.hasProperty(PROP_NumberingLevel) ) |
432 | 54.8k | aPropSet.setProperty< sal_Int16 >( PROP_NumberingLevel, -1 ); |
433 | | |
434 | 154k | maBulletList.pushToPropMap( pFilterBase, rioBulletMap ); |
435 | | |
436 | 154k | if ( maParaTopMargin.bHasValue || bPushDefaultValues ) |
437 | 143k | aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 12.0 ) ) ); |
438 | 154k | if ( maParaBottomMargin.bHasValue || bPushDefaultValues ) |
439 | 143k | aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 12.0 ) ) ); |
440 | | |
441 | 154k | std::optional< sal_Int32 > noParaLeftMargin( moParaLeftMargin ); |
442 | 154k | std::optional< sal_Int32 > noFirstLineIndentation( moFirstLineIndentation ); |
443 | | |
444 | 154k | if ( nNumberingType != NumberingType::NUMBER_NONE ) |
445 | 43.5k | { |
446 | 43.5k | if ( noParaLeftMargin ) |
447 | 39.5k | { |
448 | 39.5k | aPropSet.setProperty<sal_Int32>( PROP_ParaLeftMargin, 0); |
449 | 39.5k | rioBulletMap.setProperty( PROP_LeftMargin, *noParaLeftMargin); |
450 | 39.5k | noParaLeftMargin.reset(); |
451 | 39.5k | } |
452 | 43.5k | if ( noFirstLineIndentation ) |
453 | 39.5k | { |
454 | | // Force Paragraph property as zero - impress seems to use the value from previous |
455 | | // (non) bullet line if not set to zero explicitly :( |
456 | 39.5k | aPropSet.setProperty<sal_Int32>( PROP_ParaFirstLineIndent, 0); |
457 | 39.5k | rioBulletMap.setProperty( PROP_FirstLineOffset, *noFirstLineIndentation); |
458 | 39.5k | noFirstLineIndentation.reset(); |
459 | 39.5k | } |
460 | 43.5k | if ( nNumberingType != NumberingType::BITMAP && !rioBulletMap.hasProperty( PROP_BulletColor ) && pFilterBase ) |
461 | 32.8k | rioBulletMap.setProperty( PROP_BulletColor, maTextCharacterProperties.maFillProperties.getBestSolidColor().getColor( pFilterBase->getGraphicHelper())); |
462 | 43.5k | } |
463 | | |
464 | 154k | if ( bApplyBulletMap ) |
465 | 154k | { |
466 | 154k | Reference< XIndexReplace > xNumRule; |
467 | 154k | aPropSet.getProperty( xNumRule, PROP_NumberingRules ); |
468 | 154k | OSL_ENSURE( xNumRule.is(), "can't get Numbering rules"); |
469 | | |
470 | 154k | try |
471 | 154k | { |
472 | 154k | if( xNumRule.is() ) |
473 | 154k | { |
474 | 154k | if( !rioBulletMap.empty() ) |
475 | 154k | { |
476 | | // fix default bullet size to be 100% |
477 | 154k | if( !rioBulletMap.hasProperty( PROP_BulletRelSize ) ) |
478 | 153k | rioBulletMap.setProperty<sal_Int16>( PROP_BulletRelSize, 100); |
479 | 154k | Sequence< PropertyValue > aBulletPropSeq = rioBulletMap.makePropertyValueSequence(); |
480 | 154k | xNumRule->replaceByIndex( getLevel(), Any( aBulletPropSeq ) ); |
481 | | |
482 | 154k | if (pTextListStyle) |
483 | 54.4k | { |
484 | | // We got the list style of this shape, then set the other levels of the |
485 | | // numbering rules, too. |
486 | 54.4k | pTextListStyle->pushToNumberingRules(xNumRule, getLevel()); |
487 | 54.4k | } |
488 | 154k | } |
489 | | |
490 | 154k | aPropSet.setProperty( PROP_NumberingRules, xNumRule ); |
491 | 154k | } |
492 | 154k | } |
493 | 154k | catch (const Exception &) |
494 | 154k | { |
495 | | // Don't warn for now, expected to fail for Writer. |
496 | 3.43k | } |
497 | 154k | } |
498 | 154k | if ( noParaLeftMargin ) |
499 | 19.6k | aPropSet.setProperty( PROP_ParaLeftMargin, *noParaLeftMargin); |
500 | 134k | else // Use 0 as default left margin |
501 | 134k | aPropSet.setProperty<sal_Int32>(PROP_ParaLeftMargin, 0); |
502 | | |
503 | 154k | if ( noFirstLineIndentation ) |
504 | 8.47k | { |
505 | 8.47k | aPropSet.setProperty( PROP_ParaFirstLineIndent, *noFirstLineIndentation ); |
506 | 8.47k | if( bPushDefaultValues ) |
507 | 8.47k | { |
508 | | // Reset TabStops - these would be auto calculated by Impress |
509 | 8.47k | TabStop aTabStop; |
510 | 8.47k | aTabStop.Position = 0; |
511 | 8.47k | Sequence< TabStop > aSeq { aTabStop }; |
512 | 8.47k | aPropSet.setProperty( PROP_ParaTabStops, aSeq ); |
513 | 8.47k | } |
514 | 8.47k | } |
515 | 146k | else |
516 | 146k | aPropSet.setProperty<sal_Int32>( PROP_ParaFirstLineIndent, 0); |
517 | | |
518 | 154k | if ( moDefaultTabSize ) |
519 | 63.3k | { |
520 | 63.3k | aPropSet.setProperty( PROP_ParaTabStopDefaultDistance, *moDefaultTabSize ); |
521 | 63.3k | } |
522 | | |
523 | 154k | if ( moParaAdjust ) |
524 | 76.7k | { |
525 | 76.7k | aPropSet.setProperty( PROP_ParaAdjust, *moParaAdjust); |
526 | 76.7k | } |
527 | 77.8k | else |
528 | 77.8k | { |
529 | 77.8k | aPropSet.setProperty( PROP_ParaAdjust, css::style::ParagraphAdjust_LEFT); |
530 | 77.8k | } |
531 | | |
532 | 154k | if ( maLineSpacing.bHasValue ) |
533 | 44.6k | { |
534 | 44.6k | aPropSet.setProperty( PROP_ParaLineSpacing, maLineSpacing.toLineSpacing()); |
535 | 44.6k | } |
536 | 110k | else |
537 | 110k | { |
538 | 110k | aPropSet.setProperty( PROP_ParaLineSpacing, css::style::LineSpacing( css::style::LineSpacingMode::PROP, 100 )); |
539 | 110k | } |
540 | | |
541 | 154k | if ( mbRestartNumbering ) |
542 | 50 | { |
543 | 50 | aPropSet.setProperty( PROP_ParaIsNumberingRestart, true); |
544 | 50 | } |
545 | 154k | } |
546 | | |
547 | | float TextParagraphProperties::getCharHeightPoints( float fDefault ) const |
548 | 16.0k | { |
549 | 16.0k | return maTextCharacterProperties.getCharHeightPoints( fDefault ); |
550 | 16.0k | } |
551 | | |
552 | | #ifdef DBG_UTIL |
553 | | // Note: Please don't remove this function. This is required for |
554 | | // debugging pptx import problems. |
555 | | void TextParagraphProperties::dump() const |
556 | | { |
557 | | Reference< css::drawing::XShape > xShape( oox::ppt::PowerPointImport::mpDebugFilterBase->getModelFactory()->createInstance( u"com.sun.star.presentation.TitleTextShape"_ustr ), UNO_QUERY ); |
558 | | Reference< css::text::XText > xText( xShape, UNO_QUERY ); |
559 | | |
560 | | Reference< css::drawing::XDrawPage > xDebugPage(ppt::SlidePersist::mxDebugPage.get(), UNO_QUERY); |
561 | | if (xDebugPage.is()) |
562 | | xDebugPage->add( xShape ); |
563 | | |
564 | | PropertyMap emptyMap; |
565 | | |
566 | | xText->setString( u"debug"_ustr ); |
567 | | Reference< css::text::XTextCursor > xStart = xText->createTextCursor(); |
568 | | xStart->gotoEnd( true ); |
569 | | Reference< XPropertySet > xPropSet( xStart, UNO_QUERY ); |
570 | | pushToPropSet( nullptr, xPropSet, emptyMap, nullptr, false, 0 ); |
571 | | PropertySet aPropSet( xPropSet ); |
572 | | aPropSet.dump(); |
573 | | } |
574 | | #endif |
575 | | } |
576 | | |
577 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |