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

Generated by: LCOV version 1.10