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>
89 const Reference< xml::sax::XFastAttributeList >& xAttrList,
94 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
101 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
103 const Reference< xml::sax::XFastAttributeList >& xAttrList,
165 { sBulletFontStyleName = rSet; }
169 { eBulletFontEncoding = eSet; }
174 { eImageVertOrient = eSet; }
180 const Reference< xml::sax::XFastAttributeList > & xAttrList );
184 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
191 ePosAndSpaceMode = eValue;
195 eLabelFollowedBy = eValue;
199 nListtabStopPosition = nValue;
203 nFirstLineIndent = nValue;
211 constexpr OUStringLiteral
gsStarBats( u
"StarBats" );
212 constexpr OUStringLiteral
gsStarMath( u
"StarMath" );
216 const Reference< xml::sax::XFastAttributeList > & xAttrList )
222 , nMinLabelWidth( 0 )
226 , nNumStartValue( 1 )
227 , nNumDisplayLevels( 1 )
228 , eAdjust( HoriOrientation::
LEFT )
231 , eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW )
232 , eImageVertOrient(0)
236 , ePosAndSpaceMode( PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION )
237 , eLabelFollowedBy( LabelFollow::LISTTAB )
238 , nListtabStopPosition( 0 )
239 , nFirstLineIndent( 0 )
262 switch( aIter.getToken() )
275 if (!aIter.isEmpty())
306 sal_Int32 nTmp = aIter.toInt32();
308 (nTmp < 0) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
309 : static_cast<sal_Int16>(nTmp) );
315 sal_Int32 nTmp = aIter.toInt32();
317 (nTmp < 1) ? 1 : ( (nTmp>SHRT_MAX) ? SHRT_MAX
318 : static_cast<sal_Int16>(nTmp) );
329 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
354 sal_Int16
eType = NumberingType::NUMBER_NONE;
359 eType = NumberingType::CHAR_SPECIAL;
364 eType = NumberingType::BITMAP;
372 eType = NumberingType::ARABIC;
391 if (
GetImport().getBuildIds(nUPD, nBuildId)
394 || (310 == nUPD) || (320 == nUPD) || (330 == nUPD)
395 || ((300 == nUPD) && (nBuildId <= 9573))))
405 beans::PropertyValue *pProps = aPropSeq.getArray();
407 pProps[nPos].Name =
"NumberingType";
408 pProps[nPos++].Value <<= eType ;
410 pProps[nPos].Name =
"Prefix";
411 pProps[nPos++].Value <<=
sPrefix;
413 pProps[nPos].Name =
"Suffix";
414 pProps[nPos++].Value <<=
sSuffix;
416 pProps[nPos].Name =
"Adjust";
417 pProps[nPos++].Value <<=
eAdjust;
420 pProps[nPos].Name =
"LeftMargin";
421 pProps[nPos++].Value <<= nLeftMargin;
425 pProps[nPos].Name =
"FirstLineOffset";
426 pProps[nPos++].Value <<= nFirstLineOffset;
428 pProps[nPos].Name =
"SymbolTextDistance";
429 pProps[nPos++].Value <<=
static_cast<sal_Int16
>(
nMinLabelDist);
431 pProps[nPos].Name =
"PositionAndSpaceMode";
433 pProps[nPos].Name =
"LabelFollowedBy";
435 pProps[nPos].Name =
"ListtabStopPosition";
437 pProps[nPos].Name =
"FirstLineIndent";
439 pProps[nPos].Name =
"IndentAt";
444 pProps[nPos].Name =
"CharStyleName";
445 pProps[nPos++].Value <<= sDisplayTextStyleName;
449 awt::FontDescriptor aFDesc;
458 bool bStarSymbol =
false;
459 if( aFDesc.Name.equalsIgnoreAsciiCase(
gsStarBats ) )
464 else if( aFDesc.Name.equalsIgnoreAsciiCase(
gsStarMath ) )
470 aFDesc.Name =
"StarSymbol" ;
475 pProps[nPos].Name =
"BulletChar";
476 pProps[nPos++].Value <<= OUString(&
cBullet, 1);
478 pProps[nPos].Name =
"BulletFont";
479 pProps[nPos++].Value <<= aFDesc;
485 uno::Reference<graphic::XGraphic>
xGraphic;
495 uno::Reference<awt::XBitmap> xBitmap;
497 xBitmap.set(xGraphic, uno::UNO_QUERY);
501 pProps[nPos].Name =
"GraphicBitmap";
502 pProps[nPos++].Value <<= xBitmap;
506 pProps[nPos].Name =
"GraphicSize";
507 pProps[nPos++].Value <<= aSize;
509 pProps[nPos].Name =
"VertOrient";
515 pProps[nPos].Name =
"StartWith";
518 pProps[nPos].Name =
"ParentNumbering";
524 pProps[nPos].Name =
"BulletRelSize";
530 pProps[nPos].Name =
"BulletColor";
534 SAL_WARN_IF( nPos != nCount,
"xmloff",
"array under/overflow" );
540 SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
542 const Reference< xml::sax::XFastAttributeList > & xAttrList,
545 rListLevel( rLLevel )
549 OUString sFontName, sFontFamily, sFontStyleName, sFontFamilyGeneric,
550 sFontPitch, sFontCharset;
551 OUString sVerticalPos, sVerticalRel;
556 switch( aIter.getToken() )
559 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
563 if (rUnitConv.convertMeasureToCore( nVal, aIter.toView(), 0, SHRT_MAX ))
567 if (rUnitConv.convertMeasureToCore( nVal, aIter.toView(), 0,
USHRT_MAX ))
572 if( !aIter.isEmpty() )
574 sal_Int16
eAdjust = HoriOrientation::LEFT;
576 eAdjust = HoriOrientation::CENTER;
578 eAdjust = HoriOrientation::RIGHT;
579 rListLevel.SetAdjust( eAdjust );
590 sFontFamilyGeneric = aIter.
toString();
609 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView()))
614 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView()))
622 rListLevel.SetColor( nColor );
628 rListLevel.SetColor(COL_AUTO);
633 if (::
sax::Converter::convertPercent( nVal, aIter.toView() ))
634 rListLevel.
SetRelSize( static_cast<sal_Int16>(nVal) );
638 sal_Int16
ePosAndSpaceMode = PositionAndSpaceMode::LABEL_WIDTH_AND_POSITION;
640 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_ALIGNMENT;
641 rListLevel.SetPosAndSpaceMode( ePosAndSpaceMode );
649 if( !sFontName.isEmpty() )
655 ::std::vector < XMLPropertyState > aProps;
656 if( pFontDecls->
FillProperties( sFontName, aProps, 0, 1, 2, 3, 4 ) )
660 for(
const auto& rProp : aProps )
662 switch( rProp.mnIndex )
665 rProp.maValue >>= sTmp;
666 rListLevel.SetBulletFontName( sTmp);
669 rProp.maValue >>= sTmp;
670 rListLevel.SetBulletFontStyleName( sTmp );
673 rProp.maValue >>= nTmp;
674 rListLevel.SetBulletFontFamily( nTmp );
677 rProp.maValue >>= nTmp;
678 rListLevel.SetBulletFontPitch( nTmp );
681 rProp.maValue >>= nTmp;
682 rListLevel.SetBulletFontEncoding( nTmp );
689 if( !sFontFamily.isEmpty() )
694 if( aFamilyNameHdl.
importXML( sFontFamily, aAny, rUnitConv ) )
698 rListLevel.SetBulletFontName( sTmp);
702 if( !sFontFamilyGeneric.isEmpty() &&
703 aFamilyHdl.
importXML( sFontFamilyGeneric, aAny, rUnitConv ) )
707 rListLevel.SetBulletFontFamily( nTmp );
710 if( !sFontStyleName.isEmpty() )
711 rListLevel.SetBulletFontStyleName( sFontStyleName );
714 if( !sFontPitch.isEmpty() &&
715 aPitchHdl.
importXML( sFontPitch, aAny, rUnitConv ) )
719 rListLevel.SetBulletFontPitch( nTmp );
723 if( !sFontCharset.isEmpty() &&
724 aEncHdl.
importXML( sFontCharset, aAny, rUnitConv ) )
728 rListLevel.SetBulletFontEncoding( nTmp );
732 sal_Int16 eVertOrient = VertOrientation::LINE_CENTER;
733 if( !sVerticalPos.isEmpty() )
736 eVertOrient = VertOrientation::LINE_TOP;
738 eVertOrient = VertOrientation::LINE_BOTTOM;
740 if( !sVerticalRel.isEmpty() )
745 switch( eVertOrient )
747 case VertOrientation::LINE_TOP:
748 eVertOrient = VertOrientation::BOTTOM;
750 case VertOrientation::LINE_CENTER:
751 eVertOrient = VertOrientation::CENTER;
753 case VertOrientation::LINE_BOTTOM:
754 eVertOrient = VertOrientation::TOP;
760 switch( eVertOrient )
762 case VertOrientation::LINE_TOP:
763 eVertOrient = VertOrientation::CHAR_TOP;
765 case VertOrientation::LINE_CENTER:
766 eVertOrient = VertOrientation::CHAR_CENTER;
768 case VertOrientation::LINE_BOTTOM:
769 eVertOrient = VertOrientation::CHAR_BOTTOM;
774 rListLevel.SetImageVertOrient( eVertOrient );
777 css::uno::Reference< css::xml::sax::XFastContextHandler > SvxXMLListLevelStyleAttrContext_Impl::createFastChildContext(
779 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
783 return new SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl( GetImport(),
793 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
795 const Reference< xml::sax::XFastAttributeList > & xAttrList,
805 switch( aIter.getToken() )
810 if( eLabelFollowedBy == LabelFollow::NEWLINE)
814 eLabelFollowedBy = LabelFollow::SPACE;
816 eLabelFollowedBy = LabelFollow::NOTHING;
818 eLabelFollowedBy = LabelFollow::NEWLINE;
822 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), 0, SHRT_MAX))
827 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
832 if (rUnitConv.convertMeasureToCore(nVal, aIter.toView(), SHRT_MIN, SHRT_MAX))
855 constexpr OUStringLiteral
sIsPhysical( u
"IsPhysical" );
862 , bConsecutive( false )
871 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
882 pLevelStyles = std::make_unique<SvxXMLListStyle_Impl>();
892 const Reference<container::XIndexReplace> & rNumRule)
const
898 sal_Int32 l_nLevels = rNumRule->getCount();
901 sal_Int32 nLevel = pLevelStyle->GetLevel();
902 if( nLevel >= 0 && nLevel < l_nLevels )
905 pLevelStyle->GetProperties();
906 rNumRule->replaceByIndex( nLevel,
Any(aProps) );
912 Reference< XPropertySetInfo > xPropSetInfo;
914 xPropSetInfo = xPropSet->getPropertySetInfo();
915 if( xPropSetInfo.is() &&
933 const Reference< XIndexReplace >& rNumRule =
943 Reference < XStyle > xStyle;
945 if( rName.isEmpty() )
951 const Reference < XNameContainer >& rNumStyles =
953 if( !rNumStyles.is() )
960 if( rNumStyles->hasByName( rName ) )
962 Any aAny = rNumStyles->getByName( rName );
969 SAL_WARN_IF( !xFactory.is(),
"xmloff",
"no factory" );
973 Reference < XInterface > xIfc = xFactory->createInstance(
"com.sun.star.style.NumberingStyle");
976 Reference < XStyle > xTmp( xIfc, UNO_QUERY );
981 rNumStyles->insertByName( rName,
Any(xStyle) );
986 Reference< XPropertySetInfo > xPropSetInfo =
987 xPropSet->getPropertySetInfo();
988 if( !bNew && xPropSetInfo->hasPropertyByName(
sIsPhysical ) )
991 bNew = !*o3tl::doAccess<bool>(aAny);
994 if ( xPropSetInfo->hasPropertyByName(
"Hidden" ) )
995 xPropSet->setPropertyValue(
"Hidden", uno::makeAny(
IsHidden( ) ) );
1003 if( bOverwrite || bNew )
1022 const OUString& rName =
GetName();
1036 const Reference < XModel > & rModel )
1038 Reference<XIndexReplace> xNumRule;
1040 Reference< XMultiServiceFactory >
xFactory( rModel, UNO_QUERY );
1041 SAL_WARN_IF( !xFactory.is(),
"xmloff",
"no factory" );
1042 if( !xFactory.is() )
1045 Reference < XInterface > xIfc = xFactory->createInstance(
"com.sun.star.text.NumberingRules");
1049 xNumRule.set( xIfc, UNO_QUERY );
1050 SAL_WARN_IF( !xNumRule.is(),
"xmloff",
"go no numbering rule" );
1056 const Reference < XIndexReplace > & rNumRule,
1061 beans::PropertyValue *pProps = aPropSeq.getArray();
1063 pProps->Name =
"NumberingType";
1064 (pProps++)->
Value <<= static_cast<sal_Int16>(bOrdered ? NumberingType::ARABIC
1065 : NumberingType::CHAR_SPECIAL );
1069 awt::FontDescriptor aFDesc;
1079 aFDesc.CharSet = RTL_TEXTENCODING_SYMBOL ;
1081 pProps->Name =
"BulletFont";
1082 (pProps++)->
Value <<= aFDesc;
1084 pProps->Name =
"BulletChar";
1086 pProps->Name =
"CharStyleName";
1087 (pProps++)->
Value <<= OUString(
"Numbering Symbols" );
1090 rNumRule->replaceByIndex( nLevel,
Any(aPropSeq) );
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
SvxXMLListLevelStyleContext_Impl(SvXMLImport &rImport, sal_Int32 nElement, const Reference< xml::sax::XFastAttributeList > &xAttrList)
css::uno::Reference< css::graphic::XGraphic > loadGraphicFromBase64(css::uno::Reference< css::io::XOutputStream > const &rxOutputStream)
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
void SetRelSize(sal_Int16 nRel)
PropertyHandler for the XML-data-type:
void SetMinLabelWidth(sal_Int32 nSet)
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...
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
tools::Long const nLeftMargin
void FillUnoNumRule(const css::uno::Reference< css::container::XIndexReplace > &rNumRule) const
virtual void CreateAndInsertLate(bool bOverwrite) override
sal_Unicode ConvStarMathCharToStarSymbol(sal_Unicode c)
SvXMLImport & GetImport()
void SetIndentAt(sal_Int32 nValue)
void SetBulletFontStyleName(const OUString &rSet)
void SetSpaceBefore(sal_Int32 nSet)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
sal_Int32 nListtabStopPosition
constexpr OUStringLiteral sIsPhysical(u"IsPhysical")
css::uno::Reference< css::graphic::XGraphic > loadGraphicByURL(OUString const &rURL)
sal_Int16 eImageVertOrient
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
sal_Int32 nFirstLineOffset
constexpr OUStringLiteral sIsContinuousNumbering(u"IsContinuousNumbering")
Sequence< beans::PropertyValue > GetProperties()
~SvxXMLListStyleContext() override
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...
css::uno::Any const & rValue
SvxXMLListStyleContext(SvXMLImport &rImport, bool bOutl=false)
static const sal_uInt16 OOo_2x
void CreateAndInsertAuto() const
#define XMLOFF_WARN_UNKNOWN(area, rIter)
std::unique_ptr< SvxXMLListStyle_Impl > pLevelStyles
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...
css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const
sal_Int32 GetLevel() const
bool convertNumFormat(sal_Int16 &rType, const OUString &rNumFormat, std::u16string_view rNumLetterSync, bool bNumberNone=false) const
convert num-format and num-letter-sync values to NumberingType
PropertyHandler for the XML-data-type:
static css::uno::Reference< css::container::XIndexReplace > CreateNumRule(const css::uno::Reference< css::frame::XModel > &rModel)
sal_Int32 nFirstLineIndent
PropertyHandler for the XML-data-type:
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Reference< css::container::XIndexReplace > xNumRules
constexpr OUStringLiteral sNumberingRules(u"NumberingRules")
const OUString & GetDisplayName() const
void SetBulletFontFamily(sal_Int16 eSet)
virtual SAL_DLLPRIVATE void SetAttribute(sal_Int32 nElement, const OUString &rValue) override
void SetBulletFontName(const OUString &rSet)
sal_Unicode ConvStarBatsCharToStarSymbol(sal_Unicode c)
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...
void SetLabelFollowedBy(sal_Int16 eValue)
void SetBulletFontPitch(sal_Int16 eSet)
sal_Int16 nNumDisplayLevels
void SetPosAndSpaceMode(sal_Int16 eValue)
rtl_TextEncoding eBulletFontEncoding
virtual void SetAttribute(sal_Int32 nElement, const OUString &rValue)
void SetListtabStopPosition(sal_Int32 nValue)
static bool convertColor(sal_Int32 &rColor, std::u16string_view rValue)
void SetMinLabelDist(sal_Int32 nSet)
constexpr OUStringLiteral gsStarMath(u"StarMath")
constexpr T & temporary(T &&x)
This class deliberately does not support XWeak, to improve performance when loading large documents...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
void SetImageHeight(sal_Int32 nSet)
sal_Int16 eLabelFollowedBy
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
#define SAL_WARN_IF(condition, area, stream)
const OUString & GetName() const
sal_Int16 eBulletFontFamily
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Handling of tokens in XML:
void SetBulletFontEncoding(rtl_TextEncoding eSet)
static const sal_uInt16 OOo_1x
#define XML_ELEMENT(prefix, name)
const SvXMLUnitConverter & GetMM100UnitConverter() const
const css::uno::Reference< css::frame::XModel > & GetModel() const
OUString sBulletFontStyleName
Reference< XOutputStream > xBase64Stream
void AddStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName, const OUString &rDisplayName)
void SetImageWidth(sal_Int32 nSet)
friend SvxXMLListLevelStyleAttrContext_Impl
Reference< XSingleServiceFactory > xFactory
constexpr sal_Int32 TOKEN_MASK
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
sal_Int16 ePosAndSpaceMode
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
static void SetDefaultStyle(const css::uno::Reference< css::container::XIndexReplace > &rNumRule, sal_Int16 nLevel, bool bOrdered)
XMLFontStylesContext * GetFontDecls()
PropertyHandler for the XML-data-type:
sal_Int16 eBulletFontPitch
void SetImageVertOrient(sal_Int16 eSet)
Reference< XGraphic > xGraphic
void SetFirstLineIndent(sal_Int32 nValue)
void SetAdjust(sal_Int16 eSet)
void SetColor(Color nColor)
OUString toString(OptionInfo const *info)
constexpr OUStringLiteral gsStarBats(u"StarBats")