LCOV - code coverage report
Current view: top level - libreoffice/oox/source/drawingml - textparagraph.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 54 56 96.4 %
Date: 2012-12-27 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 "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 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          93 : TextParagraph::TextParagraph()
      38             : {
      39          93 : }
      40             : 
      41          93 : TextParagraph::~TextParagraph()
      42             : {
      43          93 : }
      44             : 
      45          36 : 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) const
      51             : {
      52             :     try {
      53          36 :         sal_Int32 nParagraphSize = 0;
      54          36 :         Reference< XTextRange > xStart( xAt, UNO_QUERY );
      55             : 
      56          36 :         sal_Int16 nLevel = maProperties.getLevel();
      57             : 
      58             :         SAL_INFO("oox", "TextParagraph::insertAt() - level " << nLevel);
      59             : 
      60          36 :         const TextParagraphPropertiesVector& rListStyle = rTextListStyle.getListStyle();
      61          36 :         if ( nLevel >= static_cast< sal_Int16 >( rListStyle.size() ) )
      62           0 :             nLevel = 0;
      63          36 :         TextParagraphPropertiesPtr pTextParagraphStyle;
      64          36 :         if ( rListStyle.size() )
      65          36 :             pTextParagraphStyle = rListStyle[ nLevel ];
      66             : 
      67          36 :         TextCharacterProperties aTextCharacterStyle;
      68          36 :         if ( pTextParagraphStyle.get() )
      69          36 :             aTextCharacterStyle.assignUsed( pTextParagraphStyle->getTextCharacterProperties() );
      70          36 :         aTextCharacterStyle.assignUsed( rTextStyleProperties );
      71          36 :         aTextCharacterStyle.assignUsed( maProperties.getTextCharacterProperties() );
      72             : 
      73          36 :         if( !bFirst )
      74             :         {
      75          18 :             xText->insertControlCharacter( xStart, ControlCharacter::APPEND_PARAGRAPH, sal_False );
      76          18 :             xAt->gotoEnd( sal_True );
      77             :         }
      78             : 
      79          36 :         sal_Int32 nCharHeight = 0;
      80          36 :         if ( maRuns.begin() == maRuns.end() )
      81             :         {
      82           1 :             PropertySet aPropSet( xStart );
      83             : 
      84           1 :             TextCharacterProperties aTextCharacterProps( aTextCharacterStyle );
      85           1 :             aTextCharacterProps.assignUsed( maEndProperties );
      86           1 :             if ( aTextCharacterProps.moHeight.has() )
      87           1 :                 nCharHeight = aTextCharacterProps.moHeight.get();
      88           1 :             aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
      89             :         }
      90             :         else
      91             :         {
      92          78 :             for( TextRunVector::const_iterator aIt = maRuns.begin(), aEnd = maRuns.end(); aIt != aEnd; ++aIt )
      93             :             {
      94          43 :                 sal_Int32 nLen = (*aIt)->getText().getLength();
      95             :                 // n#759180: Force use, maEndProperties for the last segment
      96             :                 // This is currently applied to only empty runs
      97          43 :                 if( !nLen && ( ( aIt + 1 ) == aEnd ) )
      98           2 :                     (*aIt)->getTextCharacterProperties().assignUsed( maEndProperties );
      99          43 :                 nCharHeight = std::max< sal_Int32 >( nCharHeight, (*aIt)->insertAt( rFilterBase, xText, xAt, aTextCharacterStyle ) );
     100          43 :                 nParagraphSize += nLen;
     101             :             }
     102             :         }
     103          36 :         xAt->gotoEnd( sal_True );
     104             : 
     105          36 :         PropertyMap aioBulletList;
     106          36 :         Reference< XPropertySet > xProps( xStart, UNO_QUERY);
     107          36 :         float fCharacterSize = nCharHeight > 0 ? GetFontHeight( nCharHeight ) :  18;
     108          36 :         if ( pTextParagraphStyle.get() )
     109             :         {
     110          36 :             TextParagraphProperties aParaProp;
     111          36 :             aParaProp.apply( *pTextParagraphStyle );
     112          36 :             aParaProp.apply( maProperties );
     113          36 :             aParaProp.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize, true );
     114          36 :             fCharacterSize = pTextParagraphStyle->getCharHeightPoints( fCharacterSize );
     115             : 
     116             :             // bullets have same color as following texts by default
     117         126 :             if( !aioBulletList.hasProperty( PROP_BulletColor ) && maRuns.size() > 0
     118          90 :                 && (*maRuns.begin())->getTextCharacterProperties().maCharColor.isUsed() )
     119           1 :                 aioBulletList[ PROP_BulletColor ] <<= (*maRuns.begin())->getTextCharacterProperties().maCharColor.getColor( rFilterBase.getGraphicHelper() );
     120             :         }
     121             : 
     122             :         // empty paragraphs do not have bullets in ppt
     123          36 :         if ( !nParagraphSize )
     124             :         {
     125           1 :             const OUString sNumberingLevel( CREATE_OUSTRING( "NumberingLevel" ) );
     126           1 :             xProps->setPropertyValue( sNumberingLevel, Any( static_cast< sal_Int16 >( -1 ) ) );
     127          36 :         }
     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          36 : }
     139             : 
     140             : 
     141          51 : } }
     142             : 
     143             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10