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