javacommons/utils/src.s60/formatternative.cpp
branchRCL_3
changeset 83 26b2b12093af
parent 60 6c158198356e
equal deleted inserted replaced
77:7cee158cb8cd 83:26b2b12093af
    14 * Description:  formatternative
    14 * Description:  formatternative
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
       
    19 //#include <avkon.rsg>
    19 #include <memory>
    20 #include <memory>
    20 #include <stringresourcereader.h>
    21 #include <stringresourcereader.h>
    21 
       
    22 #ifdef RD_JAVA_UI_QT
       
    23 #include <QLocale>
       
    24 #else // RD_JAVA_UI_QT
       
    25 #include <AknUtils.h>
    22 #include <AknUtils.h>
    26 #endif // RD_JAVA_UI_QT
       
    27 
    23 
    28 #include "com_nokia_mj_impl_utils_Formatter.h"
    24 #include "com_nokia_mj_impl_utils_Formatter.h"
    29 #include "com_nokia_mj_impl_utils_ResourceLoader.h"
    25 #include "com_nokia_mj_impl_utils_ResourceLoader.h"
    30 #include "javajniutils.h"
    26 #include "javajniutils.h"
    31 #include "s60commonutils.h"
    27 #include "s60commonutils.h"
    47 // const TInt KMaxDateTimeStringSize = 50;
    43 // const TInt KMaxDateTimeStringSize = 50;
    48 const TInt KMaxDateFormatSize = 30;
    44 const TInt KMaxDateFormatSize = 30;
    49 const TInt KMaxNumberFormatSize = 40;
    45 const TInt KMaxNumberFormatSize = 40;
    50 using namespace java::util;
    46 using namespace java::util;
    51 
    47 
       
    48 // _LIT( KAvkonResFile, "z:\\resource\\avkon.rsc" );
    52 
    49 
    53 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatInteger
    50 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatInteger
    54 (JNIEnv *aJni, jobject, jint aNumber)
    51 (JNIEnv *aJni, jobject, jint aNumber)
    55 {
    52 {
    56     JELOG2(EUtils);
    53     JELOG2(EUtils);
    69     {
    66     {
    70         WLOG2(EUtils,
    67         WLOG2(EUtils,
    71               "Cannot format %d to current locale. Error: %d", aNumber, error);
    68               "Cannot format %d to current locale. Error: %d", aNumber, error);
    72     }
    69     }
    73 
    70 
    74 #ifndef RD_JAVA_UI_QT
    71     AknTextUtils::LanguageSpecificNumberConversion( numberPtr );
    75         AknTextUtils::LanguageSpecificNumberConversion( numberPtr );
       
    76 #endif // RD_JAVA_UI_QT
       
    77 
       
    78     return aJni->NewString(
    72     return aJni->NewString(
    79                (const jchar*)numberPtr.Ptr(), numberPtr.Length());
    73                (const jchar*)numberPtr.Ptr(), numberPtr.Length());
    80 }
    74 }
    81 
    75 
    82 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDate
    76 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_Formatter__1formatDate
   120 {
   114 {
   121     jstring ret = str;
   115     jstring ret = str;
   122     std::wstring wstr = JniUtils::jstringToWstring(aEnv, str);
   116     std::wstring wstr = JniUtils::jstringToWstring(aEnv, str);
   123     HBufC* buf = S60CommonUtils::wstringToDes(wstr.c_str());
   117     HBufC* buf = S60CommonUtils::wstringToDes(wstr.c_str());
   124     TPtr ptr(buf->Des());
   118     TPtr ptr(buf->Des());
   125 
       
   126 #ifndef RD_JAVA_UI_QT
       
   127     AknTextUtils::LanguageSpecificNumberConversion( ptr );
   119     AknTextUtils::LanguageSpecificNumberConversion( ptr );
   128 #endif // RD_JAVA_UI_QT
       
   129     ret = S60CommonUtils::NativeToJavaString(*aEnv, ptr);
   120     ret = S60CommonUtils::NativeToJavaString(*aEnv, ptr);
   130     delete buf; buf = NULL;
   121     delete buf; buf = NULL;
   131     return ret;
   122     return ret;
   132 }
   123 }
   133 
       
   134 JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_utils_ResourceLoader__1getLocaleIdQt
       
   135   (JNIEnv *env, jclass)
       
   136 {
       
   137 #ifdef RD_JAVA_UI_QT
       
   138     QString localeName = QLocale::system().name();
       
   139     jstring loc = env->NewString(localeName.utf16(), localeName.size());
       
   140     return loc;
       
   141 #else // RD_JAVA_UI_QT
       
   142     (void)env;     // just to suppress a warning
       
   143     return NULL;
       
   144 #endif // RD_JAVA_UI_QT
       
   145 }