27#include <ooxml/resourceids.hxx>
29#include <com/sun/star/lang/XMultiServiceFactory.hpp>
30#include <com/sun/star/container/XNameContainer.hpp>
31#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
32#include <com/sun/star/style/NumberingType.hpp>
33#include <com/sun/star/text/HoriOrientation.hpp>
34#include <com/sun/star/text/PositionAndSpaceMode.hpp>
35#include <com/sun/star/text/XChapterNumberingSupplier.hpp>
36#include <com/sun/star/graphic/XGraphic.hpp>
37#include <com/sun/star/awt/XBitmap.hpp>
39#include <osl/diagnose.h>
40#include <rtl/ustring.hxx>
64 sal_Int32 nLen = aProps.getLength( );
67 while (
nPos == -1 &&
i < nLen )
81 for (
const auto& rProp : aSrc )
88 aDst.getArray()[
nPos] = rProp;
93 aDst.realloc( aDst.getLength( ) + 1 );
94 aDst.getArray()[ aDst.getLength( ) - 1 ] = rProp;
104 case NS_ooxml::LN_CT_Lvl_start:
107 case NS_ooxml::LN_CT_NumLvl_startOverride:
110 case NS_ooxml::LN_CT_NumFmt_val:
113 case NS_ooxml::LN_CT_Lvl_isLgl:
116 case NS_ooxml::LN_CT_Lvl_legacy:
118 case NS_ooxml::LN_CT_Lvl_suff:
121 case NS_ooxml::LN_CT_TabStop_pos:
125 "unsupported list tab stop position " <<
nValue);
131 OSL_FAIL(
"this line should never be reached");
166 return (
aStr==
u"Adjust" ||
aStr==
u"IndentAt" ||
aStr==
u"FirstLineIndent"
167 ||
aStr==
u"FirstLineOffset" ||
aStr==
u"LeftMargin"
170 || (bIsSymbol &&
aStr==
u"CharFontName")
179 for(
const auto& rPropNal : vPropVals )
181 rProperties.emplace_back(rPropNal.Name, 0, rPropNal.Value, beans::PropertyState_DIRECT_VALUE);
188 std::vector<beans::PropertyValue> aNumberingProperties;
193 aNumberingProperties.push_back(lcl_makePropVal<sal_Int16>(
PROP_START_WITH, 0));
195 sal_Int16 nNumberFormat = -1;
196 if (
m_nNFC == NS_ooxml::LN_Value_ST_NumberFormat_custom)
207 nNumberFormat = style::NumberingType::BITMAP;
212 if( nNumberFormat == style::NumberingType::CHAR_SPECIAL )
221 aNumberingProperties.push_back(lcl_makePropVal<sal_Unicode>(
PROP_BULLET_CHAR, 0));
255 std::optional<PropertyMap::Property> aProp =
getProperty(rReadId);
257 aNumberingProperties.emplace_back(
getPropertyName(aProp->first), 0, aProp->second, beans::PropertyState_DIRECT_VALUE );
260 aNumberingProperties.emplace_back(
"FirstLineIndent", 0,
uno::Any(
static_cast<sal_Int32
>(0)), beans::PropertyState_DIRECT_VALUE);
263 aNumberingProperties.emplace_back(
"IndentAt", 0,
264 uno::Any(
static_cast<sal_Int32
>(0)),
265 beans::PropertyState_DIRECT_VALUE);
291 if( hasFirstLineIndent && hasIndentAt )
304 for (
const auto& rParaProp : aParaProps )
306 if ( !hasFirstLineIndent && rParaProp.Name == sParaIndent )
308 aProps.realloc( aProps.getLength() + 1 );
309 auto pProps = aProps.getArray();
310 pProps[aProps.getLength( ) - 1] = rParaProp;
311 pProps[aProps.getLength( ) - 1].Name = sFirstLineIndent;
313 else if ( !hasIndentAt && rParaProp.Name == sParaLeftMargin )
315 aProps.realloc( aProps.getLength() + 1 );
316 auto pProps = aProps.getArray();
317 pProps[aProps.getLength( ) - 1] = rParaProp;
318 pProps[aProps.getLength( ) - 1].Name = sIndentAt;
359 case NS_ooxml::LN_CT_AbstractNum_tmpl:
362 OSL_FAIL(
"this line should never be reached");
393 for (
int i = 0;
i < nLevels;
i++ )
396 aResult[
i] =
m_aLevels[
i]->GetProperties(bDefaults);
426 OUString sStyleName =
"WWNum" + OUString::number( nId );
428 while (xStyles->hasByName(sStyleName))
451 auto aAbstractRange = asNonConstRange(aAbstract);
458 sal_Int32 nThisCount = aThis.getLength( );
459 sal_Int32 nAbstractCount = aAbstract.getLength( );
460 for ( sal_Int32
i = 0;
i < nThisCount &&
i < nAbstractCount;
i++ )
463 if (level.hasElements() &&
GetLevel(
i)->HasValues())
481 uno::Any oFamily = xFamilies->getStyleFamilies( )->getByName(
"NumberingStyles");
485 catch (
const uno::Exception & )
495 sal_Int16 nWeight = 0;
497 for (
sal_Int8 nLevel = 0; nLevel < nAbstLevels; ++nLevel)
511 else if (pAbsLevel->GetNumberingType(style::NumberingType::NUMBER_NONE)
512 != style::NumberingType::NUMBER_NONE)
516 sal_uInt16 nWeightingFactor =
GetId() == 1 ? 8 : 1;
517 if (pParaStyle->m_sStyleIdentifierD.startsWith(
"Heading") )
519 nWeight += nWeightingFactor;
538 if (
GetId() == nOutline)
541 xStyles->insertByName(
543 css::uno::Any(
xFactory->createInstance(
"com.sun.star.style.NumberingStyle")));
555 sal_Int32 nLevel = 0;
556 while ( nLevel < nAbstLevels )
562 auto aLvlProps = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(aProps[nLevel]);
565 auto aAbsCharStyleProps = pAbsLevel
566 ? pAbsLevel->GetCharStyleProperties()
572 pLevel->GetCharStyleProperties( );
579 = comphelper::sequenceToContainer<PropertyValueVector_t>(aAbsCharStyleProps);
587 OUString sText = pAbsLevel
588 ? pAbsLevel->GetBulletChar()
591 if (pLevel && pLevel->HasBulletChar())
592 sText = pLevel->GetBulletChar( );
602 if (
GetId() == nOutline && pAbsLevel && pAbsLevel->GetParaStyle())
607 xOutlines->getChapterNumberingRules( );
610 pParaStyle->m_bAssignedAsChapterNumbering =
true;
623 catch(
const lang::IllegalArgumentException& )
626 assert( !
"Incorrect argument to UNO call" );
628 catch(
const uno::RuntimeException& )
631 assert( !
"Incorrect argument to UNO call" );
633 catch(
const uno::Exception& )
647 , m_rDMapper(rDMapper)
662 xShape = rNumPicBullet->GetShape();
666 xShapeComponent->dispose();
675 if (nName != NS_ooxml::LN_CT_NumPicBullet_numPicBulletId)
688 int nIntValue = rVal.
getInt();
693 case NS_ooxml::LN_CT_LevelText_val:
701 std::string sLevelText( rVal.
getString().replace(0xad, 0x2d).toUtf8() );
705 static const std::regex aTokenRegex(
"(%\\d)");
706 sLevelText = std::regex_replace(sLevelText, aTokenRegex,
"$1%");
707 pCurrentLvl->SetBulletChar( OUString::fromUtf8(sLevelText) );
711 case NS_ooxml::LN_CT_Lvl_start:
712 case NS_ooxml::LN_CT_Lvl_numFmt:
713 case NS_ooxml::LN_CT_NumFmt_format:
714 case NS_ooxml::LN_CT_NumFmt_val:
715 case NS_ooxml::LN_CT_Lvl_isLgl:
716 case NS_ooxml::LN_CT_Lvl_legacy:
719 if (nName == NS_ooxml::LN_CT_NumFmt_format)
721 pCurrentLvl->SetCustomNumberFormat(rVal.
getString());
725 pCurrentLvl->SetValue(nName, sal_Int32(nIntValue));
729 case NS_ooxml::LN_CT_Num_numId:
732 case NS_ooxml::LN_CT_AbstractNum_nsid:
735 case NS_ooxml::LN_CT_AbstractNum_tmpl:
738 case NS_ooxml::LN_CT_NumLvl_ilvl:
742 case NS_ooxml::LN_CT_Lvl_ilvl:
745 case NS_ooxml::LN_CT_AbstractNum_abstractNumId:
749 sal_Int32 nVal = rVal.
getString().toInt32();
753 case NS_ooxml::LN_CT_Ind_start:
754 case NS_ooxml::LN_CT_Ind_left:
759 case NS_ooxml::LN_CT_Ind_hanging:
764 case NS_ooxml::LN_CT_Ind_firstLine:
769 case NS_ooxml::LN_CT_Lvl_tplc:
770 case NS_ooxml::LN_CT_Lvl_tentative:
772 case NS_ooxml::LN_CT_TabStop_pos:
776 pCurrentLvl->SetValue( nName,
780 case NS_ooxml::LN_CT_TabStop_val:
785 case NS_ooxml::LN_CT_NumPicBullet_numPicBulletId:
789 SAL_WARN(
"writerfilter",
"ListsManager::lcl_attribute: unhandled token: " << nName);
796 sal_uInt32 nSprmId = rSprm.
getId();
798 nSprmId == NS_ooxml::LN_CT_Numbering_abstractNum ||
799 nSprmId == NS_ooxml::LN_CT_Numbering_num ||
801 nSprmId == NS_ooxml::LN_CT_Numbering_numPicBullet))
804 static bool bIsStartVisited =
false;
805 sal_Int32 nIntValue = rSprm.
getValue()->getInt();
808 case NS_ooxml::LN_CT_Numbering_abstractNum:
816 pProperties->resolve( *
this );
823 case NS_ooxml::LN_CT_Numbering_num:
832 pProperties->resolve( *
this );
840 case NS_ooxml::LN_CT_Numbering_numPicBullet:
847 pProperties->resolve(*
this);
853 case NS_ooxml::LN_CT_NumPicBullet_pict:
860 case NS_ooxml::LN_CT_Lvl_lvlPicBulletId:
866 if (rNumPicBullet->GetId() == nIntValue)
868 xShape = rNumPicBullet->GetShape();
877 uno::Any aAny = xPropertySet->getPropertyValue(
"Graphic");
884 pCurrentLevel->SetGraphicBitmap(xBitmap);
888 catch (
const beans::UnknownPropertyException&)
892 awt::Size aPrefSize = xShape->getSize();
893 if ( aPrefSize.Height * aPrefSize.Width != 0 )
896 const int nFontHeight = 14;
898 const int nHeight = nFontHeight * 35;
899 int nWidth = (nHeight * aPrefSize.Width) / aPrefSize.Height;
902 pCurrentLevel->SetGraphicSize( aSize );
907 pCurrentLevel->SetGraphicSize( aSize );
912 case NS_ooxml::LN_CT_Num_abstractNumId:
914 sal_Int32 nAbstractNumId = rSprm.
getValue()->getInt();
916 if ( pListDef !=
nullptr )
924 case NS_ooxml::LN_CT_AbstractNum_multiLevelType:
926 case NS_ooxml::LN_CT_AbstractNum_tmpl:
929 case NS_ooxml::LN_CT_AbstractNum_lvl:
933 pProperties->resolve(*
this);
936 case NS_ooxml::LN_CT_Lvl_start:
938 pCurrentLevel->SetValue( nSprmId, nIntValue );
939 bIsStartVisited =
true;
941 case NS_ooxml::LN_CT_Lvl_numFmt:
946 pProperties->resolve(*
this);
950 if( !bIsStartVisited )
952 pCurrentLevel->SetValue( NS_ooxml::LN_CT_Lvl_start, 0 );
953 bIsStartVisited =
true;
958 case NS_ooxml::LN_CT_Lvl_isLgl:
959 case NS_ooxml::LN_CT_Lvl_legacy:
962 pCurrentLevel->SetValue(nSprmId, nIntValue);
965 case NS_ooxml::LN_CT_Lvl_suff:
970 if( rSprm.
getValue()->getString() ==
"tab" )
972 else if( rSprm.
getValue()->getString() ==
"space" )
974 else if( rSprm.
getValue()->getString() ==
"nothing" )
977 SAL_WARN(
"writerfilter",
"Unknown ST_LevelSuffix value "
979 pCurrentLevel->SetValue( nSprmId,
value );
983 case NS_ooxml::LN_CT_Lvl_lvlText:
984 case NS_ooxml::LN_CT_Lvl_rPr :
988 pProperties->resolve(*
this);
991 case NS_ooxml::LN_CT_NumLvl_lvl:
996 pProperties->resolve(*
this);
999 case NS_ooxml::LN_CT_Lvl_lvlJc:
1004 case NS_ooxml::LN_Value_ST_Jc_left:
1005 case NS_ooxml::LN_Value_ST_Jc_start:
1006 nValue = text::HoriOrientation::LEFT;
1008 case NS_ooxml::LN_Value_ST_Jc_center:
1009 nValue = text::HoriOrientation::CENTER;
1011 case NS_ooxml::LN_Value_ST_Jc_right:
1012 case NS_ooxml::LN_Value_ST_Jc_end:
1013 nValue = text::HoriOrientation::RIGHT;
1027 case NS_ooxml::LN_CT_Lvl_pPr:
1028 case NS_ooxml::LN_CT_PPrBase_ind:
1033 pProperties->resolve(*
this);
1036 case NS_ooxml::LN_CT_PPrBase_tabs:
1037 case NS_ooxml::LN_CT_Tabs_tab:
1041 pProperties->resolve(*
this);
1044 case NS_ooxml::LN_CT_Lvl_pStyle:
1046 OUString sStyleName = rSprm.
getValue( )->getString( );
1051 pLevel->SetParaStyle( pStyle );
1055 case NS_ooxml::LN_CT_Num_lvlOverride:
1059 pProperties->resolve(*
this);
1062 case NS_ooxml::LN_CT_NumLvl_startOverride:
1068 pCurrentLevel->SetValue(NS_ooxml::LN_CT_NumLvl_startOverride, nIntValue);
1073 case NS_ooxml::LN_CT_AbstractNum_numStyleLink:
1075 OUString sStyleName = rSprm.
getValue( )->getString( );
1079 case NS_ooxml::LN_CT_AbstractNum_styleLink:
1081 OUString sStyleName = rSprm.
getValue()->getString();
1085 case NS_ooxml::LN_EG_RPrBase_rFonts:
1086 case NS_ooxml::LN_EG_RPrBase_color:
1087 case NS_ooxml::LN_EG_RPrBase_u:
1088 case NS_ooxml::LN_EG_RPrBase_sz:
1089 case NS_ooxml::LN_EG_RPrBase_lang:
1090 case NS_ooxml::LN_EG_RPrBase_eastAsianLayout:
1106 ref->resolve(*
this);
1113 ref->resolve(*
this);
1124 if (listDef->GetId( ) ==
nId)
1126 if (listDef->GetNumStyleLink().getLength() > 0)
1132 pStylesTable->FindStyleSheetByISTD(listDef->GetNumStyleLink() );
1135 pStyleSheetEntry ? pStyleSheetEntry->m_pProperties.
get() :
nullptr;
1137 if( pStyleSheetProperties && pStyleSheetProperties->
props().
GetListId() >= 0 )
1140 if ( pList!=
nullptr )
1141 return pList->GetAbstractDefinition();
1147 if (baseListDef->GetStyleLink() == listDef->GetNumStyleLink())
1170 while ( !pList &&
i < nLen )
1187 sal_Int16 nChosenAsChapterNumberingId = -1;
1188 sal_uInt16 nHighestWeight = 5;
1191 sal_uInt16 nWeight = rList->GetChapterNumberingWeight();
1192 if (nWeight > nHighestWeight)
1194 nHighestWeight = nWeight;
1195 nChosenAsChapterNumberingId = rList->GetId();
1197 if (nHighestWeight > 17)
1203 for (
const auto& rList :
m_aLists )
std::vector< css::beans::PropertyValue > PropertyValueVector_t
css::uno::Any getProperty(sal_Int32 nPropId)
static const OUString & getPropertyName(sal_Int32 nPropId)
void sprm(Sprm &sprm) override
Receives a SPRM.
An SPRM: Section, Paragraph and Run Modifier.
virtual sal_uInt32 getId() const =0
Returns id of the SPRM.
virtual writerfilter::Reference< Properties >::Pointer_t getProps()=0
Returns reference to properties contained in the SPRM.
virtual Value::Pointer_t getValue()=0
Returns value of the SPRM.
virtual int getInt() const =0
Returns integer representation of the value.
virtual OUString getString() const =0
Returns string representation of the value.
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetPropertyValues(bool bDefaults)
static void SetValue(sal_uInt32 nSprmId)
tools::SvRef< AbstractListDef > Pointer
::std::vector< ListLevel::Pointer > m_aLevels
void AddLevel(sal_uInt16 nLvl)
ListLevel::Pointer GetLevel(sal_uInt16 nLvl)
std::optional< OUString > m_oListId
list id to use for all derived numbering definitions
virtual ~AbstractListDef() override
ListLevel::Pointer m_pCurrentLevel
const OUString & MapListId(OUString const &rId)
bool IsOOXMLImport() const
css::uno::Reference< css::drawing::XShape > PopPendingShape()
Return the first from the pending (not inserted to the document) shapes, if there are any.
StyleSheetTablePtr const & GetStyleSheetTable()
OUString getOrCreateCharStyle(PropertyValueVector_t &rCharProperties, bool bAlwaysCreate)
void PushListProperties(const ::tools::SvRef< PropertyMap > &pListProperties)
void SetAbstractDefinition(AbstractListDef::Pointer pAbstract)
sal_uInt16 GetChapterNumberingWeight() const
Rank the list in terms of suitability for becoming the Outline numbering rule in LO.
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetMergedPropertyValues()
void CreateNumberingRules(DomainMapper &rDMapper, css::uno::Reference< css::lang::XMultiServiceFactory > const &xFactory, sal_Int16 nOutline)
const OUString & GetStyleName() const
AbstractListDef::Pointer m_pAbstractDef
css::uno::Reference< css::container::XIndexReplace > m_xNumRules
OUString m_StyleName
mapped list style name
virtual ~ListDef() override
Class representing the numbering level properties.
tools::SvRef< StyleSheetEntry > m_pParaStyle
css::uno::Reference< css::awt::XBitmap > m_xGraphicBitmap
std::optional< sal_Int32 > m_nTabstop
sal_Int16 GetNumberingType(sal_Int16 nDefault) const
void SetCustomNumberFormat(const OUString &rValue)
css::uno::Sequence< css::beans::PropertyValue > GetProperties(bool bDefaults)
css::uno::Sequence< css::beans::PropertyValue > GetCharStyleProperties()
sal_Int32 m_nStartOverride
css::uno::Sequence< css::beans::PropertyValue > GetLevelProperties(bool bDefaults)
OUString m_aCustomNumberFormat
LN_CT_NumFmt_format, in case m_nNFC is custom.
void SetParaStyle(const tools::SvRef< StyleSheetEntry > &pStyle)
void AddParaProperties(css::uno::Sequence< css::beans::PropertyValue > *pProps)
css::awt::Size m_aGraphicSize
OUString GetBulletChar() const
std::optional< OUString > m_sBulletChar
void SetValue(Id nId, sal_Int32 nValue)
bool HasValues() const
Determines if SetValue() was called at least once.
virtual void lcl_attribute(Id nName, Value &rVal) override
std::vector< NumPicBullet::Pointer > m_aNumPicBullets
NumPicBullet::Pointer m_pCurrentNumPicBullet
std::vector< AbstractListDef::Pointer > m_aAbstractLists
std::vector< ListDef::Pointer > m_aLists
void CreateNumberingRules()
ListDef::Pointer GetList(sal_Int32 nId)
AbstractListDef::Pointer m_pCurrentDefinition
virtual void lcl_sprm(Sprm &sprm) override
DomainMapper & m_rDMapper
ListsManager(DomainMapper &rDMapper, css::uno::Reference< css::lang::XMultiServiceFactory > xFactory)
AbstractListDef::Pointer GetAbstractList(sal_Int32 nId)
void DisposeNumPicBullets()
css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory
virtual ~ListsManager() override
virtual void lcl_entry(writerfilter::Reference< Properties >::Pointer_t ref) override
Represents a numbering picture bullet: an id and a graphic.
void SetId(sal_Int32 nId)
css::uno::Reference< css::drawing::XShape > m_xShape
tools::SvRef< NumPicBullet > Pointer
void SetShape(css::uno::Reference< css::drawing::XShape > const &xShape)
ParagraphProperties & props()
sal_Int32 GetListId() const
sal_Int16 GetOutlineLevel() const
sal_Int16 GetListLevel() const
#define TOOLS_WARN_EXCEPTION(area, stream)
virtual sal_uInt32 GetId() const override
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
double getLength(const B2DPolygon &rCandidate)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr auto toTwips(N number, Length from)
sal_Int16 ConvertNumberingType(const sal_Int32 nFmt, const sal_Int16 nDefault)
sal_Int32 convertTwipToMM100(sal_Int32 _t)
sal_Int16 ConvertCustomNumberFormat(std::u16string_view rFormat)
OUString getPropertyName(PropertyIds eId)
static uno::Reference< container::XNameContainer > lcl_getUnoNumberingStyles(uno::Reference< lang::XMultiServiceFactory > const &xFactory)
static void lcl_mergeProperties(const uno::Sequence< beans::PropertyValue > &aSrc, uno::Sequence< beans::PropertyValue > &aDst)
static bool IgnoreForCharStyle(std::u16string_view aStr, const bool bIsSymbol)
@ PROP_LISTTAB_STOP_POSITION
@ PROP_PARA_FIRST_LINE_INDENT
@ PROP_HEADING_STYLE_NAME
@ PROP_POSITION_AND_SPACE_MODE
static beans::PropertyValue lcl_makePropVal(PropertyIds nNameID, T const &aValue)
static sal_Int32 lcl_findProperty(const uno::Sequence< beans::PropertyValue > &aProps, std::u16string_view sName)