2016-08-22 18:10:02 +09:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <math.h>
|
2018-07-28 15:57:23 +02:00
|
|
|
#include <sal/log.hxx>
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <cppuhelper/bootstrap.hxx>
|
2019-06-14 00:40:47 +02:00
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
2016-08-22 18:10:02 +09:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
|
|
|
|
2019-06-14 00:40:47 +02:00
|
|
|
#include <vcl/event.hxx>
|
2017-11-23 23:03:52 +01:00
|
|
|
#include <vcl/gradient.hxx>
|
2016-08-22 18:10:02 +09:00
|
|
|
#include <vcl/vclmain.hxx>
|
|
|
|
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/wrkwin.hxx>
|
|
|
|
#include <vcl/virdev.hxx>
|
|
|
|
|
|
|
|
#include <basegfx/numeric/ftools.hxx>
|
2018-04-05 16:20:13 +02:00
|
|
|
#include <tools/diagnose_ex.h>
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
#include <chrono>
|
|
|
|
#include <iostream>
|
|
|
|
|
2017-10-23 22:28:18 +02:00
|
|
|
#include <test/outputdevice.hxx>
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
using namespace css;
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static void drawBitmapCentered(tools::Rectangle const& rRect, const Bitmap& aBitmap,
|
2018-09-06 08:50:58 +02:00
|
|
|
vcl::RenderContext& rRenderContext)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
long nWidth = rRect.GetWidth();
|
|
|
|
long nHeight = rRect.GetHeight();
|
|
|
|
|
|
|
|
Size aBitmapSize(aBitmap.GetSizePixel());
|
|
|
|
|
|
|
|
Point aPoint(rRect.TopLeft());
|
|
|
|
|
2018-02-21 15:56:58 +02:00
|
|
|
aPoint.AdjustX((nWidth - aBitmapSize.Width()) / 2 );
|
|
|
|
aPoint.AdjustY((nHeight - aBitmapSize.Height()) / 2 );
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
rRenderContext.DrawBitmap(aPoint, aBitmap);
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static void drawBitmapScaledAndCentered(tools::Rectangle const & rRect, Bitmap aBitmap, vcl::RenderContext& rRenderContext, BmpScaleFlag aFlag = BmpScaleFlag::Fast)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
long nWidth = rRect.GetWidth();
|
|
|
|
long nHeight = rRect.GetHeight();
|
|
|
|
|
|
|
|
Size aBitmapSize(aBitmap.GetSizePixel());
|
|
|
|
|
2018-01-11 08:47:15 +02:00
|
|
|
double fWidthHeight = std::min(nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
double fScale = fWidthHeight / aBitmapSize.Width();
|
|
|
|
aBitmap.Scale(fScale, fScale, aFlag);
|
|
|
|
|
|
|
|
drawBitmapCentered(rRect, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static void drawBackgroundRect(tools::Rectangle const & rRect, Color aColor, vcl::RenderContext& rRenderContext)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
rRenderContext.Push(PushFlags::LINECOLOR | PushFlags::FILLCOLOR);
|
|
|
|
rRenderContext.SetFillColor(aColor);
|
|
|
|
rRenderContext.SetLineColor(aColor);
|
|
|
|
rRenderContext.DrawRect(rRect);
|
|
|
|
rRenderContext.Pop();
|
|
|
|
}
|
|
|
|
|
2018-09-15 19:13:19 +02:00
|
|
|
static void assertAndSetBackground(vcl::test::TestResult eResult, tools::Rectangle const & rRect, vcl::RenderContext& rRenderContext)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
if (eResult == vcl::test::TestResult::Passed)
|
|
|
|
drawBackgroundRect(rRect, COL_GREEN, rRenderContext);
|
|
|
|
else if (eResult == vcl::test::TestResult::PassedWithQuirks)
|
|
|
|
drawBackgroundRect(rRect, COL_YELLOW, rRenderContext);
|
|
|
|
else if (eResult == vcl::test::TestResult::Failed)
|
|
|
|
drawBackgroundRect(rRect, COL_RED, rRenderContext);
|
|
|
|
}
|
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
namespace {
|
|
|
|
|
2016-08-22 18:10:02 +09:00
|
|
|
class VisualBackendTestWindow : public WorkWindow
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Timer maUpdateTimer;
|
|
|
|
std::vector<std::chrono::high_resolution_clock::time_point> mTimePoints;
|
2019-11-13 17:24:42 +01:00
|
|
|
static constexpr unsigned char gnNumberOfTests = 8;
|
2016-08-22 18:10:02 +09:00
|
|
|
unsigned char mnTest;
|
|
|
|
bool mbAnimate;
|
|
|
|
ScopedVclPtr<VirtualDevice> mpVDev;
|
|
|
|
|
|
|
|
public:
|
|
|
|
VisualBackendTestWindow()
|
2016-08-23 16:36:20 +10:00
|
|
|
: WorkWindow(nullptr, WB_APP | WB_STDWORK)
|
2018-09-13 15:00:56 +02:00
|
|
|
, mnTest(10 * gnNumberOfTests)
|
|
|
|
, mbAnimate(mnTest % gnNumberOfTests == gnNumberOfTests - 1)
|
2016-08-22 18:10:02 +09:00
|
|
|
, mpVDev(VclPtr<VirtualDevice>::Create())
|
|
|
|
{
|
2017-01-23 19:37:51 +01:00
|
|
|
maUpdateTimer.SetInvokeHandler(LINK(this, VisualBackendTestWindow, updateHdl));
|
2019-11-26 15:49:07 +01:00
|
|
|
maUpdateTimer.SetPriority(TaskPriority::DEFAULT_IDLE);
|
2016-08-22 18:10:02 +09:00
|
|
|
if (mbAnimate)
|
|
|
|
{
|
|
|
|
maUpdateTimer.SetTimeout(1000.0);
|
|
|
|
maUpdateTimer.Start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~VisualBackendTestWindow() override
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
disposeOnce();
|
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
DECL_LINK(updateHdl, Timer*, void);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
virtual void KeyInput(const KeyEvent& rKEvt) override
|
|
|
|
{
|
|
|
|
sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
|
|
|
|
|
|
|
|
if (nCode == KEY_BACKSPACE)
|
|
|
|
mnTest--;
|
|
|
|
else if(nCode == KEY_SPACE)
|
|
|
|
mnTest++;
|
|
|
|
|
|
|
|
if (nCode == KEY_BACKSPACE || nCode == KEY_SPACE)
|
|
|
|
{
|
2018-09-13 15:00:56 +02:00
|
|
|
if (mnTest % gnNumberOfTests == gnNumberOfTests - 1)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
mbAnimate = true;
|
|
|
|
maUpdateTimer.Start();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mbAnimate = false;
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
static std::vector<tools::Rectangle> setupRegions(int nPartitionsX, int nPartitionsY, int nWidth, int nHeight)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2017-03-30 20:27:55 +02:00
|
|
|
std::vector<tools::Rectangle> aRegions;
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
for (int y = 0; y < nPartitionsY; y++)
|
|
|
|
{
|
|
|
|
for (int x = 0; x < nPartitionsX; x++)
|
|
|
|
{
|
|
|
|
long x1 = x * (nWidth / nPartitionsX);
|
|
|
|
long y1 = y * (nHeight / nPartitionsY);
|
|
|
|
long x2 = (x+1) * (nWidth / nPartitionsX);
|
|
|
|
long y2 = (y+1) * (nHeight / nPartitionsY);
|
|
|
|
|
2017-09-13 16:44:19 +02:00
|
|
|
aRegions.emplace_back(x1 + 1, y1 + 1, x2 - 2, y2 - 2);
|
2016-08-22 18:10:02 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return aRegions;
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:36:20 +10:00
|
|
|
static void testRectangles(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aRectangle;
|
2016-08-22 18:10:02 +09:00
|
|
|
size_t index = 0;
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(3, 2, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestRect aOutDevTest;
|
2019-04-15 21:52:46 +09:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupRectangle(false);
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPixel aOutDevTest;
|
2019-04-15 21:52:46 +09:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupRectangle(false);
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestLine aOutDevTest;
|
2019-04-15 21:52:46 +09:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupRectangle(false);
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolygon aOutDevTest;
|
2019-04-15 21:52:46 +09:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupRectangle(false);
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyLine aOutDevTest;
|
2019-04-15 21:52:46 +09:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupRectangle(false);
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
|
2019-04-15 21:52:46 +09:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupRectangle(false);
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkRectangle(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:36:20 +10:00
|
|
|
static void testFilledRectangles(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aRectangle;
|
2016-08-22 18:10:02 +09:00
|
|
|
size_t index = 0;
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(3, 2, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestRect aOutDevTest;
|
2019-11-01 13:44:20 +01:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolygon aOutDevTest;
|
2019-11-01 13:44:20 +01:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
|
2019-11-01 13:44:20 +01:00
|
|
|
Bitmap aBitmap = aOutDevTest.setupFilledRectangle(false);
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, false), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
2019-11-01 13:44:20 +01:00
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestRect aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupFilledRectangle(true);
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolygon aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupFilledRectangle(true);
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyPolygon aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupFilledRectangle(true);
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkFilledRectangle(aBitmap, true), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void testDiamonds(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
|
|
|
|
{
|
|
|
|
tools::Rectangle aRectangle;
|
|
|
|
size_t index = 0;
|
|
|
|
|
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(3, 1, nWidth, nHeight);
|
|
|
|
|
2016-08-22 18:10:02 +09:00
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolygon aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDiamond();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestLine aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDiamond();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyLine aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDiamond();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkDiamond(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:36:20 +10:00
|
|
|
static void testLines(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aRectangle;
|
2016-08-22 18:10:02 +09:00
|
|
|
size_t index = 0;
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(3, 2, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestLine aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupLines();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkLines(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyLine aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupLines();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkLines(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolygon aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupLines();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkLines(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestLine aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupAALines();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkAALines(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolyLine aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupAALines();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkAALines(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestPolygon aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupAALines();
|
2016-08-23 15:28:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestCommon::checkAALines(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-23 16:36:20 +10:00
|
|
|
static void testBitmaps(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aRectangle;
|
2016-08-22 18:10:02 +09:00
|
|
|
size_t index = 0;
|
|
|
|
|
2019-12-03 21:49:08 +01:00
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(3, 2, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestBitmap aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDrawBitmap();
|
2016-08-23 16:06:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestBitmap aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDrawTransformedBitmap();
|
2016-08-23 16:06:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkTransformedBitmap(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestBitmap aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDrawBitmapExWithAlpha();
|
2016-08-23 16:06:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBitmapExWithAlpha(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestBitmap aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDrawMask();
|
2016-08-23 16:06:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkMask(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
2019-12-03 21:49:08 +01:00
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestBitmap aOutDevTest;
|
|
|
|
BitmapEx aBitmap = aOutDevTest.setupDrawBlend();
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestBitmap::checkBlend(aBitmap), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap.GetBitmap(), rRenderContext);
|
|
|
|
}
|
2016-08-22 18:10:02 +09:00
|
|
|
}
|
|
|
|
|
2019-11-13 17:24:42 +01:00
|
|
|
static void testInvert(vcl::RenderContext& rRenderContext, int nWidth, int nHeight)
|
|
|
|
{
|
|
|
|
tools::Rectangle aRectangle;
|
|
|
|
size_t index = 0;
|
|
|
|
|
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(2, 2, nWidth, nHeight);
|
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestRect aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupInvert_NONE();
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestRect::checkInvertRectangle(aBitmap), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestRect aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupInvert_N50();
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestRect::checkInvertN50Rectangle(aBitmap), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestRect aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupInvert_TrackFrame();
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestRect::checkInvertTrackFrameRectangle(aBitmap), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupXOR();
|
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestAnotherOutDev::checkXOR(aBitmap), aRectangle, rRenderContext);
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2018-09-13 15:00:56 +02:00
|
|
|
if (mnTest % gnNumberOfTests == gnNumberOfTests - 1)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
rRenderContext.SetBackground(Wallpaper(COL_GREEN));
|
|
|
|
|
|
|
|
static size_t nTimeIndex = 0;
|
|
|
|
static const size_t constSamplesFPS = 120;
|
|
|
|
double fps = 0.0;
|
|
|
|
|
|
|
|
if (mTimePoints.size() < constSamplesFPS)
|
|
|
|
{
|
|
|
|
mTimePoints.push_back(std::chrono::high_resolution_clock::now());
|
|
|
|
nTimeIndex++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size_t current = nTimeIndex % constSamplesFPS;
|
|
|
|
mTimePoints[current] = std::chrono::high_resolution_clock::now();
|
|
|
|
size_t last = (nTimeIndex + 1) % constSamplesFPS;
|
|
|
|
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(mTimePoints[current] - mTimePoints[last]).count();
|
|
|
|
fps = constSamplesFPS * 1000.0 / ms;
|
|
|
|
nTimeIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
double fTime = 0.5 + std::sin(nTimeIndex / 100.0) / 2.0;
|
|
|
|
|
|
|
|
Size aSizePixel = GetSizePixel();
|
|
|
|
|
|
|
|
mpVDev->SetAntialiasing(AntialiasingFlags::EnableB2dDraw | AntialiasingFlags::PixelSnapHairline);
|
|
|
|
mpVDev->SetOutputSizePixel(aSizePixel);
|
|
|
|
mpVDev->SetBackground(Wallpaper(COL_LIGHTGRAY));
|
|
|
|
mpVDev->Erase();
|
|
|
|
mpVDev->SetFillColor(COL_LIGHTRED);
|
|
|
|
mpVDev->SetLineColor(COL_LIGHTBLUE);
|
|
|
|
|
|
|
|
basegfx::B2DPolyPolygon polyPolygon;
|
|
|
|
|
|
|
|
for (int b=10; b<14; b++)
|
|
|
|
{
|
|
|
|
basegfx::B2DPolygon polygon;
|
|
|
|
for (double a=0.0; a<360.0; a+=0.5)
|
|
|
|
{
|
2018-08-04 10:37:17 +03:00
|
|
|
double x = std::sin(basegfx::deg2rad(a)) * (b+1) * 20;
|
|
|
|
double y = std::cos(basegfx::deg2rad(a)) * (b+1) * 20;
|
2016-08-22 18:10:02 +09:00
|
|
|
polygon.append(basegfx::B2DPoint(x + 200 + 500 * fTime, y + 200 + 500 * fTime));
|
|
|
|
}
|
|
|
|
polygon.setClosed(true);
|
|
|
|
polyPolygon.append(polygon);
|
|
|
|
}
|
|
|
|
|
|
|
|
mpVDev->DrawPolyPolygon(polyPolygon);
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aGradientRect(Point(200, 200), Size(200 + fTime * 300, 200 + fTime * 300));
|
2016-09-02 10:53:14 +02:00
|
|
|
mpVDev->DrawGradient(aGradientRect, Gradient(GradientStyle::Linear, COL_YELLOW, COL_BLUE));
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
rRenderContext.DrawOutDev(Point(), mpVDev->GetOutputSizePixel(),
|
|
|
|
Point(), mpVDev->GetOutputSizePixel(),
|
2019-01-07 13:52:59 +02:00
|
|
|
*mpVDev);
|
2016-08-22 18:10:02 +09:00
|
|
|
rRenderContext.SetTextColor(COL_LIGHTRED);
|
2016-08-23 16:36:20 +10:00
|
|
|
rRenderContext.DrawText(Point(10, 10), "FPS: " + OUString::number(int(fps)));
|
2016-08-22 18:10:02 +09:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rRenderContext.SetBackground(Wallpaper(COL_GREEN));
|
|
|
|
|
|
|
|
Size aSize = GetOutputSizePixel();
|
|
|
|
|
|
|
|
long nWidth = aSize.Width();
|
|
|
|
long nHeight = aSize.Height();
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
tools::Rectangle aRectangle;
|
2016-08-22 18:10:02 +09:00
|
|
|
size_t index = 0;
|
|
|
|
|
2018-09-13 15:00:56 +02:00
|
|
|
if (mnTest % gnNumberOfTests == 0)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
testRectangles(rRenderContext, nWidth, nHeight);
|
|
|
|
}
|
2018-09-13 15:00:56 +02:00
|
|
|
else if (mnTest % gnNumberOfTests == 1)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
testFilledRectangles(rRenderContext, nWidth, nHeight);
|
|
|
|
}
|
2018-09-13 15:00:56 +02:00
|
|
|
else if (mnTest % gnNumberOfTests == 2)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2019-11-01 13:44:20 +01:00
|
|
|
testDiamonds(rRenderContext, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
}
|
2018-09-13 15:00:56 +02:00
|
|
|
else if (mnTest % gnNumberOfTests == 3)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2019-11-01 13:44:20 +01:00
|
|
|
testLines(rRenderContext, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
}
|
2018-09-13 15:00:56 +02:00
|
|
|
else if (mnTest % gnNumberOfTests == 4)
|
2019-11-01 13:44:20 +01:00
|
|
|
{
|
|
|
|
testBitmaps(rRenderContext, nWidth, nHeight);
|
|
|
|
}
|
|
|
|
else if (mnTest % gnNumberOfTests == 5)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2019-11-13 17:24:42 +01:00
|
|
|
testInvert(rRenderContext, nWidth, nHeight);
|
|
|
|
}
|
|
|
|
else if (mnTest % gnNumberOfTests == 6)
|
|
|
|
{
|
|
|
|
std::vector<tools::Rectangle> aRegions = setupRegions(3, 1, nWidth, nHeight);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestAnotherOutDev aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupDrawOutDev();
|
2016-08-23 16:06:35 +10:00
|
|
|
assertAndSetBackground(vcl::test::OutputDeviceTestAnotherOutDev::checkDrawOutDev(aBitmap), aRectangle, rRenderContext);
|
2016-08-22 18:10:02 +09:00
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestGradient aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupLinearGradient();
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
aRectangle = aRegions[index++];
|
|
|
|
{
|
|
|
|
vcl::test::OutputDeviceTestGradient aOutDevTest;
|
|
|
|
Bitmap aBitmap = aOutDevTest.setupRadialGradient();
|
|
|
|
drawBitmapScaledAndCentered(aRectangle, aBitmap, rRenderContext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(VisualBackendTestWindow, updateHdl, Timer *, void)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
|
|
|
if (mbAnimate)
|
|
|
|
{
|
2019-11-06 10:20:32 +01:00
|
|
|
maUpdateTimer.SetTimeout(1.0);
|
2016-08-22 18:10:02 +09:00
|
|
|
maUpdateTimer.Start();
|
|
|
|
Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
namespace {
|
|
|
|
|
2016-08-22 18:10:02 +09:00
|
|
|
class VisualBackendTestApp : public Application
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
VisualBackendTestApp()
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual int Main() override
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ScopedVclPtrInstance<VisualBackendTestWindow> aMainWindow;
|
|
|
|
|
|
|
|
aMainWindow->SetText("VCL Test");
|
|
|
|
aMainWindow->Show();
|
|
|
|
|
|
|
|
Application::Execute();
|
|
|
|
}
|
2018-04-05 16:20:13 +02:00
|
|
|
catch (const css::uno::Exception&)
|
2016-08-22 18:10:02 +09:00
|
|
|
{
|
2018-04-05 16:20:13 +02:00
|
|
|
DBG_UNHANDLED_EXCEPTION("vcl.app", "Fatal");
|
2016-08-22 18:10:02 +09:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
catch (const std::exception& rException)
|
|
|
|
{
|
|
|
|
SAL_WARN("vcl.app", "Fatal exception: " << rException.what());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void Init() override
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
uno::Reference<uno::XComponentContext> xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext();
|
2019-06-21 12:14:08 +02:00
|
|
|
uno::Reference<lang::XMultiServiceFactory> xMSF(xComponentContext->getServiceManager(), uno::UNO_QUERY);
|
2016-08-22 18:10:02 +09:00
|
|
|
|
|
|
|
if (!xMSF.is())
|
|
|
|
Application::Abort("Bootstrap failure - no service manager");
|
|
|
|
|
|
|
|
comphelper::setProcessServiceFactory(xMSF);
|
|
|
|
}
|
|
|
|
catch (const uno::Exception &e)
|
|
|
|
{
|
|
|
|
Application::Abort("Bootstrap exception " + e.Message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeInit() override
|
|
|
|
{
|
|
|
|
uno::Reference<lang::XComponent> xComponent(comphelper::getProcessComponentContext(), uno::UNO_QUERY_THROW);
|
|
|
|
xComponent->dispose();
|
|
|
|
comphelper::setProcessServiceFactory(nullptr);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
Extend loplugin:external to warn about classes
...following up on 314f15bff08b76bf96acf99141776ef64d2f1355 "Extend
loplugin:external to warn about enums".
Cases where free functions were moved into an unnamed namespace along with a
class, to not break ADL, are in:
filter/source/svg/svgexport.cxx
sc/source/filter/excel/xelink.cxx
sc/source/filter/excel/xilink.cxx
svx/source/sdr/contact/viewobjectcontactofunocontrol.cxx
All other free functions mentioning moved classes appear to be harmless and not
give rise to (silent, even) ADL breakage. (One remaining TODO in
compilerplugins/clang/external.cxx is that derived classes are not covered by
computeAffectedTypes, even though they could also be affected by ADL-breakage---
but don't seem to be in any acutal case across the code base.)
For friend declarations using elaborate type specifiers, like
class C1 {};
class C2 { friend class C1; };
* If C2 (but not C1) is moved into an unnamed namespace, the friend declaration
must be changed to not use an elaborate type specifier (i.e., "friend C1;"; see
C++17 [namespace.memdef]/3: "If the name in a friend declaration is neither
qualified nor a template-id and the declaration is a function or an
elaborated-type-specifier, the lookup to determine whether the entity has been
previously declared shall not consider any scopes outside the innermost
enclosing namespace.")
* If C1 (but not C2) is moved into an unnamed namespace, the friend declaration
must be changed too, see <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71882>
"elaborated-type-specifier friend not looked up in unnamed namespace".
Apart from that, to keep changes simple and mostly mechanical (which should help
avoid regressions), out-of-line definitions of class members have been left in
the enclosing (named) namespace. But explicit specializations of class
templates had to be moved into the unnamed namespace to appease
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92598> "explicit specialization of
template from unnamed namespace using unqualified-id in enclosing namespace".
Also, accompanying declarations (of e.g. typedefs or static variables) that
could arguably be moved into the unnamed namespace too have been left alone.
And in some cases, mention of affected types in blacklists in other loplugins
needed to be adapted.
And sc/qa/unit/mark_test.cxx uses a hack of including other .cxx, one of which
is sc/source/core/data/segmenttree.cxx where e.g. ScFlatUInt16SegmentsImpl is
not moved into an unnamed namespace (because it is declared in
sc/inc/segmenttree.hxx), but its base ScFlatSegmentsImpl is. GCC warns about
such combinations with enabled-by-default -Wsubobject-linkage, but "The compiler
doesn’t give this warning for types defined in the main .C file, as those are
unlikely to have multiple definitions."
(<https://gcc.gnu.org/onlinedocs/gcc-9.2.0/gcc/Warning-Options.html>) The
warned-about classes also don't have multiple definitions in the given test, so
disable the warning when including the .cxx.
Change-Id: Ib694094c0d8168be68f8fe90dfd0acbb66a3f1e4
Reviewed-on: https://gerrit.libreoffice.org/83239
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-11-19 16:32:49 +01:00
|
|
|
}
|
|
|
|
|
2016-08-22 18:10:02 +09:00
|
|
|
void vclmain::createApplication()
|
|
|
|
{
|
|
|
|
static VisualBackendTestApp aApplication;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|