1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "oox/drawingml/textparagraphproperties.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include <com/sun/star/text/XNumberingRulesSupplier.hpp>
31*cdf0e10cSrcweir #include <com/sun/star/container/XIndexReplace.hpp>
32*cdf0e10cSrcweir #include <com/sun/star/text/HoriOrientation.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/awt/FontDescriptor.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/awt/XBitmap.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/graphic/XGraphic.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "oox/helper/helper.hxx"
39*cdf0e10cSrcweir #include "oox/helper/propertyset.hxx"
40*cdf0e10cSrcweir #include "oox/core/xmlfilterbase.hxx"
41*cdf0e10cSrcweir #include "oox/drawingml/drawingmltypes.hxx"
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using rtl::OUString;
44*cdf0e10cSrcweir using namespace ::oox::core;
45*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
46*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
47*cdf0e10cSrcweir using namespace ::com::sun::star::style;
48*cdf0e10cSrcweir using namespace ::com::sun::star::text;
49*cdf0e10cSrcweir using namespace ::com::sun::star::container;
50*cdf0e10cSrcweir using ::com::sun::star::awt::FontDescriptor;
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir namespace oox { namespace drawingml {
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir BulletList::BulletList( )
55*cdf0e10cSrcweir : maBulletColorPtr( new Color() )
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir }
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir bool BulletList::is() const
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 	return mnNumberingType.hasValue();
62*cdf0e10cSrcweir }
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir void BulletList::setBulletChar( const ::rtl::OUString & sChar )
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir 	mnNumberingType <<= NumberingType::CHAR_SPECIAL;
67*cdf0e10cSrcweir 	msBulletChar <<= sChar;
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir void BulletList::setGraphic( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rXGraphic )
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir 	mnNumberingType <<= NumberingType::BITMAP;
73*cdf0e10cSrcweir 	maGraphic <<= rXGraphic;
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir void BulletList::setNone( )
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	mnNumberingType <<= NumberingType::NUMBER_NONE;
79*cdf0e10cSrcweir }
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir void BulletList::setSuffixParenBoth()
82*cdf0e10cSrcweir {
83*cdf0e10cSrcweir 	msNumberingSuffix <<= CREATE_OUSTRING( ")" );
84*cdf0e10cSrcweir 	msNumberingPrefix <<= CREATE_OUSTRING( "(" );
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir void BulletList::setSuffixParenRight()
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir 	msNumberingSuffix <<= CREATE_OUSTRING( ")" );
90*cdf0e10cSrcweir 	msNumberingPrefix <<= OUString();
91*cdf0e10cSrcweir }
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir void BulletList::setSuffixPeriod()
94*cdf0e10cSrcweir {
95*cdf0e10cSrcweir 	msNumberingSuffix <<= CREATE_OUSTRING( "." );
96*cdf0e10cSrcweir 	msNumberingPrefix <<= OUString();
97*cdf0e10cSrcweir }
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir void BulletList::setSuffixNone()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	msNumberingSuffix <<= OUString();
102*cdf0e10cSrcweir 	msNumberingPrefix <<= OUString();
103*cdf0e10cSrcweir }
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir void BulletList::setSuffixMinusRight()
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir 	msNumberingSuffix <<= CREATE_OUSTRING( "-" );
108*cdf0e10cSrcweir 	msNumberingPrefix <<= OUString();
109*cdf0e10cSrcweir }
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir void BulletList::setType( sal_Int32 nType )
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir //	OSL_TRACE( "OOX: set list numbering type %d", nType);
114*cdf0e10cSrcweir 	switch( nType )
115*cdf0e10cSrcweir 	{
116*cdf0e10cSrcweir 	case XML_alphaLcParenBoth:
117*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER;
118*cdf0e10cSrcweir 		setSuffixParenBoth();
119*cdf0e10cSrcweir 		break;
120*cdf0e10cSrcweir 	case XML_alphaLcParenR:
121*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER;
122*cdf0e10cSrcweir 		setSuffixParenRight();
123*cdf0e10cSrcweir 		break;
124*cdf0e10cSrcweir 	case XML_alphaLcPeriod:
125*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_LOWER_LETTER;
126*cdf0e10cSrcweir 		setSuffixPeriod();
127*cdf0e10cSrcweir 		break;
128*cdf0e10cSrcweir 	case XML_alphaUcParenBoth:
129*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER;
130*cdf0e10cSrcweir 		setSuffixParenBoth();
131*cdf0e10cSrcweir 		break;
132*cdf0e10cSrcweir 	case XML_alphaUcParenR:
133*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER;
134*cdf0e10cSrcweir 		setSuffixParenRight();
135*cdf0e10cSrcweir 		break;
136*cdf0e10cSrcweir 	case XML_alphaUcPeriod:
137*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_UPPER_LETTER;
138*cdf0e10cSrcweir 		setSuffixPeriod();
139*cdf0e10cSrcweir 		break;
140*cdf0e10cSrcweir 	case XML_arabic1Minus:
141*cdf0e10cSrcweir 	case XML_arabic2Minus:
142*cdf0e10cSrcweir 	case XML_arabicDbPeriod:
143*cdf0e10cSrcweir 	case XML_arabicDbPlain:
144*cdf0e10cSrcweir 		// TODO
145*cdf0e10cSrcweir 		break;
146*cdf0e10cSrcweir 	case XML_arabicParenBoth:
147*cdf0e10cSrcweir  		mnNumberingType <<= NumberingType::ARABIC;
148*cdf0e10cSrcweir 		setSuffixParenBoth();
149*cdf0e10cSrcweir 		break;
150*cdf0e10cSrcweir 	case XML_arabicParenR:
151*cdf0e10cSrcweir  		mnNumberingType <<= NumberingType::ARABIC;
152*cdf0e10cSrcweir 		setSuffixParenRight();
153*cdf0e10cSrcweir 		break;
154*cdf0e10cSrcweir 	case XML_arabicPeriod:
155*cdf0e10cSrcweir  		mnNumberingType <<= NumberingType::ARABIC;
156*cdf0e10cSrcweir 		setSuffixPeriod();
157*cdf0e10cSrcweir 		break;
158*cdf0e10cSrcweir 	case XML_arabicPlain:
159*cdf0e10cSrcweir  		mnNumberingType <<= NumberingType::ARABIC;
160*cdf0e10cSrcweir 		setSuffixNone();
161*cdf0e10cSrcweir 		break;
162*cdf0e10cSrcweir 	case XML_circleNumDbPlain:
163*cdf0e10cSrcweir 	case XML_circleNumWdBlackPlain:
164*cdf0e10cSrcweir 	case XML_circleNumWdWhitePlain:
165*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CIRCLE_NUMBER;
166*cdf0e10cSrcweir 		break;
167*cdf0e10cSrcweir 	case XML_ea1ChsPeriod:
168*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH;
169*cdf0e10cSrcweir  		setSuffixPeriod();
170*cdf0e10cSrcweir 		break;
171*cdf0e10cSrcweir 	case XML_ea1ChsPlain:
172*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH;
173*cdf0e10cSrcweir 		setSuffixNone();
174*cdf0e10cSrcweir 		break;
175*cdf0e10cSrcweir 	case XML_ea1ChtPeriod:
176*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH_TW;
177*cdf0e10cSrcweir  		setSuffixPeriod();
178*cdf0e10cSrcweir 		break;
179*cdf0e10cSrcweir 	case XML_ea1ChtPlain:
180*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::NUMBER_UPPER_ZH_TW;
181*cdf0e10cSrcweir 		setSuffixNone();
182*cdf0e10cSrcweir 		break;
183*cdf0e10cSrcweir 	case XML_ea1JpnChsDbPeriod:
184*cdf0e10cSrcweir 	case XML_ea1JpnKorPeriod:
185*cdf0e10cSrcweir 	case XML_ea1JpnKorPlain:
186*cdf0e10cSrcweir 		break;
187*cdf0e10cSrcweir 	case XML_hebrew2Minus:
188*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_HEBREW;
189*cdf0e10cSrcweir 		setSuffixMinusRight();
190*cdf0e10cSrcweir 		break;
191*cdf0e10cSrcweir 	case XML_hindiAlpha1Period:
192*cdf0e10cSrcweir 	case XML_hindiAlphaPeriod:
193*cdf0e10cSrcweir 	case XML_hindiNumParenR:
194*cdf0e10cSrcweir 	case XML_hindiNumPeriod:
195*cdf0e10cSrcweir 		// TODO
196*cdf0e10cSrcweir 		break;
197*cdf0e10cSrcweir 	case XML_romanLcParenBoth:
198*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::ROMAN_LOWER;
199*cdf0e10cSrcweir 		setSuffixParenBoth();
200*cdf0e10cSrcweir 		break;
201*cdf0e10cSrcweir 	case XML_romanLcParenR:
202*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::ROMAN_LOWER;
203*cdf0e10cSrcweir 		setSuffixParenRight();
204*cdf0e10cSrcweir 		break;
205*cdf0e10cSrcweir 	case XML_romanLcPeriod:
206*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::ROMAN_LOWER;
207*cdf0e10cSrcweir  		setSuffixPeriod();
208*cdf0e10cSrcweir 		break;
209*cdf0e10cSrcweir 	case XML_romanUcParenBoth:
210*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::ROMAN_UPPER;
211*cdf0e10cSrcweir 		setSuffixParenBoth();
212*cdf0e10cSrcweir 		break;
213*cdf0e10cSrcweir 	case XML_romanUcParenR:
214*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::ROMAN_UPPER;
215*cdf0e10cSrcweir 		setSuffixParenRight();
216*cdf0e10cSrcweir 		break;
217*cdf0e10cSrcweir 	case XML_romanUcPeriod:
218*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::ROMAN_UPPER;
219*cdf0e10cSrcweir  		setSuffixPeriod();
220*cdf0e10cSrcweir 		break;
221*cdf0e10cSrcweir 	case XML_thaiAlphaParenBoth:
222*cdf0e10cSrcweir 	case XML_thaiNumParenBoth:
223*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_THAI;
224*cdf0e10cSrcweir 		setSuffixParenBoth();
225*cdf0e10cSrcweir 		break;
226*cdf0e10cSrcweir 	case XML_thaiAlphaParenR:
227*cdf0e10cSrcweir 	case XML_thaiNumParenR:
228*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_THAI;
229*cdf0e10cSrcweir 		setSuffixParenRight();
230*cdf0e10cSrcweir 		break;
231*cdf0e10cSrcweir 	case XML_thaiAlphaPeriod:
232*cdf0e10cSrcweir 	case XML_thaiNumPeriod:
233*cdf0e10cSrcweir 		mnNumberingType <<= NumberingType::CHARS_THAI;
234*cdf0e10cSrcweir  		setSuffixPeriod();
235*cdf0e10cSrcweir 		break;
236*cdf0e10cSrcweir 	}
237*cdf0e10cSrcweir }
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir void BulletList::setBulletSize(sal_Int16 nSize)
240*cdf0e10cSrcweir {
241*cdf0e10cSrcweir 	mnSize <<= nSize;
242*cdf0e10cSrcweir }
243*cdf0e10cSrcweir 
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir void BulletList::setFontSize(sal_Int16 nSize)
246*cdf0e10cSrcweir {
247*cdf0e10cSrcweir 	mnFontSize <<= nSize;
248*cdf0e10cSrcweir }
249*cdf0e10cSrcweir 
250*cdf0e10cSrcweir void BulletList::apply( const BulletList& rSource )
251*cdf0e10cSrcweir {
252*cdf0e10cSrcweir 	if ( rSource.maBulletColorPtr->isUsed() )
253*cdf0e10cSrcweir 		maBulletColorPtr = rSource.maBulletColorPtr;
254*cdf0e10cSrcweir 	if ( rSource.mbBulletColorFollowText.hasValue() )
255*cdf0e10cSrcweir 		mbBulletColorFollowText = rSource.mbBulletColorFollowText;
256*cdf0e10cSrcweir 	if ( rSource.mbBulletFontFollowText.hasValue() )
257*cdf0e10cSrcweir 		mbBulletFontFollowText = rSource.mbBulletFontFollowText;
258*cdf0e10cSrcweir     maBulletFont.assignIfUsed( rSource.maBulletFont );
259*cdf0e10cSrcweir 	if ( rSource.msBulletChar.hasValue() )
260*cdf0e10cSrcweir 		msBulletChar = rSource.msBulletChar;
261*cdf0e10cSrcweir 	if ( rSource.mnStartAt.hasValue() )
262*cdf0e10cSrcweir 		mnStartAt = rSource.mnStartAt;
263*cdf0e10cSrcweir 	if ( rSource.mnNumberingType.hasValue() )
264*cdf0e10cSrcweir 		mnNumberingType = rSource.mnNumberingType;
265*cdf0e10cSrcweir 	if ( rSource.msNumberingPrefix.hasValue() )
266*cdf0e10cSrcweir 		msNumberingPrefix = rSource.msNumberingPrefix;
267*cdf0e10cSrcweir 	if ( rSource.msNumberingSuffix.hasValue() )
268*cdf0e10cSrcweir 		msNumberingSuffix = rSource.msNumberingSuffix;
269*cdf0e10cSrcweir 	if ( rSource.mnSize.hasValue() )
270*cdf0e10cSrcweir 		mnSize = rSource.mnSize;
271*cdf0e10cSrcweir 	if ( rSource.mnFontSize.hasValue() )
272*cdf0e10cSrcweir 		mnFontSize = rSource.mnFontSize;
273*cdf0e10cSrcweir 	if ( rSource.maStyleName.hasValue() )
274*cdf0e10cSrcweir 		maStyleName = rSource.maStyleName;
275*cdf0e10cSrcweir 	if ( rSource.maGraphic.hasValue() )
276*cdf0e10cSrcweir 		maGraphic = rSource.maGraphic;
277*cdf0e10cSrcweir }
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir void BulletList::pushToPropMap( const ::oox::core::XmlFilterBase& rFilterBase, PropertyMap& rPropMap ) const
280*cdf0e10cSrcweir {
281*cdf0e10cSrcweir 	if( msNumberingPrefix.hasValue() )
282*cdf0e10cSrcweir         rPropMap[ PROP_Prefix ] = msNumberingPrefix;
283*cdf0e10cSrcweir 	if( msNumberingSuffix.hasValue() )
284*cdf0e10cSrcweir         rPropMap[ PROP_Suffix ] = msNumberingSuffix;
285*cdf0e10cSrcweir 	if( mnStartAt.hasValue() )
286*cdf0e10cSrcweir         rPropMap[ PROP_StartWith ] = mnStartAt;
287*cdf0e10cSrcweir     rPropMap[ PROP_Adjust ] <<= HoriOrientation::LEFT;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir 	if( mnNumberingType.hasValue() )
290*cdf0e10cSrcweir         rPropMap[ PROP_NumberingType ] = mnNumberingType;
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir     OUString aBulletFontName;
293*cdf0e10cSrcweir     sal_Int16 nBulletFontPitch = 0;
294*cdf0e10cSrcweir     sal_Int16 nBulletFontFamily = 0;
295*cdf0e10cSrcweir     if( maBulletFont.getFontData( aBulletFontName, nBulletFontPitch, nBulletFontFamily, rFilterBase ) )
296*cdf0e10cSrcweir 	{
297*cdf0e10cSrcweir 		FontDescriptor aFontDesc;
298*cdf0e10cSrcweir 		sal_Int16 nFontSize = 0;
299*cdf0e10cSrcweir 		if( mnFontSize >>= nFontSize )
300*cdf0e10cSrcweir 			aFontDesc.Height = nFontSize;
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir 		// TODO move the to the TextFont struct.
303*cdf0e10cSrcweir         aFontDesc.Name = aBulletFontName;
304*cdf0e10cSrcweir         aFontDesc.Pitch = nBulletFontPitch;
305*cdf0e10cSrcweir         aFontDesc.Family = nBulletFontFamily;
306*cdf0e10cSrcweir         rPropMap[ PROP_BulletFont ] <<= aFontDesc;
307*cdf0e10cSrcweir         rPropMap[ PROP_BulletFontName ] <<= aBulletFontName;
308*cdf0e10cSrcweir 	}
309*cdf0e10cSrcweir 	if ( msBulletChar.hasValue() )
310*cdf0e10cSrcweir         rPropMap[ PROP_BulletChar ] = msBulletChar;
311*cdf0e10cSrcweir 	if ( maGraphic.hasValue() )
312*cdf0e10cSrcweir 	{
313*cdf0e10cSrcweir 		Reference< com::sun::star::awt::XBitmap > xBitmap( maGraphic, UNO_QUERY );
314*cdf0e10cSrcweir 		if ( xBitmap.is() )
315*cdf0e10cSrcweir             rPropMap[ PROP_Graphic ] <<= xBitmap;
316*cdf0e10cSrcweir 	}
317*cdf0e10cSrcweir 	if( mnSize.hasValue() )
318*cdf0e10cSrcweir         rPropMap[ PROP_BulletRelSize ] = mnSize;
319*cdf0e10cSrcweir 	if ( maStyleName.hasValue() )
320*cdf0e10cSrcweir         rPropMap[ PROP_CharStyleName ] <<= maStyleName;
321*cdf0e10cSrcweir 	if ( maBulletColorPtr->isUsed() )
322*cdf0e10cSrcweir         rPropMap[ PROP_BulletColor ] <<= maBulletColorPtr->getColor( rFilterBase.getGraphicHelper() );
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir TextParagraphProperties::TextParagraphProperties()
326*cdf0e10cSrcweir : mnLevel( 0 )
327*cdf0e10cSrcweir {
328*cdf0e10cSrcweir }
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir TextParagraphProperties::~TextParagraphProperties()
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir void TextParagraphProperties::apply( const TextParagraphProperties& rSourceProps )
335*cdf0e10cSrcweir {
336*cdf0e10cSrcweir     maTextParagraphPropertyMap.insert( rSourceProps.maTextParagraphPropertyMap.begin(), rSourceProps.maTextParagraphPropertyMap.end() );
337*cdf0e10cSrcweir     maBulletList.apply( rSourceProps.maBulletList );
338*cdf0e10cSrcweir     maTextCharacterProperties.assignUsed( rSourceProps.maTextCharacterProperties );
339*cdf0e10cSrcweir     if ( rSourceProps.maParaTopMargin.bHasValue )
340*cdf0e10cSrcweir         maParaTopMargin = rSourceProps.maParaTopMargin;
341*cdf0e10cSrcweir     if ( rSourceProps.maParaBottomMargin.bHasValue )
342*cdf0e10cSrcweir         maParaBottomMargin = rSourceProps.maParaBottomMargin;
343*cdf0e10cSrcweir     if ( rSourceProps.moParaLeftMargin )
344*cdf0e10cSrcweir         moParaLeftMargin = rSourceProps.moParaLeftMargin;
345*cdf0e10cSrcweir     if ( rSourceProps.moFirstLineIndentation )
346*cdf0e10cSrcweir         moFirstLineIndentation = rSourceProps.moFirstLineIndentation;
347*cdf0e10cSrcweir }
348*cdf0e10cSrcweir 
349*cdf0e10cSrcweir void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase& rFilterBase,
350*cdf0e10cSrcweir     const Reference < XPropertySet >& xPropSet, PropertyMap& rioBulletMap, const BulletList* pMasterBuList, sal_Bool bApplyBulletMap, float fCharacterSize ) const
351*cdf0e10cSrcweir {
352*cdf0e10cSrcweir     PropertySet aPropSet( xPropSet );
353*cdf0e10cSrcweir     aPropSet.setProperties( maTextParagraphPropertyMap );
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir 	sal_Int32 nNumberingType = NumberingType::NUMBER_NONE;
356*cdf0e10cSrcweir 	if ( maBulletList.mnNumberingType.hasValue() )
357*cdf0e10cSrcweir 		maBulletList.mnNumberingType >>= nNumberingType;
358*cdf0e10cSrcweir 	else if ( pMasterBuList && pMasterBuList->mnNumberingType.hasValue() )
359*cdf0e10cSrcweir 		pMasterBuList->mnNumberingType >>= nNumberingType;
360*cdf0e10cSrcweir 	if ( nNumberingType == NumberingType::NUMBER_NONE )
361*cdf0e10cSrcweir         aPropSet.setProperty< sal_Int16 >( PROP_NumberingLevel, -1 );
362*cdf0e10cSrcweir 
363*cdf0e10cSrcweir 	maBulletList.pushToPropMap( rFilterBase, rioBulletMap );
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir 	if ( maParaTopMargin.bHasValue )
366*cdf0e10cSrcweir         aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( getCharHeightPoints( 18.0 ) ) );
367*cdf0e10cSrcweir 	if ( maParaBottomMargin.bHasValue )
368*cdf0e10cSrcweir         aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( getCharHeightPoints( 18.0 ) ) );
369*cdf0e10cSrcweir 	if ( nNumberingType == NumberingType::BITMAP )
370*cdf0e10cSrcweir 	{
371*cdf0e10cSrcweir         fCharacterSize = getCharHeightPoints( fCharacterSize );
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir 		com::sun::star::awt::Size aBulletSize;
374*cdf0e10cSrcweir 		aBulletSize.Width = aBulletSize.Height = static_cast< sal_Int32 >( ( fCharacterSize * ( 2540.0 / 72.0 ) * 0.8 ) );
375*cdf0e10cSrcweir         rioBulletMap[ PROP_GraphicSize ] <<= aBulletSize;
376*cdf0e10cSrcweir 	}
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir 	boost::optional< sal_Int32 > noParaLeftMargin( moParaLeftMargin );
379*cdf0e10cSrcweir 	boost::optional< sal_Int32 > noFirstLineIndentation( moFirstLineIndentation );
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir 	if ( nNumberingType != NumberingType::NUMBER_NONE )
382*cdf0e10cSrcweir 	{
383*cdf0e10cSrcweir 		if ( noParaLeftMargin )
384*cdf0e10cSrcweir 		{
385*cdf0e10cSrcweir             rioBulletMap[ PROP_LeftMargin ] <<= static_cast< sal_Int32 >( *noParaLeftMargin );
386*cdf0e10cSrcweir 			noParaLeftMargin = boost::optional< sal_Int32 >( 0 );
387*cdf0e10cSrcweir 		}
388*cdf0e10cSrcweir 		if ( noFirstLineIndentation )
389*cdf0e10cSrcweir 		{
390*cdf0e10cSrcweir             rioBulletMap[ PROP_FirstLineOffset ] <<= static_cast< sal_Int32 >( *noFirstLineIndentation );
391*cdf0e10cSrcweir 			noFirstLineIndentation = boost::optional< sal_Int32 >( 0 );
392*cdf0e10cSrcweir 		}
393*cdf0e10cSrcweir 	}
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 	if ( bApplyBulletMap )
396*cdf0e10cSrcweir 	{
397*cdf0e10cSrcweir 		Reference< XIndexReplace > xNumRule;
398*cdf0e10cSrcweir         aPropSet.getProperty( xNumRule, PROP_NumberingRules );
399*cdf0e10cSrcweir 		OSL_ENSURE( xNumRule.is(), "can't get Numbering rules");
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir 		if( xNumRule.is() )
402*cdf0e10cSrcweir 		{
403*cdf0e10cSrcweir             if( !rioBulletMap.empty() )
404*cdf0e10cSrcweir             {
405*cdf0e10cSrcweir                 Sequence< PropertyValue > aBulletPropSeq = rioBulletMap.makePropertyValueSequence();
406*cdf0e10cSrcweir 				xNumRule->replaceByIndex( getLevel(), makeAny( aBulletPropSeq ) );
407*cdf0e10cSrcweir             }
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir             aPropSet.setProperty( PROP_NumberingRules, xNumRule );
410*cdf0e10cSrcweir 		}
411*cdf0e10cSrcweir 	}
412*cdf0e10cSrcweir 	if ( noParaLeftMargin )
413*cdf0e10cSrcweir         aPropSet.setProperty( PROP_ParaLeftMargin, *noParaLeftMargin );
414*cdf0e10cSrcweir 	if ( noFirstLineIndentation )
415*cdf0e10cSrcweir         aPropSet.setProperty( PROP_ParaFirstLineIndent, *noFirstLineIndentation );
416*cdf0e10cSrcweir }
417*cdf0e10cSrcweir 
418*cdf0e10cSrcweir float TextParagraphProperties::getCharHeightPoints( float fDefault ) const
419*cdf0e10cSrcweir {
420*cdf0e10cSrcweir     return maTextCharacterProperties.getCharHeightPoints( fDefault );
421*cdf0e10cSrcweir }
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir } }
424