1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "xmlimpit.hxx"
23 #include <sax/tools/converter.hxx>
24 #include <xmloff/xmluconv.hxx>
25 #include <svl/itempool.hxx>
26 #include <svl/poolitem.hxx>
27 #include <svl/itemset.hxx>
28 #include <xmloff/attrlist.hxx>
29 #include <xmloff/nmspmap.hxx>
30 #include <xmloff/xmlnmspe.hxx>
31 #include <editeng/xmlcnitm.hxx>
32 #include <editeng/memberids.hrc>
35 #include "hintids.hxx"
37 #include <svx/unomid.hxx>
38 #include <editeng/lrspitem.hxx>
39 #include <editeng/ulspitem.hxx>
40 #include <editeng/shaditem.hxx>
41 #include <editeng/boxitem.hxx>
42 #include <editeng/formatbreakitem.hxx>
43 #include <editeng/keepitem.hxx>
44 #include <editeng/brushitem.hxx>
45 #include "fmtpdsc.hxx"
46 #include "fmtornt.hxx"
47 #include "fmtfsize.hxx"
49 #include "fmtlsplt.hxx"
50 #include <xmloff/prhdlfac.hxx>
51 #include <xmloff/xmltypes.hxx>
52 #include "xmlithlp.hxx"
53 #include <com/sun/star/uno/Any.hxx>
55 using ::editeng::SvxBorderLine
;
56 using namespace ::com::sun::star
;
57 using namespace ::xmloff::token
;
60 SvXMLImportItemMapper::SvXMLImportItemMapper(
61 SvXMLItemMapEntriesRef rMapEntries
,
62 sal_uInt16 nUnknWhich
) :
63 mrMapEntries( rMapEntries
),
64 nUnknownWhich( nUnknWhich
)
68 SvXMLImportItemMapper::~SvXMLImportItemMapper()
73 SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries
)
75 mrMapEntries
= rMapEntries
;
78 /** fills the given itemset with the attributes in the given list */
79 void SvXMLImportItemMapper::importXML( SfxItemSet
& rSet
,
80 uno::Reference
< xml::sax::XAttributeList
> xAttrList
,
81 const SvXMLUnitConverter
& rUnitConverter
,
82 const SvXMLNamespaceMap
& rNamespaceMap
)
84 sal_Int16 nAttr
= xAttrList
->getLength();
86 SvXMLAttrContainerItem
*pUnknownItem
= 0;
87 for( sal_Int16 i
=0; i
< nAttr
; i
++ )
89 const OUString
& rAttrName
= xAttrList
->getNameByIndex( i
);
90 OUString aLocalName
, aPrefix
, aNamespace
;
92 rNamespaceMap
.GetKeyByAttrName( rAttrName
, &aPrefix
, &aLocalName
,
94 if( XML_NAMESPACE_XMLNS
== nPrefix
)
97 const OUString
& rValue
= xAttrList
->getValueByIndex( i
);
99 // find a map entry for this attribute
100 SvXMLItemMapEntry
* pEntry
= mrMapEntries
->getByName( nPrefix
, aLocalName
);
104 // we have a valid map entry here, so lets use it...
105 if( 0 == (pEntry
->nMemberId
& (MID_SW_FLAG_NO_ITEM_IMPORT
|
106 MID_SW_FLAG_ELEMENT_ITEM_IMPORT
)) )
108 // first get item from itemset
109 const SfxPoolItem
* pItem
= 0;
110 SfxItemState eState
= rSet
.GetItemState( pEntry
->nWhichId
, sal_True
,
113 // if its not set, try the pool
114 if(SFX_ITEM_SET
!= eState
&& SFX_WHICH_MAX
> pEntry
->nWhichId
)
115 pItem
= &rSet
.GetPool()->GetDefaultItem(pEntry
->nWhichId
);
117 // do we have an item?
118 if(eState
>= SFX_ITEM_DEFAULT
&& pItem
)
120 SfxPoolItem
*pNewItem
= pItem
->Clone();
123 if( 0 == (pEntry
->nMemberId
&MID_SW_FLAG_SPECIAL_ITEM_IMPORT
) )
125 bPut
= PutXMLValue( *pNewItem
, rValue
,
126 static_cast<sal_uInt16
>( pEntry
->nMemberId
& MID_SW_FLAG_MASK
),
132 bPut
= handleSpecialItem( *pEntry
, *pNewItem
, rSet
,
133 rValue
, rUnitConverter
,
138 rSet
.Put( *pNewItem
);
144 OSL_FAIL( "Could not get a needed item for xml import!" );
147 else if( 0 != (pEntry
->nMemberId
& MID_SW_FLAG_NO_ITEM_IMPORT
) )
149 handleNoItem( *pEntry
, rSet
, rValue
, rUnitConverter
,
153 else if( USHRT_MAX
!= nUnknownWhich
)
157 const SfxPoolItem
* pItem
= 0;
158 if( SFX_ITEM_SET
== rSet
.GetItemState( nUnknownWhich
, sal_True
,
161 SfxPoolItem
*pNew
= pItem
->Clone();
162 pUnknownItem
= PTR_CAST( SvXMLAttrContainerItem
, pNew
);
163 OSL_ENSURE( pUnknownItem
,
164 "SvXMLAttrContainerItem expected" );
170 pUnknownItem
= new SvXMLAttrContainerItem( nUnknownWhich
);
175 if( XML_NAMESPACE_NONE
== nPrefix
)
176 pUnknownItem
->AddAttr( aLocalName
, rValue
);
178 pUnknownItem
->AddAttr( aPrefix
, aNamespace
, aLocalName
,
186 rSet
.Put( *pUnknownItem
);
190 finished(rSet
, rUnitConverter
);
193 /** this method is called for every item that has the
194 MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set */
196 SvXMLImportItemMapper::handleSpecialItem( const SvXMLItemMapEntry
& /*rEntry*/,
197 SfxPoolItem
& /*rItem*/,
198 SfxItemSet
& /*rSet*/,
199 const OUString
& /*rValue*/,
200 const SvXMLUnitConverter
& /*rUnitConverter*/,
201 const SvXMLNamespaceMap
& /*rNamespaceMap*/ )
203 OSL_FAIL( "unsuported special item in xml import" );
207 /** this method is called for every item that has the
208 MID_SW_FLAG_NO_ITEM_IMPORT flag set */
209 bool SvXMLImportItemMapper::handleNoItem( const SvXMLItemMapEntry
& /*rEntry*/,
210 SfxItemSet
& /*rSet*/,
211 const OUString
& /*rValue*/,
212 const SvXMLUnitConverter
& /*rUnitConverter*/,
213 const SvXMLNamespaceMap
& /*rNamespaceMap*/ )
215 OSL_FAIL( "unsuported no item in xml import" );
220 SvXMLImportItemMapper::finished(SfxItemSet
&, SvXMLUnitConverter
const&) const
222 // nothing to do here
227 // put an XML-string value into an item
228 bool SvXMLImportItemMapper::PutXMLValue(
230 const OUString
& rValue
,
231 sal_uInt16 nMemberId
,
232 const SvXMLUnitConverter
& rUnitConverter
)
236 switch (rItem
.Which())
240 SvxLRSpaceItem
* pLRSpace
= PTR_CAST(SvxLRSpaceItem
, &rItem
);
241 OSL_ENSURE( pLRSpace
!= NULL
, "Wrong Which-ID!" );
248 sal_Int32 nProp
= 100;
251 if( rValue
.indexOf( sal_Unicode('%') ) != -1 )
252 bOk
= ::sax::Converter::convertPercent(nProp
, rValue
);
254 bOk
= rUnitConverter
.convertMeasureToCore(nAbs
, rValue
);
261 pLRSpace
->SetTxtLeft( (sal_Int32
)nAbs
, (sal_uInt16
)nProp
);
264 pLRSpace
->SetRight( (sal_Int32
)nAbs
, (sal_uInt16
)nProp
);
270 case MID_FIRST_LINE_INDENT
:
272 sal_Int32 nProp
= 100;
275 if( rValue
.indexOf( sal_Unicode('%') ) != -1 )
276 bOk
= ::sax::Converter::convertPercent(nProp
, rValue
);
278 bOk
= rUnitConverter
.convertMeasureToCore(nAbs
, rValue
,
281 pLRSpace
->SetTxtFirstLineOfst( (short)nAbs
, (sal_uInt16
)nProp
);
286 bool bAutoFirst(false);
287 bOk
= ::sax::Converter::convertBool( bAutoFirst
, rValue
);
289 pLRSpace
->SetAutoFirst( bAutoFirst
);
294 OSL_FAIL( "unknown member id!");
301 SvxULSpaceItem
* pULSpace
= PTR_CAST(SvxULSpaceItem
, &rItem
);
302 OSL_ENSURE( pULSpace
!= NULL
, "Wrong Which-ID!" );
304 sal_Int32 nProp
= 100;
307 if( rValue
.indexOf( sal_Unicode('%') ) != -1 )
308 bOk
= ::sax::Converter::convertPercent( nProp
, rValue
);
310 bOk
= rUnitConverter
.convertMeasureToCore( nAbs
, rValue
);
315 pULSpace
->SetUpper( (sal_uInt16
)nAbs
, (sal_uInt16
)nProp
);
318 pULSpace
->SetLower( (sal_uInt16
)nAbs
, (sal_uInt16
)nProp
);
321 OSL_FAIL("unknown MemberId");
328 SvxShadowItem
* pShadow
= PTR_CAST(SvxShadowItem
, &rItem
);
329 OSL_ENSURE( pShadow
!= NULL
, "Wrong Which-ID" );
331 bool bColorFound
= false;
332 bool bOffsetFound
= false;
334 SvXMLTokenEnumerator
aTokenEnum( rValue
);
336 Color
aColor( 128,128, 128 );
337 pShadow
->SetLocation( SVX_SHADOW_BOTTOMRIGHT
);
340 while( aTokenEnum
.getNextToken( aToken
) )
342 if( IsXMLToken( aToken
, XML_NONE
) )
344 pShadow
->SetLocation( SVX_SHADOW_NONE
);
347 else if( !bColorFound
&& aToken
.startsWith("#") )
350 bOk
= ::sax::Converter::convertColor( nColor
, aToken
);
354 aColor
.SetColor(nColor
);
357 else if( !bOffsetFound
)
359 sal_Int32 nX
= 0, nY
= 0;
361 bOk
= rUnitConverter
.convertMeasureToCore( nX
, aToken
);
362 if( bOk
&& aTokenEnum
.getNextToken( aToken
) )
363 bOk
= rUnitConverter
.convertMeasureToCore( nY
, aToken
);
371 pShadow
->SetLocation( SVX_SHADOW_TOPLEFT
);
375 pShadow
->SetLocation( SVX_SHADOW_BOTTOMLEFT
);
382 pShadow
->SetLocation( SVX_SHADOW_TOPRIGHT
);
386 pShadow
->SetLocation( SVX_SHADOW_BOTTOMRIGHT
);
390 if( nX
< 0 ) nX
*= -1;
391 if( nY
< 0 ) nY
*= -1;
393 pShadow
->SetWidth( static_cast< sal_uInt16
>( (nX
+ nY
) >> 1 ) );
398 if( bOk
&& ( bColorFound
|| bOffsetFound
) )
400 pShadow
->SetColor( aColor
);
409 SvxBoxItem
* pBox
= PTR_CAST(SvxBoxItem
, &rItem
);
410 OSL_ENSURE( pBox
!= NULL
, "Wrong WHich-ID" );
412 /** copy SvxBorderLines */
413 SvxBorderLine
* pTop
= pBox
->GetTop() == NULL
?
414 NULL
: new SvxBorderLine( *pBox
->GetTop() );
415 SvxBorderLine
* pBottom
= pBox
->GetBottom() == NULL
?
416 NULL
: new SvxBorderLine( *pBox
->GetBottom() );
417 SvxBorderLine
* pLeft
= pBox
->GetLeft() == NULL
?
418 NULL
: new SvxBorderLine( *pBox
->GetLeft() );
419 SvxBorderLine
* pRight
= pBox
->GetRight() == NULL
?
420 NULL
: new SvxBorderLine( *pBox
->GetRight() );
426 case ALL_BORDER_PADDING
:
427 case LEFT_BORDER_PADDING
:
428 case RIGHT_BORDER_PADDING
:
429 case TOP_BORDER_PADDING
:
430 case BOTTOM_BORDER_PADDING
:
431 if (!rUnitConverter
.convertMeasureToCore( nTemp
, rValue
,
437 if( nMemberId
== LEFT_BORDER_PADDING
||
438 nMemberId
== ALL_BORDER_PADDING
)
439 pBox
->SetDistance( (sal_uInt16
)nTemp
, BOX_LINE_LEFT
);
440 if( nMemberId
== RIGHT_BORDER_PADDING
||
441 nMemberId
== ALL_BORDER_PADDING
)
442 pBox
->SetDistance( (sal_uInt16
)nTemp
, BOX_LINE_RIGHT
);
443 if( nMemberId
== TOP_BORDER_PADDING
||
444 nMemberId
== ALL_BORDER_PADDING
)
445 pBox
->SetDistance( (sal_uInt16
)nTemp
, BOX_LINE_TOP
);
446 if( nMemberId
== BOTTOM_BORDER_PADDING
||
447 nMemberId
== ALL_BORDER_PADDING
)
448 pBox
->SetDistance( (sal_uInt16
)nTemp
, BOX_LINE_BOTTOM
);
457 bool bHasStyle
= false;
458 bool bHasWidth
= false;
459 bool bHasColor
= false;
461 sal_uInt16 nStyle
= USHRT_MAX
;
462 sal_uInt16 nWidth
= 0;
463 sal_uInt16 nNamedWidth
= USHRT_MAX
;
465 Color
aColor( COL_BLACK
);
467 if( !sw_frmitems_parseXMLBorder( rValue
, rUnitConverter
,
469 bHasWidth
, nWidth
, nNamedWidth
,
470 bHasColor
, aColor
) )
473 if( TOP_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
474 sw_frmitems_setXMLBorder( pTop
,
476 bHasWidth
, nWidth
, nNamedWidth
,
479 if( BOTTOM_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
480 sw_frmitems_setXMLBorder( pBottom
,
482 bHasWidth
, nWidth
, nNamedWidth
,
485 if( LEFT_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
486 sw_frmitems_setXMLBorder( pLeft
,
488 bHasWidth
, nWidth
, nNamedWidth
,
491 if( RIGHT_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
492 sw_frmitems_setXMLBorder( pRight
,
494 bHasWidth
, nWidth
, nNamedWidth
,
498 case ALL_BORDER_LINE_WIDTH
:
499 case LEFT_BORDER_LINE_WIDTH
:
500 case RIGHT_BORDER_LINE_WIDTH
:
501 case TOP_BORDER_LINE_WIDTH
:
502 case BOTTOM_BORDER_LINE_WIDTH
:
504 SvXMLTokenEnumerator
aTokenEnum( rValue
);
506 sal_Int32 nInWidth
, nDistance
, nOutWidth
;
509 if( !aTokenEnum
.getNextToken( aToken
) )
512 if (!rUnitConverter
.convertMeasureToCore(nInWidth
, aToken
))
515 if( !aTokenEnum
.getNextToken( aToken
) )
518 if (!rUnitConverter
.convertMeasureToCore(nDistance
, aToken
))
521 if( !aTokenEnum
.getNextToken( aToken
) )
524 if (!rUnitConverter
.convertMeasureToCore(nOutWidth
, aToken
))
527 // #i61946: accept line style even it's not part of our "normal" set of line styles
528 sal_uInt16 nWidth
= 0;
530 if( TOP_BORDER_LINE_WIDTH
== nMemberId
||
531 ALL_BORDER_LINE_WIDTH
== nMemberId
)
532 sw_frmitems_setXMLBorder( pTop
, nWidth
,
533 static_cast< sal_uInt16
>( nOutWidth
),
534 static_cast< sal_uInt16
>( nInWidth
),
535 static_cast< sal_uInt16
>( nDistance
) );
537 if( BOTTOM_BORDER_LINE_WIDTH
== nMemberId
||
538 ALL_BORDER_LINE_WIDTH
== nMemberId
)
539 sw_frmitems_setXMLBorder( pBottom
, nWidth
,
540 static_cast< sal_uInt16
>( nOutWidth
),
541 static_cast< sal_uInt16
>( nInWidth
),
542 static_cast< sal_uInt16
>( nDistance
) );
544 if( LEFT_BORDER_LINE_WIDTH
== nMemberId
||
545 ALL_BORDER_LINE_WIDTH
== nMemberId
)
546 sw_frmitems_setXMLBorder( pLeft
, nWidth
,
547 static_cast< sal_uInt16
>( nOutWidth
),
548 static_cast< sal_uInt16
>( nInWidth
),
549 static_cast< sal_uInt16
>( nDistance
) );
551 if( RIGHT_BORDER_LINE_WIDTH
== nMemberId
||
552 ALL_BORDER_LINE_WIDTH
== nMemberId
)
553 sw_frmitems_setXMLBorder( pRight
, nWidth
,
554 static_cast< sal_uInt16
>( nOutWidth
),
555 static_cast< sal_uInt16
>( nInWidth
),
556 static_cast< sal_uInt16
>( nDistance
) );
561 pBox
->SetLine( pTop
, BOX_LINE_TOP
);
562 pBox
->SetLine( pBottom
, BOX_LINE_BOTTOM
);
563 pBox
->SetLine( pLeft
, BOX_LINE_LEFT
);
564 pBox
->SetLine( pRight
, BOX_LINE_RIGHT
);
577 SvxFmtBreakItem
* pFmtBreak
= PTR_CAST(SvxFmtBreakItem
, &rItem
);
578 OSL_ENSURE( pFmtBreak
!= NULL
, "Wrong Which-ID" );
582 if( !rUnitConverter
.convertEnum( eEnum
, rValue
, psXML_BreakType
) )
587 pFmtBreak
->SetValue( SVX_BREAK_NONE
);
594 case MID_BREAK_BEFORE
:
595 pFmtBreak
->SetValue( static_cast< sal_uInt16
>((eEnum
== 1) ?
596 SVX_BREAK_COLUMN_BEFORE
:
597 SVX_BREAK_PAGE_BEFORE
) );
599 case MID_BREAK_AFTER
:
600 pFmtBreak
->SetValue( static_cast< sal_uInt16
>((eEnum
== 1) ?
601 SVX_BREAK_COLUMN_AFTER
:
602 SVX_BREAK_PAGE_AFTER
) );
612 SvxFmtKeepItem
* pFmtKeep
= PTR_CAST(SvxFmtKeepItem
, &rItem
);
613 OSL_ENSURE( pFmtKeep
!= NULL
, "Wrong Which-ID" );
615 if( IsXMLToken( rValue
, XML_ALWAYS
) ||
616 IsXMLToken( rValue
, XML_TRUE
) )
618 pFmtKeep
->SetValue( sal_True
);
621 else if( IsXMLToken( rValue
, XML_AUTO
) ||
622 IsXMLToken( rValue
, XML_FALSE
) )
624 pFmtKeep
->SetValue( sal_False
);
632 SvxBrushItem
* pBrush
= PTR_CAST(SvxBrushItem
, &rItem
);
633 OSL_ENSURE( pBrush
!= NULL
, "Wrong Which-ID" );
635 sal_Int32
nTempColor(0);
639 if( IsXMLToken( rValue
, XML_TRANSPARENT
) )
641 pBrush
->GetColor().SetTransparency(0xff);
644 else if (::sax::Converter::convertColor(nTempColor
, rValue
))
646 Color
aTempColor(nTempColor
);
647 aTempColor
.SetTransparency(0);
648 pBrush
->SetColor( aTempColor
);
653 case MID_GRAPHIC_LINK
:
655 SvxGraphicPosition eOldGraphicPos
= pBrush
->GetGraphicPos();
658 pBrush
->PutValue( aAny
, MID_GRAPHIC_URL
);
659 if( GPOS_NONE
== eOldGraphicPos
&&
660 GPOS_NONE
!= pBrush
->GetGraphicPos() )
661 pBrush
->SetGraphicPos( GPOS_TILED
);
666 case MID_GRAPHIC_REPEAT
:
668 SvxGraphicPosition eGraphicPos
= pBrush
->GetGraphicPos();
669 sal_uInt16 nPos
= GPOS_NONE
;
670 if( rUnitConverter
.convertEnum( nPos
, rValue
,
671 psXML_BrushRepeat
) )
673 if( GPOS_MM
!= nPos
|| GPOS_NONE
== eGraphicPos
||
674 GPOS_AREA
== eGraphicPos
|| GPOS_TILED
== eGraphicPos
)
675 pBrush
->SetGraphicPos( (SvxGraphicPosition
)nPos
);
681 case MID_GRAPHIC_POSITION
:
683 SvxGraphicPosition ePos
= GPOS_NONE
, eTmp
;
685 SvXMLTokenEnumerator
aTokenEnum( rValue
);
687 bool bHori
= false, bVert
= false;
689 while( bOk
&& aTokenEnum
.getNextToken( aToken
) )
695 else if( -1 != aToken
.indexOf( sal_Unicode('%') ) )
698 if (::sax::Converter::convertPercent(nPrc
, aToken
))
702 ePos
= nPrc
< 25 ? GPOS_LT
:
703 (nPrc
< 75 ? GPOS_MM
: GPOS_RB
);
708 eTmp
= nPrc
< 25 ? GPOS_LT
:
709 (nPrc
< 75 ? GPOS_LM
: GPOS_LB
);
710 sw_frmitems_MergeXMLVertPos( ePos
, eTmp
);
720 else if( IsXMLToken( aToken
, XML_CENTER
) )
723 sw_frmitems_MergeXMLVertPos( ePos
, GPOS_MM
);
725 sw_frmitems_MergeXMLHoriPos( ePos
, GPOS_MM
);
729 else if( rUnitConverter
.convertEnum( nTmp
, aToken
,
730 psXML_BrushHoriPos
) )
733 sw_frmitems_MergeXMLHoriPos(
734 ePos
, (SvxGraphicPosition
)nTmp
);
736 ePos
= (SvxGraphicPosition
)nTmp
;
741 else if( rUnitConverter
.convertEnum( nTmp
, aToken
,
742 psXML_BrushVertPos
) )
745 sw_frmitems_MergeXMLVertPos(
746 ePos
, (SvxGraphicPosition
)nTmp
);
748 ePos
= (SvxGraphicPosition
)nTmp
;
759 if( GPOS_NONE
== ePos
) bOk
= false;
761 pBrush
->SetGraphicPos( ePos
);
765 case MID_GRAPHIC_FILTER
:
766 pBrush
->SetGraphicFilter( rValue
);
775 SwFmtPageDesc
* pPageDesc
= PTR_CAST(SwFmtPageDesc
, &rItem
);
776 OSL_ENSURE( pPageDesc
!= NULL
, "Wrong Which-ID" );
778 if( MID_PAGEDESC_PAGENUMOFFSET
==nMemberId
)
781 bOk
= ::sax::Converter::convertNumber(
782 nVal
, rValue
, 0, USHRT_MAX
);
784 pPageDesc
->SetNumOffset( (sal_uInt16
)nVal
);
789 case RES_LAYOUT_SPLIT
:
792 SfxBoolItem
* pSplit
= PTR_CAST(SfxBoolItem
, &rItem
);
793 OSL_ENSURE( pSplit
!= NULL
, "Wrong Which-ID" );
795 if( IsXMLToken( rValue
, XML_AUTO
) ||
796 IsXMLToken( rValue
, XML_TRUE
) )
798 pSplit
->SetValue( sal_True
);
801 else if( IsXMLToken( rValue
, XML_ALWAYS
) ||
802 IsXMLToken( rValue
, XML_FALSE
) )
804 pSplit
->SetValue( sal_False
);
810 case RES_HORI_ORIENT
:
812 SwFmtHoriOrient
* pHoriOrient
= PTR_CAST(SwFmtHoriOrient
, &rItem
);
813 OSL_ENSURE( pHoriOrient
!= NULL
, "Wrong Which-ID" );
816 bOk
= rUnitConverter
.convertEnum( nValue
, rValue
,
819 pHoriOrient
->SetHoriOrient( nValue
);
823 case RES_VERT_ORIENT
:
825 SwFmtVertOrient
* pVertOrient
= PTR_CAST(SwFmtVertOrient
, &rItem
);
826 OSL_ENSURE( pVertOrient
!= NULL
, "Wrong Which-ID" );
829 bOk
= rUnitConverter
.convertEnum( nValue
, rValue
,
830 aXMLTableVAlignMap
);
832 pVertOrient
->SetVertOrient( nValue
);
833 //#i8855# text::VertOrientation::NONE is stored as empty string and should be applied here
834 else if(rValue
.isEmpty())
836 pVertOrient
->SetVertOrient( text::VertOrientation::NONE
);
844 SwFmtFrmSize
* pFrmSize
= PTR_CAST(SwFmtFrmSize
, &rItem
);
845 OSL_ENSURE( pFrmSize
!= NULL
, "Wrong Which-ID" );
847 bool bSetHeight
= false;
848 bool bSetWidth
= false;
849 bool bSetSizeType
= false;
850 SwFrmSize eSizeType
= ATT_VAR_SIZE
;
851 sal_Int32 nMin
= MINLAY
;
855 case MID_FRMSIZE_REL_WIDTH
:
858 bOk
= ::sax::Converter::convertPercent( nValue
, rValue
);
863 else if( nValue
> 100 )
866 pFrmSize
->SetWidthPercent( (sal_Int8
)nValue
);
870 case MID_FRMSIZE_WIDTH
:
873 case MID_FRMSIZE_MIN_HEIGHT
:
874 eSizeType
= ATT_MIN_SIZE
;
879 case MID_FRMSIZE_FIX_HEIGHT
:
880 eSizeType
= ATT_FIX_SIZE
;
885 case MID_FRMSIZE_COL_WIDTH
:
886 eSizeType
= ATT_FIX_SIZE
;
890 case MID_FRMSIZE_REL_COL_WIDTH
:
892 sal_Int32 nPos
= rValue
.indexOf( (sal_Unicode
)'*' );
895 sal_Int32 nValue
= rValue
.toInt32();
896 if( nValue
< MINLAY
)
898 else if( nValue
> USHRT_MAX
)
901 pFrmSize
->SetWidth( (sal_uInt16
)nValue
);
902 pFrmSize
->SetHeightSizeType( ATT_VAR_SIZE
);
910 if( bSetHeight
|| bSetWidth
)
912 bOk
= rUnitConverter
.convertMeasureToCore(nValue
, rValue
, nMin
,
917 pFrmSize
->SetWidth( (sal_uInt16
)nValue
);
919 pFrmSize
->SetHeight( (sal_uInt16
)nValue
);
921 pFrmSize
->SetHeightSizeType( eSizeType
);
929 const XMLPropertyHandler
* pWritingModeHandler
=
930 XMLPropertyHandlerFactory::CreatePropertyHandler(
931 XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
);
932 if( pWritingModeHandler
!= NULL
)
935 bOk
= pWritingModeHandler
->importXML( rValue
, aAny
,
938 bOk
= rItem
.PutValue( aAny
);
940 delete pWritingModeHandler
;
945 case RES_COLLAPSING_BORDERS
:
947 SfxBoolItem
* pBorders
= PTR_CAST(SfxBoolItem
, &rItem
);
948 OSL_ENSURE( pBorders
!= NULL
, "Wrong Which-ID" );
950 if( IsXMLToken( rValue
, XML_COLLAPSING
) )
952 pBorders
->SetValue( sal_True
);
955 else if( IsXMLToken( rValue
, XML_SEPARATING
) )
957 pBorders
->SetValue( sal_False
);
966 OSL_FAIL("Item not implemented!");
974 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */