diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-02-04 09:13:52 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-02-04 15:02:03 +0100 |
commit | e00032ba6a2ddd4c08ae6f03b1982d3c099d288e (patch) | |
tree | 33f52e795971fd330922e21857b12c6097727ca8 /sfx2 | |
parent | 8d3f658aa58ddee8c7bc32ddea070c1bb3bf19b8 (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 'sfx2')
-rw-r--r-- | sfx2/source/appl/newhelp.cxx | 36 | ||||
-rw-r--r-- | sfx2/source/devtools/DocumentModelTreeHandler.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/devtools/ObjectInspectorTreeHandler.cxx | 12 | ||||
-rw-r--r-- | sfx2/source/dialog/versdlg.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/autoredactdialog.cxx | 13 |
5 files changed, 42 insertions, 45 deletions
diff --git a/sfx2/source/appl/newhelp.cxx b/sfx2/source/appl/newhelp.cxx index ee4e2c32b955..674c1717f6c9 100644 --- a/sfx2/source/appl/newhelp.cxx +++ b/sfx2/source/appl/newhelp.cxx @@ -225,7 +225,7 @@ void ContentTabPage_Impl::InitRoot() bool bIsFolder = ( '1' == cFolder ); OUString sId; if (bIsFolder) - sId = OUString::number(reinterpret_cast<sal_Int64>(new ContentEntry_Impl(aURL, true))); + sId = weld::toId(new ContentEntry_Impl(aURL, true)); m_xContentBox->insert(nullptr, -1, &aTitle, &sId, nullptr, nullptr, true, m_xScratchIter.get()); m_xContentBox->set_image(*m_xScratchIter, aClosedBookImage); } @@ -238,7 +238,7 @@ void ContentTabPage_Impl::ClearChildren(const weld::TreeIter* pParent) while (bEntry) { ClearChildren(xEntry.get()); - delete reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(*xEntry).toInt64()); + delete weld::fromId<ContentEntry_Impl*>(m_xContentBox->get_id(*xEntry)); bEntry = m_xContentBox->iter_next_sibling(*xEntry); } @@ -246,7 +246,7 @@ void ContentTabPage_Impl::ClearChildren(const weld::TreeIter* pParent) IMPL_LINK(ContentTabPage_Impl, ExpandingHdl, const weld::TreeIter&, rIter, bool) { - ContentEntry_Impl* pContentEntry = reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(rIter).toInt64()); + ContentEntry_Impl* pContentEntry = weld::fromId<ContentEntry_Impl*>(m_xContentBox->get_id(rIter)); if (!m_xContentBox->iter_has_child(rIter)) { try @@ -264,7 +264,7 @@ IMPL_LINK(ContentTabPage_Impl, ExpandingHdl, const weld::TreeIter&, rIter, bool) bool bIsFolder = ( '1' == cFolder ); if ( bIsFolder ) { - OUString sId = OUString::number(reinterpret_cast<sal_Int64>(new ContentEntry_Impl(aURL, true))); + OUString sId = weld::toId(new ContentEntry_Impl(aURL, true)); m_xContentBox->insert(&rIter, -1, &aTitle, &sId, nullptr, nullptr, true, m_xScratchIter.get()); m_xContentBox->set_image(*m_xScratchIter, aClosedBookImage); } @@ -274,7 +274,7 @@ IMPL_LINK(ContentTabPage_Impl, ExpandingHdl, const weld::TreeIter&, rIter, bool) OUString sId; OUString aTargetURL; if ( aAny >>= aTargetURL ) - sId = OUString::number(reinterpret_cast<sal_Int64>(new ContentEntry_Impl(aTargetURL, false))); + sId = weld::toId(new ContentEntry_Impl(aTargetURL, false)); m_xContentBox->insert(&rIter, -1, &aTitle, &sId, nullptr, nullptr, false, m_xScratchIter.get()); m_xContentBox->set_image(*m_xScratchIter, aDocumentImage); } @@ -295,7 +295,7 @@ IMPL_LINK(ContentTabPage_Impl, ExpandingHdl, const weld::TreeIter&, rIter, bool) IMPL_LINK(ContentTabPage_Impl, CollapsingHdl, const weld::TreeIter&, rIter, bool) { - ContentEntry_Impl* pContentEntry = reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(rIter).toInt64()); + ContentEntry_Impl* pContentEntry = weld::fromId<ContentEntry_Impl*>(m_xContentBox->get_id(rIter)); if (!pContentEntry || pContentEntry->bIsFolder) m_xContentBox->set_image(rIter, aClosedBookImage); @@ -305,7 +305,7 @@ IMPL_LINK(ContentTabPage_Impl, CollapsingHdl, const weld::TreeIter&, rIter, bool OUString ContentTabPage_Impl::GetSelectedEntry() const { OUString aRet; - ContentEntry_Impl* pEntry = reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_selected_id().toInt64()); + ContentEntry_Impl* pEntry = weld::fromId<ContentEntry_Impl*>(m_xContentBox->get_selected_id()); if (pEntry && !pEntry->bIsFolder) aRet = pEntry->aURL; return aRet; @@ -360,7 +360,7 @@ ContentTabPage_Impl::~ContentTabPage_Impl() while (bEntry) { ClearChildren(xEntry.get()); - delete reinterpret_cast<ContentEntry_Impl*>(m_xContentBox->get_id(*xEntry).toInt64()); + delete weld::fromId<ContentEntry_Impl*>(m_xContentBox->get_id(*xEntry)); bEntry = m_xContentBox->iter_next_sibling(*xEntry); } } @@ -373,11 +373,11 @@ void IndexTabPage_Impl::SelectExecutableEntry() sal_Int32 nOldPos = nPos; OUString aEntryText; - IndexEntry_Impl* pEntry = reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(nPos).toInt64()); + IndexEntry_Impl* pEntry = weld::fromId<IndexEntry_Impl*>(m_xIndexList->get_id(nPos)); sal_Int32 nCount = m_xIndexList->n_children(); while ( nPos < nCount && ( !pEntry || pEntry->m_aURL.isEmpty() ) ) { - pEntry = reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(++nPos).toInt64()); + pEntry = weld::fromId<IndexEntry_Impl*>(m_xIndexList->get_id(++nPos)); aEntryText = m_xIndexList->get_text(nPos); } @@ -445,7 +445,7 @@ IMPL_LINK(IndexTabPage_Impl, CustomRenderHdl, weld::TreeView::render_args, aPayl int nIndex = m_xIndexList->find_id(rId); OUString aEntry(m_xIndexList->get_text(nIndex)); - IndexEntry_Impl* pEntry = reinterpret_cast<IndexEntry_Impl*>(rId.toInt64()); + IndexEntry_Impl* pEntry = weld::fromId<IndexEntry_Impl*>(rId); if (pEntry && pEntry->m_bSubEntry) { // indent sub entries @@ -609,7 +609,7 @@ void IndexTabPage_Impl::InitializeIndex() { aIndex = aTempString; it = aInfo.emplace(aTempString, 0).first; - sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(OUString(), false))); + sId = weld::toId(new IndexEntry_Impl(OUString(), false)); if ( (tmp = it->second++) != 0) m_xIndexList->append( sId, aTempString + std::u16string_view(append, tmp)); @@ -630,10 +630,10 @@ void IndexTabPage_Impl::InitializeIndex() if ( aAnchorList[0].getLength() > 0 ) { aData.append( aRefList[0] ).append( '#' ).append( aAnchorList[0] ); - sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aData.makeStringAndClear(), insert))); + sId = weld::toId(new IndexEntry_Impl(aData.makeStringAndClear(), insert)); } else - sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aRefList[0], insert))); + sId = weld::toId(new IndexEntry_Impl(aRefList[0], insert)); } // Assume the token is trimmed @@ -657,10 +657,10 @@ void IndexTabPage_Impl::InitializeIndex() if ( aAnchorList[j].getLength() > 0 ) { aData.append( aRefList[j] ).append( '#' ).append( aAnchorList[j] ); - sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aData.makeStringAndClear(), insert))); + sId = weld::toId(new IndexEntry_Impl(aData.makeStringAndClear(), insert)); } else - sId = OUString::number(reinterpret_cast<sal_Int64>(new IndexEntry_Impl(aRefList[j], insert))); + sId = weld::toId(new IndexEntry_Impl(aRefList[j], insert)); it = aInfo.emplace(aTempString, 0).first; if ( (tmp = it->second++) != 0 ) @@ -688,7 +688,7 @@ void IndexTabPage_Impl::ClearIndex() { const sal_Int32 nCount = m_xIndexList->n_children(); for ( sal_Int32 i = 0; i < nCount; ++i ) - delete reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(i).toInt64()); + delete weld::fromId<IndexEntry_Impl*>(m_xIndexList->get_id(i)); m_xIndexList->clear(); } @@ -821,7 +821,7 @@ void IndexTabPage_Impl::SetFactory( const OUString& rFactory ) OUString IndexTabPage_Impl::GetSelectedEntry() const { OUString aRet; - IndexEntry_Impl* pEntry = reinterpret_cast<IndexEntry_Impl*>(m_xIndexList->get_id(m_xIndexList->find_text(m_xIndexEntry->get_text())).toInt64()); + IndexEntry_Impl* pEntry = weld::fromId<IndexEntry_Impl*>(m_xIndexList->get_id(m_xIndexList->find_text(m_xIndexEntry->get_text()))); if (pEntry) aRet = pEntry->m_aURL; return aRet; diff --git a/sfx2/source/devtools/DocumentModelTreeHandler.cxx b/sfx2/source/devtools/DocumentModelTreeHandler.cxx index 7373cb1e603c..49484309dfd4 100644 --- a/sfx2/source/devtools/DocumentModelTreeHandler.cxx +++ b/sfx2/source/devtools/DocumentModelTreeHandler.cxx @@ -93,7 +93,7 @@ public: void lclAppendToParentEntry(const std::unique_ptr<weld::TreeView>& rTree, weld::TreeIter const& rParent, DocumentModelTreeEntry* pEntry) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); OUString const& rString = pEntry->getString(); rTree->insert(&rParent, -1, &rString, &sId, nullptr, nullptr, pEntry->shouldShowExpander(), nullptr); @@ -102,7 +102,7 @@ void lclAppendToParentEntry(const std::unique_ptr<weld::TreeView>& rTree, // append a root entry to a input TreeView OUString lclAppend(const std::unique_ptr<weld::TreeView>& rTree, DocumentModelTreeEntry* pEntry) { - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); OUString const& rString = pEntry->getString(); rTree->insert(nullptr, -1, &rString, &sId, nullptr, nullptr, pEntry->shouldShowExpander(), nullptr); @@ -714,7 +714,7 @@ uno::Reference<uno::XInterface> DocumentModelTreeHandler::getObjectByID(OUString uno::Reference<uno::XInterface> xObject; if (rID.isEmpty()) return xObject; - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(rID.toInt64()); + auto* pEntry = weld::fromId<DocumentModelTreeEntry*>(rID); return pEntry->getMainObject(); } @@ -723,7 +723,7 @@ void DocumentModelTreeHandler::clearAll() // destroy all DocumentModelTreeEntries from the tree mpDocumentModelTree->all_foreach([this](weld::TreeIter& rEntry) { OUString sID = mpDocumentModelTree->get_id(rEntry); - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(sID.toInt64()); + auto* pEntry = weld::fromId<DocumentModelTreeEntry*>(sID); delete pEntry; return false; }); @@ -744,7 +744,7 @@ void DocumentModelTreeHandler::clearChildren(weld::TreeIter const& rParent) { clearChildren(*pChild); OUString sID = mpDocumentModelTree->get_id(*pChild); - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(sID.toInt64()); + auto* pEntry = weld::fromId<DocumentModelTreeEntry*>(sID); delete pEntry; mpDocumentModelTree->remove(*pChild); } @@ -756,7 +756,7 @@ void DocumentModelTreeHandler::dispose() { mpDocumentModelTree->all_foreach([this](weld::TreeIter& rEntry) { OUString sID = mpDocumentModelTree->get_id(rEntry); - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(sID.toInt64()); + auto* pEntry = weld::fromId<DocumentModelTreeEntry*>(sID); delete pEntry; return false; }); @@ -769,7 +769,7 @@ IMPL_LINK(DocumentModelTreeHandler, ExpandingHandler, weld::TreeIter const&, rPa return true; clearChildren(rParent); - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(sID.toInt64()); + auto* pEntry = weld::fromId<DocumentModelTreeEntry*>(sID); pEntry->fill(mpDocumentModelTree, rParent); return true; @@ -782,7 +782,7 @@ void DocumentModelTreeHandler::selectObject( mpDocumentModelTree->all_foreach([this, xInterface](weld::TreeIter& rEntry) { OUString sID = mpDocumentModelTree->get_id(rEntry); - auto* pEntry = reinterpret_cast<DocumentModelTreeEntry*>(sID.toInt64()); + auto* pEntry = weld::fromId<DocumentModelTreeEntry*>(sID); if (xInterface == pEntry->getMainObject()) { mpDocumentModelTree->select(rEntry); diff --git a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx index 7228f48e13ca..7787c61d9468 100644 --- a/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx +++ b/sfx2/source/devtools/ObjectInspectorTreeHandler.cxx @@ -351,7 +351,7 @@ OUString lclAppendNode(const std::unique_ptr<weld::TreeView>& pTree, ObjectInspectorNodeInterface* pEntry) { OUString sName = pEntry->getObjectName(); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); std::unique_ptr<weld::TreeIter> pCurrent = pTree->make_iterator(); pTree->insert(nullptr, -1, &sName, &sId, nullptr, nullptr, pEntry->shouldShowExpander(), pCurrent.get()); @@ -370,7 +370,7 @@ OUString lclAppendNodeToParent(const std::unique_ptr<weld::TreeView>& pTree, const weld::TreeIter* pParent, ObjectInspectorNodeInterface* pEntry) { OUString sName = pEntry->getObjectName(); - OUString sId(OUString::number(reinterpret_cast<sal_Int64>(pEntry))); + OUString sId(weld::toId(pEntry)); std::unique_ptr<weld::TreeIter> pCurrent = pTree->make_iterator(); pTree->insert(pParent, -1, &sName, &sId, nullptr, nullptr, pEntry->shouldShowExpander(), pCurrent.get()); @@ -902,7 +902,7 @@ ObjectInspectorNodeInterface* getSelectedNode(weld::TreeView const& rTreeView) if (sID.isEmpty()) return nullptr; - if (auto* pNode = reinterpret_cast<ObjectInspectorNodeInterface*>(sID.toInt64())) + if (auto* pNode = weld::fromId<ObjectInspectorNodeInterface*>(sID)) return pNode; return nullptr; @@ -1000,7 +1000,7 @@ void ObjectInspectorTreeHandler::handleExpanding(std::unique_ptr<weld::TreeView> return; clearObjectInspectorChildren(pTreeView, rParent); - auto* pNode = reinterpret_cast<ObjectInspectorNodeInterface*>(sID.toInt64()); + auto* pNode = weld::fromId<ObjectInspectorNodeInterface*>(sID); pNode->fillChildren(pTreeView, &rParent); } @@ -1206,7 +1206,7 @@ void ObjectInspectorTreeHandler::clearObjectInspectorChildren( { clearObjectInspectorChildren(pTreeView, *pChild); OUString sID = pTreeView->get_id(*pChild); - auto* pEntry = reinterpret_cast<ObjectInspectorNodeInterface*>(sID.toInt64()); + auto* pEntry = weld::fromId<ObjectInspectorNodeInterface*>(sID); delete pEntry; pTreeView->remove(*pChild); } @@ -1220,7 +1220,7 @@ void ObjectInspectorTreeHandler::clearAll(std::unique_ptr<weld::TreeView>& pTree // destroy all ObjectInspectorNodes from the tree pTreeView->all_foreach([&pTreeView](weld::TreeIter& rEntry) { OUString sID = pTreeView->get_id(rEntry); - auto* pEntry = reinterpret_cast<ObjectInspectorNodeInterface*>(sID.toInt64()); + auto* pEntry = weld::fromId<ObjectInspectorNodeInterface*>(sID); delete pEntry; return false; }); diff --git a/sfx2/source/dialog/versdlg.cxx b/sfx2/source/dialog/versdlg.cxx index 6de0d866c30b..4b0a05d40eae 100644 --- a/sfx2/source/dialog/versdlg.cxx +++ b/sfx2/source/dialog/versdlg.cxx @@ -126,7 +126,7 @@ namespace for (int i = 0; i < rVersionBox.n_children(); ++i) { - aAuthors.insert(reinterpret_cast<SfxVersionInfo*>(rVersionBox.get_id(i).toInt64())->aAuthor); + aAuthors.insert(weld::fromId<SfxVersionInfo*>(rVersionBox.get_id(i))->aAuthor); } int nMaxAuthorWidth = nRest/4; @@ -218,7 +218,7 @@ void SfxVersionDialog::Init_Impl() { SfxVersionInfo *pInfo = m_pTable->at( n ); OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper()); - m_xVersionBox->append(OUString::number(reinterpret_cast<sal_Int64>(pInfo)), aEntry); + m_xVersionBox->append(weld::toId(pInfo), aEntry); auto nLastRow = m_xVersionBox->n_children() - 1; m_xVersionBox->set_text(nLastRow, pInfo->aAuthor, 1); m_xVersionBox->set_text(nLastRow, ConvertWhiteSpaces_Impl(pInfo->aComment), 2); @@ -331,7 +331,7 @@ IMPL_LINK(SfxVersionDialog, ButtonHdl_Impl, weld::Button&, rButton, void) } else if (&rButton == m_xDeleteButton.get() && nEntry != -1) { - SfxVersionInfo* pInfo = reinterpret_cast<SfxVersionInfo*>(m_xVersionBox->get_id(nEntry).toInt64()); + SfxVersionInfo* pInfo = weld::fromId<SfxVersionInfo*>(m_xVersionBox->get_id(nEntry)); pObjShell->GetMedium()->RemoveVersion_Impl(pInfo->aName); pObjShell->SetModified(); m_xVersionBox->freeze(); @@ -345,7 +345,7 @@ IMPL_LINK(SfxVersionDialog, ButtonHdl_Impl, weld::Button&, rButton, void) } else if (&rButton == m_xViewButton.get() && nEntry != -1) { - SfxVersionInfo* pInfo = reinterpret_cast<SfxVersionInfo*>(m_xVersionBox->get_id(nEntry).toInt64()); + SfxVersionInfo* pInfo = weld::fromId<SfxVersionInfo*>(m_xVersionBox->get_id(nEntry)); SfxViewVersionDialog_Impl aDlg(m_xDialog.get(), *pInfo, false); aDlg.run(); } @@ -460,7 +460,7 @@ void SfxCmisVersionsDialog::LoadVersions() { SfxVersionInfo *pInfo = m_pTable->at( n ); OUString aEntry = formatTime(pInfo->aCreationDate, Application::GetSettings().GetLocaleDataWrapper()); - m_xVersionBox->append(OUString::number(reinterpret_cast<sal_Int64>(pInfo)), aEntry); + m_xVersionBox->append(weld::toId(pInfo), aEntry); auto nLastRow = m_xVersionBox->n_children() - 1; m_xVersionBox->set_text(nLastRow, pInfo->aAuthor, 1); m_xVersionBox->set_text(nLastRow, ConvertWhiteSpaces_Impl(pInfo->aComment), 2); diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx index 4acbb8ea7816..ea1fa8fb218c 100644 --- a/sfx2/source/doc/autoredactdialog.cxx +++ b/sfx2/source/doc/autoredactdialog.cxx @@ -29,8 +29,7 @@ int TargetsTable::GetRowByTargetName(std::u16string_view sName) { for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i) { - RedactionTarget* pTarget - = reinterpret_cast<RedactionTarget*>(m_xControl->get_id(i).toInt64()); + RedactionTarget* pTarget = weld::fromId<RedactionTarget*>(m_xControl->get_id(i)); if (pTarget->sName == sName) { return i; @@ -122,7 +121,7 @@ void TargetsTable::InsertTarget(RedactionTarget* pTarget) // Add to the end int nRow = m_xControl->n_children(); - m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(pTarget)), pTarget->sName); + m_xControl->append(weld::toId(pTarget), pTarget->sName); m_xControl->set_text(nRow, getTypeName(pTarget->sType), 1); m_xControl->set_text(nRow, sContent, 2); m_xControl->set_text( @@ -138,7 +137,7 @@ RedactionTarget* TargetsTable::GetTargetByName(std::u16string_view sName) if (nEntry == -1) return nullptr; - return reinterpret_cast<RedactionTarget*>(m_xControl->get_id(nEntry).toInt64()); + return weld::fromId<RedactionTarget*>(m_xControl->get_id(nEntry)); } OUString TargetsTable::GetNameProposal() const @@ -147,8 +146,7 @@ OUString TargetsTable::GetNameProposal() const sal_Int32 nHighestTargetId = 0; for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i) { - RedactionTarget* pTarget - = reinterpret_cast<RedactionTarget*>(m_xControl->get_id(i).toInt64()); + RedactionTarget* pTarget = weld::fromId<RedactionTarget*>(m_xControl->get_id(i)); const OUString& sName = pTarget->sName; sal_Int32 nIndex = 0; if (sName.getToken(0, ' ', nIndex) == sDefaultTargetName) @@ -269,8 +267,7 @@ IMPL_LINK_NOARG(SfxAutoRedactDialog, EditHdl, weld::Button&, void) } // Get the redaction target to be edited - RedactionTarget* pTarget - = reinterpret_cast<RedactionTarget*>(m_xTargetsBox->get_id(nSelectedRow).toInt64()); + RedactionTarget* pTarget = weld::fromId<RedactionTarget*>(m_xTargetsBox->get_id(nSelectedRow)); // Construct and run the edit target dialog SfxAddTargetDialog aEditTargetDialog(getDialog(), pTarget->sName, pTarget->sType, |