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

Generated by: LCOV version 1.10