diff options
Diffstat (limited to 'svl')
-rw-r--r-- | svl/inc/svl/zformat.hxx | 9 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.cxx | 37 | ||||
-rw-r--r-- | svl/source/numbers/zforfind.hxx | 2 | ||||
-rw-r--r-- | svl/source/numbers/zformat.cxx | 45 |
4 files changed, 86 insertions, 7 deletions
diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx index 9ad2895aa2f7..1ad50d704a15 100644 --- a/svl/inc/svl/zformat.hxx +++ b/svl/inc/svl/zformat.hxx @@ -476,6 +476,15 @@ private: SVL_DLLPRIVATE bool ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const; + /** Whether to use possessive genitive case month name instead of noun. + @param io_nState + 0: execute check, set to 1 if true is returned, set to 2 if false + is returned <br> + 1: don't execute check, return true <br> + 2: don't execute check, return false <br> + */ + SVL_DLLPRIVATE bool ImpUseGenitiveMonth( int & io_nState, const ImpSvNumFor& rNumFor ) const; + #ifdef THE_FUTURE SVL_DLLPRIVATE bool ImpSwitchToSpecifiedCalendar( String& rOrgCalendar, double& fOrgDateTime, const ImpSvNumFor& rNumFor ) const; diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index 36d69038020c..a4086335562b 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -84,6 +84,8 @@ ImpSvNumberInputScan::ImpSvNumberInputScan( SvNumberFormatter* pFormatterP ) : pUpperMonthText( NULL ), pUpperAbbrevMonthText( NULL ), + pUpperGenitiveMonthText( NULL ), + pUpperGenitiveAbbrevMonthText( NULL ), pUpperDayText( NULL ), pUpperAbbrevDayText( NULL ), eScannedType( NUMBERFORMAT_UNDEFINED ), @@ -106,6 +108,8 @@ ImpSvNumberInputScan::~ImpSvNumberInputScan() delete pNullDate; delete [] pUpperMonthText; delete [] pUpperAbbrevMonthText; + delete [] pUpperGenitiveMonthText; + delete [] pUpperGenitiveAbbrevMonthText; delete [] pUpperDayText; delete [] pUpperAbbrevDayText; } @@ -556,14 +560,26 @@ short ImpSvNumberInputScan::GetMonth( const String& rString, xub_StrLen& nPos ) sal_Int16 nMonths = pFormatter->GetCalendar()->getNumberOfMonthsInYear(); for ( sal_Int16 i = 0; i < nMonths; i++ ) { - if ( StringContains( pUpperMonthText[i], rString, nPos ) ) - { // full names first + if ( StringContains( pUpperGenitiveMonthText[i], rString, nPos ) ) + { // genitive full names first + nPos = nPos + pUpperGenitiveMonthText[i].Len(); + res = i+1; + break; // for + } + else if ( StringContains( pUpperGenitiveAbbrevMonthText[i], rString, nPos ) ) + { // genitive abbreviated + nPos = nPos + pUpperGenitiveAbbrevMonthText[i].Len(); + res = sal::static_int_cast< short >(-(i+1)); // negative + break; // for + } + else if ( StringContains( pUpperMonthText[i], rString, nPos ) ) + { // noun full names nPos = nPos + pUpperMonthText[i].Len(); res = i+1; break; // for } else if ( StringContains( pUpperAbbrevMonthText[i], rString, nPos ) ) - { // abbreviated + { // noun abbreviated nPos = nPos + pUpperAbbrevMonthText[i].Len(); res = sal::static_int_cast< short >(-(i+1)); // negative break; // for @@ -2412,6 +2428,7 @@ void ImpSvNumberInputScan::InitText() sal_Int32 j, nElems; const CharClass* pChrCls = pFormatter->GetCharClass(); const CalendarWrapper* pCal = pFormatter->GetCalendar(); + delete [] pUpperMonthText; delete [] pUpperAbbrevMonthText; ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > xElems @@ -2424,6 +2441,19 @@ void ImpSvNumberInputScan::InitText() pUpperMonthText[j] = pChrCls->upper( xElems[j].FullName ); pUpperAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName ); } + + delete [] pUpperGenitiveMonthText; + delete [] pUpperGenitiveAbbrevMonthText; + xElems = pCal->getGenitiveMonths(); + nElems = xElems.getLength(); + pUpperGenitiveMonthText = new String[nElems]; + pUpperGenitiveAbbrevMonthText = new String[nElems]; + for ( j=0; j<nElems; j++ ) + { + pUpperGenitiveMonthText[j] = pChrCls->upper( xElems[j].FullName ); + pUpperGenitiveAbbrevMonthText[j] = pChrCls->upper( xElems[j].AbbrevName ); + } + delete [] pUpperDayText; delete [] pUpperAbbrevDayText; xElems = pCal->getDays(); @@ -2435,6 +2465,7 @@ void ImpSvNumberInputScan::InitText() pUpperDayText[j] = pChrCls->upper( xElems[j].FullName ); pUpperAbbrevDayText[j] = pChrCls->upper( xElems[j].AbbrevName ); } + bTextInitialized = true; } diff --git a/svl/source/numbers/zforfind.hxx b/svl/source/numbers/zforfind.hxx index 3b9fd9b82eb2..158a4564a28d 100644 --- a/svl/source/numbers/zforfind.hxx +++ b/svl/source/numbers/zforfind.hxx @@ -73,6 +73,8 @@ private: SvNumberFormatter* pFormatter; String* pUpperMonthText; // Array of month names, uppercase String* pUpperAbbrevMonthText; // Array of month names, abbreviated, uppercase + String* pUpperGenitiveMonthText; // Array of genitive month names, uppercase + String* pUpperGenitiveAbbrevMonthText; // Array of genitive month names, abbreviated, uppercase String* pUpperDayText; // Array of day of week names, uppercase String* pUpperAbbrevDayText; // Array of day of week names, abbreviated, uppercase String aUpperCurrSymbol; // Currency symbol, uppercase diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 214d89f7c9af..e6da6105f25e 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2942,6 +2942,33 @@ bool SvNumberformat::ImpGetTimeOutput(double fNumber, return bRes; } + +/** If a day of month occurs within the format, the month name is in possessive + genitive case. + */ +bool SvNumberformat::ImpUseGenitiveMonth( int & io_nState, const ImpSvNumFor& rNumFor ) const +{ + if (io_nState) + return io_nState == 1; + + const ImpSvNumberformatInfo& rInfo = rNumFor.Info(); + const sal_uInt16 nAnz = rNumFor.GetCount(); + sal_uInt16 i; + for ( i = 0; i < nAnz; i++ ) + { + switch ( rInfo.nTypeArray[i] ) + { + case NF_KEY_D : + case NF_KEY_DD : + io_nState = 1; + return true; + } + } + io_nState = 2; + return false; +} + + bool SvNumberformat::ImpIsOtherCalendar( const ImpSvNumFor& rNumFor ) const { if ( GetCal().getUniqueID() != Gregorian::get() ) @@ -3101,6 +3128,7 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber, double fDiff = DateTime(*(rScan.GetNullDate())) - rCal.getEpochStart(); fNumber += fDiff; rCal.setLocalDateTime( fNumber ); + int nUseGenitiveMonth = 0; // not decided yet String aOrgCalendar; // empty => not changed yet double fOrgDateTime; bool bOtherCalendar = ImpIsOtherCalendar( NumFor[nIx] ); @@ -3154,11 +3182,15 @@ bool SvNumberformat::ImpGetDateOutput(double fNumber, break; case NF_KEY_MMM: // MMM OutString += rCal.getDisplayString( - CalendarDisplayCode::SHORT_MONTH_NAME, nNatNum ); + (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ? + CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME : + CalendarDisplayCode::SHORT_MONTH_NAME), nNatNum ); break; case NF_KEY_MMMM: // MMMM OutString += rCal.getDisplayString( - CalendarDisplayCode::LONG_MONTH_NAME, nNatNum ); + (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ? + CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME : + CalendarDisplayCode::LONG_MONTH_NAME), nNatNum ); break; case NF_KEY_MMMMM: // MMMMM OutString += rCal.getDisplayString( @@ -3309,6 +3341,7 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber, } rCal.setLocalDateTime( fNumber ); + int nUseGenitiveMonth = 0; // not decided yet String aOrgCalendar; // empty => not changed yet double fOrgDateTime; bool bOtherCalendar = ImpIsOtherCalendar( NumFor[nIx] ); @@ -3476,11 +3509,15 @@ bool SvNumberformat::ImpGetDateTimeOutput(double fNumber, break; case NF_KEY_MMM: // MMM OutString += rCal.getDisplayString( - CalendarDisplayCode::SHORT_MONTH_NAME, nNatNum ); + (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ? + CalendarDisplayCode::SHORT_GENITIVE_MONTH_NAME : + CalendarDisplayCode::SHORT_MONTH_NAME), nNatNum ); break; case NF_KEY_MMMM: // MMMM OutString += rCal.getDisplayString( - CalendarDisplayCode::LONG_MONTH_NAME, nNatNum ); + (ImpUseGenitiveMonth( nUseGenitiveMonth, NumFor[nIx]) ? + CalendarDisplayCode::LONG_GENITIVE_MONTH_NAME : + CalendarDisplayCode::LONG_MONTH_NAME), nNatNum ); break; case NF_KEY_MMMMM: // MMMMM OutString += rCal.getDisplayString( |