Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <tools/debug.hxx>
21 : #include <osl/thread.h>
22 : #include <com/sun/star/awt/FontFamily.hpp>
23 : #include <com/sun/star/awt/FontPitch.hpp>
24 : #include <com/sun/star/table/BorderLine2.hpp>
25 : #include <com/sun/star/text/VertOrientation.hpp>
26 : #include <com/sun/star/text/SizeType.hpp>
27 : #include <xmloff/XMLFontStylesContext.hxx>
28 : #include <xmloff/txtprmap.hxx>
29 : #include <xmloff/xmlimp.hxx>
30 : #include "xmloff/txtimppr.hxx"
31 :
32 : #define XML_LINE_LEFT 0
33 : #define XML_LINE_RIGHT 1
34 : #define XML_LINE_TOP 2
35 : #define XML_LINE_BOTTOM 3
36 : #define MIN_BORDER_DIST 49
37 :
38 : using ::rtl::OUString;
39 :
40 : using namespace ::com::sun::star;
41 : using namespace ::com::sun::star::uno;
42 : using namespace ::com::sun::star::table;
43 : using namespace ::com::sun::star::text;
44 :
45 336 : bool XMLTextImportPropertyMapper::handleSpecialItem(
46 : XMLPropertyState& rProperty,
47 : ::std::vector< XMLPropertyState >& rProperties,
48 : const ::rtl::OUString& rValue,
49 : const SvXMLUnitConverter& rUnitConverter,
50 : const SvXMLNamespaceMap& rNamespaceMap ) const
51 : {
52 336 : sal_Bool bRet = sal_False;
53 336 : sal_Int32 nIndex = rProperty.mnIndex;
54 336 : switch( getPropertySetMapper()->GetEntryContextId( nIndex ) )
55 : {
56 : case CTF_FONTNAME:
57 : case CTF_FONTNAME_CJK:
58 : case CTF_FONTNAME_CTL:
59 300 : if( xFontDecls.Is() )
60 : {
61 : DBG_ASSERT(
62 : ( CTF_FONTFAMILYNAME ==
63 : getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
64 : CTF_FONTSTYLENAME ==
65 : getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
66 : CTF_FONTFAMILY ==
67 : getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
68 : CTF_FONTPITCH ==
69 : getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
70 : CTF_FONTCHARSET ==
71 : getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
72 : ( CTF_FONTFAMILYNAME_CJK ==
73 : getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
74 : CTF_FONTSTYLENAME_CJK ==
75 : getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
76 : CTF_FONTFAMILY_CJK ==
77 : getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
78 : CTF_FONTPITCH_CJK ==
79 : getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
80 : CTF_FONTCHARSET_CJK ==
81 : getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
82 : ( CTF_FONTFAMILYNAME_CTL ==
83 : getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
84 : CTF_FONTSTYLENAME_CTL ==
85 : getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
86 : CTF_FONTFAMILY_CTL ==
87 : getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
88 : CTF_FONTPITCH_CTL ==
89 : getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
90 : CTF_FONTCHARSET_CTL ==
91 : getPropertySetMapper()->GetEntryContextId(nIndex+5) ),
92 : "illegal property map" );
93 :
94 300 : ((XMLFontStylesContext *)&xFontDecls)->FillProperties(
95 : rValue, rProperties,
96 : rProperty.mnIndex+1, rProperty.mnIndex+2,
97 : rProperty.mnIndex+3, rProperty.mnIndex+4,
98 600 : rProperty.mnIndex+5 );
99 300 : bRet = sal_False; // the property hasn't been filled
100 : }
101 300 : break;
102 :
103 : // If we want to do StarMath/StarSymbol font conversion, then we'll
104 : // want these special items to be treated just like regular ones...
105 : // For the Writer, we'll catch and convert them in _FillPropertySet;
106 : // the other apps probably don't care. For the other apps, we just
107 : // imitate the default non-special-item mechanism.
108 : case CTF_FONTFAMILYNAME:
109 : case CTF_FONTFAMILYNAME_CJK:
110 : case CTF_FONTFAMILYNAME_CTL:
111 36 : bRet = getPropertySetMapper()->importXML( rValue, rProperty,
112 36 : rUnitConverter );
113 36 : break;
114 :
115 : case CTF_TEXT_DISPLAY:
116 0 : bRet = getPropertySetMapper()->importXML( rValue, rProperty,
117 0 : rUnitConverter );
118 0 : if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
119 : {
120 : sal_Bool bHidden;
121 0 : rProperty.maValue >>= bHidden;
122 0 : bHidden = !bHidden;
123 0 : rProperty.maValue <<= bHidden;
124 : }
125 0 : break;
126 : default:
127 : bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
128 0 : rProperties, rValue, rUnitConverter, rNamespaceMap );
129 0 : break;
130 : }
131 :
132 336 : return bRet;
133 : }
134 :
135 803 : XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
136 : const UniReference< XMLPropertySetMapper >& rMapper,
137 : SvXMLImport& rImp,
138 : XMLFontStylesContext *pFontDecls ) :
139 : SvXMLImportPropertyMapper( rMapper, rImp ),
140 : nSizeTypeIndex( -2 ),
141 : nWidthTypeIndex( -2 ),
142 803 : xFontDecls( pFontDecls )
143 : {
144 803 : }
145 :
146 1606 : XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
147 : {
148 1606 : }
149 :
150 156 : void XMLTextImportPropertyMapper::SetFontDecls(
151 : XMLFontStylesContext *pFontDecls )
152 : {
153 156 : xFontDecls = pFontDecls;
154 156 : }
155 :
156 336 : void XMLTextImportPropertyMapper::FontFinished(
157 : XMLPropertyState *pFontFamilyNameState,
158 : XMLPropertyState *pFontStyleNameState,
159 : XMLPropertyState *pFontFamilyState,
160 : XMLPropertyState *pFontPitchState,
161 : XMLPropertyState *pFontCharsetState ) const
162 : {
163 336 : if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
164 : {
165 336 : OUString sName;
166 336 : pFontFamilyNameState->maValue >>= sName;
167 336 : if( sName.isEmpty() )
168 18 : pFontFamilyNameState->mnIndex = -1;
169 : }
170 336 : if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
171 : {
172 18 : if( pFontStyleNameState )
173 18 : pFontStyleNameState->mnIndex = -1;
174 18 : if( pFontFamilyState )
175 18 : pFontFamilyState->mnIndex = -1;
176 18 : if( pFontPitchState )
177 18 : pFontPitchState->mnIndex = -1;
178 18 : if( pFontCharsetState )
179 18 : pFontCharsetState->mnIndex = -1;
180 : }
181 336 : }
182 :
183 : /** since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily",
184 : "CharFontPitch" and "CharFontSet" and theire CJK and CTL counterparts are only
185 : usable as a union, we add defaults to all values that are not set as long as we
186 : have an "CharFontFamilyName"
187 :
188 : #99928# CL */
189 2502 : void XMLTextImportPropertyMapper::FontDefaultsCheck(
190 : XMLPropertyState* pFontFamilyName,
191 : XMLPropertyState* pFontStyleName,
192 : XMLPropertyState* pFontFamily,
193 : XMLPropertyState* pFontPitch,
194 : XMLPropertyState* pFontCharSet,
195 : XMLPropertyState** ppNewFontStyleName,
196 : XMLPropertyState** ppNewFontFamily,
197 : XMLPropertyState** ppNewFontPitch,
198 : XMLPropertyState** ppNewFontCharSet ) const
199 : {
200 2502 : if( pFontFamilyName )
201 : {
202 336 : OUString sEmpty;
203 336 : Any aAny;
204 :
205 336 : if( !pFontStyleName )
206 : {
207 36 : aAny <<= sEmpty;
208 : #ifdef DBG_UTIL
209 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
210 : pFontFamilyName->mnIndex + 1 );
211 : DBG_ASSERT( nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL,
212 : "wrong property context id" );
213 : #endif
214 : *ppNewFontStyleName = new XMLPropertyState( pFontFamilyName->mnIndex + 1,
215 36 : aAny );
216 : }
217 :
218 336 : if( !pFontFamily )
219 : {
220 2 : aAny <<= (sal_Int16)com::sun::star::awt::FontFamily::DONTKNOW;
221 :
222 : #ifdef DBG_UTIL
223 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
224 : pFontFamilyName->mnIndex + 2 );
225 : DBG_ASSERT( nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL,
226 : "wrong property context id" );
227 : #endif
228 : *ppNewFontFamily = new XMLPropertyState( pFontFamilyName->mnIndex + 2,
229 2 : aAny );
230 : }
231 :
232 336 : if( !pFontPitch )
233 : {
234 0 : aAny <<= (sal_Int16)com::sun::star::awt::FontPitch::DONTKNOW;
235 : #ifdef DBG_UTIL
236 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
237 : pFontFamilyName->mnIndex + 3 );
238 : DBG_ASSERT( nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL,
239 : "wrong property context id" );
240 : #endif
241 : *ppNewFontPitch = new XMLPropertyState( pFontFamilyName->mnIndex + 3,
242 0 : aAny );
243 : }
244 :
245 336 : if( !pFontCharSet )
246 : {
247 36 : aAny <<= (sal_Int16)osl_getThreadTextEncoding();
248 : #ifdef DBG_UTIL
249 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
250 : pFontFamilyName->mnIndex + 4 );
251 : DBG_ASSERT( nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL,
252 : "wrong property context id" );
253 : #endif
254 : *ppNewFontCharSet = new XMLPropertyState( pFontFamilyName->mnIndex + 4,
255 36 : aAny );
256 336 : }
257 : }
258 2502 : }
259 :
260 834 : void XMLTextImportPropertyMapper::finished(
261 : ::std::vector< XMLPropertyState >& rProperties,
262 : sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
263 : {
264 834 : sal_Bool bHasAnyHeight = sal_False;
265 834 : sal_Bool bHasAnyMinHeight = sal_False;
266 834 : sal_Bool bHasAnyWidth = sal_False;
267 834 : sal_Bool bHasAnyMinWidth = sal_False;
268 :
269 834 : XMLPropertyState* pFontFamilyName = 0;
270 834 : XMLPropertyState* pFontStyleName = 0;
271 834 : XMLPropertyState* pFontFamily = 0;
272 834 : XMLPropertyState* pFontPitch = 0;
273 834 : XMLPropertyState* pFontCharSet = 0;
274 834 : XMLPropertyState* pNewFontStyleName = 0;
275 834 : XMLPropertyState* pNewFontFamily = 0;
276 834 : XMLPropertyState* pNewFontPitch = 0;
277 834 : XMLPropertyState* pNewFontCharSet = 0;
278 834 : XMLPropertyState* pFontFamilyNameCJK = 0;
279 834 : XMLPropertyState* pFontStyleNameCJK = 0;
280 834 : XMLPropertyState* pFontFamilyCJK = 0;
281 834 : XMLPropertyState* pFontPitchCJK = 0;
282 834 : XMLPropertyState* pFontCharSetCJK = 0;
283 834 : XMLPropertyState* pNewFontStyleNameCJK = 0;
284 834 : XMLPropertyState* pNewFontFamilyCJK = 0;
285 834 : XMLPropertyState* pNewFontPitchCJK = 0;
286 834 : XMLPropertyState* pNewFontCharSetCJK = 0;
287 834 : XMLPropertyState* pFontFamilyNameCTL = 0;
288 834 : XMLPropertyState* pFontStyleNameCTL = 0;
289 834 : XMLPropertyState* pFontFamilyCTL = 0;
290 834 : XMLPropertyState* pFontPitchCTL = 0;
291 834 : XMLPropertyState* pFontCharSetCTL = 0;
292 834 : XMLPropertyState* pNewFontStyleNameCTL = 0;
293 834 : XMLPropertyState* pNewFontFamilyCTL = 0;
294 834 : XMLPropertyState* pNewFontPitchCTL = 0;
295 834 : XMLPropertyState* pNewFontCharSetCTL = 0;
296 834 : XMLPropertyState* pAllBorderDistance = 0;
297 834 : XMLPropertyState* pBorderDistances[4] = { 0, 0, 0, 0 };
298 834 : XMLPropertyState* pNewBorderDistances[4] = { 0, 0, 0, 0 };
299 834 : XMLPropertyState* pAllBorder = 0;
300 834 : XMLPropertyState* pBorders[4] = { 0, 0, 0, 0 };
301 834 : XMLPropertyState* pNewBorders[4] = { 0, 0, 0, 0 };
302 834 : XMLPropertyState* pAllBorderWidth = 0;
303 834 : XMLPropertyState* pBorderWidths[4] = { 0, 0, 0, 0 };
304 834 : XMLPropertyState* pVertOrient = 0;
305 834 : XMLPropertyState* pVertOrientRelAsChar = 0;
306 834 : XMLPropertyState* pBackTransparency = NULL; // transparency in %
307 834 : XMLPropertyState* pBackTransparent = NULL; // transparency as boolean
308 834 : XMLPropertyState* pAllParaMargin = 0;
309 834 : XMLPropertyState* pParaMargins[4] = { 0, 0, 0, 0 };
310 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
311 4170 : ::std::auto_ptr<XMLPropertyState> pNewParaMargins[4];
312 : SAL_WNODEPRECATED_DECLARATIONS_POP
313 834 : XMLPropertyState* pAllMargin = 0;
314 834 : XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 };
315 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
316 4170 : ::std::auto_ptr<XMLPropertyState> pNewMargins[4];
317 : SAL_WNODEPRECATED_DECLARATIONS_POP
318 :
319 21138 : for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
320 14092 : aIter != rProperties.end();
321 : ++aIter )
322 : {
323 6212 : XMLPropertyState* property = &(*aIter);
324 6212 : if( -1 == property->mnIndex )
325 121 : continue;
326 :
327 6091 : switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
328 : {
329 104 : case CTF_FONTFAMILYNAME: pFontFamilyName = property; break;
330 84 : case CTF_FONTSTYLENAME: pFontStyleName = property; break;
331 104 : case CTF_FONTFAMILY: pFontFamily = property; break;
332 104 : case CTF_FONTPITCH: pFontPitch = property; break;
333 84 : case CTF_FONTCHARSET: pFontCharSet = property; break;
334 :
335 87 : case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJK = property; break;
336 79 : case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property; break;
337 86 : case CTF_FONTFAMILY_CJK: pFontFamilyCJK = property; break;
338 87 : case CTF_FONTPITCH_CJK: pFontPitchCJK = property; break;
339 79 : case CTF_FONTCHARSET_CJK: pFontCharSetCJK = property; break;
340 :
341 145 : case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTL = property; break;
342 137 : case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property; break;
343 144 : case CTF_FONTFAMILY_CTL: pFontFamilyCTL = property; break;
344 145 : case CTF_FONTPITCH_CTL: pFontPitchCTL = property; break;
345 137 : case CTF_FONTCHARSET_CTL: pFontCharSetCTL = property; break;
346 :
347 2 : case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break;
348 1 : case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break;
349 1 : case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break;
350 1 : case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break;
351 1 : case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break;
352 2 : case CTF_ALLBORDER: pAllBorder = property; break;
353 1 : case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break;
354 1 : case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break;
355 1 : case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break;
356 1 : case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break;
357 :
358 0 : case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break;
359 0 : case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break;
360 0 : case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break;
361 0 : case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break;
362 0 : case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break;
363 3 : case CTF_ANCHORTYPE: break;
364 7 : case CTF_VERTICALPOS: pVertOrient = property; break;
365 1 : case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
366 :
367 : case CTF_FRAMEHEIGHT_MIN_ABS:
368 : case CTF_FRAMEHEIGHT_MIN_REL:
369 : // case CTF_SYNCHEIGHT_MIN:
370 1 : bHasAnyMinHeight = sal_True;
371 : // no break here!
372 : case CTF_FRAMEHEIGHT_ABS:
373 : case CTF_FRAMEHEIGHT_REL:
374 : // case CTF_SYNCHEIGHT:
375 1 : bHasAnyHeight = sal_True; break;
376 : case CTF_FRAMEWIDTH_MIN_ABS:
377 : case CTF_FRAMEWIDTH_MIN_REL:
378 1 : bHasAnyMinWidth = sal_True;
379 : // no break here!
380 : case CTF_FRAMEWIDTH_ABS:
381 : case CTF_FRAMEWIDTH_REL:
382 1 : bHasAnyWidth = sal_True; break;
383 0 : case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
384 0 : case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break;
385 : case CTF_PARAMARGINALL:
386 : case CTF_PARAMARGINALL_REL:
387 4 : pAllParaMargin = property; break;
388 : case CTF_PARALEFTMARGIN:
389 : case CTF_PARALEFTMARGIN_REL:
390 39 : pParaMargins[XML_LINE_LEFT] = property; break;
391 : case CTF_PARARIGHTMARGIN:
392 : case CTF_PARARIGHTMARGIN_REL:
393 39 : pParaMargins[XML_LINE_RIGHT] = property; break;
394 : case CTF_PARATOPMARGIN:
395 : case CTF_PARATOPMARGIN_REL:
396 172 : pParaMargins[XML_LINE_TOP] = property; break;
397 : case CTF_PARABOTTOMMARGIN:
398 : case CTF_PARABOTTOMMARGIN_REL:
399 172 : pParaMargins[XML_LINE_BOTTOM] = property; break;
400 : case CTF_MARGINALL:
401 0 : pAllMargin = property; break;
402 : case CTF_MARGINLEFT:
403 1 : pMargins[XML_LINE_LEFT] = property; break;
404 : case CTF_MARGINRIGHT:
405 1 : pMargins[XML_LINE_RIGHT] = property; break;
406 : case CTF_MARGINTOP:
407 1 : pMargins[XML_LINE_TOP] = property; break;
408 : case CTF_MARGINBOTTOM:
409 1 : pMargins[XML_LINE_BOTTOM] = property; break;
410 : }
411 : }
412 :
413 834 : if( pFontFamilyName || pFontStyleName || pFontFamily ||
414 : pFontPitch || pFontCharSet )
415 : FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
416 104 : pFontPitch, pFontCharSet );
417 834 : if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
418 : pFontPitchCJK || pFontCharSetCJK )
419 : FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
420 87 : pFontPitchCJK, pFontCharSetCJK );
421 834 : if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
422 : pFontPitchCTL || pFontCharSetCTL )
423 : FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
424 145 : pFontPitchCTL, pFontCharSetCTL );
425 :
426 4170 : for (sal_uInt16 i = 0; i < 4; i++)
427 : {
428 3336 : if (pAllParaMargin && !pParaMargins[i])
429 : {
430 : #if OSL_DEBUG_LEVEL > 0
431 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
432 : pAllParaMargin->mnIndex + (2*i) + 2 );
433 : OSL_ENSURE( nTmp >= CTF_PARALEFTMARGIN &&
434 : nTmp <= CTF_PARABOTTOMMARGIN_REL,
435 : "wrong property context id" );
436 : #endif
437 2 : pNewParaMargins[i].reset(new XMLPropertyState(
438 4 : pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue));
439 : }
440 3336 : if (pAllMargin && !pMargins[i])
441 : {
442 : #if OSL_DEBUG_LEVEL > 0
443 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
444 : pAllMargin->mnIndex + i + 1 );
445 : OSL_ENSURE( nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM,
446 : "wrong property context id" );
447 : #endif
448 0 : pNewMargins[i].reset(new XMLPropertyState(
449 0 : pAllMargin->mnIndex + i + 1, pAllMargin->maValue));
450 : }
451 3336 : if( pAllBorderDistance && !pBorderDistances[i] )
452 : {
453 : #ifdef DBG_UTIL
454 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
455 : pAllBorderDistance->mnIndex + i + 1 );
456 : DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE &&
457 : nTmp <= CTF_BOTTOMBORDERDISTANCE,
458 : "wrong property context id" );
459 : #endif
460 8 : pNewBorderDistances[i] =
461 : new XMLPropertyState( pAllBorderDistance->mnIndex + i + 1,
462 16 : pAllBorderDistance->maValue );
463 8 : pBorderDistances[i] = pNewBorderDistances[i];
464 : }
465 3336 : if( pAllBorder && !pBorders[i] )
466 : {
467 : #ifdef DBG_UTIL
468 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
469 : pAllBorder->mnIndex + i + 1 );
470 : DBG_ASSERT( nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER,
471 : "wrong property context id" );
472 : #endif
473 8 : pNewBorders[i] = new XMLPropertyState( pAllBorder->mnIndex + i + 1,
474 16 : pAllBorder->maValue );
475 8 : pBorders[i] = pNewBorders[i];
476 : }
477 3336 : if( !pBorderWidths[i] )
478 3336 : pBorderWidths[i] = pAllBorderWidth;
479 : else
480 0 : pBorderWidths[i]->mnIndex = -1;
481 :
482 3336 : if( pBorders[i] && pBorderWidths[i] )
483 : {
484 0 : table::BorderLine2 aBorderLine;
485 0 : pBorders[i]->maValue >>= aBorderLine;
486 :
487 0 : table::BorderLine2 aBorderLineWidth;
488 0 : pBorderWidths[i]->maValue >>= aBorderLineWidth;
489 :
490 0 : aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
491 0 : aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
492 0 : aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
493 0 : aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
494 :
495 0 : pBorders[i]->maValue <<= aBorderLine;
496 : }
497 : }
498 :
499 834 : if (pAllParaMargin)
500 : {
501 4 : pAllParaMargin->mnIndex = -1;
502 : }
503 834 : if (pAllMargin)
504 : {
505 0 : pAllMargin->mnIndex = -1;
506 : }
507 :
508 834 : if( pAllBorderDistance )
509 2 : pAllBorderDistance->mnIndex = -1;
510 :
511 834 : if( pAllBorder )
512 2 : pAllBorder->mnIndex = -1;
513 :
514 834 : if( pAllBorderWidth )
515 0 : pAllBorderWidth->mnIndex = -1;
516 :
517 834 : if( pVertOrient && pVertOrientRelAsChar )
518 : {
519 : sal_Int16 nVertOrient;
520 1 : pVertOrient->maValue >>= nVertOrient;
521 1 : sal_Int16 nVertOrientRel = 0;
522 1 : pVertOrientRelAsChar->maValue >>= nVertOrientRel;
523 1 : switch( nVertOrient )
524 : {
525 : case VertOrientation::TOP:
526 1 : nVertOrient = nVertOrientRel;
527 1 : break;
528 : case VertOrientation::CENTER:
529 0 : switch( nVertOrientRel )
530 : {
531 : case VertOrientation::CHAR_TOP:
532 0 : nVertOrient = VertOrientation::CHAR_CENTER;
533 0 : break;
534 : case VertOrientation::LINE_TOP:
535 0 : nVertOrient = VertOrientation::LINE_CENTER;
536 0 : break;
537 : }
538 0 : break;
539 : case VertOrientation::BOTTOM:
540 0 : switch( nVertOrientRel )
541 : {
542 : case VertOrientation::CHAR_TOP:
543 0 : nVertOrient = VertOrientation::CHAR_BOTTOM;
544 0 : break;
545 : case VertOrientation::LINE_TOP:
546 0 : nVertOrient = VertOrientation::LINE_BOTTOM;
547 0 : break;
548 : }
549 0 : break;
550 : }
551 1 : pVertOrient->maValue <<= nVertOrient;
552 1 : pVertOrientRelAsChar->mnIndex = -1;
553 : }
554 :
555 : FontDefaultsCheck( pFontFamilyName,
556 : pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
557 834 : &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
558 :
559 : FontDefaultsCheck( pFontFamilyNameCJK,
560 : pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
561 834 : &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
562 :
563 : FontDefaultsCheck( pFontFamilyNameCTL,
564 : pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
565 834 : &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
566 :
567 : // #i5775# don't overwrite %transparency with binary transparency
568 834 : if( ( pBackTransparency != NULL ) && ( pBackTransparent != NULL ) )
569 : {
570 0 : if( ! *(sal_Bool*)(pBackTransparent->maValue.getValue()) )
571 0 : pBackTransparent->mnIndex = -1;
572 : }
573 :
574 :
575 : // insert newly created properties. This inavlidates all iterators!
576 : // Most of the pXXX variables in this method are iterators and will be
577 : // invalidated!!!
578 :
579 834 : if( pNewFontStyleName )
580 : {
581 20 : rProperties.push_back( *pNewFontStyleName );
582 20 : delete pNewFontStyleName;
583 : }
584 :
585 834 : if( pNewFontFamily )
586 : {
587 0 : rProperties.push_back( *pNewFontFamily );
588 0 : delete pNewFontFamily;
589 : }
590 :
591 834 : if( pNewFontPitch )
592 : {
593 0 : rProperties.push_back( *pNewFontPitch );
594 0 : delete pNewFontPitch;
595 : }
596 :
597 834 : if( pNewFontCharSet )
598 : {
599 20 : rProperties.push_back( *pNewFontCharSet );
600 20 : delete pNewFontCharSet;
601 : }
602 :
603 834 : if( pNewFontStyleNameCJK )
604 : {
605 8 : rProperties.push_back( *pNewFontStyleNameCJK );
606 8 : delete pNewFontStyleNameCJK;
607 : }
608 :
609 834 : if( pNewFontFamilyCJK )
610 : {
611 1 : rProperties.push_back( *pNewFontFamilyCJK );
612 1 : delete pNewFontFamilyCJK;
613 : }
614 :
615 834 : if( pNewFontPitchCJK )
616 : {
617 0 : rProperties.push_back( *pNewFontPitchCJK );
618 0 : delete pNewFontPitchCJK;
619 : }
620 :
621 834 : if( pNewFontCharSetCJK )
622 : {
623 8 : rProperties.push_back( *pNewFontCharSetCJK );
624 8 : delete pNewFontCharSetCJK;
625 : }
626 :
627 834 : if( pNewFontStyleNameCTL)
628 : {
629 8 : rProperties.push_back( *pNewFontStyleNameCTL );
630 8 : delete pNewFontStyleNameCTL;
631 : }
632 :
633 834 : if( pNewFontFamilyCTL )
634 : {
635 1 : rProperties.push_back( *pNewFontFamilyCTL );
636 1 : delete pNewFontFamilyCTL;
637 : }
638 :
639 834 : if( pNewFontPitchCTL )
640 : {
641 0 : rProperties.push_back( *pNewFontPitchCTL );
642 0 : delete pNewFontPitchCTL;
643 : }
644 :
645 834 : if( pNewFontCharSetCTL )
646 : {
647 8 : rProperties.push_back( *pNewFontCharSetCTL );
648 8 : delete pNewFontCharSetCTL;
649 : }
650 :
651 4170 : for (sal_uInt16 i=0; i<4; i++)
652 : {
653 3336 : if (pNewParaMargins[i].get())
654 : {
655 2 : rProperties.push_back(*pNewParaMargins[i]);
656 : }
657 3336 : if (pNewMargins[i].get())
658 : {
659 0 : rProperties.push_back(*pNewMargins[i]);
660 : }
661 3336 : if( pNewBorderDistances[i] )
662 : {
663 8 : rProperties.push_back( *pNewBorderDistances[i] );
664 8 : delete pNewBorderDistances[i];
665 : }
666 3336 : if( pNewBorders[i] )
667 : {
668 8 : rProperties.push_back( *pNewBorders[i] );
669 8 : delete pNewBorders[i];
670 : }
671 : }
672 :
673 834 : if( bHasAnyHeight )
674 : {
675 1 : if( nSizeTypeIndex == -2 )
676 : {
677 : const_cast < XMLTextImportPropertyMapper * > ( this )
678 1 : ->nSizeTypeIndex = -1;
679 1 : sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
680 170 : for( sal_Int32 j=0; j < nPropCount; j++ )
681 : {
682 340 : if( CTF_SIZETYPE == getPropertySetMapper()
683 170 : ->GetEntryContextId( j ) )
684 : {
685 : const_cast < XMLTextImportPropertyMapper * > ( this )
686 1 : ->nSizeTypeIndex = j;
687 1 : break;
688 : }
689 : }
690 : }
691 1 : if( nSizeTypeIndex != -1 )
692 : {
693 1 : XMLPropertyState aSizeTypeState( nSizeTypeIndex );
694 : aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinHeight
695 : ? SizeType::MIN
696 1 : : SizeType::FIX);
697 1 : rProperties.push_back( aSizeTypeState );
698 : }
699 : }
700 :
701 834 : if( bHasAnyWidth )
702 : {
703 1 : if( nWidthTypeIndex == -2 )
704 : {
705 : const_cast < XMLTextImportPropertyMapper * > ( this )
706 1 : ->nWidthTypeIndex = -1;
707 1 : sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
708 165 : for( sal_Int32 j=0; j < nCount; j++ )
709 : {
710 330 : if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper()
711 165 : ->GetEntryContextId( j ) )
712 : {
713 : const_cast < XMLTextImportPropertyMapper * > ( this )
714 1 : ->nWidthTypeIndex = j;
715 1 : break;
716 : }
717 : }
718 : }
719 1 : if( nWidthTypeIndex != -1 )
720 : {
721 1 : XMLPropertyState aSizeTypeState( nWidthTypeIndex );
722 : aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinWidth
723 : ? SizeType::MIN
724 1 : : SizeType::FIX);
725 1 : rProperties.push_back( aSizeTypeState );
726 : }
727 7506 : }
728 :
729 : // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
730 : // THIS LINE. All iterators into the rProperties-vector, especially all
731 : // pXXX-type variables set in the first switch statement of this method,
732 : // may have been invalidated by the above push_back() calls!
733 834 : }
734 :
735 :
736 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|