replace sal_uLong variables with sal_uInt32 for SvNumberFormatter IDs
Replace the stopgap type sal_uLong as SvNumberFormatter
format index uses sal_uInt32.
SwInsertDBColAutoPilot uses format indices from SvNumberFormatter and
from the property "FormatKey" which is stored as sal_Int32 but ctor
guards against negative values.
Change type of loop variable in SwCaptionDialog to avoid narrowing
in GetFormatStr/GetFormatKey.
Change-Id: I79980696c07760f7ff026bb1bacf0e069363898c
Reviewed-on: https://gerrit.libreoffice.org/40464
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx
index 50dc382..7612621 100644
--- a/editeng/source/items/flditem.cxx
+++ b/editeng/source/items/flditem.cxx
@@ -439,7 +439,7 @@ OUString SvxDateField::GetFormatted( Date const & aDate, SvxDateFormat eFormat,
eFormat = SVXDATEFORMAT_STDSMALL;
}
sal_uLong nFormatKey;
sal_uInt32 nFormatKey;
switch( eFormat )
{
diff --git a/sw/inc/dbfld.hxx b/sw/inc/dbfld.hxx
index 753d119..62318b1 100644
--- a/sw/inc/dbfld.hxx
+++ b/sw/inc/dbfld.hxx
@@ -66,7 +66,7 @@ class SW_DLLPUBLIC SwDBField : public SwValueField
virtual SwField* Copy() const override;
public:
SwDBField(SwDBFieldType*, sal_uLong nFormat = 0);
SwDBField(SwDBFieldType*, sal_uInt32 nFormat = 0);
virtual ~SwDBField() override;
virtual SwFieldType* ChgTyp( SwFieldType* ) override;
@@ -127,7 +127,7 @@ protected:
const SwDBData& GetDBData() const {return aDBData;}
SwDBData& GetDBData() {return aDBData;}
SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uLong nFormat = 0);
SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uInt32 nFormat = 0);
public:
/// DBName
@@ -267,7 +267,7 @@ class SW_DLLPUBLIC SwDBSetNumberField : public SwDBNameInfField
{
long nNumber;
public:
SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uLong nFormat = 0);
SwDBSetNumberField(SwDBSetNumberFieldType*, const SwDBData& rDBData, sal_uInt32 nFormat = 0);
virtual OUString Expand() const override;
virtual SwField* Copy() const override;
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 320ace2..3631e5f 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1473,7 +1473,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex)
break;
case SwFieldIds::JumpEdit:
{
const sal_uInt16 nFormat= pField->GetFormat();
const sal_uInt32 nFormat= pField->GetFormat();
const sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false);
if (nFormat < nSize)
{
@@ -1534,7 +1534,7 @@ OUString SwAccessibleParagraph::GetFieldTypeNameAtIndex(sal_Int32 nIndex)
if (nWhich == SwFieldIds::DocInfo)
{
strTypeName = sEntry;
sal_uInt32 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false);
sal_uInt16 nSize = aMgr.GetFormatCount(pField->GetTypeId(), false);
const sal_uInt16 nExSub = pField->GetSubType() & 0xff00;
if (nSize > 0 && nExSub > 0)
{
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index 0df616a..d77b6d2 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -167,7 +167,7 @@ bool SwDBFieldType::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
// database field
SwDBField::SwDBField(SwDBFieldType* pTyp, sal_uLong nFormat)
SwDBField::SwDBField(SwDBFieldType* pTyp, sal_uInt32 nFormat)
: SwValueField(pTyp, nFormat),
nSubType(0),
bIsInBodyText(true),
@@ -448,7 +448,7 @@ bool SwDBField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
// base class for all further database fields
SwDBNameInfField::SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uLong nFormat) :
SwDBNameInfField::SwDBNameInfField(SwFieldType* pTyp, const SwDBData& rDBData, sal_uInt32 nFormat) :
SwField(pTyp, nFormat),
aDBData(rDBData),
nSubType(0)
@@ -808,7 +808,7 @@ SwFieldType* SwDBSetNumberFieldType::Copy() const
SwDBSetNumberField::SwDBSetNumberField(SwDBSetNumberFieldType* pTyp,
const SwDBData& rDBData,
sal_uLong nFormat)
sal_uInt32 nFormat)
: SwDBNameInfField(pTyp, rDBData, nFormat), nNumber(0)
{}
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 03ad470..272d2d6 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -116,7 +116,7 @@ struct DB_Column
union {
OUString* pText;
SwField* pField;
sal_uLong nFormat;
sal_uInt32 nFormat;
};
const SwInsDBColumn* pColInfo;
@@ -131,7 +131,7 @@ struct DB_Column
pColInfo(nullptr)
{}
DB_Column( const SwInsDBColumn& rInfo, sal_uLong nFormat_ )
DB_Column( const SwInsDBColumn& rInfo, sal_uInt32 nFormat_ )
: eColType(Type::COL_TEXT),
nFormat(nFormat_),
pColInfo(&rInfo)
@@ -301,7 +301,7 @@ SwInsertDBColAutoPilot::SwInsertDBColAutoPilot( SwView& rView,
aFormatVal >>= sFormat;
lang::Locale aLoc;
aLocale >>= aLoc;
long nKey = xDocNumberFormats->queryKey( sFormat, aLoc, true);
sal_Int32 nKey = xDocNumberFormats->queryKey( sFormat, aLoc, true);
if(nKey < 0)
{
nKey = xDocNumberFormats->addNew( sFormat, aLoc );
@@ -913,11 +913,11 @@ bool SwInsertDBColAutoPilot::SplitTextToColArr( const OUString& rText,
nSttPos = 0;
sal_uInt16 nSubType = 0;
sal_uLong nFormat;
sal_uInt32 nFormat;
if( rFndCol.bHasFormat )
{
if( rFndCol.bIsDBFormat )
nFormat = rFndCol.nDBNumFormat;
nFormat = static_cast<sal_uInt32>(rFndCol.nDBNumFormat);
else
{
nFormat = rFndCol.nUsrNumFormat;
@@ -1122,7 +1122,7 @@ void SwInsertDBColAutoPilot::DataToDoc( const Sequence<Any>& rSelection,
if( pEntry->bHasFormat )
{
SwTableBoxNumFormat aNumFormat(
pEntry->bIsDBFormat ? pEntry->nDBNumFormat
pEntry->bIsDBFormat ? static_cast<sal_uInt32>(pEntry->nDBNumFormat)
: pEntry->nUsrNumFormat );
aTableSet.Put(aNumFormat);
if( xColumn.is() )
diff --git a/sw/source/ui/fldui/flddinf.cxx b/sw/source/ui/fldui/flddinf.cxx
index 02e65cc..f7b4df0 100644
--- a/sw/source/ui/fldui/flddinf.cxx
+++ b/sw/source/ui/fldui/flddinf.cxx
@@ -326,7 +326,7 @@ IMPL_LINK_NOARG(SwFieldDokInfPage, SubTypeHdl, ListBox&, void)
bEnable = true;
}
sal_uLong nFormat = IsFieldEdit() ? static_cast<SwDocInfoField*>(GetCurField())->GetFormat() : 0;
sal_uInt32 nFormat = IsFieldEdit() ? static_cast<SwDocInfoField*>(GetCurField())->GetFormat() : 0;
sal_uInt16 nOldSubType = IsFieldEdit() ? (static_cast<SwDocInfoField*>(GetCurField())->GetSubType() & 0xff00) : 0;
@@ -430,7 +430,7 @@ bool SwFieldDokInfPage::FillItemSet(SfxItemSet* )
sal_uInt16 nSubType = (sal_uInt16)reinterpret_cast<sal_uLong>(pSelEntry->GetUserData());
sal_uLong nFormat = 0;
sal_uInt32 nFormat = 0;
sal_Int32 nPos = m_pSelectionLB->GetSelectEntryPos();
diff --git a/sw/source/ui/fldui/fldpage.cxx b/sw/source/ui/fldui/fldpage.cxx
index a0dedb4..b1bdd9e 100644
--- a/sw/source/ui/fldui/fldpage.cxx
+++ b/sw/source/ui/fldui/fldpage.cxx
@@ -117,7 +117,7 @@ void SwFieldPage::EditNewField( bool bOnlyActivate )
// insert field
void SwFieldPage::InsertField(sal_uInt16 nTypeId, sal_uInt16 nSubType, const OUString& rPar1,
const OUString& rPar2, sal_uLong nFormatId,
const OUString& rPar2, sal_uInt32 nFormatId,
sal_Unicode cSeparator, bool bIsAutomaticLanguage)
{
SwView* pView = GetActiveView();
diff --git a/sw/source/ui/fldui/fldpage.hxx b/sw/source/ui/fldui/fldpage.hxx
index 548cd5d..4fa6c41 100644
--- a/sw/source/ui/fldui/fldpage.hxx
+++ b/sw/source/ui/fldui/fldpage.hxx
@@ -70,7 +70,7 @@ protected:
sal_uInt16 nSubType,
const OUString& rPar1,
const OUString& rPar2,
sal_uLong nFormatId,
sal_uInt32 nFormatId,
sal_Unicode cDelim = ' ',
bool bIsAutomaticLanguage = true);
diff --git a/sw/source/ui/frmdlg/cption.cxx b/sw/source/ui/frmdlg/cption.cxx
index 5fa7714..20b8ccf 100644
--- a/sw/source/ui/frmdlg/cption.cxx
+++ b/sw/source/ui/frmdlg/cption.cxx
@@ -214,8 +214,8 @@ SwCaptionDialog::SwCaptionDialog( vcl::Window *pParent, SwView &rV ) :
}
}
nCount = pMgr->GetFormatCount(TYP_SEQFLD, false);
for ( size_t i = 0; i < nCount; ++i )
sal_uInt16 nFormatCount = pMgr->GetFormatCount(TYP_SEQFLD, false);
for ( sal_uInt16 i = 0; i < nFormatCount; ++i )
{
m_pFormatBox->InsertEntry( pMgr->GetFormatStr(TYP_SEQFLD, i) );
const sal_uInt16 nFormatId = pMgr->GetFormatId(TYP_SEQFLD, i);
diff --git a/sw/source/uibase/fldui/fldmgr.cxx b/sw/source/uibase/fldui/fldmgr.cxx
index 93c635d..fb7f82c 100644
--- a/sw/source/uibase/fldui/fldmgr.cxx
+++ b/sw/source/uibase/fldui/fldmgr.cxx
@@ -718,7 +718,7 @@ sal_uInt16 SwFieldMgr::GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const
}
// determine FormatString to a type
OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const
OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
{
OSL_ENSURE(nTypeId < TYP_END, "forbidden TypeId");
const sal_uInt16 nPos = GetPos(nTypeId);
@@ -731,7 +731,7 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const
return OUString();
if (TYP_AUTHORFLD == nTypeId|| TYP_FILENAMEFLD == nTypeId)
nFormatId &= ~FF_FIXED; // mask out Fixed-Flag
nFormatId &= ~static_cast<sal_uInt32>(FF_FIXED); // mask out Fixed-Flag
if (nFormatId < aSwFields[nPos].nFormatLength)
return SwResId(pStart[nFormatId]);
@@ -743,14 +743,14 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const
{
Sequence<sal_Int16> aTypes = xNumberingInfo->getSupportedNumberingTypes();
const sal_Int16* pTypes = aTypes.getConstArray();
sal_Int32 nValidEntry = 0;
sal_uInt32 nValidEntry = 0;
for (sal_Int32 nType = 0; nType < aTypes.getLength(); nType++)
{
sal_Int16 nCurrent = pTypes[nType];
if(nCurrent > NumberingType::CHARS_LOWER_LETTER_N &&
(nCurrent != (NumberingType::BITMAP | LINK_TOKEN)))
{
if (nValidEntry == ((sal_Int32)nFormatId))
if (nValidEntry == nFormatId)
{
sal_uInt32 n = SvxNumberingTypeTable::FindIndex(pTypes[nType]);
if (n != RESARRAY_INDEX_NOTFOUND)
@@ -773,7 +773,7 @@ OUString SwFieldMgr::GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const
}
// determine FormatId from Pseudo-ID
sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const
sal_uInt16 SwFieldMgr::GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const
{
sal_uInt16 nId = (sal_uInt16)nFormatId;
switch( nTypeId )
@@ -902,7 +902,7 @@ bool SwFieldMgr::InsertField(
bool bExp = false;
bool bTable = false;
bool bPageVar = false;
sal_uLong nFormatId = rData.m_nFormatId;
sal_uInt32 nFormatId = rData.m_nFormatId;
sal_uInt16 nSubType = rData.m_nSubType;
sal_Unicode cSeparator = rData.m_cSeparator;
SwWrtShell* pCurShell = rData.m_pSh;
@@ -1510,7 +1510,7 @@ bool SwFieldMgr::InsertField(
}
// fields update
void SwFieldMgr::UpdateCurField(sal_uLong nFormat,
void SwFieldMgr::UpdateCurField(sal_uInt32 nFormat,
const OUString& rPar1,
const OUString& rPar2,
SwField * _pTmpField)
@@ -1806,7 +1806,7 @@ void SwFieldMgr::SetMacroPath(const OUString& rPath)
}
}
sal_uLong SwFieldMgr::GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
sal_uInt32 SwFieldMgr::GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter)
{
short nDefFormat;
diff --git a/sw/source/uibase/inc/fldmgr.hxx b/sw/source/uibase/inc/fldmgr.hxx
index 4e134e5..916c40f4 100644
--- a/sw/source/uibase/inc/fldmgr.hxx
+++ b/sw/source/uibase/inc/fldmgr.hxx
@@ -70,7 +70,7 @@ struct SwInsertField_Data
sal_uInt16 m_nSubType;
const OUString m_sPar1;
const OUString m_sPar2;
sal_uLong m_nFormatId;
sal_uInt32 m_nFormatId;
SwWrtShell* m_pSh;
sal_Unicode m_cSeparator;
bool m_bIsAutomaticLanguage;
@@ -80,7 +80,7 @@ struct SwInsertField_Data
VclPtr<vcl::Window> m_pParent; // parent dialog used for SwWrtShell::StartInputFieldDlg()
SwInsertField_Data(sal_uInt16 nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2,
sal_uLong nFormatId, SwWrtShell* pShell = nullptr, sal_Unicode cSep = ' ', bool bIsAutoLanguage = true) :
sal_uInt32 nFormatId, SwWrtShell* pShell = nullptr, sal_Unicode cSep = ' ', bool bIsAutoLanguage = true) :
m_nTypeId(nType),
m_nSubType(nSub),
m_sPar1(rPar1),
@@ -105,7 +105,7 @@ private:
OUString sMacroPath;
OUString sMacroName;
sal_uLong nCurFormat;
sal_uInt32 nCurFormat;
bool bEvalExp;
SAL_DLLPRIVATE LanguageType GetCurrLanguage() const;
@@ -124,7 +124,7 @@ public:
bool InsertField( const SwInsertField_Data& rData );
// change the current field directly
void UpdateCurField(sal_uLong nFormat,
void UpdateCurField(sal_uInt32 nFormat,
const OUString& rPar1,
const OUString& rPar2,
SwField * _pField = nullptr);
@@ -181,9 +181,9 @@ public:
// format to a type
sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bHtmlMode) const;
OUString GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter);
OUString GetFormatStr(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const;
sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uInt32 nFormatId) const;
sal_uInt32 GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter);
// turn off evaluation of expression fields for insertation
// of many expression fields (see labels)
diff --git a/sw/source/uibase/inc/numfmtlb.hxx b/sw/source/uibase/inc/numfmtlb.hxx
index 27cdbc1..bcc5f5f 100644
--- a/sw/source/uibase/inc/numfmtlb.hxx
+++ b/sw/source/uibase/inc/numfmtlb.hxx
@@ -30,7 +30,7 @@ class SW_DLLPUBLIC NumFormatListBox : public ListBox
short nCurrFormatType;
sal_Int32 nStdEntry;
bool bOneArea;
sal_uLong nDefFormat;
sal_uInt32 nDefFormat;
SwView* pVw;
SvNumberFormatter* pOwnFormatter;
LanguageType eCurLanguage;
@@ -56,8 +56,8 @@ public:
void SetFormatType(const short nFormatType);
short GetFormatType() const { return nCurrFormatType; }
void SetDefFormat(const sal_uLong nDefFormat);
sal_uLong GetFormat() const;
void SetDefFormat(const sal_uInt32 nDefFormat);
sal_uInt32 GetFormat() const;
LanguageType GetCurLanguage() const { return eCurLanguage;}
void SetLanguage(LanguageType eSet) { eCurLanguage = eSet;}
diff --git a/sw/source/uibase/shells/textfld.cxx b/sw/source/uibase/shells/textfld.cxx
index 811db69..74263ba 100644
--- a/sw/source/uibase/shells/textfld.cxx
+++ b/sw/source/uibase/shells/textfld.cxx
@@ -119,7 +119,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
bool bIsText = true;
sal_uInt16 nInsertType = 0;
sal_uInt16 nInsertSubType = 0;
sal_uLong nInsertFormat = 0;
sal_uInt32 nInsertFormat = 0;
switch(nSlot)
{
@@ -221,7 +221,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
bool bRes = false;
if( pItem )
{
sal_uLong nFormat = 0;
sal_uInt32 nFormat = 0;
sal_uInt16 nType = 0;
OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue();
OUString aPar2;
@@ -266,7 +266,7 @@ void SwTextShell::ExecField(SfxRequest &rReq)
bool bRes = false;
if( pItem && nSlot != FN_INSERT_FIELD_CTRL)
{
sal_uLong nFormat = 0;
sal_uInt32 nFormat = 0;
sal_uInt16 nType = 0;
sal_uInt16 nSubType = 0;
OUString aPar1 = static_cast<const SfxStringItem *>(pItem)->GetValue();
diff --git a/sw/source/uibase/utlui/numfmtlb.cxx b/sw/source/uibase/utlui/numfmtlb.cxx
index f1cc7b0..b718d47 100644
--- a/sw/source/uibase/utlui/numfmtlb.cxx
+++ b/sw/source/uibase/utlui/numfmtlb.cxx
@@ -260,9 +260,9 @@ void NumFormatListBox::SetFormatType(const short nFormatType)
}
}
void NumFormatListBox::SetDefFormat(const sal_uLong nDefaultFormat)
void NumFormatListBox::SetDefFormat(const sal_uInt32 nDefaultFormat)
{
if (nDefaultFormat == ULONG_MAX)
if (nDefaultFormat == NUMBERFORMAT_ENTRY_NOT_FOUND)
{
nDefFormat = nDefaultFormat;
return;
@@ -285,11 +285,11 @@ void NumFormatListBox::SetDefFormat(const sal_uLong nDefaultFormat)
SetFormatType(nType);
sal_uLong nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefaultFormat, eCurLanguage);
sal_uInt32 nFormat = pFormatter->GetFormatForLanguageIfBuiltIn(nDefaultFormat, eCurLanguage);
for (sal_Int32 i = 0; i < GetEntryCount(); i++)
{
if (nFormat == reinterpret_cast<sal_uLong>(GetEntryData(i)))
if (nFormat == static_cast<sal_uInt32>(reinterpret_cast<sal_uIntPtr>(GetEntryData(i))))
{
SelectEntryPos(i);
nStdEntry = i;
@@ -313,7 +313,7 @@ void NumFormatListBox::SetDefFormat(const sal_uLong nDefaultFormat)
}
sal_Int32 nPos = 0;
while (reinterpret_cast<sal_uLong>(GetEntryData(nPos)) == ULONG_MAX)
while (static_cast<sal_uInt32>(reinterpret_cast<sal_uIntPtr>(GetEntryData(nPos))) == NUMBERFORMAT_ENTRY_NOT_FOUND)
nPos++;
const sal_uInt32 nSysNumFormat = pFormatter->GetFormatIndex( NF_NUMBER_SYSTEM, eCurLanguage);
@@ -349,11 +349,11 @@ void NumFormatListBox::SetDefFormat(const sal_uLong nDefaultFormat)
nDefFormat = GetFormat();
}
sal_uLong NumFormatListBox::GetFormat() const
sal_uInt32 NumFormatListBox::GetFormat() const
{
sal_Int32 nPos = GetSelectEntryPos();
return reinterpret_cast<sal_uLong>(GetEntryData(nPos));
return static_cast<sal_uInt32>(reinterpret_cast<sal_uIntPtr>(GetEntryData(nPos)));
}
IMPL_LINK( NumFormatListBox, SelectHdl, ListBox&, rBox, void )
@@ -380,7 +380,7 @@ IMPL_LINK( NumFormatListBox, SelectHdl, ListBox&, rBox, void )
double fValue = GetDefValue( nCurrFormatType);
sal_uLong nFormat = pFormatter->GetStandardFormat( nCurrFormatType, eCurLanguage);
sal_uInt32 nFormat = pFormatter->GetStandardFormat( nCurrFormatType, eCurLanguage);
aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormat ));
aCoreSet.Put( SvxNumberInfoItem( pFormatter, fValue,