[Libreoffice-commits] .: 27 commits - officecfg/registry sc/AllLangResTarget_sc.mk sc/inc sc/Library_sc.mk sc/Library_scui.mk sc/sdi sc/source sc/uiconfig

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Sun Jun 10 23:20:15 PDT 2012


 officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |   17 
 sc/AllLangResTarget_sc.mk                                         |    3 
 sc/Library_sc.mk                                                  |    1 
 sc/Library_scui.mk                                                |    2 
 sc/inc/colorscale.hxx                                             |   81 
 sc/inc/conditio.hxx                                               |   84 
 sc/inc/document.hxx                                               |   12 
 sc/inc/sc.hrc                                                     |   31 
 sc/inc/scabstdlg.hxx                                              |   17 
 sc/inc/sccommands.h                                               |    3 
 sc/inc/table.hxx                                                  |   12 
 sc/sdi/cellsh.sdi                                                 |    5 
 sc/sdi/scalc.sdi                                                  |   39 
 sc/source/core/data/attarray.cxx                                  |   25 
 sc/source/core/data/colorscale.cxx                                |  201 -
 sc/source/core/data/conditio.cxx                                  |  480 ++--
 sc/source/core/data/documen4.cxx                                  |   52 
 sc/source/core/data/documen7.cxx                                  |   17 
 sc/source/core/data/fillinfo.cxx                                  |   39 
 sc/source/core/data/table1.cxx                                    |   30 
 sc/source/core/data/table2.cxx                                    |   76 
 sc/source/filter/excel/xecontent.cxx                              |   21 
 sc/source/filter/excel/xestyle.cxx                                |    9 
 sc/source/filter/excel/xicontent.cxx                              |    6 
 sc/source/filter/inc/condformatbuffer.hxx                         |    8 
 sc/source/filter/oox/condformatbuffer.cxx                         |  128 -
 sc/source/filter/xml/XMLConverter.cxx                             |   32 
 sc/source/filter/xml/XMLConverter.hxx                             |    2 
 sc/source/filter/xml/xmlcondformat.cxx                            |  170 +
 sc/source/filter/xml/xmlcondformat.hxx                            |   15 
 sc/source/filter/xml/xmlexprt.cxx                                 |  232 +-
 sc/source/filter/xml/xmlimprt.cxx                                 |   24 
 sc/source/filter/xml/xmlimprt.hxx                                 |   16 
 sc/source/filter/xml/xmlstyli.cxx                                 |    2 
 sc/source/ui/app/scdll.cxx                                        |    1 
 sc/source/ui/attrdlg/condfrmt.cxx                                 | 1039 ---------
 sc/source/ui/attrdlg/scdlgfact.cxx                                |   44 
 sc/source/ui/attrdlg/scdlgfact.hxx                                |   19 
 sc/source/ui/condformat/colorformat.cxx                           |  340 +++
 sc/source/ui/condformat/condformatdlg.cxx                         | 1057 ++++++++++
 sc/source/ui/docshell/docfunc.cxx                                 |   23 
 sc/source/ui/inc/colorformat.hrc                                  |   53 
 sc/source/ui/inc/colorformat.hxx                                  |   77 
 sc/source/ui/inc/condformatdlg.hrc                                |   57 
 sc/source/ui/inc/condformatdlg.hxx                                |  195 +
 sc/source/ui/inc/condfrmt.hrc                                     |   85 
 sc/source/ui/inc/condfrmt.hxx                                     |  179 -
 sc/source/ui/inc/docfunc.hxx                                      |    7 
 sc/source/ui/inc/reffact.hxx                                      |    1 
 sc/source/ui/src/colorformat.src                                  |  174 +
 sc/source/ui/src/condformatdlg.src                                |  226 ++
 sc/source/ui/src/condfrmt.src                                     |  442 ----
 sc/source/ui/unoobj/cellsuno.cxx                                  |    9 
 sc/source/ui/unoobj/fmtuno.cxx                                    |   49 
 sc/source/ui/view/cellsh.cxx                                      |   14 
 sc/source/ui/view/cellsh1.cxx                                     |   70 
 sc/source/ui/view/cellsh3.cxx                                     |   10 
 sc/source/ui/view/reffact.cxx                                     |    7 
 sc/source/ui/view/tabview3.cxx                                    |    1 
 sc/source/ui/view/tabvwsh.cxx                                     |    1 
 sc/source/ui/view/tabvwshc.cxx                                    |   15 
 sc/source/ui/view/viewfun2.cxx                                    |    2 
 sc/source/ui/view/viewfunc.cxx                                    |    8 
 sc/uiconfig/scalc/menubar/menubar.xml                             |    6 
 64 files changed, 3317 insertions(+), 2786 deletions(-)

New commits:
commit fe90ba33bf3c9adb586ff43625b5b75ccf26796d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Jun 11 07:58:51 2012 +0200

    remove unnecessary menu entries for 3-6
    
    they can go back in for 3-7 when we have overlapping conditional formats
    
    Change-Id: I029d247444368165df92dfbc123f4a7a2de647a1

diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml
index ec7c688..fbea1b9 100644
--- a/sc/uiconfig/scalc/menubar/menubar.xml
+++ b/sc/uiconfig/scalc/menubar/menubar.xml
@@ -261,8 +261,6 @@
             <menu:menuitem menu:id=".uno:AutoFormat"/>
             <menu:menu menu:id=".uno:ConditionalFormatMenu">
 	          <menu:menupopup>
-	            <menu:menuitem menu:id="uno:DataBarDialog"/>
-	            <menu:menuitem menu:id="uno:ColorScaleDialog"/>
 	            <menu:menuitem menu:id="uno:ConditionalFormatDialog"/>
 	          </menu:menupopup>
 	        </menu:menu>
commit 78c67ecb10ce741f9117cda7eb63ff4a3b6e086d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Jun 11 07:36:09 2012 +0200

    remove empty conditions for color format export to excel
    
    Change-Id: I8b35869f3e4455bb8cb16d67bd9636462a24e26b

diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 3395cf9..6021704 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -972,10 +972,6 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat
             {
                 if(pFormatEntry->GetType() == condformat::CONDITION)
                     maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), nIndex ) );
-                else if(pFormatEntry->GetType() == condformat::COLORSCALE)
-                    ;
-                else if(pFormatEntry->GetType() == condformat::DATABAR)
-                    ;
             }
         aScRanges.Format( msSeqRef, SCA_VALID, NULL, formula::FormulaGrammar::CONV_XL_A1 );
     }
commit 6655d658984ad7518b8ccae492433bf2f45bceb0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Jun 11 07:33:11 2012 +0200

    fix rebase problems
    
    Change-Id: If025dbfc3364f49151638a606928229dba0ee645

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index e8b3b36..1b241cf 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -322,6 +322,7 @@ private:
 public:
     ScConditionalFormatList() {}
     ScConditionalFormatList(const ScConditionalFormatList& rList);
+    ScConditionalFormatList(ScDocument* pDoc, const ScConditionalFormatList& rList);
     ~ScConditionalFormatList() {}
 
     void    InsertNew( ScConditionalFormat* pNew )
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 61ab60e..6ae7572 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1201,6 +1201,8 @@ public:
     SC_DLLPUBLIC void           FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab );
     void            ConditionalChanged( sal_uLong nKey, SCTAB nTab );
 
+    void SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab );
+
     SC_DLLPUBLIC sal_uLong          AddValidationEntry( const ScValidationData& rNew );
 
     SC_DLLPUBLIC const ScValidationData*    GetValidationEntry( sal_uLong nIndex ) const;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 7756f77..78cd977 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -796,6 +796,7 @@ public:
 
     ScConditionalFormatList* GetCondFormList();
     const ScConditionalFormatList* GetCondFormList() const;
+    void SetCondFormList( ScConditionalFormatList* pList );
 
     void DeleteConditionalFormat(sal_uLong nOldIndex);
 
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 52e5e2f..7a555a6 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1586,12 +1586,14 @@ bool ScConditionalFormat::MarkUsedExternalReferences() const
 
 ScConditionalFormatList::ScConditionalFormatList(const ScConditionalFormatList& rList)
 {
-    //  fuer Ref-Undo - echte Kopie mit neuen Tokens!
-
     for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr)
         InsertNew( itr->Clone() );
+}
 
-    //!     sortierte Eintraege aus rList schneller einfuegen ???
+ScConditionalFormatList::ScConditionalFormatList(ScDocument* pDoc, const ScConditionalFormatList& rList)
+{
+    for(const_iterator itr = rList.begin(); itr != rList.end(); ++itr)
+        InsertNew( itr->Clone(pDoc) );
 }
 
 bool ScConditionalFormatList::operator==( const ScConditionalFormatList& r ) const
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index f6bb911..a757d04 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -712,6 +712,12 @@ ScConditionalFormatList* ScDocument::GetCondFormList(SCTAB nTab) const
     return NULL;
 }
 
+void ScDocument::SetCondFormList( ScConditionalFormatList* pList, SCTAB nTab )
+{
+    if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
+        maTabs[nTab]->SetCondFormList(pList);
+}
+
 
 const ScValidationData* ScDocument::GetValidationEntry( sal_uLong nIndex ) const
 {
commit 4c462b24ab82147211e7e2bee7e6aa98893f429e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jun 10 07:17:49 2012 +0200

    correctly copy the cond formats, fdo#50679
    
    Change-Id: I52d645a8a7662016ced8c1eb6b320c4a14807353

diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index b562225..a81d2ca 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -629,6 +629,8 @@ void ScTable::CopyToClip(SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         if ( IsProtected() )
             for (i = nCol1; i <= nCol2; i++)
                 pTable->aCol[i].RemoveProtected(nRow1, nRow2);
+
+        pTable->mpCondFormatList.reset(new ScConditionalFormatList(pTable->pDocument, *mpCondFormatList));
     }
 }
 
@@ -663,8 +665,16 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
             {
                 ScConditionalFormat* pFormat = pOldCondFormatList->GetFormat(nId);
                 ScConditionalFormat* pNewFormat = pFormat->Clone(pDocument);
-                pNewFormat->SetKey(mpCondFormatList->size()+1);
+                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)
+                {
+                    if(itr->GetKey() > nMax)
+                        nMax = itr->GetKey();
+                }
+                pNewFormat->SetKey(nMax + 1);
                 mpCondFormatList->InsertNew(pNewFormat);
                 sal_Int32 nNewId = pNewFormat->GetKey();
                 aOldIdToNewId.insert( std::pair<sal_Int32, sal_Int32>( nId, nNewId ) );
