LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/style - xmltabe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 29 34 85.3 %
Date: 2012-12-27 Functions: 4 5 80.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             : 
      21             : #include <com/sun/star/style/TabStop.hpp>
      22             : #include <com/sun/star/style/TabAlign.hpp>
      23             : #include <rtl/ustrbuf.hxx>
      24             : #include <xmloff/nmspmap.hxx>
      25             : #include "xmloff/xmlnmspe.hxx"
      26             : #include <xmloff/xmltoken.hxx>
      27             : #include <xmloff/xmluconv.hxx>
      28             : #include <xmloff/xmlexp.hxx>
      29             : #include "xmloff/xmltabe.hxx"
      30             : 
      31             : using ::rtl::OUString;
      32             : using ::rtl::OUStringBuffer;
      33             : 
      34             : using namespace ::com::sun::star;
      35             : using namespace ::xmloff::token;
      36             : 
      37             : SvXMLEnumMapEntry pXML_tabstop_style[] =
      38             : {
      39             :     { XML_LEFT,     style::TabAlign_LEFT    },
      40             :     { XML_CENTER,   style::TabAlign_CENTER  },
      41             :     { XML_RIGHT,    style::TabAlign_RIGHT   },
      42             :     { XML_CHAR,     style::TabAlign_DECIMAL },
      43             :     { XML_DEFAULT,  style::TabAlign_DEFAULT  }, // ?????????????????????????????????????
      44             :     { XML_TOKEN_INVALID,        0 }
      45             : };
      46             : 
      47           4 : void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* pTabStop )
      48             : {
      49           4 :     SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
      50             : 
      51             :     // text:level
      52           4 :     OUStringBuffer sBuffer;
      53             : 
      54             :     // position attribute
      55           4 :     rUnitConv.convertMeasureToXML( sBuffer, pTabStop->Position );
      56             :     rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION,
      57           4 :                            sBuffer.makeStringAndClear() );
      58             : 
      59             :     // type attribute
      60           4 :     if( style::TabAlign_LEFT != pTabStop->Alignment )
      61             :     {
      62             :         rUnitConv.convertEnum( sBuffer, pTabStop->Alignment,
      63           4 :                                    pXML_tabstop_style );
      64             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_TYPE,
      65           4 :                                sBuffer.makeStringAndClear() );
      66             :     }
      67             : 
      68             :     // char
      69           4 :     if( style::TabAlign_DECIMAL == pTabStop->Alignment &&
      70             :         pTabStop->DecimalChar != 0 )
      71             :     {
      72           0 :         sBuffer.append( pTabStop->DecimalChar );
      73             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_CHAR,
      74           0 :                                sBuffer.makeStringAndClear() );
      75             :     }
      76             : 
      77             :     // leader-char
      78           4 :     if( ' ' != pTabStop->FillChar && 0 != pTabStop->FillChar )
      79             :     {
      80             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_STYLE,
      81             :                       GetXMLToken('.' == pTabStop->FillChar ? XML_DOTTED
      82           0 :                                                                : XML_SOLID) );
      83             : 
      84           0 :         sBuffer.append( pTabStop->FillChar );
      85             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_TEXT,
      86           0 :                                sBuffer.makeStringAndClear() );
      87             :     }
      88             : 
      89             :     SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOP,
      90           4 :                               sal_True, sal_True );
      91           4 : }
      92             : 
      93             : 
      94          70 : SvxXMLTabStopExport::SvxXMLTabStopExport(
      95             :     SvXMLExport& rExp)
      96          70 :     : rExport( rExp )
      97             : {
      98          70 : }
      99             : 
     100          70 : SvxXMLTabStopExport::~SvxXMLTabStopExport()
     101             : {
     102          70 : }
     103             : 
     104           4 : void SvxXMLTabStopExport::Export( const uno::Any& rAny )
     105             : {
     106           4 :     uno::Sequence< ::com::sun::star::style::TabStop> aSeq;
     107           4 :     if(!(rAny >>= aSeq))
     108             :     {
     109             :         OSL_FAIL( "SvxXMLTabStopExport needs a Sequence ::com::sun::star::style::TabStop>" );
     110             :     }
     111             :     else
     112             :     {
     113           4 :         const ::com::sun::star::style::TabStop* pTabs = aSeq.getConstArray();
     114           4 :         const sal_Int32 nTabs   = aSeq.getLength();
     115             : 
     116             :         SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOPS,
     117           4 :                                   sal_True, sal_True );
     118             : 
     119          10 :         for( sal_Int32 nIndex = 0; nIndex < nTabs; nIndex++ )
     120             :         {
     121           6 :             if( style::TabAlign_DEFAULT != pTabs[nIndex].Alignment )
     122           4 :                 exportTabStop( &(pTabs[nIndex]) );
     123           4 :         }
     124           4 :     }
     125           4 : }
     126             : 
     127             : 
     128             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10