svl/inc/svl/zformat.hxx | 14 +++++++++++++- svl/source/numbers/zforfind.cxx | 4 ++-- svl/source/numbers/zformat.cxx | 9 +++++---- 3 files changed, 20 insertions(+), 7 deletions(-)
New commits: commit 2ded844730e178b71183988e9078881a8c43dded Author: Eike Rathke <[email protected]> Date: Fri Mar 15 19:33:03 2013 +0100 clarify logic Change-Id: Idc223daa6034b359ac62693ce8dfebed846d5789 diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx index ba56235..6b0a054 100644 --- a/svl/inc/svl/zformat.hxx +++ b/svl/inc/svl/zformat.hxx @@ -328,12 +328,11 @@ public: bool IsFirstSubformatRealNegative() const { return fLimit1 == 0.0 && fLimit2 == 0.0 && - ( (eOp2 == NUMBERFORMAT_OP_GT && eOp1 == NUMBERFORMAT_OP_LT) || - (eOp2 == NUMBERFORMAT_OP_EQ && eOp1 == NUMBERFORMAT_OP_LT) || - (eOp2 == NUMBERFORMAT_OP_GE && eOp1 == NUMBERFORMAT_OP_LT) || - (eOp2 == NUMBERFORMAT_OP_NO && eOp1 == NUMBERFORMAT_OP_LT) || - (eOp2 == NUMBERFORMAT_OP_NO && eOp1 == NUMBERFORMAT_OP_LE) || - (eOp2 == NUMBERFORMAT_OP_GT && eOp1 == NUMBERFORMAT_OP_LE)); + ((eOp1 == NUMBERFORMAT_OP_LT && + (eOp2 == NUMBERFORMAT_OP_GT || eOp2 == NUMBERFORMAT_OP_EQ || + eOp2 == NUMBERFORMAT_OP_GE || eOp2 == NUMBERFORMAT_OP_NO)) || + (eOp1 == NUMBERFORMAT_OP_LE && + (eOp2 == NUMBERFORMAT_OP_NO || eOp2 == NUMBERFORMAT_OP_GT))); } // Whether the negative format is without a sign or not commit 6c6c70df543dd34229c8ac98f39073ca3c3bcf4d Author: Eike Rathke <[email protected]> Date: Fri Mar 15 17:57:11 2013 +0100 rename methods to something meaningful Change-Id: I92f5b3cb637b7cc6152d118505b69e762047f78b diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx index d4bbef7..ba56235 100644 --- a/svl/inc/svl/zformat.hxx +++ b/svl/inc/svl/zformat.hxx @@ -315,16 +315,17 @@ public: // Whether the second subformat code is really for negative numbers // or another limit set. - bool IsNegativeRealNegative() const + bool IsSecondSubformatRealNegative() const { return fLimit1 == 0.0 && fLimit2 == 0.0 && ( (eOp1 == NUMBERFORMAT_OP_GE && eOp2 == NUMBERFORMAT_OP_NO) || (eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT) || (eOp1 == NUMBERFORMAT_OP_NO && eOp2 == NUMBERFORMAT_OP_NO) ); } + // Whether the first subformat code is really for negative numbers // or another limit set. - sal_Bool IsNegativeRealNegative2() const + bool IsFirstSubformatRealNegative() const { return fLimit1 == 0.0 && fLimit2 == 0.0 && ( (eOp2 == NUMBERFORMAT_OP_GT && eOp1 == NUMBERFORMAT_OP_LT) || diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index a6a3f20..2ce5097 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -2826,7 +2826,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString, / if ( !bFound ) { if ( !bDontDetectNegation && (nString == 0) && - !bFirst && (nSign < 0) && pFormat->IsNegativeRealNegative() ) + !bFirst && (nSign < 0) && pFormat->IsSecondSubformatRealNegative() ) { // simply negated twice? --1 aString = comphelper::string::remove(aString, ' '); @@ -2843,7 +2843,7 @@ bool ImpSvNumberInputScan::ScanStringNumFor( const OUString& rString, / } } else if ( !bDontDetectNegation && (nSub == 1) && - pFormat->IsNegativeRealNegative() ) + pFormat->IsSecondSubformatRealNegative() ) { // negative if ( nStringScanSign < 0 ) diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 1ded02f..889f394 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2522,8 +2522,8 @@ bool SvNumberformat::GetOutputString(double fNumber, } } if (fNumber < 0.0 && - ((nIx == 0 && IsNegativeRealNegative2()) || // 1st, usually positive subformat - (nIx == 1 && IsNegativeRealNegative()))) // 2nd, usually negative subformat + ((nIx == 0 && IsFirstSubformatRealNegative()) || // 1st, usually positive subformat + (nIx == 1 && IsSecondSubformatRealNegative()))) // 2nd, usually negative subformat { fNumber = -fNumber; // eliminate sign } @@ -4874,7 +4874,7 @@ short SvNumberformat::GetNumForType( sal_uInt16 nNumFor, sal_uInt16 nPos, bool SvNumberformat::IsNegativeWithoutSign() const { - if ( IsNegativeRealNegative() ) + if ( IsSecondSubformatRealNegative() ) { const OUString* pStr = GetNumForString( 1, 0, true ); if ( pStr ) commit 7c66e99f1d1f2e640157b079088aba35b33e0fc0 Author: Eike Rathke <[email protected]> Date: Fri Mar 15 17:52:15 2013 +0100 simplify logic Change-Id: I60726b445712cc15f8453812ce6313167314a8df diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index eca7005..1ded02f 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2521,14 +2521,12 @@ bool SvNumberformat::GetOutputString(double fNumber, nIx = 2; } } - if (nIx == 1 && fNumber < 0.0 && // negatives Format - IsNegativeRealNegative() ) // ohne Vorzeichen + if (fNumber < 0.0 && + ((nIx == 0 && IsNegativeRealNegative2()) || // 1st, usually positive subformat + (nIx == 1 && IsNegativeRealNegative()))) // 2nd, usually negative subformat { - fNumber = -fNumber; // Vorzeichen eliminieren + fNumber = -fNumber; // eliminate sign } - if(nIx == 0 && - IsNegativeRealNegative2() && fNumber < 0.0) - fNumber = -fNumber; *ppColor = NumFor[nIx].GetColor(); const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); const sal_uInt16 nAnz = NumFor[nIx].GetCount(); commit 5c6dd7a8438f17f768c069f0bcc52d6420aa3e3e Author: Wang Lei <[email protected]> Date: Thu Jun 21 06:27:18 2012 +0000 i#119964 - Number displays different from MS with the same format code Patch by: Zhang Lu Review by: Wang Lei Conflicts: svl/source/numbers/zformat.cxx Change-Id: Id1ce742dc829a7aa8056e3be50e315ea4499ecc6 diff --git a/svl/inc/svl/zformat.hxx b/svl/inc/svl/zformat.hxx index ddb1535..d4bbef7 100644 --- a/svl/inc/svl/zformat.hxx +++ b/svl/inc/svl/zformat.hxx @@ -322,6 +322,18 @@ public: (eOp1 == NUMBERFORMAT_OP_GT && eOp2 == NUMBERFORMAT_OP_LT) || (eOp1 == NUMBERFORMAT_OP_NO && eOp2 == NUMBERFORMAT_OP_NO) ); } + // Whether the first subformat code is really for negative numbers + // or another limit set. + sal_Bool IsNegativeRealNegative2() const + { + return fLimit1 == 0.0 && fLimit2 == 0.0 && + ( (eOp2 == NUMBERFORMAT_OP_GT && eOp1 == NUMBERFORMAT_OP_LT) || + (eOp2 == NUMBERFORMAT_OP_EQ && eOp1 == NUMBERFORMAT_OP_LT) || + (eOp2 == NUMBERFORMAT_OP_GE && eOp1 == NUMBERFORMAT_OP_LT) || + (eOp2 == NUMBERFORMAT_OP_NO && eOp1 == NUMBERFORMAT_OP_LT) || + (eOp2 == NUMBERFORMAT_OP_NO && eOp1 == NUMBERFORMAT_OP_LE) || + (eOp2 == NUMBERFORMAT_OP_GT && eOp1 == NUMBERFORMAT_OP_LE)); + } // Whether the negative format is without a sign or not bool IsNegativeWithoutSign() const; diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 45c1f29..eca7005 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2526,6 +2526,9 @@ bool SvNumberformat::GetOutputString(double fNumber, { fNumber = -fNumber; // Vorzeichen eliminieren } + if(nIx == 0 && + IsNegativeRealNegative2() && fNumber < 0.0) + fNumber = -fNumber; *ppColor = NumFor[nIx].GetColor(); const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); const sal_uInt16 nAnz = NumFor[nIx].GetCount(); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
