[Libreoffice-commits] core.git: i18nutil/source sc/qa

Winfried Donkers winfrieddonkers at libreoffice.org
Fri Feb 2 15:09:46 UTC 2018


 i18nutil/source/utility/widthfolding.cxx     |   45 ---------------------------
 i18nutil/source/utility/widthfolding_data.h  |   23 +++----------
 sc/qa/unit/data/functions/text/fods/jis.fods |   24 +++++++++++++-
 3 files changed, 28 insertions(+), 64 deletions(-)

New commits:
commit 6c79c9053e3090df09fc2c0a24f1fec26ac8bf02
Author: Winfried Donkers <winfrieddonkers at libreoffice.org>
Date:   Thu Feb 1 15:39:56 2018 +0100

    Clean up of dirty hack.
    
    Follow up of tdf#103550. The conversion from half to full width characters and vice versa happens per character according to a table. There is no need to have a separate table with exceptions to the general rule.
    
    Change-Id: Id611d1d6074cb2489fb0254d8ba9a83d7c26065f
    Reviewed-on: https://gerrit.libreoffice.org/49102
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Eike Rathke <erack at redhat.com>

diff --git a/i18nutil/source/utility/widthfolding.cxx b/i18nutil/source/utility/widthfolding.cxx
index a7e8dd05c285..8db7524235e2 100644
--- a/i18nutil/source/utility/widthfolding.cxx
+++ b/i18nutil/source/utility/widthfolding.cxx
@@ -214,27 +214,6 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC()
     static oneToOneMappingWithFlag table(full2half, sizeof(full2half), FULL2HALF_ASC_FUNCTION);
     table.makeIndex();
 
-    // bluedwarf: dirty hack!
-    // There is an exception. Additional conversion is required following:
-    //  0xFFE5 (FULLWIDTH YEN SIGN)  --> 0x005C (REVERSE SOLIDUS)
-    //
-    //  See the following page for detail:
-    // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
-    for( int i = 0; i < int(SAL_N_ELEMENTS(full2halfASCException)); i++ )
-    {
-        const int high = (full2halfASCException[i].first >> 8) & 0xFF;
-        const int low  = (full2halfASCException[i].first)      & 0xFF;
-
-        if( !table.mpIndex[high] )
-        {
-            table.mpIndex[high] = new UnicodePairWithFlag*[256];
-
-            for( int j = 0; j < 256; j++ )
-                table.mpIndex[high][j] = nullptr;
-        }
-        table.mpIndex[high][low] = &full2halfASCException[i];
-    }
-
     return table;
 }
 
@@ -243,30 +222,6 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS()
     static oneToOneMappingWithFlag table(half2full, sizeof(half2full), HALF2FULL_JIS_FUNCTION);
     table.makeIndex();
 
-    // bluedwarf: dirty hack!
-    //  There are some exceptions. Additional conversion are required following:
-    //  0x0022 (QUOTATION MARK)  --> 0x201D (RIGHT DOUBLE QUOTATION MARK)
-    //  0x0027 (APOSTROPHE)      --> 0x2019 (RIGHT SINGLE QUOTATION MARK)
-    //  0x005C (REVERSE SOLIDUS) --> 0xFFE5 (FULLWIDTH YEN SIGN)
-    //  0x0060 (GRAVE ACCENT)    --> 0x2018 (LEFT SINGLE QUOTATION MARK)
-    //
-    //  See the following page for detail:
-    // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions
-    for( int i = 0; i < int(SAL_N_ELEMENTS(half2fullJISException)); i++ )
-    {
-        const int high = (half2fullJISException[i].first >> 8) & 0xFF;
-        const int low  = (half2fullJISException[i].first)      & 0xFF;
-
-        if( !table.mpIndex[high] )
-        {
-            table.mpIndex[high] = new UnicodePairWithFlag*[256];
-
-            for( int j = 0; j < 256; j++ )
-                table.mpIndex[high][j] = nullptr;
-        }
-        table.mpIndex[high][low] = &half2fullJISException[i];
-    }
-
     return table;
 }
 
diff --git a/i18nutil/source/utility/widthfolding_data.h b/i18nutil/source/utility/widthfolding_data.h
index 999ca82734b1..b1c0e2c00c57 100644
--- a/i18nutil/source/utility/widthfolding_data.h
+++ b/i18nutil/source/utility/widthfolding_data.h
@@ -481,17 +481,11 @@ UnicodePairWithFlag full2half[] = {
     { 0xFFE3, 0x00AF, FULL2HALF_NORMAL },  // FULLWIDTH MACRON --> MACRON
     { 0xFFE4, 0x00A6, FULL2HALF_NORMAL },  // FULLWIDTH BROKEN BAR --> BROKEN BAR
     { 0xFFE5, 0x00A5, FULL2HALF_NORMAL },  // FULLWIDTH YEN SIGN --> YEN SIGN
+    { 0xFFE5, 0x005C, FULL2HALF_ASC_FUNCTION },  // FULLWIDTH YEN SIGN --> REVERSE SOLIDUS, exceptional conversion
     { 0xFFE6, 0x20A9, FULL2HALF_NORMAL },  // FULLWIDTH WON SIGN --> WON SIGN
 };
 
 /*
- Exceptional conversion table for ASC function
-*/
-UnicodePairWithFlag full2halfASCException[] = {
-    { 0xFFE5, 0x005C, FULL2HALF_ASC_FUNCTION }  // FULLWIDTH YEN SIGN --> REVERSE SOLIDUS
- };
-
-/*
   Unicode Normalization Forms
   http://www.unicode.org/unicode/reports/tr15/index.html
   http://www.w3.org/International/charlint/
@@ -708,11 +702,13 @@ UnicodePairWithFlag half2full[] = {
     { 0x0020, 0x3000, HALF2FULL_NORMAL },  // SPACE --> IDEOGRAPHIC SPACE
     { 0x0021, 0xFF01, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // EXCLAMATION MARK --> FULLWIDTH EXCLAMATION MARK
     { 0x0022, 0xFF02, HALF2FULL_NORMAL },  // QUOTATION MARK --> FULLWIDTH QUOTATION MARK
+    { 0x0022, 0x201D, HALF2FULL_JIS_FUNCTION }, // QUOTATION MARK --> RIGHT DOUBLE QUOTATION MARK, exceptional conversion
     { 0x0023, 0xFF03, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // NUMBER SIGN --> FULLWIDTH NUMBER SIGN
     { 0x0024, 0xFF04, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // DOLLAR SIGN --> FULLWIDTH DOLLAR SIGN
     { 0x0025, 0xFF05, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // PERCENT SIGN --> FULLWIDTH PERCENT SIGN
     { 0x0026, 0xFF06, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // AMPERSAND --> FULLWIDTH AMPERSAND
     { 0x0027, 0xFF07, HALF2FULL_NORMAL },  // APOSTROPHE --> FULLWIDTH APOSTROPHE
+    { 0x0027, 0x2019, HALF2FULL_JIS_FUNCTION }, // APOSTROPHE --> RIGHT SINGLE QUOTATION MARK, exceptional conversion
     { 0x0028, 0xFF08, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LEFT PARENTHESIS --> FULLWIDTH LEFT PARENTHESIS
     { 0x0029, 0xFF09, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // RIGHT PARENTHESIS --> FULLWIDTH RIGHT PARENTHESIS
     { 0x002A, 0xFF0A, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // ASTERISK --> FULLWIDTH ASTERISK
@@ -766,10 +762,12 @@ UnicodePairWithFlag half2full[] = {
     { 0x005A, 0xFF3A, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LATIN CAPITAL LETTER Z --> FULLWIDTH LATIN CAPITAL LETTER Z
     { 0x005B, 0xFF3B, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LEFT SQUARE BRACKET --> FULLWIDTH LEFT SQUARE BRACKET
     { 0x005C, 0xFF3C, HALF2FULL_NORMAL },  // REVERSE SOLIDUS --> FULLWIDTH REVERSE SOLIDUS
+    { 0x005C, 0xFFE5, HALF2FULL_JIS_FUNCTION }, // REVERSE SOLIDUS --> FULLWIDTH YEN SIGN, exceptional conversion
     { 0x005D, 0xFF3D, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // RIGHT SQUARE BRACKET --> FULLWIDTH RIGHT SQUARE BRACKET
     { 0x005E, 0xFF3E, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // CIRCUMFLEX ACCENT --> FULLWIDTH CIRCUMFLEX ACCENT
     { 0x005F, 0xFF3F, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LOW LINE --> FULLWIDTH LOW LINE
     { 0x0060, 0xFF40, HALF2FULL_NORMAL },  // GRAVE ACCENT --> FULLWIDTH GRAVE ACCENT
+    { 0x0060, 0x2018, HALF2FULL_JIS_FUNCTION }, // GRAVE ACCENT --> LEFT SINGLE QUOTATION MARK, exceptional conversion
     { 0x0061, 0xFF41, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LATIN SMALL LETTER A --> FULLWIDTH LATIN SMALL LETTER A
     { 0x0062, 0xFF42, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LATIN SMALL LETTER B --> FULLWIDTH LATIN SMALL LETTER B
     { 0x0063, 0xFF43, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION },  // LATIN SMALL LETTER C --> FULLWIDTH LATIN SMALL LETTER C
@@ -936,17 +934,6 @@ UnicodePairWithFlag half2full[] = {
     { 0xFFEE, 0x25CB, HALF2FULL_NORMAL },  // HALFWIDTH WHITE CIRCLE --> WHITE CIRCLE
 };
 
-/*
- Exceptional conversion table for JIS function
-*/
-UnicodePairWithFlag half2fullJISException[] = {
-    { 0x0022, 0x201D, HALF2FULL_JIS_FUNCTION }, // QUOTATION MARK --> RIGHT DOUBLE QUOTATION MARK
-    { 0x0027, 0x2019, HALF2FULL_JIS_FUNCTION }, // APOSTROPHE --> RIGHT SINGLE QUOTATION MARK
-    { 0x005C, 0xFFE5, HALF2FULL_JIS_FUNCTION }, // REVERSE SOLIDUS --> FULLWIDTH YEN SIGN
-    { 0x0060, 0x2018, HALF2FULL_JIS_FUNCTION }, // GRAVE ACCENT --> LEFT SINGLE QUOTATION MARK
- };
-
-
 }
 
 #endif
