lok: impress: show only supported transitions in the side pane
[LibreOffice.git] / vcl / workben / mtfdemo.cxx
blob0ee726e051f835410d17107aceb9628fbba355bf
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/.
8 */
10 #include <comphelper/processfactory.hxx>
11 #include <cppuhelper/bootstrap.hxx>
12 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
13 #include <com/sun/star/lang/XInitialization.hpp>
14 #include <com/sun/star/registry/XSimpleRegistry.hpp>
15 #include <com/sun/star/ucb/UniversalContentBroker.hpp>
17 #include <vcl/vclmain.hxx>
18 #include <vcl/layout.hxx>
19 #include <vcl/gdimtf.hxx>
20 #include <vcl/wmf.hxx>
22 #include <tools/diagnose_ex.h>
23 #include <tools/urlobj.hxx>
24 #include <tools/stream.hxx>
25 #include <tools/vcompat.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/wrkwin.hxx>
28 #include <vcl/virdev.hxx>
29 #include <sal/log.hxx>
31 #include <cstdlib>
33 using namespace css;
35 class DemoMtfWin : public WorkWindow
37 GDIMetaFile maMtf;
39 public:
40 explicit DemoMtfWin(const OUString& rFileName)
41 : WorkWindow(nullptr, WB_APP | WB_STDWORK)
43 SvFileStream aFileStream(rFileName, StreamMode::READ);
45 if (aFileStream.IsOpen())
47 ReadWindowMetafile(aFileStream, maMtf);
49 else
51 Application::Abort("Can't read metafile");
55 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
58 void DemoMtfWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
60 maMtf.Play(this, maMtf.GetActionSize());
62 WorkWindow::Paint(rRenderContext, rRect);
65 class DemoMtfApp : public Application
67 VclPtr<DemoMtfWin> mpWin;
68 OUString maFileName;
70 static void showHelp()
72 fprintf(stderr, "Usage: mtfdemo --help | FILE\n");
73 fprintf(stderr, "A VCL test app that displays Windows metafiles\n");
74 std::exit(0);
77 public:
79 DemoMtfApp()
80 : mpWin(nullptr)
84 virtual int Main() override
86 try
88 mpWin = VclPtr<DemoMtfWin>::Create(maFileName);
89 mpWin->SetText("Display metafile");
91 mpWin->Show();
93 Application::Execute();
95 catch (const css::uno::Exception&)
97 TOOLS_WARN_EXCEPTION("vcl.app", "Fatal");
98 return 1;
100 catch (const std::exception& e)
102 SAL_WARN("vcl.app", "Fatal: " << e.what());
103 return 1;
105 return 0;
108 private:
109 uno::Reference<lang::XMultiServiceFactory> xMSF;
110 void Init() override
114 const sal_uInt16 nCmdParams = GetCommandLineParamCount();
116 if (nCmdParams == 0)
117 showHelp();
118 else
120 OUString aArg = GetCommandLineParam(0);
122 if (aArg == "--help" || aArg == "-h")
123 showHelp();
124 else
125 maFileName = aArg;
128 uno::Reference<uno::XComponentContext> xComponentContext
129 = ::cppu::defaultBootstrap_InitialComponentContext();
130 xMSF.set(xComponentContext->getServiceManager(), uno::UNO_QUERY);
131 if(!xMSF.is())
132 Application::Abort("Bootstrap failure - no service manager");
134 ::comphelper::setProcessServiceFactory(xMSF);
136 catch (const uno::Exception &e)
138 Application::Abort("Bootstrap exception " + e.Message);
142 void DeInit() override
144 uno::Reference< lang::XComponent >(
145 comphelper::getProcessComponentContext(),
146 uno::UNO_QUERY_THROW)-> dispose();
147 ::comphelper::setProcessServiceFactory(nullptr);
153 void vclmain::createApplication()
155 static DemoMtfApp aApp;
158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */