diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-03-14 12:51:31 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-03-15 09:57:43 +0100 |
commit | 8bddb3c77048814b370351e0eb72c31f289fb34f (patch) | |
tree | 8b081c15b1779301eee613e6f24de1371dd77265 /sw/source/ui/misc | |
parent | f5efc3cb9d2bbcaaca95e15a03815e8f8eda7b09 (diff) |
add drop target support to welded widget
refactor the mega-widget dnd drop target to be reused at
mini-widget level
and weld SwInsertBookmarkDlg
Change-Id: I3f36e1cd902ecf166e369d0a05902d3df2b4f791
Reviewed-on: https://gerrit.libreoffice.org/69274
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/ui/misc')
-rw-r--r-- | sw/source/ui/misc/bookmark.cxx | 273 |
1 files changed, 123 insertions, 150 deletions
diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index fabcae7a521e..32631b20d2f5 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -42,14 +42,14 @@ const OUString BookmarkTable::aForbiddenChars("/\\@*?\",#"); const char BookmarkTable::cSeparator(';'); // callback to modify EditBox -IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, Edit&, void) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, weld::Entry&, void) { ValidateBookmarks(); - m_pBookmarksBox->SelectAll(false); + m_xBookmarksBox->unselect_all(); // if a string has been pasted from the clipboard then // there may be illegal characters in the box // sanitization - OUString sTmp = m_pEditBox->GetText(); + OUString sTmp = m_xEditBox->get_text(); OUString sMsg; const sal_Int32 nLen = sTmp.getLength(); for (sal_Int32 i = 0; i < BookmarkTable::aForbiddenChars.getLength(); i++) @@ -61,8 +61,8 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, Edit&, void) } if (sTmp.getLength() != nLen) { - m_pEditBox->SetText(sTmp); - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), + m_xEditBox->set_text(sTmp); + std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(m_xDialog.get(), VclMessageType::Info, VclButtonsType::Ok, sRemoveWarning + sMsg)); xInfoBox->run(); @@ -74,36 +74,38 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, ModifyHdl, Edit&, void) while (!sTmp.isEmpty() && nTokenIndex >= 0) { OUString aToken = sTmp.getToken(0, BookmarkTable::cSeparator, nTokenIndex); - if (m_pBookmarksBox->GetBookmarkByName(aToken)) + if (m_xBookmarksBox->GetBookmarkByName(aToken)) { - m_pBookmarksBox->SelectByName(aToken); + m_xBookmarksBox->SelectByName(aToken); nSelectedEntries++; } nEntries++; } // allow to add new bookmark only if one name provided and it's not taken - m_pInsertBtn->Enable(nEntries == 1 && nSelectedEntries == 0); + m_xInsertBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 0); // allow to delete only if all bookmarks are recognized - m_pDeleteBtn->Enable(nEntries > 0 && nSelectedEntries == nEntries); - m_pGotoBtn->Enable(nEntries == 1 && nSelectedEntries == 1); - m_pRenameBtn->Enable(nEntries == 1 && nSelectedEntries == 1); + m_xDeleteBtn->set_sensitive(nEntries > 0 && nSelectedEntries == nEntries); + m_xGotoBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 1); + m_xRenameBtn->set_sensitive(nEntries == 1 && nSelectedEntries == 1); } // callback to delete a text mark -IMPL_LINK_NOARG(SwInsertBookmarkDlg, DeleteHdl, Button*, void) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, DeleteHdl, weld::Button&, void) { if (!ValidateBookmarks()) return; - if (m_pBookmarksBox->GetSelectionCount() == 0) + std::vector<int> aSelectedRows(m_xBookmarksBox->get_selected_rows()); + if (aSelectedRows.empty()) return; + std::sort(aSelectedRows.begin(), aSelectedRows.end()); - SvTreeListEntry* pSelected = m_pBookmarksBox->FirstSelected(); - for (sal_Int32 i = m_pBookmarksBox->GetSelectionCount(); i; i--) + for (size_t i = aSelectedRows.size(); i; --i) { + int nRow = aSelectedRows[i-1]; // remove from model - sw::mark::IMark* pBookmark = static_cast<sw::mark::IMark*>(pSelected->GetUserData()); + sw::mark::IMark* pBookmark = reinterpret_cast<sw::mark::IMark*>(m_xBookmarksBox->get_id(nRow).toInt64()); OUString sRemoved = pBookmark->GetName(); IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); pMarkAccess->deleteMark(pMarkAccess->findMark(sRemoved)); @@ -113,76 +115,74 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, DeleteHdl, Button*, void) aTableBookmarks.erase(std::remove(aTableBookmarks.begin(), aTableBookmarks.end(), std::make_pair(pBookmark, sRemoved)), aTableBookmarks.end()); // remove from BookmarkTable - SvTreeListEntry* nextSelected = m_pBookmarksBox->NextSelected(pSelected); - m_pBookmarksBox->RemoveEntry(pSelected); - pSelected = nextSelected; + m_xBookmarksBox->remove(nRow); } - m_pBookmarksBox->SelectAll(false); - m_pEditBox->SetText(""); - m_pDeleteBtn->Disable(); - m_pGotoBtn->Disable(); - m_pRenameBtn->Disable(); - m_pInsertBtn->Disable(); + m_xBookmarksBox->unselect_all(); + m_xEditBox->set_text(""); + m_xDeleteBtn->set_sensitive(false); + m_xGotoBtn->set_sensitive(false); + m_xRenameBtn->set_sensitive(false); + m_xInsertBtn->set_sensitive(false); } // callback to a goto button -IMPL_LINK_NOARG(SwInsertBookmarkDlg, GotoHdl, Button*, void) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, GotoHdl, weld::Button&, void) { GotoSelectedBookmark(); } -IMPL_LINK_NOARG(SwInsertBookmarkDlg, DoubleClickHdl, SvTreeListBox*, bool) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, DoubleClickHdl, weld::TreeView&, void) { GotoSelectedBookmark(); - return true; } -IMPL_LINK_NOARG(SwInsertBookmarkDlg, SelectionChangedHdl, SvTreeListBox*, void) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, SelectionChangedHdl, weld::TreeView&, void) { if (!ValidateBookmarks()) return; // this event should fired only if we change selection by clicking on BookmarkTable entry - if (!m_pBookmarksBox->HasFocus()) + if (!m_xBookmarksBox->has_focus()) return; OUStringBuffer sEditBoxText; - SvTreeListEntry* pSelected = m_pBookmarksBox->FirstSelected(); - for (sal_Int32 i = m_pBookmarksBox->GetSelectionCount(); i; i--) + + std::vector<int> aSelectedRows(m_xBookmarksBox->get_selected_rows()); + std::sort(aSelectedRows.begin(), aSelectedRows.end()); + for (size_t i = aSelectedRows.size(); i; --i) { - sw::mark::IMark* pBookmark = static_cast<sw::mark::IMark*>(pSelected->GetUserData()); + int nRow = aSelectedRows[i-1]; + sw::mark::IMark* pBookmark = reinterpret_cast<sw::mark::IMark*>(m_xBookmarksBox->get_id(nRow).toInt64()); const OUString& sEntryName = pBookmark->GetName(); sEditBoxText.append(sEntryName); - if (i > 1) + if (nRow > 1) sEditBoxText.append(";"); - pSelected = m_pBookmarksBox->NextSelected(pSelected); } - if (m_pBookmarksBox->GetSelectionCount() > 0) + if (!aSelectedRows.empty()) { - m_pInsertBtn->Disable(); - m_pGotoBtn->Enable(m_pBookmarksBox->GetSelectionCount() == 1); - m_pRenameBtn->Enable(m_pBookmarksBox->GetSelectionCount() == 1); - m_pDeleteBtn->Enable(); - m_pEditBox->SetText(sEditBoxText.makeStringAndClear()); + m_xInsertBtn->set_sensitive(false); + m_xGotoBtn->set_sensitive(aSelectedRows.size() == 1); + m_xRenameBtn->set_sensitive(aSelectedRows.size() == 1); + m_xDeleteBtn->set_sensitive(true); + m_xEditBox->set_text(sEditBoxText.makeStringAndClear()); } else { - m_pInsertBtn->Enable(); - m_pGotoBtn->Disable(); - m_pRenameBtn->Disable(); - m_pDeleteBtn->Disable(); + m_xInsertBtn->set_sensitive(true); + m_xGotoBtn->set_sensitive(false); + m_xRenameBtn->set_sensitive(false); + m_xDeleteBtn->set_sensitive(false); } } -IMPL_LINK_NOARG(SwInsertBookmarkDlg, RenameHdl, Button*, void) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, RenameHdl, weld::Button&, void) { if (!ValidateBookmarks()) return; - if (m_pBookmarksBox->GetSelectionCount() == 0) + int nSelected = m_xBookmarksBox->get_selected_index(); + if (nSelected == -1) return; - SvTreeListEntry* pSelected = m_pBookmarksBox->FirstSelected(); - sw::mark::IMark* pBookmark = static_cast<sw::mark::IMark*>(pSelected->GetUserData()); - + sw::mark::IMark* pBookmark = reinterpret_cast<sw::mark::IMark*>(m_xBookmarksBox->get_id(nSelected).toInt64()); uno::Reference<frame::XModel> xModel = rSh.GetView().GetDocShell()->GetBaseModel(); uno::Reference<text::XBookmarksSupplier> xBkms(xModel, uno::UNO_QUERY); uno::Reference<container::XNameAccess> xNameAccess = xBkms->getBookmarks(); @@ -191,37 +191,37 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, RenameHdl, Button*, void) aObj >>= xTmp; uno::Reference<container::XNamed> xNamed(xTmp, uno::UNO_QUERY); SwAbstractDialogFactory& rFact = swui::GetFactory(); - ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg(rFact.CreateSwRenameXNamedDlg(GetFrameWeld(), xNamed, xNameAccess)); + ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg(rFact.CreateSwRenameXNamedDlg(m_xDialog.get(), xNamed, xNameAccess)); pDlg->SetForbiddenChars(BookmarkTable::aForbiddenChars + OUStringLiteral1(BookmarkTable::cSeparator)); if (pDlg->Execute()) { ValidateBookmarks(); - m_pDeleteBtn->Disable(); - m_pGotoBtn->Disable(); - m_pRenameBtn->Disable(); - m_pInsertBtn->Disable(); + m_xDeleteBtn->set_sensitive(false); + m_xGotoBtn->set_sensitive(false); + m_xRenameBtn->set_sensitive(false); + m_xInsertBtn->set_sensitive(false); } } // callback to a insert button. Inserts a new text mark to the current position. -IMPL_LINK_NOARG(SwInsertBookmarkDlg, InsertHdl, Button*, void) +IMPL_LINK_NOARG(SwInsertBookmarkDlg, InsertHdl, weld::Button&, void) { - OUString sBookmark = m_pEditBox->GetText(); - rSh.SetBookmark2(vcl::KeyCode(), sBookmark, m_pHideCB->IsChecked(), m_pConditionED->GetText()); + OUString sBookmark = m_xEditBox->get_text(); + rSh.SetBookmark2(vcl::KeyCode(), sBookmark, m_xHideCB->get_active(), m_xConditionED->get_text()); rReq.AppendItem(SfxStringItem(FN_INSERT_BOOKMARK, sBookmark)); rReq.Done(); if (!rReq.IsDone()) rReq.Ignore(); - EndDialog(RET_OK); + m_xDialog->response(RET_OK); } -IMPL_LINK(SwInsertBookmarkDlg, ChangeHideHdl, Button *, pBox, void) +IMPL_LINK(SwInsertBookmarkDlg, ChangeHideHdl, weld::ToggleButton&, rBox, void) { - bool bHide = static_cast<CheckBox*>(pBox)->IsChecked(); - m_pConditionED->Enable(bHide); - m_pConditionFT->Enable(bHide); + bool bHide = rBox.get_active(); + m_xConditionED->set_sensitive(bHide); + m_xConditionFT->set_sensitive(bHide); } void SwInsertBookmarkDlg::GotoSelectedBookmark() @@ -230,10 +230,11 @@ void SwInsertBookmarkDlg::GotoSelectedBookmark() return; // if no entries selected we can't jump anywhere // shouldn't be needed as we disable GoTo button when jump is not possible - if (m_pBookmarksBox->GetSelectionCount() == 0) + int nSelected = m_xBookmarksBox->get_selected_index(); + if (nSelected == -1) return; - sw::mark::IMark* pBookmark = static_cast<sw::mark::IMark*>(m_pBookmarksBox->FirstSelected()->GetUserData()); + sw::mark::IMark* pBookmark = reinterpret_cast<sw::mark::IMark*>(m_xBookmarksBox->get_id(nSelected).toInt64()); rSh.EnterStdMode(); rSh.GotoMark(pBookmark); @@ -244,7 +245,7 @@ bool SwInsertBookmarkDlg::ValidateBookmarks() if (HaveBookmarksChanged()) { PopulateTable(); - m_pEditBox->SetText(""); + m_xEditBox->set_text(""); return false; } return true; @@ -278,7 +279,7 @@ bool SwInsertBookmarkDlg::HaveBookmarksChanged() void SwInsertBookmarkDlg::PopulateTable() { aTableBookmarks.clear(); - m_pBookmarksBox->Clear(); + m_xBookmarksBox->clear(); IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); for (IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin(); @@ -286,91 +287,64 @@ void SwInsertBookmarkDlg::PopulateTable() { if (IDocumentMarkAccess::MarkType::BOOKMARK == IDocumentMarkAccess::GetType(**ppBookmark)) { - m_pBookmarksBox->InsertBookmark(ppBookmark->get()); + m_xBookmarksBox->InsertBookmark(ppBookmark->get()); aTableBookmarks.emplace_back(ppBookmark->get(), ppBookmark->get()->GetName()); } } m_nLastBookmarksCount = pMarkAccess->getBookmarksCount(); } -void SwInsertBookmarkDlg::Apply() -{ -} - -SwInsertBookmarkDlg::SwInsertBookmarkDlg(vcl::Window* pParent, SwWrtShell& rS, SfxRequest& rRequest) - : SvxStandardDialog(pParent, "InsertBookmarkDialog", "modules/swriter/ui/insertbookmark.ui") +SwInsertBookmarkDlg::SwInsertBookmarkDlg(weld::Window* pParent, SwWrtShell& rS, SfxRequest& rRequest) + : SfxDialogController(pParent, "modules/swriter/ui/insertbookmark.ui", "InsertBookmarkDialog") , rSh(rS) , rReq(rRequest) , m_nLastBookmarksCount(0) + , m_xEditBox(m_xBuilder->weld_entry("name")) + , m_xInsertBtn(m_xBuilder->weld_button("insert")) + , m_xDeleteBtn(m_xBuilder->weld_button("delete")) + , m_xGotoBtn(m_xBuilder->weld_button("goto")) + , m_xRenameBtn(m_xBuilder->weld_button("rename")) + , m_xHideCB(m_xBuilder->weld_check_button("hide")) + , m_xConditionFT(m_xBuilder->weld_label("condlabel")) + , m_xConditionED(new SwConditionEdit(m_xBuilder->weld_entry("withcond"))) + , m_xBookmarksBox(new BookmarkTable(m_xBuilder->weld_tree_view("bookmarks"))) { - get(m_pBookmarksContainer, "bookmarks"); - get(m_pEditBox, "name"); - get(m_pInsertBtn, "insert"); - get(m_pDeleteBtn, "delete"); - get(m_pGotoBtn, "goto"); - get(m_pRenameBtn, "rename"); - get(m_pHideCB, "hide"); - get(m_pConditionFT, "condlabel"); - get(m_pConditionED, "withcond"); - - m_pBookmarksBox = VclPtr<BookmarkTable>::Create(*m_pBookmarksContainer); - - m_pBookmarksBox->SetSelectHdl(LINK(this, SwInsertBookmarkDlg, SelectionChangedHdl)); - m_pBookmarksBox->SetDeselectHdl(LINK(this, SwInsertBookmarkDlg, SelectionChangedHdl)); - m_pBookmarksBox->SetDoubleClickHdl(LINK(this, SwInsertBookmarkDlg, DoubleClickHdl)); - m_pEditBox->SetModifyHdl(LINK(this, SwInsertBookmarkDlg, ModifyHdl)); - m_pInsertBtn->SetClickHdl(LINK(this, SwInsertBookmarkDlg, InsertHdl)); - m_pDeleteBtn->SetClickHdl(LINK(this, SwInsertBookmarkDlg, DeleteHdl)); - m_pGotoBtn->SetClickHdl(LINK(this, SwInsertBookmarkDlg, GotoHdl)); - m_pRenameBtn->SetClickHdl(LINK(this, SwInsertBookmarkDlg, RenameHdl)); - m_pHideCB->SetClickHdl(LINK(this, SwInsertBookmarkDlg, ChangeHideHdl)); - - m_pDeleteBtn->Disable(); - m_pGotoBtn->Disable(); - m_pRenameBtn->Disable(); + m_xBookmarksBox->connect_changed(LINK(this, SwInsertBookmarkDlg, SelectionChangedHdl)); + m_xBookmarksBox->connect_row_activated(LINK(this, SwInsertBookmarkDlg, DoubleClickHdl)); + m_xEditBox->connect_changed(LINK(this, SwInsertBookmarkDlg, ModifyHdl)); + m_xInsertBtn->connect_clicked(LINK(this, SwInsertBookmarkDlg, InsertHdl)); + m_xDeleteBtn->connect_clicked(LINK(this, SwInsertBookmarkDlg, DeleteHdl)); + m_xGotoBtn->connect_clicked(LINK(this, SwInsertBookmarkDlg, GotoHdl)); + m_xRenameBtn->connect_clicked(LINK(this, SwInsertBookmarkDlg, RenameHdl)); + m_xHideCB->connect_toggled(LINK(this, SwInsertBookmarkDlg, ChangeHideHdl)); + + m_xDeleteBtn->set_sensitive(false); + m_xGotoBtn->set_sensitive(false); + m_xRenameBtn->set_sensitive(false); PopulateTable(); - m_pEditBox->SetText(m_pBookmarksBox->GetNameProposal()); - m_pEditBox->SetCursorAtLast(); + m_xEditBox->set_text(m_xBookmarksBox->GetNameProposal()); + m_xEditBox->set_position(-1); sRemoveWarning = SwResId(STR_REMOVE_WARNING); } SwInsertBookmarkDlg::~SwInsertBookmarkDlg() { - disposeOnce(); } -void SwInsertBookmarkDlg::dispose() +BookmarkTable::BookmarkTable(std::unique_ptr<weld::TreeView> xControl) + : m_xControl(std::move(xControl)) { - m_pBookmarksBox.disposeAndClear(); - m_pBookmarksContainer.clear(); - m_pInsertBtn.clear(); - m_pDeleteBtn.clear(); - m_pGotoBtn.clear(); - m_pEditBox.clear(); - m_pRenameBtn.clear(); - m_pHideCB.clear(); - m_pConditionFT.clear(); - m_pConditionED.clear(); - SvxStandardDialog::dispose(); -} - -BookmarkTable::BookmarkTable(SvSimpleTableContainer& rParent) : - SvSimpleTable(rParent, 0) -{ - static long nTabs[] = { 0, 40, 150, 300, 340 }; - - SetTabs(SAL_N_ELEMENTS(nTabs), nTabs, MapUnit::MapPixel); - SetSelectionMode(SelectionMode::Multiple); - InsertHeaderEntry(SwResId(STR_PAGE)); - InsertHeaderEntry(SwResId(STR_BOOKMARK_NAME)); - InsertHeaderEntry(SwResId(STR_BOOKMARK_TEXT)); - InsertHeaderEntry(SwResId(STR_BOOKMARK_HIDDEN)); - InsertHeaderEntry(SwResId(STR_BOOKMARK_CONDITION)); - - rParent.SetTable(this); + m_xControl->set_size_request(450, 250); + std::vector<int> aWidths; + aWidths.push_back(40); + aWidths.push_back(110); + aWidths.push_back(150); + aWidths.push_back(60); + m_xControl->set_column_fixed_widths(aWidths); + m_xControl->set_selection_mode(SelectionMode::Multiple); } void BookmarkTable::InsertBookmark(sw::mark::IMark* pMark) @@ -413,51 +387,51 @@ void BookmarkTable::InsertBookmark(sw::mark::IMark* pMark) sHidden = "Yes"; const OUString& sHideCondition = pBookmark->GetHideCondition(); OUString sPageNum = OUString::number(SwPaM(pMark->GetMarkStart()).GetPageNum()); - OUString sColumnData = sPageNum + "\t" + pBookmark->GetName() + "\t" + sBookmarkNodeText + "\t" + sHidden + "\t" + sHideCondition; - InsertEntryToColumn(sColumnData, TREELIST_APPEND, 0xffff, pMark); + int nRow = m_xControl->n_children(); + m_xControl->append(OUString::number(reinterpret_cast<sal_Int64>(pMark)), sPageNum); + m_xControl->set_text(nRow, pBookmark->GetName(), 1); + m_xControl->set_text(nRow, sBookmarkNodeText, 2); + m_xControl->set_text(nRow, sHidden, 3); + m_xControl->set_text(nRow, sHideCondition, 4); } -SvTreeListEntry* BookmarkTable::GetRowByBookmarkName(const OUString& sName) +int BookmarkTable::GetRowByBookmarkName(const OUString& sName) { - SvTreeListEntry* pEntry = First(); - while (pEntry) + for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i) { - sw::mark::IMark* pBookmark = static_cast<sw::mark::IMark*>(pEntry->GetUserData()); + sw::mark::IMark* pBookmark = reinterpret_cast<sw::mark::IMark*>(m_xControl->get_id(i).toInt64()); if (pBookmark->GetName() == sName) { - return pEntry; + return i; } - pEntry = Next(pEntry); } - return nullptr; + return -1; } sw::mark::IMark* BookmarkTable::GetBookmarkByName(const OUString& sName) { - SvTreeListEntry* pEntry = GetRowByBookmarkName(sName); - if (!pEntry) + int nEntry = GetRowByBookmarkName(sName); + if (nEntry == -1) return nullptr; - return static_cast<sw::mark::IMark*>(pEntry->GetUserData()); + return reinterpret_cast<sw::mark::IMark*>(m_xControl->get_id(nEntry).toInt64()); } void BookmarkTable::SelectByName(const OUString& sName) { - SvTreeListEntry* pEntry = GetRowByBookmarkName(sName); - if (!pEntry) + int nEntry = GetRowByBookmarkName(sName); + if (nEntry == -1) return; - - Select(pEntry); + select(nEntry); } OUString BookmarkTable::GetNameProposal() { OUString sDefaultBookmarkName = SwResId(STR_BOOKMARK_DEF_NAME); sal_Int32 nHighestBookmarkId = 0; - SvTreeListEntry* pEntry = First(); - while (pEntry) + for (int i = 0, nCount = m_xControl->n_children(); i < nCount; ++i) { - sw::mark::IMark* pBookmark = static_cast<sw::mark::IMark*>(pEntry->GetUserData()); + sw::mark::IMark* pBookmark = reinterpret_cast<sw::mark::IMark*>(m_xControl->get_id(i).toInt64()); const OUString& sName = pBookmark->GetName(); sal_Int32 nIndex = 0; if (sName.getToken(0, ' ', nIndex) == sDefaultBookmarkName) @@ -465,7 +439,6 @@ OUString BookmarkTable::GetNameProposal() sal_Int32 nCurrBookmarkId = sName.getToken(0, ' ', nIndex).toInt32(); nHighestBookmarkId = std::max<sal_Int32>(nHighestBookmarkId, nCurrBookmarkId); } - pEntry = Next(pEntry); } return sDefaultBookmarkName + " " + OUString::number(nHighestBookmarkId + 1); } |