[Libreoffice-commits] core.git: 4 commits - sc/qa sc/source
Markus Mohrhard
markus.mohrhard at googlemail.com
Wed May 13 20:33:55 PDT 2015
sc/qa/unit/data/xlsx/cond_format_theme_color2.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 23 +++++++++++
sc/source/core/data/colorscale.cxx | 43 ++++++++++++++-------
sc/source/filter/oox/condformatbuffer.cxx | 7 +++
sc/source/ui/condformat/colorformat.cxx | 2
5 files changed, 61 insertions(+), 14 deletions(-)
New commits:
commit 571bbac2c738d96f61464b04e0e63a4fc0531b8d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 14 05:30:54 2015 +0200
now we also support axis min length and max length for middle
Change-Id: Ie4ce5906094386d68be46c03d9fb0c75b2663947
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index 37bae8c..cfae7b7 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -335,7 +335,7 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, TypeSelectHdl )
IMPL_LINK_NOARG( ScDataBarSettingsDlg, PosSelectHdl )
{
sal_Int32 axisPos = mpLbAxisPos->GetSelectEntryPos();
- if(axisPos != 2) // disable if axis vertical position is anything other than none
+ if(axisPos != 2 && axisPos != 1) // disable if axis vertical position is automatic
{
mpLenMin->Disable();
mpLenMax->Disable();
commit 8d7a4416f5c1ea2610164e533ab17590605adddc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 14 05:28:30 2015 +0200
fixes and improvements for databar length calculation
Now min length and max length are also respected when the axis is in the
middle.
Additionally when the axis is in the middle we now scale the negative
and the positive part with the same factor. This is better for itnerop
and makes more sense.
Change-Id: If4c1adc0977d8ed66b8f22d937b0b3933288d012
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index c41fc68..9ef4aea 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -915,24 +915,41 @@ ScDataBarInfo* ScDataBarFormat::GetDataBarInfo(const ScAddress& rAddr) const
nMinPositive = nMin;
if (mpFormatData->mpUpperLimit->GetType() == COLORSCALE_MAX && nMax < 0)
nMaxNegative = nMax;
- }
- else if( mpFormatData->meAxisPosition == databar::MIDDLE)
- pInfo->mnZero = 50;
- //calculate the length
- if(nValue < 0)
- {
- if (nValue < nMin)
- pInfo->mnLength = -100;
+ //calculate the length
+ if(nValue < 0)
+ {
+ if (nValue < nMin)
+ pInfo->mnLength = -100;
+ else
+ pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative);
+ }
else
- pInfo->mnLength = -100 * (nValue-nMaxNegative)/(nMin-nMaxNegative);
+ {
+ if ( nValue > nMax )
+ pInfo->mnLength = 100;
+ else
+ pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100;
+ }
}
- else
+ else if( mpFormatData->meAxisPosition == databar::MIDDLE)
{
- if ( nValue > nMax )
- pInfo->mnLength = 100;
+ 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
- pInfo->mnLength = (nValue-nMinPositive)/(nMax-nMinPositive)*100;
+ {
+ if (nValue > nMax)
+ pInfo->mnLength = nMaxLength;
+ else
+ pInfo->mnLength = nMaxLength * (nValue/nAbsMax);
+ }
}
}
commit 6439999fcb7d359fda57e3e5d51474a94d70ab57
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 14 04:42:02 2015 +0200
add test for negative data bar theme color
Includes test for work-around for Excel bug.
Change-Id: Iee51241725c827b20b1ecaa8b5dc8144860749c2
diff --git a/sc/qa/unit/data/xlsx/cond_format_theme_color2.xlsx b/sc/qa/unit/data/xlsx/cond_format_theme_color2.xlsx
new file mode 100644
index 0000000..61c0d58
Binary files /dev/null and b/sc/qa/unit/data/xlsx/cond_format_theme_color2.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 12bb93a..1ec7460 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -135,6 +135,7 @@ public:
void testNewCondFormatODS();
void testNewCondFormatXLSX();
void testCondFormatThemeColorXLSX();
+ void testCondFormatThemeColor2XLSX(); // negative bar color and axis color
void testLiteralInFormulaXLS();
@@ -242,6 +243,7 @@ public:
CPPUNIT_TEST(testNewCondFormatODS);
CPPUNIT_TEST(testNewCondFormatXLSX);
CPPUNIT_TEST(testCondFormatThemeColorXLSX);
+ CPPUNIT_TEST(testCondFormatThemeColor2XLSX);
CPPUNIT_TEST(testLiteralInFormulaXLS);
CPPUNIT_TEST(testNumberFormatHTML);
@@ -2380,6 +2382,27 @@ void ScFiltersTest::testCondFormatThemeColorXLSX()
CPPUNIT_ASSERT_EQUAL(Color(157, 195, 230), pColorScaleEntry->GetColor());
}
+void ScFiltersTest::testCondFormatThemeColor2XLSX()
+{
+ ScDocShellRef xDocSh = ScBootstrapFixture::loadDoc( "cond_format_theme_color2.", XLSX );
+
+ CPPUNIT_ASSERT_MESSAGE("Failed to load cond_format_theme_color2.xlsx", xDocSh.Is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+ ScConditionalFormat* pFormat = rDoc.GetCondFormat(5, 5, 0);
+ CPPUNIT_ASSERT(pFormat);
+ const ScFormatEntry* pEntry = pFormat->GetEntry(0);
+ CPPUNIT_ASSERT(pEntry);
+ CPPUNIT_ASSERT_EQUAL(pEntry->GetType(), condformat::DATABAR);
+ const ScDataBarFormat* pDataBar = static_cast<const ScDataBarFormat*>(pEntry);
+ const ScDataBarFormatData* pDataBarFormatData = pDataBar->GetDataBarData();
+
+ CPPUNIT_ASSERT_EQUAL(Color(99, 142, 198), pDataBarFormatData->maPositiveColor);
+ CPPUNIT_ASSERT(pDataBarFormatData->mpNegativeColor.get());
+ CPPUNIT_ASSERT_EQUAL(Color(217, 217, 217), *pDataBarFormatData->mpNegativeColor.get());
+ CPPUNIT_ASSERT_EQUAL(Color(197, 90, 17), pDataBarFormatData->maAxisColor);
+}
+
void ScFiltersTest::testLiteralInFormulaXLS()
{
ScDocShellRef xDocSh = loadDoc("shared-string/literal-in-formula.", XLS);
commit 83120950d5138577185598f5eaf8a267d2244dd1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu May 14 04:25:52 2015 +0200
work around Excel bug with negative bar theme based color
Change-Id: Id1276dc0e68b46158b750c96aad8afc24fb18743
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index a5c42f3..16946aa 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -179,6 +179,13 @@ namespace {
else if( rAttribs.hasAttribute( XML_theme ) )
{
sal_uInt32 nThemeIndex = rAttribs.getUnsigned( XML_theme, 0 );
+
+ // looks like an Excel bug
+ if (nThemeIndex == 0)
+ nThemeIndex = 1;
+ else if (nThemeIndex == 1)
+ nThemeIndex = 0;
+
nColor = rThemeBuffer.getColorByIndex( nThemeIndex );
}
More information about the Libreoffice-commits
mailing list