[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2018-09-04 Thread Libreoffice Gerrit user
 sw/qa/extras/ooxmlexport/data/tdf119143.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |   42 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   18 +++
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |5 ++
 writerfilter/source/ooxml/model.xml   |   24 ++
 5 files changed, 89 insertions(+)

New commits:
commit 348a1e11045ca8d9dbceab43a68d44dbde3f922c
Author: Mike Kaganski 
AuthorDate: Mon Aug 27 12:34:12 2018 +0300
Commit: Aron Budea 
CommitDate: Tue Sep 4 16:02:20 2018 +0200

tdf#119143: introduce tentative directional embedding import support

ECMA-376-1:2016 states that w:dir is functionally equivalent to LRE/RLE+PDF
pair around the enclosed runs. So this patch does just that.

Change-Id: Ibf9775338cc38a3bbc38a42a33fc64ae787b478f
Reviewed-on: https://gerrit.libreoffice.org/59643
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/59672
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf119143.docx 
b/sw/qa/extras/ooxmlexport/data/tdf119143.docx
new file mode 100644
index ..be0bc03f71c1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf119143.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 079fadcca914..7e6b07bde3ec 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -733,6 +733,48 @@ DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx")
  getProperty(getShape(1), "RelativeWidth"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf119143, "tdf119143.docx")
+{
+const char sParaTextExpected[] =
+"\xD8\xB9\xD9\x86\xD8\xAF\xD9\x85\xD8\xA7 
\xD9\x8A\xD8\xB1\xD9\x8A\xD8\xAF \xD8\xA7\xD9\x84"
+"\xD8\xB9\xD8\xA7\xD9\x84\xD9\x85 \xD8\xA3\xD9\x86 
\xD9\x8A\xD8\xAA\xD9\x83\xD9\x84\xD9\x91"
+"\xD9\x85 \xE2\x80\xAC \xD8\x8C \xD9\x81\xD9\x87\xD9\x88 
\xD9\x8A\xD8\xAA\xD8\xAD\xD8\xAF"
+"\xD9\x91\xD8\xAB \xD8\xA8\xD9\x84\xD8\xBA\xD8\xA9 
\xD9\x8A\xD9\x88\xD9\x86\xD9\x8A\xD9\x83"
+"\xD9\x88\xD8\xAF. \xD8\xAA\xD8\xB3\xD8\xAC\xD9\x91\xD9\x84 
\xD8\xA7\xD9\x84\xD8\xA2\xD9"
+"\x86 \xD9\x84\xD8\xAD\xD8\xB6\xD9\x88\xD8\xB1 
\xD8\xA7\xD9\x84\xD9\x85\xD8\xA4\xD8\xAA\xD9"
+"\x85\xD8\xB1 \xD8\xA7\xD9\x84\xD8\xAF\xD9\x88\xD9\x84\xD9\x8A 
\xD8\xA7\xD9\x84\xD8\xB9\xD8"
+"\xA7\xD8\xB4\xD8\xB1 
\xD9\x84\xD9\x8A\xD9\x88\xD9\x86\xD9\x8A\xD9\x83\xD9\x88\xD8\xAF (Uni"
+"code Conference)\xD8\x8C \xD8\xA7\xD9\x84\xD8\xB0\xD9\x8A 
\xD8\xB3\xD9\x8A\xD8\xB9\xD9\x82"
+"\xD8\xAF \xD9\x81\xD9\x8A 10-12 \xD8\xA2\xD8\xB0\xD8\xA7\xD8\xB1 1997 
\xD8\xA8\xD9\x85\xD8"
+"\xAF\xD9\x8A\xD9\x86\xD8\xA9 
\xD9\x85\xD9\x8E\xD8\xA7\xD9\x8A\xD9\x90\xD9\x86\xD9\x92\xD8"
+"\xAA\xD9\x92\xD8\xB3\xD8\x8C 
\xD8\xA3\xD9\x84\xD9\x85\xD8\xA7\xD9\x86\xD9\x8A\xD8\xA7. "
+"\xD9\x88 \xD8\xB3\xD9\x8A\xD8\xAC\xD9\x85\xD8\xB9 
\xD8\xA7\xD9\x84\xD9\x85\xD8\xA4\xD8\xAA"
+"\xD9\x85\xD8\xB1 \xD8\xA8\xD9\x8A\xD9\x86 
\xD8\xAE\xD8\xA8\xD8\xB1\xD8\xA7\xD8\xA1 \xD9"
+"\x85\xD9\x86 \xD9\x83\xD8\xA7\xD9\x81\xD8\xA9 
\xD9\x82\xD8\xB7\xD8\xA7\xD8\xB9\xD8\xA7\xD8"
+"\xAA \xD8\xA7\xD9\x84\xD8\xB5\xD9\x86\xD8\xA7\xD8\xB9\xD8\xA9 
\xD8\xB9\xD9\x84\xD9\x89 "
+"\xD8\xA7\xD9\x84\xD8\xB4\xD8\xA8\xD9\x83\xD8\xA9 
\xD8\xA7\xD9\x84\xD8\xB9\xD8\xA7\xD9\x84"
+"\xD9\x85\xD9\x8A\xD8\xA9 
\xD8\xA7\xD9\x86\xD8\xAA\xD8\xB1\xD9\x86\xD9\x8A\xD8\xAA \xD9\x88"
+"\xD9\x8A\xD9\x88\xD9\x86\xD9\x8A\xD9\x83\xD9\x88\xD8\xAF\xD8\x8C 
\xD8\xAD\xD9\x8A\xD8\xAB "
+"\xD8\xB3\xD8\xAA\xD8\xAA\xD9\x85\xD8\x8C \xD8\xB9\xD9\x84\xD9\x89 
\xD8\xA7\xD9\x84\xD8\xB5"
+"\xD8\xB9\xD9\x8A\xD8\xAF\xD9\x8A\xD9\x86 
\xD8\xA7\xD9\x84\xD8\xAF\xD9\x88\xD9\x84\xD9\x8A "
+"\xD9\x88\xD8\xA7\xD9\x84\xD9\x85\xD8\xAD\xD9\x84\xD9\x8A 
\xD8\xB9\xD9\x84\xD9\x89 \xD8\xAD"
+"\xD8\xAF \xD8\xB3\xD9\x88\xD8\xA7\xD8\xA1 
\xD9\x85\xD9\x86\xD8\xA7\xD9\x82\xD8\xB4\xD8\xA9"
+" \xD8\xB3\xD8\xA8\xD9\x84 
\xD8\xA7\xD8\xB3\xD8\xAA\xD8\xAE\xD8\xAF\xD8\xA7\xD9\x85 \xD9"
+"\x8A\xD9\x88\xD9\x86\xD9\x83\xD9\x88\xD8\xAF \xD9\x81\xD9\x8A 
\xD8\xA7\xD9\x84\xD9\x86\xD8"
+"\xB8\xD9\x85 \xD8\xA7\xD9\x84\xD9\x82\xD8\xA7\xD8\xA6\xD9\x85\xD8\xA9 
\xD9\x88\xD9\x81\xD9"
+"\x8A\xD9\x85\xD8\xA7 \xD9\x8A\xD8\xAE\xD8\xB5 
\xD8\xA7\xD9\x84\xD8\xAA\xD8\xB7\xD8\xA8\xD9"
+"\x8A\xD9\x82\xD8\xA7\xD8\xAA 
\xD8\xA7\xD9\x84\xD8\xAD\xD8\xA7\xD8\xB3\xD9\x88\xD8\xA8\xD9"
+"\x8A\xD8\xA9\xD8\x8C 
\xD8\xA7\xD9\x84\xD8\xAE\xD8\xB7\xD9\x88\xD8\xB7\xD8\x8C \xD8\xAA\xD8"
+"\xB5\xD9\x85\xD9\x8A\xD9\x85 
\xD8\xA7\xD9\x84\xD9\x86\xD8\xB5\xD9\x88\xD8\xB5 \xD9\x88\xD8"
+"\xA7\xD9\x84\xD8\xAD\xD9\x88\xD8\xB3\xD8\xA8\xD8\xA9 
\xD9\x85\xD8\xAA\xD8\xB9\xD8\xAF\xD8"
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2018-05-22 Thread Miklos Vajna
 sw/qa/extras/ooxmlexport/data/tdf116976.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |7 +++
 writerfilter/source/dmapper/GraphicImport.cxx |   10 --
 3 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit e6f39221b5ce652c78cc675c8dd0a662332ecacc
Author: Miklos Vajna 
Date:   Thu Apr 12 18:39:36 2018 +0200

tdf#116976 DOCX import: fix rel size of shape after bitmap

We have a queue of these odd relative sizes (which are not XML
attributes but text inside the XML element), if the bitmap doesn't pop
the queue, the following shape won't get its size.

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx

Change-Id: I1602208c9509d8889bf0be254f3b25fb25fafca2
Reviewed-on: https://gerrit.libreoffice.org/54669
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf116976.docx 
b/sw/qa/extras/ooxmlexport/data/tdf116976.docx
new file mode 100644
index ..70492a4af2f3
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf116976.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index ddcce371d885..079fadcca914 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -726,6 +726,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf115861, "tdf115861.docx")
 CPPUNIT_ASSERT_EQUAL(OUString("(k)"), getParagraph(2)->getString());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf116976, "tdf116976.docx")
+{
+// This was 0, reltive size of shape after bitmap was ignored.
+CPPUNIT_ASSERT_EQUAL(static_cast(40),
+ getProperty(getShape(1), "RelativeWidth"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index 5044454ddaef..5ae59defc618 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -1087,10 +1087,12 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
 break;
 case NS_ooxml::LN_CT_SizeRelH_pctWidth:
 case NS_ooxml::LN_CT_SizeRelV_pctHeight:
-if (m_xShape.is() && !m_pImpl->m_rPositivePercentages.empty())
+if (m_pImpl->m_rPositivePercentages.empty())
+break;
+
+if (m_xShape.is())
 {
 sal_Int16 nPositivePercentage = 
rtl::math::round(m_pImpl->m_rPositivePercentages.front().toDouble() / 
oox::drawingml::PER_PERCENT);
-m_pImpl->m_rPositivePercentages.pop();
 
 if (nPositivePercentage)
 {
@@ -1099,6 +1101,10 @@ void GraphicImport::lcl_sprm(Sprm& rSprm)
 xPropertySet->setPropertyValue(aProperty, 
uno::makeAny(nPositivePercentage));
 }
 }
+
+// Make sure the token is consumed even if xShape is an empty
+// reference.
+m_pImpl->m_rPositivePercentages.pop();
 break;
 case NS_ooxml::LN_EG_WrapType_wrapNone: // 90944; - doesn't contain 
attributes
 //depending on the behindDoc attribute text wraps through behind 
or in fron of the object
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2018-04-03 Thread Mike Kaganski
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx|   16 
 sw/qa/extras/rtfimport/rtfimport.cxx |   16 ++--
 writerfilter/source/dmapper/ConversionHelper.cxx |9 +
 3 files changed, 23 insertions(+), 18 deletions(-)

New commits:
commit 3a53fe4456f72dd57640b5bb33c5f08da96069f7
Author: Mike Kaganski 
Date:   Mon Mar 19 00:11:33 2018 +0300

tdf#116472: import "auto" border color as black

Since commit fe6da2feb57c3d5e355a36f6b8ac09b48412ff39, "auto" color is
supported in OOXML import.

Since ODF doesn't support "auto" color as border color, just convert
"auto" border color to black on import, like is done in GetLineIndex
in ww8par6.cxx.

Incidentally, this also fixes a problem in RTF import, where we used to
import black borders ("\red0\green0\blue0;" entries in color table) as
0x01 ("\red0\green0\blue1;") - see fixed tests in rtfimport.cxx.

Change-Id: I4f5e720d215b51c8a43dc7c58f338741bd608efc
Reviewed-on: https://gerrit.libreoffice.org/51519
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/51585
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/52272
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index fb5fcfba122d..779d210259da 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -654,43 +654,43 @@ DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx")
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:val
 = 'single']",1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:sz
 = 4]", 1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:space
 = 0]", 1);
-assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:color
 = 'auto']", 1);
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:color
 = '00']", 1);
 
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:val
 = 'single']",1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:sz
 = 4]", 1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:space
 = 0]", 1);
-assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:color
 = 'auto']", 1);
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:color
 = '00']", 1);
 
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:val
 = 'single']",1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:sz
 = 4]", 1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:space
 = 0]", 1);
-assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:color
 = 'auto']", 1);
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:color
 = '00']", 1);
 
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:val
 = 'single']",1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:sz
 = 4]", 1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:space
 = 0]", 1);
-assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:color
 = 'auto']", 1);
+assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:color
 = '00']", 1);
 
 //Table Cell Borders
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val
 = 'single']",1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:sz
 = 4]", 1);
 assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:space
 = 0]", 1);
-assertXPath(pXmlDocument, 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2018-03-23 Thread Miklos Vajna
 sw/qa/extras/ooxmlexport/data/tdf115861.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |7 +++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |6 ++
 writerfilter/source/dmapper/util.cxx  |   14 +-
 4 files changed, 26 insertions(+), 1 deletion(-)

New commits:
commit 01d1fdf8a348013eb6fc4cda61d3225a81681dd5
Author: Miklos Vajna 
Date:   Mon Mar 5 22:09:39 2018 +0100

tdf#115861 DOCX import: avoid last-paragraph removal when discarding footer

Discarding header/footer is necessary when the document or section
settings request to ignore first or even headers/footers. In the bugdoc
case settings.xml didn't opt-in for different even/odd footers, but
there was an even footer to be ignored.

Handle this state at two more places, so we don't end up in a situation
where we ignore the footer but not its "remove last (empty) paragraph at
the end of the footer" action.

Also make the debug dumper for text ranges more robust to have a working
token dump when we try to get the string for a table.

(cherry picked from commit 49cf733effc56c09c5e2eb023120c2d3532b5b3d)

Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx

Change-Id: I6395f37aa40c42304e2c918d87dadecb21e9d378
Reviewed-on: https://gerrit.libreoffice.org/51763
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf115861.docx 
b/sw/qa/extras/ooxmlexport/data/tdf115861.docx
new file mode 100644
index ..f42a7bad2cfa
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf115861.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index d1327a5216fb..fba031390ecc 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -709,6 +709,13 @@ DECLARE_OOXMLEXPORT_TEST(testTdf112118_DOCX, 
"tdf112118.docx")
 }
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf115861, "tdf115861.docx")
+{
+// Second item in the paragraph enumeration was a table, 2nd paragraph was
+// lost.
+CPPUNIT_ASSERT_EQUAL(OUString("(k)"), getParagraph(2)->getString());
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 3e555e650d7f..858e02069d5a 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -392,6 +392,9 @@ void DomainMapper_Impl::AddDummyParaForTableInSection()
 
 void DomainMapper_Impl::RemoveLastParagraph( )
 {
+if (m_bDiscardHeaderFooter)
+return;
+
 if (m_aTextAppendStack.empty())
 return;
 uno::Reference< text::XTextAppend > xTextAppend = 
m_aTextAppendStack.top().xTextAppend;
@@ -1039,6 +1042,9 @@ void DomainMapper_Impl::CheckUnregisteredFrameConversion( 
)
 
 void DomainMapper_Impl::finishParagraph( const PropertyMapPtr& pPropertyMap )
 {
+if (m_bDiscardHeaderFooter)
+return;
+
 #ifdef DEBUG_WRITERFILTER
 TagLogger::getInstance().startElement("finishParagraph");
 #endif
diff --git a/writerfilter/source/dmapper/util.cxx 
b/writerfilter/source/dmapper/util.cxx
index 7886bba5c684..f0549fb48d3a 100644
--- a/writerfilter/source/dmapper/util.cxx
+++ b/writerfilter/source/dmapper/util.cxx
@@ -35,7 +35,19 @@ std::string XTextRangeToString(uno::Reference< 
text::XTextRange > const & textRa
 #ifdef DEBUG_WRITERFILTER
 if (textRange.get())
 {
-OUString aOUStr = textRange->getString();
+OUString aOUStr;
+
+try
+{
+aOUStr = textRange->getString();
+}
+catch (const uno::Exception& rException)
+{
+result += "(exception: ";
+result += rException.Message.toUtf8().getStr();
+result += ")";
+}
+
 OString aOStr(aOUStr.getStr(), aOUStr.getLength(),  
RTL_TEXTENCODING_ASCII_US );
 
 result = aOStr.getStr();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2018-02-07 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf114217.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |8 
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |5 -
 writerfilter/source/dmapper/DomainMapper_Impl.hxx|6 --
 writerfilter/source/dmapper/PropertyMap.cxx  |5 +
 5 files changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 561f2a32966ff68bdf0d30a33b90fe95ee7e48cb
Author: Mike Kaganski 
Date:   Wed Feb 7 01:03:32 2018 +0300

tdf#114217: Consider relative width when importing floating table

Unit test included

Change-Id: I8e3338d7df431bd016caa4e06e684fbd189127c4
Reviewed-on: https://gerrit.libreoffice.org/49324
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/49335
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf114217.docx 
b/sw/qa/extras/ooxmlimport/data/tdf114217.docx
new file mode 100644
index ..49f1ce164cbe
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf114217.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a45d1c8469e3..b8920caf2976 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1587,6 +1587,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx")
 getCell(innerTable, "A1", "[outer:A2]\n[inner:A1]");
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf114217, "tdf114217.docx")
+{
+uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+// This was 1, multi-page table was imported as a floating one.
+CPPUNIT_ASSERT_EQUAL(static_cast(0), xDrawPage->getCount());
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 4c8365f0ad6f..a872ecb16c6a 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -1136,8 +1136,11 @@ void DomainMapperTableHandler::endTable(unsigned int 
nestedTableLevel, bool bTab
 // table is not in the body text.
 sal_Int32 nTableWidth = 0;
 m_aTableProperties->getValue(TablePropertyMap::TABLE_WIDTH, 
nTableWidth);
+sal_Int32 nTableWidthType = text::SizeType::FIX;
+m_aTableProperties->getValue(TablePropertyMap::TABLE_WIDTH_TYPE, 
nTableWidthType);
 if (m_rDMapper_Impl.GetSectionContext() && nestedTableLevel <= 1 
&& !m_rDMapper_Impl.IsInHeaderFooter())
-
m_rDMapper_Impl.m_aPendingFloatingTables.push_back(FloatingTableInfo(xStart, 
xEnd, comphelper::containerToSequence(aFrameProperties), nTableWidth));
+m_rDMapper_Impl.m_aPendingFloatingTables.push_back(
+FloatingTableInfo(xStart, xEnd, 
comphelper::containerToSequence(aFrameProperties), nTableWidth, 
nTableWidthType));
 else
 {
 // m_xText points to the body text, get the current xText from 
m_rDMapper_Impl, in case e.g. we would be in a header.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 44a2be003c30..9d51754bd1ef 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -310,17 +310,19 @@ struct FloatingTableInfo
 css::uno::Reference m_xEnd;
 css::uno::Sequence m_aFrameProperties;
 sal_Int32 m_nTableWidth;
+sal_Int32 m_nTableWidthType;
 /// Break type of the section that contains this table.
 sal_Int32 m_nBreakType = -1;
 
 FloatingTableInfo(css::uno::Reference const& xStart,
 css::uno::Reference const& xEnd,
 const css::uno::Sequence& 
aFrameProperties,
-sal_Int32 nTableWidth)
+sal_Int32 nTableWidth, sal_Int32 nTableWidthType)
 : m_xStart(xStart),
 m_xEnd(xEnd),
 m_aFrameProperties(aFrameProperties),
-m_nTableWidth(nTableWidth)
+m_nTableWidth(nTableWidth),
+m_nTableWidthType(nTableWidthType)
 {
 }
 css::uno::Any getPropertyValue(const OUString );
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index 91528c7967ce..70d9c3fcbf32 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1074,6 +1075,10 @@ bool 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-12-18 Thread Justin Luth
 sw/qa/extras/ooxmlexport/data/tdf112352_nextPageColumns.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   11 +++
 writerfilter/source/dmapper/PropertyMap.cxx  |2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 2bdfe1355c4c571e71bd4197d5814c6e15fb8db7
Author: Justin Luth 
Date:   Tue Nov 7 09:29:30 2017 +0300

tdf#112352 ooxmlimport: ALWAYS treat 1st nextpage w/cols as cont

fix 5.4 regression from 4605bd46984125a99b0e993b71efa6edb411699f.

When there are columns, if a nextpage section doesn't contain any
other "page style" details we treat it as a continuous break,
If we don't, the column info becomes part of the style itself,
and not just a section property.

However, the very first section is troublesome - by definition it DOES
contain page style details, and so if the document starts with columns,
the default style would gain the column attribute. Usually that
results in a mess, so lets make sure that we avoid that also in
the case where headers/footers are defined.

Reviewed-on: https://gerrit.libreoffice.org/44505
Tested-by: Jenkins 
Reviewed-by: Justin Luth 
Tested-by: Justin Luth 
(cherry picked from commit afc96d263959d10e457b54a574f0829d20e99df4)

Change-Id: I7e08a9218e4304206579ed064bc92c9604d4470e
Reviewed-on: https://gerrit.libreoffice.org/46638
Reviewed-by: Justin Luth 
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf112352_nextPageColumns.docx 
b/sw/qa/extras/ooxmlexport/data/tdf112352_nextPageColumns.docx
new file mode 100644
index ..f14681dd51c2
Binary files /dev/null and 
b/sw/qa/extras/ooxmlexport/data/tdf112352_nextPageColumns.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 8d125bea4910..7fef2cd0e199 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -190,6 +190,17 @@ DECLARE_OOXMLEXPORT_TEST(testRhbz988516, "rhbz988516.docx")
 CPPUNIT_ASSERT_EQUAL( 2, getPages() );
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf112352_nextPageColumns, 
"tdf112352_nextPageColumns.docx")
+{
+uno::Reference xTextSection = getProperty< 
uno::Reference >(getParagraph(2), "TextSection");
+uno::Reference xTextColumns = getProperty< 
uno::Reference >(xTextSection, "TextColumns");
+CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xTextColumns->getColumnCount());
+
+xTextSection = getProperty< uno::Reference 
>(getParagraph(3), "TextSection");
+xTextColumns = getProperty< uno::Reference 
>(xTextSection, "TextColumns");
+CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextColumns->getColumnCount());
+}
+
 DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
 {
 xmlDocPtr pXmlDoc = parseExport("word/document.xml");
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index 6ff4d05c1476..91528c7967ce 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1223,7 +1223,7 @@ void SectionPropertyMap::CloseSectionGroup( 
DomainMapper_Impl& rDM_Impl )
 // Continuous sections usually create only a section, and not a new page 
style
 const bool bTreatAsContinuous = m_nBreakType == 
NS_ooxml::LN_Value_ST_SectionMark_nextPage
 && m_nColumnCount > 0
-&& !HasHeader(m_bTitlePage) && 
!HasFooter(m_bTitlePage)
+&& (m_bIsFirstSection || (!HasHeader( 
m_bTitlePage ) && !HasFooter( m_bTitlePage )) )
 && (m_bIsFirstSection || 
m_sFollowPageStyleName.isEmpty() || (m_sFirstPageStyleName.isEmpty() && 
m_bTitlePage));
 if(m_nBreakType == 
static_cast(NS_ooxml::LN_Value_ST_SectionMark_continuous) || 
bTreatAsContinuous)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-11-15 Thread Mike Kaganski
 sw/qa/extras/ooxmlexport/data/tdf111964.docx  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |   10 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   28 +-
 3 files changed, 37 insertions(+), 1 deletion(-)

New commits:
commit 1abb4d3469b4ca982602a199578b929cf02d3cdc
Author: Mike Kaganski 
Date:   Wed Aug 23 09:09:57 2017 +0300

tdf#111964: only trim XML whitespace

OUString::trim() uses rtl_uString_newTrim, which relies upon
rtl_ImplIsWhitespace. The latter treats as whitespaces not only
characters with values less than or equal to 32, but also Unicode
General Punctuation area Space and some Control characters. Thus,
using OUString::trim() is incorrect when the goal is to trim XML
whitespace, which is defined as one of 0x09, 0x0A, 0x0D, 0x20.

A unit test included.

Change-Id: I45a132be923a52dcd5a4c35aeecb53d423b49fec
Reviewed-on: https://gerrit.libreoffice.org/41444
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/44746
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf111964.docx 
b/sw/qa/extras/ooxmlexport/data/tdf111964.docx
new file mode 100644
index ..7cb85a1d87df
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf111964.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 313a8e3d4e3c..a7b36683f943 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -564,6 +564,16 @@ DECLARE_OOXMLEXPORT_TEST(tdf112169, "tdf112169.odt")
 // LO crashed while export because of chararacter background color handling
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf111964, "tdf111964.docx")
+{
+xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+if (!pXmlDoc)
+return;
+// Unicode spaces that are not XML whitespace must not be trimmed
+const sal_Unicode sWSReference [] { 0x2002, 0x2002, 0x2002, 0x2002, 
0x2002, 0 };
+assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[4]/w:t", 
sWSReference);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 3b39eaa1a954..388f02603f85 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -620,6 +620,32 @@ void OOXMLFastContextHandler::endTxbxContent()
 mpParserState->endTxbxContent();
 }
 
+namespace {
+// XML schema defines white space as one of four characters:
+// #x9 (tab), #xA (line feed), #xD (carriage return), and #x20 (space)
+bool IsXMLWhitespace(sal_Unicode cChar)
+{
+return cChar == 0x9 || cChar == 0xA || cChar == 0xD || cChar == 0x20;
+}
+
+OUString TrimXMLWhitespace(const OUString & sText)
+{
+sal_Int32 nTrimmedStart = 0;
+const sal_Int32 nLen = sText.getLength();
+sal_Int32 nTrimmedEnd = nLen - 1;
+while (nTrimmedStart < nLen && IsXMLWhitespace(sText[nTrimmedStart]))
+++nTrimmedStart;
+while (nTrimmedStart <= nTrimmedEnd && IsXMLWhitespace(sText[nTrimmedEnd]))
+--nTrimmedEnd;
+if ((nTrimmedStart == 0) && (nTrimmedEnd == nLen - 1))
+return sText;
+else if (nTrimmedStart > nTrimmedEnd)
+return OUString();
+else
+return sText.copy(nTrimmedStart, nTrimmedEnd-nTrimmedStart+1);
+}
+}
+
 void OOXMLFastContextHandler::text(const OUString & sText)
 {
 if (isForwardEvents())
@@ -631,7 +657,7 @@ void OOXMLFastContextHandler::text(const OUString & sText)
 // tabs are converted to spaces
 if (!IsPreserveSpace())
 {
-sNormalizedText = sNormalizedText.trim().replaceAll("\t", " ");
+sNormalizedText = 
TrimXMLWhitespace(sNormalizedText).replaceAll("\t", " ");
 }
 mpStream->utext(reinterpret_cast < const sal_uInt8 * >
 (sNormalizedText.getStr()),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-09-19 Thread Jan Holesovsky
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |7 +--
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |4 
 2 files changed, 5 insertions(+), 6 deletions(-)

New commits:
commit 8efd33127aff8d62bc2612ddc4bf97c1ef373338
Author: Jan Holesovsky 
Date:   Mon Sep 18 13:17:39 2017 +0200

Word 2013 and 2016 does not honor the  setting, let's ignore it too.

In other words, let's open documents in the non-web view even when saved 
with
.

The behavior I see in Word 2013 (and it's documented that his happens in 
2016
too) is that the setting is not a document setting any more, but user's
setting.  Ie. regardless of what is written in the file, the .docx document
opens in the Print Layout if the Word was in the Print Layout until now, and
in the Web Layout if it was that mode.

We handle the non-web layout much better than the web layout, so let's just
default to the normal layout on load.

Change-Id: Ieba7ddc280b9b79501a6b89ff21b03a86356583c
Reviewed-on: https://gerrit.libreoffice.org/42414
Tested-by: Jenkins 
Reviewed-by: Jan Holesovsky 
Reviewed-on: https://gerrit.libreoffice.org/42412
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 55f74de73635..313a8e3d4e3c 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -322,8 +322,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf99074, "tdf99074.docx")
 xModel->getCurrentController(), uno::UNO_QUERY);
 uno::Reference const xViewSettings(
 xController->getViewSettings());
-// This was false, Web Layout was ignored on import.
-CPPUNIT_ASSERT(getProperty(xViewSettings, "ShowOnlineLayout"));
+
+// The behavior changed - Word 2013 and 2016 ignore this setting on
+// import, and instead honor the user's setting.
+// Let's ignore the  too.
+CPPUNIT_ASSERT(!getProperty(xViewSettings, "ShowOnlineLayout"));
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf107104, "tdf107104.docx")
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 25751c12be4e..3e555e650d7f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -5118,10 +5118,6 @@ void DomainMapper_Impl::ApplySettingsTable()
 aViewProps.push_back(beans::PropertyValue("VisibleBottom", 
-1, uno::makeAny(sal_Int32(0)), beans::PropertyState_DIRECT_VALUE));
 aViewProps.push_back(beans::PropertyValue("ZoomType", -1, 
uno::makeAny(sal_Int16(0)), beans::PropertyState_DIRECT_VALUE));
 }
-if (m_pSettingsTable->GetView())
-{
-
aViewProps.push_back(beans::PropertyValue("ShowOnlineLayout", -1, 
uno::makeAny(m_pSettingsTable->GetView() == 
NS_ooxml::LN_Value_doc_ST_View_web), beans::PropertyState_DIRECT_VALUE));
-}
 uno::Reference xBox = 
document::IndexedPropertyValues::create(m_xComponentContext);
 xBox->insertByIndex(sal_Int32(0), 
uno::makeAny(comphelper::containerToSequence(aViewProps)));
 uno::Reference xIndexAccess(xBox, 
uno::UNO_QUERY);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-08-25 Thread Szymon Kłos
 sw/qa/extras/ooxmlexport/data/tdf109184.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   19 +++
 writerfilter/source/dmapper/CellColorHandler.cxx |2 +-
 3 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit 729a4ae3b859d97376b7c7179de5069683b45169
Author: Szymon Kłos 
Date:   Thu Aug 17 12:18:23 2017 +0200

tdf#109184 auto cell color should be transparent

Don't add color to the property map if is set to auto.
In this case white color was assumed and tables were
white instead of transparent.

Reviewed-on: https://gerrit.libreoffice.org/41255
Reviewed-by: Szymon Kłos 
Tested-by: Szymon Kłos 
(cherry picked from commit d239bf6d79e93f650a4241fcd2da0cb77c9cb95b)

