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 
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;
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:
60  case CTF_FONTNAME_CJK:
61  case CTF_FONTNAME_CTL:
62  if( GetImport().GetFontDecls() != nullptr )
63  {
64  assert((
66  getPropertySetMapper()->GetEntryContextId(nIndex+1) &&
68  getPropertySetMapper()->GetEntryContextId(nIndex+2) &&
70  getPropertySetMapper()->GetEntryContextId(nIndex+3) &&
71  CTF_FONTPITCH ==
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.
111  case CTF_FONTFAMILYNAME:
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::unique_ptr<XMLPropertyState>* ppNewFontStyleName,
191  std::unique_ptr<XMLPropertyState>* ppNewFontFamily,
192  std::unique_ptr<XMLPropertyState>* ppNewFontPitch,
193  std::unique_ptr<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 );
206  #endif
207  ppNewFontStyleName->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 1,
208  aAny ));
209  }
210 
211  if( !pFontFamily )
212  {
213  aAny <<= sal_Int16(css::awt::FontFamily::DONTKNOW);
214 
215  #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
216  sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
217  pFontFamilyName->mnIndex + 2 );
218  assert(nTmp == CTF_FONTFAMILY || nTmp == CTF_FONTFAMILY_CJK || nTmp == CTF_FONTFAMILY_CTL);
219  #endif
220  ppNewFontFamily->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 2,
221  aAny ));
222  }
223 
224  if( !pFontPitch )
225  {
226  aAny <<= sal_Int16(css::awt::FontPitch::DONTKNOW);
227  #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
228  sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
229  pFontFamilyName->mnIndex + 3 );
230  assert(nTmp == CTF_FONTPITCH || nTmp == CTF_FONTPITCH_CJK || nTmp == CTF_FONTPITCH_CTL);
231  #endif
232  ppNewFontPitch->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 3,
233  aAny ));
234  }
235 
236  if( !pFontCharSet )
237  {
238  aAny <<= static_cast<sal_Int16>(osl_getThreadTextEncoding());
239  #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
240  sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
241  pFontFamilyName->mnIndex + 4 );
242  assert(nTmp == CTF_FONTCHARSET || nTmp == CTF_FONTCHARSET_CJK || nTmp == CTF_FONTCHARSET_CTL);
243  #endif
244  ppNewFontCharSet->reset(new XMLPropertyState( pFontFamilyName->mnIndex + 4,
245  aAny ));
246  }
247  }
248 
249  (void) this; // avoid loplugin:staticmethods
250 }
251 
252 namespace {
253 //fdo#58730 The [UL|LR]Space class has a deficiency where "100%" also serves as
254 //a flag that the value is an absolute value so we can't truly handle an
255 //up/lower space property which wants to specify its 200% upper but 100% lower
256 //of its parent (try typing 100% vs 200% into the edit style dialog and revisit
257 //your style). So on xml load that ends up meaning 200%, 0 lower. This is a
258 //crock.
259 
260 //On import clear 100% all-margins relative sizes.
261 bool
262 isNotDefaultRelSize(const XMLPropertyState* pRelState, const rtl::Reference<XMLPropertySetMapper>& rPrMap)
263 {
264  if (rPrMap->GetEntryContextId(pRelState->mnIndex) == CTF_PARAMARGINALL_REL)
265  {
266  sal_Int32 nTemp = 0;
267  pRelState->maValue >>= nTemp;
268  return nTemp != 100;
269  }
270  return true;
271 }
272 
279 void lcl_SeparateBorder(
280  sal_uInt16 nIndex, XMLPropertyState const * pAllBorderDistance,
281  XMLPropertyState* pBorderDistances[4], XMLPropertyState* pNewBorderDistances[4],
282  XMLPropertyState const * pAllBorder, XMLPropertyState* pBorders[4],
283  XMLPropertyState* pNewBorders[4], XMLPropertyState* pAllBorderWidth,
284  XMLPropertyState* pBorderWidths[4]
285 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
287 #endif
288 )
289 {
290  if( pAllBorderDistance && !pBorderDistances[nIndex] )
291  {
292 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
293  sal_Int16 nTmp = rMapper->GetEntryContextId(
294  pAllBorderDistance->mnIndex + nIndex + 1 );
296  rMapper->GetEntryContextId(pAllBorderDistance->mnIndex))
297  {
300  }
301  else
302  {
303  assert(nTmp >= CTF_LEFTBORDERDISTANCE &&
304  nTmp <= CTF_BOTTOMBORDERDISTANCE);
305  }
306 #endif
307  pNewBorderDistances[nIndex] =
308  new XMLPropertyState( pAllBorderDistance->mnIndex + nIndex + 1,
309  pAllBorderDistance->maValue );
310  pBorderDistances[nIndex] = pNewBorderDistances[nIndex];
311  }
312  if( pAllBorder && !pBorders[nIndex] )
313  {
314 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
315  sal_Int16 nTmp = rMapper->GetEntryContextId(
316  pAllBorder->mnIndex + nIndex + 1 );
317  if (CTF_CHARALLBORDER ==
318  rMapper->GetEntryContextId(pAllBorder->mnIndex))
319  {
320  assert(nTmp >= CTF_CHARLEFTBORDER && nTmp <= CTF_CHARBOTTOMBORDER);
321  }
322  else
323  {
324  assert(nTmp >= CTF_LEFTBORDER && nTmp <= CTF_BOTTOMBORDER);
325  }
326 #endif
327  pNewBorders[nIndex] = new XMLPropertyState( pAllBorder->mnIndex + nIndex + 1,
328  pAllBorder->maValue );
329  pBorders[nIndex] = pNewBorders[nIndex];
330  }
331  if( !pBorderWidths[nIndex] )
332  pBorderWidths[nIndex] = pAllBorderWidth;
333  else
334  pBorderWidths[nIndex]->mnIndex = -1;
335 
336  if( !(pBorders[nIndex] && pBorderWidths[nIndex]) )
337  return;
338 
339  table::BorderLine2 aBorderLine;
340  pBorders[nIndex]->maValue >>= aBorderLine;
341 
342  table::BorderLine2 aBorderLineWidth;
343  pBorderWidths[nIndex]->maValue >>= aBorderLineWidth;
344 
345  aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth;
346  aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth;
347  aBorderLine.LineDistance = aBorderLineWidth.LineDistance;
348  aBorderLine.LineWidth = aBorderLineWidth.LineWidth;
349 
350  pBorders[nIndex]->maValue <<= aBorderLine;
351 }
352 
353 }
354 
356  ::std::vector< XMLPropertyState >& rProperties,
357  sal_Int32 /*nStartIndex*/, sal_Int32 /*nEndIndex*/ ) const
358 {
359  bool bHasAnyHeight = false;
360  bool bHasAnyMinHeight = false;
361  bool bHasAnyWidth = false;
362  bool bHasAnyMinWidth = false;
363 
364  XMLPropertyState* pFontFamilyName = nullptr;
365  XMLPropertyState* pFontStyleName = nullptr;
366  XMLPropertyState* pFontFamily = nullptr;
367  XMLPropertyState* pFontPitch = nullptr;
368  XMLPropertyState* pFontCharSet = nullptr;
369  std::unique_ptr<XMLPropertyState> pNewFontStyleName;
370  std::unique_ptr<XMLPropertyState> pNewFontFamily;
371  std::unique_ptr<XMLPropertyState> pNewFontPitch;
372  std::unique_ptr<XMLPropertyState> pNewFontCharSet;
373  XMLPropertyState* pFontFamilyNameCJK = nullptr;
374  XMLPropertyState* pFontStyleNameCJK = nullptr;
375  XMLPropertyState* pFontFamilyCJK = nullptr;
376  XMLPropertyState* pFontPitchCJK = nullptr;
377  XMLPropertyState* pFontCharSetCJK = nullptr;
378  std::unique_ptr<XMLPropertyState> pNewFontStyleNameCJK;
379  std::unique_ptr<XMLPropertyState> pNewFontFamilyCJK;
380  std::unique_ptr<XMLPropertyState> pNewFontPitchCJK;
381  std::unique_ptr<XMLPropertyState> pNewFontCharSetCJK;
382  XMLPropertyState* pFontFamilyNameCTL = nullptr;
383  XMLPropertyState* pFontStyleNameCTL = nullptr;
384  XMLPropertyState* pFontFamilyCTL = nullptr;
385  XMLPropertyState* pFontPitchCTL = nullptr;
386  XMLPropertyState* pFontCharSetCTL = nullptr;
387  std::unique_ptr<XMLPropertyState> pNewFontStyleNameCTL;
388  std::unique_ptr<XMLPropertyState> pNewFontFamilyCTL;
389  std::unique_ptr<XMLPropertyState> pNewFontPitchCTL;
390  std::unique_ptr<XMLPropertyState> pNewFontCharSetCTL;
391  XMLPropertyState* pAllBorderDistance = nullptr;
392  XMLPropertyState* pBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
393  XMLPropertyState* pNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
394  XMLPropertyState* pAllBorder = nullptr;
395  XMLPropertyState* pBorders[4] = { nullptr, nullptr, nullptr, nullptr };
396  XMLPropertyState* pNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
397  XMLPropertyState* pAllBorderWidth = nullptr;
398  XMLPropertyState* pBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
399  XMLPropertyState* pCharAllBorderDistance = nullptr;
400  XMLPropertyState* pCharBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
401  XMLPropertyState* pCharNewBorderDistances[4] = { nullptr, nullptr, nullptr, nullptr };
402  XMLPropertyState* pCharAllBorder = nullptr;
403  XMLPropertyState* pCharBorders[4] = { nullptr, nullptr, nullptr, nullptr };
404  XMLPropertyState* pCharNewBorders[4] = { nullptr, nullptr, nullptr, nullptr };
405  XMLPropertyState* pCharAllBorderWidth = nullptr;
406  XMLPropertyState* pCharBorderWidths[4] = { nullptr, nullptr, nullptr, nullptr };
407  XMLPropertyState* pVertOrient = nullptr;
408  XMLPropertyState* pVertOrientRelAsChar = nullptr;
409  XMLPropertyState* pBackTransparency = nullptr; // transparency in %
410  XMLPropertyState* pBackTransparent = nullptr; // transparency as boolean
411  XMLPropertyState* pAllParaMargin = nullptr;
412  XMLPropertyState* pParaMargins[4] = { nullptr, nullptr, nullptr, nullptr };
413  ::std::unique_ptr<XMLPropertyState> pNewParaMargins[4];
414  XMLPropertyState* pAllMargin = nullptr;
415  XMLPropertyState* pMargins[4] = { nullptr, nullptr, nullptr, nullptr };
416  ::std::unique_ptr<XMLPropertyState> pNewMargins[4];
417  XMLPropertyState* pFillStyle(nullptr);
418  XMLPropertyState* pFillColor(nullptr);
419 
420  for( auto& rProperty : rProperties )
421  {
422  XMLPropertyState* property = &rProperty;
423  if( -1 == property->mnIndex )
424  continue;
425 
426  switch( getPropertySetMapper()->GetEntryContextId( property->mnIndex ) )
427  {
428  case CTF_FONTFAMILYNAME: pFontFamilyName = property; break;
429  case CTF_FONTSTYLENAME: pFontStyleName = property; break;
430  case CTF_FONTFAMILY: pFontFamily = property; break;
431  case CTF_FONTPITCH: pFontPitch = property; break;
432  case CTF_FONTCHARSET: pFontCharSet = property; break;
433 
434  case CTF_FONTFAMILYNAME_CJK: pFontFamilyNameCJK = property; break;
435  case CTF_FONTSTYLENAME_CJK: pFontStyleNameCJK = property; break;
436  case CTF_FONTFAMILY_CJK: pFontFamilyCJK = property; break;
437  case CTF_FONTPITCH_CJK: pFontPitchCJK = property; break;
438  case CTF_FONTCHARSET_CJK: pFontCharSetCJK = property; break;
439 
440  case CTF_FONTFAMILYNAME_CTL: pFontFamilyNameCTL = property; break;
441  case CTF_FONTSTYLENAME_CTL: pFontStyleNameCTL = property; break;
442  case CTF_FONTFAMILY_CTL: pFontFamilyCTL = property; break;
443  case CTF_FONTPITCH_CTL: pFontPitchCTL = property; break;
444  case CTF_FONTCHARSET_CTL: pFontCharSetCTL = property; break;
445 
446  case CTF_ALLBORDERDISTANCE: pAllBorderDistance = property; break;
447  case CTF_LEFTBORDERDISTANCE: pBorderDistances[XML_LINE_LEFT] = property; break;
448  case CTF_RIGHTBORDERDISTANCE: pBorderDistances[XML_LINE_RIGHT] = property; break;
449  case CTF_TOPBORDERDISTANCE: pBorderDistances[XML_LINE_TOP] = property; break;
450  case CTF_BOTTOMBORDERDISTANCE: pBorderDistances[XML_LINE_BOTTOM] = property; break;
451  case CTF_ALLBORDER: pAllBorder = property; break;
452  case CTF_LEFTBORDER: pBorders[XML_LINE_LEFT] = property; break;
453  case CTF_RIGHTBORDER: pBorders[XML_LINE_RIGHT] = property; break;
454  case CTF_TOPBORDER: pBorders[XML_LINE_TOP] = property; break;
455  case CTF_BOTTOMBORDER: pBorders[XML_LINE_BOTTOM] = property; break;
456  case CTF_ALLBORDERWIDTH: pAllBorderWidth = property; break;
457  case CTF_LEFTBORDERWIDTH: pBorderWidths[XML_LINE_LEFT] = property; break;
458  case CTF_RIGHTBORDERWIDTH: pBorderWidths[XML_LINE_RIGHT] = property; break;
459  case CTF_TOPBORDERWIDTH: pBorderWidths[XML_LINE_TOP] = property; break;
460  case CTF_BOTTOMBORDERWIDTH: pBorderWidths[XML_LINE_BOTTOM] = property; break;
461 
462  case CTF_CHARALLBORDERDISTANCE: pCharAllBorderDistance = property; break;
463  case CTF_CHARLEFTBORDERDISTANCE: pCharBorderDistances[XML_LINE_LEFT] = property; break;
464  case CTF_CHARRIGHTBORDERDISTANCE: pCharBorderDistances[XML_LINE_RIGHT] = property; break;
465  case CTF_CHARTOPBORDERDISTANCE: pCharBorderDistances[XML_LINE_TOP] = property; break;
466  case CTF_CHARBOTTOMBORDERDISTANCE: pCharBorderDistances[XML_LINE_BOTTOM] = property; break;
467  case CTF_CHARALLBORDER: pCharAllBorder = property; break;
468  case CTF_CHARLEFTBORDER: pCharBorders[XML_LINE_LEFT] = property; break;
469  case CTF_CHARRIGHTBORDER: pCharBorders[XML_LINE_RIGHT] = property; break;
470  case CTF_CHARTOPBORDER: pCharBorders[XML_LINE_TOP] = property; break;
471  case CTF_CHARBOTTOMBORDER: pCharBorders[XML_LINE_BOTTOM] = property; break;
472  case CTF_CHARALLBORDERWIDTH: pCharAllBorderWidth = property; break;
473  case CTF_CHARLEFTBORDERWIDTH: pCharBorderWidths[XML_LINE_LEFT] = property; break;
474  case CTF_CHARRIGHTBORDERWIDTH: pCharBorderWidths[XML_LINE_RIGHT] = property; break;
475  case CTF_CHARTOPBORDERWIDTH: pCharBorderWidths[XML_LINE_TOP] = property; break;
476  case CTF_CHARBOTTOMBORDERWIDTH: pCharBorderWidths[XML_LINE_BOTTOM] = property; break;
477 
478  case CTF_ANCHORTYPE: break;
479  case CTF_VERTICALPOS: pVertOrient = property; break;
480  case CTF_VERTICALREL_ASCHAR: pVertOrientRelAsChar = property; break;
481 
484 // case CTF_SYNCHEIGHT_MIN:
485  bHasAnyMinHeight = true;
486  [[fallthrough]];
487  case CTF_FRAMEHEIGHT_ABS:
488  case CTF_FRAMEHEIGHT_REL:
489 // case CTF_SYNCHEIGHT:
490  bHasAnyHeight = true; break;
493  bHasAnyMinWidth = true;
494  [[fallthrough]];
495  case CTF_FRAMEWIDTH_ABS:
496  case CTF_FRAMEWIDTH_REL:
497  bHasAnyWidth = true; break;
498  case CTF_BACKGROUND_TRANSPARENCY: pBackTransparency = property; break;
499  case CTF_BACKGROUND_TRANSPARENT: pBackTransparent = property; break;
500  case CTF_FILLSTYLE: pFillStyle = property; break;
501  case CTF_FILLCOLOR: pFillColor = property; break;
502  case CTF_PARAMARGINALL:
504  pAllParaMargin = property; break;
505  case CTF_PARALEFTMARGIN:
507  pParaMargins[XML_LINE_LEFT] = property; break;
508  case CTF_PARARIGHTMARGIN:
510  pParaMargins[XML_LINE_RIGHT] = property; break;
511  case CTF_PARATOPMARGIN:
513  pParaMargins[XML_LINE_TOP] = property; break;
516  pParaMargins[XML_LINE_BOTTOM] = property; break;
517  case CTF_MARGINALL:
518  pAllMargin = property; break;
519  case CTF_MARGINLEFT:
520  pMargins[XML_LINE_LEFT] = property; break;
521  case CTF_MARGINRIGHT:
522  pMargins[XML_LINE_RIGHT] = property; break;
523  case CTF_MARGINTOP:
524  pMargins[XML_LINE_TOP] = property; break;
525  case CTF_MARGINBOTTOM:
526  pMargins[XML_LINE_BOTTOM] = property; break;
527  }
528  }
529 
530  if( pFontFamilyName || pFontStyleName || pFontFamily ||
531  pFontPitch || pFontCharSet )
532  FontFinished( pFontFamilyName, pFontStyleName, pFontFamily,
533  pFontPitch, pFontCharSet );
534  if( pFontFamilyNameCJK || pFontStyleNameCJK || pFontFamilyCJK ||
535  pFontPitchCJK || pFontCharSetCJK )
536  FontFinished( pFontFamilyNameCJK, pFontStyleNameCJK, pFontFamilyCJK,
537  pFontPitchCJK, pFontCharSetCJK );
538  if( pFontFamilyNameCTL || pFontStyleNameCTL || pFontFamilyCTL ||
539  pFontPitchCTL || pFontCharSetCTL )
540  FontFinished( pFontFamilyNameCTL, pFontStyleNameCTL, pFontFamilyCTL,
541  pFontPitchCTL, pFontCharSetCTL );
542 
543  for (sal_uInt16 i = 0; i < 4; i++)
544  {
545  if (pAllParaMargin && !pParaMargins[i]
546  && isNotDefaultRelSize(pAllParaMargin, getPropertySetMapper()))
547  {
548 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
549  sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
550  pAllParaMargin->mnIndex + (2*i) + 2 );
551  assert(nTmp >= CTF_PARALEFTMARGIN &&
552  nTmp <= CTF_PARABOTTOMMARGIN_REL);
553 #endif
554  pNewParaMargins[i].reset(new XMLPropertyState(
555  pAllParaMargin->mnIndex + (2*i) + 2, pAllParaMargin->maValue));
556  }
557  if (pAllMargin && !pMargins[i])
558  {
559 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
560  sal_Int16 nTmp = getPropertySetMapper()->GetEntryContextId(
561  pAllMargin->mnIndex + i + 1 );
562  assert(nTmp >= CTF_MARGINLEFT && nTmp <= CTF_MARGINBOTTOM);
563 #endif
564  pNewMargins[i].reset(new XMLPropertyState(
565  pAllMargin->mnIndex + i + 1, pAllMargin->maValue));
566  }
567 
568  lcl_SeparateBorder(
569  i, pAllBorderDistance, pBorderDistances, pNewBorderDistances,
570  pAllBorder, pBorders, pNewBorders,
571  pAllBorderWidth, pBorderWidths
572 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
574 #endif
575  );
576 
577  lcl_SeparateBorder(
578  i, pCharAllBorderDistance, pCharBorderDistances,
579  pCharNewBorderDistances, pCharAllBorder, pCharBorders,
580  pCharNewBorders, pCharAllBorderWidth, pCharBorderWidths
581 #if OSL_DEBUG_LEVEL > 0 && !defined NDEBUG
583 #endif
584  );
585  }
586 
587  if (pAllParaMargin)
588  {
589  pAllParaMargin->mnIndex = -1;
590  }
591  if (pAllMargin)
592  {
593  pAllMargin->mnIndex = -1;
594  }
595 
596  if( pAllBorderDistance )
597  pAllBorderDistance->mnIndex = -1;
598 
599  if( pAllBorder )
600  pAllBorder->mnIndex = -1;
601 
602  if( pAllBorderWidth )
603  pAllBorderWidth->mnIndex = -1;
604 
605  if( pCharAllBorderDistance )
606  pCharAllBorderDistance->mnIndex = -1;
607 
608  if( pCharAllBorder )
609  pCharAllBorder->mnIndex = -1;
610 
611  if( pCharAllBorderWidth )
612  pCharAllBorderWidth->mnIndex = -1;
613 
614  if( pVertOrient && pVertOrientRelAsChar )
615  {
616  sal_Int16 nVertOrient;
617  pVertOrient->maValue >>= nVertOrient;
618  sal_Int16 nVertOrientRel = 0;
619  pVertOrientRelAsChar->maValue >>= nVertOrientRel;
620  switch( nVertOrient )
621  {
622  case VertOrientation::TOP:
623  nVertOrient = nVertOrientRel;
624  break;
625  case VertOrientation::CENTER:
626  switch( nVertOrientRel )
627  {
628  case VertOrientation::CHAR_TOP:
629  nVertOrient = VertOrientation::CHAR_CENTER;
630  break;
631  case VertOrientation::LINE_TOP:
632  nVertOrient = VertOrientation::LINE_CENTER;
633  break;
634  }
635  break;
636  case VertOrientation::BOTTOM:
637  switch( nVertOrientRel )
638  {
639  case VertOrientation::CHAR_TOP:
640  nVertOrient = VertOrientation::CHAR_BOTTOM;
641  break;
642  case VertOrientation::LINE_TOP:
643  nVertOrient = VertOrientation::LINE_BOTTOM;
644  break;
645  }
646  break;
647  }
648  pVertOrient->maValue <<= nVertOrient;
649  pVertOrientRelAsChar->mnIndex = -1;
650  }
651 
652  FontDefaultsCheck( pFontFamilyName,
653  pFontStyleName, pFontFamily, pFontPitch, pFontCharSet,
654  &pNewFontStyleName, &pNewFontFamily, &pNewFontPitch, &pNewFontCharSet );
655 
656  FontDefaultsCheck( pFontFamilyNameCJK,
657  pFontStyleNameCJK, pFontFamilyCJK, pFontPitchCJK, pFontCharSetCJK,
658  &pNewFontStyleNameCJK, &pNewFontFamilyCJK, &pNewFontPitchCJK, &pNewFontCharSetCJK );
659 
660  FontDefaultsCheck( pFontFamilyNameCTL,
661  pFontStyleNameCTL, pFontFamilyCTL, pFontPitchCTL, pFontCharSetCTL,
662  &pNewFontStyleNameCTL, &pNewFontFamilyCTL, &pNewFontPitchCTL, &pNewFontCharSetCTL );
663 
664  if (pFillStyle && !pFillColor && pBackTransparent
665  && drawing::FillStyle_SOLID == pFillStyle->maValue.get<drawing::FillStyle>()
666  && pBackTransparent->maValue.get<bool>())
667  {
668  // fo:background="transparent", draw:fill="solid" without draw:fill-color
669  // prevent getSvxBrushItemFromSourceSet from adding bogus default color
670  pFillStyle->mnIndex = -1;
671  }
672 
673  // #i5775# don't overwrite %transparency with binary transparency
674  if( ( pBackTransparency != nullptr ) && ( pBackTransparent != nullptr ) )
675  {
676  if( ! *o3tl::doAccess<bool>(pBackTransparent->maValue) )
677  pBackTransparent->mnIndex = -1;
678  }
679 
680 
681  // insert newly created properties. This invalidates all iterators!
682  // Most of the pXXX variables in this method are iterators and will be
683  // invalidated!!!
684 
685  if( pNewFontStyleName )
686  {
687  rProperties.push_back( *pNewFontStyleName );
688  pNewFontStyleName.reset();
689  }
690 
691  if( pNewFontFamily )
692  {
693  rProperties.push_back( *pNewFontFamily );
694  pNewFontFamily.reset();
695  }
696 
697  if( pNewFontPitch )
698  {
699  rProperties.push_back( *pNewFontPitch );
700  pNewFontPitch.reset();
701  }
702 
703  if( pNewFontCharSet )
704  {
705  rProperties.push_back( *pNewFontCharSet );
706  pNewFontCharSet.reset();
707  }
708 
709  if( pNewFontStyleNameCJK )
710  {
711  rProperties.push_back( *pNewFontStyleNameCJK );
712  pNewFontStyleNameCJK.reset();
713  }
714 
715  if( pNewFontFamilyCJK )
716  {
717  rProperties.push_back( *pNewFontFamilyCJK );
718  pNewFontFamilyCJK.reset();
719  }
720 
721  if( pNewFontPitchCJK )
722  {
723  rProperties.push_back( *pNewFontPitchCJK );
724  pNewFontPitchCJK.reset();
725  }
726 
727  if( pNewFontCharSetCJK )
728  {
729  rProperties.push_back( *pNewFontCharSetCJK );
730  pNewFontCharSetCJK.reset();
731  }
732 
733  if( pNewFontStyleNameCTL)
734  {
735  rProperties.push_back( *pNewFontStyleNameCTL );
736  pNewFontStyleNameCTL.reset();
737  }
738 
739  if( pNewFontFamilyCTL )
740  {
741  rProperties.push_back( *pNewFontFamilyCTL );
742  pNewFontFamilyCTL.reset();
743  }
744 
745  if( pNewFontPitchCTL )
746  {
747  rProperties.push_back( *pNewFontPitchCTL );
748  pNewFontPitchCTL.reset();
749  }
750 
751  if( pNewFontCharSetCTL )
752  {
753  rProperties.push_back( *pNewFontCharSetCTL );
754  pNewFontCharSetCTL.reset();
755  }
756 
757  for (sal_uInt16 i=0; i<4; i++)
758  {
759  if (pNewParaMargins[i])
760  {
761  rProperties.push_back(*pNewParaMargins[i]);
762  }
763  if (pNewMargins[i])
764  {
765  rProperties.push_back(*pNewMargins[i]);
766  }
767  if( pNewBorderDistances[i] )
768  {
769  rProperties.push_back( *pNewBorderDistances[i] );
770  delete pNewBorderDistances[i];
771  }
772  if( pNewBorders[i] )
773  {
774  rProperties.push_back( *pNewBorders[i] );
775  delete pNewBorders[i];
776  }
777  if( pCharNewBorderDistances[i] )
778  {
779  rProperties.push_back( *pCharNewBorderDistances[i] );
780  delete pCharNewBorderDistances[i];
781  }
782  if( pCharNewBorders[i] )
783  {
784  rProperties.push_back( *pCharNewBorders[i] );
785  delete pCharNewBorders[i];
786  }
787  }
788 
789  if( bHasAnyHeight )
790  {
791  if( nSizeTypeIndex == -2 )
792  {
793  const_cast < XMLTextImportPropertyMapper * > ( this )
794  ->nSizeTypeIndex = -1;
795  sal_Int32 nPropCount = getPropertySetMapper()->GetEntryCount();
796  for( sal_Int32 j=0; j < nPropCount; j++ )
797  {
799  ->GetEntryContextId( j ) )
800  {
801  const_cast < XMLTextImportPropertyMapper * > ( this )
802  ->nSizeTypeIndex = j;
803  break;
804  }
805  }
806  }
807  if( nSizeTypeIndex != -1 )
808  {
809  XMLPropertyState aSizeTypeState( nSizeTypeIndex );
810  aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinHeight
811  ? SizeType::MIN
812  : SizeType::FIX);
813  rProperties.push_back( aSizeTypeState );
814  }
815  }
816 
817  if( !bHasAnyWidth )
818  return;
819 
820  if( nWidthTypeIndex == -2 )
821  {
822  const_cast < XMLTextImportPropertyMapper * > ( this )
823  ->nWidthTypeIndex = -1;
824  sal_Int32 nCount = getPropertySetMapper()->GetEntryCount();
825  for( sal_Int32 j=0; j < nCount; j++ )
826  {
828  ->GetEntryContextId( j ) )
829  {
830  const_cast < XMLTextImportPropertyMapper * > ( this )
831  ->nWidthTypeIndex = j;
832  break;
833  }
834  }
835  }
836  if( nWidthTypeIndex != -1 )
837  {
838  XMLPropertyState aSizeTypeState( nWidthTypeIndex );
839  aSizeTypeState.maValue <<= static_cast<sal_Int16>( bHasAnyMinWidth
840  ? SizeType::MIN
841  : SizeType::FIX);
842  rProperties.push_back( aSizeTypeState );
843  }
844 
845  // DO NOT USE ITERATORS/POINTERS INTO THE rProperties-VECTOR AFTER
846  // THIS LINE. All iterators into the rProperties-vector, especially all
847  // pXXX-type variables set in the first switch statement of this method,
848  // may have been invalidated by the above push_back() calls!
849 }
850 
851 
852 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:355
#define CTF_FONTPITCH_CJK
Definition: txtprmap.hxx:98
#define CTF_FONTFAMILY_CTL
Definition: txtprmap.hxx:106
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
sal_Int32 nIndex
#define CTF_FRAMEWIDTH_MIN_REL
Definition: txtprmap.hxx:148
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
#define CTF_BOTTOMBORDER
Definition: txtprmap.hxx:51
#define CTF_PARALEFTMARGIN_REL
Definition: txtprmap.hxx:28
#define CTF_CHARTOPBORDERDISTANCE
Definition: txtprmap.hxx:190
#define CTF_LEFTBORDER
Definition: txtprmap.hxx:48
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
#define CTF_CHARRIGHTBORDERDISTANCE
Definition: txtprmap.hxx:189
#define CTF_MARGINTOP
Definition: txtprmap.hxx:178
#define CTF_FRAMEHEIGHT_ABS
Definition: txtprmap.hxx:65
#define CTF_FRAMEHEIGHT_MIN_REL
Definition: txtprmap.hxx:68
#define CTF_SIZETYPE
Definition: txtprmap.hxx:69
#define CTF_PARAMARGINALL
Definition: txtprmap.hxx:173
#define CTF_FONTSTYLENAME_CJK
Definition: txtprmap.hxx:96
#define CTF_ALLBORDER
Definition: txtprmap.hxx:47
sal_Int32 mnIndex
Definition: maptype.hxx:124
#define CTF_FRAMEWIDTH_ABS
Definition: txtprmap.hxx:146
#define CTF_FONTFAMILYNAME_CJK
Definition: txtprmap.hxx:95
#define CTF_FONTPITCH_CTL
Definition: txtprmap.hxx:107
static void FontFinished(XMLPropertyState *pFontFamilyNameState, XMLPropertyState *pFontStyleNameState, XMLPropertyState *pFontFamilyState, XMLPropertyState *pFontPitchState, XMLPropertyState *pFontCharsetState)
Definition: txtimppr.cxx:151
#define CTF_PARABOTTOMMARGIN_REL
Definition: txtprmap.hxx:36
#define CTF_FONTCHARSET
Definition: txtprmap.hxx:62
#define CTF_FONTFAMILYNAME
Definition: txtprmap.hxx:58
const rtl::Reference< XMLPropertySetMapper > & getPropertySetMapper() const
Definition: xmlimppr.hxx:195
#define CTF_RIGHTBORDERDISTANCE
Definition: txtprmap.hxx:44
XMLTextImportPropertyMapper(const rtl::Reference< XMLPropertySetMapper > &rMapper, SvXMLImport &rImport)
Definition: txtimppr.cxx:138
virtual ~XMLTextImportPropertyMapper() override
Definition: txtimppr.cxx:147
#define CTF_TOPBORDERWIDTH
Definition: txtprmap.hxx:40
#define CTF_FONTCHARSET_CJK
Definition: txtprmap.hxx:99
#define CTF_RIGHTBORDER
Definition: txtprmap.hxx:49
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
static const sal_uInt16 OOo_2x
Definition: xmlimp.hxx:542
#define CTF_BACKGROUND_TRANSPARENCY
Definition: txtprmap.hxx:143
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
#define CTF_CHARLEFTBORDER
Definition: txtprmap.hxx:193
int nCount
#define CTF_PARATOPMARGIN
Definition: txtprmap.hxx:33
#define CTF_MARGINLEFT
Definition: txtprmap.hxx:176
#define CTF_VERTICALREL_ASCHAR
Definition: txtprmap.hxx:87
SvXMLImport & GetImport() const
Definition: xmlimppr.hxx:74
#define XML_LINE_BOTTOM
Definition: txtimppr.cxx:40
const char * sName
#define CTF_FRAMEWIDTH_MIN_ABS
Definition: txtprmap.hxx:147
#define CTF_CHARLEFTBORDERDISTANCE
Definition: txtprmap.hxx:188
#define CTF_LEFTBORDERDISTANCE
Definition: txtprmap.hxx:43
#define CTF_FONTCHARSET_CTL
Definition: txtprmap.hxx:108
#define CTF_FONTNAME_CJK
Definition: txtprmap.hxx:94
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:350
#define CTF_LEFTBORDERWIDTH
Definition: txtprmap.hxx:38
#define CTF_CHARALLBORDERWIDTH
Definition: txtprmap.hxx:182
int i
#define CTF_PARATOPMARGIN_REL
Definition: txtprmap.hxx:34
#define CTF_FONTFAMILY
Definition: txtprmap.hxx:60
#define CTF_CHARRIGHTBORDERWIDTH
Definition: txtprmap.hxx:184
#define CTF_BACKGROUND_TRANSPARENT
Definition: txtprmap.hxx:144
#define CTF_FONTPITCH
Definition: txtprmap.hxx:61
#define CTF_FONTSTYLENAME_CTL
Definition: txtprmap.hxx:105
#define CTF_TOPBORDERDISTANCE
Definition: txtprmap.hxx:45
#define CTF_CHARTOPBORDERWIDTH
Definition: txtprmap.hxx:185
#define CTF_BOTTOMBORDERDISTANCE
Definition: txtprmap.hxx:46
#define CTF_FRAMEWIDTH_REL
Definition: txtprmap.hxx:149
#define CTF_FRAMEHEIGHT_MIN_ABS
Definition: txtprmap.hxx:67
#define CTF_CHARALLBORDERDISTANCE
Definition: txtprmap.hxx:187
#define CTF_PARALEFTMARGIN
Definition: txtprmap.hxx:27
#define CTF_ANCHORTYPE
Definition: txtprmap.hxx:75
css::uno::Any maValue
Definition: maptype.hxx:125
#define CTF_CHARTOPBORDER
Definition: txtprmap.hxx:195
#define CTF_CHARALLBORDER
Definition: txtprmap.hxx:192
#define XML_LINE_TOP
Definition: txtimppr.cxx:39
#define CTF_CHARBOTTOMBORDER
Definition: txtprmap.hxx:196
#define CTF_FONTSTYLENAME
Definition: txtprmap.hxx:59
#define CTF_PARARIGHTMARGIN_REL
Definition: txtprmap.hxx:30
#define CTF_FRAMEWIDTH_TYPE
Definition: txtprmap.hxx:150
#define CTF_FONTFAMILYNAME_CTL
Definition: txtprmap.hxx:104
Smart struct to transport an Any with an index to the appropriate property-name.
Definition: maptype.hxx:122
#define CTF_MARGINALL
Definition: txtprmap.hxx:175
#define CTF_CHARBOTTOMBORDERWIDTH
Definition: txtprmap.hxx:186
#define CTF_MARGINRIGHT
Definition: txtprmap.hxx:177
#define CTF_ALLBORDERDISTANCE
Definition: txtprmap.hxx:42
#define CTF_FONTNAME_CTL
Definition: txtprmap.hxx:103
#define CTF_TEXT_DISPLAY
Definition: txtprmap.hxx:170
#define CTF_FRAMEHEIGHT_REL
Definition: txtprmap.hxx:66
#define CTF_PARARIGHTMARGIN
Definition: txtprmap.hxx:29
#define CTF_CHARLEFTBORDERWIDTH
Definition: txtprmap.hxx:183
#define CTF_VERTICALPOS
Definition: txtprmap.hxx:83
#define XML_LINE_RIGHT
Definition: txtimppr.cxx:38
#define CTF_FILLCOLOR
Definition: txtprmap.hxx:203
#define CTF_CHARRIGHTBORDER
Definition: txtprmap.hxx:194
#define CTF_ALLBORDERWIDTH
Definition: txtprmap.hxx:37
#define XML_LINE_LEFT
Definition: txtimppr.cxx:37
#define CTF_BOTTOMBORDERWIDTH
Definition: txtprmap.hxx:41
#define CTF_CHARBOTTOMBORDERDISTANCE
Definition: txtprmap.hxx:191
XMLFontStylesContext * GetFontDecls()
Definition: xmlimp.cxx:1660
#define CTF_FONTNAME
Definition: txtprmap.hxx:93
#define CTF_FILLSTYLE
Definition: txtprmap.hxx:202
#define CTF_PARABOTTOMMARGIN
Definition: txtprmap.hxx:35
#define CTF_RIGHTBORDERWIDTH
Definition: txtprmap.hxx:39
#define CTF_FONTFAMILY_CJK
Definition: txtprmap.hxx:97
#define CTF_PARAMARGINALL_REL
Definition: txtprmap.hxx:174
#define CTF_MARGINBOTTOM
Definition: txtprmap.hxx:179
#define CTF_TOPBORDER
Definition: txtprmap.hxx:50
void FontDefaultsCheck(XMLPropertyState const *pFontFamilyName, XMLPropertyState const *pFontStyleName, XMLPropertyState const *pFontFamily, XMLPropertyState const *pFontPitch, XMLPropertyState const *pFontCharSet, std::unique_ptr< XMLPropertyState > *ppNewFontStyleName, std::unique_ptr< XMLPropertyState > *ppNewFontFamily, std::unique_ptr< XMLPropertyState > *ppNewFontPitch, std::unique_ptr< XMLPropertyState > *ppNewFontCharSet) const
since the properties "CharFontFamilyName", "CharFontStyleName", "CharFontFamily", "CharFontPitch" and...
Definition: txtimppr.cxx:184
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo