[Libreoffice-commits] core.git: sd/qa

2020-06-21 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/SdrPdfImportTest.cxx   |  132 ++
 sd/qa/unit/data/PdfWithAnnotation.pdf |binary
 2 files changed, 132 insertions(+)

New commits:
commit 037463d2617e5d7bbaea6b99f6b8ffd265cb38af
Author: Tomaž Vajngerl 
AuthorDate: Fri Jun 19 12:59:59 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 21 23:09:30 2020 +0200

sd: Test PDF Annotation roundtrip

Change-Id: I2532ecb451362b3b48c8c08b79c010dcad67d5da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96760
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index 9f30ff5000be..4bbb24de4035 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -16,7 +16,11 @@
 
 #include 
 #include 
+#include 
 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -123,6 +127,134 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, 
testImportSimpleText)
 #endif // HAVE_FEATURE_PDFIUM
 }
 
+CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testAnnotationsImportExport)
+{
+#if HAVE_FEATURE_PDFIUM && !defined(_WIN32)
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+unsetenv("LO_IMPORT_USE_PDFIUM");
+});
+
+bool bPDFCompressorResetEnvVar = false;
+if (getenv("VCL_DEBUG_DISABLE_PDFCOMPRESSION") == nullptr)
+{
+bPDFCompressorResetEnvVar = true;
+setenv("VCL_DEBUG_DISABLE_PDFCOMPRESSION", "1", false);
+}
+comphelper::ScopeGuard aPDFCompressorEnvVarGuard([&]() {
+if (bPDFCompressorResetEnvVar)
+unsetenv("VCL_DEBUG_DISABLE_PDFCOMPRESSION");
+});
+
+auto pPdfiumLibrary = vcl::pdf::PDFiumLibrary::get();
+
+mxComponent
+= 
loadFromDesktop(m_directories.getURLFromSrc("sd/qa/unit/data/PdfWithAnnotation.pdf"));
+auto pImpressDocument = 
dynamic_cast(mxComponent.get());
+sd::ViewShell* pViewShell = 
pImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+
+const void* pData = nullptr;
+int nLength = 0;
+
+{
+// Get the first page - there should be only one.
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+// Check the number of annotations
+CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->getAnnotations().size());
+
+// Get the first object - there should be only one.
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+// Check the object is a graphic object
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+// Check the graphic is a vector graphic and that it is PDF
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+
+// Write the PDF
+pData = 
pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
+nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+}
+
+{ // check graphic PDF has annotations
+
+auto pPDFDocument = pPdfiumLibrary->openDocument(pData, nLength);
+auto pPDFPage = pPDFDocument->openPage(0);
+
+CPPUNIT_ASSERT_EQUAL(2, pPDFPage->getAnnotationCount());
+
+auto pPDFAnnotation1 = pPDFPage->getAnnotation(0);
+CPPUNIT_ASSERT_EQUAL(1, pPDFAnnotation1->getSubType()); // Text 
annotation
+
+auto pPDFAnnotation2 = pPDFPage->getAnnotation(1);
+CPPUNIT_ASSERT_EQUAL(16, pPDFAnnotation2->getSubType()); // Pop-up 
annotation
+}
+
+{ // save as PDF and check annotations
+utl::TempFile aTempFile;
+aTempFile.EnableKillingFile();
+
+uno::Reference xStorable(mxComponent, 
uno::UNO_QUERY);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+uno::Sequence aFilterData(
+comphelper::InitPropertySequence({ { "ExportBookmarks", 
uno::Any(true) } }));
+aMediaDescriptor["FilterData"] <<= aFilterData;
+xStorable->storeToURL(aTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+mxComponent->dispose();
+
+SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ);
+SvMemoryStream aMemory;
+aMemory.WriteStream(aFile);
+
+// Check PDF for annotations
+auto pPDFDocument = pPdfiumLibrary->openDocument(aMemory.GetData(), 
aMemory.GetSize());
+

[Libreoffice-commits] core.git: include/vcl sd/source vcl/qa vcl/source

2020-06-21 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/filter/PDFiumLibrary.hxx |6 +++
 include/vcl/pdfread.hxx  |2 +
 sd/source/filter/pdf/sdpdffilter.cxx |1 
 vcl/qa/cppunit/PDFiumLibraryTest.cxx |   25 +++
 vcl/source/filter/ipdf/pdfread.cxx   |   12 +++
 vcl/source/pdf/PDFiumLibrary.cxx |   57 +++
 6 files changed, 102 insertions(+), 1 deletion(-)

New commits:
commit 4e3196ceedc2b79d58bb57dba86f2f0158d32998
Author: Tomaž Vajngerl 
AuthorDate: Thu Jun 18 13:50:15 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 21 21:02:38 2020 +0200

support date and time for PDFium and use it for annotations

PDF annotations have the modification date and time accessible in
the PDF specific format. With PDFium we read the annotation date
and time and convert that to css::utils::DateTime (by converting
to ISO8601 compatible string first).

Add support for modification date and tme for annotations into
ImportPDFUnloaded and when the annotations are inserted into the
document as comments (in Draw document).

Change-Id: I24aacde84b7530365d67ed335b1eefbaee706eca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96759
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index 9deff47e0ab9..2a70c3f89bce 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -29,7 +29,7 @@ namespace vcl::pdf
 constexpr char constDictionaryKeyTitle[] = "T";
 constexpr char constDictionaryKeyContents[] = "Contents";
 constexpr char constDictionaryKeyPopup[] = "Popup";
-
+constexpr char constDictionaryKeyModificationDate[] = "M";
 class PDFiumDocument;
 
 class VCL_DLLPUBLIC PDFium final
@@ -121,6 +121,10 @@ struct PDFiumLibrary final : public 
rtl::StaticWithInit,
 std::shared_ptr operator()() { return std::make_shared(); }
 };
 
+// Tools
+
+VCL_DLLPUBLIC OUString convertPdfDateToISO8601(OUString const& rInput);
+
 } // namespace vcl::pdf
 
 #endif // HAVE_FEATURE_PDFIUM
diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index d79115f40249..f1534c326ee6 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace com::sun::star::uno
 {
@@ -38,6 +39,7 @@ struct PDFGraphicAnnotation
 OUString maText;
 // In HMM
 basegfx::B2DRectangle maRectangle;
+css::util::DateTime maDateTime;
 };
 
 struct PDFGraphicResult
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx 
b/sd/source/filter/pdf/sdpdffilter.cxx
index da989974bc87..9a53dde90cdf 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -91,6 +91,7 @@ bool SdPdfFilter::Import()
   
rPDFAnnotation.maRectangle.getHeight() / 100.00);
 xAnnotation->setPosition(aUnoPosition);
 xAnnotation->setSize(aUnoSize);
+xAnnotation->setDateTime(rPDFAnnotation.maDateTime);
 }
 }
 
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx 
b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index c786b6edc211..61b3981731f6 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -16,6 +16,9 @@
 
 #include 
 #include 
+#include 
+
+#include 
 
 #include 
 #include 
@@ -34,12 +37,14 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
 void testPages();
 void testAnnotationsMadeInEvince();
 void testAnnotationsMadeInAcrobat();
+void testTools();
 
 CPPUNIT_TEST_SUITE(PDFiumLibraryTest);
 CPPUNIT_TEST(testDocument);
 CPPUNIT_TEST(testPages);
 CPPUNIT_TEST(testAnnotationsMadeInEvince);
 CPPUNIT_TEST(testAnnotationsMadeInAcrobat);
+CPPUNIT_TEST(testTools);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -144,6 +149,10 @@ void PDFiumLibraryTest::testAnnotationsMadeInEvince()
 
 CPPUNIT_ASSERT_EQUAL(1, pPage->getAnnotationIndex(pPopupAnnotation));
 CPPUNIT_ASSERT_EQUAL(16, pPopupAnnotation->getSubType());
+
+OUString sDateTimeString
+= 
pAnnotation->getString(vcl::pdf::constDictionaryKeyModificationDate);
+CPPUNIT_ASSERT_EQUAL(OUString("D:20200612201322+02'00"), 
sDateTimeString);
 }
 
 {
@@ -231,6 +240,22 @@ void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
 }
 }
 
+void PDFiumLibraryTest::testTools()
+{
+OUString sConverted = 
vcl::pdf::convertPdfDateToISO8601("D:20200612201322+02'00");
+
+css::util::DateTime aDateTime;
+CPPUNIT_ASSERT(utl::ISO8601parseDateTime(sConverted, aDateTime));
+CPPUNIT_ASSERT_EQUAL(sal_Int16(2020), aDateTime.Year);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(6), aDateTime.Month);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(12), aDateTime.Day);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(20), aDateTime.Hours);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(13), aDateTime.Minutes);
+

[Libreoffice-commits] core.git: include/vcl vcl/CppunitTest_vcl_pdfium_library_test.mk vcl/Module_vcl.mk vcl/qa vcl/source

2020-06-20 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/filter/PDFiumLibrary.hxx   |   59 +++-
 vcl/CppunitTest_vcl_pdfium_library_test.mk |   45 
 vcl/Module_vcl.mk  |1 
 vcl/qa/cppunit/PDFiumLibraryTest.cxx   |  105 +
 vcl/source/pdf/PDFiumLibrary.cxx   |   81 ++
 5 files changed, 288 insertions(+), 3 deletions(-)

New commits:
commit 526b09604399a71c17b15ee80bab48967563bfb6
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 15 13:50:18 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 20 13:10:47 2020 +0200

vcl: wrap PDFium types in c++ classes to ease lifecycle management

Change-Id: Idd33dfe752a22b6628750c06f02e9467a69802bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96753
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index bc7912c17e81..6dde31f2927b 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -14,24 +14,79 @@
 
 #if HAVE_FEATURE_PDFIUM
 
+#include 
+
 #include 
 #include 
-#include 
+#include 
+#include 
+
+#include 
 
 namespace vcl::pdf
 {
+class PDFiumDocument;
+
 class VCL_DLLPUBLIC PDFium final
 {
 private:
 PDFium(const PDFium&) = delete;
 PDFium& operator=(const PDFium&) = delete;
 
+OUString maLastError;
+
 public:
 PDFium();
 ~PDFium();
+
+OUString getLastError() { return maLastError; }
+
+std::unique_ptr openDocument(const void* pData, int nSize);
+};
+
+class VCL_DLLPUBLIC PDFiumPage final
+{
+private:
+FPDF_PAGE mpPage;
+
+private:
+PDFiumPage(const PDFiumPage&) = delete;
+PDFiumPage& operator=(const PDFiumPage&) = delete;
+
+public:
+PDFiumPage(FPDF_PAGE pPage)
+: mpPage(pPage)
+{
+}
+
+~PDFiumPage()
+{
+if (mpPage)
+FPDF_ClosePage(mpPage);
+}
+};
+
+class VCL_DLLPUBLIC PDFiumDocument final
+{
+private:
+FPDF_DOCUMENT mpPdfDocument;
+
+private:
+PDFiumDocument(const PDFiumDocument&) = delete;
+PDFiumDocument& operator=(const PDFiumDocument&) = delete;
+
+public:
+PDFiumDocument(FPDF_DOCUMENT pPdfDocument);
+~PDFiumDocument();
+
+// Page size in points
+basegfx::B2DSize getPageSize(int nIndex);
+int getPageCount();
+
+std::unique_ptr openPage(int nIndex);
 };
 
-struct PDFiumLibrary : public rtl::StaticWithInit, 
PDFiumLibrary>
+struct PDFiumLibrary final : public 
rtl::StaticWithInit, PDFiumLibrary>
 {
 std::shared_ptr operator()() { return std::make_shared(); }
 };
diff --git a/vcl/CppunitTest_vcl_pdfium_library_test.mk 
b/vcl/CppunitTest_vcl_pdfium_library_test.mk
new file mode 100644
index ..0f4a480c8254
--- /dev/null
+++ b/vcl/CppunitTest_vcl_pdfium_library_test.mk
@@ -0,0 +1,45 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,vcl_pdfium_library_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,vcl_pdfium_library_test, \
+vcl/qa/cppunit/PDFiumLibraryTest \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,vcl_pdfium_library_test))
+
+$(eval $(call gb_CppunitTest_use_libraries,vcl_pdfium_library_test, \
+   basegfx \
+   comphelper \
+   cppu \
+   cppuhelper \
+   sal \
+   test \
+   unotest \
+   utl \
+   tl \
+   vcl \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,vcl_pdfium_library_test, \
+   boost_headers \
+   $(if $(filter PDFIUM,$(BUILD_TYPE)),pdfium) \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,vcl_pdfium_library_test))
+
+$(eval $(call gb_CppunitTest_use_ure,vcl_pdfium_library_test))
+$(eval $(call gb_CppunitTest_use_vcl,vcl_pdfium_library_test))
+
+$(eval $(call gb_CppunitTest_use_rdb,vcl_pdfium_library_test,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,vcl_pdfium_library_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index aaa05759d39d..08704e2b6254 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -207,6 +207,7 @@ $(eval $(call gb_Module_add_check_targets,vcl,\
 CppunitTest_vcl_backend_test \
 CppunitTest_vcl_blocklistparser_test \
 CppunitTest_vcl_type_serializer_test \
+CppunitTest_vcl_pdfium_library_test \
 ))
 
 ifeq ($(USING_X11),TRUE)
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx 
b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
new file mode 100644
index ..422325aa9b1d
--- /dev/null
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source 

[Libreoffice-commits] core.git: vcl/source

2020-06-20 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/filter/ipdf/pdfread.cxx |   17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

New commits:
commit 4fa45de60601d34b3a821b35b5aca72f494a7487
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 15 14:01:49 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 20 13:11:02 2020 +0200

vcl: use pdfium c++ wraper classes in ImportPDFUnloaded

Change-Id: I1d0d97f4b981fa62aa38dc5ceaf89d3976bbccbe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96754
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 2a7e7ce04198..10caf1a975f5 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -247,28 +247,27 @@ size_t ImportPDFUnloaded(const OUString& rURL, 
std::vectorGetData(), pGfxLink->GetDataSize(), 
/*password=*/nullptr);
+auto pPdfDocument = pPdfium->openDocument(pGfxLink->GetData(), 
pGfxLink->GetDataSize());
+
 if (!pPdfDocument)
 return 0;
 
-const int nPageCount = FPDF_GetPageCount(pPdfDocument);
+const int nPageCount = pPdfDocument->getPageCount();
 if (nPageCount <= 0)
 return 0;
 
 for (int nPageIndex = 0; nPageIndex < nPageCount; ++nPageIndex)
 {
-double fPageWidth = 0;
-double fPageHeight = 0;
-if (FPDF_GetPageSizeByIndex(pPdfDocument, nPageIndex, , 
) == 0)
+basegfx::B2DSize aPageSize = pPdfDocument->getPageSize(nPageIndex);
+if (aPageSize.getX() <= 0.0 || aPageSize.getY() <= 0.0)
 continue;
 
 // Returned unit is points, convert that to twip
 // 1 pt = 20 twips
 constexpr double pointToTwipconversionRatio = 20;
 
-long nPageWidth = convertTwipToMm100(fPageWidth * 
pointToTwipconversionRatio);
-long nPageHeight = convertTwipToMm100(fPageHeight * 
pointToTwipconversionRatio);
+long nPageWidth = convertTwipToMm100(aPageSize.getX() * 
pointToTwipconversionRatio);
+long nPageHeight = convertTwipToMm100(aPageSize.getY() * 
pointToTwipconversionRatio);
 
 auto aVectorGraphicDataPtr = std::make_shared(
 aPdfDataArray, OUString(), VectorGraphicDataType::Pdf, nPageIndex);
@@ -282,8 +281,6 @@ size_t ImportPDFUnloaded(const OUString& rURL, 
std::vectorhttps://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sd/qa vcl/source

2020-06-22 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/SdrPdfImportTest.cxx   |9 +-
 vcl/source/gdi/pdfwriter_impl.cxx |  128 --
 vcl/source/gdi/pdfwriter_impl.hxx |   14 +++-
 3 files changed, 113 insertions(+), 38 deletions(-)

New commits:
commit 51d529c18dadb05754590a01ce4c1f06f41cf412
Author: Tomaž Vajngerl 
AuthorDate: Sat Jun 20 08:43:58 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 22 08:13:31 2020 +0200

pdf export: support pop-up annotation for notes / comments

This changes pdf export for annotation, so the comments are
exported as "text" annotation with an child "pop-up" annotations.
This seems to be more common what PDF readers do (even when text
annotation only should be enough).

Also changes the test, so that it now works as expected.

Change-Id: I95bc12939f490effe7759dad54e136c44e44a2f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96765
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
index 4bbb24de4035..e8dd60b0a806 100644
--- a/sd/qa/unit/SdrPdfImportTest.cxx
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -231,14 +231,13 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, 
testAnnotationsImportExport)
 auto pPDFPage = pPDFDocument->openPage(0);
 CPPUNIT_ASSERT(pPDFPage);
 
-// TODO: Should be 2 really
-CPPUNIT_ASSERT_EQUAL(1, pPDFPage->getAnnotationCount());
+CPPUNIT_ASSERT_EQUAL(2, pPDFPage->getAnnotationCount());
 
 auto pPDFAnnotation1 = pPDFPage->getAnnotation(0);
 CPPUNIT_ASSERT_EQUAL(1, pPDFAnnotation1->getSubType()); // Text 
annotation
 
-//auto pPDFAnnotation2 = pPDFPage->getAnnotation(1);
-//CPPUNIT_ASSERT_EQUAL(16, pPDFAnnotation2->getSubType()); // Pop-up 
annotation
+auto pPDFAnnotation2 = pPDFPage->getAnnotation(1);
+CPPUNIT_ASSERT_EQUAL(16, pPDFAnnotation2->getSubType()); // Pop-up 
annotation
 
 // Load document again
 mxComponent = loadFromDesktop(aTempFile.GetURL());
@@ -249,7 +248,7 @@ CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, 
testAnnotationsImportExport)
 SdPage* pPage = pNewViewShell->GetActualPage();
 CPPUNIT_ASSERT(pPage);
 
-//CPPUNIT_ASSERT_EQUAL(false, pPage->getAnnotations().empty());
+CPPUNIT_ASSERT(!pPage->getAnnotations().empty());
 }
 
 #endif // HAVE_FEATURE_PDFIUM
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 04fcb70a152f..c7e56544f58a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3418,50 +3418,111 @@ we check in the following sequence:
 return true;
 }
 
+namespace
+{
+
+void appendAnnotationRect(tools::Rectangle const & rRectangle, OStringBuffer & 
aLine)
+{
+aLine.append("/Rect[");
+appendFixedInt(rRectangle.Left(), aLine);
+aLine.append(' ');
+appendFixedInt(rRectangle.Top(), aLine);
+aLine.append(' ');
+appendFixedInt(rRectangle.Right(), aLine);
+aLine.append(' ');
+appendFixedInt(rRectangle.Bottom(), aLine);
+aLine.append("] ");
+}
+
+void appendObjectID(sal_Int32 nObjectID, OStringBuffer & aLine)
+{
+aLine.append(nObjectID);
+aLine.append(" 0 obj\n");
+}
+
+void appendObjectReference(sal_Int32 nObjectID, OStringBuffer & aLine)
+{
+aLine.append(nObjectID);
+aLine.append(" 0 R ");
+}
+
+} // end anonymous namespace
+
+void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer & aLine, PDFNoteEntry 
const & rNote)
+{
+appendObjectID(rNote.m_nObject, aLine);
+
+aLine.append("<>\n");
+aLine.append("endobj\n\n");
+}
+
+void PDFWriterImpl::emitPopupAnnotationLine(OStringBuffer & aLine, 
PDFPopupAnnotation const & rPopUp)
+{
+appendObjectID(rPopUp.m_nObject, aLine);
+aLine.append("<>\n");
+aLine.append("endobj\n\n");
+}
+
 bool PDFWriterImpl::emitNoteAnnotations()
 {
 // emit note annotations
 int nAnnots = m_aNotes.size();
 for( int i = 0; i < nAnnots; i++ )
 {
-const PDFNoteEntry& rNote   = m_aNotes[i];
-if( ! updateObject( rNote.m_nObject ) )
-return false;
+const PDFNoteEntry& rNote = m_aNotes[i];
+const PDFPopupAnnotation& rPopUp = rNote.m_aPopUpAnnotation;
 
-OStringBuffer aLine( 1024 );
-aLine.append( rNote.m_nObject );
-aLine.append( " 0 obj\n" );
-// i59651: key /F set bits Print to 1 rest to 0. We don't set NoZoom NoRotate 
to 1, since it's a 'should'
-// see PDF 8.4.2 and ISO 19005-1:2005 6.5.3
-aLine.append( "<>\nendobj\n\n" );
-CHECK_RETURN( writeBuffer( aLine.getStr(), aLine.getLength() ) );
+{
+
+if (!updateObject(rPopUp.m_nObject))
+return false;
+
+OStringBuffer aLine(1024);
+
+emitPopupAnnotationLine(aLine, rPopUp);
+
+if (!writeBuffer(aLine.getStr(), aLine.getLength()))
+return false;
+}
 }
 

[Libreoffice-commits] core.git: include/vcl sd/source vcl/source

2020-06-22 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/pdfwriter.hxx |2 
 sd/source/ui/unoidl/unomodel.cxx  |   12 +
 vcl/source/gdi/pdfwriter_impl.cxx |   78 --
 3 files changed, 55 insertions(+), 37 deletions(-)

New commits:
commit 235c54e115b66c880d3da0b8018f8ef29d20bc42
Author: Tomaž Vajngerl 
AuthorDate: Sat Jun 20 09:16:11 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 22 08:14:10 2020 +0200

pdf export: add support for modification time/date in annotations

Previously the modification date was written to the annotation
"title" as string, together with the username. This is however
not neccessary as PDF supports the modification date perfectly
fine.

Change-Id: I6f55e4fe63d9c3c81ec557f6cfd3387f011e67c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96766
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx
index 12f4a8e1e805..f635a924507b 100644
--- a/include/vcl/pdfwriter.hxx
+++ b/include/vcl/pdfwriter.hxx
@@ -32,6 +32,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -64,6 +65,7 @@ struct PDFNote
 {
 OUString  Title;  // optional title for the popup 
containing the note
 OUString  Contents;   // contents of the note
+css::util::DateTime maModificationDate;
 };
 
 class VCL_DLLPUBLIC PDFOutputStream
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index fba4d8f68e6f..c72ef5725b89 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1556,24 +1556,18 @@ static void ImplPDFExportComments( const 
uno::Reference< drawing::XDrawPage >& x
 uno::Reference< office::XAnnotationAccess > xAnnotationAccess( xPage, 
uno::UNO_QUERY_THROW );
 uno::Reference< office::XAnnotationEnumeration > 
xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() );
 
-LanguageType eLanguage = 
Application::GetSettings().GetLanguageTag().getLanguageType();
 while( xAnnotationEnumeration->hasMoreElements() )
 {
 uno::Reference< office::XAnnotation > xAnnotation( 
xAnnotationEnumeration->nextElement() );
 
 geometry::RealPoint2D aRealPoint2D( xAnnotation->getPosition() );
 uno::Reference< text::XText > xText( xAnnotation->getTextRange() );
-util::DateTime aDateTime( xAnnotation->getDateTime() );
-
-Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
-::tools::Time aTime( ::tools::Time::EMPTY );
-OUString aStr = SvxDateTimeField::GetFormatted( aDate, aTime,
-SvxDateFormat::B, SvxTimeFormat::AppDefault,
-*(SD_MOD()->GetNumberFormatter()), eLanguage );
 
 vcl::PDFNote aNote;
-aNote.Title = xAnnotation->getAuthor() + ", " + aStr;
+aNote.Title = xAnnotation->getAuthor();
 aNote.Contents = xText->getString();
+aNote.maModificationDate = xAnnotation->getDateTime();
+
 rPDFExtOutDevData.CreateNote( ::tools::Rectangle( Point( 
static_cast< long >( aRealPoint2D.X * 100 ),
 static_cast< long >( aRealPoint2D.Y * 100 ) ), Size( 1000, 
1000 ) ), aNote );
 }
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index c7e56544f58a..c7c6b5cccfbc 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -561,6 +561,49 @@ void PDFWriterImpl::appendNonStrokingColor( const Color& 
rColor, OStringBuffer&
 }
 }
 
+namespace
+{
+
+void appendPdfTimeDate(OStringBuffer & rBuffer,
+sal_Int16 year, sal_uInt16 month, sal_uInt16 day, sal_uInt16 hours, 
sal_uInt16 minutes, sal_uInt16 seconds, sal_uInt32 tzDelta)
+{
+rBuffer.append("D:");
+rBuffer.append(char('0' + ((year / 1000) % 10)));
+rBuffer.append(char('0' + ((year / 100) % 10)));
+rBuffer.append(char('0' + ((year / 10) % 10)));
+rBuffer.append(char('0' + (year % 10)));
+rBuffer.append(char('0' + ((month / 10) % 10)));
+rBuffer.append(char('0' + (month % 10)));
+rBuffer.append(char('0' + ((day / 10) % 10)));
+rBuffer.append(char('0' + (day % 10)));
+rBuffer.append(char('0' + ((hours / 10) % 10)));
+rBuffer.append(char('0' + (hours % 10)));
+rBuffer.append(char('0' + ((minutes / 10) % 10)));
+rBuffer.append(char('0' + (minutes % 10)));
+rBuffer.append(char('0' + ((seconds / 10) % 10)));
+rBuffer.append(char('0' + (seconds % 10)));
+
+if (tzDelta == 0)
+{
+rBuffer.append("Z");
+}
+else
+{
+if (tzDelta > 0 )
+rBuffer.append("+");
+else
+rBuffer.append("-");
+
+rBuffer.append(char('0' + ((tzDelta / 36000) % 10)));
+rBuffer.append(char('0' + ((tzDelta / 3600) % 10)));
+rBuffer.append("'");
+rBuffer.append(char('0' + 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 213 commits - accessibility/source basctl/source basic/qa basic/source chart2/qa chart2/source compilerplugins/clang config_host/con

2020-06-22 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 5096a6a8440f73d35e2901eaa55c43666da57c9a
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 15 19:39:35 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 22 09:38:09 2020 +0200

vcl: add a Bitmap interface to basegfx, BitmapEx implementing it

Change-Id: I758f421d545191883e615f5016e9fc643459556e

diff --git a/include/basegfx/bitmap/Bitmap.hxx 
b/include/basegfx/bitmap/Bitmap.hxx
new file mode 100644
index ..b91b702aa212
--- /dev/null
+++ b/include/basegfx/bitmap/Bitmap.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 
+
+namespace basegfx
+{
+class BASEGFX_DLLPUBLIC IBitmap
+{
+};
+
+} // end of namespace basegfx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 4dac473bb2f5..774afe981d07 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -25,6 +25,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 namespace com::sun::star::rendering {
@@ -40,7 +42,7 @@ enum class TransparentType
 Bitmap
 };
 
-class SAL_WARN_UNUSED VCL_DLLPUBLIC BitmapEx
+class SAL_WARN_UNUSED VCL_DLLPUBLIC BitmapEx : basegfx::IBitmap
 {
 public:
 
commit 89dffdea2521d779c353b7ad13d70160f2c7b291
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 17:00:47 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 22 09:38:09 2020 +0200

drawinglayer: remove textprimitive2d.hxx from clang-format blacklist

Change-Id: I6fa692bb3e4a16400ee2ae847a1f97201493f53a

diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx 
b/include/drawinglayer/primitive2d/textprimitive2d.hxx
index 9aeaa96fc15e..6bbc14aa498a 100644
--- a/include/drawinglayer/primitive2d/textprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx
@@ -33,152 +33,151 @@
 
 namespace drawinglayer::primitive2d
 {
-/** TextSimplePortionPrimitive2D class
+/** TextSimplePortionPrimitive2D class
 
-This is the basic primitive for representing a text portion. It 
contains
-all needed information. If it is not handled by a renderer, its 
decomposition
-will provide the text tools::PolyPolygon outlines as filled 
polygons, correctly
-transformed.
+This is the basic primitive for representing a text portion. It contains
+all needed information. If it is not handled by a renderer, its 
decomposition
+will provide the text tools::PolyPolygon outlines as filled polygons, 
correctly
+transformed.
 
-To get better text quality, it is suggested to handle this 
primitive directly
-in a renderer. In that case, e.g. hintings on the system can be 
supported.
+To get better text quality, it is suggested to handle this primitive 
directly
+in a renderer. In that case, e.g. hintings on the system can be supported.
 
-@param maTextTransform
-The text transformation contains the text start position (always 
baselined)
-as translation, the FontSize as scale (where width relative to 
height defines
-font scaling and width == height means no font scaling) and the 
font rotation
-and shear.
-When shear is used and a renderer does not support it, it may be 
better to use
-the decomposition which will do everything correctly. Same is true 
for mirroring
-which would be expressed as negative scalings.
+@param maTextTransform
+The text transformation contains the text start position (always baselined)
+as translation, the FontSize as scale (where width relative to height 
defines
+font scaling and width == height means no font scaling) and the font 
rotation
+and shear.
+When shear is used and a renderer does not support it, it may be better to 
use
+the decomposition which will do everything correctly. Same is true for 
mirroring
+which would be expressed as negative scalings.
 
-@param rText
-The text to be used. Only a part may be used, but a bigger part of 
the string
-may be necessary for correct layouting (e.g. international)
-
-@param aTextPosition
-The index to the first character to use from rText
-
-@param aTextLength
-The number of characters to use from rText
-
-@param rDXArray
-The distances between the characters. This parameter may be empty, 
in that case
-the renderer is responsible to do something useful. If it is 
given, it has to be of
-the size aTextLength. Its values 

[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source

2020-06-20 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/filter/PDFiumLibrary.hxx  |   30 
 vcl/qa/cppunit/PDFiumLibraryTest.cxx  |  135 ++
 vcl/qa/cppunit/data/PangramAcrobatAnnotations.pdf |binary
 vcl/qa/cppunit/data/PangramWithAnnotations.pdf|binary
 vcl/source/pdf/PDFiumLibrary.cxx  |   73 +++
 5 files changed, 238 insertions(+)

New commits:
commit 7e4dc3b1eabcb1993d4143c046a2f32fedc852ed
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 15 14:44:19 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 20 14:24:33 2020 +0200

vcl: Add annotation reading to PDFiumLibrary c++ wrapper

Also add tests readin annotations from Evince and Acrobat modified
PDF files.

Change-Id: I4565c6b621774fc8485a6c33bc18708664917b73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96756
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
index 6dde31f2927b..9deff47e0ab9 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -19,12 +19,17 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
 
 namespace vcl::pdf
 {
+constexpr char constDictionaryKeyTitle[] = "T";
+constexpr char constDictionaryKeyContents[] = "Contents";
+constexpr char constDictionaryKeyPopup[] = "Popup";
+
 class PDFiumDocument;
 
 class VCL_DLLPUBLIC PDFium final
@@ -44,6 +49,26 @@ public:
 std::unique_ptr openDocument(const void* pData, int nSize);
 };
 
+class VCL_DLLPUBLIC PDFiumAnnotation final
+{
+private:
+FPDF_ANNOTATION mpAnnotation;
+
+PDFiumAnnotation(const PDFiumAnnotation&) = delete;
+PDFiumAnnotation& operator=(const PDFiumAnnotation&) = delete;
+
+public:
+PDFiumAnnotation(FPDF_ANNOTATION pAnnotation);
+~PDFiumAnnotation();
+FPDF_ANNOTATION getPointer() { return mpAnnotation; }
+
+int getSubType();
+basegfx::B2DRectangle getRectangle();
+bool hasKey(OString const& rKey);
+OUString getString(OString const& rKey);
+std::unique_ptr getLinked(OString const& rKey);
+};
+
 class VCL_DLLPUBLIC PDFiumPage final
 {
 private:
@@ -64,6 +89,11 @@ public:
 if (mpPage)
 FPDF_ClosePage(mpPage);
 }
+
+int getAnnotationCount();
+int getAnnotationIndex(std::unique_ptr const& 
rAnnotation);
+
+std::unique_ptr getAnnotation(int nIndex);
 };
 
 class VCL_DLLPUBLIC PDFiumDocument final
diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx 
b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 422325aa9b1d..c786b6edc211 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -32,10 +32,14 @@ class PDFiumLibraryTest : public test::BootstrapFixtureBase
 
 void testDocument();
 void testPages();
+void testAnnotationsMadeInEvince();
+void testAnnotationsMadeInAcrobat();
 
 CPPUNIT_TEST_SUITE(PDFiumLibraryTest);
 CPPUNIT_TEST(testDocument);
 CPPUNIT_TEST(testPages);
+CPPUNIT_TEST(testAnnotationsMadeInEvince);
+CPPUNIT_TEST(testAnnotationsMadeInAcrobat);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -96,6 +100,137 @@ void PDFiumLibraryTest::testPages()
 CPPUNIT_ASSERT(pPage);
 }
 
+void PDFiumLibraryTest::testAnnotationsMadeInEvince()
+{
+OUString aURL = getFullUrl("PangramWithAnnotations.pdf");
+SvFileStream aStream(aURL, StreamMode::READ);
+GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
+Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
+aGraphic.makeAvailable();
+
+auto pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+
+const void* pData = 
pVectorGraphicData->getVectorGraphicDataArray().getConstArray();
+int nLength = pVectorGraphicData->getVectorGraphicDataArrayLength();
+
+auto pPdfium = vcl::pdf::PDFiumLibrary::get();
+auto pDocument = pPdfium->openDocument(pData, nLength);
+CPPUNIT_ASSERT(pDocument);
+
+CPPUNIT_ASSERT_EQUAL(1, pDocument->getPageCount());
+
+auto pPage = pDocument->openPage(0);
+CPPUNIT_ASSERT(pPage);
+
+CPPUNIT_ASSERT_EQUAL(2, pPage->getAnnotationCount());
+
+{
+auto pAnnotation = pPage->getAnnotation(0);
+CPPUNIT_ASSERT(pAnnotation);
+CPPUNIT_ASSERT_EQUAL(1, pAnnotation->getSubType()); // FPDF_ANNOT_TEXT
+
+OUString aPopupString = 
pAnnotation->getString(vcl::pdf::constDictionaryKeyTitle);
+CPPUNIT_ASSERT_EQUAL(OUString("quikee"), aPopupString);
+
+OUString aContentsString = 
pAnnotation->getString(vcl::pdf::constDictionaryKeyContents);
+CPPUNIT_ASSERT_EQUAL(OUString("Annotation test"), aContentsString);
+
+CPPUNIT_ASSERT_EQUAL(true, 
pAnnotation->hasKey(vcl::pdf::constDictionaryKeyPopup));
+auto pPopupAnnotation = 

[Libreoffice-commits] core.git: vcl/inc

2020-06-20 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/pdf/BitmapID.hxx |5 +
 vcl/inc/pdf/Matrix3.hxx  |5 +
 vcl/inc/pdf/ResourceDict.hxx |5 +
 vcl/inc/pdf/XmpMetadata.hxx  |5 +
 4 files changed, 4 insertions(+), 16 deletions(-)

New commits:
commit 3e4d77a6cbdb40e587dedc0045beced5f006da0a
Author: Tomaž Vajngerl 
AuthorDate: Thu Jun 18 13:17:53 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 20 14:24:58 2020 +0200

pragma once for some PDF headers

Change-Id: I4c0b734abba8240b9dd76d82fbf576655a2d1273
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96757
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/pdf/BitmapID.hxx b/vcl/inc/pdf/BitmapID.hxx
index cedc5790338f..afc9aff9fcf6 100644
--- a/vcl/inc/pdf/BitmapID.hxx
+++ b/vcl/inc/pdf/BitmapID.hxx
@@ -8,8 +8,7 @@
  *
  */
 
-#ifndef INCLUDED_VCL_INC_PDF_BITMAPID_HXX
-#define INCLUDED_VCL_INC_PDF_BITMAPID_HXX
+#pragma once
 
 #include 
 #include 
@@ -39,6 +38,4 @@ struct BitmapID
 };
 }
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/pdf/Matrix3.hxx b/vcl/inc/pdf/Matrix3.hxx
index c36332015c13..795b2af4be52 100644
--- a/vcl/inc/pdf/Matrix3.hxx
+++ b/vcl/inc/pdf/Matrix3.hxx
@@ -8,8 +8,7 @@
  *
  */
 
-#ifndef INCLUDED_VCL_INC_PDF_MATRIX3_HXX
-#define INCLUDED_VCL_INC_PDF_MATRIX3_HXX
+#pragma once
 
 #include 
 #include 
@@ -49,6 +48,4 @@ public:
 };
 }
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/pdf/ResourceDict.hxx b/vcl/inc/pdf/ResourceDict.hxx
index 488a821db79c..57ecb8e0f33f 100644
--- a/vcl/inc/pdf/ResourceDict.hxx
+++ b/vcl/inc/pdf/ResourceDict.hxx
@@ -8,8 +8,7 @@
  *
  */
 
-#ifndef INCLUDED_VCL_INC_PDF_RESOURCEDICT_HXX
-#define INCLUDED_VCL_INC_PDF_RESOURCEDICT_HXX
+#pragma once
 
 #include 
 #include 
@@ -37,6 +36,4 @@ struct ResourceDict
 };
 }
 
-#endif
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx
index cc3f8da1a34c..ae3ffadcd847 100644
--- a/vcl/inc/pdf/XmpMetadata.hxx
+++ b/vcl/inc/pdf/XmpMetadata.hxx
@@ -8,8 +8,7 @@
  *
  */
 
-#ifndef INCLUDED_VCL_INC_PDF_XMPMETADATA_HXX
-#define INCLUDED_VCL_INC_PDF_XMPMETADATA_HXX
+#pragma once
 
 #include 
 #include 
@@ -43,6 +42,4 @@ private:
 };
 }
 
-#endif
-
 /* 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: include/vcl sd/source vcl/source

2020-06-20 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/pdfread.hxx  |   18 --
 sd/source/filter/pdf/sdpdffilter.cxx |8 
 vcl/source/filter/ipdf/pdfread.cxx   |2 +-
 3 files changed, 21 insertions(+), 7 deletions(-)

New commits:
commit 03f0ea92bc381ef5a8df7de1ae9edf4aed45a3b2
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 15 14:07:04 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 20 14:24:01 2020 +0200

vcl: add PDFGraphicResult instead of std::pair in ImportPDFUnloaded

ImportPDFUnloaded returned graphics as a vector of std::pair with
Graphic and Size. Instead, use a new struct PDFGraphicResult, so
it can be extended in the future.

Change-Id: Idda00a3b98a8efcbd9b8c8d0ee3982becfdc1d7f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96755
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index ba0eb1ca85be..a65d230279b9 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -13,13 +13,13 @@
 #include 
 #include 
 #include 
+#include 
 
 namespace com::sun::star::uno
 {
 template  class Sequence;
 }
 class Bitmap;
-class Graphic;
 
 namespace vcl
 {
@@ -31,10 +31,24 @@ VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, 
int nSize, std::vecto
 /// Imports a PDF stream into rGraphic as VectorGraphicData.
 VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
 
+struct PDFGraphicResult
+{
+Graphic maGraphic;
+
+// Size in HMM
+Size maSize;
+
+PDFGraphicResult(Graphic const& rGraphic, Size const& rSize)
+: maGraphic(rGraphic)
+, maSize(rSize)
+{
+}
+};
+
 /// Import PDF as Graphic images (1 per page), but not loaded yet.
 /// Returns the number of pages read.
 VCL_DLLPUBLIC size_t ImportPDFUnloaded(const OUString& rURL,
-   std::vector>& 
rGraphics);
+   std::vector& 
rGraphics);
 }
 
 #endif // INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx 
b/sd/source/filter/pdf/sdpdffilter.cxx
index 55d21f4057b8..2b09bc9e828e 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -41,7 +41,7 @@ bool SdPdfFilter::Import()
 const OUString aFileName(
 
mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
 
-std::vector> aGraphics;
+std::vector aGraphics;
 if (vcl::ImportPDFUnloaded(aFileName, aGraphics) == 0)
 return false;
 
@@ -52,10 +52,10 @@ bool SdPdfFilter::Import()
 mrDocument.DuplicatePage(0);
 }
 
-for (const std::pair& aPair : aGraphics)
+for (vcl::PDFGraphicResult const& rPDFGraphicResult : aGraphics)
 {
-const Graphic& rGraphic = aPair.first;
-const Size& aSizeHMM = aPair.second;
+const Graphic& rGraphic = rPDFGraphicResult.maGraphic;
+const Size& aSizeHMM = rPDFGraphicResult.maSize;
 
 const sal_Int32 nPageNumber = rGraphic.getPageNumber();
 assert(nPageNumber >= 0 && o3tl::make_unsigned(nPageNumber) < 
aGraphics.size());
diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 10caf1a975f5..9845c6c387c4 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -224,7 +224,7 @@ bool ImportPDF(SvStream& rStream, Graphic& rGraphic)
 return true;
 }
 
-size_t ImportPDFUnloaded(const OUString& rURL, std::vector>& rGraphics)
+size_t ImportPDFUnloaded(const OUString& rURL, std::vector& 
rGraphics)
 {
 #if HAVE_FEATURE_PDFIUM
 std::unique_ptr xStream(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 126 commits - accessibility/inc accessibility/source basctl/source basegfx/source basic/source binaryurp/source canvas/source chart2

2020-06-25 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit b866bcd61f6a1a2a13760a9040f05e27530437df
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 15 19:39:35 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 25 10:19:36 2020 +0200

vcl: add a Bitmap interface to basegfx, BitmapEx implementing it

Change-Id: I758f421d545191883e615f5016e9fc643459556e

diff --git a/include/basegfx/bitmap/Bitmap.hxx 
b/include/basegfx/bitmap/Bitmap.hxx
new file mode 100644
index ..b91b702aa212
--- /dev/null
+++ b/include/basegfx/bitmap/Bitmap.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 
+
+namespace basegfx
+{
+class BASEGFX_DLLPUBLIC IBitmap
+{
+};
+
+} // end of namespace basegfx
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index 4dac473bb2f5..774afe981d07 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -25,6 +25,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 
 namespace com::sun::star::rendering {
@@ -40,7 +42,7 @@ enum class TransparentType
 Bitmap
 };
 
-class SAL_WARN_UNUSED VCL_DLLPUBLIC BitmapEx
+class SAL_WARN_UNUSED VCL_DLLPUBLIC BitmapEx : basegfx::IBitmap
 {
 public:
 
commit b20079ee1da94a9719582fad6c508a4f4dcc82dc
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 17:00:47 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 25 10:19:36 2020 +0200

drawinglayer: remove textprimitive2d.hxx from clang-format blacklist

Change-Id: I6fa692bb3e4a16400ee2ae847a1f97201493f53a

diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx 
b/include/drawinglayer/primitive2d/textprimitive2d.hxx
index 9aeaa96fc15e..6bbc14aa498a 100644
--- a/include/drawinglayer/primitive2d/textprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx
@@ -33,152 +33,151 @@
 
 namespace drawinglayer::primitive2d
 {
-/** TextSimplePortionPrimitive2D class
+/** TextSimplePortionPrimitive2D class
 
-This is the basic primitive for representing a text portion. It 
contains
-all needed information. If it is not handled by a renderer, its 
decomposition
-will provide the text tools::PolyPolygon outlines as filled 
polygons, correctly
-transformed.
+This is the basic primitive for representing a text portion. It contains
+all needed information. If it is not handled by a renderer, its 
decomposition
+will provide the text tools::PolyPolygon outlines as filled polygons, 
correctly
+transformed.
 
-To get better text quality, it is suggested to handle this 
primitive directly
-in a renderer. In that case, e.g. hintings on the system can be 
supported.
+To get better text quality, it is suggested to handle this primitive 
directly
+in a renderer. In that case, e.g. hintings on the system can be supported.
 
-@param maTextTransform
-The text transformation contains the text start position (always 
baselined)
-as translation, the FontSize as scale (where width relative to 
height defines
-font scaling and width == height means no font scaling) and the 
font rotation
-and shear.
-When shear is used and a renderer does not support it, it may be 
better to use
-the decomposition which will do everything correctly. Same is true 
for mirroring
-which would be expressed as negative scalings.
+@param maTextTransform
+The text transformation contains the text start position (always baselined)
+as translation, the FontSize as scale (where width relative to height 
defines
+font scaling and width == height means no font scaling) and the font 
rotation
+and shear.
+When shear is used and a renderer does not support it, it may be better to 
use
+the decomposition which will do everything correctly. Same is true for 
mirroring
+which would be expressed as negative scalings.
 
-@param rText
-The text to be used. Only a part may be used, but a bigger part of 
the string
-may be necessary for correct layouting (e.g. international)
-
-@param aTextPosition
-The index to the first character to use from rText
-
-@param aTextLength
-The number of characters to use from rText
-
-@param rDXArray
-The distances between the characters. This parameter may be empty, 
in that case
-the renderer is responsible to do something useful. If it is 
given, it has to be of
-the size aTextLength. Its values 

[Libreoffice-commits] core.git: sd/source

2020-06-28 Thread Tomaž Vajngerl (via logerrit)
 sd/source/core/annotations/Annotation.cxx |6 ++
 sd/source/ui/unoidl/unomodel.cxx  |   13 +++--
 2 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit f008bd0277001226f2dd695836a019c9b9c84799
Author: Tomaž Vajngerl 
AuthorDate: Fri Jun 26 09:06:18 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 28 08:51:59 2020 +0200

sd: send annotation position for LOKit, fix multiple annotations

This adds support to send annotation position in the document when
sending the available annotations using LOKit.

It also fixes an issue with the json structure for the annotations,
which sends multiple annotation objects with the same (empty) key,
that after parsing reduces to only one (so only one of the many
annotations is present). This fix changes that so annotation
objects have each its own unique key.

Change-Id: I9d994383d6ee322f27f1426be5bd96ac81e8e609
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97329
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/source/core/annotations/Annotation.cxx 
b/sd/source/core/annotations/Annotation.cxx
index bd0feacf8a68..bff000a229cd 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -433,6 +433,12 @@ std::string 
lcl_LOKGetCommentPayload(CommentNotificationType nType, ReferencegetString());
 const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
 aAnnotation.put("parthash", pPage ? 
OString::number(pPage->GetHashCode()) : OString());
+geometry::RealPoint2D const & rPoint = rxAnnotation->getPosition();
+geometry::RealSize2D const & rSize = rxAnnotation->getSize();
+::tools::Rectangle aRectangle(Point(rPoint.X * 100.0, rPoint.Y * 
100.0), Size(rSize.Width * 100.0, rSize.Height * 100.0));
+aRectangle = OutputDevice::LogicToLogic(aRectangle, 
MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+OString sRectangle = aRectangle.toString();
+aAnnotation.put("rectangle", sRectangle.getStr());
 }
 
 boost::property_tree::ptree aTree;
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index c72ef5725b89..ad460509dda0 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -118,6 +118,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2407,13 +2408,21 @@ void 
SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter)
 
 for (const uno::Reference& xAnnotation : 
aPageAnnotations)
 {
-auto commentNode = rJsonWriter.startNode("");
-rJsonWriter.put("id", sd::getAnnotationId(xAnnotation));
+sal_uInt32 nID = sd::getAnnotationId(xAnnotation);
+OString nodeName = "comment" + OString::number(nID);
+auto commentNode = rJsonWriter.startNode(nodeName.getStr());
+rJsonWriter.put("id", nID);
 rJsonWriter.put("author", xAnnotation->getAuthor());
 rJsonWriter.put("dateTime", 
utl::toISO8601(xAnnotation->getDateTime()));
 uno::Reference xText(xAnnotation->getTextRange());
 rJsonWriter.put("text", xText->getString());
 rJsonWriter.put("parthash", pPage->GetHashCode());
+geometry::RealPoint2D const & rPoint = xAnnotation->getPosition();
+geometry::RealSize2D const & rSize = xAnnotation->getSize();
+::tools::Rectangle aRectangle(Point(rPoint.X * 100.0, rPoint.Y * 
100.0), Size(rSize.Width * 100.0, rSize.Height * 100.0));
+aRectangle = OutputDevice::LogicToLogic(aRectangle, 
MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+OString sRectangle = aRectangle.toString();
+rJsonWriter.put("rectangle", sRectangle.getStr());
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: vcl/source

2020-06-28 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/gdi/pdfwriter_impl.cxx |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 09c01a8d6f5dc072991450d215558555152764a8
Author: Tomaž Vajngerl 
AuthorDate: Fri Jun 26 09:18:47 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 28 08:52:14 2020 +0200

pdf: fix text annotation (note) modification date

The modification date wasn't encolsed in brackets, which is
required for the modification date.

Change-Id: Icf91516436b095a8577d3ab10b2a708d10d58cb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97330
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index c7c6b5cccfbc..de1cea050f04 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3483,8 +3483,9 @@ void PDFWriterImpl::emitTextAnnotationLine(OStringBuffer 
& aLine, PDFNoteEntry c
 
 auto & rDateTime = rNote.m_aContents.maModificationDate;
 
-aLine.append("/M ");
+aLine.append("/M (");
 appendPdfTimeDate(aLine, rDateTime.Year, rDateTime.Month, rDateTime.Day, 
rDateTime.Hours, rDateTime.Minutes, rDateTime.Seconds, 0);
+aLine.append(") ");
 
 // contents of the note (type text string)
 aLine.append("/Contents ");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loleaflet/css loleaflet/src

2020-06-28 Thread Tomaž Vajngerl (via logerrit)
 loleaflet/css/loleaflet.css  |   11 ++
 loleaflet/src/layer/marker/Annotation.js |   32 +++
 2 files changed, 43 insertions(+)

New commits:
commit 552462cecd225b5d12f40fea410686a2f3a40ba0
Author: Tomaž Vajngerl 
AuthorDate: Fri Jun 26 09:04:35 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 28 08:51:15 2020 +0200

Add support to show annotation marker for draw/impress

Change-Id: Ibaeaed97de5b5a87f4a46c4da593a3ee861e2399
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97335
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/loleaflet/css/loleaflet.css b/loleaflet/css/loleaflet.css
index 41e9459fc..dccd4b4b5 100644
--- a/loleaflet/css/loleaflet.css
+++ b/loleaflet/css/loleaflet.css
@@ -236,6 +236,17 @@ body {
margin-right: 10px;
 }
 
+.annotation-marker {
+   margin-left: 0px;
+   margin-top: 0px;
+   width: 24px;
+   height: 24px;
+   background-image: url('images/note.svg');
+   background-size: 100% 100%;
+   background-repeat: no-repeat;
+   outline: none;
+}
+
 .loleaflet-scrolled {
overflow: auto;
 }
diff --git a/loleaflet/src/layer/marker/Annotation.js 
b/loleaflet/src/layer/marker/Annotation.js
index 6224007f8..730396ab9 100644
--- a/loleaflet/src/layer/marker/Annotation.js
+++ b/loleaflet/src/layer/marker/Annotation.js
@@ -19,6 +19,7 @@ L.Annotation = L.Layer.extend({
this._latlng = L.latLng(latlng);
this._data = data;
this._skipCheckBounds = false;
+   this._annotationMarker = null;
},
 
onAdd: function (map) {
@@ -51,6 +52,7 @@ L.Annotation = L.Layer.extend({
this._updateContent();
this._updateLayout();
this._updatePosition();
+   this._updateAnnotationMarker();
},
 
setData: function (data) {
@@ -89,6 +91,9 @@ L.Annotation = L.Layer.extend({
if (this._data.textSelected && this._map.hasLayer && 
!this._map.hasLayer(this._data.textSelected)) {
this._map.addLayer(this._data.textSelected);
}
+   if (this._annotationMarker != null) {
+   this._map.addLayer(this._annotationMarker);
+   }
},
 
hide: function () {
@@ -99,6 +104,9 @@ L.Annotation = L.Layer.extend({
if (this._data.textSelected && 
this._map.hasLayer(this._data.textSelected)) {
this._map.removeLayer(this._data.textSelected);
}
+   if (this._annotationMarker != null) {
+   this._map.removeLayer(this._annotationMarker);
+   }
},
 
isVisible: function () {
@@ -441,6 +449,30 @@ L.Annotation = L.Layer.extend({
var authorImageHeight = Math.round(this.options.imgSize.y * 
scaleFactor);
this._authorAvatarImg.setAttribute('width', authorImageWidth);
this._authorAvatarImg.setAttribute('height', authorImageHeight);
+   },
+
+   _updateAnnotationMarker: function () {
+   if (this._data == null)
+   return;
+
+   if (this._annotationMarker == null) {
+   this._annotationMarker = L.marker(new L.LatLng(0, 0), {
+   icon: L.divIcon({
+   className: 'annotation-marker',
+   iconSize: null
+   }),
+   draggable: true
+   });
+   this._map.addLayer(this._annotationMarker);
+   }
+   var stringTwips = this._data.rectangle.match(/\d+/g);
+   var topLeftTwips = new L.Point(parseInt(stringTwips[0]), 
parseInt(stringTwips[1]));
+   var offset = new L.Point(parseInt(stringTwips[2]), 
parseInt(stringTwips[3]));
+   var bottomRightTwips = topLeftTwips.add(offset);
+   var bounds = new L.LatLngBounds(
+   this._map._docLayer._twipsToLatLng(topLeftTwips, 
this._map.getZoom()),
+   this._map._docLayer._twipsToLatLng(bottomRightTwips, 
this._map.getZoom()));
+   this._annotationMarker.setLatLng(bounds.getSouthWest());
}
 });
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx svx/sdi sw/source

2020-06-25 Thread Tomaž Vajngerl (via logerrit)
 include/svx/svxids.hrc  |7 ---
 svx/sdi/svx.sdi |4 ++--
 sw/source/uibase/uiview/viewtab.cxx |   16 +++-
 3 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit 472ab1cad9d7565572877f30709029606c86dc54
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 1 16:03:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 25 12:55:11 2020 +0200

lok: add "Remove" param to .uno:ChangeTabStop

Change-Id: Ic6b71c0bb6177eb10f5be4197d77c5db5f5884a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95330
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 8d0b7e5b2f6773f4b3feb75f1ac73ea1a26609f7)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97091
Tested-by: Jenkins CollaboraOffice 

diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 8d4030ec0285..4951af004d23 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -533,12 +533,13 @@ class SvxSetItem;
 #define SID_TABSTOP_ADD_OR_CHANGE   ( SID_SVX_START + 581 )
 #define SID_TABSTOP_ATTR_INDEX  ( SID_SVX_START + 582 )
 #define SID_TABSTOP_ATTR_POSITION   ( SID_SVX_START + 583 )
-#define SID_PARAGRAPH_FIRST_LINE_INDENT ( SID_SVX_START + 584 )
-#define SID_PARAGRAPH_LEFT_INDENT   ( SID_SVX_START + 585 )
-#define SID_PARAGRAPH_RIGHT_INDENT  ( SID_SVX_START + 586 )
+#define SID_TABSTOP_ATTR_REMOVE ( SID_SVX_START + 584 )
 
 // CAUTION! Range <587 .. 587> used by EditEngine (!)
 
+#define SID_PARAGRAPH_FIRST_LINE_INDENT ( SID_SVX_START + 588 )
+#define SID_PARAGRAPH_LEFT_INDENT   ( SID_SVX_START + 589 )
+#define SID_PARAGRAPH_RIGHT_INDENT  ( SID_SVX_START + 590 )
 
 // CAUTION! Range <591 .. 591> used by EditEngine (!)
 
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 17f4b27f9dbf..64531a736a69 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -7209,7 +7209,8 @@ SfxVoidItem RulerChangeState SID_RULER_CHANGE_STATE
 
 SfxVoidItem ChangeTabStop SID_TABSTOP_ADD_OR_CHANGE
 (SfxInt32Item Index SID_TABSTOP_ATTR_INDEX,
- SfxInt32Item Position SID_TABSTOP_ATTR_POSITION)
+ SfxInt32Item Position SID_TABSTOP_ATTR_POSITION,
+ SfxBoolItem  Remove SID_TABSTOP_ATTR_REMOVE)
 [
 AutoUpdate = FALSE,
 FastCall = TRUE,
@@ -7219,7 +7220,6 @@ SfxVoidItem ChangeTabStop SID_TABSTOP_ADD_OR_CHANGE
 RecordAbsolute = FALSE,
 RecordPerSet;
 
-
 AccelConfig = FALSE,
 MenuConfig = FALSE,
 ToolBoxConfig = FALSE,
diff --git a/sw/source/uibase/uiview/viewtab.cxx 
b/sw/source/uibase/uiview/viewtab.cxx
index cb8662580fa3..7a2f8c852625 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -663,8 +663,12 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
 {
 const auto aIndexItem = static_cast(pReqArgs->Get(SID_TABSTOP_ATTR_INDEX));
 const auto aPositionItem = static_cast(pReqArgs->Get(SID_TABSTOP_ATTR_POSITION));
+const auto aRemoveItem = static_cast(pReqArgs->Get(SID_TABSTOP_ATTR_REMOVE));
 const sal_Int32 nIndex = aIndexItem.GetValue();
 const sal_Int32 nPosition = aPositionItem.GetValue();
+const bool bRemove = aRemoveItem.GetValue();
+
+
 
 SfxItemSet aItemSet(GetPool(), svl::Items{});
 rSh.GetCurAttr(aItemSet);
@@ -688,12 +692,14 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
 {
 SvxTabStop aTabStop = aTabStopItem.At(nIndex);
 aTabStopItem.Remove(nIndex);
-aTabStop.GetTabPos() = nPosition;
-aTabStopItem.Insert(aTabStop);
-
-SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
-aTabStopItem.Insert(aSwTabStop);
+if (!bRemove)
+{
+aTabStop.GetTabPos() = nPosition;
+aTabStopItem.Insert(aTabStop);
 
+SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
+aTabStopItem.Insert(aSwTabStop);
+}
 const SvxTabStopItem& rDefaultTabs = 
rSh.GetDefault(RES_PARATR_TABSTOP);
 MakeDefTabs(GetTabDist(rDefaultTabs), aTabStopItem);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sd/source vcl/source

2020-06-07 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/pdfread.hxx  |   18 +++---
 sd/source/filter/pdf/sdpdffilter.cxx |   17 -
 vcl/source/filter/ipdf/pdfread.cxx   |   14 --
 3 files changed, 15 insertions(+), 34 deletions(-)

New commits:
commit ef4f5a6433259e441dbf0e0295a9d07644b43e2c
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 29 16:30:19 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 7 21:15:13 2020 +0200

pdfium: fix setting the size of the document when opening PDF

When loading the pages of PDF, the size of the document was
set to the wrong value. Size returned by ImportPDFUnloaded was
in pixels, which is not really useful considering the svx and
sd core uses 100th mm as the unit and converting it to a device
dependent pixel will just bring grief. Also we don't need to know
the size in pixels until we actually render.
This change removes DPI as the parameter to the ImportPDFUnloaded
and changes the code to get the size of the page from the PDF as
points and converts that to 100th mm.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91330
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 489b18edd6dc87287f260ba87d95abcc95d87932)

Change-Id: I0c0db23d2775e2897ba7621ef6320a974c0b9275
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95641
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/pdfread.hxx b/include/vcl/pdfread.hxx
index b56e8139447d..ba0eb1ca85be 100644
--- a/include/vcl/pdfread.hxx
+++ b/include/vcl/pdfread.hxx
@@ -14,19 +14,10 @@
 #include 
 #include 
 
-namespace com
-{
-namespace sun
-{
-namespace star
-{
-namespace uno
+namespace com::sun::star::uno
 {
 template  class Sequence;
 }
-}
-}
-}
 class Bitmap;
 class Graphic;
 
@@ -40,13 +31,10 @@ VCL_DLLPUBLIC size_t RenderPDFBitmaps(const void* pBuffer, 
int nSize, std::vecto
 /// Imports a PDF stream into rGraphic as VectorGraphicData.
 VCL_DLLPUBLIC bool ImportPDF(SvStream& rStream, Graphic& rGraphic);
 
-/// Import PDF as Graphic images (1 per page), all unloaded.
-/// Since Graphic is unloaded, we need to return the page size (in pixels) 
separately.
-/// Does not set rPdfData if no conversion is done.
+/// Import PDF as Graphic images (1 per page), but not loaded yet.
 /// Returns the number of pages read.
 VCL_DLLPUBLIC size_t ImportPDFUnloaded(const OUString& rURL,
-   std::vector>& 
rGraphics,
-   double fResolutionDPI = 96.);
+   std::vector>& 
rGraphics);
 }
 
 #endif // INCLUDED_VCL_SOURCE_FILTER_IPDF_PDFREAD_HXX
diff --git a/sd/source/filter/pdf/sdpdffilter.cxx 
b/sd/source/filter/pdf/sdpdffilter.cxx
index 8980e902ec73..c1069da58233 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -40,11 +40,8 @@ bool SdPdfFilter::Import()
 const OUString aFileName(
 
mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
 
-// Rendering resolution.
-const double dResolutionDPI = 96.0;
-
 std::vector> aGraphics;
-if (vcl::ImportPDFUnloaded(aFileName, aGraphics, dResolutionDPI) == 0)
+if (vcl::ImportPDFUnloaded(aFileName, aGraphics) == 0)
 return false;
 
 // Add as many pages as we need up-front.
@@ -57,26 +54,20 @@ bool SdPdfFilter::Import()
 for (const std::pair& aPair : aGraphics)
 {
 const Graphic& rGraphic = aPair.first;
-const Size& aSize = aPair.second;
+const Size& aSizeHMM = aPair.second;
 
 const sal_Int32 nPageNumber = rGraphic.getPageNumber();
 assert(nPageNumber >= 0 && static_cast(nPageNumber) < 
aGraphics.size());
 
 // Create the page and insert the Graphic.
 SdPage* pPage = mrDocument.GetSdPage(nPageNumber, PageKind::Standard);
-Size aGraphicSize(OutputDevice::LogicToLogic(aSize, 
rGraphic.GetPrefMapMode(),
- 
MapMode(MapUnit::Map100thMM)));
-
-// Resize to original size based on 72 dpi to preserve page size.
-aGraphicSize = Size(aGraphicSize.Width() * 72.0 / dResolutionDPI,
-aGraphicSize.Height() * 72.0 / dResolutionDPI);
 
 // Make the page size match the rendered image.
-pPage->SetSize(aGraphicSize);
+pPage->SetSize(aSizeHMM);
 Point aPosition(0, 0);
 
 SdrGrafObj* pSdrGrafObj = new 
SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic,
- tools::Rectangle(aPosition, 
aGraphicSize));
+ tools::Rectangle(aPosition, 
aSizeHMM));
 pPage->InsertObject(pSdrGrafObj);
 }
 
diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index b734a7bc4420..091b4cd37850 100644
--- 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - svx/source

2020-06-07 Thread Tomaž Vajngerl (via logerrit)
 svx/source/svdraw/svdpdf.cxx |   38 --
 svx/source/svdraw/svdpdf.hxx |4 ++--
 2 files changed, 22 insertions(+), 20 deletions(-)

New commits:
commit ca006ba55cceb0a4c97e9c9f9d59be3fc1727765
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 29 23:05:25 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 7 21:17:07 2020 +0200

replace usage of Matrix for B2DHomMatrix in ImpSdrPdfImport

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91341
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit c20fa884cf20959dbd65814274e450e1f49cf45e)

Change-Id: I366ee435ddf217c7c078d58f882610df12bec276
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95698
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 415c6e3dc7df..820832265aa0 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -768,11 +768,11 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
  int /*nPageObjectIndex*/)
 {
 // Get the form matrix to perform correct translation/scaling of the form 
sub-objects.
-const Matrix aOldMatrix = mCurMatrix;
+const basegfx::B2DHomMatrix aOldMatrix = maCurrentMatrix;
 
 double a, b, c, d, e, f;
-FPDFFormObj_GetMatrix(pPageObject, , , , , , );
-mCurMatrix = Matrix(a, b, c, d, e, f);
+FPDFTextObj_GetMatrix(pPageObject, , , , , , );
+maCurrentMatrix = basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
 
 const int nCount = FPDFFormObj_CountObjects(pPageObject);
 for (int nIndex = 0; nIndex < nCount; ++nIndex)
@@ -782,7 +782,7 @@ void ImpSdrPdfImport::ImportForm(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 }
 
 // Restore the old one.
-mCurMatrix = aOldMatrix;
+maCurrentMatrix = aOldMatrix;
 }
 
 void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE 
pTextPage,
@@ -802,10 +802,12 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 
 double a, b, c, d, e, f;
 FPDFTextObj_GetMatrix(pPageObject, , , , , , );
-Matrix aTextMatrix(mCurMatrix);
 
-aTextMatrix.Transform(left, right, top, bottom);
-const tools::Rectangle aRect = PointsToLogic(left, right, top, bottom);
+basegfx::B2DHomMatrix aTextMatrix(maCurrentMatrix);
+basegfx::B2DRange aTextRect(left, top, right, bottom);
+aTextRect *= aTextMatrix;
+const tools::Rectangle aRect = PointsToLogic(aTextRect.getMinX(), 
aTextRect.getMaxX(),
+ aTextRect.getMinY(), 
aTextRect.getMaxY());
 
 const int nChars = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0);
 std::unique_ptr pText(new sal_Unicode[nChars]);
@@ -1037,8 +1039,8 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
 {
 double a, b, c, d, e, f;
 FPDFPath_GetMatrix(pPageObject, , , , , , );
-Matrix aPathMatrix(a, b, c, d, e, f);
-aPathMatrix.Concatinate(mCurMatrix);
+auto aPathMatrix = basegfx::B2DHomMatrix::abcdef(a, b, c, d, e, f);
+aPathMatrix *= maCurrentMatrix;
 
 basegfx::B2DPolyPolygon aPolyPoly;
 basegfx::B2DPolygon aPoly;
@@ -1057,26 +1059,26 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
 continue;
 }
 
-double x = fx;
-double y = fy;
-aPathMatrix.Transform(x, y);
+basegfx::B2DPoint aB2DPoint(fx, fy);
+aB2DPoint *= aPathMatrix;
+
 const bool bClose = FPDFPathSegment_GetClose(pPathSegment);
 if (bClose)
 aPoly.setClosed(bClose); // TODO: Review
 
-Point aPoint = PointsToLogic(x, y);
-x = aPoint.X();
-y = aPoint.Y();
+Point aPoint = PointsToLogic(aB2DPoint.getX(), aB2DPoint.getY());
+aB2DPoint.setX(aPoint.X());
+aB2DPoint.setY(aPoint.Y());
 
 const int nSegmentType = FPDFPathSegment_GetType(pPathSegment);
 switch (nSegmentType)
 {
 case FPDF_SEGMENT_LINETO:
-aPoly.append(basegfx::B2DPoint(x, y));
+aPoly.append(aB2DPoint);
 break;
 
 case FPDF_SEGMENT_BEZIERTO:
-aBezier.emplace_back(x, y);
+aBezier.emplace_back(aB2DPoint.getX(), aB2DPoint.getY());
 if (aBezier.size() == 3)
 {
 aPoly.appendBezierSegment(aBezier[0], aBezier[1], 
aBezier[2]);
@@ -1092,7 +1094,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
 aPoly.clear();
 }
 
-aPoly.append(basegfx::B2DPoint(x, y));
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - basegfx/test include/basegfx

2020-06-07 Thread Tomaž Vajngerl (via logerrit)
 basegfx/test/B2DHomMatrixTest.cxx |  181 --
 include/basegfx/matrix/Matrix.hxx |  178 -
 2 files changed, 59 insertions(+), 300 deletions(-)

New commits:
commit 49c21d31e2ba117d5b2b6cf3e77e9ebf42f4201d
Author: Tomaž Vajngerl 
AuthorDate: Sun Mar 29 23:15:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 7 21:17:24 2020 +0200

remove Matrix class from basegfx, convert B2DHomMatrix tests

The common test cases of MAtrix and B2DHomMatrix are just converted
into additional test cases for B2DHomMatrix.

Change-Id: I8ed2f6d25263797b21a844e209e910a8a3f2a347
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91342
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 4501a0ba623ad61c5a4e0b807da2e96f0e4ce82c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95699
Tested-by: Tomaž Vajngerl 

diff --git a/basegfx/test/B2DHomMatrixTest.cxx 
b/basegfx/test/B2DHomMatrixTest.cxx
index 340f37c8937f..8063587ac2dd 100644
--- a/basegfx/test/B2DHomMatrixTest.cxx
+++ b/basegfx/test/B2DHomMatrixTest.cxx
@@ -23,7 +23,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -446,127 +445,62 @@ public:
 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", F_PI, 
fDRot, 1E-12);
 }
 
-void testMatrix()
+void testCreate_abcdef()
 {
-{
-B2DHomMatrix aB2DMatrix(00, 01, 02, 10, 11, 12);
-Matrix aMatrix(00, 10, 01, 11, 02, 12);
-
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.a(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.b(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.c(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.d(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.e(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.f(), 
1E-12);
-
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.get(0, 
0), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.get(1, 
0), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.get(0, 
1), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.get(1, 
1), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.get(0, 
2), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.get(1, 
2), 1E-12);
-}
-
-{
-B2DHomMatrix aB2DMatrix = B2DHomMatrix::abcdef(00, 10, 01, 11, 02, 
12);
-Matrix aMatrix(00, 10, 01, 11, 02, 12);
-
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.a(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.b(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.c(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.d(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.e(), 
1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.f(), 
1E-12);
-
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.get(0, 
0), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.get(1, 
0), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.get(0, 
1), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.get(1, 
1), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.get(0, 
2), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.get(1, 
2), 1E-12);
-
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.a(), aMatrix.a(), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.b(), aMatrix.b(), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.c(), aMatrix.c(), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.d(), aMatrix.d(), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.e(), aMatrix.e(), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.f(), aMatrix.f(), 1E-12);
-}
-
-{
-B2DHomMatrix aB2DMatrix(00, 01, 02, 10, 11, 12); //column first
-Matrix aMatrix(00, 10, 01, 11, 02, 12); // row first
-
-Matrix aNewMatrix(1, 2, 3, 4, 5, 6);
-
-B2DHomMatrix aNewB2DMatrix(1, 3, 5, 2, 4, 6);
-
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(0, 0), 
aNewB2DMatrix.get(0, 0), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(1, 0), 
aNewB2DMatrix.get(1, 0), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(0, 1), 
aNewB2DMatrix.get(0, 1), 1E-12);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(1, 1), 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source

2020-06-07 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/gdi/pdfwriter_impl.cxx |7 ++-
 vcl/source/gdi/pdfwriter_impl.hxx |1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit 13631a77f27a9794821745a78e509167881d2252
Author: Tomaž Vajngerl 
AuthorDate: Sun Apr 26 12:07:19 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 7 21:18:20 2020 +0200

vcl: When exporing PDF, write the correct page of embedded PDF

We can display PDF as an graphic in the document, where the PDF
is treated as a vector graphic and rendered with Pdfium. When
in that case we export the document as PDF, we can insert the
original PDF page as an reference XObject. This workes fine,
however the PDF as an graphic also contains the page number,
which page should be rendered. This was not taken into account
in the PDF export - it was hardcored to first page.

This extends the support so it reads the page index from the
graphic, and sets the correct PDF page.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92924
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 218ad66010fdba3c28564e2038876b6822752243)

Change-Id: I15188ee495f9b3fcc3aa7df6f4bad4fa09903c6a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95700
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 807c2b5a60d8..b966ef0ed15c 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8848,7 +8848,9 @@ void 
PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit)
 return;
 }
 
-filter::PDFObjectElement* pPage = aPages[0];
+size_t nPageIndex = rEmit.m_nPDFPageIndex >= 0 ? rEmit.m_nPDFPageIndex 
: 0;
+
+filter::PDFObjectElement* pPage = aPages[nPageIndex];
 if (!pPage)
 {
 SAL_WARN("vcl.pdfwriter", "PDFWriterImpl::writeReferenceXObject: 
no page");
@@ -9440,7 +9442,10 @@ void PDFWriterImpl::createEmbeddedFile(const Graphic& 
rGraphic, ReferenceXObject
 rEmit.m_nEmbeddedObject = m_aEmbeddedFiles.back().m_nObject;
 }
 else
+{
+rEmit.m_nPDFPageIndex = 
rGraphic.getVectorGraphicData()->getPageIndex();
 rEmit.m_aPDFData = *pPDFData;
+}
 
 rEmit.m_nFormObject = createObject();
 rEmit.m_aPixelSize = rGraphic.GetPrefSize();
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx 
b/vcl/source/gdi/pdfwriter_impl.hxx
index 8c88ed6fb172..f8e89949b1be 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -209,6 +209,7 @@ public:
 Size m_aPixelSize;
 /// PDF data from the graphic object, if not writing a reference 
XObject.
 std::vector m_aPDFData;
+sal_Int32 m_nPDFPageIndex;
 
 ReferenceXObjectEmit()
 : m_nFormObject(0),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/qa

2020-06-07 Thread Tomaž Vajngerl (via logerrit)
 vcl/qa/cppunit/pdfexport/data/SimpleMultiPagePDF.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |  137 +++
 2 files changed, 137 insertions(+)

New commits:
commit 9a66b4fb9b3c408c3ea61cd89817d14f3c8d9a50
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 30 07:54:46 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun Jun 7 21:18:41 2020 +0200

test import and export of multi-page PDF with PDFium filter

The test checks that the exported PDFs contain embedded PDF for
different pages.

Change-Id: I4e5cd108d8597851d86aa774efbde0d4f2b9d2ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93322
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95701
Tested-by: Tomaž Vajngerl 

diff --git a/vcl/qa/cppunit/pdfexport/data/SimpleMultiPagePDF.pdf 
b/vcl/qa/cppunit/pdfexport/data/SimpleMultiPagePDF.pdf
new file mode 100644
index ..af665fcba8a0
Binary files /dev/null and 
b/vcl/qa/cppunit/pdfexport/data/SimpleMultiPagePDF.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 898e7188ed8c..be40e202306d 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -23,6 +23,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -141,6 +142,8 @@ public:
 void testLargePage();
 void testVersion15();
 void testDefaultVersion();
+void testMultiPagePDF();
+
 
 CPPUNIT_TEST_SUITE(PdfExportTest);
 CPPUNIT_TEST(testTdf106059);
@@ -182,6 +185,7 @@ public:
 CPPUNIT_TEST(testLargePage);
 CPPUNIT_TEST(testVersion15);
 CPPUNIT_TEST(testDefaultVersion);
+CPPUNIT_TEST(testMultiPagePDF);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -2060,6 +2064,139 @@ void PdfExportTest::testVersion15()
 CPPUNIT_ASSERT_EQUAL(15, nFileVersion);
 }
 
+// Check round-trip of importing and exporting the PDF with PDFium filter,
+// which imports the PDF document as multiple PDFs as graphic object.
+// Each page in the document has one PDF graphic object which content is
+// the correcponding page in the PDF. When such a document is exported,
+// the PDF graphic gets embedded into the exported PDF document (as a
+// Form XObject).
+void PdfExportTest::testMultiPagePDF()
+{
+// setenv only works on unix based systems
+#ifndef _WIN32
+// We need to enable PDFium import (and make sure to disable after the 
test)
+bool bResetEnvVar = false;
+if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr)
+{
+bResetEnvVar = true;
+setenv("LO_IMPORT_USE_PDFIUM", "1", false);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+unsetenv("LO_IMPORT_USE_PDFIUM");
+});
+
+// Load the PDF and save as PDF
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"SimpleMultiPagePDF.pdf";
+mxComponent = loadFromDesktop(aURL);
+CPPUNIT_ASSERT(mxComponent.is());
+
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+
+// Parse the export result.
+vcl::filter::PDFDocument aDocument;
+SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(static_cast(3), aPages.size());
+
+vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources");
+CPPUNIT_ASSERT(pResources);
+
+auto pXObjects = 
dynamic_cast(pResources->Lookup("XObject"));
+CPPUNIT_ASSERT(pXObjects);
+
+CPPUNIT_ASSERT_EQUAL(static_cast(3), 
pXObjects->GetItems().size()); // 3 PDFs as Form XObjects
+
+std::vector rIDs;
+for (auto const & rPair : pXObjects->GetItems()) {
+rIDs.push_back(rPair.first);
+}
+
+// Let's check the embedded PDF pages - just make sure the size differs,
+// which should indicate we don't have 3 times the same page.
+
+{   // embedded PDF page 1
+vcl::filter::PDFObjectElement* pXObject1 = 
pXObjects->LookupObject(rIDs[0]);
+CPPUNIT_ASSERT(pXObject1);
+CPPUNIT_ASSERT_EQUAL(OString("Im19"), rIDs[0]);
+
+auto pSubtype1 = 
dynamic_cast(pXObject1->Lookup("Subtype"));
+CPPUNIT_ASSERT(pSubtype1);
+CPPUNIT_ASSERT_EQUAL(OString("Form"), pSubtype1->GetValue());
+
+auto pXObjectResources = 
dynamic_cast(pXObject1->Lookup("Resources"));
+CPPUNIT_ASSERT(pXObjectResources);
+auto pXObjectForms = 
dynamic_cast(pXObjectResources->LookupElement("XObject"));
+CPPUNIT_ASSERT(pXObjectForms);
+vcl::filter::PDFObjectElement* pForm = 
pXObjectForms->LookupObject(pXObjectForms->GetItems().begin()->first);
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/qa vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|3 -
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   33 
 vcl/source/graphic/VectorGraphicSearch.cxx |   79 +++--
 3 files changed, 86 insertions(+), 29 deletions(-)

New commits:
commit 5713b22bc3b7bc54d83fc99616912504ebf63649
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 14:03:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 23:34:28 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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95460
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 1f8a46ae50c6977add4c4116f114df3a58796be3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95946
Tested-by: Jenkins CollaboraOffice 

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 a719329b7708..6ca73280605d 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -33,18 +33,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)
 {
 }
 
@@ -74,13 +74,30 @@ public:
 return aSize;
 }
 
