Kaydet (Commit) abe1e852 authored tarafından Luboš Luňák's avatar Luboš Luňák

handle properly page breaks even if a page contains only a frame (fdo#55381)

The test document has 4 pages which only contain frames, first 3 pages
(sections) have <p> block with <framePr> and another <p> with just <sectPr>,
and the second paragraph would be removed, thus there would be no nodes on which
to actually set the page style and they would be set on nodes for the previous
page, overwriting its page style. The last page does not have its own <p>
at all, so it needs to be faked.

The changes in finishParagraph() are because of e.g. the comments-nested.odt
sw test, which there causes exception because of unknown property ParaStyleName
(comments do not use those it seems) and the code is skipped over (which
is probably a bug on its own, but it's unrelated to this change otherwise).

Change-Id: I9d37f992407a9b649c710d2a031ec4447fb11771
üst d44067e9
...@@ -2056,6 +2056,15 @@ DECLARE_OOXMLIMPORT_TEST(testFdo75722dml, "fdo75722-dml.docx") ...@@ -2056,6 +2056,15 @@ DECLARE_OOXMLIMPORT_TEST(testFdo75722dml, "fdo75722-dml.docx")
CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot); CPPUNIT_ASSERT_EQUAL(sal_Int64(3128), nRot);
} }
DECLARE_OOXMLIMPORT_TEST(testFdo55381, "fdo55381.docx")
{
uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
xCursor->jumpToLastPage();
CPPUNIT_ASSERT_EQUAL(sal_Int16(4), xCursor->getPage());
}
#endif #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -2458,6 +2458,18 @@ void DomainMapper::lcl_endSectionGroup() ...@@ -2458,6 +2458,18 @@ void DomainMapper::lcl_endSectionGroup()
{ {
m_pImpl->CheckUnregisteredFrameConversion(); m_pImpl->CheckUnregisteredFrameConversion();
m_pImpl->ExecuteFrameConversion(); m_pImpl->ExecuteFrameConversion();
if(m_pImpl->GetIsFirstParagraphInSection())
{
// This section has no paragraph at all (e.g. they are all actually in a frame).
// If this section has a page break, there would be nothing to apply to the page
// style, so force a dummy paragraph.
lcl_startParagraphGroup();
lcl_startCharacterGroup();
sal_uInt8 sBreak[] = { 0xd };
lcl_text(sBreak, 1);
lcl_endCharacterGroup();
lcl_endParagraphGroup();
}
PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION); PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION);
SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() ); SectionPropertyMap* pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() );
OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); OSL_ENSURE(pSectionContext, "SectionContext unavailable!");
......
...@@ -1105,12 +1105,6 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) ...@@ -1105,12 +1105,6 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY ); uno::Reference< text::XTextRange > xParaEnd( xCur, uno::UNO_QUERY );
CheckParaMarkerRedline( xParaEnd ); CheckParaMarkerRedline( xParaEnd );
m_bIsFirstParaInSection = false;
m_bIsLastParaInSection = false;
m_bParaChanged = false;
// Reset the frame properties for the next paragraph
pParaContext->ResetFrameProperties();
} }
if( !bKeepLastParagraphProperties ) if( !bKeepLastParagraphProperties )
rAppendContext.pLastParagraphProperties = pToBeSavedProperties; rAppendContext.pLastParagraphProperties = pToBeSavedProperties;
...@@ -1119,11 +1113,22 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap ) ...@@ -1119,11 +1113,22 @@ void DomainMapper_Impl::finishParagraph( PropertyMapPtr pPropertyMap )
{ {
OSL_FAIL( "IllegalArgumentException in DomainMapper_Impl::finishParagraph" ); OSL_FAIL( "IllegalArgumentException in DomainMapper_Impl::finishParagraph" );
} }
catch(const uno::Exception&) catch(const uno::Exception& e)
{ {
SAL_WARN( "writerfilter", "finishParagraph() exception: " << e.Message );
} }
} }
m_bParaChanged = false;
if(!pParaContext->IsFrameMode())
{ // If the paragraph is in a frame, it's not a paragraph of the section itself.
m_bIsFirstParaInSection = false;
m_bIsLastParaInSection = false;
}
// Reset the frame properties for the next paragraph
pParaContext->ResetFrameProperties();
#ifdef DEBUG_DOMAINMAPPER #ifdef DEBUG_DOMAINMAPPER
dmapper_logger->endElement(); dmapper_logger->endElement();
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment