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

Generated by: LCOV version 1.10