editeng/source/editeng/impedit3.cxx |    6 ++++--
 sw/qa/core/text/data/tdf129810.odt  |binary
 sw/qa/core/text/text.cxx            |   33 +++++++++++++++++++++++++++++++++
 sw/source/core/text/porlay.cxx      |    3 +++
 4 files changed, 40 insertions(+), 2 deletions(-)

New commits:
commit 4a92323b54e7d63a8bc0b8e62fdc6b31760dcd05
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Fri Jun 23 19:10:49 2023 +0300
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Sat Jun 24 01:01:18 2023 +0200

    tdf#129810: Compress fullwidth CJK punctuation
    
    When compressions CJK punctuation, compress also full width versions to
    match Word behaviour.
    
    Change-Id: Ic35cfcbacca1974b7241d657f078148bac06478e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153530
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>

diff --git a/editeng/source/editeng/impedit3.cxx 
b/editeng/source/editeng/impedit3.cxx
index 7a82359e8851..510ab1624319 100644
--- a/editeng/source/editeng/impedit3.cxx
+++ b/editeng/source/editeng/impedit3.cxx
@@ -142,14 +142,16 @@ AsianCompressionFlags GetCharTypeForCompression( 
sal_Unicode cChar )
     {
         case 0x3008: case 0x300A: case 0x300C: case 0x300E:
         case 0x3010: case 0x3014: case 0x3016: case 0x3018:
-        case 0x301A: case 0x301D:
+        case 0x301A: case 0x301D: case 0xFF09: case 0xFF3D:
+        case 0xFF5D:
         {
             return AsianCompressionFlags::PunctuationRight;
         }
         case 0x3001: case 0x3002: case 0x3009: case 0x300B:
         case 0x300D: case 0x300F: case 0x3011: case 0x3015:
         case 0x3017: case 0x3019: case 0x301B: case 0x301E:
-        case 0x301F:
+        case 0x301F: case 0xFF08: case 0xFF0C: case 0xFF0E:
+        case 0xFF1A: case 0xFF1B: case 0xFF3B: case 0xFF5B:
         {
             return AsianCompressionFlags::PunctuationLeft;
         }
diff --git a/sw/qa/core/text/data/tdf129810.odt 
b/sw/qa/core/text/data/tdf129810.odt
new file mode 100644
index 000000000000..b5a482b52caf
Binary files /dev/null and b/sw/qa/core/text/data/tdf129810.odt differ
diff --git a/sw/qa/core/text/text.cxx b/sw/qa/core/text/text.cxx
index 96ffbf4e74a3..0997d64725b8 100644
--- a/sw/qa/core/text/text.cxx
+++ b/sw/qa/core/text/text.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/text/XDocumentIndex.hpp>
 
 #include <vcl/gdimtf.hxx>
+#include <vcl/metaact.hxx>
 #include <vcl/filter/PDFiumLibrary.hxx>
 #include <comphelper/propertyvalue.hxx>
 #include <editeng/fhgtitem.hxx>
@@ -1424,6 +1425,38 @@ CPPUNIT_TEST_FIXTURE(SwCoreTextTest, 
testParaUpperMarginFlyIntersect)
     CPPUNIT_ASSERT_EQUAL(521, nHeight);
 }
 
+CPPUNIT_TEST_FIXTURE(SwCoreTextTest, testTdf129810)
+{
+    // Load the document, which embeds a CJK font.
+    createSwDoc("tdf129810.odt");
+
+    // Render the document to a metafile.
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    SwDocShell* pShell = pTextDoc->GetDocShell();
+    std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile();
+    CPPUNIT_ASSERT(xMetaFile);
+
+    // Find the fist text array action
+    for (size_t nAction = 0; nAction < xMetaFile->GetActionSize(); nAction++)
+    {
+        auto pAction = xMetaFile->GetAction(nAction);
+        if (pAction->GetType() == MetaActionType::TEXTARRAY)
+        {
+            auto pTextArrayAction = static_cast<MetaTextArrayAction*>(pAction);
+            auto pDXArray = pTextArrayAction->GetDXArray();
+
+            // There should be 13 chars on the first line
+            CPPUNIT_ASSERT_GREATER(size_t(13), pDXArray.size());
+
+            // Assert we are using the expected width for uncompressed chars
+            CPPUNIT_ASSERT_EQUAL(sal_Int32(720), pDXArray[0]);
+            // Assert we are using the expected width for compressed chars
+            CPPUNIT_ASSERT_EQUAL(sal_Int32(500), pDXArray[6] - pDXArray[5]);
+            break;
+        }
+    }
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx
index 14ac23395dcf..4f15fbcccbf7 100644
--- a/sw/source/core/text/porlay.cxx
+++ b/sw/source/core/text/porlay.cxx
@@ -1481,6 +1481,7 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& rNode,
                 case 0x3008: case 0x300A: case 0x300C: case 0x300E:
                 case 0x3010: case 0x3014: case 0x3016: case 0x3018:
                 case 0x301A: case 0x301D:
+                case 0xFF08: case 0xFF3B: case 0xFF5B:
                     eState = SPECIAL_LEFT;
                     break;
                 // Right punctuation found
@@ -1488,9 +1489,11 @@ void SwScriptInfo::InitScriptInfo(const SwTextNode& 
rNode,
                 case 0x300D: case 0x300F: case 0x3011: case 0x3015:
                 case 0x3017: case 0x3019: case 0x301B: case 0x301E:
                 case 0x301F:
+                case 0xFF09: case 0xFF3D: case 0xFF5D:
                     eState = SPECIAL_RIGHT;
                     break;
                 case 0x3001: case 0x3002:   // Fullstop or comma
+                case 0xFF0C: case 0xFF0E: case 0xFF1A: case 0xFF1B:
                     eState = SPECIAL_MIDDLE ;
                     break;
                 default:

Reply via email to