diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-06-25 15:42:29 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-06-25 16:24:58 +0100 |
commit | d54830a9b608cbd1792d37ee51797b825ab644e5 (patch) | |
tree | 184f44ba1db02e531679ced748ed6490439b3305 /extensions | |
parent | 18b15e48cb1fa7590620930975796a0c0dcac225 (diff) |
throw an exception if a given resource file is not found
Change-Id: I8929e9b2cdeffa4d893f795a66809475a7cdae19
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/source/resource/ResourceIndexAccess.cxx | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/extensions/source/resource/ResourceIndexAccess.cxx b/extensions/source/resource/ResourceIndexAccess.cxx index 523a5fd5abd3..7b99e83ef5af 100644 --- a/extensions/source/resource/ResourceIndexAccess.cxx +++ b/extensions/source/resource/ResourceIndexAccess.cxx @@ -70,7 +70,7 @@ namespace ResourceIndexAccessBase( ::boost::shared_ptr<ResMgr> pResMgr) : m_pResMgr(pResMgr) { - OSL_ENSURE(m_pResMgr, "no ressource manager given"); + OSL_ENSURE(m_pResMgr, "no resource manager given"); } // XIndexAccess @@ -122,7 +122,7 @@ Reference<XInterface> initResourceIndexAccess(ResourceIndexAccess* pResourceInde // and will crash on getByIndex calls, better just give back an empty Reference // so that such ResourceStringIndexAccess instances are never release into the wild throw RuntimeException( - OUString(RTL_CONSTASCII_USTRINGPARAM("ressource manager could not get initialized")), + OUString(RTL_CONSTASCII_USTRINGPARAM("resource manager could not get initialized")), /* xResult */ Reference<XInterface>()); return xResult; } @@ -172,12 +172,19 @@ Any SAL_CALL ResourceStringIndexAccess::getByIndex(sal_Int32 nIdx) if(nIdx > SAL_MAX_UINT16 || nIdx < 0) throw IndexOutOfBoundsException(); SolarMutexGuard aGuard; + if(!m_pResMgr.get()) + throw RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM("resource manager not available")), + Reference<XInterface>()); + const ResId aId(static_cast<sal_uInt16>(nIdx), *m_pResMgr); aId.SetRT(RSC_STRING); + if(!m_pResMgr->IsAvailable(aId)) throw RuntimeException( - OUString(RTL_CONSTASCII_USTRINGPARAM("string ressource for id not available")), + OUString(RTL_CONSTASCII_USTRINGPARAM("string resource for id not available")), Reference<XInterface>()); + return makeAny(OUString(String(aId))); } @@ -187,11 +194,17 @@ Any SAL_CALL ResourceStringListIndexAccess::getByIndex(sal_Int32 nIdx) if(nIdx > SAL_MAX_UINT16 || nIdx < 0) throw IndexOutOfBoundsException(); SolarMutexGuard aGuard; + + if(!m_pResMgr.get()) + throw RuntimeException( + OUString(RTL_CONSTASCII_USTRINGPARAM("resource manager not available")), + Reference<XInterface>()); + const ResId aId(static_cast<sal_uInt16>(nIdx), *m_pResMgr); aId.SetRT(RSC_STRINGARRAY); if(!m_pResMgr->IsAvailable(aId)) throw RuntimeException( - OUString(RTL_CONSTASCII_USTRINGPARAM("string list ressource for id not available")), + OUString(RTL_CONSTASCII_USTRINGPARAM("string list resource for id not available")), Reference<XInterface>()); const ResStringArray aStringList(aId); Sequence<PropertyValue> aPropList(aStringList.Count()); |