diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-18 21:42:23 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-11-18 21:47:10 -0500 |
commit | 764600bc6175a32d119487afda2e8409f3395666 (patch) | |
tree | 605b752d773d8611b67d089869c50e870126fa20 /tools | |
parent | 1b9aaba0bfe8bc0872e7ea9f9aef5961e4b52f7c (diff) |
Apply pimpl to ResStringArray, to hide its internals.
Change-Id: I23969735f35e221a1aad39081ee63d02066d856f
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/rc/resary.cxx | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/tools/source/rc/resary.cxx b/tools/source/rc/resary.cxx index dac1d94df054..03854d31eec0 100644 --- a/tools/source/rc/resary.cxx +++ b/tools/source/rc/resary.cxx @@ -17,11 +17,34 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <tools/resmgr.hxx> #include <tools/resary.hxx> +#include <tools/resmgr.hxx> #include <tools/rcid.h> -ResStringArray::ResStringArray( const ResId& rResId ) +#include <vector> + +namespace { + +struct ImplResStringItem +{ + OUString m_aStr; + sal_IntPtr m_nValue; + + ImplResStringItem( const OUString& rStr, long nValue = 0 ) : + m_aStr(rStr), + m_nValue(nValue) + { } +}; + +} + +struct ResStringArray::Impl +{ + std::vector<ImplResStringItem> m_aStrings; +}; + +ResStringArray::ResStringArray( const ResId& rResId ) : + mpImpl(new Impl) { rResId.SetRT( RSC_STRINGARRAY ); ResMgr* pMgr = rResId.GetResMgr(); @@ -32,14 +55,14 @@ ResStringArray::ResStringArray( const ResId& rResId ) const sal_uInt32 nItems = pMgr->ReadLong(); if ( nItems ) { - m_aStrings.reserve( nItems ); + mpImpl->m_aStrings.reserve( nItems ); for ( sal_uInt32 i = 0; i < nItems; i++ ) { // load string - m_aStrings.push_back( ImplResStringItem( pMgr->ReadString() ) ); + mpImpl->m_aStrings.push_back(ImplResStringItem(pMgr->ReadString())); // load value - m_aStrings[i].m_nValue = pMgr->ReadLong(); + mpImpl->m_aStrings[i].m_nValue = pMgr->ReadLong(); } } } @@ -47,14 +70,30 @@ ResStringArray::ResStringArray( const ResId& rResId ) ResStringArray::~ResStringArray() { + delete mpImpl; +} + +OUString ResStringArray::GetString( sal_uInt32 nIndex ) const +{ + return (nIndex < mpImpl->m_aStrings.size()) ? mpImpl->m_aStrings[nIndex].m_aStr : OUString(); +} + +sal_IntPtr ResStringArray::GetValue( sal_uInt32 nIndex ) const +{ + return (nIndex < mpImpl->m_aStrings.size()) ? mpImpl->m_aStrings[nIndex].m_nValue : -1; +} + +sal_uInt32 ResStringArray::Count() const +{ + return sal_uInt32(mpImpl->m_aStrings.size()); } sal_uInt32 ResStringArray::FindIndex( sal_IntPtr nValue ) const { - const sal_uInt32 nItems = m_aStrings.size(); + const sal_uInt32 nItems = mpImpl->m_aStrings.size(); for ( sal_uInt32 i = 0; i < nItems; i++ ) { - if ( m_aStrings[i].m_nValue == nValue ) + if (mpImpl->m_aStrings[i].m_nValue == nValue) return i; } return RESARRAY_INDEX_NOTFOUND; @@ -62,8 +101,8 @@ sal_uInt32 ResStringArray::FindIndex( sal_IntPtr nValue ) const sal_uInt32 ResStringArray::AddItem( const OUString& rString, sal_IntPtr nValue ) { - m_aStrings.push_back( ImplResStringItem( rString, nValue)); - return m_aStrings.size(); + mpImpl->m_aStrings.push_back(ImplResStringItem(rString, nValue)); + return mpImpl->m_aStrings.size(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |