1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
56 sal_Int32 nIndex
= rProperty
.mnIndex
;
57 switch( getPropertySetMapper()->GetEntryContextId( nIndex
) )
60 case CTF_FONTNAME_CJK
:
61 case CTF_FONTNAME_CTL
:
62 if( GetImport().GetFontDecls() != nullptr )
65 ( CTF_FONTFAMILYNAME
==
66 getPropertySetMapper()->GetEntryContextId(nIndex
+1) &&
68 getPropertySetMapper()->GetEntryContextId(nIndex
+2) &&
70 getPropertySetMapper()->GetEntryContextId(nIndex
+3) &&
72 getPropertySetMapper()->GetEntryContextId(nIndex
+4) &&
74 getPropertySetMapper()->GetEntryContextId(nIndex
+5) ) ||
75 ( CTF_FONTFAMILYNAME_CJK
==
76 getPropertySetMapper()->GetEntryContextId(nIndex
+1) &&
77 CTF_FONTSTYLENAME_CJK
==
78 getPropertySetMapper()->GetEntryContextId(nIndex
+2) &&
80 getPropertySetMapper()->GetEntryContextId(nIndex
+3) &&
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) &&
90 getPropertySetMapper()->GetEntryContextId(nIndex
+3) &&
92 getPropertySetMapper()->GetEntryContextId(nIndex
+4) &&
93 CTF_FONTCHARSET_CTL
==
94 getPropertySetMapper()->GetEntryContextId(nIndex
+5) )
95 ) && "illegal property map" );
97 GetImport().GetFontDecls()->FillProperties(
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
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
,
118 case CTF_TEXT_DISPLAY
:
119 bRet
= getPropertySetMapper()->importXML( rValue
, rProperty
,
121 if( SvXMLImport::OOo_2x
== GetImport().getGeneratorVersion() )
123 bool bHidden
= false;
124 rProperty
.maValue
>>= bHidden
;
126 rProperty
.maValue
<<= bHidden
;
130 bRet
= SvXMLImportPropertyMapper::handleSpecialItem( rProperty
,
131 rProperties
, rValue
, rUnitConverter
, rNamespaceMap
);
138 XMLTextImportPropertyMapper::XMLTextImportPropertyMapper(
139 const rtl::Reference
< XMLPropertySetMapper
>& rMapper
,
140 SvXMLImport
& rImp
) :
141 SvXMLImportPropertyMapper( rMapper
, rImp
),
142 m_nSizeTypeIndex( -2 ),
143 m_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 )
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"
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::optional
<XMLPropertyState
>* ppNewFontStyleName
,
191 std::optional
<XMLPropertyState
>* ppNewFontFamily
,
192 std::optional
<XMLPropertyState
>* ppNewFontPitch
,
193 std::optional
<XMLPropertyState
>* ppNewFontCharSet
) const
195 if( pFontFamilyName
)
199 if( !pFontStyleName
)
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
);
207 ppNewFontStyleName
->emplace( pFontFamilyName
->mnIndex
+ 1, aAny
);
212 aAny
<<= sal_Int16(css::awt::FontFamily::DONTKNOW
);
214 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
215 sal_Int16 nTmp
= getPropertySetMapper()->GetEntryContextId(
216 pFontFamilyName
->mnIndex
+ 2 );
217 assert(nTmp
== CTF_FONTFAMILY
|| nTmp
== CTF_FONTFAMILY_CJK
|| nTmp
== CTF_FONTFAMILY_CTL
);
219 ppNewFontFamily
->emplace( pFontFamilyName
->mnIndex
+ 2, aAny
);
224 aAny
<<= sal_Int16(css::awt::FontPitch::DONTKNOW
);
225 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
226 sal_Int16 nTmp
= getPropertySetMapper()->GetEntryContextId(
227 pFontFamilyName
->mnIndex
+ 3 );
228 assert(nTmp
== CTF_FONTPITCH
|| nTmp
== CTF_FONTPITCH_CJK
|| nTmp
== CTF_FONTPITCH_CTL
);
230 ppNewFontPitch
->emplace( pFontFamilyName
->mnIndex
+ 3, aAny
);
235 aAny
<<= static_cast<sal_Int16
>(osl_getThreadTextEncoding());
236 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
237 sal_Int16 nTmp
= getPropertySetMapper()->GetEntryContextId(
238 pFontFamilyName
->mnIndex
+ 4 );
239 assert(nTmp
== CTF_FONTCHARSET
|| nTmp
== CTF_FONTCHARSET_CJK
|| nTmp
== CTF_FONTCHARSET_CTL
);
241 ppNewFontCharSet
->emplace( pFontFamilyName
->mnIndex
+ 4, aAny
);
245 (void) this; // avoid loplugin:staticmethods
249 //fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
250 //a flag that the value is an absolute value so we can't truly handle an
251 //up/lower space property which wants to specify its 200% upper but 100% lower
252 //of its parent (try typing 100% vs 200% into the edit style dialog and revisit
253 //your style). So on xml load that ends up meaning 200%, 0 lower. This is a
256 //On import clear 100% all-margins relative sizes.
258 isNotDefaultRelSize(const XMLPropertyState
* pRelState
, const rtl::Reference
<XMLPropertySetMapper
>& rPrMap
)
260 if (rPrMap
->GetEntryContextId(pRelState
->mnIndex
) == CTF_PARAMARGINALL_REL
)
263 pRelState
->maValue
>>= nTemp
;
270 * Separate compressed border attributes.
271 * During export, border attributes are compressed if there are equal to all four side.
272 * Since Writer hasn't the same compressed attributes, but has distinct ones for all
273 * four side, we have to duplicate the compressed attribute during import.
275 void lcl_SeparateBorder(
276 sal_uInt16 nIndex
, XMLPropertyState
const * pAllBorderDistance
,
277 XMLPropertyState
* pBorderDistances
[4], XMLPropertyState
* pNewBorderDistances
[4],
278 XMLPropertyState
const * pAllBorder
, XMLPropertyState
* pBorders
[4],
279 XMLPropertyState
* pNewBorders
[4], XMLPropertyState
* pAllBorderWidth
,
280 XMLPropertyState
* pBorderWidths
[4]
281 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
282 , const rtl::Reference
< XMLPropertySetMapper
>& rMapper
286 if( pAllBorderDistance
&& !pBorderDistances
[nIndex
] )
288 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
289 sal_Int16 nTmp
= rMapper
->GetEntryContextId(
290 pAllBorderDistance
->mnIndex
+ nIndex
+ 1 );
291 if (CTF_CHARALLBORDERDISTANCE
==
292 rMapper
->GetEntryContextId(pAllBorderDistance
->mnIndex
))
294 assert(nTmp
>= CTF_CHARLEFTBORDERDISTANCE
&&
295 nTmp
<= CTF_CHARBOTTOMBORDERDISTANCE
);
299 assert(nTmp
>= CTF_LEFTBORDERDISTANCE
&&
300 nTmp
<= CTF_BOTTOMBORDERDISTANCE
);
303 pNewBorderDistances
[nIndex
] =
304 new XMLPropertyState( pAllBorderDistance
->mnIndex
+ nIndex
+ 1,
305 pAllBorderDistance
->maValue
);
306 pBorderDistances
[nIndex
] = pNewBorderDistances
[nIndex
];
308 if( pAllBorder
&& !pBorders
[nIndex
] )
310 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
311 sal_Int16 nTmp
= rMapper
->GetEntryContextId(
312 pAllBorder
->mnIndex
+ nIndex
+ 1 );
313 if (CTF_CHARALLBORDER
==
314 rMapper
->GetEntryContextId(pAllBorder
->mnIndex
))
316 assert(nTmp
>= CTF_CHARLEFTBORDER
&& nTmp
<= CTF_CHARBOTTOMBORDER
);
320 assert(nTmp
>= CTF_LEFTBORDER
&& nTmp
<= CTF_BOTTOMBORDER
);
323 pNewBorders
[nIndex
] = new XMLPropertyState( pAllBorder
->mnIndex
+ nIndex
+ 1,
324 pAllBorder
->maValue
);
325 pBorders
[nIndex
] = pNewBorders
[nIndex
];
327 if( !pBorderWidths
[nIndex
] )
328 pBorderWidths
[nIndex
] = pAllBorderWidth
;
330 pBorderWidths
[nIndex
]->mnIndex
= -1;
332 if( !(pBorders
[nIndex
] && pBorderWidths
[nIndex
]) )
335 table::BorderLine2 aBorderLine
;
336 pBorders
[nIndex
]->maValue
>>= aBorderLine
;
338 table::BorderLine2 aBorderLineWidth
;
339 pBorderWidths
[nIndex
]->maValue
>>= aBorderLineWidth
;
341 aBorderLine
.OuterLineWidth
= aBorderLineWidth
.OuterLineWidth
;
342 aBorderLine
.InnerLineWidth
= aBorderLineWidth
.InnerLineWidth
;
343 aBorderLine
.LineDistance
= aBorderLineWidth
.LineDistance
;
344 aBorderLine
.LineWidth
= aBorderLineWidth
.LineWidth
;
346 pBorders
[nIndex
]->maValue
<<= aBorderLine
;
351 void XMLTextImportPropertyMapper::finished(
352 ::std::vector
< XMLPropertyState
>& rProperties
,
353 sal_Int32
/*nStartIndex*/, sal_Int32
/*nEndIndex*/ ) const
355 bool bHasAnyHeight
= false;
356 bool bHasAnyMinHeight
= false;
357 bool bHasAnyWidth
= false;
358 bool bHasAnyMinWidth
= false;
360 XMLPropertyState
* pFontFamilyName
= nullptr;
361 XMLPropertyState
* pFontStyleName
= nullptr;
362 XMLPropertyState
* pFontFamily
= nullptr;
363 XMLPropertyState
* pFontPitch
= nullptr;
364 XMLPropertyState
* pFontCharSet
= nullptr;
365 std::optional
<XMLPropertyState
> pNewFontStyleName
;
366 std::optional
<XMLPropertyState
> pNewFontFamily
;
367 std::optional
<XMLPropertyState
> pNewFontPitch
;
368 std::optional
<XMLPropertyState
> pNewFontCharSet
;
369 XMLPropertyState
* pFontFamilyNameCJK
= nullptr;
370 XMLPropertyState
* pFontStyleNameCJK
= nullptr;
371 XMLPropertyState
* pFontFamilyCJK
= nullptr;
372 XMLPropertyState
* pFontPitchCJK
= nullptr;
373 XMLPropertyState
* pFontCharSetCJK
= nullptr;
374 std::optional
<XMLPropertyState
> pNewFontStyleNameCJK
;
375 std::optional
<XMLPropertyState
> pNewFontFamilyCJK
;
376 std::optional
<XMLPropertyState
> pNewFontPitchCJK
;
377 std::optional
<XMLPropertyState
> pNewFontCharSetCJK
;
378 XMLPropertyState
* pFontFamilyNameCTL
= nullptr;
379 XMLPropertyState
* pFontStyleNameCTL
= nullptr;
380 XMLPropertyState
* pFontFamilyCTL
= nullptr;
381 XMLPropertyState
* pFontPitchCTL
= nullptr;
382 XMLPropertyState
* pFontCharSetCTL
= nullptr;
383 std::optional
<XMLPropertyState
> pNewFontStyleNameCTL
;
384 std::optional
<XMLPropertyState
> pNewFontFamilyCTL
;
385 std::optional
<XMLPropertyState
> pNewFontPitchCTL
;
386 std::optional
<XMLPropertyState
> pNewFontCharSetCTL
;
387 XMLPropertyState
* pAllBorderDistance
= nullptr;
388 XMLPropertyState
* pBorderDistances
[4] = { nullptr, nullptr, nullptr, nullptr };
389 XMLPropertyState
* pNewBorderDistances
[4] = { nullptr, nullptr, nullptr, nullptr };
390 XMLPropertyState
* pAllBorder
= nullptr;
391 XMLPropertyState
* pBorders
[4] = { nullptr, nullptr, nullptr, nullptr };
392 XMLPropertyState
* pNewBorders
[4] = { nullptr, nullptr, nullptr, nullptr };
393 XMLPropertyState
* pAllBorderWidth
= nullptr;
394 XMLPropertyState
* pBorderWidths
[4] = { nullptr, nullptr, nullptr, nullptr };
395 XMLPropertyState
* pCharAllBorderDistance
= nullptr;
396 XMLPropertyState
* pCharBorderDistances
[4] = { nullptr, nullptr, nullptr, nullptr };
397 XMLPropertyState
* pCharNewBorderDistances
[4] = { nullptr, nullptr, nullptr, nullptr };
398 XMLPropertyState
* pCharAllBorder
= nullptr;
399 XMLPropertyState
* pCharBorders
[4] = { nullptr, nullptr, nullptr, nullptr };
400 XMLPropertyState
* pCharNewBorders
[4] = { nullptr, nullptr, nullptr, nullptr };
401 XMLPropertyState
* pCharAllBorderWidth
= nullptr;
402 XMLPropertyState
* pCharBorderWidths
[4] = { nullptr, nullptr, nullptr, nullptr };
403 XMLPropertyState
* pVertOrient
= nullptr;
404 XMLPropertyState
* pVertOrientRelAsChar
= nullptr;
405 XMLPropertyState
* pBackTransparency
= nullptr; // transparency in %
406 XMLPropertyState
* pBackTransparent
= nullptr; // transparency as boolean
407 XMLPropertyState
* pAllParaMargin
= nullptr;
408 XMLPropertyState
* pParaMargins
[4] = { nullptr, nullptr, nullptr, nullptr };
409 ::std::optional
<XMLPropertyState
> pNewParaMargins
[4];
410 XMLPropertyState
* pAllMargin
= nullptr;
411 XMLPropertyState
* pMargins
[4] = { nullptr, nullptr, nullptr, nullptr };
412 ::std::optional
<XMLPropertyState
> pNewMargins
[4];
413 XMLPropertyState
* pFillStyle(nullptr);
414 XMLPropertyState
* pFillColor(nullptr);
416 for( auto& rProperty
: rProperties
)
418 XMLPropertyState
* property
= &rProperty
;
419 if( -1 == property
->mnIndex
)
422 switch( getPropertySetMapper()->GetEntryContextId( property
->mnIndex
) )
424 case CTF_FONTFAMILYNAME
: pFontFamilyName
= property
; break;
425 case CTF_FONTSTYLENAME
: pFontStyleName
= property
; break;
426 case CTF_FONTFAMILY
: pFontFamily
= property
; break;
427 case CTF_FONTPITCH
: pFontPitch
= property
; break;
428 case CTF_FONTCHARSET
: pFontCharSet
= property
; break;
430 case CTF_FONTFAMILYNAME_CJK
: pFontFamilyNameCJK
= property
; break;
431 case CTF_FONTSTYLENAME_CJK
: pFontStyleNameCJK
= property
; break;
432 case CTF_FONTFAMILY_CJK
: pFontFamilyCJK
= property
; break;
433 case CTF_FONTPITCH_CJK
: pFontPitchCJK
= property
; break;
434 case CTF_FONTCHARSET_CJK
: pFontCharSetCJK
= property
; break;
436 case CTF_FONTFAMILYNAME_CTL
: pFontFamilyNameCTL
= property
; break;
437 case CTF_FONTSTYLENAME_CTL
: pFontStyleNameCTL
= property
; break;
438 case CTF_FONTFAMILY_CTL
: pFontFamilyCTL
= property
; break;
439 case CTF_FONTPITCH_CTL
: pFontPitchCTL
= property
; break;
440 case CTF_FONTCHARSET_CTL
: pFontCharSetCTL
= property
; break;
442 case CTF_ALLBORDERDISTANCE
: pAllBorderDistance
= property
; break;
443 case CTF_LEFTBORDERDISTANCE
: pBorderDistances
[XML_LINE_LEFT
] = property
; break;
444 case CTF_RIGHTBORDERDISTANCE
: pBorderDistances
[XML_LINE_RIGHT
] = property
; break;
445 case CTF_TOPBORDERDISTANCE
: pBorderDistances
[XML_LINE_TOP
] = property
; break;
446 case CTF_BOTTOMBORDERDISTANCE
: pBorderDistances
[XML_LINE_BOTTOM
] = property
; break;
447 case CTF_ALLBORDER
: pAllBorder
= property
; break;
448 case CTF_LEFTBORDER
: pBorders
[XML_LINE_LEFT
] = property
; break;
449 case CTF_RIGHTBORDER
: pBorders
[XML_LINE_RIGHT
] = property
; break;
450 case CTF_TOPBORDER
: pBorders
[XML_LINE_TOP
] = property
; break;
451 case CTF_BOTTOMBORDER
: pBorders
[XML_LINE_BOTTOM
] = property
; break;
452 case CTF_ALLBORDERWIDTH
: pAllBorderWidth
= property
; break;
453 case CTF_LEFTBORDERWIDTH
: pBorderWidths
[XML_LINE_LEFT
] = property
; break;
454 case CTF_RIGHTBORDERWIDTH
: pBorderWidths
[XML_LINE_RIGHT
] = property
; break;
455 case CTF_TOPBORDERWIDTH
: pBorderWidths
[XML_LINE_TOP
] = property
; break;
456 case CTF_BOTTOMBORDERWIDTH
: pBorderWidths
[XML_LINE_BOTTOM
] = property
; break;
458 case CTF_CHARALLBORDERDISTANCE
: pCharAllBorderDistance
= property
; break;
459 case CTF_CHARLEFTBORDERDISTANCE
: pCharBorderDistances
[XML_LINE_LEFT
] = property
; break;
460 case CTF_CHARRIGHTBORDERDISTANCE
: pCharBorderDistances
[XML_LINE_RIGHT
] = property
; break;
461 case CTF_CHARTOPBORDERDISTANCE
: pCharBorderDistances
[XML_LINE_TOP
] = property
; break;
462 case CTF_CHARBOTTOMBORDERDISTANCE
: pCharBorderDistances
[XML_LINE_BOTTOM
] = property
; break;
463 case CTF_CHARALLBORDER
: pCharAllBorder
= property
; break;
464 case CTF_CHARLEFTBORDER
: pCharBorders
[XML_LINE_LEFT
] = property
; break;
465 case CTF_CHARRIGHTBORDER
: pCharBorders
[XML_LINE_RIGHT
] = property
; break;
466 case CTF_CHARTOPBORDER
: pCharBorders
[XML_LINE_TOP
] = property
; break;
467 case CTF_CHARBOTTOMBORDER
: pCharBorders
[XML_LINE_BOTTOM
] = property
; break;
468 case CTF_CHARALLBORDERWIDTH
: pCharAllBorderWidth
= property
; break;
469 case CTF_CHARLEFTBORDERWIDTH
: pCharBorderWidths
[XML_LINE_LEFT
] = property
; break;
470 case CTF_CHARRIGHTBORDERWIDTH
: pCharBorderWidths
[XML_LINE_RIGHT
] = property
; break;
471 case CTF_CHARTOPBORDERWIDTH
: pCharBorderWidths
[XML_LINE_TOP
] = property
; break;
472 case CTF_CHARBOTTOMBORDERWIDTH
: pCharBorderWidths
[XML_LINE_BOTTOM
] = property
; break;
474 case CTF_ANCHORTYPE
: break;
475 case CTF_VERTICALPOS
: pVertOrient
= property
; break;
476 case CTF_VERTICALREL_ASCHAR
: pVertOrientRelAsChar
= property
; break;
478 case CTF_FRAMEHEIGHT_MIN_ABS
:
479 case CTF_FRAMEHEIGHT_MIN_REL
:
480 // case CTF_SYNCHEIGHT_MIN:
481 bHasAnyMinHeight
= true;
483 case CTF_FRAMEHEIGHT_ABS
:
484 case CTF_FRAMEHEIGHT_REL
:
485 // case CTF_SYNCHEIGHT:
486 bHasAnyHeight
= true; break;
487 case CTF_FRAMEWIDTH_MIN_ABS
:
488 case CTF_FRAMEWIDTH_MIN_REL
:
489 bHasAnyMinWidth
= true;
491 case CTF_FRAMEWIDTH_ABS
:
492 case CTF_FRAMEWIDTH_REL
:
493 bHasAnyWidth
= true; break;
494 case CTF_BACKGROUND_TRANSPARENCY
: pBackTransparency
= property
; break;
495 case CTF_BACKGROUND_TRANSPARENT
: pBackTransparent
= property
; break;
496 case CTF_FILLSTYLE
: pFillStyle
= property
; break;
497 case CTF_FILLCOLOR
: pFillColor
= property
; break;
498 case CTF_PARAMARGINALL
:
499 case CTF_PARAMARGINALL_REL
:
500 pAllParaMargin
= property
; break;
501 case CTF_PARALEFTMARGIN
:
502 case CTF_PARALEFTMARGIN_REL
:
503 pParaMargins
[XML_LINE_LEFT
] = property
; break;
504 case CTF_PARARIGHTMARGIN
:
505 case CTF_PARARIGHTMARGIN_REL
:
506 pParaMargins
[XML_LINE_RIGHT
] = property
; break;
507 case CTF_PARATOPMARGIN
:
508 case CTF_PARATOPMARGIN_REL
:
509 pParaMargins
[XML_LINE_TOP
] = property
; break;
510 case CTF_PARABOTTOMMARGIN
:
511 case CTF_PARABOTTOMMARGIN_REL
:
512 pParaMargins
[XML_LINE_BOTTOM
] = property
; break;
514 pAllMargin
= property
; break;
516 pMargins
[XML_LINE_LEFT
] = property
; break;
517 case CTF_MARGINRIGHT
:
518 pMargins
[XML_LINE_RIGHT
] = property
; break;
520 pMargins
[XML_LINE_TOP
] = property
; break;
521 case CTF_MARGINBOTTOM
:
522 pMargins
[XML_LINE_BOTTOM
] = property
; break;
526 if( pFontFamilyName
|| pFontStyleName
|| pFontFamily
||
527 pFontPitch
|| pFontCharSet
)
528 FontFinished( pFontFamilyName
, pFontStyleName
, pFontFamily
,
529 pFontPitch
, pFontCharSet
);
530 if( pFontFamilyNameCJK
|| pFontStyleNameCJK
|| pFontFamilyCJK
||
531 pFontPitchCJK
|| pFontCharSetCJK
)
532 FontFinished( pFontFamilyNameCJK
, pFontStyleNameCJK
, pFontFamilyCJK
,
533 pFontPitchCJK
, pFontCharSetCJK
);
534 if( pFontFamilyNameCTL
|| pFontStyleNameCTL
|| pFontFamilyCTL
||
535 pFontPitchCTL
|| pFontCharSetCTL
)
536 FontFinished( pFontFamilyNameCTL
, pFontStyleNameCTL
, pFontFamilyCTL
,
537 pFontPitchCTL
, pFontCharSetCTL
);
539 for (sal_uInt16 i
= 0; i
< 4; i
++)
541 if (pAllParaMargin
&& !pParaMargins
[i
]
542 && isNotDefaultRelSize(pAllParaMargin
, getPropertySetMapper()))
544 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
545 sal_Int16 nTmp
= getPropertySetMapper()->GetEntryContextId(
546 pAllParaMargin
->mnIndex
+ (2*i
) + 2 );
547 assert(nTmp
>= CTF_PARALEFTMARGIN
&&
548 nTmp
<= CTF_PARABOTTOMMARGIN_REL
);
550 pNewParaMargins
[i
].emplace(
551 pAllParaMargin
->mnIndex
+ (2*i
) + 2, pAllParaMargin
->maValue
);
553 if (pAllMargin
&& !pMargins
[i
])
555 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
556 sal_Int16 nTmp
= getPropertySetMapper()->GetEntryContextId(
557 pAllMargin
->mnIndex
+ i
+ 1 );
558 assert(nTmp
>= CTF_MARGINLEFT
&& nTmp
<= CTF_MARGINBOTTOM
);
560 pNewMargins
[i
].emplace(
561 pAllMargin
->mnIndex
+ i
+ 1, pAllMargin
->maValue
);
565 i
, pAllBorderDistance
, pBorderDistances
, pNewBorderDistances
,
566 pAllBorder
, pBorders
, pNewBorders
,
567 pAllBorderWidth
, pBorderWidths
568 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
569 , getPropertySetMapper()
574 i
, pCharAllBorderDistance
, pCharBorderDistances
,
575 pCharNewBorderDistances
, pCharAllBorder
, pCharBorders
,
576 pCharNewBorders
, pCharAllBorderWidth
, pCharBorderWidths
577 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
578 , getPropertySetMapper()
585 pAllParaMargin
->mnIndex
= -1;
589 pAllMargin
->mnIndex
= -1;
592 if( pAllBorderDistance
)
593 pAllBorderDistance
->mnIndex
= -1;
596 pAllBorder
->mnIndex
= -1;
598 if( pAllBorderWidth
)
599 pAllBorderWidth
->mnIndex
= -1;
601 if( pCharAllBorderDistance
)
602 pCharAllBorderDistance
->mnIndex
= -1;
605 pCharAllBorder
->mnIndex
= -1;
607 if( pCharAllBorderWidth
)
608 pCharAllBorderWidth
->mnIndex
= -1;
610 if( pVertOrient
&& pVertOrientRelAsChar
)
612 sal_Int16 nVertOrient
;
613 pVertOrient
->maValue
>>= nVertOrient
;
614 sal_Int16 nVertOrientRel
= 0;
615 pVertOrientRelAsChar
->maValue
>>= nVertOrientRel
;
616 switch( nVertOrient
)
618 case VertOrientation::TOP
:
619 nVertOrient
= nVertOrientRel
;
621 case VertOrientation::CENTER
:
622 switch( nVertOrientRel
)
624 case VertOrientation::CHAR_TOP
:
625 nVertOrient
= VertOrientation::CHAR_CENTER
;
627 case VertOrientation::LINE_TOP
:
628 nVertOrient
= VertOrientation::LINE_CENTER
;
632 case VertOrientation::BOTTOM
:
633 switch( nVertOrientRel
)
635 case VertOrientation::CHAR_TOP
:
636 nVertOrient
= VertOrientation::CHAR_BOTTOM
;
638 case VertOrientation::LINE_TOP
:
639 nVertOrient
= VertOrientation::LINE_BOTTOM
;
644 pVertOrient
->maValue
<<= nVertOrient
;
645 pVertOrientRelAsChar
->mnIndex
= -1;
648 FontDefaultsCheck( pFontFamilyName
,
649 pFontStyleName
, pFontFamily
, pFontPitch
, pFontCharSet
,
650 &pNewFontStyleName
, &pNewFontFamily
, &pNewFontPitch
, &pNewFontCharSet
);
652 FontDefaultsCheck( pFontFamilyNameCJK
,
653 pFontStyleNameCJK
, pFontFamilyCJK
, pFontPitchCJK
, pFontCharSetCJK
,
654 &pNewFontStyleNameCJK
, &pNewFontFamilyCJK
, &pNewFontPitchCJK
, &pNewFontCharSetCJK
);
656 FontDefaultsCheck( pFontFamilyNameCTL
,
657 pFontStyleNameCTL
, pFontFamilyCTL
, pFontPitchCTL
, pFontCharSetCTL
,
658 &pNewFontStyleNameCTL
, &pNewFontFamilyCTL
, &pNewFontPitchCTL
, &pNewFontCharSetCTL
);
660 if (pFillStyle
&& !pFillColor
&& pBackTransparent
661 && drawing::FillStyle_SOLID
== pFillStyle
->maValue
.get
<drawing::FillStyle
>()
662 && pBackTransparent
->maValue
.get
<bool>())
664 // fo:background="transparent", draw:fill="solid" without draw:fill-color
665 // prevent getSvxBrushItemFromSourceSet from adding bogus default color
666 pFillStyle
->mnIndex
= -1;
669 // #i5775# don't overwrite %transparency with binary transparency
670 if( ( pBackTransparency
!= nullptr ) && ( pBackTransparent
!= nullptr ) )
672 if( ! *o3tl::doAccess
<bool>(pBackTransparent
->maValue
) )
673 pBackTransparent
->mnIndex
= -1;
677 // insert newly created properties. This invalidates all iterators!
678 // Most of the pXXX variables in this method are iterators and will be
681 if( pNewFontStyleName
)
683 rProperties
.push_back( *pNewFontStyleName
);
684 pNewFontStyleName
.reset();
689 rProperties
.push_back( *pNewFontFamily
);
690 pNewFontFamily
.reset();
695 rProperties
.push_back( *pNewFontPitch
);
696 pNewFontPitch
.reset();
699 if( pNewFontCharSet
)
701 rProperties
.push_back( *pNewFontCharSet
);
702 pNewFontCharSet
.reset();
705 if( pNewFontStyleNameCJK
)
707 rProperties
.push_back( *pNewFontStyleNameCJK
);
708 pNewFontStyleNameCJK
.reset();
711 if( pNewFontFamilyCJK
)
713 rProperties
.push_back( *pNewFontFamilyCJK
);
714 pNewFontFamilyCJK
.reset();
717 if( pNewFontPitchCJK
)
719 rProperties
.push_back( *pNewFontPitchCJK
);
720 pNewFontPitchCJK
.reset();
723 if( pNewFontCharSetCJK
)
725 rProperties
.push_back( *pNewFontCharSetCJK
);
726 pNewFontCharSetCJK
.reset();
729 if( pNewFontStyleNameCTL
)
731 rProperties
.push_back( *pNewFontStyleNameCTL
);
732 pNewFontStyleNameCTL
.reset();
735 if( pNewFontFamilyCTL
)
737 rProperties
.push_back( *pNewFontFamilyCTL
);
738 pNewFontFamilyCTL
.reset();
741 if( pNewFontPitchCTL
)
743 rProperties
.push_back( *pNewFontPitchCTL
);
744 pNewFontPitchCTL
.reset();
747 if( pNewFontCharSetCTL
)
749 rProperties
.push_back( *pNewFontCharSetCTL
);
750 pNewFontCharSetCTL
.reset();
753 for (sal_uInt16 i
=0; i
<4; i
++)
755 if (pNewParaMargins
[i
])
757 rProperties
.push_back(*pNewParaMargins
[i
]);
761 rProperties
.push_back(*pNewMargins
[i
]);
763 if( pNewBorderDistances
[i
] )
765 rProperties
.push_back( *pNewBorderDistances
[i
] );
766 delete pNewBorderDistances
[i
];
770 rProperties
.push_back( *pNewBorders
[i
] );
771 delete pNewBorders
[i
];
773 if( pCharNewBorderDistances
[i
] )
775 rProperties
.push_back( *pCharNewBorderDistances
[i
] );
776 delete pCharNewBorderDistances
[i
];
778 if( pCharNewBorders
[i
] )
780 rProperties
.push_back( *pCharNewBorders
[i
] );
781 delete pCharNewBorders
[i
];
787 if( m_nSizeTypeIndex
== -2 )
789 const_cast < XMLTextImportPropertyMapper
* > ( this )
790 ->m_nSizeTypeIndex
= -1;
791 sal_Int32 nPropCount
= getPropertySetMapper()->GetEntryCount();
792 for( sal_Int32 j
=0; j
< nPropCount
; j
++ )
794 if( CTF_SIZETYPE
== getPropertySetMapper()
795 ->GetEntryContextId( j
) )
797 const_cast < XMLTextImportPropertyMapper
* > ( this )
798 ->m_nSizeTypeIndex
= j
;
803 if( m_nSizeTypeIndex
!= -1 )
805 XMLPropertyState
aSizeTypeState( m_nSizeTypeIndex
);
806 aSizeTypeState
.maValue
<<= static_cast<sal_Int16
>( bHasAnyMinHeight
809 rProperties
.push_back( aSizeTypeState
);
816 if( m_nWidthTypeIndex
== -2 )
818 const_cast < XMLTextImportPropertyMapper
* > ( this )
819 ->m_nWidthTypeIndex
= -1;
820 sal_Int32 nCount
= getPropertySetMapper()->GetEntryCount();
821 for( sal_Int32 j
=0; j
< nCount
; j
++ )
823 if( CTF_FRAMEWIDTH_TYPE
== getPropertySetMapper()
824 ->GetEntryContextId( j
) )
826 const_cast < XMLTextImportPropertyMapper
* > ( this )
827 ->m_nWidthTypeIndex
= j
;
832 if( m_nWidthTypeIndex
!= -1 )
834 XMLPropertyState
aSizeTypeState( m_nWidthTypeIndex
);
835 aSizeTypeState
.maValue
<<= static_cast<sal_Int16
>( bHasAnyMinWidth
838 rProperties
.push_back( aSizeTypeState
);
841 // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
842 // THIS LINE. All iterators into the rProperties-vector, especially all
843 // pXXX-type variables set in the first switch statement of this method,
844 // may have been invalidated by the above push_back() calls!
848 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */