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

2023-11-03 Thread Michael Stahl (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx  |   14 +---
 vcl/qa/cppunit/pdfexport/pdfexport.cxx  |   90 
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx |   72 -
 vcl/source/gdi/pdfwriter_impl.cxx   |   53 +++---
 4 files changed, 108 insertions(+), 121 deletions(-)

New commits:
commit 822a0c4fcd4607d5247b828c69728a510684a442
Author: Michael Stahl 
AuthorDate: Thu Nov 2 16:34:56 2023 +0100
Commit: Michael Stahl 
CommitDate: Fri Nov 3 13:41:08 2023 +0100

tdf#157028 vcl: PDF export: inline OBJR dictionaries

There seems to be no reason why SE child OBJR dictionaries are separate
objects, they could just be inline.

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 23ba7c7baed5..ae8754e6cc1a 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -566,15 +567,10 @@ struct PDFStructureAttribute
 {}
 };
 
-struct PDFStructureElementKid // for Kids entries
-{
-sal_Int32 const nObject;  // an object number if nMCID is -1,
-// else the page object relevant to MCID
-sal_Int32 const nMCID;// an MCID if >= 0
-
-explicit PDFStructureElementKid( sal_Int32 nObj ) : nObject( nObj ), 
nMCID( -1 ) {}
-PDFStructureElementKid( sal_Int32 MCID, sal_Int32 nPage ) : nObject( nPage 
), nMCID( MCID ) {}
-};
+struct ObjReference { sal_Int32 const nObject; };
+struct ObjReferenceObj { sal_Int32 const nObject; };
+struct MCIDReference { sal_Int32 const nPageObj; sal_Int32 const nMCID; };
+typedef ::std::variant 
PDFStructureElementKid;
 
 struct PDFStructureElement
 {
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 9db3cf63f187..ef317e600ca5 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2064,19 +2064,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
 for (size_t i = 0; i < pKids->GetElements().size(); ++i)
 {
 auto pNum = 
dynamic_cast(pKids->GetElement(i));
-auto pRef = 
dynamic_cast(pKids->GetElement(i));
+auto pObjR = 
dynamic_cast(pKids->GetElement(i));
 if (pNum)
 {
 ++nMCID;
 }
-if (pRef)
+if (pObjR)
 {
 ++nRef;
-auto pObjR = pRef->LookupObject();
-auto pOType = 
dynamic_cast(pObjR->Lookup("Type"));
+auto pOType
+= 
dynamic_cast(pObjR->LookupElement("Type"));
 CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
 auto pAnnotRef
-= 
dynamic_cast(pObjR->Lookup("Obj"));
+= 
dynamic_cast(pObjR->LookupElement("Obj"));
 auto pAnnot = pAnnotRef->LookupObject();
 auto pAType = 
dynamic_cast(pAnnot->Lookup("Type"));
 CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2129,19 +2129,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
 for (size_t i = 0; i < pKids->GetElements().size(); ++i)
 {
 auto pNum = 
dynamic_cast(pKids->GetElement(i));
-auto pRef = 
dynamic_cast(pKids->GetElement(i));
+auto pObjR = 
dynamic_cast(pKids->GetElement(i));
 if (pNum)
 {
 ++nMCID;
 }
-if (pRef)
+if (pObjR)
 {
 ++nRef;
-auto pObjR = pRef->LookupObject();
-auto pOType = 
dynamic_cast(pObjR->Lookup("Type"));
+auto pOType
+= 
dynamic_cast(pObjR->LookupElement("Type"));
 CPPUNIT_ASSERT_EQUAL(OString("OBJR"), pOType->GetValue());
 auto pAnnotRef
-= 
dynamic_cast(pObjR->Lookup("Obj"));
+= 
dynamic_cast(pObjR->LookupElement("Obj"));
 auto pAnnot = pAnnotRef->LookupObject();
 auto pAType = 
dynamic_cast(pAnnot->Lookup("Type"));
 CPPUNIT_ASSERT_EQUAL(OString("Annot"), pAType->GetValue());
@@ -2193,19 +2193,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816)
 for (size_t i = 0; i < pKids->GetElements().size(); ++i)
 {
 auto pNum = 
dynamic_cast(pKids->GetElement(i));
-auto pRef = 
dynamic_cast(pKids->GetElement(i));
+auto pObjR = 
dynamic_cast(pKids->GetElement(i));
 if (pNum)
 {
 ++nMCID;
 }
-if (pRef)
+if (pObjR)
 {
 ++nRef;
-  

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

2023-07-30 Thread Khaled Hosny (via logerrit)
 vcl/inc/sallayout.hxx  |4 +++-
 vcl/qa/cppunit/complextext.cxx |   33 +
 vcl/source/gdi/CommonSalLayout.cxx |   15 +++
 3 files changed, 51 insertions(+), 1 deletion(-)

New commits:
commit d4653fa961b1aa1cd4bf568e7d1fe50ae97df484
Author: Khaled Hosny 
AuthorDate: Sun Jul 30 07:12:53 2023 +0300
Commit: خالد حسني 
CommitDate: Sun Jul 30 09:50:11 2023 +0200

tdf#107612: Include NNBSP and Mongolian characters in the same fallback run

When a Mongolian character is preceded by a Narrow No Break Space
(NNBSP), it is used to trigger special letter forms, but when we do font
fallback NNBSP is always taken from the main font (HarfBuzz synthesises
it when missing from the font, so we almost never use font fallback for
it).

We now check if the start of the fallback run is a Mongolian character
and the previous is NNBSP and extend the fallback run to include it.

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

diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index dbe3000f8a83..94f0086b1517 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -57,7 +57,7 @@ namespace vcl::text {
 class TextLayoutCache;
 }
 
-class MultiSalLayout final : public SalLayout
+class VCL_DLLPUBLIC MultiSalLayout final : public SalLayout
 {
 public:
 voidDrawText(SalGraphics&) const override;
@@ -86,6 +86,8 @@ public:
   vcl::text::ImplLayoutArgs& 
rMultiArgs,
   const double* pMultiDXArray);
 
+SAL_DLLPRIVATE ImplLayoutRuns* GetFallbackRuns() { return maFallbackRuns; }
+
 virtual ~MultiSalLayout() override;
 
 private:
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index bcb0c9622361..ec6ce0ccd0e2 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -540,4 +540,37 @@ CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107718)
 #endif
 }
 
+CPPUNIT_TEST_FIXTURE(VclComplexTextTest, testTdf107612)
+{
+#if HAVE_MORE_FONTS
+vcl::Font aFont(u"DejaVu Sans", u"Book", Size(0, 72));
+
+ScopedVclPtrInstance pOutDev;
+pOutDev->SetFont(aFont);
+
+auto pLayout = pOutDev->ImplLayout(u"a\u202F\u1823", 0, -1, Point(0, 0), 
0, {}, {});
+
+// If font fallback happened, then the returned layout must be a
+// MultiSalLayout instance.
+auto pMultiLayout = dynamic_cast(pLayout.get());
+CPPUNIT_ASSERT(pMultiLayout);
+
+auto pFallbackRuns = pMultiLayout->GetFallbackRuns();
+CPPUNIT_ASSERT(!pFallbackRuns->IsEmpty());
+
+bool bRTL;
+int nCharPos = -1;
+std::vector aFallbacks;
+while (pFallbackRuns->GetNextPos(, ))
+aFallbacks.push_back(nCharPos);
+
+// Assert that U+202F is included in the fallback run.
+// Without the fix this fails with:
+// - Expected: { 2 }
+// - Actual  : { 1, 2 }
+std::vector aExpctedFallbacks = { 1, 2 };
+CPPUNIT_ASSERT_EQUAL(aFallbacks, aExpctedFallbacks);
+#endif
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 3a5fdbef0ad0..79f1a0d2c40c 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -128,6 +128,21 @@ void 
GenericSalLayout::SetNeedFallback(vcl::text::ImplLayoutArgs& rArgs, sal_Int
 mxBreak->previousCharacters(rArgs.mrStr, nCharPos, aLocale,
 i18n::CharacterIteratorMode::SKIPCELL, 1, nDone);
 
+// tdf#107612
+// If the start of the fallback run is Mongolian character and the previous
+// character is NNBSP, we want to include the NNBSP in the fallback since
+// it has special uses in Mongolian and have to be in the same text run to
+// work.
+sal_Int32 nTempPos = nGraphemeStartPos;
+if (nGraphemeStartPos > 0)
+{
+auto nCurrChar = rArgs.mrStr.iterateCodePoints(, 0);
+auto nPrevChar = rArgs.mrStr.iterateCodePoints(, -1);
+if (nPrevChar == 0x202F
+&& u_getIntPropertyValue(nCurrChar, UCHAR_SCRIPT) == 
USCRIPT_MONGOLIAN)
+nGraphemeStartPos = nTempPos;
+}
+
 //stay inside the Layout range (e.g. with tdf124116-1.odt)
 nGraphemeStartPos = std::max(rArgs.mnMinCharPos, nGraphemeStartPos);
 nGraphemeEndPos = std::min(rArgs.mnEndCharPos, nGraphemeEndPos);


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

2022-12-29 Thread Noel Grandin (via logerrit)
 vcl/inc/SwapFile.hxx   |   39 +--
 vcl/inc/impgraph.hxx   |2 -
 vcl/qa/cppunit/GraphicTest.cxx |   82 ++---
 vcl/source/gdi/impgraph.cxx|   68 --
 4 files changed, 57 insertions(+), 134 deletions(-)

New commits:
commit 9645e4003c1787a32aa13a261fb94accf6770138
Author: Noel Grandin 
AuthorDate: Wed Dec 28 18:48:42 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Dec 29 10:27:11 2022 +

use TempFileFast for vcl graphics swapout

which is considerably faster on Windows when there is lots of
system RAM available.

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

diff --git a/vcl/inc/SwapFile.hxx b/vcl/inc/SwapFile.hxx
index 64060fd306a9..7ca34fb60698 100644
--- a/vcl/inc/SwapFile.hxx
+++ b/vcl/inc/SwapFile.hxx
@@ -22,8 +22,7 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
 #include 
 
 namespace vcl
@@ -31,42 +30,10 @@ namespace vcl
 class VCL_DLLPUBLIC SwapFile
 {
 private:
-INetURLObject maSwapURL;
+utl::TempFileFast maTempFile;
 
 public:
-SwapFile(INetURLObject aSwapURL)
-: maSwapURL(std::move(aSwapURL))
-{
-}
-
-~SwapFile() COVERITY_NOEXCEPT_FALSE
-{
-
utl::UCBContentHelper::Kill(maSwapURL.GetMainURL(INetURLObject::DecodeMechanism::NONE));
-}
-
-const INetURLObject& getSwapURL() const { return maSwapURL; }
-
-OUString getSwapURLString() const
-{
-return maSwapURL.GetMainURL(INetURLObject::DecodeMechanism::NONE);
-}
-
-std::unique_ptr openOutputStream()
-{
-OUString sSwapURL = getSwapURLString();
-if (!sSwapURL.isEmpty())
-{
-try
-{
-return utl::UcbStreamHelper::CreateStream(
-sSwapURL, StreamMode::READWRITE | 
StreamMode::SHARE_DENYWRITE);
-}
-catch (const css::uno::Exception&)
-{
-}
-}
-return std::unique_ptr();
-}
+SvStream* getStream() { return 
maTempFile.GetStream(StreamMode::READWRITE); }
 };
 }
 
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 6007dcc63ed1..b62cc8e623ec 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -216,7 +216,7 @@ public:
 bool swapIn();
 bool swapOut();
 bool isSwappedOut() const { return mbSwapOut; }
-OUString getSwapFileURL() const;
+SvStream* getSwapFileStream() const;
 // public only because of use in GraphicFilter
 void updateFromLoadedGraphic(const ImpGraphic* graphic);
 };
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 90164c7e317c..2dff15f29d34 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -191,26 +191,10 @@ std::string toHexString(const std::vector& 
a)
 return aStrm.str();
 }
 
-std::unique_ptr createStream(OUString const& rSwapFileURL)
-{
-std::unique_ptr xStream;
-
-try
-{
-xStream = ::utl::UcbStreamHelper::CreateStream(
-rSwapFileURL, StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE);
-}
-catch (const css::uno::Exception&)
-{
-}
-
-return xStream;
-}
-
-std::vector calculateHash(std::unique_ptr& rStream)
+std::vector calculateHash(SvStream* pStream)
 {
 comphelper::Hash aHashEngine(comphelper::HashType::SHA1);
-const sal_uInt32 nSize(rStream->remainingSize());
+const sal_uInt32 nSize(pStream->remainingSize());
 std::vector aData(nSize);
 aHashEngine.update(aData.data(), nSize);
 return aHashEngine.finalize();
@@ -576,7 +560,7 @@ void GraphicTest::testSwappingGraphic_PNG_WithGfxLink()
 sal_uLong rByteSize = aGraphic.GetSizeBytes();
 
 // Check the swap file (shouldn't exist)
-CPPUNIT_ASSERT_EQUAL(true, 
aGraphic.ImplGetImpGraphic()->getSwapFileURL().isEmpty());
+CPPUNIT_ASSERT_EQUAL(true, 
aGraphic.ImplGetImpGraphic()->getSwapFileStream() == nullptr);
 
 // Swapping out
 CPPUNIT_ASSERT_EQUAL(true, aGraphic.ImplGetImpGraphic()->swapOut());
@@ -587,7 +571,7 @@ void GraphicTest::testSwappingGraphic_PNG_WithGfxLink()
 CPPUNIT_ASSERT_EQUAL(rByteSize, aGraphic.GetSizeBytes());
 
 // Check the swap file (still shouldn't exist)
-CPPUNIT_ASSERT_EQUAL(true, 
aGraphic.ImplGetImpGraphic()->getSwapFileURL().isEmpty());
+CPPUNIT_ASSERT_EQUAL(true, 
aGraphic.ImplGetImpGraphic()->getSwapFileStream() == nullptr);
 
 // Let's swap in
 CPPUNIT_ASSERT_EQUAL(false, aGraphic.isAvailable());
@@ -627,8 +611,7 @@ void GraphicTest::testSwappingGraphic_PNG_WithoutGfxLink()
 
 // Get the declared byte size of the graphic
 sal_uLong rByteSize = aGraphic.GetSizeBytes();
-OUString rSwapFileURL = aGraphic.ImplGetImpGraphic()->getSwapFileURL();
-CPPUNIT_ASSERT_EQUAL(true, rSwapFileURL.isEmpty());
+

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

2022-11-24 Thread Caolán McNamara (via logerrit)
 vcl/inc/impglyphitem.hxx|8 
 vcl/qa/cppunit/complextext.cxx  |2 +-
 vcl/source/gdi/impglyphitem.cxx |6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 96aa8a8f1c4ec2b038f0eb486c7e5c240c0092a2
Author: Caolán McNamara 
AuthorDate: Thu Nov 24 11:08:27 2022 +
Commit: Caolán McNamara 
CommitDate: Thu Nov 24 14:57:34 2022 +0100

relax glyph assert wrt layout equivalency

as per: https://github.com/harfbuzz/harfbuzz/issues/3888

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

diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index 87276657e641..87f966bd1676 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -105,15 +105,15 @@ public:
 void setLinearPos(const DevicePoint& point) { m_aLinearPos = point; }
 void setLinearPosX(double x) { m_aLinearPos.setX(x); }
 void adjustLinearPosX(double diff) { m_aLinearPos.adjustX(diff); }
-bool operator==(const GlyphItem& other) const
+bool isLayoutEquivalent(const GlyphItem& other) const
 {
 return m_aLinearPos == other.m_aLinearPos && m_nOrigWidth == 
other.m_nOrigWidth
&& m_nCharPos == other.m_nCharPos && m_nXOffset == 
other.m_nXOffset
&& m_nYOffset == other.m_nYOffset && m_nNewWidth == 
other.m_nNewWidth
&& m_aGlyphId == other.m_aGlyphId && m_nCharCount == 
other.m_nCharCount
-   && m_nFlags == other.m_nFlags;
+   && (m_nFlags & ~GlyphItemFlags::IS_UNSAFE_TO_BREAK)
+  == (other.m_nFlags & 
~GlyphItemFlags::IS_UNSAFE_TO_BREAK);
 }
-bool operator!=(const GlyphItem& other) const { return !(*this == other); }
 };
 
 bool GlyphItem::GetGlyphBoundRect(const LogicalFontInstance* pFontInstance,
@@ -148,7 +148,7 @@ public:
 void SetFlags(SalLayoutFlags flags) { mnFlags = flags; }
 SalLayoutFlags GetFlags() const { return mnFlags; }
 #ifdef DBG_UTIL
-bool isEqual(const SalLayoutGlyphsImpl* other) const;
+bool isLayoutEquivalent(const SalLayoutGlyphsImpl* other) const;
 #endif
 
 private:
diff --git a/vcl/qa/cppunit/complextext.cxx b/vcl/qa/cppunit/complextext.cxx
index 77b9444d1c74..92f537b1b73a 100644
--- a/vcl/qa/cppunit/complextext.cxx
+++ b/vcl/qa/cppunit/complextext.cxx
@@ -147,7 +147,7 @@ static void checkCompareGlyphs( const SalLayoutGlyphs& 
aGlyphs1, const SalLayout
 CPPUNIT_ASSERT_EQUAL_MESSAGE(messageLevel, g1->size(), g2->size());
 for( size_t i = 0; i < g1->size(); ++i )
 {
-const bool equal = (*g1)[i] == (*g2)[i];
+const bool equal = (*g1)[i].isLayoutEquivalent((*g2)[i]);
 CPPUNIT_ASSERT_MESSAGE(messageLevel, equal);
 }
 }
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 2ee4938f51d8..6a2c576e1f1a 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -200,7 +200,7 @@ bool SalLayoutGlyphsImpl::isSafeToBreak(const_iterator pos, 
bool rtl) const
 }
 
 #ifdef DBG_UTIL
-bool SalLayoutGlyphsImpl::isEqual(const SalLayoutGlyphsImpl* other) const
+bool SalLayoutGlyphsImpl::isLayoutEquivalent(const SalLayoutGlyphsImpl* other) 
const
 {
 if (!GetFont()->mxFontMetric->CompareDeviceIndependentFontAttributes(
 *other->GetFont()->mxFontMetric))
@@ -213,7 +213,7 @@ bool SalLayoutGlyphsImpl::isEqual(const 
SalLayoutGlyphsImpl* other) const
 return false;
 for (size_t pos = 0; pos < size(); ++pos)
 {
-if ((*this)[pos] != (*other)[pos])
+if (!(*this)[pos].isLayoutEquivalent((*other)[pos]))
 return false;
 }
 return true;
@@ -314,7 +314,7 @@ static void checkGlyphsEqual(const SalLayoutGlyphs& g1, 
const SalLayoutGlyphs& g
 assert(l1 == l2);
 break;
 }
-assert(l1->isEqual(l2));
+assert(l1->isLayoutEquivalent(l2));
 }
 }
 #endif


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

2022-10-03 Thread Caolán McNamara (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx |3 ++-
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   11 +++
 vcl/source/gdi/pdfwriter_impl.cxx  |   14 +-
 3 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit a0bc0cc81b597aa81189355a8125753d6b873cce
Author: Caolán McNamara 
AuthorDate: Mon Oct 3 09:01:56 2022 +0100
Commit: Caolán McNamara 
CommitDate: Mon Oct 3 10:54:03 2022 +0200

tdf#150786 use the same colors for pdf widgets regardless of theme

use StyleSettings::SetStandardStyles()

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 500fd6e89d64..9f099f58b6a4 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -55,11 +55,11 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
 
-class StyleSettings;
 class FontSubsetInfo;
 class ZCodec;
 class EncHashTransporter;
@@ -692,6 +692,7 @@ private:
 void DrawHatchLine_DrawLine(const Point& rStartPoint, const Point& 
rEndPoint) override;
 
 MapMode m_aMapMode; // PDFWriterImpl scaled 
units
+StyleSettings   m_aWidgetStyleSettings;
 std::vector< PDFPage >  m_aPages;
 /* maps object numbers to file offsets (needed for xref) */
 std::vector< sal_uInt64 >   m_aObjects;
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index faf87842d8cf..88139dd0ecd4 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2732,17 +2732,12 @@ 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: rg /TiRo 12 Tf
-// - Actual  : rg /F2 12 Tf
+// - 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("rg /TiRo 12 Tf"), aDA.copy(rgPos));
+CPPUNIT_ASSERT_EQUAL(OUString("0 0 0 rg /TiRo 12 Tf"), aDA);
 }
 
 // Check we don't have duplicated objects when we reexport the PDF multiple
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 5731352459ea..2082056940f9 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1193,6 +1193,7 @@ PDFWriterImpl::PDFWriterImpl( const 
PDFWriter::PDFWriterContext& rContext,
PDFWriter& i_rOuterFace)
 : VirtualDevice(Application::GetDefaultDevice(), 
DeviceFormat::DEFAULT, DeviceFormat::NONE, OUTDEV_PDF),
 m_aMapMode( MapUnit::MapPoint, Point(), Fraction( 1, pointToPixel(1) 
), Fraction( 1, pointToPixel(1) ) ),
+m_aWidgetStyleSettings(Application::GetSettings().GetStyleSettings()),
 m_nCurrentStructElement( 0 ),
 m_bEmitStructure( true ),
 m_nNextFID( 1 ),
@@ -1228,6 +1229,9 @@ PDFWriterImpl::PDFWriterImpl( const 
PDFWriter::PDFWriterContext& rContext,
 aFont.SetFamilyName( "Times" );
 aFont.SetFontSize( Size( 0, 12 ) );
 
+// tdf#150786 use the same settings for widgets regardless of theme
+m_aWidgetStyleSettings.SetStandardStyles();
+
 GraphicsState aState;
 aState.m_aMapMode   = m_aMapMode;
 aState.m_aFont  = aFont;
@@ -3902,7 +3906,7 @@ static const Color& replaceColor( const Color& rCol1, 
const Color& rCol2 )
 
 void PDFWriterImpl::createDefaultPushButtonAppearance( PDFWidget& rButton, 
const PDFWriter::PushButtonWidget& rWidget )
 {
-const StyleSettings& rSettings = 
Application::GetSettings().GetStyleSettings();
+const StyleSettings& rSettings = m_aWidgetStyleSettings;
 
 // save graphics state
 push( PushFlags::ALL );
@@ -4009,7 +4013,7 @@ Font PDFWriterImpl::drawFieldBorder( PDFWidget& rIntern,
 
 void PDFWriterImpl::createDefaultEditAppearance( PDFWidget& rEdit, const 
PDFWriter::EditWidget& rWidget )
 {
-const StyleSettings& rSettings = 
Application::GetSettings().GetStyleSettings();
+const StyleSettings& rSettings = m_aWidgetStyleSettings;
 SvMemoryStream* pEditStream = new SvMemoryStream( 1024, 1024 );
 
 push( PushFlags::ALL );
@@ -4055,7 +4059,7 @@ void PDFWriterImpl::createDefaultEditAppearance( 
PDFWidget& rEdit, const PDFWrit
 
 void 

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

2022-08-25 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/OpenTypeFeatureStrings.hrc |1 
 vcl/qa/cppunit/FontFeatureTest.cxx  |   61 
 vcl/source/font/FeatureCollector.cxx|   69 
 3 files changed, 124 insertions(+), 7 deletions(-)

New commits:
commit 9ca3c6794ca1969f453ddaa66c4e02ac8c695cc6
Author: Khaled Hosny 
AuthorDate: Wed Aug 24 07:54:15 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Aug 25 13:04:27 2022 +0200

FeatureCollector: Detect ENUM features in OpenType fonts

A bit heavy handed, but the only way to detect the number of alternates
a feature has is to get the maximum number of alternates for all lookups
in all glyphs of this feature, which is what this code does.

Additionally, for cvXX features, parameter names from the font are used
when available.

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

diff --git a/vcl/inc/font/OpenTypeFeatureStrings.hrc 
b/vcl/inc/font/OpenTypeFeatureStrings.hrc
index a8bb5473fafb..aebdda1d2743 100644
--- a/vcl/inc/font/OpenTypeFeatureStrings.hrc
+++ b/vcl/inc/font/OpenTypeFeatureStrings.hrc
@@ -97,6 +97,7 @@
 #define STR_FONT_FEATURE_ID_VRT2  NC_("STR_FONT_FEATURE_ID_VRT2", 
"Vertical Alternates and Rotation")
 #define STR_FONT_FEATURE_ID_VRTR  NC_("STR_FONT_FEATURE_ID_VRTR", 
"Vertical Alternates for Rotation")
 #define STR_FONT_FEATURE_ID_ZERO  NC_("STR_FONT_FEATURE_ID_ZERO", 
"Slashed Zero")
+#define STR_FONT_FEATURE_PARAM_NONE   NC_("STR_FONT_FEATURE_PARAM_NONE", 
"None")
 
 #endif // INCLUDED_VCL_INC_STRINGS_HRC
 
diff --git a/vcl/qa/cppunit/FontFeatureTest.cxx 
b/vcl/qa/cppunit/FontFeatureTest.cxx
index 103870306bcf..9858c96e0a9f 100644
--- a/vcl/qa/cppunit/FontFeatureTest.cxx
+++ b/vcl/qa/cppunit/FontFeatureTest.cxx
@@ -27,11 +27,13 @@ public:
 
 void testGetFontFeaturesGraphite();
 void testGetFontFeaturesOpenType();
+void testGetFontFeaturesOpenTypeEnum();
 void testParseFeature();
 
 CPPUNIT_TEST_SUITE(FontFeatureTest);
 CPPUNIT_TEST(testGetFontFeaturesGraphite);
 CPPUNIT_TEST(testGetFontFeaturesOpenType);
+CPPUNIT_TEST(testGetFontFeaturesOpenTypeEnum);
 CPPUNIT_TEST(testParseFeature);
 CPPUNIT_TEST_SUITE_END();
 };
@@ -169,6 +171,65 @@ void FontFeatureTest::testGetFontFeaturesOpenType()
 #endif // HAVE_MORE_FONTS
 }
 
+void FontFeatureTest::testGetFontFeaturesOpenTypeEnum()
+{
+#if HAVE_MORE_FONTS
+ScopedVclPtrInstance aVDev(*Application::GetDefaultDevice(),
+  DeviceFormat::DEFAULT, 
DeviceFormat::DEFAULT);
+aVDev->SetOutputSizePixel(Size(10, 10));
+
+OUString aFontName("Reem Kufi");
+CPPUNIT_ASSERT(aVDev->IsFontAvailable(aFontName));
+
+vcl::Font aFont = aVDev->GetFont();
+aFont.SetFamilyName(aFontName);
+aFont.SetWeight(FontWeight::WEIGHT_NORMAL);
+aFont.SetItalic(FontItalic::ITALIC_NORMAL);
+aFont.SetWidthType(FontWidth::WIDTH_NORMAL);
+aVDev->SetFont(aFont);
+
+std::vector rFontFeatures;
+CPPUNIT_ASSERT(aVDev->GetFontFeatures(rFontFeatures));
+
+OUString aFeaturesString;
+for (vcl::font::Feature const& rFeature : rFontFeatures)
+aFeaturesString += vcl::font::featureCodeAsString(rFeature.m_nCode) + 
" ";
+
+CPPUNIT_ASSERT_EQUAL(size_t(10), rFontFeatures.size());
+
+CPPUNIT_ASSERT_EQUAL(OUString("aalt case cv01 cv02 cv03 frac ordn sups "
+  "zero kern "),
+ aFeaturesString);
+
+// Check aalt feature
+{
+vcl::font::Feature& rFeature = rFontFeatures[0];
+CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("aalt"), rFeature.m_nCode);
+
+vcl::font::FeatureDefinition& rFeatureDefinition = 
rFeature.m_aDefinition;
+CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("aalt"), 
rFeatureDefinition.getCode());
+CPPUNIT_ASSERT(!rFeatureDefinition.getDescription().isEmpty());
+CPPUNIT_ASSERT_EQUAL(vcl::font::FeatureParameterType::ENUM, 
rFeatureDefinition.getType());
+
+CPPUNIT_ASSERT_EQUAL(size_t(3), 
rFeatureDefinition.getEnumParameters().size());
+
+vcl::font::FeatureParameter const& rParameter1 = 
rFeatureDefinition.getEnumParameters()[0];
+CPPUNIT_ASSERT_EQUAL(uint32_t(0), rParameter1.getCode());
+CPPUNIT_ASSERT(!rParameter1.getDescription().isEmpty());
+
+vcl::font::FeatureParameter const& rParameter2 = 
rFeatureDefinition.getEnumParameters()[1];
+CPPUNIT_ASSERT_EQUAL(uint32_t(1), rParameter2.getCode());
+CPPUNIT_ASSERT(!rParameter2.getDescription().isEmpty());
+
+vcl::font::FeatureParameter const& rParameter3 = 
rFeatureDefinition.getEnumParameters()[2];
+CPPUNIT_ASSERT_EQUAL(uint32_t(2), rParameter3.getCode());
+CPPUNIT_ASSERT(!rParameter2.getDescription().isEmpty());
+}
+
+

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

2022-08-25 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/FeatureCollector.hxx  |6 +-
 vcl/inc/font/OpenTypeFeatureDefinitionList.hxx |2 
 vcl/qa/cppunit/FontFeatureTest.cxx |   57 +++--
 vcl/source/font/FeatureCollector.cxx   |   46 +++-
 vcl/source/outdev/font.cxx |4 -
 5 files changed, 105 insertions(+), 10 deletions(-)

New commits:
commit 19787042b1f139cb9c366801d283c6c0227e85e6
Author: Khaled Hosny 
AuthorDate: Wed Aug 24 00:26:10 2022 +0200
Commit: Tomaž Vajngerl 
CommitDate: Thu Aug 25 13:03:55 2022 +0200

FeatureCollector: Get feature labels for ssXX/cvXX features from the font

If the font provides feature labels for ssXX/cvXX features, fetch and
use them.

Switches also to using the UI language not locale for finding labels as
the UI language is what controls the UI localization.

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

diff --git a/vcl/inc/font/FeatureCollector.hxx 
b/vcl/inc/font/FeatureCollector.hxx
index 976a89fc8d86..ae784474e06d 100644
--- a/vcl/inc/font/FeatureCollector.hxx
+++ b/vcl/inc/font/FeatureCollector.hxx
@@ -22,14 +22,14 @@ class FeatureCollector
 private:
 hb_face_t* m_pHbFace;
 std::vector& m_rFontFeatures;
-LanguageType m_eLanguageType;
+const LanguageTag& m_rLanguageTag;
 
 public:
 FeatureCollector(hb_face_t* pHbFace, std::vector& 
rFontFeatures,
- LanguageType eLanguageType)
+ const LanguageTag& rLanguageTag)
 : m_pHbFace(pHbFace)
 , m_rFontFeatures(rFontFeatures)
-, m_eLanguageType(eLanguageType)
+, m_rLanguageTag(rLanguageTag)
 {
 }
 
diff --git a/vcl/inc/font/OpenTypeFeatureDefinitionList.hxx 
b/vcl/inc/font/OpenTypeFeatureDefinitionList.hxx
index 52dbcfb5b9f0..aaa89ebe5d48 100644
--- a/vcl/inc/font/OpenTypeFeatureDefinitionList.hxx
+++ b/vcl/inc/font/OpenTypeFeatureDefinitionList.hxx
@@ -25,12 +25,12 @@ private:
 
 void init();
 
-static bool isSpecialFeatureCode(sal_uInt32 nFeatureCode);
 static FeatureDefinition handleSpecialFeatureCode(sal_uInt32 nFeatureCode);
 
 public:
 OpenTypeFeatureDefinitionListPrivate();
 FeatureDefinition getDefinition(sal_uInt32 nFeatureCode);
+static bool isSpecialFeatureCode(sal_uInt32 nFeatureCode);
 bool isRequired(sal_uInt32 nFeatureCode);
 };
 
diff --git a/vcl/qa/cppunit/FontFeatureTest.cxx 
b/vcl/qa/cppunit/FontFeatureTest.cxx
index 91bcda29b74f..103870306bcf 100644
--- a/vcl/qa/cppunit/FontFeatureTest.cxx
+++ b/vcl/qa/cppunit/FontFeatureTest.cxx
@@ -25,16 +25,18 @@ public:
 {
 }
 
