1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX 25 #define COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX 26 27 #include <comphelper/comphelperdllapi.h> 28 29 /** === begin UNO includes === **/ 30 #include <com/sun/star/uno/XComponentContext.hpp> 31 /** === end UNO includes === **/ 32 #include <rtl/ustring.hxx> 33 34 #include <memory> 35 36 //........................................................................ 37 namespace comphelper 38 { 39 //........................................................................ 40 41 //==================================================================== 42 //= OfficeResourceBundle 43 //==================================================================== 44 class ResourceBundle_Impl; 45 /** wraps the <type scope="com::sun::star::resource">OfficeResourceAccess</type> service 46 */ 47 class COMPHELPER_DLLPUBLIC OfficeResourceBundle 48 { 49 private: 50 ::std::auto_ptr< ResourceBundle_Impl > m_pImpl; 51 52 public: 53 /** constructs a resource bundle 54 @param _context 55 the component context to operate in 56 @param _bundleBaseName 57 the base name of the resource file which should be accessed (*without* the SUPD!) 58 @raises ::com::sun::star::lang::NullPointerException 59 if the given component context is <NULL/> 60 */ 61 OfficeResourceBundle( 62 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _context, 63 const ::rtl::OUString& _bundleBaseName 64 ); 65 66 /** constructs a resource bundle with the resource bundle given as 8-bit ASCII name 67 68 This is a convenience constructor only, it does nothing different than the constructor 69 taking an unicode string. 70 71 @param _context 72 the component context to operate in 73 @param _bundleBaseName 74 the base name of the resource file which should be accessed (*without* the SUPD!) 75 @raises ::com::sun::star::lang::NullPointerException 76 if the given component context is <NULL/> 77 */ 78 OfficeResourceBundle( 79 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _context, 80 const sal_Char* _bundleBaseAsciiName 81 ); 82 83 /** destroys the instance 84 */ 85 ~OfficeResourceBundle(); 86 87 /** loads the string with the given resource id from the resource bundle 88 @param _resourceId 89 the id of the string to load 90 @return 91 the requested resource string. If no string with the given id exists in the resource bundle, 92 an empty string is returned. In a non-product version, an OSL_ENSURE will notify you of this 93 then. 94 */ 95 ::rtl::OUString loadString( sal_Int32 _resourceId ) const; 96 97 /** determines whether the resource bundle has a string with the given id 98 @param _resourceId 99 the id of the string whose existence is to be checked 100 @return 101 <TRUE/> if and only if a string with the given ID exists in the resource 102 bundle. 103 */ 104 bool hasString( sal_Int32 _resourceId ) const; 105 }; 106 107 //........................................................................ 108 } // namespace comphelper 109 //........................................................................ 110 111 #endif // COMPHELPER_OFFICE_RESOURCE_BUNDLE_HXX 112 113