-bool initialize()
+bool initialize(OUString const& rSearchString, SearchStartPosition 
eStartPosition)
 {
 if (!mpPdfDocument)
 return false;
+
+if (rSearchString == maSearchString)
+return true;
+
+if (mpSearchHandle)
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sd/source vcl/qa vcl/source

2020-06-10 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 456116d97b66703e23055b83ded5d87ed85c728d
Author: Tomaž Vajngerl 
AuthorDate: Thu Jun 4 18:26:58 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 10 08:11:41 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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95530
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 112d8113388513d9c6b317e828f5d373b4a54330)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95950
Tested-by: Jenkins CollaboraOffice 

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 3114196f7cf2..c01e2fe6fe73 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -840,8 +840,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)
 {
@@ -1253,11 +1257,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 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - sd/qa vcl/qa

2020-06-10 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   16 
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx|6 ++
 2 files changed, 22 insertions(+)

New commits:
commit 3e20ddab50de57f8a4f915791bbb56710c4936e3
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 12:31:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 10 08:11:29 2020 +0200

sd: disable LOKitSearchTest that test PDF search if no PDFium

enclose the tests with HAVE_FEATURE_PDFIUM

Change-Id: I1ce97fe090cef2cc2ab2f25fd1d2698bcaf28222
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95463
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 25da71b489228b866f20d8ea6d1926128168d1fa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95949
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8c2a41eeca9e..91b5ecbc8473 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -8,6 +8,8 @@
  */
 
 #include "../sdmodeltestbase.hxx"
+#include 
+
 #include "CallbackRecorder.hxx"
 
 #include 
@@ -140,6 +142,7 @@ void lcl_search(const OUString& rKey, bool bFindAll = 
false, bool bBackwards = f
 Scheduler::ProcessEventsToIdle();
 }
 
+#if HAVE_FEATURE_PDFIUM
 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 {
 SdrView* pSdrView = pViewShell->GetView();
@@ -148,6 +151,7 @@ SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
 return pObject;
 }
+#endif
 
 } // end anonymous namespace
 
@@ -262,6 +266,7 @@ void LOKitSearchTest::testDontSearchInMasterPages()
 
 void LOKitSearchTest::testSearchInPDFNonExisting()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -285,10 +290,12 @@ void LOKitSearchTest::testSearchInPDFNonExisting()
 lcl_search("NonExisting");
 
 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDF()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -332,10 +339,12 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
  mpCallbackRecorder->m_aSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePages()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -422,10 +431,12 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -520,12 +531,14 @@ void 
LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchIn2MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -606,11 +619,13 @@ void LOKitSearchTest::testSearchIn2MixedObjects()
 
 CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
 void LOKitSearchTest::testSearchIn6MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -770,6 +785,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-10 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit ca214ec3f5b3c65c8d6d335d284b0702f29b4c25
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 21:59:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 10 08:11:00 2020 +0200

sd: allow to change the search string between searches

Before this was missing, so even with a different search string,
it still searched using the old string, which was a bug.

Change-Id: I1655cb421e216e30ae593aabd3ead3a2d5c06299
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95461
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 191288d6a7fb52b31038a21c4e71ee57ffa3bacd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95947
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 09d84fafc3a7..3114196f7cf2 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -837,13 +837,19 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 
 if (mpImpl->mbCurrentIsVectorGraphic)
 {
+OUString const & rString = mpSearchItem->GetSearchString();
 bool bBackwards = mpSearchItem->GetBackward();
 
-bool bResult = false;
-if (bBackwards)
-bResult = mpImpl->mpVectorGraphicSearch->previous();
-else
-bResult = mpImpl->mpVectorGraphicSearch->next();
+SearchStartPosition eSearchStartPosition = bBackwards ? 
SearchStartPosition::End : SearchStartPosition::Begin;
+bool bResult = mpImpl->mpVectorGraphicSearch->search(rString, 
eSearchStartPosition);
+
+if (bResult)
+{
+if (bBackwards)
+bResult = mpImpl->mpVectorGraphicSearch->previous();
+else
+bResult = mpImpl->mpVectorGraphicSearch->next();
+}
 
 if (bResult)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/tools sd/qa

2020-06-10 Thread Tomaž Vajngerl (via logerrit)
 include/tools/weakbase.h|5 ++-
 include/tools/weakbase.hxx  |9 -
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx   |   39 
 sd/qa/unit/tiledrendering/data/OnePDFObject.odg |binary
 4 files changed, 51 insertions(+), 2 deletions(-)

New commits:
commit 8ca89dc44aa5905d8d189be765ad2a1a613d31f4
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 10 11:08:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 10 15:58:16 2020 +0200

fix reseting WeakReference when moving a ref to another ref.

In ViewIteratorImpl::Reverse we std::move a reference, to a local
variable, however the reference was not reset correctly, which
caused a crash.

The issue is that a mpWeakConnection in WeakReference always
needs to be non-null as shown in reset(reference_type* pReference)
method. In the move constructor of WeakReference, we just std::move
the reference like:

mpWeakConnection = std::move(rWeakRef.mpWeakConnection);

This means rWeakRef.mpWeakConnection will be reset to null, which
is not what is expected, so what is missing is to instantiate
rWeakRef.mpWeakConnection by calling reset(nullptr) or using the
added reset() method.

This also adds a test for LOKit PDF search as this is the case
where the crash has been reproduced. It happens because of a
call to:

... std::move(maPosition.mxObject);

in the method ViewIteratorImpl::Reverse()

Change-Id: I43692554ba4f6231d00091269b7c902ab5cbc11f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95995
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/tools/weakbase.h b/include/tools/weakbase.h
index 0f9a500bb55b..86f3c24d8c24 100644
--- a/include/tools/weakbase.h
+++ b/include/tools/weakbase.h
@@ -82,7 +82,7 @@ public:
 /** constructs a reference from another reference */
 inline WeakReference( const WeakReference< reference_type >& rWeakRef );
 
-/** constructs a reference from another reference */
+/** move a reference from another reference */
 inline WeakReference( WeakReference< reference_type >&& rWeakRef );
 
 /** returns true if the reference object is not null and still alive */
@@ -97,6 +97,9 @@ public:
 /** sets this reference to the given object or null */
 inline void reset( reference_type* pReference );
 
+/** resets this reference to null */
+inline void reset();
+
 /** returns the pointer to the reference object or null */
 inline reference_type * operator->() const;
 
diff --git a/include/tools/weakbase.hxx b/include/tools/weakbase.hxx
index 5c1645e69cf1..ca6bdc37e6d4 100644
--- a/include/tools/weakbase.hxx
+++ b/include/tools/weakbase.hxx
@@ -49,6 +49,7 @@ template< class reference_type >
 inline WeakReference< reference_type >::WeakReference( WeakReference< 
reference_type >&& rWeakRef )
 {
 mpWeakConnection = std::move(rWeakRef.mpWeakConnection);
+rWeakRef.reset();
 }
 
 template< class reference_type >
@@ -73,7 +74,13 @@ inline void WeakReference< reference_type >::reset( 
reference_type* pReference )
 if( pReference )
 mpWeakConnection = pReference->getWeakConnection();
 else
-mpWeakConnection = new WeakConnection;
+reset();
+}
+
+template< class reference_type >
+inline void WeakReference< reference_type >::reset()
+{
+mpWeakConnection = new WeakConnection;
 }
 
 template< class reference_type >
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 91b5ecbc8473..ac2695441575 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -57,6 +57,7 @@ public:
 void testDontSearchInMasterPages();
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
+void testSearchInPDFOnePDFObject();
 void testSearchInPDFInMultiplePages();
 void testSearchInPDFInMultiplePagesBackwards();
 void testSearchIn2MixedObjects();
@@ -71,6 +72,7 @@ public:
 CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
+CPPUNIT_TEST(testSearchInPDFOnePDFObject);
 CPPUNIT_TEST(testSearchInPDFInMultiplePages);
 CPPUNIT_TEST(testSearchInPDFInMultiplePagesBackwards);
 CPPUNIT_TEST(testSearchIn2MixedObjects);
@@ -342,6 +344,43 @@ void LOKitSearchTest::testSearchInPDF()
 #endif
 }
 
+void LOKitSearchTest::testSearchInPDFOnePDFObject()
+{
+#if HAVE_FEATURE_PDFIUM
+SdXImpressDocument* pXImpressDocument = createDoc("OnePDFObject.odg");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+SdrObject* pObject = 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - sd/qa sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |  196 +-
 sd/source/ui/view/Outliner.cxx|   21 ++
 2 files changed, 212 insertions(+), 5 deletions(-)

New commits:
commit da05adafeea785eea26cab98b77753341fc60f8b
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 13:28:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 22:52:26 2020 +0200

sd: add support to search backwards in PDF search

Change-Id: I2c7f75d16a430dcfa892d28fb6b4f64118705ad2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95459
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 7b2170f6239f0c4f16a1cbd3ec54a861405aa07a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95945
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 2c1e1c0426a3..8c2a41eeca9e 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -56,6 +56,7 @@ public:
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
 void testSearchInPDFInMultiplePages();
+void testSearchInPDFInMultiplePagesBackwards();
 void testSearchIn2MixedObjects();
 void testSearchIn6MixedObjects();
 
@@ -69,6 +70,7 @@ public:
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
 CPPUNIT_TEST(testSearchInPDFInMultiplePages);
+CPPUNIT_TEST(testSearchInPDFInMultiplePagesBackwards);
 CPPUNIT_TEST(testSearchIn2MixedObjects);
 CPPUNIT_TEST(testSearchIn6MixedObjects);
 CPPUNIT_TEST_SUITE_END();
@@ -123,14 +125,14 @@ LOKitSearchTest::createDoc(const char* pName, const 
uno::Sequence 
aPropertyValues(comphelper::InitPropertySequence({
 { "SearchItem.SearchString", uno::makeAny(rKey) },
-{ "SearchItem.Backward", uno::makeAny(false) },
+{ "SearchItem.Backward", uno::makeAny(bBackwards) },
 { "SearchItem.Command", uno::makeAny(sal_uInt16(eSearch)) },
 }));
 
@@ -422,6 +424,104 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 }
 
+void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Expected for backwards search is:
+// - Start with Page 1
+//   + search backwards through objects
+//   + inside objects search backwards through text
+// - Switch to Page 2
+//   + search backwards through objects
+//   + inside objects search backwards through text
+
+// Search for "him"
+lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 

[Libreoffice-commits] core.git: include/vcl svx/source vcl/Library_vcl.mk vcl/qa vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/filter/PDFiumLibrary.hxx   |   43 +
 svx/source/inc/svdpdf.hxx  |4 ++
 svx/source/svdraw/svdpdf.cxx   |   14 +
 vcl/Library_vcl.mk |1 
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   20 ++---
 vcl/source/filter/ipdf/pdfread.cxx |   26 +++--
 vcl/source/graphic/VectorGraphicSearch.cxx |   13 +++-
 vcl/source/pdf/PDFiumLibrary.cxx   |   36 
 8 files changed, 100 insertions(+), 57 deletions(-)

New commits:
commit 067a8a954c8e1d8d6465a4ab5fb61e93f16c26c2
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 11:50:20 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 13:32:01 2020 +0200

pdfium: only init pdfium library one and destroy on LO exit

With more and more usage of PDFium, it is hard to keep track of
the life-time of the PDFium library, so it can happen that a
FPDF_DestroyLibrary happens when we still have another instance
where PDFium is still use. The result of this is a crash. To
prevent this, just initialize the library once and delete, when
on LO exit.

This can be improved in the future to only keep the library
active when in actual use.

Change-Id: I5c7e5de7f8b97d10efb394c67c7a61b976c8d57c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95391
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
new file mode 100644
index ..bc7912c17e81
--- /dev/null
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 
+
+#if HAVE_FEATURE_PDFIUM
+
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+class VCL_DLLPUBLIC PDFium final
+{
+private:
+PDFium(const PDFium&) = delete;
+PDFium& operator=(const PDFium&) = delete;
+
+public:
+PDFium();
+~PDFium();
+};
+
+struct PDFiumLibrary : public rtl::StaticWithInit, 
PDFiumLibrary>
+{
+std::shared_ptr operator()() { return std::make_shared(); }
+};
+
+} // namespace vcl::pdf
+
+#endif // HAVE_FEATURE_PDFIUM
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index 9b48eb1d30c5..1f02b2151594 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -42,6 +42,8 @@
 #include 
 #include 
 
+#include 
+
 // Forward Declarations
 
 class SfxItemSet;
@@ -100,6 +102,8 @@ class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
 tools::Rectangle PointsToLogic(double left, double right, double top, 
double bottom) const;
 Point PointsToLogic(double x, double y) const;
 
+std::shared_ptr mpPDFium;
+
 // check for clip and evtl. fill maClip
 void checkClip();
 bool isClip() const;
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 5cd0c0765a29..188651be386c 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -116,6 +116,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
 , mnPageCount(0)
 , mdPageWidthPts(0)
 , mdPageHeightPts(0)
+, mpPDFium(vcl::pdf::PDFiumLibrary::get())
 {
 mpVD->EnableOutput(false);
 mpVD->SetLineColor();
@@ -129,13 +130,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
   svl::Items{});
 checkClip();
 
-FPDF_LIBRARY_CONFIG aConfig;
-aConfig.version = 2;
-aConfig.m_pUserFontPaths = nullptr;
-aConfig.m_pIsolate = nullptr;
-aConfig.m_v8EmbedderSlot = 0;
-FPDF_InitLibraryWithConfig();
-
 // Load the buffer using pdfium.
 auto const& rVectorGraphicData = rGraphic.getVectorGraphicData();
 mpPdfDocument = FPDF_LoadMemDocument(
@@ -170,11 +164,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
 mnPageCount = FPDF_GetPageCount(mpPdfDocument);
 }
 
-ImpSdrPdfImport::~ImpSdrPdfImport()
-{
-FPDF_CloseDocument(mpPdfDocument);
-FPDF_DestroyLibrary();
-}
+ImpSdrPdfImport::~ImpSdrPdfImport() { FPDF_CloseDocument(mpPdfDocument); }
 
 void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* 
pActionsToReport,
 int nPageIndex)
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index ccbe52b2902c..4ee0873bd189 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -318,6 +318,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/pdf/ResourceDict \
 vcl/source/pdf/Matrix3 

[Libreoffice-commits] core.git: sd/qa

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/sdmodeltestbase.hxx |   16 
 sd/qa/unit/tiledrendering/CallbackRecorder.hxx |3 +++
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx  |   18 +-
 3 files changed, 32 insertions(+), 5 deletions(-)

New commits:
commit 4dcc48f37248a1eb45188739de961689e7873f3c
Author: Tomaž Vajngerl 
AuthorDate: Sat May 30 13:10:04 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 13:27:18 2020 +0200

sd: improve the test for LOKit search in PDF graphic

Record how many times we het the search result back, so we can
be sure that the search happend and don't just read the old
values. Assert the search result selection rectangles and text
selection rectangles.

Add tools:Rectangle support for CPPUnit into sdmodeltestbase.hxx

Change-Id: I0b22d2d2f66abdc0dd0d5ac13a1bfebaa470749a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95383
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 6469eba789fe..08f66de864f1 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -483,6 +483,22 @@ template<> struct assertion_traits
 }
 };
 
+template<> struct assertion_traits
+{
+static bool equal( const tools::Rectangle& r1, const tools::Rectangle& r2 )
+{
+return r1 == r2;
+}
+
+static std::string toString( const tools::Rectangle& r)
+{
+OStringStream ost;
+ost << "Rect P: [" << r.Top() << ", " << r.Left() << "] "
+"S: [" << r.GetWidth() << ", " << r.GetHeight() << "]";
+return ost.str();
+}
+};
+
 CPPUNIT_NS_END
 
 #endif
diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx 
b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
index fc5117cce6dc..7e6c8a42d07d 100644
--- a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
+++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
@@ -51,6 +51,7 @@ struct CallbackRecorder
 , m_nPart(0)
 , m_nSelectionBeforeSearchResult(0)
 , m_nSelectionAfterSearchResult(0)
+, m_nSearchResultCount(0)
 {
 }
 
@@ -62,6 +63,7 @@ struct CallbackRecorder
 std::vector m_aSearchResultPart;
 int m_nSelectionBeforeSearchResult;
 int m_nSelectionAfterSearchResult;
+int m_nSearchResultCount;
 /// For document size changed callback.
 osl::Condition m_aDocumentSizeCondition;
 
@@ -115,6 +117,7 @@ struct CallbackRecorder
 break;
 case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
 {
+m_nSearchResultCount++;
 m_aSearchResultSelection.clear();
 m_aSearchResultPart.clear();
 boost::property_tree::ptree aTree;
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 33257f12d4ab..8d8b11e43fa1 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -292,21 +292,29 @@ void LOKitSearchTest::testSearchInPDF()
 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
  pVectorGraphicData->getVectorGraphicDataType());
 
+// Search
 lcl_search("ABC");
 
 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
 
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
+ mpCallbackRecorder->m_aSelection[0]);
 
-CPPUNIT_ASSERT_EQUAL(long(3763), 
mpCallbackRecorder->m_aSelection[0].Left());
-CPPUNIT_ASSERT_EQUAL(long(1331), 
mpCallbackRecorder->m_aSelection[0].Top());
-CPPUNIT_ASSERT_EQUAL(long(1433), 
mpCallbackRecorder->m_aSelection[0].GetWidth());
-CPPUNIT_ASSERT_EQUAL(long(484), 
mpCallbackRecorder->m_aSelection[0].GetHeight());
-
+// Search again - same result
 lcl_search("ABC");
+
 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
 
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
+ mpCallbackRecorder->m_aSelection[0]);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|   12 +++-
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   79 +
 vcl/source/graphic/VectorGraphicSearch.cxx |   28 +++---
 3 files changed, 90 insertions(+), 29 deletions(-)

New commits:
commit 83d27791fed75941c75d3cc571c3d5cf27d14e8c
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 23:52:50 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 13:26:40 2020 +0200

vcl: add search start position support for VectorGraphicSearch

By default we start at the begin of the page, but with this change
make it possible to start at the end. This makes it possible to
search in the backwards direction (set the start position at to
the end and search with "previous").

Change-Id: I78fb1461b86bf9eab2f91c3b9a81cbb5c6557332
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95382
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index a00c212ad61c..b67c63a844d8 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -21,6 +21,12 @@
 
 class SearchContext;
 
+enum class SearchStartPosition
+{
+Begin,
+End
+};
+
 class VCL_DLLPUBLIC VectorGraphicSearch final
 {
 private:
@@ -29,12 +35,14 @@ private:
 Graphic maGraphic;
 std::unique_ptr mpSearchContext;
 
-bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString);
+bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString,
+   SearchStartPosition eStartPosition);
 
 public:
 VectorGraphicSearch(Graphic const& rGraphic);
 ~VectorGraphicSearch();
-bool search(OUString const& rSearchString);
+bool search(OUString const& rSearchString,
+SearchStartPosition eStartPosition = 
SearchStartPosition::Begin);
 basegfx::B2DSize pageSize();
 bool next();
 bool previous();
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 7962c23f4e8f..5f65b4ba7e3d 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -93,32 +93,71 @@ void VectorGraphicSearchTest::testNextPrevious()
 Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
 aGraphic.makeAvailable();
 
-VectorGraphicSearch aSearch(aGraphic);
-CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
+{ // Start from the beginning of the page
+VectorGraphicSearch aSearch(aGraphic);
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
 
-// next - first match found
-CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+// no previous - we are at the begin
+CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(0, aSearch.index()); // nothing was yet found, so 
it is 0
 
-// next - second match found
-CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+// next - first position found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
 
-// next - not found, index unchanged
-CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+// next - second position found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
 
-// previous - first match
-CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
-CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+// next - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
 
-// previous - not found, index unchanged
-CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
-CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+// previous - first position
+CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
 
-// next - second match found
-CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+// previous - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// next - second position found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+}
+
+{ // Start from the end of the page
+VectorGraphicSearch aSearch(aGraphic);
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy", 
SearchStartPosition::End));
+
+// no next - we are at the end
+CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(0, aSearch.index()); // nothing was yet found, so 
it is 0
+
+// previous - second 

[Libreoffice-commits] core.git: vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/graphic/VectorGraphicSearch.cxx |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit 40d682542f02d78b5ed6bd4fc0ba461a1a7fb5f1
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 09:51:33 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 13:28:21 2020 +0200

vcl: VectorGraphicSearch - clean-up SearchContext member vars.

Change-Id: I1740be5ed1b47235da3794fa46e3533b17ca1fb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95390
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index 76e8c59404a9..fc7c9257e1f8 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -34,26 +34,26 @@ public:
 
 class SearchContext
 {
-public:
-bool bInitialized = false;
-
+private:
 FPDF_DOCUMENT mpPdfDocument;
-sal_Int32 mnPageIndex;
 FPDF_PAGE mpPage;
 FPDF_TEXTPAGE mpTextPage;
+FPDF_SCHHANDLE mpSearchHandle;
+
+public:
+sal_Int32 mnPageIndex;
 OUString maSearchString;
 SearchStartPosition meStartPosition;
-FPDF_SCHHANDLE mpSearchHandle;
 
 SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex, OUString 
const& rSearchString,
   SearchStartPosition eStartPosition)
 : mpPdfDocument(pPdfDocument)
-, mnPageIndex(nPageIndex)
 , mpPage(nullptr)
 , mpTextPage(nullptr)
+, mpSearchHandle(nullptr)
+, mnPageIndex(nPageIndex)
 , maSearchString(rSearchString)
 , meStartPosition(eStartPosition)
-, mpSearchHandle(nullptr)
 {
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   16 
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx|6 ++
 2 files changed, 22 insertions(+)

New commits:
commit 80afeb83ed90995fde0d2275b9146462920cfd07
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 12:31:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 12:31:34 2020 +0200

sd: disable LOKitSearchTest that test PDF search if no PDFium

enclose the tests with HAVE_FEATURE_PDFIUM

Change-Id: I1ce97fe090cef2cc2ab2f25fd1d2698bcaf28222

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8c2a41eeca9e..91b5ecbc8473 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -8,6 +8,8 @@
  */
 
 #include "../sdmodeltestbase.hxx"
+#include 
+
 #include "CallbackRecorder.hxx"
 
 #include 
@@ -140,6 +142,7 @@ void lcl_search(const OUString& rKey, bool bFindAll = 
false, bool bBackwards = f
 Scheduler::ProcessEventsToIdle();
 }
 
+#if HAVE_FEATURE_PDFIUM
 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 {
 SdrView* pSdrView = pViewShell->GetView();
@@ -148,6 +151,7 @@ SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
 return pObject;
 }
+#endif
 
 } // end anonymous namespace
 
@@ -262,6 +266,7 @@ void LOKitSearchTest::testDontSearchInMasterPages()
 
 void LOKitSearchTest::testSearchInPDFNonExisting()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -285,10 +290,12 @@ void LOKitSearchTest::testSearchInPDFNonExisting()
 lcl_search("NonExisting");
 
 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDF()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -332,10 +339,12 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
  mpCallbackRecorder->m_aSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePages()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -422,10 +431,12 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -520,12 +531,14 @@ void 
LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchIn2MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -606,11 +619,13 @@ void LOKitSearchTest::testSearchIn2MixedObjects()
 
 CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
 void LOKitSearchTest::testSearchIn6MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -770,6 +785,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
+#endif
 }
 
 

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 38 commits - accessibility/source avmedia/source basctl/source basic/qa chart2/qa comphelper/qa comphelper/source compilerplugins/cl

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit a342960ac2122c8ceb544f1544ad17c3d907641a
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 12:31:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 14:05:35 2020 +0200

sd: disable LOKitSearchTest that test PDF search if no PDFium

enclose the tests with HAVE_FEATURE_PDFIUM

Change-Id: I1ce97fe090cef2cc2ab2f25fd1d2698bcaf28222

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8c2a41eeca9e..91b5ecbc8473 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -8,6 +8,8 @@
  */
 
 #include "../sdmodeltestbase.hxx"
+#include 
+
 #include "CallbackRecorder.hxx"
 
 #include 
@@ -140,6 +142,7 @@ void lcl_search(const OUString& rKey, bool bFindAll = 
false, bool bBackwards = f
 Scheduler::ProcessEventsToIdle();
 }
 
+#if HAVE_FEATURE_PDFIUM
 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 {
 SdrView* pSdrView = pViewShell->GetView();
@@ -148,6 +151,7 @@ SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
 return pObject;
 }
+#endif
 
 } // end anonymous namespace
 
@@ -262,6 +266,7 @@ void LOKitSearchTest::testDontSearchInMasterPages()
 
 void LOKitSearchTest::testSearchInPDFNonExisting()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -285,10 +290,12 @@ void LOKitSearchTest::testSearchInPDFNonExisting()
 lcl_search("NonExisting");
 
 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDF()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -332,10 +339,12 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
  mpCallbackRecorder->m_aSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePages()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -422,10 +431,12 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -520,12 +531,14 @@ void 
LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchIn2MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -606,11 +619,13 @@ void LOKitSearchTest::testSearchIn2MixedObjects()
 
 CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
 void LOKitSearchTest::testSearchIn6MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -770,6 +785,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));
+#endif
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
commit 6c17eede288826982b9850b23d8be39a6d3a5e80
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 12:23:57 2020 +0200
Commit: 

[Libreoffice-commits] core.git: include/vcl vcl/qa vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|1 
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   40 +
 vcl/source/graphic/VectorGraphicSearch.cxx |   14 ++
 3 files changed, 55 insertions(+)

New commits:
commit e20440effc7a47c8a5e8ef0943e6872cd9b3646a
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 23:26:51 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 09:56:20 2020 +0200

vcl: add "previous" search to VectorGraphicSearch

Previous moves backwards in the search matches.

Change-Id: I88d402e0b8cb9dc4fd93e7f1ce5b08fb42aadd06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95381
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 5420e161448b..a00c212ad61c 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -37,6 +37,7 @@ public:
 bool search(OUString const& rSearchString);
 basegfx::B2DSize pageSize();
 bool next();
+bool previous();
 int index();
 std::vector getTextRectangles();
 };
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 01022a3fe225..7962c23f4e8f 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -26,9 +26,11 @@ class VectorGraphicSearchTest : public 
test::BootstrapFixtureBase
 }
 
 void test();
+void testNextPrevious();
 
 CPPUNIT_TEST_SUITE(VectorGraphicSearchTest);
 CPPUNIT_TEST(test);
+CPPUNIT_TEST(testNextPrevious);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -81,6 +83,44 @@ void VectorGraphicSearchTest::test()
 CPPUNIT_ASSERT_DOUBLES_EQUAL(6381.04, aRectangles[3].getMaxY(), 1E-2);
 }
 
+// Test next and previous work as expected to move
+// between search matches.
+void VectorGraphicSearchTest::testNextPrevious()
+{
+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"));
+
+// next - first match found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// next - second match found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+// next - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+// previous - first match
+CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// previous - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// next - second match found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, 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 36eeae6d2a6c..dd37c9fc98cf 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -103,6 +103,13 @@ public:
 return false;
 }
 
+bool previous()
+{
+if (mpSearchHandle)
+return FPDFText_FindPrev(mpSearchHandle);
+return false;
+}
+
 int index()
 {
 if (mpSearchHandle)
@@ -244,6 +251,13 @@ bool VectorGraphicSearch::next()
 return false;
 }
 
+bool VectorGraphicSearch::previous()
+{
+if (mpSearchContext)
+return mpSearchContext->previous();
+return false;
+}
+
 int VectorGraphicSearch::index()
 {
 if (mpSearchContext)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sd/qa

2020-06-04 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   16 
 1 file changed, 16 insertions(+)

New commits:
commit 25da71b489228b866f20d8ea6d1926128168d1fa
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 12:31:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 17:01:57 2020 +0200

sd: disable LOKitSearchTest that test PDF search if no PDFium

enclose the tests with HAVE_FEATURE_PDFIUM

Change-Id: I1ce97fe090cef2cc2ab2f25fd1d2698bcaf28222
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95463
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8c2a41eeca9e..91b5ecbc8473 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -8,6 +8,8 @@
  */
 
 #include "../sdmodeltestbase.hxx"
+#include 
+
 #include "CallbackRecorder.hxx"
 
 #include 
@@ -140,6 +142,7 @@ void lcl_search(const OUString& rKey, bool bFindAll = 
false, bool bBackwards = f
 Scheduler::ProcessEventsToIdle();
 }
 
+#if HAVE_FEATURE_PDFIUM
 SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 {
 SdrView* pSdrView = pViewShell->GetView();
@@ -148,6 +151,7 @@ SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
 SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
 return pObject;
 }
+#endif
 
 } // end anonymous namespace
 
@@ -262,6 +266,7 @@ void LOKitSearchTest::testDontSearchInMasterPages()
 
 void LOKitSearchTest::testSearchInPDFNonExisting()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -285,10 +290,12 @@ void LOKitSearchTest::testSearchInPDFNonExisting()
 lcl_search("NonExisting");
 
 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDF()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -332,10 +339,12 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
  mpCallbackRecorder->m_aSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePages()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -422,10 +431,12 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -520,12 +531,14 @@ void 
LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
 CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
 CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchIn2MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -606,11 +619,13 @@ void LOKitSearchTest::testSearchIn2MixedObjects()
 
 CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
  mpCallbackRecorder->m_aSearchResultSelection[0]);
+#endif
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
 void LOKitSearchTest::testSearchIn6MixedObjects()
 {
+#if HAVE_FEATURE_PDFIUM
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
 CPPUNIT_ASSERT(pViewShell);
@@ -770,6 +785,7 @@ void LOKitSearchTest::testSearchIn6MixedObjects()
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
 CPPUNIT_ASSERT_EQUAL(pPage->GetObj(0), lclGetSelectedObject(pViewShell));

[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 'distro/collabora/cp-6.4' - filter/source include/vcl offapi/com sd/qa vcl/inc vcl/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 filter/source/pdf/pdfdecomposer.cxx|   28 
 include/vcl/graph.hxx  |2 -
 include/vcl/vectorgraphicdata.hxx  |   12 +---
 offapi/com/sun/star/graphic/XPdfDecomposer.idl |8 +
 sd/qa/unit/import-tests.cxx|   15 ++-
 vcl/inc/impgraph.hxx   |7 +
 vcl/source/filter/ipdf/pdfread.cxx |   18 +++--
 vcl/source/gdi/graph.cxx   |7 -
 vcl/source/gdi/impgraph.cxx|   34 ++---
 vcl/source/gdi/vectorgraphicdata.cxx   |   22 
 10 files changed, 85 insertions(+), 68 deletions(-)

New commits:
commit c298489ba242b298e09e78069587e6f4707614af
Author: Tomaž Vajngerl 
AuthorDate: Fri Mar 13 20:04:45 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:24:24 2020 +0200

pdfium: support for pages when using PDF import with pdfium

Moving PDF to use VectorGraphicData in Graphic has temporary
removed the support for showing different PDF pages when opening
the PDF using pdfium (LO_IMPORT_USE_PDFIUM=1).
This adds the support for back by specifying whcih PDF page to
render when creating the VectorGraphicData (and can't be changd
afterwards), which is used to create a Graphic and contains the
PDF source data array.

Change-Id: Ib915216b8d4c0c063d0fead44ff156b1915a35d2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90562
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 27ee05f860e8225a41e15e0853fcef00a9d7a621)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95628
Tested-by: Tomaž Vajngerl 

diff --git a/filter/source/pdf/pdfdecomposer.cxx 
b/filter/source/pdf/pdfdecomposer.cxx
index c926b1b35a9d..a03e70bd5d1a 100644
--- a/filter/source/pdf/pdfdecomposer.cxx
+++ b/filter/source/pdf/pdfdecomposer.cxx
@@ -39,8 +39,9 @@ public:
 XPdfDecomposer& operator=(const XPdfDecomposer&) = delete;
 
 // XPdfDecomposer
-uno::Sequence>
-SAL_CALL getDecomposition(const uno::Sequence& xPdfData) 
override;
+uno::Sequence> SAL_CALL
+getDecomposition(const uno::Sequence& xPdfData,
+ const uno::Sequence& 
xDecompositionParameters) override;
 
 // XServiceInfo
 OUString SAL_CALL getImplementationName() override;
@@ -50,12 +51,27 @@ public:
 
 XPdfDecomposer::XPdfDecomposer(uno::Reference const&) 
{}
 
-uno::Sequence>
-SAL_CALL XPdfDecomposer::getDecomposition(const uno::Sequence& 
xPdfData)
+uno::Sequence> SAL_CALL 
XPdfDecomposer::getDecomposition(
+const uno::Sequence& xPdfData, const 
uno::Sequence& xParameters)
 {
+sal_Int32 nPageIndex = -1;
+
+for (sal_Int32 index = 0; index < xParameters.getLength(); index++)
+{
+const beans::PropertyValue& rProperty = xParameters[index];
+
+if (rProperty.Name == "PageIndex")
+{
+rProperty.Value >>= nPageIndex;
+}
+}
+
+if (nPageIndex < 0)
+nPageIndex = 0;
+
 std::vector aBitmaps;
-vcl::RenderPDFBitmaps(xPdfData.getConstArray(), xPdfData.getLength(), 
aBitmaps, 0,
-  1 /*, fResolutionDPI*/);
+vcl::RenderPDFBitmaps(xPdfData.getConstArray(), xPdfData.getLength(), 
aBitmaps, nPageIndex, 1);
+
 BitmapEx aReplacement(aBitmaps[0]);
 
 // short form for scale and translate transformation
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index 6e372a0bbaf9..fda9027cbd1f 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -204,8 +204,6 @@ public:
 
 const VectorGraphicDataPtr& getVectorGraphicData() const;
 
-/// Set the page number of the multi-page source this Graphic is rendered 
from.
-void setPageNumber(sal_Int32 nPageNumber);
 /// Get the page number of the multi-page source this Graphic is rendered 
from.
 sal_Int32 getPageNumber() const;
 
diff --git a/include/vcl/vectorgraphicdata.hxx 
b/include/vcl/vectorgraphicdata.hxx
index ce79961b5364..86b0e6e1ad2f 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -70,6 +70,9 @@ private:
 // extra:
 std::unique_ptr mpExternalHeader;
 
+// If the vector format has more pages this denotes which page to render
+sal_Int32 mnPageIndex;
+
 // on demand creators
 void ensurePdfReplacement();
 void ensureReplacement();
@@ -82,10 +85,9 @@ public:
 VectorGraphicData(
 const VectorGraphicDataArray& rVectorGraphicDataArray,
 const OUString& rPath,
-VectorGraphicDataType eVectorDataType);
-VectorGraphicData(
-const OUString& rPath,
-VectorGraphicDataType eVectorDataType);
+VectorGraphicDataType eVectorDataType,
+sal_Int32 nPageIndex = -1);
+VectorGraphicData(const OUString& rPath, VectorGraphicDataType 
eVectorDataType);
 ~VectorGraphicData();
 
 /// compare op
@@ 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/inc vcl/Library_vcl.mk vcl/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/graph.hxx |   24 --
 vcl/Library_vcl.mk|1 
 vcl/inc/graphic/GraphicReader.hxx |   51 ++
 vcl/source/filter/graphicfilter.cxx   |1 
 vcl/source/filter/igif/gifread.cxx|1 
 vcl/source/filter/ixbm/xbmread.cxx|1 
 vcl/source/filter/ixpm/xpmread.cxx|1 
 vcl/source/filter/jpeg/JpegReader.hxx |1 
 vcl/source/gdi/impgraph.cxx   |   35 -
 vcl/source/graphic/GraphicReader.cxx  |   56 ++
 10 files changed, 114 insertions(+), 58 deletions(-)

New commits:
commit 9103f62a0d2bf61b2135dd017e279cb95a399032
Author: Tomaž Vajngerl 
AuthorDate: Mon Feb 10 18:27:23 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:22:58 2020 +0200

move GraphicReader class out of graph.hxx

Change-Id: Id78995bfb8e8308a388ed542690ad85e4d19ce12
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88425
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 203aba33e6631315c735f6d42ad2c088a973)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95615
Tested-by: Tomaž Vajngerl 

diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index a30b3909e899..c1fadb49d9cb 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -32,7 +32,6 @@
 #include 
 #include 
 
-
 enum class GraphicType
 {
 NONE,
@@ -49,28 +48,7 @@ class GDIMetaFile;
 class SvStream;
 class ImpGraphic;
 class OutputDevice;
-class ReaderData;
-
-class GraphicReader
-{
-public:
-virtual ~GraphicReader();
-
-const OUString& GetUpperFilterName() const { return maUpperName; }
-
-// TODO: when incompatible changes are possible again
-// the preview size hint should be redone
-voidDisablePreviewMode();
-voidSetPreviewSize( const Size& );
-SizeGetPreviewSize() const;
-
-protected:
-OUStringmaUpperName;
-
-GraphicReader();
-private:
-std::unique_ptr   mpReaderData;
-};
+class GraphicReader;
 
 class VCL_DLLPUBLIC GraphicConversionParameters
 {
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 1a6fdce0d48b..a88bec146536 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -319,6 +319,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/graphic/GraphicLoader \
 vcl/source/graphic/GraphicObject \
 vcl/source/graphic/GraphicObject2 \
+vcl/source/graphic/GraphicReader \
 vcl/source/graphic/grfattr \
 vcl/source/graphic/Manager \
 vcl/source/graphic/UnoGraphic \
diff --git a/vcl/inc/graphic/GraphicReader.hxx 
b/vcl/inc/graphic/GraphicReader.hxx
new file mode 100644
index ..fe60ecf97b29
--- /dev/null
+++ b/vcl/inc/graphic/GraphicReader.hxx
@@ -0,0 +1,51 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+#include 
+
+class ReaderData;
+
+class GraphicReader
+{
+public:
+virtual ~GraphicReader();
+
+const OUString& GetUpperFilterName() const { return maUpperName; }
+
+// TODO: when incompatible changes are possible again
+// the preview size hint should be redone
+void DisablePreviewMode();
+void SetPreviewSize(const Size&);
+Size GetPreviewSize() const;
+
+protected:
+OUString maUpperName;
+
+GraphicReader();
+
+private:
+std::unique_ptr mpReaderData;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index d1bd6cff4508..102e1de028b0 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -71,6 +71,7 @@
 #include "graphicfilter_internal.hxx"
 
 #include 
+#include 
 
 #define PMGCHUNG_msOG   0x6d734f47  // Microsoft Office Animated GIF
 
diff --git a/vcl/source/filter/igif/gifread.cxx 
b/vcl/source/filter/igif/gifread.cxx
index 6bd2290f777f..a3b301d3aeed 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -23,6 +23,7 @@
 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl sd/qa

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/vectorgraphicdata.hxx |2 ++
 sd/qa/unit/data/pdf/multipage.pdf |binary
 sd/qa/unit/import-tests.cxx   |4 +++-
 3 files changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 125eda6df4267541177a9b25aa0f1d7c140a49a9
Author: Tomaž Vajngerl 
AuthorDate: Thu Mar 26 12:25:10 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:25:31 2020 +0200

sd: extend test to check the PDF pages aren't rendered when loaded

Change-Id: I9e407bb20a00ec620fe3f772f50708f997027942
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91093
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 56a1f9bea2f1b64dee4111ec6671caf42ef63c91)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95631
Tested-by: Tomaž Vajngerl 

diff --git a/include/vcl/vectorgraphicdata.hxx 
b/include/vcl/vectorgraphicdata.hxx
index 86b0e6e1ad2f..28828426ac2e 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -111,6 +111,8 @@ public:
 BitmapChecksum GetChecksum() const;
 
 sal_Int32 getPageIndex() const { return mnPageIndex; }
+
+bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
 };
 
 typedef std::shared_ptr< VectorGraphicData > VectorGraphicDataPtr;
diff --git a/sd/qa/unit/data/pdf/multipage.pdf 
b/sd/qa/unit/data/pdf/multipage.pdf
index 5cd8b4e4e569..65c8eeaa32a5 100644
Binary files a/sd/qa/unit/data/pdf/multipage.pdf and 
b/sd/qa/unit/data/pdf/multipage.pdf differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 006adedcd588..bd719567104c 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -1283,11 +1283,13 @@ void SdImportTest::testPDFImportShared()
 
 const GraphicObject& rGraphicObject = 
pSdrGrafObj->GetGraphicObject().GetGraphic();
 const Graphic& rGraphic = rGraphicObject.GetGraphic();
+CPPUNIT_ASSERT_MESSAGE("After loading, the PDF shouldn't have the 
primitive sequence created yet",
+   
!rGraphic.getVectorGraphicData()->isPrimitiveSequenceCreated());
 aGraphics.push_back(rGraphic);
 }
 }
 
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(3), 
aGraphics.size());
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(9), 
aGraphics.size());
 
 Graphic const & rFirstGraphic = aGraphics[0];
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/inc vcl/Library_vcl.mk vcl/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 vcl/Library_vcl.mk   |1 
 vcl/inc/graphic/GraphicID.hxx|   47 
 vcl/inc/impgraph.hxx |   21 ---
 vcl/source/gdi/impgraph.cxx  |   83 
 vcl/source/graphic/GraphicID.cxx |  112 +++
 5 files changed, 161 insertions(+), 103 deletions(-)

New commits:
commit e8b78a64a635b8599df0b3d35d1726f31c2e8560
Author: Tomaž Vajngerl 
AuthorDate: Mon Feb 24 23:02:20 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:23:18 2020 +0200

vcl: move GraphicID out of impgraph.{cxx,hxx}

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89449
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit b6bc43f354bcbe6a98db9fb372fd47bc5b23f4d8)

Change-Id: I0b3b17736a76be290f6e5b77ee547b7e650d4489
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95616
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index a88bec146536..06df252a7c26 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -316,6 +316,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
 vcl/source/gdi/scrptrun \
 vcl/source/gdi/CommonSalLayout \
 vcl/source/gdi/TypeSerializer \
+vcl/source/graphic/GraphicID \
 vcl/source/graphic/GraphicLoader \
 vcl/source/graphic/GraphicObject \
 vcl/source/graphic/GraphicObject2 \
diff --git a/vcl/inc/graphic/GraphicID.hxx b/vcl/inc/graphic/GraphicID.hxx
new file mode 100644
index ..87ac6a50f37a
--- /dev/null
+++ b/vcl/inc/graphic/GraphicID.hxx
@@ -0,0 +1,47 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+#include 
+#include 
+#include 
+
+class ImpGraphic;
+
+class GraphicID
+{
+private:
+sal_uInt32 mnID1;
+sal_uInt32 mnID2;
+sal_uInt32 mnID3;
+BitmapChecksum mnID4;
+
+public:
+GraphicID(ImpGraphic const& rGraphic);
+
+bool operator==(const GraphicID& rID) const
+{
+return rID.mnID1 == mnID1 && rID.mnID2 == mnID2 && rID.mnID3 == mnID3 
&& rID.mnID4 == mnID4;
+}
+
+OString getIDString() const;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 159b70a691e0..62a44b7e17a9 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include "graphic/Manager.hxx"
+#include "graphic/GraphicID.hxx"
 
 struct ImpSwapInfo
 {
@@ -45,26 +46,6 @@ struct ImpSwapFile;
 class GraphicConversionParameters;
 class ImpGraphic;
 
-class GraphicID
-{
-private:
-sal_uInt32  mnID1;
-sal_uInt32  mnID2;
-sal_uInt32  mnID3;
-BitmapChecksum  mnID4;
-
-public:
-GraphicID(ImpGraphic const & rGraphic);
-
-bool operator==(const GraphicID& rID) const
-{
-return rID.mnID1 == mnID1 && rID.mnID2 == mnID2 &&
-   rID.mnID3 == mnID3 && rID.mnID4 == mnID4;
-}
-
-OString getIDString() const;
-};
-
 class ImpGraphic final
 {
 friend class Graphic;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 673efbe26b45..e55fb7f12395 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -69,89 +69,6 @@ struct ImpSwapFile
 ~ImpSwapFile();
 };
 
-GraphicID::GraphicID(ImpGraphic const & rGraphic)
-{
-rGraphic.ensureAvailable();
-
-mnID1 = static_cast(rGraphic.ImplGetType()) << 28;
-mnID2 = mnID3 = mnID4 = 0;
-
-if (rGraphic.ImplGetType() == GraphicType::Bitmap)
-{
-if (rGraphic.getVectorGraphicData().get())
-{
-const VectorGraphicDataPtr& rVectorGraphicDataPtr = 
rGraphic.getVectorGraphicData();
-const basegfx::B2DRange& rRange = 
rVectorGraphicDataPtr->getRange();
-
-mnID1 |= rVectorGraphicDataPtr->getVectorGraphicDataArrayLength();
-mnID2 = basegfx::fround(rRange.getWidth());
-mnID3 = basegfx::fround(rRange.getHeight());
-mnID4 = vcl_get_checksum(0, 
rVectorGraphicDataPtr->getVectorGraphicDataArray().getConstArray(), 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - svx/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 svx/source/svdraw/svdedtv2.cxx |   17 -
 svx/source/svdraw/svdpdf.cxx   |   13 -
 svx/source/svdraw/svdpdf.hxx   |8 +---
 3 files changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 90922a7b4485d7dac7666ee7e44eda2eee916dc0
Author: Tomaž Vajngerl 
AuthorDate: Fri Mar 27 20:14:39 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:27:01 2020 +0200

pdfium: make breaking of PDF graphic work again

Changing PDF to use VectorGraphicData deleted the calls which
triggered the breaking of the PDF. This change makes breaking
work again.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91234
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit f265b14d6f8e3e63260b3c8ecce48d4251288fea)

Change-Id: I1d817f1556e37fcbcc3d2850b690eb0810676fa5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95635
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 4531aa511579..7eab69f7bb5b 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -52,6 +52,7 @@
 #include 
 #include 
 #include 
+#include 
 
 using ::std::vector;
 using namespace com::sun::star;
@@ -2095,7 +2096,21 @@ void SdrEditView::DoImportMarkedMtf(SvdProgressInfo 
*pProgrInfo)
 SdrGrafObj*  pGraf = dynamic_cast( pObj );
 if (pGraf != nullptr)
 {
-if (pGraf->HasGDIMetaFile() || 
pGraf->isEmbeddedVectorGraphicData())
+Graphic aGraphic = pGraf->GetGraphic();
+auto const & pVectorGraphicData = aGraphic.getVectorGraphicData();
+
+if (pVectorGraphicData && 
pVectorGraphicData->getVectorGraphicDataType() == VectorGraphicDataType::Pdf)
+{
+#if HAVE_FEATURE_PDFIUM
+aLogicRect = pGraf->GetLogicRect();
+ImpSdrPdfImport aFilter(*mpModel, pObj->GetLayer(), 
aLogicRect, aGraphic);
+if (pGraf->getEmbeddedPageNumber() < aFilter.GetPageCount())
+{
+nInsCnt = aFilter.DoImport(*pOL, nInsPos, 
aGraphic.getPageNumber(), pProgrInfo);
+}
+#endif // HAVE_FEATURE_PDFIUM
+}
+else if (pGraf->HasGDIMetaFile() || 
pGraf->isEmbeddedVectorGraphicData() )
 {
 GDIMetaFile aMetaFile(GetMetaFile(pGraf));
 if (aMetaFile.GetActionSize())
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index b392e9523f79..415c6e3dc7df 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -29,6 +29,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -118,11 +119,11 @@ struct FPDFBitmapDeleter
 using namespace com::sun::star;
 
 ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const 
tools::Rectangle& rRect,
- const std::shared_ptr>& 
pPdfData)
-: maTmpList()
+ Graphic const& rGraphic)
+: mrGraphic(rGraphic)
+, maTmpList()
 , mpVD(VclPtr::Create())
 , maScaleRect(rRect)
-, mpPdfData(pPdfData)
 , mnMapScalingOfs(0)
 , mpModel()
 , mnLayer(nLay)
@@ -166,8 +167,10 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
 FPDF_InitLibraryWithConfig();
 
 // Load the buffer using pdfium.
-mpPdfDocument = FPDF_LoadMemDocument(mpPdfData->data(), mpPdfData->size(),
- /*password=*/nullptr);
+auto const& rVectorGraphicData = mrGraphic.getVectorGraphicData();
+mpPdfDocument = FPDF_LoadMemDocument(
+rVectorGraphicData->getVectorGraphicDataArray().getConstArray(),
+rVectorGraphicData->getVectorGraphicDataArrayLength(), 
/*password=*/nullptr);
 if (!mpPdfDocument)
 {
 //TODO: Handle failure to load.
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 70b5a44e4ddf..1005b081142a 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -158,10 +159,10 @@ class ImpSdrPdfImport final
 double ma, mb, mc, md, me, mf;
 };
 
-::std::vector maTmpList;
+Graphic const& mrGraphic;
+std::vector maTmpList;
 ScopedVclPtr mpVD;
 tools::Rectangle const maScaleRect;
-const std::shared_ptr> mpPdfData;
 size_t mnMapScalingOfs; // from here on, not edited with MapScaling
 std::unique_ptr mpLineAttr;
 std::unique_ptr mpFillAttr;
@@ -233,7 +234,8 @@ class ImpSdrPdfImport final
 
 public:
 ImpSdrPdfImport(SdrModel& rModel, SdrLayerID nLay, const tools::Rectangle& 
rRect,
-const std::shared_ptr>& pPdfData);
+Graphic const& rGraphic);
+
 ~ImpSdrPdfImport();
 
 int GetPageCount() const { return mnPageCount; }

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/basegfx svx/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/basegfx/matrix/Matrix.hxx |  126 ++
 svx/source/svdraw/svdpdf.hxx  |  106 ---
 2 files changed, 128 insertions(+), 104 deletions(-)

New commits:
commit 67437d2f41b4fab475c0351c6336968dff0c5103
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 28 18:00:22 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:27:30 2020 +0200

svdpdf: move Matrix to basegfx just to get it separated

Change-Id: I9d887dc7a2836b90151ef352b47a9b9ad3b6f12b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91280
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit befd6880873cc3f63a0566b76246d2ae54f8a3c5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95636
Tested-by: Tomaž Vajngerl 

diff --git a/include/basegfx/matrix/Matrix.hxx 
b/include/basegfx/matrix/Matrix.hxx
new file mode 100644
index ..b742d8cdf293
--- /dev/null
+++ b/include/basegfx/matrix/Matrix.hxx
@@ -0,0 +1,126 @@
+/* -*- 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 .
+ */
+
+#pragma once
+
+class Matrix
+{
+public:
+Matrix()
+: Matrix(1, 0, 0, 1, 0, 0)
+{
+}
+
+Matrix(const Matrix& other)
+: Matrix(other.ma, other.mb, other.mc, other.md, other.me, other.mf)
+{
+}
+
+Matrix(double da, double db, double dc, double dd, double de, double df)
+: ma(da)
+, mb(db)
+, mc(dc)
+, md(dd)
+, me(de)
+, mf(df)
+{
+}
+
+const Matrix& operator=(const Matrix& other)
+{
+ma = other.ma;
+mb = other.mb;
+mc = other.mc;
+md = other.md;
+me = other.me;
+mf = other.mf;
+return *this;
+}
+
+double a() const { return ma; }
+double b() const { return mb; }
+double c() const { return mc; }
+double d() const { return md; }
+double e() const { return me; }
+double f() const { return mf; }
+
+/// Multiply this * other.
+void Concatinate(const Matrix& other)
+{
+ma = ma * other.ma + mb * other.mc;
+mb = ma * other.mb + mb * other.md;
+mc = mc * other.ma + md * other.mc;
+md = mc * other.mb + md * other.md;
+me = me * other.ma + mf * other.mc + other.me;
+mf = me * other.mb + mf * other.md + other.mf;
+}
+
+/// Transform the point (x, y) by this Matrix.
+template  void Transform(T& x, T& y)
+{
+x = ma * x + mc * y + me;
+y = mb * x + md * y + mf;
+}
+
+/// Transform the rectangle (left, right, top, bottom) by this Matrix.
+template  void Transform(T& left, T& right, T& top, T& bottom)
+{
+T leftTopX = left;
+T leftTopY = top;
+Transform(leftTopX, leftTopY);
+
+T leftBottomX = left;
+T leftBottomY = bottom;
+Transform(leftBottomX, leftBottomY);
+
+T rightTopX = right;
+T rightTopY = top;
+Transform(rightTopX, rightTopY);
+
+T rightBottomX = right;
+T rightBottomY = bottom;
+Transform(rightBottomX, rightBottomY);
+
+left = std::min(leftTopX, leftBottomX);
+right = std::max(rightTopX, rightBottomX);
+
+if (top > bottom)
+top = std::max(leftTopY, rightTopY);
+else
+top = std::min(leftTopY, rightTopY);
+
+if (top > bottom)
+bottom = std::max(leftBottomY, rightBottomY);
+else
+bottom = std::min(leftBottomY, rightBottomY);
+}
+
+std::string toString() const
+{
+std::ostringstream oss;
+oss << '(' << ma << ", " << mb << ", " << mc << ", " << md << ", " << 
me << ", " << mf
+<< ')';
+return oss.str();
+}
+
+private:
+double ma, mb, mc, md, me, mf;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/svdraw/svdpdf.hxx
index 1005b081142a..40e835bb67a4 100644
--- a/svx/source/svdraw/svdpdf.hxx
+++ b/svx/source/svdraw/svdpdf.hxx
@@ -37,6 +37,8 @@
 #include 
 #include 
 
+#include 
+
 // Prevent 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - svx/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 svx/source/svdraw/svdograf.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 6e5cc0932a5fddc7dbd588de3b3dcae563ecd866
Author: Tomaž Vajngerl 
AuthorDate: Wed Mar 25 10:28:53 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:24:56 2020 +0200

SdrGrafObj: don't check the primitive sequence for PDF to get metadata

For a PDF we create a BitmapPrimitive2D only, so it doesn't have
any metadata in the primitive sequence itself, but a call to the
getVectorGraphicData() method will render the PDF in order to
create the BitmapPrimitive2D. This is a problem when we have
multiple pages as we want them to be rendered on demand and not
right away on load.
This change short-circuits the gathering of metadata for PDF to
prevent unnecessary early rendering of PDF pages.

Change-Id: If5c286e88e72c4c0ba5083a98c7db707d207b6cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91034
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 74ebc6dcbc85ce9f49d7451e08d71a41f794f569)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95629
Tested-by: Tomaž Vajngerl 

diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx
index 9460926c069f..875aa8efcefb 100644
--- a/svx/source/svdraw/svdograf.cxx
+++ b/svx/source/svdraw/svdograf.cxx
@@ -165,6 +165,12 @@ void SdrGrafObj::onGraphicChanged()
 if (!rVectorGraphicDataPtr.get())
 return;
 
+// Skip for PDF as it is only a bitmap primitive in a sequence and
+// doesn't contain metadata. However getting the primitive sequence
+// will also trigger a premature rendering of the PDF.
+if (rVectorGraphicDataPtr->getVectorGraphicDataType() == 
VectorGraphicDataType::Pdf)
+return;
+
 const drawinglayer::primitive2d::Primitive2DContainer 
aSequence(rVectorGraphicDataPtr->getPrimitive2DSequence());
 
 if (aSequence.empty())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - offapi/com sd/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 offapi/com/sun/star/graphic/XPdfDecomposer.idl |2 -
 sd/source/filter/pdf/sdpdffilter.cxx   |   36 ++---
 2 files changed, 11 insertions(+), 27 deletions(-)

New commits:
commit 92c204382522b2b363cbefb260b199476d04b992
Author: Tomaž Vajngerl 
AuthorDate: Wed Mar 18 14:14:13 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:26:15 2020 +0200

XPdfDecomposer - fix the described property name

The propery name should be "PageIndex" and not "Page"

Change-Id: Ic8d012abcfcb3381bb287bc43ca1d776c2c4ac95
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95632
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/offapi/com/sun/star/graphic/XPdfDecomposer.idl 
b/offapi/com/sun/star/graphic/XPdfDecomposer.idl
index aae6eda55347..a5563e0294e5 100644
--- a/offapi/com/sun/star/graphic/XPdfDecomposer.idl
+++ b/offapi/com/sun/star/graphic/XPdfDecomposer.idl
@@ -30,7 +30,7 @@ interface XPdfDecomposer : ::com::sun::star::uno::XInterface
 @param xDecompositionParameters
 Parameters for decomposition. Parameters include:
 
-sal_Int32 Page - which page to use
+sal_Int32 PageIndex - which page to use
 
 @since LibreOffice 7.0
  */
commit ce617fdcedb7f495b5b20859f54419443bba1d74
Author: Tomaž Vajngerl 
AuthorDate: Thu Mar 26 21:40:36 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:26:02 2020 +0200

clean-up SdPdfFilter implementation

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91156
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 52a06aeb4d8b58245fa0363fe22c7f255bcfc310)

Change-Id: I17f76ac8eaf8781deef076ca99c21bab7b62569e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95633
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/source/filter/pdf/sdpdffilter.cxx 
b/sd/source/filter/pdf/sdpdffilter.cxx
index 88986fe0e477..8980e902ec73 100644
--- a/sd/source/filter/pdf/sdpdffilter.cxx
+++ b/sd/source/filter/pdf/sdpdffilter.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include 
 #include 
 #include 
 
@@ -27,16 +28,7 @@
 #include 
 #include 
 
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::beans;
-using namespace ::com::sun::star::graphic;
-using namespace ::com::sun::star::io;
-using namespace ::com::sun::star::ucb;
-using namespace ::sfx2;
-
-SdPdfFilter::SdPdfFilter(SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell)
+SdPdfFilter::SdPdfFilter(SfxMedium& rMedium, sd::DrawDocShell& rDocShell)
 : SdFilter(rMedium, rDocShell)
 {
 }
@@ -45,14 +37,11 @@ SdPdfFilter::~SdPdfFilter() {}
 
 bool SdPdfFilter::Import()
 {
-//FIXME: Replace with parsing the PDF elements to allow editing.
-//FIXME: For now we import as images for simplicity.
-
 const OUString aFileName(
 
mrMedium.GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::NONE));
 
 // Rendering resolution.
-const double dResolutionDPI = 96.;
+const double dResolutionDPI = 96.0;
 
 std::vector> aGraphics;
 if (vcl::ImportPDFUnloaded(aFileName, aGraphics, dResolutionDPI) == 0)
@@ -75,25 +64,20 @@ bool SdPdfFilter::Import()
 
 // Create the page and insert the Graphic.
 SdPage* pPage = mrDocument.GetSdPage(nPageNumber, PageKind::Standard);
-Size aGrfSize(OutputDevice::LogicToLogic(aSize, 
rGraphic.GetPrefMapMode(),
- 
MapMode(MapUnit::Map100thMM)));
+Size aGraphicSize(OutputDevice::LogicToLogic(aSize, 
rGraphic.GetPrefMapMode(),
+ 
MapMode(MapUnit::Map100thMM)));
 
 // Resize to original size based on 72 dpi to preserve page size.
-aGrfSize = Size(aGrfSize.Width() * 72. / dResolutionDPI,
-aGrfSize.Height() * 72. / dResolutionDPI);
+aGraphicSize = Size(aGraphicSize.Width() * 72.0 / dResolutionDPI,
+aGraphicSize.Height() * 72.0 / dResolutionDPI);
 
 // Make the page size match the rendered image.
-pPage->SetSize(aGrfSize);
-Point aPos(0, 0);
+pPage->SetSize(aGraphicSize);
+Point aPosition(0, 0);
 
 SdrGrafObj* pSdrGrafObj = new 
SdrGrafObj(pPage->getSdrModelFromSdrPage(), rGraphic,
- tools::Rectangle(aPos, 
aGrfSize));
+ tools::Rectangle(aPosition, 
aGraphicSize));
 pPage->InsertObject(pSdrGrafObj);
-
-// we know that the initial bitmap we provided was just a placeholder,
-// we need to swap it out, so that on the next swap in, we render the
-// correct one
-// 
const_cast(pSdrGrafObj->GetGraphicObject()).SwapOut();
 }
 
 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/gdi/impgraph.cxx |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 1d6f3b0aeda8fa98d3ec0910d78676a341d4
Author: Tomaž Vajngerl 
AuthorDate: Fri Mar 27 20:38:06 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:26:37 2020 +0200

graphic: sPdfDataCache is not used anymore

Change-Id: I3fd13784c80dc3308f751594830ee08761e8d8c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91235
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 211dbdb78838e77ae8eea6cadd8050973b2f6080)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95634
Tested-by: Tomaž Vajngerl 

diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index a8dbb0fb99a7..c628e7d20a03 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1634,8 +1634,6 @@ sal_Int32 ImpGraphic::getPageNumber() const
 return -1;
 }
 
-static std::map>> 
sPdfDataCache;
-
 void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
 {
 if (rIStm.GetError())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - basegfx/test

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 basegfx/test/B2DHomMatrixTest.cxx |  126 ++
 1 file changed, 126 insertions(+)

New commits:
commit 6b9992998672cf0c0e1dcedf76bc0b49ca8f5751
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 28 20:27:17 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:29:18 2020 +0200

basegfx: test B2DHomMatrix and Matrix together

This adds a test for B2DHomMatix and Matrix to test them together.
Ther reason for this is that we can remove Matrix in favour to
B2DHomMatrix, but first we need to make sure it is safe so by
checking that the operations in Matrix yield the same result as
with B2DHomMatrix.

Change-Id: Ia93c1d3c7b2b7ff257c35831ff31afad3e8f34ba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91312
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 60f14ad158801183519ff929167b8526b7941670)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95640
Tested-by: Tomaž Vajngerl 

diff --git a/basegfx/test/B2DHomMatrixTest.cxx 
b/basegfx/test/B2DHomMatrixTest.cxx
index 52ab3e77ad5e..340f37c8937f 100644
--- a/basegfx/test/B2DHomMatrixTest.cxx
+++ b/basegfx/test/B2DHomMatrixTest.cxx
@@ -23,8 +23,10 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 
 namespace basegfx
 {
@@ -444,6 +446,129 @@ public:
 CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("decompose: error test J1", F_PI, 
fDRot, 1E-12);
 }
 
+void testMatrix()
+{
+{
+B2DHomMatrix aB2DMatrix(00, 01, 02, 10, 11, 12);
+Matrix aMatrix(00, 10, 01, 11, 02, 12);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.a(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.b(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.c(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.d(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.e(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.f(), 
1E-12);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.get(0, 
0), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.get(1, 
0), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.get(0, 
1), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.get(1, 
1), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.get(0, 
2), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.get(1, 
2), 1E-12);
+}
+
+{
+B2DHomMatrix aB2DMatrix = B2DHomMatrix::abcdef(00, 10, 01, 11, 02, 
12);
+Matrix aMatrix(00, 10, 01, 11, 02, 12);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.a(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.b(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.c(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.d(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.e(), 
1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.f(), 
1E-12);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 0), aMatrix.get(0, 
0), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 0), aMatrix.get(1, 
0), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 1), aMatrix.get(0, 
1), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 1), aMatrix.get(1, 
1), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(0, 2), aMatrix.get(0, 
2), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.get(1, 2), aMatrix.get(1, 
2), 1E-12);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.a(), aMatrix.a(), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.b(), aMatrix.b(), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.c(), aMatrix.c(), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.d(), aMatrix.d(), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.e(), aMatrix.e(), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aB2DMatrix.f(), aMatrix.f(), 1E-12);
+}
+
+{
+B2DHomMatrix aB2DMatrix(00, 01, 02, 10, 11, 12); //column first
+Matrix aMatrix(00, 10, 01, 11, 02, 12); // row first
+
+Matrix aNewMatrix(1, 2, 3, 4, 5, 6);
+
+B2DHomMatrix aNewB2DMatrix(1, 3, 5, 2, 4, 6);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(0, 0), 
aNewB2DMatrix.get(0, 0), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(1, 0), 
aNewB2DMatrix.get(1, 0), 1E-12);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aNewMatrix.get(0, 1), 
aNewB2DMatrix.get(0, 1), 1E-12);
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/basegfx

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/basegfx/matrix/Matrix.hxx |   25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

New commits:
commit 560bfab85e0bd91a820c8c7dbe744628d807c1e6
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 28 20:21:12 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:28:48 2020 +0200

basegfx: Fix the problem with Matrix Concatinate and Transform

In Concatinate and Transform methods we change the instance
variables during calculation (matrix multiplication), which leads
to the wrong result. This change fixes both calculations.

Change-Id: I9f7ef7323707df1ab4a764f97f9bae8593c42940
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91311
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit d088b243cad18777f785abf704b0310f057f740b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95639
Tested-by: Tomaž Vajngerl 

diff --git a/include/basegfx/matrix/Matrix.hxx 
b/include/basegfx/matrix/Matrix.hxx
index 9224e2784b60..e690216a3824 100644
--- a/include/basegfx/matrix/Matrix.hxx
+++ b/include/basegfx/matrix/Matrix.hxx
@@ -86,19 +86,28 @@ public:
 /// Multiply this * other.
 void Concatinate(const Matrix& other)
 {
-ma = ma * other.ma + mb * other.mc;
-mb = ma * other.mb + mb * other.md;
-mc = mc * other.ma + md * other.mc;
-md = mc * other.mb + md * other.md;
-me = me * other.ma + mf * other.mc + other.me;
-mf = me * other.mb + mf * other.md + other.mf;
+double newA = ma * other.ma + mb * other.mc;
+double newB = ma * other.mb + mb * other.md;
+double newC = mc * other.ma + md * other.mc;
+double newD = mc * other.mb + md * other.md;
+double newE = me * other.ma + mf * other.mc + other.me;
+double newF = me * other.mb + mf * other.md + other.mf;
+
+ma = newA;
+mb = newB;
+mc = newC;
+md = newD;
+me = newE;
+mf = newF;
 }
 
 /// Transform the point (x, y) by this Matrix.
 template  void Transform(T& x, T& y)
 {
-x = ma * x + mc * y + me;
-y = mb * x + md * y + mf;
+T newX = v00 * x + v01 * y + v02;
+T newY = v10 * x + v11 * y + v12;
+x = newX;
+y = newY;
 }
 
 /// Transform the rectangle (left, right, top, bottom) by this Matrix.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/basegfx

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/basegfx/matrix/Matrix.hxx |   45 +-
 1 file changed, 44 insertions(+), 1 deletion(-)

New commits:
commit cbbc7fc27e24d624d1f4dac641be42e5c43821f1
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 28 20:11:48 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:28:24 2020 +0200

add convenience accessors to Matrix.hxx

Change-Id: Ifaaff3b1526aed111725a46c6cc64c189909a904
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91309
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit b53a9c552a30a3aaa2b26ef8b1a3e8cf0f011a5c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95638
Tested-by: Tomaž Vajngerl 

diff --git a/include/basegfx/matrix/Matrix.hxx 
b/include/basegfx/matrix/Matrix.hxx
index b742d8cdf293..9224e2784b60 100644
--- a/include/basegfx/matrix/Matrix.hxx
+++ b/include/basegfx/matrix/Matrix.hxx
@@ -53,6 +53,29 @@ public:
 return *this;
 }
 
+double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
+{
+if (nRow == 0)
+{
+if (nColumn == 0)
+return v00;
+else if (nColumn == 1)
+return v01;
+else if (nColumn == 2)
+return v02;
+}
+else if (nRow == 1)
+{
+if (nColumn == 0)
+return v10;
+else if (nColumn == 1)
+return v11;
+else if (nColumn == 2)
+return v12;
+}
+return 0.0;
+}
+
 double a() const { return ma; }
 double b() const { return mb; }
 double c() const { return mc; }
@@ -120,7 +143,27 @@ public:
 }
 
 private:
-double ma, mb, mc, md, me, mf;
+union {
+struct
+{
+double ma;
+double mb;
+double mc;
+double md;
+double me;
+double mf;
+};
+
+struct
+{
+double v00;
+double v10;
+double v01;
+double v11;
+double v02;
+double v12;
+};
+};
 };
 
 /* 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 'distro/collabora/cp-6.4' - include/basegfx

2020-06-06 Thread Tomaž Vajngerl (via logerrit)
 include/basegfx/range/b2drange.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8aea19d95cef334f92d6f9858d7297b70a8dacab
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 28 19:21:10 2020 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Jun 6 19:28:08 2020 +0200

basegfx: export B2DRange operator*=

Change-Id: Ia2e72e6650b14d5d024b65b1261876885cf1b05a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91308
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit c44e2f95603866aca7c71ee9b066c5088745381c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95637
Tested-by: Tomaž Vajngerl 

diff --git a/include/basegfx/range/b2drange.hxx 
b/include/basegfx/range/b2drange.hxx
index 00eab63d1472..a599fd03fe93 100644
--- a/include/basegfx/range/b2drange.hxx
+++ b/include/basegfx/range/b2drange.hxx
@@ -292,7 +292,7 @@ namespace basegfx
 This means that the range will grow evtl. when a shear and/or 
rotation
 is part of the transformation.
 */
-B2DRange& operator*=( const ::basegfx::B2DHomMatrix& rMat );
+BASEGFX_DLLPUBLIC B2DRange& operator*=( const ::basegfx::B2DHomMatrix& 
rMat );
 
 /** Get a range filled with (0.0, 0.0, 1.0, 1.0) */
 static const B2DRange& getUnitB2DRange();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - include/svx sd/inc sd/source svx/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 include/svx/svdmrkv.hxx|2 
 sd/inc/Outliner.hxx|6 
 sd/source/ui/view/Outliner.cxx |   11 
 svx/source/svdraw/svdmrkv.cxx  |  499 -
 4 files changed, 260 insertions(+), 258 deletions(-)

New commits:
commit b61ed3d735eedc24f81d18783673a8cb361897bf
Author: Tomaž Vajngerl 
AuthorDate: Sat May 16 19:49:40 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 16:19:07 2020 +0200

svx: move LOKit specifics out of SetMarkHandles into own method

The SdrMarkView::SetMarkHandles method is too big because it
also hosts the LOKit sending of callbacks, so move that into
it's own method. Would be a good idea to split even more and
move into own class in a future commit.

Change-Id: I7e6389bfa98f22c44863c6eddc840692a7f22605
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94728
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 3f14671b5f0cf11dc2e0e5ae11700afcef63ce81)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95799
Tested-by: Jenkins CollaboraOffice 

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index cb5660018260..b62749f41335 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -141,6 +141,8 @@ private:
 SVX_DLLPRIVATE void ImpSetPointsRects() const;
 void UndirtyMrkPnt() const;
 
+void SetMarkHandlesForLOKit(tools::Rectangle const & rRect, SfxViewShell* 
pOtherShell);
+
 protected:
 virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
 virtual void ModelHasChanged() override; // Is called by the PaintView
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 4b6780120045..937464b85571 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -674,6 +674,258 @@ OUString lcl_getDragParameterString( const OUString& rCID 
)
 }
 } // anonymous namespace
 
+void SdrMarkView::SetMarkHandlesForLOKit(tools::Rectangle const & rRect, 
SfxViewShell* pOtherShell)
+{
+SfxViewShell* pViewShell = GetSfxViewShell();
+
+tools::Rectangle aSelection(rRect);
+bool bIsChart = false;
+
+if (!rRect.IsEmpty())
+{
+sal_uInt32 nTotalPaintWindows = this->PaintWindowCount();
+if (nTotalPaintWindows == 1)
+{
+const vcl::Window* pWin = dynamic_cast(this->GetFirstOutputDevice());
+if (pWin && pWin->IsChart())
+{
+bIsChart = true;
+const vcl::Window* pViewShellWindow = 
GetSfxViewShell()->GetEditWindowForActiveOLEObj();
+if (pViewShellWindow && pViewShellWindow->IsAncestorOf(*pWin))
+{
+Point aOffsetPx = 
pWin->GetOffsetPixelFrom(*pViewShellWindow);
+Point aLogicOffset = pWin->PixelToLogic(aOffsetPx);
+aSelection.Move(aLogicOffset.getX(), aLogicOffset.getY());
+}
+}
+}
+}
+
+if (!aSelection.IsEmpty())
+{
+// In case the map mode is in 100th MM, then need to convert the 
coordinates over to twips for LOK.
+if (mpMarkedPV)
+{
+if (OutputDevice* pOutputDevice = 
mpMarkedPV->GetView().GetFirstOutputDevice())
+{
+if (pOutputDevice->GetMapMode().GetMapUnit() == 
MapUnit::Map100thMM)
+aSelection = OutputDevice::LogicToLogic(aSelection, 
MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+}
+}
+
+// hide the text selection too
+pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, 
"");
+}
+
+{
+OString sSelectionText;
+boost::property_tree::ptree aTableJsonTree;
+bool bTableSelection = false;
+
+if (mpMarkedObj && mpMarkedObj->GetObjIdentifier() == OBJ_TABLE)
+{
+auto& rTableObject = 
dynamic_cast(*mpMarkedObj);
+bTableSelection = 
rTableObject.createTableEdgesJson(aTableJsonTree);
+}
+if (GetMarkedObjectCount())
+{
+SdrMark* pM = GetSdrMarkByIndex(0);
+SdrObject* pO = pM->GetMarkedSdrObj();
+long nRotAngle = pO->GetRotateAngle();
+// true if we are dealing with a RotGrfFlyFrame
+// (SwVirtFlyDrawObj with a SwGrfNode)
+bool bWriterGraphic = pO->HasLimitedRotation();
+
+if (bWriterGraphic)
+{
+nRotAngle *= 10;
+}
+
+OStringBuffer aExtraInfo;
+
+aExtraInfo.append("{\"id\":\"");
+
aExtraInfo.append(OString::number(reinterpret_cast(pO)));
+aExtraInfo.append("\",\"type\":");
+aExtraInfo.append(OString::number(pO->GetObjIdentifier()));
+
+if (bWriterGraphic)
+{
+aExtraInfo.append(", \"isWriterGraphic\": true");
+}
+else if (bIsChart)
+   

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - 2 commits - include/vcl svx/source vcl/CppunitTest_vcl_graphic_test.mk vcl/Library_vcl.mk vcl/qa vcl/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|   39 ++
 include/vcl/vectorgraphicdata.hxx  |3 
 svx/source/svdraw/svdedtv2.cxx |2 
 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 +
 8 files changed, 265 insertions(+), 5 deletions(-)

New commits:
commit c0de8e44e92c8d83c98afe8f807deb2633b3d2bd
Author: Tomaž Vajngerl 
AuthorDate: Thu May 7 22:01:22 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 16:28:07 2020 +0200

vcl: VectorGraphicSearch - for searching text inside PDF

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95254
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit efba780d6155317b592b6f5f73945a7851ec4d3b)

Change-Id: Iee940a3927330c8739774ff3c1af15998f89193b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95801
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

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 fd5c7aeb039b..7dc9e31a54b9 100644
--- a/vcl/CppunitTest_vcl_graphic_test.mk
+++ b/vcl/CppunitTest_vcl_graphic_test.mk
@@ -13,11 +13,12 @@ $(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/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 06df252a7c26..6812c52c35a3 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -328,6 +328,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();
+
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/qa vcl/source

2020-06-09 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 4d823e2cfa3171a54f20c313d7670be8ed9fa604
Author: Tomaž Vajngerl 
AuthorDate: Sat May 16 19:45:41 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 13:41:18 2020 +0200

vcl: VectorGraphicSearch - add search result selection rectangles

Change-Id: Ia0c5610f600719bcfb5de503f3876fc896cb630a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95256
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 4062b3f87689e48fd250d9cf0297a24b5427bf59)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95833

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 53127b85d9c1..a00df2555fb5 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] core.git: Branch 'distro/collabora/cp-6.4' - include/tools

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/tools/UnitConversion.hxx |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 5eb4a8b5562fde916b4049580c62a3e400922446
Author: Tomaž Vajngerl 
AuthorDate: Sun May 17 20:12:33 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 13:40:10 2020 +0200

vcl: add conversion point to 100th mm for double values

Integer conversion throws away percision, which is problematic
when we work with floating point values.

Change-Id: Ib34e46bd59aa67e933d49bc800e96cc6426414e5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95260
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 0e29e9ea7f4fe58d8dbdc7a9b9f58543a93d5bf5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95831
Tested-by: Tomaž Vajngerl 

diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx
index e59077d8a5fa..2093db6181d9 100644
--- a/include/tools/UnitConversion.hxx
+++ b/include/tools/UnitConversion.hxx
@@ -15,13 +15,18 @@ constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
 return (n >= 0) ? (n * 127 + 36) / 72 : (n * 127 - 36) / 72;
 }
 
-constexpr sal_Int64 convertPointToMm100(sal_Int64 n) { return 
convertTwipToMm100(n * 20); }
-
 constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
 {
 return (n >= 0) ? (n * 72 + 63) / 127 : (n * 72 - 63) / 127;
 }
 
+constexpr sal_Int64 convertPointToMm100(sal_Int64 nNumber)
+{
+return convertTwipToMm100(nNumber * 20);
+}
+
+constexpr double convertPointToMm100(double fNumber) { return fNumber * 
35.278; }
+
 // Convert PPT's "master unit" (1/576 inch) to twips
 constexpr sal_Int64 convertMasterUnitToTwip(sal_Int64 n) { return n * 2540.0 / 
576.0; }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|6 ++--
 vcl/source/graphic/VectorGraphicSearch.cxx |   35 +
 2 files changed, 29 insertions(+), 12 deletions(-)

New commits:
commit 2514c23a4bde8adf0872494c9009bae6b8dba816
Author: Tomaž Vajngerl 
AuthorDate: Fri May 15 12:20:42 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 13:40:35 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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95255
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 115655a09868d5977f740995d88e36d958f30bb5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95832
Tested-by: Tomaž Vajngerl 

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..53127b85d9c1 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())
@@ -144,9 +160,10 @@ bool 
VectorGraphicSearch::searchPDF(std::shared_ptr const& rD
 return false;
 }
 
-sal_Int32 nPageIndex = std::max(rData->getPageIndex(), 0);
+sal_Int32 nPageIndex = std::max(rData->getPageIndex(), sal_Int32(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 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 76ba829bf18123daf552afe253a8304a982ceb8d
Author: Tomaž Vajngerl 
AuthorDate: Wed May 27 14:27:30 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:21:26 2020 +0200

sd: some style fixes in Outliner.cxx

Also no need to reset the mpImpl in destructor when it will be
reset and destroyed in the next step anyway.

Change-Id: I5027f962efc4159e61aa7eda26619db2e3b9434c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95309
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 43a6def48f425361d79dff46dca41685d5ee03fa)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95920

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e98c1bde5795..c2cff89909a7 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -211,7 +211,6 @@ SdOutliner::SdOutliner( SdDrawDocument* pDoc, OutlinerMode 
nMode )
 /// Nothing spectacular in the destructor.
 SdOutliner::~SdOutliner()
 {
-mpImpl.reset();
 }
 
 /** Prepare find or spellchecking.  This distinguishes between three
@@ -467,7 +466,9 @@ bool SdOutliner::StartSearchAndReplace (const 
SvxSearchItem* pSearchItem)
 
 const SvxSearchCmd nCommand (mpSearchItem->GetCommand());
 if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == 
SvxSearchCmd::REPLACE_ALL)
+{
 bEndOfSearch = SearchAndReplaceAll ();
+}
 else
 {
 RememberStartPosition ();
@@ -573,6 +574,7 @@ void SdOutliner::Initialize (bool bDirectionIsForward)
 bool SdOutliner::SearchAndReplaceAll()
 {
 bool bRet = true;
+
 // Save the current position to be restored after having replaced all
 // matches.
 RememberStartPosition ();
@@ -756,13 +758,13 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 pOutlinerView = mpImpl->GetOutlinerView();
 }
 
-if (pViewShell != nullptr)
+if (pViewShell)
 {
 mpView = pViewShell->GetView();
 mpWindow = pViewShell->GetActiveWindow();
 pOutlinerView->SetWindow(mpWindow);
 
-if( nullptr != dynamic_cast< const sd::DrawViewShell *>( 
pViewShell.get() ))
+if (nullptr != dynamic_cast(pViewShell.get()))
 {
 // When replacing we first check if there is a selection
 // indicating a match.  If there is then replace it.  The
@@ -785,7 +787,7 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 {
 ProvideNextTextObject ();
 
-if ( ! mbEndOfSearch)
+if (!mbEndOfSearch)
 {
 // Remember the current position as the last one with a
 // text object.
@@ -807,7 +809,7 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 }
 }
 }
-else if( nullptr != dynamic_cast< const sd::OutlineViewShell *>( 
pViewShell.get() ))
+else if (nullptr != dynamic_cast(pViewShell.get()))
 {
 mpDrawDocument->GetDocSh()->SetWaitCursor(false);
 // The following loop is executed more than once only when a
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/graphic/VectorGraphicSearch.cxx |   45 +
 1 file changed, 45 insertions(+)

New commits:
commit 8c0776fb005cb99a1f8e289f26173bec9c246585
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 12:13:59 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:33:53 2020 +0200

vcl: use HAVE_FEATURE_PDFIUM in VectorGraphicSearch impl.

Change-Id: Id6c30e8f1c5bdb0481b0c7d4680554e3e8caa323
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95393
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 67f7a26c047ae2878e3ecd76f83af3941b9079c3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95935
Tested-by: Tomaž Vajngerl 

diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index 911c19cebd38..a719329b7708 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -10,6 +10,10 @@
 
 #include 
 
+#include 
+
+#if HAVE_FEATURE_PDFIUM
+
 #include 
 
 #include 
@@ -289,4 +293,45 @@ std::vector 
VectorGraphicSearch::getTextRectangles()
 return std::vector();
 }
 
+#else // !HAVE_FEATURE_PDFIUM
+
+class VectorGraphicSearch::Implementation
+{
+};
+
+VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
+: maGraphic(rGraphic)
+{
+}
+
+VectorGraphicSearch::~VectorGraphicSearch() {}
+
+bool VectorGraphicSearch::search(OUString const& /*rSearchString*/,
+ SearchStartPosition /*eStartPosition*/)
+{
+return false;
+}
+
+bool VectorGraphicSearch::searchPDF(std::shared_ptr const& 
/*rData*/,
+OUString const& /*rSearchString*/,
+SearchStartPosition /*eStartPosition*/)
+{
+return false;
+}
+
+basegfx::B2DSize VectorGraphicSearch::pageSize() { return basegfx::B2DSize(); }
+
+bool VectorGraphicSearch::next() { return false; }
+
+bool VectorGraphicSearch::previous() { return false; }
+
+int VectorGraphicSearch::index() { return -1; }
+
+std::vector VectorGraphicSearch::getTextRectangles()
+{
+return std::vector();
+}
+
+#endif // HAVE_FEATURE_PDFIUM
+
 /* 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 'distro/collabora/cp-6.4' - 3 commits - basegfx/test include/svx include/tools svx/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 basegfx/test/B2DHomMatrixTest.cxx |   32 
 include/svx/svdmrkv.hxx   |6 +++---
 include/tools/UnitConversion.hxx  |6 +-
 svx/source/svdraw/svdmrkv.cxx |   24 +---
 4 files changed, 49 insertions(+), 19 deletions(-)

New commits:
commit 716fa0cc58a39a9975a6827088e9209b7b3311e6
Author: Tomaž Vajngerl 
AuthorDate: Wed May 27 12:54:54 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 13:55:52 2020 +0200

svx: convert ImplMarkingOverlay and friends to use unique_ptr

Change-Id: I19ba9e93f2804fded237b760a28f3ce62e4b2c5f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95305
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit a6c0dc079700d662e14d422d18c6c3a9c2c3b7af)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95916
Tested-by: Tomaž Vajngerl 

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index b62749f41335..5b57da626d4f 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -90,9 +90,9 @@ class SVX_DLLPUBLIC SdrMarkView : public SdrSnapView
 friend classSdrPageView;
 
 // #114409#-3 Migrate selections
-ImplMarkingOverlay* mpMarkObjOverlay;
-ImplMarkingOverlay* mpMarkPointsOverlay;
-ImplMarkingOverlay* 
mpMarkGluePointsOverlay;
+std::unique_ptr mpMarkObjOverlay;
+std::unique_ptr mpMarkPointsOverlay;
+std::unique_ptr mpMarkGluePointsOverlay;
 
 protected:
 SdrObject*  mpMarkedObj;   // If not just one object ( 
i.e. More than one object ) is marked.
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 937464b85571..c6dd6928c755 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -165,9 +165,6 @@ SdrMarkView::SdrMarkView(
 SdrModel& rSdrModel,
 OutputDevice* pOut)
 :   SdrSnapView(rSdrModel, pOut),
-mpMarkObjOverlay(nullptr),
-mpMarkPointsOverlay(nullptr),
-mpMarkGluePointsOverlay(nullptr),
 maHdlList(this)
 {
 ImpClearVars();
@@ -363,10 +360,10 @@ void SdrMarkView::BegMarkObj(const Point& rPnt, bool 
bUnmark)
 {
 BrkAction();
 
-DBG_ASSERT(nullptr == mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There 
exists a mpMarkObjOverlay (!)");
+DBG_ASSERT(!mpMarkObjOverlay, "SdrMarkView::BegMarkObj: There exists a 
mpMarkObjOverlay (!)");
 
 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
-mpMarkObjOverlay = new ImplMarkingOverlay(*this, aStartPos, bUnmark);
+mpMarkObjOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, bUnmark));
 
 maDragStat.Reset(rPnt);
 maDragStat.NextPoint();
@@ -410,8 +407,7 @@ void SdrMarkView::BrkMarkObj()
 if(IsMarkObj())
 {
 DBG_ASSERT(mpMarkObjOverlay, "SdrSnapView::MovSetPageOrg: no 
ImplPageOriginOverlay (!)");
-delete mpMarkObjOverlay;
-mpMarkObjOverlay = nullptr;
+mpMarkObjOverlay.reset();
 }
 }
 
@@ -422,9 +418,9 @@ bool SdrMarkView::BegMarkPoints(const Point& rPnt, bool 
bUnmark)
 {
 BrkAction();
 
-DBG_ASSERT(nullptr == mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: 
There exists a mpMarkPointsOverlay (!)");
+DBG_ASSERT(!mpMarkPointsOverlay, "SdrMarkView::BegMarkObj: There 
exists a mpMarkPointsOverlay (!)");
 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
-mpMarkPointsOverlay = new ImplMarkingOverlay(*this, aStartPos, 
bUnmark);
+mpMarkPointsOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, 
bUnmark));
 
 maDragStat.Reset(rPnt);
 maDragStat.NextPoint();
@@ -475,8 +471,7 @@ void SdrMarkView::BrkMarkPoints()
 if(IsMarkPoints())
 {
 DBG_ASSERT(mpMarkPointsOverlay, "SdrSnapView::MovSetPageOrg: no 
ImplPageOriginOverlay (!)");
-delete mpMarkPointsOverlay;
-mpMarkPointsOverlay = nullptr;
+mpMarkPointsOverlay.reset();
 }
 }
 
@@ -487,10 +482,10 @@ bool SdrMarkView::BegMarkGluePoints(const Point& rPnt, 
bool bUnmark)
 {
 BrkAction();
 
-DBG_ASSERT(nullptr == mpMarkGluePointsOverlay, 
"SdrMarkView::BegMarkObj: There exists a mpMarkGluePointsOverlay (!)");
+DBG_ASSERT(!mpMarkGluePointsOverlay, "SdrMarkView::BegMarkObj: There 
exists a mpMarkGluePointsOverlay (!)");
 
 basegfx::B2DPoint aStartPos(rPnt.X(), rPnt.Y());
-mpMarkGluePointsOverlay = new ImplMarkingOverlay(*this, aStartPos, 
bUnmark);
+mpMarkGluePointsOverlay.reset(new ImplMarkingOverlay(*this, aStartPos, 
bUnmark));
 maDragStat.Reset(rPnt);
 maDragStat.NextPoint();
 maDragStat.SetMinMove(mnMinMovLog);
@@ -534,8 +529,7 @@ void SdrMarkView::BrkMarkGluePoints()
 if(IsMarkGluePoints())
 {
 DBG_ASSERT(mpMarkGluePointsOverlay, "SdrSnapView::MovSetPageOrg: no 
ImplPageOriginOverlay (!)");
-delete 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |  247 ++---
 1 file changed, 209 insertions(+), 38 deletions(-)

New commits:
commit 894b1a2f412ecc889a9932df3935c69e30852c6f
Author: Tomaž Vajngerl 
AuthorDate: Thu May 28 08:07:51 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:22:46 2020 +0200

sd: Search inside PDF document that were inserted as a graphic

This implements searching inside PDF documents that were inserted
into the Draw/Impress document as a graphics and marks the areas
of text that matches the search string. Complex (regex) search is
not supported.

Change-Id: I55d67772a2fe876ae72b9164998347304025d3e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95348
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 7a84dffb44d4b1fa6e2a3cd3e3dc7d942f3c3e80)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95923

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index c2cff89909a7..0d69cf872090 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -29,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -96,6 +98,11 @@ public:
 */
 void ReleaseOutlinerView();
 
+/** Search in vector graphic
+ */
+bool mbCurrentIsVectorGraphic;
+std::unique_ptr mpVectorGraphicSearch;
+
 private:
 /** Flag that specifies whether we own the outline view pointed to by
 mpOutlineView and thus have to
@@ -685,21 +692,93 @@ bool SdOutliner::SearchAndReplaceAll()
 return bRet;
 }
 
+namespace
+{
+basegfx::B2DRange b2DRectangleFromRectangle( const ::tools::Rectangle& rRect )
+{
+if (rRect.IsWidthEmpty() && rRect.IsHeightEmpty())
+return basegfx::B2DRange(basegfx::B2DTuple(rRect.Left(), rRect.Top()));
+return basegfx::B2DRectangle(rRect.Left(),
+ rRect.Top(),
+ rRect.IsWidthEmpty() ? rRect.Left() : 
rRect.Right(),
+ rRect.IsHeightEmpty() ? rRect.Top() : 
rRect.Bottom());
+}
+
+void getPDFSelections(std::vector & rSubSelections,
+  std::unique_ptr & 
rVectorGraphicSearch,
+  SdrObject* pObject)
+{
+basegfx::B2DSize aPdfPageSize = rVectorGraphicSearch->pageSize();
+
+basegfx::B2DRectangle 
aObjectB2DRectHMM(b2DRectangleFromRectangle(pObject->GetLogicRect()));
+
+// Setup coordinate conversion matrix to convert the inner PDF
+// coordinates to the page relative coordinates
+basegfx::B2DHomMatrix aB2DMatrix;
+
+aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSize.getX(),
+ aObjectB2DRectHMM.getHeight() / aPdfPageSize.getY());
+
+aB2DMatrix.translate(aObjectB2DRectHMM.getMinX(), 
aObjectB2DRectHMM.getMinY());
+
+basegfx::B2DRectangle aCombined;
+
+for (auto const & rRectangle : rVectorGraphicSearch->getTextRectangles())
+{
+basegfx::B2DRectangle aRectangle(rRectangle);
+aRectangle *= aB2DMatrix;
+if (aCombined.isEmpty())
+aCombined = aRectangle;
+else
+aCombined.expand(aRectangle);
+}
+
+rSubSelections.push_back(aCombined);
+}
+
+} // end namespace
+
 void SdOutliner::sendLOKSearchResultCallback(std::shared_ptr & 
pViewShell,
  OutlinerView* pOutlinerView,
  std::vector* 
pSelections)
 {
 std::vector<::tools::Rectangle> aLogicRects;
-pOutlinerView->GetSelectionRectangles(aLogicRects);
+if (mpImpl->mbCurrentIsVectorGraphic)
+{
+basegfx::B2DSize aPdfPageSize = 
mpImpl->mpVectorGraphicSearch->pageSize();
+
+tools::Rectangle aObjectRectTwip = 
OutputDevice::LogicToLogic(mpObj->GetLogicRect(), MapMode(MapUnit::Map100thMM), 
MapMode(MapUnit::MapTwip));
+basegfx::B2DRectangle 
aObjectB2DRectTwip(b2DRectangleFromRectangle(aObjectRectTwip));
+
+// Setup coordinate conversion matrix to convert the inner PDF
+// coordinates to the page relative coordinates
+basegfx::B2DHomMatrix aB2DMatrix;
+
+aB2DMatrix.scale(aObjectB2DRectTwip.getWidth() / aPdfPageSize.getX(),
+ aObjectB2DRectTwip.getHeight() / aPdfPageSize.getY());
+
+aB2DMatrix.translate(aObjectB2DRectTwip.getMinX(), 
aObjectB2DRectTwip.getMinY());
 
-// convert to twips if in 100thmm (seems as if LibreOfficeKit is based on 
twips?). Do this
-// here where we have the only place needing this, *not* in 
ImpEditView::GetSelectionRectangles
-// which makes that method unusable for others
-if (pOutlinerView->GetWindow() && MapUnit::Map100thMM == 
pOutlinerView->GetWindow()->GetMapMode().GetMapUnit())
+for (auto const & rRectangle : 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx svx/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/svx/svdmrkv.hxx   |   10 +++-
 svx/source/svdraw/svdmrkv.cxx |   48 --
 2 files changed, 55 insertions(+), 3 deletions(-)

New commits:
commit fe69802e22bb2c8365b7542f3f0fbf71cb6182e7
Author: Tomaž Vajngerl 
AuthorDate: Wed May 27 15:27:14 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:22:23 2020 +0200

svx: add ability to show sub-selections in a marked object

Draws selection rectangles inside the object window.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95347
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit cf812f15b3295a17a9b5d7e3a1c51b00dcbf2629)

Change-Id: I994477426489ea4cea89c86f9e51c9978f16b350
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95921
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index 5b57da626d4f..f080a57d1bbb 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -26,6 +26,8 @@
 #include 
 #include 
 #include 
+#include 
+
 
 class SfxViewShell;
 
@@ -84,6 +86,7 @@ enum class ImpGetDescriptionOptions
 };
 
 class ImplMarkingOverlay;
+class MarkingSubSelectionOverlay;
 
 class SVX_DLLPUBLIC SdrMarkView : public SdrSnapView
 {
@@ -94,6 +97,8 @@ class SVX_DLLPUBLIC SdrMarkView : public SdrSnapView
 std::unique_ptr mpMarkPointsOverlay;
 std::unique_ptr mpMarkGluePointsOverlay;
 
+std::unique_ptr mpMarkingSubSelectionOverlay;
+
 protected:
 SdrObject*  mpMarkedObj;   // If not just one object ( 
i.e. More than one object ) is marked.
 SdrPageView*mpMarkedPV;// If all marked obects are 
situated on the same PageView.
@@ -101,8 +106,10 @@ protected:
 Point   maRef1;// Persistent - Rotation 
center / axis of reflection
 Point   maRef2;// Persistent
 SdrHdlList  maHdlList;
+
 sdr::ViewSelection  maSdrViewSelection;
 
+std::vector maSubSelectionList;
 tools::RectanglemaMarkedObjRect;
 tools::RectanglemaMarkedPointsRect;
 tools::RectanglemaMarkedGluePointsRect;
@@ -302,7 +309,8 @@ public:
 // Mark all objects within a rectangular area
 // Just objects are marked which are inclosed completely
 void MarkObj(const tools::Rectangle& rRect, bool bUnmark);
-void MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark=false, bool 
bImpNoSetMarkHdl=false);
+void MarkObj(SdrObject* pObj, SdrPageView* pPV, bool bUnmark = false, bool 
bDoNoSetMarkHdl = false,
+ std::vector const & rSubSelections = 
std::vector());
 void MarkAllObj(SdrPageView* pPV=nullptr); // pPage=NULL => all displayed 
pages
 void UnmarkAllObj(SdrPageView const * pPV=nullptr); // pPage=NULL => all 
displayed pages
 
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index c6dd6928c755..326de3db561f 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -134,6 +135,38 @@ void ImplMarkingOverlay::SetSecondPosition(const 
basegfx::B2DPoint& rNewPosition
 }
 }
 
+class MarkingSubSelectionOverlay
+{
+sdr::overlay::OverlayObjectList maObjects;
+
+public:
+MarkingSubSelectionOverlay(const SdrPaintView& rView, 
std::vector const & rSelections)
+{
+if (comphelper::LibreOfficeKit::isActive())
+return; // We do client-side object manipulation with the Kit API
+
+for (sal_uInt32 a(0); a < rView.PaintWindowCount(); a++)
+{
+SdrPaintWindow* pCandidate = rView.GetPaintWindow(a);
+const rtl::Reference& xTargetOverlay 
= pCandidate->GetOverlayManager();
+
+if (xTargetOverlay.is())
+{
+const SvtOptionsDrawinglayer aSvtOptionsDrawinglayer;
+const Color aHighlightColor = 
aSvtOptionsDrawinglayer.getHilightColor();
+
+std::unique_ptr pNew =
+std::make_unique(
+sdr::overlay::OverlayType::Transparent,
+aHighlightColor, rSelections, false);
+
+xTargetOverlay->add(*pNew);
+maObjects.append(std::move(pNew));
+}
+}
+}
+};
+
 
 // MarkView
 
@@ -929,6 +962,8 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
 SdrHdlKind eSaveKind(SdrHdlKind::Move);
 SdrObject* pSaveObj = nullptr;
 
+mpMarkingSubSelectionOverlay.reset();
+
 if(pSaveOldFocusHdl
 && pSaveOldFocusHdl->GetObj()
 && dynamic_cast(pSaveOldFocusHdl->GetObj()) != 
nullptr
@@ -1023,6 +1058,11 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* 
pOtherShell)
 {
 return;
 }
+
+if 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/CppunitTest_sd_tiledrendering.mk sd/qa

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/CppunitTest_sd_tiledrendering.mk|1 
 sd/qa/unit/sdmodeltestbase.hxx |2 
 sd/qa/unit/tiledrendering/CallbackRecorder.hxx |  142 +++
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx  |  233 +
 sd/qa/unit/tiledrendering/tiledrendering.cxx   |  140 +--
 5 files changed, 388 insertions(+), 130 deletions(-)

New commits:
commit 38f68c0b81e62def94fd4f90e6fb1804b7ef0f82
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 18:18:40 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:24:42 2020 +0200

sd: move LOK search tests out of tiledrendering.cxx

Change-Id: I76ff3e251afc877b0dcf54d772da95bb7a60e823
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95351
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit b40f1d657affbe87f60bfd358199a91c9fea7454)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95926

diff --git a/sd/CppunitTest_sd_tiledrendering.mk 
b/sd/CppunitTest_sd_tiledrendering.mk
index 9b643c869a84..3b555860f963 100644
--- a/sd/CppunitTest_sd_tiledrendering.mk
+++ b/sd/CppunitTest_sd_tiledrendering.mk
@@ -14,6 +14,7 @@ $(eval $(call gb_CppunitTest_CppunitTest,sd_tiledrendering))
 $(eval $(call gb_CppunitTest_use_common_precompiled_header,sd_tiledrendering))
 
 $(eval $(call gb_CppunitTest_add_exception_objects,sd_tiledrendering, \
+sd/qa/unit/tiledrendering/LOKitSearchTest \
 sd/qa/unit/tiledrendering/tiledrendering \
 ))
 
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index 8fef3182ee3e..dd76e2349e23 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -73,7 +73,7 @@ pFilterName: 
 pTypeName: ...
 nFormatType: ...
 */
