44 #include <unordered_map>
45 #include <libxml/xmlwriter.h>
47 #include <rtl/ustrbuf.hxx>
50 #include <osl/diagnose.h>
56 #include <com/sun/star/beans/PropertyValue.hpp>
63 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr } };
66 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr } };
70 1440/4, 1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2, 1440*7/4, 1440*2,
112 (*mpNumRuleMap)[rName] =
this;
135 tTextNodeList::iterator aIter =
146 tTextNodeList::iterator aIter =
163 OSL_ENSURE(
MAXLEVEL > nLvl,
"NumLevel is out of range" );
169 OSL_ENSURE(
MAXLEVEL > nLvl,
"NumLevel is out of range" );
189 SwClient( rFormat.GetRegisteredInNonConst() ),
191 ,m_cGrfBulletCP(rFormat.m_cGrfBulletCP)
206 const OUString rCharStyleName = rNumFormat.SvxNumberFormat::GetCharFormatName();
207 if( !rCharStyleName.isEmpty() )
218 pCFormat->
Add(
this );
276 pChFormat->
Add(
this );
289 switch(pLegacy->GetWhich())
312 const sal_Int16* pOrient)
331 for (
auto& rpTextNode : aTextNodeList )
340 if( bFnd && !bDocIsModified )
360 maParagraphStyleList(),
361 mpNumRuleMap(nullptr),
366 mnPoolHlpFileId( UCHAR_MAX ),
367 mbAutoRuleFlag( true ),
368 mbInvalidRuleFlag( true ),
369 mbContinusNum( false ),
370 mbAbsSpaces( false ),
372 mbCountPhantoms( true ),
373 mbUsedByRedline( false ),
374 meDefaultNumberFormatPositionAndSpaceMode( eDefaultNumberFormatPositionAndSpaceMode ),
393 SwNumRule::saBaseFormats[
NUM_RULE ][ n ] = pFormat;
402 1440/2, 1440*3/4, 1440, 1440*5/4, 1440*3/2,
403 1440*7/4, 1440*2, 1440*9/4, 1440*5/2, 1440*11/4 };
416 SwNumRule::saLabelAlignmentBaseFormats[
NUM_RULE ][ n ] = pFormat;
429 SwNumRule::saBaseFormats[
OUTLINE_RULE ][ n ] = pFormat;
440 SwNumRule::saLabelAlignmentBaseFormats[
OUTLINE_RULE ][ n ] = pFormat;
443 OSL_ENSURE( !
msName.isEmpty(),
"NumRule without a name!" );
448 maParagraphStyleList(),
449 mpNumRuleMap(nullptr),
451 meRuleType( rNumRule.meRuleType ),
452 mnPoolFormatId( rNumRule.GetPoolFormatId() ),
453 mnPoolHelpId( rNumRule.GetPoolHelpId() ),
454 mnPoolHlpFileId( rNumRule.GetPoolHlpFileId() ),
455 mbAutoRuleFlag( rNumRule.mbAutoRuleFlag ),
456 mbInvalidRuleFlag( true ),
457 mbContinusNum( rNumRule.mbContinusNum ),
458 mbAbsSpaces( rNumRule.mbAbsSpaces ),
459 mbHidden( rNumRule.mbHidden ),
460 mbCountPhantoms( true ),
461 mbUsedByRedline( false ),
462 meDefaultNumberFormatPositionAndSpaceMode( rNumRule.meDefaultNumberFormatPositionAndSpaceMode ),
463 msDefaultListId( rNumRule.msDefaultListId )
484 SwNumFormat** ppFormats = &SwNumRule::saBaseFormats[0][0];
487 for( n = 0; n <
MAXLEVEL; ++n, ++ppFormats )
490 *ppFormats =
nullptr;
494 for( n = 0; n <
MAXLEVEL; ++n, ++ppFormats )
497 *ppFormats =
nullptr;
500 ppFormats = &SwNumRule::saLabelAlignmentBaseFormats[0][0];
501 for( n = 0; n <
MAXLEVEL; ++n, ++ppFormats )
504 *ppFormats =
nullptr;
506 for( n = 0; n <
MAXLEVEL; ++n, ++ppFormats )
509 *ppFormats =
nullptr;
524 if( pFormat && pFormat->
GetDoc() != &rDoc )
529 rpNumFormat.reset(pNew);
537 if(
this != &rNumRule )
580 OSL_ENSURE( i <
MAXLEVEL,
"Serious defect" );
593 OSL_ENSURE( i <
MAXLEVEL,
"Serious defect" );
604 else if( !pNumFormat )
625 const bool bInclStrings,
626 const bool bOnlyArabic,
627 const unsigned int _nRestrictToThisLevel,
633 SwNumberTree::tNumberVector::size_type nLevel = rNumVector.size() - 1;
638 if ( nLevel > _nRestrictToThisLevel )
640 nLevel = _nRestrictToThisLevel;
645 const SwNumFormat& rMyNFormat =
Get( static_cast<sal_uInt16>(nLevel) );
655 for (SwNumberTree::tNumberVector::size_type
i=0;
i <= nLevel; ++
i)
657 OUString sReplacement;
661 sReplacement = OUString::number(rNumVector[i]);
663 sReplacement =
Get(i).
GetNumStr(rNumVector[i], aLocale);
668 OUString sFind(
"%" + OUString::number(i + 1));
669 sal_Int32 nPosition = sLevelFormat.indexOf(sFind);
671 sLevelFormat = sLevelFormat.replaceAt(nPosition, sFind.getLength(), sReplacement);
677 if (sLevelFormat.isEmpty())
686 SwNumberTree::tNumberVector::size_type
i = nLevel;
703 for (; i <= nLevel; ++i)
717 aStr.append(OUString::number(rNumVector[i]));
719 aStr.append(rNFormat.
GetNumStr(rNumVector[i], aLocale));
723 if (i != nLevel && !aStr.isEmpty())
729 if (bInclStrings && !bOnlyArabic &&
736 aStr.insert(0, sPrefix);
737 aStr.append(sSuffix);
748 return aStr.makeStringAndClear();
752 const bool bInclSuperiorNumLabels,
753 const int nRestrictInclToThisLevel )
const
759 bool bOldHadPrefix =
true;
761 const SwNodeNum* pWorkingNodeNum( &rNodeNum );
764 bool bMakeNumStringForPhantom(
false );
775 SwNumFormat aFormat(
Get( static_cast<sal_uInt16>(nListLevel) ) );
780 if ( bMakeNumStringForPhantom ||
789 sal_Int32 nStrip = 0;
793 if ( c!=
'\t' && c!=
' ')
800 aPrevStr = aPrevStr.copy( nStrip );
809 aPrevStr = aPrevStr.copy(0,
815 aRefNumStr = aPrevStr + aRefNumStr;
823 while ( pWorkingNodeNum && n > 1 )
833 }
while ( pWorkingNodeNum &&
843 OUString aParagraphStyleListString;
846 if (!aParagraphStyleListString.isEmpty())
847 aParagraphStyleListString +=
", ";
848 aParagraphStyleListString += rParagraphStyle->GetName();
850 return aParagraphStyleListString;
896 SvxNumRule aRule(SvxNumRuleFlags::CONTINUOUS | SvxNumRuleFlags::CHAR_STYLE |
897 SvxNumRuleFlags::ENABLE_LINKED_BMP | SvxNumRuleFlags::ENABLE_EMBEDDED_BMP,
899 meRuleType ==
NUM_RULE ? SvxNumRuleType::NUMBERING : SvxNumRuleType::OUTLINE_NUMBERING );
918 SwList* pList = pTextNode->GetDoc().getIDocumentListsAccess().getListByName( pTextNode->GetListId() );
919 OSL_ENSURE( pList,
"<SwNumRule::SetInvalidRule(..)> - list at which the text node is registered at does not exist. This is a serious issue.");
925 for (
auto aList : aLists )
926 aList->InvalidateListTree();
943 auto nNewIndent = nDiff +
945 if ( nNewIndent < 0 )
965 Set(
i, aTmpNumFormat );
973 const sal_uInt16 nListLevel )
1005 sal_Int32 nDiff( 0 );
1029 aLists.
insert( pTextNode->GetDoc().getIDocumentListsAccess().getListByName( pTextNode->GetListId() ) );
1031 for (
auto aList : aLists )
1032 aList->ValidateListTree();
1049 tParagraphStyleList::iterator aIter =
1060 tParagraphStyleList::iterator aIter =
1071 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwNumRule"));
1072 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"msName"), BAD_CAST(
msName.toUtf8().getStr()));
1073 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"mnPoolFormatId"), BAD_CAST(OString::number(
mnPoolFormatId).getStr()));
1074 xmlTextWriterWriteAttribute(pWriter, BAD_CAST(
"mbAutoRuleFlag"), BAD_CAST(OString::boolean(
mbAutoRuleFlag).getStr()));
1083 pFormat->dumpAsXml(pWriter);
1086 xmlTextWriterEndElement(pWriter);
1094 rVal <<= uno::Sequence<beans::PropertyValue>();
1113 static SwDefBulletConfig& getInstance();
1115 const OUString& GetFontname()
const
1120 bool IsFontnameUserDefined()
const
1140 SwDefBulletConfig();
1144 void SetToDefault();
1147 static uno::Sequence<OUString> GetPropNames();
1157 virtual void Notify(
const uno::Sequence<OUString>& aPropertyNames )
override;
1158 virtual void ImplCommit()
override;
1171 class theSwDefBulletConfig
1172 :
public rtl::Static<SwDefBulletConfig, theSwDefBulletConfig>{};
1175 SwDefBulletConfig& SwDefBulletConfig::getInstance()
1180 SwDefBulletConfig::SwDefBulletConfig()
1181 : ConfigItem(
"Office.Writer/Numbering/DefaultBulletList" ),
1193 EnableNotification( GetPropNames() );
1196 void SwDefBulletConfig::SetToDefault()
1215 uno::Sequence<OUString> SwDefBulletConfig::GetPropNames()
1219 pNames[0] =
"BulletFont/FontFamilyname";
1220 pNames[1] =
"BulletFont/FontWeight";
1221 pNames[2] =
"BulletFont/FontItalic";
1222 pNames[3] =
"BulletCharLvl1";
1223 pNames[4] =
"BulletCharLvl2";
1224 pNames[5] =
"BulletCharLvl3";
1225 pNames[6] =
"BulletCharLvl4";
1226 pNames[7] =
"BulletCharLvl5";
1227 pNames[8] =
"BulletCharLvl6";
1228 pNames[9] =
"BulletCharLvl7";
1229 pNames[10] =
"BulletCharLvl8";
1230 pNames[11] =
"BulletCharLvl9";
1231 pNames[12] =
"BulletCharLvl10";
1236 void SwDefBulletConfig::LoadConfig()
1238 uno::Sequence<OUString>
aPropNames = GetPropNames();
1239 uno::Sequence<uno::Any> aValues = GetProperties( aPropNames );
1241 OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1242 "<SwDefBulletConfig::SwDefBulletConfig()> - GetProperties failed");
1243 if ( aValues.getLength() != aPropNames.getLength() )
1246 for (
int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1248 if ( pValues[nProp].hasValue() )
1255 pValues[nProp] >>= aStr;
1264 pValues[nProp] >>= nTmp;
1267 else if ( nProp == 2 )
1283 pValues[nProp] >>= cChar;
1293 void SwDefBulletConfig::InitFont()
1298 mpFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
1308 void SwDefBulletConfig::ImplCommit()
1314 return SwDefBulletConfig::getInstance().GetFontname();
1319 return SwDefBulletConfig::getInstance().IsFontnameUserDefined();
1324 return SwDefBulletConfig::getInstance().GetFont();
1329 return SwDefBulletConfig::getInstance().GetChar( nLevel );
1342 static SwNumberingUIBehaviorConfig& getInstance();
1349 SwNumberingUIBehaviorConfig();
1354 void SetToDefault();
1357 static css::uno::Sequence<OUString> GetPropNames();
1363 virtual void Notify(
const css::uno::Sequence<OUString>& aPropertyNames )
override;
1370 class theSwNumberingUIBehaviorConfig :
public rtl::Static<SwNumberingUIBehaviorConfig, theSwNumberingUIBehaviorConfig>{};
1373 SwNumberingUIBehaviorConfig& SwNumberingUIBehaviorConfig::getInstance()
1378 SwNumberingUIBehaviorConfig::SwNumberingUIBehaviorConfig()
1379 : ConfigItem(
"Office.Writer/Numbering/UserInterfaceBehavior" ),
1386 EnableNotification( GetPropNames() );
1389 void SwNumberingUIBehaviorConfig::SetToDefault()
1394 css::uno::Sequence<OUString> SwNumberingUIBehaviorConfig::GetPropNames()
1396 css::uno::Sequence<OUString> aPropNames {
"ChangeIndentOnTabAtFirstPosOfFirstListItem" };
1401 void SwNumberingUIBehaviorConfig::ImplCommit() {}
1403 void SwNumberingUIBehaviorConfig::LoadConfig()
1405 css::uno::Sequence<OUString> aPropNames = GetPropNames();
1406 css::uno::Sequence<css::uno::Any> aValues = GetProperties( aPropNames );
1407 const css::uno::Any* pValues = aValues.getConstArray();
1408 OSL_ENSURE( aValues.getLength() == aPropNames.getLength(),
1409 "<SwNumberingUIBehaviorConfig::LoadConfig()> - GetProperties failed");
1410 if ( aValues.getLength() != aPropNames.getLength() )
1413 for (
int nProp = 0; nProp < aPropNames.getLength(); ++nProp )
1415 if ( pValues[nProp].hasValue() )
1426 OSL_FAIL(
"<SwNumberingUIBehaviorConfig::LoadConfig()> - unknown configuration property");
1441 return SwNumberingUIBehaviorConfig::getInstance().ChangeIndentOnTabAtFirstPosOfFirstListItem();
1465 int nNewLevel = nOldLevel + 1;
1509 return ePosAndSpaceMode;
1515 xmlTextWriterStartElement(pWriter, BAD_CAST(
"SwNumRuleTable"));
1518 xmlTextWriterEndElement(pWriter);
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
virtual SwCharFormat * GetCharFormatFromPool(sal_uInt16 nId)=0
OUString GetNumStr(sal_Int32 nNo) const
SvxNumType GetNumberingType() const
void AddParagraphStyle(SwTextFormatColl &rTextFormatColl)
sal_uInt16 mnPoolHelpId
HelpId for this Pool-style.
SwNode & GetNode(bool bPoint=true) const
bool mbHidden
Is the numbering rule to be hidden in the UI?
void Add(SwClient *pDepend)
Represents the style of a paragraph.
static sal_uInt16 GetBullIndent(sal_uInt8 nLvl)
static void lcl_SetRuleChgd(SwTextNode &rNd, sal_uInt8 nLevel)
virtual void trackChangeOfListStyleName(const OUString &rListStyleName, const OUString &rNewListStyleName)=0
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
SwCharFormat * FindCharFormatByName(std::u16string_view rName) const
OUString MakeRefNumString(const SwNodeNum &rNodeNum, const bool bInclSuperiorNumLabels, const int nRestrictInclToThisLevel) const
OUString MakeNumString(const SwNodeNum &, bool bInclStrings=true) const
SwCharFormat * MakeCharFormat(const OUString &rFormatName, SwCharFormat *pDerivedFrom, bool bBroadcast=false)
const SwNumFormat * GetNumFormat(sal_uInt16 i) const
const short lNumberFirstLineOffset
void AddTextNode(SwTextNode &rTextNode)
SwNumberTreeNode * GetParent() const
Returns the parent of this node.
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames)=0
OUString MakeParagraphStyleListString() const
sal_uInt16 GetPoolFormatId() const
Query and set PoolFormat IDs.
const OUString & GetDefaultListId() const
void GetGrabBagItem(css::uno::Any &rVal) const
const SvxNumberFormat * Get(sal_uInt16 nLevel) const
void RemoveParagraphStyle(SwTextFormatColl &rTextFormatColl)
sal_uInt8 mnPoolHlpFileId
FilePos at Doc on style helps.
virtual bool IsCounted() const override
Return if this node is counted.
const OUString & GetName() const
sal_uInt16 GetPoolHelpId() const
Query and set Help-IDs for document styles.
SwNumberTree::tNumberVector GetNumberVector() const
Returns level numbers of this node.
bool operator==(const SwNumRule &) const
bool HasNumber() const
Returns if this text node has a number.
void dumpAsXml(xmlTextWriterPtr pWriter) const
SwTextNode * GetTextNode() const
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
int GetLevelInListTree() const
Return level of this node.
static LanguageType nLang
static const sal_uInt16 saDefNumIndents[MAXLEVEL]
Used by the UI to modify the document model.
void StartListeningToSameModifyAs(const SwClient &)
void SetGrabBagItem(const css::uno::Any &rVal)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
sal_Unicode GetBulletChar(sal_uInt8 nLevel)
retrieve unicode of character used for the default bullet list for the given list level ...
static SW_DLLPUBLIC sal_uInt16 GetPoolIdFromUIName(const OUString &rName, SwGetPoolIdFromName)
constexpr TypedWhichId< SwAttrSetChg > RES_ATTRSET_CHG(161)
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(160)
void SetNumRuleMap(std::unordered_map< OUString, SwNumRule * > *pNumRuleMap)
Register this rule in a "name->numrule" map.
sal_Unicode mnLevelChars[MAXLEVEL]
SvxNumRule MakeSvxNumRule() const
bool IsAlive(typename std::remove_pointer< Value >::type const *const p) const
check that given format is still alive (i.e. contained here)
bool IsContinusNum() const
exports com.sun.star. text
bool mbChangeIndentOnTabAtFirstPosOfFirstListItem
SwNumRule(const OUString &rNm, const SvxNumberFormat::SvxNumPositionAndSpaceMode eDefaultNumberFormatPositionAndSpaceMode, SwNumRuleType=NUM_RULE)
add parameter
PaM is Point and Mark: a selection of the document model.
struct _xmlTextWriter * xmlTextWriterPtr
std::unique_ptr< sw::ModifyChangedHint > CheckRegistration(const SfxPoolItem *pOldValue)
void CheckCharFormats(SwDoc &rDoc)
Tests whether the CharFormats are from the given doc and copies them if appropriate.
std::vector< SwNumRule * >::size_type size_type
virtual bool IsModified() const =0
Changes of document?
const vcl::Font & GetDefBulletFont()
retrieve font used for the default bullet list characters
bool IsPhantom() const
Return if this node is a phantom.
bool mbAbsSpaces
Levels represent absolute indents.
void RemoveTextNode(SwTextNode &rTextNode)
static OUString GetOutlineRuleName()
SwNumRule * GetNumRule(bool bInParent=true) const
Returns numbering rule of this text node.
IDocumentState const & getIDocumentState() const
const PropertyStruct aPropNames[]
sal_uInt8 GetPoolHlpFileId() const
void GetTextNodeList(SwNumRule::tTextNodeList &rTextNodeList) const
static sal_uInt16 GetNumIndent(sal_uInt8 nLvl)
const short lOutlineMinTextDistance
void SetCountPhantoms(bool bCountPhantoms)
std::unordered_map< OUString, SwNumRule * > * mpNumRuleMap
unordered_map containing "name->rule" relation
void SetIndent(const short nNewIndent, const sal_uInt16 nListLevel)
set indent of certain list level to given value
void dumpAsXml(xmlTextWriterPtr w) const
SwNumRule::tParagraphStyleList::size_type GetParagraphStyleListSize() const
ODFSaneDefaultVersion GetODFSaneDefaultVersion() const
std::unique_ptr< vcl::Font > mpFont
Provides access to the lists of a document.
void ChangeIndent(const sal_Int32 nDiff)
change indent of all list levels by given difference
std::vector< tSwNumTreeNumber > tNumberVector
bool mbContinusNum
Continuous numbering without levels.
const SvxNumberFormat::SvxNumPositionAndSpaceMode meDefaultNumberFormatPositionAndSpaceMode
it needs to export as part of tracked numbering change
const SwNumFormat & Get(sal_uInt16 i) const
std::unique_ptr< SwNumFormat > maFormats[MAXLEVEL]
const PropertyValue * pValues
SwTextNode is a paragraph in the document model.
bool IsContinuousNumbering() const
void Set(sal_uInt16 i, const SwNumFormat *)
SwNumRule::tTextNodeList::size_type GetTextNodeListSize() const
static SwNumFormat * saBaseFormats[RULE_END][MAXLEVEL]
void SetInvalidRule(bool bFlag)
const SwCharFormats * GetCharFormats() const
SvxNumberFormat::SvxNumPositionAndSpaceMode GetDefaultPositionAndSpaceMode()
bool IsDefBulletFontUserDefined()
determine if default bullet font is user defined
OUString const & GetDefBulletFontname()
retrieve font family name used for the default bullet list characters
static sal_uInt16 snRefCount
SwCharFormat * CopyCharFormat(const SwCharFormat &)
copy the char format
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
tTextNodeList maTextNodeList
container for associated text nodes
const SwNumRuleTable & GetNumRuleTable() const
const sal_uInt16 lNumberIndent
void SetSvxRule(const SvxNumRule &, SwDoc *pDoc)
const SwModify * GetRegisteredIn() const
SwNumRule & operator=(const SwNumRule &)
static SwNumFormat * saLabelAlignmentBaseFormats[RULE_END][MAXLEVEL]
default list level properties for position-and-space mode LABEL_ALIGNMENT
std::vector< SwTextNode * > tTextNodeList
std::shared_ptr< SfxGrabBagItem > mpGrabBagItem
Style InteropGrabBag.
bool NumDownChangesIndent(const SwWrtShell &rShell)
Decides if increasing ("downing") the numbering level will change the amount of indentation or not...
tParagraphStyleList maParagraphStyleList
container for associated paragraph styles
void NumRuleChgd()
Notify this textnode that its numbering rule has changed.
bool mbUserDefinedFontname
virtual void ImplCommit()=0
void SetNumberingType(SvxNumType nSet)
void SetName(const OUString &rNm, IDocumentListsAccess &rDocListAccess)
std::pair< const_iterator, bool > insert(Value &&x)
void SetIndentOfFirstListLevelAndChangeOthers(const short nNewIndent)
set indent of first list level to given value and change other list level's indents accordingly ...
void SetLevel(sal_uInt16 nLevel, const SvxNumberFormat &rFmt, bool bIsValid=true)
sal_uInt16 mnPoolFormatId
Id-for NumRules created "automatically".
bool ChangeIndentOnTabAtFirstPosOfFirstListItem()
configuration, if at first position of the first list item the -key increased the indent of the ...
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
static css::lang::Locale convertToLocale(LanguageType nLangID, bool bResolveSystem=true)
virtual void ResetModified()=0
SwNumRule & CopyNumRule(SwDoc &, const SwNumRule &)
A kind of copy-constructor to make sure the num formats are attached to the correctCharFormats of a d...
namespace for static functions and methods for numbering and bullets