core.git: vcl/qa

2024-10-09 Thread Miklos Vajna (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit fe9dab32a3083059f46aba1ba5eab5840c2d07b5
Author: Miklos Vajna 
AuthorDate: Wed Oct 9 15:11:18 2024 +0200
Commit: Miklos Vajna 
CommitDate: Wed Oct 9 23:06:26 2024 +0200

CppunitTest_vcl_pdfexport2: relax testPdfImageHyperlink a bit

This will start to fail on pdfium-6764 with:
pdfexport2.cxx:4186:Assertion
Test name: (anonymous namespace)::testPdfImageHyperlink::TestBody
equality assertion failed
- Expected: 0.0012626264
- Actual  : 0.0012626261

But the original problem was that the repriprocal was just 0.00126. If
we require one less digit, 1/0.001262626 is 792.0001647360343 and
1/0.0012626264 is 791.138304095, so the original problem that the
rounded result is 794 points (and not 792) is still tested.

Change-Id: Ia4489625fd25eca971261b14005b10bbf34343eb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174724
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 5e59ec0373f1..59c96bb72ba5 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -4183,7 +4183,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, 
testPdfImageHyperlink)
 // - Expected: 0.0012626264
 // - Actual  : 0.00126
 // i.e. the rounded reciprocal was 794 points, not the original 792.
-CPPUNIT_ASSERT_EQUAL(0.0012626264, rtl::math::round(aScale.getY(), 10));
+CPPUNIT_ASSERT_EQUAL(0.001262626, rtl::math::round(aScale.getY(), 9));
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testURIs)


core.git: vcl/qa

2024-08-28 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |   28 +++-
 1 file changed, 23 insertions(+), 5 deletions(-)

New commits:
commit ffcd44ce7c109ca6daf9b9a339609af92f163ecf
Author: Michael Stahl 
AuthorDate: Tue Aug 27 15:52:27 2024 +0200
Commit: Michael Stahl 
CommitDate: Wed Aug 28 11:31:46 2024 +0200

vcl: fix testMultiPagePDF with zlib-ng

After upgrading to Fedora 40, which replaced zlib with zlib-ng, this
test fails on different compressed stream sizes, but the uncompressed
content of the stream is the same as before (only checked first one).

  vcl/qa/cppunit/pdfexport/pdfexport2.cxx:808:(anonymous 
namespace)::testMultiPagePDF::TestBody
  equality assertion failed
  - Expected: 230
  - Actual  : 228

Change-Id: I27a6d4ac47691258793e18442fb1b59ac1b581c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172471
Reviewed-by: David Gilbert 
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index c3660e5a9c13..43e3e16ec034 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -804,8 +804,14 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMultiPagePDF)
 SvMemoryStream& rObjectStream = pStream->GetMemory();
 rObjectStream.Seek(STREAM_SEEK_TO_BEGIN);
 
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
 // Just check that the size of the page stream is what is expected.
-CPPUNIT_ASSERT_EQUAL(sal_uInt64(230), rObjectStream.remainingSize());
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(1236), aUncompressed.Tell());
 }
 
 { // embedded PDF page 2
@@ -833,8 +839,14 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMultiPagePDF)
 SvMemoryStream& rObjectStream = pStream->GetMemory();
 rObjectStream.Seek(STREAM_SEEK_TO_BEGIN);
 
-// Just check that the size of the page stream is what is expected
-CPPUNIT_ASSERT_EQUAL(sal_uInt64(309), rObjectStream.remainingSize());
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+// Just check that the size of the page stream is what is expected.
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(3911), aUncompressed.Tell());
 }
 
 { // embedded PDF page 3
@@ -862,8 +874,14 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMultiPagePDF)
 SvMemoryStream& rObjectStream = pStream->GetMemory();
 rObjectStream.Seek(STREAM_SEEK_TO_BEGIN);
 
-// Just check that the size of the page stream is what is expected
-CPPUNIT_ASSERT_EQUAL(sal_uInt64(193), rObjectStream.remainingSize());
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+// Just check that the size of the page stream is what is expected.
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(373), aUncompressed.Tell());
 }
 #endif
 }


core.git: vcl/qa

2024-08-27 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit 6f5eb77023d50114ae9e837b7d81fe414abbef4a
Author: Michael Stahl 
AuthorDate: Tue Aug 27 15:04:40 2024 +0200
Commit: Michael Stahl 
CommitDate: Tue Aug 27 17:21:28 2024 +0200

vcl: fix testTdf129085

For unclear reasons, after upgrading to Fedora 40 and pulling the latest
master, testTdf129085 started to fail:

 pdfexport2.cxx:328:Assertion
 Test name: (anonymous namespace)::testTdf129085::TestBody
 equality assertion failed
 - Expected: 0x0(Error Area:Io Class:NONE Code:0)
 - Actual  : 0x8203(Error Area:Vcl Class:General Code:3)

The test runs in the libreoffice-24-2 branch, and the difference is that
in the old brach a JPEG was exported into the PDF as expected, but in
master a DIB was exported instead, because it turned out to be smaller
than the JPEG, because the quality level of the JPEG was 90 in master
and 80 in the old branch, due to the old branch test passing FilterData
with UseTaggedPDF, which was later removed from the test due to being
the default.

Pass in an explicit low quality to prevent this problem.

Change-Id: Ic26c25b15fecd52c5195a7d30c603bda34fe88d3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172470
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 4895845f4b8c..c3660e5a9c13 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -295,6 +295,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf161346)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf129085)
 {
+uno::Sequence 
aFilterData(comphelper::InitPropertySequence({
+// if the Quality is too high (like 90) then the image will be a DIB,
+// not a JPEG! 80 works currently but set it lower to be sure...
+{ "Quality", uno::Any(sal_Int32(50)) },
+}));
+aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
+
 vcl::filter::PDFDocument aDocument;
 load(u"tdf129085.docx", aDocument);
 


core.git: vcl/qa vcl/source

2024-08-23 Thread Tibor Nagy (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf159895.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |   61 
 vcl/source/gdi/pdfwriter_impl.cxx   |   15 +++---
 3 files changed, 68 insertions(+), 8 deletions(-)

New commits:
commit 54374c97b86730d97f5ad622dc88c0798af4be1c
Author: Tibor Nagy 
AuthorDate: Thu Aug 22 21:34:34 2024 +0200
Commit: Nagy Tibor 
CommitDate: Fri Aug 23 16:25:43 2024 +0200

tdf#159895 sw: fix "Stack empty" error in tagged PDF export

Change-Id: I8a2e0d51d1cfe6d4b517f193c73e512600638cf0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172302
Tested-by: Jenkins
Reviewed-by: Nagy Tibor 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf159895.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf159895.odt
new file mode 100644
index ..77091cf51cad
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf159895.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 9b08b1fa047a..4895845f4b8c 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -85,6 +85,67 @@ void PdfExportTest2::load(std::u16string_view rFile, 
vcl::filter::PDFDocument& r
 CPPUNIT_ASSERT(rDocument.Read(aStream));
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf159895)
+{
+// Enable PDF/UA
+uno::Sequence 
aFilterData(comphelper::InitPropertySequence({
+{ "PDFUACompliance", uno::Any(true) },
+{ "ExportFormFields", uno::Any(true) },
+}));
+aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
+
+vcl::filter::PDFDocument aDocument;
+load(u"tdf159895.odt", aDocument);
+
+// The document has one page.
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(1), aPages.size());
+
+for (const auto& rDocElement : aDocument.GetElements())
+{
+auto pObj = 
dynamic_cast(rDocElement.get());
+if (!pObj)
+continue;
+
+auto pType = 
dynamic_cast(pObj->Lookup("Type"_ostr));
+if (pType && pType->GetValue() == "XObject")
+{
+auto pFilter = 
dynamic_cast(pObj->Lookup("Filter"_ostr));
+CPPUNIT_ASSERT(pFilter);
+
+vcl::filter::PDFStreamElement* pStream = pObj->GetStream();
+CPPUNIT_ASSERT(pStream);
+SvMemoryStream& rObjectStream = pStream->GetMemory();
+// Uncompress it.
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+rObjectStream.Seek(0);
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+auto pStart = static_cast(aUncompressed.GetData());
+const char* const pEnd = pStart + aUncompressed.GetSize();
+
+OString sText;
+while (true)
+{
+auto const pLine = ::std::find(pStart, pEnd, '
');
+if (pLine == pEnd)
+break;
+
+std::string_view const line(pStart, pLine - pStart);
+pStart = pLine + 1;
+if (!line.empty() && line[0] != '%')
+{
+sText += line + "
"_ostr;
+}
+}
+CPPUNIT_ASSERT_EQUAL("/Tx BMC
EMC
"_ostr, sText);
+}
+}
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf124272)
 {
 // Import the bugdoc and export as PDF.
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 434156491703..d986c93c3de3 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4364,20 +4364,12 @@ void PDFWriterImpl::createDefaultListBoxAppearance( 
PDFWidget& rBox, const PDFWr
 Font aFont = drawFieldBorder( rBox, rWidget, rSettings );
 sal_Int32 nBest = getSystemFont( aFont );
 
-beginRedirect( pListBoxStream, rBox.m_aRect );
-
 setLineColor( COL_TRANSPARENT );
 setFillColor( replaceColor( rWidget.BackgroundColor, 
rSettings.GetFieldColor() ) );
 drawRectangle( rBox.m_aRect );
 
-// empty appearance, see createDefaultEditAppearance for reference
-writeBuffer( "/Tx BMC
EMC
" );
-
-endRedirect();
 pop();
 
-rBox.m_aAppearances[ "N"_ostr ][ "Standard"_ostr ] = pListBoxStream;
-
 // prepare DA string
 OStringBuffer aDA( 256 );
 // prepare DA string
@@ -4394,6 +4386,13 @@ void PDFWriterImpl::createDefaultListBoxAppearance( 
PDFWidget& rBox, const PDFWr
 aDA.append( ' ' );
 m_aPages[ m_nCurrentPage ].appendMappedLength( sal_Int32( 
aFont.GetFontHeight() ), aDA );
 aDA.append( " Tf" );
+
+beginRedirect(pListBoxStream, rBox.m_aRect);
+// empty appearance, see createDefaultEditAppearance for reference
+writeBuffer("/Tx BMC
EMC
");
+endRedirect();
+
+rBox.m_aAppearances["N"_ostr]["Standard"_ostr] = pListBoxStream;
 rBox.m_aDAString = aDA.makeStringAn

core.git: vcl/qa

2024-07-31 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   33 ++--
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |3 --
 2 files changed, 19 insertions(+), 17 deletions(-)

New commits:
commit f09775c69bbdd5c43ad375f4869c0d329bccebf2
Author: Xisco Fauli 
AuthorDate: Wed Jul 31 12:08:13 2024 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jul 31 13:19:48 2024 +0200

CppunitTest_vcl_pdfexport: simplify a bit more

after 159d823c7b7502ee07d897d74c4e74c6e1873596
"tdf#153040 PDF export: disable export of form fields as PDF forms by
default"

Change-Id: I1da61a7ccddc362b8d8ab08f7e48c7da57d47337
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171308
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index d033b71bb11c..897ab39df7d1 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -44,8 +44,7 @@ public:
 }
 
 void saveAsPDF(std::u16string_view rFile);
-void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument,
-  bool bUseExportFormFields = false);
+void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument);
 };
 
 void PdfExportTest::saveAsPDF(std::u16string_view rFile)
@@ -56,16 +55,8 @@ void PdfExportTest::saveAsPDF(std::u16string_view rFile)
 saveWithParams(aMediaDescriptor.getAsConstPropertyValueList());
 }
 
-void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& 
rDocument,
- bool bUseExportFormFields)
+void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& 
rDocument)
 {
-if (bUseExportFormFields)
-{
-uno::Sequence 
aFilterData(comphelper::InitPropertySequence({
-{ "ExportFormFields", uno::Any(bUseExportFormFields) },
-}));
-aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
-}
 saveAsPDF(rFile);
 
 // Parse the export result.
@@ -874,8 +865,12 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testAlternativeText)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105972)
 {
+uno::Sequence 
aFilterData(comphelper::InitPropertySequence({
+{ "ExportFormFields", uno::Any(true) },
+}));
+aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
 vcl::filter::PDFDocument aDocument;
-load(u"tdf105972.fodt", aDocument, /*bUseExportFormFields=*/true);
+load(u"tdf105972.fodt", aDocument);
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
@@ -938,8 +933,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105972)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442)
 {
+uno::Sequence 
aFilterData(comphelper::InitPropertySequence({
+{ "ExportFormFields", uno::Any(true) },
+}));
+aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
+
 vcl::filter::PDFDocument aDocument;
-load(u"tdf148442.odt", aDocument, /*bUseExportFormFields=*/true);
+load(u"tdf148442.odt", aDocument);
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
@@ -1007,8 +1007,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148442)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf118244_radioButtonGroup)
 {
+uno::Sequence 
aFilterData(comphelper::InitPropertySequence({
+{ "ExportFormFields", uno::Any(true) },
+}));
+aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
+
 vcl::filter::PDFDocument aDocument;
-load(u"tdf118244_radioButtonGroup.odt", aDocument, 
/*bUseExportFormFields=*/true);
+load(u"tdf118244_radioButtonGroup.odt", aDocument);
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 1b00d1cc52c0..702b71db7eff 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -5282,7 +5282,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157390)
 // tdf#162205 - Verifies bidi portions on vertical left-to-right pages are 
rendered correctly
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf162205Ltr)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
 saveAsPDF(u"tdf162205-ltr.fodt");
 
 auto pPdfDocument = parsePDFExport();
@@ -5338,7 +5337,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf162205Ltr)
 // tdf#162205 - Verifies bidi portions on vertical left-to-right pages are 
rendered correctly
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf162205Rtl)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
 saveAsPDF(u"tdf162205-rtl.fodt");
 
 auto pPdfDocument = parsePDFExport();
@@ -5394,7 +5392,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf162205Rtl)
 // tdf#162194 - Verifies soft hyphens inside ligatures are rendered correctly.
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf162194SoftHyphen)
 {
-aMe

core.git: vcl/qa

2024-07-28 Thread Caolán McNamara (via logerrit)
 vcl/qa/unx/generic/generic.cxx |   32 
 1 file changed, 20 insertions(+), 12 deletions(-)

New commits:
commit d01dcab81a6a66fd5b4448ccff348f69c82c538d
Author: Caolán McNamara 
AuthorDate: Sun Jul 28 16:17:04 2024 +0100
Commit: Caolán McNamara 
CommitDate: Sun Jul 28 21:59:41 2024 +0200

Related: tdf#162072 compare fallback to what "serif" resolves to

instead of assuming that the resolved serif font will have
serif in its name.

Change-Id: I3f85e2a8abd1dbf851debec9196e55d5c2da4e66
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171144
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/unx/generic/generic.cxx b/vcl/qa/unx/generic/generic.cxx
index 60f91266e067..7d71bec072e5 100644
--- a/vcl/qa/unx/generic/generic.cxx
+++ b/vcl/qa/unx/generic/generic.cxx
@@ -26,32 +26,40 @@ public:
 : UnoApiTest(u"/vcl/qa/unx/generic/data/"_ustr)
 {
 }
+static OUString GetFallbackFont(const vcl::Font& rFont)
+{
+Size aSize(0, 3840);
+float fExactHeight = 3840;
+bool bNonAntialias = false;
+vcl::font::FontSelectPattern aPattern(rFont, rFont.GetFamilyName(), 
aSize, fExactHeight,
+  bNonAntialias);
+aPattern.maTargetName = rFont.GetFamilyName();
+psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+OUString aMissingCodes;
+
+rMgr.Substitute(aPattern, aMissingCodes);
+
+return aPattern.maSearchName;
+}
 };
 
 CPPUNIT_TEST_FIXTURE(Test, testFontFallbackSerif)
 {
+OUString sResolvedSerif = GetFallbackFont(vcl::Font("serif", Size(12, 
12)));
+
 // Given a font select pattern with a font name we don't bundle and with a 
serif family:
 vcl::Font aFont;
 aFont.SetFamilyName("IBM Plex Serif");
 aFont.SetFamily(FAMILY_ROMAN);
-Size aSize(0, 3840);
-float fExactHeight = 3840;
-bool bNonAntialias = false;
-vcl::font::FontSelectPattern aPattern(aFont, aFont.GetFamilyName(), aSize, 
fExactHeight,
-  bNonAntialias);
-aPattern.maTargetName = aFont.GetFamilyName();
-psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
-OUString aMissingCodes;
-
-// When substituting that font:
-rMgr.Substitute(aPattern, aMissingCodes);
+
+OUString sPlexFallback = GetFallbackFont(aFont);
 
 // Then make sure we get a serif fallback:
 // Without the accompanying fix in place, this test would have failed with:
 // - Expected: Noto Serif (or DejaVu Serif)
 // - Actual  : Noto Kufi Arabic
 // i.e. we got a sans fallback for a serif pattern, which is clearly poor.
-CPPUNIT_ASSERT(aPattern.maSearchName.endsWith(u"Serif"));
+CPPUNIT_ASSERT_EQUAL(sResolvedSerif, sPlexFallback);
 }
 }
 


core.git: vcl/qa

2024-07-26 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |  207 +---
 1 file changed, 38 insertions(+), 169 deletions(-)

New commits:
commit 80a69f6780c899df0443abd7e49a68c203378fac
Author: Xisco Fauli 
AuthorDate: Fri Jul 26 13:49:41 2024 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 26 18:57:01 2024 +0200

CppunitTest_vcl_pdfexport2: simplify a bit

TaggedPDF is enabled by default since 
544d6d781b3c8aa108ced362d708693b5127f3d7
"tdf#39667 Enable tagged PDF by default"
Only disable it when needed

OTOH, using writer_pdf_Export as a FilterName works when
exporting calc/impress/draw documents too

Change-Id: I970406b8a87cad937c3023815e4f5caa9b4f7143
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171069
Reviewed-by: Xisco Fauli 
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 0f0d49054d95..2c314d6b886f 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -15,7 +15,6 @@
 #include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -66,25 +65,19 @@ public:
 }
 
 void saveAsPDF(std::u16string_view rFile);
-void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument,
-  bool bUseTaggedPDF = true);
+void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument);
 };
 
 void PdfExportTest2::saveAsPDF(std::u16string_view rFile)
 {
 // Import the bugdoc and export as PDF.
 loadFromFile(rFile);
-uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
-xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
+saveWithParams(aMediaDescriptor.getAsConstPropertyValueList());
 }
 
-void PdfExportTest2::load(std::u16string_view rFile, vcl::filter::PDFDocument& 
rDocument,
-  bool bUseTaggedPDF)
+void PdfExportTest2::load(std::u16string_view rFile, vcl::filter::PDFDocument& 
rDocument)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
-uno::Sequence aFilterData(
-comphelper::InitPropertySequence({ { "UseTaggedPDF", 
uno::Any(bUseTaggedPDF) } }));
-aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
 saveAsPDF(rFile);
 
 // Parse the export result.
@@ -316,7 +309,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTocLink)
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReduceSmallImage)
 {
 // Load the Writer document.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
 saveAsPDF(u"reduce-small-image.fodt");
 std::unique_ptr pPdfDocument = parsePDFExport();
 CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
@@ -341,7 +333,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReduceSmallImage)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf114256)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"calc_pdf_Export"_ustr;
 saveAsPDF(u"tdf114256.ods");
 std::unique_ptr pPdfDocument = parsePDFExport();
 CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
@@ -356,7 +347,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf114256)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf150931)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"calc_pdf_Export"_ustr;
 saveAsPDF(u"tdf150931.ods");
 std::unique_ptr pPdfDocument = parsePDFExport();
 CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
@@ -406,7 +396,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf147027)
 return;
 
 // Load the Calc document.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"calc_pdf_Export"_ustr;
 saveAsPDF(u"tdf147027.ods");
 std::unique_ptr pPdfDocument = parsePDFExport();
 CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
@@ -422,7 +411,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf147027)
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf135346)
 {
 // Load the Calc document.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"calc_pdf_Export"_ustr;
 saveAsPDF(u"tdf135346.ods");
 std::unique_ptr pPdfDocument = parsePDFExport();
 CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
@@ -437,7 +425,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf135346)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf147164)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"impress_pdf_Export"_ustr;
 saveAsPDF(u"tdf147164.odp");
 std::unique_ptr pPdfDocument = parsePDFExport();
 CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
@@ -502,7 +489,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReduceImage)
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testLinkWrongPage)
 {
 // Import the bugdoc and export as PDF.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"impress_pdf_Export"_ustr;
 saveAsPDF(u"link-wrong-page.odp");
 std::unique_ptr pPdfDocument = parsePDFExport();
 
@@ -530,7 +516,6 @@ CPPUNIT_TEST_FIXTURE(P

core.git: vcl/qa

2024-07-26 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   96 -
 1 file changed, 13 insertions(+), 83 deletions(-)

New commits:
commit a5133fb0416a98ff727747e873fbb508c5ac3168
Author: Xisco Fauli 
AuthorDate: Fri Jul 26 14:27:09 2024 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 26 15:43:34 2024 +0200

CppunitTest_vcl_pdfexport: simplify a bit

TaggedPDF is enabled by default since 
544d6d781b3c8aa108ced362d708693b5127f3d7
"tdf#39667 Enable tagged PDF by default"

OTOH, using writer_pdf_Export as a FilterName works when
exporting calc/impress/draw documents too

Change-Id: I5dc0c9eedbb6716f1ef58ffd1faa16e9cc015f9d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171070
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 63b89fcbbcb8..1195985703cf 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -14,7 +14,6 @@
 
 #include 
 
-#include 
 #include 
 
 #include 
@@ -44,25 +43,19 @@ public:
 }
 
 void saveAsPDF(std::u16string_view rFile);
-void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument,
-  bool bUseTaggedPDF = true);
+void load(std::u16string_view rFile, vcl::filter::PDFDocument& rDocument);
 };
 
 void PdfExportTest::saveAsPDF(std::u16string_view rFile)
 {
 // Import the bugdoc and export as PDF.
 loadFromFile(rFile);
-uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
-xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
+saveWithParams(aMediaDescriptor.getAsConstPropertyValueList());
 }
 
-void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& 
rDocument,
- bool bUseTaggedPDF)
+void PdfExportTest::load(std::u16string_view rFile, vcl::filter::PDFDocument& 
rDocument)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
-uno::Sequence aFilterData(
-comphelper::InitPropertySequence({ { "UseTaggedPDF", 
uno::Any(bUseTaggedPDF) } }));
-aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
 saveAsPDF(rFile);
 
 // Parse the export result.
@@ -72,17 +65,8 @@ void PdfExportTest::load(std::u16string_view rFile, 
vcl::filter::PDFDocument& rD
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testFigurePlacement)
 {
-aMediaDescriptor[u"FilterName"_ustr] <<= u"impress_pdf_Export"_ustr;
-
-uno::Sequence aFilterData(
-comphelper::InitPropertySequence({ { "UseTaggedPDF", uno::Any(true) } 
}));
-aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
-saveAsPDF(u"tdf159900_figurePlacement.odt");
-
-// Parse the export result.
 vcl::filter::PDFDocument aDocument;
-SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
-CPPUNIT_ASSERT(aDocument.Read(aStream));
+load(u"tdf159900_figurePlacement.odt", aDocument);
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
@@ -124,18 +108,13 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testFigurePlacement)
 /// Tests that a pdf image is roundtripped back to PDF as a vector format.
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106059)
 {
-// Import the bugdoc and export as PDF.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
 // Explicitly enable the usage of the reference XObject markup.
 uno::Sequence aFilterData(
 comphelper::InitPropertySequence({ { "UseReferenceXObject", 
uno::Any(true) } }));
 aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
-saveAsPDF(u"tdf106059.odt");
 
-// Parse the export result.
 vcl::filter::PDFDocument aDocument;
-SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
-CPPUNIT_ASSERT(aDocument.Read(aStream));
+load(u"tdf106059.odt", aDocument);
 
 // Assert that the XObject in the page resources dictionary is a reference 
XObject.
 std::vector aPages = aDocument.GetPages();
@@ -206,7 +185,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106693)
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105461)
 {
 // Import the bugdoc and export as PDF.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
 saveAsPDF(u"tdf105461.odp");
 
 // Parse the export result with pdfium.
@@ -362,7 +340,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf106206)
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf127217)
 {
 // Import the bugdoc and export as PDF.
-aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
 saveAsPDF(u"tdf127217.odt");
 
 // Parse the export result with pdfium.
@@ -600,7 +577,6 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf107018)
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf148706)
 {
 // Import the bugdoc and export as PDF.
-aMediaDescriptor[u"Filte

core.git: vcl/qa vcl/source

2024-07-24 Thread Patrick Luby (via logerrit)
 vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx |4 ++--
 vcl/source/filter/webp/writer.cxx  |4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 4bbdb2f0718d71840a4e55cc7e9c82157422b0dd
Author: Patrick Luby 
AuthorDate: Wed Jul 24 10:25:30 2024 -0400
Commit: Patrick Luby 
CommitDate: Wed Jul 24 20:58:16 2024 +0200

tdf#162171 alpha mask pixels are now alpha instead of transparency

Starting with commit 81994cb2b8b32453a92bcb011830fcb884f22ff3,
alpha masks now store alpha instead of transparency values.

Change-Id: I74d7a536e0ae1aea3b462d660ae3e4b815cf89c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170968
Tested-by: Jenkins
Reviewed-by: Noel Grandin 
Reviewed-by: Patrick Luby 

diff --git a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx 
b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
index 7c2c88a983ca..0bdf908ad059 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
@@ -95,7 +95,7 @@ void WebpFilterTest::testRoundtrip(bool lossy)
 pAccess->SetFillColor(COL_BLUE);
 pAccess->FillRect(tools::Rectangle(Point(10, 10), Size(10, 10)));
 BitmapScopedWriteAccess pAccessAlpha(aAlpha);
-pAccessAlpha->SetFillColor(BitmapColor(0)); // opaque
+pAccessAlpha->SetFillColor(BitmapColor(COL_WHITE)); // opaque
 pAccessAlpha->FillRect(tools::Rectangle(Point(0, 0), Size(10, 10)));
 pAccessAlpha->FillRect(tools::Rectangle(Point(10, 0), Size(10, 10)));
 pAccessAlpha->FillRect(tools::Rectangle(Point(0, 10), Size(10, 10)));
@@ -144,7 +144,7 @@ void WebpFilterTest::testRoundtrip(bool lossy)
 CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(0, 
0));
 CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(0, 
19));
 CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(19, 
0));
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(191), pAccessAlpha->GetPixelIndex(19, 
19));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(64), pAccessAlpha->GetPixelIndex(19, 
19));
 }
 
 aStream.Seek(STREAM_SEEK_TO_BEGIN);
diff --git a/vcl/source/filter/webp/writer.cxx 
b/vcl/source/filter/webp/writer.cxx
index 021947682a1c..da20e2dcc18e 100644
--- a/vcl/source/filter/webp/writer.cxx
+++ b/vcl/source/filter/webp/writer.cxx
@@ -148,8 +148,8 @@ static bool writeWebp(SvStream& rStream, const BitmapEx& 
bitmapEx, bool lossless
 for (tools::Long x = 0; x < access->Width(); ++x)
 {
 BitmapColor color = access->GetPixelFromData(srcB, x);
-BitmapColor transparency = 
accessAlpha->GetPixelFromData(srcA, x);
-color.SetAlpha(255 - transparency.GetIndex());
+BitmapColor alpha = accessAlpha->GetPixelFromData(srcA, x);
+color.SetAlpha(alpha.GetIndex());
 dst[0] = color.GetRed();
 dst[1] = color.GetGreen();
 dst[2] = color.GetBlue();


core.git: vcl/qa vcl/source

2024-07-24 Thread Jonathan Clark (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf157390-overlapping-kanji.fodt |  239 
++
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx|   54 ++
 vcl/source/gdi/pdfwriter_impl.cxx  |   13 
 3 files changed, 304 insertions(+), 2 deletions(-)

New commits:
commit 15d92cd882e7d8280d6d9bdc44b6f29a951aef46
Author: Jonathan Clark 
AuthorDate: Wed Jul 24 01:45:01 2024 -0600
Commit: Jonathan Clark 
CommitDate: Wed Jul 24 15:05:59 2024 +0200

tdf#157390 Fix overlapping CJK characters in PDF export

This change fixes a vertical text glyph metrics regression that was
introduced while migrating PDF export to use metrics from HarfBuzz. The
root cause was incorrectly caching CJK glyph heights in place of widths
for vertical text.

Change-Id: I8426fc902658d1c045b42e760028f26b09eeef93
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170935
Tested-by: Jenkins
Reviewed-by: Jonathan Clark 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf157390-overlapping-kanji.fodt 
b/vcl/qa/cppunit/pdfexport/data/tdf157390-overlapping-kanji.fodt
new file mode 100644
index ..6385cf597986
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf157390-overlapping-kanji.fodt
@@ -0,0 +1,239 @@
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ 
2024-07-23T06:07:05.8023702802024-07-24T00:55:47.337561889PT45M9S14LibreOfficeDev/25.2.0.0.alpha0$Linux_X86_64
 
LibreOffice_project/e9bd8614e28421d4907b06ed2e84bda9ba08e12f2024-07-23T06:49:26.331205263PDF
 files
+ 
+  
+  
+  
+   
+
+ 
AAERAQAABAAQR1BPU1gER70AAAwkAAACmkdTVUIWpuctAAAOwcZPUy8yVT7L/QAA
+  CKBgU1RBVHiSbN0AABCILmNtYXAfLimoAAAJAMhnYXNwEAAADBwI
+  Z2x5ZuFez6oAAAEcAAAGqGhlYWQi08pEAAAICDZoaGVhDBEIgAAACHwkaG10eCu5
+  CEYAAAhAPGxvY2EMDgoDAAAH5CJtYXhwAGUCCQAAB8QgbmFtZS00RvoAAAnQ
+  AAACKnBvc3T/hgAyAAAL/CBwcmVwaAaMhQAACcgHdmhlYQyeFyAAABDcJHZt
+  dHgNEAQOAAAQuCIAAgBf//MA4wLtAAUAEQAAdwMnMwcDByImNTQ2MzIWFRQGgg0CXAIM
+  IBsnJxscJibdAahoaP5Y6iceICYmIB4nAAIAWgHjAX8DAwAFAAsAAFMnJzMHBzMnJzMHB24S
+  AmACEYwTAmECEwHjumZmurpmZroAAQDTASUBVwGyAAsAAEEiJjU0NjMyFhUUBgEUGyYmGxso
+  KAElKB4gJycgHigAAAEANP/IAVUA4AAJAABFLgInNx4CFwERIExNJEEkUE0fOChQSh05HUxQ
+  JQAAAgB+//cDmAK8ACEALgAAUw4CFQYWFhceAjMyPgI3Fw4CIyImJicuAjU0JicFHgQXBy4D
+  J98CAwMBAQMECCY3IxMkIRsJPx49PyIvWEAOBQUBAgUCahsxKSEVBVAGHiw6JAK6DCQkDR9P
+  VSpTfUYjO0klR1VjLEWbgSxmXB0RNhIeIltnbm0yIUSNhXYrAAEAcP/VA1gC8gBXAABTFhYz
+  Mj4DNzY2NxcGBgcOAwc2NjMyFhYVFAYGIyImJjU0NjYzMhYWFwcmJiMiBhUUFjMyNjY1NCYm
+  IyIOAgcnPgM3PgM3Ig4DBwYGB+4RJw8PRVdXRRAWGAguDR0OE0BNSh4jRyFTgUlUmmpEYjUm
+  Ri5DWDADSARHPCIuSjtVfUM6ZUE/ZFdVMDkfS0xBFhU/RD0TED5MSz0QECIQAuECAgIDAwQB
+  AgQCOgkUDA41QT4ZDAk9akRQeEEkQCoiPCQ3WTMMQFMmGiQqLlg+MU4tGzJLMDsZPz83EhE1
+  

core.git: vcl/qa vcl/source

2024-06-25 Thread Tomaž Vajngerl (via logerrit)
 vcl/source/filter/igif/gifread.cxx |  148 +++--
 1 file changed, 45 insertions(+), 103 deletions(-)

New commits:
commit d9fee55c634b500f1d7d0edaa25cecfc276b0869
Author: Tomaž Vajngerl 
AuthorDate: Tue Jun 25 00:08:50 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Jun 26 00:44:55 2024 +0200

vcl: remove partial GIF image loading

This removes the code that handles the IO_PENDING and the graphic
"context" handling from GIF image format.

Partial loading of images complicates the image filter life cycle
a lot (many exceptions) and is not really needed so much today as
this was needed in the past. In most cases we load the whole image
in one pass anyway. Even loading from the network should be fast
enough to not cause issues for the user.

Most image filters don't even implement this like PNG and nobody
noticed for many years that this is not supported.

To handle IO_PENDING case it is probably better to load the
bitstream into memory and then load the whole image after that
in one pass. This can also be implemented all inside (Imp)Graphic
in a very straight forward way.

In addition some broken GIF files for testCVEs now fail to load
completely and those need to be moved from pass/ to fail/.

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

diff --git 
a/vcl/qa/cppunit/graphicfilter/data/gif/pass/afl-sample-short-read-1.gif 
b/vcl/qa/cppunit/graphicfilter/data/gif/fail/afl-sample-short-read-1.gif
similarity index 100%
rename from 
vcl/qa/cppunit/graphicfilter/data/gif/pass/afl-sample-short-read-1.gif
rename to vcl/qa/cppunit/graphicfilter/data/gif/fail/afl-sample-short-read-1.gif
diff --git 
a/vcl/qa/cppunit/graphicfilter/data/gif/pass/afl-sample-short-read-2.gif 
b/vcl/qa/cppunit/graphicfilter/data/gif/fail/afl-sample-short-read-2.gif
similarity index 100%
rename from 
vcl/qa/cppunit/graphicfilter/data/gif/pass/afl-sample-short-read-2.gif
rename to vcl/qa/cppunit/graphicfilter/data/gif/fail/afl-sample-short-read-2.gif
diff --git a/vcl/qa/cppunit/graphicfilter/data/gif/pass/crash-1.gif 
b/vcl/qa/cppunit/graphicfilter/data/gif/fail/crash-1.gif
similarity index 100%
rename from vcl/qa/cppunit/graphicfilter/data/gif/pass/crash-1.gif
rename to vcl/qa/cppunit/graphicfilter/data/gif/fail/crash-1.gif
diff --git a/vcl/qa/cppunit/graphicfilter/data/gif/pass/crash-2.gif 
b/vcl/qa/cppunit/graphicfilter/data/gif/fail/crash-2.gif
similarity index 100%
rename from vcl/qa/cppunit/graphicfilter/data/gif/pass/crash-2.gif
rename to vcl/qa/cppunit/graphicfilter/data/gif/fail/crash-2.gif
diff --git a/vcl/source/filter/igif/gifread.cxx 
b/vcl/source/filter/igif/gifread.cxx
index 443eb05c045a..67af603218d4 100644
--- a/vcl/source/filter/igif/gifread.cxx
+++ b/vcl/source/filter/igif/gifread.cxx
@@ -42,8 +42,7 @@ enum GIFAction
 enum ReadState
 {
 GIFREAD_OK,
-GIFREAD_ERROR,
-GIFREAD_NEED_MORE
+GIFREAD_ERROR
 };
 
 }
@@ -115,7 +114,6 @@ public:
 ReadState   ReadGIF( Graphic& rGraphic );
 boolReadIsAnimated();
 void GetLogicSize(Size& rLogicSize);
-Graphic GetIntermediateGraphic();
 
 explicitGIFReader( SvStream& rStm );
 };
@@ -261,13 +259,13 @@ bool GIFReader::ReadGlobalHeader()
 boolbRet = false;
 
 auto nRead = rIStm.ReadBytes(pBuf, 6);
-if (nRead == 6 && (rIStm.GetError() != ERRCODE_IO_PENDING))
+if (nRead == 6 && rIStm.good())
 {
 pBuf[ 6 ] = 0;
 if( !strcmp( pBuf, "GIF87a" ) || !strcmp( pBuf, "GIF89a" ) )
 {
 nRead = rIStm.ReadBytes(pBuf, 7);
-if (nRead == 7 && (rIStm.GetError() != ERRCODE_IO_PENDING))
+if (nRead == 7 && rIStm.good())
 {
 sal_uInt8   nAspect;
 sal_uInt8   nRF;
@@ -287,7 +285,7 @@ bool GIFReader::ReadGlobalHeader()
 else
 nBackgroundColor = 0;
 
-if (rIStm.GetError() != ERRCODE_IO_PENDING)
+if (rIStm.good())
 bRet = true;
 }
 }
@@ -307,7 +305,7 @@ void GIFReader::ReadPaletteEntries( BitmapPalette* pPal, 
sal_uLong nCount )
 std::unique_ptr pBuf(new sal_uInt8[ nLen ]);
 std::size_t nRead = rIStm.ReadBytes(pBuf.get(), nLen);
 nCount = nRead/3UL;
-if (rIStm.GetError() == ERRCODE_IO_PENDING)
+if (!rIStm.good())
 return;
 
 sal_uInt8* pTmp = pBuf.get();
@@ -340,7 +338,7 @@ bool GIFReader::ReadExtension()
 // Extension-Label
 sal_uInt8 cFunction(0);
 rIStm.ReadUChar( cFunction );
-if (rIStm.GetError() != ERRCODE_IO_PENDING)
+if (rIStm.good())
 {
 boolbOverreadDataBlocks = false;
 sal_uInt8 cSize(0);
@@ -358,7 +356,7 @@ bool GIFReader::ReadExtension()
 sal

core.git: vcl/qa

2024-06-18 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/data/fdo47811-1_Word2013.docx |binary
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx|   10 ++
 2 files changed, 10 insertions(+)

New commits:
commit d0c979b4baee55b4d7352f7ebab201e65d6c1fcd
Author: Michael Stahl 
AuthorDate: Mon Jun 17 19:51:02 2024 +0200
Commit: Michael Stahl 
CommitDate: Tue Jun 18 10:46:05 2024 +0200

tdf#161346 add unit test

Change-Id: I7f441a1fcf92f40678811faf26ec40eac98a7ae6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/169046
Reviewed-by: Michael Stahl 
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/fdo47811-1_Word2013.docx 
b/vcl/qa/cppunit/pdfexport/data/fdo47811-1_Word2013.docx
new file mode 100644
index ..c002b30d7c88
Binary files /dev/null and 
b/vcl/qa/cppunit/pdfexport/data/fdo47811-1_Word2013.docx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 8502a6b5593a..5ede679fcdab 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -229,6 +229,16 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf141171)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf161346)
+{
+// this crashed
+vcl::filter::PDFDocument aDocument;
+load(u"fdo47811-1_Word2013.docx", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(2), aPages.size());
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf129085)
 {
 vcl::filter::PDFDocument aDocument;


core.git: vcl/qa

2024-06-16 Thread Andrea Gelmini (via logerrit)
 0 files changed

New commits:
commit 7d93b585f5366ce22aaf174a1b463b004739f588
Author: Andrea Gelmini 
AuthorDate: Sun Jun 16 19:18:04 2024 +0200
Commit: Julien Nabet 
CommitDate: Sun Jun 16 21:30:39 2024 +0200

Remove exec bits on pdf file

Change-Id: Ia3bb4a2c100e7dccafe9710c7af3a99268e53239
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168963
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/data/Annotations_Adobe_FreeText.pdf 
b/vcl/qa/cppunit/data/Annotations_Adobe_FreeText.pdf
old mode 100755
new mode 100644


core.git: vcl/qa

2024-06-13 Thread Tomaž Vajngerl (via logerrit)
 vcl/qa/cppunit/PDFiumLibraryTest.cxx |   39 ---
 1 file changed, 9 insertions(+), 30 deletions(-)

New commits:
commit 16f990255128ec32996ea92a726ffc34d9ea2fac
Author: Tomaž Vajngerl 
AuthorDate: Thu Jun 13 14:53:51 2024 +0900
Commit: Tomaž Vajngerl 
CommitDate: Fri Jun 14 04:07:28 2024 +0200

vcl: convert PDFiumLibraryTest to CPPUNIT_TEST_FIXTURE

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

diff --git a/vcl/qa/cppunit/PDFiumLibraryTest.cxx 
b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
index 172af6829b45..d11c66bae323 100644
--- a/vcl/qa/cppunit/PDFiumLibraryTest.cxx
+++ b/vcl/qa/cppunit/PDFiumLibraryTest.cxx
@@ -28,33 +28,14 @@
 
 class PDFiumLibraryTest : public test::BootstrapFixtureBase
 {
+protected:
 OUString getFullUrl(std::u16string_view sFileName)
 {
 return m_directories.getURLFromSrc(u"/vcl/qa/cppunit/data/") + 
sFileName;
 }
-
-void testDocument();
-void testPages();
-void testPageObjects();
-void testAnnotationsMadeInEvince();
-void testAnnotationsMadeInAcrobat();
-void testAnnotationsDifferentTypes();
-void testTools();
-void testFormFields();
-
-CPPUNIT_TEST_SUITE(PDFiumLibraryTest);
-CPPUNIT_TEST(testDocument);
-CPPUNIT_TEST(testPages);
-CPPUNIT_TEST(testPageObjects);
-CPPUNIT_TEST(testAnnotationsMadeInEvince);
-CPPUNIT_TEST(testAnnotationsMadeInAcrobat);
-CPPUNIT_TEST(testAnnotationsDifferentTypes);
-CPPUNIT_TEST(testTools);
-CPPUNIT_TEST(testFormFields);
-CPPUNIT_TEST_SUITE_END();
 };
 
-void PDFiumLibraryTest::testDocument()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testDocument)
 {
 OUString aURL = getFullUrl(u"Pangram.pdf");
 SvFileStream aStream(aURL, StreamMode::READ);
@@ -81,7 +62,7 @@ void PDFiumLibraryTest::testDocument()
 CPPUNIT_ASSERT_EQUAL(792.0, aSize.getHeight());
 }
 
-void PDFiumLibraryTest::testPages()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testPages)
 {
 OUString aURL = getFullUrl(u"Pangram.pdf");
 SvFileStream aStream(aURL, StreamMode::READ);
@@ -106,7 +87,7 @@ void PDFiumLibraryTest::testPages()
 CPPUNIT_ASSERT(pPage);
 }
 
-void PDFiumLibraryTest::testPageObjects()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testPageObjects)
 {
 OUString aURL = getFullUrl(u"Pangram.pdf");
 SvFileStream aStream(aURL, StreamMode::READ);
@@ -159,7 +140,7 @@ void PDFiumLibraryTest::testPageObjects()
 CPPUNIT_ASSERT_DOUBLES_EQUAL(732.54, pPageObject->getBounds().getMaxY(), 
1E-2);
 }
 
-void PDFiumLibraryTest::testAnnotationsMadeInEvince()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testAnnotationsMadeInEvince)
 {
 OUString aURL = getFullUrl(u"PangramWithAnnotations.pdf");
 SvFileStream aStream(aURL, StreamMode::READ);
@@ -215,7 +196,7 @@ void PDFiumLibraryTest::testAnnotationsMadeInEvince()
 }
 }
 
-void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testAnnotationsMadeInAcrobat)
 {
 OUString aURL = getFullUrl(u"PangramAcrobatAnnotations.pdf");
 SvFileStream aStream(aURL, StreamMode::READ);
@@ -292,7 +273,7 @@ void PDFiumLibraryTest::testAnnotationsMadeInAcrobat()
 }
 }
 
-void PDFiumLibraryTest::testFormFields()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testFormFields)
 {
 // Given a document with a form field that looks like plain text:
 OUString aURL = getFullUrl(u"form-fields.pdf");
@@ -327,7 +308,7 @@ void PDFiumLibraryTest::testFormFields()
 CPPUNIT_ASSERT_GREATER(static_cast(1), aColors.size());
 }
 
-void PDFiumLibraryTest::testAnnotationsDifferentTypes()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testAnnotationsDifferentTypes)
 {
 OUString aURL = getFullUrl(u"PangramWithMultipleTypeOfAnnotations.pdf");
 SvFileStream aStream(aURL, StreamMode::READ);
@@ -431,7 +412,7 @@ void PDFiumLibraryTest::testAnnotationsDifferentTypes()
 }
 }
 
-void PDFiumLibraryTest::testTools()
+CPPUNIT_TEST_FIXTURE(PDFiumLibraryTest, testTools)
 {
 OUString sConverted = 
vcl::pdf::convertPdfDateToISO8601(u"D:20200612201322+02'00");
 
@@ -447,8 +428,6 @@ void PDFiumLibraryTest::testTools()
 CPPUNIT_ASSERT_EQUAL(false, bool(aDateTime.IsUTC));
 }
 
-CPPUNIT_TEST_SUITE_REGISTRATION(PDFiumLibraryTest);
-
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


core.git: vcl/qa

2024-06-13 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf160401.pptx |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |   32 +++
 2 files changed, 32 insertions(+)

New commits:
commit 96f22f5e5302e030fcbc939ef94b7c1fd2748df2
Author: Xisco Fauli 
AuthorDate: Thu Jun 13 13:18:59 2024 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jun 13 15:28:10 2024 +0200

tdf#160401: vcl_pdfexport: Add unittest

Change-Id: I92649734bad553d07e0b37d80f804638aacd89fa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168780
Reviewed-by: Xisco Fauli 
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf160401.pptx 
b/vcl/qa/cppunit/pdfexport/data/tdf160401.pptx
new file mode 100644
index ..7da2c7a10891
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf160401.pptx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 50a4f7041017..054496ee4895 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1258,6 +1258,38 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf150846)
 CPPUNIT_ASSERT_EQUAL(u"hello"_ustr, aActualText);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf160401)
+{
+aMediaDescriptor[u"FilterName"_ustr] <<= u"impress_pdf_Export"_ustr;
+saveAsPDF(u"tdf160401.pptx");
+
+// Parse the export result with pdfium.
+std::unique_ptr pPdfDocument = parsePDFExport();
+
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage);
+
+std::unique_ptr pPdfTextPage = 
pPdfPage->getTextPage();
+CPPUNIT_ASSERT(pPdfTextPage);
+
+int nChars = pPdfTextPage->countChars();
+
+CPPUNIT_ASSERT_EQUAL(16, nChars);
+
+std::vector aChars(nChars);
+for (int i = 0; i < nChars; i++)
+aChars[i] = pPdfTextPage->getUnicode(i);
+OUString aActualText(aChars.data(), aChars.size());
+
+// Without the fix in place, this test would have failed with
+// - Expected: אאא בבב
+// אאא בבב
+// - Actual  : אאא בבב
+// בבב אאא
+CPPUNIT_ASSERT_EQUAL(u"אאא בבב
אאא בבב"_ustr, aActualText);
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf103492)
 {
 // Import the bugdoc and export as PDF.


core.git: vcl/qa

2024-05-23 Thread Michael Weghorn (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 87c41bbf04c361746bf9c2373aa144a02d971303
Author: Michael Weghorn 
AuthorDate: Fri May 24 06:21:30 2024 +0200
Commit: Michael Weghorn 
CommitDate: Fri May 24 08:44:29 2024 +0200

gtk3 a11y tests: Increase timeout for AT-SPI method calls

As discussed in the ESC call of 2024-05-23,
CppunitTest_vcl_gtk3_a11y fails relatively often recently:

> 38 CppunitTest_vcl_gtk3_a11ygerrit_linux_clang_dbgutil
>+ this week: have a new problem with CppunitTest_vcl_gtk3_a11y (Cloph)
>  + failure is not new, but the frequency increased recently
>  + assume: timing issue

Jenkins logs show that failures are due to running into
timeouts, example from [1]:

[...]
found run attribute: CharTopBorder=
found run attribute: CharTopBorderComplexColor=
found run attribute: MMToPixelRatio=
  matching atspi attribute is: mm-to-pixel-ratio=1.25
unknown:0:Test1::TestBody
An uncaught exception of type com.sun.star.uno.RuntimeException
- timeout from dbind at 
/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx:302

Increase the timeout for method calls from 2.5 to 10 seconds
in the hope that will help.
(Issue is not reproducible locally for me.)

[1] 
https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/162811/consoleFull

Change-Id: Ib0eef753cf9f574ee5b2a013a46a0a600c91eb34
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168002
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx 
b/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx
index bcde764aa981..a0ac926c719d 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx
@@ -80,8 +80,8 @@ public:
 if (!atspi_is_initialized())
 atspi_init();
 
-// increase timeout to avoid spurious avoid CI failures
-atspi_set_timeout(2500, 15000);
+// increase timeout to avoid spurious CI failures
+atspi_set_timeout(1, 15000);
 }
 
 virtual void setUp() override


core.git: vcl/qa

2024-05-09 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/svm/svmtest.cxx |   25 +
 1 file changed, 21 insertions(+), 4 deletions(-)

New commits:
commit b009ffb1620bb7a51f027c0f7fbc3ea9297cef69
Author: Caolán McNamara 
AuthorDate: Wed May 8 20:46:15 2024 +0100
Commit: Caolán McNamara 
CommitDate: Thu May 9 09:29:50 2024 +0200

update crcs for --enable-cairo-rgba case

Change-Id: If0588a018564a708361b0246b294520ac5d2d1db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167368
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index d339e80b2fa3..1b5db975e2f2 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -33,6 +33,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -943,7 +944,11 @@ void SvmTest::checkBitmaps(const GDIMetaFile& rMetaFile)
 #if defined OSL_BIGENDIAN
 "5e01ddcc"
 #else
-"469f0820"
+#if !ENABLE_CAIRO_RGBA
+"469f0820"  // typical BGRA little-endian config
+#else
+"3789377b"  // atypical RGBA little-endian config
+#endif
 #endif
 }});
 assertXPathAttrs(pDoc, "/metafile/bmpscale[1]"_ostr, {
@@ -956,7 +961,11 @@ void SvmTest::checkBitmaps(const GDIMetaFile& rMetaFile)
 #if defined OSL_BIGENDIAN
  "b8dee5da"
 #else
- "3789377b"
+#if !ENABLE_CAIRO_RGBA
+ "3789377b"  // typical BGRA little-endian config
+#else
+ "469f0820"  // atypical RGBA little-endian config
+#endif
 #endif
 }
 });
@@ -1018,9 +1027,17 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& 
rMetaFile, bool bIsSvmFile)
 "33b4a07c",
 "742c3e35",
 #else
-"ac936607",
+#if !ENABLE_CAIRO_RGBA
+"ac936607", // typical BGRA little-endian config
+#else
+"ecd75a28", // atypical RGBA little-endian config
+#endif
 "4937e32d",
-"3789377b",
+#if !ENABLE_CAIRO_RGBA
+"3789377b", // typical BGRA little-endian config
+#else
+"469f0820", // atypical RGBA little-endian config
+#endif
 "839e8cce",
 "236aaf55", // 1-bit
 "2949ccc7", // 4-bit color bitmap - same as 8-bit color bitmap


core.git: vcl/qa

2024-04-30 Thread Mike Kaganski (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |  250 
 1 file changed, 125 insertions(+), 125 deletions(-)

New commits:
commit 41e5b9d32f8914e3f0159f064e46c362d55b6ccd
Author: Mike Kaganski 
AuthorDate: Tue Apr 30 09:14:55 2024 +0200
Commit: Mike Kaganski 
CommitDate: Tue Apr 30 10:37:02 2024 +0200

Remove some syntactic noise

Use of auto num(0) together with decltype(1) is overkill,
when the language explicitly specifies these literals to be int.

Also, change static_casts on literals into function-style cast.

And make some comparisong use CPPUNIT_ASSERT_GREATEREQUAL.

Change-Id: I3af7231a997a4611b564b38facd15a3a6bb76cdf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166893
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index ccaab1d5c9bf..96e34cc8c208 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -100,7 +100,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf124272)
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
-CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), aPages.size());
 
 // The page has a stream.
 vcl::filter::PDFObjectElement* pContents = 
aPages[0]->LookupObject("Contents"_ostr);
@@ -133,7 +133,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf121615)
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
-CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), aPages.size());
 
 // Get access to the only image on the only page.
 vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources"_ostr);
@@ -141,7 +141,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf121615)
 auto pXObjects
 = 
dynamic_cast(pResources->Lookup("XObject"_ostr));
 CPPUNIT_ASSERT(pXObjects);
-CPPUNIT_ASSERT_EQUAL(static_cast(1), pXObjects->GetItems().size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), pXObjects->GetItems().size());
 vcl::filter::PDFObjectElement* pXObject
 = pXObjects->LookupObject(pXObjects->GetItems().begin()->first);
 CPPUNIT_ASSERT(pXObject);
@@ -181,7 +181,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf141171)
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
-CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), aPages.size());
 
 // Get access to the only image on the only page.
 vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources"_ostr);
@@ -189,7 +189,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf141171)
 auto pXObjects
 = 
dynamic_cast(pResources->Lookup("XObject"_ostr));
 CPPUNIT_ASSERT(pXObjects);
-CPPUNIT_ASSERT_EQUAL(static_cast(1), pXObjects->GetItems().size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), pXObjects->GetItems().size());
 vcl::filter::PDFObjectElement* pXObject
 = pXObjects->LookupObject(pXObjects->GetItems().begin()->first);
 CPPUNIT_ASSERT(pXObject);
@@ -236,7 +236,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf129085)
 
 // The document has one page.
 std::vector aPages = aDocument.GetPages();
-CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), aPages.size());
 
 // Get access to the only image on the only page.
 vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources"_ostr);
@@ -246,7 +246,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf129085)
 
 // Without the fix in place, this test would have failed here
 CPPUNIT_ASSERT(pXObjects);
-CPPUNIT_ASSERT_EQUAL(static_cast(1), pXObjects->GetItems().size());
+CPPUNIT_ASSERT_EQUAL(size_t(1), pXObjects->GetItems().size());
 vcl::filter::PDFObjectElement* pXObject
 = pXObjects->LookupObject(pXObjects->GetItems().begin()->first);
 CPPUNIT_ASSERT(pXObject);
@@ -700,7 +700,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMultiPagePDF)
 load(u"SimpleMultiPagePDF.pdf", aDocument);
 
 std::vector aPages = aDocument.GetPages();
-CPPUNIT_ASSERT_EQUAL(static_cast(3), aPages.size());
+CPPUNIT_ASSERT_EQUAL(size_t(3), aPages.size());
 
 vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources"_ostr);
 CPPUNIT_ASSERT(pResources);
@@ -709,7 +709,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testMultiPagePDF)
 = 
dynamic_cast(pResources->Lookup("XObject"_ostr));
 CPPUNIT_ASSERT(pXObjects);
 
-CPPUNIT_ASSERT_EQUAL(static_cast(3),
+CPPUNIT_ASSERT_EQUAL(size_t(3),
  pXObjects->GetItems().size()); // 3 PDFs as Form 
XObjects
 
 std::vector rIDs;
@@ -1055,7 +1055,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf160117)
 
 // The document has one p

core.git: vcl/qa vcl/source

2024-04-24 Thread Patrick Luby (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |6 +-
 vcl/source/gdi/pdfwriter_impl.cxx   |   14 ++
 2 files changed, 15 insertions(+), 5 deletions(-)

New commits:
commit 4b31f87e918c38a7eb30ceb85563a5c98b426da5
Author: Patrick Luby 
AuthorDate: Mon Apr 22 19:36:14 2024 -0400
Commit: Patrick Luby 
CommitDate: Wed Apr 24 20:17:56 2024 +0200

tdf#160714 use crop box for bounds of embedded PDF object

If there is no crop box, fallback to the media box just to be safe.

Change-Id: I29f99a43e550cf09a1534c0aa01ffd6a55536fb7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166544
Tested-by: Jenkins
Reviewed-by: Patrick Luby 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 525f1d91a449..ccaab1d5c9bf 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -45,6 +45,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 
@@ -4627,7 +4628,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, 
testRexportMediaBoxOrigin)
 = { // Rotation by $   heta$ $cos( heta), sin( heta), -sin(
heta), cos( heta)$
 0, -1, 1, 0,
 // Translate x,y
--aOrigin[1] - aSize[1] / 2 + aSize[0] / 2, aOrigin[0] + aSize[0] / 
2 + aSize[1] / 2
+-aOrigin[1] - aSize[1] / vcl::PDF_INSERT_MAGIC_SCALE_FACTOR / 2
++ aSize[0] / vcl::PDF_INSERT_MAGIC_SCALE_FACTOR / 2,
+aOrigin[0] + aSize[0] / vcl::PDF_INSERT_MAGIC_SCALE_FACTOR / 2
++ aSize[1] / vcl::PDF_INSERT_MAGIC_SCALE_FACTOR / 2
   };
 
 for (sal_Int32 nIdx = 0; nIdx < 6; ++nIdx)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index d780b0c4f88e..cf5a5fc39546 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9124,9 +9124,15 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 }
 
 double aOrigin[2] = { 0.0, 0.0 };
-if (auto* pArray = 
dynamic_cast(pPage->Lookup("MediaBox"_ostr)))
+
+// tdf#160714 use crop box for bounds of embedded PDF object
+// If there is no crop box, fallback to the media box just to be safe.
+auto* pBoundsArray = 
dynamic_cast(pPage->Lookup("CropBox"_ostr));
+if (!pBoundsArray)
+pBoundsArray = 
dynamic_cast(pPage->Lookup("MediaBox"_ostr));
+if (pBoundsArray)
 {
-const auto& rElements = pArray->GetElements();
+const auto& rElements = pBoundsArray->GetElements();
 if (rElements.size() >= 4)
 {
 // get x1, y1 of the rectangle.
@@ -9239,9 +9245,9 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 // Now transform the object: rotate around the center and make 
sure that the rotation
 // doesn't affect the aspect ratio.
 basegfx::B2DHomMatrix aMat;
-aMat.translate(-0.5 * aBBox.getWidth() - aOrigin[0], -0.5 * 
aBBox.getHeight() - aOrigin[1]);
+aMat.translate((-0.5 * aBBox.getWidth() / fMagicScaleFactor) - 
aOrigin[0], (-0.5 * aBBox.getHeight() / fMagicScaleFactor) - aOrigin[1]);
 aMat.rotate(basegfx::deg2rad(nAngle));
-aMat.translate(0.5 * nWidth, 0.5 * nHeight);
+aMat.translate(0.5 * nWidth / fMagicScaleFactor, 0.5 * nHeight / 
fMagicScaleFactor);
 
 aLine.append(" /Matrix [ ");
 aLine.append(aMat.a());


core.git: vcl/qa vcl/source

2024-04-22 Thread Noel Grandin (via logerrit)
 vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx |   12 ++--
 vcl/source/filter/webp/reader.cxx  |4 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit c503b6eef32055f75dc9cf761bd20eda4f161dd4
Author: Noel Grandin 
AuthorDate: Mon Apr 22 14:52:32 2024 +0200
Commit: Noel Grandin 
CommitDate: Mon Apr 22 21:24:17 2024 +0200

tdf#160431 Inverts webp file image when inserted

regression from
commit 81994cb2b8b32453a92bcb011830fcb884f22ff3
Author: Noel Grandin 
Date:   Fri Apr 16 20:33:10 2021 +0200
Convert internal vcl bitmap formats transparency->alpha (II)

Change-Id: I3b2959c99a2e18c3972920f8ca86072566d54225
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/166450
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx 
b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
index d3c43f48191f..cbc23315ca30 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
@@ -141,10 +141,10 @@ void WebpFilterTest::testRoundtrip(bool lossy)
 }
 AlphaMask tmpAlpha = aResultBitmap.GetAlphaMask();
 BitmapScopedReadAccess pAccessAlpha(tmpAlpha);
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 0));
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 19));
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(19, 0));
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(64), pAccessAlpha->GetPixelIndex(19, 
19));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(0, 
0));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(0, 
19));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), pAccessAlpha->GetPixelIndex(19, 
0));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(191), pAccessAlpha->GetPixelIndex(19, 
19));
 }
 
 aStream.Seek(STREAM_SEEK_TO_BEGIN);
@@ -192,8 +192,8 @@ void WebpFilterTest::testRead(std::u16string_view rName, 
bool lossy, bool alpha)
 {
 AlphaMask tmpAlpha = aResultBitmap.GetAlphaMask();
 BitmapScopedReadAccess pAccessAlpha(tmpAlpha);
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 
0));
-CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), 
pAccessAlpha->GetPixelIndex(0, 9));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(255), 
pAccessAlpha->GetPixelIndex(0, 0));
+CPPUNIT_ASSERT_EQUAL(sal_uInt8(0), pAccessAlpha->GetPixelIndex(0, 
9));
 }
 }
 }
diff --git a/vcl/source/filter/webp/reader.cxx 
b/vcl/source/filter/webp/reader.cxx
index 61af0d3c0241..a5ff3aaca916 100644
--- a/vcl/source/filter/webp/reader.cxx
+++ b/vcl/source/filter/webp/reader.cxx
@@ -241,7 +241,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic)
 for (tools::Long x = 0; x < access->Width(); ++x)
 {
 memcpy(dstB, src, 3);
-*dstA = 255 - *(src + 3);
+*dstA = *(src + 3);
 src += 4;
 dstB += 3;
 dstA += 1;
@@ -273,7 +273,7 @@ static bool readWebp(SvStream& stream, Graphic& graphic)
 for (tools::Long x = 0; x < accessAlpha->Width(); ++x)
 {
 sal_uInt8 a = src[3];
-accessAlpha->SetPixelIndex(y, x, 255 - a);
+accessAlpha->SetPixelIndex(y, x, a);
 src += 4;
 }
 }


core.git: vcl/qa

2024-03-30 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/GraphicMemoryTest.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c9d4f99b2bb54ac7735b3e0d0cadbafbd0279518
Author: Andrea Gelmini 
AuthorDate: Sat Mar 30 17:06:54 2024 +0100
Commit: Julien Nabet 
CommitDate: Sat Mar 30 21:24:58 2024 +0100

Fix typo in code

Change-Id: I6babc5ec476a27fcecb582466183f999cf56757b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165577
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/GraphicMemoryTest.cxx 
b/vcl/qa/cppunit/GraphicMemoryTest.cxx
index 95e64e471246..80c8619508fe 100644
--- a/vcl/qa/cppunit/GraphicMemoryTest.cxx
+++ b/vcl/qa/cppunit/GraphicMemoryTest.cxx
@@ -148,7 +148,7 @@ CPPUNIT_TEST_FIXTURE(GraphicMemoryTest, 
testMemoryManager_Unloaded)
 CPPUNIT_ASSERT_EQUAL(sal_uLong(9), aGraphic_300.GetSizeBytes());
 }
 
-CPPUNIT_TEST_FIXTURE(GraphicMemoryTest, testMemoryManager_Destrucion)
+CPPUNIT_TEST_FIXTURE(GraphicMemoryTest, testMemoryManager_Destruction)
 {
 auto& rManager = vcl::graphic::MemoryManager::get();
 CPPUNIT_ASSERT_EQUAL(size_t(0), rManager.getManagedObjects().size());


core.git: vcl/qa

2024-03-22 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf160117.ods |binary
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |   42 
 2 files changed, 42 insertions(+)

New commits:
commit c6518dc58f76ad9b59a61dd3736abd62acc5fc57
Author: Xisco Fauli 
AuthorDate: Thu Mar 21 12:36:24 2024 +0100
Commit: Xisco Fauli 
CommitDate: Fri Mar 22 10:10:33 2024 +0100

tdf#160117: vcl_pdfexport2: Add unittest

Change-Id: I5b10d92d1ba4d62a8a0b4e2d8b0f023b58225fb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165098
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf160117.ods 
b/vcl/qa/cppunit/pdfexport/data/tdf160117.ods
new file mode 100644
index ..ed18444e7b8d
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf160117.ods differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index 061b79e488cb..525f1d91a449 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -1047,6 +1047,48 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReexportPDF)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf160117)
+{
+vcl::filter::PDFDocument aDocument;
+load(u"tdf160117.ods", aDocument);
+
+// The document has one page.
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+
+int nCount = 0;
+bool bFound1 = false;
+bool bFound2 = false;
+bool bFound3 = false;
+for (const auto& rDocElement : aDocument.GetElements())
+{
+auto pObject = 
dynamic_cast(rDocElement.get());
+if (!pObject)
+continue;
+auto pType = 
dynamic_cast(pObject->Lookup("Type"_ostr));
+if (pType && pType->GetValue() == "FontDescriptor")
+{
+auto pFontName
+= 
dynamic_cast(pObject->Lookup("FontName"_ostr));
+CPPUNIT_ASSERT(pFontName);
+if ("CA+LiberationSans-Bold"_ostr == pFontName->GetValue())
+bFound1 = true;
+else if ("DA+LiberationSans-Italic"_ostr == 
pFontName->GetValue())
+bFound2 = true;
+else if ("BA+LiberationSans"_ostr == pFontName->GetValue())
+bFound3 = true;
+++nCount;
+}
+}
+// Without the fix in place, this test would have failed with
+// - Expected: 3
+// - Actual  : 2
+CPPUNIT_ASSERT_EQUAL(3, nCount);
+CPPUNIT_ASSERT(bFound1);
+CPPUNIT_ASSERT(bFound2);
+CPPUNIT_ASSERT(bFound3);
+}
+
 // Check we correctly copy more complex resources (Fonts describing
 // glyphs in recursive arrays) to the target PDF
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testReexportDocumentWithComplexResources)


core.git: vcl/qa writerfilter/source

2024-03-08 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf142133.docx  |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   35 ++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx |   23 --
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |3 +
 4 files changed, 52 insertions(+), 9 deletions(-)

New commits:
commit b56678ae967bb1e09b52930a0b1d59a5e68bb7be
Author: Xisco Fauli 
AuthorDate: Fri Mar 8 14:23:08 2024 +0100
Commit: Xisco Fauli 
CommitDate: Fri Mar 8 21:09:31 2024 +0100

tdf#142133: partially revert 576611895e5

if 'Internet Link' character style doens't exist then
apply the hyperlink style
This also reverts 023285158bde72dcd73b965ce205cf8550e7a5e2
"tdf#128504 save DOCX as ODT: don't color not highlighted hyperlinks"
which is no longer necessary

Change-Id: Id100af5fddb10745af9d56c0ba75cb2366ecbe55
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164576
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf142133.docx 
b/vcl/qa/cppunit/pdfexport/data/tdf142133.docx
new file mode 100644
index ..fa1e155b873e
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf142133.docx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index d362a3855303..e9a8530c3cce 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2740,6 +2740,41 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link)
 CPPUNIT_ASSERT_EQUAL(static_cast(4), 
pAnnots->GetElements().size());
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142133)
+{
+vcl::filter::PDFDocument aDocument;
+load(u"tdf142133.docx", aDocument);
+
+// The document has one page.
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+
+auto pAnnots = 
dynamic_cast(aPages[0]->Lookup("Annots"_ostr));
+CPPUNIT_ASSERT(pAnnots);
+
+// There should be one annotation
+CPPUNIT_ASSERT_EQUAL(static_cast(1), 
pAnnots->GetElements().size());
+auto pAnnotReference
+= 
dynamic_cast(pAnnots->GetElements()[0]);
+CPPUNIT_ASSERT(pAnnotReference);
+vcl::filter::PDFObjectElement* pAnnot = pAnnotReference->LookupObject();
+CPPUNIT_ASSERT(pAnnot);
+// We're expecting something like /Type /Annot /A << /Type /Action /S /URI 
/URI (path)
+CPPUNIT_ASSERT_EQUAL(
+"Annot"_ostr,
+
static_cast(pAnnot->Lookup("Type"_ostr))->GetValue());
+CPPUNIT_ASSERT_EQUAL(
+"Link"_ostr,
+
static_cast(pAnnot->Lookup("Subtype"_ostr))->GetValue());
+auto pAction = 
dynamic_cast(pAnnot->Lookup("A"_ostr));
+CPPUNIT_ASSERT(pAction);
+auto pURIElem
+= 
dynamic_cast(pAction->LookupElement("URI"_ostr));
+CPPUNIT_ASSERT(pURIElem);
+// Check it matches
+CPPUNIT_ASSERT_EQUAL("https://google.com/"_ostr, pURIElem->GetValue());
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806)
 {
 aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index bbdfbd35c34a..f4943c60c88c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3304,6 +3304,15 @@ void 
DomainMapper_Impl::MergeAtContentImageRedlineWithNext(const css::uno::Refer
 }
 else
 {
+if (IsOpenField() && GetTopFieldContext()->GetFieldId() == 
FIELD_HYPERLINK)
+{
+// It is content of hyperlink field. We need to create and 
remember
+// character style for later applying to hyperlink
+PropertyValueVector_t aProps = 
comphelper::sequenceToContainer< PropertyValueVector_t 
>(GetTopContext()->GetPropertyValues());
+OUString sHyperlinkStyleName = 
GetStyleSheetTable()->getOrCreateCharStyle(aProps, /*bAlwaysCreate=*/false);
+
GetTopFieldContext()->SetHyperlinkStyle(sHyperlinkStyleName);
+}
+
 #if !defined(MACOSX) // TODO: check layout differences and support all 
platforms, if needed
 sal_Int32 nPos = 0;
 OUString sFontName;
@@ -8787,25 +8796,21 @@ void DomainMapper_Impl::PopFieldContext()
 
xCrsrProperties->setPropertyValue("VisitedCharStyleName",uno::Any(sDisplayName));
 
xCrsrProperties->setPropertyValue("UnvisitedCharStyleName",uno::Any(sDisplayName));
 }
-else
+else if 
(!pContext->GetHyperlinkStyle().isEmpty())
 {
 uno::Any aAny = 
xCrsrProperties->getPropertyValue("CharStyleName");
 

core.git: vcl/qa vcl/source

2024-03-04 Thread Noel Grandin (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf159817.fodt |  607 +++
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx  |   56 ++
 vcl/source/control/button.cxx|6 
 vcl/source/control/combobox.cxx  |9 
 vcl/source/window/tabpage.cxx|5 
 5 files changed, 675 insertions(+), 8 deletions(-)

New commits:
commit b03f1dfb15a67641bc516a1c6b5632857451a18d
Author: Noel Grandin 
AuthorDate: Sun Mar 3 17:11:39 2024 +0200
Commit: Noel Grandin 
CommitDate: Mon Mar 4 09:27:07 2024 +0100

tdf#159817 tdf#159802 Form controls coordinates wrong when export to pdf

This reverts the following commits:
d408fe5cd45c9594feecec727ab2f73c66e361d0 "unnecessary LogicToPixel in 
CheckBox::Draw"
7441aaa4c5b2215e369c62e22af098184e8ce807 "unnecessary LogicToPixel in 
RadioButton::Draw"
a2dacae0c8acfad8a5e5a16c766ee740ec202c5e "unnecessary LogicToPixel in 
ComboBox::Draw"
f73e8c895e24fda10931ecf344a1a0dd8bcdf92c "unnecessary LogicToPixel in 
TabPage::Draw"

I am fairly sure this code that I am restoring is dodgy,
and I am just papering over some other bug somewhere, but
I can't seem to see where that is.

Change-Id: I0f9088e43b0e3af74fd5ff9d297008ee23a3facb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164313
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf159817.fodt 
b/vcl/qa/cppunit/pdfexport/data/tdf159817.fodt
new file mode 100644
index ..6aa986bdc6ad
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf159817.fodt
@@ -0,0 +1,607 @@
+
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:formx="u
 rn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:ooo="http:/
 /openoffice.org/2004/office" 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ LibreOfficeDev/24.8.0.0.alpha0$MacOSX_AARCH64 
LibreOffice_project/d8978a8c4ffabd6b36a691fd3e2df685638082342003-10-02T15:57:292024-03-03T15:16:09.338790904880P124DT12H36M25S2024-02-21T10:01:49.80100Fichiers
 PDF
+ 
+  
+   0
+   0
+   20717
+   10631
+   false
+   false
+   
+
+ view2
+ 11534
+ 5101
+ 0
+ 0
+ 20715
+ 10629
+ 0
+ 1
+ false
+ 140
+ false
+ false
+ false
+ true
+ false
+ false
+
+   
+  
+  
+   0
+   true
+   false
+   false
+   false
+   true
+   false
+   true
+   false
+   
+   true
+   false
+   false
+   false
+   false
+   true
+   false
+   false
+   0
+   false
+   false
+   false
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   true
+   false
+   449756
+   true
+   true
+   true
+   false
+   false
+   false
+   false
+   false
+   false
+   false
+   true
+   true
+   false
+   false
+   true
+   false
+   20255833
+   false
+   false
+   false
+   false
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   true
+   false
+   
+   true
+   false
+   false
+   false
+   true
+   false
+   false
+  

core.git: vcl/qa vcl/unx

2023-12-19 Thread Michael Weghorn (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspi2.cxx |   11 +++
 vcl/unx/gtk3/a11y/atklistener.cxx |2 +-
 vcl/unx/gtk3/a11y/atkwrapper.cxx  |   12 
 vcl/unx/gtk3/a11y/atkwrapper.hxx  |2 +-
 4 files changed, 17 insertions(+), 10 deletions(-)

New commits:
commit a30f8ee1121aa2448be047f104a099b3272e6bde
Author: Michael Weghorn 
AuthorDate: Mon Nov 13 11:45:06 2023 +0100
Commit: Michael Weghorn 
CommitDate: Tue Dec 19 22:33:22 2023 +0100

tdf#123864 gtk3 a11y: Consider states when mapping BUTTON_DROPDOWN

Take the checkable state into account when mapping the
`AccessibleRole::BUTTON_DROPDOWN` role.

There is no direct ATK equivalent for
`AccessibleRole::BUTTON_DROPDOWN`.
Don't always use ATK_ROLE_PUSH_BUTTON, but
use ATK_ROLE_TOGGLE_BUTTON when the button is CHECKABLE,
i.e. it can be toggled.

With this in place, Orca now announces the state of
the underline button (on/off) when using the gtk3
VCL plugin.

Related Orca source code that requires the toggle button
role: [1]

The state is not announced when using the qt6 VCL
plugin yet, and Qt currently doesn't have a toggle button
role, so that would have to be added there first to
do something similar there.

For gtk4, mapping could probably be done similarly,
but more is missing for Orca to announce things in
custom widgets (e.g. event handling),
so leave that for later.

[1] 
https://gitlab.gnome.org/GNOME/orca/-/blob/b80bb951a651f5f12a5ddfb2a5b1c151568d045b/src/orca/scripts/apps/soffice/speech_generator.py#L177

Change-Id: If69e08d2e4939cc709d44e89cc2fd1d01691a70b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160904
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx 
b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
index e24bf8078613..04d885d623c3 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
@@ -25,7 +25,7 @@
 using namespace css;
 
 // from gtk3/a11y/atkwrapper.cxx
-static AtspiRole mapToAtspiRole(sal_Int16 nRole)
+static AtspiRole mapToAtspiRole(sal_Int16 nRole, sal_Int64 nStates)
 {
 switch (nRole)
 {
@@ -103,7 +103,6 @@ static AtspiRole mapToAtspiRole(sal_Int16 nRole)
 MAP_DIRECT(TREE);
 MAP(VIEW_PORT, VIEWPORT);
 MAP_DIRECT(WINDOW);
-MAP(BUTTON_DROPDOWN, PUSH_BUTTON);
 #if ATSPI_ROLE_COUNT > 130 /* ATSPI_ROLE_PUSH_BUTTON_MENU is 129 */
 MAP(BUTTON_MENU, PUSH_BUTTON_MENU);
 #else
@@ -130,7 +129,10 @@ static AtspiRole mapToAtspiRole(sal_Int16 nRole)
 
 #undef MAP_DIRECT
 #undef MAP
-
+case css::accessibility::AccessibleRole::BUTTON_DROPDOWN:
+if (nStates & css::accessibility::AccessibleStateType::CHECKABLE)
+return ATSPI_ROLE_TOGGLE_BUTTON;
+return ATSPI_ROLE_PUSH_BUTTON;
 default:
 SAL_WARN("vcl.gtk", "Unmapped accessible role: " << nRole);
 return ATSPI_ROLE_UNKNOWN;
@@ -265,7 +267,8 @@ void Atspi2TestTree::compareObjects(const 
uno::ReferencegetAccessibleRole());
+const AtspiRole nLORole
+= mapToAtspiRole(xLOContext->getAccessibleRole(), 
xLOContext->getAccessibleStateSet());
 const auto nAtspiRole = pAtspiAccessible.getRole();
 CPPUNIT_ASSERT_EQUAL(nLORole, nAtspiRole);
 /* name (no need to worry about debugging suffixes as 
AccessibilityTools::nameEquals does, as
diff --git a/vcl/unx/gtk3/a11y/atklistener.cxx 
b/vcl/unx/gtk3/a11y/atklistener.cxx
index 3ba088c8..f647c52a5c36 100644
--- a/vcl/unx/gtk3/a11y/atklistener.cxx
+++ b/vcl/unx/gtk3/a11y/atklistener.cxx
@@ -630,7 +630,7 @@ void AtkListener::notifyEvent( const 
accessibility::AccessibleEventObject& aEven
 case accessibility::AccessibleEventId::ROLE_CHANGED:
 {
 uno::Reference< accessibility::XAccessibleContext > xContext = 
getAccessibleContextFromSource( aEvent.Source );
-atk_object_wrapper_set_role( mpWrapper, 
xContext->getAccessibleRole() );
+atk_object_wrapper_set_role(mpWrapper, 
xContext->getAccessibleRole(), xContext->getAccessibleStateSet());
 break;
 }
 
diff --git a/vcl/unx/gtk3/a11y/atkwrapper.cxx b/vcl/unx/gtk3/a11y/atkwrapper.cxx
index 49b1d371ae12..c946a6e3daaf 100644
--- a/vcl/unx/gtk3/a11y/atkwrapper.cxx
+++ b/vcl/unx/gtk3/a11y/atkwrapper.cxx
@@ -167,7 +167,7 @@ AtkStateType mapAtkState( sal_Int64 nState )
 return type;
 }
 
-static AtkRole mapToAtkRole( sal_Int16 nRole )
+static AtkRole mapToAtkRole(sal_Int16 nRole, sal_Int64 nStates)
 {
 switch (nRole)
 {
@@ -310,7 +310,11 @@ static AtkRole mapToAtkRole( sal_Int16 nRole )
 case accessibility::AccessibleRole::WINDOW:
 return ATK_ROLE_WINDOW;
 case accessibility::AccessibleRole::BUTTON_DROPDOWN:
+{
+if (nStates & css::accessibility::AccessibleStateType::CHECKABLE)
+r

core.git: vcl/qa

2023-12-17 Thread Rene Engelhard (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspi2.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e7f298e8e35935de86ea0373fa68eabc343ee091
Author: Rene Engelhard 
AuthorDate: Sun Dec 17 12:38:11 2023 +0100
Commit: Michael Weghorn 
CommitDate: Sun Dec 17 19:45:17 2023 +0100

fix 32 bit build


/home/rene/LibreOffice/git/libreoffice-24-2/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx:
 In static member function 'static void Atspi2TestTree::compareObjects(const 
com::sun::star::uno::Reference&, 
const Atspi::Accessible&, sal_uInt16)':

/home/rene/LibreOffice/git/libreoffice-24-2/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx:362:9:
 error: no matching function for call to 'assertEquals(const long int&, int, 
CppUnit::SourceLine, const char [1])'
  362 | CPPUNIT_ASSERT_EQUAL(nLOTargetsCount, 
pAtspiRelation.getNTargets());
  | ^
/usr/include/cppunit/TestAssert.h:161:6: note: candidate: 'template void CppUnit::assertEquals(const T&, const T&, SourceLine, const 
std::string&)'
  161 | void assertEquals( const T& expected,
  |  ^~~~
/usr/include/cppunit/TestAssert.h:161:6: note:   template argument 
deduction/substitution failed:

/home/rene/LibreOffice/git/libreoffice-24-2/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx:362:9:
 note:   deduced conflicting types for parameter 'const T' ('long int' and 
'int')
  362 | CPPUNIT_ASSERT_EQUAL(nLOTargetsCount, 
pAtspiRelation.getNTargets());
  | ^
make: *** 
[/home/rene/LibreOffice/git/libreoffice-24-2/solenv/gbuild/LinkTarget.mk:340: 
/home/rene/LibreOffice/git/libreoffice-24-2/workdir/CxxObject/vcl/qa/cppunit/a11y/atspi2/atspi2.o]
 Error 1

Change-Id: I7b7e3e756b135d1066af631e92738e7dfc1ede4a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160882
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx 
b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
index 85110eeddecb..7ef2efeca0ef 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
@@ -359,7 +359,7 @@ void Atspi2TestTree::compareObjects(const 
uno::Reference(pAtspiRelation.getNTargets()));
 
 if (recurseFlags & RecurseFlags::RELATIONS_TARGETS)
 {


core.git: vcl/qa

2023-12-10 Thread Rene Engelhard (via logerrit)
 vcl/qa/cppunit/complextext.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 94d0cf4d4e308627922c4afb5e38523ea4f6af37
Author: Rene Engelhard 
AuthorDate: Sat Dec 9 09:30:22 2023 +0100
Commit: René Engelhard 
CommitDate: Sun Dec 10 09:05:54 2023 +0100

add missing #if MORE_FONTS

since it nededs Source Han Sans since 
9b5964cf5931d7c09e4fd624d68595891c2afb58

Change-Id: I35bd30048b298e8cbdaf6de22ae2022d51415aa9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160512
Tested-by: Jenkins
Reviewed-by: Chris Sherlock 
Reviewed-by: René Engelhard 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 37f4fbc0766c..8a847def8763 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -529,6 +529,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, 
testMixedCJKLatinScript_glyph_advanceme
 
 CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718)
 {
+#if HAVE_MORE_FONTS
 #if !defined _WIN32 // TODO: Fails on jenkins but passes locally
 vcl::Font aFont(u"Source Han Sans"_ustr, u"Regular"_ustr, Size(0, 72));
 
@@ -574,6 +575,7 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718)
 CPPUNIT_ASSERT_EQUAL(3, nStart);
 }
 #endif
+#endif
 }
 
 CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107612)


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

2023-12-05 Thread Chris Sherlock (via logerrit)
 vcl/qa/cppunit/complextext.cxx |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 9b5964cf5931d7c09e4fd624d68595891c2afb58
Author: Chris Sherlock 
AuthorDate: Tue Nov 14 02:13:17 2023 +1100
Commit: Tomaž Vajngerl 
CommitDate: Tue Dec 5 14:23:50 2023 +0100

vcl: add unit test for cached glyphs based on tdf#103492

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

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index d4eb3db67093..37f4fbc0766c 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -191,6 +191,8 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testCaching)
 testCachedGlyphs( "test", "Dejavu Sans" );
 // This font does not have latin characters, will need fallback.
 testCachedGlyphs( "test", "Noto Kufi Arabic" );
+// see tdf#103492
+testCachedGlyphs( u"يوسف My name is"_ustr, "Liberation Sans");
 }
 
 static void testCachedGlyphsSubstring( const OUString& aText, const OUString& 
aFontName, bool rtl )


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

2023-11-18 Thread Chris Sherlock (via logerrit)
 vcl/qa/cppunit/text.cxx |   97 
 1 file changed, 97 insertions(+)

New commits:
commit 4a1fac7c703068a49df897bb635ff98bf22c0468
Author: Chris Sherlock 
AuthorDate: Wed Nov 8 14:21:47 2023 +1100
Commit: Tomaž Vajngerl 
CommitDate: Sun Nov 19 02:24:59 2023 +0100

vcl: add unit tests for simple text 'AV' with kerning and no-kerning enabled

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

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index 59e079c963ce..b2e837a32c40 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -224,6 +224,103 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleText)
 CPPUNIT_ASSERT_DOUBLES_EQUAL(width36 / 2, width36pct50, 2);
 }
 
+CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleTextFontSpecificKerning)
+{
+OUString aAV(u"AV"_ustr);
+
+vcl::Font aFont("DejaVu Sans", "Book", Size(0, 2048));
+
+ScopedVclPtrInstance pOutDev;
+pOutDev->SetFont(aFont);
+
+// absolute character widths AKA text array.
+tools::Long nRefTextWidth = 2671;
+std::vector aRefCharWidths = { 1270, 2671 };
+KernArray aCharWidths;
+tools::Long nTextWidth = pOutDev->GetTextArray(aAV, &aCharWidths);
+
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], 
aCharWidths.get_subunit_array()[0]);
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], 
aCharWidths.get_subunit_array()[1]);
+// this sporadically returns 75 or 74 on some of the windows tinderboxes 
eg. tb73
+CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back());
+
+// text advance width and line height
+CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aAV));
+CPPUNIT_ASSERT_EQUAL(tools::Long(2384), pOutDev->GetTextHeight());
+
+// exact bounding rectangle, not essentially the same as text width/height
+tools::Rectangle aBoundRect;
+pOutDev->GetTextBoundRect(aBoundRect, aAV);
+CPPUNIT_ASSERT_EQUAL(tools::Long(16), aBoundRect.Left());
+CPPUNIT_ASSERT_EQUAL(tools::Long(408), aBoundRect.Top());
+CPPUNIT_ASSERT_EQUAL(tools::Long(2639), aBoundRect.GetWidth());
+CPPUNIT_ASSERT_EQUAL(tools::Long(1493), aBoundRect.getOpenHeight());
+
+// normal orientation
+tools::Rectangle aInput;
+tools::Rectangle aRect = pOutDev->GetTextRect(aInput, aAV);
+
+// now rotate 270 degrees
+vcl::Font aRotated(aFont);
+aRotated.SetOrientation(2700_deg10);
+pOutDev->SetFont(aRotated);
+tools::Rectangle aRectRot = pOutDev->GetTextRect(aInput, aAV);
+
+// Check that we did do the rotation...
+CPPUNIT_ASSERT_EQUAL(aRectRot.GetWidth(), aRect.GetHeight());
+CPPUNIT_ASSERT_EQUAL(aRectRot.GetHeight(), aRect.GetWidth());
+}
+
+CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleTextNoKerning)
+{
+OUString aAV(u"AV"_ustr);
+
+vcl::Font aFont("DejaVu Sans", "Book", Size(0, 2048));
+aFont.SetKerning(FontKerning::NONE);
+
+ScopedVclPtrInstance pOutDev;
+pOutDev->SetFont(aFont);
+
+// absolute character widths AKA text array.
+tools::Long nRefTextWidth = 2802;
+std::vector aRefCharWidths = { 1401, 2802 };
+KernArray aCharWidths;
+tools::Long nTextWidth = pOutDev->GetTextArray(aAV, &aCharWidths);
+
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths[0], 
aCharWidths.get_subunit_array()[0]);
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths[1], 
aCharWidths.get_subunit_array()[1]);
+// this sporadically returns 75 or 74 on some of the windows tinderboxes 
eg. tb73
+CPPUNIT_ASSERT_EQUAL(nRefTextWidth, nTextWidth);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back());
+
+// text advance width and line height
+CPPUNIT_ASSERT_EQUAL(nRefTextWidth, pOutDev->GetTextWidth(aAV));
+CPPUNIT_ASSERT_EQUAL(tools::Long(2384), pOutDev->GetTextHeight());
+
+// exact bounding rectangle, not essentially the same as text width/height
+tools::Rectangle aBoundRect;
+pOutDev->GetTextBoundRect(aBoundRect, aAV);
+CPPUNIT_ASSERT_EQUAL(tools::Long(16), aBoundRect.Left());
+CPPUNIT_ASSERT_EQUAL(tools::Long(408), aBoundRect.Top());
+CPPUNIT_ASSERT_EQUAL(tools::Long(2770), aBoundRect.GetWidth());
+CPPUNIT_ASSERT_EQUAL(tools::Long(1493), aBoundRect.getOpenHeight());
+
+// normal orientation
+tools::Rectangle aInput;
+tools::Rectangle aRect = pOutDev->GetTextRect(aInput, aAV);
+
+// now rotate 270 degrees
+vcl::Font aRotated(aFont);
+aRotated.SetOrientation(2700_deg10);
+pOutDev->SetFont(aRotated);
+tools::Rectangle aRectRot = pOutDev->GetTextRect(aInput, aAV);
+
+// Check that we did do the rotation...
+CPPUNIT_ASSERT_EQUAL(aRectRot.GetWidth(), aRect.GetHeight());
+CPPUNIT_ASSERT_EQUAL(aRectRot.GetHeight(), aRect.GetWidth());
+}
+
 CPPUNIT_TEST_FIXTURE(VclTextTest, testTextLayoutCache)
 {
 OUString sTestString = u"The 

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

2023-11-08 Thread Stephan Bergmann (via logerrit)
 vcl/qa/cppunit/complextext.cxx |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit aea53c0ed1527ed1f8233972a27128e14d645e8f
Author: Stephan Bergmann 
AuthorDate: Wed Nov 8 14:03:53 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Wed Nov 8 22:50:26 2023 +0100

loplugin:unreffun (clang-cl)

...and make things private/protected, while at it

Change-Id: I5854f55dfe073e30b853c0d3bbafc4b7293c7f0b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159132
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 99b728d338b8..633dc2210e07 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -44,14 +44,15 @@ static std::ostream& operator<<(std::ostream& rStream, 
const std::vector

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

2023-11-06 Thread Noel Grandin (via logerrit)
 vcl/qa/cppunit/outdev.cxx  |   38 ++
 vcl/source/outdev/gradient.cxx |   35 ++-
 2 files changed, 8 insertions(+), 65 deletions(-)

New commits:
commit ee38eea6dd2ef487a4a6014ed2a36f46946648c7
Author: Noel Grandin 
AuthorDate: Sun Nov 5 20:23:32 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Nov 7 06:10:47 2023 +0100

simplify OutputDevice::ClipAndDrawGradientMetafile

using a poly clip is better than using XOR, so make this the
default.

Change-Id: I48bb6b5d617b8b6dc82760277d72a50a2123ae0f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158957
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 379346dd0b76..83325db08b60 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -1920,47 +1920,13 @@ static size_t ClipGradientTest(GDIMetaFile& rMtf, 
size_t nIndex)
 pAction = rMtf.GetAction(nIndex);
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action", MetaActionType::PUSH, 
pAction->GetType());
 MetaPushAction* pPushAction = dynamic_cast(pAction);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not using XOR push flags", 
vcl::PushFlags::RASTEROP,
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Not using CLIPREGION push flags", 
vcl::PushFlags::CLIPREGION,
  pPushAction->GetFlags());
 
 nIndex++;
 pAction = rMtf.GetAction(nIndex);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rasterop action", 
MetaActionType::RASTEROP,
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a CLIPREGION action", 
MetaActionType::CLIPREGION,
  pAction->GetType());
-MetaRasterOpAction* pRasterOpAction = 
dynamic_cast(pAction);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an XOR rasterop", RasterOp::Xor,
- pRasterOpAction->GetRasterOp());
-
-nIndex++;
-pAction = rMtf.GetAction(nIndex);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action", 
MetaActionType::GRADIENT,
- pAction->GetType());
-
-nIndex++;
-pAction = rMtf.GetAction(nIndex);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action", 
MetaActionType::FILLCOLOR,
- pAction->GetType());
-
-nIndex++;
-pAction = rMtf.GetAction(nIndex);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rasterop action", 
MetaActionType::RASTEROP,
- pAction->GetType());
-pRasterOpAction = dynamic_cast(pAction);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an N0 rasterop", RasterOp::N0,
- pRasterOpAction->GetRasterOp());
-
-nIndex++;
-pAction = rMtf.GetAction(nIndex);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", 
MetaActionType::POLYPOLYGON,
- pAction->GetType());
-
-nIndex++;
-pAction = rMtf.GetAction(nIndex);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rasterop action", 
MetaActionType::RASTEROP,
- pAction->GetType());
-pRasterOpAction = dynamic_cast(pAction);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("Not an XOR rasterop", RasterOp::Xor,
- pRasterOpAction->GetRasterOp());
 
 nIndex++;
 pAction = rMtf.GetAction(nIndex);
diff --git a/vcl/source/outdev/gradient.cxx b/vcl/source/outdev/gradient.cxx
index 52359a779061..d7fb11afd5d5 100644
--- a/vcl/source/outdev/gradient.cxx
+++ b/vcl/source/outdev/gradient.cxx
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -156,36 +155,14 @@ void OutputDevice::DrawGradient( const 
tools::PolyPolygon& rPolyPoly,
 
 void OutputDevice::ClipAndDrawGradientMetafile ( const Gradient &rGradient, 
const tools::PolyPolygon &rPolyPoly )
 {
-const tools::Rectangle aBoundRect( rPolyPoly.GetBoundRect() );
 const bool  bOldOutput = IsOutputEnabled();
-
 EnableOutput( false );
-#if HAVE_FEATURE_SKIA
-// tdf#156539 Draw the gradient with polypolygonal clip when using Skia
-// For some unknown reason, the previous "draw gradient with XOR, draw
-// polygon with N0, and draw gradient again with XOR" does not work
-// with Skia/Raster (at least on macOS). Fortunately, Skia supports
-// polypolygonal clipping so just clip and draw the gradient.
-if ( SkiaHelper::isVCLSkiaEnabled() )
-{
-Push( vcl::PushFlags::CLIPREGION );
-SetClipRegion( vcl::Region( rPolyPoly ) );
-DrawGradient( aBoundRect, rGradient );
-Pop();
-}
-else
-#endif
-{
-Push( vcl::PushFlags::RASTEROP );
-SetRasterOp( RasterOp::Xor );
-DrawGradient( aBoundRect, rGradient );
-SetFillColor( COL_BLACK );
-SetRasterOp( RasterOp::N0 );
-DrawPolyPolygon( rPolyPoly );
-SetRasterOp( RasterOp::Xor );
-DrawGradient( aBoundRect, rGradient );
-Pop();
-}
+
+Push( vcl::PushFlags::CLIPREGION );
+

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

2023-10-31 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf157679.pptx |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |   28 +++
 2 files changed, 28 insertions(+)

New commits:
commit d0f521132c43fea1ca18e18d3e31c6d868e4ebd6
Author: Xisco Fauli 
AuthorDate: Tue Oct 31 13:43:32 2023 +0100
Commit: Xisco Fauli 
CommitDate: Tue Oct 31 17:24:31 2023 +0100

tdf#157679: vcl_pdfexport: Add unittest

Change-Id: I31aa7f683e8d9f9a227ba88c58e7fdba94c83bb5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158725
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf157679.pptx 
b/vcl/qa/cppunit/pdfexport/data/tdf157679.pptx
new file mode 100644
index ..ca82491c21f3
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf157679.pptx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index fdcc1730b6a8..192d559f9c74 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1692,6 +1692,34 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf105954)
 CPPUNIT_ASSERT_LESS(static_cast(250), aMeta.getWidth());
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157679)
+{
+// Import the bugdoc and export as PDF.
+aMediaDescriptor["FilterName"] <<= OUString("impress_pdf_Export");
+saveAsPDF(u"tdf157679.pptx");
+std::unique_ptr pPdfDocument = parsePDFExport();
+
+// The document has one page.
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage);
+
+// Without the fix in place, this test would have failed with
+// - Expected: 3
+// - Actual  : 5
+CPPUNIT_ASSERT_EQUAL(3, pPdfPage->getObjectCount());
+
+std::unique_ptr pTextPage = 
pPdfPage->getTextPage();
+int nPageObjectCount = pPdfPage->getObjectCount();
+for (int i = 0; i < nPageObjectCount; ++i)
+{
+// Check there are not Text objects
+std::unique_ptr pPageObject = 
pPdfPage->getObject(i);
+CPPUNIT_ASSERT(pPageObject->getType() != 
vcl::pdf::PDFPageObjectType::Text);
+}
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128445)
 {
 // Import the bugdoc and export as PDF.


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

2023-10-30 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 6270996c66a05722c5d7c8fe1fcdb3992761650d
Author: Andrea Gelmini 
AuthorDate: Mon Oct 30 05:51:59 2023 +0100
Commit: Julien Nabet 
CommitDate: Mon Oct 30 10:54:13 2023 +0100

Fix typo

Change-Id: I63c8d4f30a1558e3f1cee72cc5d4ba1426409912
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158635
Reviewed-by: Julien Nabet 
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt 
b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt
index 4aa4a92b6710..eda699e27f02 100644
--- a/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt
+++ b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt
@@ -161,7 +161,7 @@
 

This text document contains some links and a text 
control.
-   When 
exporting the document to PDF in LO 7.5.3.2 or newer 
the links won't have the right target any more. First link to "Kläranlage" will 
open last link to "#pano=24", second link wont open anything and third link will open 
"Mechanische Vorreinigung"
+   When 
exporting the document to PDF in LO 7.5.3.2 or newer 
the links won't have the right target any more. First link to "Kläranlage" will 
open last link to "#pano=24", second link won't open anything and third link will open 
"Mechanische Vorreinigung"
https://klexikon.zum.de/wiki/Kläranlage"; 
text:style-name="Internet_20_link" 
text:visited-style-name="Visited_20_Internet_20_Link">https://klexikon.zum.de/wiki/Kläranlage
https://de.wikipedia.org/wiki/Kläranlage#Mechanische_Vorreinigung"; 
text:style-name="Internet_20_link" 
text:visited-style-name="Visited_20_Internet_20_Link">https://de.wikipedia.org/wiki/Kläranlage#Mechanische_Vorreinigung
https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24";
 text:style-name="Internet_20_link" 
text:visited-style-name="Visited_20_Internet_20_Link">https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24
@@ -171,4 +171,4 @@
Up to LO 7.5.2.2 this bug won't 
appear.
   
  
-
\ No newline at end of file
+


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

2023-10-29 Thread offtkp (via logerrit)
 vcl/qa/cppunit/animationrenderer.cxx |   45 +++
 1 file changed, 15 insertions(+), 30 deletions(-)

New commits:
commit 6d423ed9bb89da15bfd9ac3555cb01696458fa71
Author: offtkp 
AuthorDate: Sun Oct 29 13:12:02 2023 +0200
Commit: Paris Oplopoios 
CommitDate: Sun Oct 29 22:18:05 2023 +0100

CppunitTest_vcl_animate: use CPPUNIT_TEST_FIXTURE

CPPUNIT_TEST_FIXTURE is easier to write tests for and separate if needed

Change-Id: I2c478205847e4d15c0f8d65d498dd8d82079fa5d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158616
Tested-by: Jenkins
Reviewed-by: Paris Oplopoios 

diff --git a/vcl/qa/cppunit/animationrenderer.cxx 
b/vcl/qa/cppunit/animationrenderer.cxx
index 86ad06c47941..93f80970f2ea 100644
--- a/vcl/qa/cppunit/animationrenderer.cxx
+++ b/vcl/qa/cppunit/animationrenderer.cxx
@@ -31,6 +31,18 @@ public:
 void ReleaseGraphics(bool) override {}
 bool UsePolyPolygonForComplexGradient() override { return false; }
 };
+
+Animation createAnimation()
+{
+Animation aAnimation;
+
+aAnimation.Insert(
+AnimationFrame(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), 
Point(0, 0), Size(10, 10)));
+aAnimation.Insert(
+AnimationFrame(BitmapEx(Size(3, 3), vcl::PixelFormat::N24_BPP), 
Point(0, 0), Size(10, 10)));
+
+return aAnimation;
+}
 }
 
 class VclAnimationRendererTest : public test::BootstrapFixture
@@ -40,22 +52,9 @@ public:
 : BootstrapFixture(true, false)
 {
 }
-
-void testMatching();
-void testDrawToPos();
-void testGetPosSizeWindow();
-
-CPPUNIT_TEST_SUITE(VclAnimationRendererTest);
-CPPUNIT_TEST(testMatching);
-CPPUNIT_TEST(testDrawToPos);
-CPPUNIT_TEST(testGetPosSizeWindow);
-CPPUNIT_TEST_SUITE_END();
-
-private:
-Animation createAnimation();
 };
 
-void VclAnimationRendererTest::testMatching()
+CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testMatching)
 {
 Animation aTestAnim = createAnimation();
 ScopedVclPtrInstance pTestRC;
@@ -69,7 +68,7 @@ void VclAnimationRendererTest::testMatching()
 CPPUNIT_ASSERT(pAnimationRenderer->matches(pTestRC, 0));
 }
 
-void VclAnimationRendererTest::testDrawToPos()
+CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testDrawToPos)
 {
 Animation aTestAnim = createAnimation();
 ScopedVclPtrInstance pTestRC;
@@ -84,7 +83,7 @@ void VclAnimationRendererTest::testDrawToPos()
 CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel());
 }
 
-void VclAnimationRendererTest::testGetPosSizeWindow()
+CPPUNIT_TEST_FIXTURE(VclAnimationRendererTest, testGetPosSizeWindow)
 {
 Animation aTestAnim = createAnimation();
 ScopedVclPtrInstance pTestRC;
@@ -102,20 +101,6 @@ void VclAnimationRendererTest::testGetPosSizeWindow()
 CPPUNIT_ASSERT_EQUAL(Size(10, 10), aSize);
 }
 
-Animation VclAnimationRendererTest::createAnimation()
-{
-Animation aAnimation;
-
-aAnimation.Insert(
-AnimationFrame(BitmapEx(Size(3, 4), vcl::PixelFormat::N24_BPP), 
Point(0, 0), Size(10, 10)));
-aAnimation.Insert(
-AnimationFrame(BitmapEx(Size(3, 3), vcl::PixelFormat::N24_BPP), 
Point(0, 0), Size(10, 10)));
-
-return aAnimation;
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(VclAnimationRendererTest);
-
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2023-10-24 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   45 ++---
 vcl/source/gdi/pdfwriter_impl.cxx  |   35 ++---
 2 files changed, 28 insertions(+), 52 deletions(-)

New commits:
commit 049f458143cbd02ab915271418625cda1299f4b1
Author: Michael Stahl 
AuthorDate: Tue Oct 24 15:58:14 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Oct 24 18:46:50 2023 +0200

tdf#157028 vcl: PDF export: inline attribute dictionaries

There seems to be no reason why SE attribute dictionaries are separate
objects, they could just be inline, which saves a little space (1%)
and more importantly the PDF file is easier to read with less clutter.

Change-Id: Iaaea2432313c0b710edabecae32545205f4f495e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158392
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 8dd1a9a71fbf..70da866889aa 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3475,11 +3475,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf149140)
 CPPUNIT_ASSERT(pAttrs != nullptr);
 for (const auto& rAttrRef : pAttrs->GetElements())
 {
-auto pARef = 
dynamic_cast(rAttrRef);
-CPPUNIT_ASSERT(pARef != nullptr);
-auto pAttr = pARef->LookupObject();
-CPPUNIT_ASSERT(pAttr != nullptr);
-auto pAttrDict = pAttr->GetDictionary();
+auto pAttrDict = 
dynamic_cast(rAttrRef);
 CPPUNIT_ASSERT(pAttrDict != nullptr);
 auto pOwner
 = 
dynamic_cast(pAttrDict->LookupElement("O"));
@@ -3841,11 +3837,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf135638)
 auto pS = 
dynamic_cast(pObject->Lookup("S"));
 if (pS && pS->GetValue() == "Figure")
 {
-auto pARef = 
dynamic_cast(pObject->Lookup("A"));
-CPPUNIT_ASSERT(pARef != nullptr);
-auto pAttr = pARef->LookupObject();
-CPPUNIT_ASSERT(pAttr != nullptr);
-auto pAttrDict = pAttr->GetDictionary();
+auto pAttrDict
+= 
dynamic_cast(pObject->Lookup("A"));
 CPPUNIT_ASSERT(pAttrDict != nullptr);
 auto pOwner
 = 
dynamic_cast(pAttrDict->LookupElement("O"));
@@ -4398,12 +4391,8 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testSpans)
 auto pS103101
 = 
dynamic_cast(pObject103101->Lookup("S"));
 CPPUNIT_ASSERT_EQUAL(OString("Span"), pS103101->GetValue());
-auto pA103101
-= 
dynamic_cast(pObject103101->Lookup("A"));
-CPPUNIT_ASSERT(pA103101);
-auto pObjectA103101 = pA103101->LookupObject();
-CPPUNIT_ASSERT(pObjectA103101);
-auto pDictA103101 = pObjectA103101->GetDictionary();
+auto pDictA103101
+= 
dynamic_cast(pObject103101->Lookup("A"));
 CPPUNIT_ASSERT(pDictA103101 != nullptr);
 CPPUNIT_ASSERT_EQUAL(OString("Layout"), 
dynamic_cast(
 
pDictA103101->LookupElement("O"))
@@ -4963,13 +4952,12 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157397)
 CPPUNIT_ASSERT_EQUAL(OString("StructElem"), pType160->GetValue());
 auto pS160 = 
dynamic_cast(pObject160->Lookup("S"));
 CPPUNIT_ASSERT_EQUAL(OString("Form"), pS160->GetValue());
-auto pA160 = 
dynamic_cast(pObject160->Lookup("A"));
-CPPUNIT_ASSERT(pA160);
-auto pA160Obj = pA160->LookupObject();
-auto pA160O = 
dynamic_cast(pA160Obj->Lookup("O"));
+auto pA160Dict = 
dynamic_cast(pObject160->Lookup("A"));
+CPPUNIT_ASSERT(pA160Dict);
+auto pA160O = 
dynamic_cast(pA160Dict->LookupElement("O"));
 CPPUNIT_ASSERT(pA160O);
 CPPUNIT_ASSERT_EQUAL(OString("PrintField"), pA160O->GetValue());
-auto pA160Role = 
dynamic_cast(pA160Obj->Lookup("Role"));
+auto pA160Role = 
dynamic_cast(pA160Dict->LookupElement("Role"));
 CPPUNIT_ASSERT(pA160Role);
 CPPUNIT_ASSERT_EQUAL(OString("tv"), pA160Role->GetValue());
 
@@ -5088,13 +5076,9 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf135192)
 for (const auto& 
rAttrRef :
  
pAttrs->GetElements())
 {
-auto pARef = 
dynamic_cast<
-
vcl::filter::PDFReferenceElement*>(
+auto pAttrDict = 
dynamic_cast<
+ 

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

2023-10-20 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf156685.docx |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |   36 +++
 2 files changed, 36 insertions(+)

New commits:
commit fc1ba4d17fd71656205697a6cf19432037e4a9d6
Author: Xisco Fauli 
AuthorDate: Fri Oct 20 16:03:56 2023 +0200
Commit: Xisco Fauli 
CommitDate: Sat Oct 21 01:04:12 2023 +0200

tdf#156182, tdf#156685: vcl_pdfexport: Add unittest

Change-Id: I6756f1f19b9cc178191a47ea81857981f44aced0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158264
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf156685.docx 
b/vcl/qa/cppunit/pdfexport/data/tdf156685.docx
new file mode 100644
index ..a3eddf84594b
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf156685.docx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 74283bdae3d3..c4158552677d 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1357,6 +1357,42 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145274)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf156685)
+{
+// Import the bugdoc and export as PDF.
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"tdf156685.docx");
+
+// Parse the export result with pdfium.
+std::unique_ptr pPdfDocument = parsePDFExport();
+
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+
+auto pPage = pPdfDocument->openPage(0);
+CPPUNIT_ASSERT(pPage);
+
+int nPageObjectCount = pPage->getObjectCount();
+
+CPPUNIT_ASSERT_EQUAL(9, nPageObjectCount);
+
+auto pTextPage = pPage->getTextPage();
+
+for (int i = 0; i < nPageObjectCount; ++i)
+{
+std::unique_ptr pPageObject = 
pPage->getObject(i);
+if (pPageObject->getType() != vcl::pdf::PDFPageObjectType::Text)
+continue;
+
+CPPUNIT_ASSERT_EQUAL(11.0, pPageObject->getFontSize());
+CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFTextRenderMode::Fill, 
pPageObject->getTextRenderMode());
+
+// Without the fix in place, this test would have failed with
+// - Expected: rgba[00ff]
+// - Actual  : rgba[]
+CPPUNIT_ASSERT_EQUAL(COL_BLACK, pPageObject->getFillColor());
+}
+}
+
 /// Test writing ToUnicode CMAP for doubly encoded glyphs.
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf66597_1)
 {


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

2023-10-12 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt |  174 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |  257 
++
 vcl/source/gdi/pdfextoutdevdata.cxx|   20 
 3 files changed, 447 insertions(+), 4 deletions(-)

New commits:
commit 2e32aa1e9fc240c9cd9854655106d0decbd3694a
Author: Michael Stahl 
AuthorDate: Tue Oct 10 18:20:04 2023 +0200
Commit: Michael Stahl 
CommitDate: Thu Oct 12 11:06:10 2023 +0200

tdf#157397 vcl: PDF export: fix CreateControl replay

The problem is that the CreateLink and CreateControl actions are
replayed in a different order than they are recorded, because CreateLink
is a global action, and CreateControl a page action.

This means that the mCurId at the time when
PDFExtOutDevData::CreateControl() is called does not correspond to a
position in mParaIds when CreateControl is replayed; it will be inserted
too early and bump all the CreateLink ones to later indexes.

Avoid this by adding another global action CreateControlLink that is
added when CreateControl is being replayed, which appears to work.

(Another subtle problem is that, in case of PDF/A-1, the page actions
could be discarded completely; this should work in that case too.)

(regression from commit d4d471fc88fe4fd14f44dfccdfe360dec327d4f0)

Change-Id: I92d89ac08db6548e9f0d1480d984aeacb4d22262
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157767
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt 
b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt
new file mode 100644
index ..4aa4a92b6710
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt
@@ -0,0 +1,174 @@
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:dc="http://purl.org/dc/elements/1.1/"; xmlns:c
 alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:
 meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ A. 
Spielhoff2020-09-12T10:51:34.4381175712023-10-11T12:40:15.543658302PT7H23M50S98LibreOfficeDev/7.5.7.0.0$Linux_X86_64
 
LibreOffice_project/0325c0aa2d3e6df97ff554ca540d316273fd149a2023-09-23T14:07:35.317591779PDF-Dateien:
 A Spielhoff
+ 
+  
+  
+  
+  
+ 
+  
+   
+   
+
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+  
+   
+  
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+   
+
+ 
+
+   
+  
+  
+  
+  
+ 
+ 
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+
+
+   
+   
+   
+  
+  
+   
+  
+ 
+ 
+  
+  
+ 
+  
+   
+
+ 
+  
+   

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

2023-10-08 Thread Mike Kaganski (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspi2.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e64d85c9eb18642ed3a0526f3dd8db9a4b88e629
Author: Mike Kaganski 
AuthorDate: Sun Oct 8 15:56:37 2023 +0200
Commit: Mike Kaganski 
CommitDate: Sun Oct 8 18:44:55 2023 +0200

Fix build

See e.g. 
https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/148996/consoleFull#699387013baec2b5c-2b20-4190-a3fa-ceac4be9cf93

> error: use a _ustr user-defined string literal instead of constructing an 
instance
> of 'rtl::OUString' from a UTF-16 string literal [loplugin:ostr]

Change-Id: Ia813425bc75e4351add73b8665355d0ccf78
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157629
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx 
b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
index bca752e85cbe..d51ceeaaee81 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspi2.cxx
@@ -443,7 +443,7 @@ static Atspi::Accessible getDescendentAtPath(const 
Atspi::Accessible& xAcc, int
 
 CPPUNIT_TEST_FIXTURE(Atspi2TestTree, Test1)
 {
-loadFromSrc(u"vcl/qa/cppunit/a11y/atspi2/testdocuments/ecclectic.fodt");
+
loadFromSrc(u"vcl/qa/cppunit/a11y/atspi2/testdocuments/ecclectic.fodt"_ustr);
 
 /* FIXME: We zoom out for everything to fit in the view not to have 
off-screen children
  * that the controller code fails to clean up properly in some situations.


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

2023-09-19 Thread Patrick Luby (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |3 ---
 vcl/source/gdi/pdfwriter_impl.cxx  |   10 ++
 2 files changed, 10 insertions(+), 3 deletions(-)

New commits:
commit c2d7c8e5c616980d5fa77ac48babbf27342b2f0a
Author: Patrick Luby 
AuthorDate: Tue Sep 19 16:43:46 2023 -0400
Commit: Miklos Vajna 
CommitDate: Wed Sep 20 08:14:19 2023 +0200

tdf#156842 increase scale for external PDF data

For some unknown reason, the scale is 8 times larger than for
non-external PDF XObjects.

This fix also allows the CppunitTest_vcl_pdfexport to run
successfully on macOS.

Change-Id: I166914e6ac575c50985efba3fb7a38ec758dea1a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157090
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index b26176c1aa0d..a07ceeb53eae 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -5290,10 +5290,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testPdfImageHyperlink)
 // - Expected: 0.0012626264
 // - Actual  : 0.00126
 // i.e. the rounded reciprocal was 794 points, not the original 792.
-// FIXME macOS actual value is 0.0001578282, for unknown reasons.
-#if !defined MACOSX
 CPPUNIT_ASSERT_EQUAL(0.0012626264, rtl::math::round(aScale.getY(), 10));
-#endif
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testURIs)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 64dfc809fccc..8d4082b1c227 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -9125,6 +9125,16 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 sal_Int32 nWrappedFormObject = 0;
 if (!m_aContext.UseReferenceXObject)
 {
+#ifdef MACOSX
+// tdf#156842 increase scale for external PDF data
+// For some unknown reason, the scale is 8 times larger than for
+// non-external PDF XObjects.
+// This fix also allows the CppunitTest_vcl_pdfexport to run
+// successfully on macOS.
+fScaleX = 8.0 / aSize.Width();
+fScaleY = 8.0 / aSize.Height();
+#endif
+
 // Parse the PDF data, we need that to write the PDF dictionary of our
 // object.
 if (rEmit.m_nExternalPDFDataIndex < 0)


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

2023-09-12 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/GraphicTest.cxx  |   12 ++
 vcl/qa/cppunit/data/tdf149545.svg   |   32 
 vcl/source/filter/GraphicFormatDetector.cxx |2 -
 3 files changed, 45 insertions(+), 1 deletion(-)

New commits:
commit fb07dcf993bd3ff7880b26414e4095560c296d8b
Author: Xisco Fauli 
AuthorDate: Tue Sep 12 14:29:21 2023 +0200
Commit: Tomaž Vajngerl 
CommitDate: Tue Sep 12 21:21:19 2023 +0200

tdf#149545: increase svg check size

otherwise it will fail to open documents like the one in
tdf#149545 with long comments before "https://gerrit.libreoffice.org/c/core/+/156844
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 606936c65f9e..ef9678e42197 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -1294,6 +1294,18 @@ CPPUNIT_TEST_FIXTURE(GraphicTest, testTdf156016)
 CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), 
aGraphic.GetSizePixel().Height());
 }
 
+CPPUNIT_TEST_FIXTURE(GraphicTest, testTdf149545)
+{
+// Without the fix in place, this test would have failed with
+// - Expected: 0x0(Error Area:Io Class:NONE Code:0)
+// - Actual  : 0x8203(Error Area:Vcl Class:General Code:3)
+Graphic aGraphic = loadGraphic(u"tdf149545.svg");
+CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+const auto[scalingX, scalingY] = getDPIScaling();
+CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingX), 
aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), 
aGraphic.GetSizePixel().Height());
+}
+
 CPPUNIT_TEST_FIXTURE(GraphicTest, testAvailableThreaded)
 {
 Graphic jpgGraphic1 = importUnloadedGraphic(u"TypeDetectionExample.jpg");
diff --git a/vcl/qa/cppunit/data/tdf149545.svg 
b/vcl/qa/cppunit/data/tdf149545.svg
new file mode 100644
index ..39fd956142bd
--- /dev/null
+++ b/vcl/qa/cppunit/data/tdf149545.svg
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; id="svg-root" width="100%" 
height="100%" viewBox="0 0 99 99">
+
+
+
+
diff --git a/vcl/source/filter/GraphicFormatDetector.cxx 
b/vcl/source/filter/GraphicFormatDetector.cxx
index 2cf9e953003e..38a6ec28585e 100644
--- a/vcl/source/filter/GraphicFormatDetector.cxx
+++ b/vcl/source/filter/GraphicFormatDetector.cxx
@@ -32,7 +32,7 @@
 #include 
 #include 
 
-constexpr sal_uInt32 SVG_CHECK_SIZE = 2048;
+constexpr sal_uInt32 SVG_CHECK_SIZE = 8192;
 constexpr sal_uInt32 WMF_EMF_CHECK_SIZE = 44;
 
 namespace


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

2023-09-12 Thread Noel Grandin (via logerrit)
 vcl/qa/cppunit/BitmapExTest.cxx |   61 
 1 file changed, 61 insertions(+)

New commits:
commit cdf4b60e3ed8beafc573ed9741a7828e299f14cc
Author: Noel Grandin 
AuthorDate: Tue Sep 12 15:21:02 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Sep 12 19:30:31 2023 +0200

add a unit test for AlphaMask::BlendWith

Change-Id: Id4602470292d0ba66601c5d2446a06df7e4b508b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156851
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/BitmapExTest.cxx b/vcl/qa/cppunit/BitmapExTest.cxx
index a8f1e5a9cda5..9e5da1c9fab6 100644
--- a/vcl/qa/cppunit/BitmapExTest.cxx
+++ b/vcl/qa/cppunit/BitmapExTest.cxx
@@ -24,11 +24,13 @@ class BitmapExTest : public CppUnit::TestFixture
 void testGetPixelColor24_8();
 void testGetPixelColor32();
 void testTransformBitmapEx();
+void testAlphaBlendWith();
 
 CPPUNIT_TEST_SUITE(BitmapExTest);
 CPPUNIT_TEST(testGetPixelColor24_8);
 CPPUNIT_TEST(testGetPixelColor32);
 CPPUNIT_TEST(testTransformBitmapEx);
+CPPUNIT_TEST(testAlphaBlendWith);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -106,6 +108,65 @@ void BitmapExTest::testTransformBitmapEx()
 }
 }
 
+void BitmapExTest::testAlphaBlendWith()
+{
+AlphaMask alpha(Size(1, 1));
+AlphaMask bitmap(Size(1, 1));
+
+// Just test a handful of combinations to make sure the algorithm doesn't
+// change (as happened when I did some 32-bit alpha changes)
+
+// Note that Erase() takes a transparency value, but we get alpha values 
in GetPixelIndex.
+
+alpha.Erase(64);
+bitmap.Erase(64);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 112),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(12);
+bitmap.Erase(64);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 73),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(12);
+bitmap.Erase(12);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 24),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(127);
+bitmap.Erase(13);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 134),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(255);
+bitmap.Erase(255);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 255),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(0);
+bitmap.Erase(255);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 255),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(255);
+bitmap.Erase(0);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 255),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+
+alpha.Erase(0);
+bitmap.Erase(0);
+alpha.BlendWith(bitmap);
+CPPUNIT_ASSERT_EQUAL(static_cast(255 - 0),
+ AlphaMask::ScopedReadAccess(alpha)->GetPixelIndex(0, 
0));
+}
+
 } // namespace
 
 CPPUNIT_TEST_SUITE_REGISTRATION(BitmapExTest);


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

2023-09-01 Thread Noel Grandin (via logerrit)
 vcl/qa/cppunit/text.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 590408329ee47496c813709a1bcc8cd35f6ebbb1
Author: Noel Grandin 
AuthorDate: Fri Sep 1 11:30:25 2023 +0200
Commit: Noel Grandin 
CommitDate: Fri Sep 1 12:59:43 2023 +0200

adjust VclTextTest::testSimpleText

on my machine, after a recent update, the text is scaled slightly
differently (Ubuntu 23.04)

Change-Id: I5ac5e0c76a4cc4c0468a9f0e9186f95004d4d24f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156398
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index 4d55b1bd91d5..a42b308f6c68 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -181,7 +181,7 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleText)
 tools::Long height72 = getCharacterLeftSideHeight(device, Point(0, 30));
 CPPUNIT_ASSERT_DOUBLES_EQUAL(height36 * 2, height72, 4);
 tools::Long width72 = getCharacterBaseWidth(device, Point(20, 99));
-CPPUNIT_ASSERT_DOUBLES_EQUAL(width36 * 2, width72, 4);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(width36 * 2, width72, 5);
 
 font.SetOrientation(2700_deg10);
 device->Erase();
@@ -207,7 +207,7 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleText)
 tools::Long height36pct200 = getCharacterLeftSideHeight(device, Point(0, 
30));
 CPPUNIT_ASSERT_DOUBLES_EQUAL(height36, height36pct200, 2);
 tools::Long width36pct200 = getCharacterBaseWidth(device, Point(20, 99));
-CPPUNIT_ASSERT_DOUBLES_EQUAL(width36 * 2, width36pct200, 4);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(width36 * 2, width36pct200, 5);
 
 // Test width scaled to 50%.
 font = vcl::Font("DejaVu Sans", "Book", Size(18, 36));
@@ -218,7 +218,7 @@ CPPUNIT_TEST_FIXTURE(VclTextTest, testSimpleText)
 device->SetFont(font);
 device->DrawText(Point(10, 10), text);
 exportDevice("simple-text-36-50pct.png", device);
-tools::Long height36pct50 = getCharacterLeftSideHeight(device, Point(0, 
30));
+tools::Long height36pct50 = getCharacterLeftSideHeight(device, Point(0, 
40));
 CPPUNIT_ASSERT_DOUBLES_EQUAL(height36, height36pct50, 2);
 tools::Long width36pct50 = getCharacterBaseWidth(device, Point(15, 99));
 CPPUNIT_ASSERT_DOUBLES_EQUAL(width36 / 2, width36pct50, 2);


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

2023-08-25 Thread Stephan Bergmann (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bb2bd14b941ea0a8463264dcf8902ae67302b386
Author: Stephan Bergmann 
AuthorDate: Fri Aug 25 08:04:07 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Aug 25 09:50:11 2023 +0200

This copy ctor should probably take its arg by const ref

It was introduced in 3426dcfec2b4d5c755024c355f323ecc9f656e4a "vcl gtk3:
Introduce AT-SPI2 tests for the GTK3 accessibility layer", and caused at 
least a
build with recent GCC 14 trunk to failed with

> In file included from vcl/qa/cppunit/a11y/atspi2/atspiwrapper.cxx:10:
> vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx: In member function 
‘Atspi::Accessible::iterator Atspi::Accessible::iterator::operator++(int)’:
> vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx:524:20: error: cannot bind 
non-const lvalue reference of type ‘Atspi::Accessible::iterator&’ to an rvalue 
of type ‘Atspi::Accessible::iterator’
>   524 | return other;
>   |^
> vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx:508:28: note:   initializing 
argument 1 of 
‘Atspi::Accessible::iterator::iterator(Atspi::Accessible::iterator&)’
>   508 | iterator(iterator& other)
>   |  ~~^

Change-Id: Ia9a1e3f58d67db1fc9851fe8a844f2076ff740c3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156075
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx 
b/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx
index 91ddd9dac217..635f9b76d407 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx
@@ -505,7 +505,7 @@ public:
 {
 }
 
-iterator(iterator& other)
+iterator(iterator const& other)
 : m_pAccessible(other.m_pAccessible)
 , m_idx(other.m_idx)
 {


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

2023-08-22 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/svm/svmtest.cxx |4 ++--
 vcl/source/gdi/mtfxmldump.cxx  |   32 
 2 files changed, 26 insertions(+), 10 deletions(-)

New commits:
commit 77dab2ac3a4dfdc6f51fdfc31078fb828e8164fa
Author: Khaled Hosny 
AuthorDate: Thu Aug 17 17:19:09 2023 +0300
Commit: خالد حسني 
CommitDate: Tue Aug 22 10:52:58 2023 +0200

vcl: Fix dumping meta file layout flags to XML

These are bit flags, so we were always writing #, so now it does
bitwise check for the flags and while at it write the names of the flags
not the numeric values.

Change-Id: I13cae38c0e549b2da1f834a264e3a3255bfa5c5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155793
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 5161f4cce960..d89f2f93118d 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -2298,11 +2298,11 @@ void SvmTest::checkLayoutMode(const GDIMetaFile& 
rMetaFile)
 xmlDocUniquePtr pDoc = dumpMeta(rMetaFile);
 
 assertXPathAttrs(pDoc, "/metafile/layoutmode[1]", {
-{"textlayout", "#0004"}
+{"textlayout", "TextOriginLeft"}
 });
 
 assertXPathAttrs(pDoc, "/metafile/layoutmode[2]", {
-{"textlayout", "#0001"}
+{"textlayout", "BiDiRtl"}
 });
 }
 
diff --git a/vcl/source/gdi/mtfxmldump.cxx b/vcl/source/gdi/mtfxmldump.cxx
index 8726316324de..c26a44310774 100644
--- a/vcl/source/gdi/mtfxmldump.cxx
+++ b/vcl/source/gdi/mtfxmldump.cxx
@@ -439,17 +439,33 @@ OUString convertPixelFormatToString(vcl::PixelFormat 
ePixelFormat)
 return OUString();
 }
 
-OUString convertComplexTestLayoutFlags(vcl::text::ComplexTextLayoutFlags 
eComplexTestLayoutFlags)
+OUString convertComplexTestLayoutFlags(vcl::text::ComplexTextLayoutFlags 
nFlags)
 {
-switch(eComplexTestLayoutFlags)
+if (nFlags == vcl::text::ComplexTextLayoutFlags::Default)
+return "Default";
+
+std::vector aStrings;
+
+if (nFlags & vcl::text::ComplexTextLayoutFlags::BiDiRtl)
+aStrings.emplace_back("BiDiRtl");
+if (nFlags & vcl::text::ComplexTextLayoutFlags::BiDiStrong)
+aStrings.emplace_back("BiDiStrong");
+if (nFlags & vcl::text::ComplexTextLayoutFlags::TextOriginLeft)
+aStrings.emplace_back("TextOriginLeft");
+if (nFlags & vcl::text::ComplexTextLayoutFlags::TextOriginRight)
+aStrings.emplace_back("TextOriginRight");
+
+OUString aString;
+
+if (aStrings.empty())
+return aString;
+
+aString = aStrings[0];
+for (size_t i = 1; i < aStrings.size(); ++i)
 {
-default:
-case vcl::text::ComplexTextLayoutFlags::Default: return "#";
-case vcl::text::ComplexTextLayoutFlags::BiDiRtl: return "#0001";
-case vcl::text::ComplexTextLayoutFlags::BiDiStrong: return "#0002";
-case vcl::text::ComplexTextLayoutFlags::TextOriginLeft: return "#0004";
-case vcl::text::ComplexTextLayoutFlags::TextOriginRight: return 
"#0008";
+aString += ", " + aStrings[i];
 }
+return aString;
 }
 
 OUString convertGfxLinkTypeToString(GfxLinkType eGfxLinkType)


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

2023-08-03 Thread Colomban Wendling (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 150a1528882347882e857649290fe81d5aa08345
Author: Colomban Wendling 
AuthorDate: Thu Aug 3 16:09:27 2023 +0200
Commit: Michael Weghorn 
CommitDate: Fri Aug 4 07:55:55 2023 +0200

gtk3 a11y tests: Increase DBus timeout

We apparently get recurrent spurious timeout failures in the CI
related to DBus timeout, so increase that value.

The chosen value is a bit arbitrary, but is below the maximum
recommended by the documentation (even though the recommendation hardly
applies to our use case), and more than 3 times larger than the
default.  That will hopefully be enough.

Change-Id: I244f711f46353009743015d00b303aeb87332936
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155310
Tested-by: Jenkins
Reviewed-by: Michael Weghorn 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx 
b/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx
index 12a58da79d4b..bcde764aa981 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspi2testbase.hxx
@@ -79,6 +79,9 @@ public:
 {
 if (!atspi_is_initialized())
 atspi_init();
+
+// increase timeout to avoid spurious avoid CI failures
+atspi_set_timeout(2500, 15000);
 }
 
 virtual void setUp() override


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

2023-08-01 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/complextext.cxx |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 21f13b90295edf84f87125791e05810666058a1c
Author: Khaled Hosny 
AuthorDate: Tue Aug 1 14:49:12 2023 +0300
Commit: خالد حسني 
CommitDate: Tue Aug 1 18:43:58 2023 +0200

Fix reversed expected and actual unit test results

Change-Id: Ie7eaec7ce9ad6f85b02edc831f1d138f45c18220
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155152
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index ec6ce0ccd0e2..a0ab0c4c00bc 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -566,10 +566,10 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107612)
 
 // Assert that U+202F is included in the fallback run.
 // Without the fix this fails with:
-// - Expected: { 2 }
-// - Actual  : { 1, 2 }
+// - Expected: { 1, 2 }
+// - Actual  : { 2 }
 std::vector aExpctedFallbacks = { 1, 2 };
-CPPUNIT_ASSERT_EQUAL(aFallbacks, aExpctedFallbacks);
+CPPUNIT_ASSERT_EQUAL(aExpctedFallbacks, aExpctedFallbacks);
 #endif
 }
 


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

2023-07-30 Thread Mike Kaganski (via logerrit)
 vcl/qa/cppunit/pdfexport/data/wide_page1.fodt |   40 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   56 ++
 vcl/source/gdi/pdfwriter_impl.cxx |8 ---
 3 files changed, 98 insertions(+), 6 deletions(-)

New commits:
commit e80e2a8dbed8a6cea71eca333564a9fa75b5cfbc
Author: Mike Kaganski 
AuthorDate: Fri Jul 28 17:55:17 2023 +0300
Commit: Mike Kaganski 
CommitDate: Sun Jul 30 20:08:04 2023 +0200

tdf#156528: Fix handling PDF page scaling factor after large pages

The map mode wasn't set when current page's user unit was 1, which meant
that it used the unchanged value from the previous page, where it could
be different.

Change-Id: Id1f1515dceac25cddc12081a86fabf8b32d633f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155025
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/vcl/qa/cppunit/pdfexport/data/wide_page1.fodt 
b/vcl/qa/cppunit/pdfexport/data/wide_page1.fodt
new file mode 100644
index ..9e7390a8e22a
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/wide_page1.fodt
@@ -0,0 +1,40 @@
+
+
+http://openoffice.org/2004/office"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:ooow="http://openoffice.org/200
 4/writer" xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; xmlns
 :css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:officeooo="http://openoffice.org/2009/office"; office:version="1.3" 
office:mimetype="application/vnd.oasis.opendocument.text">
+ 
+ 
+ 
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+  
+ 
+ 
+  
+  
+ 
+ 
+  
+   
+ 
+ 
+
+   
+ 
+ 
+
+  
+ 
+
\ No newline at end of file
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index aaf3998eb99a..2ac143029c07 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -5423,6 +5423,62 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf48707_2)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf156528)
+{
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"wide_page1.fodt");
+std::unique_ptr pPdfDocument = parsePDFExport();
+
+// The document has two pages
+CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+
+// 1st page (5100 mm width x 210 mm high, UserUnit = 2)
+auto pPdfPage = pPdfDocument->openPage(0);
+CPPUNIT_ASSERT(pPdfPage);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(o3tl::convert(5100.0 / 2, o3tl::Length::mm, 
o3tl::Length::pt),
+ pPdfPage->getWidth(), 1);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(o3tl::convert(210.0 / 2, o3tl::Length::mm, 
o3tl::Length::pt),
+ pPdfPage->getHeight(), 1);
+
+// 1 object (rectangle 5060 mm width x 170 mm high, UserUnit = 2)
+CPPUNIT_ASSERT_EQUAL(1, pPdfPage->getObjectCount());
+auto pRect = pPdfPage->getObject(0);
+CPPUNIT_ASSERT(pRect);
+CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFPageObjectType::Path, pRect->getType());
+auto bounds = pRect->getBounds();
+CPPUNIT_ASSERT_DOUBLES_EQUAL(o3tl::convert(5060.0 / 2, o3tl::Length::mm, 
o3tl::Length::pt),
+ 

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

2023-07-28 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit bf704afbb7c9ff843d66fec2eddbb00c43a9ab42
Author: Andrea Gelmini 
AuthorDate: Fri Jul 28 16:39:45 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Jul 28 17:05:20 2023 +0200

Fix typo

Change-Id: I1973ac5efd12b2071a92a97d8d669f1e46b9c594
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155020
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx 
b/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx
index 209495e826ae..91ddd9dac217 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspiwrapper.hxx
@@ -604,7 +604,7 @@ public:
 /** Wrapper for AtspiRange
  *
  * This is not actually required, but helps make this more C++-y (by 
allowing TextRange to
- * inherit it) and more LibreOffice-y (by having cameCase names) */
+ * inherit it) and more LibreOffice-y (by having camelCase names) */
 struct Range
 {
 int startOffset;


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

2023-07-28 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/a11y/atspi2/atspi2text.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 92bc3c8c1968d177d7db365b7062e4750d451ff6
Author: Andrea Gelmini 
AuthorDate: Fri Jul 28 16:42:24 2023 +0200
Commit: Julien Nabet 
CommitDate: Fri Jul 28 17:03:59 2023 +0200

Fix typo

Change-Id: Ia8d0859088614c29ae358fed46d0c750d5a54e81
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155023
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/a11y/atspi2/atspi2text.cxx 
b/vcl/qa/cppunit/a11y/atspi2/atspi2text.cxx
index 68ac59e6bf62..eb0e2aa7e5d8 100644
--- a/vcl/qa/cppunit/a11y/atspi2/atspi2text.cxx
+++ b/vcl/qa/cppunit/a11y/atspi2/atspi2text.cxx
@@ -831,7 +831,7 @@ void Atspi2TestTree::compareTextObjects(
 CPPUNIT_ASSERT_EQUAL_MESSAGE(offsetMsg.getStr(), loRect.Height,
  sal_Int32(atspiRect.height));
 /* for some reason getCharacterBounds() might return negative widths 
in some cases
- * (including a space at the end of a right-justified line), and ATK 
will then then adjust
+ * (including a space at the end of a right-justified line), and ATK 
will then adjust
  * the X and width values to positive to workaround RTL issues (see
  * https://bugzilla.gnome.org/show_bug.cgi?id=102954), so we work 
around that */
 if (loRect.Width < 0)


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

2023-07-11 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |2 +-
 vcl/source/gdi/pdfwriter_impl.cxx  |8 
 2 files changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 1ae1f76caeef35a0db7705dd0c330936a77b6a8c
Author: Michael Stahl 
AuthorDate: Mon Jul 10 20:38:25 2023 +0200
Commit: Michael Stahl 
CommitDate: Tue Jul 11 12:17:07 2023 +0200

tdf#152234 vcl: Role values are lowercase

Old version 3 of PAC throws exceptions if these are capitalized;
presumably this is case sensitive, and all-lowercase unlike everything
else.

Change-Id: Ifc0cef38e333123e810376ab6a7630443d253841
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154282
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index f5de0480e4d4..5e26c693197d 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4260,7 +4260,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testFormControlAnnot)
 CPPUNIT_ASSERT_EQUAL(OString("PrintField"), pO->GetValue());
 auto pRole = 
dynamic_cast(pAObj->Lookup("Role"));
 CPPUNIT_ASSERT(pRole);
-CPPUNIT_ASSERT_EQUAL(OString("Cb"), pRole->GetValue());
+CPPUNIT_ASSERT_EQUAL(OString("cb"), pRole->GetValue());
 auto pKids = 
dynamic_cast(pStructElem->Lookup("K"));
 auto nMCID(0);
 auto nRef(0);
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 75e74b4e1af9..9d957f0d113a 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1911,10 +1911,10 @@ const char* PDFWriterImpl::getAttributeValueTag( 
PDFWriter::StructAttributeValue
 aValueStrings[ PDFWriter::Header ]  = "Header";
 aValueStrings[ PDFWriter::Footer ]  = "Footer";
 aValueStrings[ PDFWriter::Watermark ]   = "Watermark";
-aValueStrings[ PDFWriter::Rb ]  = "Rb";
-aValueStrings[ PDFWriter::Cb ]  = "Cb";
-aValueStrings[ PDFWriter::Pb ]  = "Pb";
-aValueStrings[ PDFWriter::Tv ]  = "Tv";
+aValueStrings[ PDFWriter::Rb ]  = "rb";
+aValueStrings[ PDFWriter::Cb ]  = "cb";
+aValueStrings[ PDFWriter::Pb ]  = "pb";
+aValueStrings[ PDFWriter::Tv ]  = "tv";
 aValueStrings[ PDFWriter::Disc ]= "Disc";
 aValueStrings[ PDFWriter::Circle ]  = "Circle";
 aValueStrings[ PDFWriter::Square ]  = "Square";


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

2023-07-04 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/GraphicTest.cxx|   12 
 vcl/qa/cppunit/data/tdf156016.svg |   33 +
 2 files changed, 45 insertions(+)

New commits:
commit e6cf27e46a48580892ecd0d82f8e55ff9aed465d
Author: Xisco Fauli 
AuthorDate: Tue Jul 4 13:01:36 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jul 4 17:32:54 2023 +0200

tdf#156016: vcl_graphic_test: Add unittest

Change-Id: I0b8a9c8d8440e5084f1cce6e666e20d4508cc691
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153963
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 3cbbcbecf112..606936c65f9e 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -1282,6 +1282,18 @@ CPPUNIT_TEST_FIXTURE(GraphicTest, testLoadSVGZ)
 CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), 
aGraphic.GetSizePixel().Height());
 }
 
+CPPUNIT_TEST_FIXTURE(GraphicTest, testTdf156016)
+{
+// Without the fix in place, this test would have failed with
+// - Expected: 0x0(Error Area:Io Class:NONE Code:0)
+// - Actual  : 0x8203(Error Area:Vcl Class:General Code:3)
+Graphic aGraphic = loadGraphic(u"tdf156016.svg");
+CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+const auto[scalingX, scalingY] = getDPIScaling();
+CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingX), 
aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), 
aGraphic.GetSizePixel().Height());
+}
+
 CPPUNIT_TEST_FIXTURE(GraphicTest, testAvailableThreaded)
 {
 Graphic jpgGraphic1 = importUnloadedGraphic(u"TypeDetectionExample.jpg");
diff --git a/vcl/qa/cppunit/data/tdf156016.svg 
b/vcl/qa/cppunit/data/tdf156016.svg
new file mode 100644
index ..e54d786fe7d4
--- /dev/null
+++ b/vcl/qa/cppunit/data/tdf156016.svg
@@ -0,0 +1,33 @@
+
+http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd";>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+http://www.w3.org/2000/svg"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; id="svg-root" width="100%" 
height="100%" viewBox="0 0 99 99">
+
+
+
+


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

2023-07-04 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/GraphicTest.cxx |  233 -
 1 file changed, 70 insertions(+), 163 deletions(-)

New commits:
commit 0c9e09af8ab85122e56bf0a40e1056248565ed75
Author: Xisco Fauli 
AuthorDate: Tue Jul 4 12:39:07 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jul 4 15:16:04 2023 +0200

CppunitTest_vcl_graphic_test: use CPPUNIT_TEST_FIXTURE()

Avoiding the declaration/registration/definition of each
test manually saves a lot of space.

Change-Id: I8a310a6aca3e575f93737cc50e0614592a7ffc8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153958
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index d9ba3b875486..3cbbcbecf112 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -41,103 +41,10 @@
 
 using namespace css;
 
-namespace
-{
 class GraphicTest : public test::BootstrapFixture
 {
 public:
 ~GraphicTest();
-
-private:
-void testUnloadedGraphic();
-void testUnloadedGraphicLoadingPng();
-void testUnloadedGraphicLoadingGif();
-void testUnloadedGraphicLoadingJpg();
-void testUnloadedGraphicLoadingTif();
-void testUnloadedGraphicLoadingWebp();
-void testUnloadedGraphicWmf();
-void testUnloadedGraphicAlpha();
-void testUnloadedGraphicSizeUnit();
-
-void testWMFRoundtrip();
-void testWMFWithEmfPlusRoundtrip();
-void testEmfToWmfConversion();
-
-void testSwappingGraphic_PNG_WithGfxLink();
-void testSwappingGraphic_PNG_WithoutGfxLink();
-void testSwappingGraphicProperties_PNG_WithGfxLink();
-void testSwappingGraphicProperties_PNG_WithoutGfxLink();
-
-void testSwappingVectorGraphic_SVG_WithGfxLink();
-void testSwappingVectorGraphic_SVG_WithoutGfxLink();
-void testSwappingGraphicProperties_SVG_WithGfxLink();
-void testSwappingGraphicProperties_SVG_WithoutGfxLink();
-
-void testSwappingVectorGraphic_PDF_WithGfxLink();
-void testSwappingVectorGraphic_PDF_WithoutGfxLink();
-
-void testSwappingAnimationGraphic_GIF_WithGfxLink();
-void testSwappingAnimationGraphic_GIF_WithoutGfxLink();
-
-void testLoadMET();
-void testLoadBMP();
-void testLoadPSD();
-void testLoadTGA();
-void testLoadXBM();
-void testLoadXPM();
-void testLoadPCX();
-void testLoadEPS();
-void testLoadWEBP();
-void testLoadSVGZ();
-
-void testAvailableThreaded();
-void testColorChangeToTransparent();
-
-CPPUNIT_TEST_SUITE(GraphicTest);
-CPPUNIT_TEST(testUnloadedGraphic);
-CPPUNIT_TEST(testUnloadedGraphicLoadingPng);
-CPPUNIT_TEST(testUnloadedGraphicLoadingGif);
-CPPUNIT_TEST(testUnloadedGraphicLoadingJpg);
-CPPUNIT_TEST(testUnloadedGraphicLoadingTif);
-CPPUNIT_TEST(testUnloadedGraphicLoadingWebp);
-CPPUNIT_TEST(testUnloadedGraphicWmf);
-CPPUNIT_TEST(testUnloadedGraphicAlpha);
-CPPUNIT_TEST(testUnloadedGraphicSizeUnit);
-CPPUNIT_TEST(testWMFRoundtrip);
-CPPUNIT_TEST(testWMFWithEmfPlusRoundtrip);
-CPPUNIT_TEST(testEmfToWmfConversion);
-
-CPPUNIT_TEST(testSwappingGraphic_PNG_WithGfxLink);
-CPPUNIT_TEST(testSwappingGraphic_PNG_WithoutGfxLink);
-CPPUNIT_TEST(testSwappingGraphicProperties_PNG_WithGfxLink);
-CPPUNIT_TEST(testSwappingGraphicProperties_PNG_WithoutGfxLink);
-
-CPPUNIT_TEST(testSwappingVectorGraphic_SVG_WithGfxLink);
-CPPUNIT_TEST(testSwappingVectorGraphic_SVG_WithoutGfxLink);
-CPPUNIT_TEST(testSwappingGraphicProperties_SVG_WithGfxLink);
-CPPUNIT_TEST(testSwappingGraphicProperties_SVG_WithoutGfxLink);
-
-CPPUNIT_TEST(testSwappingVectorGraphic_PDF_WithGfxLink);
-CPPUNIT_TEST(testSwappingVectorGraphic_PDF_WithoutGfxLink);
-
-CPPUNIT_TEST(testSwappingAnimationGraphic_GIF_WithGfxLink);
-CPPUNIT_TEST(testSwappingAnimationGraphic_GIF_WithoutGfxLink);
-
-CPPUNIT_TEST(testLoadMET);
-CPPUNIT_TEST(testLoadBMP);
-CPPUNIT_TEST(testLoadPSD);
-CPPUNIT_TEST(testLoadTGA);
-CPPUNIT_TEST(testLoadXBM);
-CPPUNIT_TEST(testLoadXPM);
-CPPUNIT_TEST(testLoadPCX);
-CPPUNIT_TEST(testLoadEPS);
-CPPUNIT_TEST(testLoadWEBP);
-CPPUNIT_TEST(testLoadSVGZ);
-
-CPPUNIT_TEST(testAvailableThreaded);
-CPPUNIT_TEST(testColorChangeToTransparent);
-
-CPPUNIT_TEST_SUITE_END();
 };
 
 GraphicTest::~GraphicTest()
@@ -147,6 +54,8 @@ GraphicTest::~GraphicTest()
 #endif
 }
 
+namespace
+{
 BitmapEx createBitmap(bool alpha = false)
 {
 Bitmap aBitmap(Size(120, 100), vcl::PixelFormat::N24_BPP);
@@ -262,7 +171,39 @@ Graphic importUnloadedGraphic(std::u16string_view const& 
rFilename)
 return rGraphicFilter.ImportUnloadedGraphic(aFileStream);
 }
 
-void GraphicTest::testUnloadedGraphic()
+int getEmfPlusActionsCount(const Graphic& graphic)
+{
+const GDIMetaFile& metafile = graphic.GetGDIMetaFile();
+int emfPlusCount = 0;
+for (size_t i = 0; i < metafile.GetActionSize(); ++i)
+{
+MetaAction*

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

2023-07-04 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/GraphicTest.cxx  |  100 +---
 vcl/source/filter/graphicfilter.cxx |8 --
 2 files changed, 83 insertions(+), 25 deletions(-)

New commits:
commit cf40ee4a162da5f357793463e5707492030eb5df
Author: Xisco Fauli 
AuthorDate: Tue Jul 4 12:06:04 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jul 4 15:15:33 2023 +0200

CppunitTest_vcl_graphic_test: Demultiplex test code

and relax hack a bit, enabling webp based on testname is
dirty since they might change

Change-Id: Id933095701d01426d2802d6a194d6f74c07baaa9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153957
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 2dff15f29d34..d9ba3b875486 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -50,7 +50,11 @@ public:
 
 private:
 void testUnloadedGraphic();
-void testUnloadedGraphicLoading();
+void testUnloadedGraphicLoadingPng();
+void testUnloadedGraphicLoadingGif();
+void testUnloadedGraphicLoadingJpg();
+void testUnloadedGraphicLoadingTif();
+void testUnloadedGraphicLoadingWebp();
 void testUnloadedGraphicWmf();
 void testUnloadedGraphicAlpha();
 void testUnloadedGraphicSizeUnit();
@@ -91,7 +95,11 @@ private:
 
 CPPUNIT_TEST_SUITE(GraphicTest);
 CPPUNIT_TEST(testUnloadedGraphic);
-CPPUNIT_TEST(testUnloadedGraphicLoading);
+CPPUNIT_TEST(testUnloadedGraphicLoadingPng);
+CPPUNIT_TEST(testUnloadedGraphicLoadingGif);
+CPPUNIT_TEST(testUnloadedGraphicLoadingJpg);
+CPPUNIT_TEST(testUnloadedGraphicLoadingTif);
+CPPUNIT_TEST(testUnloadedGraphicLoadingWebp);
 CPPUNIT_TEST(testUnloadedGraphicWmf);
 CPPUNIT_TEST(testUnloadedGraphicAlpha);
 CPPUNIT_TEST(testUnloadedGraphicSizeUnit);
@@ -294,25 +302,79 @@ void GraphicTest::testUnloadedGraphic()
 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
 }
 
-void GraphicTest::testUnloadedGraphicLoading()
+void GraphicTest::testUnloadedGraphicLoadingPng()
 {
-const OUString aFormats[] = { "png", "gif", "jpg", "tif", "webp" };
+Graphic aGraphic = makeUnloadedGraphic(u"png");
 
-for (OUString const& sFormat : aFormats)
-{
-Graphic aGraphic = makeUnloadedGraphic(sFormat);
-
-// check available
-CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
-CPPUNIT_ASSERT_EQUAL(tools::Long(120), 
aGraphic.GetSizePixel().Width());
-CPPUNIT_ASSERT_EQUAL(tools::Long(100), 
aGraphic.GetSizePixel().Height());
-CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
-CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
-CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
-
-if (sFormat != "jpg")
-CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
-}
+// check available
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingGif()
+{
+Graphic aGraphic = makeUnloadedGraphic(u"gif");
+
+// check available
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+CPPUNIT_ASSERT_EQUAL(true, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingJpg()
+{
+Graphic aGraphic = makeUnloadedGraphic(u"jpg");
+
+// check available
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+CPPUNIT_ASSERT_EQUAL(true, aGraphic.isAvailable());
+
+CPPUNIT_ASSERT_EQUAL(false, checkBitmap(aGraphic));
+}
+
+void GraphicTest::testUnloadedGraphicLoadingTif()
+{
+Graphic aGraphic = makeUnloadedGraphic(u"tif");
+
+// check available
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT_EQUAL(tools::Long(120), aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
+CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > 0);
+CPPUNIT_ASSER

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

2023-07-04 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ef1c755e31971d92429d70fbab58446ccb2bfcda
Author: Andrea Gelmini 
AuthorDate: Mon Jul 3 15:24:46 2023 +0200
Commit: Julien Nabet 
CommitDate: Tue Jul 4 13:16:50 2023 +0200

Fix typo

Change-Id: I14c4862788b3fe28f9c2f6b0ef41601192f5560e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153881
Tested-by: Julien Nabet 
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 3016358e49a5..5698288b4c22 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3306,7 +3306,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf152231)
 ++nPara;
 auto pKids = 
dynamic_cast(pObject->Lookup("K"));
 CPPUNIT_ASSERT(pKids);
-// one problem was that that some StructElem were missing kids
+// one problem was that some StructElem were missing kids
 CPPUNIT_ASSERT(!pKids->GetElements().empty());
 }
 }


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

2023-07-03 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt |  290 ++
 vcl/qa/cppunit/pdfexport/data/tdf48707-2.fodt |  335 ++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   65 +
 vcl/source/gdi/pdfwriter_impl.cxx |3 
 4 files changed, 693 insertions(+)

New commits:
commit 13c4456ca382a92b93395db367ef8edb27a349fa
Author: Khaled Hosny 
AuthorDate: Mon Jul 3 14:19:42 2023 +0300
Commit: خالد حسني 
CommitDate: Mon Jul 3 17:35:17 2023 +0200

tdf#48707: Explicitly set overline color in PDF export

Like we do with underline color, so that color does not leak from
elsewhere.

Change-Id: I3716a117a0d0a1260e47cbfed2242f401a09d7b6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153877
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt 
b/vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt
new file mode 100644
index ..02286e5051c5
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf48707-1.fodt
@@ -0,0 +1,290 @@
+
+
+http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:formx="u
 rn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:rpt="http://openoffice.org/2005/report"; 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:ooow="http://openoffice.org/2004/writer"; 
xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:ooo="http:/
 /openoffice.org/2004/office" 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ Scott 
Wills2011-08-03T07:12:282023-07-03T14:56:12.773653822PT1M52S2LibreOffice/7.5.4.2$MacOSX_X86_64
 
LibreOffice_project/36ccfdc35048b057fd9854c757a8b67ec53977b6
+ 
+  
+   0
+   0
+   22666
+   10624
+   true
+   false
+   
+
+ view2
+ 10463
+ 2501
+ 0
+ 0
+ 22664
+ 10622
+ 3
+ 0
+ false
+ 167
+ false
+ false
+ true
+ true
+ false
+
+   
+  
+  
+   true
+   true
+   true
+   true
+   false
+   
+   false
+   false
+   true
+   false
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   0
+   0
+   false
+   false
+   false
+   false
+   true
+   false
+   false
+   false
+   true
+   false
+   false
+   
+   false
+   false
+   
+   true
+   false
+   false
+   false
+   false
+   false
+   true
+   true
+   false
+   false
+   false
+   false
+   false
+   false
+   false
+   false
+   false
+   
+   false
+   false
+   false
+   false
+   false
+   false
+   0
+   false
+   false
+   false
+   false
+   false
+   true
+   false
+   false
+   false
+   false
+   false
+   false
+   false
+   
+   false
+   false
+   true
+   true
+   false
+   true
+   true
+   false
+   821660
+   true
+   true
+   false
+   
+   false
+   true
+   false
+   high-resolution
+   1
+   0
+   true
+   false
+   false
+   true
+   true
+   true
+   true
+   true
+   false
+   true
+   
+   false
+   true
+   850755
+   false
+  
+ 
+ 
+  
+   http://openoffice.org/2004/office"; 
xmlns:xlink="http://www.w3.org/1999/xlink"/>
+  
+ 
+ 
+  
+  
+  
+  
+  
+ 
+ 
+  
+   
+   
+
+   
+   
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+  
+   
+   
+  
+  
+   
+  
+  
+   
+  
+  
+   
+   
+  
+  
+   

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

2023-06-21 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/data/tdf107718.otf.readme |2 +-
 vcl/qa/cppunit/data/tdf153440.ttf.readme |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 91eaaaf5317ef5bdbedac8a3f2ed6332439a63a9
Author: Khaled Hosny 
AuthorDate: Wed Jun 21 19:50:34 2023 +0300
Commit: René Engelhard 
CommitDate: Wed Jun 21 19:04:44 2023 +0200

Use Unicode hex instead of string literal in readme

Apparently the string literal in command line argument does not work
everywhere.

Change-Id: I4d742f53757699a69d9ba13326a54478f18e51a9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153403
Tested-by: René Engelhard 
Reviewed-by: René Engelhard 

diff --git a/vcl/qa/cppunit/data/tdf107718.otf.readme 
b/vcl/qa/cppunit/data/tdf107718.otf.readme
index b3f740ef58ad..22f656f96d3d 100644
--- a/vcl/qa/cppunit/data/tdf107718.otf.readme
+++ b/vcl/qa/cppunit/data/tdf107718.otf.readme
@@ -5,7 +5,7 @@ obtained from (the Static Super OTC):
 
 And subset using hb-subset to contain only the one glyph used in the test:
 
-  hb-subset SourceHanSans.ttc --face-index=25 
--unicodes="u4E16,u1109,u1168,u11BC,u302E,uC185,u0020" -o tdf107718.otf
+  hb-subset SourceHanSans.ttc --face-index=25 
--unicodes="4E16,1109,1168,11BC,302E,C185,0020" -o tdf107718.otf
 
 U+C185 is not directly used in the test but we need its glyphs. The space is
 added to the subset as it seems needed to get the font to work on Windows.
diff --git a/vcl/qa/cppunit/data/tdf153440.ttf.readme 
b/vcl/qa/cppunit/data/tdf153440.ttf.readme
index 6fffab0decab..a4fc4465bd15 100644
--- a/vcl/qa/cppunit/data/tdf153440.ttf.readme
+++ b/vcl/qa/cppunit/data/tdf153440.ttf.readme
@@ -5,7 +5,7 @@ obtained from:
 
 And subset using hb-subset to contain only the one glyph used in the test:
 
-  hb-subset static/NotoEmoji-Regular.ttf "🌿 " -o tdf153440.ttf 
--drop-tables=GSUB,STAT,vhea,vmtx
+  hb-subset static/NotoEmoji-Regular.ttf --unicodes="1F33F,0020" 
--drop-tables=GSUB,STAT,vhea,vmtx -o tdf153440.ttf
 
 The space is added to the subset as it seems needed to get the font to work on
 Windows. (The --drop-tables argument is not necessary be saves a few bytes of


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

2023-06-20 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/complextext.cxx   |   52 +++
 vcl/qa/cppunit/data/tdf107718.otf|binary
 vcl/qa/cppunit/data/tdf107718.otf.readme |   11 ++
 vcl/source/gdi/CommonSalLayout.cxx   |2 -
 4 files changed, 64 insertions(+), 1 deletion(-)

New commits:
commit 1afc13b0b84353109827d78807836c01f030ab66
Author: Khaled Hosny 
AuthorDate: Tue Jun 20 10:17:49 2023 +0300
Commit: خالد حسني 
CommitDate: Tue Jun 20 14:20:23 2023 +0200

tdf#107718: Fix script itemization of vertical text

Mixed script vertical text was not correctly splitting runs at script
changes, resulting in Hangul text being mixed with Han text in the same
run breaking the Hangul composition.

Change-Id: I09c3f799bede6aa8a19684779d500504a9813af7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153313
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 631a24379a7f..bcf96cb4f99b 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -479,4 +479,56 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf153440)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718)
+{
+#if !defined _WIN32 // TODO: Fails on jenkins but passes locally
+vcl::Font aFont(u"Source Han Sans", u"Regular", Size(0, 72));
+
+ScopedVclPtrInstance pOutDev;
+
+bool bAdded = addFont(pOutDev, u"tdf107718.otf", u"Source Han Sans");
+CPPUNIT_ASSERT_EQUAL(true, bAdded);
+
+OUString aText(u"\u4E16\u1109\u1168\u11BC\u302E");
+for (bool bVertical : { false, true })
+{
+aFont.SetVertical(bVertical);
+pOutDev->SetFont(aFont);
+
+auto pLayout = pOutDev->ImplLayout(aText, 0, -1, Point(0, 0), 0, {}, 
{});
+
+int nStart = 0;
+DevicePoint aPos;
+const GlyphItem* pGlyphItem;
+while (pLayout->GetNextGlyph(&pGlyphItem, aPos, nStart))
+{
+// Check that we found a font for all characters, a zero glyph ID
+// means no font was found so the rest of the test would be
+// meaningless.
+CPPUNIT_ASSERT(pGlyphItem->glyphId());
+
+// Assert that we are indeed doing vertical layout for vertical
+// font since the bug does not happen for horizontal text.
+CPPUNIT_ASSERT_EQUAL(bVertical, pGlyphItem->IsVertical());
+
+// For the second glyph, assert that it is a composition of 
characters 1 to 4
+// Without the fix this fails with:
+// - Expected: 4
+// - Actual  : 1
+if (nStart == 2)
+{
+CPPUNIT_ASSERT_EQUAL(1, pGlyphItem->charPos());
+CPPUNIT_ASSERT_EQUAL(4, pGlyphItem->charCount());
+}
+}
+
+// Assert there are only three glyphs
+// Without the fix this fails with:
+// - Expected: 3
+// - Actual  : 5
+CPPUNIT_ASSERT_EQUAL(3, nStart);
+}
+#endif
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/data/tdf107718.otf 
b/vcl/qa/cppunit/data/tdf107718.otf
new file mode 100644
index ..b892a29a886a
Binary files /dev/null and b/vcl/qa/cppunit/data/tdf107718.otf differ
diff --git a/vcl/qa/cppunit/data/tdf107718.otf.readme 
b/vcl/qa/cppunit/data/tdf107718.otf.readme
new file mode 100644
index ..b3f740ef58ad
--- /dev/null
+++ b/vcl/qa/cppunit/data/tdf107718.otf.readme
@@ -0,0 +1,11 @@
+This is a subset copy of Source Han Sans font licensed under Open Font License 
and
+obtained from (the Static Super OTC):
+
+  https://github.com/adobe-fonts/source-han-sans/releases/tag/2.004R
+
+And subset using hb-subset to contain only the one glyph used in the test:
+
+  hb-subset SourceHanSans.ttc --face-index=25 
--unicodes="u4E16,u1109,u1168,u11BC,u302E,uC185,u0020" -o tdf107718.otf
+
+U+C185 is not directly used in the test but we need its glyphs. The space is
+added to the subset as it seems needed to get the font to work on Windows.
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 907197c70c5e..7ea3ba687485 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -391,7 +391,7 @@ bool 
GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
 aDirection = bRightToLeft ? HB_DIRECTION_RTL : 
HB_DIRECTION_LTR;
 }
 
-if (aSubRuns.empty() || aSubRuns.back().maDirection != 
aDirection)
+if (aSubRuns.empty() || aSubRuns.back().maDirection != 
aDirection || aSubRuns.back().maScript != aScript)
 aSubRuns.push_back({ nPrevIdx, nIdx, aScript, 
aDirection });
 else
 aSubRuns.back().mnEnd = nIdx;


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

2023-06-15 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf155161.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   40 
 2 files changed, 40 insertions(+)

New commits:
commit 198a1afe4d4c3c57a0cf6dc69c2494a2b9119751
Author: Khaled Hosny 
AuthorDate: Wed Jun 14 16:39:18 2023 +0300
Commit: خالد حسني 
CommitDate: Thu Jun 15 13:51:17 2023 +0200

tdf#155161: Add test

The test document embeds Cantarell font because we don’t bundle any
fonts with CFF2 table (or CFF table for that matter).

Change-Id: Icdbab58ea3999baa75bc85fad60172218d9f6058
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153054
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf155161.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf155161.odt
new file mode 100644
index ..1d22bb7c4d01
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf155161.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 0739cd25cd8a..e19f989ce9b9 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4779,6 +4779,46 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf152246)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf155161)
+{
+// TODO: We seem to get a fallback font on Windows
+#ifndef _WIN32
+vcl::filter::PDFDocument aDocument;
+load(u"tdf155161.odt", aDocument);
+
+// Check that all fonts in the document are Type 3 fonts
+int nFonts = 0;
+for (const auto& aElement : aDocument.GetElements())
+{
+auto pObject = 
dynamic_cast(aElement.get());
+if (!pObject)
+continue;
+auto pType = 
dynamic_cast(pObject->Lookup("Type"));
+if (pType && pType->GetValue() == "Font")
+{
+auto pSubtype = 
dynamic_cast(pObject->Lookup("Subtype"));
+CPPUNIT_ASSERT(pSubtype);
+CPPUNIT_ASSERT_EQUAL(OString("Type3"), pSubtype->GetValue());
+
+auto pName = 
dynamic_cast(pObject->Lookup("Name"));
+CPPUNIT_ASSERT(pName);
+CPPUNIT_ASSERT_EQUAL(OString("Cantarell-Regular"), 
pName->GetValue());
+
+nFonts++;
+}
+}
+
+#ifdef MACOSX
+// There must be two fonts
+CPPUNIT_ASSERT_EQUAL(2, nFonts);
+#else
+// But it seems that embedded variable fonts don’t register all supported
+// styles on Linux, so the bold and regular text use the same regular font.
+CPPUNIT_ASSERT(nFonts);
+#endif
+#endif
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();


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

2023-06-13 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/complextext.cxx   |   60 ++-
 vcl/qa/cppunit/data/tdf153440.ttf|binary
 vcl/qa/cppunit/data/tdf153440.ttf.readme |   12 ++
 3 files changed, 71 insertions(+), 1 deletion(-)

New commits:
commit 6b178c6e88ec5a765ad2b3ccd98182286222f550
Author: Khaled Hosny 
AuthorDate: Mon Jun 12 22:48:59 2023 +0300
Commit: خالد حسني 
CommitDate: Tue Jun 13 22:44:52 2023 +0200

tdf#153440: Add test

Change-Id: I0c036cd1d8022e6ff265aa67ab177c57eba0c4ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152934
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 9473d5b7b696..631a24379a7f 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -44,8 +44,27 @@ static std::ostream& operator<<(std::ostream& rStream, const 
std::vectorAddTempDevFont(getFullUrl(sFileName), 
OUString(sFamilyName));
+OutputDevice::ImplRefreshAllFontData(true);
+return bAdded;
+}
+
+VclComplexTextTest()
+: BootstrapFixture(true, false)
+{
+}
 };
 
 CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testArabic)
@@ -421,4 +440,43 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf152048_2)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf153440)
+{
+#if HAVE_MORE_FONTS
+vcl::Font aFont(u"Noto Naskh Arabic", u"Regular", Size(0, 72));
+
+ScopedVclPtrInstance pOutDev;
+pOutDev->SetFont(aFont);
+
+#if !defined _WIN32 // TODO: Fails on jenkins but passes locally
+// Add an emoji font so that we are sure a font will be found for the
+// emoji. The font is subset and supports only 🌿.
+bool bAdded = addFont(pOutDev, u"tdf153440.ttf", u"Noto Emoji");
+CPPUNIT_ASSERT_EQUAL(true, bAdded);
+#endif
+
+for (auto& aString : { u"ع 🌿 ع", u"a 🌿 a" })
+{
+OUString aText(aString);
+bool bRTL = aText.startsWith(u"ع");
+
+auto pLayout = pOutDev->ImplLayout(aText, 0, -1, Point(0, 0), 0, {}, 
{});
+
+int nStart = 0;
+DevicePoint aPos;
+const GlyphItem* pGlyphItem;
+while (pLayout->GetNextGlyph(&pGlyphItem, aPos, nStart))
+{
+// Assert glyph ID is not 0, if it is 0 then font fallback didn’t
+// happen.
+CPPUNIT_ASSERT(pGlyphItem->glyphId());
+
+// Assert that we are indeed doing RTL layout for RTL text since
+// the bug does not happen for LTR text.
+CPPUNIT_ASSERT_EQUAL(bRTL, pGlyphItem->IsRTLGlyph());
+}
+}
+#endif
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/data/tdf153440.ttf 
b/vcl/qa/cppunit/data/tdf153440.ttf
new file mode 100644
index ..933e74733b0a
Binary files /dev/null and b/vcl/qa/cppunit/data/tdf153440.ttf differ
diff --git a/vcl/qa/cppunit/data/tdf153440.ttf.readme 
b/vcl/qa/cppunit/data/tdf153440.ttf.readme
new file mode 100644
index ..6fffab0decab
--- /dev/null
+++ b/vcl/qa/cppunit/data/tdf153440.ttf.readme
@@ -0,0 +1,12 @@
+This is a subset copy of Noto Emoji font licensed under Open Font License and
+obtained from:
+
+  https://fonts.google.com/noto/specimen/Noto+Emoji
+
+And subset using hb-subset to contain only the one glyph used in the test:
+
+  hb-subset static/NotoEmoji-Regular.ttf "🌿 " -o tdf153440.ttf 
--drop-tables=GSUB,STAT,vhea,vmtx
+
+The space is added to the subset as it seems needed to get the font to work on
+Windows. (The --drop-tables argument is not necessary be saves a few bytes of
+stuff we don’t need.)


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

2023-05-29 Thread Dr. David Alan Gilbert (via logerrit)
 vcl/qa/cppunit/timer.cxx |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

New commits:
commit b20eb3367436de4fb189dc82d14412539c02d30c
Author: Dr. David Alan Gilbert 
AuthorDate: Thu May 25 01:31:11 2023 +0100
Commit: Noel Grandin 
CommitDate: Mon May 29 14:48:37 2023 +0200

cppunit/timer: Use a range based loop and cleanup

Use a range based loop in testDurations re

tdf#145538

which also nails a SAL_N_ELEMENTS
tdf#147021

and takes out a sal_uLong
tdf#114441

while here, clean out the rest of the sal_uLong's in that file
to be sal_uInt64 to match timer.hxx which was changed by 9c7016b5b5
way back in 2015.

Change-Id: Ie065885939a340d9a73af797fb4d7d6f76530242
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152250
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx
index 15493b953639..467d7b1a776d 100644
--- a/vcl/qa/cppunit/timer.cxx
+++ b/vcl/qa/cppunit/timer.cxx
@@ -160,7 +160,7 @@ class TimerBool : public Timer
 {
 bool &mrBool;
 public:
-TimerBool( sal_uLong nMS, bool &rBool ) :
+TimerBool( sal_uInt64 nMS, bool &rBool ) :
 Timer( "TimerBool" ), mrBool( rBool )
 {
 SetTimeout( nMS );
@@ -178,11 +178,10 @@ public:
 
 void TimerTest::testDurations()
 {
-static const sal_uLong aDurations[] = { 0, 1, 500, 1000 };
-for (size_t i = 0; i < SAL_N_ELEMENTS( aDurations ); i++)
+for (auto const nDuration : { 0, 1, 500, 1000 })
 {
 bool bDone = false;
-TimerBool aTimer( aDurations[i], bDone );
+TimerBool aTimer( nDuration, bDone );
 // coverity[loop_top] - Application::Yield allows the timer to fire 
and toggle bDone
 while( !bDone )
 {
@@ -199,7 +198,7 @@ class AutoTimerCount : public AutoTimer
 const sal_Int32 mnMaxCount;
 
 public:
-AutoTimerCount( sal_uLong nMS, sal_Int32 &rCount,
+AutoTimerCount( sal_uInt64 nMS, sal_Int32 &rCount,
 const sal_Int32 nMaxCount = -1 )
 : AutoTimer( "AutoTimerCount" )
 , mrCount( rCount )
@@ -340,7 +339,7 @@ namespace {
 class YieldTimer : public Timer
 {
 public:
-explicit YieldTimer( sal_uLong nMS ) : Timer( "YieldTimer" )
+explicit YieldTimer( sal_uInt64 nMS ) : Timer( "YieldTimer" )
 {
 SetTimeout( nMS );
 Start();
@@ -370,7 +369,7 @@ class SlowCallbackTimer : public Timer
 {
 bool &mbSlow;
 public:
-SlowCallbackTimer( sal_uLong nMS, bool &bBeenSlow ) :
+SlowCallbackTimer( sal_uInt64 nMS, bool &bBeenSlow ) :
 Timer( "SlowCallbackTimer" ), mbSlow( bBeenSlow )
 {
 SetTimeout( nMS );


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

2023-05-25 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |8 
 vcl/source/gdi/CommonSalLayout.cxx |2 +-
 vcl/source/gdi/sallayout.cxx   |   13 ++---
 3 files changed, 7 insertions(+), 16 deletions(-)

New commits:
commit 43a5400063b17ed4ba4cbb38bdf5da4a991f60e2
Author: Khaled Hosny 
AuthorDate: Thu May 25 10:59:18 2023 +0300
Commit: خالد حسني 
CommitDate: Thu May 25 14:18:07 2023 +0200

tdf#152048: Fix underline width for Kashida-justified text

Fix GenericSalLayout::GetTextWidth() again, this time doing away with
using linearPos as it is wrong, the glyph’s position is not directly
related to how much it contributes to the text width (for example,
combining marks have zero advance width yet their position is different
from the base glyph they apply too). This is a followup to:

commit ce7c1c608fa99c86c8f2380cd8b82d02123f514e
Author: Khaled Hosny 
Date:   Wed Aug 31 07:07:54 2022 +0200

vcl: Fix GenericSalLayout::GetTextWidth()

Additionally, inserted Kashida should have its origWidth and newWidth
both set to zero, since it does not add to the text width, all
additional width is already added to the glyph the Kashida is applied
to.

With both fixes, the text width of Kashida-justified lines is correctly
calculated and the underline no longer extends beyond the text line.

Fix test expectation now we are reporting the real text width.

Change-Id: I0de93f955929cf3030cf420cb4f4e94df974fb79
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152267
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 4bdc920b3574..bf2ca137646f 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -777,15 +777,15 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf108963)
 pSegment = pPdfPageObject->getPathSegment(1);
 CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
 aPoint = pSegment->getPoint();
-CPPUNIT_ASSERT_DOUBLES_EQUAL(275.074, aPoint.getX(), 0.0005);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(267.590, aPoint.getY(), 0.0005);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(275.216, aPoint.getX(), 0.0005);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(267.732, aPoint.getY(), 0.0005);
 CPPUNIT_ASSERT(!pSegment->isClosed());
 
 pSegment = pPdfPageObject->getPathSegment(2);
 CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFSegmentType::Lineto, 
pSegment->getType());
 aPoint = pSegment->getPoint();
-CPPUNIT_ASSERT_DOUBLES_EQUAL(287.490, aPoint.getX(), 0.0005);
-CPPUNIT_ASSERT_DOUBLES_EQUAL(251.801, aPoint.getY(), 0.0005);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(287.660, aPoint.getX(), 0.0005);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(251.914, aPoint.getY(), 0.0005);
 CPPUNIT_ASSERT(!pSegment->isClosed());
 
 pSegment = pPdfPageObject->getPathSegment(3);
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 0c6043a91869..907197c70c5e 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -834,7 +834,7 @@ void GenericSalLayout::ApplyDXArray(const double* pDXArray, 
const sal_Bool* pKas
 aPos.adjustX(-nClusterWidth + pGlyphIter->origWidth());
 while (nCopies--)
 {
-GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, 
nKashidaWidth, 0, 0);
+GlyphItem aKashida(nCharPos, 0, nKashidaIndex, aPos, nFlags, 0, 0, 
0);
 pGlyphIter = m_GlyphItems.insert(pGlyphIter, aKashida);
 aPos.adjustX(nKashidaWidth - nOverlap);
 ++pGlyphIter;
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 85ad838615d9..1ed2a37ad71b 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -269,19 +269,10 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const
 if (!m_GlyphItems.IsValid())
 return 0;
 
-// initialize the extent
-DeviceCoordinate nMinPos = 0;
-DeviceCoordinate nMaxPos = 0;
-
+DeviceCoordinate nWidth = 0;
 for (auto const& aGlyphItem : m_GlyphItems)
-{
-// update the text extent with the glyph extent
-DeviceCoordinate nXPos = aGlyphItem.linearPos().getX() - 
aGlyphItem.xOffset();
-nMinPos = std::min(nMinPos, nXPos);
-nMaxPos = std::max(nMaxPos, nXPos + aGlyphItem.newWidth());
-}
+nWidth += aGlyphItem.newWidth();
 
-DeviceCoordinate nWidth = nMaxPos - nMinPos;
 return nWidth;
 }
 


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

2023-05-18 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx |   17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 3584fd0d110b4138ec32cf55ddd07e3fb8d81333
Author: Xisco Fauli 
AuthorDate: Thu May 18 11:09:51 2023 +0200
Commit: Xisco Fauli 
CommitDate: Thu May 18 15:30:46 2023 +0200

CppunitTest_vcl_filters_test: just pass the file name as parameter

Otherwise these files would be flagged as unused

Change-Id: I3203ef7820a6e5b31d48578d9184b5822836f27c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151940
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx 
b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
index 66153f463f78..6bbe34c50d2b 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-webp-test.cxx
@@ -57,7 +57,7 @@ public:
 
 private:
 void testRoundtrip(bool lossy);
-void testRead(bool lossy, bool alpha);
+void testRead(std::u16string_view rName, bool lossy, bool alpha);
 };
 
 bool WebpFilterTest::load(const OUString&, const OUString& rURL, const 
OUString&, SfxFilterFlags,
@@ -156,20 +156,19 @@ void WebpFilterTest::testRoundtrip(bool lossy)
  
vcl::getImportFormatShortName(aDetector.getMetadata().mnFormat));
 }
 
-void WebpFilterTest::testReadAlphaLossless() { testRead(false, true); }
+void WebpFilterTest::testReadAlphaLossless() { 
testRead(u"alpha_lossless.webp", false, true); }
 
-void WebpFilterTest::testReadAlphaLossy() { testRead(true, true); }
+void WebpFilterTest::testReadAlphaLossy() { testRead(u"alpha_lossy.webp", 
true, true); }
 
-void WebpFilterTest::testReadNoAlphaLossless() { testRead(false, false); }
+void WebpFilterTest::testReadNoAlphaLossless() { 
testRead(u"noalpha_lossless.webp", false, false); }
 
-void WebpFilterTest::testReadNoAlphaLossy() { testRead(true, false); }
+void WebpFilterTest::testReadNoAlphaLossy() { testRead(u"noalpha_lossy.webp", 
true, false); }
 
-void WebpFilterTest::testRead(bool lossy, bool alpha)
+void WebpFilterTest::testRead(std::u16string_view rName, bool lossy, bool 
alpha)
 {
 // Read a file created in GIMP and check it's read correctly.
-OUString file = 
m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/webp/")
-+ (alpha ? u"alpha" : u"noalpha") + "_" + (lossy ? 
u"lossy" : u"lossless")
-+ ".webp";
+OUString file
+= 
m_directories.getURLFromSrc(u"/vcl/qa/cppunit/graphicfilter/data/webp/") + 
rName;
 SvFileStream aFileStream(file, StreamMode::READ);
 Graphic aGraphic;
 GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();


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

2023-05-01 Thread Hossein (via logerrit)
 vcl/qa/cppunit/pdfexport/data/content-control-rtl.docx |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   53 +
 2 files changed, 53 insertions(+)

New commits:
commit 57f46a5a64f4e3bca2f0a52309ca7d201c1e2372
Author: Hossein 
AuthorDate: Wed Apr 26 13:38:20 2023 +0200
Commit: Hossein 
CommitDate: Mon May 1 13:00:48 2023 +0200

tdf#152246 Test position of RTL elements in PDF

This test checks the position of RTL/LTR elements in the exported PDF
files. Without the fix in place, the test fails because the RTL elements
will position as LTR, and the "Rect" element will be something else:

double equality assertion failed
- Expected: 303.349
- Actual  : 56.699
- Delta   : 1e-06

The Sample DOCX file contains both RTL and LTR content controls for testing.

One may run the test with:

 make CPPUNIT_TEST_NAME=testTdf152246 -sr CppunitTest_vcl_pdfexport

For an overview on PDF fill-in forms, please refer to:

James C. King, Introduction to the Insides of PDF, pages 81-85
https://www.adobe.com/technology/pdfs/presentations/KingPDFTutorial.pdf

Change-Id: I6c15b49bffb1aef6f137f7bb518a291f4d88b888
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151228
Tested-by: Jenkins
Reviewed-by: Hossein 

diff --git a/vcl/qa/cppunit/pdfexport/data/content-control-rtl.docx 
b/vcl/qa/cppunit/pdfexport/data/content-control-rtl.docx
new file mode 100644
index ..1b5fba455517
Binary files /dev/null and 
b/vcl/qa/cppunit/pdfexport/data/content-control-rtl.docx differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index a11e2a820506..4bdc920b3574 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4638,6 +4638,59 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportResourceItemReference)
 CPPUNIT_ASSERT(pFontWidths);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf152246)
+{
+// Import the bugdoc and export as PDF.
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"content-control-rtl.docx");
+
+// Parse the export result.
+vcl::filter::PDFDocument aDocument;
+SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
+CPPUNIT_ASSERT(aDocument.Read(aStream));
+
+// The document has one page.
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(static_cast(1), aPages.size());
+
+// Position array
+constexpr double aPos[5][4] = { { 56.699, 707.701, 131.401, 721.499 },
+{ 198.499, 707.701, 273.201, 721.499 },
+{ 303.349, 680.101, 378.051, 693.899 },
+{ 480.599, 680.101, 555.301, 693.899 },
+{ 56.699, 652.501, 131.401, 666.299 } };
+
+// Get page annotations.
+auto pAnnots = 
dynamic_cast(aPages[0]->Lookup("Annots"));
+CPPUNIT_ASSERT(pAnnots);
+CPPUNIT_ASSERT_EQUAL(static_cast(5), 
pAnnots->GetElements().size());
+for (sal_Int32 i = 0; i < 5; ++i)
+{
+auto pAnnotReference
+= 
dynamic_cast(pAnnots->GetElements()[i]);
+CPPUNIT_ASSERT(pAnnotReference);
+vcl::filter::PDFObjectElement* pAnnot = 
pAnnotReference->LookupObject();
+CPPUNIT_ASSERT(pAnnot);
+CPPUNIT_ASSERT_EQUAL(
+OString("Annot"),
+
static_cast(pAnnot->Lookup("Type"))->GetValue());
+CPPUNIT_ASSERT_EQUAL(
+OString("Widget"),
+
static_cast(pAnnot->Lookup("Subtype"))->GetValue());
+
+auto pRect = 
dynamic_cast(pAnnot->Lookup("Rect"));
+CPPUNIT_ASSERT(pRect);
+const auto& rElements = pRect->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(4), rElements.size());
+for (sal_Int32 nIdx = 0; nIdx < 4; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(aPos[i][nIdx], 
pNumElement->GetValue(), 1e-6);
+}
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();


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

2023-04-11 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/outdev.cxx |  234 +++---
 1 file changed, 57 insertions(+), 177 deletions(-)

New commits:
commit 886fb2fe7275469a7bd586b99705784a012c67f6
Author: Xisco Fauli 
AuthorDate: Tue Apr 11 11:59:59 2023 +0200
Commit: Xisco Fauli 
CommitDate: Tue Apr 11 14:29:53 2023 +0200

CppunitTest_vcl_outdev: use CPPUNIT_TEST_FIXTURE()

This suite is large enough so that avoiding the
declaration/registration/definition of each test manually saves a lot of
space.

Change-Id: Icfbfede5663d93eca10d7585313b51c3e19303bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150223
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 99fb0b9be7d9..e9576c42221e 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -39,133 +39,15 @@ public:
 : BootstrapFixture(true, false)
 {
 }
-
-void testVirtualDevice();
-void testUseAfterDispose();
-void testPrinterBackgroundColor();
-void testWindowBackgroundColor();
-void testGetReadableFontColorPrinter();
-void testGetReadableFontColorWindow();
-void testDrawInvertedBitmap();
-void testDrawBlackBitmap();
-void testDrawWhiteBitmap();
-void testDrawGrayBitmap();
-void testDrawBitmap();
-void testDrawScaleBitmap();
-void testDrawScalePartBitmap();
-void testDrawTransformedBitmapEx();
-void testDrawTransformedBitmapExFlip();
-void testRTL();
-void testRTLGuard();
-void testDefaultFillColor();
-void testTransparentFillColor();
-void testFillColor();
-void testDefaultLineColor();
-void testTransparentLineColor();
-void testLineColor();
-void testFont();
-void testTransparentFont();
-void testDefaultRefPoint();
-void testRefPoint();
-void testRasterOp();
-void testOutputFlag();
-void testAntialias();
-void testDrawMode();
-void testLayoutMode();
-void testDigitLanguage();
-void testStackFunctions();
-void testSystemTextColor();
-void testShouldDrawWavePixelAsRect();
-void testGetWaveLineSize();
-void testErase();
-void testDrawPixel();
-void testDrawLine();
-void testDrawRect();
-void testDrawArc();
-void testDrawEllipse();
-void testDrawPie();
-void testDrawChord();
-void testDrawCheckered();
-void testDrawBorder();
-void testDrawWaveLine();
-void testDrawPolyLine();
-void testDrawPolygon();
-void testDrawPolyPolygon();
-void testDrawGradient_drawmode();
-void testDrawGradient_rect_linear();
-void testDrawGradient_rect_axial();
-void testDrawGradient_polygon_linear();
-void testDrawGradient_polygon_axial();
-void testDrawGradient_rect_complex();
-
-CPPUNIT_TEST_SUITE(VclOutdevTest);
-CPPUNIT_TEST(testVirtualDevice);
-CPPUNIT_TEST(testUseAfterDispose);
-CPPUNIT_TEST(testPrinterBackgroundColor);
-CPPUNIT_TEST(testWindowBackgroundColor);
-CPPUNIT_TEST(testDrawInvertedBitmap);
-CPPUNIT_TEST(testDrawBlackBitmap);
-CPPUNIT_TEST(testDrawWhiteBitmap);
-CPPUNIT_TEST(testDrawGrayBitmap);
-CPPUNIT_TEST(testDrawBitmap);
-CPPUNIT_TEST(testDrawScaleBitmap);
-CPPUNIT_TEST(testDrawScalePartBitmap);
-CPPUNIT_TEST(testGetReadableFontColorPrinter);
-CPPUNIT_TEST(testGetReadableFontColorWindow);
-CPPUNIT_TEST(testDrawTransformedBitmapEx);
-CPPUNIT_TEST(testDrawTransformedBitmapExFlip);
-CPPUNIT_TEST(testRTL);
-CPPUNIT_TEST(testRTLGuard);
-CPPUNIT_TEST(testDefaultFillColor);
-CPPUNIT_TEST(testTransparentFillColor);
-CPPUNIT_TEST(testFillColor);
-CPPUNIT_TEST(testDefaultLineColor);
-CPPUNIT_TEST(testTransparentLineColor);
-CPPUNIT_TEST(testLineColor);
-CPPUNIT_TEST(testFont);
-CPPUNIT_TEST(testTransparentFont);
-CPPUNIT_TEST(testDefaultRefPoint);
-CPPUNIT_TEST(testRefPoint);
-CPPUNIT_TEST(testRasterOp);
-CPPUNIT_TEST(testOutputFlag);
-CPPUNIT_TEST(testAntialias);
-CPPUNIT_TEST(testDrawMode);
-CPPUNIT_TEST(testLayoutMode);
-CPPUNIT_TEST(testDigitLanguage);
-CPPUNIT_TEST(testStackFunctions);
-CPPUNIT_TEST(testSystemTextColor);
-CPPUNIT_TEST(testShouldDrawWavePixelAsRect);
-CPPUNIT_TEST(testGetWaveLineSize);
-CPPUNIT_TEST(testErase);
-CPPUNIT_TEST(testDrawPixel);
-CPPUNIT_TEST(testDrawLine);
-CPPUNIT_TEST(testDrawRect);
-CPPUNIT_TEST(testDrawArc);
-CPPUNIT_TEST(testDrawEllipse);
-CPPUNIT_TEST(testDrawPie);
-CPPUNIT_TEST(testDrawChord);
-CPPUNIT_TEST(testDrawCheckered);
-CPPUNIT_TEST(testDrawBorder);
-CPPUNIT_TEST(testDrawWaveLine);
-CPPUNIT_TEST(testDrawPolyLine);
-CPPUNIT_TEST(testDrawPolygon);
-CPPUNIT_TEST(testDrawPolyPolygon);
-CPPUNIT_TEST(testDrawGradient_drawmode);
-CPPUNIT_TEST(testDrawGradient_rect_linear);
-CPPUNIT_TEST(testDrawGradient_rect_axial);
-CPPUNIT_TEST(testDr

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

2023-04-05 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf154549.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   33 
 2 files changed, 33 insertions(+)

New commits:
commit 8c3e219a831719ebb40dd2af8a26b0a24ad7aba1
Author: Xisco Fauli 
AuthorDate: Mon Apr 3 16:45:30 2023 +0200
Commit: Xisco Fauli 
CommitDate: Wed Apr 5 20:43:43 2023 +0200

tdf#154549: vcl_pdfexport: Add unittest

Change-Id: Ia2865346e966cdd4b64ed588a29cc1e760d36c73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149969
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf154549.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf154549.odt
new file mode 100644
index ..09ed1324ecbb
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf154549.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index beb1a1daf50c..65e1a06a4b99 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1216,6 +1216,39 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115117_2a)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf154549)
+{
+// FIXME: On Windows, the number of chars is 4 instead of 3
+#ifndef _WIN32
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"tdf154549.odt");
+
+// Parse the export result with pdfium.
+std::unique_ptr pPdfDocument = parsePDFExport();
+
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage);
+
+std::unique_ptr pPdfTextPage = 
pPdfPage->getTextPage();
+CPPUNIT_ASSERT(pPdfTextPage);
+
+int nChars = pPdfTextPage->countChars();
+
+CPPUNIT_ASSERT_EQUAL(3, nChars);
+
+std::vector aChars(nChars);
+for (int i = 0; i < nChars; i++)
+aChars[i] = pPdfTextPage->getUnicode(i);
+OUString aActualText(aChars.data(), aChars.size());
+
+// Without the fix in place, this test would have failed with
+// - Expected: ִبي
+// - Actual  : بִي
+CPPUNIT_ASSERT_EQUAL(OUString(u"\u05B4\u0628\u064A"), aActualText);
+#endif
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf150846)
 {
 // Without the fix in place, this test would have failed with


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

2023-03-30 Thread Noel Grandin (via logerrit)
 vcl/qa/cppunit/BitmapTest.cxx  |   10 
 vcl/source/app/svmain.cxx  |   14 
 vcl/source/control/field.cxx   |9 
 vcl/source/control/fmtfield.cxx|   26 -
 vcl/source/control/throbber.cxx|   12 
 vcl/source/filter/ipdf/pdfdocument.cxx |   40 +-
 vcl/source/gdi/mtfxmldump.cxx  |5 
 vcl/source/gdi/pdfobjectcopier.cxx |8 
 vcl/source/gdi/pdfwriter_impl.cxx  |  530 +++--
 vcl/source/gdi/print3.cxx  |3 
 vcl/source/treelist/headbar.cxx|3 
 vcl/source/treelist/imap2.cxx  |3 
 vcl/source/treelist/transfer.cxx   |   10 
 vcl/source/window/printdlg.cxx |7 
 vcl/unx/generic/fontmanager/helper.cxx |7 
 vcl/unx/generic/print/glyphset.cxx |6 
 vcl/unx/generic/print/printerjob.cxx   |   38 +-
 vcl/unx/generic/printer/jobdata.cxx|   55 +--
 vcl/unx/generic/printer/ppdparser.cxx  |   18 -
 vcl/unx/gtk3/gtkinst.cxx   |6 
 20 files changed, 359 insertions(+), 451 deletions(-)

New commits:
commit a5084d15e1b72e303e1628fbff84432036b014a9
Author: Noel Grandin 
AuthorDate: Thu Mar 30 10:42:07 2023 +0200
Commit: Noel Grandin 
CommitDate: Thu Mar 30 13:36:59 2023 +

loplugin:stringadd in vcl

when applying my upcoming patch to also consider O[U]StringBuffer

Change-Id: I44ce7183e4b292269fac1e3d2217286bf5abe823
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149752
Tested-by: Noel Grandin 
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 98fabd569f24..dfcf44a8f6a7 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -330,13 +330,9 @@ void checkAndInsert(CRCHash& rHash, sal_uInt64 nCRC, const 
char* pLocation)
 auto it = rHash.find(nCRC);
 if (it != rHash.end())
 {
-OStringBuffer aBuf("CRC collision between ");
-aBuf.append(pLocation);
-aBuf.append(" and ");
-aBuf.append(it->second);
-aBuf.append(" hash is 0x");
-aBuf.append(static_cast(nCRC), 16);
-CPPUNIT_FAIL(aBuf.toString().getStr());
+OString aBuf = OString::Concat("CRC collision between ") + pLocation + 
" and " + it->second
+   + " hash is 0x" + 
OString::number(static_cast(nCRC), 16);
+CPPUNIT_FAIL(aBuf.getStr());
 }
 rHash[nCRC] = pLocation;
 }
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 571be29579bc..ab461912724f 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -456,13 +456,13 @@ void DeInitVCL()
 nBadTopWindows--;
 else
 {
-aBuf.append( "text = \"" );
-aBuf.append( OUStringToOString( pWin->GetText(), 
osl_getThreadTextEncoding() ) );
-aBuf.append( "\" type = \"" );
-aBuf.append( typeid(*pWin).name() );
-aBuf.append( "\", ptr = 0x" );
-aBuf.append( reinterpret_cast( pWin ), 16 );
-aBuf.append( "\n" );
+aBuf.append( "text = \""
++ OUStringToOString( pWin->GetText(), 
osl_getThreadTextEncoding() )
++ "\" type = \""
++ typeid(*pWin).name()
++ "\", ptr = 0x"
++ OString::number(reinterpret_cast( pWin ), 16 )
++ "\n" );
 }
 }
 SAL_WARN_IF( nBadTopWindows!=0, "vcl", aBuf.getStr() );
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index 0bd9ebab713e..3de0eaf50165 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -314,8 +314,7 @@ bool ImplNumericGetValue( const OUString& rStr, sal_Int64& 
rValue,
 sal_Int64 nDenom = o3tl::toInt64(aStrDenom);
 if (nDenom == 0) return false; // Division by zero
 double nFrac2Dec = nWholeNum + static_cast(nNum)/nDenom; // 
Convert to double for floating point precision
-OUStringBuffer aStrFrac;
-aStrFrac.append(nFrac2Dec);
+OUStringBuffer aStrFrac(OUString::number(nFrac2Dec));
 // Reconvert division result to string and parse
 nDecPos = aStrFrac.indexOf('.');
 if ( nDecPos >= 0)
@@ -383,14 +382,12 @@ void ImplUpdateSeparatorString( OUString& io_rText,
|| (nIndexTh != -1 && nIndexDec == -1)
)
 {
-aBuf.append( pBuffer + nIndex, nIndexTh - nIndex );
-aBuf.append( rNewThSep );
+aBuf.append( OUString::Concat(std::u16string_view(pBuffer + 
nIndex, nIndexTh - nIndex )) + rNewThSep );
 nIndex = nIndexTh + rOldThSep.size();
 }
 else if( nIndexDec != -1 )
 {
-aBuf.append( pBuffer + nIndex, nIndexDec - nIndex );
-aBuf.append( rNewDecSep );
+aBuf.append( OUString::Concat(std::u16string_view(pBuffer + 
nIndex, nIndexDec - nIndex )) + rNewDecSep );
 nIndex = nIndexDec + rOldDec

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

2023-03-22 Thread Michael Stahl (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   12 +++--
 vcl/source/gdi/pdfwriter_impl.cxx  |   42 +
 2 files changed, 42 insertions(+), 12 deletions(-)

New commits:
commit d41c3c820dad7c78bc57815e0f4a6999d125561d
Author: Michael Stahl 
AuthorDate: Mon Mar 20 20:40:13 2023 +0100
Commit: Michael Stahl 
CommitDate: Wed Mar 22 11:55:55 2023 +

vcl: PDF/UA export: produce UF and Desc for embedded files

  7.11 Embedded files
  The file specification dictionary for an embedded file shall contain
  the F and UF keys and should contain the Desc key (ISO 32000-1:2008,
  7.11.3, Table 44.).

Also write Alt text as hex/unicode string, not literal string.

Change-Id: Id83597cc5ea645bd57c110514bafede433aee572
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149259
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 4304846c9834..448ba4ba24ed 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3610,13 +3610,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testMediaShapeAnnot)
 CPPUNIT_ASSERT(pR);
 auto pC = 
dynamic_cast(pR->LookupElement("C"));
 CPPUNIT_ASSERT(pC);
+auto pD = 
dynamic_cast(pC->LookupElement("D"));
+CPPUNIT_ASSERT(pD);
+auto pDesc = 
dynamic_cast(pD->LookupElement("Desc"));
+CPPUNIT_ASSERT(pDesc);
+CPPUNIT_ASSERT_EQUAL(OUString("alternativloser text\nand some 
description"),
+ 
::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pDesc));
 auto pAlt = 
dynamic_cast(pC->LookupElement("Alt"));
 CPPUNIT_ASSERT(pAlt);
 auto pLang = 
dynamic_cast(pAlt->GetElement(0));
 CPPUNIT_ASSERT_EQUAL(OString(""), pLang->GetValue());
-auto pAltText = 
dynamic_cast(pAlt->GetElement(1));
-CPPUNIT_ASSERT_EQUAL(OString("alternativloser text\\nand some 
description"),
- pAltText->GetValue());
+auto pAltText = 
dynamic_cast(pAlt->GetElement(1));
+CPPUNIT_ASSERT_EQUAL(OUString("alternativloser text\nand some 
description"),
+ 
::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAltText));
 
 auto pStructParent
 = 
dynamic_cast(pAnnot->Lookup("StructParent"));
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f6776c1d560b..3fe6430fc000 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3607,17 +3607,33 @@ bool PDFWriterImpl::emitScreenAnnotations()
 aLine.append("/C<) /EF << /F 
");
+aLine.append("\n/D << /Type /Filespec /F () ");
+if (PDFWriter::PDFVersion::PDF_1_7 <= m_aContext.Version)
+{   // ISO 14289-1:2014, Clause: 7.11
+aLine.append("/UF () ");
+}
+aLine.append("/EF << /F ");
 aLine.append(rScreen.m_nTempFileObject);
-aLine.append(" 0 R >> >>");
+aLine.append(" 0 R >>");
 }
 else
 {
 // Linked.
-aLine.append("/D << /Type /Filespec /FS /URL /F ");
+aLine.append("\n/D << /Type /Filespec /FS /URL /F ");
 appendLiteralStringEncrypt(rScreen.m_aURL, rScreen.m_nObject, 
aLine, osl_getThreadTextEncoding());
-aLine.append(" >>");
+if (PDFWriter::PDFVersion::PDF_1_7 <= m_aContext.Version)
+{   // ISO 14289-1:2014, Clause: 7.11
+aLine.append("/UF ");
+appendUnicodeTextStringEncrypt(rScreen.m_aURL, 
rScreen.m_nObject, aLine);
+}
+}
+if (PDFWriter::PDFVersion::PDF_1_6 <= m_aContext.Version
+&& !rScreen.m_AltText.isEmpty())
+{   // ISO 14289-1:2014, Clause: 7.11
+aLine.append("/Desc ");
+appendUnicodeTextStringEncrypt(rScreen.m_AltText, 
rScreen.m_nObject, aLine);
 }
+aLine.append(" >>\n"); // end of /D
 // Allow playing the video via a tempfile.
 aLine.append("/P <>");
 // ISO 14289-1:2014, Clause: 7.18.6.2
@@ -3626,7 +3642,7 @@ bool PDFWriterImpl::emitScreenAnnotations()
 // ISO 14289-1:2014, Clause: 7.18.6.2
 // Alt text is a "Multi-language Text Array"
 aLine.append(" /Alt [ () ");
-appendLiteralStringEncrypt(rScreen.m_AltText, rScreen.m_nObject, 
aLine, osl_getThreadTextEncoding());
+appendUnicodeTextStringEncrypt(rScreen.m_AltText, rScreen.m_nObject, 
aLine);
 aLine.append(" ] ");
 aLine.append(">>");
 
@@ -5207,9 +5223,12 @@ bool PDFWriterImpl::emitCatalog()
 aLine.append("/F<");
 PDFWriter::AppendUnicodeTextString(rAttachedFile.maFilename, aLine);
 aLine.append("> ");
-aLine.append("/UF<");
-PDFWriter::AppendUnicodeTextString(rAttachedFile.maFilename, aLine);
-aLine.append("> ");
+if (PD

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

2023-03-14 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf139065.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   15 +++
 2 files changed, 15 insertions(+)

New commits:
commit 4b695a28ff01a0ee27186dfc583da6facad06de8
Author: Xisco Fauli 
AuthorDate: Mon Mar 13 17:04:10 2023 +0100
Commit: Xisco Fauli 
CommitDate: Tue Mar 14 14:11:40 2023 +

tdf#139065: vcl_pdfexport: Add unittest

Change-Id: Ic185f4e9bd26844b01cf3df61c9b4bcf3b637e6f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148798
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf139065.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf139065.odt
new file mode 100644
index ..f8ffa26b2f26
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf139065.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ed27ecac3bbf..d04f3e98f75f 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1900,6 +1900,21 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf121962)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139065)
+{
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"tdf139065.odt");
+std::unique_ptr pPdfDocument = parsePDFExport();
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage);
+
+// Without the fix in place, this test would have failed with
+// - Expected: 15
+// - Actual  : 6
+CPPUNIT_ASSERT_EQUAL(15, pPdfPage->getObjectCount());
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115967)
 {
 aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");


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

2023-03-07 Thread Jaume Pujantell (via logerrit)
 vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf |   55 
++
 vcl/qa/cppunit/filter/ipdf/ipdf.cxx  |   25 

 vcl/source/filter/ipdf/pdfdocument.cxx   |   45 

 3 files changed, 125 insertions(+)

New commits:
commit 574e89ccda1b389faca9f3e44d909a71b5599473
Author: Jaume Pujantell 
AuthorDate: Fri Mar 3 19:25:11 2023 +0100
Commit: Andras Timar 
CommitDate: Tue Mar 7 08:36:01 2023 +

Fix a bug parsing pdf arrays

The parser ignored number elements in some situations, like before
a reference element. This manifested in creating an invalid pdf
file when exporting as pdf a document that contains a pdf.

Change-Id: I98625c8da8631056079814f7e824f36177cf41c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148198
Tested-by: Jenkins
Reviewed-by: Andras Timar 

diff --git 
a/vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf 
b/vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf
new file mode 100644
index ..01030ecf88bc
--- /dev/null
+++ b/vcl/qa/cppunit/filter/ipdf/data/array-mixed-numbers-and-elements.pdf
@@ -0,0 +1,55 @@
+%PDF-1.7
+%���
+1 0 obj <<
+  /Type /Catalog
+  /Pages 2 0 R
+>>
+endobj
+2 0 obj <<
+  /Type /Pages
+  /MediaBox [0 0 200 300]
+  /Count 1
+  /Kids [3 0 R]
+>>
+endobj
+3 0 obj <<
+  /Type /Page
+  /Parent 2 0 R
+  /Contents 4 0 R
+  /Test [1 4 0 R 3 false 5 (Lieral) 7 <90>]
+>>
+endobj
+4 0 obj <<
+  /Length 188
+>>
+stream
+q
+0 0 0 rg
+0 290 10 10 re B*
+10 150 50 30 re B*
+0 0 1 rg
+190 290 10 10 re B*
+70 232 50 30 re B*
+0 1 0 rg
+190 0 10 10 re B*
+130 150 50 30 re B*
+1 0 0 rg
+0 0 10 10 re B*
+70 67 50 30 re B*
+Q
+endstream
+endobj
+xref
+0 5
+00 65535 f 
+15 0 n 
+68 0 n 
+000157 0 n 
+000270 0 n 
+trailer <<
+  /Root 1 0 R
+  /Size 5
+>>
+startxref
+510
+%%EOF
diff --git a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx 
b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx
index 1c143a1b8319..c27555ca1d70 100644
--- a/vcl/qa/cppunit/filter/ipdf/ipdf.cxx
+++ b/vcl/qa/cppunit/filter/ipdf/ipdf.cxx
@@ -186,6 +186,31 @@ CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testCommentEnd)
 CPPUNIT_ASSERT(aDocument.Read(aFile));
 }
 
+CPPUNIT_TEST_FIXTURE(VclFilterIpdfTest, testMixedArrayWithNumbers)
+{
+// Load a file that has markup like this:
+// 3 0 obj <<
+//  /Test [1 4 0 R 3 false 5 (Lieral) 7 <90>]
+// >>
+OUString aSourceURL = 
createFileURL(u"array-mixed-numbers-and-elements.pdf");
+SvFileStream aFile(aSourceURL, StreamMode::READ);
+vcl::filter::PDFDocument aDocument;
+CPPUNIT_ASSERT(aDocument.Read(aFile));
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT(!aPages.empty());
+vcl::filter::PDFObjectElement* pPage = aPages[0];
+auto pTest = 
dynamic_cast(pPage->Lookup("Test"));
+std::vector aElements = pTest->GetElements();
+
+// Without the accompanying fix in place, this test would have failed with
+// the array containing the wrong number of elements and in the incorrect 
order
+CPPUNIT_ASSERT_EQUAL(8, static_cast(aElements.size()));
+CPPUNIT_ASSERT(dynamic_cast(aElements[0]));
+CPPUNIT_ASSERT(dynamic_cast(aElements[2]));
+CPPUNIT_ASSERT(dynamic_cast(aElements[4]));
+CPPUNIT_ASSERT(dynamic_cast(aElements[6]));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 19748e241ead..5ff50d3b55ac 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -3248,6 +3248,18 @@ size_t PDFObjectParser::parse(PDFElement* 
pParsingElement, size_t nStartIndex, i
 }
 else if (auto pReference = 
dynamic_cast(pCurrentElement))
 {
+// Handle previously stored number
+if (aNumbers.size() > 2)
+{
+aNumbers.resize(aNumbers.size() - 2);
+if (pParsingArray)
+{
+for (auto& pNumber : aNumbers)
+pParsingArray->PushBack(pNumber);
+}
+aNumbers.clear();
+}
+
 if (pParsingArray)
 {
 pParsingArray->PushBack(pReference);
@@ -3268,6 +3280,17 @@ size_t PDFObjectParser::parse(PDFElement* 
pParsingElement, size_t nStartIndex, i
 }
 else if (auto pLiteralString = 
dynamic_cast(pCurrentElement))
 {
+// Handle previously stored number
+if (!aNumbers.empty())
+{
+if (pParsingArray)
+{
+for (auto& pNumber : aNumbers)
+pParsingArray->PushBack(pNumber);
+}
+aNumbers.clear();
+}
+
 if (pParsingArray)
 {
 

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

2023-03-05 Thread Sarper Akdemir (via logerrit)
 vcl/qa/cppunit/png/PngFilterTest.cxx |   53 +++
 vcl/source/filter/png/PngImageWriter.cxx |   35 +++-
 2 files changed, 79 insertions(+), 9 deletions(-)

New commits:
commit c010b8cc712d1336ed79fb220764f1a850dc22e5
Author: Sarper Akdemir 
AuthorDate: Wed Jan 25 15:36:59 2023 +0300
Commit: Tomaž Vajngerl 
CommitDate: Sun Mar 5 10:55:44 2023 +

tdf#153180: PngImageWriter add support for gray alpha colortype

8 bit grayscale images can have alpha accompanying it, and
PNG supports 2 channel gray-alpha images.

libpng supports this with the use of colortype
PNG_COLOR_TYPE_GRAY_ALPHA.

This patch adds support for writing GRAY_ALPHA colorType PNG
images.

This is done by expanding what was in place for
ScanlineFormat::N24BitTcRgb with alpha PNG_COLOR_TYPE_RGBA.

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

diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx 
b/vcl/qa/cppunit/png/PngFilterTest.cxx
index dae007eb7898..fc3963c356e8 100644
--- a/vcl/qa/cppunit/png/PngFilterTest.cxx
+++ b/vcl/qa/cppunit/png/PngFilterTest.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -176,6 +177,7 @@ public:
 void testPngRoundtrip24_8();
 void testPngRoundtrip32();
 void testPngWrite8BitRGBPalette();
+void testTdf153180MonochromeFilterPngExport();
 void testDump();
 
 CPPUNIT_TEST_SUITE(PngFilterTest);
@@ -188,6 +190,7 @@ public:
 CPPUNIT_TEST(testPngRoundtrip32);
 CPPUNIT_TEST(testPngWrite8BitRGBPalette);
 CPPUNIT_TEST(testDump);
+CPPUNIT_TEST(testTdf153180MonochromeFilterPngExport);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -1958,6 +1961,56 @@ void PngFilterTest::testPngWrite8BitRGBPalette()
 }
 }
 
+void PngFilterTest::testTdf153180MonochromeFilterPngExport()
+{
+GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+
+Graphic aGraphicOriginal;
+{
+// 3 * 16 bits rgb color alpha, no background chunk
+const OUString aURL(getFullUrl(u"bgan6a16.png"));
+SvFileStream aFileStream(aURL, StreamMode::READ);
+ErrCode aResult = rFilter.ImportGraphic(aGraphicOriginal, aURL, 
aFileStream);
+CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aResult);
+CPPUNIT_ASSERT(aGraphicOriginal.IsAlpha());
+}
+
+// Apply the monochrome filter to the graphic but keep the alpha.
+BitmapEx aBitmapEx(aGraphicOriginal.GetBitmapEx());
+AlphaMask aAlphaMask(aBitmapEx.GetAlphaMask());
+
+BitmapEx aTmpBmpEx(aBitmapEx.GetBitmap());
+BitmapFilter::Filter(aTmpBmpEx, BitmapMonochromeFilter{ sal_uInt8{ 127 } 
});
+
+Graphic aGraphicAfterFilter{ BitmapEx(aTmpBmpEx.GetBitmap(), aAlphaMask) };
+CPPUNIT_ASSERT(aGraphicAfterFilter.IsAlpha());
+
+// export the resulting graphic
+utl::TempFileNamed aTempFile(u"testPngExportTdf153180", true, u".png");
+if (!bKeepTemp)
+aTempFile.EnableKillingFile();
+{
+SvStream& rStream = *aTempFile.GetStream(StreamMode::WRITE);
+vcl::PngImageWriter aPngWriter(rStream);
+bool bWriteSuccess = 
aPngWriter.write(aGraphicAfterFilter.GetBitmapEx());
+CPPUNIT_ASSERT_EQUAL(true, bWriteSuccess);
+aTempFile.CloseStream();
+}
+{
+SvStream& rStream = *aTempFile.GetStream(StreamMode::READ);
+rStream.Seek(0);
+// Import the png and check that it still has alpha
+Graphic aGraphic;
+ErrCode aResult = rFilter.ImportGraphic(aGraphic, aTempFile.GetURL(), 
rStream);
+CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, aResult);
+
+// Without the accompanying patch would fail with:
+// assertion failed
+// -Expression : aGraphic.IsAlpha()
+CPPUNIT_ASSERT(aGraphic.IsAlpha());
+}
+}
+
 void PngFilterTest::testDump()
 {
 utl::TempFileNamed aTempFile;
diff --git a/vcl/source/filter/png/PngImageWriter.cxx 
b/vcl/source/filter/png/PngImageWriter.cxx
index 35ccefaec2c7..914302223d6a 100644
--- a/vcl/source/filter/png/PngImageWriter.cxx
+++ b/vcl/source/filter/png/PngImageWriter.cxx
@@ -15,15 +15,25 @@
 
 namespace
 {
-void combineScanlineChannels(Scanline pRGBScanline, Scanline pAlphaScanline,
+void combineScanlineChannels(Scanline pColorScanline, Scanline pAlphaScanline,
  std::vector>& 
pResult,
- sal_uInt32 nBitmapWidth)
+ sal_uInt32 nBitmapWidth, int colorType)
 {
+if (colorType == PNG_COLOR_TYPE_GRAY_ALPHA)
+{
+for (sal_uInt32 i = 0; i < nBitmapWidth; ++i)
+{
+pResult[i * 2] = *pColorScanline++; // Gray
+pResult[i * 2 + 1] = *pAlphaScanline++; // A
+}
+return;
+}
+
 for (sal_uInt32 i = 0; i < nBitmapWidth; ++i)
 {
-pResult[i * 4] = *pRGBSca

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

2023-01-15 Thread Tomaž Vajngerl (via logerrit)
 vcl/qa/cppunit/svm/svmtest.cxx |   36 ++---
 vcl/source/gdi/mtfxmldump.cxx  |   70 +
 2 files changed, 89 insertions(+), 17 deletions(-)

New commits:
commit 28edd79792a4b0ae7665a23bfbebb9499416daef
Author: Tomaž Vajngerl 
AuthorDate: Sat Jan 14 16:45:15 2023 +0900
Commit: Tomaž Vajngerl 
CommitDate: Sun Jan 15 08:07:41 2023 +

vcl: add more device independent checks for bitmaps in svmtest

Adds writing of "contentchecksum" to MetafileXmlDump, which sums
the content of all the colors in an device independent way, by
reading the each pixel color from the bitmap and summing each
component always in RGBA order.

In addition add some others bitmap attributes not checked before,
like bitmap width, height and pixel format.

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

diff --git a/vcl/qa/cppunit/svm/svmtest.cxx b/vcl/qa/cppunit/svm/svmtest.cxx
index 02cec9bcfd45..e8925ffda064 100644
--- a/vcl/qa/cppunit/svm/svmtest.cxx
+++ b/vcl/qa/cppunit/svm/svmtest.cxx
@@ -1005,8 +1005,7 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& 
rMetaFile, bool bIsSvmFile)
 if (SkiaHelper::isVCLSkiaEnabled())
 return; // TODO SKIA using CRCs is broken (the idea of it)
 
-std::vector aExpectedCRC;
-aExpectedCRC.insert(aExpectedCRC.end(),
+std::array aExpectedCRC
 {
 #if defined OSL_BIGENDIAN
 "08feb5d3",
@@ -1027,39 +1026,54 @@ void SvmTest::checkBitmapExs(const GDIMetaFile& 
rMetaFile, bool bIsSvmFile)
 "3c80d829",
 "71efc447",
 #endif
-});
+};
+
+std::array aExpectedContentChecksum
+{
+"26bdebd04e5b18d685cea04982179e273ee3b659",
+"f4f52df6ef965a2f0fbccbe6aca35ba3457cf9d5",
+"7c953a06d34bbd38897f950d595df2880dbb0f75",
+"ca3e5cdde1c395e1ee76d339a5bf6e46fbac3249",
+"8a1ebc46f890eb0879464c6e293bffd4ce7fadc0", // 1-bit
+"23611fc9f484c23e45bbd457730adb8ab5355509", // 4-bit color bitmap - 
same as 8-bit color bitmap
+"23611fc9f484c23e45bbd457730adb8ab5355509",
+"97e499b74104debf12f99a774a2c4edc914d8900",
+};
 
 assertXPathAttrs(pDoc, "/metafile/bmpex[1]", {
-{"x", "1"}, {"y", "1"}, {"crc", aExpectedCRC[0]}, {"transparenttype", 
"bitmap"}
+{"x", "1"}, {"y", "1"}, {"crc", aExpectedCRC[0]}, {"transparenttype", 
"bitmap"}, {"contentchecksum", aExpectedContentChecksum[0]}, {"pixelformat", 
"24BPP"}
 });
 assertXPathAttrs(pDoc, "/metafile/bmpexscale[1]", {
 {"x", "5"}, {"y", "0"}, {"width", "2"}, {"height", "3"},
-{"crc", aExpectedCRC[1]}, {"transparenttype", "bitmap"}
+{"crc", aExpectedCRC[1]}, {"transparenttype", "bitmap"}, 
{"contentchecksum", aExpectedContentChecksum[1]}, {"pixelformat", "24BPP"}
 });
 assertXPathAttrs(pDoc, "/metafile/bmpexscalepart[1]", {
 {"destx", "7"}, {"desty", "1"}, {"destwidth", "2"}, {"destheight", 
"2"},
 {"srcx", "0"},  {"srcy", "0"},  {"srcwidth", "3"},  {"srcheight", "4"},
-{"crc", aExpectedCRC[2]}, {"transparenttype", "bitmap"}
+{"crc", aExpectedCRC[2]}, {"transparenttype", "bitmap"}, 
{"contentchecksum", aExpectedContentChecksum[2]}, {"pixelformat", "24BPP"}
 });
 
 #ifndef MACOSX
 assertXPathAttrs(pDoc, "/metafile/bmpex[2]", {
-{"x", "6"}, {"y", "6"}, {"crc", aExpectedCRC[3]}, {"transparenttype", 
"bitmap"}
+{"x", "6"}, {"y", "6"}, {"crc", aExpectedCRC[3]}, {"transparenttype", 
"bitmap"}, {"contentchecksum", aExpectedContentChecksum[3]}
+});
+assertXPathAttrs(pDoc, "/metafile/bmpex[3]", {
+{"x", "0"}, {"y", "6"}, {"transparenttype", "bitmap"}, 
{"contentchecksum", aExpectedContentChecksum[4]}, {"pixelformat", "8BPP"}
 });
 if (!bIsSvmFile)
 {
 assertXPathAttrs(pDoc, "/metafile/bmpex[3]", {
-{"x", "0"}, {"y", "6"}, {"crc", aExpectedCRC[4]}, 
{"transparenttype", "bitmap"}
+{"crc", aExpectedCRC[4]}
 });
 }
 assertXPathAttrs(pDoc, "/metafile/bmpex[4]", {
-{"x", "2"}, {"y", "6"}, {"crc", aExpectedCRC[5]}, {"transparenttype", 
"bitmap"}
+{"x", "2"}, {"y", "6"}, {"crc", aExpectedCRC[5]}, {"transparenttype", 
"bitmap"}, {"contentchecksum", aExpectedContentChecksum[5]}, {"pixelformat", 
"8BPP"}
 });
 assertXPathAttrs(pDoc, "/metafile/bmpex[5]", {
-{"x", "0"}, {"y", "8"}, {"crc", aExpectedCRC[6]}, {"transparenttype", 
"bitmap"}
+{"x", "0"}, {"y", "8"}, {"crc", aExpectedCRC[6]}, {"transparenttype", 
"bitmap"}, {"contentchecksum", aExpectedContentChecksum[6]}, {"pixelformat", 
"8BPP"}
 });
 assertXPathAttrs(pDoc, "/metafile/bmpex[6]", {
-{"x", "2"}, {"y", "8"}, {"crc", aExpectedCRC[7]}, {"transparenttype", 
"bitmap"}
+{"x", "2"}, {"y", "8"}, {"crc", aExpectedCRC[7]}, {"transparenttype", 
"bitma

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

2023-01-12 Thread Stephan Bergmann (via logerrit)
 vcl/qa/cppunit/text.cxx |   13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

New commits:
commit 933519505aee0e91ca99af0ed860e4a0f148f922
Author: Stephan Bergmann 
AuthorDate: Thu Jan 12 16:42:39 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Jan 12 19:08:03 2023 +

Fix VclTextTest with colorized antialiasing

The Flathub build for


"Merge pull request #206 from flathub/lo-7.4.4" on 2023-01-12 at
 consistently 
failed for
both aarch64 and x86_64 builds with

> text.cxx:260:Assertion
> Test name: VclTextTest::testSimpleText
> double equality assertion failed
> - Expected: 28
> - Actual  : -1
> - Delta   : 2

during CppunitTest_vcl_text.  The reason (as seen with a temporary build 
setting
mbExportBitmap = true and looking at the resulting
workdir/CppunitTest/vcl_text.test.core/simple-text-36-50pct.png) is that the
stem of the "L" doesn't contain any COL_BLACK pixels, so
getCharacterLeftSideHeight returns early with -1.  The stem is drawn as 
three
vertical lines of pixels, a yellow (RGB 255/195/111), a black-ish (RGB 
23/0/0),
and a blue (RGB 31/155/199) one.  In comparison, when running the same test 
on
Fedora 37, the three vertical lines use gray-scale instead of colors,
RGB 195/195/195, then true black (RGB 0/0/0), and RGB 115/115/115.

An earlier test build of
 "Update to
LibreOffice 7.4.4" for the same libreoffice-7.4.4.2 tag on 2023-01-02 at
 succeeded, so I 
assume
that it must be some change in the meantime to the underlying
org.fedoraproject.sdk//22.08 that started to cause colorized antialiasing 
here.

Change-Id: I7059268eabcfe8e501d0be4f38746707def7bb35
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145411
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index 69365f98a00e..833022ee2204 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -99,6 +99,13 @@ public:
 CPPUNIT_TEST_SUITE_END();
 };
 
+// Avoid issues when colorized antialiasing generates slightly tinted rather 
than truly black
+// pixels:
+static bool isBlack(Color col)
+{
+return col.GetRed() < 25 && col.GetGreen() < 25 && col.GetBlue() < 25;
+}
+
 // Return pixel width of the base of the given character located above
 // the starting position.
 // In other words, go up in y direction until a black pixel is found,
@@ -109,7 +116,7 @@ static tools::Long getCharacterBaseWidth(VirtualDevice* 
device, const Point& sta
 Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel());
 Bitmap::ScopedReadAccess access(bitmap);
 tools::Long y = start.Y();
-while (y >= 0 && access->GetColor(y, start.X()) != COL_BLACK)
+while (y >= 0 && !isBlack(access->GetColor(y, start.X(
 --y;
 if (y < 0)
 return -1;
@@ -128,7 +135,7 @@ static tools::Long getCharacterTopWidth(VirtualDevice* 
device, const Point& star
 Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel());
 Bitmap::ScopedReadAccess access(bitmap);
 tools::Long y = start.Y();
-while (y < bitmap.GetSizePixel().Height() && access->GetColor(y, 
start.X()) != COL_BLACK)
+while (y < bitmap.GetSizePixel().Height() && !isBlack(access->GetColor(y, 
start.X(
 ++y;
 if (y >= bitmap.GetSizePixel().Height())
 return -1;
@@ -149,7 +156,7 @@ static tools::Long 
getCharacterLeftSideHeight(VirtualDevice* device, const Point
 Bitmap bitmap = device->GetBitmap(Point(), device->GetOutputSizePixel());
 Bitmap::ScopedReadAccess access(bitmap);
 tools::Long x = start.X();
-while (x < bitmap.GetSizePixel().Width() && access->GetColor(start.Y(), x) 
!= COL_BLACK)
+while (x < bitmap.GetSizePixel().Width() && 
!isBlack(access->GetColor(start.Y(), x)))
 ++x;
 if (x >= bitmap.GetSizePixel().Width())
 return -1;


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

2023-01-02 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   46 ++
 vcl/source/gdi/pdfobjectcopier.cxx|   22 
 3 files changed, 68 insertions(+)

New commits:
commit 68540314ecc801ddff06b843ac2e332b02bd7a3b
Author: Dennis Francis 
AuthorDate: Fri Dec 2 13:11:42 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:26:25 2023 +

vcl: Copy the resource kind object itself if...

some of the items in that resource are themselves dictionaries instead
of references.

Change-Id: I427386b14fe5507dfdfc9745dad27a8fceefd929
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143564
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 4cb521b28e8582eda1a63bc4d92061fd111a2e3d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144438
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 0390ccad8410..fdda33f78231 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ce070a711911..4cf31e708220 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4247,6 +4247,52 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportMediaBoxOrigin)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportResourceItemReference)
+{
+// 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;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that has reference to Font in 
page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pResources
+= 
dynamic_cast(pInnerIm->Lookup("Resources"));
+CPPUNIT_ASSERT(pResources);
+auto pFontsReference
+= 
dynamic_cast(pResources->LookupElement("Font"));
+CPPUNIT_ASSERT(pFontsReference);
+
+auto pFontsObject = pFontsReference->LookupObject();
+CPPUNIT_ASSERT(pFontsObject);
+
+auto pFontDict
+= 
dynamic_cast(pFontsObject->Lookup("FF132"));
+CPPUNIT_ASSERT(pFontDict);
+
+auto pFontDescriptor = pFontDict->LookupObject("FontDescriptor");
+CPPUNIT_ASSERT(pFontDescriptor);
+
+auto pFontWidths = pFontDict->LookupObject("Widths");
+CPPUNIT_ASSERT(pFontWidths);
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 67f70d10f2a9..2f32cdc27ce1 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -184,6 +184,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 
 // Get the rKind subset of the resource dictionary.
 std::map aItems;
+filter::PDFObjectElement* pKindObject = nullptr;
 if (auto pResources = 
dynamic_cast(rPage.Lookup("Resources")))
 {
 // Resources is a direct dictionary.
@@ -202,6 +203,7 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 return {};
 }
 
+pKindObject = pReferenced;
 aItems = pReferenced->GetDictionaryItems();
 }
 }
@@ -210,23 +212,37 @@ OString 
PDFObjectCopier::copyExternalResources(filter::PDFObjectElement& rPage,
 // Resources is an indirect object.
 filter::PDFElement* pValue = pPageResources->Lookup(rKind);
 if (auto pDictionary = 
dynamic_cast(pValue))
+{
 // Kind is a direct dictionary.
 aItems = pDictionary->GetItems();
+}
 else if (filter::PDFObjectElement* pObject = 
pPageResources->LookupObject(rKind))
+{
 // Kind is an indirect object.
 aItems = pObject->GetDictionaryItems();
+pKindObject = pObject;
+}
 }
 if (aItems.empty())
 return {};
 
 SvMemoryStream& rDocBuffer = rPage.GetDocument().GetEditBuffer();
+bool bHasDictValue = false;
 
 for (const auto& rItem : aItems)
 {
 // For each item copy it over to our output then insert it into aRet.
 auto pReference = 
dynamic_cast(rItem.second);
 

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

2023-01-02 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   61 ++
 vcl/source/gdi/pdfwriter_impl.cxx |   29 ++--
 3 files changed, 85 insertions(+), 5 deletions(-)

New commits:
commit e72f77b8164820569834f5459514c18d2bfd911b
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:47:12 2022 +0530
Commit: Miklos Vajna 
CommitDate: Tue Jan 3 07:25:42 2023 +

vcl: use /MediaBox origin in the ctm...

of the inner XObject, else the clip polypolygon may clip out partly or
whole contents. Adjusting the clip polypolygon is not straightforward.

Change-Id: If3b208ba850c3579c9e16c15e4fb2f947dad4406
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143561
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit a67dcc248a103098de883a4dd2fa9ff2e1cc1f90)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144436
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
index 598358a636aa..0390ccad8410 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf and 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 428f9d5a132a..ce070a711911 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4186,6 +4186,67 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testRexportFilterSingletonArray)
 CPPUNIT_ASSERT(it != pEnd);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportMediaBoxOrigin)
+{
+// 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;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im10 that contains the rectangle 
drawings in page 2.
+auto pInnerIm = aDocument.LookupObject(10);
+CPPUNIT_ASSERT(pInnerIm);
+
+constexpr sal_Int32 aOrigin[2] = { -800, -600 };
+sal_Int32 aSize[2] = { 0, 0 };
+
+auto pBBox = 
dynamic_cast(pInnerIm->Lookup("BBox"));
+CPPUNIT_ASSERT(pBBox);
+const auto& rElements2 = pBBox->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(4), rElements2.size());
+for (sal_Int32 nIdx = 0; nIdx < 4; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements2[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+if (nIdx < 2)
+CPPUNIT_ASSERT_EQUAL(aOrigin[nIdx], 
static_cast(pNumElement->GetValue()));
+else
+aSize[nIdx - 2] = static_cast(pNumElement->GetValue()) 
- aOrigin[nIdx - 2];
+}
+
+auto pMatrix = 
dynamic_cast(pInnerIm->Lookup("Matrix"));
+CPPUNIT_ASSERT(pMatrix);
+const auto& rElements = pMatrix->GetElements();
+CPPUNIT_ASSERT_EQUAL(static_cast(6), rElements.size());
+sal_Int32 aMatTranslate[6]
+= { // Rotation by $\theta$ $cos(\theta), sin(\theta), -sin(\theta), 
cos(\theta)$
+0, -1, 1, 0,
+// Translate x,y
+-aOrigin[1] - aSize[1] / 2 + aSize[0] / 2, aOrigin[0] + aSize[0] / 
2 + aSize[1] / 2
+  };
+
+for (sal_Int32 nIdx = 0; nIdx < 6; ++nIdx)
+{
+const auto* pNumElement = 
dynamic_cast(rElements[nIdx]);
+CPPUNIT_ASSERT(pNumElement);
+CPPUNIT_ASSERT_EQUAL(aMatTranslate[nIdx], 
static_cast(pNumElement->GetValue()));
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f4a3145c5085..d95a74aeb6af 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -8873,6 +8873,21 @@ void PDFWriterImpl::writeReferenceXObject(const 
ReferenceXObjectEmit& rEmit)
 return;
 }
 
+double aOrigin[2] = { 0.0, 0.0 };
+if (auto* pArray = 
dynamic_cast(pPage->Lookup("MediaBox")))
+{
+const auto& rElements = pArray->GetElements();
+if (rElements.size() >= 4)
+{
+// get x1, y1 of the rectangle.
+for (sal_Int32 nIdx = 0; nIdx < 2; ++nIdx)
+{
+if (const auto* pNumElement = 
dynamic_cast(rElements[nIdx]))
+aOrigin[nIdx] = pNumElement->GetValue();
+}
+}
+}
+
 std::vect

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

2022-12-20 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   50 +
 vcl/source/gdi/pdfobjectcopier.cxx |8 +
 2 files changed, 58 insertions(+)

New commits:
commit db2757e110c1d99bc6128d80a0c6b9fd63982b89
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:28:49 2022 +0530
Commit: Miklos Vajna 
CommitDate: Wed Dec 21 07:59:04 2022 +

vcl: /Filter [/FlatDecode] not properly read

Change-Id: I156e153ae1a123cf9cf54eb23e6d3abe8962f677
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143560
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit f5ad4f9dfac27d5675fa5c397f66b8cc45cc31a1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144435
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index f18077505abd..428f9d5a132a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -4136,6 +4136,56 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportFilterSingletonArray)
+{
+// 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;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+// Directly go to the inner XObject Im5 that contains the rectangle 
drawings.
+auto pInnerIm = aDocument.LookupObject(5);
+CPPUNIT_ASSERT(pInnerIm);
+
+auto pFilter = 
dynamic_cast(pInnerIm->Lookup("Filter"));
+CPPUNIT_ASSERT(pFilter);
+CPPUNIT_ASSERT_EQUAL_MESSAGE("Filter must be FlateDecode", 
OString("FlateDecode"),
+ pFilter->GetValue());
+
+vcl::filter::PDFStreamElement* pStream = pInnerIm->GetStream();
+CPPUNIT_ASSERT(pStream);
+SvMemoryStream& rObjectStream = pStream->GetMemory();
+// Uncompress it.
+SvMemoryStream aUncompressed;
+ZCodec aZCodec;
+aZCodec.BeginCompression();
+rObjectStream.Seek(0);
+aZCodec.Decompress(rObjectStream, aUncompressed);
+CPPUNIT_ASSERT(aZCodec.EndCompression());
+
+// Without the fix, the stream is doubly compressed,
+// hence one decompression will not yield the "re" expressions.
+auto pStart = static_cast(aUncompressed.GetData());
+const char* pEnd = pStart + aUncompressed.GetSize();
+OString aImage = "100 0 30 50 re B*\n70 67 50 30 re B*\n";
+auto it = std::search(pStart, pEnd, aImage.getStr(), aImage.getStr() + 
aImage.getLength());
+CPPUNIT_ASSERT(it != pEnd);
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 93b7b4989710..999be92bd752 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -283,6 +283,14 @@ sal_Int32 
PDFObjectCopier::copyPageStreams(std::vectorGetMemory();
 
 auto pFilter = 
dynamic_cast(pContent->Lookup("Filter"));
+auto pFilterArray = 
dynamic_cast(pContent->Lookup("Filter"));
+if (!pFilter && pFilterArray)
+{
+auto& aElements = pFilterArray->GetElements();
+if (!aElements.empty())
+pFilter = dynamic_cast(aElements[0]);
+}
+
 if (pFilter)
 {
 if (pFilter->GetValue() != "FlateDecode")


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

2022-12-20 Thread Dennis Francis (via logerrit)
 vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|   38 ++
 vcl/source/filter/ipdf/pdfdocument.cxx|   21 +-
 3 files changed, 58 insertions(+), 1 deletion(-)

New commits:
commit 9a45d2779ceaa1938feddf820d826922ed17854b
Author: Dennis Francis 
AuthorDate: Thu Dec 1 11:18:22 2022 +0530
Commit: Miklos Vajna 
CommitDate: Wed Dec 21 07:58:38 2022 +

vcl: read references to /Kids array...

if the argument of /Kids is not an array.

Conflicts:
vcl/qa/cppunit/pdfexport/pdfexport.cxx

Change-Id: Ib73962d3a27aa7e1ce5ddbe6845a1dd73bd7a343
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143559
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 
(cherry picked from commit 10185a6aec5d3b74a51e4b9474645e12bf794df8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144434
Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf
new file mode 100644
index ..598358a636aa
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/ref-to-kids.pdf 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index ea8f83e6ba8f..f18077505abd 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -4098,6 +4099,43 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
  / aRect[jehtatweel].getWidth());
 #endif
 }
+
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testRexportRefToKids)
+{
+// 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;
+osl_setEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData, 
OUString("1").pData);
+}
+comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() {
+if (bResetEnvVar)
+osl_clearEnvironment(OUString("LO_IMPORT_USE_PDFIUM").pData);
+});
+
+// Load the PDF and save as PDF
+vcl::filter::PDFDocument aDocument;
+load(u"ref-to-kids.pdf", aDocument);
+
+std::vector aPages = aDocument.GetPages();
+CPPUNIT_ASSERT_EQUAL(size_t(5), aPages.size());
+
+vcl::filter::PDFObjectElement* pResources = 
aPages[0]->LookupObject("Resources");
+CPPUNIT_ASSERT(pResources);
+
+auto pXObjects
+= 
dynamic_cast(pResources->Lookup("XObject"));
+CPPUNIT_ASSERT(pXObjects);
+
+// Without the fix LookupObject for all /Im's will fail.
+for (auto const& rPair : pXObjects->GetItems())
+{
+if (rPair.first.startsWith("Im"))
+CPPUNIT_ASSERT(pXObjects->LookupObject(rPair.first));
+}
+}
+
 } // end anonymous namespace
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index 25e731f5352a..19748e241ead 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1918,7 +1918,26 @@ const std::vector>& 
PDFDocument::GetElements() const
 /// Visits the page tree recursively, looking for page objects.
 static void visitPages(PDFObjectElement* pPages, 
std::vector& rRet)
 {
-auto pKids = dynamic_cast(pPages->Lookup("Kids"));
+auto pKidsRef = pPages->Lookup("Kids");
+auto pKids = dynamic_cast(pKidsRef);
+if (!pKids)
+{
+auto pRefKids = dynamic_cast(pKidsRef);
+if (!pRefKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+auto pObjWithKids = pRefKids->LookupObject();
+if (!pObjWithKids)
+{
+SAL_WARN("vcl.filter", "visitPages: pages has no kids");
+return;
+}
+
+pKids = pObjWithKids->GetArray();
+}
+
 if (!pKids)
 {
 SAL_WARN("vcl.filter", "visitPages: pages has no kids");


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

2022-11-20 Thread Chris Sherlock (via logerrit)
 vcl/qa/cppunit/text.cxx |  102 
 1 file changed, 102 insertions(+)

New commits:
commit e535da3b6d72c0aca312dcf1ca38a3fcc3532a38
Author: Chris Sherlock 
AuthorDate: Sun Oct 2 19:11:11 2022 +1100
Commit: خالد حسني 
CommitDate: Sun Nov 20 16:25:25 2022 +0100

vcl: add unit tests for OutputDevice::GetTextRect()

Change-Id: Ic36d42b0b38083c6a9ce3b6af4d80d5acf3e96e3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140906
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index a450c99ee3df..ee7ab8cd5859 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -66,6 +66,13 @@ public:
 void testGetStringWithEndEllpsis();
 void testGetStringWithNewsEllpsis();
 void testGetTextBreak();
+void testGetSingleLineTextRect();
+void testGetSingleLineTextRectWithEndEllipsis();
+void testGetRightBottomAlignedSingleLineTextRect();
+void testGetMultiLineTextRect();
+void testGetMultiLineTextRectWithEndEllipsis();
+void testGetRightBottomAlignedMultiLineTextRect();
+void testGetRotatedSingleLineTextRect();
 
 CPPUNIT_TEST_SUITE(VclTextTest);
 CPPUNIT_TEST(testSimpleText);
@@ -82,6 +89,13 @@ public:
 CPPUNIT_TEST(testGetStringWithEndEllpsis);
 CPPUNIT_TEST(testGetStringWithNewsEllpsis);
 CPPUNIT_TEST(testGetTextBreak);
+CPPUNIT_TEST(testGetSingleLineTextRect);
+CPPUNIT_TEST(testGetSingleLineTextRectWithEndEllipsis);
+CPPUNIT_TEST(testGetRightBottomAlignedSingleLineTextRect);
+CPPUNIT_TEST(testGetMultiLineTextRect);
+CPPUNIT_TEST(testGetMultiLineTextRectWithEndEllipsis);
+CPPUNIT_TEST(testGetRightBottomAlignedMultiLineTextRect);
+CPPUNIT_TEST(testGetRotatedSingleLineTextRect);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -671,6 +685,94 @@ void VclTextTest::testGetTextBreak()
  device->GetTextBreak(sTestStr, nTextWidth, 13, nLen));
 }
 
+void VclTextTest::testGetSingleLineTextRect()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("Liberation Sans", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(
+tools::Rectangle(Point(), Size(75, 12)),
+device->GetTextRect(tools::Rectangle(Point(), Point(100, 100)), "This 
is test text"));
+}
+
+void VclTextTest::testGetSingleLineTextRectWithEndEllipsis()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("Liberation Sans", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(
+tools::Rectangle(Point(), Size(52, 12)),
+device->GetTextRect(tools::Rectangle(Point(), Point(50, 50)), "This is 
test text",
+DrawTextFlags::WordBreak | 
DrawTextFlags::EndEllipsis));
+}
+
+void VclTextTest::testGetRightBottomAlignedSingleLineTextRect()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("Liberation Sans", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(926, 989), Size(75, 12)),
+ device->GetTextRect(tools::Rectangle(Point(), 
Point(1000, 1000)),
+ "This is test text",
+ DrawTextFlags::Right | 
DrawTextFlags::Bottom));
+}
+
+void VclTextTest::testGetRotatedSingleLineTextRect()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("Liberation Sans", Size(0, 11)));
+
+vcl::Font aFont(device->GetFont());
+aFont.SetOrientation(45_deg10);
+device->SetFont(aFont);
+
+CPPUNIT_ASSERT_EQUAL(
+tools::Rectangle(Point(0, -3), Size(75, 18)),
+device->GetTextRect(tools::Rectangle(Point(), Point(100, 100)), "This 
is test text"));
+}
+
+void VclTextTest::testGetMultiLineTextRect()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("Liberation Sans", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(), Size(75, 12)),
+ device->GetTextRect(tools::Rectangle(Point(), 
Point(100, 100)),
+ "This is test text",
+ DrawTextFlags::WordBreak | 
DrawTextFlags::MultiLine));
+}
+
+void VclTextTest::testGetMultiLineTextRectWithEndEllipsis()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("Liberation Sans", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(), Size(52, 48)),
+ device->GetTextRect(tools::Rectangle(P

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

2022-10-15 Thread Chris Sherlock (via logerrit)
 vcl/qa/cppunit/text.cxx |   71 
 1 file changed, 71 insertions(+)

New commits:
commit 5c2e1c894e6d0ef846d3643ef96c56ab548ef0d0
Author: Chris Sherlock 
AuthorDate: Sun Oct 2 18:33:12 2022 +1100
Commit: Noel Grandin 
CommitDate: Sat Oct 15 12:55:43 2022 +0200

vcl: test generating ellipses

Change-Id: Ic985bd9bbee4319243c01fff6dffa46e860581a1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140905
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index 8ec7597e6a65..a450c99ee3df 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -62,6 +62,9 @@ public:
 void testImplLayoutArgsBiDiRtl();
 void testImplLayoutArgsRightAlign();
 void testImplLayoutArgs_PrepareFallback_precalculatedglyphs();
+void testGetStringWithCenterEllpsis();
+void testGetStringWithEndEllpsis();
+void testGetStringWithNewsEllpsis();
 void testGetTextBreak();
 
 CPPUNIT_TEST_SUITE(VclTextTest);
@@ -75,6 +78,9 @@ public:
 CPPUNIT_TEST(testImplLayoutArgsBiDiRtl);
 CPPUNIT_TEST(testImplLayoutArgsRightAlign);
 CPPUNIT_TEST(testImplLayoutArgs_PrepareFallback_precalculatedglyphs);
+CPPUNIT_TEST(testGetStringWithCenterEllpsis);
+CPPUNIT_TEST(testGetStringWithEndEllpsis);
+CPPUNIT_TEST(testGetStringWithNewsEllpsis);
 CPPUNIT_TEST(testGetTextBreak);
 CPPUNIT_TEST_SUITE_END();
 };
@@ -576,6 +582,71 @@ void 
VclTextTest::testImplLayoutArgs_PrepareFallback_precalculatedglyphs()
 CPPUNIT_ASSERT(!bRTL);
 }
 
+void VclTextTest::testGetStringWithCenterEllpsis()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("DejaVu Sans", "Book", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"a b c d ...v w x y z"),
+device->GetEllipsisString(u"a b c d e f g h i j k l m n o p q r s t u 
v w x y z", 100,
+  DrawTextFlags::CenterEllipsis));
+}
+
+void VclTextTest::testGetStringWithEndEllpsis()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("DejaVu Sans", "Book", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(OUString(u"a"), device->GetEllipsisString(u"abcde. f 
g h i j ...", 10,
+   
DrawTextFlags::EndEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"a b c d e f g h i j ..."),
+device->GetEllipsisString(u"a b c d e f g h i j k l m n o p q r s t u 
v w x y z", 100,
+  DrawTextFlags::EndEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(OUString(u"a"), device->GetEllipsisString(u"abcde. f 
g h i j ...", 1,
+   
DrawTextFlags::EndEllipsis
+   | 
DrawTextFlags::Clip));
+}
+
+void VclTextTest::testGetStringWithNewsEllpsis()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("DejaVu Sans", "Book", Size(0, 11)));
+
+CPPUNIT_ASSERT_EQUAL(OUString(u"a"), device->GetEllipsisString(u"abcde. f 
g h i j ...", 10,
+   
DrawTextFlags::NewsEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"a b  x y z"),
+device->GetEllipsisString(u"a b c d. e f g. h i j k l m n o p q r s t 
u v w. x y z", 100,
+  DrawTextFlags::NewsEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"a b  x y z"),
+device->GetEllipsisString(u"a b c d. e f g h i j k l m n o p q r s t u 
v w. x y z", 100,
+  DrawTextFlags::NewsEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"a b c d e f g h i j ..."),
+device->GetEllipsisString(u"a b c d e f g h i j k l m n o p q r s t u 
v w. x y z", 100,
+  DrawTextFlags::NewsEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"a. x y z"),
+device->GetEllipsisString(u"a. b c d e f g h i j k l m n o p q r s t u 
v w. x y z", 100,
+  DrawTextFlags::NewsEllipsis));
+
+CPPUNIT_ASSERT_EQUAL(
+OUString(u"ab. cde..."),
+device->GetEllipsisString(u"ab. cde. x y z", 50, 
DrawTextFlags::NewsEllipsis));
+}
+
 void VclTextTest::testGetTextBreak()
 {
 ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);


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

2022-10-07 Thread Chris Sherlock (via logerrit)
 vcl/qa/cppunit/text.cxx |   26 ++
 1 file changed, 26 insertions(+)

New commits:
commit 0cf173ff4a53618e6ddd40a278f375680d92a71f
Author: Chris Sherlock 
AuthorDate: Tue Sep 27 05:37:47 2022 +1000
Commit: Michael Stahl 
CommitDate: Fri Oct 7 10:42:05 2022 +0200

vcl: test OutputDevice::GetTextBreak()

Change-Id: I1618d268ca7495d4aae1bde1a43be6bcf8811869
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140630
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/vcl/qa/cppunit/text.cxx b/vcl/qa/cppunit/text.cxx
index d233fa9d9aa3..8ec7597e6a65 100644
--- a/vcl/qa/cppunit/text.cxx
+++ b/vcl/qa/cppunit/text.cxx
@@ -62,6 +62,7 @@ public:
 void testImplLayoutArgsBiDiRtl();
 void testImplLayoutArgsRightAlign();
 void testImplLayoutArgs_PrepareFallback_precalculatedglyphs();
+void testGetTextBreak();
 
 CPPUNIT_TEST_SUITE(VclTextTest);
 CPPUNIT_TEST(testSimpleText);
@@ -74,6 +75,7 @@ public:
 CPPUNIT_TEST(testImplLayoutArgsBiDiRtl);
 CPPUNIT_TEST(testImplLayoutArgsRightAlign);
 CPPUNIT_TEST(testImplLayoutArgs_PrepareFallback_precalculatedglyphs);
+CPPUNIT_TEST(testGetTextBreak);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -574,6 +576,30 @@ void 
VclTextTest::testImplLayoutArgs_PrepareFallback_precalculatedglyphs()
 CPPUNIT_ASSERT(!bRTL);
 }
 
+void VclTextTest::testGetTextBreak()
+{
+ScopedVclPtr device = 
VclPtr::Create(DeviceFormat::DEFAULT);
+device->SetOutputSizePixel(Size(1000, 1000));
+device->SetFont(vcl::Font("DejaVu Sans", "Book", Size(0, 11)));
+
+const OUString sTestStr(u"textline_ text_");
+const auto nLen = sTestStr.getLength();
+const auto nTextWidth = device->GetTextWidth("text");
+
+CPPUNIT_ASSERT_EQUAL(static_cast(4),
+ device->GetTextBreak(sTestStr, nTextWidth, 0, nLen));
+CPPUNIT_ASSERT_EQUAL(static_cast(7),
+ device->GetTextBreak(sTestStr, nTextWidth, 3, nLen));
+CPPUNIT_ASSERT_EQUAL(static_cast(9),
+ device->GetTextBreak(sTestStr, nTextWidth, 6, nLen));
+CPPUNIT_ASSERT_EQUAL(static_cast(12),
+ device->GetTextBreak(sTestStr, nTextWidth, 8, nLen));
+CPPUNIT_ASSERT_EQUAL(static_cast(14),
+ device->GetTextBreak(sTestStr, nTextWidth, 11, nLen));
+CPPUNIT_ASSERT_EQUAL(static_cast(-1),
+ device->GetTextBreak(sTestStr, nTextWidth, 13, nLen));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VclTextTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();


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

2022-10-05 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   54 +
 vcl/source/gdi/CommonSalLayout.cxx |6 ---
 2 files changed, 22 insertions(+), 38 deletions(-)

New commits:
commit 09c076c3f29c28497f162d3a5b7baab040725d56
Author: Khaled Hosny 
AuthorDate: Wed Oct 5 21:00:46 2022 +0200
Commit: خالد حسني 
CommitDate: Wed Oct 5 22:08:08 2022 +0200

tdf#151350: Fix extraneous gaps before marks

After latest changes we no longer need HarfBuzz buffer level
MONOTONE_CHARACTERS (which was needed to allow us to address individual
combining marks). With the default cluster level, combining marks get
the same cluster as their base and so we need not do any thing special.

I had to update testTdf139627 because this results in using ActualText
spans in the PDF, and PDFium support for them is lacking.

Change-Id: I0011072330fdbf409c30ff781fd3beaceae400f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140994
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 88139dd0ecd4..b8efd4c5dc6e 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3621,10 +3621,10 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testBitmapScaledown)
 CPPUNIT_ASSERT_EQUAL(2616, nWidth);
 }
 }
-} // end anonymous namespace
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
 {
+#if HAVE_MORE_FONTS
 aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
 saveAsPDF(u"justified-arabic-kashida.odt");
 std::unique_ptr pPdfDocument = parseExport();
@@ -3635,20 +3635,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
 std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
 CPPUNIT_ASSERT(pPdfPage);
 
-// 7 or 8 objects, 4 text, others are path
+// 7 objects, 3 text, others are path
 int nPageObjectCount = pPdfPage->getObjectCount();
-CPPUNIT_ASSERT_GREATEREQUAL(7, nPageObjectCount);
+CPPUNIT_ASSERT_EQUAL(7, nPageObjectCount);
 
-// 4 text objects, "رم" (reh+mim), then "ِ" (kasreh), tatweel, and "ج" 
(jeh)
-OUString sText[4];
+// 3 text objects
+OUString sText[3];
 
 /* With "Noto Sans Arabic" font, these are the X ranges on Linux:
-0: ( 61.75 - 218.35)
-1: (479.70 - 520.02)
-2: (209.40 - 457.08)
-3: (447.80 - 546.62)
+0: ( 61.75 - 415.94)
+1: (479.70 - 422.40)
+2: (209.40 - 453.2)
 */
-basegfx::B2DRectangle aRect[4];
+basegfx::B2DRectangle aRect[3];
 
 std::unique_ptr pTextPage = 
pPdfPage->getTextPage();
 std::unique_ptr pPageObject;
@@ -3665,47 +3664,38 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
 ++nTextObjectCount;
 }
 }
-CPPUNIT_ASSERT_EQUAL(4, nTextObjectCount);
+CPPUNIT_ASSERT_EQUAL(3, nTextObjectCount);
 
 // Text: جِـرم (which means "mass" in Persian)
-// Rendered as (left to right): "reh + mim" - "tatweel" - "kasreh" - "jeh"
-int rehmim = 0, kasreh = 1, tatweel = 2, jeh = 3;
-
-// Bad rendering can cause tatweel enumerated before kasreh
-// This can be the end of journey, but let's accept this for now
-if (sText[2].equals(u"ِ"))
-{
-tatweel = 1;
-kasreh = 2;
-}
+// Rendered as (left to right): "reh + mim" - "kasreh" - "jeh + tatweel"
+int rehmim = 0, kasreh = 1, jehtatweel = 2;
 
 CPPUNIT_ASSERT_EQUAL(OUString(u"رم"), sText[rehmim].trim());
-CPPUNIT_ASSERT_EQUAL(OUString(u"ِ"), sText[kasreh].trim());
-CPPUNIT_ASSERT_EQUAL(OUString(u""), sText[tatweel].trim());
-CPPUNIT_ASSERT_EQUAL(OUString(u"ج"), sText[jeh].trim());
+CPPUNIT_ASSERT_EQUAL(OUString(u""), sText[kasreh].trim());
+CPPUNIT_ASSERT_EQUAL(OUString(u""), sText[jehtatweel].trim());
 
 // "Kasreh" should be within "jeh" character
-CPPUNIT_ASSERT_GREATER(aRect[jeh].getMinX(), aRect[kasreh].getMinX());
-CPPUNIT_ASSERT_LESS(aRect[jeh].getMaxX(), aRect[kasreh].getMaxX());
+CPPUNIT_ASSERT_GREATER(aRect[jehtatweel].getMinX(), 
aRect[kasreh].getMinX());
+CPPUNIT_ASSERT_LESS(aRect[jehtatweel].getMaxX(), aRect[kasreh].getMaxX());
 
 // "Tatweel" should cover "jeh" and "reh"+"mim" to avoid gap
 // Checking right gap
-CPPUNIT_ASSERT_GREATER(aRect[jeh].getMinX(), aRect[tatweel].getMaxX());
+//CPPUNIT_ASSERT_GREATER(aRect[jehtatweel].getMinX(), 
aRect[tatweel].getMaxX());
 // Checking left gap
 // Kashida fails to reach to rehmim before the series of patches starting
 // with 3901e029bd39575f700e69a73818565d62226a23. The visible symptom is
 // a gap in the left of Kashida.
-// CPPUNIT_ASSERT_LESS(aRect[rehmim].getMaxX(), aRect[tatweel].getMinX());
+CPPUNIT_ASSERT_LESS(aRect[rehmim].getMaxX(), aRect[jehtatweel].getMinX());
 
 // Overlappings of Kashida and surrounding characters is ~9% of the width
 // of the "jeh" characte

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

