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 /vcl/workben | |
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>
Diffstat (limited to 'vcl/workben')
-rw-r--r-- | vcl/workben/minvcl.cxx | 77 |
1 files changed, 77 insertions, 0 deletions
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: */ |