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

Generated by: LCOV version 1.11