1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #include "condformatdlg.hxx"
11 #include "condformatdlgentry.hxx"
12 #include "condformatdlg.hrc"
13 #include "conditio.hxx"
15 #include "document.hxx"
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"
29 #include "colorformat.hxx"
31 #include "globstr.hrc"
35 ScCondFrmtEntry::ScCondFrmtEntry(Window
* pParent
, ScDocument
* pDoc
, const ScAddress
& rPos
):
36 Control(pParent
, ScResId( RID_COND_ENTRY
) ),
38 maFtCondNr( this, ScResId( FT_COND_NR
) ),
39 maFtCondition( this, ScResId( FT_CONDITION
) ),
41 maStrCondition(ScResId( STR_CONDITION
).toString()),
42 maLbType( this, ScResId( LB_TYPE
) ),
46 SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
48 maLbType
.SetSelectHdl( LINK( pParent
, ScCondFormatList
, TypeListHdl
) );
49 maClickHdl
= LINK( pParent
, ScCondFormatList
, EntrySelectHdl
);
52 ScCondFrmtEntry::~ScCondFrmtEntry()
56 long ScCondFrmtEntry::Notify( NotifyEvent
& rNEvt
)
58 if( rNEvt
.GetType() == EVENT_MOUSEBUTTONDOWN
)
60 ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN
, maClickHdl
, this );
62 return Control::Notify(rNEvt
);
65 void ScCondFrmtEntry::SetIndex(sal_Int32 nIndex
)
68 OUStringBuffer
aBuffer(maStrCondition
);
69 aBuffer
.append(OUString::number(nIndex
));
70 maFtCondNr
.SetText(aBuffer
.makeStringAndClear());
73 void ScCondFrmtEntry::SetHeight()
75 long nPad
= LogicToPixel(Size(42,2), MapMode(MAP_APPFONT
)).getHeight();
77 // Calculate maximum height we need from visible widgets
78 sal_uInt16 nChildren
= GetChildCount();
81 for(sal_uInt16 i
= 0; i
< nChildren
; i
++)
83 Window
*pChild
= GetChild(i
);
84 if(!pChild
|| !pChild
->IsVisible())
86 Point aPos
= pChild
->GetPosPixel();
87 Size aSize
= pChild
->GetSizePixel();
88 nMaxHeight
= std::max(aPos
.Y() + aSize
.Height(), nMaxHeight
);
90 Size aSize
= GetSizePixel();
93 aSize
.Height() = nMaxHeight
+ nPad
;
98 void ScCondFrmtEntry::Select()
100 maFtCondition
.SetText(OUString());
101 maFtCondition
.Hide();
107 void ScCondFrmtEntry::Deselect()
109 OUString maCondText
= GetExpressionString();
110 maFtCondition
.SetText(maCondText
);
111 maFtCondition
.Show();
117 bool ScCondFrmtEntry::IsSelected() const
122 IMPL_LINK(ScCondFrmtEntry
, EdModifyHdl
, Edit
*, pEdit
)
124 OUString aFormula
= pEdit
->GetText();
125 ScCompiler
aComp( mpDoc
, maPos
);
126 aComp
.SetGrammar( mpDoc
->GetGrammar() );
127 boost::scoped_ptr
<ScTokenArray
> mpCode(aComp
.CompileString(aFormula
));
128 if(mpCode
->GetCodeError())
130 pEdit
->SetControlBackground(COL_LIGHTRED
);
134 pEdit
->SetControlBackground(GetSettings().GetStyleSettings().GetWindowColor());
144 void FillStyleListBox( ScDocument
* pDoc
, ListBox
& rLbStyle
)
146 rLbStyle
.SetSeparatorPos(0);
147 std::set
<OUString
> aStyleNames
;
148 SfxStyleSheetIterator
aStyleIter( pDoc
->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA
);
149 for ( SfxStyleSheetBase
* pStyle
= aStyleIter
.First(); pStyle
; pStyle
= aStyleIter
.Next() )
151 OUString aName
= pStyle
->GetName();
152 aStyleNames
.insert(aName
);
154 for(std::set
<OUString
>::const_iterator itr
= aStyleNames
.begin(), itrEnd
= aStyleNames
.end();
155 itr
!= itrEnd
; ++itr
)
157 rLbStyle
.InsertEntry( *itr
);
163 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 mbIsInStyleCreate(false)
175 maLbType
.SelectEntryPos(1);
179 StartListening(*pDoc
->GetStyleSheetPool(), true);
183 OUString aStyleName
= pFormatEntry
->GetStyle();
184 maLbStyle
.SelectEntry(aStyleName
);
185 StyleSelectHdl(NULL
);
186 ScConditionMode eMode
= pFormatEntry
->GetOperation();
187 maEdVal1
.SetText(pFormatEntry
->GetExpression(maPos
, 0));
192 maLbCondType
.SelectEntryPos(0);
195 maLbCondType
.SelectEntryPos(1);
197 case SC_COND_GREATER
:
198 maLbCondType
.SelectEntryPos(2);
201 maLbCondType
.SelectEntryPos(3);
203 case SC_COND_EQGREATER
:
204 maLbCondType
.SelectEntryPos(4);
206 case SC_COND_NOTEQUAL
:
207 maLbCondType
.SelectEntryPos(5);
209 case SC_COND_BETWEEN
:
211 maEdVal2
.SetText(pFormatEntry
->GetExpression(maPos
, 1));
212 maLbCondType
.SelectEntryPos(6);
214 case SC_COND_NOTBETWEEN
:
216 maEdVal2
.SetText(pFormatEntry
->GetExpression(maPos
, 1));
217 maLbCondType
.SelectEntryPos(7);
219 case SC_COND_DUPLICATE
:
220 maLbCondType
.SelectEntryPos(8);
222 case SC_COND_NOTDUPLICATE
:
223 maLbCondType
.SelectEntryPos(9);
227 //maLbType.SelectEntryPos(2);
230 maLbCondType
.SelectEntryPos(10);
232 case SC_COND_BOTTOM10
:
233 maLbCondType
.SelectEntryPos(11);
235 case SC_COND_TOP_PERCENT
:
236 maLbCondType
.SelectEntryPos(12);
238 case SC_COND_BOTTOM_PERCENT
:
239 maLbCondType
.SelectEntryPos(13);
241 case SC_COND_ABOVE_AVERAGE
:
243 maLbCondType
.SelectEntryPos(14);
245 case SC_COND_BELOW_AVERAGE
:
247 maLbCondType
.SelectEntryPos(15);
249 case SC_COND_ABOVE_EQUAL_AVERAGE
:
251 maLbCondType
.SelectEntryPos(16);
253 case SC_COND_BELOW_EQUAL_AVERAGE
:
255 maLbCondType
.SelectEntryPos(17);
259 maLbCondType
.SelectEntryPos(18);
261 case SC_COND_NOERROR
:
263 maLbCondType
.SelectEntryPos(19);
265 case SC_COND_BEGINS_WITH
:
266 maLbCondType
.SelectEntryPos(20);
268 case SC_COND_ENDS_WITH
:
269 maLbCondType
.SelectEntryPos(21);
271 case SC_COND_CONTAINS_TEXT
:
272 maLbCondType
.SelectEntryPos(22);
274 case SC_COND_NOT_CONTAINS_TEXT
:
275 maLbCondType
.SelectEntryPos(23);
283 maLbCondType
.SelectEntryPos(0);
285 maLbStyle
.SelectEntryPos(1);
287 maLbType
.SelectEntryPos(1);
290 void ScConditionFrmtEntry::Init()
292 maEdVal1
.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg
, RangeGetFocusHdl
) );
293 maEdVal2
.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg
, RangeGetFocusHdl
) );
294 maEdVal1
.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg
, RangeLoseFocusHdl
) );
295 maEdVal2
.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg
, RangeLoseFocusHdl
) );
297 maEdVal1
.SetStyle( maEdVal1
.GetStyle() | WB_FORCECTRLBACKGROUND
);
298 maEdVal2
.SetStyle( maEdVal2
.GetStyle() | WB_FORCECTRLBACKGROUND
);
300 maEdVal1
.SetModifyHdl( LINK( this, ScCondFrmtEntry
, EdModifyHdl
) );
301 maEdVal2
.SetModifyHdl( LINK( this, ScCondFrmtEntry
, EdModifyHdl
) );
303 FillStyleListBox( mpDoc
, maLbStyle
);
304 maLbStyle
.SetSelectHdl( LINK( this, ScConditionFrmtEntry
, StyleSelectHdl
) );
306 maLbCondType
.SetSelectHdl( LINK( this, ScConditionFrmtEntry
, ConditionTypeSelectHdl
) );
309 ScFormatEntry
* ScConditionFrmtEntry::createConditionEntry() const
311 ScConditionMode eMode
;
313 switch(maLbCondType
.GetSelectEntryPos())
316 eMode
= SC_COND_EQUAL
;
319 eMode
= SC_COND_LESS
;
322 eMode
= SC_COND_GREATER
;
325 eMode
= SC_COND_EQLESS
;
328 eMode
= SC_COND_EQGREATER
;
331 eMode
= SC_COND_NOTEQUAL
;
334 aExpr2
= maEdVal2
.GetText();
335 eMode
= SC_COND_BETWEEN
;
340 eMode
= SC_COND_NOTBETWEEN
;
341 aExpr2
= maEdVal2
.GetText();
346 eMode
= SC_COND_DUPLICATE
;
349 eMode
= SC_COND_NOTDUPLICATE
;
352 eMode
= SC_COND_TOP10
;
355 eMode
= SC_COND_BOTTOM10
;
358 eMode
= SC_COND_TOP_PERCENT
;
361 eMode
= SC_COND_BOTTOM_PERCENT
;
364 eMode
= SC_COND_ABOVE_AVERAGE
;
367 eMode
= SC_COND_BELOW_AVERAGE
;
370 eMode
= SC_COND_ABOVE_EQUAL_AVERAGE
;
373 eMode
= SC_COND_BELOW_EQUAL_AVERAGE
;
376 eMode
= SC_COND_ERROR
;
379 eMode
= SC_COND_NOERROR
;
382 eMode
= SC_COND_BEGINS_WITH
;
385 eMode
= SC_COND_ENDS_WITH
;
388 eMode
= SC_COND_CONTAINS_TEXT
;
391 eMode
= SC_COND_NOT_CONTAINS_TEXT
;
394 assert(false); // this cannot happen
398 OUString aExpr1
= maEdVal1
.GetText();
400 ScFormatEntry
* pEntry
= new ScCondFormatEntry(eMode
, aExpr1
, aExpr2
, mpDoc
, maPos
, maLbStyle
.GetSelectEntry());
405 OUString
ScConditionFrmtEntry::GetExpressionString()
407 return ScCondFormatHelper::GetExpression(CONDITION
, maLbCondType
.GetSelectEntryPos(), maEdVal1
.GetText(), maEdVal2
.GetText());
410 ScFormatEntry
* ScConditionFrmtEntry::GetEntry() const
412 return createConditionEntry();
415 void ScConditionFrmtEntry::SetActive()
419 if(maLbCondType
.GetSelectEntryPos() == 6 || maLbCondType
.GetSelectEntryPos() == 7)
428 void ScConditionFrmtEntry::SetInactive()
442 void UpdateStyleList(ListBox
& rLbStyle
, ScDocument
* pDoc
)
444 OUString aSelectedStyle
= rLbStyle
.GetSelectEntry();
445 for(sal_Int32 i
= rLbStyle
.GetEntryCount(); i
>= 1; --i
)
447 rLbStyle
.RemoveEntry(i
);
449 FillStyleListBox(pDoc
, rLbStyle
);
450 rLbStyle
.SelectEntry(aSelectedStyle
);
455 void ScConditionFrmtEntry::Notify(SfxBroadcaster
&, const SfxHint
& rHint
)
457 SfxStyleSheetHint
* pHint
= PTR_CAST(SfxStyleSheetHint
, &rHint
);
461 sal_uInt16 nHint
= pHint
->GetHint();
462 if(nHint
== SFX_STYLESHEET_MODIFIED
)
464 if(!mbIsInStyleCreate
)
465 UpdateStyleList(maLbStyle
, mpDoc
);
471 void StyleSelect( ListBox
& rLbStyle
, ScDocument
* pDoc
, SvxFontPrevWindow
& rWdPreview
)
473 if(rLbStyle
.GetSelectEntryPos() == 0)
475 // call new style dialog
476 SfxUInt16Item
aFamilyItem( SID_STYLE_FAMILY
, SFX_STYLE_FAMILY_PARA
);
477 SfxStringItem
aRefItem( SID_STYLE_REFERENCE
, ScGlobal::GetRscString(STR_STYLENAME_STANDARD
) );
479 // unlock the dispatcher so SID_STYLE_NEW can be executed
480 // (SetDispatcherLock would affect all Calc documents)
481 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
482 SfxDispatcher
* pDisp
= pViewShell
->GetDispatcher();
483 sal_Bool bLocked
= pDisp
->IsLocked();
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
,
495 pDisp
->Lock(sal_True
);
497 // Find the new style and add it into the style list boxes
498 SfxStyleSheetIterator
aStyleIter( pDoc
->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA
);
500 for ( SfxStyleSheetBase
* pStyle
= aStyleIter
.First(); pStyle
&& !bFound
; pStyle
= aStyleIter
.Next() )
502 OUString aName
= pStyle
->GetName();
503 if ( rLbStyle
.GetEntryPos(aName
) == LISTBOX_ENTRY_NOTFOUND
) // all lists contain the same entries
505 for( sal_uInt16 i
= 1, n
= rLbStyle
.GetEntryCount(); i
<= n
&& !bFound
; ++i
)
507 OUString aStyleName
= ScGlobal::pCharClass
->uppercase(OUString(rLbStyle
.GetEntry(i
)));
510 rLbStyle
.InsertEntry(aName
);
511 rLbStyle
.SelectEntry(aName
);
514 else if( aStyleName
> ScGlobal::pCharClass
->uppercase(aName
) )
516 rLbStyle
.InsertEntry(aName
, i
);
517 rLbStyle
.SelectEntry(aName
);
525 OUString aStyleName
= rLbStyle
.GetSelectEntry();
526 SfxStyleSheetBase
* pStyleSheet
= pDoc
->GetStyleSheetPool()->Find( aStyleName
, SFX_STYLE_FAMILY_PARA
);
529 const SfxItemSet
& rSet
= pStyleSheet
->GetItemSet();
530 rWdPreview
.Init( rSet
);
536 IMPL_LINK_NOARG(ScConditionFrmtEntry
, StyleSelectHdl
)
538 mbIsInStyleCreate
= true;
539 StyleSelect( maLbStyle
, mpDoc
, maWdPreview
);
540 mbIsInStyleCreate
= false;
546 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 maEdFormula( this, NULL
, NULL
, ScResId( ED_FORMULA
) )
556 maLbType
.SelectEntryPos(2);
560 maEdFormula
.SetText(pFormat
->GetExpression(rPos
, 0, 0, pDoc
->GetGrammar()));
561 maLbStyle
.SelectEntry(pFormat
->GetStyle());
565 maLbStyle
.SelectEntryPos(1);
568 StyleSelectHdl(NULL
);
571 void ScFormulaFrmtEntry::Init()
573 maEdFormula
.SetGetFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg
, RangeGetFocusHdl
) );
574 maEdFormula
.SetLoseFocusHdl( LINK( GetParent()->GetParent(), ScCondFormatDlg
, RangeLoseFocusHdl
) );
576 FillStyleListBox( mpDoc
, maLbStyle
);
577 maLbStyle
.SetSelectHdl( LINK( this, ScFormulaFrmtEntry
, StyleSelectHdl
) );
580 IMPL_LINK_NOARG(ScFormulaFrmtEntry
, StyleSelectHdl
)
582 StyleSelect( maLbStyle
, mpDoc
, maWdPreview
);
587 ScFormatEntry
* ScFormulaFrmtEntry::createFormulaEntry() const
589 ScConditionMode eMode
= SC_COND_DIRECT
;
590 OUString aFormula
= maEdFormula
.GetText();
591 if(aFormula
.isEmpty())
595 ScFormatEntry
* pEntry
= new ScCondFormatEntry(eMode
, aFormula
, aExpr2
, mpDoc
, maPos
, maLbStyle
.GetSelectEntry());
599 ScFormatEntry
* ScFormulaFrmtEntry::GetEntry() const
601 return createFormulaEntry();
604 OUString
ScFormulaFrmtEntry::GetExpressionString()
606 return ScCondFormatHelper::GetExpression(FORMULA
, 0, maEdFormula
.GetText());
609 void ScFormulaFrmtEntry::SetActive()
619 void ScFormulaFrmtEntry::SetInactive()
633 OUString
convertNumberToString(double nVal
, ScDocument
* pDoc
)
635 SvNumberFormatter
* pNumberFormatter
= pDoc
->GetFormatTable();
637 pNumberFormatter
->GetInputLineString(nVal
, 0, aText
);
641 void SetColorScaleEntryTypes( const ScColorScaleEntry
& rEntry
, ListBox
& rLbType
, Edit
& rEdit
, ColorListBox
& rLbCol
, ScDocument
* pDoc
)
643 // entry Automatic is not available for color scales
644 sal_Int32 nIndex
= static_cast<sal_Int32
>(rEntry
.GetType());
646 rLbType
.SelectEntryPos(nIndex
- 1);
647 switch(rEntry
.GetType())
652 case COLORSCALE_PERCENTILE
:
653 case COLORSCALE_VALUE
:
654 case COLORSCALE_PERCENT
:
656 double nVal
= rEntry
.GetValue();
657 rEdit
.SetText(convertNumberToString(nVal
, pDoc
));
660 case COLORSCALE_FORMULA
:
661 rEdit
.SetText(rEntry
.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT
));
663 case COLORSCALE_AUTO
:
667 rLbCol
.SelectEntry(rEntry
.GetColor());
670 void SetColorScaleEntry( ScColorScaleEntry
* pEntry
, const ListBox
& rType
, const Edit
& rValue
, ScDocument
* pDoc
, const ScAddress
& rPos
, bool bDataBar
)
672 sal_uInt32 nIndex
= 0;
674 SvNumberFormatter
* pNumberFormatter
= pDoc
->GetFormatTable();
675 pNumberFormatter
->IsNumberFormat(rValue
.GetText(), nIndex
, nVal
);
677 // color scale does not have the automatic entry
678 sal_Int32 nPos
= rType
.GetSelectEntryPos();
682 pEntry
->SetType(static_cast<ScColorScaleEntryType
>(nPos
));
685 case COLORSCALE_AUTO
:
689 case COLORSCALE_PERCENTILE
:
690 case COLORSCALE_VALUE
:
691 case COLORSCALE_PERCENT
:
692 pEntry
->SetValue(nVal
);
694 case COLORSCALE_FORMULA
:
695 pEntry
->SetFormula(rValue
.GetText(), pDoc
, rPos
);
702 ScColorScaleEntry
* createColorScaleEntry( const ListBox
& rType
, const ColorListBox
& rColor
, const Edit
& rValue
, ScDocument
* pDoc
, const ScAddress
& rPos
)
704 ScColorScaleEntry
* pEntry
= new ScColorScaleEntry();
706 SetColorScaleEntry( pEntry
, rType
, rValue
, pDoc
, rPos
, false );
707 Color aColor
= rColor
.GetSelectEntryColor();
708 pEntry
->SetColor(aColor
);
714 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 maLbColMax( this, ScResId( LB_COL_MAX
) )
724 // remove the automatic entry from color scales
725 maLbEntryTypeMin
.RemoveEntry(0);
726 maLbEntryTypeMax
.RemoveEntry(0);
728 maLbType
.SelectEntryPos(0);
729 maLbColorFormat
.SelectEntryPos(0);
733 ScColorScaleFormat::const_iterator itr
= pFormat
->begin();
734 SetColorScaleEntryTypes(*itr
, maLbEntryTypeMin
, maEdMin
, maLbColMin
, pDoc
);
736 SetColorScaleEntryTypes(*itr
, maLbEntryTypeMax
, maEdMax
, maLbColMax
, pDoc
);
740 maLbEntryTypeMin
.SelectEntryPos(0);
741 maLbEntryTypeMax
.SelectEntryPos(1);
745 maLbColorFormat
.SetSelectHdl( LINK( pParent
, ScCondFormatList
, ColFormatTypeHdl
) );
747 EntryTypeHdl(&maLbEntryTypeMin
);
748 EntryTypeHdl(&maLbEntryTypeMax
);
751 void ScColorScale2FrmtEntry::Init()
753 maLbEntryTypeMin
.SetSelectHdl( LINK( this, ScColorScale2FrmtEntry
, EntryTypeHdl
) );
754 maLbEntryTypeMax
.SetSelectHdl( LINK( this, ScColorScale2FrmtEntry
, EntryTypeHdl
) );
756 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
757 XColorListRef pColorTable
;
759 DBG_ASSERT( pDocSh
, "DocShell not found!" );
763 const SfxPoolItem
* pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
765 pColorTable
= ( (SvxColorListItem
*)pItem
)->GetColorList();
767 if ( pColorTable
.is() )
769 // filling the line color box
770 maLbColMin
.SetUpdateMode( false );
771 maLbColMax
.SetUpdateMode( false );
773 for ( long i
= 0; i
< pColorTable
->Count(); ++i
)
775 XColorEntry
* pEntry
= pColorTable
->GetColor(i
);
776 maLbColMin
.InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
777 maLbColMax
.InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
779 if(pEntry
->GetColor() == Color(COL_LIGHTRED
))
780 maLbColMin
.SelectEntryPos(i
);
781 if(pEntry
->GetColor() == Color(COL_LIGHTBLUE
))
782 maLbColMax
.SelectEntryPos(i
);
784 maLbColMin
.SetUpdateMode( sal_True
);
785 maLbColMax
.SetUpdateMode( sal_True
);
789 ScFormatEntry
* ScColorScale2FrmtEntry::createColorscaleEntry() const
791 ScColorScaleFormat
* pColorScale
= new ScColorScaleFormat(mpDoc
);
792 pColorScale
->AddEntry(createColorScaleEntry(maLbEntryTypeMin
, maLbColMin
, maEdMin
, mpDoc
, maPos
));
793 pColorScale
->AddEntry(createColorScaleEntry(maLbEntryTypeMax
, maLbColMax
, maEdMax
, mpDoc
, maPos
));
797 OUString
ScColorScale2FrmtEntry::GetExpressionString()
799 return ScCondFormatHelper::GetExpression( COLORSCALE
, 0 );
802 ScFormatEntry
* ScColorScale2FrmtEntry::GetEntry() const
804 return createColorscaleEntry();
807 void ScColorScale2FrmtEntry::SetActive()
809 maLbColorFormat
.Show();
811 maLbEntryTypeMin
.Show();
812 maLbEntryTypeMax
.Show();
823 void ScColorScale2FrmtEntry::SetInactive()
825 maLbColorFormat
.Hide();
827 maLbEntryTypeMin
.Hide();
828 maLbEntryTypeMax
.Hide();
839 IMPL_LINK( ScColorScale2FrmtEntry
, EntryTypeHdl
, ListBox
*, pBox
)
841 bool bEnableEdit
= true;
842 sal_Int32 nPos
= pBox
->GetSelectEntryPos();
849 if(pBox
== &maLbEntryTypeMin
)
851 else if(pBox
== &maLbEntryTypeMax
)
862 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 maLbColMax( this, ScResId( LB_COL_MAX
) )
875 // remove the automatic entry from color scales
876 maLbEntryTypeMin
.RemoveEntry(0);
877 maLbEntryTypeMiddle
.RemoveEntry(0);
878 maLbEntryTypeMax
.RemoveEntry(0);
879 maLbColorFormat
.SelectEntryPos(1);
882 maLbType
.SelectEntryPos(0);
885 ScColorScaleFormat::const_iterator itr
= pFormat
->begin();
886 SetColorScaleEntryTypes(*itr
, maLbEntryTypeMin
, maEdMin
, maLbColMin
, pDoc
);
887 assert(pFormat
->size() == 3);
889 SetColorScaleEntryTypes(*itr
, maLbEntryTypeMiddle
, maEdMiddle
, maLbColMiddle
, pDoc
);
891 SetColorScaleEntryTypes(*itr
, maLbEntryTypeMax
, maEdMax
, maLbColMax
, pDoc
);
895 maLbColorFormat
.SelectEntryPos(1);
896 maLbEntryTypeMin
.SelectEntryPos(0);
897 maLbEntryTypeMiddle
.SelectEntryPos(2);
898 maLbEntryTypeMax
.SelectEntryPos(1);
899 maEdMiddle
.SetText(OUString::number(50));
903 maLbColorFormat
.SetSelectHdl( LINK( pParent
, ScCondFormatList
, ColFormatTypeHdl
) );
904 EntryTypeHdl(&maLbEntryTypeMin
);
905 EntryTypeHdl(&maLbEntryTypeMiddle
);
906 EntryTypeHdl(&maLbEntryTypeMax
);
909 void ScColorScale3FrmtEntry::Init()
911 maLbEntryTypeMin
.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry
, EntryTypeHdl
) );
912 maLbEntryTypeMax
.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry
, EntryTypeHdl
) );
913 maLbEntryTypeMiddle
.SetSelectHdl( LINK( this, ScColorScale3FrmtEntry
, EntryTypeHdl
) );
915 SfxObjectShell
* pDocSh
= SfxObjectShell::Current();
916 XColorListRef pColorTable
;
918 DBG_ASSERT( pDocSh
, "DocShell not found!" );
922 const SfxPoolItem
* pItem
= pDocSh
->GetItem( SID_COLOR_TABLE
);
924 pColorTable
= ( (SvxColorListItem
*)pItem
)->GetColorList();
926 if ( pColorTable
.is() )
928 // filling the line color box
929 maLbColMin
.SetUpdateMode( false );
930 maLbColMiddle
.SetUpdateMode( false );
931 maLbColMax
.SetUpdateMode( false );
933 for ( long i
= 0; i
< pColorTable
->Count(); ++i
)
935 XColorEntry
* pEntry
= pColorTable
->GetColor(i
);
936 maLbColMin
.InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
937 maLbColMiddle
.InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
938 maLbColMax
.InsertEntry( pEntry
->GetColor(), pEntry
->GetName() );
940 if(pEntry
->GetColor() == Color(COL_LIGHTRED
))
941 maLbColMin
.SelectEntryPos(i
);
942 if(pEntry
->GetColor() == Color(COL_GREEN
))
943 maLbColMiddle
.SelectEntryPos(i
);
944 if(pEntry
->GetColor() == Color(COL_LIGHTBLUE
))
945 maLbColMax
.SelectEntryPos(i
);
947 maLbColMin
.SetUpdateMode( sal_True
);
948 maLbColMiddle
.SetUpdateMode( sal_True
);
949 maLbColMax
.SetUpdateMode( sal_True
);
953 ScFormatEntry
* ScColorScale3FrmtEntry::createColorscaleEntry() const
955 ScColorScaleFormat
* pColorScale
= new ScColorScaleFormat(mpDoc
);
956 pColorScale
->AddEntry(createColorScaleEntry(maLbEntryTypeMin
, maLbColMin
, maEdMin
, mpDoc
, maPos
));
957 if(maLbColorFormat
.GetSelectEntryPos() == 1)
958 pColorScale
->AddEntry(createColorScaleEntry(maLbEntryTypeMiddle
, maLbColMiddle
, maEdMiddle
, mpDoc
, maPos
));
959 pColorScale
->AddEntry(createColorScaleEntry(maLbEntryTypeMax
, maLbColMax
, maEdMax
, mpDoc
, maPos
));
963 OUString
ScColorScale3FrmtEntry::GetExpressionString()
965 return ScCondFormatHelper::GetExpression( COLORSCALE
, 0 );
968 ScFormatEntry
* ScColorScale3FrmtEntry::GetEntry() const
970 return createColorscaleEntry();
973 void ScColorScale3FrmtEntry::SetActive()
975 maLbColorFormat
.Show();
976 maLbEntryTypeMin
.Show();
977 maLbEntryTypeMiddle
.Show();
978 maLbEntryTypeMax
.Show();
985 maLbColMiddle
.Show();
991 void ScColorScale3FrmtEntry::SetInactive()
993 maLbColorFormat
.Hide();
995 maLbEntryTypeMin
.Hide();
996 maLbEntryTypeMiddle
.Hide();
997 maLbEntryTypeMax
.Hide();
1004 maLbColMiddle
.Hide();
1010 IMPL_LINK( ScColorScale3FrmtEntry
, EntryTypeHdl
, ListBox
*, pBox
)
1012 bool bEnableEdit
= true;
1013 sal_Int32 nPos
= pBox
->GetSelectEntryPos();
1016 bEnableEdit
= false;
1020 if(pBox
== &maLbEntryTypeMin
)
1022 else if(pBox
== &maLbEntryTypeMiddle
)
1024 else if(pBox
== &maLbEntryTypeMax
)
1035 IMPL_LINK_NOARG( ScConditionFrmtEntry
, ConditionTypeSelectHdl
)
1037 sal_Int32 nSelectPos
= maLbCondType
.GetSelectEntryPos();
1038 if(nSelectPos
== 6 || nSelectPos
== 7)
1043 else if(nSelectPos
== 8 || nSelectPos
== 9)
1048 else if(nSelectPos
<= 5 || (nSelectPos
>= 10 && nSelectPos
<= 13)
1049 || nSelectPos
>= 18)
1067 void SetDataBarEntryTypes( const ScColorScaleEntry
& rEntry
, ListBox
& rLbType
, Edit
& rEdit
, ScDocument
* pDoc
)
1069 rLbType
.SelectEntryPos(rEntry
.GetType());
1070 switch(rEntry
.GetType())
1072 case COLORSCALE_AUTO
:
1073 case COLORSCALE_MIN
:
1074 case COLORSCALE_MAX
:
1076 case COLORSCALE_VALUE
:
1077 case COLORSCALE_PERCENT
:
1078 case COLORSCALE_PERCENTILE
:
1080 double nVal
= rEntry
.GetValue();
1081 SvNumberFormatter
* pNumberFormatter
= pDoc
->GetFormatTable();
1083 pNumberFormatter
->GetInputLineString(nVal
, 0, aText
);
1084 rEdit
.SetText(aText
);
1087 case COLORSCALE_FORMULA
:
1088 rEdit
.SetText(rEntry
.GetFormula(formula::FormulaGrammar::GRAM_DEFAULT
));
1095 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 maBtOptions( this, ScResId( BTN_OPTIONS
) )
1104 maLbColorFormat
.SelectEntryPos(2);
1105 maLbType
.SelectEntryPos(0);
1108 mpDataBarData
.reset(new ScDataBarFormatData(*pFormat
->GetDataBarData()));
1109 SetDataBarEntryTypes(*mpDataBarData
->mpLowerLimit
, maLbDataBarMinType
, maEdDataBarMin
, pDoc
);
1110 SetDataBarEntryTypes(*mpDataBarData
->mpUpperLimit
, maLbDataBarMaxType
, maEdDataBarMax
, pDoc
);
1111 DataBarTypeSelectHdl(NULL
);
1115 maLbDataBarMinType
.SelectEntryPos(0);
1116 maLbDataBarMaxType
.SelectEntryPos(0);
1117 DataBarTypeSelectHdl(NULL
);
1121 maLbColorFormat
.SetSelectHdl( LINK( pParent
, ScCondFormatList
, ColFormatTypeHdl
) );
1126 ScFormatEntry
* ScDataBarFrmtEntry::GetEntry() const
1128 return createDatabarEntry();
1131 void ScDataBarFrmtEntry::Init()
1133 maLbDataBarMinType
.SetSelectHdl( LINK( this, ScDataBarFrmtEntry
, DataBarTypeSelectHdl
) );
1134 maLbDataBarMaxType
.SetSelectHdl( LINK( this, ScDataBarFrmtEntry
, DataBarTypeSelectHdl
) );
1136 maBtOptions
.SetClickHdl( LINK( this, ScDataBarFrmtEntry
, OptionBtnHdl
) );
1140 mpDataBarData
.reset(new ScDataBarFormatData());
1141 mpDataBarData
->mpUpperLimit
.reset(new ScColorScaleEntry());
1142 mpDataBarData
->mpLowerLimit
.reset(new ScColorScaleEntry());
1143 mpDataBarData
->mpLowerLimit
->SetType(COLORSCALE_AUTO
);
1144 mpDataBarData
->mpUpperLimit
->SetType(COLORSCALE_AUTO
);
1145 mpDataBarData
->maPositiveColor
= COL_LIGHTBLUE
;
1149 ScFormatEntry
* ScDataBarFrmtEntry::createDatabarEntry() const
1151 SetColorScaleEntry(mpDataBarData
->mpLowerLimit
.get(), maLbDataBarMinType
, maEdDataBarMin
, mpDoc
, maPos
, true);
1152 SetColorScaleEntry(mpDataBarData
->mpUpperLimit
.get(), maLbDataBarMaxType
, maEdDataBarMax
, mpDoc
, maPos
, true);
1153 ScDataBarFormat
* pDataBar
= new ScDataBarFormat(mpDoc
);
1154 pDataBar
->SetDataBarData(new ScDataBarFormatData(*mpDataBarData
.get()));
1158 OUString
ScDataBarFrmtEntry::GetExpressionString()
1160 return ScCondFormatHelper::GetExpression( DATABAR
, 0 );
1163 void ScDataBarFrmtEntry::SetActive()
1165 maLbColorFormat
.Show();
1167 maLbDataBarMinType
.Show();
1168 maLbDataBarMaxType
.Show();
1169 maEdDataBarMin
.Show();
1170 maEdDataBarMax
.Show();
1176 void ScDataBarFrmtEntry::SetInactive()
1178 maLbColorFormat
.Hide();
1180 maLbDataBarMinType
.Hide();
1181 maLbDataBarMaxType
.Hide();
1182 maEdDataBarMin
.Hide();
1183 maEdDataBarMax
.Hide();
1189 IMPL_LINK_NOARG( ScDataBarFrmtEntry
, DataBarTypeSelectHdl
)
1191 sal_Int32 nSelectPos
= maLbDataBarMinType
.GetSelectEntryPos();
1192 if(nSelectPos
<= COLORSCALE_MAX
)
1193 maEdDataBarMin
.Disable();
1195 maEdDataBarMin
.Enable();
1197 nSelectPos
= maLbDataBarMaxType
.GetSelectEntryPos();
1198 if(nSelectPos
<= COLORSCALE_MAX
)
1199 maEdDataBarMax
.Disable();
1201 maEdDataBarMax
.Enable();
1206 IMPL_LINK_NOARG( ScDataBarFrmtEntry
, OptionBtnHdl
)
1208 SetColorScaleEntry(mpDataBarData
->mpLowerLimit
.get(), maLbDataBarMinType
, maEdDataBarMin
, mpDoc
, maPos
, true);
1209 SetColorScaleEntry(mpDataBarData
->mpUpperLimit
.get(), maLbDataBarMaxType
, maEdDataBarMax
, mpDoc
, maPos
, true);
1210 ScDataBarSettingsDlg
* pDlg
= new ScDataBarSettingsDlg(this, *mpDataBarData
, mpDoc
, maPos
);
1211 if( pDlg
->Execute() == RET_OK
)
1213 mpDataBarData
.reset(pDlg
->GetData());
1214 SetDataBarEntryTypes(*mpDataBarData
->mpLowerLimit
, maLbDataBarMinType
, maEdDataBarMin
, mpDoc
);
1215 SetDataBarEntryTypes(*mpDataBarData
->mpUpperLimit
, maLbDataBarMaxType
, maEdDataBarMax
, mpDoc
);
1216 DataBarTypeSelectHdl(NULL
);
1221 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 mbIsInStyleCreate(false)
1232 StartListening(*pDoc
->GetStyleSheetPool(), sal_True
);
1236 sal_Int32 nPos
= static_cast<sal_Int32
>(pFormat
->GetDateType());
1237 maLbDateEntry
.SelectEntryPos(nPos
);
1239 OUString aStyleName
= pFormat
->GetStyleName();
1240 maLbStyle
.SelectEntry(aStyleName
);
1243 StyleSelectHdl(NULL
);
1246 void ScDateFrmtEntry::Init()
1248 maLbDateEntry
.SelectEntryPos(0);
1249 maLbType
.SelectEntryPos(3);
1251 FillStyleListBox( mpDoc
, maLbStyle
);
1252 maLbStyle
.SetSelectHdl( LINK( this, ScDateFrmtEntry
, StyleSelectHdl
) );
1253 maLbStyle
.SelectEntryPos(1);
1256 void ScDateFrmtEntry::SetActive()
1258 maLbDateEntry
.Show();
1266 void ScDateFrmtEntry::SetInactive()
1268 maLbDateEntry
.Hide();
1276 void ScDateFrmtEntry::Notify( SfxBroadcaster
&, const SfxHint
& rHint
)
1278 SfxStyleSheetHint
* pHint
= PTR_CAST(SfxStyleSheetHint
, &rHint
);
1282 sal_uInt16 nHint
= pHint
->GetHint();
1283 if(nHint
== SFX_STYLESHEET_MODIFIED
)
1285 if(!mbIsInStyleCreate
)
1286 UpdateStyleList(maLbStyle
, mpDoc
);
1290 ScFormatEntry
* ScDateFrmtEntry::GetEntry() const
1292 ScCondDateFormatEntry
* pNewEntry
= new ScCondDateFormatEntry(mpDoc
);
1293 condformat::ScCondFormatDateType eType
= static_cast<condformat::ScCondFormatDateType
>(maLbDateEntry
.GetSelectEntryPos());
1294 pNewEntry
->SetDateType(eType
);
1295 pNewEntry
->SetStyleName(maLbStyle
.GetSelectEntry());
1299 OUString
ScDateFrmtEntry::GetExpressionString()
1301 return ScCondFormatHelper::GetExpression(DATE
, 0);
1304 IMPL_LINK_NOARG( ScDateFrmtEntry
, StyleSelectHdl
)
1306 mbIsInStyleCreate
= true;
1307 StyleSelect( maLbStyle
, mpDoc
, maWdPreview
);
1308 mbIsInStyleCreate
= false;
1313 class ScIconSetFrmtDataEntry
: public Control
1316 FixedImage maImgIcon
;
1317 FixedText maFtEntry
;
1319 ListBox maLbEntryType
;
1322 ScIconSetFrmtDataEntry( Window
* pParent
, ScIconSetType eType
, ScDocument
* pDoc
,
1323 sal_Int32 i
, const ScColorScaleEntry
* pEntry
= NULL
);
1325 ScColorScaleEntry
* CreateEntry(ScDocument
* pDoc
, const ScAddress
& rPos
) const;
1327 void SetFirstEntry();
1330 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 maLbEntryType( this, ScResId( LB_ICON_SET_ENTRY_TYPE
) )
1337 maImgIcon
.SetImage(Image(ScIconSetFormat::getBitmap(eType
, i
)));
1340 switch(pEntry
->GetType())
1342 case COLORSCALE_VALUE
:
1343 maLbEntryType
.SelectEntryPos(0);
1344 maEdEntry
.SetText(convertNumberToString(pEntry
->GetValue(), pDoc
));
1346 case COLORSCALE_PERCENTILE
:
1347 maLbEntryType
.SelectEntryPos(2);
1348 maEdEntry
.SetText(convertNumberToString(pEntry
->GetValue(), pDoc
));
1350 case COLORSCALE_PERCENT
:
1351 maLbEntryType
.SelectEntryPos(1);
1352 maEdEntry
.SetText(convertNumberToString(pEntry
->GetValue(), pDoc
));
1354 case COLORSCALE_FORMULA
:
1355 maLbEntryType
.SelectEntryPos(3);
1356 maEdEntry
.SetText(pEntry
->GetFormula(formula::FormulaGrammar::GRAM_DEFAULT
));
1364 maLbEntryType
.SelectEntryPos(1);
1369 ScColorScaleEntry
* ScIconSetFrmtDataEntry::CreateEntry(ScDocument
* pDoc
, const ScAddress
& rPos
) const
1371 sal_Int32 nPos
= maLbEntryType
.GetSelectEntryPos();
1372 OUString aText
= maEdEntry
.GetText();
1373 ScColorScaleEntry
* pEntry
= new ScColorScaleEntry();
1375 sal_uInt32 nIndex
= 0;
1377 SvNumberFormatter
* pNumberFormatter
= pDoc
->GetFormatTable();
1378 pNumberFormatter
->IsNumberFormat(aText
, nIndex
, nVal
);
1379 pEntry
->SetValue(nVal
);
1384 pEntry
->SetType(COLORSCALE_VALUE
);
1387 pEntry
->SetType(COLORSCALE_PERCENT
);
1390 pEntry
->SetType(COLORSCALE_PERCENTILE
);
1393 pEntry
->SetType(COLORSCALE_FORMULA
);
1394 pEntry
->SetFormula(aText
, pDoc
, rPos
, pDoc
->GetGrammar());
1403 void ScIconSetFrmtDataEntry::SetFirstEntry()
1406 maLbEntryType
.Hide();
1408 maEdEntry
.SetText(OUString("0"));
1409 maLbEntryType
.SelectEntryPos(1);
1412 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 maLbIconSetType( this, ScResId( LB_ICONSET_TYPE
) )
1419 maLbColorFormat
.SetSelectHdl( LINK( pParent
, ScCondFormatList
, ColFormatTypeHdl
) );
1423 const ScIconSetFormatData
* pIconSetFormatData
= pFormat
->GetIconSetData();
1424 ScIconSetType eType
= pIconSetFormatData
->eIconSetType
;
1425 sal_Int32 nType
= static_cast<sal_Int32
>(eType
);
1426 maLbIconSetType
.SelectEntryPos(nType
);
1428 for(size_t i
= 0, n
= pIconSetFormatData
->maEntries
.size();
1431 maEntries
.push_back( new ScIconSetFrmtDataEntry( this, eType
, pDoc
, i
, &pIconSetFormatData
->maEntries
[i
] ) );
1432 Point aPos
= maEntries
[0].GetPosPixel();
1433 aPos
.Y() += maEntries
[0].GetSizePixel().Height() * i
* 1.2;
1434 maEntries
[i
].SetPosPixel( aPos
);
1436 maEntries
.begin()->SetFirstEntry();
1439 IconSetTypeHdl(NULL
);
1442 void ScIconSetFrmtEntry::Init()
1444 maLbColorFormat
.SelectEntryPos(3);
1445 maLbType
.SelectEntryPos(0);
1446 maLbIconSetType
.SelectEntryPos(0);
1448 maLbIconSetType
.SetSelectHdl( LINK( this, ScIconSetFrmtEntry
, IconSetTypeHdl
) );
1451 IMPL_LINK_NOARG( ScIconSetFrmtEntry
, IconSetTypeHdl
)
1453 ScIconSetMap
* pMap
= ScIconSetFormat::getIconSetMap();
1455 sal_Int32 nPos
= maLbIconSetType
.GetSelectEntryPos();
1456 sal_uInt32 nElements
= pMap
[nPos
].nElements
;
1459 for(size_t i
= 0; i
< nElements
; ++i
)
1461 maEntries
.push_back( new ScIconSetFrmtDataEntry( this, static_cast<ScIconSetType
>(nPos
), mpDoc
, i
) );
1462 Point aPos
= maEntries
[0].GetPosPixel();
1463 aPos
.Y() += maEntries
[0].GetSizePixel().Height() * i
* 1.2;
1464 maEntries
[i
].SetPosPixel( aPos
);
1465 maEntries
[i
].Show();
1467 maEntries
.begin()->SetFirstEntry();
1470 static_cast<ScCondFormatList
*>(GetParent())->RecalcAll();
1475 OUString
ScIconSetFrmtEntry::GetExpressionString()
1477 return ScCondFormatHelper::GetExpression(ICONSET
, 0);
1480 void ScIconSetFrmtEntry::SetActive()
1482 maLbColorFormat
.Show();
1483 maLbIconSetType
.Show();
1484 for(ScIconSetFrmtDataEntriesType::iterator itr
= maEntries
.begin(),
1485 itrEnd
= maEntries
.end(); itr
!= itrEnd
; ++itr
)
1493 void ScIconSetFrmtEntry::SetInactive()
1495 maLbColorFormat
.Hide();
1496 maLbIconSetType
.Hide();
1497 for(ScIconSetFrmtDataEntriesType::iterator itr
= maEntries
.begin(),
1498 itrEnd
= maEntries
.end(); itr
!= itrEnd
; ++itr
)
1506 ScFormatEntry
* ScIconSetFrmtEntry::GetEntry() const
1508 ScIconSetFormat
* pFormat
= new ScIconSetFormat(mpDoc
);
1510 ScIconSetFormatData
* pData
= new ScIconSetFormatData
;
1511 pData
->eIconSetType
= static_cast<ScIconSetType
>(maLbIconSetType
.GetSelectEntryPos());
1512 for(ScIconSetFrmtDataEntriesType::const_iterator itr
= maEntries
.begin(),
1513 itrEnd
= maEntries
.end(); itr
!= itrEnd
; ++itr
)
1515 pData
->maEntries
.push_back(itr
->CreateEntry(mpDoc
, maPos
));
1517 pFormat
->SetIconSetData(pData
);
1522 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */