include/vcl/vcllayout.hxx                  |   10 +++----
 sw/qa/extras/globalfilter/globalfilter.cxx |   41 ++++++++++++++++-------------
 vcl/qt5/QtGraphics_Text.cxx                |    3 --
 vcl/quartz/salgdi.cxx                      |    2 -
 vcl/skia/osx/gdiimpl.cxx                   |    2 -
 vcl/skia/win/gdiimpl.cxx                   |    2 -
 vcl/skia/x11/textrender.cxx                |    2 -
 vcl/source/gdi/sallayout.cxx               |    4 +-
 vcl/source/outdev/text.cxx                 |    2 -
 vcl/unx/generic/gdi/cairotextrender.cxx    |   12 ++++----
 vcl/win/gdi/winlayout.cxx                  |    2 -
 11 files changed, 44 insertions(+), 38 deletions(-)

New commits:
commit ea0f9776ed8e7e9809853d292923b86756274564
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Tue Jul 18 13:41:00 2023 +0300
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Sun Jul 23 06:01:46 2023 +0200

    Improve CppunitTest_sw_globalfilter CPPUNIT_TEST_NAME=testListLabelPDFExport
    
    Extract the textual content of the page using high level PDFiumDocument
    API instead of fiddling with low level PDF text stream details.
    
    Change-Id: If989addb3200e728e8ed771bfcc23cc18c7664de
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154579
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    Reviewed-by: خالد حسني <kha...@libreoffice.org>

diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx 
b/sw/qa/extras/globalfilter/globalfilter.cxx
index 0c7415ddabe6..64bc2063beb1 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -1283,6 +1283,29 @@ CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
     css::uno::Reference<frame::XStorable> xStorable(mxComponent, 
css::uno::UNO_QUERY_THROW);
     xStorable->storeToURL(maTempFile.GetURL(), 
aMediaDescriptor.getAsConstPropertyValueList());
 
+    // Parse the export result with pdfium.
+    std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument = parsePDFExport();
+
+    // The document has one page.
+    CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
+    std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = 
pPdfDocument->openPage(/*nIndex=*/0);
+    CPPUNIT_ASSERT(pPdfPage);
+
+    std::unique_ptr<vcl::pdf::PDFiumTextPage> pPdfTextPage = 
pPdfPage->getTextPage();
+    CPPUNIT_ASSERT(pPdfTextPage);
+
+    int nChars = pPdfTextPage->countChars();
+    CPPUNIT_ASSERT_EQUAL(22, nChars);
+
+    // Check that the label strings were exported correctly
+    std::vector<sal_uInt32> aChars(nChars);
+    for (int i = 0; i < nChars; i++)
+        aChars[i] = pPdfTextPage->getUnicode(i);
+    OUString aText(aChars.data(), aChars.size());
+    
CPPUNIT_ASSERT_EQUAL(OUString(u"\u0623\r\n.\r\n\u0623.\u0623\r\n.\r\n\u0623.\u0623.\u0623\r\n."),
 aText);
+
+    // Parse the document again to get its raw content
+    // TODO: get the content from PDFiumPage somehow
     vcl::filter::PDFDocument aDocument;
     SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
     CPPUNIT_ASSERT(aDocument.Read(aStream));
@@ -1345,10 +1368,6 @@ CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
                 auto const endj(line.find(">Tj"));
                 if (endj != ::std::string_view::npos)
                 {
-                    auto const start(line.rfind("<", endj) + 1);
-                    // for these, expected length is 1 glyphs, each 2 digits
-                    // would be better to check the content but it depends on 
CMap
-                    CPPUNIT_ASSERT_EQUAL(static_cast<decltype(endj - start)>(1 
* 2), endj - start);
                     state = LblFoundText;
                     ++nLblTj;
                 }
@@ -1357,17 +1376,6 @@ CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
                     auto const endJ(line.find("]TJ"));
                     if (endJ != ::std::string_view::npos)
                     {
-                        auto const start(line.rfind("[", endJ) + 1);
-                        auto i(line.find("<", start));
-                        auto digits(0);
-                        while (i != ::std::string_view::npos && i < endJ)
-                        {
-                            auto const j(line.find(">", i));
-                            digits += j - (i+1);
-                            i = line.find("<", j);
-                        }
-                        // these have list-level numbers + one less ".", each 
2 digits
-                        
CPPUNIT_ASSERT_EQUAL(static_cast<decltype(digits)>((((nLbl/2 + 1) * 2) - 1) * 
2), digits);
                         state = LblFoundText;
                         ++nLblTJ;
                     }
@@ -1386,8 +1394,7 @@ CPPUNIT_TEST_FIXTURE(Test, testListLabelPDFExport)
     // tree into 3 Lbl.
     CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nLbl)>(6), nLbl);
     // these are quite arbitrary?
-    CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nLbl)>(2), nLblTJ);
-    CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nLbl)>(4), nLblTj);
+    CPPUNIT_ASSERT_EQUAL(static_cast<decltype(nLbl)>(6), nLblTJ + nLblTj);
 
     auto nL(0);
     for (const auto& rDocElement : aDocument.GetElements())
commit dd4a3fe191aab884380784250144c9fdd9647be3
Author:     Khaled Hosny <kha...@libreoffice.org>
AuthorDate: Mon Jul 17 12:27:03 2023 +0300
Commit:     خالد حسني <kha...@libreoffice.org>
CommitDate: Sun Jul 23 06:01:38 2023 +0200

    vcl: TextRenderModeForResolutionIndependentLayout → SubpixelPositioning
    
    Change-Id: I8698d0f74889ac8a7de64a97e8cf0e8878ef7fc4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154517
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <kha...@libreoffice.org>

diff --git a/include/vcl/vcllayout.hxx b/include/vcl/vcllayout.hxx
index 4acfb9b4ab04..ff9e2d926e88 100644
--- a/include/vcl/vcllayout.hxx
+++ b/include/vcl/vcllayout.hxx
@@ -82,14 +82,14 @@ public:
 
     Degree10        GetOrientation() const                  { return 
mnOrientation; }
 
-    void            SetTextRenderModeForResolutionIndependentLayout(bool 
bTextRenderModeForResolutionIndependentLayout)
+    void            SetSubpixelPositioning(bool bSubpixelPositioning)
     {
-        mbTextRenderModeForResolutionIndependentLayout = 
bTextRenderModeForResolutionIndependentLayout;
+        mbSubpixelPositioning = bSubpixelPositioning;
     }
 
-    bool            GetTextRenderModeForResolutionIndependentLayout() const
+    bool            GetSubpixelPositioning() const
     {
-        return mbTextRenderModeForResolutionIndependentLayout;
+        return mbSubpixelPositioning;
     }
 
     // methods using string indexing
@@ -125,7 +125,7 @@ protected:
     mutable Point   maDrawOffset;
     DevicePoint     maDrawBase;
 
-    bool            mbTextRenderModeForResolutionIndependentLayout;
+    bool            mbSubpixelPositioning;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx
index 325791802ed3..163cb6de56e5 100644
--- a/vcl/qt5/QtGraphics_Text.cxx
+++ b/vcl/qt5/QtGraphics_Text.cxx
@@ -177,8 +177,7 @@ void QtGraphics::DrawTextLayout(const GenericSalLayout& 
rLayout)
 {
     const QtFont* pFont = static_cast<const QtFont*>(&rLayout.GetFont());
     assert(pFont);
-    QRawFont aRawFont(
-        GetRawFont(*pFont, 
rLayout.GetTextRenderModeForResolutionIndependentLayout()));
+    QRawFont aRawFont(GetRawFont(*pFont, rLayout.GetSubpixelPositioning()));
 
     QVector<quint32> glyphIndexes;
     QVector<QPointF> positions;
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index b06e0d41bdbd..bd0d03b216ce 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -397,7 +397,7 @@ void AquaGraphicsBackend::drawTextLayout(const 
GenericSalLayout& rLayout)
         CGContextSetTextDrawingMode(mrShared.maContextHolder.get(), 
kCGTextFillStroke);
     }
 
