1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
22 #include <osl/process.h>
23 #include <com/sun/star/registry/XRegistryKey.hpp>
24 #include <cppuhelper/implementationentry.hxx>
25 #include <rtl/logfile.hxx>
26 #include <rtl/ustrbuf.hxx>
27 #include <rtl/math.hxx>
29 #define PIPE_ARG "--splash-pipe="
31 using namespace ::rtl
;
32 using namespace ::com::sun::star
;
33 using namespace ::com::sun::star::registry
;
34 using namespace ::com::sun::star::uno
;
38 UnxSplashScreen::UnxSplashScreen( const Reference
< uno::XComponentContext
>& xCtx
)
44 UnxSplashScreen::~UnxSplashScreen()
46 #if OSL_DEBUG_LEVEL > 1
47 fprintf( stderr
, "UnxSplashScreen::~UnxSplashScreen()\n" );
57 void SAL_CALL
UnxSplashScreen::start( const OUString
& /*aText*/, sal_Int32
/*nRange*/ )
58 throw ( RuntimeException
)
62 void SAL_CALL
UnxSplashScreen::end()
63 throw ( RuntimeException
)
65 #if OSL_DEBUG_LEVEL > 1
66 fprintf( stderr
, "UnxSplashScreen::end()\n" );
71 fprintf( m_pOutFd
, "end\n" );
75 void SAL_CALL
UnxSplashScreen::reset()
76 throw ( RuntimeException
)
78 #if OSL_DEBUG_LEVEL > 1
79 fprintf( stderr
, "UnxSplashScreen::reset()\n" );
84 fprintf( m_pOutFd
, "restart\n" );
88 void SAL_CALL
UnxSplashScreen::setText( const OUString
& /*aText*/ )
89 throw ( RuntimeException
)
94 void SAL_CALL
UnxSplashScreen::setValue( sal_Int32 nValue
)
95 throw ( RuntimeException
)
99 fprintf( m_pOutFd
, "%" SAL_PRIdINT32
"%%\n", nValue
);
106 UnxSplashScreen::initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& )
107 throw ( RuntimeException
)
109 for ( sal_uInt32 i
= 0; i
< osl_getCommandArgCount(); i
++ )
112 if ( osl_getCommandArg( i
, &aArg
.pData
) )
114 if ( aArg
.matchIgnoreAsciiCaseAsciiL( PIPE_ARG
, sizeof( PIPE_ARG
) - 1, 0 ) )
116 OUString aNum
= aArg
.copy( sizeof( PIPE_ARG
) - 1 );
117 int fd
= aNum
.toInt32();
118 m_pOutFd
= fdopen( fd
, "w" );
119 #if OSL_DEBUG_LEVEL > 1
120 fprintf( stderr
, "Got argument '--splash-pipe=%d ('%s') (%p)\n",
121 fd
, OUStringToOString( aNum
, RTL_TEXTENCODING_UTF8
).getStr(),
129 using namespace desktop
;
131 // get service instance...
132 static uno::Reference
< uno::XInterface
> m_xINSTANCE
;
134 uno::Reference
< uno::XInterface
> SAL_CALL
UnxSplash_createInstance(const uno::Reference
< uno::XComponentContext
> & xCtx
) throw( uno::Exception
)
136 static osl::Mutex m_aMutex
;
137 if ( !m_xINSTANCE
.is() )
139 osl::MutexGuard
guard( m_aMutex
);
140 if ( !m_xINSTANCE
.is() )
141 m_xINSTANCE
= (cppu::OWeakObject
*) new UnxSplashScreen( xCtx
);
147 OUString
UnxSplash_getImplementationName()
149 return OUString( "com.sun.star.office.comp.PipeSplashScreen" );
152 uno::Sequence
< OUString
> SAL_CALL
UnxSplash_getSupportedServiceNames() throw()
154 const OUString
aServiceName( "com.sun.star.office.PipeSplashScreen" );
155 const uno::Sequence
< OUString
> aSeq( &aServiceName
, 1 );
159 ::cppu::ImplementationEntry aEntries
[] =
162 UnxSplash_createInstance
, UnxSplash_getImplementationName
,
163 UnxSplash_getSupportedServiceNames
,
164 ::cppu::createSingleComponentFactory
,
173 SAL_DLLPUBLIC_EXPORT
void* SAL_CALL
splash_component_getFactory( const sal_Char
* pImplName
, void* pServiceManager
, void* pRegistryKey
)
175 return ::cppu::component_getFactoryHelper( pImplName
, pServiceManager
,
176 pRegistryKey
, aEntries
);
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */