[Libreoffice-commits] core.git: 2 commits - sw/qa sw/source
Miklos Vajna
vmiklos at collabora.co.uk
Fri Jun 27 13:35:03 PDT 2014
sw/qa/extras/rtfexport/data/fdo80167.rtf | 6 ++++++
sw/qa/extras/rtfexport/rtfexport.cxx | 12 +++++++++---
sw/source/filter/ww8/docxexport.hxx | 2 ++
sw/source/filter/ww8/rtfexport.hxx | 5 +++++
sw/source/filter/ww8/wrtww8.hxx | 5 +++++
sw/source/filter/ww8/ww8atr.cxx | 13 ++++++++++---
6 files changed, 37 insertions(+), 6 deletions(-)
New commits:
commit 8100100298b877765e1781fb0eed285e82749ad1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jun 27 21:28:36 2014 +0200
fdo#80167 RTF export: don't loose page breaks
DOCX export tries to write accurately both <w:br> and
<w:pageBreakBefore>, while DOC/RTF prefers just the page break before
paragraph attribute. Given that these later two exporters are not
adapted to write their equivalent of <w:br> at all, add a virtual method
to determine if writing page breaks as "page break before" is preferred
or not, that'll give the expected RTF export result.
This conditionally reverts commit
a31fbb53dba76736b37213b98b64937f05929a67 (fdo#74566:DOCX: Preservation
<w:br> tag for Break to Next Page, 2014-02-06).
Change-Id: I4a5dd295b07739a570cd8cc6709561e64d031273
diff --git a/sw/qa/extras/rtfexport/data/fdo80167.rtf b/sw/qa/extras/rtfexport/data/fdo80167.rtf
new file mode 100644
index 0000000..3aa9dd3
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo80167.rtf
@@ -0,0 +1,6 @@
+{\rtf1
+\pard\plain
+one\par
+\pard\page\par
+\pard two\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 1fe8c88..cdbb06d 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -653,6 +653,12 @@ DECLARE_RTFEXPORT_TEST(testFdo79599, "fdo79599.rtf")
CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(xRun, "CharBackColor"));
}
+DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf")
+{
+ // Problem was that after export, the page break was missing, so this was 1.
+ CPPUNIT_ASSERT_EQUAL(2, getPages());
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx
index 3415b03..9e2b6b7 100644
--- a/sw/source/filter/ww8/docxexport.hxx
+++ b/sw/source/filter/ww8/docxexport.hxx
@@ -124,6 +124,8 @@ public:
virtual bool ignoreAttributeForStyles( sal_uInt16 nWhich ) const SAL_OVERRIDE;
+ virtual bool PreferPageBreakBefore() const SAL_OVERRIDE { return false; }
+
/// Guess the script (asian/western).
virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) SAL_OVERRIDE;
diff --git a/sw/source/filter/ww8/rtfexport.hxx b/sw/source/filter/ww8/rtfexport.hxx
index aebb839..c384289 100644
--- a/sw/source/filter/ww8/rtfexport.hxx
+++ b/sw/source/filter/ww8/rtfexport.hxx
@@ -80,6 +80,11 @@ public:
return false;
}
+ virtual bool PreferPageBreakBefore() const SAL_OVERRIDE
+ {
+ return true;
+ }
+
/// Guess the script (asian/western).
virtual bool CollapseScriptsforWordOk(sal_uInt16 nScript, sal_uInt16 nWhich) SAL_OVERRIDE;
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 46c4077..d4eaa22 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -655,6 +655,9 @@ public:
/// Used to filter out attributes that can be e.g. written to .doc but not to .docx
virtual bool ignoreAttributeForStyles( sal_uInt16 /*nWhich*/ ) const { return false; }
+ /// If saving page break is preferred as a paragraph attribute (yes) or as a special character (no).
+ virtual bool PreferPageBreakBefore() const = 0;
+
/// Guess the script (asian/western).
///
/// Sadly word does not have two different sizes for asian font size and
@@ -974,6 +977,8 @@ public:
/// False for WW6, true for WW8.
virtual bool SupportsUnicode() const SAL_OVERRIDE { return bWrtWW8; }
+ virtual bool PreferPageBreakBefore() const SAL_OVERRIDE { return true; }
+
virtual bool SupportsOneColumnBreak() const SAL_OVERRIDE { return false; }
virtual bool FieldsQuoted() const SAL_OVERRIDE { return false; }
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 31b9df7..4eeb176 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -3765,9 +3765,16 @@ void AttributeOutputBase::FormatBreak( const SvxFmtBreakItem& rBreak )
break;
case SVX_BREAK_PAGE_BEFORE: // PageBreak
- // From now on(fix for #i77900#) we prefer to save a page break as
- // paragraph attribute, this has to be done after the export of the
- // paragraph ( => !GetExport().bBreakBefore )
+ // From now on(fix for #i77900#) we prefer to save a page break
+ // as paragraph attribute (if the exporter is OK with that),
+ // this has to be done after the export of the paragraph ( =>
+ // !GetExport().bBreakBefore )
+ if (GetExport().PreferPageBreakBefore())
+ {
+ if (!GetExport().bBreakBefore)
+ PageBreakBefore(true);
+ break;
+ }
case SVX_BREAK_PAGE_AFTER:
case SVX_BREAK_PAGE_BOTH:
nC = msword::PageBreak;
commit 085424074d9aa250d03b66110302e061c4d4f07f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Fri Jun 27 20:31:34 2014 +0200
identation fixes
Change-Id: Ie9a95b99e1f6de65985b295076f5f89e5d99ec93
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index c2ed07c..1fe8c88 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -471,11 +471,11 @@ DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf")
DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf")
{
CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
- getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL"));
+ getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL"));
CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
- getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL"));
+ getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL"));
CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
- getProperty<OUString>(getRun(getParagraph(2), 3, "\t46"), "HyperLinkURL"));
+ getProperty<OUString>(getRun(getParagraph(2), 3, "\t46"), "HyperLinkURL"));
}
DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf")
More information about the Libreoffice-commits
mailing list