@@ -680,6 +690,9 @@ void ScTable::CopyConditionalFormat( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCRO
     {
         sal_uInt32 nNewKey = aOldIdToNewId.find(itr->first)->second;
         ScConditionalFormat* pFormat = mpCondFormatList->GetFormat( nNewKey );
+        if(!pFormat)
+            continue;
+
         pFormat->UpdateReference(URM_MOVE, ScRange(nCol1 - nDx, nRow1 - nDy, pTable->nTab, nCol2 - nDx, nRow2 - nDy, pTable->nTab),
                 nDx, nDy, pTable->nTab - nTab);
         pFormat->AddRange(itr->second);
commit ec961611990a64753be34af2401037d2bf3b1109
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jun 10 03:16:02 2012 +0200

    correctly create between/not between entries
    
    Change-Id: I99e553e2e729c46d320f796361b0e04508b63e84

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 1f102f6..32869de 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -636,14 +636,14 @@ ScFormatEntry* ScCondFrmtEntry::createConditionEntry() const
 	    eMode = SC_COND_NOTEQUAL;
 	    break;
 	case 6:
-	    aExpr2 = maEdVal1.GetText();
+	    aExpr2 = maEdVal2.GetText();
 	    eMode = SC_COND_BETWEEN;
 	    if(aExpr2.isEmpty())
 		return NULL;
 	    break;
 	case 7:
 	    eMode = SC_COND_NOTBETWEEN;
-	    aExpr2 = maEdVal1.GetText();
+	    aExpr2 = maEdVal2.GetText();
 	    if(aExpr2.isEmpty())
 		return NULL;
 	    break;
commit 7b5ded5e33723230c7dee49394039f324ea819fa
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jun 10 03:10:57 2012 +0200

    set correct range as title + update for (not) between
    
    Change-Id: I4b819920417c1b2c67b27295170c7a56108fef64

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 0f27399..1f102f6 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -217,6 +217,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
 	maLbStyle.SelectEntry(aStyleName);
 	ScConditionMode eMode = pEntry->GetOperation();
 	maLbType.SelectEntryPos(1);
+	maEdVal1.SetText(pEntry->GetExpression(maPos, 0));
 	switch(eMode)
 	{
 	    case SC_COND_EQUAL:
@@ -238,9 +239,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
 		maLbCondType.SelectEntryPos(5);
 		break;
 	    case SC_COND_BETWEEN:
+		maEdVal2.SetText(pEntry->GetExpression(maPos, 1));
 		maLbCondType.SelectEntryPos(6);
 		break;
 	    case SC_COND_NOTBETWEEN:
+		maEdVal2.SetText(pEntry->GetExpression(maPos, 1));
 		maLbCondType.SelectEntryPos(7);
 		break;
 	    case SC_COND_DUPLICATE:
@@ -374,6 +377,7 @@ void ScCondFrmtEntry::Init()
     maBtOptions.SetClickHdl( LINK( this, ScCondFrmtEntry, OptionBtnHdl ) );
     maLbDataBarMinType.SetSelectHdl( LINK( this, ScCondFrmtEntry, DataBarTypeSelectHdl ) );
     maLbDataBarMaxType.SetSelectHdl( LINK( this, ScCondFrmtEntry, DataBarTypeSelectHdl ) );
+    maLbCondType.SetSelectHdl( LINK( this, ScCondFrmtEntry, ConditionTypeSelectHdl ) );
 
     mpDataBarData.reset(new ScDataBarFormatData());
     mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry());
@@ -860,6 +864,23 @@ IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
     return 0;
 }
 
+IMPL_LINK_NOARG( ScCondFrmtEntry, ConditionTypeSelectHdl )
+{
+    if(maLbCondType.GetSelectEntryPos() == 6 || maLbCondType.GetSelectEntryPos() == 7)
+    {
+	std::cout << "OldSize: " << maEdVal1.GetSizePixel().Width() << " " << maEdVal1.GetSizePixel().Height() << std::endl;
+	maEdVal1.SetSizePixel(maEdVal2.GetSizePixel());
+	maEdVal2.Show();
+    }
+    else
+    {
+	maEdVal2.Hide();
+	Size aSize(193, 30);
+	maEdVal1.SetSizePixel(aSize);
+    }
+    return 0;
+}
+
 ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc):
     Control(pParent, rResId),
     mbHasScrollBar(false),
@@ -981,7 +1002,7 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScCond
     rtl::OUStringBuffer aTitle( GetText() );
     aTitle.append(rtl::OUString(" "));
     rtl::OUString aRangeString;
-    rRange.Format(aRangeString, 0, pDoc);
+    rRange.Format(aRangeString, SCA_VALID, pDoc, pDoc->GetAddressConvention());
     aTitle.append(aRangeString);
     SetText(aTitle.makeStringAndClear());
     maBtnAdd.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, AddBtnHdl ) );
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 9ffa872..2a4a89b 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5075,7 +5075,7 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
 	ScMarkData aMarkData;
 	aMarkData.MarkFromRangeList(rRanges, true);
 	pDoc->ApplySelectionPattern( aPattern , aMarkData );
-	size_t n = rRanges.size()
+	size_t n = rRanges.size();
 	for(size_t i = 0; i < n; ++i)
 	    pFormat->DoRepaint(rRanges[i]);
     }
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 70fef96..e66c090 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -126,6 +126,7 @@ private:
     DECL_LINK( StyleSelectHdl, void* );
     DECL_LINK( OptionBtnHdl, void* );
     DECL_LINK( DataBarTypeSelectHdl, void* );
+    DECL_LINK( ConditionTypeSelectHdl, void* );
 
 public:
     ScCondFrmtEntry( Window* pParent, ScDocument* pDoc );
commit 796e18826275b4b831c23e41d13c0665e356350b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jun 10 02:21:24 2012 +0200

    fix repainting of conditional formats
    
    Change-Id: I14da7e5cdb1bdd4bb3bcd4e03d379f0858c7f999

diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index f4d137b..52e5e2f 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1486,87 +1486,7 @@ bool lcl_CutRange( ScRange& rRange, const ScRange& rOther )
 
 void ScConditionalFormat::DoRepaint( const ScRange* pModified )
 {
-    /*
-    SfxObjectShell* pSh = pDoc->GetDocumentShell();
-    if (pSh)
-    {
-        //  Rahmen/Schatten enthalten?
-        //  (alle Bedingungen testen)
-        bool bExtend = false;
-        bool bRotate = false;
-        bool bAttrTested = false;
-
-        if (!pAreas)        //  RangeList ggf. holen
-        {
-            pAreas = new ScRangeList;
-            pDoc->FindConditionalFormat( nKey, pRanges->front()->aStart.Tab(), *pAreas );
-        }
-        for (size_t i = 0, nCount = pAreas->size(); i < nCount; i++ )
-        {
-            ScRange aRange = *(*pAreas)[i];
-            bool bDo = true;
-            if ( pModified )
-            {
-                if ( !lcl_CutRange( aRange, *pModified ) )
-                    bDo = false;
-            }
-            if (bDo)
-            {
-                if ( !bAttrTested )
-                {
-                    // Look at the style's content only if the repaint is necessary
-                    // for any condition, to avoid the time-consuming Find() if there are many
-                    // conditional formats and styles.
-                    for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
-                    {
-                        String aStyle = ppEntries[nEntry]->GetStyle();
-                        if (aStyle.Len())
-                        {
-                            SfxStyleSheetBase* pStyleSheet =
-                                pDoc->GetStyleSheetPool()->Find( aStyle, SFX_STYLE_FAMILY_PARA );
-                            if ( pStyleSheet )
-                            {
-                                const SfxItemSet& rSet = pStyleSheet->GetItemSet();
-                                if (rSet.GetItemState( ATTR_BORDER, true ) == SFX_ITEM_SET ||
-                                    rSet.GetItemState( ATTR_SHADOW, true ) == SFX_ITEM_SET)
-                                {
-                                    bExtend = true;
-                                }
-                                if (rSet.GetItemState( ATTR_ROTATE_VALUE, true ) == SFX_ITEM_SET ||
-                                    rSet.GetItemState( ATTR_ROTATE_MODE, true ) == SFX_ITEM_SET)
-                                {
-                                    bRotate = true;
-                                }
-                            }
-                        }
-                    }
-                    bAttrTested = true;
-                }
-
-                lcl_Extend( aRange, pDoc, bExtend );        // zusammengefasste und bExtend
-                if ( bRotate )
-                {
-                    aRange.aStart.SetCol(0);
-                    aRange.aEnd.SetCol(MAXCOL);     // gedreht: ganze Zeilen
-                }
-
-                // gedreht -> ganze Zeilen
-                if ( aRange.aStart.Col() != 0 || aRange.aEnd.Col() != MAXCOL )
-                {
-                    if ( pDoc->HasAttrib( 0,aRange.aStart.Row(),aRange.aStart.Tab(),
-                                            MAXCOL,aRange.aEnd.Row(),aRange.aEnd.Tab(),
-                                            HASATTR_ROTATE ) )
-                    {
-                        aRange.aStart.SetCol(0);
-                        aRange.aEnd.SetCol(MAXCOL);
-                    }
-                }
-
-                pDoc->RepaintRange( aRange );
-            }
-        }
-    }
-    */
+    pDoc->RepaintRange(*pModified);
 }
 
 void ScConditionalFormat::CompileAll()
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 191dd78..9ffa872 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5075,6 +5075,9 @@ void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFor
 	ScMarkData aMarkData;
 	aMarkData.MarkFromRangeList(rRanges, true);
 	pDoc->ApplySelectionPattern( aPattern , aMarkData );
+	size_t n = rRanges.size()
+	for(size_t i = 0; i < n; ++i)
+	    pFormat->DoRepaint(rRanges[i]);
     }
     aModificator.SetDocumentModified();
     SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
commit ecc2805d642d2ec562d8ba15a799fcf7d6fae0d8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sun Jun 10 01:59:23 2012 +0200

    correctly set new conditional format
    
     #
    
    Change-Id: I6dc3f1cd99cd15aa3dad72a1417f3e2c1af0108d

diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 73e6ece..e8b3b36 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -349,6 +349,8 @@ public:
     SC_DLLPUBLIC const_iterator end() const;
 
     size_t size() const;
+
+    void erase(sal_uLong nIndex);
 };
 
 #endif
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index cc2780f..61ab60e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1196,6 +1196,7 @@ public:
     void            ChangeSelectionIndent( bool bIncrement, const ScMarkData& rMark );
 
     SC_DLLPUBLIC sal_uLong AddCondFormat( ScConditionalFormat* pNew, SCTAB nTab );
+    void DeleteConditionalFormat( sal_uLong nIndex, SCTAB nTab );
     SC_DLLPUBLIC void           FindConditionalFormat( sal_uLong nKey, SCTAB nTab, ScRangeList& rRanges );
     SC_DLLPUBLIC void           FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SCTAB nTab );
     void            ConditionalChanged( sal_uLong nKey, SCTAB nTab );
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 4c5d697..7756f77 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -797,6 +797,8 @@ public:
     ScConditionalFormatList* GetCondFormList();
     const ScConditionalFormatList* GetCondFormList() const;
 
+    void DeleteConditionalFormat(sal_uLong nOldIndex);
+
     sal_uLong          AddCondFormat( ScConditionalFormat* pNew );
 
 private:
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 08ef1db..3c333f9 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -144,14 +144,6 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern, bool bAlloc )
                 aAdrEnd  .SetRow( pData[i].nRow );
                 pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
             }
-            // conditional format or deleted?
-            if ( &pPattern->GetItem(ATTR_CONDITIONAL) != &pOldPattern->GetItem(ATTR_CONDITIONAL) )
-            {
-                pDocument->ConditionalChanged( ((const SfxUInt32Item&)
-                                pOldPattern->GetItem(ATTR_CONDITIONAL)).GetValue(), nTab );
-                pDocument->ConditionalChanged( ((const SfxUInt32Item&)
-                                pPattern->GetItem(ATTR_CONDITIONAL)).GetValue(), nTab );
-            }
             pDocPool->Remove(*pOldPattern);
         }
         delete[] pData;
@@ -370,13 +362,6 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern
                     aAdrEnd  .SetRow( Min(nEndRow,pData[nx].nRow) );
                     pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
                 }
-                if ( &rNewSet.Get(ATTR_CONDITIONAL) != &rOldSet.Get(ATTR_CONDITIONAL) )
-                {
-                    pDocument->ConditionalChanged( ((const SfxUInt32Item&)
-                                    rOldSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab );
-                    pDocument->ConditionalChanged( ((const SfxUInt32Item&)
-                                    rNewSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab );
-                }
                 ns = pData[nx].nRow + 1;
                 nx++;
             }
@@ -773,16 +758,6 @@ void ScAttrArray::ApplyCacheArea( SCROW nStartRow, SCROW nEndRow, SfxItemPoolCac
                         pDocument->InvalidateTextWidth( &aAdrStart, &aAdrEnd, bNumFormatChanged );
                     }
 
-                    // Reset conditional formats or delete ?
-
-                    if ( &rNewSet.Get(ATTR_CONDITIONAL) != &rOldSet.Get(ATTR_CONDITIONAL) )
-                    {
-                        pDocument->ConditionalChanged( ((const SfxUInt32Item&)
-                                        rOldSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab );
-                        pDocument->ConditionalChanged( ((const SfxUInt32Item&)
-                                        rNewSet.Get(ATTR_CONDITIONAL)).GetValue(), nTab );
-                    }
-
                     pDocument->GetPool()->Remove(*pData[nPos].pPattern);
                     pData[nPos].pPattern = pNewPattern;
                     if (Concat(nPos))
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index 77b1540..f4d137b 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1762,4 +1762,16 @@ size_t ScConditionalFormatList::size() const
     return maConditionalFormats.size();
 }
 
+void ScConditionalFormatList::erase( sal_uLong nIndex )
+{
+    for( iterator itr = begin(); itr != end(); ++itr )
+    {
+        if( itr->GetKey() == nIndex )
+        {
+            maConditionalFormats.erase(itr);
+            break;
+        }
+    }
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 52b9f8b..f6bb911 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -733,12 +733,10 @@ void ScDocument::FindConditionalFormat( sal_uLong nKey, ScRangeList& rRanges, SC
         maTabs[nTab]->FindConditionalFormat( nKey, rRanges );
 }
 
-void ScDocument::ConditionalChanged( sal_uLong nKey, SCTAB nTab )
+void ScDocument::DeleteConditionalFormat(sal_uLong nOldIndex, SCTAB nTab)
 {
-    ScConditionalFormatList* pCondFormList = GetCondFormList(nTab);
-    if ( nKey && pCondFormList && !bIsClip && !bIsUndo )        // nKey==0 -> noop
-    {
-    }
+    if(VALIDTAB(nTab) && nTab < static_cast<SCTAB>(maTabs.size()) && maTabs[nTab])
+        maTabs[nTab]->DeleteConditionalFormat(nOldIndex);
 }
 
 //------------------------------------------------------------------------
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index b1acdf6..bdf7832 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -2016,6 +2016,11 @@ sal_uLong ScTable::AddCondFormat( ScConditionalFormat* pNew )
     return nMax + 1;
 }
 
+void ScTable::DeleteConditionalFormat( sal_uLong nIndex )
+{
+    mpCondFormatList->erase(nIndex);
+}
+
 void ScTable::SetCondFormList( ScConditionalFormatList* pNew )
 {
     mpCondFormatList.reset( pNew );
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 6f13586..0f27399 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -84,6 +84,34 @@ void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType,
     rLbCol.SelectEntry(rEntry.GetColor());
 }
 
+void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit )
+{
+    if(rEntry.GetMin())
+	rLbType.SelectEntryPos(0);
+    else if(rEntry.GetMax())
+	rLbType.SelectEntryPos(1);
+    else if(rEntry.GetPercentile())
+    {
+	rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+	rLbType.SelectEntryPos(2);
+    }
+    else if(rEntry.GetPercent())
+    {
+	rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+	rLbType.SelectEntryPos(4);
+    }
+    else if(rEntry.HasFormula())
+    {
+	rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
+	rLbType.SelectEntryPos(5);
+    }
+    else
+    {
+	rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+	rLbType.SelectEntryPos(3);
+    }
+}
+
 }
 
 ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
@@ -132,6 +160,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
     maLbEntryTypeMin.SelectEntryPos(0);
     maLbEntryTypeMiddle.SelectEntryPos(2);
     maLbEntryTypeMax.SelectEntryPos(1);
+    maLbDataBarMinType.SelectEntryPos(0);
+    maLbDataBarMaxType.SelectEntryPos(1);
+    maEdMiddle.SetText(rtl::OUString::valueOf(50));
+    maEdDataBarMin.Disable();
+    maEdDataBarMax.Disable();
 
     Init();
     maLbStyle.SelectEntryPos(1);
@@ -250,6 +283,9 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
 	mpDataBarData.reset(new ScDataBarFormatData(*pEntry->GetDataBarData()));
 	maLbType.SelectEntryPos(0);
 	maLbColorFormat.SelectEntryPos(2);
+	SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin);
+	SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax);
+	DataBarTypeSelectHdl(NULL);
 	SetDataBarType();
     }
 
@@ -288,7 +324,7 @@ void ScCondFrmtEntry::Init()
     maLbEntryTypeMiddle.SetPosPixel(aPointLb);
     maEdMiddle.SetPosPixel(aPointEd);
     maLbColMiddle.SetPosPixel(aPointCol);
-    maEdDataBarMin.SetPosPixel(aPointEdDataBar);
+    maEdDataBarMax.SetPosPixel(aPointEdDataBar);
     maLbDataBarMaxType.SetPosPixel(aPointLbDataBar);
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
@@ -336,12 +372,15 @@ void ScCondFrmtEntry::Init()
     }
 
     maBtOptions.SetClickHdl( LINK( this, ScCondFrmtEntry, OptionBtnHdl ) );
+    maLbDataBarMinType.SetSelectHdl( LINK( this, ScCondFrmtEntry, DataBarTypeSelectHdl ) );
+    maLbDataBarMaxType.SetSelectHdl( LINK( this, ScCondFrmtEntry, DataBarTypeSelectHdl ) );
 
     mpDataBarData.reset(new ScDataBarFormatData());
     mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry());
     mpDataBarData->mpLowerLimit.reset(new ScColorScaleEntry());
     mpDataBarData->mpLowerLimit->SetMin(true);
     mpDataBarData->mpUpperLimit->SetMax(true);
+    mpDataBarData->maPositiveColor = COL_LIGHTBLUE;
 }
 
 namespace {
@@ -373,10 +412,20 @@ rtl::OUString getExpression(sal_Int32 nIndex)
 	    return rtl::OUString("<");
 	case 2:
 	    return rtl::OUString(">");
+	case 3:
+	    return rtl::OUString("<=");
+	case 4:
+	    return rtl::OUString(">=");
 	case 5:
 	    return rtl::OUString("!=");
-	default:
-	    return rtl::OUString("not yet supported");
+	case 6:
+	    return rtl::OUString("between");
+	case 7:
+	    return rtl::OUString("not between");
+	case 8:
+	    return rtl::OUString("duplicate");
+	case 9:
+	    return rtl::OUString("unique");
     }
     return rtl::OUString();
 }
@@ -401,7 +450,8 @@ void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
 		maLbType.Hide();
 		rtl::OUStringBuffer maCondText(getTextForType(meType));
 		maCondText.append(rtl::OUString(" "));
-		maCondText.append(getExpression(maLbCondType.GetSelectEntryPos()));
+		if(meType == CONDITION)
+		    maCondText.append(getExpression(maLbCondType.GetSelectEntryPos()));
 		maFtCondition.SetText(maCondText.makeStringAndClear());
 		maFtCondition.Show();
 	    }
@@ -612,9 +662,8 @@ ScFormatEntry* ScCondFrmtEntry::createConditionEntry() const
 
 namespace {
 
-ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
+void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
 {
-    ScColorScaleEntry* pEntry = new ScColorScaleEntry();
     double nVal = rtl::math::stringToDouble(rValue.GetText(), '.', ',');
     switch(rType.GetSelectEntryPos())
     {
@@ -639,7 +688,13 @@ ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListB
 	    pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
 	    break;
     }
+}
 
+ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
+{
+    ScColorScaleEntry* pEntry = new ScColorScaleEntry();
+
+    SetColorScaleEntry( pEntry, rType, rValue, pDoc, rPos );
     Color aColor = rColor.GetSelectEntryColor();
     pEntry->SetColor(aColor);
     return pEntry;
@@ -774,13 +829,33 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl)
     return 0;
 }
 
+IMPL_LINK_NOARG( ScCondFrmtEntry, DataBarTypeSelectHdl )
+{
+    sal_Int32 nSelectPos = maLbDataBarMinType.GetSelectEntryPos();
+    if(nSelectPos == 0 || nSelectPos == 1)
+	maEdDataBarMin.Disable();
+    else
+	maEdDataBarMin.Enable();
+
+    nSelectPos = maLbDataBarMaxType.GetSelectEntryPos();
+    if(nSelectPos == 0 || nSelectPos == 1)
+	maEdDataBarMax.Disable();
+    else
+	maEdDataBarMax.Enable();
+
+    return 0;
+}
+
 IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
 {
+    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), maLbDataBarMinType, maEdDataBarMin, mpDoc, maPos);
+    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), maLbDataBarMaxType, maEdDataBarMax, mpDoc, maPos);
     ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this, *mpDataBarData);
     if( pDlg->Execute() == RET_OK)
     {
-	std::cout << "Ok" << std::endl;
 	mpDataBarData.reset(pDlg->GetData());
+	SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin);
+	SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax);
     }
     return 0;
 }
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index ffd5e1a..191dd78 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -5058,7 +5058,27 @@ sal_Bool ScDocFunc::InsertAreaLink( const String& rFile, const String& rFilter,
     return sal_True;
 }
 
+void ScDocFunc::ReplaceConditionalFormat( sal_uLong nOldFormat, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges )
+{
+    ScDocShellModificator aModificator(rDocShell);
+    ScDocument* pDoc = rDocShell.GetDocument();
+    if(nOldFormat)
+    {
+	pDoc->DeleteConditionalFormat(nOldFormat, nTab);
+    }
+    if(pFormat)
+    {
+	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 );
+    }
+    aModificator.SetDocumentModified();
+    SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
+}
 
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index d1f80a9..70fef96 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -125,6 +125,7 @@ private:
     DECL_LINK( ColFormatTypeHdl, void*);
     DECL_LINK( StyleSelectHdl, void* );
     DECL_LINK( OptionBtnHdl, void* );
+    DECL_LINK( DataBarTypeSelectHdl, void* );
 
 public:
     ScCondFrmtEntry( Window* pParent, ScDocument* pDoc );
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index 9ea375a..f8b6b9b 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -52,6 +52,7 @@ class ScTokenArray;
 struct ScTabOpParam;
 class ScTableProtection;
 struct ScCellMergeOption;
+class ScConditionalFormat;
 
 // ---------------------------------------------------------------------------
 
@@ -202,6 +203,12 @@ public:
                                             const String& rOptions, const String& rSource,
                                             const ScRange& rDestRange, sal_uLong nRefresh,
                                             sal_Bool bFitBlock, sal_Bool bApi );
+
+    /**
+     * @param nOldIndex If 0 don't delete an old format
+     * @param pFormat if NULL only delete an old format
+     */
+    virtual void ReplaceConditionalFormat( sal_uLong nOldIndex, ScConditionalFormat* pFormat, SCTAB nTab, const ScRangeList& rRanges );
 };
 
 class ScDocFuncDirect : public ScDocFunc
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index d9c78cd..c0a59a9 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2056,11 +2056,11 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
 
                 ScRangeList aRangeList;
-                ScViewData* pViewData = GetViewData();
-                pViewData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
+                ScViewData* pData = GetViewData();
+                pData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
                 ScDocument* pDoc = GetViewData()->GetDocument();
 
-                ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
+                ScAddress aPos(pData->GetCurX(), pData->GetCurY(), pData->GetTabNo());
                 AbstractScCondFormatDlg* pDlg = NULL;
                 const ScConditionalFormat* pCondFormat = pDoc->GetCondFormat(aPos.Col(), aPos.Row(), aPos.Tab());
                 if(pCondFormat)
@@ -2075,11 +2075,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 if(pDlg->Execute() == RET_OK)
                 {
                     ScConditionalFormat* pFormat = pDlg->GetConditionalFormat();
-                    sal_uLong nIndex = pDoc->AddCondFormat(pFormat, pViewData->GetTabNo());
-
-                    ScPatternAttr aPattern( pDoc->GetPool() );
-                    aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
-                    pDoc->ApplySelectionPattern( aPattern , pViewData->GetMarkData() );
+                    sal_uLong nOldIndex = 0;
+                    if(pCondFormat)
+                        nOldIndex = pCondFormat->GetKey();
+                    pData->GetDocShell()->GetDocFunc().ReplaceConditionalFormat( nOldIndex, pFormat, pData->GetTabNo(), pFormat->GetRange() );
                 }
                 delete pDlg;
             }
commit c161e8a5a816f649e21105b09723f620336507ac
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jun 8 09:38:01 2012 +0200

    more support for data bars in new dialogs
    
    Change-Id: I2292517a060a12c1d0dffd70558afc8a57e89754

diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index 745d123..de45815 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -33,6 +33,7 @@
 
 #include <svx/xtable.hxx>
 #include <svx/drawitem.hxx>
+#include <vcl/msgbox.hxx>
 
 ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow):
     ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ),
@@ -66,7 +67,7 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow):
 
 namespace {
 
-void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox)
+void SetType(const ScColorScaleEntry* pEntry, ListBox& aLstBox)
 {
     if(pEntry->GetMin())
         aLstBox.SelectEntryPos(0);
@@ -82,6 +83,37 @@ void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox)
         aLstBox.SelectEntryPos(4);
 }
 
+void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry )
+{
+    double nVal = 0;
+    switch(rLstBox.GetSelectEntryPos())
+    {
+        case 0:
+            pEntry->SetMin(true);
+            break;
+        case 1:
+            pEntry->SetMax(true);
+            break;
+        case 2:
+            pEntry->SetPercentile(true);
+            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetValue(nVal);
+            break;
+        case 3:
+            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetPercent(true);
+            pEntry->SetValue(nVal);
+            break;
+        case 4:
+            //FIXME
+            break;
+        case 5:
+            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetValue(nVal);
+            break;
+    }
+}
+
 void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit)
 {
     if(pEntry->HasFormula())
@@ -94,6 +126,53 @@ void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit)
 
 }
 
+ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, const ScDataBarFormatData& rData):
+    ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ),
+    maBtnOk( this, ScResId( BTN_OK ) ),
+    maBtnCancel( this, ScResId( BTN_CANCEL ) ),
+    maFlBarColors( this, ScResId( FL_BAR_COLORS ) ),
+    maFlAxes( this, ScResId( FL_AXIS ) ),
+    maFlValues( this, ScResId( FL_VALUES ) ),
+    maFtMin( this, ScResId( FT_MINIMUM ) ),
+    maFtMax( this, ScResId( FT_MAXIMUM ) ),
+    maFtPositive( this, ScResId( FT_POSITIVE ) ),
+    maFtNegative( this, ScResId( FT_NEGATIVE ) ),
+    maFtPosition( this, ScResId( FT_POSITION ) ),
+    maFtAxisColor( this, ScResId( FT_COLOR_AXIS ) ),
+    maLbPos( this, ScResId( LB_POS ) ),
+    maLbNeg( this, ScResId( LB_NEG ) ),
+    maLbAxisCol( this, ScResId( LB_COL_AXIS ) ),
+    maLbTypeMin( this, ScResId( LB_TYPE ) ),
+    maLbTypeMax( this, ScResId( LB_TYPE ) ),
+    maLbAxisPos( this, ScResId( LB_AXIS_POSITION ) ),
+    maEdMin( this, ScResId( ED_MIN ) ),
+    maEdMax( this, ScResId( ED_MAX ) )
+{
+    Init();
+    FreeResource();
+
+    maLbPos.SelectEntry( rData.maPositiveColor );
+    if(rData.mpNegativeColor)
+        maLbNeg.SelectEntry( *rData.mpNegativeColor );
+
+    switch (rData.meAxisPosition)
+    {
+        case databar::NONE:
+            maLbAxisPos.SelectEntryPos(2);
+            break;
+        case databar::AUTOMATIC:
+            maLbAxisPos.SelectEntryPos(0);
+            break;
+        case databar::MIDDLE:
+            maLbAxisPos.SelectEntryPos(1);
+            break;
+    }
+    ::SetType(rData.mpLowerLimit.get(), maLbTypeMin);
+    ::SetType(rData.mpUpperLimit.get(), maLbTypeMax);
+    SetValue(rData.mpLowerLimit.get(), maEdMin);
+    SetValue(rData.mpUpperLimit.get(), maEdMax);
+}
+
 ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, ScDataBarFormat* pFormat):
     ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ),
     maBtnOk( this, ScResId( BTN_OK ) ),
@@ -188,6 +267,43 @@ void ScDataBarSettingsDlg::Init()
     maLbTypeMax.SetPosPixel(aPoint);
 }
 
+namespace {
+
+void GetAxesPosition(ScDataBarFormatData* pData, const ListBox& rLbox)
+{
+    switch(rLbox.GetSelectEntryPos())
+    {
+        case 0:
+            pData->meAxisPosition = databar::AUTOMATIC;
+            break;
+        case 1:
+            pData->meAxisPosition = databar::MIDDLE;
+            break;
+        case 2:
+            pData->meAxisPosition = databar::NONE;
+            break;
+    }
+}
+
+
+}
+
+ScDataBarFormatData* ScDataBarSettingsDlg::GetData()
+{
+    ScDataBarFormatData* pData = new ScDataBarFormatData();
+    pData->maPositiveColor = maLbPos.GetSelectEntryColor();
+    pData->mpNegativeColor.reset(new Color(maLbNeg.GetSelectEntryColor()));
+    pData->mbGradient = true; //FIXME
+    pData->mpUpperLimit.reset(new ScColorScaleEntry());
+    pData->mpLowerLimit.reset(new ScColorScaleEntry());
+
+    ::GetType(maLbTypeMin, maEdMin, pData->mpLowerLimit.get());
+    ::GetType(maLbTypeMax, maEdMax, pData->mpUpperLimit.get());
+    GetAxesPosition(pData, maLbAxisPos);
+
+    return pData;
+}
+
 IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
 {
     //check that min < max
@@ -216,7 +332,7 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
     }
     else
     {
-        Close();
+        EndDialog(RET_OK);
     }
     return 0;
 }
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 2f46754..6f13586 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -36,6 +36,7 @@
 #include <svl/intitem.hxx>
 #include <svx/xtable.hxx>
 #include <svx/drawitem.hxx>
+#include <vcl/msgbox.hxx>
 
 #include "anyrefdg.hxx"
 #include "document.hxx"
@@ -44,6 +45,7 @@
 #include "tabvwsh.hxx"
 #include "conditio.hxx"
 #include "colorscale.hxx"
+#include "colorformat.hxx"
 
 #include <rtl/math.hxx>
 
@@ -164,6 +166,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
     maLbColMin( this, ScResId( LB_COL) ),
     maLbColMiddle( this, ScResId( LB_COL) ),
     maLbColMax( this, ScResId( LB_COL) ),
+    maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ),
+    maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ),
+    maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ),
+    maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ),
+    maBtOptions( this, ScResId( BTN_OPTIONS ) ),
     mpDoc(pDoc)
 {
     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
@@ -240,6 +247,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
     else if( pFormatEntry && pFormatEntry->GetType() == condformat::DATABAR )
     {
 	const ScDataBarFormat* pEntry = static_cast<const ScDataBarFormat*>(pFormatEntry);
+	mpDataBarData.reset(new ScDataBarFormatData(*pEntry->GetDataBarData()));
 	maLbType.SelectEntryPos(0);
 	maLbColorFormat.SelectEntryPos(2);
 	SetDataBarType();
@@ -250,6 +258,10 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
     SetHeight();
 }
 
+ScCondFrmtEntry::~ScCondFrmtEntry()
+{
+}
+
 void ScCondFrmtEntry::Init()
 {
     maLbType.SetSelectHdl( LINK( this, ScCondFrmtEntry, TypeListHdl ) );
@@ -266,15 +278,18 @@ void ScCondFrmtEntry::Init()
     Point aPointEd = maEdMiddle.GetPosPixel();
     Point aPointCol = maLbColMiddle.GetPosPixel();
     Point aPointEdDataBar = maEdDataBarMin.GetPosPixel();
+    Point aPointLbDataBar = maLbDataBarMaxType.GetPosPixel();
     const long nMovePos = 150;
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
     aPointCol.X() += nMovePos;
     aPointEdDataBar.X() += 1.5*nMovePos;
+    aPointLbDataBar.X() += 1.5*nMovePos;
     maLbEntryTypeMiddle.SetPosPixel(aPointLb);
     maEdMiddle.SetPosPixel(aPointEd);
     maLbColMiddle.SetPosPixel(aPointCol);
     maEdDataBarMin.SetPosPixel(aPointEdDataBar);
+    maLbDataBarMaxType.SetPosPixel(aPointLbDataBar);
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
     aPointCol.X() += nMovePos;
@@ -319,6 +334,14 @@ void ScCondFrmtEntry::Init()
         maLbColMiddle.SetUpdateMode( sal_True );
         maLbColMax.SetUpdateMode( sal_True );
     }
+
+    maBtOptions.SetClickHdl( LINK( this, ScCondFrmtEntry, OptionBtnHdl ) );
+
+    mpDataBarData.reset(new ScDataBarFormatData());
+    mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry());
+    mpDataBarData->mpLowerLimit.reset(new ScColorScaleEntry());
+    mpDataBarData->mpLowerLimit->SetMin(true);
+    mpDataBarData->mpUpperLimit->SetMax(true);
 }
 
 namespace {
@@ -445,7 +468,7 @@ void ScCondFrmtEntry::SetHeight()
 		aSize.Height() = 200;
 		break;
 	    case DATABAR:
-		aSize.Height() = 120;
+		aSize.Height() = 200;
 		break;
 	    default:
 		break;
@@ -637,7 +660,7 @@ ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const
 ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const
 {
     ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
-    pDataBar->SetDataBarData(new ScDataBarFormatData());
+    pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData.get()));
     return pDataBar;
 }
 
@@ -753,8 +776,12 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl)
 
 IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
 {
-    ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this);
-    pDlg->Execute();
+    ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this, *mpDataBarData);
+    if( pDlg->Execute() == RET_OK)
+    {
+	std::cout << "Ok" << std::endl;
+	mpDataBarData.reset(pDlg->GetData());
+    }
     return 0;
 }
 
diff --git a/sc/source/ui/inc/colorformat.hxx b/sc/source/ui/inc/colorformat.hxx
index e89c3ed..4fe44f9 100644
--- a/sc/source/ui/inc/colorformat.hxx
+++ b/sc/source/ui/inc/colorformat.hxx
@@ -33,11 +33,7 @@
 #include "anyrefdg.hxx"
 
 class ScDataBarFormat;
-
-class ScColorScaleSettingsDlg : public ModalDialog
-{
-
-};
+struct ScDataBarFormatData;
 
 class ScDataBarSettingsDlg : public ModalDialog
 {
@@ -72,7 +68,10 @@ private:
 
 public:
     ScDataBarSettingsDlg(Window* pParent);
+    ScDataBarSettingsDlg(Window* pParent, const ScDataBarFormatData& rData);
     ScDataBarSettingsDlg(Window* pParent, ScDataBarFormat* pFormat);
+
+    ScDataBarFormatData* GetData();
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index 87f8944..045b215 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -52,6 +52,6 @@
 #define ED_COL_SCALE 28
 #define WD_PREVIEW 26
 #define LB_COL 27
-#define BTN_OPTIONS 28
+#define BTN_OPTIONS 30
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index f44e6c8..d1f80a9 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -44,6 +44,7 @@ class ScDocument;
 class ScConditionalFormat;
 class ScFormatEntry;
 class ScConditionalFormat;
+struct ScDataBarFormatData;
 
 enum ScCondFormatEntryType
 {
@@ -97,7 +98,9 @@ private:
     ListBox maLbDataBarMaxType;
     Edit maEdDataBarMin;
     Edit maEdDataBarMax;
-    Button maBtOptions;
+    PushButton maBtOptions;
+
+    boost::scoped_ptr<ScDataBarFormatData> mpDataBarData;
 
     //
     void SwitchToType(ScCondFormatEntryType eType);
@@ -121,10 +124,12 @@ private:
     DECL_LINK( TypeListHdl, void*);
     DECL_LINK( ColFormatTypeHdl, void*);
     DECL_LINK( StyleSelectHdl, void* );
+    DECL_LINK( OptionBtnHdl, void* );
 
 public:
     ScCondFrmtEntry( Window* pParent, ScDocument* pDoc );
     ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry );
+    virtual ~ScCondFrmtEntry();
 
     virtual long Notify( NotifyEvent& rNEvt );
 
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index ecac52b..48aa50c 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -215,10 +215,11 @@ Control RID_COND_ENTRY
         DropDown = TRUE;
         DDExtraWidth = TRUE;
     };
-    Button BTN_OPTIONS
+    PushButton BTN_OPTIONS
     {
-	Pos = MAP_APPFONT( 120 , 62 );
+	Pos = MAP_APPFONT( 120, 62 );
 	Size = MAP_APPFONT( 60, 14 );
+	Text [ en-US ] = "More options ...";
     };
 };
 
commit 3d193574ef0143f07eed2df4235f390c747327a4
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jun 8 07:16:37 2012 +0200

    add data bar ui elements
    
    Change-Id: I3ba7ac39e5339dc42850a15df9b95adf474f8e3a

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 8d2d634..2f46754 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -109,6 +109,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
     maLbColMin( this, ScResId( LB_COL) ),
     maLbColMiddle( this, ScResId( LB_COL) ),
     maLbColMax( this, ScResId( LB_COL) ),
+    maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ),
+    maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ),
+    maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ),
+    maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ),
+    maBtOptions( this, ScResId( BTN_OPTIONS ) ),
     mpDoc(pDoc)
 {
     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
@@ -260,13 +265,16 @@ void ScCondFrmtEntry::Init()
     Point aPointLb = maLbEntryTypeMiddle.GetPosPixel();
     Point aPointEd = maEdMiddle.GetPosPixel();
     Point aPointCol = maLbColMiddle.GetPosPixel();
+    Point aPointEdDataBar = maEdDataBarMin.GetPosPixel();
     const long nMovePos = 150;
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
     aPointCol.X() += nMovePos;
+    aPointEdDataBar.X() += 1.5*nMovePos;
     maLbEntryTypeMiddle.SetPosPixel(aPointLb);
     maEdMiddle.SetPosPixel(aPointEd);
     maLbColMiddle.SetPosPixel(aPointCol);
+    maEdDataBarMin.SetPosPixel(aPointEdDataBar);
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
     aPointCol.X() += nMovePos;
@@ -485,6 +493,11 @@ void ScCondFrmtEntry::SetColorScaleType()
 void ScCondFrmtEntry::HideDataBarElements()
 {
     maLbColorFormat.Hide();
+    maLbDataBarMinType.Hide();
+    maLbDataBarMaxType.Hide();
+    maEdDataBarMin.Hide();
+    maEdDataBarMax.Hide();
+    maBtOptions.Hide();
 }
 
 void ScCondFrmtEntry::SetDataBarType()
@@ -493,6 +506,11 @@ void ScCondFrmtEntry::SetDataBarType()
     HideCondElements();
     HideColorScaleElements();
     maLbColorFormat.Show();
+    maLbDataBarMinType.Show();
+    maLbDataBarMaxType.Show();
+    maEdDataBarMin.Show();
+    maEdDataBarMax.Show();
+    maBtOptions.Show();
 }
 
 void ScCondFrmtEntry::Select()
@@ -733,6 +751,13 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl)
     return 0;
 }
 
+IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
+{
+    ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this);
+    pDlg->Execute();
+    return 0;
+}
+
 ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc):
     Control(pParent, rResId),
     mbHasScrollBar(false),
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index 27aa1b2..87f8944 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -52,5 +52,6 @@
 #define ED_COL_SCALE 28
 #define WD_PREVIEW 26
 #define LB_COL 27
+#define BTN_OPTIONS 28
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 44b0362..f44e6c8 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -93,7 +93,12 @@ private:
     ColorListBox maLbColMax;
 
     //data bar ui elements
-    //
+    ListBox maLbDataBarMinType;
+    ListBox maLbDataBarMaxType;
+    Edit maEdDataBarMin;
+    Edit maEdDataBarMax;
+    Button maBtOptions;
+
     //
     void SwitchToType(ScCondFormatEntryType eType);
     void SetCondType();
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index f69b445..ecac52b 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -215,6 +215,11 @@ Control RID_COND_ENTRY
         DropDown = TRUE;
         DDExtraWidth = TRUE;
     };
+    Button BTN_OPTIONS
+    {
+	Pos = MAP_APPFONT( 120 , 62 );
+	Size = MAP_APPFONT( 60, 14 );
+    };
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 76f5ca40207448dfb5a7c87ba2c27076e024a50f
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jun 8 05:10:33 2012 +0200

    use the result of the dialog and apply it to the document
    
    Change-Id: I01dd992ccd3ddd6b8fc61ce0549ec71b5ff257c0

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index fd2322b..56e653e 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -55,12 +55,15 @@ private:
     bool mbPercentile;
 public:
     ScColorScaleEntry(double nVal, const Color& rCol);
+    ScColorScaleEntry();
     ScColorScaleEntry(const ScColorScaleEntry& rEntry);
     ScColorScaleEntry(ScDocument* pDoc, const ScColorScaleEntry& rEntry);
     ~ScColorScaleEntry();
 
     const Color& GetColor() const;
+    void SetColor(const Color&);
     double GetValue() const;
+    void SetValue(double nValue);
     void SetFormula(const rtl::OUString& rFormula, ScDocument* pDoc, const ScAddress& rAddr, formula::FormulaGrammar::Grammar eGrammar = formula::FormulaGrammar::GRAM_DEFAULT);
     void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab, SCTAB nTabNo);
     void UpdateReference( UpdateRefMode eUpdateRefMode,
@@ -208,6 +211,8 @@ public:
     const_iterator begin() const;
     iterator end();
     const_iterator end() const;
+
+    size_t size() const;
 };
 
 class SC_DLLPUBLIC ScDataBarFormat : public ScColorFormat
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 70c182f..73e6ece 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -255,7 +255,6 @@ protected:
 class SC_DLLPUBLIC ScConditionalFormat
 {
     ScDocument*         pDoc;
-    ScRangeList*        pAreas;             // area for Paint
     sal_uInt32          nKey;               // Index in attributes
 
     typedef boost::ptr_vector<ScFormatEntry> CondFormatContainer;
@@ -296,7 +295,6 @@ public:
     bool            EqualEntries( const ScConditionalFormat& r ) const;
 
     void            DoRepaint( const ScRange* pModified );
-    void            InvalidateArea();
 
     sal_uInt32      GetKey() const          { return nKey; }
     void            SetKey(sal_uInt32 nNew) { nKey = nNew; }    // only if not inserted!
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index f91be66..496ab89 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -57,6 +57,7 @@ class ScDPObject;
 struct ScDPFuncData;
 struct ScDPNumGroupInfo;
 class ScTabViewShell;
+class ScConditionalFormat;
 
 namespace com { namespace sun { namespace star { namespace sheet {
     struct DataPilotFieldReference;
@@ -87,6 +88,8 @@ public:
 
 class AbstractScCondFormatDlg : public VclAbstractDialog
 {
+public:
+    virtual ScConditionalFormat* GetConditionalFormat() = 0;
 };
 
 class AbstractScDataBarSettingsDlg : public VclAbstractDialog
@@ -356,8 +359,8 @@ public:
                                                     sal_Bool                bColDefault = sal_True ) = 0;
     virtual VclAbstractDialog * CreateScSortWarningDlg ( Window* pParent, const String& rExtendText, const String& rCurrentText, int nId ) = 0;  //add for ScSortWarningDlg
 
-    virtual AbstractScCondFormatDlg* CreateScCondFormatDlg (Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat,
-                                                                const ScRangeList& rList, int nId ) = 0; //add for ScCondFormatDlg
+    virtual AbstractScCondFormatDlg* CreateScCondFormatDlg (Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+                                                                const ScRangeList& rList, const ScAddress& rPos, int nId ) = 0; //add for ScCondFormatDlg
 
     virtual AbstractScDataBarSettingsDlg* CreateScDataBarSetttingsDlg (Window* pParent ,int nId ) = 0; //add for ScDataBarSettingsDlg
 
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index e16cc22..e6a5c8d 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -31,6 +31,16 @@
 #include "cell.hxx"
 #include "fillinfo.hxx"
 
+ScColorScaleEntry::ScColorScaleEntry():
+    mnVal(0),
+    mpCell(NULL),
+    mbMin(false),
+    mbMax(false),
+    mbPercent(false),
+    mbPercentile(false)
+{
+}
+
 ScColorScaleEntry::ScColorScaleEntry(double nVal, const Color& rCol):
     mnVal(nVal),
     maColor(rCol),
@@ -113,6 +123,11 @@ double ScColorScaleEntry::GetValue() const
     return mnVal;
 }
 
+void ScColorScaleEntry::SetValue(double nValue)
+{
+    mnVal = nValue;
+}
+
 void ScColorScaleEntry::UpdateMoveTab( SCTAB nOldTab, SCTAB nNewTab, SCTAB nTabNo )
 {
     if(mpCell)
@@ -135,6 +150,11 @@ const Color& ScColorScaleEntry::GetColor() const
     return maColor;
 }
 
+void ScColorScaleEntry::SetColor(const Color& rColor)
+{
+    maColor = rColor;
+}
+
 ScColorFormat::ScColorFormat(ScDocument* pDoc):
     ScFormatEntry(pDoc)
 {
@@ -585,6 +605,11 @@ ScColorScaleFormat::const_iterator ScColorScaleFormat::end() const
     return maColorScales.end();
 }
 
+size_t ScColorScaleFormat::size() const
+{
+    return maColorScales.size();
+}
+
 ScDataBarFormat::ScDataBarFormat(ScDocument* pDoc):
     ScColorFormat(pDoc)
 {
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index a270e30..77b1540 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -1309,14 +1309,12 @@ ScFormatEntry* ScCondFormatEntry::Clone( ScDocument* pDoc ) const
 
 ScConditionalFormat::ScConditionalFormat(sal_uInt32 nNewKey, ScDocument* pDocument) :
     pDoc( pDocument ),
-    pAreas( NULL ),
     nKey( nNewKey )
 {
 }
 
 ScConditionalFormat::ScConditionalFormat(const ScConditionalFormat& r) :
     pDoc( r.pDoc ),
-    pAreas( NULL ),
     nKey( r.nKey ),
     maRanges( r.maRanges )
 {
@@ -1377,7 +1375,6 @@ void ScConditionalFormat::AddEntry( ScFormatEntry* pNew )
 
 ScConditionalFormat::~ScConditionalFormat()
 {
-    delete pAreas;
 }
 
 const ScFormatEntry* ScConditionalFormat::GetEntry( sal_uInt16 nPos ) const
@@ -1572,12 +1569,6 @@ void ScConditionalFormat::DoRepaint( const ScRange* pModified )
     */
 }
 
-void ScConditionalFormat::InvalidateArea()
-{
-    delete pAreas;
-    pAreas = NULL;
-}
-
 void ScConditionalFormat::CompileAll()
 {
     for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
@@ -1598,9 +1589,6 @@ void ScConditionalFormat::UpdateReference( UpdateRefMode eUpdateRefMode,
     maRanges.UpdateReference( eUpdateRefMode, pDoc, rRange, nDx, nDy, nDz );
     for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
         itr->UpdateReference(eUpdateRefMode, rRange, nDx, nDy, nDz);
-
-    delete pAreas;      // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf
-    pAreas = NULL;
 }
 
 void ScConditionalFormat::RenameCellStyle(const String& rOld, const String& rNew)
@@ -1649,9 +1637,6 @@ void ScConditionalFormat::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos )
 
     for(CondFormatContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
         itr->UpdateMoveTab( nOldPos, nNewPos );
-
-    delete pAreas;      // aus dem AttrArray kommt beim Einfuegen/Loeschen kein Aufruf
-    pAreas = NULL;
 }
 
 void ScConditionalFormat::SourceChanged( const ScAddress& rAddr )
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 8ec16e0..52b9f8b 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -738,9 +738,6 @@ void ScDocument::ConditionalChanged( sal_uLong nKey, SCTAB nTab )
     ScConditionalFormatList* pCondFormList = GetCondFormList(nTab);
     if ( nKey && pCondFormList && !bIsClip && !bIsUndo )        // nKey==0 -> noop
     {
-        ScConditionalFormat* pForm = pCondFormList->GetFormat( nKey );
-        if (pForm)
-            pForm->InvalidateArea();
     }
 }
 
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 649e4d3..ee142d3 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -455,6 +455,12 @@ sal_uLong   AbstractScLinkedAreaDlg_Impl::GetRefresh()
 }
 
 
+ScConditionalFormat* AbstractScCondFormatDlg_Impl::GetConditionalFormat()
+{
+    return pDlg->GetConditionalFormat();
+}
+
+
 
 
 long AbstractScMetricInputDlg_Impl::GetInputValue( FieldUnit eUnit ) const
@@ -770,14 +776,14 @@ VclAbstractDialog * ScAbstractDialogFactory_Impl::CreateScSortWarningDlg( Window
 }
 
 
-AbstractScCondFormatDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat,
-                                                                            const ScRangeList& rRange, int nId)
+AbstractScCondFormatDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+                                                                            const ScRangeList& rRange, const ScAddress& rPos, int nId)
 {
     ScCondFormatDlg* pDlg = NULL;
     switch( nId )
     {
         case RID_SCDLG_CONDFORMAT:
-            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange );
+            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos );
             break;
         default:
             break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 04aa605..8667db4 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -142,6 +142,8 @@ class AbstractScColRowLabelDlg_Impl : public AbstractScColRowLabelDlg  //add for
 class AbstractScCondFormatDlg_Impl : public AbstractScCondFormatDlg
 {
     DECL_ABSTDLG_BASE(AbstractScCondFormatDlg_Impl, ScCondFormatDlg)
+
+    virtual ScConditionalFormat* GetConditionalFormat();
 };
 
 class AbstractScDataBarSettingsDlg_Impl : public AbstractScDataBarSettingsDlg
