summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2014-05-24 00:36:06 +0200
committerLuboš Luňák <l.lunak@collabora.com>2014-05-24 00:41:49 +0200
commit5510f563502168defa4ccfc54214d781a7c92868 (patch)
tree4bacd7a0d1246f3bfd6e867e69b9695e7f5cdee1
parent57b1bac23b610f63bdb146fc84eaac7c22ec7e37 (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). Change-Id: I2e7192e00237db1f030d0524c5667fe92c9e496b
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx3
-rw-r--r--sw/qa/extras/ooxmlimport/data/bnc875718.docxbin0 -> 7369 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx23
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx14
4 files changed, 34 insertions, 6 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index a508a489423f..064e4fd47c01 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3497,8 +3497,7 @@ DECLARE_OOXMLEXPORT_TEST(testWordArtWithinDraingtool, "testWordArtWithinDraingto
return;
assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]/mc:Fallback[1]/w:pict[1]/v:rect[1]/v:textbox[1]/w:txbxContent[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
- assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]",1);
- assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[4]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
+ assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:txbx[1]/w:txbxContent[1]",1);
}
DECLARE_OOXMLEXPORT_TEST(testFdo78910, "fdo78910.docx")
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 3e2f2ac7d3a8..0089c4a42cdc 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2126,6 +2126,29 @@ DECLARE_OOXMLIMPORT_TEST(testInlineGroupshape, "inline-groupshape.docx")
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getShape(1), "Opaque"));
}
+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();
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 4a5b8a4549cc..816e85d44065 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2435,6 +2435,8 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::FindOrCreateFieldMaster
-----------------------------------------------------------------------*/
void DomainMapper_Impl::PushFieldContext()
{
+ if(m_bDiscardHeaderFooter)
+ return;
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->element("pushFieldContext");
#endif
@@ -3239,6 +3241,8 @@ void DomainMapper_Impl::handleIndex
-----------------------------------------------------------------------*/
void DomainMapper_Impl::CloseFieldCommand()
{
+ if(m_bDiscardHeaderFooter)
+ return;
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->element("closeFieldCommand");
#endif
@@ -4060,6 +4064,8 @@ void DomainMapper_Impl::SetFieldFFData(FFDataHandler::Pointer_t pFFDataHandler)
-----------------------------------------------------------------------*/
void DomainMapper_Impl::PopFieldContext()
{
+ if(m_bDiscardHeaderFooter)
+ return;
#ifdef DEBUG_DOMAINMAPPER
dmapper_logger->element("popFieldContext");
#endif
@@ -4424,7 +4430,7 @@ void DomainMapper_Impl::RegisterFrameConversion(
bool DomainMapper_Impl::ExecuteFrameConversion()
{
bool bRet = false;
- if( m_xFrameStartRange.is() && m_xFrameEndRange.is() )
+ if( m_xFrameStartRange.is() && m_xFrameEndRange.is() && !m_bDiscardHeaderFooter )
{
bRet = true;
try
@@ -4440,10 +4446,10 @@ bool DomainMapper_Impl::ExecuteFrameConversion()
SAL_WARN( "writerfilter", "Exception caught when converting to frame: " + rEx.Message );
bRet = false;
}
- m_xFrameStartRange = 0;
- m_xFrameEndRange = 0;
- m_aFrameProperties.realloc( 0 );
}
+ m_xFrameStartRange = 0;
+ m_xFrameEndRange = 0;
+ m_aFrameProperties.realloc( 0 );
return bRet;
}