diff options
author | Noel Power <noel.power@novell.com> | 2010-10-06 10:32:27 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2010-10-06 10:32:27 +0100 |
commit | 48e0d844280937f54d65aca7ad4ce911bf02b5c4 (patch) | |
tree | 99053c7e6283979b632a442632e829b6a90d3a7d /svtools/source/misc/filterutils.cxx | |
parent | 6c84dc18062ec6aad71fd65a409373c274402991 (diff) |
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'svtools/source/misc/filterutils.cxx')
-rw-r--r-- | svtools/source/misc/filterutils.cxx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/svtools/source/misc/filterutils.cxx b/svtools/source/misc/filterutils.cxx new file mode 100644 index 000000000000..8f161b7e9fe8 --- /dev/null +++ b/svtools/source/misc/filterutils.cxx @@ -0,0 +1,56 @@ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" +#include "filterutils.hxx" +#include <rtl/ustrbuf.hxx> + +namespace svt +{ +//........................................................................ + + using namespace ::com::sun::star; + + rtl::OUString lcl_createStringFromArray( const char* pcCharArr, sal_uInt32 nBufSize, bool bIsCompressed ) + { + rtl::OUStringBuffer aBuffer; + if( bIsCompressed ) + { + // buffer contains compressed Unicode, not encoded bytestring + sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufSize ); + aBuffer.setLength( nStrLen ); + const char* pcCurrChar = pcCharArr; + for( sal_Int32 nChar = 0; nChar < nStrLen; ++nChar, ++pcCurrChar ) + /* *pcCurrChar may contain negative values and therefore MUST be + casted to unsigned char, before assigned to a sal_Unicode. */ + aBuffer.setCharAt( nChar, static_cast< unsigned char >( *pcCurrChar ) ); + } + else + { + // buffer contains Little-Endian Unicode + sal_Int32 nStrLen = static_cast< sal_Int32 >( nBufSize ) / 2; + aBuffer.setLength( nStrLen ); + const char* pcCurrChar = pcCharArr; + for( sal_Int32 nChar = 0; nChar < nStrLen; ++nChar ) + { + /* *pcCurrChar may contain negative values and therefore MUST be + casted to unsigned char, before assigned to a sal_Unicode. */ + sal_Unicode cChar = static_cast< unsigned char >( *pcCurrChar++ ); + cChar |= (static_cast< unsigned char >( *pcCurrChar++ ) << 8); + aBuffer.setCharAt( nChar, cChar ); + } + } + return aBuffer.makeStringAndClear(); + } + + rtl::OUString BinFilterUtils::CreateOUStringFromUniStringArray( const char* pcCharArr, sal_uInt32 nBufSize ) + { + return lcl_createStringFromArray( pcCharArr, nBufSize, false ); + } + + rtl::OUString BinFilterUtils::CreateOUStringFromStringArray( const char* pcCharArr, sal_uInt32 nBufSize ) + { + return lcl_createStringFromArray( pcCharArr, nBufSize, true ); + } +//........................................................................ +} // namespace svt +//........................................................................ + |