sc/qa/unit/ucalc.cxx | 160 ++++++++++++++++++++++++++++++ sc/qa/unit/ucalc.hxx | 4 sc/source/core/data/colorscale.cxx | 99 +++++++++--------- sc/source/filter/oox/condformatbuffer.cxx | 5 sc/source/ui/condformat/condformatdlg.cxx | 4 5 files changed, 220 insertions(+), 52 deletions(-)
New commits: commit 1e8d6bb3e64700b0309bbc3331109d08404972e8 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 06:44:47 2015 +0200 add a few more databar length tests Change-Id: I178a028d65acaf80fdfe23c3911c1f178650b9c1 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 430a1fb..ad0ae3d 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5970,6 +5970,26 @@ void Test::testDataBarLengthAutomaticAxis() testDataBarLengthImpl(m_pDoc, aValues2, ScRange(1,0,0,1,15,0), -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE, 1.0/3.0 * 100, databar::AUTOMATIC); + ScDataBarLengthData aValues3[] = { + { 2, 0.0 }, + { 3, 25.0 }, + { 4, 50.0 }, + { 6, 100.0 }, + { 0, -200 } + }; + testDataBarLengthImpl(m_pDoc, aValues3, ScRange(2,0,0,2,3,0), + 0, COLORSCALE_MIN, 0, COLORSCALE_MAX, 0, databar::AUTOMATIC); + + ScDataBarLengthData aValues4[] = { + { 2, 40.0 }, + { 3, 60.0 }, + { 4, 80.0 }, + { 5, 100.0 }, + { 0, -200 } + }; + testDataBarLengthImpl(m_pDoc, aValues4, ScRange(3,0,0,3,3,0), + 0, COLORSCALE_AUTO, 0, COLORSCALE_AUTO, 0, databar::AUTOMATIC); + m_pDoc->DeleteTab(0); } commit 0b43d4232e0f6eacfdca8334c6cc19eece47d79a Author: Markus Mohrhard <[email protected]> Date: Sun May 17 05:45:20 2015 +0200 add tests for last round of fixes Change-Id: I5c6d079e8da8797edae4f0649524fcd70c84f2bf diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 78e7af6..430a1fb 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5890,7 +5890,7 @@ struct ScDataBarLengthData void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const ScRange& rRange, double nMinVal, ScColorScaleEntryType eMinType, double nMaxVal, ScColorScaleEntryType eMaxType, - double nZeroPos) + double nZeroPos, databar::ScAxisPosition eAxisPos) { ScConditionalFormat* pFormat = new ScConditionalFormat(1, pDoc); ScRangeList aRangeList(rRange); @@ -5902,6 +5902,8 @@ void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const S pFormat->AddEntry(pDatabar); ScDataBarFormatData* pFormatData = new ScDataBarFormatData(); + pFormatData->meAxisPosition = eAxisPos; + pFormatData->mpLowerLimit.reset(new ScColorScaleEntry()); pFormatData->mpLowerLimit->SetValue(nMinVal); pFormatData->mpLowerLimit->SetType(eMinType); @@ -5927,7 +5929,7 @@ void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const S } -void Test::testDataBarLength() +void Test::testDataBarLengthAutomaticAxis() { m_pDoc->InsertTab(0, "Test"); @@ -5944,7 +5946,7 @@ void Test::testDataBarLength() }; testDataBarLengthImpl(m_pDoc, aValues, ScRange(0,0,0,0,7,0), - 3, COLORSCALE_VALUE, 7, COLORSCALE_VALUE, 0.0); + 3, COLORSCALE_VALUE, 7, COLORSCALE_VALUE, 0.0, databar::AUTOMATIC); ScDataBarLengthData aValues2[] = { { -6, -100 }, @@ -5966,7 +5968,52 @@ void Test::testDataBarLength() { 0, -200 } }; testDataBarLengthImpl(m_pDoc, aValues2, ScRange(1,0,0,1,15,0), - -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE, 1.0/3.0 * 100); + -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE, 1.0/3.0 * 100, databar::AUTOMATIC); + + m_pDoc->DeleteTab(0); +} + +void Test::testDataBarLengthMiddleAxis() +{ + m_pDoc->InsertTab(0, "Test"); + + ScDataBarLengthData aValues[] = { + { 1, 25.0 }, + { 2, 25.0 }, + { 3, 37.5 }, + { 4, 50.0 }, + { 5, 62.5 }, + { 6, 75.0 }, + { 7, 87.5 }, + { 8, 100.0 }, + { 9, 100.0 }, + { 0, -200 } + }; + + testDataBarLengthImpl(m_pDoc, aValues, ScRange(0,0,0,0,8,0), + 2, COLORSCALE_VALUE, 8, COLORSCALE_VALUE, 50.0, databar::MIDDLE); + + ScDataBarLengthData aValues2[] = { + { -6, -50 }, + { -5, -50 }, + { -4, -50 }, + { -3, -37.5 }, + { -2, -25.0 }, + { -1, -12.5 }, + { 0, 0.0 }, + { 1, 12.5 }, + { 2, 25.0 }, + { 3, 37.5 }, + { 4, 50.0 }, + { 5, 62.5 }, + { 6, 75.0 }, + { 7, 87.5 }, + { 8, 100.0 }, + { 9, 100.0 }, + { 0, -200 } + }; + testDataBarLengthImpl(m_pDoc, aValues2, ScRange(1,0,0,1,15,0), + -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE, 50.0, databar::MIDDLE); m_pDoc->DeleteTab(0); } diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index ff8356e..a2bd053 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -419,7 +419,8 @@ public: void testCondCopyPasteSheetBetweenDoc(); void testCondCopyPasteSheet(); void testIconSet(); - void testDataBarLength(); + void testDataBarLengthAutomaticAxis(); + void testDataBarLengthMiddleAxis(); void testImportStream(); void testDeleteContents(); @@ -632,7 +633,8 @@ public: CPPUNIT_TEST(testCondCopyPasteSheetBetweenDoc); CPPUNIT_TEST(testCondCopyPasteSheet); CPPUNIT_TEST(testIconSet); - CPPUNIT_TEST(testDataBarLength); + CPPUNIT_TEST(testDataBarLengthAutomaticAxis); + CPPUNIT_TEST(testDataBarLengthMiddleAxis); CPPUNIT_TEST(testImportStream); CPPUNIT_TEST(testDeleteContents); CPPUNIT_TEST(testTransliterateText); commit 2649cbd38433f1e20da167d54b2caf6a69a9be7a Author: Markus Mohrhard <[email protected]> Date: Sun May 17 05:45:07 2015 +0200 a few more databar length fixes Change-Id: I29f27d3a84d16d9d6e9d51c4e86881fff6aa4b96 diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index cf55990..9be59b7 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -936,19 +936,19 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const { pInfo->mnZero = 50; double nAbsMax = std::max(std::abs(nMin), std::abs(nMax)); - if (nValue < 0) + if (nValue < 0 && nMin < 0) { if (nValue < nMin) - pInfo->mnLength = -nMaxLength; + pInfo->mnLength = nMaxLength * (nMin/nAbsMax); else pInfo->mnLength = nMaxLength * (nValue/nAbsMax); } else { if (nValue > nMax) - pInfo->mnLength = nMaxLength; + pInfo->mnLength = nMaxLength * (nMax/nAbsMax); else - pInfo->mnLength = nMaxLength * (nValue/nAbsMax); + pInfo->mnLength = nMaxLength * (std::max(nValue, nMin)/nAbsMax); } } commit 2d09ea9537cababd3ea8d44e5b4225791beac1bc Author: Markus Mohrhard <[email protected]> Date: Sun May 17 05:01:34 2015 +0200 also test zero position Change-Id: I74dac1362acb04453c51d93ce9fd400a4ce22f2f diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 6114eb3..78e7af6 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5889,7 +5889,8 @@ struct ScDataBarLengthData void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const ScRange& rRange, double nMinVal, ScColorScaleEntryType eMinType, - double nMaxVal, ScColorScaleEntryType eMaxType) + double nMaxVal, ScColorScaleEntryType eMaxType, + double nZeroPos) { ScConditionalFormat* pFormat = new ScConditionalFormat(1, pDoc); ScRangeList aRangeList(rRange); @@ -5919,6 +5920,7 @@ void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const S ScDataBarInfo* pInfo = pDatabar->GetDataBarInfo(ScAddress(nCol, i, 0)); CPPUNIT_ASSERT(pInfo); ASSERT_DOUBLES_EQUAL(pData[i].nLength, pInfo->mnLength); + ASSERT_DOUBLES_EQUAL(nZeroPos, pInfo->mnZero); } delete pFormat; } @@ -5942,7 +5944,7 @@ void Test::testDataBarLength() }; testDataBarLengthImpl(m_pDoc, aValues, ScRange(0,0,0,0,7,0), - 3, COLORSCALE_VALUE, 7, COLORSCALE_VALUE); + 3, COLORSCALE_VALUE, 7, COLORSCALE_VALUE, 0.0); ScDataBarLengthData aValues2[] = { { -6, -100 }, @@ -5964,7 +5966,7 @@ void Test::testDataBarLength() { 0, -200 } }; testDataBarLengthImpl(m_pDoc, aValues2, ScRange(1,0,0,1,15,0), - -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE); + -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE, 1.0/3.0 * 100); m_pDoc->DeleteTab(0); } commit 3257372f3434cca2428bfdbc57dd777135c65b34 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 04:53:55 2015 +0200 add more databar length tests Change-Id: I16ea569d360e75290b9b5a54b915c83dd99db759 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 4a76629..6114eb3 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5909,12 +5909,12 @@ void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const S pFormatData->mpUpperLimit->SetType(eMaxType); pDatabar->SetDataBarData(pFormatData); - for (size_t i = 0; pData[i].nVal != 0; ++i) + for (size_t i = 0; pData[i].nLength != -200; ++i) { pDoc->SetValue(nCol, i, 0, pData[i].nVal); } - for (size_t i = 0; pData[i].nVal != 0; ++i) + for (size_t i = 0; pData[i].nLength != -200; ++i) { ScDataBarInfo* pInfo = pDatabar->GetDataBarInfo(ScAddress(nCol, i, 0)); CPPUNIT_ASSERT(pInfo); @@ -5937,12 +5937,35 @@ void Test::testDataBarLength() { 6, 75.0 }, { 7, 100.0 }, { 8, 100.0 }, - { 0, 0 } + { 9, 100.0 }, + { 0, -200 } }; testDataBarLengthImpl(m_pDoc, aValues, ScRange(0,0,0,0,7,0), 3, COLORSCALE_VALUE, 7, COLORSCALE_VALUE); + ScDataBarLengthData aValues2[] = { + { -6, -100 }, + { -5, -100 }, + { -4, -100 }, + { -3, -75.0 }, + { -2, -50.0 }, + { -1, -25.0 }, + { 0, 0.0 }, + { 1, 12.5 }, + { 2, 25.0 }, + { 3, 37.5 }, + { 4, 50.0 }, + { 5, 62.5 }, + { 6, 75.0 }, + { 7, 87.5 }, + { 8, 100.0 }, + { 9, 100.0 }, + { 0, -200 } + }; + testDataBarLengthImpl(m_pDoc, aValues2, ScRange(1,0,0,1,15,0), + -4, COLORSCALE_VALUE, 8, COLORSCALE_VALUE); + m_pDoc->DeleteTab(0); } commit 8ad59d194491af8317b3770e83d93d2e32508947 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 04:53:22 2015 +0200 more databar length bugs fixed Change-Id: I921e6dbbf62c3bd5c3c8552161ba6f5d25a0185b diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 4652587..cf55990 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -912,13 +912,15 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const else pInfo->mnZero = 0; + double nMinNonNegative = std::max(0.0, nMin); + double nMaxNonPositive = std::min(0.0, nMax); //calculate the length if(nValue < 0 && nMin < 0) { if (nValue < nMin) pInfo->mnLength = -100; else - pInfo->mnLength = -100 * (nValue-nMax)/(nMin-nMax); + pInfo->mnLength = -100 * (nValue-nMaxNonPositive)/(nMin-nMaxNonPositive); } else { @@ -927,7 +929,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const else if (nValue <= nMin) pInfo->mnLength = 0; else - pInfo->mnLength = 100 * (nValue-nMin)/(nMax-nMin); + pInfo->mnLength = 100 * (nValue-nMinNonNegative)/(nMax-nMinNonNegative); } } else if( mpFormatData->meAxisPosition == databar::MIDDLE) commit a5f65a5c2836b000bc0b6f92d5a2a3d13133de71 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 03:11:46 2015 +0200 extract code into own method Change-Id: I13fe9fcdbc056480b7eb66304f9ddef48bab3bd4 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index c9a46f8..4a76629 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5879,50 +5879,70 @@ void Test::testIconSet() m_pDoc->DeleteTab(0); } -void Test::testDataBarLength() +namespace { + +struct ScDataBarLengthData { - m_pDoc->InsertTab(0, "Test"); + double nVal; + double nLength; +}; - ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc); - ScRangeList aRangeList(ScRange(0,0,0,0,7,0)); +void testDataBarLengthImpl(ScDocument* pDoc, ScDataBarLengthData* pData, const ScRange& rRange, + double nMinVal, ScColorScaleEntryType eMinType, + double nMaxVal, ScColorScaleEntryType eMaxType) +{ + ScConditionalFormat* pFormat = new ScConditionalFormat(1, pDoc); + ScRangeList aRangeList(rRange); pFormat->SetRange(aRangeList); - ScDataBarFormat* pDatabar = new ScDataBarFormat(m_pDoc); + SCCOL nCol = rRange.aStart.Col(); + + ScDataBarFormat* pDatabar = new ScDataBarFormat(pDoc); pFormat->AddEntry(pDatabar); ScDataBarFormatData* pFormatData = new ScDataBarFormatData(); pFormatData->mpLowerLimit.reset(new ScColorScaleEntry()); - pFormatData->mpLowerLimit->SetValue(3); - pFormatData->mpLowerLimit->SetType(COLORSCALE_VALUE); + pFormatData->mpLowerLimit->SetValue(nMinVal); + pFormatData->mpLowerLimit->SetType(eMinType); pFormatData->mpUpperLimit.reset(new ScColorScaleEntry()); - pFormatData->mpUpperLimit->SetValue(7); - pFormatData->mpUpperLimit->SetType(COLORSCALE_VALUE); + pFormatData->mpUpperLimit->SetValue(nMaxVal); + pFormatData->mpUpperLimit->SetType(eMaxType); pDatabar->SetDataBarData(pFormatData); - struct { - double nVal; double nLength; - } aValues[] = { + for (size_t i = 0; pData[i].nVal != 0; ++i) + { + pDoc->SetValue(nCol, i, 0, pData[i].nVal); + } + + for (size_t i = 0; pData[i].nVal != 0; ++i) + { + ScDataBarInfo* pInfo = pDatabar->GetDataBarInfo(ScAddress(nCol, i, 0)); + CPPUNIT_ASSERT(pInfo); + ASSERT_DOUBLES_EQUAL(pData[i].nLength, pInfo->mnLength); + } + delete pFormat; +} + +} + +void Test::testDataBarLength() +{ + m_pDoc->InsertTab(0, "Test"); + + ScDataBarLengthData aValues[] = { { 2, 0 }, { 3, 0 }, { 4, 25.0 }, { 5, 50.0 }, { 6, 75.0 }, { 7, 100.0 }, - { 8, 100.0 } + { 8, 100.0 }, + { 0, 0 } }; - for (size_t i = 0; i < SAL_N_ELEMENTS(aValues); ++i) - { - m_pDoc->SetValue(0, i, 0, aValues[i].nVal); - } + testDataBarLengthImpl(m_pDoc, aValues, ScRange(0,0,0,0,7,0), + 3, COLORSCALE_VALUE, 7, COLORSCALE_VALUE); - for (size_t i = 0; i < SAL_N_ELEMENTS(aValues); ++i) - { - ScDataBarInfo* pInfo = pDatabar->GetDataBarInfo(ScAddress(0, i, 0)); - CPPUNIT_ASSERT(pInfo); - ASSERT_DOUBLES_EQUAL(aValues[i].nLength, pInfo->mnLength); - } - delete pFormat; m_pDoc->DeleteTab(0); } diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 2369bac..4652587 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -913,7 +913,7 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const pInfo->mnZero = 0; //calculate the length - if(nValue < 0) + if(nValue < 0 && nMin < 0) { if (nValue < nMin) pInfo->mnLength = -100; commit 31719b052740766c43df508999b691af9075aa3d Author: Markus Mohrhard <[email protected]> Date: Sun May 17 03:07:45 2015 +0200 initial test for databar length calculation Change-Id: I6fb47b7987733e4047008430a62f77d58cc592ad diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 6503ddc..c9a46f8 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5879,6 +5879,53 @@ void Test::testIconSet() m_pDoc->DeleteTab(0); } +void Test::testDataBarLength() +{ + m_pDoc->InsertTab(0, "Test"); + + ScConditionalFormat* pFormat = new ScConditionalFormat(1, m_pDoc); + ScRangeList aRangeList(ScRange(0,0,0,0,7,0)); + pFormat->SetRange(aRangeList); + + ScDataBarFormat* pDatabar = new ScDataBarFormat(m_pDoc); + pFormat->AddEntry(pDatabar); + + ScDataBarFormatData* pFormatData = new ScDataBarFormatData(); + pFormatData->mpLowerLimit.reset(new ScColorScaleEntry()); + pFormatData->mpLowerLimit->SetValue(3); + pFormatData->mpLowerLimit->SetType(COLORSCALE_VALUE); + pFormatData->mpUpperLimit.reset(new ScColorScaleEntry()); + pFormatData->mpUpperLimit->SetValue(7); + pFormatData->mpUpperLimit->SetType(COLORSCALE_VALUE); + pDatabar->SetDataBarData(pFormatData); + + struct { + double nVal; double nLength; + } aValues[] = { + { 2, 0 }, + { 3, 0 }, + { 4, 25.0 }, + { 5, 50.0 }, + { 6, 75.0 }, + { 7, 100.0 }, + { 8, 100.0 } + }; + + for (size_t i = 0; i < SAL_N_ELEMENTS(aValues); ++i) + { + m_pDoc->SetValue(0, i, 0, aValues[i].nVal); + } + + for (size_t i = 0; i < SAL_N_ELEMENTS(aValues); ++i) + { + ScDataBarInfo* pInfo = pDatabar->GetDataBarInfo(ScAddress(0, i, 0)); + CPPUNIT_ASSERT(pInfo); + ASSERT_DOUBLES_EQUAL(aValues[i].nLength, pInfo->mnLength); + } + delete pFormat; + m_pDoc->DeleteTab(0); +} + void Test::testImportStream() { sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc. diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 1cec088..ff8356e 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -419,6 +419,7 @@ public: void testCondCopyPasteSheetBetweenDoc(); void testCondCopyPasteSheet(); void testIconSet(); + void testDataBarLength(); void testImportStream(); void testDeleteContents(); @@ -631,6 +632,7 @@ public: CPPUNIT_TEST(testCondCopyPasteSheetBetweenDoc); CPPUNIT_TEST(testCondCopyPasteSheet); CPPUNIT_TEST(testIconSet); + CPPUNIT_TEST(testDataBarLength); CPPUNIT_TEST(testImportStream); CPPUNIT_TEST(testDeleteContents); CPPUNIT_TEST(testTransliterateText); commit a8fc28682da6223520706f990598f58362fad9d5 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 03:07:30 2015 +0200 another databar length calculation bug Change-Id: I164e1da11fe43b87c9fba32249439cbce860da6a diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index d9876eb..2369bac 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -924,6 +924,8 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const { if ( nValue > nMax ) pInfo->mnLength = 100; + else if (nValue <= nMin) + pInfo->mnLength = 0; else pInfo->mnLength = 100 * (nValue-nMin)/(nMax-nMin); } commit de72cead8f8f9e20302b8aa2d174c2359260d1a2 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 03:07:03 2015 +0200 add missing DeleteTab in test Change-Id: I396b9416e60aeba6576be7e3accdc9b2ae6575c4 diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index c5d7a98..6503ddc 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -5876,6 +5876,7 @@ void Test::testIconSet() } delete pEntry; + m_pDoc->DeleteTab(0); } void Test::testImportStream() commit fed568a27f1810beb93fc127ee7392b1a6131628 Author: Markus Mohrhard <[email protected]> Date: Sun May 17 02:12:37 2015 +0200 fix more conditional format crashes, tdf#90982 Change-Id: I009df010f93641310c31031f535d50fb42a655ba diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index e256f74..9f4d302 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -324,6 +324,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox) case condformat::entry::ICONSET: return 0; } + itr->disposeAndClear(); *itr = VclPtr<ScColorScale3FrmtEntry>::Create(this, mpDoc, maPos); mpDialogParent->InvalidateRefData(); (*itr)->SetActive(); @@ -332,6 +333,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox) if((*itr)->GetType() == condformat::entry::CONDITION) return 0; + itr->disposeAndClear(); *itr = VclPtr<ScConditionFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos); mpDialogParent->InvalidateRefData(); (*itr)->SetActive(); @@ -340,6 +342,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox) if((*itr)->GetType() == condformat::entry::FORMULA) return 0; + itr->disposeAndClear(); *itr = VclPtr<ScFormulaFrmtEntry>::Create(this, mpDoc, mpDialogParent, maPos); mpDialogParent->InvalidateRefData(); (*itr)->SetActive(); @@ -348,6 +351,7 @@ IMPL_LINK(ScCondFormatList, AfterTypeListHdl, ListBox*, pBox) if((*itr)->GetType() == condformat::entry::DATE) return 0; + itr->disposeAndClear(); *itr = VclPtr<ScDateFrmtEntry>::Create( this, mpDoc ); mpDialogParent->InvalidateRefData(); (*itr)->SetActive(); commit 01f29d865e62f6a5371f4459c66f035e56326f5b Author: Markus Mohrhard <[email protected]> Date: Sat May 16 20:22:00 2015 +0200 fix incorrect databar length calculation Change-Id: I8d6fda8b78daa228fff62f2af8f5f14c7aa03312 diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 35d0cf7..d9876eb 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -892,8 +892,12 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const } else if (mpFormatData->meAxisPosition == databar::AUTOMATIC) { - double nMaxNegative = 0; - double nMinPositive = 0; + // if auto is used we may need to adjust it + // for the length calculation + if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_AUTO && nMin > 0) + nMin = 0; + if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) + nMax = 0; //calculate the zero position first if(nMin < 0) @@ -908,27 +912,20 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const else pInfo->mnZero = 0; - // if max or min is used we may need to adjust it - // for the length calculation - if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0) - nMinPositive = nMin; - if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) - nMaxNegative = nMax; - //calculate the length if(nValue < 0) { if (nValue < nMin) pInfo->mnLength = -100; else - pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative); + pInfo->mnLength = -100 * (nValue-nMax)/(nMin-nMax); } else { if ( nValue > nMax ) pInfo->mnLength = 100; else - pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100; + pInfo->mnLength = 100 * (nValue-nMin)/(nMax-nMin); } } else if( mpFormatData->meAxisPosition == databar::MIDDLE) commit c35dc39928824fc258080dd1ba2eb0569559e544 Author: Markus Mohrhard <[email protected]> Date: Sat May 16 20:01:31 2015 +0200 little refactoring in databar code Change-Id: Icf2943604106440ff0b1979ebe10497f01fea784 diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 176b1c8..35d0cf7 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -890,66 +890,64 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const } pInfo->mnZero = 0; } - else + else if (mpFormatData->meAxisPosition == databar::AUTOMATIC) { - double nMinPositive = 0; double nMaxNegative = 0; + double nMinPositive = 0; + //calculate the zero position first - if(mpFormatData->meAxisPosition == databar::AUTOMATIC) + if(nMin < 0) { - if(nMin < 0) + if(nMax < 0) + pInfo->mnZero = 100; + else { - if(nMax < 0) - pInfo->mnZero = 100; - else - { - pInfo->mnZero = -100*nMin/(nMax-nMin); - } + pInfo->mnZero = -100*nMin/(nMax-nMin); } - else - pInfo->mnZero = 0; + } + else + pInfo->mnZero = 0; - // if max or min is used we may need to adjust it - // for the length calculation - if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0) - nMinPositive = nMin; - if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) - nMaxNegative = nMax; + // if max or min is used we may need to adjust it + // for the length calculation + if (mpFormatData->mpLowerLimit->GetType() == COLORSCALE_MIN && nMin > 0) + nMinPositive = nMin; + if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0) + nMaxNegative = nMax; - //calculate the length - if(nValue < 0) - { - if (nValue < nMin) - pInfo->mnLength = -100; - else - pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative); - } + //calculate the length + if(nValue < 0) + { + if (nValue < nMin) + pInfo->mnLength = -100; else - { - if ( nValue > nMax ) - pInfo->mnLength = 100; - else - pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100; - } + pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative); } - else if( mpFormatData->meAxisPosition == databar::MIDDLE) + else { - pInfo->mnZero = 50; - double nAbsMax = std::max(std::abs(nMin), std::abs(nMax)); - if (nValue < 0) - { - if (nValue < nMin) - pInfo->mnLength = -nMaxLength; - else - pInfo->mnLength = nMaxLength * (nValue/nAbsMax); - } + if ( nValue > nMax ) + pInfo->mnLength = 100; else - { - if (nValue > nMax) - pInfo->mnLength = nMaxLength; - else - pInfo->mnLength = nMaxLength * (nValue/nAbsMax); - } + pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100; + } + } + else if( mpFormatData->meAxisPosition == databar::MIDDLE) + { + pInfo->mnZero = 50; + double nAbsMax = std::max(std::abs(nMin), std::abs(nMax)); + if (nValue < 0) + { + if (nValue < nMin) + pInfo->mnLength = -nMaxLength; + else + pInfo->mnLength = nMaxLength * (nValue/nAbsMax); + } + else + { + if (nValue > nMax) + pInfo->mnLength = nMaxLength; + else + pInfo->mnLength = nMaxLength * (nValue/nAbsMax); } } commit 598f0e26c16f18b6ea03ef1e0e6d7d9dddf6d10f Author: Markus Mohrhard <[email protected]> Date: Sat May 16 16:47:37 2015 +0200 don't use alpha for now in cond format OOXML colors Change-Id: I1be02cf847b75352ef4c013265ef62a2d7af341c diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 927513c..955b304 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -164,12 +164,13 @@ namespace { ::Color ARgbToARgbComponents( sal_uInt32& nRgb ) { - sal_Int32 ornA = 255 - ((nRgb >> 24) & 0xFF); + // sal_Int32 ornA = 255 - ((nRgb >> 24) & 0xFF); + // sal_Int32 ornR = (nRgb >> 16) & 0xFF; sal_Int32 ornG = (nRgb >> 8) & 0xFF; sal_Int32 ornB = nRgb & 0xFF; - return ::Color(ornA, ornR, ornG, ornB); + return ::Color(/*ornA*/ 0, ornR, ornG, ornB); } ::Color importOOXColor(const AttributeList& rAttribs, ThemeBuffer& rThemeBuffer, GraphicHelper& rGraphicHelper) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
