[Libreoffice-commits] .: 21 commits - sc/inc sc/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Oct 5 15:28:57 PDT 2012
sc/inc/attarray.hxx | 3
sc/inc/attrib.hxx | 24 ++++++
sc/inc/column.hxx | 2
sc/inc/document.hxx | 3
sc/inc/scabstdlg.hxx | 2
sc/inc/scitems.hxx | 87 +++++++++++------------
sc/inc/table.hxx | 4 -
sc/source/core/data/attarray.cxx | 112 ++++++++++++++++++++++++++++--
sc/source/core/data/attrib.cxx | 47 ++++++++++++
sc/source/core/data/column.cxx | 10 ++
sc/source/core/data/column2.cxx | 4 -
sc/source/core/data/docpool.cxx | 4 -
sc/source/core/data/documen4.cxx | 48 +++++++-----
sc/source/core/data/documen6.cxx | 3
sc/source/core/data/document.cxx | 22 +++++
sc/source/core/data/fillinfo.cxx | 73 ++++++++++---------
sc/source/core/data/table1.cxx | 4 -
sc/source/core/data/table2.cxx | 101 ++++++++++++++++++---------
sc/source/core/data/table3.cxx | 17 ----
sc/source/filter/excel/xecontent.cxx | 3
sc/source/filter/excel/xicontent.cxx | 15 ----
sc/source/filter/oox/condformatbuffer.cxx | 13 ---
sc/source/filter/xml/xmlcondformat.cxx | 14 ---
sc/source/filter/xml/xmlstyli.cxx | 13 ---
sc/source/ui/attrdlg/scdlgfact.cxx | 5 +
sc/source/ui/attrdlg/scdlgfact.hxx | 2
sc/source/ui/condformat/condformatdlg.cxx | 31 +++++++-
sc/source/ui/condformat/condformatmgr.cxx | 16 +++-
sc/source/ui/docshell/docfunc.cxx | 71 ++++++++++++++++---
sc/source/ui/inc/condformatdlg.hrc | 3
sc/source/ui/inc/condformatdlg.hxx | 5 +
sc/source/ui/inc/condformatmgr.hxx | 4 +
sc/source/ui/inc/docfunc.hxx | 9 ++
sc/source/ui/src/condformatdlg.src | 16 +++-
sc/source/ui/unoobj/cellsuno.cxx | 14 +--
sc/source/ui/view/cellsh1.cxx | 21 ++---
36 files changed, 576 insertions(+), 249 deletions(-)
New commits:
commit c6e44b87ef6d47ab24bebd586de3e75e9f08cfbe
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Oct 6 00:22:21 2012 +0200
fix crash in cond format dialog with new range edit
Change-Id: Ie19038046fa9121cc234546a9891685153be5646
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 50be91f..2e294f2 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -1103,7 +1103,7 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScCond
SetText(aTitle.makeStringAndClear());
maBtnAdd.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, AddBtnHdl ) );
maBtnRemove.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, RemoveBtnHdl ) );
- maEdRange.SetModifyHdl( LINK( &maEdRange, ScCondFormatDlg, EdRangeModifyHdl ) );
+ maEdRange.SetModifyHdl( LINK( this, ScCondFormatDlg, EdRangeModifyHdl ) );
FreeResource();
maEdRange.SetText(aRangeString);
@@ -1166,15 +1166,15 @@ IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
return 0;
}
-IMPL_LINK_NOARG( ScCondFormatDlg, EdRangeModifyHdl )
+IMPL_LINK( ScCondFormatDlg, EdRangeModifyHdl, Edit*, pEdit )
{
- rtl::OUString aRangeStr = maEdRange.GetText();
+ rtl::OUString aRangeStr = pEdit->GetText();
ScRangeList aRange;
sal_uInt16 nFlags = aRange.Parse(aRangeStr, mpDoc, SCA_VALID, mpDoc->GetAddressConvention());
if(nFlags & SCA_VALID)
- maEdRange.SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
+ pEdit->SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
else
- maEdRange.SetControlBackground(COL_LIGHTRED);
+ pEdit->SetControlBackground(COL_LIGHTRED);
return 0;
}
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 5ddc027..4b3e780 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -185,7 +185,7 @@ private:
ScAddress maPos;
ScDocument* mpDoc;
- DECL_LINK( EdRangeModifyHdl, void* );
+ DECL_LINK( EdRangeModifyHdl, Edit* );
public:
ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos);
commit fa02cce6800cd6021e0160e4698b9e90496a94c5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sat Oct 6 00:03:35 2012 +0200
also support removing of conditional formats
Change-Id: I47ba632ccf752611a41b29c0da8e5d0f28a88565
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index ded335e..1674049 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -139,6 +139,7 @@ public:
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
void AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
+ void RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
void ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement );
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 388b121..3206637 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -318,6 +318,7 @@ public:
void ApplySelectionLineStyle( const ScMarkData& rMark,
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
+ void RemoveCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
const ScStyleSheet* GetStyle( SCROW nRow ) const;
const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 51a5493..f02f028 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1156,6 +1156,7 @@ public:
const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
ScPatternAttr* CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
+ void RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index e4d7ba0..c630cb7 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -544,6 +544,7 @@ public:
void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
const ScPatternAttr& rPattern, short nNewType );
void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
+ void RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle );
void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 1b16d0b..b7b2260 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -322,6 +322,57 @@ void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nInd
}
+void ScAttrArray::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex )
+{
+ if(!VALIDROW(nStartRow) || !VALIDROW(nEndRow))
+ return;
+
+ if(nEndRow < nStartRow)
+ return;
+
+ SCROW nTempStartRow = nStartRow;
+ SCROW nTempEndRow = nEndRow;
+
+ do
+ {
+ const ScPatternAttr* pPattern = GetPattern(nTempStartRow);
+
+ ScPatternAttr aPattern( pDocument->GetPool() );
+ if(pPattern)
+ {
+ SCROW nPatternStartRow;
+ SCROW nPatternEndRow;
+ GetPatternRange( nPatternStartRow, nPatternEndRow, nTempStartRow );
+
+ nTempEndRow = std::min<SCROW>( nPatternEndRow, nEndRow );
+ const SfxPoolItem* pItem = NULL;
+ pPattern->GetItemSet().GetItemState( ATTR_CONDITIONAL, true, &pItem );
+ if(pItem)
+ {
+ std::vector< sal_uInt32 > aCondFormatData = static_cast<const ScCondFormatItem*>(pItem)->GetCondFormatData();
+ std::vector<sal_uInt32>::iterator itr = std::find(aCondFormatData.begin(), aCondFormatData.end(), nIndex);
+ if(itr != aCondFormatData.end())
+ {
+ ScCondFormatItem aItem;
+ aCondFormatData.erase(itr);
+ aItem.SetCondFormatData( aCondFormatData );
+ aPattern.GetItemSet().Put( aItem );
+ SetPatternArea( nTempStartRow, nTempEndRow, &aPattern, true );
+ }
+
+ }
+ }
+ else
+ {
+ return;
+ }
+
+ nTempStartRow = nTempEndRow + 1;
+ }
+ while(nTempEndRow < nEndRow);
+
+}
+
//------------------------------------------------------------------------
void ScAttrArray::SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool )
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index 446ddc1..683f99d 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -503,6 +503,11 @@ void ScColumn::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex
pAttrArray->AddCondFormat( nStartRow, nEndRow, nIndex );
}
+void ScColumn::RemoveCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex )
+{
+ pAttrArray->RemoveCondFormat( nStartRow, nEndRow, nIndex );
+}
+
void ScColumn::ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle )
{
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 14b6983..30e1229 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4222,6 +4222,17 @@ void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_u
maTabs[nTab]->AddCondFormatData(rRange, nIndex);
}
+void ScDocument::RemoveCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
+{
+ if(!(static_cast<size_t>(nTab) < maTabs.size()))
+ return;
+
+ if(!maTabs[nTab])
+ return;
+
+ maTabs[nTab]->RemoveCondFormatData(rRange, nIndex);
+}
+
void ScDocument::ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScStyleSheet& rStyle)
{
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index dbd65eb..69c7d00 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2164,6 +2164,23 @@ void ScTable::AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex )
}
}
+void ScTable::RemoveCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex )
+{
+ size_t n = rRange.size();
+ for(size_t i = 0; i < n; ++i)
+ {
+ const ScRange* pRange = rRange[i];
+ SCCOL nColStart = pRange->aStart.Col();
+ SCCOL nColEnd = pRange->aEnd.Col();
+ SCROW nRowStart = pRange->aStart.Row();
+ SCROW nRowEnd = pRange->aEnd.Row();
+ for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
+ {
+ aCol[nCol].RemoveCondFormat(nRowStart, nRowEnd, nIndex);
+ }
+ }
+}
+
void ScTable::ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle )
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index c68b03d..99a65a2 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5061,9 +5061,10 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
namespace {
-void RemoveCondFormatAttributes(ScDocument* pDoc, const ScConditionalFormat* pFormat)
+void RemoveCondFormatAttributes(ScDocument* pDoc, const ScConditionalFormat* pFormat, SCTAB nTab)
{
const ScRangeList& rRangeList = pFormat->GetRange();
+ pDoc->RemoveCondFormatData( rRangeList, nTab, pFormat->GetKey() );
}
void SetConditionalFormatAttributes(ScDocument* pDoc, const ScRangeList& rRanges, sal_uLong nIndex, SCTAB nTab)
@@ -5087,7 +5088,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
pRepaintRange.reset(new ScRange( pOldFormat->GetRange().Combine() ));
if(pOldFormat)
{
- RemoveCondFormatAttributes(pDoc, pOldFormat);
+ RemoveCondFormatAttributes(pDoc, pOldFormat, nTab);
}
pDoc->DeleteConditionalFormat(nOldFormat, nTab);
@@ -5124,7 +5125,7 @@ void ScDocFunc::SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB
ScConditionalFormatList* pOldList = pDoc->GetCondFormList(nTab);
for(ScConditionalFormatList::const_iterator itr = pOldList->begin(), itrEnd = pOldList->end(); itr != itrEnd; ++itr)
{
- RemoveCondFormatAttributes(pDoc, &(*itr));
+ RemoveCondFormatAttributes(pDoc, &(*itr), nTab);
}
// then set new entries
commit 4921d9650d2ec41e3973e346ed73a20991255cde
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 23:10:33 2012 +0200
finally adapt the uno implementation
Change-Id: I15ae8d041f4813c0ee0a36464526296d0cdeb3d7
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index dd95c27..f06da09 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -2412,11 +2412,8 @@ void ScCellRangesBase::SetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
ScConditionalFormat* pNew = new ScConditionalFormat( 0, pDoc ); // Index wird beim Einfuegen gesetzt
pFormat->FillFormat( *pNew, pDoc, eGrammar );
pNew->AddRange( aRanges );
- sal_uLong nIndex = pDoc->AddCondFormat( pNew, aRanges.front()->aStart.Tab() );
-
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- pDocShell->GetDocFunc().ApplyAttributes( *GetMarkData(), aPattern, sal_True, sal_True );
+ SCTAB nTab = aRanges.front()->aStart.Tab();
+ pDocShell->GetDocFunc().ReplaceConditionalFormat( 0, pNew, nTab, aRanges );
}
}
}
@@ -2572,8 +2569,11 @@ void ScCellRangesBase::GetOnePropertyValue( const SfxItemPropertySimpleEntry* pE
formula::FormulaGrammar::Grammar eGrammar = (bXML ?
pDoc->GetStorageGrammar() :
formula::FormulaGrammar::mapAPItoGrammar( bEnglish, bXML));
- sal_uLong nIndex = ((const SfxUInt32Item&)
- pPattern->GetItem(ATTR_CONDITIONAL)).GetValue();
+ const std::vector<sal_uInt32>& rIndex = ((const ScCondFormatItem&)
+ pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
+ sal_uLong nIndex = 0;
+ if(!rIndex.empty())
+ nIndex = rIndex[0];
rAny <<= uno::Reference<sheet::XSheetConditionalEntries>(
new ScTableConditionalFormat( pDoc, nIndex, aRanges.front()->aStart.Tab(), eGrammar ));
}
commit 1a25d4645ab9cf943cd4153647bfcaa02854d77e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 23:00:16 2012 +0200
remaining places in calc core are adapted to overlapping cond formats
Change-Id: I096623d3c531d21eca2f5be29f22a1677a738b0d
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 4820cb1..1b16d0b 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -297,7 +297,7 @@ void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nInd
nTempEndRow = std::min<SCROW>( nPatternEndRow, nEndRow );
const SfxPoolItem* pItem = NULL;
- SfxItemState eState = pPattern->GetItemSet().GetItemState( ATTR_CONDITIONAL, true, &pItem );
+ pPattern->GetItemSet().GetItemState( ATTR_CONDITIONAL, true, &pItem );
std::vector< sal_uInt32 > aCondFormatData;
if(pItem)
aCondFormatData = static_cast<const ScCondFormatItem*>(pItem)->GetCondFormatData();
@@ -1229,9 +1229,9 @@ bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const
}
if ( nMask & HASATTR_CONDITIONAL )
{
- const SfxUInt32Item* pConditional =
- (const SfxUInt32Item*) &pPattern->GetItem( ATTR_CONDITIONAL );
- if ( pConditional->GetValue() != 0 )
+ bool bContainsCondFormat =
+ !static_cast<const ScCondFormatItem&>(pPattern->GetItem( ATTR_CONDITIONAL )).GetCondFormatData().empty();
+ if ( bContainsCondFormat )
bFound = true;
}
if ( nMask & HASATTR_PROTECTED )
@@ -1242,9 +1242,9 @@ bool ScAttrArray::HasAttrib( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const
if ( pProtect->GetProtection() || pProtect->GetHideCell() )
bFoundTemp = true;
- const SfxUInt32Item* pConditional =
- (const SfxUInt32Item*) &pPattern->GetItem( ATTR_CONDITIONAL );
- if ( pConditional->GetValue() != 0 )
+ bool bContainsCondFormat =
+ !static_cast<const ScCondFormatItem&>(pPattern->GetItem( ATTR_CONDITIONAL )).GetCondFormatData().empty();
+ if ( bContainsCondFormat )
{
SCROW nRowStartCond = std::max<SCROW>( nRow1, i ? pData[i-1].nRow + 1: 0 );
SCROW nRowEndCond = std::min<SCROW>( nRow2, pData[i].nRow );
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 435e8b8..b554ff9 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -126,9 +126,7 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev,
}
// bedingte Formatierung
- const SfxItemSet* pCondSet = NULL;
- if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() )
- pCondSet = pDocument->GetCondResult( nCol, nRow, nTab );
+ const SfxItemSet* pCondSet = pDocument->GetCondResult( nCol, nRow, nTab );
// Zeilenumbruch?
commit 3cb337fdcf0c502875c25405c1012713b1b86152
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 22:50:34 2012 +0200
adpat ScTable methods to overlapping conditional formats
Change-Id: I2f63ac7884f0897aa47fd4ee35b8af06553c311c
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 684a16a..51a5493 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 757f357..e4d7ba0 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 1a21d69..3295106 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 2e1dfbd..6d61bd7 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 e3d3864..dbd65eb 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 7688b4e..2e1c57d 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 abca86f..2cac520 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() )
{
commit 7152dd8ebfa93e4d7ebe84998fa0ce5fbe43966c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 21:41:58 2012 +0200
adapt ScDocument methods to new overlapping cond formats
Change-Id: Ifc18a3f02b7734e1f6772fb264f2c7bfe6907f17
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 52fe982..1a21d69 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -49,6 +49,7 @@
#include "compiler.hxx"
#include "externalrefmgr.hxx"
#include "colorscale.hxx"
+#include "attrib.hxx"
using namespace formula;
@@ -639,22 +640,26 @@ const SfxPoolItem* ScDocument::GetEffItem(
const SfxPoolItem* pItem;
if ( rSet.GetItemState( ATTR_CONDITIONAL, true, &pItem ) == SFX_ITEM_SET )
{
- sal_uLong nIndex = ((const SfxUInt32Item*)pItem)->GetValue();
+ const std::vector<sal_uInt32>& rIndex = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
ScConditionalFormatList* pCondFormList = GetCondFormList( nTab );
- if (nIndex && pCondFormList)
+ if (!rIndex.empty() && pCondFormList)
{
- const ScConditionalFormat* pForm = pCondFormList->GetFormat( nIndex );
- if ( pForm )
+ for(std::vector<sal_uInt32>::const_iterator itr = rIndex.begin(), itrEnd = rIndex.end();
+ itr != itrEnd; ++itr)
{
- ScBaseCell* pCell = ((ScDocument*)this)->GetCell(ScAddress(nCol,nRow,nTab));
- rtl::OUString aStyle = pForm->GetCellStyle( pCell, ScAddress(nCol, nRow, nTab) );
- if (!aStyle.isEmpty())
+ const ScConditionalFormat* pForm = pCondFormList->GetFormat( *itr );
+ if ( pForm )
{
- SfxStyleSheetBase* pStyleSheet = xPoolHelper->GetStylePool()->Find(
- aStyle, SFX_STYLE_FAMILY_PARA );
- if ( pStyleSheet && pStyleSheet->GetItemSet().GetItemState(
- nWhich, true, &pItem ) == SFX_ITEM_SET )
- return pItem;
+ ScBaseCell* pCell = ((ScDocument*)this)->GetCell(ScAddress(nCol,nRow,nTab));
+ rtl::OUString aStyle = pForm->GetCellStyle( pCell, ScAddress(nCol, nRow, nTab) );
+ if (!aStyle.isEmpty())
+ {
+ SfxStyleSheetBase* pStyleSheet = xPoolHelper->GetStylePool()->Find(
+ aStyle, SFX_STYLE_FAMILY_PARA );
+ if ( pStyleSheet && pStyleSheet->GetItemSet().GetItemState(
+ nWhich, true, &pItem ) == SFX_ITEM_SET )
+ return pItem;
+ }
}
}
}
@@ -667,9 +672,16 @@ const SfxPoolItem* ScDocument::GetEffItem(
const SfxItemSet* ScDocument::GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const
{
- const ScConditionalFormat* pForm = GetCondFormat( nCol, nRow, nTab );
- if ( pForm )
+ const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
+ const std::vector<sal_uInt32>& rIndex = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
+ ScConditionalFormatList* pFormatList = GetCondFormList(nTab);
+ for(std::vector<sal_uInt32>::const_iterator itr = rIndex.begin(), itrEnd = rIndex.end();
+ itr != itrEnd; ++itr)
{
+ ScConditionalFormat* pForm = pFormatList->GetFormat(*itr);
+ if(!pForm)
+ continue;
+
ScBaseCell* pCell = ((ScDocument*)this)->GetCell(ScAddress(nCol,nRow,nTab));
rtl::OUString aStyle = pForm->GetCellStyle( pCell, ScAddress(nCol, nRow, nTab) );
if (!aStyle.isEmpty())
@@ -679,7 +691,9 @@ const SfxItemSet* ScDocument::GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab
return &pStyleSheet->GetItemSet();
// if style is not there, treat like no condition
}
+
}
+
return NULL;
}
diff --git a/sc/source/core/data/documen6.cxx b/sc/source/core/data/documen6.cxx
index 4acd9ea..544950f 100644
--- a/sc/source/core/data/documen6.cxx
+++ b/sc/source/core/data/documen6.cxx
@@ -39,6 +39,7 @@
#include "patattr.hxx"
#include "scrdata.hxx"
#include "poolhelp.hxx"
+#include "attrib.hxx"
using namespace com::sun::star;
@@ -168,7 +169,7 @@ sal_uInt8 ScDocument::GetScriptType( SCCOL nCol, SCROW nRow, SCTAB nTab, ScBaseC
const ScPatternAttr* pPattern = GetPattern( nCol, nRow, nTab );
if (!pPattern) return 0;
const SfxItemSet* pCondSet = NULL;
- if ( ((const SfxUInt32Item&)pPattern->GetItem(ATTR_CONDITIONAL)).GetValue() )
+ if ( !((const ScCondFormatItem&)pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData().empty() )
pCondSet = GetCondResult( nCol, nRow, nTab );
sal_uLong nFormat = pPattern->GetNumberFormat( xPoolHelper->GetFormTable(), pCondSet );
commit 455feac565c124a670d72bdd985e398021fb6ae9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 20:39:20 2012 +0200
adapt xls import to new cond formats
Change-Id: Ibf8149d14c1404fc6e82ec285be9389072f24c31
diff --git a/sc/source/filter/excel/xicontent.cxx b/sc/source/filter/excel/xicontent.cxx
index 0d4319a..c5f6dad 100644
--- a/sc/source/filter/excel/xicontent.cxx
+++ b/sc/source/filter/excel/xicontent.cxx
@@ -650,19 +650,10 @@ void XclImpCondFormat::Apply()
{
ScDocument& rDoc = GetDoc();
- sal_uLong nKey = rDoc.AddCondFormat( mxScCondFmt->Clone(), maRanges.front()->aStart.Tab() );
- ScPatternAttr aPattern( rDoc.GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nKey ) );
+ SCTAB nTab = maRanges.front()->aStart.Tab();
+ sal_uLong nKey = rDoc.AddCondFormat( mxScCondFmt->Clone(), nTab );
- // maRanges contains only valid cell ranges
- for ( size_t i = 0, nRanges = maRanges.size(); i < nRanges; ++i )
- {
- const ScRange* pScRange = maRanges[ i ];
- rDoc.ApplyPatternAreaTab(
- pScRange->aStart.Col(), pScRange->aStart.Row(),
- pScRange->aEnd.Col(), pScRange->aEnd.Row(),
- pScRange->aStart.Tab(), aPattern );
- }
+ rDoc.AddCondFormatData( maRanges, nTab, nKey );
}
}
commit e454487d3a7349a1ec19b9785e36ad9e50add542
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 20:38:57 2012 +0200
use parantheses to prevent wrong evaluation
Change-Id: Ia872b5648286fd76039f7c397ea78e18bc2ad6b8
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 5ebd9f5..14b6983 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4213,7 +4213,7 @@ void ScDocument::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
{
- if(!static_cast<SCTAB>(nTab) < maTabs.size())
+ if(!(static_cast<size_t>(nTab) < maTabs.size()))
return;
if(!maTabs[nTab])
commit 72f1b6743ad5e6b1f8daeac1d1a2b3da4c3fde54
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 19:58:56 2012 +0200
adapt old style odf cond format import
Change-Id: I0bfcc21f66e2c76f6c8521bfc711972eb747ac43
diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx
index 687c841..fe0f265 100644
--- a/sc/source/filter/xml/xmlstyli.cxx
+++ b/sc/source/filter/xml/xmlstyli.cxx
@@ -454,12 +454,7 @@ void XMLTableStyleContext::ApplyCondFormat( uno::Sequence<table::CellRangeAddres
rRangeList.Join(*pRange);
}
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nCondId ) );
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList(aRangeList, true);
- pDoc->ApplySelectionPattern( aPattern , aMarkData);
-
+ pDoc->AddCondFormatData( aRangeList, nTab, nCondId );
break;
}
}
@@ -471,11 +466,7 @@ void XMLTableStyleContext::ApplyCondFormat( uno::Sequence<table::CellRangeAddres
mpCondFormat->SetKey(nIndex);
mpCondFormat->AddRange(aRangeList);
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList(aRangeList, true);
- pDoc->ApplySelectionPattern( aPattern , aMarkData);
+ pDoc->AddCondFormatData( aRangeList, nTab, nIndex );
}
commit 23f51dc5accf23271921dd0fcefa68124644b100
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 19:50:59 2012 +0200
remove some newly unused includes
Change-Id: I33e3d581d2ba38d6f68629fc2a7671cb48873bad
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 23cff09..32e0751 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -36,11 +36,6 @@
#include "rangelst.hxx"
#include "rangeutl.hxx"
#include "docfunc.hxx"
-#include "markdata.hxx"
-#include "docpool.hxx"
-#include "scitems.hxx"
-#include "patattr.hxx"
-#include "svl/intitem.hxx"
#include "XMLConverter.hxx"
commit e07da9e6c044c9e145f63eec0ddc7cbebfcb0e6e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 19:47:31 2012 +0200
adapt oox import to cond format change
Change-Id: I0924e0077f877cc123eab999c332e4c08df41f50
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 7df5321..254b0d6 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -58,9 +58,6 @@
#include "document.hxx"
#include "convuno.hxx"
#include "docfunc.hxx"
-#include "markdata.hxx"
-#include "docpool.hxx"
-#include "scitems.hxx"
#include "tokenarray.hxx"
#include "tokenuno.hxx"
@@ -892,21 +889,17 @@ void CondFormat::finalizeImport()
{
ScDocument& rDoc = getScDocument();
maRules.forEachMem( &CondFormatRule::finalizeImport );
- sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, maModel.maRanges.getBaseAddress().Sheet);
+ SCTAB nTab = maModel.maRanges.getBaseAddress().Sheet;
+ sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, nTab);
ScRangeList aList;
for( ApiCellRangeList::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr)
{
ScRange aRange;
ScUnoConversion::FillScRange(aRange, *itr);
- ScPatternAttr aPattern( rDoc.GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.SetMarkArea(aRange);
- rDoc.ApplySelectionPattern( aPattern , aMarkData);
-
aList.Append(aRange);
}
+ rDoc.AddCondFormatData( aList, nTab, nIndex );
mpFormat->AddRange(aList);
}
commit 62525574cc1ecbb4e8753ca704cb6a47f3d22dea
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 19:46:54 2012 +0200
adapt ods import of new cond format data
Change-Id: I15969a5ddaab1d7edb2f0b2035f8206e6f544ab3
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index c53e77f..23cff09 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -137,14 +137,11 @@ void ScXMLConditionalFormatContext::EndElement()
{
ScDocument* pDoc = GetScImport().GetDocument();
- sal_uLong nIndex = pDoc->AddCondFormat(mpFormat, GetScImport().GetTables().GetCurrentSheet());
+ SCTAB nTab = GetScImport().GetTables().GetCurrentSheet();
+ sal_uLong nIndex = pDoc->AddCondFormat(mpFormat, nTab);
mpFormat->SetKey(nIndex);
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList(mpFormat->GetRange(), true);
- pDoc->ApplySelectionPattern( aPattern , aMarkData);
+ pDoc->AddCondFormatData( mpFormat->GetRange(), nTab, nIndex);
}
ScXMLColorScaleFormatContext::ScXMLColorScaleFormatContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
commit d2b49b5b9bffdfa34174af96d85a392fde21fae1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Oct 5 19:05:25 2012 +0200
support overlapping conditional formats
Still missing:
*Removing conditional formats
*Handling of Manage Names dialog
*UNO
*Undo/Redo
*Import/export
*Adjusting the dialogs to support this
Change-Id: I72481cfb807fee2c3a1546222fe7e786d515ab44
diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 1f8d9f2..ded335e 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -138,6 +138,8 @@ public:
void ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
+ void AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
+
void ClearItems( SCROW nStartRow, SCROW nEndRow, const sal_uInt16* pWhich );
void ChangeIndent( SCROW nStartRow, SCROW nEndRow, bool bIncrement );
diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 0418d78..eb051fd 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -393,6 +393,30 @@ private:
sal_uInt16 mnHeight;
};
+class ScCondFormatItem : public SfxPoolItem
+{
+public:
+ TYPEINFO();
+
+ explicit ScCondFormatItem();
+ explicit ScCondFormatItem(sal_uInt32 nIndex);
+ explicit ScCondFormatItem(const std::vector<sal_uInt32>& nIndex);
+
+ virtual ~ScCondFormatItem();
+
+ virtual int operator==(const SfxPoolItem& rCmp ) const;
+ virtual ScCondFormatItem* Clone( SfxItemPool* = 0 ) const;
+
+ const std::vector<sal_uInt32>& GetCondFormatData() const;
+ void AddCondFormatData( sal_uInt32 nIndex );
+ void SetCondFormatData( const std::vector<sal_uInt32>& aIndex );
+ void RemoveCondFormatData( sal_uInt32 nIndex );
+
+private:
+
+ std::vector<sal_uInt32> maIndex;
+};
+
// ============================================================================
#endif
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx
index 34e05cb..388b121 100644
--- a/sc/inc/column.hxx
+++ b/sc/inc/column.hxx
@@ -317,6 +317,7 @@ public:
void ApplySelectionStyle(const ScStyleSheet& rStyle, const ScMarkData& rMark);
void ApplySelectionLineStyle( const ScMarkData& rMark,
const ::editeng::SvxBorderLine* pLine, bool bColorOnly );
+ void AddCondFormat(SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex );
const ScStyleSheet* GetStyle( SCROW nRow ) const;
const ScStyleSheet* GetSelectionStyle( const ScMarkData& rMark, bool& rFound ) const;
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index da7b575..684a16a 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1155,6 +1155,7 @@ public:
SC_DLLPUBLIC const ScPatternAttr* GetMostUsedPattern( SCCOL nCol, SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const;
const ScPatternAttr* GetSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
ScPatternAttr* CreateSelectionPattern( const ScMarkData& rMark, bool bDeep = true );
+ SC_DLLPUBLIC void AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex );
SC_DLLPUBLIC ScConditionalFormat* GetCondFormat( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
SC_DLLPUBLIC const SfxItemSet* GetCondResult( SCCOL nCol, SCROW nRow, SCTAB nTab ) const;
diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx
index 2f219e2..e644854 100644
--- a/sc/inc/scitems.hxx
+++ b/sc/inc/scitems.hxx
@@ -118,51 +118,51 @@
#define ATTR_VALIDDATA 153
#define ATTR_CONDITIONAL 154
-#define ATTR_PATTERN_END 155 // end cell-attribute-pattern
+#define ATTR_PATTERN_END 154 // end cell-attribute-pattern
-#define ATTR_PATTERN 156
+#define ATTR_PATTERN 155
// page attributes
-#define ATTR_LRSPACE 157 // editor: PageDesc-TabPage
-#define ATTR_ULSPACE 158
-#define ATTR_PAGE 159
-#define ATTR_PAGE_PAPERTRAY 160
-#define ATTR_PAGE_PAPERBIN 161
-#define ATTR_PAGE_SIZE 162
-#define ATTR_PAGE_MAXSIZE 163
-#define ATTR_PAGE_HORCENTER 164
-#define ATTR_PAGE_VERCENTER 165
-
-#define ATTR_PAGE_ON 166 // editor: header/footer-page
-#define ATTR_PAGE_DYNAMIC 167
-#define ATTR_PAGE_SHARED 168
-
-#define ATTR_PAGE_NOTES 169 // editor: table
-#define ATTR_PAGE_GRID 170
-#define ATTR_PAGE_HEADERS 171
-#define ATTR_PAGE_CHARTS 172
-#define ATTR_PAGE_OBJECTS 173
-#define ATTR_PAGE_DRAWINGS 174
-#define ATTR_PAGE_TOPDOWN 175
-#define ATTR_PAGE_SCALE 176
-#define ATTR_PAGE_SCALETOPAGES 177
-#define ATTR_PAGE_FIRSTPAGENO 178
-
-#define ATTR_PAGE_PRINTAREA 179 // editor: print areas
-#define ATTR_PAGE_REPEATROW 180
-#define ATTR_PAGE_REPEATCOL 181
-#define ATTR_PAGE_PRINTTABLES 182
-
-#define ATTR_PAGE_HEADERLEFT 183 // contents of header/
-#define ATTR_PAGE_FOOTERLEFT 184 // footer (left)
-#define ATTR_PAGE_HEADERRIGHT 185 // contents of header/
-#define ATTR_PAGE_FOOTERRIGHT 186 // footer (right)
-#define ATTR_PAGE_HEADERSET 187 // the corresponding sets
-#define ATTR_PAGE_FOOTERSET 188
-
-#define ATTR_PAGE_FORMULAS 189
-#define ATTR_PAGE_NULLVALS 190
-
-#define ATTR_PAGE_SCALETO 191 // #i8868# scale printout to width/height
+#define ATTR_LRSPACE 156 // editor: PageDesc-TabPage
+#define ATTR_ULSPACE 157
+#define ATTR_PAGE 158
+#define ATTR_PAGE_PAPERTRAY 159
+#define ATTR_PAGE_PAPERBIN 160
+#define ATTR_PAGE_SIZE 161
+#define ATTR_PAGE_MAXSIZE 162
+#define ATTR_PAGE_HORCENTER 163
+#define ATTR_PAGE_VERCENTER 164
+
+#define ATTR_PAGE_ON 165 // editor: header/footer-page
+#define ATTR_PAGE_DYNAMIC 166
+#define ATTR_PAGE_SHARED 167
+
+#define ATTR_PAGE_NOTES 168 // editor: table
+#define ATTR_PAGE_GRID 169
+#define ATTR_PAGE_HEADERS 170
+#define ATTR_PAGE_CHARTS 171
+#define ATTR_PAGE_OBJECTS 172
+#define ATTR_PAGE_DRAWINGS 173
+#define ATTR_PAGE_TOPDOWN 174
+#define ATTR_PAGE_SCALE 175
+#define ATTR_PAGE_SCALETOPAGES 176
+#define ATTR_PAGE_FIRSTPAGENO 177
+
+#define ATTR_PAGE_PRINTAREA 178 // editor: print areas
+#define ATTR_PAGE_REPEATROW 179
+#define ATTR_PAGE_REPEATCOL 180
+#define ATTR_PAGE_PRINTTABLES 181
+
+#define ATTR_PAGE_HEADERLEFT 182 // contents of header/
+#define ATTR_PAGE_FOOTERLEFT 183 // footer (left)
+#define ATTR_PAGE_HEADERRIGHT 184 // contents of header/
+#define ATTR_PAGE_FOOTERRIGHT 185 // footer (right)
+#define ATTR_PAGE_HEADERSET 186 // the corresponding sets
+#define ATTR_PAGE_FOOTERSET 187
+
+#define ATTR_PAGE_FORMULAS 188
+#define ATTR_PAGE_NULLVALS 189
+
+#define ATTR_PAGE_SCALETO 190 // #i8868# scale printout to width/height
#define ATTR_ENDINDEX ATTR_PAGE_SCALETO // end of pool-range
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 2b205e5..757f357 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -543,6 +543,7 @@ public:
void SetPattern( SCCOL nCol, SCROW nRow, const ScPatternAttr& rAttr, bool bPutToPool = false );
void ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
const ScPatternAttr& rPattern, short nNewType );
+ void AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex );
void ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle );
void ApplyStyleArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, const ScStyleSheet& rStyle );
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index bcba4de..4820cb1 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -273,6 +273,55 @@ const ScPatternAttr* ScAttrArray::GetPatternRange( SCROW& rStartRow,
return NULL;
}
+void ScAttrArray::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex )
+{
+ if(!VALIDROW(nStartRow) || !VALIDROW(nEndRow))
+ return;
+
+ if(nEndRow < nStartRow)
+ return;
+
+ SCROW nTempStartRow = nStartRow;
+ SCROW nTempEndRow = nEndRow;
+
+ do
+ {
+ const ScPatternAttr* pPattern = GetPattern(nTempStartRow);
+
+ ScPatternAttr aPattern( pDocument->GetPool() );
+ if(pPattern)
+ {
+ SCROW nPatternStartRow;
+ SCROW nPatternEndRow;
+ GetPatternRange( nPatternStartRow, nPatternEndRow, nTempStartRow );
+
+ nTempEndRow = std::min<SCROW>( nPatternEndRow, nEndRow );
+ const SfxPoolItem* pItem = NULL;
+ SfxItemState eState = pPattern->GetItemSet().GetItemState( ATTR_CONDITIONAL, true, &pItem );
+ std::vector< sal_uInt32 > aCondFormatData;
+ if(pItem)
+ aCondFormatData = static_cast<const ScCondFormatItem*>(pItem)->GetCondFormatData();
+ aCondFormatData.push_back(nIndex);
+
+ ScCondFormatItem aItem;
+ aItem.SetCondFormatData( aCondFormatData );
+ aPattern.GetItemSet().Put( aItem );
+ }
+ else
+ {
+ ScCondFormatItem aItem;
+ aItem.AddCondFormatData(nIndex);
+ aPattern.GetItemSet().Put( aItem );
+ nTempEndRow = nEndRow;
+ }
+
+ SetPatternArea( nTempStartRow, nTempEndRow, &aPattern, true );
+ nTempStartRow = nTempEndRow + 1;
+ }
+ while(nTempEndRow < nEndRow);
+
+}
+
//------------------------------------------------------------------------
void ScAttrArray::SetPattern( SCROW nRow, const ScPatternAttr* pPattern, bool bPutToPool )
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index e2f2c55..3ad9b8b 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -60,6 +60,7 @@ TYPEINIT1(ScPageHFItem, SfxPoolItem);
TYPEINIT1(ScViewObjectModeItem, SfxEnumItem);
TYPEINIT1(ScDoubleItem, SfxPoolItem);
TYPEINIT1(ScPageScaleToItem, SfxPoolItem);
+TYPEINIT1(ScCondFormatItem, SfxPoolItem);
//------------------------------------------------------------------------
@@ -1222,5 +1223,51 @@ bool ScPageScaleToItem::PutValue( const uno::Any& rAny, sal_uInt8 nMemberId )
// ============================================================================
+ScCondFormatItem::ScCondFormatItem():
+ SfxPoolItem( ATTR_CONDITIONAL )
+{
+}
+
+ScCondFormatItem::ScCondFormatItem( sal_uInt32 nIndex ):
+ SfxPoolItem( ATTR_CONDITIONAL )
+{
+ maIndex.push_back(nIndex);
+}
+
+ScCondFormatItem::ScCondFormatItem( const std::vector<sal_uInt32>& rIndex ):
+ SfxPoolItem( ATTR_CONDITIONAL ),
+ maIndex( rIndex )
+{
+}
+
+ScCondFormatItem::~ScCondFormatItem()
+{
+}
+
+int ScCondFormatItem::operator==( const SfxPoolItem& rCmp ) const
+{
+ return maIndex == static_cast<const ScCondFormatItem&>(rCmp).maIndex;
+}
+
+ScCondFormatItem* ScCondFormatItem::Clone(SfxItemPool*) const
+{
+ return new ScCondFormatItem(maIndex);
+}
+
+const std::vector<sal_uInt32>& ScCondFormatItem::GetCondFormatData() const
+{
+ return maIndex;
+}
+
+void ScCondFormatItem::AddCondFormatData( sal_uInt32 nIndex )
+{
+ maIndex.push_back(nIndex);
+}
+
+void ScCondFormatItem::SetCondFormatData( const std::vector<sal_uInt32>& rIndex )
+{
+ maIndex = rIndex;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index db99462..446ddc1 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -498,6 +498,11 @@ void ScColumn::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
}
}
+void ScColumn::AddCondFormat( SCROW nStartRow, SCROW nEndRow, sal_uInt32 nIndex )
+{
+ pAttrArray->AddCondFormat( nStartRow, nEndRow, nIndex );
+}
+
void ScColumn::ApplyStyle( SCROW nRow, const ScStyleSheet& rStyle )
{
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index b0a8d7d..cc8915f 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -287,7 +287,7 @@ ScDocumentPool::ScDocumentPool( SfxItemPool* pSecPool, sal_Bool bLoadRefCounts )
ppPoolDefaults[ ATTR_BORDER_INNER - ATTR_STARTINDEX ] = pGlobalBorderInnerAttr;
ppPoolDefaults[ ATTR_SHADOW - ATTR_STARTINDEX ] = new SvxShadowItem( ATTR_SHADOW );
ppPoolDefaults[ ATTR_VALIDDATA - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALIDDATA, 0 );
- ppPoolDefaults[ ATTR_CONDITIONAL - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_CONDITIONAL, 0 );
+ ppPoolDefaults[ ATTR_CONDITIONAL - ATTR_STARTINDEX ] = new ScCondFormatItem;
// GetRscString funktioniert erst nach ScGlobal::Init, zu erkennen am EmptyBrushItem
//! zusaetzliche Methode ScGlobal::IsInit() oder so...
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index ade6c8e..5ebd9f5 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -4211,6 +4211,17 @@ void ScDocument::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
maTabs[*itr]->ApplyPatternIfNumberformatIncompatible( rRange, rPattern, nNewType );
}
+void ScDocument::AddCondFormatData( const ScRangeList& rRange, SCTAB nTab, sal_uInt32 nIndex )
+{
+ if(!static_cast<SCTAB>(nTab) < maTabs.size())
+ return;
+
+ if(!maTabs[nTab])
+ return;
+
+ maTabs[nTab]->AddCondFormatData(rRange, nIndex);
+}
+
void ScDocument::ApplyStyle( SCCOL nCol, SCROW nRow, SCTAB nTab, const ScStyleSheet& rStyle)
{
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 29fee72..01204d6 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -477,12 +477,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
else
bHidden = bHideFormula = false;
- sal_uLong nConditional = ((const SfxUInt32Item&)pPattern->
- GetItem(ATTR_CONDITIONAL)).GetValue();
-
- const ScConditionalFormat* pCondForm = NULL;
- if ( nConditional && pCondFormList )
- pCondForm = pCondFormList->GetFormat( nConditional );
+ const std::vector<sal_uInt32>& rCondFormats = static_cast<const ScCondFormatItem&>(pPattern->GetItem(ATTR_CONDITIONAL)).GetCondFormatData();
+ bool bContainsCondFormat = !rCondFormats.empty();
do
{
@@ -493,7 +489,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
RowInfo* pThisRowInfo = &pRowInfo[nArrY];
if (pBackground != pDefBackground) // Spalten-HG == Standard ?
pThisRowInfo->bEmptyBack = false;
- if (pCondForm)
+ if (bContainsCondFormat)
pThisRowInfo->bEmptyBack = false;
if (bAutoFilter)
pThisRowInfo->bAutoFilter = true;
@@ -529,41 +525,50 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX
pThisRowInfo->bEmptyBack = false;
}
- if ( pCondForm )
+ if ( bContainsCondFormat )
{
- ScCondFormatData aData = pCondForm->GetData( pInfo->pCell,
- ScAddress( nX, nCurRow, nTab ) );
- if (!aData.aStyleName.isEmpty())
+ bool bFound = false;
+ for(std::vector<sal_uInt32>::const_iterator itr = rCondFormats.begin();
+ itr != rCondFormats.end() && !bFound; ++itr)
{
- SfxStyleSheetBase* pStyleSheet =
- pStlPool->Find( aData.aStyleName, SFX_STYLE_FAMILY_PARA );
- if ( pStyleSheet )
+ ScConditionalFormat* pCondForm = pCondFormList->GetFormat(*itr);
+ ScCondFormatData aData = pCondForm->GetData( pInfo->pCell,
+ ScAddress( nX, nCurRow, nTab ) );
+ if (!aData.aStyleName.isEmpty())
{
- //! Style-Sets cachen !!!
- pInfo->pConditionSet = &pStyleSheet->GetItemSet();
- bAnyCondition = true;
-
- // we need to check already here for protected cells
- const SfxPoolItem* pItem;
- if ( bTabProtect && pInfo->pConditionSet->GetItemState( ATTR_PROTECTION, true, &pItem ) == SFX_ITEM_SET )
+ SfxStyleSheetBase* pStyleSheet =
+ pStlPool->Find( aData.aStyleName, SFX_STYLE_FAMILY_PARA );
+ if ( pStyleSheet )
{
- const ScProtectionAttr* pProtAttr = static_cast<const ScProtectionAttr*>(pItem);
- bHidden = pProtAttr->GetHideCell();
- bHideFormula = pProtAttr->GetHideFormula();
+ //! Style-Sets cachen !!!
+ pInfo->pConditionSet = &pStyleSheet->GetItemSet();
+ bAnyCondition = true;
- }
+ // we need to check already here for protected cells
+ const SfxPoolItem* pItem;
+ if ( bTabProtect && pInfo->pConditionSet->GetItemState( ATTR_PROTECTION, true, &pItem ) == SFX_ITEM_SET )
+ {
+ const ScProtectionAttr* pProtAttr = static_cast<const ScProtectionAttr*>(pItem);
+ bHidden = pProtAttr->GetHideCell();
+ bHideFormula = pProtAttr->GetHideFormula();
+
+ }
+ bFound = true;
+ }
+ // if style is not there, treat like no condition
+ }
+ if(aData.pColorScale)
+ {
+ pInfo->pColorScale = aData.pColorScale;
+ bFound = true;
}
- // if style is not there, treat like no condition
- }
- if(aData.pColorScale)
- {
- pInfo->pColorScale = aData.pColorScale;
- }
- if(aData.pDataBar)
- {
- pInfo->pDataBar = aData.pDataBar;
+ if(aData.pDataBar)
+ {
+ pInfo->pDataBar = aData.pDataBar;
+ bFound = true;
+ }
}
}
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index eb22ac6..e3d3864 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2146,6 +2146,23 @@ void ScTable::ApplyPatternIfNumberformatIncompatible( const ScRange& rRange,
}
}
+void ScTable::AddCondFormatData( const ScRangeList& rRange, sal_uInt32 nIndex )
+{
+ size_t n = rRange.size();
+ for(size_t i = 0; i < n; ++i)
+ {
+ const ScRange* pRange = rRange[i];
+ SCCOL nColStart = pRange->aStart.Col();
+ SCCOL nColEnd = pRange->aEnd.Col();
+ SCROW nRowStart = pRange->aStart.Row();
+ SCROW nRowEnd = pRange->aEnd.Row();
+ for(SCCOL nCol = nColStart; nCol <= nColEnd; ++nCol)
+ {
+ aCol[nCol].AddCondFormat(nRowStart, nRowEnd, nIndex);
+ }
+ }
+}
+
void ScTable::ApplyStyle( SCCOL nCol, SCROW nRow, const ScStyleSheet& rStyle )
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 52b5c08..c68b03d 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5064,21 +5064,11 @@ namespace {
void RemoveCondFormatAttributes(ScDocument* pDoc, const ScConditionalFormat* pFormat)
{
const ScRangeList& rRangeList = pFormat->GetRange();
-
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, 0 ) );
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList(rRangeList, true);
- pDoc->ApplySelectionPattern( aPattern , aMarkData );
}
-void SetConditionalFormatAttributes(ScDocument* pDoc, const ScRangeList& rRanges, sal_uLong nIndex)
+void SetConditionalFormatAttributes(ScDocument* pDoc, const ScRangeList& rRanges, sal_uLong nIndex, SCTAB nTab)
{
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList(rRanges, true);
- pDoc->ApplySelectionPattern( aPattern , aMarkData );
+ pDoc->AddCondFormatData( rRanges, nTab, nIndex );
}
}
@@ -5112,7 +5102,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
sal_uLong nIndex = pDoc->AddCondFormat(pFormat, nTab);
- SetConditionalFormatAttributes(pDoc, rRanges, nIndex);
+ SetConditionalFormatAttributes(pDoc, rRanges, nIndex, nTab);
pDoc->SetStreamValid(nTab, false);
}
@@ -5142,7 +5132,7 @@ void ScDocFunc::SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB
{
sal_uLong nIndex = itr->GetKey();
const ScRangeList& rRange = itr->GetRange();
- SetConditionalFormatAttributes(pDoc, rRange, nIndex);
+ SetConditionalFormatAttributes(pDoc, rRange, nIndex, nTab);
}
pDoc->SetCondFormList(pList, nTab);
commit 8b100e1b0f90a43a0f4503415f114b1790606ea4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 23:25:19 2012 +0200
remove unused ATTR_COLORSCALE
Change-Id: I8118127b21144962275cb4486881b1e63b06ff0a
diff --git a/sc/inc/scitems.hxx b/sc/inc/scitems.hxx
index 57073f3..2f219e2 100644
--- a/sc/inc/scitems.hxx
+++ b/sc/inc/scitems.hxx
@@ -117,7 +117,6 @@
#define ATTR_SHADOW 152
#define ATTR_VALIDDATA 153
#define ATTR_CONDITIONAL 154
-#define ATTR_COLORSCALE 155
#define ATTR_PATTERN_END 155 // end cell-attribute-pattern
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index f2c9661..b0a8d7d 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -150,7 +150,6 @@ static SfxItemInfo const aItemInfos[] =
{ SID_ATTR_BORDER_SHADOW, SFX_ITEM_POOLABLE }, // ATTR_SHADOW
{ 0, SFX_ITEM_POOLABLE }, // ATTR_VALIDDATA
{ 0, SFX_ITEM_POOLABLE }, // ATTR_CONDITIONAL
- { 0, SFX_ITEM_POOLABLE }, // ATTR_COLORSCALE
{ 0, SFX_ITEM_POOLABLE }, // ATTR_PATTERN
{ SID_ATTR_LRSPACE, SFX_ITEM_POOLABLE }, // ATTR_LRSPACE
{ SID_ATTR_ULSPACE, SFX_ITEM_POOLABLE }, // ATTR_ULSPACE
@@ -289,7 +288,6 @@ ScDocumentPool::ScDocumentPool( SfxItemPool* pSecPool, sal_Bool bLoadRefCounts )
ppPoolDefaults[ ATTR_SHADOW - ATTR_STARTINDEX ] = new SvxShadowItem( ATTR_SHADOW );
ppPoolDefaults[ ATTR_VALIDDATA - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_VALIDDATA, 0 );
ppPoolDefaults[ ATTR_CONDITIONAL - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_CONDITIONAL, 0 );
- ppPoolDefaults[ ATTR_COLORSCALE - ATTR_STARTINDEX ] = new SfxUInt32Item( ATTR_COLORSCALE, 0 );
// GetRscString funktioniert erst nach ScGlobal::Init, zu erkennen am EmptyBrushItem
//! zusaetzliche Methode ScGlobal::IsInit() oder so...
commit 9aee608f4997201f29b740bf803f1f96ed4f7358
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 05:56:37 2012 +0200
also highlight invalid ranges
Change-Id: I51c725319acb0547963feddf18c0fb34aa6e4f25
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 5d56bec..50be91f 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -1168,6 +1168,13 @@ IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
IMPL_LINK_NOARG( ScCondFormatDlg, EdRangeModifyHdl )
{
+ rtl::OUString aRangeStr = maEdRange.GetText();
+ ScRangeList aRange;
+ sal_uInt16 nFlags = aRange.Parse(aRangeStr, mpDoc, SCA_VALID, mpDoc->GetAddressConvention());
+ if(nFlags & SCA_VALID)
+ maEdRange.SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
+ else
+ maEdRange.SetControlBackground(COL_LIGHTRED);
return 0;
}
commit 76063f78d510a1e3a2396dbfb8cc37d29f7b127d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 05:22:00 2012 +0200
add range edit box to cond format dialog
Change-Id: I913c844b08f2fd01963c60c4ffa948fc128a5897
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 51fc485..5d56bec 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -1089,10 +1089,12 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScCond
maBtnRemove( this, ScResId( BTN_REMOVE ) ),
maBtnOk( this, ScResId( BTN_OK ) ),
maBtnCancel( this, ScResId( BTN_CANCEL ) ),
+ maFtRange( this, ScResId( FT_RANGE ) ),
+ maEdRange( this, ScResId( ED_RANGE ) ),
maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, rPos ),
- maPos(rPos)
+ maPos(rPos),
+ mpDoc(pDoc)
{
-
rtl::OUStringBuffer aTitle( GetText() );
aTitle.append(rtl::OUString(" "));
rtl::OUString aRangeString;
@@ -1101,12 +1103,23 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScCond
SetText(aTitle.makeStringAndClear());
maBtnAdd.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, AddBtnHdl ) );
maBtnRemove.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, RemoveBtnHdl ) );
+ maEdRange.SetModifyHdl( LINK( &maEdRange, ScCondFormatDlg, EdRangeModifyHdl ) );
FreeResource();
+
+ maEdRange.SetText(aRangeString);
}
ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
{
- return maCondFormList.GetConditionalFormat();
+ rtl::OUString aRangeStr = maEdRange.GetText();
+ ScRangeList aRange;
+ sal_uInt16 nFlags = aRange.Parse(aRangeStr, mpDoc, SCA_VALID, mpDoc->GetAddressConvention());
+ ScConditionalFormat* pFormat = maCondFormList.GetConditionalFormat();
+
+ if(nFlags & SCA_VALID && !aRange.empty())
+ pFormat->AddRange(aRange);
+
+ return pFormat;
}
IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
@@ -1153,5 +1166,10 @@ IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
return 0;
}
+IMPL_LINK_NOARG( ScCondFormatDlg, EdRangeModifyHdl )
+{
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index d92e7a7..98bf32a 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -55,4 +55,7 @@
#define BTN_OPTIONS 30
#define STR_CONDITION 31
+#define FT_RANGE 32
+#define ED_RANGE 33
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index c5ea01d..5ddc027 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -177,10 +177,15 @@ private:
PushButton maBtnRemove;
OKButton maBtnOk;
CancelButton maBtnCancel;
+ FixedText maFtRange;
+ Edit maEdRange;
ScCondFormatList maCondFormList;
ScAddress maPos;
+ ScDocument* mpDoc;
+
+ DECL_LINK( EdRangeModifyHdl, void* );
public:
ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos);
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index 2800724..9a49776 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -50,14 +50,14 @@ ModalDialog RID_SCDLG_CONDFORMAT
};
PushButton BTN_ADD
{
- Pos = MAP_APPFONT( 5, 255 );
+ Pos = MAP_APPFONT( 5, 245 );
Size = MAP_APPFONT( 50, 14 );
Text [ en-US ] = "Add";
TabStop = TRUE;
};
PushButton BTN_REMOVE
{
- Pos = MAP_APPFONT( 60, 255 );
+ Pos = MAP_APPFONT( 60, 245 );
Size = MAP_APPFONT( 50, 14 );
Text [ en-US ] = "Remove";
TabStop = TRUE;
@@ -68,6 +68,18 @@ ModalDialog RID_SCDLG_CONDFORMAT
Size = MAP_APPFONT( 290, 220 );
Border = TRUE;
};
+ FixedText FT_RANGE
+ {
+ Pos = MAP_APPFONT( 5, 262 );
+ Size = MAP_APPFONT( 50, 16 );
+ Text [ en-US ] = "Range:";
+ };
+ Edit ED_RANGE
+ {
+ Pos = MAP_APPFONT( 60, 262 );
+ Size = MAP_APPFONT( 200, 14 );
+ Border = TRUE;
+ };
};
Control RID_COND_ENTRY
commit a57a183a2b8b613118b1d2a212ef3069f5ae7e90
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 04:34:10 2012 +0200
replace some pointers with boost::scoped_ptr
Change-Id: I5c263cd95262fae2f75069cb441752bbf7ce61f8
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index d31841d..0931899 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -216,8 +216,8 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, EditBtnHdl)
if(!pFormat)
return 0;
- ScCondFormatDlg* pDlg = new ScCondFormatDlg(this, mpDoc, pFormat, pFormat->GetRange(),
- pFormat->GetRange().GetTopLeftCorner());
+ boost::scoped_ptr<ScCondFormatDlg> pDlg(new ScCondFormatDlg(this, mpDoc, pFormat, pFormat->GetRange(),
+ pFormat->GetRange().GetTopLeftCorner()));
if(pDlg->Execute() == RET_OK)
{
sal_Int32 nKey = pFormat->GetKey();
@@ -227,7 +227,6 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, EditBtnHdl)
mpFormatList->InsertNew(pNewFormat);
maCtrlManager.Update();
}
- delete pDlg;
mbModified = true;
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index c4d79b5..b468530 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2057,15 +2057,15 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
aRangeList.push_back(pRange);
}
- AbstractScCondFormatDlg* pDlg = NULL;
+ boost::scoped_ptr<AbstractScCondFormatDlg> pDlg;
const ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
if(pCondFormat)
{
- pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, pCondFormat->GetRange(), aPos, RID_SCDLG_CONDFORMAT );
+ pDlg.reset(pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, pCondFormat->GetRange(), aPos, RID_SCDLG_CONDFORMAT ));
}
else
{
- pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), RID_SCDLG_CONDFORMAT );
+ pDlg.reset(pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), RID_SCDLG_CONDFORMAT ));
}
if(pDlg->Execute() == RET_OK)
@@ -2076,7 +2076,6 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
nOldIndex = pCondFormat->GetKey();
pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat( nOldIndex, pFormat, pData->GetTabNo(), pFormat->GetRange() );
}
- delete pDlg;
}
break;
@@ -2097,13 +2096,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
ScConditionalFormatList* pList = pDoc->GetCondFormList( aPos.Tab() );
- AbstractScCondFormatManagerDlg* pDlg = pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER);
+ boost::scoped_ptr<AbstractScCondFormatManagerDlg> pDlg(pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER));
if(pDlg->Execute() == RET_OK && pDlg->CondFormatsChanged())
{
ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
}
- delete pDlg;
}
break;
@@ -2113,10 +2111,9 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
ScDocument* pDoc = GetViewData()->GetDocument();
- AbstractScDataBarSettingsDlg* pDlg = pFact->CreateScDataBarSetttingsDlg( pTabViewShell->GetDialogParent(), pDoc, RID_SCDLG_DATABAR );
+ boost::scoped_ptr<AbstractScDataBarSettingsDlg> pDlg(pFact->CreateScDataBarSetttingsDlg( pTabViewShell->GetDialogParent(), pDoc, RID_SCDLG_DATABAR ));
OSL_ENSURE(pDlg, "Dialog create fail!");
pDlg->Execute();
- delete pDlg;
}
break;
@@ -2126,13 +2123,12 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
ScDocument* pDoc = GetViewData()->GetDocument();
- AbstractScDataBarSettingsDlg* pDlg = pFact->CreateScDataBarSetttingsDlg( pTabViewShell->GetDialogParent(), pDoc, RID_SCDLG_DATABAR );
+ boost::scoped_ptr<AbstractScDataBarSettingsDlg> pDlg(pFact->CreateScDataBarSetttingsDlg( pTabViewShell->GetDialogParent(), pDoc, RID_SCDLG_DATABAR ));
OSL_ENSURE(pDlg, "Dialog create fail!");
if(pDlg->Execute() == RET_OK)
{
//add here code that handles the data bar inserting
}
- delete pDlg;
}
break;
commit f94d197789cfd0c6418fd03cb18c3a1272150c4e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 04:27:42 2012 +0200
only set a new cond format list if it really changed
Change-Id: I820d1f083edb09abb262beba1536b1b1acba3321
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 7081ddb..aac528e 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -94,6 +94,8 @@ class AbstractScCondFormatManagerDlg : public VclAbstractDialog
{
public:
virtual ScConditionalFormatList* GetConditionalFormatList() = 0;
+
+ virtual bool CondFormatsChanged() = 0;
};
class AbstractScDataBarSettingsDlg : public VclAbstractDialog
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 4dd4bc3..7962c6d 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -462,6 +462,11 @@ ScConditionalFormatList* AbstractScCondFormatManagerDlg_Impl::GetConditionalForm
return pDlg->GetConditionalFormatList();
}
+bool AbstractScCondFormatManagerDlg_Impl::CondFormatsChanged()
+{
+ return pDlg->CondFormatsChanged();
+}
+
long AbstractScMetricInputDlg_Impl::GetInputValue( FieldUnit eUnit ) const
{
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index b4c6ddc..1462b75 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -148,6 +148,8 @@ class AbstractScCondFormatManagerDlg_Impl : public AbstractScCondFormatManagerDl
DECL_ABSTDLG_BASE(AbstractScCondFormatManagerDlg_Impl, ScCondFormatManagerDlg)
virtual ScConditionalFormatList* GetConditionalFormatList();
+
+ virtual bool CondFormatsChanged();
};
class AbstractScDataBarSettingsDlg_Impl : public AbstractScDataBarSettingsDlg
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 62b1fdc..d31841d 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -174,7 +174,8 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc
mpFormatList( pFormatList ? new ScConditionalFormatList(*pFormatList) : NULL),
maCtrlManager(this, pDoc, mpFormatList, rPos),
mpDoc(pDoc),
- maPos(rPos)
+ maPos(rPos),
+ mbModified(false)
{
FreeResource();
@@ -196,9 +197,15 @@ ScConditionalFormatList* ScCondFormatManagerDlg::GetConditionalFormatList()
return pList;
}
+bool ScCondFormatManagerDlg::CondFormatsChanged()
+{
+ return mbModified;
+}
+
IMPL_LINK_NOARG(ScCondFormatManagerDlg, RemoveBtnHdl)
{
maCtrlManager.DeleteSelection();
+ mbModified = true;
return 0;
}
@@ -222,6 +229,8 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, EditBtnHdl)
}
delete pDlg;
+ mbModified = true;
+
return 0;
}
diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx
index 3735e63..c71e2ef 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -85,6 +85,8 @@ public:
ScConditionalFormatList* GetConditionalFormatList();
+ bool CondFormatsChanged();
+
private:
PushButton maBtnAdd;
PushButton maBtnRemove;
@@ -104,6 +106,8 @@ private:
DECL_LINK(RemoveBtnHdl, void*);
DECL_LINK(EditBtnHdl, void*);
+
+ bool mbModified;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index a5b739e..c4d79b5 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2098,7 +2098,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
ScConditionalFormatList* pList = pDoc->GetCondFormList( aPos.Tab() );
AbstractScCondFormatManagerDlg* pDlg = pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER);
- if(pDlg->Execute() == RET_OK)
+ if(pDlg->Execute() == RET_OK && pDlg->CondFormatsChanged())
{
ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
commit 6c695e1208d2d40f6e1f1d61eb65261719f8dd8d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 04:10:37 2012 +0200
faster repaint after cond format dialog
Change-Id: Id5894efd385ad20c7a544142ce4fa4ec5d4ef062
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 9775708..52b5c08 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5090,9 +5090,11 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
if(pDoc->IsTabProtected(nTab))
return;
+ boost::scoped_ptr<ScRange> pRepaintRange;
if(nOldFormat)
{
ScConditionalFormat* pOldFormat = pDoc->GetCondFormList(nTab)->GetFormat(nOldFormat);
+ pRepaintRange.reset(new ScRange( pOldFormat->GetRange().Combine() ));
if(pOldFormat)
{
RemoveCondFormatAttributes(pDoc, pOldFormat);
@@ -5103,14 +5105,20 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
}
if(pFormat)
{
+ if(pRepaintRange)
+ pRepaintRange->ExtendTo(rRanges.Combine());
+ else
+ pRepaintRange.reset(new ScRange(rRanges.Combine()));
+
sal_uLong nIndex = pDoc->AddCondFormat(pFormat, nTab);
SetConditionalFormatAttributes(pDoc, rRanges, nIndex);
- size_t n = rRanges.size();
- for(size_t i = 0; i < n; ++i)
- pFormat->DoRepaint(rRanges[i]);
pDoc->SetStreamValid(nTab, false);
}
+
+ if(pRepaintRange)
+ rDocShell.PostPaint(*pRepaintRange, PAINT_GRID);
+
aModificator.SetDocumentModified();
SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
}
commit 6ba6fe0ce1cf000c59c5a4a71256625f5f89cbac
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 03:59:48 2012 +0200
after setting a ScConditionalFormatList repainting is necessary
Change-Id: I7283974ae8f12bd49c6ab806b1b052074f13a932
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 72dbd69..9775708 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5138,6 +5138,7 @@ void ScDocFunc::SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB
}
pDoc->SetCondFormList(pList, nTab);
+ rDocShell.PostPaintGridAll();
pDoc->SetStreamValid(nTab, false);
aModificator.SetDocumentModified();
commit 79b1868bf687ff105ce3bf3ccf583434946848aa
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Thu Oct 4 03:53:37 2012 +0200
more work on getting cell attributes and cond formats in sync
Change-Id: If10059a6d2b8d2449a01fe09eb2efb9ccea55806
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 41fdfe6..72dbd69 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5059,6 +5059,30 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
return sal_True;
}
+namespace {
+
+void RemoveCondFormatAttributes(ScDocument* pDoc, const ScConditionalFormat* pFormat)
+{
+ const ScRangeList& rRangeList = pFormat->GetRange();
+
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, 0 ) );
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList(rRangeList, true);
+ pDoc->ApplySelectionPattern( aPattern , aMarkData );
+}
+
+void SetConditionalFormatAttributes(ScDocument* pDoc, const ScRangeList& rRanges, sal_uLong nIndex)
+{
+ ScPatternAttr aPattern( pDoc->GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
+ ScMarkData aMarkData;
+ aMarkData.MarkFromRangeList(rRanges, true);
+ pDoc->ApplySelectionPattern( aPattern , aMarkData );
+}
+
+}
+
void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges )
{
ScDocShellModificator aModificator(rDocShell);
@@ -5068,6 +5092,12 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
if(nOldFormat)
{
+ ScConditionalFormat* pOldFormat = pDoc->GetCondFormList(nTab)->GetFormat(nOldFormat);
+ if(pOldFormat)
+ {
+ RemoveCondFormatAttributes(pDoc, pOldFormat);
+ }
+
pDoc->DeleteConditionalFormat(nOldFormat, nTab);
pDoc->SetStreamValid(nTab, false);
}
@@ -5075,11 +5105,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
{
sal_uLong nIndex = pDoc->AddCondFormat(pFormat, nTab);
- ScPatternAttr aPattern( pDoc->GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.MarkFromRangeList(rRanges, true);
- pDoc->ApplySelectionPattern( aPattern , aMarkData );
+ SetConditionalFormatAttributes(pDoc, rRanges, nIndex);
size_t n = rRanges.size();
for(size_t i = 0; i < n; ++i)
pFormat->DoRepaint(rRanges[i]);
@@ -5089,6 +5115,35 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
}
+void ScDocFunc::SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB nTab )
+{
+ ScDocShellModificator aModificator(rDocShell);
+ ScDocument* pDoc = rDocShell.GetDocument();
+ if(pDoc->IsTabProtected(nTab))
+ return;
+
+ // first remove all old entries
+ ScConditionalFormatList* pOldList = pDoc->GetCondFormList(nTab);
+ for(ScConditionalFormatList::const_iterator itr = pOldList->begin(), itrEnd = pOldList->end(); itr != itrEnd; ++itr)
+ {
+ RemoveCondFormatAttributes(pDoc, &(*itr));
+ }
+
+ // then set new entries
+ for(ScConditionalFormatList::iterator itr = pList->begin(); itr != pList->end(); ++itr)
+ {
+ sal_uLong nIndex = itr->GetKey();
+ const ScRangeList& rRange = itr->GetRange();
+ SetConditionalFormatAttributes(pDoc, rRange, nIndex);
+ }
+
+ pDoc->SetCondFormList(pList, nTab);
+
+ pDoc->SetStreamValid(nTab, false);
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
+}
+
void ScDocFunc::EnterListAction( sal_uInt16 nNameResId )
{
String aUndo( ScGlobal::GetRscString( nNameResId ) );
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 8d87bd9..3c9d64d 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -53,6 +53,7 @@ struct ScTabOpParam;
class ScTableProtection;
struct ScCellMergeOption;
class ScConditionalFormat;
+class ScConditionalFormatList;
// ---------------------------------------------------------------------------
@@ -212,6 +213,14 @@ public:
* @param pFormat if NULL only delete an old format
*/
virtual void ReplaceConditionalFormat( sal_uLong nOldIndex, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges );
+
+ /**
+ * Sets or replaces the conditional format list of a table
+ *
+ * @param pList the new ScConditionalFormatList, method takes ownership
+ * @param nTab the tab to which the conditional format list belongs
+ */
+ virtual void SetConditionalFormatList( ScConditionalFormatList* pList, SCTAB nTab );
};
class ScDocFuncDirect : public ScDocFunc
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index bd8f75a..a5b739e 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2100,7 +2100,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
AbstractScCondFormatManagerDlg* pDlg = pFact->CreateScCondFormatMgrDlg( pTabViewShell->GetDialogParent(), pDoc, pList, aPos, RID_SCDLG_COND_FORMAT_MANAGER);
if(pDlg->Execute() == RET_OK)
{
- pDoc->SetCondFormList(pDlg->GetConditionalFormatList(), aPos.Tab());
+ ScConditionalFormatList* pCondFormatList = pDlg->GetConditionalFormatList();
+ pData->GetDocShell()->GetDocFunc().SetConditionalFormatList(pCondFormatList, aPos.Tab());
}
delete pDlg;
}
More information about the Libreoffice-commits
mailing list