1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #include "vbaparagraphformat.hxx"
28 #include <vbahelper/vbahelper.hxx>
29 #include <tools/diagnose_ex.h>
30 #include "wordvbahelper.hxx"
31 #include <com/sun/star/style/LineSpacingMode.hpp>
32 #include <ooo/vba/word/WdLineSpacing.hpp>
33 #include <ooo/vba/word/WdParagraphAlignment.hpp>
34 #include <ooo/vba/word/WdOutlineLevel.hpp>
35 #include <com/sun/star/style/ParagraphAdjust.hpp>
36 #include <com/sun/star/style/BreakType.hpp>
37 
38 
39 using namespace ::ooo::vba;
40 using namespace ::com::sun::star;
41 
42 static const sal_Int16 CHARACTER_INDENT_FACTOR = 12;
43 static const sal_Int16 PERCENT100 = 100;
44 static const sal_Int16 PERCENT150 = 150;
45 static const sal_Int16 PERCENT200 = 200;
46 
47 SwVbaParagraphFormat::SwVbaParagraphFormat( const uno::Reference< ooo::vba::XHelperInterface >& rParent, const uno::Reference< uno::XComponentContext >& rContext, const uno::Reference< text::XTextDocument >& rTextDocument, const uno::Reference< beans::XPropertySet >& rParaProps ) : SwVbaParagraphFormat_BASE( rParent, rContext ), mxTextDocument( rTextDocument ), mxParaProps( rParaProps )
48 {
49 }
50 
51 SwVbaParagraphFormat::~SwVbaParagraphFormat()
52 {
53 }
54 
55 sal_Int32 SAL_CALL SwVbaParagraphFormat::getAlignment() throw (uno::RuntimeException)
56 {
57     style::ParagraphAdjust aParaAdjust = style::ParagraphAdjust_LEFT;
58     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAdjust") ) ) >>= aParaAdjust;
59     return getMSWordAlignment( aParaAdjust );
60 }
61 
62 void SAL_CALL SwVbaParagraphFormat::setAlignment( sal_Int32 _alignment ) throw (uno::RuntimeException)
63 {
64     style::ParagraphAdjust aParaAdjust = ( style::ParagraphAdjust ) getOOoAlignment( _alignment );
65     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaAdjust") ), uno::makeAny( aParaAdjust ) );
66 }
67 
68 float SAL_CALL SwVbaParagraphFormat::getFirstLineIndent() throw (uno::RuntimeException)
69 {
70     sal_Int32 indent = 0;
71     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaFirstLineIndent") ) ) >>= indent;
72     return (float)( Millimeter::getInPoints( indent ) );
73 }
74 
75 void SAL_CALL SwVbaParagraphFormat::setFirstLineIndent( float _firstlineindent ) throw (uno::RuntimeException)
76 {
77     sal_Int32 indent = Millimeter::getInHundredthsOfOneMillimeter( _firstlineindent );
78     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaFirstLineIndent") ), uno::makeAny( indent ) );
79 }
80 
81 uno::Any SAL_CALL SwVbaParagraphFormat::getKeepTogether() throw (uno::RuntimeException)
82 {
83     sal_Bool bKeep = sal_False;
84     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaKeepTogether") ) ) >>= bKeep;
85     return uno::makeAny ( bKeep );
86 }
87 
88 void SAL_CALL SwVbaParagraphFormat::setKeepTogether( const uno::Any& _keeptogether ) throw (uno::RuntimeException)
89 {
90     sal_Bool bKeep = sal_False;
91     if( _keeptogether >>= bKeep )
92     {
93         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaKeepTogether") ), uno::makeAny( bKeep ) );
94     }
95     else
96     {
97         DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
98     }
99 }
100 
101 uno::Any SAL_CALL SwVbaParagraphFormat::getKeepWithNext() throw (uno::RuntimeException)
102 {
103     sal_Bool bKeep = sal_False;
104     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaSplit") ) ) >>= bKeep;
105     return uno::makeAny ( bKeep );
106 }
107 
108 void SAL_CALL SwVbaParagraphFormat::setKeepWithNext( const uno::Any& _keepwithnext ) throw (uno::RuntimeException)
109 {
110     sal_Bool bKeep = sal_False;
111     if( _keepwithnext >>= bKeep )
112     {
113         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaSplit") ), uno::makeAny( bKeep ) );
114     }
115     else
116     {
117         DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
118     }
119 }
120 
121 uno::Any SAL_CALL SwVbaParagraphFormat::getHyphenation() throw (uno::RuntimeException)
122 {
123     sal_Bool bHypn = sal_False;
124     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsHyphenation") ) ) >>= bHypn;
125     return uno::makeAny ( bHypn );
126 }
127 
128 void SAL_CALL SwVbaParagraphFormat::setHyphenation( const uno::Any& _hyphenation ) throw (uno::RuntimeException)
129 {
130     sal_Bool bHypn = sal_False;
131     if( _hyphenation >>= bHypn )
132     {
133         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaIsHyphenation") ), uno::makeAny( bHypn ) );
134     }
135     else
136     {
137         DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
138     }
139 }
140 
141 float SAL_CALL SwVbaParagraphFormat::getLineSpacing() throw (uno::RuntimeException)
142 {
143     style::LineSpacing aLineSpacing;
144     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ) ) >>= aLineSpacing;
145     return getMSWordLineSpacing( aLineSpacing );
146 }
147 
148 void SAL_CALL SwVbaParagraphFormat::setLineSpacing( float _linespacing ) throw (uno::RuntimeException)
149 {
150     style::LineSpacing aLineSpacing;
151     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ) ) >>= aLineSpacing;
152     aLineSpacing = getOOoLineSpacing( _linespacing, aLineSpacing.Mode );
153     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ), uno::makeAny( aLineSpacing ) );
154 }
155 
156 sal_Int32 SAL_CALL SwVbaParagraphFormat::getLineSpacingRule() throw (uno::RuntimeException)
157 {
158     style::LineSpacing aLineSpacing;
159     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ) ) >>= aLineSpacing;
160     return getMSWordLineSpacingRule( aLineSpacing );
161 }
162 
163 void SAL_CALL SwVbaParagraphFormat::setLineSpacingRule( sal_Int32 _linespacingrule ) throw (uno::RuntimeException)
164 {
165     style::LineSpacing aLineSpacing = getOOoLineSpacingFromRule( _linespacingrule );
166     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineSpacing") ), uno::makeAny( aLineSpacing ) );
167 }
168 
169 uno::Any SAL_CALL SwVbaParagraphFormat::getNoLineNumber() throw (uno::RuntimeException)
170 {
171     sal_Bool noLineNum = sal_False;
172     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineNumberCount") ) ) >>= noLineNum;
173     return uno::makeAny ( noLineNum );
174 }
175 
176 void SAL_CALL SwVbaParagraphFormat::setNoLineNumber( const uno::Any& _nolinenumber ) throw (uno::RuntimeException)
177 {
178     sal_Bool noLineNum = sal_False;
179     if( _nolinenumber >>= noLineNum )
180     {
181         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLineNumberCount") ), uno::makeAny( noLineNum ) );
182     }
183     else
184     {
185         DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
186     }
187 }
188 
189 sal_Int32 SAL_CALL SwVbaParagraphFormat::getOutlineLevel() throw (uno::RuntimeException)
190 {
191     sal_Int32 nLevel = word::WdOutlineLevel::wdOutlineLevelBodyText;
192     rtl::OUString aHeading;
193     const rtl::OUString HEADING = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Heading") );
194     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaStyleName") ) ) >>= aHeading;
195     if( aHeading.indexOf( HEADING ) == 0 )
196     {
197         // get the sub string after "Heading"
198         nLevel = aHeading.copy( HEADING.getLength() ).toInt32();
199     }
200     return nLevel;
201 }
202 
203 void SAL_CALL SwVbaParagraphFormat::setOutlineLevel( sal_Int32 /*_outlinelevel*/ ) throw (uno::RuntimeException)
204 {
205     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
206 }
207 
208 uno::Any SAL_CALL SwVbaParagraphFormat::getPageBreakBefore() throw (uno::RuntimeException)
209 {
210     style::BreakType aBreakType;
211     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ) ) >>= aBreakType;
212     sal_Bool bBreakBefore = ( aBreakType == style::BreakType_PAGE_BEFORE || aBreakType == style::BreakType_PAGE_BOTH );
213     return uno::makeAny( bBreakBefore );
214 }
215 
216 void SAL_CALL SwVbaParagraphFormat::setPageBreakBefore( const uno::Any& _breakbefore ) throw (uno::RuntimeException)
217 {
218     sal_Bool bBreakBefore = sal_False;
219     if( _breakbefore >>= bBreakBefore )
220     {
221         style::BreakType aBreakType;
222         mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ) ) >>= aBreakType;
223         if( bBreakBefore )
224         {
225             if( aBreakType == style::BreakType_NONE )
226                 aBreakType = style::BreakType_PAGE_BEFORE;
227             else if ( aBreakType == style::BreakType_PAGE_AFTER )
228                 aBreakType = style::BreakType_PAGE_BOTH;
229         }
230         else
231         {
232             if( aBreakType == style::BreakType_PAGE_BOTH )
233                 aBreakType = style::BreakType_PAGE_AFTER;
234             else if ( aBreakType == style::BreakType_PAGE_BEFORE )
235                 aBreakType = style::BreakType_PAGE_AFTER;
236         }
237         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BreakType") ), uno::makeAny( aBreakType ) );
238     }
239     else
240     {
241         DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
242     }
243 }
244 
245 float SAL_CALL SwVbaParagraphFormat::getSpaceBefore() throw (uno::RuntimeException)
246 {
247     sal_Int32 nSpace = 0;
248     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTopMargin") ) ) >>= nSpace;
249     return (float)( Millimeter::getInPoints( nSpace ) );
250 }
251 
252 void SAL_CALL SwVbaParagraphFormat::setSpaceBefore( float _space ) throw (uno::RuntimeException)
253 {
254     sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _space );
255     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaTopMargin") ), uno::makeAny( nSpace ) );
256 }
257 
258 float SAL_CALL SwVbaParagraphFormat::getSpaceAfter() throw (uno::RuntimeException)
259 {
260     sal_Int32 nSpace = 0;
261     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaBottomMargin") ) ) >>= nSpace;
262     return (float)( Millimeter::getInPoints( nSpace ) );
263 }
264 
265 void SAL_CALL SwVbaParagraphFormat::setSpaceAfter( float _space ) throw (uno::RuntimeException)
266 {
267     sal_Int32 nSpace = Millimeter::getInHundredthsOfOneMillimeter( _space );
268     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaBottomMargin") ), uno::makeAny( nSpace ) );
269 }
270 
271 float SAL_CALL SwVbaParagraphFormat::getLeftIndent() throw (uno::RuntimeException)
272 {
273     sal_Int32 nIndent = 0;
274     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLeftMargin") ) ) >>= nIndent;
275     return (float)( Millimeter::getInPoints( nIndent ) );
276 }
277 
278 void SAL_CALL SwVbaParagraphFormat::setLeftIndent( float _leftindent ) throw (uno::RuntimeException)
279 {
280     sal_Int32 nIndent = Millimeter::getInHundredthsOfOneMillimeter( _leftindent );
281     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaLeftMargin") ), uno::makeAny( nIndent ) );
282 }
283 
284 float SAL_CALL SwVbaParagraphFormat::getRightIndent() throw (uno::RuntimeException)
285 {
286     sal_Int32 nIndent = 0;
287     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaRightMargin") ) ) >>= nIndent;
288     return (float)( Millimeter::getInPoints( nIndent ) );
289 }
290 
291 void SAL_CALL SwVbaParagraphFormat::setRightIndent( float _rightindent ) throw (uno::RuntimeException)
292 {
293     sal_Int32 nIndent = Millimeter::getInHundredthsOfOneMillimeter( _rightindent );
294     mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaRightMargin") ), uno::makeAny( nIndent ) );
295 }
296 
297 uno::Any SAL_CALL SwVbaParagraphFormat::getTabStops() throw (uno::RuntimeException)
298 {
299     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
300 }
301 
302 void SAL_CALL SwVbaParagraphFormat::setTabStops( const uno::Any& /*_tabstops*/ ) throw (uno::RuntimeException)
303 {
304     throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
305 }
306 
307 uno::Any SAL_CALL SwVbaParagraphFormat::getWidowControl() throw (uno::RuntimeException)
308 {
309     sal_Bool bWidow = sal_False;
310     sal_Int8 nWidow = 0;
311     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaWidows") ) ) >>= nWidow;
312     sal_Int8 nOrphan = 0;
313     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaOrphans") ) ) >>= nOrphan;
314     // if the amount of single lines on one page > 1 and the same of start and end of the paragraph,
315     // true is retured.
316     bWidow = ( nWidow > 1 && nOrphan == nWidow );
317     return uno::makeAny( bWidow );
318 }
319 
320 void SAL_CALL SwVbaParagraphFormat::setWidowControl( const uno::Any& _widowcontrol ) throw (uno::RuntimeException)
321 {
322     // if we get true, the part of the paragraph on one page has to be
323     // at least two lines
324     sal_Bool bWidow = sal_False;
325     if( _widowcontrol >>= bWidow )
326     {
327         sal_Int8 nControl = bWidow? 2:1;
328         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaWidows") ), uno::makeAny( nControl ) );
329         mxParaProps->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ParaOrphans") ), uno::makeAny( nControl ) );
330     }
331     else
332     {
333         DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
334     }
335 }
336 
337 style::LineSpacing SwVbaParagraphFormat::getOOoLineSpacing( float _lineSpace, sal_Int16 mode )
338 {
339     style::LineSpacing aLineSpacing;
340     if( mode != style::LineSpacingMode::MINIMUM && mode != style::LineSpacingMode::FIX )
341     {
342         // special behaviour of word: if the space is set to these values, the rule and
343         // the height are changed accordingly
344         if( _lineSpace == CHARACTER_INDENT_FACTOR )
345         {
346             aLineSpacing.Mode = style::LineSpacingMode::PROP;
347             aLineSpacing.Height = PERCENT100;
348         }
349         else if( _lineSpace == ( sal_Int16 )( CHARACTER_INDENT_FACTOR * 1.5 ) )
350         {
351             aLineSpacing.Mode = style::LineSpacingMode::PROP;
352             aLineSpacing.Height = PERCENT150;
353         }
354         else if( _lineSpace == ( sal_Int16 )( ( CHARACTER_INDENT_FACTOR ) * 2 ) )
355         {
356             aLineSpacing.Mode = style::LineSpacingMode::PROP;
357             aLineSpacing.Height = PERCENT200;
358         }
359         else
360         {
361             aLineSpacing.Mode = style::LineSpacingMode::FIX;
362             aLineSpacing.Height = ( sal_Int16 )( Millimeter::getInHundredthsOfOneMillimeter( _lineSpace ) );
363         }
364     }
365     else
366     {
367         aLineSpacing.Mode = mode;
368         aLineSpacing.Height = ( sal_Int16 )( Millimeter::getInHundredthsOfOneMillimeter( _lineSpace ) );
369     }
370     return aLineSpacing;
371 }
372 
373 style::LineSpacing SwVbaParagraphFormat::getOOoLineSpacingFromRule( sal_Int32 _linespacingrule )
374 {
375     style::LineSpacing aLineSpacing;
376     switch( _linespacingrule )
377     {
378         case word::WdLineSpacing::wdLineSpace1pt5:
379         {
380             aLineSpacing.Mode = style::LineSpacingMode::PROP;
381             aLineSpacing.Height = PERCENT150;
382             break;
383         }
384         case word::WdLineSpacing::wdLineSpaceAtLeast:
385         {
386             aLineSpacing.Mode = style::LineSpacingMode::MINIMUM;
387             aLineSpacing.Height = getCharHeight();
388             break;
389         }
390         case word::WdLineSpacing::wdLineSpaceDouble:
391         {
392             aLineSpacing.Mode = style::LineSpacingMode::PROP;
393             aLineSpacing.Height = getCharHeight();
394             break;
395         }
396         case word::WdLineSpacing::wdLineSpaceExactly:
397         case word::WdLineSpacing::wdLineSpaceMultiple:
398         {
399             aLineSpacing.Mode = style::LineSpacingMode::FIX;
400             aLineSpacing.Height = getCharHeight();
401             break;
402         }
403         case word::WdLineSpacing::wdLineSpaceSingle:
404         {
405             aLineSpacing.Mode = style::LineSpacingMode::PROP;
406             aLineSpacing.Height = PERCENT100;
407             break;
408         }
409         default:
410         {
411             DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
412             break;
413         }
414     }
415     return aLineSpacing;
416 }
417 
418 float SwVbaParagraphFormat::getMSWordLineSpacing( style::LineSpacing& rLineSpacing )
419 {
420     float wdLineSpacing = 0;
421     if( rLineSpacing.Mode != style::LineSpacingMode::PROP )
422     {
423         wdLineSpacing = (float)( Millimeter::getInPoints( rLineSpacing.Height ) );
424     }
425     else
426     {
427         wdLineSpacing = (float)( CHARACTER_INDENT_FACTOR * rLineSpacing.Height ) / PERCENT100;
428     }
429     return wdLineSpacing;
430 }
431 
432 sal_Int32 SwVbaParagraphFormat::getMSWordLineSpacingRule( style::LineSpacing& rLineSpacing )
433 {
434     sal_Int32 wdLineSpacing = word::WdLineSpacing::wdLineSpaceSingle;
435     switch( rLineSpacing.Mode )
436     {
437         case style::LineSpacingMode::PROP:
438         {
439             switch( rLineSpacing.Height )
440             {
441                 case PERCENT100:
442                 {
443                     wdLineSpacing = word::WdLineSpacing::wdLineSpaceSingle;
444                     break;
445                 }
446                 case PERCENT150:
447                 {
448                     wdLineSpacing = word::WdLineSpacing::wdLineSpace1pt5;
449                     break;
450                 }
451                 case PERCENT200:
452                 {
453                     wdLineSpacing = word::WdLineSpacing::wdLineSpaceDouble;
454                     break;
455                 }
456                 default:
457                 {
458                     wdLineSpacing = word::WdLineSpacing::wdLineSpaceMultiple;
459                 }
460             }
461             break;
462         }
463         case style::LineSpacingMode::MINIMUM:
464         {
465             wdLineSpacing = word::WdLineSpacing::wdLineSpaceAtLeast;
466             break;
467         }
468         case style::LineSpacingMode::FIX:
469         case style::LineSpacingMode::LEADING:
470         {
471             wdLineSpacing = word::WdLineSpacing::wdLineSpaceExactly;
472             break;
473         }
474         default:
475         {
476             DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
477         }
478     }
479     return wdLineSpacing;
480 }
481 
482 sal_Int16 SwVbaParagraphFormat::getCharHeight() throw (uno::RuntimeException)
483 {
484     float fCharHeight = 0.0;
485     mxParaProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CharHeight") ) ) >>= fCharHeight;
486     return (sal_Int16)( Millimeter::getInHundredthsOfOneMillimeter( fCharHeight ) );
487 }
488 
489 sal_Int32 SwVbaParagraphFormat::getOOoAlignment( sal_Int32 _alignment )
490 {
491     sal_Int32 nParaAjust = style::ParagraphAdjust_LEFT;
492     switch( _alignment )
493     {
494         case word::WdParagraphAlignment::wdAlignParagraphCenter:
495         {
496             nParaAjust = style::ParagraphAdjust_CENTER;
497             break;
498         }
499         case word::WdParagraphAlignment::wdAlignParagraphJustify:
500         {
501             nParaAjust = style::ParagraphAdjust_BLOCK;
502             break;
503         }
504         case word::WdParagraphAlignment::wdAlignParagraphLeft:
505         {
506             nParaAjust = style::ParagraphAdjust_LEFT;
507             break;
508         }
509         case word::WdParagraphAlignment::wdAlignParagraphRight:
510         {
511             nParaAjust = style::ParagraphAdjust_RIGHT;
512             break;
513         }
514         default:
515         {
516             DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
517         }
518     }
519     return nParaAjust;
520 }
521 
522 sal_Int32 SwVbaParagraphFormat::getMSWordAlignment( sal_Int32 _alignment )
523 {
524     sal_Int32 wdAlignment = word::WdParagraphAlignment::wdAlignParagraphLeft;
525     switch( _alignment )
526     {
527         case style::ParagraphAdjust_CENTER:
528         {
529             wdAlignment = word::WdParagraphAlignment::wdAlignParagraphCenter;
530             break;
531         }
532         case style::ParagraphAdjust_LEFT:
533         {
534             wdAlignment = word::WdParagraphAlignment::wdAlignParagraphLeft;
535             break;
536         }
537         case style::ParagraphAdjust_BLOCK:
538         {
539             wdAlignment = word::WdParagraphAlignment::wdAlignParagraphJustify;
540             break;
541         }
542         case style::ParagraphAdjust_RIGHT:
543         {
544             wdAlignment = word::WdParagraphAlignment::wdAlignParagraphRight;
545             break;
546         }
547         default:
548         {
549             DebugHelper::exception( SbERR_BAD_PARAMETER, rtl::OUString() );
550         }
551     }
552     return wdAlignment;
553 }
554 
555 rtl::OUString&
556 SwVbaParagraphFormat::getServiceImplName()
557 {
558 	static rtl::OUString sImplName( RTL_CONSTASCII_USTRINGPARAM("SwVbaParagraphFormat") );
559 	return sImplName;
560 }
561 
562 uno::Sequence< rtl::OUString >
563 SwVbaParagraphFormat::getServiceNames()
564 {
565 	static uno::Sequence< rtl::OUString > aServiceNames;
566 	if ( aServiceNames.getLength() == 0 )
567 	{
568 		aServiceNames.realloc( 1 );
569 		aServiceNames[ 0 ] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.word.ParagraphFormat" ) );
570 	}
571 	return aServiceNames;
572 }
573 
574