LCOV - code coverage report
Current view: top level - oox/source/drawingml - textparagraph.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 43 54 79.6 %
Date: 2012-08-25 Functions: 5 5 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 63 144 43.8 %

           Branch data     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                 :            : 
      20                 :            : #include "oox/drawingml/textparagraph.hxx"
      21                 :            : #include "oox/drawingml/drawingmltypes.hxx"
      22                 :            : #include "oox/drawingml/textcharacterproperties.hxx"
      23                 :            : 
      24                 :            : #include <rtl/ustring.hxx>
      25                 :            : #include "oox/helper/propertyset.hxx"
      26                 :            : #include <com/sun/star/text/XText.hpp>
      27                 :            : #include <com/sun/star/text/XTextCursor.hpp>
      28                 :            : #include <com/sun/star/text/ControlCharacter.hpp>
      29                 :            : 
      30                 :            : using ::rtl::OUString;
      31                 :            : using namespace ::com::sun::star::text;
      32                 :            : using namespace ::com::sun::star::uno;
      33                 :            : using namespace ::com::sun::star::beans;
      34                 :            : using namespace ::com::sun::star::frame;
      35                 :            : 
      36                 :            : namespace oox { namespace drawingml {
      37                 :            : 
      38 [ +  - ][ +  - ]:        198 : TextParagraph::TextParagraph()
      39                 :            : {
      40                 :        198 : }
      41                 :            : 
      42         [ +  - ]:        198 : TextParagraph::~TextParagraph()
      43                 :            : {
      44                 :        198 : }
      45                 :            : 
      46                 :         45 : void TextParagraph::insertAt(
      47                 :            :         const ::oox::core::XmlFilterBase& rFilterBase,
      48                 :            :         const Reference < XText > &xText,
      49                 :            :         const Reference < XTextCursor > &xAt,
      50                 :            :         const TextCharacterProperties& rTextStyleProperties,
      51                 :            :         const TextListStyle& rTextListStyle, bool bFirst) const
      52                 :            : {
      53                 :            :     try {
      54                 :         45 :         sal_Int32 nParagraphSize = 0;
      55         [ +  - ]:         45 :         Reference< XTextRange > xStart( xAt, UNO_QUERY );
      56                 :            : 
      57                 :         45 :         sal_Int16 nLevel = maProperties.getLevel();
      58                 :            : 
      59                 :            :         SAL_INFO("oox", "TextParagraph::insertAt() - level " << nLevel);
      60                 :            : 
      61                 :         45 :         const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle();
      62         [ -  + ]:         45 :         if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) )
      63                 :          0 :             nLevel = 0;
      64         [ +  - ]:         45 :         TextParagraphPropertiesPtr pTextParagraphStyle;
      65         [ +  - ]:         45 :         if ( rListStyle.size() )
      66         [ +  - ]:         45 :             pTextParagraphStyle = rListStyle[ nLevel ];
      67                 :            : 
      68         [ +  - ]:         45 :         TextCharacterProperties aTextCharacterStyle;
      69         [ +  - ]:         45 :         if ( pTextParagraphStyle.get() )
      70         [ +  - ]:         45 :             aTextCharacterStyle.assignUsed( pTextParagraphStyle->getTextCharacterProperties() );
      71         [ +  - ]:         45 :         aTextCharacterStyle.assignUsed( rTextStyleProperties );
      72         [ +  - ]:         45 :         aTextCharacterStyle.assignUsed( maProperties.getTextCharacterProperties() );
      73                 :            : 
      74         [ +  + ]:         45 :         if( !bFirst )
      75                 :            :         {
      76 [ +  - ][ +  - ]:          6 :             xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False );
      77 [ +  - ][ +  - ]:          6 :             xAt->gotoEnd( sal_True );
      78                 :            :         }
      79                 :            : 
      80                 :         45 :         sal_Int32 nCharHeight = 0;
      81 [ +  - ][ -  + ]:         45 :         if ( maRuns.begin() == maRuns.end() )
      82                 :            :         {
      83         [ #  # ]:          0 :             PropertySet aPropSet( xStart );
      84                 :            : 
      85         [ #  # ]:          0 :             TextCharacterProperties aTextCharacterProps( aTextCharacterStyle );
      86         [ #  # ]:          0 :             aTextCharacterProps.assignUsed( maEndProperties );
      87         [ #  # ]:          0 :             if ( aTextCharacterProps.moHeight.has() )
      88                 :          0 :                 nCharHeight = aTextCharacterProps.moHeight.get();
      89 [ #  # ][ #  # ]:          0 :             aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
                 [ #  # ]
      90                 :            :         }
      91                 :            :         else
      92                 :            :         {
      93 [ +  - ][ +  + ]:        108 :             for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt )
      94                 :            :             {
      95                 :         63 :                 sal_Int32 nLen = (*aIt)->getText().getLength();
      96                 :            :                 // n#759180: Force use, maEndProperties for the last segment
      97                 :            :                 // This is currently applied to only empty runs
      98 [ +  - ][ +  - ]:         63 :                 if( !nLen && ( ( aIt + 1 ) == aEnd ) )
         [ +  + ][ +  + ]
         [ +  + ][ +  +  
             #  #  #  # ]
                 [ +  + ]
      99         [ +  - ]:          6 :                     (*aIt)->getTextCharacterProperties().assignUsed( maEndProperties );
     100 [ +  - ][ +  - ]:         63 :                 nCharHeight = std::max< sal_Int32 >( nCharHeight, (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ) );
     101                 :         63 :                 nParagraphSize += nLen;
     102                 :            :             }
     103                 :            :         }
     104 [ +  - ][ +  - ]:         45 :         xAt->gotoEnd( sal_True );
     105                 :            : 
     106         [ +  - ]:         45 :         PropertyMap aioBulletList;
     107         [ +  - ]:         45 :         Reference< XPropertySet > xProps( xStart, UNO_QUERY);
     108 [ +  + ][ +  - ]:         45 :         float fCharacterSize = nCharHeight > 0 ? GetFontHeight( nCharHeight ) :  18;
     109         [ +  - ]:         45 :         if ( pTextParagraphStyle.get() )
     110                 :            :         {
     111         [ +  - ]:         45 :             pTextParagraphStyle->pushToPropSet( &rFilterBase, xProps, aioBulletList, NULL, sal_True, fCharacterSize, true );
     112         [ +  - ]:         45 :             fCharacterSize = pTextParagraphStyle->getCharHeightPoints( fCharacterSize );
     113                 :            : 
     114                 :            :             // bullets have same color as following texts by default
     115 [ +  - ][ +  + ]:        126 :             if( !aioBulletList.hasProperty( PROP_BulletColor ) && maRuns.size() > 0
           [ +  -  -  + ]
                 [ -  + ]
     116 [ +  + ][ #  # ]:         81 :                 && (*maRuns.begin())->getTextCharacterProperties().maCharColor.isUsed() )
     117 [ #  # ][ #  # ]:          0 :                 aioBulletList[ PROP_BulletColor ] <<= (*maRuns.begin())->getTextCharacterProperties().maCharColor.getColor( rFilterBase.getGraphicHelper() );
         [ #  # ][ #  # ]
     118                 :            : 
     119         [ +  - ]:         45 :             maProperties.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize );
     120                 :            :         }
     121                 :            : 
     122                 :            :         // empty paragraphs do not have bullets in ppt
     123         [ -  + ]:         45 :         if ( !nParagraphSize )
     124                 :            :         {
     125         [ #  # ]:          0 :             const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) );
     126 [ #  # ][ #  # ]:          0 :             xProps->setPropertyValue( sNumberingLevel, Any( static_cast< sal_Int16 >( -1 ) ) );
                 [ #  # ]
     127 [ +  - ][ +  - ]:         45 :         }
                 [ #  # ]
     128                 :            : 
     129                 :            : // FIXME this is causing a lot of dispruption (ie does not work). I wonder what to do -- Hub
     130                 :            : //          Reference< XTextRange > xEnd( xAt, UNO_QUERY );
     131                 :            : //      Reference< XPropertySet > xProps2( xEnd, UNO_QUERY );
     132                 :            : //          mpEndProperties->pushToPropSet( xProps2 );
     133                 :            :     }
     134                 :          0 :     catch( Exception & )
     135                 :            :     {
     136                 :            :         SAL_INFO("oox", "exception in TextParagraph::insertAt");
     137                 :            :     }
     138                 :         45 : }
     139                 :            : 
     140                 :            : 
     141 [ +  - ][ +  - ]:        285 : } }
     142                 :            : 
     143                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10