diff --git a/sc/qa/unit/data/functions/text/fods/jis.fods b/sc/qa/unit/data/functions/text/fods/jis.fods
index 2c55690735fb..b637276070d1 100644
--- a/sc/qa/unit/data/functions/text/fods/jis.fods
+++ b/sc/qa/unit/data/functions/text/fods/jis.fods
@@ -1750,7 +1750,29 @@
      </table:table-cell>
      <table:table-cell table:number-columns-repeated="4"/>
     </table:table-row>
-    <table:table-row table:style-name="ro2" table:number-rows-repeated="4">
+    <table:table-row table:style-name="ro5">
+     <table:table-cell table:style-name="ce14" table:formula="of:=JIS([.I38])" office:value-type="string" office:string-value="”’¥‘" calcext:value-type="string">
+      <text:p>”’¥‘</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce34" office:value-type="string" calcext:value-type="string">
+      <text:p>”’¥‘</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce36" table:formula="of:=[.A38]=[.B38]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean">
+      <text:p>WAAR</text:p>
+     </table:table-cell>
+     <table:table-cell table:style-name="ce11" table:formula="of:=FORMULA([.A38])" office:value-type="string" office:string-value="=JIS(I38)" calcext:value-type="string">
+      <text:p>=JIS(I38)</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string" calcext:value-type="string">
+      <text:p>Tdf103550 related</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="3"/>
+     <table:table-cell table:style-name="ce34" office:value-type="string" calcext:value-type="string">
+      <text:p>"'\`</text:p>
+     </table:table-cell>
+     <table:table-cell table:number-columns-repeated="4"/>
+    </table:table-row>
+    <table:table-row table:style-name="ro2" table:number-rows-repeated="3">
      <table:table-cell table:style-name="ce23"/>
      <table:table-cell table:style-name="ce24"/>
      <table:table-cell table:style-name="ce29"/>


More information about the Libreoffice-commits mailing list