summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-01-15 17:54:52 +0100
committerMiklos Vajna <vmiklos@collabora.com>2020-01-16 20:35:16 +0100
commitc521e69ab9b0330e9e8ad8c58d14f44d74aa2267 (patch)
treefd010f2d5193920e9960f84787ec80eedd22fa66 /writerfilter
parent739627a524ab32a085c49a8936708ba58de8d393 (diff)
DOCX import: improve support for headers/footers from cont sect break
A continuous section break in a DOCX file can set new headers/footers which start appearing from the next page. In general, this is not something Writer supports, but commit 08f13ab85b5c65b5dc8adfa15918fb3e426fcc3c (tdf#112202 writerfilter,sw: fix loss of headers, 2019-12-16) improved the situation significantly here. Build on top of that and add support for a few more cases: 1) When checking for the last paragraph of the previous section, detect when that last paragraph is so small so in practice that's not the last one. 2) Handle when the text node in question has no explicit break type set, only a SwFormatPageDesc (which implicitly causes a page break). 3) When setting the page style to show the correct header/footer, don't set the page style on the previous paragraph directly, rather update the "next style" of the already set page style. (This is safe, as we never reuse the same Writer page style for multiple Word sections.) Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport14.cxx (cherry picked from commit 9a50e8f2bcde95233e4b38707c521ada90fcd6af) Change-Id: Iede196b864af5123c5637f82432ed6e0f7e7241a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86915 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 120fb7872ed3..8fbfdb01aca8 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1415,9 +1415,11 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
}
}
}
+ uno::Reference<text::XParagraphCursor> const xPCursor(xCursor,
+ uno::UNO_QUERY_THROW);
+ float fCharHeight = 0;
if (!isFound)
{ // HACK: try the last paragraph of the previous section
- uno::Reference<text::XParagraphCursor> const xPCursor(xCursor, uno::UNO_QUERY_THROW);
xPCursor->gotoPreviousParagraph(false);
uno::Reference<beans::XPropertySet> const xPSCursor(xCursor, uno::UNO_QUERY_THROW);
style::BreakType bt;
@@ -1426,6 +1428,27 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
{
xPSCursor->setPropertyValue(getPropertyName(PROP_PAGE_DESC_NAME),
uno::makeAny(m_sFollowPageStyleName));
+ isFound = true;
+ }
+ else
+ {
+ xPSCursor->getPropertyValue("CharHeight") >>= fCharHeight;
+ }
+ }
+ if (!isFound && fCharHeight <= 1.0)
+ {
+ // If still not found, see if the last paragraph is ~invisible, and work with
+ // the last-in-practice paragraph.
+ xPCursor->gotoPreviousParagraph(false);
+ uno::Reference<beans::XPropertySet> xPropertySet(xCursor, uno::UNO_QUERY_THROW);
+ OUString aPageDescName;
+ if ((xPropertySet->getPropertyValue("PageDescName") >>= aPageDescName)
+ && !aPageDescName.isEmpty())
+ {
+ uno::Reference<beans::XPropertySet> xPageStyle(
+ rDM_Impl.GetPageStyles()->getByName(aPageDescName), uno::UNO_QUERY);
+ xPageStyle->setPropertyValue("FollowStyle",
+ uno::makeAny(m_sFollowPageStyleName));
}
}
}