LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/vba - vbaparagraphformat.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 261 0.0 %
Date: 2012-12-27 Functions: 0 44 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10