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