Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / desktop / source / splash / unxsplash.cxx
blobb068cfa28e5c1c11520084aea6229e3616f13be5
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 "unxsplash.hxx"
21 #include <stdio.h>
22 #include <osl/process.h>
23 #include <cppuhelper/implementationentry.hxx>
24 #include <cppuhelper/supportsservice.hxx>
25 #include <rtl/ustrbuf.hxx>
26 #include <rtl/math.hxx>
27 #include <sal/log.hxx>
29 using namespace com::sun::star;
31 namespace desktop
33 UnxSplashScreen::UnxSplashScreen()
34 : m_pOutFd( nullptr )
38 UnxSplashScreen::~UnxSplashScreen()
40 SAL_INFO("desktop.splash", "UnxSplashScreen::~UnxSplashScreen()");
41 if ( m_pOutFd )
43 fclose( m_pOutFd );
44 m_pOutFd = nullptr;
48 void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
52 void SAL_CALL UnxSplashScreen::end()
54 SAL_INFO("desktop.splash", "UnxSplashScreen::end()");
55 if( !m_pOutFd )
56 return;
58 fprintf( m_pOutFd, "end\n" );
59 fflush( m_pOutFd );
62 void SAL_CALL UnxSplashScreen::reset()
64 SAL_INFO("desktop.splash", "UNXSplashScreen::reset()");
65 if( !m_pOutFd )
66 return;
68 fprintf( m_pOutFd, "restart\n" );
69 fflush( m_pOutFd );
72 void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
74 // TODO?
77 void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
79 if ( m_pOutFd )
81 fprintf( m_pOutFd, "%" SAL_PRIdINT32 "%%\n", nValue );
82 fflush( m_pOutFd );
86 // XInitialize
87 void SAL_CALL
88 UnxSplashScreen::initialize( const css::uno::Sequence< css::uno::Any>& )
90 for ( sal_uInt32 i = 0; i < osl_getCommandArgCount(); i++ )
92 OUString aArg;
93 osl_getCommandArg( i, &aArg.pData );
94 OUString aNum;
95 if ( aArg.startsWithIgnoreAsciiCase("--splash-pipe=", &aNum) )
97 auto fd = aNum.toUInt32();
98 m_pOutFd = fdopen( fd, "w" );
99 SAL_INFO("desktop.splash", "Got argument '--splash-pipe=" << fd << " ('"
100 << aNum << "') ("
101 << static_cast<void *>(m_pOutFd) << ")");
106 OUString UnxSplashScreen::getImplementationName()
108 return UnxSplash_getImplementationName();
111 sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName)
113 return cppu::supportsService(this, ServiceName);
116 css::uno::Sequence<OUString> UnxSplashScreen::getSupportedServiceNames()
118 return UnxSplash_getSupportedServiceNames();
123 using namespace desktop;
125 // get service instance...
126 static uno::Reference< uno::XInterface > m_xINSTANCE;
128 uno::Reference< uno::XInterface > UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > & )
130 static osl::Mutex s_aMutex;
131 if ( !m_xINSTANCE.is() )
133 osl::MutexGuard guard( s_aMutex );
134 if ( !m_xINSTANCE.is() )
135 m_xINSTANCE = static_cast<cppu::OWeakObject*>(new UnxSplashScreen);
138 return m_xINSTANCE;
141 OUString UnxSplash_getImplementationName()
143 return "com.sun.star.office.comp.PipeSplashScreen";
146 uno::Sequence< OUString > UnxSplash_getSupportedServiceNames() throw()
148 return uno::Sequence< OUString > { "com.sun.star.office.PipeSplashScreen" };
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */