LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/condformat - condformatdlgentry.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 860 0.1 %
Date: 2013-07-09 Functions: 2 93 2.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include "condformatdlg.hxx"
      11             : #include "condformatdlgentry.hxx"
      12             : #include "condformatdlg.hrc"
      13             : #include "conditio.hxx"
      14             : 
      15             : #include "document.hxx"
      16             : 
      17             : #include <vcl/vclevent.hxx>
      18             : #include <svl/style.hxx>
      19             : #include <sfx2/dispatch.hxx>
      20             : #include <svl/stritem.hxx>
      21             : #include <svl/intitem.hxx>
      22             : #include <svx/xtable.hxx>
      23             : #include <svx/drawitem.hxx>
      24             : #include <vcl/msgbox.hxx>
      25             : #include "tokenarray.hxx"
      26             : #include "stlpool.hxx"
      27             : #include "tabvwsh.hxx"
      28             : 
      29             : #include "colorformat.hxx"
      30             : 
      31             : #include "globstr.hrc"
      32             : 
      33             : #include <set>
      34             : 
      35           0 : ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScAddress& rPos):
      36             :     Control(pParent, ScResId( RID_COND_ENTRY ) ),
      37             :     mbActive(false),
      38             :     maFtCondNr( this, ScResId( FT_COND_NR ) ),
      39             :     maFtCondition( this, ScResId( FT_CONDITION ) ),
      40             :     mnIndex(0),
      41             :     maStrCondition(ScResId( STR_CONDITION ).toString()),
      42             :     maLbType( this, ScResId( LB_TYPE ) ),
      43             :     mpDoc(pDoc),
      44           0 :     maPos(rPos)
      45             : {
      46           0 :     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
      47             : 
      48           0 :     maLbType.SetSelectHdl( LINK( pParent, ScCondFormatList, TypeListHdl ) );
      49           0 :     maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
      50           0 : }
      51             : 
      52           0 : ScCondFrmtEntry::~ScCondFrmtEntry()
      53             : {
      54           0 : }
      55             : 
      56           0 : long ScCondFrmtEntry::Notify( NotifyEvent& rNEvt )
      57             : {
      58           0 :     if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
      59             :     {
      60           0 :         ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, maClickHdl, this );
      61             :     }
      62           0 :     return Control::Notify(rNEvt);
      63             : }
      64             : 
      65           0 : void ScCondFrmtEntry::SetIndex(sal_Int32 nIndex)
      66             : {
      67           0 :     mnIndex = nIndex;
      68           0 :     OUStringBuffer aBuffer(maStrCondition);
      69           0 :     aBuffer.append(OUString::valueOf(nIndex));
      70           0 :     maFtCondNr.SetText(aBuffer.makeStringAndClear());
      71           0 : }
      72             : 
      73           0 : void ScCondFrmtEntry::SetHeight()
      74             : {
      75           0 :     long nPad = LogicToPixel(Size(42,2), MapMode(MAP_APPFONT)).getHeight();
      76             : 
      77             :     // Calculate maximum height we need from visible widgets
      78           0 :     sal_uInt16 nChildren = GetChildCount();
      79             : 
      80           0 :     long nMaxHeight = 0;
      81           0 :     for(sal_uInt16 i = 0; i < nChildren; i++)
      82             :     {
      83           0 :         Window *pChild  = GetChild(i);
      84           0 :         if(!pChild || !pChild->IsVisible())
      85           0 :             continue;
      86           0 :         Point aPos = pChild->GetPosPixel();
      87           0 :         Size aSize = pChild->GetSizePixel();
      88           0 :         nMaxHeight = std::max(aPos.Y() + aSize.Height(), nMaxHeight);
      89             :     }
      90           0 :     Size aSize = GetSizePixel();
      91           0 :     if(nMaxHeight > 0)
      92             :     {
      93           0 :         aSize.Height() = nMaxHeight + nPad;
      94           0 :         SetSizePixel(aSize);
      95             :     }
      96           0 : }
      97             : 
      98           0 : void ScCondFrmtEntry::Select()
      99             : {
     100           0 :     maFtCondition.SetText(OUString());
     101           0 :     maFtCondition.Hide();
     102           0 :     maLbType.Show();
     103           0 :     mbActive = true;
     104           0 :     SetHeight();
     105           0 : }
     106             : 
     107           0 : void ScCondFrmtEntry::Deselect()
     108             : {
     109           0 :     OUString maCondText = GetExpressionString();
     110           0 :     maFtCondition.SetText(maCondText);
     111           0 :     maFtCondition.Show();
     112           0 :     maLbType.Hide();
     113           0 :     mbActive = false;
     114           0 :     SetHeight();
     115           0 : }
     116             : 
     117           0 : bool ScCondFrmtEntry::IsSelected() const
     118             : {
     119           0 :     return mbActive;
     120             : }
     121             : 
     122           0 : IMPL_LINK(ScCondFrmtEntry, EdModifyHdl, Edit*, pEdit)
     123             : {
     124           0 :     OUString aFormula = pEdit->GetText();
     125           0 :     ScCompiler aComp( mpDoc, maPos );
     126           0 :     aComp.SetGrammar( mpDoc->GetGrammar() );
     127           0 :     boost::scoped_ptr<ScTokenArray> mpCode(aComp.CompileString(aFormula));
     128           0 :     if(mpCode->GetCodeError())
     129             :     {
     130           0 :         pEdit->SetControlBackground(COL_LIGHTRED);
     131             :     }
     132             :     else
     133             :     {
     134           0 :         pEdit->SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
     135             :     }
     136           0 :     return 0;
     137             : }
     138             : 
     139             : //
     140             : //condition
     141             : //
     142             : namespace {
     143             : 
     144           0 : void FillStyleListBox( ScDocument* pDoc, ListBox& rLbStyle )
     145             : {
     146           0 :     rLbStyle.SetSeparatorPos(0);
     147           0 :     std::set<OUString> aStyleNames;
     148           0 :     SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
     149           0 :     for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
     150             :     {
     151           0 :         OUString aName = pStyle->GetName();
     152           0 :         aStyleNames.insert(aName);
     153           0 :     }
     154           0 :     for(std::set<OUString>::const_iterator itr = aStyleNames.begin(), itrEnd = aStyleNames.end();
     155             :                         itr != itrEnd; ++itr)
     156             :     {
     157           0 :         rLbStyle.InsertEntry( *itr );
     158           0 :     }
     159           0 : }
     160             : 
     161             : }
     162             : 
     163           0 : ScConditionFrmtEntry::ScConditionFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry ):
     164             :     ScCondFrmtEntry( pParent, pDoc, rPos ),
     165             :     maLbCondType( this, ScResId( LB_CELLIS_TYPE ) ),
     166             :     maEdVal1( this, NULL, NULL, ScResId( ED_VAL1 ) ),
     167             :     maEdVal2( this, NULL, NULL, ScResId( ED_VAL2 ) ),
     168             :     maFtStyle( this, ScResId( FT_STYLE ) ),
     169             :     maLbStyle( this, ScResId( LB_STYLE ) ),
     170             :     maWdPreview( this, ScResId( WD_PREVIEW ) ),
     171           0 :     mbIsInStyleCreate(false)
     172             : {
     173             : 
     174           0 :     FreeResource();
     175           0 :     maLbType.SelectEntryPos(1);
     176             : 
     177           0 :     Init();
     178             : 
     179           0 :     StartListening(*pDoc->GetStyleSheetPool(), true);
     180             : 
     181           0 :     if(pFormatEntry)
     182             :     {
     183           0 :         OUString aStyleName = pFormatEntry->GetStyle();
     184           0 :         maLbStyle.SelectEntry(aStyleName);
     185           0 :         StyleSelectHdl(NULL);
     186           0 :         ScConditionMode eMode = pFormatEntry->GetOperation();
     187           0 :         maEdVal1.SetText(pFormatEntry->GetExpression(maPos, 0));
     188           0 :         maEdVal2.Hide();
     189           0 :         switch(eMode)
     190             :         {
     191             :             case SC_COND_EQUAL:
     192           0 :                 maLbCondType.SelectEntryPos(0);
     193           0 :                 break;
     194             :             case SC_COND_LESS:
     195           0 :                 maLbCondType.SelectEntryPos(1);
     196           0 :                 break;
     197             :             case SC_COND_GREATER:
     198           0 :                 maLbCondType.SelectEntryPos(2);
     199           0 :                 break;
     200             :             case SC_COND_EQLESS:
     201           0 :                 maLbCondType.SelectEntryPos(3);
     202           0 :                 break;
     203             :             case SC_COND_EQGREATER:
     204           0 :                 maLbCondType.SelectEntryPos(4);
     205           0 :                 break;
     206             :             case SC_COND_NOTEQUAL:
     207           0 :                 maLbCondType.SelectEntryPos(5);
     208           0 :                 break;
     209             :             case SC_COND_BETWEEN:
     210           0 :                 maEdVal2.Show();
     211           0 :                 maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1));
     212           0 :                 maLbCondType.SelectEntryPos(6);
     213           0 :                 break;
     214             :             case SC_COND_NOTBETWEEN:
     215           0 :                 maEdVal2.Show();
     216           0 :                 maEdVal2.SetText(pFormatEntry->GetExpression(maPos, 1));
     217           0 :                 maLbCondType.SelectEntryPos(7);
     218           0 :                 break;
     219             :             case SC_COND_DUPLICATE:
     220           0 :                 maLbCondType.SelectEntryPos(8);
     221           0 :                 break;
     222             :             case SC_COND_NOTDUPLICATE:
     223           0 :                 maLbCondType.SelectEntryPos(9);
     224           0 :                 break;
     225             :             case SC_COND_DIRECT:
     226             :                 assert(false);
     227             :                 //maLbType.SelectEntryPos(2);
     228           0 :                 break;
     229             :             case SC_COND_TOP10:
     230           0 :                 maLbCondType.SelectEntryPos(10);
     231           0 :                 break;
     232             :             case SC_COND_BOTTOM10:
     233           0 :                 maLbCondType.SelectEntryPos(11);
     234           0 :                 break;
     235             :             case SC_COND_TOP_PERCENT:
     236           0 :                 maLbCondType.SelectEntryPos(12);
     237           0 :                 break;
     238             :             case SC_COND_BOTTOM_PERCENT:
     239           0 :                 maLbCondType.SelectEntryPos(13);
     240           0 :                 break;
     241             :             case SC_COND_ABOVE_AVERAGE:
     242           0 :                 maEdVal1.Hide();
     243           0 :                 maLbCondType.SelectEntryPos(14);
     244           0 :                 break;
     245             :             case SC_COND_BELOW_AVERAGE:
     246           0 :                 maEdVal1.Hide();
     247           0 :                 maLbCondType.SelectEntryPos(15);
     248           0 :                 break;
     249             :             case SC_COND_ABOVE_EQUAL_AVERAGE:
     250           0 :                 maEdVal1.Hide();
     251           0 :                 maLbCondType.SelectEntryPos(16);
     252           0 :                 break;
     253             :             case SC_COND_BELOW_EQUAL_AVERAGE:
     254           0 :                 maEdVal1.Hide();
     255           0 :                 maLbCondType.SelectEntryPos(17);
     256           0 :                 break;
     257             :             case SC_COND_ERROR:
     258           0 :                 maEdVal1.Hide();
     259           0 :                 maLbCondType.SelectEntryPos(18);
     260           0 :                 break;
     261             :             case SC_COND_NOERROR:
     262           0 :                 maEdVal1.Hide();
     263           0 :                 maLbCondType.SelectEntryPos(19);
     264           0 :                 break;
     265             :             case SC_COND_BEGINS_WITH:
     266           0 :                 maLbCondType.SelectEntryPos(20);
     267           0 :                 break;
     268             :             case SC_COND_ENDS_WITH:
     269           0 :                 maLbCondType.SelectEntryPos(21);
     270           0 :                 break;
     271             :             case SC_COND_CONTAINS_TEXT:
     272           0 :                 maLbCondType.SelectEntryPos(22);
     273           0 :                 break;
     274             :             case SC_COND_NOT_CONTAINS_TEXT:
     275           0 :                 maLbCondType.SelectEntryPos(23);
     276           0 :                 break;
     277             :             case SC_COND_NONE:
     278           0 :                 break;
     279           0 :         }
     280             :     }
     281             :     else
     282             :     {
     283           0 :         maLbCondType.SelectEntryPos(0);
     284           0 :         maEdVal2.Hide();
     285           0 :         maLbStyle.SelectEntryPos(1);
     286             :     }
     287           0 :     maLbType.SelectEntryPos(1);
     288           0 : }
     289             : 
     290           0 : void ScConditionFrmtEntry::Init()
     291             : {
     292           0 :     maEdVal1.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
     293           0 :     maEdVal2.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
     294           0 :     maEdVal1.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
     295           0 :     maEdVal2.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
     296             : 
     297           0 :     maEdVal1.SetStyle( maEdVal1.GetStyle() | WB_FORCECTRLBACKGROUND );
     298           0 :     maEdVal2.SetStyle( maEdVal2.GetStyle() | WB_FORCECTRLBACKGROUND );
     299             : 
     300           0 :     maEdVal1.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
     301           0 :     maEdVal2.SetModifyHdl( LINK( this, ScCondFrmtEntry, EdModifyHdl ) );
     302             : 
     303           0 :     FillStyleListBox( mpDoc, maLbStyle );
     304           0 :     maLbStyle.SetSelectHdl( LINK( this, ScConditionFrmtEntry, StyleSelectHdl ) );
     305             : 
     306           0 :     maLbCondType.SetSelectHdl( LINK( this, ScConditionFrmtEntry, ConditionTypeSelectHdl ) );
     307           0 : }
     308             : 
     309           0 : ScFormatEntry* ScConditionFrmtEntry::createConditionEntry() const
     310             : {
     311             :     ScConditionMode eMode;
     312           0 :     OUString aExpr2;
     313           0 :     switch(maLbCondType.GetSelectEntryPos())
     314             :     {
     315             :         case 0:
     316           0 :             eMode = SC_COND_EQUAL;
     317           0 :             break;
     318             :         case 1:
     319           0 :             eMode = SC_COND_LESS;
     320           0 :             break;
     321             :         case 2:
     322           0 :             eMode = SC_COND_GREATER;
     323           0 :             break;
     324             :         case 3:
     325           0 :             eMode = SC_COND_EQLESS;
     326           0 :             break;
     327             :         case 4:
     328           0 :             eMode = SC_COND_EQGREATER;
     329           0 :             break;
     330             :         case 5:
     331           0 :             eMode = SC_COND_NOTEQUAL;
     332           0 :             break;
     333             :         case 6:
     334           0 :             aExpr2 = maEdVal2.GetText();
     335           0 :             eMode = SC_COND_BETWEEN;
     336           0 :             if(aExpr2.isEmpty())
     337           0 :                 return NULL;
     338           0 :             break;
     339             :         case 7:
     340           0 :             eMode = SC_COND_NOTBETWEEN;
     341           0 :             aExpr2 = maEdVal2.GetText();
     342           0 :             if(aExpr2.isEmpty())
     343           0 :                 return NULL;
     344           0 :             break;
     345             :         case 8:
     346           0 :             eMode = SC_COND_DUPLICATE;
     347           0 :             break;
     348             :         case 9:
     349           0 :             eMode = SC_COND_NOTDUPLICATE;
     350           0 :             break;
     351             :         case 10:
     352           0 :             eMode = SC_COND_TOP10;
     353           0 :             break;
     354             :         case 11:
     355           0 :             eMode = SC_COND_BOTTOM10;
     356           0 :             break;
     357             :         case 12:
     358           0 :             eMode = SC_COND_TOP_PERCENT;
     359           0 :             break;
     360             :         case 13:
     361           0 :             eMode = SC_COND_BOTTOM_PERCENT;
     362           0 :             break;
     363             :         case 14:
     364           0 :             eMode = SC_COND_ABOVE_AVERAGE;
     365           0 :             break;
     366             :         case 15:
     367           0 :             eMode = SC_COND_BELOW_AVERAGE;
     368           0 :             break;
     369             :         case 16:
     370           0 :             eMode = SC_COND_ABOVE_EQUAL_AVERAGE;
     371           0 :             break;
     372             :         case 17:
     373           0 :             eMode = SC_COND_BELOW_EQUAL_AVERAGE;
     374           0 :             break;
     375             :         case 18:
     376           0 :             eMode = SC_COND_ERROR;
     377           0 :             break;
     378             :         case 19:
     379           0 :             eMode = SC_COND_NOERROR;
     380           0 :             break;
     381             :         case 20:
     382           0 :             eMode = SC_COND_BEGINS_WITH;
     383           0 :             break;
     384             :         case 21:
     385           0 :             eMode = SC_COND_ENDS_WITH;
     386           0 :             break;
     387             :         case 22:
     388           0 :             eMode = SC_COND_CONTAINS_TEXT;
     389           0 :             break;
     390             :         case 23:
     391           0 :             eMode = SC_COND_NOT_CONTAINS_TEXT;
     392           0 :             break;
     393             :         default:
     394             :             assert(false); // this cannot happen
     395           0 :             return NULL;
     396             :     }
     397             : 
     398           0 :     OUString aExpr1 = maEdVal1.GetText();
     399             : 
     400           0 :     ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
     401             : 
     402           0 :     return pEntry;
     403             : }
     404             : 
     405           0 : OUString ScConditionFrmtEntry::GetExpressionString()
     406             : {
     407           0 :     return ScCondFormatHelper::GetExpression(CONDITION, maLbCondType.GetSelectEntryPos(), maEdVal1.GetText(), maEdVal2.GetText());
     408             : }
     409             : 
     410           0 : ScFormatEntry* ScConditionFrmtEntry::GetEntry() const
     411             : {
     412           0 :     return createConditionEntry();
     413             : }
     414             : 
     415           0 : void ScConditionFrmtEntry::SetActive()
     416             : {
     417           0 :     maLbCondType.Show();
     418           0 :     maEdVal1.Show();
     419           0 :     if(maLbCondType.GetSelectEntryPos() == 6 || maLbCondType.GetSelectEntryPos() == 7)
     420           0 :         maEdVal2.Show();
     421           0 :     maFtStyle.Show();
     422           0 :     maLbStyle.Show();
     423           0 :     maWdPreview.Show();
     424             : 
     425           0 :     Select();
     426           0 : }
     427             : 
     428           0 : void ScConditionFrmtEntry::SetInactive()
     429             : {
     430           0 :     maLbCondType.Hide();
     431           0 :     maEdVal1.Hide();
     432           0 :     maEdVal2.Hide();
     433           0 :     maFtStyle.Hide();
     434           0 :     maLbStyle.Hide();
     435           0 :     maWdPreview.Hide();
     436             : 
     437           0 :     Deselect();
     438           0 : }
     439             : 
     440             : namespace {
     441             : 
     442           0 : void UpdateStyleList(ListBox& rLbStyle, ScDocument* pDoc)
     443             : {
     444           0 :     OUString aSelectedStyle = rLbStyle.GetSelectEntry();
     445           0 :     for(sal_Int32 i = rLbStyle.GetEntryCount(); i >= 1; --i)
     446             :     {
     447           0 :         rLbStyle.RemoveEntry(i);
     448             :     }
     449           0 :     FillStyleListBox(pDoc, rLbStyle);
     450           0 :     rLbStyle.SelectEntry(aSelectedStyle);
     451           0 : }
     452             : 
     453             : }
     454             : 
     455           0 : void ScConditionFrmtEntry::Notify(SfxBroadcaster&, const SfxHint& rHint)
     456             : {
     457           0 :     SfxStyleSheetHint* pHint = PTR_CAST(SfxStyleSheetHint, &rHint);
     458           0 :     if(!pHint)
     459           0 :         return;
     460             : 
     461           0 :     sal_uInt16 nHint = pHint->GetHint();
     462           0 :     if(nHint == SFX_STYLESHEET_MODIFIED)
     463             :     {
     464           0 :         if(!mbIsInStyleCreate)
     465           0 :             UpdateStyleList(maLbStyle, mpDoc);
     466             :     }
     467             : }
     468             : 
     469             : namespace {
     470             : 
     471           0 : void StyleSelect( ListBox& rLbStyle, ScDocument* pDoc, SvxFontPrevWindow& rWdPreview )
     472             : {
     473           0 :     if(rLbStyle.GetSelectEntryPos() == 0)
     474             :     {
     475             :         // call new style dialog
     476           0 :         SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, SFX_STYLE_FAMILY_PARA );
     477           0 :         SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScGlobal::GetRscString(STR_STYLENAME_STANDARD) );
     478             : 
     479             :         // unlock the dispatcher so SID_STYLE_NEW can be executed
     480             :         // (SetDispatcherLock would affect all Calc documents)
     481           0 :         ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
     482           0 :         SfxDispatcher* pDisp = pViewShell->GetDispatcher();
     483           0 :         sal_Bool bLocked = pDisp->IsLocked();
     484           0 :         if (bLocked)
     485           0 :             pDisp->Lock(false);
     486             : 
     487             :         // Execute the "new style" slot, complete with undo and all necessary updates.
     488             :         // The return value (SfxUInt16Item) is ignored, look for new styles instead.
     489             :         pDisp->Execute( SID_STYLE_NEW, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD | SFX_CALLMODE_MODAL,
     490             :                 &aFamilyItem,
     491             :                 &aRefItem,
     492           0 :                 0L );
     493             : 
     494           0 :         if (bLocked)
     495           0 :             pDisp->Lock(sal_True);
     496             : 
     497             :         // Find the new style and add it into the style list boxes
     498           0 :         SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
     499           0 :         bool bFound = false;
     500           0 :         for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; pStyle = aStyleIter.Next() )
     501             :         {
     502           0 :             OUString aName = pStyle->GetName();
     503           0 :             if ( rLbStyle.GetEntryPos(aName) == LISTBOX_ENTRY_NOTFOUND )    // all lists contain the same entries
     504             :             {
     505           0 :                 for( sal_uInt16 i = 1, n = rLbStyle.GetEntryCount(); i <= n && !bFound; ++i)
     506             :                 {
     507           0 :                     OUString aStyleName = ScGlobal::pCharClass->uppercase(OUString(rLbStyle.GetEntry(i)));
     508           0 :                     if( i == n )
     509             :                     {
     510           0 :                         rLbStyle.InsertEntry(aName);
     511           0 :                         rLbStyle.SelectEntry(aName);
     512           0 :                         bFound = true;
     513             :                     }
     514           0 :                     else if( aStyleName > ScGlobal::pCharClass->uppercase(aName) )
     515             :                     {
     516           0 :                         rLbStyle.InsertEntry(aName, i);
     517           0 :                         rLbStyle.SelectEntry(aName);
     518           0 :                         bFound = true;
     519             :                     }
     520           0 :                 }
     521             :             }
     522           0 :         }
     523             :     }
     524             : 
     525           0 :     OUString aStyleName = rLbStyle.GetSelectEntry();
     526           0 :     SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SFX_STYLE_FAMILY_PARA );
     527           0 :     if(pStyleSheet)
     528             :     {
     529           0 :         const SfxItemSet& rSet = pStyleSheet->GetItemSet();
     530           0 :         rWdPreview.Init( rSet );
     531           0 :     }
     532           0 : }
     533             : 
     534             : }
     535             : 
     536           0 : IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl)
     537             : {
     538           0 :     mbIsInStyleCreate = true;
     539           0 :     StyleSelect( maLbStyle, mpDoc, maWdPreview );
     540           0 :     mbIsInStyleCreate = false;
     541           0 :     return 0;
     542             : }
     543             : 
     544             : // formula
     545             : 
     546           0 : ScFormulaFrmtEntry::ScFormulaFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScCondFormatEntry* pFormat ):
     547             :     ScCondFrmtEntry( pParent, pDoc, rPos ),
     548             :     maFtStyle( this, ScResId( FT_STYLE ) ),
     549             :     maLbStyle( this, ScResId( LB_STYLE ) ),
     550             :     maWdPreview( this, ScResId( WD_PREVIEW ) ),
     551           0 :     maEdFormula( this, NULL, NULL, ScResId( ED_FORMULA ) )
     552             : {
     553           0 :     Init();
     554             : 
     555           0 :     FreeResource();
     556           0 :     maLbType.SelectEntryPos(2);
     557             : 
     558           0 :     if(pFormat)
     559             :     {
     560           0 :         maEdFormula.SetText(pFormat->GetExpression(rPos, 0, 0, pDoc->GetGrammar()));
     561           0 :         maLbStyle.SelectEntry(pFormat->GetStyle());
     562             :     }
     563             :     else
     564             :     {
     565           0 :         maLbStyle.SelectEntryPos(1);
     566             :     }
     567             : 
     568           0 :     StyleSelectHdl(NULL);
     569           0 : }
     570             : 
     571           0 : void ScFormulaFrmtEntry::Init()
     572             : {
     573           0 :     maEdFormula.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeGetFocusHdl ) );
     574           0 :     maEdFormula.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg, RangeLoseFocusHdl ) );
     575             : 
     576           0 :     FillStyleListBox( mpDoc, maLbStyle );
     577           0 :     maLbStyle.SetSelectHdl( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) );
     578           0 : }
     579             : 
     580           0 : IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl)
     581             : {
     582           0 :     StyleSelect( maLbStyle, mpDoc, maWdPreview );
     583             : 
     584           0 :     return 0;
     585             : }
     586             : 
     587           0 : ScFormatEntry* ScFormulaFrmtEntry::createFormulaEntry() const
     588             : {
     589           0 :     ScConditionMode eMode = SC_COND_DIRECT;
     590           0 :     OUString aFormula = maEdFormula.GetText();
     591           0 :     if(aFormula.isEmpty())
     592           0 :         return NULL;
     593             : 
     594           0 :     OUString aExpr2;
     595           0 :     ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aFormula, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
     596           0 :     return pEntry;
     597             : }
     598             : 
     599           0 : ScFormatEntry* ScFormulaFrmtEntry::GetEntry() const
     600             : {
     601           0 :     return createFormulaEntry();
     602             : }
     603             : 
     604           0 : OUString ScFormulaFrmtEntry::GetExpressionString()
     605             : {
     606           0 :     return ScCondFormatHelper::GetExpression(FORMULA, 0, maEdFormula.GetText());
     607             : }
     608             : 
     609           0 : void ScFormulaFrmtEntry::SetActive()
     610             : {
     611           0 :     maWdPreview.Show();
     612           0 :     maFtStyle.Show();
     613           0 :     maLbStyle.Show();
     614           0 :     maEdFormula.Show();
     615             : 
     616           0 :     Select();
     617           0 : }
     618             : 
     619           0 : void ScFormulaFrmtEntry::SetInactive()
     620             : {
     621           0 :     maWdPreview.Hide();
     622           0 :     maFtStyle.Hide();
     623           0 :     maLbStyle.Hide();
     624           0 :     maEdFormula.Hide();
     625             : 
     626           0 :     Deselect();
     627           0 : }
     628             : 
     629             : //color scale
     630             : 
     631             : namespace {
     632             : 
     633           0 : OUString convertNumberToString(double nVal, ScDocument* pDoc)
     634             : {
     635           0 :     SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
     636           0 :     OUString aText;
     637           0 :     pNumberFormatter->GetInputLineString(nVal, 0, aText);
     638           0 :     return aText;
     639             : }
     640             : 
     641           0 : void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ColorListBox& rLbCol, ScDocument* pDoc )
     642             : {
     643             :     // entry Automatic is not available for color scales
     644           0 :     sal_Int32 nIndex = static_cast<sal_Int32>(rEntry.GetType());
     645             :     assert(nIndex > 0);
     646           0 :     rLbType.SelectEntryPos(nIndex - 1);
     647           0 :     switch(rEntry.GetType())
     648             :     {
     649             :         case COLORSCALE_MIN:
     650             :         case COLORSCALE_MAX:
     651           0 :             break;
     652             :         case COLORSCALE_PERCENTILE:
     653             :         case COLORSCALE_VALUE:
     654             :         case COLORSCALE_PERCENT:
     655             :             {
     656           0 :                 double nVal = rEntry.GetValue();
     657           0 :                 rEdit.SetText(convertNumberToString(nVal, pDoc));
     658             :             }
     659           0 :             break;
     660             :         case COLORSCALE_FORMULA:
     661           0 :             rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
     662           0 :             break;
     663             :         case COLORSCALE_AUTO:
     664           0 :             abort();
     665             :             break;
     666             :     }
     667           0 :     rLbCol.SelectEntry(rEntry.GetColor());
     668           0 : }
     669             : 
     670           0 : void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos, bool bDataBar )
     671             : {
     672           0 :     sal_uInt32 nIndex = 0;
     673           0 :     double nVal = 0;
     674           0 :     SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
     675           0 :     pNumberFormatter->IsNumberFormat(rValue.GetText(), nIndex, nVal);
     676             : 
     677             :     // color scale does not have the automatic entry
     678           0 :     sal_Int32 nPos = rType.GetSelectEntryPos();
     679           0 :     if(!bDataBar)
     680           0 :         ++nPos;
     681             : 
     682           0 :     pEntry->SetType(static_cast<ScColorScaleEntryType>(nPos));
     683           0 :     switch(nPos)
     684             :     {
     685             :         case COLORSCALE_AUTO:
     686             :         case COLORSCALE_MIN:
     687             :         case COLORSCALE_MAX:
     688           0 :             break;
     689             :         case COLORSCALE_PERCENTILE:
     690             :         case COLORSCALE_VALUE:
     691             :         case COLORSCALE_PERCENT:
     692           0 :             pEntry->SetValue(nVal);
     693           0 :             break;
     694             :         case COLORSCALE_FORMULA:
     695           0 :             pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
     696           0 :             break;
     697             :         default:
     698           0 :             break;
     699             :     }
     700           0 : }
     701             : 
     702           0 : ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListBox& rColor, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
     703             : {
     704           0 :     ScColorScaleEntry* pEntry = new ScColorScaleEntry();
     705             : 
     706           0 :     SetColorScaleEntry( pEntry, rType, rValue, pDoc, rPos, false );
     707           0 :     Color aColor = rColor.GetSelectEntryColor();
     708           0 :     pEntry->SetColor(aColor);
     709           0 :     return pEntry;
     710             : }
     711             : 
     712             : }
     713             : 
     714           0 : ScColorScale2FrmtEntry::ScColorScale2FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
     715             :     ScCondFrmtEntry( pParent, pDoc, rPos ),
     716             :     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
     717             :     maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE_MIN ) ),
     718             :     maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE_MAX ) ),
     719             :     maEdMin( this, ScResId( ED_COL_SCALE_MIN ) ),
     720             :     maEdMax( this, ScResId( ED_COL_SCALE_MAX ) ),
     721             :     maLbColMin( this, ScResId( LB_COL_MIN ) ),
     722           0 :     maLbColMax( this, ScResId( LB_COL_MAX ) )
     723             : {
     724             :     // remove the automatic entry from color scales
     725           0 :     maLbEntryTypeMin.RemoveEntry(0);
     726           0 :     maLbEntryTypeMax.RemoveEntry(0);
     727             : 
     728           0 :     maLbType.SelectEntryPos(0);
     729           0 :     maLbColorFormat.SelectEntryPos(0);
     730           0 :     Init();
     731           0 :     if(pFormat)
     732             :     {
     733           0 :         ScColorScaleFormat::const_iterator itr = pFormat->begin();
     734           0 :         SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin, pDoc);
     735           0 :         ++itr;
     736           0 :         SetColorScaleEntryTypes(*itr, maLbEntryTypeMax, maEdMax, maLbColMax, pDoc);
     737             :     }
     738             :     else
     739             :     {
     740           0 :         maLbEntryTypeMin.SelectEntryPos(0);
     741           0 :         maLbEntryTypeMax.SelectEntryPos(1);
     742             :     }
     743           0 :     FreeResource();
     744             : 
     745           0 :     maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
     746             : 
     747           0 :     EntryTypeHdl(&maLbEntryTypeMin);
     748           0 :     EntryTypeHdl(&maLbEntryTypeMax);
     749           0 : }
     750             : 
     751           0 : void ScColorScale2FrmtEntry::Init()
     752             : {
     753           0 :     maLbEntryTypeMin.SetSelectHdl( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
     754           0 :     maLbEntryTypeMax.SetSelectHdl( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
     755             : 
     756           0 :     SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
     757           0 :     XColorListRef       pColorTable;
     758             : 
     759             :     DBG_ASSERT( pDocSh, "DocShell not found!" );
     760             : 
     761           0 :     if ( pDocSh )
     762             :     {
     763           0 :         const SfxPoolItem*  pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     764           0 :         if ( pItem != NULL )
     765           0 :             pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
     766             :     }
     767           0 :     if ( pColorTable.is() )
     768             :     {
     769             :         // filling the line color box
     770           0 :         maLbColMin.SetUpdateMode( false );
     771           0 :         maLbColMax.SetUpdateMode( false );
     772             : 
     773           0 :         for ( long i = 0; i < pColorTable->Count(); ++i )
     774             :         {
     775           0 :             XColorEntry* pEntry = pColorTable->GetColor(i);
     776           0 :             maLbColMin.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     777           0 :             maLbColMax.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     778             : 
     779           0 :             if(pEntry->GetColor() == Color(COL_LIGHTRED))
     780           0 :                 maLbColMin.SelectEntryPos(i);
     781           0 :             if(pEntry->GetColor() == Color(COL_LIGHTBLUE))
     782           0 :                 maLbColMax.SelectEntryPos(i);
     783             :         }
     784           0 :         maLbColMin.SetUpdateMode( sal_True );
     785           0 :         maLbColMax.SetUpdateMode( sal_True );
     786           0 :     }
     787           0 : }
     788             : 
     789           0 : ScFormatEntry* ScColorScale2FrmtEntry::createColorscaleEntry() const
     790             : {
     791           0 :     ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
     792           0 :     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
     793           0 :     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMax, maLbColMax, maEdMax, mpDoc, maPos));
     794           0 :     return pColorScale;
     795             : }
     796             : 
     797           0 : OUString ScColorScale2FrmtEntry::GetExpressionString()
     798             : {
     799           0 :     return ScCondFormatHelper::GetExpression( COLORSCALE, 0 );
     800             : }
     801             : 
     802           0 : ScFormatEntry* ScColorScale2FrmtEntry::GetEntry() const
     803             : {
     804           0 :     return createColorscaleEntry();
     805             : }
     806             : 
     807           0 : void ScColorScale2FrmtEntry::SetActive()
     808             : {
     809           0 :     maLbColorFormat.Show();
     810             : 
     811           0 :     maLbEntryTypeMin.Show();
     812           0 :     maLbEntryTypeMax.Show();
     813             : 
     814           0 :     maEdMin.Show();
     815           0 :     maEdMax.Show();
     816             : 
     817           0 :     maLbColMin.Show();
     818           0 :     maLbColMax.Show();
     819             : 
     820           0 :     Select();
     821           0 : }
     822             : 
     823           0 : void ScColorScale2FrmtEntry::SetInactive()
     824             : {
     825           0 :     maLbColorFormat.Hide();
     826             : 
     827           0 :     maLbEntryTypeMin.Hide();
     828           0 :     maLbEntryTypeMax.Hide();
     829             : 
     830           0 :     maEdMin.Hide();
     831           0 :     maEdMax.Hide();
     832             : 
     833           0 :     maLbColMin.Hide();
     834           0 :     maLbColMax.Hide();
     835             : 
     836           0 :     Deselect();
     837           0 : }
     838             : 
     839           0 : IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, ListBox*, pBox )
     840             : {
     841           0 :     bool bEnableEdit = true;
     842           0 :     sal_Int32 nPos = pBox->GetSelectEntryPos();
     843           0 :     if(nPos < 2)
     844             :     {
     845           0 :         bEnableEdit = false;
     846             :     }
     847             : 
     848           0 :     Edit* pEd = NULL;
     849           0 :     if(pBox == &maLbEntryTypeMin)
     850           0 :         pEd = &maEdMin;
     851           0 :     else if(pBox == &maLbEntryTypeMax)
     852           0 :         pEd = &maEdMax;
     853             : 
     854           0 :     if(bEnableEdit)
     855           0 :         pEd->Enable();
     856             :     else
     857           0 :         pEd->Disable();
     858             : 
     859           0 :     return 0;
     860             : }
     861             : 
     862           0 : ScColorScale3FrmtEntry::ScColorScale3FrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScColorScaleFormat* pFormat ):
     863             :     ScCondFrmtEntry( pParent, pDoc, rPos ),
     864             :     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
     865             :     maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE_MIN ) ),
     866             :     maLbEntryTypeMiddle( this, ScResId( LB_TYPE_COL_SCALE_MIDDLE ) ),
     867             :     maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE_MAX ) ),
     868             :     maEdMin( this, ScResId( ED_COL_SCALE_MIN ) ),
     869             :     maEdMiddle( this, ScResId( ED_COL_SCALE_MIDDLE ) ),
     870             :     maEdMax( this, ScResId( ED_COL_SCALE_MAX ) ),
     871             :     maLbColMin( this, ScResId( LB_COL_MIN ) ),
     872             :     maLbColMiddle( this, ScResId( LB_COL_MIDDLE ) ),
     873           0 :     maLbColMax( this, ScResId( LB_COL_MAX ) )
     874             : {
     875             :     // remove the automatic entry from color scales
     876           0 :     maLbEntryTypeMin.RemoveEntry(0);
     877           0 :     maLbEntryTypeMiddle.RemoveEntry(0);
     878           0 :     maLbEntryTypeMax.RemoveEntry(0);
     879           0 :     maLbColorFormat.SelectEntryPos(1);
     880             : 
     881           0 :     Init();
     882           0 :     maLbType.SelectEntryPos(0);
     883           0 :     if(pFormat)
     884             :     {
     885           0 :         ScColorScaleFormat::const_iterator itr = pFormat->begin();
     886           0 :         SetColorScaleEntryTypes(*itr, maLbEntryTypeMin, maEdMin, maLbColMin, pDoc);
     887             :         assert(pFormat->size() == 3);
     888           0 :         ++itr;
     889           0 :         SetColorScaleEntryTypes(*itr, maLbEntryTypeMiddle, maEdMiddle, maLbColMiddle, pDoc);
     890           0 :         ++itr;
     891           0 :         SetColorScaleEntryTypes(*itr, maLbEntryTypeMax, maEdMax, maLbColMax, pDoc);
     892             :     }
     893             :     else
     894             :     {
     895           0 :         maLbColorFormat.SelectEntryPos(1);
     896           0 :         maLbEntryTypeMin.SelectEntryPos(0);
     897           0 :         maLbEntryTypeMiddle.SelectEntryPos(2);
     898           0 :         maLbEntryTypeMax.SelectEntryPos(1);
     899           0 :         maEdMiddle.SetText(OUString::number(50));
     900             :     }
     901           0 :     FreeResource();
     902             : 
     903           0 :     maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
     904           0 :     EntryTypeHdl(&maLbEntryTypeMin);
     905           0 :     EntryTypeHdl(&maLbEntryTypeMiddle);
     906           0 :     EntryTypeHdl(&maLbEntryTypeMax);
     907           0 : }
     908             : 
     909           0 : void ScColorScale3FrmtEntry::Init()
     910             : {
     911           0 :     maLbEntryTypeMin.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
     912           0 :     maLbEntryTypeMax.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
     913           0 :     maLbEntryTypeMiddle.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
     914             : 
     915           0 :     SfxObjectShell*     pDocSh      = SfxObjectShell::Current();
     916           0 :     XColorListRef       pColorTable;
     917             : 
     918             :     DBG_ASSERT( pDocSh, "DocShell not found!" );
     919             : 
     920           0 :     if ( pDocSh )
     921             :     {
     922           0 :         const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE );
     923           0 :         if ( pItem != NULL )
     924           0 :             pColorTable = ( (SvxColorListItem*)pItem )->GetColorList();
     925             :     }
     926           0 :     if ( pColorTable.is() )
     927             :     {
     928             :         // filling the line color box
     929           0 :         maLbColMin.SetUpdateMode( false );
     930           0 :         maLbColMiddle.SetUpdateMode( false );
     931           0 :         maLbColMax.SetUpdateMode( false );
     932             : 
     933           0 :         for ( long i = 0; i < pColorTable->Count(); ++i )
     934             :         {
     935           0 :             XColorEntry* pEntry = pColorTable->GetColor(i);
     936           0 :             maLbColMin.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     937           0 :             maLbColMiddle.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     938           0 :             maLbColMax.InsertEntry( pEntry->GetColor(), pEntry->GetName() );
     939             : 
     940           0 :             if(pEntry->GetColor() == Color(COL_LIGHTRED))
     941           0 :                 maLbColMin.SelectEntryPos(i);
     942           0 :             if(pEntry->GetColor() == Color(COL_GREEN))
     943           0 :                 maLbColMiddle.SelectEntryPos(i);
     944           0 :             if(pEntry->GetColor() == Color(COL_LIGHTBLUE))
     945           0 :                 maLbColMax.SelectEntryPos(i);
     946             :         }
     947           0 :         maLbColMin.SetUpdateMode( sal_True );
     948           0 :         maLbColMiddle.SetUpdateMode( sal_True );
     949           0 :         maLbColMax.SetUpdateMode( sal_True );
     950           0 :     }
     951           0 : }
     952             : 
     953           0 : ScFormatEntry* ScColorScale3FrmtEntry::createColorscaleEntry() const
     954             : {
     955           0 :     ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
     956           0 :     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMin, maLbColMin, maEdMin, mpDoc, maPos));
     957           0 :     if(maLbColorFormat.GetSelectEntryPos() == 1)
     958           0 :         pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMiddle, maLbColMiddle, maEdMiddle, mpDoc, maPos));
     959           0 :     pColorScale->AddEntry(createColorScaleEntry(maLbEntryTypeMax, maLbColMax, maEdMax, mpDoc, maPos));
     960           0 :     return pColorScale;
     961             : }
     962             : 
     963           0 : OUString ScColorScale3FrmtEntry::GetExpressionString()
     964             : {
     965           0 :     return ScCondFormatHelper::GetExpression( COLORSCALE, 0 );
     966             : }
     967             : 
     968           0 : ScFormatEntry* ScColorScale3FrmtEntry::GetEntry() const
     969             : {
     970           0 :     return createColorscaleEntry();
     971             : }
     972             : 
     973           0 : void ScColorScale3FrmtEntry::SetActive()
     974             : {
     975           0 :     maLbColorFormat.Show();
     976           0 :     maLbEntryTypeMin.Show();
     977           0 :     maLbEntryTypeMiddle.Show();
     978           0 :     maLbEntryTypeMax.Show();
     979             : 
     980           0 :     maEdMin.Show();
     981           0 :     maEdMiddle.Show();
     982           0 :     maEdMax.Show();
     983             : 
     984           0 :     maLbColMin.Show();
     985           0 :     maLbColMiddle.Show();
     986           0 :     maLbColMax.Show();
     987             : 
     988           0 :     Select();
     989           0 : }
     990             : 
     991           0 : void ScColorScale3FrmtEntry::SetInactive()
     992             : {
     993           0 :     maLbColorFormat.Hide();
     994             : 
     995           0 :     maLbEntryTypeMin.Hide();
     996           0 :     maLbEntryTypeMiddle.Hide();
     997           0 :     maLbEntryTypeMax.Hide();
     998             : 
     999           0 :     maEdMin.Hide();
    1000           0 :     maEdMiddle.Hide();
    1001           0 :     maEdMax.Hide();
    1002             : 
    1003           0 :     maLbColMin.Hide();
    1004           0 :     maLbColMiddle.Hide();
    1005           0 :     maLbColMax.Hide();
    1006             : 
    1007           0 :     Deselect();
    1008           0 : }
    1009             : 
    1010           0 : IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, ListBox*, pBox )
    1011             : {
    1012           0 :     bool bEnableEdit = true;
    1013           0 :     sal_Int32 nPos = pBox->GetSelectEntryPos();
    1014           0 :     if(nPos < 2)
    1015             :     {
    1016           0 :         bEnableEdit = false;
    1017             :     }
    1018             : 
    1019           0 :     Edit* pEd = NULL;
    1020           0 :     if(pBox == &maLbEntryTypeMin)
    1021           0 :         pEd = &maEdMin;
    1022           0 :     else if(pBox == &maLbEntryTypeMiddle)
    1023           0 :         pEd = &maEdMiddle;
    1024           0 :     else if(pBox == &maLbEntryTypeMax)
    1025           0 :         pEd = &maEdMax;
    1026             : 
    1027           0 :     if(bEnableEdit)
    1028           0 :         pEd->Enable();
    1029             :     else
    1030           0 :         pEd->Disable();
    1031             : 
    1032           0 :     return 0;
    1033             : }
    1034             : 
    1035           0 : IMPL_LINK_NOARG( ScConditionFrmtEntry, ConditionTypeSelectHdl )
    1036             : {
    1037           0 :     sal_Int32 nSelectPos = maLbCondType.GetSelectEntryPos();
    1038           0 :     if(nSelectPos == 6 || nSelectPos == 7)
    1039             :     {
    1040           0 :         maEdVal1.Show();
    1041           0 :         maEdVal2.Show();
    1042             :     }
    1043           0 :     else if(nSelectPos == 8 || nSelectPos == 9)
    1044             :     {
    1045           0 :         maEdVal2.Hide();
    1046           0 :         maEdVal1.Hide();
    1047             :     }
    1048           0 :     else if(nSelectPos <= 5 || (nSelectPos >= 10 && nSelectPos <= 13)
    1049           0 :             || nSelectPos >= 18)
    1050             :     {
    1051           0 :         maEdVal1.Show();
    1052           0 :         maEdVal2.Hide();
    1053             :     }
    1054             :     else
    1055             :     {
    1056           0 :         maEdVal1.Hide();
    1057           0 :         maEdVal2.Hide();
    1058             :     }
    1059             : 
    1060           0 :     return 0;
    1061             : }
    1062             : 
    1063             : //databar
    1064             : 
    1065             : namespace {
    1066             : 
    1067           0 : void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, ListBox& rLbType, Edit& rEdit, ScDocument* pDoc )
    1068             : {
    1069           0 :     rLbType.SelectEntryPos(rEntry.GetType());
    1070           0 :     switch(rEntry.GetType())
    1071             :     {
    1072             :         case COLORSCALE_AUTO:
    1073             :         case COLORSCALE_MIN:
    1074             :         case COLORSCALE_MAX:
    1075           0 :             break;
    1076             :         case COLORSCALE_VALUE:
    1077             :         case COLORSCALE_PERCENT:
    1078             :         case COLORSCALE_PERCENTILE:
    1079             :             {
    1080           0 :                 double nVal = rEntry.GetValue();
    1081           0 :                 SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
    1082           0 :                 OUString aText;
    1083           0 :                 pNumberFormatter->GetInputLineString(nVal, 0, aText);
    1084           0 :                 rEdit.SetText(aText);
    1085             :             }
    1086           0 :             break;
    1087             :         case COLORSCALE_FORMULA:
    1088           0 :             rEdit.SetText(rEntry.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
    1089           0 :             break;
    1090             :     }
    1091           0 : }
    1092             : 
    1093             : }
    1094             : 
    1095           0 : ScDataBarFrmtEntry::ScDataBarFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScDataBarFormat* pFormat ):
    1096             :     ScCondFrmtEntry( pParent, pDoc, rPos ),
    1097             :     maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
    1098             :     maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE_MIN ) ),
    1099             :     maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE_MAX ) ),
    1100             :     maEdDataBarMin( this, ScResId( ED_COL_SCALE_MIN ) ),
    1101             :     maEdDataBarMax( this, ScResId( ED_COL_SCALE_MAX ) ),
    1102           0 :     maBtOptions( this, ScResId( BTN_OPTIONS ) )
    1103             : {
    1104           0 :     maLbColorFormat.SelectEntryPos(2);
    1105           0 :     maLbType.SelectEntryPos(0);
    1106           0 :     if(pFormat)
    1107             :     {
    1108           0 :         mpDataBarData.reset(new ScDataBarFormatData(*pFormat->GetDataBarData()));
    1109           0 :         SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin, pDoc);
    1110           0 :         SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax, pDoc);
    1111           0 :         DataBarTypeSelectHdl(NULL);
    1112             :     }
    1113             :     else
    1114             :     {
    1115           0 :         maLbDataBarMinType.SelectEntryPos(0);
    1116           0 :         maLbDataBarMaxType.SelectEntryPos(0);
    1117           0 :         DataBarTypeSelectHdl(NULL);
    1118             :     }
    1119           0 :     Init();
    1120             : 
    1121           0 :     maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    1122             : 
    1123           0 :     FreeResource();
    1124           0 : }
    1125             : 
    1126           0 : ScFormatEntry* ScDataBarFrmtEntry::GetEntry() const
    1127             : {
    1128           0 :     return createDatabarEntry();
    1129             : }
    1130             : 
    1131           0 : void ScDataBarFrmtEntry::Init()
    1132             : {
    1133           0 :     maLbDataBarMinType.SetSelectHdl( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
    1134           0 :     maLbDataBarMaxType.SetSelectHdl( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
    1135             : 
    1136           0 :     maBtOptions.SetClickHdl( LINK( this, ScDataBarFrmtEntry, OptionBtnHdl ) );
    1137             : 
    1138           0 :     if(!mpDataBarData)
    1139             :     {
    1140           0 :         mpDataBarData.reset(new ScDataBarFormatData());
    1141           0 :         mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry());
    1142           0 :         mpDataBarData->mpLowerLimit.reset(new ScColorScaleEntry());
    1143           0 :         mpDataBarData->mpLowerLimit->SetType(COLORSCALE_AUTO);
    1144           0 :         mpDataBarData->mpUpperLimit->SetType(COLORSCALE_AUTO);
    1145           0 :         mpDataBarData->maPositiveColor = COL_LIGHTBLUE;
    1146             :     }
    1147           0 : }
    1148             : 
    1149           0 : ScFormatEntry* ScDataBarFrmtEntry::createDatabarEntry() const
    1150             : {
    1151           0 :     SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), maLbDataBarMinType, maEdDataBarMin, mpDoc, maPos, true);
    1152           0 :     SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), maLbDataBarMaxType, maEdDataBarMax, mpDoc, maPos, true);
    1153           0 :     ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
    1154           0 :     pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData.get()));
    1155           0 :     return pDataBar;
    1156             : }
    1157             : 
    1158           0 : OUString ScDataBarFrmtEntry::GetExpressionString()
    1159             : {
    1160           0 :     return ScCondFormatHelper::GetExpression( DATABAR, 0 );
    1161             : }
    1162             : 
    1163           0 : void ScDataBarFrmtEntry::SetActive()
    1164             : {
    1165           0 :     maLbColorFormat.Show();
    1166             : 
    1167           0 :     maLbDataBarMinType.Show();
    1168           0 :     maLbDataBarMaxType.Show();
    1169           0 :     maEdDataBarMin.Show();
    1170           0 :     maEdDataBarMax.Show();
    1171           0 :     maBtOptions.Show();
    1172             : 
    1173           0 :     Select();
    1174           0 : }
    1175             : 
    1176           0 : void ScDataBarFrmtEntry::SetInactive()
    1177             : {
    1178           0 :     maLbColorFormat.Hide();
    1179             : 
    1180           0 :     maLbDataBarMinType.Hide();
    1181           0 :     maLbDataBarMaxType.Hide();
    1182           0 :     maEdDataBarMin.Hide();
    1183           0 :     maEdDataBarMax.Hide();
    1184           0 :     maBtOptions.Hide();
    1185             : 
    1186           0 :     Deselect();
    1187           0 : }
    1188             : 
    1189           0 : IMPL_LINK_NOARG( ScDataBarFrmtEntry, DataBarTypeSelectHdl )
    1190             : {
    1191           0 :     sal_Int32 nSelectPos = maLbDataBarMinType.GetSelectEntryPos();
    1192           0 :     if(nSelectPos <= COLORSCALE_MAX)
    1193           0 :         maEdDataBarMin.Disable();
    1194             :     else
    1195           0 :         maEdDataBarMin.Enable();
    1196             : 
    1197           0 :     nSelectPos = maLbDataBarMaxType.GetSelectEntryPos();
    1198           0 :     if(nSelectPos <= COLORSCALE_MAX)
    1199           0 :         maEdDataBarMax.Disable();
    1200             :     else
    1201           0 :         maEdDataBarMax.Enable();
    1202             : 
    1203           0 :     return 0;
    1204             : }
    1205             : 
    1206           0 : IMPL_LINK_NOARG( ScDataBarFrmtEntry, OptionBtnHdl )
    1207             : {
    1208           0 :     SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), maLbDataBarMinType, maEdDataBarMin, mpDoc, maPos, true);
    1209           0 :     SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), maLbDataBarMaxType, maEdDataBarMax, mpDoc, maPos, true);
    1210           0 :     ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this, *mpDataBarData, mpDoc, maPos);
    1211           0 :     if( pDlg->Execute() == RET_OK)
    1212             :     {
    1213           0 :         mpDataBarData.reset(pDlg->GetData());
    1214           0 :         SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin, mpDoc);
    1215           0 :         SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax, mpDoc);
    1216           0 :         DataBarTypeSelectHdl(NULL);
    1217             :     }
    1218           0 :     return 0;
    1219             : }
    1220             : 
    1221           0 : ScDateFrmtEntry::ScDateFrmtEntry( Window* pParent, ScDocument* pDoc, const ScCondDateFormatEntry* pFormat ):
    1222             :     ScCondFrmtEntry( pParent, pDoc, ScAddress() ),
    1223             :     maLbDateEntry( this, ScResId( LB_DATE_TYPE ) ),
    1224             :     maFtStyle( this, ScResId( FT_STYLE ) ),
    1225             :     maLbStyle( this, ScResId( LB_STYLE ) ),
    1226             :     maWdPreview( this, ScResId( WD_PREVIEW ) ),
    1227           0 :     mbIsInStyleCreate(false)
    1228             : {
    1229           0 :     Init();
    1230           0 :     FreeResource();
    1231             : 
    1232           0 :     StartListening(*pDoc->GetStyleSheetPool(), sal_True);
    1233             : 
    1234           0 :     if(pFormat)
    1235             :     {
    1236           0 :         sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType());
    1237           0 :         maLbDateEntry.SelectEntryPos(nPos);
    1238             : 
    1239           0 :         OUString aStyleName = pFormat->GetStyleName();
    1240           0 :         maLbStyle.SelectEntry(aStyleName);
    1241             :     }
    1242             : 
    1243           0 :     StyleSelectHdl(NULL);
    1244           0 : }
    1245             : 
    1246           0 : void ScDateFrmtEntry::Init()
    1247             : {
    1248           0 :     maLbDateEntry.SelectEntryPos(0);
    1249           0 :     maLbType.SelectEntryPos(3);
    1250             : 
    1251           0 :     FillStyleListBox( mpDoc, maLbStyle );
    1252           0 :     maLbStyle.SetSelectHdl( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) );
    1253           0 :     maLbStyle.SelectEntryPos(1);
    1254           0 : }
    1255             : 
    1256           0 : void ScDateFrmtEntry::SetActive()
    1257             : {
    1258           0 :     maLbDateEntry.Show();
    1259           0 :     maFtStyle.Show();
    1260           0 :     maWdPreview.Show();
    1261           0 :     maLbStyle.Show();
    1262             : 
    1263           0 :     Select();
    1264           0 : }
    1265             : 
    1266           0 : void ScDateFrmtEntry::SetInactive()
    1267             : {
    1268           0 :     maLbDateEntry.Hide();
    1269           0 :     maFtStyle.Hide();
    1270           0 :     maWdPreview.Hide();
    1271           0 :     maLbStyle.Hide();
    1272             : 
    1273           0 :     Deselect();
    1274           0 : }
    1275             : 
    1276           0 : void ScDateFrmtEntry::Notify( SfxBroadcaster&, const SfxHint& rHint )
    1277             : {
    1278           0 :     SfxStyleSheetHint* pHint = PTR_CAST(SfxStyleSheetHint, &rHint);
    1279           0 :     if(!pHint)
    1280           0 :         return;
    1281             : 
    1282           0 :     sal_uInt16 nHint = pHint->GetHint();
    1283           0 :     if(nHint == SFX_STYLESHEET_MODIFIED)
    1284             :     {
    1285           0 :         if(!mbIsInStyleCreate)
    1286           0 :             UpdateStyleList(maLbStyle, mpDoc);
    1287             :     }
    1288             : }
    1289             : 
    1290           0 : ScFormatEntry* ScDateFrmtEntry::GetEntry() const
    1291             : {
    1292           0 :     ScCondDateFormatEntry* pNewEntry = new ScCondDateFormatEntry(mpDoc);
    1293           0 :     condformat::ScCondFormatDateType eType = static_cast<condformat::ScCondFormatDateType>(maLbDateEntry.GetSelectEntryPos());
    1294           0 :     pNewEntry->SetDateType(eType);
    1295           0 :     pNewEntry->SetStyleName(maLbStyle.GetSelectEntry());
    1296           0 :     return pNewEntry;
    1297             : }
    1298             : 
    1299           0 : OUString ScDateFrmtEntry::GetExpressionString()
    1300             : {
    1301           0 :     return ScCondFormatHelper::GetExpression(DATE, 0);
    1302             : }
    1303             : 
    1304           0 : IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl )
    1305             : {
    1306           0 :     mbIsInStyleCreate = true;
    1307           0 :     StyleSelect( maLbStyle, mpDoc, maWdPreview );
    1308           0 :     mbIsInStyleCreate = false;
    1309             : 
    1310           0 :     return 0;
    1311             : }
    1312             : 
    1313           0 : class ScIconSetFrmtDataEntry : public Control
    1314             : {
    1315             :     private:
    1316             :         FixedImage maImgIcon;
    1317             :         FixedText maFtEntry;
    1318             :         Edit maEdEntry;
    1319             :         ListBox maLbEntryType;
    1320             : 
    1321             :     public:
    1322             :         ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, ScDocument* pDoc,
    1323             :                 sal_Int32 i, const ScColorScaleEntry* pEntry = NULL );
    1324             : 
    1325             :         ScColorScaleEntry* CreateEntry(ScDocument* pDoc, const ScAddress& rPos) const;
    1326             : 
    1327             :         void SetFirstEntry();
    1328             : };
    1329             : 
    1330           0 : ScIconSetFrmtDataEntry::ScIconSetFrmtDataEntry( Window* pParent, ScIconSetType eType, ScDocument* pDoc, sal_Int32 i, const ScColorScaleEntry* pEntry ):
    1331             :     Control( pParent, ScResId( RID_ICON_SET_ENTRY ) ),
    1332             :     maImgIcon( this, ScResId( IMG_ICON ) ),
    1333             :     maFtEntry( this, ScResId( FT_ICON_SET_ENTRY_TEXT ) ),
    1334             :     maEdEntry( this, ScResId( ED_ICON_SET_ENTRY_VALUE ) ),
    1335           0 :     maLbEntryType( this, ScResId( LB_ICON_SET_ENTRY_TYPE ) )
    1336             : {
    1337           0 :     maImgIcon.SetImage(ScIconSetFormat::getBitmap( eType, i ));
    1338           0 :     if(pEntry)
    1339             :     {
    1340           0 :         switch(pEntry->GetType())
    1341             :         {
    1342             :             case COLORSCALE_VALUE:
    1343           0 :                 maLbEntryType.SelectEntryPos(0);
    1344           0 :                 maEdEntry.SetText(convertNumberToString(pEntry->GetValue(), pDoc));
    1345           0 :                 break;
    1346             :             case COLORSCALE_PERCENTILE:
    1347           0 :                 maLbEntryType.SelectEntryPos(2);
    1348           0 :                 maEdEntry.SetText(convertNumberToString(pEntry->GetValue(), pDoc));
    1349           0 :                 break;
    1350             :             case COLORSCALE_PERCENT:
    1351           0 :                 maLbEntryType.SelectEntryPos(1);
    1352           0 :                 maEdEntry.SetText(convertNumberToString(pEntry->GetValue(), pDoc));
    1353           0 :                 break;
    1354             :             case COLORSCALE_FORMULA:
    1355           0 :                 maLbEntryType.SelectEntryPos(3);
    1356           0 :                 maEdEntry.SetText(pEntry->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT));
    1357           0 :                 break;
    1358             :             default:
    1359             :                 assert(false);
    1360             :         }
    1361             :     }
    1362             :     else
    1363             :     {
    1364           0 :         maLbEntryType.SelectEntryPos(1);
    1365             :     }
    1366           0 :     FreeResource();
    1367           0 : }
    1368             : 
    1369           0 : ScColorScaleEntry* ScIconSetFrmtDataEntry::CreateEntry(ScDocument* pDoc, const ScAddress& rPos) const
    1370             : {
    1371           0 :     sal_Int32 nPos = maLbEntryType.GetSelectEntryPos();
    1372           0 :     OUString aText = maEdEntry.GetText();
    1373           0 :     ScColorScaleEntry* pEntry = new ScColorScaleEntry();
    1374             : 
    1375           0 :     sal_uInt32 nIndex = 0;
    1376           0 :     double nVal = 0;
    1377           0 :     SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
    1378           0 :     pNumberFormatter->IsNumberFormat(aText, nIndex, nVal);
    1379           0 :     pEntry->SetValue(nVal);
    1380             : 
    1381           0 :     switch(nPos)
    1382             :     {
    1383             :         case 0:
    1384           0 :             pEntry->SetType(COLORSCALE_VALUE);
    1385           0 :             break;
    1386             :         case 1:
    1387           0 :             pEntry->SetType(COLORSCALE_PERCENT);
    1388           0 :             break;
    1389             :         case 2:
    1390           0 :             pEntry->SetType(COLORSCALE_PERCENTILE);
    1391           0 :             break;
    1392             :         case 3:
    1393           0 :             pEntry->SetType(COLORSCALE_FORMULA);
    1394           0 :             pEntry->SetFormula(aText, pDoc, rPos, pDoc->GetGrammar());
    1395           0 :             break;
    1396             :         default:
    1397             :             assert(false);
    1398             :     }
    1399             : 
    1400           0 :     return pEntry;
    1401             : }
    1402             : 
    1403           0 : void ScIconSetFrmtDataEntry::SetFirstEntry()
    1404             : {
    1405           0 :     maEdEntry.Hide();
    1406           0 :     maLbEntryType.Hide();
    1407           0 :     maFtEntry.Hide();
    1408           0 :     maEdEntry.SetText(OUString("0"));
    1409           0 :     maLbEntryType.SelectEntryPos(1);
    1410           0 : }
    1411             : 
    1412           0 : ScIconSetFrmtEntry::ScIconSetFrmtEntry( Window* pParent, ScDocument* pDoc, const ScAddress& rPos, const ScIconSetFormat* pFormat ):
    1413             :         ScCondFrmtEntry( pParent, pDoc, rPos ),
    1414             :         maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
    1415           0 :         maLbIconSetType( this, ScResId( LB_ICONSET_TYPE ) )
    1416             : {
    1417           0 :     Init();
    1418           0 :     FreeResource();
    1419           0 :     maLbColorFormat.SetSelectHdl( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
    1420             : 
    1421           0 :     if(pFormat)
    1422             :     {
    1423           0 :         const ScIconSetFormatData* pIconSetFormatData = pFormat->GetIconSetData();
    1424           0 :         ScIconSetType eType = pIconSetFormatData->eIconSetType;
    1425           0 :         sal_Int32 nType = static_cast<sal_Int32>(eType);
    1426           0 :         maLbIconSetType.SelectEntryPos(nType);
    1427             : 
    1428           0 :         for(size_t i = 0, n = pIconSetFormatData->maEntries.size();
    1429             :                 i < n; ++i)
    1430             :         {
    1431           0 :             maEntries.push_back( new ScIconSetFrmtDataEntry( this, eType, pDoc, i, &pIconSetFormatData->maEntries[i] ) );
    1432           0 :             Point aPos = maEntries[0].GetPosPixel();
    1433           0 :             aPos.Y() += maEntries[0].GetSizePixel().Height() * i * 1.2;
    1434           0 :             maEntries[i].SetPosPixel( aPos );
    1435             :         }
    1436           0 :         maEntries.begin()->SetFirstEntry();
    1437             :     }
    1438             :     else
    1439           0 :         IconSetTypeHdl(NULL);
    1440           0 : }
    1441             : 
    1442           0 : void ScIconSetFrmtEntry::Init()
    1443             : {
    1444           0 :     maLbColorFormat.SelectEntryPos(3);
    1445           0 :     maLbType.SelectEntryPos(0);
    1446           0 :     maLbIconSetType.SelectEntryPos(0);
    1447             : 
    1448           0 :     maLbIconSetType.SetSelectHdl( LINK( this, ScIconSetFrmtEntry, IconSetTypeHdl ) );
    1449           0 : }
    1450             : 
    1451           0 : IMPL_LINK_NOARG( ScIconSetFrmtEntry, IconSetTypeHdl )
    1452             : {
    1453           0 :     ScIconSetMap* pMap = ScIconSetFormat::getIconSetMap();
    1454             : 
    1455           0 :     sal_Int32 nPos = maLbIconSetType.GetSelectEntryPos();
    1456           0 :     sal_uInt32 nElements = pMap[nPos].nElements;
    1457           0 :     maEntries.clear();
    1458             : 
    1459           0 :     for(size_t i = 0; i < nElements; ++i)
    1460             :     {
    1461           0 :         maEntries.push_back( new ScIconSetFrmtDataEntry( this, static_cast<ScIconSetType>(nPos), mpDoc, i ) );
    1462           0 :         Point aPos = maEntries[0].GetPosPixel();
    1463           0 :         aPos.Y() += maEntries[0].GetSizePixel().Height() * i * 1.2;
    1464           0 :         maEntries[i].SetPosPixel( aPos );
    1465           0 :         maEntries[i].Show();
    1466             :     }
    1467           0 :     maEntries.begin()->SetFirstEntry();
    1468             : 
    1469           0 :     SetHeight();
    1470           0 :     static_cast<ScCondFormatList*>(GetParent())->RecalcAll();
    1471             : 
    1472           0 :     return 0;
    1473             : }
    1474             : 
    1475           0 : OUString ScIconSetFrmtEntry::GetExpressionString()
    1476             : {
    1477           0 :     return ScCondFormatHelper::GetExpression(ICONSET, 0);
    1478             : }
    1479             : 
    1480           0 : void ScIconSetFrmtEntry::SetActive()
    1481             : {
    1482           0 :     maLbColorFormat.Show();
    1483           0 :     maLbIconSetType.Show();
    1484           0 :     for(ScIconSetFrmtDataEntriesType::iterator itr = maEntries.begin(),
    1485           0 :             itrEnd = maEntries.end(); itr != itrEnd; ++itr)
    1486             :     {
    1487           0 :         itr->Show();
    1488             :     }
    1489             : 
    1490           0 :     Select();
    1491           0 : }
    1492             : 
    1493           0 : void ScIconSetFrmtEntry::SetInactive()
    1494             : {
    1495           0 :     maLbColorFormat.Hide();
    1496           0 :     maLbIconSetType.Hide();
    1497           0 :     for(ScIconSetFrmtDataEntriesType::iterator itr = maEntries.begin(),
    1498           0 :             itrEnd = maEntries.end(); itr != itrEnd; ++itr)
    1499             :     {
    1500           0 :         itr->Hide();
    1501             :     }
    1502             : 
    1503           0 :     Deselect();
    1504           0 : }
    1505             : 
    1506           0 : ScFormatEntry* ScIconSetFrmtEntry::GetEntry() const
    1507             : {
    1508           0 :     ScIconSetFormat* pFormat = new ScIconSetFormat(mpDoc);
    1509             : 
    1510           0 :     ScIconSetFormatData* pData = new ScIconSetFormatData;
    1511           0 :     pData->eIconSetType = static_cast<ScIconSetType>(maLbIconSetType.GetSelectEntryPos());
    1512           0 :     for(ScIconSetFrmtDataEntriesType::const_iterator itr = maEntries.begin(),
    1513           0 :             itrEnd = maEntries.end(); itr != itrEnd; ++itr)
    1514             :     {
    1515           0 :         pData->maEntries.push_back(itr->CreateEntry(mpDoc, maPos));
    1516             :     }
    1517           0 :     pFormat->SetIconSetData(pData);
    1518             : 
    1519           0 :     return pFormat;
    1520          93 : }
    1521             : 
    1522             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10