diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-10-05 22:50:34 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-10-06 00:26:41 +0200 |
commit | 3cb337fdcf0c502875c25405c1012713b1b86152 (patch) | |
tree | 2b4faff6a77b655d73098cf944265881b4a064e7 | |
parent | 7152dd8ebfa93e4d7ebe84998fa0ce5fbe43966c (diff) |
adpat ScTable methods to overlapping conditional formats
Change-Id: I2f63ac7884f0897aa47fd4ee35b8af06553c311c
-rw-r--r-- | sc/inc/document.hxx | 1 | ||||
-rw-r--r-- | sc/inc/table.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/documen4.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/table1.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/table2.cxx | 67 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 17 | ||||
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 3 |
7 files changed, 36 insertions, 64 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 684a16a16165..51a549390524 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1190,7 +1190,6 @@ public: SC_DLLPUBLIC sal_uLong AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab ); void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab ); - SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab ); void ConditionalChanged( sal_uLong nKey, SCTAB nTab ); void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab ); diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 757f3576d3c5..e4d7ba0a2876 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -778,8 +778,6 @@ public: SCCOL nCol, SCROW nRowStart, SCROW nRowEnd ) const; - void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges ) const; - void IncRecalcLevel(); void DecRecalcLevel( bool bUpdateNoteCaptionPos = true ); diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 1a21d690722a..3295106f40d1 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -738,12 +738,6 @@ const ScValidationData* ScDocument::GetValidationEntry( sal_uLong nIndex ) const return NULL; } -void ScDocument::FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab ) -{ - if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) - maTabs[nTab]->FindConditionalFormat( nKey, rRanges ); -} - void ScDocument::DeleteConditionalFormat(sal_uLong nOldIndex, SCTAB nTab) { if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 2e1dfbdd595d..6d61bd7b4b23 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -1790,9 +1790,7 @@ void ScTable::MaybeAddExtraColumn(SCCOL& rCol, SCROW nRow, OutputDevice* pDev, d // look at alignment const ScPatternAttr* pPattern = GetPattern( rCol, nRow ); - const SfxItemSet* pCondSet = NULL; - if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ) - pCondSet = pDocument->GetCondResult( rCol, nRow, nTab ); + const SfxItemSet* pCondSet = pDocument->GetCondResult( rCol, nRow, nTab ); SvxCellHorJustify eHorJust = (SvxCellHorJustify)((const SvxHorJustifyItem&) pPattern->GetItem( ATTR_HOR_JUSTIFY, pCondSet )).GetValue(); diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index e3d386447221..dbd65eb8d926 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -664,12 +664,13 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO ScAttrIterator* pIter = pTable->aCol[i-nDx].CreateAttrIterator( nRow1-nDy, nRow2-nDy ); SCROW nStartRow = 0, nEndRow = 0; const ScPatternAttr* pPattern = pIter->Next( nStartRow, nEndRow ); - sal_uInt32 nId = ((SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue(); - if ( nId != 0) + const std::vector<sal_uInt32>& rCondFormatData = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData(); + for(std::vector<sal_uInt32>::const_iterator itr = rCondFormatData.begin(), itrEnd = rCondFormatData.end(); + itr != itrEnd; ++itr) { - if (aOldIdToNewId.find(nId) == aOldIdToNewId.end()) + if (aOldIdToNewId.find(*itr) == aOldIdToNewId.end()) { - ScConditionalFormat* pFormat = pOldCondFormatList->GetFormat(nId); + ScConditionalFormat* pFormat = pOldCondFormatList->GetFormat(*itr); if(!pFormat) { // may happen in some strange circumstances where cell storage and @@ -680,20 +681,20 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO pNewFormat->SetKey(0); //not in list => create entries in both maps and new format sal_uLong nMax = 0; - for(ScConditionalFormatList::const_iterator itr = mpCondFormatList->begin(); - itr != mpCondFormatList->end(); ++itr) + for(ScConditionalFormatList::const_iterator itrCond = mpCondFormatList->begin(); + itrCond != mpCondFormatList->end(); ++itrCond) { - if(itr->GetKey() > nMax) - nMax = itr->GetKey(); + if(itrCond->GetKey() > nMax) + nMax = itrCond->GetKey(); } pNewFormat->SetKey(nMax + 1); mpCondFormatList->InsertNew(pNewFormat); sal_Int32 nNewId = pNewFormat->GetKey(); - aOldIdToNewId.insert( std::pair<sal_Int32, sal_Int32>( nId, nNewId ) ); - aIdToRange.insert( std::pair<sal_Int32, ScRangeList>( nId, ScRangeList() ) ); + aOldIdToNewId.insert( std::pair<sal_Int32, sal_Int32>( *itr, nNewId ) ); + aIdToRange.insert( std::pair<sal_Int32, ScRangeList>( *itr, ScRangeList() ) ); } - aIdToRange.find(nId)->second.Join( ScRange( i, nStartRow + nDy, nTab, i, nEndRow + nDy, nTab ) ); + aIdToRange.find(*itr)->second.Join( ScRange( i, nStartRow + nDy, nTab, i, nEndRow + nDy, nTab ) ); } } @@ -709,11 +710,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO nDx, nDy, pTable->nTab - nTab); pFormat->AddRange(itr->second); - ScPatternAttr aPattern( pDocument->GetPool() ); - aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nNewKey ) ); - ScMarkData aMarkData; - aMarkData.MarkFromRangeList(itr->second, true); - pDocument->ApplySelectionPattern( aPattern, aMarkData ); + pDocument->AddCondFormatData( itr->second, nTab, nNewKey ); } } @@ -1762,31 +1759,35 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC // alle Formate durchgehen, damit die Zellen nicht einzeln // angeschaut werden muessen - sal_uLong nIndex = ((const SfxUInt32Item*)pCondItem)->GetValue(); + const std::vector<sal_uInt32>& rCondFormatData = static_cast<const ScCondFormatItem*>(pCondItem)->GetCondFormatData(); ScStyleSheetPool* pStylePool = pDocument->GetStyleSheetPool(); - if (mpCondFormatList && pStylePool && nIndex) + if (mpCondFormatList && pStylePool && !rCondFormatData.empty()) { - const ScConditionalFormat* pFormat = mpCondFormatList->GetFormat(nIndex); - if ( pFormat ) + for(std::vector<sal_uInt32>::const_iterator itr = rCondFormatData.begin(), itrEnd = rCondFormatData.end(); + itr != itrEnd; ++itr) { - size_t nEntryCount = pFormat->size(); - for (size_t nEntry=0; nEntry<nEntryCount; nEntry++) + const ScConditionalFormat* pFormat = mpCondFormatList->GetFormat(*itr); + if ( pFormat ) { - const ScFormatEntry* pEntry = pFormat->GetEntry(nEntry); - if(pEntry->GetType() != condformat::CONDITION) - continue; - - String aStyleName = static_cast<const ScCondFormatEntry*>(pEntry)->GetStyle(); - if (aStyleName.Len()) + size_t nEntryCount = pFormat->size(); + for (size_t nEntry=0; nEntry<nEntryCount; nEntry++) { - SfxStyleSheetBase* pStyleSheet = - pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); - if ( pStyleSheet ) + const ScFormatEntry* pEntry = pFormat->GetEntry(nEntry); + if(pEntry->GetType() != condformat::CONDITION) + continue; + + String aStyleName = static_cast<const ScCondFormatEntry*>(pEntry)->GetStyle(); + if (aStyleName.Len()) { - FillMaxRot( pRowInfo, nArrCount, nX1, nX2, + SfxStyleSheetBase* pStyleSheet = + pStylePool->Find( aStyleName, SFX_STYLE_FAMILY_PARA ); + if ( pStyleSheet ) + { + FillMaxRot( pRowInfo, nArrCount, nX1, nX2, nCol, nAttrRow1, nAttrRow2, nArrY, pPattern, &pStyleSheet->GetItemSet() ); - // nArrY nicht veraendern + // nArrY nicht veraendern + } } } } diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index 7688b4e4f825..2e1c57d0380b 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -2302,23 +2302,6 @@ void ScTable::UpdateSelectionFunction( ScFunctionData& rData, aCol[nCol].UpdateAreaFunction( rData, *mpHiddenRows, nStartRow, nEndRow ); } -void ScTable::FindConditionalFormat( sal_uLong nKey, ScRangeList& rList ) const -{ - SCROW nStartRow = 0, nEndRow = 0; - for (SCCOL nCol=0; nCol<=MAXCOL; nCol++) - { - ScAttrIterator* pIter = aCol[nCol].CreateAttrIterator( 0, MAXROW ); - const ScPatternAttr* pPattern = pIter->Next( nStartRow, nEndRow ); - while (pPattern) - { - if (((SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() == nKey) - rList.Join( ScRange(nCol,nStartRow,nTab, nCol,nEndRow,nTab) ); - pPattern = pIter->Next( nStartRow, nEndRow ); - } - delete pIter; - } -} - void ScTable::IncRecalcLevel() { ++nRecalcLvl; diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index abca86f96d68..2cac520d7063 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -973,8 +973,7 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat XclExpRecord( EXC_ID_CONDFMT ), XclExpRoot( rRoot ) { - ScRangeList aScRanges; - GetDoc().FindConditionalFormat( rCondFormat.GetKey(), aScRanges, GetCurrScTab() ); + ScRangeList aScRanges = rCondFormat.GetRange(); GetAddressConverter().ConvertRangeList( maXclRanges, aScRanges, true ); if( !maXclRanges.empty() ) { |