-    if (rLayout.GetTextRenderModeForResolutionIndependentLayout())
+    if (rLayout.GetSubpixelPositioning())
     {
         
CGContextSetAllowsFontSubpixelQuantization(mrShared.maContextHolder.get(), 
false);
         
CGContextSetShouldSubpixelQuantizeFonts(mrShared.maContextHolder.get(), false);
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
index e392587c8836..89ae4224fb8e 100644
--- a/vcl/skia/osx/gdiimpl.cxx
+++ b/vcl/skia/osx/gdiimpl.cxx
@@ -296,7 +296,7 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType 
nType, ControlPart n
 
 void AquaSkiaSalGraphicsImpl::drawTextLayout(const GenericSalLayout& rLayout)
 {
-    const bool bSubpixelPositioning = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
+    const bool bSubpixelPositioning = rLayout.GetSubpixelPositioning();
     const CoreTextFont& rFont = *static_cast<const 
CoreTextFont*>(&rLayout.GetFont());
     const vcl::font::FontSelectPattern& rFontSelect = 
rFont.GetFontSelectPattern();
     int nHeight = rFontSelect.mnHeight;
diff --git a/vcl/skia/win/gdiimpl.cxx b/vcl/skia/win/gdiimpl.cxx
index 0d7d60f9207e..39294bc2b372 100644
--- a/vcl/skia/win/gdiimpl.cxx
+++ b/vcl/skia/win/gdiimpl.cxx
@@ -256,7 +256,7 @@ bool WinSkiaSalGraphicsImpl::DrawTextLayout(const 
GenericSalLayout& rLayout)
 
     SkFont font(typeface);
 
-    bool bSubpixelPositioning = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
+    bool bSubpixelPositioning = rLayout.GetSubpixelPositioning();
     SkFont::Edging ePreferredAliasing
         = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
fontEdging;
     if (bSubpixelPositioning)
diff --git a/vcl/skia/x11/textrender.cxx b/vcl/skia/x11/textrender.cxx
index c0bbb102f5d8..b4083636d2a0 100644
--- a/vcl/skia/x11/textrender.cxx
+++ b/vcl/skia/x11/textrender.cxx
@@ -71,7 +71,7 @@ void SkiaTextRender::DrawTextLayout(const GenericSalLayout& 
rLayout, const SalGr
     if (rInstance.NeedsArtificialBold())
         font.setEmbolden(true);
 
-    bool bSubpixelPositioning = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
+    bool bSubpixelPositioning = rLayout.GetSubpixelPositioning();
     SkFont::Edging ePreferredAliasing
         = bSubpixelPositioning ? SkFont::Edging::kSubpixelAntiAlias : 
SkFont::Edging::kAntiAlias;
     if (bSubpixelPositioning)
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index ba2f1e050dca..3e1bbf546fa6 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -127,7 +127,7 @@ SalLayout::SalLayout()
     maLanguageTag( LANGUAGE_DONTKNOW ),
     mnOrientation( 0 ),
     maDrawOffset( 0, 0 ),
-    mbTextRenderModeForResolutionIndependentLayout(false)
+    mbSubpixelPositioning(false)
 {}
 
 SalLayout::~SalLayout()
@@ -164,7 +164,7 @@ DevicePoint SalLayout::GetDrawPosition(const DevicePoint& 
rRelative) const
 
         double fX = aOfs.getX();
         double fY = aOfs.getY();
-        if (mbTextRenderModeForResolutionIndependentLayout)
+        if (mbSubpixelPositioning)
         {
             double nX = +fCos * fX + fSin * fY;
             double nY = +fCos * fY - fSin * fX;
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 6e35beccfec0..e3196a512a2c 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1377,7 +1377,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplLayout(const 
OUString& rOrigStr,
     if( !pSalLayout )
         return nullptr;
 
-    pSalLayout->SetTextRenderModeForResolutionIndependentLayout(mbMap);
+    pSalLayout->SetSubpixelPositioning(mbMap);
 
     // do glyph fallback if needed
     // #105768# avoid fallback for very small font sizes
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx 
b/vcl/unx/generic/gdi/cairotextrender.cxx
index 8390e47680be..ef3f05fd7416 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -241,7 +241,7 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
 {
     const LogicalFontInstance& rInstance = rLayout.GetFont();
 
-    const bool bResolutionIndependentLayoutEnabled = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
+    const bool bSubpixelPositioning = rLayout.GetSubpixelPositioning();
 
     /*
      * It might be ideal to cache surface and cairo context between calls and
@@ -279,7 +279,7 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
         const bool bVertical = pGlyph->IsVertical();
         glyph_extrarotation.push_back(bVertical ? 1 : 0);
 
-        if (bResolutionIndependentLayoutEnabled)
+        if (bSubpixelPositioning)
         {
             // tdf#150507 like skia, even when subpixel rendering pixel, snap y
             if (!bVertical)
@@ -419,12 +419,12 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
     const bool bDisableAA = !rStyleSettings.GetUseFontAAFromSystem() && 
!rGraphics.getAntiAlias();
 
     const cairo_font_options_t* pFontOptions = 
GetSalInstance()->GetCairoFontOptions();
-    if (pFontOptions || bDisableAA || bResolutionIndependentLayoutEnabled)
+    if (pFontOptions || bDisableAA || bSubpixelPositioning)
     {
         cairo_hint_style_t eHintStyle = pFontOptions ? 
cairo_font_options_get_hint_style(pFontOptions) : CAIRO_HINT_STYLE_DEFAULT;
-        bool bAllowedHintStyle = !bResolutionIndependentLayoutEnabled || 
(eHintStyle == CAIRO_HINT_STYLE_NONE || eHintStyle == CAIRO_HINT_STYLE_SLIGHT);
+        bool bAllowedHintStyle = !bSubpixelPositioning || (eHintStyle == 
CAIRO_HINT_STYLE_NONE || eHintStyle == CAIRO_HINT_STYLE_SLIGHT);
 
-        if (bDisableAA || !bAllowedHintStyle || 
bResolutionIndependentLayoutEnabled)
+        if (bDisableAA || !bAllowedHintStyle || bSubpixelPositioning)
         {
             // Disable font AA in case global AA setting is supposed to affect
             // font rendering (not the default) and AA is disabled.
@@ -436,7 +436,7 @@ void CairoTextRender::DrawTextLayout(const 
GenericSalLayout& rLayout, const SalG
                 cairo_font_options_set_hint_style(pOptions, 
CAIRO_HINT_STYLE_SLIGHT);
             // Disable private CAIRO_ROUND_GLYPH_POS_ON by merging with font 
options known to have
             // CAIRO_ROUND_GLYPH_POS_OFF
-            if (bResolutionIndependentLayoutEnabled)
+            if (bSubpixelPositioning)
             {
                 cairo_font_options_merge(pOptions, CairoFontOptions::get());
                 // tdf#153699 skip this with cairo 1.17.8 as it has a problem
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 5081456aaaef..925965ce6650 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -225,7 +225,7 @@ void WinSalGraphics::DrawTextLayout(const GenericSalLayout& 
rLayout)
     // DWrite text renderer performs vertical writing better except printing.
     const bool bVerticalScreenText
         = !mbPrinter && rLayout.GetFont().GetFontSelectPattern().mbVertical;
-    const bool bRenderingModeNatural = 
rLayout.GetTextRenderModeForResolutionIndependentLayout();
+    const bool bRenderingModeNatural = rLayout.GetSubpixelPositioning();
     const bool bUseDWrite = bVerticalScreenText || bRenderingModeNatural;
     DrawTextLayout(rLayout, hDC, bUseDWrite, bRenderingModeNatural);
 

Reply via email to