summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-06-24 16:55:02 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-06-24 17:00:23 +0200
commita531676d6ddcda78f126781ca628cc2d5fc20277 (patch)
tree4a3a619a7f5e26bbcce91e616777f3a04dff7721
parentfdo#72157: webdav: Release WebDAV file lock on document close. (diff)
downloadcore-a531676d6ddcda78f126781ca628cc2d5fc20277.tar.gz
core-a531676d6ddcda78f126781ca628cc2d5fc20277.zip
fix broken redlines after undoing column count change (cp#1000071)
Changing a document with redlines to two columns and then using undo set some redlines to point to the end of the document (done by the call to RemoveIdxFromSection() in SwUndoInsSection::UndoImpl()). Change-Id: I88b563b88beebcd1c3cb21fe61bb56cdb12cdc41
-rw-r--r--sw/CppunitTest_sw_uiwriter.mk1
-rw-r--r--sw/qa/extras/uiwriter/data/cp1000071.odtbin0 -> 9268 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx45
-rw-r--r--sw/source/core/inc/UndoSection.hxx1
-rw-r--r--sw/source/core/undo/unsect.cxx7
5 files changed, 54 insertions, 0 deletions
diff --git a/sw/CppunitTest_sw_uiwriter.mk b/sw/CppunitTest_sw_uiwriter.mk
index 4ddff3a188b0..1a1914e8e1b6 100644
--- a/sw/CppunitTest_sw_uiwriter.mk
+++ b/sw/CppunitTest_sw_uiwriter.mk
@@ -20,6 +20,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uiwriter, \
cppu \
cppuhelper \
sal \
+ svl \
svt \
svxcore \
sw \
diff --git a/sw/qa/extras/uiwriter/data/cp1000071.odt b/sw/qa/extras/uiwriter/data/cp1000071.odt
new file mode 100644
index 000000000000..109e39986596
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/cp1000071.odt
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 85c294c07776..2bf8d5ac7598 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -13,6 +13,10 @@
#include <shellio.hxx>
#include <expfld.hxx>
#include <drawdoc.hxx>
+#include <docary.hxx>
+#include <redline.hxx>
+#include <section.hxx>
+#include <fmtclds.hxx>
#include <svx/svdpage.hxx>
@@ -36,6 +40,7 @@ public:
void testFdo75898();
void testFdo74981();
void testShapeTextboxDelete();
+ void testCp1000071();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -48,6 +53,7 @@ public:
CPPUNIT_TEST(testFdo75898);
CPPUNIT_TEST(testFdo74981);
CPPUNIT_TEST(testShapeTextboxDelete);
+ CPPUNIT_TEST(testCp1000071);
CPPUNIT_TEST_SUITE_END();
private:
@@ -293,6 +299,45 @@ void SwUiWriterTest::testShapeTextboxDelete()
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nActual);
}
+void SwUiWriterTest::testCp1000071()
+{
+ SwDoc* pDoc = createDoc("cp1000071.odt");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+
+ const SwRedlineTbl& rTbl = pDoc->GetRedlineTbl();
+ CPPUNIT_ASSERT_EQUAL( size_t( 2 ), rTbl.size());
+ sal_uLong redlineStart0NodeIndex = rTbl[ 0 ]->Start()->nNode.GetIndex();
+ sal_Int32 redlineStart0Index = rTbl[ 0 ]->Start()->nContent.GetIndex();
+ sal_uLong redlineEnd0NodeIndex = rTbl[ 0 ]->End()->nNode.GetIndex();
+ sal_Int32 redlineEnd0Index = rTbl[ 0 ]->End()->nContent.GetIndex();
+ sal_uLong redlineStart1NodeIndex = rTbl[ 1 ]->Start()->nNode.GetIndex();
+ sal_Int32 redlineStart1Index = rTbl[ 1 ]->Start()->nContent.GetIndex();
+ sal_uLong redlineEnd1NodeIndex = rTbl[ 1 ]->End()->nNode.GetIndex();
+ sal_Int32 redlineEnd1Index = rTbl[ 1 ]->End()->nContent.GetIndex();
+
+ // Change the document layout to be 2 columns, and then undo.
+ pWrtShell->SelAll();
+ SwSectionData section(CONTENT_SECTION, pWrtShell->GetUniqueSectionName());
+ SfxItemSet set( pDoc->GetDocShell()->GetPool(), RES_COL, RES_COL, 0 );
+ SwFmtCol col;
+ col.Init( 2, 0, 10000 );
+ set.Put( col );
+ pWrtShell->InsertSection( section, &set );
+ sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+ rUndoManager.Undo();
+
+ // Check that redlines are the same like at the beginning.
+ CPPUNIT_ASSERT_EQUAL( size_t( 2 ), rTbl.size());
+ CPPUNIT_ASSERT_EQUAL( redlineStart0NodeIndex, rTbl[ 0 ]->Start()->nNode.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineStart0Index, rTbl[ 0 ]->Start()->nContent.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineEnd0NodeIndex, rTbl[ 0 ]->End()->nNode.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineEnd0Index, rTbl[ 0 ]->End()->nContent.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineStart1NodeIndex, rTbl[ 1 ]->Start()->nNode.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineStart1Index, rTbl[ 1 ]->Start()->nContent.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineEnd1NodeIndex, rTbl[ 1 ]->End()->nNode.GetIndex());
+ CPPUNIT_ASSERT_EQUAL( redlineEnd1Index, rTbl[ 1 ]->End()->nContent.GetIndex());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/inc/UndoSection.hxx b/sw/source/core/inc/UndoSection.hxx
index 72524128aed5..4c769a60de60 100644
--- a/sw/source/core/inc/UndoSection.hxx
+++ b/sw/source/core/inc/UndoSection.hxx
@@ -38,6 +38,7 @@ private:
const ::std::auto_ptr<SfxItemSet> m_pAttrSet;
::std::auto_ptr<SwHistory> m_pHistory;
::std::auto_ptr<SwRedlineData> m_pRedlData;
+ ::std::auto_ptr<SwRedlineSaveDatas> m_pRedlineSaveData;
sal_uLong m_nSectionNodePos;
bool m_bSplitAtStart : 1;
bool m_bSplitAtEnd : 1;
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index b229aa32687d..2b9e19fd463a 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -70,6 +70,7 @@ SwUndoInsSection::SwUndoInsSection(
, m_pAttrSet( (pSet && pSet->Count()) ? new SfxItemSet( *pSet ) : 0 )
, m_pHistory(0)
, m_pRedlData(0)
+ , m_pRedlineSaveData(0)
, m_nSectionNodePos(0)
, m_bSplitAtStart(false)
, m_bSplitAtEnd(false)
@@ -82,6 +83,9 @@ SwUndoInsSection::SwUndoInsSection(
rDoc.GetRedlineAuthor() ));
SetRedlineMode( rDoc.GetRedlineMode() );
}
+ m_pRedlineSaveData.reset( new SwRedlineSaveDatas );
+ if( !FillSaveData( rPam, *m_pRedlineSaveData, false ))
+ m_pRedlineSaveData.reset( NULL );
if( !rPam.HasMark() )
{
@@ -151,6 +155,9 @@ void SwUndoInsSection::UndoImpl(::sw::UndoRedoContext & rContext)
}
AddUndoRedoPaM(rContext);
+
+ if( m_pRedlineSaveData.get())
+ SetSaveData( rDoc, *m_pRedlineSaveData );
}
void SwUndoInsSection::RedoImpl(::sw::UndoRedoContext & rContext)