LibreOffice Module xmloff (master)  1
XMLFootnoteSeparatorExport.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 
22 
23 #include <sax/tools/converter.hxx>
24 
25 #include <xmloff/xmlexp.hxx>
26 #include <xmloff/xmlnamespace.hxx>
27 #include <xmloff/xmluconv.hxx>
28 #include <xmloff/xmltoken.hxx>
29 #include <xmloff/xmlprmap.hxx>
30 #include <xmloff/xmlement.hxx>
31 
32 #include <PageMasterStyleMap.hxx>
33 #include <com/sun/star/text/HorizontalAdjust.hpp>
34 #include <rtl/ustrbuf.hxx>
35 
36 
37 using namespace ::com::sun::star;
38 using namespace ::xmloff::token;
39 using ::std::vector;
40 
42  rExport(rExp)
43 {
44 }
45 
47 {
48 }
49 
50 
52  const vector<XMLPropertyState> * pProperties,
53  sal_uInt32 const nIdx,
55 {
56  assert(pProperties);
57 
58  // initialize values
59  text::HorizontalAdjust eLineAdjust = text::HorizontalAdjust_LEFT;
60  sal_Int32 nLineColor = 0;
61  sal_Int32 nLineDistance = 0;
62  sal_Int8 nLineRelWidth = 0;
63  sal_Int32 nLineTextDistance = 0;
64  sal_Int16 nLineWeight = 0;
65  sal_Int8 nLineStyle = 0;
66 
67  // find indices into property map and get values
68  sal_uInt32 nCount = pProperties->size();
69  for(sal_uInt32 i = 0; i < nCount; i++)
70  {
71  const XMLPropertyState& rState = (*pProperties)[i];
72 
73  if( rState.mnIndex == -1 )
74  continue;
75 
76  switch (rMapper->GetEntryContextId(rState.mnIndex))
77  {
79  {
80  sal_Int16 nTmp;
81  if (rState.maValue >>= nTmp)
82  eLineAdjust = static_cast<text::HorizontalAdjust>(nTmp);
83  break;
84  }
86  rState.maValue >>= nLineColor;
87  break;
89  rState.maValue >>= nLineDistance;
90  break;
92  rState.maValue >>= nLineRelWidth;
93  break;
95  rState.maValue >>= nLineTextDistance;
96  break;
98  (void) nIdx;
99  assert(i == nIdx && "received wrong property state index");
100  rState.maValue >>= nLineWeight;
101  break;
103  rState.maValue >>= nLineStyle;
104  break;
105  }
106  }
107 
108  OUStringBuffer sBuf;
109 
110  // weight/width
111  if (nLineWeight > 0)
112  {
115  sBuf.makeStringAndClear());
116  }
117 
118  // line text distance
119  if (nLineTextDistance > 0)
120  {
122  nLineTextDistance);
124  sBuf.makeStringAndClear());
125  }
126 
127  // line distance
128  if (nLineDistance > 0)
129  {
131  nLineDistance);
133  sBuf.makeStringAndClear());
134  }
135 
136  // line style
137  static const SvXMLEnumMapEntry<sal_Int8> aXML_LineStyle_Enum[] =
138  {
139  { XML_NONE, 0 },
140  { XML_SOLID, 1 },
141  { XML_DOTTED, 2 },
142  { XML_DASH, 3 },
143  { XML_TOKEN_INVALID, 0 }
144  };
146  sBuf, nLineStyle, aXML_LineStyle_Enum ) )
147  {
149  sBuf.makeStringAndClear());
150  }
151 
152  // adjustment
154  {
155  { XML_LEFT, text::HorizontalAdjust_LEFT },
156  { XML_CENTER, text::HorizontalAdjust_CENTER },
157  { XML_RIGHT, text::HorizontalAdjust_RIGHT },
158  { XML_TOKEN_INVALID, text::HorizontalAdjust(0) }
159  };
160 
162  sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
163  {
165  sBuf.makeStringAndClear());
166  }
167 
168  // relative line width
169  ::sax::Converter::convertPercent(sBuf, nLineRelWidth);
171  sBuf.makeStringAndClear());
172 
173  // color
174  ::sax::Converter::convertColor(sBuf, nLineColor);
176  sBuf.makeStringAndClear());
177 
178  // line-style
179 
181  XML_FOOTNOTE_SEP, true, true);
182 }
183 
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
#define CTF_PM_FTN_LINE_ADJUST
signed char sal_Int8
#define CTF_PM_FTN_LINE_WEIGHT
#define CTF_PM_FTN_LINE_COLOR
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlexp.hxx:394
#define CTF_PM_FTN_LINE_WIDTH
sal_Int32 mnIndex
Definition: maptype.hxx:124
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
int nCount
void AddAttribute(sal_uInt16 nPrefix, const char *pName, const OUString &rValue)
Definition: xmlexp.cxx:909
int i
void exportXML(const ::std::vector< XMLPropertyState > *pProperties, sal_uInt32 nIdx, const rtl::Reference< XMLPropertySetMapper > &rMapper)
#define CTF_PM_FTN_LINE_STYLE
#define CTF_PM_FTN_DISTANCE
Map an XMLTokenEnum to an enum value.
Definition: ximpshap.hxx:40
css::uno::Any maValue
Definition: maptype.hxx:125
static bool convertColor(sal_Int32 &rColor, const OUString &rValue)
#define CTF_PM_FTN_LINE_DISTANCE
Handling of tokens in XML:
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:122
css::uno::Any const SvXMLExport & rExport
Definition: ImageStyle.hxx:38
SvXMLEnumMapEntry< text::HorizontalAdjust > const aXML_HorizontalAdjust_Enum[]
Definition: prhdlfac.cxx:74
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
convert measure to string: from meCoreMeasureUnit to meXMLMeasureUnit
Definition: xmluconv.cxx:181
constexpr sal_uInt16 XML_NAMESPACE_STYLE
static bool convertPercent(sal_Int32 &rValue, const OUString &rString)
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo