LibreOffice Module xmloff (master)  1
xmltabe.cxx
Go to the documentation of this file.
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 <osl/diagnose.h>
25 #include <xmloff/xmlement.hxx>
26 #include <xmloff/xmlnmspe.hxx>
27 #include <xmloff/xmltoken.hxx>
28 #include <xmloff/xmluconv.hxx>
29 #include <xmloff/xmlexp.hxx>
30 #include <xmltabe.hxx>
31 
32 
33 using namespace ::com::sun::star;
34 using namespace ::xmloff::token;
35 
37 {
38  { XML_LEFT, style::TabAlign_LEFT },
39  { XML_CENTER, style::TabAlign_CENTER },
40  { XML_RIGHT, style::TabAlign_RIGHT },
41  { XML_CHAR, style::TabAlign_DECIMAL },
42  { XML_DEFAULT, style::TabAlign_DEFAULT }, // ?????????????????????????????????????
43  { XML_TOKEN_INVALID, style::TabAlign(0) }
44 };
45 
46 void SvxXMLTabStopExport::exportTabStop( const css::style::TabStop* pTabStop )
47 {
49 
50  // text:level
51  OUStringBuffer sBuffer;
52 
53  // position attribute
54  rUnitConv.convertMeasureToXML( sBuffer, pTabStop->Position );
56  sBuffer.makeStringAndClear() );
57 
58  // type attribute
59  if( style::TabAlign_LEFT != pTabStop->Alignment )
60  {
61  SvXMLUnitConverter::convertEnum( sBuffer, pTabStop->Alignment,
62  pXML_tabstop_style );
64  sBuffer.makeStringAndClear() );
65  }
66 
67  // char
68  if( style::TabAlign_DECIMAL == pTabStop->Alignment &&
69  pTabStop->DecimalChar != 0 )
70  {
71  sBuffer.append( pTabStop->DecimalChar );
73  sBuffer.makeStringAndClear() );
74  }
75 
76  // leader-char
77  if( ' ' != pTabStop->FillChar && 0 != pTabStop->FillChar )
78  {
80  GetXMLToken('.' == pTabStop->FillChar ? XML_DOTTED
81  : XML_SOLID) );
82 
83  sBuffer.append( pTabStop->FillChar );
85  sBuffer.makeStringAndClear() );
86  }
87 
89  true, true );
90 }
91 
92 
94  SvXMLExport& rExp)
95  : rExport( rExp )
96 {
97 }
98 
100 {
101 }
102 
104 {
105  uno::Sequence< css::style::TabStop> aSeq;
106  if(!(rAny >>= aSeq))
107  {
108  OSL_FAIL( "SvxXMLTabStopExport needs a Sequence css::style::TabStop>" );
109  }
110  else
111  {
113  true, true );
114 
115  for( const auto& rTab : std::as_const(aSeq) )
116  {
117  if( style::TabAlign_DEFAULT != rTab.Alignment )
118  exportTabStop( &rTab );
119  }
120  }
121 }
122 
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 XML_NAMESPACE_STYLE
Definition: xmlnmspe.hxx:30
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
convert string to enum using given enum map, if the enum is not found in the map, this method will re...
Definition: xmluconv.hxx:128
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:395
SvxXMLTabStopExport(SvXMLExport &rExport)
Definition: xmltabe.cxx:93
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:926
SvXMLEnumMapEntry< style::TabAlign > const pXML_tabstop_style[]
Definition: xmltabe.cxx:36
void Export(const css::uno::Any &rAny)
Definition: xmltabe.cxx:103
void exportTabStop(const css::style::TabStop *pTabStop)
Definition: xmltabe.cxx:46
Map an XMLTokenEnum to an enum value.
Definition: ximpshap.hxx:40
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3366
Handling of tokens in XML:
Sequence< sal_Int8 > aSeq
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
SvXMLExport & rExport
Definition: xmltabe.hxx:36
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
Definition: xmluconv.cxx:181