1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX 29 #define COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX 30 31 #include <comphelper/comphelperdllapi.h> 32 33 /** === begin UNO includes === **/ 34 #include <com/sun/star/uno/XComponentContext.hpp> 35 /** === end UNO includes === **/ 36 #include <rtl/ustring.hxx> 37 38 #include <memory> 39 40 //........................................................................ 41 namespace comphelper 42 { 43 //........................................................................ 44 45 //==================================================================== 46 //= OfficeResourceBundle 47 //==================================================================== 48 class ResourceBundle_Impl; 49 /** wraps the <type scope="com::sun::star::resource">OfficeResourceAccess</type> service 50 */ 51 class COMPHELPER_DLLPUBLIC OfficeResourceBundle 52 { 53 private: 54 ::std::auto_ptr< ResourceBundle_Impl > m_pImpl; 55 56 public: 57 /** constructs a resource bundle 58 @param _context 59 the component context to operate in 60 @param _bundleBaseName 61 the base name of the resource file which should be accessed (*without* the SUPD!) 62 @raises ::com::sun::star::lang::NullPointerException 63 if the given component context is <NULL/> 64 */ 65 OfficeResourceBundle( 66 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _context, 67 const ::rtl::OUString& _bundleBaseName 68 ); 69 70 /** constructs a resource bundle with the resource bundle given as 8-bit ASCII name 71 72 This is a convenience constructor only, it does nothing different than the constructor 73 taking an unicode string. 74 75 @param _context 76 the component context to operate in 77 @param _bundleBaseName 78 the base name of the resource file which should be accessed (*without* the SUPD!) 79 @raises ::com::sun::star::lang::NullPointerException 80 if the given component context is <NULL/> 81 */ 82 OfficeResourceBundle( 83 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _context, 84 const sal_Char* _bundleBaseAsciiName 85 ); 86 87 /** destroys the instance 88 */ 89 ~OfficeResourceBundle(); 90 91 /** loads the string with the given resource id from the resource bundle 92 @param _resourceId 93 the id of the string to load 94 @return 95 the requested resource string. If no string with the given id exists in the resource bundle, 96 an empty string is returned. In a non-product version, an OSL_ENSURE will notify you of this 97 then. 98 */ 99 ::rtl::OUString loadString( sal_Int32 _resourceId ) const; 100 101 /** determines whether the resource bundle has a string with the given id 102 @param _resourceId 103 the id of the string whose existence is to be checked 104 @return 105 <TRUE/> if and only if a string with the given ID exists in the resource 106 bundle. 107 */ 108 bool hasString( sal_Int32 _resourceId ) const; 109 }; 110 111 //........................................................................ 112 } // namespace comphelper 113 //........................................................................ 114 115 #endif // COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX 116 117