[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - sw/CppunitTest_sw_core_txtnode.mk sw/Module_sw.mk sw/qa sw/source vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 8 09:23:08 UTC 2020
sw/CppunitTest_sw_core_txtnode.mk | 73 ++++++++++++++++++++++++++
sw/Module_sw.mk | 1
sw/qa/core/txtnode/data/btlr-cell-chinese.doc |binary
sw/qa/core/txtnode/txtnode.cxx | 54 +++++++++++++++++++
sw/source/core/txtnode/swfont.cxx | 7 +-
vcl/source/gdi/mtfxmldump.cxx | 1
6 files changed, 133 insertions(+), 3 deletions(-)
New commits:
commit f570e6618611c2ba239ff686e120d8a4508580c3
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Apr 6 21:02:30 2020 +0200
Commit: Michael Stahl <michael.stahl at cib.de>
CommitDate: Wed Apr 8 11:22:37 2020 +0200
tdf#131490 sw btlr: fix handling of vertical text
Latin text goes from l->r, then t->b. If we rotate to the right, then we
get t->b, then r->l. Vertical text in vcl's Font means the individual
glyphs are painted in a way that looks "non-rotated" in the tbrl case.
btlr is not symmetric to this: if you rotate to the left, then Latin and
vertical text is handled the same way, i.e. there is no compensation at
a glyph level.
This means that as far as vcl is concerned, the Font's vertical flag has
to be true in the tbrl case, but no in the btlr one. Fix
SwFont::SetVertical() to do this, which means that rotating at a
character level or using the btlr text direction will result in the same
rendering for a one-liner text.
Regression from commit 89e5b431d468745da3a1eff14d48296107b9101b (sw btlr
writing mode: implement DOC filter, 2019-03-28).
(cherry picked from commit a8d26a0bb40c101394ded8061d1b58048153631b)
Change-Id: I2619c77a3b2597dbf9feab6c7042e8d8c7454197
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91820
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl at cib.de>
diff --git a/sw/CppunitTest_sw_core_txtnode.mk b/sw/CppunitTest_sw_core_txtnode.mk
new file mode 100644
index 000000000000..2f09165d86cb
--- /dev/null
+++ b/sw/CppunitTest_sw_core_txtnode.mk
@@ -0,0 +1,73 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,sw_core_txtnode))
+
+$(eval $(call gb_CppunitTest_use_common_precompiled_header,sw_core_txtnode))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sw_core_txtnode, \
+ sw/qa/core/txtnode/txtnode \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sw_core_txtnode, \
+ comphelper \
+ cppu \
+ cppuhelper \
+ sal \
+ sfx \
+ svxcore \
+ sw \
+ test \
+ unotest \
+ utl \
+ vcl \
+ svt \
+ tl \
+ svl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sw_core_txtnode,\
+ boost_headers \
+ libxml2 \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sw_core_txtnode,\
+ -I$(SRCDIR)/sw/inc \
+ -I$(SRCDIR)/sw/source/core/inc \
+ -I$(SRCDIR)/sw/source/uibase/inc \
+ -I$(SRCDIR)/sw/qa/inc \
+ $$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_api,sw_core_txtnode,\
+ udkapi \
+ offapi \
+ oovbaapi \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,sw_core_txtnode))
+$(eval $(call gb_CppunitTest_use_vcl,sw_core_txtnode))
+
+$(eval $(call gb_CppunitTest_use_rdb,sw_core_txtnode,services))
+
+$(eval $(call gb_CppunitTest_use_custom_headers,sw_core_txtnode,\
+ officecfg/registry \
+))
+
+$(eval $(call gb_CppunitTest_use_configuration,sw_core_txtnode))
+
+$(eval $(call gb_CppunitTest_use_uiconfigs,sw_core_txtnode, \
+ modules/swriter \
+))
+
+$(eval $(call gb_CppunitTest_use_more_fonts,sw_core_txtnode))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 470e7b545971..4784dcc64f8b 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -108,6 +108,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sw,\
CppunitTest_sw_core_doc \
CppunitTest_sw_uibase_shells \
CppunitTest_sw_core_frmedt \
+ CppunitTest_sw_core_txtnode \
))
ifneq ($(DISABLE_GUI),TRUE)
diff --git a/sw/qa/core/txtnode/data/btlr-cell-chinese.doc b/sw/qa/core/txtnode/data/btlr-cell-chinese.doc
new file mode 100644
index 000000000000..a4a70f6779dd
Binary files /dev/null and b/sw/qa/core/txtnode/data/btlr-cell-chinese.doc differ
diff --git a/sw/qa/core/txtnode/txtnode.cxx b/sw/qa/core/txtnode/txtnode.cxx
new file mode 100644
index 000000000000..b6af5230faf8
--- /dev/null
+++ b/sw/qa/core/txtnode/txtnode.cxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <swmodeltestbase.hxx>
+
+#include <comphelper/classids.hxx>
+#include <svtools/embedhlp.hxx>
+#include <svx/svdpage.hxx>
+#include <tools/globname.hxx>
+#include <unotest/bootstrapfixturebase.hxx>
+#include <vcl/gdimtf.hxx>
+
+#include <wrtsh.hxx>
+#include <fmtanchr.hxx>
+#include <IDocumentDrawModelAccess.hxx>
+#include <drawdoc.hxx>
+#include <dcontact.hxx>
+
+static char const DATA_DIRECTORY[] = "/sw/qa/core/txtnode/data/";
+
+/// Covers sw/source/core/txtnode/ fixes.
+class SwCoreTxtnodeTest : public SwModelTestBase
+{
+};
+
+CPPUNIT_TEST_FIXTURE(SwCoreTxtnodeTest, testBtlrCellChinese)
+{
+ // Load a document with a table cell, with btlr cell direction. The cell has text which is
+ // classified as vertical, i.e. the glyph has the same direction in both the lrtb ("Latin") and
+ // tbrl ("Chinese") directions. Make sure that Chinese text is handled the same way in the btlr
+ // case as it's handled in the Latin case.
+ load(DATA_DIRECTORY, "btlr-cell-chinese.doc");
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ SwDocShell* pShell = pTextDoc->GetDocShell();
+ std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+ MetafileXmlDump dumper;
+ xmlDocPtr pXmlDoc = dumpAndParse(dumper, *xMetaFile);
+ assertXPath(pXmlDoc, "//font[1]", "orientation", "900");
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: false
+ // - Actual : true
+ // i.e. the glyph was rotated further, so it was upside down.
+ assertXPath(pXmlDoc, "//font[1]", "vertical", "false");
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index 9816212aa690..7ea5bf077aab 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -446,9 +446,10 @@ void SwFont::SetVertical(sal_uInt16 nDir, const bool bVertFormat, const bool bVe
if( nDir != m_aSub[SwFontScript::Latin].GetOrientation() )
{
m_bFontChg = true;
- m_aSub[SwFontScript::Latin].SetVertical( nDir, bVertFormat );
- m_aSub[SwFontScript::CJK].SetVertical( nDir, bVertFormat );
- m_aSub[SwFontScript::CTL].SetVertical( nDir, bVertFormat );
+ bool bVertical = bVertFormat && !bVertLayoutLRBT;
+ m_aSub[SwFontScript::Latin].SetVertical(nDir, bVertical);
+ m_aSub[SwFontScript::CJK].SetVertical(nDir, bVertical);
+ m_aSub[SwFontScript::CTL].SetVertical(nDir, bVertical);
}
}
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index efc8dfc5b999..8c242bcb7c21 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -1136,6 +1136,7 @@ void MetafileXmlDump::writeXml(const GDIMetaFile& rMetaFile, tools::XmlWriter& r
rWriter.attribute("height", aFont.GetFontSize().Height());
rWriter.attribute("orientation", aFont.GetOrientation());
rWriter.attribute("weight", convertFontWeigthToString(aFont.GetWeight()));
+ rWriter.attribute("vertical", aFont.IsVertical() ? "true" : "false");
rWriter.endElement();
}
More information about the Libreoffice-commits
mailing list