From a3fa048790b6e0928be3ff8bcd102813e0bcedb3 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 4 Oct 2013 11:02:59 +0200 Subject: [PATCH] fdo#69384 fix impress -> writer copy&paste Regression from 2ade07126971b79c92f729fae5709f2e2e2b495c (fdo#62044 RTF import: don't overwrite existing styles when pasting, 2013-06-04), during paste, if existing style was found, then the intention was to skip that style, but instead we tried to create one. (cherry picked from commit 5ebe826caf75e8d00656b3333385bf0bbc05cb27) Conflicts: writerfilter/source/dmapper/StyleSheetTable.cxx Change-Id: I83adaf9fe6b8a578fa60c21b9463fabde7707d7e Reviewed-on: https://gerrit.libreoffice.org/6126 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- sw/qa/extras/rtfimport/data/fdo69384-paste.rtf | 17 +++++++++++++++++ sw/qa/extras/rtfimport/rtfimport.cxx | 14 ++++++++++++++ writerfilter/source/dmapper/StyleSheetTable.cxx | 11 +++++++++-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/rtfimport/data/fdo69384-paste.rtf diff --git a/sw/qa/extras/rtfimport/data/fdo69384-paste.rtf b/sw/qa/extras/rtfimport/data/fdo69384-paste.rtf new file mode 100644 index 0000000..cbdca5b --- /dev/null +++ b/sw/qa/extras/rtfimport/data/fdo69384-paste.rtf @@ -0,0 +1,17 @@ +{\rtf\ansi +{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fprq2\fcharset0 Segoe UI;}{\f2\fprq2\fcharset0 Arial;}{\f3\froman\fprq2\fcharset0 Arial;}{\f4\fprq2\fcharset0 Droid Sans Fallback;}} +{\colortbl\red255\green255\blue255;;} +{\stylesheet +{\s1\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\snext1 Default;} +{\s2\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext2 Object with arrow;} +{\s3\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext3 Object with shadow;} +{\s4\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext4 Object without fill;} +{\s5\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext5 Object with no fill and no line;} +{\s6\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext6 Text;} +{\s7\fi0\li0\ri0\sb0\sa0\sl200\slmult0\cf0\f3\fs32\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext7 Text body;} +{\s8\fi0\li0\ri0\sb0\sa0\sl200\slmult0\ql\cf0\f3\fs36\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs36\fs36\b0\b0\i0\i0\accnone\olnone\sbasedon1\snext8 Text body justified;}} +{\*\EditEnginePoolDefaults\ltrpar\fi0\li0\ri0\fi0\li0\ri0\sb0\sa0\sl0\slmult0\ql\cf0\f0\fs48\b0\ulnone\strike0\i0\outl0\shad0\kerning0\expndtw0\f1\f2\fs48\fs48\b0\b0\i0\i0\accnone\olnone} +\deftab709 +{ +\s27\fi0\li0\ri0\qc\cf0\f3\fs64\b0\ulnone\strike0\i0\outl0\shad0\kerning1\f4\f2\fs64\fs64\b0\b0\i0\i0\accnone\olnone {\f3\fs64\b0\i0 sss}\par\pard\plain +}} diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx index 8508909..e79d282 100644 --- a/sw/qa/extras/rtfimport/rtfimport.cxx +++ b/sw/qa/extras/rtfimport/rtfimport.cxx @@ -159,6 +159,7 @@ public: void testFdo44715(); void testFdo68076(); void testFdo68291(); + void testFdo69384(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -302,6 +303,7 @@ void Test::run() {"fdo44715.rtf", &Test::testFdo44715}, {"fdo68076.rtf", &Test::testFdo68076}, {"fdo68291.odt", &Test::testFdo68291}, + {"hello.rtf", &Test::testFdo69384}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1464,6 +1466,18 @@ void Test::testFdo68291() CPPUNIT_ASSERT_EQUAL(OUString(), getProperty(getParagraph(1), "PageDescName")); } +void Test::testFdo69384() +{ + uno::Reference xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference xText(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference xEnd = xText->getEnd(); + paste("fdo69384-paste.rtf", xEnd); + + // Import got interrupted in the middle of style sheet table import, + // resuling in missing styles and text. + getStyles("ParagraphStyles")->getByName("Text body justified"); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 8352b1b..61ff0ba 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -724,9 +724,16 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) uno::Reference< container::XNameContainer > xStyles = bParaStyle ? xParaStyles : xCharStyles; uno::Reference< style::XStyle > xStyle; OUString sConvertedStyleName = ConvertStyleName( pEntry->sStyleName ); - // When pasting, don't update existing styles. - if(xStyles->hasByName( sConvertedStyleName ) && m_pImpl->m_bIsNewDoc) + if(xStyles->hasByName( sConvertedStyleName )) + { + // When pasting, don't update existing styles. + if (!m_pImpl->m_bIsNewDoc) + { + ++aIt; + continue; + } xStyles->getByName( sConvertedStyleName ) >>= xStyle; + } else { bInsert = true; -- 1.8.3.1