diff options
author | Hossein <hossein@libreoffice.org> | 2021-12-30 11:43:47 +0100 |
---|---|---|
committer | Hossein <hossein@libreoffice.org> | 2021-12-30 13:36:23 +0100 |
commit | dd1b0471b70f9b5c5db6b681c1fceacfe17c9349 (patch) | |
tree | e39ddc2d1151301ef6aefde50e03d729c0fd9104 | |
parent | 206c52d1248cc474fc7c3bbb6812688c97eb2ca0 (diff) |
Minimal vcl application
Created a minimal vcl application inside vcl/workben in ~55 loc
in which creates a window and paints a simple text inside it.
One can run the application by invoking:
./bin/run minvcl
Change-Id: If648666ff25c4b66089a37c8d8164752663fa225
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125124
Tested-by: Jenkins
Reviewed-by: Hossein <hossein@libreoffice.org>
-rw-r--r-- | Repository.mk | 1 | ||||
-rw-r--r-- | vcl/Executable_minvcl.mk | 37 | ||||
-rw-r--r-- | vcl/Module_vcl.mk | 1 | ||||
-rw-r--r-- | vcl/workben/minvcl.cxx | 77 |
4 files changed, 116 insertions, 0 deletions
diff --git a/Repository.mk b/Repository.mk index dddb180f589c..812d47dc18df 100644 --- a/Repository.mk +++ b/Repository.mk @@ -67,6 +67,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ xrmex \ $(if $(filter-out ANDROID iOS WNT,$(OS)), \ svdemo \ + minvcl \ fftester \ svptest \ svpclient ) \ diff --git a/vcl/Executable_minvcl.mk b/vcl/Executable_minvcl.mk new file mode 100644 index 000000000000..8de973dcd1f4 --- /dev/null +++ b/vcl/Executable_minvcl.mk @@ -0,0 +1,37 @@ +# -*- 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,minvcl)) + +$(eval $(call gb_Executable_use_api,minvcl,\ + offapi \ + udkapi \ +)) + +$(eval $(call gb_Executable_set_include,minvcl,\ + $$(INCLUDE) \ + -I$(SRCDIR)/vcl/inc \ +)) + +$(eval $(call gb_Executable_use_libraries,minvcl,\ + tl \ + sal \ + vcl \ + cppu \ + cppuhelper \ + comphelper \ + i18nlangtag \ +)) + +$(eval $(call gb_Executable_add_exception_objects,minvcl,\ + vcl/workben/minvcl \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/vcl/Module_vcl.mk b/vcl/Module_vcl.mk index b1cfb2c5b2cd..6b15c775b6f0 100644 --- a/vcl/Module_vcl.mk +++ b/vcl/Module_vcl.mk @@ -46,6 +46,7 @@ ifeq ($(CROSS_COMPILING)$(DISABLE_DYNLOADING),) $(eval $(call gb_Module_add_targets,vcl,\ $(if $(filter-out ANDROID iOS WNT,$(OS)), \ Executable_svdemo \ + Executable_minvcl \ Executable_fftester \ Executable_svptest \ Executable_svpclient) \ diff --git a/vcl/workben/minvcl.cxx b/vcl/workben/minvcl.cxx new file mode 100644 index 000000000000..98e8dddaacc3 --- /dev/null +++ b/vcl/workben/minvcl.cxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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 <cppuhelper/bootstrap.hxx> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <i18nlangtag/languagetag.hxx> +#include <i18nlangtag/mslangid.hxx> + +#include <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> + +namespace +{ +class TheWindow : public WorkWindow +{ +public: + TheWindow() + : WorkWindow(nullptr, WB_APP | WB_STDWORK) + { + } + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect); +}; + +class TheApplication : public Application +{ +public: + virtual int Main(); + +private: + VclPtr<TheWindow> mpWin; +}; +} + +void TheWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) +{ + rRenderContext.DrawText(Point(rRect.GetWidth() / 2, rRect.getHeight() / 2), + OUString(u"VCL module in LibreOffice")); +} + +int TheApplication::Main() +{ + mpWin = VclPtr<TheWindow>::Create(); + mpWin->SetText(u"VCL"); + mpWin->Show(); + Execute(); + mpWin.disposeAndClear(); + return 0; +} + +int main() +{ + auto xContext = cppu::defaultBootstrap_InitialComponentContext(); + css::uno::Reference<css::lang::XMultiServiceFactory> xServiceManager( + xContext->getServiceManager(), css::uno::UNO_QUERY); + comphelper::setProcessServiceFactory(xServiceManager); + LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage()); + + TheApplication aApp; + InitVCL(); + int ret = aApp.Main(); + DeInitVCL(); + + css::uno::Reference<css::lang::XComponent>(xContext, css::uno::UNO_QUERY_THROW)->dispose(); + comphelper::setProcessServiceFactory(nullptr); + + return ret; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |