32#include <osl/diagnose.h>
55#include <com/sun/star/uno/Any.hxx>
57using ::editeng::SvxBorderLine;
66 mrMapEntries(
std::move( aMapEntries ))
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( std::move(pNewItem) );
141 OSL_FAIL(
"Could not get a needed item for xml import!" );
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;
178 if ( !rAttrNamespacePrefix.isEmpty() )
179 pUnknownItem->AddAttr( rAttrNamespacePrefix, aNamespace, aLocalName,
182 pUnknownItem->AddAttr( aLocalName, sValue );
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)
221 if( rAttribute.NamespaceURL.isEmpty() )
222 pUnknownItem->AddAttr( rAttribute.Name, rAttribute.Value );
226 OUString
sName = rAttribute.Name;
227 int i =
sName.indexOf(
':');
234 if (
sName.indexOf(
':') == -1)
235 pUnknownItem->AddAttr(
sPrefix, rAttribute.NamespaceURL,
sName,
238 SAL_WARN(
"sw",
"ignoring dodgy attribute: " + rAttribute.Name);
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())
335 sal_Int32 nProp = 100;
338 if( rValue.indexOf(
'%' ) != -1 )
348 rLRSpace.
SetTextLeft( nAbs, o3tl::narrowing<sal_uInt16>(nProp) );
351 rLRSpace.
SetRight( nAbs, o3tl::narrowing<sal_uInt16>(nProp) );
361 sal_Int32 nProp = 100;
364 if( rValue.indexOf(
'%' ) != -1 )
377 bool bAutoFirst(
false);
385 OSL_FAIL(
"unknown member id!");
394 sal_Int32 nProp = 100;
397 if( rValue.indexOf(
'%' ) != -1 )
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");
420 bool bColorFound =
false;
421 bool bOffsetFound =
false;
425 Color aColor( 128,128, 128 );
426 rShadow.
SetLocation( SvxShadowLocation::BottomRight );
428 std::u16string_view aToken;
436 else if( !bColorFound && aToken.substr(0,1) ==
u"#" )
444 else if( !bOffsetFound )
446 sal_Int32 nX = 0, nY = 0;
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 ) )
499 BoxHolder aBoxes(rBox);
518 rBox.
SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::LEFT );
521 rBox.
SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::RIGHT );
524 rBox.
SetDistance( o3tl::narrowing<sal_uInt16>(nTemp), SvxBoxItemLine::TOP );
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;
548 bHasWidth, nWidth, nNamedWidth,
549 bHasColor, aColor ) )
555 bHasWidth, nWidth, nNamedWidth,
561 bHasWidth, nWidth, nNamedWidth,
567 bHasWidth, nWidth, nNamedWidth,
573 bHasWidth, nWidth, nNamedWidth,
585 sal_Int32 nInWidth, nDistance, nOutWidth;
587 std::u16string_view aToken;
607 sal_uInt16 nWidth = 0;
612 static_cast< sal_uInt16
>( nOutWidth ),
613 static_cast< sal_uInt16
>( nInWidth ),
614 static_cast< sal_uInt16
>( nDistance ) );
619 static_cast< sal_uInt16
>( nOutWidth ),
620 static_cast< sal_uInt16
>( nInWidth ),
621 static_cast< sal_uInt16
>( nDistance ) );
626 static_cast< sal_uInt16
>( nOutWidth ),
627 static_cast< sal_uInt16
>( nInWidth ),
628 static_cast< sal_uInt16
>( nDistance ) );
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 );
659 rFormatBreak.SetValue( SvxBreak::NONE );
667 rFormatBreak.SetValue( eEnum == 1 ?
668 SvxBreak::ColumnBefore :
669 SvxBreak::PageBefore );
672 rFormatBreak.SetValue( eEnum == 1 ?
673 SvxBreak::ColumnAfter :
674 SvxBreak::PageAfter );
689 rFormatKeep.SetValue(
true );
695 rFormatKeep.SetValue(
false );
742 std::u16string_view aToken;
743 bool bHori =
false, bVert =
false;
751 else if( std::u16string_view::npos != aToken.find(
'%' ) )
837 nVal, rValue, 0, USHRT_MAX);
841 if( bOk && nVal > 0 )
842 rPageDesc.
SetNumOffset( o3tl::narrowing<sal_uInt16>(nVal) );
873 rHasTextChangesOnly.
SetValue(
true );
878 rHasTextChangesOnly.
SetValue(
false );
906 else if(rValue.isEmpty())
918 bool bSetHeight =
false;
919 bool bSetWidth =
false;
920 bool bSetSizeType =
false;
963 sal_Int32
nPos = rValue.indexOf(
'*' );
966 sal_Int32
nValue = rValue.toInt32();
980 if( bSetHeight || bSetWidth )
1005 aAny <<= static_cast<sal_uInt16>(SvxFrameDirection::Vertical_LR_BT);
1012 aAny <<= static_cast<sal_uInt16>(SvxFrameDirection::Vertical_RL_TB90);
1017 std::unique_ptr<XMLPropertyHandler> pWritingModeHandler =
1021 bOk = pWritingModeHandler->importXML( rValue, aAny,
1049 OSL_FAIL(
"Item not implemented!");
css::chart::ChartAxisLabelPosition ePos
void SetAlpha(sal_uInt8 nAlpha)
void SetValue(bool const bTheValue)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
static bool IsWhich(sal_uInt16 nId)
SfxItemPool * GetPool() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
SvXMLImportItemMapper(SvXMLItemMapEntriesRef aMapEntries)
virtual void setMapEntries(SvXMLItemMapEntriesRef rMapEntries)
void importXMLUnknownAttributes(SfxItemSet &rSet, css::uno::Reference< css::xml::sax::XFastAttributeList > const &xAttrList, const SvXMLUnitConverter &rUnitConverter, std::unique_ptr< SvXMLAttrContainerItem > &pUnknownItem)
SvXMLItemMapEntriesRef mrMapEntries
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.
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
virtual void finished(SfxItemSet &rSet, SvXMLUnitConverter const &rUnitConverter) const
This method is called when all attributes have benn processed.
virtual ~SvXMLImportItemMapper()
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
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
sal_uInt16 GetKeyByAttrName(const OUString &rAttrName, OUString *pPrefix, OUString *pLocalName, OUString *pNamespace) const
bool getNextToken(std::u16string_view &rToken)
static bool convertEnum(EnumT &rEnum, std::u16string_view rValue, const SvXMLEnumMapEntry< EnumT > *pMap)
bool convertMeasureToCore(sal_Int32 &rValue, std::u16string_view rString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32) const
const editeng::SvxBorderLine * GetTop() const
const editeng::SvxBorderLine * GetRight() const
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetLeft() const
void SetDistance(sal_Int16 nNew, SvxBoxItemLine nLine)
const editeng::SvxBorderLine * GetBottom() const
void SetGraphicPos(SvxGraphicPosition eNew)
const Color & GetColor() const
void SetColor(const Color &rCol)
SvxGraphicPosition GetGraphicPos() const
void SetGraphicFilter(const OUString &rNew)
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp=100)
void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp=100)
void SetAutoFirst(const bool bNew)
void SetLocation(SvxShadowLocation eNew)
void SetWidth(sal_uInt16 nNew)
void SetColor(const Color &rNew)
void SetHeight(tools::Long n)
void SetWidth(tools::Long n)
void SetLower(const sal_uInt16 nL, const sal_uInt16 nProp=100)
void SetUpper(const sal_uInt16 nU, const sal_uInt16 nProp=100)
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
void SetNumOffset(const ::std::optional< sal_uInt16 > &oNum)
static std::unique_ptr< XMLPropertyHandler > CreatePropertyHandler(sal_Int32 nType)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertBool(bool &rBool, std::u16string_view rString)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
@ Fixed
Frame cannot be moved in Var-direction.
@ Variable
Frame is variable in Var-direction.
@ Minimum
Value in Var-direction gives minimum (can be exceeded but not be less).
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(126)
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(116)
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(128)
constexpr TypedWhichId< SvxFirstLineIndentItem > RES_MARGIN_FIRSTLINE(91)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(109)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(113)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(119)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(131)
constexpr TypedWhichId< SvxBoxItem > RES_BOX(112)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SvxRightMarginItem > RES_MARGIN_RIGHT(93)
constexpr TypedWhichId< SvxTextLeftMarginItem > RES_MARGIN_TEXTLEFT(92)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(104)
#define SAL_WARN(area, stream)
#define MID_GRAPHIC_REPEAT
#define MID_GRAPHIC_POSITION
#define MID_FIRST_LINE_INDENT
#define MID_GRAPHIC_FILTER
const sal_uInt16 XML_NAMESPACE_NONE
const sal_uInt16 XML_NAMESPACE_XMLNS
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
#define MID_FRMSIZE_REL_COL_WIDTH
#define MID_FRMSIZE_MIN_HEIGHT
#define MID_FRMSIZE_FIX_HEIGHT
#define MID_FRMSIZE_REL_WIDTH
#define MID_FRMSIZE_WIDTH
#define MID_PAGEDESC_PAGENUMOFFSET
#define MID_FRMSIZE_COL_WIDTH
#define ALL_BORDER_PADDING
#define TOP_BORDER_LINE_WIDTH
#define BOTTOM_BORDER_PADDING
#define BOTTOM_BORDER_LINE_WIDTH
#define ALL_BORDER_LINE_WIDTH
#define LEFT_BORDER_PADDING
#define LEFT_BORDER_LINE_WIDTH
#define RIGHT_BORDER_PADDING
#define RIGHT_BORDER_LINE_WIDTH
#define TOP_BORDER_PADDING
#define XML_ELEMENT(prefix, name)
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
constexpr sal_Int32 TOKEN_MASK
constexpr sal_uInt16 nUnknownWhich
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableVAlignMap[]
const struct SvXMLEnumMapEntry< sal_Int16 > aXMLTableAlignMap[]
const struct SvXMLEnumMapEntry< SvxGraphicPosition > psXML_BrushHoriPos[]
void sw_frmitems_MergeXMLVertPos(SvxGraphicPosition &ePos, SvxGraphicPosition eVert)
const struct SvXMLEnumMapEntry< SvxGraphicPosition > psXML_BrushVertPos[]
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.
const struct SvXMLEnumMapEntry< sal_uInt16 > psXML_BreakType[]
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)
const struct SvXMLEnumMapEntry< SvxGraphicPosition > psXML_BrushRepeat[]
void sw_frmitems_MergeXMLHoriPos(SvxGraphicPosition &ePos, SvxGraphicPosition eHori)
#define MID_SW_FLAG_SPECIAL_ITEM_IMPORT
#define MID_SW_FLAG_NO_ITEM_IMPORT
#define MID_SW_FLAG_ELEMENT_ITEM_IMPORT
constexpr sal_uInt16 XML_NAMESPACE_FO_COMPAT
#define XML_TYPE_TEXT_WRITING_MODE_WITH_DEFAULT