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 :
37 :
38 : using namespace ::com::sun::star;
39 : using namespace ::com::sun::star::uno;
40 : using namespace ::com::sun::star::table;
41 : using namespace ::com::sun::star::text;
42 :
43 4727 : bool XMLTextImportPropertyMapper::handleSpecialItem(
44 : XMLPropertyState& rProperty,
45 : ::std::vector< XMLPropertyState >& rProperties,
46 : const OUString& rValue,
47 : const SvXMLUnitConverter& rUnitConverter,
48 : const SvXMLNamespaceMap& rNamespaceMap ) const
49 : {
50 4727 : sal_Bool bRet = sal_False;
51 4727 : sal_Int32 nIndex = rProperty.mnIndex;
52 4727 : switch( getPropertySetMapper()->GetEntryContextId( nIndex ) )
53 : {
54 : case CTF_FONTNAME:
55 : case CTF_FONTNAME_CJK:
56 : case CTF_FONTNAME_CTL:
57 3782 : if( GetImport().GetFontDecls() != NULL )
58 : {
59 : DBG_ASSERT(
60 : ( CTF_FONTFAMILYNAME ==
61 : getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
62 : CTF_FONTSTYLENAME ==
63 : getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
64 : CTF_FONTFAMILY ==
65 : getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
66 : CTF_FONTPITCH ==
67 : getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
68 : CTF_FONTCHARSET ==
69 : getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
70 : ( CTF_FONTFAMILYNAME_CJK ==
71 : getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
72 : CTF_FONTSTYLENAME_CJK ==
73 : getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
74 : CTF_FONTFAMILY_CJK ==
75 : getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
76 : CTF_FONTPITCH_CJK ==
77 : getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
78 : CTF_FONTCHARSET_CJK ==
79 : getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
80 : ( CTF_FONTFAMILYNAME_CTL ==
81 : getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
82 : CTF_FONTSTYLENAME_CTL ==
83 : getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
84 : CTF_FONTFAMILY_CTL ==
85 : getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
86 : CTF_FONTPITCH_CTL ==
87 : getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
88 : CTF_FONTCHARSET_CTL ==
89 : getPropertySetMapper()->GetEntryContextId(nIndex+5) ),
90 : "illegal property map" );
91 :
92 3782 : GetImport().GetFontDecls()->FillProperties(
93 : rValue, rProperties,
94 : rProperty.mnIndex+1, rProperty.mnIndex+2,
95 : rProperty.mnIndex+3, rProperty.mnIndex+4,
96 7564 : rProperty.mnIndex+5 );
97 3782 : bRet = sal_False; // the property hasn't been filled
98 : }
99 3782 : break;
100 :
101 : // If we want to do StarMath/StarSymbol font conversion, then we'll
102 : // want these special items to be treated just like regular ones...
103 : // For the Writer, we'll catch and convert them in _FillPropertySet;
104 : // the other apps probably don't care. For the other apps, we just
105 : // imitate the default non-special-item mechanism.
106 : case CTF_FONTFAMILYNAME:
107 : case CTF_FONTFAMILYNAME_CJK:
108 : case CTF_FONTFAMILYNAME_CTL:
109 935 : bRet = getPropertySetMapper()->importXML( rValue, rProperty,
110 935 : rUnitConverter );
111 935 : break;
112 :
113 : case CTF_TEXT_DISPLAY:
114 10 : bRet = getPropertySetMapper()->importXML( rValue, rProperty,
115 10 : rUnitConverter );
116 10 : if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
117 : {
118 : sal_Bool bHidden;
119 0 : rProperty.maValue >>= bHidden;
120 0 : bHidden = !bHidden;
121 0 : rProperty.maValue <<= bHidden;
122 : }
123 10 : break;
124 : default:
125 : bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
126 0 : rProperties, rValue, rUnitConverter, rNamespaceMap );
127 0 : break;
128 : }
129 :
130 4727 : return bRet;
131 : }
132 :
133 5897 : XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
134 : const UniReference< XMLPropertySetMapper >& rMapper,
135 : SvXMLImport& rImp ) :
136 : SvXMLImportPropertyMapper( rMapper, rImp ),
137 : nSizeTypeIndex( -2 ),
138 5897 : nWidthTypeIndex( -2 )
139 : {
140 5897 : }
141 :
142 11774 : XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
143 : {
144 11774 : }
145 :
146 3865 : void XMLTextImportPropertyMapper::FontFinished(
147 : XMLPropertyState *pFontFamilyNameState,
148 : XMLPropertyState *pFontStyleNameState,
149 : XMLPropertyState *pFontFamilyState,
150 : XMLPropertyState *pFontPitchState,
151 : XMLPropertyState *pFontCharsetState ) const
152 : {
153 3865 : if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
154 : {
155 3865 : OUString sName;
156 3865 : pFontFamilyNameState->maValue >>= sName;
157 3865 : if( sName.isEmpty() )
158 50 : pFontFamilyNameState->mnIndex = -1;
159 : }
160 3865 : if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
161 : {
162 50 : if( pFontStyleNameState )
163 50 : pFontStyleNameState->mnIndex = -1;
164 50 : if( pFontFamilyState )
165 50 : pFontFamilyState->mnIndex = -1;
166 50 : if( pFontPitchState )
167 50 : pFontPitchState->mnIndex = -1;
168 50 : if( pFontCharsetState )
169 50 : pFontCharsetState->mnIndex = -1;
170 : }
171 3865 : }
172 :
173 : /** since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily",
174 : "CharFontPitch" and "CharFontSet" and theire CJK and CTL counterparts are only
175 : usable as a union, we add defaults to all values that are not set as long as we
176 : have an "CharFontFamilyName"
177 :
178 : #99928# CL */
179 19260 : void XMLTextImportPropertyMapper::FontDefaultsCheck(
180 : XMLPropertyState* pFontFamilyName,
181 : XMLPropertyState* pFontStyleName,
182 : XMLPropertyState* pFontFamily,
183 : XMLPropertyState* pFontPitch,
184 : XMLPropertyState* pFontCharSet,
185 : XMLPropertyState** ppNewFontStyleName,
186 : XMLPropertyState** ppNewFontFamily,
187 : XMLPropertyState** ppNewFontPitch,
188 : XMLPropertyState** ppNewFontCharSet ) const
189 : {
190 19260 : if( pFontFamilyName )
191 : {
192 3865 : OUString sEmpty;
193 7730 : Any aAny;
194 :
195 3865 : if( !pFontStyleName )
196 : {
197 99 : aAny <<= sEmpty;
198 : #ifdef DBG_UTIL
199 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
200 : pFontFamilyName->mnIndex + 1 );
201 : DBG_ASSERT( nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL,
202 : "wrong property context id" );
203 : #endif
204 : *ppNewFontStyleName = new XMLPropertyState( pFontFamilyName->mnIndex + 1,
205 99 : aAny );
206 : }
207 :
208 3865 : if( !pFontFamily )
209 : {
210 2 : aAny <<= (sal_Int16)com::sun::star::awt::FontFamily::DONTKNOW;
211 :
212 : #ifdef DBG_UTIL
213 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
214 : pFontFamilyName->mnIndex + 2 );
215 : DBG_ASSERT( nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL,
216 : "wrong property context id" );
217 : #endif
218 : *ppNewFontFamily = new XMLPropertyState( pFontFamilyName->mnIndex + 2,
219 2 : aAny );
220 : }
221 :
222 3865 : if( !pFontPitch )
223 : {
224 0 : aAny <<= (sal_Int16)com::sun::star::awt::FontPitch::DONTKNOW;
225 : #ifdef DBG_UTIL
226 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
227 : pFontFamilyName->mnIndex + 3 );
228 : DBG_ASSERT( nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL,
229 : "wrong property context id" );
230 : #endif
231 : *ppNewFontPitch = new XMLPropertyState( pFontFamilyName->mnIndex + 3,
232 0 : aAny );
233 : }
234 :
235 3865 : if( !pFontCharSet )
236 : {
237 99 : aAny <<= (sal_Int16)osl_getThreadTextEncoding();
238 : #ifdef DBG_UTIL
239 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
240 : pFontFamilyName->mnIndex + 4 );
241 : DBG_ASSERT( nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL,
242 : "wrong property context id" );
243 : #endif
244 : *ppNewFontCharSet = new XMLPropertyState( pFontFamilyName->mnIndex + 4,
245 99 : aAny );
246 3865 : }
247 : }
248 19260 : }
249 :
250 : namespace {
251 : //fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
252 : //a flag that the value is an absolute value so we can't truly handle an
253 : //up/lower space property which wants to specify its 200% upper but 100% lower
254 : //of its parent (try typing 100% vs 200% into the edit style dialog and revisit
255 : //your style). So on xml load that ends up meaning 200%, 0 lower. This is a
256 : //crock.
257 :
258 : //On import clear 100% all-margins relative sizes.
259 : static bool
260 2 : isNotDefaultRelSize(const XMLPropertyState* pRelState, const UniReference<XMLPropertySetMapper>& rPrMap)
261 : {
262 2 : if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
263 : {
264 2 : sal_Int32 nTemp = 0;
265 2 : pRelState->maValue >>= nTemp;
266 2 : return nTemp != 100;
267 : }
268 0 : return true;
269 : }
270 :
271 : /**
272 : * Separate compressed border attributes.
273 : * During export, border attributes are compressed if there are equal to all four side.
274 : * Since Writer hasn't the same compressed attributes, but has distinct ones for all
275 : * four side, we have to duplicate the compressed attribute during import.
276 : **/
277 51360 : static void lcl_SeparateBorder(
278 : sal_uInt16 nIndex, XMLPropertyState* pAllBorderDistance,
279 : XMLPropertyState* pBorderDistances[4], XMLPropertyState* pNewBorderDistances[4],
280 : XMLPropertyState* pAllBorder, XMLPropertyState* pBorders[4],
281 : XMLPropertyState* pNewBorders[4], XMLPropertyState* pAllBorderWidth,
282 : XMLPropertyState* pBorderWidths[4]
283 : #ifdef DBG_UTIL
284 : , const UniReference< XMLPropertySetMapper >& rMapper
285 : #endif
286 : )
287 : {
288 51360 : if( pAllBorderDistance && !pBorderDistances[nIndex] )
289 : {
290 : #ifdef DBG_UTIL
291 : sal_Int16 nTmp = rMapper->GetEntryContextId(
292 : pAllBorderDistance->mnIndex + nIndex + 1 );
293 : DBG_ASSERT( nTmp >= CTF_LEFTBORDERDISTANCE &&
294 : nTmp <= CTF_BOTTOMBORDERDISTANCE,
295 : "wrong property context id" );
296 : #endif
297 208 : pNewBorderDistances[nIndex] =
298 208 : new XMLPropertyState( pAllBorderDistance->mnIndex + nIndex + 1,
299 624 : pAllBorderDistance->maValue );
300 208 : pBorderDistances[nIndex] = pNewBorderDistances[nIndex];
301 : }
302 51360 : if( pAllBorder && !pBorders[nIndex] )
303 : {
304 : #ifdef DBG_UTIL
305 : sal_Int16 nTmp = rMapper->GetEntryContextId(
306 : pAllBorder->mnIndex + nIndex + 1 );
307 : DBG_ASSERT( nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER,
308 : "wrong property context id" );
309 : #endif
310 576 : pNewBorders[nIndex] = new XMLPropertyState( pAllBorder->mnIndex + nIndex + 1,
311 864 : pAllBorder->maValue );
312 288 : pBorders[nIndex] = pNewBorders[nIndex];
313 : }
314 51360 : if( !pBorderWidths[nIndex] )
315 51351 : pBorderWidths[nIndex] = pAllBorderWidth;
316 : else
317 9 : pBorderWidths[nIndex]->mnIndex = -1;
318 :
319 51360 : if( pBorders[nIndex] && pBorderWidths[nIndex] )
320 : {
321 21 : table::BorderLine2 aBorderLine;
322 21 : pBorders[nIndex]->maValue >>= aBorderLine;
323 :
324 21 : table::BorderLine2 aBorderLineWidth;
325 21 : pBorderWidths[nIndex]->maValue >>= aBorderLineWidth;
326 :
327 21 : aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
328 21 : aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
329 21 : aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
330 21 : aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
331 :
332 21 : pBorders[nIndex]->maValue <<= aBorderLine;
333 : }
334 51360 : }
335 :
336 : }
337 :
338 6420 : void XMLTextImportPropertyMapper::finished(
339 : ::std::vector< XMLPropertyState >& rProperties,
340 : sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
341 : {
342 6420 : sal_Bool bHasAnyHeight = sal_False;
343 6420 : sal_Bool bHasAnyMinHeight = sal_False;
344 6420 : sal_Bool bHasAnyWidth = sal_False;
345 6420 : sal_Bool bHasAnyMinWidth = sal_False;
346 :
347 6420 : XMLPropertyState* pFontFamilyName = 0;
348 6420 : XMLPropertyState* pFontStyleName = 0;
349 6420 : XMLPropertyState* pFontFamily = 0;
350 6420 : XMLPropertyState* pFontPitch = 0;
351 6420 : XMLPropertyState* pFontCharSet = 0;
352 6420 : XMLPropertyState* pNewFontStyleName = 0;
353 6420 : XMLPropertyState* pNewFontFamily = 0;
354 6420 : XMLPropertyState* pNewFontPitch = 0;
355 6420 : XMLPropertyState* pNewFontCharSet = 0;
356 6420 : XMLPropertyState* pFontFamilyNameCJK = 0;
357 6420 : XMLPropertyState* pFontStyleNameCJK = 0;
358 6420 : XMLPropertyState* pFontFamilyCJK = 0;
359 6420 : XMLPropertyState* pFontPitchCJK = 0;
360 6420 : XMLPropertyState* pFontCharSetCJK = 0;
361 6420 : XMLPropertyState* pNewFontStyleNameCJK = 0;
362 6420 : XMLPropertyState* pNewFontFamilyCJK = 0;
363 6420 : XMLPropertyState* pNewFontPitchCJK = 0;
364 6420 : XMLPropertyState* pNewFontCharSetCJK = 0;
365 6420 : XMLPropertyState* pFontFamilyNameCTL = 0;
366 6420 : XMLPropertyState* pFontStyleNameCTL = 0;
367 6420 : XMLPropertyState* pFontFamilyCTL = 0;
368 6420 : XMLPropertyState* pFontPitchCTL = 0;
369 6420 : XMLPropertyState* pFontCharSetCTL = 0;
370 6420 : XMLPropertyState* pNewFontStyleNameCTL = 0;
371 6420 : XMLPropertyState* pNewFontFamilyCTL = 0;
372 6420 : XMLPropertyState* pNewFontPitchCTL = 0;
373 6420 : XMLPropertyState* pNewFontCharSetCTL = 0;
374 6420 : XMLPropertyState* pAllBorderDistance = 0;
375 6420 : XMLPropertyState* pBorderDistances[4] = { 0, 0, 0, 0 };
376 6420 : XMLPropertyState* pNewBorderDistances[4] = { 0, 0, 0, 0 };
377 6420 : XMLPropertyState* pAllBorder = 0;
378 6420 : XMLPropertyState* pBorders[4] = { 0, 0, 0, 0 };
379 6420 : XMLPropertyState* pNewBorders[4] = { 0, 0, 0, 0 };
380 6420 : XMLPropertyState* pAllBorderWidth = 0;
381 6420 : XMLPropertyState* pBorderWidths[4] = { 0, 0, 0, 0 };
382 6420 : XMLPropertyState* pCharAllBorderDistance = 0;
383 6420 : XMLPropertyState* pCharBorderDistances[4] = { 0, 0, 0, 0 };
384 6420 : XMLPropertyState* pCharNewBorderDistances[4] = { 0, 0, 0, 0 };
385 6420 : XMLPropertyState* pCharAllBorder = 0;
386 6420 : XMLPropertyState* pCharBorders[4] = { 0, 0, 0, 0 };
387 6420 : XMLPropertyState* pCharNewBorders[4] = { 0, 0, 0, 0 };
388 6420 : XMLPropertyState* pCharAllBorderWidth = 0;
389 6420 : XMLPropertyState* pCharBorderWidths[4] = { 0, 0, 0, 0 };
390 6420 : XMLPropertyState* pVertOrient = 0;
391 6420 : XMLPropertyState* pVertOrientRelAsChar = 0;
392 6420 : XMLPropertyState* pBackTransparency = NULL; // transparency in %
393 6420 : XMLPropertyState* pBackTransparent = NULL; // transparency as boolean
394 6420 : XMLPropertyState* pAllParaMargin = 0;
395 6420 : XMLPropertyState* pParaMargins[4] = { 0, 0, 0, 0 };
396 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
397 32100 : ::std::auto_ptr<XMLPropertyState> pNewParaMargins[4];
398 : SAL_WNODEPRECATED_DECLARATIONS_POP
399 6420 : XMLPropertyState* pAllMargin = 0;
400 6420 : XMLPropertyState* pMargins[4] = { 0, 0, 0, 0 };
401 : SAL_WNODEPRECATED_DECLARATIONS_PUSH
402 12840 : ::std::auto_ptr<XMLPropertyState> pNewMargins[4];
403 : SAL_WNODEPRECATED_DECLARATIONS_POP
404 :
405 211941 : for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
406 141294 : aIter != rProperties.end();
407 : ++aIter )
408 : {
409 64227 : XMLPropertyState* property = &(*aIter);
410 64227 : if( -1 == property->mnIndex )
411 1034 : continue;
412 :
413 63193 : switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
414 : {
415 1429 : case CTF_FONTFAMILYNAME: pFontFamilyName = property; break;
416 1235 : case CTF_FONTSTYLENAME: pFontStyleName = property; break;
417 1423 : case CTF_FONTFAMILY: pFontFamily = property; break;
418 1413 : case CTF_FONTPITCH: pFontPitch = property; break;
419 1231 : case CTF_FONTCHARSET: pFontCharSet = property; break;
420 :
421 1269 : case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJK = property; break;
422 1106 : case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property; break;
423 1263 : case CTF_FONTFAMILY_CJK: pFontFamilyCJK = property; break;
424 1269 : case CTF_FONTPITCH_CJK: pFontPitchCJK = property; break;
425 1106 : case CTF_FONTCHARSET_CJK: pFontCharSetCJK = property; break;
426 :
427 1713 : case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTL = property; break;
428 1429 : case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property; break;
429 1681 : case CTF_FONTFAMILY_CTL: pFontFamilyCTL = property; break;
430 1589 : case CTF_FONTPITCH_CTL: pFontPitchCTL = property; break;
431 1429 : case CTF_FONTCHARSET_CTL: pFontCharSetCTL = property; break;
432 :
433 34 : case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break;
434 33 : case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break;
435 33 : case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break;
436 33 : case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break;
437 33 : case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break;
438 54 : case CTF_ALLBORDER: pAllBorder = property; break;
439 12 : case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break;
440 12 : case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break;
441 12 : case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break;
442 12 : case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break;
443 3 : case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break;
444 1 : case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break;
445 2 : case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break;
446 0 : case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break;
447 2 : case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break;
448 :
449 18 : case CTF_CHARALLBORDERDISTANCE: pCharAllBorderDistance = property; break;
450 12 : case CTF_CHARLEFTBORDERDISTANCE: pCharBorderDistances[XML_LINE_LEFT] = property; break;
451 12 : case CTF_CHARRIGHTBORDERDISTANCE: pCharBorderDistances[XML_LINE_RIGHT] = property; break;
452 12 : case CTF_CHARTOPBORDERDISTANCE: pCharBorderDistances[XML_LINE_TOP] = property; break;
453 12 : case CTF_CHARBOTTOMBORDERDISTANCE: pCharBorderDistances[XML_LINE_BOTTOM] = property; break;
454 18 : case CTF_CHARALLBORDER: pCharAllBorder = property; break;
455 12 : case CTF_CHARLEFTBORDER: pCharBorders[XML_LINE_LEFT] = property; break;
456 12 : case CTF_CHARRIGHTBORDER: pCharBorders[XML_LINE_RIGHT] = property; break;
457 12 : case CTF_CHARTOPBORDER: pCharBorders[XML_LINE_TOP] = property; break;
458 12 : case CTF_CHARBOTTOMBORDER: pCharBorders[XML_LINE_BOTTOM] = property; break;
459 0 : case CTF_CHARALLBORDERWIDTH: pCharAllBorderWidth = property; break;
460 0 : case CTF_CHARLEFTBORDERWIDTH: pCharBorderWidths[XML_LINE_LEFT] = property; break;
461 0 : case CTF_CHARRIGHTBORDERWIDTH: pCharBorderWidths[XML_LINE_RIGHT] = property; break;
462 4 : case CTF_CHARTOPBORDERWIDTH: pCharBorderWidths[XML_LINE_TOP] = property; break;
463 0 : case CTF_CHARBOTTOMBORDERWIDTH: pCharBorderWidths[XML_LINE_BOTTOM] = property; break;
464 :
465 217 : case CTF_ANCHORTYPE: break;
466 283 : case CTF_VERTICALPOS: pVertOrient = property; break;
467 63 : case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
468 :
469 : case CTF_FRAMEHEIGHT_MIN_ABS:
470 : case CTF_FRAMEHEIGHT_MIN_REL:
471 : // case CTF_SYNCHEIGHT_MIN:
472 17 : bHasAnyMinHeight = sal_True;
473 : // no break here!
474 : case CTF_FRAMEHEIGHT_ABS:
475 : case CTF_FRAMEHEIGHT_REL:
476 : // case CTF_SYNCHEIGHT:
477 174 : bHasAnyHeight = sal_True; break;
478 : case CTF_FRAMEWIDTH_MIN_ABS:
479 : case CTF_FRAMEWIDTH_MIN_REL:
480 12 : bHasAnyMinWidth = sal_True;
481 : // no break here!
482 : case CTF_FRAMEWIDTH_ABS:
483 : case CTF_FRAMEWIDTH_REL:
484 172 : bHasAnyWidth = sal_True; break;
485 19 : case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
486 18 : case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break;
487 : case CTF_PARAMARGINALL:
488 : case CTF_PARAMARGINALL_REL:
489 18 : pAllParaMargin = property; break;
490 : case CTF_PARALEFTMARGIN:
491 : case CTF_PARALEFTMARGIN_REL:
492 635 : pParaMargins[XML_LINE_LEFT] = property; break;
493 : case CTF_PARARIGHTMARGIN:
494 : case CTF_PARARIGHTMARGIN_REL:
495 635 : pParaMargins[XML_LINE_RIGHT] = property; break;
496 : case CTF_PARATOPMARGIN:
497 : case CTF_PARATOPMARGIN_REL:
498 1542 : pParaMargins[XML_LINE_TOP] = property; break;
499 : case CTF_PARABOTTOMMARGIN:
500 : case CTF_PARABOTTOMMARGIN_REL:
501 1542 : pParaMargins[XML_LINE_BOTTOM] = property; break;
502 : case CTF_MARGINALL:
503 0 : pAllMargin = property; break;
504 : case CTF_MARGINLEFT:
505 48 : pMargins[XML_LINE_LEFT] = property; break;
506 : case CTF_MARGINRIGHT:
507 48 : pMargins[XML_LINE_RIGHT] = property; break;
508 : case CTF_MARGINTOP:
509 45 : pMargins[XML_LINE_TOP] = property; break;
510 : case CTF_MARGINBOTTOM:
511 45 : pMargins[XML_LINE_BOTTOM] = property; break;
512 : }
513 : }
514 :
515 6420 : if( pFontFamilyName || pFontStyleName || pFontFamily ||
516 5135 : pFontPitch || pFontCharSet )
517 : FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
518 1285 : pFontPitch, pFontCharSet );
519 6420 : if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
520 5291 : pFontPitchCJK || pFontCharSetCJK )
521 : FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
522 1129 : pFontPitchCJK, pFontCharSetCJK );
523 6420 : if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
524 4969 : pFontPitchCTL || pFontCharSetCTL )
525 : FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
526 1451 : pFontPitchCTL, pFontCharSetCTL );
527 :
528 32100 : for (sal_uInt16 i = 0; i < 4; i++)
529 : {
530 25752 : if (pAllParaMargin && !pParaMargins[i]
531 25682 : && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
532 : {
533 : #if OSL_DEBUG_LEVEL > 0
534 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
535 : pAllParaMargin->mnIndex + (2*i) + 2 );
536 : OSL_ENSURE( nTmp >= CTF_PARALEFTMARGIN &&
537 : nTmp <= CTF_PARABOTTOMMARGIN_REL,
538 : "wrong property context id" );
539 : #endif
540 0 : pNewParaMargins[i].reset(new XMLPropertyState(
541 0 : pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue));
542 : }
543 25680 : if (pAllMargin && !pMargins[i])
544 : {
545 : #if OSL_DEBUG_LEVEL > 0
546 : sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
547 : pAllMargin->mnIndex + i + 1 );
548 : OSL_ENSURE( nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM,
549 : "wrong property context id" );
550 : #endif
551 0 : pNewMargins[i].reset(new XMLPropertyState(
552 0 : pAllMargin->mnIndex + i + 1, pAllMargin->maValue));
553 : }
554 :
555 : lcl_SeparateBorder(
556 : i, pAllBorderDistance, pBorderDistances, pNewBorderDistances,
557 : pAllBorder, pBorders, pNewBorders,
558 : pAllBorderWidth, pBorderWidths
559 : #ifdef DBG_UTIL
560 : , getPropertySetMapper()
561 : #endif
562 25680 : );
563 :
564 : lcl_SeparateBorder(
565 : i, pCharAllBorderDistance, pCharBorderDistances,
566 : pCharNewBorderDistances, pCharAllBorder, pCharBorders,
567 : pCharNewBorders, pCharAllBorderWidth, pCharBorderWidths
568 : #ifdef DBG_UTIL
569 : , getPropertySetMapper()
570 : #endif
571 25680 : );
572 : }
573 :
574 6420 : if (pAllParaMargin)
575 : {
576 18 : pAllParaMargin->mnIndex = -1;
577 : }
578 6420 : if (pAllMargin)
579 : {
580 0 : pAllMargin->mnIndex = -1;
581 : }
582 :
583 6420 : if( pAllBorderDistance )
584 34 : pAllBorderDistance->mnIndex = -1;
585 :
586 6420 : if( pAllBorder )
587 54 : pAllBorder->mnIndex = -1;
588 :
589 6420 : if( pAllBorderWidth )
590 3 : pAllBorderWidth->mnIndex = -1;
591 :
592 6420 : if( pCharAllBorderDistance )
593 18 : pCharAllBorderDistance->mnIndex = -1;
594 :
595 6420 : if( pCharAllBorder )
596 18 : pCharAllBorder->mnIndex = -1;
597 :
598 6420 : if( pCharAllBorderWidth )
599 0 : pCharAllBorderWidth->mnIndex = -1;
600 :
601 6420 : if( pVertOrient && pVertOrientRelAsChar )
602 : {
603 : sal_Int16 nVertOrient;
604 63 : pVertOrient->maValue >>= nVertOrient;
605 63 : sal_Int16 nVertOrientRel = 0;
606 63 : pVertOrientRelAsChar->maValue >>= nVertOrientRel;
607 63 : switch( nVertOrient )
608 : {
609 : case VertOrientation::TOP:
610 20 : nVertOrient = nVertOrientRel;
611 20 : break;
612 : case VertOrientation::CENTER:
613 36 : switch( nVertOrientRel )
614 : {
615 : case VertOrientation::CHAR_TOP:
616 2 : nVertOrient = VertOrientation::CHAR_CENTER;
617 2 : break;
618 : case VertOrientation::LINE_TOP:
619 34 : nVertOrient = VertOrientation::LINE_CENTER;
620 34 : break;
621 : }
622 36 : break;
623 : case VertOrientation::BOTTOM:
624 0 : switch( nVertOrientRel )
625 : {
626 : case VertOrientation::CHAR_TOP:
627 0 : nVertOrient = VertOrientation::CHAR_BOTTOM;
628 0 : break;
629 : case VertOrientation::LINE_TOP:
630 0 : nVertOrient = VertOrientation::LINE_BOTTOM;
631 0 : break;
632 : }
633 0 : break;
634 : }
635 63 : pVertOrient->maValue <<= nVertOrient;
636 63 : pVertOrientRelAsChar->mnIndex = -1;
637 : }
638 :
639 : FontDefaultsCheck( pFontFamilyName,
640 : pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
641 6420 : &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
642 :
643 : FontDefaultsCheck( pFontFamilyNameCJK,
644 : pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
645 6420 : &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
646 :
647 : FontDefaultsCheck( pFontFamilyNameCTL,
648 : pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
649 6420 : &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
650 :
651 : // #i5775# don't overwrite %transparency with binary transparency
652 6420 : if( ( pBackTransparency != NULL ) && ( pBackTransparent != NULL ) )
653 : {
654 17 : if( ! *(sal_Bool*)(pBackTransparent->maValue.getValue()) )
655 17 : pBackTransparent->mnIndex = -1;
656 : }
657 :
658 :
659 : // insert newly created properties. This invalidates all iterators!
660 : // Most of the pXXX variables in this method are iterators and will be
661 : // invalidated!!!
662 :
663 6420 : if( pNewFontStyleName )
664 : {
665 54 : rProperties.push_back( *pNewFontStyleName );
666 54 : delete pNewFontStyleName;
667 : }
668 :
669 6420 : if( pNewFontFamily )
670 : {
671 0 : rProperties.push_back( *pNewFontFamily );
672 0 : delete pNewFontFamily;
673 : }
674 :
675 6420 : if( pNewFontPitch )
676 : {
677 0 : rProperties.push_back( *pNewFontPitch );
678 0 : delete pNewFontPitch;
679 : }
680 :
681 6420 : if( pNewFontCharSet )
682 : {
683 54 : rProperties.push_back( *pNewFontCharSet );
684 54 : delete pNewFontCharSet;
685 : }
686 :
687 6420 : if( pNewFontStyleNameCJK )
688 : {
689 23 : rProperties.push_back( *pNewFontStyleNameCJK );
690 23 : delete pNewFontStyleNameCJK;
691 : }
692 :
693 6420 : if( pNewFontFamilyCJK )
694 : {
695 1 : rProperties.push_back( *pNewFontFamilyCJK );
696 1 : delete pNewFontFamilyCJK;
697 : }
698 :
699 6420 : if( pNewFontPitchCJK )
700 : {
701 0 : rProperties.push_back( *pNewFontPitchCJK );
702 0 : delete pNewFontPitchCJK;
703 : }
704 :
705 6420 : if( pNewFontCharSetCJK )
706 : {
707 23 : rProperties.push_back( *pNewFontCharSetCJK );
708 23 : delete pNewFontCharSetCJK;
709 : }
710 :
711 6420 : if( pNewFontStyleNameCTL)
712 : {
713 22 : rProperties.push_back( *pNewFontStyleNameCTL );
714 22 : delete pNewFontStyleNameCTL;
715 : }
716 :
717 6420 : if( pNewFontFamilyCTL )
718 : {
719 1 : rProperties.push_back( *pNewFontFamilyCTL );
720 1 : delete pNewFontFamilyCTL;
721 : }
722 :
723 6420 : if( pNewFontPitchCTL )
724 : {
725 0 : rProperties.push_back( *pNewFontPitchCTL );
726 0 : delete pNewFontPitchCTL;
727 : }
728 :
729 6420 : if( pNewFontCharSetCTL )
730 : {
731 22 : rProperties.push_back( *pNewFontCharSetCTL );
732 22 : delete pNewFontCharSetCTL;
733 : }
734 :
735 32100 : for (sal_uInt16 i=0; i<4; i++)
736 : {
737 25680 : if (pNewParaMargins[i].get())
738 : {
739 0 : rProperties.push_back(*pNewParaMargins[i]);
740 : }
741 25680 : if (pNewMargins[i].get())
742 : {
743 0 : rProperties.push_back(*pNewMargins[i]);
744 : }
745 25680 : if( pNewBorderDistances[i] )
746 : {
747 136 : rProperties.push_back( *pNewBorderDistances[i] );
748 136 : delete pNewBorderDistances[i];
749 : }
750 25680 : if( pNewBorders[i] )
751 : {
752 216 : rProperties.push_back( *pNewBorders[i] );
753 216 : delete pNewBorders[i];
754 : }
755 25680 : if( pCharNewBorderDistances[i] )
756 : {
757 72 : rProperties.push_back( *pCharNewBorderDistances[i] );
758 72 : delete pCharNewBorderDistances[i];
759 : }
760 25680 : if( pCharNewBorders[i] )
761 : {
762 72 : rProperties.push_back( *pCharNewBorders[i] );
763 72 : delete pCharNewBorders[i];
764 : }
765 : }
766 :
767 6420 : if( bHasAnyHeight )
768 : {
769 174 : if( nSizeTypeIndex == -2 )
770 : {
771 : const_cast < XMLTextImportPropertyMapper * > ( this )
772 22 : ->nSizeTypeIndex = -1;
773 22 : sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
774 3740 : for( sal_Int32 j=0; j < nPropCount; j++ )
775 : {
776 7480 : if( CTF_SIZETYPE == getPropertySetMapper()
777 3740 : ->GetEntryContextId( j ) )
778 : {
779 : const_cast < XMLTextImportPropertyMapper * > ( this )
780 22 : ->nSizeTypeIndex = j;
781 22 : break;
782 : }
783 : }
784 : }
785 174 : if( nSizeTypeIndex != -1 )
786 : {
787 174 : XMLPropertyState aSizeTypeState( nSizeTypeIndex );
788 348 : aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinHeight
789 : ? SizeType::MIN
790 174 : : SizeType::FIX);
791 174 : rProperties.push_back( aSizeTypeState );
792 : }
793 : }
794 :
795 6420 : if( bHasAnyWidth )
796 : {
797 172 : if( nWidthTypeIndex == -2 )
798 : {
799 : const_cast < XMLTextImportPropertyMapper * > ( this )
800 20 : ->nWidthTypeIndex = -1;
801 20 : sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
802 3300 : for( sal_Int32 j=0; j < nCount; j++ )
803 : {
804 6600 : if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper()
805 3300 : ->GetEntryContextId( j ) )
806 : {
807 : const_cast < XMLTextImportPropertyMapper * > ( this )
808 20 : ->nWidthTypeIndex = j;
809 20 : break;
810 : }
811 : }
812 : }
813 172 : if( nWidthTypeIndex != -1 )
814 : {
815 172 : XMLPropertyState aSizeTypeState( nWidthTypeIndex );
816 344 : aSizeTypeState.maValue <<= (sal_Int16)( bHasAnyMinWidth
817 : ? SizeType::MIN
818 172 : : SizeType::FIX);
819 172 : rProperties.push_back( aSizeTypeState );
820 : }
821 32100 : }
822 :
823 : // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
824 : // THIS LINE. All iterators into the rProperties-vector, especially all
825 : // pXXX-type variables set in the first switch statement of this method,
826 : // may have been invalidated by the above push_back() calls!
827 6420 : }
828 :
829 :
830 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|