pass DelFormats around using std::vector
instead of an array and a separate count Change-Id: Ia12a549da7e35092da2db35f8b2b9fc6a9e9c2be Reviewed-on: https://gerrit.libreoffice.org/59506 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
68b9553d44
commit
e8e5584882
10 changed files with 37 additions and 116 deletions
|
@ -757,14 +757,12 @@ bool SvxNumberFormatTabPage::FillItemSet( SfxItemSet* rCoreAttrs )
|
|||
|
||||
// List of changed user defined formats:
|
||||
|
||||
const size_t nDelCount = pNumFmtShell->GetUpdateDataCount();
|
||||
std::vector<sal_uInt32> const & aDelFormats = pNumFmtShell->GetUpdateData();
|
||||
|
||||
if ( nDelCount > 0 )
|
||||
if ( !aDelFormats.empty() )
|
||||
{
|
||||
std::unique_ptr<sal_uInt32[]> pDelArr(new sal_uInt32[nDelCount]);
|
||||
|
||||
pNumFmtShell->GetUpdateData( pDelArr.get(), nDelCount );
|
||||
pNumItem->SetDelFormatArray( pDelArr.get(), nDelCount );
|
||||
pNumItem->SetDelFormats( aDelFormats );
|
||||
|
||||
if(bNumItemFlag)
|
||||
{
|
||||
|
|
|
@ -873,12 +873,10 @@ bool callColumnFormatDialog(vcl::Window* _pParent,
|
|||
{
|
||||
const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
|
||||
const SvxNumberInfoItem* pInfoItem = static_cast<const SvxNumberInfoItem*>(pItem);
|
||||
if (pInfoItem && pInfoItem->GetDelCount())
|
||||
if (pInfoItem)
|
||||
{
|
||||
const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
|
||||
|
||||
for (sal_uInt32 i=0; i< pInfoItem->GetDelCount(); ++i)
|
||||
_pFormatter->DeleteEntry(pDeletedKeys[i]);
|
||||
for (sal_uInt32 key : pInfoItem->GetDelFormats())
|
||||
_pFormatter->DeleteEntry(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2658,12 +2658,10 @@ namespace pcr
|
|||
|
||||
const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
|
||||
const SvxNumberInfoItem* pInfoItem = dynamic_cast< const SvxNumberInfoItem* >( pItem );
|
||||
if (pInfoItem && pInfoItem->GetDelCount())
|
||||
if (pInfoItem)
|
||||
{
|
||||
const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
|
||||
|
||||
for (sal_uInt32 i=0; i< pInfoItem->GetDelCount(); ++i)
|
||||
pFormatter->DeleteEntry(pDeletedKeys[i]);
|
||||
for (sal_uInt32 key : pInfoItem->GetDelFormats())
|
||||
pFormatter->DeleteEntry(key);
|
||||
}
|
||||
|
||||
pItem = nullptr;
|
||||
|
|
|
@ -144,8 +144,7 @@ public:
|
|||
bool FindEntry( const OUString& rFmtString, sal_uInt32* pAt = nullptr );
|
||||
|
||||
void ValidateNewEntries() { bUndoAddList = false; }
|
||||
size_t GetUpdateDataCount() const;
|
||||
void GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize );
|
||||
std::vector<sal_uInt32> const & GetUpdateData() const;
|
||||
|
||||
void SetCurNumFmtKey( sal_uInt32 nNew ) { nCurFormatKey = nNew; }
|
||||
sal_uInt32 GetCurNumFmtKey() const { return nCurFormatKey; }
|
||||
|
|
|
@ -56,12 +56,10 @@ public:
|
|||
const OUString& GetValueString() const { return aStringVal; }
|
||||
double GetValueDouble() const { return nDoubleVal; }
|
||||
|
||||
const sal_uInt32* GetDelArray() const { return pDelFormatArr.get(); }
|
||||
void SetDelFormatArray( const sal_uInt32* pData,
|
||||
const sal_uInt32 nCount );
|
||||
const std::vector<sal_uInt32> & GetDelFormats() const { return mvDelFormats; }
|
||||
void SetDelFormats( std::vector<sal_uInt32> const & );
|
||||
|
||||
SvxNumberValueType GetValueType() const { return eValueType; }
|
||||
sal_uInt32 GetDelCount() const { return nDelCount; }
|
||||
|
||||
private:
|
||||
SvNumberFormatter* pFormatter;
|
||||
|
@ -69,9 +67,7 @@ private:
|
|||
OUString aStringVal;
|
||||
double nDoubleVal;
|
||||
|
||||
std::unique_ptr<sal_uInt32[]>
|
||||
pDelFormatArr;
|
||||
sal_uInt32 nDelCount;
|
||||
std::vector<sal_uInt32> mvDelFormats;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -386,15 +386,8 @@ SvxNumberInfoItem* ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, const S
|
|||
void ScTabViewShell::UpdateNumberFormatter(
|
||||
const SvxNumberInfoItem& rInfoItem )
|
||||
{
|
||||
const sal_uInt32 nDelCount = rInfoItem.GetDelCount();
|
||||
|
||||
if ( nDelCount > 0 )
|
||||
{
|
||||
const sal_uInt32* pDelArr = rInfoItem.GetDelArray();
|
||||
|
||||
for ( sal_uInt32 i=0; i<nDelCount; i++ )
|
||||
rInfoItem.GetNumberFormatter()->DeleteEntry( pDelArr[i] );
|
||||
}
|
||||
for ( sal_uInt32 key : rInfoItem.GetDelFormats() )
|
||||
rInfoItem.GetNumberFormatter()->DeleteEntry( key );
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -177,21 +177,9 @@ SvxNumberFormatShell::~SvxNumberFormatShell()
|
|||
}
|
||||
|
||||
|
||||
size_t SvxNumberFormatShell::GetUpdateDataCount() const
|
||||
std::vector<sal_uInt32> const & SvxNumberFormatShell::GetUpdateData() const
|
||||
{
|
||||
return aDelList.size();
|
||||
}
|
||||
|
||||
|
||||
void SvxNumberFormatShell::GetUpdateData( sal_uInt32* pDelArray, const sal_uInt32 nSize )
|
||||
{
|
||||
const size_t nListSize = aDelList.size();
|
||||
|
||||
DBG_ASSERT( pDelArray && ( nSize == nListSize ), "Array not initialised!" );
|
||||
|
||||
if ( pDelArray && ( nSize == nListSize ) )
|
||||
for (std::vector<sal_uInt32>::const_iterator it(aDelList.begin()); it != aDelList.end(); ++it )
|
||||
*pDelArray++ = *it;
|
||||
return aDelList;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
pFormatter ( pNum ), \
|
||||
eValueType ( eVal ), \
|
||||
aStringVal ( rStr ), \
|
||||
nDoubleVal ( nDouble ), \
|
||||
pDelFormatArr ( nullptr ), \
|
||||
nDelCount ( 0 )
|
||||
nDoubleVal ( nDouble ) \
|
||||
|
||||
SvxNumberInfoItem::SvxNumberInfoItem( const sal_uInt16 nId ) :
|
||||
|
||||
|
@ -83,17 +81,8 @@ SvxNumberInfoItem::SvxNumberInfoItem( const SvxNumberInfoItem& rItem ) :
|
|||
eValueType ( rItem.eValueType ),
|
||||
aStringVal ( rItem.aStringVal ),
|
||||
nDoubleVal ( rItem.nDoubleVal ),
|
||||
pDelFormatArr( nullptr ),
|
||||
nDelCount ( rItem.nDelCount )
|
||||
|
||||
mvDelFormats( rItem.mvDelFormats )
|
||||
{
|
||||
if ( rItem.nDelCount > 0 )
|
||||
{
|
||||
pDelFormatArr.reset( new sal_uInt32[ rItem.nDelCount ] );
|
||||
|
||||
for ( sal_uInt32 i = 0; i < rItem.nDelCount; ++i )
|
||||
pDelFormatArr[i] = rItem.pDelFormatArr[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,30 +110,11 @@ bool SvxNumberInfoItem::operator==( const SfxPoolItem& rItem ) const
|
|||
|
||||
const SvxNumberInfoItem& rOther = static_cast<const SvxNumberInfoItem&>(rItem);
|
||||
|
||||
bool bEqual = false;
|
||||
|
||||
if ( nDelCount == rOther.nDelCount )
|
||||
{
|
||||
if ( nDelCount > 0 )
|
||||
{
|
||||
if ( pDelFormatArr != nullptr && rOther.pDelFormatArr != nullptr )
|
||||
{
|
||||
bEqual = true;
|
||||
|
||||
for ( sal_uInt32 i = 0; i < nDelCount && bEqual; ++i )
|
||||
bEqual = ( pDelFormatArr[i] == rOther.pDelFormatArr[i] );
|
||||
}
|
||||
}
|
||||
else if ( nDelCount == 0 )
|
||||
bEqual = ( pDelFormatArr == nullptr && rOther.pDelFormatArr == nullptr );
|
||||
|
||||
bEqual = bEqual &&
|
||||
pFormatter == rOther.pFormatter &&
|
||||
eValueType == rOther.eValueType &&
|
||||
nDoubleVal == rOther.nDoubleVal &&
|
||||
aStringVal == rOther.aStringVal;
|
||||
}
|
||||
return bEqual;
|
||||
return mvDelFormats == rOther.mvDelFormats &&
|
||||
pFormatter == rOther.pFormatter &&
|
||||
eValueType == rOther.eValueType &&
|
||||
nDoubleVal == rOther.nDoubleVal &&
|
||||
aStringVal == rOther.aStringVal;
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,23 +124,9 @@ SfxPoolItem* SvxNumberInfoItem::Clone( SfxItemPool * ) const
|
|||
}
|
||||
|
||||
|
||||
void SvxNumberInfoItem::SetDelFormatArray( const sal_uInt32* pData,
|
||||
const sal_uInt32 nCount )
|
||||
void SvxNumberInfoItem::SetDelFormats( std::vector<sal_uInt32> const & aData )
|
||||
{
|
||||
pDelFormatArr.reset();
|
||||
|
||||
nDelCount = nCount;
|
||||
|
||||
if ( nCount > 0 )
|
||||
{
|
||||
pDelFormatArr.reset( new sal_uInt32[ nCount ] );
|
||||
|
||||
if ( pData != nullptr )
|
||||
{
|
||||
for ( sal_uInt32 i = 0; i < nCount; ++i )
|
||||
pDelFormatArr[i] = pData[i];
|
||||
}
|
||||
}
|
||||
mvDelFormats = aData;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -681,26 +681,23 @@ void SwTableShell::Execute(SfxRequest &rReq)
|
|||
|
||||
if (RET_OK == pDlg->Execute())
|
||||
{
|
||||
const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()->
|
||||
GetItem( SID_ATTR_NUMBERFORMAT_INFO );
|
||||
const SvxNumberInfoItem* pNumberFormatItem
|
||||
= GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
|
||||
|
||||
if( pNumberFormatItem && 0 != static_cast<const SvxNumberInfoItem*>(pNumberFormatItem)->GetDelCount() )
|
||||
if( pNumberFormatItem )
|
||||
{
|
||||
const sal_uInt32* pDelArr = static_cast<const SvxNumberInfoItem*>(
|
||||
pNumberFormatItem)->GetDelArray();
|
||||
|
||||
for ( sal_uInt32 i = 0; i < static_cast<const SvxNumberInfoItem*>(pNumberFormatItem)->GetDelCount(); i++ )
|
||||
static_cast<const SvxNumberInfoItem*>(pNumberFormatItem)->
|
||||
GetNumberFormatter()->DeleteEntry( pDelArr[i] );
|
||||
for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
|
||||
pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
|
||||
}
|
||||
|
||||
const SfxPoolItem* pNumberFormatValueItem = nullptr;
|
||||
if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(
|
||||
SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatItem ))
|
||||
SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatValueItem ))
|
||||
{
|
||||
SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
|
||||
svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT>{} );
|
||||
aBoxFormatSet.Put( SwTableBoxNumFormat(
|
||||
static_cast<const SfxUInt32Item*>(pNumberFormatItem)->GetValue() ));
|
||||
static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() ));
|
||||
rSh.SetTableBoxFormulaAttrs( aBoxFormatSet );
|
||||
|
||||
}
|
||||
|
|
|
@ -378,12 +378,10 @@ IMPL_LINK( NumFormatListBox, SelectHdl, ListBox&, rBox, void )
|
|||
const SfxPoolItem* pItem = pView->GetDocShell()->
|
||||
GetItem( SID_ATTR_NUMBERFORMAT_INFO );
|
||||
|
||||
if( pItem && 0 != static_cast<const SvxNumberInfoItem*>(pItem)->GetDelCount() )
|
||||
if( pItem )
|
||||
{
|
||||
const sal_uInt32* pDelArr = static_cast<const SvxNumberInfoItem*>(pItem)->GetDelArray();
|
||||
|
||||
for ( sal_uInt32 i = 0; i < static_cast<const SvxNumberInfoItem*>(pItem)->GetDelCount(); i++ )
|
||||
pFormatter->DeleteEntry( pDelArr[i] );
|
||||
for ( sal_uInt32 key : static_cast<const SvxNumberInfoItem*>(pItem)->GetDelFormats() )
|
||||
pFormatter->DeleteEntry( key );
|
||||
}
|
||||
|
||||
const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
|
||||
|
|
Loading…
Reference in a new issue