[Libreoffice-commits] .: svl/inc svl/Library_svl.mk svl/Package_inc.mk svl/source

Stephan Bergmann sbergmann at kemper.freedesktop.org
Fri Sep 30 10:07:06 PDT 2011


 svl/Library_svl.mk                    |    2 
 svl/Package_inc.mk                    |    1 
 svl/inc/svl/itempool.hxx              |    2 
 svl/inc/svl/svldata.hxx               |   72 ------------------------
 svl/source/items/dateitem.cxx         |    1 
 svl/source/items/itempool.cxx         |    1 
 svl/source/items/poolio.cxx           |    7 +-
 svl/source/misc/getstringresource.cxx |  101 ++++++++++++++++++++++++++++++++++
 svl/source/misc/getstringresource.hxx |   50 ++++++++++++++++
 svl/source/misc/inettype.cxx          |    5 +
 svl/source/misc/svldata.cxx           |   87 -----------------------------
 11 files changed, 161 insertions(+), 168 deletions(-)

New commits:
commit c35ad52639b3a1f79fa9ec884096a4a0f65bb973
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 30 19:03:03 2011 +0200

    Cleaned up svldata.

diff --git a/svl/Library_svl.mk b/svl/Library_svl.mk
index 3c7164c..0fb7477 100644
--- a/svl/Library_svl.mk
+++ b/svl/Library_svl.mk
@@ -117,6 +117,7 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
     svl/source/misc/filenotation \
     svl/source/misc/folderrestriction \
     svl/source/misc/fstathelper \
+    svl/source/misc/getstringresource \
     svl/source/misc/inethist \
     svl/source/misc/inettype \
     svl/source/misc/lngmisc \
@@ -125,7 +126,6 @@ $(eval $(call gb_Library_add_exception_objects,svl,\
     svl/source/misc/restrictedpaths \
     svl/source/misc/sharecontrolfile \
     svl/source/misc/strmadpt \
-    svl/source/misc/svldata \
     svl/source/misc/urihelper \
     svl/source/notify/brdcst \
     svl/source/notify/broadcast \
diff --git a/svl/Package_inc.mk b/svl/Package_inc.mk
index 5f65c03..7e72d1c 100644
--- a/svl/Package_inc.mk
+++ b/svl/Package_inc.mk
@@ -114,7 +114,6 @@ $(eval $(call gb_Package_add_file,svl_inc,inc/svl/stylepool.hxx,svl/stylepool.hx
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svarray.hxx,svl/svarray.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svdde.hxx,svl/svdde.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svl.hrc,svl/svl.hrc))
-$(eval $(call gb_Package_add_file,svl_inc,inc/svl/svldata.hxx,svl/svldata.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svldllapi.h,svl/svldllapi.h))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/svstdarr.hxx,svl/svstdarr.hxx))
 $(eval $(call gb_Package_add_file,svl_inc,inc/svl/szitem.hxx,svl/szitem.hxx))
diff --git a/svl/inc/svl/itempool.hxx b/svl/inc/svl/itempool.hxx
index 9027b89..27a8038 100644
--- a/svl/inc/svl/itempool.hxx
+++ b/svl/inc/svl/itempool.hxx
@@ -237,6 +237,8 @@ public:
 
 private:
     const SfxItemPool&              operator=(const SfxItemPool &);   // n.i.!!
+
+    static const SfxItemPool*       pStoringPool_;
 };
 
 // --------------- Inline Implementierungen ------------------------------
diff --git a/svl/inc/svl/svldata.hxx b/svl/inc/svl/svldata.hxx
deleted file mode 100644
index c498dd0..0000000
--- a/svl/inc/svl/svldata.hxx
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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 _SVL_SVLDATA_HXX
-#define _SVL_SVLDATA_HXX
-
-#include <tools/simplerm.hxx>
-#include <rtl/instance.hxx>
-
-class SfxItemPool;
-
-//============================================================================
-class ImpSvlData
-{
-public:
-    const SfxItemPool * pStoringPool;
-    void*           m_pThreadsafeRMs;
-        // one SimpleResMgr for each language for which a resource was requested
-        // (When using the 'non-simple' resmgr, the first request for any language wins, any
-        // further request for any other language supply the resmgr of the first call.
-        // For the simple resmgr we have a mgr for each language ever requested).
-
-    public: //TODO: should be private
-    ImpSvlData() : pStoringPool(0), m_pThreadsafeRMs(NULL) {}
-    ~ImpSvlData();
-
-public:
-    SimpleResMgr * GetSimpleRM(const ::com::sun::star::lang::Locale& rLocale);
-    static ImpSvlData & GetSvlData();
-};
-
-//============================================================================
-class SvtSimpleResId
-{
-    String  m_sValue;
-
-public:
-    SvtSimpleResId(sal_uInt16 nId, const ::com::sun::star::lang::Locale aLocale) : m_sValue(ImpSvlData::GetSvlData().GetSimpleRM(aLocale)->ReadString(nId)) { };
-
-    operator String () const { return m_sValue; }
-};
-
-
-
-#endif //  _SVL_SVLDATA_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/dateitem.cxx b/svl/source/items/dateitem.cxx
index 87c034e..28c7896 100644
--- a/svl/source/items/dateitem.cxx
+++ b/svl/source/items/dateitem.cxx
@@ -33,7 +33,6 @@
 
 #define _DATETIMEITEM_CXX
 #include <svl/dateitem.hxx>
-#include <svl/svldata.hxx>
 #include <svl/svl.hrc>
 
 #include <unotools/intlwrapper.hxx>
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index e5a499a..2bcef79 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -1060,5 +1060,6 @@ void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion )
         pPool->pImp->mnFileFormatVersion = nFileFormatVersion;
 }
 
+const SfxItemPool* SfxItemPool::pStoringPool_ = 0;
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx
index d719e98..5174498 100644
--- a/svl/source/items/poolio.cxx
+++ b/svl/source/items/poolio.cxx
@@ -37,7 +37,6 @@
 #include "whassert.hxx"
 #include <svl/brdcst.hxx>
 #include <svl/filerec.hxx>
-#include <svl/svldata.hxx>
 #include "poolio.hxx"
 
 // STATIC DATA -----------------------------------------------------------
@@ -58,7 +57,7 @@ const SfxItemPool* SfxItemPool::GetStoringPool()
 */
 
 {
-    return ImpSvlData::GetSvlData().pStoringPool;
+    return pStoringPool_;
 }
 
 //-------------------------------------------------------------------------
@@ -143,7 +142,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
 
     // jeder Pool ist als ganzes ein Record
     SfxMiniRecordWriter aPoolRec( &rStream, SFX_ITEMPOOL_REC );
-    ImpSvlData::GetSvlData().pStoringPool = this;
+    pStoringPool_ = this;
 
     // Einzel-Header (Version des Inhalts und Name)
     {
@@ -281,7 +280,7 @@ SvStream &SfxItemPool::Store(SvStream &rStream) const
     }
 
     // weitere Pools rausschreiben
-    ImpSvlData::GetSvlData().pStoringPool = 0;
+    pStoringPool_ = 0;
     aPoolRec.Close();
     if ( !rStream.GetError() && pImp->mpSecondary )
         pImp->mpSecondary->Store( rStream );
diff --git a/svl/source/misc/getstringresource.cxx b/svl/source/misc/getstringresource.cxx
new file mode 100644
index 0000000..6e5bbf8
--- /dev/null
+++ b/svl/source/misc/getstringresource.cxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_svl.hxx"
+#include "sal/config.h"
+
+#include <map>
+
+#include "boost/noncopyable.hpp"
+#include "boost/scoped_ptr.hpp"
+#include "com/sun/star/lang/Locale.hpp"
+#include "rtl/instance.hxx"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "tools/resmgr.hxx"
+#include "tools/simplerm.hxx"
+
+#include "getstringresource.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+class ResMgrMap: private boost::noncopyable {
+public:
+    ~ResMgrMap();
+
+    SimpleResMgr * get(css::lang::Locale const & locale);
+
+private:
+    typedef std::map< rtl::OUString, SimpleResMgr * > Map;
+
+    Map map_;
+        // one SimpleResMgr for each language for which a resource was requested
+        // (when using the "non-simple" resmgr, the first request for any
+        // language wins, any further requests for any other languages supply
+        // the resmgr of the first call; for the simple resmgr we have a mgr
+        // for each language ever requested)
+};
+
+ResMgrMap::~ResMgrMap() {
+    for (Map::iterator i(map_.begin()); i != map_.end(); ++i) {
+        delete i->second;
+    }
+}
+
+SimpleResMgr * ResMgrMap::get(css::lang::Locale const & locale) {
+    rtl::OUStringBuffer buf(locale.Language);
+    buf.append(sal_Unicode('-'));
+    buf.append(locale.Country);
+    rtl::OUString code(buf.makeStringAndClear());
+    Map::iterator i(map_.find(code));
+    if (i == map_.end()) {
+        boost::scoped_ptr< SimpleResMgr > mgr(
+            new SimpleResMgr(CREATEVERSIONRESMGR_NAME(svl), locale));
+        i = map_.insert(Map::value_type(code, mgr.get())).first;
+        mgr.reset();
+    }
+    return i->second;
+}
+
+struct theResMgrMap: public rtl::Static< ResMgrMap, theResMgrMap > {};
+
+}
+
+namespace svl {
+
+rtl::OUString getStringResource(sal_uInt16 id, css::lang::Locale const & locale)
+{
+    return theResMgrMap::get().get(locale)->ReadString(id);
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/misc/getstringresource.hxx b/svl/source/misc/getstringresource.hxx
new file mode 100644
index 0000000..99c5352
--- /dev/null
+++ b/svl/source/misc/getstringresource.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * 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_SVL_SOURCE_INC_GETSTRINGRESOURCE_HXX
+#define INCLUDED_SVL_SOURCE_INC_GETSTRINGRESOURCE_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+namespace com { namespace sun { namespace star { namespace lang {
+    struct Locale;
+} } } }
+namespace rtl { class OUString; }
+
+namespace svl {
+
+rtl::OUString getStringResource(
+    sal_uInt16 id, com::sun::star::lang::Locale const & locale);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx
index 686056e..1a75aba 100644
--- a/svl/source/misc/inettype.cxx
+++ b/svl/source/misc/inettype.cxx
@@ -31,9 +31,10 @@
 #include <tools/table.hxx>
 #include <tools/wldcrd.hxx>
 #include <svl/inettype.hxx>
-#include <svl/svldata.hxx>
 #include <svl/svl.hrc>
 
+#include "getstringresource.hxx"
+
 #ifndef _SVSTDARR_STRINGSSORT_DECL
 #define _SVSTDARR_STRINGSSORT
 #include <svl/svstdarr.hxx>
@@ -929,7 +930,7 @@ UniString INetContentTypes::GetPresentation(INetContentType eTypeID,
         else
             return aPresentation;
     }
-    return SvtSimpleResId(nResID, aLocale);
+    return svl::getStringResource(nResID, aLocale);
 }
 
 //============================================================================
diff --git a/svl/source/misc/svldata.cxx b/svl/source/misc/svldata.cxx
deleted file mode 100644
index c03ee02..0000000
--- a/svl/source/misc/svldata.cxx
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * 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_svl.hxx"
-
-#include <map>
-#include <tools/resmgr.hxx>
-#include <tools/shl.hxx>
-#include <svl/svldata.hxx>
-
-namespace
-{
-    typedef std::map< rtl::OUString, SimpleResMgr * > SimpleResMgrMap;
-}
-
-ImpSvlData::~ImpSvlData()
-{
-    if (m_pThreadsafeRMs)
-    {
-        SimpleResMgrMap *pThreadsafeRMs =
-            static_cast<SimpleResMgrMap*>(m_pThreadsafeRMs);
-        for (SimpleResMgrMap::iterator t = pThreadsafeRMs->begin(),
-             end = pThreadsafeRMs->end(); t != end; ++t)
-        {
-            delete t->second;
-        }
-        delete pThreadsafeRMs;
-    }
-}
-
-//============================================================================
-SimpleResMgr* ImpSvlData::GetSimpleRM(const ::com::sun::star::lang::Locale& rLocale)
-{
-    if (!m_pThreadsafeRMs)
-        m_pThreadsafeRMs = new SimpleResMgrMap;
-    rtl::OUString aISOcode = rLocale.Language;
-    aISOcode += rtl::OStringToOUString("-", RTL_TEXTENCODING_UTF8);
-    aISOcode += rLocale.Country;
-
-    SimpleResMgr *& rResMgr
-        = (*static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs))[aISOcode];
-    if (!rResMgr)
-    {
-        rResMgr = new SimpleResMgr(CREATEVERSIONRESMGR_NAME(svl), rLocale );
-    }
-    return rResMgr;
-}
-
-namespace
-{
-    class theSvlData : public rtl::Static< ImpSvlData, theSvlData > {};
-}
-
-//============================================================================
-// static
-ImpSvlData & ImpSvlData::GetSvlData()
-{
-    return theSvlData::get();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list