vcl/source/filter/svm/SvmReader.cxx |   21 +++++++++++++++++++++
 vcl/source/filter/svm/SvmWriter.cxx |    8 +++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit 62ff1053eeba26cecd7264db08e73da154835816
Author:     Khaled Hosny <kha...@aliftype.com>
AuthorDate: Sat Aug 13 23:06:27 2022 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sun Aug 14 22:01:19 2022 +0200

    svm: serialize MetaTextArrayAction’s Kashida array
    
    Otherwise reading SVM files would lose the Kashida but not the DX
    adjustments and would leave blanks in their place.
    
    Change-Id: Id37e09fed12da5e256d65e2c45c91869364c8d06
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138242
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/source/filter/svm/SvmReader.cxx 
b/vcl/source/filter/svm/SvmReader.cxx
index f02451ea36ff..a7b990c3ddba 100644
--- a/vcl/source/filter/svm/SvmReader.cxx
+++ b/vcl/source/filter/svm/SvmReader.cxx
@@ -707,6 +707,27 @@ rtl::Reference<MetaAction> 
SvmReader::TextArrayHandler(const ImplMetaReadData* p
     if (!aArray.empty())
         pAction->SetDXArray(std::move(aArray));
 
+    if (aCompat.GetVersion() >= 3) // Version 3
+    {
+        sal_Int32 nKashidaAryLen(0);
+        mrStream.ReadInt32(nKashidaAryLen);
+        nTmpLen = std::min(nKashidaAryLen, sal_Int32(aArray.size()));
+        if (nTmpLen)
+        {
+            // aKashidaArray, if not empty, must be the same size as aArray
+            std::vector<sal_Bool> aKashidaArray(aArray.size(), 0);
+
+            // [-loplugin:fakebool] false positive:
+            sal_Bool val(sal_False);
+            for (sal_Int32 i = 0; i < nTmpLen; i++)
+            {
+                mrStream.ReadUChar(val);
+                aKashidaArray[i] = val;
+            }
+            pAction->SetKashidaArray(std::move(aKashidaArray));
+        }
+    }
+
     return pAction;
 }
 
diff --git a/vcl/source/filter/svm/SvmWriter.cxx 
b/vcl/source/filter/svm/SvmWriter.cxx
index 118db1325d71..6dec8279c151 100644
--- a/vcl/source/filter/svm/SvmWriter.cxx
+++ b/vcl/source/filter/svm/SvmWriter.cxx
@@ -988,7 +988,7 @@ void SvmWriter::TextArrayHandler(const MetaTextArrayAction* 
pAction, const ImplM
 
     const sal_Int32 nAryLen = !rDXArray.empty() ? pAction->GetLen() : 0;
 
-    VersionCompatWrite aCompat(mrStream, 2);
+    VersionCompatWrite aCompat(mrStream, 3);
     TypeSerializer aSerializer(mrStream);
     aSerializer.writePoint(pAction->GetPoint());
     mrStream.WriteUniOrByteString(pAction->GetText(), pData->meActualCharSet);
@@ -1000,6 +1000,12 @@ void SvmWriter::TextArrayHandler(const 
MetaTextArrayAction* pAction, const ImplM
         mrStream.WriteInt32(rDXArray[i]);
 
     write_uInt16_lenPrefixed_uInt16s_FromOUString(mrStream, 
pAction->GetText()); // version 2
+
+    // Version 3
+    const auto& rKashidaArray = pAction->GetKashidaArray();
+    mrStream.WriteInt32(sal_Int32(rKashidaArray.size()));
+    for (const auto& val : rKashidaArray)
+        mrStream.WriteUChar(val);
 }
 
 void SvmWriter::StretchTextHandler(const MetaStretchTextAction* pAction,

Reply via email to