summaryrefslogtreecommitdiffstats
path: root/editeng/source/items/numitem.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'editeng/source/items/numitem.cxx')
-rw-r--r--editeng/source/items/numitem.cxx111
1 files changed, 57 insertions, 54 deletions
diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx
index 6823a6616d03..2a1e540c3cb7 100644
--- a/editeng/source/items/numitem.cxx
+++ b/editeng/source/items/numitem.cxx
@@ -24,6 +24,7 @@
#include <editeng/numitem.hxx>
#include <com/sun/star/text/VertOrientation.hpp>
+#include <comphelper/propertyvalue.hxx>
#include <editeng/brushitem.hxx>
#include <rtl/ustrbuf.hxx>
#include <vcl/font.hxx>
@@ -45,18 +46,18 @@
#include <tools/stream.hxx>
#include <tools/debug.hxx>
#include <tools/GenericTypeSerializer.hxx>
-#include <unotools/configmgr.hxx>
+#include <comphelper/configuration.hxx>
#include <libxml/xmlwriter.h>
#include <editeng/unonrule.hxx>
#include <sal/log.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <editeng/legacyitem.hxx>
-#define DEF_WRITER_LSPACE 500 //Standard Indentation
-#define DEF_DRAW_LSPACE 800 //Standard Indentation
+constexpr sal_Int32 DEF_WRITER_LSPACE = 500; //Standard Indentation
+constexpr sal_Int32 DEF_DRAW_LSPACE = 800; //Standard Indentation
-#define NUMITEM_VERSION_03 0x03
-#define NUMITEM_VERSION_04 0x04
+constexpr sal_uInt16 NUMITEM_VERSION_03 = 0x03;
+constexpr sal_uInt16 NUMITEM_VERSION_04 = 0x04;
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
@@ -106,13 +107,19 @@ SvxNumberType::~SvxNumberType()
OUString SvxNumberType::GetNumStr( sal_Int32 nNo ) const
{
- LanguageTag aLang = utl::ConfigManager::IsFuzzing() ?
+ LanguageTag aLang = comphelper::IsFuzzing() ?
LanguageTag("en-US") :
Application::GetSettings().GetLanguageTag();
return GetNumStr( nNo, aLang.getLocale() );
}
-OUString SvxNumberType::GetNumStr( sal_Int32 nNo, const css::lang::Locale& rLocale ) const
+static bool isArabicNumberingType(SvxNumType t)
+{
+ return t == SVX_NUM_ARABIC || t == SVX_NUM_ARABIC_ZERO || t == SVX_NUM_ARABIC_ZERO3
+ || t == SVX_NUM_ARABIC_ZERO4 || t == SVX_NUM_ARABIC_ZERO5;
+}
+
+OUString SvxNumberType::GetNumStr( sal_Int32 nNo, const css::lang::Locale& rLocale, bool bIsLegal ) const
{
lcl_getFormatter(xFormatter);
if(!xFormatter.is())
@@ -132,12 +139,14 @@ OUString SvxNumberType::GetNumStr( sal_Int32 nNo, const css::lang::Locale& rLoca
return OUString('0');
else
{
- Sequence< PropertyValue > aProperties(2);
- PropertyValue* pValues = aProperties.getArray();
- pValues[0].Name = "NumberingType";
- pValues[0].Value <<= static_cast<sal_uInt16>(nNumType);
- pValues[1].Name = "Value";
- pValues[1].Value <<= nNo;
+ SvxNumType nActType = !bIsLegal || isArabicNumberingType(nNumType) ? nNumType : SVX_NUM_ARABIC;
+ static constexpr OUString sNumberingType = u"NumberingType"_ustr;
+ static constexpr OUString sValue = u"Value"_ustr;
+ Sequence< PropertyValue > aProperties
+ {
+ comphelper::makePropertyValue(sNumberingType, static_cast<sal_uInt16>(nActType)),
+ comphelper::makePropertyValue(sValue, nNo)
+ };
try
{
@@ -364,6 +373,7 @@ SvxNumberFormat& SvxNumberFormat::operator=( const SvxNumberFormat& rFormat )
pBulletFont.reset();
if(rFormat.pBulletFont)
pBulletFont = *rFormat.pBulletFont;
+ mbIsLegal = rFormat.mbIsLegal;
return *this;
}
@@ -390,7 +400,8 @@ bool SvxNumberFormat::operator==( const SvxNumberFormat& rFormat) const
nBulletColor != rFormat.nBulletColor ||
nBulletRelSize != rFormat.nBulletRelSize ||
IsShowSymbol() != rFormat.IsShowSymbol() ||
- sCharStyleName != rFormat.sCharStyleName
+ sCharStyleName != rFormat.sCharStyleName ||
+ mbIsLegal != rFormat.mbIsLegal
)
return false;
if (
@@ -539,48 +550,40 @@ Size SvxNumberFormat::GetGraphicSizeMM100(const Graphic* pGraphic)
OUString SvxNumberFormat::CreateRomanString( sal_Int32 nNo, bool bUpper )
{
- nNo %= 4000; // more can not be displayed
-// i, ii, iii, iv, v, vi, vii, vii, viii, ix
-// (Dummy),1000,500,100,50,10,5,1
- const char *cRomanArr = bUpper
- ? "MDCLXVI--" // +2 Dummy entries!
- : "mdclxvi--"; // +2 Dummy entries!
-
OUStringBuffer sRet;
- sal_uInt16 nMask = 1000;
- while( nMask )
- {
- sal_uInt8 nNumber = sal_uInt8(nNo / nMask);
- sal_uInt8 nDiff = 1;
- nNo %= nMask;
- if( 5 < nNumber )
- {
- if( nNumber < 9 )
- sRet.append(*(cRomanArr-1));
- ++nDiff;
- nNumber -= 5;
- }
- switch( nNumber )
+ constexpr char romans[][13] = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
+ constexpr sal_Int32 values[] = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
+
+ for (size_t i = 0; i < std::size(romans); ++i)
+ {
+ while(nNo - values[i] >= 0)
{
- case 3: { sRet.append(*cRomanArr); [[fallthrough]]; }
- case 2: { sRet.append(*cRomanArr); [[fallthrough]]; }
- case 1: { sRet.append(*cRomanArr); }
- break;
-
- case 4: {
- sRet.append(*cRomanArr);
- sRet.append(*(cRomanArr-nDiff));
- }
- break;
- case 5: { sRet.append(*(cRomanArr-nDiff)); }
- break;
+ sRet.appendAscii(romans[i]);
+ nNo -= values[i];
}
-
- nMask /= 10; // for the next decade
- cRomanArr += 2;
}
- return sRet.makeStringAndClear();
+
+ return bUpper ? sRet.makeStringAndClear()
+ : sRet.makeStringAndClear().toAsciiLowerCase();
+}
+
+void SvxNumberFormat::SetPrefix(const OUString& rSet)
+{
+ // ListFormat manages the prefix. If badly changed via this function, sListFormat is invalidated
+ if (sListFormat && rSet.getLength() != sPrefix.getLength())
+ sListFormat.reset();
+
+ sPrefix = rSet;
+}
+
+void SvxNumberFormat::SetSuffix(const OUString& rSet)
+{
+ // ListFormat manages the suffix. If badly changed via this function, sListFormat is invalidated
+ if (sListFormat && rSet.getLength() != sSuffix.getLength())
+ sListFormat.reset();
+
+ sSuffix = rSet;
}
void SvxNumberFormat::SetListFormat(const OUString& rPrefix, const OUString& rSuffix, int nLevel)
@@ -613,13 +616,13 @@ void SvxNumberFormat::SetListFormat(std::optional<OUString> oSet)
sPrefix.clear();
sSuffix.clear();
+ sListFormat = oSet;
+
if (!oSet.has_value())
{
return;
}
- sListFormat = oSet;
-
// For backward compatibility and UI we should create something looking like
// a prefix, suffix and included levels also. This is not possible in general case
// since level format string is much more flexible. But for most cases is okay
@@ -1012,7 +1015,7 @@ OUString SvxNumRule::MakeNumString( const SvxNodeNum& rNum ) const
if(SVX_NUM_BITMAP != rNFmt.GetNumberingType())
{
const LanguageTag& rLang = Application::GetSettings().GetLanguageTag();
- aStr.append(rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], rLang.getLocale() ));
+ aStr.append(rNFmt.GetNumStr( rNum.GetLevelVal()[ i ], rLang.getLocale(), rMyNFmt.GetIsLegal() ));
}
else
bDot = false;