Re: NEWBIE 1 Where can I find the sourcecode for the asian phonetic guide? 2 Where can I find the sourcecode for specific language packs?
Hi Ben, You may find part of Asian phonetic guide code from my past commit: https://gerrit.libreoffice.org/q/owner:marklh9+status:Merged+ruby Best regards Ben Engbers 於 2024年3月6日 週三 上午5:58寫道: > Hi, > > After following the instructions from > https://wiki.documentfoundation.org/Development/BuildingOnLinux I was > able to compile my first LO executable. > Acoording to these instructions after executing make I should find a > local installation in the PREFIX-directory. This was not correct, I had > to execute make install. > > 1 > My goal is to work on the Asiatic phonetic Guide but I can't find the > present code. Where can I find and dowload the sources? I tried grok but > that didn't help. > > 2 > Since being Dutch, I want to install the Dutch translation. Is it > possible to dowload only that langpack and not all the other translations. > > 3 > And since I also often create texts in French, German and Japanese, I > guess that I also have to install those langpacks. > > Where in the developerssite can I find all the needed materials and > instructions? > > Ben > -- Mark Hung
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/source
vcl/source/outdev/font.cxx | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) New commits: commit 6de58389343d40ea9e638423967b9a845c7ef0d9 Author: Mark Hung AuthorDate: Mon Feb 27 08:58:22 2023 +0800 Commit: Michael Stahl CommitDate: Thu Mar 16 09:21:29 2023 + tdf#114556 fix vertical writing emphasis mark position. 1. Calculate emphasis mark offset from base line using ascender + descender, so it won't be too close or even overlap with the glyph. It's an approximate for ideographic embox right or ideographic chraceter face right. 2. CJK Ideographs have different drawing base positions. Besides, it seems that glyph bound rect isn't consistent among platforms, so use glyph advance information ( pGlyph->origWidth ) to calculate proper position and center the emphasis mark along glyph advance axis. Change-Id: I93676656ed2a1b12a2237a9af94d772879eb7ff7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147748 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 9e6ff03454c2c554fc81b5f5d453a02edd5245d1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148862 Reviewed-by: Michael Stahl diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 5014800fa2c6..6e8db56e06a3 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -931,11 +931,20 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) } Point aOffset(0,0); +Point aOffsetVert(0,0); if ( nEmphasisMark & FontEmphasisMark::PosBelow ) +{ aOffset.AdjustY(mpFontInstance->mxFontMetric->GetDescent() + aEmphasisMark.GetYOffset()); +aOffsetVert = aOffset; +} else +{ aOffset.AdjustY(-(mpFontInstance->mxFontMetric->GetAscent() + aEmphasisMark.GetYOffset())); +// Todo: use ideographic em-box or ideographic character face information. +aOffsetVert.AdjustY(-(mpFontInstance->mxFontMetric->GetAscent() + +mpFontInstance->mxFontMetric->GetDescent() + aEmphasisMark.GetYOffset())); +} tools::Long nEmphasisWidth2 = aEmphasisMark.GetWidth() / 2; tools::Long nEmphasisHeight2 = nEmphasisHeight / 2; @@ -953,8 +962,18 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) if (!pGlyph->IsSpacing()) { -Point aAdjPoint = aOffset; -aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - aEmphasisMark.GetWidth()) / 2 ); +Point aAdjPoint; +if (pGlyph->IsVertical()) +{ +aAdjPoint = aOffsetVert; +aAdjPoint.AdjustX((-pGlyph->origWidth() + aEmphasisMark.GetWidth()) / 2); +} +else +{ +aAdjPoint = aOffset; +aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - aEmphasisMark.GetWidth()) / 2 ); +} + if ( mpFontInstance->mnOrientation ) { Point aOriginPt(0, 0);
[Libreoffice-commits] core.git: Changes to 'distro/lhm/libreoffice-7-5+backports'
New branch 'distro/lhm/libreoffice-7-5+backports' available with the following commits:
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - vcl/source
vcl/source/gdi/pdfwriter_impl.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f32f7d0d34cb4fcc5acd94cdf91cbd7b2f7f98ab Author: Mark Hung AuthorDate: Mon Feb 27 21:32:48 2023 +0800 Commit: Xisco Fauli CommitDate: Mon Mar 13 19:23:08 2023 + tdf#115321, tdf#139065 render emphasismark for pdf export. Fix the logical mistake: it rendered emphasis mark only for spaces - that is excatly opposite to what we want. Change-Id: Id478af269c6cf8ab9a9e1413d19f9b3a3451d59d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147916 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit f88bb22cc3cbbc35abf72ec0ce1a4c0bb60ee88c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148768 Reviewed-by: Xisco Fauli diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index b0ef56e64511..268946426990 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6909,7 +6909,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool nIndex = 0; while (rLayout.GetNextGlyph(, aPos, nIndex)) { -if (pGlyph->IsSpacing()) +if (!pGlyph->IsSpacing()) { DevicePoint aAdjOffset(aOffset.X(), aOffset.Y()); aAdjOffset.adjustX((pGlyph->newWidth() - aEmphasisMark.GetWidth()) / 2);
[Libreoffice-commits] core.git: vcl/source
vcl/source/gdi/pdfwriter_impl.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit f88bb22cc3cbbc35abf72ec0ce1a4c0bb60ee88c Author: Mark Hung AuthorDate: Mon Feb 27 21:32:48 2023 +0800 Commit: Mark Hung CommitDate: Mon Mar 13 13:10:35 2023 + tdf#115321, tdf#139065 render emphasismark for pdf export. Fix the logical mistake: it rendered emphasis mark only for spaces - that is excatly opposite to what we want. Change-Id: Id478af269c6cf8ab9a9e1413d19f9b3a3451d59d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147916 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 9a78d6908a58..65af9138cdfd 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -7001,7 +7001,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool nIndex = 0; while (rLayout.GetNextGlyph(, aPos, nIndex)) { -if (pGlyph->IsSpacing()) +if (!pGlyph->IsSpacing()) { DevicePoint aAdjOffset(aOffset.X(), aOffset.Y()); aAdjOffset.adjustX((pGlyph->newWidth() - aEmphasisMark.GetWidth()) / 2);
[Libreoffice-commits] core.git: vcl/source
vcl/source/outdev/font.cxx | 23 +-- 1 file changed, 21 insertions(+), 2 deletions(-) New commits: commit 9e6ff03454c2c554fc81b5f5d453a02edd5245d1 Author: Mark Hung AuthorDate: Mon Feb 27 08:58:22 2023 +0800 Commit: Mark Hung CommitDate: Fri Mar 10 12:42:39 2023 + tdf#114556 fix vertical writing emphasis mark position. 1. Calculate emphasis mark offset from base line using ascender + descender, so it won't be too close or even overlap with the glyph. It's an approximate for ideographic embox right or ideographic chraceter face right. 2. CJK Ideographs have different drawing base positions. Besides, it seems that glyph bound rect isn't consistent among platforms, so use glyph advance information ( pGlyph->origWidth ) to calculate proper position and center the emphasis mark along glyph advance axis. Change-Id: I93676656ed2a1b12a2237a9af94d772879eb7ff7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147748 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 5014800fa2c6..6e8db56e06a3 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -931,11 +931,20 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) } Point aOffset(0,0); +Point aOffsetVert(0,0); if ( nEmphasisMark & FontEmphasisMark::PosBelow ) +{ aOffset.AdjustY(mpFontInstance->mxFontMetric->GetDescent() + aEmphasisMark.GetYOffset()); +aOffsetVert = aOffset; +} else +{ aOffset.AdjustY(-(mpFontInstance->mxFontMetric->GetAscent() + aEmphasisMark.GetYOffset())); +// Todo: use ideographic em-box or ideographic character face information. +aOffsetVert.AdjustY(-(mpFontInstance->mxFontMetric->GetAscent() + +mpFontInstance->mxFontMetric->GetDescent() + aEmphasisMark.GetYOffset())); +} tools::Long nEmphasisWidth2 = aEmphasisMark.GetWidth() / 2; tools::Long nEmphasisHeight2 = nEmphasisHeight / 2; @@ -953,8 +962,18 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) if (!pGlyph->IsSpacing()) { -Point aAdjPoint = aOffset; -aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - aEmphasisMark.GetWidth()) / 2 ); +Point aAdjPoint; +if (pGlyph->IsVertical()) +{ +aAdjPoint = aOffsetVert; +aAdjPoint.AdjustX((-pGlyph->origWidth() + aEmphasisMark.GetWidth()) / 2); +} +else +{ +aAdjPoint = aOffset; +aAdjPoint.AdjustX(aRectangle.Left() + (aRectangle.GetWidth() - aEmphasisMark.GetWidth()) / 2 ); +} + if ( mpFontInstance->mnOrientation ) { Point aOriginPt(0, 0);
[Libreoffice-commits] core.git: sd/qa sd/source
sd/qa/unit/export-tests-ooxml3.cxx| 10 +++--- sd/source/filter/eppt/pptx-animations-nodectx.cxx | 20 +--- sd/source/filter/eppt/pptx-animations-nodectx.hxx |4 sd/source/filter/eppt/pptx-animations.cxx | 19 ++- 4 files changed, 46 insertions(+), 7 deletions(-) New commits: commit 4e6601cf1b99c1aa52934388e9cefd527389cf80 Author: Mark Hung AuthorDate: Sat Jan 28 18:39:49 2023 +0800 Commit: Noel Grandin CommitDate: Sun Jan 29 06:01:05 2023 + tdf#124230 export subTnLst for event triggered nodes. LibreOffice export all the child nodes of a timenode to childTnLst. It seems that PowerPoint anticipate there being fixed starting-time timenodes on childTnLst. This patch export event-triggered audio time nodes to subTnLst to make audio playback work. Other node types can be added in the future once more test cases are found. Change-Id: Ic96ec50876f568145bdde122d01dec10c1ac7c50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146295 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sd/qa/unit/export-tests-ooxml3.cxx b/sd/qa/unit/export-tests-ooxml3.cxx index db023bef2592..7753abe651ee 100644 --- a/sd/qa/unit/export-tests-ooxml3.cxx +++ b/sd/qa/unit/export-tests-ooxml3.cxx @@ -1113,10 +1113,14 @@ void SdOOXMLExportTest3::testTdf44223() xmlDocUniquePtr pDoc1 = parseExport("ppt/slides/slide1.xml"); +// tdf#124230 all nodes were under p:childTnLst, but event triggered nodes need +// to be under p:subTnLst, especially for audio to work correctly. // Start condition: 0s after timenode id 5 begins. -assertXPath(pDoc1, "//p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond", "evt", "begin"); -assertXPath(pDoc1, "//p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond", "delay", "0"); -assertXPath(pDoc1, "//p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond/p:tn", "val", "5"); +assertXPath(pDoc1, "//p:subTnLst/p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond", "evt", +"begin"); +assertXPath(pDoc1, "//p:subTnLst/p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond", "delay", "0"); +assertXPath(pDoc1, "//p:subTnLst/p:audio/p:cMediaNode/p:cTn/p:stCondLst/p:cond/p:tn", "val", +"5"); xmlDocUniquePtr pDoc2 = parseExport("ppt/slides/slide2.xml"); assertXPath(pDoc2, "//p:transition/p:sndAc/p:stSnd/p:snd[@r:embed]", 2); diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.cxx b/sd/source/filter/eppt/pptx-animations-nodectx.cxx index 957301a5afd8..e538a0ca4e99 100644 --- a/sd/source/filter/eppt/pptx-animations-nodectx.cxx +++ b/sd/source/filter/eppt/pptx-animations-nodectx.cxx @@ -57,10 +57,11 @@ bool IsAudioURL(const OUString& rURL) /// Returns if rURL has an extension which is a video format. bool IsVideoURL(const OUString& rURL) { return rURL.endsWithIgnoreAsciiCase(".mp4"); } -void initCondList(const Any& rAny, std::vector& rList, bool bIsMainSeqChild) +bool initCondList(const Any& rAny, std::vector& rList, bool bIsMainSeqChild) { +bool bEventTrigger = false; if (!rAny.hasValue()) -return; +return false; Sequence aCondSeq; if (rAny >>= aCondSeq) @@ -69,15 +70,24 @@ void initCondList(const Any& rAny, std::vector& rList, bool bIsMainSeqChil { Cond aCond(rCond, bIsMainSeqChild); if (aCond.isValid()) +{ rList.push_back(aCond); +if (aCond.mpEvent) +bEventTrigger = true; +} } } else { Cond aCond(rAny, bIsMainSeqChild); if (aCond.isValid()) +{ rList.push_back(aCond); +if (aCond.mpEvent) +bEventTrigger = true; +} } +return bEventTrigger; } } @@ -86,6 +96,7 @@ NodeContext::NodeContext(const Reference& xNode, bool bMainSeqCh : mxNode(xNode) , mbMainSeqChild(bMainSeqChild) , mbValid(true) +, mbOnSubTnLst(false) , mnEffectNodeType(-1) , mnEffectPresetClass(css::presentation::EffectPresetClass::CUSTOM) { @@ -95,7 +106,10 @@ NodeContext::NodeContext(const Reference& xNode, bool bMainSeqCh initValid(initChildNodes(), bIsIterateChild); -initCondList(getNodeForCondition()->getBegin(), maBeginCondList, mbMainSeqChild); +// Put event triggered Audio time nodes to SubTnLst. +// Add other types of nodes once we find more test cases. +mbOnSubTnLst = initCondList(getNodeForCondition()->getBegin(), maBeginCondList, mbMainSeqChild) + && mxNode->getType() == AnimationNodeType::AUDIO; initCondLi
[Libreoffice-commits] core.git: sd/source
sd/source/filter/eppt/pptx-animations-nodectx.cxx | 27 sd/source/filter/eppt/pptx-animations-nodectx.hxx |5 ++ sd/source/filter/eppt/pptx-animations.cxx | 47 +++--- 3 files changed, 40 insertions(+), 39 deletions(-) New commits: commit f640a0c5d295368e5c0e3247b3039054cccad7da Author: Mark Hung AuthorDate: Sat Jan 28 00:32:21 2023 +0800 Commit: Noel Grandin CommitDate: Sun Jan 29 05:59:50 2023 + sd/filter/pptx-animations: store condition in NodeContext. Change-Id: I80cc7209f5347562560590554a8aa9a61e410179 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146294 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.cxx b/sd/source/filter/eppt/pptx-animations-nodectx.cxx index 0d5cabd49343..957301a5afd8 100644 --- a/sd/source/filter/eppt/pptx-animations-nodectx.cxx +++ b/sd/source/filter/eppt/pptx-animations-nodectx.cxx @@ -56,6 +56,29 @@ bool IsAudioURL(const OUString& rURL) /// Returns if rURL has an extension which is a video format. bool IsVideoURL(const OUString& rURL) { return rURL.endsWithIgnoreAsciiCase(".mp4"); } + +void initCondList(const Any& rAny, std::vector& rList, bool bIsMainSeqChild) +{ +if (!rAny.hasValue()) +return; + +Sequence aCondSeq; +if (rAny >>= aCondSeq) +{ +for (const auto& rCond : std::as_const(aCondSeq)) +{ +Cond aCond(rCond, bIsMainSeqChild); +if (aCond.isValid()) +rList.push_back(aCond); +} +} +else +{ +Cond aCond(rAny, bIsMainSeqChild); +if (aCond.isValid()) +rList.push_back(aCond); +} +} } NodeContext::NodeContext(const Reference& xNode, bool bMainSeqChild, @@ -71,6 +94,10 @@ NodeContext::NodeContext(const Reference& xNode, bool bMainSeqCh initUserData(); initValid(initChildNodes(), bIsIterateChild); + +initCondList(getNodeForCondition()->getBegin(), maBeginCondList, mbMainSeqChild); + +initCondList(getNodeForCondition()->getEnd(), maEndCondList, mbMainSeqChild); } void NodeContext::initUserData() diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.hxx b/sd/source/filter/eppt/pptx-animations-nodectx.hxx index 46a97c5a40cc..e9f884063c2e 100644 --- a/sd/source/filter/eppt/pptx-animations-nodectx.hxx +++ b/sd/source/filter/eppt/pptx-animations-nodectx.hxx @@ -11,6 +11,7 @@ #include #include #include +#include "pptx-animations-cond.hxx" namespace oox::core { @@ -24,6 +25,8 @@ class NodeContext const bool mbMainSeqChild; std::vector maChildNodes; +std::vector maBeginCondList; +std::vector maEndCondList; // if the node has valid target or contains at least one valid target. bool mbValid; @@ -55,5 +58,7 @@ public: bool isValid() const { return mbValid; } const std::vector& getChildNodes() const { return maChildNodes; }; const css::uno::Reference& getNodeForCondition() const; +const std::vector& getBeginCondList() const { return maBeginCondList; } +const std::vector& getEndCondList() const { return maEndCondList; } }; } diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx index bfe1079885e9..0cb6a5c72319 100644 --- a/sd/source/filter/eppt/pptx-animations.cxx +++ b/sd/source/filter/eppt/pptx-animations.cxx @@ -490,9 +490,8 @@ class PPTXAnimationExport void WriteAnimationNodeMedia(); void WriteAnimationNodeCommonPropsStart(); void WriteAnimationTarget(const Any& rTarget); -void WriteAnimationCondList(const Any& rAny, sal_Int32 nToken); +void WriteAnimationCondList(const std::vector& rList, sal_Int32 nToken); void WriteAnimationCond(const Cond& rCond); -bool isMainSeqChild() const; const Reference& getCurrentNode() const; PowerPointExport& mrPowerPointExport; @@ -535,12 +534,6 @@ PPTXAnimationExport::PPTXAnimationExport(PowerPointExport& rExport, const FSHelp { } -bool PPTXAnimationExport::isMainSeqChild() const -{ -assert(mpContext); -return mpContext->isMainSeqChild(); -} - const Reference& PPTXAnimationExport::getCurrentNode() const { assert(mpContext); @@ -589,37 +582,13 @@ void PPTXAnimationExport::WriteAnimationTarget(const Any& rTarget) mpFS->endElementNS(XML_p, XML_tgtEl); } -void PPTXAnimationExport::WriteAnimationCondList(const Any& rAny, sal_Int32 nToken) +void PPTXAnimationExport::WriteAnimationCondList(const std::vector& rList, sal_Int32 nToken) { -if (!rAny.hasValue()) -return; - -std::vector aList; - -bool bIsMainSeqChild = isMainSeqChild(); - -Sequence aCondSeq; -if (rAny >>= aCondSeq) -{ -for (const auto& rCond : std::as_const(aCondSeq)) -{ -Cond aCond(rCond, bIsMa
[Libreoffice-commits] core.git: sd/Library_sd.mk sd/source
sd/Library_sd.mk |1 sd/source/filter/eppt/pptx-animations-nodectx.cxx | 188 ++ sd/source/filter/eppt/pptx-animations-nodectx.hxx | 59 ++ sd/source/filter/eppt/pptx-animations.cxx | 184 - 4 files changed, 250 insertions(+), 182 deletions(-) New commits: commit 55d4dc3a6b955e54ee73bc81807552a3b4d4a279 Author: Mark Hung AuthorDate: Fri Jan 27 23:34:49 2023 +0800 Commit: Noel Grandin CommitDate: Sat Jan 28 18:57:59 2023 + sd/pptx-anmiations refactor NodeContext. Change-Id: I6439882884b3808dec91eaaede50856b0afdd278 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146293 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 297c2bc23654..4ffb86b7d461 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -188,6 +188,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/filter/eppt/pptx-epptooxml \ sd/source/filter/eppt/pptx-animations \ sd/source/filter/eppt/pptx-animations-cond \ +sd/source/filter/eppt/pptx-animations-nodectx \ sd/source/filter/eppt/pptx-grouptable \ sd/source/filter/eppt/pptx-stylesheet \ sd/source/filter/eppt/pptx-text \ diff --git a/sd/source/filter/eppt/pptx-animations-nodectx.cxx b/sd/source/filter/eppt/pptx-animations-nodectx.cxx new file mode 100644 index ..0d5cabd49343 --- /dev/null +++ b/sd/source/filter/eppt/pptx-animations-nodectx.cxx @@ -0,0 +1,188 @@ +/* -*- 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 "pptx-animations-nodectx.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +using ::com::sun::star::beans::NamedValue; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::drawing::XShape; + +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::presentation; +using namespace ::com::sun::star::uno; + +namespace oox::core +{ +namespace +{ +bool isValidTarget(const Any& rTarget) +{ +Reference xShape; + +if ((rTarget >>= xShape) && xShape.is()) +return true; + +ParagraphTarget aParagraphTarget; + +return (rTarget >>= aParagraphTarget) && aParagraphTarget.Shape.is(); +} + +bool IsAudioURL(const OUString& rURL) +{ +return rURL.endsWithIgnoreAsciiCase(".wav") || rURL.endsWithIgnoreAsciiCase(".m4a"); +} + +/// Returns if rURL has an extension which is a video format. +bool IsVideoURL(const OUString& rURL) { return rURL.endsWithIgnoreAsciiCase(".mp4"); } +} + +NodeContext::NodeContext(const Reference& xNode, bool bMainSeqChild, + bool bIsIterateChild) +: mxNode(xNode) +, mbMainSeqChild(bMainSeqChild) +, mbValid(true) +, mnEffectNodeType(-1) +, mnEffectPresetClass(css::presentation::EffectPresetClass::CUSTOM) +{ +assert(xNode.is()); + +initUserData(); + +initValid(initChildNodes(), bIsIterateChild); +} + +void NodeContext::initUserData() +{ +assert(mxNode.is()); + +Sequence aUserData = mxNode->getUserData(); +for (const NamedValue& rProp : aUserData) +{ +if (rProp.Name == "node-type") +{ +rProp.Value >>= mnEffectNodeType; +} +else if (rProp.Name == "preset-class") +{ +rProp.Value >>= mnEffectPresetClass; +} +else if (rProp.Name == "preset-id") +{ +rProp.Value >>= msEffectPresetId; +} +else if (rProp.Name == "preset-sub-type") +{ +rProp.Value >>= msEffectPresetSubType; +} +} +} + +void NodeContext::initValid(bool bHasValidChild, bool bIsIterateChild) +{ +sal_Int16 nType = mxNode->getType(); + +if (nType == AnimationNodeType::ITERATE) +{ +Reference xIterate(mxNode, UNO_QUERY); +mbValid = xIterate.is() && (bIsIterateChild || isValidTarget(xIterate->getTarget())) + && !maChildNodes.empty(); +} +else if (nType == AnimationNodeType::COMMAND) +{ +Reference xCommand(mxNode, UNO_QUERY); +mbValid = xCommand.is() && (bIsIterateChild || isValidTarget(xCommand->getTarget())); +} +else if (nType == AnimationNodeType::PAR || nType == AnimationNodeType::SEQ) +{ +mbValid = bHasValidChi
[Libreoffice-commits] core.git: 3 commits - sd/Library_sd.mk sd/source svx/source
sd/Library_sd.mk |1 sd/source/filter/eppt/pptx-animations-cond.cxx| 105 ++ sd/source/filter/eppt/pptx-animations-cond.hxx| 31 sd/source/filter/eppt/pptx-animations.cxx | 95 svx/source/accessibility/svxpixelctlaccessiblecontext.cxx |3 svx/source/accessibility/svxrectctaccessiblecontext.cxx |3 svx/source/inc/svxpixelctlaccessiblecontext.hxx | 11 - svx/source/inc/svxrectctaccessiblecontext.hxx | 12 - 8 files changed, 145 insertions(+), 116 deletions(-) New commits: commit 0a55335ef3b91bbf573f6e5eaa4241d14a15a4ee Author: Mark Hung AuthorDate: Fri Jan 27 22:13:36 2023 +0800 Commit: Noel Grandin CommitDate: Sat Jan 28 17:44:37 2023 + sd/filter/pptx-anmiation refactor Cond class. Change-Id: Iffb0eeb1454a858987680d402add3f5122f7b6db Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146292 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 86ad12f6a2b9..297c2bc23654 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -187,6 +187,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\ sd/source/filter/eppt/pptx-epptbase \ sd/source/filter/eppt/pptx-epptooxml \ sd/source/filter/eppt/pptx-animations \ +sd/source/filter/eppt/pptx-animations-cond \ sd/source/filter/eppt/pptx-grouptable \ sd/source/filter/eppt/pptx-stylesheet \ sd/source/filter/eppt/pptx-text \ diff --git a/sd/source/filter/eppt/pptx-animations-cond.cxx b/sd/source/filter/eppt/pptx-animations-cond.cxx new file mode 100644 index ..440d31885dad --- /dev/null +++ b/sd/source/filter/eppt/pptx-animations-cond.cxx @@ -0,0 +1,105 @@ +/* -*- 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 +#include +#include +#include +#include +#include "pptx-animations-cond.hxx" + +using namespace ::com::sun::star::animations; +using namespace ::com::sun::star::drawing; +using namespace ::com::sun::star::uno; + +namespace +{ +const char* convertEventTrigger(sal_Int16 nTrigger) +{ +const char* pEvent = nullptr; +switch (nTrigger) +{ +case EventTrigger::ON_NEXT: +pEvent = "onNext"; +break; +case EventTrigger::ON_PREV: +pEvent = "onPrev"; +break; +case EventTrigger::BEGIN_EVENT: +pEvent = "begin"; +break; +case EventTrigger::END_EVENT: +pEvent = "end"; +break; +case EventTrigger::ON_BEGIN: +pEvent = "onBegin"; +break; +case EventTrigger::ON_END: +pEvent = "onEnd"; +break; +case EventTrigger::ON_CLICK: +pEvent = "onClick"; +break; +case EventTrigger::ON_DBL_CLICK: +pEvent = "onDblClick"; +break; +case EventTrigger::ON_STOP_AUDIO: +pEvent = "onStopAudio"; +break; +case EventTrigger::ON_MOUSE_ENTER: +pEvent = "onMouseOver"; // not exact? +break; +case EventTrigger::ON_MOUSE_LEAVE: +pEvent = "onMouseOut"; +break; +} +return pEvent; +} +} + +namespace oox::core +{ +Cond::Cond(const Any& rAny, bool bIsMainSeqChild) +: mpEvent(nullptr) +{ +bool bHasFDelay = false; +double fDelay = 0; +Timing eTiming; +Event aEvent; + +if (rAny >>= eTiming) +{ +if (eTiming == Timing_INDEFINITE) +msDelay = "indefinite"; +} +else if (rAny >>= aEvent) +{ +if (aEvent.Trigger == EventTrigger::ON_NEXT && bIsMainSeqChild) +msDelay = "indefinite"; +else +{ +mpEvent = convertEventTrigger(aEvent.Trigger); +if (!(aEvent.Source >>= mxShape)) +aEvent.Source >>= mxNode; + +if (aEvent.Offset >>= fDelay) +bHasFDelay = true; +} +} +else if (rAny >>= fDelay) +bHasFDelay = true; + +if (bHasFDelay) +{ +sal_Int32 nDelay = static_cast(fDelay * 1000.0); +msDelay = OString::number(nDelay); +} +} +} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/filter/eppt/pptx-animations-cond.hxx b/sd/source/filter/eppt/pptx-animations-cond.hxx new file mode 100644 index ..ec101c429ef1 --- /dev/null +++ b/sd/source
[Libreoffice-commits] core.git: 3 commits - sd/source svx/source
sd/source/filter/eppt/pptx-animations.cxx| 15 +++ svx/source/accessibility/AccessibleFrameSelector.cxx |3 --- svx/source/accessibility/charmapacc.cxx |3 --- svx/source/inc/AccessibleFrameSelector.hxx | 11 +++ svx/source/inc/charmapacc.hxx| 14 +- 5 files changed, 15 insertions(+), 31 deletions(-) New commits: commit 28f3aeff99fa635f7d59ab88f1f41ff6a036bebb Author: Mark Hung AuthorDate: Fri Jan 27 20:56:55 2023 +0800 Commit: Noel Grandin CommitDate: Sat Jan 28 17:43:54 2023 + sd/source/filter refactor pptx animation export. Refactor "Any NodeContext::getCondition(bool bBegin) const" to "const Reference& NodeContext::getNodeForCondition() const", to get rid of the bool arguement of getCondition. Change-Id: Ic61d2caecaad2d3ada38556346f66aedb258e554 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146291 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/sd/source/filter/eppt/pptx-animations.cxx b/sd/source/filter/eppt/pptx-animations.cxx index 1d53833fa89f..03c8e6cc7b49 100644 --- a/sd/source/filter/eppt/pptx-animations.cxx +++ b/sd/source/filter/eppt/pptx-animations.cxx @@ -572,7 +572,7 @@ public: const OUString& getEffectPresetSubType() const { return msEffectPresetSubType; } bool isValid() const { return mbValid; } const std::vector& getChildNodes() const { return maChildNodes; }; -Any getCondition(bool bBegin) const; +const Reference& getNodeForCondition() const; }; struct Cond @@ -1101,8 +1101,8 @@ void PPTXAnimationExport::WriteAnimationNodeCommonPropsStart() sax_fastparser::UseIf(OString::number(nPresetSubType), bPresetSubType), XML_repeatCount, sRepeatCount); -WriteAnimationCondList(mpContext->getCondition(true), XML_stCondLst); -WriteAnimationCondList(mpContext->getCondition(false), XML_endCondLst); +WriteAnimationCondList(mpContext->getNodeForCondition()->getBegin(), XML_stCondLst); +WriteAnimationCondList(mpContext->getNodeForCondition()->getEnd(), XML_endCondLst); if (rXNode->getType() == AnimationNodeType::ITERATE) { @@ -1287,8 +1287,8 @@ void PPTXAnimationExport::WriteAnimationNodeMedia() { mpFS->startElementNS(XML_p, XML_cTn); } -WriteAnimationCondList(mpContext->getCondition(true), XML_stCondLst); -WriteAnimationCondList(mpContext->getCondition(false), XML_endCondLst); +WriteAnimationCondList(mpContext->getNodeForCondition()->getBegin(), XML_stCondLst); +WriteAnimationCondList(mpContext->getNodeForCondition()->getEnd(), XML_endCondLst); mpFS->endElementNS(XML_p, XML_cTn); mpFS->startElementNS(XML_p, XML_tgtEl); @@ -1528,13 +1528,12 @@ bool NodeContext::initChildNodes() return bValid; } -Any NodeContext::getCondition(bool bBegin) const +const Reference& NodeContext::getNodeForCondition() const { const bool bParent = (mnEffectNodeType != EffectNodeType::INTERACTIVE_SEQUENCE || maChildNodes.empty()); const Reference& rNode = bParent ? mxNode : maChildNodes[0]->getNode(); - -return bBegin ? rNode->getBegin() : rNode->getEnd(); +return rNode; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit 131904c23ab539a3eb2aba5467cbbeee0650632b Author: Stephan Bergmann AuthorDate: Fri Jan 27 15:44:13 2023 +0100 Commit: Stephan Bergmann CommitDate: Sat Jan 28 17:43:52 2023 + Use ImplInheritanceHelper in SvxShowCharSetAcc Change-Id: I9009b6168c66a1b340a34aaf804e097bfe614d21 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146279 Tested-by: Jenkins Reviewed-by: Stephan Bergmann diff --git a/svx/source/accessibility/charmapacc.cxx b/svx/source/accessibility/charmapacc.cxx index 46fe8b11ac15..89e0b62199dc 100644 --- a/svx/source/accessibility/charmapacc.cxx +++ b/svx/source/accessibility/charmapacc.cxx @@ -91,9 +91,6 @@ void SAL_CALL SvxShowCharSetAcc::disposing() m_pParent = nullptr; } -IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base ) -IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base ) - bool SvxShowCharSetAcc::implIsSelected( sal_Int64 nAccessibleChildIndex ) { if (!m_pParent) diff --git a/svx/source/inc/charmapacc.hxx b/svx/source/inc/charmapacc.hxx index e94567e8c32d..339192ced108 100644 --- a/svx/source/inc/charmapacc.hxx +++ b/svx/source/inc/charmapacc.hxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -60,17 +61,15 @@ namespace svx }; -typedef ::cppu::ImplHelper2 < css::accessibility::XAccessible, -css::accessibility::XAccessibleTable -> OAc
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa sw/source
sw/qa/extras/layout/data/tdf152031-stair.odt|binary sw/qa/extras/layout/data/tdf152085-section-tblr.odt |binary sw/qa/extras/layout/layout2.cxx | 36 ++ sw/source/core/layout/calcmove.cxx | 49 +--- 4 files changed, 59 insertions(+), 26 deletions(-) New commits: commit 65cbb9c52301c784dd4e185967cec140bb8fcd50 Author: Mark Hung AuthorDate: Sat Nov 26 11:37:31 2022 +0800 Commit: Michael Stahl CommitDate: Wed Dec 21 10:50:37 2022 + tdf#152031,tdf#152085 minimize impact to table layout. Revert two commits[1][2] that are related to fixing tdf#135991 ( but keep the unit tests) and rework the solution. Cases related to IsNeighborFrame() imply either IsCellFrame() ( a table cell ), or IsColumnFrame() ( a column inside a section ). Original patch[2] affected both of tables and sections. Try to limit the affected case to the section so it does not affect table layout for tdf#152031. [1] 1bf82b26aea3a403920a64cdfcb4671c947c7a01 Author: Mark Hung Date: Fri Sep 9 16:09:47 2022 +0800 tdf#150642 fix table layout with vertical writing. [2] 1e21902106cbe57658bed03ed24d4d0863685cfd Author: Mark Hung Date: Sun Aug 14 15:23:14 2022 +0800 tdf#135991 fix unexpected hidden RTL sections. Change-Id: If50e2b50b47352dad8eafebd6cce0af0530abefa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143317 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit ae6e57d99cfdeac69cc42cd82904c24edc866310) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144180 Reviewed-by: Xisco Fauli (cherry picked from commit 6a4bedc761bba6c1d1cb44d9e36c5d12bc8719f7) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144430 Reviewed-by: Michael Stahl diff --git a/sw/qa/extras/layout/data/tdf152031-stair.odt b/sw/qa/extras/layout/data/tdf152031-stair.odt new file mode 100644 index ..5171920e3496 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152031-stair.odt differ diff --git a/sw/qa/extras/layout/data/tdf152085-section-tblr.odt b/sw/qa/extras/layout/data/tdf152085-section-tblr.odt new file mode 100644 index ..3b454edc9b41 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152085-section-tblr.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 1e0ec0eb97bd..d02072038d12 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -2199,6 +2200,41 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150642) assertXPath(pDump, "//bounds[@right<0]", 0); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152085) +{ +createSwDoc(DATA_DIRECTORY, "tdf152085-section-tblr.odt"); +auto pDump = parseLayoutDump(); +sal_Int32 nSectionHeight += getXPath(pDump, "//section/infos/bounds", "bottom").toInt32(); // was 8391 +sal_Int32 nColumnHeight += getXPath(pDump, "(//column/infos/bounds)[2]", "bottom").toInt32(); // was 16216 +CPPUNIT_ASSERT_MESSAGE("The column in a TBRL page should be shorter than the section.", + nColumnHeight <= nSectionHeight); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152031) +{ +createSwDoc(DATA_DIRECTORY, "tdf152031-stair.odt"); + +// reproduce the bug by shrinking the table width. +uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xTables(xTablesSupplier->getTextTables(), +uno::UNO_QUERY); +uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); +// Shrink table width from 5" to 4" +sal_Int32 nWidth = getProperty(xTable, "Width") * 4 / 5; + +uno::Reference xSet(xTable, uno::UNO_QUERY); +xSet->setPropertyValue("Width", uno::Any(nWidth)); + +auto pDump = parseLayoutDump(); +// There was a stair effect after change the table size. +sal_Int32 nLeft_Row1 = getXPath(pDump, "(//row/infos/bounds)[1]", "left").toInt32(); +sal_Int32 nLeft_Row2 = getXPath(pDump, "(//row/infos/bounds)[2]", "left").toInt32(); +CPPUNIT_ASSERT_EQUAL_MESSAGE("left values of SwRowFrames should be consistent.", nLeft_Row1, + nLeft_Row2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 4894c8524cf3..c9d5622ba02d 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -949,7 +949,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext
[Libreoffice-commits] core.git: Branch 'libreoffice-7-5' - sw/qa sw/source
sw/qa/extras/layout/data/tdf152031-stair.odt|binary sw/qa/extras/layout/data/tdf152085-section-tblr.odt |binary sw/qa/extras/layout/layout2.cxx | 36 ++ sw/source/core/layout/calcmove.cxx | 49 +--- 4 files changed, 59 insertions(+), 26 deletions(-) New commits: commit 6a4bedc761bba6c1d1cb44d9e36c5d12bc8719f7 Author: Mark Hung AuthorDate: Sat Nov 26 11:37:31 2022 +0800 Commit: Xisco Fauli CommitDate: Mon Dec 19 08:40:46 2022 + tdf#152031,tdf#152085 minimize impact to table layout. Revert two commits[1][2] that are related to fixing tdf#135991 ( but keep the unit tests) and rework the solution. Cases related to IsNeighborFrame() imply either IsCellFrame() ( a table cell ), or IsColumnFrame() ( a column inside a section ). Original patch[2] affected both of tables and sections. Try to limit the affected case to the section so it does not affect table layout for tdf#152031. [1] 1bf82b26aea3a403920a64cdfcb4671c947c7a01 Author: Mark Hung Date: Fri Sep 9 16:09:47 2022 +0800 tdf#150642 fix table layout with vertical writing. [2] 1e21902106cbe57658bed03ed24d4d0863685cfd Author: Mark Hung Date: Sun Aug 14 15:23:14 2022 +0800 tdf#135991 fix unexpected hidden RTL sections. Change-Id: If50e2b50b47352dad8eafebd6cce0af0530abefa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143317 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit ae6e57d99cfdeac69cc42cd82904c24edc866310) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144180 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/layout/data/tdf152031-stair.odt b/sw/qa/extras/layout/data/tdf152031-stair.odt new file mode 100644 index ..5171920e3496 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152031-stair.odt differ diff --git a/sw/qa/extras/layout/data/tdf152085-section-tblr.odt b/sw/qa/extras/layout/data/tdf152085-section-tblr.odt new file mode 100644 index ..3b454edc9b41 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152085-section-tblr.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 259a6ea66292..b8ba46bebc20 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -2485,6 +2486,41 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150642) assertXPath(pDump, "//bounds[@right<0]", 0); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152085) +{ +createSwDoc("tdf152085-section-tblr.odt"); +auto pDump = parseLayoutDump(); +sal_Int32 nSectionHeight += getXPath(pDump, "//section/infos/bounds", "bottom").toInt32(); // was 8391 +sal_Int32 nColumnHeight += getXPath(pDump, "(//column/infos/bounds)[2]", "bottom").toInt32(); // was 16216 +CPPUNIT_ASSERT_MESSAGE("The column in a TBRL page should be shorter than the section.", + nColumnHeight <= nSectionHeight); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152031) +{ +createSwDoc("tdf152031-stair.odt"); + +// reproduce the bug by shrinking the table width. +uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xTables(xTablesSupplier->getTextTables(), +uno::UNO_QUERY); +uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); +// Shrink table width from 5" to 4" +sal_Int32 nWidth = getProperty(xTable, "Width") * 4 / 5; + +uno::Reference xSet(xTable, uno::UNO_QUERY); +xSet->setPropertyValue("Width", uno::Any(nWidth)); + +auto pDump = parseLayoutDump(); +// There was a stair effect after change the table size. +sal_Int32 nLeft_Row1 = getXPath(pDump, "(//row/infos/bounds)[1]", "left").toInt32(); +sal_Int32 nLeft_Row2 = getXPath(pDump, "(//row/infos/bounds)[2]", "left").toInt32(); +CPPUNIT_ASSERT_EQUAL_MESSAGE("left values of SwRowFrames should be consistent.", nLeft_Row1, + nLeft_Row2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index acb384f2b759..184373585928 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -949,7 +949,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) const SwLayNotify aNotify( this ); bool bVert = IsVertical(); -SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) :
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/layout/data/tdf152031-stair.odt|binary sw/qa/extras/layout/data/tdf152085-section-tblr.odt |binary sw/qa/extras/layout/layout2.cxx | 36 ++ sw/source/core/layout/calcmove.cxx | 49 +--- 4 files changed, 59 insertions(+), 26 deletions(-) New commits: commit ae6e57d99cfdeac69cc42cd82904c24edc866310 Author: Mark Hung AuthorDate: Sat Nov 26 11:37:31 2022 +0800 Commit: Mark Hung CommitDate: Thu Dec 15 04:50:11 2022 + tdf#152031,tdf#152085 minimize impact to table layout. Revert two commits[1][2] that are related to fixing tdf#135991 ( but keep the unit tests) and rework the solution. Cases related to IsNeighborFrame() imply either IsCellFrame() ( a table cell ), or IsColumnFrame() ( a column inside a section ). Original patch[2] affected both of tables and sections. Try to limit the affected case to the section so it does not affect table layout for tdf#152031. [1] 1bf82b26aea3a403920a64cdfcb4671c947c7a01 Author: Mark Hung Date: Fri Sep 9 16:09:47 2022 +0800 tdf#150642 fix table layout with vertical writing. [2] 1e21902106cbe57658bed03ed24d4d0863685cfd Author: Mark Hung Date: Sun Aug 14 15:23:14 2022 +0800 tdf#135991 fix unexpected hidden RTL sections. Change-Id: If50e2b50b47352dad8eafebd6cce0af0530abefa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143317 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/layout/data/tdf152031-stair.odt b/sw/qa/extras/layout/data/tdf152031-stair.odt new file mode 100644 index ..5171920e3496 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152031-stair.odt differ diff --git a/sw/qa/extras/layout/data/tdf152085-section-tblr.odt b/sw/qa/extras/layout/data/tdf152085-section-tblr.odt new file mode 100644 index ..3b454edc9b41 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf152085-section-tblr.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 259a6ea66292..b8ba46bebc20 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -2485,6 +2486,41 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150642) assertXPath(pDump, "//bounds[@right<0]", 0); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152085) +{ +createSwDoc("tdf152085-section-tblr.odt"); +auto pDump = parseLayoutDump(); +sal_Int32 nSectionHeight += getXPath(pDump, "//section/infos/bounds", "bottom").toInt32(); // was 8391 +sal_Int32 nColumnHeight += getXPath(pDump, "(//column/infos/bounds)[2]", "bottom").toInt32(); // was 16216 +CPPUNIT_ASSERT_MESSAGE("The column in a TBRL page should be shorter than the section.", + nColumnHeight <= nSectionHeight); +} + +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf152031) +{ +createSwDoc("tdf152031-stair.odt"); + +// reproduce the bug by shrinking the table width. +uno::Reference xTablesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xTables(xTablesSupplier->getTextTables(), +uno::UNO_QUERY); +uno::Reference xTable(xTables->getByIndex(0), uno::UNO_QUERY); +// Shrink table width from 5" to 4" +sal_Int32 nWidth = getProperty(xTable, "Width") * 4 / 5; + +uno::Reference xSet(xTable, uno::UNO_QUERY); +xSet->setPropertyValue("Width", uno::Any(nWidth)); + +auto pDump = parseLayoutDump(); +// There was a stair effect after change the table size. +sal_Int32 nLeft_Row1 = getXPath(pDump, "(//row/infos/bounds)[1]", "left").toInt32(); +sal_Int32 nLeft_Row2 = getXPath(pDump, "(//row/infos/bounds)[2]", "left").toInt32(); +CPPUNIT_ASSERT_EQUAL_MESSAGE("left values of SwRowFrames should be consistent.", nLeft_Row1, + nLeft_Row2); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index acb384f2b759..184373585928 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -949,7 +949,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) const SwLayNotify aNotify( this ); bool bVert = IsVertical(); -SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori; +SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) :
Re: table and section in East Asian vertical writing mode
Mark Hung 於 2022年11月16日 週三 晚上9:12寫道: > Hi, > > Miklos Vajna 於 2022年11月16日 週三 下午4:05寫道: > >> Hi, >> >> On Tue, Nov 15, 2022 at 01:04:12AM +0100, Regina Henschel < >> rb.hensc...@t-online.de> wrote: >> > How are tables in text documents usually organized in East Asian >> vertical >> > writing mode? I mean: Where are column headers? Where are row headers? >> What >> > > It's not so common to see a table in a vertically formatted text. I've > tried to find the definition first from "Requirements for Chinese Text > Layouts." > FYI: https://www.w3.org/TR/2020/NOTE-jlreq-20200811/#processing_of_tables > -- Mark Hung
Re: table and section in East Asian vertical writing mode
Hi, Miklos Vajna 於 2022年11月16日 週三 下午4:05寫道: > Hi, > > On Tue, Nov 15, 2022 at 01:04:12AM +0100, Regina Henschel < > rb.hensc...@t-online.de> wrote: > > How are tables in text documents usually organized in East Asian vertical > > writing mode? I mean: Where are column headers? Where are row headers? > What > It's not so common to see a table in a vertically formatted text. I've tried to find the definition first from "Requirements for Chinese Text Layouts." Unfortunately there is nothing about it there. I've found a physical book and a document to see how the tables are used. Both have headers on the right side of the page. I think that Writer performs correctly. Tables are rotated 90 degrees clockwise. ( i.e. the second row is at the left of the first row, the second column is below the first column. ) Contrarily, MS Word is awkward. If you set the text flow to vertical, insert a table, change the design of the table so that it paints the background of the header, the top most part ( can't be sure if it's a row or a column ) is painted. But this test is rough. It will be better to find more examples. > > it the order of columns? If I insert a table in Writer the result is > > different than inserting a table in Word. > > > > > How should a section work if the section has more than one column? That > > seems to be buggy in LO. > I've found an old Chinese dictionary with three columns. The second column is below the first one. Writer seems to act correctly to me. > > > > Has a book in East Asian vertical writing mode the binding edge left or > > right? > > CC Mark, perhaps he knows these. > > Regards, > > Miklos > HTH -- Mark Hung
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa sw/source
sw/qa/extras/layout/data/tdf150642.odt |binary sw/qa/extras/layout/layout2.cxx|9 + sw/source/core/layout/calcmove.cxx |2 +- 3 files changed, 10 insertions(+), 1 deletion(-) New commits: commit 5e3abdf6ecded4f69bc7e1bdfb9dc8300f30685d Author: Mark Hung AuthorDate: Fri Sep 9 16:09:47 2022 +0800 Commit: Christian Lohmaier CommitDate: Wed Sep 21 12:54:07 2022 +0200 tdf#150642 fix table layout with vertical writing. Revert part of 1bf82b26ae3. N | V | WAS | 1bf82b26aea3 | WAS | 1bf82b26aea3 | --- F | F | fnRectHori | fnRectHori | fnAddRight/fnSubLeft | | F | T | fnRectVert | fnRectVert | fnAddRight/fnSubLeft | | T | F | fnRectVert | fnRectHori | fnAddRight/fnSubLeft | fnAddBottom | T | T | fnRectHori | fnRectVert | fnAddRight/fnSubLeft | fnAddBottom | * *: the case fixed in this patch. Ref: commit 1bf82b26aea3a403920a64cdfcb4671c947c7a01 Author: Mark Hung Date: Sun Aug 14 15:23:14 2022 +0800 tdf#135991 fix unexpected hidden RTL sections. Change-Id: I1e30c277dd03369bef0a6930b3d3534b7d57a640 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139777 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 11ec622b8405dcaabc359e3d6e38c8a9142dad6b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140172 Reviewed-by: Michael Stahl diff --git a/sw/qa/extras/layout/data/tdf150642.odt b/sw/qa/extras/layout/data/tdf150642.odt new file mode 100644 index ..5e316424a289 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150642.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 00d7a8e65a48..6bbda55706a4 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2173,6 +2173,15 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135991) assertXPath(pDump, "//bounds[@top<0]", 0); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150642) +{ +createSwDoc(DATA_DIRECTORY, "tdf150642.odt"); +auto pDump = parseLayoutDump(); +// There used to be negative values that made the cell frame invisible. +assertXPath(pDump, "//bounds[@left<0]", 0); +assertXPath(pDump, "//bounds[@right<0]", 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 1869794300f6..e40e1dab6ef3 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -977,7 +977,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) setFramePrintAreaValid(false); SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); -if (IsNeighbourFrame()) +if (IsNeighbourFrame() && !bVert) { SwTwips nPrtHeight = (GetUpper()->getFramePrintArea().*fnRect->fnGetHeight)(); const tools::Long nDiff = nPrtHeight - (getFrameArea().*fnRect->fnGetHeight)();
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/layout/data/tdf150642.odt |binary sw/qa/extras/layout/layout2.cxx|9 + sw/source/core/layout/calcmove.cxx |2 +- 3 files changed, 10 insertions(+), 1 deletion(-) New commits: commit 11ec622b8405dcaabc359e3d6e38c8a9142dad6b Author: Mark Hung AuthorDate: Fri Sep 9 16:09:47 2022 +0800 Commit: Mark Hung CommitDate: Tue Sep 20 18:47:53 2022 +0200 tdf#150642 fix table layout with vertical writing. Revert part of 1bf82b26ae3. N | V | WAS | 1bf82b26aea3 | WAS | 1bf82b26aea3 | --- F | F | fnRectHori | fnRectHori | fnAddRight/fnSubLeft | | F | T | fnRectVert | fnRectVert | fnAddRight/fnSubLeft | | T | F | fnRectVert | fnRectHori | fnAddRight/fnSubLeft | fnAddBottom | T | T | fnRectHori | fnRectVert | fnAddRight/fnSubLeft | fnAddBottom | * *: the case fixed in this patch. Ref: commit 1bf82b26aea3a403920a64cdfcb4671c947c7a01 Author: Mark Hung Date: Sun Aug 14 15:23:14 2022 +0800 tdf#135991 fix unexpected hidden RTL sections. Change-Id: I1e30c277dd03369bef0a6930b3d3534b7d57a640 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139777 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/layout/data/tdf150642.odt b/sw/qa/extras/layout/data/tdf150642.odt new file mode 100644 index ..5e316424a289 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf150642.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 208bdf908d19..ac783be344fd 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2382,6 +2382,15 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135991) assertXPath(pDump, "//bounds[@top<0]", 0); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf150642) +{ +createSwDoc(DATA_DIRECTORY, "tdf150642.odt"); +auto pDump = parseLayoutDump(); +// There used to be negative values that made the cell frame invisible. +assertXPath(pDump, "//bounds[@left<0]", 0); +assertXPath(pDump, "//bounds[@right<0]", 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 1869794300f6..e40e1dab6ef3 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -977,7 +977,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) setFramePrintAreaValid(false); SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); -if (IsNeighbourFrame()) +if (IsNeighbourFrame() && !bVert) { SwTwips nPrtHeight = (GetUpper()->getFramePrintArea().*fnRect->fnGetHeight)(); const tools::Long nDiff = nPrtHeight - (getFrameArea().*fnRect->fnGetHeight)();
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa sw/source
sw/qa/extras/layout/data/tdf135991.odt |binary sw/qa/extras/layout/layout2.cxx|8 + sw/source/core/layout/calcmove.cxx | 46 + 3 files changed, 33 insertions(+), 21 deletions(-) New commits: commit 45e4abfed10aff768cd884ebcb1a38af0fea32d6 Author: Mark Hung AuthorDate: Sun Aug 14 15:23:14 2022 +0800 Commit: Xisco Fauli CommitDate: Mon Aug 15 15:46:45 2022 +0200 tdf#135991 fix unexpected hidden RTL sections. SwLayoutFrame::MakeAll tried to manipulate the height instead of the width for SwCellFrame and SwColumnFrame ( i.e. when IsNeghbourFrame() is true. ), by selecting a wrong SwRectFn. SwRectFn fnRect = bVert == IsNeighbourFrame() ? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); It doesn't make sense to select among fnRectVertL2RBT, fnRectVertL2R, and fnRectVert if the layout is horizontal. The frame position got a negative top value and make the frame invisble. Check he following commit for reference: commit c90b6806d18c8ed25015eb2ecdff13c7bab2572d Author: Andreas Martens Date: Wed Sep 19 07:45:10 2001 + Chg: Moving vertical help functions from SwFrm to SwRect Change-Id: I2f6da9cdbc2947de95a6fb9ce8fa94a79360c83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138250 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit 1bf82b26aea3a403920a64cdfcb4671c947c7a01) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138278 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/layout/data/tdf135991.odt b/sw/qa/extras/layout/data/tdf135991.odt new file mode 100644 index ..f490ee9fb28c Binary files /dev/null and b/sw/qa/extras/layout/data/tdf135991.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 24c4d32acc5d..d602d74c9bba 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2131,6 +2131,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124261) #endif } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135991) +{ +createSwDoc(DATA_DIRECTORY, "tdf135991.odt"); +auto pDump = parseLayoutDump(); +// There used to be negative values that made the column frames invisible. +assertXPath(pDump, "//bounds[@top<0]", 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 1bc2506a72f4..1869794300f6 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -949,7 +949,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) const SwLayNotify aNotify( this ); bool bVert = IsVertical(); -SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); +SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori; std::optional oAccess; const SwBorderAttrs*pAttrs = nullptr; @@ -975,32 +975,36 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) { // Set FixSize; VarSize is set by Format() after calculating the PrtArea setFramePrintAreaValid(false); - -SwTwips nPrtWidth = (GetUpper()->getFramePrintArea().*fnRect->fnGetWidth)(); -if( bVert && ( IsBodyFrame() || IsFootnoteContFrame() ) ) -{ -SwFrame* pNxt = GetPrev(); -while( pNxt && !pNxt->IsHeaderFrame() ) -pNxt = pNxt->GetPrev(); -if( pNxt ) -nPrtWidth -= pNxt->getFrameArea().Height(); -pNxt = GetNext(); -while( pNxt && !pNxt->IsFooterFrame() ) -pNxt = pNxt->GetNext(); -if( pNxt ) -nPrtWidth -= pNxt->getFrameArea().Height(); -} - -const tools::Long nDiff = nPrtWidth - (getFrameArea().*fnRect->fnGetWidth)(); SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); -if( IsNeighbourFrame() && IsRightToLeft() ) +if (IsNeighbourFrame()) { -(aFrm.*fnRect->fnSubLeft)( nDiff ); +SwTwips nPrtHeight = (GetUpper()->getFramePrintArea().*fnRect->fnGetHeight)(); +const tools::Long nDiff = nPrtHeight - (getFrameArea().*fnRect->fnGetHeight)(); +
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/layout/data/tdf135991.odt |binary sw/qa/extras/layout/layout2.cxx|8 + sw/source/core/layout/calcmove.cxx | 46 + 3 files changed, 33 insertions(+), 21 deletions(-) New commits: commit 1bf82b26aea3a403920a64cdfcb4671c947c7a01 Author: Mark Hung AuthorDate: Sun Aug 14 15:23:14 2022 +0800 Commit: Miklos Vajna CommitDate: Mon Aug 15 11:39:09 2022 +0200 tdf#135991 fix unexpected hidden RTL sections. SwLayoutFrame::MakeAll tried to manipulate the height instead of the width for SwCellFrame and SwColumnFrame ( i.e. when IsNeghbourFrame() is true. ), by selecting a wrong SwRectFn. SwRectFn fnRect = bVert == IsNeighbourFrame() ? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); It doesn't make sense to select among fnRectVertL2RBT, fnRectVertL2R, and fnRectVert if the layout is horizontal. The frame position got a negative top value and make the frame invisble. Check he following commit for reference: commit c90b6806d18c8ed25015eb2ecdff13c7bab2572d Author: Andreas Martens Date: Wed Sep 19 07:45:10 2001 + Chg: Moving vertical help functions from SwFrm to SwRect Change-Id: I2f6da9cdbc2947de95a6fb9ce8fa94a79360c83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138250 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/layout/data/tdf135991.odt b/sw/qa/extras/layout/data/tdf135991.odt new file mode 100644 index ..f490ee9fb28c Binary files /dev/null and b/sw/qa/extras/layout/data/tdf135991.odt differ diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index c4d1a976fe7c..09e113fc4ed0 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2301,6 +2301,14 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf124261) #endif } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf135991) +{ +createSwDoc(DATA_DIRECTORY, "tdf135991.odt"); +auto pDump = parseLayoutDump(); +// There used to be negative values that made the column frames invisible. +assertXPath(pDump, "//bounds[@top<0]", 0); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/layout/calcmove.cxx b/sw/source/core/layout/calcmove.cxx index 1bc2506a72f4..1869794300f6 100644 --- a/sw/source/core/layout/calcmove.cxx +++ b/sw/source/core/layout/calcmove.cxx @@ -949,7 +949,7 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) const SwLayNotify aNotify( this ); bool bVert = IsVertical(); -SwRectFn fnRect = ( IsNeighbourFrame() == bVert )? fnRectHori : ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ); +SwRectFn fnRect = bVert ? ( IsVertLR() ? (IsVertLRBT() ? fnRectVertL2RB2T : fnRectVertL2R) : fnRectVert ) : fnRectHori; std::optional oAccess; const SwBorderAttrs*pAttrs = nullptr; @@ -975,32 +975,36 @@ void SwLayoutFrame::MakeAll(vcl::RenderContext* /*pRenderContext*/) { // Set FixSize; VarSize is set by Format() after calculating the PrtArea setFramePrintAreaValid(false); - -SwTwips nPrtWidth = (GetUpper()->getFramePrintArea().*fnRect->fnGetWidth)(); -if( bVert && ( IsBodyFrame() || IsFootnoteContFrame() ) ) -{ -SwFrame* pNxt = GetPrev(); -while( pNxt && !pNxt->IsHeaderFrame() ) -pNxt = pNxt->GetPrev(); -if( pNxt ) -nPrtWidth -= pNxt->getFrameArea().Height(); -pNxt = GetNext(); -while( pNxt && !pNxt->IsFooterFrame() ) -pNxt = pNxt->GetNext(); -if( pNxt ) -nPrtWidth -= pNxt->getFrameArea().Height(); -} - -const tools::Long nDiff = nPrtWidth - (getFrameArea().*fnRect->fnGetWidth)(); SwFrameAreaDefinition::FrameAreaWriteAccess aFrm(*this); -if( IsNeighbourFrame() && IsRightToLeft() ) +if (IsNeighbourFrame()) { -(aFrm.*fnRect->fnSubLeft)( nDiff ); +SwTwips nPrtHeight = (GetUpper()->getFramePrintArea().*fnRect->fnGetHeight)(); +const tools::Long nDiff = nPrtHeight - (getFrameArea().*fnRect->fnGetHeight)(); +(aFrm.*fnRect->fnAddBottom)( nDiff ); } else { -(aFrm.*fnRect->fnAddRight)( nDiff )
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa writerfilter/source
sw/qa/extras/ooxmlexport/data/tdf149089.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 10 ++ writerfilter/source/dmapper/PropertyMap.cxx | 13 ++--- 3 files changed, 20 insertions(+), 3 deletions(-) New commits: commit ac0ab772d93bcf3197c1c6e2191cba74eb39718a Author: Mark Hung AuthorDate: Wed Jun 29 21:03:35 2022 +0800 Commit: Xisco Fauli CommitDate: Thu Jul 7 16:59:08 2022 +0200 tdf#149089 fallback GridMode. If line pitch is not defined -> fallback to none. Otherwise if charSpace is not defined -> fallback to lines. Change-Id: I1df027f2e74baf0215567fb9a70c879522558346 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136622 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 23f80b26098bcf9a8ae870e8ded878cca6e0c541) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136865 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/ooxmlexport/data/tdf149089.docx b/sw/qa/extras/ooxmlexport/data/tdf149089.docx new file mode 100644 index ..2390476841e3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149089.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index bcd34ff459a2..f7035eb1d073 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1027,6 +1028,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, "tdf148273_secti CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue()); } +DECLARE_OOXMLEXPORT_TEST(testTdf149089, "tdf149089.docx") +{ +uno::Reference xPageStyles = getStyles("PageStyles"); +uno::Reference xPageStyle(xPageStyles->getByName("Standard"), uno::UNO_QUERY); +sal_Int16 nGridMode; +xPageStyle->getPropertyValue("GridMode") >>= nGridMode; +CPPUNIT_ASSERT_EQUAL( sal_Int16(text::TextGridMode::LINES), nGridMode); // was LINES_AND_CHARS +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index e1814a8ce1d5..1ae28759db33 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1759,16 +1759,23 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } const sal_Int32 nGridLines = nTextAreaHeight / nGridLinePitch; +sal_Int16 nGridType = m_nGridType; if ( nGridLines >= 0 && nGridLines <= SAL_MAX_INT16 ) Insert( PROP_GRID_LINES, uno::Any( sal_Int16(nGridLines) ) ); +else +nGridType = text::TextGridMode::NONE; // PROP_GRID_MODE -Insert( PROP_GRID_MODE, uno::Any( static_cast (m_nGridType) ) ); -if ( m_nGridType == text::TextGridMode::LINES_AND_CHARS ) +if ( nGridType == text::TextGridMode::LINES_AND_CHARS ) { -Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars ) ); +if (!m_nDxtCharSpace) +nGridType = text::TextGridMode::LINES; +else +Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars ) ); } +Insert( PROP_GRID_MODE, uno::Any( nGridType ) ); + sal_Int32 nCharWidth = 423; //240 twip/ 12 pt const StyleSheetEntryPtr pEntry = rDM_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( u"Standard" ); if ( pEntry )
[Libreoffice-commits] core.git: sw/qa writerfilter/source
sw/qa/extras/ooxmlexport/data/tdf149089.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 10 ++ writerfilter/source/dmapper/PropertyMap.cxx | 13 ++--- 3 files changed, 20 insertions(+), 3 deletions(-) New commits: commit 23f80b26098bcf9a8ae870e8ded878cca6e0c541 Author: Mark Hung AuthorDate: Wed Jun 29 21:03:35 2022 +0800 Commit: Mark Hung CommitDate: Thu Jul 7 15:18:19 2022 +0200 tdf#149089 fallback GridMode. If line pitch is not defined -> fallback to none. Otherwise if charSpace is not defined -> fallback to lines. Change-Id: I1df027f2e74baf0215567fb9a70c879522558346 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136622 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/ooxmlexport/data/tdf149089.docx b/sw/qa/extras/ooxmlexport/data/tdf149089.docx new file mode 100644 index ..2390476841e3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf149089.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 75d7b8feb4ba..c264342fdb77 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1021,6 +1022,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf148273_sectionBulletFormatLeak, "tdf148273_secti CPPUNIT_ASSERT_EQUAL(false, aValue.hasValue()); } +DECLARE_OOXMLEXPORT_TEST(testTdf149089, "tdf149089.docx") +{ +uno::Reference xPageStyles = getStyles("PageStyles"); +uno::Reference xPageStyle(xPageStyles->getByName("Standard"), uno::UNO_QUERY); +sal_Int16 nGridMode; +xPageStyle->getPropertyValue("GridMode") >>= nGridMode; +CPPUNIT_ASSERT_EQUAL( sal_Int16(text::TextGridMode::LINES), nGridMode); // was LINES_AND_CHARS +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index e1814a8ce1d5..1ae28759db33 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1759,16 +1759,23 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) } const sal_Int32 nGridLines = nTextAreaHeight / nGridLinePitch; +sal_Int16 nGridType = m_nGridType; if ( nGridLines >= 0 && nGridLines <= SAL_MAX_INT16 ) Insert( PROP_GRID_LINES, uno::Any( sal_Int16(nGridLines) ) ); +else +nGridType = text::TextGridMode::NONE; // PROP_GRID_MODE -Insert( PROP_GRID_MODE, uno::Any( static_cast (m_nGridType) ) ); -if ( m_nGridType == text::TextGridMode::LINES_AND_CHARS ) +if ( nGridType == text::TextGridMode::LINES_AND_CHARS ) { -Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars ) ); +if (!m_nDxtCharSpace) +nGridType = text::TextGridMode::LINES; +else +Insert( PROP_GRID_SNAP_TO_CHARS, uno::Any( m_bGridSnapToChars ) ); } +Insert( PROP_GRID_MODE, uno::Any( nGridType ) ); + sal_Int32 nCharWidth = 423; //240 twip/ 12 pt const StyleSheetEntryPtr pEntry = rDM_Impl.GetStyleSheetTable()->FindStyleSheetByConvertedStyleName( u"Standard" ); if ( pEntry )
Re: How to write OOXML attribute 'vert' of element to ODF?
Hi Regina, > > > > I found that I was confused with the name "loext:text-direction", and > > connected it to writing-mode. > In different context direction may mean > writing direction in Bidi text, > > as in [1]. > > You are right, the name is indeed misleading, probably > "loext:text-vertical" is better? > > I was thinking text-orientation, but I found it has different meaning some where ( see below. ) Naming is hard. :-) Apology for not being able to give useful advice on this. > > Is that new "loext:text-direction" attribute only intended to rotate > > text for RL_TB writing mode? > > ( wordArtVert and wordArtVertRtl should also be excluded in that case? ) > > "wordArtVer" and "wordArtVertRtl" would be included in principle. But > both are not yet implemented. > > I am not sure if I should go this way at all. My knowledge is enough to > extend the "extended-geometry" with an additional attribute for "vert" > and "vert270". And it can be extended to the values "wordArtVert" and > "wordArtVertRtl" if that is implemented. However, another option would > be to enable the text in shapes to use WritingMode2 and extend its > values similar to the current loext:writing-mode="bt-lr". This looks > better to me for future development. Only I certainly need help for the > implementation. > > The real use cases might be mixed depending on content, as described in CJK text layout requirement[1]: Western text keeps upright as CJK text for single alphabet, digit, or abbreviation ( ex, GDP ). Western text rotated 90 degrees for numbers more than 4 digits, longer phrases, or sentences. There is a CSS property called text-orientation[2]. Since you're mapping ooxml values to CustomGeometry property, I guess it's not wrong to include them. [1] https://www.w3.org/TR/clreq/#mixed_text_composition_in_vertical_writing_mode [2]https://developer.mozilla.org/en-US/docs/Web/CSS/text-orientation Kind regards, > Regina > -- Mark Hung
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/core/txtnode/justify.cxx | 21 - sw/source/core/txtnode/fntcache.cxx | 20 ++-- sw/source/core/txtnode/justify.cxx |2 +- sw/source/core/txtnode/justify.hxx |2 +- 4 files changed, 24 insertions(+), 21 deletions(-) New commits: commit f770dd18192addf0bbc587c0b2d266e3dd56819b Author: Mark Hung AuthorDate: Fri Jun 10 21:25:07 2022 +0800 Commit: Mark Hung CommitDate: Sun Jun 19 10:10:07 2022 +0200 sw: prefix namespace Justify with sw. Change-Id: Ia813b93dc719a5715804aa06b555c99eaf99b039 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135594 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/core/txtnode/justify.cxx b/sw/qa/core/txtnode/justify.cxx index 0bdcd01e38d5..1565703f1f9e 100644 --- a/sw/qa/core/txtnode/justify.cxx +++ b/sw/qa/core/txtnode/justify.cxx @@ -82,7 +82,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributionHalfSpace) CharWidthArray aExpected{ 720, 851, 573, 720, 639, 612, 573, 720, 480, 720 }; aActual.InvokeWithKernArray( -[&] { Justify::SpaceDistribution(aActual.maArray, aText, 0, 10, 425, 0, false); }); +[&] { sw::Justify::SpaceDistribution(aActual.maArray, aText, 0, 10, 425, 0, false); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } @@ -94,7 +94,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributionNoHalfSpace) CharWidthArray aExpected{ 720, 639, 785, 720, 639, 400, 785, 720, 480, 720 }; aActual.InvokeWithKernArray( -[&] { Justify::SpaceDistribution(aActual.maArray, aText, 0, 10, 425, 0, true); }); +[&] { sw::Justify::SpaceDistribution(aActual.maArray, aText, 0, 10, 425, 0, true); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } @@ -106,7 +106,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributionUnicodeIVS) CharWidthArray aActual{ 1600, 1600, 1600, 0, 0, 1600, 1600, 1600, 1600, 1600, 0, 0 }; CharWidthArray aExpected{ 1800, 1800, 1800, 0, 0, 1800, 1800, 1800, 1800, 1800, 0, 0 }; aActual.InvokeWithKernArray( -[&] { Justify::SpaceDistribution(aActual.maArray, aText, 0, 12, 0, 200, false); }); +[&] { sw::Justify::SpaceDistribution(aActual.maArray, aText, 0, 12, 0, 200, false); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } @@ -121,7 +121,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGrid) 1360, 1040, 1200, 1200, 1200, 1200, 1200, 1200, 1040, 1360, 1200, 1040 }; aActual.InvokeWithKernArray( -[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 12, 400, false); }); +[&] { nDelta = sw::Justify::SnapToGrid(aActual.maArray, aText, 0, 12, 400, false); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); CPPUNIT_ASSERT_EQUAL(tools::Long(160), nDelta); } @@ -136,7 +136,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridMixWidth) CharWidthArray aActual{ 640, 640, 640, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320 }; CharWidthArray aExpected{ 800, 800, 760, 400, 400, 400, 400, 400, 400, 400, 400, 400, 360 }; aActual.InvokeWithKernArray( -[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 13, 400, false); }); +[&] { nDelta = sw::Justify::SnapToGrid(aActual.maArray, aText, 0, 13, 400, false); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); CPPUNIT_ASSERT_EQUAL(tools::Long(80), nDelta); } @@ -150,7 +150,7 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridIVS) CharWidthArray aActual{ 800, 800, 800, 0, 0, 800, 800 }; CharWidthArray aExpected{ 800, 800, 800, 0, 0, 800, 800 }; aActual.InvokeWithKernArray( -[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 7, 400, false); }); +[&] { nDelta = sw::Justify::SnapToGrid(aActual.maArray, aText, 0, 7, 400, false); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); CPPUNIT_ASSERT_EQUAL(tools::Long(0), nDelta); } @@ -159,7 +159,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridEdge1) { CharWidthArray aActual{ 640, 640, 640, 640, 640, 640, 320, 960 }; CharWidthArray aExpected{ 840, 840, 840, 840, 840, 840, 440, 1240 }; -aActual.InvokeWithKernArray([&] { Justify::SnapToGridEdge(aActual.maArray, 8, 400, 40, 0); }); +aActual.InvokeWithKernArray( +[&] { sw::Justify::SnapToGridEdge(aActual.maArray, 8, 400, 40, 0); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } @@ -167,7 +168,8 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridEdge2) { CharWidthArray aActual{ 640, 640, 640, 640, 640, 640, 320, 640 }; CharWidthArray aExpected{ 840, 840, 840, 840, 840, 840, 440, 840 }; -aActual.InvokeWithKernArray([&] { Justify::SnapToGridEdge(aActual.maArray, 8, 100, 40, 80); }); +aActual.InvokeWithKernArray( +[&] { sw::Justify::SnapToGridEdge(aActual.maArray, 8, 100, 40, 80); });
Re: How to write OOXML attribute 'vert' of element to ODF?
Hi Regina, > > My idea is to introduce a new loext:text-direction attribute of the > > element, which can carry each of the values > of > > the OOXML attribute 'vert'. "Each" needs to be discussed, perhaps > > better > > to exclude values eaVert and mongolianVert, which in fact are writing > > modes TB_RL and TB_LR. Possible values would be ("eaVert"), "horz", > > ("mongolianVert"), "vert", "vert270", "wordArtVert" and > > "wordArtVertRtl". > > Both "eaVert" and "mongolianVert" are not pure geometrical, but consider > east asian scripts, so that such characters are excluded from the rotation. > > > It seems to me that: > > - horz, vert, vert270 are effectively horizontal (LR_TB or RL_TB) with > > different rotation angles. > > Yes. That makes it possible to render "vert" and "vert270" by > incorporating the "TextPreRotateAngle" into aTextBoxMatrix in > > https://opengrok.libreoffice.org/xref/core/svx/source/sdr/contact/viewcontactofsdrobjcustomshape.cxx?r=b739bdab#160 > > I found that I was confused with the name "loext:text-direction", and connected it to writing-mode. In different context direction may mean writing direction in Bidi text, as in [1]. Is that new "loext:text-direction" attribute only intended to rotate text for RL_TB writing mode? ( wordArtVert and wordArtVertRtl should also be excluded in that case? ) [1] https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/direction -- Mark Hung
Re: How to write OOXML attribute 'vert' of element to ODF?
Hi Regina, Regina Henschel 於 2022年6月16日 週四 晚上8:49寫道: > Hi all, > > Currently the "vert" attribute of element is connected to > TextPreRotateAngle property. vert="vert" produces TextPreRotateAngle=-90 > and vert="vert270" produces TextPreRotateAngle=-270. When converting it > to ODF it produces draw:text-rotate-angle="-90" and > draw:text-rotate-angle="-270". > > That approach does not work, because the ODF attribute > draw:text-rotate-angle produces a rotation of the text area rectangle, > same as the 'rot' attribute of element in OOXML. Try with > attached file the export to ODF and reload to see the problem. > > For using draw:text-rotate-angle attribute it would be necessary to > change the values of the draw:text-areas attribute in addition. But this > requires introducing additional equations and it conflicts with the > definitions of the predefined shapes of the presets. > > My idea is to introduce a new loext:text-direction attribute of the > element, which can carry each of the values of > the OOXML attribute 'vert'. "Each" needs to be discussed, perhaps better > to exclude values eaVert and mongolianVert, which in fact are writing > modes TB_RL and TB_LR. Possible values would be ("eaVert"), "horz", > ("mongolianVert"), "vert", "vert270", "wordArtVert" and "wordArtVertRtl". > > It's not clear to me why you think eaVert, and mongolianVert should be excluded here. Maybe you can explain further. It seems to me that: - horz, vert, vert270 are effectively horizontal (LR_TB or RL_TB) with different rotation angles. CJK text ( along its upright axis ) is perpendicular to the run direction. - eaVert, wordArtVertRtl : TB_RL. CJK text is parallel to the run direction. - mongolianVert, wordArtVert: TB_LR. CJK text is parallel to the run direction. Both wordArtVertRtl and wordArtVert don't apply rotation to Latin scripts - which I think is something missing in LibreOffice. We don't have the attribute to keep the state. We always render Latin script text in vertical writing as same as in horizontal writing, only rotate the whole run. > The CustomShapeGeometry property, which is a sequence, would get a new > property "TextDirection". Import from OOXML or from ODF-extended would > put the value into it without any rotate-angle calculations. Evaluation > of the attribute would be at rendering time in > > ViewContactOfSdrObjCustomShape::createViewIndependentPrimitive2DSequence(). The current used attribute TextPreRotateAngle would be removed. > Currently it can be used in the CustomShapeGeometry sequence via macro, > but is not published in the API and has no UI. > > Currently we have a confusion of attribute 'vert' and attribute 'rot' > resulting in bug 124437 (assigning the angle of the 'rot' attribute to > TextPreRotateAngle, which produces sheared text) and bug 127457 (value > of attribute 'vert' overwrites value of 'rot'). Therefore I prefer an > enum (or constants in API or string?) so that such errors cannot happen. > > What do you think? > > Kind regards, > Regina > -- Mark Hung
[Libreoffice-commits] core.git: Branch 'libreoffice-7-4' - sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter7.cxx | 19 ++- sw/source/core/text/itrform2.cxx| 13 - 2 files changed, 22 insertions(+), 10 deletions(-) New commits: commit b345858e92351ceb997cf8e77024d7fe573a99c6 Author: Mark Hung AuthorDate: Sat Jun 11 19:52:28 2022 +0800 Commit: Xisco Fauli CommitDate: Thu Jun 16 21:15:29 2022 +0200 tdf#149089 snap to grid if IsSnapToChars() is false for non-CJK scripts. Non Asian text was centered within as many cells as required according to ODF1.2 20.301. But it also required that text should be snapped to grid if style:layout-grid-snap-to is true ( i.e. IsSnapToChars() is false ) per ODF1.2 20.305. That means ODF1.2 20.301 ruled. This patch changes the width of inserted SwKernGridPortion so that non-CJK text aligns to the edge of text grid to make ODF1.2 20.301 rule, an provide more consistent layout result as expected. Change-Id: Id6b4d2b965e20670eb9ddf657d36b8a49073f32a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135654 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 47eff9bf12abf963907b4d3dcb90b73e0ccc646d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135984 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index 8b5a23d1a695..0ac6b0183068 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -2779,11 +2779,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf149089) { createSwDoc(DATA_DIRECTORY, "tdf149089.odt"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); -sal_Int32 nTextPortionWidth = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "width").toInt32(); -sal_Int32 nKernPortionWidth = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32(); -// nKernPortionWidth was about 1/3 of nTextPortionWidth -double nRatio = double(nKernPortionWidth) / nTextPortionWidth; -CPPUNIT_ASSERT_LESS(0.05, nRatio); +sal_Int32 nPorLen1 = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "length").toInt32(); +sal_Int32 nPorLen2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "length").toInt32(); +sal_Int32 nPorLen3 = getXPath(pXmlDoc, "(//SwLinePortion)[3]", "length").toInt32(); +// Two SwTextPortion and one SwKernPortion +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nPorLen1); // SwTextPortion " " +CPPUNIT_ASSERT_EQUAL(sal_Int32(12), nPorLen2); // SwTextPortion "BUG " +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPorLen3); // SwKernPortion + +sal_Int32 nPorWidth1 = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "width").toInt32(); +sal_Int32 nPorWidth2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32(); +sal_Int32 nPorWidth3 = getXPath(pXmlDoc, "(//SwLinePortion)[3]", "width").toInt32(); +sal_Int32 nGridWidth1 = nPorWidth1 / 3; +sal_Int32 nGridWidth2 = (nPorWidth2 + nPorWidth3) / 7; +CPPUNIT_ASSERT_EQUAL(nGridWidth1, nGridWidth2); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index e7bcde5983b8..563ddd5c4c02 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -686,15 +686,18 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo ) 0; const SwTwips nTmpWidth = i * nGridWidth; const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, nRestWidth); -const SwTwips nKernWidth_1 = nKernWidth / 2; +const SwTwips nKernWidth_1 = pGrid->IsSnapToChars() ? +nKernWidth / 2 : 0; OSL_ENSURE( nKernWidth <= nRestWidth, "Not enough space left for adjusting non-asian text in grid mode" ); +if (nKernWidth_1) +{ +pGridKernPortion->Width( pGridKernPortion->Width() + nKernWidth_1 ); +rInf.X( rInf.X() + nKernWidth_1 ); +} -pGridKernPortion->Width( pGridKernPortion->Width() + nKernWidth_1 ); -rInf.X( rInf.X() + nKernWidth_1 ); - -if ( ! bFull ) +if ( ! bFull && nKernWidth - nKernWidth_1 > 0 ) new SwKernPortion( *pPor, static_cast(nKernWidth - nKernWidth_1), false, true );
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter7.cxx | 19 ++- sw/source/core/text/itrform2.cxx| 13 - 2 files changed, 22 insertions(+), 10 deletions(-) New commits: commit 47eff9bf12abf963907b4d3dcb90b73e0ccc646d Author: Mark Hung AuthorDate: Sat Jun 11 19:52:28 2022 +0800 Commit: Mark Hung CommitDate: Thu Jun 16 14:40:05 2022 +0200 tdf#149089 snap to grid if IsSnapToChars() is false for non-CJK scripts. Non Asian text was centered within as many cells as required according to ODF1.2 20.301. But it also required that text should be snapped to grid if style:layout-grid-snap-to is true ( i.e. IsSnapToChars() is false ) per ODF1.2 20.305. That means ODF1.2 20.301 ruled. This patch changes the width of inserted SwKernGridPortion so that non-CJK text aligns to the edge of text grid to make ODF1.2 20.301 rule, an provide more consistent layout result as expected. Change-Id: Id6b4d2b965e20670eb9ddf657d36b8a49073f32a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135654 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index 8b5a23d1a695..0ac6b0183068 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -2779,11 +2779,20 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf149089) { createSwDoc(DATA_DIRECTORY, "tdf149089.odt"); xmlDocUniquePtr pXmlDoc = parseLayoutDump(); -sal_Int32 nTextPortionWidth = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "width").toInt32(); -sal_Int32 nKernPortionWidth = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32(); -// nKernPortionWidth was about 1/3 of nTextPortionWidth -double nRatio = double(nKernPortionWidth) / nTextPortionWidth; -CPPUNIT_ASSERT_LESS(0.05, nRatio); +sal_Int32 nPorLen1 = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "length").toInt32(); +sal_Int32 nPorLen2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "length").toInt32(); +sal_Int32 nPorLen3 = getXPath(pXmlDoc, "(//SwLinePortion)[3]", "length").toInt32(); +// Two SwTextPortion and one SwKernPortion +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nPorLen1); // SwTextPortion " " +CPPUNIT_ASSERT_EQUAL(sal_Int32(12), nPorLen2); // SwTextPortion "BUG " +CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPorLen3); // SwKernPortion + +sal_Int32 nPorWidth1 = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "width").toInt32(); +sal_Int32 nPorWidth2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32(); +sal_Int32 nPorWidth3 = getXPath(pXmlDoc, "(//SwLinePortion)[3]", "width").toInt32(); +sal_Int32 nGridWidth1 = nPorWidth1 / 3; +sal_Int32 nGridWidth2 = (nPorWidth2 + nPorWidth3) / 7; +CPPUNIT_ASSERT_EQUAL(nGridWidth1, nGridWidth2); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index e7bcde5983b8..563ddd5c4c02 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -686,15 +686,18 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo ) 0; const SwTwips nTmpWidth = i * nGridWidth; const SwTwips nKernWidth = std::min(nTmpWidth - nSumWidth, nRestWidth); -const SwTwips nKernWidth_1 = nKernWidth / 2; +const SwTwips nKernWidth_1 = pGrid->IsSnapToChars() ? +nKernWidth / 2 : 0; OSL_ENSURE( nKernWidth <= nRestWidth, "Not enough space left for adjusting non-asian text in grid mode" ); +if (nKernWidth_1) +{ +pGridKernPortion->Width( pGridKernPortion->Width() + nKernWidth_1 ); +rInf.X( rInf.X() + nKernWidth_1 ); +} -pGridKernPortion->Width( pGridKernPortion->Width() + nKernWidth_1 ); -rInf.X( rInf.X() + nKernWidth_1 ); - -if ( ! bFull ) +if ( ! bFull && nKernWidth - nKernWidth_1 > 0 ) new SwKernPortion( *pPor, static_cast(nKernWidth - nKernWidth_1), false, true );
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/core/txtnode/justify.cxx | 25 ++ sw/qa/extras/uiwriter/data/tdf149089.odt |binary sw/qa/extras/uiwriter/uiwriter7.cxx | 11 + sw/source/core/txtnode/fntcache.cxx | 265 +-- sw/source/core/txtnode/justify.cxx | 27 +++ sw/source/core/txtnode/justify.hxx | 10 + 6 files changed, 120 insertions(+), 218 deletions(-) New commits: commit 3e754c07fabd1f74d57f42f273ea46e03dbdc094 Author: Mark Hung AuthorDate: Sun May 29 15:44:49 2022 +0800 Commit: Miklos Vajna CommitDate: Wed Jun 8 08:14:25 2022 +0200 tdf#149089 fix extra mini space in text grid. 1. Create Justify::SnapToGridEdge() to adjust kern array under CJK textgrid GRID_LINES_CHARS mode when snap to chars is off. This function can handle a) Unicode IVS b) rInf.GetSpace() like what CJKJustify() does. c) rInf.GetKern() value for letter spacing. Excluded parts comparing to original kern array adjustment: a) Kana compression under textgrid mode has been removed. Kana compression is used to compress space of punctuation. It doesn't make sense to perform that under textgrid node. b) Inserting nSpaceAdd for CH_BLANK is removed. I don't know its purpose. 2. Use Justify::SnapToGridEdge() in GetTextSize(), GetTextBreak(), DrawText(), GetModelPositionForViewPoint() to adjust kern array consistently. Change-Id: I136a92f513fae05af2fb429e747356ba7eedec7f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135086 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/core/txtnode/justify.cxx b/sw/qa/core/txtnode/justify.cxx index 8f8956f5a736..0bdcd01e38d5 100644 --- a/sw/qa/core/txtnode/justify.cxx +++ b/sw/qa/core/txtnode/justify.cxx @@ -154,4 +154,29 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridIVS) CPPUNIT_ASSERT_EQUAL(aExpected, aActual); CPPUNIT_ASSERT_EQUAL(tools::Long(0), nDelta); } + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridEdge1) +{ +CharWidthArray aActual{ 640, 640, 640, 640, 640, 640, 320, 960 }; +CharWidthArray aExpected{ 840, 840, 840, 840, 840, 840, 440, 1240 }; +aActual.InvokeWithKernArray([&] { Justify::SnapToGridEdge(aActual.maArray, 8, 400, 40, 0); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridEdge2) +{ +CharWidthArray aActual{ 640, 640, 640, 640, 640, 640, 320, 640 }; +CharWidthArray aExpected{ 840, 840, 840, 840, 840, 840, 440, 840 }; +aActual.InvokeWithKernArray([&] { Justify::SnapToGridEdge(aActual.maArray, 8, 100, 40, 80); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridEdgeIVS) +{ +CharWidthArray aActual{ 640, 0, 0, 640, 640, 640, 640, 640 }; +CharWidthArray aExpected{ 840, 0, 0, 840, 840, 840, 840, 840 }; +aActual.InvokeWithKernArray([&] { Justify::SnapToGridEdge(aActual.maArray, 8, 400, 40, 0); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/uiwriter/data/tdf149089.odt b/sw/qa/extras/uiwriter/data/tdf149089.odt new file mode 100644 index ..08cb5a4db594 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf149089.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index 0cb70e91076b..8b5a23d1a695 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -2775,6 +2775,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf149184) xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf149089) +{ +createSwDoc(DATA_DIRECTORY, "tdf149089.odt"); +xmlDocUniquePtr pXmlDoc = parseLayoutDump(); +sal_Int32 nTextPortionWidth = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "width").toInt32(); +sal_Int32 nKernPortionWidth = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32(); +// nKernPortionWidth was about 1/3 of nTextPortionWidth +double nRatio = double(nKernPortionWidth) / nTextPortionWidth; +CPPUNIT_ASSERT_LESS(0.05, nRatio); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 559633126cf8..12613bfd3b7f 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -72,24 +72,6 @@ tools::Long SwFntObj::s_nPixWidth; MapMode* SwFntObj::s_pPixMap = nullptr; static vcl::DeleteOnDeinit< VclPtr > s_pFntObjPixOut {}; -namespace -{ - -tools::Long EvalGridWidthAdd( const SwTextGridItem *const pGrid, -const SwDrawTextInfo , tools::Long nFontWidth ) -{ -const SwDoc* pDoc = rInf.GetShell()->GetDoc(); -const sal_uInt16 nGridWidth = GetGridWidt
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/core/txtnode/justify.cxx | 31 +++ sw/source/core/txtnode/fntcache.cxx | 71 ++--- sw/source/core/txtnode/justify.cxx | 149 +--- sw/source/core/txtnode/justify.hxx | 11 ++ 4 files changed, 139 insertions(+), 123 deletions(-) New commits: commit 7f310b8c2d8d496b38dd62aa6b06e61442e1a2d0 Author: Mark Hung AuthorDate: Mon May 30 08:18:16 2022 +0800 Commit: Miklos Vajna CommitDate: Tue Jun 7 08:51:58 2022 +0200 tdf#149365 tdf#149214 handle IVS and mix width chars in Justify::SnapToGrid correctly, and use it in SwFntObj::GetTextBreak() and SwFntObj::GetModelPositionForViewPoint() to get correct text positions before any further calculation. In fntcache.cxx a simple formula was used to calculate the average width of text grids occupied by ideographs. That's incorrect because 1) for strings containing Unicode IVS, a ideograph is composed of several sal_Unicode and the length of the string is not the same as the number of ideographs contained. 2) The average width doesn't work because character width varies, like ideograph and half-width kana in the test case. Change-Id: I863e8d8e346f555ff184a2f47d615e513b965b34 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135342 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/core/txtnode/justify.cxx b/sw/qa/core/txtnode/justify.cxx index ec63c2b8c5a4..8f8956f5a736 100644 --- a/sw/qa/core/txtnode/justify.cxx +++ b/sw/qa/core/txtnode/justify.cxx @@ -121,8 +121,37 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGrid) 1360, 1040, 1200, 1200, 1200, 1200, 1200, 1200, 1040, 1360, 1200, 1040 }; aActual.InvokeWithKernArray( -[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 12, 400, 14400); }); +[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 12, 400, false); }); CPPUNIT_ASSERT_EQUAL(aExpected, aActual); CPPUNIT_ASSERT_EQUAL(tools::Long(160), nDelta); } + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridMixWidth) +{ +// Related to: tdf#149365 +tools::Long nDelta = 0; +// "中中中ケコサシスセソカケコ" ( mixing fullwidth ideograph and half-width kana ) +static const OUStringLiteral aText += u"\u4e2d\u4e2d\u4e2d\uff79\uff7a\uff7b\uff7c\uff7d\uff7e\uff7f\uff76\uff79\uff7a"; +CharWidthArray aActual{ 640, 640, 640, 320, 320, 320, 320, 320, 320, 320, 320, 320, 320 }; +CharWidthArray aExpected{ 800, 800, 760, 400, 400, 400, 400, 400, 400, 400, 400, 400, 360 }; +aActual.InvokeWithKernArray( +[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 13, 400, false); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +CPPUNIT_ASSERT_EQUAL(tools::Long(80), nDelta); +} + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGridIVS) +{ +// Related to: tdf#149214 +tools::Long nDelta = 0; +static const OUStringLiteral aText = u"\u9053\u9ad8\u4e00\U000E01E2\u5c3a\u5316"; + +CharWidthArray aActual{ 800, 800, 800, 0, 0, 800, 800 }; +CharWidthArray aExpected{ 800, 800, 800, 0, 0, 800, 800 }; +aActual.InvokeWithKernArray( +[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 7, 400, false); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +CPPUNIT_ASSERT_EQUAL(tools::Long(0), nDelta); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 8036af0e56c5..559633126cf8 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -951,7 +951,7 @@ void SwFntObj::DrawText( SwDrawTextInfo ) tools::Long nDelta = Justify::SnapToGrid(aKernArray, rInf.GetText(), sal_Int32(rInf.GetIdx()), - sal_Int32(rInf.GetLen()), nGridWidth, rInf.GetWidth()); + sal_Int32(rInf.GetLen()), nGridWidth, false); if (nDelta) aTextOriginPos.AdjustX(nDelta); @@ -1703,13 +1703,12 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) aTextSize.setHeight( pOutDev->GetTextHeight() + GetFontLeading( rInf.GetShell(), rInf.GetOut() ) ); -tools::Long nAvgWidthPerChar = aTextSize.Width() / sal_Int32(nLn); - -const sal_uLong i = nAvgWidthPerChar ? -( nAvgWidthPerChar - 1 ) / nGridWidth + 1: -1; +std::vector aKernArray; +GetTextArray(*pOutDev, rInf, aKernArray, sal_Int32(rInf.GetLen())); +Justify::SnapToGrid(aKernArray, rInf.GetText(), sal_Int32(rInf.GetIdx()), + sal_Int32(rInf.GetLen()), nGridWidth, true); -aTextSize.setWidth(i * nGridWidth * sal_Int32(nLn)); +
Re: trigger MapMode ScaleX change in writer
Caolán McNamara 於 2022年5月26日 週四 下午6:33寫道: > On Wed, 2022-05-25 at 21:42 +0800, Mark Hung wrote: > > here is another precondition: OutputDevice must be a printer (bPrt > > ==true) > > I think this requires that "Use printer metrics for document > formatting" is enabled to get to this path (tools, options, writer, > compatibility) which I think is "PrinterIndependantLayout" of > "disabled" in the config setting in the file format. > > If I create a new document, enable that "use printer metrics", add some > text and then use the "file, print" dialog and I get a hit of bPrt of > true. If you can reproduce the same I think that backtrace is valuable > to you to attempt a test, e.g. PrintOrPDFExport(pOut, ...) where I see > pOut->GetOutDevType() is OUTPUT_PRINTER (unotxdoc.cxx:2962) so I'd > guess something like > > a doc with "use printer metrics" enabled > ScopedVclPtrInstance printer, > SwViewShell::PrintOrPDFExport(printer, ... > might get you where you want to go > > Now I can make both bPrt and bStretch true, if I enable "Use printer metrics for document formatting" and insert some code in PrintOrPDFExport to set ScaleX and ScaleY. I guess I can continue with that for my unit test. Interestingly, I didn't find any place it is set for the printer. I wonder if it is something that is no longer useful. In that case, we may remove the code completely. Thank you. -- Mark Hung
Re: trigger MapMode ScaleX change in writer
Caolán McNamara 於 2022年5月26日 週四 下午6:33寫道: > On Wed, 2022-05-25 at 21:42 +0800, Mark Hung wrote: > > here is another precondition: OutputDevice must be a printer (bPrt > > ==true) > > I think this requires that "Use printer metrics for document > formatting" is enabled to get to this path (tools, options, writer, > compatibility) which I think is "PrinterIndependantLayout" of > "disabled" in the config setting in the file format. > After I enabled "use printer metrics", bPrt = true is achieved, but I still need XScale changed. Maybe some printers have an option to scale the printed data? I didn't find any options that looks related with CUPS pdf printer or print to file. -- Mark Hung
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/core/txtnode/justify.cxx | 15 sw/source/core/txtnode/fntcache.cxx | 100 +- sw/source/core/txtnode/justify.cxx | 118 sw/source/core/txtnode/justify.hxx | 18 + 4 files changed, 156 insertions(+), 95 deletions(-) New commits: commit 7f77a180dd22e7d07b1840660dc9a6e66463b84f Author: Mark Hung AuthorDate: Sat May 21 21:11:24 2022 +0800 Commit: Mark Hung CommitDate: Wed May 25 16:10:16 2022 +0200 sw: refactor and create Justify::SnapToGrid() Move snapt to grid code from SwFntObj::DrawText() to Justify::SnapToGrid() and create a simple unit test case testSnapToGrid. Note that SnapToGrid() is for "Snap to char is on" case. Change-Id: Ib9b3a08c744216e37dd260434700cbf3f079a0fe Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134707 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/core/txtnode/justify.cxx b/sw/qa/core/txtnode/justify.cxx index 46a52f851efc..88ae8bef3865 100644 --- a/sw/qa/core/txtnode/justify.cxx +++ b/sw/qa/core/txtnode/justify.cxx @@ -109,4 +109,19 @@ CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributionUnicodeIVS) CPPUNIT_ASSERT_EQUAL(aExpected, aActual); } +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSnapToGrid) +{ +tools::Long nDelta = 0; +// "曰〈道高一尺化太平〉云云" +static const OUStringLiteral aText += u"\u66f0\u3008\u9053\u9ad8\u4e00\u5c3a\u5316\u592a\u5e73\u3009\u4e91\u4e91"; +CharWidthArray aActual{ 880, 880, 880, 880, 880, 880, 880, 880, 880, 880, 880, 880 }; +CharWidthArray aExpected{ +1360, 1040, 1200, 1200, 1200, 1200, 1200, 1200, 1040, 1360, 1200, 1040 +}; +aActual.InvokeWithKernArray( +[&] { nDelta = Justify::SnapToGrid(aActual.maArray, aText, 0, 12, 400, 14400); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +CPPUNIT_ASSERT_EQUAL(tools::Long(160), nDelta); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index acac99fb4701..8036af0e56c5 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -604,27 +604,6 @@ void SwFntObj::SetDevFont( const SwViewShell *pSh, OutputDevice& rOut ) * on printer, !Kerning => DrawText * on printer + Kerning => DrawStretchText */ -static sal_uInt8 lcl_WhichPunctuation( sal_Unicode cChar ) -{ -if ( ( cChar < 0x3001 || cChar > 0x3002 ) && -( cChar < 0x3008 || cChar > 0x3011 ) && -( cChar < 0x3014 || cChar > 0x301F ) && - 0xFF62 != cChar && 0xFF63 != cChar ) -// no punctuation -return SwScriptInfo::NONE; -else if ( 0x3001 == cChar || 0x3002 == cChar || - 0x3009 == cChar || 0x300B == cChar || - 0x300D == cChar || 0x300F == cChar || - 0x3011 == cChar || 0x3015 == cChar || - 0x3017 == cChar || 0x3019 == cChar || - 0x301B == cChar || 0x301E == cChar || - 0x301F == cChar || 0xFF63 == cChar ) -// right punctuation -return SwScriptInfo::SPECIAL_RIGHT; - -return SwScriptInfo::SPECIAL_LEFT; -} - static bool lcl_IsMonoSpaceFont( const vcl::RenderContext& rOut ) { const tools::Long nWidth1 = rOut.GetTextWidth( OUString( u'\x3008' ) ); @@ -970,81 +949,12 @@ void SwFntObj::DrawText( SwDrawTextInfo ) else GetTextArray(rInf.GetOut(), rInf, aKernArray); -// Change the average width per character to an appropriate grid width -// basically get the ratio of the avg width to the grid unit width, then -// multiple this ratio to give the new avg width - which in this case -// gives a new grid width unit size - -tools::Long nAvgWidthPerChar = aKernArray[sal_Int32(rInf.GetLen()) - 1] / sal_Int32(rInf.GetLen()); - -const sal_uLong nRatioAvgWidthCharToGridWidth = nAvgWidthPerChar ? -( nAvgWidthPerChar - 1 ) / nGridWidth + 1: -1; - -nAvgWidthPerChar = nRatioAvgWidthCharToGridWidth * nGridWidth; - -// the absolute end position of the first character is also its width -tools::Long nCharWidth = aKernArray[ 0 ]; -sal_uLong nHalfWidth = nAvgWidthPerChar / 2; - -tools::Long nNextFix=0; - -// we work out the start position (origin) of the first character, -// and we set the next "fix" offset to half the width of the char. -// The exceptions are for punctuation characters that are not centered -// so in these cases we just add half a regular "average" character width -// to the first characters actual width to allow the next chara
Re: trigger MapMode ScaleX change in writer
Hi Luboš, Luboš Luňák 於 2022年5月25日 週三 下午12:13寫道: > On Wednesday 25 of May 2022, Mark Hung wrote: > > Hi, > > > > I'm refactoring SwFntObj::DrawText() in > sw/soucre/core/txtnode/fntcache.c, > > and writing unit test for it. I'm looking for a way to trigger the > > situation that > > GetMapMode().GetScaleX() doesn't equal to 1. > > Getting GetScaleX() not be 1 is easy here, I just need to open a new > Writer > document and Ctrl+wheel to zoom. Are you sure that is the part you have a > problem reproducing? > > You're right. GetScaleX() changes as soon as I zoom the document in or out. I have just neglected that there is another precondition: OutputDevice must be a printer (bPrt ==true) I'm still trying to figure out how to have a OutputDevice use a different scale value. I'm using a Linux VM so I don't know if a physical printer can make a difference. > -- > Luboš Luňák > l.lu...@collabora.com > Thank you. -- Mark Hung
trigger MapMode ScaleX change in writer
Hi, I'm refactoring SwFntObj::DrawText() in sw/soucre/core/txtnode/fntcache.c, and writing unit test for it. I'm looking for a way to trigger the situation that GetMapMode().GetScaleX() doesn't equal to 1. To be more specific, to trigger the case bStretch = true for following code snippet. const Fraction aTmp( 1, 1 ); bool bStretch = rInf.GetWidth() && (rInf.GetLen() > TextFrameIndex(1)) && bPrt && ( aTmp != rInf.GetOut().GetMapMode().GetScaleX() ); The bStretch decides whether to draw stretched text. Does anyone know how to do trigger the situation? It seems that none of the sw unit tests trigger that, scaling in the character property, or zoom in, print preview cause the value to change. -- Mark Hung
[Libreoffice-commits] core.git: sw/CppunitTest_sw_core_txtnode.mk sw/qa
sw/CppunitTest_sw_core_txtnode.mk |2 sw/qa/core/txtnode/justify.cxx| 112 ++ 2 files changed, 114 insertions(+) New commits: commit f94ba53cd446a80f3d07a5d67740129fde831018 Author: Mark Hung AuthorDate: Fri May 13 22:43:03 2022 +0800 Commit: Miklos Vajna CommitDate: Mon May 23 08:48:04 2022 +0200 tdf#149017 Justify::SpaceDistribution unit tests. Cerate new unit test cases for core/txtnode/justify.cxx and Justify namespace. It implements basic utility to convert between KernArray and char width array, and can serve for kern array related tests. Change-Id: I3da172853c6d8aca517247af34b29f712d3b6e62 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134298 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/CppunitTest_sw_core_txtnode.mk b/sw/CppunitTest_sw_core_txtnode.mk index 441e415267b7..4fb34a695656 100644 --- a/sw/CppunitTest_sw_core_txtnode.mk +++ b/sw/CppunitTest_sw_core_txtnode.mk @@ -15,6 +15,7 @@ $(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 \ +sw/qa/core/txtnode/justify \ )) $(eval $(call gb_CppunitTest_use_libraries,sw_core_txtnode, \ @@ -44,6 +45,7 @@ $(eval $(call gb_CppunitTest_use_externals,sw_core_txtnode,\ $(eval $(call gb_CppunitTest_set_include,sw_core_txtnode,\ -I$(SRCDIR)/sw/inc \ -I$(SRCDIR)/sw/source/core/inc \ +-I$(SRCDIR)/sw/source/core/txtnode \ -I$(SRCDIR)/sw/source/uibase/inc \ -I$(SRCDIR)/sw/qa/inc \ $$(INCLUDE) \ diff --git a/sw/qa/core/txtnode/justify.cxx b/sw/qa/core/txtnode/justify.cxx new file mode 100644 index ..46a52f851efc --- /dev/null +++ b/sw/qa/core/txtnode/justify.cxx @@ -0,0 +1,112 @@ +/* -*- 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 +#include +#include + +namespace +{ +/// Covers sw/source/core/txtnode/justify fixes. +class SwCoreJustifyTest : public SwModelTestBase +{ +}; + +/// CharWidthArray: store char widths because they are more readable. +class CharWidthArray +{ +public: +std::vector maArray; +template +CharWidthArray(Args&&... args) +: maArray{ std::forward(args)... } +{ +} +template void InvokeWithKernArray(Function f); +void ConvertToKernArray(); +void ConvertToCharWidths(); +}; + +inline bool operator==(const CharWidthArray& lhs, const CharWidthArray& rhs) +{ +return lhs.maArray == rhs.maArray; +} + +std::ostream& operator<<(std::ostream& rStrm, const CharWidthArray& rCharWidthArray) +{ +const std::vector& rArray(rCharWidthArray.maArray); +sal_Int32 nLen = rArray.size(); +rStrm << "{ "; +for (sal_Int32 i = 0; i < nLen; ++i) +{ +rStrm << rArray[i]; +rStrm << (i < nLen - 1 ? ", " : " "); +} +rStrm << "}"; +return rStrm; +} + +void CharWidthArray::ConvertToKernArray() +{ +for (sal_Int32 i = 1; i < sal_Int32(maArray.size()); ++i) +maArray[i] += maArray[i - 1]; +} + +void CharWidthArray::ConvertToCharWidths() +{ +for (sal_Int32 i = maArray.size() - 1; i > 0; --i) +maArray[i] -= maArray[i - 1]; +} + +/// Convert maArray to kern array values, then invoke the function, and convert it back. +template void CharWidthArray::InvokeWithKernArray(Function f) +{ +ConvertToKernArray(); +f(); +ConvertToCharWidths(); +} +} + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributionHalfSpace) +{ +// Related to: tdf#149017 +static const OUStringLiteral aText = u"ne del pro"; +CharWidthArray aActual{ 720, 639, 360, 720, 639, 400, 360, 720, 480, 720 }; +CharWidthArray aExpected{ 720, 851, 573, 720, 639, 612, 573, 720, 480, 720 }; + +aActual.InvokeWithKernArray( +[&] { Justify::SpaceDistribution(aActual.maArray, aText, 0, 10, 425, 0, false); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributionNoHalfSpace) +{ +// Related to: tdf#149017 +static const OUStringLiteral aText = u"ne del pro"; +CharWidthArray aActual{ 720, 639, 360, 720, 639, 400, 360, 720, 480, 720 }; +CharWidthArray aExpected{ 720, 639, 785, 720, 639, 400, 785, 720, 480, 720 }; + +aActual.InvokeWithKernArray( +[&] { Justify::SpaceDistribution(aActual.maArray, aText, 0, 10, 425, 0, true); }); +CPPUNIT_ASSERT_EQUAL(aExpected, aActual); +} + +CPPUNIT_TEST_FIXTURE(SwCoreJustifyTest, testSpaceDistributi
[Libreoffice-commits] core.git: sw/source
sw/source/core/txtnode/justify.hxx |1 - 1 file changed, 1 deletion(-) New commits: commit 4122d2b96f98f3b7b7332f6c1b047e03d0744f95 Author: Mark Hung AuthorDate: Thu May 19 20:13:28 2022 +0800 Commit: Tomaž Vajngerl CommitDate: Thu May 19 17:15:38 2022 +0200 remove using namespace css in justify.hxx. Change-Id: I22b582ed88d43ef5299443914dd28b8db61d1b70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134639 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl diff --git a/sw/source/core/txtnode/justify.hxx b/sw/source/core/txtnode/justify.hxx index a51601b970a4..e98ecb5216c2 100644 --- a/sw/source/core/txtnode/justify.hxx +++ b/sw/source/core/txtnode/justify.hxx @@ -10,7 +10,6 @@ #pragma once #include -using namespace ::com::sun::star; namespace Justify { /// Distribute space between words and letters.
[Libreoffice-commits] core.git: sw/Library_sw.mk sw/source
sw/Library_sw.mk|1 sw/source/core/txtnode/fntcache.cxx | 67 ++ sw/source/core/txtnode/justify.cxx | 90 sw/source/core/txtnode/justify.hxx | 31 4 files changed, 128 insertions(+), 61 deletions(-) New commits: commit f8560e09006cec5cc6ef26ccbf4f21aa28c22ac3 Author: Mark Hung AuthorDate: Fri May 13 00:06:49 2022 +0800 Commit: Mark Hung CommitDate: Wed May 18 14:32:06 2022 +0200 tdf#149017 fix space distribution in SwFntObj::DrawText() - Fix logic problem for the last element. - Some glyphs may be made of many sal_Unicode ( ex. Unicode IVS ), take care ( fix ) of the following case a) 1 as the second glyph b) n-1 as the previous glyph. c) nCnt-1 as the last glyph. - Move the code to justify.cxx and its own namespace. Change-Id: Ice2236a54e8290a489fb2d887a326ccc4768213e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134243 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index 9ce3a482b766..eec16fd5612c 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -437,6 +437,7 @@ $(eval $(call gb_Library_add_exception_objects,sw,\ sw/source/core/txtnode/atrtox \ sw/source/core/txtnode/attrlinebreak \ sw/source/core/txtnode/chrfmt \ +sw/source/core/txtnode/justify \ sw/source/core/txtnode/fmtatr2 \ sw/source/core/txtnode/fntcache \ sw/source/core/txtnode/fntcap \ diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 838547282770..acac99fb4701 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -56,6 +56,7 @@ #include #include #include +#include "justify.hxx" using namespace ::com::sun::star; @@ -1553,7 +1554,6 @@ void SwFntObj::DrawText( SwDrawTextInfo ) else nCnt = nCnt - rInf.GetIdx(); nCnt = std::min(nCnt, rInf.GetLen()); -tools::Long nKernSum = rInf.GetKern(); sal_Unicode cChPrev = rInf.GetText()[sal_Int32(rInf.GetIdx())]; // In case of a single underlined space in justified text, @@ -1578,67 +1578,11 @@ void SwFntObj::DrawText( SwDrawTextInfo ) } else { -// nSpaceSum contains the sum of the intermediate space distributed -// among Spaces by the Justification. -// The Spaces themselves will be positioned in the middle of the -// intermediate space, hence the nSpace/2. -// In case of word-by-word underlining they have to be positioned -// at the beginning of the intermediate space, so that the space -// is not underlined. -// A Space at the beginning or end of the text must be positioned -// before (resp. after) the whole intermediate space, otherwise -// the underline/strike-through would have gaps. -tools::Long nSpaceSum = 0; -// in word line mode and for Arabic, we disable the half space trick: -const tools::Long nHalfSpace = m_pPrtFont->IsWordLineMode() || bNoHalfSpace ? 0 : nSpaceAdd / 2; -const tools::Long nOtherHalf = nSpaceAdd - nHalfSpace; -if ( nSpaceAdd && ( cChPrev == CH_BLANK ) ) -nSpaceSum = nHalfSpace; -for (sal_Int32 i = 1; i < sal_Int32(nCnt); ++i, nKernSum += rInf.GetKern()) -{ -sal_Unicode nCh = rInf.GetText()[sal_Int32(rInf.GetIdx()) + i]; - -// Apply SpaceSum -if (cChPrev == CH_BLANK) -{ -// no Pixel is lost: -nSpaceSum += nOtherHalf; -} - -if (nCh == CH_BLANK) -{ -if (i + 1 == sal_Int32(nCnt)) -nSpaceSum += nSpaceAdd; -else -nSpaceSum += nHalfSpace; -} - -tools::Long nOldValue = aKernArray[i-1]; - -cChPrev = nCh; -aKernArray[i-1] += nKernSum + nSpaceSum; -// In word line mode and for Arabic, we disabled the half space trick. If a portion -// ends with a blank, the full nSpaceAdd value has been added to the character in -// front of the blank. This leads to painting artifacts, therefore we remove the -// nSpaceAdd value again: -if ((bNoHalfSpace || m_pPrtFont->IsWordLineMode()) && i+1 == sal_Int32(nCnt) && nCh == CH_BLANK) -aKernArray[i-1] = aKernArray[i-1] - nSpaceAdd; - -// Some glyph items use more than one sal_Unicode, eg. CJK ideograph extensions -// or unicode IVS. Don't assign space multiple times in case the original text array -// h
[Libreoffice-commits] core.git: sw/source
sw/source/core/txtnode/fntcache.cxx |2 ++ 1 file changed, 2 insertions(+) New commits: commit beb3b39ddf04d90b4c18cb15c35dccac35f4dcb7 Author: Mark Hung AuthorDate: Wed May 18 06:02:34 2022 +0800 Commit: Caolán McNamara CommitDate: Wed May 18 09:50:16 2022 +0200 fix CID#1504441 for SwFntObj. Change-Id: Ia5dfb07e2c3e980f6fd8664f648ef96aa2c0d345 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134501 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index b3fe68906821..838547282770 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -112,6 +112,8 @@ SwFntObj::SwFntObj(const SwSubFont , std::uintptr_t nFontCacheId, SwViewSh , m_nScrHeight(0) , m_nPrtHeight(USHRT_MAX) , m_nPropWidth(rFont.GetPropWidth()) +, m_nScrHangingBaseline(0) +, m_nPrtHangingBaseline(0) { m_nZoom = pSh ? pSh->GetViewOptions()->GetZoom() : USHRT_MAX; m_bSymbol = RTL_TEXTENCODING_SYMBOL == m_aFont.GetCharSet();
[Libreoffice-commits] core.git: vcl/source
vcl/source/font/fontmetric.cxx |1 + 1 file changed, 1 insertion(+) New commits: commit 6e9d183d4c1107d15dd0d5941cdca79cb4731693 Author: Mark Hung AuthorDate: Wed May 18 06:00:18 2022 +0800 Commit: Caolán McNamara CommitDate: Wed May 18 09:49:34 2022 +0200 fix CID#1504438 for ImplFontMetricData Change-Id: I037ad60c4bc2189ba6e93648ba9e168c6242efe7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134500 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index 1fddb1195ab7..1c1bb932f56c 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -147,6 +147,7 @@ ImplFontMetricData::ImplFontMetricData( const vcl::font::FontSelectPattern& rFon , mnExtLeading( 0 ) , mnSlant( 0 ) , mnMinKashida( 0 ) +, mnHangingBaseline( 0 ) , mbFullstopCentered( false ) , mnBulletOffset( 0 ) , mnUnderlineSize( 0 )
[Libreoffice-commits] core.git: vcl/source
vcl/source/gdi/sallayout.cxx | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) New commits: commit 01c14670554b2c93de79f07a71a3f94d81a2178d Author: Mark Hung AuthorDate: Fri May 13 00:11:37 2022 +0800 Commit: Mark Hung CommitDate: Tue May 17 13:56:28 2022 +0200 vcl/GetTextBreak(): don't add extra width if char width is 0. Char width is 0 when multiple characters made up of one glyph. Don't insert extra space in that case. Change-Id: Ieb37aa8a4fffc534d84acf994a231e801e89f782 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134244 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 17d5bfbb6c20..81897ac68bbd 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -492,10 +492,16 @@ sal_Int32 GenericSalLayout::GetTextBreak( DeviceCoordinate nMaxWidth, DeviceCoor DeviceCoordinate nWidth = 0; for( int i = mnMinCharPos; i < mnEndCharPos; ++i ) { -nWidth += aCharWidths[ i - mnMinCharPos ] * nFactor; -if( nWidth > nMaxWidth ) -return i; -nWidth += nCharExtra; +DeviceCoordinate nDelta = aCharWidths[ i - mnMinCharPos ] * nFactor; + +if (nDelta != 0) +{ +nWidth += nDelta; +if( nWidth > nMaxWidth ) +return i; + +nWidth += nCharExtra; +} } return -1;
[Libreoffice-commits] core.git: sw/source
sw/source/core/inc/fntcache.hxx |3 +++ sw/source/core/inc/swfont.hxx |4 sw/source/core/text/inftxt.hxx |7 +++ sw/source/core/text/itrform2.cxx|3 +++ sw/source/core/text/itrpaint.cxx|2 +- sw/source/core/text/itrtxt.cxx |9 - sw/source/core/text/porlin.cxx |1 + sw/source/core/text/porlin.hxx |5 + sw/source/core/txtnode/fntcache.cxx | 17 + sw/source/core/txtnode/swfont.cxx |6 ++ 10 files changed, 55 insertions(+), 2 deletions(-) New commits: commit fb8eb0ad9c3a5957a6e131490a7a8c97e5353ba2 Author: Mark Hung AuthorDate: Sun May 1 14:07:01 2022 +0800 Commit: Mark Hung CommitDate: Fri May 13 01:32:22 2022 +0200 tdf#104930 aligning CTL text with hanging baseline. 1. SwTextSizeInfo::GetHangingBaseline() calls SwFont::GetHangingBaseline() to obtain the hanging baseline value. Only CTL script handled, it always return 0 for other two scripts. Eventually Outdev::GetFontMetric() and TextMetric::GetHangingBaseline() are called to obtain the hanging baseline value from vcl. 2. SwTextFormatter::CalcAscent() sets the baseline value for the portion via SwTextSizeInfo::GetHangingBaseline(). 3. SwTextFormatter::InsertPortion() sets the maximum baseline value for the whole line. 4. SwTextCursor::AdjustBaseLine() calculates the new baseline in case hanging baseline is available. Change-Id: I1aae7a34dfc953227b7873fc8e3af5cc7e2fbbff Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133668 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/source/core/inc/fntcache.hxx b/sw/source/core/inc/fntcache.hxx index 4f58be568951..bea6663e1420 100644 --- a/sw/source/core/inc/fntcache.hxx +++ b/sw/source/core/inc/fntcache.hxx @@ -74,6 +74,8 @@ class SwFntObj final : public SwCacheObj sal_uInt16 m_nScrHeight; sal_uInt16 m_nPrtHeight; sal_uInt16 m_nPropWidth; +sal_uInt16 m_nScrHangingBaseline; +sal_uInt16 m_nPrtHangingBaseline; sal_uInt16 m_nZoom; bool m_bSymbol : 1; bool m_bPaintBlank : 1; @@ -97,6 +99,7 @@ public: sal_uInt16 GetFontAscent( const SwViewShell *pSh, const OutputDevice& rOut ); sal_uInt16 GetFontHeight( const SwViewShell *pSh, const OutputDevice& rOut ); sal_uInt16 GetFontLeading( const SwViewShell *pSh, const OutputDevice& rOut ); +sal_uInt16 GetFontHangingBaseline( const SwViewShell *pSh, const OutputDevice& rOut ); void GuessLeading( const SwViewShell& rSh, const FontMetric& rMet ); diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx index 40a4c2e8d66c..38936574a471 100644 --- a/sw/source/core/inc/swfont.hxx +++ b/sw/source/core/inc/swfont.hxx @@ -72,6 +72,7 @@ class SwSubFont final : public SvxFont bool IsSymbol( SwViewShell const *pSh ); sal_uInt16 GetAscent( SwViewShell const *pSh, const OutputDevice& rOut ); sal_uInt16 GetHeight( SwViewShell const *pSh, const OutputDevice& rOut ); +sal_uInt16 GetHangingBaseline( SwViewShell const *pSh, const OutputDevice& rOut ); Size GetTextSize_( SwDrawTextInfo& rInf ); Size GetCapitalSize( SwDrawTextInfo& rInf ); void DrawText_( SwDrawTextInfo , const bool bGrey ); @@ -328,6 +329,9 @@ public: sal_uInt16 GetHeight( SwViewShell const *pSh, const OutputDevice& rOut ) { return m_aSub[m_nActual].GetHeight( pSh, rOut ); } +sal_uInt16 GetHangingBaseline( SwViewShell const *pSh, const OutputDevice& rOut ) +{ return m_nActual == SwFontScript::CTL ? m_aSub[m_nActual].GetHangingBaseline( pSh, rOut ) : 0; } + void Invalidate() { m_bFontChg = m_bOrgChg = true; } diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx index 7c7bf57afa56..1621b4f35a8f 100644 --- a/sw/source/core/text/inftxt.hxx +++ b/sw/source/core/text/inftxt.hxx @@ -267,6 +267,7 @@ public: vcl::text::TextLayoutCache const*) const; sal_uInt16 GetAscent() const; +sal_uInt16 GetHangingBaseline() const; TextFrameIndex GetIdx() const { return m_nIdx; } void SetIdx(const TextFrameIndex nNew) { m_nIdx = nNew; } @@ -715,6 +716,12 @@ inline sal_uInt16 SwTextSizeInfo::GetTextHeight() const return const_cast(GetFont())->GetHeight( m_pVsh, *GetOut() ); } +inline sal_uInt16 SwTextSizeInfo::GetHangingBaseline() const +{ +assert(GetOut()); +return const_cast(GetFont())->GetHangingBaseline( m_pVsh, *GetOut() ); +} + inline SwPosSize SwTextSizeInfo::GetTextSize( const OUString ) const { return GetTextSize(m_pOut, nullptr, rText, TextFrameIndex(0), TextFrameIndex(rText.getLength())); diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 52d13e690481..e7bcde5983b8 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -341,6 +341,
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/uiwriter/uiwriter4.cxx |5 +- sw/source/core/text/itrform2.cxx|4 +- sw/source/core/txtnode/fntcache.cxx | 64 3 files changed, 27 insertions(+), 46 deletions(-) New commits: commit 3dcf845691ee55621a9475d7c39cbc63611c3f7a Author: Mark Hung AuthorDate: Sun May 8 12:56:16 2022 +0800 Commit: Mark Hung CommitDate: Thu May 12 09:15:48 2022 +0200 tdf#148940 improve non Snap-to-char mode textgrid layout. - Revert b647f9f4bcb24ed9b71c77038da6b754b8d42eb7 , i.e. tdf#107362 don't insert kern if snap to char is not checked. This includes: a) Revert to insert kern portion to align the next CJK text portion to the next grid cell border. b) Revert none snap-to-char code to proecess CJK script only as before. Latin and CTL scripts are processed as witnout text grid. - EvalGridWidthAdd() now uses the 0th element of kern array as the glyph width to calculate the distance to the nearest cell border. This makes layout more accurate and do not generate extra spaces, allow testTdf107362 to pass. - SwFont::GetTextBreak() non snap-to-char mode now uses the same code as snap-to-char mode to calculate the accommodable text length. This fix one excess character per line problem for non snap-to-char mode. - Update testTdf107025 because the character in the test case occupies more than one text grid cells. Layout change has been verified. - tdf#107446 breaks again because of the patch. It needs different solution for Word compatibility. Change-Id: I7fadb065b9cce2d71aaaed39be2881c43d8e4db4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134001 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index e3a625be7b30..ae650c84f234 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -1836,10 +1836,11 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf107025) return; CPPUNIT_ASSERT(!parseDump("(//SwLinePortion)[2]", "width").isEmpty()); -// Width of the second line is expected to be 9 times of the first. sal_Int32 nWidth2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32(); +sal_Int32 nRatio = nWidth2 / nWidth1; -CPPUNIT_ASSERT_EQUAL(sal_Int32(9), nWidth2 / nWidth1); +CPPUNIT_ASSERT(nRatio >= 9); // Occupy at least 9 cells. +CPPUNIT_ASSERT(nRatio < 18); // Occupy at most 18 cells. } CPPUNIT_TEST_FIXTURE(SwUiWriterTest4, testTdf107362) diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index f9e6f45a4433..52d13e690481 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -507,7 +507,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo ) } } } -else if ( bHasGrid && pGrid->IsSnapToChars() && ! pGridKernPortion && ! m_pMulti && ! pPor->InTabGrp() ) +else if ( bHasGrid && ! pGridKernPortion && ! m_pMulti && ! pPor->InTabGrp() ) { // insert a grid kerning portion pGridKernPortion = pPor->IsKernPortion() ? @@ -650,7 +650,7 @@ void SwTextFormatter::BuildPortions( SwTextFormatInfo ) } } -if ( bHasGrid && pGrid->IsSnapToChars() && pPor != pGridKernPortion && ! m_pMulti && ! pPor->InTabGrp() ) +if ( bHasGrid && pPor != pGridKernPortion && ! m_pMulti && ! pPor->InTabGrp() ) { TextFrameIndex const nTmp = rInf.GetIdx() + pPor->GetLen(); const SwTwips nRestWidth = rInf.Width() - rInf.X() - pPor->Width(); diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index cfcf549c45b7..5623a35e1677 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -74,21 +74,15 @@ static vcl::DeleteOnDeinit< VclPtr > s_pFntObjPixOut {}; namespace { -tools::Long EvalGridWidthAdd( const SwTextGridItem *const pGrid, const SwDrawTextInfo ) +tools::Long EvalGridWidthAdd( const SwTextGridItem *const pGrid, +const SwDrawTextInfo , tools::Long nFontWidth ) { -SwDocShell* pDocShell = rInf.GetShell()->GetDoc()->GetDocShell(); -SfxStyleSheetBasePool* pBasePool = pDocShell->GetStyleSheetPool(); - -SfxStyleSheetBase* pStyle = pBasePool->Find(SwResId(STR_POOLCOLL_STANDARD), SfxStyleFamily::Para); -SfxItemSet& aTmpSet = pStyle->GetItemSet(); -const SvxFontHeightItem = aTmpSet.Get(RES_CHRATR_CJK_FONTSIZE); - const SwDoc* pDoc = rInf.GetShell()->GetDoc(); const sal_uInt16 nGridWidth = GetGrid
[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win
include/vcl/metric.hxx |3 +++ vcl/inc/impfontmetricdata.hxx |3 +++ vcl/qt5/QtGraphics_Text.cxx|1 + vcl/quartz/ctfonts.cxx |1 + vcl/source/font/fontmetric.cxx | 21 + vcl/source/outdev/font.cxx |1 + vcl/unx/generic/glyphs/freetype_glyphcache.cxx |1 + vcl/win/gdi/salfont.cxx|1 + 8 files changed, 32 insertions(+) New commits: commit 5f92e8cf3da6b5f66b6ef23219fcc91d2ad7c754 Author: Mark Hung AuthorDate: Sun May 1 13:50:00 2022 +0800 Commit: Mark Hung CommitDate: Tue May 10 15:01:25 2022 +0200 tdf#104930 Implement TextMetric::GetHangingBaseline. The text metric value is initialized in ImplFontMetricData::ImplInitBaselines() using harfbuzz API hb_ot_layout_get_baseline. It can't handle multiple hanging baselines of the same font for different scripts yet because the script is fixed to HB_SCRIPT_UNKOWN. Change-Id: I2574f0dba45501187064b9341c573159914a4a17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133667 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/include/vcl/metric.hxx b/include/vcl/metric.hxx index a89e8eedfb0c..36964eef2347 100644 --- a/include/vcl/metric.hxx +++ b/include/vcl/metric.hxx @@ -47,6 +47,7 @@ public: tools::LongGetLineHeight() const { return mnLineHeight; } // TODO this is ascent + descnt tools::LongGetSlant() const{ return mnSlant; } tools::LongGetBulletOffset() const { return mnBulletOffset; } +tools::LongGetHangingBaseline() const { return mnHangingBaseline; } voidSetAscent( tools::Long nAscent ) { mnAscent = nAscent; } voidSetDescent( tools::Long nDescent ) { mnDescent = nDescent; } @@ -55,6 +56,7 @@ public: voidSetLineHeight( tools::Long nHeight ) { mnLineHeight = nHeight; } // TODO this is ascent + descent voidSetSlant( tools::Long nSlant ) { mnSlant = nSlant; } voidSetBulletOffset( tools::Long nOffset ) { mnBulletOffset = nOffset; } +voidSetHangingBaseline( tools::Long nBaseline ){ mnHangingBaseline = nBaseline; } boolIsFullstopCentered() const { return mbFullstopCentered; } @@ -74,6 +76,7 @@ private: tools::LongmnLineHeight; // Ascent+Descent+EmphasisMark tools::LongmnSlant; // Slant tools::LongmnBulletOffset;// Offset for non-printing character +tools::LongmnHangingBaseline; // Offset from Romn baseline to hanigng baseline. boolmbFullstopCentered; }; diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx index aca6da417367..0ad29f3e821e 100644 --- a/vcl/inc/impfontmetricdata.hxx +++ b/vcl/inc/impfontmetricdata.hxx @@ -58,6 +58,7 @@ public: tools::LongGetExternalLeading() const { return mnExtLeading; } int GetSlant() const { return mnSlant; } tools::LongGetMinKashida() const { return mnMinKashida; } +tools::LongGetHangingBaseline() const { return mnHangingBaseline; } voidSetSlant(int nSlant) { mnSlant=nSlant; } voidSetMinKashida( tools::Long nMinKashida ) { mnMinKashida=nMinKashida; } @@ -99,6 +100,7 @@ public: voidImplInitAboveTextLineSize(); voidImplInitFlags( const OutputDevice* pDev ); voidImplCalcLineSpacing(LogicalFontInstance *pFontInstance); +voidImplInitBaselines(LogicalFontInstance *pFontInstance); private: boolShouldUseWinMetrics(const vcl::TTGlobalFontInfo& rInfo) const; @@ -115,6 +117,7 @@ private: tools::LongmnExtLeading; // External Leading int mnSlant;// Slant (Italic/Oblique) tools::LongmnMinKashida; // Minimal width of kashida (Arabic) +tools::LongmnHangingBaseline; // Offset of haning baseline to Romn baseline // font attributes queried from the font instance boolmbFullstopCentered; diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx index 02158fca29db..9859ff02f061 100644 --- a/vcl
[Libreoffice-commits] core.git: editeng/source
editeng/source/editeng/impedit2.cxx | 17 - editeng/source/items/svxfont.cxx| 66 2 files changed, 61 insertions(+), 22 deletions(-) New commits: commit 88aeb649ed33a1a67547419f9b76c2c892dd2ee1 Author: Mark Hung AuthorDate: Sun Apr 17 12:56:06 2022 +0800 Commit: Mark Hung CommitDate: Wed Apr 20 13:07:31 2022 +0200 tdf#148630 fix text layout and cursor position for IVS+spacing in Impress. This involves: 1. SvxFont::QuickGetTextSize() and SvxFont::GetPhysTxtSize(): insert space only when text array value changes. Same value indicates diffferent characters of the same glyph item (e.x. surrogate pairs, unicode IVS that is made of a base character and a selector. ). 2. ImpEditEngine::GetChar(): fix a logical mistake that tried to increase the index by 1 than checking the value of character position. To advance the index we always need to check the position first. Change-Id: I4e3547413ce361ae7801c957e6d589776ebed114 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133102 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index 2f44eaf5468a..1471b4f291c1 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -4001,16 +4001,17 @@ sal_Int32 ImpEditEngine::GetChar( tools::Long nDiffRight = nTmpPosMax - nXInPortion; OSL_ENSURE( nDiffLeft >= 0, "DiffLeft negative" ); OSL_ENSURE( nDiffRight >= 0, "DiffRight negative" ); -nOffset = ( bSmart && ( nDiffRight < nDiffLeft ) ) ? x+1 : x; -// I18N: If there are character position with the length of 0, -// they belong to the same character, we can not use this position as an index. -// Skip all 0-positions, cheaper than using XBreakIterator: -if ( nOffset < nMax ) + +if (bSmart && nDiffRight < nDiffLeft) { -const tools::Long nX = pLine->GetCharPosArray()[nOffset]; -while ( ( (nOffset+1) < nMax ) && ( pLine->GetCharPosArray()[nOffset+1] == nX ) ) -nOffset++; +// I18N: If there are character position with the length of 0, +// they belong to the same character, we can not use this position as an index. +// Skip all 0-positions, cheaper than using XBreakIterator: +tools::Long nX = pLine->GetCharPosArray()[nTmpCurIndex + x]; +while(x < nMax && pLine->GetCharPosArray()[nTmpCurIndex + x] == nX) +++x; } +nOffset = x; break; } } diff --git a/editeng/source/items/svxfont.cxx b/editeng/source/items/svxfont.cxx index 4b549d49d711..839240f828df 100644 --- a/editeng/source/items/svxfont.cxx +++ b/editeng/source/items/svxfont.cxx @@ -30,6 +30,15 @@ #include #include #include +#include + +static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, std::vector* pDXAry, + sal_Int32 nIndex, sal_Int32 nLen ) + +{ +const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(pOut, rStr, nIndex, nLen); +return pOut->GetTextArray( rStr, pDXAry, nIndex, nLen, nullptr, layoutGlyphs); +} SvxFont::SvxFont() { @@ -433,7 +442,21 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut, const OUString , } if( IsKern() && ( nLen > 1 ) ) -aTxtSize.AdjustWidth( ( nLen-1 ) * tools::Long( nKern ) ); +{ +std::vector aDXArray(nLen); +GetTextArray(pOut, rTxt, , nIdx, nLen); +tools::Long nOldValue = aDXArray[0]; +sal_Int32 nSpaceCount = 0; +for(sal_Int32 i = 1; i < nLen; ++i) +{ +if (aDXArray[i] != nOldValue) +{ +nOldValue = aDXArray[i]; +++nSpaceCount; +} +} +aTxtSize.AdjustWidth( nSpaceCount * tools::Long( nKern ) ); +} return aTxtSize; } @@ -453,13 +476,6 @@ Size SvxFont::GetPhysTxtSize( const OutputDevice *pOut ) return aTxtSize; } -static tools::Long GetTextArray( const OutputDevice* pOut, const OUString& rStr, std::vector* pDXAry, - sal_Int32 nIndex, sal_Int32 nLen ) -{ -const SalLayoutGlyphs* layoutGlyphs = SalLayoutGlyphsCache::self()->GetLayoutGlyphs(pOut, rStr, nIndex, nLen); -return pOut->GetTextArr
[Libreoffice-commits] core.git: sw/source
sw/source/core/txtnode/fntcache.cxx | 33 +++-- 1 file changed, 31 insertions(+), 2 deletions(-) New commits: commit 7418fc88021a7d2cb45eb3b029466ed7a14d3338 Author: Mark Hung AuthorDate: Sat Apr 16 15:36:09 2022 +0800 Commit: Mark Hung CommitDate: Tue Apr 19 13:51:07 2022 +0200 tdf#148594 correcting the number of kern spaces. A glyph item ( or a glyph cluster ) may be made up of more than one sal_Unicode values ( e.g. CJK ideograph extension B characters that need surrogate pairs, or unicode iVS that have a base character and a selector ). Insert the kern space only when KernArray value changes. I.e. character belongs to a different glyph item or cluster. Count the number of needed kern spaces in the same way. Change-Id: If79766bda37cf4d10ca5be2d51dfdc992eaf9cc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133093 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 65a4332b462d..3e1a6f9b2c67 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1598,6 +1598,8 @@ void SwFntObj::DrawText( SwDrawTextInfo ) nSpaceSum += nHalfSpace; } +tools::Long nOldValue = aKernArray[i-1]; + cChPrev = nCh; aKernArray[i-1] += nKernSum + nSpaceSum; // In word line mode and for Arabic, we disabled the half space trick. If a portion @@ -1606,10 +1608,22 @@ void SwFntObj::DrawText( SwDrawTextInfo ) // nSpaceAdd value again: if ((bNoHalfSpace || m_pPrtFont->IsWordLineMode()) && i+1 == sal_Int32(nCnt) && nCh == CH_BLANK) aKernArray[i-1] = aKernArray[i-1] - nSpaceAdd; + +// Some glyph items use more than one sal_Unicode, eg. CJK ideograph extensions +// or unicode IVS. Don't assign space multiple times in case the orginal text array +// have the same values. +while(i < sal_Int32(nCnt) && aKernArray[i] == nOldValue) +{ +aKernArray[i] = aKernArray[i-1]; +++i; +} } // the layout engine requires the total width of the output -aKernArray[sal_Int32(rInf.GetLen()) - 1] += nKernSum + nSpaceSum; +tools::Long nOldValue = aKernArray[sal_Int32(rInf.GetLen()) - 1]; +for(sal_Int32 i = sal_Int32(rInf.GetLen()) - 1; i >= 0 && aKernArray[i] == nOldValue; --i) +aKernArray[i] += nKernSum + nSpaceSum; + if( rInf.GetGreyWave() ) { @@ -1906,8 +1920,23 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) if (nLn) { aTextSize.setWidth(aKernArray[sal_Int32(nLn) - 1]); + +// Note that we can't simply use sal_Int(nLn) - 1 as nSpaceCount +// because a glyph may be made up of more than one characters. +sal_Int32 nSpaceCount = 0; +tools::Long nOldValue = aKernArray[0]; + +for(sal_Int32 i = 1; i < sal_Int32(nLn); ++i) +{ +if (nOldValue != aKernArray[i]) +{ +++nSpaceCount; +nOldValue = aKernArray[i]; +} +} + if (rInf.GetKern()) -aTextSize.AdjustWidth((sal_Int32(nLn) - 1) * rInf.GetKern()); +aTextSize.AdjustWidth(nSpaceCount * rInf.GetKern()); } OSL_ENSURE( !rInf.GetShell() ||
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - vcl/win
vcl/win/window/salframe.cxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit c3189d9527ee6e5923bfc897428b1b1ade803a47 Author: Mark Hung AuthorDate: Mon Apr 4 20:12:36 2022 +0800 Commit: Adolfo Jayme Barrientos CommitDate: Wed Apr 13 16:56:45 2022 +0200 tdf#143447 ignore IME candidate window state. Some traditional Chinese IMEs ( Input Method Editors ) under Windows10 send WM_IME_NOTIFY with IMN_OPENCANDIDATE but not IMN_CLOSECANDIDATE. The behavior is different if users configure the IME and enable "legacy" option. That caused the cursor been hidden, misled by mbCandidateMode. The patch ignores the candidate window mode in case the length of the composition string is 0, assume in that case candidate window is useless, and resets the candidate window mode when composition ended to maintain the state as much as we can. Change-Id: I91a1c23ee1a031313243e032653f50f39b0f2a3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132512 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 2b2d1c08c94fdc3982971c2b19ea241f05e578c9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132858 Reviewed-by: Adolfo Jayme Barrientos diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 6593b2fbebb6..4556c850edec 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -5079,7 +5079,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, if ( (nTextLen > 0) || !(lParam & GCS_RESULTSTR) ) { // End the mode, if the last character is deleted -if ( !nTextLen && !pFrame->mbCandidateMode ) +if ( !nTextLen ) { pFrame->CallCallback( SalEvent::ExtTextInput, ); pFrame->CallCallback( SalEvent::EndExtTextInput, nullptr ); @@ -5164,7 +5164,10 @@ static bool ImplHandleIMEEndComposition( HWND hWnd ) if ( pFrame && pFrame->mbHandleIME ) { if ( pFrame->mbAtCursorIME ) +{ +pFrame->mbCandidateMode = false; bDef = false; +} } ImplSalYieldMutexRelease();
[Libreoffice-commits] core.git: vcl/inc vcl/source
vcl/inc/fontinstance.hxx |8 vcl/source/font/fontinstance.cxx | 37 + vcl/source/gdi/CommonSalLayout.cxx | 13 + 3 files changed, 58 insertions(+) New commits: commit 257bb11cbc5b1eb1f90014f528b9e7d6ccfeae86 Author: Mark Hung AuthorDate: Sun Apr 3 14:53:14 2022 +0800 Commit: Mark Hung CommitDate: Fri Apr 8 15:25:37 2022 +0200 tdf#148330 fix vertical offset for DFKai-SB (ukai.ttf). DFKai-SB (ukai.ttf) is a built-in font under tradtional Chinese Windows. The font is very common, especially for official documents. It is one of the so-called tricky fonts in FreeType[1]. DFKai-SB has incorrect extent in the glyf table[2]. It results in incorrect glyph positions in vertical writing. FreeType recalculates the extents based on the glyph outline, but LibreOffice uses Harfbuzz with built-in ot font functions instead of ft (FreeType). This patch decides if the fix is necessary by checking the family name of the font and the y-offset value, and recaculates the glyph offset based on glyph height and top bearing obtained from the glyph bound rect. [1]https://freetype.org/freetype2/docs/reference/ft2-base_interface.html#ft_face_flag_tricky [2]https://github.com/harfbuzz/harfbuzz/issues/3521 Change-Id: If632dd38c462c229837e1efb5446e2142f8f0639 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132511 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx index 5822bd1a08b5..5b5ab206c26a 100644 --- a/vcl/inc/fontinstance.hxx +++ b/vcl/inc/fontinstance.hxx @@ -86,6 +86,9 @@ public: // TODO: make data members private inline hb_font_t* GetHbFont(); bool IsGraphiteFont(); +// NeedOffsetCorrection: Return if the font need offset correction in TTB direction. +// nYOffset is the original offset. It is used to check if the correction is necessary. +bool NeedOffsetCorrection(sal_Int32 nYOffset); void SetAverageWidthFactor(double nFactor) { m_nAveWidthFactor = std::abs(nFactor); } double GetAverageWidthFactor() const { return m_nAveWidthFactor; } const vcl::font::FontSelectPattern& GetFontSelectPattern() const { return m_aFontSelData; } @@ -129,6 +132,11 @@ private: double m_nAveWidthFactor; rtl::Reference m_pFontFace; std::optional m_xbIsGraphiteFont; + +enum class FontFamilyEnum { Unclassified, DFKaiSB }; + +// The value is initialized and used in NeedOffsetCorrection(). +std::optional m_xeFontFamilyEnum; }; inline hb_font_t* LogicalFontInstance::GetHbFont() diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx index 5dbd1748a3c3..6f5bc7d1f37a 100644 --- a/vcl/source/font/fontinstance.cxx +++ b/vcl/source/font/fontinstance.cxx @@ -152,4 +152,41 @@ bool LogicalFontInstance::IsGraphiteFont() return *m_xbIsGraphiteFont; } +bool LogicalFontInstance::NeedOffsetCorrection(sal_Int32 nYOffset) +{ +if (!m_xeFontFamilyEnum) +{ +char familyname[10]; +unsigned int familyname_size = 10; + +m_xeFontFamilyEnum = FontFamilyEnum::Unclassified; + +if (hb_ot_name_get_utf8 (hb_font_get_face(GetHbFont()), +HB_OT_NAME_ID_FONT_FAMILY , HB_LANGUAGE_INVALID, _size, familyname) == 8) +{ +// DFKai-SB (ukai.ttf) is a built-in font under tradtional Chinese +// Windows. It has wrong extent values in glyf table. The problem results +// in wrong positioning of glyphs in vertical writing. +// Check https://github.com/harfbuzz/harfbuzz/issues/3521 for reference. +if (!strncmp("DFKai-SB", familyname, 8)) +m_xeFontFamilyEnum = FontFamilyEnum::DFKaiSB; +} +} + +bool bRet = true; + +switch (*m_xeFontFamilyEnum) +{ +case FontFamilyEnum::DFKaiSB: +// -839: optimization for one third of ukai.ttf +if (nYOffset == -839) +bRet = false; +break; +default: +bRet = false; +} + +return bRet; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index be6480bfde1a..8dee28727997 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -621,6 +621,19 @@ bool GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay nAdvance = -pHbPositions[i].y_advance; nXOffset = -pHbPositions[i].y_offset; nYOffset = -pHbPositions[i].x_offset - nBaseOffset; + +if (GetFont().NeedOffsetCorrection(pHbPositions[i].y_offset)) +{ +// We need glyph's advance, top bearing, and height to +/
[Libreoffice-commits] core.git: vcl/win
vcl/win/window/salframe.cxx |5 - 1 file changed, 4 insertions(+), 1 deletion(-) New commits: commit 2b2d1c08c94fdc3982971c2b19ea241f05e578c9 Author: Mark Hung AuthorDate: Mon Apr 4 20:12:36 2022 +0800 Commit: Mark Hung CommitDate: Fri Apr 8 15:23:54 2022 +0200 tdf#143447 ignore IME candidate window state. Some traditional Chinese IMEs ( Input Method Editors ) under Windows10 send WM_IME_NOTIFY with IMN_OPENCANDIDATE but not IMN_CLOSECANDIDATE. The behavior is different if users configure the IME and enable "legacy" option. That caused the cursor been hidden, misled by mbCandidateMode. The patch ignores the candidate window mode in case the length of the composition string is 0, assume in that case candidate window is useless, and resets the candidate window mode when composition ended to maintain the state as much as we can. Change-Id: I91a1c23ee1a031313243e032653f50f39b0f2a3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132512 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index cd9449c1a4ae..bbfd7843502a 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -5153,7 +5153,7 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, if ( (nTextLen > 0) || !(lParam & GCS_RESULTSTR) ) { // End the mode, if the last character is deleted -if ( !nTextLen && !pFrame->mbCandidateMode ) +if ( !nTextLen ) { pFrame->CallCallback( SalEvent::ExtTextInput, ); pFrame->CallCallback( SalEvent::EndExtTextInput, nullptr ); @@ -5238,7 +5238,10 @@ static bool ImplHandleIMEEndComposition( HWND hWnd ) if ( pFrame && pFrame->mbHandleIME ) { if ( pFrame->mbAtCursorIME ) +{ +pFrame->mbCandidateMode = false; bDef = false; +} } ImplSalYieldMutexRelease();
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - sw/source
sw/source/filter/ww8/rtfattributeoutput.cxx |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit 0c1894acda828c02c76c97c25149187cb04ae91f Author: Mark Hung AuthorDate: Sat Mar 19 21:18:54 2022 +0800 Commit: Xisco Fauli CommitDate: Mon Mar 28 20:53:46 2022 +0200 tdf#141671 fix destroyed pargraph style in exported RTF in MSO. Do not call MoveCharacterProperties() in RtfAttributeOutput ::EndParagraphProperties(). RtfAttributeOutput::ParagraphStyle() has emited run associated properties defined in paragraph style. Calling MoveCharacterProperties() again overwrites them. As this bug is only visible in MS Word, no unit test case is added. Change-Id: I6e5bfd12e8afa7dc286ca54448c1ff022aade31d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131848 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 882045b934a3416cc48da2c4e30648892a419577) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132175 Reviewed-by: Xisco Fauli diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index cc7d61c80d75..ca43274da2c7 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -384,7 +384,9 @@ void RtfAttributeOutput::EndParagraphProperties( const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData* /*pRedlineParagraphMarkerInserted*/) { -const OString aProperties = MoveCharacterProperties(true); +// Do not call MoveCharacterProperties(), +// Otherwise associate properties in the paragraph style are ruined. +const OString aProperties = m_aStyles.makeStringAndClear(); m_rExport.Strm().WriteOString(aProperties); }
[Libreoffice-commits] core.git: sw/source
sw/source/filter/ww8/rtfattributeoutput.cxx |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) New commits: commit 882045b934a3416cc48da2c4e30648892a419577 Author: Mark Hung AuthorDate: Sat Mar 19 21:18:54 2022 +0800 Commit: Mark Hung CommitDate: Thu Mar 24 14:04:32 2022 +0100 tdf#141671 fix destroyed pargraph style in exported RTF in MSO. Do not call MoveCharacterProperties() in RtfAttributeOutput ::EndParagraphProperties(). RtfAttributeOutput::ParagraphStyle() has emited run associated properties defined in paragraph style. Calling MoveCharacterProperties() again overwrites them. As this bug is only visible in MS Word, no unit test case is added. Change-Id: I6e5bfd12e8afa7dc286ca54448c1ff022aade31d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131848 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index f22ec5a48c02..273d660237f6 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -384,7 +384,9 @@ void RtfAttributeOutput::EndParagraphProperties( const SwRedlineData* /*pRedlineParagraphMarkerDeleted*/, const SwRedlineData* /*pRedlineParagraphMarkerInserted*/) { -const OString aProperties = MoveCharacterProperties(true); +// Do not call MoveCharacterProperties(), +// Otherwise associate properties in the paragraph style are ruined. +const OString aProperties = m_aStyles.makeStringAndClear(); m_rExport.Strm().WriteOString(aProperties); }
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - vcl/inc vcl/win
vcl/inc/win/salgdi.h |4 +++- vcl/inc/win/winlayout.hxx |6 ++ vcl/win/gdi/salfont.cxx | 32 ++-- vcl/win/gdi/winlayout.cxx | 38 +- 4 files changed, 72 insertions(+), 8 deletions(-) New commits: commit 25b77b4a684695e8948c8a97902c8e9de80b446e Author: Mark Hung AuthorDate: Mon Nov 1 20:53:19 2021 +0800 Commit: Adolfo Jayme Barrientos CommitDate: Sat Dec 11 17:55:56 2021 +0100 tdf#145322, tdf#144378 fix printing for vertical writing Printing still uses ExTextOutRenderer to render text because Skia haven't yet support printing and DWriteTextRenderer can't bind the printer DC. ExTextOutRenderer uses win32 API ExtTextOutW. In order to renderer upright CJK text in vertical writing with that API, the HFONT created with CreateFontIndirectW needs a font name prefixed with '@'. OTOH, use '@' prefixed font with Skia break the vertical writing unit test. - WinSalGraphics::ImplDoSetFont: use '@' prefixed font name if the requested font is vertical and is for printing. - ExTextOutRenderer: use SetTextAlign and text metric tmDescent to adjust vertical glyphs. It's not consistent with Skia or DWriteTextRenderer, and is still incorrect in many cases. The patch is adapted from reverting commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba Author: Mark Hung Date: Sun May 2 14:45:45 2021 +0800 vcl: use DWriteTextRenderer for vertical writing. Change-Id: Ib2d3df8b68cad4bebe0672c9da0a16b62aed99e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125978 Tested-by: Jenkins Reviewed-by: Mark Hung Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126545 Reviewed-by: Adolfo Jayme Barrientos diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 959d8abc0301..bcd25f8e92dd 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -166,7 +166,9 @@ private: int mnPenWidth; // line width public: -HFONT ImplDoSetFont(FontSelectPattern const & i_rFont, const PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); +// Return HFONT, and whether the font is for vertical writing ( prefixed with '@' ) +// and tmDescent value for adjusting offset in vertical writing mode. +std::tuple ImplDoSetFont(FontSelectPattern const & i_rFont, const PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); HDC getHDC() const { return mhLocalDC; } void setHDC(HDC aNew) { mhLocalDC = aNew; } diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index b4e51d8dc4bb..7cedb3f7a40b 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -43,6 +43,10 @@ public: HFONT GetHFONT() const { return m_hFont; } float GetScale() const { return m_fScale; } +// Return true if the font is for vertical writing. +// I.e. the font name of the LOGFONT is prefixed with '@'. +bool IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; } +sal_Int32 GetTmDescent() const { return m_nTmDescent; } // Prevent deletion of the HFONT in the WinFontInstance destructor // Used for the ScopedFont handling @@ -62,6 +66,8 @@ private: WinSalGraphics *m_pGraphics; HFONT m_hFont; float m_fScale; +bool m_bIsCJKVerticalFont; +sal_Int32 m_nTmDescent; }; class TextOutRenderer diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 2830d6048590..4b74741d3b9e 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -760,6 +760,12 @@ void WinSalGraphics::SetTextColor( Color nColor ) ::SetTextColor( getHDC(), aCol ); } +static int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*, const TEXTMETRICW*, DWORD, LPARAM lParam ) +{ +*reinterpret_cast(lParam) = true; +return 0; +} + void ImplGetLogFontFromFontSelect( const FontSelectPattern& rFont, const PhysicalFontFace* pFontFace, LOGFONTW& rLogFont ) @@ -809,7 +815,7 @@ void ImplGetLogFontFromFontSelect( const FontSelectPattern& rFont, } -HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont, +std::tuple WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont, const PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont) { @@ -818,6 +824,27 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont, LOGFONTW aLogFont; ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont ); +boolbIsCJKVerticalFont = false; +// select vertical mode for printing if requested and available +if ( i_rFont.mbVertical && mbPrinter ) +{ +constexpr size_t nLen = sizeof(aLogFont.lfFaceName) - sizeof(aLogFont.lfFaceName[0]); +// vertic
[Libreoffice-commits] core.git: Branch 'libreoffice-7-3' - vcl/inc vcl/win
vcl/inc/win/salgdi.h |4 +++- vcl/inc/win/winlayout.hxx |6 ++ vcl/win/gdi/salfont.cxx | 32 ++-- vcl/win/gdi/winlayout.cxx | 42 +++--- 4 files changed, 74 insertions(+), 10 deletions(-) New commits: commit 3c2836972613ff418d76306d958a8ef85ff18afe Author: Mark Hung AuthorDate: Mon Nov 1 20:53:19 2021 +0800 Commit: Xisco Fauli CommitDate: Thu Dec 9 13:00:40 2021 +0100 tdf#145322, tdf#144378 fix printing for vertical writing Printing still uses ExTextOutRenderer to render text because Skia haven't yet support printing and DWriteTextRenderer can't bind the printer DC. ExTextOutRenderer uses win32 API ExtTextOutW. In order to renderer upright CJK text in vertical writing with that API, the HFONT created with CreateFontIndirectW needs a font name prefixed with '@'. OTOH, use '@' prefixed font with Skia break the vertical writing unit test. - WinSalGraphics::ImplDoSetFont: use '@' prefixed font name if the requested font is vertical and is for printing. - ExTextOutRenderer: use SetTextAlign and text metric tmDescent to adjust vertical glyphs. It's not consistent with Skia or DWriteTextRenderer, and is still incorrect in many cases. The patch is adapted from reverting commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba Author: Mark Hung Date: Sun May 2 14:45:45 2021 +0800 vcl: use DWriteTextRenderer for vertical writing. Change-Id: Ib2d3df8b68cad4bebe0672c9da0a16b62aed99e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125978 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 6720e9569d7ab6c20616ec6b97e5d4a56948908b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126443 Reviewed-by: Xisco Fauli diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 8c6c1adcdbed..b472ece0a256 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -181,7 +181,9 @@ private: void DeInitGraphics(); public: -HFONT ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); +// Return HFONT, and whether the font is for vertical writing ( prefixed with '@' ) +// and tmDescent value for adjusting offset in vertical writing mode. +std::tuple ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); HDC getHDC() const { return mhLocalDC; } // NOTE: this doesn't transfer ownership! See class comment. diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index 29bccf5acf4f..0b43ef4eeca1 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -44,6 +44,10 @@ public: HFONT GetHFONT() const { return m_hFont; } float GetScale() const { return m_fScale; } +// Return true if the font is for vertical writing. +// I.e. the font name of the LOGFONT is prefixed with '@'. +bool IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; } +sal_Int32 GetTmDescent() const { return m_nTmDescent; } const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); } WinFontFace * GetFontFace() { return static_cast(LogicalFontInstance::GetFontFace()); } @@ -59,6 +63,8 @@ private: WinSalGraphics *m_pGraphics; HFONT m_hFont; float m_fScale; +bool m_bIsCJKVerticalFont; +sal_Int32 m_nTmDescent; }; class TextOutRenderer diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 7682def12661..acaca76584a3 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -762,6 +762,12 @@ void WinSalGraphics::SetTextColor( Color nColor ) ::SetTextColor( getHDC(), aCol ); } +static int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*, const TEXTMETRICW*, DWORD, LPARAM lParam ) +{ +*reinterpret_cast(lParam) = true; +return 0; +} + void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, const vcl::font::PhysicalFontFace* pFontFace, LOGFONTW& rLogFont ) @@ -811,7 +817,7 @@ void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, } -HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, +std::tuple WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont) { @@ -820,6 +826,27 @@ HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const LOGFONTW aLogFont; ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont );
[Libreoffice-commits] core.git: vcl/inc vcl/win
vcl/inc/win/salgdi.h |4 +++- vcl/inc/win/winlayout.hxx |6 ++ vcl/win/gdi/salfont.cxx | 32 ++-- vcl/win/gdi/winlayout.cxx | 42 +++--- 4 files changed, 74 insertions(+), 10 deletions(-) New commits: commit 6720e9569d7ab6c20616ec6b97e5d4a56948908b Author: Mark Hung AuthorDate: Mon Nov 1 20:53:19 2021 +0800 Commit: Mark Hung CommitDate: Tue Dec 7 10:52:55 2021 +0100 tdf#145322, tdf#144378 fix printing for vertical writing Printing still uses ExTextOutRenderer to render text because Skia haven't yet support printing and DWriteTextRenderer can't bind the printer DC. ExTextOutRenderer uses win32 API ExtTextOutW. In order to renderer upright CJK text in vertical writing with that API, the HFONT created with CreateFontIndirectW needs a font name prefixed with '@'. OTOH, use '@' prefixed font with Skia break the vertical writing unit test. - WinSalGraphics::ImplDoSetFont: use '@' prefixed font name if the requested font is vertical and is for printing. - ExTextOutRenderer: use SetTextAlign and text metric tmDescent to adjust vertical glyphs. It's not consistent with Skia or DWriteTextRenderer, and is still incorrect in many cases. The patch is adapted from reverting commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba Author: Mark Hung Date: Sun May 2 14:45:45 2021 +0800 vcl: use DWriteTextRenderer for vertical writing. Change-Id: Ib2d3df8b68cad4bebe0672c9da0a16b62aed99e6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125978 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 8c6c1adcdbed..b472ece0a256 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -181,7 +181,9 @@ private: void DeInitGraphics(); public: -HFONT ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); +// Return HFONT, and whether the font is for vertical writing ( prefixed with '@' ) +// and tmDescent value for adjusting offset in vertical writing mode. +std::tuple ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont); HDC getHDC() const { return mhLocalDC; } // NOTE: this doesn't transfer ownership! See class comment. diff --git a/vcl/inc/win/winlayout.hxx b/vcl/inc/win/winlayout.hxx index 29bccf5acf4f..0b43ef4eeca1 100644 --- a/vcl/inc/win/winlayout.hxx +++ b/vcl/inc/win/winlayout.hxx @@ -44,6 +44,10 @@ public: HFONT GetHFONT() const { return m_hFont; } float GetScale() const { return m_fScale; } +// Return true if the font is for vertical writing. +// I.e. the font name of the LOGFONT is prefixed with '@'. +bool IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; } +sal_Int32 GetTmDescent() const { return m_nTmDescent; } const WinFontFace * GetFontFace() const { return static_cast(LogicalFontInstance::GetFontFace()); } WinFontFace * GetFontFace() { return static_cast(LogicalFontInstance::GetFontFace()); } @@ -59,6 +63,8 @@ private: WinSalGraphics *m_pGraphics; HFONT m_hFont; float m_fScale; +bool m_bIsCJKVerticalFont; +sal_Int32 m_nTmDescent; }; class TextOutRenderer diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 7682def12661..acaca76584a3 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -762,6 +762,12 @@ void WinSalGraphics::SetTextColor( Color nColor ) ::SetTextColor( getHDC(), aCol ); } +static int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*, const TEXTMETRICW*, DWORD, LPARAM lParam ) +{ +*reinterpret_cast(lParam) = true; +return 0; +} + void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, const vcl::font::PhysicalFontFace* pFontFace, LOGFONTW& rLogFont ) @@ -811,7 +817,7 @@ void ImplGetLogFontFromFontSelect( const vcl::font::FontSelectPattern& rFont, } -HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, +std::tuple WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const & i_rFont, const vcl::font::PhysicalFontFace * i_pFontFace, HFONT& o_rOldFont) { @@ -820,6 +826,27 @@ HFONT WinSalGraphics::ImplDoSetFont(HDC hDC, vcl::font::FontSelectPattern const LOGFONTW aLogFont; ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont ); +boolbIsCJKVerticalFont = false; +// select vertical mode for printing if requested and available +if ( i_rFont.mbVertical && mbPrinter
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/tdf144222.ods |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 42 vcl/source/gdi/pdfwriter_impl.cxx |2 - 3 files changed, 42 insertions(+), 2 deletions(-) New commits: commit 28dcd1f17a73929c26e490cec929706d3a06b042 Author: Mark Hung AuthorDate: Sat Oct 16 13:55:56 2021 +0800 Commit: Xisco Fauli CommitDate: Thu Oct 21 17:45:50 2021 +0200 tdf#144222 fix pdf export with vertical layout Remove the offset adjustment that is no longer necessary. That was done in every backend before, and has been removed now. We can trust what layout text provides us. Regression from: commit dd0d0b44fd1c6c0292d7b2eb3f5cf2baa21e4481 Author: Mark Hung Date: Sun May 2 15:12:46 2021 +0800 vcl: adjust LayoutText() for vertical writing. Change-Id: I077f5a5f0711444086e56e4469dbcb3010ffe661 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123682 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit a4244c0f05b95ded277a3a7ed217bf0451daa996) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123986 Reviewed-by: Xisco Fauli diff --git a/vcl/qa/cppunit/pdfexport/data/tdf144222.ods b/vcl/qa/cppunit/pdfexport/data/tdf144222.ods new file mode 100644 index ..7b572d301abc Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf144222.ods differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 0da9bedd33ef..ad19395c5669 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2945,6 +2945,48 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfImageRotate180) CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, aScale.getX(), 0.01); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf144222) +{ +// Assume Windows has the font for U+4E2D +#ifdef _WIN32 +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf144222.ods"; +utl::MediaDescriptor aMediaDescriptor; +aMediaDescriptor["FilterName"] <<= OUString("calc_pdf_Export"); +auto pPdfDocument = exportAndParse(aURL, aMediaDescriptor); + +// The document has one page. +CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); +std::unique_ptr pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); +CPPUNIT_ASSERT(pPdfPage); +std::unique_ptr pTextPage = pPdfPage->getTextPage(); +CPPUNIT_ASSERT(pTextPage); + +int nPageObjectCount = pPdfPage->getObjectCount(); +const OUString sChar = u"\u4E2D"; +basegfx::B2DRectangle aRect1, aRect2; +int nCount = 0; + +for (int i = 0; i < nPageObjectCount; ++i) +{ +std::unique_ptr pPdfPageObject = pPdfPage->getObject(i); +if (pPdfPageObject->getType() == vcl::pdf::PDFPageObjectType::Text) +{ +++nCount; +OUString sText = pPdfPageObject->getText(pTextPage); +if (sText == sChar) +aRect1 = pPdfPageObject->getBounds(); +else +aRect2 = pPdfPageObject->getBounds(); +} +} + +CPPUNIT_ASSERT_EQUAL(2, nCount); +CPPUNIT_ASSERT(!aRect1.isEmpty()); +CPPUNIT_ASSERT(!aRect2.isEmpty()); +CPPUNIT_ASSERT(!aRect1.overlaps(aRect2)); +#endif +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 5ca3dfd4cf25..80542ac41dfa 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5827,8 +5827,6 @@ void PDFWriterImpl::drawVerticalGlyphs( if (rGlyphs[i].m_pGlyph->IsVertical()) { fDeltaAngle = M_PI/2.0; -aDeltaPos.setX( GetFontMetric().GetAscent() ); -aDeltaPos.setY( static_cast(static_cast(GetFontMetric().GetDescent()) * fXScale) ); fYScale = fXScale; fTempXScale = 1.0; fSkewA = -fSkewB;
[Libreoffice-commits] core.git: vcl/qa vcl/source
vcl/qa/cppunit/pdfexport/data/tdf144222.ods |binary vcl/qa/cppunit/pdfexport/pdfexport.cxx | 42 vcl/source/gdi/pdfwriter_impl.cxx |2 - 3 files changed, 42 insertions(+), 2 deletions(-) New commits: commit a4244c0f05b95ded277a3a7ed217bf0451daa996 Author: Mark Hung AuthorDate: Sat Oct 16 13:55:56 2021 +0800 Commit: Mark Hung CommitDate: Thu Oct 21 14:13:30 2021 +0200 tdf#144222 fix pdf export with vertical layout Remove the offset adjustment that is no longer necessary. That was done in every backend before, and has been removed now. We can trust what layout text provides us. Regression from: commit dd0d0b44fd1c6c0292d7b2eb3f5cf2baa21e4481 Author: Mark Hung Date: Sun May 2 15:12:46 2021 +0800 vcl: adjust LayoutText() for vertical writing. Change-Id: I077f5a5f0711444086e56e4469dbcb3010ffe661 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123682 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/qa/cppunit/pdfexport/data/tdf144222.ods b/vcl/qa/cppunit/pdfexport/data/tdf144222.ods new file mode 100644 index ..7b572d301abc Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf144222.ods differ diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 0da9bedd33ef..ad19395c5669 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2945,6 +2945,48 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfImageRotate180) CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, aScale.getX(), 0.01); } +CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf144222) +{ +// Assume Windows has the font for U+4E2D +#ifdef _WIN32 +OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf144222.ods"; +utl::MediaDescriptor aMediaDescriptor; +aMediaDescriptor["FilterName"] <<= OUString("calc_pdf_Export"); +auto pPdfDocument = exportAndParse(aURL, aMediaDescriptor); + +// The document has one page. +CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount()); +std::unique_ptr pPdfPage = pPdfDocument->openPage(/*nIndex=*/0); +CPPUNIT_ASSERT(pPdfPage); +std::unique_ptr pTextPage = pPdfPage->getTextPage(); +CPPUNIT_ASSERT(pTextPage); + +int nPageObjectCount = pPdfPage->getObjectCount(); +const OUString sChar = u"\u4E2D"; +basegfx::B2DRectangle aRect1, aRect2; +int nCount = 0; + +for (int i = 0; i < nPageObjectCount; ++i) +{ +std::unique_ptr pPdfPageObject = pPdfPage->getObject(i); +if (pPdfPageObject->getType() == vcl::pdf::PDFPageObjectType::Text) +{ +++nCount; +OUString sText = pPdfPageObject->getText(pTextPage); +if (sText == sChar) +aRect1 = pPdfPageObject->getBounds(); +else +aRect2 = pPdfPageObject->getBounds(); +} +} + +CPPUNIT_ASSERT_EQUAL(2, nCount); +CPPUNIT_ASSERT(!aRect1.isEmpty()); +CPPUNIT_ASSERT(!aRect2.isEmpty()); +CPPUNIT_ASSERT(!aRect1.overlaps(aRect2)); +#endif +} + } // end anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 7718cbd39f9c..b987c948bd6d 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -5841,8 +5841,6 @@ void PDFWriterImpl::drawVerticalGlyphs( if (rGlyphs[i].m_pGlyph->IsVertical()) { fDeltaAngle = M_PI/2.0; -aDeltaPos.setX( GetFontMetric().GetAscent() ); -aDeltaPos.setY( static_cast(static_cast(GetFontMetric().GetDescent()) * fXScale) ); fYScale = fXScale; fTempXScale = 1.0; fSkewA = -fSkewB;
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/source
sw/source/ui/misc/pggrid.cxx | 19 +++ 1 file changed, 19 insertions(+) New commits: commit b21880ab06e85fdb688c8e5d11453a9fb9d52896 Author: Mark Hung AuthorDate: Thu Oct 7 20:36:17 2021 +0800 Commit: Xisco Fauli CommitDate: Thu Oct 14 16:43:46 2021 +0200 tdf#141957 include the size of header and footer. Text grid dialog didn't include the size of header and footer, so if any of them are included, the resulted number of lines or chars per line was wrong. Change-Id: I09c1eed1552485adf75ad75cfaf25b99f8eec1e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123215 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 8ac8a20ed15bb458e1ee5a8df2b97aef05ca4f7c) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123397 Reviewed-by: Xisco Fauli diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 20a964eceaf7..73657c9573aa 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -272,6 +273,24 @@ void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet) sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight(); sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower(); +for( sal_Int32 nId : { SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_FOOTERSET }) +{ +const SfxPoolItem* pItem; +if( SfxItemState::SET == rSet.GetItemState( nId, false, ) ) +{ +const SfxItemSet& rExtraSet = static_cast(pItem)->GetItemSet(); +const SfxBoolItem& rOn = +static_cast(rExtraSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_ON ) )); + +if ( rOn.GetValue() ) +{ +const SvxSizeItem& rSizeItem = +static_cast(rExtraSet.Get(rSet.GetPool()->GetWhich(SID_ATTR_PAGE_SIZE))); +nDistanceUL += rSizeItem.GetSize().Height(); +} +} +} + sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL - rBox.GetDistance(SvxBoxItemLine::TOP) - rBox.GetDistance(SvxBoxItemLine::BOTTOM);
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - sw/qa writerfilter/source
sw/qa/extras/ooxmlexport/data/tdf142407.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |8 writerfilter/source/dmapper/PropertyMap.cxx |6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) New commits: commit 829a001ffe89dd9c9dcda08fcc61bb4711b447df Author: Mark Hung AuthorDate: Thu Oct 7 23:54:51 2021 +0800 Commit: Xisco Fauli CommitDate: Tue Oct 12 15:20:44 2021 +0200 tdf#142407 fix incorrect number of lines in vertical writing. Wrting mode isn't read correctly. The property PROP_WRITING_MODE contans an Any of sal_Int16. When converting to WritingMode enum directly, it always get WrtingMode::LR_TB(0), hence use wrong side to calculate number of grid lines for vertical writing. The resulted number of grid lines are much smaller than expected, it ends up leaving large space between header and text. Change-Id: Ifb0ff09fe981819cc2705de8d5596190f320f79e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123223 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 5f84c44e3d5ff19b800b6358e61228546e318d4f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123396 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/ooxmlexport/data/tdf142407.docx b/sw/qa/extras/ooxmlexport/data/tdf142407.docx new file mode 100644 index ..38397a4de996 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf142407.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 6884ea3ebc03..5a331a5f505d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -62,6 +62,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx") CPPUNIT_ASSERT_EQUAL(OUString("Bookmark1"), getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:bookmarkStart[1]", "name")); } +DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx") +{ +uno::Reference xPageStyles = getStyles("PageStyles"); +uno::Reference xPageStyle(xPageStyles->getByName("Standard"), uno::UNO_QUERY); +sal_Int16 nGridLines; +xPageStyle->getPropertyValue("GridLines") >>= nGridLines; +CPPUNIT_ASSERT_EQUAL( sal_Int16(36), nGridLines); // was 23, left large space before text. +} CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index b4c58c0d8808..3b8f36d602a0 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1709,12 +1709,12 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) if ( pProp ) pProp->second >>= nWidth; -text::WritingMode eWritingMode = text::WritingMode_LR_TB; +sal_Int16 nWritingMode = text::WritingMode2::LR_TB; pProp = getProperty( PROP_WRITING_MODE ); if ( pProp ) -pProp->second >>= eWritingMode; +pProp->second >>= nWritingMode; -sal_Int32 nTextAreaHeight = eWritingMode == text::WritingMode_LR_TB ? +sal_Int32 nTextAreaHeight = nWritingMode == text::WritingMode2::LR_TB ? nHeight - m_nTopMargin - m_nBottomMargin : nWidth - m_nLeftMargin - m_nRightMargin;
[Libreoffice-commits] core.git: vcl/inc vcl/win
vcl/inc/win/salprn.h |2 +- vcl/win/gdi/salprn.cxx | 12 2 files changed, 5 insertions(+), 9 deletions(-) New commits: commit d27187b158d7e3f92180b1f2ab79b048dc5318a5 Author: Mark Hung AuthorDate: Mon Oct 11 10:26:56 2021 +0800 Commit: Noel Grandin CommitDate: Tue Oct 12 08:34:28 2021 +0200 vcl:use unique_ptr in WinSalPrinter to replace plain SalWinGraphics pointer, and get rid of delete. Change-Id: If06df98a8ebfdf5797bddfefa37647522b8e711b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123365 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h index 43eaa520c23d..2d02aa5b0e54 100644 --- a/vcl/inc/win/salprn.h +++ b/vcl/inc/win/salprn.h @@ -78,7 +78,7 @@ public: class WinSalPrinter : public SalPrinter { public: -WinSalGraphics* mpGraphics; // current Printer graphics +std::unique_ptr mxGraphics;// current Printer graphics WinSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter WinSalPrinter* mpNextPrinter; // next printing printer HDC mhDC; // printer hdc diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx index 21e779eb6156..86e1e616a57f 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -1350,7 +1350,6 @@ static DEVMODEW const * ImplSalSetCopies( DEVMODEW const * pDevMode, sal_uInt32 WinSalPrinter::WinSalPrinter() : -mpGraphics( nullptr ), mpInfoPrinter( nullptr ), mpNextPrinter( nullptr ), mhDC( nullptr ), @@ -1374,7 +1373,6 @@ WinSalPrinter::~WinSalPrinter() HDC hDC = mhDC; if ( hDC ) { -delete mpGraphics; DeleteDC( hDC ); } @@ -1531,8 +1529,7 @@ bool WinSalPrinter::EndJob() HDC hDC = mhDC; if (isValid()) { -delete mpGraphics; -mpGraphics = nullptr; +mxGraphics.reset(); // #i54419# Windows fax printer brings up a dialog in EndDoc // which text previously copied in soffice process can be @@ -1587,14 +1584,13 @@ SalGraphics* WinSalPrinter::StartPage( ImplJobSetup* pSetupData, bool bNewJobDat SelectPen( hDC, hTempPen ); SelectBrush( hDC, hTempBrush ); -mpGraphics = ImplCreateSalPrnGraphics( hDC ); -return mpGraphics; +mxGraphics.reset(ImplCreateSalPrnGraphics( hDC )); +return mxGraphics.get(); } void WinSalPrinter::EndPage() { -delete mpGraphics; -mpGraphics = nullptr; +mxGraphics.reset(); if (!isValid()) return;
[Libreoffice-commits] core.git: sw/qa writerfilter/source
sw/qa/extras/ooxmlexport/data/tdf142407.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx |8 writerfilter/source/dmapper/PropertyMap.cxx |6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) New commits: commit 5f84c44e3d5ff19b800b6358e61228546e318d4f Author: Mark Hung AuthorDate: Thu Oct 7 23:54:51 2021 +0800 Commit: Mark Hung CommitDate: Mon Oct 11 14:16:16 2021 +0200 tdf#142407 fix incorrect number of lines in vertical writing. Wrting mode isn't read correctly. The property PROP_WRITING_MODE contans an Any of sal_Int16. When converting to WritingMode enum directly, it always get WrtingMode::LR_TB(0), hence use wrong side to calculate number of grid lines for vertical writing. The resulted number of grid lines are much smaller than expected, it ends up leaving large space between header and text. Change-Id: Ifb0ff09fe981819cc2705de8d5596190f320f79e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123223 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/ooxmlexport/data/tdf142407.docx b/sw/qa/extras/ooxmlexport/data/tdf142407.docx new file mode 100644 index ..38397a4de996 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf142407.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 523d4a6e747d..77645a84aefb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -106,6 +106,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123642_BookmarkAtDocEnd, "tdf123642.docx") CPPUNIT_ASSERT_EQUAL(OUString("Bookmark1"), getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:bookmarkStart[1]", "name")); } +DECLARE_OOXMLEXPORT_TEST(testTdf142407, "tdf142407.docx") +{ +uno::Reference xPageStyles = getStyles("PageStyles"); +uno::Reference xPageStyle(xPageStyles->getByName("Standard"), uno::UNO_QUERY); +sal_Int16 nGridLines; +xPageStyle->getPropertyValue("GridLines") >>= nGridLines; +CPPUNIT_ASSERT_EQUAL( sal_Int16(36), nGridLines); // was 23, left large space before text. +} CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index 3fdecb9ed576..920874afa39d 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -1710,12 +1710,12 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) if ( pProp ) pProp->second >>= nWidth; -text::WritingMode eWritingMode = text::WritingMode_LR_TB; +sal_Int16 nWritingMode = text::WritingMode2::LR_TB; pProp = getProperty( PROP_WRITING_MODE ); if ( pProp ) -pProp->second >>= eWritingMode; +pProp->second >>= nWritingMode; -sal_Int32 nTextAreaHeight = eWritingMode == text::WritingMode_LR_TB ? +sal_Int32 nTextAreaHeight = nWritingMode == text::WritingMode2::LR_TB ? nHeight - m_nTopMargin - m_nBottomMargin : nWidth - m_nLeftMargin - m_nRightMargin;
[Libreoffice-commits] core.git: sw/source
sw/source/ui/misc/pggrid.cxx | 19 +++ 1 file changed, 19 insertions(+) New commits: commit 8ac8a20ed15bb458e1ee5a8df2b97aef05ca4f7c Author: Mark Hung AuthorDate: Thu Oct 7 20:36:17 2021 +0800 Commit: Mark Hung CommitDate: Mon Oct 11 14:14:13 2021 +0200 tdf#141957 include the size of header and footer. Text grid dialog didn't include the size of header and footer, so if any of them are included, the resulted number of lines or chars per line was wrong. Change-Id: I09c1eed1552485adf75ad75cfaf25b99f8eec1e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123215 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/source/ui/misc/pggrid.cxx b/sw/source/ui/misc/pggrid.cxx index 5b1b69b05b37..875bee7ad331 100644 --- a/sw/source/ui/misc/pggrid.cxx +++ b/sw/source/ui/misc/pggrid.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -274,6 +275,24 @@ void SwTextGridPage::UpdatePageSize(const SfxItemSet& rSet) sal_Int32 nDistanceLR = rLRSpace.GetLeft() + rLRSpace.GetRight(); sal_Int32 nDistanceUL = rULSpace.GetUpper() + rULSpace.GetLower(); +for( sal_Int32 nId : { SID_ATTR_PAGE_HEADERSET, SID_ATTR_PAGE_FOOTERSET }) +{ +const SfxPoolItem* pItem; +if( SfxItemState::SET == rSet.GetItemState( nId, false, ) ) +{ +const SfxItemSet& rExtraSet = static_cast(pItem)->GetItemSet(); +const SfxBoolItem& rOn = +static_cast(rExtraSet.Get( rSet.GetPool()->GetWhich( SID_ATTR_PAGE_ON ) )); + +if ( rOn.GetValue() ) +{ +const SvxSizeItem& rSizeItem = +static_cast(rExtraSet.Get(rSet.GetPool()->GetWhich(SID_ATTR_PAGE_SIZE))); +nDistanceUL += rSizeItem.GetSize().Height(); +} +} +} + sal_Int32 nValue1 = rSize.GetSize().Height() - nDistanceUL - rBox.GetDistance(SvxBoxItemLine::TOP) - rBox.GetDistance(SvxBoxItemLine::BOTTOM);
Re: What is the best fit for hindiVowels import? CHARS_PERSIAN or CHARS_NEPALI
Hi Miklos and Justin, Miklos Vajna 於 2021年6月28日 週一 下午3:44寫道: > Hi Justin, > > On Thu, Jun 24, 2021 at 01:24:44PM +0200, Justin Luth > wrote: > > DOCX import was provided by commit > 9da74fa484772595fa50e188ba2c496a459cbd6b > > > > Author: Cédric Bosdonnat on Wed Mar 3 14:27:29 2010 +0100 > > cbosdo03: Fixed issue 109772. > > Backported go-oo patch to the CWS > > > > > > DOCX export was provided by commit > 91b926d4b9939337f54d6c9f0b940b161dc3437f > > Author: Mark Hung on Sun Jan 24 16:36:05 2016 +0800 > > tdf#84317 convert missing numbering types to OOXML tokens. > > Thanks for digging into the history of this. Mark is still around. > > Mark: any input on this? > > I don't remember how I mapped those enums. But I think it's reasonable to copy what doc filter does. Since I don't know the languages either, I'd prefer to let actual users judge about the result. Best regards. ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - vcl/inc vcl/source
vcl/inc/sallayout.hxx|2 +- vcl/source/gdi/sallayout.cxx | 17 - vcl/source/outdev/font.cxx | 12 3 files changed, 25 insertions(+), 6 deletions(-) New commits: commit f5e565eb0dcee2d7e42180b1fd0ad12555de2a22 Author: Mark Hung AuthorDate: Mon Jun 14 10:20:42 2021 +0800 Commit: Xisco Fauli CommitDate: Thu Jun 24 17:25:24 2021 +0200 tdf#142560 handle cached glpyh items in ImplGlyphFallbackLayout Fallback layout beyond level1 isn't generated because pre-caculated glyph items does not contain glyph items that needs to fallback, i.e. when calling ImplLayoutArgs::PrepareFallback. Hence it produce no maFallbackRuns and maRuns. The patch changes ImplLayoutArgs::PrepareFallback so that it use pre-caculated glyph items in the next level to create maRuns to ensure the same fallback layouts are genrated as layouts generated without pre-caculated glyph items. Change-Id: I672f3be6c4915892792b3cb968ad4a325465ccc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117105 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 10ea27faec115d4cffd6f66cee8f688399e1e0b2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117570 Reviewed-by: Xisco Fauli diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 3852442eeadb..f6783f3cc1ca 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -114,7 +114,7 @@ public: // methods used by BiDi and glyph fallback boolNeedFallback() const { return !maFallbackRuns.IsEmpty(); } -boolPrepareFallback(); +boolPrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl); private: voidAddRun( int nMinCharPos, int nEndCharPos, bool bRTL ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 9f4757148b36..7b8f2c2a2a05 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -486,8 +486,23 @@ void ImplLayoutArgs::AddRun( int nCharPos0, int nCharPos1, bool bRTL ) maRuns.AddRun( nCharPos0, nCharPos1, bRTL ); } -bool ImplLayoutArgs::PrepareFallback() +bool ImplLayoutArgs::PrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl) { +// Generate runs with pre-calculated glyph items instead maFallbackRuns. +if( pGlyphsImpl != nullptr ) +{ +maRuns.Clear(); +maFallbackRuns.Clear(); + +for (auto const& aGlyphItem : *pGlyphsImpl) +{ +for(int i = aGlyphItem.charPos(); i < aGlyphItem.charPos() + aGlyphItem.charCount(); ++i) +maRuns.AddPos(i, aGlyphItem.IsRTLGlyph()); +} + +return !maRuns.IsEmpty(); +} + // short circuit if no fallback is needed if( maFallbackRuns.IsEmpty() ) { diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index b6c7fcff82e3..6c761ec4bf07 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1254,7 +1254,7 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt // prepare multi level glyph fallback std::unique_ptr pMultiSalLayout; ImplLayoutRuns aLayoutRuns = rLayoutArgs.maRuns; -rLayoutArgs.PrepareFallback(); +rLayoutArgs.PrepareFallback(nullptr); rLayoutArgs.mnFlags |= SalLayoutFlags::ForFallback; // get list of code units that need glyph fallback @@ -1267,13 +1267,14 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear(); FontSelectPattern aFontSelData(mpFontInstance->GetFontSelectPattern()); +SalLayoutGlyphsImpl* pGlyphsImpl = pGlyphs ? pGlyphs->Impl(1) : nullptr; // try if fallback fonts support the missing code units for( int nFallbackLevel = 1; nFallbackLevel < MAX_FALLBACK; ++nFallbackLevel ) { rtl::Reference pFallbackFont; -if(pGlyphs != nullptr && pGlyphs->Impl(nFallbackLevel) != nullptr) -pFallbackFont = pGlyphs->Impl(nFallbackLevel)->GetFont(); +if(pGlyphsImpl != nullptr) +pFallbackFont = pGlyphsImpl->GetFont(); // find a font family suited for glyph fallback // GetGlyphFallbackFont() needs a valid FontInstance // if the system-specific glyph fallback is active @@ -1307,8 +1308,11 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt pMultiSalLayout->SetIncomplete(true); } +if (pGlyphs != nullptr) +pGlyphsImpl = pGlyphs->Impl(nFallbackLevel + 1); + // break when this fallback was sufficient -if( !rLayoutArgs.PrepareFallback() ) +if( !rLayoutArgs.PrepareFallback(pGlyphsImpl) ) break; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: vcl/inc vcl/source
vcl/inc/sallayout.hxx|2 +- vcl/source/gdi/sallayout.cxx | 17 - vcl/source/outdev/font.cxx | 12 3 files changed, 25 insertions(+), 6 deletions(-) New commits: commit 10ea27faec115d4cffd6f66cee8f688399e1e0b2 Author: Mark Hung AuthorDate: Mon Jun 14 10:20:42 2021 +0800 Commit: Mark Hung CommitDate: Mon Jun 21 13:22:23 2021 +0200 tdf#142560 handle cached glpyh items in ImplGlyphFallbackLayout Fallback layout beyond level1 isn't generated because pre-caculated glyph items does not contain glyph items that needs to fallback, i.e. when calling ImplLayoutArgs::PrepareFallback. Hence it produce no maFallbackRuns and maRuns. The patch changes ImplLayoutArgs::PrepareFallback so that it use pre-caculated glyph items in the next level to create maRuns to ensure the same fallback layouts are genrated as layouts generated without pre-caculated glyph items. Change-Id: I672f3be6c4915892792b3cb968ad4a325465ccc0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117105 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx index 3852442eeadb..f6783f3cc1ca 100644 --- a/vcl/inc/sallayout.hxx +++ b/vcl/inc/sallayout.hxx @@ -114,7 +114,7 @@ public: // methods used by BiDi and glyph fallback boolNeedFallback() const { return !maFallbackRuns.IsEmpty(); } -boolPrepareFallback(); +boolPrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl); private: voidAddRun( int nMinCharPos, int nEndCharPos, bool bRTL ); diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index 9f4757148b36..7b8f2c2a2a05 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -486,8 +486,23 @@ void ImplLayoutArgs::AddRun( int nCharPos0, int nCharPos1, bool bRTL ) maRuns.AddRun( nCharPos0, nCharPos1, bRTL ); } -bool ImplLayoutArgs::PrepareFallback() +bool ImplLayoutArgs::PrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl) { +// Generate runs with pre-calculated glyph items instead maFallbackRuns. +if( pGlyphsImpl != nullptr ) +{ +maRuns.Clear(); +maFallbackRuns.Clear(); + +for (auto const& aGlyphItem : *pGlyphsImpl) +{ +for(int i = aGlyphItem.charPos(); i < aGlyphItem.charPos() + aGlyphItem.charCount(); ++i) +maRuns.AddPos(i, aGlyphItem.IsRTLGlyph()); +} + +return !maRuns.IsEmpty(); +} + // short circuit if no fallback is needed if( maFallbackRuns.IsEmpty() ) { diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index b6c7fcff82e3..6c761ec4bf07 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1254,7 +1254,7 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt // prepare multi level glyph fallback std::unique_ptr pMultiSalLayout; ImplLayoutRuns aLayoutRuns = rLayoutArgs.maRuns; -rLayoutArgs.PrepareFallback(); +rLayoutArgs.PrepareFallback(nullptr); rLayoutArgs.mnFlags |= SalLayoutFlags::ForFallback; // get list of code units that need glyph fallback @@ -1267,13 +1267,14 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt OUString aMissingCodes = aMissingCodeBuf.makeStringAndClear(); FontSelectPattern aFontSelData(mpFontInstance->GetFontSelectPattern()); +SalLayoutGlyphsImpl* pGlyphsImpl = pGlyphs ? pGlyphs->Impl(1) : nullptr; // try if fallback fonts support the missing code units for( int nFallbackLevel = 1; nFallbackLevel < MAX_FALLBACK; ++nFallbackLevel ) { rtl::Reference pFallbackFont; -if(pGlyphs != nullptr && pGlyphs->Impl(nFallbackLevel) != nullptr) -pFallbackFont = pGlyphs->Impl(nFallbackLevel)->GetFont(); +if(pGlyphsImpl != nullptr) +pFallbackFont = pGlyphsImpl->GetFont(); // find a font family suited for glyph fallback // GetGlyphFallbackFont() needs a valid FontInstance // if the system-specific glyph fallback is active @@ -1307,8 +1308,11 @@ std::unique_ptr OutputDevice::ImplGlyphFallbackLayout( std::unique_pt pMultiSalLayout->SetIncomplete(true); } +if (pGlyphs != nullptr) +pGlyphsImpl = pGlyphs->Impl(nFallbackLevel + 1); + // break when this fallback was sufficient -if( !rLayoutArgs.PrepareFallback() ) +if( !rLayoutArgs.PrepareFallback(pGlyphsImpl) ) break; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: vcl/source
vcl/source/gdi/sallayout.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 8a65d3e9ceb268f785c5b2b77e126bd62af567a3 Author: Mark Hung AuthorDate: Thu May 13 23:57:31 2021 +0800 Commit: Mark Hung CommitDate: Fri May 28 07:03:53 2021 +0200 vcl: handle fallback glyph offset for vertical writing. When GenericSalLayout::MoveGlyph() is called from MultiSalLayout::AdjustLayout(), new position is calculatd by adding glyph advances ( i.e. glyph items' m_nNewWidth ). To move the glyph, the moving offset should be calculated based on the corresponding position, i.e. m_nXOffset v.s. m_LinearPos.X(). Change-Id: I912d499f49f69f68d8388bc8677e6b47bfb6f066 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115926 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx index cde5cac31730..9f4757148b36 100644 --- a/vcl/source/gdi/sallayout.cxx +++ b/vcl/source/gdi/sallayout.cxx @@ -949,7 +949,7 @@ void GenericSalLayout::MoveGlyph( int nStart, tools::Long nNewXPos ) if( pGlyphIter->IsRTLGlyph() ) nNewXPos += pGlyphIter->m_nNewWidth - pGlyphIter->origWidth(); // calculate the x-offset to the old position -tools::Long nXDelta = nNewXPos - pGlyphIter->m_aLinearPos.getX(); +tools::Long nXDelta = nNewXPos - pGlyphIter->m_aLinearPos.getX() + pGlyphIter->xOffset(); // adjust all following glyph positions if needed if( nXDelta != 0 ) { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: vcl/source
vcl/source/font/fontmetric.cxx |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 68c1682929d5b8af95e299a2cfb3fdbb4f97e5ed Author: Mark Hung AuthorDate: Sun May 2 11:38:16 2021 +0800 Commit: Mark Hung CommitDate: Mon May 10 21:15:04 2021 +0200 tdf#105650 different strikethrough offset for vertical writing. Change-Id: I7f1a8753bb00972865625628baeff76ff5dc4699 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115015 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx index 90873445bca1..817025286b37 100644 --- a/vcl/source/font/fontmetric.cxx +++ b/vcl/source/font/fontmetric.cxx @@ -170,7 +170,7 @@ void ImplFontMetricData::ImplInitTextLineSize( const OutputDevice* pDev ) const vcl::Font& rFont ( pDev->GetFont() ); bool bCJKVertical = MsLangId::isCJK(rFont.GetLanguage()) && rFont.IsVertical(); tools::Long nUnderlineOffset = bCJKVertical ? mnDescent : (mnDescent/2 + 1); -tools::Long nStrikeoutOffset = -((mnAscent - mnIntLeading) / 3); +tools::Long nStrikeoutOffset = rFont.IsVertical() ? -((mnAscent - mnDescent) / 2) : -((mnAscent - mnIntLeading) / 3); mnUnderlineSize= nLineHeight; mnUnderlineOffset = nUnderlineOffset - nLineHeight2; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: vcl/inc vcl/win
vcl/inc/win/salgdi.h|2 - vcl/win/gdi/salfont.cxx | 30 ++-- vcl/win/gdi/winlayout.cxx | 46 vcl/win/window/salframe.cxx | 12 --- 4 files changed, 10 insertions(+), 80 deletions(-) New commits: commit 5686c1aca40beb9514d40c86b4a3780a8a1334ba Author: Mark Hung AuthorDate: Sun May 2 14:45:45 2021 +0800 Commit: Mark Hung CommitDate: Mon May 10 21:14:09 2021 +0200 vcl: use DWriteTextRenderer for vertical writing. It's really not possible to support vertical writing with old ExTextOutW API, use DWriteTextRenderer in this case. This also get rid of the hacks to prepend '@' in front of the font name when it's for vertical writing. Change-Id: Icf594dd248be35fb101d6c1e296971f1acf56e39 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115017 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 21f1b46ec016..959d8abc0301 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -392,7 +392,7 @@ public: // Init/Deinit Graphics voidImplUpdateSysColorEntries(); int ImplIsSysColorEntry( Color nColor ); -voidImplGetLogFontFromFontSelect( HDC, const FontSelectPattern&, +voidImplGetLogFontFromFontSelect( const FontSelectPattern&, const PhysicalFontFace*, LOGFONTW& ); #define MAX_64KSALPOINTSsal_uInt16)0x)-8)/sizeof(POINTS)) diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 39f67e26a057..473f743d3cee 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -195,7 +195,7 @@ bool WinGlyphFallbackSubstititution::HasMissingChars(PhysicalFontFace* pFace, OU const FontSelectPattern aFSD( *pFace, aSize, static_cast(aSize.Height()), 0, false ); // construct log font LOGFONTW aLogFont; -ImplGetLogFontFromFontSelect( mhDC, aFSD, pFace, aLogFont ); +ImplGetLogFontFromFontSelect( aFSD, pFace, aLogFont ); // create HFONT from log font HFONT hNewFont = ::CreateFontIndirectW( ); @@ -768,8 +768,7 @@ static int CALLBACK SalEnumQueryFontProcExW( const LOGFONTW*, return 0; } -void ImplGetLogFontFromFontSelect( HDC hDC, - const FontSelectPattern& rFont, +void ImplGetLogFontFromFontSelect( const FontSelectPattern& rFont, const PhysicalFontFace* pFontFace, LOGFONTW& rLogFont ) { @@ -816,29 +815,6 @@ void ImplGetLogFontFromFontSelect( HDC hDC, if ( rFont.mbNonAntialiased ) rLogFont.lfQuality = NONANTIALIASED_QUALITY; -// select vertical mode if requested and available -if ( rFont.mbVertical && nNameLen ) -{ -// vertical fonts start with an '@' -memmove( [1], [0], -sizeof(rLogFont.lfFaceName)-sizeof(rLogFont.lfFaceName[0]) ); -rLogFont.lfFaceName[0] = '@'; - -// check availability of vertical mode for this font -bool bAvailable = false; -EnumFontFamiliesExW( hDC, , SalEnumQueryFontProcExW, - reinterpret_cast(), 0 ); - -if( !bAvailable ) -{ -// restore non-vertical name if not vertical mode isn't available -memcpy( [0], aName.getStr(), nNameLen*sizeof(wchar_t) ); -rLogFont.lfFaceName[nNameLen] = '\0'; -// keep it upright and create the font for sideway glyphs later. -rLogFont.lfEscapement = rLogFont.lfEscapement - 2700; -rLogFont.lfOrientation = rLogFont.lfEscapement; -} -} } HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont, @@ -848,7 +824,7 @@ HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern const & i_rFont, HFONT hNewFont = nullptr; LOGFONTW aLogFont; -ImplGetLogFontFromFontSelect( getHDC(), i_rFont, i_pFontFace, aLogFont ); +ImplGetLogFontFromFontSelect( i_rFont, i_pFontFace, aLogFont ); hNewFont = ::CreateFontIndirectW( ); diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx index 0f82d1af5bc6..c0fe1e32b863 100644 --- a/vcl/win/gdi/winlayout.cxx +++ b/vcl/win/gdi/winlayout.cxx @@ -80,53 +80,13 @@ TextOutRenderer& TextOutRenderer::get(bool bUseDWrite) bool ExTextOutRenderer::operator()(GenericSalLayout const& rLayout, SalGraphics& /*rGraphics*/, HDC hDC) { -HFONT hFont = static_cast(GetCurrentObject(hDC, OBJ_FONT)); -ScopedHFONT hAltFont; -bool bUseAltFont = false; -bool bShift = false; -if (rLayout.GetFont().GetFontSelectPattern().mbVertical) -{ -LOGFONTW aLogFont; -GetObjectW(hFont, sizeof(aLogFont), ); -if (aLogFont.lfFaceName[0] == '@') -{ -memmove([0], [1], -sizeof(aLogFont.lfFaceName) - sizeof(a
[Libreoffice-commits] core.git: vcl/win
vcl/win/gdi/salfont.cxx | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions(-) New commits: commit f0653d01e15ed9f0e0e862a0679ae6ac88a2cb07 Author: Mark Hung AuthorDate: Wed May 5 21:53:41 2021 +0800 Commit: Mark Hung CommitDate: Sat May 8 06:37:05 2021 +0200 vcl: vertical writing in WinFontInstance::ImplGetGlyphBoundRect. Identity matrix isn't enough for vertical writing. For those glyphs that is vertical, they have to be rotated 90 degrees. Change-Id: Ia5f1f8ac9cea89aec2c98b88058ec79f733fc238 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115148 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index 6fd4836e3040..39f67e26a057 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1254,7 +1254,7 @@ void WinSalGraphics::ClearDevFontCache() ImplReleaseTempFonts(*GetSalData(), false); } -bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool) const +bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& rRect, bool bIsVertical) const { assert(m_pGraphics); HDC hDC = m_pGraphics->getHDC(); @@ -1269,8 +1269,24 @@ bool WinFontInstance::ImplGetGlyphBoundRect(sal_GlyphId nId, tools::Rectangle& r // use unity matrix MAT2 aMat; -aMat.eM11 = aMat.eM22 = FixedFromDouble( 1.0 ); -aMat.eM12 = aMat.eM21 = FixedFromDouble( 0.0 ); +const FontSelectPattern& rFSD = GetFontSelectPattern(); + +// Use identity matrix for fonts requested in horizontal +// writing (LTR or RTL), or rotated glyphs in vertical writing. +if (!rFSD.mbVertical || !bIsVertical) +{ +aMat.eM11 = aMat.eM22 = FixedFromDouble(1.0); +aMat.eM12 = aMat.eM21 = FixedFromDouble(0.0); +} +else +{ +constexpr double nCos = 0.0; +constexpr double nSin = 1.0; +aMat.eM11 = FixedFromDouble(nCos); +aMat.eM12 = FixedFromDouble(nSin); +aMat.eM21 = FixedFromDouble(-nSin); +aMat.eM22 = FixedFromDouble(nCos); +} UINT nGGOFlags = GGO_METRICS; nGGOFlags |= GGO_GLYPH_INDEX; ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: vcl/inc vcl/win
vcl/inc/win/DWriteTextRenderer.hxx |2 +- vcl/win/gdi/DWriteTextRenderer.cxx | 14 ++ 2 files changed, 11 insertions(+), 5 deletions(-) New commits: commit b35b8079b3f03b93efdaf2d54b4a515df296e71d Author: Mark Hung AuthorDate: Sun May 2 11:28:34 2021 +0800 Commit: Mark Hung CommitDate: Sat May 8 06:34:31 2021 +0200 vcl: Rotate glyph in DWriteTextRenderer for vertical writing. - This is part of the work to make all the text renders consistently use the positions created from harfbuzz. - Rotate 90 deg if the glyph is vertical. Change-Id: I0ef6569cf019ed2cfeec0b7e7b9709a7e8cf8021 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115016 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/inc/win/DWriteTextRenderer.hxx b/vcl/inc/win/DWriteTextRenderer.hxx index 9011a951d277..6e097546d1e2 100644 --- a/vcl/inc/win/DWriteTextRenderer.hxx +++ b/vcl/inc/win/DWriteTextRenderer.hxx @@ -88,7 +88,7 @@ private: class WinFontTransformGuard { public: -WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline); +WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, const D2D1_POINT_2F& rBaseline, bool bIsVertical); ~WinFontTransformGuard(); private: diff --git a/vcl/win/gdi/DWriteTextRenderer.cxx b/vcl/win/gdi/DWriteTextRenderer.cxx index abf9be7d5f86..690f569dbeba 100644 --- a/vcl/win/gdi/DWriteTextRenderer.cxx +++ b/vcl/win/gdi/DWriteTextRenderer.cxx @@ -268,7 +268,7 @@ bool D2DWriteTextOutRenderer::performRender(GenericSalLayout const & rLayout, Sa DWRITE_GLYPH_OFFSET glyphOffsets[] = { { 0.0f, 0.0f }, }; D2D1_POINT_2F baseline = { static_cast(aPos.X() - bounds.Left()) / fHScale, static_cast(aPos.Y() - bounds.Top()) }; -WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, baseline); +WinFontTransformGuard aTransformGuard(mpRT, fHScale, rLayout, baseline, pGlyph->IsVertical()); DWRITE_GLYPH_RUN glyphs = { mpFontFace, mlfEmHeight, @@ -389,7 +389,8 @@ bool D2DWriteTextOutRenderer::GetDWriteFaceFromHDC(HDC hDC, IDWriteFontFace ** p WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, float fHScale, const GenericSalLayout& rLayout, - const D2D1_POINT_2F& rBaseline) + const D2D1_POINT_2F& rBaseline, + bool bIsVertical) : mpRenderTarget(pRenderTarget) { pRenderTarget->GetTransform(); @@ -400,13 +401,18 @@ WinFontTransformGuard::WinFontTransformGuard(ID2D1RenderTarget* pRenderTarget, f = aTransform * D2D1::Matrix3x2F::Scale(D2D1::Size(fHScale, 1.0f), D2D1::Point2F(0, 0)); } -if (rLayout.GetOrientation()) +Degree10 angle = rLayout.GetOrientation(); + +if (bIsVertical) +angle += 900_deg10; + +if (angle) { // DWrite angle is in clockwise degrees, our orientation is in counter-clockwise 10th // degrees. aTransform = aTransform * D2D1::Matrix3x2F::Rotation( - -static_cast(rLayout.GetOrientation().get()) / 10, rBaseline); + -static_cast(angle.get()) / 10, rBaseline); } mpRenderTarget->SetTransform(aTransform); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
Re: Fwd: Drawing vertical text glyphs
Hi Lubos, Luboš Luňák 於 2021年5月6日 週四 上午12:05寫道: > > Is there a testcase for that > I think you can take sample file from tdf#106295. It contains the set of fullwidth punctuations that worth testing. Also I find it useful, drawing the glyph bounding box together with the glyph. Based on my tests, Skia and DWrite text renderer ( with my patches on gerrit ) render consistently inside the bounding box. BTW, I've reported glyph positioning of windows built-in Chinese font DFKai-SB issue to Harfbuzz - i.e either we rely on Harfbuzz to fix the ot font functions, or we have to use Freetype for font functions to fix the problem. https://github.com/harfbuzz/harfbuzz/issues/2974 -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
[Libreoffice-commits] core.git: vcl/unx
vcl/unx/generic/gdi/cairotextrender.cxx | 16 1 file changed, 16 deletions(-) New commits: commit 6c9948d80aaa1d4827ccf741d900093abe7a973e Author: Mark Hung AuthorDate: Mon May 3 06:51:50 2021 +0800 Commit: Mark Hung CommitDate: Wed May 5 16:06:54 2021 +0200 vcl: adjust cairo text renderer for vertical writing , remove extra matrix translation and use the positions from Harfbuzz more directly. Change-Id: I2eb337b7f3bd70f4726f56d85a38f4a1f0931155 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115018 Tested-by: Jenkins Reviewed-by: Caolán McNamara Reviewed-by: Mark Hung diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx index 9cd6afaf7e53..b121f0f1b9d1 100644 --- a/vcl/unx/generic/gdi/cairotextrender.cxx +++ b/vcl/unx/generic/gdi/cairotextrender.cxx @@ -249,22 +249,6 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG cairo_matrix_init_identity(_square); cairo_set_matrix(cr, _square); - -//gives the same positions as pre-cairo conversion, but I don't -//like them -double xdiff = 0.0; -double ydiff = 0.0; - -// The y is the origin point position, but Cairo will draw -// the glyph *above* that point, we need to move it down to -// the glyph’s baseline. -cairo_text_extents_t aExt; -cairo_glyph_extents(cr, _glyphs[nStartIndex], nLen, ); -double nDescender = std::fmax(aExt.height + aExt.y_bearing, 0); -ydiff = (aExt.x_advance - nDescender) / nHeight; -xdiff = -font_extents.descent/nHeight; - -cairo_matrix_translate(, xdiff, ydiff); } if (rFont.NeedsArtificialItalic()) ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: vcl/source
vcl/source/gdi/CommonSalLayout.cxx | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) New commits: commit dd0d0b44fd1c6c0292d7b2eb3f5cf2baa21e4481 Author: Mark Hung AuthorDate: Sun May 2 15:12:46 2021 +0800 Commit: Mark Hung CommitDate: Wed May 5 16:06:15 2021 +0200 vcl: adjust LayoutText() for vertical writing. Revert 58af692e2814 "tdf#111967 translate offsets so it is relative to vorigin", which use hb_font_add_glyph_origin_for_direction to change the origin for vertical writing. This caused major problem in Y-axis. For X-axis, align the baseline of the vertical run to the center of the rotated horizontal run, by adding "(ascender + descener) / 2. Besides the alignment mentioned above, underlying text rendering code should be able to render properly based on the positions that Harfbuzz API creates. Change-Id: Ic1ef1f734686d0e61c4b2a6bf7feb7c870bba84f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115014 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 5565b3eb4d69..801abdd16670 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -325,6 +325,18 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm pTextLayout = pNewScriptRun.get(); } +// nBaseOffset is used to align vertical text to the center of rotated +// horizontal text. That is the offset from original baseline to +// the center of EM box. Maybe we can use OpenType base table to improve this +// in the future. +DeviceCoordinate nBaseOffset = 0; +if (rArgs.mnFlags & SalLayoutFlags::Vertical) +{ +hb_font_extents_t extents; +if (hb_font_get_h_extents(pHbFont, )) +nBaseOffset = ( extents.ascender + extents.descender ) / 2; +} + hb_buffer_t* pHbBuffer = hb_buffer_create(); hb_buffer_pre_allocate(pHbBuffer, nGlyphCapacity); #if !HB_VERSION_ATLEAST(1, 1, 0) @@ -583,16 +595,9 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs, const SalLayoutGlyphsIm { nGlyphFlags |= GlyphItemFlags::IS_VERTICAL; -// We have glyph offsets that is relative to h origin now, -// add the origin back so it is relative to v origin. -hb_font_add_glyph_origin_for_direction(pHbFont, -nGlyphIndex, -HB_DIRECTION_TTB, -[i].x_offset , -[i].y_offset ); nAdvance = -pHbPositions[i].y_advance; nXOffset = -pHbPositions[i].y_offset; -nYOffset = -pHbPositions[i].x_offset; +nYOffset = -pHbPositions[i].x_offset - nBaseOffset; } else { ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
Re: Fwd: Drawing vertical text glyphs
Hi Lubos, I investigate a little bit more in last few days. Since Libreoffice unified all the text layout to use Harfbuzz, it would be best to achieve the result consistent with output generated from Harfbuzz utilities. Binaries can be downloaded from [1]. Here are some examples I use to verify: ./hb-view -O png -o ~/output.png \ --shapers=ot,fallback \ --direction ttb \ --font-funcs=ot \ ~/下載/kaiu.ttf "「風調,雨順」" ./hb-shape -O text \ --shapers=ot,fallback \ --direction ttb \ --font-funcs=ot \ ~/下載/kaiu.ttf "「風調,雨順」" You can check if it is a text renderer's problem this way when something goes wrong. Note that LibreOffice use default font function implementation from Harfbuzz (opentype, --font-funcs=ot ), while the utility use Freetype library ( --font-funcs=ft ) by default. I find that an important Windows built-in font (Kaiu.ttf) doesn't work well with Harfbuzz ot font functions. Skia text renderer works with [2], but it means that other text renderers are broken. Since Harfbuzz utilities also use Cairo, I believe we must be able to achieve consistent results at least with Cairo. My fix there seems to work[3]. For Windows, I think it's not possible to make old ExTextOutW API correct for vertical writing. It is possible to use DWriteTextRenderer for vertical writing[4][5]. There are still some clipping issues, though. I don't have a Mac so someone needs to fix that if it's broken. [1]https://github.com/harfbuzz/harfbuzz/releases [2]https://gerrit.libreoffice.org/c/core/+/115014 [3]https://gerrit.libreoffice.org/c/core/+/115018 [4]https://gerrit.libreoffice.org/c/core/+/115016 [5]https://gerrit.libreoffice.org/c/core/+/115017 -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Re: Fwd: Drawing vertical text glyphs
Hi Lubos, Luboš Luňák 於 2021年4月29日 週四 上午1:19寫道: > On Wednesday 28 of April 2021, Mark Hung wrote: > > Anyway, if you need someone to verify text layout results with vertical > > writing or > > , don't hesitate to ask. > > > > I can definitely help. I can also verify patches on Windows. > > There is also a telegram group of TDF members from the CJK area if you > > prefer. > > The Skia VCL backend code for text drawing is > SkiaSalGraphicsImpl::drawGenericLayout(). For non-vertical glyphs, the > code > is easy, just iterate over all glyphs and pass them to Skia with their > positions, possibly rotated. That approach doesn't work well for vertical > glyphs, for the tdf#103785 document I get [1], with the glyphs being > positioned too high. If I apply the attached patch that moves all vertical > glyphs down based on the glyph height, then I get [2], which appears to be > at > least roughly acceptable, although it doesn't look to be completely > correct. > > And I don't know how to make it correct. First of all, I don't know how > to > visually identify what is correct. At [3] I've uploaded screenshots of the > document rendered by LO/Cairo, LO/GDI and Word2013. They are all > different, > both in X and Y positioning. Cairo draws them slightly to the left of the > latin alphabet characters, GDI is roughly centered, Word draws them to the > right. Vertically they also differ, I made sure to include cursor in all > the > screenshots and e.g. with the first glyph (中) the cursor doesn't touch the > glyph with Word, it touches it with GDI and it overlaps the glyph with > Cairo > (the image may need zooming to see it clearly). Which of those are correct? > > To be honest, I can only verify from the point of view of a user who can read Chinese. The cursor which overlaps the position doesn't seem right. It's not a big problem as long as it does not strike through the glyph in the middle. But the inconsistence among platforms might be a problem. I would have tested fullwidth punctuations. It went wrong in vertical writing before. > Second, I would need to express the correct positioning in the code. Do > you > know how to do that? I copied the glyph-size change in the attached patch > from Cairo, it also moves in X direction by the font descent, but I'd > prefer > not to do random modifications without understanding them. > > I tried to make a patch to highlight the relative positions, and find out something that I added to fix the issue - of course it can not complete fix the problem, but it may make more sense. https://gerrit.libreoffice.org/c/core/+/114887 ( the image of the test of the patch is also attached. ) Vertical positioning there is more correct to me. It also doesn't overlap with the cursor. It introduce horizontal offset issue unfortunately. Hope that helps. > [1] https://people.collabora.com/~llunak/skia/skia_current.png > [2] https://people.collabora.com/~llunak/skia/skia_vert1.png > [3] https://people.collabora.com/~llunak/skia/ > > -- > Luboš Luňák > l.lu...@collabora.com > -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
Fwd: Drawing vertical text glyphs
Hi, I just found that I didn't send to the list. -- Forwarded message - 寄件者: Mark Hung Date: 2021年4月28日 週三 上午12:46 Subject: Re: Drawing vertical text glyphs To: Luboš Luňák Hi Lubos, Maybe it's after I commited 51b9042efea0, that I started to feel that vertical writing just worked by coincidence. I tried to start from what we get from Harfbuzz. In theory, if the sample code with Cairo there works, then we can expect the correct result in LibreOffice. We rotate things at many places. I'd prefer to get rid of those rotations if possible. For example in SalLayout::GetDrawPosition called by GenericSalLayout::GetNextGlyph And underlying platform code rotate them again, like calling cairo_matrix_rotate in CairoTextRender::DrawTextLayout. I wonder where the center is when rotation is applied. And how GetNextGlyph() returns a position that is unified among all the underlying text render API on all platforms. Do all of them have the same offset from reference point to the origin of a glyph? These are unanswered questions to myself. Anyway, if you need someone to verify text layout results with vertical writing or , don't hesitate to ask. I can definitely help. I can also verify patches on Windows. There is also a telegram group of TDF members from the CJK area if you prefer. Luboš Luňák 於 2021年4月26日 週一 下午6:30寫道: > > Hello, > > is here somebody who understands drawing vertical (asian etc.) texts? I > need > help in that area for the Skia backend. > > Specifically, the problems are tdf#137907, tdf#136081 and tdf#105650, > which > all stem from the same problem of positioning vertical glyphs. > Positioning "normal" horizontal glyphs works fine, even in rotated text. > I've > looked at other VCL backends, and most of them handle vertical glyphs > specially[*], and each of them in a different way. And the visual results > are > also different for those that I can check, and even that is different from > what I can see if I check e.g. tdf#103785 in MS Office. > > Given that I don't have that deep understanding of font rendering and I'm > also not familiar with languages that need vertical glyphs, I have no idea > what the correct way to do this should be. Is there somebody who > understands > this and could help me (preferably with knowledge of how it works, but > even > just being able to visually tell what's correct could do). > > [*] AquaSalGraphics::DrawTextLayout(), CairoTextRender::DrawTextLayout(), > PrinterGfx::DrawGlyph(), ExTextOutRenderer::operator() , make your pick > > -- > Luboš Luňák > l.lu...@collabora.com > ___ > LibreOffice mailing list > LibreOffice@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/libreoffice > -- Mark Hung -- Mark Hung ___ LibreOffice mailing list LibreOffice@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - include/svx svx/source
include/svx/sdrundomanager.hxx |2 ++ svx/source/svdraw/sdrundomanager.cxx |3 +++ svx/source/svdraw/svdedxv.cxx|3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) New commits: commit 016a83306f6744892038b1bd9e6a6817e6a8c087 Author: Mark Hung AuthorDate: Wed Apr 14 22:30:06 2021 +0800 Commit: Michael Stahl CommitDate: Wed Apr 21 11:41:03 2021 +0200 tdf#131634 Don't redo actions created before text edit begins. In SdrObjEditView::SdrEndTextEdit(), pSdrUndoManager->Redo() was invoked until all the redo actions created after text edit began were converted to undo actions. Without checking, all the redo actions include the ones created before text edit began were moved to undo stack, and caused the SdrTextObj to be destroyed in SdrUndoManager::SetEndTextEditHdl when removing the undo actions and a use after release problem. The patch add GetRedoActionCountBeforeTextEdit() so the program won't invoke pSdrUndoManager->Redo() on actions created before text edit begin. Change-Id: Ic010bc6e71ee78ef2cb20a5259dc9d6d6579ccaa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114102 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 7a641c71f8191e83bb6c408d3ff51a58d7dd4af9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114360 Reviewed-by: Caolán McNamara Reviewed-by: Michael Stahl diff --git a/include/svx/sdrundomanager.hxx b/include/svx/sdrundomanager.hxx index 12fa1c7b3852..9ff23e441c54 100644 --- a/include/svx/sdrundomanager.hxx +++ b/include/svx/sdrundomanager.hxx @@ -33,6 +33,7 @@ private: Link maEndTextEditHdl; SfxUndoAction* mpLastUndoActionBeforeTextEdit; +size_t mnRedoActionCountBeforeTextEdit; bool mbEndTextEditTriggeredFromUndo; SfxObjectShell* m_pDocSh; @@ -64,6 +65,7 @@ public: // by a last undo during text edit bool isEndTextEditTriggeredFromUndo() const { return mbEndTextEditTriggeredFromUndo; } void SetDocShell(SfxObjectShell* pDocShell); +size_t GetRedoActionCountBeforeTextEdit() const { return mnRedoActionCountBeforeTextEdit; } }; #endif // INCLUDED_SVX_SDRUNDOMANAGER_HXX diff --git a/svx/source/svdraw/sdrundomanager.cxx b/svx/source/svdraw/sdrundomanager.cxx index 1e64a1a89482..8b1f19fbecfa 100644 --- a/svx/source/svdraw/sdrundomanager.cxx +++ b/svx/source/svdraw/sdrundomanager.cxx @@ -25,6 +25,7 @@ SdrUndoManager::SdrUndoManager() : EditUndoManager(20 /*nMaxUndoActionCount*/) , maEndTextEditHdl() , mpLastUndoActionBeforeTextEdit(nullptr) +, mnRedoActionCountBeforeTextEdit(0) , mbEndTextEditTriggeredFromUndo(false) , m_pDocSh(nullptr) { @@ -107,6 +108,7 @@ void SdrUndoManager::SetEndTextEditHdl(const Link& rLink) { // text edit start, remember last non-textedit action for later cleanup mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction() : nullptr; +mnRedoActionCountBeforeTextEdit = GetRedoActionCount(); } else { @@ -123,6 +125,7 @@ void SdrUndoManager::SetEndTextEditHdl(const Link& rLink) // forget marker again mpLastUndoActionBeforeTextEdit = nullptr; +mnRedoActionCountBeforeTextEdit = 0; } } diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index 8220b4c59b03..736d31b7aac5 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1438,7 +1438,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally) // to create a complete text change undo action for the redo buffer. Also mark this // state when at least one redo was executed; the created extra TextChange needs to // be undone in addition to the first real undo outside the text edit changes -while (pSdrUndoManager->GetRedoActionCount()) +while (pSdrUndoManager->GetRedoActionCount() + > pSdrUndoManager->GetRedoActionCountBeforeTextEdit()) { bNeedToUndoSavedRedoTextEdit = true; pSdrUndoManager->Redo(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: include/svx svx/source
include/svx/sdrundomanager.hxx |2 ++ svx/source/svdraw/sdrundomanager.cxx |3 +++ svx/source/svdraw/svdedxv.cxx|3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) New commits: commit 7a641c71f8191e83bb6c408d3ff51a58d7dd4af9 Author: Mark Hung AuthorDate: Wed Apr 14 22:30:06 2021 +0800 Commit: Mark Hung CommitDate: Fri Apr 16 15:04:07 2021 +0200 tdf#131634 Don't redo actions created before text edit begins. In SdrObjEditView::SdrEndTextEdit(), pSdrUndoManager->Redo() was invoked until all the redo actions created after text edit began were converted to undo actions. Without checking, all the redo actions include the ones created before text edit began were moved to undo stack, and caused the SdrTextObj to be destroyed in SdrUndoManager::SetEndTextEditHdl when removing the undo actions and a use after release problem. The patch add GetRedoActionCountBeforeTextEdit() so the program won't invoke pSdrUndoManager->Redo() on actions created before text edit begin. Change-Id: Ic010bc6e71ee78ef2cb20a5259dc9d6d6579ccaa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114102 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/include/svx/sdrundomanager.hxx b/include/svx/sdrundomanager.hxx index 12fa1c7b3852..9ff23e441c54 100644 --- a/include/svx/sdrundomanager.hxx +++ b/include/svx/sdrundomanager.hxx @@ -33,6 +33,7 @@ private: Link maEndTextEditHdl; SfxUndoAction* mpLastUndoActionBeforeTextEdit; +size_t mnRedoActionCountBeforeTextEdit; bool mbEndTextEditTriggeredFromUndo; SfxObjectShell* m_pDocSh; @@ -64,6 +65,7 @@ public: // by a last undo during text edit bool isEndTextEditTriggeredFromUndo() const { return mbEndTextEditTriggeredFromUndo; } void SetDocShell(SfxObjectShell* pDocShell); +size_t GetRedoActionCountBeforeTextEdit() const { return mnRedoActionCountBeforeTextEdit; } }; #endif // INCLUDED_SVX_SDRUNDOMANAGER_HXX diff --git a/svx/source/svdraw/sdrundomanager.cxx b/svx/source/svdraw/sdrundomanager.cxx index 1e64a1a89482..8b1f19fbecfa 100644 --- a/svx/source/svdraw/sdrundomanager.cxx +++ b/svx/source/svdraw/sdrundomanager.cxx @@ -25,6 +25,7 @@ SdrUndoManager::SdrUndoManager() : EditUndoManager(20 /*nMaxUndoActionCount*/) , maEndTextEditHdl() , mpLastUndoActionBeforeTextEdit(nullptr) +, mnRedoActionCountBeforeTextEdit(0) , mbEndTextEditTriggeredFromUndo(false) , m_pDocSh(nullptr) { @@ -107,6 +108,7 @@ void SdrUndoManager::SetEndTextEditHdl(const Link& rLink) { // text edit start, remember last non-textedit action for later cleanup mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction() : nullptr; +mnRedoActionCountBeforeTextEdit = GetRedoActionCount(); } else { @@ -123,6 +125,7 @@ void SdrUndoManager::SetEndTextEditHdl(const Link& rLink) // forget marker again mpLastUndoActionBeforeTextEdit = nullptr; +mnRedoActionCountBeforeTextEdit = 0; } } diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx index e18738dba12a..a4ae54035c2c 100644 --- a/svx/source/svdraw/svdedxv.cxx +++ b/svx/source/svdraw/svdedxv.cxx @@ -1441,7 +1441,8 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally) // to create a complete text change undo action for the redo buffer. Also mark this // state when at least one redo was executed; the created extra TextChange needs to // be undone in addition to the first real undo outside the text edit changes -while (pSdrUndoManager->GetRedoActionCount()) +while (pSdrUndoManager->GetRedoActionCount() + > pSdrUndoManager->GetRedoActionCountBeforeTextEdit()) { bNeedToUndoSavedRedoTextEdit = true; pSdrUndoManager->Redo(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sd/qa svx/source
sd/qa/unit/misc-tests.cxx | 35 ++ svx/source/table/tablemodel.cxx | 62 +++- 2 files changed, 71 insertions(+), 26 deletions(-) New commits: commit d47afb54ed3e37be7216b5f2e3943f1ab7bdb84f Author: Mark Hung AuthorDate: Thu Mar 11 23:44:06 2021 +0800 Commit: Xisco Fauli CommitDate: Wed Mar 17 21:21:38 2021 +0100 tdf#136956 reorder undo actions in removeColumns and removeRows. Inside the removeColumns and removeRows, undo actions are added first, and then cell spans are updated to reflect the removed columns or rows. Once undo the cell spans they become immediately invalid because the rows or columns are already removed, hence cause Impress to crash. Change-Id: I9d8641bdad43026eca03cbeaaa3a5907b516304f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112355 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit f3f7cc53efda828af8897fa45fa2a8f18cf3b48b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112526 Reviewed-by: Michael Stahl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112649 diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 216bdb7d08b0..086170576636 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -83,6 +85,7 @@ public: void testTdf130988(); void testTdf131033(); void testTdf129898LayerDrawnInSlideshow(); +void testTdf136956(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); @@ -104,6 +107,7 @@ public: CPPUNIT_TEST(testTdf130988); CPPUNIT_TEST(testTdf131033); CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow); +CPPUNIT_TEST(testTdf136956); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -879,6 +883,37 @@ void SdMiscTest::testTdf129898LayerDrawnInSlideshow() xDocShRef->DoClose(); } +void SdMiscTest::testTdf136956() +{ +::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/cellspan.odp"), ODP); + +const SdrPage *pPage = GetPage( 1, xDocShRef ); +sdr::table::SdrTableObj *pTableObj = dynamic_cast(pPage->GetObj(0)); +CPPUNIT_ASSERT( pTableObj ); +uno::Reference< table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW); + +uno::Reference< css::table::XMergeableCellRange > xRange( +xTable->createCursorByRange( xTable->getCellRangeByPosition( 0, 0, 3, 2 ) ), uno::UNO_QUERY_THROW ); + +// 4x3 Table before merge. +CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); + +xRange->merge(); + +// 1x1 Table after merge. +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRowCount()); + +xDocShRef->GetUndoManager()->Undo(); + +// 4x3 Table after undo. Undo crashed before. +CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); + +xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index 464f862c0947..0fb08353d8a8 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -692,24 +692,6 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) { rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - -TableModelRef xThis( this ); -ColumnVector aRemovedCols( nCount ); -sal_Int32 nOffset; -for( nOffset = 0; nOffset < nCount; ++nOffset ) -{ -aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; -} - -CellVector aRemovedCells( nCount * nRows ); -CellVector::iterator aCellIter( aRemovedCells.begin() ); -for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) -{ -for( nOffset = 0; nOffset < nCount; ++nOffset ) -(*aCellIter++) = getCell( nIndex + nOffset, nRow ); -} - -rModel.AddUndo( std::make_unique( xThis, nIndex, aRemovedCols, aRemovedCells ) ); } // only rows before and inside the removed rows are considered @@ -756,6 +738,29 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) } } +// We must not add RemoveColU
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sd/qa svx/source
sd/qa/unit/misc-tests.cxx | 35 ++ svx/source/table/tablemodel.cxx | 61 ++-- 2 files changed, 70 insertions(+), 26 deletions(-) New commits: commit eeeb3a422e25c22201e1325154f1913df3942f2a Author: Mark Hung AuthorDate: Thu Mar 11 23:44:06 2021 +0800 Commit: Michael Stahl CommitDate: Wed Mar 17 11:00:44 2021 +0100 tdf#136956 reorder undo actions in removeColumns and removeRows. Inside the removeColumns and removeRows, undo actions are added first, and then cell spans are updated to reflect the removed columns or rows. Once undo the cell spans they become immediately invalid because the rows or columns are already removed, hence cause Impress to crash. Change-Id: I9d8641bdad43026eca03cbeaaa3a5907b516304f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112355 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit f3f7cc53efda828af8897fa45fa2a8f18cf3b48b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112526 Reviewed-by: Michael Stahl diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 52c3b55513be..75818805295a 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -83,6 +85,7 @@ public: void testTdf130988(); void testTdf131033(); void testTdf129898LayerDrawnInSlideshow(); +void testTdf136956(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); @@ -104,6 +107,7 @@ public: CPPUNIT_TEST(testTdf130988); CPPUNIT_TEST(testTdf131033); CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow); +CPPUNIT_TEST(testTdf136956); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -875,6 +879,37 @@ void SdMiscTest::testTdf129898LayerDrawnInSlideshow() xDocShRef->DoClose(); } +void SdMiscTest::testTdf136956() +{ +::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/cellspan.odp"), ODP); + +const SdrPage *pPage = GetPage( 1, xDocShRef ); +sdr::table::SdrTableObj *pTableObj = dynamic_cast(pPage->GetObj(0)); +CPPUNIT_ASSERT( pTableObj ); +uno::Reference< table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW); + +uno::Reference< css::table::XMergeableCellRange > xRange( +xTable->createCursorByRange( xTable->getCellRangeByPosition( 0, 0, 3, 2 ) ), uno::UNO_QUERY_THROW ); + +// 4x3 Table before merge. +CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); + +xRange->merge(); + +// 1x1 Table after merge. +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRowCount()); + +xDocShRef->GetUndoManager()->Undo(); + +// 4x3 Table after undo. Undo crashed before. +CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); + +xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index d7d04191163c..993535a52ec7 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -694,24 +694,6 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) { rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - -TableModelRef xThis( this ); -ColumnVector aRemovedCols( nCount ); -sal_Int32 nOffset; -for( nOffset = 0; nOffset < nCount; ++nOffset ) -{ -aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; -} - -CellVector aRemovedCells( nCount * nRows ); -CellVector::iterator aCellIter( aRemovedCells.begin() ); -for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) -{ -for( nOffset = 0; nOffset < nCount; ++nOffset ) -(*aCellIter++) = getCell( nIndex + nOffset, nRow ); -} - -rModel.AddUndo( std::make_unique( xThis, nIndex, aRemovedCols, aRemovedCells ) ); } // only rows before and inside the removed rows are considered @@ -758,6 +740,29 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) } } +// We must not add RemoveColUndo before we make cell spans correct, otherwise we +// get invalid cell span after undo. +if( bUndo ) +{ +TableModelRef xThis( this );
[Libreoffice-commits] core.git: sd/qa svx/source
sd/qa/unit/misc-tests.cxx | 35 ++ svx/source/table/tablemodel.cxx | 61 ++-- 2 files changed, 70 insertions(+), 26 deletions(-) New commits: commit f3f7cc53efda828af8897fa45fa2a8f18cf3b48b Author: Mark Hung AuthorDate: Thu Mar 11 23:44:06 2021 +0800 Commit: Mark Hung CommitDate: Tue Mar 16 15:23:58 2021 +0100 tdf#136956 reorder undo actions in removeColumns and removeRows. Inside the removeColumns and removeRows, undo actions are added first, and then cell spans are updated to reflect the removed columns or rows. Once undo the cell spans they become immediately invalid because the rows or columns are already removed, hence cause Impress to crash. Change-Id: I9d8641bdad43026eca03cbeaaa3a5907b516304f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112355 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 0ae169ce4431..d7fbf74ef58a 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include #include @@ -82,6 +84,7 @@ public: void testTdf130988(); void testTdf131033(); void testTdf129898LayerDrawnInSlideshow(); +void testTdf136956(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); @@ -103,6 +106,7 @@ public: CPPUNIT_TEST(testTdf130988); CPPUNIT_TEST(testTdf131033); CPPUNIT_TEST(testTdf129898LayerDrawnInSlideshow); +CPPUNIT_TEST(testTdf136956); CPPUNIT_TEST_SUITE_END(); virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override @@ -874,6 +878,37 @@ void SdMiscTest::testTdf129898LayerDrawnInSlideshow() xDocShRef->DoClose(); } +void SdMiscTest::testTdf136956() +{ +::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/cellspan.odp"), ODP); + +const SdrPage *pPage = GetPage( 1, xDocShRef ); +sdr::table::SdrTableObj *pTableObj = dynamic_cast(pPage->GetObj(0)); +CPPUNIT_ASSERT( pTableObj ); +uno::Reference< table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW); + +uno::Reference< css::table::XMergeableCellRange > xRange( +xTable->createCursorByRange( xTable->getCellRangeByPosition( 0, 0, 3, 2 ) ), uno::UNO_QUERY_THROW ); + +// 4x3 Table before merge. +CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); + +xRange->merge(); + +// 1x1 Table after merge. +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRowCount()); + +xDocShRef->GetUndoManager()->Undo(); + +// 4x3 Table after undo. Undo crashed before. +CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getColumnCount()); +CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTable->getRowCount()); + +xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/source/table/tablemodel.cxx b/svx/source/table/tablemodel.cxx index 6efcbd1280dc..a6d21f3935db 100644 --- a/svx/source/table/tablemodel.cxx +++ b/svx/source/table/tablemodel.cxx @@ -694,24 +694,6 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) { rModel.BegUndo( SvxResId(STR_UNDO_COL_DELETE) ); rModel.AddUndo( rModel.GetSdrUndoFactory().CreateUndoGeoObject(*mpTableObj) ); - -TableModelRef xThis( this ); -ColumnVector aRemovedCols( nCount ); -sal_Int32 nOffset; -for( nOffset = 0; nOffset < nCount; ++nOffset ) -{ -aRemovedCols[nOffset] = maColumns[nIndex+nOffset]; -} - -CellVector aRemovedCells( nCount * nRows ); -CellVector::iterator aCellIter( aRemovedCells.begin() ); -for( sal_Int32 nRow = 0; nRow < nRows; ++nRow ) -{ -for( nOffset = 0; nOffset < nCount; ++nOffset ) -(*aCellIter++) = getCell( nIndex + nOffset, nRow ); -} - -rModel.AddUndo( std::make_unique( xThis, nIndex, aRemovedCols, aRemovedCells ) ); } // only rows before and inside the removed rows are considered @@ -758,6 +740,29 @@ void TableModel::removeColumns( sal_Int32 nIndex, sal_Int32 nCount ) } } +// We must not add RemoveColUndo before we make cell spans correct, otherwise we +// get invalid cell span after undo. +if( bUndo ) +{ +TableModelRef xThis( this ); +ColumnVector aRemovedCols( nCount ); +sal_Int32 nOffset; +for( nOffset = 0; nOffset < nCount; ++nOffset ) +{ +aRemoved
[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - include/oox oox/source sd/qa
include/oox/export/shapes.hxx |4 ++- oox/source/export/shapes.cxx | 46 - sd/qa/unit/data/odp/tdf119223.odp |binary sd/qa/unit/data/xml/tdf90338_0.xml |2 - sd/qa/unit/data/xml/tdf92001_0.xml |2 - sd/qa/unit/export-tests-ooxml2.cxx | 36 6 files changed, 66 insertions(+), 24 deletions(-) New commits: commit 3212626c66205ab8f38cf17350522bd5705c77a8 Author: Mark Hung AuthorDate: Sun Jun 28 10:57:09 2020 +0800 Commit: Gabor Kelemen CommitDate: Thu Feb 25 13:43:59 2021 +0100 tdf#119223 export the object name for pptx documents. Originally the name was always an object type plus an index. That not only ignores the existing object name, but also makes an unnamed object named in the roundtrip. So here the object name is used no matter it is empty or not, to keep unamed object unamed. Change-Id: Ib29a8fbc1fd67fa9a4a4efbfd0b2e9c4fb50de0a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96908 Tested-by: Jenkins Reviewed-by: Mark Hung Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111536 Tested-by: Gabor Kelemen Reviewed-by: Gabor Kelemen diff --git a/include/oox/export/shapes.hxx b/include/oox/export/shapes.hxx index 2dbbb658c036..53d505f168a2 100644 --- a/include/oox/export/shapes.hxx +++ b/include/oox/export/shapes.hxx @@ -87,10 +87,12 @@ public: typedef std::unordered_map< css::uno::Reference< css::drawing::XShape>, sal_Int32> ShapeHashMap; protected: -sal_Int32 mnShapeIdMax, mnPictureIdMax; +sal_Int32 mnShapeIdMax; void WriteGraphicObjectShapePart( const css::uno::Reference< css::drawing::XShape >& xShape, const Graphic *pGraphic=nullptr ); +OUStringGetShapeName(const css::uno::Reference< css::drawing::XShape >& xShape); + private: sal_Int32 mnXmlNamespace; MapMode maMapModeSrc, maMapModeDest; diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index 8a86bb07152c..ab0d53861d3e 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -91,7 +91,6 @@ using ::css::frame::XModel; using ::oox::core::XmlFilterBase; using ::sax_fastparser::FSHelperPtr; -#define IDS(x) OString(#x " " + OString::number(mnShapeIdMax++)).getStr() namespace oox { @@ -325,7 +324,6 @@ ShapeExport::ShapeExport( sal_Int32 nXmlNamespace, FSHelperPtr pFS, ShapeHashMap : DrawingML( std::move(pFS), pFB, eDocumentType, pTextExport ) , m_nEmbeddedObjects(0) , mnShapeIdMax( 1 ) -, mnPictureIdMax( 1 ) , mnXmlNamespace( nXmlNamespace ) , maMapModeSrc( MapUnit::Map100thMM ) , maMapModeDest( MapUnit::MapInch, Point(), Fraction( 1, 576 ), Fraction( 1, 576 ) ) @@ -416,7 +414,7 @@ ShapeExport& ShapeExport::WritePolyPolygonShape( const Reference< XShape >& xSha pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), - XML_name, IDS( Freeform ) ); + XML_name, GetShapeName(xShape).toUtf8()); } pFS->singleElementNS(mnXmlNamespace, XML_cNvSpPr); if (GetDocumentType() != DOCUMENT_DOCX) @@ -477,7 +475,7 @@ ShapeExport& ShapeExport::WriteGroupShape(const uno::Reference& pFS->startElementNS(mnXmlNamespace, XML_nvGrpSpPr); pFS->singleElementNS(mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), -XML_name, IDS(Group)); +XML_name, GetShapeName(xShape).toUtf8()); pFS->singleElementNS(mnXmlNamespace, XML_cNvGrpSpPr); WriteNonVisualProperties(xShape ); pFS->endElementNS(mnXmlNamespace, XML_nvGrpSpPr); @@ -803,7 +801,7 @@ ShapeExport& ShapeExport::WriteCustomShape( const Reference< XShape >& xShape ) pFS->startElementNS( mnXmlNamespace, XML_nvSpPr ); pFS->startElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), -XML_name, IDS( CustomShape ), +XML_name, GetShapeName(xShape).toUtf8(), XML_hidden, isVisible ? nullptr : "1" ); if( GETA( URL ) ) @@ -1061,7 +1059,7 @@ ShapeExport& ShapeExport::WriteEllipseShape( const Reference< XShape >& xShape ) pFS->startElementNS(mnXmlNamespace, XML_nvSpPr); pFS->singleElementNS( mnXmlNamespace, XML_cNvPr, XML_id, OString::number(GetNewShapeID(xShape)), -XML_name, IDS( Ellipse ) ); +XML_name, GetShapeName(xShape).toUtf8()); pFS->singleElementNS( mnXmlNamespace, XML_cNvSpPr ); WriteNonVisualProperties
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sc/qa sc/source
sc/qa/unit/data/ods/tdf129940.ods|binary sc/qa/unit/subsequent_filters-test.cxx | 21 sc/source/filter/xml/celltextparacontext.cxx | 120 --- sc/source/filter/xml/celltextparacontext.hxx | 45 ++ 4 files changed, 177 insertions(+), 9 deletions(-) New commits: commit 297f511263db7434bb10cdc91230b4d3f8ac9aa0 Author: Mark Hung AuthorDate: Thu Jan 28 22:53:49 2021 +0800 Commit: Michael Stahl CommitDate: Wed Feb 10 10:54:46 2021 +0100 tdf#129940 handle text:ruby element inside text:p Implement ScXMLCellTextRubyContext for text:ruby. It creates two types of child elements: ScXMLCellRubyBaseContext for text:ruby-base, and ScXMLCellRubyTextContext, for text:ruby-text. Ruby text isn't used now, but can serve for future application. Change-Id: I33b778838032458ffbefc6a2835d2ae59dff30cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110088 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit e630da1ed8a27c64bc9f22ecb71afd10bf252d93) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110567 Reviewed-by: Michael Stahl diff --git a/sc/qa/unit/data/ods/tdf129940.ods b/sc/qa/unit/data/ods/tdf129940.ods new file mode 100644 index ..5cc5369acd49 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf129940.ods differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 3d5621da963d..47837905f407 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -297,6 +297,7 @@ public: void testDeleteCircles(); void testDrawCircleInMergeCells(); void testDeleteCirclesInRowAndCol(); +void testTdf129940(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCondFormatFormulaIsXLSX); @@ -479,6 +480,7 @@ public: CPPUNIT_TEST(testDeleteCircles); CPPUNIT_TEST(testDrawCircleInMergeCells); CPPUNIT_TEST(testDeleteCirclesInRowAndCol); +CPPUNIT_TEST(testTdf129940); CPPUNIT_TEST_SUITE_END(); @@ -5367,6 +5369,25 @@ void ScFiltersTest::testDeleteCirclesInRowAndCol() xDocSh->DoClose(); } +void ScFiltersTest::testTdf129940() +{ +// Test pure span elements inside text:ruby-base +ScDocShellRef xDocSh = loadDoc(u"tdf129940.", FORMAT_ODS); +CPPUNIT_ASSERT_MESSAGE("Failed to load tdf129940.ods", xDocSh.is()); +ScDocument& rDoc = xDocSh->GetDocument(); +// Pure text within text:ruby-base +OUString aStr = rDoc.GetString(ScAddress(0,0,0)); +CPPUNIT_ASSERT_EQUAL(OUString(u"小笠原"), aStr); +aStr = rDoc.GetString(ScAddress(1,0,0)); +CPPUNIT_ASSERT_EQUAL(OUString(u"徳彦"), aStr); + +// Multiple text:span within text:ruby-base +aStr = rDoc.GetString(ScAddress(2,0,0)); +CPPUNIT_ASSERT_EQUAL(OUString(u"注音符號"), aStr); + +xDocSh->DoClose(); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) { diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx index 8a54d38c2b32..ce7f90651645 100644 --- a/sc/source/filter/xml/celltextparacontext.cxx +++ b/sc/source/filter/xml/celltextparacontext.cxx @@ -60,6 +60,8 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellTextParaContex return new ScXMLCellFieldTitleContext(GetScImport(), *this); case XML_ELEMENT( TEXT, XML_A ): return new ScXMLCellFieldURLContext(GetScImport(), *this); +case XML_ELEMENT( TEXT, XML_RUBY ): +return new ScXMLCellTextRubyContext(GetScImport(), *this); default: ; } @@ -118,10 +120,7 @@ void SAL_CALL ScXMLCellTextSpanContext::startFastElement( sal_Int32 /*nElement*/ void SAL_CALL ScXMLCellTextSpanContext::endFastElement( sal_Int32 /*nElement*/ ) { -if (!maContent.isEmpty()) -{ -mrParentCxt.PushSpan(maContent, maStyleName); -} +submitContentAndClear(); } void SAL_CALL ScXMLCellTextSpanContext::characters( const OUString& rChars ) @@ -132,11 +131,7 @@ void SAL_CALL ScXMLCellTextSpanContext::characters( const OUString& rChars ) uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellTextSpanContext::createFastChildContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { -if (!maContent.isEmpty()) -{ -mrParentCxt.PushSpan(maContent, maStyleName); -maContent.clear(); -} +submitContentAndClear(); switch (nElement) { @@ -177,6 +172,15 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellTextSpanContex return nullptr; } +void ScXMLCellTextSpanContext::submitContentAndClear() +{ +if (!maContent.isEmpty()) +{ +mrParentCxt.PushSpan(maContent, maStyleN
[Libreoffice-commits] core.git: sc/qa sc/source
sc/qa/unit/data/ods/tdf129940.ods|binary sc/qa/unit/subsequent_filters-test.cxx | 21 sc/source/filter/xml/celltextparacontext.cxx | 120 --- sc/source/filter/xml/celltextparacontext.hxx | 45 ++ 4 files changed, 177 insertions(+), 9 deletions(-) New commits: commit e630da1ed8a27c64bc9f22ecb71afd10bf252d93 Author: Mark Hung AuthorDate: Thu Jan 28 22:53:49 2021 +0800 Commit: Mark Hung CommitDate: Mon Feb 8 14:07:07 2021 +0100 tdf#129940 handle text:ruby element inside text:p Implement ScXMLCellTextRubyContext for text:ruby. It creates two types of child elements: ScXMLCellRubyBaseContext for text:ruby-base, and ScXMLCellRubyTextContext, for text:ruby-text. Ruby text isn't used now, but can serve for future application. Change-Id: I33b778838032458ffbefc6a2835d2ae59dff30cf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110088 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sc/qa/unit/data/ods/tdf129940.ods b/sc/qa/unit/data/ods/tdf129940.ods new file mode 100644 index ..5cc5369acd49 Binary files /dev/null and b/sc/qa/unit/data/ods/tdf129940.ods differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index d0553d74e3c4..7e7c62500674 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -304,6 +304,7 @@ public: void testDeleteCircles(); void testDrawCircleInMergeCells(); void testDeleteCirclesInRowAndCol(); +void testTdf129940(); CPPUNIT_TEST_SUITE(ScFiltersTest); CPPUNIT_TEST(testCondFormatFormulaIsXLSX); @@ -491,6 +492,7 @@ public: CPPUNIT_TEST(testDeleteCircles); CPPUNIT_TEST(testDrawCircleInMergeCells); CPPUNIT_TEST(testDeleteCirclesInRowAndCol); +CPPUNIT_TEST(testTdf129940); CPPUNIT_TEST_SUITE_END(); @@ -5434,6 +5436,25 @@ void ScFiltersTest::testDeleteCirclesInRowAndCol() xDocSh->DoClose(); } +void ScFiltersTest::testTdf129940() +{ +// Test pure span elements inside text:ruby-base +ScDocShellRef xDocSh = loadDoc(u"tdf129940.", FORMAT_ODS); +CPPUNIT_ASSERT_MESSAGE("Failed to load tdf129940.ods", xDocSh.is()); +ScDocument& rDoc = xDocSh->GetDocument(); +// Pure text within text:ruby-base +OUString aStr = rDoc.GetString(ScAddress(0,0,0)); +CPPUNIT_ASSERT_EQUAL(OUString(u"小笠原"), aStr); +aStr = rDoc.GetString(ScAddress(1,0,0)); +CPPUNIT_ASSERT_EQUAL(OUString(u"徳彦"), aStr); + +// Multiple text:span within text:ruby-base +aStr = rDoc.GetString(ScAddress(2,0,0)); +CPPUNIT_ASSERT_EQUAL(OUString(u"注音符號"), aStr); + +xDocSh->DoClose(); +} + ScFiltersTest::ScFiltersTest() : ScBootstrapFixture( "sc/qa/unit/data" ) { diff --git a/sc/source/filter/xml/celltextparacontext.cxx b/sc/source/filter/xml/celltextparacontext.cxx index 8a54d38c2b32..ce7f90651645 100644 --- a/sc/source/filter/xml/celltextparacontext.cxx +++ b/sc/source/filter/xml/celltextparacontext.cxx @@ -60,6 +60,8 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellTextParaContex return new ScXMLCellFieldTitleContext(GetScImport(), *this); case XML_ELEMENT( TEXT, XML_A ): return new ScXMLCellFieldURLContext(GetScImport(), *this); +case XML_ELEMENT( TEXT, XML_RUBY ): +return new ScXMLCellTextRubyContext(GetScImport(), *this); default: ; } @@ -118,10 +120,7 @@ void SAL_CALL ScXMLCellTextSpanContext::startFastElement( sal_Int32 /*nElement*/ void SAL_CALL ScXMLCellTextSpanContext::endFastElement( sal_Int32 /*nElement*/ ) { -if (!maContent.isEmpty()) -{ -mrParentCxt.PushSpan(maContent, maStyleName); -} +submitContentAndClear(); } void SAL_CALL ScXMLCellTextSpanContext::characters( const OUString& rChars ) @@ -132,11 +131,7 @@ void SAL_CALL ScXMLCellTextSpanContext::characters( const OUString& rChars ) uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellTextSpanContext::createFastChildContext( sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ ) { -if (!maContent.isEmpty()) -{ -mrParentCxt.PushSpan(maContent, maStyleName); -maContent.clear(); -} +submitContentAndClear(); switch (nElement) { @@ -177,6 +172,15 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLCellTextSpanContex return nullptr; } +void ScXMLCellTextSpanContext::submitContentAndClear() +{ +if (!maContent.isEmpty()) +{ +mrParentCxt.PushSpan(maContent, maStyleName); +maContent.clear(); +} +} + ScXMLCellFieldSheetNameContext::ScXMLCellFieldSheetNameContext( ScXMLImport& rImport, ScXMLCellTextParaCo
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - oox/source sd/qa
oox/source/ppt/timenode.cxx | 57 ++-- sd/qa/unit/data/pptx/tdf128550.pptx |binary sd/qa/unit/export-tests.cxx | 14 3 files changed, 63 insertions(+), 8 deletions(-) New commits: commit d56e4aea5fd5d777204f9f4e4b14cf0047348beb Author: Mark Hung AuthorDate: Sat Jan 16 23:48:56 2021 +0800 Commit: Xisco Fauli CommitDate: Thu Jan 21 15:30:11 2021 +0100 tdf#128550 set sub item on the ancestor node. The target of a animation node may resolved to a subitem. However it only has effect on a iterate container or animate node, not on any other containers. Subitem setting like background and paragraph got ignored, so everything were shown together. The patch find the ancestor node that is iterate container or animate, and set the subitem on it. Change-Id: Iaaa52aed3a34eb2d70b3b318b8336246e17e1e98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109444 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 9b19bf0283b569a5c134de6b5cce1d72d8f37879) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109679 Reviewed-by: Michael Stahl Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109754 diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 41fb39fba150..4071f8b6a8b8 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -51,8 +51,37 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::animations; using namespace ::com::sun::star::presentation; -namespace oox::ppt { +namespace { + +void lcl_setAncestorSubItem( const Reference& xParent, sal_Int16 nSubItem ) +{ + +Reference xNode = xParent; + +while ( xNode.is() ) +{ +if ( xNode->getType() == AnimationNodeType::ANIMATE ) +{ +Reference xAnimate( xNode, UNO_QUERY ); +if ( xAnimate.is() ) +xAnimate->setSubItem( nSubItem ); +break; +} +else if ( xNode->getType() == AnimationNodeType::ITERATE ) +{ +Reference xIterateContainer( xNode, UNO_QUERY ); +if ( xIterateContainer.is() ) +xIterateContainer->setSubItem( nSubItem ); +break; +} + +xNode.set( xNode->getParent(), UNO_QUERY ); +} +} + +} +namespace oox::ppt { OUString TimeNode::getServiceName( sal_Int16 nNodeType ) { OUString sServiceName; @@ -225,11 +254,17 @@ namespace oox::ppt { if( mpTarget ) { -sal_Int16 nSubType(0); -maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubType ); +sal_Int16 nSubItem(0); +maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubItem ); if( mpTarget->mnType == XML_spTgt ) { -maNodeProperties[ NP_SUBITEM ] <<= nSubType; +if ( xNode->getType() == AnimationNodeType::ANIMATE || +xNode->getType() == AnimationNodeType::ITERATE ) +{ +maNodeProperties[ NP_SUBITEM ] <<= nSubItem; +} +else +lcl_setAncestorSubItem( xParent, nSubItem ); } } @@ -338,15 +373,21 @@ namespace oox::ppt { } break; case NP_SUBITEM: -if( xAnimate.is() ) +if( aValue >>= nInt16 ) { -if( aValue >>= nInt16 ) +if( xAnimate.is() ) +{ xAnimate->setSubItem( nInt16 ); -else +} +else if ( xIterateContainer.is() ) { -SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +xIterateContainer->setSubItem( nInt16 ); } } +else +{ +SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +} break; case NP_ATTRIBUTENAME: if( xAnimate.is() ) diff --git a/sd/qa/unit/data/pptx/tdf128550.pptx b/sd/qa/unit/data/pptx/tdf128550.pptx new file mode 100755 index ..e2be342b2e51 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128550.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index a2186fae6
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - oox/source sd/qa
oox/source/ppt/timenode.cxx | 57 ++-- sd/qa/unit/data/pptx/tdf128550.pptx |binary sd/qa/unit/export-tests.cxx | 14 3 files changed, 63 insertions(+), 8 deletions(-) New commits: commit 742b699335ca81626e79c937389efd6b5fdc15ed Author: Mark Hung AuthorDate: Sat Jan 16 23:48:56 2021 +0800 Commit: Caolán McNamara CommitDate: Thu Jan 21 10:35:46 2021 +0100 tdf#128550 set sub item on the ancestor node. The target of a animation node may resolved to a subitem. However it only has effect on a iterate container or animate node, not on any other containers. Subitem setting like background and paragraph got ignored, so everything were shown together. The patch find the ancestor node that is iterate container or animate, and set the subitem on it. Change-Id: Iaaa52aed3a34eb2d70b3b318b8336246e17e1e98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109444 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 9b19bf0283b569a5c134de6b5cce1d72d8f37879) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109679 Reviewed-by: Michael Stahl diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 3e08a6716d74..132c54b79f4a 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -51,8 +51,37 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::animations; using namespace ::com::sun::star::presentation; -namespace oox::ppt { +namespace { + +void lcl_setAncestorSubItem( const Reference& xParent, sal_Int16 nSubItem ) +{ + +Reference xNode = xParent; + +while ( xNode.is() ) +{ +if ( xNode->getType() == AnimationNodeType::ANIMATE ) +{ +Reference xAnimate( xNode, UNO_QUERY ); +if ( xAnimate.is() ) +xAnimate->setSubItem( nSubItem ); +break; +} +else if ( xNode->getType() == AnimationNodeType::ITERATE ) +{ +Reference xIterateContainer( xNode, UNO_QUERY ); +if ( xIterateContainer.is() ) +xIterateContainer->setSubItem( nSubItem ); +break; +} + +xNode.set( xNode->getParent(), UNO_QUERY ); +} +} + +} +namespace oox::ppt { OUString TimeNode::getServiceName( sal_Int16 nNodeType ) { OUString sServiceName; @@ -225,11 +254,17 @@ namespace oox::ppt { if( mpTarget ) { -sal_Int16 nSubType(0); -maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubType ); +sal_Int16 nSubItem(0); +maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubItem ); if( mpTarget->mnType == XML_spTgt ) { -maNodeProperties[ NP_SUBITEM ] <<= nSubType; +if ( xNode->getType() == AnimationNodeType::ANIMATE || +xNode->getType() == AnimationNodeType::ITERATE ) +{ +maNodeProperties[ NP_SUBITEM ] <<= nSubItem; +} +else +lcl_setAncestorSubItem( xParent, nSubItem ); } } @@ -320,15 +355,21 @@ namespace oox::ppt { } break; case NP_SUBITEM: -if( xAnimate.is() ) +if( aValue >>= nInt16 ) { -if( aValue >>= nInt16 ) +if( xAnimate.is() ) +{ xAnimate->setSubItem( nInt16 ); -else +} +else if ( xIterateContainer.is() ) { -SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +xIterateContainer->setSubItem( nInt16 ); } } +else +{ +SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +} break; case NP_ATTRIBUTENAME: if( xAnimate.is() ) diff --git a/sd/qa/unit/data/pptx/tdf128550.pptx b/sd/qa/unit/data/pptx/tdf128550.pptx new file mode 100755 index ..e2be342b2e51 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128550.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index e54e02ddecd5..96022e2fc118 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -7
[Libreoffice-commits] core.git: oox/source sd/qa
oox/source/ppt/timenode.cxx | 57 ++-- sd/qa/unit/data/pptx/tdf128550.pptx |binary sd/qa/unit/export-tests.cxx | 14 3 files changed, 63 insertions(+), 8 deletions(-) New commits: commit 9b19bf0283b569a5c134de6b5cce1d72d8f37879 Author: Mark Hung AuthorDate: Sat Jan 16 23:48:56 2021 +0800 Commit: Mark Hung CommitDate: Wed Jan 20 12:14:21 2021 +0100 tdf#128550 set sub item on the ancestor node. The target of a animation node may resolved to a subitem. However it only has effect on a iterate container or animate node, not on any other containers. Subitem setting like background and paragraph got ignored, so everything were shown together. The patch find the ancestor node that is iterate container or animate, and set the subitem on it. Change-Id: Iaaa52aed3a34eb2d70b3b318b8336246e17e1e98 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109444 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/oox/source/ppt/timenode.cxx b/oox/source/ppt/timenode.cxx index 3e08a6716d74..132c54b79f4a 100644 --- a/oox/source/ppt/timenode.cxx +++ b/oox/source/ppt/timenode.cxx @@ -51,8 +51,37 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::animations; using namespace ::com::sun::star::presentation; -namespace oox::ppt { +namespace { + +void lcl_setAncestorSubItem( const Reference& xParent, sal_Int16 nSubItem ) +{ + +Reference xNode = xParent; + +while ( xNode.is() ) +{ +if ( xNode->getType() == AnimationNodeType::ANIMATE ) +{ +Reference xAnimate( xNode, UNO_QUERY ); +if ( xAnimate.is() ) +xAnimate->setSubItem( nSubItem ); +break; +} +else if ( xNode->getType() == AnimationNodeType::ITERATE ) +{ +Reference xIterateContainer( xNode, UNO_QUERY ); +if ( xIterateContainer.is() ) +xIterateContainer->setSubItem( nSubItem ); +break; +} + +xNode.set( xNode->getParent(), UNO_QUERY ); +} +} + +} +namespace oox::ppt { OUString TimeNode::getServiceName( sal_Int16 nNodeType ) { OUString sServiceName; @@ -225,11 +254,17 @@ namespace oox::ppt { if( mpTarget ) { -sal_Int16 nSubType(0); -maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubType ); +sal_Int16 nSubItem(0); +maNodeProperties[ NP_TARGET ] = mpTarget->convert( pSlide, nSubItem ); if( mpTarget->mnType == XML_spTgt ) { -maNodeProperties[ NP_SUBITEM ] <<= nSubType; +if ( xNode->getType() == AnimationNodeType::ANIMATE || +xNode->getType() == AnimationNodeType::ITERATE ) +{ +maNodeProperties[ NP_SUBITEM ] <<= nSubItem; +} +else +lcl_setAncestorSubItem( xParent, nSubItem ); } } @@ -320,15 +355,21 @@ namespace oox::ppt { } break; case NP_SUBITEM: -if( xAnimate.is() ) +if( aValue >>= nInt16 ) { -if( aValue >>= nInt16 ) +if( xAnimate.is() ) +{ xAnimate->setSubItem( nInt16 ); -else +} +else if ( xIterateContainer.is() ) { -SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +xIterateContainer->setSubItem( nInt16 ); } } +else +{ +SAL_INFO("oox.ppt","any >>= failed " << __LINE__ ); +} break; case NP_ATTRIBUTENAME: if( xAnimate.is() ) diff --git a/sd/qa/unit/data/pptx/tdf128550.pptx b/sd/qa/unit/data/pptx/tdf128550.pptx new file mode 100755 index ..e2be342b2e51 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf128550.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 56227498f2e5..e101731d0238 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -80,6 +80,7 @@ public: void testSoftEdges(); void testShadowBlur(); void testRhbz1870501(); +void testTdf128550(); CPPUNIT_TEST_SUITE(SdExportTest); @@
[Libreoffice-commits] core.git: sc/source
sc/source/ui/dbgui/csvgrid.cxx | 14 +++- sc/source/ui/docshell/impex.cxx | 44 +--- sc/source/ui/inc/impex.hxx | 15 + 3 files changed, 64 insertions(+), 9 deletions(-) New commits: commit 621c189173b35ac7f5ce4c578f57045479c63ab6 Author: Mark Hung AuthorDate: Tue Jan 5 20:26:51 2021 +0800 Commit: Mark Hung CommitDate: Sat Jan 9 05:13:55 2021 +0100 tdf#104927 consider character width for CSV import dialog in fixed width mode. Postions and column width in csvgrid.cxx are muliplied by character width to get X coordinate. Positions are calculated based on the string length, disregard the fact that the characters may have different visual width. Most CJK ideographs and symbols are designed so that their width are twice of the western characters in the same font in general. This patch implement ScImportExport::CountVisualWidth() to count their visual width, convert the position so string that contains CJK ideographs render at the right place, and separate the string based on the calculated visual width instead of the number of sal_Unicode chars. Change-Id: Ic5c1ec219820cf4e1d6c554d5eaccca9f8210ec6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108802 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx index 1fd2cea6de69..13b8f671c3e8 100644 --- a/sc/source/ui/dbgui/csvgrid.cxx +++ b/sc/source/ui/dbgui/csvgrid.cxx @@ -789,7 +789,7 @@ void ScCsvGrid::ImplSetTextLineSep( /* TODO: signal overflow somewhere in UI */ // update column width -sal_Int32 nWidth = std::max( CSV_MINCOLWIDTH, aCellText.getLength() + 1 ); +sal_Int32 nWidth = std::max( CSV_MINCOLWIDTH, ScImportExport::CountVisualWidth( aCellText ) + 1 ); if( IsValidColumn( nColIx ) ) { // expand existing column @@ -826,9 +826,9 @@ void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine ) { if( nLine < GetFirstVisLine() ) return; -sal_Int32 nChars = rTextLine.getLength(); -if( nChars > GetPosCount() ) -Execute( CSVCMD_SETPOSCOUNT, nChars ); +sal_Int32 nWidth = ScImportExport::CountVisualWidth( rTextLine ); +if( nWidth > GetPosCount() ) +Execute( CSVCMD_SETPOSCOUNT, nWidth ); sal_uInt32 nLineIx = nLine - GetFirstVisLine(); while( maTexts.size() <= nLineIx ) @@ -842,9 +842,11 @@ void ScCsvGrid::ImplSetTextLineFix( sal_Int32 nLine, const OUString& rTextLine ) for( sal_uInt32 nColIx = 0; (nColIx < nColCount) && (nStrIx < nStrLen); ++nColIx ) { sal_Int32 nColWidth = GetColumnWidth( nColIx ); -sal_Int32 nLen = std::min( std::min( nColWidth, CSV_MAXSTRLEN ), nStrLen - nStrIx); +sal_Int32 nLastIx = nStrIx; +ScImportExport::CountVisualWidth( rTextLine, nLastIx, nColWidth ); +sal_Int32 nLen = std::min( CSV_MAXSTRLEN, nLastIx - nStrIx ); rStrVec.push_back( rTextLine.copy( nStrIx, nLen ) ); -nStrIx = nStrIx + nColWidth; +nStrIx = nStrIx + nLen; } InvalidateGfx(); } diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx index 54fc6ea0765e..4835a75edabe 100644 --- a/sc/source/ui/docshell/impex.cxx +++ b/sc/source/ui/docshell/impex.cxx @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -541,6 +542,36 @@ void ScImportExport::WriteUnicodeOrByteEndl( SvStream& rStrm ) endl( rStrm ); } +sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr, sal_Int32& nIdx, sal_Int32 nMaxWidth) +{ +sal_Int32 nWidth = 0; +while(nIdx < rStr.getLength() && nWidth < nMaxWidth) +{ +sal_uInt32 nCode = rStr.iterateCodePoints(); + +if (unicode::isCJKIVSCharacter(nCode) || (nCode >= 0x3000 && nCode <= 0x303F)) +nWidth += 2; +else if (!unicode::isIVSSelector(nCode)) +nWidth += 1; +} + +if (nIdx < rStr.getLength()) +{ +sal_Int32 nTmpIdx = nIdx; +sal_uInt32 nCode = rStr.iterateCodePoints(); + +if (unicode::isIVSSelector(nCode)) +nIdx = nTmpIdx; +} +return nWidth; +} + +sal_Int32 ScImportExport::CountVisualWidth(const OUString& rStr) +{ +sal_Int32 nIdx = 0; +return CountVisualWidth(rStr, nIdx, SAL_MAX_INT32); +} + void ScImportExport::SetNoEndianSwap( SvStream& rStrm ) { #ifdef OSL_BIGENDIAN @@ -1400,6 +1431,7 @@ bool ScImportExport::ExtText2Doc( SvStream& rStrm ) bool bMultiLine = false; if ( bFixed ) // Fixed line length { +sal_Int32 nStartIdx = 0; // Yes, the check is nCol<=rDoc.MaxCol()+1, +1 because it is only an // overflow if there
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - 2 commits - editeng/source sc/qa sc/source
editeng/source/editeng/impedit3.cxx|7 ++ sc/qa/unit/data/xlsx/tdf120749.xlsx|binary sc/qa/unit/subsequent_filters-test.cxx | 38 + sc/source/filter/inc/extlstcontext.hxx |1 sc/source/filter/oox/extlstcontext.cxx | 33 +++- 5 files changed, 74 insertions(+), 5 deletions(-) New commits: commit e865a170a3a964dfa28ca51789801691932827e9 Author: Mark Hung AuthorDate: Sat Jan 2 22:58:23 2021 +0800 Commit: Xisco Fauli CommitDate: Mon Jan 4 21:51:27 2021 +0100 tdf#120171 editeng: don't reduce nBreakPos even if it is greater then nMaxBreakPos. The only situation that happens is when there is a hanging punctuation. Reducing nBreakPos to nMaxBreakPos always break that punctuation to the next line. Change-Id: Ie4b61d21f4d8f6f874e2a969260c13a3bca2a049 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108594 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 2ffa6c897379bf07367d445918b4c142cd493e7f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108591 Reviewed-by: Xisco Fauli diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index a271aa37c1e6..7df8aaa92bf4 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -1900,10 +1900,9 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te OSL_FAIL( "I18N: XBreakIterator::getLineBreak returns position > Max" ); nBreakPos = nMaxBreakPos; } - -// nBreakPos can never be outside the portion, even not with hanging punctuation -if ( nBreakPos > nMaxBreakPos ) -nBreakPos = nMaxBreakPos; +// Hanging punctuation is the only case that increases nBreakPos and makes +// nBreakPos > nMaxBreakPos. It's expected that the hanging punctuation goes over +// the border of the object. } // BUG in I18N - the japanese dot is in the next line! commit 75596e1254f284fca22efc8e6cba158bd6c50b15 Author: Tibor Nagy AuthorDate: Sun Dec 20 19:45:50 2020 +0100 Commit: Xisco Fauli CommitDate: Mon Jan 4 21:51:15 2021 +0100 tdf#120749 XLSX: fix "begins/ends with" conditional formatting when using "Given text" type and cell reference. Follow-up of commit 583e2bfba2d72ac8afe7261c23f380daf5486889 (tdf#139021 XLSX export: fix "contains" conditional formatting). Co-authored-by: Attila Szűcs (NISZ) Change-Id: Idf5d46469765454a11311bd6ec1d85c85b89e26f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108058 Tested-by: László Németh Reviewed-by: László Németh (cherry picked from commit 879ea123514ce6808212dfbef7e1d226e9d5fd9b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108592 Tested-by: Jenkins Reviewed-by: Xisco Fauli diff --git a/sc/qa/unit/data/xlsx/tdf120749.xlsx b/sc/qa/unit/data/xlsx/tdf120749.xlsx new file mode 100644 index ..de601234d3be Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf120749.xlsx differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 28db571e66de..ce65fc6684cf 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -106,6 +106,7 @@ public: virtual void tearDown() override; //ods, xls, xlsx filter tests +void testCondFormatBeginsAndEndsWithXLSX(); void testExtCondFormatXLSX(); void testUpdateCircleInMergedCellODS(); void testDeleteCircleInMergedCellODS(); @@ -297,6 +298,7 @@ public: void testDeleteCirclesInRowAndCol(); CPPUNIT_TEST_SUITE(ScFiltersTest); +CPPUNIT_TEST(testCondFormatBeginsAndEndsWithXLSX); CPPUNIT_TEST(testExtCondFormatXLSX); CPPUNIT_TEST(testUpdateCircleInMergedCellODS); CPPUNIT_TEST(testDeleteCircleInMergedCellODS); @@ -532,6 +534,42 @@ void testRangeNameImpl(const ScDocument& rDoc) } +void ScFiltersTest::testCondFormatBeginsAndEndsWithXLSX() +{ +ScDocShellRef xDocSh = loadDoc("tdf120749.", FORMAT_XLSX); +CPPUNIT_ASSERT_MESSAGE("Failed to load tdf120749.xlsx", xDocSh.is()); + +ScDocument& rDoc = xDocSh->GetDocument(); + +// begins with and ends with conditions +ScConditionalFormat* pFormatA1 = rDoc.GetCondFormat(0, 0, 0); +CPPUNIT_ASSERT(pFormatA1); +ScConditionalFormat* pFormatA2 = rDoc.GetCondFormat(0, 1, 0); +CPPUNIT_ASSERT(pFormatA2); +ScConditionalFormat* pFormatA3 = rDoc.GetCondFormat(0, 2, 0); +CPPUNIT_ASSERT(pFormatA3); +ScConditionalFormat* pFormatA4 = rDoc.GetCondFormat(0, 3, 0); +CPPUNIT_ASSERT(pFormatA4); + +ScRefCellValue aCellA1(rDoc, ScAddress(0, 0, 0)); +OUString aCellStyleA1 = pFormatA1->GetCellStyle(aCellA1, ScAddr
[Libreoffice-commits] core.git: editeng/source
editeng/source/editeng/impedit3.cxx |7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) New commits: commit 2ffa6c897379bf07367d445918b4c142cd493e7f Author: Mark Hung AuthorDate: Sat Jan 2 22:58:23 2021 +0800 Commit: Mark Hung CommitDate: Mon Jan 4 13:40:01 2021 +0100 tdf#120171 editeng: don't reduce nBreakPos even if it is greater then nMaxBreakPos. The only situation that happens is when there is a hanging punctuation. Reducing nBreakPos to nMaxBreakPos always break that punctuation to the next line. Change-Id: Ie4b61d21f4d8f6f874e2a969260c13a3bca2a049 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108594 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index a271aa37c1e6..7df8aaa92bf4 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -1900,10 +1900,9 @@ void ImpEditEngine::ImpBreakLine( ParaPortion* pParaPortion, EditLine* pLine, Te OSL_FAIL( "I18N: XBreakIterator::getLineBreak returns position > Max" ); nBreakPos = nMaxBreakPos; } - -// nBreakPos can never be outside the portion, even not with hanging punctuation -if ( nBreakPos > nMaxBreakPos ) -nBreakPos = nMaxBreakPos; +// Hanging punctuation is the only case that increases nBreakPos and makes +// nBreakPos > nMaxBreakPos. It's expected that the hanging punctuation goes over +// the border of the object. } // BUG in I18N - the japanese dot is in the next line! ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa sw/source
sw/qa/extras/rtfexport/data/tdf138779.docx |binary sw/qa/extras/rtfexport/rtfexport5.cxx |6 ++ sw/source/filter/ww8/rtfattributeoutput.cxx | 19 +++ sw/source/filter/ww8/rtfattributeoutput.hxx |2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) New commits: commit 30ad09049bf76956a696c2b61f5b9922bb744a08 Author: Mark Hung AuthorDate: Sun Dec 20 22:36:20 2020 +0800 Commit: Xisco Fauli CommitDate: Mon Jan 4 12:25:39 2021 +0100 tdf#138779 do not call EndRun() in StartRuby() and EndRuby(). Ruby is implemented as EQ field in RTF. The original run text become the ruby base text in this case. Calling EndRun() in StartRuby() might cause the run completed early and text attributes that hasn't be processed mistakenly applied to next run. This patch close the in EQ field command in EndRun, in case StartRuby has already inserted EQ field command. Change-Id: I3a755f235b79d11b7897f85ae3989cc3ac73b06a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108194 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 326388da4e40c85f8a1af40264aaf56c7845e224) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108343 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/rtfexport/data/tdf138779.docx b/sw/qa/extras/rtfexport/data/tdf138779.docx new file mode 100644 index ..ef7d5dd84105 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf138779.docx differ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 0d921ed6c7b6..fea953889795 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1276,6 +1276,12 @@ DECLARE_RTFEXPORT_TEST(testTdf137894, "tdf137894.odt") CPPUNIT_ASSERT_EQUAL(32.f, getProperty(getRun(getParagraph(2), 1), "CharHeightComplex")); } +DECLARE_RTFEXPORT_TEST(testTdf138779, "tdf138779.docx") +{ +// The text "2. Kozuka Mincho Pro, 8 pt Ruby ..." has font size 11pt ( was 20pt ). +CPPUNIT_ASSERT_EQUAL(11.f, getProperty(getRun(getParagraph(2), 14), "CharHeight")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 23dc3af728e2..f1a6da4f3f47 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -405,6 +405,13 @@ void RtfAttributeOutput::EndRun(const SwTextNode* /*pNode*/, sal_Int32 /*nPos*/, { m_aRun->append(SAL_NEWLINE_STRING); m_aRun.appendAndClear(m_aRunText); + +if (m_bInRuby) +{ +m_aRun->append(")}}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {}}}"); +m_bInRuby = false; +} + if (!m_bSingleEmptyRun && m_bInRun) m_aRun->append('}'); m_bInRun = false; @@ -508,7 +515,7 @@ void RtfAttributeOutput::RawText(const OUString& rText, rtl_TextEncoding eCharSe m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet)); } -void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, +void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/, const SwFormatRuby& rRuby) { WW8Ruby aWW8Ruby(rNode, rRuby, GetExport()); @@ -521,18 +528,13 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, aStr += "\\a" + OUStringChar(aWW8Ruby.GetDirective()); } aStr += "(\\s\\up " + OUString::number((aWW8Ruby.GetBaseHeight() + 10) / 20 - 1) + "("; -EndRun(, nPos); m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::Start | FieldFlags::CmdStart); aStr = rRuby.GetText() + "),"; m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::NONE); +m_bInRuby = true; } -void RtfAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos) -{ -m_rExport.OutputField(nullptr, ww::eEQ, ")", - FieldFlags::CmdEnd | FieldFlags::End | FieldFlags::Close); -EndRun(, nPos); -} +void RtfAttributeOutput::EndRuby(const SwTextNode& /*rNode*/, sal_Int32 /*nPos*/) {} bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget) { @@ -3810,6 +3812,7 @@ RtfAttributeOutput::RtfAttributeOutput(RtfExport& rExport) , m_bIsBeforeFirstParagraph(true) , m_bSingleEmptyRun(false) , m_bInRun(false) +, m_bInRuby(false) , m_pFlyFrameSize(nullptr) , m_bParaBeforeAutoSpacing(false) , m_nParaBeforeSpacing(0) diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index 246ab4aba50b..a7f95813c2c0 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtf
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sd/source
sd/source/ui/animations/CustomAnimationPane.cxx | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) New commits: commit 2a468a02e4ef2dd90f29f750e701a00936d13f60 Author: Mark Hung AuthorDate: Sat Dec 19 21:38:55 2020 +0800 Commit: Xisco Fauli CommitDate: Tue Dec 29 15:31:36 2020 +0100 tdf#138937 don't use attributes that depend on preset data if preset data is not found. Curve, polygon, and free form motion paths do not have preset data. Create the path in these cases as well. Change-Id: Idd3b24b81a15de53e302e8cb7f3636d72e10b4da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108022 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 765b13b67e46aa8c8618fdad8582f8586bffce9e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108296 Reviewed-by: Xisco Fauli diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 37ab3c36c4f1..81acc71b0eb8 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -1815,14 +1815,14 @@ void CustomAnimationPane::onAdd() if (nEntryData) pDescriptor = *reinterpret_cast(nEntryData); -const double fDuration = pDescriptor->getDuration(); -mxCBXDuration->set_value(fDuration*100.0, FieldUnit::NONE); -bool bHasSpeed = pDescriptor->getDuration() > 0.001; -mxCBXDuration->set_sensitive( bHasSpeed ); -mxFTDuration->set_sensitive( bHasSpeed ); - if( pDescriptor ) { +const double fDuration = pDescriptor->getDuration(); +mxCBXDuration->set_value(fDuration*100.0, FieldUnit::NONE); +bool bHasSpeed = pDescriptor->getDuration() > 0.001; +mxCBXDuration->set_sensitive( bHasSpeed ); +mxFTDuration->set_sensitive( bHasSpeed ); + mxCustomAnimationList->unselect_all(); // gather shapes from the selection @@ -1851,6 +1851,14 @@ void CustomAnimationPane::onAdd() } } +PathKind ePathKind = getCreatePathKind(); + +if (ePathKind != PathKind::NONE) +{ +createPath( ePathKind, aTargets, 0.0 ); +updateMotionPathTags(); +} + mrBase.GetDocShell()->SetModified(); updateControls(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sw/qa sw/source
sw/qa/extras/rtfexport/data/tdf138779.docx |binary sw/qa/extras/rtfexport/rtfexport5.cxx |6 ++ sw/source/filter/ww8/rtfattributeoutput.cxx | 19 +++ sw/source/filter/ww8/rtfattributeoutput.hxx |2 ++ 4 files changed, 19 insertions(+), 8 deletions(-) New commits: commit 326388da4e40c85f8a1af40264aaf56c7845e224 Author: Mark Hung AuthorDate: Sun Dec 20 22:36:20 2020 +0800 Commit: Mark Hung CommitDate: Tue Dec 29 13:55:41 2020 +0100 tdf#138779 do not call EndRun() in StartRuby() and EndRuby(). Ruby is implemented as EQ field in RTF. The original run text become the ruby base text in this case. Calling EndRun() in StartRuby() might cause the run completed early and text attributes that hasn't be processed mistakenly applied to next run. This patch close the in EQ field command in EndRun, in case StartRuby has already inserted EQ field command. Change-Id: I3a755f235b79d11b7897f85ae3989cc3ac73b06a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108194 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/rtfexport/data/tdf138779.docx b/sw/qa/extras/rtfexport/data/tdf138779.docx new file mode 100644 index ..ef7d5dd84105 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf138779.docx differ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 0d921ed6c7b6..fea953889795 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1276,6 +1276,12 @@ DECLARE_RTFEXPORT_TEST(testTdf137894, "tdf137894.odt") CPPUNIT_ASSERT_EQUAL(32.f, getProperty(getRun(getParagraph(2), 1), "CharHeightComplex")); } +DECLARE_RTFEXPORT_TEST(testTdf138779, "tdf138779.docx") +{ +// The text "2. Kozuka Mincho Pro, 8 pt Ruby ..." has font size 11pt ( was 20pt ). +CPPUNIT_ASSERT_EQUAL(11.f, getProperty(getRun(getParagraph(2), 14), "CharHeight")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 5fdabb896756..6213a509aa3e 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -405,6 +405,13 @@ void RtfAttributeOutput::EndRun(const SwTextNode* /*pNode*/, sal_Int32 /*nPos*/, { m_aRun->append(SAL_NEWLINE_STRING); m_aRun.appendAndClear(m_aRunText); + +if (m_bInRuby) +{ +m_aRun->append(")}}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {}}}"); +m_bInRuby = false; +} + if (!m_bSingleEmptyRun && m_bInRun) m_aRun->append('}'); m_bInRun = false; @@ -508,7 +515,7 @@ void RtfAttributeOutput::RawText(const OUString& rText, rtl_TextEncoding eCharSe m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet)); } -void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, +void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 /*nPos*/, const SwFormatRuby& rRuby) { WW8Ruby aWW8Ruby(rNode, rRuby, GetExport()); @@ -521,18 +528,13 @@ void RtfAttributeOutput::StartRuby(const SwTextNode& rNode, sal_Int32 nPos, aStr += "\\a" + OUStringChar(aWW8Ruby.GetDirective()); } aStr += "(\\s\\up " + OUString::number((aWW8Ruby.GetBaseHeight() + 10) / 20 - 1) + "("; -EndRun(, nPos); m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::Start | FieldFlags::CmdStart); aStr = rRuby.GetText() + "),"; m_rExport.OutputField(nullptr, ww::eEQ, aStr, FieldFlags::NONE); +m_bInRuby = true; } -void RtfAttributeOutput::EndRuby(const SwTextNode& rNode, sal_Int32 nPos) -{ -m_rExport.OutputField(nullptr, ww::eEQ, ")", - FieldFlags::CmdEnd | FieldFlags::End | FieldFlags::Close); -EndRun(, nPos); -} +void RtfAttributeOutput::EndRuby(const SwTextNode& /*rNode*/, sal_Int32 /*nPos*/) {} bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget) { @@ -3807,6 +3809,7 @@ RtfAttributeOutput::RtfAttributeOutput(RtfExport& rExport) , m_bIsBeforeFirstParagraph(true) , m_bSingleEmptyRun(false) , m_bInRun(false) +, m_bInRuby(false) , m_pFlyFrameSize(nullptr) , m_bParaBeforeAutoSpacing(false) , m_nParaBeforeSpacing(0) diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx index 246ab4aba50b..a7f95813c2c0 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.hxx +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx @@ -610,6 +610,8 @@ private: bool m_bInRun; +bool m_bInRuby; + /// Maps ID's to postit fields, used in atrfsta
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sd/source
sd/source/ui/animations/CustomAnimationPane.cxx | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) New commits: commit 3c44c403791754207142c60183a118c323b9c297 Author: Mark Hung AuthorDate: Sat Dec 19 21:38:55 2020 +0800 Commit: Xisco Fauli CommitDate: Tue Dec 29 13:39:01 2020 +0100 tdf#138937 don't use attributes that depend on preset data if preset data is not found. Curve, polygon, and free form motion paths do not have preset data. Create the path in these cases as well. Change-Id: Idd3b24b81a15de53e302e8cb7f3636d72e10b4da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108022 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 765b13b67e46aa8c8618fdad8582f8586bffce9e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108295 Reviewed-by: Xisco Fauli diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 2e6d511253ee..b58ca838b709 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -1815,14 +1815,14 @@ void CustomAnimationPane::onAdd() if (nEntryData) pDescriptor = *reinterpret_cast(nEntryData); -const double fDuration = pDescriptor->getDuration(); -mxCBXDuration->set_value(fDuration*100.0, FieldUnit::NONE); -bool bHasSpeed = pDescriptor->getDuration() > 0.001; -mxCBXDuration->set_sensitive( bHasSpeed ); -mxFTDuration->set_sensitive( bHasSpeed ); - if( pDescriptor ) { +const double fDuration = pDescriptor->getDuration(); +mxCBXDuration->set_value(fDuration*100.0, FieldUnit::NONE); +bool bHasSpeed = pDescriptor->getDuration() > 0.001; +mxCBXDuration->set_sensitive( bHasSpeed ); +mxFTDuration->set_sensitive( bHasSpeed ); + mxCustomAnimationList->unselect_all(); // gather shapes from the selection @@ -1851,6 +1851,14 @@ void CustomAnimationPane::onAdd() } } +PathKind ePathKind = getCreatePathKind(); + +if (ePathKind != PathKind::NONE) +{ +createPath( ePathKind, aTargets, 0.0 ); +updateMotionPathTags(); +} + mrBase.GetDocShell()->SetModified(); updateControls(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: sd/source
sd/source/ui/animations/CustomAnimationPane.cxx | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) New commits: commit 765b13b67e46aa8c8618fdad8582f8586bffce9e Author: Mark Hung AuthorDate: Sat Dec 19 21:38:55 2020 +0800 Commit: Mark Hung CommitDate: Thu Dec 24 14:02:57 2020 +0100 tdf#138937 don't use attributes that depend on preset data if preset data is not found. Curve, polygon, and free form motion paths do not have preset data. Create the path in these cases as well. Change-Id: Idd3b24b81a15de53e302e8cb7f3636d72e10b4da Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108022 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sd/source/ui/animations/CustomAnimationPane.cxx b/sd/source/ui/animations/CustomAnimationPane.cxx index 95a0eb941597..d9f86d628f6e 100644 --- a/sd/source/ui/animations/CustomAnimationPane.cxx +++ b/sd/source/ui/animations/CustomAnimationPane.cxx @@ -1816,14 +1816,14 @@ void CustomAnimationPane::onAdd() if (nEntryData) pDescriptor = *reinterpret_cast(nEntryData); -const double fDuration = pDescriptor->getDuration(); -mxCBXDuration->set_value(fDuration*100.0, FieldUnit::NONE); -bool bHasSpeed = pDescriptor->getDuration() > 0.001; -mxCBXDuration->set_sensitive( bHasSpeed ); -mxFTDuration->set_sensitive( bHasSpeed ); - if( pDescriptor ) { +const double fDuration = pDescriptor->getDuration(); +mxCBXDuration->set_value(fDuration*100.0, FieldUnit::NONE); +bool bHasSpeed = pDescriptor->getDuration() > 0.001; +mxCBXDuration->set_sensitive( bHasSpeed ); +mxFTDuration->set_sensitive( bHasSpeed ); + mxCustomAnimationList->unselect_all(); // gather shapes from the selection @@ -1852,6 +1852,14 @@ void CustomAnimationPane::onAdd() } } +PathKind ePathKind = getCreatePathKind(); + +if (ePathKind != PathKind::NONE) +{ +createPath( ePathKind, aTargets, 0.0 ); +updateMotionPathTags(); +} + mrBase.GetDocShell()->SetModified(); updateControls(); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-1' - sw/qa sw/source writerfilter/source
sw/qa/extras/rtfexport/data/tdf137894.odt |binary sw/qa/extras/rtfexport/rtfexport5.cxx | 16 ++ sw/source/filter/ww8/rtfattributeoutput.cxx | 138 sw/source/filter/ww8/rtfattributeoutput.hxx |6 - writerfilter/source/rtftok/rtfdispatchvalue.cxx |4 5 files changed, 95 insertions(+), 69 deletions(-) New commits: commit efe85aa1ef4034ae70c50a256b491737199b8747 Author: Mark Hung AuthorDate: Sun Nov 22 19:32:32 2020 +0800 Commit: Xisco Fauli CommitDate: Wed Nov 25 18:17:43 2020 +0100 tdf#137894 separate associated character properties in ww8filter/RtfAttributeOutput and treat \dbch as CJK and \hich Western in order to roundtrip the RTF document. ww8filter mix all the associated style, including properties for CJK and CTL scripts. Both RtfAttributeOutput::CharFontCJK and RtfAttributeOutput::CharFontCTL output \dbch, that result in incorrect assocation. CharFontCTL should use \rtlch, but it was already in RtfAttributeOutput::MoveCharacterProperties. To make the order correct, I separate the associated character properties that were stored in m_aSyltesAssoc into m_aSyltesAssocRtlch, and m_aSyltesAssocDbch by their script types. Note that it is not clear what associated character properties that we should adopt for \hich and \ltrch. In theory RTL scripts can output high ANSI chars too, so \hich may get properties from either Western or CTL scripts. However, examining Hebrew RTF documents, I didn't see any sign that \hich is used in that way. Use RTL as CTL might be a problem for Mongolian, Manchu and Xibe. They are CTL but top-to-bottom (aka LTR) . But I don't think they will be expressed as high ANSI chars either. Change-Id: I214edbb00a67c2ffe19c5a37254c8988a0828f40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106355 Tested-by: Jenkins Reviewed-by: Miklos Vajna (cherry picked from commit f97af19460fbd7483a0e1c1d0137e814f5390e69) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106523 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/rtfexport/data/tdf137894.odt b/sw/qa/extras/rtfexport/data/tdf137894.odt new file mode 100755 index ..79c7eb178a7f Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf137894.odt differ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index a48adfa653cd..0d921ed6c7b6 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1260,6 +1260,22 @@ DECLARE_RTFEXPORT_TEST(testTdf138210, "tdf138210.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); } +DECLARE_RTFEXPORT_TEST(testTdf137894, "tdf137894.odt") +{ +lang::Locale locale1(getProperty(getRun(getParagraph(1), 1), "CharLocaleAsian")); +CPPUNIT_ASSERT_EQUAL(OUString("ja"), locale1.Language); +CPPUNIT_ASSERT_EQUAL(OUString("MS UI Gothic"), + getProperty(getRun(getParagraph(1), 1), "CharFontNameAsian")); +CPPUNIT_ASSERT_EQUAL(20.f, getProperty(getRun(getParagraph(1), 1), "CharHeightAsian")); +CPPUNIT_ASSERT_EQUAL(OUString("Mangal"), + getProperty(getRun(getParagraph(1), 1), "CharFontNameComplex")); +CPPUNIT_ASSERT_EQUAL(20.f, getProperty(getRun(getParagraph(1), 1), "CharHeightComplex")); +lang::Locale locale2( +getProperty(getRun(getParagraph(2), 1), "CharLocaleComplex")); +CPPUNIT_ASSERT_EQUAL(OUString("he"), locale2.Language); +CPPUNIT_ASSERT_EQUAL(32.f, getProperty(getRun(getParagraph(2), 1), "CharHeightComplex")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 9e76b3d3fd48..23dc3af728e2 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -423,49 +423,58 @@ void RtfAttributeOutput::EndRunProperties(const SwRedlineData* /*pRedlineData*/) OString RtfAttributeOutput::MoveCharacterProperties(bool aAutoWriteRtlLtr) { -const OString aAssoc = m_aStylesAssoc.makeStringAndClear(); +const OString aAssocHich = m_aStylesAssocHich.makeStringAndClear(); +const OString aAssocDbch = m_aStylesAssocDbch.makeStringAndClear(); +const OString aAssocRtlch = m_aStylesAssocRtlch.makeStringAndClear(); +const OString aAssocLtrch = m_aStylesAssocLtrch.makeStringAndClear(); const OString aNormal = m_aStyles.makeStringAndClear(); OStringBuffer aBuf; if (aAutoWriteRtlLtr && !m_bControlLtrRtl) { -m_bControlLtrRtl = !aAssoc.isEmpty(); +m_bControlLtrRtl = !aAssocRt
[Libreoffice-commits] core.git: sw/qa sw/source writerfilter/source
sw/qa/extras/rtfexport/data/tdf137894.odt |binary sw/qa/extras/rtfexport/rtfexport5.cxx | 16 ++ sw/source/filter/ww8/rtfattributeoutput.cxx | 138 sw/source/filter/ww8/rtfattributeoutput.hxx |6 - writerfilter/source/rtftok/rtfdispatchvalue.cxx |4 5 files changed, 95 insertions(+), 69 deletions(-) New commits: commit f97af19460fbd7483a0e1c1d0137e814f5390e69 Author: Mark Hung AuthorDate: Sun Nov 22 19:32:32 2020 +0800 Commit: Miklos Vajna CommitDate: Wed Nov 25 09:20:27 2020 +0100 tdf#137894 separate associated character properties in ww8filter/RtfAttributeOutput and treat \dbch as CJK and \hich Western in order to roundtrip the RTF document. ww8filter mix all the associated style, including properties for CJK and CTL scripts. Both RtfAttributeOutput::CharFontCJK and RtfAttributeOutput::CharFontCTL output \dbch, that result in incorrect assocation. CharFontCTL should use \rtlch, but it was already in RtfAttributeOutput::MoveCharacterProperties. To make the order correct, I separate the associated character properties that were stored in m_aSyltesAssoc into m_aSyltesAssocRtlch, and m_aSyltesAssocDbch by their script types. Note that it is not clear what associated character properties that we should adopt for \hich and \ltrch. In theory RTL scripts can output high ANSI chars too, so \hich may get properties from either Western or CTL scripts. However, examining Hebrew RTF documents, I didn't see any sign that \hich is used in that way. Use RTL as CTL might be a problem for Mongolian, Manchu and Xibe. They are CTL but top-to-bottom (aka LTR) . But I don't think they will be expressed as high ANSI chars either. Change-Id: I214edbb00a67c2ffe19c5a37254c8988a0828f40 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106355 Tested-by: Jenkins Reviewed-by: Miklos Vajna diff --git a/sw/qa/extras/rtfexport/data/tdf137894.odt b/sw/qa/extras/rtfexport/data/tdf137894.odt new file mode 100755 index ..79c7eb178a7f Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf137894.odt differ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index a48adfa653cd..0d921ed6c7b6 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -1260,6 +1260,22 @@ DECLARE_RTFEXPORT_TEST(testTdf138210, "tdf138210.rtf") CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); } +DECLARE_RTFEXPORT_TEST(testTdf137894, "tdf137894.odt") +{ +lang::Locale locale1(getProperty(getRun(getParagraph(1), 1), "CharLocaleAsian")); +CPPUNIT_ASSERT_EQUAL(OUString("ja"), locale1.Language); +CPPUNIT_ASSERT_EQUAL(OUString("MS UI Gothic"), + getProperty(getRun(getParagraph(1), 1), "CharFontNameAsian")); +CPPUNIT_ASSERT_EQUAL(20.f, getProperty(getRun(getParagraph(1), 1), "CharHeightAsian")); +CPPUNIT_ASSERT_EQUAL(OUString("Mangal"), + getProperty(getRun(getParagraph(1), 1), "CharFontNameComplex")); +CPPUNIT_ASSERT_EQUAL(20.f, getProperty(getRun(getParagraph(1), 1), "CharHeightComplex")); +lang::Locale locale2( +getProperty(getRun(getParagraph(2), 1), "CharLocaleComplex")); +CPPUNIT_ASSERT_EQUAL(OUString("he"), locale2.Language); +CPPUNIT_ASSERT_EQUAL(32.f, getProperty(getRun(getParagraph(2), 1), "CharHeightComplex")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 9e76b3d3fd48..23dc3af728e2 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -423,49 +423,58 @@ void RtfAttributeOutput::EndRunProperties(const SwRedlineData* /*pRedlineData*/) OString RtfAttributeOutput::MoveCharacterProperties(bool aAutoWriteRtlLtr) { -const OString aAssoc = m_aStylesAssoc.makeStringAndClear(); +const OString aAssocHich = m_aStylesAssocHich.makeStringAndClear(); +const OString aAssocDbch = m_aStylesAssocDbch.makeStringAndClear(); +const OString aAssocRtlch = m_aStylesAssocRtlch.makeStringAndClear(); +const OString aAssocLtrch = m_aStylesAssocLtrch.makeStringAndClear(); const OString aNormal = m_aStyles.makeStringAndClear(); OStringBuffer aBuf; if (aAutoWriteRtlLtr && !m_bControlLtrRtl) { -m_bControlLtrRtl = !aAssoc.isEmpty(); +m_bControlLtrRtl = !aAssocRtlch.isEmpty(); m_bIsRTL = false; m_nScript = i18n::ScriptType::LATIN; } -if (m_bControlLtrRtl) +if (m_bIsRTL) { -m_bContro
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/qa writerfilter/source
sw/qa/extras/rtfexport/data/tdf138210.rtf |binary sw/qa/extras/rtfexport/rtfexport5.cxx |9 +++ writerfilter/source/rtftok/rtfsdrimport.cxx | 74 +--- 3 files changed, 44 insertions(+), 39 deletions(-) New commits: commit 9db952d2e793577f44df7a4a5b98c19ea87c8db0 Author: Mark Hung AuthorDate: Sat Nov 14 19:37:31 2020 +0800 Commit: Xisco Fauli CommitDate: Mon Nov 23 10:26:13 2020 +0100 tdf#138210 check if CustomShapeGeometry exist first. CustomShapeGeometry does not exist for a text frame. Getting the property throws an Exception and cause a general IO error. Change-Id: I0e31780292d45211bfd1250d0d359c72def50583 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105834 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 8c14adfa76956e76bac98330ce67f080c90af184) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106237 Reviewed-by: Xisco Fauli diff --git a/sw/qa/extras/rtfexport/data/tdf138210.rtf b/sw/qa/extras/rtfexport/data/tdf138210.rtf new file mode 100755 index ..d91a87d901e6 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf138210.rtf differ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index e005ce674b92..25cd2ee423bb 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1253,6 +1254,14 @@ DECLARE_RTFEXPORT_TEST(testTdf129513, "tdf129513.rtf") CPPUNIT_ASSERT_EQUAL(OUString("In table"), xCell->getString()); } +DECLARE_RTFEXPORT_TEST(testTdf138210, "tdf138210.rtf") +{ +uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xIndexAccess(xTextFramesSupplier->getTextFrames(), + uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index 1ecde8a8a684..ef2c92afac4d 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -917,46 +917,43 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap } // Creating CustomShapeGeometry property -std::vector aGeometry; -if (aViewBox.X || aViewBox.Y || aViewBox.Width || aViewBox.Height) +if (bCustom && xPropertySet.is()) { -aViewBox.Width -= aViewBox.X; -aViewBox.Height -= aViewBox.Y; -aPropertyValue.Name = "ViewBox"; -aPropertyValue.Value <<= aViewBox; -aGeometry.push_back(aPropertyValue); -} -if (!aPath.empty()) -{ -aPropertyValue.Name = "Path"; -aPropertyValue.Value <<= comphelper::containerToSequence(aPath); -aGeometry.push_back(aPropertyValue); -} -if (!aGeometry.empty() && xPropertySet.is() && !m_bTextFrame) -xPropertySet->setPropertyValue("CustomShapeGeometry", - uno::Any(comphelper::containerToSequence(aGeometry))); +bool bChanged = false; +comphelper::SequenceAsHashMap aCustomShapeGeometry( +xPropertySet->getPropertyValue("CustomShapeGeometry")); -if (!aShapeText.isEmpty()) -{ -auto aGeomPropSeq = xPropertySet->getPropertyValue("CustomShapeGeometry") -.get>(); -auto aGeomPropVec -= comphelper::sequenceToContainer>(aGeomPropSeq); -uno::Sequence aPropertyValues(comphelper::InitPropertySequence({ -{ "TextPath", uno::makeAny(true) }, -})); -auto it = std::find_if( -aGeomPropVec.begin(), aGeomPropVec.end(), -[](const beans::PropertyValue& rValue) { return rValue.Name == "TextPath"; }); -if (it == aGeomPropVec.end()) -aGeomPropVec.push_back(comphelper::makePropertyValue("TextPath", aPropertyValues)); -else -it->Value <<= aPropertyValues; +if (aViewBox.X || aViewBox.Y || aViewBox.Width || aViewBox.Height) +{ +aViewBox.Width -= aViewBox.X; +aViewBox.Height -= aViewBox.Y; +aCustomShapeGeometry["ViewBox"] <<= aViewBox; +bChanged = true; +} + +if (!aPath.empty()) +{ +aCustomShapeGeometry["Path"] <<= comphelper::containerToSequence(aPath); +bChanged = true; +} + +if (!aShapeText.isEmpty()) +{ +uno::Sequence aSequence(comphelper:
[Libreoffice-commits] core.git: sw/qa writerfilter/source
sw/qa/extras/rtfexport/data/tdf138210.rtf |binary sw/qa/extras/rtfexport/rtfexport5.cxx |9 +++ writerfilter/source/rtftok/rtfsdrimport.cxx | 74 +--- 3 files changed, 44 insertions(+), 39 deletions(-) New commits: commit 8c14adfa76956e76bac98330ce67f080c90af184 Author: Mark Hung AuthorDate: Sat Nov 14 19:37:31 2020 +0800 Commit: Mark Hung CommitDate: Sat Nov 21 02:32:49 2020 +0100 tdf#138210 check if CustomShapeGeometry exist first. CustomShapeGeometry does not exist for a text frame. Getting the property throws an Exception and cause a general IO error. Change-Id: I0e31780292d45211bfd1250d0d359c72def50583 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105834 Tested-by: Jenkins Reviewed-by: Mark Hung diff --git a/sw/qa/extras/rtfexport/data/tdf138210.rtf b/sw/qa/extras/rtfexport/data/tdf138210.rtf new file mode 100755 index ..d91a87d901e6 Binary files /dev/null and b/sw/qa/extras/rtfexport/data/tdf138210.rtf differ diff --git a/sw/qa/extras/rtfexport/rtfexport5.cxx b/sw/qa/extras/rtfexport/rtfexport5.cxx index 4bac42fecfb4..a48adfa653cd 100644 --- a/sw/qa/extras/rtfexport/rtfexport5.cxx +++ b/sw/qa/extras/rtfexport/rtfexport5.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1251,6 +1252,14 @@ DECLARE_RTFEXPORT_TEST(testTdf129513, "tdf129513.rtf") CPPUNIT_ASSERT_EQUAL(OUString("In table"), xCell->getString()); } +DECLARE_RTFEXPORT_TEST(testTdf138210, "tdf138210.rtf") +{ +uno::Reference xTextFramesSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xIndexAccess(xTextFramesSupplier->getTextFrames(), + uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx index b98723e5aee3..01af8259ff91 100644 --- a/writerfilter/source/rtftok/rtfsdrimport.cxx +++ b/writerfilter/source/rtftok/rtfsdrimport.cxx @@ -918,46 +918,43 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap } // Creating CustomShapeGeometry property -std::vector aGeometry; -if (aViewBox.X || aViewBox.Y || aViewBox.Width || aViewBox.Height) +if (bCustom && xPropertySet.is()) { -aViewBox.Width -= aViewBox.X; -aViewBox.Height -= aViewBox.Y; -aPropertyValue.Name = "ViewBox"; -aPropertyValue.Value <<= aViewBox; -aGeometry.push_back(aPropertyValue); -} -if (!aPath.empty()) -{ -aPropertyValue.Name = "Path"; -aPropertyValue.Value <<= comphelper::containerToSequence(aPath); -aGeometry.push_back(aPropertyValue); -} -if (!aGeometry.empty() && xPropertySet.is() && !m_bTextFrame) -xPropertySet->setPropertyValue("CustomShapeGeometry", - uno::Any(comphelper::containerToSequence(aGeometry))); +bool bChanged = false; +comphelper::SequenceAsHashMap aCustomShapeGeometry( +xPropertySet->getPropertyValue("CustomShapeGeometry")); -if (!aShapeText.isEmpty()) -{ -auto aGeomPropSeq = xPropertySet->getPropertyValue("CustomShapeGeometry") -.get>(); -auto aGeomPropVec -= comphelper::sequenceToContainer>(aGeomPropSeq); -uno::Sequence aPropertyValues(comphelper::InitPropertySequence({ -{ "TextPath", uno::makeAny(true) }, -})); -auto it = std::find_if( -aGeomPropVec.begin(), aGeomPropVec.end(), -[](const beans::PropertyValue& rValue) { return rValue.Name == "TextPath"; }); -if (it == aGeomPropVec.end()) -aGeomPropVec.push_back(comphelper::makePropertyValue("TextPath", aPropertyValues)); -else -it->Value <<= aPropertyValues; +if (aViewBox.X || aViewBox.Y || aViewBox.Width || aViewBox.Height) +{ +aViewBox.Width -= aViewBox.X; +aViewBox.Height -= aViewBox.Y; +aCustomShapeGeometry["ViewBox"] <<= aViewBox; +bChanged = true; +} + +if (!aPath.empty()) +{ +aCustomShapeGeometry["Path"] <<= comphelper::containerToSequence(aPath); +bChanged = true; +} + +if (!aShapeText.isEmpty()) +{ +uno::Sequence aSequence(comphelper::InitPropertySequence({ +{ "TextPath", uno::makeAny(true) }, +})); +aCustomShapeGeometry[&qu
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - sw/source
sw/source/core/text/portxt.cxx |8 1 file changed, 4 insertions(+), 4 deletions(-) New commits: commit b8dd7d02a072c80961838b00c9e8cbdbddc9ce08 Author: Mark Hung AuthorDate: Fri Oct 2 11:24:31 2020 +0800 Commit: Xisco Fauli CommitDate: Mon Oct 26 19:29:49 2020 +0100 tdf#130314 space counting for input field. 1. Input field should be counted like other fields, with its content expanded with GetExpText(). 2. Use only GetLen() instead of rInf.GetLen() in SwTextInputFieldPortion::GetExpText() because when justifying the text, rInf.GetLen() isn't always updated corresponding to rInf.GetIdx(). ( Check SwTextAdjuster::CalcNewBlock() for ref.) Change-Id: I6a41275295607887c476fdd3f8e5a90c936c9d31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103782 Tested-by: Jenkins Reviewed-by: Mark Hung Signed-off-by: Xisco Fauli This commit also contains the following commit: tdf#130314 fix incorrect logic in last commit Previous commit ( ac76f9e8ad8b ) contains a logical mistake. Change && to || there. Change-Id: Id982ce6f22b0022316b564029f813da9072b71e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104089 Tested-by: Jenkins Reviewed-by: Mark Hung Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104806 diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index 84bbee847d72..65d6a58f3dc2 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -583,7 +583,7 @@ TextFrameIndex SwTextPortion::GetSpaceCnt(const SwTextSizeInfo , return TextFrameIndex(0); } -if ( InExpGrp() ) +if ( InExpGrp() || PortionType::InputField == GetWhichPor() ) { if( !IsBlankPortion() && !InNumberGrp() && !IsCombinedPortion() ) { @@ -620,7 +620,7 @@ long SwTextPortion::CalcSpacing( long nSpaceAdd, const SwTextSizeInfo ) co return 0; } -if ( InExpGrp() ) +if ( InExpGrp() || PortionType::InputField == GetWhichPor() ) { if( !IsBlankPortion() && !InNumberGrp() && !IsCombinedPortion() ) { @@ -717,13 +717,13 @@ void SwTextInputFieldPortion::Paint( const SwTextPaintInfo ) const bool SwTextInputFieldPortion::GetExpText( const SwTextSizeInfo , OUString ) const { sal_Int32 nIdx(rInf.GetIdx()); -sal_Int32 nLen(rInf.GetLen()); +sal_Int32 nLen(GetLen()); if ( rInf.GetChar( rInf.GetIdx() ) == CH_TXT_ATR_INPUTFIELDSTART ) { ++nIdx; --nLen; } -if (rInf.GetChar(rInf.GetIdx() + rInf.GetLen() - TextFrameIndex(1)) == CH_TXT_ATR_INPUTFIELDEND) +if (rInf.GetChar(rInf.GetIdx() + GetLen() - TextFrameIndex(1)) == CH_TXT_ATR_INPUTFIELDEND) { --nLen; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - editeng/source include/editeng
editeng/source/editeng/editeng.cxx | 15 +-- editeng/source/editeng/editview.cxx |7 ++- editeng/source/editeng/impedit.hxx |2 +- editeng/source/editeng/impedit5.cxx |6 +++--- editeng/source/editeng/textconv.cxx |2 +- include/editeng/editdata.hxx|2 ++ include/editeng/editeng.hxx |1 + include/editeng/editview.hxx|1 + 8 files changed, 28 insertions(+), 8 deletions(-) New commits: commit a419deb3279e9d3571ac55fa77c1b162f4eaabea Author: Mark Hung AuthorDate: Mon Oct 19 00:07:34 2020 +0800 Commit: Xisco Fauli CommitDate: Mon Oct 26 10:25:45 2020 +0100 tdf#104378: don't reset para attributes while converting Chinese characters. In TextConvWrapper::ChangeText_impl, calls to EditView::RemoveAttribs() reset the paragraph attributes. That makes SvxLanguageItem of EE_CHAR_LANGUAGE_CJK become LANGUAGE_DONTKNOW. Hence it always stops converting after the first success. This patch overload EditView::RemoveAttribs() so that it is possible to clear all character attributes of the selction without touching paragraph attributes. Before, bRemoveParaAttribs either removes items between EE_ITEMS_START and EE_CHAR_END, or removes items between EE_CHAR_START and EE_CHAR_END. The patch add a new enum class EERemoveParaAttribsMode, with the following values: 1. RemoveAll : correspond to the old bRemoveParaAttribs = true 2. RemoveCharItems: correspond to the old bRemoveParaAttribs = false 3. RemoveNone: new thing for "don't touch para attributes." Change-Id: I5132e708dea9e2066f13f1b001bd954d7b477f56 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104484 Tested-by: Jenkins Reviewed-by: Mark Hung (cherry picked from commit 5b74b3322fd51cf075eb0c218b3adb786a28b4c9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104680 Reviewed-by: Xisco Fauli diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 73d85a07b7ce..9af0db1ccdc3 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -755,7 +755,15 @@ void EditEngine::RemoveCharAttribs(sal_Int32 nPara, sal_uInt16 nWhich, bool bRem void EditEngine::RemoveCharAttribs(const EditSelection& rSel, bool bRemoveParaAttribs, sal_uInt16 nWhich) { -pImpEditEngine->RemoveCharAttribs(rSel, bRemoveParaAttribs, nWhich); +const EERemoveParaAttribsMode eMode = bRemoveParaAttribs? +EERemoveParaAttribsMode::RemoveAll : +EERemoveParaAttribsMode::RemoveCharItems; +pImpEditEngine->RemoveCharAttribs(rSel, eMode, nWhich); +} + +void EditEngine::RemoveCharAttribs(const EditSelection& rSel, EERemoveParaAttribsMode eMode, sal_uInt16 nWhich) +{ +pImpEditEngine->RemoveCharAttribs(rSel, eMode, nWhich); } EditEngine::ViewsType& EditEngine::GetEditViews() @@ -1773,10 +1781,13 @@ SfxItemSet EditEngine::GetAttribs( sal_Int32 nPara, sal_Int32 nStart, sal_Int32 void EditEngine::RemoveAttribs( const ESelection& rSelection, bool bRemoveParaAttribs, sal_uInt16 nWhich ) { +const EERemoveParaAttribsMode eMode = bRemoveParaAttribs? +EERemoveParaAttribsMode::RemoveAll : +EERemoveParaAttribsMode::RemoveCharItems; pImpEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); EditSelection aSel( pImpEditEngine->ConvertSelection( rSelection.nStartPara, rSelection.nStartPos, rSelection.nEndPara, rSelection.nEndPos ) ); -pImpEditEngine->RemoveCharAttribs( aSel, bRemoveParaAttribs, nWhich ); +pImpEditEngine->RemoveCharAttribs( aSel, eMode, nWhich ); pImpEditEngine->UndoActionEnd(); pImpEditEngine->FormatAndUpdate(); } diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 7c6698f7c2c8..7bfd9e616d40 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -559,10 +559,15 @@ void EditView::RemoveAttribsKeepLanguages( bool bRemoveParaAttribs ) void EditView::RemoveAttribs( bool bRemoveParaAttribs, sal_uInt16 nWhich ) { +RemoveAttribs(bRemoveParaAttribs ? EERemoveParaAttribsMode::RemoveAll +: EERemoveParaAttribsMode::RemoveCharItems, nWhich); +} +void EditView::RemoveAttribs( EERemoveParaAttribsMode eMode, sal_uInt16 nWhich ) +{ pImpEditView->DrawSelectionXOR(); pImpEditView->pEditEngine->UndoActionStart( EDITUNDO_RESETATTRIBS ); -pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), bRemoveParaAttribs, nWhich ); +pImpEditView->pEditEngine->RemoveCharAttribs( pImpEditView->GetEditSelection(), eMode, nWhich ); pImpEditView->pEditEngine->UndoActionEnd(); pImpEditView->pEditEngine->FormatAndUpdate( this ); } diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 0ec