lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / desktop / source / splash / unxsplash.cxx
blob702d1913070813cbd6acca796931e71ef5387fdd
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>
28 #include <tools/diagnose_ex.h>
30 using namespace com::sun::star;
32 namespace desktop
34 UnxSplashScreen::UnxSplashScreen()
35 : m_pOutFd( nullptr )
39 UnxSplashScreen::~UnxSplashScreen()
41 SAL_INFO("desktop.splash", "UnxSplashScreen::~UnxSplashScreen()");
42 if ( m_pOutFd )
44 fclose( m_pOutFd );
45 m_pOutFd = nullptr;
49 void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
53 void SAL_CALL UnxSplashScreen::end()
55 SAL_INFO("desktop.splash", "UnxSplashScreen::end()");
56 if( !m_pOutFd )
57 return;
59 fprintf( m_pOutFd, "end\n" );
60 fflush( m_pOutFd );
63 void SAL_CALL UnxSplashScreen::reset()
65 SAL_INFO("desktop.splash", "UNXSplashScreen::reset()");
66 if( !m_pOutFd )
67 return;
69 fprintf( m_pOutFd, "restart\n" );
70 fflush( m_pOutFd );
73 void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
75 // TODO?
78 void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
80 if ( m_pOutFd )
82 fprintf( m_pOutFd, "%" SAL_PRIdINT32 "%%\n", nValue );
83 fflush( m_pOutFd );
87 // XInitialize
88 void SAL_CALL
89 UnxSplashScreen::initialize( const css::uno::Sequence< css::uno::Any>& )
91 for ( sal_uInt32 i = 0; i < osl_getCommandArgCount(); i++ )
93 OUString aArg;
94 osl_getCommandArg( i, &aArg.pData );
95 OUString aNum;
96 if ( aArg.startsWithIgnoreAsciiCase("--splash-pipe=", &aNum) )
98 auto fd = aNum.toUInt32();
99 m_pOutFd = fdopen( fd, "w" );
100 SAL_INFO("desktop.splash", "Got argument '--splash-pipe=" << fd << " ('"
101 << aNum << "') ("
102 << static_cast<void *>(m_pOutFd) << ")");
107 OUString UnxSplashScreen::getImplementationName()
109 return UnxSplash_getImplementationName();
112 sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName)
114 return cppu::supportsService(this, ServiceName);
117 css::uno::Sequence<OUString> UnxSplashScreen::getSupportedServiceNames()
119 return UnxSplash_getSupportedServiceNames();
124 using namespace desktop;
126 // get service instance...
127 static uno::Reference< uno::XInterface > m_xINSTANCE;
129 uno::Reference< uno::XInterface > UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > & )
131 static osl::Mutex s_aMutex;
132 if ( !m_xINSTANCE.is() )
134 osl::MutexGuard guard( s_aMutex );
135 if ( !m_xINSTANCE.is() )
136 m_xINSTANCE = static_cast<cppu::OWeakObject*>(new UnxSplashScreen);
139 return m_xINSTANCE;
142 OUString UnxSplash_getImplementationName()
144 return "com.sun.star.office.comp.PipeSplashScreen";
147 uno::Sequence< OUString > UnxSplash_getSupportedServiceNames() throw()
149 return uno::Sequence< OUString > { "com.sun.star.office.PipeSplashScreen" };
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */