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