[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/source

2021-02-12 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit fe0a78bb9f0915860f351ed8fb6ef76eaaafc588
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 9 19:02:25 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Feb 12 21:02:40 2021 +0900

vcl: split-up GraphicFilter::Import into per-format methods

Change-Id: Idb5f120f47b4374fc709413a615baa606cd9b165

diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 5b18654cb81b..1943e60cdd53 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -327,6 +327,25 @@ public:
 
 void preload();
 
+ErrCode readGIF(SvStream& rStream, Graphic& rGraphic, GfxLinkType& 
rLinkType);
+ErrCode readPNG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+std::unique_ptr & rpGraphicContent, 
sal_Int32& rGraphicContentSize);
+ErrCode readJPEG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+GraphicFilterImportFlags nImportFlags);
+ErrCode readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+std::unique_ptr & rpGraphicContent, 
sal_Int32& rGraphicContentSize);
+ErrCode readXBM(SvStream & rStream, Graphic & rGraphic);
+ErrCode readXPM(SvStream & rStream, Graphic & rGraphic);
+
+ErrCode readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+WmfExternal const* pExtHeader, VectorGraphicDataType 
eType);
+ErrCode readWMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType, WmfExternal const* pExtHeader);
+ErrCode readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType, WmfExternal const* pExtHeader);
+
+ErrCode readPDF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType);
+ErrCode readTIFF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType);
+ErrCode readWithTypeSerializer(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, OUString aFilterName);
+
 private:
 OUStringaFilterPath;
 FilterConfigCache*  pConfig;
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index d6b1f9e5777a..3a2e38ec5b11 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1449,17 +1449,282 @@ void GraphicFilter::preload()
 }
 }
 
+ErrCode GraphicFilter::readGIF(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType)
+{
+if (ImportGIF(rStream, rGraphic))
+{
+rLinkType = GfxLinkType::NativeGif;
+return ERRCODE_NONE;
+}
+else
+return ERRCODE_GRFILTER_FILTERERROR;
+}
+
+ErrCode GraphicFilter::readPNG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, std::unique_ptr & rpGraphicContent,
+sal_Int32& rGraphicContentSize)
+{
+ErrCode aReturnCode = ERRCODE_NONE;
+
+vcl::PNGReader aPNGReader(rStream);
+{
+// check if this PNG contains a GIF chunk!
+const std::vector& rChunkData = 
aPNGReader.GetChunks();
+for (auto const& chunk : rChunkData)
+{
+// Microsoft Office is storing Animated GIFs in following chunk
+if (chunk.nType == PMGCHUNG_msOG)
+{
+sal_uInt32 nChunkSize = chunk.aData.size();
+
+if (nChunkSize > 11)
+{
+const std::vector& rData = chunk.aData;
+rGraphicContentSize = nChunkSize - 11;
+SvMemoryStream aIStrm(const_cast([11]), 
rGraphicContentSize, StreamMode::READ);
+rpGraphicContent.reset(new sal_uInt8[rGraphicContentSize]);
+sal_uInt64 aCurrentPosition = aIStrm.Tell();
+aIStrm.ReadBytes(rpGraphicContent.get(), 
rGraphicContentSize);
+aIStrm.Seek(aCurrentPosition);
+ImportGIF(aIStrm, rGraphic);
+rLinkType = GfxLinkType::NativeGif;
+return aReturnCode;
+}
+}
+}
+}
+
+// PNG has no GIF chunck
+BitmapEx aBitmapEx(aPNGReader.Read());
+if (!aBitmapEx.IsEmpty())
+{
+rGraphic = aBitmapEx;
+rLinkType = GfxLinkType::NativePng;
+}
+else
+aReturnCode = ERRCODE_GRFILTER_FILTERERROR;
+
+return aReturnCode;
+}
+
+ErrCode GraphicFilter::readJPEG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, GraphicFilterImportFlags nImportFlags)
+{
+ErrCode aReturnCode = ERRCODE_NONE;
+
+// set LOGSIZE flag always, if not explicitly disabled
+// (see #90508 and #106763)
+if (!(nImportFlags & GraphicFilterImportFlags::DontSetLogsizeForJpeg))
+{
+nImportFlags |= GraphicFilterImportFlags::SetLogsizeForJpeg;
+}
+
+sal_uInt64 nPosition = rStream.Tell();
+if (!ImportJPEG(rStream, rGraphic, nImportFlags | 
GraphicFilterImportFlags::OnlyCreateBitmap, nullptr))
+aReturnCode 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/source

2021-02-12 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit e0cee7aecae51074da9028147d31438090198750
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 9 19:02:25 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Feb 12 20:32:57 2021 +0900

vcl: split-up GraphicFilter::Import into per-format methods

Change-Id: Idb5f120f47b4374fc709413a615baa606cd9b165

diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 5b18654cb81b..d3f6152ebd5b 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -327,6 +327,23 @@ public:
 
 void preload();
 
+ErrCode readGIF(SvStream& rStream, Graphic& rGraphic, GfxLinkType& 
rLinkType);
+ErrCode readPNG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+std::unique_ptr & rpGraphicContent, 
sal_Int32& rGraphicContentSize);
+ErrCode readJPEG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+GraphicFilterImportFlags nImportFlags);
+ErrCode readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+std::unique_ptr & rpGraphicContent, 
sal_Int32& rGraphicContentSize);
+ErrCode readXBM(SvStream & rStream, Graphic & rGraphic);
+ErrCode readXPM(SvStream & rStream, Graphic & rGraphic);
+
+ErrCode readWMF_EMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+WmfExternal const* pExtHeader, VectorGraphicDataType 
eType);
+ErrCode readWMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType, WmfExternal const* pExtHeader);
+ErrCode readEMF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType, WmfExternal const* pExtHeader);
+
+ErrCode readPDF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType);
+ErrCode readTIFF(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType);
 private:
 OUStringaFilterPath;
 FilterConfigCache*  pConfig;
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index d6b1f9e5777a..260638039e56 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1449,17 +1449,257 @@ void GraphicFilter::preload()
 }
 }
 
+ErrCode GraphicFilter::readGIF(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType)
+{
+if (ImportGIF(rStream, rGraphic))
+{
+rLinkType = GfxLinkType::NativeGif;
+return ERRCODE_NONE;
+}
+else
+return ERRCODE_GRFILTER_FILTERERROR;
+}
+
+ErrCode GraphicFilter::readPNG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, std::unique_ptr & rpGraphicContent,
+sal_Int32& rGraphicContentSize)
+{
+ErrCode aReturnCode = ERRCODE_NONE;
+
+vcl::PNGReader aPNGReader(rStream);
+{
+// check if this PNG contains a GIF chunk!
+const std::vector& rChunkData = 
aPNGReader.GetChunks();
+for (auto const& chunk : rChunkData)
+{
+// Microsoft Office is storing Animated GIFs in following chunk
+if (chunk.nType == PMGCHUNG_msOG)
+{
+sal_uInt32 nChunkSize = chunk.aData.size();
+
+if (nChunkSize > 11)
+{
+const std::vector& rData = chunk.aData;
+rGraphicContentSize = nChunkSize - 11;
+SvMemoryStream aIStrm(const_cast([11]), 
rGraphicContentSize, StreamMode::READ);
+rpGraphicContent.reset(new sal_uInt8[rGraphicContentSize]);
+sal_uInt64 aCurrentPosition = aIStrm.Tell();
+aIStrm.ReadBytes(rpGraphicContent.get(), 
rGraphicContentSize);
+aIStrm.Seek(aCurrentPosition);
+ImportGIF(aIStrm, rGraphic);
+rLinkType = GfxLinkType::NativeGif;
+return aReturnCode;
+}
+}
+}
+}
+
+// PNG has no GIF chunck
+BitmapEx aBitmapEx(aPNGReader.Read());
+if (!aBitmapEx.IsEmpty())
+{
+rGraphic = aBitmapEx;
+rLinkType = GfxLinkType::NativePng;
+}
+else
+aReturnCode = ERRCODE_GRFILTER_FILTERERROR;
+
+return aReturnCode;
+}
+
+ErrCode GraphicFilter::readJPEG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, GraphicFilterImportFlags nImportFlags)
+{
+ErrCode aReturnCode = ERRCODE_NONE;
+
+// set LOGSIZE flag always, if not explicitly disabled
+// (see #90508 and #106763)
+if (!(nImportFlags & GraphicFilterImportFlags::DontSetLogsizeForJpeg))
+{
+nImportFlags |= GraphicFilterImportFlags::SetLogsizeForJpeg;
+}
+
+sal_uInt64 nPosition = rStream.Tell();
+if (!ImportJPEG(rStream, rGraphic, nImportFlags | 
GraphicFilterImportFlags::OnlyCreateBitmap, nullptr))
+aReturnCode = ERRCODE_GRFILTER_FILTERERROR;
+else
+{
+Bitmap& rBitmap = 
const_cast(rGraphic.GetBitmapExRef().GetBitmap());

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/source

2021-02-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/graphicfilter.hxx   |7 
 vcl/source/filter/graphicfilter.cxx |  308 
 2 files changed, 179 insertions(+), 136 deletions(-)

New commits:
commit bcf411b61c5d9022f3bd0859b32876706bd54d79
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 9 19:02:25 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Feb 9 19:06:55 2021 +0900

vcl: split-up GraphicFilter::Import into per-format methods

Change-Id: Idb5f120f47b4374fc709413a615baa606cd9b165

diff --git a/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 5b18654cb81b..84b856d4b3be 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -327,6 +327,13 @@ public:
 
 void preload();
 
+ErrCode readGIF(SvStream& rStream, Graphic& rGraphic, GfxLinkType& 
rLinkType);
+ErrCode readPNG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+std::unique_ptr & rpGraphicContent, 
sal_Int32& rGraphicContentSize);
+ErrCode readJPEG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+GraphicFilterImportFlags nImportFlags);
+ErrCode readSVG(SvStream & rStream, Graphic & rGraphic, GfxLinkType & 
rLinkType,
+std::unique_ptr & rpGraphicContent, 
sal_Int32& rGraphicContentSize);
 private:
 OUStringaFilterPath;
 FilterConfigCache*  pConfig;
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index d6b1f9e5777a..61c660ddf141 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1449,17 +1449,175 @@ void GraphicFilter::preload()
 }
 }
 
+ErrCode GraphicFilter::readGIF(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType)
+{
+if (ImportGIF(rStream, rGraphic))
+{
+rLinkType = GfxLinkType::NativeGif;
+return ERRCODE_NONE;
+}
+else
+return ERRCODE_GRFILTER_FILTERERROR;
+}
+
+ErrCode GraphicFilter::readPNG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, std::unique_ptr & rpGraphicContent,
+sal_Int32& rGraphicContentSize)
+{
+ErrCode aReturnCode = ERRCODE_NONE;
+
+vcl::PNGReader aPNGReader(rStream);
+{
+// check if this PNG contains a GIF chunk!
+const std::vector& rChunkData = 
aPNGReader.GetChunks();
+for (auto const& chunk : rChunkData)
+{
+// Microsoft Office is storing Animated GIFs in following chunk
+if (chunk.nType == PMGCHUNG_msOG)
+{
+sal_uInt32 nChunkSize = chunk.aData.size();
+
+if (nChunkSize > 11)
+{
+const std::vector& rData = chunk.aData;
+rGraphicContentSize = nChunkSize - 11;
+SvMemoryStream aIStrm(const_cast([11]), 
rGraphicContentSize, StreamMode::READ);
+rpGraphicContent.reset(new sal_uInt8[rGraphicContentSize]);
+sal_uInt64 aCurrentPosition = aIStrm.Tell();
+aIStrm.ReadBytes(rpGraphicContent.get(), 
rGraphicContentSize);
+aIStrm.Seek(aCurrentPosition);
+ImportGIF(aIStrm, rGraphic);
+rLinkType = GfxLinkType::NativeGif;
+return aReturnCode;
+}
+}
+}
+}
+
+// PNG has no GIF chunck
+BitmapEx aBitmapEx(aPNGReader.Read());
+if (!aBitmapEx.IsEmpty())
+{
+rGraphic = aBitmapEx;
+rLinkType = GfxLinkType::NativePng;
+}
+else
+aReturnCode = ERRCODE_GRFILTER_FILTERERROR;
+
+return aReturnCode;
+}
+
+ErrCode GraphicFilter::readJPEG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, GraphicFilterImportFlags nImportFlags)
+{
+ErrCode aReturnCode = ERRCODE_NONE;
+
+// set LOGSIZE flag always, if not explicitly disabled
+// (see #90508 and #106763)
+if (!(nImportFlags & GraphicFilterImportFlags::DontSetLogsizeForJpeg))
+{
+nImportFlags |= GraphicFilterImportFlags::SetLogsizeForJpeg;
+}
+
+sal_uInt64 nPosition = rStream.Tell();
+if (!ImportJPEG(rStream, rGraphic, nImportFlags | 
GraphicFilterImportFlags::OnlyCreateBitmap, nullptr))
+aReturnCode = ERRCODE_GRFILTER_FILTERERROR;
+else
+{
+Bitmap& rBitmap = 
const_cast(rGraphic.GetBitmapExRef().GetBitmap());
+BitmapScopedWriteAccess pWriteAccess(rBitmap);
+rStream.Seek(nPosition);
+if (!ImportJPEG(rStream, rGraphic, nImportFlags | 
GraphicFilterImportFlags::UseExistingBitmap, ))
+aReturnCode = ERRCODE_GRFILTER_FILTERERROR;
+else
+rLinkType = GfxLinkType::NativeJpg;
+}
+
+return aReturnCode;
+}
+
+ErrCode GraphicFilter::readSVG(SvStream & rStream, Graphic & rGraphic, 
GfxLinkType & rLinkType, std::unique_ptr & rpGraphicContent,
+sal_Int32& rGraphicContentSize)
+{
+ErrCode aReturnCode = 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl offapi/com offapi/UnoApi_offapi.mk vcl/inc vcl/Library_vcl.mk vcl/source

2020-12-31 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 6767de862a64b75e4c40a9a4874aaa3bb9f5d9d5
Author: Tomaž Vajngerl 
AuthorDate: Fri Dec 25 20:10:44 2020 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Dec 31 21:02:01 2020 +0900

vcl: add an UNO interface and impl. for BinaryDataContainer

Change-Id: Icbc384892bee8c31eb7f3a39ff9a64f1199b23b1

diff --git a/include/vcl/BinaryDataContainerTools.hxx 
b/include/vcl/BinaryDataContainerTools.hxx
new file mode 100644
index ..3d50379a82d3
--- /dev/null
+++ b/include/vcl/BinaryDataContainerTools.hxx
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+
+namespace vcl
+{
+VCL_DLLPUBLIC BinaryDataContainer convertUnoBinaryDataContainer(
+css::uno::Reference const& 
rxBinaryDataContainer);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index eabb1272588a..5e7fa60ebc34 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -446,6 +446,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui/test,\
 UITest \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/util,\
+   BinaryDataContainer \
JobManager \
NumberFormatter \
NumberFormatsSupplier \
@@ -4143,6 +4144,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,com/sun/star/util,\
VetoException \
XAccounting \
XAtomServer \
+   XBinaryDataContainer \
XBroadcaster \
XCancellable \
XChainable \
diff --git a/offapi/com/sun/star/util/BinaryDataContainer.idl 
b/offapi/com/sun/star/util/BinaryDataContainer.idl
new file mode 100644
index ..be4102a20b1c
--- /dev/null
+++ b/offapi/com/sun/star/util/BinaryDataContainer.idl
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#ifndef com_sun_star_util_BinaryDataContainer_idl
+#define com_sun_star_util_BinaryDataContainer_idl
+
+
+module com { module sun { module star { module util
+{
+
+/** Implementation of a container for binary data.
+
+@since LibreOffice 7.2
+ */
+
+service BinaryDataContainer : XBinaryDataContainer
+{
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/util/XBinaryDataContainer.idl 
b/offapi/com/sun/star/util/XBinaryDataContainer.idl
new file mode 100644
index ..563ac4db7e00
--- /dev/null
+++ b/offapi/com/sun/star/util/XBinaryDataContainer.idl
@@ -0,0 +1,29 @@
+/* -*- 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/.
+ */
+
+#ifndef com_sun_star_util_XBinaryDataContainer_idl
+#define com_sun_star_util_XBinaryDataContainer_idl
+
+module com { module sun { module star { module util
+{
+
+/** Container for binary data, typically an in-memory content of files.
+
+@since LibreOffice 7.2
+ */
+interface XBinaryDataContainer
+{
+sequence getCopyAsByteSequence();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 1a93ab808208..478638da2220 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -322,12 +322,14 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/pdf/PDFiumLibrary \
 vcl/source/pdf/ExternalPDFStreams \
 vcl/source/graphic/BinaryDataContainer \
+vcl/source/graphic/BinaryDataContainerTools \
 vcl/source/graphic/GraphicID \
 vcl/source/graphic/GraphicLoader \
 vcl/source/graphic/GraphicObject \
 vcl/source/graphic/GraphicObject2 \
 vcl/source/graphic/GraphicReader \
 vcl/source/graphic/Manager \
+vcl/source/graphic/UnoBinaryDataContainer \
 vcl/source/graphic/UnoGraphic \
 vcl/source/graphic/UnoGraphicMapper \
 vcl/source/graphic/UnoGraphicDescriptor \
diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx 
b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
new file mode 100644
index ..115cbc46d46c
--- /dev/null
+++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl offapi/com offapi/UnoApi_offapi.mk vcl/inc vcl/Library_vcl.mk vcl/source

2020-12-31 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 08a8f10c21b8f1884a31b1ac7c82fdc36fa748ab
Author: Tomaž Vajngerl 
AuthorDate: Fri Dec 25 20:10:44 2020 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Dec 31 20:57:15 2020 +0900

vcl: add an UNO interface and impl. for BinaryDataContainer

Change-Id: Icbc384892bee8c31eb7f3a39ff9a64f1199b23b1

diff --git a/include/vcl/BinaryDataContainerTools.hxx 
b/include/vcl/BinaryDataContainerTools.hxx
new file mode 100644
index ..3d50379a82d3
--- /dev/null
+++ b/include/vcl/BinaryDataContainerTools.hxx
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+
+namespace vcl
+{
+VCL_DLLPUBLIC BinaryDataContainer convertUnoBinaryDataContainer(
+css::uno::Reference const& 
rxBinaryDataContainer);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk
index eabb1272588a..5e7fa60ebc34 100644
--- a/offapi/UnoApi_offapi.mk
+++ b/offapi/UnoApi_offapi.mk
@@ -446,6 +446,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/ui/test,\
 UITest \
 ))
 $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,com/sun/star/util,\
+   BinaryDataContainer \
JobManager \
NumberFormatter \
NumberFormatsSupplier \
@@ -4143,6 +4144,7 @@ $(eval $(call 
gb_UnoApi_add_idlfiles,offapi,com/sun/star/util,\
VetoException \
XAccounting \
XAtomServer \
+   XBinaryDataContainer \
XBroadcaster \
XCancellable \
XChainable \
diff --git a/offapi/com/sun/star/util/BinaryDataContainer.idl 
b/offapi/com/sun/star/util/BinaryDataContainer.idl
new file mode 100644
index ..be4102a20b1c
--- /dev/null
+++ b/offapi/com/sun/star/util/BinaryDataContainer.idl
@@ -0,0 +1,30 @@
+/* -*- 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/.
+ */
+
+#ifndef com_sun_star_util_BinaryDataContainer_idl
+#define com_sun_star_util_BinaryDataContainer_idl
+
+
+module com { module sun { module star { module util
+{
+
+/** Implementation of a container for binary data.
+
+@since LibreOffice 7.2
+ */
+
+service BinaryDataContainer : XBinaryDataContainer
+{
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/util/XBinaryDataContainer.idl 
b/offapi/com/sun/star/util/XBinaryDataContainer.idl
new file mode 100644
index ..563ac4db7e00
--- /dev/null
+++ b/offapi/com/sun/star/util/XBinaryDataContainer.idl
@@ -0,0 +1,29 @@
+/* -*- 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/.
+ */
+
+#ifndef com_sun_star_util_XBinaryDataContainer_idl
+#define com_sun_star_util_XBinaryDataContainer_idl
+
+module com { module sun { module star { module util
+{
+
+/** Container for binary data, typically an in-memory content of files.
+
+@since LibreOffice 7.2
+ */
+interface XBinaryDataContainer
+{
+sequence getCopyAsByteSequence();
+};
+
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 1a93ab808208..478638da2220 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -322,12 +322,14 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/pdf/PDFiumLibrary \
 vcl/source/pdf/ExternalPDFStreams \
 vcl/source/graphic/BinaryDataContainer \
+vcl/source/graphic/BinaryDataContainerTools \
 vcl/source/graphic/GraphicID \
 vcl/source/graphic/GraphicLoader \
 vcl/source/graphic/GraphicObject \
 vcl/source/graphic/GraphicObject2 \
 vcl/source/graphic/GraphicReader \
 vcl/source/graphic/Manager \
+vcl/source/graphic/UnoBinaryDataContainer \
 vcl/source/graphic/UnoGraphic \
 vcl/source/graphic/UnoGraphicMapper \
 vcl/source/graphic/UnoGraphicDescriptor \
diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx 
b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
new file mode 100644
index ..f722d8966b62
--- /dev/null
+++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/inc vcl/Library_vcl.mk vcl/source vcl/vcl.common.component

2020-12-31 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 1a5731ca35bec6663842eaf517d72174c81d009f
Author: Tomaž Vajngerl 
AuthorDate: Thu Dec 31 19:38:25 2020 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Dec 31 19:41:03 2020 +0900

BinaryDataContainer UNO improvement

Change-Id: I44afd52d39bcb3d11bbd6676f54118b4161786cb

diff --git a/include/vcl/BinaryDataContainerTools.hxx 
b/include/vcl/BinaryDataContainerTools.hxx
new file mode 100644
index ..3d50379a82d3
--- /dev/null
+++ b/include/vcl/BinaryDataContainerTools.hxx
@@ -0,0 +1,23 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+
+namespace vcl
+{
+VCL_DLLPUBLIC BinaryDataContainer convertUnoBinaryDataContainer(
+css::uno::Reference const& 
rxBinaryDataContainer);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index b7b47ac463ec..478638da2220 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -322,6 +322,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/pdf/PDFiumLibrary \
 vcl/source/pdf/ExternalPDFStreams \
 vcl/source/graphic/BinaryDataContainer \
+vcl/source/graphic/BinaryDataContainerTools \
 vcl/source/graphic/GraphicID \
 vcl/source/graphic/GraphicLoader \
 vcl/source/graphic/GraphicObject \
diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx 
b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
new file mode 100644
index ..f722d8966b62
--- /dev/null
+++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
@@ -0,0 +1,53 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+class UnoBinaryDataContainer final
+: public cppu::WeakImplHelper
+{
+private:
+BinaryDataContainer maBinaryDataContainer;
+
+public:
+UnoBinaryDataContainer() {}
+
+UnoBinaryDataContainer(BinaryDataContainer const& rBinaryDataContainer)
+: maBinaryDataContainer(rBinaryDataContainer)
+{
+}
+
+BinaryDataContainer const& getBinaryDataContainer() const { return 
maBinaryDataContainer; }
+
+void setBinaryDataContainer(BinaryDataContainer const& 
rBinaryDataContainer)
+{
+maBinaryDataContainer = rBinaryDataContainer;
+}
+
+// XBinaryDataContainer
+css::uno::Sequence SAL_CALL getCopyAsByteSequence() override;
+
+UNO3_GETIMPLEMENTATION_DECL(UnoBinaryDataContainer)
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/BinaryDataContainerTools.cxx 
b/vcl/source/graphic/BinaryDataContainerTools.cxx
new file mode 100644
index ..3921e075cea2
--- /dev/null
+++ b/vcl/source/graphic/BinaryDataContainerTools.cxx
@@ -0,0 +1,28 @@
+/* -*- 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 
+
+namespace vcl
+{
+BinaryDataContainer convertUnoBinaryDataContainer(
+const css::uno::Reference& 
rxBinaryDataContainer)
+{
+BinaryDataContainer aBinaryDataContainer;
+UnoBinaryDataContainer* pUnoBinaryDataContainer
+= 
comphelper::getUnoTunnelImplementation(rxBinaryDataContainer);
+if (pUnoBinaryDataContainer)
+aBinaryDataContainer = 
pUnoBinaryDataContainer->getBinaryDataContainer();
+return aBinaryDataContainer;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/UnoBinaryDataContainer.cxx 
b/vcl/source/graphic/UnoBinaryDataContainer.cxx
index cd6ce99d4a39..8ee3660be416 100644
--- a/vcl/source/graphic/UnoBinaryDataContainer.cxx
+++ b/vcl/source/graphic/UnoBinaryDataContainer.cxx
@@ -8,77 +8,27 @@
  *
  */
 
-#include 
-#include 
+#include 
 
-#include 
-#include 
-#include 
-
-#include 
+#include 
 
 using namespace css;
 
-namespace
-{
-typedef ::cppu::WeakImplHelper
-BinaryDataContainer_BASE;
+// css::lang::XUnoTunnel
+UNO3_GETIMPLEMENTATION_IMPL(UnoBinaryDataContainer);
 
-class UnoBinaryDataContainer : public 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl sd/qa svx/source vcl/inc vcl/qa vcl/source

2020-12-27 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/vectorgraphicdata.hxx  |   19 ++-
 sd/qa/unit/SdrPdfImportTest.cxx|   11 ++--
 sd/qa/unit/import-tests.cxx|4 -
 svx/source/svdraw/svdpdf.cxx   |4 -
 svx/source/xoutdev/_xoutbmp.cxx|3 -
 vcl/inc/pdf/ExternalPDFStreams.hxx |7 +-
 vcl/qa/cppunit/PDFiumLibraryTest.cxx   |   30 
 vcl/source/filter/graphicfilter.cxx|9 ++-
 vcl/source/filter/ipdf/pdfread.cxx |   21 
 vcl/source/gdi/TypeSerializer.cxx  |6 +-
 vcl/source/gdi/impgraph.cxx|4 -
 vcl/source/gdi/pdfwriter_impl.cxx  |   13 ++---
 vcl/source/gdi/pdfwriter_impl.hxx  |3 -
 vcl/source/gdi/vectorgraphicdata.cxx   |   72 +++--
 vcl/source/graphic/GraphicID.cxx   |5 --
 vcl/source/graphic/VectorGraphicSearch.cxx |4 -
 vcl/source/pdf/ExternalPDFStreams.cxx  |9 +--
 17 files changed, 129 insertions(+), 95 deletions(-)

New commits:
commit 29d11ca997552df56917a5e310e5b68e0c3d187b
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 28 10:03:18 2020 +0900
Commit: Tomaž Vajngerl 
CommitDate: Mon Dec 28 10:05:02 2020 +0900

vcl: use BinaryDataContianer in VectorGraphicData

This change is needed so we can use the same data in GfxLink and
in VectorGraphicData. Currently the data needed to be duplicated,
which is less than ideal.

Change-Id: I79419921d09681fa8f0b1ac4bf8ea84199d4aae6

diff --git a/include/vcl/vectorgraphicdata.hxx 
b/include/vcl/vectorgraphicdata.hxx
index e231435312e8..8d55a9487d26 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -55,7 +56,7 @@ class VCL_DLLPUBLIC VectorGraphicData
 {
 private:
 // the file and length
-VectorGraphicDataArray  maVectorGraphicDataArray;
+BinaryDataContainer maDataContainer;
 
 // on demand created content
 boolmbSequenceCreated;
@@ -89,6 +90,10 @@ public:
 const VectorGraphicDataArray& rVectorGraphicDataArray,
 VectorGraphicDataType eVectorDataType,
 sal_Int32 nPageIndex = -1);
+VectorGraphicData(
+const BinaryDataContainer& rDataContainer,
+VectorGraphicDataType eVectorDataType,
+sal_Int32 nPageIndex = -1);
 ~VectorGraphicData();
 
 /// compare op
@@ -98,8 +103,16 @@ public:
 void setWmfExternalHeader(const WmfExternal& aExtHeader);
 
 /// data read
-const VectorGraphicDataArray& getVectorGraphicDataArray() const { return 
maVectorGraphicDataArray; }
-sal_uInt32 getVectorGraphicDataArrayLength() const { return 
maVectorGraphicDataArray.getLength(); }
+const BinaryDataContainer& getBinaryDataContainer() const
+{
+return maDataContainer;
+}
+
+sal_uInt32 getVectorGraphicDataArrayLength() const
+{
+return maDataContainer.getSize();
+}
+
 enum class State { UNPARSED, PARSED };
 std::pair getSizeBytes() const;
 
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index f5e24fd19ede..85fb33d8243c 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -175,8 +175,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, 
testAnnotationsImportExport)
 sd::ViewShell* pViewShell = 
pImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
 
-const void* pData = nullptr;
-int nLength = 0;
+BinaryDataContainer aContainer;
 
 {
 // Get the first page - there should be only one.
@@ -202,13 +201,15 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, 
testAnnotationsImportExport)
  pVectorGraphicData->getVectorGraphicDataType());
 
 // Write the PDF
-pData = 
pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
-nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+aContainer = pVectorGraphicData->getBinaryDataContainer();
 }
 
 { // check graphic PDF has annotations
 
-auto pPDFDocument = pPdfiumLibrary->openDocument(pData, nLength);
+CPPUNIT_ASSERT_EQUAL(false, aContainer.isEmpty());
+
+auto pPDFDocument
+= pPdfiumLibrary->openDocument(aContainer.getData(), 
aContainer.getSize());
 auto pPDFPage = pPDFDocument->openPage(0);
 
 CPPUNIT_ASSERT_EQUAL(2, pPDFPage->getAnnotationCount());
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 12b340ccf3fa..3de5d48b1f75 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1380,8 +1380,8 @@ void SdImportTest::testPDFImportShared()
 {
 Graphic const & rGraphic = aGraphics[i];
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all PDF streams to be 
identical.",
- 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/source

2020-12-22 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/BinaryDataContainer.hxx |   59 +
 include/vcl/gfxlink.hxx |   14 +++
 vcl/source/gdi/gfxlink.cxx  |   64 +++-
 3 files changed, 93 insertions(+), 44 deletions(-)

New commits:
commit 9c06701a2d588321348ad28dcd427a6f14912334
Author: Tomaž Vajngerl 
AuthorDate: Mon Dec 21 21:47:39 2020 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Dec 23 11:38:42 2020 +0900

vcl: add BinaryDataContainer and change GfxLink to use it

Add a wrapper for shared_ptr called BinaryDataContainer,
which is used to easily manage the binary data - mainly for a
better reuse, control and to prevent duplication.

Change-Id: I68140ec379dba4a5ab1b624a334129bba2401998

diff --git a/include/vcl/BinaryDataContainer.hxx 
b/include/vcl/BinaryDataContainer.hxx
new file mode 100644
index ..7ec9926b245c
--- /dev/null
+++ b/include/vcl/BinaryDataContainer.hxx
@@ -0,0 +1,59 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+#include 
+
+class VCL_DLLPUBLIC BinaryDataContainer final
+{
+private:
+// the binary data
+std::shared_ptr> mpData;
+
+public:
+explicit BinaryDataContainer() {}
+
+explicit BinaryDataContainer(size_t nSize)
+: mpData(std::make_shared>(nSize))
+{
+}
+
+explicit BinaryDataContainer(const sal_uInt8* pData, size_t nSize)
+: mpData(std::make_shared>(nSize))
+{
+std::copy(pData, pData + nSize, mpData->data());
+}
+
+explicit BinaryDataContainer(const BinaryDataContainer& 
rBinaryDataContainer) = default;
+explicit BinaryDataContainer(BinaryDataContainer&& rBinaryDataContainer) = 
default;
+BinaryDataContainer& operator=(const BinaryDataContainer& 
rBinaryDataContainer) = default;
+BinaryDataContainer& operator=(BinaryDataContainer&& rBinaryDataContainer) 
= default;
+
+size_t getSize() const { return mpData ? mpData->size() : 0; }
+
+bool isEmpty() const { return mpData ? mpData->empty() : true; }
+
+const sal_uInt8* getData() const { return mpData ? mpData->data() : 
nullptr; }
+
+size_t calculateHash() const
+{
+size_t nSeed = 0;
+boost::hash_combine(nSeed, getSize());
+for (sal_uInt8 const& rByte : *mpData)
+boost::hash_combine(nSeed, rByte);
+return nSeed;
+}
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/gfxlink.hxx b/include/vcl/gfxlink.hxx
index 72352f6902a1..85bb85cb53f2 100644
--- a/include/vcl/gfxlink.hxx
+++ b/include/vcl/gfxlink.hxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 class SvStream;
@@ -61,20 +62,17 @@ class VCL_DLLPUBLIC GfxLink
 private:
 GfxLinkType meType;
 sal_uInt32  mnUserId;
-mutable std::shared_ptr mpSwapInData;
+BinaryDataContainer maDataContainer;
 mutable size_t  maHash;
-sal_uInt32  mnSwapInDataSize;
 MapMode maPrefMapMode;
 SizemaPrefSize;
 boolmbPrefMapModeValid;
 boolmbPrefSizeValid;
 
-SAL_DLLPRIVATE std::shared_ptr GetSwapInData() const;
 public:
-GfxLink();
-
-// pBuff = The Graphic data. This class takes 
ownership of this
-GfxLink( std::unique_ptr pBuf, sal_uInt32 
nBufSize, GfxLinkType nType );
+GfxLink();
+explicit GfxLink(std::unique_ptr pBuf, sal_uInt32 nBufSize, 
GfxLinkType nType);
+explicit GfxLink(BinaryDataContainer const & rDataConainer, GfxLinkType 
nType);
 
 booloperator==( const GfxLink& ) const;
 
@@ -85,7 +83,7 @@ public:
 voidSetUserId( sal_uInt32 nUserId ) { mnUserId = nUserId; }
 sal_uInt32  GetUserId() const { return mnUserId; }
 
-sal_uInt32  GetDataSize() const { return mnSwapInDataSize;}
+sal_uInt32  GetDataSize() const { return 
maDataContainer.getSize(); }
 const sal_uInt8*GetData() const;
 
 const Size& GetPrefSize() const { return maPrefSize;}
diff --git a/vcl/source/gdi/gfxlink.cxx b/vcl/source/gdi/gfxlink.cxx
index 83936c277ead..82b37fe4e668 100644
--- a/vcl/source/gdi/gfxlink.cxx
+++ b/vcl/source/gdi/gfxlink.cxx
@@ -30,60 +30,61 @@ GfxLink::GfxLink()
 : meType(GfxLinkType::NONE)
 , mnUserId(0)
 , maHash(0)
-, mnSwapInDataSize(0)
 , mbPrefMapModeValid(false)
 , mbPrefSizeValid(false)
 {
 }
 
-
-
 GfxLink::GfxLink(std::unique_ptr pBuf, sal_uInt32 nSize, 
GfxLinkType nType)
 : meType(nType)
 , mnUserId(0)
-, 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl sd/source vcl/qa vcl/source

2020-06-04 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|   24 +++
 sd/source/ui/view/Outliner.cxx |   16 +++--
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   88 -
 vcl/source/graphic/VectorGraphicSearch.cxx |   22 ---
 4 files changed, 135 insertions(+), 15 deletions(-)

New commits:
commit c8470364bdbc142661ec89eff8e3a7e05e7695b2
Author: Tomaž Vajngerl 
AuthorDate: Thu Jun 4 18:26:58 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 18:26:58 2020 +0200

sd: support match case, match whole word for PDF search

THis adds support for match case and match whole word to the
VectorGraphicSearch + tests.

It uses the new options in PDF seearch in Draw/Impress.

Change-Id: I20a6382c22bf01a5a021c8bae1ff78861419c0ef

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index c9faaa51f1c9..4601a1f5ac1d 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -25,6 +25,28 @@ enum class SearchStartPosition
 End
 };
 
+struct VCL_DLLPUBLIC VectorGraphicSearchOptions final
+{
+SearchStartPosition meStartPosition;
+bool mbMatchCase;
+bool mbMatchWholeWord;
+
+VectorGraphicSearchOptions()
+: meStartPosition(SearchStartPosition::Begin)
+, mbMatchCase(false)
+, mbMatchWholeWord(false)
+{
+}
+
+VectorGraphicSearchOptions(SearchStartPosition eStartPosition, bool 
bMatchCase,
+   bool bMatchWholeWord)
+: meStartPosition(eStartPosition)
+, mbMatchCase(bMatchCase)
+, mbMatchWholeWord(bMatchWholeWord)
+{
+}
+};
+
 class VCL_DLLPUBLIC VectorGraphicSearch final
 {
 private:
@@ -38,7 +60,7 @@ public:
 VectorGraphicSearch(Graphic const& rGraphic);
 ~VectorGraphicSearch();
 bool search(OUString const& rSearchString,
-SearchStartPosition eStartPosition = 
SearchStartPosition::Begin);
+VectorGraphicSearchOptions const& rOptions = 
VectorGraphicSearchOptions());
 basegfx::B2DSize pageSize();
 bool next();
 bool previous();
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index f8cec9464896..9b777d3a1dad 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -829,8 +829,12 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 OUString const & rString = mpSearchItem->GetSearchString();
 bool bBackwards = mpSearchItem->GetBackward();
 
-SearchStartPosition eSearchStartPosition = bBackwards ? 
SearchStartPosition::End : SearchStartPosition::Begin;
-bool bResult = mpImpl->mpVectorGraphicSearch->search(rString, 
eSearchStartPosition);
+VectorGraphicSearchOptions aOptions;
+aOptions.meStartPosition = bBackwards ? 
SearchStartPosition::End : SearchStartPosition::Begin;
+aOptions.mbMatchCase = mpSearchItem->GetExact();
+aOptions.mbMatchWholeWord = mpSearchItem->GetWordOnly();
+
+bool bResult = mpImpl->mpVectorGraphicSearch->search(rString, 
aOptions);
 
 if (bResult)
 {
@@ -1242,11 +1246,15 @@ void SdOutliner::ProvideNextTextObject()
 auto* pGraphicObject = static_cast(mpObj);
 OUString const & rString = mpSearchItem->GetSearchString();
 bool bBackwards = mpSearchItem->GetBackward();
-SearchStartPosition eSearchStartPosition = bBackwards ? 
SearchStartPosition::End : SearchStartPosition::Begin;
+
+VectorGraphicSearchOptions aOptions;
+aOptions.meStartPosition = bBackwards ? 
SearchStartPosition::End : SearchStartPosition::Begin;
+aOptions.mbMatchCase = mpSearchItem->GetExact();
+aOptions.mbMatchWholeWord = mpSearchItem->GetWordOnly();
 
 mpImpl->mpVectorGraphicSearch = 
std::make_unique(pGraphicObject->GetGraphic());
 
-bool bResult = 
mpImpl->mpVectorGraphicSearch->search(rString, eSearchStartPosition);
+bool bResult = 
mpImpl->mpVectorGraphicSearch->search(rString, aOptions);
 if (bResult)
 {
 if (bBackwards)
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 00febce16e71..0659e4e62dcf 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -32,11 +32,15 @@ class VectorGraphicSearchTest : public 
test::BootstrapFixtureBase
 void test();
 void testNextPrevious();
 void testSearchStringChange();
+void testSearchMatchWholeWord();
+void testSearchMatchCase();
 
 CPPUNIT_TEST_SUITE(VectorGraphicSearchTest);
 CPPUNIT_TEST(test);
 CPPUNIT_TEST(testNextPrevious);
 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/qa vcl/source

2020-05-31 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit f5f846460272653a9ea3d3b16300cb65c58d21d1
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 14:03:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun May 31 21:58:31 2020 +0200

vcl: VectorGraphicSearch - support changing search string

Initial implementation only allowed to set the search string once.
This change allows to change the search string and still retain
the last position of a found string, so the search continues
from this positon forward or backwards. This mimicks how we search
through the GUI (which is the main use for this functionallity
anyway).

Change-Id: I8a7aee4b6b6525f483f105feaa1f83c4a0ad9594

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 2dc8cca3b76a..c9faaa51f1c9 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -32,8 +32,7 @@ private:
 std::unique_ptr mpImplementation;
 Graphic maGraphic;
 
-bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString,
-   SearchStartPosition eStartPosition);
+bool searchPDF(std::shared_ptr const& rData);
 
 public:
 VectorGraphicSearch(Graphic const& rGraphic);
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 5f65b4ba7e3d..8dbdcac0e2e1 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -27,10 +27,12 @@ class VectorGraphicSearchTest : public 
test::BootstrapFixtureBase
 
 void test();
 void testNextPrevious();
+void testSearchStringChange();
 
 CPPUNIT_TEST_SUITE(VectorGraphicSearchTest);
 CPPUNIT_TEST(test);
 CPPUNIT_TEST(testNextPrevious);
+CPPUNIT_TEST(testSearchStringChange);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -160,6 +162,37 @@ void VectorGraphicSearchTest::testNextPrevious()
 }
 }
 
+void VectorGraphicSearchTest::testSearchStringChange()
+{
+OUString aURL = getFullUrl("Pangram.pdf");
+SvFileStream aStream(aURL, StreamMode::READ);
+GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+aGraphic.makeAvailable();
+
+VectorGraphicSearch aSearch(aGraphic);
+
+// Set search to "lazy"
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+// Change search to "fox"
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("fox"));
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(822, aSearch.index());
+
+// Change search to "Quick"
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("Quick"));
+CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(784, aSearch.index());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VectorGraphicSearchTest);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index db17df2539ec..07e4b19afc08 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -56,18 +56,18 @@ private:
 
 public:
 sal_Int32 mnPageIndex;
+int mnCurrentIndex;
 OUString maSearchString;
 SearchStartPosition meStartPosition;
 
-SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex, OUString 
const& rSearchString,
-  SearchStartPosition eStartPosition)
+SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex)
 : mpPdfDocument(pPdfDocument)
 , mpPage(nullptr)
 , mpTextPage(nullptr)
 , mpSearchHandle(nullptr)
 , mnPageIndex(nPageIndex)
-, maSearchString(rSearchString)
-, meStartPosition(eStartPosition)
+, mnCurrentIndex(-1)
+, meStartPosition(SearchStartPosition::Begin)
 {
 }
 
@@ -96,13 +96,30 @@ public:
 return aSize;
 }
 
-bool initialize()
+bool initialize(OUString const& rSearchString, SearchStartPosition 
eStartPosition)
 {
 if (!mpPdfDocument)
 return false;
+
+if (rSearchString == maSearchString)
+return true;
+
+if (mpSearchHandle)
+FPDFText_FindClose(mpSearchHandle);
+
+if (mpTextPage)
+FPDFText_ClosePage(mpTextPage);
+
+if (mpPage)
+FPDF_ClosePage(mpPage);
+
+maSearchString = rSearchString;
+meStartPosition = eStartPosition;
+
 mpPage = FPDF_LoadPage(mpPdfDocument, mnPageIndex);
 if (!mpPage)
 return false;
+
 mpTextPage = FPDFText_LoadPage(mpPage);
 if (!mpTextPage)
 return false;
@@ -112,6 +129,9 @@ public:
 // Index where to 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl svx/source

2020-05-31 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/vectorgraphicdata.hxx |2 +-
 svx/source/svdraw/svdedtv2.cxx|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit c4226858298f898843efa568305c2e4d0a619be2
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 20:25:11 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun May 31 20:25:11 2020 +0200

tdf#133547 Fix breaking of PDF graphic objects

ImpSdrPdfImport did not handle -1 as the page number correctly.
When the page number is -1 it means it was never explicitly set
and should be treated as page with index 0 most of the time. So
instead of allowing -1 as the page index, return it as 0 already
in Graphic (VectorGraphicData).

Change-Id: I3813f3ceeb5e41cb06fc40d67297d2439d7f3407

diff --git a/include/vcl/vectorgraphicdata.hxx 
b/include/vcl/vectorgraphicdata.hxx
index 62e7617cdb56..5ee8a54577a6 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -110,7 +110,7 @@ public:
 const BitmapEx& getReplacement() const;
 BitmapChecksum GetChecksum() const;
 
-sal_Int32 getPageIndex() const { return mnPageIndex; }
+sal_Int32 getPageIndex() const { return std::max(0, mnPageIndex); }
 
 bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
 };
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 661dd0779e18..de8c521b3119 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -2104,7 +2104,7 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo 
*pProgrInfo)
 #if HAVE_FEATURE_PDFIUM
 aLogicRect = pGraf->GetLogicRect();
 ImpSdrPdfImport aFilter(*mpModel, pObj->GetLayer(), 
aLogicRect, aGraphic);
-if (pGraf->getEmbeddedPageNumber() < aFilter.GetPageCount())
+if (aGraphic.getPageNumber() < aFilter.GetPageCount())
 {
 nInsCnt = aFilter.DoImport(*pOL, nInsPos, 
aGraphic.getPageNumber(), pProgrInfo);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/qa vcl/source

2020-05-31 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|3 -
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   33 +
 vcl/source/graphic/VectorGraphicSearch.cxx |   72 +++--
 3 files changed, 82 insertions(+), 26 deletions(-)

New commits:
commit 7ab1794e5eb2f6d5a4f35affc4ffd6e08a3eb089
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 14:03:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun May 31 14:03:36 2020 +0200

vcl: VectorGraphicSearch - support changing search string

Initial implementation only allowed to set the search string once.
This change allows to change the search string and still retain
the last position of a found string, so the search continues
from this positon forward or backwards. This mimicks how we search
through the GUI (which is the main use for this functionallity
anyway).

Change-Id: I8a7aee4b6b6525f483f105feaa1f83c4a0ad9594

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 2dc8cca3b76a..c9faaa51f1c9 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -32,8 +32,7 @@ private:
 std::unique_ptr mpImplementation;
 Graphic maGraphic;
 
-bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString,
-   SearchStartPosition eStartPosition);
+bool searchPDF(std::shared_ptr const& rData);
 
 public:
 VectorGraphicSearch(Graphic const& rGraphic);
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 5f65b4ba7e3d..8dbdcac0e2e1 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -27,10 +27,12 @@ class VectorGraphicSearchTest : public 
test::BootstrapFixtureBase
 
 void test();
 void testNextPrevious();
+void testSearchStringChange();
 
 CPPUNIT_TEST_SUITE(VectorGraphicSearchTest);
 CPPUNIT_TEST(test);
 CPPUNIT_TEST(testNextPrevious);
+CPPUNIT_TEST(testSearchStringChange);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -160,6 +162,37 @@ void VectorGraphicSearchTest::testNextPrevious()
 }
 }
 
+void VectorGraphicSearchTest::testSearchStringChange()
+{
+OUString aURL = getFullUrl("Pangram.pdf");
+SvFileStream aStream(aURL, StreamMode::READ);
+GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+aGraphic.makeAvailable();
+
+VectorGraphicSearch aSearch(aGraphic);
+
+// Set search to "lazy"
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+// Change search to "fox"
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("fox"));
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(822, aSearch.index());
+
+// Change search to "Quick"
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("Quick"));
+CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(784, aSearch.index());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VectorGraphicSearchTest);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index db17df2539ec..95059c00cd7a 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -56,18 +56,18 @@ private:
 
 public:
 sal_Int32 mnPageIndex;
+int mnCurrentIndex;
 OUString maSearchString;
 SearchStartPosition meStartPosition;
 
-SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex, OUString 
const& rSearchString,
-  SearchStartPosition eStartPosition)
+SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex)
 : mpPdfDocument(pPdfDocument)
 , mpPage(nullptr)
 , mpTextPage(nullptr)
 , mpSearchHandle(nullptr)
 , mnPageIndex(nPageIndex)
-, maSearchString(rSearchString)
-, meStartPosition(eStartPosition)
+, mnCurrentIndex(-1)
+, meStartPosition(SearchStartPosition::Begin)
 {
 }
 
@@ -96,13 +96,27 @@ public:
 return aSize;
 }
 
-bool initialize()
+bool initialize(OUString const& rSearchString, SearchStartPosition 
eStartPosition)
 {
 if (!mpPdfDocument)
 return false;
+
+if (mpSearchHandle)
+FPDFText_FindClose(mpSearchHandle);
+
+if (mpTextPage)
+FPDFText_ClosePage(mpTextPage);
+
+if (mpPage)
+FPDF_ClosePage(mpPage);
+
+maSearchString = rSearchString;
+meStartPosition = eStartPosition;
+
 mpPage = FPDF_LoadPage(mpPdfDocument, mnPageIndex);
 if (!mpPage)
 return false;
+
 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/Library_vcl.mk vcl/source

2020-05-26 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/GraphicAttributes.hxx |   32 +++-
 vcl/Library_vcl.mk|1 
 vcl/source/graphic/grfattr.cxx|   60 --
 3 files changed, 30 insertions(+), 63 deletions(-)

New commits:
commit bfaaac456e539efe5c73c3e3e310bb022da1bd84
Author: Tomaž Vajngerl 
AuthorDate: Tue May 26 15:57:38 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue May 26 15:57:38 2020 +0200

GraphicAttributes: put const. and op. '=' into the header file

Change-Id: I1bc38f89457c3593673b445e7571a4fd82d5960b

diff --git a/include/vcl/GraphicAttributes.hxx 
b/include/vcl/GraphicAttributes.hxx
index 90364e408fee..ad2093875f72 100644
--- a/include/vcl/GraphicAttributes.hxx
+++ b/include/vcl/GraphicAttributes.hxx
@@ -53,9 +53,37 @@ private:
 GraphicDrawMode meDrawMode;
 
 public:
-GraphicAttr();
+GraphicAttr()
+: mfGamma(1.0)
+, mnMirrFlags(basegfx::MirrorDirectionFlags::NONE)
+, mnLeftCrop(0)
+, mnTopCrop(0)
+, mnRightCrop(0)
+, mnBottomCrop(0)
+, mnRotate10(0)
+, mnContPercent(0)
+, mnLumPercent(0)
+, mnRPercent(0)
+, mnGPercent(0)
+, mnBPercent(0)
+, mbInvert(false)
+, mcTransparency(0)
+, meDrawMode(GraphicDrawMode::Standard)
+{
+}
+
+bool operator==(const GraphicAttr& rAttr) const
+{
+return mfGamma == rAttr.mfGamma && mnMirrFlags == rAttr.mnMirrFlags
+   && mnLeftCrop == rAttr.mnLeftCrop && mnTopCrop == 
rAttr.mnTopCrop
+   && mnRightCrop == rAttr.mnRightCrop && mnBottomCrop == 
rAttr.mnBottomCrop
+   && mnRotate10 == rAttr.mnRotate10 && mnContPercent == 
rAttr.mnContPercent
+   && mnLumPercent == rAttr.mnLumPercent && mnRPercent == 
rAttr.mnRPercent
+   && mnGPercent == rAttr.mnGPercent && mnBPercent == 
rAttr.mnBPercent
+   && mbInvert == rAttr.mbInvert && mcTransparency == 
rAttr.mcTransparency
+   && meDrawMode == rAttr.meDrawMode;
+}
 
-bool operator==(const GraphicAttr& rAttr) const;
 bool operator!=(const GraphicAttr& rAttr) const { return !(*this == 
rAttr); }
 
 void SetDrawMode(GraphicDrawMode eDrawMode) { meDrawMode = eDrawMode; }
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 873bd41224b2..3147e6b1174f 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -323,7 +323,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/graphic/GraphicObject \
 vcl/source/graphic/GraphicObject2 \
 vcl/source/graphic/GraphicReader \
-vcl/source/graphic/grfattr \
 vcl/source/graphic/Manager \
 vcl/source/graphic/UnoGraphic \
 vcl/source/graphic/UnoGraphicDescriptor \
diff --git a/vcl/source/graphic/grfattr.cxx b/vcl/source/graphic/grfattr.cxx
deleted file mode 100644
index 36e8605b77de..
--- a/vcl/source/graphic/grfattr.cxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include 
-
-GraphicAttr::GraphicAttr() :
-mfGamma ( 1.0 ),
-mnMirrFlags ( basegfx::MirrorDirectionFlags::NONE ),
-mnLeftCrop  ( 0 ),
-mnTopCrop   ( 0 ),
-mnRightCrop ( 0 ),
-mnBottomCrop( 0 ),
-mnRotate10  ( 0 ),
-mnContPercent   ( 0 ),
-mnLumPercent( 0 ),
-mnRPercent  ( 0 ),
-mnGPercent  ( 0 ),
-mnBPercent  ( 0 ),
-mbInvert( false ),
-mcTransparency  ( 0 ),
-meDrawMode  ( GraphicDrawMode::Standard )
-{
-}
-
-bool GraphicAttr::operator==( const GraphicAttr& rAttr ) const
-{
-return( ( mfGamma == rAttr.mfGamma ) &&
-( mnMirrFlags == rAttr.mnMirrFlags ) &&
-( mnLeftCrop == rAttr.mnLeftCrop ) &&
-( mnTopCrop == rAttr.mnTopCrop ) &&
-( mnRightCrop == rAttr.mnRightCrop ) &&
-( mnBottomCrop == rAttr.mnBottomCrop ) &&
-( mnRotate10 == rAttr.mnRotate10 ) &&
-( mnContPercent == rAttr.mnContPercent ) &&
-( mnLumPercent == rAttr.mnLumPercent ) &&
-( mnRPercent 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl

2020-05-25 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/GraphicObject.hxx |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

New commits:
commit 81a76f40282857a311e31e5c6029e20927266aa2
Author: Tomaž Vajngerl 
AuthorDate: Mon May 25 20:46:38 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon May 25 20:46:38 2020 +0200

vcl: convert to use "pragma once" in GraphicObject.hxx

Change-Id: I6fd1897574d831ef153adc0d385c6484f6c17d7a

diff --git a/include/vcl/GraphicObject.hxx b/include/vcl/GraphicObject.hxx
index 5a4053fa6569..92c01274a453 100644
--- a/include/vcl/GraphicObject.hxx
+++ b/include/vcl/GraphicObject.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_GRAPHICOBJECT_HXX
-#define INCLUDED_VCL_GRAPHICOBJECT_HXX
+#pragma once
 
 #include 
 #include 
@@ -396,6 +395,4 @@ VCL_DLLPUBLIC void 
SearchForGraphics(css::uno::Reference c
 }
 } // end namespace vcl::graphic
 
-#endif // INCLUDED_VCL_GRAPHICOBJECT_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/qa vcl/source

2020-05-16 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|3 +
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   23 +
 vcl/source/graphic/VectorGraphicSearch.cxx |   49 -
 3 files changed, 74 insertions(+), 1 deletion(-)

New commits:
commit 423cf93f347528e11a538b927e7587ab06e30e5b
Author: Tomaž Vajngerl 
AuthorDate: Sat May 16 19:45:41 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat May 16 19:45:41 2020 +0200

vcl: VectorGraphicSearch - add search result selection rectangles

Change-Id: Ia0c5610f600719bcfb5de503f3876fc896cb630a

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 6c2589db1d01..41c7745d0cf5 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -14,6 +14,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 class SearchContext;
@@ -34,6 +36,7 @@ public:
 bool search(OUString const& rSearchString);
 bool next();
 int index();
+std::vector getTextRectangles();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 0ed21ccf9e26..112748d23bbe 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -9,6 +9,7 @@
 
 #include 
 #include 
+
 #include 
 #include 
 
@@ -43,6 +44,28 @@ void VectorGraphicSearchTest::test()
 CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
 CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
 CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+auto aRectangles = aSearch.getTextRectangles();
+CPPUNIT_ASSERT_EQUAL(size_t(4), aRectangles.size());
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(229.00, aRectangles[0].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(231.85, aRectangles[0].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(724.10, aRectangles[0].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(732.42, aRectangles[0].getMaxY(), 1E-2);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(232.47, aRectangles[1].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(237.22, aRectangles[1].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(723.99, aRectangles[1].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(729.72, aRectangles[1].getMaxY(), 1E-2);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(237.68, aRectangles[2].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(242.35, aRectangles[2].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(724.09, aRectangles[2].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(729.60, aRectangles[2].getMaxY(), 1E-2);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(242.81, aRectangles[3].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(248.61, aRectangles[3].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(721.51, aRectangles[3].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(729.60, aRectangles[3].getMaxY(), 1E-2);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(VectorGraphicSearchTest);
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index 34ac0abd6654..8e90145cbecb 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -8,9 +8,10 @@
  *
  */
 
-#include 
 #include 
 
+#include 
+
 #include 
 #include 
 
@@ -93,6 +94,44 @@ public:
 return FPDFText_GetSchResultIndex(mpSearchHandle);
 return -1;
 }
+
+int size()
+{
+if (mpSearchHandle)
+return FPDFText_GetSchCount(mpSearchHandle);
+return -1;
+}
+
+std::vector getTextRectangles()
+{
+std::vector aRectangles;
+
+if (!mpTextPage || !mpSearchHandle)
+return aRectangles;
+
+int nIndex = index();
+if (nIndex < 0)
+return aRectangles;
+
+int nSize = size();
+if (nSize <= 0)
+return aRectangles;
+
+for (int nCount = 0; nCount < nSize; nCount++)
+{
+double left = 0.0;
+double right = 0.0;
+double bottom = 0.0;
+double top = 0.0;
+
+if (FPDFText_GetCharBox(mpTextPage, nIndex + nCount, , 
, , ))
+{
+aRectangles.emplace_back(left, bottom, right, top);
+}
+}
+
+return aRectangles;
+}
 };
 
 VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
@@ -182,4 +221,12 @@ int VectorGraphicSearch::index()
 return -1;
 }
 
+std::vector VectorGraphicSearch::getTextRectangles()
+{
+if (mpSearchContext)
+return mpSearchContext->getTextRectangles();
+
+return std::vector();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/source

2020-05-15 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|6 ++---
 vcl/source/graphic/VectorGraphicSearch.cxx |   33 +
 2 files changed, 28 insertions(+), 11 deletions(-)

New commits:
commit 78a8e2c75b8c370b5c1b9f41de5df02174a47e23
Author: Tomaž Vajngerl 
AuthorDate: Fri May 15 12:20:42 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Fri May 15 12:20:42 2020 +0200

vcl: Add internal "Implementation" class for VectorGraphicSearch

We need to hide includes (needed for members) of PDFium inside
from the outside, so not everyone using the VectorGraphicSearch
needs to depend on PDFium too.

Change-Id: I95e46c714758b130594d78a4618af7350e29a075

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 3411d0a931e6..6c2589db1d01 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -14,8 +14,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 
 class SearchContext;
@@ -23,9 +21,11 @@ class SearchContext;
 class VCL_DLLPUBLIC VectorGraphicSearch final
 {
 private:
+class Implementation;
+std::unique_ptr mpImplementation;
 Graphic maGraphic;
-FPDF_DOCUMENT mpPdfDocument;
 std::unique_ptr mpSearchContext;
+
 bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString);
 
 public:
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index 864c65f2dda2..34ac0abd6654 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -11,8 +11,26 @@
 #include 
 #include 
 
+#include 
 #include 
 
+class VectorGraphicSearch::Implementation
+{
+public:
+FPDF_DOCUMENT mpPdfDocument;
+
+Implementation()
+: mpPdfDocument(nullptr)
+{
+}
+
+~Implementation()
+{
+if (mpPdfDocument)
+FPDF_CloseDocument(mpPdfDocument);
+}
+};
+
 class SearchContext
 {
 public:
@@ -78,8 +96,8 @@ public:
 };
 
 VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
-: maGraphic(rGraphic)
-, mpPdfDocument(nullptr)
+: mpImplementation(std::make_unique())
+, maGraphic(rGraphic)
 {
 FPDF_LIBRARY_CONFIG aConfig;
 aConfig.version = 2;
@@ -92,9 +110,7 @@ VectorGraphicSearch::VectorGraphicSearch(Graphic const& 
rGraphic)
 VectorGraphicSearch::~VectorGraphicSearch()
 {
 mpSearchContext.reset();
-
-if (mpPdfDocument)
-FPDF_CloseDocument(mpPdfDocument);
+mpImplementation.reset();
 FPDF_DestroyLibrary();
 }
 
@@ -115,11 +131,11 @@ bool 
VectorGraphicSearch::searchPDF(std::shared_ptr const& rD
 if (rSearchString.isEmpty())
 return false;
 
-mpPdfDocument
+mpImplementation->mpPdfDocument
 = 
FPDF_LoadMemDocument(rData->getVectorGraphicDataArray().getConstArray(),
rData->getVectorGraphicDataArrayLength(), 
/*password=*/nullptr);
 
-if (!mpPdfDocument)
+if (!mpImplementation->mpPdfDocument)
 {
 //TODO: Handle failure to load.
 switch (FPDF_GetLastError())
@@ -146,7 +162,8 @@ bool 
VectorGraphicSearch::searchPDF(std::shared_ptr const& rD
 
 sal_Int32 nPageIndex = std::max(rData->getPageIndex(), 0);
 
-mpSearchContext.reset(new SearchContext(mpPdfDocument, nPageIndex, 
rSearchString));
+mpSearchContext.reset(
+new SearchContext(mpImplementation->mpPdfDocument, nPageIndex, 
rSearchString));
 
 return mpSearchContext->initialize();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/CppunitTest_vcl_graphic_test.mk vcl/Library_vcl.mk vcl/qa vcl/source

2020-05-07 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|   39 ++
 vcl/CppunitTest_vcl_graphic_test.mk|7 -
 vcl/Library_vcl.mk |1 
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   50 
 vcl/qa/cppunit/data/Pangram.pdf|binary
 vcl/source/graphic/VectorGraphicSearch.cxx |  168 +
 6 files changed, 262 insertions(+), 3 deletions(-)

New commits:
commit 09e15db17c05a4631ee876964a31d903cf07904f
Author: Tomaž Vajngerl 
AuthorDate: Thu May 7 22:01:22 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu May 7 22:01:22 2020 +0200

vcl: VectorGraphicSearch - for searching text inside PDF

Change-Id: Iee940a3927330c8739774ff3c1af15998f89193b

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
new file mode 100644
index ..3411d0a931e6
--- /dev/null
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -0,0 +1,39 @@
+/* -*- 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/.
+ *
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+class SearchContext;
+
+class VCL_DLLPUBLIC VectorGraphicSearch final
+{
+private:
+Graphic maGraphic;
+FPDF_DOCUMENT mpPdfDocument;
+std::unique_ptr mpSearchContext;
+bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString);
+
+public:
+VectorGraphicSearch(Graphic const& rGraphic);
+~VectorGraphicSearch();
+bool search(OUString const& rSearchString);
+bool next();
+int index();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/CppunitTest_vcl_graphic_test.mk 
b/vcl/CppunitTest_vcl_graphic_test.mk
index 7b042f84d7da..ea49eacdb781 100644
--- a/vcl/CppunitTest_vcl_graphic_test.mk
+++ b/vcl/CppunitTest_vcl_graphic_test.mk
@@ -14,11 +14,12 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,vcl_graphic_test, \
 vcl/qa/cppunit/GraphicDescriptorTest \
 vcl/qa/cppunit/GraphicFormatDetectorTest \
 vcl/qa/cppunit/GraphicNativeMetadataTest \
+vcl/qa/cppunit/VectorGraphicSearchTest \
 ))
 
-$(eval $(call gb_CppunitTest_use_externals,vcl_graphic_test,\
-   boost_headers \
-   glm_headers \
+$(eval $(call gb_CppunitTest_use_externals,vcl_graphic_test, \
+boost_headers \
+$(if $(filter PDFIUM,$(BUILD_TYPE)),pdfium) \
 ))
 
 $(eval $(call gb_CppunitTest_set_include,vcl_graphic_test,\
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 3a56406b9adf..12cb40226c82 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -329,6 +329,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/graphic/UnoGraphicObject \
 vcl/source/graphic/UnoGraphicProvider \
 vcl/source/graphic/UnoGraphicTransformer \
+vcl/source/graphic/VectorGraphicSearch \
 vcl/source/bitmap/bitmap \
 vcl/source/bitmap/bitmapfilter \
 vcl/source/bitmap/BitmapAlphaClampFilter \
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
new file mode 100644
index ..0ed21ccf9e26
--- /dev/null
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -0,0 +1,50 @@
+/* -*- 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 
+#include 
+#include 
+
+class VectorGraphicSearchTest : public test::BootstrapFixtureBase
+{
+OUString getFullUrl(const OUString& sFileName)
+{
+return m_directories.getURLFromSrc("/vcl/qa/cppunit/data/") + 
sFileName;
+}
+
+void test();
+
+CPPUNIT_TEST_SUITE(VectorGraphicSearchTest);
+CPPUNIT_TEST(test);
+CPPUNIT_TEST_SUITE_END();
+};
+
+void VectorGraphicSearchTest::test()
+{
+OUString aURL = getFullUrl("Pangram.pdf");
+SvFileStream aStream(aURL, StreamMode::READ);
+GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+aGraphic.makeAvailable();
+
+VectorGraphicSearch aSearch(aGraphic);
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(VectorGraphicSearchTest);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/data/Pangram.pdf b/vcl/qa/cppunit/data/Pangram.pdf
new file mode 100644
index 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl

2020-04-23 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/graph.hxx |   12 +---
 1 file changed, 1 insertion(+), 11 deletions(-)

New commits:
commit c21010b8ed9a4d33189227276b3885fc91a3a957
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 23 21:59:32 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 23 22:00:11 2020 +0200

Graphic: cleanup private, public declarations, remove friend

Friend GraphicObject doesn't seem to be needed anymore.

Change-Id: I629ddaabf0c1802e986af42b457cd6322d2fd04d

diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index b304cfb7ac97..17fdd6336e2d 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -83,15 +83,12 @@ class Image;
 class VCL_DLLPUBLIC Graphic
 {
 private:
-
 std::shared_ptr mxImpGraphic;
+SAL_DLLPRIVATE void ImplTestRefCount();
 
 public:
-
-SAL_DLLPRIVATE void ImplTestRefCount();
 SAL_DLLPRIVATE ImpGraphic* ImplGetImpGraphic() const { return 
mxImpGraphic.get(); }
 
-public:
 Graphic();
 Graphic( const GraphicExternalLink& rGraphicLink );
 Graphic( const Graphic& rGraphic );
@@ -180,16 +177,11 @@ public:
 
 OString getUniqueID() const;
 
-public:
-
 std::shared_ptr& GetReaderContext();
 voidSetReaderContext( const 
std::shared_ptr  );
 voidSetDummyContext(bool value);
 boolIsDummyContext() const;
-private:
-friend class GraphicObject;
 
-public:
 voidSetGfxLink(const std::shared_ptr& rGfxLink);
 std::shared_ptr GetSharedGfxLink() const;
 GfxLink GetGfxLink() const;
@@ -200,8 +192,6 @@ public:
 friend VCL_DLLPUBLIC void WriteGraphic(SvStream& rOStream, const Graphic& 
rGraphic);
 friend VCL_DLLPUBLIC void ReadGraphic(SvStream& rIStream, Graphic& 
rGraphic);
 
-public:
-
 const std::shared_ptr& getVectorGraphicData() const;
 
 /// Get the page number of the multi-page source this Graphic is rendered 
from.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/CppunitTest_vcl_graphic_test.mk vcl/qa vcl/source

2020-04-23 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/GraphicNativeMetadata.hxx|4 +
 vcl/CppunitTest_vcl_graphic_test.mk  |1 
 vcl/qa/cppunit/GraphicNativeMetadataTest.cxx |  101 +++
 vcl/qa/cppunit/data/Exif1.jpg|binary
 vcl/qa/cppunit/data/Exif1_090CW.jpg  |binary
 vcl/qa/cppunit/data/Exif1_180.jpg|binary
 vcl/qa/cppunit/data/Exif1_270CW.jpg  |binary
 vcl/source/filter/GraphicNativeMetadata.cxx  |   12 ++-
 8 files changed, 114 insertions(+), 4 deletions(-)

New commits:
commit a5ff67f7fb286485e49c04b302cef3400cadcd6c
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 23 16:22:26 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Apr 23 16:34:10 2020 +0200

vcl: add tests for GraphicNativeMetadata

Test the rotation in JPEG metadata is what we expect.

Change-Id: I5ee2d646a5257d5695c51f37fb6fe795dcb9af50

diff --git a/include/vcl/GraphicNativeMetadata.hxx 
b/include/vcl/GraphicNativeMetadata.hxx
index 318fb724bf25..3dbd7ff8a7d2 100644
--- a/include/vcl/GraphicNativeMetadata.hxx
+++ b/include/vcl/GraphicNativeMetadata.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include 
+#include 
 
 class VCL_DLLPUBLIC GraphicNativeMetadata final
 {
@@ -30,6 +31,9 @@ public:
 ~GraphicNativeMetadata();
 
 bool read(Graphic const& rGraphic);
+bool read(SvStream& rStream);
+
+// counter-clock-wise rotation in permille
 sal_uInt16 getRotation() const { return mRotation; }
 };
 
diff --git a/vcl/CppunitTest_vcl_graphic_test.mk 
b/vcl/CppunitTest_vcl_graphic_test.mk
index fd5c7aeb039b..a1649124133f 100644
--- a/vcl/CppunitTest_vcl_graphic_test.mk
+++ b/vcl/CppunitTest_vcl_graphic_test.mk
@@ -13,6 +13,7 @@ $(eval $(call 
gb_CppunitTest_add_exception_objects,vcl_graphic_test, \
 vcl/qa/cppunit/GraphicTest \
 vcl/qa/cppunit/GraphicDescriptorTest \
 vcl/qa/cppunit/GraphicFormatDetectorTest \
+vcl/qa/cppunit/GraphicNativeMetadataTest \
 ))
 
 $(eval $(call gb_CppunitTest_use_externals,vcl_graphic_test,\
diff --git a/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx 
b/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx
new file mode 100644
index ..4fde27f53354
--- /dev/null
+++ b/vcl/qa/cppunit/GraphicNativeMetadataTest.cxx
@@ -0,0 +1,101 @@
+/* -*- 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 
+
+using namespace css;
+
+namespace
+{
+class GraphicNativeMetadataTest : public test::BootstrapFixtureBase
+{
+OUString getFullUrl(const OUString& sFileName)
+{
+return m_directories.getURLFromSrc("/vcl/qa/cppunit/data/") + 
sFileName;
+}
+
+void testReadFromGraphic();
+void testExifRotationJpeg();
+
+CPPUNIT_TEST_SUITE(GraphicNativeMetadataTest);
+CPPUNIT_TEST(testReadFromGraphic);
+CPPUNIT_TEST(testExifRotationJpeg);
+CPPUNIT_TEST_SUITE_END();
+};
+
+void GraphicNativeMetadataTest::testReadFromGraphic()
+{
+SvFileStream aFileStream(getFullUrl("Exif1_180.jpg"), StreamMode::READ);
+GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+
+// don't load the grpahic, but try to get the metadata
+Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aFileStream);
+
+{
+GraphicNativeMetadata aMetadata;
+aMetadata.read(aFileStream);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(1800), aMetadata.getRotation());
+// just the metadata shouldn't make the graphic available
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+}
+
+// now load, and it should still work the same
+{
+aGraphic.makeAvailable();
+CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+GraphicNativeMetadata aMetadata;
+aMetadata.read(aFileStream);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(1800), aMetadata.getRotation());
+}
+}
+
+void GraphicNativeMetadataTest::testExifRotationJpeg()
+{
+{
+// No rotation in metadata
+SvFileStream aFileStream(getFullUrl("Exif1.jpg"), StreamMode::READ);
+GraphicNativeMetadata aMetadata;
+aMetadata.read(aFileStream);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(0), aMetadata.getRotation());
+}
+{
+// Rotation 90 degree clock-wise = 270 degree counter-clock-wise
+SvFileStream aFileStream(getFullUrl("Exif1_090CW.jpg"), 
StreamMode::READ);
+GraphicNativeMetadata aMetadata;
+aMetadata.read(aFileStream);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(2700), aMetadata.getRotation());
+}
+{
+// Rotation 180 degree
+SvFileStream aFileStream(getFullUrl("Exif1_180.jpg"), 
StreamMode::READ);
+GraphicNativeMetadata aMetadata;
+

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - include/vcl vcl/source

2020-04-14 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/GraphicNativeMetadata.hxx  |5 +
 include/vcl/GraphicNativeTransform.hxx |6 ++
 vcl/source/filter/jpeg/Exif.hxx|6 ++
 3 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit 82fbd762d0973c26be747a668f6e7e086a1efb39
Author: Tomaž Vajngerl 
AuthorDate: Tue Apr 14 20:48:56 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Apr 14 20:48:56 2020 +0200

use pragma once

Change-Id: Ia78cc4ee565a5f39835499764b1f2d0a2a72c5ba

diff --git a/include/vcl/GraphicNativeMetadata.hxx 
b/include/vcl/GraphicNativeMetadata.hxx
index b6b162556e76..118efa480df8 100644
--- a/include/vcl/GraphicNativeMetadata.hxx
+++ b/include/vcl/GraphicNativeMetadata.hxx
@@ -17,8 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_GRAPHICNATIVEMETADATA_HXX
-#define INCLUDED_VCL_GRAPHICNATIVEMETADATA_HXX
+#pragma once
 
 #include 
 
@@ -34,6 +33,4 @@ public:
 sal_uInt16 getRotation() const { return mRotation;}
 };
 
-#endif // INCLUDED_VCL_GRAPHICNATIVEMETADATA_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/GraphicNativeTransform.hxx 
b/include/vcl/GraphicNativeTransform.hxx
index c8203377dc55..318327bf5b66 100644
--- a/include/vcl/GraphicNativeTransform.hxx
+++ b/include/vcl/GraphicNativeTransform.hxx
@@ -17,12 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_GRAPHICNATIVETRANSFORM_HXX
-#define INCLUDED_VCL_GRAPHICNATIVETRANSFORM_HXX
+#pragma once
 
 #include 
 #include 
 #include 
+
 class Graphic;
 
 class VCL_DLLPUBLIC GraphicNativeTransform final
@@ -40,6 +40,4 @@ public:
 void rotate(sal_uInt16 aRotation);
 };
 
-#endif // INCLUDED_VCL_GRAPHICNATIVETRANSFORM_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/jpeg/Exif.hxx b/vcl/source/filter/jpeg/Exif.hxx
index 47c34e427810..6052a44842da 100644
--- a/vcl/source/filter/jpeg/Exif.hxx
+++ b/vcl/source/filter/jpeg/Exif.hxx
@@ -17,12 +17,12 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#ifndef INCLUDED_VCL_SOURCE_FILTER_JPEG_EXIF_HXX
-#define INCLUDED_VCL_SOURCE_FILTER_JPEG_EXIF_HXX
+#pragma once
 
 #include 
 
 namespace exif {
+
 enum Orientation {
 TOP_LEFT= 1,
 TOP_RIGHT   = 2,
@@ -80,6 +80,4 @@ public:
 
 };
 
-#endif // INCLUDED_VCL_SOURCE_FILTER_JPEG_EXIF_HXX
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits