LibreOffice Module xmloff (master) 1
txtimppr.cxx
Go to the documentation of this file.
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 <memory>
21#include <sal/config.h>
22
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>
32#include <xmloff/txtprmap.hxx>
33#include <xmloff/xmlimp.hxx>
34#include <xmloff/txtimppr.hxx>
35#include <xmloff/maptype.hxx>
36
37#define XML_LINE_LEFT 0
38#define XML_LINE_RIGHT 1
39#define XML_LINE_TOP 2
40#define XML_LINE_BOTTOM 3
41
42
43using namespace ::com::sun::star;
44using namespace ::com::sun::star::uno;
45using namespace ::com::sun::star::table;
46using namespace ::com::sun::star::text;
47
49 XMLPropertyState& rProperty,
50 ::std::vector< XMLPropertyState >& rProperties,
51 const OUString& rValue,
52 const SvXMLUnitConverter& rUnitConverter,
53 const SvXMLNamespaceMap& rNamespaceMap ) const
54{
55 bool bRet = false;
56 sal_Int32 nIndex = rProperty.mnIndex;
57 switch( getPropertySetMapper()->GetEntryContextId( nIndex ) )
58 {
59 case CTF_FONTNAME:
62 if( GetImport().GetFontDecls() != nullptr )
63 {
64 assert((
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) ) ||
76 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
78 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
80 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
82 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
84 getPropertySetMapper()->GetEntryContextId(nIndex+5) ) ||
86 getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
88 getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
90 getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
92 getPropertySetMapper()->GetEntryContextId(nIndex+4) &&
94 getPropertySetMapper()->GetEntryContextId(nIndex+5) )
95 ) && "illegal property map" );
96
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
103 }
104 break;
105
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.
114 bRet = getPropertySetMapper()->importXML( rValue, rProperty,
115 rUnitConverter );
116 break;
117
118 case CTF_TEXT_DISPLAY:
119 bRet = getPropertySetMapper()->importXML( rValue, rProperty,
120 rUnitConverter );
121 if( SvXMLImport::OOo_2x == GetImport().getGeneratorVersion() )
122 {
123 bool bHidden = false;
124 rProperty.maValue >>= bHidden;
125 bHidden = !bHidden;
126 rProperty.maValue <<= bHidden;
127 }
128 break;
129 default:
131 rProperties, rValue, rUnitConverter, rNamespaceMap );
132 break;
133 }
134
135 return bRet;
136}
137
140 SvXMLImport& rImp ) :
141 SvXMLImportPropertyMapper( rMapper, rImp ),
142 nSizeTypeIndex( -2 ),
143 nWidthTypeIndex( -2 )
144{
145}
146
148{
149}
150
152 XMLPropertyState *pFontFamilyNameState,
153 XMLPropertyState *pFontStyleNameState,
154 XMLPropertyState *pFontFamilyState,
155 XMLPropertyState *pFontPitchState,
156 XMLPropertyState *pFontCharsetState )
157{
158 if( pFontFamilyNameState && pFontFamilyNameState->mnIndex != -1 )
159 {
160 OUString sName;
161 pFontFamilyNameState->maValue >>= sName;
162 if( sName.isEmpty() )
163 pFontFamilyNameState->mnIndex = -1;
164 }
165 if( !pFontFamilyNameState || pFontFamilyNameState->mnIndex == -1 )
166 {
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;
175 }
176}
177
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
194{
195 if( pFontFamilyName )
196 {
197 Any aAny;
198
199 if( !pFontStyleName )
200 {
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->emplace( pFontFamilyName->mnIndex + 1, aAny );
208 }
209
210 if( !pFontFamily )
211 {
212 aAny <<= sal_Int16(css::awt::FontFamily::DONTKNOW);
213
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);
218 #endif
219 ppNewFontFamily->emplace( pFontFamilyName->mnIndex + 2, aAny );
220 }
221
222 if( !pFontPitch )
223 {
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);
229 #endif
230 ppNewFontPitch->emplace( pFontFamilyName->mnIndex + 3, aAny );
231 }
232
233 if( !pFontCharSet )
234 {
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);
240 #endif
241 ppNewFontCharSet->emplace( pFontFamilyName->mnIndex + 4, aAny );
242 }
243 }
244
245 (void) this; // avoid loplugin:staticmethods
246}
247
248namespace {
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
254//crock.
255
256//On import clear 100% all-margins relative sizes.
257bool
258isNotDefaultRelSize(const XMLPropertyState* pRelState, const rtl::Reference<XMLPropertySetMapper>& rPrMap)
259{
260 if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
261 {
262 sal_Int32 nTemp = 0;
263 pRelState->maValue >>= nTemp;
264 return nTemp != 100;
265 }
266 return true;
267}
268
275void 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
283#endif
284)
285{
286 if( pAllBorderDistance && !pBorderDistances[nIndex] )
287 {
288#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
289 sal_Int16 nTmp = rMapper->GetEntryContextId(
290 pAllBorderDistance->mnIndex + nIndex + 1 );
292 rMapper->GetEntryContextId(pAllBorderDistance->mnIndex))
293 {
294 assert(nTmp >= CTF_CHARLEFTBORDERDISTANCE &&
296 }
297 else
298 {
299 assert(nTmp >= CTF_LEFTBORDERDISTANCE &&
301 }
302#endif
303 pNewBorderDistances[nIndex] =
304 new XMLPropertyState( pAllBorderDistance->mnIndex + nIndex + 1,
305 pAllBorderDistance->maValue );
306 pBorderDistances[nIndex] = pNewBorderDistances[nIndex];
307 }
308 if( pAllBorder && !pBorders[nIndex] )
309 {
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))
315 {
316 assert(nTmp >= CTF_CHARLEFTBORDER && nTmp <= CTF_CHARBOTTOMBORDER);
317 }
318 else
319 {
320 assert(nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER);
321 }
322#endif
323 pNewBorders[nIndex] = new XMLPropertyState( pAllBorder->mnIndex + nIndex + 1,
324 pAllBorder->maValue );
325 pBorders[nIndex] = pNewBorders[nIndex];
326 }
327 if( !pBorderWidths[nIndex] )
328 pBorderWidths[nIndex] = pAllBorderWidth;
329 else
330 pBorderWidths[nIndex]->mnIndex = -1;
331
332 if( !(pBorders[nIndex] && pBorderWidths[nIndex]) )
333 return;
334
335 table::BorderLine2 aBorderLine;
336 pBorders[nIndex]->maValue >>= aBorderLine;
337
338 table::BorderLine2 aBorderLineWidth;
339 pBorderWidths[nIndex]->maValue >>= aBorderLineWidth;
340
341 aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
342 aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
343 aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
344 aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
345
346 pBorders[nIndex]->maValue <<= aBorderLine;
347}
348
349}
350
352 ::std::vector< XMLPropertyState >& rProperties,
353 sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
354{
355 bool bHasAnyHeight = false;
356 bool bHasAnyMinHeight = false;
357 bool bHasAnyWidth = false;
358 bool bHasAnyMinWidth = false;
359
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);
415
416 for( auto& rProperty : rProperties )
417 {
418 XMLPropertyState* property = &rProperty;
419 if( -1 == property->mnIndex )
420 continue;
421
422 switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
423 {
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;
429
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;
435
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;
441
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;
457
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;
473
474 case CTF_ANCHORTYPE: break;
475 case CTF_VERTICALPOS: pVertOrient = property; break;
476 case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
477
480// case CTF_SYNCHEIGHT_MIN:
481 bHasAnyMinHeight = true;
482 [[fallthrough]];
485// case CTF_SYNCHEIGHT:
486 bHasAnyHeight = true; break;
489 bHasAnyMinWidth = true;
490 [[fallthrough]];
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;
500 pAllParaMargin = property; break;
503 pParaMargins[XML_LINE_LEFT] = property; break;
506 pParaMargins[XML_LINE_RIGHT] = property; break;
509 pParaMargins[XML_LINE_TOP] = property; break;
512 pParaMargins[XML_LINE_BOTTOM] = property; break;
513 case CTF_MARGINALL:
514 pAllMargin = property; break;
515 case CTF_MARGINLEFT:
516 pMargins[XML_LINE_LEFT] = property; break;
517 case CTF_MARGINRIGHT:
518 pMargins[XML_LINE_RIGHT] = property; break;
519 case CTF_MARGINTOP:
520 pMargins[XML_LINE_TOP] = property; break;
521 case CTF_MARGINBOTTOM:
522 pMargins[XML_LINE_BOTTOM] = property; break;
523 }
524 }
525
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 );
538
539 for (sal_uInt16 i = 0; i < 4; i++)
540 {
541 if (pAllParaMargin && !pParaMargins[i]
542 && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
543 {
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 &&
549#endif
550 pNewParaMargins[i].emplace(
551 pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue);
552 }
553 if (pAllMargin && !pMargins[i])
554 {
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);
559#endif
560 pNewMargins[i].emplace(
561 pAllMargin->mnIndex + i + 1, pAllMargin->maValue);
562 }
563
564 lcl_SeparateBorder(
565 i, pAllBorderDistance, pBorderDistances, pNewBorderDistances,
566 pAllBorder, pBorders, pNewBorders,
567 pAllBorderWidth, pBorderWidths
568#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
570#endif
571 );
572
573 lcl_SeparateBorder(
574 i, pCharAllBorderDistance, pCharBorderDistances,
575 pCharNewBorderDistances, pCharAllBorder, pCharBorders,
576 pCharNewBorders, pCharAllBorderWidth, pCharBorderWidths
577#if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
579#endif
580 );
581 }
582
583 if (pAllParaMargin)
584 {
585 pAllParaMargin->mnIndex = -1;
586 }
587 if (pAllMargin)
588 {
589 pAllMargin->mnIndex = -1;
590 }
591
592 if( pAllBorderDistance )
593 pAllBorderDistance->mnIndex = -1;
594
595 if( pAllBorder )
596 pAllBorder->mnIndex = -1;
597
598 if( pAllBorderWidth )
599 pAllBorderWidth->mnIndex = -1;
600
601 if( pCharAllBorderDistance )
602 pCharAllBorderDistance->mnIndex = -1;
603
604 if( pCharAllBorder )
605 pCharAllBorder->mnIndex = -1;
606
607 if( pCharAllBorderWidth )
608 pCharAllBorderWidth->mnIndex = -1;
609
610 if( pVertOrient && pVertOrientRelAsChar )
611 {
612 sal_Int16 nVertOrient;
613 pVertOrient->maValue >>= nVertOrient;
614 sal_Int16 nVertOrientRel = 0;
615 pVertOrientRelAsChar->maValue >>= nVertOrientRel;
616 switch( nVertOrient )
617 {
618 case VertOrientation::TOP:
619 nVertOrient = nVertOrientRel;
620 break;
621 case VertOrientation::CENTER:
622 switch( nVertOrientRel )
623 {
624 case VertOrientation::CHAR_TOP:
625 nVertOrient = VertOrientation::CHAR_CENTER;
626 break;
627 case VertOrientation::LINE_TOP:
628 nVertOrient = VertOrientation::LINE_CENTER;
629 break;
630 }
631 break;
632 case VertOrientation::BOTTOM:
633 switch( nVertOrientRel )
634 {
635 case VertOrientation::CHAR_TOP:
636 nVertOrient = VertOrientation::CHAR_BOTTOM;
637 break;
638 case VertOrientation::LINE_TOP:
639 nVertOrient = VertOrientation::LINE_BOTTOM;
640 break;
641 }
642 break;
643 }
644 pVertOrient->maValue <<= nVertOrient;
645 pVertOrientRelAsChar->mnIndex = -1;
646 }
647
648 FontDefaultsCheck( pFontFamilyName,
649 pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
650 &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
651
652 FontDefaultsCheck( pFontFamilyNameCJK,
653 pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
654 &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
655
656 FontDefaultsCheck( pFontFamilyNameCTL,
657 pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
658 &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
659
660 if (pFillStyle && !pFillColor && pBackTransparent
661 && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>()
662 && pBackTransparent->maValue.get<bool>())
663 {
664 // fo:background="transparent", draw:fill="solid" without draw:fill-color
665 // prevent getSvxBrushItemFromSourceSet from adding bogus default color
666 pFillStyle->mnIndex = -1;
667 }
668
669 // #i5775# don't overwrite %transparency with binary transparency
670 if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) )
671 {
672 if( ! *o3tl::doAccess<bool>(pBackTransparent->maValue) )
673 pBackTransparent->mnIndex = -1;
674 }
675
676
677 // insert newly created properties. This invalidates all iterators!
678 // Most of the pXXX variables in this method are iterators and will be
679 // invalidated!!!
680
681 if( pNewFontStyleName )
682 {
683 rProperties.push_back( *pNewFontStyleName );
684 pNewFontStyleName.reset();
685 }
686
687 if( pNewFontFamily )
688 {
689 rProperties.push_back( *pNewFontFamily );
690 pNewFontFamily.reset();
691 }
692
693 if( pNewFontPitch )
694 {
695 rProperties.push_back( *pNewFontPitch );
696 pNewFontPitch.reset();
697 }
698
699 if( pNewFontCharSet )
700 {
701 rProperties.push_back( *pNewFontCharSet );
702 pNewFontCharSet.reset();
703 }
704
705 if( pNewFontStyleNameCJK )
706 {
707 rProperties.push_back( *pNewFontStyleNameCJK );
708 pNewFontStyleNameCJK.reset();
709 }
710
711 if( pNewFontFamilyCJK )
712 {
713 rProperties.push_back( *pNewFontFamilyCJK );
714 pNewFontFamilyCJK.reset();
715 }
716
717 if( pNewFontPitchCJK )
718 {
719 rProperties.push_back( *pNewFontPitchCJK );
720 pNewFontPitchCJK.reset();
721 }
722
723 if( pNewFontCharSetCJK )
724 {
725 rProperties.push_back( *pNewFontCharSetCJK );
726 pNewFontCharSetCJK.reset();
727 }
728
729 if( pNewFontStyleNameCTL)
730 {
731 rProperties.push_back( *pNewFontStyleNameCTL );
732 pNewFontStyleNameCTL.reset();
733 }
734
735 if( pNewFontFamilyCTL )
736 {
737 rProperties.push_back( *pNewFontFamilyCTL );
738 pNewFontFamilyCTL.reset();
739 }
740
741 if( pNewFontPitchCTL )
742 {
743 rProperties.push_back( *pNewFontPitchCTL );
744 pNewFontPitchCTL.reset();
745 }
746
747 if( pNewFontCharSetCTL )
748 {
749 rProperties.push_back( *pNewFontCharSetCTL );
750 pNewFontCharSetCTL.reset();
751 }
752
753 for (sal_uInt16 i=0; i<4; i++)
754 {
755 if (pNewParaMargins[i])
756 {
757 rProperties.push_back(*pNewParaMargins[i]);
758 }
759 if (pNewMargins[i])
760 {
761 rProperties.push_back(*pNewMargins[i]);
762 }
763 if( pNewBorderDistances[i] )
764 {
765 rProperties.push_back( *pNewBorderDistances[i] );
766 delete pNewBorderDistances[i];
767 }
768 if( pNewBorders[i] )
769 {
770 rProperties.push_back( *pNewBorders[i] );
771 delete pNewBorders[i];
772 }
773 if( pCharNewBorderDistances[i] )
774 {
775 rProperties.push_back( *pCharNewBorderDistances[i] );
776 delete pCharNewBorderDistances[i];
777 }
778 if( pCharNewBorders[i] )
779 {
780 rProperties.push_back( *pCharNewBorders[i] );
781 delete pCharNewBorders[i];
782 }
783 }
784
785 if( bHasAnyHeight )
786 {
787 if( nSizeTypeIndex == -2 )
788 {
789 const_cast < XMLTextImportPropertyMapper * > ( this )
790 ->nSizeTypeIndex = -1;
791 sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
792 for( sal_Int32 j=0; j < nPropCount; j++ )
793 {
795 ->GetEntryContextId( j ) )
796 {
797 const_cast < XMLTextImportPropertyMapper * > ( this )
798 ->nSizeTypeIndex = j;
799 break;
800 }
801 }
802 }
803 if( nSizeTypeIndex != -1 )
804 {
805 XMLPropertyState aSizeTypeState( nSizeTypeIndex );
806 aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinHeight
807 ? SizeType::MIN
808 : SizeType::FIX);
809 rProperties.push_back( aSizeTypeState );
810 }
811 }
812
813 if( !bHasAnyWidth )
814 return;
815
816 if( nWidthTypeIndex == -2 )
817 {
818 const_cast < XMLTextImportPropertyMapper * > ( this )
819 ->nWidthTypeIndex = -1;
820 sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
821 for( sal_Int32 j=0; j < nCount; j++ )
822 {
824 ->GetEntryContextId( j ) )
825 {
826 const_cast < XMLTextImportPropertyMapper * > ( this )
827 ->nWidthTypeIndex = j;
828 break;
829 }
830 }
831 }
832 if( nWidthTypeIndex != -1 )
833 {
834 XMLPropertyState aSizeTypeState( nWidthTypeIndex );
835 aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth
836 ? SizeType::MIN
837 : SizeType::FIX);
838 rProperties.push_back( aSizeTypeState );
839 }
840
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!
845}
846
847
848/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool handleSpecialItem(XMLPropertyState &rProperty, ::std::vector< XMLPropertyState > &rProperties, const OUString &rValue, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap) const
this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set
Definition: xmlimppr.cxx:347
const rtl::Reference< XMLPropertySetMapper > & getPropertySetMapper() const
Definition: xmlimppr.hxx:197
SvXMLImport & GetImport() const
Definition: xmlimppr.hxx:76
XMLFontStylesContext * GetFontDecls()
Definition: xmlimp.cxx:1588
static const sal_uInt16 OOo_2x
Definition: xmlimp.hxx:536
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
bool FillProperties(const OUString &rName, ::std::vector< XMLPropertyState > &rProps, sal_Int32 nFamilyNameIdx, sal_Int32 nStyleNameIdx, sal_Int32 nFamilyIdx, sal_Int32 nPitchIdx, sal_Int32 nCharsetIdx) const
virtual void finished(::std::vector< XMLPropertyState > &rProperties, sal_Int32 nStartIndex, sal_Int32 nEndIndex) const override
This method is called when all attributes have benn processed.
Definition: txtimppr.cxx:351
virtual bool handleSpecialItem(XMLPropertyState &rProperty, ::std::vector< XMLPropertyState > &rProperties, const OUString &rValue, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap) const override
this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set
Definition: txtimppr.cxx:48
void FontDefaultsCheck(XMLPropertyState const *pFontFamilyName, XMLPropertyState const *pFontStyleName, XMLPropertyState const *pFontFamily, XMLPropertyState const *pFontPitch, XMLPropertyState const *pFontCharSet, std::optional< XMLPropertyState > *ppNewFontStyleName, std::optional< XMLPropertyState > *ppNewFontFamily, std::optional< XMLPropertyState > *ppNewFontPitch, std::optional< XMLPropertyState > *ppNewFontCharSet) const
since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily", "CharFontPitch" and...
Definition: txtimppr.cxx:184
XMLTextImportPropertyMapper(const rtl::Reference< XMLPropertySetMapper > &rMapper, SvXMLImport &rImport)
Definition: txtimppr.cxx:138
static void FontFinished(XMLPropertyState *pFontFamilyNameState, XMLPropertyState *pFontStyleNameState, XMLPropertyState *pFontFamilyState, XMLPropertyState *pFontPitchState, XMLPropertyState *pFontCharsetState)
Definition: txtimppr.cxx:151
virtual ~XMLTextImportPropertyMapper() override
Definition: txtimppr.cxx:147
int nCount
sal_Int32 nIndex
const char * sName
enum SAL_DLLPUBLIC_RTTI FillStyle
Definition: xmlimppr.hxx:42
int i
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:140
css::uno::Any maValue
Definition: maptype.hxx:142
sal_Int32 mnIndex
Definition: maptype.hxx:141
#define XML_LINE_TOP
Definition: txtimppr.cxx:39
#define XML_LINE_BOTTOM
Definition: txtimppr.cxx:40
#define XML_LINE_RIGHT
Definition: txtimppr.cxx:38
#define XML_LINE_LEFT
Definition: txtimppr.cxx:37
#define CTF_RIGHTBORDER
Definition: txtprmap.hxx:49
#define CTF_FONTNAME_CJK
Definition: txtprmap.hxx:94
#define CTF_PARAMARGINALL_REL
Definition: txtprmap.hxx:174
#define CTF_LEFTBORDERWIDTH
Definition: txtprmap.hxx:38
#define CTF_CHARLEFTBORDERWIDTH
Definition: txtprmap.hxx:183
#define CTF_MARGINALL
Definition: txtprmap.hxx:175
#define CTF_VERTICALREL_ASCHAR
Definition: txtprmap.hxx:87
#define CTF_PARABOTTOMMARGIN_REL
Definition: txtprmap.hxx:36
#define CTF_PARALEFTMARGIN
Definition: txtprmap.hxx:27
#define CTF_PARATOPMARGIN_REL
Definition: txtprmap.hxx:34
#define CTF_FONTSTYLENAME_CTL
Definition: txtprmap.hxx:105
#define CTF_CHARRIGHTBORDERWIDTH
Definition: txtprmap.hxx:184
#define CTF_BOTTOMBORDER
Definition: txtprmap.hxx:51
#define CTF_BOTTOMBORDERDISTANCE
Definition: txtprmap.hxx:46
#define CTF_CHARTOPBORDERWIDTH
Definition: txtprmap.hxx:185
#define CTF_FONTFAMILYNAME
Definition: txtprmap.hxx:58
#define CTF_ALLBORDERWIDTH
Definition: txtprmap.hxx:37
#define CTF_PARATOPMARGIN
Definition: txtprmap.hxx:33
#define CTF_CHARBOTTOMBORDER
Definition: txtprmap.hxx:196
#define CTF_ANCHORTYPE
Definition: txtprmap.hxx:75
#define CTF_CHARALLBORDERDISTANCE
Definition: txtprmap.hxx:187
#define CTF_PARARIGHTMARGIN
Definition: txtprmap.hxx:29
#define CTF_TOPBORDERDISTANCE
Definition: txtprmap.hxx:45
#define CTF_FRAMEHEIGHT_MIN_REL
Definition: txtprmap.hxx:68
#define CTF_CHARTOPBORDER
Definition: txtprmap.hxx:195
#define CTF_CHARBOTTOMBORDERDISTANCE
Definition: txtprmap.hxx:191
#define CTF_FONTFAMILY_CTL
Definition: txtprmap.hxx:106
#define CTF_MARGINRIGHT
Definition: txtprmap.hxx:177
#define CTF_PARAMARGINALL
Definition: txtprmap.hxx:173
#define CTF_RIGHTBORDERDISTANCE
Definition: txtprmap.hxx:44
#define CTF_FONTNAME_CTL
Definition: txtprmap.hxx:103
#define CTF_MARGINBOTTOM
Definition: txtprmap.hxx:179
#define CTF_CHARALLBORDER
Definition: txtprmap.hxx:192
#define CTF_MARGINTOP
Definition: txtprmap.hxx:178
#define CTF_FONTFAMILYNAME_CJK
Definition: txtprmap.hxx:95
#define CTF_LEFTBORDER
Definition: txtprmap.hxx:48
#define CTF_CHARTOPBORDERDISTANCE
Definition: txtprmap.hxx:190
#define CTF_FONTFAMILY
Definition: txtprmap.hxx:60
#define CTF_FRAMEWIDTH_MIN_REL
Definition: txtprmap.hxx:148
#define CTF_FONTCHARSET
Definition: txtprmap.hxx:62
#define CTF_TOPBORDER
Definition: txtprmap.hxx:50
#define CTF_RIGHTBORDERWIDTH
Definition: txtprmap.hxx:39
#define CTF_FONTPITCH
Definition: txtprmap.hxx:61
#define CTF_ALLBORDER
Definition: txtprmap.hxx:47
#define CTF_CHARRIGHTBORDER
Definition: txtprmap.hxx:194
#define CTF_FONTFAMILYNAME_CTL
Definition: txtprmap.hxx:104
#define CTF_FRAMEWIDTH_MIN_ABS
Definition: txtprmap.hxx:147
#define CTF_FONTNAME
Definition: txtprmap.hxx:93
#define CTF_SIZETYPE
Definition: txtprmap.hxx:69
#define CTF_FILLSTYLE
Definition: txtprmap.hxx:202
#define CTF_FONTSTYLENAME_CJK
Definition: txtprmap.hxx:96
#define CTF_TEXT_DISPLAY
Definition: txtprmap.hxx:170
#define CTF_FRAMEWIDTH_ABS
Definition: txtprmap.hxx:146
#define CTF_BACKGROUND_TRANSPARENT
Definition: txtprmap.hxx:144
#define CTF_PARABOTTOMMARGIN
Definition: txtprmap.hxx:35
#define CTF_PARARIGHTMARGIN_REL
Definition: txtprmap.hxx:30
#define CTF_CHARLEFTBORDER
Definition: txtprmap.hxx:193
#define CTF_FRAMEHEIGHT_MIN_ABS
Definition: txtprmap.hxx:67
#define CTF_MARGINLEFT
Definition: txtprmap.hxx:176
#define CTF_FRAMEWIDTH_REL
Definition: txtprmap.hxx:149
#define CTF_TOPBORDERWIDTH
Definition: txtprmap.hxx:40
#define CTF_FONTSTYLENAME
Definition: txtprmap.hxx:59
#define CTF_LEFTBORDERDISTANCE
Definition: txtprmap.hxx:43
#define CTF_CHARRIGHTBORDERDISTANCE
Definition: txtprmap.hxx:189
#define CTF_FONTPITCH_CJK
Definition: txtprmap.hxx:98
#define CTF_FONTCHARSET_CJK
Definition: txtprmap.hxx:99
#define CTF_VERTICALPOS
Definition: txtprmap.hxx:83
#define CTF_FONTCHARSET_CTL
Definition: txtprmap.hxx:108
#define CTF_ALLBORDERDISTANCE
Definition: txtprmap.hxx:42
#define CTF_FRAMEHEIGHT_ABS
Definition: txtprmap.hxx:65
#define CTF_BACKGROUND_TRANSPARENCY
Definition: txtprmap.hxx:143
#define CTF_FRAMEHEIGHT_REL
Definition: txtprmap.hxx:66
#define CTF_PARALEFTMARGIN_REL
Definition: txtprmap.hxx:28
#define CTF_CHARBOTTOMBORDERWIDTH
Definition: txtprmap.hxx:186
#define CTF_FILLCOLOR
Definition: txtprmap.hxx:203
#define CTF_FONTFAMILY_CJK
Definition: txtprmap.hxx:97
#define CTF_FONTPITCH_CTL
Definition: txtprmap.hxx:107
#define CTF_CHARALLBORDERWIDTH
Definition: txtprmap.hxx:182
#define CTF_CHARLEFTBORDERDISTANCE
Definition: txtprmap.hxx:188
#define CTF_BOTTOMBORDERWIDTH
Definition: txtprmap.hxx:41
#define CTF_FRAMEWIDTH_TYPE
Definition: txtprmap.hxx:150