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