У чет, 21. 02 2008. у 07:48 +0100, Pavel Janík пише:
> On 21.2.2008, at 0:22, Goran Rakic wrote:
> > I want to add transliteration from Serbian Cyrillic to Serbian 
> > Latin, wich is almost one to one with some simple 
> > folding/decomposing (like "љ" to "lj" etc).
> 
> please post complete patch to [EMAIL PROTECTED]


Ah, sorry for not doing that first time.

This patch is not working, as  serbianCyrillicToLatin.cxx has wrong fold
method prototype, and as I don't need rtl support I don't know what
prototype to use.

Any help in getting this to work is highly appreciated...

Regards,
Goran Rakic

? i18npool/source/transliteration/serbianCyrillicToLatin.cxx
Index: i18npool/inc/transliteration_OneToOne.hxx
===================================================================
RCS file: /cvs/l10n/i18npool/inc/transliteration_OneToOne.hxx,v
retrieving revision 1.6.166.1
diff -r1.6.166.1 transliteration_OneToOne.hxx
130a131,138
> #if defined( TRANSLITERATION_serbianCyrillicToLatin ) || defined( TRANSLITERATION_ALL )
> TRANSLITERATION_ONETOONE( serbianCyrillicToLatin )
> #endif
> /*
> #if defined( TRANSLITERATION_serbianLatinToCyrillic ) || defined( TRANSLITERATION_ALL )
> TRANSLITERATION_ONETOONE( serbianLatinToCyrillic )
> #endif
> */
Index: i18npool/source/registerservices/registerservices.cxx
===================================================================
RCS file: /cvs/l10n/i18npool/source/registerservices/registerservices.cxx,v
retrieving revision 1.42.90.1
diff -r1.42.90.1 registerservices.cxx
302a303,304
> IMPL_CREATEINSTANCE( serbianCyrillicToLatin )
> /* IMPL_CREATEINSTANCE( serbianLatinToCyrillic ) */
576a579,587
> 
>     {   TRLT_SERVICELNAME_L10N,
>         TRLT_IMPLNAME_PREFIX  "SERBIANCYRILLIC_LATIN",
>         &serbianCyrillicToLatin_CreateInstance },
> /*    {   TRLT_SERVICELNAME_L10N,
>         TRLT_IMPLNAME_PREFIX  "SERBIANLATIN_CYRILLIC",
>         &serbianLatinToCyrillic_CreateInstance },
> */
> 
Index: i18npool/source/transliteration/makefile.mk
===================================================================
RCS file: /cvs/l10n/i18npool/source/transliteration/makefile.mk,v
retrieving revision 1.8
diff -r1.8 makefile.mk
58a59
>                         $(SLO)$/serbianCyrillicToLatin.obj \
/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: serbianCyrillicToLatin.cxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: obo $ $Date: 2008/02/18 14:13:28 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library 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 for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_i18npool.hxx"

// prevent internal compiler error with MSVC6SP3
#include <utility>

#include <i18nutil/oneToOneMapping.hxx>
#define TRANSLITERATION_serbianCyrillicToLatin
#include <transliteration_OneToOne.hxx>

#define IS_UPPERCASE(char) \
  (((char)>='A' && (char)<='Z') || ((char)>=0x0410 && (char)<=0xC5A0))

using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace rtl;

