Related: tdf#132970 handle more places with potentially utf16 bullets

Change-Id: Iac6b319700d610b5a1debff0a633172b2411c40e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103161
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx
index a51ed1f3..211b131 100644
--- a/cui/source/tabpages/autocdlg.cxx
+++ b/cui/source/tabpages/autocdlg.cxx
@@ -534,10 +534,10 @@ void OfaSwAutoFmtOptionsPage::Reset( const SfxItemSet* )
    const ACFlags nFlags = pAutoCorrect->GetFlags();

    aBulletFont = pOpt->aBulletFont;
    sBulletChar = OUString(pOpt->cBullet);
    sBulletChar = OUString(&pOpt->cBullet, 1);

    aByInputBulletFont = pOpt->aByInputBulletFont;
    sByInputBulletChar = OUString( pOpt->cByInputBullet );
    sByInputBulletChar = OUString(&pOpt->cByInputBullet, 1);

    nPercent = pOpt->nRightMargin;
    sMargin = unicode::formatPercent(nPercent, Application::GetSettings().GetUILanguageTag());
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 1410216..4eb04ec 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -688,8 +688,9 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, ValueSet*, void)
            else
                aFmt.SetBulletFont( &rActBulletFont );

            sal_Int32 nIndexUtf16 = 0;
            aFmt.SetBulletChar( !pLevelSettings->sBulletChar.isEmpty()
                                    ? pLevelSettings->sBulletChar[0]
                                    ? pLevelSettings->sBulletChar.iterateCodePoints(&nIndexUtf16)
                                    : 0 );
            aFmt.SetCharFormatName( sBulletCharFormatName );
            aFmt.SetBulletRelSize(45);
diff --git a/editeng/source/uno/unonrule.cxx b/editeng/source/uno/unonrule.cxx
index 57b68a0..03b766d 100644
--- a/editeng/source/uno/unonrule.cxx
+++ b/editeng/source/uno/unonrule.cxx
@@ -206,7 +206,7 @@ Sequence<beans::PropertyValue> SvxUnoNumberingRules::getNumberingRuleByIndex(sal

    if(SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType())
    {
        sal_Unicode nCode = rFmt.GetBulletChar();
        sal_UCS4 nCode = rFmt.GetBulletChar();
        OUString aStr( &nCode, 1 );
        aVal <<= aStr;
        beans::PropertyValue aBulletProp( "BulletChar", -1, aVal, beans::PropertyState_DIRECT_VALUE);
@@ -324,7 +324,8 @@ void SvxUnoNumberingRules::setNumberingRuleByIndex(const Sequence<beans::Propert
            {
                if(!aStr.isEmpty())
                {
                    aFmt.SetBulletChar(aStr[0]);
                    sal_Int32 nIndexUtf16 = 0;
                    aFmt.SetBulletChar(aStr.iterateCodePoints(&nIndexUtf16));
                }
                else
                {
diff --git a/include/editeng/swafopt.hxx b/include/editeng/swafopt.hxx
index 4fd1207..ccdcf99 100644
--- a/include/editeng/swafopt.hxx
+++ b/include/editeng/swafopt.hxx
@@ -26,6 +26,7 @@
#include <o3tl/sorted_vector.hxx>
#include <rtl/ustring.hxx>
#include <vcl/font.hxx>
#include <vcl/vclenum.hxx>

class SmartTagMgr;

@@ -81,8 +82,8 @@ struct EDITENG_DLLPUBLIC SvxSwAutoFormatFlags
    const editeng::SortedAutoCompleteStrings * m_pAutoCompleteList;
    SmartTagMgr* pSmartTagMgr;

    sal_Unicode cBullet;
    sal_Unicode cByInputBullet;
    sal_UCS4 cBullet;
    sal_UCS4 cByInputBullet;

    sal_uInt16 nAutoCmpltWordLen, nAutoCmpltListLen;
    sal_uInt16 nAutoCmpltExpandKey;
diff --git a/include/svx/nbdtmg.hxx b/include/svx/nbdtmg.hxx
index fbecb27..eceb96b8 100644
--- a/include/svx/nbdtmg.hxx
+++ b/include/svx/nbdtmg.hxx
@@ -73,7 +73,7 @@ class  SVX_DLLPUBLIC BulletsSettings
public:
    vcl::Font       aFont;
    OUString        sDescription;
    sal_Unicode     cBulletChar;
    sal_UCS4        cBulletChar;
    bool            bIsCustomized;
    BulletsSettings() : cBulletChar(0), bIsCustomized(false)  {}
};
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index ccb45ce..91d796b 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -3225,9 +3225,9 @@ void SdImportTest::testTdf49856()
    const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
    const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET);
    CPPUNIT_ASSERT(pNumFmt);
    const sal_Unicode aBullet = pNumFmt->GetNumRule()->GetLevel(0).GetBulletChar();
    const sal_UCS4 aBullet = pNumFmt->GetNumRule()->GetLevel(0).GetBulletChar();
    CPPUNIT_ASSERT_EQUAL(OUString("More level 2"), aEdit.GetText(2));
    CPPUNIT_ASSERT_EQUAL(u'\x2022', aBullet);
    CPPUNIT_ASSERT_EQUAL(sal_UCS4(0x2022), aBullet);

    xDocShRef->DoClose();
}
diff --git a/sd/source/ui/dlg/BulletAndPositionDlg.cxx b/sd/source/ui/dlg/BulletAndPositionDlg.cxx
index 4fa1414..45e2a1d 100644
--- a/sd/source/ui/dlg/BulletAndPositionDlg.cxx
+++ b/sd/source/ui/dlg/BulletAndPositionDlg.cxx
@@ -920,7 +920,7 @@ IMPL_LINK_NOARG(SvxBulletAndPositionDlg, BulletHdl_Impl, weld::Button&, void)
    sal_uInt16 nMask = 1;
    const vcl::Font* pFmtFont = nullptr;
    bool bSameBullet = true;
    sal_Unicode cBullet = 0;
    sal_UCS4 cBullet = 0;
    bool bFirst = true;
    for (sal_uInt16 i = 0; i < pActNum->GetLevelCount(); i++)
    {
diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx
index 3d99502..b36e58b 100644
--- a/svx/source/sidebar/nbdtmg.cxx
+++ b/svx/source/sidebar/nbdtmg.cxx
@@ -282,7 +282,7 @@ sal_uInt16 BulletsTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 mLe
        return sal_uInt16(0xFFFF);

    const SvxNumberFormat& aFmt(aNum.GetLevel(nActLv));
    sal_Unicode cChar = aFmt.GetBulletChar();
    sal_UCS4 cChar = aFmt.GetBulletChar();
    for(sal_uInt16 i = nFromIndex; i < DEFAULT_BULLET_TYPES; i++)
    {
        if ( (cChar == pActualBullets[i]->cBulletChar) ||
@@ -310,7 +310,7 @@ void BulletsTypeMgr::RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uI
        return;

    SvxNumberFormat aFmt(aNum.GetLevel(nActLv));
    sal_Unicode cChar = aFmt.GetBulletChar();
    sal_UCS4 cChar = aFmt.GetBulletChar();
    const vcl::Font* pFont = aFmt.GetBulletFont();
    if ( nIndex >= DEFAULT_BULLET_TYPES )
        return;
@@ -325,7 +325,7 @@ void BulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1
{
    if ( nIndex >= DEFAULT_BULLET_TYPES )
        return;
    sal_Unicode cChar = pActualBullets[nIndex]->cBulletChar;
    sal_UCS4 cChar = pActualBullets[nIndex]->cBulletChar;
    const vcl::Font& rActBulletFont = pActualBullets[nIndex]->aFont;

    sal_uInt16 nMask = 1;
@@ -337,7 +337,7 @@ void BulletsTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1
            SvxNumberFormat aFmt(aNum.GetLevel(i));
            aFmt.SetNumberingType( SVX_NUM_CHAR_SPECIAL );
            aFmt.SetBulletFont(&rActBulletFont);
            aFmt.SetBulletChar(cChar );
            aFmt.SetBulletChar(cChar);
            aFmt.SetCharFormatName(sBulletCharFormatName);
            aFmt.SetPrefix( "" );
            aFmt.SetSuffix( "" );
@@ -648,8 +648,11 @@ sal_uInt16 OutlineTypeMgr::GetNBOIndexForNumRule(SvxNumRule& aNum,sal_uInt16 /*m
            sal_Int16 eNumType = aFmt.GetNumberingType();
            if( eNumType == SVX_NUM_CHAR_SPECIAL)
            {
                sal_Unicode cChar = aFmt.GetBulletChar();
                sal_Unicode ccChar = _pSet->sBulletChar[0];
                sal_UCS4 cChar = aFmt.GetBulletChar();

                sal_Int32 nIndexUtf16 = 0;
                sal_UCS4 ccChar = _pSet->sBulletChar.iterateCodePoints(&nIndexUtf16);

                if ( !((cChar == ccChar) &&
                    _pSet->eLabelFollowedBy == aFmt.GetLabelFollowedBy() &&
                    _pSet->nTabValue == aFmt.GetListtabPos() &&
@@ -726,8 +729,8 @@ void OutlineTypeMgr::RelplaceNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uI

        if( eNumType == SVX_NUM_CHAR_SPECIAL)
        {
            sal_Unicode cChar = aFmt.GetBulletChar();
            OUString sChar(cChar);
            sal_UCS4 cChar = aFmt.GetBulletChar();
            OUString sChar(&cChar, 1);
            _pSet->sBulletChar = sChar;
            if ( aFmt.GetBulletFont() )
                _pSet->sBulletFont = aFmt.GetBulletFont()->GetFamilyName();
@@ -822,9 +825,12 @@ void OutlineTypeMgr::ApplyNumRule(SvxNumRule& aNum, sal_uInt16 nIndex, sal_uInt1
            }else
                aFmt.SetBulletFont( &rActBulletFont );

            sal_Unicode cChar = 0;
            sal_UCS4 cChar = 0;
            if( !pLevelSettings->sBulletChar.isEmpty() )
                cChar = pLevelSettings->sBulletChar[0];
            {
                sal_Int32 nIndexUtf16 = 0;
                cChar = pLevelSettings->sBulletChar.iterateCodePoints(&nIndexUtf16);
            }
            if( AllSettings::GetLayoutRTL() )
            {
                if( 0 == i && cChar == BulletsTypeMgr::aDynamicBulletTypes[5] )
diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx
index 48d5bef..696d26a 100644
--- a/sw/source/core/edit/autofmt.cxx
+++ b/sw/source/core/edit/autofmt.cxx
@@ -1527,7 +1527,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
                if( !aRule.GetNumFormat( nLvl ) )
                {
                    int nBulletPos = pFndBulletChr - pBulletChar;
                    sal_Unicode cBullChar;
                    sal_UCS4 cBullChar;
                    const vcl::Font* pBullFnt( nullptr );
                    if( nBulletPos < cnPosEnDash )
                    {
@@ -1726,7 +1726,7 @@ void SwAutoFormat::BuildEnum( sal_uInt16 nLvl, sal_uInt16 nDigitLevel )
        {
            OUString sChgStr('\t');
            if( bChgBullet )
                sChgStr = OUStringChar( m_aFlags.cBullet ) + sChgStr;
                sChgStr = OUString(&m_aFlags.cBullet, 1) + sChgStr;
            m_pDoc->getIDocumentContentOperations().InsertString( m_aDelPam, sChgStr );

            SfxItemSet aSet( m_pDoc->GetAttrPool(), aTextNodeSetRange );
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 292de27..d689ab3 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -669,7 +669,10 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV,

                // take only the very first character
                if (rAV.cbTextBefore || rAV.cbTextAfter)
                    rNum.SetBulletChar( sText[ 0 ] );
                {
                    sal_Int32 nIndexUtf16 = 0;
                    rNum.SetBulletChar(sText.toString().iterateCodePoints(&nIndexUtf16));
                }
                else
                    rNum.SetBulletChar( 0x2190 );
            }
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 3fbe650..6ce3738 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -622,7 +622,7 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet
    sal_uInt8       aBits1(0);
    SvxNumType      nType(SVX_NUM_ARABIC);
    SvxAdjust       eAdj;               // Alignment (Left/right/centered)
    sal_Unicode     cBullet(0x2190);    // default safe bullet
    sal_UCS4        cBullet(0x2190);    // default safe bullet

    sal_Unicode     cGrfBulletCP(USHRT_MAX);

@@ -832,7 +832,8 @@ bool WW8ListManager::ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet

    if (style::NumberingType::CHAR_SPECIAL == nType)
    {
        cBullet = !sNumString.isEmpty() ? sNumString[0] : 0x2190;
        sal_Int32 nIndexUtf16 = 0;
        cBullet = !sNumString.isEmpty() ? sNumString.iterateCodePoints(&nIndexUtf16) : 0x2190;

        if (!cBullet)  // unsave control code?
            cBullet = 0x2190;