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>
27#include <xmloff/xmltoken.hxx>
28#include <xmloff/xmluconv.hxx>
29#include <xmloff/xmlexp.hxx>
30#include <xmltabe.hxx>
31
32
33using namespace ::com::sun::star;
34using 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
46void 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,
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 uno::Sequence< css::style::TabStop> aSeq;
102 if(!(rAny >>= aSeq))
103 {
104 OSL_FAIL( "SvxXMLTabStopExport needs a Sequence css::style::TabStop>" );
105 }
106 else
107 {
109 true, true );
110
111 for( const auto& rTab : std::as_const(aSeq) )
112 {
113 if( style::TabAlign_DEFAULT != rTab.Alignment )
114 exportTabStop( &rTab );
115 }
116 }
117}
118
119
120/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void AddAttribute(sal_uInt16 nPrefix, const OUString &rName, const OUString &rValue)
Definition: xmlexp.cxx:907
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:391
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
static bool convertEnum(EnumT &rEnum, std::u16string_view 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:145
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
Definition: xmluconv.cxx:208
SvXMLExport & rExport
Definition: xmltabe.hxx:35
SvxXMLTabStopExport(SvXMLExport &rExport)
Definition: xmltabe.cxx:93
void Export(const css::uno::Any &rAny)
Definition: xmltabe.cxx:99
void exportTabStop(const css::style::TabStop *pTabStop)
Definition: xmltabe.cxx:46
Sequence< sal_Int8 > aSeq
Handling of tokens in XML:
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3541
constexpr sal_uInt16 XML_NAMESPACE_STYLE
SvXMLEnumMapEntry< style::TabAlign > const pXML_tabstop_style[]
Definition: xmltabe.cxx:36