20#include <com/sun/star/beans/PropertyValue.hpp>
21#include <com/sun/star/beans/XPropertySet.hpp>
22#include <com/sun/star/awt/Size.hpp>
23#include <com/sun/star/frame/XModel.hpp>
24#include <com/sun/star/graphic/XGraphic.hpp>
25#include <com/sun/star/awt/FontDescriptor.hpp>
26#include <com/sun/star/text/HoriOrientation.hpp>
27#include <com/sun/star/text/VertOrientation.hpp>
28#include <com/sun/star/text/PositionAndSpaceMode.hpp>
29#include <com/sun/star/text/LabelFollow.hpp>
30#include <com/sun/star/container/XNameContainer.hpp>
31#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32#include <com/sun/star/style/XStyle.hpp>
33#include <com/sun/star/io/XOutputStream.hpp>
34#include <com/sun/star/awt/XBitmap.hpp>
35#include <com/sun/star/style/NumberingType.hpp>
36#include <com/sun/star/container/XIndexReplace.hpp>
40#include <rtl/ustrbuf.hxx>
92 const Reference< xml::sax::XFastAttributeList >& xAttrList,
97 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
104 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
106 const Reference< xml::sax::XFastAttributeList >& xAttrList,
185 const Reference< xml::sax::XFastAttributeList > & xAttrList );
189 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
220 SvXMLImport& rImport, sal_Int32 nElement,
221 const Reference< xml::sax::XFastAttributeList > & xAttrList )
232, nNumDisplayLevels( 1 )
233, eAdjust( HoriOrientation::
LEFT )
236, eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW )
241, ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
242, eLabelFollowedBy( LabelFollow::LISTTAB )
243, nListtabStopPosition( 0 )
244, nFirstLineIndent( 0 )
267 switch( aIter.getToken() )
280 if (!aIter.isEmpty())
306 sListFormat = std::make_optional(aIter.toString());
315 sal_Int32 nTmp = aIter.toInt32();
317 (nTmp < 0) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
318 :
static_cast<sal_Int16
>(nTmp) );
324 sal_Int32 nTmp = aIter.toInt32();
326 (nTmp < 1) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
327 :
static_cast<sal_Int16
>(nTmp) );
338 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
365 return Sequence<beans::PropertyValue>();
368 sal_Int16
eType = NumberingType::NUMBER_NONE;
373 eType = NumberingType::CHAR_SPECIAL;
377 eType = NumberingType::BITMAP;
381 eType = NumberingType::ARABIC;
382 GetImport().GetMM100UnitConverter().convertNumFormat(
391 if (
GetImport().getBuildIds(nUPD, nBuildId)
392 && ( (SvXMLImport::OOo_1x ==
nVersion)
393 || (SvXMLImport::OOo_2x ==
nVersion)
394 || (310 == nUPD) || (320 == nUPD) || (330 == nUPD)
395 || ((300 == nUPD) && (nBuildId <= 9573))))
451 awt::FontDescriptor aFDesc;
460 bool bStarSymbol =
false;
461 if( aFDesc.Name.equalsIgnoreAsciiCase(
gsStarBats ) )
466 else if( aFDesc.Name.equalsIgnoreAsciiCase(
gsStarMath ) )
472 aFDesc.Name =
"StarSymbol" ;
483 uno::Reference<graphic::XGraphic> xGraphic;
493 uno::Reference<awt::XBitmap> xBitmap;
495 xBitmap.set(xGraphic, uno::UNO_QUERY);
528SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
529 SvXMLImport& rImport, sal_Int32 ,
530 const Reference< xml::sax::XFastAttributeList > & xAttrList,
533 rListLevel( rLLevel )
537 OUString sFontName, sFontFamily, sFontStyleName, sFontFamilyGeneric,
538 sFontPitch, sFontCharset;
539 OUString sVerticalPos, sVerticalRel;
544 switch( aIter.getToken() )
547 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
551 if (rUnitConv.convertMeasureToCore( nVal, aIter.toView(), 0, SHRT_MAX ))
555 if (rUnitConv.convertMeasureToCore( nVal, aIter.toView(), 0, USHRT_MAX ))
560 if( !aIter.isEmpty() )
562 sal_Int16
eAdjust = HoriOrientation::LEFT;
564 eAdjust = HoriOrientation::CENTER;
566 eAdjust = HoriOrientation::RIGHT;
567 rListLevel.SetAdjust(
eAdjust );
578 sFontFamilyGeneric = aIter.
toString();
597 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView()))
602 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView()))
610 rListLevel.SetColor( nColor );
616 rListLevel.SetColor(COL_AUTO);
621 if (::
sax::Converter::convertPercent( nVal, aIter.toView() ))
622 rListLevel.
SetRelSize( static_cast<sal_Int16>(nVal) );
626 sal_Int16
ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
637 if( !sFontName.isEmpty() )
643 ::std::vector < XMLPropertyState > aProps;
644 if( pFontDecls->
FillProperties( sFontName, aProps, 0, 1, 2, 3, 4 ) )
648 for(
const auto& rProp : aProps )
650 switch( rProp.mnIndex )
653 rProp.maValue >>= sTmp;
654 rListLevel.SetBulletFontName( sTmp);
657 rProp.maValue >>= sTmp;
658 rListLevel.SetBulletFontStyleName( sTmp );
661 rProp.maValue >>= nTmp;
662 rListLevel.SetBulletFontFamily( nTmp );
665 rProp.maValue >>= nTmp;
666 rListLevel.SetBulletFontPitch( nTmp );
669 rProp.maValue >>= nTmp;
670 rListLevel.SetBulletFontEncoding( nTmp );
677 if( !sFontFamily.isEmpty() )
682 if( aFamilyNameHdl.
importXML( sFontFamily, aAny, rUnitConv ) )
686 rListLevel.SetBulletFontName( sTmp);
690 if( !sFontFamilyGeneric.isEmpty() &&
691 aFamilyHdl.
importXML( sFontFamilyGeneric, aAny, rUnitConv ) )
695 rListLevel.SetBulletFontFamily( nTmp );
698 if( !sFontStyleName.isEmpty() )
699 rListLevel.SetBulletFontStyleName( sFontStyleName );
702 if( !sFontPitch.isEmpty() &&
703 aPitchHdl.
importXML( sFontPitch, aAny, rUnitConv ) )
707 rListLevel.SetBulletFontPitch( nTmp );
711 if( !sFontCharset.isEmpty() &&
712 aEncHdl.
importXML( sFontCharset, aAny, rUnitConv ) )
716 rListLevel.SetBulletFontEncoding( nTmp );
720 sal_Int16 eVertOrient = VertOrientation::LINE_CENTER;
721 if( !sVerticalPos.isEmpty() )
724 eVertOrient = VertOrientation::LINE_TOP;
726 eVertOrient = VertOrientation::LINE_BOTTOM;
728 if( !sVerticalRel.isEmpty() )
733 switch( eVertOrient )
735 case VertOrientation::LINE_TOP:
736 eVertOrient = VertOrientation::BOTTOM;
738 case VertOrientation::LINE_CENTER:
739 eVertOrient = VertOrientation::CENTER;
741 case VertOrientation::LINE_BOTTOM:
742 eVertOrient = VertOrientation::TOP;
748 switch( eVertOrient )
750 case VertOrientation::LINE_TOP:
751 eVertOrient = VertOrientation::CHAR_TOP;
753 case VertOrientation::LINE_CENTER:
754 eVertOrient = VertOrientation::CHAR_CENTER;
756 case VertOrientation::LINE_BOTTOM:
757 eVertOrient = VertOrientation::CHAR_BOTTOM;
762 rListLevel.SetImageVertOrient( eVertOrient );
765css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLListLevelStyleAttrContext_Impl::createFastChildContext(
767 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
771 return new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(),
781SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
782 SvXMLImport& rImport, sal_Int32 ,
783 const Reference< xml::sax::XFastAttributeList > & xAttrList,
793 switch( aIter.getToken() )
810 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), 0, SHRT_MAX))
815 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
820 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
831 const OUString& rValue )
850, bConsecutive( false )
859 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
870 pLevelStyles = std::make_unique<SvxXMLListStyle_Impl>();
880 const Reference<container::XIndexReplace> & rNumRule)
const
886 sal_Int32 l_nLevels = rNumRule->getCount();
889 sal_Int32 nLevel = pLevelStyle->GetLevel();
890 if( nLevel >= 0 && nLevel < l_nLevels )
892 Sequence<beans::PropertyValue> aProps =
893 pLevelStyle->GetProperties();
894 rNumRule->replaceByIndex( nLevel,
Any(aProps) );
899 Reference < XPropertySet > xPropSet( rNumRule, UNO_QUERY );
900 Reference< XPropertySetInfo > xPropSetInfo;
902 xPropSetInfo = xPropSet->getPropertySetInfo();
903 if( xPropSetInfo.is() &&
921 const Reference< XIndexReplace >& rNumRule =
922 GetImport().GetTextImport()->GetChapterNumbering();
931 Reference < XStyle > xStyle;
933 if( rName.isEmpty() )
939 const Reference < XNameContainer >& rNumStyles =
940 GetImport().GetTextImport()->GetNumberingStyles();
941 if( !rNumStyles.is() )
948 if( rNumStyles->hasByName( rName ) )
950 Any aAny = rNumStyles->getByName( rName );
961 Reference < XInterface > xIfc =
xFactory->createInstance(
"com.sun.star.style.NumberingStyle");
964 Reference < XStyle > xTmp( xIfc, UNO_QUERY );
969 rNumStyles->insertByName( rName,
Any(xStyle) );
973 Reference < XPropertySet > xPropSet( xStyle, UNO_QUERY );
974 Reference< XPropertySetInfo > xPropSetInfo =
975 xPropSet->getPropertySetInfo();
976 if( !bNew && xPropSetInfo->hasPropertyByName(
sIsPhysical ) )
979 bNew = !*o3tl::doAccess<bool>(aAny);
982 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
991 if( bOverwrite || bNew )
1010 const OUString& rName =
GetName();
1024 const Reference < XModel > & rModel )
1026 Reference<XIndexReplace> xNumRule;
1028 Reference< XMultiServiceFactory >
xFactory( rModel, UNO_QUERY );
1033 Reference < XInterface > xIfc =
xFactory->createInstance(
"com.sun.star.text.NumberingRules");
1037 xNumRule.set( xIfc, UNO_QUERY );
1038 SAL_WARN_IF( !xNumRule.is(),
"xmloff",
"go no numbering rule" );
1044 const Reference < XIndexReplace > & rNumRule,
1048 Sequence<beans::PropertyValue> aPropSeq( bOrdered ? 1 : 4 );
1049 beans::PropertyValue *pProps = aPropSeq.getArray();
1051 pProps->Name =
"NumberingType";
1052 (pProps++)->
Value <<=
static_cast<sal_Int16
>(bOrdered ? NumberingType::ARABIC
1053 : NumberingType::CHAR_SPECIAL );
1057 awt::FontDescriptor aFDesc;
1067 aFDesc.CharSet = RTL_TEXTENCODING_SYMBOL ;
1069 pProps->Name =
"BulletFont";
1070 (pProps++)->
Value <<= aFDesc;
1072 pProps->Name =
"BulletChar";
1074 pProps->Name =
"CharStyleName";
1075 (pProps++)->
Value <<= OUString(
"Numbering Symbols" );
1078 rNumRule->replaceByIndex( nLevel,
Any(aPropSeq) );
PropertiesInfo aProperties
This class deliberately does not support XWeak, to improve performance when loading large documents.
SvXMLImport & GetImport()
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue)
const OUString & GetName() const
const OUString & GetDisplayName() const
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
void SetRelSize(sal_Int16 nRel)
void SetListtabStopPosition(sal_Int32 nValue)
void SetMinLabelDist(sal_Int32 nSet)
sal_Int32 nListtabStopPosition
void SetBulletFontPitch(sal_Int16 eSet)
void SetIndentAt(sal_Int32 nValue)
std::optional< OUString > sListFormat
sal_Int16 nNumDisplayLevels
Sequence< beans::PropertyValue > GetProperties()
SvxXMLListLevelStyleContext_Impl(SvXMLImport &rImport, sal_Int32 nElement, const Reference< xml::sax::XFastAttributeList > &xAttrList)
sal_Int32 GetLevel() const
sal_Int32 nFirstLineIndent
sal_Int16 eLabelFollowedBy
void SetBulletFontFamily(sal_Int16 eSet)
void SetImageVertOrient(sal_Int16 eSet)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
sal_Int16 ePosAndSpaceMode
void SetImageHeight(sal_Int32 nSet)
sal_Int16 eBulletFontPitch
void SetSpaceBefore(sal_Int32 nSet)
sal_Int16 eImageVertOrient
rtl_TextEncoding eBulletFontEncoding
void SetLabelFollowedBy(sal_Int16 eValue)
friend SvxXMLListLevelStyleAttrContext_Impl
void SetFirstLineIndent(sal_Int32 nValue)
sal_Int16 eBulletFontFamily
void SetBulletFontEncoding(rtl_TextEncoding eSet)
void SetBulletFontName(const OUString &rSet)
OUString sBulletFontStyleName
void SetMinLabelWidth(sal_Int32 nSet)
void SetBulletFontStyleName(const OUString &rSet)
void SetPosAndSpaceMode(sal_Int16 eValue)
Reference< XOutputStream > xBase64Stream
void SetAdjust(sal_Int16 eSet)
void SetColor(Color nColor)
void SetImageWidth(sal_Int32 nSet)
void FillUnoNumRule(const css::uno::Reference< css::container::XIndexReplace > &rNumRule) const
std::unique_ptr< SvxXMLListStyle_Impl > pLevelStyles
css::uno::Reference< css::container::XIndexReplace > xNumRules
static css::uno::Reference< css::container::XIndexReplace > CreateNumRule(const css::uno::Reference< css::frame::XModel > &rModel)
virtual SAL_DLLPRIVATE void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
SvxXMLListStyleContext(SvXMLImport &rImport, bool bOutl=false)
static void SetDefaultStyle(const css::uno::Reference< css::container::XIndexReplace > &rNumRule, sal_Int16 nLevel, bool bOrdered)
void CreateAndInsertAuto() const
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual void CreateAndInsertLate(bool bOverwrite) override
~SvxXMLListStyleContext() override
PropertyHandler for the XML-data-type:
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
PropertyHandler for the XML-data-type:
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
PropertyHandler for the XML-data-type:
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
PropertyHandler for the XML-data-type:
virtual bool importXML(const OUString &rStrImpValue, css::uno::Any &rValue, const SvXMLUnitConverter &rUnitConverter) const override
Imports the given value according to the XML-data-type corresponding to the derived class.
bool FillProperties(const OUString &rName, ::std::vector< XMLPropertyState > &rProps, sal_Int32 nFamilyNameIdx, sal_Int32 nStyleNameIdx, sal_Int32 nFamilyIdx, sal_Int32 nPitchIdx, sal_Int32 nCharsetIdx) const
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
#define TOOLS_WARN_EXCEPTION(area, stream)
Reference< XSingleServiceFactory > xFactory
sal_Int32 nFirstLineOffset
#define SAL_WARN_IF(condition, area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
tools::Long const nLeftMargin
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr T & temporary(T &&x)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OUString toString(OptionInfo const *info)
Handling of tokens in XML:
@ XML_LIST_LEVEL_STYLE_IMAGE
@ XML_LIST_LEVEL_PROPERTIES
@ XML_LIST_LEVEL_STYLE_NUMBER
@ XML_LIST_TAB_STOP_POSITION
@ XML_CONSECUTIVE_NUMBERING
@ XML_FONT_FAMILY_GENERIC
@ XML_LIST_LEVEL_POSITION_AND_SPACE_MODE
@ XML_LIST_LEVEL_STYLE_BULLET
@ XML_USE_WINDOW_FONT_COLOR
@ XML_OUTLINE_LEVEL_STYLE
@ XML_LIST_LEVEL_LABEL_ALIGNMENT
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr sal_Int32 TOKEN_MASK
constexpr OUStringLiteral gsStarBats(u"StarBats")
constexpr OUStringLiteral sIsContinuousNumbering(u"IsContinuousNumbering")
constexpr OUStringLiteral sNumberingRules(u"NumberingRules")
constexpr OUStringLiteral sIsPhysical(u"IsPhysical")
constexpr OUStringLiteral gsStarMath(u"StarMath")