2022-09-23 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/GraphicTest.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 23cbe9b969db11f9fb25d8dffe8d801e002b5e94
Author: Xisco Fauli 
AuthorDate: Thu Sep 22 11:38:35 2022 +0200
Commit: Xisco Fauli 
CommitDate: Fri Sep 23 16:47:58 2022 +0200

Fix GraphicTest::testLoadSVGZ() on non-default DPI

Change-Id: I6f6435a285e34cf27798265d9d98f15337991b54
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140406
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 09bf18782708..d8875666431e 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -1331,8 +1331,9 @@ void GraphicTest::testLoadSVGZ()
 {
 Graphic aGraphic = loadGraphic(u"TypeDetectionExample.svgz");
 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
-CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Width());
-CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+const auto[scalingX, scalingY] = getDPIScaling();
+CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingX), 
aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100 * scalingY), 
aGraphic.GetSizePixel().Height());
 }
 
 void GraphicTest::testAvailableThreaded()


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

2022-09-15 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf150931.ods |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   45 
 2 files changed, 45 insertions(+)

New commits:
commit f089f56aa0035ca0ee33bac752a7a92086680c24
Author: Xisco Fauli 
AuthorDate: Thu Sep 15 13:18:13 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Sep 15 18:39:51 2022 +0200

tdf#150931: vcl_pdfexport: Add unittest

Probably this test could be improved by checking the
position of the pathes. For now, this is better than nothing

Change-Id: I5063a9005a55be9d556eb147ba6a11fb2a1115a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140013
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf150931.ods 
b/vcl/qa/cppunit/pdfexport/data/tdf150931.ods
new file mode 100644
index ..633362c614ef
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf150931.ods differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index e2c6ae39784b..1b6036abfee8 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2231,6 +2231,51 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf114256)
 CPPUNIT_ASSERT_EQUAL(13, pPdfPage->getObjectCount());
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf150931)
+{
+aMediaDescriptor["FilterName"] <<= OUString("calc_pdf_Export");
+saveAsPDF(u"tdf150931.ods");
+std::unique_ptr pPdfDocument = parseExport();
+CPPUNIT_ASSERT(pPdfDocument);
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage);
+
+int nPageObjectCount = pPdfPage->getObjectCount();
+// Without the fix in place, this test would have failed with
+// - Expected: 15
+// - Actual  : 16
+CPPUNIT_ASSERT_EQUAL(16, nPageObjectCount);
+
+int nYellowPathCount = 0;
+int nBlackPathCount = 0;
+int nGrayPathCount = 0;
+int nRedPathCount = 0;
+for (int i = 0; i < nPageObjectCount; ++i)
+{
+std::unique_ptr pPdfPageObject = 
pPdfPage->getObject(i);
+if (pPdfPageObject->getType() != vcl::pdf::PDFPageObjectType::Path)
+continue;
+
+int nSegments = pPdfPageObject->getPathSegmentCount();
+CPPUNIT_ASSERT_EQUAL(5, nSegments);
+
+if (pPdfPageObject->getFillColor() == COL_YELLOW)
+++nYellowPathCount;
+else if (pPdfPageObject->getFillColor() == COL_BLACK)
+++nBlackPathCount;
+else if (pPdfPageObject->getFillColor() == COL_GRAY)
+++nGrayPathCount;
+else if (pPdfPageObject->getFillColor() == COL_LIGHTRED)
+++nRedPathCount;
+}
+
+CPPUNIT_ASSERT_EQUAL(3, nYellowPathCount);
+CPPUNIT_ASSERT_EQUAL(3, nRedPathCount);
+CPPUNIT_ASSERT_EQUAL(3, nGrayPathCount);
+CPPUNIT_ASSERT_EQUAL(3, nBlackPathCount);
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf147027)
 {
 // FIXME: the DPI check should be removed when either (1) the test is 
fixed to work with


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

2022-09-08 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf150846.txt |1 
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   29 
 2 files changed, 30 insertions(+)

New commits:
commit 7578842634e007d096ed146f494939bd315b78e4
Author: Xisco Fauli 
AuthorDate: Thu Sep 8 12:31:47 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Sep 8 20:00:45 2022 +0200

tdf#150846: vcl_pdfexport: Add unittest

Change-Id: I16a7326a0164e319cf97b1a34849a3134232364d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139646
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf150846.txt 
b/vcl/qa/cppunit/pdfexport/data/tdf150846.txt
new file mode 100644
index ..ce013625030b
--- /dev/null
+++ b/vcl/qa/cppunit/pdfexport/data/tdf150846.txt
@@ -0,0 +1 @@
+hello
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 02a91516a3fb..1e056cc904d1 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1251,6 +1251,35 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115117_2a)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf150846)
+{
+// Without the fix in place, this test would have failed with
+// An uncaught exception of type com.sun.star.io.IOException
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"tdf150846.txt");
+
+// Parse the export result with pdfium.
+std::unique_ptr pPdfDocument = parseExport();
+CPPUNIT_ASSERT(pPdfDocument);
+
+CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+std::unique_ptr pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage);
+
+std::unique_ptr pPdfTextPage = 
pPdfPage->getTextPage();
+CPPUNIT_ASSERT(pPdfTextPage);
+
+int nChars = pPdfTextPage->countChars();
+
+CPPUNIT_ASSERT_EQUAL(5, nChars);
+
+std::vector aChars(nChars);
+for (int i = 0; i < nChars; i++)
+aChars[i] = pPdfTextPage->getUnicode(i);
+OUString aActualText(aChars.data(), aChars.size());
+CPPUNIT_ASSERT_EQUAL(OUString(u"hello"), aActualText);
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf103492)
 {
 // Import the bugdoc and export as PDF.


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

2022-09-08 Thread Mike Kaganski (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 3801a45eb8e82095d5f1a65ad1646e300a900bdd
Author: Mike Kaganski 
AuthorDate: Thu Sep 8 18:04:44 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Sep 8 18:33:15 2022 +0200

Fix CppunitTest_vcl_pdfexport on non-default DPI

Change-Id: I6cfeed3059246d01e56b1b55c8c85f89256c7340
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139698
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 840dae3ac561..02a91516a3fb 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1677,6 +1677,11 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128445)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128630)
 {
+// FIXME: the DPI check should be removed when either (1) the test is 
fixed to work with
+// non-default DPI; or (2) unit tests on Windows are made to use svp VCL 
plugin.
+if (!IsDefaultDPI())
+return;
+
 // Import the bugdoc and export as PDF.
 aMediaDescriptor["FilterName"] <<= OUString("impress_pdf_Export");
 saveAsPDF(u"tdf128630.odp");
@@ -1703,9 +1708,9 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf128630)
 // - Expected: 466
 // - Actual  : 289
 // i.e. the rotated + scaled arrow was more thin than it should be.
-CPPUNIT_ASSERT_EQUAL(466, nWidth);
+CPPUNIT_ASSERT_DOUBLES_EQUAL(466, nWidth, 1);
 int nHeight = pBitmap->getHeight();
-CPPUNIT_ASSERT_EQUAL(466, nHeight);
+CPPUNIT_ASSERT_EQUAL(nWidth, nHeight);
 }
 }
 
@@ -2199,6 +2204,11 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf114256)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf147027)
 {
+// FIXME: the DPI check should be removed when either (1) the test is 
fixed to work with
+// non-default DPI; or (2) unit tests on Windows are made to use svp VCL 
plugin.
+if (!IsDefaultDPI())
+return;
+
 // Load the Calc document.
 aMediaDescriptor["FilterName"] <<= OUString("calc_pdf_Export");
 saveAsPDF(u"tdf147027.ods");
@@ -3508,6 +3518,11 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, 
testPdfImageEncryption)
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testBitmapScaledown)
 {
+// FIXME: the DPI check should be removed when either (1) the test is 
fixed to work with
+// non-default DPI; or (2) unit tests on Windows are made to use svp VCL 
plugin.
+if (!IsDefaultDPI())
+return;
+
 // Given a document with an upscaled and rotated barcode bitmap in it:
 aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
 


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

2022-09-08 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/GraphicTest.cxx|   10 ++
 vcl/qa/cppunit/data/TypeDetectionExample.svgz |binary
 2 files changed, 10 insertions(+)

New commits:
commit 845fa950ac635ea57dd860fb96fadcfb75e97f2b
Author: Xisco Fauli 
AuthorDate: Thu Sep 8 13:37:35 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Sep 8 17:35:37 2022 +0200

tdf#150808: vcl_graphic_test: Add unittest

Change-Id: Icc0f323606d5702abe03e1537e42fbd78dc6b297
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139651
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 97ef23eac15d..09bf18782708 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -84,6 +84,7 @@ private:
 void testLoadPCX();
 void testLoadEPS();
 void testLoadWEBP();
+void testLoadSVGZ();
 
 void testAvailableThreaded();
 void testColorChangeToTransparent();
@@ -123,6 +124,7 @@ private:
 CPPUNIT_TEST(testLoadPCX);
 CPPUNIT_TEST(testLoadEPS);
 CPPUNIT_TEST(testLoadWEBP);
+CPPUNIT_TEST(testLoadSVGZ);
 
 CPPUNIT_TEST(testAvailableThreaded);
 CPPUNIT_TEST(testColorChangeToTransparent);
@@ -1325,6 +1327,14 @@ void GraphicTest::testLoadWEBP()
 CPPUNIT_ASSERT_EQUAL(tools::Long(10), aGraphic.GetSizePixel().Height());
 }
 
+void GraphicTest::testLoadSVGZ()
+{
+Graphic aGraphic = loadGraphic(u"TypeDetectionExample.svgz");
+CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Width());
+CPPUNIT_ASSERT_EQUAL(tools::Long(100), aGraphic.GetSizePixel().Height());
+}
+
 void GraphicTest::testAvailableThreaded()
 {
 Graphic jpgGraphic1 = importUnloadedGraphic(u"TypeDetectionExample.jpg");
diff --git a/vcl/qa/cppunit/data/TypeDetectionExample.svgz 
b/vcl/qa/cppunit/data/TypeDetectionExample.svgz
index 17c1bcc3c7f1..ef04021fd029 100644
Binary files a/vcl/qa/cppunit/data/TypeDetectionExample.svgz and 
b/vcl/qa/cppunit/data/TypeDetectionExample.svgz differ


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

2022-09-08 Thread Mike Kaganski (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 9f682acf75d56c82b40114bb9fceb29d837de2dd
Author: Mike Kaganski 
AuthorDate: Thu Sep 8 12:39:14 2022 +0300
Commit: Mike Kaganski 
CommitDate: Thu Sep 8 13:08:14 2022 +0200

Related: tdf#150786 workaround unit test failure

The test detects a different problem, so this issue is unrelated to
the detection. Indeed, after this issue is fixed, the test could be
restored to test it all, complementing the test coverage.

Change-Id: Ie3c8621d76bf1ccb58ffbdde875a7adb7bceb76a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139639
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 0168c157b0c2..840dae3ac561 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2648,12 +2648,17 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testFormFontName)
 CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFObjectType::String, 
pAnnot->getValueType("DA"));
 OUString aDA = pAnnot->getString("DA");
 
+// Workaround tdf#150786: skip color. It may be either "0 0 0 rg /TiRo 12 
Tf" on light mode,
+//  or "1 1 1 rg /TiRo 12 
Tf" on dark mode.
+sal_Int32 rgPos = aDA.indexOf(u"rg");
+CPPUNIT_ASSERT(rgPos >= 0);
+
 // Without the accompanying fix in place, this test would have failed with:
-// - Expected: 0 0 0 rg /TiRo 12 Tf
-// - Actual  : 0 0 0 rg /F2 12 Tf
+// - Expected: rg /TiRo 12 Tf
+// - Actual  : rg /F2 12 Tf
 // i.e. Liberation Serif was exposed as a form font as-is, without picking 
the closest built-in
 // font.
-CPPUNIT_ASSERT_EQUAL(OUString("0 0 0 rg /TiRo 12 Tf"), aDA);
+CPPUNIT_ASSERT_EQUAL(OUString("rg /TiRo 12 Tf"), aDA.copy(rgPos));
 }
 
 // Check we don't have duplicated objects when we reexport the PDF multiple


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

2022-09-01 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 5dd22c7fe8aeaaee76cb8124113adda6c43dfd39
Author: Andrea Gelmini 
AuthorDate: Wed Aug 31 22:54:47 2022 +0200
Commit: Julien Nabet 
CommitDate: Thu Sep 1 12:50:43 2022 +0200

Fix typo

Change-Id: Id912bf46e9c9b2aa02f58124cc8ee63a7cd3322b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139137
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 4df845e45ed7..0168c157b0c2 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3580,7 +3580,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
 CPPUNIT_ASSERT_EQUAL(4, nTextObjectCount);
 
 // Text: جِـرم (which means "mass" in Persian)
-// Rendered as (left to right): "reh + mim" - "tahtweel" - "kasreh" - "jeh"
+// Rendered as (left to right): "reh + mim" - "tatweel" - "kasreh" - "jeh"
 int rehmim = 0, kasreh = 1, tatweel = 2, jeh = 3;
 
 // Bad rendering can cause tatweel enumerated before kasreh


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

2022-08-31 Thread Andrea Gelmini (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c54c576a5043dc5a0cc01f8c71897373516ae091
Author: Andrea Gelmini 
AuthorDate: Wed Aug 31 22:53:48 2022 +0200
Commit: Julien Nabet 
CommitDate: Thu Sep 1 07:21:49 2022 +0200

Fix typo

Change-Id: Idc3bfb5298a00c681950aa4686748335ddd90d9c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139136
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 4b25202bb2d4..4df845e45ed7 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -3605,7 +3605,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf139627)
 CPPUNIT_ASSERT_GREATER(aRect[jeh].getMinX(), aRect[tatweel].getMaxX());
 // Checking left gap
 // Kashida fails to reach to rehmim before the series of patches starting
-// with 3901e029bd39575f700e69a73818565d62226a23. The visible sypotom is
+// with 3901e029bd39575f700e69a73818565d62226a23. The visible symptom is
 // a gap in the left of Kashida.
 // CPPUNIT_ASSERT_LESS(aRect[rehmim].getMaxX(), aRect[tatweel].getMinX());
 


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

2022-08-31 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/complextext.cxx |   10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

New commits:
commit 22795263e6743005c4f7df3e0dcedd933ed133b4
Author: Caolán McNamara 
AuthorDate: Wed Aug 31 19:54:41 2022 +0100
Commit: خالد حسني 
CommitDate: Thu Sep 1 05:29:43 2022 +0200

use VirtualDevice, not WorkWindow, in test

like

commit 8ca13426ca50a9466f552ac1e2f062920003d5ea
Date:   Tue Aug 30 16:28:38 2022 +0300

Workaround interdependency of tests

Change-Id: Ic550f1cae45ff3145a3a25785499bf0d226e4940
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139131
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index d052564d638b..77b9444d1c74 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -240,12 +240,9 @@ void VclComplexTextTest::testCaret()
 #if HAVE_MORE_FONTS
 // Test caret placement in fonts *without* ligature carets in GDEF table.
 
-ScopedVclPtrInstance pWin(static_cast(nullptr));
-CPPUNIT_ASSERT( pWin );
-
 vcl::Font aFont("DejaVu Sans", "Book", Size(0, 200));
 
-OutputDevice *pOutDev = pWin->GetOutDev();
+ScopedVclPtrInstance pOutDev;
 pOutDev->SetFont( aFont );
 
 OUString aText;
@@ -321,10 +318,7 @@ void VclComplexTextTest::testGdefCaret()
 #if HAVE_MORE_FONTS
 // Test caret placement in fonts *with* ligature carets in GDEF table.
 
-ScopedVclPtrInstance pWin(static_cast(nullptr));
-CPPUNIT_ASSERT( pWin );
-
-OutputDevice *pOutDev = pWin->GetOutDev();
+ScopedVclPtrInstance pOutDev;
 
 vcl::Font aFont;
 OUString aText;


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

2022-08-30 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/complextext.cxx |5 ++---
 vcl/source/gdi/sallayout.cxx   |9 +++--
 2 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit ce7c1c608fa99c86c8f2380cd8b82d02123f514e
Author: Khaled Hosny 
AuthorDate: Wed Aug 31 07:07:54 2022 +0200
Commit: خالد حسني 
CommitDate: Wed Aug 31 08:47:16 2022 +0200

vcl: Fix GenericSalLayout::GetTextWidth()

There was a mismatch between text width calculated in
GenericSalLayout::GetTextWidth() and last glyph width calculated in
GenericSalLayout::GetCharWidths(), with the later using the sum of
GlyphItem::newWidth() and the later using the GlyphItem::linearPos(),
but linearPos() includes glyph offset and it should be subtracted from
it to get actual width and we were subtracting it in the wrong place.

I fixed where the xOffset() is subtracted but didn’t change it to simply
sum GlyphItem::newWidth() though that is simpler so that we continue to
test that linearPos() is correctly set.

Change-Id: I40d6be6d1c82ed0ca1ce04bf792adf72faa0d787
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139071
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index fb25459bb737..d052564d638b 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -287,9 +287,8 @@ void VclComplexTextTest::testCaret()
 CPPUNIT_ASSERT_EQUAL(aCharWidths[6], aCharWidths[7]);
 CPPUNIT_ASSERT_EQUAL(aCharWidths[8], aCharWidths[9]);
 CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
-// FIXME: this should be 353, and the next assert should be true as well.
-CPPUNIT_ASSERT_EQUAL(tools::Long(388), nTextWidth2);
-//CPPUNIT_ASSERT_EQUAL(nTextWidth, nTextWidth2);
+CPPUNIT_ASSERT_EQUAL(tools::Long(353), nTextWidth2);
+CPPUNIT_ASSERT_EQUAL(nTextWidth, nTextWidth2);
 CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back());
 
 // B. LTR text
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 6d22b302b6c5..de5385f93ac2 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -286,12 +286,9 @@ DeviceCoordinate GenericSalLayout::GetTextWidth() const
 for (auto const& aGlyphItem : m_GlyphItems)
 {
 // update the text extent with the glyph extent
-DeviceCoordinate nXPos = aGlyphItem.linearPos().getX();
-if( nMinPos > nXPos )
-nMinPos = nXPos;
-nXPos += aGlyphItem.newWidth() - aGlyphItem.xOffset();
-if( nMaxPos < nXPos )
-nMaxPos = nXPos;
+DeviceCoordinate nXPos = aGlyphItem.linearPos().getX() - 
aGlyphItem.xOffset();
+nMinPos = std::min(nMinPos, nXPos);
+nMaxPos = std::max(nMaxPos, nXPos + aGlyphItem.newWidth());
 }
 
 DeviceCoordinate nWidth = nMaxPos - nMinPos;


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

2022-08-30 Thread Khaled Hosny (via logerrit)
 vcl/qa/cppunit/complextext.cxx |   91 +
 vcl/source/gdi/CommonSalLayout.cxx |   54 ++---
 2 files changed, 137 insertions(+), 8 deletions(-)

New commits:
commit bdbbdc9b931d35f6d7d816512ac5be599295dc80
Author: Khaled Hosny 
AuthorDate: Sun Aug 28 06:59:06 2022 +0200
Commit: خالد حسني 
CommitDate: Wed Aug 31 08:46:25 2022 +0200

tdf#30731: Use ligature caret positions from the font

When ligature caret positions from the font are available, use them for
more accurate caret positions instead of evenly distributing the glyph
width over grapheme clusters.

Change-Id: I0ecfa35e1fff2b264b105182a4b29b2ebd033093
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138955
Tested-by: Jenkins
Reviewed-by: خالد حسني 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 0b76f5eb91d9..fb25459bb737 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -53,6 +53,7 @@ public:
 void testCaching();
 void testCachingSubstring();
 void testCaret();
+void testGdefCaret();
 
 CPPUNIT_TEST_SUITE(VclComplexTextTest);
 CPPUNIT_TEST(testArabic);
@@ -60,6 +61,7 @@ public:
 CPPUNIT_TEST(testCaching);
 CPPUNIT_TEST(testCachingSubstring);
 CPPUNIT_TEST(testCaret);
+CPPUNIT_TEST(testGdefCaret);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -236,6 +238,8 @@ void VclComplexTextTest::testCachingSubstring()
 void VclComplexTextTest::testCaret()
 {
 #if HAVE_MORE_FONTS
+// Test caret placement in fonts *without* ligature carets in GDEF table.
+
 ScopedVclPtrInstance pWin(static_cast(nullptr));
 CPPUNIT_ASSERT( pWin );
 
@@ -313,6 +317,93 @@ void VclComplexTextTest::testCaret()
 #endif
 }
 
+void VclComplexTextTest::testGdefCaret()
+{
+#if HAVE_MORE_FONTS
+// Test caret placement in fonts *with* ligature carets in GDEF table.
+
+ScopedVclPtrInstance pWin(static_cast(nullptr));
+CPPUNIT_ASSERT( pWin );
+
+OutputDevice *pOutDev = pWin->GetOutDev();
+
+vcl::Font aFont;
+OUString aText;
+std::vector aCharWidths, aRefCharWidths;
+tools::Long nTextWidth, nTextWidth2;
+
+// A. RTL text
+aFont = vcl::Font("Noto Naskh Arabic", "Regular", Size(0, 200));
+pOutDev->SetFont(aFont);
+
+aText = u"لا بلا";
+
+// 1) Regular DX array, the ligature width is given to the first components
+// and the next ones are all zero width.
+aRefCharWidths = { 104, 104, 148, 203, 325, 325 };
+aCharWidths.resize(aText.getLength());
+std::fill(aCharWidths.begin(), aCharWidths.end(), 0);
+nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, 
/*bCaret*/false);
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
+CPPUNIT_ASSERT_EQUAL(tools::Long(325), nTextWidth);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back());
+
+// 2) Caret placement DX array, ligature width is distributed over its
+// components.
+aRefCharWidths = { 53, 104, 148, 203, 265, 325 };
+aCharWidths.resize(aText.getLength());
+std::fill(aCharWidths.begin(), aCharWidths.end(), 0);
+nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, 
/*bCaret*/true);
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
+CPPUNIT_ASSERT_EQUAL(tools::Long(325), nTextWidth);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back());
+
+// 3) caret placement with combining marks, they should not add to ligature
+// component count.
+aText = u"لَاَ بلَاَ";
+aRefCharWidths = { 53, 53, 104, 104, 148, 203, 265, 265, 325, 325 };
+aCharWidths.resize(aText.getLength());
+std::fill(aCharWidths.begin(), aCharWidths.end(), 0);
+nTextWidth2 = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, 
/*bCaret*/true);
+CPPUNIT_ASSERT_EQUAL(aCharWidths[0], aCharWidths[1]);
+CPPUNIT_ASSERT_EQUAL(aCharWidths[2], aCharWidths[3]);
+CPPUNIT_ASSERT_EQUAL(aCharWidths[6], aCharWidths[7]);
+CPPUNIT_ASSERT_EQUAL(aCharWidths[8], aCharWidths[9]);
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
+CPPUNIT_ASSERT_EQUAL(tools::Long(325), nTextWidth2);
+CPPUNIT_ASSERT_EQUAL(nTextWidth, nTextWidth2);
+CPPUNIT_ASSERT_EQUAL(sal_Int32(nTextWidth), aCharWidths.back());
+
+// B. LTR text
+aFont = vcl::Font("Amiri", "Regular", Size(0, 200));
+pOutDev->SetFont(aFont);
+
+aText = u"fi ffi fl ffl fb ffb";
+
+// 1) Regular DX array, the ligature width is given to the first components
+// and the next ones are all zero width.
+aRefCharWidths = { 104, 104, 162, 321, 321, 321, 379, 487, 487, 545, 708,
+   708, 708, 766, 926, 926, 984, 1198, 1198, 1198 };
+aCharWidths.resize(aText.getLength());
+std::fill(aCharWidths.begin(), aCharWidths.end(), 0);
+nTextWidth = pOutDev->GetTextArray(aText, &aCharWidths, 0, -1, 
/*bCaret*/false);
+CPPUNIT_ASSERT_EQUAL(aRefCharWidths, aCharWidths);
+CPPUNIT_AS

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

2022-08-30 Thread Mike Kaganski (via logerrit)
 vcl/qa/cppunit/complextext.cxx |9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

New commits:
commit 8ca13426ca50a9466f552ac1e2f062920003d5ea
Author: Mike Kaganski 
AuthorDate: Tue Aug 30 16:28:38 2022 +0300
Commit: Mike Kaganski 
CommitDate: Tue Aug 30 20:04:33 2022 +0200

Workaround interdependency of tests

CppunitTest_vcl_text failed for me on Windows:

  [_RUN_] VclTextTest::testSimpleText
  C:/lo/src/core/vcl/qa/cppunit/text.cxx:198:VclTextTest::testSimpleText
  double equality assertion failed
  - Expected: 28
  - Actual  : -1
  - Delta   : 4

This turned out to depend on test order; the minimal failing command was

  make CppunitTest_vcl_text CPPUNIT_TEST_NAME="testArabic testSimpleText"

and running testArabic before testSimpleText made the latter to render
white text on white background, and thus being unable to get resulting
height of the painted text.

Changing how the complex tests obtain their virtusl devices fixes this
for me. I have no idea how and why the previous complex test code
affected following tests. Windows buildbots were unaffected maybe
because they had HAVE_MORE_FONTS undefined.

Change-Id: If079e21e6b986fed5407295a71f9b121cf8de0b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139047
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index ff85b14e33ef..6c35fd740b33 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -65,12 +65,10 @@ void VclComplexTextTest::testArabic()
 {
 #if HAVE_MORE_FONTS
 OUString aOneTwoThree(u"واحِدْ إثٍنين ثلاثةٌ");
-ScopedVclPtrInstance pWin(static_cast(nullptr));
-CPPUNIT_ASSERT( pWin );
 
 vcl::Font aFont("DejaVu Sans", "Book", Size(0, 12));
 
-OutputDevice *pOutDev = pWin->GetOutDev();
+ScopedVclPtrInstance pOutDev;
 pOutDev->SetFont( aFont );
 
 // absolute character widths AKA text array.
@@ -120,10 +118,7 @@ void VclComplexTextTest::testTdf95650()
 "\u0D11\u1312\u0105\u020A\u0512\u1403\u030C\u1528"
 "\u2931\u632E\u7074\u0D20\u0E0A\u100A\uF00D\u0D20"
 "\u030A\u0C0B\u20E0\u0A0D";
-ScopedVclPtrInstance pWin(static_cast(nullptr));
-CPPUNIT_ASSERT(pWin);
-
-OutputDevice *pOutDev = pWin->GetOutDev();
+ScopedVclPtrInstance pOutDev;
 // Check that the following executes without failing assertion
 pOutDev->ImplLayout(aTxt, 9, 1, Point(), 0, {}, {}, 
SalLayoutFlags::BiDiRtl);
 }


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

2022-08-22 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf115967.odt |binary
 1 file changed

New commits:
commit 91597052bea39720f5a557d30f7d687d4308e7a8
Author: Caolán McNamara 
AuthorDate: Mon Aug 22 09:44:22 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Aug 22 13:12:22 2022 +0200

change hi to ar and Lohit Devanagari to Noto Sans Arabic

for reproducible tests

Change-Id: Ia5429c259190b2263dc4a9de971538dda0f53166
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138638
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf115967.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf115967.odt
index 39f4ce1784e5..ff538af5f516 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/tdf115967.odt and 
b/vcl/qa/cppunit/pdfexport/data/tdf115967.odt differ


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

2022-08-22 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf145873.pptx |binary
 1 file changed

New commits:
commit 86a78634bfef2c3e800990d245c227b832c89e6b
Author: Caolán McNamara 
AuthorDate: Sun Aug 21 14:51:06 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Aug 22 10:19:20 2022 +0200

use "Rubik" from more_fonts instead of "System" for consistent layout

using Rubik with trailing 0 because need to overwrite the binary
fontname in the embedded wmf in this docx

Change-Id: I2c49154bbef9405c15dd8bc044d21ec874f9825e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138639
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf145873.pptx 
b/vcl/qa/cppunit/pdfexport/data/tdf145873.pptx
index 8a5eaa83824a..7f5eb135c9c5 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/tdf145873.pptx and 
b/vcl/qa/cppunit/pdfexport/data/tdf145873.pptx differ


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

2022-08-21 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf103492.odt |binary
 1 file changed

New commits:
commit 547b4a054ac7f310485aaece6e936318f876d63e
Author: Caolán McNamara 
AuthorDate: Sun Aug 21 14:36:25 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Aug 21 17:42:19 2022 +0200

Tahoma -> DejaVu Sans for reproducible tests

Change-Id: Iedb007987848fbd5567bb96692e5501ff3046868
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138637
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf103492.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf103492.odt
index 9000e670b710..88b8dc146f49 100644
Binary files a/vcl/qa/cppunit/pdfexport/data/tdf103492.odt and 
b/vcl/qa/cppunit/pdfexport/data/tdf103492.odt differ


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

2022-08-21 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/pdfexport/data/forcepoint80-1.rtf |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 6c0b8669e1f09a8301f3ebd1da21855d84abb2b1
Author: Caolán McNamara 
AuthorDate: Sat Aug 20 21:39:24 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun Aug 21 11:50:42 2022 +0200

Arial Black -> DejaVu Sans for reproducible tests

Change-Id: Ia4c4f47578f6674b6a5cfdbaa68fc12221ddb5ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138599
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/pdfexport/data/forcepoint80-1.rtf 
b/vcl/qa/cppunit/pdfexport/data/forcepoint80-1.rtf
index 46fc60e6ddd4..7ff7c82e46ba 100644
--- a/vcl/qa/cppunit/pdfexport/data/forcepoint80-1.rtf
+++ b/vcl/qa/cppunit/pdfexport/data/forcepoint80-1.rtf
@@ -1 +1 @@
-{\rtf1\cnsi 
\ansicpg1252\stshfloch0{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green102\blue204;\red102\green99\blue98;\red143\green142\blue142;\red75\green60\blue52;}{\fonttbl{\f0\froman\cpg1257\fcharset186
 DejaVu Serif;}{\f1\froman\cpg0\fcharset0 DejaVu 
Serif;}{\f2\froman\cpg1252\fcharset0 DejaVu 
Serif;}{\f3\fswiss\cpg1257\fcharset186 Arial Black;}{\f4\fswiss\cpg0\fcharset0 
Arial Black;}{\f5\fswiss\cpg1252\fcharset0 Arial 
Black;}{\f6\fro-an\cpg1257\fcharset186 Times New 
Roman;}{\f7\froman\cpg0\fcharset0 Times New 
Roman;}{\f8\froman\cpg1252\fcharset0 Times New 
Roman;}{\f9\fmodern\cpg1257\fcharset186 Courier 
New;}{\f10\fmodern\cpg0\fcharset0 Courier New;}{\f11\fmodern\cpg1252\fcharset0 
Courier New;}}{\stylesheet {\ql Normal;}{\s1\sbasedon0\ql\fi-120\sl-276\slmult0 
Style1;}{\s2\sbasedon0\qj\fi560\sl-300\slmult0 Style2;}{\s3\sbasedon0\ql\
 sl-264\slmult0 Style3;}{\s4\sbasedon0\ql\fi-1088\sl-320\slmult0 
Style4;}{\s5\sbasedon0\ql Style5;}{\s6\sbasedon0\ql 
Style6;}{\s7\sbasedon0\ql\sl-320\slmult0 Style7;}{\s8\sbasedon0\qr 
Style8;}{\s9\sbasedon0\ql Style9;}{\s10\sbasedon0\qj\sl-264\slmult0 
Style10;}{\s11\sbasedon0\qj\sl-298\slmult0 
Style11;}{\s12\sbasedon0\qj\sl-288\slmult0 Style12;}{\s13\sbasedon0\ql 
Style13;}{\s14\sbasedon0\ql\fi600\sl-329\slmult0 
Style14;}{\s15\sbasedon0\ql\sl-240\slmult0 Style15;}{\s16\sbasedon0\ql 
Style16;}{\s17\sbasedon0\ql\fi576\sl-328\slmult0 Style17;}{\s18\sbasedon0\ql 
Style18;}{\s19\sbasedon0\ql\sl-271\slmult0 
Style19;}{\s20\sbasedon0\ql\fi2406\sl-339\slmult0 Style20;}{\s21\sbasedon0\ql 
Style21;}{\s22\sbasedon0\ql\fi2821\sl-161\slmult0 
Style22;}{\s23\sbasedon0\ql\fi568\sl-306\slmult0 Style23;}{\s24\sbasedon0\ql 
Style24;}{\s25\sbasedon0\ql Style25;}{\s26\sbasedon0\ql 
Style26;}{\s27\sbasedon0\ql Style27;}{\s28\sbasedon0\qj\sl-271\slmult0 
Style28;}{\s29\sbasedon0\ql\fi568\sl-322\slmult0 Style29;}{\
 s30\sbasedon0\ql Style30;}{\s31\sbasedon0\ql Style31;}{\s32\sbasedon0\ql 
Style32;}{\s33\sbasedon0\ql Style33;}{\s34\sbasedon0\ql 
Style34;}{\s35\sbasedon0\ql Style35;}{\*\cs36\additive Default Paragraph 
Font;}{\*\cs37\sbasedon36\additive\b\charscalex120\f2\fs58 Font 
Style37;}{\*\cs38\sbasedon36\additive\b\charscalex30\f2\fs400 Font 
Style38;}{\*\cs39\sbasedon36\additive\i\f2\fs22 Font 
Style39;}{\*\cs40\sbasedon36\additive\scaps\f8\fs8 Font 
Style40;}{\*\cs41\sbasedon36\additive\i\b\f2\fs10 Font 
Style41;}{\*\cs42\sbasedon36\additive\f5\fs8 Font 
Style42;}{\*\cs43\sbasedon36\additive\b\expndtw200\f2\fs10 Font 
Style43;}{\*\cs44\sbasedon36\additive\f2\fs22 Font 
Style44;}{\*\cs45\sbasedon36\additive\b\expndtw-10\f2\fs22 Font 
Style45;}{\*\cs46\sbasedon36\additive\scaps\f2\fs20 Font 
Style46;}{\*\cs47\sbasedon36\additive\charscalex20\f2\fs104 Font 
Style47;}{\*\cs48\sbasedon36\additive\b\f2\fs20 Font 
Style48;}{\*\cs49\sbasedon36\additive\f2\fs22 Font 
Style49;}{\*\cs50\sbasedon36\additive\b\f2\fs
 38 Font Style50;}{\*\cs51\sbasedon36\additive\f2\fs20 Font 
Style51;}{\*\cs52\sbasedon36\additive\expndtw-20\f2\fs30 Font 
Style52;}{\*\cs53\sbasedon36\additive\i\expndtw-10\f2\fs22 Font 
Style53;}{\*\cs54\sbasedon36\additive\i\expndtw-20\f2\fs22 Font 
Style54;}{\*\cs55\sbasedon36\additive\f2\fs22 Font 
Style55;}{\*\cs56\sbasedon36\additive\f2\fs18 Font 
Style56;}{\*\cs57\sbasedon36\additive\b\expndtw10\f2\fs16 Font 
Style57;}{\*\cs58\sbasedon36\additive\b\f2\fs20 Font 
Style58;}{\*\cs59\sbasedon36\additive\i\b\expndtw-10\f11\fs22 Font 
Style59;}{\*\cs60\sbasedon36\additive\f2\fs20 Font 
Style60;}{\*\cs61\sbasedon36\additive\f2\fs12 Font 
Style61;}{\*\cs62\sbasedon36\additive\f2\fs18 Font 
Style62;}{\*\cs63\sbasedon36\additive\i\expndtw-20\f2\fs22 Font 
Style63;}{\*\cs64\sbasedon36\additive\b\expndtw-20\f2\fs26 Font 
Style64;}}\fet2{\*\ftnsep {\chftnsep\par }}{\*\aftnsep {\chftnsep\par 
}}\expshrtn\widowctrl\paperw20384\paperh12312\margl360\margr360\margt360\margb360
 \sectd \sbknone\pgwsxn20384\pg
 
hsxn12312\marglsxn360\margrsxn360\margtsxn360\margbsxn360\titlepg\cols2\colno1\colw8632\colsr2104\colno2\colw8928

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

2022-08-15 Thread Xisco Fauli (via logerrit)
 vcl/qa/cppunit/pdfexport/data/tdf103492.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   48 
 2 files changed, 48 insertions(+)

New commits:
commit c1446da82b999349e1a09fed3420bd1c38d7b38c
Author: Xisco Fauli 
AuthorDate: Mon Aug 15 11:46:19 2022 +0200
Commit: Xisco Fauli 
CommitDate: Tue Aug 16 00:26:28 2022 +0200

tdf#103492: vcl_pdfexport: Add unittest

Change-Id: I426ace3f1272b2cb5f40d627c9c701b903c3e632
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138272
Reviewed-by: خالد حسني 
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf103492.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf103492.odt
new file mode 100644
index ..c76e8b4348a9
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf103492.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index fb821ae4..a6d635d21369 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1251,6 +1251,54 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf115117_2a)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf103492)
+{
+// Import the bugdoc and export as PDF.
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+saveAsPDF(u"tdf103492.odt");
+
+// Parse the export result with pdfium.
+std::unique_ptr pPdfDocument = parseExport();
+CPPUNIT_ASSERT(pPdfDocument);
+
+// The document has two page.
+CPPUNIT_ASSERT_EQUAL(2, pPdfDocument->getPageCount());
+std::unique_ptr pPdfPage1 = 
pPdfDocument->openPage(/*nIndex=*/0);
+CPPUNIT_ASSERT(pPdfPage1);
+
+std::unique_ptr pPdfTextPage1 = 
pPdfPage1->getTextPage();
+CPPUNIT_ASSERT(pPdfTextPage1);
+
+int nChars1 = pPdfTextPage1->countChars();
+
+// Without the fix in place, this test would have failed with
+// - Expected: 15
+// - Actual  : 18
+CPPUNIT_ASSERT_EQUAL(15, nChars1);
+
+std::vector aChars1(nChars1);
+for (int i = 0; i < nChars1; i++)
+aChars1[i] = pPdfTextPage1->getUnicode(i);
+OUString aActualText1(aChars1.data(), aChars1.size());
+CPPUNIT_ASSERT_EQUAL(OUString(u"يوسف My name is"), aActualText1);
+
+std::unique_ptr pPdfPage2 = 
pPdfDocument->openPage(/*nIndex=*/1);
+CPPUNIT_ASSERT(pPdfPage2);
+
+std::unique_ptr pPdfTextPage2 = 
pPdfPage2->getTextPage();
+CPPUNIT_ASSERT(pPdfTextPage2);
+
+int nChars2 = pPdfTextPage2->countChars();
+
+CPPUNIT_ASSERT_EQUAL(15, nChars2);
+
+std::vector aChars2(nChars2);
+for (int i = 0; i < nChars2; i++)
+aChars2[i] = pPdfTextPage2->getUnicode(i);
+OUString aActualText2(aChars2.data(), aChars2.size());
+CPPUNIT_ASSERT_EQUAL(OUString(u"My name is يوسف"), aActualText2);
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf145274)
 {
 // Import the bugdoc and export as PDF.


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

2022-08-12 Thread Luboš Luňák (via logerrit)
 vcl/qa/cppunit/complextext.cxx |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit d21a23cb03b54d423faf6c4a3d706cb9c749916d
Author: Luboš Luňák 
AuthorDate: Tue Aug 9 12:46:06 2022 +0200
Commit: Luboš Luňák 
CommitDate: Fri Aug 12 12:12:33 2022 +0200

use the same vcl::text::TextLayoutCache when comparing text layout

Otherwise OutputDevice::ImplLayout() might use a temporary cache
just for the subtext while SalLayoutGlyphsCache would use cache
for the whole string, and those two might differ e.g. with an arabic
string starting with numbers when the subset is just the numbers.

Change-Id: Idea7ef277beae07e39e4a714088a7585361d13e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138143
Tested-by: Jenkins
Reviewed-by: Luboš Luňák 

diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index d6c624fa7406..9e96205946b1 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -226,8 +226,10 @@ static void testCachedGlyphsSubstring( const OUString& 
aText, const OUString& aF
 vcl::Font aFont( aFontName, Size(0, 12));
 pOutputDevice->SetFont( aFont );
 SalLayoutGlyphsCache::self()->clear();
+std::shared_ptr layoutCache = 
OutputDevice::CreateTextLayoutCache(aText);
 // Get the glyphs for the entire text once, to ensure the cache can built 
subsets from it.
-pOutputDevice->ImplLayout( aText, 0, aText.getLength(), Point(0, 0), 0, 
{}, SalLayoutFlags::GlyphItemsOnly);
+pOutputDevice->ImplLayout( aText, 0, aText.getLength(), Point(0, 0), 0, 
{}, SalLayoutFlags::GlyphItemsOnly,
+layoutCache.get());
 // Now check for all subsets. Some of them possibly do not make sense in 
practice, but the code
 // should cope with them.
 for( sal_Int32 len = 1; len <= aText.getLength(); ++len )
@@ -235,10 +237,10 @@ static void testCachedGlyphsSubstring( const OUString& 
aText, const OUString& aF
 {
 std::string message = prefix + " (" + std::to_string(pos) + "/" + 
std::to_string(len) + ")";
 std::unique_ptr pLayout1 = pOutputDevice->ImplLayout(
-aText, pos, len, Point(0, 0), 0, {}, 
SalLayoutFlags::GlyphItemsOnly);
+aText, pos, len, Point(0, 0), 0, {}, 
SalLayoutFlags::GlyphItemsOnly, layoutCache.get());
 SalLayoutGlyphs aGlyphs1 = pLayout1->GetGlyphs();
 const SalLayoutGlyphs* aGlyphs2 = 
SalLayoutGlyphsCache::self()->GetLayoutGlyphs(
-pOutputDevice, aText, pos, len, 0);
+pOutputDevice, aText, pos, len, 0, layoutCache.get());
 CPPUNIT_ASSERT_MESSAGE(message, aGlyphs2 != nullptr);
 checkCompareGlyphs(aGlyphs1, *aGlyphs2, message);
 }


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

2022-08-11 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2022-1210-1.tiff |binary
 1 file changed

New commits:
commit ff1db14fe71eec4cdf7e6b7cfec4c0db9c6014d2
Author: Caolán McNamara 
AuthorDate: Thu Aug 11 11:11:50 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Aug 11 20:40:04 2022 +0200

add CVE-2022-1210 testcase

Change-Id: I9390b128006dd3cec4e0b482885dbbd5492f912f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138138
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2022-1210-1.tiff 
b/vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2022-1210-1.tiff
new file mode 100644
index ..78460c790ca9
Binary files /dev/null and 
b/vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2022-1210-1.tiff differ


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

2022-08-11 Thread Caolán McNamara (via logerrit)
 vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2017-9937-1.tiff |binary
 1 file changed

New commits:
commit 3f410b62672d5cef71ae16010b1a74b9eee52825
Author: Caolán McNamara 
AuthorDate: Thu Aug 11 10:03:01 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Aug 11 14:33:18 2022 +0200

add CVE-2017-9937 testcase

Change-Id: Ibefbd727a662292995be01d6c8c04354f10e9e2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138110
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2017-9937-1.tiff 
b/vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2017-9937-1.tiff
new file mode 100644
index ..b12bf6bd4dc0
Binary files /dev/null and 
b/vcl/qa/cppunit/graphicfilter/data/tiff/fail/CVE-2017-9937-1.tiff differ


  1   2   3   4   5   >