Rebased ref, commits from common ancestor: commit 2ed5c94e656ed9729eb0c27bc0f9d20715a68492 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon May 4 08:49:36 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon May 4 08:53:37 2020 +0200
SdrPdfImport: add a test class to sd and write a simple test Open a simple PDF document, run the "break" action, check that we get the expected text as a text object. Change-Id: Iadb458f06b437689202eb013cb900edaabf17673 diff --git a/sd/CppunitTest_sd_pdf_import_test.mk b/sd/CppunitTest_sd_pdf_import_test.mk new file mode 100644 index 000000000000..4326c9cdede0 --- /dev/null +++ b/sd/CppunitTest_sd_pdf_import_test.mk @@ -0,0 +1,73 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_CppunitTest_CppunitTest,sd_pdf_import_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sd_pdf_import_test, \ + sd/qa/unit/SdrPdfImportTest \ +)) + +$(eval $(call gb_CppunitTest_use_externals,sd_pdf_import_test, \ + boost_headers \ + $(if $(filter PDFIUM,$(BUILD_TYPE)),pdfium) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sd_pdf_import_test,\ + -I$(SRCDIR)/sd/inc \ + -I$(SRCDIR)/sd/source/ui/inc \ + -I$(SRCDIR)/sd/source/ui/slidesorter/inc \ + -I$(SRCDIR)/svx/source/inc \ + -I$(SRCDIR)/svx/inc \ + $$(INCLUDE) \ +)) + +$(eval $(call gb_CppunitTest_use_libraries,sd_pdf_import_test, \ + $(call gb_Helper_optional,AVMEDIA,avmedia) \ + basegfx \ + canvastools \ + comphelper \ + cppcanvas \ + cppu \ + cppuhelper \ + drawinglayer \ + editeng \ + for \ + forui \ + i18nlangtag \ + i18nutil \ + msfilter \ + oox \ + sal \ + salhelper \ + sax \ + sb \ + sd \ + sfx \ + sot \ + svl \ + svt \ + svx \ + svxcore \ + test \ + tl \ + tk \ + ucbhelper \ + unotest \ + utl \ + vcl \ + xo \ +)) + +$(eval $(call gb_CppunitTest_use_sdk_api,sd_pdf_import_test)) +$(eval $(call gb_CppunitTest_use_ure,sd_pdf_import_test)) +$(eval $(call gb_CppunitTest_use_vcl,sd_pdf_import_test)) +$(eval $(call gb_CppunitTest_use_rdb,sd_pdf_import_test,services)) +$(eval $(call gb_CppunitTest_use_configuration,sd_pdf_import_test)) + +# vim: set noet sw=4 ts=4: diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk index a7edda76cbe4..d5c6b2ecab23 100644 --- a/sd/Module_sd.mk +++ b/sd/Module_sd.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Module_add_slowcheck_targets,sd,\ CppunitTest_sd_uiimpress \ CppunitTest_sd_html_export_tests \ CppunitTest_sd_activex_controls_tests \ + CppunitTest_sd_pdf_import_test \ )) endif diff --git a/sd/qa/unit/SdrPdfImportTest.cxx b/sd/qa/unit/SdrPdfImportTest.cxx new file mode 100644 index 000000000000..f7215360ec7e --- /dev/null +++ b/sd/qa/unit/SdrPdfImportTest.cxx @@ -0,0 +1,128 @@ +/* -*- 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 <test/bootstrapfixture.hxx> +#include <unotest/macros_test.hxx> + +#include <svdpdf.hxx> + +#include <config_features.h> + +#include <comphelper/scopeguard.hxx> +#include <comphelper/processfactory.hxx> + +#include <svx/svdograf.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/editobj.hxx> + +#include <DrawDocShell.hxx> +#include <DrawController.hxx> +#include <ViewShell.hxx> +#include <drawdoc.hxx> +#include <sdpage.hxx> +#include <unomodel.hxx> + +#include <com/sun/star/frame/Desktop.hpp> + +using namespace css; + +class SdrPdfImportTest : public test::BootstrapFixture, public unotest::MacrosTest +{ +protected: + uno::Reference<lang::XComponent> mxComponent; + +public: + virtual void setUp() override; + virtual void tearDown() override; +}; + +void SdrPdfImportTest::setUp() +{ + test::BootstrapFixture::setUp(); + + mxDesktop.set(frame::Desktop::create(mxComponentContext)); +} + +void SdrPdfImportTest::tearDown() +{ + if (mxComponent.is()) + mxComponent->dispose(); + + test::BootstrapFixture::tearDown(); +} + +// Load the PDF in Draw, which will load the PDF as an Graphic, then +// mark the graphic object and trigger "break" funcition. This should +// convert the PDF content into objects/shapes. +CPPUNIT_TEST_FIXTURE(SdrPdfImportTest, testImportSimpleText) +{ +#if HAVE_FEATURE_PDFIUM + // We need to enable PDFium import (and make sure to disable after the test) + bool bResetEnvVar = false; + if (getenv("LO_IMPORT_USE_PDFIUM") == nullptr) + { + bResetEnvVar = true; + setenv("LO_IMPORT_USE_PDFIUM", "1", false); + } + comphelper::ScopeGuard aPDFiumEnvVarGuard([&]() { + if (bResetEnvVar) + unsetenv("LO_IMPORT_USE_PDFIUM"); + }); + + mxComponent = loadFromDesktop(m_directories.getURLFromSrc("sd/qa/unit/data/SimplePDF.pdf")); + auto pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + sd::ViewShell* pViewShell = pImpressDocument->GetDocShell()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + + // Get the first page - there should be only one. + SdPage* pPage = pViewShell->GetActualPage(); + CPPUNIT_ASSERT(pPage); + + // Get the first object - there should be only one. + SdrObject* pObject = pPage->GetObj(0); + CPPUNIT_ASSERT(pObject); + + // Check the object is a graphic object + SdrGrafObj* pGraphicObject = dynamic_cast<SdrGrafObj*>(pObject); + CPPUNIT_ASSERT(pGraphicObject); + // Check the graphic is a vector graphic and that it is PDF + Graphic aGraphic = pGraphicObject->GetGraphic(); + auto const& pVectorGraphicData = aGraphic.getVectorGraphicData(); + CPPUNIT_ASSERT(pVectorGraphicData); + CPPUNIT_ASSERT_EQUAL(VectorGraphicDataType::Pdf, + pVectorGraphicData->getVectorGraphicDataType()); + + // Mark the object + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pObject, pView->GetSdrPageView()); + + // Execute the break operation - to turn the PDF into shapes/objects + pViewShell->GetDrawView()->DoImportMarkedMtf(); + + // Check Objects after import + + SdrObject* pImportedObject = pPage->GetObj(0); + CPPUNIT_ASSERT(pImportedObject); + + // Object should be a text object containing one paragraph with + // content "This is PDF!" + + SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pImportedObject); + CPPUNIT_ASSERT(pTextObject); + OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); + const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject(); + OUString sText = aEdit.GetText(0); + CPPUNIT_ASSERT_EQUAL(OUString("This is PDF!"), sText); + +#endif // HAVE_FEATURE_PDFIUM +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/data/SimplePDF.pdf b/sd/qa/unit/data/SimplePDF.pdf new file mode 100644 index 000000000000..5d6fdb191544 Binary files /dev/null and b/sd/qa/unit/data/SimplePDF.pdf differ diff --git a/svx/source/svdraw/svdpdf.hxx b/svx/source/inc/svdpdf.hxx similarity index 98% rename from svx/source/svdraw/svdpdf.hxx rename to svx/source/inc/svdpdf.hxx index d9d35fe0c80c..9b48eb1d30c5 100644 --- a/svx/source/svdraw/svdpdf.hxx +++ b/svx/source/inc/svdpdf.hxx @@ -24,9 +24,9 @@ #if HAVE_FEATURE_PDFIUM #include <sal/config.h> +#include <svx/svxdllapi.h> #include <memory> -#include <sstream> #include <tools/fract.hxx> #include <vcl/virdev.hxx> @@ -52,7 +52,7 @@ class SdrObject; class SvdProgressInfo; // Helper Class to import PDF -class ImpSdrPdfImport final +class SVXCORE_DLLPUBLIC ImpSdrPdfImport final { std::vector<SdrObject*> maTmpList; ScopedVclPtr<VirtualDevice> mpVD; diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 5394c3c261d1..5cd0c0765a29 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "svdpdf.hxx" +#include <svdpdf.hxx> #include <config_features.h> commit 11edfeac4257d2d6a63b3784d9fc34c9524ed8f4 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun May 3 13:03:30 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon May 4 08:53:36 2020 +0200 SdrPdfImport: use convertPointToMm100 for all unit conversion Change-Id: I78b3512cc0b9aea1fa4e9a810ec71eadd00b7635 diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index ad3a89ed9c02..5394c3c261d1 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -79,27 +79,8 @@ namespace { -/// Convert from DPI to pixels. -/// PDFs don't have resolution, rather, -/// dimensions are in inches, with 72 points / inch. -/// Here we effectively render at 96 DPI (to match -/// the image rendered in vcl::ImportPDF in pdfread.cxx). -double lcl_PointToPixel(double fPoint) { return fPoint * 96. / 72.; } - -/// Convert from pixels to logic (twips). -long lcl_ToLogic(double value) -{ - // Convert to integral preserving two dp. - const long in = static_cast<long>(value * 100.); - const long out = OutputDevice::LogicToLogic(in, MapUnit::MapPixel, MapUnit::Map100thMM); - return out / 100; -} - double sqrt2(double a, double b) { return sqrt(a * a + b * b); } -} -namespace -{ struct FPDFBitmapDeleter { void operator()(FPDF_BITMAP bitmap) { FPDFBitmap_Destroy(bitmap); } @@ -248,8 +229,7 @@ void ImpSdrPdfImport::SetupPageScale(const double dPageWidth, const double dPage mdPageWidthPts = dPageWidth; mdPageHeightPts = dPageHeight; - Size aPageSize(lcl_ToLogic(lcl_PointToPixel(dPageWidth)), - lcl_ToLogic(lcl_PointToPixel(dPageHeight))); + Size aPageSize(convertPointToMm100(dPageWidth), convertPointToMm100(dPageHeight)); if (aPageSize.Width() && aPageSize.Height() && (!maScaleRect.IsEmpty())) { @@ -815,10 +795,9 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex const double dFontSize = FPDFTextObj_GetFontSize(pPageObject); double dFontSizeH = fabs(sqrt2(matrix.a, matrix.c) * dFontSize); double dFontSizeV = fabs(sqrt2(matrix.b, matrix.d) * dFontSize); - dFontSizeH = lcl_PointToPixel(dFontSizeH); - dFontSizeV = lcl_PointToPixel(dFontSizeV); - dFontSizeH = lcl_ToLogic(dFontSizeH); - dFontSizeV = lcl_ToLogic(dFontSizeV); + + dFontSizeH = convertPointToMm100(dFontSizeH); + dFontSizeV = convertPointToMm100(dFontSizeV); const Size aFontSize(dFontSizeH, dFontSizeV); vcl::Font aFnt = mpVD->GetFont(); @@ -1120,7 +1099,7 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI float fWidth = 1; FPDFPageObj_GetStrokeWidth(pPageObject, &fWidth); const double dWidth = 0.5 * fabs(sqrt2(aPathMatrix.a(), aPathMatrix.c()) * fWidth); - mnLineWidth = lcl_ToLogic(lcl_PointToPixel(dWidth)); + mnLineWidth = convertPointToMm100(dWidth); int nFillMode = FPDF_FILLMODE_ALTERNATE; FPDF_BOOL bStroke = 1; // Assume we have to draw, unless told otherwise. @@ -1160,10 +1139,8 @@ void ImpSdrPdfImport::ImportPath(FPDF_PAGEOBJECT pPageObject, int /*nPageObjectI Point ImpSdrPdfImport::PointsToLogic(double x, double y) const { y = correctVertOrigin(y); - x = lcl_PointToPixel(x); - y = lcl_PointToPixel(y); - Point aPos(lcl_ToLogic(x), lcl_ToLogic(y)); + Point aPos(convertPointToMm100(x), convertPointToMm100(y)); return aPos; } @@ -1173,15 +1150,10 @@ tools::Rectangle ImpSdrPdfImport::PointsToLogic(double left, double right, doubl top = correctVertOrigin(top); bottom = correctVertOrigin(bottom); - left = lcl_PointToPixel(left); - right = lcl_PointToPixel(right); - top = lcl_PointToPixel(top); - bottom = lcl_PointToPixel(bottom); + Point aPos(convertPointToMm100(left), convertPointToMm100(top)); + Size aSize(convertPointToMm100(right - left), convertPointToMm100(bottom - top)); - Point aPos(lcl_ToLogic(left), lcl_ToLogic(top)); - Size aSize(lcl_ToLogic(right - left), lcl_ToLogic(bottom - top)); - tools::Rectangle aRect(aPos, aSize); - return aRect; + return tools::Rectangle(aPos, aSize); } #endif // HAVE_FEATURE_PDFIUM commit 59d28435f9bbde313b57ab299e531fc2880966d2 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Apr 1 13:00:25 2020 +0200 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon May 4 08:52:47 2020 +0200 Add OutputDevice::drawPrimitive2D to OutputDevice Change-Id: Ifc22eca62df72bddd247ba097054f34756520614 diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 1df0137cdcee..9cd127d3490c 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -49,6 +49,8 @@ #include <com/sun/star/drawing/LineCap.hpp> #include <com/sun/star/uno/Reference.h> +#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> + #include <memory> #include <vector> @@ -1955,6 +1957,9 @@ public: ///@} + bool drawPrimitive2D(drawinglayer::primitive2d::Primitive2DContainer & rPrimitive2D); + + /** @name Native Widget Rendering functions These all just call through to the private mpGraphics functions of the same name. diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index cb59e378fb89..6d5b09ae4592 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -80,6 +80,7 @@ $(eval $(call gb_Library_use_libraries,vcl,\ basegfx \ comphelper \ cppuhelper \ + drawinglayercore \ i18nlangtag \ i18nutil \ $(if $(filter OPENCL,$(BUILD_TYPE)),opencl) \ diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 0dcdd84a5d0a..52f31234caa3 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -713,4 +713,9 @@ bool OutputDevice::DrawEPS( const Point& rPoint, const Size& rSize, return bDrawn; } +bool OutputDevice::drawPrimitive2D(drawinglayer::primitive2d::Primitive2DContainer & rPrimitive2D) +{ + return false; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit c13b208131fd171cc5e07f651697787de6d88e29 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat Mar 7 14:33:43 2020 +0100 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Mon May 4 08:52:47 2020 +0200 Separate core drawinglayer func. into drawinglayercore library This separates the drawinglayer core functionallity into a separate library, to keep a strict separation what is backend dependent and what is not. More strict separation can be done at a later date. This will make it possible to push part of drawinglayer (part of processor2d) directly into VCL. Change-Id: Ibc26580067e50bf20d7cdd37fa0e44eb10200878 diff --git a/Repository.mk b/Repository.mk index 4479ed901e23..78b146096bdd 100644 --- a/Repository.mk +++ b/Repository.mk @@ -350,6 +350,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ $(call gb_Helper_optional,SCRIPTING,dlgprov) \ $(if $(filter WNT,$(OS)),directx9canvas) \ $(if $(ENABLE_OPENGL_CANVAS),oglcanvas) \ + drawinglayercore \ drawinglayer \ editeng \ $(if $(filter WNT,$(OS)),emser) \ diff --git a/drawinglayer/CppunitTest_drawinglayer_border.mk b/drawinglayer/CppunitTest_drawinglayer_border.mk index fa2f715590cd..e00006c18dba 100644 --- a/drawinglayer/CppunitTest_drawinglayer_border.mk +++ b/drawinglayer/CppunitTest_drawinglayer_border.mk @@ -21,6 +21,7 @@ $(eval $(call gb_CppunitTest_use_libraries,drawinglayer_border, \ sal \ salhelper \ drawinglayer \ + drawinglayercore \ vcl \ test \ tl \ diff --git a/drawinglayer/Library_drawinglayer.mk b/drawinglayer/Library_drawinglayer.mk index 2a0f1030a789..46f21f56b6b6 100644 --- a/drawinglayer/Library_drawinglayer.mk +++ b/drawinglayer/Library_drawinglayer.mk @@ -30,6 +30,7 @@ $(eval $(call gb_Library_use_externals,drawinglayer,\ )) $(eval $(call gb_Library_use_libraries,drawinglayer,\ + drawinglayercore \ basegfx \ canvastools \ comphelper \ @@ -67,11 +68,9 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\ drawinglayer/source/attribute/sdrsceneattribute3d \ drawinglayer/source/attribute/sdrshadowattribute \ drawinglayer/source/attribute/strokeattribute \ - drawinglayer/source/geometry/viewinformation2d \ drawinglayer/source/geometry/viewinformation3d \ drawinglayer/source/primitive2d/animatedprimitive2d \ drawinglayer/source/primitive2d/backgroundcolorprimitive2d \ - drawinglayer/source/primitive2d/baseprimitive2d \ drawinglayer/source/primitive2d/bitmapprimitive2d \ drawinglayer/source/primitive2d/borderlineprimitive2d \ drawinglayer/source/primitive2d/controlprimitive2d \ @@ -111,7 +110,6 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\ drawinglayer/source/primitive2d/PolyPolygonGraphicPrimitive2D \ drawinglayer/source/primitive2d/PolyPolygonSelectionPrimitive2D \ drawinglayer/source/primitive2d/primitivetools2d \ - drawinglayer/source/primitive2d/Primitive2DContainer \ drawinglayer/source/primitive2d/sceneprimitive2d \ drawinglayer/source/primitive2d/sdrdecompositiontools2d \ drawinglayer/source/primitive2d/shadowprimitive2d \ @@ -126,7 +124,6 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\ drawinglayer/source/primitive2d/textlineprimitive2d \ drawinglayer/source/primitive2d/textprimitive2d \ drawinglayer/source/primitive2d/textstrikeoutprimitive2d \ - drawinglayer/source/primitive2d/Tools \ drawinglayer/source/primitive2d/transformprimitive2d \ drawinglayer/source/primitive2d/transparenceprimitive2d \ drawinglayer/source/primitive2d/unifiedtransparenceprimitive2d \ diff --git a/drawinglayer/Library_drawinglayercore.mk b/drawinglayer/Library_drawinglayercore.mk new file mode 100644 index 000000000000..f1643d27014d --- /dev/null +++ b/drawinglayer/Library_drawinglayercore.mk @@ -0,0 +1,49 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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/. +# + +$(eval $(call gb_Library_Library,drawinglayercore)) + +$(eval $(call gb_Library_set_include,drawinglayercore,\ + $$(INCLUDE) \ + -I$(SRCDIR)/drawinglayer/inc \ +)) + +$(eval $(call gb_Library_add_defs,drawinglayercore,\ + -DDRAWINGLAYERCORE_DLLIMPLEMENTATION \ +)) + +$(eval $(call gb_Library_set_precompiled_header,drawinglayercore,drawinglayer/inc/pch/precompiled_drawinglayercore)) + +$(eval $(call gb_Library_use_sdk_api,drawinglayercore)) + +$(eval $(call gb_Library_use_externals,drawinglayercore,\ + boost_headers \ + libxml2 \ +)) + +$(eval $(call gb_Library_use_libraries,drawinglayercore,\ + basegfx \ + comphelper \ + cppu \ + cppuhelper \ + i18nlangtag \ + sal \ + salhelper \ + svl \ + tl \ +)) + +$(eval $(call gb_Library_add_exception_objects,drawinglayercore,\ + drawinglayer/source/primitive2d/baseprimitive2d \ + drawinglayer/source/primitive2d/Primitive2DContainer \ + drawinglayer/source/primitive2d/Tools \ + drawinglayer/source/geometry/viewinformation2d \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/drawinglayer/Module_drawinglayer.mk b/drawinglayer/Module_drawinglayer.mk index 6d329e95c60a..687cd9c2671f 100644 --- a/drawinglayer/Module_drawinglayer.mk +++ b/drawinglayer/Module_drawinglayer.mk @@ -10,6 +10,7 @@ $(eval $(call gb_Module_Module,drawinglayer)) $(eval $(call gb_Module_add_targets,drawinglayer,\ + Library_drawinglayercore \ Library_drawinglayer \ )) diff --git a/drawinglayer/inc/pch/precompiled_drawinglayer.hxx b/drawinglayer/inc/pch/precompiled_drawinglayer.hxx index 9aaf7bace296..d60954dab588 100644 --- a/drawinglayer/inc/pch/precompiled_drawinglayer.hxx +++ b/drawinglayer/inc/pch/precompiled_drawinglayer.hxx @@ -93,7 +93,6 @@ #include <basegfx/range/basicrange.hxx> #include <basegfx/tuple/b2dtuple.hxx> #include <basegfx/tuple/b3dtuple.hxx> -#include <basegfx/utils/canvastools.hxx> #include <basegfx/vector/b2dvector.hxx> #include <basegfx/vector/b2enums.hxx> #include <basegfx/vector/b2ivector.hxx> @@ -105,7 +104,7 @@ #include <com/sun/star/drawing/TextureMode.hpp> #include <com/sun/star/drawing/TextureProjectionMode.hpp> #include <com/sun/star/graphic/XPrimitive3D.hpp> -#include <com/sun/star/util/XAccounting.hpp> +#include <com/sun/star/uno/Reference.hxx> #include <comphelper/comphelperdllapi.h> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> @@ -139,7 +138,6 @@ #include <drawinglayer/drawinglayerdllapi.h> #include <drawinglayer/geometry/viewinformation2d.hxx> #include <drawinglayer/geometry/viewinformation3d.hxx> -#include <drawinglayer/primitive2d/CommonTypes.hxx> #include <drawinglayer/primitive2d/PolyPolygonColorPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonGradientPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx> @@ -147,9 +145,6 @@ #include <drawinglayer/primitive2d/PolyPolygonHatchPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonStrokePrimitive2D.hxx> -#include <drawinglayer/primitive2d/Primitive2DContainer.hxx> -#include <drawinglayer/primitive2d/Primitive2DVisitor.hxx> -#include <drawinglayer/primitive2d/Tools.hxx> #include <drawinglayer/primitive2d/baseprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> diff --git a/drawinglayer/inc/pch/precompiled_drawinglayercore.cxx b/drawinglayer/inc/pch/precompiled_drawinglayercore.cxx new file mode 100644 index 000000000000..4a8c23ea8e65 --- /dev/null +++ b/drawinglayer/inc/pch/precompiled_drawinglayercore.cxx @@ -0,0 +1,12 @@ +/* -*- 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 "precompiled_drawinglayercore.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/inc/pch/precompiled_drawinglayercore.hxx b/drawinglayer/inc/pch/precompiled_drawinglayercore.hxx new file mode 100644 index 000000000000..4cc5ca4612c9 --- /dev/null +++ b/drawinglayer/inc/pch/precompiled_drawinglayercore.hxx @@ -0,0 +1,46 @@ +/* -*- 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 has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such + manual changes will be rewritten by the next run of update_pch.sh (which presumably + also fixes all possible problems, so it's usually better to use it). + + Generated on 2020-03-07 12:37:18 using: + ./bin/update_pch drawinglayer drawinglayercore --cutoff=4 --exclude:system --exclude:module --exclude:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./drawinglayer/inc/pch/precompiled_drawinglayercore.hxx "make drawinglayer.build" --find-conflicts +*/ + +#if PCH_LEVEL >= 1 +#include <ostream> +#include <vector> +#endif // PCH_LEVEL >= 1 +#if PCH_LEVEL >= 2 +#include <osl/diagnose.h> +#include <osl/interlck.h> +#include <sal/config.h> +#include <sal/types.h> +#endif // PCH_LEVEL >= 2 +#if PCH_LEVEL >= 3 +#include <basegfx/basegfxdllapi.h> +#include <basegfx/point/b2dpoint.hxx> +#include <basegfx/range/b2drange.hxx> +#include <basegfx/range/basicrange.hxx> +#include <basegfx/tuple/b2dtuple.hxx> +#include <basegfx/utils/canvastools.hxx> +#include <basegfx/vector/b2dvector.hxx> +#endif // PCH_LEVEL >= 3 +#if PCH_LEVEL >= 4 +#include <drawinglayer/geometry/viewinformation2d.hxx> +#endif // PCH_LEVEL >= 4 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/emfio/CppunitTest_emfio_emf_test.mk b/emfio/CppunitTest_emfio_emf_test.mk index 123e4b3549bd..2679c0a604d9 100644 --- a/emfio/CppunitTest_emfio_emf_test.mk +++ b/emfio/CppunitTest_emfio_emf_test.mk @@ -23,6 +23,7 @@ $(eval $(call gb_CppunitTest_use_sdk_api,emfio_emf)) $(eval $(call gb_CppunitTest_use_libraries,emfio_emf,\ basegfx \ drawinglayer \ + drawinglayercore \ cppu \ cppuhelper \ comphelper \ diff --git a/emfio/Library_emfio.mk b/emfio/Library_emfio.mk index 52fde14885b3..89add50b781a 100644 --- a/emfio/Library_emfio.mk +++ b/emfio/Library_emfio.mk @@ -41,6 +41,7 @@ $(eval $(call gb_Library_use_sdk_api,emfio)) $(eval $(call gb_Library_use_libraries,emfio,\ basegfx \ + drawinglayercore \ drawinglayer \ cppu \ cppuhelper \ diff --git a/filter/Library_svgfilter.mk b/filter/Library_svgfilter.mk index 21318aa1fd03..1f0caf11758c 100644 --- a/filter/Library_svgfilter.mk +++ b/filter/Library_svgfilter.mk @@ -56,6 +56,7 @@ $(eval $(call gb_Library_use_libraries,svgfilter,\ sax \ salhelper \ comphelper \ + drawinglayercore \ drawinglayer \ basegfx \ cppuhelper \ diff --git a/include/drawinglayer/drawinglayerdllapi.h b/include/drawinglayer/drawinglayerdllapi.h index 0b3983504919..36a0d8abfea2 100644 --- a/include/drawinglayer/drawinglayerdllapi.h +++ b/include/drawinglayer/drawinglayerdllapi.h @@ -19,6 +19,12 @@ #endif #define DRAWINGLAYER_DLLPRIVATE SAL_DLLPRIVATE +#if defined(DRAWINGLAYERCORE_DLLIMPLEMENTATION) +#define DRAWINGLAYERCORE_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define DRAWINGLAYERCORE_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/drawinglayer/geometry/viewinformation2d.hxx b/include/drawinglayer/geometry/viewinformation2d.hxx index 95be29a72bda..06b17248d213 100644 --- a/include/drawinglayer/geometry/viewinformation2d.hxx +++ b/include/drawinglayer/geometry/viewinformation2d.hxx @@ -63,7 +63,7 @@ namespace drawinglayer::geometry It is an implementation to support the sequence of PropertyValues used in a css::graphic::XPrimitive2D for C++ implementations working with those */ -class DRAWINGLAYER_DLLPUBLIC ViewInformation2D +class DRAWINGLAYERCORE_DLLPUBLIC ViewInformation2D { public: typedef o3tl::cow_wrapper<ImpViewInformation2D, o3tl::ThreadSafeRefCountingPolicy> ImplType; diff --git a/include/drawinglayer/primitive2d/Primitive2DContainer.hxx b/include/drawinglayer/primitive2d/Primitive2DContainer.hxx index cca3a0a91485..c096e9a8cc2f 100644 --- a/include/drawinglayer/primitive2d/Primitive2DContainer.hxx +++ b/include/drawinglayer/primitive2d/Primitive2DContainer.hxx @@ -34,7 +34,7 @@ class ViewInformation2D; namespace drawinglayer::primitive2d { -class SAL_WARN_UNUSED DRAWINGLAYER_DLLPUBLIC Primitive2DContainer +class SAL_WARN_UNUSED DRAWINGLAYERCORE_DLLPUBLIC Primitive2DContainer : public std::deque<Primitive2DReference>, public Primitive2DDecompositionVisitor { diff --git a/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx b/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx index dfe04b32a320..e174d1e0878d 100644 --- a/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx +++ b/include/drawinglayer/primitive2d/Primitive2DVisitor.hxx @@ -27,7 +27,7 @@ namespace drawinglayer::primitive2d class Primitive2DContainer; // Visitor class for walking a tree of Primitive2DReference -class DRAWINGLAYER_DLLPUBLIC Primitive2DDecompositionVisitor +class DRAWINGLAYERCORE_DLLPUBLIC Primitive2DDecompositionVisitor { public: virtual void append(const Primitive2DReference&) = 0; diff --git a/include/drawinglayer/primitive2d/Tools.hxx b/include/drawinglayer/primitive2d/Tools.hxx index fbb6f5717c01..1c30565c8c1b 100644 --- a/include/drawinglayer/primitive2d/Tools.hxx +++ b/include/drawinglayer/primitive2d/Tools.hxx @@ -31,16 +31,16 @@ class ViewInformation2D; namespace drawinglayer::primitive2d { /// get B2DRange from a given Primitive2DReference -basegfx::B2DRange DRAWINGLAYER_DLLPUBLIC getB2DRangeFromPrimitive2DReference( +basegfx::B2DRange DRAWINGLAYERCORE_DLLPUBLIC getB2DRangeFromPrimitive2DReference( const Primitive2DReference& rCandidate, const geometry::ViewInformation2D& aViewInformation); /** compare two Primitive2DReferences for equality, including trying to get implementations (BasePrimitive2D) and using compare operator */ -bool DRAWINGLAYER_DLLPUBLIC arePrimitive2DReferencesEqual(const Primitive2DReference& rA, - const Primitive2DReference& rB); +bool DRAWINGLAYERCORE_DLLPUBLIC arePrimitive2DReferencesEqual(const Primitive2DReference& rA, + const Primitive2DReference& rB); -OUString DRAWINGLAYER_DLLPUBLIC idToString(sal_uInt32 nId); +OUString DRAWINGLAYERCORE_DLLPUBLIC idToString(sal_uInt32 nId); } // end of namespace drawinglayer::primitive2d diff --git a/include/drawinglayer/primitive2d/baseprimitive2d.hxx b/include/drawinglayer/primitive2d/baseprimitive2d.hxx index 5e1a96429ff3..8818cdd0bcde 100644 --- a/include/drawinglayer/primitive2d/baseprimitive2d.hxx +++ b/include/drawinglayer/primitive2d/baseprimitive2d.hxx @@ -121,8 +121,8 @@ typedef cppu::WeakComponentImplHelper<css::graphic::XPrimitive2D, css::util::XAc for view-independent primitives which are defined by not using ViewInformation2D in their get2DDecomposition/getB2DRange implementations. */ -class DRAWINGLAYER_DLLPUBLIC BasePrimitive2D : protected cppu::BaseMutex, - public BasePrimitive2DImplBase +class DRAWINGLAYERCORE_DLLPUBLIC BasePrimitive2D : protected cppu::BaseMutex, + public BasePrimitive2DImplBase { BasePrimitive2D(const BasePrimitive2D&) = delete; BasePrimitive2D& operator=(const BasePrimitive2D&) = delete; @@ -200,7 +200,7 @@ public: to identify if a new decomposition is needed at the next call (f) return maBuffered2DDecomposition */ -class DRAWINGLAYER_DLLPUBLIC BufferedDecompositionPrimitive2D : public BasePrimitive2D +class DRAWINGLAYERCORE_DLLPUBLIC BufferedDecompositionPrimitive2D : public BasePrimitive2D { private: /// a sequence used for buffering the last create2DDecomposition() result diff --git a/sc/CppunitTest_sc_ucalc.mk b/sc/CppunitTest_sc_ucalc.mk index 8943de7ab4c3..60fb6676dab9 100644 --- a/sc/CppunitTest_sc_ucalc.mk +++ b/sc/CppunitTest_sc_ucalc.mk @@ -49,6 +49,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_ucalc, \ cppuhelper \ dbtools \ drawinglayer \ + drawinglayercore \ editeng \ for \ forui \ diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk index 997b14c0add9..b540b27c9834 100644 --- a/sc/Library_sc.mk +++ b/sc/Library_sc.mk @@ -70,6 +70,7 @@ $(eval $(call gb_Library_use_libraries,sc,\ cppu \ cppuhelper \ dbtools \ + drawinglayercore \ drawinglayer \ editeng \ for \ diff --git a/sd/CppunitTest_sd_uimpress.mk b/sd/CppunitTest_sd_uimpress.mk index 93426dfc3a55..63f143978231 100644 --- a/sd/CppunitTest_sd_uimpress.mk +++ b/sd/CppunitTest_sd_uimpress.mk @@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_uimpress,\ cppu \ cppuhelper \ drawinglayer \ + drawinglayercore \ editeng \ i18nlangtag \ i18nutil \ diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk index 43b168be8d8c..24520633e77f 100644 --- a/sd/Library_sd.mk +++ b/sd/Library_sd.mk @@ -74,6 +74,7 @@ $(eval $(call gb_Library_use_libraries,sd,\ cppcanvas \ cppu \ cppuhelper \ + drawinglayercore \ drawinglayer \ editeng \ i18nlangtag \ diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index 67a66ef2d211..a6d6b7d6b71a 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -49,6 +49,7 @@ $(eval $(call gb_Library_use_libraries,sfx,\ comphelper \ cppu \ cppuhelper \ + drawinglayercore \ drawinglayer \ fwe \ i18nlangtag \ diff --git a/svgio/CppunitTest_svgio.mk b/svgio/CppunitTest_svgio.mk index c6f4db91fc60..24fb7a39af32 100644 --- a/svgio/CppunitTest_svgio.mk +++ b/svgio/CppunitTest_svgio.mk @@ -30,6 +30,7 @@ $(eval $(call gb_CppunitTest_use_library_objects,svgio,\ $(eval $(call gb_CppunitTest_use_libraries,svgio,\ basegfx \ drawinglayer \ + drawinglayercore \ cppu \ cppuhelper \ comphelper \ diff --git a/svgio/Library_svgio.mk b/svgio/Library_svgio.mk index 449c17f61196..7ef1aeb19513 100644 --- a/svgio/Library_svgio.mk +++ b/svgio/Library_svgio.mk @@ -33,6 +33,7 @@ $(eval $(call gb_Library_use_sdk_api,svgio)) $(eval $(call gb_Library_use_libraries,svgio,\ basegfx \ + drawinglayercore \ drawinglayer \ comphelper \ cppu \ diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk index 92feb45d6578..c78b8d7769eb 100644 --- a/svx/CppunitTest_svx_unit.mk +++ b/svx/CppunitTest_svx_unit.mk @@ -35,6 +35,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ basegfx \ drawinglayer \ + drawinglayercore \ sal \ sfx \ svxcore \ diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index d3eff20b6769..9ccba33a748c 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -50,6 +50,7 @@ $(eval $(call gb_Library_use_libraries,svx,\ crashreport) \ $(call gb_Helper_optional,DBCONNECTIVITY, \ dbtools) \ + drawinglayercore \ drawinglayer \ editeng \ fwe \ diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk index 222d69bb6c8a..7a9b31e58b77 100644 --- a/svx/Library_svxcore.mk +++ b/svx/Library_svxcore.mk @@ -57,6 +57,7 @@ $(eval $(call gb_Library_use_libraries,svxcore,\ cppu \ $(call gb_Helper_optional,DBCONNECTIVITY, \ dbtools) \ + drawinglayercore \ drawinglayer \ editeng \ fwe \ diff --git a/sw/CppunitTest_sw_uwriter.mk b/sw/CppunitTest_sw_uwriter.mk index 6b9ffa4ba683..a881587735e4 100644 --- a/sw/CppunitTest_sw_uwriter.mk +++ b/sw/CppunitTest_sw_uwriter.mk @@ -33,6 +33,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uwriter, \ $(call gb_Helper_optional,DBCONNECTIVITY, \ dbtools) \ drawinglayer \ + drawinglayercore \ editeng \ i18nlangtag \ i18nutil \ diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk index b6d75fd890bf..d99c59a58a4b 100644 --- a/sw/Library_sw.mk +++ b/sw/Library_sw.mk @@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_libraries,sw,\ cppuhelper \ $(call gb_Helper_optional,DBCONNECTIVITY, \ dbtools) \ + drawinglayercore \ drawinglayer \ editeng \ i18nlangtag \ diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index 99f1dd20ae3d..4c09d1cc4bda 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -75,6 +75,7 @@ $(eval $(call gb_Library_use_libraries,swui,\ ucbhelper \ utl \ vcl \ + drawinglayercore \ drawinglayer \ )) commit 029194643d0ba7d76df28bc21eec4a27492eea99 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun May 3 11:34:51 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:43:35 2020 +0200 drawinglayer: extract constant in renderWrongSpellPrimitive2D Change-Id: I131e2d5620d027f32dc2929cd12fedb168e30e9c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93390 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx index 27df21201efe..9f838a7e1b61 100644 --- a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx +++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx @@ -28,6 +28,11 @@ using namespace css; namespace drawinglayer { +namespace +{ +constexpr sal_uInt32 constMinimumFontHeight = 5; // #define WRONG_SHOW_MIN 5 +} + bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate, OutputDevice& rOutputDevice, const basegfx::B2DHomMatrix& rObjectToViewTransformation, @@ -38,9 +43,7 @@ bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWron const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0)); const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength())); - static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5 - - if (nFontPixelHeight <= nMinimumFontHeight) + if (nFontPixelHeight <= constMinimumFontHeight) return true; const basegfx::B2DPoint aStart(aLocalTransform commit 2f844056c340ead941188fd1ea7ad2b1400586aa Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sun May 3 11:32:25 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:43:21 2020 +0200 drawinglayer: flatten renderWrongSpellPrimitive2D Change-Id: I93ff19f9f54b6f14c660af554d697b9ba525f81c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93389 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx index 83fdba7cc1f5..27df21201efe 100644 --- a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx +++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx @@ -40,30 +40,30 @@ bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWron static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5 - if (nFontPixelHeight > nMinimumFontHeight) - { - const basegfx::B2DPoint aStart(aLocalTransform - * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0)); - const basegfx::B2DPoint aStop(aLocalTransform - * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0)); - const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY())); - const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY())); + if (nFontPixelHeight <= nMinimumFontHeight) + return true; - // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device, - // e.g. when used with mask/transparence buffer device - const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin()); + const basegfx::B2DPoint aStart(aLocalTransform + * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0)); + const basegfx::B2DPoint aStop(aLocalTransform + * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0)); + const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY())); + const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY())); - const basegfx::BColor aProcessedColor( - rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor())); - const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled()); + // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device, + // e.g. when used with mask/transparence buffer device + const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin()); - vcl::ScopedAntialiasing a(rOutputDevice, true); - rOutputDevice.EnableMapMode(false); - rOutputDevice.SetLineColor(Color(aProcessedColor)); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop); - rOutputDevice.EnableMapMode(bMapModeEnabledState); - } + const basegfx::BColor aProcessedColor( + rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor())); + const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled()); + + vcl::ScopedAntialiasing a(rOutputDevice, true); + rOutputDevice.EnableMapMode(false); + rOutputDevice.SetLineColor(Color(aProcessedColor)); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop); + rOutputDevice.EnableMapMode(bMapModeEnabledState); // cannot really go wrong return true; commit e4f72f84661fba50937891e28f73f6661edaa21e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 23:38:44 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:43:03 2020 +0200 remove helperwrongspellrenderer.{cxx,hxx} from clang-format blacklist Change-Id: Ib0b1f389189012ab27dd061481737ac6a6a1a84e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93388 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx index c359b3485bc6..83fdba7cc1f5 100644 --- a/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx +++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.cxx @@ -28,43 +28,46 @@ using namespace css; namespace drawinglayer { - bool renderWrongSpellPrimitive2D( - const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate, - OutputDevice& rOutputDevice, - const basegfx::B2DHomMatrix& rObjectToViewTransformation, - const basegfx::BColorModifierStack& rBColorModifierStack) - { - const basegfx::B2DHomMatrix aLocalTransform(rObjectToViewTransformation * rWrongSpellCandidate.getTransformation()); - const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0)); - const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength())); - - static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5 +bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate, + OutputDevice& rOutputDevice, + const basegfx::B2DHomMatrix& rObjectToViewTransformation, + const basegfx::BColorModifierStack& rBColorModifierStack) +{ + const basegfx::B2DHomMatrix aLocalTransform(rObjectToViewTransformation + * rWrongSpellCandidate.getTransformation()); + const basegfx::B2DVector aFontVectorPixel(aLocalTransform * basegfx::B2DVector(0.0, 1.0)); + const sal_uInt32 nFontPixelHeight(basegfx::fround(aFontVectorPixel.getLength())); - if(nFontPixelHeight > nMinimumFontHeight) - { - const basegfx::B2DPoint aStart(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0)); - const basegfx::B2DPoint aStop(aLocalTransform * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0)); - const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY())); - const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY())); + static const sal_uInt32 nMinimumFontHeight(5); // #define WRONG_SHOW_MIN 5 - // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device, - // e.g. when used with mask/transparence buffer device - const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin()); + if (nFontPixelHeight > nMinimumFontHeight) + { + const basegfx::B2DPoint aStart(aLocalTransform + * basegfx::B2DPoint(rWrongSpellCandidate.getStart(), 0.0)); + const basegfx::B2DPoint aStop(aLocalTransform + * basegfx::B2DPoint(rWrongSpellCandidate.getStop(), 0.0)); + const Point aVclStart(basegfx::fround(aStart.getX()), basegfx::fround(aStart.getY())); + const Point aVclStop(basegfx::fround(aStop.getX()), basegfx::fround(aStop.getY())); - const basegfx::BColor aProcessedColor(rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor())); - const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled()); + // #i101075# draw it. Do not forget to use the evtl. offsetted origin of the target device, + // e.g. when used with mask/transparence buffer device + const Point aOrigin(rOutputDevice.GetMapMode().GetOrigin()); - vcl::ScopedAntialiasing a(rOutputDevice, true); - rOutputDevice.EnableMapMode(false); - rOutputDevice.SetLineColor(Color(aProcessedColor)); - rOutputDevice.SetFillColor(); - rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop); - rOutputDevice.EnableMapMode(bMapModeEnabledState); - } + const basegfx::BColor aProcessedColor( + rBColorModifierStack.getModifiedColor(rWrongSpellCandidate.getColor())); + const bool bMapModeEnabledState(rOutputDevice.IsMapModeEnabled()); - // cannot really go wrong - return true; + vcl::ScopedAntialiasing a(rOutputDevice, true); + rOutputDevice.EnableMapMode(false); + rOutputDevice.SetLineColor(Color(aProcessedColor)); + rOutputDevice.SetFillColor(); + rOutputDevice.DrawWaveLine(aOrigin + aVclStart, aOrigin + aVclStop); + rOutputDevice.EnableMapMode(bMapModeEnabledState); } + + // cannot really go wrong + return true; +} } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx index 9ca43f705c1f..886ce99bb7ff 100644 --- a/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx +++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx @@ -21,13 +21,15 @@ class OutputDevice; -namespace drawinglayer::primitive2d { - class WrongSpellPrimitive2D; +namespace drawinglayer::primitive2d +{ +class WrongSpellPrimitive2D; } -namespace basegfx { - class B2DHomMatrix; - class BColorModifierStack; +namespace basegfx +{ +class B2DHomMatrix; +class BColorModifierStack; } // support WrongSpell rendering using VCL from primitives due to VCLs nice @@ -35,11 +37,10 @@ namespace basegfx { namespace drawinglayer { - bool renderWrongSpellPrimitive2D( - const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate, - OutputDevice& rOutputDevice, - const basegfx::B2DHomMatrix& rObjectToViewTransformation, - const basegfx::BColorModifierStack& rBColorModifierStack); +bool renderWrongSpellPrimitive2D(const primitive2d::WrongSpellPrimitive2D& rWrongSpellCandidate, + OutputDevice& rOutputDevice, + const basegfx::B2DHomMatrix& rObjectToViewTransformation, + const basegfx::BColorModifierStack& rBColorModifierStack); } // end of namespace drawinglayer diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 298745b86375..db09c4a5d8a9 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -3744,8 +3744,6 @@ drawinglayer/source/processor2d/baseprocessor2d.cxx drawinglayer/source/processor2d/contourextractor2d.cxx drawinglayer/source/processor2d/getdigitlanguage.cxx drawinglayer/source/processor2d/getdigitlanguage.hxx -drawinglayer/source/processor2d/helperwrongspellrenderer.cxx -drawinglayer/source/processor2d/helperwrongspellrenderer.hxx drawinglayer/source/processor2d/hittestprocessor2d.cxx drawinglayer/source/processor2d/linegeometryextractor2d.cxx drawinglayer/source/processor2d/objectinfoextractor2d.cxx commit a57a6d145f7c91cc1ba51f73ea7be217f5837be7 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 23:35:27 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:42:46 2020 +0200 pragma once in helperwrongspellrenderer.hxx Change-Id: I25aac069b9212824fee50240a1b6682bf7e6f0f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93387 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx b/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx index 08210a4b02d7..9ca43f705c1f 100644 --- a/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx +++ b/drawinglayer/source/processor2d/helperwrongspellrenderer.hxx @@ -17,24 +17,19 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_HELPERWRONGSPELLRENDERER_HXX -#define INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_HELPERWRONGSPELLRENDERER_HXX - - -// predefines +#pragma once class OutputDevice; -namespace drawinglayer { namespace primitive2d { +namespace drawinglayer::primitive2d { class WrongSpellPrimitive2D; -}} +} namespace basegfx { class B2DHomMatrix; class BColorModifierStack; } - // support WrongSpell rendering using VCL from primitives due to VCLs nice // and fast solution with wavelines @@ -48,7 +43,4 @@ namespace drawinglayer } // end of namespace drawinglayer - -#endif // INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_HELPERWRONGSPELLRENDERER_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit e360fb8a316215e6b2d2d27be24b038f0b16a82c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 23:09:53 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:42:10 2020 +0200 organize includes in vclpixelprocessor2d.cxx Change-Id: I1590e437946aaa4bd3a8b6a2c47d2ee17d2060a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93386 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx index f09c6ad0fd76..bba66e2d4272 100644 --- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx @@ -19,8 +19,16 @@ #include "vclpixelprocessor2d.hxx" #include "vclhelperbufferdevice.hxx" +#include "helperwrongspellrenderer.hxx" + +#include <sal/log.hxx> +#include <tools/stream.hxx> #include <vcl/BitmapFilterStackBlur.hxx> #include <vcl/outdev.hxx> +#include <vcl/dibtools.hxx> +#include <vcl/hatch.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> + #include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx> #include <drawinglayer/primitive2d/Tools.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> @@ -41,25 +49,19 @@ #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> #include <drawinglayer/primitive2d/glowprimitive2d.hxx> -#include <primitive2d/pointarrayprimitive2d.hxx> #include <drawinglayer/primitive2d/wrongspellprimitive2d.hxx> #include <drawinglayer/primitive2d/controlprimitive2d.hxx> #include <drawinglayer/primitive2d/borderlineprimitive2d.hxx> -#include <com/sun/star/awt/XWindow2.hpp> #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> -#include "helperwrongspellrenderer.hxx" -#include <primitive2d/fillhatchprimitive2d.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> -#include <vcl/hatch.hxx> -#include <sal/log.hxx> -#include <com/sun/star/awt/XControl.hpp> #include <drawinglayer/primitive2d/backgroundcolorprimitive2d.hxx> -#include <primitive2d/epsprimitive2d.hxx> #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> +#include <primitive2d/pointarrayprimitive2d.hxx> +#include <primitive2d/fillhatchprimitive2d.hxx> +#include <primitive2d/epsprimitive2d.hxx> -#include <vcl/dibtools.hxx> -#include <tools/stream.hxx> +#include <com/sun/star/awt/XWindow2.hpp> +#include <com/sun/star/awt/XControl.hpp> using namespace com::sun::star; commit 94d5587e013ba61091d90d6636d0e6f320ac5615 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 23:05:12 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:41:55 2020 +0200 organize includes in vclprocessor2d.cxx Change-Id: I1117eb86823762882d463c6e4d3b295efaa3151c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93365 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx index c5460f0433e1..96b0bf9a97b5 100644 --- a/drawinglayer/source/processor2d/vclprocessor2d.cxx +++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx @@ -17,16 +17,27 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include "vclprocessor2d.hxx" + +#include "getdigitlanguage.hxx" +#include "vclhelperbufferdevice.hxx" #include <cmath> #include <comphelper/string.hxx> -#include "vclprocessor2d.hxx" -#include <drawinglayer/primitive2d/textprimitive2d.hxx> -#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> #include <tools/debug.hxx> +#include <vcl/graph.hxx> #include <vcl/outdev.hxx> +#include <rtl/ustrbuf.hxx> +#include <sal/log.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <basegfx/polygon/b2dpolygontools.hxx> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <basegfx/polygon/b2dpolygonclipper.hxx> +#include <basegfx/color/bcolor.hxx> +#include <basegfx/matrix/b2dhommatrixtools.hxx> +#include <drawinglayer/primitive2d/textprimitive2d.hxx> +#include <drawinglayer/primitive2d/textdecoratedprimitive2d.hxx> #include <drawinglayer/primitive2d/polygonprimitive2d.hxx> #include <drawinglayer/primitive2d/bitmapprimitive2d.hxx> -#include <basegfx/polygon/b2dpolygontools.hxx> #include <drawinglayer/primitive2d/fillgraphicprimitive2d.hxx> #include <drawinglayer/primitive2d/PolyPolygonHairlinePrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonMarkerPrimitive2D.hxx> @@ -37,36 +48,21 @@ #include <drawinglayer/primitive2d/PolyPolygonGraphicPrimitive2D.hxx> #include <drawinglayer/primitive2d/PolyPolygonSelectionPrimitive2D.hxx> #include <drawinglayer/primitive2d/maskprimitive2d.hxx> -#include <basegfx/polygon/b2dpolypolygontools.hxx> -#include "vclhelperbufferdevice.hxx" #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/transparenceprimitive2d.hxx> #include <drawinglayer/primitive2d/transformprimitive2d.hxx> #include <drawinglayer/primitive2d/markerarrayprimitive2d.hxx> -#include <primitive2d/pointarrayprimitive2d.hxx> #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx> -#include <rtl/ustrbuf.hxx> -#include <sal/log.hxx> #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx> -#include <primitive2d/epsprimitive2d.hxx> #include <drawinglayer/primitive2d/svggradientprimitive2d.hxx> -#include <basegfx/color/bcolor.hxx> -#include <basegfx/matrix/b2dhommatrixtools.hxx> -#include <vcl/graph.hxx> - -#include "getdigitlanguage.hxx" - -// control support - -#include <drawinglayer/primitive2d/textlayoutdevice.hxx> - -#include <basegfx/polygon/b2dpolygonclipper.hxx> - // for support of Title/Description in all apps when embedding pictures #include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx> +// control support +#include <drawinglayer/primitive2d/textlayoutdevice.hxx> -#include <toolkit/helper/vclunohelper.hxx> +#include <primitive2d/pointarrayprimitive2d.hxx> +#include <primitive2d/epsprimitive2d.hxx> using namespace com::sun::star; commit 8e63a3623a05713154d798081b13374a819fa84f Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 21:16:42 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:41:20 2020 +0200 dl: replace OSL_ENSURE with SAL_WARN_IF in impBufferDevice Change-Id: I457b9310109157da03b6c310783651f5232d2054 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93364 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index 54206abf7aa5..534c512daa42 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -219,7 +219,8 @@ void VDevBuffer::free(VirtualDevice& rDevice) { ::osl::MutexGuard aGuard(m_aMutex); const auto aUsedFound = std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice); - OSL_ENSURE(aUsedFound != maUsedBuffers.end(), "OOps, non-registered buffer freed (!)"); + SAL_WARN_IF(aUsedFound == maUsedBuffers.end(), "drawinglayer", + "OOps, non-registered buffer freed (!)"); maUsedBuffers.erase(aUsedFound); maFreeBuffers.emplace_back(&rDevice); @@ -286,8 +287,8 @@ impBufferDevice::impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& #endif // #i93485# assert when copying from window to VDev is used - OSL_ENSURE( - mrOutDev.GetOutDevType() != OUTDEV_WINDOW, + SAL_WARN_IF( + mrOutDev.GetOutDevType() == OUTDEV_WINDOW, "drawinglayer", "impBufferDevice render helper: Copying from Window to VDev, this should be avoided (!)"); const bool bWasEnabledSrc(mrOutDev.IsMapModeEnabled()); @@ -424,13 +425,15 @@ void impBufferDevice::paint(double fTrans) VirtualDevice& impBufferDevice::getContent() { - assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); + SAL_WARN_IF(!mpContent, "drawinglayer", + "impBufferDevice: No content, check isVisible() before accessing (!)"); return *mpContent; } VirtualDevice& impBufferDevice::getMask() { - assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); + SAL_WARN_IF(!mpContent, "drawinglayer", + "impBufferDevice: No content, check isVisible() before accessing (!)"); if (!mpMask) { mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, true); @@ -444,7 +447,8 @@ VirtualDevice& impBufferDevice::getMask() VirtualDevice& impBufferDevice::getTransparence() { - OSL_ENSURE(mpContent, "impBufferDevice: No content, check isVisible() before accessing (!)"); + SAL_WARN_IF(!mpContent, "drawinglayer", + "impBufferDevice: No content, check isVisible() before accessing (!)"); if (!mpAlpha) { mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); commit f256d5d5cb3f715325c2bff03c2cca2046bbf97c Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 21:07:23 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:41:05 2020 +0200 drawinglayer: remove aBuffer typedef in VDevBuffer Also use back() method on vector instead of end() - 1 Change-Id: I944691d097f82b1651cff87a7bb0d7c457ece27a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93363 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index 53ecdd4ee685..54206abf7aa5 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -39,16 +39,14 @@ namespace { -typedef std::vector<VclPtr<VirtualDevice>> aBuffers; - class VDevBuffer : public Timer, protected cppu::BaseMutex { private: // available buffers - aBuffers maFreeBuffers; + std::vector<VclPtr<VirtualDevice>> maFreeBuffers; // allocated/used buffers (remembered to allow deleting them in destructor) - aBuffers maUsedBuffers; + std::vector<VclPtr<VirtualDevice>> maUsedBuffers; // remember what outputdevice was the template passed to VirtualDevice::Create // so we can test if that OutputDevice was disposed before reusing a @@ -83,13 +81,13 @@ VDevBuffer::~VDevBuffer() while (!maFreeBuffers.empty()) { - (*(maFreeBuffers.end() - 1)).disposeAndClear(); + maFreeBuffers.back().disposeAndClear(); maFreeBuffers.pop_back(); } while (!maUsedBuffers.empty()) { - (*(maUsedBuffers.end() - 1)).disposeAndClear(); + maUsedBuffers.back().disposeAndClear(); maUsedBuffers.pop_back(); } } @@ -105,9 +103,9 @@ VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSize bool bOkay(false); if (!maFreeBuffers.empty()) { - aBuffers::iterator aFound(maFreeBuffers.end()); + auto aFound(maFreeBuffers.end()); - for (aBuffers::iterator a(maFreeBuffers.begin()); a != maFreeBuffers.end(); ++a) + for (auto a = maFreeBuffers.begin(); a != maFreeBuffers.end(); ++a) { assert(*a && "Empty pointer in VDevBuffer (!)"); @@ -220,8 +218,7 @@ VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSize void VDevBuffer::free(VirtualDevice& rDevice) { ::osl::MutexGuard aGuard(m_aMutex); - const aBuffers::iterator aUsedFound( - std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice)); + const auto aUsedFound = std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice); OSL_ENSURE(aUsedFound != maUsedBuffers.end(), "OOps, non-registered buffer freed (!)"); maUsedBuffers.erase(aUsedFound); @@ -237,9 +234,9 @@ void VDevBuffer::Invoke() while (!maFreeBuffers.empty()) { - aBuffers::iterator aLastOne(maFreeBuffers.end() - 1); - maDeviceTemplates.erase(*aLastOne); - aLastOne->disposeAndClear(); + auto aLastOne = maFreeBuffers.back(); + maDeviceTemplates.erase(aLastOne); + aLastOne.disposeAndClear(); maFreeBuffers.pop_back(); } } commit e5889bb63a20061b3986afff5e64062c8db3fd64 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 19:33:57 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:40:50 2020 +0200 remove vclhelperbufferdevice.{cxx,hxx} from clang-format blacklist Change-Id: I0ab6572ab700756322f96b982f7faeb6d8dc9fb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93362 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx index f362559d12bf..53ecdd4ee685 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx @@ -35,422 +35,430 @@ #include <vcl/lazydelete.hxx> #include <vcl/dibtools.hxx> - // buffered VDev usage namespace { - typedef std::vector< VclPtr<VirtualDevice> > aBuffers; - - class VDevBuffer : public Timer, protected cppu::BaseMutex - { - private: - // available buffers - aBuffers maFreeBuffers; - - // allocated/used buffers (remembered to allow deleting them in destructor) - aBuffers maUsedBuffers; - - // remember what outputdevice was the template passed to VirtualDevice::Create - // so we can test if that OutputDevice was disposed before reusing a - // virtualdevice because that isn't safe to do at least for Gtk2 - std::map< VclPtr<VirtualDevice>, VclPtr<OutputDevice> > maDeviceTemplates; +typedef std::vector<VclPtr<VirtualDevice>> aBuffers; - public: - VDevBuffer(); - virtual ~VDevBuffer() override; - - VclPtr<VirtualDevice> alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome); - void free(VirtualDevice& rDevice); +class VDevBuffer : public Timer, protected cppu::BaseMutex +{ +private: + // available buffers + aBuffers maFreeBuffers; + + // allocated/used buffers (remembered to allow deleting them in destructor) + aBuffers maUsedBuffers; + + // remember what outputdevice was the template passed to VirtualDevice::Create + // so we can test if that OutputDevice was disposed before reusing a + // virtualdevice because that isn't safe to do at least for Gtk2 + std::map<VclPtr<VirtualDevice>, VclPtr<OutputDevice>> maDeviceTemplates; + +public: + VDevBuffer(); + virtual ~VDevBuffer() override; + + VclPtr<VirtualDevice> alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, + bool bMonoChrome); + void free(VirtualDevice& rDevice); + + // Timer virtuals + virtual void Invoke() override; +}; + +VDevBuffer::VDevBuffer() + : Timer("VDevBuffer timer") + , maFreeBuffers() + , maUsedBuffers() +{ + SetTimeout(10L * 1000L); // ten seconds + SetDebugName("drawinglayer::VDevBuffer via Invoke()"); +} - // Timer virtuals - virtual void Invoke() override; - }; +VDevBuffer::~VDevBuffer() +{ + ::osl::MutexGuard aGuard(m_aMutex); + Stop(); - VDevBuffer::VDevBuffer() - : Timer("VDevBuffer timer"), - maFreeBuffers(), - maUsedBuffers() + while (!maFreeBuffers.empty()) { - SetTimeout(10L * 1000L); // ten seconds - SetDebugName("drawinglayer::VDevBuffer via Invoke()"); + (*(maFreeBuffers.end() - 1)).disposeAndClear(); + maFreeBuffers.pop_back(); } - VDevBuffer::~VDevBuffer() + while (!maUsedBuffers.empty()) { - ::osl::MutexGuard aGuard(m_aMutex); - Stop(); + (*(maUsedBuffers.end() - 1)).disposeAndClear(); + maUsedBuffers.pop_back(); + } +} - while(!maFreeBuffers.empty()) - { - (*(maFreeBuffers.end() - 1)).disposeAndClear(); - maFreeBuffers.pop_back(); - } +VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, + bool bMonoChrome) +{ + ::osl::MutexGuard aGuard(m_aMutex); + VclPtr<VirtualDevice> pRetval; - while(!maUsedBuffers.empty()) - { - (*(maUsedBuffers.end() - 1)).disposeAndClear(); - maUsedBuffers.pop_back(); - } - } + sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); - VclPtr<VirtualDevice> VDevBuffer::alloc(OutputDevice& rOutDev, const Size& rSizePixel, bool bClear, bool bMonoChrome) + bool bOkay(false); + if (!maFreeBuffers.empty()) { - ::osl::MutexGuard aGuard(m_aMutex); - VclPtr<VirtualDevice> pRetval; + aBuffers::iterator aFound(maFreeBuffers.end()); - sal_Int32 nBits = bMonoChrome ? 1 : rOutDev.GetBitCount(); - - bool bOkay(false); - if(!maFreeBuffers.empty()) + for (aBuffers::iterator a(maFreeBuffers.begin()); a != maFreeBuffers.end(); ++a) { - aBuffers::iterator aFound(maFreeBuffers.end()); + assert(*a && "Empty pointer in VDevBuffer (!)"); - for(aBuffers::iterator a(maFreeBuffers.begin()); a != maFreeBuffers.end(); ++a) + if (nBits == (*a)->GetBitCount()) { - assert(*a && "Empty pointer in VDevBuffer (!)"); - - if (nBits == (*a)->GetBitCount()) + // candidate is valid due to bit depth + if (aFound != maFreeBuffers.end()) { - // candidate is valid due to bit depth - if(aFound != maFreeBuffers.end()) + // already found + if (bOkay) { - // already found - if(bOkay) + // found is valid + const bool bCandidateOkay( + (*a)->GetOutputWidthPixel() >= rSizePixel.getWidth() + && (*a)->GetOutputHeightPixel() >= rSizePixel.getHeight()); + + if (bCandidateOkay) { - // found is valid - const bool bCandidateOkay((*a)->GetOutputWidthPixel() >= rSizePixel.getWidth() && (*a)->GetOutputHeightPixel() >= rSizePixel.getHeight()); + // found and candidate are valid + const sal_uLong aSquare((*aFound)->GetOutputWidthPixel() + * (*aFound)->GetOutputHeightPixel()); + const sal_uLong aCandidateSquare((*a)->GetOutputWidthPixel() + * (*a)->GetOutputHeightPixel()); - if(bCandidateOkay) - { - // found and candidate are valid - const sal_uLong aSquare((*aFound)->GetOutputWidthPixel() * (*aFound)->GetOutputHeightPixel()); - const sal_uLong aCandidateSquare((*a)->GetOutputWidthPixel() * (*a)->GetOutputHeightPixel()); - - if(aCandidateSquare < aSquare) - { - // candidate is valid and smaller, use it - aFound = a; - } - } - else + if (aCandidateSquare < aSquare) { - // found is valid, candidate is not. Keep found + // candidate is valid and smaller, use it + aFound = a; } } else { - // found is invalid, use candidate - aFound = a; - bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); + // found is valid, candidate is not. Keep found } } else { - // none yet, use candidate + // found is invalid, use candidate aFound = a; - bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); - } - } - } - - if(aFound != maFreeBuffers.end()) - { - pRetval = *aFound; - maFreeBuffers.erase(aFound); - } - } - - if (pRetval) - { - // found a suitable cached virtual device, but the - // outputdevice it was based on has been disposed, - // drop it and create a new one instead as reusing - // such devices is unsafe under at least Gtk2 - if (maDeviceTemplates[pRetval]->isDisposed()) - { - maDeviceTemplates.erase(pRetval); - pRetval.disposeAndClear(); - } - else - { - if (bOkay) - { - if (bClear) - { - pRetval->Erase(::tools::Rectangle(0, 0, rSizePixel.getWidth(), rSizePixel.getHeight())); + bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() + && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); } } else { - pRetval->SetOutputSizePixel(rSizePixel, bClear); + // none yet, use candidate + aFound = a; + bOkay = (*aFound)->GetOutputWidthPixel() >= rSizePixel.getWidth() + && (*aFound)->GetOutputHeightPixel() >= rSizePixel.getHeight(); } } } - // no success yet, create new buffer - if(!pRetval) + if (aFound != maFreeBuffers.end()) { - pRetval = VclPtr<VirtualDevice>::Create(rOutDev, bMonoChrome ? DeviceFormat::BITMASK : DeviceFormat::DEFAULT); - maDeviceTemplates[pRetval] = &rOutDev; - pRetval->SetOutputSizePixel(rSizePixel, bClear); + pRetval = *aFound; + maFreeBuffers.erase(aFound); + } + } + + if (pRetval) + { + // found a suitable cached virtual device, but the + // outputdevice it was based on has been disposed, + // drop it and create a new one instead as reusing + // such devices is unsafe under at least Gtk2 + if (maDeviceTemplates[pRetval]->isDisposed()) + { + maDeviceTemplates.erase(pRetval); + pRetval.disposeAndClear(); } else { - // reused, reset some values - pRetval->SetMapMode(); - pRetval->SetRasterOp(RasterOp::OverPaint); + if (bOkay) + { + if (bClear) + { + pRetval->Erase( + ::tools::Rectangle(0, 0, rSizePixel.getWidth(), rSizePixel.getHeight())); + } + } + else + { + pRetval->SetOutputSizePixel(rSizePixel, bClear); + } } - - // remember allocated buffer - maUsedBuffers.push_back(pRetval); - - return pRetval; } - void VDevBuffer::free(VirtualDevice& rDevice) + // no success yet, create new buffer + if (!pRetval) { - ::osl::MutexGuard aGuard(m_aMutex); - const aBuffers::iterator aUsedFound(std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice)); - OSL_ENSURE(aUsedFound != maUsedBuffers.end(), "OOps, non-registered buffer freed (!)"); - - maUsedBuffers.erase(aUsedFound); - maFreeBuffers.emplace_back(&rDevice); - SAL_WARN_IF(maFreeBuffers.size() > 1000, "drawinglayer", "excessive cached buffers, " - << maFreeBuffers.size() << " entries!"); - Start(); + pRetval = VclPtr<VirtualDevice>::Create(rOutDev, bMonoChrome ? DeviceFormat::BITMASK + : DeviceFormat::DEFAULT); + maDeviceTemplates[pRetval] = &rOutDev; + pRetval->SetOutputSizePixel(rSizePixel, bClear); } - - void VDevBuffer::Invoke() + else { - ::osl::MutexGuard aGuard(m_aMutex); - - while(!maFreeBuffers.empty()) - { - aBuffers::iterator aLastOne(maFreeBuffers.end() - 1); - maDeviceTemplates.erase(*aLastOne); - aLastOne->disposeAndClear(); - maFreeBuffers.pop_back(); - } + // reused, reset some values + pRetval->SetMapMode(); + pRetval->SetRasterOp(RasterOp::OverPaint); } + + // remember allocated buffer + maUsedBuffers.push_back(pRetval); + + return pRetval; } +void VDevBuffer::free(VirtualDevice& rDevice) +{ + ::osl::MutexGuard aGuard(m_aMutex); + const aBuffers::iterator aUsedFound( + std::find(maUsedBuffers.begin(), maUsedBuffers.end(), &rDevice)); + OSL_ENSURE(aUsedFound != maUsedBuffers.end(), "OOps, non-registered buffer freed (!)"); + + maUsedBuffers.erase(aUsedFound); + maFreeBuffers.emplace_back(&rDevice); + SAL_WARN_IF(maFreeBuffers.size() > 1000, "drawinglayer", + "excessive cached buffers, " << maFreeBuffers.size() << " entries!"); + Start(); +} + +void VDevBuffer::Invoke() +{ + ::osl::MutexGuard aGuard(m_aMutex); + + while (!maFreeBuffers.empty()) + { + aBuffers::iterator aLastOne(maFreeBuffers.end() - 1); + maDeviceTemplates.erase(*aLastOne); + aLastOne->disposeAndClear(); + maFreeBuffers.pop_back(); + } +} +} // support for rendering Bitmap and BitmapEx contents namespace drawinglayer { - // static global VDev buffer for the VclProcessor2D's (VclMetafileProcessor2D and VclPixelProcessor2D) - VDevBuffer& getVDevBuffer() - { - // secure global instance with Vcl's safe destroyer of external (seen by - // library base) stuff, the remembered VDevs need to be deleted before - // Vcl's deinit - static vcl::DeleteOnDeinit< VDevBuffer > aVDevBuffer(new VDevBuffer()); - return *aVDevBuffer.get(); - } +// static global VDev buffer for the VclProcessor2D's (VclMetafileProcessor2D and VclPixelProcessor2D) +VDevBuffer& getVDevBuffer() +{ + // secure global instance with Vcl's safe destroyer of external (seen by + // library base) stuff, the remembered VDevs need to be deleted before + // Vcl's deinit + static vcl::DeleteOnDeinit<VDevBuffer> aVDevBuffer(new VDevBuffer()); + return *aVDevBuffer.get(); +} - impBufferDevice::impBufferDevice( - OutputDevice& rOutDev, - const basegfx::B2DRange& rRange) - : mrOutDev(rOutDev), - mpContent(nullptr), - mpMask(nullptr), - mpAlpha(nullptr) - { - basegfx::B2DRange aRangePixel(rRange); - aRangePixel.transform(mrOutDev.GetViewTransformation()); - const ::tools::Rectangle aRectPixel( - static_cast<sal_Int32>(floor(aRangePixel.getMinX())), static_cast<sal_Int32>(floor(aRangePixel.getMinY())), - static_cast<sal_Int32>(ceil(aRangePixel.getMaxX())), static_cast<sal_Int32>(ceil(aRangePixel.getMaxY()))); - const Point aEmptyPoint; - maDestPixel = ::tools::Rectangle(aEmptyPoint, mrOutDev.GetOutputSizePixel()); - maDestPixel.Intersection(aRectPixel); - - if(!isVisible()) - return; +impBufferDevice::impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& rRange) + : mrOutDev(rOutDev) + , mpContent(nullptr) + , mpMask(nullptr) + , mpAlpha(nullptr) +{ + basegfx::B2DRange aRangePixel(rRange); + aRangePixel.transform(mrOutDev.GetViewTransformation()); + const ::tools::Rectangle aRectPixel(static_cast<sal_Int32>(floor(aRangePixel.getMinX())), + static_cast<sal_Int32>(floor(aRangePixel.getMinY())), + static_cast<sal_Int32>(ceil(aRangePixel.getMaxX())), + static_cast<sal_Int32>(ceil(aRangePixel.getMaxY()))); + const Point aEmptyPoint; + maDestPixel = ::tools::Rectangle(aEmptyPoint, mrOutDev.GetOutputSizePixel()); + maDestPixel.Intersection(aRectPixel); + + if (!isVisible()) + return; #ifdef IOS - // Exact mechanism unknown, but for some reason SmartArt - // rendering, especially shadows, is broken on iOS unless - // we pass 'true' here. Are virtual devices always de - // facto cleared when created on other platforms? - mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); + // Exact mechanism unknown, but for some reason SmartArt + // rendering, especially shadows, is broken on iOS unless + // we pass 'true' here. Are virtual devices always de + // facto cleared when created on other platforms? + mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); #else - mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), false, false); + mpContent = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), false, false); #endif - // #i93485# assert when copying from window to VDev is used - OSL_ENSURE(mrOutDev.GetOutDevType() != OUTDEV_WINDOW, - "impBufferDevice render helper: Copying from Window to VDev, this should be avoided (!)"); + // #i93485# assert when copying from window to VDev is used + OSL_ENSURE( + mrOutDev.GetOutDevType() != OUTDEV_WINDOW, + "impBufferDevice render helper: Copying from Window to VDev, this should be avoided (!)"); - const bool bWasEnabledSrc(mrOutDev.IsMapModeEnabled()); - mrOutDev.EnableMapMode(false); - mpContent->DrawOutDev(aEmptyPoint, maDestPixel.GetSize(), maDestPixel.TopLeft(), maDestPixel.GetSize(), mrOutDev); - mrOutDev.EnableMapMode(bWasEnabledSrc); + const bool bWasEnabledSrc(mrOutDev.IsMapModeEnabled()); + mrOutDev.EnableMapMode(false); + mpContent->DrawOutDev(aEmptyPoint, maDestPixel.GetSize(), maDestPixel.TopLeft(), + maDestPixel.GetSize(), mrOutDev); + mrOutDev.EnableMapMode(bWasEnabledSrc); - MapMode aNewMapMode(mrOutDev.GetMapMode()); + MapMode aNewMapMode(mrOutDev.GetMapMode()); - const Point aLogicTopLeft(mrOutDev.PixelToLogic(maDestPixel.TopLeft())); - aNewMapMode.SetOrigin(Point(-aLogicTopLeft.X(), -aLogicTopLeft.Y())); + const Point aLogicTopLeft(mrOutDev.PixelToLogic(maDestPixel.TopLeft())); + aNewMapMode.SetOrigin(Point(-aLogicTopLeft.X(), -aLogicTopLeft.Y())); - mpContent->SetMapMode(aNewMapMode); + mpContent->SetMapMode(aNewMapMode); - // copy AA flag for new target - mpContent->SetAntialiasing(mrOutDev.GetAntialiasing()); + // copy AA flag for new target + mpContent->SetAntialiasing(mrOutDev.GetAntialiasing()); - // copy RasterOp (e.g. may be RasterOp::Xor on destination) - mpContent->SetRasterOp(mrOutDev.GetRasterOp()); - } + // copy RasterOp (e.g. may be RasterOp::Xor on destination) + mpContent->SetRasterOp(mrOutDev.GetRasterOp()); +} - impBufferDevice::~impBufferDevice() +impBufferDevice::~impBufferDevice() +{ + if (mpContent) { - if(mpContent) - { - getVDevBuffer().free(*mpContent); - } - - if(mpMask) - { - getVDevBuffer().free(*mpMask); - } + getVDevBuffer().free(*mpContent); + } - if(mpAlpha) - { - getVDevBuffer().free(*mpAlpha); - } + if (mpMask) + { + getVDevBuffer().free(*mpMask); } - void impBufferDevice::paint(double fTrans) + if (mpAlpha) { - if(!isVisible()) - return; + getVDevBuffer().free(*mpAlpha); + } +} + +void impBufferDevice::paint(double fTrans) +{ + if (!isVisible()) + return; - const Point aEmptyPoint; - const Size aSizePixel(maDestPixel.GetSize()); - const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled()); + const Point aEmptyPoint; + const Size aSizePixel(maDestPixel.GetSize()); + const bool bWasEnabledDst(mrOutDev.IsMapModeEnabled()); #ifdef DBG_UTIL - static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore + static bool bDoSaveForVisualControl(false); // loplugin:constvars:ignore #endif - mrOutDev.EnableMapMode(false); - mpContent->EnableMapMode(false); + mrOutDev.EnableMapMode(false); + mpContent->EnableMapMode(false); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew( + if (bDoSaveForVisualControl) + { + SvFileStream aNew( #ifdef _WIN32 - "c:\\content.bmp", + "c:\\content.bmp", #else - "~/content.bmp", + "~/content.bmp", #endif - StreamMode::WRITE|StreamMode::TRUNC); - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - WriteDIB(aContent, aNew, false, true); - } + StreamMode::WRITE | StreamMode::TRUNC); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + WriteDIB(aContent, aNew, false, true); + } #endif - // during painting the buffer, disable evtl. set RasterOp (may be RasterOp::Xor) - const RasterOp aOrigRasterOp(mrOutDev.GetRasterOp()); - mrOutDev.SetRasterOp(RasterOp::OverPaint); + // during painting the buffer, disable evtl. set RasterOp (may be RasterOp::Xor) + const RasterOp aOrigRasterOp(mrOutDev.GetRasterOp()); + mrOutDev.SetRasterOp(RasterOp::OverPaint); - if(mpAlpha) - { - mpAlpha->EnableMapMode(false); - const AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); + if (mpAlpha) + { + mpAlpha->EnableMapMode(false); + const AlphaMask aAlphaMask(mpAlpha->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew( + if (bDoSaveForVisualControl) + { + SvFileStream aNew( #ifdef _WIN32 - "c:\\transparence.bmp", + "c:\\transparence.bmp", #else - "~/transparence.bmp", + "~/transparence.bmp", #endif - StreamMode::WRITE|StreamMode::TRUNC); - WriteDIB(aAlphaMask.GetBitmap(), aNew, false, true); - } + StreamMode::WRITE | StreamMode::TRUNC); + WriteDIB(aAlphaMask.GetBitmap(), aNew, false, true); + } #endif - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); - } - else if(mpMask) - { - mpMask->EnableMapMode(false); - const Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); + } + else if (mpMask) + { + mpMask->EnableMapMode(false); + const Bitmap aMask(mpMask->GetBitmap(aEmptyPoint, aSizePixel)); #ifdef DBG_UTIL - if(bDoSaveForVisualControl) - { - SvFileStream aNew( + if (bDoSaveForVisualControl) + { + SvFileStream aNew( #ifdef _WIN32 - "c:\\mask.bmp", + "c:\\mask.bmp", #else - "~/mask.bmp", + "~/mask.bmp", #endif - StreamMode::WRITE|StreamMode::TRUNC); - WriteDIB(aMask, aNew, false, true); - } -#endif - - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask)); - } - else if(0.0 != fTrans) - { - sal_uInt8 nMaskValue(static_cast<sal_uInt8>(basegfx::fround(fTrans * 255.0))); - const AlphaMask aAlphaMask(aSizePixel, &nMaskValue); - Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); - mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); - } - else - { - mrOutDev.DrawOutDev(maDestPixel.TopLeft(), aSizePixel, - aEmptyPoint, aSizePixel, - *mpContent); + StreamMode::WRITE | StreamMode::TRUNC); + WriteDIB(aMask, aNew, false, true); } +#endif - mrOutDev.SetRasterOp(aOrigRasterOp); - mrOutDev.EnableMapMode(bWasEnabledDst); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask)); } - - VirtualDevice& impBufferDevice::getContent() + else if (0.0 != fTrans) { - assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); - return *mpContent; + sal_uInt8 nMaskValue(static_cast<sal_uInt8>(basegfx::fround(fTrans * 255.0))); + const AlphaMask aAlphaMask(aSizePixel, &nMaskValue); + Bitmap aContent(mpContent->GetBitmap(aEmptyPoint, aSizePixel)); + mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask)); } - - VirtualDevice& impBufferDevice::getMask() + else { - assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); - if (!mpMask) - { - mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, true); - mpMask->SetMapMode(mpContent->GetMapMode()); + mrOutDev.DrawOutDev(maDestPixel.TopLeft(), aSizePixel, aEmptyPoint, aSizePixel, *mpContent); + } - // do NOT copy AA flag for mask! - } + mrOutDev.SetRasterOp(aOrigRasterOp); + mrOutDev.EnableMapMode(bWasEnabledDst); +} - return *mpMask; - } +VirtualDevice& impBufferDevice::getContent() +{ + assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); + return *mpContent; +} - VirtualDevice& impBufferDevice::getTransparence() +VirtualDevice& impBufferDevice::getMask() +{ + assert(mpContent && "impBufferDevice: No content, check isVisible() before accessing (!)"); + if (!mpMask) { - OSL_ENSURE(mpContent, "impBufferDevice: No content, check isVisible() before accessing (!)"); - if(!mpAlpha) - { - mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); - mpAlpha->SetMapMode(mpContent->GetMapMode()); + mpMask = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, true); + mpMask->SetMapMode(mpContent->GetMapMode()); - // copy AA flag for new target; masking needs to be smooth - mpAlpha->SetAntialiasing(mpContent->GetAntialiasing()); - } + // do NOT copy AA flag for mask! + } + + return *mpMask; +} + +VirtualDevice& impBufferDevice::getTransparence() +{ + OSL_ENSURE(mpContent, "impBufferDevice: No content, check isVisible() before accessing (!)"); + if (!mpAlpha) + { + mpAlpha = getVDevBuffer().alloc(mrOutDev, maDestPixel.GetSize(), true, false); + mpAlpha->SetMapMode(mpContent->GetMapMode()); - return *mpAlpha; + // copy AA flag for new target; masking needs to be smooth + mpAlpha->SetAntialiasing(mpContent->GetAntialiasing()); } + + return *mpAlpha; +} } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx index 5305b1c0541e..90d351eac50f 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx @@ -21,32 +21,33 @@ #include <vcl/virdev.hxx> -namespace basegfx { class B2DRange; } +namespace basegfx +{ +class B2DRange; +} // support methods for vcl direct gradient rendering namespace drawinglayer { - class impBufferDevice - { - OutputDevice& mrOutDev; - VclPtr<VirtualDevice> mpContent; - VclPtr<VirtualDevice> mpMask; - VclPtr<VirtualDevice> mpAlpha; - ::tools::Rectangle maDestPixel; - - public: - impBufferDevice( - OutputDevice& rOutDev, - const basegfx::B2DRange& rRange); - ~impBufferDevice(); - - void paint(double fTrans = 0.0); - bool isVisible() const { return !maDestPixel.IsEmpty(); } - VirtualDevice& getContent(); - VirtualDevice& getMask(); - VirtualDevice& getTransparence(); - }; +class impBufferDevice +{ + OutputDevice& mrOutDev; + VclPtr<VirtualDevice> mpContent; + VclPtr<VirtualDevice> mpMask; + VclPtr<VirtualDevice> mpAlpha; + tools::Rectangle maDestPixel; + +public: + impBufferDevice(OutputDevice& rOutDev, const basegfx::B2DRange& rRange); + ~impBufferDevice(); + + void paint(double fTrans = 0.0); + bool isVisible() const { return !maDestPixel.IsEmpty(); } + VirtualDevice& getContent(); + VirtualDevice& getMask(); + VirtualDevice& getTransparence(); +}; } // end of namespace drawinglayer /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/clang-format/blacklist b/solenv/clang-format/blacklist index 466245492198..298745b86375 100644 --- a/solenv/clang-format/blacklist +++ b/solenv/clang-format/blacklist @@ -3752,8 +3752,6 @@ drawinglayer/source/processor2d/objectinfoextractor2d.cxx drawinglayer/source/processor2d/processor2dtools.cxx drawinglayer/source/processor2d/processorfromoutputdevice.cxx drawinglayer/source/processor2d/textaspolygonextractor2d.cxx -drawinglayer/source/processor2d/vclhelperbufferdevice.cxx -drawinglayer/source/processor2d/vclhelperbufferdevice.hxx drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx drawinglayer/source/processor2d/vclmetafileprocessor2d.hxx drawinglayer/source/processor3d/baseprocessor3d.cxx commit 1a86c041cd9eaefd5869df984c780b84f847e6fd Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Sat May 2 19:29:49 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Mon May 4 08:40:17 2020 +0200 pragma once in vclhelperbufferdevice.hxx Change-Id: I12e53849fa23496799ba5e45fc0077cb9b54048c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93361 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx index 3bcbb979761e..5305b1c0541e 100644 --- a/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx +++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.hxx @@ -17,17 +17,12 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_VCLHELPERBUFFERDEVICE_HXX -#define INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_VCLHELPERBUFFERDEVICE_HXX +#pragma once #include <vcl/virdev.hxx> - -// predefines - namespace basegfx { class B2DRange; } - // support methods for vcl direct gradient rendering namespace drawinglayer @@ -54,7 +49,4 @@ namespace drawinglayer }; } // end of namespace drawinglayer - -#endif // INCLUDED_DRAWINGLAYER_SOURCE_PROCESSOR2D_VCLHELPERBUFFERDEVICE_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ commit b6caf887c6e47b65b3453b4319180325d67a5671 Author: Andrea Gelmini <andrea.gelm...@gelma.net> AuthorDate: Thu Apr 30 14:20:46 2020 +0200 Commit: Julien Nabet <serval2...@yahoo.fr> CommitDate: Mon May 4 07:18:39 2020 +0200 Fix typo Change-Id: Ic084ebbc04731b362bac0cf51e4b2bbdf5ef0526 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93208 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2...@yahoo.fr> diff --git a/basegfx/source/polygon/b2dpolygonclipper.cxx b/basegfx/source/polygon/b2dpolygonclipper.cxx index cdcfeafbfaea..246d5a10ab84 100644 --- a/basegfx/source/polygon/b2dpolygonclipper.cxx +++ b/basegfx/source/polygon/b2dpolygonclipper.cxx @@ -547,7 +547,7 @@ namespace basegfx::utils * inside |inside |next * inside |outside |intersect with clip plane * outside |outside |nothing - * outside |inside |intersect with clip plane follwed by next + * outside |inside |intersect with clip plane followed by next * */ static sal_uInt32 scissorLineSegment( ::basegfx::B2DPoint *in_vertex, // input buffer commit a162f0f036fa1d0dc4dcd63c7859bda0b5702247 Author: Andrea Gelmini <andrea.gelm...@gelma.net> AuthorDate: Sun May 3 22:49:28 2020 +0200 Commit: Andrea Gelmini <andrea.gelm...@gelma.net> CommitDate: Mon May 4 07:01:22 2020 +0200 Fix typos Change-Id: I63ae6adec1967bcf888538437e5e88f0acdea66e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93392 Tested-by: Jenkins Reviewed-by: Andrea Gelmini <andrea.gelm...@gelma.net> diff --git a/svx/source/svdraw/svdpdf.cxx b/svx/source/svdraw/svdpdf.cxx index 7e4a3e6a5345..ad3a89ed9c02 100644 --- a/svx/source/svdraw/svdpdf.cxx +++ b/svx/source/svdraw/svdpdf.cxx @@ -807,9 +807,9 @@ void ImpSdrPdfImport::ImportText(FPDF_PAGEOBJECT pPageObject, FPDF_TEXTPAGE pTex return; } - // Let's rely on null-terminaton for the length of the string. We + // Let's rely on null-termination for the length of the string. We // just know the number of bytes the string takes, but in OUString - // needs the number of charaters. + // needs the number of characters. OUString sText(pText.get()); const double dFontSize = FPDFTextObj_GetFontSize(pPageObject); diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 346a8646abb9..ab5333498649 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2161,7 +2161,7 @@ void PdfExportTest::testVersion15() // Check round-trip of importing and exporting the PDF with PDFium filter, // which imports the PDF document as multiple PDFs as graphic object. // Each page in the document has one PDF graphic object which content is -// the correcponding page in the PDF. When such a document is exported, +// the corresponding page in the PDF. When such a document is exported, // the PDF graphic gets embedded into the exported PDF document (as a // Form XObject). void PdfExportTest::testMultiPagePDF() commit b58b06fdc5edc9dbe5178225b2c090f7faf1918a Author: Olivier Hallot <olivier.hal...@libreoffice.org> AuthorDate: Sun May 3 22:54:53 2020 -0300 Commit: Gerrit Code Review <ger...@gerrit.libreoffice.org> CommitDate: Mon May 4 03:54:53 2020 +0200 Update git submodules * Update helpcontent2 from branch 'master' to 45490e779509af867ed9da186f834cc868d518db - tdf#132630 Hide Whitespace -> Show Whitespace Change-Id: I9a14cce825874338b87b5f82f55c52f661e7a877 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/93346 Tested-by: Jenkins Reviewed-by: Olivier Hallot <olivier.hal...@libreoffice.org> diff --git a/helpcontent2 b/helpcontent2 index f6eb36852572..45490e779509 160000 --- a/helpcontent2 +++ b/helpcontent2 @@ -1 +1 @@ -Subproject commit f6eb368525721bf598325dcf78c82604919b9484 +Subproject commit 45490e779509af867ed9da186f834cc868d518db ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits