revert writer won't allow us to enter multiple CrossRefBookmark

i.e.

commit af64f43018
Date:   Mon Dec 8 16:11:41 2014 +0000

    writer won't allow us to enter multiple CrossRefBookmarks on the same node

    e.g. fdo63164-1.docx and loads more like that, and the .docx genuinely has
    multiple bookmarks at the same place, so just allow the first one and discard
    the following ones

in favour of

commit 7a12360e1f
Date:   Wed Dec 10 14:56:27 2014 +0100

    sw: don't assert when SwXBookmark creates duplicate CrossRef*Bookmark

    The bugdoc of fdo#87110 has a couple such duplicates.  Check for it and
    let SwXBookmark throw an IllegalArgumentException.

but leave test doc in place

Change-Id: Ib0bfc991684b2c9c4f1959a17c49bf1c0179be79
This commit is contained in:
Caolán McNamara
2014-12-10 16:36:26 +00:00
parent f3c653a138
commit a645c82894
2 changed files with 4 additions and 27 deletions

View File

@@ -55,7 +55,6 @@
#include <com/sun/star/text/XParagraphCursor.hpp>
#include <com/sun/star/text/XRedline.hpp>
#include <com/sun/star/text/XTextFieldsSupplier.hpp>
#include <com/sun/star/text/XTextRangeCompare.hpp>
#include <com/sun/star/style/DropCapFormat.hpp>
#include <com/sun/star/util/NumberFormatter.hpp>
#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
@@ -4416,31 +4415,11 @@ void DomainMapper_Impl::StartOrEndBookmark( const OUString& rId )
{
xCursor->goLeft( 1, false );
}
uno::Reference< container::XNamed > xBkmNamed( xBookmark, uno::UNO_QUERY_THROW );
bool bAllowInsert = true;
uno::Reference<text::XTextRange> xRange(xCursor, uno::UNO_QUERY_THROW);
if (m_xPrevBookmark.is())
{
uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xRange->getText(), uno::UNO_QUERY_THROW);
if (xTextRangeCompare->compareRegionStarts(m_xPrevBookmark, xRange) == 0 &&
xTextRangeCompare->compareRegionEnds(m_xPrevBookmark, xRange) == 0)
{
SAL_WARN("writerfilter", "Cannot insert bookmark " << aBookmarkIter->second.m_sBookmarkName
<< " because another one is already inserted at this point");
bAllowInsert = false;
}
}
if (bAllowInsert)
{
assert(!aBookmarkIter->second.m_sBookmarkName.isEmpty());
//todo: make sure the name is not used already!
xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
xTextAppend->insertTextContent(xRange, xBookmark, !xCursor->isCollapsed());
m_xPrevBookmark = xRange;
}
assert(!aBookmarkIter->second.m_sBookmarkName.isEmpty());
//todo: make sure the name is not used already!
xBkmNamed->setName( aBookmarkIter->second.m_sBookmarkName );
xTextAppend->insertTextContent( uno::Reference< text::XTextRange >( xCursor, uno::UNO_QUERY_THROW), xBookmark, !xCursor->isCollapsed() );
}
m_aBookmarkMap.erase( aBookmarkIter );
m_sCurrentBkmkId.clear();

View File

@@ -349,8 +349,6 @@ private:
LineNumberSettings m_aLineNumberSettings;
BookmarkMap_t m_aBookmarkMap;
/// Detect attempt to insert multiple bookmarks at the same position
css::uno::Reference<css::text::XTextRange> m_xPrevBookmark;
OUString m_sCurrentBkmkId;
OUString m_sCurrentBkmkName;