32 #include <osl/diagnose.h>
55 #include <com/sun/star/uno/Any.hxx>
57 using ::editeng::SvxBorderLine;
66 mrMapEntries( rMapEntries )
82 uno::Reference< xml::sax::XFastAttributeList >
const & xAttrList,
86 std::unique_ptr<SvXMLAttrContainerItem> pUnknownItem;
92 sal_Int32
nToken = aIter.getToken();
93 const OUString sValue = aIter.toString();
96 sal_Int32 nLookupToken = nToken;
118 if(eState >= SfxItemState::DEFAULT && pItem)
120 std::unique_ptr<SfxPoolItem> pNewItem(pItem->
Clone());
133 sValue, rUnitConverter );
137 rSet.
Put( *pNewItem );
141 OSL_FAIL(
"Could not get a needed item for xml import!" );
158 pUnknownItem.reset( static_cast<SvXMLAttrContainerItem*>( pItem->
Clone() ) );
173 if ( !rAttrNamespacePrefix.isEmpty() )
175 OUString aLocalName, aPrefix, aNamespace;
178 if ( !rAttrNamespacePrefix.isEmpty() )
179 pUnknownItem->AddAttr( rAttrNamespacePrefix, aNamespace, aLocalName,
182 pUnknownItem->AddAttr( aLocalName, sValue );
192 rSet.
Put( *pUnknownItem );
199 uno::Reference< xml::sax::XFastAttributeList >
const & xAttrList,
201 std::unique_ptr<SvXMLAttrContainerItem>& pUnknownItem)
203 const css::uno::Sequence< css::xml::Attribute > unknownAttributes = xAttrList->getUnknownAttributes();
204 for (
const auto & rAttribute : unknownAttributes)
212 pUnknownItem.reset( static_cast<SvXMLAttrContainerItem*>( pItem->
Clone() ) );
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);
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 );
260 OSL_FAIL(
"unsupported special item in xml import" );
272 OSL_FAIL(
"unsupported no item in xml import" );
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;
297 pTop.reset(
new SvxBorderLine( *rBox.
GetTop() ));
299 pBottom.reset(
new SvxBorderLine( *rBox.
GetBottom() ));
301 pLeft.reset(
new SvxBorderLine( *rBox.
GetLeft() ));
303 pRight.reset(
new SvxBorderLine( *rBox.
GetRight() ));
312 const OUString& rValue,
313 sal_uInt16 nMemberId,
318 switch (rItem.
Which())
329 sal_Int32 nProp = 100;
332 if( rValue.indexOf(
'%' ) != -1 )
342 rLRSpace.
SetTextLeft( nAbs, static_cast<sal_uInt16>(nProp) );
345 rLRSpace.
SetRight( nAbs, static_cast<sal_uInt16>(nProp) );
354 sal_Int32 nProp = 100;
357 if( rValue.indexOf(
'%' ) != -1 )
369 bool bAutoFirst(
false);
377 OSL_FAIL(
"unknown member id!");
386 sal_Int32 nProp = 100;
389 if( rValue.indexOf(
'%' ) != -1 )
397 rULSpace.
SetUpper( static_cast<sal_uInt16>(nAbs), static_cast<sal_uInt16>(nProp) );
400 rULSpace.
SetLower( static_cast<sal_uInt16>(nAbs), static_cast<sal_uInt16>(nProp) );
403 OSL_FAIL(
"unknown MemberId");
412 bool bColorFound =
false;
413 bool bOffsetFound =
false;
417 Color aColor( 128,128, 128 );
418 rShadow.
SetLocation( SvxShadowLocation::BottomRight );
420 std::u16string_view aToken;
428 else if( !bColorFound && aToken.substr(0,1) ==
u"#" )
436 else if( !bOffsetFound )
438 sal_Int32 nX = 0, nY = 0;
454 rShadow.
SetLocation( SvxShadowLocation::BottomLeft );
461 rShadow.
SetLocation( SvxShadowLocation::TopRight );
465 rShadow.
SetLocation( SvxShadowLocation::BottomRight );
469 if( nX < 0 ) nX *= -1;
470 if( nY < 0 ) nY *= -1;
472 rShadow.
SetWidth( static_cast< sal_uInt16 >( (nX + nY) >> 1 ) );
477 if( bOk && ( bColorFound || bOffsetFound ) )
491 BoxHolder aBoxes(rBox);
510 rBox.
SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::LEFT );
513 rBox.
SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::RIGHT );
516 rBox.
SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::TOP );
519 rBox.
SetDistance( static_cast<sal_uInt16>(nTemp), SvxBoxItemLine::BOTTOM);
528 bool bHasStyle =
false;
529 bool bHasWidth =
false;
530 bool bHasColor =
false;
533 sal_uInt16 nWidth = 0;
540 bHasWidth, nWidth, nNamedWidth,
541 bHasColor, aColor ) )
547 bHasWidth, nWidth, nNamedWidth,
553 bHasWidth, nWidth, nNamedWidth,
559 bHasWidth, nWidth, nNamedWidth,
565 bHasWidth, nWidth, nNamedWidth,
577 sal_Int32 nInWidth, nDistance, nOutWidth;
579 std::u16string_view aToken;
599 sal_uInt16 nWidth = 0;
604 static_cast< sal_uInt16 >( nOutWidth ),
605 static_cast< sal_uInt16 >( nInWidth ),
606 static_cast< sal_uInt16 >( nDistance ) );
611 static_cast< sal_uInt16 >( nOutWidth ),
612 static_cast< sal_uInt16 >( nInWidth ),
613 static_cast< sal_uInt16 >( nDistance ) );
618 static_cast< sal_uInt16 >( nOutWidth ),
619 static_cast< sal_uInt16 >( nInWidth ),
620 static_cast< sal_uInt16 >( nDistance ) );
625 static_cast< sal_uInt16 >( nOutWidth ),
626 static_cast< sal_uInt16 >( nInWidth ),
627 static_cast< sal_uInt16 >( nDistance ) );
632 rBox.
SetLine( aBoxes.pTop.get(), SvxBoxItemLine::TOP );
633 rBox.
SetLine( aBoxes.pBottom.get(), SvxBoxItemLine::BOTTOM );
634 rBox.
SetLine( aBoxes.pLeft.get(), SvxBoxItemLine::LEFT );
635 rBox.
SetLine( aBoxes.pRight.get(), SvxBoxItemLine::RIGHT );
651 rFormatBreak.SetValue( SvxBreak::NONE );
659 rFormatBreak.SetValue( eEnum == 1 ?
660 SvxBreak::ColumnBefore :
661 SvxBreak::PageBefore );
664 rFormatBreak.SetValue( eEnum == 1 ?
665 SvxBreak::ColumnAfter :
666 SvxBreak::PageAfter );
681 rFormatKeep.SetValue(
true );
687 rFormatKeep.SetValue(
false );
734 std::u16string_view aToken;
735 bool bHori =
false, bVert =
false;
743 else if( std::u16string_view::npos != aToken.find(
'%' ) )
833 if( bOk && nVal > 0 )
834 rPageDesc.
SetNumOffset( static_cast<sal_uInt16>(nVal) );
881 else if(rValue.isEmpty())
893 bool bSetHeight =
false;
894 bool bSetWidth =
false;
895 bool bSetSizeType =
false;
909 else if( nValue > 100 )
938 sal_Int32
nPos = rValue.indexOf(
'*' );
941 sal_Int32
nValue = rValue.toInt32();
947 rFrameSize.
SetWidth( static_cast<sal_uInt16>(nValue) );
955 if( bSetHeight || bSetWidth )
963 rFrameSize.
SetWidth( static_cast<sal_uInt16>(nValue) );
965 rFrameSize.
SetHeight( static_cast<sal_uInt16>(nValue) );
980 aAny <<= static_cast<sal_uInt16>(SvxFrameDirection::Vertical_LR_BT);
985 std::unique_ptr<XMLPropertyHandler> pWritingModeHandler =
989 bOk = pWritingModeHandler->importXML( rValue, aAny,
1017 OSL_FAIL(
"Item not implemented!");
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
void SetAlpha(sal_uInt8 nAlpha)
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
void SetHeight(tools::Long n)
void sw_frmitems_MergeXMLHoriPos(SvxGraphicPosition &ePos, SvxGraphicPosition eHori)
SvXMLImportItemMapper(SvXMLItemMapEntriesRef const &rMapEntries)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
SvXMLItemMapEntry const * getByName(sal_Int32 nElement) const
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
static std::unique_ptr< XMLPropertyHandler > CreatePropertyHandler(sal_Int32 nType)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
#define MID_FRMSIZE_MIN_HEIGHT
virtual bool handleNoItem(const SvXMLItemMapEntry &rEntry, SfxItemSet &rSet, const OUString &rValue, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap)
this method is called for every item that has the MID_SW_FLAG_NO_ITEM_IMPORT flag set ...
#define MID_FRMSIZE_REL_WIDTH
void SetColor(const Color &rNew)
#define LEFT_BORDER_PADDING
#define MID_PAGEDESC_PAGENUMOFFSET
constexpr sal_uInt16 XML_NAMESPACE_FO_COMPAT
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
const editeng::SvxBorderLine * GetRight() const
css::chart::ChartAxisLabelPosition ePos
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
#define MID_FIRST_LINE_INDENT
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableVAlignMap[]
Value in Var-direction gives minimum (can be exceeded but not be less).
const struct SvXMLEnumMapEntry< SvxGraphicPosition > psXML_BrushVertPos[]
#define TOP_BORDER_LINE_WIDTH
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
bool sw_frmitems_parseXMLBorder(std::u16string_view rValue, const SvXMLUnitConverter &rUnitConverter, bool &rHasStyle, sal_uInt16 &rStyle, bool &rHasWidth, sal_uInt16 &rWidth, sal_uInt16 &rNamedWidth, bool &rHasColor, Color &rColor)
Define various helper variables and functions for xmlimpit.cxx and xmlexpit.cxx.
#define ALL_BORDER_LINE_WIDTH
const sal_uInt16 XML_NAMESPACE_XMLNS
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
SvxGraphicPosition GetGraphicPos() const
#define XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
static constexpr OUStringLiteral aNamespaceSeparator
#define MID_FRMSIZE_REL_COL_WIDTH
#define MID_FRMSIZE_FIX_HEIGHT
#define MID_GRAPHIC_REPEAT
virtual void setMapEntries(SvXMLItemMapEntriesRef rMapEntries)
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
constexpr sal_uInt16 nUnknownWhich
void SetColor(const Color &rCol)
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableAlignMap[]
const Color & GetColor() const
#define MID_FRMSIZE_WIDTH
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define BOTTOM_BORDER_PADDING
bool getNextToken(std::u16string_view &rToken)
SvXMLItemMapEntriesRef mrMapEntries
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(124)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
#define TOP_BORDER_PADDING
static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap *pMap)
virtual void finished(SfxItemSet &rSet, SvXMLUnitConverter const &rUnitConverter) const
This method is called when all attributes have benn processed.
void SetDistance(sal_uInt16 nNew, SvxBoxItemLine nLine)
virtual ~SvXMLImportItemMapper()
void importXMLUnknownAttributes(SfxItemSet &rSet, css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, const SvXMLUnitConverter &rUnitConverter, std::unique_ptr< SvXMLAttrContainerItem > &pUnknownItem)
#define MID_GRAPHIC_POSITION
const sal_uInt16 XML_NAMESPACE_NONE
static bool PutXMLValue(SfxPoolItem &rItem, const OUString &rValue, sal_uInt16 nMemberId, const SvXMLUnitConverter &rUnitConverter)
This method is called for every item that should be set based upon an XML attribute value...
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
bool sw_frmitems_setXMLBorder(std::unique_ptr< SvxBorderLine > &rpLine, bool bHasStyle, sal_uInt16 nStyle, bool bHasWidth, sal_uInt16 nWidth, sal_uInt16 nNamedWidth, bool bHasColor, const Color &rColor)
SfxItemPool * GetPool() const
Frame cannot be moved in Var-direction.
#define MID_SW_FLAG_SPECIAL_ITEM_IMPORT
void SetValue(bool const bTheValue)
void SetWidth(tools::Long n)
static bool convertBool(bool &rBool, std::u16string_view rString)
static const OUString & getNameFromToken(sal_Int32 nToken)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
virtual bool handleSpecialItem(const SvXMLItemMapEntry &rEntry, SfxPoolItem &rItem, SfxItemSet &rSet, const OUString &rValue, const SvXMLUnitConverter &rUnitConverter)
this method is called for every item that has the MID_SW_FLAG_SPECIAL_ITEM_IMPORT flag set ...
#define ALL_BORDER_PADDING
void SetGraphicPos(SvxGraphicPosition eNew)
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
#define MID_SW_FLAG_NO_ITEM_IMPORT
#define LEFT_BORDER_LINE_WIDTH
#define RIGHT_BORDER_LINE_WIDTH
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
#define RIGHT_BORDER_PADDING
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
void importXML(SfxItemSet &rSet, css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, const SvXMLUnitConverter &rUnitConverter, const SvXMLNamespaceMap &rNamespaceMap)
fills the given itemset with the attributes in the given list
void SetWidth(sal_uInt16 nNew)
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
void SetLocation(SvxShadowLocation eNew)
const struct SvXMLEnumMapEntry< SvxGraphicPosition > psXML_BrushHoriPos[]
#define XML_ELEMENT(prefix, name)
void SetGraphicFilter(const OUString &rNew)
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
void sw_frmitems_MergeXMLVertPos(SvxGraphicPosition &ePos, SvxGraphicPosition eVert)
#define MID_GRAPHIC_FILTER
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
const struct SvXMLEnumMapEntry< sal_uInt16 > psXML_BreakType[]
#define SAL_WARN(area, stream)
constexpr sal_Int32 TOKEN_MASK
void SetNumOffset(const ::std::optional< sal_uInt16 > &oNum)
#define MID_FRMSIZE_COL_WIDTH
Frame is variable in Var-direction.
void SetAutoFirst(const bool bNew)
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
#define MID_SW_FLAG_ELEMENT_ITEM_IMPORT
const editeng::SvxBorderLine * GetBottom() const
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
#define BOTTOM_BORDER_LINE_WIDTH
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(107)
static bool IsWhich(sal_uInt16 nId)
const struct SvXMLEnumMapEntry< SvxGraphicPosition > psXML_BrushRepeat[]
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)