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 SvXMLUnitConverter& rUnitConverter,
243  const SfxItemSet &rSet,
244  SvXmlExportFlags nFlags,
245  const std::vector<sal_uInt16> &rIndexArray ) const
246 {
247  const size_t nCount = rIndexArray.size();
248 
249  bool bItemsExported = false;
250  for( size_t nIndex = 0; nIndex < nCount; ++nIndex )
251  {
252  const sal_uInt16 nElement = rIndexArray[ nIndex ];
253  SvXMLItemMapEntry const & rEntry = mrMapEntries->getByIndex( nElement );
254  OSL_ENSURE( 0 != (rEntry.nMemberId & MID_SW_FLAG_ELEMENT_ITEM_EXPORT),
255  "wrong mid flag!" );
256 
257  const SfxPoolItem* pItem = GetItem( rSet, rEntry.nWhichId );
258  // do we have an item?
259  if(pItem)
260  {
261  rExport.IgnorableWhitespace();
262  handleElementItem( rExport, rEntry, *pItem, rUnitConverter,
263  rSet, nFlags);
264  bItemsExported = true;
265  }
266  }
267 
268  if( bItemsExported )
269  rExport.IgnorableWhitespace();
270 }
271 
276  sal_uInt16 nWhichId)
277 {
278  // first get item from itemset
279  const SfxPoolItem* pItem;
280  SfxItemState eState = rSet.GetItemState( nWhichId, false, &pItem );
281 
282  if( SfxItemState::SET == eState )
283  {
284  return pItem;
285  }
286  else
287  {
288  return nullptr;
289  }
290 }
291 
293 {
294  mrMapEntries = std::move(rMapEntries);
295 }
296 
298 {
299 }
300 
302  const SfxItemSet& rSet,
303  const SvXMLUnitConverter& rUnitConverter,
304  XMLTokenEnum ePropToken ) const
305 {
306  std::vector<sal_uInt16> aIndexArray;
307 
308  exportXML( rExport, rExport.GetAttrList(), rSet, rUnitConverter,
309  rExport.GetNamespaceMap(), &aIndexArray );
310 
311  if( rExport.GetAttrList().getLength() > 0 || !aIndexArray.empty() )
312  {
313  rExport.IgnorableWhitespace();
314 
315  SvXMLElementExport aElem( rExport, XML_NAMESPACE_STYLE, ePropToken,
316  false, false );
317  exportElementItems( rExport, rUnitConverter,
318  rSet, SvXmlExportFlags::IGN_WS, aIndexArray );
319  }
320 }
321 
325  const SvXMLItemMapEntry& /*rEntry*/,
326  const SfxPoolItem& /*rItem*/,
327  const SvXMLUnitConverter& /*rUnitConverter*/,
328  const SvXMLNamespaceMap& /*rNamespaceMap*/,
329  const SfxItemSet* /*pSet*/ /* = NULL */ ) const
330 {
331  OSL_FAIL( "special item not handled in xml export" );
332 }
333 
337  SvXMLExport& /*rExport*/,
338  const SvXMLItemMapEntry& /*rEntry*/,
339  const SfxPoolItem& /*rItem*/,
340  const SvXMLUnitConverter& /*rUnitConverter*/,
341  const SfxItemSet& /*rSet*/,
342  SvXmlExportFlags /*nFlags*/ ) const
343 {
344  OSL_FAIL( "element item not handled in xml export" );
345 }
346 
347 static bool lcl_isOdfDoubleLine( const SvxBorderLine* pLine )
348 {
349  bool bIsOdfDouble = false;
350  switch (pLine->GetBorderLineStyle())
351  {
352  case SvxBorderLineStyle::DOUBLE:
353  case SvxBorderLineStyle::THINTHICK_SMALLGAP:
354  case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
355  case SvxBorderLineStyle::THINTHICK_LARGEGAP:
356  case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
357  case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
358  case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
359  bIsOdfDouble = true;
360  break;
361  default:
362  break;
363  }
364  return bIsOdfDouble;
365 }
366 
368  const SfxPoolItem& rItem,
369  OUString& rValue,
370  sal_uInt16 nMemberId,
371  const SvXMLUnitConverter& rUnitConverter )
372 {
373  bool bOk = false;
374  OUStringBuffer aOut;
375 
376  switch ( rItem.Which() )
377  {
378 
379  case RES_LR_SPACE:
380  {
381  const SvxLRSpaceItem& rLRSpace = dynamic_cast<const SvxLRSpaceItem&>(rItem);
382 
383  bOk = true;
384  switch( nMemberId )
385  {
386  case MID_L_MARGIN:
387  if (rLRSpace.GetPropLeft() != 100)
388  {
390  aOut, rLRSpace.GetPropLeft() );
391  }
392  else
393  {
394  rUnitConverter.convertMeasureToXML(
395  aOut, rLRSpace.GetLeft() );
396  }
397  break;
398 
399  case MID_R_MARGIN:
400  if (rLRSpace.GetPropRight() != 100)
401  {
403  aOut, rLRSpace.GetPropRight() );
404  }
405  else
406  {
407  rUnitConverter.convertMeasureToXML(
408  aOut, rLRSpace.GetRight() );
409  }
410  break;
411 
412  case MID_FIRST_AUTO:
413  if (rLRSpace.IsAutoFirst())
414  {
416  aOut, rLRSpace.IsAutoFirst() );
417  }
418  else
419  bOk = false;
420  break;
421 
423  if (!rLRSpace.IsAutoFirst())
424  {
425  if (rLRSpace.GetPropTextFirstLineOfst() != 100)
426  {
428  aOut, rLRSpace.GetPropTextFirstLineOfst() );
429  }
430  else
431  {
432  rUnitConverter.convertMeasureToXML(
433  aOut, rLRSpace.GetTextFirstLineOfst() );
434  }
435  }
436  else
437  bOk = false;
438  break;
439 
440  default:
441  OSL_FAIL( "unknown member id!");
442  bOk = false;
443  break;
444  }
445  }
446  break;
447 
448  case RES_UL_SPACE:
449  {
450  const SvxULSpaceItem& rULSpace = dynamic_cast<const SvxULSpaceItem&>(rItem);
451 
452  switch( nMemberId )
453  {
454  case MID_UP_MARGIN:
455  if (rULSpace.GetPropUpper() != 100)
456  {
458  aOut, rULSpace.GetPropUpper() );
459  }
460  else
461  {
462  rUnitConverter.convertMeasureToXML(
463  aOut, rULSpace.GetUpper() );
464  }
465  break;
466 
467  case MID_LO_MARGIN:
468  if (rULSpace.GetPropLower() != 100)
469  {
471  aOut, rULSpace.GetPropLower() );
472  }
473  else
474  {
475  rUnitConverter.convertMeasureToXML(
476  aOut, rULSpace.GetLower() );
477  }
478  break;
479 
480  default:
481  OSL_FAIL("unknown MemberId");
482  };
483 
484  bOk = true;
485  }
486  break;
487 
488  case RES_SHADOW:
489  {
490  const SvxShadowItem* pShadow = dynamic_cast<const SvxShadowItem*>( &rItem );
491  assert(pShadow && "Wrong Which-ID");
492  if (pShadow)
493  {
494  sal_Int32 nX = 1, nY = 1;
495  switch( pShadow->GetLocation() )
496  {
497  case SvxShadowLocation::TopLeft:
498  nX = -1;
499  nY = -1;
500  break;
501  case SvxShadowLocation::TopRight:
502  nY = -1;
503  break;
504  case SvxShadowLocation::BottomLeft:
505  nX = -1;
506  break;
507  case SvxShadowLocation::BottomRight:
508  break;
509  case SvxShadowLocation::NONE:
510  default:
511  rValue = GetXMLToken(XML_NONE);
512  return true;
513  }
514 
515  nX *= pShadow->GetWidth();
516  nY *= pShadow->GetWidth();
517 
518  ::sax::Converter::convertColor(aOut, pShadow->GetColor());
519  aOut.append( ' ' );
520  rUnitConverter.convertMeasureToXML( aOut, nX );
521  aOut.append( ' ' );
522  rUnitConverter.convertMeasureToXML( aOut, nY );
523 
524  bOk = true;
525  }
526  }
527  break;
528 
529  case RES_BOX:
530  {
531  const SvxBoxItem* pBox = dynamic_cast<const SvxBoxItem*>( &rItem );
532  assert(pBox && "Wrong Which-ID");
533  if (pBox)
534  {
557  const SvxBorderLine* pLeft = pBox->GetLeft();
558  const SvxBorderLine* pRight = pBox->GetRight();
559  const SvxBorderLine* pTop = pBox->GetTop();
560  const SvxBorderLine* pBottom = pBox->GetBottom();
561  const sal_uInt16 nTopDist = pBox->GetDistance( SvxBoxItemLine::TOP );
562  const sal_uInt16 nBottomDist = pBox->GetDistance( SvxBoxItemLine::BOTTOM );
563  const sal_uInt16 nLeftDist = pBox->GetDistance( SvxBoxItemLine::LEFT );
564  const sal_uInt16 nRightDist = pBox->GetDistance( SvxBoxItemLine::RIGHT );
565 
566  // check if we need to export it
567  switch( nMemberId )
568  {
569  case ALL_BORDER_PADDING:
570  case LEFT_BORDER_PADDING:
572  case TOP_BORDER_PADDING:
574  {
575  bool bEqual = nLeftDist == nRightDist &&
576  nLeftDist == nTopDist &&
577  nLeftDist == nBottomDist;
578  // don't export individual paddings if all paddings are equal and
579  // don't export all padding if some paddings are not equal
580  if( (bEqual && ALL_BORDER_PADDING != nMemberId) ||
581  (!bEqual && ALL_BORDER_PADDING == nMemberId) )
582  return false;
583  }
584  break;
585  case ALL_BORDER:
586  case LEFT_BORDER:
587  case RIGHT_BORDER:
588  case TOP_BORDER:
589  case BOTTOM_BORDER:
590  {
591  bool bEqual = ( nullptr == pTop && nullptr == pBottom &&
592  nullptr == pLeft && nullptr == pRight ) ||
593  ( pTop && pBottom && pLeft && pRight &&
594  *pTop == *pBottom && *pTop == *pLeft &&
595  *pTop == *pRight );
596 
597  // don't export individual borders if all are the same and
598  // don't export all borders if some are not equal
599  if( (bEqual && ALL_BORDER != nMemberId) ||
600  (!bEqual && ALL_BORDER == nMemberId) )
601  return false;
602  }
603  break;
609  {
610  // if no line is set, there is nothing to export
611  if( !pTop && !pBottom && !pLeft && !pRight )
612  return false;
613 
614  bool bEqual = nullptr != pTop &&
615  nullptr != pBottom &&
616  nullptr != pLeft &&
617  nullptr != pRight;
618 
619  if( bEqual )
620  {
621  const sal_uInt16 nDistance = pTop->GetDistance();
622  const sal_uInt16 nInWidth = pTop->GetInWidth();
623  const sal_uInt16 nOutWidth = pTop->GetOutWidth();
624  const long nWidth = pTop->GetWidth();
625 
626  bEqual = nDistance == pLeft->GetDistance() &&
627  nInWidth == pLeft->GetInWidth() &&
628  nOutWidth == pLeft->GetOutWidth() &&
629  nWidth == pLeft->GetWidth() &&
630  nDistance == pRight->GetDistance() &&
631  nInWidth == pRight->GetInWidth() &&
632  nOutWidth == pRight->GetOutWidth() &&
633  nWidth == pRight->GetWidth() &&
634  nDistance == pBottom->GetDistance() &&
635  nInWidth == pBottom->GetInWidth() &&
636  nOutWidth == pBottom->GetOutWidth() &&
637  nWidth == pBottom->GetWidth();
638  }
639 
640  switch( nMemberId )
641  {
643  if( !bEqual || pTop->GetDistance() == 0 ||
644  !lcl_isOdfDoubleLine( pTop ) )
645  return false;
646  break;
648  if( bEqual || nullptr == pLeft ||
649  0 == pLeft->GetDistance() ||
650  !lcl_isOdfDoubleLine( pLeft ) )
651  return false;
652  break;
654  if( bEqual || nullptr == pRight ||
655  0 == pRight->GetDistance() ||
656  !lcl_isOdfDoubleLine( pRight ) )
657  return false;
658  break;
660  if( bEqual || nullptr == pTop ||
661  0 == pTop->GetDistance() ||
662  !lcl_isOdfDoubleLine( pTop ) )
663  return false;
664  break;
666  if( bEqual || nullptr == pBottom ||
667  0 == pBottom->GetDistance() ||
668  !lcl_isOdfDoubleLine( pBottom ) )
669  return false;
670  break;
671  }
672  }
673  break;
674  }
675 
676  // now export it export
677  switch( nMemberId )
678  {
679  // padding
680  case ALL_BORDER_PADDING:
681  case LEFT_BORDER_PADDING:
682  rUnitConverter.convertMeasureToXML( aOut, nLeftDist );
683  break;
685  rUnitConverter.convertMeasureToXML( aOut, nRightDist );
686  break;
687  case TOP_BORDER_PADDING:
688  rUnitConverter.convertMeasureToXML( aOut, nTopDist );
689  break;
691  rUnitConverter.convertMeasureToXML( aOut, nBottomDist );
692  break;
693 
694  // border
695  case ALL_BORDER:
696  case LEFT_BORDER:
697  case RIGHT_BORDER:
698  case TOP_BORDER:
699  case BOTTOM_BORDER:
700  {
701  const SvxBorderLine* pLine;
702  switch( nMemberId )
703  {
704  case ALL_BORDER:
705  case LEFT_BORDER:
706  pLine = pLeft;
707  break;
708  case RIGHT_BORDER:
709  pLine = pRight;
710  break;
711  case TOP_BORDER:
712  pLine = pTop;
713  break;
714  case BOTTOM_BORDER:
715  pLine = pBottom;
716  break;
717  default:
718  pLine = nullptr;
719  break;
720  }
721 
722  if( nullptr != pLine )
723  {
724  sal_Int32 nWidth = pLine->GetWidth();
725 
726  enum XMLTokenEnum eStyle = XML_SOLID;
727  bool bNoBorder = false;
728  switch (pLine->GetBorderLineStyle())
729  {
730  case SvxBorderLineStyle::SOLID:
731  eStyle = XML_SOLID;
732  break;
733  case SvxBorderLineStyle::DOTTED:
734  eStyle = XML_DOTTED;
735  break;
736  case SvxBorderLineStyle::DASHED:
737  eStyle = XML_DASHED;
738  break;
739  case SvxBorderLineStyle::FINE_DASHED:
740  eStyle = XML_FINE_DASHED;
741  break;
742  case SvxBorderLineStyle::DASH_DOT:
743  eStyle = XML_DASH_DOT;
744  break;
745  case SvxBorderLineStyle::DASH_DOT_DOT:
746  eStyle = XML_DASH_DOT_DOT;
747  break;
748  case SvxBorderLineStyle::DOUBLE_THIN:
749  eStyle = XML_DOUBLE_THIN;
750  break;
751  case SvxBorderLineStyle::DOUBLE:
752  case SvxBorderLineStyle::THINTHICK_SMALLGAP:
753  case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
754  case SvxBorderLineStyle::THINTHICK_LARGEGAP:
755  case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
756  case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
757  case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
758  eStyle = XML_DOUBLE;
759  break;
760  case SvxBorderLineStyle::EMBOSSED:
761  eStyle = XML_RIDGE;
762  break;
763  case SvxBorderLineStyle::ENGRAVED:
764  eStyle = XML_GROOVE;
765  break;
766  case SvxBorderLineStyle::INSET:
767  eStyle = XML_INSET;
768  break;
769  case SvxBorderLineStyle::OUTSET:
770  eStyle = XML_OUTSET;
771  break;
772  default:
773  bNoBorder = true;
774  }
775 
776  if ( !bNoBorder )
777  {
779  util::MeasureUnit::TWIP,
780  util::MeasureUnit::POINT);
781  aOut.append( ' ' );
782  aOut.append( GetXMLToken( eStyle ) );
783  aOut.append( ' ' );
785  pLine->GetColor());
786  }
787  }
788  else
789  {
790  aOut.append( GetXMLToken(XML_NONE) );
791  }
792  }
793  break;
794 
795  // width
801  const SvxBorderLine* pLine;
802  switch( nMemberId )
803  {
806  pLine = pLeft;
807  break;
809  pLine = pRight;
810  break;
812  pLine = pTop;
813  break;
815  pLine = pBottom;
816  break;
817  default:
818  return false;
819  }
820  rUnitConverter.convertMeasureToXML( aOut, pLine->GetInWidth() );
821  aOut.append( ' ' );
822  rUnitConverter.convertMeasureToXML( aOut, pLine->GetDistance() );
823  aOut.append( ' ' );
824  rUnitConverter.convertMeasureToXML( aOut, pLine->GetOutWidth() );
825  break;
826  }
827  bOk = true;
828  }
829  }
830  break;
831 
832  case RES_BREAK:
833  {
834  const SvxFormatBreakItem& rFormatBreak = dynamic_cast<const SvxFormatBreakItem&>(rItem);
835 
836  sal_uInt16 eEnum = 0;
837 
838  switch( nMemberId )
839  {
840  case MID_BREAK_BEFORE:
841  switch (rFormatBreak.GetBreak())
842  {
843  case SvxBreak::ColumnBefore:
844  eEnum = 1;
845  break;
846  case SvxBreak::PageBefore:
847  eEnum = 2;
848  break;
849  case SvxBreak::NONE:
850  eEnum = 0;
851  break;
852  default:
853  return false;
854  }
855  break;
856  case MID_BREAK_AFTER:
857  switch (rFormatBreak.GetBreak())
858  {
859  case SvxBreak::ColumnAfter:
860  eEnum = 1;
861  break;
862  case SvxBreak::PageAfter:
863  eEnum = 2;
864  break;
865  case SvxBreak::NONE:
866  eEnum = 0;
867  break;
868  default:
869  return false;
870  }
871  break;
872  }
873 
874  bOk = SvXMLUnitConverter::convertEnum( aOut, eEnum, psXML_BreakType );
875  }
876  break;
877 
878  case RES_KEEP:
879  {
880  const SvxFormatKeepItem* pFormatKeep = dynamic_cast<const SvxFormatKeepItem*>( &rItem );
881  assert(pFormatKeep && "Wrong Which-ID");
882  if (pFormatKeep)
883  {
884  aOut.append( pFormatKeep->GetValue()
886  : GetXMLToken( XML_AUTO ) );
887  bOk = true;
888  }
889  }
890  break;
891 
892  case RES_BACKGROUND:
893  {
894  const SvxBrushItem& rBrush = dynamic_cast<const SvxBrushItem&>(rItem);
895 
896  // note: the graphic is only exported if nMemberId equals
897  // MID_GRAPHIC..
898  // If not, only the color or transparency is exported
899 
900  switch( nMemberId )
901  {
902  case MID_BACK_COLOR:
903  if ( rBrush.GetColor().GetTransparency() )
904  aOut.append( GetXMLToken(XML_TRANSPARENT) );
905  else
906  {
908  rBrush.GetColor());
909  }
910  bOk = true;
911  break;
912 
914  switch (rBrush.GetGraphicPos())
915  {
916  case GPOS_LT:
917  case GPOS_MT:
918  case GPOS_RT:
919  aOut.append( GetXMLToken(XML_TOP) );
920  bOk = true;
921  break;
922  case GPOS_LM:
923  case GPOS_MM:
924  case GPOS_RM:
925  aOut.append( GetXMLToken(XML_CENTER) );
926  bOk = true;
927  break;
928  case GPOS_LB:
929  case GPOS_MB:
930  case GPOS_RB:
931  aOut.append( GetXMLToken(XML_BOTTOM) );
932  bOk = true;
933  break;
934  default:
935  ;
936  }
937 
938  if( bOk )
939  {
940  aOut.append( ' ' );
941 
942  switch (rBrush.GetGraphicPos())
943  {
944  case GPOS_LT:
945  case GPOS_LB:
946  case GPOS_LM:
947  aOut.append( GetXMLToken(XML_LEFT) );
948  break;
949  case GPOS_MT:
950  case GPOS_MM:
951  case GPOS_MB:
952  aOut.append( GetXMLToken(XML_CENTER) );
953  break;
954  case GPOS_RM:
955  case GPOS_RT:
956  case GPOS_RB:
957  aOut.append( GetXMLToken(XML_RIGHT) );
958  break;
959  default:
960  ;
961  }
962  }
963  break;
964 
965  case MID_GRAPHIC_REPEAT:
966  {
967  SvxGraphicPosition eGraphicPos = rBrush.GetGraphicPos();
968  if( GPOS_AREA == eGraphicPos )
969  {
970  aOut.append( GetXMLToken(XML_BACKGROUND_STRETCH) );
971  bOk = true;
972  }
973  else if( GPOS_NONE != eGraphicPos && GPOS_TILED != eGraphicPos )
974  {
975  aOut.append( GetXMLToken(XML_BACKGROUND_NO_REPEAT) );
976  bOk = true;
977  }
978  }
979  break;
980 
981  case MID_GRAPHIC_FILTER:
982  if (rBrush.GetGraphicPos() != GPOS_NONE &&
983  !rBrush.GetGraphicFilter().isEmpty())
984  {
985  aOut.append(rBrush.GetGraphicFilter());
986  bOk = true;
987  }
988  break;
989  }
990  }
991  break;
992 
993  case RES_PAGEDESC:
994  {
995  const SwFormatPageDesc& rPageDesc = dynamic_cast<const SwFormatPageDesc&>(rItem);
996 
997  if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
998  {
999  ::boost::optional<sal_uInt16> oNumOffset = rPageDesc.GetNumOffset();
1000  if (oNumOffset && oNumOffset.get() > 0)
1001  {
1002  // #i114163# positiveInteger only!
1003  sal_Int32 const number(oNumOffset.get());
1004  aOut.append(number);
1005  }
1006  else
1007  {
1008  aOut.append(GetXMLToken(XML_AUTO));
1009  }
1010  bOk = true;
1011  }
1012  }
1013  break;
1014 
1015  case RES_LAYOUT_SPLIT:
1016  case RES_ROW_SPLIT:
1017  {
1018  const SfxBoolItem* pSplit = dynamic_cast<const SfxBoolItem*>( &rItem );
1019  assert(pSplit && "Wrong Which-ID");
1020  if (pSplit)
1021  {
1022  ::sax::Converter::convertBool( aOut, pSplit->GetValue() );
1023  bOk = true;
1024  }
1025  }
1026  break;
1027 
1028  case RES_HORI_ORIENT:
1029  {
1030  const SwFormatHoriOrient* pHoriOrient = dynamic_cast<const SwFormatHoriOrient*>( &rItem );
1031  assert(pHoriOrient && "Wrong Which-ID");
1032  if (pHoriOrient)
1033  {
1034  SvXMLUnitConverter::convertEnum( aOut, pHoriOrient->GetHoriOrient(),
1036  bOk = true;
1037  }
1038  }
1039  break;
1040 
1041  case RES_VERT_ORIENT:
1042  {
1043  const SwFormatVertOrient* pVertOrient = dynamic_cast<const SwFormatVertOrient*>( &rItem );
1044  assert(pVertOrient && "Wrong Which-ID");
1045 
1046  SvXMLUnitConverter::convertEnum( aOut, pVertOrient->GetVertOrient(),
1048  bOk = true;
1049  }
1050  break;
1051 
1052  case RES_FRM_SIZE:
1053  {
1054  const SwFormatFrameSize& rFrameSize = dynamic_cast<const SwFormatFrameSize&>(rItem);
1055 
1056  bool bOutHeight = false;
1057  switch( nMemberId )
1058  {
1059  case MID_FRMSIZE_REL_WIDTH:
1060  if (rFrameSize.GetWidthPercent())
1061  {
1063  aOut, rFrameSize.GetWidthPercent() );
1064  bOk = true;
1065  }
1066  break;
1068  if( ATT_MIN_SIZE == rFrameSize.GetHeightSizeType() )
1069  bOutHeight = true;
1070  break;
1072  if( ATT_FIX_SIZE == rFrameSize.GetHeightSizeType() )
1073  bOutHeight = true;
1074  break;
1075  }
1076 
1077  if( bOutHeight )
1078  {
1079  rUnitConverter.convertMeasureToXML(aOut, rFrameSize.GetHeight());
1080  bOk = true;
1081  }
1082  }
1083  break;
1084 
1085  case RES_FRAMEDIR:
1086  {
1087  Any aAny;
1088  bOk = rItem.QueryValue( aAny );
1089  if( bOk )
1090  {
1091  std::unique_ptr<XMLPropertyHandler> pWritingModeHandler =
1094  OUString sValue;
1095  bOk = pWritingModeHandler->exportXML( sValue, aAny,
1096  rUnitConverter );
1097  if( bOk )
1098  aOut.append( sValue );
1099  }
1100  }
1101  break;
1102 
1104  {
1105  const SfxBoolItem* pBorders = dynamic_cast<const SfxBoolItem*>( &rItem );
1106  assert(pBorders && "Wrong RES-ID");
1107  if (pBorders)
1108  {
1109  aOut.append( pBorders->GetValue()
1111  : GetXMLToken( XML_SEPARATING ) );
1112  bOk = true;
1113  }
1114  }
1115  break;
1116 
1117  default:
1118  OSL_FAIL("GetXMLValue not implemented for this item.");
1119  break;
1120  }
1121 
1122  if ( bOk )
1123  rValue = aOut.makeStringAndClear();
1124 
1125  return bOk;
1126 }
1127 
1128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
long GetLeft() const
bool GetValue() const
XML_BOTTOM
#define RES_FRM_SIZE
Definition: hintids.hxx:194
static bool convertEnum(EnumT &rEnum, const OUString &rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
XML_DOUBLE_THIN
SvXMLExportItemMapper(SvXMLItemMapEntriesRef rMapEntries)
Definition: xmlexpit.cxx:292
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:208
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:212
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:225
#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:297
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:197
#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:324
#define RES_ROW_SPLIT
Definition: hintids.hxx:227
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableAlignMap[]
Definition: xmlithlp.cxx:313
#define RES_BACKGROUND
Definition: hintids.hxx:210
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:207
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:275
#define RES_LAYOUT_SPLIT
Definition: hintids.hxx:218
SvXMLItemMapEntriesRef mrMapEntries
Definition: xmlexpit.hxx:38
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:367
XML_CENTER
static bool lcl_isOdfDoubleLine(const SvxBorderLine *pLine)
Definition: xmlexpit.cxx:347
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:196
#define ALL_BORDER_PADDING
void exportElementItems(SvXMLExport &rExport, const SvXMLUnitConverter &rUnitConverter, const SfxItemSet &rSet, SvXmlExportFlags nFlags, const std::vector< sal_uInt16 > &rIndexArray) const
Definition: xmlexpit.cxx:240
void IgnorableWhitespace()
#define LEFT_BORDER_LINE_WIDTH
#define RIGHT_BORDER_LINE_WIDTH
#define BOTTOM_BORDER
SfxItemState
#define MID_BREAK_AFTER
#define RIGHT_BORDER_PADDING
SvXmlExportFlags
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:259
#define RES_KEEP
Definition: hintids.hxx:215
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
virtual void handleElementItem(SvXMLExport &rExport, const SvXMLItemMapEntry &rEntry, const SfxPoolItem &rItem, const SvXMLUnitConverter &rUnitConverter, const SfxItemSet &rSet, SvXmlExportFlags nFlags) const
this method is called for every item that has the MID_SW_FLAG_ELEMENT_EXPORT flag set ...
Definition: xmlexpit.cxx:336
XML_DOTTED
sal_uInt16 GetPropTextFirstLineOfst() const
sal_uInt16 GetAttrCount() const
#define ALL_BORDER
#define RES_BOX
Definition: hintids.hxx:211
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:229
const OUString & GetNameByIndex(sal_uInt16 nIdx) const
GPOS_LB
XML_BACKGROUND_NO_REPEAT
#define RES_PAGEDESC
Definition: hintids.hxx:198
#define RES_BREAK
Definition: hintids.hxx:199
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