tdf#117587 Ordinal/cardinal numbering preview

I implemented cardinal and ordinal numbering for text
using the current text language
instead of the program's locale language.
The preview is now shown in the text language.

Change-Id: I68d4ce5868adb7b5f4b6786947d2e529daab48aa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/201931
Tested-by: Jenkins
Reviewed-by: Khaled Hosny <khaled@libreoffice.org>
This commit is contained in:
Aya Jamal
2026-03-26 06:42:16 +01:00
committed by Ilmari Lauhakangas
parent 44a0fa54b8
commit cec8abfcb4
9 changed files with 43 additions and 15 deletions
+9 -2
View File
@@ -26,6 +26,10 @@
#include <tools/mapunit.hxx>
#include <tools/stream.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/flstitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/numitem.hxx>
#include <svl/eitem.hxx>
#include <vcl/svapp.hxx>
@@ -35,13 +39,11 @@
#include <svx/nbdtmg.hxx>
#include <svx/strarray.hxx>
#include <svx/gallery.hxx>
#include <editeng/brushitem.hxx>
#include <svl/intitem.hxx>
#include <sfx2/objsh.hxx>
#include <vcl/graph.hxx>
#include <vcl/settings.hxx>
#include <svx/cuicharmap.hxx>
#include <editeng/flstitem.hxx>
#include <svx/numvset.hxx>
#include <sfx2/htmlmode.hxx>
#include <unotools/pathoptions.hxx>
@@ -1455,6 +1457,11 @@ void SvxNumOptionsTabPage::Reset( const SfxItemSet* rSet )
InitControls();
bModified = false;
const SvxLanguageItem* pLangItem = rSet->GetItemIfSet(SID_ATTR_CHAR_LANGUAGE, true);
if (!pLangItem)
pLangItem = rSet->GetItemIfSet(EE_CHAR_LANGUAGE, true);
if (pLangItem)
m_aPreviewWIN.SetLanguage(pLangItem->GetLanguage());
}
void SvxNumOptionsTabPage::InitControls()
+3 -3
View File
@@ -1034,7 +1034,7 @@ void SvxNumRule::SetLevel(sal_uInt16 nLevel, const SvxNumberFormat* pFmt)
}
}
OUString SvxNumRule::MakeNumString( const SvxNodeNum& rNum ) const
OUString SvxNumRule::MakeNumString(const SvxNodeNum& rNum, LanguageType aLang) const
{
OUStringBuffer aStr;
if( SVX_NO_NUM > rNum.GetLevel() && !( SVX_NO_NUMLEVEL & rNum.GetLevel() ) )
@@ -1071,8 +1071,8 @@ 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(), rMyNFmt.GetIsLegal() ));
css::lang::Locale aLocale(LanguageTag::convertToLocale(aLang));
aStr.append(rNFmt.GetNumStr(rNum.GetLevelVal()[ i ], aLocale, rMyNFmt.GetIsLegal()));
}
else
bDot = false;
+1 -1
View File
@@ -308,7 +308,7 @@ public:
SvxNumRuleFlags GetFeatureFlags() const {return nFeatureFlags;}
void SetFeatureFlag( SvxNumRuleFlags nFlag, bool bSet = true ) { if(bSet) nFeatureFlags |= nFlag; else nFeatureFlags &= ~nFlag; }
OUString MakeNumString( const SvxNodeNum& ) const;
OUString MakeNumString(const SvxNodeNum&, LanguageType eLang) const;
SvxNumRuleType GetNumRuleType() const { return eNumberingType; }
+3
View File
@@ -11,6 +11,7 @@
#include <svx/svxdllapi.h>
#include <editeng/numitem.hxx>
#include <vcl/weld/customweld.hxx>
#include <i18nlangtag/lang.h>
/// Provides the preview to show how looks bullet or numbering format before the apply.
class SVXCORE_DLLPUBLIC SvxNumberingPreview final : public weld::CustomWidgetController
@@ -19,12 +20,14 @@ class SVXCORE_DLLPUBLIC SvxNumberingPreview final : public weld::CustomWidgetCon
vcl::Font m_aStdFont;
bool m_bPosition;
sal_uInt16 m_nActLevel;
LanguageType m_eLang;
virtual void Paint(vcl::RenderContext& rRenderContext,
const ::tools::Rectangle& rRect) override;
public:
SvxNumberingPreview();
void SetLanguage(LanguageType eLang) { m_eLang = eLang; }
void SetNumRule(const SvxNumRule* pNum)
{
+7 -5
View File
@@ -18,7 +18,9 @@
*/
#include <editeng/brushitem.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/numitem.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <svtools/colorcfg.hxx>
#include <svx/dialmgr.hxx>
@@ -30,7 +32,7 @@
#include <vcl/rendercontext/GetDefaultFontFlags.hxx>
#include <vcl/virdev.hxx>
#include <numberingtype.hrc>
#include <com/sun/star/lang/Locale.hpp>
#include <com/sun/star/style/NumberingType.hpp>
SvxPageNumberListBox::SvxPageNumberListBox(std::unique_ptr<weld::ComboBox> pControl)
@@ -63,6 +65,7 @@ SvxNumberingPreview::SvxNumberingPreview()
: m_pActNum(nullptr)
, m_bPosition(false)
, m_nActLevel(SAL_MAX_UINT16)
, m_eLang(LANGUAGE_NONE)
{
}
@@ -159,8 +162,7 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext,
tools::Long nYStep = (aSize.Height() - 6)
/ (m_pActNum->GetLevelCount() > 1 ? m_pActNum->GetLevelCount() : 5);
m_aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS,
MsLangId::getConfiguredSystemLanguage(),
m_aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, m_eLang,
GetDefaultFontFlags::OnlyOne);
m_aStdFont.SetColor(aTextColor);
m_aStdFont.SetFillColor(aBackColor);
@@ -245,7 +247,7 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext,
aNum.SetLevel(nLevel);
if (m_pActNum->IsContinuousNumbering())
aNum.GetLevelVal()[nLevel] = nPreNum;
OUString aText(m_pActNum->MakeNumString(aNum));
OUString aText(m_pActNum->MakeNumString(aNum, m_eLang));
vcl::Font aSaveFont = pVDev->GetFont();
vcl::Font aColorFont(aSaveFont);
Color aTmpBulletColor = rFmt.GetBulletColor();
@@ -401,7 +403,7 @@ void SvxNumberingPreview::Paint(vcl::RenderContext& rRenderContext,
aNum.SetLevel(nLevel);
if (m_pActNum->IsContinuousNumbering())
aNum.GetLevelVal()[nLevel] = nPreNum;
OUString aText(m_pActNum->MakeNumString(aNum));
OUString aText(m_pActNum->MakeNumString(aNum, m_eLang));
tools::Long nY = nYStart;
nY -= (pVDev->GetTextHeight() - nTextHeight
- pVDev->GetFontMetric().GetDescent());
+5
View File
@@ -432,6 +432,11 @@ void SwNumPositionTabPage::Reset( const SfxItemSet* rSet )
ShowControlsDependingOnPosAndSpaceMode();
InitControls();
m_bModified = false;
const SvxLanguageItem* pLangItem = rSet->GetItemIfSet(SID_ATTR_CHAR_LANGUAGE, true);
if (!pLangItem)
pLangItem = rSet->GetItemIfSet(EE_CHAR_LANGUAGE, true);
if (pLangItem)
m_aPreviewWIN.SetLanguage(pLangItem->GetLanguage());
}
void SwNumPositionTabPage::InitPosAndSpaceMode()
+2 -2
View File
@@ -913,7 +913,7 @@ void NumberingPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Re
const tools::Long nXStep = aSize.Width() / (3 * MAXLEVEL * ((MAXLEVEL < 10) ? 2 : 1));
const tools::Long nYStep = (aSize.Height() - 6)/ MAXLEVEL;
tools::Long nYStart = 4;
m_aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, GetAppLanguage(),
m_aStdFont = OutputDevice::GetDefaultFont(DefaultFontType::UI_SANS, m_eLang,
GetDefaultFontFlags::OnlyOne, &rRenderContext);
if (svtools::ColorConfig().GetColorValue(svtools::FONTCOLOR, false).nColor == COL_AUTO)
@@ -981,7 +981,7 @@ void NumberingPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Re
pVDev->SetFont(m_aStdFont);
if(m_pActNum->IsContinusNum())
aNumVector[nLevel] = nPreNum;
OUString aText(m_pActNum->MakeNumString( aNumVector ));
OUString aText(m_pActNum->MakeNumString(aNumVector, true, 255, false, nullptr, m_eLang));
pVDev->DrawText( Point(nNumberXPos, nYStart), aText );
nBulletWidth = pVDev->GetTextWidth(aText);
nPreNum++;
+6 -1
View File
@@ -22,6 +22,8 @@
#include <names.hxx>
#include <vcl/weld/customweld.hxx>
#include <editeng/eeitem.hxx>
#include <editeng/langitem.hxx>
class SwNumRule;
@@ -29,10 +31,11 @@ class NumberingPreview final : public weld::CustomWidgetController
{
const SwNumRule* m_pActNum;
vcl::Font m_aStdFont;
tools::Long m_nPageWidth;
tools::Long m_nPageWidth;
const UIName* m_pOutlineNames;
bool m_bPosition;
sal_uInt16 m_nActLevel;
LanguageType m_eLang;
private:
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
@@ -44,6 +47,7 @@ public:
, m_pOutlineNames(nullptr)
, m_bPosition(false)
, m_nActLevel(USHRT_MAX)
, m_eLang(LANGUAGE_NONE)
{
}
@@ -60,6 +64,7 @@ public:
void SetPositionMode()
{ m_bPosition = true;}
void SetLevel(sal_uInt16 nSet) {m_nActLevel = nSet;}
void SetLanguage(LanguageType eLang) { m_eLang = eLang; }
};
#endif
+7 -1
View File
@@ -22,6 +22,9 @@
#include <svl/stritem.hxx>
#include <editeng/numitem.hxx>
#include <editeng/brushitem.hxx>
#include <editeng/langitem.hxx>
#include <editeng/eeitem.hxx>
#include <svx/svxids.hrc>
#include <osl/diagnose.h>
#include <numrule.hxx>
@@ -119,7 +122,7 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
case FN_NUMBER_BULLETS:
case SID_OUTLINE_BULLET:
{
SfxItemSetFixed<SID_HTML_MODE, SID_HTML_MODE,
SfxItemSetFixed<EE_CHAR_LANGUAGE, EE_CHAR_LANGUAGE, SID_HTML_MODE, SID_HTML_MODE,
SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL> aSet( GetPool() );
SwDocShell* pDocSh = GetView().GetDocShell();
const bool bHtml = dynamic_cast<SwWebDocShell*>( pDocSh ) != nullptr;
@@ -186,6 +189,9 @@ void SwTextShell::ExecEnterNum(SfxRequest &rReq)
aSet.Put( SfxBoolItem( SID_PARAM_NUM_PRESET,false ));
LanguageType eLang = GetShell().GetCurLang();
aSet.Put(SvxLanguageItem(eLang, EE_CHAR_LANGUAGE));
// Before the dialogue of the HTML mode will be dropped at the Docshell.
pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh)));