diff options
26 files changed, 328 insertions, 300 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index ed8eb3bbc3ee..20b47abe25e5 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -245,8 +245,6 @@ private: VirtualDevice* pVirtualDevice_100th_mm; ScDrawLayer* pDrawLayer; // SdrModel rtl::Reference<XColorList> pColorList; - ScConditionalFormatList* pCondFormList; // conditional formats - boost::scoped_ptr<ScColorFormatList> mpColorScaleList; //color scales ScValidationDataList* pValidationList; // validity SvNumberFormatterIndexTable* pFormatExchangeList; // for application of number formats TableContainer maTabs; @@ -1198,22 +1196,21 @@ public: void ClearSelectionItems( const sal_uInt16* pWhich, const ScMarkData& rMark ); void ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark ); - SC_DLLPUBLIC sal_uLong AddCondFormat( const ScConditionalFormat& rNew ); - SC_DLLPUBLIC sal_uLong AddColorFormat( ScColorFormat* pNew ); - SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges ); + SC_DLLPUBLIC sal_uLong AddCondFormat( const ScConditionalFormat& rNew, SCTAB nTab ); + SC_DLLPUBLIC sal_uLong AddColorFormat( ScColorFormat* pNew, SCTAB nTab ); + SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, SCTAB nTab, ScRangeList& rRanges ); SC_DLLPUBLIC void FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab ); - void ConditionalChanged( sal_uLong nKey ); + void ConditionalChanged( sal_uLong nKey, SCTAB nTab ); SC_DLLPUBLIC sal_uLong AddValidationEntry( const ScValidationData& rNew ); SC_DLLPUBLIC const ScValidationData* GetValidationEntry( sal_uLong nIndex ) const; - ScConditionalFormatList* GetCondFormList() const // Ref-Undo - { return pCondFormList; } - void SetCondFormList(ScConditionalFormatList* pNew); + SC_DLLPUBLIC ScConditionalFormatList* GetCondFormList( SCTAB nTab ) const; + void SetCondFormList(ScConditionalFormatList* pNew, SCTAB nTab); - SC_DLLPUBLIC const ScColorFormatList* GetColorScaleList() const; - SC_DLLPUBLIC ScColorFormatList* GetColorScaleList(); + SC_DLLPUBLIC const ScColorFormatList* GetColorScaleList(SCTAB nTab) const; + SC_DLLPUBLIC ScColorFormatList* GetColorScaleList(SCTAB nTab); ScValidationDataList* GetValidationList() const { return pValidationList; } diff --git a/sc/inc/fmtuno.hxx b/sc/inc/fmtuno.hxx index 6632ce25e7df..003806a2f8a5 100644 --- a/sc/inc/fmtuno.hxx +++ b/sc/inc/fmtuno.hxx @@ -94,7 +94,7 @@ private: ScTableConditionalFormat(); // disable public: ScTableConditionalFormat(ScDocument* pDoc, sal_uLong nKey, - formula::FormulaGrammar::Grammar eGrammar); + SCTAB nTab, formula::FormulaGrammar::Grammar eGrammar); virtual ~ScTableConditionalFormat(); void FillFormat( ScConditionalFormat& rFormat, ScDocument* pDoc, diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index d684c8ff6015..397da579b096 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -73,6 +73,10 @@ class ScProgress; class ScRangeList; class ScSheetEvents; class ScSortInfoArray; +class ScColorFormatList; +class ScColorFormat; +class ScConditionalFormat; +class ScConditionalFormatList; class ScStyleSheet; class ScTableLink; class ScTableProtection; @@ -169,6 +173,9 @@ private: ScDBData* pDBDataNoName; mutable ScRangeName* mpRangeName; + boost::scoped_ptr<ScConditionalFormatList> mpCondFormatList; + boost::scoped_ptr<ScColorFormatList> mpColorFormatList; + ScNotes maNotes; bool bScenario:1; @@ -792,6 +799,16 @@ public: ScRangeName* GetRangeName() const; void UpdateMoveTab(SCTAB nOldPos,SCTAB nNewPos); + ScConditionalFormatList* GetCondFormList(); + const ScConditionalFormatList* GetCondFormList() const; + void SetCondFormList(ScConditionalFormatList* pNew); + + sal_uLong AddCondFormat( const ScConditionalFormat& rNew ); + sal_uLong AddColorFormat( ScColorFormat* pNew ); + ScColorFormatList* GetColorFormatList(); + const ScColorFormatList* GetColorFormatList() const; + + private: void FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index f201e5d82bf2..0a594dd37f01 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -151,9 +151,9 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern, bool bAlloc ) if ( &pPattern->GetItem(ATTR_CONDITIONAL) != &pOldPattern->GetItem(ATTR_CONDITIONAL) ) { pDocument->ConditionalChanged( ((const SfxUInt32Item&) - pOldPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ); + pOldPattern->GetItem(ATTR_CONDITIONAL)).GetValue(), nTab ); pDocument->ConditionalChanged( ((const SfxUInt32Item&) - pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() ); + pPattern->GetItem(ATTR_CONDITIONAL)).GetValue(), nTab ); } pDocPool->Remove(*pOldPattern); } @@ -376,9 +376,9 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern if ( &rNewSet.Get(ATTR_CONDITIONAL) != &rOldSet.Get(ATTR_CONDITIONAL) ) { pDocument->ConditionalChanged( ((const SfxUInt32Item&) - rOldSet.Get(ATTR_CONDITIONAL)).GetValue() ); + rOldSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab ); pDocument->ConditionalChanged( ((const SfxUInt32Item&) - rNewSet.Get(ATTR_CONDITIONAL)).GetValue() ); + rNewSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab ); } ns = pData[nx].nRow + 1; nx++; @@ -781,9 +781,9 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac if ( &rNewSet.Get(ATTR_CONDITIONAL) != &rOldSet.Get(ATTR_CONDITIONAL) ) { pDocument->ConditionalChanged( ((const SfxUInt32Item&) - rOldSet.Get(ATTR_CONDITIONAL)).GetValue() ); + rOldSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab ); pDocument->ConditionalChanged( ((const SfxUInt32Item&) - rNewSet.Get(ATTR_CONDITIONAL)).GetValue() ); + rNewSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab ); } pDocument->GetPool()->Remove(*pData[nPos].pPattern); diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx index 5c13b90b9548..bbf3beb64a69 100644 --- a/sc/source/core/data/conditio.cxx +++ b/sc/source/core/data/conditio.cxx @@ -1446,7 +1446,7 @@ void ScConditionalFormat::DoRepaint( const ScRange* pModified ) if (!pAreas) // RangeList ggf. holen { pAreas = new ScRangeList; - pDoc->FindConditionalFormat( nKey, *pAreas ); + pDoc->FindConditionalFormat( nKey, pRanges->front()->aStart.Tab(), *pAreas ); } for (size_t i = 0, nCount = pAreas->size(); i < nCount; i++ ) { diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 0135892d8ad7..158c7312bfb3 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -135,7 +135,6 @@ ScDocument::ScDocument( ScDocumentMode eMode, pPrinter( NULL ), pVirtualDevice_100th_mm( NULL ), pDrawLayer( NULL ), - pCondFormList( NULL ), pValidationList( NULL ), pFormatExchangeList( NULL ), pRangeName(NULL), @@ -409,10 +408,6 @@ ScDocument::~ScDocument() Clear( true ); // true = from destructor (needed for SdrModel::ClearModel) - if (pCondFormList) - { - DELETEZ(pCondFormList); - } if (pValidationList) { pValidationList->DeleteAndDestroy( 0, pValidationList->Count() ); @@ -456,10 +451,6 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc ) { OSL_ENSURE(bIsClip, "InitClipPtrs und nicht bIsClip"); - if (pCondFormList) - { - DELETEZ(pCondFormList); - } if (pValidationList) { pValidationList->DeleteAndDestroy( 0, pValidationList->Count() ); @@ -472,14 +463,6 @@ void ScDocument::InitClipPtrs( ScDocument* pSourceDoc ) // bedingte Formate / Gueltigkeiten //! Vorlagen kopieren? - const ScConditionalFormatList* pSourceCond = pSourceDoc->pCondFormList; - if ( pSourceCond ) - pCondFormList = new ScConditionalFormatList(this, *pSourceCond); - - const ScColorFormatList* pSourceColorScaleList = pSourceDoc->mpColorScaleList.get(); - if ( pSourceColorScaleList ) - mpColorScaleList.reset(new ScColorFormatList(this, *pSourceColorScaleList)); - const ScValidationDataList* pSourceValid = pSourceDoc->pValidationList; if ( pSourceValid ) pValidationList = new ScValidationDataList(this, *pSourceValid); @@ -756,10 +739,6 @@ bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress ) UpdateChartRef( URM_REORDER, 0,0,nOldPos, MAXCOL,MAXROW,nOldPos, 0,0,nDz ); UpdateRefAreaLinks( URM_REORDER, aSourceRange, 0,0,nDz ); - if ( pCondFormList ) - pCondFormList->UpdateMoveTab( nOldPos, nNewPos ); - if ( mpColorScaleList ) - mpColorScaleList->UpdateMoveTab( nOldPos, nNewPos ); if ( pValidationList ) pValidationList->UpdateMoveTab( nOldPos, nNewPos ); if ( pUnoBroadcaster ) @@ -868,11 +847,6 @@ bool ScDocument::CopyTab( SCTAB nOldPos, SCTAB nNewPos, const ScMarkData* pOnlyM if (*it && it != maTabs.begin()+nOldPos && it != maTabs.begin()+nNewPos) (*it)->StartAllListeners(); - // update conditional formats after table is inserted - if ( pCondFormList ) - pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); - if ( mpColorScaleList ) - mpColorScaleList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); if ( pValidationList ) pValidationList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); // sheet names of references may not be valid until sheet is copied diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index f1bce7bb445f..3a0aeb506962 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1007,10 +1007,6 @@ void ScDocument::UpdateReference( UpdateRefMode eUpdateRefMode, pDPCollection->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); UpdateChartRef( eUpdateRefMode, nCol1, nRow1, nTab1, nCol2, nRow2, nTab2, nDx, nDy, nDz ); UpdateRefAreaLinks( eUpdateRefMode, aRange, nDx, nDy, nDz ); - if ( mpColorScaleList ) - mpColorScaleList->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); - if ( pCondFormList ) - pCondFormList->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); if ( pValidationList ) pValidationList->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz ); if ( pDetOpList ) diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 6ec09a3ee69b..c18b993768c7 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -433,9 +433,6 @@ void ScDocument::CompileDBFormula( bool bCreateFormulaString ) void ScDocument::CompileNameFormula( bool bCreateFormulaString ) { - if ( pCondFormList ) - pCondFormList->CompileAll(); // nach ScNameDlg noetig - TableContainer::iterator it = maTabs.begin(); for (;it != maTabs.end(); ++it) { @@ -600,57 +597,44 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uLong nFormat ) // bedingte Formate und Gueltigkeitsbereiche // -sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew ) +sal_uLong ScDocument::AddCondFormat( const ScConditionalFormat& rNew, SCTAB nTab ) { if (rNew.IsEmpty()) return 0; // leer ist immer 0 - if (!pCondFormList) - pCondFormList = new ScConditionalFormatList; - - sal_uLong nMax = 0; - for (ScConditionalFormatList::const_iterator itr = pCondFormList->begin(); - itr != pCondFormList->end(); ++itr) - { - sal_uLong nKey = itr->GetKey(); - if ( itr->EqualEntries( rNew ) ) - return nKey; - if ( nKey > nMax ) - nMax = nKey; - } - - // Der Aufruf kann aus ScPatternAttr::PutInPool kommen, darum Clone (echte Kopie) + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + return maTabs[nTab]->AddCondFormat( rNew ); - sal_uLong nNewKey = nMax + 1; - ScConditionalFormat* pInsert = rNew.Clone(this); - pInsert->SetKey( nNewKey ); - pCondFormList->InsertNew( pInsert ); - return nNewKey; + return 0; } -const ScColorFormatList* ScDocument::GetColorScaleList() const +const ScColorFormatList* ScDocument::GetColorScaleList(SCTAB nTab) const { - return mpColorScaleList.get(); + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + return maTabs[nTab]->GetColorFormatList(); + + return NULL; } -ScColorFormatList* ScDocument::GetColorScaleList() +ScColorFormatList* ScDocument::GetColorScaleList( SCTAB nTab ) { - return mpColorScaleList.get(); + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + return maTabs[nTab]->GetColorFormatList(); + + return NULL; } //takes ownership // returns a 1-based index, 0 is reserved for no entry -sal_uLong ScDocument::AddColorFormat( ScColorFormat* pNew ) +sal_uLong ScDocument::AddColorFormat( ScColorFormat* pNew, SCTAB nTab ) { if(!pNew) return 0; - if(!mpColorScaleList) - mpColorScaleList.reset(new ScColorFormatList()); - - mpColorScaleList->AddFormat( pNew ); + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + return maTabs[nTab]->AddColorFormat(pNew); - return mpColorScaleList->size(); + return 0; } sal_uLong ScDocument::AddValidationEntry( const ScValidationData& rNew ) @@ -693,6 +677,7 @@ const SfxPoolItem* ScDocument::GetEffItem( if ( rSet.GetItemState( ATTR_CONDITIONAL, true, &pItem ) == SFX_ITEM_SET ) { sal_uLong nIndex = ((const SfxUInt32Item*)pItem)->GetValue(); + ScConditionalFormatList* pCondFormList = GetCondFormList( nTab ); if (nIndex && pCondFormList) { const ScConditionalFormat* pForm = pCondFormList->GetFormat( nIndex ); @@ -741,6 +726,7 @@ const ScConditionalFormat* ScDocument::GetCondFormat( sal_uLong nIndex = ((const SfxUInt32Item*)GetAttr(nCol,nRow,nTab,ATTR_CONDITIONAL))->GetValue(); if (nIndex) { + ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); if (pCondFormList) return pCondFormList->GetFormat( nIndex ); else @@ -752,6 +738,15 @@ const ScConditionalFormat* ScDocument::GetCondFormat( return NULL; } +ScConditionalFormatList* ScDocument::GetCondFormList(SCTAB nTab) const +{ + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + return maTabs[nTab]->GetCondFormList(); + + return NULL; +} + + const ScValidationData* ScDocument::GetValidationEntry( sal_uLong nIndex ) const { if ( pValidationList ) @@ -760,10 +755,10 @@ const ScValidationData* ScDocument::GetValidationEntry( sal_uLong nIndex ) const return NULL; } -void ScDocument::FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges ) +void ScDocument::FindConditionalFormat( sal_uLong nKey, SCTAB nTab, ScRangeList& rRanges ) { - for (SCTAB i=0; i< static_cast<SCTAB>(maTabs.size()) && maTabs[i]; i++) - maTabs[i]->FindConditionalFormat( nKey, rRanges ); + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + maTabs[nTab]->FindConditionalFormat( nKey, rRanges ); } void ScDocument::FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab ) @@ -772,8 +767,9 @@ void ScDocument::FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SC maTabs[nTab]->FindConditionalFormat( nKey, rRanges ); } -void ScDocument::ConditionalChanged( sal_uLong nKey ) +void ScDocument::ConditionalChanged( sal_uLong nKey, SCTAB nTab ) { + ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); if ( nKey && pCondFormList && !bIsClip && !bIsUndo ) // nKey==0 -> noop { ScConditionalFormat* pForm = pCondFormList->GetFormat( nKey ); @@ -782,14 +778,10 @@ void ScDocument::ConditionalChanged( sal_uLong nKey ) } } -void ScDocument::SetCondFormList(ScConditionalFormatList* pNew) +void ScDocument::SetCondFormList(ScConditionalFormatList* pNew, SCTAB nTab) { - if (pCondFormList) - { - delete pCondFormList; - } - - pCondFormList = pNew; + if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab]) + maTabs[nTab]->SetCondFormList(pNew); } //------------------------------------------------------------------------ diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 3d2815211d51..ab9b95bfea0d 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -109,11 +109,19 @@ void ScDocument::Broadcast( const ScHint& rHint ) } // Repaint fuer bedingte Formate mit relativen Referenzen: - if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) - pCondFormList->SourceChanged( rHint.GetAddress() ); + for(SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabs.size()); ++nTab) + { + if(!maTabs[nTab]) + continue; + + ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); + if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) + pCondFormList->SourceChanged( rHint.GetAddress() ); - if( mpColorScaleList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) - mpColorScaleList->DataChanged( rHint.GetAddress() ); + ScColorFormatList* pColorFormatList = GetColorScaleList(nTab); + if( pColorFormatList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) + pColorFormatList->DataChanged( rHint.GetAddress() ); + } if ( rHint.GetAddress() != BCA_BRDCST_ALWAYS ) { @@ -135,12 +143,19 @@ void ScDocument::AreaBroadcast( const ScHint& rHint ) TrackFormulas( rHint.GetId() ); } - // Repaint fuer bedingte Formate mit relativen Referenzen: - if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) - pCondFormList->SourceChanged( rHint.GetAddress() ); + for(SCTAB nTab = 0; nTab < static_cast<SCTAB>(maTabs.size()); ++nTab) + { + if(!maTabs[nTab]) + continue; - if( mpColorScaleList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) - mpColorScaleList->DataChanged( rHint.GetAddress() ); + ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); + if ( pCondFormList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) + pCondFormList->SourceChanged( rHint.GetAddress() ); + + ScColorFormatList* pColorFormatList = GetColorScaleList(nTab); + if( pColorFormatList && rHint.GetAddress() != BCA_BRDCST_ALWAYS ) + pColorFormatList->DataChanged( rHint.GetAddress() ); + } } @@ -157,37 +172,44 @@ void ScDocument::AreaBroadcastInRange( const ScRange& rRange, const ScHint& rHin // Repaint for conditional formats containing relative references. //! This is _THE_ bottle neck! - if ( pCondFormList ) + TableContainer::iterator itr = maTabs.begin(); + for(; itr != maTabs.end(); ++itr) { - SCCOL nCol; - SCROW nRow; - SCTAB nTab; - SCCOL nCol1; - SCROW nRow1; - SCTAB nTab1; - SCCOL nCol2; - SCROW nRow2; - SCTAB nTab2; - rRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); - ScAddress aAddress( rRange.aStart ); - for ( nTab = nTab1; nTab <= nTab2; ++nTab ) + if(!*itr) + continue; + + ScConditionalFormatList* pCondFormList = (*itr)->GetCondFormList(); + + if ( pCondFormList ) { - aAddress.SetTab( nTab ); - for ( nCol = nCol1; nCol <= nCol2; ++nCol ) + SCCOL nCol1; + SCROW nRow1; + SCTAB nTab1; + SCCOL nCol2; + SCROW nRow2; + SCTAB nTab2; + rRange.GetVars( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + ScAddress aAddress( rRange.aStart ); + for ( SCTAB nTab = nTab1; nTab <= nTab2; ++nTab ) { - aAddress.SetCol( nCol ); - for ( nRow = nRow1; nRow <= nRow2; ++nRow ) + aAddress.SetTab( nTab ); + for ( SCCOL nCol = nCol1; nCol <= nCol2; ++nCol ) { - aAddress.SetRow( nRow ); - pCondFormList->SourceChanged( aAddress ); + aAddress.SetCol( nCol ); + for ( SCROW nRow = nRow1; nRow <= nRow2; ++nRow ) + { + aAddress.SetRow( nRow ); + pCondFormList->SourceChanged( aAddress ); + } } } } - } - if(mpColorScaleList) - { - mpColorScaleList->DataChanged(rRange); + ScColorFormatList* pColorFormatList = (*itr)->GetColorFormatList(); + if(pColorFormatList) + { + pColorFormatList->DataChanged(rRange); + } } } @@ -464,8 +486,19 @@ void ScDocument::TrackFormulas( sal_uLong nHintId ) pBC->Broadcast( aHint ); pBASM->AreaBroadcast( aHint ); // Repaint fuer bedingte Formate mit relativen Referenzen: - if ( pCondFormList ) - pCondFormList->SourceChanged( pTrack->aPos ); + TableContainer::iterator itr = maTabs.begin(); + for(; itr != maTabs.end(); ++itr) + { + if(!*itr) + continue; + ScConditionalFormatList* pCondFormList = (*itr)->GetCondFormList(); + if ( pCondFormList ) + pCondFormList->SourceChanged( pTrack->aPos ); + + ScColorFormatList* pColorFormatList = (*itr)->GetColorFormatList(); + if( pColorFormatList ) + pColorFormatList->DataChanged( pTrack->aPos ); + } // for "calculate" event, keep track of which sheets are affected by tracked formulas if ( bCalcEvent ) SetCalcNotification( pTrack->aPos.Tab() ); diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index d24cb7f9aa05..bf783adc3e41 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -475,11 +475,6 @@ bool ScDocument::InsertTab( SCTAB nPos, const rtl::OUString& rName, if ( *it ) (*it)->StartAllListeners(); - // update conditional formats after table is inserted - if ( pCondFormList ) - pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); - if ( mpColorScaleList ) - mpColorScaleList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); if ( pValidationList ) pValidationList->UpdateReference( URM_INSDEL, aRange, 0,0,1 ); // sheet names of references are not valid until sheet is inserted @@ -565,11 +560,6 @@ bool ScDocument::InsertTabs( SCTAB nPos, const std::vector<rtl::OUString>& rName if ( *it ) (*it)->StartAllListeners(); - // update conditional formats after table is inserted - if ( pCondFormList ) - pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,nNewSheets); - if ( mpColorScaleList ) - mpColorScaleList->UpdateReference( URM_INSDEL, aRange, 0,0,nNewSheets); if ( pValidationList ) pValidationList->UpdateReference( URM_INSDEL, aRange, 0,0,nNewSheets ); // sheet names of references are not valid until sheet is inserted @@ -632,10 +622,6 @@ bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc ) pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,-1 ); UpdateChartRef( URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1 ); UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,-1 ); - if ( pCondFormList ) - pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,-1 ); - if ( mpColorScaleList ) - mpColorScaleList->UpdateReference( URM_INSDEL, aRange, 0,0,-1 ); if ( pValidationList ) pValidationList->UpdateReference( URM_INSDEL, aRange, 0,0,-1 ); if ( pUnoBroadcaster ) @@ -723,10 +709,6 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* pRefUndoDoc pDetOpList->UpdateReference( this, URM_INSDEL, aRange, 0,0,-1*nSheets ); UpdateChartRef( URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1*nSheets ); UpdateRefAreaLinks( URM_INSDEL, aRange, 0,0,-1*nSheets ); - if ( pCondFormList ) - pCondFormList->UpdateReference( URM_INSDEL, aRange, 0,0,-1*nSheets ); - if ( mpColorScaleList ) - mpColorScaleList->UpdateReference( URM_INSDEL, aRange, 0,0,-1*nSheets ); if ( pValidationList ) pValidationList->UpdateReference( URM_INSDEL, aRange, 0,0,-1*nSheets ); if ( pUnoBroadcaster ) @@ -3399,9 +3381,6 @@ void ScDocument::CalcAll() void ScDocument::CompileAll() { - if ( pCondFormList ) - pCondFormList->CompileAll(); - TableContainer::iterator it = maTabs.begin(); for (; it != maTabs.end(); ++it) if (*it) @@ -3431,8 +3410,6 @@ void ScDocument::CompileXML() DELETEZ( pAutoNameCache ); // valid only during CompileXML, where cell contents don't change - if ( pCondFormList ) - pCondFormList->CompileXML(); if ( pValidationList ) pValidationList->CompileXML(); diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index 7e5c050cc176..81487268377c 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -483,15 +483,17 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX sal_uLong nColorScale = ((const SfxUInt32Item&)pPattern-> GetItem(ATTR_COLORSCALE)).GetValue(); + ScConditionalFormatList* pCondFormList = GetCondFormList(nTab); const ScConditionalFormat* pCondForm = NULL; if ( nConditional && pCondFormList ) pCondForm = pCondFormList->GetFormat( nConditional ); + ScColorFormatList* pColorFormatList = GetColorScaleList(nTab); const ScColorScaleFormat* pColorScale = NULL; const ScDataBarFormat* pDataBar = NULL; - if ( nColorScale && mpColorScaleList ) + if ( nColorScale && pColorFormatList ) { - ScColorFormat* pFormat = mpColorScaleList->GetFormat( nColorScale ); + ScColorFormat* pFormat = pColorFormatList->GetFormat( nColorScale ); if(pFormat->GetType() == COLORSCALE) pColorScale = static_cast<ScColorScaleFormat*>(pFormat); else if(pFormat->GetType() == DATABAR) diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 5dfa7bef0440..ce626fe4f701 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1026,39 +1026,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD { SfxPoolItem* pNewItem = NULL; - if ( nAttrId == ATTR_CONDITIONAL ) - { - // Bedingte Formate ins neue Dokument kopieren - - sal_uLong nNewIndex = 0; - ScConditionalFormatList* pSrcList = pSrcDoc->GetCondFormList(); - if ( pSrcList ) - { - sal_uLong nOldIndex = ((const SfxUInt32Item*)pSrcItem)->GetValue(); - const ScConditionalFormat* pOldData = pSrcList->GetFormat( nOldIndex ); - if ( pOldData ) - { - nNewIndex = pDestDoc->AddCondFormat( *pOldData ); - - // zugehoerige Styles auch mitkopieren - //! nur wenn Format bei Add neu angelegt - - ScStyleSheetPool* pSrcSPool = pSrcDoc->GetStyleSheetPool(); - ScStyleSheetPool* pDestSPool = pDestDoc->GetStyleSheetPool(); - const SvNumberFormatterIndexTable* pFormatExchangeList = pDestDoc->GetFormatExchangeList(); - sal_uInt16 nStlCnt = pOldData->Count(); - for (sal_uInt16 i=0; i<nStlCnt; i++) - { - String aName = pOldData->GetEntry(i)->GetStyle(); - SfxStyleSheetBase* pSrcStl = - pSrcDoc->GetStyleSheetPool()->Find(aName, SFX_STYLE_FAMILY_PARA); - lcl_CopyStyleToPool( pSrcStl, pSrcSPool, pDestSPool, pFormatExchangeList ); - } - } - } - pNewItem = new SfxUInt32Item( ATTR_CONDITIONAL, nNewIndex ); - } - else if ( nAttrId == ATTR_VALIDDATA ) + if ( nAttrId == ATTR_VALIDDATA ) { // Gueltigkeit ins neue Dokument kopieren diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx index 40cc82cd84fa..14eaa87f1e31 100644 --- a/sc/source/core/data/table1.cxx +++ b/sc/source/core/data/table1.cxx @@ -54,6 +54,8 @@ #include "sheetevents.hxx" #include "segmenttree.hxx" #include "dbdata.hxx" +#include "colorscale.hxx" +#include "conditio.hxx" #include <vector> @@ -267,6 +269,7 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const rtl::OUString& rNewName nScenarioFlags( 0 ), pDBDataNoName(NULL), mpRangeName(NULL), + mpCondFormatList( new ScConditionalFormatList() ), maNotes(pDoc), bScenario(false), bLayoutRTL(false), @@ -1466,6 +1469,9 @@ void ScTable::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW if (bUpdated && IsStreamValid()) SetStreamValid(false); + + if(mpCondFormatList) + mpCondFormatList->UpdateReference( eUpdateRefMode, ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2), nDx, nDy, nDz); } void ScTable::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, @@ -1499,6 +1505,11 @@ void ScTable::UpdateInsertTab(SCTAB nTable, SCTAB nNewSheets) if (IsStreamValid()) SetStreamValid(false); + + if(mpCondFormatList) + mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nNewSheets-1),0,0, nNewSheets); + if(mpColorFormatList) + mpColorFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nNewSheets-1),0,0, nNewSheets); } void ScTable::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScTable* pRefUndo, SCTAB nSheets ) @@ -1531,6 +1542,11 @@ void ScTable::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScTable* pRefUndo, SC if (IsStreamValid()) SetStreamValid(false); + + if(mpCondFormatList) + mpCondFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nSheets-1),0,0, -1*nSheets); + if(mpColorFormatList) + mpColorFormatList->UpdateReference( URM_INSDEL, ScRange(0,0, nTable, MAXCOL, MAXROW, nTable+nSheets-1),0,0, -1*nSheets); } void ScTable::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, @@ -1551,6 +1567,11 @@ void ScTable::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo, SetStreamValid(false); if (pDBDataNoName) pDBDataNoName->UpdateMoveTab(nOldPos, nNewPos); + + if(mpCondFormatList) + mpCondFormatList->UpdateMoveTab(nOldPos, nNewPos); + if(mpColorFormatList) + mpColorFormatList->UpdateMoveTab(nOldPos, nNewPos); } void ScTable::UpdateCompile( bool bForceIfNameInUse ) @@ -1984,4 +2005,62 @@ ScDBData* ScTable::GetAnonymousDBData() return pDBDataNoName; } +sal_uLong ScTable::AddCondFormat( const ScConditionalFormat& rNew ) +{ + if(!mpCondFormatList) + mpCondFormatList.reset(new ScConditionalFormatList()); + + sal_uLong nMax = 0; + for(ScConditionalFormatList::const_iterator itr = mpCondFormatList->begin(); + itr != mpCondFormatList->end(); ++itr) + { + sal_uLong nKey = itr->GetKey(); + if(nKey > nMax) + nMax = nKey; + } + + ScConditionalFormat* pNewFormat = rNew.Clone(pDocument); + pNewFormat->SetKey(nMax+1); + mpCondFormatList->InsertNew(pNewFormat); + + return nMax + 1; +} + +ScColorFormatList* ScTable::GetColorFormatList() +{ + return mpColorFormatList.get(); +} + +const ScColorFormatList* ScTable::GetColorFormatList() const +{ + return mpColorFormatList.get(); +} + +void ScTable::SetCondFormList( ScConditionalFormatList* pNew ) +{ + mpCondFormatList.reset( pNew ); +} + +ScConditionalFormatList* ScTable::GetCondFormList() +{ + if(!mpCondFormatList) + mpCondFormatList.reset( new ScConditionalFormatList() ); + + return mpCondFormatList.get(); +} + +const ScConditionalFormatList* ScTable::GetCondFormList() const +{ + return mpCondFormatList.get(); +} + +sal_uLong ScTable::AddColorFormat( ScColorFormat* pNew ) +{ + if(!mpColorFormatList) + mpColorFormatList.reset(new ScColorFormatList()); + + mpColorFormatList->AddFormat( pNew ); + return mpColorFormatList->size(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx index 09a171f03b9c..c16426f7198b 100644 --- a/sc/source/core/data/table2.cxx +++ b/sc/source/core/data/table2.cxx @@ -653,8 +653,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO std::map<sal_Int32, sal_Int32> aOldIdToNewId; std::map<sal_Int32, ScRangeList> aIdToRange; - ScConditionalFormatList* pCondFormatList = pDocument->GetCondFormList(); - ScConditionalFormatList* pOldCondFormatList = pTable->pDocument->GetCondFormList(); + ScConditionalFormatList* pOldCondFormatList = pTable->mpCondFormatList.get(); for(SCCOL i = nCol1; i <= nCol2; ++i) { ScAttrIterator* pIter = aCol[i-nDx].CreateAttrIterator( nRow1-nDy, nRow2-nDy ); @@ -667,9 +666,9 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO { ScConditionalFormat* pFormat = pOldCondFormatList->GetFormat(nId); ScConditionalFormat* pNewFormat = pFormat->Clone(pDocument); - pNewFormat->SetKey(pCondFormatList->size()+1); + pNewFormat->SetKey(mpCondFormatList->size()+1); //not in list => create entries in both maps and new format - pCondFormatList->InsertNew(pNewFormat); + 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() ) ); @@ -683,7 +682,7 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO itr != aIdToRange.end(); ++itr) { sal_uInt32 nNewKey = aOldIdToNewId.find(itr->first)->second; - ScConditionalFormat* pFormat = pCondFormatList->GetFormat( nNewKey ); + ScConditionalFormat* pFormat = mpCondFormatList->GetFormat( nNewKey ); pFormat->UpdateReference(URM_MOVE, ScRange(nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab), nDx, nDy, pTable->nTab - nTab); pFormat->AddRangeInfo(new ScRangeList(itr->second)); @@ -702,8 +701,8 @@ void ScTable::CopyColorScales( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow std::map<sal_Int32, sal_Int32> aOldIdToNewId; std::map<sal_Int32, ScRangeList> aIdToRange; - ScColorFormatList* pColorScaleList = pDocument->GetColorScaleList(); - ScColorFormatList* pOldColorScaleList = pTable->pDocument->GetColorScaleList(); + ScColorFormatList* pColorScaleList = mpColorFormatList.get(); + ScColorFormatList* pOldColorScaleList = pTable->mpColorFormatList.get(); for(SCCOL i = nCol1; i <= nCol2; ++i) { ScAttrIterator* pIter = aCol[i-nDx].CreateAttrIterator( nRow1-nDy, nRow2-nDy ); @@ -1542,6 +1541,9 @@ void ScTable::CalcAll() void ScTable::CompileAll() { for (SCCOL i=0; i <= MAXCOL; i++) aCol[i].CompileAll(); + + if(mpCondFormatList) + mpCondFormatList->CompileAll(); } @@ -1554,6 +1556,9 @@ void ScTable::CompileXML( ScProgress& rProgress ) { aCol[i].CompileXML( rProgress ); } + + if(mpCondFormatList) + mpCondFormatList->CompileXML(); } void ScTable::CalcAfterLoad() @@ -1785,11 +1790,10 @@ void ScTable::FindMaxRotCol( RowInfo* pRowInfo, SCSIZE nArrCount, SCCOL nX1, SCC // angeschaut werden muessen sal_uLong nIndex = ((const SfxUInt32Item*)pCondItem)->GetValue(); - ScConditionalFormatList* pList = pDocument->GetCondFormList(); ScStyleSheetPool* pStylePool = pDocument->GetStyleSheetPool(); - if (pList && pStylePool && nIndex) + if (mpCondFormatList && pStylePool && nIndex) { - const ScConditionalFormat* pFormat = pList->GetFormat(nIndex); + const ScConditionalFormat* pFormat = mpCondFormatList->GetFormat(nIndex); if ( pFormat ) { sal_uInt16 nEntryCount = pFormat->Count(); diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 87b1d250f669..7c8a34621c08 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -1073,7 +1073,7 @@ void XclExpColorScale::SaveXml( XclExpXmlStream& rStrm ) XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot ) : XclExpRoot( rRoot ) { - if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList() ) + if( const ScConditionalFormatList* pCondFmtList = GetDoc().GetCondFormList(GetCurrScTab()) ) { for( ScConditionalFormatList::const_iterator itr = pCondFmtList->begin(); itr != pCondFmtList->end(); ++itr) @@ -1083,19 +1083,15 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot ) : maCondfmtList.AppendRecord( xCondfmtRec ); } } - if( const ScColorFormatList* pColorScaleList = GetDoc().GetColorScaleList() ) + if( const ScColorFormatList* pColorScaleList = GetDoc().GetColorScaleList(GetCurrScTab()) ) { for( ScColorFormatList::const_iterator itr = pColorScaleList->begin(); itr != pColorScaleList->end(); ++itr) { - const ScRangeList& rList = itr->GetRange(); - if (rList.front()->aStart.Tab() == GetCurrScTab()) + if(itr->GetType() == COLORSCALE) { - if(itr->GetType() == COLORSCALE) - { - XclExpColorScaleList::RecordRefType xColorScaleRec( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*itr) ) ); - maColorScaleList.AppendRecord( xColorScaleRec ); - } + XclExpColorScaleList::RecordRefType xColorScaleRec( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*itr) ) ); + maColorScaleList.AppendRecord( xColorScaleRec ); } } } diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index aaed2c99c100..77d9deefe2c5 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -2851,77 +2851,81 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) (*mpKeywordTable)[ NF_KEY_THAI_T ] = String( RTL_CONSTASCII_USTRINGPARAM( "T" ) ); sal_Int32 nNumFmtIndex = 0; - ScConditionalFormatList* pList = rRoot.GetDoc().GetCondFormList(); - if (pList) + SCTAB nTables = rRoot.GetDoc().GetTableCount(); + for(SCTAB nTab = 0; nTab < nTables; ++nTab) { - sal_Int32 nIndex = 0; - for (ScConditionalFormatList::const_iterator itr = pList->begin(); - itr != pList->end(); ++itr) + ScConditionalFormatList* pList = rRoot.GetDoc().GetCondFormList(nTab); + if (pList) { - sal_Int32 nEntryCount = itr->Count(); - for (sal_Int32 nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry) + sal_Int32 nIndex = 0; + for (ScConditionalFormatList::const_iterator itr = pList->begin(); + itr != pList->end(); ++itr) { - const ScCondFormatEntry* pEntry = itr->GetEntry(nFormatEntry); - if (!pEntry) - continue; - - rtl::OUString aStyleName = pEntry->GetStyle(); - if (maStyleNameToDxfId.find(aStyleName) == maStyleNameToDxfId.end()) + sal_Int32 nEntryCount = itr->Count(); + for (sal_Int32 nFormatEntry = 0; nFormatEntry < nEntryCount; ++nFormatEntry) { - maStyleNameToDxfId.insert(std::pair<rtl::OUString, sal_Int32>(aStyleName, nIndex)); - - SfxItemSet& rSet = rRoot.GetDoc().GetStyleSheetPool()->Find(aStyleName)->GetItemSet(); - - XclExpCellBorder* pBorder = new XclExpCellBorder; - if (!pBorder->FillFromItemSet( rSet, GetPalette(), GetBiff()) ) - { - delete pBorder; - pBorder = NULL; - } - - XclExpCellAlign* pAlign = new XclExpCellAlign; - if (!pAlign->FillFromItemSet( rSet, false, GetBiff())) - { - delete pAlign; - pAlign = NULL; - } - - XclExpCellProt* pCellProt = new XclExpCellProt; - if (!pCellProt->FillFromItemSet( rSet )) - { - delete pCellProt; - pCellProt = NULL; - } - - XclExpCellArea* pCellArea = new XclExpCellArea; - if(!pCellArea->FillFromItemSet( rSet, GetPalette(), GetBiff() )) - { - delete pCellArea; - pCellArea = NULL; - } + const ScCondFormatEntry* pEntry = itr->GetEntry(nFormatEntry); + if (!pEntry) + continue; - XclExpFont* pFont = NULL; - // check if non default font is set and only export then - if (rSet.GetItemState(rSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ))>SFX_ITEM_DEFAULT ) + rtl::OUString aStyleName = pEntry->GetStyle(); + if (maStyleNameToDxfId.find(aStyleName) == maStyleNameToDxfId.end()) { - Font aFont = XclExpFontHelper::GetFontFromItemSet( GetRoot(), rSet, com::sun::star::i18n::ScriptType::WEAK ); - pFont = new XclExpFont( GetRoot(), XclFontData( aFont ), EXC_COLOR_CELLTEXT ); + maStyleNameToDxfId.insert(std::pair<rtl::OUString, sal_Int32>(aStyleName, nIndex)); + + SfxItemSet& rSet = rRoot.GetDoc().GetStyleSheetPool()->Find(aStyleName)->GetItemSet(); + + XclExpCellBorder* pBorder = new XclExpCellBorder; + if (!pBorder->FillFromItemSet( rSet, GetPalette(), GetBiff()) ) + { + delete pBorder; + pBorder = NULL; + } + + XclExpCellAlign* pAlign = new XclExpCellAlign; + if (!pAlign->FillFromItemSet( rSet, false, GetBiff())) + { + delete pAlign; + pAlign = NULL; + } + + XclExpCellProt* pCellProt = new XclExpCellProt; + if (!pCellProt->FillFromItemSet( rSet )) + { + delete pCellProt; + pCellProt = NULL; + } + + XclExpCellArea* pCellArea = new XclExpCellArea; + if(!pCellArea->FillFromItemSet( rSet, GetPalette(), GetBiff() )) + { + delete pCellArea; + pCellArea = NULL; + } + + XclExpFont* pFont = NULL; + // check if non default font is set and only export then + if (rSet.GetItemState(rSet.GetPool()->GetWhich( SID_ATTR_CHAR_FONT ))>SFX_ITEM_DEFAULT ) + { + Font aFont = XclExpFontHelper::GetFontFromItemSet( GetRoot(), rSet, com::sun::star::i18n::ScriptType::WEAK ); + pFont = new XclExpFont( GetRoot(), XclFontData( aFont ), EXC_COLOR_CELLTEXT ); + } + + XclExpNumFmt* pNumFormat = NULL; + const SfxPoolItem *pPoolItem = NULL; + if( rSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) + { + sal_uLong nScNumFmt = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); + sal_uInt16 nXclNumFmt = static_cast< sal_uInt16 >( EXC_FORMAT_OFFSET8 + nIndex ); + pNumFormat = new XclExpNumFmt( nScNumFmt, nXclNumFmt, GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() )); + ++nNumFmtIndex; + } + + maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, pFont, pNumFormat, pCellProt, pCellArea )); + ++nIndex; } - XclExpNumFmt* pNumFormat = NULL; - const SfxPoolItem *pPoolItem = NULL; - if( rSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_True, &pPoolItem ) == SFX_ITEM_SET ) - { - sal_uLong nScNumFmt = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); - sal_uInt16 nXclNumFmt = static_cast< sal_uInt16 >( EXC_FORMAT_OFFSET8 + nIndex ); - pNumFormat = new XclExpNumFmt( nScNumFmt, nXclNumFmt, GetNumberFormatCode( *this, nScNumFmt, mxFormatter.get(), mpKeywordTable.get() )); - ++nNumFmtIndex; - } - - maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, pFont, pNumFormat, pCellProt, pCellArea )); - ++nIndex; } - } } } diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx index 50b72e883eda..f8d0ab3789d5 100644 --- a/sc/source/filter/excel/xicontent.cxx +++ b/sc/source/filter/excel/xicontent.cxx @@ -648,7 +648,7 @@ void XclImpCondFormat::Apply() { ScDocument& rDoc = GetDoc(); - sal_uLong nKey = rDoc.AddCondFormat( *mxScCondFmt ); + sal_uLong nKey = rDoc.AddCondFormat( *mxScCondFmt, maRanges.front()->aStart.Tab() ); ScPatternAttr aPattern( rDoc.GetPool() ); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nKey ) ); diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index 3471e11e951f..2c3042474624 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -809,7 +809,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > ScDocument& rDoc = getScDocument(); ScColorScaleFormat* pFormat = new ScColorScaleFormat(&rDoc); - sal_Int32 nIndex = rDoc.AddColorFormat(pFormat); + sal_Int32 nIndex = rDoc.AddColorFormat(pFormat, getSheetIndex()); ScRangeList aList; // apply attributes to cells @@ -840,7 +840,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > ScDocument& rDoc = getScDocument(); ScDataBarFormat* pFormat = new ScDataBarFormat(&rDoc); - sal_Int32 nIndex = rDoc.AddColorFormat(pFormat); + sal_Int32 nIndex = rDoc.AddColorFormat(pFormat, getSheetIndex()); // apply attributes to cells // diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index aa4495cd218b..a572a082c403 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -2852,7 +2852,7 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe } //export new conditional format information - ExportConditionalFormat(); + ExportConditionalFormat(nTable); } } @@ -3814,10 +3814,10 @@ rtl::OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry) } -void ScXMLExport::ExportConditionalFormat() +void ScXMLExport::ExportConditionalFormat(SCTAB nTab) { - ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(); - ScColorFormatList* pColorFormatList = pDoc->GetColorScaleList(); + ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(nTab); + ScColorFormatList* pColorFormatList = pDoc->GetColorScaleList(nTab); if(pCondFormatList || pColorFormatList) { SvXMLElementExport aElementCondFormats(*this, XML_NP_TABLE_EXT, XML_CONDITIONAL_FORMATS, true, true); diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx index 158e81813e70..032bb182c901 100644 --- a/sc/source/filter/xml/xmlexprt.hxx +++ b/sc/source/filter/xml/xmlexprt.hxx @@ -36,6 +36,8 @@ #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/table/XCellRange.hpp> +#include "address.hxx" + namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } } @@ -205,7 +207,7 @@ class ScXMLExport : public SvXMLExport void WriteLabelRanges( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xRangesIAccess, bool bColumn ); void WriteNamedExpressions(); void WriteNamedRange(ScRangeName* pRangeName); - void ExportConditionalFormat(); + void ExportConditionalFormat(SCTAB nTab); void WriteExternalRefCaches(); void WriteConsolidation(); // core implementation diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index 2543d2368e2d..9524e6ba4a74 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1363,9 +1363,12 @@ void ScDocShell::NotifyStyle( const SfxStyleSheetHint& rHint ) aOldName = ((SfxStyleSheetHintExtended&)rHint).GetOldName(); if ( aNewName != aOldName ) { - ScConditionalFormatList* pList = aDocument.GetCondFormList(); - if (pList) - pList->RenameCellStyle( aOldName,aNewName ); + for(SCTAB i = 0; i < aDocument.GetTableCount(); ++i) + { + ScConditionalFormatList* pList = aDocument.GetCondFormList(i); + if (pList) + pList->RenameCellStyle( aOldName,aNewName ); + } } } } diff --git a/sc/source/ui/inc/refundo.hxx b/sc/source/ui/inc/refundo.hxx index 25de386d023e..eaa77e155c30 100644 --- a/sc/source/ui/inc/refundo.hxx +++ b/sc/source/ui/inc/refundo.hxx @@ -37,7 +37,6 @@ class ScRangeName; class ScPrintRangeSaver; class ScDPCollection; class ScChartCollection; -class ScConditionalFormatList; class ScDetOpList; class ScChartListenerCollection; class ScAreaLinkSaveCollection; @@ -50,7 +49,6 @@ private: ScRangeName* pRangeName; ScPrintRangeSaver* pPrintRanges; ScDPCollection* pDPCollection; - ScConditionalFormatList* pCondFormList; ScDetOpList* pDetOpList; ScChartListenerCollection* pChartListenerCollection; ScAreaLinkSaveCollection* pAreaLinks; diff --git a/sc/source/ui/undo/refundo.cxx b/sc/source/ui/undo/refundo.cxx index 1d2d2bc62fc3..2b55c3258c98 100644 --- a/sc/source/ui/undo/refundo.cxx +++ b/sc/source/ui/undo/refundo.cxx @@ -41,7 +41,6 @@ #include "pivot.hxx" #include "chartarr.hxx" #include "stlpool.hxx" -#include "conditio.hxx" #include "detdata.hxx" #include "prnsave.hxx" #include "chartlis.hxx" @@ -67,9 +66,6 @@ ScRefUndoData::ScRefUndoData( const ScDocument* pDoc ) : ScDPCollection* pOldDP = ((ScDocument*)pDoc)->GetDPCollection(); //! const pDPCollection = pOldDP ? new ScDPCollection(*pOldDP) : NULL; - ScConditionalFormatList* pOldCond = pDoc->GetCondFormList(); - pCondFormList = pOldCond ? new ScConditionalFormatList(*pOldCond) : NULL; - ScDetOpList* pOldDetOp = pDoc->GetDetOpList(); pDetOpList = pOldDetOp ? new ScDetOpList(*pOldDetOp) : 0; @@ -89,7 +85,6 @@ ScRefUndoData::~ScRefUndoData() delete pRangeName; delete pPrintRanges; delete pDPCollection; - delete pCondFormList; delete pDetOpList; delete pChartListenerCollection; delete pAreaLinks; @@ -126,13 +121,6 @@ void ScRefUndoData::DeleteUnchanged( const ScDocument* pDoc ) DELETEZ(pDPCollection); } - if (pCondFormList) - { - ScConditionalFormatList* pNewCond = pDoc->GetCondFormList(); - if ( pNewCond && *pCondFormList == *pNewCond ) - DELETEZ(pCondFormList); - } - if (pDetOpList) { ScDetOpList* pNewDetOp = pDoc->GetDetOpList(); @@ -182,8 +170,6 @@ void ScRefUndoData::DoUndo( ScDocument* pDoc, sal_Bool bUndoRefFirst ) pDPCollection->WriteRefsTo( *pDocDP ); } - if (pCondFormList) - pDoc->SetCondFormList( new ScConditionalFormatList(*pCondFormList) ); if (pDetOpList) pDoc->SetDetOpList( new ScDetOpList(*pDetOpList) ); diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 7fc9093a223e..6a50811fafab 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -2116,7 +2116,7 @@ uno::Any SAL_CALL ScCellRangesBase::getPropertyDefault( const rtl::OUString& aPr formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML)); aAny <<= uno::Reference<sheet::XSheetConditionalEntries>( - new ScTableConditionalFormat( pDoc, 0, eGrammar )); + new ScTableConditionalFormat( pDoc, 0, aRanges[0]->aStart.Tab(), eGrammar )); } break; case SC_WID_UNO_VALIDAT: @@ -2418,7 +2418,7 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE pFormat->FillFormat( aNew, pDoc, eGrammar ); ScRangeListRef pRanges = new ScRangeList( aRanges ); aNew.AddRangeInfo( pRanges ); - sal_uLong nIndex = pDoc->AddCondFormat( aNew ); + sal_uLong nIndex = pDoc->AddCondFormat( aNew, aRanges.front()->aStart.Tab() ); ScPatternAttr aPattern( pDoc->GetPool() ); aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) ); @@ -2581,7 +2581,7 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE sal_uLong nIndex = ((const SfxUInt32Item&) pPattern->GetItem(ATTR_CONDITIONAL)).GetValue(); rAny <<= uno::Reference<sheet::XSheetConditionalEntries>( - new ScTableConditionalFormat( pDoc, nIndex, eGrammar )); + new ScTableConditionalFormat( pDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar )); } } break; diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx index a2b135bff15d..0cc06a397965 100644 --- a/sc/source/ui/unoobj/fmtuno.cxx +++ b/sc/source/ui/unoobj/fmtuno.cxx @@ -181,13 +181,13 @@ ScCondFormatEntryItem::ScCondFormatEntryItem() : //------------------------------------------------------------------------ ScTableConditionalFormat::ScTableConditionalFormat( - ScDocument* pDoc, sal_uLong nKey, FormulaGrammar::Grammar eGrammar) + ScDocument* pDoc, sal_uLong nKey, SCTAB nTab, FormulaGrammar::Grammar eGrammar) { // Eintrag aus dem Dokument lesen... if ( pDoc && nKey ) { - ScConditionalFormatList* pList = pDoc->GetCondFormList(); + ScConditionalFormatList* pList = pDoc->GetCondFormList(nTab); if (pList) { const ScConditionalFormat* pFormat = pList->GetFormat( nKey ); diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx index cdb42db764fe..e87979449de6 100644 --- a/sc/source/ui/view/viewfun2.cxx +++ b/sc/source/ui/view/viewfun2.cxx @@ -3080,7 +3080,7 @@ void ScViewFunc::SetSelectionFrameLines( const SvxBorderLine* pLine, void ScViewFunc::SetConditionalFormat( const ScConditionalFormat& rNew ) { ScDocument* pDoc = GetViewData()->GetDocument(); - sal_uLong nIndex = pDoc->AddCondFormat(rNew); // for it there is no Undo + sal_uLong nIndex = pDoc->AddCondFormat(rNew, GetViewData()->GetTabNo()); // for it there is no Undo SfxUInt32Item aItem( ATTR_CONDITIONAL, nIndex ); ApplyAttr( aItem ); // with Paint and Undo... |