-FileFormat aFileFormats[] =
+static FileFormat aFileFormats[] =
 {
 { "odp",  "impress8", "impress8", "", ODP_FORMAT_TYPE },
 { "ppt",  "MS PowerPoint 97", "impress_MS_PowerPoint_97", "sdfilt", 
PPT_FORMAT_TYPE },
diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx 
b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
new file mode 100644
index ..fc5117cce6dc
--- /dev/null
+++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
@@ -0,0 +1,142 @@
+/* -*- 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 
+
+namespace
+{
+std::vector lcl_convertSeparated(const OUString& rString, 
sal_Unicode nSeparator)
+{
+std::vector aRet;
+
+sal_Int32 nIndex = 0;
+do
+{
+OUString aToken = rString.getToken(0, nSeparator, nIndex);
+aToken = aToken.trim();
+if (!aToken.isEmpty())
+aRet.push_back(aToken);
+} while (nIndex >= 0);
+
+return aRet;
+}
+
+void lcl_convertRectangle(const OUString& rString, tools::Rectangle& 
rRectangle)
+{
+uno::Sequence aSeq = 
comphelper::string::convertCommaSeparated(rString);
+CPPUNIT_ASSERT(aSeq.getLength() == 4 || aSeq.getLength() == 5);
+rRectangle.setX(aSeq[0].toInt32());
+rRectangle.setY(aSeq[1].toInt32());
+rRectangle.setWidth(aSeq[2].toInt32());
+rRectangle.setHeight(aSeq[3].toInt32());
+}
+}
+
+struct CallbackRecorder
+{
+CallbackRecorder()
+: m_bFound(true)
+, m_nPart(0)
+, m_nSelectionBeforeSearchResult(0)
+, m_nSelectionAfterSearchResult(0)
+{
+}
+
+tools::Rectangle m_aInvalidation;
+std::vector<::tools::Rectangle> m_aSelection;
+bool m_bFound;
+sal_Int32 m_nPart;
+std::vector m_aSearchResultSelection;
+std::vector m_aSearchResultPart;
+int m_nSelectionBeforeSearchResult;
+int m_nSelectionAfterSearchResult;
+/// For document size changed callback.
+osl::Condition m_aDocumentSizeCondition;
+
+static void callback(int nType, const char* pPayload, void* pData)
+{
+static_cast(pData)->processCallback(nType, 
pPayload);
+}
+
+void processCallback(int nType, const char* pPayload)
+{
+switch (nType)
+{
+case LOK_CALLBACK_INVALIDATE_TILES:
+{
+OUString aPayload = OUString::createFromAscii(pPayload);
+if (aPayload != "EMPTY" && m_aInvalidation.IsEmpty())
+lcl_convertRectangle(aPayload, m_aInvalidation);
+}
+break;
+case LOK_CALLBACK_TEXT_SELECTION:
+{
+OUString aPayload = OUString::createFromAscii(pPayload);
+m_aSelection.clear();
+for (const OUString& rString : lcl_convertSeparated(aPayload, 
u';'))
+{
+::tools::Rectangle aRectangle;
+ 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   36 +++-
 1 file changed, 23 insertions(+), 13 deletions(-)

New commits:
commit 42cfe2309bd9731d0e5b497356af5834757521bb
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 08:33:42 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:23:38 2020 +0200

sd: remove code dupl. when getting PDF text selection for LOK

Change-Id: I61d0a9851e9cfe60e9672acec38946b0b25f310f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95349
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 06ddbd4a7a15b80b0286b359bd0a05812fd7ee75)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95924
Tested-by: Tomaž Vajngerl 

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 0d69cf872090..f60748bb13a5 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -704,11 +704,16 @@ basegfx::B2DRange b2DRectangleFromRectangle( const 
::tools::Rectangle& rRect )
  rRect.IsHeightEmpty() ? rRect.Top() : 
rRect.Bottom());
 }
 
-void getPDFSelections(std::vector & rSubSelections,
-  std::unique_ptr & 
rVectorGraphicSearch,
-  SdrObject* pObject)
+basegfx::B2DRectangle getPDFSelection(std::unique_ptr & 
rVectorGraphicSearch,
+   SdrObject* pObject)
 {
-basegfx::B2DSize aPdfPageSize = rVectorGraphicSearch->pageSize();
+basegfx::B2DRectangle aSelection;
+
+auto const & rTextRectangles = rVectorGraphicSearch->getTextRectangles();
+if (rTextRectangles.empty())
+return aSelection;
+
+basegfx::B2DSize aPdfPageSizeHMM = rVectorGraphicSearch->pageSize();
 
 basegfx::B2DRectangle 
aObjectB2DRectHMM(b2DRectangleFromRectangle(pObject->GetLogicRect()));
 
@@ -716,24 +721,24 @@ void getPDFSelections(std::vector 
& rSubSelections,
 // coordinates to the page relative coordinates
 basegfx::B2DHomMatrix aB2DMatrix;
 
-aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSize.getX(),
- aObjectB2DRectHMM.getHeight() / aPdfPageSize.getY());
+aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSizeHMM.getX(),
+ aObjectB2DRectHMM.getHeight() / aPdfPageSizeHMM.getY());
 
 aB2DMatrix.translate(aObjectB2DRectHMM.getMinX(), 
aObjectB2DRectHMM.getMinY());
 
-basegfx::B2DRectangle aCombined;
 
 for (auto const & rRectangle : rVectorGraphicSearch->getTextRectangles())
 {
 basegfx::B2DRectangle aRectangle(rRectangle);
 aRectangle *= aB2DMatrix;
-if (aCombined.isEmpty())
-aCombined = aRectangle;
+
+if (aSelection.isEmpty())
+aSelection = aRectangle;
 else
-aCombined.expand(aRectangle);
+aSelection.expand(aRectangle);
 }
 
-rSubSelections.push_back(aCombined);
+return aSelection;
 }
 
 } // end namespace
@@ -862,7 +867,9 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 mpView->UnmarkAllObj(pPageView);
 
 std::vector aSubSelections;
-getPDFSelections(aSubSelections, 
mpImpl->mpVectorGraphicSearch, mpObj);
+basegfx::B2DRectangle aSubSelection = 
getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+if (!aSubSelection.isEmpty())
+aSubSelections.push_back(aSubSelection);
 mpView->MarkObj(mpObj, pPageView, false, false, 
aSubSelections);
 }
 }
@@ -1263,7 +1270,10 @@ void SdOutliner::ProvideNextTextObject()
 mpView->UnmarkAllObj(pPageView);
 
 std::vector aSubSelections;
-getPDFSelections(aSubSelections, 
mpImpl->mpVectorGraphicSearch, mpObj);
+basegfx::B2DRectangle aSubSelection = 
getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+if (!aSubSelection.isEmpty())
+aSubSelections.push_back(aSubSelection);
+
 mpView->MarkObj(mpObj, pPageView, false, false, 
aSubSelections);
 
 mpDrawDocument->GetDocSh()->SetWaitCursor( false );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

New commits:
commit 2c402eb238ef375971b1604c5dbfe6c6eedc2000
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 08:36:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:24:07 2020 +0200

sd: use b2DRectangleFromRectangle from canvastools.hxx

Change-Id: I8604b80f887a2c3a1143b8a9bc70f429576512f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95350
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit beb0fc465163e5edc0b7f978ad46c6ad0cd9e2de)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95925

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index f60748bb13a5..041f08c9b0a5 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -694,15 +695,6 @@ bool SdOutliner::SearchAndReplaceAll()
 
 namespace
 {
-basegfx::B2DRange b2DRectangleFromRectangle( const ::tools::Rectangle& rRect )
-{
-if (rRect.IsWidthEmpty() && rRect.IsHeightEmpty())
-return basegfx::B2DRange(basegfx::B2DTuple(rRect.Left(), rRect.Top()));
-return basegfx::B2DRectangle(rRect.Left(),
- rRect.Top(),
- rRect.IsWidthEmpty() ? rRect.Left() : 
rRect.Right(),
- rRect.IsHeightEmpty() ? rRect.Top() : 
rRect.Bottom());
-}
 
 basegfx::B2DRectangle getPDFSelection(std::unique_ptr & 
rVectorGraphicSearch,
SdrObject* pObject)
@@ -715,7 +707,7 @@ basegfx::B2DRectangle 
getPDFSelection(std::unique_ptr & rVe
 
 basegfx::B2DSize aPdfPageSizeHMM = rVectorGraphicSearch->pageSize();
 
-basegfx::B2DRectangle 
aObjectB2DRectHMM(b2DRectangleFromRectangle(pObject->GetLogicRect()));
+basegfx::B2DRectangle 
aObjectB2DRectHMM(vcl::unotools::b2DRectangleFromRectangle(pObject->GetLogicRect()));
 
 // Setup coordinate conversion matrix to convert the inner PDF
 // coordinates to the page relative coordinates
@@ -753,7 +745,7 @@ void 
SdOutliner::sendLOKSearchResultCallback(std::shared_ptr & pV
 basegfx::B2DSize aPdfPageSize = 
mpImpl->mpVectorGraphicSearch->pageSize();
 
 tools::Rectangle aObjectRectTwip = 
OutputDevice::LogicToLogic(mpObj->GetLogicRect(), MapMode(MapUnit::Map100thMM), 
MapMode(MapUnit::MapTwip));
-basegfx::B2DRectangle 
aObjectB2DRectTwip(b2DRectangleFromRectangle(aObjectRectTwip));
+basegfx::B2DRectangle 
aObjectB2DRectTwip(vcl::unotools::b2DRectangleFromRectangle(aObjectRectTwip));
 
 // Setup coordinate conversion matrix to convert the inner PDF
 // coordinates to the page relative coordinates
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/qa

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/sdmodeltestbase.hxx |   16 
 sd/qa/unit/tiledrendering/CallbackRecorder.hxx |3 +++
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx  |   18 +-
 3 files changed, 32 insertions(+), 5 deletions(-)

New commits:
commit 60ec74e442aebe1d80b1416ec1405fffc06ab4ae
Author: Tomaž Vajngerl 
AuthorDate: Sat May 30 13:10:04 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:27:35 2020 +0200

sd: improve the test for LOKit search in PDF graphic

Record how many times we het the search result back, so we can
be sure that the search happend and don't just read the old
values. Assert the search result selection rectangles and text
selection rectangles.

Add tools:Rectangle support for CPPUnit into sdmodeltestbase.hxx

Change-Id: I0b22d2d2f66abdc0dd0d5ac13a1bfebaa470749a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95383
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 4dcc48f37248a1eb45188739de961689e7873f3c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95931
Tested-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index dd76e2349e23..f36bab03a322 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -485,6 +485,22 @@ template<> struct assertion_traits
 }
 };
 
+template<> struct assertion_traits
+{
+static bool equal( const tools::Rectangle& r1, const tools::Rectangle& r2 )
+{
+return r1 == r2;
+}
+
+static std::string toString( const tools::Rectangle& r)
+{
+OStringStream ost;
+ost << "Rect P: [" << r.Top() << ", " << r.Left() << "] "
+"S: [" << r.GetWidth() << ", " << r.GetHeight() << "]";
+return ost.str();
+}
+};
+
 CPPUNIT_NS_END
 
 #endif
diff --git a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx 
b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
index fc5117cce6dc..7e6c8a42d07d 100644
--- a/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
+++ b/sd/qa/unit/tiledrendering/CallbackRecorder.hxx
@@ -51,6 +51,7 @@ struct CallbackRecorder
 , m_nPart(0)
 , m_nSelectionBeforeSearchResult(0)
 , m_nSelectionAfterSearchResult(0)
+, m_nSearchResultCount(0)
 {
 }
 
@@ -62,6 +63,7 @@ struct CallbackRecorder
 std::vector m_aSearchResultPart;
 int m_nSelectionBeforeSearchResult;
 int m_nSelectionAfterSearchResult;
+int m_nSearchResultCount;
 /// For document size changed callback.
 osl::Condition m_aDocumentSizeCondition;
 
@@ -115,6 +117,7 @@ struct CallbackRecorder
 break;
 case LOK_CALLBACK_SEARCH_RESULT_SELECTION:
 {
+m_nSearchResultCount++;
 m_aSearchResultSelection.clear();
 m_aSearchResultPart.clear();
 boost::property_tree::ptree aTree;
diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 33257f12d4ab..8d8b11e43fa1 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -292,21 +292,29 @@ void LOKitSearchTest::testSearchInPDF()
 CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
  pVectorGraphicData->getVectorGraphicDataType());
 
+// Search
 lcl_search("ABC");
 
 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
 
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
+ mpCallbackRecorder->m_aSelection[0]);
 
-CPPUNIT_ASSERT_EQUAL(long(3763), 
mpCallbackRecorder->m_aSelection[0].Left());
-CPPUNIT_ASSERT_EQUAL(long(1331), 
mpCallbackRecorder->m_aSelection[0].Top());
-CPPUNIT_ASSERT_EQUAL(long(1433), 
mpCallbackRecorder->m_aSelection[0].GetWidth());
-CPPUNIT_ASSERT_EQUAL(long(484), 
mpCallbackRecorder->m_aSelection[0].GetHeight());
-
+// Search again - same result
 lcl_search("ABC");
+
 CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
 
 CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(OString("3763, 1331, 1432, 483"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(3763, 1331), Size(1433, 484)),
+ mpCallbackRecorder->m_aSelection[0]);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
___
Libreoffice-commits 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl svx/source vcl/Library_vcl.mk vcl/qa vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/filter/PDFiumLibrary.hxx   |   43 +
 svx/source/inc/svdpdf.hxx  |4 ++
 svx/source/svdraw/svdpdf.cxx   |   14 +
 vcl/Library_vcl.mk |1 
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   20 ++---
 vcl/source/filter/ipdf/pdfread.cxx |   26 +++--
 vcl/source/graphic/VectorGraphicSearch.cxx |   13 +++-
 vcl/source/pdf/PDFiumLibrary.cxx   |   36 
 8 files changed, 100 insertions(+), 57 deletions(-)

New commits:
commit 3538b83c8d83e66f63c745bd769d118117704026
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 11:50:20 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:28:10 2020 +0200

pdfium: only init pdfium library one and destroy on LO exit

With more and more usage of PDFium, it is hard to keep track of
the life-time of the PDFium library, so it can happen that a
FPDF_DestroyLibrary happens when we still have another instance
where PDFium is still use. The result of this is a crash. To
prevent this, just initialize the library once and delete, when
on LO exit.

This can be improved in the future to only keep the library
active when in actual use.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95391
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 067a8a954c8e1d8d6465a4ab5fb61e93f16c26c2)

Change-Id: I5c7e5de7f8b97d10efb394c67c7a61b976c8d57c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95933
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/filter/PDFiumLibrary.hxx 
b/include/vcl/filter/PDFiumLibrary.hxx
new file mode 100644
index ..bc7912c17e81
--- /dev/null
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -0,0 +1,43 @@
+/* -*- 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 
+
+#if HAVE_FEATURE_PDFIUM
+
+#include 
+#include 
+#include 
+
+namespace vcl::pdf
+{
+class VCL_DLLPUBLIC PDFium final
+{
+private:
+PDFium(const PDFium&) = delete;
+PDFium& operator=(const PDFium&) = delete;
+
+public:
+PDFium();
+~PDFium();
+};
+
+struct PDFiumLibrary : public rtl::StaticWithInit, 
PDFiumLibrary>
+{
+std::shared_ptr operator()() { return std::make_shared(); }
+};
+
+} // namespace vcl::pdf
+
+#endif // HAVE_FEATURE_PDFIUM
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index cc3ec7f27bfa..3765f8a59577 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -45,6 +45,8 @@
 #include 
 #include 
 
+#include 
+
 // Forward Declarations
 
 class SfxItemSet;
@@ -104,6 +106,8 @@ class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
 tools::Rectangle PointsToLogic(double left, double right, double top, 
double bottom) const;
 Point PointsToLogic(double x, double y) const;
 
+std::shared_ptr mpPDFium;
+
 // check for clip and evtl. fill maClip
 void checkClip();
 bool isClip() const;
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index b380d478d806..f539d56ca355 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -131,6 +131,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
 , mnPageCount(0)
 , mdPageWidthPts(0)
 , mdPageHeightPts(0)
+, mpPDFium(vcl::pdf::PDFiumLibrary::get())
 {
 mpVD->EnableOutput(false);
 mpVD->SetLineColor();
@@ -144,13 +145,6 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
   svl::Items{});
 checkClip();
 
-FPDF_LIBRARY_CONFIG aConfig;
-aConfig.version = 2;
-aConfig.m_pUserFontPaths = nullptr;
-aConfig.m_pIsolate = nullptr;
-aConfig.m_v8EmbedderSlot = 0;
-FPDF_InitLibraryWithConfig();
-
 // Load the buffer using pdfium.
 auto const& rVectorGraphicData = mrGraphic.getVectorGraphicData();
 mpPdfDocument = FPDF_LoadMemDocument(
@@ -185,11 +179,7 @@ ImpSdrPdfImport::ImpSdrPdfImport(SdrModel& rModel, 
SdrLayerID nLay, const tools:
 mnPageCount = FPDF_GetPageCount(mpPdfDocument);
 }
 
-ImpSdrPdfImport::~ImpSdrPdfImport()
-{
-FPDF_CloseDocument(mpPdfDocument);
-FPDF_DestroyLibrary();
-}
+ImpSdrPdfImport::~ImpSdrPdfImport() { FPDF_CloseDocument(mpPdfDocument); }
 
 void ImpSdrPdfImport::DoObjects(SvdProgressInfo* pProgrInfo, sal_uInt32* 
pActionsToReport,
 int nPageIndex)
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/qa vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|   12 +++-
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   79 +
 vcl/source/graphic/VectorGraphicSearch.cxx |   28 +++---
 3 files changed, 90 insertions(+), 29 deletions(-)

New commits:
commit d7e75f660b3cdfa43ffa572f7a150263b7ed27e8
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 23:52:50 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:27:19 2020 +0200

vcl: add search start position support for VectorGraphicSearch

By default we start at the begin of the page, but with this change
make it possible to start at the end. This makes it possible to
search in the backwards direction (set the start position at to
the end and search with "previous").

Change-Id: I78fb1461b86bf9eab2f91c3b9a81cbb5c6557332
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95382
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 83d27791fed75941c75d3cc571c3d5cf27d14e8c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95930
Tested-by: Tomaž Vajngerl 

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index a00c212ad61c..b67c63a844d8 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -21,6 +21,12 @@
 
 class SearchContext;
 
+enum class SearchStartPosition
+{
+Begin,
+End
+};
+
 class VCL_DLLPUBLIC VectorGraphicSearch final
 {
 private:
@@ -29,12 +35,14 @@ private:
 Graphic maGraphic;
 std::unique_ptr mpSearchContext;
 
-bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString);
+bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString,
+   SearchStartPosition eStartPosition);
 
 public:
 VectorGraphicSearch(Graphic const& rGraphic);
 ~VectorGraphicSearch();
-bool search(OUString const& rSearchString);
+bool search(OUString const& rSearchString,
+SearchStartPosition eStartPosition = 
SearchStartPosition::Begin);
 basegfx::B2DSize pageSize();
 bool next();
 bool previous();
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 7962c23f4e8f..5f65b4ba7e3d 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -93,32 +93,71 @@ void VectorGraphicSearchTest::testNextPrevious()
 Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
 aGraphic.makeAvailable();
 
-VectorGraphicSearch aSearch(aGraphic);
-CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
+{ // Start from the beginning of the page
+VectorGraphicSearch aSearch(aGraphic);
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
 
-// next - first match found
-CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+// no previous - we are at the begin
+CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(0, aSearch.index()); // nothing was yet found, so 
it is 0
 
-// next - second match found
-CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+// next - first position found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
 
-// next - not found, index unchanged
-CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+// next - second position found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
 
-// previous - first match
-CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
-CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+// next - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
 
-// previous - not found, index unchanged
-CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
-CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+// previous - first position
+CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
 
-// next - second match found
-CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
-CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+// previous - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// next - second position found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+}
+
+{ // Start from the end of the page
+VectorGraphicSearch aSearch(aGraphic);
+CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy", 
SearchStartPosition::End));
+
+// no next - we are at the end
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/graphic/VectorGraphicSearch.cxx |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit c1a973678474c9775730ae577ec349b76ff356bb
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 09:51:33 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:27:53 2020 +0200

vcl: VectorGraphicSearch - clean-up SearchContext member vars.

Change-Id: I1740be5ed1b47235da3794fa46e3533b17ca1fb8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95390
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 40d682542f02d78b5ed6bd4fc0ba461a1a7fb5f1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95932

diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index 42d98a981ef9..94d954516f13 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -34,26 +34,26 @@ public:
 
 class SearchContext
 {
-public:
-bool bInitialized = false;
-
+private:
 FPDF_DOCUMENT mpPdfDocument;
-sal_Int32 mnPageIndex;
 FPDF_PAGE mpPage;
 FPDF_TEXTPAGE mpTextPage;
+FPDF_SCHHANDLE mpSearchHandle;
+
+public:
+sal_Int32 mnPageIndex;
 OUString maSearchString;
 SearchStartPosition meStartPosition;
-FPDF_SCHHANDLE mpSearchHandle;
 
 SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex, OUString 
const& rSearchString,
   SearchStartPosition eStartPosition)
 : mpPdfDocument(pPdfDocument)
-, mnPageIndex(nPageIndex)
 , mpPage(nullptr)
 , mpTextPage(nullptr)
+, mpSearchHandle(nullptr)
+, mnPageIndex(nPageIndex)
 , maSearchString(rSearchString)
 , meStartPosition(eStartPosition)
-, mpSearchHandle(nullptr)
 {
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/inc sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/inc/Outliner.hxx|4 +
 sd/source/ui/view/Outliner.cxx |  110 ++---
 2 files changed, 65 insertions(+), 49 deletions(-)

New commits:
commit 6eec4e40f6f8ea88d3136295d5485ee73ef7bf2c
Author: Tomaž Vajngerl 
AuthorDate: Wed May 27 14:07:10 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 14:01:04 2020 +0200

sd: move LOK search result logic to it's own method

Change-Id: I67cbe4d3d63bffdab72c09b3a956f67806588348
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95306
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit e9dbdc9fc6ff943650e6e18986ed1cce913971ef)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95917
Tested-by: Tomaž Vajngerl 

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index d935d6f1d6a8..39e2720f6a01 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -355,6 +355,10 @@ private:
 */
 bool SearchAndReplaceOnce(std::vector<::sd::SearchSelection>* pSelections 
= nullptr);
 
+void sendLOKSearchResultCallback(std::shared_ptr& 
pViewShell,
+ OutlinerView* pOutlinerView,
+ std::vector* 
pSelections);
+
 /** Detect changes of the document or view and react accordingly.  Such
 changes may occur because different calls to
 SearchAndReplace() there usually is user
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e7f676f43e4e..6e982f3d25f7 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -673,6 +673,66 @@ bool SdOutliner::SearchAndReplaceAll()
 return bRet;
 }
 
+void SdOutliner::sendLOKSearchResultCallback(std::shared_ptr & 
pViewShell,
+ OutlinerView* pOutlinerView,
+ std::vector* 
pSelections)
+{
+std::vector<::tools::Rectangle> aLogicRects;
+pOutlinerView->GetSelectionRectangles(aLogicRects);
+
+// convert to twips if in 100thmm (seems as if LibreOfficeKit is based on 
twips?). Do this
+// here where we have the only place needing this, *not* in 
ImpEditView::GetSelectionRectangles
+// which makes that method unusable for others
+if (pOutlinerView->GetWindow() && MapUnit::Map100thMM == 
pOutlinerView->GetWindow()->GetMapMode().GetMapUnit())
+{
+for (tools::Rectangle& rRectangle : aLogicRects)
+{
+rRectangle = OutputDevice::LogicToLogic(rRectangle, 
MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+}
+}
+
+std::vector aLogicRectStrings;
+std::transform(aLogicRects.begin(), aLogicRects.end(), 
std::back_inserter(aLogicRectStrings),
+[](const ::tools::Rectangle& rRectangle)
+{
+return rRectangle.toString();
+});
+
+OString sRectangles = comphelper::string::join("; ", aLogicRectStrings);
+
+if (!pSelections)
+{
+// notify LibreOfficeKit about changed page
+OString aPayload = OString::number(maCurrentPosition.mnPageIndex);
+SfxViewShell& rSfxViewShell = pViewShell->GetViewShellBase();
+rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, 
aPayload.getStr());
+
+// also about search result selections
+boost::property_tree::ptree aTree;
+aTree.put("searchString", 
mpSearchItem->GetSearchString().toUtf8().getStr());
+aTree.put("highlightAll", false);
+
+boost::property_tree::ptree aChildren;
+boost::property_tree::ptree aChild;
+aChild.put("part", 
OString::number(maCurrentPosition.mnPageIndex).getStr());
+aChild.put("rectangles", sRectangles.getStr());
+aChildren.push_back(std::make_pair("", aChild));
+aTree.add_child("searchResultSelection", aChildren);
+
+std::stringstream aStream;
+boost::property_tree::write_json(aStream, aTree);
+aPayload = aStream.str().c_str();
+
rSfxViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_SEARCH_RESULT_SELECTION, 
aPayload.getStr());
+}
+else
+{
+sd::SearchSelection aSelection(maCurrentPosition.mnPageIndex, 
sRectangles);
+bool bDuplicate = !pSelections->empty() && pSelections->back() == 
aSelection;
+if (!bDuplicate)
+pSelections->push_back(aSelection);
+}
+}
+
 bool SdOutliner::SearchAndReplaceOnce(std::vector* 
pSelections)
 {
 DetectChange ();
@@ -764,55 +824,7 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 
 if (pViewShell && comphelper::LibreOfficeKit::isActive() && mbStringFound)
 {
-std::vector<::tools::Rectangle> aLogicRects;
-pOutlinerView->GetSelectionRectangles(aLogicRects);
-
-// convert to twips if in 100thmm (seems as if LibreOfficeKit is based 
on twips?). Do this
-// here where we have the only place needing this, *not* in 
ImpEditView::GetSelectionRectangles

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/inc sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/inc/Outliner.hxx|7 ---
 sd/source/ui/view/Outliner.cxx |   20 +---
 2 files changed, 13 insertions(+), 14 deletions(-)

New commits:
commit 5bc2314a95199337e796de9be23650a71dff9294
Author: Tomaž Vajngerl 
AuthorDate: Wed May 27 14:13:02 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:18:43 2020 +0200

sd: move IsValidTextObject into source as anon. function

IsValidTextObject is only used internally in Outline, so put it
inside the source file as an anonymous function and not as a
member function of Outliner.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95307
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 14b55b3a8de070935489acd4f6f8be7b6a3d96a4)

Change-Id: I867dc4f465a694e61b6102b19f8e54ce623e2858
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95918
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/inc/Outliner.hxx b/sd/inc/Outliner.hxx
index 39e2720f6a01..3e6514f16b80 100644
--- a/sd/inc/Outliner.hxx
+++ b/sd/inc/Outliner.hxx
@@ -411,13 +411,6 @@ private:
 */
 bool ShowWrapArroundDialog();
 
-/** Check whether the object pointed to by the iterator is a valid text
-object.
-@param aPosition
-The object for which to test whether it is a valid text object.
-*/
-static bool IsValidTextObject (const ::sd::outliner::IteratorPosition& 
rPosition);
-
 /** Put text of current text object into outliner so that the text can
 be searched/spell checked.
 */
diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 6e982f3d25f7..e77e60c5d305 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1024,6 +1024,18 @@ void SdOutliner::RestoreStartPosition()
 }
 }
 
