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 .
20 #include "xmlimpit.hxx"
22 #include <sal/log.hxx>
23 #include <sax/tools/converter.hxx>
25 #include <xmloff/xmluconv.hxx>
26 #include <svl/itempool.hxx>
27 #include <svl/poolitem.hxx>
28 #include <svl/itemset.hxx>
29 #include <xmloff/namespacemap.hxx>
30 #include <editeng/xmlcnitm.hxx>
31 #include <editeng/memberids.h>
32 #include <osl/diagnose.h>
34 #include <hintids.hxx>
36 #include <svx/unomid.hxx>
37 #include <editeng/lrspitem.hxx>
38 #include <editeng/ulspitem.hxx>
39 #include <editeng/shaditem.hxx>
40 #include <editeng/boxitem.hxx>
41 #include <editeng/formatbreakitem.hxx>
42 #include <editeng/keepitem.hxx>
43 #include <editeng/brushitem.hxx>
44 #include <editeng/frmdir.hxx>
45 #include <fmtpdsc.hxx>
46 #include <fmtornt.hxx>
47 #include <fmtfsize.hxx>
49 #include <xmloff/prhdlfac.hxx>
50 #include <xmloff/xmltypes.hxx>
51 #include <xmloff/xmlprhdl.hxx>
52 #include <xmloff/xmlimp.hxx>
53 #include <xmloff/xmlnamespace.hxx>
54 #include "xmlithlp.hxx"
55 #include <com/sun/star/uno/Any.hxx>
57 using ::editeng::SvxBorderLine
;
58 using namespace ::com::sun::star
;
59 using namespace ::xmloff::token
;
62 constexpr sal_uInt16 nUnknownWhich
= RES_UNKNOWNATR_CONTAINER
;
64 SvXMLImportItemMapper::SvXMLImportItemMapper(
65 SvXMLItemMapEntriesRef aMapEntries
) :
66 mrMapEntries(std::move( aMapEntries
))
70 SvXMLImportItemMapper::~SvXMLImportItemMapper()
75 SvXMLImportItemMapper::setMapEntries( SvXMLItemMapEntriesRef rMapEntries
)
77 mrMapEntries
= std::move(rMapEntries
);
80 // fills the given itemset with the attributes in the given list
81 void SvXMLImportItemMapper::importXML( SfxItemSet
& rSet
,
82 uno::Reference
< xml::sax::XFastAttributeList
> const & xAttrList
,
83 const SvXMLUnitConverter
& rUnitConverter
,
84 const SvXMLNamespaceMap
& rNamespaceMap
)
86 std::unique_ptr
<SvXMLAttrContainerItem
> pUnknownItem
;
87 for (auto &aIter
: sax_fastparser::castToFastAttributeList( xAttrList
))
89 if( IsTokenInNamespace(aIter
.getToken(), XML_NAMESPACE_XMLNS
) )
92 sal_Int32 nToken
= aIter
.getToken();
93 const OUString sValue
= aIter
.toString();
95 // find a map entry for this attribute
96 sal_Int32 nLookupToken
= nToken
;
97 // compatibility namespaces need to be transformed into current namespace before looking up
98 if (IsTokenInNamespace(nLookupToken
, XML_NAMESPACE_FO_COMPAT
))
99 nLookupToken
= XML_ELEMENT(FO
, (nLookupToken
& TOKEN_MASK
));
100 SvXMLItemMapEntry
const * pEntry
= mrMapEntries
->getByName( nLookupToken
);
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
= nullptr;
110 SfxItemState eState
= rSet
.GetItemState( pEntry
->nWhichId
, true,
113 // if it's not set, try the pool
114 if (SfxItemState::SET
!= eState
&& SfxItemPool::IsWhich(pEntry
->nWhichId
))
115 pItem
= &rSet
.GetPool()->GetDefaultItem(pEntry
->nWhichId
);
117 // do we have an item?
118 if(eState
>= SfxItemState::DEFAULT
&& pItem
)
120 std::unique_ptr
<SfxPoolItem
> pNewItem(pItem
->Clone());
123 if( 0 == (pEntry
->nMemberId
&MID_SW_FLAG_SPECIAL_ITEM_IMPORT
) )
125 bPut
= PutXMLValue( *pNewItem
, sValue
,
126 o3tl::narrowing
<sal_uInt16
>( pEntry
->nMemberId
& MID_SW_FLAG_MASK
),
132 bPut
= handleSpecialItem( *pEntry
, *pNewItem
, rSet
,
133 sValue
, rUnitConverter
);
137 rSet
.Put( std::move(pNewItem
) );
141 OSL_FAIL( "Could not get a needed item for xml import!" );
144 else if( 0 != (pEntry
->nMemberId
& MID_SW_FLAG_NO_ITEM_IMPORT
) )
146 handleNoItem( *pEntry
, rSet
, sValue
, rUnitConverter
,
154 const SfxPoolItem
* pItem
= nullptr;
155 if( SfxItemState::SET
== rSet
.GetItemState( nUnknownWhich
, true,
158 pUnknownItem
.reset( static_cast<SvXMLAttrContainerItem
*>( pItem
->Clone() ) );
162 pUnknownItem
.reset( new SvXMLAttrContainerItem( nUnknownWhich
) );
167 if( IsTokenInNamespace(nToken
, XML_NAMESPACE_NONE
) )
168 pUnknownItem
->AddAttr( SvXMLImport::getNameFromToken( nToken
), sValue
);
171 const OUString
& rAttrNamespacePrefix
= SvXMLImport::getNamespacePrefixFromToken(nToken
, &rNamespaceMap
);
172 OUString sAttrName
= SvXMLImport::getNameFromToken( nToken
);
173 if ( !rAttrNamespacePrefix
.isEmpty() )
174 sAttrName
= rAttrNamespacePrefix
+ SvXMLImport::aNamespaceSeparator
+ sAttrName
;
175 OUString aLocalName
, aPrefix
, aNamespace
;
176 rNamespaceMap
.GetKeyByAttrName( sAttrName
, &aPrefix
, &aLocalName
,
178 if ( !rAttrNamespacePrefix
.isEmpty() )
179 pUnknownItem
->AddAttr( rAttrNamespacePrefix
, aNamespace
, aLocalName
,
182 pUnknownItem
->AddAttr( aLocalName
, sValue
);
188 importXMLUnknownAttributes(rSet
, xAttrList
, rUnitConverter
, pUnknownItem
);
192 rSet
.Put( *pUnknownItem
);
195 finished(rSet
, rUnitConverter
);
198 void SvXMLImportItemMapper::importXMLUnknownAttributes( SfxItemSet
& rSet
,
199 uno::Reference
< xml::sax::XFastAttributeList
> const & xAttrList
,
200 const SvXMLUnitConverter
& rUnitConverter
,
201 std::unique_ptr
<SvXMLAttrContainerItem
>& pUnknownItem
)
203 const css::uno::Sequence
< css::xml::Attribute
> unknownAttributes
= xAttrList
->getUnknownAttributes();
204 for (const auto & rAttribute
: unknownAttributes
)
208 const SfxPoolItem
* pItem
= nullptr;
209 if( SfxItemState::SET
== rSet
.GetItemState( nUnknownWhich
, true,
212 pUnknownItem
.reset( static_cast<SvXMLAttrContainerItem
*>( pItem
->Clone() ) );
216 pUnknownItem
.reset( new SvXMLAttrContainerItem( nUnknownWhich
) );
221 if( rAttribute
.NamespaceURL
.isEmpty() )
222 pUnknownItem
->AddAttr( rAttribute
.Name
, rAttribute
.Value
);
226 OUString sName
= rAttribute
.Name
;
227 int i
= sName
.indexOf(':');
230 sPrefix
= sName
.copy(0, i
-1);
231 sName
= sName
.copy(i
+1);
233 // the sax parser doesn't reject these, strangely
234 if (sName
.indexOf(':') == -1)
235 pUnknownItem
->AddAttr( sPrefix
, rAttribute
.NamespaceURL
, sName
,
238 SAL_WARN("sw", "ignoring dodgy attribute: " + rAttribute
.Name
);
245 rSet
.Put( *pUnknownItem
);
248 finished(rSet
, rUnitConverter
);
251 /** this method is called for every item that has the
252 MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set */
254 SvXMLImportItemMapper::handleSpecialItem( const SvXMLItemMapEntry
& /*rEntry*/,
255 SfxPoolItem
& /*rItem*/,
256 SfxItemSet
& /*rSet*/,
257 const OUString
& /*rValue*/,
258 const SvXMLUnitConverter
& /*rUnitConverter*/ )
260 OSL_FAIL( "unsupported special item in xml import" );
264 /** this method is called for every item that has the
265 MID_SW_FLAG_NO_ITEM_IMPORT flag set */
266 bool SvXMLImportItemMapper::handleNoItem( const SvXMLItemMapEntry
& /*rEntry*/,
267 SfxItemSet
& /*rSet*/,
268 const OUString
& /*rValue*/,
269 const SvXMLUnitConverter
& /*rUnitConverter*/,
270 const SvXMLNamespaceMap
& /*rNamespaceMap*/ )
272 OSL_FAIL( "unsupported no item in xml import" );
277 SvXMLImportItemMapper::finished(SfxItemSet
&, SvXMLUnitConverter
const&) const
279 // nothing to do here
286 std::unique_ptr
<SvxBorderLine
> pTop
;
287 std::unique_ptr
<SvxBorderLine
> pBottom
;
288 std::unique_ptr
<SvxBorderLine
> pLeft
;
289 std::unique_ptr
<SvxBorderLine
> pRight
;
291 BoxHolder(BoxHolder
const&) = delete;
292 BoxHolder
& operator=(BoxHolder
const&) = delete;
294 explicit BoxHolder(SvxBoxItem
const & rBox
)
297 pTop
.reset(new SvxBorderLine( *rBox
.GetTop() ));
298 if (rBox
.GetBottom())
299 pBottom
.reset(new SvxBorderLine( *rBox
.GetBottom() ));
301 pLeft
.reset(new SvxBorderLine( *rBox
.GetLeft() ));
303 pRight
.reset(new SvxBorderLine( *rBox
.GetRight() ));
309 // put an XML-string value into an item
310 bool SvXMLImportItemMapper::PutXMLValue(
312 const OUString
& rValue
,
313 sal_uInt16 nMemberId
,
314 const SvXMLUnitConverter
& rUnitConverter
)
318 switch (rItem
.Which())
320 case RES_MARGIN_FIRSTLINE
:
321 case RES_MARGIN_TEXTLEFT
:
322 case RES_MARGIN_RIGHT
:
323 assert(false); // is only called for frame formats?
328 SvxLRSpaceItem
& rLRSpace
= dynamic_cast<SvxLRSpaceItem
&>(rItem
);
335 sal_Int32 nProp
= 100;
338 if( rValue
.indexOf( '%' ) != -1 )
339 bOk
= ::sax::Converter::convertPercent(nProp
, rValue
);
341 bOk
= rUnitConverter
.convertMeasureToCore(nAbs
, rValue
);
348 rLRSpace
.SetTextLeft( nAbs
, o3tl::narrowing
<sal_uInt16
>(nProp
) );
351 rLRSpace
.SetRight( nAbs
, o3tl::narrowing
<sal_uInt16
>(nProp
) );
358 case MID_FIRST_LINE_INDENT
:
360 assert(false); // it looks like this can't be called? (frame formats only, aTableItemMap)
361 sal_Int32 nProp
= 100;
364 if( rValue
.indexOf( '%' ) != -1 )
365 bOk
= ::sax::Converter::convertPercent(nProp
, rValue
);
367 bOk
= rUnitConverter
.convertMeasureToCore(nAbs
, rValue
,
370 rLRSpace
.SetTextFirstLineOffset( static_cast<short>(nAbs
), o3tl::narrowing
<sal_uInt16
>(nProp
) );
376 assert(false); // it looks like this can't be called? (frame formats only, aTableItemMap)
377 bool bAutoFirst(false);
378 bOk
= ::sax::Converter::convertBool( bAutoFirst
, rValue
);
380 rLRSpace
.SetAutoFirst( bAutoFirst
);
385 OSL_FAIL( "unknown member id!");
392 SvxULSpaceItem
& rULSpace
= dynamic_cast<SvxULSpaceItem
&>(rItem
);
394 sal_Int32 nProp
= 100;
397 if( rValue
.indexOf( '%' ) != -1 )
398 bOk
= ::sax::Converter::convertPercent( nProp
, rValue
);
400 bOk
= rUnitConverter
.convertMeasureToCore( nAbs
, rValue
);
405 rULSpace
.SetUpper( o3tl::narrowing
<sal_uInt16
>(nAbs
), o3tl::narrowing
<sal_uInt16
>(nProp
) );
408 rULSpace
.SetLower( o3tl::narrowing
<sal_uInt16
>(nAbs
), o3tl::narrowing
<sal_uInt16
>(nProp
) );
411 OSL_FAIL("unknown MemberId");
418 SvxShadowItem
& rShadow
= dynamic_cast<SvxShadowItem
&>(rItem
);
420 bool bColorFound
= false;
421 bool bOffsetFound
= false;
423 SvXMLTokenEnumerator
aTokenEnum( rValue
);
425 Color
aColor( 128,128, 128 );
426 rShadow
.SetLocation( SvxShadowLocation::BottomRight
);
428 std::u16string_view aToken
;
429 while( aTokenEnum
.getNextToken( aToken
) )
431 if( IsXMLToken( aToken
, XML_NONE
) )
433 rShadow
.SetLocation( SvxShadowLocation::NONE
);
436 else if( !bColorFound
&& aToken
.substr(0,1) == u
"#" )
438 bOk
= ::sax::Converter::convertColor( aColor
, aToken
);
444 else if( !bOffsetFound
)
446 sal_Int32 nX
= 0, nY
= 0;
448 bOk
= rUnitConverter
.convertMeasureToCore( nX
, aToken
);
449 if( bOk
&& aTokenEnum
.getNextToken( aToken
) )
450 bOk
= rUnitConverter
.convertMeasureToCore( nY
, aToken
);
458 rShadow
.SetLocation( SvxShadowLocation::TopLeft
);
462 rShadow
.SetLocation( SvxShadowLocation::BottomLeft
);
469 rShadow
.SetLocation( SvxShadowLocation::TopRight
);
473 rShadow
.SetLocation( SvxShadowLocation::BottomRight
);
477 if( nX
< 0 ) nX
*= -1;
478 if( nY
< 0 ) nY
*= -1;
480 rShadow
.SetWidth( static_cast< sal_uInt16
>( (nX
+ nY
) >> 1 ) );
485 if( bOk
&& ( bColorFound
|| bOffsetFound
) )
487 rShadow
.SetColor(aColor
);
496 SvxBoxItem
& rBox
= dynamic_cast<SvxBoxItem
&>(rItem
);
498 // copy SvxBorderLines
499 BoxHolder
aBoxes(rBox
);
505 case ALL_BORDER_PADDING
:
506 case LEFT_BORDER_PADDING
:
507 case RIGHT_BORDER_PADDING
:
508 case TOP_BORDER_PADDING
:
509 case BOTTOM_BORDER_PADDING
:
510 if (!rUnitConverter
.convertMeasureToCore( nTemp
, rValue
,
516 if( nMemberId
== LEFT_BORDER_PADDING
||
517 nMemberId
== ALL_BORDER_PADDING
)
518 rBox
.SetDistance( o3tl::narrowing
<sal_uInt16
>(nTemp
), SvxBoxItemLine::LEFT
);
519 if( nMemberId
== RIGHT_BORDER_PADDING
||
520 nMemberId
== ALL_BORDER_PADDING
)
521 rBox
.SetDistance( o3tl::narrowing
<sal_uInt16
>(nTemp
), SvxBoxItemLine::RIGHT
);
522 if( nMemberId
== TOP_BORDER_PADDING
||
523 nMemberId
== ALL_BORDER_PADDING
)
524 rBox
.SetDistance( o3tl::narrowing
<sal_uInt16
>(nTemp
), SvxBoxItemLine::TOP
);
525 if( nMemberId
== BOTTOM_BORDER_PADDING
||
526 nMemberId
== ALL_BORDER_PADDING
)
527 rBox
.SetDistance( o3tl::narrowing
<sal_uInt16
>(nTemp
), SvxBoxItemLine::BOTTOM
);
536 bool bHasStyle
= false;
537 bool bHasWidth
= false;
538 bool bHasColor
= false;
540 sal_uInt16 nStyle
= USHRT_MAX
;
541 sal_uInt16 nWidth
= 0;
542 sal_uInt16 nNamedWidth
= USHRT_MAX
;
544 Color
aColor( COL_BLACK
);
546 if( !sw_frmitems_parseXMLBorder( rValue
, rUnitConverter
,
548 bHasWidth
, nWidth
, nNamedWidth
,
549 bHasColor
, aColor
) )
552 if( TOP_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
553 sw_frmitems_setXMLBorder( aBoxes
.pTop
,
555 bHasWidth
, nWidth
, nNamedWidth
,
558 if( BOTTOM_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
559 sw_frmitems_setXMLBorder( aBoxes
.pBottom
,
561 bHasWidth
, nWidth
, nNamedWidth
,
564 if( LEFT_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
565 sw_frmitems_setXMLBorder( aBoxes
.pLeft
,
567 bHasWidth
, nWidth
, nNamedWidth
,
570 if( RIGHT_BORDER
== nMemberId
|| ALL_BORDER
== nMemberId
)
571 sw_frmitems_setXMLBorder( aBoxes
.pRight
,
573 bHasWidth
, nWidth
, nNamedWidth
,
577 case ALL_BORDER_LINE_WIDTH
:
578 case LEFT_BORDER_LINE_WIDTH
:
579 case RIGHT_BORDER_LINE_WIDTH
:
580 case TOP_BORDER_LINE_WIDTH
:
581 case BOTTOM_BORDER_LINE_WIDTH
:
583 SvXMLTokenEnumerator
aTokenEnum( rValue
);
585 sal_Int32 nInWidth
, nDistance
, nOutWidth
;
587 std::u16string_view aToken
;
588 if( !aTokenEnum
.getNextToken( aToken
) )
591 if (!rUnitConverter
.convertMeasureToCore(nInWidth
, aToken
))
594 if( !aTokenEnum
.getNextToken( aToken
) )
597 if (!rUnitConverter
.convertMeasureToCore(nDistance
, aToken
))
600 if( !aTokenEnum
.getNextToken( aToken
) )
603 if (!rUnitConverter
.convertMeasureToCore(nOutWidth
, aToken
))
606 // #i61946: accept line style even it's not part of our "normal" set of line styles
607 sal_uInt16 nWidth
= 0;
609 if( TOP_BORDER_LINE_WIDTH
== nMemberId
||
610 ALL_BORDER_LINE_WIDTH
== nMemberId
)
611 sw_frmitems_setXMLBorder( aBoxes
.pTop
, nWidth
,
612 static_cast< sal_uInt16
>( nOutWidth
),
613 static_cast< sal_uInt16
>( nInWidth
),
614 static_cast< sal_uInt16
>( nDistance
) );
616 if( BOTTOM_BORDER_LINE_WIDTH
== nMemberId
||
617 ALL_BORDER_LINE_WIDTH
== nMemberId
)
618 sw_frmitems_setXMLBorder( aBoxes
.pBottom
, nWidth
,
619 static_cast< sal_uInt16
>( nOutWidth
),
620 static_cast< sal_uInt16
>( nInWidth
),
621 static_cast< sal_uInt16
>( nDistance
) );
623 if( LEFT_BORDER_LINE_WIDTH
== nMemberId
||
624 ALL_BORDER_LINE_WIDTH
== nMemberId
)
625 sw_frmitems_setXMLBorder( aBoxes
.pLeft
, nWidth
,
626 static_cast< sal_uInt16
>( nOutWidth
),
627 static_cast< sal_uInt16
>( nInWidth
),
628 static_cast< sal_uInt16
>( nDistance
) );
630 if( RIGHT_BORDER_LINE_WIDTH
== nMemberId
||
631 ALL_BORDER_LINE_WIDTH
== nMemberId
)
632 sw_frmitems_setXMLBorder( aBoxes
.pRight
, nWidth
,
633 static_cast< sal_uInt16
>( nOutWidth
),
634 static_cast< sal_uInt16
>( nInWidth
),
635 static_cast< sal_uInt16
>( nDistance
) );
640 rBox
.SetLine( aBoxes
.pTop
.get(), SvxBoxItemLine::TOP
);
641 rBox
.SetLine( aBoxes
.pBottom
.get(), SvxBoxItemLine::BOTTOM
);
642 rBox
.SetLine( aBoxes
.pLeft
.get(), SvxBoxItemLine::LEFT
);
643 rBox
.SetLine( aBoxes
.pRight
.get(), SvxBoxItemLine::RIGHT
);
651 SvxFormatBreakItem
& rFormatBreak
= dynamic_cast<SvxFormatBreakItem
&>(rItem
);
654 if( !SvXMLUnitConverter::convertEnum( eEnum
, rValue
, psXML_BreakType
) )
659 rFormatBreak
.SetValue( SvxBreak::NONE
);
666 case MID_BREAK_BEFORE
:
667 rFormatBreak
.SetValue( eEnum
== 1 ?
668 SvxBreak::ColumnBefore
:
669 SvxBreak::PageBefore
);
671 case MID_BREAK_AFTER
:
672 rFormatBreak
.SetValue( eEnum
== 1 ?
673 SvxBreak::ColumnAfter
:
674 SvxBreak::PageAfter
);
684 SvxFormatKeepItem
& rFormatKeep
= dynamic_cast<SvxFormatKeepItem
&>(rItem
);
686 if( IsXMLToken( rValue
, XML_ALWAYS
) ||
687 IsXMLToken( rValue
, XML_TRUE
) )
689 rFormatKeep
.SetValue( true );
692 else if( IsXMLToken( rValue
, XML_AUTO
) ||
693 IsXMLToken( rValue
, XML_FALSE
) )
695 rFormatKeep
.SetValue( false );
703 SvxBrushItem
& rBrush
= dynamic_cast<SvxBrushItem
&>(rItem
);
709 if( IsXMLToken( rValue
, XML_TRANSPARENT
) )
711 rBrush
.GetColor().SetAlpha(0);
714 else if (::sax::Converter::convertColor(aTempColor
, rValue
))
716 aTempColor
.SetAlpha(255);
717 rBrush
.SetColor( aTempColor
);
722 case MID_GRAPHIC_REPEAT
:
724 SvxGraphicPosition eGraphicPos
= rBrush
.GetGraphicPos();
725 SvxGraphicPosition nPos
= GPOS_NONE
;
726 if( SvXMLUnitConverter::convertEnum( nPos
, rValue
,
727 psXML_BrushRepeat
) )
729 if( GPOS_MM
!= nPos
|| GPOS_NONE
== eGraphicPos
||
730 GPOS_AREA
== eGraphicPos
|| GPOS_TILED
== eGraphicPos
)
731 rBrush
.SetGraphicPos( nPos
);
737 case MID_GRAPHIC_POSITION
:
739 SvxGraphicPosition ePos
= GPOS_NONE
, eTmp
;
740 SvxGraphicPosition nTmp
;
741 SvXMLTokenEnumerator
aTokenEnum( rValue
);
742 std::u16string_view aToken
;
743 bool bHori
= false, bVert
= false;
745 while( bOk
&& aTokenEnum
.getNextToken( aToken
) )
751 else if( std::u16string_view::npos
!= aToken
.find( '%' ) )
754 if (::sax::Converter::convertPercent(nPrc
, aToken
))
758 ePos
= nPrc
< 25 ? GPOS_LT
:
759 (nPrc
< 75 ? GPOS_MM
: GPOS_RB
);
764 eTmp
= nPrc
< 25 ? GPOS_LT
:
765 (nPrc
< 75 ? GPOS_LM
: GPOS_LB
);
766 sw_frmitems_MergeXMLVertPos( ePos
, eTmp
);
776 else if( IsXMLToken( aToken
, XML_CENTER
) )
779 sw_frmitems_MergeXMLVertPos( ePos
, GPOS_MM
);
781 sw_frmitems_MergeXMLHoriPos( ePos
, GPOS_MM
);
785 else if( SvXMLUnitConverter::convertEnum( nTmp
, aToken
,
786 psXML_BrushHoriPos
) )
789 sw_frmitems_MergeXMLHoriPos(
797 else if( SvXMLUnitConverter::convertEnum( nTmp
, aToken
,
798 psXML_BrushVertPos
) )
801 sw_frmitems_MergeXMLVertPos(
815 if( GPOS_NONE
== ePos
) bOk
= false;
817 rBrush
.SetGraphicPos( ePos
);
821 case MID_GRAPHIC_FILTER
:
822 rBrush
.SetGraphicFilter( rValue
);
831 SwFormatPageDesc
& rPageDesc
= dynamic_cast<SwFormatPageDesc
&>(rItem
);
833 if( MID_PAGEDESC_PAGENUMOFFSET
==nMemberId
)
836 bOk
= ::sax::Converter::convertNumber(
837 nVal
, rValue
, 0, USHRT_MAX
);
838 // i#114163 tdf#77111: OOo < 3.3 had a bug where it wrote
839 // "auto" as "0" for tables - now that we support a real offset
840 // 0, this fake "0" MUST NOT be imported as offset 0!
841 if( bOk
&& nVal
> 0 )
842 rPageDesc
.SetNumOffset( o3tl::narrowing
<sal_uInt16
>(nVal
) );
847 case RES_LAYOUT_SPLIT
:
850 SfxBoolItem
& rSplit
= dynamic_cast<SfxBoolItem
&>(rItem
);
852 if( IsXMLToken( rValue
, XML_AUTO
) ||
853 IsXMLToken( rValue
, XML_TRUE
) )
855 rSplit
.SetValue( true );
858 else if( IsXMLToken( rValue
, XML_ALWAYS
) ||
859 IsXMLToken( rValue
, XML_FALSE
) )
861 rSplit
.SetValue( false );
869 SfxBoolItem
& rHasTextChangesOnly
= dynamic_cast<SfxBoolItem
&>(rItem
);
871 if( IsXMLToken( rValue
, XML_TRUE
) )
873 rHasTextChangesOnly
.SetValue( true );
876 else if( IsXMLToken( rValue
, XML_FALSE
) )
878 rHasTextChangesOnly
.SetValue( false );
884 case RES_HORI_ORIENT
:
886 SwFormatHoriOrient
& rHoriOrient
= dynamic_cast<SwFormatHoriOrient
&>(rItem
);
889 bOk
= SvXMLUnitConverter::convertEnum( nValue
, rValue
,
892 rHoriOrient
.SetHoriOrient( nValue
);
896 case RES_VERT_ORIENT
:
898 SwFormatVertOrient
& rVertOrient
= dynamic_cast<SwFormatVertOrient
&>(rItem
);
901 bOk
= SvXMLUnitConverter::convertEnum( nValue
, rValue
,
902 aXMLTableVAlignMap
);
904 rVertOrient
.SetVertOrient( nValue
);
905 //#i8855# text::VertOrientation::NONE is stored as empty string and should be applied here
906 else if(rValue
.isEmpty())
908 rVertOrient
.SetVertOrient( text::VertOrientation::NONE
);
916 SwFormatFrameSize
& rFrameSize
= dynamic_cast<SwFormatFrameSize
&>(rItem
);
918 bool bSetHeight
= false;
919 bool bSetWidth
= false;
920 bool bSetSizeType
= false;
921 SwFrameSize eSizeType
= SwFrameSize::Variable
;
922 sal_Int32 nMin
= MINLAY
;
926 case MID_FRMSIZE_REL_WIDTH
:
929 bOk
= ::sax::Converter::convertPercent( nValue
, rValue
);
934 else if( nValue
> 100 )
937 rFrameSize
.SetWidthPercent( static_cast<sal_Int8
>(nValue
) );
941 case MID_FRMSIZE_WIDTH
:
944 case MID_FRMSIZE_MIN_HEIGHT
:
945 eSizeType
= SwFrameSize::Minimum
;
950 case MID_FRMSIZE_FIX_HEIGHT
:
951 eSizeType
= SwFrameSize::Fixed
;
956 case MID_FRMSIZE_COL_WIDTH
:
957 eSizeType
= SwFrameSize::Fixed
;
961 case MID_FRMSIZE_REL_COL_WIDTH
:
963 sal_Int32 nPos
= rValue
.indexOf( '*' );
966 sal_Int32 nValue
= rValue
.toInt32();
967 if( nValue
< MINLAY
)
969 else if( nValue
> SAL_MAX_UINT16
)
970 nValue
= SAL_MAX_UINT16
;
972 rFrameSize
.SetWidth( o3tl::narrowing
<sal_uInt16
>(nValue
) );
973 rFrameSize
.SetHeightSizeType( SwFrameSize::Variable
);
980 if( bSetHeight
|| bSetWidth
)
983 bOk
= rUnitConverter
.convertMeasureToCore(nValue
, rValue
, nMin
,
988 rFrameSize
.SetWidth( o3tl::narrowing
<sal_uInt16
>(nValue
) );
990 rFrameSize
.SetHeight( o3tl::narrowing
<sal_uInt16
>(nValue
) );
992 rFrameSize
.SetHeightSizeType( eSizeType
);
1000 if (IsXMLToken(rValue
, XML_BT_LR
))
1002 // Read bt-lr from the extension namespace, handle other values
1005 aAny
<<= static_cast<sal_uInt16
>(SvxFrameDirection::Vertical_LR_BT
);
1006 bOk
= rItem
.PutValue(aAny
, 0);
1008 else if (IsXMLToken(rValue
, XML_TB_RL90
))
1010 // Read tb-rl90 from the extension namespace.
1012 aAny
<<= static_cast<sal_uInt16
>(SvxFrameDirection::Vertical_RL_TB90
);
1013 bOk
= rItem
.PutValue(aAny
, 0);
1017 std::unique_ptr
<XMLPropertyHandler
> pWritingModeHandler
=
1018 XMLPropertyHandlerFactory::CreatePropertyHandler(
1019 XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
);
1021 bOk
= pWritingModeHandler
->importXML( rValue
, aAny
,
1024 bOk
= rItem
.PutValue( aAny
, 0 );
1029 case RES_COLLAPSING_BORDERS
:
1031 SfxBoolItem
& rBorders
= dynamic_cast<SfxBoolItem
&>(rItem
);
1033 if( IsXMLToken( rValue
, XML_COLLAPSING
) )
1035 rBorders
.SetValue(true);
1038 else if( IsXMLToken( rValue
, XML_SEPARATING
) )
1040 rBorders
.SetValue(false);
1049 OSL_FAIL("Item not implemented!");
1056 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */