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,
170 { sBulletFontStyleName = rSet; }
174 { eBulletFontEncoding = eSet; }
179 { eImageVertOrient = eSet; }
185 const Reference< xml::sax::XFastAttributeList > & xAttrList );
189 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
override;
196 ePosAndSpaceMode = eValue;
200 eLabelFollowedBy = eValue;
204 nListtabStopPosition = nValue;
208 nFirstLineIndent = nValue;
216 constexpr OUStringLiteral
gsStarBats( u
"StarBats" );
217 constexpr OUStringLiteral
gsStarMath( u
"StarMath" );
221 const Reference< xml::sax::XFastAttributeList > & xAttrList )
227 , nMinLabelWidth( 0 )
231 , nNumStartValue( 1 )
232 , nNumDisplayLevels( 1 )
233 , eAdjust( HoriOrientation::
LEFT )
236 , eBulletFontEncoding( RTL_TEXTENCODING_DONTKNOW )
237 , eImageVertOrient(0)
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 )
368 sal_Int16
eType = NumberingType::NUMBER_NONE;
373 eType = NumberingType::CHAR_SPECIAL;
377 eType = NumberingType::BITMAP;
381 eType = NumberingType::ARABIC;
391 if (
GetImport().getBuildIds(nUPD, nBuildId)
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);
528 SvxXMLListLevelStyleAttrContext_Impl::SvxXMLListLevelStyleAttrContext_Impl(
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;
628 ePosAndSpaceMode = PositionAndSpaceMode::LABEL_ALIGNMENT;
629 rListLevel.SetPosAndSpaceMode( ePosAndSpaceMode );
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 );
765 css::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(),
781 SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl::SvxXMLListLevelStyleLabelAlignmentAttrContext_Impl(
783 const Reference< xml::sax::XFastAttributeList > & xAttrList,
793 switch( aIter.getToken() )
798 if( eLabelFollowedBy == LabelFollow::NEWLINE)
802 eLabelFollowedBy = LabelFollow::SPACE;
804 eLabelFollowedBy = LabelFollow::NOTHING;
806 eLabelFollowedBy = LabelFollow::NEWLINE;
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 )
843 constexpr OUStringLiteral
sIsPhysical( u
"IsPhysical" );
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 )
893 pLevelStyle->GetProperties();
894 rNumRule->replaceByIndex( nLevel,
Any(aProps) );
900 Reference< XPropertySetInfo > xPropSetInfo;
902 xPropSetInfo = xPropSet->getPropertySetInfo();
903 if( xPropSetInfo.is() &&
921 const Reference< XIndexReplace >& rNumRule =
931 Reference < XStyle > xStyle;
933 if( rName.isEmpty() )
939 const Reference < XNameContainer >& rNumStyles =
941 if( !rNumStyles.is() )
948 if( rNumStyles->hasByName( rName ) )
950 Any aAny = rNumStyles->getByName( rName );
957 SAL_WARN_IF( !xFactory.is(),
"xmloff",
"no factory" );
961 Reference < XInterface > xIfc = xFactory->createInstance(
"com.sun.star.style.NumberingStyle");
964 Reference < XStyle > xTmp( xIfc, UNO_QUERY );
969 rNumStyles->insertByName( rName,
Any(xStyle) );
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 );
1029 SAL_WARN_IF( !xFactory.is(),
"xmloff",
"no factory" );
1030 if( !xFactory.is() )
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,
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) );
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
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
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...
SvxXMLListStyleContext(SvXMLImport &rImport, bool bOutl=false)
static const sal_uInt16 OOo_2x
PropertiesInfo aProperties
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")
std::optional< OUString > sListFormat
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
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Handling of tokens in XML:
void SetBulletFontEncoding(rtl_TextEncoding eSet)
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
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
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)
void SetFirstLineIndent(sal_Int32 nValue)
void SetAdjust(sal_Int16 eSet)
void SetColor(Color nColor)
OUString toString(OptionInfo const *info)
constexpr OUStringLiteral gsStarBats(u"StarBats")
bool m_bDetectedRangeSegmentation false