1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "XMLFootnoteSeparatorExport.hxx"
27 #include <tools/debug.hxx>
28 #include <xmloff/xmlexp.hxx>
29 #include "xmloff/xmlnmspe.hxx"
30 #include <xmloff/xmluconv.hxx>
31 #include <xmloff/xmltoken.hxx>
32 #include <xmloff/xmlprmap.hxx>
33
34 #ifndef _XMLOFF_PAGEMASTERSTYLEMAP_HXX
35 #include <xmloff/PageMasterStyleMap.hxx>
36 #endif
37 #include <com/sun/star/text/HorizontalAdjust.hpp>
38 #include <rtl/ustrbuf.hxx>
39
40
41 using namespace ::com::sun::star;
42 using namespace ::xmloff::token;
43 using ::rtl::OUStringBuffer;
44 using ::std::vector;
45
XMLFootnoteSeparatorExport(SvXMLExport & rExp)46 XMLFootnoteSeparatorExport::XMLFootnoteSeparatorExport(SvXMLExport& rExp) :
47 rExport(rExp)
48 {
49 }
50
~XMLFootnoteSeparatorExport()51 XMLFootnoteSeparatorExport::~XMLFootnoteSeparatorExport()
52 {
53 }
54
55
exportXML(const vector<XMLPropertyState> * pProperties,sal_uInt32 nIdx,const UniReference<XMLPropertySetMapper> & rMapper)56 void XMLFootnoteSeparatorExport::exportXML(
57 const vector<XMLPropertyState> * pProperties,
58 sal_uInt32
59 #ifdef DBG_UTIL
60 nIdx
61 #endif
62 ,
63 const UniReference<XMLPropertySetMapper> & rMapper)
64 {
65 DBG_ASSERT(NULL != pProperties, "Need property states");
66
67 // initialize values
68 sal_Int16 eLineAdjust = text::HorizontalAdjust_LEFT;
69 sal_Int32 nLineColor = 0;
70 sal_Int32 nLineDistance = 0;
71 sal_Int8 nLineRelWidth = 0;
72 sal_Int32 nLineTextDistance = 0;
73 sal_Int16 nLineWeight = 0;
74
75 // find indices into property map and get values
76 sal_uInt32 nCount = pProperties->size();
77 for(sal_uInt32 i = 0; i < nCount; i++)
78 {
79 const XMLPropertyState& rState = (*pProperties)[i];
80
81 if( rState.mnIndex == -1 )
82 continue;
83
84 switch (rMapper->GetEntryContextId(rState.mnIndex))
85 {
86 case CTF_PM_FTN_LINE_ADJUST:
87 rState.maValue >>= eLineAdjust;
88 break;
89 case CTF_PM_FTN_LINE_COLOR:
90 rState.maValue >>= nLineColor;
91 break;
92 case CTF_PM_FTN_DISTANCE:
93 rState.maValue >>= nLineDistance;
94 break;
95 case CTF_PM_FTN_LINE_WIDTH:
96 rState.maValue >>= nLineRelWidth;
97 break;
98 case CTF_PM_FTN_LINE_DISTANCE:
99 rState.maValue >>= nLineTextDistance;
100 break;
101 case CTF_PM_FTN_LINE_WEIGTH:
102 DBG_ASSERT( i == nIdx,
103 "received wrong property state index" );
104 rState.maValue >>= nLineWeight;
105 break;
106 }
107 }
108
109 OUStringBuffer sBuf;
110
111 // weight/width
112 if (nLineWeight > 0)
113 {
114 rExport.GetMM100UnitConverter().convertMeasure(sBuf, nLineWeight);
115 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_WIDTH,
116 sBuf.makeStringAndClear());
117 }
118
119 // line text distance
120 if (nLineTextDistance > 0)
121 {
122 rExport.GetMM100UnitConverter().convertMeasure(sBuf,nLineTextDistance);
123 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_BEFORE_SEP,
124 sBuf.makeStringAndClear());
125 }
126
127 // line distance
128 if (nLineDistance > 0)
129 {
130 rExport.GetMM100UnitConverter().convertMeasure(sBuf, nLineDistance);
131 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_DISTANCE_AFTER_SEP,
132 sBuf.makeStringAndClear());
133 }
134
135 // adjustment
136 static const SvXMLEnumMapEntry aXML_HorizontalAdjust_Enum[] =
137 {
138 { XML_LEFT, text::HorizontalAdjust_LEFT },
139 { XML_CENTER, text::HorizontalAdjust_CENTER },
140 { XML_RIGHT, text::HorizontalAdjust_RIGHT },
141 { XML_TOKEN_INVALID, 0 }
142 };
143
144 if (rExport.GetMM100UnitConverter().convertEnum(
145 sBuf, eLineAdjust, aXML_HorizontalAdjust_Enum))
146 {
147 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_ADJUSTMENT,
148 sBuf.makeStringAndClear());
149 }
150
151 // relative line width
152 SvXMLUnitConverter::convertPercent(sBuf, nLineRelWidth);
153 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_REL_WIDTH,
154 sBuf.makeStringAndClear());
155
156 // color
157 rExport.GetMM100UnitConverter().convertColor(sBuf, nLineColor);
158 rExport.AddAttribute(XML_NAMESPACE_STYLE, XML_COLOR,
159 sBuf.makeStringAndClear());
160
161 SvXMLElementExport aElem(rExport, XML_NAMESPACE_STYLE,
162 XML_FOOTNOTE_SEP, sal_True, sal_True);
163 }
164