@@ -427,8 +429,8 @@ public:
 
     virtual VclAbstractDialog * CreateScSortWarningDlg( Window* pParent, const String& rExtendText, const String& rCurrentText, int nId );
 
-    virtual AbstractScCondFormatDlg* CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat,
-                                                                const ScRangeList& rRange, int nId ); //add for ScDataBarSettingsDlg
+    virtual AbstractScCondFormatDlg* CreateScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+                                                                const ScRangeList& rRange, const ScAddress& rPos, int nId ); //add for ScDataBarSettingsDlg
 
     virtual AbstractScDataBarSettingsDlg* CreateScDataBarSetttingsDlg (Window* pParent ,int nId ); //add for ScDataBarSettingsDlg
 
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index eb3d34c..8d2d634 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -34,6 +34,8 @@
 #include <sfx2/dispatch.hxx>
 #include <svl/stritem.hxx>
 #include <svl/intitem.hxx>
+#include <svx/xtable.hxx>
+#include <svx/drawitem.hxx>
 
 #include "anyrefdg.hxx"
 #include "document.hxx"
@@ -41,11 +43,47 @@
 #include "stlpool.hxx"
 #include "tabvwsh.hxx"
 #include "conditio.hxx"
+#include "colorscale.hxx"
+
+#include <rtl/math.hxx>
 
 #include "globstr.hrc"
 
 #include <iostream>
 
+namespace {
+
+void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol )
+{
+    if(rEntry.GetMin())
+	rLbType.SelectEntryPos(0);
+    else if(rEntry.GetMax())
+	rLbType.SelectEntryPos(1);
+    else if(rEntry.GetPercentile())
+    {
+	rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+	rLbType.SelectEntryPos(2);
+    }
+    else if(rEntry.GetPercent())
+    {
+	rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+	rLbType.SelectEntryPos(4);
+    }
+    else if(rEntry.HasFormula())
+    {
+	rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
+	rLbType.SelectEntryPos(5);
+    }
+    else
+    {
+	rEdit.SetText(rtl::OUString::valueOf(rEntry.GetValue()));
+	rLbType.SelectEntryPos(3);
+    }
+    rLbCol.SelectEntry(rEntry.GetColor());
+}
+
+}
+
 ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
     Control(pParent, ScResId( RID_COND_ENTRY ) ),
     mbActive(false),
@@ -68,6 +106,9 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
     maEdMin( this, ScResId( ED_COL_SCALE ) ),
     maEdMiddle( this, ScResId( ED_COL_SCALE ) ),
     maEdMax( this, ScResId( ED_COL_SCALE ) ),
+    maLbColMin( this, ScResId( LB_COL) ),
+    maLbColMiddle( this, ScResId( LB_COL) ),
+    maLbColMax( this, ScResId( LB_COL) ),
     mpDoc(pDoc)
 {
     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
@@ -78,7 +119,6 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
     maEdVal2.Hide();
 
     maLbStyle.SetSeparatorPos(0);
-    maLbStyle.SelectEntryPos(1);
 
     //disable entries for color formats
     maLbColorFormat.SelectEntryPos(0);
@@ -87,6 +127,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
     maLbEntryTypeMax.SelectEntryPos(1);
 
     Init();
+    maLbStyle.SelectEntryPos(1);
     maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
     SwitchToType(COLLAPSED);
     SetHeight();
@@ -115,10 +156,14 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
     maEdMin( this, ScResId( ED_COL_SCALE ) ),
     maEdMiddle( this, ScResId( ED_COL_SCALE ) ),
     maEdMax( this, ScResId( ED_COL_SCALE ) ),
+    maLbColMin( this, ScResId( LB_COL) ),
+    maLbColMiddle( this, ScResId( LB_COL) ),
+    maLbColMax( this, ScResId( LB_COL) ),
     mpDoc(pDoc)
 {
     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
     FreeResource();
+    Init();
 
     if(pFormatEntry && pFormatEntry->GetType() == condformat::CONDITION)
     {
@@ -165,13 +210,39 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
 	    case SC_COND_NONE:
 		break;
 	}
+	SwitchToType(CONDITION);
+	SetCondType();
+    }
+    else if( pFormatEntry && pFormatEntry->GetType() == condformat::COLORSCALE )
+    {
+	const ScColorScaleFormat* pEntry = static_cast<const ScColorScaleFormat*>(pFormatEntry);
+	maLbType.SelectEntryPos(0);
+	if(pEntry->size() == 2)
+	    maLbColorFormat.SelectEntryPos(0);
+	else
+	    maLbColorFormat.SelectEntryPos(1);
+	SetColorScaleType();
+	ScColorScaleFormat::const_iterator itr = pEntry->begin();
+	SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin);
+	if(pEntry->size() == 3)
+	{
+	    ++itr;
+	    SetColorScaleEntryTypes(*itr, maLbEntryTypeMiddle, maEdMiddle, maLbColMiddle);
+	}
+	++itr;
+	SetColorScaleEntryTypes(*itr, maLbEntryTypeMax, maEdMax, maLbColMax);
+    }
+    else if( pFormatEntry && pFormatEntry->GetType() == condformat::DATABAR )
+    {
+	const ScDataBarFormat* pEntry = static_cast<const ScDataBarFormat*>(pFormatEntry);
+	maLbType.SelectEntryPos(0);
+	maLbColorFormat.SelectEntryPos(2);
+	SetDataBarType();
     }
 
-    Init();
     maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
     SwitchToType(COLLAPSED);
     SetHeight();
-    SetCondType();
 }
 
 void ScCondFrmtEntry::Init()
@@ -188,15 +259,58 @@ void ScCondFrmtEntry::Init()
 
     Point aPointLb = maLbEntryTypeMiddle.GetPosPixel();
     Point aPointEd = maEdMiddle.GetPosPixel();
+    Point aPointCol = maLbColMiddle.GetPosPixel();
     const long nMovePos = 150;
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
+    aPointCol.X() += nMovePos;
     maLbEntryTypeMiddle.SetPosPixel(aPointLb);
     maEdMiddle.SetPosPixel(aPointEd);
+    maLbColMiddle.SetPosPixel(aPointCol);
     aPointLb.X() += nMovePos;
     aPointEd.X() += nMovePos;
+    aPointCol.X() += nMovePos;
     maLbEntryTypeMax.SetPosPixel(aPointLb);
     maEdMax.SetPosPixel(aPointEd);
+    maLbColMax.SetPosPixel(aPointCol);
+
+    SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
+    const SfxPoolItem*  pItem       = NULL;
+    XColorListRef       pColorTable;
+
+    DBG_ASSERT( pDocSh, "DocShell not found!" );
+
+    if ( pDocSh )
+    {
+        pItem = pDocSh->GetItem( SID_COLOR_TABLE );
+        if ( pItem != NULL )
+            pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
+    }
+    if ( pColorTable.is() )
+    {
+        // filling the line color box
+        maLbColMin.SetUpdateMode( false );
+	maLbColMiddle.SetUpdateMode( false );
+        maLbColMax.SetUpdateMode( false );
+
+        for ( long i = 0; i < pColorTable->Count(); ++i )
+        {
+            XColorEntry* pEntry = pColorTable->GetColor(i);
+            maLbColMin.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+            maLbColMiddle.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+            maLbColMax.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+
+            if(pEntry->GetColor() == Color(COL_LIGHTRED))
+                maLbColMin.SelectEntryPos(i);
+            if(pEntry->GetColor() == Color(COL_GREEN))
+                maLbColMiddle.SelectEntryPos(i);
+            if(pEntry->GetColor() == Color(COL_LIGHTBLUE))
+                maLbColMax.SelectEntryPos(i);
+        }
+        maLbColMin.SetUpdateMode( sal_True );
+        maLbColMiddle.SetUpdateMode( sal_True );
+        maLbColMax.SetUpdateMode( sal_True );
+    }
 }
 
 namespace {
@@ -304,6 +418,9 @@ void ScCondFrmtEntry::HideColorScaleElements()
     maEdMin.Hide();
     maEdMiddle.Hide();
     maEdMax.Hide();
+    maLbColMin.Hide();
+    maLbColMiddle.Hide();
+    maLbColMax.Hide();
 }
 
 void ScCondFrmtEntry::SetHeight()
@@ -314,15 +431,12 @@ void ScCondFrmtEntry::SetHeight()
 	switch (meType)
 	{
 	    case CONDITION:
-		std::cout << "CONDITION: set height 120" << std::endl;
 		aSize.Height() = 120;
 		break;
 	    case COLORSCALE:
-		std::cout << "set height 200" << std::endl;
 		aSize.Height() = 200;
 		break;
 	    case DATABAR:
-		std::cout << "DATABAR: set height 120" << std::endl;
 		aSize.Height() = 120;
 		break;
 	    default:
@@ -332,7 +446,6 @@ void ScCondFrmtEntry::SetHeight()
     }
     else
     {
-	std::cout << "set height 40" << std::endl;
 	Size aSize = GetSizePixel();
 	aSize.Height() = 40;
 	SetSizePixel(aSize);
@@ -350,6 +463,7 @@ void ScCondFrmtEntry::SetColorScaleType()
 	maLbEntryTypeMiddle.Hide();
 	maLbColScale2.Show();
 	maLbColScale3.Hide();
+	maLbColMiddle.Hide();
     }
     else
     {
@@ -357,11 +471,14 @@ void ScCondFrmtEntry::SetColorScaleType()
 	maLbEntryTypeMiddle.Show();
 	maLbColScale2.Hide();
 	maLbColScale3.Show();
+	maLbColMiddle.Show();
     }
     maLbEntryTypeMin.Show();
     maLbEntryTypeMax.Show();
     maEdMin.Show();
     maEdMax.Show();
+    maLbColMin.Show();
+    maLbColMax.Show();
     SwitchToType(COLORSCALE);
 }
 
@@ -399,6 +516,132 @@ bool ScCondFrmtEntry::IsSelected() const
     return mbActive;
 }
 
+ScFormatEntry* ScCondFrmtEntry::createConditionEntry() const
+{
+    ScConditionMode eMode;
+    rtl::OUString aExpr2;
+    switch(maLbCondType.GetSelectEntryPos())
+    {
+	case 0:
+	    eMode = SC_COND_EQUAL;
+	    break;
+	case 1:
+	    eMode = SC_COND_LESS;
+	    break;
+	case 2:
+	    eMode = SC_COND_GREATER;
+	    break;
+	case 3:
+	    eMode = SC_COND_EQLESS;
+	    break;
+	case 4:
+	    eMode = SC_COND_EQGREATER;
+	    break;
+	case 5:
+	    eMode = SC_COND_NOTEQUAL;
+	    break;
+	case 6:
+	    aExpr2 = maEdVal1.GetText();
+	    eMode = SC_COND_BETWEEN;
+	    if(aExpr2.isEmpty())
+		return NULL;
+	    break;
+	case 7:
+	    eMode = SC_COND_NOTBETWEEN;
+	    aExpr2 = maEdVal1.GetText();
+	    if(aExpr2.isEmpty())
+		return NULL;
+	    break;
+	case 8:
+	    eMode = SC_COND_DUPLICATE;
+	    break;
+	case 9:
+	    eMode = SC_COND_NOTDUPLICATE;
+	    break;
+	default:
+	    break;
+    }
+
+    rtl::OUString aExpr1 = maEdVal1.GetText();
+
+    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
+
+    return pEntry;
+}
+
+namespace {
+
+ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
+{
+    ScColorScaleEntry* pEntry = new ScColorScaleEntry();
+    double nVal = rtl::math::stringToDouble(rValue.GetText(), '.', ',');
+    switch(rType.GetSelectEntryPos())
+    {
+	case 0:
+	    pEntry->SetMin(true);
+	    break;
+	case 1:
+	    pEntry->SetMax(true);
+	    break;
+	case 2:
+	    pEntry->SetPercentile(true);
+	    pEntry->SetValue(nVal);
+	    break;
+	case 3:
+	    pEntry->SetValue(nVal);
+	    break;
+	case 4:
+	    pEntry->SetPercent(true);
+	    pEntry->SetValue(nVal);
+	    break;
+	case 5:
+	    pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
+	    break;
+    }
+
+    Color aColor = rColor.GetSelectEntryColor();
+    pEntry->SetColor(aColor);
+    return pEntry;
+}
+
+}
+
+ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const
+{
+    ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
+    pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
+    if(maLbColorFormat.GetSelectEntryPos() == 1)
+	pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMiddle, maLbColMiddle, maEdMiddle, mpDoc, maPos));
+    pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMax, maLbColMax, maEdMax, mpDoc, maPos));
+    return pColorScale;
+}
+
+ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const
+{
+    ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
+    pDataBar->SetDataBarData(new ScDataBarFormatData());
+    return pDataBar;
+}
+
+ScFormatEntry* ScCondFrmtEntry::GetEntry() const
+{
+    switch(meType)
+    {
+	case CONDITION:
+	    return createConditionEntry();
+	    break;
+	case COLORSCALE:
+	    return createColorscaleEntry();
+	    break;
+	case DATABAR:
+	    return createDatabarEntry();
+	    break;
+	default:
+	    break;
+    }
+    return NULL;
+}
+
 IMPL_LINK_NOARG(ScCondFrmtEntry, TypeListHdl)
 {
     sal_Int32 nPos = maLbType.GetSelectEntryPos();
@@ -504,12 +747,14 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
     FreeResource();
 }
 
-ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, ScConditionalFormat* pFormat):
+ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRanges, const ScAddress& rPos):
     Control(pParent, rResId),
     mbHasScrollBar(false),
     mpScrollBar(new ScrollBar(this, WB_VERT )),
     mnTopIndex(0),
-    mpDoc(pDoc)
+    mpDoc(pDoc),
+    maPos(rPos),
+    maRanges(rRanges)
 {
     mpScrollBar->SetScrollHdl( LINK( this, ScCondFormatList, ScrollHdl ) );
     mpScrollBar->EnableDrag();
@@ -527,6 +772,24 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
     FreeResource();
 }
 
+ScConditionalFormat* ScCondFormatList::GetConditionalFormat() const
+{
+    if(maEntries.empty())
+	return NULL;
+
+    ScConditionalFormat* pFormat = new ScConditionalFormat(0, mpDoc);
+    for(EntryContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+    {
+	ScFormatEntry* pEntry = itr->GetEntry();
+	if(pEntry)
+	    pFormat->AddEntry(pEntry);
+    }
+
+    pFormat->AddRange(maRanges);
+
+    return pFormat;
+}
+
 void ScCondFormatList::RecalcAll()
 {
     sal_Int32 nTotalHeight = 0;
@@ -542,15 +805,12 @@ void ScCondFormatList::RecalcAll()
 	mbHasScrollBar = true;
 	mpScrollBar->SetPosSizePixel(Point(aCtrlSize.Width() -nSrcBarSize, 0),
 					Size(nSrcBarSize, aCtrlSize.Height()) );
-	std::cout << "Need ScrollBar" << std::endl;
 	mpScrollBar->SetRangeMax(nTotalHeight);
 	mpScrollBar->SetVisibleSize(aCtrlSize.Height());
 	mpScrollBar->Show();
     }
     else
     {
-	std::cout << "Don't need ScrollBar" << std::endl;
-
 	mbHasScrollBar = false;
 	mpScrollBar->Hide();
     }
@@ -579,15 +839,16 @@ void ScCondFormatList::DoScroll(long nDelta)
     mpScrollBar->SetPosPixel(aNewPoint);
 }
 
-ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat, const ScRangeList& rRange):
+ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos):
     ModalDialog(pParent, ScResId( RID_SCDLG_CONDFORMAT )),
     maBtnAdd( this, ScResId( BTN_ADD ) ),
     maBtnRemove( this, ScResId( BTN_REMOVE ) ),
     maBtnOk( this, ScResId( BTN_OK ) ),
     maBtnCancel( this, ScResId( BTN_CANCEL ) ),
-    maCondFormList( this, ScResId( CTRL_LIST ), pDoc ),
+    maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, maPos ),
     mpDoc(pDoc),
-    mpFormat(pFormat)
+    mpFormat(pFormat),
+    maPos(rPos)
 {
 
     rtl::OUStringBuffer aTitle( GetText() );
@@ -601,6 +862,11 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditiona
     FreeResource();
 }
 
+ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
+{
+    return maCondFormList.GetConditionalFormat();
+}
+
 IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
 {
     maEntries.push_back( new ScCondFrmtEntry(this, mpDoc) );
diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc
index d4f16b7..27aa1b2 100644
--- a/sc/source/ui/inc/condformatdlg.hrc
+++ b/sc/source/ui/inc/condformatdlg.hrc
@@ -51,5 +51,6 @@
 #define LB_TYPE_COL_SCALE 25
 #define ED_COL_SCALE 28
 #define WD_PREVIEW 26
+#define LB_COL 27
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index f7693fc..44b0362 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -33,6 +33,7 @@
 #include <vcl/fixed.hxx>
 #include <vcl/edit.hxx>
 #include <svx/fntctrl.hxx>
+#include <svtools/ctrlbox.hxx>
 
 #include "rangelst.hxx"
 
@@ -87,6 +88,10 @@ private:
     Edit maEdMiddle;
     Edit maEdMax;
 
+    ColorListBox maLbColMin;
+    ColorListBox maLbColMiddle;
+    ColorListBox maLbColMax;
+
     //data bar ui elements
     //
     //
@@ -101,7 +106,12 @@ private:
     void SetHeight();
     void Init();
 
+    ScFormatEntry* createConditionEntry() const;
+    ScFormatEntry* createColorscaleEntry() const;
+    ScFormatEntry* createDatabarEntry() const;
+
     ScDocument* mpDoc;
+    ScAddress maPos;
 
     DECL_LINK( TypeListHdl, void*);
     DECL_LINK( ColFormatTypeHdl, void*);
@@ -117,6 +127,8 @@ public:
     void Deselect();
 
     bool IsSelected() const;
+
+    ScFormatEntry* GetEntry() const;
 };
 
 class ScCondFormatList : public Control
@@ -130,12 +142,16 @@ private:
     long mnTopIndex;
 
     ScDocument* mpDoc;
+    ScAddress maPos;
+    ScRangeList maRanges;
 
     void RecalcAll();
     void DoScroll(long nDiff);
 public:
     ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc );
-    ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc, ScConditionalFormat* pFormat);
+    ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRanges, const ScAddress& rPos);
+
+    ScConditionalFormat* GetConditionalFormat() const;
 
     DECL_LINK( AddBtnHdl, void* );
     DECL_LINK( RemoveBtnHdl, void* );
@@ -155,11 +171,13 @@ private:
     ScCondFormatList maCondFormList;
 
     ScDocument* mpDoc;
-    ScConditionalFormat* mpFormat;
+    const ScConditionalFormat* mpFormat;
+    ScAddress maPos;
 
 public:
-    ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, ScConditionalFormat* pFormat, const ScRangeList& rRange);
+    ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos);
 
+    ScConditionalFormat* GetConditionalFormat() const;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src
index ab2a0c5..f69b445 100644
--- a/sc/source/ui/src/condformatdlg.src
+++ b/sc/source/ui/src/condformatdlg.src
@@ -207,6 +207,14 @@ Control RID_COND_ENTRY
 	Text [ en-US ] = "Example";
 	Border = TRUE;
     };
+    ListBox LB_COL
+    {
+	Pos = MAP_APPFONT( 5, 62 );
+	Size = MAP_APPFONT( 40, 40 );
+        Border = TRUE;
+        DropDown = TRUE;
+        DDExtraWidth = TRUE;
+    };
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index f6f15a3..d9c78cd 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -98,6 +98,7 @@
 #include "docsh.hxx"
 #include "cliputil.hxx"
 #include "markdata.hxx"
+#include "docpool.hxx"
 
 #include "globstr.hrc"
 #include "scui_def.hxx"
@@ -2055,12 +2056,31 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
 
                 ScRangeList aRangeList;
-                GetViewData()->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
+                ScViewData* pViewData = GetViewData();
+                pViewData->GetMarkData().FillRangeListWithMarks(&aRangeList, false);
                 ScDocument* pDoc = GetViewData()->GetDocument();
 
-                AbstractScCondFormatDlg* pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, RID_SCDLG_CONDFORMAT );
+                ScAddress aPos(pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo());
+                AbstractScCondFormatDlg* pDlg = NULL;
+                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 );
+                }
+                else
+                {
+                    pDlg = pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aPos, RID_SCDLG_CONDFORMAT );
+                }
                 OSL_ENSURE(pDlg, "Dialog create fail!");
-                pDlg->Execute();
+                if(pDlg->Execute() == RET_OK)
+                {
+                    ScConditionalFormat* pFormat = pDlg->GetConditionalFormat();
+                    sal_uLong nIndex = pDoc->AddCondFormat(pFormat, pViewData->GetTabNo());
+
+                    ScPatternAttr aPattern( pDoc->GetPool() );
+                    aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
+                    pDoc->ApplySelectionPattern( aPattern , pViewData->GetMarkData() );
+                }
                 delete pDlg;
             }
             break;
commit c41ee0d526c6d105d53cace1c81e43a9cc519c2d
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Jun 6 05:41:42 2012 +0200

    fix cond format import from ods
    
    Change-Id: I974c46fad862edd320b54d4c7e72807dd715dfb1

diff --git a/sc/source/filter/xml/XMLConverter.cxx b/sc/source/filter/xml/XMLConverter.cxx
index aa67e55..b475c17 100644
--- a/sc/source/filter/xml/XMLConverter.cxx
+++ b/sc/source/filter/xml/XMLConverter.cxx
@@ -546,19 +546,6 @@ void lclSkipExpression( const sal_Unicode*& rpcString, const sal_Unicode* pcEnd,
     @param cEndChar
         The termination character following the expression.
   */
-OUString lclGetExpression( const sal_Unicode*& rpcString, const sal_Unicode* pcEnd, sal_Unicode cEndChar )
-{
-    OUString aExp;
-    const sal_Unicode* pcExpStart = rpcString;
-    lclSkipExpression( rpcString, pcEnd, cEndChar );
-    if( rpcString < pcEnd )
-    {
-        aExp = OUString( pcExpStart, static_cast< sal_Int32 >( rpcString - pcExpStart ) ).trim();
-        ++rpcString;
-    }
-    return aExp;
-}
-
 /** Tries to skip an empty pair of parentheses (which may contain whitespace
     characters).
 
@@ -634,7 +621,7 @@ void ScXMLConditionHelper::parseCondition(
                 // format is <condition>(<expression>)
                 if( (pcString < pcEnd) && (*pcString == '(') )
                 {
-                    rParseResult.maOperand1 = lclGetExpression( ++pcString, pcEnd, ')' );
+                    rParseResult.maOperand1 = getExpression( ++pcString, pcEnd, ')' );
                     if( !rParseResult.maOperand1.isEmpty() )
                         rParseResult.meToken = pCondInfo->meToken;
                 }
@@ -644,10 +631,10 @@ void ScXMLConditionHelper::parseCondition(
                 // format is <condition>(<expression1>,<expression2>)
                 if( (pcString < pcEnd) && (*pcString == '(') )
                 {
-                    rParseResult.maOperand1 = lclGetExpression( ++pcString, pcEnd, ',' );
+                    rParseResult.maOperand1 = getExpression( ++pcString, pcEnd, ',' );
                     if( !rParseResult.maOperand1.isEmpty() )
                     {
-                        rParseResult.maOperand2 = lclGetExpression( pcString, pcEnd, ')' );
+                        rParseResult.maOperand2 = getExpression( pcString, pcEnd, ')' );
                         if( !rParseResult.maOperand2.isEmpty() )
                             rParseResult.meToken = pCondInfo->meToken;
                     }
@@ -658,6 +645,19 @@ void ScXMLConditionHelper::parseCondition(
     }
 }
 
+OUString ScXMLConditionHelper::getExpression( const sal_Unicode*& rpcString, const sal_Unicode* pcEnd, sal_Unicode cEndChar )
+{
+    OUString aExp;
+    const sal_Unicode* pcExpStart = rpcString;
+    lclSkipExpression( rpcString, pcEnd, cEndChar );
+    if( rpcString < pcEnd )
+    {
+        aExp = OUString( pcExpStart, static_cast< sal_Int32 >( rpcString - pcExpStart ) ).trim();
+        ++rpcString;
+    }
+    return aExp;
+}
+
 // ============================================================================
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/xml/XMLConverter.hxx b/sc/source/filter/xml/XMLConverter.hxx
index 995e3e8..2a07969 100644
--- a/sc/source/filter/xml/XMLConverter.hxx
+++ b/sc/source/filter/xml/XMLConverter.hxx
@@ -164,6 +164,8 @@ public:
                             const ::rtl::OUString& rAttribute,
                             sal_Int32 nStartIndex );
 
+    static rtl::OUString getExpression(const sal_Unicode*& rpcString, const sal_Unicode* pcEnd, sal_Unicode cEndChar );
+
 private:
                         ScXMLConditionHelper();
                         ~ScXMLConditionHelper();
diff --git a/sc/source/filter/xml/xmlcondformat.cxx b/sc/source/filter/xml/xmlcondformat.cxx
index 673ee00..6aa55cc 100644
--- a/sc/source/filter/xml/xmlcondformat.cxx
+++ b/sc/source/filter/xml/xmlcondformat.cxx
@@ -41,12 +41,14 @@
 #include "scitems.hxx"
 #include "patattr.hxx"
 #include "svl/intitem.hxx"
+#include "XMLConverter.hxx"
 
 
 ScXMLConditionalFormatsContext::ScXMLConditionalFormatsContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
                         const ::rtl::OUString& rLName):
     SvXMLImportContext( rImport, nPrfx, rLName )
 {
+    GetScImport().SetNewCondFormatData();
     GetScImport().GetDocument()->SetCondFormList(new ScConditionalFormatList(), GetScImport().GetTables().GetCurrentSheet());
 }
 
@@ -115,6 +117,9 @@ SvXMLImportContext* ScXMLConditionalFormatContext::CreateChildContext( sal_uInt1
     SvXMLImportContext* pContext = NULL;
     switch (nToken)
     {
+        case XML_TOK_CONDFORMAT_CONDITION:
+            pContext = new ScXMLCondContext( GetScImport(), nPrefix, rLocalName, xAttrList, mpFormat );
+            break;
         case XML_TOK_CONDFORMAT_COLORSCALE:
             pContext = new ScXMLColorScaleFormatContext( GetScImport(), nPrefix, rLocalName, mpFormat );
             break;
@@ -284,6 +289,132 @@ void ScXMLDataBarFormatContext::EndElement()
 
 namespace {
 
+void GetConditionData(const rtl::OUString& rValue, ScConditionMode& eMode, rtl::OUString& rExpr1, rtl::OUString& rExpr2)
+{
+    if(rValue.indexOf("unique") == 0)
+    {
+        eMode = SC_COND_NOTDUPLICATE;
+    }
+    else if(rValue.indexOf("duplicate") == 0)
+    {
+        eMode = SC_COND_DUPLICATE;
+    }
+    else if(rValue.indexOf("between") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 7;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ',');
+        rExpr2 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
+        eMode = SC_COND_BETWEEN;
+    }
+    else if(rValue.indexOf("not-between") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 12;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ',');
+        rExpr2 = ScXMLConditionHelper::getExpression( pStart, pEnd, ')');
+        eMode = SC_COND_NOTBETWEEN;
+    }
+    else if(rValue.indexOf("<=") == 0)
+    {
+        rExpr1 = rValue.copy(2);
+        eMode = SC_COND_EQLESS;
+    }
+    else if(rValue.indexOf(">=") == 0)
+    {
+        rExpr1 = rValue.copy(2);
+        eMode = SC_COND_EQGREATER;
+    }
+    else if(rValue.indexOf("!=") == 0)
+    {
+        rExpr1 = rValue.copy(2);
+        eMode = SC_COND_NOTEQUAL;
+    }
+    else if(rValue.indexOf("<") == 0)
+    {
+        rExpr1 = rValue.copy(1);
+        eMode = SC_COND_LESS;
+    }
+    else if(rValue.indexOf("=") == 0)
+    {
+        rExpr1 = rValue.copy(1);
+        eMode = SC_COND_EQUAL;
+    }
+    else if(rValue.indexOf(">") == 0)
+    {
+        rExpr1 = rValue.copy(1);
+        eMode = SC_COND_GREATER;
+    }
+    else if(rValue.indexOf("formula-is") == 0)
+    {
+        const sal_Unicode* pStr = rValue.getStr();
+        const sal_Unicode* pStart = pStr + 11;
+        const sal_Unicode* pEnd = pStr + rValue.getLength();
+        rExpr1 = ScXMLConditionHelper::getExpression( pStart, pEnd, ',');
+        eMode = SC_COND_DIRECT;
+    }
+    else
+        eMode = SC_COND_NONE;
+}
+
+}
+
+ScXMLCondContext::ScXMLCondContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+                        const ::rtl::OUString& rLName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+                        ScConditionalFormat* pFormat ):
+    SvXMLImportContext( rImport, nPrfx, rLName )
+{
+    rtl::OUString sExpression;
+    rtl::OUString sStyle;
+    rtl::OUString sAddress;
+
+    sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
+    const SvXMLTokenMap& rAttrTokenMap = GetScImport().GetConditionAttrMap();
+    for( sal_Int16 i=0; i < nAttrCount; ++i )
+    {
+        const rtl::OUString& sAttrName(xAttrList->getNameByIndex( i ));
+        rtl::OUString aLocalName;
+        sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
+                    sAttrName, &aLocalName ));
+        const rtl::OUString& sValue(xAttrList->getValueByIndex( i ));
+
+        switch( rAttrTokenMap.Get( nPrefix, aLocalName ) )
+        {
+            case XML_TOK_CONDITION_VALUE:
+                sExpression = sValue;
+                break;
+            case XML_TOK_CONDITION_APPLY_STYLE_NAME:
+                sStyle = sValue;
+            case XML_TOK_CONDITION_BASE_CELL_ADDRESS:
+                sAddress = sValue;
+            default:
+                break;
+        }
+    }
+
+    rtl::OUString aExpr1;
+    rtl::OUString aExpr2;
+    ScConditionMode eMode;
+    GetConditionData(sExpression, eMode, aExpr1, aExpr2);
+    ScAddress aPos;
+    sal_Int32 nIndex = 0;
+    ScRangeStringConverter::GetAddressFromString(aPos, sAddress, GetScImport().GetDocument(), formula::FormulaGrammar::CONV_ODF, nIndex);
+
+    ScCondFormatEntry* pFormatEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, GetScImport().GetDocument(), aPos, sStyle,
+                                                        rtl::OUString(), rtl::OUString(), formula::FormulaGrammar::GRAM_ODFF, formula::FormulaGrammar::GRAM_ODFF);
+
+    pFormat->AddEntry(pFormatEntry);
+}
+
+void ScXMLCondContext::EndElement()
+{
+
+}
+
+namespace {
+
 void setColorEntryType(const rtl::OUString& rType, ScColorScaleEntry* pEntry, const rtl::OUString rFormula,
         ScXMLImport& rImport)
 {
diff --git a/sc/source/filter/xml/xmlcondformat.hxx b/sc/source/filter/xml/xmlcondformat.hxx
index 80926cc..8d84a15 100644
--- a/sc/source/filter/xml/xmlcondformat.hxx
+++ b/sc/source/filter/xml/xmlcondformat.hxx
@@ -169,17 +169,18 @@ public:
     virtual void EndElement();
 };
 
-class ScXMLConditionContext : public SvXMLImportContext
+class ScXMLCondContext : public SvXMLImportContext
 {
     const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); }
     ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); }
 public:
-    ScXMLConditionContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
+    ScXMLCondContext( ScXMLImport& rImport, sal_uInt16 nPrfx,
                         const ::rtl::OUString& rLName,
                         const ::com::sun::star::uno::Reference<
-                                        ::com::sun::star::xml::sax::XAttributeList>& xAttrList);
+                                        ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
+                        ScConditionalFormat* pFormat);
 
-    virtual ~ScXMLConditionContext() {}
+    virtual ~ScXMLCondContext() {}
 
     virtual void EndElement();
 };
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 71caee8..bb4d6fc 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -3842,44 +3842,45 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
                     {
                         const ScCondFormatEntry* pEntry = static_cast<const ScCondFormatEntry*>(pFormatEntry);
                         rtl::OUStringBuffer aCond;
+                        ScAddress aPos = pEntry->GetSrcPos();
                         switch(pEntry->GetOperation())
                         {
                             case SC_COND_EQUAL:
                                 aCond.append('=');
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 break;
                             case SC_COND_LESS:
                                 aCond.append('<');
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 break;
                             case SC_COND_GREATER:
                                 aCond.append('>');
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 break;
                             case SC_COND_EQLESS:
                                 aCond.append("<=");
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 break;
                             case SC_COND_EQGREATER:
                                 aCond.append(">=");
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 break;
                             case SC_COND_NOTEQUAL:
                                 aCond.append("!=");
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 break;
                             case SC_COND_BETWEEN:
                                 aCond.append(rtl::OUString("between("));
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 aCond.append(',');
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 1, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 1, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 aCond.append(')');
                                 break;
                             case SC_COND_NOTBETWEEN:
                                 aCond.append(rtl::OUString("not-between("));
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 aCond.append(',');
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 1, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 1, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 aCond.append(')');
                                 break;
                             case SC_COND_DUPLICATE:
@@ -3890,7 +3891,7 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
                                 break;
                             case SC_COND_DIRECT:
                                 aCond.append("formula-is(");
-                                aCond.append(pEntry->GetExpression(pEntry->GetSrcPos(), 0, 0, formula::FormulaGrammar::GRAM_ODFF));
+                                aCond.append(pEntry->GetExpression(aPos, 0, 0, formula::FormulaGrammar::GRAM_ODFF));
                                 aCond.append(')');
                                 break;
                             case SC_COND_NONE:
@@ -3899,6 +3900,10 @@ void ScXMLExport::ExportConditionalFormat(SCTAB nTab)
                         rtl::OUString sStyle = pEntry->GetStyle();
                         AddAttribute(XML_NAMESPACE_CALC_EXT, XML_APPLY_STYLE_NAME, sStyle);
                         AddAttribute(XML_NAMESPACE_CALC_EXT, XML_VALUE, aCond.makeStringAndClear());
+
+                        rtl::OUString sBaseAddress;
+                        ScRangeStringConverter::GetStringFromAddress( sBaseAddress, aPos, pDoc,formula::FormulaGrammar::CONV_ODF );
+                        AddAttribute(XML_NAMESPACE_CALC_EXT, XML_BASE_CELL_ADDRESS, sBaseAddress);
                         SvXMLElementExport aElementCondEntry(*this, XML_NAMESPACE_CALC_EXT, XML_CONDITION, true, true);
                     }
                     else if(pFormatEntry->GetType() == condformat::COLORSCALE)
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index 219345d..5d1d99a 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -618,6 +618,7 @@ const SvXMLTokenMap& ScXMLImport::GetCondFormatTokenMap()
         {
             { XML_NAMESPACE_CALC_EXT, XML_COLOR_SCALE, XML_TOK_CONDFORMAT_COLORSCALE },
             { XML_NAMESPACE_CALC_EXT, XML_DATA_BAR, XML_TOK_CONDFORMAT_DATABAR },
+            { XML_NAMESPACE_CALC_EXT, XML_CONDITION, XML_TOK_CONDFORMAT_CONDITION },
             XML_TOKEN_MAP_END
         };
 

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list