Change-Id: I7f203b8f3831b86ba8de33dc57de227b3029c6d9
Reviewed-on: https://gerrit.libreoffice.org/41451
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf109184.docx 
b/sw/qa/extras/ooxmlexport/data/tdf109184.docx
new file mode 100644
index ..36e5232ae671
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf109184.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 0a0ea9f3804e..9b98417a361b 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -527,6 +527,25 @@ DECLARE_OOXMLEXPORT_TEST(testActiveXControlAtRunEnd, 
"activex_control_at_run_end
 
CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER,getProperty(xPropertySet2,"AnchorType"));
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf109184, "tdf109184.docx")
+{
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+uno::Reference xTable(xTables->getByIndex(0), 
uno::UNO_QUERY);
+
+// Before table background color was white, should be transparent (auto).
+uno::Reference xCell1(xTable->getCellByName("A1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(static_cast(-1), 
getProperty(xCell1, "BackColor"));
+
+// Cell with auto color but with 15% fill, shouldn't be transparent.
+uno::Reference xCell2(xTable->getCellByName("B1"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(static_cast(0xd8d8d8), 
getProperty(xCell2, "BackColor"));
+
+// Cell with color defined (red).
+uno::Reference xCell3(xTable->getCellByName("A2"), 
uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(static_cast(0xff), 
getProperty(xCell3, "BackColor"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx 
b/writerfilter/source/dmapper/CellColorHandler.cxx
index 47d329d245fa..6b276188c0af 100644
--- a/writerfilter/source/dmapper/CellColorHandler.cxx
+++ b/writerfilter/source/dmapper/CellColorHandler.cxx
@@ -281,7 +281,7 @@ TablePropertyMapPtr  CellColorHandler::getProperties()
 
 pPropertyMap->Insert(PROP_FILL_COLOR, uno::makeAny(nApplyColor));
 }
-else
+else if (nWW8BrushStyle || !m_bAutoFillColor)
 pPropertyMap->Insert( m_OutputFormat == Form ? PROP_BACK_COLOR
 : PROP_CHAR_BACK_COLOR, uno::makeAny( nApplyColor 
));
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-08-10 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf111550.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |   66 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   19 +
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |4 +
 writerfilter/source/ooxml/factoryimpl_ns.py   |4 +
 writerfilter/source/ooxml/model.xml   |   19 +
 6 files changed, 112 insertions(+)

New commits:
commit 81ea6ed1f837545dd787c8855683b7ce04c265a8
Author: Mike Kaganski 
Date:   Thu Jul 13 09:08:56 2017 +0300

tdf#111550: A workaround for out-of-order (in-paragraph) tbl on OOXML

Word allows  to be direct child of , which is illegal
according to ECMA-376-1:2016.

This allows for import the data in such tables (previously, this text
was simply dropped, causing dataloss) - bug-to-bug compatibility
with Word.

Change-Id: I19c17ab19915ea46685727c635476fe5df593212
Reviewed-on: https://gerrit.libreoffice.org/40909
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit 67a61e54531801645d51ad89aac30064b8c4b4e8)
Reviewed-on: https://gerrit.libreoffice.org/40949
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf111550.docx 
b/sw/qa/extras/ooxmlimport/data/tdf111550.docx
new file mode 100644
index ..6e13df351906
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf111550.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 942917f67eb8..dde5f4157910 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1523,6 +1523,72 @@ DECLARE_OOXMLIMPORT_TEST(testGroupShapeFontName, 
"groupshape-fontname.docx")
 CPPUNIT_ASSERT_EQUAL(OUString(""), 
getProperty(getRun(getParagraphOfText(1, xText), 1), 
"CharFontNameAsian"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf111550, "tdf111550.docx")
+{
+// The test document has following ill-formed structure:
+//
+//
+//...
+//
+//
+//
+//
+//[outer:A2]
+//
+//
+//
+//
+//
+//
+//
+//[inner:A1]
+//
+//
+//
+//
+//
+//
+//
+//
+//
+//
+// i.e., a  as direct child of  inside another table.
+// Word accepts that illegal OOXML, and treats it as equal to
+//
+//
+//...
+//
+//
+//
+//
+//
+//
+//
+//[outer:A2]
+//
+//
+//
+//[inner:A1]
+//
+//
+//
+//
+//
+//
+//
+//
+//
+// i.e., moves all contents of the outer paragraph into the inner table's 
first paragraph.
+
+CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
+
+uno::Reference outerTable = getParagraphOrTable(1);
+getCell(outerTable, "A1", "[outer:A1]");
+uno::Reference cellA2(getCell(outerTable, "A2"), 
uno::UNO_QUERY_THROW);
+uno::Reference innerTable = getParagraphOrTable(1, 
cellA2);
+getCell(innerTable, "A1", "[outer:A2]\n[inner:A1]");
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index bb59ed9bebdc..3b39eaa1a954 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -1614,6 +1614,25 @@ void OOXMLFastContextHandlerTextTable::lcl_endFastElement
 mpParserState->endTable();
 }
 
+// tdf#111550
+void OOXMLFastContextHandlerTextTable::start_P_Tbl()
+{
+// Normally, when one paragraph ends, and another begins,
+// in OOXMLFactory_wml::endAction handler for ,
+// pHandler->endOfParagraph() is called, which (among other things)
+// calls TableManager::setHandle() to update 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-07-28 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf109524.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |   12 
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   13 ++---
 3 files changed, 22 insertions(+), 3 deletions(-)

New commits:
commit d045fd7b5d5bbd7e2569ba1571229f4f1fc3559a
Author: Mike Kaganski 
Date:   Tue Jul 25 16:58:28 2017 +0300

tdf#109524: use 100% table width when there's no explicit width available

According to ECMA-376-1:2016 17.4.63, 17.18.87, etc, all table widths are
considered preferred, and actual table layout should be determined using an
algorithm described in 17.18.87. When w:tblLayout element is omitted, or
there is no explicit width information given, it is assumed that AutoFit 
Table
Layout should be used, i.e. using cells content to determine final widths of
table grid. In the description of the AutoFit Table Layout algorithm, it is
stated that the table width grows to hold data, but no more than page width.

As a first approach, this commit just sets table width to 100% when there's
no width data available. TODO is to implement the AutoFit Table Layout
algorithm properly.

Change-Id: I000c548eb152c70d2c6e053f4d2b1d16e8976c27
Reviewed-on: https://gerrit.libreoffice.org/40500
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit cae5dd9363b68dbabbeb2069f4aee7d057f6b5a8)
Reviewed-on: https://gerrit.libreoffice.org/40508
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf109524.docx 
b/sw/qa/extras/ooxmlimport/data/tdf109524.docx
new file mode 100644
index ..534245b8f907
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf109524.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index ce4676dcab88..8b0ad8f3b512 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1500,6 +1500,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108849, "tdf108849.docx")
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Misplaced body-level sectPr's create extra 
sections!", 2, getPages());
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf109524, "tdf109524.docx")
+{
+uno::Reference xTablesSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference 
xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+// The table should have a small width (just to hold the short text in its 
single cell).
+// Until it's correctly implemented, we assign it 100% relative width.
+// Previously, the table (without explicitly set width) had huge actual 
width
+// and extended far outside of page's right border.
+CPPUNIT_ASSERT_EQUAL(true, bool(getProperty(xTables->getByIndex(0), 
"IsWidthRelative")));
+CPPUNIT_ASSERT_EQUAL(sal_Int16(100), 
getProperty(xTables->getByIndex(0), "RelativeWidth"));
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx 
b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index 5676a3c3ce80..4c8365f0ad6f 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -325,8 +325,6 @@ TableStyleSheetEntry * 
DomainMapperTableHandler::endTableGetTableStyle(TableInfo
 //pPropMap->Insert( PROP_HORI_ORIENT, uno::makeAny( 
text::HoriOrientation::RIGHT ));
 sal_Int32 nGapHalf = 0;
 sal_Int32 nLeftMargin = 0;
-sal_Int32 nTableWidth = 0;
-sal_Int32 nTableWidthType = text::SizeType::FIX;
 
 comphelper::SequenceAsHashMap aGrabBag;
 
@@ -555,14 +553,23 @@ TableStyleSheetEntry * 
DomainMapperTableHandler::endTableGetTableStyle(TableInfo
 m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::makeAny( 
nLeftMargin - nGapHalf - rInfo.nLeftBorderDistance ));
 }
 
+sal_Int32 nTableWidth = 0;
+sal_Int32 nTableWidthType = text::SizeType::FIX;
 m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH, 
nTableWidth );
 m_aTableProperties->getValue( TablePropertyMap::TABLE_WIDTH_TYPE, 
nTableWidthType );
 if( nTableWidthType == text::SizeType::FIX )
 {
 if( nTableWidth > 0 )
 m_aTableProperties->Insert( PROP_WIDTH, uno::makeAny( 
nTableWidth ));
+else
+{
+// tdf#109524: If there is no width for the table, make it 
simply 100% by default.
+// TODO: use cell contents to evaluate width (according to 
ECMA-376-1:2016 17.18.87)
+nTableWidth = 100;
+nTableWidthType = text::SizeType::VARIABLE;
+}
 }
-else
+if (nTableWidthType != 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-07-20 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf108849.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |8 
 writerfilter/source/ooxml/model.xml  |   14 +-
 3 files changed, 21 insertions(+), 1 deletion(-)

New commits:
commit 748941df6d4d1e441c7996043ca2fef5cf706442
Author: Mike Kaganski 
Date:   Tue Jul 18 23:02:32 2017 +0300

tdf#108849: allow out-of-order sectPr

According to ISO/IEC 29500-1:2016(E) 17.6.17), the final 
must be the last child element of the body element. Also, this is
enforced in schema for CT_Body complex type (Annex A. (normative)
Schemas – W3C XML Schema, A.1 WordprocessingML, page 3866), where
sectPr is a part of , and thus *must* stay at specific
place in sequence, namely being the last element, and be at most one
instance.

However, real-life documents (generated by some third-party software)
have sectPr before other body contents. Unfortunately, MS Word seems
to allow this standards-violating content, and thus encourages
creation of non-standard documents by third-party generators.

This patch doesn't assume that current final (body-level) sectPr is
the last body element, and does not mark current paragraph as last
section's paragraph. Thus, current section (possibly started after
previous paragraph-level sectPr) is continued after final sectPr is
closed.

Change-Id: I8e88288bc6659d77d17986514b3b4fe16a5b45d9
Reviewed-on: https://gerrit.libreoffice.org/40161
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit 4b4cd502806cfc9c9cc9754b8aae18a2c2632cdc)
Reviewed-on: https://gerrit.libreoffice.org/40216
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108849.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108849.docx
new file mode 100644
index ..6f3664374cd8
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108849.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 3778c52d7a50..ce4676dcab88 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1492,6 +1492,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf109053, "tdf109053.docx")
 CPPUNIT_ASSERT_EQUAL(getPages(), 2);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108849, "tdf108849.docx")
+{
+// sectPr element that is child element of body must be the last child. 
Hovewer, Word accepts it
+// in wrong places, and we should do the same (bug-to-bug compatibility) 
without creating extra sections.
+CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Misplaced body-level sectPr's create extra 
sections!", 2, getPages());
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/ooxml/model.xml 
b/writerfilter/source/ooxml/model.xml
index a5c9a8afabc9..05a7ff6d2a70 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -13194,6 +13194,14 @@
 
 
   
+  
+
+
+
+  
+
+
+  
   
 
   
@@ -16322,7 +16330,7 @@
   
 
 
-  
+  
 
   
   
@@ -17859,6 +17867,10 @@
   
   
 
+
+  
+  
+
 
   column
   page
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-07-14 Thread Tamás Zolnai
 sw/qa/extras/ooxmlimport/data/tdf109053.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |8 
 writerfilter/source/dmapper/PropertyMap.cxx  |   23 +++
 3 files changed, 23 insertions(+), 8 deletions(-)

New commits:
commit b85c798c7f5cd85f814122c76b3bb4f13f8b54be
Author: Tamás Zolnai 
Date:   Wed Jul 12 16:07:10 2017 +0200

tdf#109053: DOCX: Multipage table is not imported properly

An other use case when converting to a "floating table" is
not a good idea. In this case we can check whether next to
the table anything fits in the text area. If not then we
can avoid floating table conversion.

Reviewed-on: https://gerrit.libreoffice.org/39811
Tested-by: Jenkins 
Reviewed-by: Tamás Zolnai 
(cherry picked from commit fc55711f01af172eb3a034454405fa941454c781)

Change-Id: I798a2f4c7a9dfe6aecbe4a73e3162b49ea5f0adc
Reviewed-on: https://gerrit.libreoffice.org/39930
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf109053.docx 
b/sw/qa/extras/ooxmlimport/data/tdf109053.docx
new file mode 100755
index ..f700c4d6a48d
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf109053.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index bdeae3b3aaac..3778c52d7a50 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1484,6 +1484,14 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108545_embeddedDocxIcon, 
"tdf108545_embeddedDocx
 CPPUNIT_ASSERT_EQUAL(embed::Aspects::MSOLE_ICON, xSupplier->getAspect());
 }
 
+
+DECLARE_OOXMLIMPORT_TEST(testTdf109053, "tdf109053.docx")
+{
+// Table was imported into a text frame which led to a one page document
+// Originally the table takes two pages, so Writer should import it 
accordingly.
+CPPUNIT_ASSERT_EQUAL(getPages(), 2);
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index 89492db7f002..9f263ab22630 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1099,21 +1099,28 @@ bool 
SectionPropertyMap::FloatingTableConversion(DomainMapper_Impl& rDM_Impl, Fl
 }
 }
 
-// If the table is wider than the text area, then don't create a fly
-// for the table: no wrapping will be performed anyway, but multi-page
-// tables will be broken.
 // It seems Word has a limit here, so that in case the table width is quite
 // close to the text area width, then it won't perform a wrapping, even in
 // case the content (e.g. an empty paragraph) would fit. The magic constant
 // here represents this limit.
-if ((nTableWidth + 469) < nTextAreaWidth)
-return true;
+const sal_Int32 nMagicNumber = 469;
 
-// If the position is relative to the edge of the page, then we always
-// create the fly.
-if (rInfo.getPropertyValue("HoriOrientRelation") == 
text::RelOrientation::PAGE_FRAME)
+// If the table's with is smaller than the text area width, text might
+// be next to the table and so it should behave as a floating table.
+if ( (nTableWidth + nMagicNumber) < nTextAreaWidth )
 return true;
 
+// If the position is relative to the edge of the page, then we need to 
check the whole
+// page width to see whether text can fit next to the table.
+if ( rInfo.getPropertyValue( "HoriOrientRelation" ) == 
text::RelOrientation::PAGE_FRAME )
+{
+// If the table is wide enough to that no text fits next to it, then 
don't create a fly
+// for the table: no wrapping will be performed anyway, but multi-page
+// tables will be broken.
+if ((nTableWidth + nMagicNumber) < (nPageWidth - 
std::min(GetLeftMargin(), GetRightMargin(
+return true;
+}
+
 // If there are columns, always create the fly, otherwise the columns would
 // restrict geometry of the table.
 if (ColumnCount() + 1 >= 2)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-07-11 Thread Miklos Vajna
 sw/qa/extras/ooxmlexport/data/tdf109063.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|8 
 writerfilter/source/dmapper/PropertyMap.cxx  |6 +-
 3 files changed, 13 insertions(+), 1 deletion(-)

New commits:
commit 40c420adf77fc6dd41306dcd1fdf2ce06b456a80
Author: Miklos Vajna 
Date:   Tue Jul 11 12:44:56 2017 +0200

tdf#109063 DOCX import: consider wrap space for multi-page floattables

Follow-up to commit 78d1f1c2835b9fae0f91ed771fc1d594c7817502 (fdo#68607
bnc#816593 DomainMapperTableHandler: don't always start a frame,
2013-09-03), turns out in case there is little space between the table
and the edge of the body area, then there is no wrapping performed in
Word, so we should not convert to floating table, either.

The limit seems to be 266 twips (mm100 unit is used in the code), and
this seems to be constant: it does not change if both the table and the
page width is changed, nor does it change when the empty paragraph to be
wrapped has a different paragraph mark size.

For the majority of the documents this means no change as usually there
is either no space available for wrapping or there is a lot more
available.

(cherry picked from commit 25445d24cfa87522ee4c47e4aa7e6e816cdc9a36)

Conflicts:
writerfilter/source/dmapper/PropertyMap.cxx

Change-Id: Ibbf7409065ba958854514f23b360be56677c8fe3
Reviewed-on: https://gerrit.libreoffice.org/39828
Reviewed-by: Tamás Zolnai 
Tested-by: Tamás Zolnai 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf109063.docx 
b/sw/qa/extras/ooxmlexport/data/tdf109063.docx
new file mode 100644
index ..70f4fe4e2f31
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf109063.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 40601461c308..fd5b1716afe3 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -90,6 +90,14 @@ DECLARE_SW_ROUNDTRIP_TEST(testBadDocm, "bad.docm", nullptr, 
DocmTest)
 CPPUNIT_ASSERT_EQUAL(OUString("MS Word 2007 XML VBA"), 
pTextDoc->GetDocShell()->GetMedium()->GetFilter()->GetName());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf109063, "tdf109063.docx")
+{
+uno::Reference xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
+uno::Reference xDrawPage = 
xDrawPageSupplier->getDrawPage();
+// This was 1, near-page-width table was imported as a TextFrame.
+CPPUNIT_ASSERT_EQUAL(static_cast(0), xDrawPage->getCount());
+}
+
 DECLARE_SW_ROUNDTRIP_TEST(testTdf108269, "tdf108269.docm", nullptr, DocmTest)
 {
 if (!mbExported)
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx 
b/writerfilter/source/dmapper/PropertyMap.cxx
index c8cf96bb1f7f..89492db7f002 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -1102,7 +1102,11 @@ bool 
SectionPropertyMap::FloatingTableConversion(DomainMapper_Impl& rDM_Impl, Fl
 // If the table is wider than the text area, then don't create a fly
 // for the table: no wrapping will be performed anyway, but multi-page
 // tables will be broken.
-if (nTableWidth < nTextAreaWidth)
+// It seems Word has a limit here, so that in case the table width is quite
+// close to the text area width, then it won't perform a wrapping, even in
+// case the content (e.g. an empty paragraph) would fit. The magic constant
+// here represents this limit.
+if ((nTableWidth + 469) < nTextAreaWidth)
 return true;
 
 // If the position is relative to the edge of the page, then we always
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-07-07 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/xml_space.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |   10 
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   37 +-
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |8 +++
 4 files changed, 53 insertions(+), 2 deletions(-)

New commits:
commit 6a3960044c609b682170f7a34612761e62746c98
Author: Mike Kaganski 
Date:   Fri Jul 7 11:33:34 2017 +0300

tdf#108995: take xml:space attribute into account

See paragraph 2.10 of XML 1.0 specification and 17.3.3.31 of ECMA-376-1:2016

Change-Id: I7f19d3b9cf2ccce88a5fa03022beeb99facc04fe
Reviewed-on: https://gerrit.libreoffice.org/39682
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit 7c1a51516aaf2767e43b393259a1ad21570df5fb)
Reviewed-on: https://gerrit.libreoffice.org/39688
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/xml_space.docx 
b/sw/qa/extras/ooxmlimport/data/xml_space.docx
new file mode 100644
index ..305c135fdd75
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/xml_space.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 767f908ab6fb..a46a09d32bf3 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1466,6 +1466,16 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108995, "xml_space.docx")
+{
+CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
+// We need to take xml:space attribute into account
+uno::Reference< text::XTextRange > paragraph = getParagraph(1);
+CPPUNIT_ASSERT_EQUAL(OUString("\tA\t\tline  with\txml:space=\"preserve\" 
\n"
+  "A  line  without xml:space"),
+ paragraph->getString());
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 84d2a65ad6e0..bb59ed9bebdc 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -627,6 +627,12 @@ void OOXMLFastContextHandler::text(const OUString & sText)
 // tdf#108806: CRLFs in XML were converted to \n before this point.
 // These must be converted to spaces before further processing.
 OUString sNormalizedText = sText.replaceAll("\n", " ");
+// tdf#108995: by default, leading and trailing white space is ignored;
+// tabs are converted to spaces
+if (!IsPreserveSpace())
+{
+sNormalizedText = sNormalizedText.trim().replaceAll("\t", " ");
+}
 mpStream->utext(reinterpret_cast < const sal_uInt8 * >
 (sNormalizedText.getStr()),
 sNormalizedText.getLength());
@@ -889,6 +895,15 @@ void OOXMLFastContextHandler::sendPropertiesToParent()
 }
 }
 
+bool OOXMLFastContextHandler::IsPreserveSpace() const
+{
+// xml:space attribute applies to all elements within the content of the 
element where it is specified,
+// unless overridden with another instance of the xml:space attribute
+if (mpParent)
+return mpParent->IsPreserveSpace();
+return false; // default value
+}
+
 /*
   class OOXMLFastContextHandlerStream
  */
@@ -896,7 +911,9 @@ void OOXMLFastContextHandler::sendPropertiesToParent()
 OOXMLFastContextHandlerStream::OOXMLFastContextHandlerStream
 (OOXMLFastContextHandler * pContext)
 : OOXMLFastContextHandler(pContext),
-  mpPropertySetAttrs(new OOXMLPropertySet)
+  mpPropertySetAttrs(new OOXMLPropertySet),
+  mbPreserveSpace(false),
+  mbPreserveSpaceSet(false)
 {
 }
 
@@ -907,7 +924,14 @@ 
OOXMLFastContextHandlerStream::~OOXMLFastContextHandlerStream()
 void OOXMLFastContextHandlerStream::newProperty(Id nId,
 const OOXMLValue::Pointer_t& 
pVal)
 {
-if (nId != 0x0)
+if (nId == NS_ooxml::LN_CT_Text_space)
+{
+// Set  value early, to allow
+// child contexts use it when dealing with strings
+mbPreserveSpace = pVal->getString() == "preserve";
+mbPreserveSpaceSet = true;
+}
+else if (nId != 0x0)
 {
 OOXMLProperty::Pointer_t pProperty(new OOXMLProperty(nId, pVal, 
OOXMLProperty::ATTRIBUTE));
 
@@ -938,6 +962,15 @@ void OOXMLFastContextHandlerStream::handleHyperlink()
 getPropertySetAttrs()->resolve(aHyperlinkHandler);
 }
 
+bool OOXMLFastContextHandlerStream::IsPreserveSpace() const
+{
+// xml:space attribute applies to all elements within the content of the 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-07-07 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf108714.docx   |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx   |4 +++-
 writerfilter/source/ooxml/OOXMLParserState.cxx |8 
 writerfilter/source/ooxml/OOXMLParserState.hxx |2 +-
 writerfilter/source/ooxml/model.xml|5 +
 5 files changed, 13 insertions(+), 6 deletions(-)

New commits:
commit 919b6958dbb1c17c060ba9a58fe245b825b271c2
Author: Mike Kaganski 
Date:   Fri Jul 7 08:38:37 2017 +0300

tdf#108714: Also support paragraph-level (line) breaks

Change-Id: Ida55015363cac3ae29b82a60a9b9a5f1b39086a2
Reviewed-on: https://gerrit.libreoffice.org/39675
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit f95f0ce163743706a3670c6e33593023c22af2ff)
Reviewed-on: https://gerrit.libreoffice.org/39677
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108714.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108714.docx
index cee4176aa8e0..69c4547960a6 100644
Binary files a/sw/qa/extras/ooxmlimport/data/tdf108714.docx and 
b/sw/qa/extras/ooxmlimport/data/tdf108714.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index ed0f0c926cf2..767f908ab6fb 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1453,8 +1453,10 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
 
 // A table with immediately following break
+// Line breaks in block and paragraph levels must be taken into account
+// Several successive out-of-place w:br's must produce required amount of 
breaks
 uno::Reference table = getParagraphOrTable(5);
-getCell(table, "A1", "Paragraph 5 in table");
+getCell(table, "A1", "\n\n\n\nParagraph 5 in table");
 breakType = getProperty(table, "BreakType");
 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, breakType);
 
diff --git a/writerfilter/source/ooxml/OOXMLParserState.cxx 
b/writerfilter/source/ooxml/OOXMLParserState.cxx
index a655488e3194..3e4d3a7bcc0a 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.cxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.cxx
@@ -214,17 +214,17 @@ void OOXMLParserState::setTableProperties(const 
OOXMLPropertySet::Pointer_t& pPr
 // tdf#108714
 void OOXMLParserState::resolvePostponedBreak(Stream & rStream)
 {
-if (mpPostponedBreak)
+for (const auto & rBreak: mvPostponedBreaks)
 {
 OOXMLBreakHandler aBreakHandler(rStream);
-mpPostponedBreak->resolve(aBreakHandler);
-mpPostponedBreak.reset();
+rBreak->resolve(aBreakHandler);
 }
+mvPostponedBreaks.clear();
 }
 
 void OOXMLParserState::setPostponedBreak(const OOXMLPropertySet::Pointer_t & 
pProps)
 {
-mpPostponedBreak = pProps;
+mvPostponedBreaks.push_back(pProps);
 }
 
 void OOXMLParserState::startTable()
diff --git a/writerfilter/source/ooxml/OOXMLParserState.hxx 
b/writerfilter/source/ooxml/OOXMLParserState.hxx
index d328b07b2835..f2895e9b9274 100644
--- a/writerfilter/source/ooxml/OOXMLParserState.hxx
+++ b/writerfilter/source/ooxml/OOXMLParserState.hxx
@@ -59,7 +59,7 @@ class OOXMLParserState final
 bool savedInCharacterGroup;
 bool savedLastParagraphInSection;
 std::vector maSavedAlternateStates;
-OOXMLPropertySet::Pointer_t mpPostponedBreak;
+std::vector mvPostponedBreaks;
 
 public:
 typedef std::shared_ptr Pointer_t;
diff --git a/writerfilter/source/ooxml/model.xml 
b/writerfilter/source/ooxml/model.xml
index 5318d7d3c819..56aff376c8f9 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -14178,6 +14178,11 @@
 
   
 
+
+
+  
+
+
   
   
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-28 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf108714.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |   19 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |8 +++
 3 files changed, 19 insertions(+), 8 deletions(-)

New commits:
commit 11a98f5bb553606d05d86a143a1e11b78a23f29f
Author: Mike Kaganski 
Date:   Wed Jun 28 10:50:28 2017 +0300

tdf#108714 follow-up: handle deferred break in character group

If an out-of-order break happens immediately after a table, then
in following paragraph group (before character group start) the
table level is > 0, and break is ignored.

Since out-of-order break only happens at top level, the following
character group necessarily designates a new paragraph group, so
it's OK to handle that at the character group level, where table
level is already updated.

Change-Id: Ic1b1bb89e12407b050c2e880ad971794311845a5
Reviewed-on: https://gerrit.libreoffice.org/39347
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit 553204015f954d20db65e6adcda68b823a8ef235)
Reviewed-on: https://gerrit.libreoffice.org/39352
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108714.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108714.docx
index e564d44a648b..cee4176aa8e0 100644
Binary files a/sw/qa/extras/ooxmlimport/data/tdf108714.docx and 
b/sw/qa/extras/ooxmlimport/data/tdf108714.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 260fabb4b690..ed0f0c926cf2 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1409,8 +1409,8 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108806, "tdf108806.docx")
 
 DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
 {
-CPPUNIT_ASSERT_EQUAL(4, getParagraphs());
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Page break is absent - we lost bug-to-bug 
compatibility with Word", 3, getPages());
+CPPUNIT_ASSERT_EQUAL(6, getParagraphs());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Page break is absent - we lost bug-to-bug 
compatibility with Word", 4, getPages());
 
 // The second (empty) paragraph must be at first page, despite the  
element was before it.
 // That's because Word treats such break as first element in first run of 
following paragraph:
@@ -1443,12 +1443,23 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108714, 
"tdf108714.docx")
 CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, breakType);
 
 paragraph = getParagraph(3);
-CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 2"), paragraph->getString());
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 3"), paragraph->getString());
 breakType = getProperty(paragraph, "BreakType");
 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
 
 paragraph = getParagraph(4);
-CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 3"), paragraph->getString());
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 4"), paragraph->getString());
+breakType = getProperty(paragraph, "BreakType");
+CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
+
+// A table with immediately following break
+uno::Reference table = getParagraphOrTable(5);
+getCell(table, "A1", "Paragraph 5 in table");
+breakType = getProperty(table, "BreakType");
+CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, breakType);
+
+paragraph = getParagraph(6);
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 6"), paragraph->getString());
 breakType = getProperty(paragraph, "BreakType");
 CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
 }
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 042998559336..84d2a65ad6e0 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -371,6 +371,10 @@ void OOXMLFastContextHandler::startCharacterGroup()
 mpParserState->setInCharacterGroup(true);
 mpParserState->resolveCharacterProperties(*mpStream);
 }
+
+// tdf#108714 : if we have a postponed break information,
+// then apply it now, before any other paragraph content.
+mpParserState->resolvePostponedBreak(*mpStream);
 }
 }
 
@@ -397,10 +401,6 @@ void OOXMLFastContextHandler::startParagraphGroup()
 {
 mpStream->startParagraphGroup();
 mpParserState->setInParagraphGroup(true);
-
-// tdf#108714 : if we have a postponed break information,
-// then apply it now, before any other paragraph content.
-mpParserState->resolvePostponedBreak(*mpStream);
 }
 }
 }
___

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-27 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf108806.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |9 +
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |9 +++--
 3 files changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 1beebea6376d9a6b4c0a854f8403799659b73bae
Author: Mike Kaganski 
Date:   Tue Jun 27 07:50:12 2017 +0300

tdf#108806: convert CRLF into space in OOXML text

Change-Id: I8e2e108a705ecdb55c096a589d83d51c48b0b83c
Reviewed-on: https://gerrit.libreoffice.org/39286
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
Reviewed-on: https://gerrit.libreoffice.org/39322
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108806.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108806.docx
new file mode 100644
index ..007b10ae6f96
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108806.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 2a22195fd17b..260fabb4b690 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1397,6 +1397,15 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
 CPPUNIT_ASSERT_EQUAL(double(20), getProperty(xRun, "CharHeight"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108806, "tdf108806.docx")
+{
+// tdf#108806:The CRLF in the text contents of XML must be converted to 
single spaces.
+CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
+uno::Reference< text::XTextRange > paragraph = getParagraph(1);
+CPPUNIT_ASSERT_EQUAL(
+OUString("First part of a line (before CRLF). Second part of the same 
line (after CRLF)."),
+paragraph->getString());
+}
 
 DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
 {
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index cd79f2c0454b..042998559336 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -623,9 +623,14 @@ void OOXMLFastContextHandler::endTxbxContent()
 void OOXMLFastContextHandler::text(const OUString & sText)
 {
 if (isForwardEvents())
+{
+// tdf#108806: CRLFs in XML were converted to \n before this point.
+// These must be converted to spaces before further processing.
+OUString sNormalizedText = sText.replaceAll("\n", " ");
 mpStream->utext(reinterpret_cast < const sal_uInt8 * >
-(sText.getStr()),
-sText.getLength());
+(sNormalizedText.getStr()),
+sNormalizedText.getLength());
+}
 }
 
 void OOXMLFastContextHandler::positionOffset(const OUString& rText)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-27 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf108714.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx  |   46 ++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   13 +
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |1 
 writerfilter/source/ooxml/OOXMLParserState.cxx|   17 ++
 writerfilter/source/ooxml/OOXMLParserState.hxx|4 +
 writerfilter/source/ooxml/factoryimpl_ns.py   |2 
 writerfilter/source/ooxml/model.xml   |   18 +++
 8 files changed, 100 insertions(+), 1 deletion(-)

New commits:
commit 304dcd15d5ea5bac750249d5688372123565f9df
Author: Mike Kaganski 
Date:   Fri Jun 23 14:48:03 2017 +0300

tdf#108714: allow  as direct child of 

LibreOffice doesn't accept  element as a child of .

ECMA-376-1:2016 17.3.3.1 describes br as element of a run content,
and points to CT_Br in §A.1.
CT_Br may appear only as part of EG_RunInnerContent.
In turn, EG_RunInnerContent may appear only inside CT_R.

So, using  outside of  produces ill-formed OOXML.
Open XML SDK 2.5 Productivity Tool for Microsoft Office confirms that,
showing OpenXmlUnknownElement error.
However, Word accepts it as direct child of . It behaves as if
the  were used as first element in first run of the following
 (thus creating page break after next paragraph).
Another Word bug that provokes third-parties to create ill-formed
documents, and requires LibreOffice to be bug-to-bug compatible.

This commit makes the following changes:
1. Registers a dedicated complex type CT_Br_OutOfOrder to handle those
unusual breaks, with corresponding handler function.
2. In the handler function, saves the gathered property set to parser
state to use later in next paragraph group handler.

This reproduces Word behaviour.

Change-Id: I5df6927e2de9266b58f87807319ad1c4977e45a7
Reviewed-on: https://gerrit.libreoffice.org/39168
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit a4a1467bc47b81ad68ecad0d5e2e163670582919)
Reviewed-on: https://gerrit.libreoffice.org/39303
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108714.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108714.docx
new file mode 100644
index ..e564d44a648b
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108714.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index ec80bb6cb561..2a22195fd17b 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1398,6 +1398,52 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
 }
 
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108714, "tdf108714.docx")
+{
+CPPUNIT_ASSERT_EQUAL(4, getParagraphs());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Page break is absent - we lost bug-to-bug 
compatibility with Word", 3, getPages());
+
+// The second (empty) paragraph must be at first page, despite the  
element was before it.
+// That's because Word treats such break as first element in first run of 
following paragraph:
+//
+//
+//
+//
+//
+//
+//
+//
+// is equal to
+//
+//
+//
+//
+//
+//
+//
+// which emits page break after that empty paragraph.
+
+uno::Reference< text::XTextRange > paragraph = getParagraph(1);
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 1"), paragraph->getString());
+style::BreakType breakType = getProperty(paragraph, 
"BreakType");
+CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, breakType);
+
+paragraph = getParagraph(2);
+CPPUNIT_ASSERT_EQUAL(OUString(), paragraph->getString());
+breakType = getProperty(paragraph, "BreakType");
+CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, breakType);
+
+paragraph = getParagraph(3);
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 2"), paragraph->getString());
+breakType = getProperty(paragraph, "BreakType");
+CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
+
+paragraph = getParagraph(4);
+CPPUNIT_ASSERT_EQUAL(OUString("Paragraph 3"), paragraph->getString());
+breakType = getProperty(paragraph, "BreakType");
+CPPUNIT_ASSERT_EQUAL(style::BreakType_PAGE_BEFORE, breakType);
+}
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index bb5ff5fa98fb..cd79f2c0454b 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -397,6 +397,10 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-23 Thread Miklos Vajna
 sw/qa/extras/ooxmlexport/data/tdf108682.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx|   11 +++
 writerfilter/source/dmapper/DomainMapper.cxx |   16 +---
 3 files changed, 24 insertions(+), 3 deletions(-)

New commits:
commit 6f93c2519940b8e0afb7c50cacf06b2addfc873b
Author: Miklos Vajna 
Date:   Thu Jun 22 13:41:30 2017 +0200

tdf#108682 DOCX import: fix  for negative values

I didn't find UI in Word to create



the equivalent markup when you set line spacing to exactly 13pt for new
documents is:



The OOXML spec and Microsoft's implementer notes ([MS-OI29500]) is also
pretty silent about what a negative value means. However, if this markup
is converted to WW8 by Word, then the WW8 LPSD structure is like this
(as presented by doc-dumper):


  
  


For the 0xfefc value the [MS-DOC] spec clearly states that means the
type of the spacing is "exactly", with the value of 0x1-0xfefc, i.e.
the same 260 twips.

Change-Id: I84b485d02dea49c610b6df2e06ccce03e1d29d21
Reviewed-on: https://gerrit.libreoffice.org/39091
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 
(cherry picked from commit f575f70b8303ba187f6989920281ff02e7a431c9)
Reviewed-on: https://gerrit.libreoffice.org/39162
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sw/qa/extras/ooxmlexport/data/tdf108682.docx 
b/sw/qa/extras/ooxmlexport/data/tdf108682.docx
new file mode 100644
index ..1364025b826c
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf108682.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 4877c57639c2..ba0e5a207d21 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -22,6 +22,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
@@ -351,6 +353,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107889, "tdf107889.docx")
 CPPUNIT_ASSERT_EQUAL(static_cast(0), xDrawPage->getCount());
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf108682, "tdf108682.docx")
+{
+auto aLineSpacing = getProperty(getParagraph(1), 
"ParaLineSpacing");
+// This was style::LineSpacingMode::PROP.
+CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::FIX, aLineSpacing.Mode);
+// 260 twips in mm100, this was a negative value.
+CPPUNIT_ASSERT_EQUAL(static_cast(459), aLineSpacing.Height);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 08c6bfd7f820..ee9f30dbf66b 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -454,9 +454,19 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
 if( sal::static_int_cast(nIntValue) == 
NS_ooxml::LN_Value_doc_ST_LineSpacingRule_auto)
 {
 m_pImpl->appendGrabBag(m_pImpl->m_aSubInteropGrabBag, 
"lineRule", "auto");
-aSpacing.Mode = style::LineSpacingMode::PROP;
-//reinterpret the already set value
-aSpacing.Height = sal_Int16( aSpacing.Height * 100 /  
ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
+if (aSpacing.Height >= 0)
+{
+aSpacing.Mode = style::LineSpacingMode::PROP;
+//reinterpret the already set value
+aSpacing.Height = sal_Int16( aSpacing.Height * 100 
/  ConversionHelper::convertTwipToMM100( nSingleLineSpacing ));
+}
+else
+{
+// Negative value still means a positive height,
+// just the mode is "exact".
+aSpacing.Mode = style::LineSpacingMode::FIX;
+aSpacing.Height *= -1;
+}
 }
 else if( sal::static_int_cast(nIntValue) == 
NS_ooxml::LN_Value_doc_ST_LineSpacingRule_atLeast)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-22 Thread Szymon Kłos
 sw/qa/extras/rtfimport/data/watermark.rtf   |  407 
 sw/qa/extras/rtfimport/rtfimport.cxx|   10 
 writerfilter/source/rtftok/rtfsdrimport.cxx |2 
 3 files changed, 419 insertions(+)

New commits:
commit e5a9450eef1bcd52b84b9a9d81d6ff430a992f23
Author: Szymon Kłos 
Date:   Fri Jun 16 14:54:35 2017 +0200

Watermark: auto size in the RTF

When Watermark size is set to Auto in the MSO,
the saved value is equal 1pt. Before this patch
in this case Watermark was invisible due to small size.

Change-Id: Ia2028a6547cf98dd31031305bcc5375625b83fe0
Reviewed-on: https://gerrit.libreoffice.org/38883
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/sw/qa/extras/rtfimport/data/watermark.rtf 
b/sw/qa/extras/rtfimport/data/watermark.rtf
new file mode 100644
index ..922032593a2a
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/watermark.rtf
@@ -0,0 +1,407 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch0\stshfloch31506\stshfhich31506\stshfbi31506\deflang1033\deflangfe1033\themelang2057\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi
 \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New 
Roman;}{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times 
New Roman;}
+{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi 
\froman\fcharset0\fprq2 Cambria;}{\fbimajor\f31503\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 
02020603050405020304}Times New Roman;}{\fdbminor\f31505\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
+{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 
020f0502020204030204}Calibri;}{\fbiminor\f31507\fbidi 
\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New 
Roman;}{\f426\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}
+{\f427\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\f429\fbidi 
\froman\fcharset161\fprq2 Times New Roman Greek;}{\f430\fbidi 
\froman\fcharset162\fprq2 Times New Roman Tur;}{\f431\fbidi 
\froman\fcharset177\fprq2 Times New Roman (Hebrew);}
+{\f432\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f433\fbidi 
\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f434\fbidi 
\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}
+{\f426\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f427\fbidi 
\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f429\fbidi 
\froman\fcharset161\fprq2 Times New Roman Greek;}{\f430\fbidi 
\froman\fcharset162\fprq2 Times New Roman Tur;}
+{\f431\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f432\fbidi 
\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f433\fbidi 
\froman\fcharset186\fprq2 Times New Roman Baltic;}
+{\f434\fbidi \froman\fcharset163\fprq2 Times New Roman 
(Vietnamese);}{\f796\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\f797\fbidi 
\fswiss\fcharset204\fprq2 Calibri Cyr;}{\f799\fbidi \fswiss\fcharset161\fprq2 
Calibri Greek;}
+{\f800\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\f803\fbidi 
\fswiss\fcharset186\fprq2 Calibri Baltic;}{\f804\fbidi 
\fswiss\fcharset163\fprq2 Calibri (Vietnamese);}{\flomajor\f31508\fbidi 
\froman\fcharset238\fprq2 Times New Roman CE;}
+{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman 
Cyr;}{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman 
Greek;}{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}
+{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman 
(Hebrew);}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman 
(Arabic);}{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman 
Baltic;}
+{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman 
(Vietnamese);}{\fdbmajor\f31518\fbidi \froman\fcharset238\fprq2 Times New Roman 
CE;}{\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}
+{\fdbmajor\f31521\fbidi \froman\fcharset161\fprq2 Times New Roman 
Greek;}{\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2 Times New Roman 
Tur;}{\fdbmajor\f31523\fbidi \froman\fcharset177\fprq2 Times New Roman 
(Hebrew);}
+{\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman 
(Arabic);}{\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2 Times New Roman 
Baltic;}{\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman 
(Vietnamese);}
+{\fhimajor\f31528\fbidi \froman\fcharset238\fprq2 Cambria 
CE;}{\fhimajor\f31529\fbidi \froman\fcharset204\fprq2 Cambria 
Cyr;}{\fhimajor\f31531\fbidi \froman\fcharset161\fprq2 Cambria 
Greek;}{\fhimajor\f31532\fbidi 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-09 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/data/tdf108408.docx   |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx   |9 +
 writerfilter/source/ooxml/OOXMLFactory.cxx |   13 ++-
 writerfilter/source/ooxml/OOXMLFactory.hxx |3 +
 writerfilter/source/ooxml/OOXMLPropertySet.cxx |   41 +++--
 writerfilter/source/ooxml/OOXMLPropertySet.hxx |   24 --
 writerfilter/source/ooxml/factoryimpl.py   |2 -
 writerfilter/source/ooxml/model.xml|8 ++--
 8 files changed, 79 insertions(+), 21 deletions(-)

New commits:
commit a6c0b1a2b7c8d29bf3561fff472a4b5684e4967b
Author: Mike Kaganski 
Date:   Thu Jun 8 11:55:18 2017 +0300

tdf#108408: support unit specifications for ST_HpsMeasure

w:ST_HpsMeasure is defined in ECMA-376 5th ed. Part 1, 17.18.42 as

  This simple type specifies that its contents contain either:
  * A positive whole number, whose contents consist of a measurement in
half-points (equivalent to 1/144th of an inch), or
  * A positive decimal number immediately followed by a unit identifier.
  ...
  This simple type is a union of the following types:
  * The ST_PositiveUniversalMeasure simple type (§22.9.2.12).
  * The ST_UnsignedDecimalNumber simple type (§22.9.2.16).

This patch generalizes OOXMLUniversalMeasureValue to handle standard-
defined units, and introduces two typedefed specifications:
OOXMLTwipsMeasureValue (which is used where UniversalMeasure was
previously used), and new OOXMLHpsMeasureValue.

Unit test included.

Reviewed-on: https://gerrit.libreoffice.org/38562
Tested-by: Jenkins 
Reviewed-by: Mike Kaganski 
(cherry picked from commit ea890b1d4bcd6dd59db9f52dce1609c020804e24)

Change-Id: Iccc6d46f717cb618381baf89dfd3e4bbb844b4af
Reviewed-on: https://gerrit.libreoffice.org/38591
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/data/tdf108408.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108408.docx
new file mode 100644
index ..dcd1ecf8bd2e
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108408.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4d027678f098..ec80bb6cb561 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1388,6 +1388,15 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108350, "tdf108350.docx")
 CPPUNIT_ASSERT_EQUAL(double(11), getProperty(xRun, "CharHeight"));
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108408, "tdf108408.docx")
+{
+// Font size must consider units specifications; previously ignored and 
only used
+// integer part as half-pt size, i.e. 10 pt (20 half-pt) instead of 20 pt
+uno::Reference xPara(getParagraph(1));
+uno::Reference xRun(getRun(xPara, 1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(double(20), getProperty(xRun, "CharHeight"));
+}
+
 
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
diff --git a/writerfilter/source/ooxml/OOXMLFactory.cxx 
b/writerfilter/source/ooxml/OOXMLFactory.cxx
index 4227ae21aa07..b30b8adf3dba 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.cxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.cxx
@@ -98,15 +98,24 @@ void OOXMLFactory::attributes(OOXMLFastContextHandler * 
pHandler,
 pFactory->attributeAction(pHandler, nToken, xValue);
 }
 break;
-case RT_UniversalMeasure:
+case RT_TwipsMeasure:
 {
 const char *pValue = "";
 pAttribs->getAsChar(nToken, pValue);
-OOXMLValue::Pointer_t xValue(new 
OOXMLUniversalMeasureValue(pValue));
+OOXMLValue::Pointer_t xValue(new 
OOXMLTwipsMeasureValue(pValue));
 pHandler->newProperty(nId, xValue);
 pFactory->attributeAction(pHandler, nToken, xValue);
 }
 break;
+case RT_HpsMeasure:
+{
+const char *pValue = "";
+pAttribs->getAsChar(nToken, pValue);
+OOXMLValue::Pointer_t xValue(new OOXMLHpsMeasureValue(pValue));
+pHandler->newProperty(nId, xValue);
+pFactory->attributeAction(pHandler, nToken, xValue);
+}
+break;
 case RT_List:
 {
 sal_uInt32 nValue;
diff --git a/writerfilter/source/ooxml/OOXMLFactory.hxx 
b/writerfilter/source/ooxml/OOXMLFactory.hxx
index e1f7a63c6c66..1527be15c0d6 100644
--- a/writerfilter/source/ooxml/OOXMLFactory.hxx
+++ b/writerfilter/source/ooxml/OOXMLFactory.hxx
@@ -53,7 +53,8 @@ enum ResourceType_t {
 RT_PropertyTable,
 RT_Math,
 RT_Any,
-RT_UniversalMeasure
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-09 Thread Mike Kaganski
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |5 ++---
 writerfilter/source/dmapper/DomainMapper.cxx |8 
 2 files changed, 6 insertions(+), 7 deletions(-)

New commits:
commit 4b470b64ecc267d3c802730436ab969df5c8378a
Author: Mike Kaganski 
Date:   Tue Jun 6 16:19:31 2017 +0200

tdf#104450: Use Calibri; let LO to fallback to Carlito

Using Calibri will allow to keep originally intended font
on round-trip. If Calibri is absent on a system, LO will
fallback to Carlito for rendering, but keep original font
intact.

Reviewed-on: https://gerrit.libreoffice.org/38456
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 
(cherry picked from commit dd1ba90f6069b41e3f2c301809afefc6f63da710)

Change-Id: I8f29bed29bc7f48912b2637053ff128ea904c7a1
Reviewed-on: https://gerrit.libreoffice.org/38590
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 2111cea8e953..4d027678f098 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1381,11 +1381,10 @@ DECLARE_OOXMLIMPORT_TEST(testTdf100072, 
"tdf100072.docx")
 
 DECLARE_OOXMLIMPORT_TEST(testTdf108350, "tdf108350.docx")
 {
-// For OOXML without explicit font information, font needs to be Carlito 
11 pt,
-// our bundled metrically compatible substitute for Calibri.
+// For OOXML without explicit font information, font needs to be Calibri 
11 pt
 uno::Reference xPara(getParagraph(1));
 uno::Reference xRun(getRun(xPara, 1), uno::UNO_QUERY);
-CPPUNIT_ASSERT_EQUAL(OUString("Carlito"), getProperty(xRun, 
"CharFontName"));
+CPPUNIT_ASSERT_EQUAL(OUString("Calibri"), getProperty(xRun, 
"CharFontName"));
 CPPUNIT_ASSERT_EQUAL(double(11), getProperty(xRun, "CharHeight"));
 }
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 860633e3fb76..08c6bfd7f820 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -136,14 +136,14 @@ DomainMapper::DomainMapper( const uno::Reference< 
uno::XComponentContext >& xCon
 
 if (eDocumentType == SourceDocumentType::OOXML) {
 // tdf#108350
-// In OOXML (i.e. Word since 2007), the default document font is 
Calibri 11 pt.
-// If a document doesn't contain font information, we should assume our
-// metric-compatible equivalent Carlito to provide best layout match.
+// In Word since version 2007, the default document font is Calibri 11 
pt.
+// If a DOCX document doesn't contain font information, we should 
assume
+// the intended font to provide best layout match.
 try
 {
 uno::Reference< beans::XPropertySet > 
xDefProps(GetTextFactory()->createInstance("com.sun.star.text.Defaults"),
 uno::UNO_QUERY_THROW);
-xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), 
css::uno::Any(OUString("Carlito")));
+xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), 
css::uno::Any(OUString("Calibri")));
 xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), 
css::uno::Any(double(11)));
 }
 catch (const uno::Exception& rException)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/qa writerfilter/source

2017-06-09 Thread Mike Kaganski
 sw/qa/extras/ooxmlexport/ooxmlexport8.cxx|4 ++--
 sw/qa/extras/ooxmlimport/data/tdf108350.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx |   11 +++
 writerfilter/source/dmapper/DomainMapper.cxx |   18 ++
 4 files changed, 31 insertions(+), 2 deletions(-)

New commits:
commit 8ebbfad8d31d75fe09c5521f70edb889ed5fa9c5
Author: Mike Kaganski 
Date:   Mon Jun 5 23:47:13 2017 +0300

tdf#108350: Use Carlito for DOCX import by default

In OOXML (i.e. Word since 2007), the default document font is Calibri
11 pt. If a document doesn't contain font information, we should assume
our metric-compatible equivalent Carlito to provide best layout match.

A unit test included.

An existing unit test (testN766487) was corrected to match the font
size that Word uses (11; was 12 which doesn't match Word's size).

Reviewed-on: https://gerrit.libreoffice.org/38421
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins 
(cherry picked from commit 5471a5585cba925bb0dcb2dc41e03ad563998166)

Change-Id: I3040f235696282dc7a124cd83fb34a6d95a29a17
Reviewed-on: https://gerrit.libreoffice.org/38589
Reviewed-by: Mike Kaganski 
Tested-by: Mike Kaganski 

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
index 0dce2c56a1a8..cdf4c8e7e826 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport8.cxx
@@ -348,7 +348,7 @@ DECLARE_OOXMLEXPORT_TEST(testN766487, "n766487.docx")
  * oPara = oParas.nextElement
  * oRuns = oPara.createEnumeration
  * oRun = oRuns.nextElement
- * xray oRun.CharHeight ' 12, was larger
+ * xray oRun.CharHeight ' 11, was larger
  * oPara = oParas.nextElement
  * xray oPara.ParaFirstLineIndent ' -635, was 0
  */
@@ -361,7 +361,7 @@ DECLARE_OOXMLEXPORT_TEST(testN766487, "n766487.docx")
 uno::Reference xPropertySet(xRunEnum->nextElement(), 
uno::UNO_QUERY);
 float fValue = 0;
 xPropertySet->getPropertyValue("CharHeight") >>= fValue;
-CPPUNIT_ASSERT_EQUAL(12.f, fValue);
+CPPUNIT_ASSERT_EQUAL(11.f, fValue);
 
 xPropertySet.set(xParaEnum->nextElement(), uno::UNO_QUERY);
 sal_Int32 nValue = 0;
diff --git a/sw/qa/extras/ooxmlimport/data/tdf108350.docx 
b/sw/qa/extras/ooxmlimport/data/tdf108350.docx
new file mode 100644
index ..b62b3e127838
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf108350.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 2e900ba0b83c..2111cea8e953 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1379,6 +1379,17 @@ DECLARE_OOXMLIMPORT_TEST(testTdf100072, "tdf100072.docx")
 CPPUNIT_ASSERT_MESSAGE("Shape line width does not match", abs(nFirstEnd - 
nSecondEnd) < 10);
 }
 
+DECLARE_OOXMLIMPORT_TEST(testTdf108350, "tdf108350.docx")
+{
+// For OOXML without explicit font information, font needs to be Carlito 
11 pt,
+// our bundled metrically compatible substitute for Calibri.
+uno::Reference xPara(getParagraph(1));
+uno::Reference xRun(getRun(xPara, 1), uno::UNO_QUERY);
+CPPUNIT_ASSERT_EQUAL(OUString("Carlito"), getProperty(xRun, 
"CharFontName"));
+CPPUNIT_ASSERT_EQUAL(double(11), getProperty(xRun, "CharHeight"));
+}
+
+
 // tests should only be added to ooxmlIMPORT *if* they fail round-tripping in 
ooxmlEXPORT
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx 
b/writerfilter/source/dmapper/DomainMapper.cxx
index 2fe1705bde61..860633e3fb76 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -134,6 +134,24 @@ DomainMapper::DomainMapper( const uno::Reference< 
uno::XComponentContext >& xCon
 SAL_WARN("writerfilter", "DomainMapper::DomainMapper: failed to 
initialize RDF metadata: " << rException.Message);
 }
 
+if (eDocumentType == SourceDocumentType::OOXML) {
+// tdf#108350
+// In OOXML (i.e. Word since 2007), the default document font is 
Calibri 11 pt.
+// If a document doesn't contain font information, we should assume our
+// metric-compatible equivalent Carlito to provide best layout match.
+try
+{
+uno::Reference< beans::XPropertySet > 
xDefProps(GetTextFactory()->createInstance("com.sun.star.text.Defaults"),
+uno::UNO_QUERY_THROW);
+xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_FONT_NAME), 
css::uno::Any(OUString("Carlito")));
+xDefProps->setPropertyValue(getPropertyName(PROP_CHAR_HEIGHT), 
css::uno::Any(double(11)));
+}
+catch (const uno::Exception& rException)
+{
+