LCOV - code coverage report
Current view: top level - xmloff/source/style - xmltabe.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 33 36 91.7 %
Date: 2015-06-13 12:38:46 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          77 : void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* pTabStop )
      46             : {
      47          77 :     SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
      48             : 
      49             :     // text:level
      50          77 :     OUStringBuffer sBuffer;
      51             : 
      52             :     // position attribute
      53          77 :     rUnitConv.convertMeasureToXML( sBuffer, pTabStop->Position );
      54             :     rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION,
      55          77 :                            sBuffer.makeStringAndClear() );
      56             : 
      57             :     // type attribute
      58          77 :     if( style::TabAlign_LEFT != pTabStop->Alignment )
      59             :     {
      60             :         SvXMLUnitConverter::convertEnum( sBuffer, pTabStop->Alignment,
      61          68 :                                    pXML_tabstop_style );
      62             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_TYPE,
      63          68 :                                sBuffer.makeStringAndClear() );
      64             :     }
      65             : 
      66             :     // char
      67          77 :     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          77 :     if( ' ' != pTabStop->FillChar && 0 != pTabStop->FillChar )
      77             :     {
      78             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_STYLE,
      79          13 :                       GetXMLToken('.' == pTabStop->FillChar ? XML_DOTTED
      80          13 :                                                                : XML_SOLID) );
      81             : 
      82          13 :         sBuffer.append( pTabStop->FillChar );
      83             :         rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_TEXT,
      84          13 :                                sBuffer.makeStringAndClear() );
      85             :     }
      86             : 
      87             :     SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOP,
      88          77 :                               true, true );
      89          77 : }
      90             : 
      91             : 
      92        7303 : SvxXMLTabStopExport::SvxXMLTabStopExport(
      93             :     SvXMLExport& rExp)
      94        7303 :     : rExport( rExp )
      95             : {
      96        7303 : }
      97             : 
      98        7298 : SvxXMLTabStopExport::~SvxXMLTabStopExport()
      99             : {
     100        7298 : }
     101             : 
     102         159 : void SvxXMLTabStopExport::Export( const uno::Any& rAny )
     103             : {
     104         159 :     uno::Sequence< ::com::sun::star::style::TabStop> aSeq;
     105         159 :     if(!(rAny >>= aSeq))
     106             :     {
     107             :         OSL_FAIL( "SvxXMLTabStopExport needs a Sequence ::com::sun::star::style::TabStop>" );
     108             :     }
     109             :     else
     110             :     {
     111         159 :         const ::com::sun::star::style::TabStop* pTabs = aSeq.getConstArray();
     112         159 :         const sal_Int32 nTabs   = aSeq.getLength();
     113             : 
     114             :         SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOPS,
     115         159 :                                   true, true );
     116             : 
     117         309 :         for( sal_Int32 nIndex = 0; nIndex < nTabs; nIndex++ )
     118             :         {
     119         150 :             if( style::TabAlign_DEFAULT != pTabs[nIndex].Alignment )
     120          77 :                 exportTabStop( &(pTabs[nIndex]) );
     121         159 :         }
     122         159 :     }
     123         159 : }
     124             : 
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11