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 {
371
372 case RES_LR_SPACE:
373 {
374 const SvxLRSpaceItem& rLRSpace = dynamic_cast<const SvxLRSpaceItem&>(rItem);
375
376 bOk = true;
377 switch( nMemberId )
378 {
379 case MID_L_MARGIN:
380 if (rLRSpace.GetPropLeft() != 100)
381 {
383 aOut, rLRSpace.GetPropLeft() );
384 }
385 else
386 {
387 rUnitConverter.convertMeasureToXML(
388 aOut, rLRSpace.GetLeft() );
389 }
390 break;
391
392 case MID_R_MARGIN:
393 if (rLRSpace.GetPropRight() != 100)
394 {
396 aOut, rLRSpace.GetPropRight() );
397 }
398 else
399 {
400 rUnitConverter.convertMeasureToXML(
401 aOut, rLRSpace.GetRight() );
402 }
403 break;
404
405 case MID_FIRST_AUTO:
406 if (rLRSpace.IsAutoFirst())
407 {
409 aOut, rLRSpace.IsAutoFirst() );
410 }
411 else
412 bOk = false;
413 break;
414
416 if (!rLRSpace.IsAutoFirst())
417 {
418 if (rLRSpace.GetPropTextFirstLineOffset() != 100)
419 {
421 aOut, rLRSpace.GetPropTextFirstLineOffset() );
422 }
423 else
424 {
425 rUnitConverter.convertMeasureToXML(
426 aOut, rLRSpace.GetTextFirstLineOffset() );
427 }
428 }
429 else
430 bOk = false;
431 break;
432
433 default:
434 OSL_FAIL( "unknown member id!");
435 bOk = false;
436 break;
437 }
438 }
439 break;
440
441 case RES_UL_SPACE:
442 {
443 const SvxULSpaceItem& rULSpace = dynamic_cast<const SvxULSpaceItem&>(rItem);
444
445 switch( nMemberId )
446 {
447 case MID_UP_MARGIN:
448 if (rULSpace.GetPropUpper() != 100)
449 {
451 aOut, rULSpace.GetPropUpper() );
452 }
453 else
454 {
455 rUnitConverter.convertMeasureToXML(
456 aOut, rULSpace.GetUpper() );
457 }
458 break;
459
460 case MID_LO_MARGIN:
461 if (rULSpace.GetPropLower() != 100)
462 {
464 aOut, rULSpace.GetPropLower() );
465 }
466 else
467 {
468 rUnitConverter.convertMeasureToXML(
469 aOut, rULSpace.GetLower() );
470 }
471 break;
472
473 default:
474 OSL_FAIL("unknown MemberId");
475 };
476
477 bOk = true;
478 }
479 break;
480
481 case RES_SHADOW:
482 {
483 const SvxShadowItem* pShadow = dynamic_cast<const SvxShadowItem*>( &rItem );
484 assert(pShadow && "Wrong Which-ID");
485 if (pShadow)
486 {
487 sal_Int32 nX = 1, nY = 1;
488 switch( pShadow->GetLocation() )
489 {
490 case SvxShadowLocation::TopLeft:
491 nX = -1;
492 nY = -1;
493 break;
494 case SvxShadowLocation::TopRight:
495 nY = -1;
496 break;
497 case SvxShadowLocation::BottomLeft:
498 nX = -1;
499 break;
500 case SvxShadowLocation::BottomRight:
501 break;
502 case SvxShadowLocation::NONE:
503 default:
504 rValue = GetXMLToken(XML_NONE);
505 return true;
506 }
507
508 nX *= pShadow->GetWidth();
509 nY *= pShadow->GetWidth();
510
512 aOut.append( ' ' );
513 rUnitConverter.convertMeasureToXML( aOut, nX );
514 aOut.append( ' ' );
515 rUnitConverter.convertMeasureToXML( aOut, nY );
516
517 bOk = true;
518 }
519 }
520 break;
521
522 case RES_BOX:
523 {
524 const SvxBoxItem* pBox = dynamic_cast<const SvxBoxItem*>( &rItem );
525 assert(pBox && "Wrong Which-ID");
526 if (pBox)
527 {
550 const SvxBorderLine* pLeft = pBox->GetLeft();
551 const SvxBorderLine* pRight = pBox->GetRight();
552 const SvxBorderLine* pTop = pBox->GetTop();
553 const SvxBorderLine* pBottom = pBox->GetBottom();
554 const sal_uInt16 nTopDist = pBox->GetDistance( SvxBoxItemLine::TOP );
555 const sal_uInt16 nBottomDist = pBox->GetDistance( SvxBoxItemLine::BOTTOM );
556 const sal_uInt16 nLeftDist = pBox->GetDistance( SvxBoxItemLine::LEFT );
557 const sal_uInt16 nRightDist = pBox->GetDistance( SvxBoxItemLine::RIGHT );
558
559 // check if we need to export it
560 switch( nMemberId )
561 {
567 {
568 bool bEqual = nLeftDist == nRightDist &&
569 nLeftDist == nTopDist &&
570 nLeftDist == nBottomDist;
571 // don't export individual paddings if all paddings are equal and
572 // don't export all padding if some paddings are not equal
573 if( (bEqual && ALL_BORDER_PADDING != nMemberId) ||
574 (!bEqual && ALL_BORDER_PADDING == nMemberId) )
575 return false;
576 }
577 break;
578 case ALL_BORDER:
579 case LEFT_BORDER:
580 case RIGHT_BORDER:
581 case TOP_BORDER:
582 case BOTTOM_BORDER:
583 {
584 bool bEqual = ( nullptr == pTop && nullptr == pBottom &&
585 nullptr == pLeft && nullptr == pRight ) ||
586 ( pTop && pBottom && pLeft && pRight &&
587 *pTop == *pBottom && *pTop == *pLeft &&
588 *pTop == *pRight );
589
590 // don't export individual borders if all are the same and
591 // don't export all borders if some are not equal
592 if( (bEqual && ALL_BORDER != nMemberId) ||
593 (!bEqual && ALL_BORDER == nMemberId) )
594 return false;
595 }
596 break;
602 {
603 // if no line is set, there is nothing to export
604 if( !pTop && !pBottom && !pLeft && !pRight )
605 return false;
606
607 bool bEqual = nullptr != pTop &&
608 nullptr != pBottom &&
609 nullptr != pLeft &&
610 nullptr != pRight;
611
612 if( bEqual )
613 {
614 const sal_uInt16 nDistance = pTop->GetDistance();
615 const sal_uInt16 nInWidth = pTop->GetInWidth();
616 const sal_uInt16 nOutWidth = pTop->GetOutWidth();
617 const tools::Long nWidth = pTop->GetWidth();
618
619 bEqual = nDistance == pLeft->GetDistance() &&
620 nInWidth == pLeft->GetInWidth() &&
621 nOutWidth == pLeft->GetOutWidth() &&
622 nWidth == pLeft->GetWidth() &&
623 nDistance == pRight->GetDistance() &&
624 nInWidth == pRight->GetInWidth() &&
625 nOutWidth == pRight->GetOutWidth() &&
626 nWidth == pRight->GetWidth() &&
627 nDistance == pBottom->GetDistance() &&
628 nInWidth == pBottom->GetInWidth() &&
629 nOutWidth == pBottom->GetOutWidth() &&
630 nWidth == pBottom->GetWidth();
631 }
632
633 switch( nMemberId )
634 {
636 if( !bEqual || pTop->GetDistance() == 0 ||
637 !lcl_isOdfDoubleLine( pTop ) )
638 return false;
639 break;
641 if( bEqual || nullptr == pLeft ||
642 0 == pLeft->GetDistance() ||
643 !lcl_isOdfDoubleLine( pLeft ) )
644 return false;
645 break;
647 if( bEqual || nullptr == pRight ||
648 0 == pRight->GetDistance() ||
649 !lcl_isOdfDoubleLine( pRight ) )
650 return false;
651 break;
653 if( bEqual || nullptr == pTop ||
654 0 == pTop->GetDistance() ||
655 !lcl_isOdfDoubleLine( pTop ) )
656 return false;
657 break;
659 if( bEqual || nullptr == pBottom ||
660 0 == pBottom->GetDistance() ||
661 !lcl_isOdfDoubleLine( pBottom ) )
662 return false;
663 break;
664 }
665 }
666 break;
667 }
668
669 // now export it export
670 switch( nMemberId )
671 {
672 // padding
675 rUnitConverter.convertMeasureToXML( aOut, nLeftDist );
676 break;
678 rUnitConverter.convertMeasureToXML( aOut, nRightDist );
679 break;
681 rUnitConverter.convertMeasureToXML( aOut, nTopDist );
682 break;
684 rUnitConverter.convertMeasureToXML( aOut, nBottomDist );
685 break;
686
687 // border
688 case ALL_BORDER:
689 case LEFT_BORDER:
690 case RIGHT_BORDER:
691 case TOP_BORDER:
692 case BOTTOM_BORDER:
693 {
694 const SvxBorderLine* pLine;
695 switch( nMemberId )
696 {
697 case ALL_BORDER:
698 case LEFT_BORDER:
699 pLine = pLeft;
700 break;
701 case RIGHT_BORDER:
702 pLine = pRight;
703 break;
704 case TOP_BORDER:
705 pLine = pTop;
706 break;
707 case BOTTOM_BORDER:
708 pLine = pBottom;
709 break;
710 default:
711 pLine = nullptr;
712 break;
713 }
714
715 if( nullptr != pLine )
716 {
717 sal_Int32 nWidth = pLine->GetWidth();
718
719 enum XMLTokenEnum eStyle = XML_SOLID;
720 bool bNoBorder = false;
721 switch (pLine->GetBorderLineStyle())
722 {
723 case SvxBorderLineStyle::SOLID:
724 eStyle = XML_SOLID;
725 break;
726 case SvxBorderLineStyle::DOTTED:
727 eStyle = XML_DOTTED;
728 break;
729 case SvxBorderLineStyle::DASHED:
730 eStyle = XML_DASHED;
731 break;
732 case SvxBorderLineStyle::FINE_DASHED:
733 eStyle = XML_FINE_DASHED;
734 break;
735 case SvxBorderLineStyle::DASH_DOT:
736 eStyle = XML_DASH_DOT;
737 break;
738 case SvxBorderLineStyle::DASH_DOT_DOT:
739 eStyle = XML_DASH_DOT_DOT;
740 break;
741 case SvxBorderLineStyle::DOUBLE_THIN:
742 eStyle = XML_DOUBLE_THIN;
743 break;
744 case SvxBorderLineStyle::DOUBLE:
745 case SvxBorderLineStyle::THINTHICK_SMALLGAP:
746 case SvxBorderLineStyle::THINTHICK_MEDIUMGAP:
747 case SvxBorderLineStyle::THINTHICK_LARGEGAP:
748 case SvxBorderLineStyle::THICKTHIN_SMALLGAP:
749 case SvxBorderLineStyle::THICKTHIN_MEDIUMGAP:
750 case SvxBorderLineStyle::THICKTHIN_LARGEGAP:
751 eStyle = XML_DOUBLE;
752 break;
753 case SvxBorderLineStyle::EMBOSSED:
754 eStyle = XML_RIDGE;
755 break;
756 case SvxBorderLineStyle::ENGRAVED:
757 eStyle = XML_GROOVE;
758 break;
759 case SvxBorderLineStyle::INSET:
760 eStyle = XML_INSET;
761 break;
762 case SvxBorderLineStyle::OUTSET:
763 eStyle = XML_OUTSET;
764 break;
765 default:
766 bNoBorder = true;
767 }
768
769 if ( !bNoBorder )
770 {
772 util::MeasureUnit::TWIP,
773 util::MeasureUnit::POINT);
774 aOut.append( ' ' );
775 aOut.append( GetXMLToken( eStyle ) );
776 aOut.append( ' ' );
778 pLine->GetColor());
779 }
780 }
781 else
782 {
783 aOut.append( GetXMLToken(XML_NONE) );
784 }
785 }
786 break;
787
788 // width
794 const SvxBorderLine* pLine;
795 switch( nMemberId )
796 {
799 pLine = pLeft;
800 break;
802 pLine = pRight;
803 break;
805 pLine = pTop;
806 break;
808 pLine = pBottom;
809 break;
810 default:
811 return false;
812 }
813 rUnitConverter.convertMeasureToXML( aOut, pLine->GetInWidth() );
814 aOut.append( ' ' );
815 rUnitConverter.convertMeasureToXML( aOut, pLine->GetDistance() );
816 aOut.append( ' ' );
817 rUnitConverter.convertMeasureToXML( aOut, pLine->GetOutWidth() );
818 break;
819 }
820 bOk = true;
821 }
822 }
823 break;
824
825 case RES_BREAK:
826 {
827 const SvxFormatBreakItem& rFormatBreak = dynamic_cast<const SvxFormatBreakItem&>(rItem);
828
829 sal_uInt16 eEnum = 0;
830
831 switch( nMemberId )
832 {
833 case MID_BREAK_BEFORE:
834 switch (rFormatBreak.GetBreak())
835 {
836 case SvxBreak::ColumnBefore:
837 eEnum = 1;
838 break;
839 case SvxBreak::PageBefore:
840 eEnum = 2;
841 break;
842 case SvxBreak::NONE:
843 eEnum = 0;
844 break;
845 default:
846 return false;
847 }
848 break;
849 case MID_BREAK_AFTER:
850 switch (rFormatBreak.GetBreak())
851 {
852 case SvxBreak::ColumnAfter:
853 eEnum = 1;
854 break;
855 case SvxBreak::PageAfter:
856 eEnum = 2;
857 break;
858 case SvxBreak::NONE:
859 eEnum = 0;
860 break;
861 default:
862 return false;
863 }
864 break;
865 }
866
868 }
869 break;
870
871 case RES_KEEP:
872 {
873 const SvxFormatKeepItem* pFormatKeep = dynamic_cast<const SvxFormatKeepItem*>( &rItem );
874 assert(pFormatKeep && "Wrong Which-ID");
875 if (pFormatKeep)
876 {
877 aOut.append( pFormatKeep->GetValue()
879 : GetXMLToken( XML_AUTO ) );
880 bOk = true;
881 }
882 }
883 break;
884
885 case RES_PRINT:
886 {
887 const SvxPrintItem* pHasTextChangesOnly = dynamic_cast<const SvxPrintItem*>( &rItem );
888 if (pHasTextChangesOnly && !pHasTextChangesOnly->GetValue())
889 {
890 aOut.append( "false" );
891 bOk = true;
892 }
893 }
894 break;
895
896 case RES_BACKGROUND:
897 {
898 const SvxBrushItem& rBrush = dynamic_cast<const SvxBrushItem&>(rItem);
899
900 // note: the graphic is only exported if nMemberId equals
901 // MID_GRAPHIC...
902 // If not, only the color or transparency is exported
903
904 switch( nMemberId )
905 {
906 case MID_BACK_COLOR:
907 if ( rBrush.GetColor().IsTransparent() )
908 aOut.append( GetXMLToken(XML_TRANSPARENT) );
909 else
910 {
912 rBrush.GetColor());
913 }
914 bOk = true;
915 break;
916
918 switch (rBrush.GetGraphicPos())
919 {
920 case GPOS_LT:
921 case GPOS_MT:
922 case GPOS_RT:
923 aOut.append( GetXMLToken(XML_TOP) );
924 bOk = true;
925 break;
926 case GPOS_LM:
927 case GPOS_MM:
928 case GPOS_RM:
929 aOut.append( GetXMLToken(XML_CENTER) );
930 bOk = true;
931 break;
932 case GPOS_LB:
933 case GPOS_MB:
934 case GPOS_RB:
935 aOut.append( GetXMLToken(XML_BOTTOM) );
936 bOk = true;
937 break;
938 default:
939 ;
940 }
941
942 if( bOk )
943 {
944 aOut.append( ' ' );
945
946 switch (rBrush.GetGraphicPos())
947 {
948 case GPOS_LT:
949 case GPOS_LB:
950 case GPOS_LM:
951 aOut.append( GetXMLToken(XML_LEFT) );
952 break;
953 case GPOS_MT:
954 case GPOS_MM:
955 case GPOS_MB:
956 aOut.append( GetXMLToken(XML_CENTER) );
957 break;
958 case GPOS_RM:
959 case GPOS_RT:
960 case GPOS_RB:
961 aOut.append( GetXMLToken(XML_RIGHT) );
962 break;
963 default:
964 ;
965 }
966 }
967 break;
968
970 {
971 SvxGraphicPosition eGraphicPos = rBrush.GetGraphicPos();
972 if( GPOS_AREA == eGraphicPos )
973 {
974 aOut.append( GetXMLToken(XML_STRETCH) );
975 bOk = true;
976 }
977 else if( GPOS_NONE != eGraphicPos && GPOS_TILED != eGraphicPos )
978 {
980 bOk = true;
981 }
982 }
983 break;
984
986 if (rBrush.GetGraphicPos() != GPOS_NONE &&
987 !rBrush.GetGraphicFilter().isEmpty())
988 {
989 aOut.append(rBrush.GetGraphicFilter());
990 bOk = true;
991 }
992 break;
993 }
994 }
995 break;
996
997 case RES_PAGEDESC:
998 {
999 const SwFormatPageDesc& rPageDesc = dynamic_cast<const SwFormatPageDesc&>(rItem);
1000
1001 if( MID_PAGEDESC_PAGENUMOFFSET==nMemberId )
1002 {
1003 ::std::optional<sal_uInt16> oNumOffset = rPageDesc.GetNumOffset();
1004 if (oNumOffset && *oNumOffset > 0)
1005 {
1006 // #i114163# positiveInteger only!
1007 sal_Int32 const number(*oNumOffset);
1008 aOut.append(number);
1009 }
1010 else
1011 {
1012 aOut.append(GetXMLToken(XML_AUTO));
1013 }
1014 bOk = true;
1015 }
1016 }
1017 break;
1018
1019 case RES_LAYOUT_SPLIT:
1020 case RES_ROW_SPLIT:
1021 {
1022 const SfxBoolItem* pSplit = dynamic_cast<const SfxBoolItem*>( &rItem );
1023 assert(pSplit && "Wrong Which-ID");
1024 if (pSplit)
1025 {
1026 ::sax::Converter::convertBool( aOut, pSplit->GetValue() );
1027 bOk = true;
1028 }
1029 }
1030 break;
1031
1032 case RES_HORI_ORIENT:
1033 {
1034 const SwFormatHoriOrient* pHoriOrient = dynamic_cast<const SwFormatHoriOrient*>( &rItem );
1035 assert(pHoriOrient && "Wrong Which-ID");
1036 if (pHoriOrient)
1037 {
1038 SvXMLUnitConverter::convertEnum( aOut, pHoriOrient->GetHoriOrient(),
1040 bOk = true;
1041 }
1042 }
1043 break;
1044
1045 case RES_VERT_ORIENT:
1046 {
1047 const SwFormatVertOrient* pVertOrient = dynamic_cast<const SwFormatVertOrient*>( &rItem );
1048 assert(pVertOrient && "Wrong Which-ID");
1049
1050 SvXMLUnitConverter::convertEnum( aOut, pVertOrient->GetVertOrient(),
1052 bOk = true;
1053 }
1054 break;
1055
1056 case RES_FRM_SIZE:
1057 {
1058 const SwFormatFrameSize& rFrameSize = dynamic_cast<const SwFormatFrameSize&>(rItem);
1059
1060 bool bOutHeight = false;
1061 switch( nMemberId )
1062 {
1064 if (rFrameSize.GetWidthPercent())
1065 {
1067 aOut, rFrameSize.GetWidthPercent() );
1068 bOk = true;
1069 }
1070 break;
1072 if( SwFrameSize::Minimum == rFrameSize.GetHeightSizeType() )
1073 bOutHeight = true;
1074 break;
1076 if( SwFrameSize::Fixed == rFrameSize.GetHeightSizeType() )
1077 bOutHeight = true;
1078 break;
1079 }
1080
1081 if( bOutHeight )
1082 {
1083 rUnitConverter.convertMeasureToXML(aOut, rFrameSize.GetHeight());
1084 bOk = true;
1085 }
1086 }
1087 break;
1088
1089 case RES_FRAMEDIR:
1090 {
1091 Any aAny;
1092 bOk = rItem.QueryValue( aAny );
1093 if( bOk )
1094 {
1095 std::unique_ptr<XMLPropertyHandler> pWritingModeHandler =
1098 OUString sValue;
1099 bOk = pWritingModeHandler->exportXML( sValue, aAny,
1100 rUnitConverter );
1101 if( bOk )
1102 aOut.append( sValue );
1103 }
1104 }
1105 break;
1106
1108 {
1109 const SfxBoolItem* pBorders = dynamic_cast<const SfxBoolItem*>( &rItem );
1110 assert(pBorders && "Wrong RES-ID");
1111 if (pBorders)
1112 {
1113 aOut.append( pBorders->GetValue()
1116 bOk = true;
1117 }
1118 }
1119 break;
1120
1121 default:
1122 OSL_FAIL("GetXMLValue not implemented for this item.");
1123 break;
1124 }
1125
1126 if ( bOk )
1127 rValue = aOut.makeStringAndClear();
1128
1129 return bOk;
1130}
1131
1132/* 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
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).
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(107)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(125)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
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
const char * sName
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