-void testGetFontFeatures();
+void testGetFontFeaturesGraphite();
+void testGetFontFeaturesOpenType();
 void testParseFeature();
 
 CPPUNIT_TEST_SUITE(FontFeatureTest);
-CPPUNIT_TEST(testGetFontFeatures);
+CPPUNIT_TEST(testGetFontFeaturesGraphite);
+CPPUNIT_TEST(testGetFontFeaturesOpenType);
 CPPUNIT_TEST(testParseFeature);
 CPPUNIT_TEST_SUITE_END();
 };
 
-void FontFeatureTest::testGetFontFeatures()
+void FontFeatureTest::testGetFontFeaturesGraphite()
 {
 #if HAVE_MORE_FONTS
 ScopedVclPtrInstance aVDev(*Application::GetDefaultDevice(),
@@ -118,6 +120,55 @@ void FontFeatureTest::testGetFontFeatures()
 #endif // HAVE_MORE_FONTS
 }
 
+void FontFeatureTest::testGetFontFeaturesOpenType()
+{
+#if HAVE_MORE_FONTS
+ScopedVclPtrInstance aVDev(*Application::GetDefaultDevice(),
+  DeviceFormat::DEFAULT, 
DeviceFormat::DEFAULT);
+aVDev->SetOutputSizePixel(Size(10, 10));
+
+OUString aFontName("Amiri");
+CPPUNIT_ASSERT(aVDev->IsFontAvailable(aFontName));
+
+vcl::Font aFont = aVDev->GetFont();
+aFont.SetFamilyName(aFontName);
+aFont.SetWeight(FontWeight::WEIGHT_NORMAL);
+aFont.SetItalic(FontItalic::ITALIC_NORMAL);
+aFont.SetWidthType(FontWidth::WIDTH_NORMAL);
+aVDev->SetFont(aFont);
+
+std::vector rFontFeatures;
+CPPUNIT_ASSERT(aVDev->GetFontFeatures(rFontFeatures));
+
+OUString aFeaturesString;
+for (vcl::font::Feature const& rFeature : rFontFeatures)
+aFeaturesString += vcl::font::featureCodeAsString(rFeature.m_nCode) + 
" ";
+
+CPPUNIT_ASSERT_EQUAL(size_t(17), rFontFeatures.size());
+
+CPPUNIT_ASSERT_EQUAL(OUString("calt calt dnom liga numr pnum ss01 ss02 "
+  "ss03 ss04 ss05 ss06 ss07 ss08 kern kern "
+  "ss05 "),
+ aFeaturesString);
+
+// Check ss01 feature
+{
+vcl::font::Feature& rFeature = rFontFeatures[6];
+CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("ss01"), rFeature.m_nCode);
+
+vcl::font::FeatureDefinition& rFeatureDefinition = 
rFeature.m_aDefinition;
+CPPUNIT_ASSERT_EQUAL(vcl::font::featureCode("ss01"), 

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

2022-07-11 Thread Chris Sherlock (via logerrit)
 vcl/inc/animate/AnimationRenderer.hxx|6 +++---
 vcl/qa/cppunit/animationrenderer.cxx |8 
 vcl/source/animate/AnimationRenderer.cxx |   20 ++--
 3 files changed, 17 insertions(+), 17 deletions(-)

New commits:
commit a19e01812b60580c656cf31619e212803e2ca0fa
Author: Chris Sherlock 
AuthorDate: Fri Jun 24 17:52:41 2022 +1000
Commit: Tomaž Vajngerl 
CommitDate: Mon Jul 11 11:05:33 2022 +0200

vcl: change drawToPos() to drawToIndex()

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

diff --git a/vcl/inc/animate/AnimationRenderer.hxx 
b/vcl/inc/animate/AnimationRenderer.hxx
index c7fc42a55aa3..18128558a44e 100644
--- a/vcl/inc/animate/AnimationRenderer.hxx
+++ b/vcl/inc/animate/AnimationRenderer.hxx
@@ -60,7 +60,7 @@ private:
 vcl::Region maClip;
 VclPtr  mpBackground;
 VclPtr  mpRestore;
-sal_uLong   mnActPos;
+sal_uLong   mnActIndex;
 DisposalmeLastDisposal;
 boolmbIsPaused;
 boolmbIsMarked;
@@ -75,8 +75,8 @@ public:
 ~AnimationRenderer();
 
 boolmatches(const OutputDevice* pOut, tools::Long nRendererId) 
const;
-voiddrawToPos( sal_uLong nPos );
-voiddraw( sal_uLong nPos, VirtualDevice* pVDev=nullptr );
+voiddrawToIndex( sal_uLong nIndex );
+voiddraw( sal_uLong nIndex, VirtualDevice* pVDev=nullptr );
 voidrepaint();
 AInfo*  createAInfo() const;
 
diff --git a/vcl/qa/cppunit/animationrenderer.cxx 
b/vcl/qa/cppunit/animationrenderer.cxx
index 25dfdc44dab5..b4e7f235e883 100644
--- a/vcl/qa/cppunit/animationrenderer.cxx
+++ b/vcl/qa/cppunit/animationrenderer.cxx
@@ -76,10 +76,10 @@ void VclAnimationRendererTest::testDrawToPos()
 
 AnimationRenderer* pAnimationRenderer
 = new AnimationRenderer(, pTestRC.get(), Point(0, 0), 
Size(10, 10), 5);
-pAnimationRenderer->drawToPos(0);
-pAnimationRenderer->drawToPos(1);
-pAnimationRenderer->drawToPos(2);
-pAnimationRenderer->drawToPos(10);
+pAnimationRenderer->drawToIndex(0);
+pAnimationRenderer->drawToIndex(1);
+pAnimationRenderer->drawToIndex(2);
+pAnimationRenderer->drawToIndex(10);
 
 CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestRC->GetOutputSizePixel());
 }
diff --git a/vcl/source/animate/AnimationRenderer.cxx 
b/vcl/source/animate/AnimationRenderer.cxx
index 611d1c71fd6e..59843e19c893 100644
--- a/vcl/source/animate/AnimationRenderer.cxx
+++ b/vcl/source/animate/AnimationRenderer.cxx
@@ -39,7 +39,7 @@ AnimationRenderer::AnimationRenderer( Animation* pParent, 
OutputDevice* pOut,
 maClip  ( mpRenderContext->GetClipRegion() ),
 mpBackground( VclPtr::Create() ),
 mpRestore   ( VclPtr::Create() ),
-mnActPos( 0 ),
+mnActIndex  ( 0 ),
 meLastDisposal  ( Disposal::Back ),
 mbIsPaused  ( false ),
 mbIsMarked  ( false ),
@@ -79,7 +79,7 @@ AnimationRenderer::AnimationRenderer( Animation* pParent, 
OutputDevice* pOut,
 mpRenderContext->SaveBackground(*mpBackground, maDispPt, maDispSz, 
maSzPix);
 
 // Initialize drawing to actual position
-drawToPos( mpParent->ImplGetCurPos() );
+drawToIndex( mpParent->ImplGetCurPos() );
 
 // If first frame OutputDevice is set, update variables now for real 
OutputDevice
 if( pFirstFrameOutDev )
@@ -139,7 +139,7 @@ void AnimationRenderer::getPosSize( const AnimationBitmap& 
rAnimationBitmap, Poi
 rPosPix.setY( maSzPix.Height() - 1 - aPt2.Y() );
 }
 
-void AnimationRenderer::drawToPos( sal_uLong nPos )
+void AnimationRenderer::drawToIndex( sal_uLong nIndex )
 {
 VclPtr pRenderContext = mpRenderContext;
 
@@ -157,9 +157,9 @@ void AnimationRenderer::drawToPos( sal_uLong nPos )
 xOldClip = pRenderContext->GetClipRegion();
 
 aVDev->SetOutputSizePixel( maSzPix, false );
-nPos = std::min( nPos, static_cast(mpParent->Count()) - 1 );
+nIndex = std::min( nIndex, static_cast(mpParent->Count()) - 1 );
 
-for( sal_uLong i = 0; i <= nPos; i++ )
+for( sal_uLong i = 0; i <= nIndex; i++ )
 draw( i, aVDev.get() );
 
 if (xOldClip)
@@ -173,7 +173,7 @@ void AnimationRenderer::drawToPos( sal_uLong nPos )
 pRenderContext->SetClipRegion(*xOldClip);
 }
 
-void AnimationRenderer::draw( sal_uLong nPos, VirtualDevice* pVDev )
+void AnimationRenderer::draw( sal_uLong nIndex, VirtualDevice* pVDev )
 {
 VclPtr pRenderContext = mpRenderContext;
 
@@ -198,8 +198,8 @@ void AnimationRenderer::draw( sal_uLong nPos, 
VirtualDevice* pVDev )
 SizeaSizePix;
 SizeaBmpSizePix;
 const sal_uLong nLastPos = mpParent->Count() - 1;
-mnActPos = std::min( nPos, nLastPos );
-const 

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

2021-12-10 Thread Luboš Luňák (via logerrit)
 vcl/inc/salbmp.hxx   |7 +++
 vcl/qa/cppunit/skia/skia.cxx |6 ++
 vcl/source/bitmap/bitmap.cxx |9 -
 3 files changed, 9 insertions(+), 13 deletions(-)

New commits:
commit 5b0e9e8c18205dd9b06cbcec146cefa1acef4f32
Author: Luboš Luňák 
AuthorDate: Thu Dec 9 13:24:44 2021 +0100
Commit: Luboš Luňák 
CommitDate: Fri Dec 10 11:02:32 2021 +0100

return value by simply returning it

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

diff --git a/vcl/inc/salbmp.hxx b/vcl/inc/salbmp.hxx
index 78d553b5194c..f04ea291aa84 100644
--- a/vcl/inc/salbmp.hxx
+++ b/vcl/inc/salbmp.hxx
@@ -97,13 +97,12 @@ public:
 return false;
 }
 
-void GetChecksum(BitmapChecksum& rChecksum) const
+BitmapChecksum GetChecksum() const
 {
 updateChecksum();
 if (!mbChecksumValid)
-rChecksum = 0; // back-compat
-else
-rChecksum = mnChecksum;
+return 0; // back-compat
+return mnChecksum;
 }
 
 void InvalidateChecksum()
diff --git a/vcl/qa/cppunit/skia/skia.cxx b/vcl/qa/cppunit/skia/skia.cxx
index 21e3d0baf696..f2990d3811fc 100644
--- a/vcl/qa/cppunit/skia/skia.cxx
+++ b/vcl/qa/cppunit/skia/skia.cxx
@@ -500,12 +500,10 @@ void SkiaTest::testChecksum()
 // The optimized changing of images to greyscale should change the 
checksum.
 SkiaSalBitmap* skiaBitmap2 = 
dynamic_cast(bitmap.ImplGetSalBitmap().get());
 skiaBitmap2->unittestResetToImage();
-BitmapChecksum checksum6;
-skiaBitmap2->GetChecksum(checksum6);
+BitmapChecksum checksum6 = skiaBitmap2->GetChecksum();
 CPPUNIT_ASSERT_EQUAL(checksum5, checksum6);
 CPPUNIT_ASSERT(skiaBitmap2->ConvertToGreyscale());
-BitmapChecksum checksum7;
-skiaBitmap2->GetChecksum(checksum7);
+BitmapChecksum checksum7 = skiaBitmap2->GetChecksum();
 CPPUNIT_ASSERT(checksum7 != checksum6);
 }
 
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 8d966e2446e0..c755a70ebad1 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -259,9 +259,8 @@ bool Bitmap::operator==( const Bitmap& rBmp ) const
 if (rBmp.mxSalBmp->GetSize() != mxSalBmp->GetSize() ||
 rBmp.mxSalBmp->GetBitCount() != mxSalBmp->GetBitCount())
 return false;
-BitmapChecksum aChecksum1, aChecksum2;
-rBmp.mxSalBmp->GetChecksum(aChecksum1);
-mxSalBmp->GetChecksum(aChecksum2);
+BitmapChecksum aChecksum1 = rBmp.mxSalBmp->GetChecksum();
+BitmapChecksum aChecksum2 = mxSalBmp->GetChecksum();
 // If the bitmaps can't calculate a checksum, best to regard them as 
different.
 if (aChecksum1 == 0 || aChecksum2 == 0)
 return false;
@@ -331,7 +330,7 @@ BitmapChecksum Bitmap::GetChecksum() const
 
 if( mxSalBmp )
 {
-mxSalBmp->GetChecksum(nRet);
+nRet = mxSalBmp->GetChecksum();
 
 if (!nRet)
 {
@@ -344,7 +343,7 @@ BitmapChecksum Bitmap::GetChecksum() const
 {
 Bitmap* pThis = const_cast(this);
 pThis->mxSalBmp = xNewImpBmp;
-mxSalBmp->GetChecksum(nRet);
+nRet = mxSalBmp->GetChecksum();
 }
 }
 }


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

2021-08-25 Thread Chris Sherlock (via logerrit)
 vcl/inc/drawmode.hxx  |2 
 vcl/qa/cppunit/drawmode.cxx   |   32 --
 vcl/qa/cppunit/outdev.cxx |  167 ++
 vcl/source/outdev/bitmap.cxx  |   29 +
 vcl/source/rendercontext/drawmode.cxx |   13 --
 5 files changed, 195 insertions(+), 48 deletions(-)

New commits:
commit 9ea129b49259231565d18f965a57c5fefb4ccc7a
Author: Chris Sherlock 
AuthorDate: Wed Aug 25 22:40:32 2021 +1000
Commit: Tomaž Vajngerl 
CommitDate: Thu Aug 26 02:16:11 2021 +0200

vcl: partial revert of drawmode

Partial revert of commit 0901297902c29c041ae944973b369e8247716893:

vcl: create drawmode functions

The GetBitmap() function will not work, as it doesn't add metafile
actions.

I have added a unit test to prevent this from occuring in future.

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

diff --git a/vcl/inc/drawmode.hxx b/vcl/inc/drawmode.hxx
index 9234b180b4c6..4c1647e0e117 100644
--- a/vcl/inc/drawmode.hxx
+++ b/vcl/inc/drawmode.hxx
@@ -44,8 +44,6 @@ VCL_DLLPUBLIC Color GetTextColor(Color const& rColor, 
DrawModeFlags nDrawMode,
 VCL_DLLPUBLIC vcl::Font GetFont(vcl::Font const& rFont, DrawModeFlags 
nDrawMode,
 StyleSettings const& rStyleSettings);
 
-VCL_DLLPUBLIC Bitmap GetBitmap(Bitmap const& rBitmap, DrawModeFlags nDrawMode);
-
 VCL_DLLPUBLIC BitmapEx GetBitmapEx(BitmapEx const& rBitmapEx, DrawModeFlags 
nDrawMode);
 };
 
diff --git a/vcl/qa/cppunit/drawmode.cxx b/vcl/qa/cppunit/drawmode.cxx
index f3ea1af773f7..a9079af29227 100644
--- a/vcl/qa/cppunit/drawmode.cxx
+++ b/vcl/qa/cppunit/drawmode.cxx
@@ -32,7 +32,6 @@ public:
 void testDrawModeHatchColor();
 void testDrawModeTextColor();
 void testDrawModeFontColor();
-void testDrawModeBitmap();
 void testDrawModeBitmapEx();
 
 CPPUNIT_TEST_SUITE(VclDrawModeTest);
@@ -42,7 +41,6 @@ public:
 CPPUNIT_TEST(testDrawModeHatchColor);
 CPPUNIT_TEST(testDrawModeTextColor);
 CPPUNIT_TEST(testDrawModeFontColor);
-CPPUNIT_TEST(testDrawModeBitmap);
 CPPUNIT_TEST(testDrawModeBitmapEx);
 
 CPPUNIT_TEST_SUITE_END();
@@ -330,36 +328,6 @@ void VclDrawModeTest::testDrawModeFontColor()
 CPPUNIT_ASSERT_EQUAL(COL_RED, aTestFont.GetFillColor());
 }
 
-void VclDrawModeTest::testDrawModeBitmap()
-{
-const StyleSettings aStyleSettings;
-
-Bitmap aBmp(Size(1, 1), vcl::PixelFormat::N24_BPP);
-BitmapWriteAccess aBmpAccess(aBmp);
-aBmpAccess.SetPixel(0, 0, BitmapColor(COL_RED));
-
-{
-Bitmap aResultBitmap(vcl::drawmode::GetBitmap(aBmp, 
DrawModeFlags::GrayBitmap));
-Bitmap::ScopedReadAccess pReadAccess(aResultBitmap);
-
-const BitmapColor& rColor = pReadAccess->GetColor(0, 0);
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0x26), sal_Int32(rColor.GetRed()));
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0x26), sal_Int32(rColor.GetGreen()));
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0x26), sal_Int32(rColor.GetBlue()));
-}
-
-// any other operation other than DrawModeFlags::GrayBitmap is a noop
-{
-Bitmap aResultBitmap(vcl::drawmode::GetBitmap(aBmp, 
DrawModeFlags::NoFill));
-Bitmap::ScopedReadAccess pReadAccess(aResultBitmap);
-
-const BitmapColor& rColor = pReadAccess->GetColor(0, 0);
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0x80), sal_Int32(rColor.GetRed()));
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00), sal_Int32(rColor.GetGreen()));
-CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00), sal_Int32(rColor.GetBlue()));
-}
-}
-
 void VclDrawModeTest::testDrawModeBitmapEx()
 {
 const StyleSettings aStyleSettings;
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index efb4d402cda4..e9d9924a2ab8 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -35,6 +35,12 @@ public:
 void testWindowBackgroundColor();
 void testGetReadableFontColorPrinter();
 void testGetReadableFontColorWindow();
+void testDrawInvertedBitmap();
+void testDrawBlackBitmap();
+void testDrawWhiteBitmap();
+void testDrawBitmap();
+void testDrawScaleBitmap();
+void testDrawScalePartBitmap();
 void testDrawTransformedBitmapEx();
 void testDrawTransformedBitmapExFlip();
 void testRTL();
@@ -45,6 +51,12 @@ public:
 CPPUNIT_TEST(testUseAfterDispose);
 CPPUNIT_TEST(testPrinterBackgroundColor);
 CPPUNIT_TEST(testWindowBackgroundColor);
+CPPUNIT_TEST(testDrawInvertedBitmap);
+CPPUNIT_TEST(testDrawBlackBitmap);
+CPPUNIT_TEST(testDrawWhiteBitmap);
+CPPUNIT_TEST(testDrawBitmap);
+CPPUNIT_TEST(testDrawScaleBitmap);
+CPPUNIT_TEST(testDrawScalePartBitmap);
 CPPUNIT_TEST(testGetReadableFontColorPrinter);
 CPPUNIT_TEST(testGetReadableFontColorWindow);
 CPPUNIT_TEST(testDrawTransformedBitmapEx);
@@ -154,6 +166,161 @@ 

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

2021-03-02 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/pdf/ExternalPDFStreams.hxx   |   12 
 vcl/qa/cppunit/PDFDocumentTest.cxx   |   12 
 vcl/qa/cppunit/data/DocumentWithNull.pdf |binary
 vcl/source/filter/ipdf/pdfdocument.cxx   |   12 +---
 vcl/source/gdi/pdfwriter_impl.cxx|   12 +---
 5 files changed, 38 insertions(+), 10 deletions(-)

New commits:
commit 2c1ed5a5dad827cde032f27a4348e81be15889bc
Author: Tomaž Vajngerl 
AuthorDate: Tue Mar 2 18:57:46 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Wed Mar 3 02:00:16 2021 +0100

tdf#140606 make PDF parsing more lenient and prevent a crash

If the external document can't be opened, it tried to continue
with the export anyway, which eventually lead to a crash. This
is fixed by handling this situation and prevent a crash, however
the part of the document in this case isn't exported.

The document couldn't be opened because of a parsing error - there
was a unexpected null character instead of a whitespace, which
made the parser panic. Fix this by making the parser more lenient
in such a situation when there is an unexpected null and try to
continue parsing.

Bug document seems to be created with a buggy PDF writer, but other
PDF readers don't complain when parsing the document so it looks to
be a valid. qpdf --check doesn't complain either.

Added a test that checks a document with a null parses.

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

diff --git a/vcl/inc/pdf/ExternalPDFStreams.hxx 
b/vcl/inc/pdf/ExternalPDFStreams.hxx
index dc484e1dd15b..7840217630c8 100644
--- a/vcl/inc/pdf/ExternalPDFStreams.hxx
+++ b/vcl/inc/pdf/ExternalPDFStreams.hxx
@@ -34,21 +34,25 @@ struct VCL_DLLPUBLIC ExternalPDFStream
 
 std::map& getCopiedResources() { return 
maCopiedResources; }
 
-filter::PDFDocument& getPDFDocument()
+std::shared_ptr& getPDFDocument()
 {
 if (!mpPDFDocument)
 {
 SvMemoryStream aPDFStream;
 aPDFStream.WriteBytes(maDataContainer.getData(), 
maDataContainer.getSize());
 aPDFStream.Seek(0);
-mpPDFDocument = std::make_shared();
-if (!mpPDFDocument->Read(aPDFStream))
+auto pPDFDocument = std::make_shared();
+if (!pPDFDocument->Read(aPDFStream))
 {
 SAL_WARN("vcl.pdfwriter",
  "PDFWriterImpl::writeReferenceXObject: reading the 
PDF document failed");
 }
+else
+{
+mpPDFDocument = pPDFDocument;
+}
 }
-return *mpPDFDocument;
+return mpPDFDocument;
 }
 };
 
diff --git a/vcl/qa/cppunit/PDFDocumentTest.cxx 
b/vcl/qa/cppunit/PDFDocumentTest.cxx
index 2246f8e38924..35af8e66cd58 100644
--- a/vcl/qa/cppunit/PDFDocumentTest.cxx
+++ b/vcl/qa/cppunit/PDFDocumentTest.cxx
@@ -156,6 +156,18 @@ CPPUNIT_TEST_FIXTURE(PDFDocumentTest, testParseBasicPDF)
 }
 }
 
+CPPUNIT_TEST_FIXTURE(PDFDocumentTest, testParseDocumentWithNullAsWhitespace)
+{
+// tdf#140606
+// Bug document contained a null, which cause the parser to panic,
+// but other PDF readers can handle the file well.
+
+OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"DocumentWithNull.pdf";
+vcl::filter::PDFDocument aDocument;
+SvFileStream aStream(aURL, StreamMode::READ);
+CPPUNIT_ASSERT(aDocument.Read(aStream));
+}
+
 namespace
 {
 vcl::filter::PDFObjectElement*
diff --git a/vcl/qa/cppunit/data/DocumentWithNull.pdf 
b/vcl/qa/cppunit/data/DocumentWithNull.pdf
new file mode 100644
index ..f6d926957366
Binary files /dev/null and b/vcl/qa/cppunit/data/DocumentWithNull.pdf differ
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index acf584949a70..5ebe05e6115a 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1324,12 +1324,18 @@ bool PDFDocument::Tokenize(SvStream& rStream, 
TokenizeMode eMode,
 }
 else
 {
-if (!rtl::isAsciiWhiteSpace(static_cast(ch)))
+auto uChar = static_cast(ch);
+// Be more lenient and allow unexpected null char
+if (!rtl::isAsciiWhiteSpace(uChar) && uChar != 0)
 {
-SAL_WARN("vcl.filter", "PDFDocument::Tokenize: 
unexpected character: "
-   << ch << " at byte position 
" << rStream.Tell());
+SAL_WARN("vcl.filter",
+ "PDFDocument::Tokenize: unexpected character 
with code "
+ << sal_Int32(ch) << " at byte position " 
<< rStream.Tell());
 return 

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

2021-02-17 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/graphic/GraphicFormatDetector.hxx|   13 +
 vcl/qa/cppunit/GraphicFormatDetectorTest.cxx |   32 +--
 vcl/source/filter/GraphicFormatDetector.cxx  |  249 +
 vcl/source/filter/graphicfilter.cxx  |  268 ---
 4 files changed, 278 insertions(+), 284 deletions(-)

New commits:
commit 68db2610c2911d6f7f2c9f2ed85fa359743c6947
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 16 10:35:11 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 18 07:10:08 2021 +0100

vcl: move def. of peekGraphicFormat into GraphicFormatDetector

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

diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx 
b/vcl/inc/graphic/GraphicFormatDetector.hxx
index b38561f790c3..f2f0393caeee 100644
--- a/vcl/inc/graphic/GraphicFormatDetector.hxx
+++ b/vcl/inc/graphic/GraphicFormatDetector.hxx
@@ -23,10 +23,19 @@
 #include 
 #include 
 
-VCL_DLLPUBLIC bool peekGraphicFormat(SvStream& rStream, OUString& 
rFormatExtension, bool bTest);
-
 namespace vcl
 {
+/***
+ * This function is has two modes:
+ * - determine the file format when bTest = false
+ *   returns true, success
+ *   out rFormatExtension - on success: file format string
+ * - verify file format when bTest = true
+ *   returns false, if file type can't be verified
+ *   true, if the format is verified or the format is not known
+ */
+VCL_DLLPUBLIC bool peekGraphicFormat(SvStream& rStream, OUString& 
rFormatExtension, bool bTest);
+
 class VCL_DLLPUBLIC GraphicFormatDetector
 {
 public:
diff --git a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx 
b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
index 1fb2fe0cb4ee..264a0e8cd48d 100644
--- a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
+++ b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
@@ -83,7 +83,7 @@ void GraphicFormatDetectorTest::testDetectMET()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("MET"), rFormatExtension);
 }
 
@@ -98,7 +98,7 @@ void GraphicFormatDetectorTest::testDetectBMP()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("BMP"), rFormatExtension);
 }
 
@@ -113,7 +113,7 @@ void GraphicFormatDetectorTest::testDetectWMF()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("WMF"), rFormatExtension);
 }
 
@@ -128,7 +128,7 @@ void GraphicFormatDetectorTest::testDetectPCX()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("PCX"), rFormatExtension);
 }
 
@@ -143,7 +143,7 @@ void GraphicFormatDetectorTest::testDetectJPG()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("JPG"), rFormatExtension);
 }
 
@@ -158,7 +158,7 @@ void GraphicFormatDetectorTest::testDetectPNG()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("PNG"), rFormatExtension);
 }
 
@@ -173,7 +173,7 @@ void GraphicFormatDetectorTest::testDetectGIF()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("GIF"), rFormatExtension);
 }
 
@@ -188,7 +188,7 @@ void GraphicFormatDetectorTest::testDetectPSD()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(vcl::peekGraphicFormat(aFileStream, rFormatExtension, 
false));
 CPPUNIT_ASSERT_EQUAL(OUString("PSD"), rFormatExtension);
 }
 
@@ 

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

2021-02-17 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/graphic/GraphicFormatDetector.hxx|2 -
 vcl/qa/cppunit/GraphicFormatDetectorTest.cxx |   32 ++--
 vcl/source/filter/graphicfilter.cxx  |   43 ---
 3 files changed, 30 insertions(+), 47 deletions(-)

New commits:
commit c3e3bed2db816bf2c929f9c3bde76b2af57a4d76
Author: Tomaž Vajngerl 
AuthorDate: Tue Feb 16 09:16:55 2021 +0900
Commit: Tomaž Vajngerl 
CommitDate: Thu Feb 18 07:08:06 2021 +0100

vcl: condense the description and rename the peek format function

remove "Imp" from ImpPeekGraphicFormat function name and condense
the description of the function.

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

diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx 
b/vcl/inc/graphic/GraphicFormatDetector.hxx
index e914ee64a3ca..b38561f790c3 100644
--- a/vcl/inc/graphic/GraphicFormatDetector.hxx
+++ b/vcl/inc/graphic/GraphicFormatDetector.hxx
@@ -23,7 +23,7 @@
 #include 
 #include 
 
-VCL_DLLPUBLIC bool ImpPeekGraphicFormat(SvStream& rStream, OUString& 
rFormatExtension, bool bTest);
+VCL_DLLPUBLIC bool peekGraphicFormat(SvStream& rStream, OUString& 
rFormatExtension, bool bTest);
 
 namespace vcl
 {
diff --git a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx 
b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
index f4f4698b28a9..1fb2fe0cb4ee 100644
--- a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
+++ b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
@@ -83,7 +83,7 @@ void GraphicFormatDetectorTest::testDetectMET()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("MET"), rFormatExtension);
 }
 
@@ -98,7 +98,7 @@ void GraphicFormatDetectorTest::testDetectBMP()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("BMP"), rFormatExtension);
 }
 
@@ -113,7 +113,7 @@ void GraphicFormatDetectorTest::testDetectWMF()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("WMF"), rFormatExtension);
 }
 
@@ -128,7 +128,7 @@ void GraphicFormatDetectorTest::testDetectPCX()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("PCX"), rFormatExtension);
 }
 
@@ -143,7 +143,7 @@ void GraphicFormatDetectorTest::testDetectJPG()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("JPG"), rFormatExtension);
 }
 
@@ -158,7 +158,7 @@ void GraphicFormatDetectorTest::testDetectPNG()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("PNG"), rFormatExtension);
 }
 
@@ -173,7 +173,7 @@ void GraphicFormatDetectorTest::testDetectGIF()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("GIF"), rFormatExtension);
 }
 
@@ -188,7 +188,7 @@ void GraphicFormatDetectorTest::testDetectPSD()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension;
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 CPPUNIT_ASSERT_EQUAL(OUString("PSD"), rFormatExtension);
 }
 
@@ -203,7 +203,7 @@ void GraphicFormatDetectorTest::testDetectTGA()
 aFileStream.Seek(aDetector.mnStreamPosition);
 
 OUString rFormatExtension("TGA"); // detection is based on extension only
-CPPUNIT_ASSERT(ImpPeekGraphicFormat(aFileStream, rFormatExtension, false));
+CPPUNIT_ASSERT(peekGraphicFormat(aFileStream, rFormatExtension, false));
 

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

2020-12-15 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/TypeSerializer.hxx|5 
 vcl/inc/impgraph.hxx  |   14 
 vcl/qa/cppunit/GraphicTest.cxx|  630 +++--
 vcl/source/gdi/TypeSerializer.cxx |5 
 vcl/source/gdi/impgraph.cxx   |  714 --
 5 files changed, 918 insertions(+), 450 deletions(-)

New commits:
commit def31e135e5e2c0adb1502cde8bc638588da485d
Author: Tomaž Vajngerl 
AuthorDate: Sun Dec 6 21:14:07 2020 +0900
Commit: Tomaž Vajngerl 
CommitDate: Tue Dec 15 09:03:40 2020 +0100

graphic: Rework swapping algorithm to take GfxLink into account

This reworks the Graphic swap algorithm to not swap to a file when
GfxLink is available and leaves the compressed data in memory.
With such a sheme, at swap-out we just remember the need specific
properties of the Graphic, and delete the graphic content (Bitmap,
Animation, VectorGraphic, Metafile). At swap-in use the GfxLink
data to decompress and recreate the graphic content, then set
the properties back as they were before (if needed).

If a GfxLink is not available it swaps out to a file and back, but
uses a simpler data format that is specific for swapping only. In
the future this case can be removed, when we switch to automatic
creation of GfxLink if that one is not present.

For reworking of swapping it was also necessary to extensively add
and extend the tests that check various swapping scenarios.

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

diff --git a/vcl/inc/TypeSerializer.hxx b/vcl/inc/TypeSerializer.hxx
index 060876593aa5..7be2f54198e7 100644
--- a/vcl/inc/TypeSerializer.hxx
+++ b/vcl/inc/TypeSerializer.hxx
@@ -32,6 +32,11 @@ constexpr sal_uInt32 createMagic(char char1, char char2, 
char char3, char char4)
| (static_cast(char3) << 8) | 
(static_cast(char4) << 0);
 }
 
+constexpr sal_uInt32 constSvgMagic = createMagic('s', 'v', 'g', '0');
+constexpr sal_uInt32 constWmfMagic = createMagic('w', 'm', 'f', '0');
+constexpr sal_uInt32 constEmfMagic = createMagic('e', 'm', 'f', '0');
+constexpr sal_uInt32 constPdfMagic = createMagic('p', 'd', 'f', '0');
+
 class VCL_DLLPUBLIC TypeSerializer : public tools::GenericTypeSerializer
 {
 public:
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index de5df4a1ac57..6a312a76d58e 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -47,6 +47,13 @@ class ImpSwapFile;
 class GraphicConversionParameters;
 class ImpGraphic;
 
+enum class GraphicContentType : sal_Int32
+{
+Bitmap,
+Animation,
+Vector
+};
+
 class VCL_DLLPUBLIC ImpGraphic final
 {
 friend class Graphic;
@@ -115,7 +122,9 @@ private:
 return mpGraphicID->getIDString();
 }
 
-voidcreateSwapInfo();
+void createSwapInfo();
+void restoreFromSwapInfo();
+
 voidImplClearGraphics();
 voidImplClear();
 
@@ -170,7 +179,7 @@ private:
 private:
 // swapping methods
 bool swapInFromStream(SvStream& rStream);
-void swapInGraphic(SvStream& rStream);
+bool swapInGraphic(SvStream& rStream);
 
 bool swapInContent(SvStream& rStream);
 bool swapOutContent(SvStream& rStream);
@@ -205,6 +214,7 @@ private:
 sal_Int32 getPageNumber() const;
 
 public:
+void resetChecksum() { mnChecksum = 0; }
 bool swapIn();
 bool swapOut();
 bool isSwappedOut() const { return mbSwapOut; }
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index d3671fe3c881..c58ca7d650b4 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -50,23 +50,50 @@ private:
 void testUnloadedGraphicWmf();
 void testUnloadedGraphicAlpha();
 void testUnloadedGraphicSizeUnit();
-void testSwapping();
-void testSwappingVectorGraphic();
-void testSwappingPageNumber();
+
 void testWMFRoundtrip();
 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();
+
 CPPUNIT_TEST_SUITE(GraphicTest);
 CPPUNIT_TEST(testUnloadedGraphic);
 CPPUNIT_TEST(testUnloadedGraphicLoading);
 CPPUNIT_TEST(testUnloadedGraphicWmf);
 

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

2020-05-03 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/graphic/DetectorTools.hxx|   63 
 vcl/qa/cppunit/GraphicFormatDetectorTest.cxx |  106 +++
 vcl/source/filter/GraphicFormatDetector.cxx  |   53 -
 3 files changed, 188 insertions(+), 34 deletions(-)

New commits:
commit bb459008de9d410e6e7ea982ce30aa22f70ae849
Author: Tomaž Vajngerl 
AuthorDate: Sat May 2 14:35:23 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun May 3 19:37:13 2020 +0200

vcl: add DetectorTools + tests, refactor array string matching

Add DetectorTools with byte array searching and matching to a
input string (or another byte array). This refactors the existing
function in GraphicFormatDetector. It needs to go into its own
header so that the function(s) can be tested easily. Replace
the previous searchEntry implementation with refactored one in
the source code.

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

diff --git a/vcl/inc/graphic/DetectorTools.hxx 
b/vcl/inc/graphic/DetectorTools.hxx
new file mode 100644
index ..b9163de135d9
--- /dev/null
+++ b/vcl/inc/graphic/DetectorTools.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+namespace vcl
+{
+const char* matchArray(const char* pSource, sal_Int32 nSourceSize, const char* 
pSearch,
+   sal_Int32 nSearchSize)
+{
+for (sal_Int32 increment = 0; increment <= (nSourceSize - nSearchSize); 
++increment)
+{
+bool bMatch = true;
+// search both arrays if they match
+for (sal_Int32 index = 0; index < nSearchSize && bMatch; ++index)
+{
+if (pSource[index] != pSearch[index])
+bMatch = false;
+}
+// match has been found
+if (bMatch)
+return pSource;
+pSource++;
+}
+return nullptr;
+}
+
+const char* matchArrayWithString(const char* pSource, sal_Int32 nSourceSize, 
OString const& rString)
+{
+return matchArray(pSource, nSourceSize, rString.getStr(), 
rString.getLength());
+}
+
+bool checkArrayForMatchingStrings(const char* pSource, sal_Int32 nSourceSize,
+  std::vector const& rStrings)
+{
+if (rStrings.empty())
+return false;
+if (rStrings.size() < 2)
+return matchArrayWithString(pSource, nSourceSize, rStrings[0]) != 
nullptr;
+
+const char* pBegin = pSource;
+const char* pCurrent = pSource;
+for (OString const& rString : rStrings)
+{
+sal_Int32 nCurrentSize = nSourceSize - sal_Int32(pCurrent - pBegin);
+printf("Current size %d -> %d\n", nCurrentSize, nSourceSize);
+pCurrent = matchArray(pCurrent, nCurrentSize, rString.getStr(), 
rString.getLength());
+if (pCurrent == nullptr)
+return false;
+printf("%s\n", pCurrent);
+}
+return true;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx 
b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
index 90183279dbc9..155ff089811b 100644
--- a/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
+++ b/vcl/qa/cppunit/GraphicFormatDetectorTest.cxx
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -41,6 +42,8 @@ class GraphicFormatDetectorTest : public 
test::BootstrapFixtureBase
 void testDetectSVG();
 void testDetectSVGZ();
 void testDetectPDF();
+void testMatchArray();
+void testCheckArrayForMatchingStrings();
 
 CPPUNIT_TEST_SUITE(GraphicFormatDetectorTest);
 CPPUNIT_TEST(testDetectMET);
@@ -58,6 +61,8 @@ class GraphicFormatDetectorTest : public 
test::BootstrapFixtureBase
 CPPUNIT_TEST(testDetectSVG);
 CPPUNIT_TEST(testDetectSVGZ);
 CPPUNIT_TEST(testDetectPDF);
+CPPUNIT_TEST(testMatchArray);
+CPPUNIT_TEST(testCheckArrayForMatchingStrings);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -286,6 +291,107 @@ void GraphicFormatDetectorTest::testDetectPDF()
 CPPUNIT_ASSERT_EQUAL(OUString("PDF"), rFormatExtension);
 }
 
+void GraphicFormatDetectorTest::testMatchArray()
+{
+std::string aString("\n"
+"http://www.w3.org/2000/svg\;>\n"
+"");
+
+const char* pCompleteStringPointer = aString.c_str();
+const char* pMatchPointer;
+int nCheckSize = aString.size();
+
+// Check beginning of the input string
+pMatchPointer = vcl::matchArrayWithString(pCompleteStringPointer, 
nCheckSize, "");
+CPPUNIT_ASSERT(pMatchPointer != nullptr);
+CPPUNIT_ASSERT_EQUAL(119, 

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

2020-05-03 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/TypeSerializer.hxx|8 +
 vcl/qa/cppunit/TypeSerializerTest.cxx |   68 -
 vcl/source/gdi/TypeSerializer.cxx |  172 --
 3 files changed, 234 insertions(+), 14 deletions(-)

New commits:
commit 1114ebb37487bd0f7ad0e327fa571a5c925b237c
Author: Tomaž Vajngerl 
AuthorDate: Fri May 1 19:24:01 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun May 3 13:04:51 2020 +0200

vcl: add Graphic reading to TypeSerializer + tests

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

diff --git a/vcl/inc/TypeSerializer.hxx b/vcl/inc/TypeSerializer.hxx
index 4ac7e06471ea..060876593aa5 100644
--- a/vcl/inc/TypeSerializer.hxx
+++ b/vcl/inc/TypeSerializer.hxx
@@ -26,6 +26,12 @@
 #include 
 #include 
 
+constexpr sal_uInt32 createMagic(char char1, char char2, char char3, char 
char4)
+{
+return (static_cast(char1) << 24) | 
(static_cast(char2) << 16)
+   | (static_cast(char3) << 8) | 
(static_cast(char4) << 0);
+}
+
 class VCL_DLLPUBLIC TypeSerializer : public tools::GenericTypeSerializer
 {
 public:
@@ -37,7 +43,7 @@ public:
 void readGfxLink(GfxLink& rGfxLink);
 void writeGfxLink(const GfxLink& rGfxLink);
 
-static void readGraphic(Graphic& rGraphic);
+void readGraphic(Graphic& rGraphic);
 void writeGraphic(const Graphic& rGraphic);
 };
 
diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx 
b/vcl/qa/cppunit/TypeSerializerTest.cxx
index 0c737a4c4f03..c7ad8827a28d 100644
--- a/vcl/qa/cppunit/TypeSerializerTest.cxx
+++ b/vcl/qa/cppunit/TypeSerializerTest.cxx
@@ -51,12 +51,12 @@ std::string toHexString(const std::vector& a)
 class TypeSerializerTest : public CppUnit::TestFixture
 {
 void testGradient();
-void testGraphic();
+void testGraphic_Vector();
 void testGraphic_Bitmap_NoGfxLink();
 
 CPPUNIT_TEST_SUITE(TypeSerializerTest);
 CPPUNIT_TEST(testGradient);
-CPPUNIT_TEST(testGraphic);
+CPPUNIT_TEST(testGraphic_Vector);
 CPPUNIT_TEST(testGraphic_Bitmap_NoGfxLink);
 CPPUNIT_TEST_SUITE_END();
 };
@@ -91,7 +91,7 @@ void TypeSerializerTest::testGradient()
 CPPUNIT_ASSERT_EQUAL(sal_uInt16(30), aReadGradient.GetSteps());
 }
 
-void TypeSerializerTest::testGraphic()
+void TypeSerializerTest::testGraphic_Vector()
 {
 test::Directories aDirectories;
 OUString aURL = aDirectories.getURLFromSrc(DATA_DIRECTORY) + 
"SimpleExample.svg";
@@ -99,6 +99,7 @@ void TypeSerializerTest::testGraphic()
 GraphicFilter& rGraphicFilter = GraphicFilter::GetGraphicFilter();
 Graphic aGraphic = rGraphicFilter.ImportUnloadedGraphic(aStream);
 aGraphic.makeAvailable();
+BitmapChecksum aChecksum = aGraphic.getVectorGraphicData()->GetChecksum();
 
 // Test WriteGraphic - Native Format 5
 {
@@ -117,6 +118,13 @@ void TypeSerializerTest::testGraphic()
 sal_uInt32 nType;
 aMemoryStream.ReadUInt32(nType);
 CPPUNIT_ASSERT_EQUAL(COMPAT_FORMAT('N', 'A', 'T', '5'), nType);
+
+// Read it back
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+Graphic aNewGraphic;
+ReadGraphic(aMemoryStream, aNewGraphic);
+CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
+CPPUNIT_ASSERT_EQUAL(aChecksum, 
aNewGraphic.getVectorGraphicData()->GetChecksum());
 }
 
 // Test WriteGraphic - Normal
@@ -129,6 +137,18 @@ void TypeSerializerTest::testGraphic()
 std::vector aHash = calculateHash(aMemoryStream);
 
CPPUNIT_ASSERT_EQUAL(std::string("c2bed2099ce617f1cc035701de5186f0d43e3064"),
  toHexString(aHash));
+
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+sal_uInt32 nType;
+aMemoryStream.ReadUInt32(nType);
+CPPUNIT_ASSERT_EQUAL(createMagic('s', 'v', 'g', '0'), nType);
+
+// Read it back
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+Graphic aNewGraphic;
+ReadGraphic(aMemoryStream, aNewGraphic);
+CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
+CPPUNIT_ASSERT_EQUAL(aChecksum, 
aNewGraphic.getVectorGraphicData()->GetChecksum());
 }
 
 // Test TypeSerializer - Native Format 5
@@ -151,6 +171,16 @@ void TypeSerializerTest::testGraphic()
 sal_uInt32 nType;
 aMemoryStream.ReadUInt32(nType);
 CPPUNIT_ASSERT_EQUAL(COMPAT_FORMAT('N', 'A', 'T', '5'), nType);
+
+// Read it back
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+Graphic aNewGraphic;
+{
+TypeSerializer aSerializer(aMemoryStream);
+aSerializer.readGraphic(aNewGraphic);
+}
+CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aNewGraphic.GetType());
+CPPUNIT_ASSERT_EQUAL(aChecksum, 
aNewGraphic.getVectorGraphicData()->GetChecksum());
 }
 
 // Test TypeSerializer - Normal
@@ -166,6 +196,21 @@ void 

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

2020-05-03 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/TypeSerializer.hxx|4 +
 vcl/qa/cppunit/TypeSerializerTest.cxx |   57 
 vcl/source/gdi/TypeSerializer.cxx |  117 ++
 3 files changed, 178 insertions(+)

New commits:
commit c79dd92480cbc409a7061da7f3dd3abaaf9a4883
Author: Tomaž Vajngerl 
AuthorDate: Thu Apr 30 10:48:44 2020 +0200
Commit: Tomaž Vajngerl 
CommitDate: Sun May 3 08:22:45 2020 +0200

vcl: add Graphic serialization (writing) to TypeSerializer + tests

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

diff --git a/vcl/inc/TypeSerializer.hxx b/vcl/inc/TypeSerializer.hxx
index befd4edd7660..4ac7e06471ea 100644
--- a/vcl/inc/TypeSerializer.hxx
+++ b/vcl/inc/TypeSerializer.hxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 class VCL_DLLPUBLIC TypeSerializer : public tools::GenericTypeSerializer
 {
@@ -35,6 +36,9 @@ public:
 
 void readGfxLink(GfxLink& rGfxLink);
 void writeGfxLink(const GfxLink& rGfxLink);
+
+static void readGraphic(Graphic& rGraphic);
+void writeGraphic(const Graphic& rGraphic);
 };
 
 #endif
diff --git a/vcl/qa/cppunit/TypeSerializerTest.cxx 
b/vcl/qa/cppunit/TypeSerializerTest.cxx
index e5d3a259f803..0c737a4c4f03 100644
--- a/vcl/qa/cppunit/TypeSerializerTest.cxx
+++ b/vcl/qa/cppunit/TypeSerializerTest.cxx
@@ -130,6 +130,43 @@ void TypeSerializerTest::testGraphic()
 
CPPUNIT_ASSERT_EQUAL(std::string("c2bed2099ce617f1cc035701de5186f0d43e3064"),
  toHexString(aHash));
 }
+
+// Test TypeSerializer - Native Format 5
+{
+SvMemoryStream aMemoryStream;
+aMemoryStream.SetVersion(SOFFICE_FILEFORMAT_50);
+aMemoryStream.SetCompressMode(SvStreamCompressFlags::NATIVE);
+{
+TypeSerializer aSerializer(aMemoryStream);
+aSerializer.writeGraphic(aGraphic);
+}
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(290), aMemoryStream.remainingSize());
+std::vector aHash = calculateHash(aMemoryStream);
+
CPPUNIT_ASSERT_EQUAL(std::string("ee55ab6faa73b61b68bc3d5628d95f0d3c528e2a"),
+ toHexString(aHash));
+
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+sal_uInt32 nType;
+aMemoryStream.ReadUInt32(nType);
+CPPUNIT_ASSERT_EQUAL(COMPAT_FORMAT('N', 'A', 'T', '5'), nType);
+}
+
+// Test TypeSerializer - Normal
+{
+SvMemoryStream aMemoryStream;
+{
+TypeSerializer aSerializer(aMemoryStream);
+aSerializer.writeGraphic(aGraphic);
+}
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(233), aMemoryStream.remainingSize());
+std::vector aHash = calculateHash(aMemoryStream);
+
CPPUNIT_ASSERT_EQUAL(std::string("c2bed2099ce617f1cc035701de5186f0d43e3064"),
+ toHexString(aHash));
+}
 }
 
 void TypeSerializerTest::testGraphic_Bitmap_NoGfxLink()
@@ -155,6 +192,26 @@ void TypeSerializerTest::testGraphic_Bitmap_NoGfxLink()
 aMemoryStream.ReadUInt16(nType);
 CPPUNIT_ASSERT_EQUAL(sal_uInt16(0x4D42), nType); // Magic written with 
WriteDIBBitmapEx
 }
+
+// Test TypeSerializer
+{
+SvMemoryStream aMemoryStream;
+{
+TypeSerializer aSerializer(aMemoryStream);
+aSerializer.writeGraphic(aGraphic);
+}
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+
+CPPUNIT_ASSERT_EQUAL(sal_uInt64(383), aMemoryStream.remainingSize());
+std::vector aHash = calculateHash(aMemoryStream);
+
CPPUNIT_ASSERT_EQUAL(std::string("da831418499146d51bf245fadf60b9111faa76c2"),
+ toHexString(aHash));
+
+aMemoryStream.Seek(STREAM_SEEK_TO_BEGIN);
+sal_uInt16 nType;
+aMemoryStream.ReadUInt16(nType);
+CPPUNIT_ASSERT_EQUAL(sal_uInt16(0x4D42), nType); // Magic written with 
WriteDIBBitmapEx
+}
 }
 
 } // namespace
diff --git a/vcl/source/gdi/TypeSerializer.cxx 
b/vcl/source/gdi/TypeSerializer.cxx
index ad2f1400da85..8266c6ac9813 100644
--- a/vcl/source/gdi/TypeSerializer.cxx
+++ b/vcl/source/gdi/TypeSerializer.cxx
@@ -20,6 +20,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 TypeSerializer::TypeSerializer(SvStream& rStream)
 : GenericTypeSerializer(rStream)
@@ -148,4 +150,119 @@ void TypeSerializer::writeGfxLink(const GfxLink& rGfxLink)
 }
 }
 
+namespace
+{
+constexpr sal_uInt32 constSvgMagic((sal_uInt32('s') << 24) | (sal_uInt32('v') 
<< 16)
+   | (sal_uInt32('g') << 8) | sal_uInt32('0'));
+constexpr sal_uInt32 constWmfMagic((sal_uInt32('w') << 24) | (sal_uInt32('m') 
<< 16)
+   | (sal_uInt32('f') << 8) | sal_uInt32('0'));
+constexpr sal_uInt32 

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

2020-01-02 Thread Miklos Vajna (via logerrit)
 vcl/inc/window.h |5 -
 vcl/qa/cppunit/outdev.cxx|   15 +++
 vcl/source/control/edit.cxx  |2 +-
 vcl/source/gdi/impanmvw.cxx  |8 
 vcl/source/window/cursor.cxx |4 ++--
 vcl/source/window/paint.cxx  |8 ++--
 6 files changed, 32 insertions(+), 10 deletions(-)

New commits:
commit b0fa356eed82a0452e6bcb915f179f5e2d02943a
Author: Miklos Vajna 
AuthorDate: Thu Jan 2 18:02:41 2020 +0100
Commit: Miklos Vajna 
CommitDate: Thu Jan 2 18:48:13 2020 +0100

tdf#129662 vcl: rtl: fix scrollbar in dropdowns

Regression from commit d4714b0fdb81e6e561ae526cc517ecc9a40a603e
(tdf#101978 vcl combobox/listbox floating window: avoid flicker,
2019-06-17).

High-level vcl double-buffering never set up RTL status of the virtual
device correctly, but now that double-buffering is used at more places,
this got noticed.

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

diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 970e7c58b0c3..4da4a3adc5d2 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -396,8 +396,10 @@ public:
 bool mbLOKParentNotifier;
 };
 
+namespace vcl
+{
 /// Sets up the buffer to have settings matching the window, and restores the 
original state in the dtor.
-class PaintBufferGuard
+class VCL_DLLPUBLIC PaintBufferGuard
 {
 ImplFrameData* mpFrameData;
 VclPtr m_pWindow;
@@ -415,6 +417,7 @@ public:
 /// Returns either the frame's buffer or the window, in case of no 
buffering.
 vcl::RenderContext* GetRenderContext();
 };
+}
 
 // helper methods
 
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 2f42412e75aa..e99a35f67adf 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -34,6 +35,7 @@ public:
 void testDrawTransformedBitmapEx();
 void testDrawTransformedBitmapExFlip();
 void testRTL();
+void testRTLGuard();
 
 CPPUNIT_TEST_SUITE(VclOutdevTest);
 CPPUNIT_TEST(testVirtualDevice);
@@ -45,6 +47,7 @@ public:
 CPPUNIT_TEST(testDrawTransformedBitmapEx);
 CPPUNIT_TEST(testDrawTransformedBitmapExFlip);
 CPPUNIT_TEST(testRTL);
+CPPUNIT_TEST(testRTLGuard);
 CPPUNIT_TEST_SUITE_END();
 };
 
@@ -269,6 +272,18 @@ void VclOutdevTest::testRTL()
 CPPUNIT_ASSERT(pBuffer->IsRTLEnabled());
 }
 
+void VclOutdevTest::testRTLGuard()
+{
+ScopedVclPtrInstance pWindow(nullptr, WB_APP | WB_STDWORK);
+pWindow->EnableRTL();
+pWindow->RequestDoubleBuffering(true);
+ImplFrameData* pFrameData = pWindow->ImplGetWindowImpl()->mpFrameData;
+vcl::PaintBufferGuard aGuard(pFrameData, pWindow);
+// Without the accompanying fix in place, this test would have failed, 
because the RTL status
+// from pWindow was not propagated to aGuard.
+CPPUNIT_ASSERT(aGuard.GetRenderContext()->IsRTLEnabled());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index ddf942f76c15..4525eb630613 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -977,7 +977,7 @@ void Edit::ImplClearBackground(vcl::RenderContext& 
rRenderContext, const tools::
 {
 // ImplPaintBorder() is a NOP, we have a native border, and this is a 
sub-edit of a control.
 // That means we have to draw the parent native widget to paint the 
edit area to clear our background.
-PaintBufferGuard g(ImplGetWindowImpl()->mpFrameData, GetParent());
+vcl::PaintBufferGuard g(ImplGetWindowImpl()->mpFrameData, GetParent());
 GetParent()->Paint(rRenderContext, rRectangle);
 }
 }
diff --git a/vcl/source/gdi/impanmvw.cxx b/vcl/source/gdi/impanmvw.cxx
index 0537c349e0f3..7818a3dcc0ed 100644
--- a/vcl/source/gdi/impanmvw.cxx
+++ b/vcl/source/gdi/impanmvw.cxx
@@ -152,11 +152,11 @@ void ImplAnimView::drawToPos( sal_uLong nPos )
 {
 VclPtr pRenderContext = mpRenderContext;
 
-std::unique_ptr pGuard;
+std::unique_ptr pGuard;
 if (mpRenderContext->GetOutDevType() == OUTDEV_WINDOW)
 {
 vcl::Window* pWindow = 
static_cast(mpRenderContext.get());
-pGuard.reset(new 
PaintBufferGuard(pWindow->ImplGetWindowImpl()->mpFrameData, pWindow));
+pGuard.reset(new 
vcl::PaintBufferGuard(pWindow->ImplGetWindowImpl()->mpFrameData, pWindow));
 pRenderContext = pGuard->GetRenderContext();
 }
 
@@ -184,11 +184,11 @@ void ImplAnimView::draw( sal_uLong nPos, VirtualDevice* 
pVDev )
 {
 VclPtr pRenderContext = mpRenderContext;
 
-std::unique_ptr pGuard;
+std::unique_ptr pGuard;
 if (!pVDev && mpRenderContext->GetOutDevType() == OUTDEV_WINDOW)
 {
 vcl::Window* pWindow = 
static_cast(mpRenderContext.get());
-pGuard.reset(new 

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

2019-11-18 Thread Tomaž Vajngerl (via logerrit)
 vcl/inc/widgetdraw/WidgetDefinition.hxx  |7 +++
 vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx |   28 +-
 vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml   |5 ++
 vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml   |6 +++
 vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml   |6 +++
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx  |   12 +-
 vcl/source/gdi/WidgetDefinition.cxx  |2 -
 vcl/source/gdi/WidgetDefinitionReader.cxx|   30 +++
 8 files changed, 93 insertions(+), 3 deletions(-)

New commits:
commit b234743dd26e0be4be272d2d2c82f90c67e192b7
Author: Tomaž Vajngerl 
AuthorDate: Mon Nov 18 22:50:46 2019 +0100
Commit: Tomaž Vajngerl 
CommitDate: Tue Nov 19 08:17:29 2019 +0100

widget theme: add centeredTabs setting to theme definition file

Change-Id: I714a44d40a99e0bb5ff48e3d36ded73db60af5a0
Reviewed-on: https://gerrit.libreoffice.org/83133
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx 
b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index 7c0259468328..50a853a6c1a6 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -201,6 +201,12 @@ public:
 std::vector> maStates;
 };
 
+class VCL_DLLPUBLIC WidgetDefinitionSettings
+{
+public:
+OString msCenteredTabs;
+};
+
 class VCL_DLLPUBLIC WidgetDefinitionStyle
 {
 public:
@@ -263,6 +269,7 @@ class VCL_DLLPUBLIC WidgetDefinition
 {
 public:
 std::shared_ptr mpStyle;
+std::shared_ptr mpSettings;
 std::unordered_map> maDefinitions;
 std::shared_ptr getDefinition(ControlType eType, 
ControlPart ePart);
 };
diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx 
b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
index 9cf818932c38..cd7945fba82c 100644
--- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
+++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
@@ -28,18 +28,44 @@ private:
 
 public:
 void testRead();
+void testReadSettings();
 
 CPPUNIT_TEST_SUITE(WidgetDefinitionReaderTest);
 CPPUNIT_TEST(testRead);
+CPPUNIT_TEST(testReadSettings);
 CPPUNIT_TEST_SUITE_END();
 };
 
+void WidgetDefinitionReaderTest::testReadSettings()
+{
+{
+vcl::WidgetDefinition aDefinition;
+vcl::WidgetDefinitionReader 
aReader(getFullUrl("definitionSettings1.xml"), getFullUrl(""));
+CPPUNIT_ASSERT(aReader.read(aDefinition));
+CPPUNIT_ASSERT_EQUAL(OString(""), 
aDefinition.mpSettings->msCenteredTabs);
+}
+
+{
+vcl::WidgetDefinition aDefinition;
+vcl::WidgetDefinitionReader 
aReader(getFullUrl("definitionSettings2.xml"), getFullUrl(""));
+CPPUNIT_ASSERT(aReader.read(aDefinition));
+CPPUNIT_ASSERT_EQUAL(OString("true"), 
aDefinition.mpSettings->msCenteredTabs);
+}
+
+{
+vcl::WidgetDefinition aDefinition;
+vcl::WidgetDefinitionReader 
aReader(getFullUrl("definitionSettings3.xml"), getFullUrl(""));
+CPPUNIT_ASSERT(aReader.read(aDefinition));
+CPPUNIT_ASSERT_EQUAL(OString("false"), 
aDefinition.mpSettings->msCenteredTabs);
+}
+}
+
 void WidgetDefinitionReaderTest::testRead()
 {
 vcl::WidgetDefinition aDefinition;
 
 vcl::WidgetDefinitionReader aReader(getFullUrl("definition1.xml"), 
getFullUrl(""));
-aReader.read(aDefinition);
+CPPUNIT_ASSERT(aReader.read(aDefinition));
 
 CPPUNIT_ASSERT_EQUAL(OUString("123456"), 
aDefinition.mpStyle->maFaceColor.AsRGBHexString());
 CPPUNIT_ASSERT_EQUAL(OUString("234567"), 
aDefinition.mpStyle->maCheckedColor.AsRGBHexString());
diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml 
b/vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml
new file mode 100644
index ..9ca7f894f29d
--- /dev/null
+++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings1.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml 
b/vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml
new file mode 100644
index ..0d6d6e11151a
--- /dev/null
+++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings2.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml 
b/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml
new file mode 100644
index ..20541b2a219e
--- /dev/null
+++ b/vcl/qa/cppunit/widgetdraw/data/definitionSettings3.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx 
b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index d6f827de3938..580f3783143b 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -85,6 +85,15 @@ std::shared_ptr const& 
getWidgetDefinitionForTheme(OUString co
 return spDefinition;
 }
 
+bool 

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

2019-03-09 Thread Libreoffice Gerrit user
 vcl/inc/widgetdraw/WidgetDefinition.hxx  |7 -
 vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx |   17 +-
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx  |  102 +++---
 vcl/source/gdi/WidgetDefinitionReader.cxx|  105 +++
 4 files changed, 119 insertions(+), 112 deletions(-)

New commits:
commit 4e25914b165d7ed64b3026af758fb857676aacd5
Author: Tomaž Vajngerl 
AuthorDate: Sat Mar 9 13:49:40 2019 +0100
Commit: Tomaž Vajngerl 
CommitDate: Sat Mar 9 18:29:22 2019 +0100

Separate style colors from WidgetDefinition into its own class

Change-Id: I11cd695da81bae7b49b2319b89e5c560ba64f04e
Reviewed-on: https://gerrit.libreoffice.org/68975
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx 
b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index c183edd9e315..7e1505c8daae 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -208,7 +208,7 @@ public:
 std::vector> maStates;
 };
 
-class VCL_DLLPUBLIC WidgetDefinition
+class VCL_DLLPUBLIC WidgetDefinitionStyle
 {
 public:
 Color maFaceColor;
@@ -261,7 +261,12 @@ public:
 Color maVisitedLinkColor;
 Color maToolTextColor;
 Color maFontColor;
+};
 
+class VCL_DLLPUBLIC WidgetDefinition
+{
+public:
+std::shared_ptr mpStyle;
 std::unordered_map> maDefinitions;
 std::shared_ptr getDefinition(ControlType eType, 
ControlPart ePart);
 };
diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx 
b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
index 20b3270267dd..c56379cc70c7 100644
--- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
+++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
@@ -39,20 +39,17 @@ void WidgetDefinitionReaderTest::testRead()
 {
 vcl::WidgetDefinition aDefinition;
 
-CPPUNIT_ASSERT_EQUAL(OUString("00"), 
aDefinition.maFaceColor.AsRGBHexString());
-CPPUNIT_ASSERT_EQUAL(OUString("00"), 
aDefinition.maCheckedColor.AsRGBHexString());
-CPPUNIT_ASSERT_EQUAL(OUString("00"), 
aDefinition.maLightColor.AsRGBHexString());
-
 vcl::WidgetDefinitionReader aReader(getFullUrl("definition1.xml"), 
getFullUrl(""));
 aReader.read(aDefinition);
 
-CPPUNIT_ASSERT_EQUAL(OUString("123456"), 
aDefinition.maFaceColor.AsRGBHexString());
-CPPUNIT_ASSERT_EQUAL(OUString("234567"), 
aDefinition.maCheckedColor.AsRGBHexString());
-CPPUNIT_ASSERT_EQUAL(OUString("345678"), 
aDefinition.maLightColor.AsRGBHexString());
+CPPUNIT_ASSERT_EQUAL(OUString("123456"), 
aDefinition.mpStyle->maFaceColor.AsRGBHexString());
+CPPUNIT_ASSERT_EQUAL(OUString("234567"), 
aDefinition.mpStyle->maCheckedColor.AsRGBHexString());
+CPPUNIT_ASSERT_EQUAL(OUString("345678"), 
aDefinition.mpStyle->maLightColor.AsRGBHexString());
 
-CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.maVisitedLinkColor.AsRGBHexString());
-CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.maToolTextColor.AsRGBHexString());
-CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.maFontColor.AsRGBHexString());
+CPPUNIT_ASSERT_EQUAL(OUString("ff"),
+ 
aDefinition.mpStyle->maVisitedLinkColor.AsRGBHexString());
+CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.mpStyle->maToolTextColor.AsRGBHexString());
+CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.mpStyle->maFontColor.AsRGBHexString());
 
 // Pushbutton
 {
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx 
b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index abd55fb0bca0..bc2636491829 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -786,56 +786,58 @@ bool 
FileDefinitionWidgetDraw::updateSettings(AllSettings& rSettings)
 {
 StyleSettings aStyleSet = rSettings.GetStyleSettings();
 
-aStyleSet.SetFaceColor(m_aWidgetDefinition.maFaceColor);
-aStyleSet.SetCheckedColor(m_aWidgetDefinition.maCheckedColor);
-aStyleSet.SetLightColor(m_aWidgetDefinition.maLightColor);
-aStyleSet.SetLightBorderColor(m_aWidgetDefinition.maLightBorderColor);
-aStyleSet.SetShadowColor(m_aWidgetDefinition.maShadowColor);
-aStyleSet.SetDarkShadowColor(m_aWidgetDefinition.maDarkShadowColor);
-aStyleSet.SetButtonTextColor(m_aWidgetDefinition.maButtonTextColor);
-
aStyleSet.SetButtonRolloverTextColor(m_aWidgetDefinition.maButtonRolloverTextColor);
-
aStyleSet.SetRadioCheckTextColor(m_aWidgetDefinition.maRadioCheckTextColor);
-aStyleSet.SetGroupTextColor(m_aWidgetDefinition.maGroupTextColor);
-aStyleSet.SetLabelTextColor(m_aWidgetDefinition.maLabelTextColor);
-aStyleSet.SetWindowColor(m_aWidgetDefinition.maWindowColor);
-aStyleSet.SetWindowTextColor(m_aWidgetDefinition.maWindowTextColor);
-aStyleSet.SetDialogColor(m_aWidgetDefinition.maDialogColor);
-

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

2019-03-04 Thread Libreoffice Gerrit user
 vcl/inc/widgetdraw/WidgetDefinition.hxx  |   48 +-
 vcl/inc/widgetdraw/WidgetDefinitionReader.hxx|5 
 vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx |8 -
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx  |6 
 vcl/source/gdi/WidgetDefinition.cxx  |  110 --
 vcl/source/gdi/WidgetDefinitionReader.cxx|  117 +--
 6 files changed, 158 insertions(+), 136 deletions(-)

New commits:
commit 9671ac2dac00c21ae840cb29c2671b22ab95a7b2
Author: Tomaž Vajngerl 
AuthorDate: Fri Jan 25 23:10:57 2019 +0100
Commit: Tomaž Vajngerl 
CommitDate: Mon Mar 4 21:20:24 2019 +0100

Refactor so we have only one definition map and ControlTypeAndPart

Until now we had multiple maps, each for a specific ControlType
(maPushButtonDefinitions for example) which had multiple parts
identified by the string.
To simplify matters, this changes that we have just one map for
a specific ControlType and ControlPart which are identified by
ControlTypeAndPart structure.

Change-Id: I90a2e5c8f83d697d26049054eacab250e2768c03
Reviewed-on: https://gerrit.libreoffice.org/68690
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx 
b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index 423ab1d970c3..486d61802654 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -17,6 +17,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 namespace vcl
@@ -83,6 +86,42 @@ public:
 }
 };
 
+struct VCL_DLLPUBLIC ControlTypeAndPart
+{
+ControlType const meType;
+ControlPart const mePart;
+
+ControlTypeAndPart(ControlType eType, ControlPart ePart)
+: meType(eType)
+, mePart(ePart)
+{
+}
+
+bool operator==(ControlTypeAndPart const& aOther) const
+{
+return meType == aOther.meType && mePart == aOther.mePart;
+}
+};
+
+} // end vcl namespace
+
+namespace std
+{
+template <> struct VCL_DLLPUBLIC hash
+{
+std::size_t operator()(vcl::ControlTypeAndPart const& rControlTypeAndPart) 
const noexcept
+{
+std::size_t seed = 0;
+boost::hash_combine(seed, rControlTypeAndPart.meType);
+boost::hash_combine(seed, rControlTypeAndPart.mePart);
+return seed;
+}
+};
+
+} // end std namespace
+
+namespace vcl
+{
 class VCL_DLLPUBLIC WidgetDefinitionState
 {
 public:
@@ -171,13 +210,8 @@ public:
 Color maToolTextColor;
 Color maFontColor;
 
-std::unordered_map> 
maPushButtonDefinitions;
-std::unordered_map> 
maRadioButtonDefinitions;
-std::unordered_map> 
maEditboxDefinitions;
-
-std::shared_ptr getPushButtonDefinition(ControlPart 
ePart);
-std::shared_ptr getRadioButtonDefinition(ControlPart 
ePart);
-std::shared_ptr getEditboxDefinition(ControlPart 
ePart);
+std::unordered_map> maDefinitions;
+std::shared_ptr getDefinition(ControlType eType, 
ControlPart ePart);
 };
 
 } // end vcl namespace
diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx 
b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
index 1cb577c08c4d..53da5e1a3bed 100644
--- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
@@ -24,9 +24,8 @@ class VCL_DLLPUBLIC WidgetDefinitionReader
 private:
 OUString m_rFilePath;
 
-static void
-readDefinition(tools::XmlWalker& rWalker,
-   std::unordered_map>& rDefinition);
+static void readDefinition(tools::XmlWalker& rWalker, WidgetDefinition& 
rWidgetDefinition,
+   ControlType eType);
 
 static void readPart(tools::XmlWalker& rWalker, 
std::shared_ptr rpPart);
 
diff --git a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx 
b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
index 54ac184651ca..6f64c95ebd7a 100644
--- a/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
+++ b/vcl/qa/cppunit/widgetdraw/WidgetDefinitionReaderTest.cxx
@@ -54,9 +54,10 @@ void WidgetDefinitionReaderTest::testRead()
 CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.maToolTextColor.AsRGBHexString());
 CPPUNIT_ASSERT_EQUAL(OUString("ff"), 
aDefinition.maFontColor.AsRGBHexString());
 
+// Pushbutton
 {
 std::vector> aStates
-= aDefinition.getPushButtonDefinition(ControlPart::Entire)
+= aDefinition.getDefinition(ControlType::Pushbutton, 
ControlPart::Entire)
   ->getStates(ControlState::DEFAULT | ControlState::ENABLED
   | ControlState::ROLLOVER,
   ImplControlValue());
@@ -69,9 +70,10 @@ void WidgetDefinitionReaderTest::testRead()
 CPPUNIT_ASSERT_EQUAL(vcl::DrawCommandType::CIRCLE, 
aStates[0]->mpDrawCommands[1]->maType);
 }
 
+// Radiobutton
 {
 std::vector> aStates
-= 

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

2018-06-18 Thread Khaled Hosny
 vcl/inc/font/OpenTypeFeatureDefinitonList.hxx|2 
 vcl/inc/font/OpenTypeFeatureStrings.hrc  |   52 
 vcl/qa/cppunit/FontFeatureTest.cxx   |   12 +--
 vcl/source/font/FeatureCollector.cxx |3 
 vcl/source/font/OpenTypeFeatureDefinitonList.cxx |   72 +++
 5 files changed, 34 insertions(+), 107 deletions(-)

New commits:
commit 80e9f9f8d8cc3e1073f98b1413bc0b80b93ec4f9
Author: Khaled Hosny 
Date:   Sun Jun 17 15:48:14 2018 +0200

Skip required features from the features dialog

Many OpenType features are required features that are applied to certain
context determined by the layout engine, or should always be on. There
is no value in presenting these features to the user and they just
clutter the dialog for fonts that usually have many of such features
(e.g. Arabic or Indic fonts).

Change-Id: Idc3d7d3a9eb1c4f693ea6fdf9f26f0264b910f91
Reviewed-on: https://gerrit.libreoffice.org/55951
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl 

diff --git a/vcl/inc/font/OpenTypeFeatureDefinitonList.hxx 
b/vcl/inc/font/OpenTypeFeatureDefinitonList.hxx
index f606017d7412..b5abb2708f4f 100644
--- a/vcl/inc/font/OpenTypeFeatureDefinitonList.hxx
+++ b/vcl/inc/font/OpenTypeFeatureDefinitonList.hxx
@@ -26,12 +26,14 @@ class VCL_DLLPUBLIC OpenTypeFeatureDefinitonListPrivate
 private:
 std::vector m_aFeatureDefinition;
 std::unordered_map m_aCodeToIndex;
+std::vector m_aRequiredFeatures;
 
 void init();
 
 public:
 OpenTypeFeatureDefinitonListPrivate();
 FeatureDefinition getDefinition(sal_uInt32 nFeatureCode);
+bool isRequired(sal_uInt32 nFeatureCode);
 };
 
 class VCL_DLLPUBLIC OpenTypeFeatureDefinitonList
diff --git a/vcl/inc/font/OpenTypeFeatureStrings.hrc 
b/vcl/inc/font/OpenTypeFeatureStrings.hrc
index 379a013b9f89..3ed3df4b90f4 100644
--- a/vcl/inc/font/OpenTypeFeatureStrings.hrc
+++ b/vcl/inc/font/OpenTypeFeatureStrings.hrc
@@ -23,27 +23,16 @@
 #define NC_(Context, String) (Context "\004" u8##String)
 
 #define STR_FONT_FEATURE_ID_AALT  NC_("STR_FONT_FEATURE_ID_AALT", 
"Access All Alternates")
-#define STR_FONT_FEATURE_ID_ABVF  NC_("STR_FONT_FEATURE_ID_ABVF", 
"Above Base Forms")
-#define STR_FONT_FEATURE_ID_ABVM  NC_("STR_FONT_FEATURE_ID_ABVM", 
"Above Base Mark Positioning")
-#define STR_FONT_FEATURE_ID_ABVS  NC_("STR_FONT_FEATURE_ID_ABVS", 
"Above Base Substitutions")
 #define STR_FONT_FEATURE_ID_AFRC  NC_("STR_FONT_FEATURE_ID_AFRC", 
"Alternative (Vertical) Fractions")
-#define STR_FONT_FEATURE_ID_AKHN  NC_("STR_FONT_FEATURE_ID_AKHN", 
"Akhands")
 #define STR_FONT_FEATURE_ID_ALIG  NC_("STR_FONT_FEATURE_ID_ALIG", 
"Ancient Ligatures")
-#define STR_FONT_FEATURE_ID_BLWF  NC_("STR_FONT_FEATURE_ID_BLWF", 
"Below Base Forms")
-#define STR_FONT_FEATURE_ID_BLWM  NC_("STR_FONT_FEATURE_ID_BLWM", 
"Below Base Mark Positioning")
-#define STR_FONT_FEATURE_ID_BLWS  NC_("STR_FONT_FEATURE_ID_BLWS", 
"Below Base Substitutions")
 #define STR_FONT_FEATURE_ID_C2PC  NC_("STR_FONT_FEATURE_ID_C2PC", 
"Capitals to Petite Capitals")
 #define STR_FONT_FEATURE_ID_C2SC  NC_("STR_FONT_FEATURE_ID_C2SC", 
"Capitals to Small Capitals")
 #define STR_FONT_FEATURE_ID_CALT  NC_("STR_FONT_FEATURE_ID_CALT", 
"Contextual Alternates")
 #define STR_FONT_FEATURE_ID_CASE  NC_("STR_FONT_FEATURE_ID_CASE", 
"Case-Sensitive Forms")
-#define STR_FONT_FEATURE_ID_CCMP  NC_("STR_FONT_FEATURE_ID_CCMP", 
"Glyph Composition / Decomposition")
-#define STR_FONT_FEATURE_ID_CFAR  NC_("STR_FONT_FEATURE_ID_CFAR", 
"Conjunct Form After Ro")
-#define STR_FONT_FEATURE_ID_CJCT  NC_("STR_FONT_FEATURE_ID_CJCT", 
"Conjunct Forms")
 #define STR_FONT_FEATURE_ID_CLIG  NC_("STR_FONT_FEATURE_ID_CLIG", 
"Contextual Ligatures")
 #define STR_FONT_FEATURE_ID_CPCT  NC_("STR_FONT_FEATURE_ID_CPCT", 
"Centered CJK Punctuation")
 #define STR_FONT_FEATURE_ID_CPSP  NC_("STR_FONT_FEATURE_ID_CPSP", 
"Capital Spacing")
 #define STR_FONT_FEATURE_ID_CSWH  NC_("STR_FONT_FEATURE_ID_CSWH", 
"Contextual Swash")
-#define STR_FONT_FEATURE_ID_CURS  NC_("STR_FONT_FEATURE_ID_CURS", 
"Cursive Attachment")
 #define STR_FONT_FEATURE_ID_CV01  NC_("STR_FONT_FEATURE_ID_CV01", 
"Character Variant 1")
 #define STR_FONT_FEATURE_ID_CV02  NC_("STR_FONT_FEATURE_ID_CV02", 
"Character Variant 2")
 #define STR_FONT_FEATURE_ID_CV03  NC_("STR_FONT_FEATURE_ID_CV03", 
"Character Variant 3")
@@ -56,32 +45,22 @@
 #define STR_FONT_FEATURE_ID_CV10  NC_("STR_FONT_FEATURE_ID_CV10", 
"Character Variant 10")
 #define STR_FONT_FEATURE_ID_CV11  NC_("STR_FONT_FEATURE_ID_CV11", 
"Character Variant 11")
 #define STR_FONT_FEATURE_ID_DCAP  NC_("STR_FONT_FEATURE_ID_DCAP", 
"Drop Caps")
-#define STR_FONT_FEATURE_ID_DIST  NC_("STR_FONT_FEATURE_ID_DIST", 
"Distances")
 

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

2018-04-27 Thread Khaled Hosny
 vcl/inc/sallayout.hxx|4 
 vcl/qa/cppunit/pdfexport/data/tdf66597-1.odt |binary
 vcl/qa/cppunit/pdfexport/data/tdf66597-2.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx   |  196 ++-
 vcl/source/gdi/CommonSalLayout.cxx   |   10 +
 vcl/source/gdi/pdfwriter_impl.cxx|  114 +--
 vcl/source/gdi/pdfwriter_impl.hxx|   14 +
 7 files changed, 320 insertions(+), 18 deletions(-)

New commits:
commit c688b01d9102832226251fc84045408afe392459
Author: Khaled Hosny 
Date:   Thu Apr 26 12:55:26 2018 +0200

tdf#66597 Fix PDF text extraction for complex text

Implement a more through strategy for embedding textual content in PDF
files:

* If there is unique one to one or one to many mapping between each
  glyph index and Unicode code points, use ToUnicode CMAP.
* If there is many to one or many to many mapping, use an ActualText
  span embedding the original string, since ToUnicode can’t handle
  these.
* If the one glyph is used for several Unicode code points, also use
  ActualText since ToUnicode can map each glyph in the font only once.
* Limit ActualText to single cluster at a time, since using it for whole
  words or sentences breaks text selection and highlighting in PDF
  viewers (there will be no way to tell which glyphs belong to which
  characters).
* Keep generating (now) redundant ToUnicode entries for compatibility
  with old tools not supporting ActualText.

Change-Id: I33261811b59b3b8fe2164c2c21d3c52c417e6208
Reviewed-on: https://gerrit.libreoffice.org/53315
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 170c2a2c380d..e07d51e8b3e8 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -287,7 +287,8 @@ public:
 IS_VERTICAL   = 0x008,
 IS_SPACING= 0x010,
 ALLOW_KASHIDA = 0x020,
-IS_DROPPED= 0x040
+IS_DROPPED= 0x040,
+IS_CLUSTER_START = 0x080
 };
 
 boolIsInCluster() const { return ((mnFlags & IS_IN_CLUSTER) != 0); 
}
@@ -297,6 +298,7 @@ public:
 boolIsSpacing() const   { return ((mnFlags & IS_SPACING) != 0); }
 boolAllowKashida() const{ return ((mnFlags & ALLOW_KASHIDA) != 0); 
}
 boolIsDropped() const   { return ((mnFlags & IS_DROPPED) != 0); }
+boolIsClusterStart() const  { return ((mnFlags & IS_CLUSTER_START) != 
0); }
 };
 
 class VCL_PLUGIN_PUBLIC GenericSalLayout : public SalLayout
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf66597-1.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf66597-1.odt
new file mode 100644
index ..7fecc55c6386
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf66597-1.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf66597-2.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf66597-2.odt
new file mode 100644
index ..3d7b5e59cc9d
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf66597-2.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index b9fe20df099f..d280f561fc64 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -75,8 +75,12 @@ public:
 void testTdf115117_1a();
 /// Test writing ToUnicode CMAP for RTL ligatures.
 void testTdf115117_2();
-/// Text extracting RTL text with ligatures.
+/// Test extracting RTL text with ligatures.
 void testTdf115117_2a();
+/// Test writing ToUnicode CMAP for doubly encoded glyphs.
+void testTdf66597_1();
+/// Test writing ActualText for many to one glyph to Unicode mapping.
+void testTdf66597_2();
 #endif
 #endif
 
@@ -101,6 +105,8 @@ public:
 CPPUNIT_TEST(testTdf115117_1a);
 CPPUNIT_TEST(testTdf115117_2);
 CPPUNIT_TEST(testTdf115117_2a);
