summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2017-11-14 12:32:41 +0300
committerCaolán McNamara <caolanm@redhat.com>2017-11-21 14:12:44 +0100
commit01632a5ee892ebd2218ad8729738672e02d94697 (patch)
tree91010556e5b158deb4e4645d179f32cdf80eaeea
parentf835c36a254c76d448fe62a923fe378c3fb60144 (diff)
tdf#113790: skip charfmt grabbag items existing in autofmt grabbag
Change-Id: Icc0065c1da9471cb36bfef0da45e2f67381a1a31 Reviewed-on: https://gerrit.libreoffice.org/44706 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/44918 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/uiwriter/data/tdf113790.docxbin0 -> 5155 bytes
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx25
-rw-r--r--sw/source/filter/ww8/wrtw8nds.cxx20
3 files changed, 45 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/data/tdf113790.docx b/sw/qa/extras/uiwriter/data/tdf113790.docx
new file mode 100644
index 000000000000..b6334aae7617
--- /dev/null
+++ b/sw/qa/extras/uiwriter/data/tdf113790.docx
Binary files differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index a06d13f7639e..d73a8aa083cb 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -250,6 +250,7 @@ public:
void testMsWordCompTrailingBlanks();
void testCreateDocxAnnotation();
void testTdf107976();
+ void testTdf113790();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -387,6 +388,7 @@ public:
CPPUNIT_TEST(testMsWordCompTrailingBlanks);
CPPUNIT_TEST(testCreateDocxAnnotation);
CPPUNIT_TEST(testTdf107976);
+ CPPUNIT_TEST(testTdf113790);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4962,6 +4964,29 @@ void SwUiWriterTest::testTdf107976()
CPPUNIT_ASSERT(!pTransferable2->GetShell());
}
+void SwUiWriterTest::testTdf113790()
+{
+ SwDoc* pDoc = createDoc("tdf113790.docx");
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ // Create the clipboard document.
+ SwDoc aClipboard;
+ aClipboard.SetClipBoard(true);
+
+ // Go to fourth line - to "ABCD" bulleted list item
+ pWrtShell->Down(/*bSelect=*/false, 4);
+ pWrtShell->SelPara(nullptr);
+ CPPUNIT_ASSERT_EQUAL(OUString("ABCD"), pWrtShell->GetSelText());
+ pWrtShell->Copy(&aClipboard);
+
+ // Go down to next-to-last (empty) line above "Title3"
+ pWrtShell->Down(/*bSelect=*/false, 4);
+ pWrtShell->Paste(&aClipboard);
+
+ // Save it as DOCX & load it again
+ reload("Office Open XML Text", "tdf113790.docx");
+ CPPUNIT_ASSERT(dynamic_cast<SwXTextDocument *>(mxComponent.get()));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index ddf3a0c098be..e86ee61a437f 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -41,6 +41,7 @@
#include <editeng/formatbreakitem.hxx>
#include <editeng/frmdiritem.hxx>
#include <editeng/tstpitem.hxx>
+#include <svl/grabbagitem.hxx>
#include <svl/urihelper.hxx>
#include <svl/whiter.hxx>
#include <fmtpdsc.hxx>
@@ -465,6 +466,25 @@ void SwWW8AttrIter::OutAttr( sal_Int32 nSwPos, bool bRuby )
if ( pCharFormatItem )
ClearOverridesFromSet( *pCharFormatItem, aExportSet );
+ // tdf#113790: AutoFormat style overwrites char style, so remove all
+ // elements from CHARFMT grab bag which are set in AUTOFMT grab bag
+ if (const SfxGrabBagItem *pAutoFmtGrabBag = dynamic_cast<const SfxGrabBagItem*>(pGrabBag))
+ {
+ if (const SfxGrabBagItem *pCharFmtGrabBag = aExportSet.GetItem<SfxGrabBagItem>(RES_CHRATR_GRABBAG, false))
+ {
+ std::unique_ptr<SfxPoolItem> pNewItem(pCharFmtGrabBag->Clone());
+ SfxGrabBagItem* pNewCharFmtGrabBag = dynamic_cast<SfxGrabBagItem*>(pNewItem.get());
+ assert(pNewCharFmtGrabBag);
+ auto & rNewFmtMap = pNewCharFmtGrabBag->GetGrabBag();
+ for (auto const & item : pAutoFmtGrabBag->GetGrabBag())
+ {
+ if (item.second.hasValue())
+ rNewFmtMap.erase(item.first);
+ }
+ aExportSet.Put(*pNewCharFmtGrabBag);
+ }
+ }
+
ww8::PoolItems aExportItems;
GetPoolItems( aExportSet, aExportItems, false );