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

2023-11-07 Thread Noel Grandin (via logerrit)
 vcl/inc/animate/AnimationRenderer.hxx |2 +-
 vcl/source/animate/Animation.cxx  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit c71edc1f2e8226d4ac0f06a87f4f7f7107158f82
Author: Noel Grandin 
AuthorDate: Tue Nov 7 14:40:22 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Nov 8 06:50:46 2023 +0100

loplugin:fieldcast in AnimationData

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

diff --git a/vcl/inc/animate/AnimationRenderer.hxx 
b/vcl/inc/animate/AnimationRenderer.hxx
index f75b88e29541..bc86e65e3f46 100644
--- a/vcl/inc/animate/AnimationRenderer.hxx
+++ b/vcl/inc/animate/AnimationRenderer.hxx
@@ -33,7 +33,7 @@ struct AnimationData
 Point maOriginStartPt;
 Size maStartSize;
 VclPtr mpRenderContext;
-void* mpRendererData;
+AnimationRenderer* mpRendererData;
 tools::Long mnRendererId;
 bool mbIsPaused;
 
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index 5f2b8ce153ee..9063b9846a24 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -310,7 +310,7 @@ void Animation::PopulateRenderers()
 }
 else
 {
-pRenderer = 
static_cast(pDataItem->mpRendererData);
+pRenderer = pDataItem->mpRendererData;
 }
 
 pRenderer->pause(pDataItem->mbIsPaused);


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

2023-11-06 Thread László Németh (via logerrit)
 vcl/inc/svdata.hxx |3 +++
 vcl/source/control/imp_listbox.cxx |2 +-
 vcl/unx/gtk3/gtkframe.cxx  |6 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 698935c220131bc761eb9cf25e01fa91087a788e
Author: László Németh 
AuthorDate: Mon Nov 6 23:56:57 2023 +0100
Commit: László Németh 
CommitDate: Tue Nov 7 07:16:01 2023 +0100

tdf#152155 vcl: fix gtk popup listbox positions on sidebar

It was fixed only on Wayland previously.

Follow-up to commit 15cdee0d846854b50dd04626b73499bef9305e00
"Resolves: tdf#152155 use gtk's knowledge of relative widget positions".

Change-Id: I7a8b17189b319146142a2193ec4b5ec41e2c2d27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159020
Tested-by: Jenkins
Reviewed-by: László Németh 

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 104b9543b74a..fd7ae855b5f2 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -118,6 +118,9 @@ class UITestLogger;
 #define SV_ICON_ID_DATABASE12
 #define SV_ICON_ID_FORMULA 13
 
+const FloatWinPopupFlags LISTBOX_FLOATWINPOPUPFLAGS = FloatWinPopupFlags::Down 
|
+FloatWinPopupFlags::NoHorzPlacement | 
FloatWinPopupFlags::AllMouseButtonClose;
+
 namespace com::sun::star::datatransfer::clipboard { class XClipboard; }
 
 namespace vcl
diff --git a/vcl/source/control/imp_listbox.cxx 
b/vcl/source/control/imp_listbox.cxx
index 04919ca26f20..bb4da51859b0 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -3011,7 +3011,7 @@ void ImplListBoxFloatingWindow::StartFloat( bool 
bStartTracking )
 pGrandparentOutDev->ReMirror( aRect );
 
 // mouse-button right: close the List-Box-Float-win and don't stop the 
handling fdo#84795
-StartPopupMode( aRect, FloatWinPopupFlags::Down | 
FloatWinPopupFlags::NoHorzPlacement | FloatWinPopupFlags::AllMouseButtonClose );
+StartPopupMode( aRect, LISTBOX_FLOATWINPOPUPFLAGS );
 
 if( nPos != LISTBOX_ENTRY_NOTFOUND )
 mpImplLB->ShowProminentEntry( nPos );
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index b1bf8474b1b2..f063f80b7dea 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -3091,8 +3091,12 @@ void GtkSalFrame::EndSetClipRegion()
 
 void GtkSalFrame::PositionByToolkit(const tools::Rectangle& rRect, 
FloatWinPopupFlags nFlags)
 {
-if (ImplGetSVData()->maNWFData.mbCanDetermineWindowPosition)
+if ( ImplGetSVData()->maNWFData.mbCanDetermineWindowPosition &&
+// tdf#152155 cannot determine window positions of popup listboxes on 
sidebar
+nFlags != LISTBOX_FLOATWINPOPUPFLAGS )
+{
 return;
+}
 
 m_aFloatRect = rRect;
 m_nFloatFlags = nFlags;


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

2023-11-05 Thread Chris Sherlock (via logerrit)
 vcl/inc/textlayout.hxx |5 
 vcl/source/text/textlayout.cxx |  226 +++--
 2 files changed, 135 insertions(+), 96 deletions(-)

New commits:
commit 5886a6faad298cb42fdb4ceb52120bfc569c6e14
Author: Chris Sherlock 
AuthorDate: Tue Oct 17 17:53:10 2023 +1100
Commit: Tomaž Vajngerl 
CommitDate: Mon Nov 6 07:20:28 2023 +0100

vcl: split out functions from TextLayoutCommon::GetEllipsisString()

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

diff --git a/vcl/inc/textlayout.hxx b/vcl/inc/textlayout.hxx
index ee9eb9e39266..b5402cc63177 100644
--- a/vcl/inc/textlayout.hxx
+++ b/vcl/inc/textlayout.hxx
@@ -66,6 +66,11 @@ namespace vcl
  ImplMultiTextLineInfo& rLineInfo,
  tools::Long nWidth, OUString const& rStr,
  DrawTextFlags nStyle);
+
+private:
+OUString GetCenterEllipsisString(OUString const& rOrigStr, sal_Int32 
nIndex, tools::Long nMaxWidth);
+OUString GetEndEllipsisString(OUString const& rOrigStr, sal_Int32 
nIndex, tools::Long nMaxWidth, bool bClipText);
+OUString GetNewsEllipsisString(OUString const& rOrigStr, tools::Long 
nMaxWidth, DrawTextFlags nStyle);
 };
 
 /** is an implementation of the ITextLayout interface which simply 
delegates its calls to the respective
diff --git a/vcl/source/text/textlayout.cxx b/vcl/source/text/textlayout.cxx
index a1597c69793e..db2226842d09 100644
--- a/vcl/source/text/textlayout.cxx
+++ b/vcl/source/text/textlayout.cxx
@@ -69,134 +69,148 @@ void ImplMultiTextLineInfo::Clear()
 
 namespace vcl
 {
+OUString TextLayoutCommon::GetCenterEllipsisString(OUString const& 
rOrigStr, sal_Int32 nIndex, tools::Long nMaxWidth)
+{
+OUStringBuffer aTmpStr(rOrigStr);
 
-OUString TextLayoutCommon::GetEllipsisString(OUString const& rOrigStr, 
tools::Long nMaxWidth, DrawTextFlags nStyle)
+// speed it up by removing all but 1.33x as many as the break pos.
+sal_Int32 nEraseChars = std::max(4, rOrigStr.getLength() - 
(nIndex*4)/3);
+while(nEraseChars < rOrigStr.getLength() && 
GetTextWidth(aTmpStr.toString(), 0, aTmpStr.getLength()) > nMaxWidth)
+{
+aTmpStr = rOrigStr;
+sal_Int32 i = (aTmpStr.getLength() - nEraseChars)/2;
+aTmpStr.remove(i, nEraseChars++);
+aTmpStr.insert(i, "...");
+}
+
+return aTmpStr.makeStringAndClear();
+}
+
+OUString TextLayoutCommon::GetEndEllipsisString(OUString const& rOrigStr, 
sal_Int32 nIndex, tools::Long nMaxWidth, bool bClipText)
 {
 OUString aStr = rOrigStr;
-sal_Int32 nIndex = GetTextBreak( aStr, nMaxWidth, 0, aStr.getLength() 
);
-
-if (nIndex == -1)
-return aStr;
+aStr = aStr.copy(0, nIndex);
 
-if( (nStyle & DrawTextFlags::CenterEllipsis) == 
DrawTextFlags::CenterEllipsis )
+if (nIndex > 1)
 {
-OUStringBuffer aTmpStr( aStr );
-// speed it up by removing all but 1.33x as many as the break pos.
-sal_Int32 nEraseChars = std::max(4, aStr.getLength() - 
(nIndex*4)/3);
-while( nEraseChars < aStr.getLength() && GetTextWidth( 
aTmpStr.toString(), 0, aTmpStr.getLength() ) > nMaxWidth )
+aStr += "...";
+while (!aStr.isEmpty() && (GetTextWidth(aStr, 0, aStr.getLength()) 
> nMaxWidth))
 {
-aTmpStr = aStr;
-sal_Int32 i = (aTmpStr.getLength() - nEraseChars)/2;
-aTmpStr.remove(i, nEraseChars++);
-aTmpStr.insert(i, "...");
+if ((nIndex > 1) || (nIndex == aStr.getLength()))
+nIndex--;
+
+aStr = aStr.replaceAt(nIndex, 1, u"");
 }
-aStr = aTmpStr.makeStringAndClear();
 }
-else if ( nStyle & DrawTextFlags::EndEllipsis )
+
+if (aStr.isEmpty() && bClipText)
+aStr += OUStringChar(rOrigStr[0]);
+
+return aStr;
+}
+
+namespace
+{
+OUString lcl_GetPathEllipsisString(OUString const& rOrigStr, sal_Int32 
nIndex)
 {
-aStr = aStr.copy(0, nIndex);
-if ( nIndex > 1 )
-{
-aStr += "...";
-while ( !aStr.isEmpty() && ( GetTextWidth( aStr, 0, 
aStr.getLength() ) > nMaxWidth) )
-{
-if ( (nIndex > 1) || (nIndex == aStr.getLength()) )
-nIndex--;
-aStr = aStr.replaceAt( nIndex, 1, u"");
-}
-}
+OUString aPath(rOrigStr);
+OUString aAbbreviatedPath;
+osl_abbreviateSystemPath(aPath.pData, , 
nIndex, nullptr);
+return aAbbreviatedPath;
+}
+}
 
-if ( 

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

2023-11-02 Thread Tobias Kokolakis (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx|3 --
 vcl/source/gdi/pdfwriter_impl.cxx |   46 --
 2 files changed, 5 insertions(+), 44 deletions(-)

New commits:
commit fa7ae4638431bf4f4d40d16ab0017ec59e233039
Author: Tobias Kokolakis 
AuthorDate: Sat Sep 2 13:52:02 2023 +0200
Commit: Mike Kaganski 
CommitDate: Fri Nov 3 06:08:23 2023 +0100

tdf#156478 Remove unused default values for MediaBox and UserUnit

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index b20de8171473..23ba7c7baed5 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -113,9 +113,6 @@ class PDFObjectElement;
 
 namespace pdf
 {
-constexpr sal_Int32 g_nInheritedPageWidth = 595;  // default A4 in inch/72
-constexpr sal_Int32 g_nInheritedPageHeight = 842; // default A4 in inch/72
-
 struct PDFPage
 {
 VclPtr   m_pWriter;
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index d11e75cf08dc..15eafe302953 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -1211,7 +1211,7 @@ void PDFPage::appendMatrix3(Matrix3 const & rMatrix, 
OStringBuffer& rBuffer)
 
 double PDFPage::getHeight() const
 {
-double fRet = m_nPageHeight ? m_nPageHeight : 
vcl::pdf::g_nInheritedPageHeight;
+double fRet = m_nPageHeight ? m_nPageHeight : 842; // default A4 height in 
inch/72, OK to use hardcoded value here?
 
 if (m_nUserUnit > 1)
 {
@@ -5241,41 +5241,9 @@ bool PDFWriterImpl::emitCatalog()
 aLine.append( getResourceDictObj() );
 aLine.append( " 0 R\n" );
 
-double nMediaBoxWidth = 0;
-double nMediaBoxHeight = 0;
-sal_Int32 nUserUnit = 1;
 if( m_aPages.empty() ) // sanity check, this should not happen
-{
-nMediaBoxWidth = g_nInheritedPageWidth;
-nMediaBoxHeight = g_nInheritedPageHeight;
-}
-else
-{
-for (auto const& page : m_aPages)
-{
-if( page.m_nPageWidth > nMediaBoxWidth )
-{
-nMediaBoxWidth = page.m_nPageWidth;
-nUserUnit = page.m_nUserUnit;
-}
-if( page.m_nPageHeight > nMediaBoxHeight )
-{
-nMediaBoxHeight = page.m_nPageHeight;
-nUserUnit = page.m_nUserUnit;
-}
-}
-}
-aLine.append( "/MediaBox[ 0 0 " );
-aLine.append(nMediaBoxWidth / nUserUnit);
-aLine.append( ' ' );
-aLine.append(nMediaBoxHeight / nUserUnit);
-aLine.append(" ]\n");
-if (nUserUnit > 1)
-{
-aLine.append("/UserUnit ");
-aLine.append(nUserUnit);
-aLine.append("\n");
-}
+aLine.append( "/MediaBox[0 0 595 842]\n" ); // default A4 size in pt
+
 aLine.append("/Kids[ ");
 unsigned int i = 0;
 for (const auto & page : m_aPages)
@@ -5421,16 +5389,12 @@ bool PDFWriterImpl::emitCatalog()
 case PDFWriter::FitWidth :
 aLine.append( "/OpenAction[" );
 aLine.append( aInitPageRef );
-aLine.append( " /FitH " );
-aLine.append( g_nInheritedPageHeight );//Open fit width
-aLine.append( "]\n" );
+aLine.append( " /FitH 842]\n" ); //Open fit width, default A4 height 
in pt, OK to use hardcoded value here?
 break;
 case PDFWriter::FitVisible :
 aLine.append( "/OpenAction[" );
 aLine.append( aInitPageRef );
-aLine.append( " /FitBH " );
-aLine.append( g_nInheritedPageHeight );//Open fit visible
-aLine.append( "]\n" );
+aLine.append( " /FitBH 842]\n" ); //Open fit visible, , default A4 
height in pt, OK to use hardcoded value here?
 break;
 case PDFWriter::ActionZoom :
 aLine.append( "/OpenAction[" );


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

2023-09-04 Thread Sarper Akdemir (via logerrit)
 vcl/inc/pdf/XmpMetadata.hxx   |1 +
 vcl/source/gdi/pdfwriter_impl.cxx |   32 +---
 vcl/source/pdf/XmpMetadata.cxx|8 +++-
 3 files changed, 29 insertions(+), 12 deletions(-)

New commits:
commit a45f72b8122d3bb4c0d5ac4252cf7e5a25d52291
Author: Sarper Akdemir 
AuthorDate: Thu Aug 31 02:59:51 2023 +0300
Commit: Sarper Akdemir 
CommitDate: Mon Sep 4 20:53:40 2023 +0200

tdf#138792: PDF export: export metadata pdf:PDFVersion

Adds export of pdf:PDFVersion metadata.

Change-Id: Ic4c3eec3672839d0d125b64dfca6149912cd2458
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156329
Tested-by: Jenkins
Reviewed-by: Sarper Akdemir 

diff --git a/vcl/inc/pdf/XmpMetadata.hxx b/vcl/inc/pdf/XmpMetadata.hxx
index d94d6e690c3c..a144266497cf 100644
--- a/vcl/inc/pdf/XmpMetadata.hxx
+++ b/vcl/inc/pdf/XmpMetadata.hxx
@@ -27,6 +27,7 @@ public:
 OString msAuthor;
 OString msSubject;
 OString msProducer;
+OString msPDFVersion;
 OString msKeywords;
 OString m_sCreatorTool;
 OString m_sCreateDate;
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index def3d4ee3ba5..00b59830f048 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -623,6 +623,25 @@ void appendPdfTimeDate(OStringBuffer & rBuffer,
 }
 }
 
+const char* getPDFVersionStr(PDFWriter::PDFVersion ePDFVersion)
+{
+switch (ePDFVersion)
+{
+case PDFWriter::PDFVersion::PDF_A_1:
+case PDFWriter::PDFVersion::PDF_1_4:
+return "1.4";
+case PDFWriter::PDFVersion::PDF_1_5:
+return "1.5";
+case PDFWriter::PDFVersion::PDF_1_6:
+return "1.6";
+default:
+case PDFWriter::PDFVersion::PDF_A_2:
+case PDFWriter::PDFVersion::PDF_A_3:
+case PDFWriter::PDFVersion::PDF_1_7:
+return "1.7";
+}
+}
+
 } // end namespace
 
 PDFPage::PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double 
nPageHeight, PDFWriter::Orientation eOrientation )
@@ -1295,17 +1314,7 @@ PDFWriterImpl::PDFWriterImpl( const 
PDFWriter::PDFWriterContext& rContext,
 // write header
 OStringBuffer aBuffer( 20 );
 aBuffer.append( "%PDF-" );
-switch( m_aContext.Version )
-{
-case PDFWriter::PDFVersion::PDF_A_1:
-case PDFWriter::PDFVersion::PDF_1_4: aBuffer.append( "1.4" );break;
-case PDFWriter::PDFVersion::PDF_1_5: aBuffer.append( "1.5" );break;
-case PDFWriter::PDFVersion::PDF_1_6: aBuffer.append( "1.6" );break;
-default:
-case PDFWriter::PDFVersion::PDF_A_2:
-case PDFWriter::PDFVersion::PDF_A_3:
-case PDFWriter::PDFVersion::PDF_1_7: aBuffer.append( "1.7" );break;
-}
+aBuffer.append(getPDFVersionStr(m_aContext.Version));
 // append something binary as comment (suggested in PDF Reference)
 aBuffer.append( "\n%\303\244\303\274\303\266\303\237\n" );
 if( !writeBuffer( aBuffer ) )
@@ -5952,6 +5961,7 @@ sal_Int32 PDFWriterImpl::emitDocumentMetadata()
 lcl_assignMeta(m_aContext.DocumentInfo.Author, aMetadata.msAuthor);
 lcl_assignMeta(m_aContext.DocumentInfo.Subject, aMetadata.msSubject);
 lcl_assignMeta(m_aContext.DocumentInfo.Producer, aMetadata.msProducer);
+aMetadata.msPDFVersion = getPDFVersionStr(m_aContext.Version);
 lcl_assignMeta(m_aContext.DocumentInfo.Keywords, aMetadata.msKeywords);
 lcl_assignMeta(m_aContext.DocumentInfo.Creator, 
aMetadata.m_sCreatorTool);
 aMetadata.m_sCreateDate = m_aCreationMetaDateString;
diff --git a/vcl/source/pdf/XmpMetadata.cxx b/vcl/source/pdf/XmpMetadata.cxx
index 7b0df42dbb92..6dae3b86ebc1 100644
--- a/vcl/source/pdf/XmpMetadata.cxx
+++ b/vcl/source/pdf/XmpMetadata.cxx
@@ -122,7 +122,7 @@ void XmpMetadata::write()
 }
 
 // PDF properties
-if (!msProducer.isEmpty() || !msKeywords.isEmpty())
+if (!msProducer.isEmpty() || !msKeywords.isEmpty() || 
!msPDFVersion.isEmpty())
 {
 aXmlWriter.startElement("rdf:Description");
 aXmlWriter.attribute("rdf:about", OString(""));
@@ -139,6 +139,12 @@ void XmpMetadata::write()
 aXmlWriter.content(msKeywords);
 aXmlWriter.endElement();
 }
+if (!msPDFVersion.isEmpty())
+{
+aXmlWriter.startElement("pdf:PDFVersion");
+aXmlWriter.content(msPDFVersion);
+aXmlWriter.endElement();
+}
 aXmlWriter.endElement();
 }
 


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

2023-08-28 Thread Szymon Kłos (via logerrit)
 vcl/inc/verticaltabctrl.hxx   |4 +++
 vcl/source/control/ivctrl.cxx |   44 ++
 2 files changed, 48 insertions(+)

New commits:
commit 407297d9c592479d9fc90033876cad96206f9259
Author: Szymon Kłos 
AuthorDate: Thu Aug 17 10:21:57 2023 +0200
Commit: Szymon Kłos 
CommitDate: Mon Aug 28 10:19:03 2023 +0200

jsdialog: dump vertical tab control

Change-Id: I673199dfd7e95bfdb748791db094e7a1c3e74dba
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155759
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Attila Szűcs 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156158
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/vcl/inc/verticaltabctrl.hxx b/vcl/inc/verticaltabctrl.hxx
index df05cfdf72b5..c5942799b381 100644
--- a/vcl/inc/verticaltabctrl.hxx
+++ b/vcl/inc/verticaltabctrl.hxx
@@ -22,6 +22,8 @@
 #include 
 #include 
 
+#include 
+
 #include 
 #include 
 
@@ -78,6 +80,8 @@ public:
 
 vcl::Window* GetPageParent() { return m_xBox.get(); }
 
+virtual void DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) override;
+
 virtual FactoryFunction GetUITestFactory() const override;
 };
 
diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx
index 8a7e111f1581..a2f502ff81dc 100644
--- a/vcl/source/control/ivctrl.cxx
+++ b/vcl/source/control/ivctrl.cxx
@@ -627,6 +627,50 @@ void VerticalTabControl::SetPageText(std::u16string_view 
rPageId, const OUString
 pData->pEntry->SetText(rText);
 }
 
+void VerticalTabControl::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
+{
+rJsonWriter.put("id", get_id());
+rJsonWriter.put("type", "tabcontrol");
+rJsonWriter.put("vertical", true);
+rJsonWriter.put("selected", GetCurPageId());
+
+{
+auto childrenNode = rJsonWriter.startArray("children");
+for (int i = 0; i < GetPageCount(); i++)
+{
+VclPtr pChild = GetPage(GetPageId(i));
+
+if (pChild)
+{
+if (!pChild->GetChildCount())
+continue;
+
+auto aChildNode = rJsonWriter.startStruct();
+pChild->DumpAsPropertyTree(rJsonWriter);
+}
+}
+}
+{
+auto tabsNode = rJsonWriter.startArray("tabs");
+for(int i = 0; i < GetPageCount(); i++)
+{
+VclPtr pChild = GetPage(GetPageId(i));
+
+if (pChild)
+{
+if (!pChild->GetChildCount())
+continue;
+
+auto aTabNode = rJsonWriter.startStruct();
+auto sId = GetPageId(i);
+rJsonWriter.put("text", GetPageText(sId));
+rJsonWriter.put("id", sId);
+rJsonWriter.put("name", GetPageText(sId));
+}
+}
+}
+}
+
 FactoryFunction VerticalTabControl::GetUITestFactory() const
 {
 return VerticalTabControlUIObject::create;


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

2023-08-10 Thread Mike Kaganski (via logerrit)
 vcl/inc/pdf/pdfcompat.hxx  |2 +-
 vcl/source/filter/ipdf/pdfread.cxx |   12 
 2 files changed, 5 insertions(+), 9 deletions(-)

New commits:
commit 0d8a5f89bff51480d721395729a67e7b4260aea5
Author: Mike Kaganski 
AuthorDate: Thu Aug 10 10:32:21 2023 +0300
Commit: Mike Kaganski 
CommitDate: Thu Aug 10 12:58:54 2023 +0200

Simplify conversion, and fix a comment

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

diff --git a/vcl/inc/pdf/pdfcompat.hxx b/vcl/inc/pdf/pdfcompat.hxx
index 8f629b3bc8ee..5d6d623a107e 100644
--- a/vcl/inc/pdf/pdfcompat.hxx
+++ b/vcl/inc/pdf/pdfcompat.hxx
@@ -17,7 +17,7 @@
 
 namespace vcl::pdf
 {
-/// Convert to inch, then assume 96 DPI.
+/// Convert to inch, then apply custom resolution.
 inline double pointToPixel(const double fPoint, const double fResolutionDPI)
 {
 return o3tl::convert(fPoint, o3tl::Length::pt, o3tl::Length::in) * 
fResolutionDPI;
diff --git a/vcl/source/filter/ipdf/pdfread.cxx 
b/vcl/source/filter/ipdf/pdfread.cxx
index 18f8c4dee95e..8dc4c967a616 100644
--- a/vcl/source/filter/ipdf/pdfread.cxx
+++ b/vcl/source/filter/ipdf/pdfread.cxx
@@ -368,14 +368,10 @@ size_t ImportPDFUnloaded(const OUString& rURL, 
std::vector& rG
 if (aPageSize.getWidth() <= 0.0 || aPageSize.getHeight() <= 0.0)
 continue;
 
-// Returned unit is points, convert that to twip
-// 1 pt = 20 twips
-constexpr double pointToTwipconversionRatio = 20;
-
-tools::Long nPageWidth
-= convertTwipToMm100(aPageSize.getWidth() * 
pointToTwipconversionRatio);
-tools::Long nPageHeight
-= convertTwipToMm100(aPageSize.getHeight() * 
pointToTwipconversionRatio);
+// Returned unit is points
+
+tools::Long nPageWidth = 
std::round(convertPointToMm100(aPageSize.getWidth()));
+tools::Long nPageHeight = 
std::round(convertPointToMm100(aPageSize.getHeight()));
 
 // Create the Graphic with the VectorGraphicDataPtr and link the 
original PDF stream.
 // We swap out this Graphic as soon as possible, and a later swap in


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

2023-07-22 Thread Khaled Hosny (via logerrit)
 vcl/inc/ImplLayoutArgs.hxx |6 +++---
 vcl/source/gdi/CommonSalLayout.cxx |4 ++--
 vcl/source/gdi/sallayout.cxx   |4 ++--
 vcl/source/outdev/text.cxx |   12 ++--
 vcl/source/text/ImplLayoutArgs.cxx |   10 +-
 5 files changed, 18 insertions(+), 18 deletions(-)

New commits:
commit 8e9b65c874d99e3302a9e7dfd0c7a30963526bc2
Author: Khaled Hosny 
AuthorDate: Sun Jul 16 18:20:14 2023 +0300
Commit: خالد حسني 
CommitDate: Sun Jul 23 06:00:49 2023 +0200

vcl: rename NaturalDXArray to DXArray

The unnatural DXArray is gone for a while now.

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

diff --git a/vcl/inc/ImplLayoutArgs.hxx b/vcl/inc/ImplLayoutArgs.hxx
index 381d09185563..d7100d71fd8b 100644
--- a/vcl/inc/ImplLayoutArgs.hxx
+++ b/vcl/inc/ImplLayoutArgs.hxx
@@ -35,7 +35,7 @@ public:
 vcl::text::TextLayoutCache const* m_pTextLayoutCache;
 
 // positioning related inputs
-const double* mpNaturalDXArray; // in floating point pixel units
+const double* mpDXArray; // in floating point pixel units
 const sal_Bool* mpKashidaArray;
 DeviceCoordinate mnLayoutWidth; // in pixel units
 Degree10 mnOrientation; // in 0-3600 system
@@ -48,7 +48,7 @@ public:
LanguageTag aLanguageTag, vcl::text::TextLayoutCache const* 
pLayoutCache);
 
 void SetLayoutWidth(DeviceCoordinate nWidth);
-void SetNaturalDXArray(const double* pDXArray);
+void SetDXArray(const double* pDXArray);
 void SetKashidaArray(const sal_Bool* pKashidaArray);
 void SetOrientation(Degree10 nOrientation);
 
@@ -56,7 +56,7 @@ public:
 bool GetNextPos(int* nCharPos, bool* bRTL);
 bool GetNextRun(int* nMinRunPos, int* nEndRunPos, bool* bRTL);
 void AddFallbackRun(int nMinRunPos, int nEndRunPos, bool bRTL);
-bool HasDXArray() const { return mpNaturalDXArray; }
+bool HasDXArray() const { return mpDXArray; }
 
 // methods used by BiDi and glyph fallback
 bool HasFallbackRun() const;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index c3b8fab84595..f46f4d875210 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -139,8 +139,8 @@ void 
GenericSalLayout::AdjustLayout(vcl::text::ImplLayoutArgs& rArgs)
 {
 SalLayout::AdjustLayout(rArgs);
 
-if (rArgs.mpNaturalDXArray)
-ApplyDXArray(rArgs.mpNaturalDXArray, rArgs.mpKashidaArray);
+if (rArgs.mpDXArray)
+ApplyDXArray(rArgs.mpDXArray, rArgs.mpKashidaArray);
 else if (rArgs.mnLayoutWidth)
 Justify(rArgs.mnLayoutWidth);
 // apply asian kerning if the glyphs are not already formatted
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 3cdd71642b5b..be3506bf4e3c 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -688,11 +688,11 @@ void MultiSalLayout::AdjustLayout( 
vcl::text::ImplLayoutArgs& rArgs )
 for (DeviceCoordinate a : aJustificationArray)
 aNaturalJustificationArray.push_back(a);
 // change the DXArray temporarily (just for the justification)
-aMultiArgs.mpNaturalDXArray = aNaturalJustificationArray.data();
+aMultiArgs.mpDXArray = aNaturalJustificationArray.data();
 }
 }
 
-ImplAdjustMultiLayout(rArgs, aMultiArgs, aMultiArgs.mpNaturalDXArray);
+ImplAdjustMultiLayout(rArgs, aMultiArgs, aMultiArgs.mpDXArray);
 }
 
 void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs,
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 2c5f9aae06aa..61d965a28b68 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -1363,10 +1363,10 @@ std::unique_ptr 
OutputDevice::ImplLayout(const OUString& rOrigStr,
 nPixelWidth, flags, pLayoutCache);
 
 DeviceCoordinate nEndGlyphCoord(0);
-std::unique_ptr xNaturalDXPixelArray;
+std::unique_ptr xDXPixelArray;
 if( !pDXArray.empty() )
 {
-xNaturalDXPixelArray.reset(new double[nLen]);
+xDXPixelArray.reset(new double[nLen]);
 
 if (mbMap)
 {
@@ -1374,16 +1374,16 @@ std::unique_ptr 
OutputDevice::ImplLayout(const OUString& rOrigStr,
 // keeping accuracy for lower levels
 int nSubPixels = pDXArray.get_factor();
 for (int i = 0; i < nLen; ++i)
-xNaturalDXPixelArray[i] = 
ImplLogicWidthToDeviceSubPixel(pDXArray.get_subunit(i)) / nSubPixels;
+xDXPixelArray[i] = 
ImplLogicWidthToDeviceSubPixel(pDXArray.get_subunit(i)) / nSubPixels;
 }
 else
 {
 for(int i = 0; i < nLen; ++i)
-xNaturalDXPixelArray[i] = pDXArray.get(i);
+xDXPixelArray[i] = pDXArray.get(i);
 }
 
-

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

2023-07-18 Thread Noel Grandin (via logerrit)
 vcl/inc/dndeventdispatcher.hxx   |2 +-
 vcl/source/window/dndeventdispatcher.cxx |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 3394fe4f19def29e314798fa64235b28d9df50a6
Author: Noel Grandin 
AuthorDate: Tue Jul 18 15:04:12 2023 +0200
Commit: Noel Grandin 
CommitDate: Tue Jul 18 21:08:00 2023 +0200

fix DNDEventDispatcher::findTopLevelWindow

for the unlikely case of antiparallel desktop (whatever that is)

regression from
commit ea05f2aa4e28fd40238c4962e9dcbbf0d873cabd
Author: Norbert Thiebaud 
Date:   Thu Oct 14 22:12:16 2010 -0500
migrate OClearableGuard(SoalrMutex) to SolarMutexGuard

when the code findTopLevelWindow was extracted into its own method,
the location parameter was not made a reference, which is necessary to
propogate the update that occurs in OutputDevice::ReMirror

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

diff --git a/vcl/inc/dndeventdispatcher.hxx b/vcl/inc/dndeventdispatcher.hxx
index 9756056da3bd..0b3f58560282 100644
--- a/vcl/inc/dndeventdispatcher.hxx
+++ b/vcl/inc/dndeventdispatcher.hxx
@@ -42,7 +42,7 @@ class DNDEventDispatcher final : public 
::cppu::WeakImplHelper<
 std::recursive_mutex m_aMutex;
 css::uno::Sequence< css::datatransfer::DataFlavor > m_aDataFlavorList;
 
-vcl::Window* findTopLevelWindow(Point location);
+vcl::Window* findTopLevelWindow(Point& location);
 /*
  * fire the events on the dnd listener container of the specified window
  */
diff --git a/vcl/source/window/dndeventdispatcher.cxx 
b/vcl/source/window/dndeventdispatcher.cxx
index a5a89928e616..c57841c1fdfa 100644
--- a/vcl/source/window/dndeventdispatcher.cxx
+++ b/vcl/source/window/dndeventdispatcher.cxx
@@ -42,7 +42,7 @@ DNDEventDispatcher::~DNDEventDispatcher()
 designate_currentwindow(nullptr);
 }
 
-vcl::Window* DNDEventDispatcher::findTopLevelWindow(Point location)
+vcl::Window* DNDEventDispatcher::findTopLevelWindow(Point& location)
 {
 SolarMutexGuard aSolarGuard;
 


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

2023-07-13 Thread Rico Tzschichholz (via logerrit)
 vcl/inc/TextLayoutCache.hxx|2 +-
 vcl/source/gdi/CommonSalLayout.cxx |1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 55d62057c0ccd533af63b2a01edb0cddbd619721
Author: Rico Tzschichholz 
AuthorDate: Sun Apr 2 11:15:11 2023 +0200
Commit: خالد حسني 
CommitDate: Thu Jul 13 18:24:39 2023 +0200

vcl: Move include of  to the appropriate place

hb_icu_script_to_script is used in CommonSalLayout.cxx only

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

diff --git a/vcl/inc/TextLayoutCache.hxx b/vcl/inc/TextLayoutCache.hxx
index 46e5c80dc320..304c6d51ebfb 100644
--- a/vcl/inc/TextLayoutCache.hxx
+++ b/vcl/inc/TextLayoutCache.hxx
@@ -25,7 +25,7 @@
 
 #include 
 
-#include 
+#include 
 
 #include 
 
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 324b6fb48b07..c3b8fab84595 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 


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

2023-07-11 Thread Szymon Kłos (via logerrit)
 vcl/inc/salvtables.hxx|   29 +
 vcl/source/app/salvtables.cxx |   29 -
 2 files changed, 29 insertions(+), 29 deletions(-)

New commits:
commit 16d600edcc33b72a9d09b7f2f496313612ffebd4
Author: Szymon Kłos 
AuthorDate: Thu Jul 6 15:36:39 2023 +0200
Commit: Szymon Kłos 
CommitDate: Tue Jul 11 15:51:11 2023 +0200

jsdialog: Move SalInstanceCalendar decl to header file

Change-Id: Ide9e685d724d646f0ab8825b1fce2b6fd130d3ec
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154135
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Szymon Kłos 
(cherry picked from commit d792875d79a63364dba02426ef75d696ae0f02ef)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154266
Tested-by: Jenkins

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 7ac28808ce3d..d3949cd68590 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include "calendar.hxx"
 #include "iconview.hxx"
 #include "listbox.hxx"
 #include "messagedialog.hxx"
@@ -2178,4 +2179,32 @@ public:
 virtual ~SalInstanceScrolledWindow() override;
 };
 
+class SalInstanceCalendar : public SalInstanceWidget, public virtual 
weld::Calendar
+{
+private:
+VclPtr<::Calendar> m_xCalendar;
+
+DECL_LINK(SelectHdl, ::Calendar*, void);
+DECL_LINK(ActivateHdl, ::Calendar*, void);
+
+public:
+SalInstanceCalendar(::Calendar* pCalendar, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership)
+: SalInstanceWidget(pCalendar, pBuilder, bTakeOwnership)
+, m_xCalendar(pCalendar)
+{
+m_xCalendar->SetSelectHdl(LINK(this, SalInstanceCalendar, SelectHdl));
+m_xCalendar->SetActivateHdl(LINK(this, SalInstanceCalendar, 
ActivateHdl));
+}
+
+virtual void set_date(const Date& rDate) override { 
m_xCalendar->SetCurDate(rDate); }
+
+virtual Date get_date() const override { return 
m_xCalendar->GetFirstSelectedDate(); }
+
+virtual ~SalInstanceCalendar() override
+{
+m_xCalendar->SetSelectHdl(Link<::Calendar*, void>());
+m_xCalendar->SetActivateHdl(Link<::Calendar*, void>());
+}
+};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 71308484ed63..4de845997375 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -76,7 +76,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -3294,34 +3293,6 @@ public:
 
 virtual void set_text(const OUString& rText) override { 
m_xProgressBar->SetText(rText); }
 };
-
-class SalInstanceCalendar : public SalInstanceWidget, public virtual 
weld::Calendar
-{
-private:
-VclPtr<::Calendar> m_xCalendar;
-
-DECL_LINK(SelectHdl, ::Calendar*, void);
-DECL_LINK(ActivateHdl, ::Calendar*, void);
-
-public:
-SalInstanceCalendar(::Calendar* pCalendar, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership)
-: SalInstanceWidget(pCalendar, pBuilder, bTakeOwnership)
-, m_xCalendar(pCalendar)
-{
-m_xCalendar->SetSelectHdl(LINK(this, SalInstanceCalendar, SelectHdl));
-m_xCalendar->SetActivateHdl(LINK(this, SalInstanceCalendar, 
ActivateHdl));
-}
-
-virtual void set_date(const Date& rDate) override { 
m_xCalendar->SetCurDate(rDate); }
-
-virtual Date get_date() const override { return 
m_xCalendar->GetFirstSelectedDate(); }
-
-virtual ~SalInstanceCalendar() override
-{
-m_xCalendar->SetSelectHdl(Link<::Calendar*, void>());
-m_xCalendar->SetActivateHdl(Link<::Calendar*, void>());
-}
-};
 }
 
 IMPL_LINK_NOARG(SalInstanceCalendar, SelectHdl, ::Calendar*, void)


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

2023-07-05 Thread Noel Grandin (via logerrit)
 vcl/inc/svimpbox.hxx |2 -
 vcl/source/bitmap/dibtools.cxx   |   45 ---
 vcl/source/treelist/iconviewimpl.cxx |7 +
 vcl/source/treelist/iconviewimpl.hxx |2 -
 vcl/source/treelist/svimpbox.cxx |   11 +++-
 5 files changed, 24 insertions(+), 43 deletions(-)

New commits:
commit 23583706b51f4c1cde8ceb20557fe376691fad88
Author: Noel Grandin 
AuthorDate: Tue Jul 4 20:27:38 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Jul 5 09:33:41 2023 +0200

loplugin:constantparam

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

diff --git a/vcl/inc/svimpbox.hxx b/vcl/inc/svimpbox.hxx
index 949a488ed816..61e103e12b1f 100644
--- a/vcl/inc/svimpbox.hxx
+++ b/vcl/inc/svimpbox.hxx
@@ -250,7 +250,7 @@ public:
 voidResize();
 voidGetFocus();
 voidLoseFocus();
-virtual voidUpdateAll( bool bInvalidateCompleteView );
+virtual voidUpdateAll();
 voidSetEntryHeight();
 voidInvalidateEntry( SvTreeListEntry* );
 voidRecalcFocusRect();
diff --git a/vcl/source/bitmap/dibtools.cxx b/vcl/source/bitmap/dibtools.cxx
index c95c21704dd9..d8fa61362635 100644
--- a/vcl/source/bitmap/dibtools.cxx
+++ b/vcl/source/bitmap/dibtools.cxx
@@ -330,7 +330,7 @@ bool ImplReadDIBPalette(SvStream& rIStm, BitmapPalette& 
rPal, bool bQuad)
 return rIStm.GetError() == ERRCODE_NONE;
 }
 
-BitmapColor SanitizePaletteIndex(sal_uInt8 nIndex, BitmapPalette& rPalette, 
bool bForceToMonoWhileReading)
+BitmapColor SanitizePaletteIndex(sal_uInt8 nIndex, BitmapPalette& rPalette)
 {
 const sal_uInt16 nPaletteEntryCount = rPalette.GetEntryCount();
 if (nPaletteEntryCount && nIndex >= nPaletteEntryCount)
@@ -341,22 +341,9 @@ BitmapColor SanitizePaletteIndex(sal_uInt8 nIndex, 
BitmapPalette& rPalette, bool
 << nPaletteEntryCount);
 nIndex = nSanitizedIndex;
 }
-
-if (nPaletteEntryCount && bForceToMonoWhileReading)
-{
-return 
BitmapColor(static_cast(rPalette[nIndex].GetLuminance() >= 255));
-}
-
 return BitmapColor(nIndex);
 }
 
-BitmapColor SanitizeColor(const BitmapColor , bool 
bForceToMonoWhileReading)
-{
-if (!bForceToMonoWhileReading)
-return rColor;
-return BitmapColor(static_cast(rColor.GetLuminance() >= 255));
-}
-
 bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & rHeader, 
BitmapWriteAccess& rAcc, BitmapPalette& rPalette, bool bRLE4)
 {
 Scanline pRLE = pBuffer;
@@ -394,10 +381,10 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const 
& rHeader, BitmapWriteA
 cTmp = *pRLE++;
 
 if( nX < nWidth )
-rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(cTmp >> 4, rPalette, /*bForceToMonoWhileReading*/false));
+rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(cTmp >> 4, rPalette));
 
 if( nX < nWidth )
-rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(cTmp & 0x0f, rPalette, /*bForceToMonoWhileReading*/false));
+rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(cTmp & 0x0f, rPalette));
 }
 
 if( nRunByte & 1 )
@@ -406,7 +393,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & 
rHeader, BitmapWriteA
 return false;
 
 if( nX < nWidth )
-rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(*pRLE >> 4, rPalette, /*bForceToMonoWhileReading*/false));
+rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(*pRLE >> 4, rPalette));
 
 pRLE++;
 }
@@ -427,7 +414,7 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const & 
rHeader, BitmapWriteA
 return false;
 
 if( nX < nWidth )
-rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(*pRLE, rPalette, /*bForceToMonoWhileReading*/false));
+rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(*pRLE, rPalette));
 
 pRLE++;
 }
@@ -474,18 +461,18 @@ bool ImplDecodeRLE(sal_uInt8* pBuffer, DIBV5Header const 
& rHeader, BitmapWriteA
 
 for (sal_uLong i = 0; i < nRunByte && nX < nWidth; ++i)
 {
-rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(cTmp >> 4, rPalette, /*bForceToMonoWhileReading*/false));
+rAcc.SetPixelOnData(pScanline, nX++, 
SanitizePaletteIndex(cTmp >> 4, rPalette));
 if( nX < 

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

2023-06-22 Thread Michael Weghorn (via logerrit)
 vcl/inc/unx/desktops.hxx  |1 +
 vcl/source/app/IconThemeSelector.cxx  |1 +
 vcl/source/app/salplug.cxx|4 ++--
 vcl/unx/generic/desktopdetect/desktopdetector.cxx |   11 +++
 vcl/unx/kf5/KFSalInstance.cxx |8 +---
 5 files changed, 20 insertions(+), 5 deletions(-)

New commits:
commit 8b0e1f2a914d672182d585d8cb2d4a815e88977e
Author: Michael Weghorn 
AuthorDate: Thu Jun 22 08:40:56 2023 +0200
Commit: Michael Weghorn 
CommitDate: Thu Jun 22 22:15:50 2023 +0200

Detect Plasma 6 desktop

Add detection for Plasma 6, which is currently in development stage.
With the following plasma-workspace commit [1] in place,
KDE_SESSION_VERSION is set to 6, so use that to detect it:

commit 4c2242d7dfafac161baec3ec316af24d7b48ef8b
Author: Michael Weghorn 
Date:   Thu Jun 22 07:47:31 2023 +0200

Set KDE_SESSION_VERSION to 6

Since the master branch is based on Qt6/KF6 and will
become Plasma 6, set KDE_SESSION_VERSION to "6".

This will allow other applications to detect they're
running in a (preview of a) Plasma 6 session and react
accordingly.
(E.g. LibreOffice can use this to choose to
use its upcoming kf6 integration by default instead of the
kf5 one.)

[1] 
https://invent.kde.org/plasma/plasma-workspace/-/commit/4c2242d7dfafac161baec3ec316af24d7b48ef8b

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

diff --git a/vcl/inc/unx/desktops.hxx b/vcl/inc/unx/desktops.hxx
index 0abb6aa71339..2056c2c37928 100644
--- a/vcl/inc/unx/desktops.hxx
+++ b/vcl/inc/unx/desktops.hxx
@@ -33,6 +33,7 @@ enum SAL_DLLPUBLIC_RTTI DesktopType
 DESKTOP_XFCE,
 DESKTOP_MATE,
 DESKTOP_PLASMA5,
+DESKTOP_PLASMA6,
 DESKTOP_LXQT
 }; // keep in sync with desktop_strings[] in salplug.cxx
 
diff --git a/vcl/source/app/IconThemeSelector.cxx 
b/vcl/source/app/IconThemeSelector.cxx
index 6b8dfc0f42c7..15eb4b7768fc 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -70,6 +70,7 @@ IconThemeSelector::GetIconThemeForDesktopEnvironment(const 
OUString& desktopEnvi
 #else
 OUString r;
 if ( desktopEnvironment.equalsIgnoreAsciiCase("plasma5") ||
+ desktopEnvironment.equalsIgnoreAsciiCase("plasma6") ||
  desktopEnvironment.equalsIgnoreAsciiCase("lxqt") ) {
 if (!bPreferDarkIconTheme)
 r = "breeze";
diff --git a/vcl/source/app/salplug.cxx b/vcl/source/app/salplug.cxx
index e51375b94ae5..fee5b7e33e6d 100644
--- a/vcl/source/app/salplug.cxx
+++ b/vcl/source/app/salplug.cxx
@@ -249,7 +249,7 @@ const char* const* autodetect_plugin_list()
   desktop == DESKTOP_XFCE  ||
   desktop == DESKTOP_MATE )
 pList = pStandardFallbackList;
-else if (desktop == DESKTOP_PLASMA5 || desktop == DESKTOP_LXQT)
+else if (desktop == DESKTOP_PLASMA5 || desktop == DESKTOP_PLASMA6 || 
desktop == DESKTOP_LXQT)
 pList = pKDEFallbackList;
 
 return pList;
@@ -426,7 +426,7 @@ const OUString& SalGetDesktopEnvironment()
 // Order to match desktops.hxx' DesktopType
 static const char * const desktop_strings[] = {
 "none", "unknown", "GNOME", "UNITY",
-"XFCE", "MATE", "PLASMA5", "LXQT" };
+"XFCE", "MATE", "PLASMA5", "PLASMA6", "LXQT" };
 static OUString aDesktopEnvironment;
 if( aDesktopEnvironment.isEmpty())
 {
diff --git a/vcl/unx/generic/desktopdetect/desktopdetector.cxx 
b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
index bad134fbdafd..8baeb303feed 100644
--- a/vcl/unx/generic/desktopdetect/desktopdetector.cxx
+++ b/vcl/unx/generic/desktopdetect/desktopdetector.cxx
@@ -117,6 +117,13 @@ static bool is_plasma5_desktop()
 return pFullVersion && pSessionVersion && (0 == strcmp(pSessionVersion, 
"5"));
 }
 
+static bool is_plasma6_desktop()
+{
+static const char* pFullVersion = getenv("KDE_FULL_SESSION");
+static const char* pSessionVersion = getenv("KDE_SESSION_VERSION");
+return pFullVersion && pSessionVersion && (0 == strcmp(pSessionVersion, 
"6"));
+}
+
 extern "C"
 {
 
@@ -132,6 +139,8 @@ DESKTOP_DETECTOR_PUBLIC DesktopType 
get_desktop_environment()
 return DESKTOP_LXQT;
 if (aOver.equalsIgnoreAsciiCase("plasma5") || 
aOver.equalsIgnoreAsciiCase("plasma"))
 return DESKTOP_PLASMA5;
+if (aOver.equalsIgnoreAsciiCase("plasma6"))
+return DESKTOP_PLASMA6;
 if ( aOver.equalsIgnoreAsciiCase( "gnome" ) )
 return DESKTOP_GNOME;
 if ( aOver.equalsIgnoreAsciiCase( "gnome-wayland" ) )
@@ -190,6 +199,8 @@ DESKTOP_DETECTOR_PUBLIC DesktopType 
get_desktop_environment()
 
 if 

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

2023-05-03 Thread Caolán McNamara (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx|2 +-
 vcl/source/gdi/pdfwriter_impl.cxx |   14 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 8b865782d798a33f95ddedad2bde78cb8450708a
Author: Caolán McNamara 
AuthorDate: Wed May 3 09:50:22 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed May 3 21:46:30 2023 +0200

pass the std::vector instead of its data()

Change-Id: I9319896eb4d0e7728a9ded77fa1bfd05e63fbbe3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151326
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 fc9e68afc18b..bad2d387511c 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -937,7 +937,7 @@ i12626
 /* writes a font descriptor and returns its object id (or 0) */
 sal_Int32 emitFontDescriptor(const vcl::font::PhysicalFontFace*, 
FontSubsetInfo const &, sal_Int32 nSubsetID, sal_Int32 nStream);
 /* writes a ToUnicode cmap, returns the corresponding stream object */
-sal_Int32 createToUnicodeCMap( sal_uInt8 const * pEncoding, const sal_Ucs* 
pCodeUnits, const sal_Int32* pCodeUnitsPerGlyph,
+sal_Int32 createToUnicodeCMap( sal_uInt8 const * pEncoding, const 
std::vector& CodeUnits, const sal_Int32* pCodeUnitsPerGlyph,
const sal_Int32* pEncToUnicodeIndex, 
uint32_t nGlyphs );
 
 /* get resource dict object number */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 7d51e3d916d1..d146e3ae85dc 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2556,7 +2556,7 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
 nFontDescriptor = emitFontDescriptor(pFace, aSubsetInfo, 
rSubset.m_nFontID, 0);
 
 if (nToUnicodeStream)
-nToUnicodeStream = createToUnicodeCMap(pEncoding, 
aCodeUnits.data(), pCodeUnitsPerGlyph,
+nToUnicodeStream = createToUnicodeCMap(pEncoding, aCodeUnits, 
pCodeUnitsPerGlyph,
pEncToUnicodeIndex, 
nGlyphs);
 
 // write font object
@@ -2865,14 +2865,14 @@ static void appendSubsetName( int nSubsetID, 
std::u16string_view rPSName, OStrin
 }
 
 sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 const * pEncoding,
-  const sal_Ucs* pCodeUnits,
+  const std::vector& 
rCodeUnits,
   const sal_Int32* 
pCodeUnitsPerGlyph,
   const sal_Int32* 
pEncToUnicodeIndex,
   uint32_t nGlyphs )
 {
 int nMapped = 0;
 for (auto n = 0u; n < nGlyphs; ++n)
-if (pCodeUnitsPerGlyph[n] && pCodeUnits[pEncToUnicodeIndex[n]])
+if (pCodeUnitsPerGlyph[n] && rCodeUnits[pEncToUnicodeIndex[n]])
 nMapped++;
 
 if( nMapped == 0 )
@@ -2900,7 +2900,7 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 
const * pEncoding,
 int nCount = 0;
 for (auto n = 0u; n < nGlyphs; ++n)
 {
-if (pCodeUnitsPerGlyph[n] && pCodeUnits[pEncToUnicodeIndex[n]])
+if (pCodeUnitsPerGlyph[n] && rCodeUnits[pEncToUnicodeIndex[n]])
 {
 if( (nCount % 100) == 0 )
 {
@@ -2916,8 +2916,8 @@ sal_Int32 PDFWriterImpl::createToUnicodeCMap( sal_uInt8 
const * pEncoding,
 sal_Int32 nIndex = pEncToUnicodeIndex[n];
 for( sal_Int32 j = 0; j < pCodeUnitsPerGlyph[n]; j++ )
 {
-appendHex( static_cast(pCodeUnits[nIndex + j] / 
256), aContents );
-appendHex( static_cast(pCodeUnits[nIndex + j] & 
255), aContents );
+appendHex( static_cast(rCodeUnits[nIndex + j] / 
256), aContents );
+appendHex( static_cast(rCodeUnits[nIndex + j] & 
255), aContents );
 }
 aContents.append( ">\n" );
 nCount++;
@@ -3184,7 +3184,7 @@ bool PDFWriterImpl::emitFonts()
 sal_Int32 nFontDescriptor = emitFontDescriptor( subset.first, 
aSubsetInfo, s_subset.m_nFontID, nFontStream );
 
 if( nToUnicodeStream )
-nToUnicodeStream = createToUnicodeCMap( pEncoding, 
aCodeUnits.data(), pCodeUnitsPerGlyph, pEncToUnicodeIndex, nGlyphs );
+nToUnicodeStream = createToUnicodeCMap( pEncoding, 
aCodeUnits, pCodeUnitsPerGlyph, pEncToUnicodeIndex, nGlyphs );
 
 sal_Int32 nFontObject = createObject();
 if ( !updateObject( nFontObject ) ) return false;


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

2023-04-19 Thread Caolán McNamara (via logerrit)
 vcl/inc/salvtables.hxx|2 ++
 vcl/source/app/salvtables.cxx |9 +++--
 2 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 3ec73488e447a693a14a773a7fb96938036c0324
Author: Caolán McNamara 
AuthorDate: Wed Apr 19 16:55:34 2023 +0100
Commit: Caolán McNamara 
CommitDate: Wed Apr 19 21:55:13 2023 +0200

Resolves: tdf#154912 make double-click to expand rows the same as arrow 
expand

the arrow case does the necessary removal of the "dummy" entry which is
necessary to get the treeview to indicate it has children, while the
double click case skipped that step, so rearrange so both behave the
same.

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

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index cbb9fce51eee..096675cf9a49 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1548,6 +1548,8 @@ protected:
 DECL_LINK(CustomRenderHdl, svtree_render_args, void);
 DECL_LINK(CustomMeasureHdl, svtree_measure_args, Size);
 
+bool ExpandRow(const SalInstanceTreeIter& rIter);
+
 // Each row has a cell for the expander image, (and an optional cell for a
 // checkbutton if enable_toggle_buttons has been called) which precede
 // index 0
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 0b818bf2f5f4..faad9efb1e3a 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -4815,7 +4815,7 @@ void SalInstanceTreeView::expand_row(const 
weld::TreeIter& rIter)
 {
 assert(m_xTreeView->IsUpdateMode() && "don't expand when frozen");
 const SalInstanceTreeIter& rVclIter = static_cast(rIter);
-if (!m_xTreeView->IsExpanded(rVclIter.iter) && signal_expanding(rIter))
+if (!m_xTreeView->IsExpanded(rVclIter.iter) && ExpandRow(rVclIter))
 m_xTreeView->Expand(rVclIter.iter);
 }
 
@@ -5329,7 +5329,12 @@ IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, 
SvTreeListBox*, bool)
 }
 
 // expanding
+return ExpandRow(aIter);
+}
 
+bool SalInstanceTreeView::ExpandRow(const SalInstanceTreeIter& rIter)
+{
+SvTreeListEntry* pEntry = rIter.iter;
 // if there's a preexisting placeholder child, required to make this
 // potentially expandable in the first place, now we remove it
 SvTreeListEntry* pPlaceHolder = GetPlaceHolderChild(pEntry);
@@ -5339,7 +5344,7 @@ IMPL_LINK_NOARG(SalInstanceTreeView, ExpandingHdl, 
SvTreeListBox*, bool)
 m_xTreeView->RemoveEntry(pPlaceHolder);
 }
 
-bool bRet = signal_expanding(aIter);
+bool bRet = signal_expanding(rIter);
 
 if (pPlaceHolder)
 {


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

2023-04-12 Thread Noel Grandin (via logerrit)
 vcl/inc/win/saldata.hxx  |3 ---
 vcl/source/app/scheduler.cxx |1 -
 vcl/win/app/salinst.cxx  |1 -
 vcl/win/window/salframe.cxx  |   19 ---
 4 files changed, 24 deletions(-)

New commits:
commit 5944f8dc9a20c5c1cd450cd457bcc973f649b7ca
Author: Noel Grandin 
AuthorDate: Wed Apr 12 12:42:50 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Apr 12 16:01:26 2023 +0200

mpMouseLeaveTimer has been dead

ever since it was added in
commit 8229967979d96bd01e63e2954b7af35a57d9e08c
Date:   Thu Sep 20 15:23:39 2007 +
INTEGRATION: CWS os2port01 (1.2.2); FILE ADDED
2006/11/29 14:34:20 ydario 1.2.2.1: Initial OS/2 import.

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

diff --git a/vcl/inc/win/saldata.hxx b/vcl/inc/win/saldata.hxx
index 2d20903d6157..c391086b30a1 100644
--- a/vcl/inc/win/saldata.hxx
+++ b/vcl/inc/win/saldata.hxx
@@ -91,7 +91,6 @@ public:
 std::unique_ptr mpDitherHigh;   // Dither mapping table
 HHOOK   mhSalObjMsgHook;// hook to get interesting 
msg for SalObject
 HWNDmhWantLeaveMsg; // window handle, that 
want a MOUSELEAVE message
-AutoTimer*  mpMouseLeaveTimer;  // Timer for MouseLeave 
Test
 WinSalInstance* mpInstance;
 WinSalFrame*mpFirstFrame;   // pointer of first frame
 WinSalObject*   mpFirstObject;  // pointer of first object 
window
@@ -201,8 +200,6 @@ int ImplSalWICompareAscii( const wchar_t* pStr1, const 
char* pStr2 );
 #define SAL_OBJECT_CHILDCLASSNAMEW  L"SALOBJECTCHILD"
 #define SAL_COM_CLASSNAMEW  L"SALCOMWND"
 
-#define SAL_MOUSELEAVE_TIMEOUT  300
-
 // wParam == bWait; lParam == 0
 #define SAL_MSG_THREADYIELD (WM_USER+111)
 // wParam == 0; lParam == nMS
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 7afdfd0846e6..098242fe6c70 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -160,7 +160,6 @@ next_priority:
 || !strcmp( pTask->GetDebugName(), "desktop::Desktop 
m_firstRunTimer" )
 || !strcmp( pTask->GetDebugName(), 
"DrawWorkStartupTimer" )
 || !strcmp( pTask->GetDebugName(), 
"editeng::ImpEditEngine aOnlineSpellTimer" )
-|| !strcmp( pTask->GetDebugName(), "ImplHandleMouseMsg 
SalData::mpMouseLeaveTimer" )
 || !strcmp( pTask->GetDebugName(), "sc ScModule 
IdleTimer" )
 || !strcmp( pTask->GetDebugName(), 
"sd::CacheConfiguration maReleaseTimer" )
 || !strcmp( pTask->GetDebugName(), 
"svtools::GraphicCache maReleaseTimer" )
diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx
index 3afb38c04648..3e2cc7a04754 100644
--- a/vcl/win/app/salinst.cxx
+++ b/vcl/win/app/salinst.cxx
@@ -256,7 +256,6 @@ SalData::SalData()
 mpDitherHigh = nullptr; // Dither mapping table
 mhSalObjMsgHook = nullptr;  // hook to get interesting msg for SalObject
 mhWantLeaveMsg = nullptr;   // window handle, that want a MOUSELEAVE 
message
-mpMouseLeaveTimer = nullptr; // Timer for MouseLeave Test
 mpInstance = nullptr;  // pointer of first instance
 mpFirstFrame = nullptr; // pointer of first frame
 mpFirstObject = nullptr;// pointer of first object window
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index 7b88c3ab8a67..48a251c38e86 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -984,11 +984,6 @@ WinSalFrame::~WinSalFrame()
 if ( pSalData->mhWantLeaveMsg == mhWnd )
 {
 pSalData->mhWantLeaveMsg = nullptr;
-if ( pSalData->mpMouseLeaveTimer )
-{
-delete pSalData->mpMouseLeaveTimer;
-pSalData->mpMouseLeaveTimer = nullptr;
-}
 }
 
 // remove windows properties
@@ -3185,15 +3180,6 @@ static bool ImplHandleMouseMsg( HWND hWnd, UINT nMsg,
 SendMessageW( pSalData->mhWantLeaveMsg, SAL_MSG_MOUSELEAVE, 0, 
GetMessagePos() );
 
 pSalData->mhWantLeaveMsg = hWnd;
-// Start MouseLeave-Timer
-if ( !pSalData->mpMouseLeaveTimer )
-{
-pSalData->mpMouseLeaveTimer = new AutoTimer( 
"ImplHandleMouseMsg SalData::mpMouseLeaveTimer" );
-pSalData->mpMouseLeaveTimer->SetTimeout( 
SAL_MOUSELEAVE_TIMEOUT );
-pSalData->mpMouseLeaveTimer->Start();
-// We don't need to set a timeout handler, because we test
-// for mouseleave in the timeout callback
-}
 aMouseEvt.mnButton = 0;
 nEvent = SalEvent::MouseMove;
 }
@@ -3226,11 +3212,6 @@ 

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

2023-04-12 Thread Noel Grandin (via logerrit)
 vcl/inc/svdata.hxx|2 +-
 vcl/source/window/window2.cxx |7 ++-
 2 files changed, 3 insertions(+), 6 deletions(-)

New commits:
commit 6629bdff20602935f042838ede5e8986a120b5f0
Author: Noel Grandin 
AuthorDate: Wed Apr 12 12:48:30 2023 +0200
Commit: Noel Grandin 
CommitDate: Wed Apr 12 13:57:13 2023 +0200

use more unique_ptr in ImplSVWinData

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

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 0a34fb2f4234..6d1d8adac015 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -258,7 +258,7 @@ struct ImplSVWinData
 std::vector> mpExecuteDialogs;   ///< Stack of 
dialogs that are Execute()'d - the last one is the top most one.
 VclPtr mpExtTextInputWin;  // Window, which 
is in ExtTextInput
 VclPtr mpTrackWin; // window, that is 
in tracking mode
-AutoTimer*  mpTrackTimer = nullptr; // tracking timer
+std::unique_ptr mpTrackTimer;// tracking timer
 std::vector  maMsgBoxImgList;// ImageList for 
MessageBox
 VclPtr mpAutoScrollWin;// window, that is 
in AutoScrollMode mode
 VclPtr mpLastWheelWindow;  // window, that 
last received a mouse wheel event
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 6a6f20dab5a7..46d8bd7f8881 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -268,7 +268,7 @@ void Window::StartTracking( StartTrackingFlags nFlags )
 if ( !mpWindowImpl->mbUseFrameData &&
  (nFlags & (StartTrackingFlags::ScrollRepeat | 
StartTrackingFlags::ButtonRepeat)) )
 {
-pSVData->mpWinData->mpTrackTimer = new AutoTimer("vcl::Window 
pSVData->mpWinData->mpTrackTimer");
+pSVData->mpWinData->mpTrackTimer.reset(new AutoTimer("vcl::Window 
pSVData->mpWinData->mpTrackTimer"));
 
 if ( nFlags & StartTrackingFlags::ScrollRepeat )
 pSVData->mpWinData->mpTrackTimer->SetTimeout( 
MouseSettings::GetScrollRepeat() );
@@ -304,10 +304,7 @@ void Window::EndTracking( TrackingEventFlags nFlags )
 return;
 
 if ( !mpWindowImpl->mbUseFrameData && pSVData->mpWinData->mpTrackTimer )
-{
-delete pSVData->mpWinData->mpTrackTimer;
-pSVData->mpWinData->mpTrackTimer = nullptr;
-}
+pSVData->mpWinData->mpTrackTimer.reset();
 
 mpWindowImpl->mpFrameData->mpTrackWin = pSVData->mpWinData->mpTrackWin = 
nullptr;
 pSVData->mpWinData->mnTrackFlags  = StartTrackingFlags::NONE;


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

2023-03-27 Thread Michael Stahl (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx  |2 ++
 vcl/source/gdi/pdfextoutdevdata.cxx |   14 +-
 vcl/source/gdi/pdfwriter_impl.cxx   |   19 +--
 3 files changed, 32 insertions(+), 3 deletions(-)

New commits:
commit d9031bd83ffe718a80da9ecbdbeb485e35fbabee
Author: Michael Stahl 
AuthorDate: Fri Mar 24 20:29:06 2023 +0100
Commit: Michael Stahl 
CommitDate: Mon Mar 27 09:17:13 2023 +

tdf#152234 vcl: PDF/UA export: StructElem<->Annot for form controls

veraPDF complains:

  Specification: ISO 14289-1:2014, Clause: 7.18.4, Test number: 1
  A Widget annotation shall be nested within a Form tag per
  ISO 32000-1:2008, 14.8.4.5, Table 340.

This is a little simpler than for Link and Screen annotations, because
the form control StructElem and Annot are exported at the same time
from VclMetafileProcessor2D::processControlPrimitive2D().

So PDFExtOutDevData can just make up the mapping on playback.

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index bb48f7c08e9f..e30c8968e59a 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -527,6 +527,8 @@ struct PDFWidget : public PDFAnnotation
 std::vector  m_aSelectedEntries;
 typedef std::unordered_map PDFAppearanceStreams;
 std::unordered_map m_aAppearances;
+sal_Int32 m_nStructParent = -1;
+
 PDFWidget()
 : m_eType( PDFWriter::PushButton ),
   m_nTextStyle( DrawTextFlags::NONE ),
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx 
b/vcl/source/gdi/pdfextoutdevdata.cxx
index 5dfcc5b19d6e..21f340fc2107 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -97,6 +97,10 @@ struct GlobalSyncData
 sal_Int32 GetMappedId();
 sal_Int32 GetMappedStructId( sal_Int32 );
 
+/** the way this appears to work: (only) everything that increments mCurId
+at recording time must put an item into mParaIds at playback time,
+so that the mCurId becomes the eventual index into mParaIds.
+ */
 sal_Int32   mCurId;
 std::vector< sal_Int32 >mParaIds;
 std::vector< sal_Int32 >mStructIdMap;
@@ -410,7 +414,14 @@ bool PageSyncData::PlaySyncPageAct( PDFWriter& rWriter, 
sal_uInt32& rCurGDIMtfAc
 std::shared_ptr< PDFWriter::AnyWidget > pControl( 
mControls.front() );
 SAL_WARN_IF( !pControl, "vcl", "PageSyncData::PlaySyncPageAct: 
invalid widget!" );
 if ( pControl )
-rWriter.CreateControl( *pControl );
+{
+sal_Int32 const n = rWriter.CreateControl(*pControl);
+// resolve AnnotIds structural attribute
+::std::vector const annotIds{ 
sal_Int32(mpGlobalData->mParaIds.size()) };
+rWriter.SetStructureAnnotIds(annotIds);
+rWriter.SetLinkPropertyID(n, 
sal_Int32(mpGlobalData->mParaIds.size()));
+mpGlobalData->mParaIds.push_back(n);
+}
 mControls.pop_front();
 }
 break;
@@ -849,6 +860,7 @@ void PDFExtOutDevData::CreateControl( const 
PDFWriter::AnyWidget& rControlType )
 
 std::shared_ptr< PDFWriter::AnyWidget > pClone( rControlType.Clone() );
 mpPageSyncData->mControls.push_back( pClone );
+mpGlobalSyncData->mCurId++;
 }
 
 void PDFExtOutDevData::BeginGroup()
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 52bd77e3ebc4..b2ba4d69555e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2242,8 +2242,16 @@ sal_Int32 PDFWriterImpl::emitStructure( 
PDFStructureElement& rEle )
 auto const it(m_aLinkPropertyMap.find(id));
 assert(it != m_aLinkPropertyMap.end());
 
-assert(0 <= it->second && o3tl::make_unsigned(it->second) < 
m_aScreens.size());
-AppendAnnotKid(rEle, m_aScreens[it->second]);
+if (rEle.m_eType == PDFWriter::Form)
+{
+assert(0 <= it->second && o3tl::make_unsigned(it->second) < 
m_aWidgets.size());
+AppendAnnotKid(rEle, m_aWidgets[it->second]);
+}
+else
+{
+assert(0 <= it->second && o3tl::make_unsigned(it->second) < 
m_aScreens.size());
+AppendAnnotKid(rEle, m_aScreens[it->second]);
+}
 }
 }
 if( ! rEle.m_aKids.empty() )
@@ -4677,6 +4685,13 @@ bool PDFWriterImpl::emitWidgetAnnotations()
 iRectMargin = 1;
 }
 
+if (0 < rWidget.m_nStructParent)
+{
+aLine.append("/StructParent ");
+

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

2023-03-13 Thread Michael Stahl (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx|5 ++
 vcl/source/gdi/pdfwriter_impl.cxx |   80 --
 2 files changed, 73 insertions(+), 12 deletions(-)

New commits:
commit 4250f334de729360567ec9bd88aed06fbd823dc4
Author: Michael Stahl 
AuthorDate: Fri Mar 10 15:14:28 2023 +0100
Commit: Michael Stahl 
CommitDate: Mon Mar 13 10:31:26 2023 +

tdf#152218 vcl: PDF/UA export: produce ID for footnote/endnote

There is this mysterious requirement:

  7.9 Notes and references
  Footnotes and endnotes shall be tagged with a Note tag. Each note
  tag shall have a unique entry in the ID key as described in ISO
  32000-1:2008, 14.7.2, Table 323.

Then also an IDTree is required; PDF 1.7, 10.6.1 Structure Hierarchy:

  (Required if any structure elements have element identifiers)

The point of this is entirely unclear to me, it looks like neither
poppler nor pdfium even have code to read the IDTree, and structure
elements already always have an object id by which they can be
referenced, so why add a second ID?

Alas veraPDF complains if it is missing:

  Specification: ISO 14289-1:2014, Clause: 7.9, Test number: 1
  Note tag shall have ID entry

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 4e10204433cb..a16d57404207 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -760,6 +761,8 @@ private:
 /* role map of struct tree root */
 std::unordered_map< OString, OString >
 m_aRoleMap;
+/* structure elements (object ids) that should have ID */
+std::unordered_set m_StructElemObjsWithID;
 
 /* contains all widgets used in the PDF
  */
@@ -993,6 +996,8 @@ i12626
 sal_Int32 emitStructure( PDFStructureElement& rEle );
 // writes structure parent tree
 sal_Int32 emitStructParentTree( sal_Int32 nTreeObject );
+// writes structure IDTree
+sal_Int32 emitStructIDTree(sal_Int32 nTreeObject);
 // writes page tree and catalog
 bool emitCatalog();
 // writes signature dictionary object
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index c5b873565611..9a78d6908a58 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -111,6 +111,18 @@ constexpr sal_Int32 pointToPixel(double pt)
 return sal_Int32(pt * fDivisor);
 }
 
+void appendObjectID(sal_Int32 nObjectID, OStringBuffer & aLine)
+{
+aLine.append(nObjectID);
+aLine.append(" 0 obj\n");
+}
+
+void appendObjectReference(sal_Int32 nObjectID, OStringBuffer & aLine)
+{
+aLine.append(nObjectID);
+aLine.append(" 0 R ");
+}
+
 void appendHex(sal_Int8 nInt, OStringBuffer& rBuffer)
 {
 static const char pHexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7',
@@ -1801,6 +1813,43 @@ sal_Int32 PDFWriterImpl::emitStructParentTree( sal_Int32 
nObject )
 return nObject;
 }
 
+// every structure element already has a unique object id - just use it for ID
+static OString GenerateID(sal_Int32 const nObjectId)
+{
+return "id" + OString::number(nObjectId);
+}
+
+sal_Int32 PDFWriterImpl::emitStructIDTree(sal_Int32 const nObject)
+{
+// loosely following PDF 1.7, 10.6.5 Example of Logical Structure, Example 
10.15
+if (nObject < 0)
+{
+return nObject;
+}
+// the name tree entries must be sorted lexicographically.
+std::map ids;
+for (auto n : m_StructElemObjsWithID)
+{
+ids.emplace(GenerateID(n), n);
+}
+OStringBuffer buf;
+appendObjectID(nObject, buf);
+buf.append("<>\nendobj\n\n");
+
+CHECK_RETURN( updateObject(nObject) );
+CHECK_RETURN( writeBuffer(buf.getStr(), buf.getLength()) );
+
+return nObject;
+}
+
 const char* PDFWriterImpl::getAttributeTag( PDFWriter::StructAttribute eAttr )
 {
 static std::map< PDFWriter::StructAttribute, const char* > 
aAttributeStrings;
@@ -2084,6 +2133,7 @@ sal_Int32 PDFWriterImpl::emitStructure( 
PDFStructureElement& rEle )
 aLine.append( " 0 obj\n"
   "<>\n" );
 }
+if (!m_StructElemObjsWithID.empty())
+{
+nIDTree = createObject();
+aLine.append("/IDTree ");
+appendObjectReference(nIDTree, aLine);
+aLine.append("\n");
+}
 }
 else
 {
@@ -2114,6 +2171,11 @@ sal_Int32 PDFWriterImpl::emitStructure( 
PDFStructureElement& rEle )
 aLine.append( rEle.m_aAlias );
 else
 aLine.append( getStructureTag( rEle.m_eType ) );
+if (m_StructElemObjsWithID.find(rEle.m_nObject) != 

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

2023-03-06 Thread Noel Grandin (via logerrit)
 vcl/inc/svdata.hxx|7 ---
 vcl/source/app/svmain.cxx |4 ++--
 vcl/source/treelist/transfer2.cxx |   13 +
 vcl/source/window/layout.cxx  |   10 +-
 4 files changed, 16 insertions(+), 18 deletions(-)

New commits:
commit 6c2542306bcc7caaab947664f252265058964fc2
Author: Noel Grandin 
AuthorDate: Mon Mar 6 15:03:18 2023 +0200
Commit: Noel Grandin 
CommitDate: Mon Mar 6 15:51:09 2023 +

no need to allocate these separately

they are all one or two words in size

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

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 06d0aeb9b9af..c514df09422c 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -42,6 +43,7 @@
 #include "displayconnectiondispatch.hxx"
 
 #include 
+#include 
 #include 
 #include 
 #include "ControlCacheKey.hxx"
@@ -72,7 +74,6 @@ class Timer;
 class AutoTimer;
 class Idle;
 class Help;
-class Image;
 class PopupMenu;
 class Application;
 class OutputDevice;
@@ -278,8 +279,8 @@ struct ImplSVCtrlData
 {
 std::vector  maCheckImgList; // ImageList for 
CheckBoxes
 std::vector  maRadioImgList; // ImageList for 
RadioButtons
-std::unique_ptr  mpDisclosurePlus;
-std::unique_ptr  mpDisclosureMinus;
+std::optionalmoDisclosurePlus;
+std::optionalmoDisclosureMinus;
 ImplTBDragMgr*  mpTBDragMgr = nullptr;  // DragMgr for 
ToolBox
 sal_uInt16  mnCheckStyle = 0;   // CheckBox-Style 
for ImageList-Update
 sal_uInt16  mnRadioStyle = 0;   // Radio-Style for 
ImageList-Update
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 7c5505f364cb..571be29579bc 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -486,8 +486,8 @@ void DeInitVCL()
 pSVData->mpWinData->maMsgBoxImgList.clear();
 pSVData->maCtrlData.maCheckImgList.clear();
 pSVData->maCtrlData.maRadioImgList.clear();
-pSVData->maCtrlData.mpDisclosurePlus.reset();
-pSVData->maCtrlData.mpDisclosureMinus.reset();
+pSVData->maCtrlData.moDisclosurePlus.reset();
+pSVData->maCtrlData.moDisclosureMinus.reset();
 pSVData->mpDefaultWin.disposeAndClear();
 
 #if defined _WIN32
diff --git a/vcl/source/treelist/transfer2.cxx 
b/vcl/source/treelist/transfer2.cxx
index 05183b9c0485..1c53be66f1c6 100644
--- a/vcl/source/treelist/transfer2.cxx
+++ b/vcl/source/treelist/transfer2.cxx
@@ -318,7 +318,7 @@ struct TransferDataContainer_Impl
 {
 std::vector< TDataCntnrEntry_Impl > aFmtList;
 Link aFinishedLnk;
-std::unique_ptr pBookmk;
+std::optional moBookmk;
 
 TransferDataContainer_Impl()
 {
@@ -368,8 +368,8 @@ bool TransferDataContainer::GetData(
  case SotClipboardFormatId::FILECONTENT:
  case SotClipboardFormatId::FILEGRPDESCRIPTOR:
  case SotClipboardFormatId::UNIFORMRESOURCELOCATOR:
-if( pImpl->pBookmk )
-bFnd = SetINetBookmark( *pImpl->pBookmk, rFlavor );
+if( pImpl->moBookmk )
+bFnd = SetINetBookmark( *pImpl->moBookmk, rFlavor );
 break;
 
 default: break;
@@ -381,10 +381,7 @@ bool TransferDataContainer::GetData(
 
 void TransferDataContainer::CopyINetBookmark( const INetBookmark& rBkmk )
 {
-if( !pImpl->pBookmk )
-pImpl->pBookmk.reset( new INetBookmark( rBkmk ) );
-else
-*pImpl->pBookmk = rBkmk;
+pImpl->moBookmk = rBkmk;
 
 AddFormat( SotClipboardFormatId::STRING );
 AddFormat( SotClipboardFormatId::SOLK );
@@ -441,7 +438,7 @@ void TransferDataContainer::CopyString( const OUString& 
rStr )
 bool TransferDataContainer::HasAnyData() const
 {
 return !pImpl->aFmtList.empty() ||
-nullptr != pImpl->pBookmk;
+pImpl->moBookmk.has_value();
 }
 
 
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index a650a0bf92ab..881d3e6ed465 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1594,13 +1594,13 @@ class DisclosureButton final : public CheckBox
 return;
 
 ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
-if (!rCtrlData.mpDisclosurePlus)
-rCtrlData.mpDisclosurePlus.reset(new Image(StockImage::Yes, 
SV_DISCLOSURE_PLUS));
-if (!rCtrlData.mpDisclosureMinus)
-rCtrlData.mpDisclosureMinus.reset(new Image(StockImage::Yes, 
SV_DISCLOSURE_MINUS));
+if (!rCtrlData.moDisclosurePlus)
+rCtrlData.moDisclosurePlus.emplace(StockImage::Yes, 
SV_DISCLOSURE_PLUS);
+if (!rCtrlData.moDisclosureMinus)
+rCtrlData.moDisclosureMinus.emplace(StockImage::Yes, 
SV_DISCLOSURE_MINUS);
 

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

2023-03-03 Thread Szymon Kłos (via logerrit)
 vcl/inc/salvtables.hxx|   42 ++
 vcl/source/app/salvtables.cxx |  292 +++---
 2 files changed, 178 insertions(+), 156 deletions(-)

New commits:
commit e55096a07a450782c4ab919b7ba60852841004c7
Author: Szymon Kłos 
AuthorDate: Wed Mar 1 16:51:02 2023 +0100
Commit: Szymon Kłos 
CommitDate: Fri Mar 3 13:19:59 2023 +

Move SalInstanceAssistant declaration to header file

Change-Id: I3407893c878fd37fe0968c2990c92d5d16213ed3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148107
Tested-by: Jenkins
Reviewed-by: Szymon Kłos 

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 00bb670ffe54..25382e53a546 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -30,6 +30,11 @@
 #include "listbox.hxx"
 #include "messagedialog.hxx"
 
+namespace vcl
+{
+class RoadmapWizard;
+};
+
 class SalInstanceBuilder : public weld::Builder
 {
 protected:
@@ -541,6 +546,43 @@ public:
 virtual weld::Container* weld_content_area() override;
 };
 
+class SalInstanceAssistant : public SalInstanceDialog, public virtual 
weld::Assistant
+{
+private:
+VclPtr m_xWizard;
+std::vector> m_aPages;
+std::vector> m_aAddedPages;
+std::vector m_aIds;
+std::vector> m_aAddedGrids;
+Idle m_aUpdateRoadmapIdle;
+
+int find_page(std::string_view rIdent) const;
+int find_id(int nId) const;
+
+DECL_LINK(OnRoadmapItemSelected, LinkParamNone*, void);
+DECL_LINK(UpdateRoadmap_Hdl, Timer*, void);
+
+public:
+SalInstanceAssistant(vcl::RoadmapWizard* pDialog, SalInstanceBuilder* 
pBuilder,
+ bool bTakeOwnership);
+virtual int get_current_page() const override;
+virtual int get_n_pages() const override;
+virtual OString get_page_ident(int nPage) const override;
+virtual OString get_current_page_ident() const override;
+virtual void set_current_page(int nPage) override;
+virtual void set_current_page(const OString& rIdent) override;
+virtual void set_page_index(const OString& rIdent, int nNewIndex) override;
+virtual weld::Container* append_page(const OString& rIdent) override;
+virtual OUString get_page_title(const OString& rIdent) const override;
+virtual void set_page_title(const OString& rIdent, const OUString& rTitle) 
override;
+virtual void set_page_sensitive(const OString& rIdent, bool bSensitive) 
override;
+virtual void set_page_side_help_id(const OString& rHelpId) override;
+virtual void set_page_side_image(const OUString& rImage) override;
+weld::Button* weld_widget_for_response(int nResponse) override;
+
+virtual ~SalInstanceAssistant() override;
+};
+
 class WeldTextFilter final : public TextFilter
 {
 private:
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 36ab4f9ec4bd..1717a3bc41ea 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -1982,203 +1982,183 @@ weld::Container* 
SalInstanceMessageDialog::weld_message_area()
 return new SalInstanceContainer(m_xMessageDialog->get_message_area(), 
m_pBuilder, false);
 }
 
-namespace
-{
-class SalInstanceAssistant : public SalInstanceDialog, public virtual 
weld::Assistant
+int SalInstanceAssistant::find_page(std::string_view rIdent) const
 {
-private:
-VclPtr m_xWizard;
-std::vector> m_aPages;
-std::vector> m_aAddedPages;
-std::vector m_aIds;
-std::vector> m_aAddedGrids;
-Idle m_aUpdateRoadmapIdle;
-
-int find_page(std::string_view rIdent) const
+for (size_t i = 0; i < m_aAddedPages.size(); ++i)
 {
-for (size_t i = 0; i < m_aAddedPages.size(); ++i)
-{
-if (m_aAddedPages[i]->get_id().toUtf8() == rIdent)
-return i;
-}
-return -1;
+if (m_aAddedPages[i]->get_id().toUtf8() == rIdent)
+return i;
 }
+return -1;
+}
 
-int find_id(int nId) const
+int SalInstanceAssistant::find_id(int nId) const
+{
+for (size_t i = 0; i < m_aIds.size(); ++i)
 {
-for (size_t i = 0; i < m_aIds.size(); ++i)
-{
-if (nId == m_aIds[i])
-return i;
-}
-return -1;
+if (nId == m_aIds[i])
+return i;
 }
+return -1;
+}
 
-DECL_LINK(OnRoadmapItemSelected, LinkParamNone*, void);
-DECL_LINK(UpdateRoadmap_Hdl, Timer*, void);
+SalInstanceAssistant::SalInstanceAssistant(vcl::RoadmapWizard* pDialog,
+   SalInstanceBuilder* pBuilder, bool 
bTakeOwnership)
+: SalInstanceDialog(pDialog, pBuilder, bTakeOwnership)
+, m_xWizard(pDialog)
+, m_aUpdateRoadmapIdle("SalInstanceAssistant m_aUpdateRoadmapIdle")
+{
+m_xWizard->SetItemSelectHdl(LINK(this, SalInstanceAssistant, 
OnRoadmapItemSelected));
 
-public:
-SalInstanceAssistant(vcl::RoadmapWizard* pDialog, SalInstanceBuilder* 
pBuilder,
- bool bTakeOwnership)
-: 

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

2023-02-09 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|2 +-
 vcl/source/font/LogicalFontInstance.cxx |8 
 vcl/source/gdi/pdfwriter_impl.cxx   |6 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

New commits:
commit 182e85aef036f30e8c6f32de5516a0286aaf0320
Author: Khaled Hosny 
AuthorDate: Wed Feb 8 21:57:07 2023 +0200
Commit: خالد حسني 
CommitDate: Thu Feb 9 18:22:41 2023 +

vcl: GetGlyphOutlineUntransformed() always returns true now

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index c9e837d540f1..a5e8a6d3249e 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -103,7 +103,7 @@ public: // TODO: make data members private
 
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
-bool GetGlyphOutlineUntransformed(sal_GlyphId, basegfx::B2DPolyPolygon&) 
const;
+basegfx::B2DPolyPolygon GetGlyphOutlineUntransformed(sal_GlyphId) const;
 
 sal_GlyphId GetGlyphIndex(uint32_t, uint32_t = 0) const;
 
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 58b291d04bdf..385fe5ccd624 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -289,8 +289,7 @@ void close_path_func(hb_draw_funcs_t*, void* pDrawData, 
hb_draw_state_t*, void*
 }
 }
 
-bool LogicalFontInstance::GetGlyphOutlineUntransformed(sal_GlyphId nGlyph,
-   
basegfx::B2DPolyPolygon& rPolyPoly) const
+basegfx::B2DPolyPolygon 
LogicalFontInstance::GetGlyphOutlineUntransformed(sal_GlyphId nGlyph) const
 {
 if (!m_pHbDrawFuncs)
 {
@@ -306,8 +305,9 @@ bool 
LogicalFontInstance::GetGlyphOutlineUntransformed(sal_GlyphId nGlyph,
 hb_draw_funcs_set_close_path_func(m_pHbDrawFuncs, close_path_func, 
pUserData, nullptr);
 }
 
-hb_font_get_glyph_shape(GetHbFontUntransformed(), nGlyph, m_pHbDrawFuncs, 
);
-return true;
+basegfx::B2DPolyPolygon aPolyPoly;
+hb_font_get_glyph_shape(GetHbFontUntransformed(), nGlyph, m_pHbDrawFuncs, 
);
+return aPolyPoly;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index e4807abfaae8..8b1a8b6287da 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6257,11 +6257,7 @@ void PDFWriterImpl::registerGlyph(const sal_GlyphId 
nFontGlyphId,
 else if (!aBitmap.empty())
 rNewGlyphEmit.setColorBitmap(aBitmap, aRect);
 else if (bVariations)
-{
-basegfx::B2DPolyPolygon aOutline;
-if (pFont->GetGlyphOutlineUntransformed(nFontGlyphId, 
aOutline))
-rNewGlyphEmit.setOutline(aOutline);
-}
+
rNewGlyphEmit.setOutline(pFont->GetGlyphOutlineUntransformed(nFontGlyphId));
 
 // add new glyph to font mapping
 Glyph& rNewGlyph = rSubset.m_aMapping[nFontGlyphId];


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

2023-01-20 Thread Stephan Bergmann (via logerrit)
 vcl/inc/graphic/UnoGraphic.hxx  |1 -
 vcl/inc/graphic/UnoGraphicDescriptor.hxx|3 +--
 vcl/source/graphic/UnoGraphic.cxx   |   14 --
 vcl/source/graphic/UnoGraphicDescriptor.cxx |   14 --
 4 files changed, 9 insertions(+), 23 deletions(-)

New commits:
commit 8be6e5dcba0fd262421c59364a463e87ef85fe74
Author: Stephan Bergmann 
AuthorDate: Fri Jan 20 13:30:28 2023 +0100
Commit: Stephan Bergmann 
CommitDate: Fri Jan 20 14:34:40 2023 +

Base GraphicDescriptor on OWeakObject

...rather than on the legacy OWeakAggObject.

It was found that e.g. Graphic, deriving from GraphicDescriptor, was
implementing queryInterface in a way that is incompatible with XAggregation
protocol inherited via OWeakAggObject.  It looks like no code actually made 
use
of the XAggregation offered by this class hierarchy, so the easiest fix for 
that
queryInterface implementation appears to switch from OWeakAggObject to
OWeakObject.

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

diff --git a/vcl/inc/graphic/UnoGraphic.hxx b/vcl/inc/graphic/UnoGraphic.hxx
index 7ab50a0b903d..0e2f2af7b1b0 100644
--- a/vcl/inc/graphic/UnoGraphic.hxx
+++ b/vcl/inc/graphic/UnoGraphic.hxx
@@ -45,7 +45,6 @@ public:
 void init(const ::Graphic& rGraphic);
 
 // XInterface
-virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & 
rType ) override;
 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & 
rType ) override;
 virtual void SAL_CALL acquire() noexcept override;
 virtual void SAL_CALL release() noexcept override;
diff --git a/vcl/inc/graphic/UnoGraphicDescriptor.hxx 
b/vcl/inc/graphic/UnoGraphicDescriptor.hxx
index 096b30fd694e..d57bb3a65d28 100644
--- a/vcl/inc/graphic/UnoGraphicDescriptor.hxx
+++ b/vcl/inc/graphic/UnoGraphicDescriptor.hxx
@@ -61,7 +61,7 @@ class Graphic;
 
 namespace unographic {
 
-class GraphicDescriptor : public ::cppu::OWeakAggObject,
+class GraphicDescriptor : public ::cppu::OWeakObject,
   public css::lang::XServiceInfo,
   public css::lang::XTypeProvider,
   public ::comphelper::PropertySetHelper
@@ -78,7 +78,6 @@ public:
 static rtl::Reference<::comphelper::PropertySetInfo> 
createPropertySetInfo();
 
 // XInterface
-virtual css::uno::Any SAL_CALL queryAggregation( const css::uno::Type & 
rType ) override;
 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & 
rType ) override;
 virtual void SAL_CALL acquire() noexcept override;
 virtual void SAL_CALL release() noexcept override;
diff --git a/vcl/source/graphic/UnoGraphic.cxx 
b/vcl/source/graphic/UnoGraphic.cxx
index a1150e26ca69..f26640563862 100644
--- a/vcl/source/graphic/UnoGraphic.cxx
+++ b/vcl/source/graphic/UnoGraphic.cxx
@@ -50,7 +50,7 @@ void Graphic::init(const ::Graphic& rGraphic)
 unographic::GraphicDescriptor::init(maGraphic);
 }
 
-uno::Any SAL_CALL Graphic::queryAggregation( const uno::Type& rType )
+uno::Any SAL_CALL Graphic::queryInterface( const uno::Type & rType )
 {
 uno::Any aAny;
 if( rType == cppu::UnoType::get())
@@ -59,20 +59,14 @@ uno::Any SAL_CALL Graphic::queryAggregation( const 
uno::Type& rType )
 aAny <<= uno::Reference< awt::XBitmap >( this );
 else if( rType == cppu::UnoType::get())
 aAny <<= uno::Reference< lang::XUnoTunnel >(this);
+else if( rType == cppu::UnoType::get())
+aAny <<= uno::Reference< graphic::XGraphicTransformer >(this);
 else
-aAny = ::unographic::GraphicDescriptor::queryAggregation( rType );
+aAny = ::unographic::GraphicDescriptor::queryInterface( rType );
 
 return aAny;
 }
 
-uno::Any SAL_CALL Graphic::queryInterface( const uno::Type & rType )
-{
-css::uno::Any aReturn = ::unographic::GraphicDescriptor::queryInterface( 
rType );
-if ( !aReturn.hasValue() )
-aReturn = ::cppu::queryInterface ( rType, static_cast< 
graphic::XGraphicTransformer*>( this ) );
-return aReturn;
-}
-
 void SAL_CALL Graphic::acquire()
 noexcept
 {
diff --git a/vcl/source/graphic/UnoGraphicDescriptor.cxx 
b/vcl/source/graphic/UnoGraphicDescriptor.cxx
index b9daeeab6b61..40f205bfdb64 100644
--- a/vcl/source/graphic/UnoGraphicDescriptor.cxx
+++ b/vcl/source/graphic/UnoGraphicDescriptor.cxx
@@ -157,7 +157,7 @@ void GraphicDescriptor::implCreate( SvStream& rIStm, const 
OUString* pURL )
 }
 
 
-uno::Any SAL_CALL GraphicDescriptor::queryAggregation( const uno::Type & rType 
)
+uno::Any SAL_CALL GraphicDescriptor::queryInterface( const uno::Type & rType )
 {
 uno::Any aAny;
 
@@ -172,29 +172,23 @@ uno::Any SAL_CALL GraphicDescriptor::queryAggregation( 
const uno::Type & rType )
 else if( rType == cppu::UnoType::get())
 aAny <<= uno::Reference< 

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

2023-01-15 Thread Noel Grandin (via logerrit)
 vcl/inc/graphic/UnoBinaryDataContainer.hxx  |6 +-
 vcl/source/graphic/BinaryDataContainerTools.cxx |2 +-
 vcl/source/graphic/UnoBinaryDataContainer.cxx   |3 ---
 3 files changed, 2 insertions(+), 9 deletions(-)

New commits:
commit 4f0012b73cfabc039da4c78dc993abb42c9cf987
Author: Noel Grandin 
AuthorDate: Fri Jan 13 09:31:38 2023 +0200
Commit: Noel Grandin 
CommitDate: Sun Jan 15 10:14:16 2023 +

XUnoTunnel->dynamic_cast in UnoBinaryDataContainer

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

diff --git a/vcl/inc/graphic/UnoBinaryDataContainer.hxx 
b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
index f1e123dad8d8..7698afe254f7 100644
--- a/vcl/inc/graphic/UnoBinaryDataContainer.hxx
+++ b/vcl/inc/graphic/UnoBinaryDataContainer.hxx
@@ -17,14 +17,12 @@
 #include 
 
 #include 
-#include 
 #include 
 
 #include 
 #include 
 
-class UnoBinaryDataContainer final
-: public cppu::WeakImplHelper
+class UnoBinaryDataContainer final : public 
cppu::WeakImplHelper
 {
 private:
 BinaryDataContainer maBinaryDataContainer;
@@ -39,8 +37,6 @@ public:
 
 // XBinaryDataContainer
 css::uno::Sequence SAL_CALL getCopyAsByteSequence() override;
-
-UNO3_GETIMPLEMENTATION_DECL(UnoBinaryDataContainer)
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/BinaryDataContainerTools.cxx 
b/vcl/source/graphic/BinaryDataContainerTools.cxx
index 359a8664daa6..c64380331356 100644
--- a/vcl/source/graphic/BinaryDataContainerTools.cxx
+++ b/vcl/source/graphic/BinaryDataContainerTools.cxx
@@ -18,7 +18,7 @@ BinaryDataContainer convertUnoBinaryDataContainer(
 {
 BinaryDataContainer aBinaryDataContainer;
 UnoBinaryDataContainer* pUnoBinaryDataContainer
-= 
comphelper::getFromUnoTunnel(rxBinaryDataContainer);
+= dynamic_cast(rxBinaryDataContainer.get());
 if (pUnoBinaryDataContainer)
 aBinaryDataContainer = 
pUnoBinaryDataContainer->getBinaryDataContainer();
 return aBinaryDataContainer;
diff --git a/vcl/source/graphic/UnoBinaryDataContainer.cxx 
b/vcl/source/graphic/UnoBinaryDataContainer.cxx
index 8ee3660be416..4d6a0de9f796 100644
--- a/vcl/source/graphic/UnoBinaryDataContainer.cxx
+++ b/vcl/source/graphic/UnoBinaryDataContainer.cxx
@@ -14,9 +14,6 @@
 
 using namespace css;
 
-// css::lang::XUnoTunnel
-UNO3_GETIMPLEMENTATION_IMPL(UnoBinaryDataContainer);
-
 css::uno::Sequence SAL_CALL 
UnoBinaryDataContainer::getCopyAsByteSequence()
 {
 if (maBinaryDataContainer.isEmpty())


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

2022-12-29 Thread Noel Grandin (via logerrit)
 vcl/inc/SwapFile.hxx|   40 
 vcl/source/gdi/impgraph.cxx |7 ---
 2 files changed, 4 insertions(+), 43 deletions(-)

New commits:
commit 98448a25219166d4775a81a01b1deb029d7d7efd
Author: Noel Grandin 
AuthorDate: Thu Dec 29 12:33:29 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Dec 29 11:38:08 2022 +

merge SwapFile into ImpSwapFile

no need for this

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

diff --git a/vcl/inc/SwapFile.hxx b/vcl/inc/SwapFile.hxx
deleted file mode 100644
index 7ca34fb60698..
--- a/vcl/inc/SwapFile.hxx
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#pragma once
-
-#include 
-#include 
-#include 
-#include 
-#include 
-
-namespace vcl
-{
-class VCL_DLLPUBLIC SwapFile
-{
-private:
-utl::TempFileFast maTempFile;
-
-public:
-SvStream* getStream() { return 
maTempFile.GetStream(StreamMode::READWRITE); }
-};
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index 65f8fb25a827..2e1edf1a1a68 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -20,8 +20,6 @@
 #include 
 #include 
 
-#include 
-
 #include 
 #include 
 #include 
@@ -59,9 +57,11 @@
 
 using namespace com::sun::star;
 
-class ImpSwapFile : public vcl::SwapFile
+
+class ImpSwapFile
 {
 private:
+utl::TempFileFast maTempFile;
 OUString maOriginURL;
 
 public:
@@ -70,6 +70,7 @@ public:
 {
 }
 
+SvStream* getStream() { return 
maTempFile.GetStream(StreamMode::READWRITE); }
 OUString const & getOriginURL() const { return maOriginURL; }
 };
 


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

2022-12-22 Thread Stephan Bergmann (via logerrit)
 vcl/inc/canvasbitmap.hxx   |8 +++-
 vcl/source/helper/canvasbitmap.cxx |   14 --
 vcl/source/helper/canvastools.cxx  |4 +++-
 3 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit 1be70dda02c12a60778b7607cff2520ae1aa611e
Author: Stephan Bergmann 
AuthorDate: Thu Dec 1 10:18:17 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Thu Dec 22 12:34:09 2022 +

loplugin:unocast (vcl::unotools::VclCanvasBitmap)

(See the upcoming commit introducing that loplugin:unocast on why such
dynamic_casts from UNO types are dangerous.)

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

diff --git a/vcl/inc/canvasbitmap.hxx b/vcl/inc/canvasbitmap.hxx
index 54586a1ad60e..141d15ef948a 100644
--- a/vcl/inc/canvasbitmap.hxx
+++ b/vcl/inc/canvasbitmap.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_VCL_INC_CANVASBITMAP_HXX
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -32,7 +33,8 @@ namespace vcl::unotools
 class VCL_DLLPUBLIC VclCanvasBitmap final :
 public cppu::WeakImplHelper< css::rendering::XIntegerReadOnlyBitmap,
  css::rendering::XBitmapPalette,
- css::rendering::XIntegerBitmapColorSpace >
+ css::rendering::XIntegerBitmapColorSpace,
+ css::lang::XUnoTunnel >
 {
 private:
 BitmapEx   m_aBmpEx;
@@ -103,6 +105,10 @@ namespace vcl::unotools
 virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL 
convertIntegerFromARGB( const css::uno::Sequence< css::rendering::ARGBColor >& 
rgbColor ) override;
 virtual css::uno::Sequence< ::sal_Int8 > SAL_CALL 
convertIntegerFromPARGB( const css::uno::Sequence< css::rendering::ARGBColor >& 
rgbColor ) override;
 
+sal_Int64 SAL_CALL getSomething(
+css::uno::Sequence const & aIdentifier) override;
+static css::uno::Sequence const & getUnoTunnelId();
+
 /** Create API wrapper for given BitmapEx
 
 @param rBitmap
diff --git a/vcl/source/helper/canvasbitmap.cxx 
b/vcl/source/helper/canvasbitmap.cxx
index 3f8507178b4f..ac5a0815638a 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -26,6 +26,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -948,7 +949,7 @@ sal_Int8 SAL_CALL VclCanvasBitmap::getEndianness(  )
 uno::Sequence SAL_CALL VclCanvasBitmap::convertFromIntegerColorSpace( 
const uno::Sequence< ::sal_Int8 >& deviceColor,
   
const uno::Reference< ::rendering::XColorSpace >& targetColorSpace )
 {
-if( dynamic_cast(targetColorSpace.get()) )
+if( comphelper::getFromUnoTunnel(targetColorSpace) )
 {
 SolarMutexGuard aGuard;
 
@@ -1012,7 +1013,7 @@ uno::Sequence SAL_CALL 
VclCanvasBitmap::convertFromIntegerColorSpace( co
 uno::Sequence< ::sal_Int8 > SAL_CALL 
VclCanvasBitmap::convertToIntegerColorSpace( const uno::Sequence< ::sal_Int8 >& 
deviceColor,

   const uno::Reference< ::rendering::XIntegerBitmapColorSpace >& 
targetColorSpace )
 {
-if( dynamic_cast(targetColorSpace.get()) )
+if( comphelper::getFromUnoTunnel(targetColorSpace) )
 {
 // it's us, so simply pass-through the data
 return deviceColor;
@@ -1344,5 +1345,14 @@ uno::Sequence< ::sal_Int8 > SAL_CALL 
VclCanvasBitmap::convertIntegerFromPARGB( c
 return aRes;
 }
 
+sal_Int64 VclCanvasBitmap::getSomething(css::uno::Sequence const & 
aIdentifier) {
+return comphelper::getSomethingImpl(aIdentifier, this);
+}
+
+css::uno::Sequence const & VclCanvasBitmap::getUnoTunnelId() {
+static comphelper::UnoIdInit const id;
+return id.getSeq();
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/helper/canvastools.cxx 
b/vcl/source/helper/canvastools.cxx
index 595f12a959c8..11b1588ecf04 100644
--- a/vcl/source/helper/canvastools.cxx
+++ b/vcl/source/helper/canvastools.cxx
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -174,7 +175,8 @@ namespace vcl::unotools
 return ::BitmapEx();
 
 // tunnel directly for known implementation
-VclCanvasBitmap* pImplBitmap = 
dynamic_cast(xInputBitmap.get());
+VclCanvasBitmap* pImplBitmap
+= comphelper::getFromUnoTunnel(xInputBitmap);
 if( pImplBitmap )
 return pImplBitmap->getBitmapEx();
 


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

2022-12-05 Thread Khaled Hosny (via logerrit)
 vcl/inc/sft.hxx  |   10 --
 vcl/source/font/PhysicalFontFace.cxx |   11 +--
 vcl/source/fontsubset/sft.cxx|   24 +++-
 3 files changed, 20 insertions(+), 25 deletions(-)

New commits:
commit 1d5a02d12eacadb708c18e70db747e80ab8817a9
Author: Khaled Hosny 
AuthorDate: Mon Dec 5 22:07:29 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Dec 6 04:24:42 2022 +

Simplify PhysicalFontFace::CreateFontSubset() a bit

Hide the logic inside fontsubset and don’t leak it to the caller.

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 52d9c3db014d..b5fc71b44530 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -608,20 +608,10 @@ class TrueTypeFont;
   intnGlyphs);
 
 VCL_DLLPUBLIC bool CreateTTFfontSubset(AbstractTrueTypeFont& aTTF,
-  std::vector& rOutBuffer,
-  const sal_GlyphId* pGlyphIds,
-  const sal_uInt8* pEncoding,
-  int nGlyphCount);
-
-VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
-  int nByteLength,
   std::vector& rOutBuffer,
   const sal_GlyphId* pGlyphIds,
   const sal_uInt8* pEncoding,
   int nGlyphCount, FontSubsetInfo& rInfo);
-
-VCL_DLLPUBLIC void FillFontSubsetInfo(AbstractTrueTypeFont *ttf,
-  FontSubsetInfo& rInfo);
 /**
  * Generates a new PostScript Type42 font and dumps it to outf file.
  * This function substitutes glyph 0 for all glyphIDs that are not found in 
the font.
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 72c0a86802c8..aa9a9327f708 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -363,17 +363,8 @@ bool 
PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
 if (aSftFont.initialize() != SFErrCodes::Ok)
 return false;
 
-// Get details about the subset font.
-FillFontSubsetInfo(, rInfo);
-
-// Shortcut for CFF-subsetting.
-auto aData = GetRawFontData(T_CFF);
-if (!aData.empty())
-return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer, 
pGlyphIds, pEncoding,
-   nGlyphCount, rInfo);
-
 // write subset into destination file
-return CreateTTFfontSubset(aSftFont, rOutBuffer, pGlyphIds, pEncoding, 
nGlyphCount);
+return CreateTTFfontSubset(aSftFont, rOutBuffer, pGlyphIds, pEncoding, 
nGlyphCount, rInfo);
 }
 
 bool PhysicalFontFace::HasColorLayers() const
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 205be4f8ce26..ee2e0de65dbc 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1809,10 +1809,24 @@ SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont  
*ttf,
 return res;
 }
 
+static void FillFontSubsetInfo(AbstractTrueTypeFont*, FontSubsetInfo&);
+static bool CreateCFFfontSubset(const unsigned char*, int, 
std::vector&,
+const sal_GlyphId*, const sal_uInt8*, int, 
FontSubsetInfo&);
+
 bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, 
std::vector& rOutBuffer,
  const sal_GlyphId* pGlyphIds, const sal_uInt8* 
pEncoding,
- const int nOrigGlyphCount)
+ const int nOrigGlyphCount, FontSubsetInfo& rInfo)
 {
+// Get details about the subset font.
+FillFontSubsetInfo(, rInfo);
+
+// Shortcut for CFF-subsetting.
+sal_uInt32 nCFF;
+const sal_uInt8* pCFF = rTTF.table(O_CFF, nCFF);
+if (nCFF)
+return CreateCFFfontSubset(pCFF, nCFF, rOutBuffer, pGlyphIds, 
pEncoding,
+   nOrigGlyphCount, rInfo);
+
 // Multiple questions:
 // - Why is there a glyph limit?
 //   MacOS used to handle 257 glyphs...
@@ -1867,9 +1881,9 @@ bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, 
std::vector
 == vcl::SFErrCodes::Ok);
 }
 
-bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
- std::vector& rOutBuffer, const 
sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding, int nGlyphCount, 
FontSubsetInfo& rInfo)
+static bool CreateCFFfontSubset(const unsigned char* pFontBytes, int 
nByteLength,
+std::vector& rOutBuffer, const 
sal_GlyphId* pGlyphIds,
+const sal_uInt8* pEncoding, int nGlyphCount, 
FontSubsetInfo& rInfo)
 {
 utl::TempFileFast aTempFile;
 SvStream* pStream = 

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

2022-12-05 Thread Khaled Hosny (via logerrit)
 vcl/inc/fontsubset.hxx   |1 +
 vcl/inc/sft.hxx  |1 -
 vcl/source/font/PhysicalFontFace.cxx |   13 ++---
 vcl/source/fontsubset/cff.cxx|   28 
 vcl/source/fontsubset/fontsubset.cxx |1 +
 vcl/source/fontsubset/sft.cxx|   11 ++-
 6 files changed, 34 insertions(+), 21 deletions(-)

New commits:
commit 7415ce2b9795a78f836bc5e5bffb4b56eee26b21
Author: Khaled Hosny 
AuthorDate: Mon Dec 5 20:52:13 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Dec 6 04:22:07 2022 +

tdf#113048: Fix PDF ascender and descender of some fonts

Use the same ascender and descender calculation for fonts with CFF
table as fonts without CFF table.

This also provides a better fix for tdf#138325 and tdf#151039.

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

diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx
index d7e5318eec26..a1ba31aa58d8 100644
--- a/vcl/inc/fontsubset.hxx
+++ b/vcl/inc/fontsubset.hxx
@@ -70,6 +70,7 @@ public: // TODO: make subsetter results private and provide 
accessor methods ins
 int m_nCapHeight;
 tools::Rectangle   m_aFontBBox;
 FontTypem_nFontType;///< font-type of subset result
+boolm_bFilled;
 
 private:
 // input-font-specific details
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 29f282a04ec4..52d9c3db014d 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -616,7 +616,6 @@ class TrueTypeFont;
 VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
   int nByteLength,
   std::vector& rOutBuffer,
-  const OUString& rPSName,
   const sal_GlyphId* pGlyphIds,
   const sal_uInt8* pEncoding,
   int nGlyphCount, FontSubsetInfo& rInfo);
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 682113cad102..72c0a86802c8 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -358,13 +358,6 @@ bool 
PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
 const sal_GlyphId* pGlyphIds, const 
sal_uInt8* pEncoding,
 const int nGlyphCount, FontSubsetInfo& 
rInfo) const
 {
-// Shortcut for CFF-subsetting.
-auto aData = GetRawFontData(T_CFF);
-if (!aData.empty())
-return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer,
-   GetName(NAME_ID_POSTSCRIPT_NAME), 
pGlyphIds, pEncoding,
-   nGlyphCount, rInfo);
-
 // Prepare data for font subsetter.
 TrueTypeFace aSftFont(RawFace(GetHbFace()), GetFontCharMap());
 if (aSftFont.initialize() != SFErrCodes::Ok)
@@ -373,6 +366,12 @@ bool 
PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
 // Get details about the subset font.
 FillFontSubsetInfo(, rInfo);
 
+// Shortcut for CFF-subsetting.
+auto aData = GetRawFontData(T_CFF);
+if (!aData.empty())
+return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer, 
pGlyphIds, pEncoding,
+   nGlyphCount, rInfo);
+
 // write subset into destination file
 return CreateTTFfontSubset(aSftFont, rOutBuffer, pGlyphIds, pEncoding, 
nGlyphCount);
 }
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx
index 45a8b7890a31..76a77ec961cd 100644
--- a/vcl/source/fontsubset/cff.cxx
+++ b/vcl/source/fontsubset/cff.cxx
@@ -2361,9 +2361,22 @@ void CffSubsetterContext::emitAsType1( Type1Emitter& 
rEmitter,
 rEmitter.emitValVector( "/FontMatrix [", "]readonly def\n", 
maFontMatrix);
 else // emit default FontMatrix if needed
 rEmitter.maBuffer.append( "/FontMatrix [0.001 0 0 0.001 0 0]readonly 
def\n");
+
 // emit FontBBox
+ValType fXFactor = 1.0;
+ValType fYFactor = 1.0;
+if( maFontMatrix.size() >= 4) {
+fXFactor = 1000.0F * maFontMatrix[0];
+fYFactor = 1000.0F * maFontMatrix[3];
+}
+
 auto aFontBBox = maFontBBox;
-if (aFontBBox.size() != 4)
+if (rFSInfo.m_bFilled)
+aFontBBox = {
+rFSInfo.m_aFontBBox.Left() / fXFactor, rFSInfo.m_aFontBBox.Top() / 
fYFactor,
+rFSInfo.m_aFontBBox.Right() / fXFactor, 
(rFSInfo.m_aFontBBox.Bottom() + 1) / fYFactor
+};
+else if (aFontBBox.size() != 4)
 aFontBBox = { 0, 0, 999, 999 }; // emit default FontBBox if needed
 rEmitter.emitValVector( "/FontBBox {", "}readonly def\n", aFontBBox);
 // emit FONTINFO into TOPDICT
@@ -2572,12 +2585,12 @@ void 

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

2022-12-05 Thread Khaled Hosny (via logerrit)
 vcl/inc/fontsubset.hxx   |1 -
 vcl/source/fontsubset/fontsubset.cxx |   10 --
 2 files changed, 11 deletions(-)

New commits:
commit 05b7e6039da5fda18205798d00e335b2c8126872
Author: Khaled Hosny 
AuthorDate: Mon Dec 5 17:58:58 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Dec 5 21:12:48 2022 +

Drop dummy function

Type 1 support is long and this was always dead code anyway.

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

diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx
index cb4cb34dd979..d7e5318eec26 100644
--- a/vcl/inc/fontsubset.hxx
+++ b/vcl/inc/fontsubset.hxx
@@ -88,7 +88,6 @@ private:
 
 boolCreateFontSubsetFromCff();
 boolCreateFontSubsetFromSfnt();
-static bool CreateFontSubsetFromType1();
 };
 
 int VCL_DLLPUBLIC TestFontSubset(const void* data, sal_uInt32 size);
diff --git a/vcl/source/fontsubset/fontsubset.cxx 
b/vcl/source/fontsubset/fontsubset.cxx
index 72b634b786f0..1e3daa401bc6 100644
--- a/vcl/source/fontsubset/fontsubset.cxx
+++ b/vcl/source/fontsubset/fontsubset.cxx
@@ -96,8 +96,6 @@ bool FontSubsetInfo::CreateFontSubset(
 case FontType::TYPE1_PFA:
 case FontType::TYPE1_PFB:
 case FontType::ANY_TYPE1:
-bOK = CreateFontSubsetFromType1();
-break;
 case FontType::NO_FONT:
 default:
 OSL_FAIL( "unhandled type in CreateFontSubset()");
@@ -151,12 +149,4 @@ bool FontSubsetInfo::CreateFontSubsetFromSfnt()
 return (nSFTErr != vcl::SFErrCodes::Ok);
 }
 
-// TODO: replace dummy implementation
-bool FontSubsetInfo::CreateFontSubsetFromType1()
-{
-SAL_WARN("vcl.fonts",
-"CreateFontSubsetFromType1: replace dummy implementation.");
-return false;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2022-12-03 Thread Caolán McNamara (via logerrit)
 vcl/inc/sallayout.hxx|2 +-
 vcl/source/gdi/sallayout.cxx |6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit c50cf1883af26daebdfc9d796ced3c20c222f43b
Author: Caolán McNamara 
AuthorDate: Sat Dec 3 20:28:21 2022 +
Commit: Caolán McNamara 
CommitDate: Sat Dec 3 23:42:22 2022 +

Related: tdf#152196 these should be at least DeviceCoordinate

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

diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 54b486b36afd..5a3a253b68a9 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -132,7 +132,7 @@ public:
 
 private:
 // for glyph+font+script fallback
-voidMoveGlyph(int nStart, tools::Long nNewXPos);
+voidMoveGlyph(int nStart, DeviceCoordinate nNewXPos);
 voidDropGlyph(int nStart);
 voidSimplify(bool bIsBase);
 
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index 521cbb3d6007..be00aaa51a42 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -539,7 +539,7 @@ bool GenericSalLayout::GetNextGlyph(const GlyphItem** 
pGlyph,
 return true;
 }
 
-void GenericSalLayout::MoveGlyph( int nStart, tools::Long nNewXPos )
+void GenericSalLayout::MoveGlyph( int nStart, DeviceCoordinate nNewXPos )
 {
 if( nStart >= static_cast(m_GlyphItems.size()) )
 return;
@@ -553,7 +553,7 @@ void GenericSalLayout::MoveGlyph( int nStart, tools::Long 
nNewXPos )
 if( pGlyphIter->IsRTLGlyph() )
 nNewXPos += pGlyphIter->newWidth() - pGlyphIter->origWidth();
 // calculate the x-offset to the old position
-tools::Long nXDelta = nNewXPos - pGlyphIter->linearPos().getX() + 
pGlyphIter->xOffset();
+DeviceCoordinate nXDelta = nNewXPos - pGlyphIter->linearPos().getX() + 
pGlyphIter->xOffset();
 // adjust all following glyph positions if needed
 if( nXDelta != 0 )
 {
@@ -771,7 +771,7 @@ void 
MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs,
 mnLevel = nLevel;
 
 // prepare merge the fallback levels
-tools::Long nXPos = 0;
+DeviceCoordinate nXPos = 0;
 for( n = 0; n < nLevel; ++n )
 maFallbackRuns[n].ResetPos();
 


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

2022-11-23 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|9 +++
 vcl/inc/pdf/pdfwriter_impl.hxx  |6 +-
 vcl/source/font/LogicalFontInstance.cxx |   88 
 vcl/source/gdi/pdfwriter_impl.cxx   |   28 --
 4 files changed, 126 insertions(+), 5 deletions(-)

New commits:
commit 164d717530aff8d2581d0a2ff249f83aabb27502
Author: Khaled Hosny 
AuthorDate: Mon Nov 21 15:37:40 2022 +0200
Commit: خالد حسني 
CommitDate: Wed Nov 23 21:35:47 2022 +0100

tdf#108497: instantiate variable fonts in PDF

Draw the outlines as PDF Type 3 glyphs until we can use HarfBuzz
subsetter to instantiate the fonts before embedding.

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index 0b40a9c7d4f7..6f4645c82c0c 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -103,6 +103,7 @@ public: // TODO: make data members private
 
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
+bool GetGlyphOutlineUntransformed(sal_GlyphId, basegfx::B2DPolyPolygon&) 
const;
 
 sal_GlyphId GetGlyphIndex(uint32_t, uint32_t = 0) const;
 
@@ -125,6 +126,8 @@ protected:
 virtual void ImplInitHbFont(hb_font_t*) {}
 
 private:
+hb_font_t* GetHbFontUntransformed() const;
+
 struct MapEntry
 {
 OUString sFontName;
@@ -139,6 +142,7 @@ private:
 mutable ImplFontCache* mpFontCache;
 const vcl::font::FontSelectPattern m_aFontSelData;
 hb_font_t* m_pHbFont;
+mutable hb_font_t* m_pHbFontUntransformed = nullptr;
 double m_nAveWidthFactor;
 rtl::Reference m_pFontFace;
 std::optional m_xbIsGraphiteFont;
@@ -151,6 +155,11 @@ private:
 
 // The value is initialized and used in NeedOffsetCorrection().
 std::optional m_xeFontFamilyEnum;
+
+#if HB_VERSION_ATLEAST(4, 0, 0)
+mutable hb_draw_funcs_t* m_pHbDrawFuncs = nullptr;
+basegfx::B2DPolygon m_aDrawPolygon;
+#endif
 };
 
 inline hb_font_t* LogicalFontInstance::GetHbFont()
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 1459cf16e0d2..b3222f4072fd 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -299,6 +299,7 @@ class GlyphEmit
 std::vector m_aColorLayers;
 font::RawFontData   m_aColorBitmap;
 tools::Rectanglem_aRect;
+basegfx::B2DPolyPolygon m_aOutline;
 
 public:
 GlyphEmit() : m_nSubsetGlyphID(0), m_nGlyphWidth(0)
@@ -325,6 +326,9 @@ public:
 return m_aColorBitmap;
 }
 
+void setOutline(basegfx::B2DPolyPolygon aOutline) { m_aOutline = aOutline; 
}
+const basegfx::B2DPolyPolygon& getOutline() const { return m_aOutline; }
+
 void addCode( sal_Ucs i_cCode )
 {
 m_CodeUnits.push_back(i_cCode);
@@ -852,7 +856,7 @@ i12626
 void appendLiteralStringEncrypt( std::string_view rInString, const 
sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
 
 /* creates fonts and subsets that will be emitted later */
-void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, 
const std::vector&, sal_Int32, sal_uInt8&, sal_Int32&);
+void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, 
const LogicalFontInstance* pFont, const std::vector&, sal_Int32, 
sal_uInt8&, sal_Int32&);
 void registerSimpleGlyph(const sal_GlyphId, const 
vcl::font::PhysicalFontFace*, const std::vector&, sal_Int32, 
sal_uInt8&, sal_Int32&);
 
 /*  emits a text object according to the passed layout */
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 34f05bbe6e33..6923ce6cd87a 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -50,6 +50,14 @@ LogicalFontInstance::~LogicalFontInstance()
 
 if (m_pHbFont)
 hb_font_destroy(m_pHbFont);
+
+if (m_pHbFontUntransformed)
+hb_font_destroy(m_pHbFontUntransformed);
+
+#if HB_VERSION_ATLEAST(4, 0, 0)
+if (m_pHbDrawFuncs)
+hb_draw_funcs_destroy(m_pHbDrawFuncs);
+#endif
 }
 
 hb_font_t* LogicalFontInstance::InitHbFont()
@@ -79,6 +87,26 @@ hb_font_t* LogicalFontInstance::InitHbFont()
 return pHbFont;
 }
 
+hb_font_t* LogicalFontInstance::GetHbFontUntransformed() const
+{
+auto* pHbFont = const_cast(this)->GetHbFont();
+
+#if HB_VERSION_ATLEAST(3, 3, 0)
+if (NeedsArtificialItalic()) // || NeedsArtificialBold()
+{
+if (!m_pHbFontUntransformed)
+{
+m_pHbFontUntransformed = hb_font_create_sub_font(pHbFont);
+// Unset slant set on parent font.
+// Does not actually work: 

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

2022-11-23 Thread Caolán McNamara (via logerrit)
 vcl/inc/calendar.hxx|3 +--
 vcl/source/control/calendar.cxx |   14 +++---
 2 files changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 5b3b13ceed474873776464269c5d71544252a928
Author: Caolán McNamara 
AuthorDate: Wed Nov 23 17:00:22 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Nov 23 20:38:00 2022 +0100

rename ImplScroll to ImplScrollCalendar

to avoid collision with Window::ImplScroll

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

diff --git a/vcl/inc/calendar.hxx b/vcl/inc/calendar.hxx
index a40f1ffdf323..5d757e056170 100644
--- a/vcl/inc/calendar.hxx
+++ b/vcl/inc/calendar.hxx
@@ -176,8 +176,7 @@ class Calendar final : public Control
 void ImplUpdateSelection( IntDateSet* pOld );
 void ImplMouseSelect( const Date& rDate, sal_uInt16 nHitTest );
 void ImplUpdate( bool bCalcNew = false );
-using Window::ImplScroll;
-void ImplScroll( bool bPrev );
+void ImplScrollCalendar( bool bPrev );
 void ImplShowMenu( const Point& rPos, const Date& rDate );
 void ImplTracking( const Point& rPos, bool bRepeat );
 void ImplEndTracking( bool bCancel );
diff --git a/vcl/source/control/calendar.cxx b/vcl/source/control/calendar.cxx
index 3995aa142bae..44d6fc56ab70 100644
--- a/vcl/source/control/calendar.cxx
+++ b/vcl/source/control/calendar.cxx
@@ -864,7 +864,7 @@ void Calendar::ImplUpdate( bool bCalcNew )
 mbFormat = true;
 }
 
-void Calendar::ImplScroll( bool bPrev )
+void Calendar::ImplScrollCalendar( bool bPrev )
 {
 Date aNewFirstMonth = GetFirstMonth();
 if ( bPrev )
@@ -943,7 +943,7 @@ void Calendar::ImplTracking( const Point& rPos, bool 
bRepeat )
 
 if ( bRepeat && (mbPrevIn || mbNextIn) )
 {
-ImplScroll( mbPrevIn );
+ImplScrollCalendar( mbPrevIn );
 }
 }
 else
@@ -992,9 +992,9 @@ void Calendar::ImplEndTracking( bool bCancel )
 Date aFirstSelDate( *mpSelectTable->begin() );
 Date aLastSelDate( *mpSelectTable->rbegin() );
 if ( aLastSelDate < GetFirstMonth() )
-ImplScroll( true );
+ImplScrollCalendar( true );
 else if ( GetLastMonth() < aFirstSelDate )
-ImplScroll( false );
+ImplScrollCalendar( false );
 }
 }
 
@@ -1026,7 +1026,7 @@ void Calendar::MouseButtonDown( const MouseEvent& rMEvt )
 if ( mbPrevIn || mbNextIn )
 {
 mbSpinDown = true;
-ImplScroll( mbPrevIn );
+ImplScrollCalendar( mbPrevIn );
 // it should really read BUTTONREPEAT, therefore do not
 // change it to SCROLLREPEAT, check with TH,
 // why it could be different (71775)
@@ -1224,7 +1224,7 @@ void Calendar::Command( const CommandEvent& rCEvt )
 {
 while ( nNotchDelta < 0 )
 {
-ImplScroll( true );
+ImplScrollCalendar( true );
 nNotchDelta++;
 }
 }
@@ -1232,7 +1232,7 @@ void Calendar::Command( const CommandEvent& rCEvt )
 {
 while ( nNotchDelta > 0 )
 {
-ImplScroll( false );
+ImplScrollCalendar( false );
 nNotchDelta--;
 }
 }


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

2022-11-21 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx|3 ++-
 vcl/source/font/PhysicalFontFace.cxx |4 ++--
 vcl/source/gdi/pdfwriter_impl.cxx|5 +++--
 3 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit ab5c60f2fd3e24f24fd82d7756d45a5fd4d19f1d
Author: Khaled Hosny 
AuthorDate: Mon Nov 21 17:32:42 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Nov 21 19:58:54 2022 +0100

vcl: fix accessing color font colors

Don’t unconditionally access palette 0.

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

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 96f2533f22fe..ac8ba2d958c7 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -174,9 +174,10 @@ public:
 bool IsColorFont() const { return HasColorLayers() || HasColorBitmaps(); }
 
 bool HasColorLayers() const;
-const ColorPalette& GetColorPalette(size_t) const;
 std::vector GetGlyphColorLayers(sal_GlyphId) const;
 
+const std::vector& GetColorPalettes() const;
+
 bool HasColorBitmaps() const;
 RawFontData GetGlyphColorBitmap(sal_GlyphId, tools::Rectangle&) const;
 
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 83f50b31e690..682113cad102 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -383,7 +383,7 @@ bool PhysicalFontFace::HasColorLayers() const
 return hb_ot_color_has_layers(pHbFace) && 
hb_ot_color_has_palettes(pHbFace);
 }
 
-const ColorPalette& PhysicalFontFace::GetColorPalette(size_t nIndex) const
+const std::vector& PhysicalFontFace::GetColorPalettes() const
 {
 if (!mxColorPalettes)
 {
@@ -410,7 +410,7 @@ const ColorPalette& 
PhysicalFontFace::GetColorPalette(size_t nIndex) const
 }
 }
 
-return (*mxColorPalettes)[nIndex];
+return *mxColorPalettes;
 }
 
 std::vector PhysicalFontFace::GetGlyphColorLayers(sal_GlyphId 
nGlyphIndex) const
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 8ba2ac6e0428..57ea2c785b81 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2446,7 +2446,7 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
 if (g_bDebugDisableCompression)
 emitComment("PDFWriterImpl::emitType3Font");
 
-const auto& aPalette = pFace->GetColorPalette(0);
+const auto& rColorPalettes = pFace->GetColorPalettes();
 
 FontSubsetInfo aSubsetInfo;
 sal_GlyphId pTempGlyphIds[] = { 0 };
@@ -2587,7 +2587,8 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
 // 0x is a special value means foreground color.
 if (rLayer.m_nColorIndex != 0x)
 {
-auto aColor(aPalette[rLayer.m_nColorIndex]);
+auto& rPalette = rColorPalettes[0];
+auto aColor(rPalette[rLayer.m_nColorIndex]);
 appendNonStrokingColor(aColor, aContents);
 aContents.append(" ");
 if (aColor.GetAlpha() != 0xFF


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

2022-11-21 Thread Jonas Eyov (via logerrit)
 vcl/inc/window.h  |2 ++
 vcl/source/window/window.cxx  |2 ++
 vcl/source/window/window2.cxx |   37 ++---
 3 files changed, 26 insertions(+), 15 deletions(-)

New commits:
commit fe21365c5a9083ae1f086ea48614263b3a75ab3e
Author: Jonas Eyov 
AuthorDate: Fri Nov 18 03:40:57 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Nov 21 17:28:45 2022 +0100

tdf#143209 vcl: track partial scroll deltas

this makes scrolling in calc smoother and makes left/up scrolling
the same speed as right/down scrolling, which was previously not the
case.

prior to this change, Window::HandleScrollCommand only checked each
event for being a large enough scroll to advance one unit. this
happened in lcl_HandleScrollHelper by way of o3tl::saturating_cast,
which meant that nonzero upward/leftward scrolls were always worth at
least one unit, while downward/rightward scrolls needed to be larger
than 1 to count.

now, we accumulate partial scroll offsets in WindowImpl and perform a
saturating cast on the absolute value, so behavior is symmetric and
sensitive to accumulated small scroll values. this feels smoother
and is more correct.

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

diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index 639bee80e82c..6f10445abf39 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -256,6 +256,8 @@ public:
 vcl::Cursor*mpCursor;
 PointerStylemaPointer;
 FractionmaZoom;
+double  mfPartialScrollX;
+double  mfPartialScrollY;
 OUStringmaText;
 std::optional
 mpControlFont;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 4705fe516ce5..5cfc50d717c0 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -590,6 +590,8 @@ WindowImpl::WindowImpl( vcl::Window& rWindow, WindowType 
nType )
 {
 mxOutDev = VclPtr::Create(rWindow);
 maZoom  = Fraction( 1, 1 );
+mfPartialScrollX= 0.0;
+mfPartialScrollY= 0.0;
 maWinRegion = vcl::Region(true);
 maWinClipRegion = vcl::Region(true);
 mpWinData   = nullptr;  // 
Extra Window Data, that we don't need for all windows
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index b6c4ee25415a..978dc0b6ecf8 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -598,12 +598,14 @@ tools::Long Window::GetDrawPixel( OutputDevice const * 
pDev, tools::Long nPixels
 return nP;
 }
 
-static void lcl_HandleScrollHelper( Scrollable* pScrl, double nN, bool 
isMultiplyByLineSize )
+// returns how much was actually scrolled (so that abs(retval) <= abs(nN))
+static double lcl_HandleScrollHelper( Scrollable* pScrl, double nN, bool 
isMultiplyByLineSize )
 {
 if (!pScrl || !nN || pScrl->Inactive())
-return;
+return 0.0;
 
 tools::Long nNewPos = pScrl->GetThumbPos();
+double scrolled = nN;
 
 if ( nN == double(-LONG_MAX) )
 nNewPos += pScrl->GetPageSize();
@@ -616,13 +618,22 @@ static void lcl_HandleScrollHelper( Scrollable* pScrl, 
double nN, bool isMultipl
 nN*=pScrl->GetLineSize();
 }
 
-const double fVal = nNewPos - nN;
+// compute how many quantized units to scroll
+tools::Long magnitude = o3tl::saturating_cast(abs(nN));
+tools::Long change = copysign(magnitude, nN);
+
+nNewPos = nNewPos - change;
 
-nNewPos = o3tl::saturating_cast(fVal);
+scrolled = double(change);
+// convert back to chunked/continuous
+if(isMultiplyByLineSize){
+scrolled /= pScrl->GetLineSize();
+}
 }
 
 pScrl->DoScroll( nNewPos );
 
+return scrolled;
 }
 
 bool Window::HandleScrollCommand( const CommandEvent& rCmd,
@@ -668,6 +679,9 @@ bool Window::HandleScrollCommand( const CommandEvent& rCmd,
 {
 double nScrollLines = pData->GetScrollLines();
 double nLines;
+double* partialScroll = pData->IsHorz()
+? >mfPartialScrollX
+: >mfPartialScrollY;
 if ( nScrollLines == COMMAND_WHEEL_PAGESCROLL )
 {
 if ( pData->GetDelta() < 0 )
@@ -676,13 +690,12 @@ bool Window::HandleScrollCommand( const CommandEvent& 
rCmd,
 nLines = double(LONG_MAX);
 }
 else
-

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

2022-11-21 Thread Caolán McNamara (via logerrit)
 vcl/inc/impfont.hxx  |7 ++-
 vcl/source/font/font.cxx |9 -
 2 files changed, 2 insertions(+), 14 deletions(-)

New commits:
commit 5a35ca12d98d7ad0bfc012d75d00f9eefb4ec078
Author: Caolán McNamara 
AuthorDate: Fri Nov 18 20:56:51 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Nov 21 09:55:29 2022 +0100

drop ImplFont::SetSymbolFlag

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

diff --git a/vcl/inc/impfont.hxx b/vcl/inc/impfont.hxx
index 450e227b34ad..b570f22a6e7c 100644
--- a/vcl/inc/impfont.hxx
+++ b/vcl/inc/impfont.hxx
@@ -49,7 +49,7 @@ public:
 rtl_TextEncodingGetCharSet() const  { 
return meCharSet; }
 const Size& GetFontSize() const  { return 
maAverageFontSize; }
 
-boolIsSymbolFont() const{ 
return mbSymbolFlag; }
+boolIsSymbolFont() const{ 
return meCharSet == RTL_TEXTENCODING_SYMBOL; }
 
 voidSetFamilyName( const OUString& sFamilyName ){ 
maFamilyName = sFamilyName; }
 voidSetStyleName( const OUString& sStyleName )  { 
maStyleName = sStyleName; }
@@ -72,8 +72,6 @@ public:
 maAverageFontSize = rSize;
 }
 
-voidSetSymbolFlag( const bool bSymbolFlag ) { 
mbSymbolFlag = bSymbolFlag; }
-
 // straight properties, no getting them from AskConfig()
 FontFamily  GetFamilyTypeNoAsk() const  { 
return meFamily; }
 FontWeight  GetWeightNoAsk() const  { 
return meWeight; }
@@ -127,8 +125,7 @@ private:
 LanguageTag maCJKLanguageTag;
 
 // Flags - device independent
-boolmbSymbolFlag:1,
-mbOutline:1,
+boolmbOutline:1,
 mbConfigLookup:1,   // config lookup should only be 
done once
 mbShadow:1,
 mbVertical:1,
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index afaa430e19f7..b6ed6926b33f 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -161,14 +161,7 @@ void Font::SetFamily( FontFamily eFamily )
 void Font::SetCharSet( rtl_TextEncoding eCharSet )
 {
 if (const_cast(mpImplFont)->GetCharSet() != eCharSet)
-{
 mpImplFont->SetCharSet( eCharSet );
-
-if ( eCharSet == RTL_TEXTENCODING_SYMBOL )
-mpImplFont->SetSymbolFlag( true );
-else
-mpImplFont->SetSymbolFlag( false );
-}
 }
 
 bool Font::IsSymbolFont() const
@@ -977,7 +970,6 @@ ImplFont::ImplFont() :
 meCharSet( RTL_TEXTENCODING_DONTKNOW ),
 maLanguageTag( LANGUAGE_DONTKNOW ),
 maCJKLanguageTag( LANGUAGE_DONTKNOW ),
-mbSymbolFlag( false ),
 mbOutline( false ),
 mbConfigLookup( false ),
 mbShadow( false ),
@@ -1011,7 +1003,6 @@ ImplFont::ImplFont( const ImplFont& rImplFont ) :
 meCharSet( rImplFont.meCharSet ),
 maLanguageTag( rImplFont.maLanguageTag ),
 maCJKLanguageTag( rImplFont.maCJKLanguageTag ),
-mbSymbolFlag( rImplFont.mbSymbolFlag ),
 mbOutline( rImplFont.mbOutline ),
 mbConfigLookup( rImplFont.mbConfigLookup ),
 mbShadow( rImplFont.mbShadow ),


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

2022-10-29 Thread Khaled Hosny (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx|2 +-
 vcl/source/gdi/pdfwriter_impl.cxx |   19 +--
 2 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 506d969193822f396bb2203718124e3516ad75d1
Author: Khaled Hosny 
AuthorDate: Sat Oct 29 11:12:23 2022 +0200
Commit: خالد حسني 
CommitDate: Sat Oct 29 12:04:05 2022 +0200

vcl: check the correct face for color glyphs

We were checking the presence of color glyphs on the base face which can
potentially different from the actual face the glyphs are using (e.g. in
case of glyph fallback). Also rename the functions so we don’t need
overloading.

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 6102b64a8956..1459cf16e0d2 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -853,7 +853,7 @@ i12626
 
 /* creates fonts and subsets that will be emitted later */
 void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, 
const std::vector&, sal_Int32, sal_uInt8&, sal_Int32&);
-void registerGlyph(const sal_GlyphId, const vcl::font::PhysicalFontFace*, 
const std::vector&, sal_Int32, sal_uInt8&, sal_Int32&, bool);
+void registerSimpleGlyph(const sal_GlyphId, const 
vcl::font::PhysicalFontFace*, const std::vector&, sal_Int32, 
sal_uInt8&, sal_Int32&);
 
 /*  emits a text object according to the passed layout */
 /* TODO: remove rText as soon as SalLayout will change so that rText is 
not necessary anymore */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 6214489203b3..6f096e52c154 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -4186,7 +4186,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
 
 sal_uInt8 nMappedGlyph;
 sal_Int32 nMappedFontObject;
-registerGlyph(nGlyphId, pDevFont, { cMark }, nGlyphWidth, nMappedGlyph, 
nMappedFontObject, pDevFont->IsColorFont());
+registerGlyph(nGlyphId, pDevFont, { cMark }, nGlyphWidth, nMappedGlyph, 
nMappedFontObject);
 
 appendNonStrokingColor( replaceColor( rWidget.TextColor, 
rSettings.GetRadioCheckTextColor() ), aDA );
 aDA.append( ' ' );
@@ -6083,7 +6083,7 @@ sal_Int32 PDFWriterImpl::getSystemFont( const vcl::Font& 
i_rFont )
 return nFontID;
 }
 
-void PDFWriterImpl::registerGlyph(const sal_GlyphId nFontGlyphId,
+void PDFWriterImpl::registerSimpleGlyph(const sal_GlyphId nFontGlyphId,
   const vcl::font::PhysicalFontFace* pFont,
   const std::vector& rCodeUnits,
   sal_Int32 nGlyphWidth,
@@ -6130,10 +6130,9 @@ void PDFWriterImpl::registerGlyph(const sal_GlyphId 
nFontGlyphId,
 void PDFWriterImpl::registerGlyph(const sal_GlyphId nFontGlyphId,
   const vcl::font::PhysicalFontFace* pFace,
   const std::vector& rCodeUnits, 
sal_Int32 nGlyphWidth,
-  sal_uInt8& nMappedGlyph, sal_Int32& 
nMappedFontObject,
-  bool bColor)
+  sal_uInt8& nMappedGlyph, sal_Int32& 
nMappedFontObject)
 {
-if (bColor)
+if (pFace->IsColorFont())
 {
 // Font has colors, check if this glyph has color layers or bitmap.
 tools::Rectangle aRect;
@@ -6178,8 +6177,8 @@ void PDFWriterImpl::registerGlyph(const sal_GlyphId 
nFontGlyphId,
 {
 sal_uInt8 nLayerGlyph;
 sal_Int32 nLayerFontID;
-registerGlyph(aLayer.nGlyphIndex, pFace, rCodeUnits, 
nGlyphWidth,
-  nLayerGlyph, nLayerFontID);
+registerSimpleGlyph(aLayer.nGlyphIndex, pFace, 
rCodeUnits, nGlyphWidth,
+nLayerGlyph, nLayerFontID);
 
 rNewGlyphEmit.addColorLayer(
 { nLayerFontID, nLayerGlyph, aLayer.nColorIndex });
@@ -6198,7 +6197,8 @@ void PDFWriterImpl::registerGlyph(const sal_GlyphId 
nFontGlyphId,
 }
 
 // If we reach here then the glyph has no color layers.
-registerGlyph(nFontGlyphId, pFace, rCodeUnits, nGlyphWidth, nMappedGlyph, 
nMappedFontObject);
+registerSimpleGlyph(nFontGlyphId, pFace, rCodeUnits, nGlyphWidth, 
nMappedGlyph,
+nMappedFontObject);
 }
 
 void PDFWriterImpl::drawRelief( SalLayout& rLayout, const OUString& rText, 
bool bTextLines )
@@ -6582,7 +6582,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
 }
 
 FontMetric aRefDevFontMetric = GetFontMetric();
-const vcl::font::PhysicalFontFace* pDevFont = 

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

2022-10-04 Thread Khaled Hosny (via logerrit)
 vcl/inc/impglyphitem.hxx   |4 +---
 vcl/source/gdi/CommonSalLayout.cxx |   20 +---
 vcl/source/gdi/pdfwriter_impl.cxx  |7 ---
 vcl/source/gdi/sallayout.cxx   |4 ++--
 4 files changed, 12 insertions(+), 23 deletions(-)

New commits:
commit 29de4d6e1afcf2ad79056e4ad4403c3d4bdda4a0
Author: Khaled Hosny 
AuthorDate: Mon Oct 3 21:53:38 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Oct 4 14:10:53 2022 +0200

tdf#150665: Fix justifying spacing marks

We shouldn’t be concerned whether a character is combining mark or not,
what we really care about is whether the font classifies it as mark
glyph, so check for that. Furthermore, for our purposes a mark glyph
forms a cluster with the preceding glyph, so we can use IN_CLUSTER flag
and drop the IS_DIACRITIC flag. This fixes the big above and a few other
issues I found myself.

Remove also overzealous asserts in pdfwriter, they are long past their
usefulness.

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

diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index 8bc8f19b9176..9c369c204500 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -34,7 +34,6 @@ enum class GlyphItemFlags : sal_uInt16
 NONE = 0,
 IS_IN_CLUSTER = 0x01,
 IS_RTL_GLYPH = 0x02,
-IS_DIACRITIC = 0x04,
 IS_VERTICAL = 0x08,
 IS_SPACING = 0x10,
 IS_DROPPED = 0x40,
@@ -44,7 +43,7 @@ enum class GlyphItemFlags : sal_uInt16
 };
 namespace o3tl
 {
-template <> struct typed_flags : 
is_typed_flags
+template <> struct typed_flags : 
is_typed_flags
 {
 };
 };
@@ -78,7 +77,6 @@ public:
 
 bool IsInCluster() const { return bool(m_nFlags & 
GlyphItemFlags::IS_IN_CLUSTER); }
 bool IsRTLGlyph() const { return bool(m_nFlags & 
GlyphItemFlags::IS_RTL_GLYPH); }
-bool IsDiacritic() const { return bool(m_nFlags & 
GlyphItemFlags::IS_DIACRITIC); }
 bool IsVertical() const { return bool(m_nFlags & 
GlyphItemFlags::IS_VERTICAL); }
 bool IsSpacing() const { return bool(m_nFlags & 
GlyphItemFlags::IS_SPACING); }
 bool IsDropped() const { return bool(m_nFlags & 
GlyphItemFlags::IS_DROPPED); }
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 6caeca7c86a1..ca7e1cd42f55 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -527,6 +527,15 @@ bool 
GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
 continue;
 }
 
+// For our purposes, a mark glyph is part of cluster as well.
+hb_face_t* pHbFace = hb_font_get_face(pHbFont);
+if (hb_ot_layout_get_glyph_class(pHbFace, nGlyphIndex) == 
HB_OT_LAYOUT_GLYPH_CLASS_MARK
+&& nCharPos != mnMinCharPos)
+{
+bClusterStart = false;
+bInCluster = true;
+}
+
 GlyphItemFlags nGlyphFlags = GlyphItemFlags::NONE;
 if (bRightToLeft)
 nGlyphFlags |= GlyphItemFlags::IS_RTL_GLYPH;
@@ -540,9 +549,6 @@ bool 
GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
 sal_UCS4 aChar
 = 
rArgs.mrStr.iterateCodePoints(::temporary(sal_Int32(nCharPos)), 0);
 
-if (u_getIntPropertyValue(aChar, UCHAR_GENERAL_CATEGORY) == 
U_NON_SPACING_MARK)
-nGlyphFlags |= GlyphItemFlags::IS_DIACRITIC;
-
 if (u_isUWhiteSpace(aChar))
 nGlyphFlags |= GlyphItemFlags::IS_SPACING;
 
@@ -792,14 +798,6 @@ void GenericSalLayout::ApplyDXArray(const double* 
pDXArray, const sal_Bool* pKas
 m_GlyphItems[j].adjustLinearPosX(nDelta + nDiff);
 }
 
-// Move any non-spacing marks to keep attached to this cluster.
-while (j > 0)
-{
-if (!m_GlyphItems[j].IsDiacritic())
-break;
-m_GlyphItems[j--].adjustLinearPosX(nDiff);
-}
-
 // This is a Kashida insertion position, mark it. Kashida glyphs
 // will be inserted below.
 if (pKashidaArray && pKashidaArray[nCharPos])
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index cf5ee9dca0f7..8fbbea859f2b 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -6616,11 +6616,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, 
const OUString& rText, bool
 if (pGlyph->IsClusterStart())
 bUseActualText = true;
 
-// Or part of a complex cluster, will be handled by the ActualText
-// of its cluster start.
-if (pGlyph->IsInCluster())
-assert(aCodeUnits.empty());
-
 

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

2022-10-01 Thread Khaled Hosny (via logerrit)
 vcl/inc/sft.hxx  |6 ++
 vcl/source/font/PhysicalFontFace.cxx |4 ++--
 vcl/source/fontsubset/sft.cxx|1 -
 3 files changed, 4 insertions(+), 7 deletions(-)

New commits:
commit dc9270d207af24c9b5cd775eda8997f3aad68f14
Author: Khaled Hosny 
AuthorDate: Sat Oct 1 17:27:46 2022 +0200
Commit: خالد حسني 
CommitDate: Sat Oct 1 19:47:48 2022 +0200

Unused constants

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index dc539ab958ac..25c8fe693c3a 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -448,7 +448,6 @@ constexpr sal_uInt32 T_post = 0x706F7374;
 constexpr sal_uInt32 T_cvt  = 0x63767420;
 constexpr sal_uInt32 T_prep = 0x70726570;
 constexpr sal_uInt32 T_fpgm = 0x6670676D;
-constexpr sal_uInt32 T_gsub = 0x47535542;
 constexpr sal_uInt32 T_CFF  = 0x43464620;
 
 class AbstractTrueTypeFont;
@@ -708,9 +707,8 @@ constexpr int O_post = 11;   /* 'post' */
 constexpr int O_cvt  = 12;   /* 'cvt_' - only used in TT->TT generation */
 constexpr int O_prep = 13;   /* 'prep' - only used in TT->TT generation */
 constexpr int O_fpgm = 14;   /* 'fpgm' - only used in TT->TT generation */
-constexpr int O_gsub = 15;   /* 'GSUB' */
-constexpr int O_CFF = 16;   /* 'CFF' */
-constexpr int NUM_TAGS = 17;
+constexpr int O_CFF = 15;   /* 'CFF' */
+constexpr int NUM_TAGS = 16;
 
 class VCL_DLLPUBLIC AbstractTrueTypeFont
 {
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index d1c02bbcc62d..05f9a4519b61 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -335,8 +335,8 @@ class TrueTypeFace final : public AbstractTrueTypeFont
 {
 assert(nIdx < NUM_TAGS);
 static const uint32_t aTags[NUM_TAGS] = {
-T_maxp, T_glyf, T_head, T_loca, T_name, T_hhea, T_hmtx, T_cmap, 
T_vhea,
-T_vmtx, T_OS2,  T_post, T_cvt,  T_prep, T_fpgm, T_gsub, T_CFF,
+T_maxp, T_glyf, T_head, T_loca, T_name, T_hhea, T_hmtx, T_cmap,
+T_vhea, T_vmtx, T_OS2,  T_post, T_cvt,  T_prep, T_fpgm, T_CFF,
 };
 if (m_aTableList[nIdx].empty())
 m_aTableList[nIdx] = std::move(m_aFace.GetTable(aTags[nIdx]));
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index a0961c36542c..2079cefbb1a6 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1356,7 +1356,6 @@ SFErrCodes TrueTypeFont::open(sal_uInt32 facenum)
 case T_cvt : nIndex = O_cvt;  break;
 case T_prep: nIndex = O_prep; break;
 case T_fpgm: nIndex = O_fpgm; break;
-case T_gsub: nIndex = O_gsub; break;
 case T_CFF:  nIndex = O_CFF; break;
 default: nIndex = -1; break;
 }


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

2022-10-01 Thread Khaled Hosny (via logerrit)
 vcl/inc/sft.hxx  |   16 -
 vcl/source/font/PhysicalFontFace.cxx |   36 +
 vcl/source/fontsubset/sft.cxx|   58 ---
 3 files changed, 36 insertions(+), 74 deletions(-)

New commits:
commit 054c8aade7cca8b6b482c16c5a80c5772522180c
Author: Khaled Hosny 
AuthorDate: Wed Sep 21 12:29:19 2022 +0200
Commit: خالد حسني 
CommitDate: Sat Oct 1 08:04:47 2022 +0200

vcl: Move TrueTypeFace where it is used

No need to make it module public. Easier to modify it.

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 780dd867d304..dc539ab958ac 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -453,7 +453,6 @@ constexpr sal_uInt32 T_CFF  = 0x43464620;
 
 class AbstractTrueTypeFont;
 class TrueTypeFont;
-class TrueTypeFace;
 
 /**
  * @defgroup sft Sun Font Tools Exported Functions
@@ -788,21 +787,6 @@ const sal_uInt8* TrueTypeFont::table(sal_uInt32 ord, 
sal_uInt32& size) const
 return rTable.pData;
 }
 
-class VCL_DLLPUBLIC TrueTypeFace final : public AbstractTrueTypeFont
-{
-const font::PhysicalFontFace& m_rFace;
-mutable std::array m_aTableList;
-
-static sal_uInt32 TableTag(sal_uInt32);
-
-public:
-TrueTypeFace(const font::PhysicalFontFace&);
-~TrueTypeFace() override;
-
-bool hasTable(sal_uInt32) const override;
-const sal_uInt8* table(sal_uInt32, sal_uInt32&) const override;
-};
-
 } // namespace vcl
 
 #endif // INCLUDED_VCL_INC_SFT_HXX
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 70738bbad06b..e649f8c7712e 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -296,6 +296,42 @@ bool 
PhysicalFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilit
 return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
 }
 
+namespace
+{
+class TrueTypeFace final : public AbstractTrueTypeFont
+{
+const PhysicalFontFace& m_rFace;
+mutable std::array m_aTableList;
+
+const RawFontData& table(sal_uInt32 nIdx) const
+{
+assert(nIdx < NUM_TAGS);
+static const uint32_t aTags[NUM_TAGS] = {
+T_maxp, T_glyf, T_head, T_loca, T_name, T_hhea, T_hmtx, T_cmap, 
T_vhea,
+T_vmtx, T_OS2,  T_post, T_cvt,  T_prep, T_fpgm, T_gsub, T_CFF,
+};
+if (m_aTableList[nIdx].empty())
+m_aTableList[nIdx] = 
std::move(m_rFace.GetRawFontData(aTags[nIdx]));
+return m_aTableList[nIdx];
+}
+
+public:
+TrueTypeFace(const PhysicalFontFace& rFace)
+: AbstractTrueTypeFont(nullptr, rFace.GetFontCharMap())
+, m_rFace(rFace)
+{
+}
+
+bool hasTable(sal_uInt32 nIdx) const override { return 
!table(nIdx).empty(); }
+const sal_uInt8* table(sal_uInt32 nIdx, sal_uInt32& nSize) const override
+{
+auto& rTable = table(nIdx);
+nSize = rTable.size();
+return rTable.data();
+}
+};
+}
+
 bool PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
 const sal_GlyphId* pGlyphIds, const 
sal_uInt8* pEncoding,
 const int nGlyphCount, FontSubsetInfo& 
rInfo) const
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index deb18ff73177..a0961c36542c 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1211,64 +1211,6 @@ TrueTypeFont::~TrueTypeFont()
 #endif
 }
 
-TrueTypeFace::TrueTypeFace(const font::PhysicalFontFace& rFace)
-: AbstractTrueTypeFont(nullptr, rFace.GetFontCharMap())
-, m_rFace(rFace)
-{
-}
-
-TrueTypeFace::~TrueTypeFace()
-{
-}
-
-sal_uInt32 TrueTypeFace::TableTag(sal_uInt32 nIdx)
-{
-switch (nIdx)
-{
-case O_cmap: return T_cmap;
-case O_cvt: return T_cvt;
-case O_fpgm: return T_fpgm;
-case O_glyf: return T_glyf;
-case O_gsub: return T_gsub;
-case O_head: return T_head;
-case O_hhea: return T_hhea;
-case O_hmtx: return T_hmtx;
-case O_loca: return T_loca;
-case O_maxp: return T_maxp;
-case O_name: return T_name;
-case O_post: return T_post;
-case O_prep: return T_prep;
-case O_vhea: return T_vhea;
-case O_vmtx: return T_vmtx;
-case O_OS2: return T_OS2;
-case O_CFF: return T_CFF;
-default:
-assert(false);
-return 0;
-}
-}
-
-bool TrueTypeFace::hasTable(sal_uInt32 nIdx) const
-{
-uint32_t nTag = TableTag(nIdx);
-if (!nTag)
-return false;
-if (m_aTableList[nIdx].empty())
-m_aTableList[nIdx] = std::move(m_rFace.GetRawFontData(nTag));
-return !m_aTableList[nIdx].empty();
-}
-
-const sal_uInt8* TrueTypeFace::table(sal_uInt32 nIdx, 

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

2022-09-30 Thread Khaled Hosny (via logerrit)
 vcl/inc/impfontmetricdata.hxx  |2 -
 vcl/source/font/fontmetric.cxx |   42 ++---
 vcl/source/outdev/font.cxx |2 -
 vcl/source/outdev/textline.cxx |2 -
 4 files changed, 14 insertions(+), 34 deletions(-)

New commits:
commit 8da2560a8ddb530abe4fb72b59ef6e18ce219d80
Author: Khaled Hosny 
AuthorDate: Fri Sep 30 19:11:14 2022 +0200
Commit: خالد حسني 
CommitDate: Fri Sep 30 20:55:18 2022 +0200

vcl: Use the same underline sizes for overlines

It makes no since to have overline of different sizes than underlines,
and in fonts with big ascenders (like Amiri), we end up calculating much
thicker overline than underline.

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

diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx
index 0fb44a840bda..a94e41540755 100644
--- a/vcl/inc/impfontmetricdata.hxx
+++ b/vcl/inc/impfontmetricdata.hxx
@@ -96,7 +96,7 @@ public:
 tools::LongGetDoubleStrikeoutOffset2() const   
{ return mnDStrikeoutOffset2; }
 
 voidImplInitTextLineSize( const OutputDevice* pDev );
-voidImplInitAboveTextLineSize();
+voidImplInitAboveTextLineSize( const OutputDevice* pDev );
 voidImplInitFlags( const OutputDevice* pDev );
 voidImplCalcLineSpacing(LogicalFontInstance *pFontInstance);
 voidImplInitBaselines(LogicalFontInstance *pFontInstance);
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 3895caf7b0fb..cdae023f0b50 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -323,8 +323,10 @@ void ImplFontMetricData::ImplInitTextLineSize( const 
OutputDevice* pDev )
 }
 
 
-void ImplFontMetricData::ImplInitAboveTextLineSize()
+void ImplFontMetricData::ImplInitAboveTextLineSize( const OutputDevice* pDev )
 {
+ImplInitTextLineSize(pDev);
+
 tools::Long nIntLeading = mnIntLeading;
 // TODO: assess usage of nLeading below (changed in extleading CWS)
 // if no leading is available, we assume 15% of the ascent
@@ -335,41 +337,19 @@ void ImplFontMetricData::ImplInitAboveTextLineSize()
 nIntLeading = 1;
 }
 
-tools::Long nLineHeight = ((nIntLeading*25)+50) / 100;
-if ( !nLineHeight )
-nLineHeight = 1;
-
-tools::Long nBLineHeight = ((nIntLeading*50)+50) / 100;
-if ( nBLineHeight == nLineHeight )
-nBLineHeight++;
-
-tools::Long n2LineHeight = ((nIntLeading*16)+50) / 100;
-if ( !n2LineHeight )
-n2LineHeight = 1;
-
 tools::Long nCeiling = -mnAscent;
 
-mnAboveUnderlineSize   = nLineHeight;
-mnAboveUnderlineOffset = nCeiling + (nIntLeading - nLineHeight + 1) / 
2;
-
-mnAboveBUnderlineSize  = nBLineHeight;
-mnAboveBUnderlineOffset= nCeiling + (nIntLeading - nBLineHeight + 1) / 
2;
+mnAboveUnderlineSize   = mnUnderlineSize;
+mnAboveUnderlineOffset = nCeiling + (nIntLeading - mnUnderlineSize + 
1) / 2;
 
-mnAboveDUnderlineSize  = n2LineHeight;
-mnAboveDUnderlineOffset1   = nCeiling + (nIntLeading - 3*n2LineHeight + 1) 
/ 2;
-mnAboveDUnderlineOffset2   = nCeiling + (nIntLeading +   n2LineHeight + 1) 
/ 2;
+mnAboveBUnderlineSize  = mnBUnderlineSize;
+mnAboveBUnderlineOffset= nCeiling + (nIntLeading - mnBUnderlineSize + 
1) / 2;
 
-tools::Long nWCalcSize = nIntLeading;
-if ( nWCalcSize < 6 )
-{
-if ( (nWCalcSize == 1) || (nWCalcSize == 2) )
-mnAboveWUnderlineSize = nWCalcSize;
-else
-mnAboveWUnderlineSize = 3;
-}
-else
-mnAboveWUnderlineSize = ((nWCalcSize*50)+50) / 100;
+mnAboveDUnderlineSize  = mnDUnderlineSize;
+mnAboveDUnderlineOffset1   = nCeiling + (nIntLeading - 3*mnDUnderlineSize 
+ 1) / 2;
+mnAboveDUnderlineOffset2   = nCeiling + (nIntLeading +   mnDUnderlineSize 
+ 1) / 2;
 
+mnAboveWUnderlineSize = mnWUnderlineSize;
 mnAboveWUnderlineOffset = nCeiling + (nIntLeading + 1) / 2;
 }
 
diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx
index 51a8689e2610..ec24bc9abc6b 100644
--- a/vcl/source/outdev/font.cxx
+++ b/vcl/source/outdev/font.cxx
@@ -755,7 +755,7 @@ bool OutputDevice::ImplNewFont() const
 mpGraphics->GetFontMetric( pFontInstance->mxFontMetric, 0 );
 
 pFontInstance->mxFontMetric->ImplInitTextLineSize( this );
-pFontInstance->mxFontMetric->ImplInitAboveTextLineSize();
+pFontInstance->mxFontMetric->ImplInitAboveTextLineSize( this );
 pFontInstance->mxFontMetric->ImplInitFlags( this );
 
 pFontInstance->mnLineHeight = pFontInstance->mxFontMetric->GetAscent() 
+ pFontInstance->mxFontMetric->GetDescent();
diff --git a/vcl/source/outdev/textline.cxx 

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

2022-09-30 Thread Khaled Hosny (via logerrit)
 vcl/inc/impfontmetricdata.hxx  |1 
 vcl/source/font/fontmetric.cxx |   61 +++--
 2 files changed, 60 insertions(+), 2 deletions(-)

New commits:
commit ba03e033d1be4bc49f2a8d6afbeecd381507b242
Author: Khaled Hosny 
AuthorDate: Fri Sep 30 18:36:59 2022 +0200
Commit: خالد حسني 
CommitDate: Fri Sep 30 20:54:47 2022 +0200

vcl: Use font’s underline/strike position and size

This respects the values set by font designer, which are usually better
than the values we calculate especially for fonts with deep descenders
(like Amiri).

Old code is kept as fallback in case the font does not provide such
values.

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

diff --git a/vcl/inc/impfontmetricdata.hxx b/vcl/inc/impfontmetricdata.hxx
index d5b244309047..0fb44a840bda 100644
--- a/vcl/inc/impfontmetricdata.hxx
+++ b/vcl/inc/impfontmetricdata.hxx
@@ -102,6 +102,7 @@ public:
 voidImplInitBaselines(LogicalFontInstance *pFontInstance);
 
 private:
+boolImplInitTextLineSizeHarfBuzz(LogicalFontInstance 
*pFontInstance);
 boolShouldUseWinMetrics(int, int, int, int, int, int) const;
 
 // font instance attributes from the font request
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 95263c694b3b..3895caf7b0fb 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -176,8 +176,67 @@ ImplFontMetricData::ImplFontMetricData( const 
vcl::font::FontSelectPattern& rFon
 SetStyleName( rFontSelData.GetStyleName() );
 }
 
+bool ImplFontMetricData::ImplInitTextLineSizeHarfBuzz(LogicalFontInstance* 
pFont)
+{
+auto* pHbFont = pFont->GetHbFont();
+double fScale = 0;
+pFont->GetScale(nullptr, );
+
+hb_position_t nUnderlineSize, nUnderlineOffset, nStrikeoutSize, 
nStrikeoutOffset;
+if (hb_ot_metrics_get_position(pHbFont, HB_OT_METRICS_TAG_UNDERLINE_SIZE, 
)
+&& hb_ot_metrics_get_position(pHbFont, 
HB_OT_METRICS_TAG_UNDERLINE_OFFSET,
+  )
+&& hb_ot_metrics_get_position(pHbFont, 
HB_OT_METRICS_TAG_STRIKEOUT_SIZE, )
+&& hb_ot_metrics_get_position(pHbFont, 
HB_OT_METRICS_TAG_STRIKEOUT_OFFSET,
+  ))
+{
+double nOffset = -nUnderlineOffset;
+double nSize = nUnderlineSize;
+double nSize2 = nSize / 2.;
+double nBSize = nSize * 2.;
+double n2Size = nBSize / 3.;
+
+mnUnderlineSize = round(nSize * fScale);
+mnUnderlineOffset = round(nOffset * fScale);
+
+mnBUnderlineSize = round(nBSize * fScale);
+mnBUnderlineOffset = round((nOffset - nSize2) * fScale);
+
+mnDUnderlineSize = round(n2Size * fScale);
+mnDUnderlineOffset1 = mnBUnderlineOffset;
+mnDUnderlineOffset2 = round((nOffset - nSize2 - n2Size + nBSize) * 
fScale);
+
+mnWUnderlineSize = mnBUnderlineSize;
+mnWUnderlineOffset = round((nOffset + nSize) * fScale);
+
+nOffset = -nStrikeoutOffset;
+nSize = nStrikeoutSize;
+nSize2 = nSize / 2.;
+nBSize = nSize * 2.;
+n2Size = nBSize / 3.;
+
+mnStrikeoutSize = round(nSize * fScale);
+mnStrikeoutOffset = round(nOffset * fScale);
+
+mnBStrikeoutSize = round(nBSize * fScale);
+mnBStrikeoutOffset = round((nOffset - nSize2) * fScale);
+
+mnDStrikeoutSize = round(n2Size * fScale);
+mnDStrikeoutOffset1 = mnBStrikeoutOffset;
+mnDStrikeoutOffset2 = round((nOffset - nSize2 - n2Size + nBSize) * 
fScale);
+
+return true;
+}
+return false;
+}
+
 void ImplFontMetricData::ImplInitTextLineSize( const OutputDevice* pDev )
 {
+mnBulletOffset = ( pDev->GetTextWidth( OUString( u' ' ) ) - 
pDev->GetTextWidth( OUString( u'\x00b7' ) ) ) >> 1 ;
+
+if 
(ImplInitTextLineSizeHarfBuzz(const_cast(pDev->GetFontInstance(
+return;
+
 tools::Long nDescent = mnDescent;
 if ( nDescent <= 0 )
 {
@@ -261,8 +320,6 @@ void ImplFontMetricData::ImplInitTextLineSize( const 
OutputDevice* pDev )
 mnDStrikeoutOffset1= nStrikeoutOffset - n2LineDY2 - n2LineHeight;
 mnDStrikeoutOffset2= mnDStrikeoutOffset1 + n2LineDY + n2LineHeight;
 
-mnBulletOffset = ( pDev->GetTextWidth( OUString( u' ' ) ) - 
pDev->GetTextWidth( OUString( u'\x00b7' ) ) ) >> 1 ;
-
 }
 
 


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

2022-09-24 Thread Noel Grandin (via logerrit)
 vcl/inc/fontsubset.hxx   |5 
 vcl/inc/sft.hxx  |6 -
 vcl/source/fontsubset/cff.cxx|   19 +--
 vcl/source/fontsubset/fontsubset.cxx |2 
 vcl/source/fontsubset/sft.cxx|  182 ++-
 vcl/unx/generic/print/glyphset.cxx   |   20 +--
 6 files changed, 142 insertions(+), 92 deletions(-)

New commits:
commit a0e674851896d2d8e869474db067b7698293c02a
Author: Noel Grandin 
AuthorDate: Thu Sep 22 20:41:33 2022 +0200
Commit: Noel Grandin 
CommitDate: Sat Sep 24 16:19:17 2022 +0200

use faster TempFile for font subset writing

by not asking for the name or URL, we stay on the happy path,
which is faster on Windows

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

diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx
index fef6603cd2fd..cb4cb34dd979 100644
--- a/vcl/inc/fontsubset.hxx
+++ b/vcl/inc/fontsubset.hxx
@@ -29,6 +29,7 @@
 #include "glyphid.hxx"
 
 namespace vcl { class TrueTypeFont; } ///< SFT's idea of a TTF font
+class SvStream;
 
 enum class FontType {
 NO_FONT = 0,
@@ -57,7 +58,7 @@ public:
 voidLoadFont( vcl::TrueTypeFont* pSftTrueTypeFont );
 
 boolCreateFontSubset( FontType nOutFontTypeMask,
-FILE* pOutFile, const char* pOutFontName,
+SvStream* pOutFile, const char* pOutFontName,
 const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncodedIds,
 int nReqGlyphCount);
 
@@ -79,7 +80,7 @@ private:
 
 // subset-request details
 FontTypemnReqFontTypeMask;  ///< allowed subset-target 
font types
-FILE*   mpOutFile;
+SvStream*   mpOutFile;
 const char* mpReqFontName;
 const sal_GlyphId*  mpReqGlyphIds;
 const sal_uInt8*mpReqEncodedIds;
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 05f62de655ec..3b72df3826a8 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -52,6 +52,8 @@
 
 #include "font/PhysicalFontFace.hxx"
 
+class SvStream;
+
 namespace vcl
 {
 
@@ -582,7 +584,7 @@ class TrueTypeFace;
  * @ingroup sft
  *
  */
-SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char 
*fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int 
wmode);
+SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, SvStream *outf, const 
char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, 
int wmode);
 
 /**
  * Generates a new TrueType font and dumps it to outf file.
@@ -644,7 +646,7 @@ class TrueTypeFace;
  *
  */
 SFErrCodes CreateT42FromTTGlyphs(TrueTypeFont  *ttf,
-   FILE  *outf,
+   SvStream  *outf,
const char*psname,
sal_uInt16 const *glyphArray,
sal_uInt8  *encoding,
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx
index f22ab23f6e12..8d8700308bed 100644
--- a/vcl/source/fontsubset/cff.cxx
+++ b/vcl/source/fontsubset/cff.cxx
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 
 typedef sal_uInt8 U8;
 typedef sal_uInt16 U16;
@@ -1610,7 +1611,7 @@ namespace {
 class Type1Emitter
 {
 public:
-explicitType1Emitter( FILE* pOutFile, bool bPfbSubset);
+explicitType1Emitter( SvStream* pOutFile, bool bPfbSubset);
 ~Type1Emitter();
 voidsetSubsetName( const char* );
 
@@ -1622,7 +1623,7 @@ public:
 voidupdateLen( int nTellPos, size_t nLength);
 voidemitValVector( const char* pLineHead, const char* pLineTail, 
const std::vector&);
 private:
-FILE*   mpFileOut;
+SvStream*   mpFileOut;
 charmaBuffer[MAX_T1OPS_SIZE];   // TODO: dynamic allocation
 unsignedmnEECryptR;
 public:
@@ -1635,7 +1636,7 @@ public:
 
 }
 
-Type1Emitter::Type1Emitter( FILE* pOutFile, bool bPfbSubset)
+Type1Emitter::Type1Emitter( SvStream* pOutFile, bool bPfbSubset)
 :   mpFileOut( pOutFile)
 ,   maBuffer{}
 ,   mnEECryptR( 55665)  // default eexec seed, TODO: mnEECryptSeed
@@ -1663,7 +1664,7 @@ void Type1Emitter::setSubsetName( const char* pSubsetName)
 
 int Type1Emitter::tellPos() const
 {
-int nTellPos = ftell( mpFileOut);
+int nTellPos = mpFileOut->Tell();
 return nTellPos;
 }
 
@@ -1675,18 +1676,18 @@ void Type1Emitter::updateLen( int nTellPos, size_t 
nLength)
 cData[1] = static_cast(nLength >>  8);
 cData[2] = static_cast(nLength >> 16);
 cData[3] = static_cast(nLength >> 24);
-const tools::Long nCurrPos = ftell(mpFileOut);
+const tools::Long nCurrPos = mpFileOut->Tell();
 if (nCurrPos < 0)
 return;
-if (fseek( mpFileOut, nTellPos, SEEK_SET) != 0)
+if (mpFileOut->Seek(nTellPos) != 

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

2022-09-23 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx|2 ++
 vcl/source/font/PhysicalFontFace.cxx |   19 +++
 vcl/source/gdi/pdfwriter_impl.cxx|6 --
 3 files changed, 25 insertions(+), 2 deletions(-)

New commits:
commit 2e2765ec4ab05ee4745125f56b907f74e7426eaf
Author: Khaled Hosny 
AuthorDate: Fri Sep 23 07:23:33 2022 +0200
Commit: خالد حسني 
CommitDate: Fri Sep 23 12:28:49 2022 +0200

vcl: Use glyph names from the font in Type 3 fonts

Some PDF viewers might use glyph names to guess corresponding character,
and it also makes debugging the PDF output a little bit easier.

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

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 3297feff87dc..3d7fa0cba71d 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -180,6 +180,8 @@ public:
 bool HasColorBitmaps() const;
 RawFontData GetGlyphColorBitmap(sal_GlyphId, tools::Rectangle&) const;
 
+OString GetGlyphName(sal_GlyphId, bool = false) const;
+
 uint32_t UnitsPerEm() const { return hb_face_get_upem(GetHbFace()); }
 
 OUString GetName(NameID, const LanguageTag&) const;
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 337995964389..70738bbad06b 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -399,6 +399,25 @@ RawFontData 
PhysicalFontFace::GetGlyphColorBitmap(sal_GlyphId nGlyphIndex,
 return aData;
 }
 
+OString PhysicalFontFace::GetGlyphName(sal_GlyphId nGlyphIndex, bool 
bValidate) const
+{
+char aBuffer[256];
+hb_font_glyph_to_string(GetHbUnscaledFont(), nGlyphIndex, aBuffer, 256);
+if (bValidate)
+{
+// 
https://learn.microsoft.com/en-us/typography/opentype/spec/post#version-20
+// Valid characters are limited to A–Z, a–z, 0–9, “.” (FULL STOP), and 
“_” (LOW LINE).
+const char* p = aBuffer;
+while ((*p >= '0' && *p <= '9') || (*p >= 'A' && *p <= 'Z') || (*p >= 
'a' && *p <= 'z')
+   || *p == '.' || *p == '_')
+++p;
+if (*p != '\0')
+return "g" + OString::number(nGlyphIndex);
+}
+
+return OString(aBuffer);
+}
+
 OUString PhysicalFontFace::GetName(NameID aNameID, const LanguageTag& 
rLanguageTag) const
 {
 auto pHbFace = GetHbFace();
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 83887db1a4dc..a381d9287c4e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2500,7 +2500,9 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
 for (auto i = 1u; i < nGlyphs; i++)
 {
 auto nStream = createObject();
-aLine.append("/g" + OString::number(i) + " ");
+aLine.append("/");
+aLine.append(pFace->GetGlyphName(pGlyphIds[i], true));
+aLine.append(" ");
 aLine.append(nStream);
 aLine.append(" 0 R\n");
 pGlyphStreams[i] = nStream;
@@ -2509,7 +2511,7 @@ bool PDFWriterImpl::emitType3Font(const 
vcl::font::PhysicalFontFace* pFace,
 
 aLine.append("/Encoding>\n");
 
 aLine.append("/FirstChar 0\n"


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

2022-09-23 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx|   13 ++
 vcl/inc/pdf/pdfwriter_impl.hxx   |   15 ++
 vcl/source/font/PhysicalFontFace.cxx |   37 ++
 vcl/source/fontsubset/sft.cxx|6 -
 vcl/source/gdi/pdfwriter_impl.cxx|  206 ---
 5 files changed, 214 insertions(+), 63 deletions(-)

New commits:
commit 77cce80bb56801acf22da2149bd597d0d7793e3b
Author: Khaled Hosny 
AuthorDate: Thu Sep 22 23:35:12 2022 +0200
Commit: خالد حسني 
CommitDate: Fri Sep 23 12:28:15 2022 +0200

vcl: tdf#121327 PDF export for bitmap color fonts

This change extracts the PNG data from the sbix/CBDT tables and embeds
them as PDF Type 3 glyphs. In case the font supports both color layers
and color bitmaps, the color layer take priority.

This also reverts the part of the following commit that allowed bitmap
fonts when creating font subsets because this is not needed now as the
such fonts will now not reach the subsetting code.

commit dcf7792da2aa2a1ef774a124f7b21f68fff0fd15
Author: Khaled Hosny 
Date:   Tue Aug 27 15:19:15 2019 +0200

Make Noto Color Emoji font work on Linux

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

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 5c4ab2eea046..3297feff87dc 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -67,6 +67,11 @@ public:
 {
 }
 
+RawFontData(const RawFontData& rOther)
+: mpBlob(hb_blob_reference(rOther.mpBlob))
+{
+}
+
 ~RawFontData() { hb_blob_destroy(mpBlob); }
 
 RawFontData& operator=(const RawFontData& rOther)
@@ -166,10 +171,15 @@ public:
 bool CreateFontSubset(std::vector&, const sal_GlyphId*, const 
sal_uInt8*, const int,
   FontSubsetInfo&) const;
 
+bool IsColorFont() const { return HasColorLayers() || HasColorBitmaps(); }
+
 bool HasColorLayers() const;
 const ColorPalette& GetColorPalette(size_t) const;
 std::vector GetGlyphColorLayers(sal_GlyphId) const;
 
+bool HasColorBitmaps() const;
+RawFontData GetGlyphColorBitmap(sal_GlyphId, tools::Rectangle&) const;
+
 uint32_t UnitsPerEm() const { return hb_face_get_upem(GetHbFace()); }
 
 OUString GetName(NameID, const LanguageTag&) const;
@@ -184,12 +194,15 @@ public:
 
 protected:
 mutable hb_face_t* mpHbFace;
+mutable hb_font_t* mpHbUnscaledFont;
 mutable FontCharMapRef mxCharMap;
 mutable vcl::FontCapabilities maFontCapabilities;
 mutable bool mbFontCapabilitiesRead;
 mutable std::vector maColorPalettes;
 
 explicit PhysicalFontFace(const FontAttributes&);
+
+hb_font_t* GetHbUnscaledFont() const;
 };
 }
 
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 942d57a26fbb..afb80c2aa403 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -297,6 +297,8 @@ class GlyphEmit
 sal_uInt8   m_nSubsetGlyphID;
 sal_Int32   m_nGlyphWidth;
 std::vector m_aColorLayers;
+font::RawFontData   m_aColorBitmap;
+tools::Rectanglem_aRect;
 
 public:
 GlyphEmit() : m_nSubsetGlyphID(0), m_nGlyphWidth(0)
@@ -312,6 +314,17 @@ public:
 void addColorLayer(ColorLayer aLayer) { m_aColorLayers.push_back(aLayer); }
 const std::vector& getColorLayers() const { return 
m_aColorLayers; }
 
+void setColorBitmap(font::RawFontData aData, tools::Rectangle aRect)
+{
+m_aColorBitmap = aData;
+m_aRect = aRect;
+}
+const font::RawFontData& getColorBitmap(tools::Rectangle& rRect) const
+{
+rRect = m_aRect;
+return m_aColorBitmap;
+}
+
 void addCode( sal_Ucs i_cCode )
 {
 m_CodeUnits.push_back(i_cCode);
@@ -866,6 +879,7 @@ i12626
 
 /* tries to find the bitmap by its id and returns its emit data if exists,
else creates a new emit data block */
+const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const 
Graphic& rGraphic, std::list& rBitmaps, ResourceDict& 
rResourceDict, std::list& rOutputStreams );
 const BitmapEmit& createBitmapEmit( const BitmapEx& rBitmapEx, const 
Graphic& rGraphic );
 
 /* writes the Do operation inside the content stream */
@@ -906,6 +920,7 @@ i12626
 return m_nFontDictObject;
 }
 /* push resource into current (redirected) resource dict */
+static void pushResource( ResourceKind eKind, const OString& rResource, 
sal_Int32 nObject, ResourceDict& rResourceDict, std::list& 
rOutputStreams );
 void pushResource( ResourceKind eKind, const OString& rResource, sal_Int32 
nObject );
 
 void appendBuildinFontsToDict( OStringBuffer& rDict ) const;
diff --git a/vcl/source/font/PhysicalFontFace.cxx 

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

2022-09-22 Thread Caolán McNamara (via logerrit)
 vcl/inc/ppdparser.hxx |8 ++--
 vcl/source/gdi/print.cxx  |1 +
 vcl/unx/generic/print/genprnpsp.cxx   |   14 --
 vcl/unx/generic/printer/ppdparser.cxx |   29 +
 4 files changed, 40 insertions(+), 12 deletions(-)

New commits:
commit 6005aeca4416eb0d583fd12ab837afa91d9d18ec
Author: Caolán McNamara 
AuthorDate: Wed Sep 21 22:22:38 2022 +0200
Commit: Caolán McNamara 
CommitDate: Thu Sep 22 19:40:02 2022 +0200

tdf#151107 swap job orientation if paper matching swapped width/height

if we eventually are forced to pick a final paper size which has the
orthogonal orientation than that requested, then swap the orientation of
the jobdata too

and re-init the orientation to defaults in Printer::SetPaperSizeUser
when we set a new user paper size rather than keeping the orig

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

diff --git a/vcl/inc/ppdparser.hxx b/vcl/inc/ppdparser.hxx
index 5d4195783a68..7ef864bc9cfc 100644
--- a/vcl/inc/ppdparser.hxx
+++ b/vcl/inc/ppdparser.hxx
@@ -36,6 +36,8 @@
 
 namespace psp {
 
+enum class orientation;
+
 class PPDCache;
 class PPDTranslator;
 
@@ -110,7 +112,6 @@ struct PPDKeyhash
 { return reinterpret_cast(pKey); }
 };
 
-
 /*
  * PPDParser - parses a PPD file and contains all available keys from it
  */
@@ -177,6 +178,9 @@ private:
 static void scanPPDDir( const OUString& rDir );
 static void initPPDFiles(PPDCache );
 static OUString getPPDFile( const OUString& rFile );
+
+OUStringmatchPaperImpl(int nWidth, int nHeight, bool bDontSwap = 
false, psp::orientation* pOrientation = nullptr) const;
+
 public:
 ~PPDParser();
 static const PPDParser* getParser( const OUString& rFile );
@@ -201,7 +205,7 @@ public:
 // returns false if paper not found
 
 // match the best paper for width and height
-OUStringmatchPaper( int nWidth, int nHeight, bool bDontSwap = 
false ) const;
+OUStringmatchPaper( int nWidth, int nHeight, psp::orientation* 
pOrientation = nullptr ) const;
 
 bool getMargins( std::u16string_view rPaperName,
  int , int& rRight,
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 5300de9a881d..6225db3a6b35 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1347,6 +1347,7 @@ bool Printer::SetPaperSizeUser( const Size& rSize )
 rData.SetPaperFormat( PAPER_USER );
 rData.SetPaperWidth( aPageSize.Width() );
 rData.SetPaperHeight( aPageSize.Height() );
+rData.SetOrientation( Orientation::Portrait );
 
 if ( IsDisplayPrinter() )
 {
diff --git a/vcl/unx/generic/print/genprnpsp.cxx 
b/vcl/unx/generic/print/genprnpsp.cxx
index 5c17874c4dfb..30c4f884a041 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -569,6 +569,10 @@ bool PspSalInfoPrinter::SetData(
 const PPDKey* pKey;
 const PPDValue* pValue;
 
+// merge orientation if necessary
+if( nSetDataFlags & JobSetFlags::ORIENTATION )
+aData.m_eOrientation = pJobSetup->GetOrientation() == 
Orientation::Landscape ? orientation::Landscape : orientation::Portrait;
+
 // merge papersize if necessary
 if( nSetDataFlags & JobSetFlags::PAPERSIZE )
 {
@@ -577,7 +581,8 @@ bool PspSalInfoPrinter::SetData(
 if( pJobSetup->GetPaperFormat() == PAPER_USER )
 aPaper = aData.m_pParser->matchPaper(
 TenMuToPt( pJobSetup->GetPaperWidth() ),
-TenMuToPt( pJobSetup->GetPaperHeight() ) );
+TenMuToPt( pJobSetup->GetPaperHeight() ),
+_eOrientation );
 else
 aPaper = 
OStringToOUString(PaperInfo::toPSName(pJobSetup->GetPaperFormat()), 
RTL_TEXTENCODING_ISO_8859_1);
 
@@ -591,7 +596,8 @@ bool PspSalInfoPrinter::SetData(
 PaperInfo aInfo( pJobSetup->GetPaperFormat() );
 aPaper = aData.m_pParser->matchPaper(
 TenMuToPt( aInfo.getWidth() ),
-TenMuToPt( aInfo.getHeight() ) );
+TenMuToPt( aInfo.getHeight() ),
+_eOrientation );
 pValue = pKey->getValueCaseInsensitive( aPaper );
 }
 
@@ -619,10 +625,6 @@ bool PspSalInfoPrinter::SetData(
 // (e.g. SGENPRT has no InputSlot)
 }
 
-// merge orientation if necessary
-if( nSetDataFlags & JobSetFlags::ORIENTATION )
-aData.m_eOrientation = pJobSetup->GetOrientation() == 
Orientation::Landscape ? orientation::Landscape : orientation::Portrait;
-
 // merge duplex if necessary
 if( nSetDataFlags & JobSetFlags::DUPLEXMODE )
 {
diff --git 

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

2022-09-22 Thread Noel Grandin (via logerrit)
 vcl/inc/sft.hxx |   26 
 vcl/inc/unx/fontmanager.hxx |3 
 vcl/source/fontsubset/sft.cxx   |  190 ++---
 vcl/source/fontsubset/ttcr.cxx  |  930 +---
 vcl/source/fontsubset/ttcr.hxx  |  242 ---
 vcl/unx/generic/fontmanager/fontmanager.cxx |   63 -
 6 files changed, 598 insertions(+), 856 deletions(-)

New commits:
commit 590796ca0866168e3129d2abd0a0197114cddcdc
Author: Noel Grandin 
AuthorDate: Wed Sep 21 20:44:42 2022 +0200
Commit: Noel Grandin 
CommitDate: Thu Sep 22 14:48:27 2022 +0200

convert TrueTypeTable to C++ class

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index a870baf57033..05f62de655ec 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -124,7 +124,7 @@ namespace vcl
 typedef struct {
 sal_uInt32 glyphID; /**< glyph ID  
 */
 sal_uInt16 nbytes;  /**< number of bytes in glyph 
data  */
-sal_uInt8  *ptr; /**< pointer to glyph data
  */
+std::unique_ptr ptr;   /**< pointer to glyph data 
 */
 sal_uInt16 aw;  /**< advance width 
 */
 sal_Int16  lsb; /**< left sidebearing  
 */
 bool compflag;  /**< false- if non-composite */
@@ -135,14 +135,13 @@ namespace vcl
 } GlyphData;
 
 /** Structure used by the TrueType Creator and CreateTTFromTTGlyphs() */
-typedef struct {
+struct NameRecord {
 sal_uInt16 platformID;  /**< Platform ID   
 */
 sal_uInt16 encodingID;  /**< Platform-specific 
encoding ID  */
 LanguageType languageID;/**< Language ID   
 */
 sal_uInt16 nameID;  /**< Name ID   
 */
-sal_uInt16 slen;/**< String length in bytes
 */
-sal_uInt8  *sptr;/**< Pointer to string data 
(not zero-terminated!)  */
-} NameRecord;
+std::vector sptr;/**< string data (not 
zero-terminated!)  */
+};
 
 /** Return value of GetTTGlobalFontInfo() */
 
@@ -535,7 +534,7 @@ class TrueTypeFace;
  * @ingroup sft
  *
  */
-GlyphData *GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 
glyphID);
+std::unique_ptr GetTTRawGlyphData(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID);
 
 /**
  * For a specified glyph adds all component glyphs IDs to the list and
@@ -559,23 +558,12 @@ class TrueTypeFace;
  * array of NameRecord structs
  *
  * @param ttf   pointer to the TrueTypeFont struct
- * @param nrpointer to the array of NameRecord structs
+ * @param nrreference to the vector of NameRecord structs
  *
- * @return  number of NameRecord structs
  * @ingroup sft
  */
 
-int GetTTNameRecords(AbstractTrueTypeFont const *ttf, NameRecord **nr);
-
-/**
- * Deallocates previously allocated array of NameRecords.
- *
- * @param nrarray of NameRecord structs
- * @param n number of elements in the array
- *
- * @ingroup sft
- */
-void DisposeNameRecords(NameRecord* nr, int n);
+void GetTTNameRecords(AbstractTrueTypeFont const *ttf, 
std::vector& nr);
 
 /**
  * Generates a new PostScript Type 3 font and dumps it to outf file.
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index 059ffe1a7e58..2ec06afcb435 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -50,6 +50,7 @@ namespace vcl::font
 {
 class FontSelectPattern;
 }
+namespace vcl { struct NameRecord; }
 class GenericUnixSalData;
 
 namespace psp {
@@ -154,7 +155,7 @@ class VCL_PLUGIN_PUBLIC PrintFontManager
 OString getFontFile(const PrintFont& rFont) const;
 
 std::vector analyzeFontFile(int nDirID, const OString& 
rFileName, const char *pFormat=nullptr) const;
-static OUString convertSfntName( void* pNameRecord ); // actually a 
NameRecord* format font subsetting code
+static OUString convertSfntName( const vcl::NameRecord& rNameRecord ); // 
format font subsetting code
 static void analyzeSfntFamilyName( void const * pTTFont, std::vector< 
OUString >& rnames ); // actually a TrueTypeFont* from font subsetting code
 bool analyzeSfntFile(PrintFont& rFont) const;
 // finds the font id for the nFaceIndex face in this font file
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 4058caef2faf..4c2bb4b3e062 100644
--- 

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

2022-09-20 Thread Noel Grandin (via logerrit)
 vcl/inc/sft.hxx |   62 +++---
 vcl/source/font/font.cxx|   12 +-
 vcl/source/fontsubset/sft.cxx   |  118 
 vcl/unx/generic/fontmanager/fontmanager.cxx |   10 +-
 4 files changed, 93 insertions(+), 109 deletions(-)

New commits:
commit 2e932f8aeb62ec05057c680ae23fc0fb3ed4f978
Author: Noel Grandin 
AuthorDate: Mon Sep 19 21:46:48 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Sep 20 13:17:47 2022 +0200

use O[U]String in TrueType code

instead of manual memory management

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index c1d2c5c8e3fe..a870baf57033 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -147,33 +147,33 @@ namespace vcl
 /** Return value of GetTTGlobalFontInfo() */
 
 typedef struct TTGlobalFontInfo_ {
-char *family; /**< family name 
*/
-sal_Unicode *ufamily; /**< family name UCS2
 */
-char *subfamily;  /**< subfamily name  
*/
-sal_Unicode *usubfamily;  /**< subfamily name UCS2 */
-char *psname; /**< PostScript name 
*/
-sal_uInt16 macStyle;  /**< macstyle bits from 'HEAD' table */
-int   weight; /**< value of WeightClass or 0 if can't be 
determined*/
-int   width;  /**< value of WidthClass or 0 if can't be 
determined */
-int   pitch;  /**< 0: proportional font, otherwise: 
monospaced */
-int   italicAngle;/**< in counter-clockwise degrees * 65536
*/
-int   xMin;   /**< global bounding box: xMin   
*/
-int   yMin;   /**< global bounding box: yMin   
*/
-int   xMax;   /**< global bounding box: xMax   
*/
-int   yMax;   /**< global bounding box: yMax   
*/
-int   ascender;   /**< typographic ascent. 
*/
-int   descender;  /**< typographic descent.
*/
-int   linegap;/**< typographic line gap.\ Negative values 
are treated as
+OStringfamily;/**< family name 
*/
+OUString   ufamily;   /**< family name UCS2
 */
+OStringsubfamily; /**< subfamily name  
*/
+OUString   usubfamily;/**< subfamily name UCS2 */
+OStringpsname;/**< PostScript name 
*/
+sal_uInt16 macStyle = 0;  /**< macstyle bits from 'HEAD' table */
+int   weight = 0; /**< value of WeightClass or 0 if can't 
be determined*/
+int   width = 0;  /**< value of WidthClass or 0 if can't 
be determined */
+int   pitch = 0;  /**< 0: proportional font, otherwise: 
monospaced */
+int   italicAngle = 0;/**< in counter-clockwise degrees * 
65536*/
+int   xMin = 0;   /**< global bounding box: xMin   
*/
+int   yMin = 0;   /**< global bounding box: yMin   
*/
+int   xMax = 0;   /**< global bounding box: xMax   
*/
+int   yMax = 0;   /**< global bounding box: yMax   
*/
+int   ascender = 0;   /**< typographic ascent. 
*/
+int   descender = 0;  /**< typographic descent.
*/
+int   linegap = 0;/**< typographic line gap.\ Negative 
values are treated as
  zero in Win 3.1, System 6 and System 7.   
  */
-int   typoAscender;   /**< OS/2 portable typographic ascender  
*/
-int   typoDescender;  /**< OS/2 portable typographic descender 
*/
-int   typoLineGap;/**< OS/2 portable typographic line gap  
 */
-int   winAscent;  /**< ascender metric for Windows 
*/
-int   winDescent; /**< descender metric for Windows
*/
-bool  symbolEncoded;  /**< true: MS 

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

2022-09-20 Thread Khaled Hosny (via logerrit)
 vcl/inc/sft.hxx  |1 +
 vcl/source/font/PhysicalFontFace.cxx |3 ++-
 vcl/source/fontsubset/sft.cxx|8 
 3 files changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 348452715de6af8be2d40407bbe191752452b883
Author: Khaled Hosny 
AuthorDate: Tue Sep 20 09:49:29 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 20 12:00:11 2022 +0200

vcl: tdf#138325 pass PostScript name down to CreateCFFfontSubset()

If we don’t pass the name from the caller, it will try to read it from
the CFF table but some fonts has CFF table without a PostScript name so
we end up with a dummy value.

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 55464aa85973..c1d2c5c8e3fe 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -628,6 +628,7 @@ class TrueTypeFace;
 VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
   int nByteLength,
   std::vector& rOutBuffer,
+  const OUString& rPSName,
   const sal_GlyphId* pGlyphIds,
   const sal_uInt8* pEncoding,
   int nGlyphCount, FontSubsetInfo& rInfo);
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index d210304f5b47..411f2d59ef5d 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -293,7 +293,8 @@ bool 
PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
 // Shortcut for CFF-subsetting.
 auto aData = GetRawFontData(T_CFF);
 if (!aData.empty())
-return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer, 
pGlyphIds, pEncoding,
+return CreateCFFfontSubset(aData.data(), aData.size(), rOutBuffer,
+   GetName(NAME_ID_POSTSCRIPT_NAME), 
pGlyphIds, pEncoding,
nGlyphCount, rInfo);
 
 // Prepare data for font subsetter.
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index de2461d07e48..892366ea3a62 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1914,8 +1914,8 @@ bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, 
std::vector
 }
 
 bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
- std::vector& rOutBuffer, const 
sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding, int nGlyphCount,
+ std::vector& rOutBuffer, const OUString& 
rPSName,
+ const sal_GlyphId* pGlyphIds, const sal_uInt8* 
pEncoding, int nGlyphCount,
  FontSubsetInfo& rInfo)
 {
 utl::TempFile aTempFile;
@@ -1926,8 +1926,8 @@ bool CreateCFFfontSubset(const unsigned char* pFontBytes, 
int nByteLength,
 return false;
 
 rInfo.LoadFont(FontType::CFF_FONT, pFontBytes, nByteLength);
-bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, nullptr, 
pGlyphIds, pEncoding,
-   nGlyphCount);
+bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, 
rPSName.toUtf8().getStr(),
+   pGlyphIds, pEncoding, nGlyphCount);
 fclose(pOutFile);
 
 if (bRet)


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

2022-09-20 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/FeatureCollector.hxx   |8 +--
 vcl/inc/font/PhysicalFontFace.hxx   |   36 +++-
 vcl/source/font/FeatureCollector.cxx|   28 +---
 vcl/source/font/LogicalFontInstance.cxx |   20 +
 vcl/source/font/PhysicalFontFace.cxx|   30 ++
 vcl/source/outdev/font.cxx  |   10 
 6 files changed, 80 insertions(+), 52 deletions(-)

New commits:
commit 06a23b7b4d23a31a4808c68f00e1be42d8218737
Author: Khaled Hosny 
AuthorDate: Tue Sep 20 07:02:18 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 20 11:59:55 2022 +0200

vcl: Add PhysicalFontFace::GetName()

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

diff --git a/vcl/inc/font/FeatureCollector.hxx 
b/vcl/inc/font/FeatureCollector.hxx
index ae784474e06d..0ffb5f9d424c 100644
--- a/vcl/inc/font/FeatureCollector.hxx
+++ b/vcl/inc/font/FeatureCollector.hxx
@@ -15,19 +15,23 @@
 #include 
 #include 
 
+#include 
+
 namespace vcl::font
 {
 class FeatureCollector
 {
 private:
+const PhysicalFontFace* m_pFace;
 hb_face_t* m_pHbFace;
 std::vector& m_rFontFeatures;
 const LanguageTag& m_rLanguageTag;
 
 public:
-FeatureCollector(hb_face_t* pHbFace, std::vector& 
rFontFeatures,
+FeatureCollector(const PhysicalFontFace* pFace, 
std::vector& rFontFeatures,
  const LanguageTag& rLanguageTag)
-: m_pHbFace(pHbFace)
+: m_pFace(pFace)
+, m_pHbFace(pFace->GetHbFace())
 , m_rFontFeatures(rFontFeatures)
 , m_rLanguageTag(rLanguageTag)
 {
diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 303976c59776..5cdf88bd3ac9 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -21,8 +21,9 @@
 
 #include 
 
-#include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -93,6 +94,36 @@ struct ColorLayer
 
 typedef std::vector ColorPalette;
 
+// https://learn.microsoft.com/en-us/typography/opentype/spec/name#name-ids
+typedef enum {
+NAME_ID_COPYRIGHT = 0,
+NAME_ID_FONT_FAMILY = 1,
+NAME_ID_FONT_SUBFAMILY = 2,
+NAME_ID_UNIQUE_ID = 3,
+NAME_ID_FULL_NAME = 4,
+NAME_ID_VERSION_STRING = 5,
+NAME_ID_POSTSCRIPT_NAME = 6,
+NAME_ID_TRADEMARK = 7,
+NAME_ID_MANUFACTURER = 8,
+NAME_ID_DESIGNER = 9,
+NAME_ID_DESCRIPTION = 10,
+NAME_ID_VENDOR_URL = 11,
+NAME_ID_DESIGNER_URL = 12,
+NAME_ID_LICENSE = 13,
+NAME_ID_LICENSE_URL = 14,
+//NAME_ID_RESERVED = 15,
+NAME_ID_TYPOGRAPHIC_FAMILY = 16,
+NAME_ID_TYPOGRAPHIC_SUBFAMILY = 17,
+NAME_ID_MAC_FULL_NAME = 18,
+NAME_ID_SAMPLE_TEXT = 19,
+NAME_ID_CID_FINDFONT_NAME = 20,
+NAME_ID_WWS_FAMILY = 21,
+NAME_ID_WWS_SUBFAMILY = 22,
+NAME_ID_LIGHT_BACKGROUND = 23,
+NAME_ID_DARK_BACKGROUND = 24,
+NAME_ID_VARIATIONS_PS_PREFIX = 25,
+} NameID;
+
 // TODO: no more direct access to members
 // TODO: get rid of height/width for scalable fonts
 // TODO: make cloning cheaper
@@ -140,6 +171,9 @@ public:
 
 uint32_t UnitsPerEm() const { return hb_face_get_upem(GetHbFace()); }
 
+OUString GetName(NameID, const LanguageTag&) const;
+OUString GetName(NameID aNameID) const { return GetName(aNameID, 
LanguageTag(LANGUAGE_NONE)); }
+
 virtual hb_face_t* GetHbFace() const;
 virtual hb_blob_t* GetHbTable(hb_tag_t) const
 {
diff --git a/vcl/source/font/FeatureCollector.cxx 
b/vcl/source/font/FeatureCollector.cxx
index 134462e0ed44..a97988ca46ce 100644
--- a/vcl/source/font/FeatureCollector.cxx
+++ b/vcl/source/font/FeatureCollector.cxx
@@ -84,29 +84,6 @@ bool FeatureCollector::collectGraphite()
 return true;
 }
 
-static OUString getName(hb_face_t* pHbFace, hb_ot_name_id_t aNameID, OString& 
rLanguage)
-{
-auto aHbLang = hb_language_from_string(rLanguage.getStr(), 
rLanguage.getLength());
-auto nName = hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, nullptr, 
nullptr);
-
-if (!nName)
-{
-// Fallback to English if localized name is missing.
-aHbLang = hb_language_from_string("en", 2);
-nName = hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, nullptr, 
nullptr);
-}
-
-OUString sName;
-if (nName)
-{
-std::vector aBuf(++nName); // make space for terminating NUL.
-hb_ot_name_get_utf16(pHbFace, aNameID, aHbLang, , aBuf.data());
-sName = OUString(reinterpret_cast(aBuf.data()), nName);
-}
-
-return sName;
-}
-
 void FeatureCollector::collectForTable(hb_tag_t aTableTag)
 {
 unsigned int nFeatureCount
@@ -144,8 +121,7 @@ void FeatureCollector::collectForTable(hb_tag_t aTableTag)
   nullptr, nullptr, 
,
   ))
 {
-

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

2022-09-19 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|2 +-
 vcl/source/font/LogicalFontInstance.cxx |   18 +++---
 vcl/source/gdi/pdfwriter_impl.cxx   |   17 -
 3 files changed, 20 insertions(+), 17 deletions(-)

New commits:
commit e5a797a9beb03b9d9759a94b98107f509a0d5488
Author: Khaled Hosny 
AuthorDate: Sun Sep 18 13:04:05 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 19 13:38:52 2022 +0200

vcl: Fix Type 3 glyph widths

It seems we need the values to be in unscaled font units not PS units.
Modify LogicalFontInstance::GetGlyphWidth() to return unscaled values
when requested and the TT-to-PS conversion conditionally in PDFWriter.

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index d1f19760a9a3..21c09dbafca0 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -102,7 +102,7 @@ public: // TODO: make data members private
 
 sal_GlyphId GetGlyphIndex(uint32_t, uint32_t = 0) const;
 
-double GetGlyphWidth(sal_GlyphId, bool = false, bool = false) const;
+double GetGlyphWidth(sal_GlyphId, bool = false, bool = true) const;
 
 int GetKashidaWidth() const;
 
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index b882ce93dfe4..6124d41b3dba 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -150,7 +150,7 @@ sal_GlyphId LogicalFontInstance::GetGlyphIndex(uint32_t 
nUnicode, uint32_t nVari
 return 0;
 }
 
-double LogicalFontInstance::GetGlyphWidth(sal_GlyphId nGlyph, bool bVertical, 
bool bPDF) const
+double LogicalFontInstance::GetGlyphWidth(sal_GlyphId nGlyph, bool bVertical, 
bool bScale) const
 {
 auto* pHbFont = const_cast(this)->GetHbFont();
 int nWidth;
@@ -159,16 +159,12 @@ double LogicalFontInstance::GetGlyphWidth(sal_GlyphId 
nGlyph, bool bVertical, bo
 else
 nWidth = hb_font_get_glyph_h_advance(pHbFont, nGlyph);
 
-if (bPDF)
-{
-return (nWidth * 1000) / GetFontFace()->UnitsPerEm();
-}
-else
-{
-double nScale = 0;
-GetScale(, nullptr);
-return double(nWidth * nScale);
-}
+if (!bScale)
+return nWidth;
+
+double nScale = 0;
+GetScale(, nullptr);
+return double(nWidth * nScale);
 }
 
 bool LogicalFontInstance::IsGraphiteFont()
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 61729e7e07b4..cc0fedd8cdc9 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2313,6 +2313,12 @@ sal_Int32 PDFWriterImpl::emitBuildinFont(const 
pdf::BuildinFontFace* pFD, sal_In
 return nFontObject;
 }
 
+namespace
+{
+// Translate units from TT to PS (standard 1/1000)
+int XUnits(int nUPEM, int n) { return (n * 1000) / nUPEM; }
+}
+
 std::map< sal_Int32, sal_Int32 > PDFWriterImpl::emitSystemFont( const 
vcl::font::PhysicalFontFace* pFont, EmbedFont const & rEmbed )
 {
 std::map< sal_Int32, sal_Int32 > aRet;
@@ -2330,10 +2336,11 @@ std::map< sal_Int32, sal_Int32 > 
PDFWriterImpl::emitSystemFont( const vcl::font:
 
 sal_Int32 pWidths[256] = { 0 };
 const LogicalFontInstance* pFontInstance = rEmbed.m_pFontInstance;
+auto nUPEM = pFont->UnitsPerEm();
 for( sal_Ucs c = 32; c < 256; c++ )
 {
 sal_GlyphId nGlyph = pFontInstance->GetGlyphIndex(c);
-pWidths[c] = pFontInstance->GetGlyphWidth(nGlyph, false, true);
+pWidths[c] = XUnits(nUPEM, pFontInstance->GetGlyphWidth(nGlyph, false, 
false));
 }
 
 // We are interested only in filling aInfo
@@ -4072,7 +4079,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
 // make sure OpenSymbol is embedded, and includes our checkmark
 const sal_Unicode cMark=0x2713;
 const auto nGlyphId = pFontInstance->GetGlyphIndex(cMark);
-const auto nGlyphWidth = pFontInstance->GetGlyphWidth(nGlyphId, false, 
true);
+const auto nGlyphWidth = pFontInstance->GetGlyphWidth(nGlyphId, false, 
false);
 
 sal_uInt8 nMappedGlyph;
 sal_Int32 nMappedFontObject;
@@ -6006,7 +6013,7 @@ void PDFWriterImpl::registerGlyph(const sal_GlyphId 
nFontGlyphId,
 // add new glyph to emitted font subset
 GlyphEmit& rNewGlyphEmit = rSubset.m_aSubsets.back().m_aMapping[ 
nFontGlyphId ];
 rNewGlyphEmit.setGlyphId( nNewId );
-rNewGlyphEmit.setGlyphWidth( nGlyphWidth );
+rNewGlyphEmit.setGlyphWidth(XUnits(pFont->UnitsPerEm(), nGlyphWidth));
 for (const auto nCode : rCodeUnits)
 rNewGlyphEmit.addCode(nCode);
 
@@ -6533,7 +6540,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
 
 assert(!aCodeUnits.empty() || 

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

2022-09-19 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx|   14 
 vcl/source/font/PhysicalFontFace.cxx |   55 +++
 2 files changed, 69 insertions(+)

New commits:
commit dac60206ff553ff424593f15d6c196a6c9cc0b5d
Author: Khaled Hosny 
AuthorDate: Fri Sep 16 07:39:04 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 19 12:24:20 2022 +0200

vcl: Add PhysicalFontFace API to get color layers

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

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 01ad46dea54e..75133503e8af 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -23,6 +23,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -84,6 +85,14 @@ private:
 hb_blob_t* mpBlob;
 };
 
+struct ColorLayer
+{
+sal_GlyphId nGlyphIndex;
+uint32_t nColorIndex;
+};
+
+typedef std::vector ColorPalette;
+
 // TODO: no more direct access to members
 // TODO: get rid of height/width for scalable fonts
 // TODO: make cloning cheaper
@@ -125,6 +134,10 @@ public:
 bool CreateFontSubset(std::vector&, const sal_GlyphId*, const 
sal_uInt8*, const int,
   FontSubsetInfo&) const;
 
+bool HasColorLayers() const;
+const ColorPalette& GetColorPalette(size_t) const;
+std::vector GetGlyphColorLayers(sal_GlyphId) const;
+
 virtual hb_face_t* GetHbFace() const;
 virtual hb_blob_t* GetHbTable(hb_tag_t) const
 {
@@ -137,6 +150,7 @@ protected:
 mutable FontCharMapRef mxCharMap;
 mutable vcl::FontCapabilities maFontCapabilities;
 mutable bool mbFontCapabilitiesRead;
+mutable std::vector maColorPalettes;
 
 explicit PhysicalFontFace(const FontAttributes&);
 };
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 66cd3aae584b..4a459ae8cee3 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -36,6 +36,8 @@
 
 #include 
 
+#include 
+
 namespace vcl::font
 {
 PhysicalFontFace::PhysicalFontFace(const FontAttributes& rDFA)
@@ -305,6 +307,59 @@ bool 
PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
 // write subset into destination file
 return CreateTTFfontSubset(aSftFont, rOutBuffer, pGlyphIds, pEncoding, 
nGlyphCount);
 }
+
+bool PhysicalFontFace::HasColorLayers() const
+{
+const auto pHbFace = GetHbFace();
+return hb_ot_color_has_layers(pHbFace) && 
hb_ot_color_has_palettes(pHbFace);
+}
+
+const ColorPalette& PhysicalFontFace::GetColorPalette(size_t nIndex) const
+{
+if (maColorPalettes.empty())
+{
+const auto pHbFace = GetHbFace();
+
+auto nPalettes = hb_ot_color_palette_get_count(pHbFace);
+maColorPalettes.reserve(nPalettes);
+for (auto nPalette = 0u; nPalette < nPalettes; nPalette++)
+{
+auto nColors = hb_ot_color_palette_get_colors(pHbFace, nPalette, 
0, nullptr, nullptr);
+ColorPalette aPalette(nColors);
+for (auto nColor = 0u; nColor < nColors; nColor++)
+{
+uint32_t nCount = 1;
+hb_color_t aColor;
+hb_ot_color_palette_get_colors(pHbFace, nPalette, nColor, 
, );
+auto a = hb_color_get_alpha(aColor);
+auto r = hb_color_get_red(aColor);
+auto g = hb_color_get_green(aColor);
+auto b = hb_color_get_blue(aColor);
+aPalette[nColor] = Color(ColorAlphaTag::ColorAlpha, a, r, g, 
b);
+}
+maColorPalettes.push_back(aPalette);
+}
+}
+
+return maColorPalettes[nIndex];
+}
+
+std::vector PhysicalFontFace::GetGlyphColorLayers(sal_GlyphId 
nGlyphIndex) const
+{
+const auto pHbFace = GetHbFace();
+
+auto nLayers = hb_ot_color_glyph_get_layers(pHbFace, nGlyphIndex, 0, 
nullptr, nullptr);
+std::vector aLayers(nLayers);
+for (auto nLayer = 0u; nLayer < nLayers; nLayer++)
+{
+hb_ot_color_layer_t aLayer;
+uint32_t nCount = 1;
+hb_ot_color_glyph_get_layers(pHbFace, nGlyphIndex, nLayer, , 
);
+aLayers[nLayer] = { aLayer.glyph, aLayer.color_index };
+}
+
+return aLayers;
+}
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */


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

2022-09-19 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx|4 +-
 vcl/inc/sft.hxx  |7 ++--
 vcl/source/font/PhysicalFontFace.cxx |   17 +++
 vcl/source/fontsubset/sft.cxx|   44 +-
 vcl/source/fontsubset/ttcr.cxx   |   16 ---
 vcl/source/fontsubset/ttcr.hxx   |2 -
 vcl/source/gdi/pdfwriter_impl.cxx|   50 +++
 7 files changed, 60 insertions(+), 80 deletions(-)

New commits:
commit 92d67d4d32dee25c6b40ade5924f9d1ab488a16c
Author: Khaled Hosny 
AuthorDate: Sun Sep 11 18:28:54 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 19 12:23:47 2022 +0200

vcl: Don’t use temporary files for CreateFontSubset()

The callers pass a path to a temporary file for the function to write
to, then they immediately read from it. This change cuts the unnecessary
use of temporary files and passes the subset font data around instead.

The CFF subsetting code really wants files and needs more invasive
change, so it still uses a temporary files but this is hidden from its
caller.

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

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 706f7c68510e..01ad46dea54e 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -115,14 +115,14 @@ public:
 // CreateFontSubset: a method to get a subset of glyphs of a font inside a
 // new valid font file
 // returns true if creation of subset was successful
-// parameters: rToFile: contains an osl file URL to write the subset to
+// parameters: rOutBuffer: vector to write the subset to
 // pGlyphIDs: the glyph ids to be extracted
 // pEncoding: the character code corresponding to each glyph
 // nGlyphs: the number of glyphs
 // rInfo: additional outgoing information
 // implementation note: encoding 0 with glyph id 0 should be added 
implicitly
 // as "undefined character"
-bool CreateFontSubset(const OUString&, const sal_GlyphId*, const 
sal_uInt8*, const int,
+bool CreateFontSubset(std::vector&, const sal_GlyphId*, const 
sal_uInt8*, const int,
   FontSubsetInfo&) const;
 
 virtual hb_face_t* GetHbFace() const;
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 06a394491cc8..55464aa85973 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -614,20 +614,21 @@ class TrueTypeFace;
  *
  */
 VCL_DLLPUBLIC SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont  *ttf,
-  const char*fname,
+  std::vector& rOutBuffer,
   sal_uInt16 const *glyphArray,
   sal_uInt8 const *encoding,
   intnGlyphs);
 
 VCL_DLLPUBLIC bool CreateTTFfontSubset(AbstractTrueTypeFont& aTTF,
-  const OString& rSysPath,
+  std::vector& rOutBuffer,
   const sal_GlyphId* pGlyphIds,
   const sal_uInt8* pEncoding,
   int nGlyphCount);
 
 VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
   int nByteLength,
-  const OString& rSysPath, const sal_GlyphId* 
pGlyphIds,
+  std::vector& rOutBuffer,
+  const sal_GlyphId* pGlyphIds,
   const sal_uInt8* pEncoding,
   int nGlyphCount, FontSubsetInfo& rInfo);
 
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index b8b0bf0316cd..66cd3aae584b 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -284,21 +284,14 @@ bool 
PhysicalFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilit
 return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
 }
 
-bool PhysicalFontFace::CreateFontSubset(const OUString& rToFile, const 
sal_GlyphId* pGlyphIds,
-const sal_uInt8* pEncoding, const int 
nGlyphCount,
-FontSubsetInfo& rInfo) const
+bool PhysicalFontFace::CreateFontSubset(std::vector& rOutBuffer,
+const sal_GlyphId* pGlyphIds, const 
sal_uInt8* pEncoding,
+const int nGlyphCount, FontSubsetInfo& 
rInfo) const
 {
-// Prepare the requested file name for writing the font-subset file
-OUString aSysPath;
-if (osl_File_E_None != osl_getSystemPathFromFileURL(rToFile.pData, 
))
-return 

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

2022-09-14 Thread Caolán McNamara (via logerrit)
 vcl/inc/image.h |6 --
 vcl/inc/salgdi.hxx  |8 
 vcl/source/gdi/salgdilayout.cxx |7 +++
 vcl/source/image/Image.cxx  |2 +-
 vcl/source/image/ImplImage.cxx  |   18 ++
 5 files changed, 30 insertions(+), 11 deletions(-)

New commits:
commit cc2a6787446f1ae6492a41c405f45a9cc8cc7d4e
Author: Caolán McNamara 
AuthorDate: Wed Sep 14 16:05:38 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Sep 14 20:34:23 2022 +0200

Related: tdf#144583 move current lok hidpi icon thing into SalGraphics

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

diff --git a/vcl/inc/image.h b/vcl/inc/image.h
index c049e27072e7..5d0cc9fcb671 100644
--- a/vcl/inc/image.h
+++ b/vcl/inc/image.h
@@ -22,6 +22,8 @@
 
 #include 
 
+class SalGraphics;
+
 class ImplImage
 {
 private:
@@ -36,7 +38,7 @@ private:
 BitmapEx maBitmapEx;
 BitmapEx maDisabledBitmapEx;
 
-bool loadStockAtScale(double fScale, BitmapEx );
+bool loadStockAtScale(SalGraphics* pGraphics, BitmapEx );
 
 public:
 ImplImage(const BitmapEx& rBitmapEx);
@@ -57,7 +59,7 @@ public:
 /// Legacy - the original bitmap
 BitmapEx const & getBitmapEx(bool bDisabled = false);
 /// Taking account of HiDPI scaling
-BitmapEx const & getBitmapExForHiDPI(bool bDisabled = false);
+BitmapEx const & getBitmapExForHiDPI(bool bDisabled, SalGraphics* 
pGraphics);
 
 bool isEqual(const ImplImage ) const;
 bool isSizeEmpty() const
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index a0f8a22df7b3..acbfd1fa73e5 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -409,6 +409,14 @@ public:
 
 virtual SystemGraphicsData  GetGraphicsData() const = 0;
 
+// Backends like the svp/gtk ones use cairo and hidpi scale at the surface
+// but bitmaps aren't hidpi, so if this returns true for the case that the
+// surface is hidpi then pScaleOut contains the scaling factor. So we can
+// create larger hires bitmaps which we know will be logically scaled down
+// by this factor but physically just copied
+virtual bool ShouldDownscaleIconsAtSurface(double* pScaleOut) const;
+
+
 #if ENABLE_CAIRO_CANVAS
 
 /// Check whether cairo will work
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 07757614b087..91419779d871 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -926,4 +926,11 @@ OUString SalGraphics::getRenderBackendName() const
 return OUString();
 }
 
+bool SalGraphics::ShouldDownscaleIconsAtSurface(double* pScaleOut) const
+{
+if (pScaleOut)
+*pScaleOut = comphelper::LibreOfficeKit::getDPIScale();
+return comphelper::LibreOfficeKit::isActive();
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index e32f7e54df22..2b0a9521c8c1 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -120,7 +120,7 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, 
DrawImageFlags nStyle
 
 Size aOutSize = pSize ? *pSize : 
pOutDev->PixelToLogic(mpImplData->getSizePixel());
 
-BitmapEx aRenderBmp = mpImplData->getBitmapExForHiDPI(bool(nStyle & 
DrawImageFlags::Disable));
+BitmapEx aRenderBmp = mpImplData->getBitmapExForHiDPI(bool(nStyle & 
DrawImageFlags::Disable), pOutDev->GetGraphics());
 
 if (!(nStyle & DrawImageFlags::Disable) &&
 (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx
index 65ce3ca0c441..7883c3b1e6f6 100644
--- a/vcl/source/image/ImplImage.cxx
+++ b/vcl/source/image/ImplImage.cxx
@@ -28,6 +28,7 @@
 #include 
 
 #include 
+#include 
 
 ImplImage::ImplImage(const BitmapEx )
 : maBitmapChecksum(0)
@@ -42,14 +43,15 @@ ImplImage::ImplImage(OUString aStockName)
 {
 }
 
-bool ImplImage::loadStockAtScale(double fScale, BitmapEx )
+bool ImplImage::loadStockAtScale(SalGraphics* pGraphics, BitmapEx )
 {
 BitmapEx aBitmapEx;
 
 ImageLoadFlags eScalingFlags = ImageLoadFlags::NONE;
 sal_Int32 nScalePercentage = -1;
 
-if (comphelper::LibreOfficeKit::isActive()) // scale at the surface
+double fScale(1.0);
+if (pGraphics && pGraphics->ShouldDownscaleIconsAtSurface()) // 
scale at the surface
 {
 nScalePercentage = fScale * 100.0;
 eScalingFlags = ImageLoadFlags::IgnoreScalingFactor;
@@ -94,7 +96,7 @@ Size ImplImage::getSizePixel()
 aRet = maSizePixel;
 else if (isStock())
 {
-if (loadStockAtScale(1.0, maBitmapEx))
+if (loadStockAtScale(nullptr, maBitmapEx))
 {
 assert(maDisabledBitmapEx.IsEmpty());
 assert(maBitmapChecksum == 0);
@@ -138,16 +140,16 @@ bool ImplImage::isEqual(const ImplImage ) 

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

2022-09-14 Thread offtkp (via logerrit)
 vcl/inc/graphic/GraphicFormatDetector.hxx   |4 +
 vcl/source/filter/GraphicFormatDetector.cxx |   63 --
 vcl/source/filter/graphicfilter2.cxx|   67 +++-
 3 files changed, 61 insertions(+), 73 deletions(-)

New commits:
commit 868fb06a2ef8f915350c77f0d63c03844fc33f62
Author: offtkp 
AuthorDate: Thu Aug 25 22:33:04 2022 +0300
Commit: Tomaž Vajngerl 
CommitDate: Wed Sep 14 13:25:26 2022 +0200

Remove code duplication in GraphicDescriptor for PBM/PGM/PPM

GraphicFormatDetector and GraphicDescriptor have duplicate format
detection code so now GraphicDescriptor uses GraphicFormatDetector
functions instead to detect the format for PBM/PGM/PPM files

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

diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx 
b/vcl/inc/graphic/GraphicFormatDetector.hxx
index 103519b6870c..64d1e74de80a 100644
--- a/vcl/inc/graphic/GraphicFormatDetector.hxx
+++ b/vcl/inc/graphic/GraphicFormatDetector.hxx
@@ -170,7 +170,9 @@ public:
 bool checkEPS();
 bool checkDXF();
 bool checkPCT();
-bool checkPBMorPGMorPPM();
+bool checkPBM();
+bool checkPGM();
+bool checkPPM();
 bool checkRAS();
 bool checkXPM();
 bool checkXBM();
diff --git a/vcl/source/filter/GraphicFormatDetector.cxx 
b/vcl/source/filter/GraphicFormatDetector.cxx
index 30573bf9b885..219915957101 100644
--- a/vcl/source/filter/GraphicFormatDetector.cxx
+++ b/vcl/source/filter/GraphicFormatDetector.cxx
@@ -199,7 +199,7 @@ bool peekGraphicFormat(SvStream& rStream, OUString& 
rFormatExtension, bool bTest
 || rFormatExtension.startsWith("PPM"))
 {
 bSomethingTested = true;
-if (aDetector.checkPBMorPGMorPPM())
+if (aDetector.checkPBM() || aDetector.checkPGM() || 
aDetector.checkPPM())
 {
 rFormatExtension = 
getImportFormatShortName(aDetector.getMetadata().mnFormat);
 return true;
@@ -1085,29 +1085,46 @@ bool GraphicFormatDetector::checkPCT()
 return false;
 }
 
-bool GraphicFormatDetector::checkPBMorPGMorPPM()
+bool GraphicFormatDetector::checkPBM()
 {
-if (maFirstBytes[0] == 'P')
-{
-switch (maFirstBytes[1])
-{
-case '1':
-case '4':
-maMetadata.mnFormat = GraphicFileFormat::PBM;
-return true;
-
-case '2':
-case '5':
-maMetadata.mnFormat = GraphicFileFormat::PGM;
-return true;
-
-case '3':
-case '6':
-maMetadata.mnFormat = GraphicFileFormat::PPM;
-return true;
-}
-}
-return false;
+bool bRet = false;
+sal_Int32 nStmPos = mrStream.Tell();
+sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
+mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird);
+if (nFirst == 'P' && ((nSecond == '1') || (nSecond == '4')) && 
isspace(nThird))
+bRet = true;
+mrStream.Seek(nStmPos);
+if (bRet)
+maMetadata.mnFormat = GraphicFileFormat::PBM;
+return bRet;
+}
+
+bool GraphicFormatDetector::checkPGM()
+{
+bool bRet = false;
+sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
+sal_Int32 nStmPos = mrStream.Tell();
+mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird);
+if (nFirst == 'P' && ((nSecond == '2') || (nSecond == '5')) && 
isspace(nThird))
+bRet = true;
+mrStream.Seek(nStmPos);
+if (bRet)
+maMetadata.mnFormat = GraphicFileFormat::PGM;
+return bRet;
+}
+
+bool GraphicFormatDetector::checkPPM()
+{
+bool bRet = false;
+sal_uInt8 nFirst = 0, nSecond = 0, nThird = 0;
+sal_Int32 nStmPos = mrStream.Tell();
+mrStream.ReadUChar(nFirst).ReadUChar(nSecond).ReadUChar(nThird);
+if (nFirst == 'P' && ((nSecond == '3') || (nSecond == '6')) && 
isspace(nThird))
+bRet = true;
+mrStream.Seek(nStmPos);
+if (bRet)
+maMetadata.mnFormat = GraphicFileFormat::PPM;
+return bRet;
 }
 
 bool GraphicFormatDetector::checkRAS()
diff --git a/vcl/source/filter/graphicfilter2.cxx 
b/vcl/source/filter/graphicfilter2.cxx
index 6d051458ccbd..42dd8816563f 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -473,68 +473,37 @@ bool GraphicDescriptor::ImpDetectXPM( SvStream& rStm, 
bool )
 
 bool GraphicDescriptor::ImpDetectPBM( SvStream& rStm, bool )
 {
-bool bRet = false;
-
-// check file extension first, as this trumps the 2 ID bytes
-if ( aPathExt.startsWith( "pbm" ) )
-bRet = true;
-else
-{
-sal_Int32 nStmPos = rStm.Tell();
-sal_uInt8   nFirst = 0, nSecond = 0;
-rStm.ReadUChar( nFirst ).ReadUChar( nSecond );
-if ( nFirst == 'P' && ( ( nSecond == '1' ) || ( nSecond == '4' ) ) )
-

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

2022-09-14 Thread Caolán McNamara (via logerrit)
 vcl/inc/sft.hxx   |2 -
 vcl/source/fontsubset/sft.cxx |   55 --
 2 files changed, 22 insertions(+), 35 deletions(-)

New commits:
commit 4ba4b14e8101c6e025375b7d671bbb699f2dd23a
Author: Caolán McNamara 
AuthorDate: Wed Sep 14 09:40:13 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed Sep 14 12:10:03 2022 +0200

use a std::vector and can avoid a copy

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 9c73c8ace308..06a394491cc8 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -521,7 +521,7 @@ class TrueTypeFace;
  * @ingroup sft
  *
  */
-int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, 
ControlPoint **pointArray);
+int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, 
std::vector& pointArray);
 
 /**
  * Extracts raw glyph data from the 'glyf' table and returns it in an allocated
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 57de32faa1ef..dea49a70a3bf 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -295,17 +295,18 @@ static void GetMetrics(AbstractTrueTypeFont const *ttf, 
sal_uInt32 glyphID, TTGl
 metrics->ah = GetUInt16(table, 4 * (ttf->vertMetricCount() - 1));
 }
 
-static int GetTTGlyphOutline(AbstractTrueTypeFont *, sal_uInt32 , ControlPoint 
**, TTGlyphMetrics *, std::vector< sal_uInt32 >* );
+static int GetTTGlyphOutline(AbstractTrueTypeFont *, sal_uInt32 , 
std::vector&, TTGlyphMetrics *, std::vector< sal_uInt32 >* );
 
 /* returns the number of control points, allocates the pointArray */
-static int GetSimpleTTOutline(AbstractTrueTypeFont const *ttf, sal_uInt32 
glyphID, ControlPoint **pointArray, TTGlyphMetrics *metrics)
+static int GetSimpleTTOutline(AbstractTrueTypeFont const *ttf, sal_uInt32 
glyphID,
+  std::vector& pointArray, 
TTGlyphMetrics *metrics)
 {
 sal_uInt32 nTableSize;
 const sal_uInt8* table = ttf->table(O_glyf, nTableSize);
 sal_uInt8 n;
 int i, j, z;
 
-*pointArray = nullptr;
+pointArray.clear();
 
 if (glyphID >= ttf->glyphCount())
 return 0;
@@ -367,7 +368,7 @@ static int GetSimpleTTOutline(AbstractTrueTypeFont const 
*ttf, sal_uInt32 glyphI
 return 0;
 }
 
-ControlPoint* pa = static_cast(calloc(palen, 
sizeof(ControlPoint)));
+std::vector pa(palen);
 
 i = 0;
 while (i <= lastPoint) {
@@ -390,7 +391,6 @@ static int GetSimpleTTOutline(AbstractTrueTypeFont const 
*ttf, sal_uInt32 glyphI
 // coverity[tainted_data : FALSE] - i > lastPoint extra checks the 
n loop bound
 for (j=0; j lastPoint) {/*- if the font is 
really broken */
-free(pa);
 return 0;
 }
 pa[i++].flags = flag;
@@ -464,7 +464,7 @@ static int GetSimpleTTOutline(AbstractTrueTypeFont const 
*ttf, sal_uInt32 glyphI
 pa[offset].flags |= 0x8000;  /*- set the end contour flag */
 }
 
-*pointArray = pa;
+pointArray = std::move(pa);
 return lastPoint + 1;
 }
 
@@ -474,18 +474,19 @@ static F16Dot16 fromF2Dot14(sal_Int16 n)
 return sal_uInt32(n) << 2;
 }
 
-static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, 
ControlPoint **pointArray, TTGlyphMetrics *metrics, std::vector< sal_uInt32 >& 
glyphlist)
+static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, 
std::vector& pointArray,
+TTGlyphMetrics *metrics, 
std::vector& glyphlist)
 {
 sal_uInt16 flags, index;
 sal_Int16 e, f;
 sal_uInt32 nTableSize;
 const sal_uInt8* table = ttf->table(O_glyf, nTableSize);
 std::vector myPoints;
-ControlPoint *nextComponent, *pa;
+std::vector nextComponent;
 int i, np;
 F16Dot16 a = 0x1, b = 0, c = 0, d = 0x1, m, n, abs1, abs2, abs3;
 
-*pointArray = nullptr;
+pointArray.clear();
 
 if (glyphID >= ttf->glyphCount())
 return 0;
@@ -553,7 +554,7 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, C
 
 glyphlist.push_back( index );
 
-np = GetTTGlyphOutline(ttf, index, , nullptr, 
);
+np = GetTTGlyphOutline(ttf, index, nextComponent, nullptr, );
 
 if( ! glyphlist.empty() )
 glyphlist.pop_back();
@@ -573,7 +574,6 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, C
 if (nAvailableBytes < 4)
 {
 SAL_WARN("vcl.fonts", "short read");
-free(nextComponent);
 return 0;
 }
 e = GetInt16(ptr, 0);
@@ -585,7 +585,6 @@ static int GetCompoundTTOutline(AbstractTrueTypeFont *ttf, 
sal_uInt32 glyphID, 

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

2022-09-13 Thread Khaled Hosny (via logerrit)
 vcl/inc/sft.hxx  |3 +--
 vcl/source/font/PhysicalFontFace.cxx |5 +
 vcl/source/fontsubset/sft.cxx|   24 +---
 3 files changed, 15 insertions(+), 17 deletions(-)

New commits:
commit 196a8331ccb80fa7d79b74e827bf5433321b9815
Author: Khaled Hosny 
AuthorDate: Sun Sep 11 16:28:38 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 13 15:28:34 2022 +0200

vcl: Simplify calling FillFontSubsetInfo()

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

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index ccadaeb8d0b5..9c73c8ace308 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -631,8 +631,7 @@ class TrueTypeFace;
   const sal_uInt8* pEncoding,
   int nGlyphCount, FontSubsetInfo& rInfo);
 
-VCL_DLLPUBLIC void FillFontSubsetInfo(const TTGlobalFontInfo& rTTInfo,
-  const OUString& pPSName,
+VCL_DLLPUBLIC void FillFontSubsetInfo(AbstractTrueTypeFont *ttf,
   FontSubsetInfo& rInfo);
 /**
  * Generates a new PostScript Type42 font and dumps it to outf file.
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 245eab3ed88e..b8b0bf0316cd 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -307,10 +307,7 @@ bool PhysicalFontFace::CreateFontSubset(const OUString& 
rToFile, const sal_Glyph
 return false;
 
 // Get details about the subset font.
-TTGlobalFontInfo aTTInfo;
-GetTTGlobalFontInfo(, );
-OUString aPSName(aTTInfo.psname, std::strlen(aTTInfo.psname), 
RTL_TEXTENCODING_UTF8);
-FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
+FillFontSubsetInfo(, rInfo);
 
 // write subset into destination file
 return CreateTTFfontSubset(aSftFont, aToFile, pGlyphIds, pEncoding, 
nGlyphCount);
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 1e270805fb90..955e70b347c6 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -2348,27 +2348,29 @@ void GetTTGlobalFontInfo(AbstractTrueTypeFont *ttf, 
TTGlobalFontInfo *info)
 }
 }
 
-void FillFontSubsetInfo(const vcl::TTGlobalFontInfo& rTTInfo, const OUString& 
pPSName,
-FontSubsetInfo& rInfo)
+void FillFontSubsetInfo(AbstractTrueTypeFont *ttf, FontSubsetInfo& rInfo)
 {
-rInfo.m_aPSName = pPSName;
+TTGlobalFontInfo aTTInfo;
+GetTTGlobalFontInfo(ttf, );
+
+rInfo.m_aPSName = OUString::fromUtf8(aTTInfo.psname);
 rInfo.m_nFontType = FontType::SFNT_TTF;
 rInfo.m_aFontBBox
-= tools::Rectangle(Point(rTTInfo.xMin, rTTInfo.yMin), 
Point(rTTInfo.xMax, rTTInfo.yMax));
-rInfo.m_nCapHeight = rTTInfo.yMax; // Well ...
-rInfo.m_nAscent = rTTInfo.winAscent;
-rInfo.m_nDescent = rTTInfo.winDescent;
+= tools::Rectangle(Point(aTTInfo.xMin, aTTInfo.yMin), 
Point(aTTInfo.xMax, aTTInfo.yMax));
+rInfo.m_nCapHeight = aTTInfo.yMax; // Well ...
+rInfo.m_nAscent = aTTInfo.winAscent;
+rInfo.m_nDescent = aTTInfo.winDescent;
 
 // mac fonts usually do not have an OS2-table
 // => get valid ascent/descent values from other tables
 if (!rInfo.m_nAscent)
-rInfo.m_nAscent = +rTTInfo.typoAscender;
+rInfo.m_nAscent = +aTTInfo.typoAscender;
 if (!rInfo.m_nAscent)
-rInfo.m_nAscent = +rTTInfo.ascender;
+rInfo.m_nAscent = +aTTInfo.ascender;
 if (!rInfo.m_nDescent)
-rInfo.m_nDescent = +rTTInfo.typoDescender;
+rInfo.m_nDescent = +aTTInfo.typoDescender;
 if (!rInfo.m_nDescent)
-rInfo.m_nDescent = -rTTInfo.descender;
+rInfo.m_nDescent = -aTTInfo.descender;
 }
 
 GlyphData *GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID)


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

2022-09-13 Thread Khaled Hosny (via logerrit)
 vcl/inc/salgdi.hxx   |   15 -
 vcl/inc/sft.hxx  |   15 +
 vcl/source/font/PhysicalFontFace.cxx |8 +-
 vcl/source/fontsubset/sft.cxx|   96 +
 vcl/source/gdi/salgdilayout.cxx  |   99 ---
 5 files changed, 115 insertions(+), 118 deletions(-)

New commits:
commit 1bf6acf0fe438194d76e7fb2f605ed26c7914f55
Author: Khaled Hosny 
AuthorDate: Sun Sep 11 16:07:34 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 13 15:28:12 2022 +0200

vcl: Move subsetting helper functions to sft.cxx

No functional change.

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

diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 4521785e3971..a0f8a22df7b3 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -44,7 +44,6 @@ namespace vcl::font {
 }
 class SalLayout;
 namespace tools { class Rectangle; }
-class FontSubsetInfo;
 class OutputDevice;
 class FreetypeFont;
 struct SystemGraphicsData;
@@ -630,20 +629,6 @@ protected:
 
 std::unique_ptr m_pWidgetDraw;
 vcl::WidgetDrawInterface* forWidget() { return m_pWidgetDraw ? 
m_pWidgetDraw.get() : this; }
-
-public:
-static bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& aTTF, const 
OString& rSysPath,
-const sal_GlyphId* pGlyphIds,
-const sal_uInt8* pEncoding,
-int nGlyphCount);
-
-static bool CreateCFFfontSubset(const unsigned char* pFontBytes, int 
nByteLength,
-const OString& rSysPath, const 
sal_GlyphId* pGlyphIds,
-const sal_uInt8* pEncoding,
-int nGlyphCount, FontSubsetInfo& rInfo);
-
-static void FillFontSubsetInfo(const vcl::TTGlobalFontInfo& rTTInfo, const 
OUString& pPSName,
-   FontSubsetInfo& rInfo);
 };
 
 bool SalGraphics::IsNativeControlSupported(ControlType eType, ControlPart 
ePart)
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 88fa729fe6b8..ccadaeb8d0b5 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -619,6 +619,21 @@ class TrueTypeFace;
   sal_uInt8 const *encoding,
   intnGlyphs);
 
+VCL_DLLPUBLIC bool CreateTTFfontSubset(AbstractTrueTypeFont& aTTF,
+  const OString& rSysPath,
+  const sal_GlyphId* pGlyphIds,
+  const sal_uInt8* pEncoding,
+  int nGlyphCount);
+
+VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
+  int nByteLength,
+  const OString& rSysPath, const sal_GlyphId* 
pGlyphIds,
+  const sal_uInt8* pEncoding,
+  int nGlyphCount, FontSubsetInfo& rInfo);
+
+VCL_DLLPUBLIC void FillFontSubsetInfo(const TTGlobalFontInfo& rTTInfo,
+  const OUString& pPSName,
+  FontSubsetInfo& rInfo);
 /**
  * Generates a new PostScript Type42 font and dumps it to outf file.
  * This function substitutes glyph 0 for all glyphIDs that are not found in 
the font.
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 10a1048dcf79..245eab3ed88e 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -298,8 +298,8 @@ bool PhysicalFontFace::CreateFontSubset(const OUString& 
rToFile, const sal_Glyph
 // Shortcut for CFF-subsetting.
 auto aData = GetRawFontData(T_CFF);
 if (!aData.empty())
-return SalGraphics::CreateCFFfontSubset(aData.data(), aData.size(), 
aToFile, pGlyphIds,
-pEncoding, nGlyphCount, rInfo);
+return CreateCFFfontSubset(aData.data(), aData.size(), aToFile, 
pGlyphIds, pEncoding,
+   nGlyphCount, rInfo);
 
 // Prepare data for font subsetter.
 TrueTypeFace aSftFont(*this);
@@ -310,10 +310,10 @@ bool PhysicalFontFace::CreateFontSubset(const OUString& 
rToFile, const sal_Glyph
 TTGlobalFontInfo aTTInfo;
 GetTTGlobalFontInfo(, );
 OUString aPSName(aTTInfo.psname, std::strlen(aTTInfo.psname), 
RTL_TEXTENCODING_UTF8);
-SalGraphics::FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
+FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
 
 // write subset into destination file
-return SalGraphics::CreateTTFfontSubset(aSftFont, aToFile, pGlyphIds, 
pEncoding, nGlyphCount);
+return CreateTTFfontSubset(aSftFont, aToFile, pGlyphIds, pEncoding, 
nGlyphCount);
 }
 }
 
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx

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

2022-09-11 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/PhysicalFontFace.hxx|   30 ++
 vcl/source/font/PhysicalFontFace.cxx |   27 ++-
 vcl/source/font/fontmetric.cxx   |   17 +
 3 files changed, 45 insertions(+), 29 deletions(-)

New commits:
commit aa0a71b5cec118d4a4a922f6833ff20d7e4ba8ba
Author: Khaled Hosny 
AuthorDate: Sat Sep 10 23:15:55 2022 +0200
Commit: خالد حسني 
CommitDate: Sun Sep 11 09:51:29 2022 +0200

vcl: Add PhysicalFontFace::GetRawFontData()

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

diff --git a/vcl/inc/font/PhysicalFontFace.hxx 
b/vcl/inc/font/PhysicalFontFace.hxx
index 396178c5e40d..3f59dd3b25e4 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -55,6 +55,34 @@ public:
 const OUString* mpTargetStyleName;
 };
 
+struct RawFontData
+{
+public:
+RawFontData(hb_blob_t* pBlob = nullptr)
+: mpBlob(pBlob ? pBlob : hb_blob_get_empty())
+{
+}
+
+~RawFontData() { hb_blob_destroy(mpBlob); }
+
+RawFontData& operator=(const RawFontData& rOther)
+{
+hb_blob_destroy(mpBlob);
+mpBlob = hb_blob_reference(rOther.mpBlob);
+return *this;
+}
+
+size_t size() const { return hb_blob_get_length(mpBlob); }
+bool empty() const { return size() == 0; }
+const uint8_t* data() const
+{
+return reinterpret_cast(hb_blob_get_data(mpBlob, 
nullptr));
+}
+
+private:
+hb_blob_t* mpBlob;
+};
+
 // TODO: no more direct access to members
 // TODO: get rid of height/width for scalable fonts
 // TODO: make cloning cheaper
@@ -78,6 +106,8 @@ public:
 virtual FontCharMapRef GetFontCharMap() const;
 virtual bool GetFontCapabilities(vcl::FontCapabilities&) const;
 
+RawFontData GetRawFontData(uint32_t) const;
+
 bool IsBetterMatch(const vcl::font::FontSelectPattern&, FontMatchStatus&) 
const;
 sal_Int32 CompareIgnoreSize(const PhysicalFontFace&) const;
 
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 88670f6e0ff6..88ec43fa2bd5 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -212,6 +212,11 @@ bool PhysicalFontFace::IsBetterMatch(const 
FontSelectPattern& rFSP, FontMatchSta
 return true;
 }
 
+RawFontData PhysicalFontFace::GetRawFontData(uint32_t nTag) const
+{
+return RawFontData(hb_face_reference_table(GetHbFace(), nTag));
+}
+
 static hb_blob_t* getTable(hb_face_t*, hb_tag_t nTag, void* pUserData)
 {
 return static_cast(pUserData)->GetHbTable(nTag);
@@ -232,15 +237,8 @@ FontCharMapRef PhysicalFontFace::GetFontCharMap() const
 
 // Check if this font is using symbol cmap subtable, most likely redundant
 // since HarfBuzz handles mapping symbol fonts for us.
-bool bSymbol = false;
-hb_blob_t* pBlob = GetHbTable(HB_TAG('c', 'm', 'a', 'p'));
-if (pBlob)
-{
-unsigned int nSize = 0;
-auto* pData = reinterpret_cast(hb_blob_get_data(pBlob, ));
-bSymbol = HasSymbolCmap(pData, nSize);
-hb_blob_destroy(pBlob);
-}
+RawFontData aData(GetRawFontData(HB_TAG('c', 'm', 'a', 'p')));
+bool bSymbol = HasSymbolCmap(aData.data(), aData.size());
 
 hb_face_t* pHbFace = GetHbFace();
 hb_set_t* pUnicodes = hb_set_create();
@@ -274,14 +272,9 @@ bool 
PhysicalFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilit
 {
 mbFontCapabilitiesRead = true;
 
-hb_blob_t* pBlob = GetHbTable(HB_TAG('O', 'S', '/', '2'));
-if (pBlob)
-{
-unsigned int nSize = 0;
-auto* pData = reinterpret_cast(hb_blob_get_data(pBlob, ));
-vcl::getTTCoverage(maFontCapabilities.oUnicodeRange, 
maFontCapabilities.oCodePageRange,
-   pData, nSize);
-}
+RawFontData aData(GetRawFontData(HB_TAG('O', 'S', '/', '2')));
+getTTCoverage(maFontCapabilities.oUnicodeRange, 
maFontCapabilities.oCodePageRange,
+  aData.data(), aData.size());
 }
 
 rFontCapabilities = maFontCapabilities;
diff --git a/vcl/source/font/fontmetric.cxx b/vcl/source/font/fontmetric.cxx
index 4f398ba76a57..2d918d4dca68 100644
--- a/vcl/source/font/fontmetric.cxx
+++ b/vcl/source/font/fontmetric.cxx
@@ -372,22 +372,15 @@ bool ImplFontMetricData::ShouldUseWinMetrics(const 
vcl::TTGlobalFontInfo& rInfo)
 void ImplFontMetricData::ImplCalcLineSpacing(LogicalFontInstance 
*pFontInstance)
 {
 mnAscent = mnDescent = mnExtLeading = mnIntLeading = 0;
+auto* pFace = pFontInstance->GetFontFace();
 
-hb_font_t* pHbFont = pFontInstance->GetHbFont();
-hb_face_t* pHbFace = hb_font_get_face(pHbFont);
-
-hb_blob_t* pHhea = hb_face_reference_table(pHbFace, HB_TAG('h', 'h', 'e', 
'a'));
-hb_blob_t* pOS2 = 

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

2022-09-09 Thread Caolán McNamara (via logerrit)
 vcl/inc/impfontcharmap.hxx   |2 +-
 vcl/source/font/PhysicalFontFace.cxx |2 +-
 vcl/source/font/fontcharmap.cxx  |6 +++---
 vcl/source/fontsubset/sft.cxx|2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit b711a008dfce399c03cd34272c37d7cc60f93363
Author: Caolán McNamara 
AuthorDate: Fri Sep 9 11:06:35 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Sep 9 13:41:24 2022 +0200

ofz: Undefined-shift

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

diff --git a/vcl/inc/impfontcharmap.hxx b/vcl/inc/impfontcharmap.hxx
index b2d47dc9f2b7..1334dc76b262 100644
--- a/vcl/inc/impfontcharmap.hxx
+++ b/vcl/inc/impfontcharmap.hxx
@@ -50,7 +50,7 @@ private:
 const bool m_bSymbolic;
 };
 
-bool VCL_DLLPUBLIC HasSymbolCmap(const char* pRawData, int nRawLength);
+bool VCL_DLLPUBLIC HasSymbolCmap(const unsigned char* pRawData, int 
nRawLength);
 
 #endif // INCLUDED_VCL_INC_IMPFONTCHARMAP_HXX
 
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 9c1a1b586423..e3a4638b3139 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -237,7 +237,7 @@ FontCharMapRef PhysicalFontFace::GetFontCharMap() const
 if (pBlob)
 {
 unsigned int nSize = 0;
-auto* pData = hb_blob_get_data(pBlob, );
+auto* pData = reinterpret_cast(hb_blob_get_data(pBlob, ));
 bSymbol = HasSymbolCmap(pData, nSize);
 hb_blob_destroy(pBlob);
 }
diff --git a/vcl/source/font/fontcharmap.cxx b/vcl/source/font/fontcharmap.cxx
index 450521cc6008..70fb51375580 100644
--- a/vcl/source/font/fontcharmap.cxx
+++ b/vcl/source/font/fontcharmap.cxx
@@ -71,9 +71,9 @@ bool ImplFontCharMap::isDefaultMap() const
 return bIsDefault;
 }
 
-static unsigned GetUShort(const char* p) { return((p[0]<<8) | p[1]);}
+static unsigned GetUShort(const unsigned char* p) { return((p[0]<<8) | p[1]);}
 
-bool HasSymbolCmap(const char* pCmap, int nLength)
+bool HasSymbolCmap(const unsigned char* pCmap, int nLength)
 {
 // parse the table header and check for validity
 if( !pCmap || (nLength < 24) )
@@ -86,7 +86,7 @@ bool HasSymbolCmap(const char* pCmap, int nLength)
 if( (nSubTables <= 0) || (nSubTables > (nLength - 24) / 8) )
 return false;
 
-for (const char* p = pCmap + 4; --nSubTables >= 0; p += 8)
+for (const unsigned char* p = pCmap + 4; --nSubTables >= 0; p += 8)
 {
 int nPlatform = GetUShort(p);
 int nEncoding = GetUShort(p + 2);
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 41918cb12e6f..93c09b31f0c5 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -1299,7 +1299,7 @@ SFErrCodes AbstractTrueTypeFont::indexGlyphData()
 if (!m_xCharMap.is())
 {
 table = this->table(O_cmap, table_size);
-m_bIsSymbolFont = HasSymbolCmap(reinterpret_cast(table), 
table_size);
+m_bIsSymbolFont = HasSymbolCmap(reinterpret_cast(table), table_size);
 }
 
 return SFErrCodes::Ok;


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

2022-09-08 Thread Khaled Hosny (via logerrit)
 vcl/inc/impfontcharmap.hxx   |1 
 vcl/inc/sft.hxx  |3 +-
 vcl/source/font/PhysicalFontFace.cxx |   37 ++-
 vcl/source/font/fontcharmap.cxx  |   26 
 vcl/source/fontsubset/sft.cxx|8 ++-
 5 files changed, 64 insertions(+), 11 deletions(-)

New commits:
commit 8597aed8a8576ad0f6efe139ff03556217b01b31
Author: Khaled Hosny 
AuthorDate: Thu Sep 8 02:05:14 2022 +0200
Commit: خالد حسني 
CommitDate: Thu Sep 8 16:32:01 2022 +0200

vcl: Get FontCharMap from HarfBuzz

Implement PhysicalFontFace::GetFontCharMap() on top
hb_face_collect_unicodes() so that it is the same charmap as what
shaping code will actually use.

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

diff --git a/vcl/inc/impfontcharmap.hxx b/vcl/inc/impfontcharmap.hxx
index 8a8428d7e34e..8a0b0c413d56 100644
--- a/vcl/inc/impfontcharmap.hxx
+++ b/vcl/inc/impfontcharmap.hxx
@@ -50,6 +50,7 @@ private:
 const bool m_bSymbolic;
 };
 
+bool VCL_DLLPUBLIC HasSymbolCmap(const char* pRawData, int nRawLength);
 bool VCL_DLLPUBLIC ParseCMAP( const unsigned char* pRawData, int nRawLength, 
CmapResult& );
 
 #endif // INCLUDED_VCL_INC_IMPFONTCHARMAP_HXX
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index fb43e51a174a..75af2af8044e 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -727,6 +727,7 @@ class VCL_DLLPUBLIC AbstractTrueTypeFont
 sal_uInt32 m_nUnitsPerEm;
 std::vector m_aGlyphOffsets;
 FontCharMapRef m_xCharMap;
+bool m_bIsSymbolFont;
 
 protected:
 SFErrCodes indexGlyphData();
@@ -741,7 +742,7 @@ public:
 sal_uInt32 horzMetricCount() const { return m_nHorzMetrics; }
 sal_uInt32 vertMetricCount() const { return m_nVertMetrics; }
 sal_uInt32 unitsPerEm() const { return m_nUnitsPerEm; }
-const FontCharMapRef & GetCharMap() const { return m_xCharMap; }
+bool IsSymbolFont() const { return m_bIsSymbolFont; }
 
 virtual bool hasTable(sal_uInt32 ord) const = 0;
 virtual const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const = 0;
diff --git a/vcl/source/font/PhysicalFontFace.cxx 
b/vcl/source/font/PhysicalFontFace.cxx
index 5d90283fe1f4..1133b0d6a131 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -230,18 +230,45 @@ FontCharMapRef PhysicalFontFace::GetFontCharMap() const
 if (mxCharMap.is())
 return mxCharMap;
 
+// Check if this font is using symbol cmap subtable, most likely redundant
+// since HarfBuzz handles mapping symbol fonts for us.
+bool bSymbol = false;
 hb_blob_t* pBlob = GetHbTable(HB_TAG('c', 'm', 'a', 'p'));
 if (pBlob)
 {
 unsigned int nSize = 0;
-auto* pData = reinterpret_cast(hb_blob_get_data(pBlob, ));
-
-CmapResult aCmapResult(IsSymbolFont());
-if (ParseCMAP(pData, nSize, aCmapResult))
-mxCharMap = new FontCharMap(aCmapResult);
+auto* pData = hb_blob_get_data(pBlob, );
+bSymbol = HasSymbolCmap(pData, nSize);
 hb_blob_destroy(pBlob);
 }
 
+hb_face_t* pHbFace = GetHbFace();
+hb_set_t* pUnicodes = hb_set_create();
+hb_face_collect_unicodes(pHbFace, pUnicodes);
+
+if (hb_set_get_population(pUnicodes))
+{
+// Convert HarfBuzz set to CmapResult ranges.
+int nRangeCount = 0;
+hb_codepoint_t nFirst, nLast = HB_SET_VALUE_INVALID;
+while (hb_set_next_range(pUnicodes, , ))
+nRangeCount++;
+
+nLast = HB_SET_VALUE_INVALID;
+auto* pRangeCodes(new sal_UCS4[nRangeCount * 2]);
+auto* pCP = pRangeCodes;
+while (hb_set_next_range(pUnicodes, , ))
+{
+*(pCP++) = nFirst;
+*(pCP++) = nLast + 1;
+}
+
+CmapResult aCmapResult(bSymbol, pRangeCodes, nRangeCount);
+mxCharMap = new FontCharMap(aCmapResult);
+}
+
+hb_set_destroy(pUnicodes);
+
 if (!mxCharMap.is())
 mxCharMap = FontCharMap::GetDefaultMap(IsSymbolFont());
 
diff --git a/vcl/source/font/fontcharmap.cxx b/vcl/source/font/fontcharmap.cxx
index cb42e3b9620c..24f1903f7165 100644
--- a/vcl/source/font/fontcharmap.cxx
+++ b/vcl/source/font/fontcharmap.cxx
@@ -83,6 +83,32 @@ bool ImplFontCharMap::isDefaultMap() const
 return bIsDefault;
 }
 
+static unsigned GetUShort(const char* p) { return((p[0]<<8) | p[1]);}
+
+bool HasSymbolCmap(const char* pCmap, int nLength)
+{
+// parse the table header and check for validity
+if( !pCmap || (nLength < 24) )
+return false;
+
+if( GetUShort( pCmap ) != 0x ) // simple check for CMAP corruption
+return false;
+
+int nSubTables = GetUShort(pCmap + 2);
+if( (nSubTables <= 0) || (nSubTables > (nLength - 24) / 8) )
+return false;
+
+for (const char* p = pCmap + 4; --nSubTables >= 0; 

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

2022-09-07 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|2 ++
 vcl/source/font/LogicalFontInstance.cxx |   21 +
 vcl/source/gdi/CommonSalLayout.cxx  |   13 +
 vcl/source/gdi/pdfwriter_impl.cxx   |9 +++--
 4 files changed, 23 insertions(+), 22 deletions(-)

New commits:
commit e34d6e017ccfa2279f7e855eb6fd5fbbbd056714
Author: Khaled Hosny 
AuthorDate: Wed Sep 7 11:10:11 2022 +0200
Commit: خالد حسني 
CommitDate: Thu Sep 8 03:34:28 2022 +0200

vcl: Add LogicalFontInstance::GetGlyphIndex()

And use it in a few places, particularly where we get glyph ID from
FontCharMap. We want to get the glyph indices from HarfBuzz like we do
for shaping, to avoid any potential discrepancy (e.g. a new “cmap”
subtable that our ParseCMAP() would not automatically support).

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index c08e3e5bc937..d1f19760a9a3 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -100,6 +100,8 @@ public: // TODO: make data members private
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
 
+sal_GlyphId GetGlyphIndex(uint32_t, uint32_t = 0) const;
+
 double GetGlyphWidth(sal_GlyphId, bool = false, bool = false) const;
 
 int GetKashidaWidth() const;
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 611c84f44610..ce6ea99ee8f3 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -66,14 +66,10 @@ hb_font_t* LogicalFontInstance::InitHbFont()
 
 int LogicalFontInstance::GetKashidaWidth() const
 {
-hb_font_t* pHbFont = const_cast(this)->GetHbFont();
-hb_position_t nWidth = 0;
-hb_codepoint_t nIndex = 0;
-
-if (hb_font_get_glyph(pHbFont, 0x0640, 0, ))
-nWidth = std::ceil(GetGlyphWidth(nIndex));
-
-return nWidth;
+sal_GlyphId nGlyph = GetGlyphIndex(0x0640);
+if (nGlyph)
+return std::ceil(GetGlyphWidth(nGlyph));
+return 0;
 }
 
 void LogicalFontInstance::GetScale(double* nXScale, double* nYScale) const
@@ -146,6 +142,15 @@ bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId 
nID, tools::Rectangle& r
 return res;
 }
 
+sal_GlyphId LogicalFontInstance::GetGlyphIndex(uint32_t nUnicode, uint32_t 
nVariationSelector) const
+{
+auto* pHbFont = const_cast(this)->GetHbFont();
+sal_GlyphId nGlyph = 0;
+if (hb_font_get_glyph(pHbFont, nUnicode, nVariationSelector, ))
+return nGlyph;
+return 0;
+}
+
 double LogicalFontInstance::GetGlyphWidth(sal_GlyphId nGlyph, bool bVertical, 
bool bPDF) const
 {
 auto* pHbFont = const_cast(this)->GetHbFont();
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index db5575fb8c82..aab404ebe73f 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -221,14 +221,13 @@ void GenericSalLayout::DrawText(SalGraphics& 
rSalGraphics) const
 // script/language then we want to always treat it as upright glyph.
 bool GenericSalLayout::HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 
aVariationSelector)
 {
-hb_codepoint_t nGlyphIndex = 0;
-hb_font_t *pHbFont = GetFont().GetHbFont();
-if (!hb_font_get_glyph(pHbFont, aChar, aVariationSelector, ))
+sal_GlyphId nGlyphIndex = GetFont().GetGlyphIndex(aChar, 
aVariationSelector);
+if (!nGlyphIndex)
 return false;
 
 if (!mpVertGlyphs)
 {
-hb_face_t* pHbFace = hb_font_get_face(pHbFont);
+hb_face_t* pHbFace = hb_font_get_face(GetFont().GetHbFont());
 mpVertGlyphs = hb_set_create();
 
 // Find all GSUB lookups for “vert” feature.
@@ -850,10 +849,8 @@ void GenericSalLayout::ApplyDXArray(const double* 
pDXArray, const sal_Bool* pKas
 return;
 
 // Find Kashida glyph width and index.
-double nKashidaWidth = 0;
-hb_codepoint_t nKashidaIndex = 0;
-if (hb_font_get_glyph(GetFont().GetHbFont(), 0x0640, 0, ))
-nKashidaWidth = GetFont().GetKashidaWidth();
+sal_GlyphId nKashidaIndex = GetFont().GetGlyphIndex(0x0640);
+double nKashidaWidth = GetFont().GetKashidaWidth();
 
 if (nKashidaWidth <= 0)
 {
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 3e01a6c76b9d..1f032c25a79e 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2335,12 +2335,11 @@ std::map< sal_Int32, sal_Int32 > 
PDFWriterImpl::emitSystemFont( const vcl::font:
 OUString aTmpName;
 osl_createTempFile( nullptr, nullptr,  );
 
-sal_Int32 pWidths[256] = {};
-FontCharMapRef xFontCharMap = 

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

2022-09-06 Thread Khaled Hosny (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx|5 -
 vcl/source/gdi/pdfwriter_impl.cxx |   33 +++--
 2 files changed, 19 insertions(+), 19 deletions(-)

New commits:
commit fe87b2a2cccbc99d001705fdd8f8dc2e9997f211
Author: Khaled Hosny 
AuthorDate: Mon Sep 5 21:25:29 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 6 15:06:41 2022 +0200

vcl: Use GetGlyphWidth() when emitting system fonts

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index 94a52bb07431..048b03cf2351 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -338,8 +338,11 @@ struct FontSubset
 struct EmbedFont
 {
 sal_Int32   m_nNormalFontID;
+LogicalFontInstance*m_pFontInstance;
 
-EmbedFont() : m_nNormalFontID( 0 ) {}
+EmbedFont()
+: m_nNormalFontID(0)
+, m_pFontInstance(nullptr) {}
 };
 
 struct PDFDest
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 76c47b54ba45..1e7869dfe1dc 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2325,35 +2325,28 @@ std::map< sal_Int32, sal_Int32 > 
PDFWriterImpl::emitSystemFont( const vcl::font:
 aInfo.m_nCapHeight = 1000;
 aInfo.m_aFontBBox = tools::Rectangle( Point( -200, -200 ), Size( 1700, 
1700 ) );
 aInfo.m_aPSName = pFont->GetFamilyName();
-sal_Int32 pWidths[256] = {};
 
 SalGraphics *pGraphics = GetGraphics();
-
 assert(pGraphics);
 
 aSubType = OString( "/TrueType" );
-std::vector< sal_Int32 > aGlyphWidths;
-Ucs2UIntMap aUnicodeMap;
-pGraphics->GetGlyphWidths( pFont, false, aGlyphWidths, aUnicodeMap );
 
 OUString aTmpName;
 osl_createTempFile( nullptr, nullptr,  );
-sal_GlyphId aGlyphIds[ 256 ] = {};
-sal_uInt8 pEncoding[ 256 ] = {};
-sal_Int32 pDuWidths[ 256 ] = {};
 
+sal_Int32 pWidths[256] = {};
+FontCharMapRef xFontCharMap = pFont->GetFontCharMap();
+const LogicalFontInstance* pFontInstance = rEmbed.m_pFontInstance;
 for( sal_Ucs c = 32; c < 256; c++ )
 {
-pEncoding[c] = c;
-aGlyphIds[c] = 0;
-if( aUnicodeMap.find( c ) != aUnicodeMap.end() )
-pWidths[ c ] = aGlyphWidths[ aUnicodeMap[ c ] ];
+sal_GlyphId nGlyph = xFontCharMap->GetGlyphIndex(c);
+pWidths[c] = pFontInstance->GetGlyphWidth(nGlyph, false, true);
 }
-//TODO: surely this is utterly broken because aGlyphIds is just all zeros, 
if we
-//had the right glyphids here then I imagine we could replace pDuWidths 
with
-//pWidths and remove pWidths assignment above. i.e. start with the glyph 
ids
-//and map those to unicode rather than try and reverse map them ?
-pGraphics->CreateFontSubset( aTmpName, pFont, aGlyphIds, pEncoding, 
pDuWidths, 256, aInfo );
+
+// We are interested only in filling aInfo
+sal_GlyphId aGlyphIds[256] = { 0 };
+sal_uInt8 pEncoding[256] = { 0 };
+pGraphics->CreateFontSubset(aTmpName, pFont, aGlyphIds, pEncoding, 
nullptr, 256, aInfo);
 osl_removeFile( aTmpName.pData );
 
 // write font descriptor
@@ -2876,6 +2869,8 @@ bool PDFWriterImpl::emitFonts()
 }
 osl_removeFile( aTmpName.pData );
 
+if (g_bDebugDisableCompression)
+emitComment( "PDFWriterImpl::emitSystemFonts" );
 // emit system fonts
 for (auto const& systemFont : m_aSystemFonts)
 {
@@ -5788,7 +5783,8 @@ sal_Int32 PDFWriterImpl::getSystemFont( const vcl::Font& 
i_rFont )
 
 SetFont( i_rFont );
 
-const vcl::font::PhysicalFontFace* pDevFont = 
GetFontInstance()->GetFontFace();
+const LogicalFontInstance* pFontInstance = GetFontInstance();
+const vcl::font::PhysicalFontFace* pDevFont = pFontInstance->GetFontFace();
 sal_Int32 nFontID = 0;
 auto it = m_aSystemFonts.find( pDevFont );
 if( it != m_aSystemFonts.end() )
@@ -5797,6 +5793,7 @@ sal_Int32 PDFWriterImpl::getSystemFont( const vcl::Font& 
i_rFont )
 {
 nFontID = m_nNextFID++;
 m_aSystemFonts[ pDevFont ] = EmbedFont();
+m_aSystemFonts[ pDevFont ].m_pFontInstance = 
const_cast(pFontInstance);
 m_aSystemFonts[ pDevFont ].m_nNormalFontID = nFontID;
 }
 


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

2022-09-06 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|2 ++
 vcl/source/font/LogicalFontInstance.cxx |   28 +++-
 vcl/source/gdi/pdfwriter_impl.cxx   |   19 ---
 3 files changed, 29 insertions(+), 20 deletions(-)

New commits:
commit 60fd694ac362e9314f54fa992e31e8baa5bdf80f
Author: Khaled Hosny 
AuthorDate: Tue Sep 6 00:56:37 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 6 15:05:39 2022 +0200

vcl: Add LogicalFontInstance::GetGlyphWidth()

To be used it in PDF export where we need the unshaped glyph width to
calculate PDF glyph adjustments.

Getting the advances from HarfBuzz instead of reading them font the font
makes sure we are always getting the correct values (e.g. when
using variable fonts, though we still don’t correctly embed them in
PDF).

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index 8187ccc2e7e0..c08e3e5bc937 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -100,6 +100,8 @@ public: // TODO: make data members private
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
 
+double GetGlyphWidth(sal_GlyphId, bool = false, bool = false) const;
+
 int GetKashidaWidth() const;
 
 void GetScale(double* nXScale, double* nYScale) const;
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 0936bb7286b9..611c84f44610 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -71,11 +71,7 @@ int LogicalFontInstance::GetKashidaWidth() const
 hb_codepoint_t nIndex = 0;
 
 if (hb_font_get_glyph(pHbFont, 0x0640, 0, ))
-{
-double nXScale = 0;
-GetScale(, nullptr);
-nWidth = std::ceil(hb_font_get_glyph_h_advance(pHbFont, nIndex) * 
nXScale);
-}
+nWidth = std::ceil(GetGlyphWidth(nIndex));
 
 return nWidth;
 }
@@ -150,6 +146,28 @@ bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId 
nID, tools::Rectangle& r
 return res;
 }
 
+double LogicalFontInstance::GetGlyphWidth(sal_GlyphId nGlyph, bool bVertical, 
bool bPDF) const
+{
+auto* pHbFont = const_cast(this)->GetHbFont();
+int nWidth;
+if (bVertical)
+nWidth = hb_font_get_glyph_v_advance(pHbFont, nGlyph);
+else
+nWidth = hb_font_get_glyph_h_advance(pHbFont, nGlyph);
+
+if (bPDF)
+{
+unsigned int nUPEM = hb_face_get_upem(hb_font_get_face(pHbFont));
+return (nWidth * 1000) / nUPEM;
+}
+else
+{
+double nScale = 0;
+GetScale(, nullptr);
+return double(nWidth * nScale);
+}
+}
+
 bool LogicalFontInstance::IsGraphiteFont()
 {
 if (!m_xbIsGraphiteFont)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 9fe9dab2ecd8..76c47b54ba45 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3905,13 +3905,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
 const GlyphItem aItem(0, 0, pMap->GetGlyphIndex(cMark),
   DevicePoint(), GlyphItemFlags::NONE, 0, 0, 0);
 const std::vector aCodeUnits={ cMark };
-sal_Int32 nGlyphWidth = 0;
-SalGraphics *pGraphics = GetGraphics();
-if (pGraphics)
-nGlyphWidth = m_aFontCache.getGlyphWidth(pDevFont,
- aItem.glyphId(),
- aItem.IsVertical(),
- pGraphics);
+auto nGlyphWidth = pFontInstance->GetGlyphWidth(aItem.glyphId(), 
aItem.IsVertical(), true);
 
 sal_uInt8 nMappedGlyph;
 sal_Int32 nMappedFontObject;
@@ -6240,13 +6234,14 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, 
const OUString& rText, bool
 const vcl::font::PhysicalFontFace* pDevFont = 
GetFontInstance()->GetFontFace();
 const GlyphItem* pGlyph = nullptr;
 const vcl::font::PhysicalFontFace* pFallbackFont = nullptr;
+const LogicalFontInstance* pGlyphFont = nullptr;
 
 // collect the glyphs into a single array
 std::vector< PDFGlyph > aGlyphs;
 aGlyphs.reserve( nMaxGlyphs );
 // first get all the glyphs and register them; coordinates still in Pixel
 DevicePoint aPos;
-while (rLayout.GetNextGlyph(, aPos, nIndex, nullptr, 
))
+while (rLayout.GetNextGlyph(, aPos, nIndex, , 
))
 {
 const auto* pFont = pFallbackFont ? pFallbackFont : pDevFont;
 
@@ -6302,13 +6297,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, 
const OUString& rText, bool
 
 assert(!aCodeUnits.empty() || bUseActualText || 

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

2022-09-05 Thread خالد حسني (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|   17 -
 vcl/source/font/LogicalFontInstance.cxx |   11 ---
 vcl/source/gdi/pdfwriter_impl.cxx   |   16 ++--
 3 files changed, 14 insertions(+), 30 deletions(-)

New commits:
commit 47981aeb3a233a01a8b099d3fe2c3f5a8a9cfb7b
Author: خالد حسني 
AuthorDate: Tue Sep 6 00:10:04 2022 +0200
Commit: خالد حسني 
CommitDate: Tue Sep 6 00:50:39 2022 +0200

Revert "vcl: Add LogicalFontInstance::GetUnscaledGLyphWidth()"

This reverts commit fa1835db77b38047d8c3cea7041d38762c329867.

Reason for revert: merged too early

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index 7e3adcb3e15e..8187ccc2e7e0 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -100,8 +100,6 @@ public: // TODO: make data members private
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
 
-sal_Int32 GetUnscaledGlyphWidth(sal_GlyphId, bool) const;
-
 int GetKashidaWidth() const;
 
 void GetScale(double* nXScale, double* nYScale) const;
@@ -130,7 +128,6 @@ private:
 mutable ImplFontCache* mpFontCache;
 const vcl::font::FontSelectPattern m_aFontSelData;
 hb_font_t* m_pHbFont;
-hb_font_t* m_pUnscaledHbFont;
 double m_nAveWidthFactor;
 rtl::Reference m_pFontFace;
 std::optional m_xbIsGraphiteFont;
@@ -143,8 +140,6 @@ private:
 
 // The value is initialized and used in NeedOffsetCorrection().
 std::optional m_xeFontFamilyEnum;
-
-inline hb_font_t* GetUnscaledHbFont();
 };
 
 inline hb_font_t* LogicalFontInstance::GetHbFont()
@@ -154,16 +149,4 @@ inline hb_font_t* LogicalFontInstance::GetHbFont()
 return m_pHbFont;
 }
 
-inline hb_font_t* LogicalFontInstance::GetUnscaledHbFont()
-{
-if (!m_pUnscaledHbFont)
-{
-auto* pHbFont = GetHbFont();
-auto nUPEM = hb_face_get_upem(hb_font_get_face(pHbFont));
-m_pUnscaledHbFont = hb_font_create_sub_font(pHbFont);
-hb_font_set_scale(m_pUnscaledHbFont, nUPEM, nUPEM);
-}
-return m_pUnscaledHbFont;
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 542a814fb9ac..0936bb7286b9 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -37,7 +37,6 @@ LogicalFontInstance::LogicalFontInstance(const 
vcl::font::PhysicalFontFace& rFon
 , mpFontCache(nullptr)
 , m_aFontSelData(rFontSelData)
 , m_pHbFont(nullptr)
-, m_pUnscaledHbFont(nullptr)
 , m_nAveWidthFactor(1.0f)
 , m_pFontFace(_cast(rFontFace))
 {
@@ -51,8 +50,6 @@ LogicalFontInstance::~LogicalFontInstance()
 
 if (m_pHbFont)
 hb_font_destroy(m_pHbFont);
-if (m_pUnscaledHbFont)
-hb_font_destroy(m_pUnscaledHbFont);
 }
 
 hb_font_t* LogicalFontInstance::InitHbFont()
@@ -153,14 +150,6 @@ bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId 
nID, tools::Rectangle& r
 return res;
 }
 
-sal_Int32 LogicalFontInstance::GetUnscaledGlyphWidth(sal_GlyphId nGlyph, bool 
bVertical) const
-{
-auto* pHbFont = 
const_cast(this)->GetUnscaledHbFont();
-if (bVertical)
-hb_font_get_glyph_v_advance(pHbFont, nGlyph);
-return hb_font_get_glyph_h_advance(pHbFont, nGlyph);
-}
-
 bool LogicalFontInstance::IsGraphiteFont()
 {
 if (!m_xbIsGraphiteFont)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index dc5e443374ba..f1c01944a48f 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3905,7 +3905,13 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
 const GlyphItem aItem(0, 0, pMap->GetGlyphIndex(cMark),
   DevicePoint(), GlyphItemFlags::NONE, 0, 0, 0);
 const std::vector aCodeUnits={ cMark };
-sal_Int32 nGlyphWidth = 
GetFontInstance()->GetUnscaledGlyphWidth(aItem.glyphId(), aItem.IsVertical());
+sal_Int32 nGlyphWidth = 0;
+SalGraphics *pGraphics = GetGraphics();
+if (pGraphics)
+nGlyphWidth = m_aFontCache.getGlyphWidth(pDevFont,
+ aItem.glyphId(),
+ aItem.IsVertical(),
+ pGraphics);
 
 sal_uInt8 nMappedGlyph;
 sal_Int32 nMappedFontObject;
@@ -6296,7 +6302,13 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, 
const OUString& rText, bool
 
 assert(!aCodeUnits.empty() || bUseActualText || pGlyph->IsInCluster());
 
-sal_Int32 nGlyphWidth = 

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

2022-09-05 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/LogicalFontInstance.hxx|   17 +
 vcl/source/font/LogicalFontInstance.cxx |   11 +++
 vcl/source/gdi/pdfwriter_impl.cxx   |   16 ++--
 3 files changed, 30 insertions(+), 14 deletions(-)

New commits:
commit fa1835db77b38047d8c3cea7041d38762c329867
Author: Khaled Hosny 
AuthorDate: Mon Sep 5 19:18:36 2022 +0200
Commit: خالد حسني 
CommitDate: Mon Sep 5 20:13:57 2022 +0200

vcl: Add LogicalFontInstance::GetUnscaledGLyphWidth()

To get glyph width in font units (i.e. scaled at font units per EM), and
use it in PDF export.

First step towards dropping SalGraphics::GetGlyphWidths().

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

diff --git a/vcl/inc/font/LogicalFontInstance.hxx 
b/vcl/inc/font/LogicalFontInstance.hxx
index 8187ccc2e7e0..7e3adcb3e15e 100644
--- a/vcl/inc/font/LogicalFontInstance.hxx
+++ b/vcl/inc/font/LogicalFontInstance.hxx
@@ -100,6 +100,8 @@ public: // TODO: make data members private
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
 
+sal_Int32 GetUnscaledGlyphWidth(sal_GlyphId, bool) const;
+
 int GetKashidaWidth() const;
 
 void GetScale(double* nXScale, double* nYScale) const;
@@ -128,6 +130,7 @@ private:
 mutable ImplFontCache* mpFontCache;
 const vcl::font::FontSelectPattern m_aFontSelData;
 hb_font_t* m_pHbFont;
+hb_font_t* m_pUnscaledHbFont;
 double m_nAveWidthFactor;
 rtl::Reference m_pFontFace;
 std::optional m_xbIsGraphiteFont;
@@ -140,6 +143,8 @@ private:
 
 // The value is initialized and used in NeedOffsetCorrection().
 std::optional m_xeFontFamilyEnum;
+
+inline hb_font_t* GetUnscaledHbFont();
 };
 
 inline hb_font_t* LogicalFontInstance::GetHbFont()
@@ -149,4 +154,16 @@ inline hb_font_t* LogicalFontInstance::GetHbFont()
 return m_pHbFont;
 }
 
+inline hb_font_t* LogicalFontInstance::GetUnscaledHbFont()
+{
+if (!m_pUnscaledHbFont)
+{
+auto* pHbFont = GetHbFont();
+auto nUPEM = hb_face_get_upem(hb_font_get_face(pHbFont));
+m_pUnscaledHbFont = hb_font_create_sub_font(pHbFont);
+hb_font_set_scale(m_pUnscaledHbFont, nUPEM, nUPEM);
+}
+return m_pUnscaledHbFont;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/font/LogicalFontInstance.cxx 
b/vcl/source/font/LogicalFontInstance.cxx
index 0936bb7286b9..542a814fb9ac 100644
--- a/vcl/source/font/LogicalFontInstance.cxx
+++ b/vcl/source/font/LogicalFontInstance.cxx
@@ -37,6 +37,7 @@ LogicalFontInstance::LogicalFontInstance(const 
vcl::font::PhysicalFontFace& rFon
 , mpFontCache(nullptr)
 , m_aFontSelData(rFontSelData)
 , m_pHbFont(nullptr)
+, m_pUnscaledHbFont(nullptr)
 , m_nAveWidthFactor(1.0f)
 , m_pFontFace(_cast(rFontFace))
 {
@@ -50,6 +51,8 @@ LogicalFontInstance::~LogicalFontInstance()
 
 if (m_pHbFont)
 hb_font_destroy(m_pHbFont);
+if (m_pUnscaledHbFont)
+hb_font_destroy(m_pUnscaledHbFont);
 }
 
 hb_font_t* LogicalFontInstance::InitHbFont()
@@ -150,6 +153,14 @@ bool LogicalFontInstance::GetGlyphBoundRect(sal_GlyphId 
nID, tools::Rectangle& r
 return res;
 }
 
+sal_Int32 LogicalFontInstance::GetUnscaledGlyphWidth(sal_GlyphId nGlyph, bool 
bVertical) const
+{
+auto* pHbFont = 
const_cast(this)->GetUnscaledHbFont();
+if (bVertical)
+hb_font_get_glyph_v_advance(pHbFont, nGlyph);
+return hb_font_get_glyph_h_advance(pHbFont, nGlyph);
+}
+
 bool LogicalFontInstance::IsGraphiteFont()
 {
 if (!m_xbIsGraphiteFont)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index f1c01944a48f..dc5e443374ba 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3905,13 +3905,7 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
 const GlyphItem aItem(0, 0, pMap->GetGlyphIndex(cMark),
   DevicePoint(), GlyphItemFlags::NONE, 0, 0, 0);
 const std::vector aCodeUnits={ cMark };
-sal_Int32 nGlyphWidth = 0;
-SalGraphics *pGraphics = GetGraphics();
-if (pGraphics)
-nGlyphWidth = m_aFontCache.getGlyphWidth(pDevFont,
- aItem.glyphId(),
- aItem.IsVertical(),
- pGraphics);
+sal_Int32 nGlyphWidth = 
GetFontInstance()->GetUnscaledGlyphWidth(aItem.glyphId(), aItem.IsVertical());
 
 sal_uInt8 nMappedGlyph;
 sal_Int32 nMappedFontObject;
@@ -6302,13 +6296,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, 
const OUString& rText, bool
 
 assert(!aCodeUnits.empty() || bUseActualText || pGlyph->IsInCluster());
 
-  

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

2022-09-03 Thread Caolán McNamara (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx|2 +-
 vcl/source/gdi/pdfwriter_impl.cxx |   26 +-
 2 files changed, 14 insertions(+), 14 deletions(-)

New commits:
commit f2762465eb8ccbad74acf07afca3358a5ab3e1c1
Author: Caolán McNamara 
AuthorDate: Sat Sep 3 15:31:14 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat Sep 3 17:25:08 2022 +0200

don't check that the shadow positions map back to source mapmode integers

because they are fake positions created by the pdf export and not from
the source application

Change-Id: Ieeb1b835123a5302ebbb35902b29ebe77ef5fe27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139326
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 9af21e81baee..94a52bb07431 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -827,7 +827,7 @@ i12626
 /* TODO: remove rText as soon as SalLayout will change so that rText is 
not necessary anymore */
 void drawVerticalGlyphs( const std::vector& rGlyphs, 
OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, 
double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight );
 void drawHorizontalGlyphs( const std::vector& rGlyphs, 
OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, 
double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight 
);
-void drawLayout( SalLayout& rLayout, const OUString& rText, bool 
bTextLines );
+void drawLayout( SalLayout& rLayout, const OUString& rText, bool 
bTextLines, bool bCheckSubPixelToLogic );
 void drawRelief( SalLayout& rLayout, const OUString& rText, bool 
bTextLines );
 void drawShadow( SalLayout& rLayout, const OUString& rText, bool 
bTextLines );
 
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 5e93cff34bb0..f1c01944a48f 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -5889,7 +5889,7 @@ void PDFWriterImpl::drawRelief( SalLayout& rLayout, const 
OUString& rText, bool
 
 rLayout.DrawOffset() += Point( nOff, nOff );
 updateGraphicsState();
-drawLayout( rLayout, rText, bTextLines );
+drawLayout( rLayout, rText, bTextLines, false );
 
 rLayout.DrawOffset() -= Point( nOff, nOff );
 setTextLineColor( aTextLineColor );
@@ -5897,7 +5897,7 @@ void PDFWriterImpl::drawRelief( SalLayout& rLayout, const 
OUString& rText, bool
 aSetFont.SetColor( aTextColor );
 setFont( aSetFont );
 updateGraphicsState();
-drawLayout( rLayout, rText, bTextLines );
+drawLayout( rLayout, rText, bTextLines, true );
 
 // clean up the mess
 pop();
@@ -5925,7 +5925,7 @@ void PDFWriterImpl::drawShadow( SalLayout& rLayout, const 
OUString& rText, bool
 if( rFont.IsOutline() )
 nOff++;
 rLayout.DrawBase() += DevicePoint(nOff, nOff);
-drawLayout( rLayout, rText, bTextLines );
+drawLayout( rLayout, rText, bTextLines, false );
 rLayout.DrawBase() -= DevicePoint(nOff, nOff);
 
 setFont( aSaveFont );
@@ -6106,7 +6106,7 @@ void PDFWriterImpl::drawHorizontalGlyphs(
 }
 }
 
-void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, 
bool bTextLines )
+void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, 
bool bTextLines, bool bCheckSubPixelToLogic )
 {
 // relief takes precedence over shadow (see outdev3.cxx)
 if(  m_aCurrentPDFState.m_aFont.GetRelief() != FontRelief::NONE )
@@ -6342,7 +6342,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
 // ascent / descent to match the on-screen rendering.
 // This is the top left of the text without ascent / descent.
 DevicePoint aDrawPosition(rLayout.GetDrawPosition());
-tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition, true),
+tools::Rectangle aRectangle(SubPixelToLogic(aDrawPosition, 
bCheckSubPixelToLogic),
 
Size(ImplDevicePixelToLogicWidth(rLayout.GetTextWidth()), 0));
 aRectangle.AdjustTop(-aRefDevFontMetric.GetAscent());
 // This includes ascent / descent.
@@ -6353,7 +6353,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
 {
 // Adapt rectangle for rotated text.
 tools::Polygon aPolygon(aRectangle);
-aPolygon.Rotate(SubPixelToLogic(aDrawPosition, true), 
pFontInstance->mnOrientation);
+aPolygon.Rotate(SubPixelToLogic(aDrawPosition, 
bCheckSubPixelToLogic), pFontInstance->mnOrientation);
 drawPolygon(aPolygon);
 }
 else
@@ -6456,7 +6456,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const 
OUString& rText, bool
 }
 else if( nWidth > 0 )
 {
-drawTextLine( SubPixelToLogic(aStartPt, 

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

2022-08-25 Thread Khaled Hosny (via logerrit)
 vcl/inc/font/OpenTypeFeatureDefinitionList.hxx |2 -
 vcl/source/font/FeatureCollector.cxx   |   45 -
 2 files changed, 23 insertions(+), 24 deletions(-)

New commits:
commit 8f058de233e5110720daa5b42e0c66e7c3b2c31f
Author: Khaled Hosny 
AuthorDate: Thu Aug 25 23:42:40 2022 +0200
Commit: خالد حسني 
CommitDate: Fri Aug 26 01:00:32 2022 +0200

FeatureCollector: Drop redundant check

HarfBuzz handles this for us, and it more future-proof this way.

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

diff --git a/vcl/inc/font/OpenTypeFeatureDefinitionList.hxx 
b/vcl/inc/font/OpenTypeFeatureDefinitionList.hxx
index aaa89ebe5d48..52dbcfb5b9f0 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/source/font/FeatureCollector.cxx 
b/vcl/source/font/FeatureCollector.cxx
index 653712c27e93..4f517bf6784a 100644
--- a/vcl/source/font/FeatureCollector.cxx
+++ b/vcl/source/font/FeatureCollector.cxx
@@ -135,31 +135,30 @@ void FeatureCollector::collectForTable(hb_tag_t aTableTag)

HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX, aFeatureTag,
))
 {
-if 
(OpenTypeFeatureDefinitionListPrivate::isSpecialFeatureCode(aFeatureTag))
+// ssXX and cvXX can have name ID defined for them, check for
+// them and use as appropriate.
+hb_ot_name_id_t aLabelID;
+hb_ot_name_id_t aFirstParameterID;
+unsigned nNamedParameters;
+if (hb_ot_layout_feature_get_name_ids(m_pHbFace, aTableTag, 
nFeatureIdx, ,
+  nullptr, nullptr, 
,
+  ))
 {
-// ssXX and cvXX can have name ID defined for them, check for
-// them and use as appropriate.
-hb_ot_name_id_t aLabelID;
-hb_ot_name_id_t aFirstParameterID;
-unsigned nNamedParameters;
-if (hb_ot_layout_feature_get_name_ids(m_pHbFace, aTableTag, 
nFeatureIdx, ,
-  nullptr, nullptr, 
,
-  ))
+OString sLanguage = m_rLanguageTag.getBcp47().toUtf8();
+OUString sLabel = getName(m_pHbFace, aLabelID, sLanguage);
+if (!sLabel.isEmpty())
+aDefinition = vcl::font::FeatureDefinition(aFeatureTag, 
sLabel);
+
+// cvXX features can have parameters name IDs, check for
+// them and populate feature parameters as appropriate.
+for (unsigned i = 0; i < nNamedParameters; i++)
 {
-OString sLanguage = m_rLanguageTag.getBcp47().toUtf8();
-OUString sLabel = getName(m_pHbFace, aLabelID, sLanguage);
-if (!sLabel.isEmpty())
-aDefinition = 
vcl::font::FeatureDefinition(aFeatureTag, sLabel);
-
-// cvXX features can have parameters name IDs, check for
-// them and populate feature parameters as appropriate.
-for (unsigned i = 0; i < nNamedParameters; i++)
-{
-hb_ot_name_id_t aNameID = aFirstParameterID + i;
-OUString sName = getName(m_pHbFace, aNameID, 
sLanguage);
-if (!sName.isEmpty())
-aParameters.emplace_back(uint32_t(i + 1), sName);
-}
+hb_ot_name_id_t aNameID = aFirstParameterID + i;
+OUString sName = getName(m_pHbFace, aNameID, sLanguage);
+if (!sName.isEmpty())
+aParameters.emplace_back(uint32_t(i + 1), sName);
+else
+aParameters.emplace_back(uint32_t(i + 1), 
OUString::number(i + 1));
 }
 }
 


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

2022-08-20 Thread Caolán McNamara (via logerrit)
 vcl/inc/ImplLayoutArgs.hxx |8 ++
 vcl/inc/sallayout.hxx  |   10 +++-
 vcl/source/gdi/CommonSalLayout.cxx |   15 
 vcl/source/gdi/sallayout.cxx   |   20 
 vcl/source/outdev/text.cxx |   46 ++---
 vcl/source/text/ImplLayoutArgs.cxx |   22 -
 6 files changed, 41 insertions(+), 80 deletions(-)

New commits:
commit 9cabb7ca71dfc426b9925300c4214f05399bfd12
Author: Caolán McNamara 
AuthorDate: Fri Aug 19 20:54:14 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat Aug 20 13:06:09 2022 +0200

always transport the text dxarray as doubles when rendering

continue to do rounding to integer, just transported as double,
unless the opt-in TextRenderModeForResolutionIndependentLayout is set,
so this is not intended to create visible changes

though
nRunAdvance = static_cast(nRunAdvance*fUnitMul + 0.5);
becomes
nRunAdvance = nRunAdvance * fUnitMul;
in MultiSalLayout::ImplAdjustMultiLayout which might create a
difference, but it is in the glyph fallback case where things are a last
ditch effort already

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

diff --git a/vcl/inc/ImplLayoutArgs.hxx b/vcl/inc/ImplLayoutArgs.hxx
index 105a4e2d8961..381d09185563 100644
--- a/vcl/inc/ImplLayoutArgs.hxx
+++ b/vcl/inc/ImplLayoutArgs.hxx
@@ -35,8 +35,7 @@ public:
 vcl::text::TextLayoutCache const* m_pTextLayoutCache;
 
 // positioning related inputs
-const DeviceCoordinate* mpDXArray; // in integer pixel units
-const double* mpAltNaturalDXArray; // in floating point pixel units
+const double* mpNaturalDXArray; // in floating point pixel units
 const sal_Bool* mpKashidaArray;
 DeviceCoordinate mnLayoutWidth; // in pixel units
 Degree10 mnOrientation; // in 0-3600 system
@@ -49,8 +48,7 @@ public:
LanguageTag aLanguageTag, vcl::text::TextLayoutCache const* 
pLayoutCache);
 
 void SetLayoutWidth(DeviceCoordinate nWidth);
-void SetDXArray(const DeviceCoordinate* pDXArray);
-void SetAltNaturalDXArray(const double* pDXArray);
+void SetNaturalDXArray(const double* pDXArray);
 void SetKashidaArray(const sal_Bool* pKashidaArray);
 void SetOrientation(Degree10 nOrientation);
 
@@ -58,7 +56,7 @@ public:
 bool GetNextPos(int* nCharPos, bool* bRTL);
 bool GetNextRun(int* nMinRunPos, int* nEndRunPos, bool* bRTL);
 void AddFallbackRun(int nMinRunPos, int nEndRunPos, bool bRTL);
-bool HasDXArray() const { return mpDXArray || mpAltNaturalDXArray; }
+bool HasDXArray() const { return mpNaturalDXArray; }
 
 // methods used by BiDi and glyph fallback
 bool HasFallbackRun() const;
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index b49c1c663ee4..165a6170bbc2 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -82,10 +82,9 @@ public:
 
 void SetIncomplete(bool bIncomplete);
 
-template
 voidImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs,
   vcl::text::ImplLayoutArgs& 
rMultiArgs,
-  const DC* pMultiDXArray);
+  const double* pMultiDXArray);
 
 virtual ~MultiSalLayout() override;
 
@@ -101,10 +100,10 @@ private:
 
 class VCL_DLLPUBLIC GenericSalLayout : public SalLayout
 {
-template friend void MultiSalLayout::ImplAdjustMultiLayout(
+friend void MultiSalLayout::ImplAdjustMultiLayout(
 vcl::text::ImplLayoutArgs& rArgs,
 vcl::text::ImplLayoutArgs& rMultiArgs,
-const DC* pMultiDXArray);
+const double* pMultiDXArray);
 
 public:
 GenericSalLayout(LogicalFontInstance&);
@@ -142,8 +141,7 @@ private:
 GenericSalLayout( const GenericSalLayout& ) = delete;
 GenericSalLayout& operator=( const GenericSalLayout& ) = 
delete;
 
-template
-voidApplyDXArray(const DC*, const sal_Bool*);
+voidApplyDXArray(const double*, const sal_Bool*);
 voidJustify(DeviceCoordinate nNewWidth);
 voidApplyAsianKerning(const OUString& rStr);
 
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index eff9dab9acbb..4072a47d7109 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -196,10 +196,8 @@ void 
GenericSalLayout::AdjustLayout(vcl::text::ImplLayoutArgs& rArgs)
 {
 SalLayout::AdjustLayout(rArgs);
 
-if (rArgs.mpAltNaturalDXArray) // Used when 
"TextRenderModeForResolutionIndependentLayout" is set
-ApplyDXArray(rArgs.mpAltNaturalDXArray, rArgs.mpKashidaArray);
-else if (rArgs.mpDXArray)   // Normal case
-

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

2022-08-19 Thread Chris Sherlock (via logerrit)
 vcl/inc/animate/AnimationRenderer.hxx|   12 ++--
 vcl/source/animate/Animation.cxx |   16 
 vcl/source/animate/AnimationRenderer.cxx |   10 +-
 3 files changed, 19 insertions(+), 19 deletions(-)

New commits:
commit c61d9e70b1bf4948408392217b9fbed9a2dc5ab1
Author: Chris Sherlock 
AuthorDate: Fri Jul 1 17:28:21 2022 +1000
Commit: Tomaž Vajngerl 
CommitDate: Fri Aug 19 10:20:55 2022 +0200

vcl: rename AnimationData fields to more sane names

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

diff --git a/vcl/inc/animate/AnimationRenderer.hxx 
b/vcl/inc/animate/AnimationRenderer.hxx
index 95de08014a21..bd4bdc61019e 100644
--- a/vcl/inc/animate/AnimationRenderer.hxx
+++ b/vcl/inc/animate/AnimationRenderer.hxx
@@ -30,12 +30,12 @@ struct AnimationBitmap;
 
 struct AnimationData
 {
-Point   aStartOrg;
-SizeaStartSize;
-VclPtr   pOutDev;
-void*   pRendererData;
-tools::Long nRendererId;
-boolmbIsPaused;
+Point maOriginStartPt;
+Size maStartSize;
+VclPtr mpRenderContext;
+void* mpRendererData;
+tools::Long mnRendererId;
+bool mbIsPaused;
 
 AnimationData();
 };
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index 831532d5977a..baa9c186023d 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -301,17 +301,17 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
 for (auto& pDataItem : aDataItems)
 {
 AnimationRenderer* pRenderer = nullptr;
-if (!pDataItem->pRendererData)
+if (!pDataItem->mpRendererData)
 {
-pRenderer
-= new AnimationRenderer(this, pDataItem->pOutDev, 
pDataItem->aStartOrg,
-pDataItem->aStartSize, 
pDataItem->nRendererId);
+pRenderer = new AnimationRenderer(
+this, pDataItem->mpRenderContext, 
pDataItem->maOriginStartPt,
+pDataItem->maStartSize, pDataItem->mnRendererId);
 
 
maRenderers.push_back(std::unique_ptr(pRenderer));
 }
 else
 {
-pRenderer = 
static_cast(pDataItem->pRendererData);
+pRenderer = 
static_cast(pDataItem->mpRendererData);
 }
 
 pRenderer->pause(pDataItem->mbIsPaused);
@@ -682,9 +682,9 @@ SvStream& ReadAnimation(SvStream& rIStm, Animation& 
rAnimation)
 }
 
 AnimationData::AnimationData()
-: pOutDev(nullptr)
-, pRendererData(nullptr)
-, nRendererId(0)
+: mpRenderContext(nullptr)
+, mpRendererData(nullptr)
+, mnRendererId(0)
 , mbIsPaused(false)
 {
 }
diff --git a/vcl/source/animate/AnimationRenderer.cxx 
b/vcl/source/animate/AnimationRenderer.cxx
index 9bb5efc38ae9..21b43c3c08d6 100644
--- a/vcl/source/animate/AnimationRenderer.cxx
+++ b/vcl/source/animate/AnimationRenderer.cxx
@@ -311,11 +311,11 @@ AnimationData* AnimationRenderer::createAnimationData() 
const
 {
 AnimationData* pDataItem = new AnimationData;
 
-pDataItem->aStartOrg = maOriginPt;
-pDataItem->aStartSize = maLogicalSize;
-pDataItem->pOutDev = mpRenderContext;
-pDataItem->pRendererData = const_cast(this);
-pDataItem->nRendererId = mnRendererId;
+pDataItem->maOriginStartPt = maOriginPt;
+pDataItem->maStartSize = maLogicalSize;
+pDataItem->mpRenderContext = mpRenderContext;
+pDataItem->mpRendererData = const_cast(this);
+pDataItem->mnRendererId = mnRendererId;
 pDataItem->mbIsPaused = mbIsPaused;
 
 return pDataItem;


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

2022-08-12 Thread Caolán McNamara (via logerrit)
 vcl/inc/graphic/GraphicFormatDetector.hxx   |2 +-
 vcl/source/filter/GraphicFormatDetector.cxx |1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f4f869400922e8803f4ece673f26a31983be052b
Author: Caolán McNamara 
AuthorDate: Thu Aug 11 20:54:09 2022 +0100
Commit: Caolán McNamara 
CommitDate: Fri Aug 12 10:16:36 2022 +0200

cid#1507888 Uninitialized scalar field

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

diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx 
b/vcl/inc/graphic/GraphicFormatDetector.hxx
index 5d5ff7f9ece3..a9cb94320a0b 100644
--- a/vcl/inc/graphic/GraphicFormatDetector.hxx
+++ b/vcl/inc/graphic/GraphicFormatDetector.hxx
@@ -193,8 +193,8 @@ private:
 sal_uInt8* checkAndUncompressBuffer(sal_uInt8* aUncompressedBuffer, 
sal_uInt32 nSize,
 sal_uInt64& nDecompressedSize);
 bool mbExtendedInfo;
-GraphicMetadata maMetadata;
 bool mbWasCompressed;
+GraphicMetadata maMetadata;
 };
 }
 
diff --git a/vcl/source/filter/GraphicFormatDetector.cxx 
b/vcl/source/filter/GraphicFormatDetector.cxx
index 4cf30e6e8571..e2345208d6f6 100644
--- a/vcl/source/filter/GraphicFormatDetector.cxx
+++ b/vcl/source/filter/GraphicFormatDetector.cxx
@@ -347,6 +347,7 @@ GraphicFormatDetector::GraphicFormatDetector(SvStream& 
rStream, OUString aFormat
 , mnStreamPosition(0)
 , mnStreamLength(0)
 , mbExtendedInfo(bExtendedInfo)
+, mbWasCompressed(false)
 , maMetadata()
 {
 }


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

2022-08-09 Thread Chris Sherlock (via logerrit)
 vcl/inc/animate/AnimationRenderer.hxx|   10 ++---
 vcl/source/animate/Animation.cxx |2 -
 vcl/source/animate/AnimationRenderer.cxx |   62 +++
 3 files changed, 37 insertions(+), 37 deletions(-)

New commits:
commit 91d77d65190e7cf11dd7cd0b29d5de6b66061faf
Author: Chris Sherlock 
AuthorDate: Fri Jul 1 17:16:21 2022 +1000
Commit: Tomaž Vajngerl 
CommitDate: Wed Aug 10 07:53:08 2022 +0200

vcl: AnimationRenderer::getOutPos() -> GetOriginPosition()

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

diff --git a/vcl/inc/animate/AnimationRenderer.hxx 
b/vcl/inc/animate/AnimationRenderer.hxx
index bc98f9ac3093..95de08014a21 100644
--- a/vcl/inc/animate/AnimationRenderer.hxx
+++ b/vcl/inc/animate/AnimationRenderer.hxx
@@ -50,11 +50,11 @@ private:
 Animation*  mpParent;
 VclPtr  mpRenderContext;
 tools::Long mnRendererId;
-Point   maPt;
+Point   maOriginPt;
 Point   maDispPt;
 Point   maRestPt;
-SizemaSz;
-SizemaSzPix;
+SizemaLogicalSize;
+SizemaSizePx;
 SizemaDispSz;
 SizemaRestSz;
 vcl::Region maClip;
@@ -82,9 +82,9 @@ public:
 
 voidgetPosSize( const AnimationBitmap& rAnm, Point& rPosPix, 
Size& rSizePix );
 
-const Point&getOutPos() const { return maPt; }
+const Point&getOriginPosition() const { return maOriginPt; }
 
-const Size& getOutSizePix() const { return maSzPix; }
+const Size& getOutSizePix() const { return maSizePx; }
 
 voidpause( bool bIsPaused ) { mbIsPaused = bIsPaused; }
 boolisPaused() const { return mbIsPaused; }
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index 0922dec2bf37..831532d5977a 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -181,7 +181,7 @@ bool Animation::Start(OutputDevice& rOut, const Point& 
rDestPt, const Size& rDes
 
 if (itAnimView != maRenderers.end())
 {
-if ((*itAnimView)->getOutPos() == rDestPt
+if ((*itAnimView)->getOriginPosition() == rDestPt
 && (*itAnimView)->getOutSizePix() == 
rOut.LogicToPixel(rDestSz))
 {
 (*itAnimView)->repaint();
diff --git a/vcl/source/animate/AnimationRenderer.cxx 
b/vcl/source/animate/AnimationRenderer.cxx
index e4ce509a694d..9bb5efc38ae9 100644
--- a/vcl/source/animate/AnimationRenderer.cxx
+++ b/vcl/source/animate/AnimationRenderer.cxx
@@ -32,10 +32,10 @@ AnimationRenderer::AnimationRenderer( Animation* pParent, 
OutputDevice* pOut,
 OutputDevice* pFirstFrameOutDev ) :
 mpParent( pParent ),
 mpRenderContext ( pFirstFrameOutDev ? pFirstFrameOutDev : pOut ),
-mnRendererId ( nRendererId ),
-maPt( rPt ),
-maSz( rSz ),
-maSzPix ( mpRenderContext->LogicToPixel( maSz ) ),
+mnRendererId( nRendererId ),
+maOriginPt  ( rPt ),
+maLogicalSize   ( rSz ),
+maSizePx( mpRenderContext->LogicToPixel( maLogicalSize ) ),
 maClip  ( mpRenderContext->GetClipRegion() ),
 mpBackground( VclPtr::Create() ),
 mpRestore   ( VclPtr::Create() ),
@@ -43,40 +43,40 @@ AnimationRenderer::AnimationRenderer( Animation* pParent, 
OutputDevice* pOut,
 meLastDisposal  ( Disposal::Back ),
 mbIsPaused  ( false ),
 mbIsMarked  ( false ),
-mbIsMirroredHorizontally ( maSz.Width() < 0 ),
-mbIsMirroredVertically ( maSz.Height() < 0 )
+mbIsMirroredHorizontally( maLogicalSize.Width() < 0 ),
+mbIsMirroredVertically( maLogicalSize.Height() < 0 )
 {
 Animation::ImplIncAnimCount();
 
 // Mirrored horizontally?
 if( mbIsMirroredHorizontally )
 {
-maDispPt.setX( maPt.X() + maSz.Width() + 1 );
-maDispSz.setWidth( -maSz.Width() );
-maSzPix.setWidth( -maSzPix.Width() );
+maDispPt.setX( maOriginPt.X() + maLogicalSize.Width() + 1 );
+maDispSz.setWidth( -maLogicalSize.Width() );
+maSizePx.setWidth( -maSizePx.Width() );
 }
 else
 {
-maDispPt.setX( maPt.X() );
-maDispSz.setWidth( maSz.Width() );
+maDispPt.setX( maOriginPt.X() );
+maDispSz.setWidth( maLogicalSize.Width() );
 }
 
 // Mirrored vertically?
 if( mbIsMirroredVertically )
 {
-maDispPt.setY( maPt.Y() + maSz.Height() + 1 );
-maDispSz.setHeight( -maSz.Height() );
-maSzPix.setHeight( -maSzPix.Height() );
+maDispPt.setY( maOriginPt.Y() + maLogicalSize.Height() + 1 );
+

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

2022-08-09 Thread offtkp (via logerrit)
 vcl/inc/graphic/GraphicFormatDetector.hxx   |2 -
 vcl/source/filter/GraphicFormatDetector.cxx |   11 ++-
 vcl/source/filter/graphicfilter2.cxx|   39 +++-
 3 files changed, 15 insertions(+), 37 deletions(-)

New commits:
commit 100893da6f1db69f79d6c35b63df4053a9341784
Author: offtkp 
AuthorDate: Sun Aug 7 21:57:14 2022 +0300
Commit: Tomaž Vajngerl 
CommitDate: Wed Aug 10 07:48:38 2022 +0200

Remove code duplication in GraphicDescriptor for GIF

GraphicFormatDetector and GraphicDescriptor have duplicate format
detection code so now GraphicDescriptor uses GraphicFormatDetector
functions instead to detect the format for GIF files

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

diff --git a/vcl/inc/graphic/GraphicFormatDetector.hxx 
b/vcl/inc/graphic/GraphicFormatDetector.hxx
index bb5ffa37361a..5d5ff7f9ece3 100644
--- a/vcl/inc/graphic/GraphicFormatDetector.hxx
+++ b/vcl/inc/graphic/GraphicFormatDetector.hxx
@@ -192,7 +192,7 @@ private:
  */
 sal_uInt8* checkAndUncompressBuffer(sal_uInt8* aUncompressedBuffer, 
sal_uInt32 nSize,
 sal_uInt64& nDecompressedSize);
-// bool mbExtendedInfo;
+bool mbExtendedInfo;
 GraphicMetadata maMetadata;
 bool mbWasCompressed;
 };
diff --git a/vcl/source/filter/GraphicFormatDetector.cxx 
b/vcl/source/filter/GraphicFormatDetector.cxx
index 4c3b6663d3b1..4cf30e6e8571 100644
--- a/vcl/source/filter/GraphicFormatDetector.cxx
+++ b/vcl/source/filter/GraphicFormatDetector.cxx
@@ -339,14 +339,14 @@ bool isPCT(SvStream& rStream, sal_uLong nStreamPos, 
sal_uLong nStreamLen)
 } // end anonymous namespace
 
 GraphicFormatDetector::GraphicFormatDetector(SvStream& rStream, OUString 
aFormatExtension,
- bool /* bExtendedInfo */)
+ bool bExtendedInfo)
 : mrStream(rStream)
 , maExtension(std::move(aFormatExtension))
 , mnFirstLong(0)
 , mnSecondLong(0)
 , mnStreamPosition(0)
 , mnStreamLength(0)
-// , mbExtendedInfo(bExtendedInfo)
+, mbExtendedInfo(bExtendedInfo)
 , maMetadata()
 {
 }
@@ -516,6 +516,13 @@ bool GraphicFormatDetector::checkGIF()
 && maFirstBytes[5] == 0x61)
 {
 maMetadata.mnFormat = GraphicFileFormat::GIF;
+if (mbExtendedInfo)
+{
+sal_uInt16 nWidth = maFirstBytes[6] | (maFirstBytes[7] << 8);
+sal_uInt16 nHeight = maFirstBytes[8] | (maFirstBytes[9] << 8);
+maMetadata.maPixSize = Size(nWidth, nHeight);
+maMetadata.mnBitsPerPixel = ((maFirstBytes[10] & 112) >> 4) + 1;
+}
 return true;
 }
 return false;
diff --git a/vcl/source/filter/graphicfilter2.cxx 
b/vcl/source/filter/graphicfilter2.cxx
index f59beaeb93a2..0a58f03a98ea 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -217,41 +217,12 @@ bool GraphicDescriptor::ImpDetectBMP( SvStream& rStm, 
bool bExtendedInfo )
 
 bool GraphicDescriptor::ImpDetectGIF( SvStream& rStm, bool bExtendedInfo )
 {
-sal_uInt32  n32 = 0;
-boolbRet = false;
-
 sal_Int32 nStmPos = rStm.Tell();
-rStm.SetEndian( SvStreamEndian::LITTLE );
-rStm.ReadUInt32( n32 );
-
-if ( n32 == 0x38464947 )
-{
-sal_uInt16  n16 = 0;
-rStm.ReadUInt16( n16 );
-if ( ( n16 == 0x6137 ) || ( n16 == 0x6139 ) )
-{
-aMetadata.mnFormat = GraphicFileFormat::GIF;
-bRet = true;
-
-if ( bExtendedInfo )
-{
-sal_uInt16 nTemp16 = 0;
-sal_uInt8  cByte = 0;
-
-// Pixel width
-rStm.ReadUInt16( nTemp16 );
-aMetadata.maPixSize.setWidth( nTemp16 );
-
-// Pixel height
-rStm.ReadUInt16( nTemp16 );
-aMetadata.maPixSize.setHeight( nTemp16 );
-
-// Bits/Pixel
-rStm.ReadUChar( cByte );
-aMetadata.mnBitsPerPixel = ( ( cByte & 112 ) >> 4 ) + 1;
-}
-}
-}
+vcl::GraphicFormatDetector aDetector( rStm, aPathExt, bExtendedInfo );
+bool bRet = aDetector.detect();
+bRet &= aDetector.checkGIF();
+if ( bRet )
+aMetadata = aDetector.getMetadata();
 rStm.Seek( nStmPos );
 return bRet;
 }


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

2022-07-28 Thread Julien Nabet (via logerrit)
 vcl/inc/font/OpenTypeFeatureStrings.hrc   |5 +
 vcl/source/font/OpenTypeFeatureDefinitionList.cxx |5 +
 2 files changed, 2 insertions(+), 8 deletions(-)

New commits:
commit d07f18e0c3f8d50deea643c0ecab171795bd1231
Author: Julien Nabet 
AuthorDate: Thu Jul 28 18:06:36 2022 +0200
Commit: Julien Nabet 
CommitDate: Fri Jul 29 07:56:00 2022 +0200

tdf#126754: Wrong OpenType tag for fractions in "font features" dialog

Opentype defines only "frac" and not parameters values like 1 or 2 for 
"frac"

See:
https://en.wikipedia.org/wiki/List_of_typographic_features
https://docs.microsoft.com/en-us/typography/opentype/spec/features_fj

So remove STR_FONT_FEATURE_ID_FRAC_PARAM_0/1/2
+ remove the extra ":" for STR_FONT_FEATURE_ID_FRAC

I gave a try with "Alegraya" font, it worked.
I also give a try with "Linux Biolinum G", there are still "None" (value 
"0"), "Diagonal fractions" (value "1") and "Nut fractions" (value "2").
It seems they're on the font itself like entry "'frac' Diagonal and nut 
Fractions".

So it shouldn't bring regression.

Change-Id: I2f46a3f4a53dc498b764dbeb1c1266589cc8d8c7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137574
Reviewed-by: Caolán McNamara 
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git a/vcl/inc/font/OpenTypeFeatureStrings.hrc 
b/vcl/inc/font/OpenTypeFeatureStrings.hrc
index 5e1960b95613..a8bb5473fafb 100644
--- a/vcl/inc/font/OpenTypeFeatureStrings.hrc
+++ b/vcl/inc/font/OpenTypeFeatureStrings.hrc
@@ -40,10 +40,7 @@
 #define STR_FONT_FEATURE_ID_DPNG  NC_("STR_FONT_FEATURE_ID_DPNG", 
"Diphthongs (Obsolete)")
 #define STR_FONT_FEATURE_ID_EXPT  NC_("STR_FONT_FEATURE_ID_EXPT", 
"Expert Forms")
 #define STR_FONT_FEATURE_ID_FALT  NC_("STR_FONT_FEATURE_ID_FALT", 
"Final Glyph on Line Alternates")
-#define STR_FONT_FEATURE_ID_FRAC  NC_("STR_FONT_FEATURE_ID_FRAC", 
"Fraction style:")
-#define STR_FONT_FEATURE_ID_FRAC_PARAM_0  
NC_("STR_FONT_FEATURE_ID_FRAC_PARAM_0", "None")
-#define STR_FONT_FEATURE_ID_FRAC_PARAM_1  
NC_("STR_FONT_FEATURE_ID_FRAC_PARAM_1", "Diagonal Fractions")
-#define STR_FONT_FEATURE_ID_FRAC_PARAM_2  
NC_("STR_FONT_FEATURE_ID_FRAC_PARAM_2", "Nut Fractions")
+#define STR_FONT_FEATURE_ID_FRAC  NC_("STR_FONT_FEATURE_ID_FRAC", 
"Fraction style")
 #define STR_FONT_FEATURE_ID_FWID  NC_("STR_FONT_FEATURE_ID_FWID", 
"Full Widths")
 #define STR_FONT_FEATURE_ID_HALT  NC_("STR_FONT_FEATURE_ID_HALT", 
"Alternate Half Widths")
 #define STR_FONT_FEATURE_ID_HIST  NC_("STR_FONT_FEATURE_ID_HIST", 
"Historical Forms")
diff --git a/vcl/source/font/OpenTypeFeatureDefinitionList.cxx 
b/vcl/source/font/OpenTypeFeatureDefinitionList.cxx
index bd60c0e3bd32..f49837ccec43 100644
--- a/vcl/source/font/OpenTypeFeatureDefinitionList.cxx
+++ b/vcl/source/font/OpenTypeFeatureDefinitionList.cxx
@@ -45,10 +45,7 @@ void OpenTypeFeatureDefinitionListPrivate::init()
 { featureCode("dpng"), STR_FONT_FEATURE_ID_DPNG },
 { featureCode("expt"), STR_FONT_FEATURE_ID_EXPT },
 { featureCode("falt"), STR_FONT_FEATURE_ID_FALT },
-{ featureCode("frac"), STR_FONT_FEATURE_ID_FRAC,
-  std::vector{ { 0, STR_FONT_FEATURE_ID_FRAC_PARAM_0 
},
- { 1, STR_FONT_FEATURE_ID_FRAC_PARAM_1 
},
- { 2, STR_FONT_FEATURE_ID_FRAC_PARAM_2 
} } },
+{ featureCode("frac"), STR_FONT_FEATURE_ID_FRAC },
 { featureCode("fwid"), STR_FONT_FEATURE_ID_FWID },
 { featureCode("halt"), STR_FONT_FEATURE_ID_HALT },
 { featureCode("hist"), STR_FONT_FEATURE_ID_HIST },


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

2022-07-28 Thread Caolán McNamara (via logerrit)
 vcl/inc/svdata.hxx|2 ++
 vcl/source/window/brdwin.cxx  |3 ++-
 vcl/unx/gtk3/salnativewidgets-gtk.cxx |3 +++
 3 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit eaa0954fbf455ad7a71c011406e382ee7f7a8018
Author: Caolán McNamara 
AuthorDate: Thu Jul 28 10:41:29 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Jul 28 17:24:54 2022 +0200

gtk4: don't attempt to create a visual junction between float and launcher

the alignment won't match when using GtkPopover to implement these,
there's an extra border+margin between the launcher and the contents

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

diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
index 8490a6f020c5..3651eb3bce61 100644
--- a/vcl/inc/svdata.hxx
+++ b/vcl/inc/svdata.hxx
@@ -327,6 +327,8 @@ struct ImplSVNWFData
 boolmbFlatMenu = false; // no popup 3D 
border
 boolmbNoFocusRects = false; // on Aqua/Gtk3 
use native focus rendering, except for flat buttons
 boolmbNoFocusRectsForFlatButtons = false; // on Gtk3 
native focusing is also preferred for flat buttons
+boolmbNoFrameJunctionForPopups = false; // on Gtk4 
popups are done via popovers and a toolbar menu won't align to its toolitem, so
+// omit the 
effort the creation a visual junction
 boolmbCenteredTabs = false; // on Aqua, tabs 
are centered
 boolmbNoActiveTabTextRaise = false; // on Aqua the 
text for the selected tab
 // should not 
"jump up" a pixel
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index c003ed17b78d..6617de6414b3 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -1363,7 +1363,8 @@ void 
ImplStdBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, con
 vcl::Region oldClipRgn(rRenderContext.GetClipRegion());
 
 // for popups, don't draw part of the frame
-if (!(pData->mnTitleType & (BorderWindowTitleType::Normal | 
BorderWindowTitleType::Small)))
+const bool bShowJunctionToLauncher = !(pData->mnTitleType & 
(BorderWindowTitleType::Normal | BorderWindowTitleType::Small));
+if (bShowJunctionToLauncher && 
!ImplGetSVData()->maNWFData.mbNoFrameJunctionForPopups)
 {
 FloatingWindow* pWin = 
dynamic_cast(pData->mpBorderWindow->GetWindow(GetWindowType::Client));
 if (pWin)
diff --git a/vcl/unx/gtk3/salnativewidgets-gtk.cxx 
b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
index 3074dd0fbad7..3bbc9365f46d 100644
--- a/vcl/unx/gtk3/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/salnativewidgets-gtk.cxx
@@ -2823,6 +2823,9 @@ void GtkSalData::initNWF()
 pSVData->maNWFData.mbNoFocusRects = true;
 pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true;
 pSVData->maNWFData.mbAutoAccel = true;
+#if GTK_CHECK_VERSION(4, 0, 0)
+pSVData->maNWFData.mbNoFrameJunctionForPopups = true;
+#endif
 
 #if defined(GDK_WINDOWING_WAYLAND)
 //gnome#768128 for the car crash that is wayland


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

2022-07-28 Thread Chris Sherlock (via logerrit)
 vcl/inc/animate/AnimationRenderer.hxx|4 ++--
 vcl/source/animate/Animation.cxx |6 +++---
 vcl/source/animate/AnimationRenderer.cxx |2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 756ff6f6dfb24048c43b682a95241d5548a1bb8f
Author: Chris Sherlock 
AuthorDate: Fri Jul 1 17:25:37 2022 +1000
Commit: Tomaž Vajngerl 
CommitDate: Thu Jul 28 16:27:19 2022 +0200

vcl: Animation - cleanup pause functions and fields

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

diff --git a/vcl/inc/animate/AnimationRenderer.hxx 
b/vcl/inc/animate/AnimationRenderer.hxx
index 6b86d07bb2de..bc98f9ac3093 100644
--- a/vcl/inc/animate/AnimationRenderer.hxx
+++ b/vcl/inc/animate/AnimationRenderer.hxx
@@ -35,7 +35,7 @@ struct AnimationData
 VclPtr   pOutDev;
 void*   pRendererData;
 tools::Long nRendererId;
-boolbPause;
+boolmbIsPaused;
 
 AnimationData();
 };
@@ -87,7 +87,7 @@ public:
 const Size& getOutSizePix() const { return maSzPix; }
 
 voidpause( bool bIsPaused ) { mbIsPaused = bIsPaused; }
-boolisPause() const { return mbIsPaused; }
+boolisPaused() const { return mbIsPaused; }
 
 voidsetMarked( bool bIsMarked ) { mbIsMarked = bIsMarked; }
 boolisMarked() const { return mbIsMarked; }
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index f7d6a4f27a93..0922dec2bf37 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -314,7 +314,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
 pRenderer = 
static_cast(pDataItem->pRendererData);
 }
 
-pRenderer->pause(pDataItem->bPause);
+pRenderer->pause(pDataItem->mbIsPaused);
 pRenderer->setMarked(true);
 }
 
@@ -326,7 +326,7 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
 
 // check if every remaining view is paused
 bGlobalPause = std::all_of(maRenderers.cbegin(), 
maRenderers.cend(),
-   [](const auto& pRenderer) { return 
pRenderer->isPause(); });
+   [](const auto& pRenderer) { return 
pRenderer->isPaused(); });
 
 // reset marked state
 std::for_each(maRenderers.cbegin(), maRenderers.cend(),
@@ -685,7 +685,7 @@ AnimationData::AnimationData()
 : pOutDev(nullptr)
 , pRendererData(nullptr)
 , nRendererId(0)
-, bPause(false)
+, mbIsPaused(false)
 {
 }
 
diff --git a/vcl/source/animate/AnimationRenderer.cxx 
b/vcl/source/animate/AnimationRenderer.cxx
index 51aaa590d24b..e4ce509a694d 100644
--- a/vcl/source/animate/AnimationRenderer.cxx
+++ b/vcl/source/animate/AnimationRenderer.cxx
@@ -316,7 +316,7 @@ AnimationData* AnimationRenderer::createAnimationData() 
const
 pDataItem->pOutDev = mpRenderContext;
 pDataItem->pRendererData = const_cast(this);
 pDataItem->nRendererId = mnRendererId;
-pDataItem->bPause = mbIsPaused;
+pDataItem->mbIsPaused = mbIsPaused;
 
 return pDataItem;
 }


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

2022-07-19 Thread Chris Sherlock (via logerrit)
 vcl/inc/animate/AnimationRenderer.hxx|6 +++---
 vcl/source/animate/Animation.cxx |   23 ---
 vcl/source/animate/AnimationRenderer.cxx |   18 +-
 3 files changed, 24 insertions(+), 23 deletions(-)

New commits:
commit 44422b97e9d6398919445363b81b4cd1ab184ce3
Author: Chris Sherlock 
AuthorDate: Fri Jun 24 18:16:07 2022 +1000
Commit: Tomaž Vajngerl 
CommitDate: Tue Jul 19 19:52:11 2022 +0200

vcl: AInfo -> AnimationData

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

diff --git a/vcl/inc/animate/AnimationRenderer.hxx 
b/vcl/inc/animate/AnimationRenderer.hxx
index 18128558a44e..6b86d07bb2de 100644
--- a/vcl/inc/animate/AnimationRenderer.hxx
+++ b/vcl/inc/animate/AnimationRenderer.hxx
@@ -28,7 +28,7 @@ class OutputDevice;
 class VirtualDevice;
 struct AnimationBitmap;
 
-struct AInfo
+struct AnimationData
 {
 Point   aStartOrg;
 SizeaStartSize;
@@ -37,7 +37,7 @@ struct AInfo
 tools::Long nRendererId;
 boolbPause;
 
-AInfo();
+AnimationData();
 };
 
 
@@ -78,7 +78,7 @@ public:
 voiddrawToIndex( sal_uLong nIndex );
 voiddraw( sal_uLong nIndex, VirtualDevice* pVDev=nullptr );
 voidrepaint();
-AInfo*  createAInfo() const;
+AnimationData*  createAnimationData() const;
 
 voidgetPosSize( const AnimationBitmap& rAnm, Point& rPosPix, 
Size& rSizePix );
 
diff --git a/vcl/source/animate/Animation.cxx b/vcl/source/animate/Animation.cxx
index b0270c194c95..f7d6a4f27a93 100644
--- a/vcl/source/animate/Animation.cxx
+++ b/vcl/source/animate/Animation.cxx
@@ -290,30 +290,31 @@ IMPL_LINK_NOARG(Animation, ImplTimeoutHdl, Timer*, void)
 
 if (maNotifyLink.IsSet())
 {
-std::vector> aAInfoList;
-// create AInfo-List
+std::vector> aDataItems;
+// create AnimationData-List
 for (auto const& i : maRenderers)
-aAInfoList.emplace_back(i->createAInfo());
+aDataItems.emplace_back(i->createAnimationData());
 
 maNotifyLink.Call(this);
 
-// set view state from AInfo structure
-for (auto& pAInfo : aAInfoList)
+// set view state from AnimationData structure
+for (auto& pDataItem : aDataItems)
 {
 AnimationRenderer* pRenderer = nullptr;
-if (!pAInfo->pRendererData)
+if (!pDataItem->pRendererData)
 {
-pRenderer = new AnimationRenderer(this, pAInfo->pOutDev, 
pAInfo->aStartOrg,
-  pAInfo->aStartSize, 
pAInfo->nRendererId);
+pRenderer
+= new AnimationRenderer(this, pDataItem->pOutDev, 
pDataItem->aStartOrg,
+pDataItem->aStartSize, 
pDataItem->nRendererId);
 
 
maRenderers.push_back(std::unique_ptr(pRenderer));
 }
 else
 {
-pRenderer = 
static_cast(pAInfo->pRendererData);
+pRenderer = 
static_cast(pDataItem->pRendererData);
 }
 
-pRenderer->pause(pAInfo->bPause);
+pRenderer->pause(pDataItem->bPause);
 pRenderer->setMarked(true);
 }
 
@@ -680,7 +681,7 @@ SvStream& ReadAnimation(SvStream& rIStm, Animation& 
rAnimation)
 return rIStm;
 }
 
-AInfo::AInfo()
+AnimationData::AnimationData()
 : pOutDev(nullptr)
 , pRendererData(nullptr)
 , nRendererId(0)
diff --git a/vcl/source/animate/AnimationRenderer.cxx 
b/vcl/source/animate/AnimationRenderer.cxx
index 59843e19c893..51aaa590d24b 100644
--- a/vcl/source/animate/AnimationRenderer.cxx
+++ b/vcl/source/animate/AnimationRenderer.cxx
@@ -307,18 +307,18 @@ void AnimationRenderer::repaint()
 mbIsPaused = bOldPause;
 }
 
-AInfo* AnimationRenderer::createAInfo() const
+AnimationData* AnimationRenderer::createAnimationData() const
 {
-AInfo* pAInfo = new AInfo;
+AnimationData* pDataItem = new AnimationData;
 
-pAInfo->aStartOrg = maPt;
-pAInfo->aStartSize = maSz;
-pAInfo->pOutDev = mpRenderContext;
-pAInfo->pRendererData = const_cast(this);
-pAInfo->nRendererId = mnRendererId;
-pAInfo->bPause = mbIsPaused;
+pDataItem->aStartOrg = maPt;
+pDataItem->aStartSize = maSz;
+pDataItem->pOutDev = mpRenderContext;
+pDataItem->pRendererData = const_cast(this);
+pDataItem->nRendererId = mnRendererId;
+pDataItem->bPause = mbIsPaused;
 
-return pAInfo;
+return pDataItem;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2022-06-09 Thread Khaled Hosny (via logerrit)
 vcl/inc/pdf/pdfwriter_impl.hxx  |8 +--
 vcl/source/gdi/pdfwriter_impl.cxx   |   23 +++-
 vcl/source/gdi/salgdilayout.cxx |   23 +++-
 vcl/unx/generic/fontmanager/fontmanager.cxx |   31 +++-
 4 files changed, 53 insertions(+), 32 deletions(-)

New commits:
commit be39eba9a3d81e20c42f1073a365e91ce855c1cd
Author: Khaled Hosny 
AuthorDate: Mon Jun 6 00:17:02 2022 +0200
Commit: Caolán McNamara 
CommitDate: Thu Jun 9 10:03:51 2022 +0200

Use same glyph width in PDF drawing and font subset

During PDF drawing we already know the glyph width, but when subsetting
we get it again from the font subset.

For fonts without CFF table this is redundant but harmless, but for
fonts with CFF table, if the CFF and hmtx table (the authoritative
source of glyph widths) disagree, we will be drawing the PDF string with
the wrong adjustment resulting in displaced glyphs. This is a font bug,
but avoiding redundancy and having one source of truth is an improvement
overall.

I kept the code that calculates advance widths for font subsets, just in
case it is is still used elsewhere.

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

diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index ae461895a55b..869ba7883458 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -287,15 +287,19 @@ class GlyphEmit
 // performance: actually this should probably a vector;
 std::vectorm_CodeUnits;
 sal_uInt8   m_nSubsetGlyphID;
+sal_Int32   m_nGlyphWidth;
 
 public:
-GlyphEmit() : m_nSubsetGlyphID(0)
+GlyphEmit() : m_nSubsetGlyphID(0), m_nGlyphWidth(0)
 {
 }
 
 void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; }
 sal_uInt8 getGlyphId() const { return m_nSubsetGlyphID; }
 
+void setGlyphWidth( sal_Int32 nWidth ) { m_nGlyphWidth = nWidth; }
+sal_Int32 getGlyphWidth() const { return m_nGlyphWidth; }
+
 void addCode( sal_Ucs i_cCode )
 {
 m_CodeUnits.push_back(i_cCode);
@@ -817,7 +821,7 @@ i12626
 void appendLiteralStringEncrypt( std::string_view rInString, const 
sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
 
 /* creates fonts and subsets that will be emitted later */
-void registerGlyph(const GlyphItem* pGlyph, const 
vcl::font::PhysicalFontFace* pFont, const std::vector& rCodeUnits, 
sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject);
+void registerGlyph(const GlyphItem* pGlyph, const 
vcl::font::PhysicalFontFace* pFont, const std::vector& rCodeUnits, 
sal_Int32 nGlyphWidth, sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject);
 
 /*  emits a text object according to the passed layout */
 /* TODO: remove rText as soon as SalLayout will change so that rText is 
not necessary anymore */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx 
b/vcl/source/gdi/pdfwriter_impl.cxx
index 23ca498ea73b..4ae1d9f5d242 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2681,6 +2681,7 @@ bool PDFWriterImpl::emitFonts()
 pEncoding[ nEnc ] = nEnc;
 pEncToUnicodeIndex[ nEnc ] = 
static_cast(aCodeUnits.size());
 pCodeUnitsPerGlyph[ nEnc ] = item.second.countCodes();
+pWidths[ nEnc ] = item.second.getGlyphWidth();
 for( sal_Int32 n = 0; n < pCodeUnitsPerGlyph[ nEnc ]; n++ )
 aCodeUnits.push_back( item.second.getCode( n ) );
 if( item.second.getCode(0) )
@@ -2693,7 +2694,7 @@ bool PDFWriterImpl::emitFonts()
 }
 }
 FontSubsetInfo aSubsetInfo;
-if( pGraphics->CreateFontSubset( aTmpName, subset.first, 
aGlyphIds, pEncoding, pWidths, nGlyphs, aSubsetInfo ) )
+if( pGraphics->CreateFontSubset( aTmpName, subset.first, 
aGlyphIds, pEncoding, nullptr, nGlyphs, aSubsetInfo ) )
 {
 // create font stream
 osl::File aFontFile(aTmpName);
@@ -3901,9 +3902,17 @@ void PDFWriterImpl::createDefaultCheckBoxAppearance( 
PDFWidget& rBox, const PDFW
 const GlyphItem aItem(0, 0, pMap->GetGlyphIndex(cMark),
   DevicePoint(), GlyphItemFlags::NONE, 0, 0, 0);
 const std::vector aCodeUnits={ cMark };
+sal_Int32 nGlyphWidth = 0;
+SalGraphics *pGraphics = GetGraphics();
+if (pGraphics)
+nGlyphWidth = m_aFontCache.getGlyphWidth(pDevFont,
+ aItem.glyphId(),
+ aItem.IsVertical(),
+ pGraphics);
+
 sal_uInt8 

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

2022-05-28 Thread Michael Weghorn (via logerrit)
 vcl/inc/salframe.hxx  |6 
 vcl/inc/unx/gtk/gtkframe.hxx  |1 
 vcl/source/app/salvtables.cxx |   50 
 vcl/unx/gtk3/gtkframe.cxx |   52 --
 vcl/unx/gtk3/gtkinst.cxx  |2 -
 5 files changed, 58 insertions(+), 53 deletions(-)

New commits:
commit 54f6599a4de738dfe3a26e8229e5588d26dd8165
Author: Michael Weghorn 
AuthorDate: Sat May 28 10:44:29 2022 +0200
Commit: Michael Weghorn 
CommitDate: Sat May 28 16:08:45 2022 +0200

Move GtkSalFrame::CalcDeleteSurroundingSelection to SalFrame

It will be used for qt5/qt6 in a follow-up commit
as well.

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

diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index ac8840b437c7..1c5cbbbcd0ee 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -306,6 +306,12 @@ public:
 // (e.g. input methods, printer update handlers).
 boolCallCallback( SalEvent nEvent, const void* pEvent 
) const
 { return m_pProc && m_pProc( m_pWindow, nEvent, pEvent ); }
+
+// Helper method for input method handling: Calculate cursor index in 
(UTF-16) OUString,
+// starting at nCursorIndex, moving number of characters (not UTF-16 
codepoints) specified
+// in nOffset, nChars.
+static SelectionCalcDeleteSurroundingSelection(const OUString& 
rSurroundingText,
+   sal_Int32 
nCursorIndex, int nOffset, int nChars);
 };
 
 #ifdef _WIN32
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index c90afbdee899..91a9470a071e 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -633,7 +633,6 @@ public:
 GdkModifierType, gpointer pFrame);
 #endif
 static OUString GetPreeditDetails(GtkIMContext* pIMContext, 
std::vector& rInputFlags, sal_Int32& rCursorPos, sal_uInt8& 
rCursorFlags);
-static SelectionCalcDeleteSurroundingSelection(const OUString& 
rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars);
 
 const cairo_font_options_t* get_font_options();
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 07a8a649c8ba..fd7739f3c460 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -7375,4 +7375,54 @@ weld::Window* SalFrame::GetFrameWeld() const
 return m_xFrameWeld.get();
 }
 
+Selection SalFrame::CalcDeleteSurroundingSelection(const OUString& 
rSurroundingText,
+   sal_Int32 nCursorIndex, int 
nOffset, int nChars)
+{
+Selection aInvalid(SAL_MAX_UINT32, SAL_MAX_UINT32);
+
+if (nCursorIndex == -1)
+return aInvalid;
+
+if (nOffset > 0)
+{
+while (nOffset && nCursorIndex < rSurroundingText.getLength())
+{
+rSurroundingText.iterateCodePoints(, 1);
+--nOffset;
+}
+}
+else if (nOffset < 0)
+{
+while (nOffset && nCursorIndex > 0)
+{
+rSurroundingText.iterateCodePoints(, -1);
+++nOffset;
+}
+}
+
+if (nOffset)
+{
+SAL_WARN("vcl",
+ "SalFrame::CalcDeleteSurroundingSelection, unable to move to 
offset: " << nOffset);
+return aInvalid;
+}
+
+sal_Int32 nCursorEndIndex(nCursorIndex);
+sal_Int32 nCount(0);
+while (nCount < nChars && nCursorEndIndex < rSurroundingText.getLength())
+{
+rSurroundingText.iterateCodePoints(, 1);
+++nCount;
+}
+
+if (nCount != nChars)
+{
+SAL_WARN("vcl", "SalFrame::CalcDeleteSurroundingSelection, unable to 
select: "
+<< nChars << " characters");
+return aInvalid;
+}
+
+return Selection(nCursorIndex, nCursorEndIndex);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk3/gtkframe.cxx b/vcl/unx/gtk3/gtkframe.cxx
index 80f235d10642..3684dd560593 100644
--- a/vcl/unx/gtk3/gtkframe.cxx
+++ b/vcl/unx/gtk3/gtkframe.cxx
@@ -5710,56 +5710,6 @@ gboolean 
GtkSalFrame::IMHandler::signalIMRetrieveSurrounding( GtkIMContext* pCon
 return true;
 }
 
-Selection GtkSalFrame::CalcDeleteSurroundingSelection(const OUString& 
rSurroundingText, sal_Int32 nCursorIndex, int nOffset, int nChars)
-{
-Selection aInvalid(SAL_MAX_UINT32, SAL_MAX_UINT32);
-
-if (nCursorIndex == -1)
-return aInvalid;
-
-// Note that offset and n_chars are in characters not in bytes
-// which differs from the usage other places in GtkIMContext
-
-if (nOffset > 0)
-{
-while (nOffset && nCursorIndex < rSurroundingText.getLength())
-{
-rSurroundingText.iterateCodePoints(, 1);
---nOffset;
-}
-}
-else if (nOffset 

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

2022-05-21 Thread Caolán McNamara (via logerrit)
 vcl/inc/impglyphitem.hxx |   14 +++---
 vcl/source/gdi/sallayout.cxx |4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

New commits:
commit 098df8583bc8d4a8d0210525f05f69b460386a46
Author: Caolán McNamara 
AuthorDate: Sat May 21 17:31:48 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 21 21:35:53 2022 +0200

ofz#47559 Integer-overflow

setLinearPosX already takes a double so use that type for nOffset,
use DeviceCoordinate as the types where that is the type of the
source data

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

diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index 18764cede500..7c3aa88849df 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -52,18 +52,18 @@ template <> struct typed_flags : 
is_typed_flags::iterator pGlyphIter = m_GlyphItems.begin(),
   pGlyphIterEnd = m_GlyphItems.end();
@@ -437,7 +437,7 @@ void GenericSalLayout::ApplyAsianKerning(const OUString& 
rStr)
 continue;
 
 // apply punctuation compression to logical glyph widths
-int nDelta = (nKernCurrent < nKernNext) ? nKernCurrent : nKernNext;
+DeviceCoordinate nDelta = (nKernCurrent < nKernNext) ? 
nKernCurrent : nKernNext;
 if (nDelta < 0)
 {
 nDelta = (nDelta * pGlyphIter->origWidth() + 2) / 4;


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

2022-05-19 Thread Caolán McNamara (via logerrit)
 vcl/inc/IconThemeSelector.hxx|3 ++-
 vcl/source/app/IconThemeSelector.cxx |   13 ++---
 vcl/source/app/settings.cxx  |9 +++--
 3 files changed, 19 insertions(+), 6 deletions(-)

New commits:
commit 0e10b846746e0a4861c42422c3bc9dd381af94e3
Author: Caolán McNamara 
AuthorDate: Thu May 19 11:08:50 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu May 19 16:30:00 2022 +0200

icon-theme not dynamically changing to match desktop if set to 'auto'

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

diff --git a/vcl/inc/IconThemeSelector.hxx b/vcl/inc/IconThemeSelector.hxx
index 7e2dfc0da1dd..8dab03d3a8d2 100644
--- a/vcl/inc/IconThemeSelector.hxx
+++ b/vcl/inc/IconThemeSelector.hxx
@@ -62,7 +62,8 @@ public:
 void
 SetUseHighContrastTheme(bool);
 
-void
+/** Returns true if the PreferredIconTheme was changed */
+bool
 SetPreferredIconTheme(const OUString&, bool bDarkIconTheme);
 
 bool
diff --git a/vcl/source/app/IconThemeSelector.cxx 
b/vcl/source/app/IconThemeSelector.cxx
index 253242bcd5ad..5abb7b29d5df 100644
--- a/vcl/source/app/IconThemeSelector.cxx
+++ b/vcl/source/app/IconThemeSelector.cxx
@@ -124,13 +124,20 @@ IconThemeSelector::SetUseHighContrastTheme(bool v)
 mUseHighContrastTheme = v;
 }
 
-void
+bool
 IconThemeSelector::SetPreferredIconTheme(const OUString& theme, bool 
bDarkIconTheme)
 {
 // lower case theme name, and (tdf#120175) replace - with _
 // see icon-themes/README
-mPreferredIconTheme = theme.toAsciiLowerCase().replace('-','_');
-mPreferDarkIconTheme = bDarkIconTheme;
+OUString sIconTheme = theme.toAsciiLowerCase().replace('-','_');
+
+const bool bChanged = mPreferredIconTheme != sIconTheme || 
mPreferDarkIconTheme != bDarkIconTheme;
+if (bChanged)
+{
+mPreferredIconTheme = sIconTheme;
+mPreferDarkIconTheme = bDarkIconTheme;
+}
+return bChanged;
 }
 
 bool
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index c7e8b8d1c6fa..f17c8286f68f 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -185,7 +185,7 @@ struct ImplStyleData
 std::shared_ptr
 mIconThemeSelector;
 
-OUString   mIconTheme;
+OUStringmIconTheme;
 boolmbSkipDisabledInMenus;
 boolmbHideDisabledMenuItems;
 boolmbPreferredContextMenuShortcuts;
@@ -3151,7 +3151,12 @@ StyleSettings::GetHighContrastMode() const
 void
 StyleSettings::SetPreferredIconTheme(const OUString& theme, bool 
bDarkIconTheme)
 {
-mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
+const bool bChanged = 
mxData->mIconThemeSelector->SetPreferredIconTheme(theme, bDarkIconTheme);
+if (bChanged)
+{
+// clear this so it is recalculated if it was selected as the 
automatic theme
+mxData->mIconTheme.clear();
+}
 }
 
 void


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

2022-05-11 Thread Caolán McNamara (via logerrit)
 vcl/inc/svimpbox.hxx|7 ---
 vcl/source/treelist/treelistbox.cxx |   16 ++--
 2 files changed, 2 insertions(+), 21 deletions(-)

New commits:
commit dad7593cf6bb91ecf95153e983723dd2cd03b469
Author: Caolán McNamara 
AuthorDate: Wed May 11 15:37:36 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed May 11 20:41:58 2022 +0200

GetDontKnowNodeBmp is always empty

so this is dead code, remove most of it, but recover setting
aControlValue.setTristateVal(ButtonValue::DontKnow) when the
possibility of expansion resulting in children is unknown

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

diff --git a/vcl/inc/svimpbox.hxx b/vcl/inc/svimpbox.hxx
index 9649708ddbfc..994a25f095ee 100644
--- a/vcl/inc/svimpbox.hxx
+++ b/vcl/inc/svimpbox.hxx
@@ -107,7 +107,6 @@ private:
 {
 NodeExpanded = 0, // node is expanded ( usually a bitmap showing a 
minus )
 NodeCollapsed,// node is collapsed ( usually a bitmap showing 
a plus )
-NodeDontKnow, // don't know the node state
 EntryDefExpanded, // default for expanded entries
 EntryDefCollapsed,// default for collapsed entries
 LAST = EntryDefCollapsed
@@ -280,7 +279,6 @@ public:
 
 inline const Image& GetExpandedNodeBmp( );
 inline const Image& GetCollapsedNodeBmp( );
-inline const Image& GetDontKnowNodeBmp( );
 
 inline void SetDefaultEntryExpBmp( const Image& _rImg );
 inline void SetDefaultEntryColBmp( const Image& _rImg );
@@ -338,11 +336,6 @@ inline void SvImpLBox::SetCollapsedNodeBmp( const Image& 
rImg )
 SetNodeBmpWidth( rImg );
 }
 
-inline const Image& SvImpLBox::GetDontKnowNodeBmp( )
-{
-return implGetImageLocation( ImageType::NodeDontKnow );
-}
-
 inline const Image& SvImpLBox::GetExpandedNodeBmp( )
 {
 return implGetImageLocation( ImageType::NodeExpanded );
diff --git a/vcl/source/treelist/treelistbox.cxx 
b/vcl/source/treelist/treelistbox.cxx
index 51c9d1f4c57c..3e231d257f93 100644
--- a/vcl/source/treelist/treelistbox.cxx
+++ b/vcl/source/treelist/treelistbox.cxx
@@ -2801,18 +2801,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, 
tools::Long nLine, vcl:
 if (IsExpanded())
 pImg = >GetExpandedNodeBmp();
 else
-{
-if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() &&
-(!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) &&
-pImpl->GetDontKnowNodeBmp().GetSizePixel().Width())
-{
-pImg = >GetDontKnowNodeBmp( );
-}
-else
-{
-pImg = >GetCollapsedNodeBmp( );
-}
-}
+pImg = >GetCollapsedNodeBmp();
 aPos.AdjustY((nTempEntryHeight - pImg->GetSizePixel().Height()) / 2 );
 
 DrawImageFlags nStyle = DrawImageFlags::NONE;
@@ -2835,8 +2824,7 @@ void SvTreeListBox::PaintEntry1(SvTreeListEntry& rEntry, 
tools::Long nLine, vcl:
 else
 {
 if ((!rEntry.HasChildren()) && rEntry.HasChildrenOnDemand() &&
-(!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)) &&
-pImpl->GetDontKnowNodeBmp().GetSizePixel().Width())
+(!(rEntry.GetFlags() & SvTLEntryFlags::HAD_CHILDREN)))
 {
 aControlValue.setTristateVal( ButtonValue::DontKnow ); //don't 
know
 }


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

2022-05-11 Thread Luboš Luňák (via logerrit)
 vcl/inc/impglyphitem.hxx|1 +
 vcl/source/gdi/impglyphitem.cxx |   30 ++
 2 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit 5caa7f44b861876afa5b3b8f71e3848abd8875e6
Author: Luboš Luňák 
AuthorDate: Wed May 11 16:32:52 2022 +0200
Commit: Luboš Luňák 
CommitDate: Wed May 11 19:00:42 2022 +0200

fix HB_GLYPH_FLAG_UNSAFE_TO_BREAK for RTL in cloneCharRange() (tdf#148954)

I got the meaning wrong, when the docs talk about beginning of a cluster,
that refers to text, not glyphs, so this needs to be backwards too.

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

diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index e86c2652100a..18764cede500 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -153,6 +153,7 @@ public:
 #endif
 
 private:
+bool isSafeToBreak(const_iterator pos, bool rtl) const;
 rtl::Reference m_rFontInstance;
 SalLayoutFlags mnFlags = SalLayoutFlags::NONE;
 };
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index 43f102102210..648696a55107 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -128,9 +128,7 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
 // (for non-RTL charPos is always the start of a multi-character glyph).
 if (rtl && pos->charPos() + pos->charCount() > beginPos + 1)
 return nullptr;
-// Don't create a subset if it's not safe to break at the beginning or end 
of the sequence
-// (https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-glyph-flags-t).
-if (pos->IsUnsafeToBreak() || (pos->IsInCluster() && 
!pos->IsClusterStart()))
+if (!isSafeToBreak(pos, rtl))
 return nullptr;
 // LinearPos needs adjusting to start at xOffset/yOffset for the first 
item,
 // that's how it's computed in GenericSalLayout::LayoutText().
@@ -163,7 +161,7 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
 // that we're not cutting in the middle of a multi-character glyph.
 if (rtl ? pos->charPos() + pos->charCount() != endPos + 1 : 
pos->charPos() != endPos)
 return nullptr;
-if (pos->IsUnsafeToBreak() || (pos->IsInCluster() && 
!pos->IsClusterStart()))
+if (!isSafeToBreak(pos, rtl))
 return nullptr;
 }
 // HACK: If mode is se to be RTL, but the last glyph is a non-RTL space,
@@ -179,6 +177,30 @@ SalLayoutGlyphsImpl* 
SalLayoutGlyphsImpl::cloneCharRange(sal_Int32 index, sal_In
 return copy.release();
 }
 
+bool SalLayoutGlyphsImpl::isSafeToBreak(const_iterator pos, bool rtl) const
+{
+if (rtl)
+{
+// RTL is more complicated, because HB_GLYPH_FLAG_UNSAFE_TO_BREAK 
talks about beginning
+// of a cluster, which refers to the text, not glyphs. This function 
is called
+// for the first glyph of the subset and the first glyph after the 
subset, but since
+// the glyphs are backwards, and we need the beginning of cluster at 
the start of the text
+// and beginning of the cluster after the text, we need to check 
glyphs before this position.
+if (pos == begin())
+return true;
+--pos;
+while (pos >= begin() && (pos->IsInCluster() && 
!pos->IsClusterStart()))
+--pos;
+if (pos < begin())
+return true;
+}
+// Don't create a subset if it's not safe to break at the beginning or end 
of the sequence
+// (https://harfbuzz.github.io/harfbuzz-hb-buffer.html#hb-glyph-flags-t).
+if (pos->IsUnsafeToBreak() || (pos->IsInCluster() && 
!pos->IsClusterStart()))
+return false;
+return true;
+}
+
 #ifdef DBG_UTIL
 bool SalLayoutGlyphsImpl::isEqual(const SalLayoutGlyphsImpl* other) const
 {


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

2022-05-09 Thread Noel Grandin (via logerrit)
 vcl/inc/salusereventlist.hxx|   14 ++
 vcl/source/app/salusereventlist.cxx |   16 
 2 files changed, 18 insertions(+), 12 deletions(-)

New commits:
commit 90523fd368cf249cb00bd1d881a2a19e1510ca85
Author: Noel Grandin 
AuthorDate: Thu May 5 22:22:51 2022 +0200
Commit: Noel Grandin 
CommitDate: Mon May 9 10:18:41 2022 +0200

osl::Mutex->std::mutex in SalUserEventList

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

diff --git a/vcl/inc/salusereventlist.hxx b/vcl/inc/salusereventlist.hxx
index cc5aa88c930c..864802c50a0b 100644
--- a/vcl/inc/salusereventlist.hxx
+++ b/vcl/inc/salusereventlist.hxx
@@ -22,7 +22,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 
 #include 
@@ -57,7 +57,7 @@ public:
 };
 
 protected:
-mutable osl::Mutex m_aUserEventsMutex;
+mutable std::mutex m_aUserEventsMutex;
 std::list< SalUserEvent >  m_aUserEvents;
 std::list< SalUserEvent >  m_aProcessingUserEvents;
 bool   m_bAllUserEventProcessedSignaled;
@@ -68,6 +68,7 @@ protected:
 virtual void TriggerUserEventProcessing() = 0;
 virtual void TriggerAllUserEventsProcessed() {}
 
+inline bool HasUserEvents_NoLock() const;
 public:
 SalUserEventList();
 virtual ~SalUserEventList() COVERITY_NOEXCEPT_FALSE;
@@ -100,13 +101,18 @@ inline bool SalUserEventList::isFrameAlive( const 
SalFrame* pFrame ) const
 
 inline bool SalUserEventList::HasUserEvents() const
 {
-osl::MutexGuard aGuard( m_aUserEventsMutex );
+std::unique_lock aGuard( m_aUserEventsMutex );
+return HasUserEvents_NoLock();
+}
+
+inline bool SalUserEventList::HasUserEvents_NoLock() const
+{
 return !(m_aUserEvents.empty() && m_aProcessingUserEvents.empty());
 }
 
 inline void SalUserEventList::PostEvent( SalFrame* pFrame, void* pData, 
SalEvent nEvent )
 {
-osl::MutexGuard aGuard( m_aUserEventsMutex );
+std::unique_lock aGuard( m_aUserEventsMutex );
 m_aUserEvents.push_back( SalUserEvent( pFrame, pData, nEvent ) );
 m_bAllUserEventProcessedSignaled = false;
 TriggerUserEventProcessing();
diff --git a/vcl/source/app/salusereventlist.cxx 
b/vcl/source/app/salusereventlist.cxx
index 949467ae218c..1e3f78cc43bf 100644
--- a/vcl/source/app/salusereventlist.cxx
+++ b/vcl/source/app/salusereventlist.cxx
@@ -62,7 +62,7 @@ bool SalUserEventList::DispatchUserEvents( bool 
bHandleAllCurrentEvents )
 oslThreadIdentifier aCurId = osl::Thread::getCurrentIdentifier();
 
 DBG_TESTSOLARMUTEX();
-osl::ResettableMutexGuard aResettableListGuard(m_aUserEventsMutex);
+std::unique_lock aResettableListGuard(m_aUserEventsMutex);
 
 if (!m_aUserEvents.empty())
 {
@@ -80,7 +80,7 @@ bool SalUserEventList::DispatchUserEvents( bool 
bHandleAllCurrentEvents )
 }
 }
 
-if (HasUserEvents())
+if (HasUserEvents_NoLock())
 {
 bWasEvent = true;
 m_aProcessingThread = aCurId;
@@ -93,13 +93,13 @@ bool SalUserEventList::DispatchUserEvents( bool 
bHandleAllCurrentEvents )
 m_aProcessingUserEvents.pop_front();
 
 // remember to reset the guard before break or continue the loop
-aResettableListGuard.clear();
+aResettableListGuard.unlock();
 
 if ( !isFrameAlive( aEvent.m_pFrame ) )
 {
 if ( aEvent.m_nEvent == SalEvent::UserEvent )
 delete static_cast< ImplSVEvent* >( aEvent.m_pData );
-aResettableListGuard.reset();
+aResettableListGuard.lock();
 continue;
 }
 
@@ -119,14 +119,14 @@ bool SalUserEventList::DispatchUserEvents( bool 
bHandleAllCurrentEvents )
 auto process = [, this] () noexcept { ProcessEvent(aEvent); 
};
 process();
 #endif
-aResettableListGuard.reset();
+aResettableListGuard.lock();
 if (!bHandleAllCurrentEvents)
 break;
 }
 while( true );
 }
 
-if ( !m_bAllUserEventProcessedSignaled && !HasUserEvents() )
+if ( !m_bAllUserEventProcessedSignaled && !HasUserEvents_NoLock() )
 {
 m_bAllUserEventProcessedSignaled = true;
 TriggerAllUserEventsProcessed();
@@ -139,7 +139,7 @@ void SalUserEventList::RemoveEvent( SalFrame* pFrame, void* 
pData, SalEvent nEve
 {
 SalUserEvent aEvent( pFrame, pData, nEvent );
 
-osl::MutexGuard aGuard( m_aUserEventsMutex );
+std::unique_lock aGuard( m_aUserEventsMutex );
 auto it = std::find( m_aUserEvents.begin(), m_aUserEvents.end(), aEvent );
 if ( it != m_aUserEvents.end() )
 {
@@ -154,7 +154,7 @@ void SalUserEventList::RemoveEvent( SalFrame* pFrame, void* 
pData, SalEvent nEve
 }
 }
 
-if ( !m_bAllUserEventProcessedSignaled && !HasUserEvents() )
+if ( 

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

2022-05-04 Thread Caolán McNamara (via logerrit)
 vcl/inc/salgdi.hxx  |   14 -
 vcl/source/gdi/salgdilayout.cxx |  103 +++-
 2 files changed, 82 insertions(+), 35 deletions(-)

New commits:
commit cceeb407c61e9af14a300e8fcfaa57fd91ede49e
Author: Caolán McNamara 
AuthorDate: Tue May 3 21:17:56 2022 +0100
Commit: Caolán McNamara 
CommitDate: Wed May 4 11:56:51 2022 +0200

Related: tdf#131725 match the basegfx translation to the mirror logic

that is used in the traditional code path, this will fix vcl RTL
scrollbars in otherwise LTR UI

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

diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index eed8ab7160ac..75938afecece 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -638,10 +638,18 @@ private:
 SalLayoutFlags  m_nLayout; //< 0: mirroring off, 1: mirror 
x-axis
 
 // for buffering the Mirror-Matrix, see ::getMirror
+enum class MirrorMode
+{
+NONE,
+Antiparallel,
+AntiparallelBiDi,
+BiDi
+};
+MirrorMode  m_eLastMirrorMode;
+tools::Long m_nLastMirrorTranslation;
 basegfx::B2DHomMatrix   m_aLastMirror;
-tools::Long m_aLastMirrorW;
-tools::Long m_nLastMirrorDeviceLTRButBiDiRtlTranslate;
-boolm_bLastMirrorDeviceLTRButBiDiRtlSet;
+
+MirrorMode GetMirrorMode(const OutputDevice& rOutDev) const;
 
 protected:
 /// flags which hold the SetAntialiasing() value from OutputDevice
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 89f9d0321daf..a998a7483df8 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -53,9 +53,8 @@ SalFrameGeometry SalFrame::GetGeometry() const
 
 SalGraphics::SalGraphics()
 :   m_nLayout( SalLayoutFlags::NONE ),
-m_aLastMirrorW(0),
-m_nLastMirrorDeviceLTRButBiDiRtlTranslate(0),
-m_bLastMirrorDeviceLTRButBiDiRtlSet(false),
+m_eLastMirrorMode(MirrorMode::NONE),
+m_nLastMirrorTranslation(0),
 m_bAntiAlias(false),
 m_bTextRenderModeForResolutionIndependentLayout(false)
 {
@@ -271,50 +270,90 @@ basegfx::B2DPolyPolygon SalGraphics::mirror( const 
basegfx::B2DPolyPolygon& i_rP
 }
 }
 
+SalGraphics::MirrorMode SalGraphics::GetMirrorMode(const OutputDevice& 
rOutDev) const
+{
+if (rOutDev.ImplIsAntiparallel())
+{
+if (m_nLayout & SalLayoutFlags::BiDiRtl)
+return MirrorMode::AntiparallelBiDi;
+else
+return MirrorMode::Antiparallel;
+}
+else if (m_nLayout & SalLayoutFlags::BiDiRtl)
+return MirrorMode::BiDi;
+return MirrorMode::NONE;
+}
+
 const basegfx::B2DHomMatrix& SalGraphics::getMirror( const OutputDevice& 
i_rOutDev ) const
 {
 // get mirroring transformation
-const tools::Long w = GetDeviceWidth(i_rOutDev);
-SAL_WARN_IF( !w, "vcl", "missing graphics width" );
-
-const bool bMirrorDeviceLTRButBiDiRtlSet = !i_rOutDev.IsRTLEnabled();
-tools::Long nMirrorDeviceLTRButBiDiRtlTranslate(0);
-if (bMirrorDeviceLTRButBiDiRtlSet)
-nMirrorDeviceLTRButBiDiRtlTranslate = w - 
i_rOutDev.GetOutputWidthPixel() - (2 * i_rOutDev.GetOutOffXPixel());
+MirrorMode eNewMirrorMode = GetMirrorMode(i_rOutDev);
+tools::Long nTranslate(0);
 
-// if the device width, or mirror state of the device changed, then 
m_aLastMirror is invalid
-bool bLastMirrorValid = w == m_aLastMirrorW && 
bMirrorDeviceLTRButBiDiRtlSet == m_bLastMirrorDeviceLTRButBiDiRtlSet;
-if (bLastMirrorValid && bMirrorDeviceLTRButBiDiRtlSet)
+switch (eNewMirrorMode)
 {
-// if the device is in the unusual mode of a LTR device, but layout 
flags of SalLayoutFlags::BiDiRtl are
-// in use, then the m_aLastMirror is invalid if the distance it should 
translate has changed
-bLastMirrorValid = nMirrorDeviceLTRButBiDiRtlTranslate == 
m_nLastMirrorDeviceLTRButBiDiRtlTranslate;
+case MirrorMode::AntiparallelBiDi:
+{
+const tools::Long w = GetDeviceWidth(i_rOutDev);
+SAL_WARN_IF(!w, "vcl", "missing graphics width");
+nTranslate = w - i_rOutDev.GetOutputWidthPixel() - (2 * 
i_rOutDev.GetOutOffXPixel());
+break;
+}
+case MirrorMode::Antiparallel:
+{
+nTranslate = i_rOutDev.GetOutputWidthPixel() + (2 * 
i_rOutDev.GetOutOffXPixel()) - 1;
+break;
+}
+case MirrorMode::BiDi:
+{
+const tools::Long w = GetDeviceWidth(i_rOutDev);
+SAL_WARN_IF(!w, "vcl", "missing graphics width");
+nTranslate = w - 1;
+break;
+}
+case MirrorMode::NONE:
+break;
 }
 
+// if the translation (due to device width), or mirror state of the 

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

2022-04-28 Thread Luboš Luňák (via logerrit)
 vcl/inc/fontinstance.hxx |4 ++--
 vcl/source/font/fontinstance.cxx |8 
 2 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit f8d6ec1a516237f0e9f73080b172ecba3e96478d
Author: Luboš Luňák 
AuthorDate: Thu Apr 28 08:30:22 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu Apr 28 12:36:02 2022 +0200

make some LogicalFontInstance functions const

They call non-const GetHbFont() internally, but conceptually they
are const.

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

diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 4f216df0389b..5cb05b1d3804 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -100,9 +100,9 @@ public: // TODO: make data members private
 bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle&, bool) const;
 virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) 
const = 0;
 
-int GetKashidaWidth();
+int GetKashidaWidth() const;
 
-void GetScale(double* nXScale, double* nYScale);
+void GetScale(double* nXScale, double* nYScale) const;
 static inline void DecodeOpenTypeTag(const uint32_t nTableTag, char* 
pTagName);
 
 protected:
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 5c63338b75a1..0907d657ad02 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -63,9 +63,9 @@ hb_font_t* LogicalFontInstance::InitHbFont(hb_face_t* pHbFace)
 return pHbFont;
 }
 
-int LogicalFontInstance::GetKashidaWidth()
+int LogicalFontInstance::GetKashidaWidth() const
 {
-hb_font_t* pHbFont = GetHbFont();
+hb_font_t* pHbFont = const_cast(this)->GetHbFont();
 hb_position_t nWidth = 0;
 hb_codepoint_t nIndex = 0;
 
@@ -79,9 +79,9 @@ int LogicalFontInstance::GetKashidaWidth()
 return nWidth;
 }
 
-void LogicalFontInstance::GetScale(double* nXScale, double* nYScale)
+void LogicalFontInstance::GetScale(double* nXScale, double* nYScale) const
 {
-hb_face_t* pHbFace = hb_font_get_face(GetHbFont());
+hb_face_t* pHbFace = 
hb_font_get_face(const_cast(this)->GetHbFont());
 unsigned int nUPEM = hb_face_get_upem(pHbFace);
 
 double nHeight(m_aFontSelData.mnHeight);


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

2022-04-14 Thread Luboš Luňák (via logerrit)
 vcl/inc/TextLayoutCache.hxx |2 ++
 vcl/inc/sallayout.hxx   |1 -
 vcl/source/gdi/CommonSalLayout.cxx  |   20 
 vcl/source/gdi/impglyphitem.cxx |2 +-
 vcl/source/outdev/text.cxx  |3 ++-
 vcl/source/text/TextLayoutCache.cxx |   25 -
 6 files changed, 29 insertions(+), 24 deletions(-)

New commits:
commit 4557ea11aeda19b705b4d701bdd1b85db7f0b206
Author: Luboš Luňák 
AuthorDate: Thu Apr 14 16:11:06 2022 +0200
Commit: Luboš Luňák 
CommitDate: Thu Apr 14 21:48:56 2022 +0200

move vcl::text::TextLayoutCache caching to the class itself

I have no idea why I did that in GenericSalLayout.

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

diff --git a/vcl/inc/TextLayoutCache.hxx b/vcl/inc/TextLayoutCache.hxx
index ecb85ea7043d..46e5c80dc320 100644
--- a/vcl/inc/TextLayoutCache.hxx
+++ b/vcl/inc/TextLayoutCache.hxx
@@ -49,6 +49,8 @@ class VCL_DLLPUBLIC TextLayoutCache
 public:
 std::vector runs;
 TextLayoutCache(sal_Unicode const* pStr, sal_Int32 const nEnd);
+// Creates a cached instance.
+static std::shared_ptr Create(OUString 
const&);
 };
 
 struct FirstCharsStringHash
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index 894be0a3098b..75f7cb3c6ea0 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -113,7 +113,6 @@ public:
 voidAdjustLayout(vcl::text::ImplLayoutArgs&) final override;
 boolLayoutText(vcl::text::ImplLayoutArgs&, const 
SalLayoutGlyphsImpl*) final override;
 voidDrawText(SalGraphics&) const final override;
-static std::shared_ptr 
CreateTextLayoutCache(OUString const&);
 SalLayoutGlyphs GetGlyphs() const final override;
 
 boolIsKashidaPosValid(int nCharPos) const final override;
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 628938c5b123..0007e3f355d1 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -21,11 +21,8 @@
 
 #include 
 #include 
-#include 
-#include 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -156,23 +153,6 @@ namespace {
 
 } // namespace
 
-std::shared_ptr 
GenericSalLayout::CreateTextLayoutCache(OUString const& rString)
-{
-typedef o3tl::lru_map,
-vcl::text::FirstCharsStringHash, vcl::text::FastStringCompareEqual> 
Cache;
-static vcl::DeleteOnDeinit< Cache > cache( 1000 );
-if( Cache* map = cache.get())
-{
-auto it = map->find(rString);
-if( it != map->end())
-return it->second;
-auto ret = std::make_shared(rString.getStr(), rString.getLength());
-map->insert( { rString, ret } );
-return ret;
-}
-return std::make_shared(rString.getStr(), rString.getLength());
-}
-
 SalLayoutGlyphs GenericSalLayout::GetGlyphs() const
 {
 SalLayoutGlyphs glyphs;
diff --git a/vcl/source/gdi/impglyphitem.cxx b/vcl/source/gdi/impglyphitem.cxx
index d581715dc9cd..0268eb3861c0 100644
--- a/vcl/source/gdi/impglyphitem.cxx
+++ b/vcl/source/gdi/impglyphitem.cxx
@@ -256,7 +256,7 @@ SalLayoutGlyphsCache::GetLayoutGlyphs(VclPtr outputDevice, c
 std::shared_ptr tmpLayoutCache;
 if (layoutCache == nullptr)
 {
-tmpLayoutCache = OutputDevice::CreateTextLayoutCache(text);
+tmpLayoutCache = vcl::text::TextLayoutCache::Create(text);
 layoutCache = tmpLayoutCache.get();
 }
 std::unique_ptr layout = outputDevice->ImplLayout(
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 522fd348c7ee..840341502beb 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define TEXT_DRAW_ELLIPSIS  (DrawTextFlags::EndEllipsis | 
DrawTextFlags::PathEllipsis | DrawTextFlags::NewsEllipsis)
@@ -1459,7 +1460,7 @@ std::unique_ptr OutputDevice::ImplLayout(const 
OUString& rOrigStr,
 std::shared_ptr 
OutputDevice::CreateTextLayoutCache(
 OUString const& rString)
 {
-return GenericSalLayout::CreateTextLayoutCache(rString);
+return vcl::text::TextLayoutCache::Create(rString);
 }
 
 bool OutputDevice::GetTextIsRTL( const OUString& rString, sal_Int32 nIndex, 
sal_Int32 nLen ) const
diff --git a/vcl/source/text/TextLayoutCache.cxx 
b/vcl/source/text/TextLayoutCache.cxx
index 00e9f9405358..e1e4321a98d3 100644
--- a/vcl/source/text/TextLayoutCache.cxx
+++ b/vcl/source/text/TextLayoutCache.cxx
@@ -17,9 +17,14 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include 
 #include 
 
+#include 
+
+#include 
+#include 
+#include 
+
 namespace vcl::text
 {
 TextLayoutCache::TextLayoutCache(sal_Unicode const* pStr, sal_Int32 const nEnd)
@@ -31,6 +36,24 @@ TextLayoutCache::TextLayoutCache(sal_Unicode const* pStr, 

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

2022-04-08 Thread Mark Hung (via logerrit)
 vcl/inc/fontinstance.hxx   |8 
 vcl/source/font/fontinstance.cxx   |   37 +
 vcl/source/gdi/CommonSalLayout.cxx |   13 +
 3 files changed, 58 insertions(+)

New commits:
commit 257bb11cbc5b1eb1f90014f528b9e7d6ccfeae86
Author: Mark Hung 
AuthorDate: Sun Apr 3 14:53:14 2022 +0800
Commit: Mark Hung 
CommitDate: Fri Apr 8 15:25:37 2022 +0200

tdf#148330 fix vertical offset for DFKai-SB (ukai.ttf).

DFKai-SB (ukai.ttf) is a built-in font under tradtional Chinese
Windows. The font is very common, especially for official documents.
It is one of the so-called tricky fonts in FreeType[1].

DFKai-SB has incorrect extent in the glyf table[2]. It results in
incorrect glyph positions in vertical writing.

FreeType recalculates the extents based on the
glyph outline, but LibreOffice uses Harfbuzz with
built-in ot font functions instead of ft (FreeType).

This patch decides if the fix is necessary by
checking the family name of the font and the y-offset
value, and recaculates the glyph offset based on glyph
height and top bearing obtained from the glyph bound rect.


[1]https://freetype.org/freetype2/docs/reference/ft2-base_interface.html#ft_face_flag_tricky
[2]https://github.com/harfbuzz/harfbuzz/issues/3521

Change-Id: If632dd38c462c229837e1efb5446e2142f8f0639
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132511
Tested-by: Jenkins
Reviewed-by: Mark Hung 

diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 5822bd1a08b5..5b5ab206c26a 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -86,6 +86,9 @@ public: // TODO: make data members private
 
 inline hb_font_t* GetHbFont();
 bool IsGraphiteFont();
+// NeedOffsetCorrection: Return if the font need offset correction in TTB 
direction.
+// nYOffset is the original offset. It is used to check if the correction 
is necessary.
+bool NeedOffsetCorrection(sal_Int32 nYOffset);
 void SetAverageWidthFactor(double nFactor) { m_nAveWidthFactor = 
std::abs(nFactor); }
 double GetAverageWidthFactor() const { return m_nAveWidthFactor; }
 const vcl::font::FontSelectPattern& GetFontSelectPattern() const { return 
m_aFontSelData; }
@@ -129,6 +132,11 @@ private:
 double m_nAveWidthFactor;
 rtl::Reference m_pFontFace;
 std::optional m_xbIsGraphiteFont;
+
+enum class FontFamilyEnum { Unclassified, DFKaiSB };
+
+// The value is initialized and used in NeedOffsetCorrection().
+std::optional m_xeFontFamilyEnum;
 };
 
 inline hb_font_t* LogicalFontInstance::GetHbFont()
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 5dbd1748a3c3..6f5bc7d1f37a 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -152,4 +152,41 @@ bool LogicalFontInstance::IsGraphiteFont()
 return *m_xbIsGraphiteFont;
 }
 
+bool LogicalFontInstance::NeedOffsetCorrection(sal_Int32 nYOffset)
+{
+if (!m_xeFontFamilyEnum)
+{
+char familyname[10];
+unsigned int familyname_size = 10;
+
+m_xeFontFamilyEnum = FontFamilyEnum::Unclassified;
+
+if (hb_ot_name_get_utf8 (hb_font_get_face(GetHbFont()),
+HB_OT_NAME_ID_FONT_FAMILY , HB_LANGUAGE_INVALID, 
_size, familyname) == 8)
+{
+// DFKai-SB (ukai.ttf) is a built-in font under tradtional Chinese
+// Windows. It has wrong extent values in glyf table. The problem 
results
+// in wrong positioning of glyphs in vertical writing.
+// Check https://github.com/harfbuzz/harfbuzz/issues/3521 for 
reference.
+if (!strncmp("DFKai-SB", familyname, 8))
+m_xeFontFamilyEnum = FontFamilyEnum::DFKaiSB;
+}
+}
+
+bool bRet = true;
+
+switch (*m_xeFontFamilyEnum)
+{
+case FontFamilyEnum::DFKaiSB:
+// -839: optimization for one third of ukai.ttf
+if (nYOffset == -839)
+bRet = false;
+break;
+default:
+bRet = false;
+}
+
+return bRet;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index be6480bfde1a..8dee28727997 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -621,6 +621,19 @@ bool 
GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
 nAdvance = -pHbPositions[i].y_advance;
 nXOffset = -pHbPositions[i].y_offset;
 nYOffset = -pHbPositions[i].x_offset - nBaseOffset;
+
+if 
(GetFont().NeedOffsetCorrection(pHbPositions[i].y_offset))
+{
+// We need glyph's advance, top bearing, and height to
+// correct y offset.
+

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

2022-03-08 Thread Noel Grandin (via logerrit)
 vcl/inc/fontinstance.hxx |   19 ++-
 vcl/source/font/fontinstance.cxx |   38 +++---
 2 files changed, 25 insertions(+), 32 deletions(-)

New commits:
commit d73551e4023f2c9de5adaaba3d2dc0e940de41e4
Author: Noel Grandin 
AuthorDate: Tue Mar 8 10:29:13 2022 +0200
Commit: Noel Grandin 
CommitDate: Tue Mar 8 15:40:41 2022 +0100

no need to allocate fallback list separately

an empty map is just a couple of words of storage anyway

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

diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index d23c6a58548d..5822bd1a08b5 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -22,6 +22,7 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -41,6 +42,22 @@
 class ConvertChar;
 class ImplFontCache;
 
+// extend std namespace to add custom hash needed for LogicalFontInstance
+
+namespace std
+{
+template <> struct hash< pair< sal_UCS4, FontWeight > >
+{
+size_t operator()(const pair< sal_UCS4, FontWeight >& rData) const
+{
+std::size_t seed = 0;
+o3tl::hash_combine(seed, rData.first);
+o3tl::hash_combine(seed, rData.second);
+return seed;
+}
+};
+}
+
 // TODO: allow sharing of metrics for related fonts
 
 class VCL_PLUGIN_PUBLIC LogicalFontInstance : public 
salhelper::SimpleReferenceObject
@@ -105,7 +122,7 @@ private:
 // TODO: a fallback map can be shared with many other ImplFontEntries
 // TODO: at least the ones which just differ in orientation, stretching or 
height
 typedef ::std::unordered_map< ::std::pair, MapEntry > 
UnicodeFallbackList;
-std::unique_ptr mpUnicodeFallbackList;
+UnicodeFallbackList maUnicodeFallbackList;
 mutable ImplFontCache * mpFontCache;
 const vcl::font::FontSelectPattern m_aFontSelData;
 hb_font_t* m_pHbFont;
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 54464b101d72..5dbd1748a3c3 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -26,25 +26,6 @@
 #include 
 #include 
 
-#include 
-
-// extend std namespace to add custom hash needed for LogicalFontInstance
-
-namespace std
-{
-template <> struct hash< pair< sal_UCS4, FontWeight > >
-{
-size_t operator()(const pair< sal_UCS4, FontWeight >& rData) const
-{
-std::size_t seed = 0;
-o3tl::hash_combine(seed, rData.first);
-o3tl::hash_combine(seed, rData.second);
-return seed;
-}
-};
-}
-
-
 LogicalFontInstance::LogicalFontInstance(const vcl::font::PhysicalFontFace& 
rFontFace, const vcl::font::FontSelectPattern& rFontSelData )
 : mxFontMetric( new ImplFontMetricData( rFontSelData ))
 , mpConversion( nullptr )
@@ -62,7 +43,7 @@ LogicalFontInstance::LogicalFontInstance(const 
vcl::font::PhysicalFontFace& rFon
 
 LogicalFontInstance::~LogicalFontInstance()
 {
-mpUnicodeFallbackList.reset();
+maUnicodeFallbackList.clear();
 mpFontCache = nullptr;
 mxFontMetric = nullptr;
 
@@ -121,9 +102,7 @@ void LogicalFontInstance::GetScale(double* nXScale, double* 
nYScale)
 void LogicalFontInstance::AddFallbackForUnicode(sal_UCS4 cChar, FontWeight 
eWeight, const OUString& rFontName,
 bool bEmbolden, const 
ItalicMatrix& rMatrix)
 {
-if( !mpUnicodeFallbackList )
-mpUnicodeFallbackList.reset(new UnicodeFallbackList);
-MapEntry& rEntry = (*mpUnicodeFallbackList)[ std::pair< sal_UCS4, 
FontWeight >(cChar,eWeight) ];
+MapEntry& rEntry = maUnicodeFallbackList[ std::pair< sal_UCS4, FontWeight 
>(cChar,eWeight) ];
 rEntry.sFontName = rFontName;
 rEntry.bEmbolden = bEmbolden;
 rEntry.aItalicMatrix = rMatrix;
@@ -132,11 +111,8 @@ void LogicalFontInstance::AddFallbackForUnicode(sal_UCS4 
cChar, FontWeight eWeig
 bool LogicalFontInstance::GetFallbackForUnicode(sal_UCS4 cChar, FontWeight 
eWeight,
 OUString* pFontName, bool* 
pEmbolden, ItalicMatrix* pMatrix) const
 {
-if( !mpUnicodeFallbackList )
-return false;
-
-UnicodeFallbackList::const_iterator it = mpUnicodeFallbackList->find( 
std::pair< sal_UCS4, FontWeight >(cChar,eWeight) );
-if( it == mpUnicodeFallbackList->end() )
+UnicodeFallbackList::const_iterator it = maUnicodeFallbackList.find( 
std::pair< sal_UCS4, FontWeight >(cChar,eWeight) );
+if( it == maUnicodeFallbackList.end() )
 return false;
 
 const MapEntry& rEntry = (*it).second;
@@ -148,12 +124,12 @@ bool LogicalFontInstance::GetFallbackForUnicode(sal_UCS4 
cChar, FontWeight eWeig
 
 void LogicalFontInstance::IgnoreFallbackForUnicode( sal_UCS4 cChar, FontWeight 
eWeight, std::u16string_view 

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

2022-03-02 Thread Caolán McNamara (via logerrit)
 vcl/inc/fontinstance.hxx   |   16 +--
 vcl/source/font/PhysicalFontCollection.cxx |   64 +
 vcl/source/font/fontinstance.cxx   |   19 ++--
 3 files changed, 64 insertions(+), 35 deletions(-)

New commits:
commit 04f9a8957c04b8c5abaa58140328d2c83381f4ff
Author: Caolán McNamara 
AuthorDate: Wed Mar 2 15:05:18 2022 +
Commit: Caolán McNamara 
CommitDate: Wed Mar 2 22:15:59 2022 +0100

tdf#147283 allow 'fake italic/bold' glyph fallback results to be cached

see also tdf#32665

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

diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 7fe31dbea828..d23c6a58548d 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -61,8 +61,10 @@ public: // TODO: make data members private
 Degree10mnOrientation;  // text angle in 3600 system
 boolmbInit; // true if maFontMetric member is 
valid
 
-voidAddFallbackForUnicode( sal_UCS4, FontWeight eWeight, const 
OUString& rFontName );
-boolGetFallbackForUnicode( sal_UCS4, FontWeight eWeight, 
OUString* pFontName ) const;
+voidAddFallbackForUnicode(sal_UCS4 cChar, FontWeight eWeight, 
const OUString& rFontName,
+  bool bEmbolden, const ItalicMatrix& 
rMatrix);
+boolGetFallbackForUnicode(sal_UCS4 cInChar, FontWeight 
eInWeight,
+  OUString* pOutFontName, bool* 
pOutEmbolden, ItalicMatrix* pOutItalicMatrix) const;
 voidIgnoreFallbackForUnicode( sal_UCS4, FontWeight eWeight, 
std::u16string_view rFontName );
 
 inline hb_font_t* GetHbFont();
@@ -93,10 +95,16 @@ protected:
 virtual hb_font_t* ImplInitHbFont() { assert(false); return 
hb_font_get_empty(); }
 
 private:
-// cache of Unicode characters and replacement font names
+struct MapEntry
+{
+OUString sFontName;
+bool bEmbolden;
+ItalicMatrix aItalicMatrix;
+};
+// cache of Unicode characters and replacement font names and attributes
 // TODO: a fallback map can be shared with many other ImplFontEntries
 // TODO: at least the ones which just differ in orientation, stretching or 
height
-typedef ::std::unordered_map< ::std::pair, OUString > 
UnicodeFallbackList;
+typedef ::std::unordered_map< ::std::pair, MapEntry > 
UnicodeFallbackList;
 std::unique_ptr mpUnicodeFallbackList;
 mutable ImplFontCache * mpFontCache;
 const vcl::font::FontSelectPattern m_aFontSelData;
diff --git a/vcl/source/font/PhysicalFontCollection.cxx 
b/vcl/source/font/PhysicalFontCollection.cxx
index 211e4e65bd57..139e4f133e88 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -196,7 +196,10 @@ PhysicalFontFamily* 
PhysicalFontCollection::GetGlyphFallbackFont(FontSelectPatte
 while( nStrIndex < rMissingCodes.getLength() )
 {
 cChar = rMissingCodes.iterateCodePoints(  );
-bCached = pFontInstance->GetFallbackForUnicode( cChar, 
rFontSelData.GetWeight(),  );
+bCached = pFontInstance->GetFallbackForUnicode(cChar, 
rFontSelData.GetWeight(),
+   
,
+   
,
+   
);
 
 // ignore entries which don't have a fallback
 if( !bCached || !rFontSelData.maSearchName.isEmpty() )
@@ -210,13 +213,20 @@ PhysicalFontFamily* 
PhysicalFontCollection::GetGlyphFallbackFont(FontSelectPatte
 int nRemainingLength = 0;
 std::unique_ptr const pRemainingCodes(new 
sal_UCS4[rMissingCodes.getLength()]);
 OUString aFontName;
+bool bEmbolden;
+ItalicMatrix aMatrix;
 
 while( nStrIndex < rMissingCodes.getLength() )
 {
 cChar = rMissingCodes.iterateCodePoints(  );
-bCached = pFontInstance->GetFallbackForUnicode( cChar, 
rFontSelData.GetWeight(),  );
-if( !bCached || (rFontSelData.maSearchName != aFontName) )
+bCached = pFontInstance->GetFallbackForUnicode(cChar, 
rFontSelData.GetWeight(),
+   , 
, );
+if (!bCached || rFontSelData.maSearchName != aFontName ||
+rFontSelData.mbEmbolden != bEmbolden ||
+rFontSelData.maItalicMatrix != aMatrix)
+{
 pRemainingCodes[ nRemainingLength++ ] = cChar;
+}
 }
 rMissingCodes = OUString( pRemainingCodes.get(), nRemainingLength 
);

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

2022-02-25 Thread Caolán McNamara (via logerrit)
 vcl/inc/fontsubset.hxx|2 ++
 vcl/source/font/font.cxx  |1 +
 vcl/source/fontsubset/sft.cxx |   31 +++
 vcl/workben/fftester.cxx  |3 ++-
 vcl/workben/sftfuzzer.cxx |5 ++---
 5 files changed, 38 insertions(+), 4 deletions(-)

New commits:
commit 237a5e5121a6f12981eb6e4c5a138fc8cfa1c3cf
Author: Caolán McNamara 
AuthorDate: Fri Feb 25 15:46:16 2022 +
Commit: Caolán McNamara 
CommitDate: Fri Feb 25 20:56:05 2022 +0100

do more work in sftfuzzer

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

diff --git a/vcl/inc/fontsubset.hxx b/vcl/inc/fontsubset.hxx
index 1a4c7b80b118..2db54387034e 100644
--- a/vcl/inc/fontsubset.hxx
+++ b/vcl/inc/fontsubset.hxx
@@ -89,6 +89,8 @@ private:
 static bool CreateFontSubsetFromType1( const sal_Int32* pOutGlyphWidths );
 };
 
+int VCL_DLLPUBLIC TestFontSubset(const void* data, sal_uInt32 size);
+
 #endif // INCLUDED_VCL_INC_FONTSUBSET_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx
index 789273aaf40b..16678dd61ac7 100644
--- a/vcl/source/font/font.cxx
+++ b/vcl/source/font/font.cxx
@@ -30,6 +30,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index bfd8c1d5e8e8..999cf07de1d2 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace vcl
@@ -2279,4 +2280,34 @@ bool getTTCoverage(
 
 } // namespace vcl
 
+int TestFontSubset(const void* data, sal_uInt32 size)
+{
+int nResult = -1;
+vcl::TrueTypeFont* pTTF = nullptr;
+if (OpenTTFontBuffer(data, size, 0, ) == vcl::SFErrCodes::Ok)
+{
+vcl::TTGlobalFontInfo aInfo;
+GetTTGlobalFontInfo(pTTF, );
+
+sal_uInt16 aGlyphIds[ 256 ] = {};
+sal_uInt8 aEncoding[ 256 ] = {};
+
+for (sal_uInt16 c = 32; c < 256; ++c)
+{
+aEncoding[c] = c;
+aGlyphIds[c] = c - 31;
+}
+
+CreateTTFromTTGlyphs(pTTF, nullptr, aGlyphIds, aEncoding, 256);
+
+
+// cleanup
+CloseTTFont( pTTF );
+// success
+nResult = 0;
+}
+
+return nResult;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx
index d69c07708841..3c6645dbb89f 100644
--- a/vcl/workben/fftester.cxx
+++ b/vcl/workben/fftester.cxx
@@ -69,6 +69,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "../source/filter/igif/gifread.hxx"
 #include "../source/filter/ixbm/xbmread.hxx"
@@ -525,7 +526,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
 SvFileStream aFileStream(out, StreamMode::READ);
 std::vector aData(aFileStream.remainingSize());
 aFileStream.ReadBytes(aData.data(), aData.size());
-(void)vcl::Font::identifyFont(aData.data(), aData.size());
+ret = TestFontSubset(aData.data(), aData.size());
 }
 
 #endif
diff --git a/vcl/workben/sftfuzzer.cxx b/vcl/workben/sftfuzzer.cxx
index fc951ddc1468..f0a4a9a8cadf 100644
--- a/vcl/workben/sftfuzzer.cxx
+++ b/vcl/workben/sftfuzzer.cxx
@@ -7,7 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include 
+#include 
 #include "commonfuzzer.hxx"
 
 #include 
@@ -37,8 +37,7 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
 
 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
 {
-(void)vcl::Font::identifyFont(data, size);
-return 0;
+return TestFontSubset(data, size);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2022-02-10 Thread Henry Castro (via logerrit)
 vcl/inc/dndlistenercontainer.hxx   |   25 
 vcl/source/window/dndlistenercontainer.cxx |   36 +
 2 files changed, 61 insertions(+)

New commits:
commit 03bcc8ad7a3347a817f087b4e444d7bed95ca973
Author: Henry Castro 
AuthorDate: Fri Jun 25 09:18:37 2021 -0400
Commit: Henry Castro 
CommitDate: Thu Feb 10 15:55:41 2022 +0100

lok: add generic class DragContext, DropContext

In tiled rendering case, there is no exists a generic
dummy to fire drag over and drag drop events.

Change-Id: I1d334df8316a09950c11bc365f12f28f0352dfc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118860
Tested-by: Szymon Kłos 
Reviewed-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117893
Tested-by: Jenkins
Reviewed-by: Henry Castro 

diff --git a/vcl/inc/dndlistenercontainer.hxx b/vcl/inc/dndlistenercontainer.hxx
index 1e23dfa6c9bc..870cc05dfacb 100644
--- a/vcl/inc/dndlistenercontainer.hxx
+++ b/vcl/inc/dndlistenercontainer.hxx
@@ -28,6 +28,31 @@
 #include 
 #include 
 
+#include 
+
+class GenericDropTargetDropContext :
+public 
::cppu::WeakImplHelper
+{
+public:
+GenericDropTargetDropContext();
+
+// XDropTargetDropContext
+virtual void SAL_CALL acceptDrop( sal_Int8 dragOperation ) override;
+virtual void SAL_CALL rejectDrop() override;
+virtual void SAL_CALL dropComplete( sal_Bool success ) override;
+};
+
+class GenericDropTargetDragContext :
+public 
::cppu::WeakImplHelper
+{
+public:
+GenericDropTargetDragContext();
+
+// XDropTargetDragContext
+virtual void SAL_CALL acceptDrag( sal_Int8 dragOperation ) override;
+virtual void SAL_CALL rejectDrag() override;
+};
+
 class DNDListenerContainer final : public cppu::BaseMutex,
 public ::cppu::WeakComponentImplHelper<
 css::datatransfer::dnd::XDragGestureRecognizer,
diff --git a/vcl/source/window/dndlistenercontainer.cxx 
b/vcl/source/window/dndlistenercontainer.cxx
index 7e38dae842f2..d3147aac5288 100644
--- a/vcl/source/window/dndlistenercontainer.cxx
+++ b/vcl/source/window/dndlistenercontainer.cxx
@@ -448,4 +448,40 @@ void SAL_CALL DNDListenerContainer::dropComplete( sal_Bool 
success )
 }
 }
 
+/*
+ *  GenericDropTargetDropContext
+ */
+
+GenericDropTargetDropContext::GenericDropTargetDropContext()
+{
+}
+
+void GenericDropTargetDropContext::acceptDrop( sal_Int8 /*dragOperation*/ )
+{
+}
+
+void GenericDropTargetDropContext::rejectDrop()
+{
+}
+
+void GenericDropTargetDropContext::dropComplete( sal_Bool /*success*/ )
+{
+}
+
+/*
+ *  GenericDropTargetDragContext
+ */
+
+GenericDropTargetDragContext::GenericDropTargetDragContext()
+{
+}
+
+void GenericDropTargetDragContext::acceptDrag( sal_Int8 /*dragOperation*/ )
+{
+}
+
+void GenericDropTargetDragContext::rejectDrag()
+{
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


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

2022-02-07 Thread Henry Castro (via logerrit)
 vcl/inc/window.h  |5 +
 vcl/source/window/winproc.cxx |  122 ++
 2 files changed, 127 insertions(+)

New commits:
commit 845e53ea13b317bd8ef4dc42cd60ea51359f34ab
Author: Henry Castro 
AuthorDate: Wed Jun 23 07:44:26 2021 -0400
Commit: Henry Castro 
CommitDate: Tue Feb 8 00:14:35 2022 +0100

lok: sc: introduce ImplLOKHandleMouseEvent

In tiled rendering case, each user has a View/Controller
object to interact with a unique document (Model) for
collaborating purposes. However, in the desktop case a
unique user has many View/Controller objects to handle a
unique document, so the user has only one global active focus,
capture and tracking window object.

In order to handle independent drag & drop for each user,
it is created ImplLOKHandleMouseEvent.

Change-Id: I735fae9b9858a75f9fedb603798220ab302d65f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118843
Reviewed-by: Szymon Kłos 
Tested-by: Szymon Kłos 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117708
Tested-by: Jenkins
Reviewed-by: Henry Castro 

diff --git a/vcl/inc/window.h b/vcl/inc/window.h
index bc4b1ee1fe49..050c0558eb7c 100644
--- a/vcl/inc/window.h
+++ b/vcl/inc/window.h
@@ -419,6 +419,11 @@ typedef std::unique_ptr
 bool ImplHandleMouseEvent( const VclPtr& xWindow, 
MouseNotifyEvent nSVEvent, bool bMouseLeave,
tools::Long nX, tools::Long nY, sal_uInt64 nMsgTime,
sal_uInt16 nCode, MouseEventModifiers nMode );
+
+bool ImplLOKHandleMouseEvent( const VclPtr& xWindow, 
MouseNotifyEvent nSVEvent, bool bMouseLeave,
+  tools::Long nX, tools::Long nY, sal_uInt64 
nMsgTime,
+  sal_uInt16 nCode, MouseEventModifiers nMode, 
sal_uInt16 nClicks);
+
 void ImplHandleResize( vcl::Window* pWindow, tools::Long nNewWidth, 
tools::Long nNewHeight );
 
 VCL_DLLPUBLIC void ImplWindowStateFromStr(WindowStateData& rData, const 
OString& rStr);
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index 059e89980fbf..35a5ce2754d2 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -804,6 +804,128 @@ bool ImplHandleMouseEvent( const VclPtr& 
xWindow, MouseNotifyEvent
 return bRet;
 }
 
+bool ImplLOKHandleMouseEvent(const VclPtr& xWindow, 
MouseNotifyEvent nEvent, bool /*bMouseLeave*/,
+ tools::Long nX, tools::Long nY, sal_uInt64 
/*nMsgTime*/,
+ sal_uInt16 nCode, MouseEventModifiers nMode, 
sal_uInt16 nClicks)
+{
+Point aMousePos(nX, nY);
+
+if (!xWindow)
+return false;
+
+if (xWindow->isDisposed())
+return false;
+
+ImplFrameData* pFrameData = xWindow->ImplGetFrameData();
+if (!pFrameData)
+return false;
+
+Point aWinPos = xWindow->ImplFrameToOutput(aMousePos);
+
+pFrameData->mnLastMouseX = nX;
+pFrameData->mnLastMouseY = nY;
+pFrameData->mnClickCount = nClicks;
+pFrameData->mnMouseCode = nCode;
+pFrameData->mbMouseIn = false;
+
+vcl::Window* pDownWin = pFrameData->mpMouseDownWin;
+if (pDownWin && nEvent == MouseNotifyEvent::MOUSEMOVE)
+{
+const MouseSettings& aSettings = 
pDownWin->GetSettings().GetMouseSettings();
+if ((nCode & (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE)) ==
+(MouseSettings::GetStartDragCode() & (MOUSE_LEFT | MOUSE_RIGHT | 
MOUSE_MIDDLE)) )
+{
+if (!pFrameData->mbStartDragCalled)
+{
+tools::Long nDragWidth = aSettings.GetStartDragWidth();
+tools::Long nDragHeight = aSettings.GetStartDragHeight();
+tools::Long nMouseX = aMousePos.X();
+tools::Long nMouseY = aMousePos.Y();
+
+if nMouseX - nDragWidth) > pFrameData->mnFirstMouseX) ||
+ ((nMouseX + nDragWidth) < pFrameData->mnFirstMouseX)) ||
+(((nMouseY - nDragHeight) > pFrameData->mnFirstMouseY) ||
+ ((nMouseY + nDragHeight) < pFrameData->mnFirstMouseY)))
+{
+pFrameData->mbStartDragCalled  = true;
+
+if (pFrameData->mbInternalDragGestureRecognizer)
+{
+// query DropTarget from child window
+css::uno::Reference< 
css::datatransfer::dnd::XDragGestureRecognizer > xDragGestureRecognizer(
+
pDownWin->ImplGetWindowImpl()->mxDNDListenerContainer,
+css::uno::UNO_QUERY );
+
+if (xDragGestureRecognizer.is())
+{
+// create a UNO mouse event out of the available 
data
+css::awt::MouseEvent aEvent(
+static_cast < css::uno::XInterface * > ( 
nullptr ),
+ #ifdef 

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

2022-01-17 Thread Stephan Bergmann (via logerrit)
 vcl/inc/bitmap/Octree.hxx|5 ++---
 vcl/source/bitmap/Octree.cxx |   40 
 2 files changed, 18 insertions(+), 27 deletions(-)

New commits:
commit 5db574727f4564238a54159a1a0673eaa2884b69
Author: Stephan Bergmann 
AuthorDate: Mon Jan 17 21:47:48 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Mon Jan 17 22:38:13 2022 +0100

Avoid -Werror=dangling-pointer=

> vcl/source/bitmap/Octree.cxx: In constructor ‘Octree::Octree(const 
BitmapReadAccess&, sal_uLong)’:
> vcl/source/bitmap/Octree.cxx:69:17: error: storing the address of local 
variable ‘aColor’ in ‘*this.Octree::mpColor’ [-Werror=dangling-pointer=]
>69 | mpColor = 
>   | ^
> vcl/source/bitmap/Octree.cxx:67:21: note: ‘aColor’ declared here
>67 | BitmapColor aColor;
>   | ^~
> vcl/source/bitmap/Octree.cxx:67:21: note: ‘’ declared here

(new with GCC 12)

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

diff --git a/vcl/inc/bitmap/Octree.hxx b/vcl/inc/bitmap/Octree.hxx
index 216f2fdd1875..4db06502256d 100644
--- a/vcl/inc/bitmap/Octree.hxx
+++ b/vcl/inc/bitmap/Octree.hxx
@@ -42,9 +42,9 @@ class VCL_PLUGIN_PUBLIC Octree
 {
 private:
 void CreatePalette(OctreeNode* pNode);
-void GetPalIndex(const OctreeNode* pNode);
+void GetPalIndex(const OctreeNode* pNode, BitmapColor const& color);
 
-SAL_DLLPRIVATE void add(std::unique_ptr& rpNode);
+SAL_DLLPRIVATE void add(std::unique_ptr& rpNode, BitmapColor 
const& color);
 SAL_DLLPRIVATE void reduce();
 
 BitmapPalette maPalette;
@@ -52,7 +52,6 @@ private:
 sal_uLong mnLevel;
 std::unique_ptr pTree;
 std::vector mpReduce;
-BitmapColor const* mpColor;
 sal_uInt16 mnPalIndex;
 
 public:
diff --git a/vcl/source/bitmap/Octree.cxx b/vcl/source/bitmap/Octree.cxx
index fab0c8374ca8..98ad8c9fcf5d 100644
--- a/vcl/source/bitmap/Octree.cxx
+++ b/vcl/source/bitmap/Octree.cxx
@@ -34,7 +34,6 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong 
nColors)
 : mnLeafCount(0)
 , mnLevel(0)
 , mpReduce(OCTREE_BITS + 1, nullptr)
-, mpColor(nullptr)
 , mnPalIndex(0)
 {
 const BitmapReadAccess* pAccess = 
@@ -53,9 +52,8 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong 
nColors)
 Scanline pScanline = pAccess->GetScanline(nY);
 for (tools::Long nX = 0; nX < nWidth; nX++)
 {
-mpColor = 
>GetPaletteColor(pAccess->GetIndexFromData(pScanline, nX));
 mnLevel = 0;
-add(pTree);
+add(pTree, 
pAccess->GetPaletteColor(pAccess->GetIndexFromData(pScanline, nX)));
 
 while (mnLeafCount > nMax)
 reduce();
@@ -64,18 +62,13 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong 
nColors)
 }
 else
 {
-BitmapColor aColor;
-
-mpColor = 
-
 for (tools::Long nY = 0; nY < nHeight; nY++)
 {
 Scanline pScanline = pAccess->GetScanline(nY);
 for (tools::Long nX = 0; nX < nWidth; nX++)
 {
-aColor = pAccess->GetPixelFromData(pScanline, nX);
 mnLevel = 0;
-add(pTree);
+add(pTree, pAccess->GetPixelFromData(pScanline, nX));
 
 while (mnLeafCount > nMax)
 reduce();
@@ -86,7 +79,7 @@ Octree::Octree(const BitmapReadAccess& rReadAcc, sal_uLong 
nColors)
 
 Octree::~Octree() {}
 
-void Octree::add(std::unique_ptr& rpNode)
+void Octree::add(std::unique_ptr& rpNode, BitmapColor const& color)
 {
 // possibly generate new nodes
 if (!rpNode)
@@ -106,20 +99,20 @@ void Octree::add(std::unique_ptr& rpNode)
 if (rpNode->bLeaf)
 {
 rpNode->nCount++;
-rpNode->nRed += mpColor->GetRed();
-rpNode->nGreen += mpColor->GetGreen();
-rpNode->nBlue += mpColor->GetBlue();
+rpNode->nRed += color.GetRed();
+rpNode->nGreen += color.GetGreen();
+rpNode->nBlue += color.GetBlue();
 }
 else
 {
 const sal_uLong nShift = 7 - mnLevel;
 const sal_uInt8 cMask = 0x80 >> mnLevel;
-const sal_uLong nIndex = (((mpColor->GetRed() & cMask) >> nShift) << 2)
- | (((mpColor->GetGreen() & cMask) >> nShift) 
<< 1)
- | ((mpColor->GetBlue() & cMask) >> nShift);
+const sal_uLong nIndex = (((color.GetRed() & cMask) >> nShift) << 2)
+ | (((color.GetGreen() & cMask) >> nShift) << 
1)
+ | ((color.GetBlue() & cMask) >> nShift);
 
 mnLevel++;
-add(rpNode->pChild[nIndex]);
+add(rpNode->pChild[nIndex], color);
 }
 }
 
@@ -184,7 +177,7 @@ 

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

2022-01-17 Thread Caolán McNamara (via logerrit)
 vcl/inc/ImplLayoutArgs.hxx   |2 ++
 vcl/inc/sallayout.hxx|   11 +--
 vcl/source/gdi/sallayout.cxx |   41 ++---
 3 files changed, 37 insertions(+), 17 deletions(-)

New commits:
commit df044d1558d340e51d42264f212c3247c534f6da
Author: Caolán McNamara 
AuthorDate: Sun Jan 16 21:01:48 2022 +
Commit: Caolán McNamara 
CommitDate: Mon Jan 17 10:04:35 2022 +0100

ensure glyph fallback would use the correct dxarray variant

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

diff --git a/vcl/inc/ImplLayoutArgs.hxx b/vcl/inc/ImplLayoutArgs.hxx
index fa5e8005ba00..fa94562ca86c 100644
--- a/vcl/inc/ImplLayoutArgs.hxx
+++ b/vcl/inc/ImplLayoutArgs.hxx
@@ -56,6 +56,8 @@ public:
 bool GetNextPos(int* nCharPos, bool* bRTL);
 bool GetNextRun(int* nMinRunPos, int* nEndRunPos, bool* bRTL);
 void AddFallbackRun(int nMinRunPos, int nEndRunPos, bool bRTL);
+bool HasDXArray() const { return mpDXArray || mpAltNaturalDXArray; }
+
 // methods used by BiDi and glyph fallback
 bool HasFallbackRun() const;
 bool PrepareFallback(const SalLayoutGlyphsImpl* pGlyphsImpl);
diff --git a/vcl/inc/sallayout.hxx b/vcl/inc/sallayout.hxx
index f5ffd0f2e587..847c22ace091 100644
--- a/vcl/inc/sallayout.hxx
+++ b/vcl/inc/sallayout.hxx
@@ -82,7 +82,11 @@ public:
 
 void SetIncomplete(bool bIncomplete);
 
-public:
+template
+voidImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs,
+  vcl::text::ImplLayoutArgs& 
rMultiArgs,
+  const DC* pMultiDXArray);
+
 virtual ~MultiSalLayout() override;
 
 private:
@@ -97,7 +101,10 @@ private:
 
 class VCL_DLLPUBLIC GenericSalLayout : public SalLayout
 {
-friend void MultiSalLayout::AdjustLayout(vcl::text::ImplLayoutArgs&);
+template friend void MultiSalLayout::ImplAdjustMultiLayout(
+vcl::text::ImplLayoutArgs& rArgs,
+vcl::text::ImplLayoutArgs& rMultiArgs,
+const DC* pMultiDXArray);
 
 public:
 GenericSalLayout(LogicalFontInstance&);
diff --git a/vcl/source/gdi/sallayout.cxx b/vcl/source/gdi/sallayout.cxx
index be020c2f11ae..abad66427491 100644
--- a/vcl/source/gdi/sallayout.cxx
+++ b/vcl/source/gdi/sallayout.cxx
@@ -648,7 +648,7 @@ void MultiSalLayout::AdjustLayout( 
vcl::text::ImplLayoutArgs& rArgs )
 vcl::text::ImplLayoutArgs aMultiArgs = rArgs;
 std::vector aJustificationArray;
 
-if( !rArgs.mpDXArray && rArgs.mnLayoutWidth )
+if( !rArgs.HasDXArray() && rArgs.mnLayoutWidth )
 {
 // for stretched text in a MultiSalLayout the target width needs to be
 // distributed by individually adjusting its virtual character widths
@@ -713,6 +713,17 @@ void MultiSalLayout::AdjustLayout( 
vcl::text::ImplLayoutArgs& rArgs )
 }
 }
 
+if (aMultiArgs.mpAltNaturalDXArray)
+ImplAdjustMultiLayout(rArgs, aMultiArgs, 
aMultiArgs.mpAltNaturalDXArray);
+else
+ImplAdjustMultiLayout(rArgs, aMultiArgs, aMultiArgs.mpDXArray);
+}
+
+template
+void MultiSalLayout::ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs,
+   vcl::text::ImplLayoutArgs& 
rMultiArgs,
+   const DC* pMultiDXArray)
+{
 // Compute rtl flags, since in some scripts glyphs/char order can be
 // reversed for a few character sequences e.g. Myanmar
 std::vector vRtl(rArgs.mnEndCharPos - rArgs.mnMinCharPos, false);
@@ -739,10 +750,10 @@ void MultiSalLayout::AdjustLayout( 
vcl::text::ImplLayoutArgs& rArgs )
 // now adjust the individual components
 if( n > 0 )
 {
-aMultiArgs.maRuns = maFallbackRuns[ n-1 ];
-aMultiArgs.mnFlags |= SalLayoutFlags::ForFallback;
+rMultiArgs.maRuns = maFallbackRuns[ n-1 ];
+rMultiArgs.mnFlags |= SalLayoutFlags::ForFallback;
 }
-mpLayouts[n]->AdjustLayout( aMultiArgs );
+mpLayouts[n]->AdjustLayout( rMultiArgs );
 
 // remove unused parts of component
 if( n > 0 )
@@ -841,7 +852,7 @@ void MultiSalLayout::AdjustLayout( 
vcl::text::ImplLayoutArgs& rArgs )
 }
 
 // skip to end of layout run and calculate its advance width
-DeviceCoordinate nRunAdvance = 0;
+DC nRunAdvance = 0;
 bool bKeepNotDef = (nFBLevel >= nLevel);
 for(;;)
 {
@@ -897,7 +908,7 @@ void MultiSalLayout::AdjustLayout( 
vcl::text::ImplLayoutArgs& rArgs )
 bKeepNotDef = bNeedFallback;
 }
 // check for reordered glyphs
-if (aMultiArgs.mpDXArray &&
+if (pMultiDXArray &&
 nRunVisibleEndChar < mnEndCharPos &&
 nRunVisibleEndChar >= mnMinCharPos &&
 

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

2022-01-12 Thread Luboš Luňák (via logerrit)
 vcl/inc/canvasbitmap.hxx   |8 +-
 vcl/source/helper/canvasbitmap.cxx |  120 +++--
 2 files changed, 81 insertions(+), 47 deletions(-)

New commits:
commit d39acd432df374ffdf4142c23d1c74df8821160c
Author: Luboš Luňák 
AuthorDate: Tue Jan 11 19:31:36 2022 +0100
Commit: Luboš Luňák 
CommitDate: Wed Jan 12 12:20:38 2022 +0100

do not force pixel reading in VclCanvasBitmap ctor

BitmapReadAccess is not need by most calls in the class, and
creating it already in ctor forces reading of all pixels,
which is expensive e.g. when fetching them from the GPU.

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

diff --git a/vcl/inc/canvasbitmap.hxx b/vcl/inc/canvasbitmap.hxx
index cb50e82bf8d9..54586a1ad60e 100644
--- a/vcl/inc/canvasbitmap.hxx
+++ b/vcl/inc/canvasbitmap.hxx
@@ -38,8 +38,10 @@ namespace vcl::unotools
 BitmapEx   m_aBmpEx;
 ::Bitmap   m_aBitmap;
 ::Bitmap   m_aAlpha;
-Bitmap::ScopedReadAccess   m_pBmpAcc;
-Bitmap::ScopedReadAccess   m_pAlphaAcc;
+Bitmap::ScopedInfoAccess   m_pBmpAcc;
+Bitmap::ScopedInfoAccess   m_pAlphaAcc;
+std::optionalm_pBmpReadAcc;
+std::optionalm_pAlphaReadAcc;
 css::uno::Sequence   m_aComponentTags;
 css::uno::Sequence  m_aComponentBitCounts;
 css::rendering::IntegerBitmapLayoutm_aLayout;
@@ -53,6 +55,8 @@ namespace vcl::unotools
 bool   m_bPalette;
 
 SAL_DLLPRIVATE void setComponentInfo( sal_uInt32 redShift, sal_uInt32 
greenShift, sal_uInt32 blueShift );
+Bitmap::ScopedReadAccess& getBitmapReadAccess();
+Bitmap::ScopedReadAccess& getAlphaReadAccess();
 
 virtual ~VclCanvasBitmap() override;
 
diff --git a/vcl/source/helper/canvasbitmap.cxx 
b/vcl/source/helper/canvasbitmap.cxx
index 2eaa16223789..301237e18e43 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -94,6 +94,24 @@ void VclCanvasBitmap::setComponentInfo( sal_uInt32 redShift, 
sal_uInt32 greenShi
 pCounts[bluePos]  = bitcount(blueShift);
 }
 
+Bitmap::ScopedReadAccess& VclCanvasBitmap::getBitmapReadAccess()
+{
+// BitmapReadAccess is more expensive than BitmapInfoAccess,
+// as the latter requires also pixels, which may need converted
+// from the system format (and even fetched). Most calls here
+// need only info access, create read access only on demand.
+if(!m_pBmpReadAcc)
+m_pBmpReadAcc.emplace(m_aBitmap);
+return m_pBmpReadAcc.value();
+}
+
+Bitmap::ScopedReadAccess& VclCanvasBitmap::getAlphaReadAccess()
+{
+if(!m_pAlphaReadAcc)
+m_pAlphaReadAcc.emplace(m_aAlpha);
+return m_pAlphaReadAcc.value();
+}
+
 VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) :
 m_aBmpEx( rBitmap ),
 m_aBitmap( rBitmap.GetBitmap() ),
@@ -110,7 +128,7 @@ VclCanvasBitmap::VclCanvasBitmap( const BitmapEx& rBitmap ) 
:
 if( m_aBmpEx.IsAlpha() )
 {
 m_aAlpha = m_aBmpEx.GetAlpha().GetBitmap();
-m_pAlphaAcc = Bitmap::ScopedReadAccess(m_aAlpha);
+m_pAlphaAcc = Bitmap::ScopedInfoAccess(m_aAlpha);
 }
 
 m_aLayout.ScanLines  = 0;
@@ -391,20 +409,23 @@ uno::Sequence< sal_Int8 > SAL_CALL 
VclCanvasBitmap::getData( rendering::IntegerB
 
 if( !m_aBmpEx.IsAlpha() )
 {
-OSL_ENSURE(m_pBmpAcc,"Invalid bmp read access");
+Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess();
+OSL_ENSURE(pBmpAcc,"Invalid bmp read access");
 
 // can return bitmap data as-is
 for( tools::Long y=aRequestedBytes.Top(); yGetScanline(y);
+Scanline pScan = pBmpAcc->GetScanline(y);
 memcpy(pOutBuf, pScan+aRequestedBytes.Left(), 
aRequestedBytes.getWidth());
 pOutBuf += nScanlineStride;
 }
 }
 else
 {
-OSL_ENSURE(m_pBmpAcc,"Invalid bmp read access");
-OSL_ENSURE(m_pAlphaAcc,"Invalid alpha read access");
+Bitmap::ScopedReadAccess& pBmpAcc = getBitmapReadAccess();
+Bitmap::ScopedReadAccess& pAlphaAcc = getAlphaReadAccess();
+OSL_ENSURE(pBmpAcc,"Invalid bmp read access");
+OSL_ENSURE(pAlphaAcc,"Invalid alpha read access");
 
 // interleave alpha with bitmap data - note, bitcount is
 // always integer multiple of 8
@@ -420,23 +441,23 @@ uno::Sequence< sal_Int8 > SAL_CALL 
VclCanvasBitmap::getData( rendering::IntegerB
 // input less than a byte - copy via GetPixel()
 for( tools::Long x=aRequestedArea.Left(); 

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

2021-12-06 Thread Tor Lillqvist (via logerrit)
 vcl/inc/printdlg.hxx   |1 +
 vcl/source/window/printdlg.cxx |   13 +
 2 files changed, 6 insertions(+), 8 deletions(-)

New commits:
commit d2ca15952de167b6236139d53f6757a7c0d22d0a
Author: Tor Lillqvist 
AuthorDate: Sat Dec 4 21:53:45 2021 +0200
Commit: Tor Lillqvist 
CommitDate: Mon Dec 6 12:55:35 2021 +0100

Revert "tdf#145354: Ensure displayed paper name matches displayed paper ..."

It causes tdf#146045.

This reverts commit 65081542d2dabdf17820d62abdc5a22d3734e52d

Change-Id: Id980701b1a823c8bf7cfb57e0b32cf5d672c3bfa
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126373
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index d2ce1670a845..21aab3667d4e 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -65,6 +65,7 @@ namespace vcl
 virtual void Resize() override;
 
 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
+ std::u16string_view i_rPaperName,
  const OUString& i_rNoPageString,
  sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
  bool i_bGreyscale
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 12aa14628887..46cb72752bbf 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -207,6 +207,7 @@ bool PrintDialog::PrintPreviewWindow::Command( const 
CommandEvent& rEvt )
 
 void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& 
i_rNewPreview,
   const Size& i_rOrigSize,
+  std::u16string_view 
i_rPaperName,
   const OUString& 
i_rReplacement,
   sal_Int32 i_nDPIX,
   sal_Int32 i_nDPIY,
@@ -234,18 +235,12 @@ void PrintDialog::PrintPreviewWindow::setPreview( const 
GDIMetaFile& i_rNewPrevi
 OUStringBuffer aBuf;
 aBuf.append( aNumText + " " );
 aBuf.appendAscii( eUnit == MapUnit::MapMM ? "mm" : "in" );
-
-// Look up the paper name from the dimensions
-PaperInfo aPaperInfoFromSize(i_rOrigSize.getWidth(), 
i_rOrigSize.getHeight());
-aPaperInfoFromSize.doSloppyFit( true );
-
-if (aPaperInfoFromSize.getPaper() != PAPER_USER)
+if( !i_rPaperName.empty() )
 {
 aBuf.append( " (" );
-aBuf.append( Printer::GetPaperName(aPaperInfoFromSize.getPaper()) );
+aBuf.append( i_rPaperName );
 aBuf.append( ')' );
 }
-
 maHorzText = aBuf.makeStringAndClear();
 
 aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
@@ -959,6 +954,7 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
 if ( !hasPreview() )
 {
 mxPreview->setPreview( aMtf, aCurPageSize,
+Printer::GetPaperName( mePaper ),
 maNoPreviewStr,
 aPrt->GetDPIX(), aPrt->GetDPIY(),
 aPrt->GetPrinterOptions().IsConvertToGreyscales()
@@ -994,6 +990,7 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
 }
 
 mxPreview->setPreview( aMtf, aCurPageSize,
+Printer::GetPaperName( mePaper ),
 nPages > 0 ? OUString() : maNoPageStr,
 aPrt->GetDPIX(), aPrt->GetDPIY(),
 
aPrt->GetPrinterOptions().IsConvertToGreyscales()


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

2021-11-25 Thread Miklos Vajna (via logerrit)
 vcl/inc/pdf/objectcopier.hxx   |2 +-
 vcl/source/gdi/pdfobjectcopier.cxx |   18 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

New commits:
commit 3134d9c0ff6ff86a797d6b7faa49d71367177d66
Author: Miklos Vajna 
AuthorDate: Wed Nov 24 20:09:06 2021 +0100
Commit: Miklos Vajna 
CommitDate: Thu Nov 25 09:34:42 2021 +0100

vcl: pInputElement is never nullptr in PDFObjectCopier::copyRecursively()

Change it to a reference to make that more obvious.

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

diff --git a/vcl/inc/pdf/objectcopier.hxx b/vcl/inc/pdf/objectcopier.hxx
index 3880d739bb10..f9b05725ce0c 100644
--- a/vcl/inc/pdf/objectcopier.hxx
+++ b/vcl/inc/pdf/objectcopier.hxx
@@ -33,7 +33,7 @@ class PDFObjectCopier
 {
 PDFObjectContainer& m_rContainer;
 
-void copyRecursively(OStringBuffer& rLine, filter::PDFElement* 
pInputElement,
+void copyRecursively(OStringBuffer& rLine, filter::PDFElement& 
rInputElement,
  SvMemoryStream& rDocBuffer,
  std::map& rCopiedResources);
 
diff --git a/vcl/source/gdi/pdfobjectcopier.cxx 
b/vcl/source/gdi/pdfobjectcopier.cxx
index 0ab88fc0e3ec..1cb6c209d699 100644
--- a/vcl/source/gdi/pdfobjectcopier.cxx
+++ b/vcl/source/gdi/pdfobjectcopier.cxx
@@ -26,11 +26,11 @@ PDFObjectCopier::PDFObjectCopier(PDFObjectContainer& 
rContainer)
 {
 }
 
-void PDFObjectCopier::copyRecursively(OStringBuffer& rLine, 
filter::PDFElement* pInputElement,
+void PDFObjectCopier::copyRecursively(OStringBuffer& rLine, 
filter::PDFElement& rInputElement,
   SvMemoryStream& rDocBuffer,
   std::map& 
rCopiedResources)
 {
-if (auto pReference = 
dynamic_cast(pInputElement))
+if (auto pReference = 
dynamic_cast())
 {
 filter::PDFObjectElement* pReferenced = pReference->LookupObject();
 if (pReferenced)
@@ -43,17 +43,17 @@ void PDFObjectCopier::copyRecursively(OStringBuffer& rLine, 
filter::PDFElement*
 rLine.append(" 0 R");
 }
 }
-else if (auto pInputArray = 
dynamic_cast(pInputElement))
+else if (auto pInputArray = 
dynamic_cast())
 {
 rLine.append("[ ");
 for (auto const& pElement : pInputArray->GetElements())
 {
-copyRecursively(rLine, pElement, rDocBuffer, rCopiedResources);
+copyRecursively(rLine, *pElement, rDocBuffer, rCopiedResources);
 rLine.append(" ");
 }
 rLine.append("] ");
 }
-else if (auto pInputDictionary = 
dynamic_cast(pInputElement))
+else if (auto pInputDictionary = 
dynamic_cast())
 {
 rLine.append("<< ");
 for (auto const& pPair : pInputDictionary->GetItems())
@@ -61,14 +61,14 @@ void PDFObjectCopier::copyRecursively(OStringBuffer& rLine, 
filter::PDFElement*
 rLine.append("/");
 rLine.append(pPair.first);
 rLine.append(" ");
-copyRecursively(rLine, pPair.second, rDocBuffer, rCopiedResources);
+copyRecursively(rLine, *pPair.second, rDocBuffer, 
rCopiedResources);
 rLine.append(" ");
 }
 rLine.append(">> ");
 }
 else
 {
-pInputElement->writeString(rLine);
+rInputElement.writeString(rLine);
 }
 }
 
@@ -107,7 +107,7 @@ sal_Int32 
PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
 aLine.append("/");
 aLine.append(rPair.first);
 aLine.append(" ");
-copyRecursively(aLine, rPair.second, rDocBuffer, rCopiedResources);
+copyRecursively(aLine, *rPair.second, rDocBuffer, 
rCopiedResources);
 }
 
 aLine.append(" >>\n");
@@ -134,7 +134,7 @@ sal_Int32 
PDFObjectCopier::copyExternalResource(SvMemoryStream& rDocBuffer,
 bFirst = false;
 else
 aLine.append(" ");
-copyRecursively(aLine, pElement, rDocBuffer, rCopiedResources);
+copyRecursively(aLine, *pElement, rDocBuffer, rCopiedResources);
 }
 aLine.append("]\n");
 }


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

2021-11-23 Thread Caolán McNamara (via logerrit)
 vcl/inc/salvtables.hxx|2 ++
 vcl/source/app/salvtables.cxx |   11 +--
 vcl/unx/gtk3/gtkinst.cxx  |   15 ---
 3 files changed, 23 insertions(+), 5 deletions(-)

New commits:
commit f5137ed5453661d21e85ecb94a08cfccae899ca1
Author: Caolán McNamara 
AuthorDate: Tue Nov 23 08:54:58 2021 +
Commit: Caolán McNamara 
CommitDate: Tue Nov 23 17:35:26 2021 +0100

only call signal_closed from Popdown dtor if it is still open

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

diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index f26950fb42a6..b91ccb26cb7f 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -1898,6 +1898,8 @@ private:
 
 DECL_LINK(PopupModeEndHdl, FloatingWindow*, void);
 
+void ImplPopDown();
+
 public:
 SalInstancePopover(DockingWindow* pPopover, SalInstanceBuilder* pBuilder, 
bool bTakeOwnership);
 
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index e8f51950b04f..78148cd10ea8 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -6696,7 +6696,12 @@ SalInstancePopover::SalInstancePopover(DockingWindow* 
pPopover, SalInstanceBuild
 {
 }
 
-SalInstancePopover::~SalInstancePopover() { signal_closed(); }
+SalInstancePopover::~SalInstancePopover()
+{
+DockingManager* pDockingManager = vcl::Window::GetDockingManager();
+if (pDockingManager->IsInPopupMode(m_xPopover))
+ImplPopDown();
+}
 
 void SalInstancePopover::popup_at_rect(weld::Widget* pParent, const 
tools::Rectangle& rRect,
weld::Placement ePlace)
@@ -6726,13 +6731,15 @@ void SalInstancePopover::popup_at_rect(weld::Widget* 
pParent, const tools::Recta
 pDockingManager->StartPopupMode(m_xPopover, aRect, nFlags);
 }
 
-void SalInstancePopover::popdown()
+void SalInstancePopover::ImplPopDown()
 {
 vcl::Window::GetDockingManager()->EndPopupMode(m_xPopover);
 m_xPopover->EnableDocking(false);
 signal_closed();
 }
 
+void SalInstancePopover::popdown() { ImplPopDown(); }
+
 IMPL_LINK_NOARG(SalInstancePopover, PopupModeEndHdl, FloatingWindow*, void) { 
signal_closed(); }
 
 SalInstanceBuilder::SalInstanceBuilder(vcl::Window* pParent, const OUString& 
rUIRoot,
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index b3dab5b14ef5..0fc8ffd9366c 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -22195,17 +22195,26 @@ public:
 gtk_popover_popdown(m_pPopover);
 }
 
+void PopdownAndFlushClosedSignal()
+{
+if (get_visible())
+popdown();
+if (m_pClosedEvent)
+{
+Application::RemoveUserEvent(m_pClosedEvent);
+async_signal_closed(nullptr);
+}
+}
+
 virtual ~GtkInstancePopover() override
 {
+PopdownAndFlushClosedSignal();
 DisconnectMouseEvents();
 #if !GTK_CHECK_VERSION(4, 0, 0)
 if (m_pMenuHack)
 gtk_widget_destroy(GTK_WIDGET(m_pMenuHack));
 #endif
-if (m_pClosedEvent)
-Application::RemoveUserEvent(m_pClosedEvent);
 g_signal_handler_disconnect(m_pPopover, m_nSignalId);
-signal_closed();
 }
 };
 


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

2021-11-03 Thread Tor Lillqvist (via logerrit)
 vcl/inc/printdlg.hxx   |1 -
 vcl/source/window/printdlg.cxx |   13 -
 2 files changed, 8 insertions(+), 6 deletions(-)

New commits:
commit 65081542d2dabdf17820d62abdc5a22d3734e52d
Author: Tor Lillqvist 
AuthorDate: Tue Nov 2 20:16:31 2021 +0200
Commit: Tor Lillqvist 
CommitDate: Wed Nov 3 12:07:14 2021 +0100

tdf#145354: Ensure displayed paper name matches displayed paper dimensions

I could not reproduce it now but at least in some slightly older
version of LibreOffice, it could happen that at the top of the print
preview image was displayed "143 mm (A4)" which is silly, as neither
side of an A4 paper is 143 mm.

Look up the matching paper size from the dimensions displayed. Use the
"sloppy" match function to allow for sub-millimeter rounding errors.

Change-Id: I6320798061246101c6fc78baf841b71b32b25833
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124612
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 

diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 21aab3667d4e..d2ce1670a845 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -65,7 +65,6 @@ namespace vcl
 virtual void Resize() override;
 
 void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
- std::u16string_view i_rPaperName,
  const OUString& i_rNoPageString,
  sal_Int32 i_nDPIX, sal_Int32 i_nDPIY,
  bool i_bGreyscale
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 9909b087e02d..bf4fdf1519eb 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -207,7 +207,6 @@ bool PrintDialog::PrintPreviewWindow::Command( const 
CommandEvent& rEvt )
 
 void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& 
i_rNewPreview,
   const Size& i_rOrigSize,
-  std::u16string_view 
i_rPaperName,
   const OUString& 
i_rReplacement,
   sal_Int32 i_nDPIX,
   sal_Int32 i_nDPIY,
@@ -235,12 +234,18 @@ void PrintDialog::PrintPreviewWindow::setPreview( const 
GDIMetaFile& i_rNewPrevi
 OUStringBuffer aBuf;
 aBuf.append( aNumText + " " );
 aBuf.appendAscii( eUnit == MapUnit::MapMM ? "mm" : "in" );
-if( !i_rPaperName.empty() )
+
+// Look up the paper name from the dimensions
+PaperInfo aPaperInfoFromSize(i_rOrigSize.getWidth(), 
i_rOrigSize.getHeight());
+aPaperInfoFromSize.doSloppyFit( true );
+
+if (aPaperInfoFromSize.getPaper() != PAPER_USER)
 {
 aBuf.append( " (" );
-aBuf.append( i_rPaperName );
+aBuf.append( Printer::GetPaperName(aPaperInfoFromSize.getPaper()) );
 aBuf.append( ')' );
 }
+
 maHorzText = aBuf.makeStringAndClear();
 
 aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
@@ -944,7 +949,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
 if ( !hasPreview() )
 {
 mxPreview->setPreview( aMtf, aCurPageSize,
-Printer::GetPaperName( mePaper ),
 maNoPreviewStr,
 aPrt->GetDPIX(), aPrt->GetDPIY(),
 aPrt->GetPrinterOptions().IsConvertToGreyscales()
@@ -979,7 +983,6 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
 }
 
 mxPreview->setPreview( aMtf, aCurPageSize,
-Printer::GetPaperName( mePaper ),
 nPages > 0 ? OUString() : maNoPageStr,
 aPrt->GetDPIX(), aPrt->GetDPIY(),
 
aPrt->GetPrinterOptions().IsConvertToGreyscales()


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

2021-10-25 Thread Luboš Luňák (via logerrit)
 vcl/inc/impglyphitem.hxx   |   13 ++---
 vcl/source/gdi/CommonSalLayout.cxx |4 ++--
 2 files changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 5dc3bc1e951a5e1c485db8034d691bac4d42344a
Author: Luboš Luňák 
AuthorDate: Mon Oct 25 14:44:12 2021 +0200
Commit: Luboš Luňák 
CommitDate: Mon Oct 25 16:55:02 2021 +0200

replace friend access with functions

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

diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index 1942b9d159d5..ca9f7cf5c052 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -114,21 +114,20 @@ void GlyphItem::dropGlyph()
 
 class SalLayoutGlyphsImpl : public std::vector
 {
-friend class GenericSalLayout;
-
 public:
+SalLayoutGlyphsImpl(LogicalFontInstance& rFontInstance)
+: m_rFontInstance()
+{
+}
 SalLayoutGlyphsImpl* clone() const;
 const rtl::Reference& GetFont() const { return 
m_rFontInstance; }
 bool IsValid() const;
+void SetFlags(SalLayoutFlags flags) { mnFlags = flags; }
+SalLayoutFlags GetFlags() const { return mnFlags; }
 
 private:
 rtl::Reference m_rFontInstance;
 SalLayoutFlags mnFlags = SalLayoutFlags::NONE;
-
-SalLayoutGlyphsImpl(LogicalFontInstance& rFontInstance)
-: m_rFontInstance()
-{
-}
 };
 
 #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX
diff --git a/vcl/source/gdi/CommonSalLayout.cxx 
b/vcl/source/gdi/CommonSalLayout.cxx
index 2028a4587695..13bc53ebbdab 100644
--- a/vcl/source/gdi/CommonSalLayout.cxx
+++ b/vcl/source/gdi/CommonSalLayout.cxx
@@ -268,7 +268,7 @@ bool 
GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
 if(!item.glyphId())
 SetNeedFallback(rArgs, item.charPos(), item.IsRTLGlyph());
 // Some flags are set as a side effect of text layout, restore them 
here.
-rArgs.mnFlags |= pGlyphs->mnFlags;
+rArgs.mnFlags |= pGlyphs->GetFlags();
 return true;
 }
 
@@ -598,7 +598,7 @@ bool 
GenericSalLayout::LayoutText(vcl::text::ImplLayoutArgs& rArgs, const SalLay
 
 // Some flags are set as a side effect of text layout, save them here.
 if (rArgs.mnFlags & SalLayoutFlags::GlyphItemsOnly)
-m_GlyphItems.mnFlags = rArgs.mnFlags;
+m_GlyphItems.SetFlags(rArgs.mnFlags);
 
 return true;
 }


  1   2   3   4   5   >