LCOV - code coverage report
Current view: top level - oox/source/drawingml - textrun.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 25 79 31.6 %
Date: 2012-08-25 Functions: 6 6 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 23 178 12.9 %

           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/textrun.hxx"
      21                 :            : 
      22                 :            : #include <com/sun/star/text/ControlCharacter.hpp>
      23                 :            : #include <com/sun/star/beans/XMultiPropertySet.hpp>
      24                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      25                 :            : #include <com/sun/star/text/XTextField.hpp>
      26                 :            : 
      27                 :            : #include "oox/helper/helper.hxx"
      28                 :            : #include "oox/helper/propertyset.hxx"
      29                 :            : #include "oox/core/xmlfilterbase.hxx"
      30                 :            : #include "oox/token/tokens.hxx"
      31                 :            : 
      32                 :            : using ::rtl::OUString;
      33                 :            : using namespace ::com::sun::star::uno;
      34                 :            : using namespace ::com::sun::star::text;
      35                 :            : using namespace ::com::sun::star::beans;
      36                 :            : using namespace ::com::sun::star::frame;
      37                 :            : using namespace ::com::sun::star::lang;
      38                 :            : 
      39                 :            : namespace oox { namespace drawingml {
      40                 :            : 
      41                 :        183 : TextRun::TextRun() :
      42         [ +  - ]:        183 :     mbIsLineBreak( false )
      43                 :            : {
      44                 :        183 : }
      45                 :            : 
      46         [ +  - ]:        183 : TextRun::~TextRun()
      47                 :            : {
      48         [ -  + ]:        333 : }
      49                 :            : 
      50                 :         51 : sal_Int32 TextRun::insertAt(
      51                 :            :         const ::oox::core::XmlFilterBase& rFilterBase,
      52                 :            :         const Reference < XText > & xText,
      53                 :            :         const Reference < XTextCursor > &xAt,
      54                 :            :         const TextCharacterProperties& rTextCharacterStyle ) const
      55                 :            : {
      56                 :         51 :     sal_Int32 nCharHeight = 0;
      57                 :            :     try {
      58         [ +  - ]:         51 :         Reference< XTextRange > xStart( xAt, UNO_QUERY );
      59         [ +  - ]:         51 :         PropertySet aPropSet( xStart );
      60                 :            : 
      61         [ +  - ]:         51 :         TextCharacterProperties aTextCharacterProps( rTextCharacterStyle );
      62         [ +  - ]:         51 :         aTextCharacterProps.assignUsed( maTextCharacterProperties );
      63         [ +  + ]:         51 :         if ( aTextCharacterProps.moHeight.has() )
      64                 :         45 :             nCharHeight = aTextCharacterProps.moHeight.get();
      65         [ +  - ]:         51 :         aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
      66                 :            : 
      67         [ +  - ]:         51 :         if( maTextCharacterProperties.maHyperlinkPropertyMap.empty() )
      68                 :            :         {
      69         [ +  + ]:         51 :             if( mbIsLineBreak )
      70                 :            :             {
      71                 :            :                 OSL_TRACE( "OOX: TextRun::insertAt() insert line break" );
      72 [ +  - ][ +  - ]:          6 :                 xText->insertControlCharacter( xStart, ControlCharacter::LINE_BREAK, sal_False );
      73                 :            :             }
      74                 :            :             else
      75                 :            :             {
      76                 :         45 :                 OUString aLatinFontName, aSymbolFontName;
      77                 :         45 :                 sal_Int16 nSymbolFontFamily = 0, nSymbolFontPitch = 0;
      78                 :            : 
      79 [ +  - ][ +  - ]:         45 :                 if ( !aTextCharacterProps.maSymbolFont.getFontData( aSymbolFontName, nSymbolFontPitch, nSymbolFontFamily, rFilterBase ) )
      80 [ +  - ][ +  - ]:         45 :                     xText->insertString( xStart, getText(), sal_False );
      81         [ #  # ]:          0 :                 else if ( !getText().isEmpty() )
      82                 :            :                 {   // !!#i113673<<<
      83                 :          0 :                     sal_Int16 nLatinFontPitch = 0, nLatinFontFamily = 0;
      84         [ #  # ]:          0 :                     aTextCharacterProps.maLatinFont.getFontData( aLatinFontName, nLatinFontPitch, nLatinFontFamily, rFilterBase );
      85                 :            : 
      86                 :          0 :                     sal_Int32 nIndex = 0;
      87                 :          0 :                     while ( sal_True )
      88                 :            :                     {
      89                 :          0 :                         sal_Int32 nCount = 0;
      90                 :          0 :                         sal_Bool bSymbol = ( getText()[ nIndex ] & 0xff00 ) == 0xf000;
      91         [ #  # ]:          0 :                         if ( bSymbol )
      92                 :            :                         {
      93         [ #  # ]:          0 :                             do
           [ #  #  #  # ]
      94                 :            :                             {
      95                 :          0 :                                 nCount++;
      96                 :            :                             }
      97                 :          0 :                             while( ( ( nCount + nIndex ) < getText().getLength() ) && ( ( getText()[ nCount + nIndex ] & 0xff00 ) == 0xf000 ) );
      98 [ #  # ][ #  # ]:          0 :                             aPropSet.setAnyProperty( PROP_CharFontName, Any( aSymbolFontName ) );
      99 [ #  # ][ #  # ]:          0 :                             aPropSet.setAnyProperty( PROP_CharFontPitch, Any( nSymbolFontPitch ) );
     100 [ #  # ][ #  # ]:          0 :                             aPropSet.setAnyProperty( PROP_CharFontFamily, Any( nSymbolFontFamily ) );
     101                 :            :                         }
     102                 :            :                         else
     103                 :            :                         {
     104         [ #  # ]:          0 :                             do
           [ #  #  #  # ]
     105                 :            :                             {
     106                 :          0 :                                 nCount++;
     107                 :            :                             }
     108                 :          0 :                             while( ( ( nCount + nIndex ) < getText().getLength() ) && ( ( getText()[ nCount + nIndex ] & 0xff00 ) != 0xf000 ) );
     109 [ #  # ][ #  # ]:          0 :                             aPropSet.setAnyProperty( PROP_CharFontName, Any( aLatinFontName ) );
     110 [ #  # ][ #  # ]:          0 :                             aPropSet.setAnyProperty( PROP_CharFontPitch, Any( nLatinFontPitch ) );
     111 [ #  # ][ #  # ]:          0 :                             aPropSet.setAnyProperty( PROP_CharFontFamily, Any( nLatinFontFamily ) );
     112                 :            :                         }
     113                 :          0 :                         rtl::OUString aSubString( getText().copy( nIndex, nCount ) );
     114 [ #  # ][ #  # ]:          0 :                         xText->insertString( xStart, aSubString, sal_False );
     115                 :          0 :                         nIndex += nCount;
     116                 :            : 
     117         [ #  # ]:          0 :                         if ( nIndex >= getText().getLength() )
     118                 :            :                             break;
     119                 :            : 
     120 [ #  # ][ #  # ]:          0 :                         xStart = Reference< XTextRange >( xAt, UNO_QUERY );
     121 [ #  # ][ #  # ]:          0 :                         aPropSet = PropertySet( xStart );
                 [ #  # ]
     122 [ #  # ][ #  # ]:          0 :                         aTextCharacterProps.pushToPropSet( aPropSet, rFilterBase );
     123                 :          0 :                     }
     124                 :         45 :                 }
     125                 :            :             }
     126                 :            :         }
     127                 :            :         else
     128                 :            :         {
     129                 :            :             OSL_TRACE( "OOX: URL field" );
     130 [ #  # ][ #  # ]:          0 :             Reference< XMultiServiceFactory > xFactory( rFilterBase.getModel(), UNO_QUERY );
     131 [ #  # ][ #  # ]:          0 :             Reference< XTextField > xField( xFactory->createInstance( CREATE_OUSTRING( "com.sun.star.text.TextField.URL" ) ), UNO_QUERY );
         [ #  # ][ #  # ]
     132         [ #  # ]:          0 :             if( xField.is() )
     133                 :            :             {
     134 [ #  # ][ #  # ]:          0 :                 Reference< XTextCursor > xTextFieldCursor = xText->createTextCursor();
     135 [ #  # ][ #  # ]:          0 :                 xTextFieldCursor->gotoEnd( sal_False );
     136                 :            : 
     137         [ #  # ]:          0 :                 PropertySet aFieldProps( xField );
     138         [ #  # ]:          0 :                 aFieldProps.setProperties( maTextCharacterProperties.maHyperlinkPropertyMap );
     139         [ #  # ]:          0 :                 aFieldProps.setProperty( PROP_Representation, getText() );
     140         [ #  # ]:          0 :                 Reference< XTextContent > xContent( xField, UNO_QUERY);
     141 [ #  # ][ #  # ]:          0 :                 xText->insertTextContent( xStart, xContent, sal_False );
     142                 :            : 
     143 [ #  # ][ #  # ]:          0 :                 xTextFieldCursor->gotoEnd( sal_True );
     144                 :            : 
     145         [ #  # ]:          0 :                 if ( !maTextCharacterProperties.maCharColor.isUsed() )
     146         [ #  # ]:          0 :                     aTextCharacterProps.maCharColor.setSchemeClr( XML_hlink );
     147         [ #  # ]:          0 :                 if ( !maTextCharacterProperties.moUnderline.has() )
     148                 :          0 :                     aTextCharacterProps.moUnderline.set( XML_sng );
     149                 :            : 
     150         [ #  # ]:          0 :                 Reference< XTextRange > xFieldRange( xTextFieldCursor, UNO_QUERY );
     151         [ #  # ]:          0 :                 PropertySet aFieldTextPropSet( xFieldRange );
     152         [ #  # ]:          0 :                 aTextCharacterProps.pushToPropSet( aFieldTextPropSet, rFilterBase );
     153                 :            : 
     154         [ #  # ]:          0 :                 oox::core::TextField aTextField;
     155         [ #  # ]:          0 :                 aTextField.xText = xText;
     156         [ #  # ]:          0 :                 aTextField.xTextCursor = xTextFieldCursor;
     157         [ #  # ]:          0 :                 aTextField.xTextField = xField;
     158 [ #  # ][ #  # ]:          0 :                 rFilterBase.getTextFieldStack().push_back( aTextField );
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            :             }
     160                 :            :             else
     161                 :            :             {
     162                 :            :                 OSL_TRACE( "OOX: URL field couldn't be created" );
     163 [ #  # ][ #  # ]:          0 :                 xText->insertString( xStart, getText(), sal_False );
     164                 :          0 :             }
     165 [ +  - ][ +  - ]:         51 :         }
                 [ #  # ]
     166                 :            :     }
     167                 :          0 :     catch( const Exception&  )
     168                 :            :     {
     169                 :            :         OSL_TRACE("OOX:  TextRun::insertAt() exception");
     170                 :            :     }
     171                 :            : 
     172                 :         51 :     return nCharHeight;
     173                 :            : }
     174                 :            : 
     175                 :            : 
     176 [ +  - ][ +  - ]:        285 : } }
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10