diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-04-06 21:02:30 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@cib.de> | 2020-04-08 11:22:37 +0200 |
commit | f570e6618611c2ba239ff686e120d8a4508580c3 (patch) | |
tree | aad6d895d3b72ffebf5e12cf2b9aa125c153d9f4 /sw | |
parent | 01daaaca2983900ede482aa8741e82b76ca3e22b (diff) |
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@cib.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/CppunitTest_sw_core_txtnode.mk | 73 | ||||
-rw-r--r-- | sw/Module_sw.mk | 1 | ||||
-rw-r--r-- | sw/qa/core/txtnode/data/btlr-cell-chinese.doc | bin | 0 -> 38912 bytes | |||
-rw-r--r-- | sw/qa/core/txtnode/txtnode.cxx | 54 | ||||
-rw-r--r-- | sw/source/core/txtnode/swfont.cxx | 7 |
5 files changed, 132 insertions, 3 deletions
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 Binary files differnew file mode 100644 index 000000000000..a4a70f6779dd --- /dev/null +++ b/sw/qa/core/txtnode/data/btlr-cell-chinese.doc 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); } } |