nss: upgrade to release 3.73
[LibreOffice.git] / xmloff / source / text / txtimppr.cxx
blobb2016d5fd88e418245c33739847a3c900bbc71dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <memory>
21 #include <sal/config.h>
23 #include <o3tl/any.hxx>
24 #include <osl/thread.h>
25 #include <com/sun/star/awt/FontFamily.hpp>
26 #include <com/sun/star/awt/FontPitch.hpp>
27 #include <com/sun/star/drawing/FillStyle.hpp>
28 #include <com/sun/star/table/BorderLine2.hpp>
29 #include <com/sun/star/text/VertOrientation.hpp>
30 #include <com/sun/star/text/SizeType.hpp>
31 #include <xmloff/XMLFontStylesContext.hxx>
32 #include <xmloff/txtprmap.hxx>
33 #include <xmloff/xmlimp.hxx>
34 #include <xmloff/txtimppr.hxx>
35 #include <xmloff/maptype.hxx>
37 #define XML_LINE_LEFT 0
38 #define XML_LINE_RIGHT 1
39 #define XML_LINE_TOP 2
40 #define XML_LINE_BOTTOM 3
43 using namespace ::com::sun::star;
44 using namespace ::com::sun::star::uno;
45 using namespace ::com::sun::star::table;
46 using namespace ::com::sun::star::text;
48 bool XMLTextImportPropertyMapper::handleSpecialItem(
49 XMLPropertyState& rProperty,
50 ::std::vector< XMLPropertyState >& rProperties,
51 const OUString& rValue,
52 const SvXMLUnitConverter& rUnitConverter,
53 const SvXMLNamespaceMap& rNamespaceMap ) const
55 bool bRet = false;
56 sal_Int32 nIndex = rProperty.mnIndex;
57 switch( getPropertySetMapper()->GetEntryContextId( nIndex ) )
59 case CTF_FONTNAME:
60 case CTF_FONTNAME_CJK:
61 case CTF_FONTNAME_CTL:
62 if( GetImport().GetFontDecls() != nullptr )
64 assert((
65 ( CTF_FONTFAMILYNAME ==
66 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
67 CTF_FONTSTYLENAME ==
68 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
69 CTF_FONTFAMILY ==
70 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
71 CTF_FONTPITCH ==
72 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
73 CTF_FONTCHARSET ==
74 getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
75 ( CTF_FONTFAMILYNAME_CJK ==
76 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
77 CTF_FONTSTYLENAME_CJK ==
78 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
79 CTF_FONTFAMILY_CJK ==
80 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
81 CTF_FONTPITCH_CJK ==
82 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
83 CTF_FONTCHARSET_CJK ==
84 getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
85 ( CTF_FONTFAMILYNAME_CTL ==
86 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
87 CTF_FONTSTYLENAME_CTL ==
88 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
89 CTF_FONTFAMILY_CTL ==
90 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
91 CTF_FONTPITCH_CTL ==
92 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
93 CTF_FONTCHARSET_CTL ==
94 getPropertySetMapper()->GetEntryContextId(nIndex+5) )
95 ) && "illegal property map" );
97 GetImport().GetFontDecls()->FillProperties(
98 rValue, rProperties,
99 rProperty.mnIndex+1, rProperty.mnIndex+2,
100 rProperty.mnIndex+3, rProperty.mnIndex+4,
101 rProperty.mnIndex+5 );
102 bRet = false; // the property hasn't been filled
104 break;
106 // If we want to do StarMath/StarSymbol font conversion, then we'll
107 // want these special items to be treated just like regular ones...
108 // For the Writer, we'll catch and convert them in _FillPropertySet;
109 // the other apps probably don't care. For the other apps, we just
110 // imitate the default non-special-item mechanism.
111 case CTF_FONTFAMILYNAME:
112 case CTF_FONTFAMILYNAME_CJK:
113 case CTF_FONTFAMILYNAME_CTL:
114 bRet = getPropertySetMapper()->importXML( rValue, rProperty,
115 rUnitConverter );
116 break;
118 case CTF_TEXT_DISPLAY:
119 bRet = getPropertySetMapper()->importXML( rValue, rProperty,
120 rUnitConverter );
121 if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
123 bool bHidden = false;
124 rProperty.maValue >>= bHidden;
125 bHidden = !bHidden;
126 rProperty.maValue <<= bHidden;
128 break;
129 default:
130 bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
131 rProperties, rValue, rUnitConverter, rNamespaceMap );
132 break;
135 return bRet;
138 XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
139 const rtl::Reference< XMLPropertySetMapper >& rMapper,
140 SvXMLImport& rImp ) :
141 SvXMLImportPropertyMapper( rMapper, rImp ),
142 nSizeTypeIndex( -2 ),
143 nWidthTypeIndex( -2 )
147 XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
151 void XMLTextImportPropertyMapper::FontFinished(
152 XMLPropertyState *pFontFamilyNameState,
153 XMLPropertyState *pFontStyleNameState,
154 XMLPropertyState *pFontFamilyState,
155 XMLPropertyState *pFontPitchState,
156 XMLPropertyState *pFontCharsetState )
158 if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
160 OUString sName;
161 pFontFamilyNameState->maValue >>= sName;
162 if( sName.isEmpty() )
163 pFontFamilyNameState->mnIndex = -1;
165 if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
167 if( pFontStyleNameState )
168 pFontStyleNameState->mnIndex = -1;
169 if( pFontFamilyState )
170 pFontFamilyState->mnIndex = -1;
171 if( pFontPitchState )
172 pFontPitchState->mnIndex = -1;
173 if( pFontCharsetState )
174 pFontCharsetState->mnIndex = -1;
178 /** since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily",
179 "CharFontPitch" and "CharFontSet" and their CJK and CTL counterparts are only
180 usable as a union, we add defaults to all values that are not set as long as we
181 have an "CharFontFamilyName"
183 #99928# CL */
184 void XMLTextImportPropertyMapper::FontDefaultsCheck(
185 XMLPropertyState const * pFontFamilyName,
186 XMLPropertyState const * pFontStyleName,
187 XMLPropertyState const * pFontFamily,
188 XMLPropertyState const * pFontPitch,
189 XMLPropertyState const * pFontCharSet,
190 std::unique_ptr<XMLPropertyState>* ppNewFontStyleName,
191 std::unique_ptr<XMLPropertyState>* ppNewFontFamily,
192 std::unique_ptr<XMLPropertyState>* ppNewFontPitch,
193 std::unique_ptr<XMLPropertyState>* ppNewFontCharSet ) const
195 if( pFontFamilyName )
197 Any aAny;
199 if( !pFontStyleName )
201 aAny <<= OUString();
202 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
203 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
204 pFontFamilyName->mnIndex + 1 );
205 assert(nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL);
206 #endif
207 ppNewFontStyleName->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 1,
208 aAny ));
211 if( !pFontFamily )
213 aAny <<= sal_Int16(css::awt::FontFamily::DONTKNOW);
215 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
216 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
217 pFontFamilyName->mnIndex + 2 );
218 assert(nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL);
219 #endif
220 ppNewFontFamily->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 2,
221 aAny ));
224 if( !pFontPitch )
226 aAny <<= sal_Int16(css::awt::FontPitch::DONTKNOW);
227 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
228 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
229 pFontFamilyName->mnIndex + 3 );
230 assert(nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL);
231 #endif
232 ppNewFontPitch->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 3,
233 aAny ));
236 if( !pFontCharSet )
238 aAny <<= static_cast<sal_Int16>(osl_getThreadTextEncoding());
239 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
240 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
241 pFontFamilyName->mnIndex + 4 );
242 assert(nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL);
243 #endif
244 ppNewFontCharSet->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 4,
245 aAny ));
249 (void) this; // avoid loplugin:staticmethods
252 namespace {
253 //fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
254 //a flag that the value is an absolute value so we can't truly handle an
255 //up/lower space property which wants to specify its 200% upper but 100% lower
256 //of its parent (try typing 100% vs 200% into the edit style dialog and revisit
257 //your style). So on xml load that ends up meaning 200%, 0 lower. This is a
258 //crock.
260 //On import clear 100% all-margins relative sizes.
261 bool
262 isNotDefaultRelSize(const XMLPropertyState* pRelState, const rtl::Reference<XMLPropertySetMapper>& rPrMap)
264 if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
266 sal_Int32 nTemp = 0;
267 pRelState->maValue >>= nTemp;
268 return nTemp != 100;
270 return true;
274 * Separate compressed border attributes.
275 * During export, border attributes are compressed if there are equal to all four side.
276 * Since Writer hasn't the same compressed attributes, but has distinct ones for all
277 * four side, we have to duplicate the compressed attribute during import.
279 void lcl_SeparateBorder(
280 sal_uInt16 nIndex, XMLPropertyState const * pAllBorderDistance,
281 XMLPropertyState* pBorderDistances[4], XMLPropertyState* pNewBorderDistances[4],
282 XMLPropertyState const * pAllBorder, XMLPropertyState* pBorders[4],
283 XMLPropertyState* pNewBorders[4], XMLPropertyState* pAllBorderWidth,
284 XMLPropertyState* pBorderWidths[4]
285 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
286 , const rtl::Reference< XMLPropertySetMapper >& rMapper
287 #endif
290 if( pAllBorderDistance && !pBorderDistances[nIndex] )
292 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
293 sal_Int16 nTmp = rMapper->GetEntryContextId(
294 pAllBorderDistance->mnIndex + nIndex + 1 );
295 if (CTF_CHARALLBORDERDISTANCE ==
296 rMapper->GetEntryContextId(pAllBorderDistance->mnIndex))
298 assert(nTmp >= CTF_CHARLEFTBORDERDISTANCE &&
299 nTmp <= CTF_CHARBOTTOMBORDERDISTANCE);
301 else
303 assert(nTmp >= CTF_LEFTBORDERDISTANCE &&
304 nTmp <= CTF_BOTTOMBORDERDISTANCE);
306 #endif
307 pNewBorderDistances[nIndex] =
308 new XMLPropertyState( pAllBorderDistance->mnIndex + nIndex + 1,
309 pAllBorderDistance->maValue );
310 pBorderDistances[nIndex] = pNewBorderDistances[nIndex];
312 if( pAllBorder && !pBorders[nIndex] )
314 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
315 sal_Int16 nTmp = rMapper->GetEntryContextId(
316 pAllBorder->mnIndex + nIndex + 1 );
317 if (CTF_CHARALLBORDER ==
318 rMapper->GetEntryContextId(pAllBorder->mnIndex))
320 assert(nTmp >= CTF_CHARLEFTBORDER && nTmp <= CTF_CHARBOTTOMBORDER);
322 else
324 assert(nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER);
326 #endif
327 pNewBorders[nIndex] = new XMLPropertyState( pAllBorder->mnIndex + nIndex + 1,
328 pAllBorder->maValue );
329 pBorders[nIndex] = pNewBorders[nIndex];
331 if( !pBorderWidths[nIndex] )
332 pBorderWidths[nIndex] = pAllBorderWidth;
333 else
334 pBorderWidths[nIndex]->mnIndex = -1;
336 if( !(pBorders[nIndex] && pBorderWidths[nIndex]) )
337 return;
339 table::BorderLine2 aBorderLine;
340 pBorders[nIndex]->maValue >>= aBorderLine;
342 table::BorderLine2 aBorderLineWidth;
343 pBorderWidths[nIndex]->maValue >>= aBorderLineWidth;
345 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
346 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
347 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
348 aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
350 pBorders[nIndex]->maValue <<= aBorderLine;
355 void XMLTextImportPropertyMapper::finished(
356 ::std::vector< XMLPropertyState >& rProperties,
357 sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
359 bool bHasAnyHeight = false;
360 bool bHasAnyMinHeight = false;
361 bool bHasAnyWidth = false;
362 bool bHasAnyMinWidth = false;
364 XMLPropertyState* pFontFamilyName = nullptr;
365 XMLPropertyState* pFontStyleName = nullptr;
366 XMLPropertyState* pFontFamily = nullptr;
367 XMLPropertyState* pFontPitch = nullptr;
368 XMLPropertyState* pFontCharSet = nullptr;
369 std::unique_ptr<XMLPropertyState> pNewFontStyleName;
370 std::unique_ptr<XMLPropertyState> pNewFontFamily;
371 std::unique_ptr<XMLPropertyState> pNewFontPitch;
372 std::unique_ptr<XMLPropertyState> pNewFontCharSet;
373 XMLPropertyState* pFontFamilyNameCJK = nullptr;
374 XMLPropertyState* pFontStyleNameCJK = nullptr;
375 XMLPropertyState* pFontFamilyCJK = nullptr;
376 XMLPropertyState* pFontPitchCJK = nullptr;
377 XMLPropertyState* pFontCharSetCJK = nullptr;
378 std::unique_ptr<XMLPropertyState> pNewFontStyleNameCJK;
379 std::unique_ptr<XMLPropertyState> pNewFontFamilyCJK;
380 std::unique_ptr<XMLPropertyState> pNewFontPitchCJK;
381 std::unique_ptr<XMLPropertyState> pNewFontCharSetCJK;
382 XMLPropertyState* pFontFamilyNameCTL = nullptr;
383 XMLPropertyState* pFontStyleNameCTL = nullptr;
384 XMLPropertyState* pFontFamilyCTL = nullptr;
385 XMLPropertyState* pFontPitchCTL = nullptr;
386 XMLPropertyState* pFontCharSetCTL = nullptr;
387 std::unique_ptr<XMLPropertyState> pNewFontStyleNameCTL;
388 std::unique_ptr<XMLPropertyState> pNewFontFamilyCTL;
389 std::unique_ptr<XMLPropertyState> pNewFontPitchCTL;
390 std::unique_ptr<XMLPropertyState> pNewFontCharSetCTL;
391 XMLPropertyState* pAllBorderDistance = nullptr;
392 XMLPropertyState* pBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
393 XMLPropertyState* pNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
394 XMLPropertyState* pAllBorder = nullptr;
395 XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr };
396 XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
397 XMLPropertyState* pAllBorderWidth = nullptr;
398 XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
399 XMLPropertyState* pCharAllBorderDistance = nullptr;
400 XMLPropertyState* pCharBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
401 XMLPropertyState* pCharNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
402 XMLPropertyState* pCharAllBorder = nullptr;
403 XMLPropertyState* pCharBorders[4] = { nullptr, nullptr, nullptr, nullptr };
404 XMLPropertyState* pCharNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
405 XMLPropertyState* pCharAllBorderWidth = nullptr;
406 XMLPropertyState* pCharBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
407 XMLPropertyState* pVertOrient = nullptr;
408 XMLPropertyState* pVertOrientRelAsChar = nullptr;
409 XMLPropertyState* pBackTransparency = nullptr; // transparency in %
410 XMLPropertyState* pBackTransparent = nullptr; // transparency as boolean
411 XMLPropertyState* pAllParaMargin = nullptr;
412 XMLPropertyState* pParaMargins[4] = { nullptr, nullptr, nullptr, nullptr };
413 ::std::unique_ptr<XMLPropertyState> pNewParaMargins[4];
414 XMLPropertyState* pAllMargin = nullptr;
415 XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
416 ::std::unique_ptr<XMLPropertyState> pNewMargins[4];
417 XMLPropertyState* pFillStyle(nullptr);
418 XMLPropertyState* pFillColor(nullptr);
420 for( auto& rProperty : rProperties )
422 XMLPropertyState* property = &rProperty;
423 if( -1 == property->mnIndex )
424 continue;
426 switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
428 case CTF_FONTFAMILYNAME: pFontFamilyName = property; break;
429 case CTF_FONTSTYLENAME: pFontStyleName = property; break;
430 case CTF_FONTFAMILY: pFontFamily = property; break;
431 case CTF_FONTPITCH: pFontPitch = property; break;
432 case CTF_FONTCHARSET: pFontCharSet = property; break;
434 case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJK = property; break;
435 case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property; break;
436 case CTF_FONTFAMILY_CJK: pFontFamilyCJK = property; break;
437 case CTF_FONTPITCH_CJK: pFontPitchCJK = property; break;
438 case CTF_FONTCHARSET_CJK: pFontCharSetCJK = property; break;
440 case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTL = property; break;
441 case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property; break;
442 case CTF_FONTFAMILY_CTL: pFontFamilyCTL = property; break;
443 case CTF_FONTPITCH_CTL: pFontPitchCTL = property; break;
444 case CTF_FONTCHARSET_CTL: pFontCharSetCTL = property; break;
446 case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break;
447 case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break;
448 case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break;
449 case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break;
450 case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break;
451 case CTF_ALLBORDER: pAllBorder = property; break;
452 case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break;
453 case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break;
454 case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break;
455 case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break;
456 case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break;
457 case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break;
458 case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break;
459 case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break;
460 case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break;
462 case CTF_CHARALLBORDERDISTANCE: pCharAllBorderDistance = property; break;
463 case CTF_CHARLEFTBORDERDISTANCE: pCharBorderDistances[XML_LINE_LEFT] = property; break;
464 case CTF_CHARRIGHTBORDERDISTANCE: pCharBorderDistances[XML_LINE_RIGHT] = property; break;
465 case CTF_CHARTOPBORDERDISTANCE: pCharBorderDistances[XML_LINE_TOP] = property; break;
466 case CTF_CHARBOTTOMBORDERDISTANCE: pCharBorderDistances[XML_LINE_BOTTOM] = property; break;
467 case CTF_CHARALLBORDER: pCharAllBorder = property; break;
468 case CTF_CHARLEFTBORDER: pCharBorders[XML_LINE_LEFT] = property; break;
469 case CTF_CHARRIGHTBORDER: pCharBorders[XML_LINE_RIGHT] = property; break;
470 case CTF_CHARTOPBORDER: pCharBorders[XML_LINE_TOP] = property; break;
471 case CTF_CHARBOTTOMBORDER: pCharBorders[XML_LINE_BOTTOM] = property; break;
472 case CTF_CHARALLBORDERWIDTH: pCharAllBorderWidth = property; break;
473 case CTF_CHARLEFTBORDERWIDTH: pCharBorderWidths[XML_LINE_LEFT] = property; break;
474 case CTF_CHARRIGHTBORDERWIDTH: pCharBorderWidths[XML_LINE_RIGHT] = property; break;
475 case CTF_CHARTOPBORDERWIDTH: pCharBorderWidths[XML_LINE_TOP] = property; break;
476 case CTF_CHARBOTTOMBORDERWIDTH: pCharBorderWidths[XML_LINE_BOTTOM] = property; break;
478 case CTF_ANCHORTYPE: break;
479 case CTF_VERTICALPOS: pVertOrient = property; break;
480 case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
482 case CTF_FRAMEHEIGHT_MIN_ABS:
483 case CTF_FRAMEHEIGHT_MIN_REL:
484 // case CTF_SYNCHEIGHT_MIN:
485 bHasAnyMinHeight = true;
486 [[fallthrough]];
487 case CTF_FRAMEHEIGHT_ABS:
488 case CTF_FRAMEHEIGHT_REL:
489 // case CTF_SYNCHEIGHT:
490 bHasAnyHeight = true; break;
491 case CTF_FRAMEWIDTH_MIN_ABS:
492 case CTF_FRAMEWIDTH_MIN_REL:
493 bHasAnyMinWidth = true;
494 [[fallthrough]];
495 case CTF_FRAMEWIDTH_ABS:
496 case CTF_FRAMEWIDTH_REL:
497 bHasAnyWidth = true; break;
498 case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
499 case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break;
500 case CTF_FILLSTYLE: pFillStyle = property; break;
501 case CTF_FILLCOLOR: pFillColor = property; break;
502 case CTF_PARAMARGINALL:
503 case CTF_PARAMARGINALL_REL:
504 pAllParaMargin = property; break;
505 case CTF_PARALEFTMARGIN:
506 case CTF_PARALEFTMARGIN_REL:
507 pParaMargins[XML_LINE_LEFT] = property; break;
508 case CTF_PARARIGHTMARGIN:
509 case CTF_PARARIGHTMARGIN_REL:
510 pParaMargins[XML_LINE_RIGHT] = property; break;
511 case CTF_PARATOPMARGIN:
512 case CTF_PARATOPMARGIN_REL:
513 pParaMargins[XML_LINE_TOP] = property; break;
514 case CTF_PARABOTTOMMARGIN:
515 case CTF_PARABOTTOMMARGIN_REL:
516 pParaMargins[XML_LINE_BOTTOM] = property; break;
517 case CTF_MARGINALL:
518 pAllMargin = property; break;
519 case CTF_MARGINLEFT:
520 pMargins[XML_LINE_LEFT] = property; break;
521 case CTF_MARGINRIGHT:
522 pMargins[XML_LINE_RIGHT] = property; break;
523 case CTF_MARGINTOP:
524 pMargins[XML_LINE_TOP] = property; break;
525 case CTF_MARGINBOTTOM:
526 pMargins[XML_LINE_BOTTOM] = property; break;
530 if( pFontFamilyName || pFontStyleName || pFontFamily ||
531 pFontPitch || pFontCharSet )
532 FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
533 pFontPitch, pFontCharSet );
534 if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
535 pFontPitchCJK || pFontCharSetCJK )
536 FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
537 pFontPitchCJK, pFontCharSetCJK );
538 if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
539 pFontPitchCTL || pFontCharSetCTL )
540 FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
541 pFontPitchCTL, pFontCharSetCTL );
543 for (sal_uInt16 i = 0; i < 4; i++)
545 if (pAllParaMargin && !pParaMargins[i]
546 && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
548 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
549 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
550 pAllParaMargin->mnIndex + (2*i) + 2 );
551 assert(nTmp >= CTF_PARALEFTMARGIN &&
552 nTmp <= CTF_PARABOTTOMMARGIN_REL);
553 #endif
554 pNewParaMargins[i].reset(new XMLPropertyState(
555 pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue));
557 if (pAllMargin && !pMargins[i])
559 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
560 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
561 pAllMargin->mnIndex + i + 1 );
562 assert(nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM);
563 #endif
564 pNewMargins[i].reset(new XMLPropertyState(
565 pAllMargin->mnIndex + i + 1, pAllMargin->maValue));
568 lcl_SeparateBorder(
569 i, pAllBorderDistance, pBorderDistances, pNewBorderDistances,
570 pAllBorder, pBorders, pNewBorders,
571 pAllBorderWidth, pBorderWidths
572 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
573 , getPropertySetMapper()
574 #endif
577 lcl_SeparateBorder(
578 i, pCharAllBorderDistance, pCharBorderDistances,
579 pCharNewBorderDistances, pCharAllBorder, pCharBorders,
580 pCharNewBorders, pCharAllBorderWidth, pCharBorderWidths
581 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
582 , getPropertySetMapper()
583 #endif
587 if (pAllParaMargin)
589 pAllParaMargin->mnIndex = -1;
591 if (pAllMargin)
593 pAllMargin->mnIndex = -1;
596 if( pAllBorderDistance )
597 pAllBorderDistance->mnIndex = -1;
599 if( pAllBorder )
600 pAllBorder->mnIndex = -1;
602 if( pAllBorderWidth )
603 pAllBorderWidth->mnIndex = -1;
605 if( pCharAllBorderDistance )
606 pCharAllBorderDistance->mnIndex = -1;
608 if( pCharAllBorder )
609 pCharAllBorder->mnIndex = -1;
611 if( pCharAllBorderWidth )
612 pCharAllBorderWidth->mnIndex = -1;
614 if( pVertOrient && pVertOrientRelAsChar )
616 sal_Int16 nVertOrient;
617 pVertOrient->maValue >>= nVertOrient;
618 sal_Int16 nVertOrientRel = 0;
619 pVertOrientRelAsChar->maValue >>= nVertOrientRel;
620 switch( nVertOrient )
622 case VertOrientation::TOP:
623 nVertOrient = nVertOrientRel;
624 break;
625 case VertOrientation::CENTER:
626 switch( nVertOrientRel )
628 case VertOrientation::CHAR_TOP:
629 nVertOrient = VertOrientation::CHAR_CENTER;
630 break;
631 case VertOrientation::LINE_TOP:
632 nVertOrient = VertOrientation::LINE_CENTER;
633 break;
635 break;
636 case VertOrientation::BOTTOM:
637 switch( nVertOrientRel )
639 case VertOrientation::CHAR_TOP:
640 nVertOrient = VertOrientation::CHAR_BOTTOM;
641 break;
642 case VertOrientation::LINE_TOP:
643 nVertOrient = VertOrientation::LINE_BOTTOM;
644 break;
646 break;
648 pVertOrient->maValue <<= nVertOrient;
649 pVertOrientRelAsChar->mnIndex = -1;
652 FontDefaultsCheck( pFontFamilyName,
653 pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
654 &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
656 FontDefaultsCheck( pFontFamilyNameCJK,
657 pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
658 &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
660 FontDefaultsCheck( pFontFamilyNameCTL,
661 pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
662 &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
664 if (pFillStyle && !pFillColor && pBackTransparent
665 && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>()
666 && pBackTransparent->maValue.get<bool>())
668 // fo:background="transparent", draw:fill="solid" without draw:fill-color
669 // prevent getSvxBrushItemFromSourceSet from adding bogus default color
670 pFillStyle->mnIndex = -1;
673 // #i5775# don't overwrite %transparency with binary transparency
674 if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) )
676 if( ! *o3tl::doAccess<bool>(pBackTransparent->maValue) )
677 pBackTransparent->mnIndex = -1;
681 // insert newly created properties. This invalidates all iterators!
682 // Most of the pXXX variables in this method are iterators and will be
683 // invalidated!!!
685 if( pNewFontStyleName )
687 rProperties.push_back( *pNewFontStyleName );
688 pNewFontStyleName.reset();
691 if( pNewFontFamily )
693 rProperties.push_back( *pNewFontFamily );
694 pNewFontFamily.reset();
697 if( pNewFontPitch )
699 rProperties.push_back( *pNewFontPitch );
700 pNewFontPitch.reset();
703 if( pNewFontCharSet )
705 rProperties.push_back( *pNewFontCharSet );
706 pNewFontCharSet.reset();
709 if( pNewFontStyleNameCJK )
711 rProperties.push_back( *pNewFontStyleNameCJK );
712 pNewFontStyleNameCJK.reset();
715 if( pNewFontFamilyCJK )
717 rProperties.push_back( *pNewFontFamilyCJK );
718 pNewFontFamilyCJK.reset();
721 if( pNewFontPitchCJK )
723 rProperties.push_back( *pNewFontPitchCJK );
724 pNewFontPitchCJK.reset();
727 if( pNewFontCharSetCJK )
729 rProperties.push_back( *pNewFontCharSetCJK );
730 pNewFontCharSetCJK.reset();
733 if( pNewFontStyleNameCTL)
735 rProperties.push_back( *pNewFontStyleNameCTL );
736 pNewFontStyleNameCTL.reset();
739 if( pNewFontFamilyCTL )
741 rProperties.push_back( *pNewFontFamilyCTL );
742 pNewFontFamilyCTL.reset();
745 if( pNewFontPitchCTL )
747 rProperties.push_back( *pNewFontPitchCTL );
748 pNewFontPitchCTL.reset();
751 if( pNewFontCharSetCTL )
753 rProperties.push_back( *pNewFontCharSetCTL );
754 pNewFontCharSetCTL.reset();
757 for (sal_uInt16 i=0; i<4; i++)
759 if (pNewParaMargins[i])
761 rProperties.push_back(*pNewParaMargins[i]);
763 if (pNewMargins[i])
765 rProperties.push_back(*pNewMargins[i]);
767 if( pNewBorderDistances[i] )
769 rProperties.push_back( *pNewBorderDistances[i] );
770 delete pNewBorderDistances[i];
772 if( pNewBorders[i] )
774 rProperties.push_back( *pNewBorders[i] );
775 delete pNewBorders[i];
777 if( pCharNewBorderDistances[i] )
779 rProperties.push_back( *pCharNewBorderDistances[i] );
780 delete pCharNewBorderDistances[i];
782 if( pCharNewBorders[i] )
784 rProperties.push_back( *pCharNewBorders[i] );
785 delete pCharNewBorders[i];
789 if( bHasAnyHeight )
791 if( nSizeTypeIndex == -2 )
793 const_cast < XMLTextImportPropertyMapper * > ( this )
794 ->nSizeTypeIndex = -1;
795 sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
796 for( sal_Int32 j=0; j < nPropCount; j++ )
798 if( CTF_SIZETYPE == getPropertySetMapper()
799 ->GetEntryContextId( j ) )
801 const_cast < XMLTextImportPropertyMapper * > ( this )
802 ->nSizeTypeIndex = j;
803 break;
807 if( nSizeTypeIndex != -1 )
809 XMLPropertyState aSizeTypeState( nSizeTypeIndex );
810 aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinHeight
811 ? SizeType::MIN
812 : SizeType::FIX);
813 rProperties.push_back( aSizeTypeState );
817 if( !bHasAnyWidth )
818 return;
820 if( nWidthTypeIndex == -2 )
822 const_cast < XMLTextImportPropertyMapper * > ( this )
823 ->nWidthTypeIndex = -1;
824 sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
825 for( sal_Int32 j=0; j < nCount; j++ )
827 if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper()
828 ->GetEntryContextId( j ) )
830 const_cast < XMLTextImportPropertyMapper * > ( this )
831 ->nWidthTypeIndex = j;
832 break;
836 if( nWidthTypeIndex != -1 )
838 XMLPropertyState aSizeTypeState( nWidthTypeIndex );
839 aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth
840 ? SizeType::MIN
841 : SizeType::FIX);
842 rProperties.push_back( aSizeTypeState );
845 // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
846 // THIS LINE. All iterators into the rProperties-vector, especially all
847 // pXXX-type variables set in the first switch statement of this method,
848 // may have been invalidated by the above push_back() calls!
852 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */