summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-05-24 00:36:06 +0200
committerAndras Timar <andras.timar@collabora.com>2014-06-02 19:01:58 +0200
commit9bc93edccb3a739e06704d11dd9363e4227ab875 (patch)
tree517cb2ef17a4063e2a82b37a0e1eec082c71ae0d /sw
parent46890f289592257673ba38b95cbd3759f09d04d7 (diff)
discard more header/footer stuff when discarding headers/footers (bnc#875718)
782adba4d436c65cdf85d48f28486321873b15ed discards unneeded headers/footers, but only the text, not e.g. frames or fields. The test document therefore ends up with a frame with a page number inside the body text, because the text in the footer it should be anchored to was discarded. This commit fixes this by discarding more (although probably the whole header/footer shouldn't even be parsed to begin with). The test from b349d2483e1fe64316d87b55d0b3b4c8f2293e2e actually checked for this incorrect frame, so change that (the whole test is suspicious, as the end result is quite far away from what the original doc looks like). (cherry picked from commit 5510f563502168defa4ccfc54214d781a7c92868) Signed-off-by: Andras Timar <andras.timar@collabora.com> Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport.cxx sw/qa/extras/ooxmlimport/ooxmlimport.cxx Change-Id: I2e7192e00237db1f030d0524c5667fe92c9e496b
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/ooxmlimport/data/bnc875718.docxbin0 -> 7369 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx23
2 files changed, 23 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/bnc875718.docx b/sw/qa/extras/ooxmlimport/data/bnc875718.docx
new file mode 100644
index 000000000000..878a46fdf912
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/bnc875718.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 6c2f3a725bca..7f7078cb5e91 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1654,6 +1654,29 @@ DECLARE_OOXMLIMPORT_TEST(testFdo55381, "fdo55381.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int16(4), xCursor->getPage());
}
+DECLARE_OOXMLIMPORT_TEST(testBnc875718, "bnc875718.docx")
+{
+ // The frame in the footer must not accidentally end up in the document body.
+ // The easiest way for this to test I've found is checking that
+ // xray ThisComponent.TextFrames.GetByIndex( index ).Anchor.Text.ImplementationName
+ // is not SwXBodyText but rather SwXHeadFootText
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ for( int i = 0;
+ i < xIndexAccess->getCount();
+ ++i )
+ {
+ uno::Reference<text::XTextFrame> frame(xIndexAccess->getByIndex( i ), uno::UNO_QUERY);
+ uno::Reference<text::XTextRange> range(frame->getAnchor(), uno::UNO_QUERY);
+ uno::Reference<lang::XServiceInfo> text(range->getText(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString( "SwXHeadFootText" ), text->getImplementationName());
+ }
+ // Also check that the footer contents are not in the body text.
+ uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<text::XText> text(textDocument->getText(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL( OUString( "Text\n" ), text->getString());
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();