[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/inc sw/qa sw/source writerfilter/source
Vasily Melenchuk (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jun 25 12:04:43 UTC 2020
sw/inc/IDocumentSettingAccess.hxx | 3 ++-
sw/qa/extras/ooxmlexport/data/128197_compat14.docx |binary
sw/qa/extras/ooxmlexport/data/128197_compat15.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport14.cxx | 15 +++++++++++++++
sw/source/core/doc/DocumentSettingManager.cxx | 12 ++++++++++++
sw/source/core/inc/DocumentSettingManager.hxx | 1 +
sw/source/core/text/itrform2.cxx | 10 ++++++++++
sw/source/uibase/uno/SwXDocumentSettings.cxx | 13 +++++++++++++
writerfilter/source/dmapper/SettingsTable.cxx | 8 ++++++++
9 files changed, 61 insertions(+), 1 deletion(-)
New commits:
commit 1e8c8d68dcf61a930d1521e7fd312c9e7a1b6392
Author: Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Jun 11 09:45:03 2020 +0300
Commit: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
CommitDate: Thu Jun 25 14:04:11 2020 +0200
tdf#128197: sw: different line height for DOCX with compat=14
Lines containing just a shape inline without any other text are
treated in DOCX with compatibility option 15 and 14 in a different
way: while compat=15 is layouting line exatly as LO does, in
compat=14 mode minimal line height takes into account just shape
height and not current font.
Change-Id: Id2bdab941a0bbaa9080567d736435d9e0babd490
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96080
Tested-by: Jenkins
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
(cherry picked from commit ee7b6c773eb22268fefee4bfcc10110b0bbbd8cf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97066
Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx
index 00176843b32f..737e1f8d5902 100644
--- a/sw/inc/IDocumentSettingAccess.hxx
+++ b/sw/inc/IDocumentSettingAccess.hxx
@@ -63,7 +63,8 @@ enum class DocumentSettingId
// tdf#104349 tdf#104668
MS_WORD_COMP_TRAILING_BLANKS,
-
+ // tdf#128197 MS Word in some modes can have line height based on shape height, not on font
+ MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY,
UNIX_FORCE_ZERO_EXT_LEADING,
TABS_RELATIVE_TO_INDENT,
PROTECT_FORM,
diff --git a/sw/qa/extras/ooxmlexport/data/128197_compat14.docx b/sw/qa/extras/ooxmlexport/data/128197_compat14.docx
new file mode 100644
index 000000000000..507e28396019
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/128197_compat14.docx differ
diff --git a/sw/qa/extras/ooxmlexport/data/128197_compat15.docx b/sw/qa/extras/ooxmlexport/data/128197_compat15.docx
new file mode 100644
index 000000000000..d618b117cfec
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/128197_compat15.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 781dfa872081..167c05111a51 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -74,6 +74,21 @@ DECLARE_OOXMLIMPORT_TEST(Tdf130907, "tdf130907.docx")
sal_Int16(style::ParagraphAdjust::ParagraphAdjust_RIGHT), nHOri3);
}
+CPPUNIT_TEST_FIXTURE(Test, testTdf128197)
+{
+ load(mpTestDocumentPath, "128197_compat14.docx");
+ xmlDocUniquePtr pLayout14 = parseLayoutDump();
+ sal_Int32 nHeight14 = getXPath(pLayout14, "//page[1]/body/txt[1]/infos/bounds", "height").toInt32();
+
+ load(mpTestDocumentPath, "128197_compat15.docx");
+ xmlDocUniquePtr pLayout15 = parseLayoutDump();
+ sal_Int32 nHeight15 = getXPath(pLayout15, "//page[1]/body/txt[1]/infos/bounds", "height").toInt32();
+
+ // In compat mode=14 second line has size of the shape thus entire paragraph height is smaller
+ // So nHeight14 < nHeight15
+ CPPUNIT_ASSERT_LESS(nHeight15, nHeight14);
+}
+
DECLARE_OOXMLIMPORT_TEST(testTdf123622, "tdf123622.docx")
{
uno::Reference<beans::XPropertySet> XPropsRight(getShape(1),uno::UNO_QUERY);
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index f8d2af02f521..6cc92e62daf3 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -78,6 +78,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
mbTabRelativeToIndent(true),
mbProtectForm(false), // i#78591#
mbMsWordCompTrailingBlanks(false), // tdf#104349 tdf#104668
+ mbMsWordCompMinLineHeightByFly(false),
mbInvertBorderSpacing (false),
mbCollapseEmptyCellPara(true),
mbTabAtLeftIndentForParagraphsInList(false), //#i89181#
@@ -185,6 +186,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const
case DocumentSettingId::PROTECT_FORM: return mbProtectForm;
// tdf#104349 tdf#104668
case DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS: return mbMsWordCompTrailingBlanks;
+ case DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY: return mbMsWordCompMinLineHeightByFly;
// #i89181#
case DocumentSettingId::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
case DocumentSettingId::INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
@@ -331,6 +333,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo
mbMsWordCompTrailingBlanks = value;
break;
+ case DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY:
+ mbMsWordCompMinLineHeightByFly = value;
+ break;
+
case DocumentSettingId::TABS_RELATIVE_TO_INDENT:
mbTabRelativeToIndent = value;
break;
@@ -619,6 +625,7 @@ void sw::DocumentSettingManager::ReplaceCompatibilityOptions(const DocumentSetti
mbTabRelativeToIndent = rSource.mbTabRelativeToIndent;
// No mbProtectForm
mbMsWordCompTrailingBlanks = rSource.mbMsWordCompTrailingBlanks;
+ mbMsWordCompMinLineHeightByFly = rSource.mbMsWordCompMinLineHeightByFly;
// No mbInvertBorderSpacing
mbCollapseEmptyCellPara = rSource.mbCollapseEmptyCellPara;
mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
@@ -842,6 +849,11 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const
BAD_CAST(OString::boolean(mbMsWordCompTrailingBlanks).getStr()));
xmlTextWriterEndElement(pWriter);
+ xmlTextWriterStartElement(pWriter, BAD_CAST("mbMsWordCompMinLineHeightByFly"));
+ xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
+ BAD_CAST(OString::boolean(mbMsWordCompMinLineHeightByFly).getStr()));
+ xmlTextWriterEndElement(pWriter);
+
xmlTextWriterStartElement(pWriter, BAD_CAST("mbInvertBorderSpacing"));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"),
BAD_CAST(OString::boolean(mbInvertBorderSpacing).getStr()));
diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx
index f2d8f34c8c50..ef404de0ba8b 100644
--- a/sw/source/core/inc/DocumentSettingManager.hxx
+++ b/sw/source/core/inc/DocumentSettingManager.hxx
@@ -143,6 +143,7 @@ class DocumentSettingManager :
bool mbTabRelativeToIndent : 1; // #i24363# tab stops relative to indent
bool mbProtectForm : 1;
bool mbMsWordCompTrailingBlanks : 1; // tdf#104349 tdf#104668
+ bool mbMsWordCompMinLineHeightByFly : 1;
bool mbInvertBorderSpacing : 1;
bool mbCollapseEmptyCellPara : 1;
bool mbTabAtLeftIndentForParagraphsInList; // #i89181# - see above
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx
index 17900f1a17e0..61621611fb73 100644
--- a/sw/source/core/text/itrform2.cxx
+++ b/sw/source/core/text/itrform2.cxx
@@ -327,6 +327,16 @@ void SwTextFormatter::InsertPortion( SwTextFormatInfo &rInf,
m_pCurr->Height( pPor->Height() );
if( m_pCurr->GetAscent() < pPor->GetAscent() )
m_pCurr->SetAscent( pPor->GetAscent() );
+
+ if (GetTextFrame()->GetDoc().getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY))
+ {
+ // For DOCX with compat=14 the only shape in line defines height of the line inspite of used font
+ if (pLast->IsFlyCntPortion() && pPor->IsTextPortion() && pPor->GetLen() == TextFrameIndex(0))
+ {
+ m_pCurr->SetAscent(pLast->GetAscent());
+ m_pCurr->Height(pLast->Height());
+ }
+ }
}
// Sometimes chains are constructed (e.g. by hyphenate)
diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx
index 1e6de063f472..7b94387500ac 100644
--- a/sw/source/uibase/uno/SwXDocumentSettings.cxx
+++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx
@@ -110,6 +110,7 @@ enum SwDocumentSettingsPropertyHandles
HANDLE_USE_OLD_PRINTER_METRICS,
HANDLE_PROTECT_FORM,
HANDLE_MS_WORD_COMP_TRAILING_BLANKS,
+ HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY,
HANDLE_TABS_RELATIVE_TO_INDENT,
HANDLE_RSID,
HANDLE_RSID_ROOT,
@@ -203,6 +204,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo()
{ OUString("RsidRoot"), HANDLE_RSID_ROOT, cppu::UnoType<sal_Int32>::get(), 0},
{ OUString("ProtectForm"), HANDLE_PROTECT_FORM, cppu::UnoType<bool>::get(), 0},
{ OUString("MsWordCompTrailingBlanks"), HANDLE_MS_WORD_COMP_TRAILING_BLANKS, cppu::UnoType<bool>::get(), 0 },
+ { OUString("MsWordCompMinLineHeightByFly"), HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY, cppu::UnoType<bool>::get(), 0 },
{ OUString("TabAtLeftIndentForParagraphsInList"), HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST, cppu::UnoType<bool>::get(), 0},
{ OUString("ModifyPasswordInfo"), HANDLE_MODIFYPASSWORDINFO, cppu::UnoType< cppu::UnoSequenceType<css::beans::PropertyValue> >::get(), 0},
{ OUString("MathBaselineAlignment"), HANDLE_MATH_BASELINE_ALIGNMENT, cppu::UnoType<bool>::get(), 0},
@@ -751,6 +753,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf
mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS, bTmp);
}
break;
+ case HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY:
+ {
+ bool bTmp = *o3tl::doAccess<bool>(rValue);
+ mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY, bTmp);
+ }
+ break;
case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
{
bool bTmp = *o3tl::doAccess<bool>(rValue);
@@ -1297,6 +1305,11 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf
rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS);
}
break;
+ case HANDLE_MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY:
+ {
+ rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::MS_WORD_COMP_MIN_LINE_HEIGHT_BY_FLY);
+ }
+ break;
case HANDLE_TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
{
rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST);
diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx
index 93bc03b60f75..e7af3f19e911 100644
--- a/writerfilter/source/dmapper/SettingsTable.cxx
+++ b/writerfilter/source/dmapper/SettingsTable.cxx
@@ -24,6 +24,7 @@
#include <rtl/ustring.hxx>
#include <sfx2/zoomitem.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertyState.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
@@ -731,6 +732,13 @@ void SettingsTable::ApplyProperties(uno::Reference<text::XTextDocument> const& x
{
uno::Reference< beans::XPropertySet> xDocProps( xDoc, uno::UNO_QUERY );
+ if (GetWordCompatibilityMode() <= 14)
+ {
+ uno::Reference<lang::XMultiServiceFactory> xTextFactory(xDoc, uno::UNO_QUERY_THROW);
+ uno::Reference<beans::XPropertySet> xDocumentSettings(xTextFactory->createInstance("com.sun.star.document.Settings"), uno::UNO_QUERY_THROW);
+ xDocumentSettings->setPropertyValue("MsWordCompMinLineHeightByFly", uno::makeAny(true));
+ }
+
// Show changes value
if (xDocProps.is())
{
More information about the Libreoffice-commits
mailing list