sw/source/core/unocore/unocoll.cxx | 74 ++++++++++++++++++++++++++++++------- sw/source/ui/index/cnttab.cxx | 10 ++--- 2 files changed, 64 insertions(+), 20 deletions(-)
New commits: commit 45be3ac8151d63ccb61879f876696704542a4ce7 Author: Michael Stahl <mst...@redhat.com> Date: Wed Aug 22 23:04:34 2012 +0200 fdo#51514: SwXBookmarks: only consider real bookmarks: Since CWS swrefactormarks2 the SwXBookmarks collection handles not only bookmarks but at least cross-ref marks as well, which then bother users when they show up in the Insert->Hyperlink dialog; remove non-bookmarks again. (regression from df6d312ca537402463e4eb0530f22b956600fc02) Change-Id: I6a64ba8a43468dd3ce1569e944371d3ef71f8824 diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index ba6570c..57ac3b5 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -86,6 +86,7 @@ #include <vbahelper/vbaaccesshelper.hxx> #include <basic/basmgr.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/sequenceasvector.hxx> using ::rtl::OUString; using namespace ::com::sun::star; @@ -1643,7 +1644,20 @@ sal_Int32 SwXBookmarks::getCount(void) SolarMutexGuard aGuard; if(!IsValid()) throw uno::RuntimeException(); - return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount(); + + sal_Int32 count(0); + IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); + for (IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getBookmarksBegin(); + ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark) + { + if (IDocumentMarkAccess::BOOKMARK == + IDocumentMarkAccess::GetType(**ppMark)) + { + ++count; // only count real bookmarks + } + } + return count; } uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex) @@ -1656,12 +1670,26 @@ uno::Any SwXBookmarks::getByIndex(sal_Int32 nIndex) if(nIndex < 0 || nIndex >= pMarkAccess->getBookmarksCount()) throw IndexOutOfBoundsException(); - uno::Any aRet; - ::sw::mark::IMark* pBkmk = pMarkAccess->getBookmarksBegin()[nIndex].get(); - const uno::Reference< text::XTextContent > xRef = - SwXBookmark::CreateXBookmark(*GetDoc(), *pBkmk); - aRet <<= xRef; - return aRet; + sal_Int32 count(0); + for (IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getBookmarksBegin(); + ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark) + { + if (IDocumentMarkAccess::BOOKMARK == + IDocumentMarkAccess::GetType(**ppMark)) + { + if (count == nIndex) + { + uno::Any aRet; + const uno::Reference< text::XTextContent > xRef = + SwXBookmark::CreateXBookmark(*GetDoc(), **ppMark); + aRet <<= xRef; + return aRet; + } + ++count; // only count real bookmarks + } + } + throw IndexOutOfBoundsException(); } uno::Any SwXBookmarks::getByName(const rtl::OUString& rName) @@ -1690,13 +1718,19 @@ uno::Sequence< OUString > SwXBookmarks::getElementNames(void) if(!IsValid()) throw uno::RuntimeException(); + ::comphelper::SequenceAsVector< ::rtl::OUString > ret; IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); - uno::Sequence<OUString> aSeq(pMarkAccess->getBookmarksCount()); - sal_Int32 nCnt = 0; - for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getBookmarksBegin(); - ppMark != pMarkAccess->getBookmarksEnd();) - aSeq[nCnt++] = (*ppMark++)->GetName(); - return aSeq; + for (IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getBookmarksBegin(); + ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark) + { + if (IDocumentMarkAccess::BOOKMARK == + IDocumentMarkAccess::GetType(**ppMark)) + { + ret.push_back((*ppMark)->GetName()); // only add real bookmarks + } + } + return ret.getAsConstList(); } sal_Bool SwXBookmarks::hasByName(const OUString& rName) @@ -1722,7 +1756,19 @@ sal_Bool SwXBookmarks::hasElements(void) SolarMutexGuard aGuard; if(!IsValid()) throw uno::RuntimeException(); - return GetDoc()->getIDocumentMarkAccess()->getBookmarksCount() != 0; + + IDocumentMarkAccess* const pMarkAccess = GetDoc()->getIDocumentMarkAccess(); + for (IDocumentMarkAccess::const_iterator_t ppMark = + pMarkAccess->getBookmarksBegin(); + ppMark != pMarkAccess->getBookmarksEnd(); ++ppMark) + { + if (IDocumentMarkAccess::BOOKMARK == + IDocumentMarkAccess::GetType(**ppMark)) + { + return true; + } + } + return false; } SwXNumberingRulesCollection::SwXNumberingRulesCollection( SwDoc* _pDoc ) : commit c47505a4525c342694ba4196544715467c2bdb8e Author: Michael Stahl <mst...@redhat.com> Date: Wed Aug 22 21:45:27 2012 +0200 SwTokenWindow::InsertAtSelection: fix STL assertion: error: attempt to copy-construct an iterator from a singular iterator. (regression from 39b8a5f87f55abe53488c9c3c35b65fb0df84cde) Change-Id: Iab29f4c356ea1cb5ca0f687bcfc5e54f185fbba3 diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx index 94bf14f..30425bf 100644 --- a/sw/source/ui/index/cnttab.cxx +++ b/sw/source/ui/index/cnttab.cxx @@ -3141,13 +3141,11 @@ void SwTokenWindow::InsertAtSelection( ctrl_iterator iterActive = std::find(aControlList.begin(), aControlList.end(), pActiveCtrl); - ctrl_iterator iterInsert = iterActive; - Size aControlSize(GetOutputSizePixel()); if( WINDOW_EDIT == pActiveCtrl->GetType()) { - ++iterInsert; + ++iterActive; Selection aSel = ((SwTOXEdit*)pActiveCtrl)->GetSelection(); aSel.Justify(); @@ -3163,7 +3161,7 @@ void SwTokenWindow::InsertAtSelection( SwFormToken aTmpToken(TOKEN_TEXT); SwTOXEdit* pEdit = new SwTOXEdit(&aCtrlParentWin, this, aTmpToken); - iterInsert = aControlList.insert(iterInsert, pEdit); + iterActive = aControlList.insert(iterActive, pEdit); pEdit->SetText(sRight); pEdit->SetSizePixel(aControlSize); @@ -3175,7 +3173,7 @@ void SwTokenWindow::InsertAtSelection( } else { - aControlList.erase(iterActive); + iterActive = aControlList.erase(iterActive); pActiveCtrl->Hide(); delete pActiveCtrl; } @@ -3183,7 +3181,7 @@ void SwTokenWindow::InsertAtSelection( //now the new button SwTOXButton* pButton = new SwTOXButton(&aCtrlParentWin, this, aToInsertToken); - aControlList.insert(iterInsert, pButton); + aControlList.insert(iterActive, pButton); pButton->SetPrevNextLink(LINK(this, SwTokenWindow, NextItemBtnHdl)); pButton->SetGetFocusHdl(LINK(this, SwTokenWindow, TbxFocusBtnHdl)); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits