Files
libreoffice/tools/source/rc/resmgr.cxx

1622 lines
51 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include <config_folders.h>
#include <sal/config.h>
#include <cassert>
2000-09-18 16:07:07 +00:00
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <tools/debug.hxx>
#include <tools/stream.hxx>
#include <tools/resmgr.hxx>
#include <tools/rc.hxx>
#include <tools/rcid.h>
#include <osl/endian.h>
#include <osl/process.h>
#include <osl/thread.h>
#include <osl/file.hxx>
#include <osl/mutex.hxx>
2010-10-11 01:26:24 -05:00
#include <osl/signal.h>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
#include <sal/log.hxx>
#include <rtl/instance.hxx>
#include <rtl/bootstrap.hxx>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <tools/simplerm.hxx>
2000-09-18 16:07:07 +00:00
#include <algorithm>
#include <functional>
#include <list>
#include <set>
#include <unordered_map>
2011-02-27 17:05:28 +01:00
using namespace osl;
// for thread safety
static osl::Mutex* pResMgrMutex = NULL;
static osl::Mutex& getResMgrMutex()
{
if( !pResMgrMutex )
{
osl::Guard<osl::Mutex> aGuard( *osl::Mutex::getGlobalMutex() );
if( ! pResMgrMutex )
pResMgrMutex = new osl::Mutex();
}
return *pResMgrMutex;
}
struct ImpContent;
class InternalResMgr
{
friend class ResMgr;
friend class SimpleResMgr;
friend class ResMgrContainer;
ImpContent * pContent;
sal_uInt32 nOffCorrection;
sal_uInt8 * pStringBlock;
SvStream * pStm;
bool bEqual2Content;
sal_uInt32 nEntries;
OUString aFileName;
OUString aPrefix;
OUString aResName;
bool bSingular;
LanguageTag aLocale;
std::unordered_map<sal_uInt64, int>* pResUseDump;
InternalResMgr( const OUString& rFileURL,
const OUString& aPrefix,
const OUString& aResName,
const LanguageTag& rLocale );
~InternalResMgr();
bool Create();
bool IsGlobalAvailable( RESOURCE_TYPE nRT, sal_uInt32 nId ) const;
void * LoadGlobalRes( RESOURCE_TYPE nRT, sal_uInt32 nId,
void **pResHandle );
public:
static void FreeGlobalRes( void *, void * );
};
class ResMgrContainer
{
static ResMgrContainer* pOneInstance;
struct ContainerElement
{
InternalResMgr* pResMgr;
OUString aFileURL;
int nRefCount;
int nLoadCount;
ContainerElement() :
pResMgr( NULL ),
nRefCount( 0 ),
nLoadCount( 0 )
{}
};
std::unordered_map< OUString, ContainerElement, OUStringHash> m_aResFiles;
LanguageTag m_aDefLocale;
ResMgrContainer() : m_aDefLocale( LANGUAGE_SYSTEM) { init(); }
~ResMgrContainer();
void init();
public:
static ResMgrContainer& get();
static void release();
InternalResMgr* getResMgr( const OUString& rPrefix,
LanguageTag& rLocale,
bool bForceNewInstance = false
);
InternalResMgr* getNextFallback( InternalResMgr* pResMgr );
void freeResMgr( InternalResMgr* pResMgr );
void setDefLocale( const LanguageTag& rLocale )
{ m_aDefLocale = rLocale; }
const LanguageTag& getDefLocale() const
{ return m_aDefLocale; }
};
ResMgrContainer* ResMgrContainer::pOneInstance = NULL;
ResMgrContainer& ResMgrContainer::get()
{
if( ! pOneInstance )
pOneInstance = new ResMgrContainer();
return *pOneInstance;
}
ResMgrContainer::~ResMgrContainer()
{
for( std::unordered_map< OUString, ContainerElement, OUStringHash >::iterator it =
m_aResFiles.begin(); it != m_aResFiles.end(); ++it )
{
2011-09-29 15:17:42 +02:00
OSL_TRACE( "Resource file %s loaded %d times",
OUStringToOString( it->second.aFileURL, osl_getThreadTextEncoding() ).getStr(),
it->second.nLoadCount );
delete it->second.pResMgr;
}
}
void ResMgrContainer::release()
{
delete pOneInstance;
pOneInstance = NULL;
}
void ResMgrContainer::init()
{
assert( m_aResFiles.empty() );
// get resource path
OUString uri("$BRAND_BASE_DIR/" LIBO_SHARE_RESOURCE_FOLDER "/");
rtl::Bootstrap::expandMacros(uri); //TODO: detect failure
// collect all possible resource files
Directory aDir( uri );
if( aDir.open() == FileBase::E_None )
{
DirectoryItem aItem;
while( aDir.getNextItem( aItem ) == FileBase::E_None )
{
FileStatus aStatus(osl_FileStatus_Mask_FileName);
if( aItem.getFileStatus( aStatus ) == FileBase::E_None )
{
OUString aFileName = aStatus.getFileName();
if( ! aFileName.endsWithIgnoreAsciiCase( ".res" ) )
continue;
OUString aResName = aFileName.copy( 0, aFileName.getLength() - strlen(".res") );
if( aResName.isEmpty() )
continue;
assert( m_aResFiles.find( aResName ) == m_aResFiles.end() );
m_aResFiles[ aResName ].aFileURL = uri + aFileName;
SAL_INFO(
"tools.rc",
"ResMgrContainer: " << aResName << " -> "
<< m_aResFiles[ aResName ].aFileURL );
}
}
}
else
SAL_WARN( "tools.rc", "opening dir " << uri << " failed" );
CWS-TOOLING: integrate CWS fwk92 2008-12-04 14:43:28 +0100 oc r264844 : #i96788# 2008-12-03 02:15:17 +0100 fredrikh r264734 : i96817 2008-12-02 16:42:46 +0100 tbo r264720 : #i96763# changes to password dialog for framework, math, global 2008-11-26 16:26:28 +0100 mav r264418 : #i93617# fix typo 2008-11-26 16:13:03 +0100 mav r264411 : #i93617# fix the linux scenario 2008-11-25 17:58:01 +0100 mav r264323 : #i93617# fix the windows problems 2008-11-25 17:51:33 +0100 mav r264321 : #i93617# fix the windows problems 2008-11-21 16:01:18 +0100 mav r264145 : #i78753# integrate the patch 2008-11-21 14:08:32 +0100 mav r264136 : #i93617# integrate the patch 2008-11-21 13:01:56 +0100 mav r264127 : #i82947# integrate the patch 2008-11-20 18:14:19 +0100 mav r264092 : #i95793# look for import filter 2008-11-18 15:23:44 +0100 pb r263776 : fix: #i92579# #i92583# SvxSecurity/SearchPage: more space for controls 2008-11-18 15:21:39 +0100 pb r263774 : fix: #i92579# #i92583# SvxSecurity/SearchPage: more space for controls 2008-11-18 15:18:54 +0100 pb r263772 : fix: #i92583# SvxSearchPage::InitControls_Impl() added 2008-11-18 15:16:07 +0100 pb r263771 : fix: #i92579# columns calculated newly 2008-11-18 11:09:28 +0100 mav r263751 : #i21923# small fixes 2008-11-17 17:22:04 +0100 mav r263730 : #i21923# integrate the patch 2008-11-17 14:29:02 +0100 mav r263723 : #i21923# integrate the patch 2008-11-13 16:46:08 +0100 mav r263653 : #i88127# integrate the patch 2008-11-13 14:46:56 +0100 mav r263645 : #i54638# integrate the patch 2008-11-11 13:11:03 +0100 pb r263554 : fix: #i93142# disable maRecommReadOnlyCB on read-only documents 2008-11-10 13:30:58 +0100 pb r263516 : fix: #i93833# Mozilla Plug-in -> Browser Plug-in 2008-11-10 13:29:10 +0100 pb r263515 : fix: #i93833# Mozilla Plug-in -> Browser Plug-in 2008-11-10 06:10:11 +0100 pb r263505 : fix: #i94937# now .uno.ExtendedHelp without image 2008-11-04 20:52:50 +0100 mav r263337 : migrate cws fwk92 to svn
2008-12-12 12:52:51 +00:00
// set default language
LanguageType nLang = MsLangId::getSystemUILanguage();
m_aDefLocale.reset( nLang);
}
namespace
{
bool isAlreadyPureenUS(const LanguageTag &rLocale)
{
return ( rLocale.getLanguageType() == LANGUAGE_ENGLISH_US );
}
}
InternalResMgr* ResMgrContainer::getResMgr( const OUString& rPrefix,
LanguageTag& rLocale,
bool bForceNewInstance
)
{
LanguageTag aLocale( rLocale );
std::unordered_map< OUString, ContainerElement, OUStringHash >::iterator it = m_aResFiles.end();
::std::vector< OUString > aFallbacks( aLocale.getFallbackStrings( true));
if (!isAlreadyPureenUS( aLocale))
aFallbacks.push_back( "en-US"); // last resort if all fallbacks fail
for (::std::vector< OUString >::const_iterator fb( aFallbacks.begin()); fb != aFallbacks.end(); ++fb)
{
OUString aSearch( rPrefix + *fb );
it = m_aResFiles.find( aSearch );
if( it != m_aResFiles.end() )
{
Many spelling fixes: directories r* - z*. Attempt to clean up most but certainly not all the spelling mistakes that found home in OpenOffice through decades. We could probably blame the international nature of the code but it is somewhat shameful that this wasn't done before. (cherry picked from commit 28206a7cb43aff5adb10f8235ad1680c3941ee3e) Conflicts: include/osl/file.hxx include/osl/pipe_decl.hxx include/osl/socket.h include/osl/socket_decl.hxx include/sal/main.h include/svx/dbaexchange.hxx include/svx/dlgctrl.hxx include/svx/msdffdef.hxx include/svx/sdr/contact/objectcontactofpageview.hxx include/svx/svdpntv.hxx include/ucbhelper/content.hxx include/ucbhelper/interceptedinteraction.hxx include/ucbhelper/resultsethelper.hxx include/unotools/sharedunocomponent.hxx include/unotools/viewoptions.hxx include/vcl/pdfwriter.hxx include/xmloff/txtparae.hxx include/xmloff/uniref.hxx rhino/rhino1_7R3.patch rsc/inc/rscrsc.hxx sal/inc/osl/conditn.h sal/inc/osl/security.h sal/inc/osl/semaphor.h sal/inc/osl/semaphor.hxx sal/inc/rtl/string.hxx sal/inc/rtl/tres.h sal/inc/systools/win32/StrConvert.h sal/osl/os2/file_path_helper.h sal/osl/os2/file_path_helper.hxx sal/osl/os2/file_url.cxx sal/osl/os2/file_url.h sal/osl/os2/makefile.mk sal/osl/os2/pipe.cxx sal/osl/os2/process.c sal/osl/os2/profile.c sal/osl/os2/socket.c sal/osl/os2/system.h sal/osl/unx/asm/interlck_sparc.s sal/osl/unx/file_url.cxx sal/osl/unx/signal.c sal/osl/unx/system.h sal/osl/w32/MAKEFILE.MK sal/osl/w32/interlck.c sal/osl/w32/module.cxx sal/osl/w32/security.c sal/qa/buildall.pl sal/qa/osl/file/osl_File.cxx sal/qa/osl/module/osl_Module_Const.h sal/qa/osl/mutex/osl_Mutex.cxx sal/qa/osl/pipe/osl_Pipe.cxx sal/qa/osl/process/osl_Thread.cxx sal/qa/osl/socket/osl_StreamSocket.cxx sal/qa/osl/socket/sockethelper.cxx sal/qa/rtl_strings/rtl_OUString.cxx sal/rtl/source/unload.cxx sal/systools/win32/kill/kill.cxx sal/systools/win32/uwinapi/MoveFileExA.cpp sal/test/bootstrap.pl sal/typesconfig/typesconfig.c sal/workben/tgetpwnam.cxx sax/inc/sax/parser/saxparser.hxx sc/addin/datefunc/dfa.cl sc/addin/datefunc/dfa.src sc/addin/rot13/rot13.cl sc/addin/rot13/rot13.src sc/inc/attarray.hxx sc/inc/chgtrack.hxx sc/inc/column.hxx sc/inc/compressedarray.hxx sc/inc/document.hxx sc/inc/table.hxx sc/source/core/data/column.cxx sc/source/core/data/dptablecache.cxx sc/source/core/data/dptabres.cxx sc/source/core/data/dptabsrc.cxx sc/source/core/data/global.cxx sc/source/core/tool/chgtrack.cxx sc/source/core/tool/compiler.cxx sc/source/filter/excel/xestyle.cxx sc/source/filter/excel/xichart.cxx sc/source/filter/inc/fapihelper.hxx sc/source/filter/inc/xistyle.hxx sc/source/filter/xml/xmlsubti.cxx sc/source/ui/Accessibility/AccessibleCell.cxx sc/source/ui/Accessibility/AccessibleContextBase.cxx sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx sc/source/ui/Accessibility/AccessibleEditObject.cxx sc/source/ui/Accessibility/AccessiblePreviewCell.cxx sc/source/ui/app/inputwin.cxx sc/source/ui/docshell/docfunc.cxx sc/source/ui/drawfunc/fupoor.cxx sc/source/ui/miscdlgs/linkarea.cxx sc/source/ui/unoobj/chart2uno.cxx sc/source/ui/unoobj/nameuno.cxx sc/source/ui/vba/vbacharacters.hxx sc/source/ui/vba/vbarange.cxx sc/source/ui/vba/vbawindow.cxx scaddins/source/analysis/analysishelper.cxx scaddins/source/analysis/analysishelper.hxx scaddins/source/datefunc/datefunc.cxx scripting/examples/python/Capitalise.py scripting/source/pyprov/officehelper.py sd/source/filter/eppt/eppt.cxx sd/source/filter/eppt/epptso.cxx sd/source/ui/dlg/prltempl.cxx sd/source/ui/dlg/tpoption.cxx sd/source/ui/func/fuediglu.cxx sd/source/ui/func/fupoor.cxx sd/source/ui/func/fusel.cxx sd/source/ui/func/smarttag.cxx sd/source/ui/inc/OutlinerIteratorImpl.hxx sd/source/ui/inc/SlideViewShell.hxx sd/source/ui/inc/fuediglu.hxx sd/source/ui/inc/fusel.hxx sd/source/ui/slideshow/slideshowimpl.cxx sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx sd/source/ui/slidesorter/controller/SlsSelectionCommand.hxx sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx sd/source/ui/slidesorter/view/SlsButtonBar.cxx sd/source/ui/view/Outliner.cxx sd/source/ui/view/drviewsh.cxx sd/source/ui/view/frmview.cxx sdext/source/presenter/PresenterFrameworkObserver.hxx sdext/source/presenter/PresenterSlideShowView.cxx setup_native/scripts/deregister_extensions setup_native/scripts/register_extensions setup_native/source/opensolaris/bundledextensions/README setup_native/source/opensolaris/bundledextensions/svc-ooo_bundled_extensions setup_native/source/win32/customactions/patch/swappatchfiles.cxx setup_native/source/win32/customactions/reg4msdoc/registrar.cxx setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx sfx2/inc/sfx2/sfxbasemodel.hxx sfx2/qa/complex/sfx2/DocumentProperties.java sfx2/source/appl/appopen.cxx sfx2/source/appl/appquit.cxx sfx2/source/appl/appserv.cxx sfx2/source/bastyp/sfxhtml.cxx sfx2/source/dialog/dockwin.cxx sfx2/source/doc/docfile.cxx sfx2/source/doc/docvor.cxx sfx2/source/doc/graphhelp.cxx sfx2/source/doc/objcont.cxx sfx2/source/doc/objserv.cxx sfx2/source/doc/objstor.cxx sfx2/source/doc/objuno.cxx sfx2/source/doc/objxtor.cxx sfx2/source/doc/printhelper.cxx sfx2/source/doc/sfxbasemodel.cxx sfx2/source/notify/eventsupplier.cxx sfx2/source/view/frmload.cxx sfx2/source/view/sfxbasecontroller.cxx shell/qa/zip/ziptest.cxx shell/source/backends/wininetbe/wininetbackend.cxx shell/source/win32/shlxthandler/util/utilities.cxx solenv/bin/build.pl solenv/bin/build_release.pl solenv/bin/cws.pl solenv/bin/download_external_dependencies.pl solenv/bin/make_download.pl solenv/bin/make_installer.pl solenv/bin/modules/Cws.pm solenv/bin/modules/ExtensionsLst.pm solenv/bin/modules/installer/control.pm solenv/bin/modules/installer/downloadsigner.pm solenv/bin/modules/installer/javainstaller.pm solenv/bin/modules/installer/packagepool.pm solenv/bin/modules/installer/patch/InstallationSet.pm solenv/bin/modules/installer/scriptitems.pm solenv/bin/modules/installer/windows/feature.pm solenv/bin/modules/installer/windows/msiglobal.pm solenv/bin/modules/installer/windows/sign.pm solenv/bin/modules/installer/worker.pm solenv/bin/modules/installer/xpdinstaller.pm solenv/bin/modules/osarch.pm solenv/bin/modules/packager/work.pm solenv/bin/modules/pre2par/parameter.pm solenv/bin/patch_tool.pl solenv/bin/transform_description.pl solenv/doc/gbuild/doxygen.cfg solenv/gbuild/LinkTarget.mk solenv/gbuild/gbuild.mk solenv/inc/os2gcci.mk solenv/inc/settings.mk solenv/inc/startup/Readme solenv/inc/target.mk solenv/inc/tg_compv.mk solenv/inc/tg_javav.mk solenv/inc/unitools.mk solenv/inc/unxbsdi.mk solenv/inc/unxbsdi2.mk solenv/inc/unxbsds.mk solenv/inc/unxfbsd.mk solenv/inc/unxlng.mk sot/source/sdstor/stg.cxx sot/source/sdstor/stgelem.cxx sot/source/sdstor/ucbstorage.cxx starmath/inc/toolbox.hxx starmath/source/mathmlexport.cxx starmath/source/node.cxx starmath/source/toolbox.cxx starmath/source/view.cxx stoc/source/bootstrap/bootstrap.xml stoc/source/corereflection/criface.cxx stoc/source/invocation/invocation.cxx stoc/source/security/access_controller.cxx stoc/source/servicemanager/servicemanager.cxx stoc/source/tdmanager/tdmgr.cxx stoc/test/javavm/testjavavm.cxx stoc/test/testconv.cxx stoc/test/testcorefl.cxx stoc/test/testintrosp.cxx svl/inc/svl/inettype.hxx svl/inc/svl/urihelper.hxx svl/qa/complex/ConfigItems/helper/HistoryOptTest.cxx svl/qa/complex/ConfigItems/helper/HistoryOptTest.hxx svl/source/config/itemholder2.hxx svl/source/items/itemset.cxx svl/source/numbers/zforlist.cxx svl/source/numbers/zformat.cxx svl/source/numbers/zforscan.cxx svtools/bmpmaker/bmp.cxx svtools/inc/svtools/helpagentwindow.hxx svtools/inc/svtools/menuoptions.hxx svtools/inc/svtools/miscopt.hxx svtools/inc/svtools/optionsdrawinglayer.hxx svtools/inc/svtools/stringtransfer.hxx svtools/inc/svtools/svlbitm.hxx svtools/inc/svtools/svtdata.hxx svtools/inc/svtools/valueset.hxx svtools/source/brwbox/editbrowsebox.cxx svtools/source/config/itemholder2.hxx svtools/source/contnr/contentenumeration.hxx svx/inc/svx/fmsrcimp.hxx svx/inc/svx/svdobj.hxx svx/inc/svx/xtable.hxx svx/source/accessibility/DGColorNameLookUp.cxx svx/source/accessibility/svxrectctaccessiblecontext.cxx svx/source/dialog/pfiledlg.cxx svx/source/fmcomp/fmgridcl.cxx svx/source/fmcomp/fmgridif.cxx svx/source/fmcomp/gridctrl.cxx svx/source/form/filtnav.cxx svx/source/form/fmPropBrw.cxx svx/source/form/fmshimp.cxx svx/source/form/fmsrcimp.cxx svx/source/gallery2/galtheme.cxx svx/source/inc/docrecovery.hxx svx/source/sdr/event/eventhandler.cxx svx/source/svdraw/svdedtv2.cxx svx/source/svdraw/svdedxv.cxx svx/source/svdraw/svdhdl.cxx svx/source/svdraw/svdobj.cxx svx/source/svdraw/svdograf.cxx svx/source/svdraw/svdoole2.cxx svx/source/svdraw/svdotxtr.cxx svx/source/svdraw/svdundo.cxx svx/source/svdraw/svdxcgv.cxx svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx sw/inc/SwNumberTree.hxx sw/inc/ndnotxt.hxx sw/source/core/access/acccell.cxx sw/source/core/access/acccell.hxx sw/source/core/access/accframebase.cxx sw/source/core/access/accframebase.hxx sw/source/core/access/accmap.cxx sw/source/core/access/accpage.cxx sw/source/core/access/accpage.hxx sw/source/core/access/accpara.cxx sw/source/core/access/accpara.hxx sw/source/core/bastyp/swrect.cxx sw/source/core/crsr/findtxt.cxx sw/source/core/doc/docdde.cxx sw/source/core/doc/notxtfrm.cxx sw/source/core/docnode/section.cxx sw/source/core/draw/dcontact.cxx sw/source/core/edit/edlingu.cxx sw/source/core/inc/anchoredobjectposition.hxx sw/source/core/layout/paintfrm.cxx sw/source/core/layout/tabfrm.cxx sw/source/core/layout/trvlfrm.cxx sw/source/core/ole/ndole.cxx sw/source/core/text/atrstck.cxx sw/source/core/text/inftxt.cxx sw/source/core/text/itratr.cxx sw/source/core/text/itrform2.cxx sw/source/core/text/itrform2.hxx sw/source/core/text/porfld.cxx sw/source/core/text/txtfly.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txtedt.cxx sw/source/core/uibase/dochdl/swdtflvr.cxx sw/source/core/uibase/docvw/PostItMgr.cxx sw/source/core/uibase/docvw/SidebarWin.cxx sw/source/core/uibase/docvw/edtwin.cxx sw/source/core/uibase/envelp/labimg.cxx sw/source/core/uibase/uiview/pview.cxx sw/source/core/uibase/uno/unomailmerge.cxx sw/source/core/undo/unattr.cxx sw/source/core/undo/untbl.cxx sw/source/core/unocore/unochart.cxx sw/source/core/view/vdraw.cxx sw/source/core/view/vnew.cxx sw/source/filter/basflt/fltini.cxx sw/source/filter/html/wrthtml.cxx sw/source/filter/inc/wwstyles.hxx sw/source/filter/rtf/rtffly.cxx sw/source/filter/rtf/swparrtf.cxx sw/source/filter/ww8/docxattributeoutput.cxx sw/source/filter/ww8/dump/msvbasic.cxx sw/source/filter/ww8/dump/ww8scan.cxx sw/source/filter/ww8/dump/ww8scan.hxx sw/source/filter/ww8/dump/ww8struc.hxx sw/source/filter/ww8/wrtww8.cxx sw/source/filter/ww8/ww8graf.cxx sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par2.cxx sw/source/filter/ww8/ww8par2.hxx sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par6.cxx sw/source/filter/ww8/ww8scan.cxx sw/source/filter/ww8/ww8scan.hxx sw/source/ui/dbui/dbinsdlg.cxx sw/source/ui/inc/tablemgr.hxx sw/source/ui/inc/uitool.hxx sw/source/ui/lingu/olmenu.cxx sw/source/ui/uiview/viewport.cxx sysui/desktop/productversion.mk sysui/desktop/slackware/makefile.mk testgraphical/source/CallExternals.pm testgraphical/source/fill_documents_loop.pl testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java toolkit/doc/layout/notes.txt toolkit/doc/layout/oldnotes.txt toolkit/source/awt/vclxtabcontrol.cxx toolkit/src2xml/source/srcparser.py toolkit/workben/layout/editor.cxx tools/inc/tools/simplerm.hxx tools/inc/tools/solar.h tools/source/communi/geninfo.cxx tools/source/fsys/dirent.cxx tools/source/fsys/filecopy.cxx tools/source/fsys/os2.cxx tools/source/inet/inetmime.cxx tools/source/rc/resmgr.cxx ucb/source/core/ucbcmds.cxx ucb/source/ucp/file/filglob.cxx ucb/source/ucp/odma/odma_content.cxx ucb/source/ucp/tdoc/ucptdoc.xml ucb/source/ucp/webdav/makefile.mk ucbhelper/inc/ucbhelper/simplecertificatevalidationrequest.hxx ucbhelper/source/client/content.cxx ucbhelper/source/client/interceptedinteraction.cxx udkapi/com/sun/star/beans/XPropertiesChangeListener.idl udkapi/com/sun/star/io/ObjectOutputStream.idl udkapi/com/sun/star/io/XMarkableStream.idl udkapi/com/sun/star/io/XTextOutputStream.idl udkapi/com/sun/star/reflection/CoreReflection.idl udkapi/com/sun/star/reflection/XTypeDescriptionEnumerationAccess.idl udkapi/com/sun/star/test/XSimpleTest.idl unodevtools/source/skeletonmaker/skeletoncommon.cxx unodevtools/source/skeletonmaker/skeletoncommon.hxx unotools/inc/unotools/cacheoptions.hxx unotools/inc/unotools/cmdoptions.hxx unotools/inc/unotools/dynamicmenuoptions.hxx unotools/inc/unotools/extendedsecurityoptions.hxx unotools/inc/unotools/fontoptions.hxx unotools/inc/unotools/historyoptions.hxx unotools/inc/unotools/idhelper.hxx unotools/inc/unotools/internaloptions.hxx unotools/inc/unotools/localisationoptions.hxx unotools/inc/unotools/moduleoptions.hxx unotools/inc/unotools/printwarningoptions.hxx unotools/inc/unotools/securityoptions.hxx unotools/inc/unotools/startoptions.hxx unotools/inc/unotools/workingsetoptions.hxx unotools/source/config/cmdoptions.cxx unotools/source/config/compatibility.cxx unotools/source/config/configitem.cxx unotools/source/config/configmgr.cxx unotools/source/config/dynamicmenuoptions.cxx unotools/source/config/fontcfg.cxx unotools/source/config/itemholder1.hxx unotools/source/config/moduleoptions.cxx unotools/source/config/pathoptions.cxx unotools/source/config/viewoptions.cxx unotools/source/misc/sharedunocomponent.cxx uui/source/fltdlg.cxx uui/source/iahndl-filter.cxx vbahelper/inc/vbahelper/collectionbase.hxx vbahelper/source/msforms/vbacontrol.cxx vbahelper/source/vbahelper/collectionbase.cxx vcl/aqua/source/gdi/atsfonts.cxx vcl/inc/aqua/salmathutils.hxx vcl/inc/graphite_cache.hxx vcl/inc/jobset.h vcl/inc/os2/salgdi.h vcl/inc/osx/saldata.hxx vcl/inc/salgdi.hxx vcl/inc/salwtype.hxx vcl/inc/unx/wmadaptor.hxx vcl/inc/vcl/print.hxx vcl/inc/vcl/strhelper.hxx vcl/os2/source/app/salinst.cxx vcl/os2/source/app/saltimer.cxx vcl/os2/source/gdi/salgdi2.cxx vcl/osx/salframeview.mm vcl/osx/salprn.cxx vcl/qa/cppunit/dndtest.cxx vcl/source/app/dbggui.cxx vcl/source/control/ilstbox.cxx vcl/source/gdi/cvtsvm.cxx vcl/source/gdi/gdimtf.cxx vcl/source/gdi/outdev4.cxx vcl/source/gdi/outdev6.cxx vcl/source/gdi/pdfwriter_impl.cxx vcl/source/gdi/pdfwriter_impl2.cxx vcl/source/gdi/print.cxx vcl/source/gdi/print2.cxx vcl/source/glyphs/gcach_layout.cxx vcl/source/glyphs/glyphcache.cxx vcl/source/glyphs/graphite_layout.cxx vcl/source/window/printdlg.cxx vcl/source/window/tabdlg.cxx vcl/source/window/window.cxx vcl/source/window/winproc.cxx vcl/unx/generic/app/saldisp.cxx vcl/unx/generic/dtrans/X11_selection.hxx vcl/unx/gtk/app/gtkdata.cxx vcl/win/source/gdi/salgdi2.cxx vcl/win/source/gdi/salgdi3.cxx vcl/win/source/window/salframe.cxx vos/inc/vos/pipe.hxx vos/inc/vos/process.hxx vos/inc/vos/signal.hxx vos/inc/vos/socket.hxx vos/inc/vos/thread.hxx vos/source/pipe.cxx vos/source/socket.cxx wizards/com/sun/star/wizards/agenda/AgendaTemplate.java wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java wizards/com/sun/star/wizards/agenda/TopicsControl.java wizards/com/sun/star/wizards/web/FTPDialog.java wizards/com/sun/star/wizards/web/ImageListDialog.java wizards/com/sun/star/wizards/web/Process.java wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java wizards/com/sun/star/wizards/web/TOCPreview.java wizards/com/sun/star/wizards/web/WWD_Startup.java wizards/com/sun/star/wizards/web/data/TypeDetection.java wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java writerfilter/inc/doctok/WW8Document.hxx writerfilter/source/dmapper/DomainMapper.cxx writerfilter/source/dmapper/NumberingManager.cxx writerfilter/source/dmapper/PropertyMap.cxx writerfilter/source/dmapper/StyleSheetTable.cxx writerfilter/source/doctok/WW8StructBase.hxx writerfilter/source/doctok/resources.xmi writerfilter/source/ooxml/README.efforts xmerge/source/activesync/XMergeFilter.cpp xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java xmerge/source/palmtests/qa/comparator/pdbcomparison.java xmerge/source/palmtests/qa/test_spec/convertor_test_spec.html xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java xmerge/workben/jstyle.pl xmlhelp/source/cxxhelp/provider/databases.hxx xmlhelp/source/cxxhelp/provider/provider.cxx xmlhelp/source/treeview/tvread.cxx xmloff/inc/txtfldi.hxx xmloff/inc/xmloff/xmlmultiimagehelper.hxx xmloff/inc/xmloff/xmluconv.hxx xmloff/source/core/xmlexp.cxx xmloff/source/draw/shapeexport2.cxx xmloff/source/draw/shapeexport3.cxx xmloff/source/meta/xmlversion.cxx xmloff/source/style/impastp4.cxx xmloff/source/style/xmlaustp.cxx xmloff/source/text/XMLSectionExport.cxx xmloff/source/text/txtflde.cxx xmloff/source/text/txtimp.cxx xmloff/source/text/txtparae.cxx xmloff/source/text/txtparai.cxx xmloff/source/text/txtvfldi.cxx xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx Change-Id: Ie072e7c3a60c5dae16a67ac36d1f372c5065c99c
2014-04-29 19:25:03 +00:00
// ensure InternalResMgr existence
if( ! it->second.pResMgr )
{
InternalResMgr* pImp =
new InternalResMgr( it->second.aFileURL, rPrefix, it->first, aLocale );
if( ! pImp->Create() )
{
delete pImp;
continue;
}
it->second.pResMgr = pImp;
}
break;
}
}
// try if there is anything with this prefix at all
if( it == m_aResFiles.end() )
{
aLocale.reset( LANGUAGE_SYSTEM);
it = m_aResFiles.find( rPrefix );
if( it == m_aResFiles.end() )
{
for( it = m_aResFiles.begin(); it != m_aResFiles.end(); ++it )
{
if( it->first.matchIgnoreAsciiCase( rPrefix ) )
{
Many spelling fixes: directories r* - z*. Attempt to clean up most but certainly not all the spelling mistakes that found home in OpenOffice through decades. We could probably blame the international nature of the code but it is somewhat shameful that this wasn't done before. (cherry picked from commit 28206a7cb43aff5adb10f8235ad1680c3941ee3e) Conflicts: include/osl/file.hxx include/osl/pipe_decl.hxx include/osl/socket.h include/osl/socket_decl.hxx include/sal/main.h include/svx/dbaexchange.hxx include/svx/dlgctrl.hxx include/svx/msdffdef.hxx include/svx/sdr/contact/objectcontactofpageview.hxx include/svx/svdpntv.hxx include/ucbhelper/content.hxx include/ucbhelper/interceptedinteraction.hxx include/ucbhelper/resultsethelper.hxx include/unotools/sharedunocomponent.hxx include/unotools/viewoptions.hxx include/vcl/pdfwriter.hxx include/xmloff/txtparae.hxx include/xmloff/uniref.hxx rhino/rhino1_7R3.patch rsc/inc/rscrsc.hxx sal/inc/osl/conditn.h sal/inc/osl/security.h sal/inc/osl/semaphor.h sal/inc/osl/semaphor.hxx sal/inc/rtl/string.hxx sal/inc/rtl/tres.h sal/inc/systools/win32/StrConvert.h sal/osl/os2/file_path_helper.h sal/osl/os2/file_path_helper.hxx sal/osl/os2/file_url.cxx sal/osl/os2/file_url.h sal/osl/os2/makefile.mk sal/osl/os2/pipe.cxx sal/osl/os2/process.c sal/osl/os2/profile.c sal/osl/os2/socket.c sal/osl/os2/system.h sal/osl/unx/asm/interlck_sparc.s sal/osl/unx/file_url.cxx sal/osl/unx/signal.c sal/osl/unx/system.h sal/osl/w32/MAKEFILE.MK sal/osl/w32/interlck.c sal/osl/w32/module.cxx sal/osl/w32/security.c sal/qa/buildall.pl sal/qa/osl/file/osl_File.cxx sal/qa/osl/module/osl_Module_Const.h sal/qa/osl/mutex/osl_Mutex.cxx sal/qa/osl/pipe/osl_Pipe.cxx sal/qa/osl/process/osl_Thread.cxx sal/qa/osl/socket/osl_StreamSocket.cxx sal/qa/osl/socket/sockethelper.cxx sal/qa/rtl_strings/rtl_OUString.cxx sal/rtl/source/unload.cxx sal/systools/win32/kill/kill.cxx sal/systools/win32/uwinapi/MoveFileExA.cpp sal/test/bootstrap.pl sal/typesconfig/typesconfig.c sal/workben/tgetpwnam.cxx sax/inc/sax/parser/saxparser.hxx sc/addin/datefunc/dfa.cl sc/addin/datefunc/dfa.src sc/addin/rot13/rot13.cl sc/addin/rot13/rot13.src sc/inc/attarray.hxx sc/inc/chgtrack.hxx sc/inc/column.hxx sc/inc/compressedarray.hxx sc/inc/document.hxx sc/inc/table.hxx sc/source/core/data/column.cxx sc/source/core/data/dptablecache.cxx sc/source/core/data/dptabres.cxx sc/source/core/data/dptabsrc.cxx sc/source/core/data/global.cxx sc/source/core/tool/chgtrack.cxx sc/source/core/tool/compiler.cxx sc/source/filter/excel/xestyle.cxx sc/source/filter/excel/xichart.cxx sc/source/filter/inc/fapihelper.hxx sc/source/filter/inc/xistyle.hxx sc/source/filter/xml/xmlsubti.cxx sc/source/ui/Accessibility/AccessibleCell.cxx sc/source/ui/Accessibility/AccessibleContextBase.cxx sc/source/ui/Accessibility/AccessibleDataPilotControl.cxx sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx sc/source/ui/Accessibility/AccessibleEditObject.cxx sc/source/ui/Accessibility/AccessiblePreviewCell.cxx sc/source/ui/app/inputwin.cxx sc/source/ui/docshell/docfunc.cxx sc/source/ui/drawfunc/fupoor.cxx sc/source/ui/miscdlgs/linkarea.cxx sc/source/ui/unoobj/chart2uno.cxx sc/source/ui/unoobj/nameuno.cxx sc/source/ui/vba/vbacharacters.hxx sc/source/ui/vba/vbarange.cxx sc/source/ui/vba/vbawindow.cxx scaddins/source/analysis/analysishelper.cxx scaddins/source/analysis/analysishelper.hxx scaddins/source/datefunc/datefunc.cxx scripting/examples/python/Capitalise.py scripting/source/pyprov/officehelper.py sd/source/filter/eppt/eppt.cxx sd/source/filter/eppt/epptso.cxx sd/source/ui/dlg/prltempl.cxx sd/source/ui/dlg/tpoption.cxx sd/source/ui/func/fuediglu.cxx sd/source/ui/func/fupoor.cxx sd/source/ui/func/fusel.cxx sd/source/ui/func/smarttag.cxx sd/source/ui/inc/OutlinerIteratorImpl.hxx sd/source/ui/inc/SlideViewShell.hxx sd/source/ui/inc/fuediglu.hxx sd/source/ui/inc/fusel.hxx sd/source/ui/slideshow/slideshowimpl.cxx sd/source/ui/slidesorter/cache/SlsQueueProcessorThread.hxx sd/source/ui/slidesorter/controller/SlsHideSlideFunction.cxx sd/source/ui/slidesorter/controller/SlsSelectionCommand.hxx sd/source/ui/slidesorter/inc/controller/SlsAnimationFunction.hxx sd/source/ui/slidesorter/view/SlsButtonBar.cxx sd/source/ui/view/Outliner.cxx sd/source/ui/view/drviewsh.cxx sd/source/ui/view/frmview.cxx sdext/source/presenter/PresenterFrameworkObserver.hxx sdext/source/presenter/PresenterSlideShowView.cxx setup_native/scripts/deregister_extensions setup_native/scripts/register_extensions setup_native/source/opensolaris/bundledextensions/README setup_native/source/opensolaris/bundledextensions/svc-ooo_bundled_extensions setup_native/source/win32/customactions/patch/swappatchfiles.cxx setup_native/source/win32/customactions/reg4msdoc/registrar.cxx setup_native/source/win32/customactions/reg4msdoc/userregistrar.cxx sfx2/inc/sfx2/sfxbasemodel.hxx sfx2/qa/complex/sfx2/DocumentProperties.java sfx2/source/appl/appopen.cxx sfx2/source/appl/appquit.cxx sfx2/source/appl/appserv.cxx sfx2/source/bastyp/sfxhtml.cxx sfx2/source/dialog/dockwin.cxx sfx2/source/doc/docfile.cxx sfx2/source/doc/docvor.cxx sfx2/source/doc/graphhelp.cxx sfx2/source/doc/objcont.cxx sfx2/source/doc/objserv.cxx sfx2/source/doc/objstor.cxx sfx2/source/doc/objuno.cxx sfx2/source/doc/objxtor.cxx sfx2/source/doc/printhelper.cxx sfx2/source/doc/sfxbasemodel.cxx sfx2/source/notify/eventsupplier.cxx sfx2/source/view/frmload.cxx sfx2/source/view/sfxbasecontroller.cxx shell/qa/zip/ziptest.cxx shell/source/backends/wininetbe/wininetbackend.cxx shell/source/win32/shlxthandler/util/utilities.cxx solenv/bin/build.pl solenv/bin/build_release.pl solenv/bin/cws.pl solenv/bin/download_external_dependencies.pl solenv/bin/make_download.pl solenv/bin/make_installer.pl solenv/bin/modules/Cws.pm solenv/bin/modules/ExtensionsLst.pm solenv/bin/modules/installer/control.pm solenv/bin/modules/installer/downloadsigner.pm solenv/bin/modules/installer/javainstaller.pm solenv/bin/modules/installer/packagepool.pm solenv/bin/modules/installer/patch/InstallationSet.pm solenv/bin/modules/installer/scriptitems.pm solenv/bin/modules/installer/windows/feature.pm solenv/bin/modules/installer/windows/msiglobal.pm solenv/bin/modules/installer/windows/sign.pm solenv/bin/modules/installer/worker.pm solenv/bin/modules/installer/xpdinstaller.pm solenv/bin/modules/osarch.pm solenv/bin/modules/packager/work.pm solenv/bin/modules/pre2par/parameter.pm solenv/bin/patch_tool.pl solenv/bin/transform_description.pl solenv/doc/gbuild/doxygen.cfg solenv/gbuild/LinkTarget.mk solenv/gbuild/gbuild.mk solenv/inc/os2gcci.mk solenv/inc/settings.mk solenv/inc/startup/Readme solenv/inc/target.mk solenv/inc/tg_compv.mk solenv/inc/tg_javav.mk solenv/inc/unitools.mk solenv/inc/unxbsdi.mk solenv/inc/unxbsdi2.mk solenv/inc/unxbsds.mk solenv/inc/unxfbsd.mk solenv/inc/unxlng.mk sot/source/sdstor/stg.cxx sot/source/sdstor/stgelem.cxx sot/source/sdstor/ucbstorage.cxx starmath/inc/toolbox.hxx starmath/source/mathmlexport.cxx starmath/source/node.cxx starmath/source/toolbox.cxx starmath/source/view.cxx stoc/source/bootstrap/bootstrap.xml stoc/source/corereflection/criface.cxx stoc/source/invocation/invocation.cxx stoc/source/security/access_controller.cxx stoc/source/servicemanager/servicemanager.cxx stoc/source/tdmanager/tdmgr.cxx stoc/test/javavm/testjavavm.cxx stoc/test/testconv.cxx stoc/test/testcorefl.cxx stoc/test/testintrosp.cxx svl/inc/svl/inettype.hxx svl/inc/svl/urihelper.hxx svl/qa/complex/ConfigItems/helper/HistoryOptTest.cxx svl/qa/complex/ConfigItems/helper/HistoryOptTest.hxx svl/source/config/itemholder2.hxx svl/source/items/itemset.cxx svl/source/numbers/zforlist.cxx svl/source/numbers/zformat.cxx svl/source/numbers/zforscan.cxx svtools/bmpmaker/bmp.cxx svtools/inc/svtools/helpagentwindow.hxx svtools/inc/svtools/menuoptions.hxx svtools/inc/svtools/miscopt.hxx svtools/inc/svtools/optionsdrawinglayer.hxx svtools/inc/svtools/stringtransfer.hxx svtools/inc/svtools/svlbitm.hxx svtools/inc/svtools/svtdata.hxx svtools/inc/svtools/valueset.hxx svtools/source/brwbox/editbrowsebox.cxx svtools/source/config/itemholder2.hxx svtools/source/contnr/contentenumeration.hxx svx/inc/svx/fmsrcimp.hxx svx/inc/svx/svdobj.hxx svx/inc/svx/xtable.hxx svx/source/accessibility/DGColorNameLookUp.cxx svx/source/accessibility/svxrectctaccessiblecontext.cxx svx/source/dialog/pfiledlg.cxx svx/source/fmcomp/fmgridcl.cxx svx/source/fmcomp/fmgridif.cxx svx/source/fmcomp/gridctrl.cxx svx/source/form/filtnav.cxx svx/source/form/fmPropBrw.cxx svx/source/form/fmshimp.cxx svx/source/form/fmsrcimp.cxx svx/source/gallery2/galtheme.cxx svx/source/inc/docrecovery.hxx svx/source/sdr/event/eventhandler.cxx svx/source/svdraw/svdedtv2.cxx svx/source/svdraw/svdedxv.cxx svx/source/svdraw/svdhdl.cxx svx/source/svdraw/svdobj.cxx svx/source/svdraw/svdograf.cxx svx/source/svdraw/svdoole2.cxx svx/source/svdraw/svdotxtr.cxx svx/source/svdraw/svdundo.cxx svx/source/svdraw/svdxcgv.cxx svx/source/unodialogs/textconversiondlgs/chinese_translationdialog.cxx sw/inc/SwNumberTree.hxx sw/inc/ndnotxt.hxx sw/source/core/access/acccell.cxx sw/source/core/access/acccell.hxx sw/source/core/access/accframebase.cxx sw/source/core/access/accframebase.hxx sw/source/core/access/accmap.cxx sw/source/core/access/accpage.cxx sw/source/core/access/accpage.hxx sw/source/core/access/accpara.cxx sw/source/core/access/accpara.hxx sw/source/core/bastyp/swrect.cxx sw/source/core/crsr/findtxt.cxx sw/source/core/doc/docdde.cxx sw/source/core/doc/notxtfrm.cxx sw/source/core/docnode/section.cxx sw/source/core/draw/dcontact.cxx sw/source/core/edit/edlingu.cxx sw/source/core/inc/anchoredobjectposition.hxx sw/source/core/layout/paintfrm.cxx sw/source/core/layout/tabfrm.cxx sw/source/core/layout/trvlfrm.cxx sw/source/core/ole/ndole.cxx sw/source/core/text/atrstck.cxx sw/source/core/text/inftxt.cxx sw/source/core/text/itratr.cxx sw/source/core/text/itrform2.cxx sw/source/core/text/itrform2.hxx sw/source/core/text/porfld.cxx sw/source/core/text/txtfly.cxx sw/source/core/txtnode/thints.cxx sw/source/core/txtnode/txtedt.cxx sw/source/core/uibase/dochdl/swdtflvr.cxx sw/source/core/uibase/docvw/PostItMgr.cxx sw/source/core/uibase/docvw/SidebarWin.cxx sw/source/core/uibase/docvw/edtwin.cxx sw/source/core/uibase/envelp/labimg.cxx sw/source/core/uibase/uiview/pview.cxx sw/source/core/uibase/uno/unomailmerge.cxx sw/source/core/undo/unattr.cxx sw/source/core/undo/untbl.cxx sw/source/core/unocore/unochart.cxx sw/source/core/view/vdraw.cxx sw/source/core/view/vnew.cxx sw/source/filter/basflt/fltini.cxx sw/source/filter/html/wrthtml.cxx sw/source/filter/inc/wwstyles.hxx sw/source/filter/rtf/rtffly.cxx sw/source/filter/rtf/swparrtf.cxx sw/source/filter/ww8/docxattributeoutput.cxx sw/source/filter/ww8/dump/msvbasic.cxx sw/source/filter/ww8/dump/ww8scan.cxx sw/source/filter/ww8/dump/ww8scan.hxx sw/source/filter/ww8/dump/ww8struc.hxx sw/source/filter/ww8/wrtww8.cxx sw/source/filter/ww8/ww8graf.cxx sw/source/filter/ww8/ww8par.cxx sw/source/filter/ww8/ww8par2.cxx sw/source/filter/ww8/ww8par2.hxx sw/source/filter/ww8/ww8par3.cxx sw/source/filter/ww8/ww8par6.cxx sw/source/filter/ww8/ww8scan.cxx sw/source/filter/ww8/ww8scan.hxx sw/source/ui/dbui/dbinsdlg.cxx sw/source/ui/inc/tablemgr.hxx sw/source/ui/inc/uitool.hxx sw/source/ui/lingu/olmenu.cxx sw/source/ui/uiview/viewport.cxx sysui/desktop/productversion.mk sysui/desktop/slackware/makefile.mk testgraphical/source/CallExternals.pm testgraphical/source/fill_documents_loop.pl testgraphical/ui/java/ConvwatchGUIProject/src/IniFile.java toolkit/doc/layout/notes.txt toolkit/doc/layout/oldnotes.txt toolkit/source/awt/vclxtabcontrol.cxx toolkit/src2xml/source/srcparser.py toolkit/workben/layout/editor.cxx tools/inc/tools/simplerm.hxx tools/inc/tools/solar.h tools/source/communi/geninfo.cxx tools/source/fsys/dirent.cxx tools/source/fsys/filecopy.cxx tools/source/fsys/os2.cxx tools/source/inet/inetmime.cxx tools/source/rc/resmgr.cxx ucb/source/core/ucbcmds.cxx ucb/source/ucp/file/filglob.cxx ucb/source/ucp/odma/odma_content.cxx ucb/source/ucp/tdoc/ucptdoc.xml ucb/source/ucp/webdav/makefile.mk ucbhelper/inc/ucbhelper/simplecertificatevalidationrequest.hxx ucbhelper/source/client/content.cxx ucbhelper/source/client/interceptedinteraction.cxx udkapi/com/sun/star/beans/XPropertiesChangeListener.idl udkapi/com/sun/star/io/ObjectOutputStream.idl udkapi/com/sun/star/io/XMarkableStream.idl udkapi/com/sun/star/io/XTextOutputStream.idl udkapi/com/sun/star/reflection/CoreReflection.idl udkapi/com/sun/star/reflection/XTypeDescriptionEnumerationAccess.idl udkapi/com/sun/star/test/XSimpleTest.idl unodevtools/source/skeletonmaker/skeletoncommon.cxx unodevtools/source/skeletonmaker/skeletoncommon.hxx unotools/inc/unotools/cacheoptions.hxx unotools/inc/unotools/cmdoptions.hxx unotools/inc/unotools/dynamicmenuoptions.hxx unotools/inc/unotools/extendedsecurityoptions.hxx unotools/inc/unotools/fontoptions.hxx unotools/inc/unotools/historyoptions.hxx unotools/inc/unotools/idhelper.hxx unotools/inc/unotools/internaloptions.hxx unotools/inc/unotools/localisationoptions.hxx unotools/inc/unotools/moduleoptions.hxx unotools/inc/unotools/printwarningoptions.hxx unotools/inc/unotools/securityoptions.hxx unotools/inc/unotools/startoptions.hxx unotools/inc/unotools/workingsetoptions.hxx unotools/source/config/cmdoptions.cxx unotools/source/config/compatibility.cxx unotools/source/config/configitem.cxx unotools/source/config/configmgr.cxx unotools/source/config/dynamicmenuoptions.cxx unotools/source/config/fontcfg.cxx unotools/source/config/itemholder1.hxx unotools/source/config/moduleoptions.cxx unotools/source/config/pathoptions.cxx unotools/source/config/viewoptions.cxx unotools/source/misc/sharedunocomponent.cxx uui/source/fltdlg.cxx uui/source/iahndl-filter.cxx vbahelper/inc/vbahelper/collectionbase.hxx vbahelper/source/msforms/vbacontrol.cxx vbahelper/source/vbahelper/collectionbase.cxx vcl/aqua/source/gdi/atsfonts.cxx vcl/inc/aqua/salmathutils.hxx vcl/inc/graphite_cache.hxx vcl/inc/jobset.h vcl/inc/os2/salgdi.h vcl/inc/osx/saldata.hxx vcl/inc/salgdi.hxx vcl/inc/salwtype.hxx vcl/inc/unx/wmadaptor.hxx vcl/inc/vcl/print.hxx vcl/inc/vcl/strhelper.hxx vcl/os2/source/app/salinst.cxx vcl/os2/source/app/saltimer.cxx vcl/os2/source/gdi/salgdi2.cxx vcl/osx/salframeview.mm vcl/osx/salprn.cxx vcl/qa/cppunit/dndtest.cxx vcl/source/app/dbggui.cxx vcl/source/control/ilstbox.cxx vcl/source/gdi/cvtsvm.cxx vcl/source/gdi/gdimtf.cxx vcl/source/gdi/outdev4.cxx vcl/source/gdi/outdev6.cxx vcl/source/gdi/pdfwriter_impl.cxx vcl/source/gdi/pdfwriter_impl2.cxx vcl/source/gdi/print.cxx vcl/source/gdi/print2.cxx vcl/source/glyphs/gcach_layout.cxx vcl/source/glyphs/glyphcache.cxx vcl/source/glyphs/graphite_layout.cxx vcl/source/window/printdlg.cxx vcl/source/window/tabdlg.cxx vcl/source/window/window.cxx vcl/source/window/winproc.cxx vcl/unx/generic/app/saldisp.cxx vcl/unx/generic/dtrans/X11_selection.hxx vcl/unx/gtk/app/gtkdata.cxx vcl/win/source/gdi/salgdi2.cxx vcl/win/source/gdi/salgdi3.cxx vcl/win/source/window/salframe.cxx vos/inc/vos/pipe.hxx vos/inc/vos/process.hxx vos/inc/vos/signal.hxx vos/inc/vos/socket.hxx vos/inc/vos/thread.hxx vos/source/pipe.cxx vos/source/socket.cxx wizards/com/sun/star/wizards/agenda/AgendaTemplate.java wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java wizards/com/sun/star/wizards/agenda/TopicsControl.java wizards/com/sun/star/wizards/web/FTPDialog.java wizards/com/sun/star/wizards/web/ImageListDialog.java wizards/com/sun/star/wizards/web/Process.java wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java wizards/com/sun/star/wizards/web/TOCPreview.java wizards/com/sun/star/wizards/web/WWD_Startup.java wizards/com/sun/star/wizards/web/data/TypeDetection.java wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java writerfilter/inc/doctok/WW8Document.hxx writerfilter/source/dmapper/DomainMapper.cxx writerfilter/source/dmapper/NumberingManager.cxx writerfilter/source/dmapper/PropertyMap.cxx writerfilter/source/dmapper/StyleSheetTable.cxx writerfilter/source/doctok/WW8StructBase.hxx writerfilter/source/doctok/resources.xmi writerfilter/source/ooxml/README.efforts xmerge/source/activesync/XMergeFilter.cpp xmerge/source/minicalc/java/org/openoffice/xmerge/converter/xml/sxc/minicalc/SxcDocumentDeserializerImpl.java xmerge/source/palmtests/qa/comparator/pdbcomparison.java xmerge/source/palmtests/qa/test_spec/convertor_test_spec.html xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/DefinedName.java xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Workbook.java xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/Worksheet.java xmerge/source/pexcel/java/org/openoffice/xmerge/converter/xml/sxc/pexcel/records/formula/SymbolLookup.java xmerge/source/pocketword/java/org/openoffice/xmerge/converter/xml/sxw/pocketword/DocumentDescriptor.java xmerge/workben/jstyle.pl xmlhelp/source/cxxhelp/provider/databases.hxx xmlhelp/source/cxxhelp/provider/provider.cxx xmlhelp/source/treeview/tvread.cxx xmloff/inc/txtfldi.hxx xmloff/inc/xmloff/xmlmultiimagehelper.hxx xmloff/inc/xmloff/xmluconv.hxx xmloff/source/core/xmlexp.cxx xmloff/source/draw/shapeexport2.cxx xmloff/source/draw/shapeexport3.cxx xmloff/source/meta/xmlversion.cxx xmloff/source/style/impastp4.cxx xmloff/source/style/xmlaustp.cxx xmloff/source/text/XMLSectionExport.cxx xmloff/source/text/txtflde.cxx xmloff/source/text/txtimp.cxx xmloff/source/text/txtparae.cxx xmloff/source/text/txtparai.cxx xmloff/source/text/txtvfldi.cxx xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx Change-Id: Ie072e7c3a60c5dae16a67ac36d1f372c5065c99c
2014-04-29 19:25:03 +00:00
// ensure InternalResMgr existence
if( ! it->second.pResMgr )
{
InternalResMgr* pImp =
new InternalResMgr( it->second.aFileURL,
rPrefix,
it->first,
aLocale );
if( ! pImp->Create() )
{
delete pImp;
continue;
}
it->second.pResMgr = pImp;
}
// try to guess locale
sal_Int32 nIndex = rPrefix.getLength();
if (nIndex < it->first.getLength())
aLocale.reset( it->first.copy( nIndex));
else
{
SAL_WARN( "tools.rc", "ResMgrContainer::getResMgr: it->first " <<
it->first << " shorter than prefix " << rPrefix);
}
break;
}
}
}
}
// give up
if( it == m_aResFiles.end() )
{
OUString sURL = rPrefix + rLocale.getBcp47() + ".res";
if ( m_aResFiles.find(sURL) == m_aResFiles.end() )
{
m_aResFiles[ sURL ].aFileURL = sURL;
return getResMgr(rPrefix,rLocale,bForceNewInstance);
} // if ( m_aResFiles.find(sURL) == m_aResFiles.end() )
return NULL;
}
rLocale = aLocale;
// at this point it->second.pResMgr must be filled either by creating a new one
// (then the refcount is still 0) or because we already had one
InternalResMgr* pImp = it->second.pResMgr;
if( it->second.nRefCount == 0 )
it->second.nLoadCount++;
// for SimpleResMgr
if( bForceNewInstance )
{
if( it->second.nRefCount == 0 )
{
// shortcut: the match algorithm already created the InternalResMgr
// take it instead of creating yet another one
it->second.pResMgr = NULL;
pImp->bSingular = true;
}
else
{
pImp = new InternalResMgr( it->second.aFileURL, rPrefix, it->first, aLocale );
pImp->bSingular = true;
if( !pImp->Create() )
{
delete pImp;
pImp = NULL;
}
else
it->second.nLoadCount++;
}
}
else
it->second.nRefCount++;
return pImp;
}
InternalResMgr* ResMgrContainer::getNextFallback( InternalResMgr* pMgr )
{
/* TODO-BCP47: this is nasty, but the previous code simply stripped a
* locale's variant and country in subsequent calls to end up with language
* only and then fallback to en-US if all failed, so this is at least
* equivalent if not better. Maybe this method could be changed to get
* passed / remember a fallback list and an index within to pick the next.
* */
::std::vector< OUString > aFallbacks( pMgr->aLocale.getFallbackStrings( true));
// The first is the locale itself, use next fallback or en-US.
/* TODO: what happens if the chain is "en-US", "en" -> "en-US", ...
* This was already an issue with the previous code. */
LanguageTag aLocale( ((aFallbacks.size() > 1) ? aFallbacks[1] : OUString( "en-US")));
InternalResMgr* pNext = getResMgr( pMgr->aPrefix, aLocale, pMgr->bSingular );
// prevent recursion
2011-05-19 11:52:37 +02:00
if( pNext == pMgr || ( pNext && pNext->aResName.equals( pMgr->aResName ) ) )
{
if( pNext->bSingular )
delete pNext;
pNext = NULL;
}
return pNext;
}
void ResMgrContainer::freeResMgr( InternalResMgr* pResMgr )
{
if( pResMgr->bSingular )
delete pResMgr;
else
{
std::unordered_map< OUString, ContainerElement, OUStringHash >::iterator it =
m_aResFiles.find( pResMgr->aResName );
if( it != m_aResFiles.end() )
{
DBG_ASSERT( it->second.nRefCount > 0, "InternalResMgr freed too often" );
if( it->second.nRefCount > 0 )
it->second.nRefCount--;
if( it->second.nRefCount == 0 )
{
delete it->second.pResMgr;
it->second.pResMgr = NULL;
}
}
}
}
#ifdef DBG_UTIL
void Resource::TestRes()
{
if( m_pResMgr )
m_pResMgr->TestStack( this );
2000-09-18 16:07:07 +00:00
}
#endif
2000-09-18 16:07:07 +00:00
struct ImpContent
{
sal_uInt64 nTypeAndId;
sal_uInt32 nOffset;
2000-09-18 16:07:07 +00:00
};
struct ImpContentLessCompare : public ::std::binary_function< ImpContent, ImpContent, bool>
2000-09-18 16:07:07 +00:00
{
inline bool operator() (const ImpContent& lhs, const ImpContent& rhs) const
{
return lhs.nTypeAndId < rhs.nTypeAndId;
}
};
2000-09-18 16:07:07 +00:00
2000-12-05 18:23:20 +00:00
static ResHookProc pImplResHookProc = 0;
InternalResMgr::InternalResMgr( const OUString& rFileURL,
const OUString& rPrefix,
const OUString& rResName,
const LanguageTag& rLocale )
2000-09-18 16:07:07 +00:00
: pContent( NULL )
, nOffCorrection( 0 )
2000-09-18 16:07:07 +00:00
, pStringBlock( NULL )
, pStm( NULL )
, bEqual2Content( true )
2000-09-18 16:07:07 +00:00
, nEntries( 0 )
, aFileName( rFileURL )
, aPrefix( rPrefix )
, aResName( rResName )
, bSingular( false )
, aLocale( rLocale )
2000-09-18 16:07:07 +00:00
, pResUseDump( 0 )
{
}
InternalResMgr::~InternalResMgr()
{
rtl_freeMemory(pContent);
rtl_freeMemory(pStringBlock);
2000-09-18 16:07:07 +00:00
delete pStm;
#ifdef DBG_UTIL
if( pResUseDump )
{
const sal_Char* pLogFile = getenv( "STAR_RESOURCE_LOGGING" );
if ( pLogFile )
{
SvFileStream aStm( OUString::createFromAscii( pLogFile ), StreamMode::WRITE );
2000-09-18 16:07:07 +00:00
aStm.Seek( STREAM_SEEK_TO_END );
OStringBuffer aLine("FileName: ");
aLine.append(OUStringToOString(aFileName,
RTL_TEXTENCODING_UTF8));
aStm.WriteLine(aLine.makeStringAndClear());
2000-09-18 16:07:07 +00:00
for( std::unordered_map<sal_uInt64, int>::const_iterator it = pResUseDump->begin();
it != pResUseDump->end(); ++it )
2000-09-18 16:07:07 +00:00
{
sal_uInt64 nKeyId = it->first;
aLine.append("Type/Id: ");
aLine.append(sal::static_int_cast< sal_Int32 >((nKeyId >> 32) & 0xFFFFFFFF));
aLine.append('/');
aLine.append(sal::static_int_cast< sal_Int32 >(nKeyId & 0xFFFFFFFF));
aStm.WriteLine(aLine.makeStringAndClear());
2000-09-18 16:07:07 +00:00
}
}
}
#endif
delete pResUseDump;
}
bool InternalResMgr::Create()
2000-09-18 16:07:07 +00:00
{
ResMgrContainer::get();
bool bDone = false;
2000-09-18 16:07:07 +00:00
pStm = new SvFileStream( aFileName, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE );
2000-09-18 16:07:07 +00:00
if( pStm->GetError() == 0 )
{
sal_Int32 lContLen = 0;
2000-09-18 16:07:07 +00:00
pStm->Seek( STREAM_SEEK_TO_END );
/*
if( ( pInternalResMgr->pHead = (RSHEADER_TYPE *)mmap( 0, nResourceFileSize,
PROT_READ, MAP_PRIVATE,
fRes, 0 ) ) != (RSHEADER_TYPE *)-1)
*/
pStm->SeekRel( - (int)sizeof( lContLen ) );
pStm->Read( &lContLen, sizeof( lContLen ) );
// is bigendian, swab to the right endian
lContLen = ResMgr::GetLong( &lContLen );
pStm->SeekRel( -lContLen );
// allocate stored ImpContent data (12 bytes per unit)
sal_uInt8* pContentBuf = static_cast<sal_uInt8*>(rtl_allocateMemory( lContLen ));
pStm->Read( pContentBuf, lContLen );
// allocate ImpContent space (sizeof(ImpContent) per unit, not necessarily 12)
pContent = static_cast<ImpContent *>(rtl_allocateMemory( sizeof(ImpContent)*lContLen/12 ));
// Shorten to number of ImpContent
nEntries = (sal_uInt32)lContLen / 12;
bEqual2Content = true;
bool bSorted = true;
2000-09-18 16:07:07 +00:00
if( nEntries )
{
#ifdef DBG_UTIL
const sal_Char* pLogFile = getenv( "STAR_RESOURCE_LOGGING" );
if ( pLogFile )
{
pResUseDump = new std::unordered_map<sal_uInt64, int>;
for( sal_uInt32 i = 0; i < nEntries; ++i )
(*pResUseDump)[pContent[i].nTypeAndId] = 1;
2000-09-18 16:07:07 +00:00
}
#endif
// swap the content to the right endian
pContent[0].nTypeAndId = ResMgr::GetUInt64( pContentBuf );
pContent[0].nOffset = ResMgr::GetLong( pContentBuf+8 );
sal_uInt32 nCount = nEntries - 1;
for( sal_uInt32 i = 0,j=1; i < nCount; ++i,++j )
2000-09-18 16:07:07 +00:00
{
// swap the content to the right endian
pContent[j].nTypeAndId = ResMgr::GetUInt64( pContentBuf + (12*j) );
pContent[j].nOffset = ResMgr::GetLong( pContentBuf + (12*j+8) );
if( pContent[i].nTypeAndId >= pContent[j].nTypeAndId )
bSorted = false;
if( (pContent[i].nTypeAndId & 0xFFFFFFFF00000000LL) == (pContent[j].nTypeAndId & 0xFFFFFFFF00000000LL)
&& pContent[i].nOffset >= pContent[j].nOffset )
bEqual2Content = false;
2000-09-18 16:07:07 +00:00
}
}
rtl_freeMemory( pContentBuf );
OSL_ENSURE( bSorted, "content not sorted" );
OSL_ENSURE( bEqual2Content, "resource structure wrong" );
2000-09-18 16:07:07 +00:00
if( !bSorted )
::std::sort(pContent,pContent+nEntries,ImpContentLessCompare());
// qsort( pContent, nEntries, sizeof( ImpContent ), Compare );
2000-09-18 16:07:07 +00:00
bDone = true;
2000-09-18 16:07:07 +00:00
}
return bDone;
}
bool InternalResMgr::IsGlobalAvailable( RESOURCE_TYPE nRT, sal_uInt32 nId ) const
2000-09-18 16:07:07 +00:00
{
// Anfang der Strings suchen
ImpContent aValue;
aValue.nTypeAndId = ((sal_uInt64(nRT) << 32) | nId);
ImpContent * pFind = ::std::lower_bound(pContent,
pContent + nEntries,
aValue,
ImpContentLessCompare());
return (pFind != (pContent + nEntries)) && (pFind->nTypeAndId == aValue.nTypeAndId);
2000-09-18 16:07:07 +00:00
}
void* InternalResMgr::LoadGlobalRes( RESOURCE_TYPE nRT, sal_uInt32 nId,
2000-09-18 16:07:07 +00:00
void **pResHandle )
{
#ifdef DBG_UTIL
if( pResUseDump )
pResUseDump->erase( (sal_uInt64(nRT) << 32) | nId );
2000-09-18 16:07:07 +00:00
#endif
// search beginning of string
ImpContent aValue;
aValue.nTypeAndId = ((sal_uInt64(nRT) << 32) | nId);
ImpContent* pEnd = (pContent + nEntries);
ImpContent* pFind = ::std::lower_bound( pContent,
pEnd,
aValue,
ImpContentLessCompare());
if( pFind && (pFind != pEnd) && (pFind->nTypeAndId == aValue.nTypeAndId) )
2000-09-18 16:07:07 +00:00
{
if( nRT == RSC_STRING && bEqual2Content )
2000-09-18 16:07:07 +00:00
{
// string optimization
if( !pStringBlock )
{
// search beginning of string
ImpContent * pFirst = pFind;
ImpContent * pLast = pFirst;
while( pFirst > pContent && ((pFirst -1)->nTypeAndId >> 32) == RSC_STRING )
--pFirst;
while( pLast < pEnd && (pLast->nTypeAndId >> 32) == RSC_STRING )
++pLast;
nOffCorrection = pFirst->nOffset;
sal_uInt32 nSize;
--pLast;
pStm->Seek( pLast->nOffset );
RSHEADER_TYPE aHdr;
pStm->Read( &aHdr, sizeof( aHdr ) );
nSize = pLast->nOffset + aHdr.GetGlobOff() - nOffCorrection;
pStringBlock = static_cast<sal_uInt8*>(rtl_allocateMemory( nSize ));
pStm->Seek( pFirst->nOffset );
pStm->Read( pStringBlock, nSize );
}
*pResHandle = pStringBlock;
return pStringBlock + pFind->nOffset - nOffCorrection;
} // if( nRT == RSC_STRING && bEqual2Content )
else
{
*pResHandle = 0;
RSHEADER_TYPE aHeader;
pStm->Seek( pFind->nOffset );
pStm->Read( &aHeader, sizeof( RSHEADER_TYPE ) );
void * pRes = rtl_allocateMemory( aHeader.GetGlobOff() );
memcpy( pRes, &aHeader, sizeof( RSHEADER_TYPE ) );
pStm->Read( static_cast<sal_uInt8*>(pRes) + sizeof( RSHEADER_TYPE ),
aHeader.GetGlobOff() - sizeof( RSHEADER_TYPE ) );
return pRes;
2000-09-18 16:07:07 +00:00
}
} // if( pFind && (pFind != pEnd) && (pFind->nTypeAndId == nValue) )
2000-09-18 16:07:07 +00:00
*pResHandle = 0;
return NULL;
}
void InternalResMgr::FreeGlobalRes( void * pResHandle, void * pResource )
{
if ( !pResHandle )
// Free allocated resource
rtl_freeMemory(pResource);
2000-09-18 16:07:07 +00:00
}
#ifdef DBG_UTIL
OUString GetTypeRes_Impl( const ResId& rTypeId )
2000-09-18 16:07:07 +00:00
{
// Return on resource errors
static bool bInUse = false;
OUString aTypStr(OUString::number(rTypeId.GetId()));
2000-09-18 16:07:07 +00:00
if ( !bInUse )
{
bInUse = true;
ResId aResId( sal_uInt32(RSCVERSION_ID), *rTypeId.GetResMgr() );
aResId.SetRT( RSC_VERSIONCONTROL );
if ( rTypeId.GetResMgr()->GetResource( aResId ) )
2000-09-18 16:07:07 +00:00
{
rTypeId.SetRT( RSC_STRING );
if ( rTypeId.GetResMgr()->IsAvailable( rTypeId ) )
{
aTypStr = rTypeId.toString();
// Set class pointer to the end
rTypeId.GetResMgr()->Increment( sizeof( RSHEADER_TYPE ) );
}
2000-09-18 16:07:07 +00:00
}
bInUse = false;
2000-09-18 16:07:07 +00:00
}
return aTypStr;
}
void ResMgr::RscError_Impl( const sal_Char* pMessage, ResMgr* pResMgr,
RESOURCE_TYPE nRT, sal_uInt32 nId,
std::vector< ImpRCStack >& rResStack, int nDepth )
2000-09-18 16:07:07 +00:00
{
// create a separate ResMgr with its own stack
// first get a second reference of the InternalResMgr
InternalResMgr* pImp =
ResMgrContainer::get().getResMgr( pResMgr->pImpRes->aPrefix,
pResMgr->pImpRes->aLocale,
true );
2000-09-18 16:07:07 +00:00
ResMgr* pNewResMgr = new ResMgr( pImp );
OStringBuffer aStr(OUStringToOString(pResMgr->GetFileName(),
RTL_TEXTENCODING_UTF8));
2000-09-18 16:07:07 +00:00
if (aStr.getLength())
aStr.append('\n');
2000-09-18 16:07:07 +00:00
aStr.append("Class: ");
aStr.append(OUStringToOString(GetTypeRes_Impl(ResId(nRT, *pNewResMgr)),
RTL_TEXTENCODING_UTF8));
aStr.append(", Id: ");
aStr.append(static_cast<sal_Int32>(nId));
aStr.append(". ");
aStr.append(pMessage);
aStr.append("\nResource Stack\n");
while( nDepth > 0 )
2000-09-18 16:07:07 +00:00
{
aStr.append("Class: ");
aStr.append(OUStringToOString(GetTypeRes_Impl(
ResId(rResStack[nDepth].pResource->GetRT(), *pNewResMgr)),
RTL_TEXTENCODING_UTF8));
aStr.append(", Id: ");
aStr.append(static_cast<sal_Int32>(
rResStack[nDepth].pResource->GetId()));
nDepth--;
2000-09-18 16:07:07 +00:00
}
// clean up
2000-09-18 16:07:07 +00:00
delete pNewResMgr;
OSL_FAIL(aStr.getStr());
2000-09-18 16:07:07 +00:00
}
#endif
static void RscException_Impl()
{
2010-10-11 01:26:24 -05:00
switch ( osl_raiseSignal( OSL_SIGNAL_USER_RESOURCEFAILURE, (void*)"" ) )
2000-09-18 16:07:07 +00:00
{
2010-10-11 01:26:24 -05:00
case osl_Signal_ActCallNextHdl:
abort();
2000-09-18 16:07:07 +00:00
2010-10-11 01:26:24 -05:00
case osl_Signal_ActIgnore:
return;
2000-09-18 16:07:07 +00:00
2010-10-11 01:26:24 -05:00
case osl_Signal_ActAbortApp:
abort();
2000-09-18 16:07:07 +00:00
2010-10-11 01:26:24 -05:00
default:
case osl_Signal_ActKillApp:
exit(-1);
2000-09-18 16:07:07 +00:00
}
}
void ImpRCStack::Init( ResMgr* pMgr, const Resource* pObj, sal_uInt32 Id )
2000-09-18 16:07:07 +00:00
{
pResource = NULL;
pClassRes = NULL;
Flags = RCFlags::NONE;
aResHandle = NULL;
pResObj = pObj;
nId = Id & ~RSC_DONTRELEASE; //TLX: Besser Init aendern
pResMgr = pMgr;
2000-09-18 16:07:07 +00:00
if ( !(Id & RSC_DONTRELEASE) )
Flags |= RCFlags::AUTORELEASE;
2000-09-18 16:07:07 +00:00
}
void ImpRCStack::Clear()
{
pResource = NULL;
pClassRes = NULL;
Flags = RCFlags::NONE;
aResHandle = NULL;
pResObj = NULL;
nId = 0;
pResMgr = NULL;
2000-09-18 16:07:07 +00:00
}
static RSHEADER_TYPE* LocalResource( const ImpRCStack* pStack,
RESOURCE_TYPE nRTType,
sal_uInt32 nId )
2000-09-18 16:07:07 +00:00
{
// Returns position of the resource if found or NULL otherwise
RSHEADER_TYPE* pTmp; // Pointer to child resource
RSHEADER_TYPE* pEnd; // Pointer to the end of this resource
2000-09-18 16:07:07 +00:00
if ( pStack->pResource && pStack->pClassRes )
{
pTmp = reinterpret_cast<RSHEADER_TYPE*>
(reinterpret_cast<sal_uInt8*>(pStack->pResource) + pStack->pResource->GetLocalOff());
pEnd = reinterpret_cast<RSHEADER_TYPE*>
(reinterpret_cast<sal_uInt8*>(pStack->pResource) + pStack->pResource->GetGlobOff());
2000-09-18 16:07:07 +00:00
while ( pTmp != pEnd )
{
if ( pTmp->GetRT() == nRTType && pTmp->GetId() == nId )
return pTmp;
pTmp = reinterpret_cast<RSHEADER_TYPE*>(reinterpret_cast<sal_uInt8*>(pTmp) + pTmp->GetGlobOff());
2000-09-18 16:07:07 +00:00
}
}
return NULL;
}
void* ResMgr::pEmptyBuffer = NULL;
void* ResMgr::getEmptyBuffer()
{
if( ! pEmptyBuffer )
pEmptyBuffer = rtl_allocateZeroMemory( 1024 );
return pEmptyBuffer;
}
2000-09-18 16:07:07 +00:00
void ResMgr::DestroyAllResMgr()
{
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pEmptyBuffer )
2000-09-18 16:07:07 +00:00
{
rtl_freeMemory( pEmptyBuffer );
pEmptyBuffer = NULL;
2000-09-18 16:07:07 +00:00
}
ResMgrContainer::release();
2000-09-18 16:07:07 +00:00
}
delete pResMgrMutex;
pResMgrMutex = NULL;
2000-09-18 16:07:07 +00:00
}
void ResMgr::Init( const OUString& rFileName )
2000-09-18 16:07:07 +00:00
{
(void) rFileName; // avoid warning about unused parameter
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
2000-09-18 16:07:07 +00:00
if ( !pImpRes )
{
#ifdef DBG_UTIL
OStringBuffer aStr("Resourcefile not found:\n");
2011-08-25 09:41:17 +01:00
aStr.append(OUStringToOString(rFileName, RTL_TEXTENCODING_UTF8));
OSL_FAIL(aStr.getStr());
2000-09-18 16:07:07 +00:00
#endif
RscException_Impl();
}
#ifdef DBG_UTIL
else
{
void* aResHandle = 0; // Helper variable for resource handles
void* pVoid; // Pointer on the resource
2000-09-18 16:07:07 +00:00
pVoid = pImpRes->LoadGlobalRes( RSC_VERSIONCONTROL, RSCVERSION_ID,
&aResHandle );
if ( pVoid )
InternalResMgr::FreeGlobalRes( aResHandle, pVoid );
2000-09-18 16:07:07 +00:00
else
{
SAL_WARN("tools.rc", "Wrong version: " << pImpRes->aFileName);
2000-09-18 16:07:07 +00:00
}
}
#endif
nCurStack = -1;
aStack.clear();
pFallbackResMgr = pOriginalResMgr = NULL;
incStack();
2000-09-18 16:07:07 +00:00
}
ResMgr::ResMgr( InternalResMgr * pImpMgr )
{
pImpRes = pImpMgr;
Init( pImpMgr->aFileName );
}
ResMgr::~ResMgr()
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
ResMgrContainer::get().freeResMgr( pImpRes );
// clean up possible left rc stack frames
while( nCurStack > 0 )
{
if( ( aStack[nCurStack].Flags & (RCFlags::GLOBAL | RCFlags::NOTFOUND) ) == RCFlags::GLOBAL )
InternalResMgr::FreeGlobalRes( aStack[nCurStack].aResHandle,
aStack[nCurStack].pResource );
nCurStack--;
}
2000-09-18 16:07:07 +00:00
}
void ResMgr::incStack()
{
nCurStack++;
if( nCurStack >= int(aStack.size()) )
aStack.push_back( ImpRCStack() );
aStack[nCurStack].Clear();
DBG_ASSERT( nCurStack < 32, "Resource stack unreasonably large" );
}
void ResMgr::decStack()
{
DBG_ASSERT( nCurStack > 0, "resource stack underrun !" );
if( (aStack[nCurStack].Flags & RCFlags::FALLBACK_UP) )
{
nCurStack--;
// warning: this will delete *this, see below
pOriginalResMgr->decStack();
}
else
{
ImpRCStack& rTop = aStack[nCurStack];
if( (rTop.Flags & RCFlags::FALLBACK_DOWN) )
{
#if OSL_DEBUG_LEVEL > 1
2011-09-29 15:17:42 +02:00
OSL_TRACE( "returning from fallback %s",
OUStringToOString(pFallbackResMgr->GetFileName(), osl_getThreadTextEncoding() ).getStr() );
#endif
delete pFallbackResMgr;
pFallbackResMgr = NULL;
}
nCurStack--;
}
}
2000-09-18 16:07:07 +00:00
#ifdef DBG_UTIL
void ResMgr::TestStack( const Resource* pResObj )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
2012-02-13 17:53:19 +01:00
int upperLimit = nCurStack;
if ( upperLimit < 0 )
{
OSL_FAIL( "resource stack underrun!" );
upperLimit = aStack.size() - 1;
}
else if ( upperLimit >= static_cast<int>(aStack.size()) )
{
OSL_FAIL( "stack occupation index > allocated stack size" );
upperLimit = aStack.size() - 1;
}
2000-09-18 16:07:07 +00:00
if ( DbgIsResource() )
{
2012-02-13 17:53:19 +01:00
for( int i = 1; i <= upperLimit; ++i )
2000-09-18 16:07:07 +00:00
{
if ( aStack[i].pResObj == pResObj )
{
RscError_Impl( "Resource not freed! ", this,
aStack[i].pResource->GetRT(),
aStack[i].pResource->GetId(),
aStack, i-1 );
2000-09-18 16:07:07 +00:00
}
}
}
}
#endif
bool ResMgr::IsAvailable( const ResId& rId, const Resource* pResObj ) const
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
bool bAvailable = false;
2000-09-18 16:07:07 +00:00
RSHEADER_TYPE* pClassRes = rId.GetpResource();
RESOURCE_TYPE nRT = rId.GetRT2();
sal_uInt32 nId = rId.GetId();
2000-09-18 16:07:07 +00:00
const ResMgr* pMgr = rId.GetResMgr();
if ( !pMgr )
pMgr = this;
if( pMgr->pFallbackResMgr )
{
ResId aId( rId );
aId.SetResMgr( NULL );
return pMgr->pFallbackResMgr->IsAvailable( aId, pResObj );
}
if ( !pResObj || pResObj == pMgr->aStack[pMgr->nCurStack].pResObj )
2000-09-18 16:07:07 +00:00
{
if ( !pClassRes )
pClassRes = LocalResource( &pMgr->aStack[pMgr->nCurStack], nRT, nId );
2000-09-18 16:07:07 +00:00
if ( pClassRes )
{
if ( pClassRes->GetRT() == nRT )
bAvailable = true;
2000-09-18 16:07:07 +00:00
}
}
if ( !pClassRes )
bAvailable = pMgr->pImpRes->IsGlobalAvailable( nRT, nId );
return bAvailable;
}
void* ResMgr::GetClass()
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->GetClass();
return aStack[nCurStack].pClassRes;
2000-09-18 16:07:07 +00:00
}
bool ResMgr::GetResource( const ResId& rId, const Resource* pResObj )
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
{
ResId aId( rId );
aId.SetResMgr( NULL );
return pFallbackResMgr->GetResource( aId, pResObj );
}
2000-09-18 16:07:07 +00:00
ResMgr* pMgr = rId.GetResMgr();
if ( pMgr && (this != pMgr) )
return pMgr->GetResource( rId, pResObj );
// normally Increment will pop the context; this is
// not possible in RCFlags::NOTFOUND case, so pop a frame here
ImpRCStack* pTop = &aStack[nCurStack];
if( (pTop->Flags & RCFlags::NOTFOUND) )
{
decStack();
}
2000-09-18 16:07:07 +00:00
RSHEADER_TYPE* pClassRes = rId.GetpResource();
RESOURCE_TYPE nRT = rId.GetRT2();
sal_uInt32 nId = rId.GetId();
2000-09-18 16:07:07 +00:00
incStack();
pTop = &aStack[nCurStack];
pTop->Init( pMgr, pResObj, nId |
2000-09-18 16:07:07 +00:00
(rId.IsAutoRelease() ? 0 : RSC_DONTRELEASE) );
if ( pClassRes )
{
if ( pClassRes->GetRT() == nRT )
pTop->pClassRes = pClassRes;
else
{
#ifdef DBG_UTIL
RscError_Impl( "Different class and resource type!",
this, nRT, nId, aStack, nCurStack-1 );
2000-09-18 16:07:07 +00:00
#endif
pTop->Flags |= RCFlags::NOTFOUND;
pTop->pClassRes = getEmptyBuffer();
pTop->pResource = static_cast<RSHEADER_TYPE*>(pTop->pClassRes);
return false;
2000-09-18 16:07:07 +00:00
}
}
else
{
OSL_ENSURE( nCurStack > 0, "stack of 1 to shallow" );
pTop->pClassRes = LocalResource( &aStack[nCurStack-1], nRT, nId );
}
2000-09-18 16:07:07 +00:00
if ( pTop->pClassRes )
// local Resource, not a system Resource
pTop->pResource = static_cast<RSHEADER_TYPE *>(pTop->pClassRes);
2000-09-18 16:07:07 +00:00
else
{
pTop->pClassRes = pImpRes->LoadGlobalRes( nRT, nId, &pTop->aResHandle );
if ( pTop->pClassRes )
{
pTop->Flags |= RCFlags::GLOBAL;
pTop->pResource = static_cast<RSHEADER_TYPE *>(pTop->pClassRes);
}
2000-09-18 16:07:07 +00:00
else
{
// try to get a fallback resource
pFallbackResMgr = CreateFallbackResMgr( rId, pResObj );
if( pFallbackResMgr )
{
pTop->Flags |= RCFlags::FALLBACK_DOWN;
#ifdef DBG_UTIL
OStringBuffer aMess("found resource ");
aMess.append(static_cast<sal_Int32>(nId));
aMess.append(" in fallback ");
aMess.append(OUStringToOString(
pFallbackResMgr->GetFileName(),
osl_getThreadTextEncoding()));
aMess.append('\n');
RscError_Impl(aMess.getStr(),
this, nRT, nId, aStack, nCurStack-1);
#endif
}
else
{
#ifdef DBG_UTIL
RscError_Impl( "Cannot load resource! ",
this, nRT, nId, aStack, nCurStack-1 );
#endif
pTop->Flags |= RCFlags::NOTFOUND;
pTop->pClassRes = getEmptyBuffer();
pTop->pResource = static_cast<RSHEADER_TYPE*>(pTop->pClassRes);
return false;
}
2000-09-18 16:07:07 +00:00
}
}
return true;
2000-09-18 16:07:07 +00:00
}
void * ResMgr::GetResourceSkipHeader( const ResId& rResId, ResMgr ** ppResMgr )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
*ppResMgr = rResId.GetResMgr();
assert(*ppResMgr != nullptr);
(*ppResMgr)->GetResource( rResId );
(*ppResMgr)->Increment( sizeof( RSHEADER_TYPE ) );
return (*ppResMgr)->GetClass();
2000-09-18 16:07:07 +00:00
}
void ResMgr::PopContext( const Resource* pResObj )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
{
pFallbackResMgr->PopContext( pResObj );
return;
}
2000-09-18 16:07:07 +00:00
#ifdef DBG_UTIL
if ( DbgIsResource() )
{
if ( (aStack[nCurStack].pResObj != pResObj) || nCurStack == 0 )
2000-09-18 16:07:07 +00:00
{
RscError_Impl( "Cannot free resource! ", this,
RSC_NOTYPE, 0, aStack, nCurStack );
2000-09-18 16:07:07 +00:00
}
}
#endif
if ( nCurStack > 0 )
2000-09-18 16:07:07 +00:00
{
ImpRCStack* pTop = &aStack[nCurStack];
2000-09-18 16:07:07 +00:00
#ifdef DBG_UTIL
if ( DbgIsResource() && !(pTop->Flags & RCFlags::NOTFOUND) )
2000-09-18 16:07:07 +00:00
{
void* pRes = reinterpret_cast<sal_uInt8*>(pTop->pResource) +
2000-09-18 16:07:07 +00:00
pTop->pResource->GetLocalOff();
if ( pTop->pClassRes != pRes )
{
RscError_Impl( "Classpointer not at the end!",
this, pTop->pResource->GetRT(),
pTop->pResource->GetId(),
aStack, nCurStack-1 );
2000-09-18 16:07:07 +00:00
}
}
#endif
// free resource
if( (pTop->Flags & (RCFlags::GLOBAL | RCFlags::NOTFOUND)) == RCFlags::GLOBAL )
// free global resource if resource is foreign
InternalResMgr::FreeGlobalRes( pTop->aResHandle, pTop->pResource );
decStack();
2000-09-18 16:07:07 +00:00
}
}
RSHEADER_TYPE* ResMgr::CreateBlock( const ResId& rId )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
{
ResId aId( rId );
aId.SetResMgr( NULL );
return pFallbackResMgr->CreateBlock( aId );
}
2000-09-18 16:07:07 +00:00
RSHEADER_TYPE* pHeader = NULL;
if ( GetResource( rId ) )
{
// Pointer is at the beginning of the resource, thus
// class pointer points to the header, and the remaining size
// equals to total size of allocated memory
pHeader = static_cast<RSHEADER_TYPE*>(rtl_allocateMemory( GetRemainSize() ));
2000-09-18 16:07:07 +00:00
memcpy( pHeader, GetClass(), GetRemainSize() );
Increment( pHeader->GetLocalOff() ); //ans Ende setzen
if ( pHeader->GetLocalOff() != pHeader->GetGlobOff() )
// Has sub-resources, thus release them as well
2000-09-18 16:07:07 +00:00
PopContext();
}
return pHeader;
}
sal_Int16 ResMgr::GetShort( void * pShort )
2000-09-18 16:07:07 +00:00
{
return ((*(static_cast<sal_uInt8*>(pShort) + 0) << 8) |
(*(static_cast<sal_uInt8*>(pShort) + 1) << 0) );
2000-09-18 16:07:07 +00:00
}
sal_Int32 ResMgr::GetLong( void * pLong )
2000-09-18 16:07:07 +00:00
{
return ((*(static_cast<sal_uInt8*>(pLong) + 0) << 24) |
(*(static_cast<sal_uInt8*>(pLong) + 1) << 16) |
(*(static_cast<sal_uInt8*>(pLong) + 2) << 8) |
(*(static_cast<sal_uInt8*>(pLong) + 3) << 0) );
2000-09-18 16:07:07 +00:00
}
sal_uInt64 ResMgr::GetUInt64( void* pDatum )
{
return ((sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 0)) << 56) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 1)) << 48) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 2)) << 40) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 3)) << 32) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 4)) << 24) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 5)) << 16) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 6)) << 8) |
(sal_uInt64(*(static_cast<sal_uInt8*>(pDatum) + 7)) << 0) );
}
2000-09-18 16:07:07 +00:00
sal_uInt32 ResMgr::GetStringWithoutHook( OUString& rStr, const sal_uInt8* pStr )
2000-09-18 16:07:07 +00:00
{
sal_uInt32 nLen=0;
sal_uInt32 nRet = GetStringSize( pStr, nLen );
const sal_Char* str = reinterpret_cast< const sal_Char* >( pStr );
OUString aString( str, strlen( str ), RTL_TEXTENCODING_UTF8,
2000-09-18 16:07:07 +00:00
RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE |
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT |
RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT );
rStr = aString;
return nRet;
}
sal_uInt32 ResMgr::GetString( OUString& rStr, const sal_uInt8* pStr )
{
OUString aString;
sal_uInt32 nRet = GetStringWithoutHook( aString, pStr );
2000-12-05 18:23:20 +00:00
if ( pImplResHookProc )
aString = pImplResHookProc( aString );
2000-09-18 16:07:07 +00:00
rStr = aString;
return nRet;
2000-09-18 16:07:07 +00:00
}
sal_uInt32 ResMgr::GetByteString( OString& rStr, const sal_uInt8* pStr )
{
sal_uInt32 nLen=0;
sal_uInt32 nRet = GetStringSize( pStr, nLen );
rStr = OString( reinterpret_cast<const char*>(pStr), nLen );
return nRet;
}
sal_uInt32 ResMgr::GetStringSize( const sal_uInt8* pStr, sal_uInt32& nLen )
2000-09-18 16:07:07 +00:00
{
nLen = static_cast< sal_uInt32 >( strlen( reinterpret_cast<const char*>(pStr) ) );
return GetStringSize( nLen );
2000-09-18 16:07:07 +00:00
}
sal_uInt32 ResMgr::GetRemainSize()
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->GetRemainSize();
const ImpRCStack& rTop = aStack[nCurStack];
return (sal_uInt32)(reinterpret_cast<sal_IntPtr>(rTop.pResource) +
rTop.pResource->GetLocalOff() -
reinterpret_cast<sal_IntPtr>(rTop.pClassRes));
2000-09-18 16:07:07 +00:00
}
void* ResMgr::Increment( sal_uInt32 nSize )
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->Increment( nSize );
ImpRCStack& rStack = aStack[nCurStack];
if( (rStack.Flags & RCFlags::NOTFOUND) )
return rStack.pClassRes;
sal_uInt8* pClassRes = static_cast<sal_uInt8*>(rStack.pClassRes) + nSize;
2000-09-18 16:07:07 +00:00
rStack.pClassRes = pClassRes;
2000-09-18 16:07:07 +00:00
RSHEADER_TYPE* pRes = rStack.pResource;
2000-09-18 16:07:07 +00:00
sal_uInt32 nLocalOff = pRes->GetLocalOff();
if ( (pRes->GetGlobOff() == nLocalOff) &&
((reinterpret_cast<char*>(pRes) + nLocalOff) == rStack.pClassRes) &&
(rStack.Flags & RCFlags::AUTORELEASE))
2000-09-18 16:07:07 +00:00
{
PopContext( rStack.pResObj );
2000-09-18 16:07:07 +00:00
}
return pClassRes;
}
ResMgr* ResMgr::CreateFallbackResMgr( const ResId& rId, const Resource* pResource )
{
ResMgr *pFallback = NULL;
if( nCurStack > 0 )
{
// get the next fallback level in resource file scope
InternalResMgr* pRes = ResMgrContainer::get().getNextFallback( pImpRes );
if( pRes )
{
// check that the fallback locale is not already in the chain of
// fallbacks - prevent fallback loops
ResMgr* pResMgr = this;
while( pResMgr && (pResMgr->pImpRes->aLocale != pRes->aLocale))
{
pResMgr = pResMgr->pOriginalResMgr;
}
if( pResMgr )
{
// found a recursion, no fallback possible
ResMgrContainer::get().freeResMgr( pRes );
return NULL;
}
OSL_TRACE( "trying fallback: %s", OUStringToOString( pRes->aFileName, osl_getThreadTextEncoding() ).getStr() );
pFallback = new ResMgr( pRes );
pFallback->pOriginalResMgr = this;
// try to recreate the resource stack
bool bHaveStack = true;
for( int i = 1; i < nCurStack; i++ )
{
if( !aStack[i].pResource )
{
bHaveStack = false;
break;
}
ResId aId( aStack[i].pResource->GetId(), *pFallbackResMgr );
aId.SetRT( aStack[i].pResource->GetRT() );
if( !pFallback->GetResource( aId ) )
{
bHaveStack = false;
break;
}
}
if( bHaveStack )
{
ResId aId( rId.GetId(), *pFallback );
aId.SetRT( rId.GetRT() );
if( !pFallback->GetResource( aId, pResource ) )
bHaveStack = false;
else
pFallback->aStack[pFallback->nCurStack].Flags |= RCFlags::FALLBACK_UP;
}
if( !bHaveStack )
{
delete pFallback;
pFallback = NULL;
}
}
}
return pFallback;
}
2000-09-18 16:07:07 +00:00
ResMgr* ResMgr::CreateResMgr( const sal_Char* pPrefixName,
const LanguageTag& _aLocale )
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
2000-09-18 16:07:07 +00:00
OUString aPrefix( pPrefixName, strlen( pPrefixName ), osl_getThreadTextEncoding() );
2000-09-18 16:07:07 +00:00
LanguageTag aLocale = _aLocale;
if( aLocale.isSystemLocale() )
aLocale = ResMgrContainer::get().getDefLocale();
InternalResMgr* pImp = ResMgrContainer::get().getResMgr( aPrefix, aLocale );
return pImp ? new ResMgr( pImp ) : NULL;
}
ResMgr* ResMgr::SearchCreateResMgr(
const sal_Char* pPrefixName,
LanguageTag& rLocale )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
OUString aPrefix( pPrefixName, strlen( pPrefixName ), osl_getThreadTextEncoding() );
if( rLocale.isSystemLocale() )
rLocale = ResMgrContainer::get().getDefLocale();
InternalResMgr* pImp = ResMgrContainer::get().getResMgr( aPrefix, rLocale );
return pImp ? new ResMgr( pImp ) : NULL;
2000-09-18 16:07:07 +00:00
}
sal_Int16 ResMgr::ReadShort()
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->ReadShort();
sal_Int16 n = GetShort( GetClass() );
Increment( sizeof( sal_Int16 ) );
2000-09-18 16:07:07 +00:00
return n;
}
sal_Int32 ResMgr::ReadLong()
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->ReadLong();
sal_Int32 n = GetLong( GetClass() );
Increment( sizeof( sal_Int32 ) );
2000-09-18 16:07:07 +00:00
return n;
}
OUString ResMgr::ReadStringWithoutHook()
2000-09-18 16:07:07 +00:00
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->ReadStringWithoutHook();
OUString aRet;
const ImpRCStack& rTop = aStack[nCurStack];
if( (rTop.Flags & RCFlags::NOTFOUND) )
{
#if OSL_DEBUG_LEVEL > 0
aRet = "<resource not found>";
#endif
}
else
Increment( GetStringWithoutHook( aRet, static_cast<const sal_uInt8*>(GetClass()) ) );
return aRet;
}
OUString ResMgr::ReadString()
{
OUString aRet = ReadStringWithoutHook();
if ( pImplResHookProc )
aRet = pImplResHookProc( aRet );
2000-09-18 16:07:07 +00:00
return aRet;
}
OString ResMgr::ReadByteString()
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->ReadByteString();
OString aRet;
const ImpRCStack& rTop = aStack[nCurStack];
if( (rTop.Flags & RCFlags::NOTFOUND) )
{
#if OSL_DEBUG_LEVEL > 0
aRet = OString( "<resource not found>" );
#endif
}
else
Increment( GetByteString( aRet, static_cast<const sal_uInt8*>(GetClass()) ) );
return aRet;
}
OString ResMgr::GetAutoHelpId()
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( pFallbackResMgr )
return pFallbackResMgr->GetAutoHelpId();
OSL_ENSURE( nCurStack, "resource stack empty in Auto help id generation" );
if( nCurStack < 1 || nCurStack > 2 )
return OString();
// prepare HID, start with resource prefix
OStringBuffer aHID( 32 );
aHID.append( OUStringToOString( pImpRes->aPrefix, RTL_TEXTENCODING_UTF8 ) );
aHID.append( '.' );
// append type
const ImpRCStack *pRC = StackTop();
OSL_ENSURE( pRC, "missing resource stack level" );
if ( nCurStack == 1 )
{
// auto help ids for top level windows
switch( pRC->pResource->GetRT() ) {
case RSC_DOCKINGWINDOW: aHID.append( "DockingWindow" ); break;
case RSC_WORKWIN: aHID.append( "WorkWindow" ); break;
default: return OString();
}
}
else
{
// only controls with the following parents get auto help ids
const ImpRCStack *pRC1 = StackTop(1);
switch( pRC1->pResource->GetRT() ) {
case RSC_DOCKINGWINDOW:
case RSC_WORKWIN:
// intentionally no breaks!
// auto help ids for controls
switch( pRC->pResource->GetRT() ) {
case RSC_RADIOBUTTON: aHID.append( "RadioButton" ); break;
case RSC_CHECKBOX: aHID.append( "CheckBox" ); break;
case RSC_EDIT: aHID.append( "Edit" ); break;
case RSC_LISTBOX: aHID.append( "ListBox" ); break;
case RSC_COMBOBOX: aHID.append( "ComboBox" ); break;
case RSC_PUSHBUTTON: aHID.append( "PushButton" ); break;
case RSC_SPINFIELD: aHID.append( "SpinField" ); break;
case RSC_NUMERICFIELD: aHID.append( "NumericField" ); break;
case RSC_METRICFIELD: aHID.append( "MetricField" ); break;
case RSC_IMAGEBUTTON: aHID.append( "ImageButton" ); break;
default:
// no type, no auto HID
return OString();
}
break;
default:
return OString();
}
}
// append resource id hierarchy
for( int nOff = nCurStack-1; nOff >= 0; nOff-- )
{
aHID.append( '.' );
pRC = StackTop( nOff );
OSL_ENSURE( pRC->pResource, "missing resource in resource stack level !" );
if( pRC->pResource )
aHID.append( sal_Int32( pRC->pResource->GetId() ) );
}
return aHID.makeStringAndClear();
}
2000-12-05 18:23:20 +00:00
void ResMgr::SetReadStringHook( ResHookProc pProc )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
2000-12-05 18:23:20 +00:00
pImplResHookProc = pProc;
}
ResHookProc ResMgr::GetReadStringHook()
{
return pImplResHookProc;
}
void ResMgr::SetDefaultLocale( const LanguageTag& rLocale )
{
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
ResMgrContainer::get().setDefLocale( rLocale );
}
const OUString& ResMgr::GetFileName() const
{
return pImpRes->aFileName;
}
2000-09-18 16:07:07 +00:00
SimpleResMgr::SimpleResMgr( const sal_Char* pPrefixName,
const LanguageTag& rLocale )
2000-09-18 16:07:07 +00:00
{
OUString aPrefix( pPrefixName, strlen( pPrefixName ), osl_getThreadTextEncoding() );
LanguageTag aLocale( rLocale );
osl::Guard<osl::Mutex> aGuard( getResMgrMutex() );
if( aLocale.isSystemLocale() )
aLocale = ResMgrContainer::get().getDefLocale();
2000-09-18 16:07:07 +00:00
m_pResImpl = ResMgrContainer::get().getResMgr( aPrefix, aLocale, true );
DBG_ASSERT( m_pResImpl, "SimpleResMgr::SimpleResMgr : have no impl class !" );
2000-09-18 16:07:07 +00:00
}
SimpleResMgr::~SimpleResMgr()
{
delete m_pResImpl;
}
SimpleResMgr* SimpleResMgr::Create(const sal_Char* pPrefixName, const LanguageTag& rLocale)
{
return new SimpleResMgr(pPrefixName, rLocale);
2000-09-18 16:07:07 +00:00
}
bool SimpleResMgr::IsAvailable( RESOURCE_TYPE _resourceType, sal_uInt32 _resourceId )
{
osl::MutexGuard aGuard(m_aAccessSafety);
if ( ( RSC_STRING != _resourceType ) && ( RSC_RESOURCE != _resourceType ) )
return false;
DBG_ASSERT( m_pResImpl, "SimpleResMgr::IsAvailable: have no impl class !" );
return m_pResImpl->IsGlobalAvailable( _resourceType, _resourceId );
}
2000-09-18 16:07:07 +00:00
OUString SimpleResMgr::ReadString( sal_uInt32 nId )
2000-09-18 16:07:07 +00:00
{
osl::MutexGuard aGuard(m_aAccessSafety);
2000-09-18 16:07:07 +00:00
DBG_ASSERT( m_pResImpl, "SimpleResMgr::ReadString : have no impl class !" );
// perhaps constructed with an invalid filename ?
OUString sReturn;
2000-09-18 16:07:07 +00:00
if ( !m_pResImpl )
return sReturn;
void* pResHandle = NULL;
InternalResMgr* pFallback = m_pResImpl;
RSHEADER_TYPE* pResHeader = static_cast<RSHEADER_TYPE*>(m_pResImpl->LoadGlobalRes( RSC_STRING, nId, &pResHandle ));
2000-09-18 16:07:07 +00:00
if ( !pResHeader )
{
osl::Guard<osl::Mutex> aGuard2( getResMgrMutex() );
// try fallback
while( ! pResHandle && pFallback )
{
InternalResMgr* pOldFallback = pFallback;
pFallback = ResMgrContainer::get().getNextFallback( pFallback );
if( pOldFallback != m_pResImpl )
ResMgrContainer::get().freeResMgr( pOldFallback );
if( pFallback )
{
// handle possible recursion
if( pFallback->aLocale != m_pResImpl->aLocale )
{
pResHeader = static_cast<RSHEADER_TYPE*>(pFallback->LoadGlobalRes( RSC_STRING, nId, &pResHandle ));
}
else
{
ResMgrContainer::get().freeResMgr( pFallback );
pFallback = NULL;
}
}
}
if( ! pResHandle )
// no such resource
return sReturn;
}
2000-09-18 16:07:07 +00:00
// sal_uIntPtr nLen = pResHeader->GetLocalOff() - sizeof(RSHEADER_TYPE);
ResMgr::GetString( sReturn, reinterpret_cast<sal_uInt8*>(pResHeader+1) );
2000-09-18 16:07:07 +00:00
2014-04-09 12:37:04 +02:00
// not necessary with the current implementation which holds the string table permanently, but to be sure ....
// note: pFallback cannot be NULL here and is either the fallback or m_pResImpl
InternalResMgr::FreeGlobalRes( pResHeader, pResHandle );
if( m_pResImpl != pFallback )
{
osl::Guard<osl::Mutex> aGuard2( getResMgrMutex() );
ResMgrContainer::get().freeResMgr( pFallback );
}
2000-09-18 16:07:07 +00:00
return sReturn;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */