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 
26 using namespace com::sun::star;
27 
28 namespace desktop
29 {
30  UnxSplashScreen::UnxSplashScreen()
31  : m_pOutFd( nullptr )
32 {
33 }
34 
36 {
37  SAL_INFO("desktop.splash", "UnxSplashScreen::~UnxSplashScreen()");
38  if ( m_pOutFd )
39  {
40  fclose( m_pOutFd );
41  m_pOutFd = nullptr;
42  }
43 }
44 
45 void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
46 {
47 }
48 
49 void SAL_CALL UnxSplashScreen::end()
50 {
51  SAL_INFO("desktop.splash", "UnxSplashScreen::end()");
52  if( !m_pOutFd )
53  return;
54 
55  fprintf( m_pOutFd, "end\n" );
56  fflush( m_pOutFd );
57 }
58 
59 void SAL_CALL UnxSplashScreen::reset()
60 {
61  SAL_INFO("desktop.splash", "UNXSplashScreen::reset()");
62  if( !m_pOutFd )
63  return;
64 
65  fprintf( m_pOutFd, "restart\n" );
66  fflush( m_pOutFd );
67 }
68 
69 void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
70 {
71  // TODO?
72 }
73 
74 void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
75 {
76  if ( m_pOutFd )
77  {
78  fprintf( m_pOutFd, "%" SAL_PRIdINT32 "%%\n", nValue );
79  fflush( m_pOutFd );
80  }
81 }
82 
83 // XInitialize
84 void SAL_CALL
85 UnxSplashScreen::initialize( const css::uno::Sequence< css::uno::Any>& )
86 {
87  for ( sal_uInt32 i = 0; i < osl_getCommandArgCount(); i++ )
88  {
89  OUString aArg;
90  osl_getCommandArg( i, &aArg.pData );
91  OUString aNum;
92  if ( aArg.startsWithIgnoreAsciiCase("--splash-pipe=", &aNum) )
93  {
94  auto fd = aNum.toUInt32();
95  m_pOutFd = fdopen( fd, "w" );
96  SAL_INFO("desktop.splash", "Got argument '--splash-pipe=" << fd << " ('"
97  << aNum << "') ("
98  << static_cast<void *>(m_pOutFd) << ")");
99  }
100  }
101 }
102 
104 {
106 }
107 
108 sal_Bool UnxSplashScreen::supportsService(OUString const & ServiceName)
109 {
110  return cppu::supportsService(this, ServiceName);
111 }
112 
113 css::uno::Sequence<OUString> UnxSplashScreen::getSupportedServiceNames()
114 {
116 }
117 
118 }
119 
120 using namespace desktop;
121 
122 // get service instance...
123 static uno::Reference< uno::XInterface > m_xINSTANCE;
124 
125 uno::Reference< uno::XInterface > UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > & )
126 {
127  static osl::Mutex s_aMutex;
128  if ( !m_xINSTANCE.is() )
129  {
130  osl::MutexGuard guard( s_aMutex );
131  if ( !m_xINSTANCE.is() )
132  m_xINSTANCE = static_cast<cppu::OWeakObject*>(new UnxSplashScreen);
133  }
134 
135  return m_xINSTANCE;
136 }
137 
139 {
140  return "com.sun.star.office.comp.PipeSplashScreen";
141 }
142 
143 uno::Sequence< OUString > UnxSplash_getSupportedServiceNames() throw()
144 {
145  return uno::Sequence< OUString > { "com.sun.star.office.PipeSplashScreen" };
146 }
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unxsplash.cxx:113
virtual void SAL_CALL setText(const OUString &aText) override
Definition: unxsplash.cxx:69
virtual void SAL_CALL setValue(sal_Int32 nValue) override
Definition: unxsplash.cxx:74
Definition: app.cxx:161
virtual void SAL_CALL end() override
Definition: unxsplash.cxx:49
static uno::Reference< uno::XInterface > m_xINSTANCE
Definition: unxsplash.cxx:123
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
uno::Reference< uno::XInterface > UnxSplash_createInstance(const uno::Reference< uno::XComponentContext > &)
Definition: unxsplash.cxx:125
int i
virtual ~UnxSplashScreen() override
Definition: unxsplash.cxx:35
unsigned char sal_Bool
virtual void SAL_CALL start(const OUString &aText, sal_Int32 nRange) override
Definition: unxsplash.cxx:45
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
Definition: unxsplash.cxx:85
OUString UnxSplash_getImplementationName()
Definition: unxsplash.cxx:138
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
Definition: unxsplash.cxx:108
#define SAL_INFO(area, stream)
uno::Sequence< OUString > UnxSplash_getSupportedServiceNames()
Definition: unxsplash.cxx:143
virtual void SAL_CALL reset() override
Definition: unxsplash.cxx:59
virtual OUString SAL_CALL getImplementationName() override
Definition: unxsplash.cxx:103