Update to m13
[ooovba.git] / applied_patches / 0118-unxsplash-rework.diff
blobf957c1aa190c4c29f8caa88868afbacf67e388b4
1 diff --git desktop/inc/app.hxx desktop/inc/app.hxx
2 index aae085b..d686e56 100644
3 --- desktop/inc/app.hxx
4 +++ desktop/inc/app.hxx
5 @@ -90,6 +90,7 @@ class Desktop : public Application
6 ~Desktop();
7 virtual void Main( );
8 virtual void Init();
9 + virtual void InitFinished();
10 virtual void DeInit();
11 virtual BOOL QueryExit();
12 virtual USHORT Exception(USHORT nError);
13 diff --git desktop/prj/build.lst desktop/prj/build.lst
14 index 89c2d8c..0b010ef 100644
15 --- desktop/prj/build.lst
16 +++ desktop/prj/build.lst
17 @@ -18,6 +18,8 @@ dt desktop\win32\source\applauncher nmake - w dt_applauncher dt_inc NULL
18 dt desktop\win32\source\applauncher\ooo nmake - w dt_applauncher_ooo dt_applauncher.w dt_inc NULL
19 dt desktop\os2\source\applauncher nmake - p dt_applauncher dt_inc NULL
20 dt desktop\unx\source\officeloader nmake - u dt_officeloader_unx dt_inc NULL
21 +dt desktop\unx\source nmake - u dt_uwrapper dt_inc NULL
22 +dt desktop\unx\splash nmake - u dt_usplash dt_inc NULL
23 dt desktop\source\pagein nmake - u dt_pagein dt_inc NULL
24 dt desktop\source\pkgchk\unopkg nmake - all dt_unopkg dt_dp_misc dt_app dt_inc dt_guiloader.w NULL
25 dt desktop\source\deployment nmake - all dt_deployment dt_dp_manager dt_dp_registry dt_dp_registry_package dt_dp_registry_executable dt_dp_registry_help dt_dp_registry_script dt_dp_registry_sfwk dt_dp_registry_component dt_dp_registry_configuration dt_dp_migration dt_dp_unopkg dt_inc NULL
26 @@ -35,5 +37,5 @@ dt desktop\source\deployment\registry\configuration nmake - all dt_dp_registry_c
27 dt desktop\source\deployment\registry\help nmake - all dt_dp_registry_help dt_inc NULL
28 dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_executable dt_inc NULL
29 dt desktop\scripts nmake - u dt_scripts dt_inc NULL
30 -dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr NULL
31 +dt desktop\util nmake - all dt_util dt_app dt_so_comp dt_spl dt_uwrapper.u dt_usplash.u dt_wrapper.w dt_officeloader.w dt_officeloader_unx.u dt_migr NULL
32 dt desktop\zipintro nmake - all dt_zipintro NULL
33 diff --git desktop/prj/d.lst desktop/prj/d.lst
34 index 1f401d8..78e9977 100644
35 --- desktop/prj/d.lst
36 +++ desktop/prj/d.lst
37 @@ -13,6 +13,7 @@ mkdir: %_DEST%\bin%_EXT%\odf4ms
38 ..\%__SRC%\bin\officeloader.exe %_DEST%\bin%_EXT%\soffice.exe
39 ..\%__SRC%\bin\soffice %_DEST%\bin%_EXT%\soffice.bin
40 ..\%__SRC%\bin\soffice_mac %_DEST%\bin%_EXT%\soffice
41 +..\%__SRC%\bin\oosplash %_DEST%\bin%_EXT%\oosplash.bin
42 ..\%__SRC%\bin\so\soffice.bin %_DEST%\bin%_EXT%\so\soffice.bin
43 ..\%__SRC%\bin\so\officeloader.exe %_DEST%\bin%_EXT%\so\soffice.exe
44 ..\%__SRC%\bin\so\soffice %_DEST%\bin%_EXT%\so\soffice.bin
45 diff --git desktop/scripts/soffice.sh desktop/scripts/soffice.sh
46 index b469f35..9ebd74c 100644
47 --- desktop/scripts/soffice.sh
48 +++ desktop/scripts/soffice.sh
49 @@ -128,6 +128,16 @@ sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-common"
50 PATH=$sd_prog${PATH+:$PATH}
51 export PATH
53 +# test for availability of the fast external splash
54 +for arg in $@; do
55 + if [ "$arg" = "-nologo" -o "$arg" = "-no-oosplash" ]; then
56 + no_oosplash=y
57 + fi
58 +done
59 +if [ "$sd_binary" = "soffice.bin" -a -x "$sd_prog/oosplash.bin" ] && [ "$no_oosplash" != "y" ] ; then
60 + sd_binary="oosplash.bin"
61 +fi
63 # execute soffice binary
64 "$sd_prog/$sd_binary" "$@" &
65 trap 'kill -9 $!' TERM
66 diff --git desktop/source/app/app.cxx desktop/source/app/app.cxx
67 index deac5f2..b1645eb 100644
68 --- desktop/source/app/app.cxx
69 +++ desktop/source/app/app.cxx
70 @@ -506,6 +506,13 @@ void Desktop::Init()
74 +void Desktop::InitFinished()
76 + RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::InitFinished" );
78 + CloseSplashScreen();
81 void Desktop::DeInit()
83 RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::DeInit" );
84 @@ -1232,6 +1239,7 @@ void Desktop::Main()
85 OpenSplashScreen();
86 RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main } OpenSplashScreen" );
88 + SetSplashScreenProgress(10);
90 UserInstall::UserInstallError instErr_fin = UserInstall::finalize();
91 if ( instErr_fin != UserInstall::E_None)
92 @@ -1247,7 +1255,7 @@ void Desktop::Main()
94 // refresh path information
95 utl::Bootstrap::reloadData();
96 - SetSplashScreenProgress(25);
97 + SetSplashScreenProgress(20);
100 Reference< XMultiServiceFactory > xSMgr =
101 @@ -1260,7 +1268,7 @@ void Desktop::Main()
103 RegisterServices( xSMgr );
105 - //SetSplashScreenProgress(15);
106 + SetSplashScreenProgress(25);
108 #ifndef UNX
109 if ( pCmdLineArgs->IsHelp() ) {
110 @@ -1298,7 +1306,7 @@ void Desktop::Main()
111 // Read the common configuration items for optimization purpose
112 if ( !InitializeConfiguration() ) return;
114 - //SetSplashScreenProgress(20);
115 + SetSplashScreenProgress(30);
117 // set static variable to enabled/disable crash reporter
118 retrieveCrashReporterState();
119 @@ -1357,10 +1365,10 @@ void Desktop::Main()
120 #endif
122 SetDisplayName( aTitle );
123 -// SetSplashScreenProgress(30);
124 + SetSplashScreenProgress(35);
125 RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtLanguageOptions" );
126 pPathOptions.reset( new SvtPathOptions);
127 -// SetSplashScreenProgress(40);
128 + SetSplashScreenProgress(40);
129 // pLanguageOptions = new SvtLanguageOptions(sal_True);
130 // SetSplashScreenProgress(45);
131 RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtLanguageOptions" );
132 @@ -1452,7 +1460,7 @@ void Desktop::Main()
133 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY );
134 if (xDesktopFrame.is())
136 -// SetSplashScreenProgress(60);
137 + SetSplashScreenProgress(60);
138 Reference< XFrame > xBackingFrame;
139 Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
141 @@ -1468,7 +1476,7 @@ void Desktop::Main()
142 Reference< XController > xBackingComp(
143 xSMgr->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs),
144 UNO_QUERY);
145 -// SetSplashScreenProgress(80);
146 + SetSplashScreenProgress(80);
147 if (xBackingComp.is())
149 Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
150 @@ -1507,7 +1515,7 @@ void Desktop::Main()
151 return;
154 -// SetSplashScreenProgress(55);
155 + SetSplashScreenProgress(55);
157 SvtFontSubstConfig().Apply();
159 @@ -1516,7 +1524,7 @@ void Desktop::Main()
160 aAppearanceCfg.SetApplicationDefaults( this );
161 SvtAccessibilityOptions aOptions;
162 aOptions.SetVCLSettings();
163 -// SetSplashScreenProgress(60);
164 + SetSplashScreenProgress(60);
166 Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) );
168 @@ -1539,7 +1547,7 @@ void Desktop::Main()
169 // use system window dialogs
170 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_DIALOG );
172 -// SetSplashScreenProgress(80);
173 + SetSplashScreenProgress(80);
175 if ( !bTerminateRequested && !pCmdLineArgs->IsInvisible() )
176 InitializeQuickstartMode( xSMgr );
177 @@ -2832,14 +2840,18 @@ void Desktop::OpenSplashScreen()
178 else if ( pCmdLine->IsWeb() )
179 aAppName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "web" ));
181 + // Which splash to use
182 + OUString aSplashService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.SplashScreen" ));
183 + if ( pCmdLine->GetStringParam( CommandLineArgs::CMD_STRINGPARAM_SPLASHPIPE ).getLength() )
184 + aSplashService = OUString::createFromAscii("com.sun.star.office.PipeSplashScreen");
186 bVisible = sal_True;
187 Sequence< Any > aSeq( 2 );
188 aSeq[0] <<= bVisible;
189 aSeq[1] <<= aAppName;
190 m_rSplashScreen = Reference<XStatusIndicator>(
191 comphelper::getProcessServiceFactory()->createInstanceWithArguments(
192 - OUString::createFromAscii("com.sun.star.office.SplashScreen"),
193 - aSeq), UNO_QUERY);
194 + aSplashService, aSeq), UNO_QUERY);
196 if(m_rSplashScreen.is())
197 m_rSplashScreen->start(OUString::createFromAscii("SplashScreen"), 100);
198 diff --git desktop/source/app/cmdlineargs.cxx desktop/source/app/cmdlineargs.cxx
199 index b14baab..6b8ca2a 100644
200 --- desktop/source/app/cmdlineargs.cxx
201 +++ desktop/source/app/cmdlineargs.cxx
202 @@ -457,6 +457,11 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString&
203 SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH, sal_True );
204 return sal_True;
206 + else if ( aArgStr.Copy(0, 13).EqualsIgnoreCaseAscii( "-splash-pipe=" ))
208 + AddStringListParam_Impl( CMD_STRINGPARAM_SPLASHPIPE, aArgStr.Copy( 13 ) );
209 + return sal_True;
211 #ifdef MACOSX
212 /* #i84053# ignore -psn on Mac
213 Platform dependent #ifdef here is ugly, however this is currently
214 @@ -858,7 +863,8 @@ sal_Bool CommandLineArgs::IsEmptyOrAcceptOnly() const
216 osl::MutexGuard aMutexGuard( m_aMutex );
218 - return m_eArgumentCount == NONE ||
219 + return m_eArgumentCount == NONE ||
220 + ( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_SPLASHPIPE ].getLength() )) ||
221 ( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_ACCEPT ].getLength() )) ||
222 ( ( m_eArgumentCount == ONE ) && m_aBoolParams[ CMD_BOOLPARAM_PSN ] );
224 diff --git desktop/source/app/cmdlineargs.hxx desktop/source/app/cmdlineargs.hxx
225 index 6411398..c42bb99 100644
226 --- desktop/source/app/cmdlineargs.hxx
227 +++ desktop/source/app/cmdlineargs.hxx
228 @@ -79,6 +79,7 @@ class CommandLineArgs
229 enum StringParam // must be zero based!
231 CMD_STRINGPARAM_PORTAL,
232 + CMD_STRINGPARAM_SPLASHPIPE,
233 CMD_STRINGPARAM_ACCEPT,
234 CMD_STRINGPARAM_UNACCEPT,
235 CMD_STRINGPARAM_USERDIR,
236 diff --git desktop/unx/source/makefile.mk desktop/unx/source/makefile.mk
237 new file mode 100644
238 index 0000000..110d081
239 --- /dev/null
240 +++ desktop/unx/source/makefile.mk
241 @@ -0,0 +1,38 @@
242 +PRJ=..$/..
243 +PRJNAME=desktop
244 +TARGET=oosplash
246 +NO_DEFAULT_STL=TRUE
248 +.INCLUDE : settings.mk
250 +STDLIB=
252 +OBJFILES= \
253 + $(OBJ)$/splashx.obj \
254 + $(OBJ)$/start.obj
256 +APP1TARGET = $(TARGET)
257 +APP1OBJS = $(OBJFILES)
258 +APP1LIBSALCPPRT=
259 +APP1CODETYPE = C
260 +APP1STDLIBS = $(SALLIB) -lX11
261 +.IF "$(OS)"=="SOLARIS"
262 +APP1STDLIBS+= -lsocket
263 +.ENDIF
265 +# --- Targets ------------------------------------------------------
267 +.INCLUDE : target.mk
269 +$(OBJ)$/start.obj : $(INCCOM)$/introbmpnames.hxx
271 +.INCLUDE .IGNORE : $(MISC)$/intro_bmp_names.mk
273 +.IF "$(INTRO_BITMAPS:f)"!="$(LASTTIME_INTRO_BITMAPS)"
274 +DO_PHONY=.PHONY
275 +.ENDIF # "$(INTRO_BITMAPS:f)"!="$(LASTTIME_INTRO_BITMAPS)"
277 +$(INCCOM)$/introbmpnames.hxx $(DO_PHONY):
278 + echo const char INTRO_BITMAP_STRINGLIST[]=$(EMQ)"$(INTRO_BITMAPS:f:t",")$(EMQ)"$(EMQ); > $@
279 + echo LASTTIME_INTRO_BITMAPS=$(INTRO_BITMAPS:f) > $(MISC)$/intro_bmp_names.mk
280 diff --git desktop/unx/source/splashx.c desktop/unx/source/splashx.c
281 new file mode 100644
282 index 0000000..b3b6da0
283 --- /dev/null
284 +++ desktop/unx/source/splashx.c
285 @@ -0,0 +1,570 @@
286 +/*************************************************************************
288 + * OpenOffice.org - a multi-platform office productivity suite
290 + * $RCSfile$
292 + * $Revision: 9695 $
294 + * last change: $Author: jholesovsky $ $Date: 2007-07-03 16:36:09 +0200 (Út, 03 čec 2007) $
296 + * The Contents of this file are made available subject to
297 + * the terms of GNU Lesser General Public License Version 2.1.
300 + * GNU Lesser General Public License Version 2.1
301 + * =============================================
302 + * Copyright 2005 by Sun Microsystems, Inc.
303 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
305 + * This library is free software; you can redistribute it and/or
306 + * modify it under the terms of the GNU Lesser General Public
307 + * License version 2.1, as published by the Free Software Foundation.
309 + * This library is distributed in the hope that it will be useful,
310 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
311 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
312 + * Lesser General Public License for more details.
314 + * You should have received a copy of the GNU Lesser General Public
315 + * License along with this library; if not, write to the Free Software
316 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
317 + * MA 02111-1307 USA
319 + ************************************************************************/
321 +#include <X11/Xlib.h>
322 +#include <X11/Xatom.h>
323 +#include <X11/Xutil.h>
325 +#include "osl/endian.h"
326 +#include <fcntl.h>
327 +#include <stdint.h>
328 +#include <stdio.h>
329 +#include <stdlib.h>
330 +#include <string.h>
331 +#include <unistd.h>
333 +#include "splashx.h"
335 +typedef struct {
336 + unsigned char b, g, r;
337 +} color_t;
339 +#define WINDOW_WIDTH 440
340 +#define WINDOW_HEIGHT 299
342 +#define PROGRESS_XOFFSET 12
343 +#define PROGRESS_YOFFSET 18
344 +#define PROGRESS_BARSPACE 2
346 +static Display *display = NULL;
347 +static int screen;
348 +static int depth;
349 +static Visual *visual = NULL;
351 +static int width = WINDOW_WIDTH;
352 +static int height = WINDOW_HEIGHT;
354 +static Colormap color_map;
355 +static Window win;
356 +static GC gc;
358 +// Progress bar values
359 +// taken from desktop/source/splash/splash.cxx
360 +static int tlx = 212;
361 +static int tly = 216;
362 +static int barwidth = 263;
363 +static int barheight = 8;
364 +static int barspace = PROGRESS_BARSPACE;
365 +static color_t barcol = { 18, 202, 157 };
366 +static color_t framecol = { 0xD3, 0xD3, 0xD3 };
368 +static XColor barcolor;
369 +static XColor framecolor;
371 +static color_t *bitmap = NULL;
373 +#define BMP_HEADER_LEN 14
374 +#define WIN_INFO_LEN 40
376 +#define UINT8( x ) ( (unsigned int)( ( (uint8_t *)( x ) )[0] ) )
378 +#define UINT16( x ) ( ( (unsigned int)( ( (uint8_t *)( x ) )[0] ) ) + \
379 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[1] ) ) << 8 ) )
381 +#define UINT32( x ) ( ( (unsigned int)( ( (uint8_t *)( x ) )[0] ) ) + \
382 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[1] ) ) << 8 ) + \
383 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[2] ) ) << 16 ) + \
384 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[3] ) ) << 24 ) )
386 +#define MAX( x, y ) ( ( (x) > (y) )? (x): (y) )
388 +#define LOAD_FAILURE( msg ) \
389 + { \
390 + fprintf( stderr, "%s: " msg, filename ); \
391 + close( fd ); \
392 + return 0; \
395 +// Load the specified Windows 24bit BMP to 'bitmap'
396 +// Return: 1 - success, 0 - failure
397 +int splash_load_bmp( char *filename )
399 + int fd = open( filename, O_RDONLY );
400 + if ( fd < 0 )
401 + return 0;
403 + char file_header[ BMP_HEADER_LEN ];
405 + if ( read( fd, file_header, BMP_HEADER_LEN ) != BMP_HEADER_LEN || file_header[0] != 'B' || file_header[1] != 'M' )
406 + LOAD_FAILURE( "Not a bitmap.\n" );
408 + int file_size = UINT32( file_header + 2 );
410 + char info_header[ WIN_INFO_LEN ];
411 + if ( read( fd, info_header, 4 ) != 4 )
412 + LOAD_FAILURE( "Unable to read the header.\n" );
414 + int header_size = UINT32( info_header );
415 + if ( header_size != WIN_INFO_LEN )
416 + LOAD_FAILURE( "Not a Windows bitmap.\n" );
418 + if ( read( fd, info_header + 4, WIN_INFO_LEN - 4 ) != WIN_INFO_LEN - 4 )
419 + LOAD_FAILURE( "The header ended too early.\n" );
421 + width = UINT32( info_header + 4 );
422 + height = UINT32( info_header + 8 );
424 + int bits = UINT16( info_header + 14 );
425 + int compression = UINT16( info_header + 16 );
427 + if ( bits != 24 )
428 + LOAD_FAILURE( "Just 24 bpp bitmaps are supported.\n" );
430 + if ( compression != 0 )
431 + LOAD_FAILURE( "Just uncompressed bitmaps are supported.\n" );
433 + size_t bitmap_size = width * height * 3;
434 + bitmap = malloc( bitmap_size );
435 + if ( bitmap == NULL )
436 + LOAD_FAILURE( "Cannot allocate memory for the data.\n" );
438 + if ( read( fd, bitmap, bitmap_size ) != bitmap_size )
439 + LOAD_FAILURE( "Cannot read the bitmap data.\n" );
441 + close( fd );
442 + return 1;
445 +static void setup_color( int val[3], color_t *col )
447 + if ( val[0] < 0 || val[1] < 0 || val[2] < 0 )
448 + return;
450 +#define CONVERT_COLOR( from,to ) if ( from < 0 ) to = 0; else if ( from > 255 ) to = 255; else to = from;
451 + CONVERT_COLOR( val[0], col->r );
452 + CONVERT_COLOR( val[1], col->g );
453 + CONVERT_COLOR( val[2], col->b );
454 +#undef CONVERT_COLOR
457 +// setup
458 +void splash_setup( int barc[3], int framec[3], int posx, int posy, int w, int h )
460 + if ( width <= 500 )
462 + barwidth = width - ( 2 * PROGRESS_XOFFSET );
463 + barheight = 6;
464 + tlx = PROGRESS_XOFFSET;
465 + tly = height - PROGRESS_YOFFSET;
467 + barcol.r = 0;
468 + barcol.g = 0;
469 + barcol.b = 128;
472 + if ( posx >= 0 )
473 + tlx = posx;
474 + if ( posy >= 0 )
475 + tly = posy;
476 + if ( w >= 0 )
477 + barwidth = w;
478 + if ( h >= 0 )
479 + barheight = h;
481 + setup_color( barc, &barcol );
482 + setup_color( framec, &framecol );
485 +// Universal shift: bits >= 0 - left, otherwise right
486 +#define SHIFT( x, bits ) ( ( (bits) >= 0 )? ( (x) << (bits) ): ( (x) >> -(bits) ) )
488 +// Position of the highest bit (more or less integer log2)
489 +inline int HIGHEST_BIT( unsigned long x )
491 + int i = 0;
492 + for ( ; x; ++i )
493 + x >>= 1;
495 + return i;
498 +// Number of bits set to 1
499 +inline int BITS( unsigned long x )
501 + int i = 0;
502 + for ( ; x; x >>= 1 )
503 + if ( x & 1UL )
504 + ++i;
506 + return i;
509 +// Set 'bitmap' as the background of our 'win' window
510 +static void create_pixmap()
512 + if ( !bitmap )
513 + return;
515 + Pixmap pixmap = XCreatePixmap( display, win, width, height, depth );
517 + unsigned long value_mask = 0;
518 + XGCValues values;
519 + GC pixmap_gc = XCreateGC( display, pixmap, value_mask, &values );
521 + if ( visual->class == TrueColor )
523 + unsigned long red_mask = visual->red_mask;
524 + unsigned long green_mask = visual->green_mask;
525 + unsigned long blue_mask = visual->blue_mask;
527 + unsigned long red_delta_mask = ( 1UL << ( 8 - BITS( red_mask ) ) ) - 1;
528 + unsigned long green_delta_mask = ( 1UL << ( 8 - BITS( green_mask ) ) ) - 1;
529 + unsigned long blue_delta_mask = ( 1UL << ( 8 - BITS( blue_mask ) ) ) - 1;
531 + int red_shift = HIGHEST_BIT( red_mask ) - 8;
532 + int green_shift = HIGHEST_BIT( green_mask ) - 8;
533 + int blue_shift = HIGHEST_BIT( blue_mask ) - 8;
535 + XImage *image = XCreateImage( display, visual, depth, ZPixmap,
536 + 0, NULL, width, height, 32, 0 );
538 + int bytes_per_line = image->bytes_per_line;
539 + int bpp = image->bits_per_pixel;
540 + int byte_order = image->byte_order;
541 + int machine_byte_order;
542 +#if defined( _LITTLE_ENDIAN )
543 + machine_byte_order = LSBFirst;
544 +#elif defined( _BIG_ENDIAN )
545 + machine_byte_order = MSBFirst;
546 +#else
548 + fprintf( stderr, "Unsupported machine endianity.\n" );
549 + XFreeGC( display, pixmap_gc );
550 + XFreePixmap( display, pixmap );
551 + XDestroyImage( image );
552 + return;
554 +#endif
556 + char *data = malloc( height * bytes_per_line );
557 + image->data = data;
559 + // The following dithers & converts the color_t color to one
560 + // acceptable for the visual
561 +#define COPY_IN_OUT( pix_size, code ) \
562 + { \
563 + out += pix_size * width * ( height - 1 ); \
564 + int x, y; \
565 + for ( y = 0; y < height; ++y ) \
566 + { \
567 + unsigned long red_delta = 0, green_delta = 0, blue_delta = 0; \
568 + for ( x = 0; x < width; ++x, ++in ) \
569 + { \
570 + unsigned long red = in->r + red_delta; \
571 + unsigned long green = in->g + green_delta; \
572 + unsigned long blue = in->b + blue_delta; \
573 + red_delta = red & red_delta_mask; \
574 + green_delta = green & green_delta_mask; \
575 + blue_delta = blue & blue_delta_mask; \
576 + if ( red > 255 ) \
577 + red = 255; \
578 + if ( green > 255 ) \
579 + green = 255; \
580 + if ( blue > 255 ) \
581 + blue = 255; \
582 + unsigned long pixel = \
583 + ( SHIFT( red, red_shift ) & red_mask ) | \
584 + ( SHIFT( green, green_shift ) & green_mask ) | \
585 + ( SHIFT( blue, blue_shift ) & blue_mask ); \
586 + code \
587 + } \
588 + out -= 2 * pix_size * width; \
589 + } \
592 + color_t *in = bitmap;
593 + char *out = data;
595 + if ( bpp == 32 )
597 + if ( machine_byte_order == byte_order )
598 + COPY_IN_OUT( 4, *( (uint32_t *)out ) = (uint32_t)pixel; out += 4; )
599 + else
600 + COPY_IN_OUT( 4, uint32_t tmp = pixel;
601 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 3 );
602 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
603 + *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 1 );
604 + *( (uint8_t *)out + 3 ) = *( (uint8_t *)(&tmp) );
605 + out += 4; )
607 + else if ( bpp == 24 )
609 + if ( machine_byte_order == byte_order && byte_order == LSBFirst )
610 + COPY_IN_OUT( 3, *( (color_t *)out ) = *( (color_t *)( &pixel ) ); out += 3; )
611 + if ( machine_byte_order == byte_order && byte_order == MSBFirst )
612 + COPY_IN_OUT( 3, uint32_t tmp = pixel;
613 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 1 );
614 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
615 + *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 3 );
616 + out += 3; )
617 + else
618 + COPY_IN_OUT( 3, uint32_t tmp = pixel;
619 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 3 );
620 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
621 + *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 1 );
622 + out += 3; )
624 + else if ( bpp == 16 )
626 + if ( machine_byte_order == byte_order )
627 + COPY_IN_OUT( 2, *( (uint16_t *)out ) = (uint16_t)pixel; out += 2; )
628 + else
629 + COPY_IN_OUT( 2, uint16_t tmp = pixel;
630 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 1 );
631 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) );
632 + out += 2; );
634 + else if ( bpp == 8 )
636 + COPY_IN_OUT( 1, *( (uint8_t *)out ) = (uint8_t)pixel; ++out; )
638 + else
640 + fprintf( stderr, "Unsupported depth: %d bits per pixel.\n", bpp );
641 + XFreeGC( display, pixmap_gc );
642 + XFreePixmap( display, pixmap );
643 + XDestroyImage( image );
644 + return;
647 +#undef COPY_IN_OUT
649 + XPutImage( display, pixmap, pixmap_gc, image, 0, 0, 0, 0, width, height );
650 + XDestroyImage( image );
652 + else //if ( depth == 1 || visual->class == DirectColor )
654 + // FIXME Something like the following, but faster ;-) - XDrawPoint is not
655 + // a good idea...
656 + int x, y;
657 + for ( y = 0; y < height; ++y )
659 + color_t *color = bitmap + y * width;
661 + int delta = 0;
662 + for ( x = 0; x < width; ++x, ++color )
664 + int rnd = (int)( ( (long)( random() - RAND_MAX/2 ) * 32000 )/RAND_MAX );
665 + int luminance = delta + rnd + 299 * (int)color->r + 587 * (int)color->g + 114 * (int)color->b;
667 + if ( luminance < 128000 )
669 + XSetForeground( display, pixmap_gc, BlackPixel( display, screen ) );
670 + delta = luminance;
672 + else
674 + XSetForeground( display, pixmap_gc, WhitePixel( display, screen ) );
675 + delta = luminance - 255000;
678 + XDrawPoint( display, pixmap, pixmap_gc, x, y );
683 + XSetWindowBackgroundPixmap( display, win, pixmap );
685 + XFreeGC( display, pixmap_gc );
686 + XFreePixmap( display, pixmap );
689 +// The old method of hiding the window decorations
690 +static void suppress_decorations_motif()
692 + struct {
693 + unsigned long flags, functions, decorations;
694 + long input_mode;
695 + unsigned long status;
696 + } mwmhints;
698 + Atom a = XInternAtom( display, "_MOTIF_WM_HINTS", False );
700 + mwmhints.flags = 15; // functions, decorations, input_mode, status
701 + mwmhints.functions = 2; // ?
702 + mwmhints.decorations = 0;
703 + mwmhints.input_mode = 0;
705 + XChangeProperty( display, win, a, a, 32,
706 + PropModeReplace, (unsigned char*)&mwmhints, 5 );
709 +// This is a splash, set it as such.
710 +// If it fails, just hide the decorations...
711 +static void suppress_decorations()
713 + Atom atom_type = XInternAtom( display, "_NET_WM_WINDOW_TYPE", True );
714 + Atom atom_splash = XInternAtom( display, "_NET_WM_WINDOW_TYPE_SPLASH", True );
716 + if ( atom_type != None && atom_splash != None )
717 + XChangeProperty( display, win, atom_type, XA_ATOM, 32,
718 + PropModeReplace, (unsigned char*)&atom_splash, 1 );
719 + //else
720 + suppress_decorations_motif(); // FIXME: Unconditional until Metacity/compiz's SPLASH handling is fixed
723 +// Create the window
724 +// Return: 1 - success, 0 - failure
725 +int splash_create_window( int argc, char** argv )
727 + char *display_name = NULL;
728 + int i;
729 + for ( i = 0; i < argc; i++ )
731 + if ( !strcmp( argv[i], "-display" ) || !strcmp( argv[i], "--display" ) )
732 + display_name = ( i + 1 < argc )? argv[i+1]: NULL;
735 + if ( !display_name )
736 + display_name = getenv( "DISPLAY" );
738 + // init display
739 + display = XOpenDisplay( display_name );
740 + if ( !display )
742 + fprintf( stderr, "Failed to open display\n" );
743 + return 0;
746 + // create the window
747 + screen = DefaultScreen( display );
748 + depth = DefaultDepth( display, screen );
749 + color_map = DefaultColormap( display, screen );
750 + visual = DefaultVisual( display, screen );
752 + Window root_win = RootWindow( display, screen );
753 + int display_width = DisplayWidth( display, screen );
754 + int display_height = DisplayHeight( display, screen );
756 + win = XCreateSimpleWindow( display, root_win,
757 + ( display_width - width ) / 2, ( display_height - height ) / 2,
758 + width, height, 0,
759 + BlackPixel( display, screen ), BlackPixel( display, screen ) );
761 + XSetWindowColormap( display, win, color_map );
763 + // setup colors
764 +#define FILL_COLOR( xcol,col ) xcol.red = 256*col.r; xcol.green = 256*col.g; xcol.blue = 256*col.b;
765 + FILL_COLOR( barcolor, barcol );
766 + FILL_COLOR( framecolor, framecol );
767 +#undef FILL_COLOR
769 + XAllocColor( display, color_map, &barcolor );
770 + XAllocColor( display, color_map, &framecolor );
772 + // not resizable, no decorations, etc.
773 + unsigned long value_mask = 0;
774 + XGCValues values;
775 + gc = XCreateGC( display, win, value_mask, &values );
777 + XSizeHints size_hints;
778 + size_hints.flags = PPosition | PSize | PMinSize | PMaxSize;
779 + size_hints.min_width = width;
780 + size_hints.max_width = width;
781 + size_hints.min_height = height;
782 + size_hints.max_height = height;
784 + char *name = "OpenOffice.org";
785 + char *icon = "icon"; // FIXME
787 + XSetStandardProperties( display, win, name, icon, None,
788 + 0, 0, &size_hints );
790 + // the actual work
791 + suppress_decorations();
792 + create_pixmap();
794 + // show it
795 + XSelectInput( display, win, 0 );
796 + XMapWindow( display, win );
798 + return 1;
801 +// Re-draw & process the events
802 +// Just throwing them away - we do not need anything more...
803 +static void process_events()
805 + XEvent xev;
806 + int num_events;
808 + XFlush( display );
809 + num_events = XPending( display );
810 + while ( num_events > 0 )
812 + num_events--;
813 + XNextEvent( display, &xev );
814 + //process_event(xev);
818 +// Draw the progress
819 +void splash_draw_progress( int progress )
821 + // sanity
822 + if ( progress < 0 )
823 + progress = 0;
824 + if ( progress > 100 )
825 + progress = 100;
827 + // draw progress...
828 + int length = ( progress * barwidth / 100 ) - ( 2 * barspace );
829 + if ( length < 0 )
830 + length = 0;
832 + // border
833 + XSetForeground( display, gc, framecolor.pixel );
834 + XDrawRectangle( display, win, gc,
835 + tlx, tly,
836 + barwidth, barheight );
838 + // progress bar
839 + XSetForeground( display, gc, barcolor.pixel );
840 + XFillRectangle( display, win, gc,
841 + tlx + barspace, tly + barspace,
842 + length + 1, barheight - 2*barspace + 1 );
844 + // pending events
845 + process_events();
848 +// Close the window & cleanup
849 +void splash_close_window()
851 + XCloseDisplay( display );
853 + free( bitmap );
854 + bitmap = NULL;
856 diff --git desktop/unx/source/splashx.h desktop/unx/source/splashx.h
857 new file mode 100644
858 index 0000000..6d84d4b
859 --- /dev/null
860 +++ desktop/unx/source/splashx.h
861 @@ -0,0 +1,71 @@
862 +/*************************************************************************
864 + * OpenOffice.org - a multi-platform office productivity suite
866 + * $RCSfile$
868 + * $Revision: 9695 $
870 + * last change: $Author: jholesovsky $ $Date: 2007-07-03 16:36:09 +0200 (Út, 03 čec 2007) $
872 + * The Contents of this file are made available subject to
873 + * the terms of GNU Lesser General Public License Version 2.1.
876 + * GNU Lesser General Public License Version 2.1
877 + * =============================================
878 + * Copyright 2005 by Sun Microsystems, Inc.
879 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
881 + * This library is free software; you can redistribute it and/or
882 + * modify it under the terms of the GNU Lesser General Public
883 + * License version 2.1, as published by the Free Software Foundation.
885 + * This library is distributed in the hope that it will be useful,
886 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
887 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
888 + * Lesser General Public License for more details.
890 + * You should have received a copy of the GNU Lesser General Public
891 + * License along with this library; if not, write to the Free Software
892 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
893 + * MA 02111-1307 USA
895 + ************************************************************************/
897 +#ifndef _SPLASHX_H
898 +#define _SPLASHX_H
900 +#ifdef __cplusplus
901 +extern "C" {
902 +#endif
904 +// Load the specified Windows 24bit BMP we can have as a background of the
905 +// splash.
907 +// Note: Must be called before the create_window(), otherwise there will be no
908 +// image in the splash, just black rectangle.
910 +// Return: 1 - success, 0 - failure (non-existing, etc.)
911 +int splash_load_bmp( char *filename );
913 +// Init some of the values
914 +// If not called, the defaults are used
915 +// barc, framec - colors, posx, posy - position, w, h - size
916 +void splash_setup( int barc[3], int framec[3], int posx, int posy, int w, int h );
918 +// Create the splash window
919 +// Return: 1 - success, 0 - failure
920 +int splash_create_window( int argc, char** argv );
922 +// Destroy the splash window
923 +void splash_close_window();
925 +// Update the progress bar
926 +void splash_draw_progress( int progress );
928 +#ifdef __cplusplus
929 +} // extern "C"
930 +#endif
932 +#endif // _SPLASHX_H
933 diff --git desktop/unx/source/start.c desktop/unx/source/start.c
934 new file mode 100644
935 index 0000000..a42a286
936 --- /dev/null
937 +++ desktop/unx/source/start.c
938 @@ -0,0 +1,719 @@
939 +/*************************************************************************
941 + * OpenOffice.org - a multi-platform office productivity suite
943 + * $RCSfile$
945 + * $Revision: 9695 $
947 + * last change: $Author: jholesovsky $ $Date: 2007-07-03 16:36:09 +0200 (Út, 03 čec 2007) $
949 + * The Contents of this file are made available subject to
950 + * the terms of GNU Lesser General Public License Version 2.1.
953 + * GNU Lesser General Public License Version 2.1
954 + * =============================================
955 + * Copyright 2005 by Sun Microsystems, Inc.
956 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
958 + * This library is free software; you can redistribute it and/or
959 + * modify it under the terms of the GNU Lesser General Public
960 + * License version 2.1, as published by the Free Software Foundation.
962 + * This library is distributed in the hope that it will be useful,
963 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
964 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
965 + * Lesser General Public License for more details.
967 + * You should have received a copy of the GNU Lesser General Public
968 + * License along with this library; if not, write to the Free Software
969 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
970 + * MA 02111-1307 USA
972 + ************************************************************************/
974 +#include <signal.h>
975 +#include <unistd.h>
976 +#include <limits.h>
977 +#include <stdlib.h>
978 +#include <sys/types.h>
979 +#include <sys/stat.h>
980 +#include <sys/socket.h>
981 +#include <arpa/inet.h>
982 +#include <sys/un.h>
983 +#include <sys/poll.h>
984 +#include <fcntl.h>
985 +#include <stdio.h>
986 +#include <libgen.h>
988 +#include <osl/nlsupport.h>
989 +#include <osl/process.h>
990 +#include <rtl/bootstrap.h>
991 +#include <rtl/digest.h>
992 +#include <sal/main.h>
994 +#include "splashx.h"
995 +#include <introbmpnames.hxx>
997 +#define PIPEDEFAULTPATH "/tmp"
998 +#define PIPEALTERNATEPATH "/var/tmp"
1000 +/* Easier conversions: rtl_uString to rtl_String */
1001 +static rtl_String *
1002 +ustr_to_str( rtl_uString *pStr )
1004 + rtl_String *pOut = NULL;
1006 + rtl_uString2String( &pOut, rtl_uString_getStr( pStr ),
1007 + rtl_uString_getLength( pStr ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS );
1009 + return pOut;
1012 +/* Easier conversions: char * to rtl_uString */
1013 +static rtl_uString *
1014 +charp_to_ustr( const char *pStr )
1016 + rtl_uString *pOut = NULL;
1018 + rtl_string2UString( &pOut, pStr, strlen( pStr ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
1020 + return pOut;
1023 +/* Easier debugging of rtl_uString values. */
1024 +#if OSL_DEBUG_LEVEL > 0
1025 +static void
1026 +ustr_debug( const char *pMessage, rtl_uString *pStr )
1028 + rtl_String *pOut = ustr_to_str( pStr );
1030 + fprintf( stderr, "%s: %s\n", pMessage, rtl_string_getStr( pOut ) );
1032 + rtl_string_release( pOut );
1033 + return;
1035 +#else
1036 +#define ustr_debug( a, b ) {}
1037 +#endif
1039 +/* Path of the application. */
1040 +static rtl_uString *
1041 +get_app_path( const char *pAppExec )
1043 + char pRealPath[PATH_MAX];
1044 + rtl_uString *pResult;
1046 + char *pPath = strdup( pAppExec );
1047 + pPath = dirname( pPath );
1049 + realpath( pPath, pRealPath );
1050 + pResult = charp_to_ustr( pRealPath );
1051 + free( pPath );
1053 + return pResult;
1056 +/* Compute the OOo md5 hash from 'pText' */
1057 +static rtl_uString *
1058 +get_md5hash( rtl_uString *pText )
1060 + rtl_uString *pResult = NULL;
1061 + sal_Int32 nCapacity = 100;
1063 + if ( !pText )
1064 + return NULL;
1066 + unsigned char *pData = (unsigned char *)rtl_uString_getStr( pText );
1067 + sal_uInt32 nSize = rtl_uString_getLength( pText ) * sizeof( sal_Unicode );
1068 + if ( !pData )
1069 + return NULL;
1071 + rtlDigest digest = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
1072 + if ( digest <= 0 )
1073 + return NULL;
1075 + sal_uInt32 md5_key_len = rtl_digest_queryLength( digest );
1076 + sal_uInt8 *md5_buf = (sal_uInt8 *)calloc( md5_key_len, sizeof( sal_uInt8 ) );
1078 + rtl_digest_init( digest, pData , nSize );
1079 + rtl_digest_update( digest, pData, nSize );
1080 + rtl_digest_get( digest, md5_buf, md5_key_len );
1081 + rtl_digest_destroy( digest );
1083 + /* create hex-value string from the MD5 value to keep
1084 + the string size minimal */
1085 + rtl_uString_new_WithLength( &pResult, nCapacity );
1086 + sal_uInt32 i = 0;
1087 + for ( ; i < md5_key_len; ++i )
1089 + char val[3];
1090 + snprintf( val, 3, "%x", md5_buf[i] ); /* sic! we ignore some of the 0's */
1092 + rtl_uStringbuffer_insert_ascii( &pResult, &nCapacity, rtl_uString_getLength( pResult ),
1093 + val, strlen( val ) );
1096 + /* cleanup */
1097 + free( md5_buf );
1099 + return pResult;
1102 +/* Construct the pipe name */
1103 +static rtl_uString *
1104 +get_pipe_path( rtl_uString *pAppPath )
1106 + rtl_uString *pPath = NULL, *pTmp = NULL, *pUserInstallation = NULL;
1107 + rtl_uString *pResult = NULL;
1109 + /* setup bootstrap filename */
1110 + rtl_uString_newFromAscii( &pPath, "file://" );
1111 + rtl_uString_newConcat( &pPath, pPath, pAppPath );
1112 + rtl_uString_newFromAscii( &pTmp, "/" );
1113 + rtl_uString_newConcat( &pPath, pPath, pTmp );
1114 + rtl_uString_newFromAscii( &pTmp, SAL_CONFIGFILE( "bootstrap" ) );
1115 + rtl_uString_newConcat( &pPath, pPath, pTmp );
1117 + ustr_debug( "bootstap", pPath );
1119 + /* read userinstallation value */
1120 + rtlBootstrapHandle handle = rtl_bootstrap_args_open( pPath );
1122 + rtl_uString_newFromAscii( &pTmp, "UserInstallation" );
1123 + rtl_bootstrap_get_from_handle( handle, pTmp, &pUserInstallation, NULL );
1125 + rtl_bootstrap_args_close( handle );
1127 + /* create the pipe name */
1128 + ustr_debug( "user installation", pUserInstallation );
1129 + rtl_uString *pMd5hash = get_md5hash( pUserInstallation );
1130 + if ( !pMd5hash )
1131 + rtl_uString_new( &pMd5hash );
1133 + if ( access( PIPEDEFAULTPATH, R_OK|W_OK ) == 0 )
1134 + rtl_uString_newFromAscii( &pResult, PIPEDEFAULTPATH );
1135 + else
1136 + rtl_uString_newFromAscii( &pResult, PIPEALTERNATEPATH );
1138 + rtl_uString_newFromAscii( &pTmp, "/OSL_PIPE_" );
1139 + rtl_uString_newConcat( &pResult, pResult, pTmp );
1141 + sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
1142 + rtl_ustr_valueOfInt32( pUnicode, (int)getuid(), 10 );
1143 + rtl_uString_newFromStr( &pTmp, pUnicode );
1144 + rtl_uString_newConcat( &pResult, pResult, pTmp );
1146 + rtl_uString_newFromAscii( &pTmp, "_SingleOfficeIPC_" );
1147 + rtl_uString_newConcat( &pResult, pResult, pTmp );
1149 + rtl_uString_newConcat( &pResult, pResult, pMd5hash );
1151 + ustr_debug( "result", pResult );
1153 + /* cleanup */
1154 + rtl_uString_release( pPath );
1155 + rtl_uString_release( pTmp );
1156 + rtl_uString_release( pUserInstallation );
1158 + return pResult;
1161 +/* Get fd of the pipe of the already running OOo. */
1162 +static int
1163 +connect_pipe( rtl_uString *pPipePath )
1165 + int fd;
1166 + size_t len;
1167 + struct sockaddr_un addr;
1169 + rtl_String *pPipeStr = ustr_to_str( pPipePath );
1171 + memset( &addr, 0, sizeof( addr ) );
1173 + if ( ( fd = socket( AF_UNIX, SOCK_STREAM, 0 ) ) < 0 )
1174 + return fd;
1176 + fcntl( fd, F_SETFD, FD_CLOEXEC );
1178 + addr.sun_family = AF_UNIX;
1179 + strncpy( addr.sun_path, rtl_string_getStr( pPipeStr ), sizeof( addr.sun_path ) );
1180 + rtl_string_release( pPipeStr );
1182 +/* cut / paste from osl's pipe.c */
1183 +#if defined(FREEBSD)
1184 + len = SUN_LEN( &addr );
1185 +#else
1186 + len = sizeof( addr );
1187 +#endif
1189 + if ( connect( fd, (struct sockaddr *)&addr, len ) < 0 )
1190 + return -1;
1192 + return fd;
1195 +/* Send args to the OOo instance (using the 'fd' file descriptor) */
1196 +static sal_Bool
1197 +send_args( int fd )
1199 + rtl_uString *pBuffer = NULL, *pTmp = NULL;
1200 + sal_Int32 nCapacity = 100;
1201 + rtl_String *pOut = NULL;
1202 + sal_Bool bResult;
1203 + size_t nLen;
1205 + rtl_uString_new_WithLength( &pBuffer, nCapacity );
1206 + rtl_uString_new( &pTmp );
1208 + sal_uInt32 nArg;
1209 + sal_uInt32 nArgCount = osl_getCommandArgCount();
1210 + for ( nArg = 0; nArg < nArgCount; ++nArg )
1212 + osl_getCommandArg( nArg, &pTmp );
1214 + rtl_uStringbuffer_insert( &pBuffer, &nCapacity,
1215 + rtl_uString_getLength( pBuffer ),
1216 + rtl_uString_getStr( pTmp ),
1217 + rtl_uString_getLength( pTmp ) );
1219 + rtl_uStringbuffer_insert_ascii( &pBuffer, &nCapacity,
1220 + rtl_uString_getLength( pBuffer ),
1221 + "|", 1 );
1224 + ustr_debug( "Pass args", pBuffer );
1226 + pOut = ustr_to_str( pBuffer );
1228 + nLen = rtl_string_getLength( pOut ) + 1;
1229 + bResult = ( write( fd, rtl_string_getStr( pOut ), nLen ) == nLen );
1231 + /* cleanup */
1232 + rtl_uString_release( pBuffer );
1233 + rtl_uString_release( pTmp );
1234 + rtl_string_release( pOut );
1236 + return bResult;
1239 +/* Load the splash bitmap. */
1240 +static void
1241 +load_splash_image( rtl_uString *pImagePath )
1243 + rtl_uString *pPath = NULL, *pBitmaps = NULL, *pTmp = NULL;
1244 + rtl_uString *pToken = NULL, *pFilename = NULL;
1246 + sal_Int32 nIndex = 0;
1248 + /* setup values */
1249 + rtl_uString_newFromString( &pPath, pImagePath );
1250 + rtl_uString_newFromAscii( &pTmp, "/" );
1251 + rtl_uString_newConcat( &pPath, pPath, pTmp );
1253 + rtl_uString_newFromAscii( &pBitmaps, INTRO_BITMAP_STRINGLIST );
1254 + rtl_uString_newFromAscii( &pTmp, ",intro.bmp" );
1255 + rtl_uString_newConcat( &pBitmaps, pBitmaps, pTmp );
1257 + /* try all the bitmaps from INTRO_BITMAP_STRINGLIST
1258 + (and the intro.bmp fallback) */
1259 + while ( nIndex >= 0 )
1261 + nIndex = rtl_uString_getToken( &pToken, pBitmaps, 0, ',', nIndex );
1262 + rtl_uString_newConcat( &pFilename, pPath, pToken );
1264 + if ( rtl_uString_getLength( pToken ) > 0 )
1266 + rtl_String *pFilenameStr = ustr_to_str( pFilename );
1267 + sal_Bool bLoaded = splash_load_bmp( rtl_string_getStr( pFilenameStr ) );
1268 + rtl_string_release( pFilenameStr );
1270 + if ( bLoaded )
1271 + break;
1275 + /* cleanup */
1276 + rtl_uString_release( pPath );
1277 + rtl_uString_release( pBitmaps );
1278 + rtl_uString_release( pTmp );
1279 + rtl_uString_release( pToken );
1280 + rtl_uString_release( pFilename );
1283 +/* Fill 'array' with values of the key 'name'.
1284 + Its value is a comma delimited list of integers */
1285 +static void
1286 +get_bootstrap_value( int *array, int size, rtlBootstrapHandle handle, const char *name )
1288 + rtl_uString *pKey = NULL, *pValue = NULL;
1289 + sal_Int32 nIndex = 0;
1290 + int i = 0;
1292 + /* get the value from the ini file */
1293 + rtl_uString_newFromAscii( &pKey, name );
1294 + rtl_bootstrap_get_from_handle( handle, pKey, &pValue, NULL );
1296 + /* the value is several numbers delimited by ',' - parse it */
1297 + if ( rtl_uString_getLength( pValue ) > 0 )
1299 + rtl_uString *pToken = NULL;
1301 + for ( ; ( nIndex >= 0 ) && ( i < size ); ++i )
1303 + nIndex = rtl_uString_getToken( &pToken, pValue, 0, ',', nIndex );
1304 + array[i] = rtl_ustr_toInt32( rtl_uString_getStr( pToken ), 10 );
1307 + rtl_uString_release( pToken );
1310 + /* cleanup */
1311 + rtl_uString_release( pKey );
1312 + rtl_uString_release( pValue );
1315 +/* Load the colors and size of the splash. */
1316 +static void
1317 +load_splash_defaults( rtl_uString *pAppPath, sal_Bool *pInhibitSplash )
1319 + rtl_uString *pSettings = NULL, *pTmp = NULL;
1320 + rtlBootstrapHandle handle;
1322 + /* costruct the sofficerc file location */
1323 + rtl_uString_newFromAscii( &pSettings, "file://" );
1324 + rtl_uString_newConcat( &pSettings, pSettings, pAppPath );
1325 + rtl_uString_newFromAscii( &pTmp, "/" );
1326 + rtl_uString_newConcat( &pSettings, pSettings, pTmp );
1327 + rtl_uString_newFromAscii( &pTmp, SAL_CONFIGFILE( "soffice" ) );
1328 + rtl_uString_newConcat( &pSettings, pSettings, pTmp );
1330 + /* use it as the bootstrap file */
1331 + handle = rtl_bootstrap_args_open( pSettings );
1333 + int logo[1] = { -1 },
1334 + bar[3] = { -1, -1, -1 },
1335 + frame[3] = { -1, -1, -1 },
1336 + pos[2] = { -1, -1 },
1337 + size[2] = { -1, -1 };
1339 + /* get the values */
1340 + get_bootstrap_value( logo, 1, handle, "Logo" );
1341 + get_bootstrap_value( bar, 3, handle, "ProgressBarColor" );
1342 + get_bootstrap_value( frame, 3, handle, "ProgressFrameColor" );
1343 + get_bootstrap_value( pos, 2, handle, "ProgressPosition" );
1344 + get_bootstrap_value( size, 2, handle, "ProgressSize" );
1346 + if ( logo[0] == 0 )
1347 + *pInhibitSplash = sal_True;
1349 + splash_setup( bar, frame, pos[0], pos[1], size[0], size[1] );
1351 + /* cleanup */
1352 + rtl_bootstrap_args_close( handle );
1353 + rtl_uString_release( pSettings );
1354 + rtl_uString_release( pTmp );
1357 +#define BUFFER_LEN 255
1359 +/* Read the percent to show in splash. */
1360 +static sal_Bool
1361 +read_percent( int status_fd, int *pPercent )
1363 + static char pBuffer[BUFFER_LEN + 1];
1364 + static char *pNext = pBuffer;
1365 + static size_t nRead = 0;
1367 + char *pBegin;
1368 + char *pIter;
1370 + /* from the last call */
1371 + int nNotProcessed = nRead - ( pNext - pBuffer );
1372 + if ( nNotProcessed >= BUFFER_LEN )
1373 + return sal_False;
1375 + memmove( pBuffer, pNext, nNotProcessed );
1377 + /* read data */
1378 + nRead = read( status_fd, pBuffer + nNotProcessed, BUFFER_LEN - nNotProcessed );
1379 + if ( nRead < 0 )
1380 + return sal_False;
1382 + nRead += nNotProcessed;
1383 + pBuffer[nRead] = '\0';
1385 + /* skip old data */
1386 + pBegin = pBuffer;
1387 + pNext = pBuffer;
1388 + for ( pIter = pBuffer; *pIter; ++pIter )
1389 + if ( *pIter == '\n' )
1391 + pBegin = pNext;
1392 + pNext = pIter + 1;
1395 +#if OSL_DEBUG_LEVEL > 0
1396 + fprintf( stderr, "Got status: %s\n", pBegin );
1397 +#endif
1398 + if ( !strncasecmp( pBegin, "end", 3 ) )
1399 + return sal_False;
1400 + else if ( sscanf( pBegin, "%d%%", pPercent ) )
1401 + return sal_True;
1403 + return sal_False;
1406 +/* Periodically update the splash & the percent acconding to what
1407 + status_fd says */
1408 +static void
1409 +show_splash( int status_fd )
1411 + int nRetval;
1412 + struct pollfd aPfd;
1414 + int nPercent = 0;
1415 + sal_Bool bFinish = sal_False;
1417 + /* we want to watch status_fd */
1418 + aPfd.fd = status_fd;
1419 + aPfd.events = POLLIN;
1421 +#if OSL_DEBUG_LEVEL > 0
1422 + fprintf( stderr, "Starting main loop, status fd: %d\n", status_fd );
1423 +#endif
1425 + /* main loop */
1426 + do {
1427 + splash_draw_progress( nPercent );
1429 + /* read from pipe if data available */
1430 + nRetval = poll( &aPfd, 1, 50 );
1431 + if ( nRetval > 0 )
1432 + bFinish = !read_percent( status_fd, &nPercent );
1433 + else if ( nRetval < 0 )
1434 + bFinish = sal_True;
1435 + } while ( !bFinish );
1438 +/* Simple system check. */
1439 +static void
1440 +system_checks( void )
1442 +#ifdef LINUX
1443 + struct stat buf;
1445 + /* check proc is mounted - lots of things fail otherwise */
1446 + if ( stat( "/proc/version", &buf ) != 0 )
1448 + fprintf( stderr, "ERROR: /proc not mounted - OO.o is unlikely to work well if at all" );
1449 + exit( 1 );
1451 +#endif
1454 +/* Start the OOo application */
1455 +static sal_Bool
1456 +fork_app( rtl_uString *pAppPath, int *status_fd )
1458 + rtl_uString *pApp = NULL, *pTmp = NULL, *pArg = NULL;
1459 + rtl_uString **ppArgs;
1460 + sal_uInt32 nArgs, i;
1462 + oslProcess aProcess;
1463 + oslProcessError nError;
1464 + int status_pipe[2];
1466 + system_checks();
1468 + /* application name */
1469 + rtl_uString_newFromAscii( &pApp, "file://" );
1470 + rtl_uString_newConcat( &pApp, pApp, pAppPath );
1471 + rtl_uString_newFromAscii( &pTmp, "/soffice.bin" );
1472 + rtl_uString_newConcat( &pApp, pApp, pTmp );
1474 + rtl_uString_new( &pTmp );
1476 + /* copy args */
1477 + nArgs = osl_getCommandArgCount();
1478 + ppArgs = (rtl_uString **)calloc( nArgs + 1, sizeof( rtl_uString* ) );
1479 + for ( i = 0; i < nArgs; ++i )
1481 + ppArgs[i] = NULL;
1482 + osl_getCommandArg( i, &pTmp );
1484 + rtl_uString_newFromString( &(ppArgs[i]), pTmp );
1487 + /* create pipe */
1488 + if ( pipe( status_pipe ) < 0 )
1490 + fprintf( stderr, "ERROR: no file handles\n");
1491 + exit( 1 );
1494 + /* add the pipe arg */
1495 + sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
1496 + rtl_ustr_valueOfInt32( pUnicode, status_pipe[1], 10 );
1498 + rtl_uString_newFromAscii( &pArg, "-splash-pipe=" );
1499 + rtl_uString_newFromStr( &pTmp, pUnicode );
1500 + rtl_uString_newConcat( &pArg, pArg, pTmp );
1502 + ppArgs[nArgs] = NULL;
1503 + rtl_uString_newFromString( &(ppArgs[nArgs]), pArg );
1504 + ++nArgs;
1506 + /* start the OOo process */
1507 + nError = osl_executeProcess( pApp, ppArgs, nArgs,
1508 + osl_Process_DETACHED | osl_Process_NORMAL,
1509 + NULL,
1510 + NULL,
1511 + NULL, 0,
1512 + &aProcess );
1514 + *status_fd = status_pipe[0];
1515 + close( status_pipe[1] );
1517 + if ( nError != osl_Process_E_None )
1519 + fprintf( stderr, "ERROR %d forking process", nError );
1520 + ustr_debug( "", pApp );
1521 + return sal_False;
1524 + return sal_True;
1527 +/* Check if 'pArg' is -pCmpWith or --pCmpWith */
1528 +static sal_Bool
1529 +arg_check( rtl_uString *pArg, const char *pCmpWith )
1531 + sal_Unicode *pUnicode = rtl_uString_getStr( pArg );
1533 + if ( pUnicode[0] == (sal_Unicode)'-' )
1534 + pUnicode++;
1535 + else
1536 + return sal_False;
1538 + /* tolerate -- prefixes etc. */
1539 + if ( pUnicode[0] == (sal_Unicode)'-' )
1540 + pUnicode++;
1542 + return !rtl_ustr_ascii_compare( pUnicode, pCmpWith );
1545 +static const char *ppInhibit[] = {
1546 + "nologo", "headless", "invisible", "help", "h", "?", "minimized",
1547 + NULL };
1548 +static const char *ppTwoArgs[] = {
1549 + "pt", "display",
1550 + NULL };
1552 +/* Read command line parameters and return whether we display the splash. */
1553 +static sal_Bool
1554 +get_inhibit_splash()
1556 + rtl_uString *pTmp = NULL;
1557 + sal_Bool bSkipNextArg = sal_False;
1558 + const char **ppIter;
1560 + rtl_uString_new( &pTmp );
1562 + sal_uInt32 nArg;
1563 + sal_uInt32 nArgCount = osl_getCommandArgCount();
1564 + for ( nArg = 0; nArg < nArgCount; ++nArg )
1566 + if ( bSkipNextArg )
1568 + bSkipNextArg = sal_False;
1569 + continue;
1572 + osl_getCommandArg( nArg, &pTmp );
1574 + /* check for inhibit splash params */
1575 + for ( ppIter = ppInhibit; *ppIter; ++ppIter )
1577 + if ( arg_check( pTmp, *ppIter ) )
1579 + rtl_uString_release( pTmp );
1580 + return sal_True;
1583 + /* check for 2 arguments params */
1584 + for ( ppIter = ppTwoArgs; *ppIter; ++ppIter )
1586 + if ( arg_check( pTmp, *ppIter ) )
1588 + bSkipNextArg = sal_True;
1589 + break;
1594 + /* cleanup */
1595 + rtl_uString_release( pTmp );
1597 + return sal_False;
1600 +SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
1602 + int fd = 0, status_fd = 0;
1603 + sal_Bool bInhibitSplash;
1604 + sal_Bool bSentArgs = sal_False;
1605 + rtl_uString *pAppPath = NULL;
1606 + rtl_uString *pPipePath = NULL;
1608 + /* turn SIGPIPE into an error */
1609 + signal( SIGPIPE, SIG_IGN );
1611 + bInhibitSplash = get_inhibit_splash();
1613 + pAppPath = get_app_path( argv[0] );
1614 + if ( !pAppPath )
1616 + fprintf( stderr, "ERROR: Can't read app link\n" );
1617 + exit( 1 );
1619 + ustr_debug( "App path", pAppPath );
1621 + pPipePath = get_pipe_path( pAppPath );
1623 + if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
1624 + bSentArgs = send_args( fd );
1625 +#if OSL_DEBUG_LEVEL > 0
1626 + else
1627 + ustr_debug( "Failed to connect to pipe", pPipePath );
1628 +#endif
1630 + if ( !bSentArgs )
1632 + if ( !fork_app( pAppPath, &status_fd ) )
1633 + return 1;
1635 + if ( !bInhibitSplash )
1637 + load_splash_image( pAppPath );
1638 + load_splash_defaults( pAppPath, &bInhibitSplash );
1641 + if ( !bInhibitSplash && splash_create_window( argc, argv ) )
1643 + splash_draw_progress( 0 );
1644 + show_splash( status_fd );
1645 + splash_close_window();
1649 + /* cleanup */
1650 + rtl_uString_release( pAppPath );
1651 + rtl_uString_release( pPipePath );
1653 + close( fd );
1654 + close( status_fd );
1656 + return 0;
1658 diff --git desktop/unx/splash/exports.map desktop/unx/splash/exports.map
1659 new file mode 100644
1660 index 0000000..ba501f9
1661 --- /dev/null
1662 +++ desktop/unx/splash/exports.map
1663 @@ -0,0 +1,10 @@
1664 +UDK_3_0_0 {
1665 + global:
1666 + GetVersionInfo;
1667 + component_getImplementationEnvironment;
1668 + component_getFactory;
1669 + component_writeInfo;
1671 + local:
1672 + *;
1674 diff --git desktop/unx/splash/makefile.mk desktop/unx/splash/makefile.mk
1675 new file mode 100644
1676 index 0000000..874b81b
1677 --- /dev/null
1678 +++ desktop/unx/splash/makefile.mk
1679 @@ -0,0 +1,73 @@
1680 +#*************************************************************************
1682 +# OpenOffice.org - a multi-platform office productivity suite
1684 +# $RCSfile$
1686 +# $Revision: 7305 $
1688 +# last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
1690 +# The Contents of this file are made available subject to
1691 +# the terms of GNU Lesser General Public License Version 2.1.
1694 +# GNU Lesser General Public License Version 2.1
1695 +# =============================================
1696 +# Copyright 2005 by Sun Microsystems, Inc.
1697 +# 901 San Antonio Road, Palo Alto, CA 94303, USA
1699 +# This library is free software; you can redistribute it and/or
1700 +# modify it under the terms of the GNU Lesser General Public
1701 +# License version 2.1, as published by the Free Software Foundation.
1703 +# This library is distributed in the hope that it will be useful,
1704 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1705 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1706 +# Lesser General Public License for more details.
1708 +# You should have received a copy of the GNU Lesser General Public
1709 +# License along with this library; if not, write to the Free Software
1710 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1711 +# MA 02111-1307 USA
1713 +#*************************************************************************
1715 +PRJ=..$/..
1717 +PRJNAME=desktop
1718 +TARGET=spl_unx
1719 +LIBTARGET=NO
1721 +ENABLE_EXCEPTIONS=TRUE
1723 +# --- Settings -----------------------------------------------------
1725 +.INCLUDE : settings.mk
1727 +# --- Files --------------------------------------------------------
1729 +SLOFILES = $(SLO)$/unxsplash.obj \
1730 + $(SLO)$/services_unxsplash.obj
1732 +SHL1DEPN= makefile.mk
1733 +SHL1OBJS= $(SLOFILES)
1736 +SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
1737 +SHL1IMPLIB=i$(TARGET)
1739 +SHL1VERSIONMAP=exports.map
1740 +SHL1DEF=$(MISC)$/$(SHL1TARGET).def
1741 +DEF1NAME=$(SHL1TARGET)
1743 +SHL1STDLIBS= \
1744 + $(VOSLIB) \
1745 + $(CPPUHELPERLIB) \
1746 + $(CPPULIB) \
1747 + $(SALLIB)
1749 +# --- Targets ------------------------------------------------------
1751 +.INCLUDE : target.mk
1753 diff --git desktop/unx/splash/services_unxsplash.cxx desktop/unx/splash/services_unxsplash.cxx
1754 new file mode 100644
1755 index 0000000..b762fa5
1756 --- /dev/null
1757 +++ desktop/unx/splash/services_unxsplash.cxx
1758 @@ -0,0 +1,177 @@
1759 +/*************************************************************************
1761 + * OpenOffice.org - a multi-platform office productivity suite
1763 + * $RCSfile$
1765 + * $Revision: 7305 $
1767 + * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
1769 + * The Contents of this file are made available subject to
1770 + * the terms of GNU Lesser General Public License Version 2.1.
1773 + * GNU Lesser General Public License Version 2.1
1774 + * =============================================
1775 + * Copyright 2005 by Sun Microsystems, Inc.
1776 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1778 + * This library is free software; you can redistribute it and/or
1779 + * modify it under the terms of the GNU Lesser General Public
1780 + * License version 2.1, as published by the Free Software Foundation.
1782 + * This library is distributed in the hope that it will be useful,
1783 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1784 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1785 + * Lesser General Public License for more details.
1787 + * You should have received a copy of the GNU Lesser General Public
1788 + * License along with this library; if not, write to the Free Software
1789 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1790 + * MA 02111-1307 USA
1792 + ************************************************************************/
1794 +#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
1795 +#include <com/sun/star/beans/NamedValue.hpp>
1796 +#endif
1797 +#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
1798 +#include <com/sun/star/registry/XRegistryKey.hpp>
1799 +#endif
1800 +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
1801 +#include <com/sun/star/util/Date.hpp>
1802 +#endif
1804 +#ifndef _UNO_ENVIRONMENT_H_
1805 +#include <uno/environment.h>
1806 +#endif
1807 +#ifndef _CPPUHELPER_FACTORY_HXX_
1808 +#include <cppuhelper/factory.hxx>
1809 +#endif
1810 +#ifndef _UTL_CONFIGMGR_HXX_
1811 +#include <unotools/configmgr.hxx>
1812 +#endif
1814 +#include <string.h>
1816 +#include "unxsplash.hxx"
1818 +using namespace rtl;
1819 +using namespace ::com::sun::star::uno;
1820 +using namespace ::com::sun::star::lang;
1821 +using namespace ::com::sun::star::beans;
1822 +using namespace ::com::sun::star::registry;
1823 +using namespace ::desktop;
1825 +static const char* pServices[] =
1827 + UnxSplashScreen::serviceName,
1828 + NULL
1831 +static const char* pImplementations[] =
1833 + UnxSplashScreen::implementationName,
1834 + NULL
1837 +typedef Reference<XInterface>(* fProvider)( const Reference<XMultiServiceFactory>& );
1839 +static const fProvider pInstanceProviders[] =
1841 + UnxSplashScreen::getInstance,
1842 + NULL
1846 +static const char** pSupportedServices[] =
1848 + UnxSplashScreen::interfaces,
1849 + NULL
1852 +static Sequence<OUString>
1853 +getSupportedServiceNames( int p ) {
1854 + const char **names = pSupportedServices[p];
1855 + Sequence<OUString> aSeq;
1856 + for ( int i = 0; names[i] != NULL; i++ )
1858 + aSeq.realloc( i+1 );
1859 + aSeq[i] = OUString::createFromAscii( names[i] );
1861 + return aSeq;
1864 +extern "C"
1866 +void SAL_CALL
1867 +component_getImplementationEnvironment(
1868 + const sal_Char** ppEnvironmentTypeName,
1869 + uno_Environment** ppEnvironment )
1871 + *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
1874 +sal_Bool SAL_CALL
1875 +component_writeInfo(
1876 + void* pServiceManager,
1877 + void* pRegistryKey )
1879 + Reference<XMultiServiceFactory> xMan(
1880 + reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
1881 + Reference<XRegistryKey> xKey(
1882 + reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ;
1884 + // iterate over service names and register them...
1885 + OUString aImpl;
1886 + const char* pServiceName = NULL;
1887 + const char* pImplName = NULL;
1888 + for ( int i = 0; ( pServices[i] != NULL ) && ( pImplementations[i] != NULL ); i++ )
1890 + pServiceName= pServices[i];
1891 + pImplName = pImplementations[i];
1892 + aImpl = OUString::createFromAscii( "/" )
1893 + + OUString::createFromAscii( pImplName )
1894 + + OUString::createFromAscii( "/UNO/SERVICES" );
1895 + Reference<XRegistryKey> xNewKey = xKey->createKey( aImpl );
1896 + xNewKey->createKey( OUString::createFromAscii( pServiceName ) );
1898 + return sal_True;
1901 +void* SAL_CALL
1902 +component_getFactory(
1903 + const sal_Char* pImplementationName,
1904 + void* pServiceManager,
1905 + void* pRegistryKey )
1907 + // Set default return value for this operation - if it failed.
1908 + if ( pImplementationName && pServiceManager )
1910 + Reference< XSingleServiceFactory > xFactory;
1911 + Reference< XMultiServiceFactory > xServiceManager(
1912 + reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
1914 + // search implementation
1915 + for ( int i = 0; ( pImplementations[i] != NULL ); i++ )
1917 + if ( strcmp( pImplementations[i], pImplementationName ) == 0 )
1919 + // found implementation
1920 + xFactory = Reference<XSingleServiceFactory>( cppu::createSingleFactory(
1921 + xServiceManager, OUString::createFromAscii( pImplementationName ),
1922 + pInstanceProviders[i], getSupportedServiceNames( i ) ) );
1923 + if ( xFactory.is() )
1925 + // Factory is valid - service was found.
1926 + xFactory->acquire();
1927 + return xFactory.get();
1933 + return NULL;
1935 +} // extern "C"
1936 diff --git desktop/unx/splash/unxsplash.cxx desktop/unx/splash/unxsplash.cxx
1937 new file mode 100644
1938 index 0000000..ca20334
1939 --- /dev/null
1940 +++ desktop/unx/splash/unxsplash.cxx
1941 @@ -0,0 +1,192 @@
1942 +/*************************************************************************
1944 + * OpenOffice.org - a multi-platform office productivity suite
1946 + * $RCSfile$
1948 + * $Revision: 7305 $
1950 + * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
1952 + * The Contents of this file are made available subject to
1953 + * the terms of GNU Lesser General Public License Version 2.1.
1956 + * GNU Lesser General Public License Version 2.1
1957 + * =============================================
1958 + * Copyright 2005 by Sun Microsystems, Inc.
1959 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1961 + * This library is free software; you can redistribute it and/or
1962 + * modify it under the terms of the GNU Lesser General Public
1963 + * License version 2.1, as published by the Free Software Foundation.
1965 + * This library is distributed in the hope that it will be useful,
1966 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1967 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1968 + * Lesser General Public License for more details.
1970 + * You should have received a copy of the GNU Lesser General Public
1971 + * License along with this library; if not, write to the Free Software
1972 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1973 + * MA 02111-1307 USA
1975 + ************************************************************************/
1977 +#include "unxsplash.hxx"
1978 +#include <stdio.h>
1979 +#ifndef _UTL_BOOTSTRAP_HXX
1980 +#include <unotools/bootstrap.hxx>
1981 +#endif
1982 +#ifndef _VOS_PROCESS_HXX_
1983 +#include <vos/process.hxx>
1984 +#endif
1985 +#ifndef _URLOBJ_HXX
1986 +#include <tools/urlobj.hxx>
1987 +#endif
1988 +#ifndef _STREAM_HXX
1989 +#include <tools/stream.hxx>
1990 +#endif
1991 +#ifndef _SFX_HRC
1992 +#include <sfx2/sfx.hrc>
1993 +#endif
1995 +#include <com/sun/star/registry/XRegistryKey.hpp>
1996 +#include <rtl/logfile.hxx>
1997 +#include <rtl/ustrbuf.hxx>
1998 +#include <rtl/math.hxx>
2000 +#define PIPE_ARG "-splash-pipe="
2002 +using namespace ::rtl;
2003 +using namespace ::com::sun::star::registry;
2005 +namespace desktop
2008 +UnxSplashScreen::UnxSplashScreen( const Reference< XMultiServiceFactory >& rSMgr )
2009 + : m_rFactory( rSMgr ),
2010 + m_pOutFd( NULL )
2014 +UnxSplashScreen::~UnxSplashScreen()
2016 +#if OSL_DEBUG_LEVEL > 1
2017 + fprintf( stderr, "UnxSplashScreen::~UnxSplashScreen()\n" );
2018 +#endif
2020 + if ( m_pOutFd )
2022 + fclose( m_pOutFd );
2023 + m_pOutFd = NULL;
2027 +void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
2028 + throw ( RuntimeException )
2032 +void SAL_CALL UnxSplashScreen::end()
2033 + throw ( RuntimeException )
2035 +#if OSL_DEBUG_LEVEL > 1
2036 + fprintf( stderr, "UnxSplashScreen::end()\n" );
2037 +#endif
2039 + fprintf( m_pOutFd, "end\n" );
2040 + fflush( m_pOutFd );
2043 +void SAL_CALL UnxSplashScreen::reset()
2044 + throw ( RuntimeException )
2046 + // TODO?
2049 +void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
2050 + throw ( RuntimeException )
2052 + // TODO?
2055 +void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
2056 + throw ( RuntimeException )
2058 + if ( m_pOutFd )
2060 + fprintf( m_pOutFd, "%d%%\n", nValue );
2061 + fflush( m_pOutFd );
2065 +// XInitialize
2066 +void SAL_CALL
2067 +UnxSplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
2068 + throw ( RuntimeException )
2070 + ::vos::OStartupInfo aInfo;
2071 + for ( sal_uInt32 i = 0; i < aInfo.getCommandArgCount(); i++ )
2073 + rtl::OUString aArg;
2074 + if ( aInfo.getCommandArg( i, aArg ) )
2075 + break;
2076 + if ( aArg.matchIgnoreAsciiCaseAsciiL( PIPE_ARG, sizeof( PIPE_ARG ) - 1, 0 ) )
2078 + OUString aNum = aArg.copy( sizeof( PIPE_ARG ) - 1 );
2079 + int fd = aNum.toInt32();
2080 + m_pOutFd = fdopen( fd, "w" );
2081 +#if OSL_DEBUG_LEVEL > 1
2082 + fprintf( stderr, "Got argument '-splash-pipe=%d ('%s') (%p)\n",
2083 + fd, (const sal_Char *)rtl::OUStringToOString( aNum, RTL_TEXTENCODING_UTF8 ),
2084 + m_pOutFd );
2085 +#endif
2090 +// get service instance...
2091 +UnxSplashScreen *UnxSplashScreen::m_pINSTANCE = NULL;
2092 +osl::Mutex UnxSplashScreen::m_aMutex;
2094 +Reference< XInterface > UnxSplashScreen::getInstance( const Reference< XMultiServiceFactory >& rSMgr )
2096 + if ( m_pINSTANCE == NULL )
2098 + osl::MutexGuard guard( m_aMutex );
2099 + if ( m_pINSTANCE == NULL )
2100 + return (XComponent*) new UnxSplashScreen( rSMgr );
2103 + return (XComponent*)NULL;
2106 +// static service info...
2107 +const char* UnxSplashScreen::interfaces[] =
2109 + "com.sun.star.task.XStartusIndicator",
2110 + "com.sun.star.lang.XInitialization",
2111 + NULL,
2113 +const sal_Char *UnxSplashScreen::serviceName = "com.sun.star.office.PipeSplashScreen";
2114 +const sal_Char *UnxSplashScreen::implementationName = "com.sun.star.office.comp.PipeSplashScreen";
2115 +const sal_Char *UnxSplashScreen::supportedServiceNames[] = { "com.sun.star.office.PipeSplashScreen", NULL };
2117 +OUString UnxSplashScreen::impl_getImplementationName()
2119 + return OUString::createFromAscii( implementationName );
2122 +Sequence<OUString> UnxSplashScreen::impl_getSupportedServiceNames()
2124 + Sequence<OUString> aSequence;
2125 + for ( int i = 0; supportedServiceNames[i] != NULL; i++ )
2127 + aSequence.realloc( i+1 );
2128 + aSequence[i] = OUString::createFromAscii( supportedServiceNames[i] );
2130 + return aSequence;
2134 diff --git desktop/unx/splash/unxsplash.hxx desktop/unx/splash/unxsplash.hxx
2135 new file mode 100644
2136 index 0000000..5419324
2137 --- /dev/null
2138 +++ desktop/unx/splash/unxsplash.hxx
2139 @@ -0,0 +1,117 @@
2140 +/*************************************************************************
2142 + * OpenOffice.org - a multi-platform office productivity suite
2144 + * $RCSfile$
2146 + * $Revision: 7305 $
2148 + * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
2150 + * The Contents of this file are made available subject to
2151 + * the terms of GNU Lesser General Public License Version 2.1.
2154 + * GNU Lesser General Public License Version 2.1
2155 + * =============================================
2156 + * Copyright 2005 by Sun Microsystems, Inc.
2157 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
2159 + * This library is free software; you can redistribute it and/or
2160 + * modify it under the terms of the GNU Lesser General Public
2161 + * License version 2.1, as published by the Free Software Foundation.
2163 + * This library is distributed in the hope that it will be useful,
2164 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2165 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2166 + * Lesser General Public License for more details.
2168 + * You should have received a copy of the GNU Lesser General Public
2169 + * License along with this library; if not, write to the Free Software
2170 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2171 + * MA 02111-1307 USA
2173 + ************************************************************************/
2175 +#include <stdio.h>
2177 +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
2178 +#include <com/sun/star/lang/XServiceInfo.hpp>
2179 +#endif
2180 +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
2181 +#include <com/sun/star/uno/Exception.hpp>
2182 +#endif
2183 +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
2184 +#include <com/sun/star/uno/Reference.h>
2185 +#endif
2186 +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
2187 +#include <com/sun/star/lang/XComponent.hpp>
2188 +#endif
2189 +#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATOR_HPP_
2190 +#include <com/sun/star/task/XStatusIndicator.hpp>
2191 +#endif
2192 +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
2193 +#include <com/sun/star/lang/XInitialization.hpp>
2194 +#endif
2195 +#ifndef _CPPUHELPER_IMPLBASE2_HXX_
2196 +#include <cppuhelper/implbase2.hxx>
2197 +#endif
2198 +#ifndef _CPPUHELPER_INTERFACECONTAINER_H_
2199 +#include <cppuhelper/interfacecontainer.h>
2200 +#endif
2201 +#include <com/sun/star/lang/XSingleServiceFactory.hpp>
2202 +#include <osl/mutex.hxx>
2203 +#ifndef _RTL_BOOTSTRAP_HXX_
2204 +#include <rtl/bootstrap.hxx>
2205 +#endif
2207 +using namespace ::rtl;
2208 +using namespace ::com::sun::star::uno;
2209 +using namespace ::com::sun::star::lang;
2210 +using namespace ::com::sun::star::task;
2212 +namespace desktop {
2214 +class UnxSplashScreen : public ::cppu::WeakImplHelper2< XStatusIndicator, XInitialization >
2216 +private:
2217 + // don't allow anybody but ourselves to create instances of this class
2218 + UnxSplashScreen( const UnxSplashScreen& );
2219 + UnxSplashScreen( void );
2220 + UnxSplashScreen operator =( const UnxSplashScreen& );
2222 + UnxSplashScreen( const Reference< XMultiServiceFactory >& xFactory );
2224 + virtual ~UnxSplashScreen();
2226 + static UnxSplashScreen *m_pINSTANCE;
2228 + static osl::Mutex m_aMutex;
2229 + Reference< XMultiServiceFactory > m_rFactory;
2231 + FILE *m_pOutFd;
2233 +public:
2234 + static const char* interfaces[];
2235 + static const sal_Char *serviceName;
2236 + static const sal_Char *implementationName;
2237 + static const sal_Char *supportedServiceNames[];
2239 + static Reference< XInterface > getInstance( const Reference < XMultiServiceFactory >& xFactory );
2241 + // static service info
2242 + static OUString impl_getImplementationName();
2243 + static Sequence<OUString> impl_getSupportedServiceNames();
2245 + // XStatusIndicator
2246 + virtual void SAL_CALL start( const OUString& aText, sal_Int32 nRange ) throw ( RuntimeException );
2247 + virtual void SAL_CALL end() throw ( RuntimeException );
2248 + virtual void SAL_CALL reset() throw ( RuntimeException );
2249 + virtual void SAL_CALL setText( const OUString& aText ) throw ( RuntimeException );
2250 + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw ( RuntimeException );
2252 + // XInitialize
2253 + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments ) throw ( RuntimeException );
2257 diff --git scp2/source/ooo/common_brand.scp scp2/source/ooo/common_brand.scp
2258 index 6bccbd8..161de3d 100644
2259 --- scp2/source/ooo/common_brand.scp
2260 +++ scp2/source/ooo/common_brand.scp
2261 @@ -415,6 +415,15 @@ File gid_Brand_File_Bin_Soffice_Bin
2262 Name = "soffice.bin";
2265 +#if defined(UNX)
2266 +File gid_File_Bin_QStart_Bin
2267 + BIN_FILE_BODY;
2268 + Dir = gid_Brand_Dir_Program;
2269 + Styles = (PACKED, PATCH);
2270 + Name = "oosplash.bin";
2271 +End
2272 +#endif
2274 // use this for high detail file open dialog >= 5.1 windows
2275 #ifdef WNT
2276 File gid_Brand_File_Bin_Soffice_Bin_Manifest
2277 diff --git scp2/source/ooo/file_library_ooo.scp scp2/source/ooo/file_library_ooo.scp
2278 index 1a6661a..dbbe327 100644
2279 --- scp2/source/ooo/file_library_ooo.scp
2280 +++ scp2/source/ooo/file_library_ooo.scp
2281 @@ -1346,6 +1346,9 @@ File gid_File_Lib_Spell
2284 STD_UNO_LIB_FILE( gid_File_Lib_Spl, spl)
2285 +#ifdef UNX
2286 +STD_UNO_LIB_FILE( gid_File_Lib_Spl_Unx, spl_unx)
2287 +#endif
2289 SPECIAL_UNO_LIB_FILE(gid_File_Lib_Srtrs1,srtrs1)
2291 diff --git smoketestoo_native/smoketest.pl smoketestoo_native/smoketest.pl
2292 index 6785977..c0a2e6c 100755
2293 --- smoketestoo_native/smoketest.pl
2294 +++ smoketestoo_native/smoketest.pl
2295 @@ -502,7 +502,7 @@ sub doTest {
2296 if ($ENV{OS} eq "MACOSX") {
2297 delete $ENV{DYLD_LIBRARY_PATH};
2299 - $Command = "\"$programpath" . "$SOFFICEBIN\" -norestore -nocrashreport macro:///Standard.Global.StartTestWithDefaultOptions";
2300 + $Command = "\"$programpath" . "$SOFFICEBIN\" -no-oosplash -norestore -nocrashreport macro:///Standard.Global.StartTestWithDefaultOptions";
2301 if ( (defined($ENV{OS})) && ($ENV{OS} eq "MACOSX") ) {
2302 $Command = "cd \"$programpath\"; " . $Command;
2304 diff --git solenv/bin/cwscheckapi solenv/bin/cwscheckapi
2305 index fe5ecc1..e43ba12 100755
2306 --- solenv/bin/cwscheckapi
2307 +++ solenv/bin/cwscheckapi
2308 @@ -225,7 +225,7 @@ if [ -n "$WORK_STAMP" ]; then
2312 -PARAM="$PARAM -cmd '$OFFICEBIN -nofirststartwizard -accept=pipe,name=$USER;urp; -norestore -nocrashreport -nolockcheck -enableautomation'"
2313 +PARAM="$PARAM -cmd '$OFFICEBIN -nofirststartwizard -no-oosplash -accept=pipe,name=$USER;urp; -norestore -nocrashreport -nolockcheck -enableautomation'"
2314 PARAM="$PARAM -cs pipe,name=$USER"
2315 PARAM="$PARAM -NoOffice true"
2316 PARAM="$PARAM -SRC_ROOT $SRC_ROOT"
2317 diff --git vcl/inc/vcl/svapp.hxx vcl/inc/vcl/svapp.hxx
2318 index d900862..a324664 100644
2319 --- vcl/inc/vcl/svapp.hxx
2320 +++ vcl/inc/vcl/svapp.hxx
2321 @@ -267,6 +267,7 @@ public:
2322 virtual void DataChanged( const DataChangedEvent& rDCEvt );
2324 virtual void Init();
2325 + virtual void InitFinished();
2326 virtual void DeInit();
2328 static void InitAppRes( const ResId& rResId );
2329 diff --git vcl/source/app/svapp.cxx vcl/source/app/svapp.cxx
2330 index 0c8b1d8..08c9ebd 100644
2331 --- vcl/source/app/svapp.cxx
2332 +++ vcl/source/app/svapp.cxx
2333 @@ -326,6 +326,11 @@ void Application::Init()
2336 // -----------------------------------------------------------------------
2337 +void Application::InitFinished()
2341 +// -----------------------------------------------------------------------
2343 void Application::DeInit()
2345 diff --git vcl/source/window/window.cxx vcl/source/window/window.cxx
2346 index d7cc722..8882c23 100644
2347 --- vcl/source/window/window.cxx
2348 +++ vcl/source/window/window.cxx
2349 @@ -6539,10 +6539,19 @@ void Window::Show( BOOL bVisible, USHORT nFlags )
2350 mpWindowImpl->mpBorderWindow->Show( TRUE, nFlags );
2351 else if ( mpWindowImpl->mbFrame )
2353 - ImplSVData* pSVData = ImplGetSVData();
2354 // #106431#, hide SplashScreen
2355 - if( pSVData->mpIntroWindow && !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
2356 + ImplSVData* pSVData = ImplGetSVData();
2357 + if ( !pSVData->mpIntroWindow )
2359 + // The right way would be just to call this (not even in the 'if')
2360 + GetpApp()->InitFinished();
2362 + else if ( !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
2364 + // ... but the VCL splash is broken, and it needs this
2365 + // (for ./soffice slot:5500)
2366 pSVData->mpIntroWindow->Hide();
2369 //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated");
2370 mpWindowImpl->mbSuppressAccessibilityEvents = FALSE;