update dev300-m58
[ooovba.git] / sw / source / filter / xml / xmlexpit.cxx
blob2135be52ea00ab931345f11a23eb8e8853fd481b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlexpit.cxx,v $
10 * $Revision: 1.25 $
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>
49 #endif
52 #include "hintids.hxx"
53 #include "unomid.h"
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"
66 #ifndef _FMTLSPLT_HXX
67 #include "fmtlsplt.hxx"
68 #endif
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;
78 using uno::Any;
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,
86 sal_uInt16 nFlags,
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,
100 nFlags );
101 // do we have an item?
102 if(pItem)
104 if( 0 != (pEntry->nMemberId & MID_SW_FLAG_ELEMENT_ITEM_EXPORT) )
106 // element items do not add any properties,
107 // we export it later
108 if( pIndexArray )
109 pIndexArray->Insert( nIndex, pIndexArray->Count() );
112 else
114 exportXML( rExport, rAttrList, *pItem, *pEntry, rUnitConverter,
115 rNamespaceMap, nFlags, &rSet );
119 else
121 handleNoItem( rAttrList, *pEntry, rUnitConverter, rNamespaceMap,
122 rSet );
124 nIndex++;
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 ) )
141 OUString aValue;
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 ),
148 rUnitConverter ) )
150 bAddAttribute = false;
153 else
155 OUStringBuffer aOut;
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();
162 if( bAddAttribute )
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 )
194 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(),
204 sNamespace );
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;
218 else
220 handleSpecialItem( rAttrList, rEntry, rItem, rUnitConverter,
221 rNamespaceMap, pSet );
224 else if( 0 == (rEntry.nMemberId & MID_SW_FLAG_ELEMENT_ITEM_EXPORT) )
226 OUString aValue;
227 if( QueryXMLValue(rItem, aValue,
228 static_cast< sal_uInt16 >(
229 rEntry.nMemberId & MID_SW_FLAG_MASK ),
230 rUnitConverter ) )
232 OUString sName(
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,
244 sal_uInt16 nFlags,
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),
255 "wrong mid flag!" );
257 const SfxPoolItem* pItem = GetItem( rSet, pEntry->nWhichId, nFlags );
258 // do we have an item?
259 if(pItem)
261 rExport.IgnorableWhitespace();
262 handleElementItem( rExport, *pEntry, *pItem, rUnitConverter,
263 rSet, nFlags);
264 bItemsExported = sal_True;
268 if( bItemsExported )
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
274 is set in the flags
276 const SfxPoolItem* SvXMLExportItemMapper::GetItem( const SfxItemSet& rSet,
277 sal_uInt16 nWhichId,
278 sal_uInt16 nFlags )
280 // first get item from itemset
281 const SfxPoolItem* pItem;
282 SfxItemState eState =
283 rSet.GetItemState( nWhichId,
284 ( nFlags & XML_EXPORT_FLAG_DEEP ) != 0,
285 &pItem );
287 if( SFX_ITEM_SET == eState )
289 return pItem;
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);
297 else
299 return NULL;
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,
378 OUString& rValue,
379 sal_uInt16 nMemberId,
380 const SvXMLUnitConverter& rUnitConverter )
382 sal_Bool bOk = sal_False;
383 OUStringBuffer aOut;
385 switch ( rItem.Which() )
388 case RES_LR_SPACE:
390 const SvxLRSpaceItem* pLRSpace = PTR_CAST(SvxLRSpaceItem, &rItem);
391 DBG_ASSERT( pLRSpace != NULL, "Wrong Which-ID!" );
393 bOk = sal_True;
394 switch( nMemberId )
396 case MID_L_MARGIN:
397 if(pLRSpace->GetPropLeft() != 100)
398 rUnitConverter.convertPercent( aOut, pLRSpace->GetPropLeft() );
399 else
400 rUnitConverter.convertMeasure( aOut, pLRSpace->GetLeft() );
401 break;
403 case MID_R_MARGIN:
404 if(pLRSpace->GetPropRight() != 100)
405 rUnitConverter.convertPercent( aOut, pLRSpace->GetPropRight() );
406 else
407 rUnitConverter.convertMeasure( aOut, pLRSpace->GetRight() );
408 break;
410 case MID_FIRST_AUTO:
411 if( pLRSpace->IsAutoFirst() )
412 rUnitConverter.convertBool( aOut, pLRSpace->IsAutoFirst() );
413 else
414 bOk = sal_False;
415 break;
417 case MID_FIRST_LINE_INDENT:
418 if( !pLRSpace->IsAutoFirst() )
420 if(pLRSpace->GetPropTxtFirstLineOfst() != 100)
421 rUnitConverter.convertPercent(
422 aOut, pLRSpace->GetPropTxtFirstLineOfst() );
423 else
424 rUnitConverter.convertMeasure( aOut, pLRSpace->GetTxtFirstLineOfst() );
426 else
427 bOk = sal_False;
428 break;
430 default:
431 DBG_ERROR( "unknown member id!");
432 bOk = sal_False;
433 break;
436 break;
438 case RES_UL_SPACE:
440 const SvxULSpaceItem* pULSpace = PTR_CAST(SvxULSpaceItem, &rItem);
441 DBG_ASSERT( pULSpace != NULL, "Wrong Which-ID!" );
443 switch( nMemberId )
445 case MID_UP_MARGIN:
446 if( pULSpace->GetPropUpper() != 100 )
447 rUnitConverter.convertPercent( aOut, pULSpace->GetPropUpper() );
448 else
449 rUnitConverter.convertMeasure( aOut, pULSpace->GetUpper() );
450 break;
452 case MID_LO_MARGIN:
453 if( pULSpace->GetPropLower() != 100 )
454 rUnitConverter.convertPercent( aOut, pULSpace->GetPropLower() );
455 else
456 rUnitConverter.convertMeasure( aOut, pULSpace->GetLower() );
457 break;
459 default:
460 DBG_ERROR("unknown MemberId");
463 bOk = sal_True;
465 break;
467 case RES_SHADOW:
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:
476 nX = -1;
477 nY = -1;
478 break;
479 case SVX_SHADOW_TOPRIGHT:
480 nY = -1;
481 break;
482 case SVX_SHADOW_BOTTOMLEFT:
483 nX = -1;
484 break;
485 case SVX_SHADOW_BOTTOMRIGHT:
486 break;
487 case SVX_SHADOW_NONE:
488 default:
489 rValue = GetXMLToken(XML_NONE);
490 return sal_True;
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 );
502 bOk = sal_True;
504 break;
506 case RES_BOX:
508 SvxBoxItem* pBox = PTR_CAST(SvxBoxItem, &rItem);
509 DBG_ASSERT( pBox != NULL, "Wrong WHich-ID" );
512 xml -> MemberId
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
520 border ALL_BORDER
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
544 switch( nMemberId )
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) )
559 return sal_False;
561 break;
562 case ALL_BORDER:
563 case LEFT_BORDER:
564 case RIGHT_BORDER:
565 case TOP_BORDER:
566 case BOTTOM_BORDER:
568 sal_Bool bEqual = ( NULL == pTop && NULL == pBottom &&
569 NULL == pLeft && NULL == pRight ) ||
570 ( pTop && pBottom && pLeft && pRight &&
571 *pTop == *pBottom && *pTop == *pLeft &&
572 *pTop == *pRight );
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) )
578 return sal_False;
580 break;
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 )
589 return sal_False;
591 sal_Bool bEqual = NULL != pTop &&
592 NULL != pBottom &&
593 NULL != pLeft &&
594 NULL != pRight;
596 if( bEqual )
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();
613 switch( nMemberId )
615 case ALL_BORDER_LINE_WIDTH:
616 if( !bEqual || pTop->GetDistance() == 0 )
617 return sal_False;
618 break;
619 case LEFT_BORDER_LINE_WIDTH:
620 if( bEqual || NULL == pLeft ||
621 0 == pLeft->GetDistance() )
622 return sal_False;
623 break;
624 case RIGHT_BORDER_LINE_WIDTH:
625 if( bEqual || NULL == pRight ||
626 0 == pRight->GetDistance() )
627 return sal_False;
628 break;
629 case TOP_BORDER_LINE_WIDTH:
630 if( bEqual || NULL == pTop ||
631 0 == pTop->GetDistance() )
632 return sal_False;
633 break;
634 case BOTTOM_BORDER_LINE_WIDTH:
635 if( bEqual || NULL == pBottom ||
636 0 == pBottom->GetDistance() )
637 return sal_False;
638 break;
641 break;
644 // now export it export
645 switch( nMemberId )
647 // padding
648 case ALL_BORDER_PADDING:
649 case LEFT_BORDER_PADDING:
650 rUnitConverter.convertMeasure( aOut, nLeftDist );
651 break;
652 case RIGHT_BORDER_PADDING:
653 rUnitConverter.convertMeasure( aOut, nRightDist );
654 break;
655 case TOP_BORDER_PADDING:
656 rUnitConverter.convertMeasure( aOut, nTopDist );
657 break;
658 case BOTTOM_BORDER_PADDING:
659 rUnitConverter.convertMeasure( aOut, nBottomDist );
660 break;
662 // border
663 case ALL_BORDER:
664 case LEFT_BORDER:
665 case RIGHT_BORDER:
666 case TOP_BORDER:
667 case BOTTOM_BORDER:
669 const SvxBorderLine* pLine;
670 switch( nMemberId )
672 case ALL_BORDER:
673 case LEFT_BORDER:
674 pLine = pLeft;
675 break;
676 case RIGHT_BORDER:
677 pLine = pRight;
678 break;
679 case TOP_BORDER:
680 pLine = pTop;
681 break;
682 case BOTTOM_BORDER:
683 pLine = pBottom;
684 break;
685 default:
686 pLine = NULL;
687 break;
690 if( NULL != pLine )
692 sal_Int32 nWidth = pLine->GetOutWidth();
693 const sal_uInt16 nDistance = pLine->GetDistance();
694 if( 0 != nDistance )
696 nWidth += nDistance;
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() );
710 else
712 aOut.append( GetXMLToken(XML_NONE) );
715 break;
717 // width
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;
724 switch( nMemberId )
726 case ALL_BORDER_LINE_WIDTH:
727 case LEFT_BORDER_LINE_WIDTH:
728 pLine = pLeft;
729 break;
730 case RIGHT_BORDER_LINE_WIDTH:
731 pLine = pRight;
732 break;
733 case TOP_BORDER_LINE_WIDTH:
734 pLine = pTop;
735 break;
736 case BOTTOM_BORDER_LINE_WIDTH:
737 pLine = pBottom;
738 break;
739 default:
740 return sal_False;
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() );
747 break;
750 bOk = sal_True;
752 break;
754 case RES_BREAK:
756 const SvxFmtBreakItem* pFmtBreak = PTR_CAST(SvxFmtBreakItem, &rItem);
757 DBG_ASSERT( pFmtBreak != NULL, "Wrong Which-ID" );
759 sal_uInt16 eEnum = 0;
761 switch( nMemberId )
763 case MID_BREAK_BEFORE:
764 switch( pFmtBreak->GetValue() )
766 case SVX_BREAK_COLUMN_BEFORE:
767 eEnum = 1;
768 break;
769 case SVX_BREAK_PAGE_BEFORE:
770 eEnum = 2;
771 break;
772 case SVX_BREAK_NONE:
773 eEnum = 0;
774 break;
775 default:
776 return sal_False;
778 break;
779 case MID_BREAK_AFTER:
780 switch( pFmtBreak->GetValue() )
782 case SVX_BREAK_COLUMN_AFTER:
783 eEnum = 1;
784 break;
785 case SVX_BREAK_PAGE_AFTER:
786 eEnum = 2;
787 break;
788 case SVX_BREAK_NONE:
789 eEnum = 0;
790 break;
791 default:
792 return sal_False;
794 break;
797 bOk = rUnitConverter.convertEnum( aOut, eEnum, psXML_BreakType );
799 break;
801 case RES_KEEP:
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 ) );
809 bOk = sal_True;
811 break;
813 case RES_BACKGROUND:
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
819 // MID_GRAPHIC..
820 // If not, only the color or transparency is exported
822 switch( nMemberId )
824 case MID_BACK_COLOR:
825 if ( pBrush->GetColor().GetTransparency() )
826 aOut.append( GetXMLToken(XML_TRANSPARENT) );
827 else
828 rUnitConverter.convertColor( aOut, pBrush->GetColor());
829 bOk = sal_True;
830 break;
832 case MID_GRAPHIC_LINK:
833 if( pBrush->GetGraphicPos() != GPOS_NONE )
835 uno::Any aAny;
836 pBrush->QueryValue( aAny, MID_GRAPHIC_URL );
837 OUString sTmp;
838 aAny >>= sTmp;
839 aOut.append( sTmp );
840 bOk = sal_True;
842 break;
844 case MID_GRAPHIC_POSITION:
845 switch( pBrush->GetGraphicPos() )
847 case GPOS_LT:
848 case GPOS_MT:
849 case GPOS_RT:
850 aOut.append( GetXMLToken(XML_TOP) );
851 bOk = sal_True;
852 break;
853 case GPOS_LM:
854 case GPOS_MM:
855 case GPOS_RM:
856 aOut.append( GetXMLToken(XML_CENTER) );
857 bOk = sal_True;
858 break;
859 case GPOS_LB:
860 case GPOS_MB:
861 case GPOS_RB:
862 aOut.append( GetXMLToken(XML_BOTTOM) );
863 bOk = sal_True;
864 break;
865 default:
869 if( bOk )
871 aOut.append( sal_Unicode( ' ' ) );
873 switch( pBrush->GetGraphicPos() )
875 case GPOS_LT:
876 case GPOS_LB:
877 case GPOS_LM:
878 aOut.append( GetXMLToken(XML_LEFT) );
879 break;
880 case GPOS_MT:
881 case GPOS_MM:
882 case GPOS_MB:
883 aOut.append( GetXMLToken(XML_CENTER) );
884 break;
885 case GPOS_RM:
886 case GPOS_RT:
887 case GPOS_RB:
888 aOut.append( GetXMLToken(XML_RIGHT) );
889 break;
890 default:
894 break;
896 case MID_GRAPHIC_REPEAT:
898 SvxGraphicPosition eGraphicPos = pBrush->GetGraphicPos();
899 if( GPOS_AREA == eGraphicPos )
901 aOut.append( GetXMLToken(XML_BACKGROUND_STRETCH) );
902 bOk = sal_True;
904 else if( GPOS_NONE != eGraphicPos && GPOS_TILED != eGraphicPos )
906 aOut.append( GetXMLToken(XML_BACKGROUND_NO_REPEAT) );
907 bOk = sal_True;
910 break;
912 case MID_GRAPHIC_FILTER:
913 if( pBrush->GetGraphicPos() != GPOS_NONE &&
914 pBrush->GetGraphicFilter() )
916 aOut.append( pBrush->GetGraphicFilter()->GetBuffer() );
917 bOk = sal_True;
919 break;
922 break;
924 case RES_PAGEDESC:
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() );
934 bOk = sal_True;
937 break;
939 case RES_LAYOUT_SPLIT:
940 case RES_ROW_SPLIT:
942 const SfxBoolItem* pSplit = PTR_CAST(SfxBoolItem, &rItem);
943 DBG_ASSERT( pSplit != NULL, "Wrong Which-ID" );
945 rUnitConverter.convertBool( aOut, pSplit->GetValue() );
946 bOk = sal_True;
948 break;
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(),
956 aXMLTableAlignMap );
957 bOk = sal_True;
959 break;
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 );
968 bOk = sal_True;
970 break;
972 case RES_FRM_SIZE:
974 SwFmtFrmSize* pFrmSize = PTR_CAST(SwFmtFrmSize, &rItem);
975 DBG_ASSERT( pFrmSize != NULL, "Wrong Which-ID" );
977 sal_Bool bOutHeight = sal_False;
978 switch( nMemberId )
980 case MID_FRMSIZE_REL_WIDTH:
981 if( pFrmSize->GetWidthPercent() )
983 rUnitConverter.convertPercent( aOut, pFrmSize->GetWidthPercent() );
984 bOk = sal_True;
986 break;
987 case MID_FRMSIZE_MIN_HEIGHT:
988 if( ATT_MIN_SIZE == pFrmSize->GetHeightSizeType() )
989 bOutHeight = sal_True;
990 break;
991 case MID_FRMSIZE_FIX_HEIGHT:
992 if( ATT_FIX_SIZE == pFrmSize->GetHeightSizeType() )
993 bOutHeight = sal_True;
994 break;
997 if( bOutHeight )
999 rUnitConverter.convertMeasure( aOut, pFrmSize->GetHeight() );
1000 bOk = sal_True;
1003 break;
1005 case RES_FRAMEDIR:
1007 Any aAny;
1008 bOk = rItem.QueryValue( aAny );
1009 if( bOk )
1011 const XMLPropertyHandler* pWritingModeHandler =
1012 XMLPropertyHandlerFactory::CreatePropertyHandler(
1013 XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT );
1014 OUString sValue;
1015 bOk = pWritingModeHandler->exportXML( sValue, aAny,
1016 rUnitConverter );
1017 if( bOk )
1018 aOut.append( sValue );
1021 break;
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 ) );
1031 bOk = sal_True;
1033 break;
1035 default:
1036 DBG_ERROR("GetXMLValue not implemented for this item.");
1037 break;
1040 if ( bOk )
1041 rValue = aOut.makeStringAndClear();
1043 return bOk;