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