Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <stdlib.h>
30 : :
31 : : #include <svx/svxids.hrc>
32 : : #include <i18npool/mslangid.hxx>
33 : : #include <svtools/ctrltool.hxx>
34 : : #include <svl/urihelper.hxx>
35 : : #include <editeng/udlnitem.hxx>
36 : : #include <editeng/adjitem.hxx>
37 : : #include <editeng/blnkitem.hxx>
38 : : #include <editeng/crsditem.hxx>
39 : : #include <editeng/kernitem.hxx>
40 : : #include <editeng/lspcitem.hxx>
41 : : #include <editeng/fontitem.hxx>
42 : : #include <editeng/postitem.hxx>
43 : : #include <editeng/colritem.hxx>
44 : : #include <editeng/cmapitem.hxx>
45 : : #include <editeng/brshitem.hxx>
46 : : #include <editeng/wghtitem.hxx>
47 : : #include <editeng/fhgtitem.hxx>
48 : : #include <editeng/boxitem.hxx>
49 : : #include <editeng/ulspitem.hxx>
50 : : #include <editeng/lrspitem.hxx>
51 : : #include <editeng/langitem.hxx>
52 : : #include <svl/itempool.hxx>
53 : : #include <editeng/spltitem.hxx>
54 : : #include <editeng/widwitem.hxx>
55 : : #include <editeng/frmdiritem.hxx>
56 : : #include <editeng/orphitem.hxx>
57 : : #include <svtools/svparser.hxx>
58 : : #include <vcl/svapp.hxx>
59 : : #include <vcl/wrkwin.hxx>
60 : :
61 : : #include "css1kywd.hxx"
62 : : #include "svxcss1.hxx"
63 : :
64 : : #include <memory>
65 : :
66 : :
67 : : using namespace ::com::sun::star;
68 : :
69 : : // die Funktionen zum Parsen einer CSS1-Property sind von folgendem Typ:
70 : : typedef void (*FnParseCSS1Prop)( const CSS1Expression *pExpr,
71 : : SfxItemSet& rItemSet,
72 : : SvxCSS1PropertyInfo& rPropInfo,
73 : : const SvxCSS1Parser& rParser );
74 : :
75 : : static CSS1PropertyEnum const aFontSizeTable[] =
76 : : {
77 : : { sCSS1_PV_xx_small, 0 },
78 : : { sCSS1_PV_x_small, 1 },
79 : : { sCSS1_PV_small, 2 },
80 : : { sCSS1_PV_medium, 3 },
81 : : { sCSS1_PV_large, 4 },
82 : : { sCSS1_PV_x_large, 5 },
83 : : { sCSS1_PV_xx_large, 6 },
84 : : { 0, 0 }
85 : : };
86 : :
87 : : static CSS1PropertyEnum const aFontFamilyTable[] =
88 : : {
89 : : { sCSS1_PV_serif, FAMILY_ROMAN },
90 : : { sCSS1_PV_sans_serif, FAMILY_SWISS },
91 : : { sCSS1_PV_cursive, FAMILY_SCRIPT },
92 : : { sCSS1_PV_fantasy, FAMILY_DECORATIVE },
93 : : { sCSS1_PV_monospace, FAMILY_MODERN },
94 : : { 0, 0 }
95 : : };
96 : :
97 : : static CSS1PropertyEnum const aFontWeightTable[] =
98 : : {
99 : : { sCSS1_PV_extra_light, WEIGHT_NORMAL }, // WEIGHT_ULTRALIGHT (OBS)
100 : : { sCSS1_PV_light, WEIGHT_NORMAL }, // WEIGHT_LIGHT (OBSOLETE)
101 : : { sCSS1_PV_demi_light, WEIGHT_NORMAL }, // WEIGHT_SEMILIGHT (OBS)
102 : : { sCSS1_PV_medium, WEIGHT_NORMAL }, // WEIGHT_MEDIUM (OBS)
103 : : { sCSS1_PV_normal, WEIGHT_NORMAL }, // WEIGHT_MEDIUM
104 : : { sCSS1_PV_demi_bold, WEIGHT_NORMAL }, // WEIGHT_SEMIBOLD (OBS)
105 : : { sCSS1_PV_bold, WEIGHT_BOLD }, // WEIGHT_BOLD (OBSOLETE)
106 : : { sCSS1_PV_extra_bold, WEIGHT_BOLD }, // WEIGHT_ULTRABOLD (OBS)
107 : : { sCSS1_PV_bolder, WEIGHT_BOLD },
108 : : { sCSS1_PV_lighter, WEIGHT_NORMAL },
109 : : { 0, 0 }
110 : : };
111 : :
112 : : static CSS1PropertyEnum const aFontStyleTable[] =
113 : : {
114 : : { sCSS1_PV_normal, ITALIC_NONE },
115 : : { sCSS1_PV_italic, ITALIC_NORMAL },
116 : : { sCSS1_PV_oblique, ITALIC_NORMAL },
117 : : { 0, 0 }
118 : : };
119 : :
120 : : static CSS1PropertyEnum const aFontVariantTable[] =
121 : : {
122 : : { sCSS1_PV_normal, SVX_CASEMAP_NOT_MAPPED },
123 : : { sCSS1_PV_small_caps, SVX_CASEMAP_KAPITAELCHEN },
124 : : { 0, 0 }
125 : : };
126 : :
127 : : static CSS1PropertyEnum const aTextTransformTable[] =
128 : : {
129 : : { sCSS1_PV_uppercase, SVX_CASEMAP_VERSALIEN },
130 : : { sCSS1_PV_lowercase, SVX_CASEMAP_GEMEINE },
131 : : { sCSS1_PV_capitalize, SVX_CASEMAP_TITEL },
132 : : { 0, 0 }
133 : : };
134 : :
135 : : static CSS1PropertyEnum const aDirectionTable[] =
136 : : {
137 : : { sCSS1_PV_ltr, FRMDIR_HORI_LEFT_TOP },
138 : : { sCSS1_PV_rtl, FRMDIR_HORI_RIGHT_TOP },
139 : : { sCSS1_PV_inherit, FRMDIR_ENVIRONMENT },
140 : : { 0, 0 }
141 : : };
142 : :
143 : : static CSS1PropertyEnum const aBGRepeatTable[] =
144 : : {
145 : : { sCSS1_PV_repeat, GPOS_TILED },
146 : : { sCSS1_PV_repeat_x, GPOS_TILED },
147 : : { sCSS1_PV_repeat_y, GPOS_TILED },
148 : : { sCSS1_PV_no_repeat, GPOS_NONE },
149 : : { 0, 0 }
150 : : };
151 : :
152 : : static CSS1PropertyEnum const aBGHoriPosTable[] =
153 : : {
154 : : { sCSS1_PV_left, GPOS_LT },
155 : : { sCSS1_PV_center, GPOS_MT },
156 : : { sCSS1_PV_right, GPOS_RT },
157 : : { 0, 0 }
158 : : };
159 : :
160 : : static CSS1PropertyEnum const aBGVertPosTable[] =
161 : : {
162 : : { sCSS1_PV_top, GPOS_LT },
163 : : { sCSS1_PV_middle, GPOS_LM },
164 : : { sCSS1_PV_bottom, GPOS_LB },
165 : : { 0, 0 }
166 : : };
167 : :
168 : : static CSS1PropertyEnum const aTextAlignTable[] =
169 : : {
170 : : { sCSS1_PV_left, SVX_ADJUST_LEFT },
171 : : { sCSS1_PV_center, SVX_ADJUST_CENTER },
172 : : { sCSS1_PV_right, SVX_ADJUST_RIGHT },
173 : : { sCSS1_PV_justify, SVX_ADJUST_BLOCK },
174 : : { 0, 0 }
175 : : };
176 : :
177 : : static CSS1PropertyEnum const aBorderWidthTable[] =
178 : : {
179 : : { sCSS1_PV_thin, 0 }, // DEF_LINE_WIDTH_0 / DEF_DOUBLE_LINE0
180 : : { sCSS1_PV_medium, 1 }, // DEF_LINE_WIDTH_1 / DEF_DOUBLE_LINE1
181 : : { sCSS1_PV_thick, 2 }, // DEF_LINE_WIDTH_2 / DEF_DOUBLE_LINE2
182 : : { 0, 0 }
183 : : };
184 : :
185 : : enum CSS1BorderStyle { CSS1_BS_NONE, CSS1_BS_SINGLE, CSS1_BS_DOUBLE, CSS1_BS_DOTTED, CSS1_BS_DASHED, CSS1_BS_GROOVE, CSS1_BS_RIDGE, CSS1_BS_INSET, CSS1_BS_OUTSET };
186 : :
187 : : static CSS1PropertyEnum const aBorderStyleTable[] =
188 : : {
189 : : { sCSS1_PV_none, CSS1_BS_NONE },
190 : : { sCSS1_PV_dotted, CSS1_BS_DOTTED },
191 : : { sCSS1_PV_dashed, CSS1_BS_DASHED },
192 : : { sCSS1_PV_solid, CSS1_BS_SINGLE },
193 : : { sCSS1_PV_double, CSS1_BS_DOUBLE },
194 : : { sCSS1_PV_groove, CSS1_BS_GROOVE },
195 : : { sCSS1_PV_ridge, CSS1_BS_RIDGE },
196 : : { sCSS1_PV_inset, CSS1_BS_INSET },
197 : : { sCSS1_PV_outset, CSS1_BS_OUTSET },
198 : : { 0, 0 }
199 : : };
200 : :
201 : : static CSS1PropertyEnum const aFloatTable[] =
202 : : {
203 : : { sCSS1_PV_left, SVX_ADJUST_LEFT },
204 : : { sCSS1_PV_right, SVX_ADJUST_RIGHT },
205 : : { sCSS1_PV_none, SVX_ADJUST_END },
206 : : { 0, 0 }
207 : : };
208 : :
209 : : static CSS1PropertyEnum const aPositionTable[] =
210 : : {
211 : : { sCSS1_PV_absolute, SVX_CSS1_POS_ABSOLUTE },
212 : : { sCSS1_PV_relative, SVX_CSS1_POS_RELATIVE },
213 : : { sCSS1_PV_static, SVX_CSS1_POS_STATIC },
214 : : { 0, 0 }
215 : : };
216 : :
217 : : // Feature: PrintExt
218 : : static CSS1PropertyEnum const aSizeTable[] =
219 : : {
220 : : { sCSS1_PV_auto, SVX_CSS1_STYPE_AUTO },
221 : : { sCSS1_PV_landscape, SVX_CSS1_STYPE_LANDSCAPE },
222 : : { sCSS1_PV_portrait, SVX_CSS1_STYPE_PORTRAIT },
223 : : { 0, 0 }
224 : : };
225 : :
226 : : static CSS1PropertyEnum const aPageBreakTable[] =
227 : : {
228 : : { sCSS1_PV_auto, SVX_CSS1_PBREAK_AUTO },
229 : : { sCSS1_PV_always, SVX_CSS1_PBREAK_ALWAYS },
230 : : { sCSS1_PV_avoid, SVX_CSS1_PBREAK_AVOID },
231 : : { sCSS1_PV_left, SVX_CSS1_PBREAK_LEFT },
232 : : { sCSS1_PV_right, SVX_CSS1_PBREAK_RIGHT },
233 : : { 0, 0 }
234 : : };
235 : :
236 : : // /Feature: PrintExt
237 : :
238 : : static sal_uInt16 const aBorderWidths[] =
239 : : {
240 : : DEF_LINE_WIDTH_0,
241 : : DEF_LINE_WIDTH_5,
242 : : DEF_LINE_WIDTH_1
243 : : };
244 : :
245 : : #undef SBORDER_ENTRY
246 : : #undef DBORDER_ENTRY
247 : :
248 : : struct SvxCSS1ItemIds
249 : : {
250 : : sal_uInt16 nFont;
251 : : sal_uInt16 nFontCJK;
252 : : sal_uInt16 nFontCTL;
253 : : sal_uInt16 nPosture;
254 : : sal_uInt16 nPostureCJK;
255 : : sal_uInt16 nPostureCTL;
256 : : sal_uInt16 nWeight;
257 : : sal_uInt16 nWeightCJK;
258 : : sal_uInt16 nWeightCTL;
259 : : sal_uInt16 nFontHeight;
260 : : sal_uInt16 nFontHeightCJK;
261 : : sal_uInt16 nFontHeightCTL;
262 : : sal_uInt16 nUnderline;
263 : : sal_uInt16 nOverline;
264 : : sal_uInt16 nCrossedOut;
265 : : sal_uInt16 nColor;
266 : : sal_uInt16 nKerning;
267 : : sal_uInt16 nCaseMap;
268 : : sal_uInt16 nBlink;
269 : :
270 : : sal_uInt16 nLineSpacing;
271 : : sal_uInt16 nAdjust;
272 : : sal_uInt16 nWidows;
273 : : sal_uInt16 nOrphans;
274 : : sal_uInt16 nFmtSplit;
275 : :
276 : : sal_uInt16 nLRSpace;
277 : : sal_uInt16 nULSpace;
278 : : sal_uInt16 nBox;
279 : : sal_uInt16 nBrush;
280 : :
281 : : sal_uInt16 nLanguage;
282 : : sal_uInt16 nLanguageCJK;
283 : : sal_uInt16 nLanguageCTL;
284 : : sal_uInt16 nDirection;
285 : : };
286 : :
287 : :
288 : : static SvxCSS1ItemIds aItemIds;
289 : :
290 : :
291 : :
292 : : struct SvxCSS1BorderInfo
293 : : {
294 : : Color aColor;
295 : : sal_uInt16 nAbsWidth;
296 : : sal_uInt16 nNamedWidth;
297 : : CSS1BorderStyle eStyle;
298 : :
299 : 0 : SvxCSS1BorderInfo() :
300 : : aColor( COL_BLACK ), nAbsWidth( USHRT_MAX ),
301 : 0 : nNamedWidth( USHRT_MAX ), eStyle( CSS1_BS_NONE )
302 : 0 : {}
303 : :
304 : 0 : SvxCSS1BorderInfo( const SvxCSS1BorderInfo& rInfo ) :
305 : : aColor( rInfo.aColor ), nAbsWidth( rInfo.nAbsWidth ),
306 : 0 : nNamedWidth( rInfo.nNamedWidth ), eStyle( rInfo.eStyle )
307 : 0 : {}
308 : :
309 : : void SetBorderLine( sal_uInt16 nLine, SvxBoxItem &rBoxItem ) const;
310 : : };
311 : :
312 : 0 : void SvxCSS1BorderInfo::SetBorderLine( sal_uInt16 nLine, SvxBoxItem &rBoxItem ) const
313 : : {
314 [ # # ][ # # ]: 0 : if( CSS1_BS_NONE==eStyle || nAbsWidth==0 ||
[ # # ][ # # ]
315 : : (nAbsWidth==USHRT_MAX && nNamedWidth==USHRT_MAX) )
316 : : {
317 [ # # ]: 0 : rBoxItem.SetLine( 0, nLine );
318 : 0 : return;
319 : : }
320 : :
321 [ # # ]: 0 : ::editeng::SvxBorderLine aBorderLine( &aColor );
322 : :
323 : : // Linien-Stil doppelt oder einfach?
324 [ # # # # : 0 : switch ( eStyle )
# # # #
# ]
325 : : {
326 : : case CSS1_BS_SINGLE:
327 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::SOLID);
328 : 0 : break;
329 : : case CSS1_BS_DOUBLE:
330 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DOUBLE);
331 : 0 : break;
332 : : case CSS1_BS_DOTTED:
333 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DOTTED);
334 : 0 : break;
335 : : case CSS1_BS_DASHED:
336 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::DASHED);
337 : 0 : break;
338 : : case CSS1_BS_GROOVE:
339 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::ENGRAVED);
340 : 0 : break;
341 : : case CSS1_BS_RIDGE:
342 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::EMBOSSED);
343 : 0 : break;
344 : : case CSS1_BS_INSET:
345 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::INSET);
346 : 0 : break;
347 : : case CSS1_BS_OUTSET:
348 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::OUTSET);
349 : 0 : break;
350 : : default:
351 [ # # ]: 0 : aBorderLine.SetBorderLineStyle(table::BorderLineStyle::NONE);
352 : 0 : break;
353 : : }
354 : :
355 : : // benannte Breite umrechnenen, wenn keine absolute gegeben ist
356 [ # # ]: 0 : if( nAbsWidth==USHRT_MAX )
357 : 0 : aBorderLine.SetWidth( aBorderWidths[ nNamedWidth ] );
358 : : else
359 : 0 : aBorderLine.SetWidth( nAbsWidth );
360 : :
361 [ # # ]: 0 : rBoxItem.SetLine( &aBorderLine, nLine );
362 : : }
363 : :
364 : 6 : SvxCSS1PropertyInfo::SvxCSS1PropertyInfo()
365 : : {
366 [ + + ]: 30 : for( sal_uInt16 i=0; i<4; i++ )
367 : 24 : aBorderInfos[i] = 0;
368 : :
369 [ + - ]: 6 : Clear();
370 : 6 : }
371 : :
372 : 0 : SvxCSS1PropertyInfo::SvxCSS1PropertyInfo( const SvxCSS1PropertyInfo& rProp ) :
373 : : aId( rProp.aId ),
374 : : bTopMargin( rProp.bTopMargin ),
375 : : bBottomMargin( rProp.bBottomMargin ),
376 : : bLeftMargin( rProp.bLeftMargin ),
377 : : bRightMargin( rProp.bRightMargin ),
378 : : bTextIndent( rProp.bTextIndent ),
379 : : eFloat( rProp.eFloat ),
380 : : ePosition( rProp.ePosition ),
381 : : nTopBorderDistance( rProp.nTopBorderDistance ),
382 : : nBottomBorderDistance( rProp.nBottomBorderDistance ),
383 : : nLeftBorderDistance( rProp.nLeftBorderDistance ),
384 : : nRightBorderDistance( rProp.nRightBorderDistance ),
385 : : nLeft( rProp.nLeft ),
386 : : nTop( rProp.nTop ),
387 : : nWidth( rProp.nWidth ),
388 : : nHeight( rProp.nHeight ),
389 : : nLeftMargin( rProp.nLeftMargin ),
390 : : nRightMargin( rProp.nRightMargin ),
391 : : eLeftType( rProp.eLeftType ),
392 : : eTopType( rProp.eTopType ),
393 : : eWidthType( rProp.eWidthType ),
394 : : eHeightType( rProp.eHeightType ),
395 : : // Feature: PrintExt
396 : : eSizeType( rProp.eSizeType ),
397 : : ePageBreakBefore( rProp.ePageBreakBefore ),
398 : 0 : ePageBreakAfter( rProp.ePageBreakAfter )
399 : : // /Feature: PrintExt
400 : : {
401 [ # # ]: 0 : for( sal_uInt16 i=0; i<4; i++ )
402 : 0 : aBorderInfos[i] = rProp.aBorderInfos[i]
403 : 0 : ? new SvxCSS1BorderInfo( *rProp.aBorderInfos[i] )
404 [ # # ][ # # ]: 0 : : 0;
405 : 0 : }
406 : :
407 : 6 : SvxCSS1PropertyInfo::~SvxCSS1PropertyInfo()
408 : : {
409 : 6 : DestroyBorderInfos();
410 : 6 : }
411 : :
412 : 12 : void SvxCSS1PropertyInfo::DestroyBorderInfos()
413 : : {
414 [ + + ]: 60 : for( sal_uInt16 i=0; i<4; i++ )
415 : : {
416 : 48 : delete aBorderInfos[i];
417 : 48 : aBorderInfos[i] = 0;
418 : : }
419 : 12 : }
420 : :
421 : 6 : void SvxCSS1PropertyInfo::Clear()
422 : : {
423 : 6 : aId.Erase();
424 : 6 : bTopMargin = bBottomMargin = sal_False;
425 : 6 : bLeftMargin = bRightMargin = bTextIndent = sal_False;
426 : 6 : nLeftMargin = nRightMargin = 0;
427 : 6 : eFloat = SVX_ADJUST_END;
428 : :
429 : 6 : ePosition = SVX_CSS1_POS_NONE;
430 : : nTopBorderDistance = nBottomBorderDistance =
431 : 6 : nLeftBorderDistance = nRightBorderDistance = USHRT_MAX;
432 : 6 : nLeft = nTop = nWidth = nHeight = 0;
433 : 6 : eLeftType = eTopType = eWidthType = eHeightType = SVX_CSS1_LTYPE_NONE;
434 : :
435 : : // Feature: PrintExt
436 : 6 : eSizeType = SVX_CSS1_STYPE_NONE;
437 : 6 : ePageBreakBefore = SVX_CSS1_PBREAK_NONE;
438 : 6 : ePageBreakAfter = SVX_CSS1_PBREAK_NONE;
439 : :
440 : 6 : DestroyBorderInfos();
441 : 6 : }
442 : :
443 : 0 : void SvxCSS1PropertyInfo::Merge( const SvxCSS1PropertyInfo& rProp )
444 : : {
445 [ # # ]: 0 : if( rProp.bTopMargin )
446 : 0 : bTopMargin = sal_True;
447 [ # # ]: 0 : if( rProp.bBottomMargin )
448 : 0 : bBottomMargin = sal_True;
449 : :
450 [ # # ]: 0 : if( rProp.bLeftMargin )
451 : : {
452 : 0 : bLeftMargin = sal_True;
453 : 0 : nLeftMargin = rProp.nLeftMargin;
454 : : }
455 [ # # ]: 0 : if( rProp.bRightMargin )
456 : : {
457 : 0 : bRightMargin = sal_True;
458 : 0 : nRightMargin = rProp.nRightMargin;
459 : : }
460 [ # # ]: 0 : if( rProp.bTextIndent )
461 : 0 : bTextIndent = sal_True;
462 : :
463 [ # # ]: 0 : for( sal_uInt16 i=0; i<4; i++ )
464 : : {
465 [ # # ]: 0 : if( rProp.aBorderInfos[i] )
466 : : {
467 [ # # ]: 0 : if( aBorderInfos[i] )
468 : 0 : delete aBorderInfos[i];
469 : :
470 : 0 : aBorderInfos[i] = new SvxCSS1BorderInfo( *rProp.aBorderInfos[i] );
471 : : }
472 : : }
473 : :
474 [ # # ]: 0 : if( USHRT_MAX != rProp.nTopBorderDistance )
475 : 0 : nTopBorderDistance = rProp.nTopBorderDistance;
476 [ # # ]: 0 : if( USHRT_MAX != rProp.nBottomBorderDistance )
477 : 0 : nBottomBorderDistance = rProp.nBottomBorderDistance;
478 [ # # ]: 0 : if( USHRT_MAX != rProp.nLeftBorderDistance )
479 : 0 : nLeftBorderDistance = rProp.nLeftBorderDistance;
480 [ # # ]: 0 : if( USHRT_MAX != rProp.nRightBorderDistance )
481 : 0 : nRightBorderDistance = rProp.nRightBorderDistance;
482 : :
483 [ # # ]: 0 : if( rProp.eFloat != SVX_ADJUST_END )
484 : 0 : eFloat = rProp.eFloat;
485 : :
486 [ # # ]: 0 : if( rProp.ePosition != SVX_CSS1_POS_NONE )
487 : 0 : ePosition = rProp.ePosition;
488 : :
489 : : // Feature: PrintExt
490 [ # # ]: 0 : if( rProp.eSizeType != SVX_CSS1_STYPE_NONE )
491 : : {
492 : 0 : eSizeType = rProp.eSizeType;
493 : 0 : nWidth = rProp.nWidth;
494 : 0 : nHeight = rProp.nHeight;
495 : : }
496 : :
497 [ # # ]: 0 : if( rProp.ePageBreakBefore != SVX_CSS1_PBREAK_NONE )
498 : 0 : ePageBreakBefore = rProp.ePageBreakBefore;
499 : :
500 [ # # ]: 0 : if( rProp.ePageBreakAfter != SVX_CSS1_PBREAK_NONE )
501 : 0 : ePageBreakAfter = rProp.ePageBreakAfter;
502 : :
503 : : // /Feature: PrintExt
504 : :
505 [ # # ]: 0 : if( rProp.eLeftType != SVX_CSS1_LTYPE_NONE )
506 : : {
507 : 0 : eLeftType = rProp.eLeftType;
508 : 0 : nLeft = rProp.nLeft;
509 : : }
510 : :
511 [ # # ]: 0 : if( rProp.eTopType != SVX_CSS1_LTYPE_NONE )
512 : : {
513 : 0 : eTopType = rProp.eTopType;
514 : 0 : nTop = rProp.nTop;
515 : : }
516 : :
517 [ # # ]: 0 : if( rProp.eWidthType != SVX_CSS1_LTYPE_NONE )
518 : : {
519 : 0 : eWidthType = rProp.eWidthType;
520 : 0 : nWidth = rProp.nWidth;
521 : : }
522 : :
523 [ # # ]: 0 : if( rProp.eHeightType != SVX_CSS1_LTYPE_NONE )
524 : : {
525 : 0 : eHeightType = rProp.eHeightType;
526 : 0 : nHeight = rProp.nHeight;
527 : : }
528 : 0 : }
529 : :
530 : 0 : SvxCSS1BorderInfo *SvxCSS1PropertyInfo::GetBorderInfo( sal_uInt16 nLine, sal_Bool bCreate )
531 : : {
532 : 0 : sal_uInt16 nPos = 0;
533 [ # # # # : 0 : switch( nLine )
# ]
534 : : {
535 : 0 : case BOX_LINE_TOP: nPos = 0; break;
536 : 0 : case BOX_LINE_BOTTOM: nPos = 1; break;
537 : 0 : case BOX_LINE_LEFT: nPos = 2; break;
538 : 0 : case BOX_LINE_RIGHT: nPos = 3; break;
539 : : }
540 : :
541 [ # # ][ # # ]: 0 : if( !aBorderInfos[nPos] && bCreate )
542 : 0 : aBorderInfos[nPos] = new SvxCSS1BorderInfo;
543 : :
544 : 0 : return aBorderInfos[nPos];
545 : : }
546 : :
547 : 0 : void SvxCSS1PropertyInfo::CopyBorderInfo( sal_uInt16 nSrcLine, sal_uInt16 nDstLine,
548 : : sal_uInt16 nWhat )
549 : : {
550 : 0 : SvxCSS1BorderInfo *pSrcInfo = GetBorderInfo( nSrcLine, sal_False );
551 [ # # ]: 0 : if( !pSrcInfo )
552 : 0 : return;
553 : :
554 : 0 : SvxCSS1BorderInfo *pDstInfo = GetBorderInfo( nDstLine );
555 [ # # ]: 0 : if( (nWhat & SVX_CSS1_BORDERINFO_WIDTH) != 0 )
556 : : {
557 : 0 : pDstInfo->nAbsWidth = pSrcInfo->nAbsWidth;
558 : 0 : pDstInfo->nNamedWidth = pSrcInfo->nNamedWidth;
559 : : }
560 : :
561 [ # # ]: 0 : if( (nWhat & SVX_CSS1_BORDERINFO_COLOR) != 0 )
562 : 0 : pDstInfo->aColor = pSrcInfo->aColor;
563 : :
564 [ # # ]: 0 : if( (nWhat & SVX_CSS1_BORDERINFO_STYLE) != 0 )
565 : 0 : pDstInfo->eStyle = pSrcInfo->eStyle;
566 : : }
567 : :
568 : 0 : void SvxCSS1PropertyInfo::CopyBorderInfo( sal_uInt16 nCount, sal_uInt16 nWhat )
569 : : {
570 [ # # ]: 0 : if( nCount==0 )
571 : : {
572 : 0 : CopyBorderInfo( BOX_LINE_BOTTOM, BOX_LINE_TOP, nWhat );
573 : 0 : CopyBorderInfo( BOX_LINE_TOP, BOX_LINE_LEFT, nWhat );
574 : : }
575 [ # # ]: 0 : if( nCount<=1 )
576 : : {
577 : 0 : CopyBorderInfo( BOX_LINE_LEFT, BOX_LINE_RIGHT, nWhat );
578 : : }
579 : 0 : }
580 : :
581 : 0 : void SvxCSS1PropertyInfo::SetBoxItem( SfxItemSet& rItemSet,
582 : : sal_uInt16 nMinBorderDist,
583 : : const SvxBoxItem *pDfltItem,
584 : : sal_Bool bTable )
585 : : {
586 : : sal_Bool bChg = nTopBorderDistance != USHRT_MAX ||
587 : : nBottomBorderDistance != USHRT_MAX ||
588 : : nLeftBorderDistance != USHRT_MAX ||
589 [ # # ][ # # ]: 0 : nRightBorderDistance != USHRT_MAX;
[ # # ][ # # ]
590 : : sal_uInt16 i;
591 : :
592 [ # # ][ # # ]: 0 : for( i = 0; !bChg && i < 4; i++ )
[ # # ]
593 : 0 : bChg = aBorderInfos[i]!=0;
594 : :
595 [ # # ]: 0 : if( !bChg )
596 : 0 : return;
597 : :
598 [ # # ]: 0 : SvxBoxItem aBoxItem( aItemIds.nBox );
599 [ # # ]: 0 : if( pDfltItem )
600 [ # # ]: 0 : aBoxItem = *pDfltItem;
601 : :
602 [ # # ]: 0 : SvxCSS1BorderInfo *pInfo = GetBorderInfo( BOX_LINE_TOP, sal_False );
603 [ # # ]: 0 : if( pInfo )
604 [ # # ]: 0 : pInfo->SetBorderLine( BOX_LINE_TOP, aBoxItem );
605 : :
606 [ # # ]: 0 : pInfo = GetBorderInfo( BOX_LINE_BOTTOM, sal_False );
607 [ # # ]: 0 : if( pInfo )
608 [ # # ]: 0 : pInfo->SetBorderLine( BOX_LINE_BOTTOM, aBoxItem );
609 : :
610 [ # # ]: 0 : pInfo = GetBorderInfo( BOX_LINE_LEFT, sal_False );
611 [ # # ]: 0 : if( pInfo )
612 [ # # ]: 0 : pInfo->SetBorderLine( BOX_LINE_LEFT, aBoxItem );
613 : :
614 [ # # ]: 0 : pInfo = GetBorderInfo( BOX_LINE_RIGHT, sal_False );
615 [ # # ]: 0 : if( pInfo )
616 [ # # ]: 0 : pInfo->SetBorderLine( BOX_LINE_RIGHT, aBoxItem );
617 : :
618 [ # # ]: 0 : for( i=0; i<4; i++ )
619 : : {
620 : 0 : sal_uInt16 nLine = BOX_LINE_TOP, nDist = 0;
621 [ # # # # : 0 : switch( i )
# ]
622 : : {
623 : 0 : case 0: nLine = BOX_LINE_TOP;
624 : 0 : nDist = nTopBorderDistance;
625 : 0 : nTopBorderDistance = USHRT_MAX;
626 : 0 : break;
627 : 0 : case 1: nLine = BOX_LINE_BOTTOM;
628 : 0 : nDist = nBottomBorderDistance;
629 : 0 : nBottomBorderDistance = USHRT_MAX;
630 : 0 : break;
631 : 0 : case 2: nLine = BOX_LINE_LEFT;
632 : 0 : nDist = nLeftBorderDistance;
633 : 0 : nLeftBorderDistance = USHRT_MAX;
634 : 0 : break;
635 : 0 : case 3: nLine = BOX_LINE_RIGHT;
636 : 0 : nDist = nRightBorderDistance;
637 : 0 : nRightBorderDistance = USHRT_MAX;
638 : 0 : break;
639 : : }
640 : :
641 [ # # ][ # # ]: 0 : if( aBoxItem.GetLine( nLine ) )
642 : : {
643 [ # # ]: 0 : if( USHRT_MAX == nDist )
644 [ # # ]: 0 : nDist = aBoxItem.GetDistance( nLine );
645 : :
646 [ # # ]: 0 : if( nDist < nMinBorderDist )
647 : 0 : nDist = nMinBorderDist;
648 : : }
649 : : else
650 : : {
651 [ # # ]: 0 : if( USHRT_MAX == nDist )
652 [ # # ]: 0 : nDist = aBoxItem.GetDistance( nLine );
653 : :
654 [ # # ]: 0 : if( !bTable )
655 : 0 : nDist = 0U;
656 [ # # ][ # # ]: 0 : else if( nDist && nDist < nMinBorderDist )
657 : 0 : nDist = nMinBorderDist;
658 : : }
659 : :
660 [ # # ]: 0 : aBoxItem.SetDistance( nDist, nLine );
661 : : }
662 : :
663 [ # # ]: 0 : rItemSet.Put( aBoxItem );
664 : :
665 [ # # ]: 0 : DestroyBorderInfos();
666 : : }
667 : :
668 : 0 : SvxCSS1MapEntry::SvxCSS1MapEntry( const String& rKey, const SfxItemSet& rItemSet,
669 : : const SvxCSS1PropertyInfo& rProp ) :
670 : : aKey( rKey ),
671 : : aItemSet( rItemSet ),
672 [ # # ][ # # ]: 0 : aPropInfo( rProp )
673 : : {
674 : : // TODO: ToUpperAscii
675 [ # # ]: 0 : aKey.ToUpperAscii();
676 : 0 : }
677 : :
678 : 0 : sal_Bool SvxCSS1Parser::StyleParsed( const CSS1Selector * /*pSelector*/,
679 : : SfxItemSet& /*rItemSet*/,
680 : : SvxCSS1PropertyInfo& /*rPropInfo*/ )
681 : : {
682 : : // wie man sieht passiert hier gar nichts
683 : 0 : return sal_True;
684 : : }
685 : :
686 : 0 : bool SvxCSS1Parser::SelectorParsed( CSS1Selector *pSelector, bool bFirst )
687 : : {
688 [ # # ]: 0 : if( bFirst )
689 : : {
690 : : OSL_ENSURE( pSheetItemSet, "Where is the Item-Set for Style-Sheets?" );
691 : :
692 [ # # ]: 0 : for (size_t i = 0; i < aSelectors.size(); ++i)
693 : : {
694 : 0 : StyleParsed( &aSelectors[i], *pSheetItemSet, *pSheetPropInfo );
695 : : }
696 : 0 : pSheetItemSet->ClearItem();
697 : 0 : pSheetPropInfo->Clear();
698 : :
699 : : // und die naechste Rule vorbereiten
700 : 0 : aSelectors.clear();
701 : : }
702 : :
703 : 0 : aSelectors.push_back(pSelector);
704 : :
705 : 0 : return false; // den Selektor haben wir gespeichert. Loeschen toedlich!
706 : : }
707 : :
708 : :
709 : 0 : sal_Bool SvxCSS1Parser::DeclarationParsed( const String& rProperty,
710 : : const CSS1Expression *pExpr )
711 : : {
712 : : OSL_ENSURE( pExpr, "DeclarationParsed() without Expression" );
713 : :
714 [ # # ]: 0 : if( !pExpr )
715 : 0 : return sal_True;
716 : :
717 : 0 : ParseProperty( rProperty, pExpr );
718 : :
719 : 0 : return sal_True; // die Deklaration brauchen wir nicht mehr. Loeschen!
720 : : }
721 : :
722 : :
723 : 2 : SvxCSS1Parser::SvxCSS1Parser( SfxItemPool& rPool, const String& rBaseURL, sal_uInt16 nMinFixLineSp,
724 : : sal_uInt16 *pWhichIds, sal_uInt16 nWhichIds ) :
725 : : CSS1Parser(),
726 : : sBaseURL( rBaseURL ),
727 : : pSheetItemSet(0),
728 : : pItemSet(0),
729 : : pSearchEntry( 0 ),
730 : : nMinFixLineSpace( nMinFixLineSp ),
731 : : eDfltEnc( RTL_TEXTENCODING_DONTKNOW ),
732 : : nScriptFlags( CSS1_SCRIPT_ALL ),
733 [ + - ][ + - ]: 2 : bIgnoreFontFamily( sal_False )
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
734 : : {
735 : : // Item-Ids auch initialisieren
736 [ + - ]: 2 : aItemIds.nFont = rPool.GetTrueWhich( SID_ATTR_CHAR_FONT, sal_False );
737 [ + - ]: 2 : aItemIds.nFontCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONT, sal_False );
738 [ + - ]: 2 : aItemIds.nFontCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONT, sal_False );
739 [ + - ]: 2 : aItemIds.nPosture = rPool.GetTrueWhich( SID_ATTR_CHAR_POSTURE, sal_False );
740 [ + - ]: 2 : aItemIds.nPostureCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_POSTURE, sal_False );
741 [ + - ]: 2 : aItemIds.nPostureCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_POSTURE, sal_False );
742 [ + - ]: 2 : aItemIds.nWeight = rPool.GetTrueWhich( SID_ATTR_CHAR_WEIGHT, sal_False );
743 [ + - ]: 2 : aItemIds.nWeightCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_WEIGHT, sal_False );
744 [ + - ]: 2 : aItemIds.nWeightCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_WEIGHT, sal_False );
745 [ + - ]: 2 : aItemIds.nFontHeight = rPool.GetTrueWhich( SID_ATTR_CHAR_FONTHEIGHT, sal_False );
746 [ + - ]: 2 : aItemIds.nFontHeightCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_FONTHEIGHT, sal_False );
747 [ + - ]: 2 : aItemIds.nFontHeightCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_FONTHEIGHT, sal_False );
748 [ + - ]: 2 : aItemIds.nUnderline = rPool.GetTrueWhich( SID_ATTR_CHAR_UNDERLINE, sal_False );
749 [ + - ]: 2 : aItemIds.nOverline = rPool.GetTrueWhich( SID_ATTR_CHAR_OVERLINE, sal_False );
750 [ + - ]: 2 : aItemIds.nCrossedOut = rPool.GetTrueWhich( SID_ATTR_CHAR_STRIKEOUT, sal_False );
751 [ + - ]: 2 : aItemIds.nColor = rPool.GetTrueWhich( SID_ATTR_CHAR_COLOR, sal_False );
752 [ + - ]: 2 : aItemIds.nKerning = rPool.GetTrueWhich( SID_ATTR_CHAR_KERNING, sal_False );
753 [ + - ]: 2 : aItemIds.nCaseMap = rPool.GetTrueWhich( SID_ATTR_CHAR_CASEMAP, sal_False );
754 [ + - ]: 2 : aItemIds.nBlink = rPool.GetTrueWhich( SID_ATTR_FLASH, sal_False );
755 : :
756 [ + - ]: 2 : aItemIds.nLineSpacing = rPool.GetTrueWhich( SID_ATTR_PARA_LINESPACE, sal_False );
757 [ + - ]: 2 : aItemIds.nAdjust = rPool.GetTrueWhich( SID_ATTR_PARA_ADJUST, sal_False );
758 [ + - ]: 2 : aItemIds.nWidows = rPool.GetTrueWhich( SID_ATTR_PARA_WIDOWS, sal_False );
759 [ + - ]: 2 : aItemIds.nOrphans = rPool.GetTrueWhich( SID_ATTR_PARA_ORPHANS, sal_False );
760 [ + - ]: 2 : aItemIds.nFmtSplit = rPool.GetTrueWhich( SID_ATTR_PARA_SPLIT, sal_False );
761 : :
762 [ + - ]: 2 : aItemIds.nLRSpace = rPool.GetTrueWhich( SID_ATTR_LRSPACE, sal_False );
763 [ + - ]: 2 : aItemIds.nULSpace = rPool.GetTrueWhich( SID_ATTR_ULSPACE, sal_False );
764 [ + - ]: 2 : aItemIds.nBox = rPool.GetTrueWhich( SID_ATTR_BORDER_OUTER, sal_False );
765 [ + - ]: 2 : aItemIds.nBrush = rPool.GetTrueWhich( SID_ATTR_BRUSH, sal_False );
766 : :
767 [ + - ]: 2 : aItemIds.nLanguage = rPool.GetTrueWhich( SID_ATTR_CHAR_LANGUAGE, sal_False );
768 [ + - ]: 2 : aItemIds.nLanguageCJK = rPool.GetTrueWhich( SID_ATTR_CHAR_CJK_LANGUAGE, sal_False );
769 [ + - ]: 2 : aItemIds.nLanguageCTL = rPool.GetTrueWhich( SID_ATTR_CHAR_CTL_LANGUAGE, sal_False );
770 [ + - ]: 2 : aItemIds.nDirection = rPool.GetTrueWhich( SID_ATTR_FRAMEDIRECTION, sal_False );
771 : :
772 [ + - ]: 2 : aWhichMap.insert( aWhichMap.begin(), 0 );
773 : : SvParser::BuildWhichTbl( aWhichMap, (sal_uInt16 *)&aItemIds,
774 [ + - ]: 2 : sizeof(aItemIds) / sizeof(sal_uInt16) );
775 [ + - ][ + - ]: 2 : if( pWhichIds && nWhichIds )
776 [ + - ]: 2 : SvParser::BuildWhichTbl( aWhichMap, pWhichIds, nWhichIds );
777 : :
778 [ + - ][ + - ]: 2 : pSheetItemSet = new SfxItemSet( rPool, &aWhichMap[0] );
[ + - ]
779 [ + - ][ + - ]: 2 : pSheetPropInfo = new SvxCSS1PropertyInfo;
780 [ + - ][ + - ]: 2 : pSearchEntry = new SvxCSS1MapEntry( rPool, &aWhichMap[0] );
[ + - ]
781 : 2 : }
782 : :
783 [ + - ][ + - ]: 2 : SvxCSS1Parser::~SvxCSS1Parser()
[ + - ][ + - ]
[ + - ][ + - ]
784 : : {
785 [ + - ][ + - ]: 2 : delete pSheetItemSet;
786 [ + - ][ + - ]: 2 : delete pSheetPropInfo;
787 [ + - ][ + - ]: 2 : delete pSearchEntry;
788 [ - + ]: 2 : }
789 : :
790 : 0 : void SvxCSS1Parser::InsertId( const String& rId,
791 : : const SfxItemSet& rItemSet,
792 : : const SvxCSS1PropertyInfo& rProp )
793 : : {
794 : 0 : InsertMapEntry( rId, rItemSet, rProp, aIds );
795 : 0 : }
796 : :
797 : 0 : const SvxCSS1MapEntry* SvxCSS1Parser::GetId( const String& rId ) const
798 : : {
799 [ # # ]: 0 : CSS1Map::const_iterator itr = aIds.find(rId);
800 [ # # ][ # # ]: 0 : return itr == aIds.end() ? NULL : itr->second;
[ # # ][ # # ]
[ # # ][ # # ]
801 : : }
802 : :
803 : 0 : void SvxCSS1Parser::InsertClass( const String& rClass,
804 : : const SfxItemSet& rItemSet,
805 : : const SvxCSS1PropertyInfo& rProp )
806 : : {
807 : 0 : InsertMapEntry( rClass, rItemSet, rProp, aClasses );
808 : 0 : }
809 : :
810 : 0 : const SvxCSS1MapEntry* SvxCSS1Parser::GetClass( const String& rClass ) const
811 : : {
812 [ # # ]: 0 : CSS1Map::const_iterator itr = aClasses.find(rClass);
813 [ # # ][ # # ]: 0 : return itr == aClasses.end() ? NULL : itr->second;
[ # # ][ # # ]
[ # # ][ # # ]
814 : : }
815 : :
816 : 0 : void SvxCSS1Parser::InsertPage( const String& rPage,
817 : : sal_Bool bPseudo,
818 : : const SfxItemSet& rItemSet,
819 : : const SvxCSS1PropertyInfo& rProp )
820 : : {
821 [ # # ]: 0 : String aKey( rPage );
822 [ # # ]: 0 : if( bPseudo )
823 [ # # ]: 0 : aKey.Insert( ':', 0 );
824 [ # # ][ # # ]: 0 : InsertMapEntry( aKey, rItemSet, rProp, aPages );
825 : 0 : }
826 : :
827 : 0 : SvxCSS1MapEntry* SvxCSS1Parser::GetPage( const String& rPage, bool bPseudo )
828 : : {
829 [ # # ]: 0 : String aKey( rPage );
830 [ # # ]: 0 : if( bPseudo )
831 [ # # ]: 0 : aKey.Insert( ':', 0 );
832 : :
833 [ # # ]: 0 : CSS1Map::iterator itr = aPages.find(aKey);
834 [ # # ][ # # ]: 0 : return itr == aPages.end() ? NULL : itr->second;
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
835 : : }
836 : :
837 : 0 : void SvxCSS1Parser::InsertTag( const String& rTag,
838 : : const SfxItemSet& rItemSet,
839 : : const SvxCSS1PropertyInfo& rProp )
840 : : {
841 : 0 : InsertMapEntry( rTag, rItemSet, rProp, aTags );
842 : 0 : }
843 : :
844 : 14 : SvxCSS1MapEntry* SvxCSS1Parser::GetTag( const String& rTag )
845 : : {
846 [ + - ]: 14 : CSS1Map::iterator itr = aTags.find(rTag);
847 [ + - ][ + - ]: 14 : return itr == aTags.end() ? NULL : itr->second;
[ + - ][ # # ]
[ - + ][ # # ]
848 : : }
849 : :
850 : 0 : sal_Bool SvxCSS1Parser::ParseStyleSheet( const String& rIn )
851 : : {
852 : 0 : pItemSet = pSheetItemSet;
853 : 0 : pPropInfo = pSheetPropInfo;
854 : :
855 : 0 : sal_Bool bSuccess = CSS1Parser::ParseStyleSheet( rIn );
856 : :
857 [ # # ]: 0 : for (size_t i = 0; i < aSelectors.size(); ++i)
858 : : {
859 : 0 : StyleParsed( &aSelectors[i], *pSheetItemSet, *pSheetPropInfo );
860 : : }
861 : :
862 : : // und etwas aufrauemen
863 : 0 : aSelectors.clear();
864 : 0 : pSheetItemSet->ClearItem();
865 : 0 : pSheetPropInfo->Clear();
866 : :
867 : 0 : pItemSet = 0;
868 : 0 : pPropInfo = 0;
869 : :
870 : 0 : return bSuccess;
871 : : }
872 : :
873 : 0 : sal_Bool SvxCSS1Parser::ParseStyleOption( const String& rIn,
874 : : SfxItemSet& rItemSet,
875 : : SvxCSS1PropertyInfo& rPropInfo )
876 : : {
877 : 0 : pItemSet = &rItemSet;
878 : 0 : pPropInfo = &rPropInfo;
879 : :
880 : 0 : sal_Bool bSuccess = CSS1Parser::ParseStyleOption( rIn );
881 : 0 : rItemSet.ClearItem( aItemIds.nDirection );
882 : :
883 : 0 : pItemSet = 0;
884 : 0 : pPropInfo = 0;
885 : :
886 : 0 : return bSuccess;
887 : : }
888 : :
889 : :
890 : 0 : sal_Bool SvxCSS1Parser::GetEnum( const CSS1PropertyEnum *pPropTable,
891 : : const String &rValue, sal_uInt16& rEnum )
892 : : {
893 [ # # ]: 0 : String aValue( rValue );
894 [ # # ]: 0 : aValue.ToLowerAscii();
895 [ # # ]: 0 : while( pPropTable->pName )
896 : : {
897 [ # # ][ # # ]: 0 : if( !rValue.EqualsIgnoreCaseAscii( pPropTable->pName ) )
898 : 0 : pPropTable++;
899 : : else
900 : 0 : break;
901 : : }
902 : :
903 [ # # ]: 0 : if( pPropTable->pName )
904 : 0 : rEnum = pPropTable->nEnum;
905 : :
906 [ # # ]: 0 : return (pPropTable->pName != 0);
907 : : }
908 : :
909 : 0 : void SvxCSS1Parser::PixelToTwip( long &rWidth, long &rHeight )
910 : : {
911 [ # # ]: 0 : if( Application::GetDefaultDevice() )
912 : : {
913 : 0 : Size aTwipSz( rWidth, rHeight );
914 : : aTwipSz = Application::GetDefaultDevice()->PixelToLogic( aTwipSz,
915 [ # # ][ # # ]: 0 : MapMode(MAP_TWIP) );
[ # # ][ # # ]
916 : :
917 : 0 : rWidth = aTwipSz.Width();
918 : 0 : rHeight = aTwipSz.Height();
919 : : }
920 : 0 : }
921 : :
922 : 0 : sal_uInt32 SvxCSS1Parser::GetFontHeight( sal_uInt16 nSize ) const
923 : : {
924 : : sal_uInt16 nHeight;
925 : :
926 [ # # # # : 0 : switch( nSize )
# # # ]
927 : : {
928 : 0 : case 0: nHeight = 8*20; break;
929 : 0 : case 1: nHeight = 10*20; break;
930 : 0 : case 2: nHeight = 11*20; break;
931 : 0 : case 3: nHeight = 12*20; break;
932 : 0 : case 4: nHeight = 17*20; break;
933 : 0 : case 5: nHeight = 20*20; break;
934 : : case 6:
935 : 0 : default: nHeight = 32*20; break;
936 : : }
937 : :
938 : 0 : return nHeight;
939 : : }
940 : :
941 : 0 : const FontList *SvxCSS1Parser::GetFontList() const
942 : : {
943 : 0 : return 0;
944 : : }
945 : :
946 : 0 : void SvxCSS1Parser::InsertMapEntry( const String& rKey,
947 : : const SfxItemSet& rItemSet,
948 : : const SvxCSS1PropertyInfo& rProp,
949 : : CSS1Map& rMap )
950 : : {
951 [ # # ]: 0 : CSS1Map::iterator itr = rMap.find(rKey);
952 [ # # ][ # # ]: 0 : if (itr == rMap.end())
[ # # ]
953 : : {
954 [ # # ][ # # ]: 0 : std::auto_ptr<SvxCSS1MapEntry> p(new SvxCSS1MapEntry(rKey, rItemSet, rProp));
955 [ # # ][ # # ]: 0 : rMap.insert(rKey, p);
[ # # ]
956 : : }
957 : : else
958 : : {
959 [ # # ]: 0 : SvxCSS1MapEntry* p = itr->second;
960 : : MergeStyles( rItemSet, rProp,
961 [ # # ]: 0 : p->GetItemSet(), p->GetPropertyInfo(), sal_True );
962 : : }
963 : 0 : }
964 : :
965 : 0 : void SvxCSS1Parser::MergeStyles( const SfxItemSet& rSrcSet,
966 : : const SvxCSS1PropertyInfo& rSrcInfo,
967 : : SfxItemSet& rTargetSet,
968 : : SvxCSS1PropertyInfo& rTargetInfo,
969 : : sal_Bool bSmart )
970 : : {
971 [ # # ]: 0 : if( !bSmart )
972 : : {
973 : 0 : rTargetSet.Put( rSrcSet );
974 : : }
975 : : else
976 : : {
977 [ # # ][ # # ]: 0 : SvxLRSpaceItem aLRSpace( (const SvxLRSpaceItem&)rTargetSet.Get(aItemIds.nLRSpace) );
978 [ # # ][ # # ]: 0 : SvxULSpaceItem aULSpace( (const SvxULSpaceItem&)rTargetSet.Get(aItemIds.nULSpace) );
979 [ # # ][ # # ]: 0 : SvxBoxItem aBox( (const SvxBoxItem&)rTargetSet.Get(aItemIds.nBox) );
980 : :
981 [ # # ]: 0 : rTargetSet.Put( rSrcSet );
982 : :
983 [ # # ][ # # ]: 0 : if( rSrcInfo.bLeftMargin || rSrcInfo.bRightMargin ||
[ # # ]
984 : : rSrcInfo.bTextIndent )
985 : : {
986 : : const SvxLRSpaceItem& rNewLRSpace =
987 [ # # ]: 0 : (const SvxLRSpaceItem&)rSrcSet.Get( aItemIds.nLRSpace );
988 : :
989 [ # # ]: 0 : if( rSrcInfo.bLeftMargin )
990 : 0 : aLRSpace.SetLeft( rNewLRSpace.GetLeft() );
991 [ # # ]: 0 : if( rSrcInfo.bRightMargin )
992 : 0 : aLRSpace.SetRight( rNewLRSpace.GetRight() );
993 [ # # ]: 0 : if( rSrcInfo.bTextIndent )
994 [ # # ]: 0 : aLRSpace.SetTxtFirstLineOfst( rNewLRSpace.GetTxtFirstLineOfst() );
995 : :
996 [ # # ]: 0 : rTargetSet.Put( aLRSpace );
997 : : }
998 : :
999 [ # # ][ # # ]: 0 : if( rSrcInfo.bTopMargin || rSrcInfo.bBottomMargin )
1000 : : {
1001 : : const SvxULSpaceItem& rNewULSpace =
1002 [ # # ]: 0 : (const SvxULSpaceItem&)rSrcSet.Get( aItemIds.nULSpace );
1003 : :
1004 [ # # ]: 0 : if( rSrcInfo.bTopMargin )
1005 : 0 : aULSpace.SetUpper( rNewULSpace.GetUpper() );
1006 [ # # ]: 0 : if( rSrcInfo.bBottomMargin )
1007 : 0 : aULSpace.SetLower( rNewULSpace.GetLower() );
1008 : :
1009 [ # # ]: 0 : rTargetSet.Put( aULSpace );
1010 [ # # ][ # # ]: 0 : }
[ # # ]
1011 : : }
1012 : :
1013 : 0 : rTargetInfo.Merge( rSrcInfo );
1014 : 0 : }
1015 : :
1016 : 2 : void SvxCSS1Parser::SetDfltEncoding( rtl_TextEncoding eEnc )
1017 : : {
1018 : 2 : eDfltEnc = eEnc;
1019 : 2 : }
1020 : :
1021 : :
1022 : 0 : static void ParseCSS1_font_size( const CSS1Expression *pExpr,
1023 : : SfxItemSet &rItemSet,
1024 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1025 : : const SvxCSS1Parser& rParser )
1026 : : {
1027 : : OSL_ENSURE( pExpr, "no expression" );
1028 : :
1029 : 0 : sal_uLong nHeight = 0;
1030 : 0 : sal_uInt16 nPropHeight = 100;
1031 : :
1032 [ # # # # : 0 : switch( pExpr->GetType() )
# ]
1033 : : {
1034 : : case CSS1_LENGTH:
1035 : 0 : nHeight = pExpr->GetULength();
1036 : 0 : break;
1037 : : case CSS1_PIXLENGTH:
1038 : : {
1039 : 0 : long nPWidth = 0;
1040 : 0 : long nPHeight = (long)pExpr->GetNumber();
1041 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
1042 : 0 : nHeight = (sal_uLong)nPHeight;
1043 : : }
1044 : 0 : break;
1045 : : case CSS1_PERCENTAGE:
1046 : : // nur fuer Drop-Caps!
1047 : 0 : nPropHeight = (sal_uInt16)pExpr->GetNumber();
1048 : 0 : break;
1049 : : case CSS1_IDENT:
1050 : : {
1051 : : sal_uInt16 nSize;
1052 : :
1053 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aFontSizeTable, pExpr->GetString(),
1054 [ # # ]: 0 : nSize ) )
1055 : : {
1056 [ # # ]: 0 : nHeight = rParser.GetFontHeight( nSize );
1057 : : }
1058 : : }
1059 : 0 : break;
1060 : :
1061 : : default:
1062 : : ;
1063 : : }
1064 : :
1065 [ # # ][ # # ]: 0 : if( nHeight || nPropHeight!=100 )
1066 : : {
1067 : : SvxFontHeightItem aFontHeight( nHeight, nPropHeight,
1068 [ # # ]: 0 : aItemIds.nFontHeight );
1069 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1070 [ # # ]: 0 : rItemSet.Put( aFontHeight );
1071 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1072 : : {
1073 : 0 : aFontHeight.SetWhich( aItemIds.nFontHeightCJK );
1074 [ # # ]: 0 : rItemSet.Put( aFontHeight );
1075 : : }
1076 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1077 : : {
1078 : 0 : aFontHeight.SetWhich( aItemIds.nFontHeightCTL );
1079 [ # # ]: 0 : rItemSet.Put( aFontHeight );
1080 [ # # ]: 0 : }
1081 : : }
1082 : 0 : }
1083 : :
1084 : :
1085 : :
1086 : 0 : static void ParseCSS1_font_family( const CSS1Expression *pExpr,
1087 : : SfxItemSet &rItemSet,
1088 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1089 : : const SvxCSS1Parser& rParser )
1090 : : {
1091 : : OSL_ENSURE( pExpr, "no expression" );
1092 : :
1093 [ # # ][ # # ]: 0 : String aName, aStyleName, aDfltName;
[ # # ]
1094 : 0 : FontFamily eFamily = FAMILY_DONTKNOW;
1095 : 0 : FontPitch ePitch = PITCH_DONTKNOW;
1096 : 0 : rtl_TextEncoding eEnc = rParser.GetDfltEncoding();
1097 [ # # ]: 0 : const FontList *pFList = rParser.GetFontList();
1098 : 0 : sal_Bool bFirst = sal_True;
1099 : 0 : sal_Bool bFound = sal_False;
1100 [ # # ][ # # ]: 0 : while( pExpr && (bFirst || ','==pExpr->GetOp() || !pExpr->GetOp()) )
[ # # ][ # # ]
[ # # ]
1101 : : {
1102 : 0 : CSS1Token eType = pExpr->GetType();
1103 [ # # ][ # # ]: 0 : if( CSS1_IDENT==eType || CSS1_STRING==eType )
1104 : : {
1105 [ # # ]: 0 : String aIdent( pExpr->GetString() );
1106 : :
1107 [ # # ]: 0 : if( CSS1_IDENT==eType )
1108 : : {
1109 : : // Alle nachfolgenden id's sammeln und mit einem
1110 : : // Space getrennt hintendranhaengen
1111 : 0 : const CSS1Expression *pNext = pExpr->GetNext();
1112 [ # # ]: 0 : while( pNext && !pNext->GetOp() &&
[ # # # # ]
[ # # ]
1113 : 0 : CSS1_IDENT==pNext->GetType() )
1114 : : {
1115 [ # # ][ # # ]: 0 : (aIdent += ' ') += pNext->GetString();
1116 : 0 : pExpr = pNext;
1117 : 0 : pNext = pExpr->GetNext();
1118 : : }
1119 : : }
1120 [ # # ]: 0 : if( aIdent.Len() )
1121 : : {
1122 [ # # ][ # # ]: 0 : if( !bFound && pFList )
1123 : : {
1124 [ # # ]: 0 : sal_Handle hFont = pFList->GetFirstFontInfo( aIdent );
1125 [ # # ]: 0 : if( 0 != hFont )
1126 : : {
1127 [ # # ]: 0 : const FontInfo& rFInfo = pFList->GetFontInfo( hFont );
1128 [ # # ][ # # ]: 0 : if( RTL_TEXTENCODING_DONTKNOW != rFInfo.GetCharSet() )
1129 : : {
1130 : 0 : bFound = sal_True;
1131 [ # # ][ # # ]: 0 : if( RTL_TEXTENCODING_SYMBOL == rFInfo.GetCharSet() )
1132 : 0 : eEnc = RTL_TEXTENCODING_SYMBOL;
1133 : : }
1134 : : }
1135 : : }
1136 [ # # ]: 0 : if( !bFirst )
1137 [ # # ]: 0 : aName += ';';
1138 [ # # ]: 0 : aName += aIdent;
1139 [ # # ]: 0 : }
1140 : : }
1141 : :
1142 : 0 : pExpr = pExpr->GetNext();
1143 : 0 : bFirst = sal_False;
1144 : : }
1145 : :
1146 [ # # ][ # # ]: 0 : if( aName.Len() && !rParser.IsIgnoreFontFamily() )
[ # # ]
1147 : : {
1148 : : SvxFontItem aFont( eFamily, aName, aStyleName, ePitch,
1149 [ # # ]: 0 : eEnc, aItemIds.nFont );
1150 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1151 [ # # ]: 0 : rItemSet.Put( aFont );
1152 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1153 : : {
1154 : 0 : aFont.SetWhich( aItemIds.nFontCJK );
1155 [ # # ]: 0 : rItemSet.Put( aFont );
1156 : : }
1157 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1158 : : {
1159 : 0 : aFont.SetWhich( aItemIds.nFontCTL );
1160 [ # # ]: 0 : rItemSet.Put( aFont );
1161 [ # # ]: 0 : }
1162 [ # # ][ # # ]: 0 : }
[ # # ]
1163 : 0 : }
1164 : :
1165 : :
1166 : 0 : static void ParseCSS1_font_weight( const CSS1Expression *pExpr,
1167 : : SfxItemSet &rItemSet,
1168 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1169 : : const SvxCSS1Parser& rParser )
1170 : : {
1171 : : OSL_ENSURE( pExpr, "no expression" );
1172 : :
1173 [ # # # ]: 0 : switch( pExpr->GetType() )
1174 : : {
1175 : : case CSS1_IDENT:
1176 : : case CSS1_STRING: // MS-IE, was sonst
1177 : : {
1178 : : sal_uInt16 nWeight;
1179 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aFontWeightTable, pExpr->GetString(),
1180 [ # # ]: 0 : nWeight ) )
1181 : : {
1182 [ # # ]: 0 : SvxWeightItem aWeight( (FontWeight)nWeight, aItemIds.nWeight );
1183 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1184 [ # # ]: 0 : rItemSet.Put( aWeight );
1185 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1186 : : {
1187 : 0 : aWeight.SetWhich( aItemIds.nWeightCJK );
1188 [ # # ]: 0 : rItemSet.Put( aWeight );
1189 : : }
1190 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1191 : : {
1192 : 0 : aWeight.SetWhich( aItemIds.nWeightCTL );
1193 [ # # ]: 0 : rItemSet.Put( aWeight );
1194 [ # # ]: 0 : }
1195 : : }
1196 : : }
1197 : 0 : break;
1198 : : case CSS1_NUMBER:
1199 : : {
1200 : 0 : sal_uInt16 nWeight = (sal_uInt16)pExpr->GetNumber();
1201 : : SvxWeightItem aWeight( nWeight>400 ? WEIGHT_BOLD : WEIGHT_NORMAL,
1202 [ # # ][ # # ]: 0 : aItemIds.nWeight );
1203 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1204 [ # # ]: 0 : rItemSet.Put( aWeight );
1205 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1206 : : {
1207 : 0 : aWeight.SetWhich( aItemIds.nWeightCJK );
1208 [ # # ]: 0 : rItemSet.Put( aWeight );
1209 : : }
1210 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1211 : : {
1212 : 0 : aWeight.SetWhich( aItemIds.nWeightCTL );
1213 [ # # ]: 0 : rItemSet.Put( aWeight );
1214 [ # # ]: 0 : }
1215 : : }
1216 : 0 : break;
1217 : :
1218 : : default:
1219 : : ;
1220 : : }
1221 : 0 : }
1222 : :
1223 : :
1224 : 0 : static void ParseCSS1_font_style( const CSS1Expression *pExpr,
1225 : : SfxItemSet &rItemSet,
1226 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1227 : : const SvxCSS1Parser& rParser )
1228 : : {
1229 : : OSL_ENSURE( pExpr, "no expression" );
1230 : :
1231 : 0 : sal_Bool bPosture = sal_False;
1232 : 0 : sal_Bool bCaseMap = sal_False;
1233 : 0 : FontItalic eItalic = ITALIC_NONE;
1234 : 0 : SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
1235 : :
1236 : : // normal | italic || small-caps | oblique || small-caps | small-caps
1237 : : // (wobei nor noch normal | italic und oblique zulaessig sind
1238 : :
1239 : : // der Wert kann zwei Werte enthalten!
1240 [ # # ][ # # ]: 0 : for( sal_uInt16 i=0; pExpr && i<2; i++ )
[ # # ]
1241 : : {
1242 : : // Auch hier hinterlaesst MS-IEs Parser seine Spuren
1243 [ # # ]: 0 : if( (CSS1_IDENT==pExpr->GetType() || CSS1_STRING==pExpr->GetType()) &&
[ # # # # ]
[ # # ]
1244 : 0 : !pExpr->GetOp() )
1245 : : {
1246 : 0 : const String& rValue = pExpr->GetString();
1247 : : // erstmal pruefen, ob es ein Italic-Wert oder 'normal' ist
1248 : : sal_uInt16 nItalic;
1249 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aFontStyleTable, rValue, nItalic ) )
1250 : : {
1251 : 0 : eItalic = (FontItalic)nItalic;
1252 [ # # ][ # # ]: 0 : if( !bCaseMap && ITALIC_NONE==eItalic )
1253 : : {
1254 : : // fuer 'normal' muessen wir auch die case-map aussch.
1255 : 0 : eCaseMap = SVX_CASEMAP_NOT_MAPPED;
1256 : 0 : bCaseMap = sal_True;
1257 : : }
1258 : 0 : bPosture = sal_True;
1259 : : }
1260 [ # # ][ # # ]: 0 : else if( !bCaseMap &&
[ # # ]
1261 [ # # ]: 0 : rValue.EqualsIgnoreCaseAscii(sCSS1_PV_small_caps) )
1262 : : {
1263 : 0 : eCaseMap = SVX_CASEMAP_KAPITAELCHEN;
1264 : 0 : bCaseMap = sal_True;
1265 : : }
1266 : : }
1267 : :
1268 : : // den naechsten Ausdruck holen
1269 : 0 : pExpr = pExpr->GetNext();
1270 : : }
1271 : :
1272 [ # # ]: 0 : if( bPosture )
1273 : : {
1274 [ # # ]: 0 : SvxPostureItem aPosture( eItalic, aItemIds.nPosture );
1275 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1276 [ # # ]: 0 : rItemSet.Put( aPosture );
1277 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1278 : : {
1279 : 0 : aPosture.SetWhich( aItemIds.nPostureCJK );
1280 [ # # ]: 0 : rItemSet.Put( aPosture );
1281 : : }
1282 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1283 : : {
1284 : 0 : aPosture.SetWhich( aItemIds.nPostureCTL );
1285 [ # # ]: 0 : rItemSet.Put( aPosture );
1286 [ # # ]: 0 : }
1287 : : }
1288 : :
1289 [ # # ]: 0 : if( bCaseMap )
1290 [ # # ]: 0 : rItemSet.Put( SvxCaseMapItem( eCaseMap, aItemIds.nCaseMap ) );
1291 : 0 : }
1292 : :
1293 : :
1294 : 0 : static void ParseCSS1_font_variant( const CSS1Expression *pExpr,
1295 : : SfxItemSet &rItemSet,
1296 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1297 : : const SvxCSS1Parser& /*rParser*/ )
1298 : : {
1299 : : OSL_ENSURE( pExpr, "no expression" );
1300 : :
1301 : : // normal | small-caps
1302 : :
1303 [ # # ]: 0 : switch( pExpr->GetType() )
1304 : : {
1305 : : case CSS1_IDENT:
1306 : : {
1307 : : sal_uInt16 nCaseMap;
1308 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aFontVariantTable, pExpr->GetString(),
1309 [ # # ]: 0 : nCaseMap ) )
1310 : : {
1311 : : rItemSet.Put( SvxCaseMapItem( (SvxCaseMap)nCaseMap,
1312 [ # # ][ # # ]: 0 : aItemIds.nCaseMap ) );
[ # # ]
1313 : : }
1314 : : }
1315 : : default:
1316 : : ;
1317 : : }
1318 : 0 : }
1319 : :
1320 : 0 : static void ParseCSS1_text_transform( const CSS1Expression *pExpr,
1321 : : SfxItemSet &rItemSet,
1322 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1323 : : const SvxCSS1Parser& /*rParser*/ )
1324 : : {
1325 : : OSL_ENSURE( pExpr, "no expression" );
1326 : :
1327 : : // none | capitalize | uppercase | lowercase
1328 : :
1329 [ # # ]: 0 : switch( pExpr->GetType() )
1330 : : {
1331 : : case CSS1_IDENT:
1332 : : {
1333 : : sal_uInt16 nCaseMap;
1334 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aTextTransformTable, pExpr->GetString(),
1335 [ # # ]: 0 : nCaseMap ) )
1336 : : {
1337 : : rItemSet.Put( SvxCaseMapItem( (SvxCaseMap)nCaseMap,
1338 [ # # ][ # # ]: 0 : aItemIds.nCaseMap ) );
[ # # ]
1339 : : }
1340 : : }
1341 : : default:
1342 : : ;
1343 : : }
1344 : 0 : }
1345 : :
1346 : :
1347 : 0 : static void ParseCSS1_color( const CSS1Expression *pExpr,
1348 : : SfxItemSet &rItemSet,
1349 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1350 : : const SvxCSS1Parser& /*rParser*/ )
1351 : : {
1352 : : OSL_ENSURE( pExpr, "no expression" );
1353 : :
1354 [ # # ]: 0 : switch( pExpr->GetType() )
1355 : : {
1356 : : case CSS1_IDENT:
1357 : : case CSS1_RGB:
1358 : : case CSS1_HEXCOLOR:
1359 : : case CSS1_STRING: // Wegen MS-IE
1360 : : {
1361 : 0 : Color aColor;
1362 [ # # ][ # # ]: 0 : if( pExpr->GetColor( aColor ) )
1363 [ # # ][ # # ]: 0 : rItemSet.Put( SvxColorItem( aColor, aItemIds.nColor ) );
[ # # ]
1364 : : }
1365 : 0 : break;
1366 : : default:
1367 : : ;
1368 : : }
1369 : 0 : }
1370 : :
1371 : 0 : static void ParseCSS1_direction( const CSS1Expression *pExpr,
1372 : : SfxItemSet &rItemSet,
1373 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1374 : : const SvxCSS1Parser& /*rParser*/ )
1375 : : {
1376 : : OSL_ENSURE( pExpr, "no expression" );
1377 : :
1378 : : sal_uInt16 nDir;
1379 [ # # ]: 0 : switch( pExpr->GetType() )
1380 : : {
1381 : : case CSS1_IDENT:
1382 : : case CSS1_STRING:
1383 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aDirectionTable, pExpr->GetString(),
1384 [ # # ]: 0 : nDir ) )
1385 : : {
1386 : : rItemSet.Put( SvxFrameDirectionItem(
1387 : : static_cast < SvxFrameDirection >( nDir ),
1388 [ # # ][ # # ]: 0 : aItemIds.nDirection ) );
[ # # ]
1389 : : }
1390 : 0 : break;
1391 : : default:
1392 : : ;
1393 : : }
1394 : 0 : }
1395 : :
1396 : :
1397 : 0 : static void MergeHori( SvxGraphicPosition& ePos, SvxGraphicPosition eHori )
1398 : : {
1399 : : OSL_ENSURE( GPOS_LT==eHori || GPOS_MT==eHori || GPOS_RT==eHori,
1400 : : "vertical position not at the top" );
1401 : :
1402 [ # # # # ]: 0 : switch( ePos )
1403 : : {
1404 : : case GPOS_LT:
1405 : : case GPOS_MT:
1406 : : case GPOS_RT:
1407 : 0 : ePos = eHori;
1408 : 0 : break;
1409 : :
1410 : : case GPOS_LM:
1411 : : case GPOS_MM:
1412 : : case GPOS_RM:
1413 [ # # ][ # # ]: 0 : ePos = GPOS_LT==eHori ? GPOS_LM : (GPOS_MT==eHori ? GPOS_MM : GPOS_RM);
1414 : 0 : break;
1415 : :
1416 : : case GPOS_LB:
1417 : : case GPOS_MB:
1418 : : case GPOS_RB:
1419 [ # # ][ # # ]: 0 : ePos = GPOS_LT==eHori ? GPOS_LB : (GPOS_MT==eHori ? GPOS_MB : GPOS_RB);
1420 : 0 : break;
1421 : :
1422 : : default:
1423 : : ;
1424 : : }
1425 : 0 : }
1426 : :
1427 : 0 : static void MergeVert( SvxGraphicPosition& ePos, SvxGraphicPosition eVert )
1428 : : {
1429 : : OSL_ENSURE( GPOS_LT==eVert || GPOS_LM==eVert || GPOS_LB==eVert,
1430 : : "horizontal position not on the left side" );
1431 : :
1432 [ # # # # ]: 0 : switch( ePos )
1433 : : {
1434 : : case GPOS_LT:
1435 : : case GPOS_LM:
1436 : : case GPOS_LB:
1437 : 0 : ePos = eVert;
1438 : 0 : break;
1439 : :
1440 : : case GPOS_MT:
1441 : : case GPOS_MM:
1442 : : case GPOS_MB:
1443 [ # # ][ # # ]: 0 : ePos = GPOS_LT==eVert ? GPOS_MT : (GPOS_LM==eVert ? GPOS_MM : GPOS_MB);
1444 : 0 : break;
1445 : :
1446 : : case GPOS_RT:
1447 : : case GPOS_RM:
1448 : : case GPOS_RB:
1449 [ # # ][ # # ]: 0 : ePos = GPOS_LT==eVert ? GPOS_RT : (GPOS_LM==eVert ? GPOS_RM : GPOS_RB);
1450 : 0 : break;
1451 : :
1452 : : default:
1453 : : ;
1454 : : }
1455 : 0 : }
1456 : :
1457 : 0 : static void ParseCSS1_background( const CSS1Expression *pExpr,
1458 : : SfxItemSet &rItemSet,
1459 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1460 : : const SvxCSS1Parser& rParser )
1461 : : {
1462 : : OSL_ENSURE( pExpr, "no expression" );
1463 : :
1464 : 0 : Color aColor;
1465 [ # # ]: 0 : String aURL;
1466 : :
1467 : 0 : sal_Bool bColor = sal_False, bTransparent = sal_False;
1468 : 0 : SvxGraphicPosition eRepeat = GPOS_TILED;
1469 : 0 : SvxGraphicPosition ePos = GPOS_LT;
1470 : 0 : sal_Bool bHori = sal_False, bVert = sal_False;
1471 : :
1472 [ # # ][ # # ]: 0 : while( pExpr && !pExpr->GetOp() )
[ # # ]
1473 : : {
1474 [ # # # # : 0 : switch( pExpr->GetType() )
# # ]
1475 : : {
1476 : : case CSS1_URL:
1477 [ # # ]: 0 : pExpr->GetURL( aURL );
1478 : 0 : break;
1479 : :
1480 : : case CSS1_RGB:
1481 [ # # ]: 0 : bColor = pExpr->GetColor( aColor );
1482 : 0 : break;
1483 : :
1484 : : case CSS1_LENGTH:
1485 : : case CSS1_PIXLENGTH:
1486 : : {
1487 : : // da wir keine absolute Positionierung koennen,
1488 : : // unterscheiden wir nur zwischen 0 und !0. Deshalb
1489 : : // koennen Pixel auch wie alle anderen Einheiten behandelt
1490 : : // werden.
1491 : :
1492 : 0 : sal_uLong nLength = (sal_uLong)pExpr->GetNumber();
1493 [ # # ]: 0 : if( !bHori )
1494 : : {
1495 [ # # ]: 0 : ePos = nLength ? GPOS_MM : GPOS_LT;
1496 : 0 : bHori = sal_True;
1497 : : }
1498 [ # # ]: 0 : else if( !bVert )
1499 : : {
1500 [ # # ]: 0 : MergeVert( ePos, (nLength ? GPOS_LM : GPOS_LT) );
1501 : 0 : bVert = sal_True;
1502 : : }
1503 : : }
1504 : 0 : break;
1505 : :
1506 : : case CSS1_PERCENTAGE:
1507 : : {
1508 : : // die %-Angabe wird auf den enum abgebildet
1509 : :
1510 : 0 : sal_uInt16 nPerc = (sal_uInt16)pExpr->GetNumber();
1511 [ # # ]: 0 : if( !bHori )
1512 : : {
1513 : : ePos = nPerc < 25 ? GPOS_LT
1514 : : : (nPerc < 75 ? GPOS_MM
1515 [ # # ][ # # ]: 0 : : GPOS_RB);
1516 : : }
1517 [ # # ]: 0 : else if( !bVert )
1518 : : {
1519 : : SvxGraphicPosition eVert =
1520 : : nPerc < 25 ? GPOS_LT: (nPerc < 75 ? GPOS_LM
1521 [ # # ][ # # ]: 0 : : GPOS_LB);
1522 : 0 : MergeVert( ePos, eVert );
1523 : : }
1524 : : }
1525 : 0 : break;
1526 : :
1527 : : case CSS1_IDENT:
1528 : : case CSS1_HEXCOLOR:
1529 : : case CSS1_STRING: // Wegen MS-IE
1530 : : {
1531 : : sal_uInt16 nEnum;
1532 : 0 : const String &rValue = pExpr->GetString();
1533 [ # # ][ # # ]: 0 : if( rValue.EqualsIgnoreCaseAscii( sCSS1_PV_transparent ) )
1534 : : {
1535 : 0 : bTransparent = sal_True;
1536 : : }
1537 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aBGRepeatTable, rValue, nEnum ) )
1538 : : {
1539 : 0 : eRepeat = (SvxGraphicPosition)nEnum;
1540 : : }
1541 [ # # ][ # # ]: 0 : else if( SvxCSS1Parser::GetEnum( aBGHoriPosTable, rValue, nEnum ) )
1542 : : {
1543 : : // <position>, horizontal
1544 : 0 : MergeHori( ePos, (SvxGraphicPosition)nEnum );
1545 : : }
1546 [ # # ][ # # ]: 0 : else if( SvxCSS1Parser::GetEnum( aBGVertPosTable, rValue, nEnum ) )
1547 : : {
1548 : : // <position>, vertikal
1549 : 0 : MergeVert( ePos, (SvxGraphicPosition)nEnum );
1550 : : }
1551 [ # # ]: 0 : else if( !bColor )
1552 : : {
1553 : : // <color>
1554 [ # # ]: 0 : bColor = pExpr->GetColor( aColor );
1555 : : }
1556 : : // <scroll> kennen wir nicht
1557 : : }
1558 : 0 : break;
1559 : :
1560 : : default:
1561 : : ;
1562 : : }
1563 : :
1564 : 0 : pExpr = pExpr->GetNext();
1565 : : }
1566 : :
1567 : : // transparent schlaegt alles
1568 [ # # ]: 0 : if( bTransparent )
1569 : : {
1570 : 0 : bColor = sal_False;
1571 [ # # ]: 0 : aURL.Erase();
1572 : : }
1573 : :
1574 : : // repeat hat prio gegenueber einer Position
1575 [ # # ]: 0 : if( GPOS_NONE == eRepeat )
1576 : 0 : eRepeat = ePos;
1577 : :
1578 [ # # ][ # # ]: 0 : if( bTransparent || bColor || aURL.Len() )
[ # # ][ # # ]
1579 : : {
1580 [ # # ]: 0 : SvxBrushItem aBrushItem( aItemIds.nBrush );
1581 : :
1582 [ # # ]: 0 : if( bTransparent )
1583 : 0 : aBrushItem.SetColor( Color(COL_TRANSPARENT));
1584 [ # # ]: 0 : else if( bColor )
1585 : 0 : aBrushItem.SetColor( aColor );
1586 : :
1587 [ # # ]: 0 : if( aURL.Len() )
1588 : : {
1589 [ # # ][ # # ]: 0 : aBrushItem.SetGraphicLink( URIHelper::SmartRel2Abs( INetURLObject( rParser.GetBaseURL()), aURL, Link(), false ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1590 [ # # ]: 0 : aBrushItem.SetGraphicPos( eRepeat );
1591 : : }
1592 : :
1593 [ # # ][ # # ]: 0 : rItemSet.Put( aBrushItem );
1594 [ # # ]: 0 : }
1595 : 0 : }
1596 : :
1597 : 0 : static void ParseCSS1_background_color( const CSS1Expression *pExpr,
1598 : : SfxItemSet &rItemSet,
1599 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1600 : : const SvxCSS1Parser& /*rParser*/ )
1601 : : {
1602 : : OSL_ENSURE( pExpr, "no expression" );
1603 : :
1604 : 0 : Color aColor;
1605 : :
1606 : 0 : sal_Bool bColor = sal_False, bTransparent = sal_False;
1607 : :
1608 [ # # # ]: 0 : switch( pExpr->GetType() )
1609 : : {
1610 : : case CSS1_RGB:
1611 [ # # ]: 0 : bColor = pExpr->GetColor( aColor );
1612 : 0 : break;
1613 : : case CSS1_IDENT:
1614 : : case CSS1_HEXCOLOR:
1615 : : case CSS1_STRING: // Wegen MS-IE
1616 [ # # ][ # # ]: 0 : if( pExpr->GetString().EqualsIgnoreCaseAscii( sCSS1_PV_transparent ) )
1617 : : {
1618 : 0 : bTransparent = sal_True;
1619 : : }
1620 : : else
1621 : : {
1622 : : // <color>
1623 [ # # ]: 0 : bColor = pExpr->GetColor( aColor );
1624 : : }
1625 : 0 : break;
1626 : : default:
1627 : : ;
1628 : : }
1629 : :
1630 [ # # ][ # # ]: 0 : if( bTransparent || bColor )
1631 : : {
1632 [ # # ]: 0 : SvxBrushItem aBrushItem( aItemIds.nBrush );
1633 : :
1634 [ # # ]: 0 : if( bTransparent )
1635 : 0 : aBrushItem.SetColor( Color(COL_TRANSPARENT) );
1636 [ # # ]: 0 : else if( bColor )
1637 : 0 : aBrushItem.SetColor( aColor);
1638 : :
1639 [ # # ][ # # ]: 0 : rItemSet.Put( aBrushItem );
1640 : : }
1641 : 0 : }
1642 : :
1643 : :
1644 : 0 : static void ParseCSS1_line_height( const CSS1Expression *pExpr,
1645 : : SfxItemSet &rItemSet,
1646 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1647 : : const SvxCSS1Parser& rParser )
1648 : : {
1649 : : OSL_ENSURE( pExpr, "no expression" );
1650 : :
1651 : 0 : sal_uInt16 nHeight = 0;
1652 : 0 : sal_uInt8 nPropHeight = 0;
1653 : :
1654 [ # # # # : 0 : switch( pExpr->GetType() )
# ]
1655 : : {
1656 : : case CSS1_LENGTH:
1657 : 0 : nHeight = (sal_uInt16)pExpr->GetULength();
1658 : 0 : break;
1659 : : case CSS1_PIXLENGTH:
1660 : : {
1661 : 0 : long nPWidth = 0;
1662 : 0 : long nPHeight = (long)pExpr->GetNumber();
1663 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
1664 : 0 : nHeight = (sal_uInt16)nPHeight;
1665 : : }
1666 : 0 : break;
1667 : : case CSS1_PERCENTAGE:
1668 : : {
1669 : 0 : sal_uInt16 nPHeight = (sal_uInt16)pExpr->GetNumber();
1670 [ # # ]: 0 : nPropHeight = nPHeight <= 200 ? (sal_uInt8)nPHeight : 200;
1671 : : }
1672 : 0 : break;
1673 : : case CSS1_NUMBER:
1674 : : {
1675 : 0 : sal_uInt16 nPHeight = (sal_uInt16)(pExpr->GetNumber() * 100);
1676 [ # # ]: 0 : nPropHeight = nPHeight <= 200 ? (sal_uInt8)nPHeight : 200;
1677 : : }
1678 : 0 : break;
1679 : : default:
1680 : : ;
1681 : : }
1682 : :
1683 [ # # ]: 0 : if( nHeight )
1684 : : {
1685 [ # # ]: 0 : if( nHeight < rParser.GetMinFixLineSpace() )
1686 : 0 : nHeight = rParser.GetMinFixLineSpace();
1687 [ # # ]: 0 : SvxLineSpacingItem aLSItem( nHeight, aItemIds.nLineSpacing );
1688 : 0 : aLSItem.SetLineHeight( nHeight );
1689 : : // interpret <line-height> attribute as minimum line height
1690 : 0 : aLSItem.GetLineSpaceRule() = SVX_LINE_SPACE_MIN;
1691 : 0 : aLSItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
1692 [ # # ][ # # ]: 0 : rItemSet.Put( aLSItem );
1693 : : }
1694 [ # # ]: 0 : else if( nPropHeight )
1695 : : {
1696 [ # # ]: 0 : SvxLineSpacingItem aLSItem( nPropHeight, aItemIds.nLineSpacing );
1697 : 0 : aLSItem.GetLineSpaceRule() = SVX_LINE_SPACE_AUTO;
1698 [ # # ]: 0 : if( 100 == nPropHeight )
1699 : 0 : aLSItem.GetInterLineSpaceRule() = SVX_INTER_LINE_SPACE_OFF;
1700 : : else
1701 : 0 : aLSItem.SetPropLineSpace( nPropHeight );
1702 [ # # ][ # # ]: 0 : rItemSet.Put( aLSItem );
1703 : : }
1704 : :
1705 : 0 : }
1706 : :
1707 : :
1708 : 0 : static void ParseCSS1_font( const CSS1Expression *pExpr,
1709 : : SfxItemSet &rItemSet,
1710 : : SvxCSS1PropertyInfo& rPropInfo,
1711 : : const SvxCSS1Parser& rParser )
1712 : : {
1713 : : OSL_ENSURE( pExpr, "no expression" );
1714 : :
1715 : 0 : FontItalic eItalic = ITALIC_NONE;
1716 : 0 : SvxCaseMap eCaseMap = SVX_CASEMAP_NOT_MAPPED;
1717 : 0 : FontWeight eWeight = WEIGHT_NORMAL;
1718 : :
1719 : : // [ <font-style> || <font-variant> || <font-weight> ] ?
1720 [ # # ][ # # : 0 : while( pExpr && !pExpr->GetOp() &&
# # # # #
# ][ # # ]
1721 : 0 : (CSS1_IDENT==pExpr->GetType() ||
1722 : 0 : CSS1_STRING==pExpr->GetType() ||
1723 : 0 : CSS1_NUMBER==pExpr->GetType()) )
1724 : : {
1725 [ # # # # ]: 0 : if( CSS1_IDENT==pExpr->GetType() ||
[ # # ]
1726 : 0 : CSS1_STRING==pExpr->GetType() )
1727 : : {
1728 : 0 : const String& rValue = pExpr->GetString();
1729 : :
1730 : : sal_uInt16 nEnum;
1731 : :
1732 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aFontStyleTable, rValue, nEnum ) )
1733 : : {
1734 : 0 : eItalic = (FontItalic)nEnum;
1735 : : }
1736 [ # # ][ # # ]: 0 : else if( SvxCSS1Parser::GetEnum( aFontVariantTable, rValue, nEnum ) )
1737 : : {
1738 : 0 : eCaseMap = (SvxCaseMap)nEnum;
1739 : : }
1740 [ # # ][ # # ]: 0 : else if( SvxCSS1Parser::GetEnum( aFontWeightTable, rValue, nEnum ) )
1741 : : {
1742 : 0 : eWeight = (FontWeight)nEnum;
1743 : : }
1744 : : }
1745 : : else
1746 : : {
1747 : 0 : eWeight = (sal_uInt16)pExpr->GetNumber() > 400 ? WEIGHT_BOLD
1748 [ # # ]: 0 : : WEIGHT_NORMAL;
1749 : : }
1750 : :
1751 : 0 : pExpr = pExpr->GetNext();
1752 : : }
1753 : :
1754 [ # # ][ # # ]: 0 : if( !pExpr || pExpr->GetOp() )
[ # # ]
1755 : : return;
1756 : :
1757 : : // Da "font" alle Werte zurecksetzt, fuer die nichts angegeben ist,
1758 : : // tun wir das hier.
1759 [ # # ]: 0 : SvxPostureItem aPosture( eItalic, aItemIds.nPosture );
1760 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1761 [ # # ]: 0 : rItemSet.Put( aPosture );
1762 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1763 : : {
1764 : 0 : aPosture.SetWhich( aItemIds.nPostureCJK );
1765 [ # # ]: 0 : rItemSet.Put( aPosture );
1766 : : }
1767 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1768 : : {
1769 : 0 : aPosture.SetWhich( aItemIds.nPostureCTL );
1770 [ # # ]: 0 : rItemSet.Put( aPosture );
1771 : : }
1772 : :
1773 [ # # ][ # # ]: 0 : rItemSet.Put( SvxCaseMapItem( eCaseMap, aItemIds.nCaseMap ) );
[ # # ]
1774 : :
1775 [ # # ]: 0 : SvxWeightItem aWeight( eWeight, aItemIds.nWeight );
1776 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
1777 [ # # ]: 0 : rItemSet.Put( aWeight );
1778 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
1779 : : {
1780 : 0 : aWeight.SetWhich( aItemIds.nWeightCJK );
1781 [ # # ]: 0 : rItemSet.Put( aWeight );
1782 : : }
1783 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
1784 : : {
1785 : 0 : aWeight.SetWhich( aItemIds.nWeightCTL );
1786 [ # # ]: 0 : rItemSet.Put( aWeight );
1787 : : }
1788 : :
1789 : :
1790 : : // font-size
1791 : 0 : CSS1Expression aExpr( pExpr->GetType(), pExpr->GetString(),
1792 [ # # ]: 0 : pExpr->GetNumber() );
1793 [ # # ]: 0 : ParseCSS1_font_size( &aExpr, rItemSet, rPropInfo, rParser );
1794 : 0 : pExpr = pExpr->GetNext();
1795 : :
1796 [ # # ]: 0 : if( !pExpr )
1797 : : return;
1798 : :
1799 : : // [ '/' line-height ]?
1800 [ # # ]: 0 : if( '/' == pExpr->GetOp() )
1801 : : {
1802 : : // '/' line-height
1803 [ # # ]: 0 : aExpr.Set( pExpr->GetType(), pExpr->GetString(), pExpr->GetNumber() );
1804 [ # # ]: 0 : ParseCSS1_line_height( &aExpr, rItemSet, rPropInfo, rParser );
1805 : :
1806 : 0 : pExpr = pExpr->GetNext();
1807 : : }
1808 : :
1809 [ # # ][ # # ]: 0 : if( !pExpr || pExpr->GetOp() )
[ # # ]
1810 : : return;
1811 : :
1812 : : // font-family
1813 [ # # ][ # # ]: 0 : ParseCSS1_font_family( pExpr, rItemSet, rPropInfo, rParser );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
1814 : : }
1815 : :
1816 : :
1817 : 0 : static void ParseCSS1_letter_spacing( const CSS1Expression *pExpr,
1818 : : SfxItemSet &rItemSet,
1819 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1820 : : const SvxCSS1Parser& /*rParser*/ )
1821 : : {
1822 : : OSL_ENSURE( pExpr, "no expression" );
1823 : :
1824 [ # # # # : 0 : switch( pExpr->GetType() )
# ]
1825 : : {
1826 : : case CSS1_LENGTH:
1827 : 0 : rItemSet.Put( SvxKerningItem( (short)pExpr->GetSLength(),
1828 [ # # ]: 0 : aItemIds.nKerning ) );
1829 : 0 : break;
1830 : :
1831 : : case CSS1_PIXLENGTH:
1832 : : {
1833 : 0 : long nPWidth = (long)pExpr->GetNumber();
1834 : 0 : long nPHeight = 0;
1835 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
1836 [ # # ][ # # ]: 0 : rItemSet.Put( SvxKerningItem( (short)nPWidth, aItemIds.nKerning ) );
[ # # ]
1837 : : }
1838 : 0 : break;
1839 : :
1840 : : case CSS1_NUMBER:
1841 [ # # ]: 0 : if( pExpr->GetNumber() == 0 )
1842 : : {
1843 : : // eigentlich unnoetig, aber wir sind ja tollerant
1844 [ # # ]: 0 : rItemSet.Put( SvxKerningItem( (short)0, aItemIds.nKerning ) );
1845 : : }
1846 : 0 : break;
1847 : :
1848 : : case CSS1_IDENT:
1849 : : case CSS1_STRING: // Vorschtshalber auch MS-IE
1850 [ # # ]: 0 : if( pExpr->GetString().EqualsIgnoreCaseAscii(sCSS1_PV_normal) )
1851 : : {
1852 [ # # ]: 0 : rItemSet.Put( SvxKerningItem( (short)0, aItemIds.nKerning ) );
1853 : : }
1854 : 0 : break;
1855 : : default:
1856 : : ;
1857 : : }
1858 : 0 : }
1859 : :
1860 : :
1861 : 0 : static void ParseCSS1_text_decoration( const CSS1Expression *pExpr,
1862 : : SfxItemSet &rItemSet,
1863 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1864 : : const SvxCSS1Parser& /*rParser*/ )
1865 : : {
1866 : : OSL_ENSURE( pExpr, "no expression" );
1867 : :
1868 : 0 : sal_Bool bUnderline = sal_False;
1869 : 0 : sal_Bool bOverline = sal_False;
1870 : 0 : sal_Bool bCrossedOut = sal_False;
1871 : 0 : sal_Bool bBlink = sal_False;
1872 : 0 : sal_Bool bBlinkOn = sal_False;
1873 : 0 : FontUnderline eUnderline = UNDERLINE_NONE;
1874 : 0 : FontUnderline eOverline = UNDERLINE_NONE;
1875 : 0 : FontStrikeout eCrossedOut = STRIKEOUT_NONE;
1876 : :
1877 : : // der Wert kann zwei Werte enthalten! Und MS-IE auch Strings
1878 [ # # ][ # # : 0 : while( pExpr && (pExpr->GetType() == CSS1_IDENT ||
# # # # ]
[ # # ]
1879 : 0 : pExpr->GetType() == CSS1_STRING) && !pExpr->GetOp() )
1880 : : {
1881 [ # # ]: 0 : String aValue = pExpr->GetString();
1882 [ # # ]: 0 : aValue.ToLowerAscii();
1883 : 0 : sal_Bool bKnown = sal_False;
1884 : :
1885 [ # # # # : 0 : switch( aValue.GetChar( 0 ) )
# # ]
1886 : : {
1887 : : case 'n':
1888 [ # # ][ # # ]: 0 : if( aValue.EqualsAscii( sCSS1_PV_none ) )
1889 : : {
1890 : 0 : bUnderline = sal_True;
1891 : 0 : eUnderline = UNDERLINE_NONE;
1892 : :
1893 : 0 : bOverline = sal_True;
1894 : 0 : eOverline = UNDERLINE_NONE;
1895 : :
1896 : 0 : bCrossedOut = sal_True;
1897 : 0 : eCrossedOut = STRIKEOUT_NONE;
1898 : :
1899 : 0 : bBlink = sal_True;
1900 : 0 : bBlinkOn = sal_False;
1901 : :
1902 : 0 : bKnown = sal_True;
1903 : : }
1904 : 0 : break;
1905 : :
1906 : : case 'u':
1907 [ # # ][ # # ]: 0 : if( aValue.EqualsAscii( sCSS1_PV_underline ) )
1908 : : {
1909 : 0 : bUnderline = sal_True;
1910 : 0 : eUnderline = UNDERLINE_SINGLE;
1911 : :
1912 : 0 : bKnown = sal_True;
1913 : : }
1914 : 0 : break;
1915 : :
1916 : : case 'o':
1917 [ # # ][ # # ]: 0 : if( aValue.EqualsAscii( sCSS1_PV_overline ) )
1918 : : {
1919 : 0 : bOverline = sal_True;
1920 : 0 : eOverline = UNDERLINE_SINGLE;
1921 : :
1922 : 0 : bKnown = sal_True;
1923 : : }
1924 : 0 : break;
1925 : :
1926 : : case 'l':
1927 [ # # ][ # # ]: 0 : if( aValue.EqualsAscii( sCSS1_PV_line_through ) )
1928 : : {
1929 : 0 : bCrossedOut = sal_True;
1930 : 0 : eCrossedOut = STRIKEOUT_SINGLE;
1931 : :
1932 : 0 : bKnown = sal_True;
1933 : : }
1934 : 0 : break;
1935 : :
1936 : : case 'b':
1937 [ # # ][ # # ]: 0 : if( aValue.EqualsAscii( sCSS1_PV_blink ) )
1938 : : {
1939 : 0 : bBlink = sal_True;
1940 : 0 : bBlinkOn = sal_True;
1941 : :
1942 : 0 : bKnown = sal_True;
1943 : : }
1944 : 0 : break;
1945 : : }
1946 : :
1947 [ # # ]: 0 : if( !bKnown )
1948 : : {
1949 : 0 : bUnderline = sal_True;
1950 : 0 : eUnderline = UNDERLINE_SINGLE;
1951 : : }
1952 : :
1953 : 0 : pExpr = pExpr->GetNext();
1954 [ # # ]: 0 : }
1955 : :
1956 [ # # ]: 0 : if( bUnderline )
1957 [ # # ]: 0 : rItemSet.Put( SvxUnderlineItem( eUnderline, aItemIds.nUnderline ) );
1958 : :
1959 [ # # ]: 0 : if( bOverline )
1960 [ # # ]: 0 : rItemSet.Put( SvxOverlineItem( eOverline, aItemIds.nOverline ) );
1961 : :
1962 [ # # ]: 0 : if( bCrossedOut )
1963 [ # # ]: 0 : rItemSet.Put( SvxCrossedOutItem( eCrossedOut, aItemIds.nCrossedOut ) );
1964 : :
1965 [ # # ]: 0 : if( bBlink )
1966 [ # # ]: 0 : rItemSet.Put( SvxBlinkItem( bBlinkOn, aItemIds.nBlink ) );
1967 : 0 : }
1968 : :
1969 : :
1970 : 0 : static void ParseCSS1_text_align( const CSS1Expression *pExpr,
1971 : : SfxItemSet &rItemSet,
1972 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
1973 : : const SvxCSS1Parser& /*rParser*/ )
1974 : : {
1975 : : OSL_ENSURE( pExpr, "no expression" );
1976 : :
1977 [ # # # # ]: 0 : if( CSS1_IDENT==pExpr->GetType() ||
[ # # ]
1978 : 0 : CSS1_STRING==pExpr->GetType() ) // MS-IE, mal wieder
1979 : : {
1980 : : sal_uInt16 nAdjust;
1981 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aTextAlignTable, pExpr->GetString(),
1982 [ # # ]: 0 : nAdjust ) )
1983 : : {
1984 : : rItemSet.Put( SvxAdjustItem( (SvxAdjust)nAdjust,
1985 [ # # ][ # # ]: 0 : aItemIds.nAdjust ) );
[ # # ]
1986 : : }
1987 : : }
1988 : 0 : }
1989 : :
1990 : :
1991 : 0 : static void ParseCSS1_text_indent( const CSS1Expression *pExpr,
1992 : : SfxItemSet &rItemSet,
1993 : : SvxCSS1PropertyInfo& rPropInfo,
1994 : : const SvxCSS1Parser& /*rParser*/ )
1995 : : {
1996 : : OSL_ENSURE( pExpr, "no expression" );
1997 : :
1998 : 0 : short nIndent = 0;
1999 : 0 : sal_Bool bSet = sal_False;
2000 [ # # # # ]: 0 : switch( pExpr->GetType() )
2001 : : {
2002 : : case CSS1_LENGTH:
2003 : 0 : nIndent = (short)pExpr->GetSLength();
2004 : 0 : bSet = sal_True;
2005 : 0 : break;
2006 : : case CSS1_PIXLENGTH:
2007 : : {
2008 : 0 : long nPWidth = (long)pExpr->GetNumber();
2009 : 0 : long nPHeight = 0;
2010 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2011 : 0 : nIndent = (short)nPWidth;
2012 : 0 : bSet = sal_True;
2013 : : }
2014 : 0 : break;
2015 : : case CSS1_PERCENTAGE:
2016 : : // koennen wir nicht
2017 : 0 : break;
2018 : : default:
2019 : : ;
2020 : : }
2021 : :
2022 [ # # ]: 0 : if( bSet )
2023 : : {
2024 : : const SfxPoolItem* pItem;
2025 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, sal_False,
2026 [ # # ]: 0 : &pItem ) )
2027 : : {
2028 [ # # ]: 0 : SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
2029 [ # # ]: 0 : aLRItem.SetTxtFirstLineOfst( nIndent );
2030 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2031 : : }
2032 : : else
2033 : : {
2034 [ # # ]: 0 : SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
2035 [ # # ]: 0 : aLRItem.SetTxtFirstLineOfst( nIndent );
2036 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2037 : : }
2038 : 0 : rPropInfo.bTextIndent = sal_True;
2039 : : }
2040 : 0 : }
2041 : :
2042 : :
2043 : 0 : static void ParseCSS1_margin_left( const CSS1Expression *pExpr,
2044 : : SfxItemSet &rItemSet,
2045 : : SvxCSS1PropertyInfo& rPropInfo,
2046 : : const SvxCSS1Parser& /*rParser*/ )
2047 : : {
2048 : : OSL_ENSURE( pExpr, "no expression" );
2049 : :
2050 : 0 : long nLeft = 0;
2051 : 0 : sal_Bool bSet = sal_False;
2052 [ # # # # ]: 0 : switch( pExpr->GetType() )
2053 : : {
2054 : : case CSS1_LENGTH:
2055 : : {
2056 : 0 : nLeft = pExpr->GetSLength();
2057 : 0 : bSet = sal_True;
2058 : : }
2059 : 0 : break;
2060 : : case CSS1_PIXLENGTH:
2061 : : {
2062 : 0 : nLeft = (long)pExpr->GetNumber();
2063 : 0 : long nPHeight = 0;
2064 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nLeft, nPHeight );
2065 : 0 : bSet = sal_True;
2066 : : }
2067 : 0 : break;
2068 : : case CSS1_PERCENTAGE:
2069 : : // koennen wir nicht
2070 : 0 : break;
2071 : : default:
2072 : : ;
2073 : : }
2074 : :
2075 [ # # ]: 0 : if( bSet )
2076 : : {
2077 : 0 : rPropInfo.nLeftMargin = nLeft;
2078 [ # # ]: 0 : if( nLeft < 0 )
2079 : 0 : nLeft = 0;
2080 : : const SfxPoolItem* pItem;
2081 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, sal_False,
2082 [ # # ]: 0 : &pItem ) )
2083 : : {
2084 [ # # ]: 0 : SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
2085 [ # # ]: 0 : aLRItem.SetTxtLeft( (sal_uInt16)nLeft );
2086 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2087 : : }
2088 : : else
2089 : : {
2090 [ # # ]: 0 : SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
2091 [ # # ]: 0 : aLRItem.SetTxtLeft( (sal_uInt16)nLeft );
2092 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2093 : : }
2094 : 0 : rPropInfo.bLeftMargin = sal_True;
2095 : : }
2096 : 0 : }
2097 : :
2098 : :
2099 : 0 : static void ParseCSS1_margin_right( const CSS1Expression *pExpr,
2100 : : SfxItemSet &rItemSet,
2101 : : SvxCSS1PropertyInfo& rPropInfo,
2102 : : const SvxCSS1Parser& /*rParser*/ )
2103 : : {
2104 : : OSL_ENSURE( pExpr, "no expression" );
2105 : :
2106 : 0 : long nRight = 0;
2107 : 0 : sal_Bool bSet = sal_False;
2108 [ # # # # ]: 0 : switch( pExpr->GetType() )
2109 : : {
2110 : : case CSS1_LENGTH:
2111 : : {
2112 : 0 : nRight = pExpr->GetSLength();
2113 : 0 : bSet = sal_True;
2114 : : }
2115 : 0 : break;
2116 : : case CSS1_PIXLENGTH:
2117 : : {
2118 : 0 : nRight = (long)pExpr->GetNumber();
2119 : 0 : long nPHeight = 0;
2120 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nRight, nPHeight );
2121 : 0 : bSet = sal_True;
2122 : : }
2123 : 0 : break;
2124 : : case CSS1_PERCENTAGE:
2125 : : // koennen wir nicht
2126 : 0 : break;
2127 : : default:
2128 : : ;
2129 : : }
2130 : :
2131 [ # # ]: 0 : if( bSet )
2132 : : {
2133 : 0 : rPropInfo.nRightMargin = nRight;
2134 [ # # ]: 0 : if( nRight < 0 )
2135 : 0 : nRight = 0;
2136 : : const SfxPoolItem* pItem;
2137 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, sal_False,
2138 [ # # ]: 0 : &pItem ) )
2139 : : {
2140 [ # # ]: 0 : SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
2141 : 0 : aLRItem.SetRight( (sal_uInt16)nRight );
2142 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2143 : : }
2144 : : else
2145 : : {
2146 [ # # ]: 0 : SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
2147 : 0 : aLRItem.SetRight( (sal_uInt16)nRight );
2148 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2149 : : }
2150 : 0 : rPropInfo.bRightMargin = sal_True;
2151 : : }
2152 : 0 : }
2153 : :
2154 : :
2155 : 0 : static void ParseCSS1_margin_top( const CSS1Expression *pExpr,
2156 : : SfxItemSet &rItemSet,
2157 : : SvxCSS1PropertyInfo& rPropInfo,
2158 : : const SvxCSS1Parser& /*rParser*/ )
2159 : : {
2160 : : OSL_ENSURE( pExpr, "no expression" );
2161 : :
2162 : 0 : sal_uInt16 nUpper = 0;
2163 : 0 : sal_Bool bSet = sal_False;
2164 [ # # # # ]: 0 : switch( pExpr->GetType() )
2165 : : {
2166 : : case CSS1_LENGTH:
2167 : : {
2168 : 0 : long nTmp = pExpr->GetSLength();
2169 [ # # ]: 0 : if( nTmp < 0 )
2170 : 0 : nTmp = 0;
2171 : 0 : nUpper = (sal_uInt16)nTmp;
2172 : 0 : bSet = sal_True;
2173 : : }
2174 : 0 : break;
2175 : : case CSS1_PIXLENGTH:
2176 : : {
2177 : 0 : long nPWidth = 0;
2178 : 0 : long nPHeight = (long)pExpr->GetNumber();
2179 [ # # ]: 0 : if( nPHeight < 0 )
2180 : 0 : nPHeight = 0;
2181 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2182 : 0 : nUpper = (sal_uInt16)nPHeight;
2183 : 0 : bSet = sal_True;
2184 : : }
2185 : 0 : break;
2186 : : case CSS1_PERCENTAGE:
2187 : : // koennen wir nicht
2188 : 0 : break;
2189 : : default:
2190 : : ;
2191 : : }
2192 : :
2193 [ # # ]: 0 : if( bSet )
2194 : : {
2195 : : const SfxPoolItem* pItem;
2196 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, sal_False,
2197 [ # # ]: 0 : &pItem ) )
2198 : : {
2199 [ # # ]: 0 : SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
2200 : 0 : aULItem.SetUpper( nUpper );
2201 [ # # ][ # # ]: 0 : rItemSet.Put( aULItem );
2202 : : }
2203 : : else
2204 : : {
2205 [ # # ]: 0 : SvxULSpaceItem aULItem( aItemIds.nULSpace );
2206 : 0 : aULItem.SetUpper( nUpper );
2207 [ # # ][ # # ]: 0 : rItemSet.Put( aULItem );
2208 : : }
2209 : 0 : rPropInfo.bTopMargin = sal_True;
2210 : : }
2211 : 0 : }
2212 : :
2213 : :
2214 : 0 : static void ParseCSS1_margin_bottom( const CSS1Expression *pExpr,
2215 : : SfxItemSet &rItemSet,
2216 : : SvxCSS1PropertyInfo& rPropInfo,
2217 : : const SvxCSS1Parser& /*rParser*/ )
2218 : : {
2219 : : OSL_ENSURE( pExpr, "no expression" );
2220 : :
2221 : 0 : sal_uInt16 nLower = 0;
2222 : 0 : sal_Bool bSet = sal_False;
2223 [ # # # # ]: 0 : switch( pExpr->GetType() )
2224 : : {
2225 : : case CSS1_LENGTH:
2226 : : {
2227 : 0 : long nTmp = pExpr->GetSLength();
2228 [ # # ]: 0 : if( nTmp < 0 )
2229 : 0 : nTmp = 0;
2230 : 0 : nLower = (sal_uInt16)nTmp;
2231 : 0 : bSet = sal_True;
2232 : : }
2233 : 0 : break;
2234 : : case CSS1_PIXLENGTH:
2235 : : {
2236 : 0 : long nPWidth = 0;
2237 : 0 : long nPHeight = (long)pExpr->GetNumber();
2238 [ # # ]: 0 : if( nPHeight < 0 )
2239 : 0 : nPHeight = 0;
2240 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2241 : 0 : nLower = (sal_uInt16)nPHeight;
2242 : 0 : bSet = sal_True;
2243 : : }
2244 : 0 : break;
2245 : : case CSS1_PERCENTAGE:
2246 : : // koennen wir nicht
2247 : 0 : break;
2248 : : default:
2249 : : ;
2250 : : }
2251 : :
2252 [ # # ]: 0 : if( bSet )
2253 : : {
2254 : : const SfxPoolItem* pItem;
2255 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, sal_False,
2256 [ # # ]: 0 : &pItem ) )
2257 : : {
2258 [ # # ]: 0 : SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
2259 : 0 : aULItem.SetLower( nLower );
2260 [ # # ][ # # ]: 0 : rItemSet.Put( aULItem );
2261 : : }
2262 : : else
2263 : : {
2264 [ # # ]: 0 : SvxULSpaceItem aULItem( aItemIds.nULSpace );
2265 : 0 : aULItem.SetLower( nLower );
2266 [ # # ][ # # ]: 0 : rItemSet.Put( aULItem );
2267 : : }
2268 : 0 : rPropInfo.bBottomMargin = sal_True;
2269 : : }
2270 : 0 : }
2271 : :
2272 : :
2273 : 0 : static void ParseCSS1_margin( const CSS1Expression *pExpr,
2274 : : SfxItemSet &rItemSet,
2275 : : SvxCSS1PropertyInfo& rPropInfo,
2276 : : const SvxCSS1Parser& /*rParser*/ )
2277 : : {
2278 : : OSL_ENSURE( pExpr, "no expression" );
2279 : :
2280 : 0 : long nMargins[4] = { 0, 0, 0, 0 };
2281 : 0 : sal_Bool bSetMargins[4] = { sal_False, sal_False, sal_False, sal_False };
2282 : :
2283 [ # # ][ # # ]: 0 : for( sal_uInt16 i=0; pExpr && i<4 && !pExpr->GetOp(); i++ )
[ # # ][ # # ]
2284 : : {
2285 : 0 : sal_Bool bSetThis = sal_False;
2286 : 0 : long nMargin = 0;
2287 : :
2288 [ # # # # ]: 0 : switch( pExpr->GetType() )
2289 : : {
2290 : : case CSS1_LENGTH:
2291 : : {
2292 : 0 : nMargin = pExpr->GetSLength();
2293 : 0 : bSetThis = sal_True;
2294 : : }
2295 : 0 : break;
2296 : : case CSS1_PIXLENGTH:
2297 : : {
2298 : 0 : long nPWidth = 0;
2299 : 0 : nMargin = (long)pExpr->GetNumber();
2300 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nMargin );
2301 : 0 : bSetThis = sal_True;
2302 : : }
2303 : 0 : break;
2304 : : case CSS1_PERCENTAGE:
2305 : : // koennen wir nicht
2306 : 0 : break;
2307 : : default:
2308 : : ;
2309 : : }
2310 : :
2311 [ # # ]: 0 : if( bSetThis )
2312 : : {
2313 : : // 0 = top
2314 : : // 1 = right
2315 : : // 2 = bottom
2316 : : // 3 = left
2317 [ # # # # : 0 : switch( i )
# ]
2318 : : {
2319 : : case 0:
2320 : 0 : nMargins[0] = nMargins[1] =nMargins[2] = nMargins[3] = nMargin;
2321 : 0 : bSetMargins[0] = bSetMargins[1] =
2322 : 0 : bSetMargins[2] = bSetMargins[3] = sal_True;
2323 : 0 : break;
2324 : : case 1:
2325 : 0 : nMargins[1] = nMargins[3] = nMargin; // right + left
2326 : 0 : bSetMargins[1] = bSetMargins[3] = sal_True;
2327 : 0 : break;
2328 : : case 2:
2329 : 0 : nMargins[2] = nMargin; // bottom
2330 : 0 : bSetMargins[2] = sal_True;
2331 : 0 : break;
2332 : : case 3:
2333 : 0 : nMargins[3] = nMargin; // left
2334 : 0 : bSetMargins[3] = sal_True;
2335 : 0 : break;
2336 : : }
2337 : : }
2338 : 0 : pExpr = pExpr->GetNext();
2339 : : }
2340 : :
2341 [ # # ][ # # ]: 0 : if( bSetMargins[3] || bSetMargins[1] )
2342 : : {
2343 [ # # ]: 0 : if( bSetMargins[3] )
2344 : : {
2345 : 0 : rPropInfo.bLeftMargin = sal_True;
2346 : 0 : rPropInfo.nLeftMargin = nMargins[3];
2347 [ # # ]: 0 : if( nMargins[3] < 0 )
2348 : 0 : nMargins[3] = 0;
2349 : : }
2350 [ # # ]: 0 : if( bSetMargins[1] )
2351 : : {
2352 : 0 : rPropInfo.bRightMargin = sal_True;
2353 : 0 : rPropInfo.nRightMargin = nMargins[1];
2354 [ # # ]: 0 : if( nMargins[1] < 0 )
2355 : 0 : nMargins[1] = 0;
2356 : : }
2357 : :
2358 : : const SfxPoolItem* pItem;
2359 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nLRSpace, sal_False,
2360 [ # # ]: 0 : &pItem ) )
2361 : : {
2362 [ # # ]: 0 : SvxLRSpaceItem aLRItem( *((const SvxLRSpaceItem*)pItem) );
2363 [ # # ]: 0 : if( bSetMargins[3] )
2364 : 0 : aLRItem.SetLeft( (sal_uInt16)nMargins[3] );
2365 [ # # ]: 0 : if( bSetMargins[1] )
2366 : 0 : aLRItem.SetRight( (sal_uInt16)nMargins[1] );
2367 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2368 : : }
2369 : : else
2370 : : {
2371 [ # # ]: 0 : SvxLRSpaceItem aLRItem( aItemIds.nLRSpace );
2372 [ # # ]: 0 : if( bSetMargins[3] )
2373 : 0 : aLRItem.SetLeft( (sal_uInt16)nMargins[3] );
2374 [ # # ]: 0 : if( bSetMargins[1] )
2375 : 0 : aLRItem.SetRight( (sal_uInt16)nMargins[1] );
2376 [ # # ][ # # ]: 0 : rItemSet.Put( aLRItem );
2377 : : }
2378 : : }
2379 : :
2380 [ # # ][ # # ]: 0 : if( bSetMargins[0] || bSetMargins[2] )
2381 : : {
2382 [ # # ]: 0 : if( nMargins[0] < 0 )
2383 : 0 : nMargins[0] = 0;
2384 [ # # ]: 0 : if( nMargins[2] < 0 )
2385 : 0 : nMargins[2] = 0;
2386 : :
2387 : : const SfxPoolItem* pItem;
2388 [ # # ]: 0 : if( SFX_ITEM_SET == rItemSet.GetItemState( aItemIds.nULSpace, sal_False,
2389 [ # # ]: 0 : &pItem ) )
2390 : : {
2391 [ # # ]: 0 : SvxULSpaceItem aULItem( *((const SvxULSpaceItem*)pItem) );
2392 [ # # ]: 0 : if( bSetMargins[0] )
2393 : 0 : aULItem.SetUpper( (sal_uInt16)nMargins[0] );
2394 [ # # ]: 0 : if( bSetMargins[2] )
2395 : 0 : aULItem.SetLower( (sal_uInt16)nMargins[2] );
2396 [ # # ][ # # ]: 0 : rItemSet.Put( aULItem );
2397 : : }
2398 : : else
2399 : : {
2400 [ # # ]: 0 : SvxULSpaceItem aULItem( aItemIds.nULSpace );
2401 [ # # ]: 0 : if( bSetMargins[0] )
2402 : 0 : aULItem.SetUpper( (sal_uInt16)nMargins[0] );
2403 [ # # ]: 0 : if( bSetMargins[2] )
2404 : 0 : aULItem.SetLower( (sal_uInt16)nMargins[2] );
2405 [ # # ][ # # ]: 0 : rItemSet.Put( aULItem );
2406 : : }
2407 : :
2408 : 0 : rPropInfo.bTopMargin |= bSetMargins[0];
2409 : 0 : rPropInfo.bBottomMargin |= bSetMargins[2];
2410 : : }
2411 : 0 : }
2412 : :
2413 : :
2414 : 0 : static sal_Bool ParseCSS1_padding_xxx( const CSS1Expression *pExpr,
2415 : : SfxItemSet & /*rItemSet*/,
2416 : : SvxCSS1PropertyInfo& rPropInfo,
2417 : : const SvxCSS1Parser& /*rParser*/,
2418 : : sal_uInt16 nWhichLine )
2419 : : {
2420 : : OSL_ENSURE( pExpr, "no expression" );
2421 : :
2422 : 0 : sal_Bool bSet = sal_False;
2423 : 0 : sal_uInt16 nDist = 0;
2424 : :
2425 [ # # # # ]: 0 : switch( pExpr->GetType() )
2426 : : {
2427 : : case CSS1_LENGTH:
2428 : : {
2429 : 0 : long nTmp = pExpr->GetSLength();
2430 [ # # ]: 0 : if( nTmp < 0 )
2431 : 0 : nTmp = 0;
2432 [ # # ]: 0 : else if( nTmp > USHRT_MAX-1 )
2433 : 0 : nTmp = USHRT_MAX-1;
2434 : 0 : nDist = (sal_uInt16)nTmp;
2435 : 0 : bSet = sal_True;
2436 : : }
2437 : 0 : break;
2438 : : case CSS1_PIXLENGTH:
2439 : : {
2440 : 0 : long nPWidth = (long)pExpr->GetNumber();
2441 : 0 : long nPHeight = 0;
2442 [ # # ]: 0 : if( nPWidth < 0 )
2443 : 0 : nPWidth = 0;
2444 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2445 [ # # ]: 0 : if( nPWidth > USHRT_MAX-1 )
2446 : 0 : nPWidth = USHRT_MAX-1;
2447 : 0 : nDist = (sal_uInt16)nPWidth;
2448 : 0 : bSet = sal_True;
2449 : : }
2450 : 0 : break;
2451 : : case CSS1_PERCENTAGE:
2452 : : // koennen wir nicht
2453 : 0 : break;
2454 : : default:
2455 : : ;
2456 : : }
2457 : :
2458 [ # # ]: 0 : if( bSet )
2459 : : {
2460 [ # # # # : 0 : switch( nWhichLine )
# ]
2461 : : {
2462 : 0 : case BOX_LINE_TOP: rPropInfo.nTopBorderDistance = nDist; break;
2463 : 0 : case BOX_LINE_BOTTOM: rPropInfo.nBottomBorderDistance = nDist;break;
2464 : 0 : case BOX_LINE_LEFT: rPropInfo.nLeftBorderDistance = nDist; break;
2465 : 0 : case BOX_LINE_RIGHT: rPropInfo.nRightBorderDistance = nDist; break;
2466 : : }
2467 : : }
2468 : :
2469 : 0 : return bSet;
2470 : : }
2471 : :
2472 : :
2473 : 0 : static void ParseCSS1_padding_top( const CSS1Expression *pExpr,
2474 : : SfxItemSet &rItemSet,
2475 : : SvxCSS1PropertyInfo& rPropInfo,
2476 : : const SvxCSS1Parser& rParser )
2477 : : {
2478 : 0 : ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP );
2479 : 0 : }
2480 : :
2481 : 0 : static void ParseCSS1_padding_bottom( const CSS1Expression *pExpr,
2482 : : SfxItemSet &rItemSet,
2483 : : SvxCSS1PropertyInfo& rPropInfo,
2484 : : const SvxCSS1Parser& rParser )
2485 : : {
2486 : : ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
2487 : 0 : BOX_LINE_BOTTOM );
2488 : 0 : }
2489 : :
2490 : 0 : static void ParseCSS1_padding_left( const CSS1Expression *pExpr,
2491 : : SfxItemSet &rItemSet,
2492 : : SvxCSS1PropertyInfo& rPropInfo,
2493 : : const SvxCSS1Parser& rParser )
2494 : : {
2495 : 0 : ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT );
2496 : 0 : }
2497 : :
2498 : 0 : static void ParseCSS1_padding_right( const CSS1Expression *pExpr,
2499 : : SfxItemSet &rItemSet,
2500 : : SvxCSS1PropertyInfo& rPropInfo,
2501 : : const SvxCSS1Parser& rParser )
2502 : : {
2503 : : ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
2504 : 0 : BOX_LINE_RIGHT );
2505 : 0 : }
2506 : :
2507 : 0 : static void ParseCSS1_padding( const CSS1Expression *pExpr,
2508 : : SfxItemSet &rItemSet,
2509 : : SvxCSS1PropertyInfo& rPropInfo,
2510 : : const SvxCSS1Parser& rParser )
2511 : : {
2512 : 0 : sal_uInt16 n=0;
2513 [ # # ][ # # ]: 0 : while( n<4 && pExpr && !pExpr->GetOp() )
[ # # ][ # # ]
2514 : : {
2515 [ # # ][ # # ]: 0 : sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
2516 [ # # ]: 0 : if( ParseCSS1_padding_xxx( pExpr, rItemSet, rPropInfo, rParser,
2517 : 0 : nLine ) )
2518 : : {
2519 [ # # ]: 0 : if( n==0 )
2520 : : {
2521 : 0 : rPropInfo.nTopBorderDistance = rPropInfo.nBottomBorderDistance;
2522 : 0 : rPropInfo.nLeftBorderDistance = rPropInfo.nTopBorderDistance;
2523 : : }
2524 [ # # ]: 0 : if( n <= 1 )
2525 : 0 : rPropInfo.nRightBorderDistance = rPropInfo.nLeftBorderDistance;
2526 : : }
2527 : :
2528 : 0 : pExpr = pExpr->GetNext();
2529 : 0 : n++;
2530 : : }
2531 : 0 : }
2532 : :
2533 : :
2534 : 0 : static void ParseCSS1_border_xxx( const CSS1Expression *pExpr,
2535 : : SfxItemSet & /*rItemSet*/,
2536 : : SvxCSS1PropertyInfo& rPropInfo,
2537 : : const SvxCSS1Parser& /*rParser*/,
2538 : : sal_uInt16 nWhichLine, sal_Bool bAll )
2539 : : {
2540 : : OSL_ENSURE( pExpr, "no expression" );
2541 : :
2542 : 0 : sal_uInt16 nWidth = USHRT_MAX; // die Linien-Dicke
2543 : 0 : sal_uInt16 nNWidth = 1; // benannte Linien-Dicke (und default)
2544 : 0 : CSS1BorderStyle eStyle = CSS1_BS_NONE; // Linien-Style
2545 : 0 : Color aColor;
2546 : 0 : sal_Bool bColor = sal_False;
2547 : :
2548 [ # # ][ # # ]: 0 : while( pExpr && !pExpr->GetOp() )
[ # # ]
2549 : : {
2550 [ # # # # : 0 : switch( pExpr->GetType() )
# ]
2551 : : {
2552 : : case CSS1_RGB:
2553 : : case CSS1_HEXCOLOR:
2554 [ # # ][ # # ]: 0 : if( pExpr->GetColor( aColor ) )
2555 : 0 : bColor = sal_True;
2556 : 0 : break;
2557 : :
2558 : : case CSS1_IDENT:
2559 : : {
2560 : 0 : const String& rValue = pExpr->GetString();
2561 : : sal_uInt16 nValue;
2562 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aBorderWidthTable, rValue, nValue ) )
2563 : : {
2564 : 0 : nNWidth = nValue;
2565 : : }
2566 [ # # ][ # # ]: 0 : else if( SvxCSS1Parser::GetEnum( aBorderStyleTable, rValue, nValue ) )
2567 : : {
2568 : 0 : eStyle = (CSS1BorderStyle)nValue;
2569 : : }
2570 [ # # ][ # # ]: 0 : else if( pExpr->GetColor( aColor ) )
2571 : : {
2572 : 0 : bColor = sal_True;
2573 : : }
2574 : : }
2575 : 0 : break;
2576 : :
2577 : : case CSS1_LENGTH:
2578 : 0 : nWidth = (sal_uInt16)pExpr->GetULength();
2579 : 0 : break;
2580 : :
2581 : : case CSS1_PIXLENGTH:
2582 : : {
2583 : : sal_Bool bHori = nWhichLine == BOX_LINE_TOP ||
2584 [ # # ][ # # ]: 0 : nWhichLine == BOX_LINE_BOTTOM;
2585 : : // Ein Pixel wird zur Haarlinie (ist huebscher)
2586 : 0 : long nWidthL = (long)pExpr->GetNumber();
2587 [ # # ]: 0 : if( nWidthL > 1 )
2588 : : {
2589 [ # # ]: 0 : long nPWidth = bHori ? 0 : nWidthL;
2590 [ # # ]: 0 : long nPHeight = bHori ? nWidthL : 0;
2591 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2592 [ # # ]: 0 : nWidth = (sal_uInt16)(bHori ? nPHeight : nPWidth);
2593 : : }
2594 : : else
2595 : 0 : nWidth = 1;
2596 : : }
2597 : 0 : break;
2598 : :
2599 : : default:
2600 : : ;
2601 : : }
2602 : :
2603 : 0 : pExpr = pExpr->GetNext();
2604 : : }
2605 : :
2606 [ # # ]: 0 : for( sal_uInt16 i=0; i<4; i++ )
2607 : : {
2608 : 0 : sal_uInt16 nLine = 0;
2609 [ # # # # : 0 : switch( i )
# ]
2610 : : {
2611 : 0 : case 0: nLine = BOX_LINE_TOP; break;
2612 : 0 : case 1: nLine = BOX_LINE_BOTTOM; break;
2613 : 0 : case 2: nLine = BOX_LINE_LEFT; break;
2614 : 0 : case 3: nLine = BOX_LINE_RIGHT; break;
2615 : : }
2616 : :
2617 [ # # ][ # # ]: 0 : if( bAll || nLine == nWhichLine )
2618 : : {
2619 [ # # ]: 0 : SvxCSS1BorderInfo *pInfo = rPropInfo.GetBorderInfo( nLine );
2620 : 0 : pInfo->eStyle = eStyle;
2621 : 0 : pInfo->nAbsWidth = nWidth;
2622 : 0 : pInfo->nNamedWidth = nNWidth;
2623 [ # # ]: 0 : if( bColor )
2624 : 0 : pInfo->aColor = aColor;
2625 : : }
2626 : : }
2627 : 0 : }
2628 : :
2629 : 0 : static void ParseCSS1_border_xxx_width( const CSS1Expression *pExpr,
2630 : : SfxItemSet & /*rItemSet*/,
2631 : : SvxCSS1PropertyInfo& rPropInfo,
2632 : : const SvxCSS1Parser& /*rParser*/,
2633 : : sal_uInt16 nWhichLine )
2634 : : {
2635 : : OSL_ENSURE( pExpr, "no expression" );
2636 : :
2637 : 0 : sal_uInt16 nWidth = USHRT_MAX; // die Linien-Dicke
2638 : 0 : sal_uInt16 nNWidth = 1; // benannte Linien-Dicke (und default)
2639 : :
2640 [ # # # # ]: 0 : switch( pExpr->GetType() )
2641 : : {
2642 : : case CSS1_IDENT:
2643 : : {
2644 : : sal_uInt16 nValue;
2645 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aBorderWidthTable, pExpr->GetString(), nValue ) )
2646 : : {
2647 : 0 : nNWidth = nValue;
2648 : : }
2649 : : }
2650 : 0 : break;
2651 : :
2652 : : case CSS1_LENGTH:
2653 : 0 : nWidth = (sal_uInt16)pExpr->GetULength();
2654 : 0 : break;
2655 : :
2656 : : case CSS1_PIXLENGTH:
2657 : : {
2658 : : sal_Bool bHori = nWhichLine == BOX_LINE_TOP ||
2659 [ # # ][ # # ]: 0 : nWhichLine == BOX_LINE_BOTTOM;
2660 : 0 : long nWidthL = (long)pExpr->GetNumber();
2661 [ # # ]: 0 : long nPWidth = bHori ? 0 : nWidthL;
2662 [ # # ]: 0 : long nPHeight = bHori ? nWidthL : 0;
2663 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2664 [ # # ]: 0 : nWidth = (sal_uInt16)(bHori ? nPHeight : nPWidth);
2665 : : }
2666 : 0 : break;
2667 : :
2668 : : default:
2669 : : ;
2670 : : }
2671 : :
2672 : 0 : SvxCSS1BorderInfo *pInfo = rPropInfo.GetBorderInfo( nWhichLine );
2673 : 0 : pInfo->nAbsWidth = nWidth;
2674 : 0 : pInfo->nNamedWidth = nNWidth;
2675 : 0 : }
2676 : :
2677 : :
2678 : 0 : static void ParseCSS1_border_top_width( const CSS1Expression *pExpr,
2679 : : SfxItemSet &rItemSet,
2680 : : SvxCSS1PropertyInfo& rPropInfo,
2681 : : const SvxCSS1Parser& rParser )
2682 : : {
2683 : 0 : ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP );
2684 : 0 : }
2685 : :
2686 : 0 : static void ParseCSS1_border_right_width( const CSS1Expression *pExpr,
2687 : : SfxItemSet &rItemSet,
2688 : : SvxCSS1PropertyInfo& rPropInfo,
2689 : : const SvxCSS1Parser& rParser )
2690 : : {
2691 : 0 : ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_RIGHT );
2692 : 0 : }
2693 : :
2694 : 0 : static void ParseCSS1_border_bottom_width( const CSS1Expression *pExpr,
2695 : : SfxItemSet &rItemSet,
2696 : : SvxCSS1PropertyInfo& rPropInfo,
2697 : : const SvxCSS1Parser& rParser )
2698 : : {
2699 : 0 : ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_BOTTOM );
2700 : 0 : }
2701 : :
2702 : 0 : static void ParseCSS1_border_left_width( const CSS1Expression *pExpr,
2703 : : SfxItemSet &rItemSet,
2704 : : SvxCSS1PropertyInfo& rPropInfo,
2705 : : const SvxCSS1Parser& rParser )
2706 : : {
2707 : 0 : ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT );
2708 : 0 : }
2709 : :
2710 : 0 : static void ParseCSS1_border_width( const CSS1Expression *pExpr,
2711 : : SfxItemSet &rItemSet,
2712 : : SvxCSS1PropertyInfo& rPropInfo,
2713 : : const SvxCSS1Parser& rParser )
2714 : : {
2715 : 0 : sal_uInt16 n=0;
2716 [ # # ][ # # ]: 0 : while( n<4 && pExpr && !pExpr->GetOp() )
[ # # ][ # # ]
2717 : : {
2718 [ # # ][ # # ]: 0 : sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
2719 : 0 : ParseCSS1_border_xxx_width( pExpr, rItemSet, rPropInfo, rParser, nLine );
2720 : 0 : rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_WIDTH );
2721 : :
2722 : 0 : pExpr = pExpr->GetNext();
2723 : 0 : n++;
2724 : : }
2725 : 0 : }
2726 : :
2727 : 0 : static void ParseCSS1_border_color( const CSS1Expression *pExpr,
2728 : : SfxItemSet & /*rItemSet*/,
2729 : : SvxCSS1PropertyInfo& rPropInfo,
2730 : : const SvxCSS1Parser& /*rParser*/ )
2731 : : {
2732 : 0 : sal_uInt16 n=0;
2733 [ # # ][ # # ]: 0 : while( n<4 && pExpr && !pExpr->GetOp() )
[ # # ][ # # ]
2734 : : {
2735 [ # # ][ # # ]: 0 : sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
2736 : 0 : Color aColor;
2737 [ # # ]: 0 : switch( pExpr->GetType() )
2738 : : {
2739 : : case CSS1_RGB:
2740 : : case CSS1_HEXCOLOR:
2741 : : case CSS1_IDENT:
2742 [ # # ][ # # ]: 0 : if( pExpr->GetColor( aColor ) )
2743 [ # # ]: 0 : rPropInfo.GetBorderInfo( nLine )->aColor = aColor;
2744 : 0 : break;
2745 : : default:
2746 : : ;
2747 : : }
2748 [ # # ]: 0 : rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_COLOR );
2749 : :
2750 : 0 : pExpr = pExpr->GetNext();
2751 : 0 : n++;
2752 : : }
2753 : 0 : }
2754 : :
2755 : 0 : static void ParseCSS1_border_style( const CSS1Expression *pExpr,
2756 : : SfxItemSet & /*rItemSet*/,
2757 : : SvxCSS1PropertyInfo& rPropInfo,
2758 : : const SvxCSS1Parser& /*rParser*/ )
2759 : : {
2760 : 0 : sal_uInt16 n=0;
2761 [ # # ][ # # ]: 0 : while( n<4 && pExpr && !pExpr->GetOp() )
[ # # ][ # # ]
2762 : : {
2763 [ # # ][ # # ]: 0 : sal_uInt16 nLine = n==0 || n==2 ? BOX_LINE_BOTTOM : BOX_LINE_LEFT;
2764 : : sal_uInt16 nValue;
2765 [ # # ][ # # ]: 0 : if( CSS1_IDENT==pExpr->GetType() &&
[ # # ]
2766 : 0 : SvxCSS1Parser::GetEnum( aBorderStyleTable, pExpr->GetString(),
2767 [ # # ]: 0 : nValue ) )
2768 : : {
2769 [ # # ]: 0 : rPropInfo.GetBorderInfo( nLine )->eStyle = (CSS1BorderStyle)nValue;
2770 : : }
2771 [ # # ]: 0 : rPropInfo.CopyBorderInfo( n, SVX_CSS1_BORDERINFO_STYLE );
2772 : :
2773 : 0 : pExpr = pExpr->GetNext();
2774 : 0 : n++;
2775 : : }
2776 : 0 : }
2777 : :
2778 : :
2779 : 0 : static void ParseCSS1_border_top( const CSS1Expression *pExpr,
2780 : : SfxItemSet &rItemSet,
2781 : : SvxCSS1PropertyInfo& rPropInfo,
2782 : : const SvxCSS1Parser& rParser )
2783 : : {
2784 : 0 : ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_TOP, sal_False );
2785 : 0 : }
2786 : :
2787 : 0 : static void ParseCSS1_border_right( const CSS1Expression *pExpr,
2788 : : SfxItemSet &rItemSet,
2789 : : SvxCSS1PropertyInfo& rPropInfo,
2790 : : const SvxCSS1Parser& rParser )
2791 : : {
2792 : 0 : ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_RIGHT, sal_False );
2793 : 0 : }
2794 : :
2795 : 0 : static void ParseCSS1_border_bottom( const CSS1Expression *pExpr,
2796 : : SfxItemSet &rItemSet,
2797 : : SvxCSS1PropertyInfo& rPropInfo,
2798 : : const SvxCSS1Parser& rParser )
2799 : : {
2800 : 0 : ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_BOTTOM, sal_False );
2801 : 0 : }
2802 : :
2803 : 0 : static void ParseCSS1_border_left( const CSS1Expression *pExpr,
2804 : : SfxItemSet &rItemSet,
2805 : : SvxCSS1PropertyInfo& rPropInfo,
2806 : : const SvxCSS1Parser& rParser )
2807 : : {
2808 : 0 : ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, BOX_LINE_LEFT, sal_False );
2809 : 0 : }
2810 : :
2811 : 0 : static void ParseCSS1_border( const CSS1Expression *pExpr,
2812 : : SfxItemSet &rItemSet,
2813 : : SvxCSS1PropertyInfo& rPropInfo,
2814 : : const SvxCSS1Parser& rParser )
2815 : : {
2816 : 0 : ParseCSS1_border_xxx( pExpr, rItemSet, rPropInfo, rParser, 0, sal_True );
2817 : 0 : }
2818 : :
2819 : :
2820 : 0 : static void ParseCSS1_float( const CSS1Expression *pExpr,
2821 : : SfxItemSet & /*rItemSet*/,
2822 : : SvxCSS1PropertyInfo& rPropInfo,
2823 : : const SvxCSS1Parser& /*rParser*/ )
2824 : : {
2825 : : OSL_ENSURE( pExpr, "no expression" );
2826 : :
2827 [ # # ]: 0 : if( CSS1_IDENT==pExpr->GetType() )
2828 : : {
2829 : : sal_uInt16 nFloat;
2830 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aFloatTable, pExpr->GetString(), nFloat ) )
2831 : 0 : rPropInfo.eFloat = (SvxAdjust)nFloat;
2832 : : }
2833 : 0 : }
2834 : :
2835 : :
2836 : :
2837 : 0 : static void ParseCSS1_position( const CSS1Expression *pExpr,
2838 : : SfxItemSet & /*rItemSet*/,
2839 : : SvxCSS1PropertyInfo& rPropInfo,
2840 : : const SvxCSS1Parser& /*rParser*/ )
2841 : : {
2842 : : OSL_ENSURE( pExpr, "no expression" );
2843 : :
2844 [ # # ]: 0 : if( CSS1_IDENT==pExpr->GetType() )
2845 : : {
2846 : : sal_uInt16 nPos;
2847 [ # # ][ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aPositionTable, pExpr->GetString(), nPos ) )
2848 : 0 : rPropInfo.ePosition = (SvxCSS1Position)nPos;
2849 : : }
2850 : 0 : }
2851 : :
2852 : :
2853 : 0 : static void ParseCSS1_length( const CSS1Expression *pExpr,
2854 : : long& rLength,
2855 : : SvxCSS1LengthType& rLengthType,
2856 : : sal_Bool bHori )
2857 : : {
2858 [ # # # # : 0 : switch( pExpr->GetType() )
# ]
2859 : : {
2860 : : case CSS1_IDENT:
2861 [ # # ]: 0 : if( pExpr->GetString().EqualsIgnoreCaseAscii( sCSS1_PV_auto ) )
2862 : : {
2863 : 0 : rLength = 0;
2864 : 0 : rLengthType = SVX_CSS1_LTYPE_AUTO;
2865 : : }
2866 : 0 : break;
2867 : :
2868 : : case CSS1_LENGTH:
2869 : 0 : rLength = pExpr->GetSLength();
2870 : 0 : rLengthType = SVX_CSS1_LTYPE_TWIP;
2871 : 0 : break;
2872 : :
2873 : : case CSS1_PIXLENGTH:
2874 : : case CSS1_NUMBER: // wegen Netscape und IE
2875 : : {
2876 : 0 : long nWidthL = (long)pExpr->GetNumber();
2877 [ # # ]: 0 : long nPWidth = bHori ? 0 : nWidthL;
2878 [ # # ]: 0 : long nPHeight = bHori ? nWidthL : 0;
2879 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2880 [ # # ]: 0 : rLength = (bHori ? nPHeight : nPWidth);
2881 : 0 : rLengthType = SVX_CSS1_LTYPE_TWIP;
2882 : : }
2883 : 0 : break;
2884 : :
2885 : : case CSS1_PERCENTAGE:
2886 : 0 : rLength = (long)pExpr->GetNumber();
2887 [ # # ]: 0 : if( rLength > 100 )
2888 : 0 : rLength = 100;
2889 : 0 : rLengthType = SVX_CSS1_LTYPE_PERCENTAGE;
2890 : 0 : break;
2891 : :
2892 : : default:
2893 : : ;
2894 : : }
2895 : 0 : }
2896 : :
2897 : :
2898 : 0 : static void ParseCSS1_width( const CSS1Expression *pExpr,
2899 : : SfxItemSet & /*rItemSet*/,
2900 : : SvxCSS1PropertyInfo& rPropInfo,
2901 : : const SvxCSS1Parser& /*rParser*/ )
2902 : : {
2903 : 0 : ParseCSS1_length( pExpr, rPropInfo.nWidth, rPropInfo.eWidthType, sal_True );
2904 : 0 : }
2905 : :
2906 : 0 : static void ParseCSS1_height( const CSS1Expression *pExpr,
2907 : : SfxItemSet & /*rItemSet*/,
2908 : : SvxCSS1PropertyInfo& rPropInfo,
2909 : : const SvxCSS1Parser& /*rParser*/ )
2910 : : {
2911 : 0 : ParseCSS1_length( pExpr, rPropInfo.nHeight, rPropInfo.eHeightType, sal_False );
2912 : 0 : }
2913 : :
2914 : 0 : static void ParseCSS1_left( const CSS1Expression *pExpr,
2915 : : SfxItemSet & /*rItemSet*/,
2916 : : SvxCSS1PropertyInfo& rPropInfo,
2917 : : const SvxCSS1Parser& /*rParser*/ )
2918 : : {
2919 : 0 : ParseCSS1_length( pExpr, rPropInfo.nLeft, rPropInfo.eLeftType, sal_True );
2920 : 0 : }
2921 : :
2922 : 0 : static void ParseCSS1_top( const CSS1Expression *pExpr,
2923 : : SfxItemSet & /*rItemSet*/,
2924 : : SvxCSS1PropertyInfo& rPropInfo,
2925 : : const SvxCSS1Parser& /*rParser*/ )
2926 : : {
2927 : 0 : ParseCSS1_length( pExpr, rPropInfo.nTop, rPropInfo.eTopType, sal_False );
2928 : 0 : }
2929 : :
2930 : :
2931 : : // Feature: PrintExt
2932 : 0 : static void ParseCSS1_size( const CSS1Expression *pExpr,
2933 : : SfxItemSet & /*rItemSet*/,
2934 : : SvxCSS1PropertyInfo& rPropInfo,
2935 : : const SvxCSS1Parser& /*rParser*/ )
2936 : : {
2937 : 0 : sal_uInt16 n=0;
2938 [ # # ][ # # ]: 0 : while( n<2 && pExpr && !pExpr->GetOp() )
[ # # ][ # # ]
2939 : : {
2940 [ # # # # ]: 0 : switch( pExpr->GetType() )
2941 : : {
2942 : : case CSS1_IDENT:
2943 : : {
2944 : : sal_uInt16 nValue;
2945 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aSizeTable, pExpr->GetString(),
2946 [ # # ]: 0 : nValue ) )
2947 : : {
2948 : 0 : rPropInfo.eSizeType = (SvxCSS1SizeType)nValue;
2949 : : }
2950 : : }
2951 : 0 : break;
2952 : :
2953 : : case CSS1_LENGTH:
2954 : 0 : rPropInfo.nHeight = pExpr->GetSLength();
2955 [ # # ]: 0 : if( n==0 )
2956 : 0 : rPropInfo.nWidth = rPropInfo.nHeight;
2957 : 0 : rPropInfo.eSizeType = SVX_CSS1_STYPE_TWIP;
2958 : 0 : break;
2959 : :
2960 : : case CSS1_PIXLENGTH:
2961 : : {
2962 : 0 : long nPHeight = (long)pExpr->GetNumber();
2963 [ # # ]: 0 : long nPWidth = n==0 ? nPHeight : 0;
2964 [ # # ]: 0 : SvxCSS1Parser::PixelToTwip( nPWidth, nPHeight );
2965 : 0 : rPropInfo.nHeight = nPHeight;
2966 [ # # ]: 0 : if( n==0 )
2967 : 0 : rPropInfo.nWidth = nPWidth;
2968 : 0 : rPropInfo.eSizeType = SVX_CSS1_STYPE_TWIP;
2969 : : }
2970 : 0 : break;
2971 : :
2972 : : default:
2973 : : ;
2974 : : }
2975 : :
2976 : 0 : pExpr = pExpr->GetNext();
2977 : 0 : n++;
2978 : : }
2979 : 0 : }
2980 : :
2981 : : // /Feature: PrintExt
2982 : :
2983 : :
2984 : : // Feature: PrintExt
2985 : :
2986 : 0 : static void ParseCSS1_page_break_xxx( const CSS1Expression *pExpr,
2987 : : SvxCSS1PageBreak& rPBreak )
2988 : : {
2989 [ # # ]: 0 : if( CSS1_IDENT == pExpr->GetType() )
2990 : : {
2991 : : sal_uInt16 nValue;
2992 [ # # ]: 0 : if( SvxCSS1Parser::GetEnum( aPageBreakTable, pExpr->GetString(),
2993 [ # # ]: 0 : nValue ) )
2994 : : {
2995 : 0 : rPBreak = (SvxCSS1PageBreak)nValue;
2996 : : }
2997 : : }
2998 : 0 : }
2999 : :
3000 : 0 : static void ParseCSS1_page_break_before( const CSS1Expression *pExpr,
3001 : : SfxItemSet & /*rItemSet*/,
3002 : : SvxCSS1PropertyInfo& rPropInfo,
3003 : : const SvxCSS1Parser& /*rParser*/ )
3004 : : {
3005 : 0 : ParseCSS1_page_break_xxx( pExpr, rPropInfo.ePageBreakBefore );
3006 : 0 : }
3007 : :
3008 : 0 : static void ParseCSS1_page_break_after( const CSS1Expression *pExpr,
3009 : : SfxItemSet & /*rItemSet*/,
3010 : : SvxCSS1PropertyInfo& rPropInfo,
3011 : : const SvxCSS1Parser& /*rParser*/ )
3012 : : {
3013 : 0 : ParseCSS1_page_break_xxx( pExpr, rPropInfo.ePageBreakAfter );
3014 : 0 : }
3015 : :
3016 : 0 : static void ParseCSS1_page_break_inside( const CSS1Expression *pExpr,
3017 : : SfxItemSet &rItemSet,
3018 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
3019 : : const SvxCSS1Parser& /*rParser*/ )
3020 : : {
3021 : 0 : SvxCSS1PageBreak eBreak(SVX_CSS1_PBREAK_NONE);
3022 [ # # ]: 0 : ParseCSS1_page_break_xxx( pExpr, eBreak );
3023 : :
3024 : 0 : sal_Bool bSetSplit = sal_False, bSplit = sal_True;
3025 [ # # # ]: 0 : switch( eBreak )
3026 : : {
3027 : : case SVX_CSS1_PBREAK_AUTO:
3028 : 0 : bSetSplit = sal_True;
3029 : 0 : break;
3030 : : case SVX_CSS1_PBREAK_AVOID:
3031 : 0 : bSplit = sal_False;
3032 : 0 : bSetSplit = sal_True;
3033 : 0 : break;
3034 : : default:
3035 : : ;
3036 : : }
3037 : :
3038 [ # # ]: 0 : if( bSetSplit )
3039 [ # # ][ # # ]: 0 : rItemSet.Put( SvxFmtSplitItem( bSplit, aItemIds.nFmtSplit ) );
[ # # ]
3040 : 0 : }
3041 : :
3042 : 0 : static void ParseCSS1_widows( const CSS1Expression *pExpr,
3043 : : SfxItemSet &rItemSet,
3044 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
3045 : : const SvxCSS1Parser& /*rParser*/ )
3046 : : {
3047 [ # # ]: 0 : if( CSS1_NUMBER == pExpr->GetType() )
3048 : : {
3049 : 0 : sal_uInt8 nVal = pExpr->GetNumber() <= 255
3050 : 0 : ? (sal_uInt8)pExpr->GetNumber()
3051 [ # # ]: 0 : : 255;
3052 [ # # ]: 0 : SvxWidowsItem aWidowsItem( nVal, aItemIds.nWidows );
3053 [ # # ][ # # ]: 0 : rItemSet.Put( aWidowsItem );
3054 : : }
3055 : 0 : }
3056 : :
3057 : 0 : static void ParseCSS1_orphans( const CSS1Expression *pExpr,
3058 : : SfxItemSet &rItemSet,
3059 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
3060 : : const SvxCSS1Parser& /*rParser*/ )
3061 : : {
3062 [ # # ]: 0 : if( CSS1_NUMBER == pExpr->GetType() )
3063 : : {
3064 : 0 : sal_uInt8 nVal = pExpr->GetNumber() <= 255
3065 : 0 : ? (sal_uInt8)pExpr->GetNumber()
3066 [ # # ]: 0 : : 255;
3067 [ # # ]: 0 : SvxOrphansItem aOrphansItem( nVal, aItemIds.nOrphans );
3068 [ # # ][ # # ]: 0 : rItemSet.Put( aOrphansItem );
3069 : : }
3070 : 0 : }
3071 : : // /Feature: PrintExt
3072 : :
3073 : 0 : static void ParseCSS1_so_language( const CSS1Expression *pExpr,
3074 : : SfxItemSet &rItemSet,
3075 : : SvxCSS1PropertyInfo& /*rPropInfo*/,
3076 : : const SvxCSS1Parser& rParser )
3077 : : {
3078 [ # # # # ]: 0 : if( CSS1_IDENT == pExpr->GetType() ||
[ # # ]
3079 : 0 : CSS1_STRING == pExpr->GetType() )
3080 : : {
3081 [ # # ]: 0 : LanguageType eLang = MsLangId::convertIsoStringToLanguage( pExpr->GetString() );
3082 [ # # ]: 0 : if( LANGUAGE_DONTKNOW != eLang )
3083 : : {
3084 [ # # ]: 0 : SvxLanguageItem aLang( eLang, aItemIds.nLanguage );
3085 [ # # ]: 0 : if( rParser.IsSetWesternProps() )
3086 [ # # ]: 0 : rItemSet.Put( aLang );
3087 [ # # ]: 0 : if( rParser.IsSetCJKProps() )
3088 : : {
3089 : 0 : aLang.SetWhich( aItemIds.nLanguageCJK );
3090 [ # # ]: 0 : rItemSet.Put( aLang );
3091 : : }
3092 [ # # ]: 0 : if( rParser.IsSetCTLProps() )
3093 : : {
3094 : 0 : aLang.SetWhich( aItemIds.nLanguageCTL );
3095 [ # # ]: 0 : rItemSet.Put( aLang );
3096 [ # # ]: 0 : }
3097 : : }
3098 : : }
3099 : 0 : }
3100 : :
3101 : :
3102 : : // die Zuordung Property zu parsender Funktion
3103 : : struct CSS1PropEntry
3104 : : {
3105 : : union
3106 : : {
3107 : : const sal_Char *sName;
3108 : : String *pName;
3109 : : };
3110 : : FnParseCSS1Prop pFunc;
3111 : : };
3112 : :
3113 : : #define CSS1_PROP_ENTRY(p) \
3114 : : { { sCSS1_P_##p }, ParseCSS1_##p }
3115 : :
3116 : :
3117 : : // die Tabelle mit den Zuordnungen
3118 : : static CSS1PropEntry aCSS1PropFnTab[] =
3119 : : {
3120 : : CSS1_PROP_ENTRY(background),
3121 : : CSS1_PROP_ENTRY(background_color),
3122 : : CSS1_PROP_ENTRY(border_top_width),
3123 : : CSS1_PROP_ENTRY(border_right_width),
3124 : : CSS1_PROP_ENTRY(border_bottom_width),
3125 : : CSS1_PROP_ENTRY(border_left_width),
3126 : : CSS1_PROP_ENTRY(border_width),
3127 : : CSS1_PROP_ENTRY(border_color),
3128 : : CSS1_PROP_ENTRY(border_style),
3129 : : CSS1_PROP_ENTRY(border_top),
3130 : : CSS1_PROP_ENTRY(border_right),
3131 : : CSS1_PROP_ENTRY(border_bottom),
3132 : : CSS1_PROP_ENTRY(border_left),
3133 : : CSS1_PROP_ENTRY(border),
3134 : : CSS1_PROP_ENTRY(color),
3135 : : CSS1_PROP_ENTRY(direction),
3136 : : CSS1_PROP_ENTRY(float),
3137 : : CSS1_PROP_ENTRY(font_size),
3138 : : CSS1_PROP_ENTRY(font_family),
3139 : : CSS1_PROP_ENTRY(font_style),
3140 : : CSS1_PROP_ENTRY(font_variant),
3141 : : CSS1_PROP_ENTRY(font_weight),
3142 : : CSS1_PROP_ENTRY(letter_spacing),
3143 : : CSS1_PROP_ENTRY(line_height),
3144 : : CSS1_PROP_ENTRY(font),
3145 : : CSS1_PROP_ENTRY(text_align),
3146 : : CSS1_PROP_ENTRY(text_decoration),
3147 : : CSS1_PROP_ENTRY(text_indent),
3148 : : CSS1_PROP_ENTRY(text_transform),
3149 : : CSS1_PROP_ENTRY(margin_left),
3150 : : CSS1_PROP_ENTRY(margin_right),
3151 : : CSS1_PROP_ENTRY(margin_top),
3152 : : CSS1_PROP_ENTRY(margin_bottom),
3153 : : CSS1_PROP_ENTRY(margin),
3154 : : CSS1_PROP_ENTRY(padding_top),
3155 : : CSS1_PROP_ENTRY(padding_bottom),
3156 : : CSS1_PROP_ENTRY(padding_left),
3157 : : CSS1_PROP_ENTRY(padding_right),
3158 : : CSS1_PROP_ENTRY(padding),
3159 : : CSS1_PROP_ENTRY(position),
3160 : : CSS1_PROP_ENTRY(left),
3161 : : CSS1_PROP_ENTRY(top),
3162 : : CSS1_PROP_ENTRY(width),
3163 : : CSS1_PROP_ENTRY(height),
3164 : : // Feature: PrintExt
3165 : : CSS1_PROP_ENTRY(size),
3166 : : CSS1_PROP_ENTRY(page_break_before),
3167 : : CSS1_PROP_ENTRY(page_break_after),
3168 : : CSS1_PROP_ENTRY(page_break_inside),
3169 : : CSS1_PROP_ENTRY(widows),
3170 : : CSS1_PROP_ENTRY(orphans),
3171 : : // /Feature: PrintExt
3172 : : CSS1_PROP_ENTRY(so_language)
3173 : : };
3174 : :
3175 : :
3176 : : static int bSortedPropFns = sal_False;
3177 : :
3178 : : extern "C"
3179 : : {
3180 : 0 : static int SAL_CALL CSS1PropEntryCompare( const void *pFirst, const void *pSecond)
3181 : : {
3182 : : int nRet;
3183 [ # # ]: 0 : if( ((CSS1PropEntry*)pFirst)->pFunc )
3184 : : {
3185 [ # # ]: 0 : if( ((CSS1PropEntry*)pSecond)->pFunc )
3186 : : nRet = strcmp( ((CSS1PropEntry*)pFirst)->sName ,
3187 : 0 : ((CSS1PropEntry*)pSecond)->sName );
3188 : : else
3189 : : nRet = -1 * ((CSS1PropEntry*)pSecond)->pName->CompareToAscii(
3190 : 0 : ((CSS1PropEntry*)pFirst)->sName );
3191 : : }
3192 : : else
3193 : : {
3194 [ # # ]: 0 : if( ((CSS1PropEntry*)pSecond)->pFunc )
3195 : : nRet = ((CSS1PropEntry*)pFirst)->pName->CompareToAscii(
3196 : 0 : ((CSS1PropEntry*)pSecond)->sName );
3197 : : else
3198 : : nRet = ((CSS1PropEntry*)pFirst)->pName->CompareTo(
3199 : 0 : *((CSS1PropEntry*)pSecond)->pName );
3200 : : }
3201 : :
3202 : 0 : return nRet;
3203 : : }
3204 : : }
3205 : :
3206 : 0 : void SvxCSS1Parser::ParseProperty( const String& rProperty,
3207 : : const CSS1Expression *pExpr )
3208 : : {
3209 : : OSL_ENSURE( pItemSet, "DeclarationParsed() without ItemSet" );
3210 : :
3211 [ # # ]: 0 : if( !bSortedPropFns )
3212 : : {
3213 : : qsort( (void*) aCSS1PropFnTab,
3214 : : sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
3215 : : sizeof( CSS1PropEntry ),
3216 [ # # ]: 0 : CSS1PropEntryCompare );
3217 : 0 : bSortedPropFns = sal_True;
3218 : : }
3219 : :
3220 [ # # ]: 0 : String aTmp( rProperty );
3221 [ # # ]: 0 : aTmp.ToLowerAscii();
3222 : :
3223 : : CSS1PropEntry aSrch;
3224 : 0 : aSrch.pName = &aTmp;
3225 : 0 : aSrch.pFunc = 0;
3226 : :
3227 : : void* pFound;
3228 [ # # ][ # # ]: 0 : if( 0 != ( pFound = bsearch( (char *) &aSrch,
3229 : : (void*) aCSS1PropFnTab,
3230 : : sizeof( aCSS1PropFnTab ) / sizeof( CSS1PropEntry ),
3231 : : sizeof( CSS1PropEntry ),
3232 : : CSS1PropEntryCompare )))
3233 : : {
3234 [ # # ]: 0 : (((CSS1PropEntry*)pFound)->pFunc)( pExpr, *pItemSet, *pPropInfo, *this );
3235 [ # # ]: 0 : }
3236 : 0 : }
3237 : :
3238 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|