tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / xmloff / source / text / txtimppr.cxx
blob7fde787242278a70ad4901321888f3074badb402
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 <sal/config.h>
22 #include <o3tl/any.hxx>
23 #include <osl/thread.h>
24 #include <com/sun/star/awt/FontFamily.hpp>
25 #include <com/sun/star/awt/FontPitch.hpp>
26 #include <com/sun/star/drawing/FillStyle.hpp>
27 #include <com/sun/star/table/BorderLine2.hpp>
28 #include <com/sun/star/text/VertOrientation.hpp>
29 #include <com/sun/star/text/SizeType.hpp>
30 #include <xmloff/XMLFontStylesContext.hxx>
31 #include <xmloff/txtprmap.hxx>
32 #include <xmloff/xmlimp.hxx>
33 #include <xmloff/txtimppr.hxx>
34 #include <xmloff/maptype.hxx>
36 #define XML_LINE_LEFT 0
37 #define XML_LINE_RIGHT 1
38 #define XML_LINE_TOP 2
39 #define XML_LINE_BOTTOM 3
42 using namespace ::com::sun::star;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::table;
45 using namespace ::com::sun::star::text;
47 bool XMLTextImportPropertyMapper::handleSpecialItem(
48 XMLPropertyState& rProperty,
49 ::std::vector< XMLPropertyState >& rProperties,
50 const OUString& rValue,
51 const SvXMLUnitConverter& rUnitConverter,
52 const SvXMLNamespaceMap& rNamespaceMap ) const
54 bool bRet = false;
55 sal_Int32 nIndex = rProperty.mnIndex;
56 switch( getPropertySetMapper()->GetEntryContextId( nIndex ) )
58 case CTF_FONTNAME:
59 case CTF_FONTNAME_CJK:
60 case CTF_FONTNAME_CTL:
61 if( GetImport().GetFontDecls() != nullptr )
63 assert((
64 ( CTF_FONTFAMILYNAME ==
65 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
66 CTF_FONTSTYLENAME ==
67 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
68 CTF_FONTFAMILY ==
69 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
70 CTF_FONTPITCH ==
71 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
72 CTF_FONTCHARSET ==
73 getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
74 ( CTF_FONTFAMILYNAME_CJK ==
75 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
76 CTF_FONTSTYLENAME_CJK ==
77 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
78 CTF_FONTFAMILY_CJK ==
79 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
80 CTF_FONTPITCH_CJK ==
81 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
82 CTF_FONTCHARSET_CJK ==
83 getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
84 ( CTF_FONTFAMILYNAME_CTL ==
85 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
86 CTF_FONTSTYLENAME_CTL ==
87 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
88 CTF_FONTFAMILY_CTL ==
89 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
90 CTF_FONTPITCH_CTL ==
91 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
92 CTF_FONTCHARSET_CTL ==
93 getPropertySetMapper()->GetEntryContextId(nIndex+5) )
94 ) && "illegal property map" );
96 GetImport().GetFontDecls()->FillProperties(
97 rValue, rProperties,
98 rProperty.mnIndex+1, rProperty.mnIndex+2,
99 rProperty.mnIndex+3, rProperty.mnIndex+4,
100 rProperty.mnIndex+5 );
101 bRet = false; // the property hasn't been filled
103 break;
105 // If we want to do StarMath/StarSymbol font conversion, then we'll
106 // want these special items to be treated just like regular ones...
107 // For the Writer, we'll catch and convert them in _FillPropertySet;
108 // the other apps probably don't care. For the other apps, we just
109 // imitate the default non-special-item mechanism.
110 case CTF_FONTFAMILYNAME:
111 case CTF_FONTFAMILYNAME_CJK:
112 case CTF_FONTFAMILYNAME_CTL:
113 bRet = getPropertySetMapper()->importXML( rValue, rProperty,
114 rUnitConverter );
115 break;
117 case CTF_TEXT_DISPLAY:
118 bRet = getPropertySetMapper()->importXML( rValue, rProperty,
119 rUnitConverter );
120 if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
122 bool bHidden = false;
123 rProperty.maValue >>= bHidden;
124 bHidden = !bHidden;
125 rProperty.maValue <<= bHidden;
127 break;
128 default:
129 bRet = SvXMLImportPropertyMapper::handleSpecialItem( rProperty,
130 rProperties, rValue, rUnitConverter, rNamespaceMap );
131 break;
134 return bRet;
137 XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
138 const rtl::Reference< XMLPropertySetMapper >& rMapper,
139 SvXMLImport& rImp ) :
140 SvXMLImportPropertyMapper( rMapper, rImp ),
141 m_nSizeTypeIndex( -2 ),
142 m_nWidthTypeIndex( -2 )
146 XMLTextImportPropertyMapper::~XMLTextImportPropertyMapper()
150 void XMLTextImportPropertyMapper::FontFinished(
151 XMLPropertyState *pFontFamilyNameState,
152 XMLPropertyState *pFontStyleNameState,
153 XMLPropertyState *pFontFamilyState,
154 XMLPropertyState *pFontPitchState,
155 XMLPropertyState *pFontCharsetState )
157 if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
159 OUString sName;
160 pFontFamilyNameState->maValue >>= sName;
161 if( sName.isEmpty() )
162 pFontFamilyNameState->mnIndex = -1;
164 if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
166 if( pFontStyleNameState )
167 pFontStyleNameState->mnIndex = -1;
168 if( pFontFamilyState )
169 pFontFamilyState->mnIndex = -1;
170 if( pFontPitchState )
171 pFontPitchState->mnIndex = -1;
172 if( pFontCharsetState )
173 pFontCharsetState->mnIndex = -1;
177 /** since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily",
178 "CharFontPitch" and "CharFontSet" and their CJK and CTL counterparts are only
179 usable as a union, we add defaults to all values that are not set as long as we
180 have an "CharFontFamilyName"
182 #99928# CL */
183 void XMLTextImportPropertyMapper::FontDefaultsCheck(
184 XMLPropertyState const * pFontFamilyName,
185 XMLPropertyState const * pFontStyleName,
186 XMLPropertyState const * pFontFamily,
187 XMLPropertyState const * pFontPitch,
188 XMLPropertyState const * pFontCharSet,
189 std::optional<XMLPropertyState>* ppNewFontStyleName,
190 std::optional<XMLPropertyState>* ppNewFontFamily,
191 std::optional<XMLPropertyState>* ppNewFontPitch,
192 std::optional<XMLPropertyState>* ppNewFontCharSet ) const
194 if( pFontFamilyName )
196 Any aAny;
198 if( !pFontStyleName )
200 aAny <<= OUString();
201 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
202 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
203 pFontFamilyName->mnIndex + 1 );
204 assert(nTmp == CTF_FONTSTYLENAME || nTmp == CTF_FONTSTYLENAME_CJK || nTmp == CTF_FONTSTYLENAME_CTL);
205 #endif
206 ppNewFontStyleName->emplace( pFontFamilyName->mnIndex + 1, aAny );
209 if( !pFontFamily )
211 aAny <<= sal_Int16(css::awt::FontFamily::DONTKNOW);
213 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
214 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
215 pFontFamilyName->mnIndex + 2 );
216 assert(nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL);
217 #endif
218 ppNewFontFamily->emplace( pFontFamilyName->mnIndex + 2, aAny );
221 if( !pFontPitch )
223 aAny <<= sal_Int16(css::awt::FontPitch::DONTKNOW);
224 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
225 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
226 pFontFamilyName->mnIndex + 3 );
227 assert(nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL);
228 #endif
229 ppNewFontPitch->emplace( pFontFamilyName->mnIndex + 3, aAny );
232 if( !pFontCharSet )
234 aAny <<= static_cast<sal_Int16>(osl_getThreadTextEncoding());
235 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
236 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
237 pFontFamilyName->mnIndex + 4 );
238 assert(nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL);
239 #endif
240 ppNewFontCharSet->emplace( pFontFamilyName->mnIndex + 4, aAny );
244 (void) this; // avoid loplugin:staticmethods
247 namespace {
248 //fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
249 //a flag that the value is an absolute value so we can't truly handle an
250 //up/lower space property which wants to specify its 200% upper but 100% lower
251 //of its parent (try typing 100% vs 200% into the edit style dialog and revisit
252 //your style). So on xml load that ends up meaning 200%, 0 lower. This is a
253 //crock.
255 //On import clear 100% all-margins relative sizes.
256 bool
257 isNotDefaultRelSize(const XMLPropertyState* pRelState, const rtl::Reference<XMLPropertySetMapper>& rPrMap)
259 if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
261 sal_Int32 nTemp = 0;
262 pRelState->maValue >>= nTemp;
263 return nTemp != 100;
265 return true;
269 * Separate compressed border attributes.
270 * During export, border attributes are compressed if there are equal to all four side.
271 * Since Writer hasn't the same compressed attributes, but has distinct ones for all
272 * four side, we have to duplicate the compressed attribute during import.
274 void lcl_SeparateBorder(
275 sal_uInt16 nIndex, XMLPropertyState const * pAllBorderDistance,
276 XMLPropertyState* pBorderDistances[4], XMLPropertyState* pNewBorderDistances[4],
277 XMLPropertyState const * pAllBorder, XMLPropertyState* pBorders[4],
278 XMLPropertyState* pNewBorders[4], XMLPropertyState* pAllBorderWidth,
279 XMLPropertyState* pBorderWidths[4]
280 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
281 , const rtl::Reference< XMLPropertySetMapper >& rMapper
282 #endif
285 if( pAllBorderDistance && !pBorderDistances[nIndex] )
287 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
288 sal_Int16 nTmp = rMapper->GetEntryContextId(
289 pAllBorderDistance->mnIndex + nIndex + 1 );
290 if (CTF_CHARALLBORDERDISTANCE ==
291 rMapper->GetEntryContextId(pAllBorderDistance->mnIndex))
293 assert(nTmp >= CTF_CHARLEFTBORDERDISTANCE &&
294 nTmp <= CTF_CHARBOTTOMBORDERDISTANCE);
296 else
298 assert(nTmp >= CTF_LEFTBORDERDISTANCE &&
299 nTmp <= CTF_BOTTOMBORDERDISTANCE);
301 #endif
302 pNewBorderDistances[nIndex] =
303 new XMLPropertyState( pAllBorderDistance->mnIndex + nIndex + 1,
304 pAllBorderDistance->maValue );
305 pBorderDistances[nIndex] = pNewBorderDistances[nIndex];
307 if( pAllBorder && !pBorders[nIndex] )
309 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
310 sal_Int16 nTmp = rMapper->GetEntryContextId(
311 pAllBorder->mnIndex + nIndex + 1 );
312 if (CTF_CHARALLBORDER ==
313 rMapper->GetEntryContextId(pAllBorder->mnIndex))
315 assert(nTmp >= CTF_CHARLEFTBORDER && nTmp <= CTF_CHARBOTTOMBORDER);
317 else
319 assert(nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER);
321 #endif
322 pNewBorders[nIndex] = new XMLPropertyState( pAllBorder->mnIndex + nIndex + 1,
323 pAllBorder->maValue );
324 pBorders[nIndex] = pNewBorders[nIndex];
326 if( !pBorderWidths[nIndex] )
327 pBorderWidths[nIndex] = pAllBorderWidth;
328 else
329 pBorderWidths[nIndex]->mnIndex = -1;
331 if( !(pBorders[nIndex] && pBorderWidths[nIndex]) )
332 return;
334 table::BorderLine2 aBorderLine;
335 pBorders[nIndex]->maValue >>= aBorderLine;
337 table::BorderLine2 aBorderLineWidth;
338 pBorderWidths[nIndex]->maValue >>= aBorderLineWidth;
340 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
341 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
342 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
343 aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
345 pBorders[nIndex]->maValue <<= aBorderLine;
350 void XMLTextImportPropertyMapper::finished(
351 ::std::vector< XMLPropertyState >& rProperties,
352 sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
354 bool bHasAnyHeight = false;
355 bool bHasAnyMinHeight = false;
356 bool bHasAnyWidth = false;
357 bool bHasAnyMinWidth = false;
359 XMLPropertyState* pFontFamilyName = nullptr;
360 XMLPropertyState* pFontStyleName = nullptr;
361 XMLPropertyState* pFontFamily = nullptr;
362 XMLPropertyState* pFontPitch = nullptr;
363 XMLPropertyState* pFontCharSet = nullptr;
364 std::optional<XMLPropertyState> pNewFontStyleName;
365 std::optional<XMLPropertyState> pNewFontFamily;
366 std::optional<XMLPropertyState> pNewFontPitch;
367 std::optional<XMLPropertyState> pNewFontCharSet;
368 XMLPropertyState* pFontFamilyNameCJK = nullptr;
369 XMLPropertyState* pFontStyleNameCJK = nullptr;
370 XMLPropertyState* pFontFamilyCJK = nullptr;
371 XMLPropertyState* pFontPitchCJK = nullptr;
372 XMLPropertyState* pFontCharSetCJK = nullptr;
373 std::optional<XMLPropertyState> pNewFontStyleNameCJK;
374 std::optional<XMLPropertyState> pNewFontFamilyCJK;
375 std::optional<XMLPropertyState> pNewFontPitchCJK;
376 std::optional<XMLPropertyState> pNewFontCharSetCJK;
377 XMLPropertyState* pFontFamilyNameCTL = nullptr;
378 XMLPropertyState* pFontStyleNameCTL = nullptr;
379 XMLPropertyState* pFontFamilyCTL = nullptr;
380 XMLPropertyState* pFontPitchCTL = nullptr;
381 XMLPropertyState* pFontCharSetCTL = nullptr;
382 std::optional<XMLPropertyState> pNewFontStyleNameCTL;
383 std::optional<XMLPropertyState> pNewFontFamilyCTL;
384 std::optional<XMLPropertyState> pNewFontPitchCTL;
385 std::optional<XMLPropertyState> pNewFontCharSetCTL;
386 XMLPropertyState* pAllBorderDistance = nullptr;
387 XMLPropertyState* pBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
388 XMLPropertyState* pNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
389 XMLPropertyState* pAllBorder = nullptr;
390 XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr };
391 XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
392 XMLPropertyState* pAllBorderWidth = nullptr;
393 XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
394 XMLPropertyState* pCharAllBorderDistance = nullptr;
395 XMLPropertyState* pCharBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
396 XMLPropertyState* pCharNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
397 XMLPropertyState* pCharAllBorder = nullptr;
398 XMLPropertyState* pCharBorders[4] = { nullptr, nullptr, nullptr, nullptr };
399 XMLPropertyState* pCharNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
400 XMLPropertyState* pCharAllBorderWidth = nullptr;
401 XMLPropertyState* pCharBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
402 XMLPropertyState* pVertOrient = nullptr;
403 XMLPropertyState* pVertOrientRelAsChar = nullptr;
404 XMLPropertyState* pBackTransparency = nullptr; // transparency in %
405 XMLPropertyState* pBackTransparent = nullptr; // transparency as boolean
406 XMLPropertyState* pAllParaMargin = nullptr;
407 XMLPropertyState* pParaMargins[4] = { nullptr, nullptr, nullptr, nullptr };
408 ::std::optional<XMLPropertyState> pNewParaMargins[4];
409 XMLPropertyState* pAllMargin = nullptr;
410 XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
411 ::std::optional<XMLPropertyState> pNewMargins[4];
412 XMLPropertyState* pFillStyle(nullptr);
413 XMLPropertyState* pFillColor(nullptr);
415 for( auto& rProperty : rProperties )
417 XMLPropertyState* property = &rProperty;
418 if( -1 == property->mnIndex )
419 continue;
421 switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
423 case CTF_FONTFAMILYNAME: pFontFamilyName = property; break;
424 case CTF_FONTSTYLENAME: pFontStyleName = property; break;
425 case CTF_FONTFAMILY: pFontFamily = property; break;
426 case CTF_FONTPITCH: pFontPitch = property; break;
427 case CTF_FONTCHARSET: pFontCharSet = property; break;
429 case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJK = property; break;
430 case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property; break;
431 case CTF_FONTFAMILY_CJK: pFontFamilyCJK = property; break;
432 case CTF_FONTPITCH_CJK: pFontPitchCJK = property; break;
433 case CTF_FONTCHARSET_CJK: pFontCharSetCJK = property; break;
435 case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTL = property; break;
436 case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property; break;
437 case CTF_FONTFAMILY_CTL: pFontFamilyCTL = property; break;
438 case CTF_FONTPITCH_CTL: pFontPitchCTL = property; break;
439 case CTF_FONTCHARSET_CTL: pFontCharSetCTL = property; break;
441 case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break;
442 case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break;
443 case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break;
444 case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break;
445 case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break;
446 case CTF_ALLBORDER: pAllBorder = property; break;
447 case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break;
448 case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break;
449 case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break;
450 case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break;
451 case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break;
452 case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break;
453 case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break;
454 case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break;
455 case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break;
457 case CTF_CHARALLBORDERDISTANCE: pCharAllBorderDistance = property; break;
458 case CTF_CHARLEFTBORDERDISTANCE: pCharBorderDistances[XML_LINE_LEFT] = property; break;
459 case CTF_CHARRIGHTBORDERDISTANCE: pCharBorderDistances[XML_LINE_RIGHT] = property; break;
460 case CTF_CHARTOPBORDERDISTANCE: pCharBorderDistances[XML_LINE_TOP] = property; break;
461 case CTF_CHARBOTTOMBORDERDISTANCE: pCharBorderDistances[XML_LINE_BOTTOM] = property; break;
462 case CTF_CHARALLBORDER: pCharAllBorder = property; break;
463 case CTF_CHARLEFTBORDER: pCharBorders[XML_LINE_LEFT] = property; break;
464 case CTF_CHARRIGHTBORDER: pCharBorders[XML_LINE_RIGHT] = property; break;
465 case CTF_CHARTOPBORDER: pCharBorders[XML_LINE_TOP] = property; break;
466 case CTF_CHARBOTTOMBORDER: pCharBorders[XML_LINE_BOTTOM] = property; break;
467 case CTF_CHARALLBORDERWIDTH: pCharAllBorderWidth = property; break;
468 case CTF_CHARLEFTBORDERWIDTH: pCharBorderWidths[XML_LINE_LEFT] = property; break;
469 case CTF_CHARRIGHTBORDERWIDTH: pCharBorderWidths[XML_LINE_RIGHT] = property; break;
470 case CTF_CHARTOPBORDERWIDTH: pCharBorderWidths[XML_LINE_TOP] = property; break;
471 case CTF_CHARBOTTOMBORDERWIDTH: pCharBorderWidths[XML_LINE_BOTTOM] = property; break;
473 case CTF_ANCHORTYPE: break;
474 case CTF_VERTICALPOS: pVertOrient = property; break;
475 case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
477 case CTF_FRAMEHEIGHT_MIN_ABS:
478 case CTF_FRAMEHEIGHT_MIN_REL:
479 // case CTF_SYNCHEIGHT_MIN:
480 bHasAnyMinHeight = true;
481 [[fallthrough]];
482 case CTF_FRAMEHEIGHT_ABS:
483 case CTF_FRAMEHEIGHT_REL:
484 // case CTF_SYNCHEIGHT:
485 bHasAnyHeight = true; break;
486 case CTF_FRAMEWIDTH_MIN_ABS:
487 case CTF_FRAMEWIDTH_MIN_REL:
488 bHasAnyMinWidth = true;
489 [[fallthrough]];
490 case CTF_FRAMEWIDTH_ABS:
491 case CTF_FRAMEWIDTH_REL:
492 bHasAnyWidth = true; break;
493 case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
494 case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break;
495 case CTF_FILLSTYLE: pFillStyle = property; break;
496 case CTF_FILLCOLOR: pFillColor = property; break;
497 case CTF_PARAMARGINALL:
498 case CTF_PARAMARGINALL_REL:
499 pAllParaMargin = property; break;
500 case CTF_PARALEFTMARGIN:
501 case CTF_PARALEFTMARGIN_REL:
502 pParaMargins[XML_LINE_LEFT] = property; break;
503 case CTF_PARARIGHTMARGIN:
504 case CTF_PARARIGHTMARGIN_REL:
505 pParaMargins[XML_LINE_RIGHT] = property; break;
506 case CTF_PARATOPMARGIN:
507 case CTF_PARATOPMARGIN_REL:
508 pParaMargins[XML_LINE_TOP] = property; break;
509 case CTF_PARABOTTOMMARGIN:
510 case CTF_PARABOTTOMMARGIN_REL:
511 pParaMargins[XML_LINE_BOTTOM] = property; break;
512 case CTF_MARGINALL:
513 pAllMargin = property; break;
514 case CTF_MARGINLEFT:
515 pMargins[XML_LINE_LEFT] = property; break;
516 case CTF_MARGINRIGHT:
517 pMargins[XML_LINE_RIGHT] = property; break;
518 case CTF_MARGINTOP:
519 pMargins[XML_LINE_TOP] = property; break;
520 case CTF_MARGINBOTTOM:
521 pMargins[XML_LINE_BOTTOM] = property; break;
525 if( pFontFamilyName || pFontStyleName || pFontFamily ||
526 pFontPitch || pFontCharSet )
527 FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
528 pFontPitch, pFontCharSet );
529 if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
530 pFontPitchCJK || pFontCharSetCJK )
531 FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
532 pFontPitchCJK, pFontCharSetCJK );
533 if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
534 pFontPitchCTL || pFontCharSetCTL )
535 FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
536 pFontPitchCTL, pFontCharSetCTL );
538 for (sal_uInt16 i = 0; i < 4; i++)
540 if (pAllParaMargin && !pParaMargins[i]
541 && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
543 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
544 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
545 pAllParaMargin->mnIndex + (2*i) + 2 );
546 assert(nTmp >= CTF_PARALEFTMARGIN &&
547 nTmp <= CTF_PARABOTTOMMARGIN_REL);
548 #endif
549 pNewParaMargins[i].emplace(
550 pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue);
552 if (pAllMargin && !pMargins[i])
554 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
555 sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
556 pAllMargin->mnIndex + i + 1 );
557 assert(nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM);
558 #endif
559 pNewMargins[i].emplace(
560 pAllMargin->mnIndex + i + 1, pAllMargin->maValue);
563 lcl_SeparateBorder(
564 i, pAllBorderDistance, pBorderDistances, pNewBorderDistances,
565 pAllBorder, pBorders, pNewBorders,
566 pAllBorderWidth, pBorderWidths
567 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
568 , getPropertySetMapper()
569 #endif
572 lcl_SeparateBorder(
573 i, pCharAllBorderDistance, pCharBorderDistances,
574 pCharNewBorderDistances, pCharAllBorder, pCharBorders,
575 pCharNewBorders, pCharAllBorderWidth, pCharBorderWidths
576 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
577 , getPropertySetMapper()
578 #endif
582 if (pAllParaMargin)
584 pAllParaMargin->mnIndex = -1;
586 if (pAllMargin)
588 pAllMargin->mnIndex = -1;
591 if( pAllBorderDistance )
592 pAllBorderDistance->mnIndex = -1;
594 if( pAllBorder )
595 pAllBorder->mnIndex = -1;
597 if( pAllBorderWidth )
598 pAllBorderWidth->mnIndex = -1;
600 if( pCharAllBorderDistance )
601 pCharAllBorderDistance->mnIndex = -1;
603 if( pCharAllBorder )
604 pCharAllBorder->mnIndex = -1;
606 if( pCharAllBorderWidth )
607 pCharAllBorderWidth->mnIndex = -1;
609 if( pVertOrient && pVertOrientRelAsChar )
611 sal_Int16 nVertOrient;
612 pVertOrient->maValue >>= nVertOrient;
613 sal_Int16 nVertOrientRel = 0;
614 pVertOrientRelAsChar->maValue >>= nVertOrientRel;
615 switch( nVertOrient )
617 case VertOrientation::TOP:
618 nVertOrient = nVertOrientRel;
619 break;
620 case VertOrientation::CENTER:
621 switch( nVertOrientRel )
623 case VertOrientation::CHAR_TOP:
624 nVertOrient = VertOrientation::CHAR_CENTER;
625 break;
626 case VertOrientation::LINE_TOP:
627 nVertOrient = VertOrientation::LINE_CENTER;
628 break;
630 break;
631 case VertOrientation::BOTTOM:
632 switch( nVertOrientRel )
634 case VertOrientation::CHAR_TOP:
635 nVertOrient = VertOrientation::CHAR_BOTTOM;
636 break;
637 case VertOrientation::LINE_TOP:
638 nVertOrient = VertOrientation::LINE_BOTTOM;
639 break;
641 break;
643 pVertOrient->maValue <<= nVertOrient;
644 pVertOrientRelAsChar->mnIndex = -1;
647 FontDefaultsCheck( pFontFamilyName,
648 pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
649 &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
651 FontDefaultsCheck( pFontFamilyNameCJK,
652 pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
653 &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
655 FontDefaultsCheck( pFontFamilyNameCTL,
656 pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
657 &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
659 if (pFillStyle && !pFillColor && pBackTransparent
660 && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>()
661 && pBackTransparent->maValue.get<bool>())
663 // fo:background="transparent", draw:fill="solid" without draw:fill-color
664 // prevent getSvxBrushItemFromSourceSet from adding bogus default color
665 pFillStyle->mnIndex = -1;
668 // #i5775# don't overwrite %transparency with binary transparency
669 if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) )
671 if( ! *o3tl::doAccess<bool>(pBackTransparent->maValue) )
672 pBackTransparent->mnIndex = -1;
676 // insert newly created properties. This invalidates all iterators!
677 // Most of the pXXX variables in this method are iterators and will be
678 // invalidated!!!
680 if( pNewFontStyleName )
682 rProperties.push_back( *pNewFontStyleName );
683 pNewFontStyleName.reset();
686 if( pNewFontFamily )
688 rProperties.push_back( *pNewFontFamily );
689 pNewFontFamily.reset();
692 if( pNewFontPitch )
694 rProperties.push_back( *pNewFontPitch );
695 pNewFontPitch.reset();
698 if( pNewFontCharSet )
700 rProperties.push_back( *pNewFontCharSet );
701 pNewFontCharSet.reset();
704 if( pNewFontStyleNameCJK )
706 rProperties.push_back( *pNewFontStyleNameCJK );
707 pNewFontStyleNameCJK.reset();
710 if( pNewFontFamilyCJK )
712 rProperties.push_back( *pNewFontFamilyCJK );
713 pNewFontFamilyCJK.reset();
716 if( pNewFontPitchCJK )
718 rProperties.push_back( *pNewFontPitchCJK );
719 pNewFontPitchCJK.reset();
722 if( pNewFontCharSetCJK )
724 rProperties.push_back( *pNewFontCharSetCJK );
725 pNewFontCharSetCJK.reset();
728 if( pNewFontStyleNameCTL)
730 rProperties.push_back( *pNewFontStyleNameCTL );
731 pNewFontStyleNameCTL.reset();
734 if( pNewFontFamilyCTL )
736 rProperties.push_back( *pNewFontFamilyCTL );
737 pNewFontFamilyCTL.reset();
740 if( pNewFontPitchCTL )
742 rProperties.push_back( *pNewFontPitchCTL );
743 pNewFontPitchCTL.reset();
746 if( pNewFontCharSetCTL )
748 rProperties.push_back( *pNewFontCharSetCTL );
749 pNewFontCharSetCTL.reset();
752 for (sal_uInt16 i=0; i<4; i++)
754 if (pNewParaMargins[i])
756 rProperties.push_back(*pNewParaMargins[i]);
758 if (pNewMargins[i])
760 rProperties.push_back(*pNewMargins[i]);
762 if( pNewBorderDistances[i] )
764 rProperties.push_back( *pNewBorderDistances[i] );
765 delete pNewBorderDistances[i];
767 if( pNewBorders[i] )
769 rProperties.push_back( *pNewBorders[i] );
770 delete pNewBorders[i];
772 if( pCharNewBorderDistances[i] )
774 rProperties.push_back( *pCharNewBorderDistances[i] );
775 delete pCharNewBorderDistances[i];
777 if( pCharNewBorders[i] )
779 rProperties.push_back( *pCharNewBorders[i] );
780 delete pCharNewBorders[i];
784 if( bHasAnyHeight )
786 if( m_nSizeTypeIndex == -2 )
788 const_cast < XMLTextImportPropertyMapper * > ( this )
789 ->m_nSizeTypeIndex = -1;
790 sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
791 for( sal_Int32 j=0; j < nPropCount; j++ )
793 if( CTF_SIZETYPE == getPropertySetMapper()
794 ->GetEntryContextId( j ) )
796 const_cast < XMLTextImportPropertyMapper * > ( this )
797 ->m_nSizeTypeIndex = j;
798 break;
802 if( m_nSizeTypeIndex != -1 )
804 XMLPropertyState aSizeTypeState( m_nSizeTypeIndex );
805 aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinHeight
806 ? SizeType::MIN
807 : SizeType::FIX);
808 rProperties.push_back( aSizeTypeState );
812 if( !bHasAnyWidth )
813 return;
815 if( m_nWidthTypeIndex == -2 )
817 const_cast < XMLTextImportPropertyMapper * > ( this )
818 ->m_nWidthTypeIndex = -1;
819 sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
820 for( sal_Int32 j=0; j < nCount; j++ )
822 if( CTF_FRAMEWIDTH_TYPE == getPropertySetMapper()
823 ->GetEntryContextId( j ) )
825 const_cast < XMLTextImportPropertyMapper * > ( this )
826 ->m_nWidthTypeIndex = j;
827 break;
831 if( m_nWidthTypeIndex != -1 )
833 XMLPropertyState aSizeTypeState( m_nWidthTypeIndex );
834 aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth
835 ? SizeType::MIN
836 : SizeType::FIX);
837 rProperties.push_back( aSizeTypeState );
840 // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
841 // THIS LINE. All iterators into the rProperties-vector, especially all
842 // pXXX-type variables set in the first switch statement of this method,
843 // may have been invalidated by the above push_back() calls!
847 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */