summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-11-07 10:42:12 +0000
committerMarkus Mohrhard <markus.mohrhard@collabora.co.uk>2014-11-10 07:59:19 +0100
commit4d757fce3dd39ddec649a0b8059ab03d3a281d5e (patch)
tree41219e39e84cdc4dadfff804d30b4ae022cd9522
parentff329be4f78241edab1ed77e0c14455526db021a (diff)
vcldemo: kill all the legacy cruft.
Change-Id: I60d7d30ff20a01e375d9851afd8bd8ce12835752
-rw-r--r--vcl/Executable_vcldemo.mk4
-rw-r--r--vcl/workben/vcldemo.cxx165
2 files changed, 61 insertions, 108 deletions
diff --git a/vcl/Executable_vcldemo.mk b/vcl/Executable_vcldemo.mk
index fb29b9a1991f..561f7d6d564e 100644
--- a/vcl/Executable_vcldemo.mk
+++ b/vcl/Executable_vcldemo.mk
@@ -36,4 +36,8 @@ $(eval $(call gb_Executable_add_exception_objects,vcldemo,\
vcl/workben/vcldemo \
))
+$(eval $(call gb_Executable_use_static_libraries,vcldemo,\
+ vclmain \
+))
+
# vim: set noet sw=4 ts=4:
diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx
index 0c683ddff11c..a8eccd033253 100644
--- a/vcl/workben/vcldemo.cxx
+++ b/vcl/workben/vcldemo.cxx
@@ -5,81 +5,30 @@
* 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 incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <sal/main.h>
-#include <tools/extendapplicationenvironment.hxx>
-
-#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
-
+#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+#include <com/sun/star/ucb/UniversalContentBroker.hpp>
+
+#include <vcl/vclmain.hxx>
-#include <vcl/event.hxx>
#include <vcl/svapp.hxx>
#include <vcl/wrkwin.hxx>
-#include <vcl/msgbox.hxx>
-
-#include <unistd.h>
-#include <stdio.h>
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::lang;
-using namespace cppu;
+using namespace css;
-// Forward declaration
-void Main();
-
-SAL_IMPLEMENT_MAIN()
+class DemoWin : public WorkWindow
{
- try
- {
- tools::extendApplicationEnvironment();
-
- Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
- Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
-
- if( !xServiceManager.is() )
- Application::Abort( "Failed to bootstrap" );
-
- comphelper::setProcessServiceFactory( xServiceManager );
-
- InitVCL();
- ::Main();
- DeInitVCL();
- }
- catch (const Exception& e)
+public:
+ DemoWin() : WorkWindow( NULL, WB_APP | WB_STDWORK)
{
- SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
- return 1;
}
- return 0;
-}
-
-class MyWin : public WorkWindow
-{
-public:
- MyWin( vcl::Window* pParent, WinBits nWinStyle );
-
- virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
- virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
- virtual void KeyUp( const KeyEvent& rKEvt ) SAL_OVERRIDE;
virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
- virtual void Resize() SAL_OVERRIDE;
std::vector<Rectangle> partitionAndClear(int nX, int nY);
@@ -142,49 +91,7 @@ public:
}
};
-void Main()
-{
- MyWin aMainWin( NULL, WB_APP | WB_STDWORK );
- aMainWin.SetText( OUString( "VCLDemo - VCL Workbench" ) );
- aMainWin.Show();
-
- Application::Execute();
-}
-
-MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
- WorkWindow( pParent, nWinStyle )
-{
-}
-
-void MyWin::MouseMove( const MouseEvent& rMEvt )
-{
- WorkWindow::MouseMove( rMEvt );
-}
-
-void MyWin::MouseButtonDown( const MouseEvent& rMEvt )
-{
- Rectangle aRect(0,0,4,4);
- aRect.SetPos( rMEvt.GetPosPixel() );
- SetFillColor(Color(COL_RED));
- DrawRect( aRect );
-}
-
-void MyWin::MouseButtonUp( const MouseEvent& rMEvt )
-{
- WorkWindow::MouseButtonUp( rMEvt );
-}
-
-void MyWin::KeyInput( const KeyEvent& rKEvt )
-{
- WorkWindow::KeyInput( rKEvt );
-}
-
-void MyWin::KeyUp( const KeyEvent& rKEvt )
-{
- WorkWindow::KeyUp( rKEvt );
-}
-
-std::vector<Rectangle> MyWin::partitionAndClear(int nX, int nY)
+std::vector<Rectangle> DemoWin::partitionAndClear(int nX, int nY)
{
Rectangle r;
std::vector<Rectangle> aRegions;
@@ -219,9 +126,9 @@ std::vector<Rectangle> MyWin::partitionAndClear(int nX, int nY)
return aRegions;
}
-void MyWin::Paint( const Rectangle& rRect )
+void DemoWin::Paint( const Rectangle& rRect )
{
- fprintf(stderr, "MyWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
+ fprintf(stderr, "DemoWin::Paint(%ld,%ld,%ld,%ld)\n", rRect.getX(), rRect.getY(), rRect.getWidth(), rRect.getHeight());
drawBackground();
@@ -236,9 +143,51 @@ void MyWin::Paint( const Rectangle& rRect )
drawGradient(aRegions[i++]);
}
-void MyWin::Resize()
+class DemoApp : public Application
+{
+public:
+ DemoApp() {}
+
+ virtual int Main() SAL_OVERRIDE
+ {
+ DemoWin aMainWin;
+ aMainWin.SetText( "Interactive VCL demo" );
+ aMainWin.Show();
+ Application::Execute();
+ }
+
+protected:
+ uno::Reference<lang::XMultiServiceFactory> xMSF;
+ void Init() SAL_OVERRIDE
+ {
+ try
+ {
+ uno::Reference<uno::XComponentContext> xComponentContext
+ = ::cppu::defaultBootstrap_InitialComponentContext();
+ 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() SAL_OVERRIDE
+ {
+ uno::Reference< lang::XComponent >(
+ comphelper::getProcessComponentContext(),
+ uno::UNO_QUERY_THROW )-> dispose();
+ ::comphelper::setProcessServiceFactory( NULL );
+ }
+};
+
+void vclmain::createApplication()
{
- WorkWindow::Resize();
+ static DemoApp aApp;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */