[Libreoffice-commits] .: Branch 'feature/cond-format-rework' - 6 commits - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 5 15:24:44 PDT 2012


 sc/inc/attarray.hxx                       |    1 
 sc/inc/column.hxx                         |    1 
 sc/inc/document.hxx                       |    2 
 sc/inc/table.hxx                          |    3 -
 sc/source/core/data/attarray.cxx          |   65 ++++++++++++++++++++---
 sc/source/core/data/column.cxx            |    5 +
 sc/source/core/data/column2.cxx           |    4 -
 sc/source/core/data/documen4.cxx          |   48 ++++++++++-------
 sc/source/core/data/documen6.cxx          |    3 -
 sc/source/core/data/document.cxx          |   11 +++
 sc/source/core/data/table1.cxx            |    4 -
 sc/source/core/data/table2.cxx            |   84 ++++++++++++++++++------------
 sc/source/core/data/table3.cxx            |   17 ------
 sc/source/filter/excel/xecontent.cxx      |    3 -
 sc/source/ui/condformat/condformatdlg.cxx |   10 +--
 sc/source/ui/docshell/docfunc.cxx         |    7 +-
 sc/source/ui/inc/condformatdlg.hxx        |    2 
 sc/source/ui/unoobj/cellsuno.cxx          |   14 ++---
 18 files changed, 179 insertions(+), 105 deletions(-)

New commits:
commit aa22cd2bd577a05d2b9ca96250cbb6507ee7125a
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 c7e2f3762f8af3155d9be5894e467518c59197f9
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 731920e47544f94f4c866afa89c0abb1ad3ee5c9
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 8ff9045376ef3448997435994488d9149daf9c12
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 af929c82a52b96f43472259f1008647911513d35
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 198591952ab45b1384a00c210f42e64b7e637c06
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 );


More information about the Libreoffice-commits mailing list