sc/source/core/data/colorscale.cxx | 5 +++-- sc/source/core/data/documen4.cxx | 3 ++- sc/source/filter/oox/condformatbuffer.cxx | 25 ++++++++++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-)
New commits: commit 9cfab5c687b337b035179561af49c16eea93b459 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Wed May 9 06:17:47 2012 +0200 index is 1-based in this case Change-Id: I74aae3f422423de09cb012e274f8d536f8b778f1 diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 4e74d1e..787690d 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -148,12 +148,13 @@ void ScColorScaleFormatList::AddFormat( ScColorScaleFormat* pFormat ) maColorScaleFormats.push_back( pFormat ); } +// attention nFormat is 1 based, 0 is reserved for no format ScColorScaleFormat* ScColorScaleFormatList::GetFormat(sal_uInt32 nFormat) { - if( nFormat >= size() ) + if( nFormat > size() || !nFormat ) return NULL; - return &maColorScaleFormats[nFormat]; + return &maColorScaleFormats[nFormat-1]; } ScColorScaleFormatList::iterator ScColorScaleFormatList::begin() diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 7df52cc..b936699 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -629,6 +629,7 @@ sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew ) } //takes ownership +// returns a 1-based index, 0 is reserved for no entry sal_uLong ScDocument::AddColorScaleFormat( ScColorScaleFormat* pNew ) { if(!pNew) @@ -639,7 +640,7 @@ sal_uLong ScDocument::AddColorScaleFormat( ScColorScaleFormat* pNew ) mpColorScaleList->AddFormat( pNew ); - return mpColorScaleList->size()-1; + return mpColorScaleList->size(); } sal_uLong ScDocument::AddValidationEntry( const ScValidationData& rNew ) commit a2a9f197f3f3e16ef5efa1d9c35e0d1fee4e3c71 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Wed May 9 06:15:34 2012 +0200 apply color scale to area during xlsx import Change-Id: I8f616c85df0e9d33c74c7354dfcadbf55bb91dc7 diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 7292245..e189c75 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/table/CellRangeAddress.hpp> #include <com/sun/star/table/XCellRange.hpp> #include <rtl/ustrbuf.hxx> +#include <svl/intitem.hxx> #include "oox/helper/attributelist.hxx" #include "oox/helper/containerhelper.hxx" #include "oox/helper/propertyset.hxx" @@ -50,8 +51,15 @@ #include "addressconverter.hxx" #include "biffinputstream.hxx" #include "stylesbuffer.hxx" + #include "colorscale.hxx" #include "document.hxx" +#include "convuno.hxx" +#include "docsh.hxx" +#include "docfunc.hxx" +#include "markdata.hxx" +#include "docpool.hxx" +#include "scitems.hxx" #include <iostream> @@ -654,7 +662,22 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > ScColorScaleFormat* pFormat = new ScColorScaleFormat(); mpColor->AddEntries( pFormat ); - rDoc.AddColorScaleFormat(pFormat); + sal_Int32 nIndex = rDoc.AddColorScaleFormat(pFormat); + + // apply attributes to cells + // + const ApiCellRangeList& rRanges = mrCondFormat.getRanges(); + for( ApiCellRangeList::const_iterator itr = rRanges.begin(); itr != rRanges.end(); ++itr) + { + ScRange aRange; + ScUnoConversion::FillScRange(aRange, *itr); + ScPatternAttr aPattern( rDoc.GetPool() ); + aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_COLORSCALE, nIndex ) ); + ScDocShell* pShell = static_cast<ScDocShell*>(rDoc.GetDocumentShell()); + ScMarkData aMarkData; + aMarkData.SetMarkArea(aRange); + pShell->GetDocFunc().ApplyAttributes( aMarkData, aPattern, sal_True, sal_True ); + } } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits