update dev300-m57
[ooovba.git] / applied_patches / 0103-unxsplash-rework.diff
blobd3339aa194a78921cfc84c4015e30bd917050007
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 --- desktop/prj/build.lst
14 +++ desktop/prj/build.lst
15 @@ -18,6 +18,8 @@ dt desktop\win32\source\applauncher nmake - w dt_applauncher dt_inc NULL
16 dt desktop\win32\source\rebase nmake - w dt_rebase dt_inc NULL
17 dt desktop\os2\source\applauncher nmake - p dt_applauncher dt_inc NULL
18 dt desktop\unx\source\officeloader nmake - u dt_officeloader_unx dt_inc NULL
19 +dt desktop\unx\source nmake - u dt_uwrapper dt_inc NULL
20 +dt desktop\unx\splash nmake - u dt_usplash dt_inc NULL
21 dt desktop\source\pagein nmake - u dt_pagein dt_inc NULL
22 dt desktop\source\pkgchk\unopkg nmake - all dt_unopkg dt_dp_misc dt_app dt_inc dt_guiloader.w NULL
23 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
24 @@ -35,5 +37,5 @@ dt desktop\source\deployment\registry\configuration nmake - all dt_dp_registry_c
25 dt desktop\source\deployment\registry\help nmake - all dt_dp_registry_help dt_inc NULL
26 dt desktop\source\deployment\registry\executable nmake - all dt_dp_registry_executable dt_inc NULL
27 dt desktop\scripts nmake - u dt_scripts dt_inc NULL
28 -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 dt_rebase.w NULL
29 +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 dt_rebase.w NULL
30 dt desktop\zipintro nmake - all dt_zipintro NULL
31 diff --git desktop/prj/d.lst desktop/prj/d.lst
32 index 1f401d8..78e9977 100644
33 --- desktop/prj/d.lst
34 +++ desktop/prj/d.lst
35 @@ -13,6 +13,7 @@ mkdir: %_DEST%\bin%_EXT%\odf4ms
36 ..\%__SRC%\bin\officeloader.exe %_DEST%\bin%_EXT%\soffice.exe
37 ..\%__SRC%\bin\soffice %_DEST%\bin%_EXT%\soffice.bin
38 ..\%__SRC%\bin\soffice_mac %_DEST%\bin%_EXT%\soffice
39 +..\%__SRC%\bin\oosplash %_DEST%\bin%_EXT%\oosplash.bin
40 ..\%__SRC%\bin\so\soffice.bin %_DEST%\bin%_EXT%\so\soffice.bin
41 ..\%__SRC%\bin\so\officeloader.exe %_DEST%\bin%_EXT%\so\soffice.exe
42 ..\%__SRC%\bin\so\soffice %_DEST%\bin%_EXT%\so\soffice.bin
43 diff --git desktop/scripts/soffice.sh desktop/scripts/soffice.sh
44 index b469f35..9ebd74c 100644
45 --- desktop/scripts/soffice.sh
46 +++ desktop/scripts/soffice.sh
47 @@ -128,6 +128,16 @@ sd_pagein_args="${sd_pagein_args:+${sd_pagein_args} }@pagein-common"
48 PATH=$sd_prog${PATH+:$PATH}
49 export PATH
51 +# test for availability of the fast external splash
52 +for arg in $@; do
53 + if [ "$arg" = "-nologo" -o "$arg" = "-no-oosplash" ]; then
54 + no_oosplash=y
55 + fi
56 +done
57 +if [ "$sd_binary" = "soffice.bin" -a -x "$sd_prog/oosplash.bin" ] && [ "$no_oosplash" != "y" ] ; then
58 + sd_binary="oosplash.bin"
59 +fi
61 # execute soffice binary
62 "$sd_prog/$sd_binary" "$@" &
63 trap 'kill -9 $!' TERM
64 diff --git desktop/source/app/app.cxx desktop/source/app/app.cxx
65 index deac5f2..b1645eb 100644
66 --- desktop/source/app/app.cxx
67 +++ desktop/source/app/app.cxx
68 @@ -506,6 +506,13 @@ void Desktop::Init()
72 +void Desktop::InitFinished()
74 + RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::InitFinished" );
76 + CloseSplashScreen();
79 void Desktop::DeInit()
81 RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::Desktop::DeInit" );
82 @@ -1232,6 +1239,7 @@ void Desktop::Main()
83 OpenSplashScreen();
84 RTL_LOGFILE_CONTEXT_TRACE( aLog, "desktop (lo119109) Desktop::Main } OpenSplashScreen" );
86 + SetSplashScreenProgress(10);
88 UserInstall::UserInstallError instErr_fin = UserInstall::finalize();
89 if ( instErr_fin != UserInstall::E_None)
90 @@ -1247,7 +1255,7 @@ void Desktop::Main()
92 // refresh path information
93 utl::Bootstrap::reloadData();
94 - SetSplashScreenProgress(25);
95 + SetSplashScreenProgress(20);
98 Reference< XMultiServiceFactory > xSMgr =
99 @@ -1260,7 +1268,7 @@ void Desktop::Main()
101 RegisterServices( xSMgr );
103 - //SetSplashScreenProgress(15);
104 + SetSplashScreenProgress(25);
106 #ifndef UNX
107 if ( pCmdLineArgs->IsHelp() ) {
108 @@ -1298,7 +1306,7 @@ void Desktop::Main()
109 // Read the common configuration items for optimization purpose
110 if ( !InitializeConfiguration() ) return;
112 - //SetSplashScreenProgress(20);
113 + SetSplashScreenProgress(30);
115 // set static variable to enabled/disable crash reporter
116 retrieveCrashReporterState();
117 @@ -1357,10 +1365,10 @@ void Desktop::Main()
118 #endif
120 SetDisplayName( aTitle );
121 -// SetSplashScreenProgress(30);
122 + SetSplashScreenProgress(35);
123 RTL_LOGFILE_CONTEXT_TRACE( aLog, "{ create SvtPathOptions and SvtLanguageOptions" );
124 pPathOptions.reset( new SvtPathOptions);
125 -// SetSplashScreenProgress(40);
126 + SetSplashScreenProgress(40);
127 // pLanguageOptions = new SvtLanguageOptions(sal_True);
128 // SetSplashScreenProgress(45);
129 RTL_LOGFILE_CONTEXT_TRACE( aLog, "} create SvtPathOptions and SvtLanguageOptions" );
130 @@ -1452,7 +1460,7 @@ void Desktop::Main()
131 OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY );
132 if (xDesktopFrame.is())
134 -// SetSplashScreenProgress(60);
135 + SetSplashScreenProgress(60);
136 Reference< XFrame > xBackingFrame;
137 Reference< ::com::sun::star::awt::XWindow > xContainerWindow;
139 @@ -1468,7 +1476,7 @@ void Desktop::Main()
140 Reference< XController > xBackingComp(
141 xSMgr->createInstanceWithArguments(OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.StartModule") ), lArgs),
142 UNO_QUERY);
143 -// SetSplashScreenProgress(80);
144 + SetSplashScreenProgress(80);
145 if (xBackingComp.is())
147 Reference< ::com::sun::star::awt::XWindow > xBackingWin(xBackingComp, UNO_QUERY);
148 @@ -1507,7 +1515,7 @@ void Desktop::Main()
149 return;
152 -// SetSplashScreenProgress(55);
153 + SetSplashScreenProgress(55);
155 SvtFontSubstConfig().Apply();
157 @@ -1516,7 +1524,7 @@ void Desktop::Main()
158 aAppearanceCfg.SetApplicationDefaults( this );
159 SvtAccessibilityOptions aOptions;
160 aOptions.SetVCLSettings();
161 -// SetSplashScreenProgress(60);
162 + SetSplashScreenProgress(60);
164 Application::SetFilterHdl( LINK( this, Desktop, ImplInitFilterHdl ) );
166 @@ -1539,7 +1547,7 @@ void Desktop::Main()
167 // use system window dialogs
168 Application::SetSystemWindowMode( SYSTEMWINDOW_MODE_DIALOG );
170 -// SetSplashScreenProgress(80);
171 + SetSplashScreenProgress(80);
173 if ( !bTerminateRequested && !pCmdLineArgs->IsInvisible() )
174 InitializeQuickstartMode( xSMgr );
175 @@ -2832,14 +2840,18 @@ void Desktop::OpenSplashScreen()
176 else if ( pCmdLine->IsWeb() )
177 aAppName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "web" ));
179 + // Which splash to use
180 + OUString aSplashService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.SplashScreen" ));
181 + if ( pCmdLine->GetStringParam( CommandLineArgs::CMD_STRINGPARAM_SPLASHPIPE ).getLength() )
182 + aSplashService = OUString::createFromAscii("com.sun.star.office.PipeSplashScreen");
184 bVisible = sal_True;
185 Sequence< Any > aSeq( 2 );
186 aSeq[0] <<= bVisible;
187 aSeq[1] <<= aAppName;
188 m_rSplashScreen = Reference<XStatusIndicator>(
189 comphelper::getProcessServiceFactory()->createInstanceWithArguments(
190 - OUString::createFromAscii("com.sun.star.office.SplashScreen"),
191 - aSeq), UNO_QUERY);
192 + aSplashService, aSeq), UNO_QUERY);
194 if(m_rSplashScreen.is())
195 m_rSplashScreen->start(OUString::createFromAscii("SplashScreen"), 100);
196 diff --git desktop/source/app/cmdlineargs.cxx desktop/source/app/cmdlineargs.cxx
197 index b14baab..6b8ca2a 100644
198 --- desktop/source/app/cmdlineargs.cxx
199 +++ desktop/source/app/cmdlineargs.cxx
200 @@ -457,6 +457,11 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString&
201 SetBoolParam_Impl( CMD_BOOLPARAM_HELPMATH, sal_True );
202 return sal_True;
204 + else if ( aArgStr.Copy(0, 13).EqualsIgnoreCaseAscii( "-splash-pipe=" ))
206 + AddStringListParam_Impl( CMD_STRINGPARAM_SPLASHPIPE, aArgStr.Copy( 13 ) );
207 + return sal_True;
209 #ifdef MACOSX
210 /* #i84053# ignore -psn on Mac
211 Platform dependent #ifdef here is ugly, however this is currently
212 @@ -858,7 +863,8 @@ sal_Bool CommandLineArgs::IsEmptyOrAcceptOnly() const
214 osl::MutexGuard aMutexGuard( m_aMutex );
216 - return m_eArgumentCount == NONE ||
217 + return m_eArgumentCount == NONE ||
218 + ( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_SPLASHPIPE ].getLength() )) ||
219 ( ( m_eArgumentCount == ONE ) && ( m_aStrParams[ CMD_STRINGPARAM_ACCEPT ].getLength() )) ||
220 ( ( m_eArgumentCount == ONE ) && m_aBoolParams[ CMD_BOOLPARAM_PSN ] );
222 diff --git desktop/source/app/cmdlineargs.hxx desktop/source/app/cmdlineargs.hxx
223 index 6411398..c42bb99 100644
224 --- desktop/source/app/cmdlineargs.hxx
225 +++ desktop/source/app/cmdlineargs.hxx
226 @@ -79,6 +79,7 @@ class CommandLineArgs
227 enum StringParam // must be zero based!
229 CMD_STRINGPARAM_PORTAL,
230 + CMD_STRINGPARAM_SPLASHPIPE,
231 CMD_STRINGPARAM_ACCEPT,
232 CMD_STRINGPARAM_UNACCEPT,
233 CMD_STRINGPARAM_USERDIR,
234 diff --git desktop/unx/source/makefile.mk desktop/unx/source/makefile.mk
235 new file mode 100644
236 index 0000000..110d081
237 --- /dev/null
238 +++ desktop/unx/source/makefile.mk
239 @@ -0,0 +1,38 @@
240 +PRJ=..$/..
241 +PRJNAME=desktop
242 +TARGET=oosplash
244 +NO_DEFAULT_STL=TRUE
246 +.INCLUDE : settings.mk
248 +STDLIB=
250 +OBJFILES= \
251 + $(OBJ)$/splashx.obj \
252 + $(OBJ)$/start.obj
254 +APP1TARGET = $(TARGET)
255 +APP1OBJS = $(OBJFILES)
256 +APP1LIBSALCPPRT=
257 +APP1CODETYPE = C
258 +APP1STDLIBS = $(SALLIB) -lX11
259 +.IF "$(OS)"=="SOLARIS"
260 +APP1STDLIBS+= -lsocket
261 +.ENDIF
263 +# --- Targets ------------------------------------------------------
265 +.INCLUDE : target.mk
267 +$(OBJ)$/start.obj : $(INCCOM)$/introbmpnames.hxx
269 +.INCLUDE .IGNORE : $(MISC)$/intro_bmp_names.mk
271 +.IF "$(INTRO_BITMAPS:f)"!="$(LASTTIME_INTRO_BITMAPS)"
272 +DO_PHONY=.PHONY
273 +.ENDIF # "$(INTRO_BITMAPS:f)"!="$(LASTTIME_INTRO_BITMAPS)"
275 +$(INCCOM)$/introbmpnames.hxx $(DO_PHONY):
276 + echo const char INTRO_BITMAP_STRINGLIST[]=$(EMQ)"$(INTRO_BITMAPS:f:t",")$(EMQ)"$(EMQ); > $@
277 + echo LASTTIME_INTRO_BITMAPS=$(INTRO_BITMAPS:f) > $(MISC)$/intro_bmp_names.mk
278 diff --git desktop/unx/source/splashx.c desktop/unx/source/splashx.c
279 new file mode 100644
280 index 0000000..b3b6da0
281 --- /dev/null
282 +++ desktop/unx/source/splashx.c
283 @@ -0,0 +1,570 @@
284 +/*************************************************************************
286 + * OpenOffice.org - a multi-platform office productivity suite
288 + * $RCSfile$
290 + * $Revision: 9695 $
292 + * last change: $Author: jholesovsky $ $Date: 2007-07-03 16:36:09 +0200 (Út, 03 čec 2007) $
294 + * The Contents of this file are made available subject to
295 + * the terms of GNU Lesser General Public License Version 2.1.
298 + * GNU Lesser General Public License Version 2.1
299 + * =============================================
300 + * Copyright 2005 by Sun Microsystems, Inc.
301 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
303 + * This library is free software; you can redistribute it and/or
304 + * modify it under the terms of the GNU Lesser General Public
305 + * License version 2.1, as published by the Free Software Foundation.
307 + * This library is distributed in the hope that it will be useful,
308 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
309 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
310 + * Lesser General Public License for more details.
312 + * You should have received a copy of the GNU Lesser General Public
313 + * License along with this library; if not, write to the Free Software
314 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
315 + * MA 02111-1307 USA
317 + ************************************************************************/
319 +#include <X11/Xlib.h>
320 +#include <X11/Xatom.h>
321 +#include <X11/Xutil.h>
323 +#include "osl/endian.h"
324 +#include <fcntl.h>
325 +#include <stdint.h>
326 +#include <stdio.h>
327 +#include <stdlib.h>
328 +#include <string.h>
329 +#include <unistd.h>
331 +#include "splashx.h"
333 +typedef struct {
334 + unsigned char b, g, r;
335 +} color_t;
337 +#define WINDOW_WIDTH 440
338 +#define WINDOW_HEIGHT 299
340 +#define PROGRESS_XOFFSET 12
341 +#define PROGRESS_YOFFSET 18
342 +#define PROGRESS_BARSPACE 2
344 +static Display *display = NULL;
345 +static int screen;
346 +static int depth;
347 +static Visual *visual = NULL;
349 +static int width = WINDOW_WIDTH;
350 +static int height = WINDOW_HEIGHT;
352 +static Colormap color_map;
353 +static Window win;
354 +static GC gc;
356 +// Progress bar values
357 +// taken from desktop/source/splash/splash.cxx
358 +static int tlx = 212;
359 +static int tly = 216;
360 +static int barwidth = 263;
361 +static int barheight = 8;
362 +static int barspace = PROGRESS_BARSPACE;
363 +static color_t barcol = { 18, 202, 157 };
364 +static color_t framecol = { 0xD3, 0xD3, 0xD3 };
366 +static XColor barcolor;
367 +static XColor framecolor;
369 +static color_t *bitmap = NULL;
371 +#define BMP_HEADER_LEN 14
372 +#define WIN_INFO_LEN 40
374 +#define UINT8( x ) ( (unsigned int)( ( (uint8_t *)( x ) )[0] ) )
376 +#define UINT16( x ) ( ( (unsigned int)( ( (uint8_t *)( x ) )[0] ) ) + \
377 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[1] ) ) << 8 ) )
379 +#define UINT32( x ) ( ( (unsigned int)( ( (uint8_t *)( x ) )[0] ) ) + \
380 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[1] ) ) << 8 ) + \
381 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[2] ) ) << 16 ) + \
382 + ( ( (unsigned int)( ( (uint8_t *)( x ) )[3] ) ) << 24 ) )
384 +#define MAX( x, y ) ( ( (x) > (y) )? (x): (y) )
386 +#define LOAD_FAILURE( msg ) \
387 + { \
388 + fprintf( stderr, "%s: " msg, filename ); \
389 + close( fd ); \
390 + return 0; \
393 +// Load the specified Windows 24bit BMP to 'bitmap'
394 +// Return: 1 - success, 0 - failure
395 +int splash_load_bmp( char *filename )
397 + int fd = open( filename, O_RDONLY );
398 + if ( fd < 0 )
399 + return 0;
401 + char file_header[ BMP_HEADER_LEN ];
403 + if ( read( fd, file_header, BMP_HEADER_LEN ) != BMP_HEADER_LEN || file_header[0] != 'B' || file_header[1] != 'M' )
404 + LOAD_FAILURE( "Not a bitmap.\n" );
406 + int file_size = UINT32( file_header + 2 );
408 + char info_header[ WIN_INFO_LEN ];
409 + if ( read( fd, info_header, 4 ) != 4 )
410 + LOAD_FAILURE( "Unable to read the header.\n" );
412 + int header_size = UINT32( info_header );
413 + if ( header_size != WIN_INFO_LEN )
414 + LOAD_FAILURE( "Not a Windows bitmap.\n" );
416 + if ( read( fd, info_header + 4, WIN_INFO_LEN - 4 ) != WIN_INFO_LEN - 4 )
417 + LOAD_FAILURE( "The header ended too early.\n" );
419 + width = UINT32( info_header + 4 );
420 + height = UINT32( info_header + 8 );
422 + int bits = UINT16( info_header + 14 );
423 + int compression = UINT16( info_header + 16 );
425 + if ( bits != 24 )
426 + LOAD_FAILURE( "Just 24 bpp bitmaps are supported.\n" );
428 + if ( compression != 0 )
429 + LOAD_FAILURE( "Just uncompressed bitmaps are supported.\n" );
431 + size_t bitmap_size = width * height * 3;
432 + bitmap = malloc( bitmap_size );
433 + if ( bitmap == NULL )
434 + LOAD_FAILURE( "Cannot allocate memory for the data.\n" );
436 + if ( read( fd, bitmap, bitmap_size ) != bitmap_size )
437 + LOAD_FAILURE( "Cannot read the bitmap data.\n" );
439 + close( fd );
440 + return 1;
443 +static void setup_color( int val[3], color_t *col )
445 + if ( val[0] < 0 || val[1] < 0 || val[2] < 0 )
446 + return;
448 +#define CONVERT_COLOR( from,to ) if ( from < 0 ) to = 0; else if ( from > 255 ) to = 255; else to = from;
449 + CONVERT_COLOR( val[0], col->r );
450 + CONVERT_COLOR( val[1], col->g );
451 + CONVERT_COLOR( val[2], col->b );
452 +#undef CONVERT_COLOR
455 +// setup
456 +void splash_setup( int barc[3], int framec[3], int posx, int posy, int w, int h )
458 + if ( width <= 500 )
460 + barwidth = width - ( 2 * PROGRESS_XOFFSET );
461 + barheight = 6;
462 + tlx = PROGRESS_XOFFSET;
463 + tly = height - PROGRESS_YOFFSET;
465 + barcol.r = 0;
466 + barcol.g = 0;
467 + barcol.b = 128;
470 + if ( posx >= 0 )
471 + tlx = posx;
472 + if ( posy >= 0 )
473 + tly = posy;
474 + if ( w >= 0 )
475 + barwidth = w;
476 + if ( h >= 0 )
477 + barheight = h;
479 + setup_color( barc, &barcol );
480 + setup_color( framec, &framecol );
483 +// Universal shift: bits >= 0 - left, otherwise right
484 +#define SHIFT( x, bits ) ( ( (bits) >= 0 )? ( (x) << (bits) ): ( (x) >> -(bits) ) )
486 +// Position of the highest bit (more or less integer log2)
487 +inline int HIGHEST_BIT( unsigned long x )
489 + int i = 0;
490 + for ( ; x; ++i )
491 + x >>= 1;
493 + return i;
496 +// Number of bits set to 1
497 +inline int BITS( unsigned long x )
499 + int i = 0;
500 + for ( ; x; x >>= 1 )
501 + if ( x & 1UL )
502 + ++i;
504 + return i;
507 +// Set 'bitmap' as the background of our 'win' window
508 +static void create_pixmap()
510 + if ( !bitmap )
511 + return;
513 + Pixmap pixmap = XCreatePixmap( display, win, width, height, depth );
515 + unsigned long value_mask = 0;
516 + XGCValues values;
517 + GC pixmap_gc = XCreateGC( display, pixmap, value_mask, &values );
519 + if ( visual->class == TrueColor )
521 + unsigned long red_mask = visual->red_mask;
522 + unsigned long green_mask = visual->green_mask;
523 + unsigned long blue_mask = visual->blue_mask;
525 + unsigned long red_delta_mask = ( 1UL << ( 8 - BITS( red_mask ) ) ) - 1;
526 + unsigned long green_delta_mask = ( 1UL << ( 8 - BITS( green_mask ) ) ) - 1;
527 + unsigned long blue_delta_mask = ( 1UL << ( 8 - BITS( blue_mask ) ) ) - 1;
529 + int red_shift = HIGHEST_BIT( red_mask ) - 8;
530 + int green_shift = HIGHEST_BIT( green_mask ) - 8;
531 + int blue_shift = HIGHEST_BIT( blue_mask ) - 8;
533 + XImage *image = XCreateImage( display, visual, depth, ZPixmap,
534 + 0, NULL, width, height, 32, 0 );
536 + int bytes_per_line = image->bytes_per_line;
537 + int bpp = image->bits_per_pixel;
538 + int byte_order = image->byte_order;
539 + int machine_byte_order;
540 +#if defined( _LITTLE_ENDIAN )
541 + machine_byte_order = LSBFirst;
542 +#elif defined( _BIG_ENDIAN )
543 + machine_byte_order = MSBFirst;
544 +#else
546 + fprintf( stderr, "Unsupported machine endianity.\n" );
547 + XFreeGC( display, pixmap_gc );
548 + XFreePixmap( display, pixmap );
549 + XDestroyImage( image );
550 + return;
552 +#endif
554 + char *data = malloc( height * bytes_per_line );
555 + image->data = data;
557 + // The following dithers & converts the color_t color to one
558 + // acceptable for the visual
559 +#define COPY_IN_OUT( pix_size, code ) \
560 + { \
561 + out += pix_size * width * ( height - 1 ); \
562 + int x, y; \
563 + for ( y = 0; y < height; ++y ) \
564 + { \
565 + unsigned long red_delta = 0, green_delta = 0, blue_delta = 0; \
566 + for ( x = 0; x < width; ++x, ++in ) \
567 + { \
568 + unsigned long red = in->r + red_delta; \
569 + unsigned long green = in->g + green_delta; \
570 + unsigned long blue = in->b + blue_delta; \
571 + red_delta = red & red_delta_mask; \
572 + green_delta = green & green_delta_mask; \
573 + blue_delta = blue & blue_delta_mask; \
574 + if ( red > 255 ) \
575 + red = 255; \
576 + if ( green > 255 ) \
577 + green = 255; \
578 + if ( blue > 255 ) \
579 + blue = 255; \
580 + unsigned long pixel = \
581 + ( SHIFT( red, red_shift ) & red_mask ) | \
582 + ( SHIFT( green, green_shift ) & green_mask ) | \
583 + ( SHIFT( blue, blue_shift ) & blue_mask ); \
584 + code \
585 + } \
586 + out -= 2 * pix_size * width; \
587 + } \
590 + color_t *in = bitmap;
591 + char *out = data;
593 + if ( bpp == 32 )
595 + if ( machine_byte_order == byte_order )
596 + COPY_IN_OUT( 4, *( (uint32_t *)out ) = (uint32_t)pixel; out += 4; )
597 + else
598 + COPY_IN_OUT( 4, uint32_t tmp = pixel;
599 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 3 );
600 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
601 + *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 1 );
602 + *( (uint8_t *)out + 3 ) = *( (uint8_t *)(&tmp) );
603 + out += 4; )
605 + else if ( bpp == 24 )
607 + if ( machine_byte_order == byte_order && byte_order == LSBFirst )
608 + COPY_IN_OUT( 3, *( (color_t *)out ) = *( (color_t *)( &pixel ) ); out += 3; )
609 + if ( machine_byte_order == byte_order && byte_order == MSBFirst )
610 + COPY_IN_OUT( 3, uint32_t tmp = pixel;
611 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 1 );
612 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
613 + *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 3 );
614 + out += 3; )
615 + else
616 + COPY_IN_OUT( 3, uint32_t tmp = pixel;
617 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 3 );
618 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
619 + *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 1 );
620 + out += 3; )
622 + else if ( bpp == 16 )
624 + if ( machine_byte_order == byte_order )
625 + COPY_IN_OUT( 2, *( (uint16_t *)out ) = (uint16_t)pixel; out += 2; )
626 + else
627 + COPY_IN_OUT( 2, uint16_t tmp = pixel;
628 + *( (uint8_t *)out ) = *( (uint8_t *)(&tmp) + 1 );
629 + *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) );
630 + out += 2; );
632 + else if ( bpp == 8 )
634 + COPY_IN_OUT( 1, *( (uint8_t *)out ) = (uint8_t)pixel; ++out; )
636 + else
638 + fprintf( stderr, "Unsupported depth: %d bits per pixel.\n", bpp );
639 + XFreeGC( display, pixmap_gc );
640 + XFreePixmap( display, pixmap );
641 + XDestroyImage( image );
642 + return;
645 +#undef COPY_IN_OUT
647 + XPutImage( display, pixmap, pixmap_gc, image, 0, 0, 0, 0, width, height );
648 + XDestroyImage( image );
650 + else //if ( depth == 1 || visual->class == DirectColor )
652 + // FIXME Something like the following, but faster ;-) - XDrawPoint is not
653 + // a good idea...
654 + int x, y;
655 + for ( y = 0; y < height; ++y )
657 + color_t *color = bitmap + y * width;
659 + int delta = 0;
660 + for ( x = 0; x < width; ++x, ++color )
662 + int rnd = (int)( ( (long)( random() - RAND_MAX/2 ) * 32000 )/RAND_MAX );
663 + int luminance = delta + rnd + 299 * (int)color->r + 587 * (int)color->g + 114 * (int)color->b;
665 + if ( luminance < 128000 )
667 + XSetForeground( display, pixmap_gc, BlackPixel( display, screen ) );
668 + delta = luminance;
670 + else
672 + XSetForeground( display, pixmap_gc, WhitePixel( display, screen ) );
673 + delta = luminance - 255000;
676 + XDrawPoint( display, pixmap, pixmap_gc, x, y );
681 + XSetWindowBackgroundPixmap( display, win, pixmap );
683 + XFreeGC( display, pixmap_gc );
684 + XFreePixmap( display, pixmap );
687 +// The old method of hiding the window decorations
688 +static void suppress_decorations_motif()
690 + struct {
691 + unsigned long flags, functions, decorations;
692 + long input_mode;
693 + unsigned long status;
694 + } mwmhints;
696 + Atom a = XInternAtom( display, "_MOTIF_WM_HINTS", False );
698 + mwmhints.flags = 15; // functions, decorations, input_mode, status
699 + mwmhints.functions = 2; // ?
700 + mwmhints.decorations = 0;
701 + mwmhints.input_mode = 0;
703 + XChangeProperty( display, win, a, a, 32,
704 + PropModeReplace, (unsigned char*)&mwmhints, 5 );
707 +// This is a splash, set it as such.
708 +// If it fails, just hide the decorations...
709 +static void suppress_decorations()
711 + Atom atom_type = XInternAtom( display, "_NET_WM_WINDOW_TYPE", True );
712 + Atom atom_splash = XInternAtom( display, "_NET_WM_WINDOW_TYPE_SPLASH", True );
714 + if ( atom_type != None && atom_splash != None )
715 + XChangeProperty( display, win, atom_type, XA_ATOM, 32,
716 + PropModeReplace, (unsigned char*)&atom_splash, 1 );
717 + //else
718 + suppress_decorations_motif(); // FIXME: Unconditional until Metacity/compiz's SPLASH handling is fixed
721 +// Create the window
722 +// Return: 1 - success, 0 - failure
723 +int splash_create_window( int argc, char** argv )
725 + char *display_name = NULL;
726 + int i;
727 + for ( i = 0; i < argc; i++ )
729 + if ( !strcmp( argv[i], "-display" ) || !strcmp( argv[i], "--display" ) )
730 + display_name = ( i + 1 < argc )? argv[i+1]: NULL;
733 + if ( !display_name )
734 + display_name = getenv( "DISPLAY" );
736 + // init display
737 + display = XOpenDisplay( display_name );
738 + if ( !display )
740 + fprintf( stderr, "Failed to open display\n" );
741 + return 0;
744 + // create the window
745 + screen = DefaultScreen( display );
746 + depth = DefaultDepth( display, screen );
747 + color_map = DefaultColormap( display, screen );
748 + visual = DefaultVisual( display, screen );
750 + Window root_win = RootWindow( display, screen );
751 + int display_width = DisplayWidth( display, screen );
752 + int display_height = DisplayHeight( display, screen );
754 + win = XCreateSimpleWindow( display, root_win,
755 + ( display_width - width ) / 2, ( display_height - height ) / 2,
756 + width, height, 0,
757 + BlackPixel( display, screen ), BlackPixel( display, screen ) );
759 + XSetWindowColormap( display, win, color_map );
761 + // setup colors
762 +#define FILL_COLOR( xcol,col ) xcol.red = 256*col.r; xcol.green = 256*col.g; xcol.blue = 256*col.b;
763 + FILL_COLOR( barcolor, barcol );
764 + FILL_COLOR( framecolor, framecol );
765 +#undef FILL_COLOR
767 + XAllocColor( display, color_map, &barcolor );
768 + XAllocColor( display, color_map, &framecolor );
770 + // not resizable, no decorations, etc.
771 + unsigned long value_mask = 0;
772 + XGCValues values;
773 + gc = XCreateGC( display, win, value_mask, &values );
775 + XSizeHints size_hints;
776 + size_hints.flags = PPosition | PSize | PMinSize | PMaxSize;
777 + size_hints.min_width = width;
778 + size_hints.max_width = width;
779 + size_hints.min_height = height;
780 + size_hints.max_height = height;
782 + char *name = "OpenOffice.org";
783 + char *icon = "icon"; // FIXME
785 + XSetStandardProperties( display, win, name, icon, None,
786 + 0, 0, &size_hints );
788 + // the actual work
789 + suppress_decorations();
790 + create_pixmap();
792 + // show it
793 + XSelectInput( display, win, 0 );
794 + XMapWindow( display, win );
796 + return 1;
799 +// Re-draw & process the events
800 +// Just throwing them away - we do not need anything more...
801 +static void process_events()
803 + XEvent xev;
804 + int num_events;
806 + XFlush( display );
807 + num_events = XPending( display );
808 + while ( num_events > 0 )
810 + num_events--;
811 + XNextEvent( display, &xev );
812 + //process_event(xev);
816 +// Draw the progress
817 +void splash_draw_progress( int progress )
819 + // sanity
820 + if ( progress < 0 )
821 + progress = 0;
822 + if ( progress > 100 )
823 + progress = 100;
825 + // draw progress...
826 + int length = ( progress * barwidth / 100 ) - ( 2 * barspace );
827 + if ( length < 0 )
828 + length = 0;
830 + // border
831 + XSetForeground( display, gc, framecolor.pixel );
832 + XDrawRectangle( display, win, gc,
833 + tlx, tly,
834 + barwidth, barheight );
836 + // progress bar
837 + XSetForeground( display, gc, barcolor.pixel );
838 + XFillRectangle( display, win, gc,
839 + tlx + barspace, tly + barspace,
840 + length + 1, barheight - 2*barspace + 1 );
842 + // pending events
843 + process_events();
846 +// Close the window & cleanup
847 +void splash_close_window()
849 + XCloseDisplay( display );
851 + free( bitmap );
852 + bitmap = NULL;
854 diff --git desktop/unx/source/splashx.h desktop/unx/source/splashx.h
855 new file mode 100644
856 index 0000000..6d84d4b
857 --- /dev/null
858 +++ desktop/unx/source/splashx.h
859 @@ -0,0 +1,71 @@
860 +/*************************************************************************
862 + * OpenOffice.org - a multi-platform office productivity suite
864 + * $RCSfile$
866 + * $Revision: 9695 $
868 + * last change: $Author: jholesovsky $ $Date: 2007-07-03 16:36:09 +0200 (Út, 03 čec 2007) $
870 + * The Contents of this file are made available subject to
871 + * the terms of GNU Lesser General Public License Version 2.1.
874 + * GNU Lesser General Public License Version 2.1
875 + * =============================================
876 + * Copyright 2005 by Sun Microsystems, Inc.
877 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
879 + * This library is free software; you can redistribute it and/or
880 + * modify it under the terms of the GNU Lesser General Public
881 + * License version 2.1, as published by the Free Software Foundation.
883 + * This library is distributed in the hope that it will be useful,
884 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
885 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
886 + * Lesser General Public License for more details.
888 + * You should have received a copy of the GNU Lesser General Public
889 + * License along with this library; if not, write to the Free Software
890 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
891 + * MA 02111-1307 USA
893 + ************************************************************************/
895 +#ifndef _SPLASHX_H
896 +#define _SPLASHX_H
898 +#ifdef __cplusplus
899 +extern "C" {
900 +#endif
902 +// Load the specified Windows 24bit BMP we can have as a background of the
903 +// splash.
905 +// Note: Must be called before the create_window(), otherwise there will be no
906 +// image in the splash, just black rectangle.
908 +// Return: 1 - success, 0 - failure (non-existing, etc.)
909 +int splash_load_bmp( char *filename );
911 +// Init some of the values
912 +// If not called, the defaults are used
913 +// barc, framec - colors, posx, posy - position, w, h - size
914 +void splash_setup( int barc[3], int framec[3], int posx, int posy, int w, int h );
916 +// Create the splash window
917 +// Return: 1 - success, 0 - failure
918 +int splash_create_window( int argc, char** argv );
920 +// Destroy the splash window
921 +void splash_close_window();
923 +// Update the progress bar
924 +void splash_draw_progress( int progress );
926 +#ifdef __cplusplus
927 +} // extern "C"
928 +#endif
930 +#endif // _SPLASHX_H
931 diff --git desktop/unx/source/start.c desktop/unx/source/start.c
932 new file mode 100644
933 index 0000000..a42a286
934 --- /dev/null
935 +++ desktop/unx/source/start.c
936 @@ -0,0 +1,719 @@
937 +/*************************************************************************
939 + * OpenOffice.org - a multi-platform office productivity suite
941 + * $RCSfile$
943 + * $Revision: 9695 $
945 + * last change: $Author: jholesovsky $ $Date: 2007-07-03 16:36:09 +0200 (Út, 03 čec 2007) $
947 + * The Contents of this file are made available subject to
948 + * the terms of GNU Lesser General Public License Version 2.1.
951 + * GNU Lesser General Public License Version 2.1
952 + * =============================================
953 + * Copyright 2005 by Sun Microsystems, Inc.
954 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
956 + * This library is free software; you can redistribute it and/or
957 + * modify it under the terms of the GNU Lesser General Public
958 + * License version 2.1, as published by the Free Software Foundation.
960 + * This library is distributed in the hope that it will be useful,
961 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
962 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
963 + * Lesser General Public License for more details.
965 + * You should have received a copy of the GNU Lesser General Public
966 + * License along with this library; if not, write to the Free Software
967 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
968 + * MA 02111-1307 USA
970 + ************************************************************************/
972 +#include <signal.h>
973 +#include <unistd.h>
974 +#include <limits.h>
975 +#include <stdlib.h>
976 +#include <sys/types.h>
977 +#include <sys/stat.h>
978 +#include <sys/socket.h>
979 +#include <arpa/inet.h>
980 +#include <sys/un.h>
981 +#include <sys/poll.h>
982 +#include <fcntl.h>
983 +#include <stdio.h>
984 +#include <libgen.h>
986 +#include <osl/nlsupport.h>
987 +#include <osl/process.h>
988 +#include <rtl/bootstrap.h>
989 +#include <rtl/digest.h>
990 +#include <sal/main.h>
992 +#include "splashx.h"
993 +#include <introbmpnames.hxx>
995 +#define PIPEDEFAULTPATH "/tmp"
996 +#define PIPEALTERNATEPATH "/var/tmp"
998 +/* Easier conversions: rtl_uString to rtl_String */
999 +static rtl_String *
1000 +ustr_to_str( rtl_uString *pStr )
1002 + rtl_String *pOut = NULL;
1004 + rtl_uString2String( &pOut, rtl_uString_getStr( pStr ),
1005 + rtl_uString_getLength( pStr ), osl_getThreadTextEncoding(), OUSTRING_TO_OSTRING_CVTFLAGS );
1007 + return pOut;
1010 +/* Easier conversions: char * to rtl_uString */
1011 +static rtl_uString *
1012 +charp_to_ustr( const char *pStr )
1014 + rtl_uString *pOut = NULL;
1016 + rtl_string2UString( &pOut, pStr, strlen( pStr ), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
1018 + return pOut;
1021 +/* Easier debugging of rtl_uString values. */
1022 +#if OSL_DEBUG_LEVEL > 0
1023 +static void
1024 +ustr_debug( const char *pMessage, rtl_uString *pStr )
1026 + rtl_String *pOut = ustr_to_str( pStr );
1028 + fprintf( stderr, "%s: %s\n", pMessage, rtl_string_getStr( pOut ) );
1030 + rtl_string_release( pOut );
1031 + return;
1033 +#else
1034 +#define ustr_debug( a, b ) {}
1035 +#endif
1037 +/* Path of the application. */
1038 +static rtl_uString *
1039 +get_app_path( const char *pAppExec )
1041 + char pRealPath[PATH_MAX];
1042 + rtl_uString *pResult;
1044 + char *pPath = strdup( pAppExec );
1045 + pPath = dirname( pPath );
1047 + realpath( pPath, pRealPath );
1048 + pResult = charp_to_ustr( pRealPath );
1049 + free( pPath );
1051 + return pResult;
1054 +/* Compute the OOo md5 hash from 'pText' */
1055 +static rtl_uString *
1056 +get_md5hash( rtl_uString *pText )
1058 + rtl_uString *pResult = NULL;
1059 + sal_Int32 nCapacity = 100;
1061 + if ( !pText )
1062 + return NULL;
1064 + unsigned char *pData = (unsigned char *)rtl_uString_getStr( pText );
1065 + sal_uInt32 nSize = rtl_uString_getLength( pText ) * sizeof( sal_Unicode );
1066 + if ( !pData )
1067 + return NULL;
1069 + rtlDigest digest = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
1070 + if ( digest <= 0 )
1071 + return NULL;
1073 + sal_uInt32 md5_key_len = rtl_digest_queryLength( digest );
1074 + sal_uInt8 *md5_buf = (sal_uInt8 *)calloc( md5_key_len, sizeof( sal_uInt8 ) );
1076 + rtl_digest_init( digest, pData , nSize );
1077 + rtl_digest_update( digest, pData, nSize );
1078 + rtl_digest_get( digest, md5_buf, md5_key_len );
1079 + rtl_digest_destroy( digest );
1081 + /* create hex-value string from the MD5 value to keep
1082 + the string size minimal */
1083 + rtl_uString_new_WithLength( &pResult, nCapacity );
1084 + sal_uInt32 i = 0;
1085 + for ( ; i < md5_key_len; ++i )
1087 + char val[3];
1088 + snprintf( val, 3, "%x", md5_buf[i] ); /* sic! we ignore some of the 0's */
1090 + rtl_uStringbuffer_insert_ascii( &pResult, &nCapacity, rtl_uString_getLength( pResult ),
1091 + val, strlen( val ) );
1094 + /* cleanup */
1095 + free( md5_buf );
1097 + return pResult;
1100 +/* Construct the pipe name */
1101 +static rtl_uString *
1102 +get_pipe_path( rtl_uString *pAppPath )
1104 + rtl_uString *pPath = NULL, *pTmp = NULL, *pUserInstallation = NULL;
1105 + rtl_uString *pResult = NULL;
1107 + /* setup bootstrap filename */
1108 + rtl_uString_newFromAscii( &pPath, "file://" );
1109 + rtl_uString_newConcat( &pPath, pPath, pAppPath );
1110 + rtl_uString_newFromAscii( &pTmp, "/" );
1111 + rtl_uString_newConcat( &pPath, pPath, pTmp );
1112 + rtl_uString_newFromAscii( &pTmp, SAL_CONFIGFILE( "bootstrap" ) );
1113 + rtl_uString_newConcat( &pPath, pPath, pTmp );
1115 + ustr_debug( "bootstap", pPath );
1117 + /* read userinstallation value */
1118 + rtlBootstrapHandle handle = rtl_bootstrap_args_open( pPath );
1120 + rtl_uString_newFromAscii( &pTmp, "UserInstallation" );
1121 + rtl_bootstrap_get_from_handle( handle, pTmp, &pUserInstallation, NULL );
1123 + rtl_bootstrap_args_close( handle );
1125 + /* create the pipe name */
1126 + ustr_debug( "user installation", pUserInstallation );
1127 + rtl_uString *pMd5hash = get_md5hash( pUserInstallation );
1128 + if ( !pMd5hash )
1129 + rtl_uString_new( &pMd5hash );
1131 + if ( access( PIPEDEFAULTPATH, R_OK|W_OK ) == 0 )
1132 + rtl_uString_newFromAscii( &pResult, PIPEDEFAULTPATH );
1133 + else
1134 + rtl_uString_newFromAscii( &pResult, PIPEALTERNATEPATH );
1136 + rtl_uString_newFromAscii( &pTmp, "/OSL_PIPE_" );
1137 + rtl_uString_newConcat( &pResult, pResult, pTmp );
1139 + sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
1140 + rtl_ustr_valueOfInt32( pUnicode, (int)getuid(), 10 );
1141 + rtl_uString_newFromStr( &pTmp, pUnicode );
1142 + rtl_uString_newConcat( &pResult, pResult, pTmp );
1144 + rtl_uString_newFromAscii( &pTmp, "_SingleOfficeIPC_" );
1145 + rtl_uString_newConcat( &pResult, pResult, pTmp );
1147 + rtl_uString_newConcat( &pResult, pResult, pMd5hash );
1149 + ustr_debug( "result", pResult );
1151 + /* cleanup */
1152 + rtl_uString_release( pPath );
1153 + rtl_uString_release( pTmp );
1154 + rtl_uString_release( pUserInstallation );
1156 + return pResult;
1159 +/* Get fd of the pipe of the already running OOo. */
1160 +static int
1161 +connect_pipe( rtl_uString *pPipePath )
1163 + int fd;
1164 + size_t len;
1165 + struct sockaddr_un addr;
1167 + rtl_String *pPipeStr = ustr_to_str( pPipePath );
1169 + memset( &addr, 0, sizeof( addr ) );
1171 + if ( ( fd = socket( AF_UNIX, SOCK_STREAM, 0 ) ) < 0 )
1172 + return fd;
1174 + fcntl( fd, F_SETFD, FD_CLOEXEC );
1176 + addr.sun_family = AF_UNIX;
1177 + strncpy( addr.sun_path, rtl_string_getStr( pPipeStr ), sizeof( addr.sun_path ) );
1178 + rtl_string_release( pPipeStr );
1180 +/* cut / paste from osl's pipe.c */
1181 +#if defined(FREEBSD)
1182 + len = SUN_LEN( &addr );
1183 +#else
1184 + len = sizeof( addr );
1185 +#endif
1187 + if ( connect( fd, (struct sockaddr *)&addr, len ) < 0 )
1188 + return -1;
1190 + return fd;
1193 +/* Send args to the OOo instance (using the 'fd' file descriptor) */
1194 +static sal_Bool
1195 +send_args( int fd )
1197 + rtl_uString *pBuffer = NULL, *pTmp = NULL;
1198 + sal_Int32 nCapacity = 100;
1199 + rtl_String *pOut = NULL;
1200 + sal_Bool bResult;
1201 + size_t nLen;
1203 + rtl_uString_new_WithLength( &pBuffer, nCapacity );
1204 + rtl_uString_new( &pTmp );
1206 + sal_uInt32 nArg;
1207 + sal_uInt32 nArgCount = osl_getCommandArgCount();
1208 + for ( nArg = 0; nArg < nArgCount; ++nArg )
1210 + osl_getCommandArg( nArg, &pTmp );
1212 + rtl_uStringbuffer_insert( &pBuffer, &nCapacity,
1213 + rtl_uString_getLength( pBuffer ),
1214 + rtl_uString_getStr( pTmp ),
1215 + rtl_uString_getLength( pTmp ) );
1217 + rtl_uStringbuffer_insert_ascii( &pBuffer, &nCapacity,
1218 + rtl_uString_getLength( pBuffer ),
1219 + "|", 1 );
1222 + ustr_debug( "Pass args", pBuffer );
1224 + pOut = ustr_to_str( pBuffer );
1226 + nLen = rtl_string_getLength( pOut ) + 1;
1227 + bResult = ( write( fd, rtl_string_getStr( pOut ), nLen ) == nLen );
1229 + /* cleanup */
1230 + rtl_uString_release( pBuffer );
1231 + rtl_uString_release( pTmp );
1232 + rtl_string_release( pOut );
1234 + return bResult;
1237 +/* Load the splash bitmap. */
1238 +static void
1239 +load_splash_image( rtl_uString *pImagePath )
1241 + rtl_uString *pPath = NULL, *pBitmaps = NULL, *pTmp = NULL;
1242 + rtl_uString *pToken = NULL, *pFilename = NULL;
1244 + sal_Int32 nIndex = 0;
1246 + /* setup values */
1247 + rtl_uString_newFromString( &pPath, pImagePath );
1248 + rtl_uString_newFromAscii( &pTmp, "/" );
1249 + rtl_uString_newConcat( &pPath, pPath, pTmp );
1251 + rtl_uString_newFromAscii( &pBitmaps, INTRO_BITMAP_STRINGLIST );
1252 + rtl_uString_newFromAscii( &pTmp, ",intro.bmp" );
1253 + rtl_uString_newConcat( &pBitmaps, pBitmaps, pTmp );
1255 + /* try all the bitmaps from INTRO_BITMAP_STRINGLIST
1256 + (and the intro.bmp fallback) */
1257 + while ( nIndex >= 0 )
1259 + nIndex = rtl_uString_getToken( &pToken, pBitmaps, 0, ',', nIndex );
1260 + rtl_uString_newConcat( &pFilename, pPath, pToken );
1262 + if ( rtl_uString_getLength( pToken ) > 0 )
1264 + rtl_String *pFilenameStr = ustr_to_str( pFilename );
1265 + sal_Bool bLoaded = splash_load_bmp( rtl_string_getStr( pFilenameStr ) );
1266 + rtl_string_release( pFilenameStr );
1268 + if ( bLoaded )
1269 + break;
1273 + /* cleanup */
1274 + rtl_uString_release( pPath );
1275 + rtl_uString_release( pBitmaps );
1276 + rtl_uString_release( pTmp );
1277 + rtl_uString_release( pToken );
1278 + rtl_uString_release( pFilename );
1281 +/* Fill 'array' with values of the key 'name'.
1282 + Its value is a comma delimited list of integers */
1283 +static void
1284 +get_bootstrap_value( int *array, int size, rtlBootstrapHandle handle, const char *name )
1286 + rtl_uString *pKey = NULL, *pValue = NULL;
1287 + sal_Int32 nIndex = 0;
1288 + int i = 0;
1290 + /* get the value from the ini file */
1291 + rtl_uString_newFromAscii( &pKey, name );
1292 + rtl_bootstrap_get_from_handle( handle, pKey, &pValue, NULL );
1294 + /* the value is several numbers delimited by ',' - parse it */
1295 + if ( rtl_uString_getLength( pValue ) > 0 )
1297 + rtl_uString *pToken = NULL;
1299 + for ( ; ( nIndex >= 0 ) && ( i < size ); ++i )
1301 + nIndex = rtl_uString_getToken( &pToken, pValue, 0, ',', nIndex );
1302 + array[i] = rtl_ustr_toInt32( rtl_uString_getStr( pToken ), 10 );
1305 + rtl_uString_release( pToken );
1308 + /* cleanup */
1309 + rtl_uString_release( pKey );
1310 + rtl_uString_release( pValue );
1313 +/* Load the colors and size of the splash. */
1314 +static void
1315 +load_splash_defaults( rtl_uString *pAppPath, sal_Bool *pInhibitSplash )
1317 + rtl_uString *pSettings = NULL, *pTmp = NULL;
1318 + rtlBootstrapHandle handle;
1320 + /* costruct the sofficerc file location */
1321 + rtl_uString_newFromAscii( &pSettings, "file://" );
1322 + rtl_uString_newConcat( &pSettings, pSettings, pAppPath );
1323 + rtl_uString_newFromAscii( &pTmp, "/" );
1324 + rtl_uString_newConcat( &pSettings, pSettings, pTmp );
1325 + rtl_uString_newFromAscii( &pTmp, SAL_CONFIGFILE( "soffice" ) );
1326 + rtl_uString_newConcat( &pSettings, pSettings, pTmp );
1328 + /* use it as the bootstrap file */
1329 + handle = rtl_bootstrap_args_open( pSettings );
1331 + int logo[1] = { -1 },
1332 + bar[3] = { -1, -1, -1 },
1333 + frame[3] = { -1, -1, -1 },
1334 + pos[2] = { -1, -1 },
1335 + size[2] = { -1, -1 };
1337 + /* get the values */
1338 + get_bootstrap_value( logo, 1, handle, "Logo" );
1339 + get_bootstrap_value( bar, 3, handle, "ProgressBarColor" );
1340 + get_bootstrap_value( frame, 3, handle, "ProgressFrameColor" );
1341 + get_bootstrap_value( pos, 2, handle, "ProgressPosition" );
1342 + get_bootstrap_value( size, 2, handle, "ProgressSize" );
1344 + if ( logo[0] == 0 )
1345 + *pInhibitSplash = sal_True;
1347 + splash_setup( bar, frame, pos[0], pos[1], size[0], size[1] );
1349 + /* cleanup */
1350 + rtl_bootstrap_args_close( handle );
1351 + rtl_uString_release( pSettings );
1352 + rtl_uString_release( pTmp );
1355 +#define BUFFER_LEN 255
1357 +/* Read the percent to show in splash. */
1358 +static sal_Bool
1359 +read_percent( int status_fd, int *pPercent )
1361 + static char pBuffer[BUFFER_LEN + 1];
1362 + static char *pNext = pBuffer;
1363 + static size_t nRead = 0;
1365 + char *pBegin;
1366 + char *pIter;
1368 + /* from the last call */
1369 + int nNotProcessed = nRead - ( pNext - pBuffer );
1370 + if ( nNotProcessed >= BUFFER_LEN )
1371 + return sal_False;
1373 + memmove( pBuffer, pNext, nNotProcessed );
1375 + /* read data */
1376 + nRead = read( status_fd, pBuffer + nNotProcessed, BUFFER_LEN - nNotProcessed );
1377 + if ( nRead < 0 )
1378 + return sal_False;
1380 + nRead += nNotProcessed;
1381 + pBuffer[nRead] = '\0';
1383 + /* skip old data */
1384 + pBegin = pBuffer;
1385 + pNext = pBuffer;
1386 + for ( pIter = pBuffer; *pIter; ++pIter )
1387 + if ( *pIter == '\n' )
1389 + pBegin = pNext;
1390 + pNext = pIter + 1;
1393 +#if OSL_DEBUG_LEVEL > 0
1394 + fprintf( stderr, "Got status: %s\n", pBegin );
1395 +#endif
1396 + if ( !strncasecmp( pBegin, "end", 3 ) )
1397 + return sal_False;
1398 + else if ( sscanf( pBegin, "%d%%", pPercent ) )
1399 + return sal_True;
1401 + return sal_False;
1404 +/* Periodically update the splash & the percent acconding to what
1405 + status_fd says */
1406 +static void
1407 +show_splash( int status_fd )
1409 + int nRetval;
1410 + struct pollfd aPfd;
1412 + int nPercent = 0;
1413 + sal_Bool bFinish = sal_False;
1415 + /* we want to watch status_fd */
1416 + aPfd.fd = status_fd;
1417 + aPfd.events = POLLIN;
1419 +#if OSL_DEBUG_LEVEL > 0
1420 + fprintf( stderr, "Starting main loop, status fd: %d\n", status_fd );
1421 +#endif
1423 + /* main loop */
1424 + do {
1425 + splash_draw_progress( nPercent );
1427 + /* read from pipe if data available */
1428 + nRetval = poll( &aPfd, 1, 50 );
1429 + if ( nRetval > 0 )
1430 + bFinish = !read_percent( status_fd, &nPercent );
1431 + else if ( nRetval < 0 )
1432 + bFinish = sal_True;
1433 + } while ( !bFinish );
1436 +/* Simple system check. */
1437 +static void
1438 +system_checks( void )
1440 +#ifdef LINUX
1441 + struct stat buf;
1443 + /* check proc is mounted - lots of things fail otherwise */
1444 + if ( stat( "/proc/version", &buf ) != 0 )
1446 + fprintf( stderr, "ERROR: /proc not mounted - OO.o is unlikely to work well if at all" );
1447 + exit( 1 );
1449 +#endif
1452 +/* Start the OOo application */
1453 +static sal_Bool
1454 +fork_app( rtl_uString *pAppPath, int *status_fd )
1456 + rtl_uString *pApp = NULL, *pTmp = NULL, *pArg = NULL;
1457 + rtl_uString **ppArgs;
1458 + sal_uInt32 nArgs, i;
1460 + oslProcess aProcess;
1461 + oslProcessError nError;
1462 + int status_pipe[2];
1464 + system_checks();
1466 + /* application name */
1467 + rtl_uString_newFromAscii( &pApp, "file://" );
1468 + rtl_uString_newConcat( &pApp, pApp, pAppPath );
1469 + rtl_uString_newFromAscii( &pTmp, "/soffice.bin" );
1470 + rtl_uString_newConcat( &pApp, pApp, pTmp );
1472 + rtl_uString_new( &pTmp );
1474 + /* copy args */
1475 + nArgs = osl_getCommandArgCount();
1476 + ppArgs = (rtl_uString **)calloc( nArgs + 1, sizeof( rtl_uString* ) );
1477 + for ( i = 0; i < nArgs; ++i )
1479 + ppArgs[i] = NULL;
1480 + osl_getCommandArg( i, &pTmp );
1482 + rtl_uString_newFromString( &(ppArgs[i]), pTmp );
1485 + /* create pipe */
1486 + if ( pipe( status_pipe ) < 0 )
1488 + fprintf( stderr, "ERROR: no file handles\n");
1489 + exit( 1 );
1492 + /* add the pipe arg */
1493 + sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
1494 + rtl_ustr_valueOfInt32( pUnicode, status_pipe[1], 10 );
1496 + rtl_uString_newFromAscii( &pArg, "-splash-pipe=" );
1497 + rtl_uString_newFromStr( &pTmp, pUnicode );
1498 + rtl_uString_newConcat( &pArg, pArg, pTmp );
1500 + ppArgs[nArgs] = NULL;
1501 + rtl_uString_newFromString( &(ppArgs[nArgs]), pArg );
1502 + ++nArgs;
1504 + /* start the OOo process */
1505 + nError = osl_executeProcess( pApp, ppArgs, nArgs,
1506 + osl_Process_DETACHED | osl_Process_NORMAL,
1507 + NULL,
1508 + NULL,
1509 + NULL, 0,
1510 + &aProcess );
1512 + *status_fd = status_pipe[0];
1513 + close( status_pipe[1] );
1515 + if ( nError != osl_Process_E_None )
1517 + fprintf( stderr, "ERROR %d forking process", nError );
1518 + ustr_debug( "", pApp );
1519 + return sal_False;
1522 + return sal_True;
1525 +/* Check if 'pArg' is -pCmpWith or --pCmpWith */
1526 +static sal_Bool
1527 +arg_check( rtl_uString *pArg, const char *pCmpWith )
1529 + sal_Unicode *pUnicode = rtl_uString_getStr( pArg );
1531 + if ( pUnicode[0] == (sal_Unicode)'-' )
1532 + pUnicode++;
1533 + else
1534 + return sal_False;
1536 + /* tolerate -- prefixes etc. */
1537 + if ( pUnicode[0] == (sal_Unicode)'-' )
1538 + pUnicode++;
1540 + return !rtl_ustr_ascii_compare( pUnicode, pCmpWith );
1543 +static const char *ppInhibit[] = {
1544 + "nologo", "headless", "invisible", "help", "h", "?", "minimized",
1545 + NULL };
1546 +static const char *ppTwoArgs[] = {
1547 + "pt", "display",
1548 + NULL };
1550 +/* Read command line parameters and return whether we display the splash. */
1551 +static sal_Bool
1552 +get_inhibit_splash()
1554 + rtl_uString *pTmp = NULL;
1555 + sal_Bool bSkipNextArg = sal_False;
1556 + const char **ppIter;
1558 + rtl_uString_new( &pTmp );
1560 + sal_uInt32 nArg;
1561 + sal_uInt32 nArgCount = osl_getCommandArgCount();
1562 + for ( nArg = 0; nArg < nArgCount; ++nArg )
1564 + if ( bSkipNextArg )
1566 + bSkipNextArg = sal_False;
1567 + continue;
1570 + osl_getCommandArg( nArg, &pTmp );
1572 + /* check for inhibit splash params */
1573 + for ( ppIter = ppInhibit; *ppIter; ++ppIter )
1575 + if ( arg_check( pTmp, *ppIter ) )
1577 + rtl_uString_release( pTmp );
1578 + return sal_True;
1581 + /* check for 2 arguments params */
1582 + for ( ppIter = ppTwoArgs; *ppIter; ++ppIter )
1584 + if ( arg_check( pTmp, *ppIter ) )
1586 + bSkipNextArg = sal_True;
1587 + break;
1592 + /* cleanup */
1593 + rtl_uString_release( pTmp );
1595 + return sal_False;
1598 +SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
1600 + int fd = 0, status_fd = 0;
1601 + sal_Bool bInhibitSplash;
1602 + sal_Bool bSentArgs = sal_False;
1603 + rtl_uString *pAppPath = NULL;
1604 + rtl_uString *pPipePath = NULL;
1606 + /* turn SIGPIPE into an error */
1607 + signal( SIGPIPE, SIG_IGN );
1609 + bInhibitSplash = get_inhibit_splash();
1611 + pAppPath = get_app_path( argv[0] );
1612 + if ( !pAppPath )
1614 + fprintf( stderr, "ERROR: Can't read app link\n" );
1615 + exit( 1 );
1617 + ustr_debug( "App path", pAppPath );
1619 + pPipePath = get_pipe_path( pAppPath );
1621 + if ( ( fd = connect_pipe( pPipePath ) ) >= 0 )
1622 + bSentArgs = send_args( fd );
1623 +#if OSL_DEBUG_LEVEL > 0
1624 + else
1625 + ustr_debug( "Failed to connect to pipe", pPipePath );
1626 +#endif
1628 + if ( !bSentArgs )
1630 + if ( !fork_app( pAppPath, &status_fd ) )
1631 + return 1;
1633 + if ( !bInhibitSplash )
1635 + load_splash_image( pAppPath );
1636 + load_splash_defaults( pAppPath, &bInhibitSplash );
1639 + if ( !bInhibitSplash && splash_create_window( argc, argv ) )
1641 + splash_draw_progress( 0 );
1642 + show_splash( status_fd );
1643 + splash_close_window();
1647 + /* cleanup */
1648 + rtl_uString_release( pAppPath );
1649 + rtl_uString_release( pPipePath );
1651 + close( fd );
1652 + close( status_fd );
1654 + return 0;
1656 diff --git desktop/unx/splash/exports.map desktop/unx/splash/exports.map
1657 new file mode 100644
1658 index 0000000..ba501f9
1659 --- /dev/null
1660 +++ desktop/unx/splash/exports.map
1661 @@ -0,0 +1,10 @@
1662 +UDK_3_0_0 {
1663 + global:
1664 + GetVersionInfo;
1665 + component_getImplementationEnvironment;
1666 + component_getFactory;
1667 + component_writeInfo;
1669 + local:
1670 + *;
1672 diff --git desktop/unx/splash/makefile.mk desktop/unx/splash/makefile.mk
1673 new file mode 100644
1674 index 0000000..874b81b
1675 --- /dev/null
1676 +++ desktop/unx/splash/makefile.mk
1677 @@ -0,0 +1,73 @@
1678 +#*************************************************************************
1680 +# OpenOffice.org - a multi-platform office productivity suite
1682 +# $RCSfile$
1684 +# $Revision: 7305 $
1686 +# last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
1688 +# The Contents of this file are made available subject to
1689 +# the terms of GNU Lesser General Public License Version 2.1.
1692 +# GNU Lesser General Public License Version 2.1
1693 +# =============================================
1694 +# Copyright 2005 by Sun Microsystems, Inc.
1695 +# 901 San Antonio Road, Palo Alto, CA 94303, USA
1697 +# This library is free software; you can redistribute it and/or
1698 +# modify it under the terms of the GNU Lesser General Public
1699 +# License version 2.1, as published by the Free Software Foundation.
1701 +# This library is distributed in the hope that it will be useful,
1702 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
1703 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1704 +# Lesser General Public License for more details.
1706 +# You should have received a copy of the GNU Lesser General Public
1707 +# License along with this library; if not, write to the Free Software
1708 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1709 +# MA 02111-1307 USA
1711 +#*************************************************************************
1713 +PRJ=..$/..
1715 +PRJNAME=desktop
1716 +TARGET=spl_unx
1717 +LIBTARGET=NO
1719 +ENABLE_EXCEPTIONS=TRUE
1721 +# --- Settings -----------------------------------------------------
1723 +.INCLUDE : settings.mk
1725 +# --- Files --------------------------------------------------------
1727 +SLOFILES = $(SLO)$/unxsplash.obj \
1728 + $(SLO)$/services_unxsplash.obj
1730 +SHL1DEPN= makefile.mk
1731 +SHL1OBJS= $(SLOFILES)
1734 +SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
1735 +SHL1IMPLIB=i$(TARGET)
1737 +SHL1VERSIONMAP=exports.map
1738 +SHL1DEF=$(MISC)$/$(SHL1TARGET).def
1739 +DEF1NAME=$(SHL1TARGET)
1741 +SHL1STDLIBS= \
1742 + $(VOSLIB) \
1743 + $(CPPUHELPERLIB) \
1744 + $(CPPULIB) \
1745 + $(SALLIB)
1747 +# --- Targets ------------------------------------------------------
1749 +.INCLUDE : target.mk
1751 diff --git desktop/unx/splash/services_unxsplash.cxx desktop/unx/splash/services_unxsplash.cxx
1752 new file mode 100644
1753 index 0000000..b762fa5
1754 --- /dev/null
1755 +++ desktop/unx/splash/services_unxsplash.cxx
1756 @@ -0,0 +1,177 @@
1757 +/*************************************************************************
1759 + * OpenOffice.org - a multi-platform office productivity suite
1761 + * $RCSfile$
1763 + * $Revision: 7305 $
1765 + * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
1767 + * The Contents of this file are made available subject to
1768 + * the terms of GNU Lesser General Public License Version 2.1.
1771 + * GNU Lesser General Public License Version 2.1
1772 + * =============================================
1773 + * Copyright 2005 by Sun Microsystems, Inc.
1774 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1776 + * This library is free software; you can redistribute it and/or
1777 + * modify it under the terms of the GNU Lesser General Public
1778 + * License version 2.1, as published by the Free Software Foundation.
1780 + * This library is distributed in the hope that it will be useful,
1781 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1782 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1783 + * Lesser General Public License for more details.
1785 + * You should have received a copy of the GNU Lesser General Public
1786 + * License along with this library; if not, write to the Free Software
1787 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1788 + * MA 02111-1307 USA
1790 + ************************************************************************/
1792 +#ifndef _COM_SUN_STAR_BEANS_NAMEDVALUE_HPP_
1793 +#include <com/sun/star/beans/NamedValue.hpp>
1794 +#endif
1795 +#ifndef _COM_SUN_STAR_REGISTRY_XREGISTRYKEY_HPP_
1796 +#include <com/sun/star/registry/XRegistryKey.hpp>
1797 +#endif
1798 +#ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
1799 +#include <com/sun/star/util/Date.hpp>
1800 +#endif
1802 +#ifndef _UNO_ENVIRONMENT_H_
1803 +#include <uno/environment.h>
1804 +#endif
1805 +#ifndef _CPPUHELPER_FACTORY_HXX_
1806 +#include <cppuhelper/factory.hxx>
1807 +#endif
1808 +#ifndef _UTL_CONFIGMGR_HXX_
1809 +#include <unotools/configmgr.hxx>
1810 +#endif
1812 +#include <string.h>
1814 +#include "unxsplash.hxx"
1816 +using namespace rtl;
1817 +using namespace ::com::sun::star::uno;
1818 +using namespace ::com::sun::star::lang;
1819 +using namespace ::com::sun::star::beans;
1820 +using namespace ::com::sun::star::registry;
1821 +using namespace ::desktop;
1823 +static const char* pServices[] =
1825 + UnxSplashScreen::serviceName,
1826 + NULL
1829 +static const char* pImplementations[] =
1831 + UnxSplashScreen::implementationName,
1832 + NULL
1835 +typedef Reference<XInterface>(* fProvider)( const Reference<XMultiServiceFactory>& );
1837 +static const fProvider pInstanceProviders[] =
1839 + UnxSplashScreen::getInstance,
1840 + NULL
1844 +static const char** pSupportedServices[] =
1846 + UnxSplashScreen::interfaces,
1847 + NULL
1850 +static Sequence<OUString>
1851 +getSupportedServiceNames( int p ) {
1852 + const char **names = pSupportedServices[p];
1853 + Sequence<OUString> aSeq;
1854 + for ( int i = 0; names[i] != NULL; i++ )
1856 + aSeq.realloc( i+1 );
1857 + aSeq[i] = OUString::createFromAscii( names[i] );
1859 + return aSeq;
1862 +extern "C"
1864 +void SAL_CALL
1865 +component_getImplementationEnvironment(
1866 + const sal_Char** ppEnvironmentTypeName,
1867 + uno_Environment** ppEnvironment )
1869 + *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
1872 +sal_Bool SAL_CALL
1873 +component_writeInfo(
1874 + void* pServiceManager,
1875 + void* pRegistryKey )
1877 + Reference<XMultiServiceFactory> xMan(
1878 + reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
1879 + Reference<XRegistryKey> xKey(
1880 + reinterpret_cast< XRegistryKey* >( pRegistryKey ) ) ;
1882 + // iterate over service names and register them...
1883 + OUString aImpl;
1884 + const char* pServiceName = NULL;
1885 + const char* pImplName = NULL;
1886 + for ( int i = 0; ( pServices[i] != NULL ) && ( pImplementations[i] != NULL ); i++ )
1888 + pServiceName= pServices[i];
1889 + pImplName = pImplementations[i];
1890 + aImpl = OUString::createFromAscii( "/" )
1891 + + OUString::createFromAscii( pImplName )
1892 + + OUString::createFromAscii( "/UNO/SERVICES" );
1893 + Reference<XRegistryKey> xNewKey = xKey->createKey( aImpl );
1894 + xNewKey->createKey( OUString::createFromAscii( pServiceName ) );
1896 + return sal_True;
1899 +void* SAL_CALL
1900 +component_getFactory(
1901 + const sal_Char* pImplementationName,
1902 + void* pServiceManager,
1903 + void* pRegistryKey )
1905 + // Set default return value for this operation - if it failed.
1906 + if ( pImplementationName && pServiceManager )
1908 + Reference< XSingleServiceFactory > xFactory;
1909 + Reference< XMultiServiceFactory > xServiceManager(
1910 + reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
1912 + // search implementation
1913 + for ( int i = 0; ( pImplementations[i] != NULL ); i++ )
1915 + if ( strcmp( pImplementations[i], pImplementationName ) == 0 )
1917 + // found implementation
1918 + xFactory = Reference<XSingleServiceFactory>( cppu::createSingleFactory(
1919 + xServiceManager, OUString::createFromAscii( pImplementationName ),
1920 + pInstanceProviders[i], getSupportedServiceNames( i ) ) );
1921 + if ( xFactory.is() )
1923 + // Factory is valid - service was found.
1924 + xFactory->acquire();
1925 + return xFactory.get();
1931 + return NULL;
1933 +} // extern "C"
1934 diff --git desktop/unx/splash/unxsplash.cxx desktop/unx/splash/unxsplash.cxx
1935 new file mode 100644
1936 index 0000000..ca20334
1937 --- /dev/null
1938 +++ desktop/unx/splash/unxsplash.cxx
1939 @@ -0,0 +1,192 @@
1940 +/*************************************************************************
1942 + * OpenOffice.org - a multi-platform office productivity suite
1944 + * $RCSfile$
1946 + * $Revision: 7305 $
1948 + * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
1950 + * The Contents of this file are made available subject to
1951 + * the terms of GNU Lesser General Public License Version 2.1.
1954 + * GNU Lesser General Public License Version 2.1
1955 + * =============================================
1956 + * Copyright 2005 by Sun Microsystems, Inc.
1957 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
1959 + * This library is free software; you can redistribute it and/or
1960 + * modify it under the terms of the GNU Lesser General Public
1961 + * License version 2.1, as published by the Free Software Foundation.
1963 + * This library is distributed in the hope that it will be useful,
1964 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1965 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1966 + * Lesser General Public License for more details.
1968 + * You should have received a copy of the GNU Lesser General Public
1969 + * License along with this library; if not, write to the Free Software
1970 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
1971 + * MA 02111-1307 USA
1973 + ************************************************************************/
1975 +#include "unxsplash.hxx"
1976 +#include <stdio.h>
1977 +#ifndef _UTL_BOOTSTRAP_HXX
1978 +#include <unotools/bootstrap.hxx>
1979 +#endif
1980 +#ifndef _VOS_PROCESS_HXX_
1981 +#include <vos/process.hxx>
1982 +#endif
1983 +#ifndef _URLOBJ_HXX
1984 +#include <tools/urlobj.hxx>
1985 +#endif
1986 +#ifndef _STREAM_HXX
1987 +#include <tools/stream.hxx>
1988 +#endif
1989 +#ifndef _SFX_HRC
1990 +#include <sfx2/sfx.hrc>
1991 +#endif
1993 +#include <com/sun/star/registry/XRegistryKey.hpp>
1994 +#include <rtl/logfile.hxx>
1995 +#include <rtl/ustrbuf.hxx>
1996 +#include <rtl/math.hxx>
1998 +#define PIPE_ARG "-splash-pipe="
2000 +using namespace ::rtl;
2001 +using namespace ::com::sun::star::registry;
2003 +namespace desktop
2006 +UnxSplashScreen::UnxSplashScreen( const Reference< XMultiServiceFactory >& rSMgr )
2007 + : m_rFactory( rSMgr ),
2008 + m_pOutFd( NULL )
2012 +UnxSplashScreen::~UnxSplashScreen()
2014 +#if OSL_DEBUG_LEVEL > 1
2015 + fprintf( stderr, "UnxSplashScreen::~UnxSplashScreen()\n" );
2016 +#endif
2018 + if ( m_pOutFd )
2020 + fclose( m_pOutFd );
2021 + m_pOutFd = NULL;
2025 +void SAL_CALL UnxSplashScreen::start( const OUString& /*aText*/, sal_Int32 /*nRange*/ )
2026 + throw ( RuntimeException )
2030 +void SAL_CALL UnxSplashScreen::end()
2031 + throw ( RuntimeException )
2033 +#if OSL_DEBUG_LEVEL > 1
2034 + fprintf( stderr, "UnxSplashScreen::end()\n" );
2035 +#endif
2037 + fprintf( m_pOutFd, "end\n" );
2038 + fflush( m_pOutFd );
2041 +void SAL_CALL UnxSplashScreen::reset()
2042 + throw ( RuntimeException )
2044 + // TODO?
2047 +void SAL_CALL UnxSplashScreen::setText( const OUString& /*aText*/ )
2048 + throw ( RuntimeException )
2050 + // TODO?
2053 +void SAL_CALL UnxSplashScreen::setValue( sal_Int32 nValue )
2054 + throw ( RuntimeException )
2056 + if ( m_pOutFd )
2058 + fprintf( m_pOutFd, "%d%%\n", nValue );
2059 + fflush( m_pOutFd );
2063 +// XInitialize
2064 +void SAL_CALL
2065 +UnxSplashScreen::initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments )
2066 + throw ( RuntimeException )
2068 + ::vos::OStartupInfo aInfo;
2069 + for ( sal_uInt32 i = 0; i < aInfo.getCommandArgCount(); i++ )
2071 + rtl::OUString aArg;
2072 + if ( aInfo.getCommandArg( i, aArg ) )
2073 + break;
2074 + if ( aArg.matchIgnoreAsciiCaseAsciiL( PIPE_ARG, sizeof( PIPE_ARG ) - 1, 0 ) )
2076 + OUString aNum = aArg.copy( sizeof( PIPE_ARG ) - 1 );
2077 + int fd = aNum.toInt32();
2078 + m_pOutFd = fdopen( fd, "w" );
2079 +#if OSL_DEBUG_LEVEL > 1
2080 + fprintf( stderr, "Got argument '-splash-pipe=%d ('%s') (%p)\n",
2081 + fd, (const sal_Char *)rtl::OUStringToOString( aNum, RTL_TEXTENCODING_UTF8 ),
2082 + m_pOutFd );
2083 +#endif
2088 +// get service instance...
2089 +UnxSplashScreen *UnxSplashScreen::m_pINSTANCE = NULL;
2090 +osl::Mutex UnxSplashScreen::m_aMutex;
2092 +Reference< XInterface > UnxSplashScreen::getInstance( const Reference< XMultiServiceFactory >& rSMgr )
2094 + if ( m_pINSTANCE == NULL )
2096 + osl::MutexGuard guard( m_aMutex );
2097 + if ( m_pINSTANCE == NULL )
2098 + return (XComponent*) new UnxSplashScreen( rSMgr );
2101 + return (XComponent*)NULL;
2104 +// static service info...
2105 +const char* UnxSplashScreen::interfaces[] =
2107 + "com.sun.star.task.XStartusIndicator",
2108 + "com.sun.star.lang.XInitialization",
2109 + NULL,
2111 +const sal_Char *UnxSplashScreen::serviceName = "com.sun.star.office.PipeSplashScreen";
2112 +const sal_Char *UnxSplashScreen::implementationName = "com.sun.star.office.comp.PipeSplashScreen";
2113 +const sal_Char *UnxSplashScreen::supportedServiceNames[] = { "com.sun.star.office.PipeSplashScreen", NULL };
2115 +OUString UnxSplashScreen::impl_getImplementationName()
2117 + return OUString::createFromAscii( implementationName );
2120 +Sequence<OUString> UnxSplashScreen::impl_getSupportedServiceNames()
2122 + Sequence<OUString> aSequence;
2123 + for ( int i = 0; supportedServiceNames[i] != NULL; i++ )
2125 + aSequence.realloc( i+1 );
2126 + aSequence[i] = OUString::createFromAscii( supportedServiceNames[i] );
2128 + return aSequence;
2132 diff --git desktop/unx/splash/unxsplash.hxx desktop/unx/splash/unxsplash.hxx
2133 new file mode 100644
2134 index 0000000..5419324
2135 --- /dev/null
2136 +++ desktop/unx/splash/unxsplash.hxx
2137 @@ -0,0 +1,117 @@
2138 +/*************************************************************************
2140 + * OpenOffice.org - a multi-platform office productivity suite
2142 + * $RCSfile$
2144 + * $Revision: 7305 $
2146 + * last change: $Author: jholesovsky $ $Date: 2006-08-04 16:35:41 +0200 (Pá, 04 srp 2006) $
2148 + * The Contents of this file are made available subject to
2149 + * the terms of GNU Lesser General Public License Version 2.1.
2152 + * GNU Lesser General Public License Version 2.1
2153 + * =============================================
2154 + * Copyright 2005 by Sun Microsystems, Inc.
2155 + * 901 San Antonio Road, Palo Alto, CA 94303, USA
2157 + * This library is free software; you can redistribute it and/or
2158 + * modify it under the terms of the GNU Lesser General Public
2159 + * License version 2.1, as published by the Free Software Foundation.
2161 + * This library is distributed in the hope that it will be useful,
2162 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
2163 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2164 + * Lesser General Public License for more details.
2166 + * You should have received a copy of the GNU Lesser General Public
2167 + * License along with this library; if not, write to the Free Software
2168 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
2169 + * MA 02111-1307 USA
2171 + ************************************************************************/
2173 +#include <stdio.h>
2175 +#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
2176 +#include <com/sun/star/lang/XServiceInfo.hpp>
2177 +#endif
2178 +#ifndef _COM_SUN_STAR_UNO_EXCEPTION_HPP_
2179 +#include <com/sun/star/uno/Exception.hpp>
2180 +#endif
2181 +#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
2182 +#include <com/sun/star/uno/Reference.h>
2183 +#endif
2184 +#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
2185 +#include <com/sun/star/lang/XComponent.hpp>
2186 +#endif
2187 +#ifndef _COM_SUN_STAR_TASK_XSTATUSINDICATOR_HPP_
2188 +#include <com/sun/star/task/XStatusIndicator.hpp>
2189 +#endif
2190 +#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
2191 +#include <com/sun/star/lang/XInitialization.hpp>
2192 +#endif
2193 +#ifndef _CPPUHELPER_IMPLBASE2_HXX_
2194 +#include <cppuhelper/implbase2.hxx>
2195 +#endif
2196 +#ifndef _CPPUHELPER_INTERFACECONTAINER_H_
2197 +#include <cppuhelper/interfacecontainer.h>
2198 +#endif
2199 +#include <com/sun/star/lang/XSingleServiceFactory.hpp>
2200 +#include <osl/mutex.hxx>
2201 +#ifndef _RTL_BOOTSTRAP_HXX_
2202 +#include <rtl/bootstrap.hxx>
2203 +#endif
2205 +using namespace ::rtl;
2206 +using namespace ::com::sun::star::uno;
2207 +using namespace ::com::sun::star::lang;
2208 +using namespace ::com::sun::star::task;
2210 +namespace desktop {
2212 +class UnxSplashScreen : public ::cppu::WeakImplHelper2< XStatusIndicator, XInitialization >
2214 +private:
2215 + // don't allow anybody but ourselves to create instances of this class
2216 + UnxSplashScreen( const UnxSplashScreen& );
2217 + UnxSplashScreen( void );
2218 + UnxSplashScreen operator =( const UnxSplashScreen& );
2220 + UnxSplashScreen( const Reference< XMultiServiceFactory >& xFactory );
2222 + virtual ~UnxSplashScreen();
2224 + static UnxSplashScreen *m_pINSTANCE;
2226 + static osl::Mutex m_aMutex;
2227 + Reference< XMultiServiceFactory > m_rFactory;
2229 + FILE *m_pOutFd;
2231 +public:
2232 + static const char* interfaces[];
2233 + static const sal_Char *serviceName;
2234 + static const sal_Char *implementationName;
2235 + static const sal_Char *supportedServiceNames[];
2237 + static Reference< XInterface > getInstance( const Reference < XMultiServiceFactory >& xFactory );
2239 + // static service info
2240 + static OUString impl_getImplementationName();
2241 + static Sequence<OUString> impl_getSupportedServiceNames();
2243 + // XStatusIndicator
2244 + virtual void SAL_CALL start( const OUString& aText, sal_Int32 nRange ) throw ( RuntimeException );
2245 + virtual void SAL_CALL end() throw ( RuntimeException );
2246 + virtual void SAL_CALL reset() throw ( RuntimeException );
2247 + virtual void SAL_CALL setText( const OUString& aText ) throw ( RuntimeException );
2248 + virtual void SAL_CALL setValue( sal_Int32 nValue ) throw ( RuntimeException );
2250 + // XInitialize
2251 + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any>& aArguments ) throw ( RuntimeException );
2255 diff --git scp2/source/ooo/common_brand.scp scp2/source/ooo/common_brand.scp
2256 index 6bccbd8..161de3d 100644
2257 --- scp2/source/ooo/common_brand.scp
2258 +++ scp2/source/ooo/common_brand.scp
2259 @@ -415,6 +415,15 @@ File gid_Brand_File_Bin_Soffice_Bin
2260 Name = "soffice.bin";
2263 +#if defined(UNX)
2264 +File gid_File_Bin_QStart_Bin
2265 + BIN_FILE_BODY;
2266 + Dir = gid_Brand_Dir_Program;
2267 + Styles = (PACKED, PATCH);
2268 + Name = "oosplash.bin";
2269 +End
2270 +#endif
2272 // use this for high detail file open dialog >= 5.1 windows
2273 #ifdef WNT
2274 File gid_Brand_File_Bin_Soffice_Bin_Manifest
2275 diff --git scp2/source/ooo/file_library_ooo.scp scp2/source/ooo/file_library_ooo.scp
2276 index 1a6661a..dbbe327 100644
2277 --- scp2/source/ooo/file_library_ooo.scp
2278 +++ scp2/source/ooo/file_library_ooo.scp
2279 @@ -1346,6 +1346,9 @@ File gid_File_Lib_Spell
2282 STD_UNO_LIB_FILE( gid_File_Lib_Spl, spl)
2283 +#ifdef UNX
2284 +STD_UNO_LIB_FILE( gid_File_Lib_Spl_Unx, spl_unx)
2285 +#endif
2287 SPECIAL_UNO_LIB_FILE(gid_File_Lib_Srtrs1,srtrs1)
2289 --- smoketestoo_native/smoketest.pl
2290 +++ smoketestoo_native/smoketest.pl
2291 @@ -502,7 +502,7 @@ sub doTest {
2293 print "starting office ($INSTSETNAME)\n";
2295 - $Command = "\"$programpath" . "$SOFFICEBIN\" -norestore -nocrashreport macro:///Standard.Global.StartTestWithDefaultOptions";
2296 + $Command = "\"$programpath" . "$SOFFICEBIN\" -no-oosplash -norestore -nocrashreport macro:///Standard.Global.StartTestWithDefaultOptions";
2297 if ( (defined($ENV{OS})) && ($ENV{OS} eq "MACOSX") ) {
2298 $Command = "cd \"$programpath\"; " . $Command;
2300 diff --git solenv/bin/cwscheckapi solenv/bin/cwscheckapi
2301 index fe5ecc1..e43ba12 100755
2302 --- solenv/bin/cwscheckapi
2303 +++ solenv/bin/cwscheckapi
2304 @@ -225,7 +225,7 @@ if [ -n "$WORK_STAMP" ]; then
2308 -PARAM="$PARAM -cmd '$OFFICEBIN -nofirststartwizard -accept=pipe,name=$USER;urp; -norestore -nocrashreport -nolockcheck -enableautomation'"
2309 +PARAM="$PARAM -cmd '$OFFICEBIN -nofirststartwizard -no-oosplash -accept=pipe,name=$USER;urp; -norestore -nocrashreport -nolockcheck -enableautomation'"
2310 PARAM="$PARAM -cs pipe,name=$USER"
2311 PARAM="$PARAM -NoOffice true"
2312 PARAM="$PARAM -SRC_ROOT $SRC_ROOT"
2313 diff --git vcl/inc/vcl/svapp.hxx vcl/inc/vcl/svapp.hxx
2314 index d900862..a324664 100644
2315 --- vcl/inc/vcl/svapp.hxx
2316 +++ vcl/inc/vcl/svapp.hxx
2317 @@ -267,6 +267,7 @@ public:
2318 virtual void DataChanged( const DataChangedEvent& rDCEvt );
2320 virtual void Init();
2321 + virtual void InitFinished();
2322 virtual void DeInit();
2324 static void InitAppRes( const ResId& rResId );
2325 diff --git vcl/source/app/svapp.cxx vcl/source/app/svapp.cxx
2326 index 0c8b1d8..08c9ebd 100644
2327 --- vcl/source/app/svapp.cxx
2328 +++ vcl/source/app/svapp.cxx
2329 @@ -326,6 +326,11 @@ void Application::Init()
2332 // -----------------------------------------------------------------------
2333 +void Application::InitFinished()
2337 +// -----------------------------------------------------------------------
2339 void Application::DeInit()
2341 diff --git vcl/source/window/window.cxx vcl/source/window/window.cxx
2342 index d7cc722..8882c23 100644
2343 --- vcl/source/window/window.cxx
2344 +++ vcl/source/window/window.cxx
2345 @@ -6539,10 +6539,19 @@ void Window::Show( BOOL bVisible, USHORT nFlags )
2346 mpWindowImpl->mpBorderWindow->Show( TRUE, nFlags );
2347 else if ( mpWindowImpl->mbFrame )
2349 - ImplSVData* pSVData = ImplGetSVData();
2350 // #106431#, hide SplashScreen
2351 - if( pSVData->mpIntroWindow && !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
2352 + ImplSVData* pSVData = ImplGetSVData();
2353 + if ( !pSVData->mpIntroWindow )
2355 + // The right way would be just to call this (not even in the 'if')
2356 + GetpApp()->InitFinished();
2358 + else if ( !ImplIsWindowOrChild( pSVData->mpIntroWindow ) )
2360 + // ... but the VCL splash is broken, and it needs this
2361 + // (for ./soffice slot:5500)
2362 pSVData->mpIntroWindow->Hide();
2365 //DBG_ASSERT( !mpWindowImpl->mbSuppressAccessibilityEvents, "Window::Show() - Frame reactivated");
2366 mpWindowImpl->mbSuppressAccessibilityEvents = FALSE;