+namespace
+{
+
+bool lclIsValidTextObject(const sd::outliner::IteratorPosition& rPosition)
+{
+auto* pObject = dynamic_cast< SdrTextObj* >( rPosition.mxObject.get() );
+return (pObject != nullptr) && pObject->HasText() && ! 
pObject->IsEmptyPresObj();
+}
+
+} // end anonymous namespace
+
+
 /** The main purpose of this method is to iterate over all shape objects of
 the search area (current selection, current view, or whole document)
 until a text object has been found that contains at least one match or
@@ -1069,7 +1081,7 @@ void SdOutliner::ProvideNextTextObject()
 bool bForbiddenPage = comphelper::LibreOfficeKit::isActive() && 
(maCurrentPosition.mePageKind != PageKind::Standard || 
maCurrentPosition.meEditMode != EditMode::Page);
 
 // Switch to the current object only if it is a valid text object.
-if (!bForbiddenPage && IsValidTextObject(maCurrentPosition))
+if (!bForbiddenPage && lclIsValidTextObject(maCurrentPosition))
 {
 // Don't set yet in case of searching: the text object may not 
match.
 if (meMode != SEARCH)
@@ -1237,12 +1249,6 @@ bool SdOutliner::ShowWrapArroundDialog()
 return (nBoxResult == RET_YES);
 }
 
-bool SdOutliner::IsValidTextObject (const sd::outliner::IteratorPosition& 
rPosition)
-{
-SdrTextObj* pObject = dynamic_cast< SdrTextObj* >( 
rPosition.mxObject.get() );
-return (pObject != nullptr) && pObject->HasText() && ! 
pObject->IsEmptyPresObj();
-}
-
 void SdOutliner::PutTextIntoOutliner()
 {
 mpSearchSpellTextObj = dynamic_cast( mpObj );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   18 ++
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit 7824545abeb308a89c08aa98e20901df05934625
Author: Tomaž Vajngerl 
AuthorDate: Wed May 27 14:20:44 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:19:10 2020 +0200

sd: in Outline add getViewShellBase to simplify code

This simplifies constant casting of SfxViewShell::Current to
sd::ViewShellBase. Instead of doing it in every method, let's
have a dedicated function for that.

Change-Id: Iadbe446c7edce5df40c2da14e3eee65012dd4d77
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95308
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 29e06da2b63441f4458c482eae1cd36bd10b4728)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95919

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index e77e60c5d305..e98c1bde5795 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -111,6 +111,16 @@ private:
 OutlinerView* mpOutlineView;
 };
 
+namespace
+{
+
+sd::ViewShellBase* getViewShellBase()
+{
+return dynamic_cast(SfxViewShell::Current());
+}
+
+} // end anonymous namespace
+
 SdOutliner::SdOutliner( SdDrawDocument* pDoc, OutlinerMode nMode )
 : SdrOutliner( >GetItemPool(), nMode ),
   mpImpl(new Implementation()),
@@ -228,7 +238,7 @@ void SdOutliner::PrepareSpelling()
 {
 mbPrepareSpellingPending = false;
 
-sd::ViewShellBase* pBase = dynamic_cast< sd::ViewShellBase *>( 
SfxViewShell::Current() );
+sd::ViewShellBase* pBase = getViewShellBase();
 if (pBase != nullptr)
 SetViewShell (pBase->GetMainViewShell());
 SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
@@ -270,7 +280,7 @@ void SdOutliner::EndSpelling()
 std::shared_ptr pViewShell (mpWeakViewShell.lock());
 std::shared_ptr pOldViewShell (pViewShell);
 
-sd::ViewShellBase* pBase = dynamic_cast< sd::ViewShellBase *>( 
SfxViewShell::Current() );
+sd::ViewShellBase* pBase = getViewShellBase();
 if (pBase != nullptr)
 pViewShell = pBase->GetMainViewShell();
 else
@@ -413,7 +423,7 @@ bool SdOutliner::StartSearchAndReplace (const 
SvxSearchItem* pSearchItem)
 mpDrawDocument->GetDocSh()->SetWaitCursor( true );
 if (mbPrepareSpellingPending)
 PrepareSpelling();
-sd::ViewShellBase* pBase = dynamic_cast< sd::ViewShellBase *>( 
SfxViewShell::Current() );
+sd::ViewShellBase* pBase = getViewShellBase();
 // Determine whether we have to abort the search.  This is necessary
 // when the main view shell does not support searching.
 bool bAbort = false;
@@ -1618,7 +1628,7 @@ void SdOutliner::BeginConversion()
 {
 SetRefDevice( SD_MOD()->GetVirtualRefDevice() );
 
-sd::ViewShellBase* pBase = dynamic_cast( 
SfxViewShell::Current() );
+sd::ViewShellBase* pBase = getViewShellBase();
 if (pBase != nullptr)
 SetViewShell (pBase->GetMainViewShell());
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|3 -
 vcl/source/graphic/VectorGraphicSearch.cxx |   76 +++--
 2 files changed, 40 insertions(+), 39 deletions(-)

New commits:
commit 044cfb405e44c5df25bccd6e421a1a228262a963
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 12:02:39 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:28:53 2020 +0200

vcl: VectorGraphicSearch - move SearchContext into Implementation

Change-Id: I3bbf085fd8b8b66a56e364168c1e70b4ce986467
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95392
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 978198a055972aff00f47b70ca79e6322a5fbac3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95934

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index b67c63a844d8..2dc8cca3b76a 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -19,8 +19,6 @@
 
 #include 
 
-class SearchContext;
-
 enum class SearchStartPosition
 {
 Begin,
@@ -33,7 +31,6 @@ private:
 class Implementation;
 std::unique_ptr mpImplementation;
 Graphic maGraphic;
-std::unique_ptr mpSearchContext;
 
 bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString,
SearchStartPosition eStartPosition);
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index 5c4022685f71..911c19cebd38 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -17,25 +17,8 @@
 #include 
 #include 
 
-class VectorGraphicSearch::Implementation
+namespace
 {
-public:
-std::shared_ptr mpPDFium;
-FPDF_DOCUMENT mpPdfDocument;
-
-Implementation()
-: mpPDFium(vcl::pdf::PDFiumLibrary::get())
-, mpPdfDocument(nullptr)
-{
-}
-
-~Implementation()
-{
-if (mpPdfDocument)
-FPDF_CloseDocument(mpPdfDocument);
-}
-};
-
 class SearchContext
 {
 private:
@@ -181,17 +164,38 @@ public:
 }
 };
 
+} // end anonymous namespace
+
+class VectorGraphicSearch::Implementation
+{
+public:
+std::shared_ptr mpPDFium;
+FPDF_DOCUMENT mpPdfDocument;
+
+std::unique_ptr mpSearchContext;
+
+Implementation()
+: mpPDFium(vcl::pdf::PDFiumLibrary::get())
+, mpPdfDocument(nullptr)
+{
+}
+
+~Implementation()
+{
+mpSearchContext.reset();
+
+if (mpPdfDocument)
+FPDF_CloseDocument(mpPdfDocument);
+}
+};
+
 VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
 : mpImplementation(std::make_unique())
 , maGraphic(rGraphic)
 {
 }
 
-VectorGraphicSearch::~VectorGraphicSearch()
-{
-mpSearchContext.reset();
-mpImplementation.reset();
-}
+VectorGraphicSearch::~VectorGraphicSearch() { mpImplementation.reset(); }
 
 bool VectorGraphicSearch::search(OUString const& rSearchString, 
SearchStartPosition eStartPosition)
 {
@@ -242,45 +246,45 @@ bool 
VectorGraphicSearch::searchPDF(std::shared_ptr const& rD
 
 sal_Int32 nPageIndex = std::max(rData->getPageIndex(), sal_Int32(0));
 
-mpSearchContext.reset(new SearchContext(mpImplementation->mpPdfDocument, 
nPageIndex,
-rSearchString, eStartPosition));
+mpImplementation->mpSearchContext.reset(new SearchContext(
+mpImplementation->mpPdfDocument, nPageIndex, rSearchString, 
eStartPosition));
 
-return mpSearchContext->initialize();
+return mpImplementation->mpSearchContext->initialize();
 }
 
 basegfx::B2DSize VectorGraphicSearch::pageSize()
 {
 basegfx::B2DSize aSize;
-if (mpSearchContext)
-aSize = mpSearchContext->getPageSize();
+if (mpImplementation->mpSearchContext)
+aSize = mpImplementation->mpSearchContext->getPageSize();
 return aSize;
 }
 
 bool VectorGraphicSearch::next()
 {
-if (mpSearchContext)
-return mpSearchContext->next();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->next();
 return false;
 }
 
 bool VectorGraphicSearch::previous()
 {
-if (mpSearchContext)
-return mpSearchContext->previous();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->previous();
 return false;
 }
 
 int VectorGraphicSearch::index()
 {
-if (mpSearchContext)
-return mpSearchContext->index();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->index();
 return -1;
 }
 
 std::vector VectorGraphicSearch::getTextRectangles()
 {
-if (mpSearchContext)
-return mpSearchContext->getTextRectangles();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->getTextRectangles();
 
 return std::vector();
 }
___
Libreoffice-commits 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/qa vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|2 +
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   51 ++---
 vcl/source/graphic/VectorGraphicSearch.cxx |   31 +
 3 files changed, 65 insertions(+), 19 deletions(-)

New commits:
commit f73fef6b9b519adaadf51abb5aa1fb3dd0cda9a9
Author: Tomaž Vajngerl 
AuthorDate: Sun May 17 20:32:49 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 13:41:49 2020 +0200

vcl: VectorGraphicSearch return text rectangles in 100th mm

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95261
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 936a670f61fed891f8aaec77b2422f366240f193)

Change-Id: I12e7ad10dc3ed68d20d94713acece1361da27e81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95834
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 41c7745d0cf5..5420e161448b 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -15,6 +15,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -34,6 +35,7 @@ public:
 VectorGraphicSearch(Graphic const& rGraphic);
 ~VectorGraphicSearch();
 bool search(OUString const& rSearchString);
+basegfx::B2DSize pageSize();
 bool next();
 int index();
 std::vector getTextRectangles();
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 112748d23bbe..01022a3fe225 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -44,28 +44,41 @@ void VectorGraphicSearchTest::test()
 CPPUNIT_ASSERT_EQUAL(true, aSearch.search("lazy"));
 CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
 CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+basegfx::B2DSize aSize = aSearch.pageSize();
+CPPUNIT_ASSERT_DOUBLES_EQUAL(21590.00, aSize.getX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(27940.00, aSize.getY(), 1E-2);
+
 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);
+// Check first and last
+CPPUNIT_ASSERT_DOUBLES_EQUAL(8078.61, aRectangles[0].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(8179.36, aRectangles[0].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(2101.56, aRectangles[0].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(2395.36, aRectangles[0].getMaxY(), 1E-2);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(8565.86, aRectangles[3].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(8770.76, aRectangles[3].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(2201.05, aRectangles[3].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(2486.37, aRectangles[3].getMaxY(), 1E-2);
+
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+aRectangles = aSearch.getTextRectangles();
+CPPUNIT_ASSERT_EQUAL(size_t(4), aRectangles.size());
+
+// Check first and last
+CPPUNIT_ASSERT_DOUBLES_EQUAL(6562.23, aRectangles[0].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(6662.98, aRectangles[0].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(5996.23, aRectangles[0].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(6290.02, aRectangles[0].getMaxY(), 1E-2);
+
+CPPUNIT_ASSERT_DOUBLES_EQUAL(7049.48, aRectangles[3].getMinX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(7254.38, aRectangles[3].getMaxX(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(6095.71, aRectangles[3].getMinY(), 1E-2);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(6381.04, aRectangles[3].getMaxY(), 1E-2);
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(VectorGraphicSearchTest);
diff --git 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - tools/qa

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 tools/qa/cppunit/test_100mm2twips.cxx |   38 +-
 1 file changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 20e02bc30ada3c824a6d025d96af1b1de8a608e9
Author: Tomaž Vajngerl 
AuthorDate: Thu May 21 11:47:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 13:42:27 2020 +0200

tools: extend test for UnitConversion

Change-Id: I8fbc2a83f40fb04656f690b4b63d3cac9f0410c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95273
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit b1c007cd06c01078df481e020d9d81afd4de6a91)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95835
Tested-by: Tomaž Vajngerl 

diff --git a/tools/qa/cppunit/test_100mm2twips.cxx 
b/tools/qa/cppunit/test_100mm2twips.cxx
index 80ceda2ffb3f..bfed8c2e2ba9 100644
--- a/tools/qa/cppunit/test_100mm2twips.cxx
+++ b/tools/qa/cppunit/test_100mm2twips.cxx
@@ -23,29 +23,39 @@
 #include 
 
 #include 
+#include 
 
-namespace tools
-{
-class cm2TwipsTest : public CppUnit::TestFixture
+class UnitConversionTest : public CppUnit::TestFixture
 {
 public:
-void testConvert()
+void testSanitiseMm100ToTwip()
+{
+CPPUNIT_ASSERT_EQUAL(sal_Int64(145), sanitiseMm100ToTwip(255));
+CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), sanitiseMm100ToTwip(-255));
+}
+
+void testConvertMm100ToTwip()
+{
+CPPUNIT_ASSERT_EQUAL(sal_Int64(145), convertMm100ToTwip(255));
+CPPUNIT_ASSERT_EQUAL(sal_Int64(-145), convertMm100ToTwip(-255));
+}
+
+void testConvertPointToMm100()
 {
-sal_Int32 nActual = sanitiseMm100ToTwip(255);
-sal_Int32 nExpected = 145;
-CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(599.72, convertPointToMm100(17.0), 1E-2);
+CPPUNIT_ASSERT_EQUAL(sal_Int64(600), 
convertPointToMm100(sal_Int64(17)));
 
-nActual = sanitiseMm100ToTwip(-255);
-nExpected = -145;
-CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(22930.55, convertPointToMm100(650.0), 
1E-2);
+CPPUNIT_ASSERT_EQUAL(sal_Int64(22931), 
convertPointToMm100(sal_Int64(650)));
 }
 
-CPPUNIT_TEST_SUITE(cm2TwipsTest);
-CPPUNIT_TEST(testConvert);
+CPPUNIT_TEST_SUITE(UnitConversionTest);
+CPPUNIT_TEST(testSanitiseMm100ToTwip);
+CPPUNIT_TEST(testConvertMm100ToTwip);
+CPPUNIT_TEST(testConvertPointToMm100);
 CPPUNIT_TEST_SUITE_END();
 };
 
-CPPUNIT_TEST_SUITE_REGISTRATION(cm2TwipsTest);
-} // namespace tools
+CPPUNIT_TEST_SUITE_REGISTRATION(UnitConversionTest);
 
 /* 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 'distro/collabora/cp-6.4' - sd/qa sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   93 --
 sd/qa/unit/tiledrendering/data/PDFSearch.pdf  |binary
 sd/source/ui/view/Outliner.cxx|   15 
 3 files changed, 102 insertions(+), 6 deletions(-)

New commits:
commit fb81d3f064b24a4fa0585eaac4e5811443a45768
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 23:06:57 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:25:25 2020 +0200

sd: fix not found case in PDF search + add PDF Search tests

When searching the PDF and the search text is not found (anymore)
in the current VectorGraphicSearch, we need to remove it and mark
that we don't currently search in a vector graphic (PDF) anymore.
This wasn't handled correctly and caused a crash.

In addition add a LOKit test for search into a PDF document, to
make sure the not-found case and usual searching case are working
correctly.

Change-Id: I663a6b2cf4879f11d62e440ea0c35ffcd205f81f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95380
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit a99aef3cf0a8ff3f04077d1530d1602505cecaae)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95927

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 4474bd8e4751..33257f12d4ab 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -24,10 +24,14 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 
 using namespace css;
@@ -38,7 +42,7 @@ private:
 static constexpr char DATA_DIRECTORY[] = 
"/sd/qa/unit/tiledrendering/data/";
 
 public:
-LOKitSearchTest() {}
+LOKitSearchTest() = default;
 
 virtual void setUp() override;
 virtual void tearDown() override;
@@ -49,6 +53,8 @@ public:
 void testSearchAllNotifications();
 void testSearchAllFollowedBySearch();
 void testDontSearchInMasterPages();
+void testSearchInPDFNonExisting();
+void testSearchInPDF();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -57,6 +63,8 @@ public:
 CPPUNIT_TEST(testSearchAllNotifications);
 CPPUNIT_TEST(testSearchAllFollowedBySearch);
 CPPUNIT_TEST(testDontSearchInMasterPages);
+CPPUNIT_TEST(testSearchInPDFNonExisting);
+CPPUNIT_TEST(testSearchInPDF);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -96,9 +104,11 @@ LOKitSearchTest::createDoc(const char* pName, const 
uno::Sequencedispose();
+
 mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY)
-  + OUString::createFromAscii(pName),
-  
"com.sun.star.presentation.PresentationDocument");
+  + OUString::createFromAscii(pName));
+
+CPPUNIT_ASSERT(mxComponent.is());
 SdXImpressDocument* pImpressDocument = 
dynamic_cast(mxComponent.get());
 CPPUNIT_ASSERT(pImpressDocument);
 pImpressDocument->initializeForTiledRendering(rArguments);
@@ -109,15 +119,20 @@ namespace
 {
 void lcl_search(const OUString& rKey, bool bFindAll = false)
 {
+Scheduler::ProcessEventsToIdle();
+SvxSearchCmd eSearch = bFindAll ? SvxSearchCmd::FIND_ALL : 
SvxSearchCmd::FIND;
+
 uno::Sequence 
aPropertyValues(comphelper::InitPropertySequence({
 { "SearchItem.SearchString", uno::makeAny(rKey) },
 { "SearchItem.Backward", uno::makeAny(false) },
-{ "SearchItem.Command", uno::makeAny(static_cast(
-bFindAll ? SvxSearchCmd::FIND_ALL : 
SvxSearchCmd::FIND)) },
+{ "SearchItem.Command", uno::makeAny(sal_uInt16(eSearch)) },
 }));
+
 comphelper::dispatchCommand(".uno:ExecuteSearch", aPropertyValues);
+Scheduler::ProcessEventsToIdle();
 }
-}
+
+} // end anonymous namespace
 
 void LOKitSearchTest::testSearch()
 {
@@ -228,6 +243,72 @@ void LOKitSearchTest::testDontSearchInMasterPages()
 CPPUNIT_ASSERT_EQUAL(false, mpCallbackRecorder->m_bFound);
 }
 
+void LOKitSearchTest::testSearchInPDFNonExisting()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/vcl vcl/qa vcl/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|1 
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   40 +
 vcl/source/graphic/VectorGraphicSearch.cxx |   14 ++
 3 files changed, 55 insertions(+)

New commits:
commit 9d653f4962aae4dae6c0d4166f020354a5f82711
Author: Tomaž Vajngerl 
AuthorDate: Fri May 29 23:26:51 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:26:27 2020 +0200

vcl: add "previous" search to VectorGraphicSearch

Previous moves backwards in the search matches.

Change-Id: I88d402e0b8cb9dc4fd93e7f1ce5b08fb42aadd06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95381
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit e20440effc7a47c8a5e8ef0943e6872cd9b3646a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95929
Tested-by: Tomaž Vajngerl 

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index 5420e161448b..a00c212ad61c 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -37,6 +37,7 @@ public:
 bool search(OUString const& rSearchString);
 basegfx::B2DSize pageSize();
 bool next();
+bool previous();
 int index();
 std::vector getTextRectangles();
 };
diff --git a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx 
b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
index 01022a3fe225..7962c23f4e8f 100644
--- a/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
+++ b/vcl/qa/cppunit/VectorGraphicSearchTest.cxx
@@ -26,9 +26,11 @@ class VectorGraphicSearchTest : public 
test::BootstrapFixtureBase
 }
 
 void test();
+void testNextPrevious();
 
 CPPUNIT_TEST_SUITE(VectorGraphicSearchTest);
 CPPUNIT_TEST(test);
+CPPUNIT_TEST(testNextPrevious);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -81,6 +83,44 @@ void VectorGraphicSearchTest::test()
 CPPUNIT_ASSERT_DOUBLES_EQUAL(6381.04, aRectangles[3].getMaxY(), 1E-2);
 }
 
+// Test next and previous work as expected to move
+// between search matches.
+void VectorGraphicSearchTest::testNextPrevious()
+{
+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"));
+
+// next - first match found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// next - second match found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+// next - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, aSearch.index());
+
+// previous - first match
+CPPUNIT_ASSERT_EQUAL(true, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// previous - not found, index unchanged
+CPPUNIT_ASSERT_EQUAL(false, aSearch.previous());
+CPPUNIT_ASSERT_EQUAL(34, aSearch.index());
+
+// next - second match found
+CPPUNIT_ASSERT_EQUAL(true, aSearch.next());
+CPPUNIT_ASSERT_EQUAL(817, 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 d54f32930276..8b73cab71340 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -104,6 +104,13 @@ public:
 return false;
 }
 
+bool previous()
+{
+if (mpSearchHandle)
+return FPDFText_FindPrev(mpSearchHandle);
+return false;
+}
+
 int index()
 {
 if (mpSearchHandle)
@@ -245,6 +252,13 @@ bool VectorGraphicSearch::next()
 return false;
 }
 
+bool VectorGraphicSearch::previous()
+{
+if (mpSearchContext)
+return mpSearchContext->previous();
+return false;
+}
+
 int VectorGraphicSearch::index()
 {
 if (mpSearchContext)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   24 +---
 1 file changed, 5 insertions(+), 19 deletions(-)

New commits:
commit e1c7df9482175dff16baa8720d4f0e962b671a35
Author: Tomaž Vajngerl 
AuthorDate: Tue Jun 2 23:15:03 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 15:25:49 2020 +0200

sd: use getPDFSelection to get the search selection for LOKit

This reduces code duplication.

Change-Id: I0a6a44d696841d1573d23f87353ac055cc92c83a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95386
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit fcc13ba6a0121cfdf70d1f39318a024777247559)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95928
Tested-by: Tomaž Vajngerl 

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index c33f07ee913c..1275a55fa801 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -742,26 +742,12 @@ void 
SdOutliner::sendLOKSearchResultCallback(std::shared_ptr & pV
 std::vector<::tools::Rectangle> aLogicRects;
 if (mpImpl->mbCurrentIsVectorGraphic)
 {
-basegfx::B2DSize aPdfPageSize = 
mpImpl->mpVectorGraphicSearch->pageSize();
+basegfx::B2DRectangle aSelectionHMM = 
getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
 
-tools::Rectangle aObjectRectTwip = 
OutputDevice::LogicToLogic(mpObj->GetLogicRect(), MapMode(MapUnit::Map100thMM), 
MapMode(MapUnit::MapTwip));
-basegfx::B2DRectangle 
aObjectB2DRectTwip(vcl::unotools::b2DRectangleFromRectangle(aObjectRectTwip));
-
-// Setup coordinate conversion matrix to convert the inner PDF
-// coordinates to the page relative coordinates
-basegfx::B2DHomMatrix aB2DMatrix;
-
-aB2DMatrix.scale(aObjectB2DRectTwip.getWidth() / aPdfPageSize.getX(),
- aObjectB2DRectTwip.getHeight() / aPdfPageSize.getY());
-
-aB2DMatrix.translate(aObjectB2DRectTwip.getMinX(), 
aObjectB2DRectTwip.getMinY());
-
-for (auto const & rRectangle : 
mpImpl->mpVectorGraphicSearch->getTextRectangles())
-{
-basegfx::B2DRectangle aRectangle(rRectangle);
-aRectangle *= aB2DMatrix;
-aLogicRects.emplace_back(Point(aRectangle.getMinX(), 
aRectangle.getMinY()), Size(aRectangle.getWidth(), aRectangle.getHeight()));
-}
+tools::Rectangle aSelection(Point(aSelectionHMM.getMinX(), 
aSelectionHMM.getMinY()),
+Size(aSelectionHMM.getWidth(), 
aSelectionHMM.getHeight()));
+aSelection = OutputDevice::LogicToLogic(aSelection, 
MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
+aLogicRects.push_back(aSelection);
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 include/svx/svxdllapi.h |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 43cc9f234306bae44ecc57d7820a5be04e91dcf3
Author: Tomaž Vajngerl 
AuthorDate: Sun Jun 7 20:32:01 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:42:16 2020 +0200

Add SVXCORE_DLLPUBLIC to svxdllapi.h

Change-Id: Ic612f9987ee46fcc317e47eb2e7771136b875ce5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95780
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/svx/svxdllapi.h b/include/svx/svxdllapi.h
index a5ee4ec859c2..3e3de30c4ae1 100644
--- a/include/svx/svxdllapi.h
+++ b/include/svx/svxdllapi.h
@@ -29,6 +29,12 @@
 #endif
 #define SVX_DLLPRIVATE SAL_DLLPRIVATE
 
+#if defined(SVXCORE_DLLIMPLEMENTATION)
+#define SVXCORE_DLLPUBLIC SAL_DLLPUBLIC_EXPORT
+#else
+#define SVXCORE_DLLPUBLIC SAL_DLLPUBLIC_IMPORT
+#endif
+
 #endif // INCLUDED_SVX_SVXDLLAPI_H
 
 /* 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 'distro/collabora/cp-6.4' - svx/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 svx/source/svdraw/svdpdf.cxx |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit 88c70ae002120f46e1f9a2a5cac2f73f835a4984
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 30 19:07:44 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:43:54 2020 +0200

SdrPdfImport: fix garbled text at breaking the PDF graphic

The text size of OUString expects no. of characters, but we give
the number of bytes as that is what we get from PDFium. Best to
just not give the text size at all and let OUString determine
that as the text shouldbe terminated correctly.

Change-Id: Icc5cd6e851a9d2920faa9ca2eb6d827465483e72
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93330
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit d4190effb9068dff5ebd3c01c7e3073b1af78b2d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95782
Tested-by: Tomaž Vajngerl 

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 106718a34aa9..78bb7131ae13 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -810,16 +810,19 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 const tools::Rectangle aRect = PointsToLogic(aTextRect.getMinX(), 
aTextRect.getMaxX(),
  aTextRect.getMinY(), 
aTextRect.getMaxY());
 
-const int nChars = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0);
-std::unique_ptr pText(new sal_Unicode[nChars]);
+const int nBytes = FPDFTextObj_GetText(pPageObject, pTextPage, nullptr, 0);
+std::unique_ptr pText(new sal_Unicode[nBytes]);
 
-const int nActualChars = FPDFTextObj_GetText(pPageObject, pTextPage, 
pText.get(), nChars);
-if (nActualChars <= 0)
+const int nActualBytes = FPDFTextObj_GetText(pPageObject, pTextPage, 
pText.get(), nBytes);
+if (nActualBytes <= 0)
 {
 return;
 }
 
-OUString sText(pText.get(), nActualChars);
+// Let's rely on null-terminaton for the length of the string. We
+// just know the number of bytes the string takes, but in OUString
+// needs the number of charaters.
+OUString sText(pText.get());
 
 const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
 double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - svx/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 svx/source/svdraw/svdpdf.cxx |   45 +--
 1 file changed, 10 insertions(+), 35 deletions(-)

New commits:
commit 26e52703188d1301f8cac335975bafff58c37ee4
Author: Tomaž Vajngerl 
AuthorDate: Sun May 3 13:03:30 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:44:36 2020 +0200

SdrPdfImport: use convertPointToMm100 for all unit conversion

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93391
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit dba50d5e6c1b4d3d16690ee5b8a9648c652f41e7)

Change-Id: I78b3512cc0b9aea1fa4e9a810ec71eadd00b7635
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95784
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 78bb7131ae13..4d973c433711 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -93,29 +93,13 @@
 
 namespace
 {
-/// Convert from DPI to pixels.
-/// PDFs don't have resolution, rather,
-/// dimensions are in inches, with 72 points / inch.
-/// Here we effectively render at 96 DPI (to match
-/// the image rendered in vcl::ImportPDF in pdfread.cxx).
-double lcl_PointToPixel(double fPoint) { return fPoint * 96. / 72.; }
-
-/// Convert from pixels to logic (twips).
-long lcl_ToLogic(double value)
-{
-// Convert to integral preserving two dp.
-const long in = static_cast(value * 100.);
-const long out = OutputDevice::LogicToLogic(in, MapUnit::MapPixel, 
MapUnit::Map100thMM);
-return out / 100;
-}
-
 double sqrt2(double a, double b) { return sqrt(a * a + b * b); }
-}
 
 struct FPDFBitmapDeleter
 {
 void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); }
 };
+}
 
 using namespace com::sun::star;
 
@@ -260,8 +244,7 @@ void ImpSdrPdfImport::SetupPageScale(const double 
dPageWidth, const double dPage
 mdPageWidthPts = dPageWidth;
 mdPageHeightPts = dPageHeight;
 
-Size aPageSize(lcl_ToLogic(lcl_PointToPixel(dPageWidth)),
-   lcl_ToLogic(lcl_PointToPixel(dPageHeight)));
+Size aPageSize(convertPointToMm100(dPageWidth), 
convertPointToMm100(dPageHeight));
 
 if (aPageSize.Width() && aPageSize.Height() && (!maScaleRect.IsEmpty()))
 {
@@ -827,10 +810,9 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 const double dFontSize = FPDFTextObj_GetFontSize(pPageObject);
 double dFontSizeH = fabs(sqrt2(a, c) * dFontSize);
 double dFontSizeV = fabs(sqrt2(b, d) * dFontSize);
-dFontSizeH = lcl_PointToPixel(dFontSizeH);
-dFontSizeV = lcl_PointToPixel(dFontSizeV);
-dFontSizeH = lcl_ToLogic(dFontSizeH);
-dFontSizeV = lcl_ToLogic(dFontSizeV);
+
+dFontSizeH = convertPointToMm100(dFontSizeH);
+dFontSizeV = convertPointToMm100(dFontSizeV);
 
 const Size aFontSize(dFontSizeH, dFontSizeV);
 vcl::Font aFnt = mpVD->GetFont();
@@ -1129,7 +,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
 float fWidth = 1;
 FPDFPageObj_GetStrokeWidth(pPageObject, );
 const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * 
fWidth);
-mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth));
+mnLineWidth = convertPointToMm100(dWidth);
 
 int nFillMode = FPDF_FILLMODE_ALTERNATE;
 FPDF_BOOL bStroke = 1; // Assume we have to draw, unless told otherwise.
@@ -1169,10 +1151,8 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT 
pPageObject, int /*nPageObjectI
 Point ImpSdrPdfImport::PointsToLogic(double x, double y) const
 {
 y = correctVertOrigin(y);
-x = lcl_PointToPixel(x);
-y = lcl_PointToPixel(y);
 
-Point aPos(lcl_ToLogic(x), lcl_ToLogic(y));
+Point aPos(convertPointToMm100(x), convertPointToMm100(y));
 return aPos;
 }
 
@@ -1182,15 +1162,10 @@ tools::Rectangle ImpSdrPdfImport::PointsToLogic(double 
left, double right, doubl
 top = correctVertOrigin(top);
 bottom = correctVertOrigin(bottom);
 
-left = lcl_PointToPixel(left);
-right = lcl_PointToPixel(right);
-top = lcl_PointToPixel(top);
-bottom = lcl_PointToPixel(bottom);
+Point aPos(convertPointToMm100(left), convertPointToMm100(top));
+Size aSize(convertPointToMm100(right - left), convertPointToMm100(bottom - 
top));
 
-Point aPos(lcl_ToLogic(left), lcl_ToLogic(top));
-Size aSize(lcl_ToLogic(right - left), lcl_ToLogic(bottom - top));
-tools::Rectangle aRect(aPos, aSize);
-return aRect;
+return tools::Rectangle(aPos, aSize);
 }
 
 #endif // HAVE_FEATURE_PDFIUM
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/tools

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 include/tools/UnitConversion.hxx |   12 
 include/tools/mapunit.hxx|   11 +--
 2 files changed, 13 insertions(+), 10 deletions(-)

New commits:
commit fab4420f23ae77f8c7266d4b4d44313f2e3129d8
Author: Tomaž Vajngerl 
AuthorDate: Fri May 1 17:20:26 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:44:20 2020 +0200

move unit conversions to UnitConversion, add convertPointToMm100

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93332
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 09e28008376e2f2a187067409d3076e81eba022e)

Change-Id: I3e5a4632e9809562885c1e0ec5c5262acec145d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95783
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/tools/UnitConversion.hxx b/include/tools/UnitConversion.hxx
index 3f2a5d870aee..e59077d8a5fa 100644
--- a/include/tools/UnitConversion.hxx
+++ b/include/tools/UnitConversion.hxx
@@ -10,6 +10,18 @@
 
 #pragma once
 
+constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
+{
+return (n >= 0) ? (n * 127 + 36) / 72 : (n * 127 - 36) / 72;
+}
+
+constexpr sal_Int64 convertPointToMm100(sal_Int64 n) { return 
convertTwipToMm100(n * 20); }
+
+constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
+{
+return (n >= 0) ? (n * 72 + 63) / 127 : (n * 72 - 63) / 127;
+}
+
 // Convert PPT's "master unit" (1/576 inch) to twips
 constexpr sal_Int64 convertMasterUnitToTwip(sal_Int64 n) { return n * 2540.0 / 
576.0; }
 
diff --git a/include/tools/mapunit.hxx b/include/tools/mapunit.hxx
index 2209f4d35261..6112bc7ef461 100644
--- a/include/tools/mapunit.hxx
+++ b/include/tools/mapunit.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_TOOLS_MAPUNIT_HXX
 
 #include 
+#include 
 
 enum class MapUnit
 {
@@ -34,16 +35,6 @@ enum class MapUnit
 LASTENUMDUMMY // used as an error return
 };
 
-constexpr sal_Int64 convertTwipToMm100(sal_Int64 n)
-{
-return (n >= 0)? (n*127+36)/72: (n*127-36)/72;
-}
-
-constexpr sal_Int64 convertMm100ToTwip(sal_Int64 n)
-{
-return (n >= 0)? (n*72+63)/127: (n*72-63)/127;
-}
-
 #endif
 
 /* 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 'distro/collabora/cp-6.4' - svx/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 svx/source/inc/svdpdf.hxx|2 +-
 svx/source/svdraw/svdpdf.cxx |4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 1dd9431056b8e16e6c2c916baa251121c36e0b7e
Author: Tomaž Vajngerl 
AuthorDate: Fri May 1 17:30:22 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:45:35 2020 +0200

SdrPdfImport: rename ImportText to InsertTextObject

There are two ImportText methods, so rename one to something
else to avoid confusion.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/9
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 92b0a4d933d682bfce10fa5f04c7a966f20cde7a)

Change-Id: I1ccc491fca47b2d72ba1f7bd5a75d325819ec041
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95785
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/svx/source/inc/svdpdf.hxx b/svx/source/inc/svdpdf.hxx
index 60894542fb8f..cc3ec7f27bfa 100644
--- a/svx/source/inc/svdpdf.hxx
+++ b/svx/source/inc/svdpdf.hxx
@@ -114,7 +114,7 @@ class SVXCORE_DLLPUBLIC ImpSdrPdfImport final
 void ImportImage(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex);
 void ImportPath(FPDF_PAGEOBJECT pPageObject, int nPageObjectIndex);
 void ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTextPage, int 
nPageObjectIndex);
-void ImportText(const Point& rPos, const Size& rSize, const OUString& 
rStr);
+void InsertTextObject(const Point& rPos, const Size& rSize, const 
OUString& rStr);
 
 void SetupPageScale(const double dPageWidth, const double dPageHeight);
 void SetAttributes(SdrObject* pObj, bool bForceTextAttr = false);
diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index 4d973c433711..b380d478d806 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -872,10 +872,10 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT 
pPageObject, FPDF_TEXTPAGE pTex
 mbFntDirty = true;
 }
 
-ImportText(aRect.TopLeft(), aRect.GetSize(), sText);
+InsertTextObject(aRect.TopLeft(), aRect.GetSize(), sText);
 }
 
-void ImpSdrPdfImport::ImportText(const Point& rPos, const Size& rSize, const 
OUString& rStr)
+void ImpSdrPdfImport::InsertTextObject(const Point& rPos, const Size& rSize, 
const OUString& rStr)
 {
 // calc text box size, add 5% to make it fit safely
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/CppunitTest_sd_pdf_import_test.mk sd/Module_sd.mk sd/qa svx/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 sd/CppunitTest_sd_pdf_import_test.mk |   73 +++
 sd/Module_sd.mk  |1 
 sd/qa/unit/SdrPdfImportTest.cxx  |  129 +++
 sd/qa/unit/data/SimplePDF.pdf|binary
 svx/source/inc/svdpdf.hxx|4 -
 svx/source/svdraw/svdedtv2.cxx   |2 
 svx/source/svdraw/svdpdf.cxx |2 
 7 files changed, 207 insertions(+), 4 deletions(-)

New commits:
commit ab95f37716c031e4824ed9ff622ea2a613a56ad3
Author: Tomaž Vajngerl 
AuthorDate: Mon May 4 08:49:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:42:56 2020 +0200

SdrPdfImport: add a test class to sd and write a simple test

Open a simple PDF document, run the "break" action, check that
we get the expected text as a text object.

Change-Id: Iadb458f06b437689202eb013cb900edaabf17673
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93395
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95702
Tested-by: Tomaž Vajngerl 

diff --git a/sd/CppunitTest_sd_pdf_import_test.mk 
b/sd/CppunitTest_sd_pdf_import_test.mk
new file mode 100644
index ..4326c9cdede0
--- /dev/null
+++ b/sd/CppunitTest_sd_pdf_import_test.mk
@@ -0,0 +1,73 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#
+# 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/.
+#
+
+$(eval $(call gb_CppunitTest_CppunitTest,sd_pdf_import_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_pdf_import_test, \
+sd/qa/unit/SdrPdfImportTest \
+))
+
+$(eval $(call gb_CppunitTest_use_externals,sd_pdf_import_test, \
+boost_headers \
+$(if $(filter PDFIUM,$(BUILD_TYPE)),pdfium) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sd_pdf_import_test,\
+-I$(SRCDIR)/sd/inc \
+-I$(SRCDIR)/sd/source/ui/inc \
+-I$(SRCDIR)/sd/source/ui/slidesorter/inc \
+-I$(SRCDIR)/svx/source/inc \
+-I$(SRCDIR)/svx/inc \
+$$(INCLUDE) \
+))
+
+$(eval $(call gb_CppunitTest_use_libraries,sd_pdf_import_test, \
+$(call gb_Helper_optional,AVMEDIA,avmedia) \
+basegfx \
+canvastools \
+comphelper \
+cppcanvas \
+cppu \
+cppuhelper \
+drawinglayer \
+editeng \
+for \
+forui \
+i18nlangtag \
+i18nutil \
+msfilter \
+oox \
+sal \
+salhelper \
+sax \
+sb \
+sd \
+sfx \
+sot \
+svl \
+svt \
+svx \
+svxcore \
+test \
+tl \
+tk \
+ucbhelper \
+unotest \
+utl \
+vcl \
+xo \
+))
+
+$(eval $(call gb_CppunitTest_use_sdk_api,sd_pdf_import_test))
+$(eval $(call gb_CppunitTest_use_ure,sd_pdf_import_test))
+$(eval $(call gb_CppunitTest_use_vcl,sd_pdf_import_test))
+$(eval $(call gb_CppunitTest_use_rdb,sd_pdf_import_test,services))
+$(eval $(call gb_CppunitTest_use_configuration,sd_pdf_import_test))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index a7edda76cbe4..d5c6b2ecab23 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -39,6 +39,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sd,\
 CppunitTest_sd_uiimpress \
 CppunitTest_sd_html_export_tests \
 CppunitTest_sd_activex_controls_tests \
+CppunitTest_sd_pdf_import_test \
 ))
 endif
 
diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx
new file mode 100644
index ..a22579d67526
--- /dev/null
+++ b/sd/qa/unit/SdrPdfImportTest.cxx
@@ -0,0 +1,129 @@
+/* -*- 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 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+using namespace css;
+
+class SdrPdfImportTest : public test::BootstrapFixture, public 
unotest::MacrosTest
+{
+protected:
+uno::Reference mxComponent;
+
+public:
+virtual void setUp() override;
+virtual void tearDown() override;
+};
+
+void SdrPdfImportTest::setUp()
+{
+test::BootstrapFixture::setUp();
+
+mxDesktop.set(
+
css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory(;
+}
+
+void SdrPdfImportTest::tearDown()
+{
+if (mxComponent.is())
+mxComponent->dispose();
+
+test::BootstrapFixture::tearDown();
+}
+
+// Load the PDF in Draw, which will load the PDF as an Graphic, then
+// mark the graphic object and trigger "break" funcition. This should
+// convert 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - svx/source

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 svx/source/svdraw/svdpdf.cxx |   28 +++-
 1 file changed, 15 insertions(+), 13 deletions(-)

New commits:
commit ae512835805da05cfa873eebf189fa7a2f927a20
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 30 13:18:21 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 13:43:26 2020 +0200

SdrPdfImport: rename some variables to non-abbreviated names

Change-Id: I1cb004a8e426f8ea26bb930d4897db3763433b31
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93329
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 9e3da9e3bc7133972fae76c27f911fc19ca854b1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95781
Tested-by: Tomaž Vajngerl 

diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx
index a41caaeaba14..106718a34aa9 100644
--- a/svx/source/svdraw/svdpdf.cxx
+++ b/svx/source/svdraw/svdpdf.cxx
@@ -99,6 +99,7 @@ namespace
 /// Here we effectively render at 96 DPI (to match
 /// the image rendered in vcl::ImportPDF in pdfread.cxx).
 double lcl_PointToPixel(double fPoint) { return fPoint * 96. / 72.; }
+
 /// Convert from pixels to logic (twips).
 long lcl_ToLogic(double value)
 {
@@ -894,21 +895,22 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const 
Size& rSize, const OUS
 // calc text box size, add 5% to make it fit safely
 
 FontMetric aFontMetric(mpVD->GetFontMetric());
-vcl::Font aFnt(mpVD->GetFont());
-FontAlign eAlg(aFnt.GetAlignment());
+vcl::Font aFont(mpVD->GetFont());
+FontAlign eAlignment(aFont.GetAlignment());
 
 // sal_Int32 nTextWidth = static_cast(mpVD->GetTextWidth(rStr) 
* mfScaleX);
 sal_Int32 nTextHeight = static_cast(mpVD->GetTextHeight() * 
mfScaleY);
 
-Point aPos(FRound(rPos.X() * mfScaleX + maOfs.X()), FRound(rPos.Y() * 
mfScaleY + maOfs.Y()));
+Point aPosition(FRound(rPos.X() * mfScaleX + maOfs.X()),
+FRound(rPos.Y() * mfScaleY + maOfs.Y()));
 Size aSize(FRound(rSize.Width() * mfScaleX), FRound(rSize.Height() * 
mfScaleY));
 
-if (eAlg == ALIGN_BASELINE)
-aPos.AdjustY(-FRound(aFontMetric.GetAscent() * mfScaleY));
-else if (eAlg == ALIGN_BOTTOM)
-aPos.AdjustY(-nTextHeight);
+if (eAlignment == ALIGN_BASELINE)
+aPosition.AdjustY(-FRound(aFontMetric.GetAscent() * mfScaleY));
+else if (eAlignment == ALIGN_BOTTOM)
+aPosition.AdjustY(-nTextHeight);
 
-tools::Rectangle aTextRect(aPos, aSize);
+tools::Rectangle aTextRect(aPosition, aSize);
 SdrRectObj* pText = new SdrRectObj(*mpModel, OBJ_TEXT, aTextRect);
 
 pText->SetMergedItem(makeSdrTextUpperDistItem(0));
@@ -916,7 +918,7 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const 
Size& rSize, const OUS
 pText->SetMergedItem(makeSdrTextRightDistItem(0));
 pText->SetMergedItem(makeSdrTextLeftDistItem(0));
 
-if (aFnt.GetAverageFontWidth())
+if (aFont.GetAverageFontWidth())
 {
 pText->ClearMergedItem(SDRATTR_TEXT_AUTOGROWWIDTH);
 pText->SetMergedItem(makeSdrTextAutoGrowHeightItem(false));
@@ -933,21 +935,21 @@ void ImpSdrPdfImport::ImportText(const Point& rPos, const 
Size& rSize, const OUS
 SetAttributes(pText, true);
 pText->SetSnapRect(aTextRect);
 
-if (!aFnt.IsTransparent())
+if (!aFont.IsTransparent())
 {
 SfxItemSet aAttr(*mpFillAttr->GetPool(), svl::Items{});
 aAttr.Put(XFillStyleItem(drawing::FillStyle_SOLID));
-aAttr.Put(XFillColorItem(OUString(), aFnt.GetFillColor()));
+aAttr.Put(XFillColorItem(OUString(), aFont.GetFillColor()));
 pText->SetMergedItemSet(aAttr);
 }
-sal_uInt32 nAngle = aFnt.GetOrientation();
+sal_uInt32 nAngle = aFont.GetOrientation();
 if (nAngle)
 {
 nAngle *= 10;
 double a = nAngle * F_PI18000;
 double nSin = sin(a);
 double nCos = cos(a);
-pText->NbcRotate(aPos, nAngle, nSin, nCos);
+pText->NbcRotate(aPosition, nAngle, nSin, nCos);
 }
 InsertObj(pText, false);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 150 commits - basctl/source binaryurp/source bin/check-implementer-notes.py compilerplugins/clang connectivity/source cppcanvas/sour

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit bef12f35d01929680d96c8a672fa9d4b09f2ef53
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 17:00:47 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Mon Jun 8 12:03:20 2020 +0200

drawinglayer: remove textprimitive2d.hxx from clang-format blacklist

Change-Id: I6fa692bb3e4a16400ee2ae847a1f97201493f53a

diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx 
b/include/drawinglayer/primitive2d/textprimitive2d.hxx
index 9aeaa96fc15e..6bbc14aa498a 100644
--- a/include/drawinglayer/primitive2d/textprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx
@@ -33,152 +33,151 @@
 
 namespace drawinglayer::primitive2d
 {
-/** TextSimplePortionPrimitive2D class
+/** TextSimplePortionPrimitive2D class
 
-This is the basic primitive for representing a text portion. It 
contains
-all needed information. If it is not handled by a renderer, its 
decomposition
-will provide the text tools::PolyPolygon outlines as filled 
polygons, correctly
-transformed.
+This is the basic primitive for representing a text portion. It contains
+all needed information. If it is not handled by a renderer, its 
decomposition
+will provide the text tools::PolyPolygon outlines as filled polygons, 
correctly
+transformed.
 
-To get better text quality, it is suggested to handle this 
primitive directly
-in a renderer. In that case, e.g. hintings on the system can be 
supported.
+To get better text quality, it is suggested to handle this primitive 
directly
+in a renderer. In that case, e.g. hintings on the system can be supported.
 
-@param maTextTransform
-The text transformation contains the text start position (always 
baselined)
-as translation, the FontSize as scale (where width relative to 
height defines
-font scaling and width == height means no font scaling) and the 
font rotation
-and shear.
-When shear is used and a renderer does not support it, it may be 
better to use
-the decomposition which will do everything correctly. Same is true 
for mirroring
-which would be expressed as negative scalings.
+@param maTextTransform
+The text transformation contains the text start position (always baselined)
+as translation, the FontSize as scale (where width relative to height 
defines
+font scaling and width == height means no font scaling) and the font 
rotation
+and shear.
+When shear is used and a renderer does not support it, it may be better to 
use
+the decomposition which will do everything correctly. Same is true for 
mirroring
+which would be expressed as negative scalings.
 
-@param rText
-The text to be used. Only a part may be used, but a bigger part of 
the string
-may be necessary for correct layouting (e.g. international)
-
-@param aTextPosition
-The index to the first character to use from rText
-
-@param aTextLength
-The number of characters to use from rText
-
-@param rDXArray
-The distances between the characters. This parameter may be empty, 
in that case
-the renderer is responsible to do something useful. If it is 
given, it has to be of
-the size aTextLength. Its values are in logical coordinates and 
describe the
-distance for each character to use. This is independent from the 
font width which
-is given with maTextTransform. The first value is the offset to 
use from the start
-point in FontCoordinateSystem X-Direction (given by 
maTextTransform) to the start
-point of the second character
-
-@param rFontAttribute
-The font definition
-
-@param rLocale
-The locale to use
-
-@param rFontColor
-The font color to use
-
-@param bFilled
-
-@param nWidthToFill
-
-@param rTextFillColor
-Text background color (has nothing to do with bFilled and 
nWidthToFill)
-
- */
-class DRAWINGLAYER_DLLPUBLIC TextSimplePortionPrimitive2D : public 
BufferedDecompositionPrimitive2D
-{
-private:
-/// text transformation (FontCoordinateSystem)
-basegfx::B2DHomMatrix   maTextTransform;
-
-/// The text, used from maTextPosition up to maTextPosition + 
maTextLength
-OUStringmaText;
-
-/// The index from where on maText is used
-sal_Int32   mnTextPosition;
-
-/// The length for maText usage, starting from maTextPosition
-sal_Int32   mnTextLength;
-
-/// The DX array in logic units
-

[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-4' - loleaflet/src

2020-06-08 Thread Tomaž Vajngerl (via logerrit)
 loleaflet/src/control/Ruler.js |   91 -
 1 file changed, 72 insertions(+), 19 deletions(-)

New commits:
commit 01a074d66e4d9786e5cf0b1cc07b9189a23726ce
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 1 23:15:11 2020 +0200
Commit: Andras Timar 
CommitDate: Mon Jun 8 20:47:02 2020 +0200

Add "delete tabstop" function to Ruler

Change-Id: I34d381f6d3e12b0444b9c7778ef6b8c87794cbd6
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95341
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95750
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 

diff --git a/loleaflet/src/control/Ruler.js b/loleaflet/src/control/Ruler.js
index a5537055e..f5c3dda4d 100644
--- a/loleaflet/src/control/Ruler.js
+++ b/loleaflet/src/control/Ruler.js
@@ -606,9 +606,30 @@ L.Control.Ruler = L.Control.extend({
this._map._socket.sendMessage('uno .uno:RulerChangeState ' + 
JSON.stringify(unoObj));
},
 
+   _getTabStopHit: function(tabstopContainer, pointX) {
+   var tabstop = null;
+   var margin = 10;
+   var tabstopDiffFromCenter = 1; // just a big initial 
condition
+
+   for (var i = 0; i < tabstopContainer.tabStops.length; i++) {
+   var current = tabstopContainer.tabStops[i];
+   var location = current.tabStopLocation;
+   if (pointX >= location.left - margin && pointX <= 
location.right + margin) {
+   var diff = Math.abs(pointX - location.center);
+   if (diff < tabstopDiffFromCenter) {
+   tabstop = current;
+   tabstopDiffFromCenter = diff;
+   }
+   }
+   }
+   return tabstop;
+   },
_initiateTabstopDrag: function(event) {
// console.log('===> _initiateTabstopDrag ' + event.type);
 
+   this.currentPositionInTwips = null;
+   this.currentTabStopIndex = null;
+
var tabstopContainer = null;
var pointX = null;
 
@@ -622,18 +643,37 @@ L.Control.Ruler = L.Control.extend({
}
tabstopContainer.tabStopMarkerBeingDragged = null;
 
+   // check if we hit any tabstop
+   var tabstop = this._getTabStopHit(tabstopContainer, pointX);
+
// Check what to do when a mouse buttons is clicked, ignore 
touch
if (event.type !== 'panstart') {
// right-click inside tabstop container
if (event.button === 2) {
-   this.currentPositionInTwips = 
this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
+   if (tabstop == null) {
+   this.currentPositionInTwips = 
this._map._docLayer._pixelsToTwips({x: pointX, y:0}).x;
+   }
+   else {
+   this.currentTabStopIndex = 
tabstop.tabStopNumber;
+   }
+   var self = this;
$.contextMenu({
selector: 
'.loleaflet-ruler-tabstopcontainer',
className: 'loleaflet-font',
items: {
inserttabstop: {
name: _('Insert 
tabstop'),
-   callback: 
(this._insertTabstop).bind(this)
+   callback: 
(this._insertTabstop).bind(this),
+   visible: function() {
+   return 
self.currentPositionInTwips != null;
+   }
+   },
+   removetabstop: {
+   name: _('Delete 
tabstop'),
+   callback: 
(this._deleteTabstop).bind(this),
+   visible: function() {
+   return 
self.currentTabStopIndex != null;
+   }
}
}
});
@@ -646,23 +686,6 @@ L.Control.Ruler = L.Control.extend({
}
}
 
-   

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/qa sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   86 ++
 sd/qa/unit/tiledrendering/data/MixedTest1.odg |binary
 sd/source/ui/view/Outliner.cxx|2 
 3 files changed, 87 insertions(+), 1 deletion(-)

New commits:
commit f5c158d2cdc45df318d56fbc9108f0acb133bb92
Author: Tomaž Vajngerl 
AuthorDate: Sat May 30 15:47:35 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 21:01:09 2020 +0200

sd: fix issue when PDF search doesn't send a search result + test

This fixes the issue when PDF search doesn't send the search
result, because of premature exit.

Also add test which reproduces this issue and tests the behavior
of searching in multiple objects.

Change-Id: I3a676eeac36bde88c67e90a49583444b8595a346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95454
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 18f8340a697be7c076fe111d0bc42faf877b9202)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95940
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8d8b11e43fa1..24037a0780ba 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,6 +55,7 @@ public:
 void testDontSearchInMasterPages();
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
+void testSearchInMixedObject();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -65,6 +66,7 @@ public:
 CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
+CPPUNIT_TEST(testSearchInMixedObject);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -317,6 +319,90 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSelection[0]);
 }
 
+void LOKitSearchTest::testSearchInMixedObject()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+CPPUNIT_ASSERT(pDocument);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+// Check we have one page
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), 
pDocument->GetSdPageCount(PageKind::Standard));
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+// Check page hase 2 objects only
+CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
+
+// Check Object 1
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 2
+{
+SdrObject* pObject = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObject);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), 
pObject->GetObjIdentifier());
+
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Let's try to search now
+
+lcl_search("ABC");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search next
+
+lcl_search("ABC");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(OString("8412, 6385, 519, 174"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search next again - we should get the first object again
+
+lcl_search("ABC");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/qa

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 5ed594f2a9642becb3f490b1aeb07231da956522
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 10:05:17 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 21:33:29 2020 +0200

sd: rename testSearchInMixedObject(2) to more descriptive name

testSearchInMixedObject -> testSearchIn2MixedObjects
testSearchInMixedObject2 -> testSearchIn6MixedObjects

Change-Id: Ifba20df38fd33bb86b072ba79085d123c914f916
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95457
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit f36fec9bd296e2aa0a5463f849808bb85e746d2e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95943
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 7786bc1f1dae..ec9f7d95c5da 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,8 +55,8 @@ public:
 void testDontSearchInMasterPages();
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
-void testSearchInMixedObject();
-void testSearchInMixedObject2();
+void testSearchIn2MixedObjects();
+void testSearchIn6MixedObjects();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -67,8 +67,8 @@ public:
 CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
-CPPUNIT_TEST(testSearchInMixedObject);
-CPPUNIT_TEST(testSearchInMixedObject2);
+CPPUNIT_TEST(testSearchIn2MixedObjects);
+CPPUNIT_TEST(testSearchIn6MixedObjects);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -332,7 +332,7 @@ void LOKitSearchTest::testSearchInPDF()
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
-void LOKitSearchTest::testSearchInMixedObject()
+void LOKitSearchTest::testSearchIn2MixedObjects()
 {
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
@@ -417,7 +417,7 @@ void LOKitSearchTest::testSearchInMixedObject()
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
-void LOKitSearchTest::testSearchInMixedObject2()
+void LOKitSearchTest::testSearchIn6MixedObjects()
 {
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/qa

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |  179 +-
 sd/qa/unit/tiledrendering/data/MixedTest2.odg |binary
 2 files changed, 178 insertions(+), 1 deletion(-)

New commits:
commit 9b51e9929b593175024085cc7bdf0482b4a56d0c
Author: Tomaž Vajngerl 
AuthorDate: Sat May 30 19:30:44 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 21:01:50 2020 +0200

sd: Add another test of searching with mixed objects

This is to make sure that we switch between different objects
during the search correctly.

Change-Id: I18aa5b251cbaadd3a9cb15a04ec1a1e5f267d2e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95455
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit ceaa07e1a1aafd9a11b8baea242605f32c56e584)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95941
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 24037a0780ba..7786bc1f1dae 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -56,6 +56,7 @@ public:
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
 void testSearchInMixedObject();
+void testSearchInMixedObject2();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -67,6 +68,7 @@ public:
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
 CPPUNIT_TEST(testSearchInMixedObject);
+CPPUNIT_TEST(testSearchInMixedObject2);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -134,6 +136,15 @@ void lcl_search(const OUString& rKey, bool bFindAll = 
false)
 Scheduler::ProcessEventsToIdle();
 }
 
+SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
+{
+SdrView* pSdrView = pViewShell->GetView();
+const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+CPPUNIT_ASSERT_EQUAL(size_t(1), rMarkList.GetMarkCount());
+SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
+return pObject;
+}
+
 } // end anonymous namespace
 
 void LOKitSearchTest::testSearch()
@@ -319,6 +330,8 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSelection[0]);
 }
 
+// Test searching in document with mixed objects.
+// We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchInMixedObject()
 {
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
@@ -334,7 +347,7 @@ void LOKitSearchTest::testSearchInMixedObject()
 SdPage* pPage = pViewShell->GetActualPage();
 CPPUNIT_ASSERT(pPage);
 
-// Check page hase 2 objects only
+// Check page has 2 objects only
 CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
 
 // Check Object 1
@@ -403,6 +416,170 @@ void LOKitSearchTest::testSearchInMixedObject()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 }
 
+// Test searching in document with mixed objects. We have 6 objects.
+void LOKitSearchTest::testSearchInMixedObject2()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+CPPUNIT_ASSERT(pDocument);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+// Check we have one page
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), 
pDocument->GetSdPageCount(PageKind::Standard));
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+// Check page has 6 objects only
+CPPUNIT_ASSERT_EQUAL(size_t(6), pPage->GetObjCount());
+
+// Check we have the right objects that we expect
+
+// Check Object 1
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 2
+{
+SdrObject* pObject = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), 
pObject->GetObjIdentifier());
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+auto const& pVectorGraphicData = 
pGraphicObject->GetGraphic().getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Check Object 3
+{
+SdrObject* pObject = pPage->GetObj(2);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_CUSTOMSHAPE), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 4
+{
+SdrObject* pObject = pPage->GetObj(3);
+CPPUNIT_ASSERT(pObject);
+

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

2020-06-09 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   45 -
 1 file changed, 23 insertions(+), 22 deletions(-)

New commits:
commit f0ef50cbfe6039dc9dd00f89af8596f309223cb7
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 09:58:26 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Jun 9 21:02:08 2020 +0200

sd: PDF search - reset mpVectorGraphicSearch at more places

and simplify the case when the search doesn't find a match in
the vector graphic.

Change-Id: I3e086e8e36f8a578711eed6d4dcca65c0c4c6268
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95456
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit f60caab2c867a578b6e6b963ebd5a72b5a12463e)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95942
Tested-by: Jenkins CollaboraOffice 

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 585eee9475e8..916d5d1d2dfb 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1170,6 +1170,7 @@ void SdOutliner::ProvideNextTextObject()
 mbFoundObject = false;
 
 // reset the vector search
+mpImpl->mbCurrentIsVectorGraphic = false;
 mpImpl->mpVectorGraphicSearch.reset();
 
 mpView->UnmarkAllObj (mpView->GetSdrPageView());
@@ -1205,6 +1206,7 @@ void SdOutliner::ProvideNextTextObject()
 bool bForbiddenPage = comphelper::LibreOfficeKit::isActive() && 
(maCurrentPosition.mePageKind != PageKind::Standard || 
maCurrentPosition.meEditMode != EditMode::Page);
 
 mpImpl->mbCurrentIsVectorGraphic = false;
+mpImpl->mpVectorGraphicSearch.reset();
 
 if (!bForbiddenPage)
 {
@@ -1238,34 +1240,30 @@ void SdOutliner::ProvideNextTextObject()
 OUString const & rString = mpSearchItem->GetSearchString();
 
 mpImpl->mpVectorGraphicSearch = 
std::make_unique(pGraphicObject->GetGraphic());
-if (mpImpl->mpVectorGraphicSearch->search(rString))
+
+bool bResult = 
mpImpl->mpVectorGraphicSearch->search(rString);
+if (bResult)
+bResult = mpImpl->mpVectorGraphicSearch->next();
+
+if (bResult)
 {
-bool bResult = mpImpl->mpVectorGraphicSearch->next();
-if (bResult)
-{
-mpObj = SetObject(maCurrentPosition);
+mpObj = SetObject(maCurrentPosition);
 
-mbStringFound = true;
-mbMatchMayExist = true;
-mbFoundObject = true;
+mbStringFound = true;
+mbMatchMayExist = true;
+mbFoundObject = true;
 
-SdrPageView* pPageView = mpView->GetSdrPageView();
-mpView->UnmarkAllObj(pPageView);
+SdrPageView* pPageView = mpView->GetSdrPageView();
+mpView->UnmarkAllObj(pPageView);
 
-std::vector aSubSelections;
-basegfx::B2DRectangle aSubSelection = 
getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
-if (!aSubSelection.isEmpty())
-aSubSelections.push_back(aSubSelection);
+std::vector aSubSelections;
+basegfx::B2DRectangle aSubSelection = 
getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+if (!aSubSelection.isEmpty())
+aSubSelections.push_back(aSubSelection);
 
-mpView->MarkObj(mpObj, pPageView, false, false, 
aSubSelections);
+mpView->MarkObj(mpObj, pPageView, false, false, 
aSubSelections);
 
-mpDrawDocument->GetDocSh()->SetWaitCursor( false );
-}
-else
-{
-mpImpl->mbCurrentIsVectorGraphic = false;
-mpImpl->mpVectorGraphicSearch.reset();
-}
+mpDrawDocument->GetDocSh()->SetWaitCursor( false );
 }
 else
 {
@@ -1298,6 +1296,9 @@ void SdOutliner::ProvideNextTextObject()
 }
 else
 {
+mpImpl->mbCurrentIsVectorGraphic = false;
+mpImpl->mpVectorGraphicSearch.reset();
+
 if (meMode == SEARCH)
 // Instead of doing a full-blown SetObject(), which would do 
the same -- but would also possibly switch pages.
 mbStringFound = false;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 4 commits - include/drawinglayer solenv/clang-format

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/drawinglayer/attribute/fontattribute.hxx |  115 +++
 include/drawinglayer/primitive2d/textprimitive2d.hxx |  282 +--
 solenv/clang-format/blacklist|2 
 3 files changed, 187 insertions(+), 212 deletions(-)

New commits:
commit 15de5b73a3c8e4064c200af78d8a480d5f2b72f5
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 17:00:47 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 17:07:33 2020 +0200

drawinglayer: remove textprimitive2d.hxx from clang-format blacklist

Change-Id: I6fa692bb3e4a16400ee2ae847a1f97201493f53a

diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx 
b/include/drawinglayer/primitive2d/textprimitive2d.hxx
index 9aeaa96fc15e..6bbc14aa498a 100644
--- a/include/drawinglayer/primitive2d/textprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx
@@ -33,152 +33,151 @@
 
 namespace drawinglayer::primitive2d
 {
-/** TextSimplePortionPrimitive2D class
+/** TextSimplePortionPrimitive2D class
 
-This is the basic primitive for representing a text portion. It 
contains
-all needed information. If it is not handled by a renderer, its 
decomposition
-will provide the text tools::PolyPolygon outlines as filled 
polygons, correctly
-transformed.
+This is the basic primitive for representing a text portion. It contains
+all needed information. If it is not handled by a renderer, its 
decomposition
+will provide the text tools::PolyPolygon outlines as filled polygons, 
correctly
+transformed.
 
-To get better text quality, it is suggested to handle this 
primitive directly
-in a renderer. In that case, e.g. hintings on the system can be 
supported.
+To get better text quality, it is suggested to handle this primitive 
directly
+in a renderer. In that case, e.g. hintings on the system can be supported.
 
-@param maTextTransform
-The text transformation contains the text start position (always 
baselined)
-as translation, the FontSize as scale (where width relative to 
height defines
-font scaling and width == height means no font scaling) and the 
font rotation
-and shear.
-When shear is used and a renderer does not support it, it may be 
better to use
-the decomposition which will do everything correctly. Same is true 
for mirroring
-which would be expressed as negative scalings.
+@param maTextTransform
+The text transformation contains the text start position (always baselined)
+as translation, the FontSize as scale (where width relative to height 
defines
+font scaling and width == height means no font scaling) and the font 
rotation
+and shear.
+When shear is used and a renderer does not support it, it may be better to 
use
+the decomposition which will do everything correctly. Same is true for 
mirroring
+which would be expressed as negative scalings.
 
-@param rText
-The text to be used. Only a part may be used, but a bigger part of 
the string
-may be necessary for correct layouting (e.g. international)
-
-@param aTextPosition
-The index to the first character to use from rText
-
-@param aTextLength
-The number of characters to use from rText
-
-@param rDXArray
-The distances between the characters. This parameter may be empty, 
in that case
-the renderer is responsible to do something useful. If it is 
given, it has to be of
-the size aTextLength. Its values are in logical coordinates and 
describe the
-distance for each character to use. This is independent from the 
font width which
-is given with maTextTransform. The first value is the offset to 
use from the start
-point in FontCoordinateSystem X-Direction (given by 
maTextTransform) to the start
-point of the second character
-
-@param rFontAttribute
-The font definition
-
-@param rLocale
-The locale to use
-
-@param rFontColor
-The font color to use
-
-@param bFilled
-
-@param nWidthToFill
-
-@param rTextFillColor
-Text background color (has nothing to do with bFilled and 
nWidthToFill)
-
- */
-class DRAWINGLAYER_DLLPUBLIC TextSimplePortionPrimitive2D : public 
BufferedDecompositionPrimitive2D
-{
-private:
-/// text transformation (FontCoordinateSystem)
-basegfx::B2DHomMatrix   maTextTransform;
-
-/// The text, used from maTextPosition up to maTextPosition + 
maTextLength
-OUStringmaText;
-
-/// The index from where on maText is used
-sal_Int32   

[Libreoffice-commits] core.git: include/vcl vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|3 -
 vcl/source/graphic/VectorGraphicSearch.cxx |   76 +++--
 2 files changed, 40 insertions(+), 39 deletions(-)

New commits:
commit 978198a055972aff00f47b70ca79e6322a5fbac3
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 12:02:39 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 20:10:29 2020 +0200

vcl: VectorGraphicSearch - move SearchContext into Implementation

Change-Id: I3bbf085fd8b8b66a56e364168c1e70b4ce986467
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95392
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/vcl/VectorGraphicSearch.hxx 
b/include/vcl/VectorGraphicSearch.hxx
index b67c63a844d8..2dc8cca3b76a 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -19,8 +19,6 @@
 
 #include 
 
-class SearchContext;
-
 enum class SearchStartPosition
 {
 Begin,
@@ -33,7 +31,6 @@ private:
 class Implementation;
 std::unique_ptr mpImplementation;
 Graphic maGraphic;
-std::unique_ptr mpSearchContext;
 
 bool searchPDF(std::shared_ptr const& rData, OUString 
const& rSearchString,
SearchStartPosition eStartPosition);
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index e8f7484320e3..be35c736e489 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -17,25 +17,8 @@
 #include 
 #include 
 
-class VectorGraphicSearch::Implementation
+namespace
 {
-public:
-std::shared_ptr mpPDFium;
-FPDF_DOCUMENT mpPdfDocument;
-
-Implementation()
-: mpPDFium(vcl::pdf::PDFiumLibrary::get())
-, mpPdfDocument(nullptr)
-{
-}
-
-~Implementation()
-{
-if (mpPdfDocument)
-FPDF_CloseDocument(mpPdfDocument);
-}
-};
-
 class SearchContext
 {
 private:
@@ -180,17 +163,38 @@ public:
 }
 };
 
+} // end anonymous namespace
+
+class VectorGraphicSearch::Implementation
+{
+public:
+std::shared_ptr mpPDFium;
+FPDF_DOCUMENT mpPdfDocument;
+
+std::unique_ptr mpSearchContext;
+
+Implementation()
+: mpPDFium(vcl::pdf::PDFiumLibrary::get())
+, mpPdfDocument(nullptr)
+{
+}
+
+~Implementation()
+{
+mpSearchContext.reset();
+
+if (mpPdfDocument)
+FPDF_CloseDocument(mpPdfDocument);
+}
+};
+
 VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
 : mpImplementation(std::make_unique())
 , maGraphic(rGraphic)
 {
 }
 
-VectorGraphicSearch::~VectorGraphicSearch()
-{
-mpSearchContext.reset();
-mpImplementation.reset();
-}
+VectorGraphicSearch::~VectorGraphicSearch() { mpImplementation.reset(); }
 
 bool VectorGraphicSearch::search(OUString const& rSearchString, 
SearchStartPosition eStartPosition)
 {
@@ -241,45 +245,45 @@ bool 
VectorGraphicSearch::searchPDF(std::shared_ptr const& rD
 
 sal_Int32 nPageIndex = std::max(rData->getPageIndex(), sal_Int32(0));
 
-mpSearchContext.reset(new SearchContext(mpImplementation->mpPdfDocument, 
nPageIndex,
-rSearchString, eStartPosition));
+mpImplementation->mpSearchContext.reset(new SearchContext(
+mpImplementation->mpPdfDocument, nPageIndex, rSearchString, 
eStartPosition));
 
-return mpSearchContext->initialize();
+return mpImplementation->mpSearchContext->initialize();
 }
 
 basegfx::B2DSize VectorGraphicSearch::pageSize()
 {
 basegfx::B2DSize aSize;
-if (mpSearchContext)
-aSize = mpSearchContext->getPageSize();
+if (mpImplementation->mpSearchContext)
+aSize = mpImplementation->mpSearchContext->getPageSize();
 return aSize;
 }
 
 bool VectorGraphicSearch::next()
 {
-if (mpSearchContext)
-return mpSearchContext->next();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->next();
 return false;
 }
 
 bool VectorGraphicSearch::previous()
 {
-if (mpSearchContext)
-return mpSearchContext->previous();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->previous();
 return false;
 }
 
 int VectorGraphicSearch::index()
 {
-if (mpSearchContext)
-return mpSearchContext->index();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->index();
 return -1;
 }
 
 std::vector VectorGraphicSearch::getTextRectangles()
 {
-if (mpSearchContext)
-return mpSearchContext->getTextRectangles();
+if (mpImplementation->mpSearchContext)
+return mpImplementation->mpSearchContext->getTextRectangles();
 
 return std::vector();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/svx svx/sdi sw/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/svx/svxids.hrc  |1 +
 svx/sdi/svx.sdi |4 ++--
 sw/source/uibase/uiview/viewtab.cxx |   16 +++-
 3 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 9d7b3fd5eb5c1ad9b1f622239a916bb1114896d7
Author: Tomaž Vajngerl 
AuthorDate: Mon Jun 1 16:03:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 14:38:49 2020 +0200

lok: add "Remove" param to .uno:ChangeTabStop

update for cp-6.2

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95330
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 
(cherry picked from commit 8d0b7e5b2f6773f4b3feb75f1ac73ea1a26609f7)

Change-Id: Ic6b71c0bb6177eb10f5be4197d77c5db5f5884a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95342
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tomaž Vajngerl 

diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc
index 7d9d69e08dfe..eba3066ecf74 100644
--- a/include/svx/svxids.hrc
+++ b/include/svx/svxids.hrc
@@ -532,6 +532,7 @@ class SfxStringItem;
 #define SID_TABSTOP_ADD_OR_CHANGE   ( SID_SVX_START + 581 )
 #define SID_TABSTOP_ATTR_INDEX  ( SID_SVX_START + 582 )
 #define SID_TABSTOP_ATTR_POSITION   ( SID_SVX_START + 583 )
+#define SID_TABSTOP_ATTR_REMOVE ( SID_SVX_START + 584 )
 
 // CAUTION! Range <587 .. 587> used by EditEngine (!)
 
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 7c4a5e8cadc0..cf48781fc77e 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -7177,7 +7177,8 @@ SfxVoidItem RulerChangeState SID_RULER_CHANGE_STATE
 
 SfxVoidItem ChangeTabStop SID_TABSTOP_ADD_OR_CHANGE
 (SfxInt32Item Index SID_TABSTOP_ATTR_INDEX,
- SfxInt32Item Position SID_TABSTOP_ATTR_POSITION)
+ SfxInt32Item Position SID_TABSTOP_ATTR_POSITION,
+ SfxBoolItem  Remove SID_TABSTOP_ATTR_REMOVE)
 [
 AutoUpdate = FALSE,
 FastCall = TRUE,
@@ -7187,7 +7188,6 @@ SfxVoidItem ChangeTabStop SID_TABSTOP_ADD_OR_CHANGE
 RecordAbsolute = FALSE,
 RecordPerSet;
 
-
 AccelConfig = FALSE,
 MenuConfig = FALSE,
 ToolBoxConfig = FALSE,
diff --git a/sw/source/uibase/uiview/viewtab.cxx 
b/sw/source/uibase/uiview/viewtab.cxx
index 7b51c2331408..6a70fb9e6397 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -658,8 +658,12 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
 {
 const auto aIndexItem = static_cast(pReqArgs->Get(SID_TABSTOP_ATTR_INDEX));
 const auto aPositionItem = static_cast(pReqArgs->Get(SID_TABSTOP_ATTR_POSITION));
+const auto aRemoveItem = static_cast(pReqArgs->Get(SID_TABSTOP_ATTR_REMOVE));
 const sal_Int32 nIndex = aIndexItem.GetValue();
 const sal_Int32 nPosition = aPositionItem.GetValue();
+const bool bRemove = aRemoveItem.GetValue();
+
+
 
 SfxItemSet aItemSet(GetPool(), svl::Items{});
 rSh.GetCurAttr(aItemSet);
@@ -683,12 +687,14 @@ void SwView::ExecTabWin( SfxRequest const & rReq )
 {
 SvxTabStop aTabStop = aTabStopItem.At(nIndex);
 aTabStopItem.Remove(nIndex);
-aTabStop.GetTabPos() = nPosition;
-aTabStopItem.Insert(aTabStop);
-
-SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
-aTabStopItem.Insert(aSwTabStop);
+if (!bRemove)
+{
+aTabStop.GetTabPos() = nPosition;
+aTabStopItem.Insert(aTabStop);
 
+SvxTabStop aSwTabStop(0, SvxTabAdjust::Default);
+aTabStopItem.Insert(aSwTabStop);
+}
 const SvxTabStopItem& rDefaultTabs = 
rSh.GetDefault(RES_PARATR_TABSTOP);
 MakeDefTabs(GetTabDist(rDefaultTabs), aTabStopItem);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: 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 112d8113388513d9c6b317e828f5d373b4a54330
Author: Tomaž Vajngerl 
AuthorDate: Thu Jun 4 18:26:58 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 22:48: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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95530
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

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();
 
   

[Libreoffice-commits] core.git: vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/graphic/VectorGraphicSearch.cxx |   45 +
 1 file changed, 45 insertions(+)

New commits:
commit 67f7a26c047ae2878e3ecd76f83af3941b9079c3
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 12:13:59 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 22:24:03 2020 +0200

vcl: use HAVE_FEATURE_PDFIUM in VectorGraphicSearch impl.

Change-Id: Id6c30e8f1c5bdb0481b0c7d4680554e3e8caa323
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95393
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx 
b/vcl/source/graphic/VectorGraphicSearch.cxx
index be35c736e489..635ed240307a 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -10,6 +10,10 @@
 
 #include 
 
+#include 
+
+#if HAVE_FEATURE_PDFIUM
+
 #include 
 
 #include 
@@ -288,4 +292,45 @@ std::vector 
VectorGraphicSearch::getTextRectangles()
 return std::vector();
 }
 
+#else // !HAVE_FEATURE_PDFIUM
+
+class VectorGraphicSearch::Implementation
+{
+};
+
+VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic)
+: maGraphic(rGraphic)
+{
+}
+
+VectorGraphicSearch::~VectorGraphicSearch() {}
+
+bool VectorGraphicSearch::search(OUString const& /*rSearchString*/,
+ SearchStartPosition /*eStartPosition*/)
+{
+return false;
+}
+
+bool VectorGraphicSearch::searchPDF(std::shared_ptr const& 
/*rData*/,
+OUString const& /*rSearchString*/,
+SearchStartPosition /*eStartPosition*/)
+{
+return false;
+}
+
+basegfx::B2DSize VectorGraphicSearch::pageSize() { return basegfx::B2DSize(); }
+
+bool VectorGraphicSearch::next() { return false; }
+
+bool VectorGraphicSearch::previous() { return false; }
+
+int VectorGraphicSearch::index() { return -1; }
+
+std::vector VectorGraphicSearch::getTextRectangles()
+{
+return std::vector();
+}
+
+#endif // HAVE_FEATURE_PDFIUM
+
 /* 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: include/vcl vcl/qa vcl/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 include/vcl/VectorGraphicSearch.hxx|3 -
 vcl/qa/cppunit/VectorGraphicSearchTest.cxx |   33 
 vcl/source/graphic/VectorGraphicSearch.cxx |   79 +++--
 3 files changed, 86 insertions(+), 29 deletions(-)

New commits:
commit 1f8a46ae50c6977add4c4116f114df3a58796be3
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 14:03:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:44:04 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
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95460
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

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 635ed240307a..95064407f553 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -33,18 +33,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)
 {
 }
 
@@ -73,13 +73,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);
+
+

[Libreoffice-commits] core.git: sd/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/source/ui/view/Outliner.cxx |   16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 191288d6a7fb52b31038a21c4e71ee57ffa3bacd
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 21:59:34 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:44:19 2020 +0200

sd: allow to change the search string between searches

Before this was missing, so even with a different search string,
it still searched using the old string, which was a bug.

Change-Id: I1655cb421e216e30ae593aabd3ead3a2d5c06299
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95461
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 3843cd692872..f8cec9464896 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -826,13 +826,19 @@ bool 
SdOutliner::SearchAndReplaceOnce(std::vector* pSelecti
 
 if (mpImpl->mbCurrentIsVectorGraphic)
 {
+OUString const & rString = mpSearchItem->GetSearchString();
 bool bBackwards = mpSearchItem->GetBackward();
 
-bool bResult = false;
-if (bBackwards)
-bResult = mpImpl->mpVectorGraphicSearch->previous();
-else
-bResult = mpImpl->mpVectorGraphicSearch->next();
+SearchStartPosition eSearchStartPosition = bBackwards ? 
SearchStartPosition::End : SearchStartPosition::Begin;
+bool bResult = mpImpl->mpVectorGraphicSearch->search(rString, 
eSearchStartPosition);
+
+if (bResult)
+{
+if (bBackwards)
+bResult = mpImpl->mpVectorGraphicSearch->previous();
+else
+bResult = mpImpl->mpVectorGraphicSearch->next();
+}
 
 if (bResult)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: sd/qa

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   92 ++
 1 file changed, 92 insertions(+)

New commits:
commit 110b17500acdee1ac1bb97bf53eb422beb67d116
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 12:17:05 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:43:09 2020 +0200

sd: add test to search inside PDF in multiple pages

Change-Id: I246508a22a4e324bae1bb10c6e292790c04da4c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95458
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index ec9f7d95c5da..2c1e1c0426a3 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,6 +55,7 @@ public:
 void testDontSearchInMasterPages();
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
+void testSearchInPDFInMultiplePages();
 void testSearchIn2MixedObjects();
 void testSearchIn6MixedObjects();
 
@@ -67,6 +68,7 @@ public:
 CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
+CPPUNIT_TEST(testSearchInPDFInMultiplePages);
 CPPUNIT_TEST(testSearchIn2MixedObjects);
 CPPUNIT_TEST(testSearchIn6MixedObjects);
 CPPUNIT_TEST_SUITE_END();
@@ -330,6 +332,96 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSelection[0]);
 }
 
+void LOKitSearchTest::testSearchInPDFInMultiplePages()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Search for "him"
+lcl_search("him");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("9463, 1308, 1099, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(4, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("5592, 2964, 1100, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him" - back to start
+lcl_search("him");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(5, mpCallbackRecorder->m_nSearchResultCount);
+
+

[Libreoffice-commits] core.git: 2 commits - sd/qa sd/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   12 +++---
 sd/source/ui/view/Outliner.cxx|   45 +-
 2 files changed, 29 insertions(+), 28 deletions(-)

New commits:
commit f36fec9bd296e2aa0a5463f849808bb85e746d2e
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 10:05:17 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:42:55 2020 +0200

sd: rename testSearchInMixedObject(2) to more descriptive name

testSearchInMixedObject -> testSearchIn2MixedObjects
testSearchInMixedObject2 -> testSearchIn6MixedObjects

Change-Id: Ifba20df38fd33bb86b072ba79085d123c914f916
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95457
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 7786bc1f1dae..ec9f7d95c5da 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,8 +55,8 @@ public:
 void testDontSearchInMasterPages();
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
-void testSearchInMixedObject();
-void testSearchInMixedObject2();
+void testSearchIn2MixedObjects();
+void testSearchIn6MixedObjects();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -67,8 +67,8 @@ public:
 CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
-CPPUNIT_TEST(testSearchInMixedObject);
-CPPUNIT_TEST(testSearchInMixedObject2);
+CPPUNIT_TEST(testSearchIn2MixedObjects);
+CPPUNIT_TEST(testSearchIn6MixedObjects);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -332,7 +332,7 @@ void LOKitSearchTest::testSearchInPDF()
 
 // Test searching in document with mixed objects.
 // We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
-void LOKitSearchTest::testSearchInMixedObject()
+void LOKitSearchTest::testSearchIn2MixedObjects()
 {
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
@@ -417,7 +417,7 @@ void LOKitSearchTest::testSearchInMixedObject()
 }
 
 // Test searching in document with mixed objects. We have 6 objects.
-void LOKitSearchTest::testSearchInMixedObject2()
+void LOKitSearchTest::testSearchIn6MixedObjects()
 {
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
 sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
commit f60caab2c867a578b6e6b963ebd5a72b5a12463e
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 09:58:26 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:42:39 2020 +0200

sd: PDF search - reset mpVectorGraphicSearch at more places

and simplify the case when the search doesn't find a match in
the vector graphic.

Change-Id: I3e086e8e36f8a578711eed6d4dcca65c0c4c6268
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95456
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 52326f0dfbf8..44ecd9182e6b 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -1159,6 +1159,7 @@ void SdOutliner::ProvideNextTextObject()
 mbFoundObject = false;
 
 // reset the vector search
+mpImpl->mbCurrentIsVectorGraphic = false;
 mpImpl->mpVectorGraphicSearch.reset();
 
 mpView->UnmarkAllObj (mpView->GetSdrPageView());
@@ -1194,6 +1195,7 @@ void SdOutliner::ProvideNextTextObject()
 bool bForbiddenPage = comphelper::LibreOfficeKit::isActive() && 
(maCurrentPosition.mePageKind != PageKind::Standard || 
maCurrentPosition.meEditMode != EditMode::Page);
 
 mpImpl->mbCurrentIsVectorGraphic = false;
+mpImpl->mpVectorGraphicSearch.reset();
 
 if (!bForbiddenPage)
 {
@@ -1227,34 +1229,30 @@ void SdOutliner::ProvideNextTextObject()
 OUString const & rString = mpSearchItem->GetSearchString();
 
 mpImpl->mpVectorGraphicSearch = 
std::make_unique(pGraphicObject->GetGraphic());
-if (mpImpl->mpVectorGraphicSearch->search(rString))
+
+bool bResult = 
mpImpl->mpVectorGraphicSearch->search(rString);
+if (bResult)
+bResult = mpImpl->mpVectorGraphicSearch->next();
+
+if (bResult)
 {
-bool bResult = mpImpl->mpVectorGraphicSearch->next();
-if (bResult)
-{
-mpObj = SetObject(maCurrentPosition);
+mpObj = SetObject(maCurrentPosition);
 
-mbStringFound = true;
-mbMatchMayExist = true;
-

[Libreoffice-commits] core.git: sd/qa sd/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |  104 +-
 sd/source/ui/view/Outliner.cxx|   21 -
 2 files changed, 120 insertions(+), 5 deletions(-)

New commits:
commit 7b2170f6239f0c4f16a1cbd3ec54a861405aa07a
Author: Tomaž Vajngerl 
AuthorDate: Sun May 31 13:28:36 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:43:43 2020 +0200

sd: add support to search backwards in PDF search

Change-Id: I2c7f75d16a430dcfa892d28fb6b4f64118705ad2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95459
Tested-by: Tomaž Vajngerl 
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 2c1e1c0426a3..8c2a41eeca9e 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -56,6 +56,7 @@ public:
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
 void testSearchInPDFInMultiplePages();
+void testSearchInPDFInMultiplePagesBackwards();
 void testSearchIn2MixedObjects();
 void testSearchIn6MixedObjects();
 
@@ -69,6 +70,7 @@ public:
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
 CPPUNIT_TEST(testSearchInPDFInMultiplePages);
+CPPUNIT_TEST(testSearchInPDFInMultiplePagesBackwards);
 CPPUNIT_TEST(testSearchIn2MixedObjects);
 CPPUNIT_TEST(testSearchIn6MixedObjects);
 CPPUNIT_TEST_SUITE_END();
@@ -123,14 +125,14 @@ LOKitSearchTest::createDoc(const char* pName, const 
uno::Sequence 
aPropertyValues(comphelper::InitPropertySequence({
 { "SearchItem.SearchString", uno::makeAny(rKey) },
-{ "SearchItem.Backward", uno::makeAny(false) },
+{ "SearchItem.Backward", uno::makeAny(bBackwards) },
 { "SearchItem.Command", uno::makeAny(sal_uInt16(eSearch)) },
 }));
 
@@ -422,6 +424,104 @@ void LOKitSearchTest::testSearchInPDFInMultiplePages()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 }
 
+void LOKitSearchTest::testSearchInPDFInMultiplePagesBackwards()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("PDFSearch.pdf");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Expected for backwards search is:
+// - Start with Page 1
+//   + search backwards through objects
+//   + inside objects search backwards through text
+// - Switch to Page 2
+//   + search backwards through objects
+//   + inside objects search backwards through text
+
+// Search for "him"
+lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("5592, 5038, 1100, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(0, mpCallbackRecorder->m_aSearchResultPart[0]);
+CPPUNIT_ASSERT_EQUAL(OString("9463, 3382, 1099, 499"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search for "him"
+lcl_search("him", /*FindAll*/ false, /*Backwards*/ true);
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(1, 

[Libreoffice-commits] core.git: sd/qa sd/source

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |   86 ++
 sd/qa/unit/tiledrendering/data/MixedTest1.odg |binary
 sd/source/ui/view/Outliner.cxx|2 
 3 files changed, 87 insertions(+), 1 deletion(-)

New commits:
commit 18f8340a697be7c076fe111d0bc42faf877b9202
Author: Tomaž Vajngerl 
AuthorDate: Sat May 30 15:47:35 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:41:49 2020 +0200

sd: fix issue when PDF search doesn't send a search result + test

This fixes the issue when PDF search doesn't send the search
result, because of premature exit.

Also add test which reproduces this issue and tests the behavior
of searching in multiple objects.

Change-Id: I3a676eeac36bde88c67e90a49583444b8595a346
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95454
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 8d8b11e43fa1..24037a0780ba 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -55,6 +55,7 @@ public:
 void testDontSearchInMasterPages();
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
+void testSearchInMixedObject();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -65,6 +66,7 @@ public:
 CPPUNIT_TEST(testDontSearchInMasterPages);
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
+CPPUNIT_TEST(testSearchInMixedObject);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -317,6 +319,90 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSelection[0]);
 }
 
+void LOKitSearchTest::testSearchInMixedObject()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+CPPUNIT_ASSERT(pDocument);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+// Check we have one page
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), 
pDocument->GetSdPageCount(PageKind::Standard));
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+// Check page hase 2 objects only
+CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
+
+// Check Object 1
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 2
+{
+SdrObject* pObject = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObject);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), 
pObject->GetObjIdentifier());
+
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+
+Graphic aGraphic = pGraphicObject->GetGraphic();
+auto const& pVectorGraphicData = aGraphic.getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Let's try to search now
+
+lcl_search("ABC");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(1, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search next
+
+lcl_search("ABC");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(2, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(OString("8412, 6385, 519, 174"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+
+// Search next again - we should get the first object again
+
+lcl_search("ABC");
+
+CPPUNIT_ASSERT_EQUAL(true, mpCallbackRecorder->m_bFound);
+CPPUNIT_ASSERT_EQUAL(3, mpCallbackRecorder->m_nSearchResultCount);
+
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultSelection.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), 
mpCallbackRecorder->m_aSearchResultPart.size());
+
+CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"),
+ mpCallbackRecorder->m_aSearchResultSelection[0]);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(LOKitSearchTest);
 
 /* vim:set 

[Libreoffice-commits] core.git: sd/qa

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
 sd/qa/unit/tiledrendering/LOKitSearchTest.cxx |  179 +-
 sd/qa/unit/tiledrendering/data/MixedTest2.odg |binary
 2 files changed, 178 insertions(+), 1 deletion(-)

New commits:
commit ceaa07e1a1aafd9a11b8baea242605f32c56e584
Author: Tomaž Vajngerl 
AuthorDate: Sat May 30 19:30:44 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Jun 4 00:42:00 2020 +0200

sd: Add another test of searching with mixed objects

This is to make sure that we switch between different objects
during the search correctly.

Change-Id: I18aa5b251cbaadd3a9cb15a04ec1a1e5f267d2e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95455
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx 
b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
index 24037a0780ba..7786bc1f1dae 100644
--- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
+++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx
@@ -56,6 +56,7 @@ public:
 void testSearchInPDFNonExisting();
 void testSearchInPDF();
 void testSearchInMixedObject();
+void testSearchInMixedObject2();
 
 CPPUNIT_TEST_SUITE(LOKitSearchTest);
 CPPUNIT_TEST(testSearch);
@@ -67,6 +68,7 @@ public:
 CPPUNIT_TEST(testSearchInPDFNonExisting);
 CPPUNIT_TEST(testSearchInPDF);
 CPPUNIT_TEST(testSearchInMixedObject);
+CPPUNIT_TEST(testSearchInMixedObject2);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -134,6 +136,15 @@ void lcl_search(const OUString& rKey, bool bFindAll = 
false)
 Scheduler::ProcessEventsToIdle();
 }
 
+SdrObject* lclGetSelectedObject(sd::ViewShell* pViewShell)
+{
+SdrView* pSdrView = pViewShell->GetView();
+const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
+CPPUNIT_ASSERT_EQUAL(size_t(1), rMarkList.GetMarkCount());
+SdrObject* pObject = rMarkList.GetMark(0)->GetMarkedSdrObj();
+return pObject;
+}
+
 } // end anonymous namespace
 
 void LOKitSearchTest::testSearch()
@@ -319,6 +330,8 @@ void LOKitSearchTest::testSearchInPDF()
  mpCallbackRecorder->m_aSelection[0]);
 }
 
+// Test searching in document with mixed objects.
+// We have 2 objects: 1. Text Object, 2. Graphic Object with PDF
 void LOKitSearchTest::testSearchInMixedObject()
 {
 SdXImpressDocument* pXImpressDocument = createDoc("MixedTest1.odg");
@@ -334,7 +347,7 @@ void LOKitSearchTest::testSearchInMixedObject()
 SdPage* pPage = pViewShell->GetActualPage();
 CPPUNIT_ASSERT(pPage);
 
-// Check page hase 2 objects only
+// Check page has 2 objects only
 CPPUNIT_ASSERT_EQUAL(size_t(2), pPage->GetObjCount());
 
 // Check Object 1
@@ -403,6 +416,170 @@ void LOKitSearchTest::testSearchInMixedObject()
  mpCallbackRecorder->m_aSearchResultSelection[0]);
 }
 
+// Test searching in document with mixed objects. We have 6 objects.
+void LOKitSearchTest::testSearchInMixedObject2()
+{
+SdXImpressDocument* pXImpressDocument = createDoc("MixedTest2.odg");
+sd::ViewShell* pViewShell = 
pXImpressDocument->GetDocShell()->GetViewShell();
+CPPUNIT_ASSERT(pViewShell);
+SdDrawDocument* pDocument = pXImpressDocument->GetDocShell()->GetDoc();
+CPPUNIT_ASSERT(pDocument);
+mpCallbackRecorder->registerCallbacksFor(pViewShell->GetViewShellBase());
+
+// Check we have one page
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), 
pDocument->GetSdPageCount(PageKind::Standard));
+
+SdPage* pPage = pViewShell->GetActualPage();
+CPPUNIT_ASSERT(pPage);
+
+// Check page has 6 objects only
+CPPUNIT_ASSERT_EQUAL(size_t(6), pPage->GetObjCount());
+
+// Check we have the right objects that we expect
+
+// Check Object 1
+{
+SdrObject* pObject = pPage->GetObj(0);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_TEXT), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 2
+{
+SdrObject* pObject = pPage->GetObj(1);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_GRAF), 
pObject->GetObjIdentifier());
+SdrGrafObj* pGraphicObject = dynamic_cast(pObject);
+CPPUNIT_ASSERT(pGraphicObject);
+auto const& pVectorGraphicData = 
pGraphicObject->GetGraphic().getVectorGraphicData();
+CPPUNIT_ASSERT(pVectorGraphicData);
+CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf,
+ pVectorGraphicData->getVectorGraphicDataType());
+}
+
+// Check Object 3
+{
+SdrObject* pObject = pPage->GetObj(2);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_CUSTOMSHAPE), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 4
+{
+SdrObject* pObject = pPage->GetObj(3);
+CPPUNIT_ASSERT(pObject);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(OBJ_CUSTOMSHAPE), 
pObject->GetObjIdentifier());
+}
+
+// Check Object 5
+{
+SdrObject* pObject = pPage->GetObj(4);
+

[Libreoffice-commits] core.git: Branch 'feature/drawinglayercore' - 41 commits - cui/Module_cui.mk cui/Package_cui.mk cui/source desktop/source drawinglayer/CppunitTest_drawinglayer_border.mk drawingl

2020-06-03 Thread Tomaž Vajngerl (via logerrit)
Rebased ref, commits from common ancestor:
commit 043c691e39746fab89a350f09a5d0bc7dfc3f3d9
Author: Tomaž Vajngerl 
AuthorDate: Wed Jun 3 17:00:47 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 3 22:28:21 2020 +0200

drawinglayer: remove textprimitive2d.hxx from clang-format blacklist

Change-Id: I6fa692bb3e4a16400ee2ae847a1f97201493f53a

diff --git a/include/drawinglayer/primitive2d/textprimitive2d.hxx 
b/include/drawinglayer/primitive2d/textprimitive2d.hxx
index 9aeaa96fc15e..6bbc14aa498a 100644
--- a/include/drawinglayer/primitive2d/textprimitive2d.hxx
+++ b/include/drawinglayer/primitive2d/textprimitive2d.hxx
@@ -33,152 +33,151 @@
 
 namespace drawinglayer::primitive2d
 {
-/** TextSimplePortionPrimitive2D class
+/** TextSimplePortionPrimitive2D class
 
-This is the basic primitive for representing a text portion. It 
contains
-all needed information. If it is not handled by a renderer, its 
decomposition
-will provide the text tools::PolyPolygon outlines as filled 
polygons, correctly
-transformed.
+This is the basic primitive for representing a text portion. It contains
+all needed information. If it is not handled by a renderer, its 
decomposition
+will provide the text tools::PolyPolygon outlines as filled polygons, 
correctly
+transformed.
 
-To get better text quality, it is suggested to handle this 
primitive directly
-in a renderer. In that case, e.g. hintings on the system can be 
supported.
+To get better text quality, it is suggested to handle this primitive 
directly
+in a renderer. In that case, e.g. hintings on the system can be supported.
 
-@param maTextTransform
-The text transformation contains the text start position (always 
baselined)
-as translation, the FontSize as scale (where width relative to 
height defines
-font scaling and width == height means no font scaling) and the 
font rotation
-and shear.
-When shear is used and a renderer does not support it, it may be 
better to use
-the decomposition which will do everything correctly. Same is true 
for mirroring
-which would be expressed as negative scalings.
+@param maTextTransform
+The text transformation contains the text start position (always baselined)
+as translation, the FontSize as scale (where width relative to height 
defines
+font scaling and width == height means no font scaling) and the font 
rotation
+and shear.
+When shear is used and a renderer does not support it, it may be better to 
use
+the decomposition which will do everything correctly. Same is true for 
mirroring
+which would be expressed as negative scalings.
 
-@param rText
-The text to be used. Only a part may be used, but a bigger part of 
the string
-may be necessary for correct layouting (e.g. international)
-
-@param aTextPosition
-The index to the first character to use from rText
-
-@param aTextLength
-The number of characters to use from rText
-
-@param rDXArray
-The distances between the characters. This parameter may be empty, 
in that case
-the renderer is responsible to do something useful. If it is 
given, it has to be of
-the size aTextLength. Its values are in logical coordinates and 
describe the
-distance for each character to use. This is independent from the 
font width which
-is given with maTextTransform. The first value is the offset to 
use from the start
-point in FontCoordinateSystem X-Direction (given by 
maTextTransform) to the start
-point of the second character
-
-@param rFontAttribute
-The font definition
-
-@param rLocale
-The locale to use
-
-@param rFontColor
-The font color to use
-
-@param bFilled
-
-@param nWidthToFill
-
-@param rTextFillColor
-Text background color (has nothing to do with bFilled and 
nWidthToFill)
-
- */
-class DRAWINGLAYER_DLLPUBLIC TextSimplePortionPrimitive2D : public 
BufferedDecompositionPrimitive2D
-{
-private:
-/// text transformation (FontCoordinateSystem)
-basegfx::B2DHomMatrix   maTextTransform;
-
-/// The text, used from maTextPosition up to maTextPosition + 
maTextLength
-OUStringmaText;
-
-/// The index from where on maText is used
-sal_Int32   mnTextPosition;
-
-/// The length for maText usage, starting from maTextPosition
-sal_Int32   mnTextLength;
-
-/// The DX array in logic units
-

<    4   5   6   7   8   9   10   11   12   13   >