diff options
author | Kurt Zenker <kz@openoffice.org> | 2009-02-05 16:21:32 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2009-02-05 16:21:32 +0000 |
commit | 9c86bd9e87bb8b20b9629abd325bbc80d6e9dfe1 (patch) | |
tree | 62e23cd192718fbcd19ec8d6a61986a07da2bed1 | |
parent | 065430d0ce8ff9302433337686aa03ff1e7d201b (diff) |
CWS-TOOLING: integrate CWS sb103_OOO310
2009-01-15 15:28:08 +0100 sb r266375 : #i97629# set UNO_PATH in python start program and use it in bootstrap function in officehelper.py (and do not erroneously encode a vnd.sun.star.pathname URE_BOOTSTRAP value in tools::extendApplicationEnvironment)
2009-01-15 10:40:17 +0100 sb r266338 : #i97424# explicit shut down of ImplImageTree singleton in DeInitVCL still required
2009-01-14 12:07:15 +0100 sb r266276 : CWS-TOOLING: rebase CWS sb103 to trunk@265758 (milestone: DEV300:m38)
2009-01-14 08:53:02 +0100 sb r266266 : #i96284# remove implementation of unused (but expensive) link feature; plus some general cleanup
2009-01-08 14:42:59 +0100 sb r266010 : #i96683# enable dlclose for GCC 3 (based on a patch by cmc)
2009-01-06 14:18:23 +0100 sb r265920 : #i97424# spurious unreferenced local variables
2008-12-19 15:33:39 +0100 sb r265727 : #i57359# no need for a special glibc 2.2.4 based libgcc_s.so.1 for URE any more as the general one used for OOo is guaranteed to be based on at least glibc 2.2.4, anyway
2008-12-19 13:54:37 +0100 sb r265724 : #i97424# clean up and speed up vcl ImplImageTree
2008-12-18 14:28:10 +0100 sb r265690 : #i97132# spread usage of the rtl::Static pattern (patch by cmc)
2008-12-15 14:33:00 +0100 sb r265499 : #i90492# generate UTF-8 encoded output (patch by tora)
2008-12-15 11:45:05 +0100 sb r265469 : #i95593# -Djava.library.path to find libtest_javauno_any.so
2008-12-15 11:23:14 +0100 sb r265468 : #i93769# it appears that Java nowadays expects file URIs in UTF-8, so ExternalUriReferenceTranslator.toExternal must not be called
2008-12-10 12:02:50 +0100 sb r265164 : #i93219# use (corrected) signal handling instead of forking again (to avoid unintended generation of core files)
-rw-r--r-- | comphelper/inc/comphelper/processfactory.hxx | 2 | ||||
-rw-r--r-- | tools/source/misc/extendapplicationenvironment.cxx | 7 | ||||
-rw-r--r-- | vcl/inc/vcl/impimagetree.hxx | 174 | ||||
-rw-r--r-- | vcl/source/app/svmain.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/imagerepository.cxx | 1 | ||||
-rw-r--r-- | vcl/source/gdi/impimagetree.cxx | 872 | ||||
-rw-r--r-- | vcl/unx/source/window/salframe.cxx | 3 |
7 files changed, 321 insertions, 740 deletions
diff --git a/comphelper/inc/comphelper/processfactory.hxx b/comphelper/inc/comphelper/processfactory.hxx index 2ae9c31c0b..41ffcb55af 100644 --- a/comphelper/inc/comphelper/processfactory.hxx +++ b/comphelper/inc/comphelper/processfactory.hxx @@ -73,7 +73,7 @@ COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XI @see getProcessServiceFactory @see setProcessServiceFactory */ -::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +COMPHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createProcessComponentWithArguments( const ::rtl::OUString& _rServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& _rArgs diff --git a/tools/source/misc/extendapplicationenvironment.cxx b/tools/source/misc/extendapplicationenvironment.cxx index 2581e745dd..507b37c0ed 100644 --- a/tools/source/misc/extendapplicationenvironment.cxx +++ b/tools/source/misc/extendapplicationenvironment.cxx @@ -71,7 +71,12 @@ void extendApplicationEnvironment() { if (rtl::Bootstrap::get( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URE_BOOTSTRAP")), uri)) { - env.append(rtl::Bootstrap::encode(uri)); + if (!uri.matchIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.pathname:"))) + { + uri = rtl::Bootstrap::encode(uri); + } + env.append(uri); } else { if (osl_getExecutableFile(&uri.pData) != osl_Process_E_None) { abort(); diff --git a/vcl/inc/vcl/impimagetree.hxx b/vcl/inc/vcl/impimagetree.hxx index 5aae2bf318..dfbcb366fe 100644 --- a/vcl/inc/vcl/impimagetree.hxx +++ b/vcl/inc/vcl/impimagetree.hxx @@ -1,116 +1,92 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: impimagetree.hxx,v $ - * $Revision: 1.4 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _SV_IMPIMAGETREE_HXX -#define _SV_IMPIMAGETREE_HXX - -#include <memory> - -#ifndef _COMPHELPER_SINGLETONREF_HXX_ -#include <salhelper/singletonref.hxx> -#endif -#include <com/sun/star/uno/Reference.hxx> - -// ---------------- -// -ImplImageTree - -// ---------------- - +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2008 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef INCLUDED_VCL_IMPIMAGETREE_HXX +#define INCLUDED_VCL_IMPIMAGETREE_HXX + +#include "sal/config.h" + +#include <list> +#include <utility> +#include <vector> + +#include <hash_map> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "rtl/ustring.hxx" +#include "salhelper/singletonref.hxx" + +namespace com { namespace sun { namespace star { namespace container { + class XNameAccess; +} } } } class BitmapEx; -namespace com { namespace sun { namespace star { namespace packages { namespace zip { class XZipFileAccess; } } } } } -namespace com { namespace sun { namespace star { namespace container { class XNameAccess; } } } } -namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } -namespace com { namespace sun { namespace star { namespace ucb { class XSimpleFileAccess; } } } } -namespace com { namespace sun { namespace star { namespace io { class XInputStream; } } } } - -// ------------------- -// - ImplZipAccessor - -// ------------------- - -class ImplZipAccessor -{ -private: - - ::std::vector< ::rtl::OUString > maURLVector; - ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxFileAccess; - ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::packages::zip::XZipFileAccess > > maZipAccVector; - ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > > maNameAccVector; +class ImplImageTree: private boost::noncopyable { public: + ImplImageTree(); - ImplZipAccessor(); - ~ImplZipAccessor(); + ~ImplImageTree(); - void Update( const ::rtl::OUString& rSymbolsStyle ); - void Clear(); - bool HasEntries() const; + bool loadImage( + rtl::OUString const & name, rtl::OUString const & style, + BitmapEx & bitmap, bool localized = false); - ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > GetByName( const ::rtl::OUString& rName ) const; -}; + void shutDown(); + // a crude form of life cycle control (called from DeInitVCL; otherwise, + // if the ImplImageTree singleton were destroyed during exit that would + // be too late for the destructors of the bitmaps in m_cache) -// ----------------- -// - ImplImageTree - -// ----------------- +private: + typedef std::list< + std::pair< + rtl::OUString, + com::sun::star::uno::Reference< + com::sun::star::container::XNameAccess > > > Zips; -class ImplImageTree -{ -public: + typedef std::hash_map< + rtl::OUString, std::pair< bool, BitmapEx >, rtl::OUStringHash > Cache; - ImplImageTree(); - ~ImplImageTree(); + rtl::OUString m_style; + Zips m_zips; + Cache m_cache; - bool loadImage( const ::rtl::OUString& rName, - const ::rtl::OUString& rSymbolsStyle, - BitmapEx& rReturn, - bool bSearchLanguageDependent = false ); - void addUserImage( const ::rtl::OUString& rName, const BitmapEx& rReturn ); + void setStyle(rtl::OUString const & style); - static void cleanup(); + void resetZips(); -private: + bool cacheLookup( + rtl::OUString const & name, bool localized, BitmapEx & bitmap); - ImplZipAccessor maZipAcc; - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > mxPathSettings; - ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxFileAccess; - bool mbInit; - ::rtl::OUString maSymbolsStyle; - - bool implInit(); - const ::rtl::OUString& implGetUserDirURL() const; - ::rtl::OUString implGetUserFileURL( const ::rtl::OUString& rName ) const; - void implCheckUserCache(); - bool implLoadFromStream( SvStream& rIStm, const ::rtl::OUString& rFileName, BitmapEx& rReturn ); - ::std::auto_ptr< SvStream > implGetStream( const ::com::sun::star::uno::Reference< - ::com::sun::star::io::XInputStream >& rxIStm ) const; - void implUpdateSymbolsStyle( const ::rtl::OUString& rSymbolsStyle ); + bool find(std::vector< rtl::OUString > const & paths, BitmapEx & bitmap); }; -typedef ::salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; +typedef salhelper::SingletonRef< ImplImageTree > ImplImageTreeSingletonRef; -#endif // _SV_IMPIMAGETREE_HXX +#endif diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx index b40935d88b..5403ebc16c 100644 --- a/vcl/source/app/svmain.cxx +++ b/vcl/source/app/svmain.cxx @@ -383,7 +383,7 @@ void DeInitVCL() DBG_ASSERT( nBadTopWindows==0, aBuf.getStr() ); #endif - ImplImageTree::cleanup(); + ImplImageTreeSingletonRef()->shutDown(); delete pExceptionHandler; pExceptionHandler = NULL; diff --git a/vcl/source/gdi/imagerepository.cxx b/vcl/source/gdi/imagerepository.cxx index bd76af0715..f03c61e982 100644 --- a/vcl/source/gdi/imagerepository.cxx +++ b/vcl/source/gdi/imagerepository.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" +#include <vcl/bitmapex.hxx> #include <vcl/imagerepository.hxx> #include <vcl/svapp.hxx> #ifndef _SV_IMPIMAGETREE_H diff --git a/vcl/source/gdi/impimagetree.cxx b/vcl/source/gdi/impimagetree.cxx index a7f9e0d403..64cddece11 100644 --- a/vcl/source/gdi/impimagetree.cxx +++ b/vcl/source/gdi/impimagetree.cxx @@ -1,696 +1,294 @@ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: impimagetree.cxx,v $ - * $Revision: 1.19 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2008 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: code,v $ +* +* $Revision: 1.4 $ +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" +#include "sal/config.h" -#include <cstdio> -#include <ctype.h> -#include <tools/debug.hxx> -#include <tools/datetime.hxx> -#include <tools/urlobj.hxx> -#include <vcl/svapp.hxx> -#include <vcl/bitmapex.hxx> -#include <vcl/pngread.hxx> -#include <unotools/ucbstreamhelper.hxx> -#ifndef _UNTOOLS_LOCALFILEHELPER_HXX -#include <unotools/localfilehelper.hxx> -#endif -#include <unotools/datetime.hxx> -#include <comphelper/processfactory.hxx> -#include <rtl/bootstrap.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/packages/zip/XZipFileAccess.hpp> -#include <com/sun/star/container/XNameAccess.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/ucb/XSimpleFileAccess.hpp> - -#include "vcl/impimagetree.hxx" - +#include <list> +#include <memory> +#include <utility> #include <vector> + #include <hash_map> -#define DEFAULT_PROJECTNAME "res" -#define IMAGES_ZIPFILENAME_PREFIX "images" -#define IMAGES_ZIPFILENAME_BRAND "_brand" -#define IMAGES_ZIPFILENAME_SUFFIX ".zip" -#define IMAGES_CACHEDIR "imagecache" +#include "com/sun/star/container/XNameAccess.hpp" +#include "com/sun/star/io/XInputStream.hpp" +#include "com/sun/star/lang/Locale.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "comphelper/processfactory.hxx" +#include "osl/diagnose.h" +#include "rtl/bootstrap.hxx" +#include "rtl/string.h" +#include "rtl/textenc.h" +#include "rtl/ustrbuf.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "tools/stream.hxx" +#include "tools/urlobj.hxx" +#include "vcl/bitmapex.hxx" +#include "vcl/impimagetree.hxx" +#include "vcl/pngread.hxx" +#include "vcl/settings.hxx" +#include "vcl/svapp.hxx" -using namespace ::com::sun::star; +namespace { -ImplZipAccessor::ImplZipAccessor() -{ - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - - if( xFactory.is() ) - { - mxFileAccess.set( xFactory->createInstance( - ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), - uno::UNO_QUERY ); - } -} - -// ----------------------------------------------------------------------- +namespace css = com::sun::star; -ImplZipAccessor::~ImplZipAccessor() +rtl::OUString createPath( + rtl::OUString const & name, sal_Int32 pos, rtl::OUString const & locale) { - Clear(); + rtl::OUStringBuffer b(name.copy(0, pos + 1)); + b.append(locale); + b.append(name.copy(pos)); + return b.makeStringAndClear(); } -// ----------------------------------------------------------------------- - -void ImplZipAccessor::Update( const ::rtl::OUString& rSymbolsStyle ) +std::auto_ptr< SvStream > wrapStream( + css::uno::Reference< css::io::XInputStream > const & stream) { -#ifdef DEBUG - std::fprintf( stderr, "\nUpdating symbols for style: %s\n", ByteString( String( rSymbolsStyle ), RTL_TEXTENCODING_ASCII_US ).GetBuffer() ); -#endif - - Clear(); - - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - - const ::rtl::OUString aZipFileName( ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_PREFIX ) ); - rtl::OUString aBrandPath( RTL_CONSTASCII_USTRINGPARAM( "$BRAND_BASE_DIR/share/config" ) ); - rtl::OUString aOOOPath( RTL_CONSTASCII_USTRINGPARAM( "$OOO_BASE_DIR/share/config" ) ); - ::std::vector< ::rtl::OUString > aTmpURLVector; - - rtl::Bootstrap::expandMacros( aBrandPath ); - rtl::Bootstrap::expandMacros( aOOOPath ); - - // Theme Branding Zip - if( rSymbolsStyle.getLength() ) - { - INetURLObject aThemeBrandURL( aBrandPath ); - ::rtl::OUString aThemeBrandZip( aZipFileName ); - - ( aThemeBrandZip += ::rtl::OUString::createFromAscii( "_" ) ) += rSymbolsStyle; - aThemeBrandZip += ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_BRAND ); - aThemeBrandZip += ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_SUFFIX ); - aThemeBrandURL.Append( aThemeBrandZip ); - - if( mxFileAccess->exists( aThemeBrandURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) - aTmpURLVector.push_back( aThemeBrandURL.GetMainURL( INetURLObject::NO_DECODE ) ); - } - - // Branding Zip - INetURLObject aBrandURL( aBrandPath ); - ::rtl::OUString aBrandZip( aZipFileName ); - - aBrandZip += ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_BRAND ); - aBrandZip += ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_SUFFIX ); - aBrandURL.Append( aBrandZip ); - - if( mxFileAccess->exists( aBrandURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) - aTmpURLVector.push_back( aBrandURL.GetMainURL( INetURLObject::NO_DECODE ) ); - - // Theme Zip - if( rSymbolsStyle.getLength() ) - { - INetURLObject aThemeURL( aOOOPath ); - ::rtl::OUString aThemeZip( aZipFileName ); - - ( aThemeZip += ::rtl::OUString::createFromAscii( "_" ) ) += rSymbolsStyle; - aThemeZip += ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_SUFFIX ); - aThemeURL.Append( aThemeZip ); - - if( mxFileAccess->exists( aThemeURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) - aTmpURLVector.push_back( aThemeURL.GetMainURL( INetURLObject::NO_DECODE ) ); - } - - // Default Zip - if( rSymbolsStyle.getLength() ) - { - INetURLObject aDefaultURL( aOOOPath ); - ::rtl::OUString aDefaultZip( aZipFileName ); - - aDefaultZip += ::rtl::OUString::createFromAscii( IMAGES_ZIPFILENAME_SUFFIX ); - aDefaultURL.Append( aDefaultZip ); - - if( mxFileAccess->exists( aDefaultURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) - aTmpURLVector.push_back( aDefaultURL.GetMainURL( INetURLObject::NO_DECODE ) ); - } - - if( xFactory.is() ) - { - for( unsigned int i = 0; i < aTmpURLVector.size(); ++i ) - { - try - { - uno::Reference< packages::zip::XZipFileAccess > xZipAcc( xFactory->createInstance( - ::rtl::OUString::createFromAscii( "com.sun.star.packages.zip.ZipFileAccess" ) ), - uno::UNO_QUERY ); - - if( xZipAcc.is() ) - { - uno::Reference< lang::XInitialization > xInit( xZipAcc, uno::UNO_QUERY ); - - if( xInit.is() ) - { - uno::Sequence< uno::Any > aInitSeq( 1 ); - const ::rtl::OUString& rZipURL = aTmpURLVector[ i ]; - - if( rZipURL.getLength() ) - { - uno::Reference< container::XNameAccess > xNameAcc; - - aInitSeq[ 0 ] <<= rZipURL; - xInit->initialize( aInitSeq ); - xNameAcc.set( xZipAcc, uno::UNO_QUERY ); - - if( xNameAcc.is() && xNameAcc->getElementNames().getLength() ) - { - maURLVector.push_back( rZipURL ); - maZipAccVector.push_back( xZipAcc ); - maNameAccVector.push_back( xNameAcc ); -#ifdef DEBUG - std::fprintf( stderr, "Current set has symbols from archive: %s\n", ByteString( String( rZipURL ), RTL_TEXTENCODING_ASCII_US ).GetBuffer() ); -#endif - } - } - } - } - } - catch( const uno::Exception& ) - { - } + // This could use SvInputStream instead if that did not have a broken + // SeekPos implementation for an XInputStream that is not also XSeekable + // (cf. "@@@" at tags/DEV300_m37/svtools/source/misc1/strmadpt.cxx@264807 + // l. 593): + OSL_ASSERT(stream.is()); + std::auto_ptr< SvStream > s(new SvMemoryStream); + for (;;) { + css::uno::Sequence< sal_Int8 > data; + sal_Int32 const size = 30000; + sal_Int32 n = stream->readBytes(data, size); + s->Write(data.getConstArray(), n); + if (n < size) { + break; } } + s->Seek(0); + return s; } -// ----------------------------------------------------------------------- - -void ImplZipAccessor::Clear() -{ - maURLVector.clear(); - maZipAccVector.clear(); - maNameAccVector.clear(); -} - -// ----------------------------------------------------------------------- - -bool ImplZipAccessor::HasEntries() const -{ - return( maNameAccVector.size() > 0 ); -} - -// ----------------------------------------------------------------------- - -uno::Reference< io::XInputStream > ImplZipAccessor::GetByName( const ::rtl::OUString& rName ) const +void loadFromStream( + css::uno::Reference< css::io::XInputStream > const & stream, + rtl::OUString const & path, BitmapEx & bitmap) { - uno::Reference< io::XInputStream > xRet; - -#ifdef DEBUG - std::fprintf( stderr, "Looking for file: %s\n", ByteString( String( rName ), RTL_TEXTENCODING_ASCII_US ).GetBuffer() ); -#endif - - for( unsigned int i = 0; ( i < maNameAccVector.size() ) && !xRet.is(); ++i ) - { - if( maNameAccVector[ i ]->hasByName( rName ) ) - { - try - { - if( maNameAccVector[ i ]->getByName( rName ) >>= xRet ) - { -#ifdef DEBUG - std::fprintf( stderr, "Found in archive: %s\n\n", ByteString( String( maURLVector[ i ] ), RTL_TEXTENCODING_ASCII_US ).GetBuffer() ); -#endif - - - break; - } - } - catch( const uno::Exception & ) - { - } - } + std::auto_ptr< SvStream > s(wrapStream(stream)); + if (path.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM(".png"))) { + bitmap = vcl::PNGReader(*s).Read(); + } else { + *s >> bitmap; } - - return( xRet ); -} - - -// ----------------- -// - ImplImageTree - -// ----------------- - -typedef ::std::hash_map< ::rtl::OUString, BitmapEx, ::rtl::OUStringHash > BmpExHashMap; -static BmpExHashMap aBmpExHashMap; - -// ----------------------------------------------------------------------- - -ImplImageTree::ImplImageTree() : - mbInit( false ), - maSymbolsStyle( Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName() ) -{ } -// ----------------------------------------------------------------------- - -ImplImageTree::~ImplImageTree() -{ } -// ----------------------------------------------------------------------- - -void ImplImageTree::cleanup() -{ - ImplImageTreeSingletonRef aCleaner; - - aCleaner->maZipAcc.Clear(); - aCleaner->mxFileAccess.clear(); - aCleaner->mxPathSettings.clear(); - - BmpExHashMap aTmp; - aBmpExHashMap.swap( aTmp ); -} +ImplImageTree::ImplImageTree() {} -// ----------------------------------------------------------------------- +ImplImageTree::~ImplImageTree() {} -bool ImplImageTree::implInit() +bool ImplImageTree::loadImage( + rtl::OUString const & name, rtl::OUString const & style, BitmapEx & bitmap, + bool localized) { - if( !mbInit ) - { - uno::Reference< lang::XMultiServiceFactory > xFactory( ::comphelper::getProcessServiceFactory() ); - - if( xFactory.is() ) - { - // #137795# protect against exceptions in service instantiation - try - { - mxPathSettings.set( xFactory->createInstance( - ::rtl::OUString::createFromAscii( "com.sun.star.util.PathSettings" ) ), - uno::UNO_QUERY ); - mxFileAccess.set( xFactory->createInstance( - ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), - uno::UNO_QUERY ); - - if( mxPathSettings.is() && mxFileAccess.is() ) - { - maZipAcc.Update( maSymbolsStyle ); - // implCheckUserCache(); + setStyle(style); + if (cacheLookup(name, localized, bitmap)) { + return true; + } + if (!bitmap.IsEmpty()) { + bitmap.SetEmpty(); + } + std::vector< rtl::OUString > paths; + paths.push_back(name); + if (localized) { + sal_Int32 pos = name.lastIndexOf('/'); + if (pos != -1) { + css::lang::Locale const & loc = + Application::GetSettings().GetUILocale(); + paths.push_back(createPath(name, pos, loc.Language)); + if (loc.Country.getLength() != 0) { + rtl::OUStringBuffer b(loc.Language); + b.append(sal_Unicode('-')); + b.append(loc.Country); + rtl::OUString p(createPath(name, pos, b.makeStringAndClear())); + paths.push_back(p); + if (loc.Variant.getLength() != 0) { + b.append(p); + b.append(sal_Unicode('-')); + b.append(loc.Variant); + paths.push_back( + createPath(name, pos, b.makeStringAndClear())); } } - catch( const uno::Exception& ) - { - maZipAcc.Clear(); - mxPathSettings.clear(); - mxFileAccess.clear(); - } } } - - return( mbInit = maZipAcc.HasEntries() ); -} - -// ----------------------------------------------------------------------- - -const ::rtl::OUString& ImplImageTree::implGetUserDirURL() const -{ - static ::rtl::OUString aRet; - - if( !aRet.getLength() && mxPathSettings.is() && mxFileAccess.is() ) - { - const ::rtl::OUString aImagesCacheDir( ::rtl::OUString::createFromAscii( IMAGES_CACHEDIR ) ); - uno::Any aAny( mxPathSettings->getPropertyValue( ::rtl::OUString::createFromAscii( "UserConfig" ) ) ); - - if( ( aAny >>= aRet ) && aRet.getLength() ) - { - INetURLObject aCacheURL( aRet ); - - aCacheURL.Append( aImagesCacheDir ); - - try - { - mxFileAccess->createFolder( aRet = aCacheURL.GetMainURL( INetURLObject::NO_DECODE ) ); - } - catch( const ucb::CommandAbortedException& ) - { - } - catch( const uno::Exception& ) - { - } - } + bool found = false; + try { + found = find(paths, bitmap); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception & e) { + OSL_TRACE( + "ImplImageTree::loadImage exception \"%s\"", + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); } - - return aRet; + if (found) { + m_cache[name.intern()] = std::make_pair(localized, bitmap); + } + return found; } -// ----------------------------------------------------------------------- - -::rtl::OUString ImplImageTree::implGetUserFileURL( const ::rtl::OUString& rName ) const -{ - INetURLObject aFileURL( implGetUserDirURL() ); - - aFileURL.Append( rName ); - - return( aFileURL.GetMainURL( INetURLObject::NO_DECODE ) ); +void ImplImageTree::shutDown() { + m_style = rtl::OUString(); + // for safety; empty m_style means "not initialized" + m_zips.clear(); + m_cache.clear(); } -// ----------------------------------------------------------------------- - -void ImplImageTree::implCheckUserCache() -{ -/* - const ::rtl::OUString& rZipURL = implGetZipFileURL(); - const ::rtl::OUString& rUserDirURL = implGetUserDirURL(); - - if( rZipURL.getLength() && rUserDirURL.getLength() ) - { - try - { - ::DateTime aZipDateTime, aCacheFileDateTime; - const uno::Sequence< ::rtl::OUString > aCacheFiles( mxFileAccess->getFolderContents( rUserDirURL, false ) ); - - ::utl::typeConvert( mxFileAccess->getDateTimeModified( rZipURL ), aZipDateTime ); - - for( sal_Int32 i = 0; i < aCacheFiles.getLength(); ++i ) - { - const ::rtl::OUString aCacheFile( aCacheFiles[ i ] ); - - try - { - ::utl::typeConvert( mxFileAccess->getDateTimeModified( aCacheFile ), aCacheFileDateTime ); - - if( aZipDateTime > aCacheFileDateTime ) - mxFileAccess->kill( aCacheFile ); - } - catch( const ucb::CommandAbortedException& ) - { - } - catch( const uno::Exception& ) - { - } - } - } - catch( const ucb::CommandAbortedException& ) - { - } - catch( const uno::Exception& ) - { - } +void ImplImageTree::setStyle(rtl::OUString const & style) { + OSL_ASSERT(style.getLength() != 0); // empty m_style means "not initialized" + if (style != m_style) { + m_style = style; + resetZips(); + m_cache.clear(); } -*/ } -// ------------------------------------------------------------------------------ - -bool ImplImageTree::implLoadFromStream( SvStream& rIStm, - const ::rtl::OUString& rFileName, - BitmapEx& rReturn ) -{ - static const ::rtl::OUString aPNGExtension( ::rtl::OUString::createFromAscii( "png" ) ); - const sal_Int32 nDotPos = rFileName.lastIndexOf( '.' ); - const sal_uInt32 nStmPos = rIStm.Tell(); - - if( ( -1 != nDotPos ) && ( rFileName.lastIndexOf( aPNGExtension ) == ( nDotPos + 1 ) ) ) +void ImplImageTree::resetZips() { + m_zips.clear(); { - ::vcl::PNGReader aPNGReader( rIStm ); - rReturn = aPNGReader.Read(); + rtl::OUString url( + RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/share/config")); + rtl::Bootstrap::expandMacros(url); + INetURLObject u(url); + OSL_ASSERT(!u.HasError()); + rtl::OUStringBuffer b; + b.appendAscii(RTL_CONSTASCII_STRINGPARAM("images_")); + b.append(m_style); + b.appendAscii(RTL_CONSTASCII_STRINGPARAM("_brand.zip")); + bool ok = u.Append(b.makeStringAndClear(), INetURLObject::ENCODE_ALL); + OSL_ASSERT(ok); (void) ok; + m_zips.push_back( + std::make_pair( + u.GetMainURL(INetURLObject::NO_DECODE), + css::uno::Reference< css::container::XNameAccess >())); } - - if( rReturn.IsEmpty() ) { - rIStm.Seek( nStmPos ); - rIStm.ResetError(); - rIStm >> rReturn; + rtl::OUString url( + RTL_CONSTASCII_USTRINGPARAM( + "$BRAND_BASE_DIR/share/config/images_brand.zip")); + rtl::Bootstrap::expandMacros(url); + m_zips.push_back( + std::make_pair( + url, css::uno::Reference< css::container::XNameAccess >())); } - - return( !rReturn.IsEmpty() ); -} - -// ------------------------------------------------------------------------------ - -::std::auto_ptr< SvStream > ImplImageTree::implGetStream( const uno::Reference< io::XInputStream >& rxIStm ) const -{ - ::std::auto_ptr< SvStream > apRet; - - // create a seekable memory stream from the non-seekable XInputStream - if( rxIStm.is() ) { - const sal_Int32 nBufferSize = 32768; - sal_Int32 nRead; - uno::Sequence < sal_Int8 > aReadSeq( nBufferSize ); - - apRet.reset( new SvMemoryStream( nBufferSize, nBufferSize ) ); - - do - { - nRead = rxIStm->readBytes ( aReadSeq, nBufferSize ); - apRet->Write( aReadSeq.getConstArray(), nRead ); - } - while ( nRead == nBufferSize ); - - if( apRet->Tell() > 0 ) - apRet->Seek( 0 ); - else - apRet.reset(); + rtl::OUString url( + RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/share/config")); + rtl::Bootstrap::expandMacros(url); + INetURLObject u(url); + OSL_ASSERT(!u.HasError()); + rtl::OUStringBuffer b; + b.appendAscii(RTL_CONSTASCII_STRINGPARAM("images_")); + b.append(m_style); + b.appendAscii(RTL_CONSTASCII_STRINGPARAM(".zip")); + bool ok = u.Append(b.makeStringAndClear(), INetURLObject::ENCODE_ALL); + OSL_ASSERT(ok); (void) ok; + m_zips.push_back( + std::make_pair( + u.GetMainURL(INetURLObject::NO_DECODE), + css::uno::Reference< css::container::XNameAccess >())); + } + { + rtl::OUString url( + RTL_CONSTASCII_USTRINGPARAM( + "$OOO_BASE_DIR/share/config/images.zip")); + rtl::Bootstrap::expandMacros(url); + m_zips.push_back( + std::make_pair( + url, css::uno::Reference< css::container::XNameAccess >())); } - - return apRet; } -// ------------------------------------------------------------------------------ - -void ImplImageTree::implUpdateSymbolsStyle( const ::rtl::OUString& rSymbolsStyle ) +bool ImplImageTree::cacheLookup( + rtl::OUString const & name, bool localized, BitmapEx & bitmap) { - if ( rSymbolsStyle != maSymbolsStyle ) - { - maSymbolsStyle = rSymbolsStyle; - if ( mbInit ) - { - maZipAcc.Clear(); - mxFileAccess.clear(); - mxPathSettings.clear(); - - BmpExHashMap aTmp; - aBmpExHashMap.swap( aTmp ); - - mbInit = false; - } + Cache::iterator i(m_cache.find(name)); + if (i != m_cache.end() && i->second.first == localized) { + bitmap = i->second.second; + return true; + } else { + return false; } } -// ------------------------------------------------------------------------------ - -bool ImplImageTree::loadImage( const ::rtl::OUString& rName, - const ::rtl::OUString& rSymbolsStyle, - BitmapEx& rReturn, - bool bSearchLanguageDependent ) +bool ImplImageTree::find( + std::vector< rtl::OUString > const & paths, BitmapEx & bitmap) { - implUpdateSymbolsStyle( rSymbolsStyle ); - - const BmpExHashMap::const_iterator aBmpExFindIter( aBmpExHashMap.find( rName ) ); - - if( aBmpExFindIter != aBmpExHashMap.end() ) - rReturn = (*aBmpExFindIter).second; - else - { - if( !rReturn.IsEmpty() ) - rReturn.SetEmpty(); - - if( maZipAcc.HasEntries() || ( implInit() && maZipAcc.HasEntries() ) ) - { - if( bSearchLanguageDependent ) - { - // try to get image from local subdirectory - const ::rtl::OUString aDash( ::rtl::OUString::createFromAscii( "-" ) ); - const lang::Locale& rLocale = Application::GetSettings().GetUILocale(); - ::rtl::OUString aSubDir[3]; // array must be expanded if more locale variants are checked! - int nSubDirs=0; - ::rtl::OUString aLocaleStr( rLocale.Language ); - - aSubDir[nSubDirs++] = aLocaleStr; - if( rLocale.Country.getLength() ) - { - ( aLocaleStr += aDash ) += rLocale.Country; - aSubDir[nSubDirs++] = aLocaleStr; - - if( rLocale.Variant.getLength() ) - { - ( aLocaleStr += aDash ) += rLocale.Variant; - aSubDir[nSubDirs++] = aLocaleStr; - } - } - - for( --nSubDirs; nSubDirs >= 0; nSubDirs-- ) - { - // check all locale variants, starting with the most detailed one - if( aSubDir[nSubDirs].getLength() ) - { - const sal_Int32 nPos = rName.lastIndexOf( '/' ); - - if( -1 != nPos ) - { - ::rtl::OUString aLocaleName( rName.copy( 0, nPos + 1 ) ); - - aLocaleName += aSubDir[nSubDirs]; - aLocaleName += ::rtl::OUString::createFromAscii( "/" ); - aLocaleName += rName.copy( nPos + 1 ); - - try - { - uno::Reference< io::XInputStream > xIStm( maZipAcc.GetByName( aLocaleName ) ); - - if( xIStm.is() ) - { - ::std::auto_ptr< SvStream > apRet( implGetStream( xIStm ) ); - - if( apRet.get() ) - implLoadFromStream( *apRet, aLocaleName, rReturn ); - } - } - catch( const uno::Exception & ) - { - } - } - } - } - } - - if( rReturn.IsEmpty() ) - { - try - { - uno::Reference< io::XInputStream > xIStm( maZipAcc.GetByName( rName ) ); - - if( xIStm.is() ) - { - ::std::auto_ptr< SvStream > apRet( implGetStream( xIStm ) ); - - if( apRet.get() ) - implLoadFromStream( *apRet, rName, rReturn ); - } - } - catch( const uno::Exception & ) - { - } - } - - if( rReturn.IsEmpty() ) - { - ::std::auto_ptr< SvStream > apIStm( ::utl::UcbStreamHelper::CreateStream( implGetUserFileURL( rName ), STREAM_READ )); - - if( apIStm.get() ) - *apIStm >> rReturn; + for (Zips::iterator i(m_zips.begin()); i != m_zips.end();) { + if (!i->second.is()) { + css::uno::Sequence< css::uno::Any > args(1); + args[0] <<= i->first; + try { + i->second.set( + comphelper::createProcessComponentWithArguments( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.packages.zip.ZipFileAccess")), + args), + css::uno::UNO_QUERY_THROW); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception & e) { + OSL_TRACE( + "ImplImageTree::find exception \"%s\"", + rtl::OUStringToOString( + e.Message, RTL_TEXTENCODING_UTF8).getStr()); + i = m_zips.erase(i); + continue; } } - else + for (std::vector< rtl::OUString >::const_reverse_iterator j( + paths.rbegin()); + j != paths.rend(); ++j) { - // HACK for old setup!!! search in filesystem relative to application root - ::rtl::OUString aAppDir( Application::GetAppFileName() ); - sal_Int32 nPos = aAppDir.lastIndexOf( '/' ); - - if( -1 == nPos ) - nPos = aAppDir.lastIndexOf( '\\' ); - - if( -1 != nPos ) - { - String aURLStr; - - aAppDir = aAppDir.copy( 0, nPos ); - - if( ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aAppDir, aURLStr ) ) - { - INetURLObject aURL( aURLStr ); - sal_Int32 nIndex = 0; - - do - { - aURL.Append( rName.getToken( 0, '/', nIndex ) ); - } - while( nIndex >= 0 ); - - aURLStr = aURL.GetMainURL( INetURLObject::NO_DECODE ); - - ::std::auto_ptr< SvStream > apIStm( ::utl::UcbStreamHelper::CreateStream( aURLStr, STREAM_READ ) ); - - if( apIStm.get() ) - { - implLoadFromStream( *apIStm, aURLStr, rReturn ); - apIStm.reset(); - } - - if( rReturn.IsEmpty() ) - { - // HACK for old setup!!! try to look in ../share/config - nPos = aAppDir.lastIndexOf( '/' ); - - if( -1 == nPos ) - nPos = aAppDir.lastIndexOf( '\\' ); - - aAppDir = aAppDir.copy( 0, nPos ); - - if( ( -1 != nPos ) && ::utl::LocalFileHelper::ConvertPhysicalNameToURL( aAppDir, aURLStr ) ) - { - aURL = INetURLObject( aURLStr ); - aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "share" ) ) ); - aURL.Append( String( RTL_CONSTASCII_USTRINGPARAM( "config" ) ) ); - nIndex = 0; - - do - { - aURL.Append( rName.getToken( 0, '/', nIndex ) ); - } - while( nIndex >= 0 ); - - aURLStr = aURL.GetMainURL( INetURLObject::NO_DECODE ); - - apIStm.reset( ::utl::UcbStreamHelper::CreateStream( aURLStr, STREAM_READ ) ); - - if( apIStm.get() ) - implLoadFromStream( *apIStm, aURLStr, rReturn ); - } - } - } + if (i->second->hasByName(*j)) { + css::uno::Reference< css::io::XInputStream > s; + bool ok = i->second->getByName(*j) >>= s; + OSL_ASSERT(ok); (void) ok; + loadFromStream(s, *j, bitmap); + return true; } } + ++i; } - - if( !rReturn.IsEmpty() ) - aBmpExHashMap[ rName.intern() ] = rReturn; - - return( !rReturn.IsEmpty() ); -} - -// ------------------------------------------------------------------------------ - -void ImplImageTree::addUserImage( const ::rtl::OUString& rName, const BitmapEx& rBmpEx ) -{ - const ::rtl::OUString aFileName( implGetUserFileURL( rName ) ); - - if( aFileName.getLength() ) - { - ::std::auto_ptr< SvStream > apOStm( ::utl::UcbStreamHelper::CreateStream( aFileName, STREAM_WRITE | STREAM_TRUNC ) ); - - if( apOStm.get() ) - *apOStm << rBmpEx; - } + return false; } diff --git a/vcl/unx/source/window/salframe.cxx b/vcl/unx/source/window/salframe.cxx index 984a0a1014..6642465c01 100644 --- a/vcl/unx/source/window/salframe.cxx +++ b/vcl/unx/source/window/salframe.cxx @@ -424,7 +424,8 @@ void X11SalFrame::Init( ULONG nSalFrameStyle, int nScreen, SystemParentData* pPa if( IsOverrideRedirect() ) Attributes.override_redirect = True; // default icon - if( SelectAppIconPixmap( pDisplay_, m_nScreen, + if( (nStyle_ & SAL_FRAME_STYLE_INTRO) == 0 && + SelectAppIconPixmap( pDisplay_, m_nScreen, mnIconID != 1 ? mnIconID : (mpParent ? mpParent->mnIconID : 1), 32, Hints.icon_pixmap, Hints.icon_mask )) |