+CPPUNIT_TEST(testTdf66597_1);
+CPPUNIT_TEST(testTdf66597_2);
 #endif
 #endif
 CPPUNIT_TEST_SUITE_END();
@@ -976,6 +982,194 @@ void PdfExportTest::testTdf115117_2a()
 OUString aActualText(aChars.data(), aChars.size());
 CPPUNIT_ASSERT_EQUAL(aExpectedText, aActualText);
 }
+
+// This requires Amiri font, if it is missing the test will fail.
+void PdfExportTest::testTdf66597_1()
+{
+// FIXME: Fallback font is used on Windows for some reason.
+#if !defined _WIN32
+vcl::filter::PDFDocument aDocument;
+load("tdf66597-1.odt", aDocument);
+
+{
+// Get access to ToUnicode of the first font
+vcl::filter::PDFObjectElement* pToUnicode = nullptr;
+for (const auto& aElement : aDocument.GetElements())
+{
+auto pObject = 
dynamic_cast(aElement.get());
+if (!pObject)
+continue;
+auto pType = 

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

2018-03-21 Thread Khaled Hosny
 vcl/inc/sallayout.hxx |5 
 vcl/qa/cppunit/pdfexport/data/tdf115117-1.odt |binary
 vcl/qa/cppunit/pdfexport/data/tdf115117-2.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport.cxx|  217 ++
 vcl/source/gdi/CommonSalLayout.cxx|   45 +
 vcl/source/gdi/pdfwriter_impl.cxx |   48 +
 6 files changed, 277 insertions(+), 38 deletions(-)

New commits:
commit b94a66ebc8db6c5ca9c7dcfdfbb06b49deae4939
Author: Khaled Hosny 
Date:   Wed Mar 21 16:54:10 2018 +0200

tdf#115117: Fix PDF ToUnicode CMAP for ligatures

Move the glyph to character(s) mapping to CommonSalLayout where we have
enough information to do this properly. This correctly handles ligatures
at end of run that wasn’t handled before, and also fixes a bug in the
PDF writer code when there is more than one ligature in the run (it
forgot to clear aCodeUnitsPerGlyph vector after each iteration). Also
drop the “temporary” fix for rotated glyph from 2009 that does not seem
to be needed now (the document from that bug exports correctly after this
change).

Change-Id: I5b5b1f4470bbd0ef05cbbc86dfa29d2ff51249ea
Reviewed-on: https://gerrit.libreoffice.org/51617
Tested-by: Jenkins 
Reviewed-by: Miklos Vajna 

diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index b1037bc684ef..962f0f6905ac 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -255,6 +255,7 @@ struct GlyphItem
 {
 int mnFlags;
 int mnCharPos;  // index in string
+int mnCharCount;// number of characters making up this glyph
 
 int mnOrigWidth;// original glyph width
 int mnNewWidth; // width after adjustments
@@ -270,6 +271,7 @@ public:
 long nFlags, int nOrigWidth )
 :   mnFlags(nFlags)
 ,   mnCharPos(nCharPos)
+,   mnCharCount(1)
 ,   mnOrigWidth(nOrigWidth)
 ,   mnNewWidth(nOrigWidth)
 ,   mnXOffset(0)
@@ -278,10 +280,11 @@ public:
 ,   mnFallbackLevel(0)
 { }
 
-GlyphItem( int nCharPos, sal_GlyphId aGlyphId, const Point& 
rLinearPos,
+GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, 
const Point& rLinearPos,
 long nFlags, int nOrigWidth, int nXOffset )
 :   mnFlags(nFlags)
 ,   mnCharPos(nCharPos)
+,   mnCharCount(nCharCount)
 ,   mnOrigWidth(nOrigWidth)
 ,   mnNewWidth(nOrigWidth)
 ,   mnXOffset(nXOffset)
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf115117-1.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf115117-1.odt
new file mode 100644
index ..63fe82946ef1
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf115117-1.odt 
differ
diff --git a/vcl/qa/cppunit/pdfexport/data/tdf115117-2.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf115117-2.odt
new file mode 100644
index ..c1e1f6d4392c
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf115117-2.odt 
differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 9ae6e19be328..fc46f22fec44 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -8,6 +8,7 @@
  */
 
 #include 
+#include 
 
 #include 
 #include 
@@ -25,6 +26,7 @@
 #include 
 #if HAVE_FEATURE_PDFIUM
 #include 
+#include 
 #include 
 #endif
 
@@ -67,6 +69,16 @@ public:
 void testTdf99680();
 void testTdf99680_2();
 void testTdf108963();
+#if !TEST_FONTS_MISSING
+/// Test writing ToUnicode CMAP for LTR ligatures.
+void testTdf115117_1();
+/// Text extracting LTR text with ligatures.
+void testTdf115117_1a();
+/// Test writing ToUnicode CMAP for RTL ligatures.
+void testTdf115117_2();
+/// Text extracting RTL text with ligatures.
+void testTdf115117_2a();
+#endif
 #endif
 
 CPPUNIT_TEST_SUITE(PdfExportTest);
@@ -85,6 +97,12 @@ public:
 CPPUNIT_TEST(testTdf99680);
 CPPUNIT_TEST(testTdf99680_2);
 CPPUNIT_TEST(testTdf108963);
+#if !TEST_FONTS_MISSING
+CPPUNIT_TEST(testTdf115117_1);
+CPPUNIT_TEST(testTdf115117_1a);
+CPPUNIT_TEST(testTdf115117_2);
+CPPUNIT_TEST(testTdf115117_2a);
+#endif
 #endif
 CPPUNIT_TEST_SUITE_END();
 };
@@ -760,6 +778,205 @@ void PdfExportTest::testTdf108963()
 
 CPPUNIT_ASSERT_EQUAL(1, nYellowPathCount);
 }
+
+#if !TEST_FONTS_MISSING
+// This requires Carlito font, if it is missing the test will most likely
+// fail.
+void PdfExportTest::testTdf115117_1()
+{
+vcl::filter::PDFDocument aDocument;
+load("tdf115117-1.odt", aDocument);
+
+vcl::filter::PDFObjectElement* pToUnicode = nullptr;
+
+// Get access to ToUnicode of the first font
+for (const auto& aElement : aDocument.GetElements())
+{
+auto pObject = 

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

2018-03-06 Thread Noel Grandin
 vcl/inc/svdata.hxx |   12 ++--
 vcl/qa/cppunit/BitmapProcessorTest.cxx |2 +-
 vcl/qa/cppunit/BitmapTest.cxx  |2 +-
 vcl/source/app/settings.cxx|2 +-
 vcl/source/control/button.cxx  |   24 
 vcl/source/gdi/gdimetafiletools.cxx|2 +-
 vcl/source/gdi/gdimtf.cxx  |6 +++---
 vcl/source/gdi/pngread.cxx |2 +-
 vcl/source/window/decoview.cxx |2 +-
 vcl/win/window/salframe.cxx|4 ++--
 vcl/workben/vcldemo.cxx|   10 +-
 11 files changed, 34 insertions(+), 34 deletions(-)

New commits:
commit b3ee860e523dce3df16350a4053a67f39c2f92f8
Author: Noel Grandin 
Date:   Tue Mar 6 10:42:13 2018 +0200

use more Color in vcl

Change-Id: Ia92c52d26b90898c1f7860128b478d1fada9d406
Reviewed-on: https://gerrit.libreoffice.org/50795
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index a074b3ce937f..42300a1e56e2 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -232,12 +232,12 @@ struct ImplSVCtrlData
 ImplTBDragMgr*  mpTBDragMgr = nullptr;  // DragMgr for 
ToolBox
 sal_uInt16  mnCheckStyle = 0;   // CheckBox-Style 
for ImageList-Update
 sal_uInt16  mnRadioStyle = 0;   // Radio-Style for 
ImageList-Update
-sal_uLong   mnLastCheckFColor = 0;  // Last FaceColor 
for CheckImage
-sal_uLong   mnLastCheckWColor = 0;  // Last 
WindowColor for CheckImage
-sal_uLong   mnLastCheckLColor = 0;  // Last LightColor 
for CheckImage
-sal_uLong   mnLastRadioFColor = 0;  // Last FaceColor 
for RadioImage
-sal_uLong   mnLastRadioWColor = 0;  // Last 
WindowColor for RadioImage
-sal_uLong   mnLastRadioLColor = 0;  // Last LightColor 
for RadioImage
+Color   mnLastCheckFColor;  // Last FaceColor 
for CheckImage
+Color   mnLastCheckWColor;  // Last 
WindowColor for CheckImage
+Color   mnLastCheckLColor;  // Last LightColor 
for CheckImage
+Color   mnLastRadioFColor;  // Last FaceColor 
for RadioImage
+Color   mnLastRadioWColor;  // Last 
WindowColor for RadioImage
+Color   mnLastRadioLColor;  // Last LightColor 
for RadioImage
 FieldUnitStringList*mpFieldUnitStrings = nullptr;   // list with field 
units
 FieldUnitStringList*mpCleanUnitStrings = nullptr;   // same list but 
with some "fluff" like spaces removed
 };
diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx 
b/vcl/qa/cppunit/BitmapProcessorTest.cxx
index 558401f84771..300302d41d60 100644
--- a/vcl/qa/cppunit/BitmapProcessorTest.cxx
+++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx
@@ -50,7 +50,7 @@ void BitmapProcessorTest::testDisabledImage()
 {
 Bitmap::ScopedReadAccess pReadAccess(aDisabledBitmap);
 Color aColor(pReadAccess->GetPixel(0, 0).GetColor());
-CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x001E1E1E), sal_uInt32(aColor));
+CPPUNIT_ASSERT_EQUAL(Color(0x001E1E1E), aColor);
 }
 }
 
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 5af967052326..3f112fa6f86b 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -484,7 +484,7 @@ void BitmapTest::testCRC()
 #endif
 
 // a 1x1 black & white checkerboard
-aVDev->DrawCheckered(Point(), aVDev->GetOutputSizePixel(), 1, 1);
+aVDev->DrawCheckered(Point(), aVDev->GetOutputSizePixel(), 1, Color(0, 0, 
1));
 Bitmap aChecker = getAsBitmap(aVDev);
 checkAndInsert(aCRCs, aChecker, "checkerboard");
 aChecker.Invert();
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index f7c35931ee60..f9eaf47ce645 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -2159,7 +2159,7 @@ static void setupPersonaHeaderFooter( WhichPersona 
eWhich, OUString& rHeaderFoot
 if ( nIndex > 0 )
 {
 OUString aColor = aPersonaSettings.getToken( 0, ';', ++nIndex );
-rMenuBarTextColor = Color( aColor.toUInt64( 16 ) );
+rMenuBarTextColor = Color( aColor.toUInt32( 16 ) );
 }
 }
 
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index bffbd1e93b66..35400b70ed8a 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2756,15 +2756,15 @@ Image RadioButton::GetRadioImage( const AllSettings& 
rSettings, DrawButtonFlags
 
 if ( pSVData->maCtrlData.maRadioImgList.empty() ||
  (pSVData->maCtrlData.mnRadioStyle != nStyle) ||
- 

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

2017-06-17 Thread Noel Grandin
 vcl/inc/unx/genpspgraphics.h   |5 -
 vcl/inc/unx/glyphcache.hxx |1 
 vcl/inc/unx/gtk/gtkframe.hxx   |1 
 vcl/inc/unx/i18n_cb.hxx|2 
 vcl/inc/unx/i18n_xkb.hxx   |3 
 vcl/inc/unx/printergfx.hxx |1 
 vcl/inc/unx/saldisp.hxx|3 
 vcl/inc/unx/salframe.h |3 
 vcl/inc/window.h   |2 
 vcl/qa/cppunit/wmf/wmfimporttest.cxx   |4 -
 vcl/source/filter/wmf/enhwmf.cxx   |   10 +--
 vcl/source/filter/wmf/winmtf.hxx   |5 -
 vcl/source/filter/wmf/winwmf.cxx   |   11 +--
 vcl/source/fontsubset/cff.cxx  |   78 -
 vcl/source/gdi/pdfwriter_impl.cxx  |8 --
 vcl/source/gdi/pdfwriter_impl.hxx  |2 
 vcl/source/gdi/pngread.cxx |4 -
 vcl/source/window/dockmgr.cxx  |   15 
 vcl/source/window/menubarwindow.cxx|1 
 vcl/source/window/menubarwindow.hxx|3 
 vcl/source/window/menufloatingwindow.cxx   |1 
 vcl/source/window/menufloatingwindow.hxx   |1 
 vcl/source/window/mouse.cxx|3 
 vcl/source/window/toolbox.cxx  |4 -
 vcl/source/window/window.cxx   |3 
 vcl/source/window/winproc.cxx  |1 
 vcl/unx/generic/app/i18n_cb.cxx|1 
 vcl/unx/generic/app/i18n_ic.cxx|1 
 vcl/unx/generic/app/i18n_status.cxx|5 -
 vcl/unx/generic/app/i18n_xkb.cxx   |4 -
 vcl/unx/generic/app/saldisp.cxx|4 -
 vcl/unx/generic/app/wmadaptor.cxx  |1 
 vcl/unx/generic/dtrans/X11_selection.cxx   |   14 
 vcl/unx/generic/dtrans/X11_selection.hxx   |7 --
 vcl/unx/generic/glyphs/freetype_glyphcache.cxx |   15 
 vcl/unx/generic/print/common_gfx.cxx   |4 -
 vcl/unx/generic/print/genprnpsp.cxx|4 -
 vcl/unx/generic/print/genpspgraphics.cxx   |9 --
 vcl/unx/generic/print/glyphset.cxx |1 
 vcl/unx/generic/print/glyphset.hxx |1 
 vcl/unx/generic/window/salframe.cxx|5 -
 vcl/unx/gtk/gtksalframe.cxx|5 -
 vcl/unx/gtk3/gtk3gtkframe.cxx  |5 -
 43 files changed, 26 insertions(+), 235 deletions(-)

New commits:
commit f9d5da8b491e30a08fa6996164e12e4d8715af46
Author: Noel Grandin 
Date:   Thu Jun 15 14:48:24 2017 +0200

loplugin:unusedfields in vcl part2

Change-Id: Icd02f63e9738c0bb91348e2084649f9edc281e67
Reviewed-on: https://gerrit.libreoffice.org/38833
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index b37bb909d1f2..01c061c565cc 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -46,14 +46,11 @@ class VCL_DLLPUBLIC GenPspGraphics : public SalGraphics
 psp::PrinterGfx*m_pPrinterGfx;
 
 FreetypeFont*   m_pFreetypeFont[ MAX_FALLBACK ];
-boolm_bFontVertical;
-SalInfoPrinter* m_pInfoPrinter;
 public:
 GenPspGraphics();
 virtual~GenPspGraphics() override;
 
-voidInit( psp::JobData* pJob, psp::PrinterGfx* pGfx,
-  SalInfoPrinter* pInfoPrinter );
+voidInit( psp::JobData* pJob, psp::PrinterGfx* pGfx );
 
 // helper methods
 static const void * DoGetEmbedFontData(psp::fontID aFont, long* 
pDataLen);
diff --git a/vcl/inc/unx/glyphcache.hxx b/vcl/inc/unx/glyphcache.hxx
index eb350ef0abd1..05095e5c9eca 100644
--- a/vcl/inc/unx/glyphcache.hxx
+++ b/vcl/inc/unx/glyphcache.hxx
@@ -190,7 +190,6 @@ private:
 boolmbFaceOk;
 boolmbArtItalic;
 boolmbArtBold;
-boolmbUseGamma;
 
 hb_font_t*  mpHbFont;
 };
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 37a4facabd0c..e5b89619efbc 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -188,7 +188,6 @@ class GtkSalFrame : public SalFrame
 boolm_bGraphics;
 ModKeyFlags m_nKeyModifiers;
 GdkCursor  *m_pCurrentCursor;
-GdkVisibilityState  m_nVisibility;
 PointerStylem_ePointerStyle;
 ScreenSaverInhibitorm_ScreenSaverInhibitor;
 int m_nWorkArea;
diff --git a/vcl/inc/unx/i18n_cb.hxx b/vcl/inc/unx/i18n_cb.hxx
index ceaf53eb3826..5ba32eea0fb0 100644
---