00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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