Kaydet (Commit) 6b9ab853 authored tarafından Michael Stahl's avatar Michael Stahl

fdo#85872: sw: fix crash in insert index dialog

Looks like the old code would create a link starting at the beginning in
this case, so let's do the same.

(regression from 94b296d5)

Change-Id: Idcd17ae51c478aa5c2a000c7b33a8244f06bd166
üst e3e064ed
......@@ -64,7 +64,9 @@ ToxLinkProcessorTest::ExceptionIsThrownIfTooManyLinksAreClosed()
ToxLinkProcessor sut;
sut.StartNewLink(0, STYLE_NAME_1);
sut.CloseLink(1, URL_1);
CPPUNIT_ASSERT_THROW(sut.CloseLink(1, URL_1), std::runtime_error);
// fdo#85872 actually it turns out the UI does something like this
// so an exception must not be thrown!
sut.CloseLink(1, URL_1);
}
void
......
......@@ -11,6 +11,7 @@
#include "SwStyleNameMapper.hxx"
#include "ndtxt.hxx"
#include <poolfmt.hrc>
#include <boost/foreach.hpp>
#include <stdexcept>
......@@ -26,11 +27,13 @@ ToxLinkProcessor::StartNewLink(sal_Int32 startPosition, const OUString& characte
void
ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url)
{
if (mStartedLinks.empty()) {
throw std::runtime_error("ToxLinkProcessor: More calls for CloseLink() than open links exist.");
StartedLink const startedLink( (mStartedLinks.empty())
? StartedLink(0, SW_RES(STR_POOLCHR_TOXJUMP))
: mStartedLinks.back() );
if (!mStartedLinks.empty())
{
mStartedLinks.pop_back();
}
StartedLink startedLink = mStartedLinks.back();
mStartedLinks.pop_back();
if (url.isEmpty()) {
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment