LCOV - code coverage report
Current view: top level - sw/source/ui/vba - vbaparagraphformat.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 261 0.0 %
Date: 2012-08-25 Functions: 0 44 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 410 0.0 %

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

Generated by: LCOV version 1.10