cURL: follow redirects
[LibreOffice.git] / svx / workben / pixelctl.cxx
blob1a751bec30e1df4955f592ead55ce09e853c1d99
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/main.h>
22 #include <cppuhelper/bootstrap.hxx>
23 #include <comphelper/processfactory.hxx>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <vcl/event.hxx>
29 #include <vcl/svapp.hxx>
30 #include <vcl/wrkwin.hxx>
31 #include <tools/extendapplicationenvironment.hxx>
33 #include <svx/dlgctrl.hxx>
35 #include <rtl/strbuf.hxx>
36 #include <rtl/ustrbuf.hxx>
38 #include <math.h>
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star::lang;
42 using namespace cppu;
44 // Forward declaration
45 void Main();
47 SAL_IMPLEMENT_MAIN()
49 try
51 tools::extendApplicationEnvironment();
53 // create the global service-manager
54 Reference< XComponentContext > xContext = defaultBootstrap_InitialComponentContext();
55 Reference< XMultiServiceFactory > xServiceManager( xContext->getServiceManager(), UNO_QUERY );
57 if( !xServiceManager.is() )
58 Application::Abort( "Failed to bootstrap" );
60 comphelper::setProcessServiceFactory( xServiceManager );
62 InitVCL();
63 ::Main();
64 DeInitVCL();
66 catch (const Exception& e)
68 SAL_WARN("vcl.app", "Fatal exception: " << e.Message);
69 return 1;
71 catch (const std::exception& e)
73 SAL_WARN("vcl.app", "Fatal exception: " << e.what());
74 return 1;
77 return 0;
80 class MyWin : public WorkWindow
82 VclPtr<SvxPixelCtl> maPixelCtl;
84 public:
85 MyWin(vcl::Window* pParent, WinBits nWinStyle);
86 virtual ~MyWin() override
88 disposeOnce();
90 virtual void dispose() override;
91 bool Close() override;
94 void Main()
96 ScopedVclPtrInstance< MyWin > aMainWin( nullptr, WB_STDWORK );
97 aMainWin->SetText( "SvxPixelCtl" );
98 aMainWin->Show();
100 Application::Execute();
103 MyWin::MyWin( vcl::Window* pParent, WinBits nWinStyle ) :
104 WorkWindow( pParent, nWinStyle ),
105 maPixelCtl( VclPtr<SvxPixelCtl>::Create(this) )
107 maPixelCtl->SetPosSizePixel( Point( 10, 10 ), Size( 200, 200 ) );
108 maPixelCtl->Show();
112 void MyWin::dispose()
114 maPixelCtl.disposeAndClear();
115 WorkWindow::dispose();
118 bool MyWin::Close()
120 bool bRet = WorkWindow::Close();
121 if( bRet )
122 Application::Quit();
123 return bRet;
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */