diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-06 15:00:19 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-06 15:00:44 +0100 |
commit | 01690f571db071781a2358bcc15581a6fa9dd86c (patch) | |
tree | a6dd6ea602512e4d7be1abb0e78b6d218de585b0 /sal/textenc | |
parent | 353bed10cf7d41881654b82b0a833da8dff36a69 (diff) |
Final disentanglement between sal and sal_textenc.
Diffstat (limited to 'sal/textenc')
-rw-r--r-- | sal/textenc/convertsimple.cxx | 11 | ||||
-rw-r--r-- | sal/textenc/handleundefinedunicodetotextchar.cxx (renamed from sal/textenc/tenchelp.cxx) | 97 | ||||
-rw-r--r-- | sal/textenc/handleundefinedunicodetotextchar.hxx | 50 | ||||
-rw-r--r-- | sal/textenc/tcvtbyte.cxx | 13 | ||||
-rw-r--r-- | sal/textenc/tcvtmb.cxx | 21 | ||||
-rw-r--r-- | sal/textenc/tenchelp.hxx | 22 | ||||
-rw-r--r-- | sal/textenc/unichars.cxx | 40 | ||||
-rw-r--r-- | sal/textenc/unichars.hxx | 36 |
8 files changed, 144 insertions, 146 deletions
diff --git a/sal/textenc/convertsimple.cxx b/sal/textenc/convertsimple.cxx index 24a4ad6b7662..939aaa3e18d2 100644 --- a/sal/textenc/convertsimple.cxx +++ b/sal/textenc/convertsimple.cxx @@ -33,6 +33,7 @@ #include "sal/types.h" #include "convertsimple.hxx" +#include "handleundefinedunicodetotextchar.hxx" #include "tenchelp.hxx" #define IMPL_MAX_REPLACECHAR 5 @@ -657,13 +658,9 @@ sal_Size sal::detail::textenc::convertUnicodeToChar( /* (all surrogates characters are undefined) */ if ( n == 0 ) { - if (ImplHandleUndefinedUnicodeToTextChar(pData, - &pSrcBuf, - pEndSrcBuf, - &pDestBuf, - pEndDestBuf, - nFlags, - pInfo)) + if (sal::detail::textenc::handleUndefinedUnicodeToTextChar( + &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf, + nFlags, pInfo)) continue; else break; diff --git a/sal/textenc/tenchelp.cxx b/sal/textenc/handleundefinedunicodetotextchar.cxx index c76d03db658f..cebe302d3e5f 100644 --- a/sal/textenc/tenchelp.cxx +++ b/sal/textenc/handleundefinedunicodetotextchar.cxx @@ -1,48 +1,52 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * - * OpenOffice.org - a multi-platform office productivity suite + * Major Contributor(s): + * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> + * (initial developer) ] * - * This file is part of OpenOffice.org. + * All Rights Reserved. * - * 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. + * For minor contributions see the git repository. * - * 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. - * - ************************************************************************/ + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ #include "sal/config.h" #include "rtl/textcvt.h" #include "sal/types.h" +#include "handleundefinedunicodetotextchar.hxx" #include "tenchelp.hxx" -#include "unichars.hxx" -static bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, - char * pBuf, - sal_Size nMaxLen); +namespace { -static bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, - char * pBuf, - sal_Size nMaxLen); - -static int ImplIsUnicodeIgnoreChar(sal_Unicode c, sal_uInt32 nFlags); +bool ImplIsUnicodeIgnoreChar(sal_Unicode c, sal_uInt32 nFlags) +{ + return + ((nFlags & RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE) != 0 + && ImplIsZeroWidth(c)) + || ((nFlags & RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE) != 0 + && ImplIsControlOrFormat(c)) + || ((nFlags & RTL_UNICODETOTEXT_FLAGS_PRIVATE_IGNORE) != 0 + && ImplIsPrivateUse(c)); +} bool ImplGetUndefinedAsciiMultiByte(sal_uInt32 nFlags, char * pBuf, @@ -92,37 +96,12 @@ bool ImplGetInvalidAsciiMultiByte(sal_uInt32 nFlags, return true; } -int ImplIsUnicodeIgnoreChar( sal_Unicode c, sal_uInt32 nFlags ) -{ - return - ((nFlags & RTL_UNICODETOTEXT_FLAGS_NONSPACING_IGNORE) != 0 - && ImplIsZeroWidth(c)) - || ((nFlags & RTL_UNICODETOTEXT_FLAGS_CONTROL_IGNORE) != 0 - && ImplIsControlOrFormat(c)) - || ((nFlags & RTL_UNICODETOTEXT_FLAGS_PRIVATE_IGNORE) != 0 - && ImplIsPrivateUse(c)); -} - -/* ======================================================================= */ - -sal_Unicode ImplGetUndefinedUnicodeChar(sal_uChar cChar, sal_uInt32 nFlags) -{ - return ((nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) - == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE) ? - RTL_TEXTCVT_BYTE_PRIVATE_START + cChar : - RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; } -/* ----------------------------------------------------------------------- */ - -bool -ImplHandleUndefinedUnicodeToTextChar(void const *, - sal_Unicode const ** ppSrcBuf, - sal_Unicode const * pEndSrcBuf, - char ** ppDestBuf, - char const * pEndDestBuf, - sal_uInt32 nFlags, - sal_uInt32 * pInfo) +bool sal::detail::textenc::handleUndefinedUnicodeToTextChar( + sal_Unicode const ** ppSrcBuf, sal_Unicode const * pEndSrcBuf, + char ** ppDestBuf, char const * pEndDestBuf, sal_uInt32 nFlags, + sal_uInt32 * pInfo) { sal_Unicode c = **ppSrcBuf; @@ -212,5 +191,3 @@ ImplHandleUndefinedUnicodeToTextChar(void const *, return true; } - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/textenc/handleundefinedunicodetotextchar.hxx b/sal/textenc/handleundefinedunicodetotextchar.hxx new file mode 100644 index 000000000000..a3a3c329d9d1 --- /dev/null +++ b/sal/textenc/handleundefinedunicodetotextchar.hxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License or as specified alternatively below. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * Major Contributor(s): + * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com> + * (initial developer) ] + * + * All Rights Reserved. + * + * For minor contributions see the git repository. + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#ifndef INCLUDED_SAL_TEXTENC_HANDLEUNDEFINEDUNICODETOTEXTCHAR_HXX +#define INCLUDED_SAL_TEXTENC_HANDLEUNDEFINEDUNICODETOTEXTCHAR_HXX + +#include "sal/config.h" + +#include "sal/saldllapi.h" +#include "sal/types.h" + +// Internal, non-stable ABI + +namespace sal { namespace detail { namespace textenc { + +// True means "continue," false means "break:" +bool SAL_DLLPUBLIC handleUndefinedUnicodeToTextChar( + sal_Unicode const ** ppSrcBuf, sal_Unicode const * pEndSrcBuf, + char ** ppDestBuf, char const * pEndDestBuf, sal_uInt32 nFlags, + sal_uInt32 * pInfo); + +} } } + +#endif diff --git a/sal/textenc/tcvtbyte.cxx b/sal/textenc/tcvtbyte.cxx index b8d78c5e757f..4861daf4aea1 100644 --- a/sal/textenc/tcvtbyte.cxx +++ b/sal/textenc/tcvtbyte.cxx @@ -30,6 +30,7 @@ #include "rtl/textcvt.h" +#include "handleundefinedunicodetotextchar.hxx" #include "tcvtbyte.hxx" #include "tenchelp.hxx" @@ -69,7 +70,7 @@ sal_Size ImplSymbolToUnicode( const void*, return (nDestChars - (pEndDestBuf-pDestBuf)); } -sal_Size ImplUnicodeToSymbol( const void* pData, +sal_Size ImplUnicodeToSymbol( const void*, void*, const sal_Unicode* pSrcBuf, sal_Size nSrcChars, char* pDestBuf, sal_Size nDestBytes, @@ -117,13 +118,9 @@ sal_Size ImplUnicodeToSymbol( const void* pData, /* Handle undefined and surrogates characters */ /* (all surrogates characters are undefined) */ - if (!ImplHandleUndefinedUnicodeToTextChar(pData, - &pSrcBuf, - pEndSrcBuf, - &pDestBuf, - pEndDestBuf, - nFlags, - pInfo)) + if (!sal::detail::textenc::handleUndefinedUnicodeToTextChar( + &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf, nFlags, + pInfo)) break; } } diff --git a/sal/textenc/tcvtmb.cxx b/sal/textenc/tcvtmb.cxx index e968beeb0062..40bb909ce639 100644 --- a/sal/textenc/tcvtmb.cxx +++ b/sal/textenc/tcvtmb.cxx @@ -30,6 +30,7 @@ #include "rtl/textcvt.h" +#include "handleundefinedunicodetotextchar.hxx" #include "tenchelp.hxx" #include "unichars.hxx" @@ -336,13 +337,9 @@ sal_Size ImplUnicodeToDBCS( const void* pData, void*, /* Handle undefined and surrogates characters */ /* (all surrogates characters are undefined) */ - if (ImplHandleUndefinedUnicodeToTextChar(pData, - &pSrcBuf, - pEndSrcBuf, - &pDestBuf, - pEndDestBuf, - nFlags, - pInfo)) + if (sal::detail::textenc::handleUndefinedUnicodeToTextChar( + &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf, nFlags, + pInfo)) continue; else break; @@ -624,13 +621,9 @@ sal_Size ImplUnicodeToEUCJP( const void* pData, /* Handle undefined and surrogates characters */ /* (all surrogates characters are undefined) */ - if (ImplHandleUndefinedUnicodeToTextChar(pData, - &pSrcBuf, - pEndSrcBuf, - &pDestBuf, - pEndDestBuf, - nFlags, - pInfo)) + if (sal::detail::textenc::handleUndefinedUnicodeToTextChar( + &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf, + nFlags, pInfo)) continue; else break; diff --git a/sal/textenc/tenchelp.hxx b/sal/textenc/tenchelp.hxx index 149a5435a8b2..381f26ada8db 100644 --- a/sal/textenc/tenchelp.hxx +++ b/sal/textenc/tenchelp.hxx @@ -32,9 +32,12 @@ #include "sal/config.h" #include "rtl/tencinfo.h" +#include "rtl/textcvt.h" #include "rtl/textenc.h" #include "sal/types.h" +#include "unichars.hxx" + #define RTL_TEXTCVT_BYTE_PRIVATE_START 0xF100 #define RTL_TEXTCVT_BYTE_PRIVATE_END 0xF1FF @@ -199,17 +202,14 @@ struct ImplEUCJPConvertData /* - TextConverter - HelpFunctions - */ /* --------------------------------- */ -sal_Unicode ImplGetUndefinedUnicodeChar(sal_uChar cChar, sal_uInt32 nFlags); - -bool -ImplHandleUndefinedUnicodeToTextChar(void const * pData, - sal_Unicode const ** ppSrcBuf, - sal_Unicode const * pEndSrcBuf, - char ** ppDestBuf, - char const * pEndDestBuf, - sal_uInt32 nFlags, - sal_uInt32 * pInfo); - /* true means 'continue,' false means 'break' */ +inline sal_Unicode ImplGetUndefinedUnicodeChar( + sal_uChar cChar, sal_uInt32 nFlags) +{ + return ((nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) + == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MAPTOPRIVATE) ? + RTL_TEXTCVT_BYTE_PRIVATE_START + cChar : + RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; +} /* ----------------------------- */ /* - TextConverter - Functions - */ diff --git a/sal/textenc/unichars.cxx b/sal/textenc/unichars.cxx index 1291fff8b8c0..65ef19ce9034 100644 --- a/sal/textenc/unichars.cxx +++ b/sal/textenc/unichars.cxx @@ -28,20 +28,10 @@ #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 @@ -86,18 +76,6 @@ bool ImplIsControlOrFormat(sal_uInt32 nUtf32) || (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 @@ -119,22 +97,4 @@ bool ImplIsZeroWidth(sal_uInt32 nUtf32) || 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.hxx b/sal/textenc/unichars.hxx index b068fff8e15e..2b8a3d05828d 100644 --- a/sal/textenc/unichars.hxx +++ b/sal/textenc/unichars.hxx @@ -31,27 +31,51 @@ #include "sal/config.h" +#include <cassert> + #include "sal/types.h" #define RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER 0xFFFD -bool ImplIsNoncharacter(sal_uInt32 nUtf32); +inline bool ImplIsNoncharacter(sal_uInt32 nUtf32) +{ + return (nUtf32 >= 0xFDD0 && nUtf32 <= 0xFDEF) + || (nUtf32 & 0xFFFF) >= 0xFFFE + || nUtf32 > 0x10FFFF; +} + // All code points that are noncharacters, as of Unicode 3.1.1. bool ImplIsControlOrFormat(sal_uInt32 nUtf32); -bool ImplIsHighSurrogate(sal_uInt32 nUtf32); +inline bool ImplIsHighSurrogate(sal_uInt32 nUtf32) +{ return nUtf32 >= 0xD800 && nUtf32 <= 0xDBFF; } + // All code points that are high-surrogates, as of Unicode 3.1.1. -bool ImplIsLowSurrogate(sal_uInt32 nUtf32); +inline bool ImplIsLowSurrogate(sal_uInt32 nUtf32) +{ return nUtf32 >= 0xDC00 && nUtf32 <= 0xDFFF; } + // All code points that are low-surrogates, as of Unicode 3.1.1. bool ImplIsPrivateUse(sal_uInt32 nUtf32); bool ImplIsZeroWidth(sal_uInt32 nUtf32); -sal_uInt32 ImplGetHighSurrogate(sal_uInt32 nUtf32); +inline sal_uInt32 ImplGetHighSurrogate(sal_uInt32 nUtf32) +{ + assert(nUtf32 >= 0x10000); + return ((nUtf32 - 0x10000) >> 10) | 0xD800; +} -sal_uInt32 ImplGetLowSurrogate(sal_uInt32 nUtf32); +inline sal_uInt32 ImplGetLowSurrogate(sal_uInt32 nUtf32) +{ + assert(nUtf32 >= 0x10000); + return ((nUtf32 - 0x10000) & 0x3FF) | 0xDC00; +} -sal_uInt32 ImplCombineSurrogates(sal_uInt32 nHigh, sal_uInt32 nLow); +inline sal_uInt32 ImplCombineSurrogates(sal_uInt32 nHigh, sal_uInt32 nLow) +{ + assert(ImplIsHighSurrogate(nHigh) && ImplIsLowSurrogate(nLow)); + return (((nHigh & 0x3FF) << 10) | (nLow & 0x3FF)) + 0x10000; +} #endif |