[Libreoffice-commits] .: 2 commits - sw/qa writerfilter/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Jan 15 02:17:17 PST 2013
sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf | 3
sw/qa/extras/rtfimport/data/copypaste-footnote.rtf | 6 +
sw/qa/extras/rtfimport/rtfimport.cxx | 47 +++++++++++----
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 7 +-
4 files changed, 49 insertions(+), 14 deletions(-)
New commits:
commit 078e8583eaee630dc24e4c355914b532cadeb316
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jan 15 11:12:55 2013 +0100
clean up copy&paste tests duplication
Change-Id: Idc3e959ba701f9967f7bdb95bd920c8e7416c80a
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 2e07e3b..480a63b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -148,6 +148,27 @@ private:
void run();
/// Get page count.
int getPages();
+ /// Copy&paste helper.
+ void paste(OUString aFilename, uno::Reference<text::XTextRange> xTextRange = uno::Reference<text::XTextRange>())
+ {
+ uno::Reference<document::XFilter> xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XImporter> xImporter(xFilter, uno::UNO_QUERY_THROW);
+ xImporter->setTargetDocument(mxComponent);
+ uno::Sequence<beans::PropertyValue> aDescriptor(xTextRange.is() ? 3 : 2);
+ aDescriptor[0].Name = "InputStream";
+ SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + aFilename, STREAM_WRITE);
+ uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+ aDescriptor[0].Value <<= xStream;
+ aDescriptor[1].Name = "IsNewDoc";
+ aDescriptor[1].Value <<= sal_False;
+ if (xTextRange.is())
+ {
+ aDescriptor[2].Name = "TextInsertModeRange";
+ aDescriptor[2].Value <<= xTextRange;
+ }
+ xFilter->filter(aDescriptor);
+ }
+
};
void Test::run()
@@ -849,18 +870,7 @@ void Test::testCopyPastePageStyle()
{
// The problem was that RTF import during copy&paste did not ignore page styles.
// Once we have more copy&paste tests, makes sense to refactor this to some helper method.
- uno::Reference<uno::XInterface> xInterface(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
- uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
- xImporter->setTargetDocument(mxComponent);
- uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
- uno::Sequence<beans::PropertyValue> aDescriptor(2);
- aDescriptor[0].Name = "InputStream";
- SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-pagestyle-paste.rtf", STREAM_WRITE);
- uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
- aDescriptor[0].Value <<= xStream;
- aDescriptor[1].Name = "IsNewDoc";
- aDescriptor[1].Value <<= sal_False;
- xFilter->filter(aDescriptor);
+ paste("copypaste-pagestyle-paste.rtf");
uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590
@@ -872,21 +882,7 @@ void Test::testCopyPasteFootnote()
uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
-
- uno::Reference<uno::XInterface> xInterface(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
- uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
- xImporter->setTargetDocument(mxComponent);
- uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
- uno::Sequence<beans::PropertyValue> aDescriptor(3);
- aDescriptor[0].Name = "InputStream";
- SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-footnote-paste.rtf", STREAM_WRITE);
- uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
- aDescriptor[0].Value <<= xStream;
- aDescriptor[1].Name = "IsNewDoc";
- aDescriptor[1].Value <<= sal_False;
- aDescriptor[2].Name = "TextInsertModeRange";
- aDescriptor[2].Value <<= xTextRange;
- xFilter->filter(aDescriptor);
+ paste("copypaste-footnote-paste.rtf", xTextRange);
CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
}
commit b6a2083b9dfe5aceb0900315363ef41e2f3abef5
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jan 15 09:58:48 2013 +0100
fdo#59338 fix RTF paste into footnote
Change-Id: I89501f267fd4256eb3b1316ef41a0f9b0786e0f0
diff --git a/sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf b/sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf
new file mode 100644
index 0000000..1f4a75e
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/copypaste-footnote-paste.rtf
@@ -0,0 +1,3 @@
+{\rtf1
+bbb
+\par }
diff --git a/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf b/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
new file mode 100644
index 0000000..93e4613
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/copypaste-footnote.rtf
@@ -0,0 +1,6 @@
+{\rtf1
+aaa
+{\super \chftn
+{\*\footnote \chftn\pard\plain \li339\fi-339 \par}
+}
+\par }
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 4f5b8c0..2e07e3b 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -117,6 +117,7 @@ public:
void testFdo52475();
void testFdo55493();
void testCopyPastePageStyle();
+ void testCopyPasteFootnote();
void testShptxtPard();
void testDoDhgt();
void testDplinehollow();
@@ -203,6 +204,7 @@ void Test::run()
{"fdo52475.rtf", &Test::testFdo52475},
{"fdo55493.rtf", &Test::testFdo55493},
{"copypaste-pagestyle.rtf", &Test::testCopyPastePageStyle},
+ {"copypaste-footnote.rtf", &Test::testCopyPasteFootnote},
{"shptxt-pard.rtf", &Test::testShptxtPard},
{"do-dhgt.rtf", &Test::testDoDhgt},
{"dplinehollow.rtf", &Test::testDplinehollow},
@@ -864,6 +866,31 @@ void Test::testCopyPastePageStyle()
CPPUNIT_ASSERT_EQUAL(sal_Int32(21001), getProperty<sal_Int32>(xPropertySet, "Width")); // Was letter, i.e. 21590
}
+void Test::testCopyPasteFootnote()
+{
+ // The RTF import did not handle the case when the position wasn't the main document XText, but something different, e.g. a footnote.
+ uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> xTextRange(xFootnotes->getByIndex(0), uno::UNO_QUERY);
+
+ uno::Reference<uno::XInterface> xInterface(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
+ uno::Reference<document::XImporter> xImporter(xInterface, uno::UNO_QUERY_THROW);
+ xImporter->setTargetDocument(mxComponent);
+ uno::Reference<document::XFilter> xFilter(xInterface, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aDescriptor(3);
+ aDescriptor[0].Name = "InputStream";
+ SvStream* pStream = utl::UcbStreamHelper::CreateStream(getURLFromSrc("/sw/qa/extras/rtfimport/data/") + "copypaste-footnote-paste.rtf", STREAM_WRITE);
+ uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+ aDescriptor[0].Value <<= xStream;
+ aDescriptor[1].Name = "IsNewDoc";
+ aDescriptor[1].Value <<= sal_False;
+ aDescriptor[2].Name = "TextInsertModeRange";
+ aDescriptor[2].Value <<= xTextRange;
+ xFilter->filter(aDescriptor);
+
+ CPPUNIT_ASSERT_EQUAL(OUString("bbb"), xTextRange->getString());
+}
+
void Test::testShptxtPard()
{
// The problem was that \pard inside \shptxt caused loss of shape text
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3ec9f5c..33d2646 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -227,9 +227,12 @@ uno::Reference< container::XNameContainer > DomainMapper_Impl::GetPageStyles(
uno::Reference< text::XText > DomainMapper_Impl::GetBodyText()
{
- if(!m_xBodyText.is() && m_xTextDocument.is())
+ if(!m_xBodyText.is())
{
- m_xBodyText = m_xTextDocument->getText();
+ if (m_xInsertTextRange.is())
+ m_xBodyText = m_xInsertTextRange->getText();
+ else if (m_xTextDocument.is())
+ m_xBodyText = m_xTextDocument->getText();
}
return m_xBodyText;
}
More information about the Libreoffice-commits
mailing list