lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / writerfilter / source / dmapper / TDefTableHandler.cxx
blob68f8494f586ffb1d629647cbf584c81082009c89
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #include "TDefTableHandler.hxx"
20 #include "PropertyMap.hxx"
21 #include "ConversionHelper.hxx"
22 #include <ooxml/resourceids.hxx>
23 #include <filter/msfilter/util.hxx>
24 #include <tools/color.hxx>
25 #include <com/sun/star/table/BorderLine2.hpp>
26 #include <com/sun/star/text/TableColumnSeparator.hpp>
27 #include <com/sun/star/text/VertOrientation.hpp>
28 #include <comphelper/sequence.hxx>
30 namespace writerfilter {
31 namespace dmapper {
33 using namespace ::com::sun::star;
36 TDefTableHandler::TDefTableHandler() :
37 LoggedProperties("TDefTableHandler"),
38 m_nLineWidth(0),
39 m_nLineType(0),
40 m_nLineColor(0)
45 TDefTableHandler::~TDefTableHandler()
49 OUString TDefTableHandler::getBorderTypeString(sal_Int32 nType)
51 switch (nType)
53 case NS_ooxml::LN_Value_ST_Border_nil: return OUString("nil");
54 case NS_ooxml::LN_Value_ST_Border_none: return OUString("none");
55 case NS_ooxml::LN_Value_ST_Border_single: return OUString("single");
56 case NS_ooxml::LN_Value_ST_Border_thick: return OUString("thick");
57 case NS_ooxml::LN_Value_ST_Border_double: return OUString("double");
58 case NS_ooxml::LN_Value_ST_Border_dotted: return OUString("dotted");
59 case NS_ooxml::LN_Value_ST_Border_dashed: return OUString("dashed");
60 case NS_ooxml::LN_Value_ST_Border_dotDash: return OUString("dotDash");
61 case NS_ooxml::LN_Value_ST_Border_dotDotDash: return OUString("dotDotDash");
62 case NS_ooxml::LN_Value_ST_Border_triple: return OUString("triple");
63 case NS_ooxml::LN_Value_ST_Border_thinThickSmallGap: return OUString("thinThickSmallGap");
64 case NS_ooxml::LN_Value_ST_Border_thickThinSmallGap: return OUString("thickThinSmallGap");
65 case NS_ooxml::LN_Value_ST_Border_thinThickThinSmallGap: return OUString("thinThickThinSmallGap");
66 case NS_ooxml::LN_Value_ST_Border_thinThickMediumGap: return OUString("thinThickMediumGap");
67 case NS_ooxml::LN_Value_ST_Border_thickThinMediumGap: return OUString("thickThinMediumGap");
68 case NS_ooxml::LN_Value_ST_Border_thinThickThinMediumGap: return OUString("thinThickThinMediumGap");
69 case NS_ooxml::LN_Value_ST_Border_thinThickLargeGap: return OUString("thinThickLargeGap");
70 case NS_ooxml::LN_Value_ST_Border_thickThinLargeGap: return OUString("thickThinLargeGap");
71 case NS_ooxml::LN_Value_ST_Border_thinThickThinLargeGap: return OUString("thinThickThinLargeGap");
72 case NS_ooxml::LN_Value_ST_Border_wave: return OUString("wave");
73 case NS_ooxml::LN_Value_ST_Border_doubleWave: return OUString("doubleWave");
74 case NS_ooxml::LN_Value_ST_Border_dashSmallGap: return OUString("dashSmallGap");
75 case NS_ooxml::LN_Value_ST_Border_dashDotStroked: return OUString("dashDotStroked");
76 case NS_ooxml::LN_Value_ST_Border_threeDEmboss: return OUString("threeDEmboss");
77 case NS_ooxml::LN_Value_ST_Border_threeDEngrave: return OUString("threeDEngrave");
78 case NS_ooxml::LN_Value_ST_Border_outset: return OUString("outset");
79 case NS_ooxml::LN_Value_ST_Border_inset: return OUString("inset");
80 case NS_ooxml::LN_Value_ST_Border_apples: return OUString("apples");
81 case NS_ooxml::LN_Value_ST_Border_archedScallops: return OUString("archedScallops");
82 case NS_ooxml::LN_Value_ST_Border_babyPacifier: return OUString("babyPacifier");
83 case NS_ooxml::LN_Value_ST_Border_babyRattle: return OUString("babyRattle");
84 case NS_ooxml::LN_Value_ST_Border_balloons3Colors: return OUString("balloons3Colors");
85 case NS_ooxml::LN_Value_ST_Border_balloonsHotAir: return OUString("balloonsHotAir");
86 case NS_ooxml::LN_Value_ST_Border_basicBlackDashes: return OUString("basicBlackDashes");
87 case NS_ooxml::LN_Value_ST_Border_basicBlackDots: return OUString("basicBlackDots");
88 case NS_ooxml::LN_Value_ST_Border_basicBlackSquares: return OUString("basicBlackSquares");
89 case NS_ooxml::LN_Value_ST_Border_basicThinLines: return OUString("basicThinLines");
90 case NS_ooxml::LN_Value_ST_Border_basicWhiteDashes: return OUString("basicWhiteDashes");
91 case NS_ooxml::LN_Value_ST_Border_basicWhiteDots: return OUString("basicWhiteDots");
92 case NS_ooxml::LN_Value_ST_Border_basicWhiteSquares: return OUString("basicWhiteSquares");
93 case NS_ooxml::LN_Value_ST_Border_basicWideInline: return OUString("basicWideInline");
94 case NS_ooxml::LN_Value_ST_Border_basicWideMidline: return OUString("basicWideMidline");
95 case NS_ooxml::LN_Value_ST_Border_basicWideOutline: return OUString("basicWideOutline");
96 case NS_ooxml::LN_Value_ST_Border_bats: return OUString("bats");
97 case NS_ooxml::LN_Value_ST_Border_birds: return OUString("birds");
98 case NS_ooxml::LN_Value_ST_Border_birdsFlight: return OUString("birdsFlight");
99 case NS_ooxml::LN_Value_ST_Border_cabins: return OUString("cabins");
100 case NS_ooxml::LN_Value_ST_Border_cakeSlice: return OUString("cakeSlice");
101 case NS_ooxml::LN_Value_ST_Border_candyCorn: return OUString("candyCorn");
102 case NS_ooxml::LN_Value_ST_Border_celticKnotwork: return OUString("celticKnotwork");
103 case NS_ooxml::LN_Value_ST_Border_certificateBanner: return OUString("certificateBanner");
104 case NS_ooxml::LN_Value_ST_Border_chainLink: return OUString("chainLink");
105 case NS_ooxml::LN_Value_ST_Border_champagneBottle: return OUString("champagneBottle");
106 case NS_ooxml::LN_Value_ST_Border_checkedBarBlack: return OUString("checkedBarBlack");
107 case NS_ooxml::LN_Value_ST_Border_checkedBarColor: return OUString("checkedBarColor");
108 case NS_ooxml::LN_Value_ST_Border_checkered: return OUString("checkered");
109 case NS_ooxml::LN_Value_ST_Border_christmasTree: return OUString("christmasTree");
110 case NS_ooxml::LN_Value_ST_Border_circlesLines: return OUString("circlesLines");
111 case NS_ooxml::LN_Value_ST_Border_circlesRectangles: return OUString("circlesRectangles");
112 case NS_ooxml::LN_Value_ST_Border_classicalWave: return OUString("classicalWave");
113 case NS_ooxml::LN_Value_ST_Border_clocks: return OUString("clocks");
114 case NS_ooxml::LN_Value_ST_Border_compass: return OUString("compass");
115 case NS_ooxml::LN_Value_ST_Border_confetti: return OUString("confetti");
116 case NS_ooxml::LN_Value_ST_Border_confettiGrays: return OUString("confettiGrays");
117 case NS_ooxml::LN_Value_ST_Border_confettiOutline: return OUString("confettiOutline");
118 case NS_ooxml::LN_Value_ST_Border_confettiStreamers: return OUString("confettiStreamers");
119 case NS_ooxml::LN_Value_ST_Border_confettiWhite: return OUString("confettiWhite");
120 case NS_ooxml::LN_Value_ST_Border_cornerTriangles: return OUString("cornerTriangles");
121 case NS_ooxml::LN_Value_ST_Border_couponCutoutDashes: return OUString("couponCutoutDashes");
122 case NS_ooxml::LN_Value_ST_Border_couponCutoutDots: return OUString("couponCutoutDots");
123 case NS_ooxml::LN_Value_ST_Border_crazyMaze: return OUString("crazyMaze");
124 case NS_ooxml::LN_Value_ST_Border_creaturesButterfly: return OUString("creaturesButterfly");
125 case NS_ooxml::LN_Value_ST_Border_creaturesFish: return OUString("creaturesFish");
126 case NS_ooxml::LN_Value_ST_Border_creaturesInsects: return OUString("creaturesInsects");
127 case NS_ooxml::LN_Value_ST_Border_creaturesLadyBug: return OUString("creaturesLadyBug");
128 case NS_ooxml::LN_Value_ST_Border_crossStitch: return OUString("crossStitch");
129 case NS_ooxml::LN_Value_ST_Border_cup: return OUString("cup");
130 case NS_ooxml::LN_Value_ST_Border_decoArch: return OUString("decoArch");
131 case NS_ooxml::LN_Value_ST_Border_decoArchColor: return OUString("decoArchColor");
132 case NS_ooxml::LN_Value_ST_Border_decoBlocks: return OUString("decoBlocks");
133 case NS_ooxml::LN_Value_ST_Border_diamondsGray: return OUString("diamondsGray");
134 case NS_ooxml::LN_Value_ST_Border_doubleD: return OUString("doubleD");
135 case NS_ooxml::LN_Value_ST_Border_doubleDiamonds: return OUString("doubleDiamonds");
136 case NS_ooxml::LN_Value_ST_Border_earth1: return OUString("earth1");
137 case NS_ooxml::LN_Value_ST_Border_earth2: return OUString("earth2");
138 case NS_ooxml::LN_Value_ST_Border_eclipsingSquares1: return OUString("eclipsingSquares1");
139 case NS_ooxml::LN_Value_ST_Border_eclipsingSquares2: return OUString("eclipsingSquares2");
140 case NS_ooxml::LN_Value_ST_Border_eggsBlack: return OUString("eggsBlack");
141 case NS_ooxml::LN_Value_ST_Border_fans: return OUString("fans");
142 case NS_ooxml::LN_Value_ST_Border_film: return OUString("film");
143 case NS_ooxml::LN_Value_ST_Border_firecrackers: return OUString("firecrackers");
144 case NS_ooxml::LN_Value_ST_Border_flowersBlockPrint: return OUString("flowersBlockPrint");
145 case NS_ooxml::LN_Value_ST_Border_flowersDaisies: return OUString("flowersDaisies");
146 case NS_ooxml::LN_Value_ST_Border_flowersModern1: return OUString("flowersModern1");
147 case NS_ooxml::LN_Value_ST_Border_flowersModern2: return OUString("flowersModern2");
148 case NS_ooxml::LN_Value_ST_Border_flowersPansy: return OUString("flowersPansy");
149 case NS_ooxml::LN_Value_ST_Border_flowersRedRose: return OUString("flowersRedRose");
150 case NS_ooxml::LN_Value_ST_Border_flowersRoses: return OUString("flowersRoses");
151 case NS_ooxml::LN_Value_ST_Border_flowersTeacup: return OUString("flowersTeacup");
152 case NS_ooxml::LN_Value_ST_Border_flowersTiny: return OUString("flowersTiny");
153 case NS_ooxml::LN_Value_ST_Border_gems: return OUString("gems");
154 case NS_ooxml::LN_Value_ST_Border_gingerbreadMan: return OUString("gingerbreadMan");
155 case NS_ooxml::LN_Value_ST_Border_gradient: return OUString("gradient");
156 case NS_ooxml::LN_Value_ST_Border_handmade1: return OUString("handmade1");
157 case NS_ooxml::LN_Value_ST_Border_handmade2: return OUString("handmade2");
158 case NS_ooxml::LN_Value_ST_Border_heartBalloon: return OUString("heartBalloon");
159 case NS_ooxml::LN_Value_ST_Border_heartGray: return OUString("heartGray");
160 case NS_ooxml::LN_Value_ST_Border_hearts: return OUString("hearts");
161 case NS_ooxml::LN_Value_ST_Border_heebieJeebies: return OUString("heebieJeebies");
162 case NS_ooxml::LN_Value_ST_Border_holly: return OUString("holly");
163 case NS_ooxml::LN_Value_ST_Border_houseFunky: return OUString("houseFunky");
164 case NS_ooxml::LN_Value_ST_Border_hypnotic: return OUString("hypnotic");
165 case NS_ooxml::LN_Value_ST_Border_iceCreamCones: return OUString("iceCreamCones");
166 case NS_ooxml::LN_Value_ST_Border_lightBulb: return OUString("lightBulb");
167 case NS_ooxml::LN_Value_ST_Border_lightning1: return OUString("lightning1");
168 case NS_ooxml::LN_Value_ST_Border_lightning2: return OUString("lightning2");
169 case NS_ooxml::LN_Value_ST_Border_mapPins: return OUString("mapPins");
170 case NS_ooxml::LN_Value_ST_Border_mapleLeaf: return OUString("mapleLeaf");
171 case NS_ooxml::LN_Value_ST_Border_mapleMuffins: return OUString("mapleMuffins");
172 case NS_ooxml::LN_Value_ST_Border_marquee: return OUString("marquee");
173 case NS_ooxml::LN_Value_ST_Border_marqueeToothed: return OUString("marqueeToothed");
174 case NS_ooxml::LN_Value_ST_Border_moons: return OUString("moons");
175 case NS_ooxml::LN_Value_ST_Border_mosaic: return OUString("mosaic");
176 case NS_ooxml::LN_Value_ST_Border_musicNotes: return OUString("musicNotes");
177 case NS_ooxml::LN_Value_ST_Border_northwest: return OUString("northwest");
178 case NS_ooxml::LN_Value_ST_Border_ovals: return OUString("ovals");
179 case NS_ooxml::LN_Value_ST_Border_packages: return OUString("packages");
180 case NS_ooxml::LN_Value_ST_Border_palmsBlack: return OUString("palmsBlack");
181 case NS_ooxml::LN_Value_ST_Border_palmsColor: return OUString("palmsColor");
182 case NS_ooxml::LN_Value_ST_Border_paperClips: return OUString("paperClips");
183 case NS_ooxml::LN_Value_ST_Border_papyrus: return OUString("papyrus");
184 case NS_ooxml::LN_Value_ST_Border_partyFavor: return OUString("partyFavor");
185 case NS_ooxml::LN_Value_ST_Border_partyGlass: return OUString("partyGlass");
186 case NS_ooxml::LN_Value_ST_Border_pencils: return OUString("pencils");
187 case NS_ooxml::LN_Value_ST_Border_people: return OUString("people");
188 case NS_ooxml::LN_Value_ST_Border_peopleWaving: return OUString("peopleWaving");
189 case NS_ooxml::LN_Value_ST_Border_peopleHats: return OUString("peopleHats");
190 case NS_ooxml::LN_Value_ST_Border_poinsettias: return OUString("poinsettias");
191 case NS_ooxml::LN_Value_ST_Border_postageStamp: return OUString("postageStamp");
192 case NS_ooxml::LN_Value_ST_Border_pumpkin1: return OUString("pumpkin1");
193 case NS_ooxml::LN_Value_ST_Border_pushPinNote2: return OUString("pushPinNote2");
194 case NS_ooxml::LN_Value_ST_Border_pushPinNote1: return OUString("pushPinNote1");
195 case NS_ooxml::LN_Value_ST_Border_pyramids: return OUString("pyramids");
196 case NS_ooxml::LN_Value_ST_Border_pyramidsAbove: return OUString("pyramidsAbove");
197 case NS_ooxml::LN_Value_ST_Border_quadrants: return OUString("quadrants");
198 case NS_ooxml::LN_Value_ST_Border_rings: return OUString("rings");
199 case NS_ooxml::LN_Value_ST_Border_safari: return OUString("safari");
200 case NS_ooxml::LN_Value_ST_Border_sawtooth: return OUString("sawtooth");
201 case NS_ooxml::LN_Value_ST_Border_sawtoothGray: return OUString("sawtoothGray");
202 case NS_ooxml::LN_Value_ST_Border_scaredCat: return OUString("scaredCat");
203 case NS_ooxml::LN_Value_ST_Border_seattle: return OUString("seattle");
204 case NS_ooxml::LN_Value_ST_Border_shadowedSquares: return OUString("shadowedSquares");
205 case NS_ooxml::LN_Value_ST_Border_sharksTeeth: return OUString("sharksTeeth");
206 case NS_ooxml::LN_Value_ST_Border_shorebirdTracks: return OUString("shorebirdTracks");
207 case NS_ooxml::LN_Value_ST_Border_skyrocket: return OUString("skyrocket");
208 case NS_ooxml::LN_Value_ST_Border_snowflakeFancy: return OUString("snowflakeFancy");
209 case NS_ooxml::LN_Value_ST_Border_snowflakes: return OUString("snowflakes");
210 case NS_ooxml::LN_Value_ST_Border_sombrero: return OUString("sombrero");
211 case NS_ooxml::LN_Value_ST_Border_southwest: return OUString("southwest");
212 case NS_ooxml::LN_Value_ST_Border_stars: return OUString("stars");
213 case NS_ooxml::LN_Value_ST_Border_starsTop: return OUString("starsTop");
214 case NS_ooxml::LN_Value_ST_Border_stars3d: return OUString("stars3d");
215 case NS_ooxml::LN_Value_ST_Border_starsBlack: return OUString("starsBlack");
216 case NS_ooxml::LN_Value_ST_Border_starsShadowed: return OUString("starsShadowed");
217 case NS_ooxml::LN_Value_ST_Border_sun: return OUString("sun");
218 case NS_ooxml::LN_Value_ST_Border_swirligig: return OUString("swirligig");
219 case NS_ooxml::LN_Value_ST_Border_tornPaper: return OUString("tornPaper");
220 case NS_ooxml::LN_Value_ST_Border_tornPaperBlack: return OUString("tornPaperBlack");
221 case NS_ooxml::LN_Value_ST_Border_trees: return OUString("trees");
222 case NS_ooxml::LN_Value_ST_Border_triangleParty: return OUString("triangleParty");
223 case NS_ooxml::LN_Value_ST_Border_triangles: return OUString("triangles");
224 case NS_ooxml::LN_Value_ST_Border_tribal1: return OUString("tribal1");
225 case NS_ooxml::LN_Value_ST_Border_tribal2: return OUString("tribal2");
226 case NS_ooxml::LN_Value_ST_Border_tribal3: return OUString("tribal3");
227 case NS_ooxml::LN_Value_ST_Border_tribal4: return OUString("tribal4");
228 case NS_ooxml::LN_Value_ST_Border_tribal5: return OUString("tribal5");
229 case NS_ooxml::LN_Value_ST_Border_tribal6: return OUString("tribal6");
230 case NS_ooxml::LN_Value_ST_Border_twistedLines1: return OUString("twistedLines1");
231 case NS_ooxml::LN_Value_ST_Border_twistedLines2: return OUString("twistedLines2");
232 case NS_ooxml::LN_Value_ST_Border_vine: return OUString("vine");
233 case NS_ooxml::LN_Value_ST_Border_waveline: return OUString("waveline");
234 case NS_ooxml::LN_Value_ST_Border_weavingAngles: return OUString("weavingAngles");
235 case NS_ooxml::LN_Value_ST_Border_weavingBraid: return OUString("weavingBraid");
236 case NS_ooxml::LN_Value_ST_Border_weavingRibbon: return OUString("weavingRibbon");
237 case NS_ooxml::LN_Value_ST_Border_weavingStrips: return OUString("weavingStrips");
238 case NS_ooxml::LN_Value_ST_Border_whiteFlowers: return OUString("whiteFlowers");
239 case NS_ooxml::LN_Value_ST_Border_woodwork: return OUString("woodwork");
240 case NS_ooxml::LN_Value_ST_Border_xIllusions: return OUString("xIllusions");
241 case NS_ooxml::LN_Value_ST_Border_zanyTriangles: return OUString("zanyTriangles");
242 case NS_ooxml::LN_Value_ST_Border_zigZag: return OUString("zigZag");
243 case NS_ooxml::LN_Value_ST_Border_zigZagStitch: return OUString("zigZagStitch");
244 default: break;
246 return OUString();
249 OUString TDefTableHandler::getThemeColorTypeString(sal_Int32 nType)
251 switch (nType)
253 case NS_ooxml::LN_Value_St_ThemeColor_dark1: return OUString("dark1");
254 case NS_ooxml::LN_Value_St_ThemeColor_light1: return OUString("light1");
255 case NS_ooxml::LN_Value_St_ThemeColor_dark2: return OUString("dark2");
256 case NS_ooxml::LN_Value_St_ThemeColor_light2: return OUString("light2");
257 case NS_ooxml::LN_Value_St_ThemeColor_accent1: return OUString("accent1");
258 case NS_ooxml::LN_Value_St_ThemeColor_accent2: return OUString("accent2");
259 case NS_ooxml::LN_Value_St_ThemeColor_accent3: return OUString("accent3");
260 case NS_ooxml::LN_Value_St_ThemeColor_accent4: return OUString("accent4");
261 case NS_ooxml::LN_Value_St_ThemeColor_accent5: return OUString("accent5");
262 case NS_ooxml::LN_Value_St_ThemeColor_accent6: return OUString("accent6");
263 case NS_ooxml::LN_Value_St_ThemeColor_hyperlink: return OUString("hyperlink");
264 case NS_ooxml::LN_Value_St_ThemeColor_followedHyperlink: return OUString("followedHyperlink");
265 case NS_ooxml::LN_Value_St_ThemeColor_none: return OUString("none");
266 case NS_ooxml::LN_Value_St_ThemeColor_background1: return OUString("background1");
267 case NS_ooxml::LN_Value_St_ThemeColor_text1: return OUString("text1");
268 case NS_ooxml::LN_Value_St_ThemeColor_background2: return OUString("background2");
269 case NS_ooxml::LN_Value_St_ThemeColor_text2: return OUString("text2");
270 default: break;
272 return OUString();
275 void TDefTableHandler::lcl_attribute(Id rName, Value & rVal)
277 sal_Int32 nIntValue = rVal.getInt();
278 switch( rName )
280 case NS_ooxml::LN_CT_Border_sz:
281 // width of a single line in 1/8 pt, max of 32 pt -> twip * 5 / 2.
282 m_nLineWidth = nIntValue * 5 / 2;
283 appendGrabBag("sz", OUString::number(nIntValue));
284 break;
285 case NS_ooxml::LN_CT_Border_val:
286 m_nLineType = nIntValue;
287 appendGrabBag("val", TDefTableHandler::getBorderTypeString(nIntValue));
288 break;
289 case NS_ooxml::LN_CT_Border_color:
290 appendGrabBag("color", OUString::fromUtf8(msfilter::util::ConvertColor(nIntValue)));
291 m_nLineColor = nIntValue;
292 break;
293 case NS_ooxml::LN_CT_Border_space:
294 appendGrabBag("space", OUString::number(nIntValue));
295 break;
296 case NS_ooxml::LN_CT_Border_shadow:
297 //if 1 then line has shadow - unsupported
298 case NS_ooxml::LN_CT_Border_frame:
299 // ignored
300 break;
301 case NS_ooxml::LN_CT_Border_themeColor:
302 appendGrabBag("themeColor", TDefTableHandler::getThemeColorTypeString(nIntValue));
303 break;
304 case NS_ooxml::LN_CT_Border_themeTint:
305 case NS_ooxml::LN_CT_Border_themeShade:
306 // ignored
307 break;
308 default:
309 OSL_FAIL("unknown attribute");
314 void TDefTableHandler::localResolve(Id rName, const writerfilter::Reference<Properties>::Pointer_t& pProperties)
316 if( pProperties.get())
318 m_nLineWidth = m_nLineType = m_nLineColor = 0;
319 std::vector<beans::PropertyValue> aSavedGrabBag;
320 if (!m_aInteropGrabBagName.isEmpty())
322 aSavedGrabBag = m_aInteropGrabBag;
323 m_aInteropGrabBag.clear();
325 pProperties->resolve( *this );
326 table::BorderLine2 aBorderLine;
327 ConversionHelper::MakeBorderLine(m_nLineWidth, m_nLineType, m_nLineColor, aBorderLine, /*bIsOOXML=*/true);
328 const bool rtl = false; // TODO
329 switch( rName )
331 case NS_ooxml::LN_CT_TcBorders_top:
332 m_aTopBorderLines.push_back(aBorderLine);
333 if (!m_aInteropGrabBagName.isEmpty())
334 aSavedGrabBag.push_back(getInteropGrabBag("top"));
335 break;
336 case NS_ooxml::LN_CT_TcBorders_start:
337 if( rtl )
338 m_aRightBorderLines.push_back(aBorderLine);
339 else
340 m_aLeftBorderLines.push_back(aBorderLine);
341 if (!m_aInteropGrabBagName.isEmpty())
342 aSavedGrabBag.push_back(getInteropGrabBag("start"));
343 break;
344 case NS_ooxml::LN_CT_TcBorders_left:
345 m_aLeftBorderLines.push_back(aBorderLine);
346 if (!m_aInteropGrabBagName.isEmpty())
347 aSavedGrabBag.push_back(getInteropGrabBag("left"));
348 break;
349 case NS_ooxml::LN_CT_TcBorders_bottom:
350 m_aBottomBorderLines.push_back(aBorderLine);
351 if (!m_aInteropGrabBagName.isEmpty())
352 aSavedGrabBag.push_back(getInteropGrabBag("bottom"));
353 break;
354 case NS_ooxml::LN_CT_TcBorders_end:
355 if( rtl )
356 m_aLeftBorderLines.push_back(aBorderLine);
357 else
358 m_aRightBorderLines.push_back(aBorderLine);
359 if (!m_aInteropGrabBagName.isEmpty())
360 aSavedGrabBag.push_back(getInteropGrabBag("end"));
361 break;
362 case NS_ooxml::LN_CT_TcBorders_right:
363 m_aRightBorderLines.push_back(aBorderLine);
364 if (!m_aInteropGrabBagName.isEmpty())
365 aSavedGrabBag.push_back(getInteropGrabBag("right"));
366 break;
367 case NS_ooxml::LN_CT_TcBorders_insideH:
368 m_aInsideHBorderLines.push_back(aBorderLine);
369 if (!m_aInteropGrabBagName.isEmpty())
370 aSavedGrabBag.push_back(getInteropGrabBag("insideH"));
371 break;
372 case NS_ooxml::LN_CT_TcBorders_insideV:
373 m_aInsideVBorderLines.push_back(aBorderLine);
374 if (!m_aInteropGrabBagName.isEmpty())
375 aSavedGrabBag.push_back(getInteropGrabBag("insideV"));
376 break;
377 case NS_ooxml::LN_CT_TcBorders_tl2br:
378 if (!m_aInteropGrabBagName.isEmpty())
379 aSavedGrabBag.push_back(getInteropGrabBag("tl2br"));
380 break;
381 case NS_ooxml::LN_CT_TcBorders_tr2bl:
382 if (!m_aInteropGrabBagName.isEmpty())
383 aSavedGrabBag.push_back(getInteropGrabBag("tr2bl"));
384 break;
385 default:;
387 if (!m_aInteropGrabBagName.isEmpty())
388 m_aInteropGrabBag = aSavedGrabBag;
393 void TDefTableHandler::lcl_sprm(Sprm & rSprm)
395 switch( rSprm.getId() )
397 case NS_ooxml::LN_CT_TcBorders_top:
398 case NS_ooxml::LN_CT_TcBorders_left:
399 case NS_ooxml::LN_CT_TcBorders_start:
400 case NS_ooxml::LN_CT_TcBorders_bottom:
401 case NS_ooxml::LN_CT_TcBorders_right:
402 case NS_ooxml::LN_CT_TcBorders_end:
403 case NS_ooxml::LN_CT_TcBorders_insideH:
404 case NS_ooxml::LN_CT_TcBorders_insideV:
405 case NS_ooxml::LN_CT_TcBorders_tl2br:
406 case NS_ooxml::LN_CT_TcBorders_tr2bl:
408 writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
409 localResolve( rSprm.getId(), pProperties );
411 break;
412 default:;
416 void TDefTableHandler::fillCellProperties( const ::tools::SvRef< TablePropertyMap >& pCellProperties ) const
418 if( !m_aTopBorderLines.empty() )
419 pCellProperties->Insert( PROP_TOP_BORDER, uno::makeAny( m_aTopBorderLines[0] ) );
420 if( !m_aLeftBorderLines.empty() )
421 pCellProperties->Insert( PROP_LEFT_BORDER, uno::makeAny( m_aLeftBorderLines[0] ) );
422 if( !m_aBottomBorderLines.empty() )
423 pCellProperties->Insert( PROP_BOTTOM_BORDER, uno::makeAny( m_aBottomBorderLines[0] ) );
424 if( !m_aRightBorderLines.empty() )
425 pCellProperties->Insert( PROP_RIGHT_BORDER, uno::makeAny( m_aRightBorderLines[0] ) );
426 if( !m_aInsideHBorderLines.empty() )
427 pCellProperties->Insert( META_PROP_HORIZONTAL_BORDER, uno::makeAny( m_aInsideHBorderLines[0] ) );
428 if( !m_aInsideVBorderLines.empty() )
429 pCellProperties->Insert( META_PROP_VERTICAL_BORDER, uno::makeAny( m_aInsideVBorderLines[0] ) );
433 void TDefTableHandler::enableInteropGrabBag(const OUString& aName)
435 m_aInteropGrabBagName = aName;
438 beans::PropertyValue TDefTableHandler::getInteropGrabBag(const OUString& aName)
440 beans::PropertyValue aRet;
441 if (aName.isEmpty())
442 aRet.Name = m_aInteropGrabBagName;
443 else
444 aRet.Name = aName;
446 aRet.Value <<= comphelper::containerToSequence(m_aInteropGrabBag);
447 m_aInteropGrabBag.clear();
448 return aRet;
451 void TDefTableHandler::appendGrabBag(const OUString& aKey, const OUString& aValue)
453 beans::PropertyValue aProperty;
454 aProperty.Name = aKey;
455 aProperty.Value <<= aValue;
456 m_aInteropGrabBag.push_back(aProperty);
459 } //namespace dmapper
460 } //namespace writerfilter
462 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */