[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - vcl/qa

2021-03-02 Thread Gabor Kelemen (via logerrit)
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   46 -
 1 file changed, 46 deletions(-)

New commits:
commit 905117465025820762be08db9ce7224b90a15de4
Author: Gabor Kelemen 
AuthorDate: Wed Mar 3 08:22:30 2021 +0100
Commit: Gabor Kelemen 
CommitDate: Wed Mar 3 08:24:12 2021 +0100

Revert failing unit test backported in 2a4dc079

Change-Id: I334ac2128a62957ee0e2a5063e3b91948d5fe661
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111866
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 33683ee75a7a..fe402b4ed8b8 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -151,7 +151,6 @@ public:
 void testVersion15();
 void testDefaultVersion();
 void testMultiPagePDF();
-void testFormFontName();
 
 
 CPPUNIT_TEST_SUITE(PdfExportTest);
@@ -197,7 +196,6 @@ public:
 CPPUNIT_TEST(testVersion15);
 CPPUNIT_TEST(testDefaultVersion);
 CPPUNIT_TEST(testMultiPagePDF);
-CPPUNIT_TEST(testFormFontName);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -2288,50 +2286,6 @@ void PdfExportTest::testMultiPagePDF()
 #endif
 }
 
-void PdfExportTest::testFormFontName()
-{
-// Import the bugdoc and export as PDF.
-OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"form-font-name.odt";
-mxComponent = loadFromDesktop(aURL);
-
-uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
-utl::MediaDescriptor aMediaDescriptor;
-aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
-xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
-
-// Parse the export result with pdfium.
-SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
-SvMemoryStream aMemory;
-aMemory.WriteStream(aFile);
-ScopedFPDFDocument pPdfDocument(
-FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), 
/*password=*/nullptr));
-CPPUNIT_ASSERT(pPdfDocument);
-
-// The document has one page.
-CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get()));
-ScopedFPDFPage pPdfPage(FPDF_LoadPage(pPdfDocument.get(), 
/*page_index=*/0));
-CPPUNIT_ASSERT(pPdfPage);
-
-// The page has one annotation.
-CPPUNIT_ASSERT_EQUAL(1, FPDFPage_GetAnnotCount(pPdfPage.get()));
-ScopedFPDFAnnotation pAnnot(FPDFPage_GetAnnot(pPdfPage.get(), 0));
-
-// Examine the default appearance.
-CPPUNIT_ASSERT(FPDFAnnot_HasKey(pAnnot.get(), "DA"));
-CPPUNIT_ASSERT_EQUAL(FPDF_OBJECT_STRING, 
FPDFAnnot_GetValueType(pAnnot.get(), "DA"));
-size_t nDALength = FPDFAnnot_GetStringValue(pAnnot.get(), "DA", nullptr, 
0);
-std::vector aDABuf(nDALength);
-FPDFAnnot_GetStringValue(pAnnot.get(), "DA", aDABuf.data(), nDALength);
-OUString aDA(reinterpret_cast(aDABuf.data()));
-
-// 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
-// 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_TEST_SUITE_REGISTRATION(PdfExportTest);
 
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - vcl/qa vcl/source

2021-01-06 Thread Miklos Vajna (via logerrit)
 vcl/qa/cppunit/pdfexport/data/form-font-name.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |   46 +++
 vcl/source/gdi/pdfwriter_impl.cxx|   13 +-
 3 files changed, 56 insertions(+), 3 deletions(-)

New commits:
commit 2a4dc0791e9c185926c9b5588d2d0d88d1d85442
Author: Miklos Vajna 
AuthorDate: Mon Jul 20 11:36:13 2020 +0200
Commit: Gabor Kelemen 
CommitDate: Wed Jan 6 10:49:00 2021 +0100

tdf#50879 PDF export: ensure only built-in fonts are used for forms

Alternative would be to embed the whole font, which is unusual: PDF
typically just embeds the used subset.

Change-Id: Ic0b7e121b3ae38804c1a396ea36104ebcc0b9588
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99032
Reviewed-by: Miklos Vajna 
Tested-by: Jenkins
(cherry picked from commit 6294ecd7b4da38de98b24ddfb9f201cef98c1f41)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108853
Tested-by: Gabor Kelemen 
Reviewed-by: Gabor Kelemen 

diff --git a/vcl/qa/cppunit/pdfexport/data/form-font-name.odt 
b/vcl/qa/cppunit/pdfexport/data/form-font-name.odt
new file mode 100644
index ..a7430c9a8a6e
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/form-font-name.odt 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index fe402b4ed8b8..33683ee75a7a 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -151,6 +151,7 @@ public:
 void testVersion15();
 void testDefaultVersion();
 void testMultiPagePDF();
+void testFormFontName();
 
 
 CPPUNIT_TEST_SUITE(PdfExportTest);
@@ -196,6 +197,7 @@ public:
 CPPUNIT_TEST(testVersion15);
 CPPUNIT_TEST(testDefaultVersion);
 CPPUNIT_TEST(testMultiPagePDF);
+CPPUNIT_TEST(testFormFontName);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -2286,6 +2288,50 @@ void PdfExportTest::testMultiPagePDF()
 #endif
 }
 
+void PdfExportTest::testFormFontName()
+{
+// Import the bugdoc and export as PDF.
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"form-font-name.odt";
+mxComponent = loadFromDesktop(aURL);
+
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+utl::MediaDescriptor aMediaDescriptor;
+aMediaDescriptor["FilterName"] <<= OUString("writer_pdf_Export");
+xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
+
+// Parse the export result with pdfium.
+SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
+SvMemoryStream aMemory;
+aMemory.WriteStream(aFile);
+ScopedFPDFDocument pPdfDocument(
+FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), 
/*password=*/nullptr));
+CPPUNIT_ASSERT(pPdfDocument);
+
+// The document has one page.
+CPPUNIT_ASSERT_EQUAL(1, FPDF_GetPageCount(pPdfDocument.get()));
+ScopedFPDFPage pPdfPage(FPDF_LoadPage(pPdfDocument.get(), 
/*page_index=*/0));
+CPPUNIT_ASSERT(pPdfPage);
+
+// The page has one annotation.
+CPPUNIT_ASSERT_EQUAL(1, FPDFPage_GetAnnotCount(pPdfPage.get()));
+ScopedFPDFAnnotation pAnnot(FPDFPage_GetAnnot(pPdfPage.get(), 0));
+
+// Examine the default appearance.
+CPPUNIT_ASSERT(FPDFAnnot_HasKey(pAnnot.get(), "DA"));
+CPPUNIT_ASSERT_EQUAL(FPDF_OBJECT_STRING, 
FPDFAnnot_GetValueType(pAnnot.get(), "DA"));
+size_t nDALength = FPDFAnnot_GetStringValue(pAnnot.get(), "DA", nullptr, 
0);
+std::vector aDABuf(nDALength);
+FPDFAnnot_GetStringValue(pAnnot.get(), "DA", aDABuf.data(), nDALength);
+OUString aDA(reinterpret_cast(aDABuf.data()));
+
+// 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
+// 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_TEST_SUITE_REGISTRATION(PdfExportTest);
 
 }
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 7e02762d6e36..811d2413f044 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3502,6 +3502,13 @@ Font PDFWriterImpl::replaceFont( const vcl::Font& 
rControlFont, const vcl::Font&
 sal_Int32 PDFWriterImpl::getBestBuildinFont( const vcl::Font& rFont )
 {
 sal_Int32 nBest = 4; // default to Helvetica
+
+if (rFont.GetFamilyType() == FAMILY_ROMAN)
+{
+// Serif: default to Times-Roman.
+nBest = 8;
+}
+
 OUString aFontName( rFont.GetFamilyName() );
 aFontName = aFontName.toAsciiLowerCase();
 
@@ -3648,14 +3655,14 @@ void PDFWriterImpl::createDefaultEditAppearance( 
PDFWidget& rEdit, const PDFWrit
 
 // prepare font to use, draw field border
 Font aFont = drawFieldBorder( rEdit, rWidget, rSettings );
-sal_Int32 nBest = getSystemFont( aFont );
+//