summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-02-04 09:13:52 +0000
committerCaolán McNamara <caolanm@redhat.com>2022-02-04 15:02:03 +0100
commite00032ba6a2ddd4c08ae6f03b1982d3c099d288e (patch)
tree33f52e795971fd330922e21857b12c6097727ca8 /basctl
parent8d3f658aa58ddee8c7bc32ddea070c1bb3bf19b8 (diff)
add toId/fromId to tidy up some ugly casting
Change-Id: I70f34ac5e9b5d2f2d6c0375e823908eaa2e540b2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129487 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/IDEComboBox.cxx14
-rw-r--r--basctl/source/basicide/baside2b.cxx24
-rw-r--r--basctl/source/basicide/bastype2.cxx8
-rw-r--r--basctl/source/basicide/moduldl2.cxx6
-rw-r--r--basctl/source/dlged/managelang.cxx8
5 files changed, 30 insertions, 30 deletions
diff --git a/basctl/source/basicide/IDEComboBox.cxx b/basctl/source/basicide/IDEComboBox.cxx
index e295e44ff1ed..423e5c5d1cda 100644
--- a/basctl/source/basicide/IDEComboBox.cxx
+++ b/basctl/source/basicide/IDEComboBox.cxx
@@ -222,7 +222,7 @@ void LibBox::FillBox()
// create list box entries
LibEntry* pEntry = new LibEntry(ScriptDocument::getApplicationScriptDocument(),
LIBRARY_LOCATION_UNKNOWN, OUString());
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xWidget->append(sId, IDEResId(RID_STR_ALL));
InsertEntries(ScriptDocument::getApplicationScriptDocument(), LIBRARY_LOCATION_USER);
@@ -261,7 +261,7 @@ void LibBox::InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLoc
OUString aName(rDocument.getTitle(eLocation));
OUString aEntryText(CreateMgrAndLibStr(aName, aLibName));
LibEntry* pEntry = new LibEntry(rDocument, eLocation, aLibName);
- m_xWidget->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), aEntryText);
+ m_xWidget->append(weld::toId(pEntry), aEntryText);
}
}
}
@@ -320,7 +320,7 @@ void LibBox::Select()
void LibBox::NotifyIDE()
{
- LibEntry* pEntry = reinterpret_cast<LibEntry*>(m_xWidget->get_active_id().toInt64());
+ LibEntry* pEntry = weld::fromId<LibEntry*>(m_xWidget->get_active_id());
if (pEntry)
{
const ScriptDocument& aDocument(pEntry->GetDocument());
@@ -340,7 +340,7 @@ void LibBox::ClearBox()
sal_Int32 nCount = m_xWidget->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LibEntry* pEntry = reinterpret_cast<LibEntry*>(m_xWidget->get_id(i).toInt64());
+ LibEntry* pEntry = weld::fromId<LibEntry*>(m_xWidget->get_id(i));
delete pEntry;
}
m_xWidget->clear();
@@ -440,7 +440,7 @@ void LanguageBox::FillBox()
sLanguage += " " + msDefaultLanguageStr;
}
LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry)));
+ OUString sId(weld::toId(pEntry));
m_xWidget->append(sId, sLanguage);
if (bIsCurrent)
@@ -467,7 +467,7 @@ void LanguageBox::ClearBox()
sal_Int32 nCount = m_xWidget->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xWidget->get_id(i).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xWidget->get_id(i));
delete pEntry;
}
m_xWidget->clear();
@@ -475,7 +475,7 @@ void LanguageBox::ClearBox()
void LanguageBox::SetLanguage()
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xWidget->get_active_id().toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xWidget->get_active_id());
if (pEntry)
GetShell()->GetCurLocalizationMgr()->handleSetCurrentLocale(pEntry->m_aLocale);
}
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 9671d149ca2b..eb038f69d86f 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -1668,7 +1668,7 @@ void WatchWindow::dispose()
// Destroy user data
m_xTreeListBox->all_foreach([this](weld::TreeIter& rEntry){
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
delete pItem;
return false;
});
@@ -1729,7 +1729,7 @@ void WatchWindow::AddWatch( const OUString& rVName )
lcl_SeparateNameAndIndex( rVName, aVar, aIndex );
WatchItem* pWatchItem = new WatchItem(aVar);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pWatchItem)));
+ OUString sId(weld::toId(pWatchItem));
std::unique_ptr<weld::TreeIter> xRet = m_xTreeListBox->make_iterator();
m_xTreeListBox->insert(nullptr, -1, &aVar, &sId, nullptr, nullptr, false, xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1);
@@ -1752,7 +1752,7 @@ void WatchWindow::RemoveSelectedWatch()
m_xTreeListBox->remove(*xEntry);
bEntry = m_xTreeListBox->get_cursor(xEntry.get());
if (bEntry)
- m_xEdit->set_text(reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xEntry).toInt64())->maName);
+ m_xEdit->set_text(weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xEntry))->maName);
else
m_xEdit->set_text(OUString());
if ( !m_xTreeListBox->n_children() )
@@ -1772,7 +1772,7 @@ IMPL_LINK_NOARG(WatchWindow, TreeListHdl, weld::TreeView&, void)
bool bCurEntry = m_xTreeListBox->get_cursor(xCurEntry.get());
if (!bCurEntry)
return;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xCurEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xCurEntry));
if (!pItem)
return;
m_xEdit->set_text(pItem->maName);
@@ -2069,7 +2069,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
if (m_xTreeListBox->iter_has_child(rParent))
return true;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rParent).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rParent));
std::unique_ptr<weld::TreeIter> xRet = m_xTreeListBox->make_iterator();
SbxDimArray* pArray = pItem->mpArray.get();
@@ -2097,7 +2097,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
OUString const& rName = pItem->maMemberList.back();
WatchItem* pWatchItem = new WatchItem(rName);
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pWatchItem)));
+ OUString sId(weld::toId(pWatchItem));
m_xTreeListBox->insert(&rParent, -1, &rName, &sId, nullptr, nullptr, false, xRet.get());
m_xTreeListBox->set_text(*xRet, "", 1);
@@ -2148,7 +2148,7 @@ IMPL_LINK(WatchWindow, RequestingChildrenHdl, const weld::TreeIter&, rParent, bo
aDisplayName += aIndexStr;
pChildItem->maDisplayName = aDisplayName;
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pChildItem)));
+ OUString sId(weld::toId(pChildItem));
m_xTreeListBox->insert(&rParent, -1, &aDisplayName, &sId, nullptr, nullptr, false,
xRet.get());
@@ -2178,12 +2178,12 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA
SbxBase* pSBX = nullptr;
rbArrayElement = false;
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
OUString aVName( pItem->maName );
std::unique_ptr<weld::TreeIter> xParentEntry = m_xTreeListBox->make_iterator(&rEntry);
bool bParentEntry = m_xTreeListBox->iter_parent(*xParentEntry);
- WatchItem* pParentItem = bParentEntry ? reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(*xParentEntry).toInt64()) : nullptr;
+ WatchItem* pParentItem = bParentEntry ? weld::fromId<WatchItem*>(m_xTreeListBox->get_id(*xParentEntry)) : nullptr;
if( pParentItem )
{
SbxObject* pObj = pParentItem->mpObject.get();
@@ -2216,7 +2216,7 @@ SbxBase* WatchWindow::ImplGetSBXForEntry(const weld::TreeIter& rEntry, bool& rbA
IMPL_LINK(WatchWindow, EditingEntryHdl, const weld::TreeIter&, rIter, bool)
{
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rIter).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rIter));
bool bEdit = false;
if (StarBASIC::IsRunning() && StarBASIC::GetActiveMethod() && !SbxBase::IsError())
@@ -2293,7 +2293,7 @@ void implCollapseModifiedObjectEntry(const weld::TreeIter& rParent, weld::TreeVi
{
implCollapseModifiedObjectEntry(*xDeleteEntry, rTree);
- WatchItem* pItem = reinterpret_cast<WatchItem*>(rTree.get_id(*xDeleteEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(rTree.get_id(*xDeleteEntry));
delete pItem;
rTree.remove(*xDeleteEntry);
rTree.copy_iterator(rParent, *xDeleteEntry);
@@ -2352,7 +2352,7 @@ void WatchWindow::UpdateWatches(bool bBasicStopped)
setBasicWatchMode( true );
m_xTreeListBox->all_foreach([this, pCurMethod, bBasicStopped](weld::TreeIter& rEntry){
- WatchItem* pItem = reinterpret_cast<WatchItem*>(m_xTreeListBox->get_id(rEntry).toInt64());
+ WatchItem* pItem = weld::fromId<WatchItem*>(m_xTreeListBox->get_id(rEntry));
DBG_ASSERT( !pItem->maName.isEmpty(), "Var? - Must not be empty!" );
OUString aWatchStr;
OUString aTypeStr;
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index afff27b75dfd..d027c7dc6d2b 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -176,7 +176,7 @@ SbTreeListBox::~SbTreeListBox()
bool bValidIter = m_xControl->get_iter_first(*m_xScratchIter);
while (bValidIter)
{
- Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(*m_xScratchIter).toInt64());
+ Entry* pBasicEntry = weld::fromId<Entry*>(m_xControl->get_id(*m_xScratchIter));
delete pBasicEntry;
bValidIter = m_xControl->iter_next(*m_xScratchIter);
}
@@ -577,7 +577,7 @@ void SbTreeListBox::RemoveEntry(const weld::TreeIter& rIter)
}
// removing the associated user data
- Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
+ Entry* pBasicEntry = weld::fromId<Entry*>(m_xControl->get_id(rIter));
delete pBasicEntry;
// removing the entry
m_xControl->remove(rIter);
@@ -604,7 +604,7 @@ bool SbTreeListBox::FindEntry(std::u16string_view rText, EntryType eType, weld::
bool bValidIter = m_xControl->iter_children(rIter);
while (bValidIter)
{
- Entry* pBasicEntry = reinterpret_cast<Entry*>(m_xControl->get_id(rIter).toInt64());
+ Entry* pBasicEntry = weld::fromId<Entry*>(m_xControl->get_id(rIter));
assert(pBasicEntry && "FindEntry: no Entry ?!");
if (pBasicEntry->GetType() == eType && rText == m_xControl->get_text(rIter))
return true;
@@ -654,7 +654,7 @@ void SbTreeListBox::AddEntry(
std::unique_ptr<weld::TreeIter> xScratch = pRet ? nullptr : m_xControl->make_iterator();
if (!pRet)
pRet = xScratch.get();
- OUString sId(OUString::number(reinterpret_cast<sal_uInt64>(rUserData.release())));
+ OUString sId(weld::toId(rUserData.release()));
m_xControl->insert(pParent, -1, &rText, &sId, nullptr, nullptr, bChildrenOnDemand, pRet);
m_xControl->set_image(*pRet, rImage);
}
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 2515cace9800..265a5d55b746 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -345,7 +345,7 @@ LibPage::~LibPage()
const sal_Int32 nCount = m_xBasicsBox->get_count();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_id(i).toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_id(i));
delete pEntry;
}
}
@@ -1184,13 +1184,13 @@ void LibPage::FillListBox()
void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
{
OUString aEntryText(rDocument.getTitle(eLocation));
- OUString sId(OUString::number(reinterpret_cast<sal_Int64>(new DocumentEntry(rDocument, eLocation))));
+ OUString sId(weld::toId(new DocumentEntry(rDocument, eLocation)));
m_xBasicsBox->append(sId, aEntryText);
}
void LibPage::SetCurLib()
{
- DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_active_id().toInt64());
+ DocumentEntry* pEntry = weld::fromId<DocumentEntry*>(m_xBasicsBox->get_active_id());
if (!pEntry)
return;
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
index c7cd423cccee..0853f4ac86d3 100644
--- a/basctl/source/dlged/managelang.cxx
+++ b/basctl/source/dlged/managelang.cxx
@@ -113,7 +113,7 @@ void ManageLanguageDialog::FillLanguageBox()
sLanguage += " " + m_sDefLangStr;
}
LanguageEntry* pEntry = new LanguageEntry(pLocale[i], bIsDefault);
- m_xLanguageLB->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), sLanguage);
+ m_xLanguageLB->append(weld::toId(pEntry), sLanguage);
}
}
else
@@ -125,7 +125,7 @@ void ManageLanguageDialog::ClearLanguageBox()
const sal_Int32 nCount = m_xLanguageLB->n_children();
for (sal_Int32 i = 0; i < nCount; ++i)
{
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(i).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(i));
delete pEntry;
}
m_xLanguageLB->clear();
@@ -166,7 +166,7 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void)
for (int i = 0; i < nCount; ++i)
{
const sal_Int32 nSelPos = aSelection[i];
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64());
+ LanguageEntry* pEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos));
if ( pEntry )
aLocaleSeqRange[i] = pEntry->m_aLocale;
}
@@ -185,7 +185,7 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void)
IMPL_LINK_NOARG(ManageLanguageDialog, MakeDefHdl, weld::Button&, void)
{
const sal_Int32 nPos = m_xLanguageLB->get_selected_index();
- LanguageEntry* pSelectEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nPos).toInt64());
+ LanguageEntry* pSelectEntry = weld::fromId<LanguageEntry*>(m_xLanguageLB->get_id(nPos));
if (pSelectEntry && !pSelectEntry->m_bIsDefault)
{
// set new default entry