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

Generated by: LCOV version 1.10