include/vcl/filter/SvmReader.hxx | 1 include/vcl/metaact.hxx | 4 +++ vcl/source/filter/svm/SvmReader.cxx | 39 +++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-)
New commits: commit 913cb8b32eb5346699770d52d288e02cc090011e Author: panoskorovesis <panoskorove...@outlook.com> AuthorDate: Thu Jul 15 12:23:31 2021 +0300 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Tue Jul 27 08:07:46 2021 +0200 Add Handler for Comment Read The handler separates MetaCommentAction::Read from metaact.hxx Read implementation is now in SvmReader.hxx Change-Id: Ic37db0ecb30482b3503ede88cd9d72de2ed0efde Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119194 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/vcl/filter/SvmReader.hxx b/include/vcl/filter/SvmReader.hxx index 3ef53c4a7962..f075e2899f6f 100644 --- a/include/vcl/filter/SvmReader.hxx +++ b/include/vcl/filter/SvmReader.hxx @@ -87,6 +87,7 @@ public: rtl::Reference<MetaAction> FloatTransparentHandler(ImplMetaReadData* pData); rtl::Reference<MetaAction> EPSHandler(); rtl::Reference<MetaAction> RefPointHandler(); + rtl::Reference<MetaAction> CommentHandler(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/metaact.hxx b/include/vcl/metaact.hxx index fe79942ac28e..be174299d1f1 100644 --- a/include/vcl/metaact.hxx +++ b/include/vcl/metaact.hxx @@ -1796,6 +1796,10 @@ public: sal_Int32 GetValue() const { return mnValue; } sal_uInt32 GetDataSize() const { return mnDataSize; } const sal_uInt8* GetData() const { return mpData.get(); } + void SetComment(const OString& rComment) { maComment = rComment; } + void SetValue(const sal_Int32 nValue) { mnValue = nValue; } + void SetDataSize(const sal_Int32 nDataSize) { mnDataSize = nDataSize; } + void SetData(const sal_uInt8* pData, const sal_uInt32 nDataSize) { ImplInitDynamicData(pData, nDataSize); } }; class UNLESS_MERGELIBS(VCL_DLLPUBLIC) MetaLayoutModeAction final : public MetaAction diff --git a/vcl/source/filter/svm/SvmReader.cxx b/vcl/source/filter/svm/SvmReader.cxx index 675bba95f7da..587b31809c7d 100644 --- a/vcl/source/filter/svm/SvmReader.cxx +++ b/vcl/source/filter/svm/SvmReader.cxx @@ -311,7 +311,7 @@ rtl::Reference<MetaAction> SvmReader::MetaActionHandler(ImplMetaReadData* pData) return RefPointHandler(); break; case MetaActionType::COMMENT: - pAction = new MetaCommentAction; + return CommentHandler(); break; case MetaActionType::LAYOUTMODE: pAction = new MetaLayoutModeAction; @@ -1377,4 +1377,41 @@ rtl::Reference<MetaAction> SvmReader::RefPointHandler() return pAction; } + +rtl::Reference<MetaAction> SvmReader::CommentHandler() +{ + auto pAction = new MetaCommentAction(); + + VersionCompatRead aCompat(mrStream); + OString aComment; + aComment = read_uInt16_lenPrefixed_uInt8s_ToOString(mrStream); + sal_Int32 nValue; + sal_uInt32 nDataSize; + mrStream.ReadInt32(nValue).ReadUInt32(nDataSize); + + if (nDataSize > mrStream.remainingSize()) + { + SAL_WARN("vcl.gdi", "Parsing error: " << mrStream.remainingSize() << " available data, but " + << nDataSize << " claimed, truncating"); + nDataSize = mrStream.remainingSize(); + } + + SAL_INFO("vcl.gdi", "MetaCommentAction::Read " << aComment); + + std::unique_ptr<sal_uInt8[]> pData; + pData.reset(); + + if (nDataSize) + { + pData.reset(new sal_uInt8[nDataSize]); + mrStream.ReadBytes(pData.get(), nDataSize); + } + + pAction->SetComment(aComment); + pAction->SetDataSize(nDataSize); + pAction->SetValue(nValue); + pAction->SetData(pData.get(), nDataSize); + + return pAction; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits