LibreOffice Module sw (master)  1
xmlexpit.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 "xmlexpit.hxx"
21 
22 #include <osl/diagnose.h>
23 #include <rtl/ustrbuf.hxx>
24 #include <sax/tools/converter.hxx>
25 #include <svl/itempool.hxx>
26 #include <svl/poolitem.hxx>
27 #include <svl/itemset.hxx>
28 #include <utility>
29 #include <xmloff/xmluconv.hxx>
30 #include <xmloff/attrlist.hxx>
31 #include <xmloff/nmspmap.hxx>
32 #include <xmloff/xmlnmspe.hxx>
33 #include <xmloff/prhdlfac.hxx>
34 #include <xmloff/xmltypes.hxx>
35 #include <editeng/xmlcnitm.hxx>
36 #include <xmloff/xmlexp.hxx>
37 #include <xmloff/xmlprhdl.hxx>
38 #include <editeng/memberids.h>
39 #include <hintids.hxx>
40 #include <unomid.h>
41 #include <svx/unomid.hxx>
42 #include <editeng/lrspitem.hxx>
43 #include <editeng/ulspitem.hxx>
44 #include <editeng/shaditem.hxx>
45 #include <editeng/boxitem.hxx>
47 #include <editeng/keepitem.hxx>
48 #include <editeng/brushitem.hxx>
49 #include <editeng/frmdiritem.hxx>
50 #include <fmtpdsc.hxx>
51 #include <fmtornt.hxx>
52 #include <fmtfsize.hxx>
53 
54 #include <fmtlsplt.hxx>
55 #include "xmlithlp.hxx"
56 
57 #include <fmtrowsplt.hxx>
58 
59 using ::editeng::SvxBorderLine;
60 using namespace ::com::sun::star;
61 using namespace ::xmloff::token;
62 using uno::Any;
63 
64 // fills the given attribute list with the items in the given set
66  SvXMLAttributeList& rAttrList,
67  const SfxItemSet& rSet,
68  const SvXMLUnitConverter& rUnitConverter,
69  const SvXMLNamespaceMap& rNamespaceMap,
70  std::vector<sal_uInt16> *pIndexArray ) const
71 {
72  const sal_uInt16 nCount = mrMapEntries->getCount();
73  sal_uInt16 nIndex = 0;
74 
75  while( nIndex < nCount )
76  {
77  SvXMLItemMapEntry const & rEntry = mrMapEntries->getByIndex( nIndex );
78 
79  // we have a valid map entry here, so lets use it...
80  if( 0 == (rEntry.nMemberId & MID_SW_FLAG_NO_ITEM_EXPORT) )
81  {
82  const SfxPoolItem* pItem = GetItem( rSet, rEntry.nWhichId );
83  // do we have an item?
84  if(pItem)
85  {
86  if( 0 != (rEntry.nMemberId & MID_SW_FLAG_ELEMENT_ITEM_EXPORT) )
87  {
88  // element items do not add any properties,
89  // we export it later
90  if( pIndexArray )
91  pIndexArray->push_back( nIndex );
92 
93  }
94  else
95  {
96  exportXML( rExport, rAttrList, *pItem, rEntry, rUnitConverter,
97  rNamespaceMap, &rSet );
98  }
99  }
100  }
101  else
102  {
103  OSL_FAIL( "no item not handled in xml export" );
104  }
105  nIndex++;
106  }
107 }
108 
110  SvXMLAttributeList& rAttrList,
111  const SfxPoolItem& rItem,
112  const SvXMLItemMapEntry& rEntry,
113  const SvXMLUnitConverter& rUnitConverter,
114  const SvXMLNamespaceMap& rNamespaceMap,
115  const SfxItemSet *pSet ) const
116 {
117  if( 0 != (rEntry.nMemberId & MID_SW_FLAG_SPECIAL_ITEM_EXPORT) )
118  {
119  if( dynamic_cast<const SwFormatRowSplit*>( &rItem) != nullptr )
120  {
121  OUString aValue;
122  bool bAddAttribute = true;
123  if( rEntry.nNameSpace == XML_NAMESPACE_STYLE )
124  {
125  if( !(rExport.getExportFlags() & SvXMLExportFlags::SAVEBACKWARDCOMPATIBLE ) ||
126  !QueryXMLValue(rItem, aValue,
127  static_cast< sal_uInt16 >( rEntry.nMemberId & MID_SW_FLAG_MASK ),
128  rUnitConverter ) )
129  {
130  bAddAttribute = false;
131  }
132  }
133  else
134  {
135  OUStringBuffer aOut;
136  const SfxBoolItem* pSplit = dynamic_cast<const SfxBoolItem*>( &rItem );
137  assert(pSplit && "Wrong Which-ID");
138  const sal_uInt16 eEnum = (pSplit && pSplit->GetValue()) ? 1 : 0;
140  aValue = aOut.makeStringAndClear();
141  }
142  if( bAddAttribute )
143  {
144  const OUString sName( rNamespaceMap.GetQNameByKey( rEntry.nNameSpace,
145  GetXMLToken(rEntry.eLocalName) ) );
146  rAttrList.AddAttribute( sName, aValue );
147  }
148  }
149  if( dynamic_cast<const SvXMLAttrContainerItem*>( &rItem) != nullptr )
150  {
151  std::unique_ptr<SvXMLNamespaceMap> pNewNamespaceMap;
152  const SvXMLNamespaceMap *pNamespaceMap = &rNamespaceMap;
153 
154  const SvXMLAttrContainerItem *pUnknown =
155  dynamic_cast<const SvXMLAttrContainerItem*>( &rItem );
156 
157  const sal_uInt16 nCount = pUnknown ? pUnknown->GetAttrCount() : 0;
158  for( sal_uInt16 i=0; i < nCount; i++ )
159  {
160  const OUString sPrefix( pUnknown->GetAttrPrefix( i ) );
161  if( !sPrefix.isEmpty() )
162  {
163  const OUString sNamespace( pUnknown->GetAttrNamespace( i ) );
164 
165  // if the prefix isn't defined yet or has another meaning,
166  // we have to redefine it now.
167  const sal_uInt16 nIdx = pNamespaceMap->GetIndexByPrefix( sPrefix );
168  if( USHRT_MAX == nIdx ||
169  pNamespaceMap->GetNameByIndex( nIdx ) != sNamespace )
170  {
171  if( !pNewNamespaceMap )
172  {
173  pNewNamespaceMap.reset(
174  new SvXMLNamespaceMap( rNamespaceMap ));
175  pNamespaceMap = pNewNamespaceMap.get();
176  }
177  pNewNamespaceMap->Add( sPrefix, sNamespace );
178 
179  rAttrList.AddAttribute( GetXMLToken(XML_XMLNS) + ":" + sPrefix,
180  sNamespace );
181  }
182 
183  rAttrList.AddAttribute( sPrefix + ":" + pUnknown->GetAttrLName(i),
184  pUnknown->GetAttrValue(i) );
185  }
186  else
187  {
188  rAttrList.AddAttribute( pUnknown->GetAttrLName(i),
189  pUnknown->GetAttrValue(i) );
190  }
191  }
192  }
193  else
194  {
195  handleSpecialItem( rAttrList, rEntry, rItem, rUnitConverter,
196  rNamespaceMap, pSet );
197  }
198  }
199  else if( 0 == (rEntry.nMemberId & MID_SW_FLAG_ELEMENT_ITEM_EXPORT) )
200  {
201  bool bDone = false;
202  switch (rItem.Which())
203  {
204  case RES_FRAMEDIR:
205  {
206  // Write bt-lr to the extension namespace, handle other values
207  // below.
208  auto pDirection = static_cast<const SvxFrameDirectionItem*>(&rItem);
209  if (rEntry.nNameSpace == XML_NAMESPACE_LO_EXT
210  && pDirection->GetValue() == SvxFrameDirection::Vertical_LR_BT)
211  {
212  const OUString sName(rNamespaceMap.GetQNameByKey(
213  XML_NAMESPACE_LO_EXT, GetXMLToken(XML_WRITING_MODE)));
215  }
216  if (rEntry.nNameSpace == XML_NAMESPACE_LO_EXT
217  || pDirection->GetValue() == SvxFrameDirection::Vertical_LR_BT)
218  bDone = true;
219  break;
220  }
221  }
222 
223  if (!bDone)
224  {
225  OUString aValue;
226  if( QueryXMLValue(rItem, aValue,
227  static_cast< sal_uInt16 >(
228  rEntry.nMemberId & MID_SW_FLAG_MASK ),
229  rUnitConverter ) )
230  {
231  const OUString sName(
232  rNamespaceMap.GetQNameByKey( rEntry.nNameSpace,
233  GetXMLToken(rEntry.eLocalName)));
234  rAttrList.AddAttribute( sName, aValue );
235  }
236  }
237  }
238 }
239 
241  SvXMLExport& rExport,
242  const SfxItemSet &rSet,
243  const std::vector<sal_uInt16> &rIndexArray ) const
244 {
245  const size_t nCount = rIndexArray.size();
246 
247  bool bItemsExported = false;
248  for( size_t nIndex = 0; nIndex < nCount; ++nIndex )
249  {
250  const sal_uInt16 nElement = rIndexArray[ nIndex ];
251  SvXMLItemMapEntry const & rEntry = mrMapEntries->getByIndex( nElement );
252  OSL_ENSURE( 0 != (rEntry.nMemberId & MID_SW_FLAG_ELEMENT_ITEM_EXPORT),
253  "wrong mid flag!" );
254 
255  const SfxPoolItem* pItem = GetItem( rSet, rEntry.nWhichId );
256  // do we have an item?
257  if(pItem)
258  {
259  rExport.IgnorableWhitespace();
260  handleElementItem( rEntry, *pItem );
261  bItemsExported = true;
262  }
263  }
264 
265  if( bItemsExported )
266  rExport.IgnorableWhitespace();
267 }
268 
273  sal_uInt16 nWhichId)
274 {
275  // first get item from itemset
276  const SfxPoolItem* pItem;
277  SfxItemState eState = rSet.GetItemState( nWhichId, false, &pItem );
278 
279  if( SfxItemState::SET == eState )
280  {
281  return pItem;
282  }
283  else
284  {
285  return nullptr;
286  }
287 }
288 
290 {
291  mrMapEntries = std::move(rMapEntries);
292 }
293 
295 {
296 }
297 
299  const SfxItemSet& rSet,
300  const SvXMLUnitConverter& rUnitConverter,
301  XMLTokenEnum ePropToken ) const
302 {
303  std::vector<sal_uInt16> aIndexArray;
304 
305  exportXML( rExport, rExport.GetAttrList(), rSet, rUnitConverter,
306  rExport.GetNamespaceMap(), &aIndexArray );
307 
308  if( rExport.GetAttrList().getLength() > 0 || !aIndexArray.empty() )
309  {
310  rExport.IgnorableWhitespace();
311 
312  SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, ePropToken,
313  false, false );
314  exportElementItems( rExport, rSet, aIndexArray );
315  }
316 }
317 
321  const SvXMLItemMapEntry& /*rEntry*/,
322  const SfxPoolItem& /*rItem*/,
323  const SvXMLUnitConverter& /*rUnitConverter*/,
324  const SvXMLNamespaceMap& /*rNamespaceMap*/,
325  const SfxItemSet* /*pSet*/ /* = NULL */ ) const
326 {
327  OSL_FAIL( "special item not handled in xml export" );
328 }
329 
333  const SvXMLItemMapEntry& /*rEntry*/,
334  const SfxPoolItem& /*rItem*/ ) const
335 {
336  OSL_FAIL( "element item not handled in xml export" );
337 }
338 
339 static bool lcl_isOdfDoubleLine( const SvxBorderLine* pLine )
340 {
341  bool bIsOdfDouble = false;
342  switch (pLine->GetBorderLineStyle())
343  {
344  case SvxBorderLineStyle::DOUBLE:
345  case SvxBorderLineStyle::THINTHICK_SMALLGAP:
346  case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
347  case SvxBorderLineStyle::THINTHICK_LARGEGAP:
348  case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
349  case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
350  case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
351  bIsOdfDouble = true;
352  break;
353  default:
354  break;
355  }
356  return bIsOdfDouble;
357 }
358 
360  const SfxPoolItem& rItem,
361  OUString& rValue,
362  sal_uInt16 nMemberId,
363  const SvXMLUnitConverter& rUnitConverter )
364 {
365  bool bOk = false;
366  OUStringBuffer aOut;
367 
368  switch ( rItem.Which() )
369  {
370 
371  case RES_LR_SPACE:
372  {
373  const SvxLRSpaceItem& rLRSpace = dynamic_cast<const SvxLRSpaceItem&>(rItem);
374 
375  bOk = true;
376  switch( nMemberId )
377  {
378  case MID_L_MARGIN:
379  if (rLRSpace.GetPropLeft() != 100)
380  {
382  aOut, rLRSpace.GetPropLeft() );
383  }
384  else
385  {
386  rUnitConverter.convertMeasureToXML(
387  aOut, rLRSpace.GetLeft() );
388  }
389  break;
390 
391  case MID_R_MARGIN:
392  if (rLRSpace.GetPropRight() != 100)
393  {
395  aOut, rLRSpace.GetPropRight() );
396  }
397  else
398  {
399  rUnitConverter.convertMeasureToXML(
400  aOut, rLRSpace.GetRight() );
401  }
402  break;
403 
404  case MID_FIRST_AUTO:
405  if (rLRSpace.IsAutoFirst())
406  {
408  aOut, rLRSpace.IsAutoFirst() );
409  }
410  else
411  bOk = false;
412  break;
413 
415  if (!rLRSpace.IsAutoFirst())
416  {
417  if (rLRSpace.GetPropTextFirstLineOfst() != 100)
418  {
420  aOut, rLRSpace.GetPropTextFirstLineOfst() );
421  }
422  else
423  {
424  rUnitConverter.convertMeasureToXML(
425  aOut, rLRSpace.GetTextFirstLineOfst() );
426  }
427  }
428  else
429  bOk = false;
430  break;
431 
432  default:
433  OSL_FAIL( "unknown member id!");
434  bOk = false;
435  break;
436  }
437  }
438  break;
439 
440  case RES_UL_SPACE:
441  {
442  const SvxULSpaceItem& rULSpace = dynamic_cast<const SvxULSpaceItem&>(rItem);
443 
444  switch( nMemberId )
445  {
446  case MID_UP_MARGIN:
447  if (rULSpace.GetPropUpper() != 100)
448  {
450  aOut, rULSpace.GetPropUpper() );
451  }
452  else
453  {
454  rUnitConverter.convertMeasureToXML(
455  aOut, rULSpace.GetUpper() );
456  }
457  break;
458 
459  case MID_LO_MARGIN:
460  if (rULSpace.GetPropLower() != 100)
461  {
463  aOut, rULSpace.GetPropLower() );
464  }
465  else
466  {
467  rUnitConverter.convertMeasureToXML(
468  aOut, rULSpace.GetLower() );
469  }
470  break;
471 
472  default:
473  OSL_FAIL("unknown MemberId");
474  };
475 
476  bOk = true;
477  }
478  break;
479 
480  case RES_SHADOW:
481  {
482  const SvxShadowItem* pShadow = dynamic_cast<const SvxShadowItem*>( &rItem );
483  assert(pShadow && "Wrong Which-ID");
484  if (pShadow)
485  {
486  sal_Int32 nX = 1, nY = 1;
487  switch( pShadow->GetLocation() )
488  {
489  case SvxShadowLocation::TopLeft:
490  nX = -1;
491  nY = -1;
492  break;
493  case SvxShadowLocation::TopRight:
494  nY = -1;
495  break;
496  case SvxShadowLocation::BottomLeft:
497  nX = -1;
498  break;
499  case SvxShadowLocation::BottomRight:
500  break;
501  case SvxShadowLocation::NONE:
502  default:
503  rValue = GetXMLToken(XML_NONE);
504  return true;
505  }
506 
507  nX *= pShadow->GetWidth();
508  nY *= pShadow->GetWidth();
509 
510  ::sax::Converter::convertColor(aOut, pShadow->GetColor());
511  aOut.append( ' ' );
512  rUnitConverter.convertMeasureToXML( aOut, nX );
513  aOut.append( ' ' );
514  rUnitConverter.convertMeasureToXML( aOut, nY );
515 
516  bOk = true;
517  }
518  }
519  break;
520 
521  case RES_BOX:
522  {
523  const SvxBoxItem* pBox = dynamic_cast<const SvxBoxItem*>( &rItem );
524  assert(pBox && "Wrong Which-ID");
525  if (pBox)
526  {
549  const SvxBorderLine* pLeft = pBox->GetLeft();
550  const SvxBorderLine* pRight = pBox->GetRight();
551  const SvxBorderLine* pTop = pBox->GetTop();
552  const SvxBorderLine* pBottom = pBox->GetBottom();
553  const sal_uInt16 nTopDist = pBox->GetDistance( SvxBoxItemLine::TOP );
554  const sal_uInt16 nBottomDist = pBox->GetDistance( SvxBoxItemLine::BOTTOM );
555  const sal_uInt16 nLeftDist = pBox->GetDistance( SvxBoxItemLine::LEFT );
556  const sal_uInt16 nRightDist = pBox->GetDistance( SvxBoxItemLine::RIGHT );
557 
558  // check if we need to export it
559  switch( nMemberId )
560  {
561  case ALL_BORDER_PADDING:
562  case LEFT_BORDER_PADDING:
564  case TOP_BORDER_PADDING:
566  {
567  bool bEqual = nLeftDist == nRightDist &&
568  nLeftDist == nTopDist &&
569  nLeftDist == nBottomDist;
570  // don't export individual paddings if all paddings are equal and
571  // don't export all padding if some paddings are not equal
572  if( (bEqual && ALL_BORDER_PADDING != nMemberId) ||
573  (!bEqual && ALL_BORDER_PADDING == nMemberId) )
574  return false;
575  }
576  break;
577  case ALL_BORDER:
578  case LEFT_BORDER:
579  case RIGHT_BORDER:
580  case TOP_BORDER:
581  case BOTTOM_BORDER:
582  {
583  bool bEqual = ( nullptr == pTop && nullptr == pBottom &&
584  nullptr == pLeft && nullptr == pRight ) ||
585  ( pTop && pBottom && pLeft && pRight &&
586  *pTop == *pBottom && *pTop == *pLeft &&
587  *pTop == *pRight );
588 
589  // don't export individual borders if all are the same and
590  // don't export all borders if some are not equal
591  if( (bEqual && ALL_BORDER != nMemberId) ||
592  (!bEqual && ALL_BORDER == nMemberId) )
593  return false;
594  }
595  break;
601  {
602  // if no line is set, there is nothing to export
603  if( !pTop && !pBottom && !pLeft && !pRight )
604  return false;
605 
606  bool bEqual = nullptr != pTop &&
607  nullptr != pBottom &&
608  nullptr != pLeft &&
609  nullptr != pRight;
610 
611  if( bEqual )
612  {
613  const sal_uInt16 nDistance = pTop->GetDistance();
614  const sal_uInt16 nInWidth = pTop->GetInWidth();
615  const sal_uInt16 nOutWidth = pTop->GetOutWidth();
616  const long nWidth = pTop->GetWidth();
617 
618  bEqual = nDistance == pLeft->GetDistance() &&
619  nInWidth == pLeft->GetInWidth() &&
620  nOutWidth == pLeft->GetOutWidth() &&
621  nWidth == pLeft->GetWidth() &&
622  nDistance == pRight->GetDistance() &&
623  nInWidth == pRight->GetInWidth() &&
624  nOutWidth == pRight->GetOutWidth() &&
625  nWidth == pRight->GetWidth() &&
626  nDistance == pBottom->GetDistance() &&
627  nInWidth == pBottom->GetInWidth() &&
628  nOutWidth == pBottom->GetOutWidth() &&
629  nWidth == pBottom->GetWidth();
630  }
631 
632  switch( nMemberId )
633  {
635  if( !bEqual || pTop->GetDistance() == 0 ||
636  !lcl_isOdfDoubleLine( pTop ) )
637  return false;
638  break;
640  if( bEqual || nullptr == pLeft ||
641  0 == pLeft->GetDistance() ||
642  !lcl_isOdfDoubleLine( pLeft ) )
643  return false;
644  break;
646  if( bEqual || nullptr == pRight ||
647  0 == pRight->GetDistance() ||
648  !lcl_isOdfDoubleLine( pRight ) )
649  return false;
650  break;
652  if( bEqual || nullptr == pTop ||
653  0 == pTop->GetDistance() ||
654  !lcl_isOdfDoubleLine( pTop ) )
655  return false;
656  break;
658  if( bEqual || nullptr == pBottom ||
659  0 == pBottom->GetDistance() ||
660  !lcl_isOdfDoubleLine( pBottom ) )
661  return false;
662  break;
663  }
664  }
665  break;
666  }
667 
668  // now export it export
669  switch( nMemberId )
670  {
671  // padding
672  case ALL_BORDER_PADDING:
673  case LEFT_BORDER_PADDING:
674  rUnitConverter.convertMeasureToXML( aOut, nLeftDist );
675  break;
677  rUnitConverter.convertMeasureToXML( aOut, nRightDist );
678  break;
679  case TOP_BORDER_PADDING:
680  rUnitConverter.convertMeasureToXML( aOut, nTopDist );
681  break;
683  rUnitConverter.convertMeasureToXML( aOut, nBottomDist );
684  break;
685 
686  // border
687  case ALL_BORDER:
688  case LEFT_BORDER:
689  case RIGHT_BORDER:
690  case TOP_BORDER:
691  case BOTTOM_BORDER:
692  {
693  const SvxBorderLine* pLine;
694  switch( nMemberId )
695  {
696  case ALL_BORDER:
697  case LEFT_BORDER:
698  pLine = pLeft;
699  break;
700  case RIGHT_BORDER:
701  pLine = pRight;
702  break;
703  case TOP_BORDER:
704  pLine = pTop;
705  break;
706  case BOTTOM_BORDER:
707  pLine = pBottom;
708  break;
709  default:
710  pLine = nullptr;
711  break;
712  }
713 
714  if( nullptr != pLine )
715  {
716  sal_Int32 nWidth = pLine->GetWidth();
717 
718  enum XMLTokenEnum eStyle = XML_SOLID;
719  bool bNoBorder = false;
720  switch (pLine->GetBorderLineStyle())
721  {
722  case SvxBorderLineStyle::SOLID:
723  eStyle = XML_SOLID;
724  break;
725  case SvxBorderLineStyle::DOTTED:
726  eStyle = XML_DOTTED;
727  break;
728  case SvxBorderLineStyle::DASHED:
729  eStyle = XML_DASHED;
730  break;
731  case SvxBorderLineStyle::FINE_DASHED:
732  eStyle = XML_FINE_DASHED;
733  break;
734  case SvxBorderLineStyle::DASH_DOT:
735  eStyle = XML_DASH_DOT;
736  break;
737  case SvxBorderLineStyle::DASH_DOT_DOT:
738  eStyle = XML_DASH_DOT_DOT;
739  break;
740  case SvxBorderLineStyle::DOUBLE_THIN:
741  eStyle = XML_DOUBLE_THIN;
742  break;
743  case SvxBorderLineStyle::DOUBLE:
744  case SvxBorderLineStyle::THINTHICK_SMALLGAP:
745  case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
746  case SvxBorderLineStyle::THINTHICK_LARGEGAP:
747  case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
748  case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
749  case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
750  eStyle = XML_DOUBLE;
751  break;
752  case SvxBorderLineStyle::EMBOSSED:
753  eStyle = XML_RIDGE;
754  break;
755  case SvxBorderLineStyle::ENGRAVED:
756  eStyle = XML_GROOVE;
757  break;
758  case SvxBorderLineStyle::INSET:
759  eStyle = XML_INSET;
760  break;
761  case SvxBorderLineStyle::OUTSET:
762  eStyle = XML_OUTSET;
763  break;
764  default:
765  bNoBorder = true;
766  }
767 
768  if ( !bNoBorder )
769  {
771  util::MeasureUnit::TWIP,
772  util::MeasureUnit::POINT);
773  aOut.append( ' ' );
774  aOut.append( GetXMLToken( eStyle ) );
775  aOut.append( ' ' );
777  pLine->GetColor());
778  }
779  }
780  else
781  {
782  aOut.append( GetXMLToken(XML_NONE) );
783  }
784  }
785  break;
786 
787  // width
793  const SvxBorderLine* pLine;
794  switch( nMemberId )
795  {
798  pLine = pLeft;
799  break;
801  pLine = pRight;
802  break;
804  pLine = pTop;
805  break;
807  pLine = pBottom;
808  break;
809  default:
810  return false;
811  }
812  rUnitConverter.convertMeasureToXML( aOut, pLine->GetInWidth() );
813  aOut.append( ' ' );
814  rUnitConverter.convertMeasureToXML( aOut, pLine->GetDistance() );
815  aOut.append( ' ' );
816  rUnitConverter.convertMeasureToXML( aOut, pLine->GetOutWidth() );
817  break;
818  }
819  bOk = true;
820  }
821  }
822  break;
823 
824  case RES_BREAK:
825  {
826  const SvxFormatBreakItem& rFormatBreak = dynamic_cast<const SvxFormatBreakItem&>(rItem);
827 
828  sal_uInt16 eEnum = 0;
829 
830  switch( nMemberId )
831  {
832  case MID_BREAK_BEFORE:
833  switch (rFormatBreak.GetBreak())
834  {
835  case SvxBreak::ColumnBefore:
836  eEnum = 1;
837  break;
838  case SvxBreak::PageBefore:
839  eEnum = 2;
840  break;
841  case SvxBreak::NONE:
842  eEnum = 0;
843  break;
844  default:
845  return false;
846  }
847  break;
848  case MID_BREAK_AFTER:
849  switch (rFormatBreak.GetBreak())
850  {
851  case SvxBreak::ColumnAfter:
852  eEnum = 1;
853  break;
854  case SvxBreak::PageAfter:
855  eEnum = 2;
856  break;
857  case SvxBreak::NONE:
858  eEnum = 0;
859  break;
860  default:
861  return false;
862  }
863  break;
864  }
865 
866  bOk = SvXMLUnitConverter::convertEnum( aOut, eEnum, psXML_BreakType );
867  }
868  break;
869 
870  case RES_KEEP:
871  {
872  const SvxFormatKeepItem* pFormatKeep = dynamic_cast<const SvxFormatKeepItem*>( &rItem );
873  assert(pFormatKeep && "Wrong Which-ID");
874  if (pFormatKeep)
875  {
876  aOut.append( pFormatKeep->GetValue()
878  : GetXMLToken( XML_AUTO ) );
879  bOk = true;
880  }
881  }
882  break;
883 
884  case RES_BACKGROUND:
885  {
886  const SvxBrushItem& rBrush = dynamic_cast<const SvxBrushItem&>(rItem);
887 
888  // note: the graphic is only exported if nMemberId equals
889  // MID_GRAPHIC...
890  // If not, only the color or transparency is exported
891 
892  switch( nMemberId )
893  {
894  case MID_BACK_COLOR:
895  if ( rBrush.GetColor().GetTransparency() )
896  aOut.append( GetXMLToken(XML_TRANSPARENT) );
897  else
898  {
900  rBrush.GetColor());
901  }
902  bOk = true;
903  break;
904 
906  switch (rBrush.GetGraphicPos())
907  {
908  case GPOS_LT:
909  case GPOS_MT:
910  case GPOS_RT:
911  aOut.append( GetXMLToken(XML_TOP) );
912  bOk = true;
913  break;
914  case GPOS_LM:
915  case GPOS_MM:
916  case GPOS_RM:
917  aOut.append( GetXMLToken(XML_CENTER) );
918  bOk = true;
919  break;
920  case GPOS_LB:
921  case GPOS_MB:
922  case GPOS_RB:
923  aOut.append( GetXMLToken(XML_BOTTOM) );
924  bOk = true;
925  break;
926  default:
927  ;
928  }
929 
930  if( bOk )
931  {
932  aOut.append( ' ' );
933 
934  switch (rBrush.GetGraphicPos())
935  {
936  case GPOS_LT:
937  case GPOS_LB:
938  case GPOS_LM:
939  aOut.append( GetXMLToken(XML_LEFT) );
940  break;
941  case GPOS_MT:
942  case GPOS_MM:
943  case GPOS_MB:
944  aOut.append( GetXMLToken(XML_CENTER) );
945  break;
946  case GPOS_RM:
947  case GPOS_RT:
948  case GPOS_RB:
949  aOut.append( GetXMLToken(XML_RIGHT) );
950  break;
951  default:
952  ;
953  }
954  }
955  break;
956 
957  case MID_GRAPHIC_REPEAT:
958  {
959  SvxGraphicPosition eGraphicPos = rBrush.GetGraphicPos();
960  if( GPOS_AREA == eGraphicPos )
961  {
962  aOut.append( GetXMLToken(XML_BACKGROUND_STRETCH) );
963  bOk = true;
964  }
965  else if( GPOS_NONE != eGraphicPos && GPOS_TILED != eGraphicPos )
966  {
967  aOut.append( GetXMLToken(XML_BACKGROUND_NO_REPEAT) );
968  bOk = true;
969  }
970  }
971  break;
972 
973  case MID_GRAPHIC_FILTER:
974  if (rBrush.GetGraphicPos() != GPOS_NONE &&
975  !rBrush.GetGraphicFilter().isEmpty())
976  {
977  aOut.append(rBrush.GetGraphicFilter());
978  bOk = true;
979  }
980  break;
981  }
982  }
983  break;
984 
985  case RES_PAGEDESC:
986  {
987  const SwFormatPageDesc& rPageDesc = dynamic_cast<const SwFormatPageDesc&>(rItem);
988 
989  if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
990  {
991  ::boost::optional<sal_uInt16> oNumOffset = rPageDesc.GetNumOffset();
992  if (oNumOffset && oNumOffset.get() > 0)
993  {
994  // #i114163# positiveInteger only!
995  sal_Int32 const number(oNumOffset.get());
996  aOut.append(number);
997  }
998  else
999  {
1000  aOut.append(GetXMLToken(XML_AUTO));
1001  }
1002  bOk = true;
1003  }
1004  }
1005  break;
1006 
1007  case RES_LAYOUT_SPLIT:
1008  case RES_ROW_SPLIT:
1009  {
1010  const SfxBoolItem* pSplit = dynamic_cast<const SfxBoolItem*>( &rItem );
1011  assert(pSplit && "Wrong Which-ID");
1012  if (pSplit)
1013  {
1014  ::sax::Converter::convertBool( aOut, pSplit->GetValue() );
1015  bOk = true;
1016  }
1017  }
1018  break;
1019 
1020  case RES_HORI_ORIENT:
1021  {
1022  const SwFormatHoriOrient* pHoriOrient = dynamic_cast<const SwFormatHoriOrient*>( &rItem );
1023  assert(pHoriOrient && "Wrong Which-ID");
1024  if (pHoriOrient)
1025  {
1026  SvXMLUnitConverter::convertEnum( aOut, pHoriOrient->GetHoriOrient(),
1028  bOk = true;
1029  }
1030  }
1031  break;
1032 
1033  case RES_VERT_ORIENT:
1034  {
1035  const SwFormatVertOrient* pVertOrient = dynamic_cast<const SwFormatVertOrient*>( &rItem );
1036  assert(pVertOrient && "Wrong Which-ID");
1037 
1038  SvXMLUnitConverter::convertEnum( aOut, pVertOrient->GetVertOrient(),
1040  bOk = true;
1041  }
1042  break;
1043 
1044  case RES_FRM_SIZE:
1045  {
1046  const SwFormatFrameSize& rFrameSize = dynamic_cast<const SwFormatFrameSize&>(rItem);
1047 
1048  bool bOutHeight = false;
1049  switch( nMemberId )
1050  {
1051  case MID_FRMSIZE_REL_WIDTH:
1052  if (rFrameSize.GetWidthPercent())
1053  {
1055  aOut, rFrameSize.GetWidthPercent() );
1056  bOk = true;
1057  }
1058  break;
1060  if( ATT_MIN_SIZE == rFrameSize.GetHeightSizeType() )
1061  bOutHeight = true;
1062  break;
1064  if( ATT_FIX_SIZE == rFrameSize.GetHeightSizeType() )
1065  bOutHeight = true;
1066  break;
1067  }
1068 
1069  if( bOutHeight )
1070  {
1071  rUnitConverter.convertMeasureToXML(aOut, rFrameSize.GetHeight());
1072  bOk = true;
1073  }
1074  }
1075  break;
1076 
1077  case RES_FRAMEDIR:
1078  {
1079  Any aAny;
1080  bOk = rItem.QueryValue( aAny );
1081  if( bOk )
1082  {
1083  std::unique_ptr<XMLPropertyHandler> pWritingModeHandler =
1086  OUString sValue;
1087  bOk = pWritingModeHandler->exportXML( sValue, aAny,
1088  rUnitConverter );
1089  if( bOk )
1090  aOut.append( sValue );
1091  }
1092  }
1093  break;
1094 
1096  {
1097  const SfxBoolItem* pBorders = dynamic_cast<const SfxBoolItem*>( &rItem );
1098  assert(pBorders && "Wrong RES-ID");
1099  if (pBorders)
1100  {
1101  aOut.append( pBorders->GetValue()
1103  : GetXMLToken( XML_SEPARATING ) );
1104  bOk = true;
1105  }
1106  }
1107  break;
1108 
1109  default:
1110  OSL_FAIL("GetXMLValue not implemented for this item.");
1111  break;
1112  }
1113 
1114  if ( bOk )
1115  rValue = aOut.makeStringAndClear();
1116 
1117  return bOk;
1118 }
1119 
1120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
bool GetValue() const
XML_BOTTOM
#define RES_FRM_SIZE
Definition: hintids.hxx:196
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
XML_DOUBLE_THIN
SvXMLExportItemMapper(SvXMLItemMapEntriesRef rMapEntries)
Definition: xmlexpit.cxx:289
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
sal_uInt16 GetLower() const
XML_WRITING_MODE
static bool convertBool(bool &rBool, const OUString &rString)
GPOS_RM
static bool convertMeasure(sal_Int32 &rValue, const OUString &rString, sal_Int16 nTargetUnit=css::util::MeasureUnit::MM_100TH, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
#define RES_HORI_ORIENT
Definition: hintids.hxx:210
virtual void handleElementItem(const SvXMLItemMapEntry &rEntry, const SfxPoolItem &rItem) const
this method is called for every item that has the MID_SW_FLAG_ELEMENT_EXPORT flag set ...
Definition: xmlexpit.cxx:332
XML_OUTSET
short GetTextFirstLineOfst() const
#define MID_FIRST_AUTO
const OUString & GetGraphicFilter() const
GPOS_NONE
GPOS_LT
static std::unique_ptr< XMLPropertyHandler > CreatePropertyHandler(sal_Int32 nType)
#define MID_FRMSIZE_MIN_HEIGHT
Definition: unomid.h:79
SvxBreak GetBreak() const
sal_uInt16 nWhichId
Definition: xmlitmap.hxx:43
#define RES_SHADOW
Definition: hintids.hxx:214
sal_uInt16 getCount() const
Definition: xmlitmpr.cxx:71
#define MID_FRMSIZE_REL_WIDTH
Definition: unomid.h:72
sal_uInt8 GetTransparency() const
XML_DOUBLE
#define RES_FRAMEDIR
Definition: hintids.hxx:227
#define LEFT_BORDER_PADDING
XML_ALWAYS
#define MID_PAGEDESC_PAGENUMOFFSET
Definition: unomid.h:27
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
#define MID_BACK_COLOR
const editeng::SvxBorderLine * GetRight() const
Frame cannot be moved in Var-direction.
Definition: fmtfsize.hxx:38
virtual ~SvXMLExportItemMapper()
Definition: xmlexpit.cxx:294
sal_uInt16 GetPropLower() const
#define MID_FIRST_LINE_INDENT
#define LEFT_BORDER
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableVAlignMap[]
Definition: xmlithlp.cxx:324
SvXMLItemMapEntry const & getByIndex(sal_uInt16 nIndex) const
Definition: xmlitmpr.cxx:66
XML_RIGHT
#define TOP_BORDER_LINE_WIDTH
#define ALL_BORDER_LINE_WIDTH
SvXMLAttributeList & GetAttrList()
GPOS_TILED
SvxGraphicPosition GetGraphicPos() const
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
SvxShadowLocation GetLocation() const
#define XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
GPOS_LM
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const
XML_INSET
#define MID_SW_FLAG_MASK
Definition: xmlitmap.hxx:28
XML_BACKGROUND_STRETCH
const OUString & GetAttrLName(sal_uInt16 i) const
#define RES_UL_SPACE
Definition: hintids.hxx:199
#define MID_FRMSIZE_FIX_HEIGHT
Definition: unomid.h:80
#define MID_GRAPHIC_REPEAT
XML_SOLID
XMLTokenEnum
virtual void handleSpecialItem(SvXMLAttributeList &rAttrList, const SvXMLItemMapEntry &rEntry, const SfxPoolItem &rItem, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap, const SfxItemSet *pSet) const
this method is called for every item that has the MID_SW_FLAG_SPECIAL_ITEM_EXPORT flag set ...
Definition: xmlexpit.cxx:320
#define RES_ROW_SPLIT
Definition: hintids.hxx:229
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableAlignMap[]
Definition: xmlithlp.cxx:313
#define RES_BACKGROUND
Definition: hintids.hxx:212
const Color & GetColor() const
sal_uInt16 GetPropRight() const
const ::boost::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:65
const Color & GetColor() const
XML_FINE_DASHED
#define MID_L_MARGIN
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
sal_uInt16 GetIndexByPrefix(const OUString &rPrefix) const
#define BOTTOM_BORDER_PADDING
#define MID_SW_FLAG_ELEMENT_ITEM_EXPORT
Definition: xmlitmap.hxx:36
enum::xmloff::token::XMLTokenEnum const eLocalName
Definition: xmlitmap.hxx:45
#define RES_VERT_ORIENT
Definition: hintids.hxx:209
OUString sName
XML_TOP
#define TOP_BORDER
int i
sal_uInt16 GetPropLeft() const
#define MID_SW_FLAG_SPECIAL_ITEM_EXPORT
Definition: xmlitmap.hxx:33
virtual sal_Int16 SAL_CALL getLength() override
GPOS_MT
SvxGraphicPosition
XML_BT_LR
static const SfxPoolItem * GetItem(const SfxItemSet &rSet, sal_uInt16 nWhichId)
returns the item with the given WhichId from the given ItemSet if its set
Definition: xmlexpit.cxx:272
#define RES_LAYOUT_SPLIT
Definition: hintids.hxx:220
SvXMLItemMapEntriesRef mrMapEntries
Definition: xmlexpit.hxx:37
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
#define TOP_BORDER_PADDING
GPOS_MM
static bool QueryXMLValue(const SfxPoolItem &rItem, OUString &rValue, sal_uInt16 nMemberId, const SvXMLUnitConverter &rUnitConverter)
Definition: xmlexpit.cxx:359
XML_CENTER
static bool lcl_isOdfDoubleLine(const SvxBorderLine *pLine)
Definition: xmlexpit.cxx:339
XML_GROOVE
XML_SEPARATING
#define MID_R_MARGIN
const OUString & GetAttrValue(sal_uInt16 i) const
#define MID_GRAPHIC_POSITION
OUString GetQNameByKey(sal_uInt16 nKey, const OUString &rLocalName, bool bCache=true) const
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
#define MID_SW_FLAG_NO_ITEM_EXPORT
Definition: xmlitmap.hxx:34
GPOS_AREA
OUString GetAttrNamespace(sal_uInt16 i) const
XML_DASH_DOT_DOT
XML_LEFT
const SvXMLNamespaceMap & GetNamespaceMap() const
XML_RIDGE
GPOS_MB
OUString GetAttrPrefix(sal_uInt16 i) const
#define RES_LR_SPACE
Definition: hintids.hxx:198
#define ALL_BORDER_PADDING
void IgnorableWhitespace()
#define LEFT_BORDER_LINE_WIDTH
#define RIGHT_BORDER_LINE_WIDTH
#define BOTTOM_BORDER
SfxItemState
#define MID_BREAK_AFTER
#define RIGHT_BORDER_PADDING
void exportXML(const SvXMLExport &rExport, SvXMLAttributeList &rAttrList, const SfxItemSet &rSet, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap, std::vector< sal_uInt16 > *pIndexArray) const
fills the given attribute list with the items in the given set
Definition: xmlexpit.cxx:65
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
static bool convertColor(sal_Int32 &rColor, const OUString &rValue)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
void exportElementItems(SvXMLExport &rExport, const SfxItemSet &rSet, const std::vector< sal_uInt16 > &rIndexArray) const
Definition: xmlexpit.cxx:240
#define RES_KEEP
Definition: hintids.hxx:217
sal_uInt16 Add(const OUString &rPrefix, const OUString &rName, sal_uInt16 nKey=XML_NAMESPACE_UNKNOWN)
#define MID_LO_MARGIN
sal_uInt32 const nMemberId
Definition: xmlitmap.hxx:48
#define MID_GRAPHIC_FILTER
sal_Int16 GetVertOrient() const
Definition: fmtornt.hxx:54
XML_COLLAPSING
XML_DASHED
const struct SvXMLEnumMapEntry< sal_uInt16 > psXML_BreakType[]
Definition: xmlithlp.cxx:303
long GetRight() const
XML_NONE
XML_DOTTED
sal_uInt16 GetPropTextFirstLineOfst() const
sal_uInt16 GetAttrCount() const
#define ALL_BORDER
#define RES_BOX
Definition: hintids.hxx:213
void AddAttribute(const OUString &sName, const OUString &sValue)
#define RIGHT_BORDER
sal_uInt16 const nNameSpace
Definition: xmlitmap.hxx:41
GPOS_RB
#define RES_COLLAPSING_BORDERS
Definition: hintids.hxx:231
const OUString & GetNameByIndex(sal_uInt16 nIdx) const
GPOS_LB
XML_BACKGROUND_NO_REPEAT
#define RES_PAGEDESC
Definition: hintids.hxx:200
#define RES_BREAK
Definition: hintids.hxx:201
long GetHeight() const
GPOS_RT
#define MID_BREAK_BEFORE
XML_XMLNS
XML_AUTO
SvXMLExportFlags getExportFlags() const
bool IsAutoFirst() const
const editeng::SvxBorderLine * GetBottom() const
#define BOTTOM_BORDER_LINE_WIDTH
void convertMeasureToXML(OUStringBuffer &rBuffer, sal_Int32 nMeasure) const
sal_uInt16 Which() const
const struct SvXMLEnumMapEntry< sal_uInt16 > aXML_KeepTogetherType[]
Definition: xmlithlp.cxx:332
sal_uInt16 GetUpper() const
static bool convertPercent(sal_Int32 &rValue, const OUString &rString)
XML_TRANSPARENT
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80
sal_uInt16 GetWidth() const
sal_uInt16 GetPropUpper() const
XML_DASH_DOT
#define MID_UP_MARGIN