1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlexpit.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include "xmlexpit.hxx"
35 #include <xmloff/xmluconv.hxx>
36 #include <rtl/ustrbuf.hxx>
37 #include <svtools/itempool.hxx>
38 #include <svtools/poolitem.hxx>
39 #include <svtools/itemset.hxx>
40 #include <xmloff/attrlist.hxx>
41 #include <xmloff/nmspmap.hxx>
42 #include <xmloff/xmlnmspe.hxx>
43 #include <svx/xmlcnitm.hxx>
44 #include <xmloff/xmlexp.hxx>
46 #ifndef _SVSTDARR_USHORTS
47 #define _SVSTDARR_USHORTS
48 #include <svtools/svstdarr.hxx>
52 #include "hintids.hxx"
54 #include <svx/unomid.hxx>
55 #include <svx/lrspitem.hxx>
56 #include <svx/ulspitem.hxx>
57 #include <svx/shaditem.hxx>
58 #include <svx/boxitem.hxx>
59 #include <svx/brkitem.hxx>
60 #include <svx/keepitem.hxx>
61 #include <svx/brshitem.hxx>
62 #include "fmtpdsc.hxx"
63 #include "fmtornt.hxx"
64 #include "fmtfsize.hxx"
67 #include "fmtlsplt.hxx"
69 #include "xmlithlp.hxx"
71 #include "fmtrowsplt.hxx"
74 using ::rtl::OUString
;
75 using ::rtl::OUStringBuffer
;
76 using namespace ::com::sun::star
;
77 using namespace ::xmloff::token
;
80 /** fills the given attribute list with the items in the given set */
81 void SvXMLExportItemMapper::exportXML( const SvXMLExport
& rExport
,
82 SvXMLAttributeList
& rAttrList
,
83 const SfxItemSet
& rSet
,
84 const SvXMLUnitConverter
& rUnitConverter
,
85 const SvXMLNamespaceMap
& rNamespaceMap
,
87 SvUShorts
* pIndexArray
) const
89 const sal_uInt16 nCount
= mrMapEntries
->getCount();
90 sal_uInt16 nIndex
= 0;
92 while( nIndex
< nCount
)
94 SvXMLItemMapEntry
* pEntry
= mrMapEntries
->getByIndex( nIndex
);
96 // we have a valid map entry here, so lets use it...
97 if( 0 == (pEntry
->nMemberId
& MID_SW_FLAG_NO_ITEM_EXPORT
) )
99 const SfxPoolItem
* pItem
= GetItem( rSet
, pEntry
->nWhichId
,
101 // do we have an item?
104 if( 0 != (pEntry
->nMemberId
& MID_SW_FLAG_ELEMENT_ITEM_EXPORT
) )
106 // element items do not add any properties,
107 // we export it later
109 pIndexArray
->Insert( nIndex
, pIndexArray
->Count() );
114 exportXML( rExport
, rAttrList
, *pItem
, *pEntry
, rUnitConverter
,
115 rNamespaceMap
, nFlags
, &rSet
);
121 handleNoItem( rAttrList
, *pEntry
, rUnitConverter
, rNamespaceMap
,
128 void SvXMLExportItemMapper::exportXML( const SvXMLExport
& rExport
,
129 SvXMLAttributeList
& rAttrList
,
130 const SfxPoolItem
& rItem
,
131 const SvXMLItemMapEntry
& rEntry
,
132 const SvXMLUnitConverter
& rUnitConverter
,
133 const SvXMLNamespaceMap
& rNamespaceMap
,
134 sal_uInt16
/*nFlags*/,
135 const SfxItemSet
*pSet
) const
137 if( 0 != (rEntry
.nMemberId
& MID_SW_FLAG_SPECIAL_ITEM_EXPORT
) )
139 if( rItem
.ISA( SwFmtRowSplit
) )
142 bool bAddAttribute
= true;
143 if( rEntry
.nNameSpace
== XML_NAMESPACE_STYLE
)
145 if( (rExport
.getExportFlags() & EXPORT_SAVEBACKWARDCOMPATIBLE
) == 0 ||
146 !QueryXMLValue(rItem
, aValue
,
147 static_cast< sal_uInt16
>( rEntry
.nMemberId
& MID_SW_FLAG_MASK
),
150 bAddAttribute
= false;
156 const SfxBoolItem
* pSplit
= PTR_CAST(SfxBoolItem
, &rItem
);
157 DBG_ASSERT( pSplit
!= NULL
, "Wrong Which-ID" );
158 sal_uInt16 eEnum
= pSplit
->GetValue() ? 1 : 0;
159 rUnitConverter
.convertEnum( aOut
, eEnum
, aXML_KeepTogetherType
);
160 aValue
= aOut
.makeStringAndClear();
164 OUString
sName( rNamespaceMap
.GetQNameByKey( rEntry
.nNameSpace
,
165 GetXMLToken(rEntry
.eLocalName
) ) );
166 rAttrList
.AddAttribute( sName
, aValue
);
169 if( rItem
.ISA( SvXMLAttrContainerItem
) )
171 SvXMLNamespaceMap
*pNewNamespaceMap
= 0;
172 const SvXMLNamespaceMap
*pNamespaceMap
= &rNamespaceMap
;
174 const SvXMLAttrContainerItem
*pUnknown
=
175 PTR_CAST( SvXMLAttrContainerItem
, &rItem
);
177 sal_uInt16 nCount
= pUnknown
->GetAttrCount();
178 OUStringBuffer sName
;
179 for( sal_uInt16 i
=0; i
< nCount
; i
++ )
181 OUString
sPrefix( pUnknown
->GetAttrPrefix( i
) );
182 if( sPrefix
.getLength() )
184 OUString
sNamespace( pUnknown
->GetAttrNamespace( i
) );
186 // if the prefix isn't defined yet or has another meaning,
187 // we have to redefine it now.
188 sal_uInt16 nIdx
= pNamespaceMap
->GetIndexByPrefix( sPrefix
);
189 if( USHRT_MAX
== nIdx
||
190 pNamespaceMap
->GetNameByIndex( nIdx
) != sNamespace
)
192 if( !pNewNamespaceMap
)
195 new SvXMLNamespaceMap( rNamespaceMap
);
196 pNamespaceMap
= pNewNamespaceMap
;
198 pNewNamespaceMap
->Add( sPrefix
, sNamespace
);
200 sName
.append( GetXMLToken(XML_XMLNS
) );
201 sName
.append( sal_Unicode(':') );
202 sName
.append( sPrefix
);
203 rAttrList
.AddAttribute( sName
.makeStringAndClear(),
207 sName
.append( sPrefix
);
208 sName
.append( sal_Unicode(':') );
211 sName
.append( pUnknown
->GetAttrLName( i
) );
212 rAttrList
.AddAttribute( sName
.makeStringAndClear(),
213 pUnknown
->GetAttrValue(i
) );
216 delete pNewNamespaceMap
;
220 handleSpecialItem( rAttrList
, rEntry
, rItem
, rUnitConverter
,
221 rNamespaceMap
, pSet
);
224 else if( 0 == (rEntry
.nMemberId
& MID_SW_FLAG_ELEMENT_ITEM_EXPORT
) )
227 if( QueryXMLValue(rItem
, aValue
,
228 static_cast< sal_uInt16
>(
229 rEntry
.nMemberId
& MID_SW_FLAG_MASK
),
233 rNamespaceMap
.GetQNameByKey( rEntry
.nNameSpace
,
234 GetXMLToken(rEntry
.eLocalName
)));
235 rAttrList
.AddAttribute( sName
, aValue
);
240 void SvXMLExportItemMapper::exportElementItems(
241 SvXMLExport
& rExport
,
242 const SvXMLUnitConverter
& rUnitConverter
,
243 const SfxItemSet
&rSet
,
245 const SvUShorts
& rIndexArray
) const
247 const sal_uInt16 nCount
= rIndexArray
.Count();
249 sal_Bool bItemsExported
= sal_False
;
250 for( sal_uInt16 nIndex
= 0; nIndex
< nCount
; nIndex
++ )
252 const sal_uInt16 nElement
= rIndexArray
.GetObject( nIndex
);
253 SvXMLItemMapEntry
* pEntry
= mrMapEntries
->getByIndex( nElement
);
254 DBG_ASSERT( 0 != (pEntry
->nMemberId
& MID_SW_FLAG_ELEMENT_ITEM_EXPORT
),
257 const SfxPoolItem
* pItem
= GetItem( rSet
, pEntry
->nWhichId
, nFlags
);
258 // do we have an item?
261 rExport
.IgnorableWhitespace();
262 handleElementItem( rExport
, *pEntry
, *pItem
, rUnitConverter
,
264 bItemsExported
= sal_True
;
269 rExport
.IgnorableWhitespace();
272 /** returns the item with the givin WhichId from the given ItemSet if its
273 set or its default item if its not set and the XML_EXPORT_FLAG_DEEP
276 const SfxPoolItem
* SvXMLExportItemMapper::GetItem( const SfxItemSet
& rSet
,
280 // first get item from itemset
281 const SfxPoolItem
* pItem
;
282 SfxItemState eState
=
283 rSet
.GetItemState( nWhichId
,
284 ( nFlags
& XML_EXPORT_FLAG_DEEP
) != 0,
287 if( SFX_ITEM_SET
== eState
)
291 else if( (nFlags
& XML_EXPORT_FLAG_DEFAULTS
) != 0 &&
292 SFX_WHICH_MAX
> nWhichId
)
294 // if its not set, try the pool if we export defaults
295 return &rSet
.GetPool()->GetDefaultItem(nWhichId
);
303 SvXMLExportItemMapper::SvXMLExportItemMapper( SvXMLItemMapEntriesRef rMapEntries
)
305 mrMapEntries
= rMapEntries
;
308 SvXMLExportItemMapper::~SvXMLExportItemMapper()
312 void SvXMLExportItemMapper::exportXML( SvXMLExport
& rExport
,
313 const SfxItemSet
& rSet
,
314 const SvXMLUnitConverter
& rUnitConverter
,
315 XMLTokenEnum ePropToken
,
316 sal_uInt16 nFlags
) const
318 SvUShorts aIndexArray
;
320 exportXML( rExport
, rExport
.GetAttrList(), rSet
, rUnitConverter
,
321 rExport
.GetNamespaceMap(), nFlags
, &aIndexArray
);
323 if( rExport
.GetAttrList().getLength() > 0L ||
324 (nFlags
& XML_EXPORT_FLAG_EMPTY
) != 0 ||
325 aIndexArray
.Count() != 0 )
327 if( (nFlags
& XML_EXPORT_FLAG_IGN_WS
) != 0 )
329 rExport
.IgnorableWhitespace();
332 SvXMLElementExport
aElem( rExport
, XML_NAMESPACE_STYLE
, ePropToken
,
333 sal_False
, sal_False
);
334 exportElementItems( rExport
, rUnitConverter
,
335 rSet
, nFlags
, aIndexArray
);
339 /** this method is called for every item that has the
340 MID_SW_FLAG_SPECIAL_ITEM_EXPORT flag set */
341 void SvXMLExportItemMapper::handleSpecialItem( SvXMLAttributeList
& /*rAttrList*/,
342 const SvXMLItemMapEntry
& /*rEntry*/,
343 const SfxPoolItem
& /*rItem*/,
344 const SvXMLUnitConverter
& /*rUnitConverter*/,
345 const SvXMLNamespaceMap
& /*rNamespaceMap*/,
346 const SfxItemSet
* /*pSet*/ /* = NULL */ ) const
348 DBG_ERROR( "special item not handled in xml export" );
351 /** this method is called for every item that has the
352 MID_SW_FLAG_NO_ITEM_EXPORT flag set */
353 void SvXMLExportItemMapper::handleNoItem( SvXMLAttributeList
& /*rAttrList*/,
354 const SvXMLItemMapEntry
& /*rEntry*/,
355 const SvXMLUnitConverter
& /*rUnitConverter*/,
356 const SvXMLNamespaceMap
& /*rNamespaceMap*/,
357 const SfxItemSet
& /*rSet*/ ) const
359 DBG_ERROR( "no item not handled in xml export" );
362 /** this method is called for every item that has the
363 MID_SW_FLAG_ELEMENT_EXPORT flag set */
364 void SvXMLExportItemMapper::handleElementItem(
365 SvXMLExport
& /*rExport*/,
366 const SvXMLItemMapEntry
& /*rEntry*/,
367 const SfxPoolItem
& /*rItem*/,
368 const SvXMLUnitConverter
& /*rUnitConverter*/,
369 const SfxItemSet
& /*rSet*/,
370 sal_uInt16
/*nFlags*/ ) const
372 DBG_ERROR( "element item not handled in xml export" );
376 sal_Bool
SvXMLExportItemMapper::QueryXMLValue(
377 const SfxPoolItem
& rItem
,
379 sal_uInt16 nMemberId
,
380 const SvXMLUnitConverter
& rUnitConverter
)
382 sal_Bool bOk
= sal_False
;
385 switch ( rItem
.Which() )
390 const SvxLRSpaceItem
* pLRSpace
= PTR_CAST(SvxLRSpaceItem
, &rItem
);
391 DBG_ASSERT( pLRSpace
!= NULL
, "Wrong Which-ID!" );
397 if(pLRSpace
->GetPropLeft() != 100)
398 rUnitConverter
.convertPercent( aOut
, pLRSpace
->GetPropLeft() );
400 rUnitConverter
.convertMeasure( aOut
, pLRSpace
->GetLeft() );
404 if(pLRSpace
->GetPropRight() != 100)
405 rUnitConverter
.convertPercent( aOut
, pLRSpace
->GetPropRight() );
407 rUnitConverter
.convertMeasure( aOut
, pLRSpace
->GetRight() );
411 if( pLRSpace
->IsAutoFirst() )
412 rUnitConverter
.convertBool( aOut
, pLRSpace
->IsAutoFirst() );
417 case MID_FIRST_LINE_INDENT
:
418 if( !pLRSpace
->IsAutoFirst() )
420 if(pLRSpace
->GetPropTxtFirstLineOfst() != 100)
421 rUnitConverter
.convertPercent(
422 aOut
, pLRSpace
->GetPropTxtFirstLineOfst() );
424 rUnitConverter
.convertMeasure( aOut
, pLRSpace
->GetTxtFirstLineOfst() );
431 DBG_ERROR( "unknown member id!");
440 const SvxULSpaceItem
* pULSpace
= PTR_CAST(SvxULSpaceItem
, &rItem
);
441 DBG_ASSERT( pULSpace
!= NULL
, "Wrong Which-ID!" );
446 if( pULSpace
->GetPropUpper() != 100 )
447 rUnitConverter
.convertPercent( aOut
, pULSpace
->GetPropUpper() );
449 rUnitConverter
.convertMeasure( aOut
, pULSpace
->GetUpper() );
453 if( pULSpace
->GetPropLower() != 100 )
454 rUnitConverter
.convertPercent( aOut
, pULSpace
->GetPropLower() );
456 rUnitConverter
.convertMeasure( aOut
, pULSpace
->GetLower() );
460 DBG_ERROR("unknown MemberId");
469 const SvxShadowItem
* pShadow
= PTR_CAST(SvxShadowItem
, &rItem
);
470 DBG_ASSERT( pShadow
!= NULL
, "Wrong Which-ID" );
472 sal_Int32 nX
= 1, nY
= 1;
473 switch( pShadow
->GetLocation() )
475 case SVX_SHADOW_TOPLEFT
:
479 case SVX_SHADOW_TOPRIGHT
:
482 case SVX_SHADOW_BOTTOMLEFT
:
485 case SVX_SHADOW_BOTTOMRIGHT
:
487 case SVX_SHADOW_NONE
:
489 rValue
= GetXMLToken(XML_NONE
);
493 nX
*= pShadow
->GetWidth();
494 nY
*= pShadow
->GetWidth();
496 rUnitConverter
.convertColor( aOut
, pShadow
->GetColor() );
497 aOut
.append( sal_Unicode(' ') );
498 rUnitConverter
.convertMeasure( aOut
, nX
);
499 aOut
.append( sal_Unicode(' ') );
500 rUnitConverter
.convertMeasure( aOut
, nY
);
508 SvxBoxItem
* pBox
= PTR_CAST(SvxBoxItem
, &rItem
);
509 DBG_ASSERT( pBox
!= NULL
, "Wrong WHich-ID" );
514 border-padding ALL_BORDER_PADDING
515 border-padding-before LEFT_BORDER_PADDING
516 border-padding-after RIGHT_BORDER_PADDING
517 border-padding-start TOP_BORDER_PADDING
518 border-padding-end BOTTOM_BORDER_PADDING
521 border-before LEFT_BORDER
522 border-after RIGHT_BORDER
523 border-start TOP_BORDER
524 border-end BOTTOM_BORDER
526 border-line-width ALL_BORDER_LINE_WIDTH
527 border-line-width-before LEFT_BORDER_LINE_WIDTH
528 border-line-width-after RIGHT_BORDER_LINE_WIDTH
529 border-line-width-start TOP_BORDER_LINE_WIDTH
530 border-line-width-end BOTTOM_BORDER_LINE_WIDTH
533 const SvxBorderLine
* pLeft
= pBox
->GetLeft();
534 const SvxBorderLine
* pRight
= pBox
->GetRight();
535 const SvxBorderLine
* pTop
= pBox
->GetTop();
536 const SvxBorderLine
* pBottom
= pBox
->GetBottom();
537 sal_uInt16 nTopDist
= pBox
->GetDistance( BOX_LINE_TOP
);
538 sal_uInt16 nBottomDist
= pBox
->GetDistance( BOX_LINE_BOTTOM
);
539 sal_uInt16 nLeftDist
= pBox
->GetDistance( BOX_LINE_LEFT
);
540 sal_uInt16 nRightDist
= pBox
->GetDistance( BOX_LINE_RIGHT
);
543 // check if we need to export it
546 case ALL_BORDER_PADDING
:
547 case LEFT_BORDER_PADDING
:
548 case RIGHT_BORDER_PADDING
:
549 case TOP_BORDER_PADDING
:
550 case BOTTOM_BORDER_PADDING
:
552 sal_Bool bEqual
= nLeftDist
== nRightDist
&&
553 nLeftDist
== nTopDist
&&
554 nLeftDist
== nBottomDist
;
555 // don't export individual paddings if all paddings are equal and
556 // don't export all padding if some paddings are not equal
557 if( (bEqual
&& ALL_BORDER_PADDING
!= nMemberId
) ||
558 (!bEqual
&& ALL_BORDER_PADDING
== nMemberId
) )
568 sal_Bool bEqual
= ( NULL
== pTop
&& NULL
== pBottom
&&
569 NULL
== pLeft
&& NULL
== pRight
) ||
570 ( pTop
&& pBottom
&& pLeft
&& pRight
&&
571 *pTop
== *pBottom
&& *pTop
== *pLeft
&&
574 // don't export individual borders if all are the same and
575 // don't export all borders if some are not equal
576 if( (bEqual
&& ALL_BORDER
!= nMemberId
) ||
577 (!bEqual
&& ALL_BORDER
== nMemberId
) )
581 case ALL_BORDER_LINE_WIDTH
:
582 case LEFT_BORDER_LINE_WIDTH
:
583 case RIGHT_BORDER_LINE_WIDTH
:
584 case TOP_BORDER_LINE_WIDTH
:
585 case BOTTOM_BORDER_LINE_WIDTH
:
587 // if no line is set, there is nothing to export
588 if( !pTop
&& !pBottom
&& !pLeft
&& !pRight
)
591 sal_Bool bEqual
= NULL
!= pTop
&&
598 const sal_uInt16 nDistance
= pTop
->GetDistance();
599 const sal_uInt16 nInWidth
= pTop
->GetInWidth();
600 const sal_uInt16 nOutWidth
= pTop
->GetOutWidth();
602 bEqual
= nDistance
== pLeft
->GetDistance() &&
603 nInWidth
== pLeft
->GetInWidth() &&
604 nOutWidth
== pLeft
->GetOutWidth() &&
605 nDistance
== pRight
->GetDistance() &&
606 nInWidth
== pRight
->GetInWidth() &&
607 nOutWidth
== pRight
->GetOutWidth() &&
608 nDistance
== pBottom
->GetDistance() &&
609 nInWidth
== pBottom
->GetInWidth() &&
610 nOutWidth
== pBottom
->GetOutWidth();
615 case ALL_BORDER_LINE_WIDTH
:
616 if( !bEqual
|| pTop
->GetDistance() == 0 )
619 case LEFT_BORDER_LINE_WIDTH
:
620 if( bEqual
|| NULL
== pLeft
||
621 0 == pLeft
->GetDistance() )
624 case RIGHT_BORDER_LINE_WIDTH
:
625 if( bEqual
|| NULL
== pRight
||
626 0 == pRight
->GetDistance() )
629 case TOP_BORDER_LINE_WIDTH
:
630 if( bEqual
|| NULL
== pTop
||
631 0 == pTop
->GetDistance() )
634 case BOTTOM_BORDER_LINE_WIDTH
:
635 if( bEqual
|| NULL
== pBottom
||
636 0 == pBottom
->GetDistance() )
644 // now export it export
648 case ALL_BORDER_PADDING
:
649 case LEFT_BORDER_PADDING
:
650 rUnitConverter
.convertMeasure( aOut
, nLeftDist
);
652 case RIGHT_BORDER_PADDING
:
653 rUnitConverter
.convertMeasure( aOut
, nRightDist
);
655 case TOP_BORDER_PADDING
:
656 rUnitConverter
.convertMeasure( aOut
, nTopDist
);
658 case BOTTOM_BORDER_PADDING
:
659 rUnitConverter
.convertMeasure( aOut
, nBottomDist
);
669 const SvxBorderLine
* pLine
;
692 sal_Int32 nWidth
= pLine
->GetOutWidth();
693 const sal_uInt16 nDistance
= pLine
->GetDistance();
697 nWidth
+= pLine
->GetInWidth();
700 enum XMLTokenEnum eStyle
=
701 (0 == nDistance
) ? XML_SOLID
: XML_DOUBLE
;
703 rUnitConverter
.convertMeasure( aOut
, nWidth
);
704 aOut
.append( sal_Unicode( ' ' ) );
705 aOut
.append( GetXMLToken( eStyle
) );
706 aOut
.append( sal_Unicode( ' ' ) );
707 rUnitConverter
.convertColor( aOut
, pLine
->GetColor() );
712 aOut
.append( GetXMLToken(XML_NONE
) );
718 case ALL_BORDER_LINE_WIDTH
:
719 case LEFT_BORDER_LINE_WIDTH
:
720 case RIGHT_BORDER_LINE_WIDTH
:
721 case TOP_BORDER_LINE_WIDTH
:
722 case BOTTOM_BORDER_LINE_WIDTH
:
723 const SvxBorderLine
* pLine
;
726 case ALL_BORDER_LINE_WIDTH
:
727 case LEFT_BORDER_LINE_WIDTH
:
730 case RIGHT_BORDER_LINE_WIDTH
:
733 case TOP_BORDER_LINE_WIDTH
:
736 case BOTTOM_BORDER_LINE_WIDTH
:
742 rUnitConverter
.convertMeasure( aOut
, pLine
->GetInWidth() );
743 aOut
.append( sal_Unicode( ' ' ) );
744 rUnitConverter
.convertMeasure( aOut
, pLine
->GetDistance() );
745 aOut
.append( sal_Unicode( ' ' ) );
746 rUnitConverter
.convertMeasure( aOut
, pLine
->GetOutWidth() );
756 const SvxFmtBreakItem
* pFmtBreak
= PTR_CAST(SvxFmtBreakItem
, &rItem
);
757 DBG_ASSERT( pFmtBreak
!= NULL
, "Wrong Which-ID" );
759 sal_uInt16 eEnum
= 0;
763 case MID_BREAK_BEFORE
:
764 switch( pFmtBreak
->GetValue() )
766 case SVX_BREAK_COLUMN_BEFORE
:
769 case SVX_BREAK_PAGE_BEFORE
:
779 case MID_BREAK_AFTER
:
780 switch( pFmtBreak
->GetValue() )
782 case SVX_BREAK_COLUMN_AFTER
:
785 case SVX_BREAK_PAGE_AFTER
:
797 bOk
= rUnitConverter
.convertEnum( aOut
, eEnum
, psXML_BreakType
);
803 SvxFmtKeepItem
* pFmtKeep
= PTR_CAST(SvxFmtKeepItem
, &rItem
);
804 DBG_ASSERT( pFmtKeep
!= NULL
, "Wrong Which-ID" );
806 aOut
.append( pFmtKeep
->GetValue()
807 ? GetXMLToken( XML_ALWAYS
)
808 : GetXMLToken( XML_AUTO
) );
815 SvxBrushItem
* pBrush
= PTR_CAST(SvxBrushItem
, &rItem
);
816 DBG_ASSERT( pBrush
!= NULL
, "Wrong Which-ID" );
818 // note: the graphic is only exported if nMemberId equals
820 // If not, only the color or transparency is exported
825 if ( pBrush
->GetColor().GetTransparency() )
826 aOut
.append( GetXMLToken(XML_TRANSPARENT
) );
828 rUnitConverter
.convertColor( aOut
, pBrush
->GetColor());
832 case MID_GRAPHIC_LINK
:
833 if( pBrush
->GetGraphicPos() != GPOS_NONE
)
836 pBrush
->QueryValue( aAny
, MID_GRAPHIC_URL
);
844 case MID_GRAPHIC_POSITION
:
845 switch( pBrush
->GetGraphicPos() )
850 aOut
.append( GetXMLToken(XML_TOP
) );
856 aOut
.append( GetXMLToken(XML_CENTER
) );
862 aOut
.append( GetXMLToken(XML_BOTTOM
) );
871 aOut
.append( sal_Unicode( ' ' ) );
873 switch( pBrush
->GetGraphicPos() )
878 aOut
.append( GetXMLToken(XML_LEFT
) );
883 aOut
.append( GetXMLToken(XML_CENTER
) );
888 aOut
.append( GetXMLToken(XML_RIGHT
) );
896 case MID_GRAPHIC_REPEAT
:
898 SvxGraphicPosition eGraphicPos
= pBrush
->GetGraphicPos();
899 if( GPOS_AREA
== eGraphicPos
)
901 aOut
.append( GetXMLToken(XML_BACKGROUND_STRETCH
) );
904 else if( GPOS_NONE
!= eGraphicPos
&& GPOS_TILED
!= eGraphicPos
)
906 aOut
.append( GetXMLToken(XML_BACKGROUND_NO_REPEAT
) );
912 case MID_GRAPHIC_FILTER
:
913 if( pBrush
->GetGraphicPos() != GPOS_NONE
&&
914 pBrush
->GetGraphicFilter() )
916 aOut
.append( pBrush
->GetGraphicFilter()->GetBuffer() );
926 const SwFmtPageDesc
* pPageDesc
= PTR_CAST(SwFmtPageDesc
, &rItem
);
927 DBG_ASSERT( pPageDesc
!= NULL
, "Wrong Which-ID" );
929 if( MID_PAGEDESC_PAGENUMOFFSET
==nMemberId
)
932 rUnitConverter
.convertNumber(
933 aOut
, (sal_Int32
)pPageDesc
->GetNumOffset() );
939 case RES_LAYOUT_SPLIT
:
942 const SfxBoolItem
* pSplit
= PTR_CAST(SfxBoolItem
, &rItem
);
943 DBG_ASSERT( pSplit
!= NULL
, "Wrong Which-ID" );
945 rUnitConverter
.convertBool( aOut
, pSplit
->GetValue() );
950 case RES_HORI_ORIENT
:
952 SwFmtHoriOrient
* pHoriOrient
= PTR_CAST(SwFmtHoriOrient
, &rItem
);
953 DBG_ASSERT( pHoriOrient
!= NULL
, "Wrong Which-ID" );
955 rUnitConverter
.convertEnum( aOut
, pHoriOrient
->GetHoriOrient(),
961 case RES_VERT_ORIENT
:
963 SwFmtVertOrient
* pVertOrient
= PTR_CAST(SwFmtVertOrient
, &rItem
);
964 DBG_ASSERT( pVertOrient
!= NULL
, "Wrong Which-ID" );
966 rUnitConverter
.convertEnum( aOut
, pVertOrient
->GetVertOrient(),
967 aXMLTableVAlignMap
);
974 SwFmtFrmSize
* pFrmSize
= PTR_CAST(SwFmtFrmSize
, &rItem
);
975 DBG_ASSERT( pFrmSize
!= NULL
, "Wrong Which-ID" );
977 sal_Bool bOutHeight
= sal_False
;
980 case MID_FRMSIZE_REL_WIDTH
:
981 if( pFrmSize
->GetWidthPercent() )
983 rUnitConverter
.convertPercent( aOut
, pFrmSize
->GetWidthPercent() );
987 case MID_FRMSIZE_MIN_HEIGHT
:
988 if( ATT_MIN_SIZE
== pFrmSize
->GetHeightSizeType() )
989 bOutHeight
= sal_True
;
991 case MID_FRMSIZE_FIX_HEIGHT
:
992 if( ATT_FIX_SIZE
== pFrmSize
->GetHeightSizeType() )
993 bOutHeight
= sal_True
;
999 rUnitConverter
.convertMeasure( aOut
, pFrmSize
->GetHeight() );
1008 bOk
= rItem
.QueryValue( aAny
);
1011 const XMLPropertyHandler
* pWritingModeHandler
=
1012 XMLPropertyHandlerFactory::CreatePropertyHandler(
1013 XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
);
1015 bOk
= pWritingModeHandler
->exportXML( sValue
, aAny
,
1018 aOut
.append( sValue
);
1023 case RES_COLLAPSING_BORDERS
:
1025 const SfxBoolItem
* pBorders
= PTR_CAST(SfxBoolItem
, &rItem
);
1026 DBG_ASSERT( pBorders
!= NULL
, "Wrong RES-ID" );
1028 aOut
.append( pBorders
->GetValue()
1029 ? GetXMLToken( XML_COLLAPSING
)
1030 : GetXMLToken( XML_SEPARATING
) );
1036 DBG_ERROR("GetXMLValue not implemented for this item.");
1041 rValue
= aOut
.makeStringAndClear();