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

Generated by: LCOV version 1.10