LibreOffice Module desktop (master)  1
unxsplash.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #include "unxsplash.hxx"
21 #include <stdio.h>
22 #include <osl/process.h>
24 #include <sal/log.hxx>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 
27 using namespace com::sun::star;
28 
29 namespace desktop
30 {
31  UnxSplashScreen::UnxSplashScreen()
32  : m_pOutFd( nullptr )
33 {
34 }
35 
37 {
38  SAL_INFO("desktop.splash", "UnxSplashScreen::~UnxSplashScreen()");
39  if ( m_pOutFd )
40  {
41  fclose( m_pOutFd );
42  m_pOutFd = nullptr;
43  }
44 }
45 
46 void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
47 {
48 }
49 
50 void SAL_CALL UnxSplashScreen::end()
51 {
52  SAL_INFO("desktop.splash", "UnxSplashScreen::end()");
53  if( !m_pOutFd )
54  return;
55 
56  fprintf( m_pOutFd, "end\n" );
57  fflush( m_pOutFd );
58 }
59 
60 void SAL_CALL UnxSplashScreen::reset()
61 {
62  SAL_INFO("desktop.splash", "UNXSplashScreen::reset()");
63  if( !m_pOutFd )
64  return;
65 
66  fprintf( m_pOutFd, "restart\n" );
67  fflush( m_pOutFd );
68 }
69 
70 void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
71 {
72  // TODO?
73 }
74 
75 void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
76 {
77  if ( m_pOutFd )
78  {
79  fprintf( m_pOutFd, "%" SAL_PRIdINT32 "%%\n", nValue );
80  fflush( m_pOutFd );
81  }
82 }
83 
84 // XInitialize
85 void SAL_CALL
86 UnxSplashScreen::initialize( const css::uno::Sequence< css::uno::Any>& )
87 {
88  for ( sal_uInt32 i = 0; i < osl_getCommandArgCount(); i++ )
89  {
90  OUString aArg;
91  osl_getCommandArg( i, &aArg.pData );
92  OUString aNum;
93  if ( aArg.startsWithIgnoreAsciiCase("--splash-pipe=", &aNum) )
94  {
95  auto fd = aNum.toUInt32();
96  m_pOutFd = fdopen( fd, "w" );
97  SAL_INFO("desktop.splash", "Got argument '--splash-pipe=" << fd << " ('"
98  << aNum << "') ("
99  << static_cast<void *>(m_pOutFd) << ")");
100  }
101  }
102 }
103 
105 {
106  return "com.sun.star.office.comp.PipeSplashScreen";
107 }
108 
109 sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName)
110 {
111  return cppu::supportsService(this, ServiceName);
112 }
113 
114 css::uno::Sequence<OUString> UnxSplashScreen::getSupportedServiceNames()
115 {
116  return { "com.sun.star.office.PipeSplashScreen" };
117 }
118 
119 }
120 
121 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
123  css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
124 {
125  return cppu::acquire(new desktop::UnxSplashScreen());
126 }
127 
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unxsplash.cxx:114
virtual void SAL_CALL setText(const OUString &aText) override
Definition: unxsplash.cxx:70
virtual void SAL_CALL setValue(sal_Int32 nValue) override
Definition: unxsplash.cxx:75
Definition: app.cxx:164
virtual void SAL_CALL end() override
Definition: unxsplash.cxx:50
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
virtual ~UnxSplashScreen() override
Definition: unxsplash.cxx:36
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * desktop_UnxSplash_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: unxsplash.cxx:122
unsigned char sal_Bool
virtual void SAL_CALL start(const OUString &aText, sal_Int32 nRange) override
Definition: unxsplash.cxx:46
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: unxsplash.cxx:86
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: unxsplash.cxx:109
#define SAL_INFO(area, stream)
virtual void SAL_CALL reset() override
Definition: unxsplash.cxx:60
virtual OUString SAL_CALL getImplementationName() override
Definition: unxsplash.cxx:104