[Libreoffice-commits] .: 6 commits - configmgr/source framework/source sfx2/inc sfx2/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon May 23 04:31:56 PDT 2011
configmgr/source/childaccess.cxx | 82 ++++++++++++------
framework/source/uiconfiguration/imagemanagerimpl.cxx | 22 ++--
sfx2/inc/sfx2/docfac.hxx | 14 +--
sfx2/source/appl/module.cxx | 9 +
sfx2/source/doc/docfac.cxx | 1
5 files changed, 78 insertions(+), 50 deletions(-)
New commits:
commit be49f936e3f4a9155e1c6a877132cdbc8af91589
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon May 23 12:29:31 2011 +0100
Resolves: fdo#33638 add extra level of language tag matching
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index 3d9c40b..fc8e1ca 100644
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -271,6 +271,17 @@ void ChildAccess::setProperty(
localModifications->add(getRelativePath());
}
+namespace
+{
+ rtl::OUString lcl_StripSegment(const rtl::OUString &rLocale)
+ {
+ sal_Int32 i = rLocale.getLength() ? rLocale.getLength() - 1 : 0;
+ while (i > 0 && rLocale[i] != '-' && rLocale[i] != '_')
+ --i;
+ return rLocale.copy(0, i);
+ }
+}
+
css::uno::Any ChildAccess::asValue() {
if (changedValue_.get() != 0) {
return *changedValue_;
@@ -281,43 +292,62 @@ css::uno::Any ChildAccess::asValue() {
getComponents());
case Node::KIND_LOCALIZED_PROPERTY:
{
- rtl::OUString locale(getRootAccess()->getLocale());
- if (!Components::allLocales(locale)) {
- // Find best match using an adaption of RFC 4647 lookup matching
- // rules, removing "-" or "_" delimited segments from the end;
- // defaults are the "en-US" locale, the "en" locale, the empty
- // string locale, the first child (if any), or a nil value (even
- // though it may be illegal for the given property), in that
- // order:
+ rtl::OUString sLocale(getRootAccess()->getLocale());
+ if (!Components::allLocales(sLocale))
+ {
rtl::Reference< ChildAccess > child;
- for (;;) {
- child = getChild(locale);
- if (child.is() || locale.getLength() == 0) {
+ // Find best match using an adaption of RFC 4647 lookup matching
+ // rules, removing "-" or "_" delimited segments from the end
+ while (1)
+ {
+ child = getChild(sLocale);
+ if (child.is())
break;
- }
- sal_Int32 i = locale.getLength() - 1;
- while (i > 0 && locale[i] != '-' && locale[i] != '_') {
- --i;
- }
- if (i == 0) {
+ rtl::OUString sTmpLocale = lcl_StripSegment(sLocale);
+ if (!sTmpLocale.getLength())
break;
+ sLocale = sTmpLocale;
+ }
+
+ //Resolves: fdo#33638 Look for the first entry with the same
+ //first segment as the requested language tag, before falling
+ //back to en-US, etc.
+ typedef std::vector< rtl::Reference< ChildAccess > > ChildVector;
+ if (!child.is())
+ {
+ const ChildVector &rAllChildren = getAllChildren();
+ for (ChildVector::const_iterator aI = rAllChildren.begin(),
+ aEnd = rAllChildren.end(); aI != aEnd; ++aI)
+ {
+ rtl::OUString sLanguage = lcl_StripSegment((*aI)->getNameInternal());
+ if (sLocale == sLanguage)
+ {
+ child = *aI;
+ break;
+ }
}
- locale = locale.copy(0, i);
}
- if (!child.is()) {
+
+ // defaults are the "en-US" locale, the "en" locale, the empty
+ // string locale, the first child (if any), or a nil value (even
+ // though it may be illegal for the given property), in that
+ // order:
+ if (!child.is())
+ {
child = getChild(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en-US")));
- if (!child.is()) {
+ if (!child.is())
+ {
child = getChild(
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en")));
- if (!child.is()) {
+ if (!child.is())
+ {
child = getChild(rtl::OUString());
- if (!child.is()) {
- std::vector< rtl::Reference< ChildAccess > >
- all(getAllChildren());
- if (!all.empty()) {
+ if (!child.is())
+ {
+ ChildVector all(getAllChildren());
+ if (!all.empty())
child = all.front();
- }
}
}
}
commit 0102f117880ecc9fb158f8c63321b790bc282e26
Author: Caolán McNamara <caolanm at redhat.com>
Date: Sun May 22 16:40:01 2011 +0100
fix leak
diff --git a/sfx2/source/appl/module.cxx b/sfx2/source/appl/module.cxx
index 1b1c84c..0351d46 100644
--- a/sfx2/source/appl/module.cxx
+++ b/sfx2/source/appl/module.cxx
@@ -357,10 +357,11 @@ void SfxModule::DestroyModules_Impl()
{
SfxModuleArr_Impl& rModules = *pModules;
for( sal_uInt16 nPos = rModules.Count(); nPos--; )
- {
- SfxModule* pMod = rModules.GetObject(nPos);
- delete pMod;
- }
+ {
+ SfxModule* pMod = rModules.GetObject(nPos);
+ delete pMod;
+ }
+ delete pModules, pModules = 0;
}
}
commit 867a8eb32e0f75ec495ac5c4ee40c2adf905f5bc
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 23:03:34 2011 +0100
make this a non-leaky singleton
diff --git a/sfx2/inc/sfx2/docfac.hxx b/sfx2/inc/sfx2/docfac.hxx
index 8f5cf0b..fb89ea4 100644
--- a/sfx2/inc/sfx2/docfac.hxx
+++ b/sfx2/inc/sfx2/docfac.hxx
@@ -122,20 +122,16 @@ private:
//=========================================================================
#define SFX_DECL_OBJECTFACTORY() \
-private: \
- static SfxObjectFactory* pObjectFactory; \
public: \
static SfxObjectFactory& Factory(); \
virtual SfxObjectFactory& GetFactory() const { return Factory(); }
#define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,Flags,ShortName) \
- SfxObjectFactory* ClassName::pObjectFactory = 0; \
- SfxObjectFactory& ClassName::Factory() \
- { if (!pObjectFactory) \
- pObjectFactory = \
- new SfxObjectFactory( GlobName, Flags, ShortName ); \
- return *pObjectFactory; \
- }
+ SfxObjectFactory& ClassName::Factory() \
+ { \
+ static SfxObjectFactory aObjectFactory(GlobName, Flags, ShortName); \
+ return aObjectFactory; \
+ }
#endif // #ifndef _SFX_OBJFAC_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit b2091208c8efdff44d6a331424de9662e94d9dc1
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 23:02:40 2011 +0100
remove leak
diff --git a/sfx2/source/doc/docfac.cxx b/sfx2/source/doc/docfac.cxx
index 7963f0c..cbd4082 100644
--- a/sfx2/source/doc/docfac.cxx
+++ b/sfx2/source/doc/docfac.cxx
@@ -148,6 +148,7 @@ SfxObjectFactory::~SfxObjectFactory()
for ( sal_uInt16 i = 0; i < nCount; ++i )
delete pImpl->aFilterArr[i];
delete pImpl->pNameResId;
+ delete pImpl->pFilterContainer;
delete pImpl;
}
commit 86f82f86055330dabffaf1e3143be1b3debc47bb
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 20:56:10 2011 +0100
this can be const
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index bc5e741..3741c7d 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -91,6 +91,8 @@ static const char IMAGE_FOLDER[] = "images";
static const char BITMAPS_FOLDER[] = "Bitmaps";
static const char IMAGE_EXTENSION[] = ".png";
+static const char ModuleImageList[] = "private:resource/images/moduleimages";
+
static const char* IMAGELIST_XML_FILE[] =
{
"sc_imagelist.xml",
@@ -105,7 +107,6 @@ static const char* BITMAP_FILE_NAMES[] =
namespace framework
{
- static char ModuleImageList[] = "private:resource/images/moduleimages";
static GlobalImageList* pGlobalImageList = 0;
static const char* ImageType_Prefixes[ImageType_COUNT] =
{
commit f286daa7298190ba4852ad7e4231d26be60097a2
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri May 20 20:52:40 2011 +0100
convert to non-leaky singleton
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index 44de6e2..bc5e741 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -61,7 +61,8 @@
#include <vcl/pngread.hxx>
#include <vcl/pngwrite.hxx>
#include <rtl/logfile.hxx>
-#include "svtools/miscopt.hxx"
+#include <rtl/instance.hxx>
+#include <svtools/miscopt.hxx>
using ::rtl::OUString;
using ::com::sun::star::uno::Sequence;
@@ -105,7 +106,6 @@ static const char* BITMAP_FILE_NAMES[] =
namespace framework
{
static char ModuleImageList[] = "private:resource/images/moduleimages";
- static osl::Mutex* pImageListWrapperMutex = 0;
static GlobalImageList* pGlobalImageList = 0;
static const char* ImageType_Prefixes[ImageType_COUNT] =
{
@@ -115,16 +115,15 @@ namespace framework
typedef GraphicNameAccess CmdToXGraphicNameAccess;
-static osl::Mutex& getGlobalImageListMutex()
+namespace
{
- if ( pImageListWrapperMutex == 0 )
- {
- osl::MutexGuard aGuard( osl::Mutex::getGlobalMutex() ) ;
- if ( pImageListWrapperMutex == 0 )
- pImageListWrapperMutex = new osl::Mutex;
- }
+ class theGlobalImageListMutex
+ : public rtl::Static<osl::Mutex, theGlobalImageListMutex> {};
+}
- return *pImageListWrapperMutex;
+static osl::Mutex& getGlobalImageListMutex()
+{
+ return theGlobalImageListMutex::get();
}
static GlobalImageList* getGlobalImageList( const uno::Reference< XMultiServiceFactory >& rServiceManager )
More information about the Libreoffice-commits
mailing list