cui/source/tabpages/numpages.cxx           |    6 +++++-
 i18npool/source/localedata/LocaleNode.cxx  |    3 ++-
 i18npool/source/localedata/data/en_US.xml  |   10 +++++-----
 i18npool/source/localedata/data/locale.dtd |    1 +
 i18npool/source/localedata/localedata.cxx  |    9 +++++----
 svx/source/sidebar/nbdtmg.cxx              |   13 +++++++++++--
 6 files changed, 29 insertions(+), 13 deletions(-)

New commits:
commit 72e2ec361acc2b57ec3fc08325a16846d3c7df33
Author:     Justin Luth <justin.l...@collabora.com>
AuthorDate: Mon Jan 2 10:48:33 2023 -0500
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Fri Apr 21 03:07:07 2023 +0200

    tdf#56258: allow i18npool to define SvxAdjust for outline
    
    This is a squashed commit, including pre-requisite
    commit b1226e1f225de4fa67a0d4f5a6aa4017284c7deb
    and follow-up commit 6cabd7d9bfed37799a344f872d5f8fcf3214116a
    
    Deciding whether the numbering should be Left, Right, or Center
    is a rather important setting. Specifically for Roman numerals
    (which grow very wide as they increment to 7 and 8)
    the numbering styles set these to right aligned.
    This really helps for keeping the text nicely aligned.
    
    The numbering styles are built-in LO defaults,
    but locale files can define numbering and outline
    choices. This patch add the setting for "adjust" on
    the outline levels.
    
    For en_US, it makes sense to right-align roman numeral levels.
    [The only other highly likely candidate for this that I could find
     was old Hungarian (SZEKELY_ROVAS),  but it doesn't seem
     to be used in any locale definitions.]
    
    I only changed en_US for now, but of course many other
    locales are also using NumType="3" and NumType="4".
    
    This only applies to the toolbar/sidebar SVX code path.
    The Bullets and Numbering dialog does not currently
    modify any spacing, so I didn't apply the adjustment either.
    
    It also doesn't make sense to do this on single numbering changes
    (aka ContinuousNumberingLevels or LC_NumberingLevel)
    because we don't know or control the first line indent there either.
    
    But at least for toolbar Outlines, we do change every level,
    and so can set a (somewhat) appropriate spacing.
    [Setting SvxAdjust without adjusting the spacing
     is pointless. Don't make any changes at all if
     the spacing ends up causing problems.]
    
    The Numbering IVX/ivx styles set the firstLineIndent to -174,
    so I did the same here. This is the scariest part of this change.
    
    AFAICS SvxAdjust::Left is a non-locale aDefNumStyle default,
    so hardcoding that for undefined LC_OutlineNumberingLevel
    shouldn't be too scary.
    
    Change-Id: I52deefe88aa55c55c9531b651411f64accb86f7f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150663
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index c307f6ac155f..19a2b37ed82d 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include <com/sun/star/text/HoriOrientation.hpp>
 #include <com/sun/star/text/VertOrientation.hpp>
 
 #include <numpages.hxx>
@@ -692,6 +691,11 @@ IMPL_LINK_NOARG(SvxNumPickTabPage, NumSelectHdl_Impl, 
ValueSet*, void)
             aFmt.SetIncludeUpperLevels(sal::static_int_cast< sal_uInt8 >(0 != 
nUpperLevelOrChar ? pActNum->GetLevelCount() : 1));
             aFmt.SetCharFormatName(sNumCharFmtName);
             aFmt.SetBulletRelSize(100);
+
+            // Completely ignore the Left/Right value provided by the locale 
outline definition,
+            // because this function doesn't actually modify the indents at 
all,
+            // and right-adjusted numbering definitely needs a different 
FirstLineIndent.
+
             // #i93908#
             aFmt.SetListFormat(pLevelSettings->sPrefix, 
pLevelSettings->sSuffix, i);
         }
diff --git a/i18npool/source/localedata/LocaleNode.cxx 
b/i18npool/source/localedata/LocaleNode.cxx
index acc7dd8f927b..14232338b9f1 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -2236,7 +2236,7 @@ void LCOutlineNumberingLevelNode::generateCode (const 
OFileWriter &of) const
     }
 
     // hardcode number of attributes per level
-    const int   nAttributes = 11;
+    const int nAttributes = 12;
     const char* attr[ nAttributes ] =
     {
         "Prefix",
@@ -2248,6 +2248,7 @@ void LCOutlineNumberingLevelNode::generateCode (const 
OFileWriter &of) const
         "LeftMargin",
         "SymbolTextDistance",
         "FirstLineOffset",
+        "Adjust",
         "Transliteration",
         "NatNum",
     };
diff --git a/i18npool/source/localedata/data/en_US.xml 
b/i18npool/source/localedata/data/en_US.xml
index ffd0bf1fad59..b83c64489238 100644
--- a/i18npool/source/localedata/data/en_US.xml
+++ b/i18npool/source/localedata/data/en_US.xml
@@ -587,7 +587,7 @@
     <OutlineStyle>
       <OutLineNumberingLevel Prefix=" " NumType="4" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" 
SymbolTextDistance="50" FirstLineOffset="0"/>
       <OutLineNumberingLevel Prefix="(" NumType="1" Suffix=")" 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" 
SymbolTextDistance="50" FirstLineOffset="0"/>
-      <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" 
SymbolTextDistance="50" FirstLineOffset="0"/>
+      <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" 
SymbolTextDistance="50" FirstLineOffset="0" Adjust="1"/>
       <OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" 
SymbolTextDistance="50" FirstLineOffset="0"/>
       <OutLineNumberingLevel Prefix=" " NumType="6" Suffix="." 
BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" 
LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0"/>
       <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " 
BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" 
LeftMargin="250" SymbolTextDistance="50" FirstLineOffset="0"/>
@@ -601,18 +601,18 @@
       <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=" " 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="250" 
SymbolTextDistance="50" FirstLineOffset="0"/>
     </OutlineStyle>
     <OutlineStyle>
-      <OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" 
SymbolTextDistance="50" FirstLineOffset="0"/>
+      <OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" 
SymbolTextDistance="50" FirstLineOffset="0" Adjust="1"/>
       <OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" 
SymbolTextDistance="50" FirstLineOffset="0"/>
-      <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" 
SymbolTextDistance="50" FirstLineOffset="0"/>
+      <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" 
SymbolTextDistance="50" FirstLineOffset="0" Adjust="1"/>
       <OutLineNumberingLevel Prefix=" " NumType="1" Suffix=")" 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" 
SymbolTextDistance="50" FirstLineOffset="0"/>
       <OutLineNumberingLevel Prefix=" " NumType="4" Suffix=")" 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="200" 
SymbolTextDistance="50" FirstLineOffset="0"/>
       <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " 
BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" 
LeftMargin="250" SymbolTextDistance="50" FirstLineOffset="0"/>
     </OutlineStyle>
     <OutlineStyle> <!-- A.I.a.i. -->
       <OutLineNumberingLevel Prefix=" " NumType="0" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="0" 
SymbolTextDistance="50" FirstLineOffset="0"/>
-      <OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" 
SymbolTextDistance="50" FirstLineOffset="0"/>
+      <OutLineNumberingLevel Prefix=" " NumType="2" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="50" 
SymbolTextDistance="50" FirstLineOffset="0" Adjust="1"/>
       <OutLineNumberingLevel Prefix=" " NumType="1" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="100" 
SymbolTextDistance="50" FirstLineOffset="0"/>
-      <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" 
SymbolTextDistance="50" FirstLineOffset="0"/>
+      <OutLineNumberingLevel Prefix=" " NumType="3" Suffix="." 
BulletChar="0020" BulletFontName="" ParentNumbering="0" LeftMargin="150" 
SymbolTextDistance="50" FirstLineOffset="0" Adjust="1"/>
       <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " 
BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" 
LeftMargin="200" SymbolTextDistance="50" FirstLineOffset="0"/>
       <OutLineNumberingLevel Prefix=" " NumType="6" Suffix=" " 
BulletChar="2022" BulletFontName="StarSymbol" ParentNumbering="0" 
LeftMargin="250" SymbolTextDistance="50" FirstLineOffset="0"/>
     </OutlineStyle>
diff --git a/i18npool/source/localedata/data/locale.dtd 
b/i18npool/source/localedata/data/locale.dtd
index f713ccf6d8b4..a867215421bc 100644
--- a/i18npool/source/localedata/data/locale.dtd
+++ b/i18npool/source/localedata/data/locale.dtd
@@ -681,5 +681,6 @@
 <!ATTLIST OutLineNumberingLevel LeftMargin CDATA   #REQUIRED>
 <!ATTLIST OutLineNumberingLevel SymbolTextDistance CDATA  #REQUIRED >
 <!ATTLIST OutLineNumberingLevel FirstLineOffset CDATA  #REQUIRED >
+<!ATTLIST OutLineNumberingLevel Adjust CDATA #IMPLIED >
 <!ATTLIST OutLineNumberingLevel Transliteration CDATA #IMPLIED >
 <!ATTLIST OutLineNumberingLevel NatNum CDATA #IMPLIED>
diff --git a/i18npool/source/localedata/localedata.cxx 
b/i18npool/source/localedata/localedata.cxx
index 4291df4809e9..fea7682cee8a 100644
--- a/i18npool/source/localedata/localedata.cxx
+++ b/i18npool/source/localedata/localedata.cxx
@@ -23,10 +23,10 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <com/sun/star/container/XIndexAccess.hpp>
 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
-#include <com/sun/star/text/HoriOrientation.hpp>
 #include <comphelper/sequence.hxx>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
+#include <editeng/svxenum.hxx>
 #include <localedata.hxx>
 #include <i18nlangtag/mslangid.hxx>
 #include <i18nlangtag/languagetag.hxx>
@@ -1319,6 +1319,7 @@ struct OutlineNumberingLevel_Impl
     sal_Int32       nLeftMargin;
     sal_Int32       nSymbolTextDistance;
     sal_Int32       nFirstLineOffset;
+    sal_Int16       nAdjust;
     OUString        sTransliteration;
     sal_Int32       nNatNum;
 };
@@ -1384,7 +1385,7 @@ LocaleDataImpl::getOutlineNumberingLevels( const 
lang::Locale& rLocale )
                         case 6: level[j].nLeftMargin         = tmp.toInt32();  
 break;
                         case 7: level[j].nSymbolTextDistance = tmp.toInt32();  
 break;
                         case 8: level[j].nFirstLineOffset    = tmp.toInt32();  
 break;
-                        case 9: break;
+                        case 9: level[j].nAdjust             = 
sal::static_int_cast<sal_Int16>(tmp.toInt32()); break;
                         case 10: level[j].sTransliteration = tmp; break;
                         case 11: level[j].nNatNum    = tmp.toInt32();   break;
                         default:
@@ -1395,6 +1396,7 @@ LocaleDataImpl::getOutlineNumberingLevels( const 
lang::Locale& rLocale )
             level[j].sPrefix.clear();
             level[j].nNumType            = 0;
             level[j].sSuffix.clear();
+            level[j].nAdjust = 0;
             level[j].cBulletChar         = 0;
             level[j].sBulletFontName.clear();
             level[j].nParentNumbering    = 0;
@@ -1487,7 +1489,6 @@ LocaleDataImpl::getAllInstalledLocaleNames()
 
 using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::text;
 
 OutlineNumbering::OutlineNumbering(std::unique_ptr<const 
OutlineNumberingLevel_Impl[]> pOutlnLevels, int nLevels) :
     m_pOutlineLevels(std::move(pOutlnLevels)),
@@ -1529,7 +1530,7 @@ Any OutlineNumbering::getByIndex( sal_Int32 nIndex )
     pValues[8].Name = "FirstLineOffset";
     pValues[8].Value <<= pTemp->nFirstLineOffset;
     pValues[9].Name = "Adjust";
-    pValues[9].Value <<= sal_Int16(HoriOrientation::LEFT);
+    pValues[9].Value <<= pTemp->nAdjust;
     pValues[10].Name = "Transliteration";
     pValues[10].Value <<= pTemp->sTransliteration;
     pValues[11].Name = "NatNum";
diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx
index a4def326c80b..3643976d2866 100644
--- a/svx/source/sidebar/nbdtmg.cxx
+++ b/svx/source/sidebar/nbdtmg.cxx
@@ -103,6 +103,12 @@ NumSettings_Impl* lcl_CreateNumberingSettingsPtr(const 
Sequence<PropertyValue>&
             rValue.Value >>= pNew->sPrefix;
         else if(rValue.Name == "Suffix")
             rValue.Value >>= pNew->sSuffix;
+        else if (rValue.Name == "Adjust")
+        {
+            sal_Int16 nTmp;
+            if (rValue.Value >>= nTmp)
+                pNew->eNumAlign = static_cast<SvxAdjust>(nTmp);
+        }
         else if(rValue.Name == "ParentNumbering")
             rValue.Value >>= pNew->nParentNumbering;
         else if(rValue.Name == "BulletChar")
@@ -600,10 +606,13 @@ void OutlineTypeMgr::Init()
 
                 NumSettings_Impl* pNew = 
lcl_CreateNumberingSettingsPtr(aLevelProps);
                 const SvxNumberFormat& aNumFmt( aDefNumRule.GetLevel( nLevel) 
);
+                assert(aNumFmt.GetNumAdjust() == SvxAdjust::Left && "new entry 
was previously defined by default, now defaults to Left");
                 pNew->eLabelFollowedBy = aNumFmt.GetLabelFollowedBy();
                 pNew->nTabValue = aNumFmt.GetListtabPos();
-                pNew->eNumAlign = aNumFmt.GetNumAdjust();
-                pNew->nNumAlignAt = aNumFmt.GetFirstLineIndent();
+                if (pNew->eNumAlign == SvxAdjust::Right)
+                    pNew->nNumAlignAt = -174; // number borrowed from 
RES_POOLNUMRULE_NUM4
+                else
+                    pNew->nNumAlignAt = aNumFmt.GetFirstLineIndent();
                 pNew->nNumIndentAt = aNumFmt.GetIndentAt();
                 
pItemArr->pNumSettingsArr->push_back(std::shared_ptr<NumSettings_Impl>(pNew));
             }

Reply via email to