LCOV - code coverage report
Current view: top level - libreoffice/oox/source/vml - vmltextbox.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 39 100.0 %
Date: 2012-12-27 Functions: 7 7 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/vml/vmltextbox.hxx"
      21             : 
      22             : #include <rtl/ustrbuf.hxx>
      23             : #include <com/sun/star/awt/FontWeight.hpp>
      24             : #include <com/sun/star/text/XTextAppend.hpp>
      25             : 
      26             : namespace oox {
      27             : namespace vml {
      28             : 
      29             : using ::rtl::OUString;
      30             : using ::rtl::OUStringBuffer;
      31             : using namespace com::sun::star;
      32             : 
      33          38 : TextFontModel::TextFontModel()
      34             : {
      35          38 : }
      36             : 
      37         131 : TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& rText ) :
      38             :     maFont( rFont ),
      39         131 :     maText( rText )
      40             : {
      41         131 : }
      42             : 
      43          15 : TextBox::TextBox(ShapeTypeModel& rTypeModel)
      44             :     : mrTypeModel(rTypeModel),
      45          15 :     borderDistanceSet( false )
      46             : {
      47          15 : }
      48             : 
      49         131 : void TextBox::appendPortion( const TextFontModel& rFont, const OUString& rText )
      50             : {
      51         131 :     maPortions.push_back( TextPortionModel( rFont, rText ) );
      52         131 : }
      53             : 
      54           1 : const TextFontModel* TextBox::getFirstFont() const
      55             : {
      56           1 :     return maPortions.empty() ? 0 : &maPortions.front().maFont;
      57             : }
      58             : 
      59           1 : OUString TextBox::getText() const
      60             : {
      61           1 :     OUStringBuffer aBuffer;
      62           2 :     for( PortionVector::const_iterator aIt = maPortions.begin(), aEnd = maPortions.end(); aIt != aEnd; ++aIt )
      63           1 :         aBuffer.append( aIt->maText );
      64           1 :     return aBuffer.makeStringAndClear();
      65             : }
      66             : 
      67           3 : void TextBox::convert(uno::Reference<drawing::XShape> xShape) const
      68             : {
      69           3 :     uno::Reference<text::XTextAppend> xTextAppend(xShape, uno::UNO_QUERY);
      70          12 :     for (PortionVector::const_iterator aIt = maPortions.begin(), aEnd = maPortions.end(); aIt != aEnd; ++aIt)
      71             :     {
      72           9 :         beans::PropertyValue aPropertyValue;
      73           9 :         std::vector<beans::PropertyValue> aPropVec;
      74           9 :         const TextFontModel& rFont = aIt->maFont;
      75           9 :         if (rFont.mobBold.has())
      76             :         {
      77           8 :             aPropertyValue.Name = "CharWeight";
      78           8 :             aPropertyValue.Value = uno::makeAny(rFont.mobBold.get() ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL);
      79           8 :             aPropVec.push_back(aPropertyValue);
      80             :         }
      81           9 :         if (rFont.monSize.has())
      82             :         {
      83           9 :             aPropertyValue.Name = "CharHeight";
      84           9 :             aPropertyValue.Value = uno::makeAny(double(rFont.monSize.get()) / 2.);
      85           9 :             aPropVec.push_back(aPropertyValue);
      86             :         }
      87           9 :         uno::Sequence<beans::PropertyValue> aPropSeq(aPropVec.size());
      88           9 :         beans::PropertyValue* pValues = aPropSeq.getArray();
      89          26 :         for (std::vector<beans::PropertyValue>::iterator i = aPropVec.begin(); i != aPropVec.end(); ++i)
      90          17 :             *pValues++ = *i;
      91           9 :         xTextAppend->appendTextPortion(aIt->maText, aPropSeq);
      92          12 :     }
      93           3 : }
      94             : 
      95             : } // namespace vml
      96             : } // namespace oox
      97             : 
      98             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10