1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
9 * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
11 * The Contents of this file are made available subject to
12 * the terms of GNU Lesser General Public License Version 2.1.
15 * GNU Lesser General Public License Version 2.1
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License version 2.1, as published by the Free Software Foundation.
24 * This library is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * Lesser General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public
30 * License along with this library; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
34 ************************************************************************/
36 #include "unxsplash.hxx"
38 #ifndef _UTL_BOOTSTRAP_HXX
39 #include <unotools/bootstrap.hxx>
41 #ifndef _VOS_PROCESS_HXX_
42 #include <vos/process.hxx>
45 #include <tools/urlobj.hxx>
48 #include <tools/stream.hxx>
51 #include <sfx2/sfx.hrc>
54 #include <com/sun/star/registry/XRegistryKey.hpp>
55 #include <rtl/logfile.hxx>
56 #include <rtl/ustrbuf.hxx>
57 #include <rtl/math.hxx>
59 #define PIPE_ARG "-splash-pipe="
61 using namespace ::rtl
;
62 using namespace ::com::sun::star::registry
;
67 UnxSplashScreen::UnxSplashScreen( const Reference
< XMultiServiceFactory
>& rSMgr
)
68 : m_rFactory( rSMgr
),
73 UnxSplashScreen::~UnxSplashScreen()
75 #if OSL_DEBUG_LEVEL > 1
76 fprintf( stderr
, "UnxSplashScreen::~UnxSplashScreen()\n" );
86 void SAL_CALL
UnxSplashScreen::start( const OUString
& /*aText*/, sal_Int32
/*nRange*/ )
87 throw ( RuntimeException
)
91 void SAL_CALL
UnxSplashScreen::end()
92 throw ( RuntimeException
)
94 #if OSL_DEBUG_LEVEL > 1
95 fprintf( stderr
, "UnxSplashScreen::end()\n" );
98 fprintf( m_pOutFd
, "end\n" );
102 void SAL_CALL
UnxSplashScreen::reset()
103 throw ( RuntimeException
)
108 void SAL_CALL
UnxSplashScreen::setText( const OUString
& /*aText*/ )
109 throw ( RuntimeException
)
114 void SAL_CALL
UnxSplashScreen::setValue( sal_Int32 nValue
)
115 throw ( RuntimeException
)
119 fprintf( m_pOutFd
, "%d%%\n", nValue
);
126 UnxSplashScreen::initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
)
127 throw ( RuntimeException
)
129 ::vos::OStartupInfo aInfo
;
130 for ( sal_uInt32 i
= 0; i
< aInfo
.getCommandArgCount(); i
++ )
133 if ( aInfo
.getCommandArg( i
, aArg
) )
135 if ( aArg
.matchIgnoreAsciiCaseAsciiL( PIPE_ARG
, sizeof( PIPE_ARG
) - 1, 0 ) )
137 OUString aNum
= aArg
.copy( sizeof( PIPE_ARG
) - 1 );
138 int fd
= aNum
.toInt32();
139 m_pOutFd
= fdopen( fd
, "w" );
140 #if OSL_DEBUG_LEVEL > 1
141 fprintf( stderr
, "Got argument '-splash-pipe=%d ('%s') (%p)\n",
142 fd
, (const sal_Char
*)rtl::OUStringToOString( aNum
, RTL_TEXTENCODING_UTF8
),
149 // get service instance...
150 UnxSplashScreen
*UnxSplashScreen::m_pINSTANCE
= NULL
;
151 osl::Mutex
UnxSplashScreen::m_aMutex
;
153 Reference
< XInterface
> UnxSplashScreen::getInstance( const Reference
< XMultiServiceFactory
>& rSMgr
)
155 if ( m_pINSTANCE
== NULL
)
157 osl::MutexGuard
guard( m_aMutex
);
158 if ( m_pINSTANCE
== NULL
)
159 return (XComponent
*) new UnxSplashScreen( rSMgr
);
162 return (XComponent
*)NULL
;
165 // static service info...
166 const char* UnxSplashScreen::interfaces
[] =
168 "com.sun.star.task.XStartusIndicator",
169 "com.sun.star.lang.XInitialization",
172 const sal_Char
*UnxSplashScreen::serviceName
= "com.sun.star.office.PipeSplashScreen";
173 const sal_Char
*UnxSplashScreen::implementationName
= "com.sun.star.office.comp.PipeSplashScreen";
174 const sal_Char
*UnxSplashScreen::supportedServiceNames
[] = { "com.sun.star.office.PipeSplashScreen", NULL
};
176 OUString
UnxSplashScreen::impl_getImplementationName()
178 return OUString::createFromAscii( implementationName
);
181 Sequence
<OUString
> UnxSplashScreen::impl_getSupportedServiceNames()
183 Sequence
<OUString
> aSequence
;
184 for ( int i
= 0; supportedServiceNames
[i
] != NULL
; i
++ )
186 aSequence
.realloc( i
+1 );
187 aSequence
[i
] = OUString::createFromAscii( supportedServiceNames
[i
] );