diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-05 23:18:19 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-05 23:24:08 +0100 |
commit | b234008ba5096f251fffec4c467f2103f4ba3cc0 (patch) | |
tree | 41e5377bf56ff47f0c998d19d0d5d8749b51ae56 /sal/textenc | |
parent | 7a7b346a527c4fca52b68281e419e1f876fbac59 (diff) |
Changed C files to C++.
Diffstat (limited to 'sal/textenc')
-rw-r--r-- | sal/textenc/context.cxx (renamed from sal/textenc/context.c) | 16 | ||||
-rw-r--r-- | sal/textenc/context.hxx (renamed from sal/textenc/context.h) | 26 | ||||
-rw-r--r-- | sal/textenc/convertadobe.tab | 10 | ||||
-rw-r--r-- | sal/textenc/convertbig5hkscs.cxx (renamed from sal/textenc/convertbig5hkscs.c) | 101 | ||||
-rw-r--r-- | sal/textenc/convertbig5hkscs.hxx (renamed from sal/textenc/convertbig5hkscs.h) | 33 | ||||
-rw-r--r-- | sal/textenc/convertbig5hkscs.tab | 14 | ||||
-rw-r--r-- | sal/textenc/converter.cxx (renamed from sal/textenc/converter.c) | 41 | ||||
-rw-r--r-- | sal/textenc/converter.hxx (renamed from sal/textenc/converter.h) | 36 | ||||
-rw-r--r-- | sal/textenc/converteuctw.cxx (renamed from sal/textenc/converteuctw.c) | 111 | ||||
-rw-r--r-- | sal/textenc/converteuctw.hxx (renamed from sal/textenc/converteuctw.h) | 35 | ||||
-rw-r--r-- | sal/textenc/converteuctw.tab | 14 | ||||
-rw-r--r-- | sal/textenc/convertgb18030.cxx (renamed from sal/textenc/convertgb18030.c) | 112 | ||||
-rw-r--r-- | sal/textenc/convertgb18030.hxx (renamed from sal/textenc/convertgb18030.h) | 43 | ||||
-rw-r--r-- | sal/textenc/convertgb18030.tab | 13 | ||||
-rw-r--r-- | sal/textenc/convertiscii.tab | 6 | ||||
-rw-r--r-- | sal/textenc/convertiso2022cn.cxx (renamed from sal/textenc/convertiso2022cn.c) | 289 | ||||
-rw-r--r-- | sal/textenc/convertiso2022cn.hxx (renamed from sal/textenc/convertiso2022cn.h) | 39 | ||||
-rw-r--r-- | sal/textenc/convertiso2022cn.tab | 18 | ||||
-rw-r--r-- | sal/textenc/convertiso2022jp.cxx (renamed from sal/textenc/convertiso2022jp.c) | 201 | ||||
-rw-r--r-- | sal/textenc/convertiso2022jp.hxx (renamed from sal/textenc/convertiso2022jp.h) | 39 | ||||
-rw-r--r-- | sal/textenc/convertiso2022jp.tab | 18 | ||||
-rw-r--r-- | sal/textenc/convertiso2022kr.cxx (renamed from sal/textenc/convertiso2022kr.c) | 162 | ||||
-rw-r--r-- | sal/textenc/convertiso2022kr.hxx (renamed from sal/textenc/convertiso2022kr.h) | 39 | ||||
-rw-r--r-- | sal/textenc/convertiso2022kr.tab | 18 | ||||
-rw-r--r-- | sal/textenc/convertsinglebytetobmpunicode.cxx | 11 | ||||
-rw-r--r-- | sal/textenc/convertsinglebytetobmpunicode.hxx | 10 | ||||
-rw-r--r-- | sal/textenc/generate/gb180302000.tab | 8 | ||||
-rw-r--r-- | sal/textenc/gettextencodingdata.hxx (renamed from sal/textenc/gettextencodingdata.h) | 20 | ||||
-rw-r--r-- | sal/textenc/tables.cxx | 15 | ||||
-rw-r--r-- | sal/textenc/tcvtbyte.cxx (renamed from sal/textenc/tcvtbyte.c) | 82 | ||||
-rw-r--r-- | sal/textenc/tcvtmb.cxx (renamed from sal/textenc/tcvtmb.c) | 63 | ||||
-rw-r--r-- | sal/textenc/tcvtutf7.cxx (renamed from sal/textenc/tcvtutf7.c) | 56 | ||||
-rw-r--r-- | sal/textenc/tcvtutf8.cxx (renamed from sal/textenc/tcvtutf8.c) | 104 | ||||
-rw-r--r-- | sal/textenc/tenchelp.cxx (renamed from sal/textenc/tenchelp.c) | 63 | ||||
-rw-r--r-- | sal/textenc/tenchelp.hxx (renamed from sal/textenc/tenchelp.h) | 104 | ||||
-rw-r--r-- | sal/textenc/tencinfo.cxx (renamed from sal/textenc/tencinfo.c) | 106 | ||||
-rw-r--r-- | sal/textenc/textcvt.cxx (renamed from sal/textenc/textcvt.c) | 45 | ||||
-rw-r--r-- | sal/textenc/textenc.cxx | 20 | ||||
-rw-r--r-- | sal/textenc/unichars.c | 139 | ||||
-rw-r--r-- | sal/textenc/unichars.cxx | 140 | ||||
-rw-r--r-- | sal/textenc/unichars.hxx (renamed from sal/textenc/unichars.h) | 35 |
41 files changed, 1167 insertions, 1288 deletions
diff --git a/sal/textenc/context.c b/sal/textenc/context.cxx index 26232cbd89c8..4770727b45e6 100644 --- a/sal/textenc/context.c +++ b/sal/textenc/context.cxx @@ -26,25 +26,27 @@ * ************************************************************************/ -#include "context.h" -#include "rtl/alloc.h" +#include "sal/config.h" -void * ImplCreateUnicodeToTextContext(void) +#include "context.hxx" + +void * ImplCreateUnicodeToTextContext() { - void * pContext = rtl_allocateMemory(sizeof (ImplUnicodeToTextContext)); - ((ImplUnicodeToTextContext *) pContext)->m_nHighSurrogate = 0; + ImplUnicodeToTextContext * pContext = new ImplUnicodeToTextContext; + pContext->m_nHighSurrogate = 0; return pContext; } void ImplResetUnicodeToTextContext(void * pContext) { if (pContext) - ((ImplUnicodeToTextContext *) pContext)->m_nHighSurrogate = 0; + static_cast< ImplUnicodeToTextContext * >(pContext)->m_nHighSurrogate = + 0; } void ImplDestroyContext(void * pContext) { - rtl_freeMemory(pContext); + delete static_cast< ImplUnicodeToTextContext * >(pContext); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/context.h b/sal/textenc/context.hxx index 6b7740ebadbb..a83006ee3548 100644 --- a/sal/textenc/context.h +++ b/sal/textenc/context.hxx @@ -26,30 +26,24 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#define INCLUDED_RTL_TEXTENC_CONTEXT_H +#ifndef INCLUDED_SAL_TEXTENC_CONTEXT_HXX +#define INCLUDED_SAL_TEXTENC_CONTEXT_HXX -#include "sal/types.h" +#include "sal/config.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "sal/types.h" -typedef struct +struct ImplUnicodeToTextContext { sal_Unicode m_nHighSurrogate; -} ImplUnicodeToTextContext; - -void * ImplCreateUnicodeToTextContext(void) SAL_THROW_EXTERN_C(); +}; -void ImplResetUnicodeToTextContext(void * pContext) SAL_THROW_EXTERN_C(); +void * ImplCreateUnicodeToTextContext(); -void ImplDestroyContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetUnicodeToTextContext(void * pContext); -#if defined __cplusplus -} -#endif /* __cpluscplus */ +void ImplDestroyContext(void * pContext); -#endif /* INCLUDED_RTL_TEXTENC_CONTEXT_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/convertadobe.tab b/sal/textenc/convertadobe.tab index 4267aa100811..98633bb55588 100644 --- a/sal/textenc/convertadobe.tab +++ b/sal/textenc/convertadobe.tab @@ -25,12 +25,14 @@ * ************************************************************************/ -#include "context.h" -#include "convertsinglebytetobmpunicode.hxx" -#include "tenchelp.h" +#include "sal/config.h" #include "rtl/tencinfo.h" -#include <sal/macros.h> +#include "sal/macros.h" + +#include "context.hxx" +#include "convertsinglebytetobmpunicode.hxx" +#include "tenchelp.hxx" namespace { diff --git a/sal/textenc/convertbig5hkscs.c b/sal/textenc/convertbig5hkscs.cxx index 0839e56acee1..113a90e2dccb 100644 --- a/sal/textenc/convertbig5hkscs.c +++ b/sal/textenc/convertbig5hkscs.cxx @@ -26,38 +26,45 @@ * ************************************************************************/ -#include "convertbig5hkscs.h" -#include "context.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" -#include "osl/diagnose.h" -#include "rtl/alloc.h" +#include "sal/config.h" + +#include <cassert> + #include "rtl/textcvt.h" #include "sal/types.h" -typedef struct +#include "context.hxx" +#include "convertbig5hkscs.hxx" +#include "converter.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + +namespace { + +struct ImplBig5HkscsToUnicodeContext { - sal_Int32 m_nRow; /* 0--255; 0 means none */ -} ImplBig5HkscsToUnicodeContext; + sal_Int32 m_nRow; // 0--255; 0 means none +}; + +} -void * ImplCreateBig5HkscsToUnicodeContext(void) +void * ImplCreateBig5HkscsToUnicodeContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplBig5HkscsToUnicodeContext)); - ((ImplBig5HkscsToUnicodeContext *) pContext)->m_nRow = 0; + ImplBig5HkscsToUnicodeContext * pContext = + new ImplBig5HkscsToUnicodeContext; + pContext->m_nRow = 0; return pContext; } void ImplResetBig5HkscsToUnicodeContext(void * pContext) { if (pContext) - ((ImplBig5HkscsToUnicodeContext *) pContext)->m_nRow = 0; + static_cast< ImplBig5HkscsToUnicodeContext * >(pContext)->m_nRow = 0; } sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -66,13 +73,13 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, sal_Size * pSrcCvtBytes) { sal_uInt16 const * pBig5Hkscs2001Data - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pBig5Hkscs2001ToUnicodeData; sal_Int32 const * pBig5Hkscs2001RowOffsets - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pBig5Hkscs2001ToUnicodeRowOffsets; ImplDBCSToUniLeadTab const * pBig5Data - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pBig5ToUnicodeData; sal_Int32 nRow = 0; sal_uInt32 nInfo = 0; @@ -81,11 +88,11 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, sal_Unicode * pDestBufEnd = pDestBuf + nDestChars; if (pContext) - nRow = ((ImplBig5HkscsToUnicodeContext *) pContext)->m_nRow; + nRow = static_cast< ImplBig5HkscsToUnicodeContext * >(pContext)->m_nRow; for (; nConverted < nSrcBytes; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++; if (nRow == 0) if (nChar < 0x80) @@ -97,7 +104,7 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, nRow = nChar; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } else @@ -125,16 +132,16 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, nUnicode = pBig5Data[nRow].mpToUniTrailTab[nChar - n]; if (nUnicode == 0) nUnicode = 0xFFFF; - OSL_VERIFY(!ImplIsHighSurrogate(nUnicode)); + assert(!ImplIsHighSurrogate(nUnicode)); } } if (nUnicode == 0xFFFF) { ImplDBCSEUDCData const * p - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pEudcData; sal_uInt32 nCount - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_nEudcCount; sal_uInt32 i; for (i = 0; i < nCount; ++i) @@ -186,7 +193,7 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, } ++p; } - OSL_VERIFY(!ImplIsHighSurrogate(nUnicode)); + assert(!ImplIsHighSurrogate(nUnicode)); } if (nUnicode == 0xFFFF) goto bad_input; @@ -211,14 +218,14 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } continue; bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -249,8 +256,8 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, - pDestBufEnd, &nInfo)) + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, + &nInfo)) { case IMPL_BAD_INPUT_STOP: case IMPL_BAD_INPUT_CONTINUE: @@ -264,7 +271,7 @@ sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, } if (pContext) - ((ImplBig5HkscsToUnicodeContext *) pContext)->m_nRow = nRow; + static_cast< ImplBig5HkscsToUnicodeContext * >(pContext)->m_nRow = nRow; if (pInfo) *pInfo = nInfo; if (pSrcCvtBytes) @@ -277,29 +284,29 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) { sal_uInt16 const * pBig5Hkscs2001Data - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pUnicodeToBig5Hkscs2001Data; sal_Int32 const * pBig5Hkscs2001PageOffsets - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pUnicodeToBig5Hkscs2001PageOffsets; sal_Int32 const * pBig5Hkscs2001PlaneOffsets - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pUnicodeToBig5Hkscs2001PlaneOffsets; ImplUniToDBCSHighTab const * pBig5Data - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pUnicodeToBig5Data; sal_Unicode nHighSurrogate = 0; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBuf + nDestBytes; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBuf + nDestBytes; if (pContext) nHighSurrogate @@ -307,7 +314,7 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, for (; nConverted < nSrcChars; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *pSrcBuf++; if (nHighSurrogate == 0) { @@ -321,19 +328,19 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, nChar = ImplCombineSurrogates(nHighSurrogate, nChar); else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar)) { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; else @@ -374,10 +381,10 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, if (nBytes == 0) { ImplDBCSEUDCData const * p - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_pEudcData; sal_uInt32 nCount - = ((ImplBig5HkscsConverterData const *) pData)-> + = static_cast< ImplBig5HkscsConverterData const * >(pData)-> m_nEudcCount; sal_uInt32 i; for (i = 0; i < nCount; ++i) { @@ -412,8 +419,8 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, goto bad_input; if (pDestBufEnd - pDestBufPtr >= 2) { - *pDestBufPtr++ = (sal_Char) (nBytes >> 8); - *pDestBufPtr++ = (sal_Char) (nBytes & 0xFF); + *pDestBufPtr++ = static_cast< char >(nBytes >> 8); + *pDestBufPtr++ = static_cast< char >(nBytes & 0xFF); } else goto no_output; @@ -459,7 +466,7 @@ sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else - switch (ImplHandleBadInputUnicodeToTextConversion(sal_False, + switch (ImplHandleBadInputUnicodeToTextConversion(false, 0, nFlags, &pDestBufPtr, diff --git a/sal/textenc/convertbig5hkscs.h b/sal/textenc/convertbig5hkscs.hxx index e7e66434b9c9..92fc3724d07e 100644 --- a/sal/textenc/convertbig5hkscs.h +++ b/sal/textenc/convertbig5hkscs.hxx @@ -26,17 +26,14 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTBIG5HKSCS_H -#define INCLUDED_RTL_TEXTENC_CONVERTBIG5HKSCS_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTBIG5HKSCS_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTBIG5HKSCS_HXX -#include "tenchelp.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "tenchelp.hxx" -typedef struct +struct ImplBig5HkscsConverterData { sal_uInt16 const * m_pBig5Hkscs2001ToUnicodeData; sal_Int32 const * m_pBig5Hkscs2001ToUnicodeRowOffsets; @@ -47,38 +44,32 @@ typedef struct ImplUniToDBCSHighTab const * m_pUnicodeToBig5Data; ImplDBCSEUDCData const * m_pEudcData; int m_nEudcCount; -} ImplBig5HkscsConverterData; +}; -void * ImplCreateBig5HkscsToUnicodeContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateBig5HkscsToUnicodeContext(); -void ImplResetBig5HkscsToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetBig5HkscsToUnicodeContext(void * pContext); sal_Size ImplConvertBig5HkscsToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtBytes); sal_Size ImplConvertUnicodeToBig5Hkscs(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtChars) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtChars); -#if defined __cplusplus -} -#endif /* __cpluscplus */ - -#endif /* INCLUDED_RTL_TEXTENC_CONVERTBIG5HKSCS_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/convertbig5hkscs.tab b/sal/textenc/convertbig5hkscs.tab index 9fe2a47b5156..29720a842b59 100644 --- a/sal/textenc/convertbig5hkscs.tab +++ b/sal/textenc/convertbig5hkscs.tab @@ -25,19 +25,13 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#include "context.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_CONVERTBIG5HKSCS_H -#include "convertbig5hkscs.h" -#endif +#include "sal/config.h" -#ifndef _RTL_TENCINFO_H #include "rtl/tencinfo.h" -#endif -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif + +#include "context.hxx" +#include "convertbig5hkscs.hxx" #include "generate/big5hkscs2001.tab" diff --git a/sal/textenc/converter.c b/sal/textenc/converter.cxx index 07c1e04c9ba3..cde368c133ae 100644 --- a/sal/textenc/converter.c +++ b/sal/textenc/converter.cxx @@ -26,14 +26,17 @@ * ************************************************************************/ -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" +#include "converter.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + ImplBadInputConversionAction ImplHandleBadInputTextToUnicodeConversion( - sal_Bool bUndefined, sal_Bool bMultiByte, sal_Char cByte, sal_uInt32 nFlags, + bool bUndefined, bool bMultiByte, char cByte, sal_uInt32 nFlags, sal_Unicode ** pDestBufPtr, sal_Unicode * pDestBufEnd, sal_uInt32 * pInfo) { *pInfo |= bUndefined @@ -69,9 +72,9 @@ ImplBadInputConversionAction ImplHandleBadInputTextToUnicodeConversion( else return IMPL_BAD_INPUT_NO_OUTPUT; - default: /* RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT, - RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT, - RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT */ + default: // RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT, + // RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT, + // RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT if (*pDestBufPtr != pDestBufEnd) { *(*pDestBufPtr)++ = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; @@ -83,20 +86,20 @@ ImplBadInputConversionAction ImplHandleBadInputTextToUnicodeConversion( } ImplBadInputConversionAction -ImplHandleBadInputUnicodeToTextConversion(sal_Bool bUndefined, +ImplHandleBadInputUnicodeToTextConversion(bool bUndefined, sal_uInt32 nUtf32, sal_uInt32 nFlags, - sal_Char ** pDestBufPtr, - sal_Char * pDestBufEnd, + char ** pDestBufPtr, + char * pDestBufEnd, sal_uInt32 * pInfo, - sal_Char const * pPrefix, + char const * pPrefix, sal_Size nPrefixLen, - sal_Bool * pPrefixWritten) + bool * pPrefixWritten) { - /* TODO! RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR */ + // TODO! RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACE + // RTL_UNICODETOTEXT_FLAGS_UNDEFINED_REPLACESTR - sal_Char cReplace; + char cReplace; if (bUndefined) { @@ -131,7 +134,7 @@ ImplHandleBadInputUnicodeToTextConversion(sal_Bool bUndefined, case RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE: case RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE: if (pPrefixWritten) - *pPrefixWritten = sal_False; + *pPrefixWritten = false; return IMPL_BAD_INPUT_CONTINUE; case RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0: @@ -141,8 +144,8 @@ ImplHandleBadInputUnicodeToTextConversion(sal_Bool bUndefined, case RTL_UNICODETOTEXT_FLAGS_UNDEFINED_QUESTIONMARK: case RTL_UNICODETOTEXT_FLAGS_INVALID_QUESTIONMARK: - default: /* RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT, - RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT */ + default: // RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT, + // RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT cReplace = '?'; break; @@ -157,7 +160,7 @@ ImplHandleBadInputUnicodeToTextConversion(sal_Bool bUndefined, *(*pDestBufPtr)++ = *pPrefix++; *(*pDestBufPtr)++ = cReplace; if (pPrefixWritten) - *pPrefixWritten = sal_True; + *pPrefixWritten = true; return IMPL_BAD_INPUT_CONTINUE; } else diff --git a/sal/textenc/converter.h b/sal/textenc/converter.hxx index c74652704781..50338c2efaa5 100644 --- a/sal/textenc/converter.h +++ b/sal/textenc/converter.hxx @@ -26,44 +26,36 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTER_H -#define INCLUDED_RTL_TEXTENC_CONVERTER_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTER_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTER_HXX -#include "sal/types.h" +#include "sal/config.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "sal/types.h" -typedef enum +enum ImplBadInputConversionAction { IMPL_BAD_INPUT_STOP, IMPL_BAD_INPUT_CONTINUE, IMPL_BAD_INPUT_NO_OUTPUT -} ImplBadInputConversionAction; +}; ImplBadInputConversionAction ImplHandleBadInputTextToUnicodeConversion( - sal_Bool bUndefined, sal_Bool bMultiByte, sal_Char cByte, sal_uInt32 nFlags, - sal_Unicode ** pDestBufPtr, sal_Unicode * pDestBufEnd, sal_uInt32 * pInfo) - SAL_THROW_EXTERN_C(); + bool bUndefined, bool bMultiByte, char cByte, sal_uInt32 nFlags, + sal_Unicode ** pDestBufPtr, sal_Unicode * pDestBufEnd, sal_uInt32 * pInfo); ImplBadInputConversionAction -ImplHandleBadInputUnicodeToTextConversion(sal_Bool bUndefined, +ImplHandleBadInputUnicodeToTextConversion(bool bUndefined, sal_uInt32 nUtf32, sal_uInt32 nFlags, - sal_Char ** pDestBufPtr, - sal_Char * pDestBufEnd, + char ** pDestBufPtr, + char * pDestBufEnd, sal_uInt32 * pInfo, - sal_Char const * pPrefix, + char const * pPrefix, sal_Size nPrefixLen, - sal_Bool * pPrefixWritten) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cpluscplus */ + bool * pPrefixWritten); -#endif /* INCLUDED_RTL_TEXTENC_CONVERTER_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/converteuctw.c b/sal/textenc/converteuctw.cxx index 062862abf76a..0b6b41bb52d4 100644 --- a/sal/textenc/converteuctw.c +++ b/sal/textenc/converteuctw.cxx @@ -26,49 +26,54 @@ * ************************************************************************/ -#include "converteuctw.h" -#include "context.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" -#include "rtl/alloc.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" -typedef enum +#include "context.hxx" +#include "converter.hxx" +#include "converteuctw.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + +namespace { + +enum ImplEucTwToUnicodeState { IMPL_EUC_TW_TO_UNICODE_STATE_0, IMPL_EUC_TW_TO_UNICODE_STATE_1, IMPL_EUC_TW_TO_UNICODE_STATE_2_1, IMPL_EUC_TW_TO_UNICODE_STATE_2_2, IMPL_EUC_TW_TO_UNICODE_STATE_2_3 -} ImplEucTwToUnicodeState; +}; -typedef struct +struct ImplEucTwToUnicodeContext { ImplEucTwToUnicodeState m_eState; - sal_Int32 m_nPlane; /* 0--15 */ - sal_Int32 m_nRow; /* 0--93 */ -} ImplEucTwToUnicodeContext; + sal_Int32 m_nPlane; // 0--15 + sal_Int32 m_nRow; // 0--93 +}; + +} -void * ImplCreateEucTwToUnicodeContext(void) +void * ImplCreateEucTwToUnicodeContext() { - void * pContext = rtl_allocateMemory(sizeof (ImplEucTwToUnicodeContext)); - ((ImplEucTwToUnicodeContext *) pContext)->m_eState - = IMPL_EUC_TW_TO_UNICODE_STATE_0; + ImplEucTwToUnicodeContext * pContext = new ImplEucTwToUnicodeContext; + pContext->m_eState = IMPL_EUC_TW_TO_UNICODE_STATE_0; return pContext; } void ImplResetEucTwToUnicodeContext(void * pContext) { if (pContext) - ((ImplEucTwToUnicodeContext *) pContext)->m_eState + static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_eState = IMPL_EUC_TW_TO_UNICODE_STATE_0; } sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -77,13 +82,13 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, sal_Size * pSrcCvtBytes) { sal_uInt16 const * pCns116431992Data - = ((ImplEucTwConverterData const *) pData)-> + = static_cast< ImplEucTwConverterData const * >(pData)-> m_pCns116431992ToUnicodeData; sal_Int32 const * pCns116431992RowOffsets - = ((ImplEucTwConverterData const *) pData)-> + = static_cast< ImplEucTwConverterData const * >(pData)-> m_pCns116431992ToUnicodeRowOffsets; sal_Int32 const * pCns116431992PlaneOffsets - = ((ImplEucTwConverterData const *) pData)-> + = static_cast< ImplEucTwConverterData const * >(pData)-> m_pCns116431992ToUnicodePlaneOffsets; ImplEucTwToUnicodeState eState = IMPL_EUC_TW_TO_UNICODE_STATE_0; sal_Int32 nPlane = 0; @@ -95,14 +100,14 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, if (pContext) { - eState = ((ImplEucTwToUnicodeContext *) pContext)->m_eState; - nPlane = ((ImplEucTwToUnicodeContext *) pContext)->m_nPlane; - nRow = ((ImplEucTwToUnicodeContext *) pContext)->m_nRow; + eState = static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_eState; + nPlane = static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_nPlane; + nRow = static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_nRow; } for (; nConverted < nSrcBytes; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++; switch (eState) { @@ -121,7 +126,7 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, eState = IMPL_EUC_TW_TO_UNICODE_STATE_2_1; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -134,7 +139,7 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -143,11 +148,11 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, if (nChar >= 0xA1 && nChar <= 0xB0) { nPlane = nChar - 0xA1; - ++eState; + eState = IMPL_EUC_TW_TO_UNICODE_STATE_2_2; } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -156,11 +161,11 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, if (nChar >= 0xA1 && nChar <= 0xFE) { nRow = nChar - 0xA1; - ++eState; + eState = IMPL_EUC_TW_TO_UNICODE_STATE_2_3; } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -170,7 +175,7 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, goto transform; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -229,7 +234,7 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -260,8 +265,8 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, - pDestBufEnd, &nInfo)) + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, + &nInfo)) { case IMPL_BAD_INPUT_STOP: case IMPL_BAD_INPUT_CONTINUE: @@ -276,9 +281,9 @@ sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, if (pContext) { - ((ImplEucTwToUnicodeContext *) pContext)->m_eState = eState; - ((ImplEucTwToUnicodeContext *) pContext)->m_nPlane = nPlane; - ((ImplEucTwToUnicodeContext *) pContext)->m_nRow = nRow; + static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_eState = eState; + static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_nPlane = nPlane; + static_cast< ImplEucTwToUnicodeContext * >(pContext)->m_nRow = nRow; } if (pInfo) *pInfo = nInfo; @@ -292,26 +297,26 @@ sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) { sal_uInt8 const * pCns116431992Data - = ((ImplEucTwConverterData const *) pData)-> + = static_cast< ImplEucTwConverterData const * >(pData)-> m_pUnicodeToCns116431992Data; sal_Int32 const * pCns116431992PageOffsets - = ((ImplEucTwConverterData const *) pData)-> + = static_cast< ImplEucTwConverterData const * >(pData)-> m_pUnicodeToCns116431992PageOffsets; sal_Int32 const * pCns116431992PlaneOffsets - = ((ImplEucTwConverterData const *) pData)-> + = static_cast< ImplEucTwConverterData const * >(pData)-> m_pUnicodeToCns116431992PlaneOffsets; sal_Unicode nHighSurrogate = 0; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBuf + nDestBytes; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBuf + nDestBytes; if (pContext) nHighSurrogate @@ -319,7 +324,7 @@ sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData, for (; nConverted < nSrcChars; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *pSrcBuf++; if (nHighSurrogate == 0) { @@ -333,19 +338,19 @@ sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData, nChar = ImplCombineSurrogates(nHighSurrogate, nChar); else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar)) { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; else @@ -373,11 +378,11 @@ sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData, goto no_output; if (nPlane != 1) { - *pDestBufPtr++ = (sal_Char) (unsigned char) 0x8E; - *pDestBufPtr++ = (sal_Char) (0xA0 + nPlane); + *pDestBufPtr++ = static_cast< char >(static_cast< unsigned char >(0x8E)); + *pDestBufPtr++ = static_cast< char >(0xA0 + nPlane); } - *pDestBufPtr++ = (sal_Char) (0xA0 + pCns116431992Data[nOffset++]); - *pDestBufPtr++ = (sal_Char) (0xA0 + pCns116431992Data[nOffset]); + *pDestBufPtr++ = static_cast< char >(0xA0 + pCns116431992Data[nOffset++]); + *pDestBufPtr++ = static_cast< char >(0xA0 + pCns116431992Data[nOffset]); } nHighSurrogate = 0; continue; @@ -420,7 +425,7 @@ sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData, if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else - switch (ImplHandleBadInputUnicodeToTextConversion(sal_False, + switch (ImplHandleBadInputUnicodeToTextConversion(false, 0, nFlags, &pDestBufPtr, diff --git a/sal/textenc/converteuctw.h b/sal/textenc/converteuctw.hxx index 6d30fced354a..72c24953ba32 100644 --- a/sal/textenc/converteuctw.h +++ b/sal/textenc/converteuctw.hxx @@ -26,17 +26,16 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTEUCTW_H -#define INCLUDED_RTL_TEXTENC_CONVERTEUCTW_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTEUCTW_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTEUCTW_HXX + +#include "sal/config.h" -#include "tenchelp.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "tenchelp.hxx" -typedef struct +struct ImplEucTwConverterData { sal_uInt16 const * m_pCns116431992ToUnicodeData; sal_Int32 const * m_pCns116431992ToUnicodeRowOffsets; @@ -44,38 +43,32 @@ typedef struct sal_uInt8 const * m_pUnicodeToCns116431992Data; sal_Int32 const * m_pUnicodeToCns116431992PageOffsets; sal_Int32 const * m_pUnicodeToCns116431992PlaneOffsets; -} ImplEucTwConverterData; +}; -void * ImplCreateEucTwToUnicodeContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateEucTwToUnicodeContext(); -void ImplResetEucTwToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetEucTwToUnicodeContext(void * pContext); sal_Size ImplConvertEucTwToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtBytes); sal_Size ImplConvertUnicodeToEucTw(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtChars) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cpluscplus */ + sal_Size * pSrcCvtChars); -#endif /* INCLUDED_RTL_TEXTENC_CONVERTEUCTW_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/converteuctw.tab b/sal/textenc/converteuctw.tab index c9bfeea697a9..398120bd0696 100644 --- a/sal/textenc/converteuctw.tab +++ b/sal/textenc/converteuctw.tab @@ -25,19 +25,13 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#include "context.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_CONVERTEUCTW_H -#include "converteuctw.h" -#endif +#include "sal/config.h" -#ifndef _RTL_TENCINFO_H #include "rtl/tencinfo.h" -#endif -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif + +#include "context.hxx" +#include "converteuctw.hxx" #include "generate/cns116431992.tab" diff --git a/sal/textenc/convertgb18030.c b/sal/textenc/convertgb18030.cxx index c9cac4bf7693..61daa30c5295 100644 --- a/sal/textenc/convertgb18030.c +++ b/sal/textenc/convertgb18030.cxx @@ -26,48 +26,52 @@ * ************************************************************************/ -#include "convertgb18030.h" -#include "context.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" -#include "rtl/alloc.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" -typedef enum +#include "context.hxx" +#include "converter.hxx" +#include "convertgb18030.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + +namespace { + +enum ImplGb18030ToUnicodeState { IMPL_GB_18030_TO_UNICODE_STATE_0, IMPL_GB_18030_TO_UNICODE_STATE_1, IMPL_GB_18030_TO_UNICODE_STATE_2, IMPL_GB_18030_TO_UNICODE_STATE_3 -} ImplGb18030ToUnicodeState; +}; -typedef struct +struct ImplGb18030ToUnicodeContext { ImplGb18030ToUnicodeState m_eState; sal_uInt32 m_nCode; -} ImplGb18030ToUnicodeContext; +}; + +} -void * ImplCreateGb18030ToUnicodeContext(void) +void * ImplCreateGb18030ToUnicodeContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplGb18030ToUnicodeContext)); - ((ImplGb18030ToUnicodeContext *) pContext)->m_eState - = IMPL_GB_18030_TO_UNICODE_STATE_0; + ImplGb18030ToUnicodeContext * pContext = new ImplGb18030ToUnicodeContext; + pContext->m_eState = IMPL_GB_18030_TO_UNICODE_STATE_0; return pContext; } void ImplResetGb18030ToUnicodeContext(void * pContext) { if (pContext) - ((ImplGb18030ToUnicodeContext *) pContext)->m_eState + static_cast< ImplGb18030ToUnicodeContext * >(pContext)->m_eState = IMPL_GB_18030_TO_UNICODE_STATE_0; } sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -76,9 +80,9 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, sal_Size * pSrcCvtBytes) { sal_Unicode const * pGb18030Data - = ((ImplGb18030ConverterData const *) pData)->m_pGb18030ToUnicodeData; + = static_cast< ImplGb18030ConverterData const * >(pData)->m_pGb18030ToUnicodeData; ImplGb180302000ToUnicodeRange const * pGb18030Ranges - = ((ImplGb18030ConverterData const *) pData)-> + = static_cast< ImplGb18030ConverterData const * >(pData)-> m_pGb18030ToUnicodeRanges; ImplGb18030ToUnicodeState eState = IMPL_GB_18030_TO_UNICODE_STATE_0; sal_uInt32 nCode = 0; @@ -89,13 +93,13 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, if (pContext) { - eState = ((ImplGb18030ToUnicodeContext *) pContext)->m_eState; - nCode = ((ImplGb18030ToUnicodeContext *) pContext)->m_nCode; + eState = static_cast< ImplGb18030ToUnicodeContext * >(pContext)->m_eState; + nCode = static_cast< ImplGb18030ToUnicodeContext * >(pContext)->m_nCode; } for (; nConverted < nSrcBytes; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++; switch (eState) { @@ -114,7 +118,7 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -138,7 +142,7 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -151,7 +155,7 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -161,7 +165,7 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, { nCode = nCode * 10 + (nChar - 0x30); - /* 90 30 81 30 to E3 32 9A 35 maps to U+10000 to U+10FFFF: */ + // 90 30 81 30 to E3 32 9A 35 maps to U+10000 to U+10FFFF: if (nCode >= 189000 && nCode <= 1237575) if (pDestBufEnd - pDestBufPtr >= 2) { @@ -213,7 +217,7 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -222,7 +226,7 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -253,8 +257,8 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, - pDestBufEnd, &nInfo)) + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, + &nInfo)) { case IMPL_BAD_INPUT_STOP: case IMPL_BAD_INPUT_CONTINUE: @@ -269,8 +273,8 @@ sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, if (pContext) { - ((ImplGb18030ToUnicodeContext *) pContext)->m_eState = eState; - ((ImplGb18030ToUnicodeContext *) pContext)->m_nCode = nCode; + static_cast< ImplGb18030ToUnicodeContext * >(pContext)->m_eState = eState; + static_cast< ImplGb18030ToUnicodeContext * >(pContext)->m_nCode = nCode; } if (pInfo) *pInfo = nInfo; @@ -284,23 +288,23 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) { sal_uInt32 const * pGb18030Data - = ((ImplGb18030ConverterData const *) pData)-> + = static_cast< ImplGb18030ConverterData const * >(pData)-> m_pUnicodeToGb18030Data; ImplUnicodeToGb180302000Range const * pGb18030Ranges - = ((ImplGb18030ConverterData const *) pData)-> + = static_cast< ImplGb18030ConverterData const * >(pData)-> m_pUnicodeToGb18030Ranges; sal_Unicode nHighSurrogate = 0; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBuf + nDestBytes; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBuf + nDestBytes; if (pContext) nHighSurrogate @@ -308,7 +312,7 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, for (; nConverted < nSrcChars; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *pSrcBuf++; if (nHighSurrogate == 0) { @@ -322,19 +326,19 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, nChar = ImplCombineSurrogates(nHighSurrogate, nChar); else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar)) { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; else if (nChar < 0x10000) @@ -353,11 +357,11 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, { if (nCode > 0xFFFF) { - *pDestBufPtr++ = (sal_Char) (nCode >> 24); - *pDestBufPtr++ = (sal_Char) (nCode >> 16 & 0xFF); + *pDestBufPtr++ = static_cast< char >(nCode >> 24); + *pDestBufPtr++ = static_cast< char >(nCode >> 16 & 0xFF); } - *pDestBufPtr++ = (sal_Char) (nCode >> 8 & 0xFF); - *pDestBufPtr++ = (sal_Char) (nCode & 0xFF); + *pDestBufPtr++ = static_cast< char >(nCode >> 8 & 0xFF); + *pDestBufPtr++ = static_cast< char >(nCode & 0xFF); } else goto no_output; @@ -370,11 +374,11 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, sal_uInt32 nCode = pRange->m_nFirstLinear + (nChar - pRange->m_nFirstUnicode); - *pDestBufPtr++ = (sal_Char) (nCode / 12600 + 0x81); + *pDestBufPtr++ = static_cast< char >(nCode / 12600 + 0x81); *pDestBufPtr++ - = (sal_Char) (nCode / 1260 % 10 + 0x30); - *pDestBufPtr++ = (sal_Char) (nCode / 10 % 126 + 0x81); - *pDestBufPtr++ = (sal_Char) (nCode % 10 + 0x30); + = static_cast< char >(nCode / 1260 % 10 + 0x30); + *pDestBufPtr++ = static_cast< char >(nCode / 10 % 126 + 0x81); + *pDestBufPtr++ = static_cast< char >(nCode % 10 + 0x30); } else goto no_output; @@ -388,10 +392,10 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, if (pDestBufEnd - pDestBufPtr >= 4) { sal_uInt32 nCode = nChar - 0x10000; - *pDestBufPtr++ = (sal_Char) (nCode / 12600 + 0x90); - *pDestBufPtr++ = (sal_Char) (nCode / 1260 % 10 + 0x30); - *pDestBufPtr++ = (sal_Char) (nCode / 10 % 126 + 0x81); - *pDestBufPtr++ = (sal_Char) (nCode % 10 + 0x30); + *pDestBufPtr++ = static_cast< char >(nCode / 12600 + 0x90); + *pDestBufPtr++ = static_cast< char >(nCode / 1260 % 10 + 0x30); + *pDestBufPtr++ = static_cast< char >(nCode / 10 % 126 + 0x81); + *pDestBufPtr++ = static_cast< char >(nCode % 10 + 0x30); } else goto no_output; @@ -436,7 +440,7 @@ sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else - switch (ImplHandleBadInputUnicodeToTextConversion(sal_False, + switch (ImplHandleBadInputUnicodeToTextConversion(false, 0, nFlags, &pDestBufPtr, diff --git a/sal/textenc/convertgb18030.h b/sal/textenc/convertgb18030.hxx index b80224d62d35..cbdc4f3430ce 100644 --- a/sal/textenc/convertgb18030.h +++ b/sal/textenc/convertgb18030.hxx @@ -26,70 +26,63 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTGB18030_H -#define INCLUDED_RTL_TEXTENC_CONVERTGB18030_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTGB18030_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTGB18030_HXX + +#include "sal/config.h" -#include "tenchelp.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "tenchelp.hxx" -typedef struct +struct ImplGb180302000ToUnicodeRange { sal_Int32 m_nNonRangeDataIndex; sal_uInt32 m_nFirstLinear; sal_uInt32 m_nPastLinear; sal_Unicode m_nFirstUnicode; -} ImplGb180302000ToUnicodeRange; +}; -typedef struct +struct ImplUnicodeToGb180302000Range { sal_Int32 m_nNonRangeDataIndex; sal_Unicode m_nFirstUnicode; sal_Unicode m_nLastUnicode; sal_uInt32 m_nFirstLinear; -} ImplUnicodeToGb180302000Range; +}; -typedef struct +struct ImplGb18030ConverterData { sal_Unicode const * m_pGb18030ToUnicodeData; ImplGb180302000ToUnicodeRange const * m_pGb18030ToUnicodeRanges; sal_uInt32 const * m_pUnicodeToGb18030Data; ImplUnicodeToGb180302000Range const * m_pUnicodeToGb18030Ranges; -} ImplGb18030ConverterData; +}; -void * ImplCreateGb18030ToUnicodeContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateGb18030ToUnicodeContext(); -void ImplResetGb18030ToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetGb18030ToUnicodeContext(void * pContext); sal_Size ImplConvertGb18030ToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtBytes); sal_Size ImplConvertUnicodeToGb18030(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtChars) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cpluscplus */ + sal_Size * pSrcCvtChars); -#endif /* INCLUDED_RTL_TEXTENC_CONVERTGB18030_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/convertgb18030.tab b/sal/textenc/convertgb18030.tab index d904d4298389..2bc290c69578 100644 --- a/sal/textenc/convertgb18030.tab +++ b/sal/textenc/convertgb18030.tab @@ -25,20 +25,13 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#include "context.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_CONVERTGB18030_H -#include "convertgb18030.h" -#endif +#include "sal/config.h" -#ifndef _RTL_TENCINFO_H #include "rtl/tencinfo.h" -#endif -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif +#include "context.hxx" +#include "convertgb18030.hxx" #include "generate/gb180302000.tab" static ImplGb18030ConverterData const aImplGb18030ConvertData diff --git a/sal/textenc/convertiscii.tab b/sal/textenc/convertiscii.tab index 96f5dc8582c5..57e5bbdd3707 100644 --- a/sal/textenc/convertiscii.tab +++ b/sal/textenc/convertiscii.tab @@ -25,12 +25,14 @@ * ************************************************************************/ -#include "tenchelp.h" +#include "sal/config.h" + +#include <cstddef> #include "rtl/tencinfo.h" #include "sal/types.h" -#include <stddef.h> +#include "tenchelp.hxx" /* Conversion tables for the Devanagari version of ISCII (IS 13194:1991). * diff --git a/sal/textenc/convertiso2022cn.c b/sal/textenc/convertiso2022cn.cxx index 40a0039aa3f0..6c317225ae67 100644 --- a/sal/textenc/convertiso2022cn.c +++ b/sal/textenc/convertiso2022cn.cxx @@ -26,16 +26,20 @@ * ************************************************************************/ -#include "convertiso2022cn.h" -#include "context.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" -#include "rtl/alloc.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" -typedef enum /* order is important: */ +#include "context.hxx" +#include "converter.hxx" +#include "convertiso2022cn.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + +namespace { + +enum ImplIso2022CnToUnicodeState // order is important: { IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII, IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO, @@ -46,39 +50,40 @@ typedef enum /* order is important: */ IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR, IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN, IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK -} ImplIso2022CnToUnicodeState; +}; -typedef struct +struct ImplIso2022CnToUnicodeContext { ImplIso2022CnToUnicodeState m_eState; sal_uInt32 m_nRow; - sal_Bool m_bSo; - sal_Bool m_b116431; -} ImplIso2022CnToUnicodeContext; + bool m_bSo; + bool m_b116431; +}; -typedef enum +enum ImplUnicodeToIso2022CnDesignator { IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE, IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312, IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_116431 -} ImplUnicodeToIso2022CnDesignator; +}; -typedef struct +struct ImplUnicodeToIso2022CnContext { sal_Unicode m_nHighSurrogate; ImplUnicodeToIso2022CnDesignator m_eSoDesignator; - sal_Bool m_b116432Designator; - sal_Bool m_bSo; -} ImplUnicodeToIso2022CnContext; + bool m_b116432Designator; + bool m_bSo; +}; -void * ImplCreateIso2022CnToUnicodeContext(void) +} + +void * ImplCreateIso2022CnToUnicodeContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplIso2022CnToUnicodeContext)); - ((ImplIso2022CnToUnicodeContext *) pContext)->m_eState - = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_bSo = sal_False; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_b116431 = sal_False; + ImplIso2022CnToUnicodeContext * pContext = + new ImplIso2022CnToUnicodeContext; + pContext->m_eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; + pContext->m_bSo = false; + pContext->m_b116431 = false; return pContext; } @@ -86,16 +91,16 @@ void ImplResetIso2022CnToUnicodeContext(void * pContext) { if (pContext) { - ((ImplIso2022CnToUnicodeContext *) pContext)->m_eState + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_bSo = sal_False; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_b116431 = sal_False; + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_bSo = false; + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_b116431 = false; } } sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -104,22 +109,22 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, sal_Size * pSrcCvtBytes) { ImplDBCSToUniLeadTab const * pGb2312Data - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pGb2312ToUnicodeData; sal_uInt16 const * pCns116431992Data - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pCns116431992ToUnicodeData; sal_Int32 const * pCns116431992RowOffsets - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pCns116431992ToUnicodeRowOffsets; sal_Int32 const * pCns116431992PlaneOffsets - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pCns116431992ToUnicodePlaneOffsets; ImplIso2022CnToUnicodeState eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; sal_uInt32 nRow = 0; - sal_Bool bSo = sal_False; - sal_Bool b116431 = sal_False; + bool bSo = false; + bool b116431 = false; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; sal_Unicode * pDestBufPtr = pDestBuf; @@ -127,26 +132,26 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, if (pContext) { - eState = ((ImplIso2022CnToUnicodeContext *) pContext)->m_eState; - nRow = ((ImplIso2022CnToUnicodeContext *) pContext)->m_nRow; - bSo = ((ImplIso2022CnToUnicodeContext *) pContext)->m_bSo; - b116431 = ((ImplIso2022CnToUnicodeContext *) pContext)->m_b116431; + eState = static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_eState; + nRow = static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_nRow; + bSo = static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_bSo; + b116431 = static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_b116431; } for (; nConverted < nSrcBytes; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++; sal_uInt32 nPlane; switch (eState) { case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII: - if (nChar == 0x0E) /* SO */ + if (nChar == 0x0E) // SO { - bSo = sal_True; + bSo = true; eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO; } - else if (nChar == 0x1B) /* ESC */ + else if (nChar == 0x1B) // ESC eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) @@ -155,18 +160,18 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, goto no_output; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO: - if (nChar == 0x0F) /* SI */ + if (nChar == 0x0F) // SI { - bSo = sal_False; + bSo = false; eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; } - else if (nChar == 0x1B) /* ESC */ + else if (nChar == 0x1B) // ESC eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC; else if (nChar >= 0x21 && nChar <= 0x7E) { @@ -175,7 +180,7 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -211,7 +216,7 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -224,7 +229,7 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -237,63 +242,63 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC: - if (nChar == 0x24) /* $ */ + if (nChar == 0x24) // $ eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR; - else if (nChar == 0x4E) /* N */ + else if (nChar == 0x4E) // N eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_116432; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR: - if (nChar == 0x29) /* ) */ + if (nChar == 0x29) // ) eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN; - else if (nChar == 0x2A) /* * */ + else if (nChar == 0x2A) // * eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN: - if (nChar == 0x41) /* A */ + if (nChar == 0x41) // A { - b116431 = sal_False; + b116431 = false; eState = bSo ? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO : IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; } - else if (nChar == 0x47) /* G */ + else if (nChar == 0x47) // G { - b116431 = sal_True; + b116431 = true; eState = bSo ? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO : IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_CN_TO_UNICODE_STATE_ESC_DOLLAR_ASTERISK: - if (nChar == 0x48) /* H */ + if (nChar == 0x48) // H eState = bSo ? IMPL_ISO_2022_CN_TO_UNICODE_STATE_SO : IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -353,17 +358,17 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; - b116431 = sal_False; + b116431 = false; break; case IMPL_BAD_INPUT_CONTINUE: eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; - b116431 = sal_False; + b116431 = false; continue; case IMPL_BAD_INPUT_NO_OUTPUT: @@ -386,13 +391,13 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: case IMPL_BAD_INPUT_CONTINUE: eState = IMPL_ISO_2022_CN_TO_UNICODE_STATE_ASCII; - b116431 = sal_False; + b116431 = false; break; case IMPL_BAD_INPUT_NO_OUTPUT: @@ -403,10 +408,10 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, if (pContext) { - ((ImplIso2022CnToUnicodeContext *) pContext)->m_eState = eState; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_nRow = nRow; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_bSo = bSo; - ((ImplIso2022CnToUnicodeContext *) pContext)->m_b116431 = b116431; + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_eState = eState; + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_nRow = nRow; + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_bSo = bSo; + static_cast< ImplIso2022CnToUnicodeContext * >(pContext)->m_b116431 = b116431; } if (pInfo) *pInfo = nInfo; @@ -418,14 +423,12 @@ sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, void * ImplCreateUnicodeToIso2022CnContext(void) { - void * pContext - = rtl_allocateMemory(sizeof (ImplUnicodeToIso2022CnContext)); - ((ImplUnicodeToIso2022CnContext *) pContext)->m_nHighSurrogate = 0; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_eSoDesignator - = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_b116432Designator - = sal_False; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_bSo = sal_False; + ImplUnicodeToIso2022CnContext * pContext = + new ImplUnicodeToIso2022CnContext; + pContext->m_nHighSurrogate = 0; + pContext->m_eSoDesignator = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE; + pContext->m_b116432Designator = false; + pContext->m_bSo = false; return pContext; } @@ -433,12 +436,12 @@ void ImplResetUnicodeToIso2022CnContext(void * pContext) { if (pContext) { - ((ImplUnicodeToIso2022CnContext *) pContext)->m_nHighSurrogate = 0; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_eSoDesignator + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_nHighSurrogate = 0; + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_eSoDesignator = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_b116432Designator - = sal_False; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_bSo = sal_False; + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_b116432Designator + = false; + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_bSo = false; } } @@ -490,49 +493,49 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) { ImplUniToDBCSHighTab const * pGb2312Data - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pUnicodeToGb2312Data; sal_uInt8 const * pCns116431992Data - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pUnicodeToCns116431992Data; sal_Int32 const * pCns116431992PageOffsets - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pUnicodeToCns116431992PageOffsets; sal_Int32 const * pCns116431992PlaneOffsets - = ((ImplIso2022CnConverterData const *) pData)-> + = static_cast< ImplIso2022CnConverterData const * >(pData)-> m_pUnicodeToCns116431992PlaneOffsets; sal_Unicode nHighSurrogate = 0; ImplUnicodeToIso2022CnDesignator eSoDesignator = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE; - sal_Bool b116432Designator = sal_False; - sal_Bool bSo = sal_False; + bool b116432Designator = false; + bool bSo = false; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBuf + nDestBytes; - sal_Bool bWritten; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBuf + nDestBytes; + bool bWritten; if (pContext) { nHighSurrogate - = ((ImplUnicodeToIso2022CnContext *) pContext)->m_nHighSurrogate; + = static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_nHighSurrogate; eSoDesignator - = ((ImplUnicodeToIso2022CnContext *) pContext)->m_eSoDesignator; - b116432Designator = ((ImplUnicodeToIso2022CnContext *) pContext)-> + = static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_eSoDesignator; + b116432Designator = static_cast< ImplUnicodeToIso2022CnContext * >(pContext)-> m_b116432Designator; - bSo = ((ImplUnicodeToIso2022CnContext *) pContext)->m_bSo; + bSo = static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_bSo; } for (; nConverted < nSrcChars; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *pSrcBuf++; if (nHighSurrogate == 0) { @@ -546,33 +549,33 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, nChar = ImplCombineSurrogates(nHighSurrogate, nChar); else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar)) { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } - if (nChar == 0x0A || nChar == 0x0D) /* LF, CR */ + if (nChar == 0x0A || nChar == 0x0D) // LF, CR { if (bSo) { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ - bSo = sal_False; + *pDestBufPtr++ = 0x0F; // SI + bSo = false; eSoDesignator = IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_NONE; - b116432Designator = sal_False; + b116432Designator = false; } else goto no_output; } if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; } @@ -584,14 +587,14 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ - bSo = sal_False; + *pDestBufPtr++ = 0x0F; // SI + bSo = false; } else goto no_output; } if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; } @@ -674,21 +677,21 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ - bSo = sal_False; + *pDestBufPtr++ = 0x0F; // SI + bSo = false; } else goto no_output; } if (pDestBufEnd - pDestBufPtr >= 4) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x24; /* $ */ - *pDestBufPtr++ = 0x29; /* ) */ + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x24; // $ + *pDestBufPtr++ = 0x29; // ) *pDestBufPtr++ = eNewDesignator == IMPL_UNICODE_TO_ISO_2022_CN_DESIGNATOR_2312 ? - 0x41 : 0x47; /* A, G */ + 0x41 : 0x47; // A, G eSoDesignator = eNewDesignator; } else @@ -698,16 +701,16 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0E; /* SO */ - bSo = sal_True; + *pDestBufPtr++ = 0x0E; // SO + bSo = true; } else goto no_output; } if (pDestBufEnd - pDestBufPtr >= 4) { - *pDestBufPtr++ = (sal_Char) (nBytes >> 8); - *pDestBufPtr++ = (sal_Char) (nBytes & 0xFF); + *pDestBufPtr++ = static_cast< char >(nBytes >> 8); + *pDestBufPtr++ = static_cast< char >(nBytes & 0xFF); } else goto no_output; @@ -738,23 +741,23 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, { if (pDestBufEnd - pDestBufPtr >= 4) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x24; /* $ */ - *pDestBufPtr++ = 0x2A; /* * */ - *pDestBufPtr++ = 0x48; /* H */ - b116432Designator = sal_True; + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x24; // $ + *pDestBufPtr++ = 0x2A; // * + *pDestBufPtr++ = 0x48; // H + b116432Designator = true; } else goto no_output; } if (pDestBufEnd - pDestBufPtr >= 4) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x4E; /* N */ + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x4E; // N *pDestBufPtr++ - = (sal_Char) (0x20 + pCns116431992Data[nOffset++]); + = static_cast< char >(0x20 + pCns116431992Data[nOffset++]); *pDestBufPtr++ - = (sal_Char) (0x20 + pCns116431992Data[nOffset]); + = static_cast< char >(0x20 + pCns116431992Data[nOffset]); } else goto no_output; @@ -770,7 +773,7 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, &pDestBufPtr, pDestBufEnd, &nInfo, - "\x0F", /* SI */ + "\x0F", // SI bSo ? 1 : 0, &bWritten)) { @@ -780,7 +783,7 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, case IMPL_BAD_INPUT_CONTINUE: if (bWritten) - bSo = sal_False; + bSo = false; nHighSurrogate = 0; continue; @@ -799,31 +802,31 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0) { - sal_Bool bFlush = sal_True; + bool bFlush = true; if (nHighSurrogate != 0) { if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputUnicodeToTextConversion( - sal_False, + false, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo, - "\x0F", /* SI */ + "\x0F", // SI bSo ? 1 : 0, &bWritten)) { case IMPL_BAD_INPUT_STOP: nHighSurrogate = 0; - bFlush = sal_False; + bFlush = false; break; case IMPL_BAD_INPUT_CONTINUE: if (bWritten) - bSo = sal_False; + bSo = false; nHighSurrogate = 0; break; @@ -836,8 +839,8 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ - bSo = sal_False; + *pDestBufPtr++ = 0x0F; // SI + bSo = false; } else nInfo |= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL; @@ -846,13 +849,13 @@ sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, if (pContext) { - ((ImplUnicodeToIso2022CnContext *) pContext)->m_nHighSurrogate + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_nHighSurrogate = nHighSurrogate; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_eSoDesignator + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_eSoDesignator = eSoDesignator; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_b116432Designator + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_b116432Designator = b116432Designator; - ((ImplUnicodeToIso2022CnContext *) pContext)->m_bSo = bSo; + static_cast< ImplUnicodeToIso2022CnContext * >(pContext)->m_bSo = bSo; } if (pInfo) *pInfo = nInfo; diff --git a/sal/textenc/convertiso2022cn.h b/sal/textenc/convertiso2022cn.hxx index bf5186d66e1f..dc2cccf62d3d 100644 --- a/sal/textenc/convertiso2022cn.h +++ b/sal/textenc/convertiso2022cn.hxx @@ -26,17 +26,16 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTISO2022CN_H -#define INCLUDED_RTL_TEXTENC_CONVERTISO2022CN_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTISO2022CN_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTISO2022CN_HXX + +#include "sal/config.h" -#include "tenchelp.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "tenchelp.hxx" -typedef struct +struct ImplIso2022CnConverterData { ImplDBCSToUniLeadTab const * m_pGb2312ToUnicodeData; sal_uInt16 const * m_pCns116431992ToUnicodeData; @@ -46,42 +45,36 @@ typedef struct sal_uInt8 const * m_pUnicodeToCns116431992Data; sal_Int32 const * m_pUnicodeToCns116431992PageOffsets; sal_Int32 const * m_pUnicodeToCns116431992PlaneOffsets; -} ImplIso2022CnConverterData; +}; -void * ImplCreateIso2022CnToUnicodeContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateIso2022CnToUnicodeContext(); -void ImplResetIso2022CnToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetIso2022CnToUnicodeContext(void * pContext); sal_Size ImplConvertIso2022CnToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtBytes); -void * ImplCreateUnicodeToIso2022CnContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateUnicodeToIso2022CnContext(); -void ImplResetUnicodeToIso2022CnContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetUnicodeToIso2022CnContext(void * pContext); sal_Size ImplConvertUnicodeToIso2022Cn(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtChars) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cpluscplus */ + sal_Size * pSrcCvtChars); -#endif /* INCLUDED_RTL_TEXTENC_CONVERTISO2022CN_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/convertiso2022cn.tab b/sal/textenc/convertiso2022cn.tab index 937437693209..319325f3a243 100644 --- a/sal/textenc/convertiso2022cn.tab +++ b/sal/textenc/convertiso2022cn.tab @@ -25,22 +25,14 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#include "context.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_CONVERTISO2022CN_H -#include "convertiso2022cn.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H -#include "tenchelp.h" -#endif +#include "sal/config.h" -#ifndef _RTL_TENCINFO_H #include "rtl/tencinfo.h" -#endif -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif + +#include "context.hxx" +#include "convertiso2022cn.hxx" +#include "tenchelp.hxx" static ImplIso2022CnConverterData const aImplIso2022CnConvertData = { aGB2312UniLeadTab, /* from tcvtscn6.tab */ diff --git a/sal/textenc/convertiso2022jp.c b/sal/textenc/convertiso2022jp.cxx index e4792b573373..7961f150e124 100644 --- a/sal/textenc/convertiso2022jp.c +++ b/sal/textenc/convertiso2022jp.cxx @@ -26,16 +26,20 @@ * ************************************************************************/ -#include "convertiso2022jp.h" -#include "context.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" -#include "rtl/alloc.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" -typedef enum /* order is important: */ +#include "context.hxx" +#include "converter.hxx" +#include "convertiso2022jp.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + +namespace { + +enum ImplIso2022JpToUnicodeState // order is important: { IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII, IMPL_ISO_2022_JP_TO_UNICODE_STATE_JIS_ROMAN, @@ -44,39 +48,40 @@ typedef enum /* order is important: */ IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC, IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC_LPAREN, IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC_DOLLAR -} ImplIso2022JpToUnicodeState; +}; -typedef struct +struct ImplIso2022JpToUnicodeContext { ImplIso2022JpToUnicodeState m_eState; sal_uInt32 m_nRow; -} ImplIso2022JpToUnicodeContext; +}; -typedef struct +struct ImplUnicodeToIso2022JpContext { sal_Unicode m_nHighSurrogate; - sal_Bool m_b0208; -} ImplUnicodeToIso2022JpContext; + bool m_b0208; +}; -void * ImplCreateIso2022JpToUnicodeContext(void) +} + +void * ImplCreateIso2022JpToUnicodeContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplIso2022JpToUnicodeContext)); - ((ImplIso2022JpToUnicodeContext *) pContext)->m_eState - = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII; + ImplIso2022JpToUnicodeContext * pContext = + new ImplIso2022JpToUnicodeContext; + pContext->m_eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII; return pContext; } void ImplResetIso2022JpToUnicodeContext(void * pContext) { if (pContext) - ((ImplIso2022JpToUnicodeContext *) pContext)->m_eState + static_cast< ImplIso2022JpToUnicodeContext * >(pContext)->m_eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII; } sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -85,7 +90,7 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, sal_Size * pSrcCvtBytes) { ImplDBCSToUniLeadTab const * pJisX0208Data - = ((ImplIso2022JpConverterData const *) pData)-> + = static_cast< ImplIso2022JpConverterData const * >(pData)-> m_pJisX0208ToUnicodeData; ImplIso2022JpToUnicodeState eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII; @@ -97,18 +102,18 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, if (pContext) { - eState = ((ImplIso2022JpToUnicodeContext *) pContext)->m_eState; - nRow = ((ImplIso2022JpToUnicodeContext *) pContext)->m_nRow; + eState = static_cast< ImplIso2022JpToUnicodeContext * >(pContext)->m_eState; + nRow = static_cast< ImplIso2022JpToUnicodeContext * >(pContext)->m_nRow; } for (; nConverted < nSrcBytes; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++; switch (eState) { case IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII: - if (nChar == 0x1B) /* ESC */ + if (nChar == 0x1B) // ESC eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) @@ -117,25 +122,25 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, goto no_output; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_JP_TO_UNICODE_STATE_JIS_ROMAN: - if (nChar == 0x1B) /* ESC */ + if (nChar == 0x1B) // ESC eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) { switch (nChar) { - case 0x5C: /* \ */ - nChar = 0xA5; /* YEN SIGN */ + case 0x5C: // REVERSE SOLIDUS (\) + nChar = 0xA5; // YEN SIGN break; - case 0x7E: /* ~ */ - nChar = 0xAF; /* MACRON */ + case 0x7E: // ~ + nChar = 0xAF; // MACRON break; } *pDestBufPtr++ = (sal_Unicode) nChar; @@ -144,13 +149,13 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, goto no_output; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_JP_TO_UNICODE_STATE_0208: - if (nChar == 0x1B) /* ESC */ + if (nChar == 0x1B) // ESC eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC; else if (nChar >= 0x21 && nChar <= 0x7E) { @@ -159,7 +164,7 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -186,7 +191,7 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -194,16 +199,16 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, case IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC: switch (nChar) { - case 0x24: /* $ */ + case 0x24: // $ eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC_DOLLAR; break; - case 0x28: /* ( */ + case 0x28: // ( eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC_LPAREN; break; default: - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -211,16 +216,16 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, case IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC_LPAREN: switch (nChar) { - case 0x42: /* A */ + case 0x42: // A eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_ASCII; break; - case 0x4A: /* J */ + case 0x4A: // J eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_JIS_ROMAN; break; default: - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -228,13 +233,13 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, case IMPL_ISO_2022_JP_TO_UNICODE_STATE_ESC_DOLLAR: switch (nChar) { - case 0x40: /* @ */ - case 0x42: /* B */ + case 0x40: // @ + case 0x42: // B eState = IMPL_ISO_2022_JP_TO_UNICODE_STATE_0208; break; default: - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -243,7 +248,7 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -274,7 +279,7 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -290,8 +295,8 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, if (pContext) { - ((ImplIso2022JpToUnicodeContext *) pContext)->m_eState = eState; - ((ImplIso2022JpToUnicodeContext *) pContext)->m_nRow = nRow; + static_cast< ImplIso2022JpToUnicodeContext * >(pContext)->m_eState = eState; + static_cast< ImplIso2022JpToUnicodeContext * >(pContext)->m_nRow = nRow; } if (pInfo) *pInfo = nInfo; @@ -301,12 +306,12 @@ sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, return pDestBufPtr - pDestBuf; } -void * ImplCreateUnicodeToIso2022JpContext(void) +void * ImplCreateUnicodeToIso2022JpContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplUnicodeToIso2022JpContext)); - ((ImplUnicodeToIso2022JpContext *) pContext)->m_nHighSurrogate = 0; - ((ImplUnicodeToIso2022JpContext *) pContext)->m_b0208 = sal_False; + ImplUnicodeToIso2022JpContext * pContext = + new ImplUnicodeToIso2022JpContext; + pContext->m_nHighSurrogate = 0; + pContext->m_b0208 = false; return pContext; } @@ -314,8 +319,8 @@ void ImplResetUnicodeToIso2022JpContext(void * pContext) { if (pContext) { - ((ImplUnicodeToIso2022JpContext *) pContext)->m_nHighSurrogate = 0; - ((ImplUnicodeToIso2022JpContext *) pContext)->m_b0208 = sal_False; + static_cast< ImplUnicodeToIso2022JpContext * >(pContext)->m_nHighSurrogate = 0; + static_cast< ImplUnicodeToIso2022JpContext * >(pContext)->m_b0208 = false; } } @@ -323,33 +328,33 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) { ImplUniToDBCSHighTab const * pJisX0208Data - = ((ImplIso2022JpConverterData const *) pData)-> + = static_cast< ImplIso2022JpConverterData const * >(pData)-> m_pUnicodeToJisX0208Data; sal_Unicode nHighSurrogate = 0; - sal_Bool b0208 = sal_False; + bool b0208 = false; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBuf + nDestBytes; - sal_Bool bWritten; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBuf + nDestBytes; + bool bWritten; if (pContext) { nHighSurrogate - = ((ImplUnicodeToIso2022JpContext *) pContext)->m_nHighSurrogate; - b0208 = ((ImplUnicodeToIso2022JpContext *) pContext)->m_b0208; + = static_cast< ImplUnicodeToIso2022JpContext * >(pContext)->m_nHighSurrogate; + b0208 = static_cast< ImplUnicodeToIso2022JpContext * >(pContext)->m_b0208; } for (; nConverted < nSrcChars; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *pSrcBuf++; if (nHighSurrogate == 0) { @@ -363,32 +368,32 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, nChar = ImplCombineSurrogates(nHighSurrogate, nChar); else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar)) { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } - if (nChar == 0x0A || nChar == 0x0D) /* LF, CR */ + if (nChar == 0x0A || nChar == 0x0D) // LF, CR { if (b0208) { if (pDestBufEnd - pDestBufPtr >= 3) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x28; /* ( */ - *pDestBufPtr++ = 0x42; /* B */ - b0208 = sal_False; + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x28; // ( + *pDestBufPtr++ = 0x42; // B + b0208 = false; } else goto no_output; } if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; } @@ -400,16 +405,16 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, { if (pDestBufEnd - pDestBufPtr >= 3) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x28; /* ( */ - *pDestBufPtr++ = 0x42; /* B */ - b0208 = sal_False; + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x28; // ( + *pDestBufPtr++ = 0x42; // B + b0208 = false; } else goto no_output; } if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; } @@ -427,15 +432,15 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, nBytes = pJisX0208Data[nIndex1]. mpToUniTrailTab[nIndex2 - nFirst]; if (nBytes == 0) - /* For some reason, the tables in tcvtjp4.tab do not - include these two conversions: */ + // For some reason, the tables in tcvtjp4.tab do not + // include these two conversions: switch (nChar) { - case 0xA5: /* YEN SIGN */ + case 0xA5: // YEN SIGN nBytes = 0x216F; break; - case 0xAF: /* MACRON */ + case 0xAF: // MACRON nBytes = 0x2131; break; } @@ -447,18 +452,18 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, { if (pDestBufEnd - pDestBufPtr >= 3) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x24; /* $ */ - *pDestBufPtr++ = 0x42; /* B */ - b0208 = sal_True; + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x24; // $ + *pDestBufPtr++ = 0x42; // B + b0208 = true; } else goto no_output; } if (pDestBufEnd - pDestBufPtr >= 2) { - *pDestBufPtr++ = (sal_Char) (nBytes >> 8); - *pDestBufPtr++ = (sal_Char) (nBytes & 0xFF); + *pDestBufPtr++ = static_cast< char >(nBytes >> 8); + *pDestBufPtr++ = static_cast< char >(nBytes & 0xFF); } else goto no_output; @@ -487,7 +492,7 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, case IMPL_BAD_INPUT_CONTINUE: if (bWritten) - b0208 = sal_False; + b0208 = false; nHighSurrogate = 0; continue; @@ -506,14 +511,14 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0) { - sal_Bool bFlush = sal_True; + bool bFlush = true; if (nHighSurrogate != 0) { if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputUnicodeToTextConversion( - sal_False, + false, 0, nFlags, &pDestBufPtr, @@ -525,12 +530,12 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, { case IMPL_BAD_INPUT_STOP: nHighSurrogate = 0; - bFlush = sal_False; + bFlush = false; break; case IMPL_BAD_INPUT_CONTINUE: if (bWritten) - b0208 = sal_False; + b0208 = false; nHighSurrogate = 0; break; @@ -545,10 +550,10 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, { if (pDestBufEnd - pDestBufPtr >= 3) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x28; /* ( */ - *pDestBufPtr++ = 0x42; /* B */ - b0208 = sal_False; + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x28; // ( + *pDestBufPtr++ = 0x42; // B + b0208 = false; } else nInfo |= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL; @@ -557,9 +562,9 @@ sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, if (pContext) { - ((ImplUnicodeToIso2022JpContext *) pContext)->m_nHighSurrogate + static_cast< ImplUnicodeToIso2022JpContext * >(pContext)->m_nHighSurrogate = nHighSurrogate; - ((ImplUnicodeToIso2022JpContext *) pContext)->m_b0208 = b0208; + static_cast< ImplUnicodeToIso2022JpContext * >(pContext)->m_b0208 = b0208; } if (pInfo) *pInfo = nInfo; diff --git a/sal/textenc/convertiso2022jp.h b/sal/textenc/convertiso2022jp.hxx index 257558387456..e7f05e8dd517 100644 --- a/sal/textenc/convertiso2022jp.h +++ b/sal/textenc/convertiso2022jp.hxx @@ -26,56 +26,49 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTISO2022JP_H -#define INCLUDED_RTL_TEXTENC_CONVERTISO2022JP_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTISO2022JP_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTISO2022JP_HXX + +#include "sal/config.h" -#include "tenchelp.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "tenchelp.hxx" -typedef struct +struct ImplIso2022JpConverterData { ImplDBCSToUniLeadTab const * m_pJisX0208ToUnicodeData; ImplUniToDBCSHighTab const * m_pUnicodeToJisX0208Data; -} ImplIso2022JpConverterData; +}; -void * ImplCreateIso2022JpToUnicodeContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateIso2022JpToUnicodeContext(); -void ImplResetIso2022JpToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetIso2022JpToUnicodeContext(void * pContext); sal_Size ImplConvertIso2022JpToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtBytes); -void * ImplCreateUnicodeToIso2022JpContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateUnicodeToIso2022JpContext(); -void ImplResetUnicodeToIso2022JpContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetUnicodeToIso2022JpContext(void * pContext); sal_Size ImplConvertUnicodeToIso2022Jp(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtChars) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cpluscplus */ + sal_Size * pSrcCvtChars); -#endif /* INCLUDED_RTL_TEXTENC_CONVERTISO2022JP_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/convertiso2022jp.tab b/sal/textenc/convertiso2022jp.tab index 5775491c87f5..a3c97fa7e9fa 100644 --- a/sal/textenc/convertiso2022jp.tab +++ b/sal/textenc/convertiso2022jp.tab @@ -25,22 +25,14 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#include "context.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_CONVERTISO2022JP_H -#include "convertiso2022jp.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H -#include "tenchelp.h" -#endif +#include "sal/config.h" -#ifndef _RTL_TENCINFO_H #include "rtl/tencinfo.h" -#endif -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif + +#include "context.hxx" +#include "convertiso2022jp.hxx" +#include "tenchelp.hxx" static ImplIso2022JpConverterData const aImplIso2022JpConvertData = { aJIS0208UniLeadTab, /* from tcvtjp6.tab */ diff --git a/sal/textenc/convertiso2022kr.c b/sal/textenc/convertiso2022kr.cxx index 8354b312ab87..d2b2e8731bbf 100644 --- a/sal/textenc/convertiso2022kr.c +++ b/sal/textenc/convertiso2022kr.cxx @@ -26,16 +26,20 @@ * ************************************************************************/ -#include "convertiso2022kr.h" -#include "context.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" -#include "rtl/alloc.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" -typedef enum /* order is important: */ +#include "context.hxx" +#include "converter.hxx" +#include "convertiso2022kr.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" + +namespace { + +enum ImplIso2022KrToUnicodeState // order is important: { IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII, IMPL_ISO_2022_KR_TO_UNICODE_STATE_1001, @@ -43,46 +47,47 @@ typedef enum /* order is important: */ IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC, IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC_DOLLAR, IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN -} ImplIso2022KrToUnicodeState; +}; -typedef struct +struct ImplIso2022KrToUnicodeContext { ImplIso2022KrToUnicodeState m_eState; sal_uInt32 m_nRow; -} ImplIso2022KrToUnicodeContext; +}; -typedef enum +enum ImplUnicodeToIso2022KrSet { IMPL_UNICODE_TO_ISO_2022_KR_SET_NONE, IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII, IMPL_UNICODE_TO_ISO_2022_KR_SET_1001 -} ImplUnicodeToIso2022KrSet; +}; -typedef struct +struct ImplUnicodeToIso2022KrContext { sal_Unicode m_nHighSurrogate; ImplUnicodeToIso2022KrSet m_eSet; -} ImplUnicodeToIso2022KrContext; +}; -void * ImplCreateIso2022KrToUnicodeContext(void) +} + +void * ImplCreateIso2022KrToUnicodeContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplIso2022KrToUnicodeContext)); - ((ImplIso2022KrToUnicodeContext *) pContext)->m_eState - = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII; + ImplIso2022KrToUnicodeContext * pContext = + new ImplIso2022KrToUnicodeContext; + pContext->m_eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII; return pContext; } void ImplResetIso2022KrToUnicodeContext(void * pContext) { if (pContext) - ((ImplIso2022KrToUnicodeContext *) pContext)->m_eState + static_cast< ImplIso2022KrToUnicodeContext * >(pContext)->m_eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII; } sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -91,7 +96,7 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, sal_Size * pSrcCvtBytes) { ImplDBCSToUniLeadTab const * pKsX1001Data - = ((ImplIso2022KrConverterData const *) pData)-> + = static_cast< ImplIso2022KrConverterData const * >(pData)-> m_pKsX1001ToUnicodeData; ImplIso2022KrToUnicodeState eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII; @@ -103,20 +108,20 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, if (pContext) { - eState = ((ImplIso2022KrToUnicodeContext *) pContext)->m_eState; - nRow = ((ImplIso2022KrToUnicodeContext *) pContext)->m_nRow; + eState = static_cast< ImplIso2022KrToUnicodeContext * >(pContext)->m_eState; + nRow = static_cast< ImplIso2022KrToUnicodeContext * >(pContext)->m_nRow; } for (; nConverted < nSrcBytes; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *(sal_uChar const *) pSrcBuf++; switch (eState) { case IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII: - if (nChar == 0x0E) /* SO */ + if (nChar == 0x0E) // SO eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_1001; - else if (nChar == 0x1B) /* ESC */ + else if (nChar == 0x1B) // ESC eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC; else if (nChar < 0x80) if (pDestBufPtr != pDestBufEnd) @@ -125,13 +130,13 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, goto no_output; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_KR_TO_UNICODE_STATE_1001: - if (nChar == 0x0F) /* SI */ + if (nChar == 0x0F) // SI eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII; else if (nChar >= 0x21 && nChar <= 0x7E) { @@ -140,7 +145,7 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -167,37 +172,37 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, } else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC: - if (nChar == 0x24) /* $ */ + if (nChar == 0x24) // $ eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC_DOLLAR; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC_DOLLAR: - if (nChar == 0x29) /* ) */ + if (nChar == 0x29) // ) eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; case IMPL_ISO_2022_KR_TO_UNICODE_STATE_ESC_DOLLAR_RPAREN: - if (nChar == 0x43) /* C */ + if (nChar == 0x43) // C eState = IMPL_ISO_2022_KR_TO_UNICODE_STATE_ASCII; else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } break; @@ -206,7 +211,7 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -237,7 +242,7 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: @@ -253,8 +258,8 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, if (pContext) { - ((ImplIso2022KrToUnicodeContext *) pContext)->m_eState = eState; - ((ImplIso2022KrToUnicodeContext *) pContext)->m_nRow = nRow; + static_cast< ImplIso2022KrToUnicodeContext * >(pContext)->m_eState = eState; + static_cast< ImplIso2022KrToUnicodeContext * >(pContext)->m_nRow = nRow; } if (pInfo) *pInfo = nInfo; @@ -264,13 +269,12 @@ sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, return pDestBufPtr - pDestBuf; } -void * ImplCreateUnicodeToIso2022KrContext(void) +void * ImplCreateUnicodeToIso2022KrContext() { - void * pContext - = rtl_allocateMemory(sizeof (ImplUnicodeToIso2022KrContext)); - ((ImplUnicodeToIso2022KrContext *) pContext)->m_nHighSurrogate = 0; - ((ImplUnicodeToIso2022KrContext *) pContext)->m_eSet - = IMPL_UNICODE_TO_ISO_2022_KR_SET_NONE; + ImplUnicodeToIso2022KrContext * pContext = + new ImplUnicodeToIso2022KrContext; + pContext->m_nHighSurrogate = 0; + pContext->m_eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_NONE; return pContext; } @@ -278,8 +282,8 @@ void ImplResetUnicodeToIso2022KrContext(void * pContext) { if (pContext) { - ((ImplUnicodeToIso2022KrContext *) pContext)->m_nHighSurrogate = 0; - ((ImplUnicodeToIso2022KrContext *) pContext)->m_eSet + static_cast< ImplUnicodeToIso2022KrContext * >(pContext)->m_nHighSurrogate = 0; + static_cast< ImplUnicodeToIso2022KrContext * >(pContext)->m_eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_NONE; } } @@ -288,38 +292,38 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtChars) { ImplUniToDBCSHighTab const * pKsX1001Data - = ((ImplIso2022KrConverterData const *) pData)-> + = static_cast< ImplIso2022KrConverterData const * >(pData)-> m_pUnicodeToKsX1001Data; sal_Unicode nHighSurrogate = 0; ImplUnicodeToIso2022KrSet eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_NONE; sal_uInt32 nInfo = 0; sal_Size nConverted = 0; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBuf + nDestBytes; - sal_Bool bWritten; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBuf + nDestBytes; + bool bWritten; if (pContext) { nHighSurrogate - = ((ImplUnicodeToIso2022KrContext *) pContext)->m_nHighSurrogate; - eSet = ((ImplUnicodeToIso2022KrContext *) pContext)->m_eSet; + = static_cast< ImplUnicodeToIso2022KrContext * >(pContext)->m_nHighSurrogate; + eSet = static_cast< ImplUnicodeToIso2022KrContext * >(pContext)->m_eSet; } if (eSet == IMPL_UNICODE_TO_ISO_2022_KR_SET_NONE) { if (pDestBufEnd - pDestBufPtr >= 4) { - *pDestBufPtr++ = 0x1B; /* ESC */ - *pDestBufPtr++ = 0x24; /* $ */ - *pDestBufPtr++ = 0x29; /* ) */ - *pDestBufPtr++ = 0x43; /* C */ + *pDestBufPtr++ = 0x1B; // ESC + *pDestBufPtr++ = 0x24; // $ + *pDestBufPtr++ = 0x29; // ) + *pDestBufPtr++ = 0x43; // C eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII; } else @@ -329,7 +333,7 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, if ((nInfo & RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL) == 0) for (; nConverted < nSrcChars; ++nConverted) { - sal_Bool bUndefined = sal_True; + bool bUndefined = true; sal_uInt32 nChar = *pSrcBuf++; if (nHighSurrogate == 0) { @@ -343,30 +347,30 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, nChar = ImplCombineSurrogates(nHighSurrogate, nChar); else { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } if (ImplIsLowSurrogate(nChar) || ImplIsNoncharacter(nChar)) { - bUndefined = sal_False; + bUndefined = false; goto bad_input; } - if (nChar == 0x0A || nChar == 0x0D) /* LF, CR */ + if (nChar == 0x0A || nChar == 0x0D) // LF, CR { if (eSet == IMPL_UNICODE_TO_ISO_2022_KR_SET_1001) { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ + *pDestBufPtr++ = 0x0F; // SI eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII; } else goto no_output; } if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; } @@ -378,14 +382,14 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ + *pDestBufPtr++ = 0x0F; // SI eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII; } else goto no_output; } if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; } @@ -408,7 +412,7 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0E; /* SO */ + *pDestBufPtr++ = 0x0E; // SO eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_1001; } else @@ -416,8 +420,8 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, } if (pDestBufEnd - pDestBufPtr >= 2) { - *pDestBufPtr++ = (sal_Char) ((nBytes >> 8) & 0x7F); - *pDestBufPtr++ = (sal_Char) (nBytes & 0x7F); + *pDestBufPtr++ = static_cast< char >((nBytes >> 8) & 0x7F); + *pDestBufPtr++ = static_cast< char >(nBytes & 0x7F); } else goto no_output; @@ -436,7 +440,7 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, &pDestBufPtr, pDestBufEnd, &nInfo, - "\x0F", /* SI */ + "\x0F", // SI eSet == IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII ? 0 : 1, &bWritten)) { @@ -465,27 +469,27 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL)) == 0) { - sal_Bool bFlush = sal_True; + bool bFlush = true; if (nHighSurrogate != 0) { if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputUnicodeToTextConversion( - sal_False, + false, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo, - "\x0F", /* SI */ + "\x0F", // SI eSet == IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII ? 0 : 1, &bWritten)) { case IMPL_BAD_INPUT_STOP: nHighSurrogate = 0; - bFlush = sal_False; + bFlush = false; break; case IMPL_BAD_INPUT_CONTINUE: @@ -505,7 +509,7 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, { if (pDestBufPtr != pDestBufEnd) { - *pDestBufPtr++ = 0x0F; /* SI */ + *pDestBufPtr++ = 0x0F; // SI eSet = IMPL_UNICODE_TO_ISO_2022_KR_SET_ASCII; } else @@ -515,9 +519,9 @@ sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, if (pContext) { - ((ImplUnicodeToIso2022KrContext *) pContext)->m_nHighSurrogate + static_cast< ImplUnicodeToIso2022KrContext * >(pContext)->m_nHighSurrogate = nHighSurrogate; - ((ImplUnicodeToIso2022KrContext *) pContext)->m_eSet = eSet; + static_cast< ImplUnicodeToIso2022KrContext * >(pContext)->m_eSet = eSet; } if (pInfo) *pInfo = nInfo; diff --git a/sal/textenc/convertiso2022kr.h b/sal/textenc/convertiso2022kr.hxx index 7208bcf63bb0..c4a93c63786a 100644 --- a/sal/textenc/convertiso2022kr.h +++ b/sal/textenc/convertiso2022kr.hxx @@ -26,56 +26,49 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTISO2022KR_H -#define INCLUDED_RTL_TEXTENC_CONVERTISO2022KR_H +#ifndef INCLUDED_SAL_TEXTENC_CONVERTISO2022KR_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTISO2022KR_HXX + +#include "sal/config.h" -#include "tenchelp.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "tenchelp.hxx" -typedef struct +struct ImplIso2022KrConverterData { ImplDBCSToUniLeadTab const * m_pKsX1001ToUnicodeData; ImplUniToDBCSHighTab const * m_pUnicodeToKsX1001Data; -} ImplIso2022KrConverterData; +}; -void * ImplCreateIso2022KrToUnicodeContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateIso2022KrToUnicodeContext(); -void ImplResetIso2022KrToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetIso2022KrToUnicodeContext(void * pContext); sal_Size ImplConvertIso2022KrToUnicode(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); + sal_Size * pSrcCvtBytes); -void * ImplCreateUnicodeToIso2022KrContext(void) SAL_THROW_EXTERN_C(); +void * ImplCreateUnicodeToIso2022KrContext(); -void ImplResetUnicodeToIso2022KrContext(void * pContext) SAL_THROW_EXTERN_C(); +void ImplResetUnicodeToIso2022KrContext(void * pContext); sal_Size ImplConvertUnicodeToIso2022Kr(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, - sal_Size * pSrcCvtChars) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cpluscplus */ + sal_Size * pSrcCvtChars); -#endif /* INCLUDED_RTL_TEXTENC_CONVERTISO2022KR_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/convertiso2022kr.tab b/sal/textenc/convertiso2022kr.tab index 87010f55590f..86cf889c7bf7 100644 --- a/sal/textenc/convertiso2022kr.tab +++ b/sal/textenc/convertiso2022kr.tab @@ -25,22 +25,14 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONTEXT_H -#include "context.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_CONVERTISO2022KR_H -#include "convertiso2022kr.h" -#endif -#ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H -#include "tenchelp.h" -#endif +#include "sal/config.h" -#ifndef _RTL_TENCINFO_H #include "rtl/tencinfo.h" -#endif -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif + +#include "context.hxx" +#include "convertiso2022kr.hxx" +#include "tenchelp.hxx" static ImplIso2022KrConverterData const aImplIso2022KrConvertData = { aKSC5601UniLeadTab, /* from tcvtkr6.tab */ diff --git a/sal/textenc/convertsinglebytetobmpunicode.cxx b/sal/textenc/convertsinglebytetobmpunicode.cxx index b563be83abaf..b485f88c7899 100644 --- a/sal/textenc/convertsinglebytetobmpunicode.cxx +++ b/sal/textenc/convertsinglebytetobmpunicode.cxx @@ -26,17 +26,18 @@ * ************************************************************************/ +#include "sal/config.h" -#include "context.h" -#include "converter.h" -#include "convertsinglebytetobmpunicode.hxx" -#include "unichars.h" +#include <cstddef> #include "osl/diagnose.h" #include "rtl/textcvt.h" #include "sal/types.h" -#include <cstddef> +#include "context.hxx" +#include "converter.hxx" +#include "convertsinglebytetobmpunicode.hxx" +#include "unichars.hxx" sal_Size rtl_textenc_convertSingleByteToBmpUnicode( ImplTextConverterData const * data, void *, sal_Char const * srcBuf, diff --git a/sal/textenc/convertsinglebytetobmpunicode.hxx b/sal/textenc/convertsinglebytetobmpunicode.hxx index 39ebed9eabca..a55ca53c8b20 100644 --- a/sal/textenc/convertsinglebytetobmpunicode.hxx +++ b/sal/textenc/convertsinglebytetobmpunicode.hxx @@ -26,14 +26,16 @@ * ************************************************************************/ -#ifndef INCLUDED_sal_textenc_convertsinglebytetobmpunicode_hxx -#define INCLUDED_sal_textenc_convertsinglebytetobmpunicode_hxx +#ifndef INCLUDED_SAL_TEXTENC_CONVERTSINGLEBYTETOBMPUNICODE_HXX +#define INCLUDED_SAL_TEXTENC_CONVERTSINGLEBYTETOBMPUNICODE_HXX -#include "tenchelp.h" +#include "sal/config.h" + +#include <cstddef> #include "sal/types.h" -#include <cstddef> +#include "tenchelp.hxx" /// @HTML diff --git a/sal/textenc/generate/gb180302000.tab b/sal/textenc/generate/gb180302000.tab index 00b58b3cff88..1fece262db2e 100644 --- a/sal/textenc/generate/gb180302000.tab +++ b/sal/textenc/generate/gb180302000.tab @@ -25,13 +25,11 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_CONVERTGB18030_H -#include "convertgb18030.h" -#endif +#include "sal/config.h" -#ifndef _SAL_TYPES_H_ #include "sal/types.h" -#endif + +#include "convertgb18030.hxx" static sal_Unicode const aImplGb180302000ToUnicodeData[] = { 0x4E02,0x4E04,0x4E05,0x4E06,0x4E0F,0x4E12,0x4E17,0x4E1F, diff --git a/sal/textenc/gettextencodingdata.h b/sal/textenc/gettextencodingdata.hxx index f2d31be82902..ab8656967f06 100644 --- a/sal/textenc/gettextencodingdata.h +++ b/sal/textenc/gettextencodingdata.hxx @@ -26,24 +26,18 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_GETTEXTENCODINGDATA_H -#define INCLUDED_RTL_TEXTENC_GETTEXTENCODINGDATA_H +#ifndef INCLUDED_SAL_TEXTENC_GETTEXTENCODINGDATA_HXX +#define INCLUDED_SAL_TEXTENC_GETTEXTENCODINGDATA_HXX + +#include "sal/config.h" -#include "tenchelp.h" #include "rtl/textenc.h" -#include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cplusplus */ +#include "tenchelp.hxx" ImplTextEncodingData const * -Impl_getTextEncodingData(rtl_TextEncoding nEncoding) SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cplusplus */ +Impl_getTextEncodingData(rtl_TextEncoding nEncoding); -#endif /* INCLUDED_RTL_TEXTENC_GETTEXTENCODINGDATA_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/tables.cxx b/sal/textenc/tables.cxx index 096876119a20..01f91905dea1 100644 --- a/sal/textenc/tables.cxx +++ b/sal/textenc/tables.cxx @@ -29,21 +29,12 @@ #include "sal/config.h" #include <cassert> +#include <cstddef> -#include "sal/types.h" - -#ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H -#include "tenchelp.h" -#endif - -#ifndef _RTL_TEXTENC_H #include "rtl/textenc.h" -#endif +#include "sal/types.h" -#ifndef INCLUDED_STDDEF_H -#include <stddef.h> -#define INCLUDED_STDDEF_H -#endif +#include "tenchelp.hxx" #define NOTABUNI_START 0xFF #define NOTABUNI_END 0x00 diff --git a/sal/textenc/tcvtbyte.c b/sal/textenc/tcvtbyte.cxx index b8e3ed222f7c..9296d68f2c0d 100644 --- a/sal/textenc/tcvtbyte.c +++ b/sal/textenc/tcvtbyte.cxx @@ -26,9 +26,12 @@ * ************************************************************************/ -#include "tenchelp.h" +#include "sal/config.h" + #include "rtl/textcvt.h" +#include "tenchelp.hxx" + /* ======================================================================= */ #define IMPL_MAX_REPLACECHAR 5 @@ -39,11 +42,11 @@ sal_uInt16 const * ImplGetReplaceString(sal_Unicode c); /* ----------------------------------------------------------------------- */ -typedef struct +struct ImplReplaceCharData { sal_uInt16 mnUniChar; sal_uInt16 mnReplaceChar; -} ImplReplaceCharData; +}; static ImplReplaceCharData const aImplRepCharTab[] = { @@ -372,11 +375,11 @@ sal_uInt16 ImplGetReplaceChar( sal_Unicode c ) /* ----------------------------------------------------------------------- */ -typedef struct +struct ImplReplaceCharStrData { sal_uInt16 mnUniChar; sal_uInt16 maReplaceChars[IMPL_MAX_REPLACECHAR]; -} ImplReplaceCharStrData; +}; static ImplReplaceCharStrData const aImplRepCharStrTab[] = { @@ -466,20 +469,16 @@ const sal_uInt16* ImplGetReplaceString( sal_Unicode c ) /* ======================================================================= */ -sal_Size ImplSymbolToUnicode( const ImplTextConverterData* pData, - void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, +sal_Size ImplSymbolToUnicode( const ImplTextConverterData*, + void*, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, - sal_uInt32 nFlags, sal_uInt32* pInfo, + sal_uInt32, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) { sal_uChar c; sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; - - (void) pData; /* unused */ - (void) pContext; /* unused */ - (void) nFlags; /* unused */ + const char* pEndSrcBuf; *pInfo = 0; pEndDestBuf = pDestBuf+nDestChars; @@ -509,18 +508,16 @@ sal_Size ImplSymbolToUnicode( const ImplTextConverterData* pData, /* ----------------------------------------------------------------------- */ sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, - void* pContext, + void*, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { sal_Unicode c; - sal_Char* pEndDestBuf; + char* pEndDestBuf; const sal_Unicode* pEndSrcBuf; - (void) pContext; /* unused */ - *pInfo = 0; pEndDestBuf = pDestBuf+nDestBytes; pEndSrcBuf = pSrcBuf+nSrcChars; @@ -535,7 +532,7 @@ sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, c = *pSrcBuf; if ( (c >= 0xF000) && (c <= 0xF0FF) ) { - *pDestBuf = (sal_Char)(sal_uChar)(c-0xF000); + *pDestBuf = static_cast< char >(static_cast< unsigned char >(c-0xF000)); pDestBuf++; pSrcBuf++; } @@ -544,7 +541,7 @@ sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, // these values else if ( c <= 0x00FF ) { - *pDestBuf = (sal_Char)(sal_uChar)c; + *pDestBuf = static_cast< char >(static_cast< unsigned char >(c)); pDestBuf++; pSrcBuf++; } @@ -576,8 +573,8 @@ sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, /* ======================================================================= */ sal_Size ImplCharToUnicode( const ImplTextConverterData* pData, - void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + void*, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) @@ -586,9 +583,7 @@ sal_Size ImplCharToUnicode( const ImplTextConverterData* pData, sal_Unicode cConv; const ImplByteConvertData* pConvertData = (const ImplByteConvertData*)pData; sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; - - (void) pContext; /* unused */ + const char* pEndSrcBuf; *pInfo = 0; pEndDestBuf = pDestBuf+nDestChars; @@ -642,20 +637,17 @@ sal_Size ImplCharToUnicode( const ImplTextConverterData* pData, /* ----------------------------------------------------------------------- */ sal_Size ImplUpperCharToUnicode( const ImplTextConverterData* pData, - void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + void*, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, - sal_uInt32 nFlags, sal_uInt32* pInfo, + sal_uInt32, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) { sal_uChar c; sal_Unicode cConv; const ImplByteConvertData* pConvertData = (const ImplByteConvertData*)pData; sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; - - (void) pContext; /* unused */ - (void) nFlags; /* unused */ + const char* pEndSrcBuf; *pInfo = 0; pEndDestBuf = pDestBuf+nDestChars; @@ -688,24 +680,24 @@ sal_Size ImplUpperCharToUnicode( const ImplTextConverterData* pData, // Writes 0--2 characters to dest: static int ImplConvertUnicodeCharToChar( - const ImplByteConvertData* pConvertData, sal_Unicode c, sal_Char * dest ) + const ImplByteConvertData* pConvertData, sal_Unicode c, char * dest ) { const ImplUniCharTabData* pToCharExTab; if ( c < 0x80 ) { - dest[0] = (sal_Char)c; + dest[0] = static_cast< char >(c); return 1; } if ( (c >= pConvertData->mnToCharStart1) && (c <= pConvertData->mnToCharEnd1) ) { - dest[0] = (sal_Char)pConvertData->mpToCharTab1[c-pConvertData->mnToCharStart1]; + dest[0] = static_cast< char >(pConvertData->mpToCharTab1[c-pConvertData->mnToCharStart1]); if ( dest[0] != 0 ) return 1; } else if ( (c >= pConvertData->mnToCharStart2) && (c <= pConvertData->mnToCharEnd2) ) { - dest[0] = (sal_Char)pConvertData->mpToCharTab2[c-pConvertData->mnToCharStart2]; + dest[0] = static_cast< char >(pConvertData->mpToCharTab2[c-pConvertData->mnToCharStart2]); if ( dest[0] != 0 ) return 1; } @@ -737,12 +729,12 @@ static int ImplConvertUnicodeCharToChar( nLow = nMid+1; else { - dest[0] = (sal_Char)pCharExData->mnChar; + dest[0] = static_cast< char >(pCharExData->mnChar); if ( pCharExData->mnChar2 == 0 ) return 1; else { - dest[1] = (sal_Char)pCharExData->mnChar2; + dest[1] = static_cast< char >(pCharExData->mnChar2); return 2; } } @@ -756,24 +748,22 @@ static int ImplConvertUnicodeCharToChar( /* ----------------------------------------------------------------------- */ sal_Size ImplUnicodeToChar( const ImplTextConverterData* pData, - void* pContext, + void*, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { sal_Unicode c; const ImplByteConvertData* pConvertData = (const ImplByteConvertData*)pData; - sal_Char* pEndDestBuf; + char* pEndDestBuf; const sal_Unicode* pEndSrcBuf; int i; int n; sal_uInt16 cTemp; - sal_Char aTempBuf[IMPL_MAX_REPLACECHAR+2]; + char aTempBuf[IMPL_MAX_REPLACECHAR+2]; const sal_uInt16* pReplace; - (void) pContext; /* unused */ - *pInfo = 0; pEndDestBuf = pDestBuf+nDestBytes; pEndSrcBuf = pSrcBuf+nSrcChars; @@ -782,7 +772,7 @@ sal_Size ImplUnicodeToChar( const ImplTextConverterData* pData, c = *pSrcBuf; if ( c < 0x80 ) { - aTempBuf[0] = (sal_Char)c; + aTempBuf[0] = static_cast< char >(c); n = 1; } else diff --git a/sal/textenc/tcvtmb.c b/sal/textenc/tcvtmb.cxx index e0936979eb19..fcaba0914ec2 100644 --- a/sal/textenc/tcvtmb.c +++ b/sal/textenc/tcvtmb.cxx @@ -26,10 +26,13 @@ * ************************************************************************/ -#include "tenchelp.h" -#include "unichars.h" +#include "sal/config.h" + #include "rtl/textcvt.h" +#include "tenchelp.hxx" +#include "unichars.hxx" + /* ======================================================================= */ /* DBCS to Unicode conversion routine use a lead table for the first byte, */ @@ -39,8 +42,8 @@ /* ======================================================================= */ -sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, +sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void*, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) @@ -52,9 +55,7 @@ sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void* pContext, const ImplDBCSConvertData* pConvertData = (const ImplDBCSConvertData*)pData; const ImplDBCSToUniLeadTab* pLeadTab = pConvertData->mpToUniLeadTab; sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; - - (void) pContext; /* unused */ + const char* pEndSrcBuf; *pInfo = 0; pEndDestBuf = pDestBuf+nDestChars; @@ -221,9 +222,9 @@ sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void* pContext, /* ----------------------------------------------------------------------- */ -sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, +sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void*, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { @@ -234,17 +235,15 @@ sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, const ImplUniToDBCSHighTab* pHighEntry; const ImplDBCSConvertData* pConvertData = (const ImplDBCSConvertData*)pData; const ImplUniToDBCSHighTab* pHighTab = pConvertData->mpToDBCSHighTab; - sal_Char* pEndDestBuf; + char* pEndDestBuf; const sal_Unicode* pEndSrcBuf; - sal_Bool bCheckRange = (pConvertData->mnLeadStart != 0 - || pConvertData->mnLeadEnd != 0xFF); + bool bCheckRange = + pConvertData->mnLeadStart != 0 || pConvertData->mnLeadEnd != 0xFF; /* this statement has the effect that this extra check is only done for EUC-KR, which uses the MS-949 tables, but does not support the full range of MS-949 */ - (void) pContext; /* unused */ - *pInfo = 0; pEndDestBuf = pDestBuf+nDestBytes; pEndSrcBuf = pSrcBuf+nSrcChars; @@ -319,7 +318,7 @@ sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, && c <= RTL_TEXTCVT_BYTE_PRIVATE_END) { if ( nFlags & RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ) - cConv = (sal_Char)(sal_uChar)(c & 0xFF); + cConv = static_cast< char >(static_cast< unsigned char >(c & 0xFF)); } } @@ -358,7 +357,7 @@ sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, break; } - *pDestBuf = (sal_Char)(sal_uChar)(cConv & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >(cConv & 0xFF)); pDestBuf++; } else @@ -369,9 +368,9 @@ sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, break; } - *pDestBuf = (sal_Char)(sal_uChar)((cConv >> 8) & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >((cConv >> 8) & 0xFF)); pDestBuf++; - *pDestBuf = (sal_Char)(sal_uChar)(cConv & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >(cConv & 0xFF)); pDestBuf++; } @@ -390,8 +389,8 @@ sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, /* ----------------------------------------------------------------------- */ sal_Size ImplEUCJPToUnicode( const ImplTextConverterData* pData, - void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + void*, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) @@ -404,9 +403,7 @@ sal_Size ImplEUCJPToUnicode( const ImplTextConverterData* pData, const ImplDBCSToUniLeadTab* pLeadTab; const ImplEUCJPConvertData* pConvertData = (const ImplEUCJPConvertData*)pData; sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; - - (void) pContext; /* unused */ + const char* pEndSrcBuf; *pInfo = 0; pEndDestBuf = pDestBuf+nDestChars; @@ -555,9 +552,9 @@ sal_Size ImplEUCJPToUnicode( const ImplTextConverterData* pData, /* ----------------------------------------------------------------------- */ sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, - void* pContext, + void*, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { @@ -568,11 +565,9 @@ sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, const ImplUniToDBCSHighTab* pHighEntry; const ImplUniToDBCSHighTab* pHighTab; const ImplEUCJPConvertData* pConvertData = (const ImplEUCJPConvertData*)pData; - sal_Char* pEndDestBuf; + char* pEndDestBuf; const sal_Unicode* pEndSrcBuf; - (void) pContext; /* unused */ - *pInfo = 0; pEndDestBuf = pDestBuf+nDestBytes; pEndSrcBuf = pSrcBuf+nSrcChars; @@ -652,7 +647,7 @@ sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, break; } - *pDestBuf = (sal_Char)(sal_uChar)(cConv & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >(cConv & 0xFF)); pDestBuf++; } /* DoubleByte */ @@ -664,9 +659,9 @@ sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, break; } - *pDestBuf = (sal_Char)(sal_uChar)((cConv >> 8) & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >((cConv >> 8) & 0xFF)); pDestBuf++; - *pDestBuf = (sal_Char)(sal_uChar)(cConv & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >(cConv & 0xFF)); pDestBuf++; } else @@ -677,11 +672,11 @@ sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, break; } - *pDestBuf = (sal_Char)(sal_uChar)((cConv >> 16) & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >((cConv >> 16) & 0xFF)); pDestBuf++; - *pDestBuf = (sal_Char)(sal_uChar)((cConv >> 8) & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >((cConv >> 8) & 0xFF)); pDestBuf++; - *pDestBuf = (sal_Char)(sal_uChar)(cConv & 0xFF); + *pDestBuf = static_cast< char >(static_cast< unsigned char >(cConv & 0xFF)); pDestBuf++; } diff --git a/sal/textenc/tcvtutf7.c b/sal/textenc/tcvtutf7.cxx index 8093a866f0c4..c01e20240eeb 100644 --- a/sal/textenc/tcvtutf7.c +++ b/sal/textenc/tcvtutf7.cxx @@ -26,14 +26,13 @@ * ************************************************************************/ -#include "tenchelp.h" -#include "unichars.h" +#include "sal/config.h" -#ifndef _RTL_ALLOC_H -#include "rtl/alloc.h" -#endif #include "rtl/textcvt.h" +#include "tenchelp.hxx" +#include "unichars.hxx" + /* ======================================================================= */ static sal_uChar const aImplBase64Tab[64] = @@ -101,34 +100,33 @@ static sal_uChar const aImplMustShiftTab[128] = /* ----------------------------------------------------------------------- */ -typedef struct +struct ImplUTF7ToUCContextData { int mbShifted; int mbFirst; int mbWroteOne; sal_uInt32 mnBitBuffer; sal_uInt32 mnBufferBits; -} ImplUTF7ToUCContextData; +}; /* ----------------------------------------------------------------------- */ -void* ImplUTF7CreateUTF7TextToUnicodeContext( void ) +void* ImplUTF7CreateUTF7TextToUnicodeContext() { - ImplUTF7ToUCContextData* pContextData; - pContextData = (ImplUTF7ToUCContextData*)rtl_allocateMemory( sizeof( ImplUTF7ToUCContextData ) ); + ImplUTF7ToUCContextData* pContextData = new ImplUTF7ToUCContextData; pContextData->mbShifted = sal_False; pContextData->mbFirst = sal_False; pContextData->mbWroteOne = sal_False; pContextData->mnBitBuffer = 0; pContextData->mnBufferBits = 0; - return (void*)pContextData; + return pContextData; } /* ----------------------------------------------------------------------- */ void ImplUTF7DestroyTextToUnicodeContext( void* pContext ) { - rtl_freeMemory( pContext ); + delete static_cast< ImplUTF7ToUCContextData * >(pContext); } /* ----------------------------------------------------------------------- */ @@ -145,8 +143,8 @@ void ImplUTF7ResetTextToUnicodeContext( void* pContext ) /* ----------------------------------------------------------------------- */ -sal_Size ImplUTF7ToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, +sal_Size ImplUTF7ToUnicode( const ImplTextConverterData*, void* pContext, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) @@ -163,9 +161,7 @@ sal_Size ImplUTF7ToUnicode( const ImplTextConverterData* pData, void* pContext, sal_uInt32 nBitBufferTemp; sal_uInt32 nBufferBits; sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; - - (void) pData; /* unused */ + const char* pEndSrcBuf; /* !!! Implementation not finnished !!! if ( pContextData ) @@ -403,30 +399,29 @@ sal_Size ImplUTF7ToUnicode( const ImplTextConverterData* pData, void* pContext, /* ======================================================================= */ -typedef struct +struct ImplUTF7FromUCContextData { int mbShifted; sal_uInt32 mnBitBuffer; sal_uInt32 mnBufferBits; -} ImplUTF7FromUCContextData; +}; /* ----------------------------------------------------------------------- */ -void* ImplUTF7CreateUnicodeToTextContext( void ) +void* ImplUTF7CreateUnicodeToTextContext() { - ImplUTF7FromUCContextData* pContextData; - pContextData = (ImplUTF7FromUCContextData*)rtl_allocateMemory( sizeof( ImplUTF7FromUCContextData ) ); + ImplUTF7FromUCContextData* pContextData = new ImplUTF7FromUCContextData; pContextData->mbShifted = sal_False; pContextData->mnBitBuffer = 0; pContextData->mnBufferBits = 0; - return (void*)pContextData; + return pContextData; } /* ----------------------------------------------------------------------- */ void ImplUTF7DestroyUnicodeToTextContext( void* pContext ) { - rtl_freeMemory( pContext ); + delete static_cast< ImplUTF7FromUCContextData * >(pContext); } /* ----------------------------------------------------------------------- */ @@ -441,10 +436,10 @@ void ImplUTF7ResetUnicodeToTextContext( void* pContext ) /* ----------------------------------------------------------------------- */ -sal_Size ImplUnicodeToUTF7( const ImplTextConverterData* pData, void* pContext, +sal_Size ImplUnicodeToUTF7( const ImplTextConverterData*, void* pContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, - sal_uInt32 nFlags, sal_uInt32* pInfo, + char* pDestBuf, sal_Size nDestBytes, + sal_uInt32, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { ImplUTF7FromUCContextData* pContextData = (ImplUTF7FromUCContextData*)pContext; @@ -455,12 +450,9 @@ sal_Size ImplUnicodeToUTF7( const ImplTextConverterData* pData, void* pContext, sal_uInt32 nBitBuffer; sal_uInt32 nBitBufferTemp; sal_uInt32 nBufferBits; - sal_Char* pEndDestBuf; + char* pEndDestBuf; const sal_Unicode* pEndSrcBuf; - (void) pData; /* unused */ - (void) nFlags; /* unused */ - /* !!! Implementation not finnished !!! if ( pContextData ) { @@ -568,7 +560,7 @@ sal_Size ImplUnicodeToUTF7( const ImplTextConverterData* pData, void* pContext, *pInfo |= RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL; break; } - *pDestBuf = (sal_Char)(sal_uChar)c; + *pDestBuf = static_cast< char >(static_cast< unsigned char >(c)); pDestBuf++; } diff --git a/sal/textenc/tcvtutf8.c b/sal/textenc/tcvtutf8.cxx index 3023c3e754e6..18c6c62dacce 100644 --- a/sal/textenc/tcvtutf8.c +++ b/sal/textenc/tcvtutf8.cxx @@ -26,19 +26,20 @@ * ************************************************************************/ +#include "sal/config.h" + #include "sal/types.h" -#include "rtl/alloc.h" #include "rtl/textcvt.h" -#include "converter.h" -#include "tenchelp.h" -#include "unichars.h" +#include "converter.hxx" +#include "tenchelp.hxx" +#include "unichars.hxx" struct ImplUtf8ToUnicodeContext { sal_uInt32 nUtf32; int nShift; - sal_Bool bCheckBom; + bool bCheckBom; }; struct ImplUnicodeToUtf8Context @@ -46,9 +47,9 @@ struct ImplUnicodeToUtf8Context sal_Unicode nHighSurrogate; /* 0xFFFF: write BOM */ }; -void * ImplCreateUtf8ToUnicodeContext(void) +void * ImplCreateUtf8ToUnicodeContext() { - void * p = rtl_allocateMemory(sizeof (struct ImplUtf8ToUnicodeContext)); + ImplUtf8ToUnicodeContext * p = new ImplUtf8ToUnicodeContext; ImplResetUtf8ToUnicodeContext(p); return p; } @@ -57,13 +58,13 @@ void ImplResetUtf8ToUnicodeContext(void * pContext) { if (pContext != NULL) { - ((struct ImplUtf8ToUnicodeContext *) pContext)->nShift = -1; - ((struct ImplUtf8ToUnicodeContext *) pContext)->bCheckBom = sal_True; + static_cast< ImplUtf8ToUnicodeContext * >(pContext)->nShift = -1; + static_cast< ImplUtf8ToUnicodeContext * >(pContext)->bCheckBom = true; } } sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, - void * pContext, sal_Char const * pSrcBuf, + void * pContext, char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes) @@ -81,7 +82,7 @@ sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, int bJavaUtf8 = pData != NULL; sal_uInt32 nUtf32 = 0; int nShift = -1; - sal_Bool bCheckBom = sal_True; + bool bCheckBom = true; sal_uInt32 nInfo = 0; sal_uChar const * pSrcBufPtr = (sal_uChar const *) pSrcBuf; sal_uChar const * pSrcBufEnd = pSrcBufPtr + nSrcBytes; @@ -90,15 +91,15 @@ sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, if (pContext != NULL) { - nUtf32 = ((struct ImplUtf8ToUnicodeContext *) pContext)->nUtf32; - nShift = ((struct ImplUtf8ToUnicodeContext *) pContext)->nShift; - bCheckBom = ((struct ImplUtf8ToUnicodeContext *) pContext)->bCheckBom; + nUtf32 = static_cast< ImplUtf8ToUnicodeContext * >(pContext)->nUtf32; + nShift = static_cast< ImplUtf8ToUnicodeContext * >(pContext)->nShift; + bCheckBom = static_cast< ImplUtf8ToUnicodeContext * >(pContext)->bCheckBom; } while (pSrcBufPtr < pSrcBufEnd) { - sal_Bool bUndefined = sal_False; - int bConsume = sal_True; + bool bUndefined = false; + int bConsume = true; sal_uInt32 nChar = *pSrcBufPtr++; if (nShift < 0) if (nChar <= 0x7F) @@ -176,29 +177,29 @@ sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, goto no_output; else { - bUndefined = sal_True; + bUndefined = true; goto bad_input; } } nShift = -1; - bCheckBom = sal_False; + bCheckBom = false; continue; bad_input: switch (ImplHandleBadInputTextToUnicodeConversion( - bUndefined, sal_True, 0, nFlags, &pDestBufPtr, pDestBufEnd, + bUndefined, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo)) { case IMPL_BAD_INPUT_STOP: nShift = -1; - bCheckBom = sal_False; + bCheckBom = false; if (!bConsume) --pSrcBufPtr; break; case IMPL_BAD_INPUT_CONTINUE: nShift = -1; - bCheckBom = sal_False; + bCheckBom = false; if (!bConsume) --pSrcBufPtr; continue; @@ -223,13 +224,13 @@ sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, nInfo |= RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; else switch (ImplHandleBadInputTextToUnicodeConversion( - sal_False, sal_True, 0, nFlags, &pDestBufPtr, - pDestBufEnd, &nInfo)) + false, true, 0, nFlags, &pDestBufPtr, pDestBufEnd, + &nInfo)) { case IMPL_BAD_INPUT_STOP: case IMPL_BAD_INPUT_CONTINUE: nShift = -1; - bCheckBom = sal_False; + bCheckBom = false; break; case IMPL_BAD_INPUT_NO_OUTPUT: @@ -240,20 +241,20 @@ sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, if (pContext != NULL) { - ((struct ImplUtf8ToUnicodeContext *) pContext)->nUtf32 = nUtf32; - ((struct ImplUtf8ToUnicodeContext *) pContext)->nShift = nShift; - ((struct ImplUtf8ToUnicodeContext *) pContext)->bCheckBom = bCheckBom; + static_cast< ImplUtf8ToUnicodeContext * >(pContext)->nUtf32 = nUtf32; + static_cast< ImplUtf8ToUnicodeContext * >(pContext)->nShift = nShift; + static_cast< ImplUtf8ToUnicodeContext * >(pContext)->bCheckBom = bCheckBom; } if (pInfo != NULL) *pInfo = nInfo; if (pSrcCvtBytes != NULL) - *pSrcCvtBytes = (sal_Char const *) pSrcBufPtr - pSrcBuf; + *pSrcCvtBytes = reinterpret_cast< char const * >(pSrcBufPtr) - pSrcBuf; return pDestBufPtr - pDestBuf; } -void * ImplCreateUnicodeToUtf8Context(void) +void * ImplCreateUnicodeToUtf8Context() { - void * p = rtl_allocateMemory(sizeof (struct ImplUnicodeToUtf8Context)); + ImplUnicodeToUtf8Context * p = new ImplUnicodeToUtf8Context; ImplResetUnicodeToUtf8Context(p); return p; } @@ -261,12 +262,12 @@ void * ImplCreateUnicodeToUtf8Context(void) void ImplResetUnicodeToUtf8Context(void * pContext) { if (pContext != NULL) - ((struct ImplUnicodeToUtf8Context *) pContext)->nHighSurrogate = 0xFFFF; + static_cast< ImplUnicodeToUtf8Context * >(pContext)->nHighSurrogate = 0xFFFF; } sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, - sal_Size nSrcChars, sal_Char * pDestBuf, + sal_Size nSrcChars, char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, sal_Size* pSrcCvtChars) { @@ -275,12 +276,12 @@ sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, sal_uInt32 nInfo = 0; sal_Unicode const * pSrcBufPtr = pSrcBuf; sal_Unicode const * pSrcBufEnd = pSrcBufPtr + nSrcChars; - sal_Char * pDestBufPtr = pDestBuf; - sal_Char * pDestBufEnd = pDestBufPtr + nDestBytes; + char * pDestBufPtr = pDestBuf; + char * pDestBufEnd = pDestBufPtr + nDestBytes; if (pContext != NULL) nHighSurrogate - = ((struct ImplUnicodeToUtf8Context *) pContext)->nHighSurrogate; + = static_cast< ImplUnicodeToUtf8Context * >(pContext)->nHighSurrogate; if (nHighSurrogate == 0xFFFF) { @@ -290,9 +291,9 @@ sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, if (pDestBufEnd - pDestBufPtr >= 3) { /* Write BOM (U+FEFF) as UTF-8: */ - *pDestBufPtr++ = (sal_Char) (unsigned char) 0xEF; - *pDestBufPtr++ = (sal_Char) (unsigned char) 0xBB; - *pDestBufPtr++ = (sal_Char) (unsigned char) 0xBF; + *pDestBufPtr++ = static_cast< char >(static_cast< unsigned char >(0xEF)); + *pDestBufPtr++ = static_cast< char >(static_cast< unsigned char >(0xBB)); + *pDestBufPtr++ = static_cast< char >(static_cast< unsigned char >(0xBF)); } else { @@ -325,32 +326,32 @@ sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, if (nChar <= 0x7F && (!bJavaUtf8 || nChar != 0)) if (pDestBufPtr != pDestBufEnd) - *pDestBufPtr++ = (sal_Char) nChar; + *pDestBufPtr++ = static_cast< char >(nChar); else goto no_output; else if (nChar <= 0x7FF) if (pDestBufEnd - pDestBufPtr >= 2) { - *pDestBufPtr++ = (sal_Char) (0xC0 | (nChar >> 6)); - *pDestBufPtr++ = (sal_Char) (0x80 | (nChar & 0x3F)); + *pDestBufPtr++ = static_cast< char >(0xC0 | (nChar >> 6)); + *pDestBufPtr++ = static_cast< char >(0x80 | (nChar & 0x3F)); } else goto no_output; else if (nChar <= 0xFFFF) if (pDestBufEnd - pDestBufPtr >= 3) { - *pDestBufPtr++ = (sal_Char) (0xE0 | (nChar >> 12)); - *pDestBufPtr++ = (sal_Char) (0x80 | ((nChar >> 6) & 0x3F)); - *pDestBufPtr++ = (sal_Char) (0x80 | (nChar & 0x3F)); + *pDestBufPtr++ = static_cast< char >(0xE0 | (nChar >> 12)); + *pDestBufPtr++ = static_cast< char >(0x80 | ((nChar >> 6) & 0x3F)); + *pDestBufPtr++ = static_cast< char >(0x80 | (nChar & 0x3F)); } else goto no_output; else if (pDestBufEnd - pDestBufPtr >= 4) { - *pDestBufPtr++ = (sal_Char) (0xF0 | (nChar >> 18)); - *pDestBufPtr++ = (sal_Char) (0x80 | ((nChar >> 12) & 0x3F)); - *pDestBufPtr++ = (sal_Char) (0x80 | ((nChar >> 6) & 0x3F)); - *pDestBufPtr++ = (sal_Char) (0x80 | (nChar & 0x3F)); + *pDestBufPtr++ = static_cast< char >(0xF0 | (nChar >> 18)); + *pDestBufPtr++ = static_cast< char >(0x80 | ((nChar >> 12) & 0x3F)); + *pDestBufPtr++ = static_cast< char >(0x80 | ((nChar >> 6) & 0x3F)); + *pDestBufPtr++ = static_cast< char >(0x80 | (nChar & 0x3F)); } else goto no_output; @@ -358,7 +359,7 @@ sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, continue; bad_input: - switch (ImplHandleBadInputUnicodeToTextConversion(sal_False, 0, nFlags, + switch (ImplHandleBadInputUnicodeToTextConversion(false, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo, NULL, 0, NULL)) @@ -390,8 +391,7 @@ sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, if ((nFlags & RTL_UNICODETOTEXT_FLAGS_FLUSH) != 0) nInfo |= RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; else - switch (ImplHandleBadInputUnicodeToTextConversion(sal_False, 0, - nFlags, + switch (ImplHandleBadInputUnicodeToTextConversion(false, 0, nFlags, &pDestBufPtr, pDestBufEnd, &nInfo, NULL, 0, @@ -410,7 +410,7 @@ sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, done: if (pContext != NULL) - ((struct ImplUnicodeToUtf8Context *) pContext)->nHighSurrogate + static_cast< ImplUnicodeToUtf8Context * >(pContext)->nHighSurrogate = nHighSurrogate; if (pInfo != NULL) *pInfo = nInfo; diff --git a/sal/textenc/tenchelp.c b/sal/textenc/tenchelp.cxx index ed924336fa17..ddc84dc18d70 100644 --- a/sal/textenc/tenchelp.c +++ b/sal/textenc/tenchelp.cxx @@ -26,27 +26,30 @@ * ************************************************************************/ -#include "tenchelp.h" -#include "unichars.h" +#include "sal/config.h" + #include "rtl/textcvt.h" #include "sal/types.h" -static sal_Bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, - sal_Char * pBuf, +#include "tenchelp.hxx" +#include "unichars.hxx" + +static bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, + char * pBuf, sal_Size nMaxLen); -static sal_Bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, - sal_Char * pBuf, +static bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, + char * pBuf, sal_Size nMaxLen); static int ImplIsUnicodeIgnoreChar(sal_Unicode c, sal_uInt32 nFlags); -sal_Bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, - sal_Char * pBuf, +bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, + char * pBuf, sal_Size nMaxLen) { if (nMaxLen == 0) - return sal_False; + return false; switch (nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) { case RTL_UNICODETOTEXT_FLAGS_UNDEFINED_0: @@ -62,15 +65,15 @@ sal_Bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, *pBuf = 0x5F; break; } - return sal_True; + return true; } -sal_Bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, - sal_Char * pBuf, +bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, + char * pBuf, sal_Size nMaxLen) { if (nMaxLen == 0) - return sal_False; + return false; switch (nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) { case RTL_UNICODETOTEXT_FLAGS_INVALID_0: @@ -86,7 +89,7 @@ sal_Bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, *pBuf = 0x5F; break; } - return sal_True; + return true; } int ImplIsUnicodeIgnoreChar( sal_Unicode c, sal_uInt32 nFlags ) @@ -112,28 +115,26 @@ sal_Unicode ImplGetUndefinedUnicodeChar(sal_uChar cChar, sal_uInt32 nFlags) /* ----------------------------------------------------------------------- */ -sal_Bool -ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, +bool +ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const *, sal_Unicode const ** ppSrcBuf, sal_Unicode const * pEndSrcBuf, - sal_Char ** ppDestBuf, - sal_Char const * pEndDestBuf, + char ** ppDestBuf, + char const * pEndDestBuf, sal_uInt32 nFlags, sal_uInt32 * pInfo) { sal_Unicode c = **ppSrcBuf; - (void) pData; /* unused */ - /* Should the private character map to one byte */ if ( (c >= RTL_TEXTCVT_BYTE_PRIVATE_START) && (c <= RTL_TEXTCVT_BYTE_PRIVATE_END) ) { if ( nFlags & RTL_UNICODETOTEXT_FLAGS_PRIVATE_MAPTO0 ) { - **ppDestBuf = (sal_Char)(sal_uChar)(c-RTL_TEXTCVT_BYTE_PRIVATE_START); + **ppDestBuf = (char)(sal_uChar)(c-RTL_TEXTCVT_BYTE_PRIVATE_START); (*ppDestBuf)++; (*ppSrcBuf)++; - return sal_True; + return true; } } @@ -141,7 +142,7 @@ ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, if ( ImplIsUnicodeIgnoreChar( c, nFlags ) ) { (*ppSrcBuf)++; - return sal_True; + return true; } /* Surrogates Characters should result in */ @@ -151,7 +152,7 @@ ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, if ( *ppSrcBuf == pEndSrcBuf ) { *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR | RTL_UNICODETOTEXT_INFO_SRCBUFFERTOSMALL; - return sal_False; + return false; } c = *((*ppSrcBuf)+1); @@ -163,12 +164,12 @@ ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_INVALID_MASK) == RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR ) { *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR; - return sal_False; + return false; } else if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_INVALID_MASK) == RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE ) { (*ppSrcBuf)++; - return sal_True; + return true; } else if (ImplGetInvalidAsciiMultiByte(nFlags, *ppDestBuf, @@ -176,13 +177,13 @@ ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, { ++*ppSrcBuf; ++*ppDestBuf; - return sal_True; + return true; } else { *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL; - return sal_False; + return false; } } } @@ -191,7 +192,7 @@ ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) == RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR ) { *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR; - return sal_False; + return false; } else if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) == RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE ) (*ppSrcBuf)++; @@ -206,10 +207,10 @@ ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, { *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL; - return sal_False; + return false; } - return sal_True; + return true; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/tenchelp.h b/sal/textenc/tenchelp.hxx index 7f6879c4bee1..5c069f90a7ea 100644 --- a/sal/textenc/tenchelp.h +++ b/sal/textenc/tenchelp.hxx @@ -26,17 +26,15 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_TENCHELP_H -#define INCLUDED_RTL_TEXTENC_TENCHELP_H +#ifndef INCLUDED_SAL_TEXTENC_TENCHELP_HXX +#define INCLUDED_SAL_TEXTENC_TENCHELP_HXX + +#include "sal/config.h" #include "rtl/tencinfo.h" #include "rtl/textenc.h" #include "sal/types.h" -#if defined __cplusplus -extern "C" { -#endif /* __cplusplus */ - #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100 #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF @@ -49,7 +47,7 @@ typedef void ImplTextConverterData; typedef sal_Size (* ImplConvertToUnicodeProc)(ImplTextConverterData const * pData, void * pContext, - sal_Char const * pSrcBuf, + char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, @@ -62,7 +60,7 @@ sal_Size (* ImplConvertToTextProc)(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, sal_Size nSrcChars, - sal_Char * pDestBuf, + char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32 * pInfo, @@ -80,7 +78,7 @@ typedef void (* ImplDestroyUnicodeContextProc)(void * pContext); typedef void (* ImplResetUnicodeContextProc)(void * pContext); -typedef struct +struct ImplTextConverter { ImplTextConverterData const * mpConvertData; ImplConvertToUnicodeProc mpConvertTextToUnicodeProc; @@ -91,13 +89,13 @@ typedef struct ImplCreateUnicodeContextProc mpCreateUnicodeToTextContext; ImplDestroyUnicodeContextProc mpDestroyUnicodeToTextContext; ImplResetUnicodeContextProc mpResetUnicodeToTextContext; -} ImplTextConverter; +}; /* ----------------------------- */ /* - TextEncoding - Structures - */ /* ----------------------------- */ -typedef struct +struct ImplTextEncodingData { ImplTextConverter maConverter; sal_uInt8 mnMinCharSize; @@ -107,22 +105,22 @@ typedef struct char const * mpBestUnixCharset; char const * mpBestMimeCharset; sal_uInt32 mnInfoFlags; -} ImplTextEncodingData; +}; /* ----------------------------------- */ /* - TextConverter - Byte-Structures - */ /* ----------------------------------- */ -typedef struct +struct ImplUniCharTabData { sal_uInt16 mnUniChar; sal_uChar mnChar; sal_uChar mnChar2; // to cater for mappings like MS1258 with 1--2 bytes per Unicode char, // 0 if unused -} ImplUniCharTabData; +}; -typedef struct +struct ImplByteConvertData { const sal_uInt16* mpToUniTab1; const sal_uInt16* mpToUniTab2; @@ -138,13 +136,13 @@ typedef struct sal_uInt16 mnToCharStart2; sal_uInt16 mnToCharEnd2; sal_uInt16 mnToCharExCount; -} ImplByteConvertData; +}; /* ----------------------------------- */ /* - TextConverter - DBCS-Structures - */ /* ----------------------------------- */ -typedef struct +struct ImplDBCSEUDCData { sal_uChar mnLeadStart; sal_uChar mnLeadEnd; @@ -158,24 +156,24 @@ typedef struct sal_uInt16 mnTrailRangeCount; sal_uInt16 mnUniStart; sal_uInt16 mnUniEnd; -} ImplDBCSEUDCData; +}; -typedef struct +struct ImplDBCSToUniLeadTab { sal_uInt16 mnUniChar; sal_uInt8 mnTrailStart; sal_uInt8 mnTrailEnd; const sal_uInt16* mpToUniTrailTab; -} ImplDBCSToUniLeadTab; +}; -typedef struct +struct ImplUniToDBCSHighTab { sal_uInt8 mnLowStart; sal_uInt8 mnLowEnd; const sal_uInt16* mpToUniTrailTab; -} ImplUniToDBCSHighTab; +}; -typedef struct +struct ImplDBCSConvertData { const ImplDBCSToUniLeadTab* mpToUniLeadTab; const ImplUniToDBCSHighTab* mpToDBCSHighTab; @@ -185,19 +183,19 @@ typedef struct sal_uChar mnTrailEnd; const ImplDBCSEUDCData* mpEUDCTab; sal_uInt16 mnEUDCCount; -} ImplDBCSConvertData; +}; /* ---------------------------------- */ /* - TextConverter - EUC-Structures - */ /* ---------------------------------- */ -typedef struct +struct ImplEUCJPConvertData { const ImplDBCSToUniLeadTab* mpJIS0208ToUniLeadTab; const ImplDBCSToUniLeadTab* mpJIS0212ToUniLeadTab; const ImplUniToDBCSHighTab* mpUniToJIS0208HighTab; const ImplUniToDBCSHighTab* mpUniToJIS0212HighTab; -} ImplEUCJPConvertData; +}; /* --------------------------------- */ /* - TextConverter - HelpFunctions - */ @@ -205,68 +203,68 @@ typedef struct sal_Unicode ImplGetUndefinedUnicodeChar(sal_uChar cChar, sal_uInt32 nFlags); -sal_Bool +bool ImplHandleUndefinedUnicodeToTextChar(ImplTextConverterData const * pData, sal_Unicode const ** ppSrcBuf, sal_Unicode const * pEndSrcBuf, - sal_Char ** ppDestBuf, - sal_Char const * pEndDestBuf, + char ** ppDestBuf, + char const * pEndDestBuf, sal_uInt32 nFlags, sal_uInt32 * pInfo); - /* sal_True means 'continue,' sal_False means 'break' */ + /* true means 'continue,' false means 'break' */ /* ----------------------------- */ /* - TextConverter - Functions - */ /* ----------------------------- */ sal_Size ImplSymbolToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); sal_Size ImplUnicodeToSymbol( const ImplTextConverterData* pData, void* pContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); sal_Size ImplCharToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); /** For those encodings only with unicode range of 0x80 to 0xFF. */ sal_Size ImplUpperCharToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); sal_Size ImplUnicodeToChar( const ImplTextConverterData* pData, void* pContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); sal_Size ImplDBCSToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); sal_Size ImplUnicodeToDBCS( const ImplTextConverterData* pData, void* pContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); sal_Size ImplEUCJPToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); sal_Size ImplUnicodeToEUCJP( const ImplTextConverterData* pData, void* pContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); void* ImplUTF7CreateUTF7TextToUnicodeContext( void ); void ImplUTF7DestroyTextToUnicodeContext( void* pContext ); void ImplUTF7ResetTextToUnicodeContext( void* pContext ); sal_Size ImplUTF7ToUnicode( const ImplTextConverterData* pData, void* pContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ); @@ -275,31 +273,25 @@ void ImplUTF7DestroyUnicodeToTextContext( void* pContext ); void ImplUTF7ResetUnicodeToTextContext( void* pContext ); sal_Size ImplUnicodeToUTF7( const ImplTextConverterData* pData, void* pContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ); -void * ImplCreateUtf8ToUnicodeContext(void) SAL_THROW_EXTERN_C(); -void ImplResetUtf8ToUnicodeContext(void * pContext) SAL_THROW_EXTERN_C(); +void * ImplCreateUtf8ToUnicodeContext(void); +void ImplResetUtf8ToUnicodeContext(void * pContext); sal_Size ImplConvertUtf8ToUnicode(ImplTextConverterData const * pData, - void * pContext, sal_Char const * pSrcBuf, + void * pContext, char const * pSrcBuf, sal_Size nSrcBytes, sal_Unicode * pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, - sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes) - SAL_THROW_EXTERN_C(); -void * ImplCreateUnicodeToUtf8Context(void) SAL_THROW_EXTERN_C(); -void ImplResetUnicodeToUtf8Context(void * pContext) SAL_THROW_EXTERN_C(); + sal_uInt32 * pInfo, sal_Size * pSrcCvtBytes); +void * ImplCreateUnicodeToUtf8Context(void); +void ImplResetUnicodeToUtf8Context(void * pContext); sal_Size ImplConvertUnicodeToUtf8(ImplTextConverterData const * pData, void * pContext, sal_Unicode const * pSrcBuf, - sal_Size nSrcChars, sal_Char * pDestBuf, + sal_Size nSrcChars, char * pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, - sal_uInt32 * pInfo, sal_Size* pSrcCvtChars) - SAL_THROW_EXTERN_C(); - -#if defined __cplusplus -} -#endif /* __cplusplus */ + sal_uInt32 * pInfo, sal_Size* pSrcCvtChars); -#endif /* INCLUDED_RTL_TEXTENC_TENCHELP_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/tencinfo.c b/sal/textenc/tencinfo.cxx index 2731880c66d2..d82a3625cf45 100644 --- a/sal/textenc/tencinfo.c +++ b/sal/textenc/tencinfo.cxx @@ -26,35 +26,27 @@ * ************************************************************************/ +#include "sal/config.h" + +#include <cstddef> +#include <cstring> + #include "rtl/tencinfo.h" -#include "gettextencodingdata.h" -#include "tenchelp.h" - -#ifndef _RTL_ALLOC_H -#include "rtl/alloc.h" -#endif - -#ifndef INCLUDED_STDDEF_H -#include <stddef.h> -#define INCLUDED_STDDEF_H -#endif -#ifndef INCLUDED_STRING_H -#include <string.h> -#define INCLUDED_STRING_H -#endif + +#include "gettextencodingdata.hxx" +#include "tenchelp.hxx" sal_Bool SAL_CALL rtl_isOctetTextEncoding(rtl_TextEncoding nEncoding) { - return (sal_Bool) - (nEncoding > RTL_TEXTENCODING_DONTKNOW - && (nEncoding <= RTL_TEXTENCODING_ADOBE_DINGBATS) - /* always update this! */ - && nEncoding != 9); /* RTL_TEXTENCODING_SYSTEM */ + return + nEncoding > RTL_TEXTENCODING_DONTKNOW + && nEncoding != 9 // RTL_TEXTENCODING_SYSTEM + && nEncoding <= RTL_TEXTENCODING_ADOBE_DINGBATS; // always update this! } /* ======================================================================= */ -static void Impl_toAsciiLower( const sal_Char* pName, sal_Char* pBuf ) +static void Impl_toAsciiLower( const char* pName, char* pBuf ) { while ( *pName ) { @@ -73,7 +65,7 @@ static void Impl_toAsciiLower( const sal_Char* pName, sal_Char* pBuf ) /* ----------------------------------------------------------------------- */ -static void Impl_toAsciiLowerAndRemoveNonAlphanumeric( const sal_Char* pName, sal_Char* pBuf ) +static void Impl_toAsciiLowerAndRemoveNonAlphanumeric( const char* pName, char* pBuf ) { while ( *pName ) { @@ -100,35 +92,35 @@ static void Impl_toAsciiLowerAndRemoveNonAlphanumeric( const sal_Char* pName, sa /* ----------------------------------------------------------------------- */ /* pMatchStr must match with all characters in pCompStr */ -static sal_Bool Impl_matchString( const sal_Char* pCompStr, const sal_Char* pMatchStr ) +static bool Impl_matchString( const char* pCompStr, const char* pMatchStr ) { /* We test only for end in MatchStr, because the last 0 character from */ /* pCompStr is unequal a character in MatchStr, so the loop terminates */ while ( *pMatchStr ) { if ( *pCompStr != *pMatchStr ) - return sal_False; + return false; pCompStr++; pMatchStr++; } - return sal_True; + return true; } /* ======================================================================= */ -typedef struct +struct ImplStrCharsetDef { - const sal_Char* mpCharsetStr; + const char* mpCharsetStr; rtl_TextEncoding meTextEncoding; -} ImplStrCharsetDef; +}; -typedef struct +struct ImplStrFirstPartCharsetDef { - const sal_Char* mpCharsetStr; + const char* mpCharsetStr; const ImplStrCharsetDef* mpSecondPartTab; -} ImplStrFirstPartCharsetDef; +}; /* ======================================================================= */ @@ -142,41 +134,41 @@ sal_Bool SAL_CALL rtl_getTextEncodingInfo( rtl_TextEncoding eTextEncoding, rtl_T /* HACK: For not implemented encoding, because not all calls handle the errors */ if ( pEncInfo->StructSize < 5 ) - return sal_False; + return false; pEncInfo->MinimumCharSize = 1; if ( pEncInfo->StructSize < 6 ) - return sal_True; + return true; pEncInfo->MaximumCharSize = 1; if ( pEncInfo->StructSize < 7 ) - return sal_True; + return true; pEncInfo->AverageCharSize = 1; if ( pEncInfo->StructSize < 12 ) - return sal_True; + return true; pEncInfo->Flags = 0; - return sal_False; + return false; } if ( pEncInfo->StructSize < 5 ) - return sal_False; + return false; pEncInfo->MinimumCharSize = pData->mnMinCharSize; if ( pEncInfo->StructSize < 6 ) - return sal_True; + return true; pEncInfo->MaximumCharSize = pData->mnMaxCharSize; if ( pEncInfo->StructSize < 7 ) - return sal_True; + return true; pEncInfo->AverageCharSize = pData->mnAveCharSize; if ( pEncInfo->StructSize < 12 ) - return sal_True; + return true; pEncInfo->Flags = pData->mnInfoFlags; - return sal_True; + return true; } /* ======================================================================= */ @@ -213,7 +205,7 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromWindowsCharset( sal_uInt8 nWinC /* ----------------------------------------------------------------------- */ -rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pUnixCharset ) +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const char* pUnixCharset ) { /* See <ftp://ftp.x.org/pub/DOCS/registry>, section 14 ("Font Charset * (Registry and Encoding) Names"). @@ -424,14 +416,14 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pU }; rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW; - sal_Char* pBuf; - sal_Char* pTempBuf; + char* pBuf; + char* pTempBuf; sal_uInt32 nBufLen = strlen( pUnixCharset )+1; - const sal_Char* pFirstPart; - const sal_Char* pSecondPart; + const char* pFirstPart; + const char* pSecondPart; /* Alloc Buffer and map to lower case */ - pBuf = (char*)rtl_allocateMemory( nBufLen ); + pBuf = new char[nBufLen]; Impl_toAsciiLower( pUnixCharset, pBuf ); /* Search FirstPart */ @@ -481,14 +473,14 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const sal_Char* pU } } - rtl_freeMemory( pBuf ); + delete[] pBuf; return eEncoding; } /* ----------------------------------------------------------------------- */ -rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pMimeCharset ) +rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeCharset ) { /* All Identifiers are in lower case and contain only alphanumeric */ /* characters. The function search for the first equal string in */ @@ -758,12 +750,12 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pM }; rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW; - sal_Char* pBuf; + char* pBuf; const ImplStrCharsetDef* pData = aVIPMimeCharsetTab; sal_uInt32 nBufLen = strlen( pMimeCharset )+1; /* Alloc Buffer and map to lower case and remove non alphanumeric chars */ - pBuf = (char*)rtl_allocateMemory( nBufLen ); + pBuf = new char[nBufLen]; Impl_toAsciiLowerAndRemoveNonAlphanumeric( pMimeCharset, pBuf ); /* Search for equal in the VIP table */ @@ -794,7 +786,7 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const sal_Char* pM } } - rtl_freeMemory( pBuf ); + delete[] pBuf; return eEncoding; } @@ -812,13 +804,13 @@ sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding e /* ----------------------------------------------------------------------- */ -const sal_Char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) +const char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) { const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding ); if ( pData ) - return (sal_Char const *) pData->mpBestUnixCharset; + return (char const *) pData->mpBestUnixCharset; else if( eTextEncoding == RTL_TEXTENCODING_UNICODE ) - return (sal_Char const *) "iso10646-1"; + return (char const *) "iso10646-1"; else return 0; } @@ -833,11 +825,11 @@ char const * SAL_CALL rtl_getMimeCharsetFromTextEncoding(rtl_TextEncoding p->mpBestMimeCharset : NULL; } -const sal_Char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) +const char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eTextEncoding ) { const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding ); if ( pData ) - return (sal_Char const *) pData->mpBestMimeCharset; + return (char const *) pData->mpBestMimeCharset; else return 0; } diff --git a/sal/textenc/textcvt.c b/sal/textenc/textcvt.cxx index 0030590cf926..e6f6470305fd 100644 --- a/sal/textenc/textcvt.c +++ b/sal/textenc/textcvt.cxx @@ -26,19 +26,22 @@ * ************************************************************************/ +#include "sal/config.h" + #include "rtl/textcvt.h" -#include "gettextencodingdata.h" -#include "tenchelp.h" + +#include "gettextencodingdata.hxx" +#include "tenchelp.hxx" /* ======================================================================= */ -static sal_Size ImplDummyToUnicode( const sal_Char* pSrcBuf, sal_Size nSrcBytes, +static sal_Size ImplDummyToUnicode( const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) { sal_Unicode* pEndDestBuf; - const sal_Char* pEndSrcBuf; + const char* pEndSrcBuf; if ( ((nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR) || ((nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR) ) @@ -72,11 +75,11 @@ static sal_Size ImplDummyToUnicode( const sal_Char* pSrcBuf, sal_Size nSrcBytes, /* ----------------------------------------------------------------------- */ static sal_Size ImplUnicodeToDummy( const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { - sal_Char* pEndDestBuf; + char* pEndDestBuf; const sal_Unicode* pEndSrcBuf; if ( ((nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) == RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR) ) @@ -97,7 +100,7 @@ static sal_Size ImplUnicodeToDummy( const sal_Unicode* pSrcBuf, sal_Size nSrcCha break; } - *pDestBuf = (sal_Char)(sal_uChar)(*pSrcBuf & 0x00FF); + *pDestBuf = (char)(sal_uChar)(*pSrcBuf & 0x00FF); pDestBuf++; pSrcBuf++; } @@ -119,10 +122,8 @@ rtl_TextToUnicodeConverter SAL_CALL rtl_createTextToUnicodeConverter( rtl_TextEn /* ----------------------------------------------------------------------- */ -void SAL_CALL rtl_destroyTextToUnicodeConverter( rtl_TextToUnicodeConverter hContext ) -{ - (void) hContext; /* unused */ -} +void SAL_CALL rtl_destroyTextToUnicodeConverter( rtl_TextToUnicodeConverter ) +{} /* ----------------------------------------------------------------------- */ @@ -144,7 +145,7 @@ void SAL_CALL rtl_destroyTextToUnicodeContext( rtl_TextToUnicodeConverter hConve { const ImplTextConverter* pConverter = (const ImplTextConverter*)hConverter; if ( pConverter && hContext && pConverter->mpDestroyTextToUnicodeContext ) - pConverter->mpDestroyTextToUnicodeContext( (void*)hContext ); + pConverter->mpDestroyTextToUnicodeContext( hContext ); } /* ----------------------------------------------------------------------- */ @@ -154,14 +155,14 @@ void SAL_CALL rtl_resetTextToUnicodeContext( rtl_TextToUnicodeConverter hConvert { const ImplTextConverter* pConverter = (const ImplTextConverter*)hConverter; if ( pConverter && hContext && pConverter->mpResetTextToUnicodeContext ) - pConverter->mpResetTextToUnicodeContext( (void*)hContext ); + pConverter->mpResetTextToUnicodeContext( hContext ); } /* ----------------------------------------------------------------------- */ sal_Size SAL_CALL rtl_convertTextToUnicode( rtl_TextToUnicodeConverter hConverter, rtl_TextToUnicodeContext hContext, - const sal_Char* pSrcBuf, sal_Size nSrcBytes, + const char* pSrcBuf, sal_Size nSrcBytes, sal_Unicode* pDestBuf, sal_Size nDestChars, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtBytes ) @@ -178,7 +179,7 @@ sal_Size SAL_CALL rtl_convertTextToUnicode( rtl_TextToUnicodeConverter hConverte } return pConverter->mpConvertTextToUnicodeProc( pConverter->mpConvertData, - (void*)hContext, + hContext, pSrcBuf, nSrcBytes, pDestBuf, nDestChars, nFlags, pInfo, @@ -198,10 +199,8 @@ rtl_UnicodeToTextConverter SAL_CALL rtl_createUnicodeToTextConverter( rtl_TextEn /* ----------------------------------------------------------------------- */ -void SAL_CALL rtl_destroyUnicodeToTextConverter( rtl_UnicodeToTextConverter hConverter ) -{ - (void) hConverter; /* unused */ -} +void SAL_CALL rtl_destroyUnicodeToTextConverter( rtl_UnicodeToTextConverter ) +{} /* ----------------------------------------------------------------------- */ @@ -223,7 +222,7 @@ void SAL_CALL rtl_destroyUnicodeToTextContext( rtl_UnicodeToTextConverter hConve { const ImplTextConverter* pConverter = (const ImplTextConverter*)hConverter; if ( pConverter && hContext && pConverter->mpDestroyUnicodeToTextContext ) - pConverter->mpDestroyUnicodeToTextContext( (void*)hContext ); + pConverter->mpDestroyUnicodeToTextContext( hContext ); } /* ----------------------------------------------------------------------- */ @@ -233,7 +232,7 @@ void SAL_CALL rtl_resetUnicodeToTextContext( rtl_UnicodeToTextConverter hConvert { const ImplTextConverter* pConverter = (const ImplTextConverter*)hConverter; if ( pConverter && hContext && pConverter->mpResetUnicodeToTextContext ) - pConverter->mpResetUnicodeToTextContext( (void*)hContext ); + pConverter->mpResetUnicodeToTextContext( hContext ); } /* ----------------------------------------------------------------------- */ @@ -241,7 +240,7 @@ void SAL_CALL rtl_resetUnicodeToTextContext( rtl_UnicodeToTextConverter hConvert sal_Size SAL_CALL rtl_convertUnicodeToText( rtl_UnicodeToTextConverter hConverter, rtl_UnicodeToTextContext hContext, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, - sal_Char* pDestBuf, sal_Size nDestBytes, + char* pDestBuf, sal_Size nDestBytes, sal_uInt32 nFlags, sal_uInt32* pInfo, sal_Size* pSrcCvtChars ) { @@ -257,7 +256,7 @@ sal_Size SAL_CALL rtl_convertUnicodeToText( rtl_UnicodeToTextConverter hConverte } return pConverter->mpConvertUnicodeToTextProc( pConverter->mpConvertData, - (void*)hContext, + hContext, pSrcBuf, nSrcChars, pDestBuf, nDestBytes, nFlags, pInfo, diff --git a/sal/textenc/textenc.cxx b/sal/textenc/textenc.cxx index 05550a505365..cc226100e58e 100644 --- a/sal/textenc/textenc.cxx +++ b/sal/textenc/textenc.cxx @@ -26,26 +26,28 @@ * ************************************************************************/ +/* TODO! This file should not be called textenc.c, because it is not the + implementation of rtl/textenc.h. Rather, it should be called + gettextencodingdata.c. */ + #include "sal/config.h" #include <cstdlib> -/* TODO! This file should not be called textenc.c, because it is not the - implementation of rtl/textenc.h. Rather, it should be called - gettextencodingdata.c. */ -#include "context.h" -#include "gettextencodingdata.h" -#include "tenchelp.h" -#include "rtl/textenc.h" -#include <sal/macros.h> #include "boost/noncopyable.hpp" #include "osl/diagnose.h" #include "osl/module.hxx" #include "rtl/instance.hxx" +#include "rtl/textenc.h" #include "rtl/ustring.h" #include "rtl/ustring.hxx" +#include "sal/macros.h" #include "sal/types.h" +#include "context.hxx" +#include "gettextencodingdata.hxx" +#include "tenchelp.hxx" + #ifndef INCLUDED_STDDEF_H #include <stddef.h> #define INCLUDED_STDDEF_H @@ -421,7 +423,7 @@ struct FullTextEncodingDataSingleton: } ImplTextEncodingData const * -Impl_getTextEncodingData(rtl_TextEncoding nEncoding) SAL_THROW_EXTERN_C() +Impl_getTextEncodingData(rtl_TextEncoding nEncoding) { switch(nEncoding) { diff --git a/sal/textenc/unichars.c b/sal/textenc/unichars.c deleted file mode 100644 index 0d4131699732..000000000000 --- a/sal/textenc/unichars.c +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "unichars.h" -#include "osl/diagnose.h" -#include "sal/types.h" - -int ImplIsNoncharacter(sal_uInt32 nUtf32) -{ - /* All code points that are noncharacters, as of Unicode 3.1.1. */ - return (nUtf32 >= 0xFDD0 && nUtf32 <= 0xFDEF) - || (nUtf32 & 0xFFFF) >= 0xFFFE - || nUtf32 > 0x10FFFF; -} - -int ImplIsControlOrFormat(sal_uInt32 nUtf32) -{ - /* All code points of <http://www.unicode.org/Public/UNIDATA/ - UnicodeData.txt>, Version 3.1.1, that have a General Category of Cc - (Other, Control) or Cf (Other, Format). - */ - return nUtf32 <= 0x001F - || (nUtf32 >= 0x007F && nUtf32 <= 0x009F) - || nUtf32 == 0x070F /* SYRIAC ABBREVIATION MARK */ - || nUtf32 == 0x180B /* MONGOLIAN FREE VARIATION SELECTOR ONE */ - || nUtf32 == 0x180C /* MONGOLIAN FREE VARIATION SELECTOR TWO */ - || nUtf32 == 0x180D /* MONGOLIAN FREE VARIATION SELECTOR THREE */ - || nUtf32 == 0x180E /* MONGOLIAN VOWEL SEPARATOR */ - || nUtf32 == 0x200C /* ZERO WIDTH NON-JOINER */ - || nUtf32 == 0x200D /* ZERO WIDTH JOINER */ - || nUtf32 == 0x200E /* LEFT-TO-RIGHT MARK */ - || nUtf32 == 0x200F /* RIGHT-TO-LEFT MARK */ - || nUtf32 == 0x202A /* LEFT-TO-RIGHT EMBEDDING */ - || nUtf32 == 0x202B /* RIGHT-TO-LEFT EMBEDDING */ - || nUtf32 == 0x202C /* POP DIRECTIONAL FORMATTING */ - || nUtf32 == 0x202D /* LEFT-TO-RIGHT OVERRIDE */ - || nUtf32 == 0x202E /* RIGHT-TO-LEFT OVERRIDE */ - || nUtf32 == 0x206A /* INHIBIT SYMMETRIC SWAPPING */ - || nUtf32 == 0x206B /* ACTIVATE SYMMETRIC SWAPPING */ - || nUtf32 == 0x206C /* INHIBIT ARABIC FORM SHAPING */ - || nUtf32 == 0x206D /* ACTIVATE ARABIC FORM SHAPING */ - || nUtf32 == 0x206E /* NATIONAL DIGIT SHAPES */ - || nUtf32 == 0x206F /* NOMINAL DIGIT SHAPES */ - || nUtf32 == 0xFEFF /* ZERO WIDTH NO-BREAK SPACE */ - || nUtf32 == 0xFFF9 /* INTERLINEAR ANNOTATION ANCHOR */ - || nUtf32 == 0xFFFA /* INTERLINEAR ANNOTATION SEPARATOR */ - || nUtf32 == 0xFFFB /* INTERLINEAR ANNOTATION TERMINATOR */ - || nUtf32 == 0x1D173 /* MUSICAL SYMBOL BEGIN BEAM */ - || nUtf32 == 0x1D174 /* MUSICAL SYMBOL END BEAM */ - || nUtf32 == 0x1D175 /* MUSICAL SYMBOL BEGIN TIE */ - || nUtf32 == 0x1D176 /* MUSICAL SYMBOL END TIE */ - || nUtf32 == 0x1D177 /* MUSICAL SYMBOL BEGIN SLUR */ - || nUtf32 == 0x1D178 /* MUSICAL SYMBOL END SLUR */ - || nUtf32 == 0x1D179 /* MUSICAL SYMBOL BEGIN PHRASE */ - || nUtf32 == 0x1D17A /* MUSICAL SYMBOL END PHRASE */ - || nUtf32 == 0xE0001 /* LANGUAGE TAG */ - || (nUtf32 >= 0xE0020 && nUtf32 <= 0xE007F); -} - -int ImplIsHighSurrogate(sal_uInt32 nUtf32) -{ - /* All code points that are high-surrogates, as of Unicode 3.1.1. */ - return nUtf32 >= 0xD800 && nUtf32 <= 0xDBFF; -} - -int ImplIsLowSurrogate(sal_uInt32 nUtf32) -{ - /* All code points that are low-surrogates, as of Unicode 3.1.1. */ - return nUtf32 >= 0xDC00 && nUtf32 <= 0xDFFF; -} - -int ImplIsPrivateUse(sal_uInt32 nUtf32) -{ - /* All code points of <http://www.unicode.org/Public/UNIDATA/ - UnicodeData.txt>, Version 3.1.1, that have a General Category of Co - (Other, Private Use). - */ - return (nUtf32 >= 0xE000 && nUtf32 <= 0xF8FF) - || (nUtf32 >= 0xF0000 && nUtf32 <= 0xFFFFD) - || (nUtf32 >= 0x100000 && nUtf32 <= 0x10FFFD); -} - -int ImplIsZeroWidth(sal_uInt32 nUtf32) -{ - /* All code points of <http://www.unicode.org/Public/UNIDATA/ - UnicodeData.txt>, Version 3.1.1, that have "ZERO WIDTH" in their - Character name. - */ - return nUtf32 == 0x200B /* ZERO WIDTH SPACE */ - || nUtf32 == 0x200C /* ZERO WIDTH NON-JOINER */ - || nUtf32 == 0x200D /* ZERO WIDTH JOINER */ - || nUtf32 == 0xFEFF; /* ZEOR WIDTH NO-BREAK SPACE */ -} - -sal_uInt32 ImplGetHighSurrogate(sal_uInt32 nUtf32) -{ - OSL_ENSURE(nUtf32 >= 0x10000, "specification violation"); - return ((nUtf32 - 0x10000) >> 10) | 0xD800; -} - -sal_uInt32 ImplGetLowSurrogate(sal_uInt32 nUtf32) -{ - OSL_ENSURE(nUtf32 >= 0x10000, "specification violation"); - return ((nUtf32 - 0x10000) & 0x3FF) | 0xDC00; -} - -sal_uInt32 ImplCombineSurrogates(sal_uInt32 nHigh, sal_uInt32 nLow) -{ - OSL_ENSURE(ImplIsHighSurrogate(nHigh) && ImplIsLowSurrogate(nLow), - "specification violation"); - return (((nHigh & 0x3FF) << 10) | (nLow & 0x3FF)) + 0x10000; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/unichars.cxx b/sal/textenc/unichars.cxx new file mode 100644 index 000000000000..1291fff8b8c0 --- /dev/null +++ b/sal/textenc/unichars.cxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "sal/config.h" + +#include <cassert> + +#include "sal/types.h" + +#include "unichars.hxx" + +bool ImplIsNoncharacter(sal_uInt32 nUtf32) +{ + // All code points that are noncharacters, as of Unicode 3.1.1: + return (nUtf32 >= 0xFDD0 && nUtf32 <= 0xFDEF) + || (nUtf32 & 0xFFFF) >= 0xFFFE + || nUtf32 > 0x10FFFF; +} + +bool ImplIsControlOrFormat(sal_uInt32 nUtf32) +{ + // All code points of + // <http://www.unicode.org/Public/UNIDATA/UnicodeData.txt>, Version 3.1.1, + // that have a General Category of Cc (Other, Control) or Cf (Other, + // Format): + return nUtf32 <= 0x001F + || (nUtf32 >= 0x007F && nUtf32 <= 0x009F) + || nUtf32 == 0x070F // SYRIAC ABBREVIATION MARK + || nUtf32 == 0x180B // MONGOLIAN FREE VARIATION SELECTOR ONE + || nUtf32 == 0x180C // MONGOLIAN FREE VARIATION SELECTOR TWO + || nUtf32 == 0x180D // MONGOLIAN FREE VARIATION SELECTOR THREE + || nUtf32 == 0x180E // MONGOLIAN VOWEL SEPARATOR + || nUtf32 == 0x200C // ZERO WIDTH NON-JOINER + || nUtf32 == 0x200D // ZERO WIDTH JOINER + || nUtf32 == 0x200E // LEFT-TO-RIGHT MARK + || nUtf32 == 0x200F // RIGHT-TO-LEFT MARK + || nUtf32 == 0x202A // LEFT-TO-RIGHT EMBEDDING + || nUtf32 == 0x202B // RIGHT-TO-LEFT EMBEDDING + || nUtf32 == 0x202C // POP DIRECTIONAL FORMATTING + || nUtf32 == 0x202D // LEFT-TO-RIGHT OVERRIDE + || nUtf32 == 0x202E // RIGHT-TO-LEFT OVERRIDE + || nUtf32 == 0x206A // INHIBIT SYMMETRIC SWAPPING + || nUtf32 == 0x206B // ACTIVATE SYMMETRIC SWAPPING + || nUtf32 == 0x206C // INHIBIT ARABIC FORM SHAPING + || nUtf32 == 0x206D // ACTIVATE ARABIC FORM SHAPING + || nUtf32 == 0x206E // NATIONAL DIGIT SHAPES + || nUtf32 == 0x206F // NOMINAL DIGIT SHAPES + || nUtf32 == 0xFEFF // ZERO WIDTH NO-BREAK SPACE + || nUtf32 == 0xFFF9 // INTERLINEAR ANNOTATION ANCHOR + || nUtf32 == 0xFFFA // INTERLINEAR ANNOTATION SEPARATOR + || nUtf32 == 0xFFFB // INTERLINEAR ANNOTATION TERMINATOR + || nUtf32 == 0x1D173 // MUSICAL SYMBOL BEGIN BEAM + || nUtf32 == 0x1D174 // MUSICAL SYMBOL END BEAM + || nUtf32 == 0x1D175 // MUSICAL SYMBOL BEGIN TIE + || nUtf32 == 0x1D176 // MUSICAL SYMBOL END TIE + || nUtf32 == 0x1D177 // MUSICAL SYMBOL BEGIN SLUR + || nUtf32 == 0x1D178 // MUSICAL SYMBOL END SLUR + || nUtf32 == 0x1D179 // MUSICAL SYMBOL BEGIN PHRASE + || nUtf32 == 0x1D17A // MUSICAL SYMBOL END PHRASE + || nUtf32 == 0xE0001 // LANGUAGE TAG + || (nUtf32 >= 0xE0020 && nUtf32 <= 0xE007F); +} + +bool ImplIsHighSurrogate(sal_uInt32 nUtf32) +{ + // All code points that are high-surrogates, as of Unicode 3.1.1. + return nUtf32 >= 0xD800 && nUtf32 <= 0xDBFF; +} + +bool ImplIsLowSurrogate(sal_uInt32 nUtf32) +{ + // All code points that are low-surrogates, as of Unicode 3.1.1. + return nUtf32 >= 0xDC00 && nUtf32 <= 0xDFFF; +} + +bool ImplIsPrivateUse(sal_uInt32 nUtf32) +{ + // All code points of + // <http://www.unicode.org/Public/UNIDATA/UnicodeData.txt>, Version 3.1.1, + // that have a General Category of Co (Other, Private Use): + return (nUtf32 >= 0xE000 && nUtf32 <= 0xF8FF) + || (nUtf32 >= 0xF0000 && nUtf32 <= 0xFFFFD) + || (nUtf32 >= 0x100000 && nUtf32 <= 0x10FFFD); +} + +bool ImplIsZeroWidth(sal_uInt32 nUtf32) +{ + // All code points of + // <http://www.unicode.org/Public/UNIDATA/UnicodeData.txt>, Version 3.1.1, + // that have "ZERO WIDTH" in their Character name: + return nUtf32 == 0x200B // ZERO WIDTH SPACE + || nUtf32 == 0x200C // ZERO WIDTH NON-JOINER + || nUtf32 == 0x200D // ZERO WIDTH JOINER + || nUtf32 == 0xFEFF; // ZEOR WIDTH NO-BREAK SPACE +} + +sal_uInt32 ImplGetHighSurrogate(sal_uInt32 nUtf32) +{ + assert(nUtf32 >= 0x10000); + return ((nUtf32 - 0x10000) >> 10) | 0xD800; +} + +sal_uInt32 ImplGetLowSurrogate(sal_uInt32 nUtf32) +{ + assert(nUtf32 >= 0x10000); + return ((nUtf32 - 0x10000) & 0x3FF) | 0xDC00; +} + +sal_uInt32 ImplCombineSurrogates(sal_uInt32 nHigh, sal_uInt32 nLow) +{ + assert(ImplIsHighSurrogate(nHigh) && ImplIsLowSurrogate(nLow)); + return (((nHigh & 0x3FF) << 10) | (nLow & 0x3FF)) + 0x10000; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/unichars.h b/sal/textenc/unichars.hxx index f1e18460dfb0..b068fff8e15e 100644 --- a/sal/textenc/unichars.h +++ b/sal/textenc/unichars.hxx @@ -26,40 +26,33 @@ * ************************************************************************/ -#ifndef INCLUDED_RTL_TEXTENC_UNICHARS_H -#define INCLUDED_RTL_TEXTENC_UNICHARS_H +#ifndef INCLUDED_SAL_TEXTENC_UNICHARS_HXX +#define INCLUDED_SAL_TEXTENC_UNICHARS_HXX -#include "sal/types.h" +#include "sal/config.h" -#if defined __cplusplus -extern "C" { -#endif /* __cpluscplus */ +#include "sal/types.h" #define RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER 0xFFFD -int ImplIsNoncharacter(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); - -int ImplIsControlOrFormat(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +bool ImplIsNoncharacter(sal_uInt32 nUtf32); -int ImplIsHighSurrogate(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +bool ImplIsControlOrFormat(sal_uInt32 nUtf32); -int ImplIsLowSurrogate(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +bool ImplIsHighSurrogate(sal_uInt32 nUtf32); -int ImplIsPrivateUse(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +bool ImplIsLowSurrogate(sal_uInt32 nUtf32); -int ImplIsZeroWidth(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +bool ImplIsPrivateUse(sal_uInt32 nUtf32); -sal_uInt32 ImplGetHighSurrogate(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +bool ImplIsZeroWidth(sal_uInt32 nUtf32); -sal_uInt32 ImplGetLowSurrogate(sal_uInt32 nUtf32) SAL_THROW_EXTERN_C(); +sal_uInt32 ImplGetHighSurrogate(sal_uInt32 nUtf32); -sal_uInt32 ImplCombineSurrogates(sal_uInt32 nHigh, sal_uInt32 nLow) - SAL_THROW_EXTERN_C(); +sal_uInt32 ImplGetLowSurrogate(sal_uInt32 nUtf32); -#if defined __cplusplus -} -#endif /* __cpluscplus */ +sal_uInt32 ImplCombineSurrogates(sal_uInt32 nHigh, sal_uInt32 nLow); -#endif /* INCLUDED_RTL_TEXTENC_UNICHARS_H */ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |