summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-03-01 16:29:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-03-02 08:30:52 +0100
commit31a8627f0323fad0f85f7859a513dbc039375afb (patch)
treec0b8ca5310c2c56661f02c90c3072c11a01e6576 /sw
parenta12b4d548cd4173d87d8736ec6a484becb44d943 (diff)
add TypedWhichId version of GetWhichOfScript
Change-Id: Ieb93f9525d0cc5b3a23e013f30ddaad6f44890ed Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130796 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/hintids.hxx6
-rw-r--r--sw/source/core/bastyp/calc.cxx6
-rw-r--r--sw/source/core/fields/expfld.cxx8
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx4
-rw-r--r--sw/source/uibase/shells/annotsh.cxx6
-rw-r--r--sw/source/uibase/shells/drwtxtsh.cxx8
-rw-r--r--sw/source/uibase/shells/textsh.cxx12
7 files changed, 32 insertions, 18 deletions
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index c3907b20dc16..76068d21ec47 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -547,6 +547,12 @@ template <class T> inline const T* GetDfltAttr(TypedWhichId<T> nWhich)
SW_DLLPUBLIC sal_uInt16 GetWhichOfScript(sal_uInt16 nWhich, sal_uInt16 nScript);
+template <class T>
+inline TypedWhichId<T> GetWhichOfScript(TypedWhichId<T> nWhich, sal_uInt16 nScript)
+{
+ return TypedWhichId<T>(GetWhichOfScript(sal_uInt16(nWhich), nScript));
+}
+
// return for the given TextAttribute without an end the correct character.
// This function returns
// CH_TXTATR_BREAKWORD for Textattribute which breaks a word (default)
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 3ba77ed08a2d..02983568e0f9 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -196,10 +196,10 @@ CalcOp* FindOperator( const OUString& rSrch )
static LanguageType GetDocAppScriptLang( SwDoc const & rDoc )
{
- return static_cast<const SvxLanguageItem&>(rDoc.GetDefault(
+ TypedWhichId<SvxLanguageItem> nWhich =
GetWhichOfScript( RES_CHRATR_LANGUAGE,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ))
- )).GetLanguage();
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ));
+ return rDoc.GetDefault(nWhich).GetLanguage();
}
static double lcl_ConvertToDateValue( SwDoc& rDoc, sal_Int32 nDate )
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index d22e29ddd6c1..6c5f45f3716d 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -996,11 +996,11 @@ sal_Int32 SwGetExpField::GetReferenceTextPos( const SwFormatField& rFormat, SwDo
SwAttrSet aSet(rDoc.GetAttrPool(), nIds);
rTextNode.GetParaAttr(aSet, nRet, nRet+1);
- if( RTL_TEXTENCODING_SYMBOL != static_cast<const SvxFontItem&>(aSet.Get(
- GetWhichOfScript( RES_CHRATR_FONT, nSrcpt )) ).GetCharSet() )
+ TypedWhichId<SvxFontItem> nFontWhich = GetWhichOfScript( RES_CHRATR_FONT, nSrcpt );
+ if( RTL_TEXTENCODING_SYMBOL != aSet.Get( nFontWhich ).GetCharSet() )
{
- LanguageType eLang = static_cast<const SvxLanguageItem&>(aSet.Get(
- GetWhichOfScript( RES_CHRATR_LANGUAGE, nSrcpt )) ).GetLanguage();
+ TypedWhichId<SvxLanguageItem> nLangWhich = GetWhichOfScript( RES_CHRATR_LANGUAGE, nSrcpt ) ;
+ LanguageType eLang = aSet.Get(nLangWhich).GetLanguage();
LanguageTag aLanguageTag( eLang);
CharClass aCC( aLanguageTag);
sal_Unicode c0 = sNodeText[0];
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index f90d04a765a3..97893aae6c13 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3246,8 +3246,8 @@ void AttributeOutputBase::TextField( const SwFormatField& rField )
assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());
sal_uInt16 nScript = g_pBreakIt->GetBreakIter()->getScriptType( pField->GetPar1(), 0);
- tools::Long nHeight = static_cast<const SvxFontHeightItem&>((GetExport().GetItem(
- GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript)))).GetHeight();
+ TypedWhichId<SvxFontHeightItem> nFontHeightWhich = GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript);
+ tools::Long nHeight = GetExport().GetItem(nFontHeightWhich).GetHeight();
nHeight = (nHeight + 10) / 20; //Font Size in points;
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index 3246e43bc404..21b249fb00d2 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -1762,9 +1762,11 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
}
else
{
- aSetDlgFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript(
+ TypedWhichId<SvxFontItem> nFontWhich =
+ GetWhichOfScript(
SID_ATTR_CHAR_FONT,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone()));
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
+ aSetDlgFont.reset(aSet.Get(nFontWhich).Clone());
}
if (sFontName.isEmpty())
diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx
index 43c35159f671..2416c3a4863c 100644
--- a/sw/source/uibase/shells/drwtxtsh.cxx
+++ b/sw/source/uibase/shells/drwtxtsh.cxx
@@ -701,9 +701,13 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
if( pI )
aSetDlgFont.reset(static_cast<SvxFontItem*>(pI->Clone()));
else
- aSetDlgFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript(
+ {
+ TypedWhichId<SvxFontItem> nFontWhich =
+ GetWhichOfScript(
SID_ATTR_CHAR_FONT,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone()));
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
+ aSetDlgFont.reset(aSet.Get( nFontWhich ).Clone());
+ }
if (sFontName.isEmpty())
sFontName = aSetDlgFont->GetFamilyName();
}
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index 158e381b1351..8fe5862e3479 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -909,11 +909,11 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
}
else
{
- aFont.reset(static_cast<SvxFontItem*>(
- aSet.Get(
+ TypedWhichId<SvxFontItem> nFontWhich =
GetWhichOfScript(
RES_CHRATR_FONT,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone()));
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
+ aFont.reset(aSet.Get(nFontWhich).Clone());
}
if (aFontName.isEmpty())
@@ -966,9 +966,11 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
}
else
{
- aFont.reset(static_cast<SvxFontItem*>(aSet.Get( GetWhichOfScript(
+ TypedWhichId<SvxFontItem> nFontWhich =
+ GetWhichOfScript(
RES_CHRATR_FONT,
- SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) )).Clone()));
+ SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetAppLanguage() ) );
+ aFont.reset(aSet.Get( nFontWhich ).Clone());
}
}