source/inc/resmgr.hxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  The Contents of this file are made available subject to
00004  *  the terms of GNU Lesser General Public License Version 2.1.
00005  *
00006  *
00007  *    GNU Lesser General Public License Version 2.1
00008  *    =============================================
00009  *    Copyright 2005 by Kohei Yoshida.
00010  *    1039 Kingsway Dr., Apex, NC 27502, USA
00011  *
00012  *    This library is free software; you can redistribute it and/or
00013  *    modify it under the terms of the GNU Lesser General Public
00014  *    License version 2.1, as published by the Free Software Foundation.
00015  *
00016  *    This library is distributed in the hope that it will be useful,
00017  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *    Lesser General Public License for more details.
00020  *
00021  *    You should have received a copy of the GNU Lesser General Public
00022  *    License along with this library; if not, write to the Free Software
00023  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024  *    MA  02111-1307  USA
00025  *
00026  ************************************************************************/
00027 
00028 #ifndef _SCSOLVER_UI_RESMGR_HXX_
00029 #define _SCSOLVER_UI_RESMGR_HXX_
00030 
00031 #include <com/sun/star/uno/XComponentContext.hpp>
00032 #include <com/sun/star/resource/XStringResourceManager.hpp>
00033 #include "rtl/ustring.hxx"
00034 
00035 #include <vector>
00036 
00037 namespace com { namespace sun { namespace star { 
00038     namespace lang {
00039         struct Locale;
00040     }
00041     namespace ucb {
00042         class XSimpleFileAccess;
00043     }
00044 }}}
00045 
00046 namespace scsolver {
00047 
00048 class CalcInterface;
00049 
00050 class StringResMgr
00051 {
00052 public:
00053     struct Entry
00054     {
00055         ::rtl::OUString Name;
00056         ::rtl::OUString Value;
00057     };
00058 
00059     StringResMgr(CalcInterface* pCalc);
00060     ~StringResMgr();
00061 
00068     const ::rtl::OUString getSystemLocaleString() const;
00069 
00070     const ::com::sun::star::lang::Locale getSystemLocale() const;
00071 
00081     const ::rtl::OUString getLocaleStr(int resid);
00082 
00083     const ::rtl::OUString getLocaleStr(const ::rtl::OUString& resName);
00084 
00085 private:
00086     struct PropertiesFile
00087     {
00088         ::rtl::OUString FilePath;
00089         ::com::sun::star::lang::Locale Locale;
00090     };
00091 
00092     void init();
00093 
00094     ::rtl::OUString getResNameByID(int resid);
00095 
00100     void loadStrings();
00101 
00102     void loadStrings(const PropertiesFile& propFile);
00103 
00104     void getPropertiesFiles(::std::vector<PropertiesFile>& files);
00105 
00106     void parsePropertiesStream(const ::com::sun::star::uno::Sequence<sal_Int8>& bytes,
00107                                ::std::vector<Entry>& rEntries);
00108 
00109     ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >
00110         getSimpleFileAccess();
00111 
00112 private:
00113     ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager >
00114         mxStrResMgr;
00115     ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >
00116         mxFileAccess;
00117     CalcInterface* mpCalc;
00118     ::rtl::OUString msBaseTransDirPath;
00119     ::std::vector< ::rtl::OUString > mResNameMapper;
00120     bool mbStringLoaded:1;
00121 };
00122 
00123 // ---------------------------------------------------------------------------
00124 
00125 class PropStreamParser
00126 {
00127 public:
00128 
00129     PropStreamParser(const ::com::sun::star::uno::Sequence<sal_Int8>& bytes);
00130     ~PropStreamParser();
00131 
00141     void parse();
00142     void getEntries(::std::vector<StringResMgr::Entry>& rEntries) const;
00143 
00144 private:
00145     PropStreamParser();
00146 
00147     void advanceToLinefeed(sal_Int32& i) const;
00148     void purgeBuffer(::rtl::OUString& rValue, ::std::vector<sal_Char>& rBuf) const;
00149     void pushEntry(const ::rtl::OUString& name, const ::rtl::OUString& value);
00150 
00151 private:
00152     const ::com::sun::star::uno::Sequence<sal_Int8>& mrBytes;
00153     ::std::vector<StringResMgr::Entry> mEntries;
00154 };
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 }
00166 
00167 #endif

Generated on Mon Jul 28 09:13:20 2008 for scsolver by  doxygen 1.5.3