namespace com { namespace sun { namespace star { namespace i18n {

OneToOneMappingTable_t serbiancyrillic2latin[] = {        
    MAKE_PAIR(0x0402, 0xC490 ),       // 'Đ'
    MAKE_PAIR(0x0408, 'J' ),
    MAKE_PAIR(0x040B, 0xC486 ),       // 'Ć' 
    MAKE_PAIR(0x0410, 'A' ),
    MAKE_PAIR(0x0411, 'B' ),
    MAKE_PAIR(0x0412, 'V' ),
    MAKE_PAIR(0x0413, 'G' ),
    MAKE_PAIR(0x0414, 'D' ),
    MAKE_PAIR(0x0415, 'E' ),
    MAKE_PAIR(0x0416, 0xC5BD ),       // 'Ž'
    MAKE_PAIR(0x0417, 'Z' ),
    MAKE_PAIR(0x0418, 'I' ),
    MAKE_PAIR(0x041A, 'K' ),
    MAKE_PAIR(0x041B, 'L' ),
    MAKE_PAIR(0x041C, 'M' ),
    MAKE_PAIR(0x041D, 'N' ),
    MAKE_PAIR(0x041E, 'O' ),
    MAKE_PAIR(0x041F, 'P' ),
    MAKE_PAIR(0x0420, 'R' ),
    MAKE_PAIR(0x0421, 'S' ),
    MAKE_PAIR(0x0422, 'T' ),
    MAKE_PAIR(0x0423, 'U' ),
    MAKE_PAIR(0x0424, 'F' ),
    MAKE_PAIR(0x0425, 'H' ),
    MAKE_PAIR(0x0426, 'C' ),
    MAKE_PAIR(0x0427, 0xC48C ),       // 'Č' 
    MAKE_PAIR(0x0428, 0xC5A0 ),       // 'Š'
    MAKE_PAIR(0x0430, 'a' ),
    MAKE_PAIR(0x0431, 'b' ),
    MAKE_PAIR(0x0432, 'v' ),
    MAKE_PAIR(0x0433, 'g' ),
    MAKE_PAIR(0x0434, 'd' ),
    MAKE_PAIR(0x0435, 'e' ),
    MAKE_PAIR(0x0436, 0xC5BE ),       // 'ž'
    MAKE_PAIR(0x0437, 'z' ),
    MAKE_PAIR(0x0438, 'i' ),
    MAKE_PAIR(0x043A, 'k' ),
    MAKE_PAIR(0x043B, 'l' ),
    MAKE_PAIR(0x043C, 'm' ),
    MAKE_PAIR(0x043D, 'n' ),
    MAKE_PAIR(0x043E, 'o' ),
    MAKE_PAIR(0x043F, 'p' ),
    MAKE_PAIR(0x0440, 'r' ),
    MAKE_PAIR(0x0441, 's' ),
    MAKE_PAIR(0x0442, 't' ),
    MAKE_PAIR(0x0443, 'u' ),
    MAKE_PAIR(0x0444, 'f' ),
    MAKE_PAIR(0x0445, 'h' ),
    MAKE_PAIR(0x0446, 'c' ),
    MAKE_PAIR(0x0447, 0xC48D ),       // 'č'
    MAKE_PAIR(0x0448, 0xC5A1 ),       // 'š'
    MAKE_PAIR(0x0452, 0xC491 ),       // 'đ'
    MAKE_PAIR(0x0458, 'j' ),
    MAKE_PAIR(0x045B, 0xC487 )        // 'ć'
};

sal_Unicode SAL_CALL
serbianCyrillicToLatin::folding(const sal_Unicode & inStr, sal_Int32 startPos,
        sal_Int32 nCount, Sequence< sal_Int32 > & offset) throw (RuntimeException)
{
    rtl::OStringBuffer sb;
    const sal_Unicode * chArr = inStr.getStr() + startPos;

    if (startPos < 0)
        throw RuntimeException();

    if (startPos + nCount > inStr.getLength())
        nCount = inStr.getLength() - startPos;

    // Replace џ with дж, Џ with Дж or ДЖ
    for (sal_Int32 i = 0; i < nCount; i++) {
        if (chArr[i] == 0x045F) {                       // џ -> дж
            sb.append(0x0434);
            sb.append(0x0436);
        }
        else if (chArr[i] == 0x040F) {                  // Џ -> Дж or ДЖ
            sb.append(0x0414);
            if( (i+1<nCount && IS_UPPERCASE(chArr[i+1])) || 
                (i>0 && IS_UPPERCASE(chArr[i-1])) ) {
                sb.append(0x0416);  // ДЖ
            }
            else {
                sb.append(0x0436);  // Дж
            }
        }
        else if (chArr[i] == 0x0459) {                       // љ -> лј
            sb.append(0x043B);
            sb.append(0x0458);
        }
        else if (chArr[i] == 0x0409) {                  // Љ -> Лј or ЛЈ
            sb.append(0x041B);            
            if( (i+1<nCount && IS_UPPERCASE(chArr[i+1])) || 
                (i>0 && IS_UPPERCASE(chArr[i-1])) ) {
                sb.append(0x0408);  // ЛЈ
            }
            else {
                sb.append(0x0458);  // Лј
            }
        }
        else if (chArr[i] == 0x045A) {                       // њ -> нј
            sb.append(0x043D);
            sb.append(0x0458);
        }
        else if (chArr[i] == 0x040A) {                  // Њ -> Нј or НЈ
            sb.append(0x041D);
            if( (i+1<nCount && IS_UPPERCASE(chArr[i+1])) || 
                (i>0 && IS_UPPERCASE(chArr[i-1])) ) {
                sb.append(0x0408);  // НЈ
            }
            else {
                sb.append(0x0458);  // Нј
            }
        }
        else sb.append(chArr[i]);
    }

    return sb.makeStringAndClear();
}

serbianCyrillicToLatin::serbianCyrillicToLatin()
{
        static oneToOneMapping _table(serbiancyrillic2latin, sizeof(serbiancyrillic2latin));
        func = (TransFunc) 0;
        table = &_table;
        transliterationName = "serbianCyrillicToLatin";
        implementationName = "com.sun.star.i18n.Transliteration.SERBIANCYRILLIC_LATIN";
}

} } } }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to