[Libreoffice-commits] core.git: Branch 'private/tvajngerl/staging' - 4 commits - basegfx/CppunitTest_basegfx.mk basegfx/test cui/source cui/uiconfig include/basegfx include/sfx2 officecfg/registry Repository.mk sfx2/Library_sfx.mk sfx2/sdi sfx2/source sfx2/uiconfig sfx2/UIConfig_sfx.mk vcl/backendtest vcl/Executable_benchmark.mk vcl/Module_vcl.mk
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Sat Feb 27 07:18:24 UTC 2021
Rebased ref, commits from common ancestor:
commit a95de7511007877531cb62fb8448e7b633dbe1b1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Thu Nov 12 10:01:20 2020 +0100
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat Feb 27 16:17:47 2021 +0900
basegfx: added LengthUnit class as the base unit for length
Change-Id: I1d4790b60dd784e8b2e2e438274f3ebd6db4b60c
diff --git a/basegfx/CppunitTest_basegfx.mk b/basegfx/CppunitTest_basegfx.mk
index a0379e76612a..b66b1381d69a 100644
--- a/basegfx/CppunitTest_basegfx.mk
+++ b/basegfx/CppunitTest_basegfx.mk
@@ -42,6 +42,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,basegfx,\
basegfx/test/basegfxtools \
basegfx/test/clipstate \
basegfx/test/genericclipper \
+ basegfx/test/LengthUnitTest \
))
# vim: set noet sw=4 ts=4:
diff --git a/basegfx/test/LengthUnitTest.cxx b/basegfx/test/LengthUnitTest.cxx
new file mode 100644
index 000000000000..0b80c33da5b0
--- /dev/null
+++ b/basegfx/test/LengthUnitTest.cxx
@@ -0,0 +1,96 @@
+/* -*- 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 <basegfx/units/LengthUnit.hxx>
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+class LengthUnitTest : public CppUnit::TestFixture
+{
+public:
+ void test();
+
+ CPPUNIT_TEST_SUITE(LengthUnitTest);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void LengthUnitTest::test()
+{
+ gfx::LengthUnit cm = 1_cm + 5_cm - 2_cm;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, cm.as_cm(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.04, cm.as_m(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(40.0, cm.as_mm(), 1e-4);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(1440000), cm.raw());
+
+ gfx::LengthUnit cm2 = 5_cm * 2;
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), cm2.raw());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, cm2.as_cm(), 1e-4);
+
+ // 1 km - 50 m = 950 m = 95000 cm
+ gfx::LengthUnit cm3 = 100000_cm - 5000_cm;
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(34200000000), cm3.raw());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(95000.0, cm3.as_cm(), 1e-4);
+
+ gfx::LengthUnit cm4(1_cm);
+ cm4 /= 2;
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(180000), cm4.raw());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5, cm4.as_cm(), 1e-4);
+
+ // (635 * 20) + 3 * (635 * 15) = 41275EMU
+ gfx::LengthUnit pt = 1_pt + 3_px;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.25, pt.as_pt(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, pt.as_twip(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0451, pt.as_in(), 1e-4);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(41275), pt.raw());
+
+ gfx::LengthUnit inch = 1_in; // 1440 * 635
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1440.0, inch.as_twip(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, inch.as_px(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, inch.as_in(), 1e-4);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(914400.0, inch.as_emu(), 1e-4);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(914400), inch.raw());
+
+ // Conversion
+ sal_Int64 asNumber(17_pt);
+ asNumber += sal_Int64(1_pt);
+ gfx::LengthUnit asLength = gfx::LengthUnit::emu(asNumber);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(18 * 635 * 20), asLength.raw());
+
+ gfx::LengthUnit maximum = gfx::LengthUnit::emu(SAL_MAX_INT64);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(256204778801.5, maximum.as_m(), 1e-1);
+ // 256204778 km
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MAX_INT64), maximum.raw());
+
+ gfx::LengthUnit minimum = gfx::LengthUnit::emu(SAL_MIN_INT64);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-256204778801.5, minimum.as_m(), 1e-1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(double(SAL_MIN_INT64), minimum.as_emu(), 1e-1);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(SAL_MIN_INT64), minimum.raw());
+
+ // 27 emu + 33 emu + 360 emu = 420
+ gfx::LengthUnit emus = 27_emu + 33_emu + 1_hmm;
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(420), emus.raw());
+
+ // Creation from number
+ int number = 10;
+ auto asCm = gfx::LengthUnit::cm(number);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asCm.as_cm(), 1e-4);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(3600000), asCm.raw());
+
+ auto asMm = gfx::LengthUnit::mm(number);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asMm.as_mm(), 1e-4);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(360000), asMm.raw());
+
+ auto asInch = gfx::LengthUnit::in(number);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, asInch.as_in(), 1e-4);
+ CPPUNIT_ASSERT_EQUAL(sal_Int64(9144000), asInch.raw());
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(LengthUnitTest);
diff --git a/include/basegfx/units/LengthUnit.hxx b/include/basegfx/units/LengthUnit.hxx
new file mode 100644
index 000000000000..4edd1cc4704f
--- /dev/null
+++ b/include/basegfx/units/LengthUnit.hxx
@@ -0,0 +1,194 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <sal/types.h>
+
+namespace gfx
+{
+namespace
+{
+constexpr sal_Int64 constFactor_hmm_to_EMU = 360ll;
+constexpr sal_Int64 constFactor_mm_to_EMU = constFactor_hmm_to_EMU * 100ll;
+constexpr sal_Int64 constFactor_cm_to_EMU = constFactor_hmm_to_EMU * 1000ll;
+constexpr sal_Int64 constFactor_m_to_EMU = constFactor_hmm_to_EMU * 100000ll;
+
+constexpr sal_Int64 constFactor_twip_to_EMU = 635ll;
+constexpr sal_Int64 constFactor_in_to_EMU = constFactor_twip_to_EMU * 1440ll;
+constexpr sal_Int64 constFactor_pt_to_EMU = constFactor_twip_to_EMU * 20ll;
+constexpr sal_Int64 constFactor_px_to_EMU = constFactor_twip_to_EMU * 15ll;
+
+} // end anonymous namespace
+
+template <typename T> class LengthUnitBase
+{
+private:
+ // value in EMU units
+ T m_nValue;
+
+ constexpr explicit LengthUnitBase(T nValue)
+ : m_nValue(nValue)
+ {
+ }
+
+public:
+ static constexpr LengthUnitBase cm(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_cm_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase mm(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_mm_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase hmm(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_hmm_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase in(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_in_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase twip(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_twip_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase pt(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_pt_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase px(T nValue)
+ {
+ return LengthUnitBase(gfx::constFactor_px_to_EMU * nValue);
+ }
+
+ static constexpr LengthUnitBase emu(T nValue) { return LengthUnitBase(nValue); }
+
+ constexpr explicit LengthUnitBase()
+ : m_nValue(0)
+ {
+ }
+
+ constexpr explicit operator T() const { return m_nValue; }
+
+ constexpr LengthUnitBase& operator+=(LengthUnitBase const& rhs)
+ {
+ m_nValue += rhs.m_nValue;
+ return *this;
+ }
+
+ constexpr LengthUnitBase& operator-=(LengthUnitBase const& rhs)
+ {
+ m_nValue -= rhs.m_nValue;
+ return *this;
+ }
+
+ constexpr LengthUnitBase& operator*=(T const& rhs)
+ {
+ m_nValue *= rhs;
+ return *this;
+ }
+
+ constexpr LengthUnitBase& operator/=(T const& rhs)
+ {
+ m_nValue /= rhs;
+ return *this;
+ }
+
+ constexpr LengthUnitBase& operator-()
+ {
+ m_nValue = -m_nValue;
+ return *this;
+ }
+
+ T raw() const { return m_nValue; }
+
+ double as_hmm() const { return m_nValue / double(constFactor_hmm_to_EMU); }
+ double as_mm() const { return m_nValue / double(constFactor_mm_to_EMU); }
+ double as_cm() const { return m_nValue / double(constFactor_cm_to_EMU); }
+ double as_m() const { return m_nValue / double(constFactor_m_to_EMU); }
+ double as_twip() const { return m_nValue / double(constFactor_twip_to_EMU); }
+ double as_in() const { return m_nValue / double(constFactor_in_to_EMU); }
+ double as_pt() const { return m_nValue / double(constFactor_pt_to_EMU); }
+ double as_px() const { return m_nValue / double(constFactor_px_to_EMU); }
+ double as_emu() const { return double(m_nValue); }
+};
+
+template <typename T>
+inline LengthUnitBase<T> operator+(LengthUnitBase<T> lhs, const LengthUnitBase<T>& rhs)
+{
+ return lhs += rhs;
+}
+
+template <typename T>
+inline LengthUnitBase<T> operator-(LengthUnitBase<T> lhs, const LengthUnitBase<T>& rhs)
+{
+ return lhs -= rhs;
+}
+
+template <typename T> inline LengthUnitBase<T> operator*(LengthUnitBase<T> lhs, const long rhs)
+{
+ return lhs *= rhs;
+}
+
+template <typename T> inline LengthUnitBase<T> operator/(LengthUnitBase<T> lhs, const long rhs)
+{
+ return lhs /= rhs;
+}
+
+typedef LengthUnitBase<sal_Int64> LengthUnit;
+typedef LengthUnitBase<double> LengthUnitD;
+
+} // end namespace gfx
+
+constexpr gfx::LengthUnit operator"" _emu(unsigned long long value)
+{
+ return gfx::LengthUnit::emu(value);
+}
+
+constexpr gfx::LengthUnit operator"" _in(unsigned long long value)
+{
+ return gfx::LengthUnit::in(value);
+}
+
+constexpr gfx::LengthUnit operator"" _cm(unsigned long long value)
+{
+ return gfx::LengthUnit::cm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _mm(unsigned long long value)
+{
+ return gfx::LengthUnit::mm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _hmm(unsigned long long value)
+{
+ return gfx::LengthUnit::hmm(value);
+}
+
+constexpr gfx::LengthUnit operator"" _twip(unsigned long long value)
+{
+ return gfx::LengthUnit::twip(value);
+}
+
+constexpr gfx::LengthUnit operator"" _pt(unsigned long long value)
+{
+ return gfx::LengthUnit::pt(value);
+}
+
+constexpr gfx::LengthUnit operator"" _px(unsigned long long value)
+{
+ return gfx::LengthUnit::px(value);
+}
commit 3b90dad06c25e2765871bcdc69c7a17c5dca4e53
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Tue May 22 14:44:39 2018 +0900
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat Feb 27 16:17:41 2021 +0900
Command Popup
Change-Id: I92cdd3130b8de42ee0863c9e7154e7c7246d9377
diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 3f9d4a232fb7..e2a9a8cdaab6 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -385,7 +385,7 @@ class SvxSearchItem;
// default-ids for windows
-// free (SID_SFX_START + 610)
+#define SID_COMMAND_POPUP (SID_SFX_START + 610)
#define SID_NEWWINDOW (SID_SFX_START + 620)
#define SID_CLOSEWIN (SID_SFX_START + 621)
#define SID_VIEWSHELL (SID_SFX_START + 623)
diff --git a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
index 967aa98a04db..47118db2540e 100644
--- a/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/Accelerators.xcu
@@ -313,6 +313,12 @@ Ctrl+Shift+e aka E_SHIFT_MOD1 under GTK/IBUS is for some emoji thing
<value xml:lang="en-US" install:module="unxwnt">.uno:OptionsTreeDialog</value>
</prop>
</node>
+ <node oor:name="SPACE_MOD1" oor:op="replace">
+ <prop oor:name="Command">
+ <value xml:lang="x-no-translate">I10N SHORTCUTS - NO TRANSLATE</value>
+ <value xml:lang="en-US">.uno:CommandPopup</value>
+ </prop>
+ </node>
</node>
<node oor:name="Modules">
<node oor:name="com.sun.star.script.BasicIDE" oor:op="replace">
diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
index 756bdd288b91..ad77ca0a19a5 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu
@@ -6537,6 +6537,14 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8
<value>1</value>
</prop>
</node>
+ <node oor:name=".uno:CommandPopup" oor:op="replace">
+ <prop oor:name="Label" oor:type="xs:string">
+ <value xml:lang="en-US">Command Popup</value>
+ </prop>
+ <prop oor:name="Properties" oor:type="xs:int">
+ <value>1</value>
+ </prop>
+ </node>
<node oor:name=".uno:DevelopmentToolsDockingWindow" oor:op="replace">
<prop oor:name="Label" oor:type="xs:string">
<value xml:lang="en-US">Development Tool</value>
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index b5126ca87893..941b11e59f94 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -291,6 +291,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/styles/StyleManager \
sfx2/source/toolbox/tbxitem \
sfx2/source/toolbox/weldutils \
+ sfx2/source/view/CommandPopup \
sfx2/source/view/classificationcontroller \
sfx2/source/view/classificationhelper \
sfx2/source/view/frame \
diff --git a/sfx2/UIConfig_sfx.mk b/sfx2/UIConfig_sfx.mk
index 7bdbd7a85a1e..ec80ab16de65 100644
--- a/sfx2/UIConfig_sfx.mk
+++ b/sfx2/UIConfig_sfx.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_UIConfig_add_uifiles,sfx,\
sfx2/uiconfig/ui/classificationbox \
sfx2/uiconfig/ui/cmisinfopage \
sfx2/uiconfig/ui/cmisline \
+ sfx2/uiconfig/ui/commandpopup \
sfx2/uiconfig/ui/custominfopage \
sfx2/uiconfig/ui/decktitlebar \
sfx2/uiconfig/ui/descriptioninfopage \
diff --git a/sfx2/sdi/frmslots.sdi b/sfx2/sdi/frmslots.sdi
index 09aafef95b7d..a7c8a472e73d 100644
--- a/sfx2/sdi/frmslots.sdi
+++ b/sfx2/sdi/frmslots.sdi
@@ -262,6 +262,11 @@ interface TopWindow : BrowseWindow
ExecMethod = MiscExec_Impl ;
StateMethod = MiscState_Impl ;
]
+ SID_COMMAND_POPUP
+ [
+ ExecMethod = MiscExec_Impl ;
+ StateMethod = MiscState_Impl ;
+ ]
SID_CLOSEWIN // ole(no) api(final/play/rec)
[
ExecMethod = Exec_Impl ;
@@ -307,4 +312,3 @@ shell SfxViewFrame
StateMethod = GetState_Impl ;
]
}
-
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index 425724440d13..85523a6f0b46 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -1271,6 +1271,23 @@ SfxStringItem FullName SID_DOCFULLNAME
GroupId = ;
]
+SfxVoidItem CommandPopup SID_COMMAND_POPUP
+[
+ AutoUpdate = TRUE,
+ FastCall = FALSE,
+ ReadOnlyDoc = TRUE,
+ Toggle = FALSE,
+ Container = TRUE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+ Asynchron;
+
+
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::View;
+]
SfxBoolItem FullScreen SID_WIN_FULLSCREEN
diff --git a/sfx2/source/view/CommandPopup.cxx b/sfx2/source/view/CommandPopup.cxx
new file mode 100644
index 000000000000..d882f48083d9
--- /dev/null
+++ b/sfx2/source/view/CommandPopup.cxx
@@ -0,0 +1,219 @@
+/* -*- 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 "CommandPopup.hxx"
+
+#include <vcl/layout.hxx>
+#include <workwin.hxx>
+#include <sfx2/msgpool.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/dispatchcommand.hxx>
+
+#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
+#include <com/sun/star/frame/theUICommandDescription.hpp>
+#include <com/sun/star/ui/theUICategoryDescription.hpp>
+
+#include <com/sun/star/ui/theModuleUIConfigurationManagerSupplier.hpp>
+#include <com/sun/star/ui/XUIConfigurationManagerSupplier.hpp>
+
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+
+#include <vcl/commandinfoprovider.hxx>
+
+using namespace css;
+
+CommandListBox::CommandListBox(vcl::Window* pParent, CommandPopup& rPopUp,
+ uno::Reference<frame::XFrame> xFrame)
+ : InterimItemWindow(pParent, "sfx/ui/commandpopup.ui", "CommandBox")
+ , m_rPopUp(rPopUp)
+ , m_xFrame(xFrame)
+ , m_pEntry(m_xBuilder->weld_entry("entry"))
+ , m_pListBox(m_xBuilder->weld_tree_view("listBox"))
+{
+ m_pEntry->connect_changed(LINK(this, CommandListBox, ModifyHdl));
+}
+
+void CommandListBox::recurse(uno::Reference<container::XIndexAccess> xIndexAccess,
+ MenuContent& rMenuContent)
+{
+ for (sal_Int32 n = 0; n < xIndexAccess->getCount(); n++)
+ {
+ MenuContent aNewContent;
+ OUString aModuleIdentifier;
+ uno::Sequence<beans::PropertyValue> aProperty;
+ uno::Reference<container::XIndexAccess> xIndexContainer;
+ try
+ {
+ if (xIndexAccess->getByIndex(n) >>= aProperty)
+ {
+ bool bShow = true;
+ bool bEnabled = true;
+
+ for (int i = 0; i < aProperty.getLength(); i++)
+ {
+ OUString aPropName = aProperty[i].Name;
+ if (aPropName == "CommandURL")
+ aProperty[i].Value >>= aNewContent.m_aCommandURL;
+ else if (aPropName == "ItemDescriptorContainer")
+ aProperty[i].Value >>= xIndexContainer;
+ else if (aPropName == "ModuleIdentifier")
+ aProperty[i].Value >>= aModuleIdentifier;
+ else if (aPropName == "IsVisible")
+ aProperty[i].Value >>= bShow;
+ else if (aPropName == "Enabled")
+ aProperty[i].Value >>= bEnabled;
+ }
+
+ OUString aModuleName(vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
+ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(
+ aNewContent.m_aCommandURL, aModuleName);
+ aNewContent.m_aMenuLabel
+ = vcl::CommandInfoProvider::GetMenuLabelForCommand(aProperties)
+ .replaceAll("~", "");
+ aNewContent.m_aLabel = rMenuContent.m_aLabel + " -> " + aNewContent.m_aMenuLabel;
+ //OUString aTooltip(vcl::CommandInfoProvider::GetTooltipForCommand(aNewContent.m_aCommandURL, aProperties, m_xFrame));
+ if (xIndexContainer.is())
+ recurse(xIndexContainer, aNewContent);
+
+ rMenuContent.m_aSubMenuContent.push_back(aNewContent);
+ }
+ }
+ catch (const lang::IndexOutOfBoundsException&)
+ {
+ return;
+ }
+ }
+}
+
+void CommandListBox::initialize()
+{
+ m_xGlobalCategoryInfo
+ = ui::theUICategoryDescription::get(comphelper::getProcessComponentContext());
+ m_sModuleLongName = vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame);
+ m_xModuleCategoryInfo.set(m_xGlobalCategoryInfo->getByName(m_sModuleLongName),
+ uno::UNO_QUERY_THROW);
+ m_xUICmdDescription
+ = frame::theUICommandDescription::get(comphelper::getProcessComponentContext());
+
+ uno::Reference<ui::XModuleUIConfigurationManagerSupplier> xModuleCfgSupplier
+ = ui::theModuleUIConfigurationManagerSupplier::get(
+ comphelper::getProcessComponentContext());
+
+ uno::Reference<ui::XUIConfigurationManager> xCfgMgr
+ = xModuleCfgSupplier->getUIConfigurationManager(m_sModuleLongName);
+ uno::Reference<container::XIndexAccess> xConfigData
+ = xCfgMgr->getSettings("private:resource/menubar/menubar", false);
+
+ recurse(xConfigData, m_aMenuContent);
+
+ Size aSize(400, 400);
+ SetSizePixel(aSize);
+ m_rPopUp.SetOutputSizePixel(aSize);
+ m_rPopUp.StartPopupMode(tools::Rectangle(Point(10, 10), aSize),
+ FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus
+ | FloatWinPopupFlags::AllMouseButtonClose
+ | FloatWinPopupFlags::NoMouseUpClose);
+
+ Show();
+
+ GrabFocus();
+ m_pEntry->grab_focus();
+}
+
+void CommandListBox::dispose()
+{
+ m_pEntry.reset();
+ m_pListBox.reset();
+ InterimItemWindow::dispose();
+}
+
+IMPL_LINK_NOARG(CommandListBox, ModifyHdl, weld::Entry&, void)
+{
+ m_pListBox->clear();
+
+ OUString sText = m_pEntry->get_text();
+ if (sText.isEmpty())
+ return;
+
+ m_aCommandList.clear();
+
+ m_pListBox->freeze();
+ findInMenu(m_aMenuContent, sText.toAsciiLowerCase());
+ m_pListBox->thaw();
+
+ if (m_pListBox->n_children() > 0)
+ {
+ m_pListBox->set_cursor(0);
+ m_pListBox->select(0);
+ }
+
+ m_pEntry->grab_focus();
+}
+
+void CommandListBox::findInMenu(MenuContent& aMenuContent, OUString const& rText)
+{
+ for (MenuContent& aSubContent : aMenuContent.m_aSubMenuContent)
+ {
+ if (aSubContent.m_aMenuLabel.toAsciiLowerCase().startsWith(rText))
+ {
+ OUString sCommandURL = aSubContent.m_aCommandURL;
+ //Image aImage = vcl::CommandInfoProvider::GetImageForCommand(sCommandURL, m_xFrame);
+ m_pListBox->append_text(aSubContent.m_aLabel);
+ m_aCommandList.push_back(sCommandURL);
+ }
+ findInMenu(aSubContent, rText);
+ }
+}
+
+bool CommandListBox::EventNotify(NotifyEvent& rNotifyEvent)
+{
+ const KeyEvent* pKeyEvent = rNotifyEvent.GetKeyEvent();
+
+ if (pKeyEvent)
+ {
+ if (pKeyEvent->GetKeyCode().GetCode() == KEY_DOWN
+ || pKeyEvent->GetKeyCode().GetCode() == KEY_UP)
+ {
+ m_pListBox->grab_focus();
+ }
+ else if (pKeyEvent->GetKeyCode().GetCode() == KEY_RETURN)
+ {
+ size_t nSelected = m_pListBox->get_selected_index();
+ if (nSelected < m_aCommandList.size())
+ {
+ OUString sCommand = m_aCommandList[nSelected];
+ dispatchCommandAndClose(sCommand);
+ }
+ }
+ else
+ {
+ m_pEntry->grab_focus();
+ }
+ }
+
+ return InterimItemWindow::EventNotify(rNotifyEvent);
+}
+
+void CommandListBox::dispatchCommandAndClose(OUString const& rCommand)
+{
+ m_rPopUp.EndPopupMode(FloatWinPopupEndFlags::CloseAll);
+ comphelper::dispatchCommand(rCommand, uno::Sequence<beans::PropertyValue>());
+}
+
+CommandPopup::CommandPopup(vcl::Window* pParent)
+ : FloatingWindow(pParent, WB_BORDER | WB_SYSTEMWINDOW)
+{
+}
+
+CommandPopup::~CommandPopup() { disposeOnce(); }
+
+void CommandPopup::dispose() { FloatingWindow::dispose(); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/CommandPopup.hxx b/sfx2/source/view/CommandPopup.hxx
new file mode 100644
index 000000000000..a3469c04cf6d
--- /dev/null
+++ b/sfx2/source/view/CommandPopup.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+#include <vcl/layout.hxx>
+
+#include <sfx2/dllapi.h>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/floatwin.hxx>
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <vcl/InterimItemWindow.hxx>
+#include <vcl/weld.hxx>
+#include <vcl/window.hxx>
+
+struct MenuContent
+{
+ OUString m_aCommandURL;
+ OUString m_aLabel;
+ OUString m_aMenuLabel;
+ std::vector<MenuContent> m_aSubMenuContent;
+};
+
+class SFX2_DLLPUBLIC CommandPopup : public FloatingWindow
+{
+public:
+ explicit CommandPopup(vcl::Window* pWorkWindow);
+
+ ~CommandPopup() override;
+
+ void dispose() override;
+};
+
+class SFX2_DLLPUBLIC CommandListBox final : public InterimItemWindow
+{
+private:
+ CommandPopup& m_rPopUp;
+
+ std::vector<OUString> m_aCommandList;
+ css::uno::Reference<css::frame::XFrame> m_xFrame;
+ css::uno::Reference<css::container::XNameAccess> m_xGlobalCategoryInfo;
+ css::uno::Reference<css::container::XNameAccess> m_xModuleCategoryInfo;
+ css::uno::Reference<css::container::XNameAccess> m_xUICmdDescription;
+ OUString m_sModuleLongName;
+
+ MenuContent m_aMenuContent;
+ OUString m_PreviousText;
+
+ std::unique_ptr<weld::Entry> m_pEntry;
+ std::unique_ptr<weld::TreeView> m_pListBox;
+
+ DECL_LINK(ModifyHdl, weld::Entry&, void);
+
+ void recurse(css::uno::Reference<css::container::XIndexAccess> xIndexAccess,
+ MenuContent& rMenuContent);
+ void findInMenu(MenuContent& aMenuContent, OUString const& rText);
+
+ void dispatchCommandAndClose(OUString const& rCommand);
+ bool EventNotify(NotifyEvent& rNotifyEvent) override;
+
+public:
+ CommandListBox(vcl::Window* pParent, CommandPopup& rPopUp,
+ css::uno::Reference<css::frame::XFrame> xFrame);
+
+ void initialize();
+
+ void dispose() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 170ce543da3b..d946525c4fd3 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -25,6 +25,7 @@
#include <sfx2/viewfrm.hxx>
#include <sfx2/classificationhelper.hxx>
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
+#include <svx/svdview.hxx>
#include <com/sun/star/document/MacroExecMode.hpp>
#include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/DispatchRecorder.hpp>
@@ -90,6 +91,7 @@
#include <unotools/configmgr.hxx>
#include <comphelper/sequenceashashmap.hxx>
+#include "CommandPopup.hxx"
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -2913,8 +2915,26 @@ void SfxViewFrame::MiscExec_Impl( SfxRequest& rReq )
rReq.Done();
break;
}
+ case SID_COMMAND_POPUP:
+ {
+ static VclPtr<CommandPopup> spCommandPopup;
+ static VclPtr<CommandListBox> spCommandListBox;
+
+ if (spCommandListBox)
+ spCommandListBox.disposeAndClear();
+
+ if (spCommandPopup)
+ spCommandPopup.disposeAndClear();
+
+ css::uno::Reference<css::frame::XFrame> xFrame(GetFrame().GetFrameInterface(), css::uno::UNO_QUERY);
+ spCommandPopup.reset(VclPtr<CommandPopup>::Create(&GetWindow()));
- // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ spCommandListBox.reset(VclPtr<CommandListBox>::Create(spCommandPopup.get(), *spCommandPopup.get(), xFrame));
+ spCommandListBox->initialize();
+
+ rReq.Done();
+ break;
+ }
case SID_WIN_FULLSCREEN:
{
const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot());
diff --git a/sfx2/uiconfig/ui/commandpopup.ui b/sfx2/uiconfig/ui/commandpopup.ui
new file mode 100644
index 000000000000..c6e035b9d7bf
--- /dev/null
+++ b/sfx2/uiconfig/ui/commandpopup.ui
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.36.0 -->
+<interface domain="sfx">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkTreeStore" id="liststore1">
+ <columns>
+ <!-- column-name text -->
+ <column type="gchararray"/>
+ <!-- column-name id -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkBox" id="CommandBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkEntry" id="entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="placeholder_text" translatable="yes" context="commandpopup|entry">Search command</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="height_request">400</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkTreeView" id="listBox">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">liststore1</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="enable_search">False</property>
+ <property name="search_column">0</property>
+ <property name="hover_selection">True</property>
+ <property name="show_expanders">False</property>
+ <property name="activate_on_single_click">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="column">
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
commit d2829810f951166175be439ad01a6ecadb1bcb3d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Aug 29 15:42:42 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat Feb 27 16:16:43 2021 +0900
Add button 'Render Features' to Options
Change-Id: I1a0aa538cdb6d32aa1d0377fd3d032c80bb742a5
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index f15171e38103..431d3a21ff3c 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -582,6 +582,7 @@ OfaViewTabPage::OfaViewTabPage(weld::Container* pPage, weld::DialogController* p
, m_xMousePosLB(m_xBuilder->weld_combo_box("mousepos"))
, m_xMouseMiddleLB(m_xBuilder->weld_combo_box("mousemiddle"))
, m_xMoreIcons(m_xBuilder->weld_button("btnMoreIcons"))
+ , m_xButtonTestRenderFeatures(m_xBuilder->weld_button("button_test_render_features"))
{
if (Application::GetToolkitName() == "gtk3")
m_xMenuIconBox->hide();
diff --git a/cui/source/options/optgdlg.hxx b/cui/source/options/optgdlg.hxx
index 07d3cca86fb7..a81bfce2a78c 100644
--- a/cui/source/options/optgdlg.hxx
+++ b/cui/source/options/optgdlg.hxx
@@ -115,6 +115,8 @@ private:
std::unique_ptr<weld::ComboBox> m_xMouseMiddleLB;
std::unique_ptr<weld::Button> m_xMoreIcons;
+ std::unique_ptr<weld::Button> m_xButtonTestRenderFeatures;
+
DECL_LINK(OnAntialiasingToggled, weld::ToggleButton&, void);
DECL_LINK(OnUseSkiaToggled, weld::ToggleButton&, void);
DECL_STATIC_LINK(OfaViewTabPage, OnMoreIconsClick, weld::Button&, void);
diff --git a/cui/uiconfig/ui/optviewpage.ui b/cui/uiconfig/ui/optviewpage.ui
index e7dd3e237fb9..03d4e50f941a 100644
--- a/cui/uiconfig/ui/optviewpage.ui
+++ b/cui/uiconfig/ui/optviewpage.ui
@@ -481,6 +481,18 @@
<property name="top-attach">0</property>
</packing>
</child>
+ <child>
+ <object class="GtkButton" id="button_test_render_features">
+ <property name="label" translatable="yes" context="optviewpage|button_test_render_features">Test Render Features</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="left-attach">0</property>
commit 5bf75f4cd58c54e11d97594733d0665779c61b4e
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sat Aug 29 15:22:03 2020 +0200
Commit: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
CommitDate: Sat Feb 27 16:16:31 2021 +0900
Benchmark
Change-Id: I22e0ac54380e2d22606e7b1fd453bed843523a29
diff --git a/Repository.mk b/Repository.mk
index 930ae5bfdc94..1b3bf551ff70 100644
--- a/Repository.mk
+++ b/Repository.mk
@@ -72,6 +72,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
tiledrendering \
mtfdemo \
visualbackendtest \
+ benchmark \
$(if $(and $(ENABLE_GTK3), $(filter LINUX %BSD SOLARIS,$(OS))), gtktiledviewer) \
))
diff --git a/vcl/Executable_benchmark.mk b/vcl/Executable_benchmark.mk
new file mode 100644
index 000000000000..c72039c13f7b
--- /dev/null
+++ b/vcl/Executable_benchmark.mk
@@ -0,0 +1,56 @@
+# -*- 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_Executable_Executable,benchmark))
+
+$(eval $(call gb_Executable_use_api,benchmark,\
+ offapi \
+ udkapi \
+))
+
+$(eval $(call gb_Executable_use_external,benchmark,boost_headers))
+
+$(eval $(call gb_Executable_set_include,benchmark,\
+ $$(INCLUDE) \
+ -I$(SRCDIR)/vcl/inc \
+))
+
+$(eval $(call gb_Executable_use_libraries,benchmark,\
+ basegfx \
+ comphelper \
+ cppu \
+ cppuhelper \
+ tl \
+ sal \
+ salhelper \
+ vcl \
+))
+
+$(eval $(call gb_Executable_add_exception_objects,benchmark,\
+ vcl/backendtest/Benchmark \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,benchmark,\
+ vclmain \
+))
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_Executable_add_libs,benchmark,\
+ -lm \
+ -ldl \
+ -lX11 \
+))
+
+$(eval $(call gb_Executable_use_static_libraries,benchmark,\
+ glxtest \
+))
+endif
+
+# vim: set noet sw=4 ts=4:
diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk
index 3a3626157b1f..1a82eaabb8be 100644
--- a/vcl/Module_vcl.mk
+++ b/vcl/Module_vcl.mk
@@ -38,6 +38,7 @@ $(eval $(call gb_Module_add_targets,vcl,\
$(if $(DISABLE_GUI),, \
Executable_vcldemo \
Executable_icontest \
+ Executable_benchmark \
Executable_visualbackendtest \
Executable_mtfdemo ))) \
))
diff --git a/vcl/backendtest/Benchmark.cxx b/vcl/backendtest/Benchmark.cxx
new file mode 100644
index 000000000000..8a57feba2657
--- /dev/null
+++ b/vcl/backendtest/Benchmark.cxx
@@ -0,0 +1,301 @@
+/* -*- 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 <comphelper/processfactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+
+#include <vcl/virdev.hxx>
+#include <vcl/vclmain.hxx>
+#include <bitmap/BitmapWriteAccess.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/svapp.hxx>
+
+#include <chrono>
+#include <iostream>
+#include <tools/ScopedNanoTimer.hxx>
+
+using namespace css;
+
+class Benchmark
+{
+ ScopedVclPtr<VirtualDevice> mpVDev;
+ int mnRepeats;
+
+ Size maSource;
+ Size maTarget;
+
+public:
+ Benchmark()
+ : mpVDev(VclPtr<VirtualDevice>::Create())
+ , mnRepeats(2)
+ {
+ mpVDev->SetAntialiasing(AntialiasingFlags::Enable | AntialiasingFlags::PixelSnapHairline);
+ mpVDev->SetOutputSizePixel(Size(4000, 4000));
+ mpVDev->SetBackground(Wallpaper(COL_LIGHTGRAY));
+ }
+
+ void run()
+ {
+ std::vector<sal_Int64> aCompleteTimes(20, 0);
+
+ mnRepeats = 5;
+ for (long iSize : { 4000, 2000, 1000 })
+ {
+ std::vector<std::pair<OUString, sal_Int64>> aTotalTimes(20);
+
+ maSource = Size(iSize, iSize);
+ maTarget = Size(200, 200);
+
+ for (int i = 0; i < mnRepeats; i++)
+ {
+ size_t a = 0;
+ //benchBitmapScale2(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ //benchBitmapScale4(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ //benchBitmapScale8X(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ //benchBitmapScale8(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ benchBitmapScale24(aTotalTimes[a].first, aTotalTimes[a].second);
+ a++;
+ benchBitmapScale24Combo(aTotalTimes[a].first, aTotalTimes[a].second);
+ a++;
+ benchBitmapScale32(aTotalTimes[a].first, aTotalTimes[a].second);
+ a++;
+ benchBitmapScale32Combo(aTotalTimes[a].first, aTotalTimes[a].second);
+ a++;
+
+ /*benchBitmap2(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ benchBitmap4(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ benchBitmap8X(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ benchBitmap8(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ benchBitmap24(aTotalTimes[a].first, aTotalTimes[a].second); a++;
+ benchBitmap32(aTotalTimes[a].first, aTotalTimes[a].second); a++;*/
+ }
+
+ int i = 0;
+ for (auto& rPair : aTotalTimes)
+ {
+ if (!rPair.first.isEmpty())
+ {
+ aCompleteTimes[i] += rPair.second / double(mnRepeats);
+ printf("TIME %d: %s - %f\n", i, rPair.first.toUtf8().getStr(),
+ rPair.second / double(mnRepeats));
+ }
+ i++;
+ }
+ printf("\n");
+ }
+ int i = 0;
+ for (auto& rTime : aCompleteTimes)
+ {
+ if (rTime > 0)
+ {
+ printf("TIME %d: %f\n", i, double(rTime));
+ i++;
+ }
+ }
+ }
+
+ void benchBitmapScale2(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "2 Scale";
+ Bitmap aBitmap(maSource, 2, &Bitmap::GetGreyPalette(2));
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale4(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "4 Scale";
+ Bitmap aBitmap(maSource, 4, &Bitmap::GetGreyPalette(16));
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale8X(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "8X Scale";
+ Bitmap aBitmap(maSource, 8);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale8(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "8 Scale";
+ Bitmap aBitmap(maSource, 8, &Bitmap::GetGreyPalette(256));
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale24(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "24 Scale Super";
+ Bitmap aBitmap(maSource, 24);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale24Combo(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "24 Scale Combo";
+ Bitmap aBitmap(maSource, 24);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale32(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "32 Scale Super";
+ Bitmap aBitmap(maSource, 32);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Super);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmapScale32Combo(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "32 Scale Combo";
+ Bitmap aBitmap(maSource, 32);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ aBitmap.Scale(maTarget, BmpScaleFlag::Combo);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmap2(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "2";
+ mpVDev->Erase();
+
+ Bitmap aBitmap(Size(4000, 4000), 2, &Bitmap::GetGreyPalette(2));
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ mpVDev->DrawBitmap(Point(), aBitmap);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmap4(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "4";
+ mpVDev->Erase();
+
+ Bitmap aBitmap(Size(4000, 4000), 4, &Bitmap::GetGreyPalette(16));
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ mpVDev->DrawBitmap(Point(), aBitmap);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmap8X(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "8X";
+ mpVDev->Erase();
+ Bitmap aBitmap(Size(4000, 4000), 8);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ mpVDev->DrawBitmap(Point(), aBitmap);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmap8(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "8";
+ mpVDev->Erase();
+ Bitmap aBitmap(Size(4000, 4000), 8, &Bitmap::GetGreyPalette(256));
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ mpVDev->DrawBitmap(Point(), aBitmap);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmap24(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "24";
+ mpVDev->Erase();
+ Bitmap aBitmap(Size(4000, 4000), 24);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer(rName.toUtf8(), 1000);
+ mpVDev->DrawBitmap(Point(), aBitmap);
+ rTotal += aTimer.stop();
+ }
+
+ void benchBitmap32(OUString& rName, sal_Int64& rTotal)
+ {
+ rName = "32";
+ mpVDev->Erase();
+ Bitmap aBitmap(Size(4000, 4000), 32);
+ aBitmap.Erase(COL_YELLOW);
+ ScopedNanoTimer aTimer("32", 1000);
+ mpVDev->DrawBitmap(Point(), aBitmap);
+ rTotal += aTimer.stop();
+ }
+};
+
+class BenchmarkApp : public Application
+{
+public:
+ BenchmarkApp() {}
+
+ virtual int Main() override
+ {
+ Benchmark aBenchmark;
+ aBenchmark.run();
+ return 0;
+ }
+
+protected:
+ void Init() override
+ {
+ try
+ {
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = ::cppu::defaultBootstrap_InitialComponentContext();
+ uno::Reference<lang::XMultiServiceFactory> xMSF
+ = uno::Reference<lang::XMultiServiceFactory>(xComponentContext->getServiceManager(),
+ uno::UNO_QUERY);
+
+ 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);
+ }
+};
+
+void vclmain::createApplication() { static BenchmarkApp aApplication; }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list