Rebased ref, commits from common ancestor: commit a4ee83bf68b1e7f25cd2250fa88419f92c463907 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Jul 4 12:50:53 2018 +0200
Fixes Change-Id: Ie589ba2cdf620e36419316f862a9c28c47e90a2b diff --git a/vcl/qt5/Qt5Font.hxx b/vcl/inc/qt5/Qt5Font.hxx similarity index 100% rename from vcl/qt5/Qt5Font.hxx rename to vcl/inc/qt5/Qt5Font.hxx diff --git a/vcl/inc/qt5/Qt5Graphics.hxx b/vcl/inc/qt5/Qt5Graphics.hxx index 0e9de46818a6..79956573737a 100644 --- a/vcl/inc/qt5/Qt5Graphics.hxx +++ b/vcl/inc/qt5/Qt5Graphics.hxx @@ -53,6 +53,8 @@ class Qt5Graphics : public SalGraphics Qt5Graphics(Qt5Frame* pFrame, QImage* pQImage); + void drawScaledImage(const SalTwoRect& rPosAry, const QImage &rImage); + public: Qt5Graphics(Qt5Frame* pFrame) : Qt5Graphics(pFrame, nullptr) diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx index f075468ca3d3..c919b401e191 100644 --- a/vcl/inc/qt5/Qt5Tools.hxx +++ b/vcl/inc/qt5/Qt5Tools.hxx @@ -49,7 +49,7 @@ inline QRect toQRect(const tools::Rectangle& rRect) inline tools::Rectangle toRectangle(const QRect& rRect) { - return tools::Rectangle(rRect.left(), rRect.top(), rRect.width(), rRect.height()); + return tools::Rectangle(rRect.left(), rRect.top(), rRect.right(), rRect.bottom()); } inline QSize toQSize(const Size& rSize) { return QSize(rSize.Width(), rSize.Height()); } diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx index 246457dd9637..e95136f385b3 100644 --- a/vcl/qt5/Qt5Bitmap.cxx +++ b/vcl/qt5/Qt5Bitmap.cxx @@ -38,11 +38,11 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPale && "Unsupported BitCount!"); if (nBitCount == 1) - assert(2 <= rPal.GetEntryCount()); + assert(2 >= rPal.GetEntryCount()); if (nBitCount == 4) - assert(16 <= rPal.GetEntryCount()); + assert(16 >= rPal.GetEntryCount()); if (nBitCount == 8) - assert(256 <= rPal.GetEntryCount()); + assert(256 >= rPal.GetEntryCount()); if (nBitCount == 4) { diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx index 1ec1da68f8f2..0ce1e0ee266b 100644 --- a/vcl/qt5/Qt5Graphics_GDI.cxx +++ b/vcl/qt5/Qt5Graphics_GDI.cxx @@ -378,6 +378,15 @@ bool Qt5Graphics::drawPolyLine(const basegfx::B2DPolygon& rPolyLine, double fTra bool Qt5Graphics::drawGradient(const tools::PolyPolygon&, const Gradient&) { return false; } +void Qt5Graphics::drawScaledImage(const SalTwoRect& rPosAry, const QImage &rImage) +{ + Qt5Painter aPainter(*this); + QRect aSrcRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight); + QRect aDestRect(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); + aPainter.drawImage(aDestRect, rImage, aSrcRect); + aPainter.update(aDestRect); +} + void Qt5Graphics::copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, long nSrcWidth, long nSrcHeight, bool /*bWindowInvalidate*/) { @@ -388,41 +397,37 @@ void Qt5Graphics::copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, lon copyBits(aTR, this); } -void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) +template< typename charT, typename traits > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, const SalTwoRect& rPosAry ) { + tools::Rectangle aSrcRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcX + rPosAry.mnSrcWidth, rPosAry.mnSrcY + rPosAry.mnSrcHeight); + tools::Rectangle aDestRect(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestX + rPosAry.mnDestWidth, rPosAry.mnDestY + rPosAry.mnDestHeight); + stream << aSrcRect << " => " << aDestRect; + return stream; +} +void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) +{ if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0) return; - assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth); - assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight); - QImage aImage, *pImage; - int nSrcX, nSrcY; + SalTwoRect aPosAry = rPosAry; if (!pSrcGraphics || this == pSrcGraphics) { - if (rPosAry.mnDestX == rPosAry.mnSrcX && rPosAry.mnDestY == rPosAry.mnSrcY) - return; pImage = static_cast<Qt5Graphics*>(this)->m_pQImage; aImage = pImage->copy(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight); pImage = &aImage; - nSrcX = 0; - nSrcY = 0; + aPosAry.mnSrcX = 0; + aPosAry.mnSrcY = 0; } else - { pImage = static_cast<Qt5Graphics*>(pSrcGraphics)->m_pQImage; - nSrcX = rPosAry.mnSrcX; - nSrcY = rPosAry.mnSrcY; - } - Qt5Painter aPainter(*this); - aPainter.drawImage( - QPoint(rPosAry.mnDestX, rPosAry.mnDestY), *pImage, - QRect(nSrcX, nSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); - aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); + drawScaledImage(aPosAry, *pImage); } void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap) @@ -431,13 +436,6 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBit || rPosAry.mnDestHeight <= 0) return; - if (rPosAry.mnSrcWidth != rPosAry.mnDestWidth) - return; - if (rPosAry.mnSrcHeight != rPosAry.mnDestHeight) - return; - assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth); - assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight); - Qt5Bitmap aRGBABitmap; if (rSalBitmap.GetBitCount() == 4) aRGBABitmap.Create(rSalBitmap, 32); @@ -447,11 +445,7 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBit : aRGBABitmap.GetQImage(); assert(pImage); - Qt5Painter aPainter(*this); - aPainter.drawImage( - QPoint(rPosAry.mnDestX, rPosAry.mnDestY), *pImage, - QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); - aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); + drawScaledImage(rPosAry, *pImage); } void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& /*rSalBitmap*/, @@ -587,12 +581,7 @@ bool Qt5Graphics::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBitmap& rS QImage aImage; if (!getAlphaImage(rSourceBitmap, rAlphaBitmap, aImage)) return false; - - Qt5Painter aPainter(*this); - aPainter.drawImage( - QPoint(rPosAry.mnDestX, rPosAry.mnDestY), aImage, - QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); - aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); + drawScaledImage(rPosAry, aImage); return true; } diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx index c2aad76a4fa1..6ea2610e03f7 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -50,7 +50,10 @@ Qt5Instance::Qt5Instance(SalYieldMutex* pMutex, bool bUseCairo) { ImplSVData* pSVData = ImplGetSVData(); delete pSVData->maAppData.mpToolkitName; - pSVData->maAppData.mpToolkitName = new OUString("qt5"); + if (bUseCairo) + pSVData->maAppData.mpToolkitName = new OUString("qt5+cairo"); + else + pSVData->maAppData.mpToolkitName = new OUString("qt5"); m_postUserEventId = QEvent::registerEventType(); diff --git a/vcl/qt5/Qt5Tools.hxx b/vcl/qt5/Qt5Tools.hxx deleted file mode 100644 index 6aa910f575d6..000000000000 --- a/vcl/qt5/Qt5Tools.hxx +++ /dev/null @@ -1,112 +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 <QtCore/QString> -#include <QtCore/QRect> -#include <QtCore/QSize> -#include <QtGui/QImage> - -#include <rtl/string.hxx> -#include <rtl/ustring.hxx> -#include <tools/gen.hxx> - -#include <memory> - -inline OUString toOUString(const QString& s) -{ - // QString stores UTF16, just like OUString - return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length()); -} - -inline QString toQString(const OUString& s) -{ - return QString::fromUtf16(reinterpret_cast<ushort const*>(s.getStr()), s.getLength()); -} - -inline QRect toQRect(const tools::Rectangle& rRect) -{ - return QRect(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight()); -} - -inline tools::Rectangle toRectangle(const QRect& rRect) -{ - return tools::Rectangle(rRect.left(), rRect.top(), rRect.right(), rRect.bottom()); -} - -inline QSize toQSize(const Size& rSize) { return QSize(rSize.Width(), rSize.Height()); } - -inline Size toSize(const QSize& rSize) { return Size(rSize.width(), rSize.height()); } - -static constexpr QImage::Format Qt5_DefaultFormat32 = QImage::Format_ARGB32; - -inline QImage::Format getBitFormat(sal_uInt16 nBitCount) -{ - switch (nBitCount) - { - case 1: - return QImage::Format_Mono; - case 8: - return QImage::Format_Indexed8; - case 16: - return QImage::Format_RGB16; - case 24: - return QImage::Format_RGB888; - case 32: - return Qt5_DefaultFormat32; - default: - std::abort(); - break; - } - return QImage::Format_Invalid; -} - -inline sal_uInt16 getFormatBits(QImage::Format eFormat) -{ - switch (eFormat) - { - case QImage::Format_Mono: - return 1; - case QImage::Format_Indexed8: - return 8; - case QImage::Format_RGB16: - return 16; - case QImage::Format_RGB888: - return 24; - case Qt5_DefaultFormat32: - return 32; - default: - std::abort(); - return 0; - } -} - -typedef struct _cairo_surface cairo_surface_t; -struct CairoDeleter -{ - void operator()(cairo_surface_t* pSurface) const; -}; - -typedef std::unique_ptr<cairo_surface_t, CairoDeleter> UniqueCairoSurface; - -sal_uInt16 GetKeyModCode(Qt::KeyboardModifiers eKeyModifiers); -sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit ca280a18514633367f1fed80274b17583e778ead Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Jul 4 06:30:07 2018 +0200 more fixes Change-Id: Ic87da238b3a47b08eb589bc8ca207c5c72c6983a diff --git a/solenv/bin/create-tags b/solenv/bin/create-tags index 0537caa7ee3d..336476c55827 100755 --- a/solenv/bin/create-tags +++ b/solenv/bin/create-tags @@ -11,7 +11,7 @@ ctags="ctags $@" saloptions="-ISAL_DELETED_FUNCTION -ISAL_OVERRIDE -ISAL_FINAL" omnicppoptions="--c++-kinds=+p --fields=+iaS --extra=+q" -if [ "$1" -eq "-e" ]; then +if [ "$1" = "-e" ]; then tagfile="TAGS" else tagfile="tags" diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx index 3c94f46777e1..c653b4be6f6e 100644 --- a/vcl/inc/qt5/Qt5FontFace.hxx +++ b/vcl/inc/qt5/Qt5FontFace.hxx @@ -37,6 +37,7 @@ public: virtual ~Qt5FontFace() override; static Qt5FontFace* fromQFont(const QFont& rFont); + static void fillAttributesFromQFont(const QFont& rFont, FontAttributes& rFA); sal_IntPtr GetFontId() const override; diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx index 2fce20b67d3d..636fad3b1dda 100644 --- a/vcl/qt5/Qt5Font.cxx +++ b/vcl/qt5/Qt5Font.cxx @@ -49,9 +49,9 @@ static QFont::Weight GetQFontWeight(FontWeight eWeight) Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP) : LogicalFontInstance(rPFF, rFSP) { - setFamily( toQString(rPFF.GetFamilyName()) ); - setWeight( GetQFontWeight(rPFF.GetWeight()) ); - setPixelSize( rFSP.mnHeight ); + setFamily(toQString(rPFF.GetFamilyName())); + setWeight(GetQFontWeight(rPFF.GetWeight())); + setPixelSize(rFSP.mnHeight ); switch( rFSP.GetItalic() ) { case ITALIC_DONTKNOW: diff --git a/vcl/qt5/Qt5FontFace.hxx b/vcl/qt5/Qt5FontFace.hxx deleted file mode 100644 index 453bebbe5e68..000000000000 --- a/vcl/qt5/Qt5FontFace.hxx +++ /dev/null @@ -1,64 +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 <PhysicalFontFace.hxx> - -#include <tools/ref.hxx> -#include <vcl/fontcapabilities.hxx> -#include <vcl/fontcharmap.hxx> - -#include <QtCore/QString> - -class FontAttributes; -class FontSelectPattern; -class QFont; - -class Qt5FontFace : public PhysicalFontFace -{ -public: - virtual ~Qt5FontFace() override; - - static Qt5FontFace* fromQFont(const QFont& rFont); - static void fillAttributesFromQFont(const QFont& rFont, FontAttributes& rFA); - - PhysicalFontFace* Clone() const override; - sal_IntPtr GetFontId() const override; - - int GetFontTable(const char pTagName[5], unsigned char*) const; - - const FontCharMapRef GetFontCharMap() const; - bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const; - bool HasChar(sal_uInt32 cChar) const; - - LogicalFontInstance* CreateFontInstance(const FontSelectPattern& rFSD) const override; - -protected: - Qt5FontFace(const Qt5FontFace&); - Qt5FontFace(const FontAttributes& rFA, const QString& rFontID); - -private: - const QString m_aFontId; - mutable FontCharMapRef m_xCharMap; - mutable vcl::FontCapabilities m_aFontCapabilities; - mutable bool m_bFontCapabilitiesRead; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx index eb3ef6972c94..1ec1da68f8f2 100644 --- a/vcl/qt5/Qt5Graphics_GDI.cxx +++ b/vcl/qt5/Qt5Graphics_GDI.cxx @@ -196,7 +196,7 @@ void Qt5Graphics::drawLine(long nX1, long nY1, long nX2, long nY2) nY1 = nY2; nY2 = tmp; } - aPainter.update(nX1, nY1, nX2 - nX1, nY2 - nY1); + aPainter.update(nX1, nY1, nX2 - nX1 + 1, nY2 - nY1 + 1); } void Qt5Graphics::drawRect(long nX, long nY, long nWidth, long nHeight) diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index dcb501a076f0..4121eb4b8f44 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -183,10 +183,10 @@ bool Qt5Graphics::GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) return false; } -class Qt5CommonSalLayout : public CommonSalLayout +class Qt5CommonSalLayout : public GenericSalLayout { public: - Qt5CommonSalLayout(LogicalFontInstance& rLFI): CommonSalLayout(rLFI) {} + Qt5CommonSalLayout(LogicalFontInstance& rLFI): GenericSalLayout(rLFI) {} void SetOrientation(int nOrientation) { @@ -212,7 +212,7 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout) // prevent glyph rotation inside the SalLayout // probably better to add a parameter to GetNextGlyphs? - Qt5CommonSalLayout *pQt5Layout = static_cast<Qt5CommonSalLayout*>(const_cast<CommonSalLayout*>(&rLayout)); + Qt5CommonSalLayout *pQt5Layout = static_cast<Qt5CommonSalLayout*>(const_cast<GenericSalLayout*>(&rLayout)); int nOrientation = rLayout.GetOrientation(); if (nOrientation) pQt5Layout->SetOrientation(0); diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 3e4087b6e4a7..c50ee6098c84 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -1072,7 +1072,7 @@ bool OutputDevice::ImplNewFont() const mbNewFont = false; // mark when lower layers need to get involved - if( pFontInstance != pOldFontInstance ) + if( bNewFontInstance ) mbInitFont = true; // select font when it has not been initialized yet commit 518ccb52c9c882bd59e5b4af29721a2aa3277429 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Apr 16 13:37:07 2018 +0000 Use fontconfig for font substitution This just shoves all known fonts from the PrintFontManager into the QFontDatabase. Can be disabled using SAL_VCL_QT5_NO_FONTCONFIG. It already feels slow - don't know. Running "./bin/run vcldemo --show text" you can see it has some pro and cons, regarding the output. Qts' diacrits look definitly nicer then the "substitutions". This brings the font support kind of on par with the other backends. And since sensible font substitition is not at all implemented in Qt, we have to rely on some platform ssolution anyway. And this needs a sensible, platform agnostic interface, so we can reuse the code easier. Change-Id: I4e9d8ee98fc479a7c4bbe4c968116e0a102ebb7a diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index 85a970527ea1..dcb501a076f0 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -23,6 +23,8 @@ #include <Qt5Painter.hxx> #include <vcl/fontcharmap.hxx> +#include <unx/geninst.h> +#include <unx/fontmanager.hxx> #include <sallayout.hxx> #include <PhysicalFontCollection.hxx> @@ -92,11 +94,33 @@ bool Qt5Graphics::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) void Qt5Graphics::GetDevFontList(PhysicalFontCollection* pPFC) { + static const bool bUseFontconfig = (nullptr == getenv("SAL_VCL_QT5_NO_FONTCONFIG")); + m_pFontCollection = pPFC; if (pPFC->Count()) return; QFontDatabase aFDB; + + if (bUseFontconfig) + { + ::std::vector< psp::fontID > aList; + psp::FastPrintFontInfo aInfo; + + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + rMgr.getFontList( aList ); + for (auto const& elem : aList) + { + if (!rMgr.getFontFastInfo(elem, aInfo)) + continue; + QString aFilename = toQString(OStringToOUString( + rMgr.getFontFileSysPath(aInfo.m_nID), RTL_TEXTENCODING_UTF8)); + aFDB.addApplicationFont(aFilename); + } + + SalGenericInstance::RegisterFontSubstitutors(pPFC); + } + for (auto& family : aFDB.families()) for (auto& style : aFDB.styles(family)) { diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx index ef618e18fa7f..c2aad76a4fa1 100644 --- a/vcl/qt5/Qt5Instance.cxx +++ b/vcl/qt5/Qt5Instance.cxx @@ -280,7 +280,7 @@ VCLPLUG_QT5_PUBLIC SalInstance* create_SalInstance() QApplication::setQuitOnLastWindowClosed(false); - const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO")); + static const bool bUseCairo = (nullptr != getenv("SAL_VCL_QT5_USE_CAIRO")); Qt5Instance* pInstance = new Qt5Instance(new SalYieldMutex(), bUseCairo); // initialize SalData commit ff8e6060473b124df5a54342be662c8d5434afef Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Apr 16 12:38:42 2018 +0000 More fixes Change-Id: Iebf3bcaecd0a5ee0185cd8c90e02bfc5a259f2fb diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx index b98c1963c881..2fce20b67d3d 100644 --- a/vcl/qt5/Qt5Font.cxx +++ b/vcl/qt5/Qt5Font.cxx @@ -52,6 +52,21 @@ Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP) setFamily( toQString(rPFF.GetFamilyName()) ); setWeight( GetQFontWeight(rPFF.GetWeight()) ); setPixelSize( rFSP.mnHeight ); + switch( rFSP.GetItalic() ) + { + case ITALIC_DONTKNOW: + case FontItalic_FORCE_EQUAL_SIZE: + break; + case ITALIC_NONE: + setStyle(Style::StyleNormal); + break; + case ITALIC_OBLIQUE: + setStyle(Style::StyleOblique); + break; + case ITALIC_NORMAL: + setStyle(Style::StyleItalic); + break; + } } Qt5Font::~Qt5Font() {} diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx index d8e7cab3fc14..8cb919a50437 100644 --- a/vcl/qt5/Qt5FontFace.cxx +++ b/vcl/qt5/Qt5FontFace.cxx @@ -41,16 +41,17 @@ Qt5FontFace::Qt5FontFace(const Qt5FontFace& rSrc) m_xCharMap = rSrc.m_xCharMap; } -Qt5FontFace* Qt5FontFace::fromQFont(const QFont& rFont) +void Qt5FontFace::fillAttributesFromQFont(const QFont& rFont, FontAttributes& rFA) { - FontAttributes aFA; QFontInfo aFontInfo(rFont); - aFA.SetFamilyName(toOUString(aFontInfo.family())); - aFA.SetStyleName(toOUString(aFontInfo.styleName())); - aFA.SetItalic(aFontInfo.italic() ? ITALIC_NORMAL : ITALIC_NONE); - aFA.SetPitch(aFontInfo.fixedPitch() ? PITCH_FIXED : PITCH_VARIABLE); - FontWeight eWeight; + rFA.SetFamilyName(toOUString(aFontInfo.family())); + if (IsStarSymbol(toOUString(aFontInfo.family()))) + rFA.SetSymbolFlag(true); + rFA.SetStyleName(toOUString(aFontInfo.styleName())); + rFA.SetPitch(aFontInfo.fixedPitch() ? PITCH_FIXED : PITCH_VARIABLE); + + FontWeight eWeight = WEIGHT_DONTKNOW; switch( aFontInfo.weight() ) { case QFont::Thin: eWeight = WEIGHT_THIN; break; @@ -63,10 +64,23 @@ Qt5FontFace* Qt5FontFace::fromQFont(const QFont& rFont) case QFont::ExtraBold: eWeight = WEIGHT_ULTRABOLD; break; case QFont::Black: eWeight = WEIGHT_BLACK; break; } - aFA.SetWeight(eWeight); + rFA.SetWeight(eWeight); + + switch (aFontInfo.style()) + { + case QFont::StyleNormal: rFA.SetItalic(ITALIC_NONE); break; + case QFont::StyleItalic: rFA.SetItalic(ITALIC_NORMAL); break; + case QFont::StyleOblique: rFA.SetItalic(ITALIC_OBLIQUE); break; + } - SAL_INFO("vcl.qt5.font", toOUString(aFontInfo.family()) << " " << aFontInfo.weight() << " => " << (int) eWeight ); + SAL_INFO("vcl.qt5.font", toOUString(aFontInfo.family()) << " " + << aFontInfo.weight() << " => " << (int) eWeight ); +} +Qt5FontFace* Qt5FontFace::fromQFont(const QFont& rFont) +{ + FontAttributes aFA; + fillAttributesFromQFont(rFont, aFA); return new Qt5FontFace(aFA, rFont.toString()); } diff --git a/vcl/qt5/Qt5FontFace.hxx b/vcl/qt5/Qt5FontFace.hxx new file mode 100644 index 000000000000..453bebbe5e68 --- /dev/null +++ b/vcl/qt5/Qt5FontFace.hxx @@ -0,0 +1,64 @@ +/* -*- 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 <PhysicalFontFace.hxx> + +#include <tools/ref.hxx> +#include <vcl/fontcapabilities.hxx> +#include <vcl/fontcharmap.hxx> + +#include <QtCore/QString> + +class FontAttributes; +class FontSelectPattern; +class QFont; + +class Qt5FontFace : public PhysicalFontFace +{ +public: + virtual ~Qt5FontFace() override; + + static Qt5FontFace* fromQFont(const QFont& rFont); + static void fillAttributesFromQFont(const QFont& rFont, FontAttributes& rFA); + + PhysicalFontFace* Clone() const override; + sal_IntPtr GetFontId() const override; + + int GetFontTable(const char pTagName[5], unsigned char*) const; + + const FontCharMapRef GetFontCharMap() const; + bool GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities) const; + bool HasChar(sal_uInt32 cChar) const; + + LogicalFontInstance* CreateFontInstance(const FontSelectPattern& rFSD) const override; + +protected: + Qt5FontFace(const Qt5FontFace&); + Qt5FontFace(const FontAttributes& rFA, const QString& rFontID); + +private: + const QString m_aFontId; + mutable FontCharMapRef m_xCharMap; + mutable vcl::FontCapabilities m_aFontCapabilities; + mutable bool m_bFontCapabilitiesRead; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index 8fb70c820788..85a970527ea1 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -56,6 +56,10 @@ void Qt5Graphics::SetFont(const FontSelectPattern* pReqFont, int nFallbackLevel) void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel) { QRawFont aRawFont(QRawFont::fromFont(*m_pTextStyle[nFallbackLevel])); + Qt5FontFace::fillAttributesFromQFont(*m_pTextStyle[nFallbackLevel], *rFMD); + + rFMD->SetSlant(0); + rFMD->SetWidth(aRawFont.averageCharWidth()); QByteArray aHheaTable = aRawFont.fontTable("hhea"); std::vector<uint8_t> rHhea(aHheaTable.data(), aHheaTable.data() + aHheaTable.size()); @@ -65,7 +69,7 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel) rFMD->ImplCalcLineSpacing(rHhea, rOS2, aRawFont.unitsPerEm()); - rFMD->SetSlant( 0 ); + rFMD->SetSlant(0); rFMD->SetWidth(aRawFont.averageCharWidth()); rFMD->SetMinKashida(m_pTextStyle[nFallbackLevel]->GetKashidaWidth()); diff --git a/vcl/qt5/Qt5Tools.hxx b/vcl/qt5/Qt5Tools.hxx index c7b47014beb0..6aa910f575d6 100644 --- a/vcl/qt5/Qt5Tools.hxx +++ b/vcl/qt5/Qt5Tools.hxx @@ -48,7 +48,7 @@ inline QRect toQRect(const tools::Rectangle& rRect) inline tools::Rectangle toRectangle(const QRect& rRect) { - return tools::Rectangle(rRect.left(), rRect.top(), rRect.width(), rRect.height()); + return tools::Rectangle(rRect.left(), rRect.top(), rRect.right(), rRect.bottom()); } inline QSize toQSize(const Size& rSize) { return QSize(rSize.Width(), rSize.Height()); } commit 724adcfc1776bbf4a00bbb3adaca0fe27d5206b3 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Apr 16 00:58:59 2018 +0000 Lot of fixes Change-Id: I6aa342ead561ef736605d3f8625fb0dcd2249b62 diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 6b97f30409e7..ae2fb1086d7f 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -963,6 +963,7 @@ void EditorWindow::CreateEditEngine() ImplSetFont(); aSyntaxIdle.SetInvokeHandler( LINK( this, EditorWindow, SyntaxTimerHdl ) ); + aSyntaxIdle.SetDebugName( "basctl EditorWindow aSyntaxIdle" ); bool bWasDoSyntaxHighlight = bDoSyntaxHighlight; bDoSyntaxHighlight = false; // too slow for large texts... diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index a13cb5312bf6..d13a9009ee0e 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -129,7 +129,10 @@ Reference < XDispatch > SAL_CALL SfxAppDispatchProvider::queryDispatch( bool bMasterCommand( false ); Reference < XDispatch > xDisp; const SfxSlot* pSlot = nullptr; - SfxDispatcher* pAppDisp = SfxGetpApp()->GetAppDispatcher_Impl(); + SfxApplication* pApp = SfxGetpApp(); + if ( !pApp ) + return xDisp; + SfxDispatcher* pAppDisp = pApp->GetAppDispatcher_Impl(); if ( aURL.Protocol == "slot:" || aURL.Protocol == "commandId:" ) { nId = static_cast<sal_uInt16>(aURL.Path.toInt32()); diff --git a/solenv/bin/create-tags b/solenv/bin/create-tags index c9fd565b823f..0537caa7ee3d 100755 --- a/solenv/bin/create-tags +++ b/solenv/bin/create-tags @@ -11,6 +11,15 @@ ctags="ctags $@" saloptions="-ISAL_DELETED_FUNCTION -ISAL_OVERRIDE -ISAL_FINAL" omnicppoptions="--c++-kinds=+p --fields=+iaS --extra=+q" +if [ "$1" -eq "-e" ]; then + tagfile="TAGS" +else + tagfile="tags" +fi + +tmpfile=$(mktemp) +ctags="$ctags -f $tmpfile" + $ctags -h "+.hdl.hrc" --langmap=c:+.hrc.src,c++:+.hdl $saloptions $omnicppoptions \ --languages=-HTML,Java,JavaScript \ --langdef=UNOIDL \ @@ -39,3 +48,6 @@ $ctags -h "+.hdl.hrc" --langmap=c:+.hrc.src,c++:+.hdl $saloptions $omnicppoption $w/UnoApiHeadersTarget/udkapi/normal \ $w/UnoApiHeadersTarget/offapi/normal \ $w/CustomTarget/officecfg/registry + +mv "$tmpfile" "$tagfile" + diff --git a/vcl/inc/qt5/Qt5Bitmap.hxx b/vcl/inc/qt5/Qt5Bitmap.hxx index 6ecdebed5ca1..c89038a28fb7 100644 --- a/vcl/inc/qt5/Qt5Bitmap.hxx +++ b/vcl/inc/qt5/Qt5Bitmap.hxx @@ -31,7 +31,7 @@ class VCL_DLLPUBLIC Qt5Bitmap : public SalBitmap BitmapPalette m_aPalette; // for 4bit support - std::unique_ptr<sal_uInt8> m_pBuffer; + std::unique_ptr<sal_uInt8[]> m_pBuffer; Size m_aSize; sal_uInt32 m_nScanline; diff --git a/vcl/qt5/Qt5Bitmap.cxx b/vcl/qt5/Qt5Bitmap.cxx index ff44143a16f2..246457dd9637 100644 --- a/vcl/qt5/Qt5Bitmap.cxx +++ b/vcl/qt5/Qt5Bitmap.cxx @@ -38,18 +38,27 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPale && "Unsupported BitCount!"); if (nBitCount == 1) - assert(2 == rPal.GetEntryCount()); + assert(2 <= rPal.GetEntryCount()); if (nBitCount == 4) - assert(16 == rPal.GetEntryCount()); + assert(16 <= rPal.GetEntryCount()); if (nBitCount == 8) - assert(256 == rPal.GetEntryCount()); + assert(256 <= rPal.GetEntryCount()); if (nBitCount == 4) { m_pImage.reset(); m_aSize = rSize; - m_nScanline = rSize.Width() / 2 + (rSize.Width() % 2) ? 0 : 1; - m_pBuffer.reset(new sal_uInt8[m_nScanline * rSize.Height()]); + bool bFail = o3tl::checked_multiply<sal_uInt32>(rSize.Width(), nBitCount, m_nScanline); + if (bFail) + { + SAL_WARN("vcl.gdi", "checked multiply failed"); + return false; + } + m_nScanline = AlignedWidth4Bytes(m_nScanline); + sal_uInt8 *pBuffer = nullptr; + if (0 != m_nScanline && 0 != rSize.Height()) + pBuffer = new sal_uInt8[m_nScanline * rSize.Height()]; + m_pBuffer.reset(pBuffer); } else { @@ -59,7 +68,7 @@ bool Qt5Bitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPale m_aPalette = rPal; auto count = rPal.GetEntryCount(); - if (nBitCount != 4 && count) + if (nBitCount != 4 && count && m_pImage.get()) { QVector<QRgb> aColorTable(count); for (unsigned i = 0; i < count; ++i) @@ -81,8 +90,14 @@ bool Qt5Bitmap::Create(const SalBitmap& rSalBmp) { m_aSize = pBitmap->m_aSize; m_nScanline = pBitmap->m_nScanline; - m_pBuffer.reset(new sal_uInt8[m_nScanline * m_aSize.Height()]); - memcpy(m_pBuffer.get(), pBitmap->m_pBuffer.get(), m_nScanline); + sal_uInt8 *pBuffer = nullptr; + if (0 != m_nScanline && 0 != m_aSize.Height()) + { + sal_uInt32 nSize = m_nScanline * m_aSize.Height(); + pBuffer = new sal_uInt8[nSize]; + memcpy(pBuffer, pBitmap->m_pBuffer.get(), nSize); + } + m_pBuffer.reset(pBuffer); m_pImage.reset(); } m_aPalette = pBitmap->m_aPalette; @@ -107,9 +122,51 @@ bool Qt5Bitmap::Create(const SalBitmap& rSalBmp, sal_uInt16 nNewBitCount) const Qt5Bitmap* pBitmap = static_cast<const Qt5Bitmap*>(&rSalBmp); if (pBitmap->m_pBuffer.get()) - return false; + { + if (nNewBitCount != 32) + return false; + + // convert 4bit indexed palette to 32bit ARGB + m_pImage.reset(new QImage(pBitmap->m_aSize.Width(), pBitmap->m_aSize.Height(), getBitFormat(nNewBitCount))); + m_pImage->fill(0); + + // prepare a whole palette + const BitmapPalette& rPal = pBitmap->m_aPalette; + QVector<QRgb> colorTable(16); + int i = 0, maxEntry = pBitmap->m_aPalette.GetEntryCount(); + assert(maxEntry <= 16 && maxEntry >= 0); + for (; i < maxEntry; ++i) + colorTable[i] = qRgb(rPal[i].GetRed(), rPal[i].GetGreen(), rPal[i].GetBlue()); + for (; i < 16; ++i) + colorTable[i] = qRgb(0, 0, 0); - m_pImage.reset(new QImage(pBitmap->m_pImage->convertToFormat(getBitFormat(nNewBitCount)))); + sal_uInt32 *image_data = reinterpret_cast<sal_uInt32*>(m_pImage->bits()); + sal_uInt8 *buffer_data_pos = pBitmap->m_pBuffer.get(); + sal_uInt32 nWidth = pBitmap->m_aSize.Height() / 2; + bool isOdd(0 != pBitmap->m_aSize.Height() % 2); + + for (sal_uInt32 h = 0; h < pBitmap->m_aSize.Height(); ++h) + { + sal_uInt8 *buffer_data = buffer_data_pos; + buffer_data_pos += pBitmap->m_nScanline; + for (sal_uInt32 w = 0; w < nWidth; ++w) + { + *image_data = reinterpret_cast<sal_uInt32>(colorTable.at(*buffer_data >> 4)); + ++image_data; + *image_data = reinterpret_cast<sal_uInt32>(colorTable.at(*buffer_data & 0xF)); + ++image_data; + ++buffer_data; + } + if (isOdd) + { + *image_data = reinterpret_cast<sal_uInt32>(colorTable.at(*buffer_data >> 4)); + ++image_data; + } + } + } + else + m_pImage.reset(new QImage(pBitmap->m_pImage->convertToFormat(getBitFormat(nNewBitCount)))); + m_pBuffer.reset(); return true; } @@ -172,7 +229,7 @@ BitmapBuffer* Qt5Bitmap::AcquireBuffer(BitmapAccessMode /*nMode*/) switch (pBuffer->mnBitCount) { case 1: - pBuffer->mnFormat = ScanlineFormat::N1BitLsbPal | ScanlineFormat::TopDown; + pBuffer->mnFormat = ScanlineFormat::N1BitMsbPal | ScanlineFormat::TopDown; pBuffer->maPalette = m_aPalette; break; case 4: diff --git a/vcl/qt5/Qt5Font.cxx b/vcl/qt5/Qt5Font.cxx index 0164c3b13cd4..b98c1963c881 100644 --- a/vcl/qt5/Qt5Font.cxx +++ b/vcl/qt5/Qt5Font.cxx @@ -18,13 +18,40 @@ */ #include "Qt5Font.hxx" +#include "Qt5Tools.hxx" #include <QtGui/QFont> #include <QtGui/QRawFont> +static QFont::Weight GetQFontWeight(FontWeight eWeight) +{ + switch(eWeight) + { + case WEIGHT_THIN: return QFont::Thin; + case WEIGHT_ULTRALIGHT: return QFont::ExtraLight; + case WEIGHT_LIGHT: return QFont::Light; + case FontWeight_FORCE_EQUAL_SIZE: + assert( 0 && "FontWeight_FORCE_EQUAL_SIZE not implementable for QFont" ); + case WEIGHT_SEMILIGHT: + case WEIGHT_DONTKNOW: + case WEIGHT_NORMAL: return QFont::Normal; + case WEIGHT_MEDIUM: return QFont::Medium; + case WEIGHT_SEMIBOLD: return QFont::DemiBold; + case WEIGHT_BOLD: return QFont::Bold; + case WEIGHT_ULTRABOLD: return QFont::ExtraBold; + case WEIGHT_BLACK: return QFont::Black; + } + + // so we would get enum not handled warning + return QFont::Normal; +} + Qt5Font::Qt5Font(const PhysicalFontFace& rPFF, const FontSelectPattern& rFSP) : LogicalFontInstance(rPFF, rFSP) { + setFamily( toQString(rPFF.GetFamilyName()) ); + setWeight( GetQFontWeight(rPFF.GetWeight()) ); + setPixelSize( rFSP.mnHeight ); } Qt5Font::~Qt5Font() {} diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx index 043a9b6e798b..d8e7cab3fc14 100644 --- a/vcl/qt5/Qt5FontFace.cxx +++ b/vcl/qt5/Qt5FontFace.cxx @@ -44,9 +44,28 @@ Qt5FontFace::Qt5FontFace(const Qt5FontFace& rSrc) Qt5FontFace* Qt5FontFace::fromQFont(const QFont& rFont) { FontAttributes aFA; - aFA.SetFamilyName(toOUString(rFont.family())); - aFA.SetStyleName(toOUString(rFont.styleName())); - aFA.SetItalic(rFont.italic() ? ITALIC_NORMAL : ITALIC_NONE); + QFontInfo aFontInfo(rFont); + aFA.SetFamilyName(toOUString(aFontInfo.family())); + aFA.SetStyleName(toOUString(aFontInfo.styleName())); + aFA.SetItalic(aFontInfo.italic() ? ITALIC_NORMAL : ITALIC_NONE); + aFA.SetPitch(aFontInfo.fixedPitch() ? PITCH_FIXED : PITCH_VARIABLE); + + FontWeight eWeight; + switch( aFontInfo.weight() ) + { + case QFont::Thin: eWeight = WEIGHT_THIN; break; + case QFont::ExtraLight: eWeight = WEIGHT_ULTRALIGHT; break; + case QFont::Light: eWeight = WEIGHT_LIGHT; break; + case QFont::Normal: eWeight = WEIGHT_NORMAL; break; + case QFont::Medium: eWeight = WEIGHT_MEDIUM; break; + case QFont::DemiBold: eWeight = WEIGHT_SEMIBOLD; break; + case QFont::Bold: eWeight = WEIGHT_BOLD; break; + case QFont::ExtraBold: eWeight = WEIGHT_ULTRABOLD; break; + case QFont::Black: eWeight = WEIGHT_BLACK; break; + } + aFA.SetWeight(eWeight); + + SAL_INFO("vcl.qt5.font", toOUString(aFontInfo.family()) << " " << aFontInfo.weight() << " => " << (int) eWeight ); return new Qt5FontFace(aFA, rFont.toString()); } diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx index b58f18e4b59b..eb3ef6972c94 100644 --- a/vcl/qt5/Qt5Graphics_GDI.cxx +++ b/vcl/qt5/Qt5Graphics_GDI.cxx @@ -207,7 +207,7 @@ void Qt5Graphics::drawRect(long nX, long nY, long nWidth, long nHeight) Qt5Painter aPainter(*this, true); if (SALCOLOR_NONE != m_aFillColor) aPainter.fillRect(nX, nY, nWidth, nHeight, aPainter.brush()); - else + if (SALCOLOR_NONE != m_aLineColor) aPainter.drawRect(nX, nY, nWidth, nHeight); aPainter.update(nX, nY, nWidth, nHeight); } @@ -248,9 +248,31 @@ void Qt5Graphics::drawPolygon(sal_uInt32 nPoints, const SalPoint* pPtAry) aPainter.update(aPolygon.boundingRect()); } -void Qt5Graphics::drawPolyPolygon(sal_uInt32 /*nPoly*/, const sal_uInt32* /*pPoints*/, - PCONSTSALPOINT* /*pPtAry*/) +void Qt5Graphics::drawPolyPolygon(sal_uInt32 nPolyCount, const sal_uInt32* pPoints, + PCONSTSALPOINT* ppPtAry) { + // ignore invisible polygons + if (SALCOLOR_NONE == m_aFillColor && SALCOLOR_NONE == m_aLineColor) + return; + + QPainterPath aPath; + for( sal_uInt32 nPoly = 0; nPoly < nPolyCount; nPoly++ ) + { + const sal_uInt32 nPoints = pPoints[nPoly]; + if( nPoints > 1 ) + { + const SalPoint *pPtAry = ppPtAry[nPoly]; + aPath.moveTo(pPtAry->mnX, pPtAry->mnY); + pPtAry++; + for( sal_uInt32 nPoint = 1; nPoint < nPoints; nPoint++, pPtAry++ ) + aPath.lineTo(pPtAry->mnX, pPtAry->mnY); + aPath.closeSubpath(); + } + } + + Qt5Painter aPainter(*this, true); + aPainter.drawPath(aPath); + aPainter.update(aPath.boundingRect()); } bool Qt5Graphics::drawPolyPolygon(const basegfx::B2DPolyPolygon& rPolyPoly, double fTransparency) @@ -368,6 +390,7 @@ void Qt5Graphics::copyArea(long nDestX, long nDestY, long nSrcX, long nSrcY, lon void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) { + if (rPosAry.mnSrcWidth <= 0 || rPosAry.mnSrcHeight <= 0 || rPosAry.mnDestWidth <= 0 || rPosAry.mnDestHeight <= 0) return; @@ -375,21 +398,30 @@ void Qt5Graphics::copyBits(const SalTwoRect& rPosAry, SalGraphics* pSrcGraphics) assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth); assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight); - QImage aImage, *pImage = &aImage; + QImage aImage, *pImage; + int nSrcX, nSrcY; if (!pSrcGraphics || this == pSrcGraphics) { if (rPosAry.mnDestX == rPosAry.mnSrcX && rPosAry.mnDestY == rPosAry.mnSrcY) return; + pImage = static_cast<Qt5Graphics*>(this)->m_pQImage; aImage = pImage->copy(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight); + pImage = &aImage; + nSrcX = 0; + nSrcY = 0; } else + { pImage = static_cast<Qt5Graphics*>(pSrcGraphics)->m_pQImage; + nSrcX = rPosAry.mnSrcX; + nSrcY = rPosAry.mnSrcY; + } Qt5Painter aPainter(*this); aPainter.drawImage( QPoint(rPosAry.mnDestX, rPosAry.mnDestY), *pImage, - QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); + QRect(nSrcX, nSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); aPainter.update(rPosAry.mnDestX, rPosAry.mnDestY, rPosAry.mnDestWidth, rPosAry.mnDestHeight); } @@ -399,14 +431,23 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& rSalBit || rPosAry.mnDestHeight <= 0) return; + if (rPosAry.mnSrcWidth != rPosAry.mnDestWidth) + return; + if (rPosAry.mnSrcHeight != rPosAry.mnDestHeight) + return; assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth); assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight); - Qt5Painter aPainter(*this); + Qt5Bitmap aRGBABitmap; + if (rSalBitmap.GetBitCount() == 4) + aRGBABitmap.Create(rSalBitmap, 32); - const QImage* pImage = static_cast<const Qt5Bitmap*>(&rSalBitmap)->GetQImage(); + const QImage* pImage = (rSalBitmap.GetBitCount() != 4) + ? static_cast<const Qt5Bitmap*>(&rSalBitmap)->GetQImage() + : aRGBABitmap.GetQImage(); assert(pImage); + Qt5Painter aPainter(*this); aPainter.drawImage( QPoint(rPosAry.mnDestX, rPosAry.mnDestY), *pImage, QRect(rPosAry.mnSrcX, rPosAry.mnSrcY, rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); @@ -422,6 +463,8 @@ void Qt5Graphics::drawBitmap(const SalTwoRect& rPosAry, const SalBitmap& /*rSalB assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth); assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight); + + assert(0 && "Qt5Graphics::drawBitmap"); } void Qt5Graphics::drawMask(const SalTwoRect& rPosAry, const SalBitmap& /*rSalBitmap*/, @@ -433,6 +476,8 @@ void Qt5Graphics::drawMask(const SalTwoRect& rPosAry, const SalBitmap& /*rSalBit assert(rPosAry.mnSrcWidth == rPosAry.mnDestWidth); assert(rPosAry.mnSrcHeight == rPosAry.mnDestHeight); + + assert(0 && "Qt5Graphics::drawMask"); } std::shared_ptr<SalBitmap> Qt5Graphics::getBitmap(long nX, long nY, long nWidth, long nHeight) @@ -442,13 +487,35 @@ std::shared_ptr<SalBitmap> Qt5Graphics::getBitmap(long nX, long nY, long nWidth, Color Qt5Graphics::getPixel(long nX, long nY) { return m_pQImage->pixel(nX, nY); } -void Qt5Graphics::invert(long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, - SalInvert /*nFlags*/) +void Qt5Graphics::invert(long nX, long nY, long nWidth, long nHeight, SalInvert nFlags) { + Qt5Painter aPainter(*this); + if (SalInvert::N50 & nFlags) + { + aPainter.setCompositionMode(QPainter::RasterOp_SourceXorDestination); + aPainter.setBrush(Qt::DiagCrossPattern); + aPainter.fillRect(nX, nY, nWidth, nHeight, aPainter.brush()); + } + else + { + if (SalInvert::TrackFrame & nFlags) + { + aPainter.setCompositionMode(QPainter::RasterOp_SourceXorDestination); + aPainter.setPen(Qt::DashLine); + aPainter.drawRect(nX, nY, nWidth, nHeight); + } + else + { + aPainter.setCompositionMode(QPainter::RasterOp_SourceXorDestination); + aPainter.fillRect(nX, nY, nWidth, nHeight, Qt::white); + } + } + aPainter.update(nX, nY, nWidth, nHeight); } void Qt5Graphics::invert(sal_uInt32 /*nPoints*/, const SalPoint* /*pPtAry*/, SalInvert /*nFlags*/) { + assert(0 && "Qt5Graphics::invert 2"); } bool Qt5Graphics::drawEPS(long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, @@ -469,13 +536,19 @@ bool Qt5Graphics::blendAlphaBitmap(const SalTwoRect&, const SalBitmap& /*rSrcBit static bool getAlphaImage(const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap, QImage& rAlphaImage) { - if (rAlphaBitmap.GetBitCount() != 8 && rAlphaBitmap.GetBitCount() != 1) + if ((rAlphaBitmap.GetBitCount() != 8 && rAlphaBitmap.GetBitCount() != 1)) { SAL_WARN("vcl.gdi", "unsupported alpha depth case: " << rAlphaBitmap.GetBitCount()); return false; } - const QImage* pBitmap = static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage(); + Qt5Bitmap aRGBABitmap; + if (rSourceBitmap.GetBitCount() == 4) + aRGBABitmap.Create(rSourceBitmap, 32); + + const QImage* pBitmap = (rSourceBitmap.GetBitCount() != 4) + ? static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage() + : aRGBABitmap.GetQImage(); const QImage* pAlpha = static_cast<const Qt5Bitmap*>(&rAlphaBitmap)->GetQImage(); rAlphaImage = pBitmap->convertToFormat(Qt5_DefaultFormat32); @@ -499,7 +572,7 @@ static bool getAlphaImage(const SalBitmap& rSourceBitmap, const SalBitmap& rAlph { if (x && !(x % 8)) ++alpha_line; - if (0 == (*alpha_line & (1 << (x % 8)))) + if (0 != (*alpha_line & (1 << (7 - x % 8)))) image_line[3] = 0; } } @@ -532,7 +605,13 @@ bool Qt5Graphics::drawTransformedBitmap(const basegfx::B2DPoint& rNull, const ba return false; else { - const QImage* pBitmap = static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage(); + Qt5Bitmap aRGBABitmap; + if (rSourceBitmap.GetBitCount() == 4) + aRGBABitmap.Create(rSourceBitmap, 32); + + const QImage* pBitmap = (rSourceBitmap.GetBitCount() != 4) + ? static_cast<const Qt5Bitmap*>(&rSourceBitmap)->GetQImage() + : aRGBABitmap.GetQImage(); aImage = pBitmap->convertToFormat(Qt5_DefaultFormat32); } @@ -556,7 +635,7 @@ bool Qt5Graphics::drawAlphaRect(long nX, long nY, long nWidth, long nHeight, Qt5Painter aPainter(*this, true, nTransparency); if (SALCOLOR_NONE != m_aFillColor) aPainter.fillRect(nX, nY, nWidth, nHeight, aPainter.brush()); - else + if (SALCOLOR_NONE != m_aLineColor) aPainter.drawRect(nX, nY, nWidth, nHeight); aPainter.update(nX, nY, nWidth, nHeight); return true; diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx index cb7bef853ba8..8fb70c820788 100644 --- a/vcl/qt5/Qt5Graphics_Text.cxx +++ b/vcl/qt5/Qt5Graphics_Text.cxx @@ -65,6 +65,7 @@ void Qt5Graphics::GetFontMetric(ImplFontMetricDataRef& rFMD, int nFallbackLevel) rFMD->ImplCalcLineSpacing(rHhea, rOS2, aRawFont.unitsPerEm()); + rFMD->SetSlant( 0 ); rFMD->SetWidth(aRawFont.averageCharWidth()); rFMD->SetMinKashida(m_pTextStyle[nFallbackLevel]->GetKashidaWidth()); @@ -106,6 +107,7 @@ void Qt5Graphics::ClearDevFontCache() {} bool Qt5Graphics::AddTempDevFont(PhysicalFontCollection*, const OUString& /*rFileURL*/, const OUString& /*rFontName*/) { + assert(0 && "Qt5Graphics::AddTempDevFont"); return false; } @@ -122,11 +124,15 @@ const void* Qt5Graphics::GetEmbedFontData(const PhysicalFontFace*, long* /*pData return nullptr; } -void Qt5Graphics::FreeEmbedFontData(const void* /*pData*/, long /*nDataLen*/) {} +void Qt5Graphics::FreeEmbedFontData(const void* /*pData*/, long /*nDataLen*/) +{ + assert(0 && "Qt5Graphics::FreeEmbedFontData"); +} void Qt5Graphics::GetGlyphWidths(const PhysicalFontFace* /*pPFF*/, bool /*bVertical*/, std::vector<sal_Int32>& /*rWidths*/, Ucs2UIntMap& /*rUnicodeEnc*/) { + assert(0 && "Qt5Graphics::GetGlyphWidths"); } bool Qt5Graphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& rRect) @@ -140,16 +146,30 @@ bool Qt5Graphics::GetGlyphBoundRect(const GlyphItem& rGlyph, tools::Rectangle& r return false; QRawFont aRawFont(QRawFont::fromFont(*pFont)); - rRect = toRectangle(aRawFont.boundingRect(rGlyph.maGlyphId).toAlignedRect()); + rRect = toRectangle(aRawFont.boundingRect(rGlyph.maGlyphId).toRect()); return true; } -bool Qt5Graphics::GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) { return false; } +bool Qt5Graphics::GetGlyphOutline(const GlyphItem&, basegfx::B2DPolyPolygon&) +{ + return false; +} + +class Qt5CommonSalLayout : public CommonSalLayout +{ +public: + Qt5CommonSalLayout(LogicalFontInstance& rLFI): CommonSalLayout(rLFI) {} + + void SetOrientation(int nOrientation) + { + mnOrientation = nOrientation; + } +}; std::unique_ptr<SalLayout> Qt5Graphics::GetTextLayout(ImplLayoutArgs&, int nFallbackLevel) { if (m_pTextStyle[nFallbackLevel]) - return std::unique_ptr<SalLayout>(new GenericSalLayout(*m_pTextStyle[nFallbackLevel])); + return std::unique_ptr<SalLayout>(new Qt5CommonSalLayout(*m_pTextStyle[nFallbackLevel])); return std::unique_ptr<SalLayout>(); } @@ -162,6 +182,13 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout) QVector<quint32> glyphIndexes; QVector<QPointF> positions; + // prevent glyph rotation inside the SalLayout + // probably better to add a parameter to GetNextGlyphs? + Qt5CommonSalLayout *pQt5Layout = static_cast<Qt5CommonSalLayout*>(const_cast<CommonSalLayout*>(&rLayout)); + int nOrientation = rLayout.GetOrientation(); + if (nOrientation) + pQt5Layout->SetOrientation(0); + Point aPos; const GlyphItem* pGlyph; int nStart = 0; @@ -171,6 +198,9 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout) positions.push_back(QPointF(aPos.X(), aPos.Y())); } + if (nOrientation) + pQt5Layout->SetOrientation(nOrientation); + QGlyphRun aGlyphRun; aGlyphRun.setPositions(positions); aGlyphRun.setGlyphIndexes(glyphIndexes); @@ -179,6 +209,21 @@ void Qt5Graphics::DrawTextLayout(const GenericSalLayout& rLayout) Qt5Painter aPainter(*this); QColor aColor = toQColor(m_aTextColor); aPainter.setPen(aColor); + + if (nOrientation) + { + // make text position the center of the rotation + // then rotate and move back + QRect window = aPainter.window(); + window.moveTo(-positions[0].x(), -positions[0].y()); + aPainter.setWindow(window); + + QTransform p; + p.rotate(-static_cast<qreal>(nOrientation) / 10.0); + p.translate(-positions[0].x(), -positions[0].y()); + aPainter.setTransform(p); + } + aPainter.drawGlyphRun(QPointF(), aGlyphRun); } diff --git a/vcl/source/font/fontcache.cxx b/vcl/source/font/fontcache.cxx index a58d9b6931f2..333bc8415c08 100644 --- a/vcl/source/font/fontcache.cxx +++ b/vcl/source/font/fontcache.cxx @@ -48,7 +48,7 @@ bool ImplFontCache::IFSD_Equal::operator()(const FontSelectPattern& rA, const Fo return false; // check font face attributes - if( (rA.GetWeight() != rB.GetWeight()) + if( (rA.GetWeight() != rB.GetWeight()) || (rA.GetItalic() != rB.GetItalic()) // || (rA.meFamily != rB.meFamily) // TODO: remove this mostly obsolete member || (rA.GetPitch() != rB.GetPitch()) ) diff --git a/vcl/source/outdev/font.cxx b/vcl/source/outdev/font.cxx index 318b9ffe116a..3e4087b6e4a7 100644 --- a/vcl/source/outdev/font.cxx +++ b/vcl/source/outdev/font.cxx @@ -199,7 +199,7 @@ bool OutputDevice::GetFontFeatures(std::vector<vcl::font::Feature>& rFontFeature FontMetric OutputDevice::GetFontMetric() const { FontMetric aMetric; - if( mbNewFont && !ImplNewFont() ) + if( !ImplNewFont() ) return aMetric; LogicalFontInstance* pFontInstance = mpFontInstance.get(); @@ -262,10 +262,8 @@ bool OutputDevice::GetFontCharMap( FontCharMapRef& rxFontCharMap ) const if( !mpGraphics && !AcquireGraphics() ) return false; - if( mbNewFont ) - ImplNewFont(); - if( mbInitFont ) - InitFont(); + ImplNewFont(); + InitFont(); if( !mpFontInstance ) return false; @@ -287,10 +285,8 @@ bool OutputDevice::GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities if( !mpGraphics && !AcquireGraphics() ) return false; - if( mbNewFont ) - ImplNewFont(); - if( mbInitFont ) - InitFont(); + ImplNewFont(); + InitFont(); if( !mpFontInstance ) return false; @@ -995,28 +991,25 @@ void OutputDevice::ImplInitFontList() const void OutputDevice::InitFont() const { - DBG_TESTSOLARMUTEX(); - - if (!mpFontInstance) + if (!mpFontInstance || !mbInitFont) return; - if ( mbInitFont ) - { - // decide if antialiasing is appropriate - bool bNonAntialiased(GetAntialiasing() & AntialiasingFlags::DisableText); - FontSelectPattern aPattern(mpFontInstance->GetFontSelectPattern()); - if (!utl::ConfigManager::IsFuzzing()) - { - const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); - bNonAntialiased |= bool(rStyleSettings.GetDisplayOptions() & DisplayOptions::AADisable); - bNonAntialiased |= (int(rStyleSettings.GetAntialiasingMinPixelHeight()) > aPattern.mnHeight); - } - aPattern.mbNonAntialiased = bNonAntialiased; + DBG_TESTSOLARMUTEX(); - // select font in the device layers - mpGraphics->SetFont(&aPattern, 0); - mbInitFont = false; + // decide if antialiasing is appropriate + bool bNonAntialiased(GetAntialiasing() & AntialiasingFlags::DisableText); + FontSelectPattern aPattern(mpFontInstance->GetFontSelectPattern()); + if (!utl::ConfigManager::IsFuzzing()) + { + const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings(); + bNonAntialiased |= bool(rStyleSettings.GetDisplayOptions() & DisplayOptions::AADisable); + bNonAntialiased |= (int(rStyleSettings.GetAntialiasingMinPixelHeight()) > aPattern.mnHeight); } + aPattern.mbNonAntialiased = bNonAntialiased; + + // select font in the device layers + mpGraphics->SetFont(&aPattern, 0); + mbInitFont = false; } bool OutputDevice::ImplNewFont() const @@ -1055,7 +1048,7 @@ bool OutputDevice::ImplNewFont() const aSize.setHeight( 1 ); else aSize.setHeight( (12*mnDPIY)/72 ); - fExactHeight = static_cast<float>(aSize.Height()); + fExactHeight = static_cast<float>(aSize.Height()); } // select the default width only when logical width is zero @@ -1076,9 +1069,10 @@ bool OutputDevice::ImplNewFont() const return false; } - // mark when lower layers need to get involved mbNewFont = false; - if( bNewFontInstance ) + + // mark when lower layers need to get involved + if( pFontInstance != pOldFontInstance ) mbInitFont = true; // select font when it has not been initialized yet @@ -1120,14 +1114,13 @@ bool OutputDevice::ImplNewFont() const } // calculate text offset depending on TextAlignment - TextAlign eAlign = maFont.GetAlignment(); - if ( eAlign == ALIGN_BASELINE ) + switch (maFont.GetAlignment()) { + case ALIGN_BASELINE: mnTextOffX = 0; mnTextOffY = 0; - } - else if ( eAlign == ALIGN_TOP ) - { + break; + case ALIGN_TOP: mnTextOffX = 0; mnTextOffY = +pFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent; if ( pFontInstance->mnOrientation ) @@ -1135,9 +1128,8 @@ bool OutputDevice::ImplNewFont() const Point aOriginPt(0, 0); aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontInstance->mnOrientation ); } - } - else // eAlign == ALIGN_BOTTOM - { + break; + case ALIGN_BOTTOM: mnTextOffX = 0; mnTextOffY = -pFontInstance->mxFontMetric->GetDescent() + mnEmphasisDescent; if ( pFontInstance->mnOrientation ) @@ -1145,6 +1137,10 @@ bool OutputDevice::ImplNewFont() const Point aOriginPt(0, 0); aOriginPt.RotateAround( mnTextOffX, mnTextOffY, pFontInstance->mnOrientation ); } + break; + case TextAlign_FORCE_EQUAL_SIZE: + assert( 0 && "TextAlign_FORCE_EQUAL_SIZE not implemented for new fonts" ); + break; } mbTextLines = ((maFont.GetUnderline() != LINESTYLE_NONE) && (maFont.GetUnderline() != LINESTYLE_DONTKNOW)) || @@ -1427,7 +1423,7 @@ std::unique_ptr<SalLayout> OutputDevice::ImplGlyphFallbackLayout( std::unique_pt long OutputDevice::GetMinKashida() const { - if( mbNewFont && !ImplNewFont() ) + if( !ImplNewFont() ) return 0; return ImplDevicePixelToLogicWidth( mpFontInstance->mxFontMetric->GetMinKashida() ); commit ee2bc3c5750b0029d253e918a95e7287edab72ca Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Fri Apr 13 09:04:56 2018 +0200 Header comment Change-Id: I641da593df5a1fa2964b3e01f5d323edf73c6721 diff --git a/vcl/inc/fontselect.hxx b/vcl/inc/fontselect.hxx index efb88ad74ae1..fd453a0d5f54 100644 --- a/vcl/inc/fontselect.hxx +++ b/vcl/inc/fontselect.hxx @@ -59,7 +59,7 @@ public: int mnWidth; // width of font in pixel units int mnHeight; // height of font in pixel units float mfExactHeight; // requested height (in pixels with subpixel details) - int mnOrientation; // text orientation in 3600 system + int mnOrientation; // text orientation in 1/10 degree (0-3600) LanguageType meLanguage; // text language bool mbVertical; // vertical mode of requested font bool mbNonAntialiased; // true if antialiasing is disabled commit 1fd44bd48ea05539b12f92b78054b706d2ccf9d3 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Mon Mar 12 09:56:18 2018 +0100 Qt5 fix font drawing The main problem was the memory management of the harfbuzz memory blob. Now we copy the font data tables into the blob, as the QByteArray memory will be freed at the end of the function. Change-Id: If5a5a4b1a235e66ba472b28a156e16be1b82bf2e diff --git a/vcl/qt5/Qt5Tools.hxx b/vcl/qt5/Qt5Tools.hxx new file mode 100644 index 000000000000..c7b47014beb0 --- /dev/null +++ b/vcl/qt5/Qt5Tools.hxx @@ -0,0 +1,112 @@ +/* -*- 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 <QtCore/QString> +#include <QtCore/QRect> +#include <QtCore/QSize> +#include <QtGui/QImage> + +#include <rtl/string.hxx> +#include <rtl/ustring.hxx> +#include <tools/gen.hxx> + +#include <memory> + +inline OUString toOUString(const QString& s) +{ + // QString stores UTF16, just like OUString + return OUString(reinterpret_cast<const sal_Unicode*>(s.data()), s.length()); +} + +inline QString toQString(const OUString& s) +{ + return QString::fromUtf16(reinterpret_cast<ushort const*>(s.getStr()), s.getLength()); +} + +inline QRect toQRect(const tools::Rectangle& rRect) +{ + return QRect(rRect.Left(), rRect.Top(), rRect.GetWidth(), rRect.GetHeight()); +} + +inline tools::Rectangle toRectangle(const QRect& rRect) +{ + return tools::Rectangle(rRect.left(), rRect.top(), rRect.width(), rRect.height()); +} + +inline QSize toQSize(const Size& rSize) { return QSize(rSize.Width(), rSize.Height()); } + +inline Size toSize(const QSize& rSize) { return Size(rSize.width(), rSize.height()); } + +static constexpr QImage::Format Qt5_DefaultFormat32 = QImage::Format_ARGB32; + +inline QImage::Format getBitFormat(sal_uInt16 nBitCount) +{ + switch (nBitCount) + { + case 1: + return QImage::Format_Mono; + case 8: + return QImage::Format_Indexed8; + case 16: + return QImage::Format_RGB16; + case 24: + return QImage::Format_RGB888; + case 32: + return Qt5_DefaultFormat32; + default: + std::abort(); + break; + } + return QImage::Format_Invalid; +} + +inline sal_uInt16 getFormatBits(QImage::Format eFormat) +{ + switch (eFormat) + { + case QImage::Format_Mono: + return 1; + case QImage::Format_Indexed8: + return 8; + case QImage::Format_RGB16: + return 16; + case QImage::Format_RGB888: + return 24; + case Qt5_DefaultFormat32: + return 32; + default: + std::abort(); + return 0; + } +} + +typedef struct _cairo_surface cairo_surface_t; +struct CairoDeleter +{ + void operator()(cairo_surface_t* pSurface) const; +}; + +typedef std::unique_ptr<cairo_surface_t, CairoDeleter> UniqueCairoSurface; + +sal_uInt16 GetKeyModCode(Qt::KeyboardModifiers eKeyModifiers); +sal_uInt16 GetMouseModCode(Qt::MouseButtons eButtons); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index eb3260bdbdc9..e77ac7890673 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -259,9 +259,6 @@ bool GenericSalLayout::HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aVariationS bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs) { - hb_font_t *pHbFont = mpFont->GetHbFont(); - hb_face_t* pHbFace = hb_font_get_face(pHbFont); - int nGlyphCapacity = 2 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos); m_GlyphItems.reserve(nGlyphCapacity); @@ -301,6 +298,8 @@ bool GenericSalLayout::LayoutText(ImplLayoutArgs& rArgs) mpFont->GetScale(&nXScale, &nYScale); Point aCurrPos(0, 0); + hb_font_t *pHbFont = mpFont->GetHbFont(); + hb_face_t *pHbFace = hb_font_get_face(pHbFont); while (true) { int nBidiMinRunPos, nBidiEndRunPos; commit 8b68ec4ac4d3477c7c6f177eaefccdf7780b36fd Author: Thorsten Behrens <thorsten.behr...@cib.de> Date: Thu Mar 1 14:57:58 2018 +0100 WaE: -Wunused-variable Change-Id: I58f012ddc2c5030b0e3e215b9cab4e89abf06c2b diff --git a/vcl/inc/unx/x11_cursors/null_curs.h b/vcl/inc/unx/x11_cursors/null_curs.h index d74b462cba9b..ebeee4e6ffc5 100644 --- a/vcl/inc/unx/x11_cursors/null_curs.h +++ b/vcl/inc/unx/x11_cursors/null_curs.h @@ -20,6 +20,5 @@ #define nullcurs_height 4 #define nullcurs_x_hot 2 #define nullcurs_y_hot 2 -static unsigned char nullcurs_bits[] = { 0x00, 0x00, 0x00, 0x00 }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/unx/x11_cursors/null_mask.h b/vcl/inc/unx/x11_cursors/null_mask.h index bc23e9c9729b..71f08a94afcf 100644 --- a/vcl/inc/unx/x11_cursors/null_mask.h +++ b/vcl/inc/unx/x11_cursors/null_mask.h @@ -18,6 +18,5 @@ */ #define nullmask_width 4 #define nullmask_height 4 -static unsigned char nullmask_bits[] = { 0x00, 0x00, 0x00, 0x00 }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index dff49c8e8b7c..ddce3f81da27 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -1494,6 +1494,9 @@ KeySym SalDisplay::GetKeySym( XKeyEvent *pEvent, } // Pointer +static unsigned char nullmask_bits[] = { 0x00, 0x00, 0x00, 0x00 }; +static unsigned char nullcurs_bits[] = { 0x00, 0x00, 0x00, 0x00 }; + #define MAKE_BITMAP( name ) \ XCreateBitmapFromData( pDisp_, \ DefaultRootWindow( pDisp_ ), \ diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx index 7c9a3d1e0fbc..689fa071ce5b 100644 --- a/vcl/unx/gtk/gtkdata.cxx +++ b/vcl/unx/gtk/gtkdata.cxx @@ -245,6 +245,9 @@ GdkCursor* GtkSalDisplay::getFromXBM( const unsigned char *pBitmap, &aBlack, &aWhite, nXHot, nYHot); } +static unsigned char nullmask_bits[] = { 0x00, 0x00, 0x00, 0x00 }; +static unsigned char nullcurs_bits[] = { 0x00, 0x00, 0x00, 0x00 }; + #define MAKE_CURSOR( vcl_name, name ) \ case vcl_name: \ pCursor = getFromXBM( name##curs##_bits, name##mask##_bits, \ diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx index fd5b47f0b626..024dac2a5014 100644 --- a/vcl/unx/gtk3/gtk3gtkdata.cxx +++ b/vcl/unx/gtk3/gtk3gtkdata.cxx @@ -213,7 +213,10 @@ GdkCursor* GtkSalDisplay::getFromXBM( const unsigned char *pBitmap, return cursor; } -#define MAKE_CURSOR( vcl_name, name ) \ +static unsigned char nullmask_bits[] = { 0x00, 0x00, 0x00, 0x00 }; +static unsigned char nullcurs_bits[] = { 0x00, 0x00, 0x00, 0x00 }; + +#define MAKE_CURSOR( vcl_name, name ) \ case vcl_name: \ pCursor = getFromXBM( name##curs##_bits, name##mask##_bits, \ name##curs_width, name##curs_height, \ commit 1b6031423c39afba57c6d67c098ac49e1e22a303 Author: Jan-Marek Glogowski <glo...@fbihome.de> Date: Wed Jul 4 08:12:05 2018 +0000 Add font mapping test for Linux Libertine G The vcl_fontfeature test needs a valid "Linux Libertine G" font, not a fallback font like DejaVuSans.ttf. Also fixes the test to work with spaces in font names. Change-Id: I6acad55c912c2ecab4b17ac7ab31021ad22d0cbc Reviewed-on: https://gerrit.libreoffice.org/56928 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/configure.ac b/configure.ac index 3ca4d8e8ab90..bc76475962c9 100644 --- a/configure.ac +++ b/configure.ac @@ -11419,21 +11419,32 @@ TEST_FONTS_MISSING=0 test_font_map() { FONT="$1" ; shift + FONT_LOWER="$(echo "$FONT" | $AWK '{print tolower($0)}')" AC_MSG_CHECKING([font mapping for '$FONT']) FONTFILE="$(basename `$FCMATCH -f '%{file}' "$FONT"`)" - FONTFILE_LOWER="$(echo $FONTFILE | $AWK '{print tolower($0)}')" + FONTFILE_LOWER="$(echo "$FONTFILE" | $AWK '{print tolower($0)}')" - TESTEXPR="'${FONTFILE_LOWER}' = '$(echo $FONT | $AWK '{print tolower($0)}').ttf'" - while test "$#" -ge 1 ; do - MAPPING="$(echo $1 | $AWK '{print tolower($0)}')"; shift - TESTEXPR="${TESTEXPR} -o '${FONTFILE_LOWER}' = '$MAPPING-regular.ttf'" - done - if test $TESTEXPR + CURRENT_FONT_FOUND=0 + if test "${FONTFILE_LOWER}" = "${FONT_LOWER}".ttf + then + CURRENT_FONT_FOUND=1 + else + while test "$#" -ge 1 ; do + MAPPING_LOWER="$(echo "$1" | $AWK '{print tolower($0)}')"; shift + if test \( "${FONTFILE_LOWER}" = "${MAPPING_LOWER}"-regular.ttf \) -o \ + \( "${FONTFILE_LOWER}" = "${MAPPING_LOWER}".ttf \) + then + CURRENT_FONT_FOUND=1 + break + fi + done + fi + if test $CURRENT_FONT_FOUND -eq 1 then AC_MSG_RESULT([ok]) else - AC_MSG_WARN([unknown ($FONTFILE)]) - add_warning "unknown ($FONTFILE)" + AC_MSG_RESULT([unknown map '$FONTFILE']) + add_warning "unkonwn map '$FONTFILE' for '$FONT'" TEST_FONTS_MISSING=1 fi } @@ -11459,6 +11470,7 @@ else else test_font_map 'Calibri' 'Carlito' test_font_map 'DejaVuSans' 'DejaVuSans' + test_font_map 'Linux Libertine G' 'LinLibertine_R_G' if test ${TEST_FONTS_MISSING} -eq 1 then AC_MSG_WARN([Unknown font mappings - unit tests disabled.]) commit 67c20d4a02c55bd1749f7cdacd8a56df9c370d98 Author: Mike Kaganski <mike.kagan...@collabora.com> Date: Tue Jul 3 21:38:48 2018 +1000 Avoid failing assert in SwDBManager::MergeMailFiles The failing assert reproducing scenario is the steps in https://bugs.documentfoundation.org/show_bug.cgi?id=116543#c0 rMergeDescriptor.nMergeType == DBMGR_MERGE_PRINTER; rMergeDescriptor.bPrefixIsFilename is true; rMergeDescriptor.sPrefix is empty. The failing assert is unrelated to the crash in tdf#116543. It looks like the assertion was incorrect; assert on empty prefix instead. Change-Id: Ibeedb90a9fac810124283fc06aa756777fa04720 Reviewed-on: https://gerrit.libreoffice.org/56863 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 8b045595d2c3..90499f74dd59 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -1153,6 +1153,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, const bool bIsMergeSilent = IsMergeSilent(); bool bCheckSingleFile_ = rMergeDescriptor.bCreateSingleFile; + OUString sPrefix_ = rMergeDescriptor.sPrefix; if( bMT_EMAIL ) { assert( !rMergeDescriptor.bPrefixIsFilename ); @@ -1161,11 +1162,13 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, } else if( bMT_SHELL || bMT_PRINTER ) { - assert( !rMergeDescriptor.bPrefixIsFilename ); assert(bCheckSingleFile_); bCheckSingleFile_ = true; + assert(sPrefix_.isEmpty()); + sPrefix_.clear(); } const bool bCreateSingleFile = bCheckSingleFile_; + const OUString sDescriptorPrefix = sPrefix_; // Setup for dumping debugging documents static const char *sMaxDumpDocs = nullptr; @@ -1388,7 +1391,7 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, // create a new temporary file name - only done once in case of bCreateSingleFile if( bNeedsTempFiles && ( !bWorkDocInitialized || !bCreateSingleFile )) { - OUString sPrefix = rMergeDescriptor.sPrefix; + OUString sPrefix = sDescriptorPrefix; OUString sLeading; //#i97667# if the name is from a database field then it will be used _as is_ @@ -1634,11 +1637,11 @@ bool SwDBManager::MergeMailFiles(SwWrtShell* pSourceShell, // save merged document assert( aTempFile.get() ); INetURLObject aTempFileURL; - if( rMergeDescriptor.sPrefix.isEmpty() || !rMergeDescriptor.bPrefixIsFilename ) + if (sDescriptorPrefix.isEmpty() || !rMergeDescriptor.bPrefixIsFilename) aTempFileURL.SetURL( aTempFile->GetURL() ); else { - aTempFileURL.SetURL( rMergeDescriptor.sPrefix ); + aTempFileURL.SetURL(sDescriptorPrefix); // remove the unneeded temporary file aTempFile->EnableKillingFile(); } commit c90312c6d61bfa43c70c9acf1093edd731c5f02a Author: Luboš Luňák <l.lu...@collabora.com> Date: Thu Jun 28 04:10:52 2018 +0200 add --enable-gdb-index for --gdb-index from gold/lld https://lists.freedesktop.org/archives/libreoffice/2018-June/080437.html Change-Id: I66904333bf329e804025d4b229a0db573e21c3af Reviewed-on: https://gerrit.libreoffice.org/56566 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/config_host.mk.in b/config_host.mk.in index 0bc686e916da..e53c9a12f8b0 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -130,6 +130,7 @@ export ENABLE_EOT=@ENABLE_EOT@ export ENABLE_EVOAB2=@ENABLE_EVOAB2@ export ENABLE_FIREBIRD_SDBC=@ENABLE_FIREBIRD_SDBC@ export ENABLE_FORMULA_LOGGER=@ENABLE_FORMULA_LOGGER@ +export ENABLE_GDB_INDEX=@ENABLE_GDB_INDEX@ export ENABLE_GIO=@ENABLE_GIO@ export ENABLE_GPGMEPP=@ENABLE_GPGMEPP@ export ENABLE_GSTREAMER_0_10=@ENABLE_GSTREAMER_0_10@ diff --git a/configure.ac b/configure.ac index ebe5d0c5be9b..3ca4d8e8ab90 100644 --- a/configure.ac +++ b/configure.ac @@ -1121,6 +1121,11 @@ libo_FUZZ_ARG_ENABLE(split-debug, [Uses split debug information (-gsplit-dwarf compile flag). Saves disk space and build time, but requires tools that support it (both build tools and debuggers).])) +libo_FUZZ_ARG_ENABLE(gdb-index, + AS_HELP_STRING([--enable-gdb-index], + [Creates debug information in the gdb index format, which makes gdb start faster. + Requires the gold or lld linker.])) + libo_FUZZ_ARG_ENABLE(sal-log, AS_HELP_STRING([--enable-sal-log], [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.])) @@ -3180,6 +3185,31 @@ printf ("hello world\n"); fi AC_SUBST(USE_LD) +ENABLE_GDB_INDEX= +if test "$enable_gdb_index" = "yes"; then + AC_MSG_CHECKING([whether $CC supports -ggnu-pubnames]) + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror -ggnu-pubnames" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ AC_MSG_RESULT( yes )],[ AC_MSG_ERROR( no )]) + + AC_MSG_CHECKING([whether $CC supports -Wl,--gdb-index]) + ldflags_save=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--gdb-index" + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include <stdio.h> + ],[ +printf ("hello world\n"); + ])], ENABLE_GDB_INDEX=TRUE, []) + if test "$ENABLE_GDB_INDEX" = "TRUE"; then + AC_MSG_RESULT( yes ) + else + AC_MSG_ERROR( no ) + fi + CFLAGS=$save_CFLAGS + LDFLAGS=$ldflags_save +fi +AC_SUBST(ENABLE_GDB_INDEX) + HAVE_LD_BSYMBOLIC_FUNCTIONS= if test "$GCC" = "yes"; then AC_MSG_CHECKING([for -Bsymbolic-functions linker support]) diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index c9cbe0d96a54..25bb4bdf6889 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -81,6 +81,12 @@ gb_CXXFLAGS_COMMON := \ gb_CXXFLAGS_Wundef = -Wno-undef +ifeq ($(ENABLE_GDB_INDEX),TRUE) +gb_LinkTarget_LDFLAGS += -Wl,--gdb-index +gb_CFLAGS_COMMON += -ggnu-pubnames +gb_CXXFLAGS_COMMON += -ggnu-pubnames +endif + ifeq ($(strip $(gb_GCOV)),YES) gb_CFLAGS_COMMON += -fprofile-arcs -ftest-coverage gb_CXXFLAGS_COMMON += -fprofile-arcs -ftest-coverage commit d0cb2967aa288852561497537327ebea838ebc9a Author: Luboš Luňák <l.lu...@collabora.com> Date: Mon Jun 25 22:42:56 2018 +0200 add configure option --enable-ld to use GNU gold or LLVM lld https://lists.freedesktop.org/archives/libreoffice/2018-June/080437.html Change-Id: I06214459fcebe5cc58fd7979f3cbe5ac3d97db7d Reviewed-on: https://gerrit.libreoffice.org/56417 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/config_host.mk.in b/config_host.mk.in index acca001c0bcd..0bc686e916da 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -601,6 +601,7 @@ export UCRTSDKDIR=@UCRTSDKDIR@ export UCRTVERSION=@UCRTVERSION@ export UCRT_REDISTDIR=@UCRT_REDISTDIR@ export UNOWINREG_DLL=@UNOWINREG_DLL@ +export USE_LD=@USE_LD@ export USE_LIBRARY_BIN_TAR=@USE_LIBRARY_BIN_TAR@ export USE_XINERAMA=@USE_XINERAMA@ export UPDATE_CONFIG=@UPDATE_CONFIG@ diff --git a/configure.ac b/configure.ac index 12516d80219b..ebe5d0c5be9b 100644 --- a/configure.ac +++ b/configure.ac @@ -1341,6 +1341,11 @@ AC_ARG_ENABLE(icecream, wrappers, you can override that using --with-gcc-home=/the/path switch.]), ,) +AC_ARG_ENABLE(ld, + AS_HELP_STRING([--enable-ld=<linker>], + [Use the specified linker. Both 'gold' and 'lld' linkers generally use less memory and link faster.]), +,) + libo_FUZZ_ARG_ENABLE(cups, AS_HELP_STRING([--disable-cups], [Do not build cups support.]) @@ -3152,6 +3157,29 @@ else fi AC_SUBST(CROSS_COMPILING) +USE_LD= +if test -n "$enable_ld" -a "$enable_ld" != "no"; then + AC_MSG_CHECKING([for -fuse-ld=$enable_ld linker support]) + if test "$GCC" = "yes"; then + ldflags_save=$LDFLAGS + LDFLAGS="$LDFLAGS -fuse-ld=$enable_ld" + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include <stdio.h> + ],[ +printf ("hello world\n"); + ])], USE_LD=$enable_ld, []) + if test -n "$USE_LD"; then + AC_MSG_RESULT( yes ) + LDFLAGS="$ldflags_save -fuse-ld=$enable_ld" + else + AC_MSG_ERROR( no ) + fi + else + AC_MSG_ERROR( not supported ) + fi +fi +AC_SUBST(USE_LD) + HAVE_LD_BSYMBOLIC_FUNCTIONS= if test "$GCC" = "yes"; then AC_MSG_CHECKING([for -Bsymbolic-functions linker support]) diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index da9440cfeb3d..c9cbe0d96a54 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -35,6 +35,10 @@ else gb_AR := $(shell $(CC) -print-prog-name=ar) endif +ifneq ($(USE_LD),) +gb_LinkTarget_LDFLAGS += -fuse-ld=$(USE_LD) +endif + ifeq ($(strip $(gb_COMPILEROPTFLAGS)),) gb_COMPILEROPTFLAGS := -O2 endif commit 0654030f98355f105ddc741147fc0ff03ab0d906 Author: Luboš Luňák <l.lu...@collabora.com> Date: Thu Jun 21 15:37:25 2018 +0200 add --enable-split-debug for -gsplit-dwarf https://lists.freedesktop.org/archives/libreoffice/2018-June/080437.html Change-Id: I2a02e23e46d7a54083249408f09fba87932b1d44 Reviewed-on: https://gerrit.libreoffice.org/56416 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/config_host.mk.in b/config_host.mk.in index c104f07cb1eb..acca001c0bcd 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -248,6 +248,7 @@ export HAVE_GCC_FNO_ENFORCE_EH_SPECS=@HAVE_GCC_FNO_ENFORCE_EH_SPECS@ export HAVE_GCC_FNO_INLINE=@HAVE_GCC_FNO_INLINE@ export HAVE_GCC_FNO_SIZED_DEALLOCATION=@HAVE_GCC_FNO_SIZED_DEALLOCATION@ export HAVE_GCC_GGDB2=@HAVE_GCC_GGDB2@ +export HAVE_GCC_SPLIT_DWARF=@HAVE_GCC_SPLIT_DWARF@ export HAVE_GNUMAKE_FILE_FUNC=@HAVE_GNUMAKE_FILE_FUNC@ export HAVE_GPGCONF_SOCKETDIR=@HAVE_GPGCONF_SOCKETDIR@ export HAVE_LD_BSYMBOLIC_FUNCTIONS=@HAVE_LD_BSYMBOLIC_FUNCTIONS@ diff --git a/configure.ac b/configure.ac index c8d18b18fde8..12516d80219b 100644 --- a/configure.ac +++ b/configure.ac @@ -1116,6 +1116,11 @@ libo_FUZZ_ARG_ENABLE(debug, [Include debugging information, disable compiler optimization and inlining plus extra debugging code like assertions. Extra large build! (enables -g compiler flag).])) +libo_FUZZ_ARG_ENABLE(split-debug, + AS_HELP_STRING([--enable-split-debug], + [Uses split debug information (-gsplit-dwarf compile flag). Saves disk space and build time, + but requires tools that support it (both build tools and debuggers).])) + libo_FUZZ_ARG_ENABLE(sal-log, AS_HELP_STRING([--enable-sal-log], [Make SAL_INFO and SAL_WARN calls do something even in a non-debug build.])) @@ -3864,6 +3869,23 @@ else fi AC_SUBST(ENABLE_DEBUG) +if test "$enable_split_debug" = yes; then + HAVE_GSPLIT_DWARF= + if test "$GCC" = "yes"; then + AC_MSG_CHECKING([whether $CC supports -gsplit-dwarf]) + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -Werror -gsplit-dwarf" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ return 0; ]])],[ HAVE_GCC_SPLIT_DWARF=TRUE ],[]) + CFLAGS=$save_CFLAGS + if test "$HAVE_GCC_SPLIT_DWARF" = "TRUE"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + fi + AC_SUBST(HAVE_GCC_SPLIT_DWARF) +fi + if test "$enable_sal_log" = yes; then ENABLE_SAL_LOG=TRUE fi diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk index cbc9499d6eb8..add0655498b0 100644 --- a/solenv/gbuild/LinkTarget.mk +++ b/solenv/gbuild/LinkTarget.mk @@ -543,22 +543,31 @@ $(WORKDIR)/Clean/LinkTarget/% : RESPONSEFILE=$(call var2file,$(shell $(gb_MKTEMP)),200,\ $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ $(foreach object,$(COBJECTS),$(call gb_CObject_get_dep_target,$(object))) \ + $(foreach object,$(COBJECTS),$(call gb_CObject_get_dwo_target,$(object))) \ $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dep_target,$(object))) \ + $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_dwo_target,$(object))) \ $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_target,$(object))) \ $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dep_target,$(object))) \ + $(foreach object,$(OBJCOBJECTS),$(call gb_ObjCObject_get_dwo_target,$(object))) \ $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \ $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dep_target,$(object))) \ + $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_dwo_target,$(object))) \ $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_target,$(object))) \ $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dep_target,$(object))) \ + $(foreach object,$(CXXCLROBJECTS),$(call gb_CxxClrObject_get_dwo_target,$(object))) \ $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \ $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dep_target,$(object))) \ + $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_dwo_target,$(object))) \ $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \ $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dep_target,$(object))) \ + $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_dwo_target,$(object))) \ $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dep_target,$(object))) \ + $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_dwo_target,$(object))) \ $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_target,$(object))) \ $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_dep_target,$(object))) \ + $(foreach object,$(GENCXXCLROBJECTS),$(call gb_GenCxxClrObject_get_dwo_target,$(object))) \ $(call gb_LinkTarget_get_target,$(LINKTARGET)) \ $(call gb_LinkTarget_get_dep_target,$(LINKTARGET)) \ $(call gb_LinkTarget_get_headers_target,$(LINKTARGET)) \ diff --git a/solenv/gbuild/TargetLocations.mk b/solenv/gbuild/TargetLocations.mk index 7f658d9c608c..a2e51cbd0447 100644 --- a/solenv/gbuild/TargetLocations.mk +++ b/solenv/gbuild/TargetLocations.mk @@ -38,8 +38,11 @@ gb_AllLangHelp_get_helpfiles_target = $(WORKDIR)/AllLangHelp/$(1).helpfiles gb_AllLangPackage_get_target = $(WORKDIR)/AllLangPackage/$(1) gb_AllLangMoTarget_get_target = $(WORKDIR)/AllLangMo/$(1) gb_AsmObject_get_target = $(WORKDIR)/AsmObject/$(1).o +gb_AsmObject_get_dwo_target = $(WORKDIR)/AsmObject/$(1).dwo gb_CObject_get_target = $(WORKDIR)/CObject/$(1).o +gb_CObject_get_dwo_target = $(WORKDIR)/CObject/$(1).dwo gb_GenCObject_get_target = $(WORKDIR)/GenCObject/$(1).o +gb_GenCObject_get_dwo_target = $(WORKDIR)/GenCObject/$(1).dwo gb_CliAssembly_get_target = $(WORKDIR)/CliAssembly/$(1).done gb_CliAssemblyTarget_get_target = $(WORKDIR)/CliAssemblyTarget/$(1).done gb_CliAssemblyTarget_get_assembly_target = $(WORKDIR)/CliAssemblyTarget/$(1)$(gb_CliAssemblyTarget_POLICYEXT) @@ -57,7 +60,9 @@ gb_CustomTarget_get_workdir = $(WORKDIR)/CustomTarget/$(1) gb_DescriptionTranslateTarget_get_target = $(WORKDIR)/DescriptionTranslateTarget/$(1).xml gb_Dictionary_get_target = $(WORKDIR)/Dictionary/$(1).done gb_CxxObject_get_target = $(WORKDIR)/CxxObject/$(1).o +gb_CxxObject_get_dwo_target = $(WORKDIR)/CxxObject/$(1).dwo gb_GenCxxObject_get_target = $(WORKDIR)/GenCxxObject/$(1).o +gb_GenCxxObject_get_dwo_target = $(WORKDIR)/GenCxxObject/$(1).dwo gb_Executable_get_headers_target = $(WORKDIR)/Headers/Executable/$(1) gb_Executable_get_runtime_target = $(WORKDIR_FOR_BUILD)/Executable/$(1).run gb_Extension_get_target = $(WORKDIR)/Extension/$(1).oxt @@ -127,9 +132,13 @@ gb_Module_get_perfcheck_target = $(WORKDIR)/Module/perfcheck/$(1) gb_Module_get_uicheck_target = $(WORKDIR)/Module/uicheck/$(1) gb_Module_get_target = $(WORKDIR)/Module/$(1) gb_ObjCxxObject_get_target = $(WORKDIR)/ObjCxxObject/$(1).o +gb_ObjCxxObject_get_dwo_target = $(WORKDIR)/ObjCxxObject/$(1).dwo gb_ObjCObject_get_target = $(WORKDIR)/ObjCObject/$(1).o +gb_ObjCObject_get_dwo_target = $(WORKDIR)/ObjCObject/$(1).dwo gb_CxxClrObject_get_target = $(WORKDIR)/CxxClrObject/$(1).o +gb_CxxClrObject_get_dwo_target = $(WORKDIR)/CxxClrObject/$(1).dwo gb_GenCxxClrObject_get_target = $(WORKDIR)/GenCxxClrObject/$(1).o +gb_GenCxxClrObject_get_dwo_target = $(WORKDIR)/GenCxxClrObject/$(1).dwo gb_Pagein_get_target = $(WORKDIR)/Pagein/pagein-$(1) gb_Package_get_preparation_target = $(WORKDIR)/Package/prepared/$(1) gb_Package_get_target = $(WORKDIR)/Package/$(1).filelist diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index 64068b3ffd2c..da9440cfeb3d 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -188,6 +188,10 @@ else gb_DEBUGINFO_FLAGS=-g2 endif +ifeq ($(HAVE_GCC_SPLIT_DWARF),TRUE) +gb_DEBUGINFO_FLAGS+=-gsplit-dwarf +endif + ifeq ($(HAVE_GCC_FINLINE_LIMIT),TRUE) FINLINE_LIMIT0=-finline-limit=0 endif commit 44137151dfd719ed921aece504eb11c5e098492c Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Jul 4 13:49:05 2018 +0200 simplify ScChartListenerCollection listener management Change-Id: I95961bc77b5f07c9eb57675ce2cada79fec4a2e2 Reviewed-on: https://gerrit.libreoffice.org/56942 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/core/tool/chartlis.cxx b/sc/source/core/tool/chartlis.cxx index 6c853fcb2166..06d1f36c0fe3 100644 --- a/sc/source/core/tool/chartlis.cxx +++ b/sc/source/core/tool/chartlis.cxx @@ -477,60 +477,31 @@ void ScChartListenerCollection::ChangeListening( const OUString& rName, pCL->StartListeningTo(); } -namespace { - -class InsertChartListener -{ - ScChartListenerCollection::ListenersType& mrListeners; -public: - explicit InsertChartListener(ScChartListenerCollection::ListenersType& rListeners) : - mrListeners(rListeners) {} - - void operator() (ScChartListener* p) - { - OUString aName = p->GetName(); - mrListeners.insert(std::make_pair(aName, std::unique_ptr<ScChartListener>(p))); - } -}; - -} - void ScChartListenerCollection::FreeUnused() { if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING) meModifiedDuringUpdate = SC_CLCUPDATE_MODIFIED; - ListenersType aUsed, aUnused; + ListenersType aUsed; - // First, filter each listener into 'used' and 'unused' categories. + for (auto & pair : m_Listeners) { - while (!m_Listeners.empty()) + ScChartListener* p = pair.second.get(); + if (p->IsUno()) { - std::unique_ptr<ScChartListener> p(std::move(m_Listeners.begin()->second)); - if (p->IsUno()) - { - // We don't delete UNO charts; they are to be deleted separately via FreeUno(). - aUsed.insert(std::make_pair(m_Listeners.begin()->first, std::move(p))); - m_Listeners.erase(m_Listeners.begin()); - continue; - } - - if (p->IsUsed()) - { - p->SetUsed(false); - aUsed.insert(std::make_pair(m_Listeners.begin()->first, std::move(p))); - m_Listeners.erase(m_Listeners.begin()); - } - else - { - aUnused.insert(std::make_pair(m_Listeners.begin()->first, std::move(p))); - m_Listeners.erase(m_Listeners.begin()); - } + // We don't delete UNO charts; they are to be deleted separately via FreeUno(). + aUsed.insert(std::make_pair(pair.first, std::move(pair.second))); + continue; + } + if (p->IsUsed()) + { + p->SetUsed(false); + aUsed.insert(std::make_pair(pair.first, std::move(pair.second))); } } - std::swap(aUsed, m_Listeners); + m_Listeners = std::move(aUsed); } void ScChartListenerCollection::FreeUno( const uno::Reference< chart::XChartDataChangeEventListener >& rListener, @@ -539,33 +510,14 @@ void ScChartListenerCollection::FreeUno( const uno::Reference< chart::XChartData if (meModifiedDuringUpdate == SC_CLCUPDATE_RUNNING) meModifiedDuringUpdate = SC_CLCUPDATE_MODIFIED; - std::vector<ScChartListener*> aUsed, aUnused; - - // First, filter each listener into 'used' and 'unused' categories. - { - for (auto const& it : m_Listeners) - { - ScChartListener *const p = it.second.get(); - if (p->IsUno() && p->GetUnoListener() == rListener && p->GetUnoSource() == rSource) - aUnused.push_back(p); - else - aUsed.push_back(p); - } - } - - // Release all pointers currently managed by the ptr_map container. - // coverity[leaked_storage] - no leak, because we will take care of them below - for (auto & it : m_Listeners) + for (auto it = m_Listeners.begin(); it != m_Listeners.end(); ) { - it.second.release(); + ScChartListener *const p = it->second.get(); + if (p->IsUno() && p->GetUnoListener() == rListener && p->GetUnoSource() == rSource) + it = m_Listeners.erase(it); + else + ++it; } - m_Listeners.clear(); - - // Re-insert the listeners we need to keep. - std::for_each(aUsed.begin(), aUsed.end(), InsertChartListener(m_Listeners)); - - // Now, delete the ones no longer needed. - std::for_each(aUnused.begin(), aUnused.end(), std::default_delete<ScChartListener>()); } void ScChartListenerCollection::StartTimer() commit e73825ea4b12cc62caa95faa902bfc9ebb48f58a Author: Luboš Luňák <l.lu...@collabora.com> Date: Sat Jun 30 03:35:49 2018 +0200 drop usage of --dynamic-list-cpp-new/typeinfo First of all, lld doesn't have these options, but there doesn't seem to be any point in using them anyway. They are supposed to block the effect of -Bsymbolic-functions, but: - --dynamic-list-cpp-new matters only if we'd create our own global operator new/delete, which we don't - --dynamic-list-cpp-typeinfo affects only the typeinfo (_ZTI*) and typeinfo name (_ZTS*) symbols, which are not functions, and so -Bsymbolic-functions shouldn't do anything with them. According to https://sourceware.org/bugzilla/show_bug.cgi?id=3831 my understanding is that --dynamic-list-cpp-typeinfo actually predates -Bsymbolic-functions and it was an attempt to do the same from the other direction ('bind locally everything except for this' instead of 'bind locally only functions'). Change-Id: Iadad2d78f32a2adfb9c2100fb4eb5abe75725545 Reviewed-on: https://gerrit.libreoffice.org/56739 Reviewed-by: Luboš Luňák <l.lu...@collabora.com> Tested-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/configure.ac b/configure.ac index bf2c8fbf5570..c8d18b18fde8 100644 --- a/configure.ac +++ b/configure.ac @@ -3151,7 +3151,7 @@ HAVE_LD_BSYMBOLIC_FUNCTIONS= if test "$GCC" = "yes"; then AC_MSG_CHECKING([for -Bsymbolic-functions linker support]) bsymbolic_functions_ldflags_save=$LDFLAGS - LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions -Wl,--dynamic-list-cpp-new -Wl,--dynamic-list-cpp-typeinfo" + LDFLAGS="$LDFLAGS -Wl,-Bsymbolic-functions" AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include <stdio.h> ],[ diff --git a/external/icu/ExternalProject_icu.mk b/external/icu/ExternalProject_icu.mk index e1ec30938bf7..1e94eef0fd5e 100644 --- a/external/icu/ExternalProject_icu.mk +++ b/external/icu/ExternalProject_icu.mk @@ -54,8 +54,7 @@ icu_LDFLAGS:=" \ $(if $(ENABLE_LTO),$(gb_LTOFLAGS)) \ $(if $(filter TRUE,$(HAVE_LD_HASH_STYLE)),-Wl$(COMMA)--hash-style=$(WITH_LINKER_HASH_STYLE)) \ $(if $(SYSBASE),-L../lib -L../../lib -L../stubdata -L../../stubdata -L$(SYSBASE)/usr/lib) \ - $(if $(filter TRUE,$(HAVE_LD_BSYMBOLIC_FUNCTIONS)),\ - -Wl$(COMMA)-Bsymbolic-functions -Wl$(COMMA)--dynamic-list-cpp-new -Wl$(COMMA)--dynamic-list-cpp-typeinfo) \ + $(if $(filter TRUE,$(HAVE_LD_BSYMBOLIC_FUNCTIONS)), -Wl$(COMMA)-Bsymbolic-functions) \ $(if $(filter ANDROID,$(OS)),$(gb_STDLIBS))" # DATASUBDIR=data in cross-compiling case, because --disable-tools completely skips the diff --git a/solenv/gbuild/platform/solaris.mk b/solenv/gbuild/platform/solaris.mk index 2210d4f972d1..88fa9413f726 100644 --- a/solenv/gbuild/platform/solaris.mk +++ b/solenv/gbuild/platform/solaris.mk @@ -81,11 +81,7 @@ gb_LinkTarget_LDFLAGS += \ endif ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),) -gb_LinkTarget_LDFLAGS += \ - -Wl,--dynamic-list-cpp-new \ - -Wl,--dynamic-list-cpp-typeinfo \ - -Wl,-Bsymbolic-functions \ - +gb_LinkTarget_LDFLAGS += -Wl,-Bsymbolic-functions endif # sun ld doesn't understand -O1 optimize flag diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index 8505f9638a19..79144b19763b 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -75,11 +75,7 @@ gb_LinkTarget_LDFLAGS += \ endif ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),) -gb_LinkTarget_LDFLAGS += \ - -Wl,--dynamic-list-cpp-new \ - -Wl,--dynamic-list-cpp-typeinfo \ - -Wl,-Bsymbolic-functions \ - +gb_LinkTarget_LDFLAGS += -Wl,-Bsymbolic-functions endif ifneq ($(gb_DEBUGLEVEL),0) commit f0d007b7b70e2845df082d11f023e4fca9ac947f Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Jul 4 13:53:15 2018 +0200 loplugin:useuniqueptr in ScDPDataDimension Change-Id: I74d6fd6a291d518c26180836706e4195f1144c8f Reviewed-on: https://gerrit.libreoffice.org/56944 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx index f57816dcb080..d4d14d735156 100644 --- a/sc/inc/dptabres.hxx +++ b/sc/inc/dptabres.hxx @@ -614,7 +614,7 @@ class ScDPDataDimension private: const ScDPResultData* pResultData; const ScDPResultDimension* pResultDimension; // column - ScDPDataMembers maMembers; + std::vector<std::unique_ptr<ScDPDataMember>> maMembers; bool bIsDataLayout; //! or ptr to IntDimension? public: diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index df38649bcfcc..d99c0d493c28 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -3534,7 +3534,6 @@ ScDPDataDimension::ScDPDataDimension( const ScDPResultData* pData ) : ScDPDataDimension::~ScDPDataDimension() { - std::for_each(maMembers.begin(), maMembers.end(), std::default_delete<ScDPDataMember>()); } void ScDPDataDimension::InitFrom( const ScDPResultDimension* pDim ) @@ -3553,7 +3552,7 @@ void ScDPDataDimension::InitFrom( const ScDPResultDimension* pDim ) const ScDPResultMember* pResMem = pDim->GetMember(i); ScDPDataMember* pNew = new ScDPDataMember( pResultData, pResMem ); - maMembers.push_back( pNew); + maMembers.emplace_back( pNew); if ( !pResultData->IsLateInit() ) { @@ -3575,7 +3574,7 @@ void ScDPDataDimension::ProcessData( const vector< SCROW >& aDataMembers, const long nCount = maMembers.size(); for (long i=0; i<nCount; i++) { - ScDPDataMember* pMember = maMembers[static_cast<sal_uInt16>(i)]; + ScDPDataMember* pMember = maMembers[static_cast<sal_uInt16>(i)].get(); // always first member for data layout dim if ( bIsDataLayout || ( !aDataMembers.empty() && pMember->IsNamedItem(aDataMembers[0]) ) ) @@ -3633,7 +3632,7 @@ void ScDPDataDimension::FillDataRow( const ScDPResultMember* pRefMember = pRefDim->GetMember(nMemberPos); if ( pRefMember->IsVisible() ) //TODO: here or in ScDPDataMember::FillDataRow ??? { - const ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(nMemberPos)]; + const ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(nMemberPos)].get(); pDataMember->FillDataRow(pRefMember, rFilterCxt, rSequence, nMemberMeasure, bIsSubTotalRow, rSubState); } } @@ -3661,7 +3660,7 @@ void ScDPDataDimension::UpdateDataRow( const ScDPResultDimension* pRefDim, // Calculate must be called even if the member is not visible (for use as reference value) const ScDPResultMember* pRefMember = pRefDim->GetMember(nMemberPos); - ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(nMemberPos)]; + ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(nMemberPos)].get(); pDataMember->UpdateDataRow( pRefMember, nMemberMeasure, bIsSubTotalRow, rSubState ); } } @@ -3696,7 +3695,7 @@ void ScDPDataDimension::SortMembers( ScDPResultDimension* pRefDim ) ScDPResultMember* pRefMember = pRefDim->GetMember(i); if ( pRefMember->IsVisible() ) //TODO: here or in ScDPDataMember ??? { - ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(i)]; + ScDPDataMember* pDataMember = maMembers[static_cast<sal_uInt16>(i)].get(); pDataMember->SortMembers( pRefMember ); } } @@ -3718,7 +3717,7 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim ) ScDPResultMember* pRefMember = pRefDim->GetMember(i); if ( pRefMember->IsVisible() ) //TODO: here or in ScDPDataMember ??? { - ScDPDataMember* pDataMember = maMembers[i]; + ScDPDataMember* pDataMember = maMembers[i].get(); pDataMember->DoAutoShow( pRefMember ); } } @@ -3739,7 +3738,7 @@ void ScDPDataDimension::DoAutoShow( ScDPResultDimension* pRefDim ) // look for equal values to the last included one long nIncluded = pRefDim->GetAutoCount(); - ScDPDataMember* pDataMember1 = maMembers[aAutoOrder[nIncluded - 1]]; + ScDPDataMember* pDataMember1 = maMembers[aAutoOrder[nIncluded - 1]].get(); if ( !pDataMember1->IsVisible() ) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits