[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa sw/source
Mike Kaganski
mike.kaganski at collabora.com
Sun Nov 19 09:37:07 UTC 2017
sw/qa/extras/uiwriter/data/tdf113790.docx |binary
sw/qa/extras/uiwriter/uiwriter.cxx | 25 +++++++++++++++++++++++++
sw/source/filter/ww8/wrtw8nds.cxx | 20 ++++++++++++++++++++
3 files changed, 45 insertions(+)
New commits:
commit de80d677c49b445b4acea8a99aea25b582ceece0
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Tue Nov 14 12:32:41 2017 +0300
tdf#113790: skip charfmt grabbag items existing in autofmt grabbag
Change-Id: Icc0065c1da9471cb36bfef0da45e2f67381a1a31
Reviewed-on: https://gerrit.libreoffice.org/44706
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/44772
Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
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
Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113790.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 973c6cadb2a8..cb603f313d95 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -238,6 +238,7 @@ public:
void testTdf105625();
void testTdf107976();
void testCreateDocxAnnotation();
+ void testTdf113790();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -364,6 +365,7 @@ public:
CPPUNIT_TEST(testTdf105625);
CPPUNIT_TEST(testTdf107976);
CPPUNIT_TEST(testCreateDocxAnnotation);
+ CPPUNIT_TEST(testTdf113790);
CPPUNIT_TEST_SUITE_END();
private:
@@ -4604,6 +4606,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 87173dbef028..ecf2b2acc3f8 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>
@@ -466,6 +467,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 );
More information about the Libreoffice-commits
mailing list