LibreOffice Module sc (master) 1
condformatdlgentry.cxx
Go to the documentation of this file.
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 <memory>
11#include <condformatdlg.hxx>
13#include <conditio.hxx>
14#include <compiler.hxx>
15#include <colorscale.hxx>
16#include <condformathelper.hxx>
17
18#include <document.hxx>
19
20#include <o3tl/string_view.hxx>
21#include <svl/style.hxx>
22#include <sfx2/dispatch.hxx>
23#include <sfx2/frame.hxx>
24#include <svl/stritem.hxx>
25#include <svl/intitem.hxx>
26#include <svl/numformat.hxx>
27#include <svx/colorbox.hxx>
28#include <vcl/svapp.hxx>
29#include <formula/token.hxx>
31#include <tokenarray.hxx>
32#include <stlpool.hxx>
33#include <tabvwsh.hxx>
35
36#include <colorformat.hxx>
37#include <scresid.hxx>
38#include <globstr.hrc>
39#include <strings.hrc>
40
41#include <set>
42
43// set the widget width to something to override their auto-width calc and
44// force them to take a 1/3 of the available space
45#define CommonWidgetWidth 10
46
48 : mpParent(pParent)
49 , mxBuilder(Application::CreateBuilder(pParent->GetContainer(), (SfxViewShell::Current() && SfxViewShell::Current()->isLOKMobilePhone())?OUString("modules/scalc/ui/conditionalentrymobile.ui"):OUString("modules/scalc/ui/conditionalentry.ui")))
50 , mxBorder(mxBuilder->weld_widget("border"))
51 , mxGrid(mxBuilder->weld_container("grid"))
52 , mxFtCondNr(mxBuilder->weld_label("number"))
53 , mxFtCondition(mxBuilder->weld_label("condition"))
54 , mbActive(false)
55 , maStrCondition(ScResId(SCSTR_CONDITION))
56 , mxLbType(mxBuilder->weld_combo_box("type"))
57 , mpDoc(pDoc)
58 , maPos(rPos)
59{
60 mxLbType->set_size_request(CommonWidgetWidth, -1);
61 mxLbType->connect_changed(LINK(pParent, ScCondFormatList, TypeListHdl));
62 mxGrid->connect_mouse_press(LINK(this, ScCondFrmtEntry, EntrySelectHdl));
63 maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
64
65 Show();
66}
67
69{
70 mpParent->GetContainer()->move(mxBorder.get(), nullptr);
71}
72
73IMPL_LINK_NOARG(ScCondFrmtEntry, EntrySelectHdl, const MouseEvent&, bool)
74{
75 maClickHdl.Call(*this);
76 return false;
77}
78
79void ScCondFrmtEntry::SetIndex(sal_Int32 nIndex)
80{
81 OUString sLabel = maStrCondition + OUString::number(nIndex);
82 mxFtCondNr->set_label(sLabel);
83
84 // tdf#124412: uitest
85 mxFtCondition->set_buildable_name(sLabel.toUtf8());
86}
87
89{
90 mxFtCondition->set_label(OUString());
91 mxFtCondition->hide();
92 mxLbType->show();
93 mbActive = true;
94}
95
97{
98 OUString aCondText = GetExpressionString();
99 mxFtCondition->set_label(aCondText);
100 mxFtCondition->show();
101 mxLbType->hide();
102 mbActive = false;
103}
104
105//condition
106
107namespace {
108
109void FillStyleListBox( const ScDocument* pDoc, weld::ComboBox& rLbStyle )
110{
111 std::set<OUString> aStyleNames;
112 SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SfxStyleFamily::Para );
113 for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
114 {
115 aStyleNames.insert(pStyle->GetName());
116 }
117 for(const auto& rStyleName : aStyleNames)
118 {
119 rLbStyle.append_text(rStyleName);
120 }
121}
122
123}
124
150};
151
153 const ScAddress& rPos, const ScCondFormatEntry* pFormatEntry)
154 : ScCondFrmtEntry(pParent, pDoc, rPos)
155 , mxLbCondType(mxBuilder->weld_combo_box("typeis"))
156 , mxEdVal1(new formula::RefEdit(mxBuilder->weld_entry("val1")))
157 , mxEdVal2(new formula::RefEdit(mxBuilder->weld_entry("val2")))
158 , mxFtVal(mxBuilder->weld_label("valueft"))
159 , mxFtStyle(mxBuilder->weld_label("styleft"))
160 , mxLbStyle(mxBuilder->weld_combo_box("style"))
161 , mxWdPreviewWin(mxBuilder->weld_widget("previewwin"))
162 , mxWdPreview(new weld::CustomWeld(*mxBuilder, "preview", maWdPreview))
163 , mbIsInStyleCreate(false)
164{
165 mxLbCondType->set_size_request(CommonWidgetWidth, -1);
166 mxLbType->set_size_request(CommonWidgetWidth, -1);
167 mxWdPreview->set_size_request(-1, mxLbStyle->get_preferred_size().Height());
168
169 mxLbType->set_active(1);
170
171 Init(pDialogParent);
172
173 StartListening(*pDoc->GetStyleSheetPool(), DuplicateHandling::Prevent);
174
175 if(pFormatEntry)
176 {
177 mxLbStyle->set_active_text(pFormatEntry->GetStyle());
178 StyleSelectHdl(*mxLbStyle);
179 ScConditionMode eMode = pFormatEntry->GetOperation();
180
182
184 {
185 case 0:
186 mxEdVal1->GetWidget()->hide();
187 mxEdVal2->GetWidget()->hide();
188 break;
189 case 1:
190 mxEdVal1->GetWidget()->show();
191 mxEdVal1->SetText(pFormatEntry->GetExpression(maPos, 0));
192 mxEdVal2->GetWidget()->hide();
193 OnEdChanged(*mxEdVal1);
194 break;
195 case 2:
196 mxEdVal1->GetWidget()->show();
197 mxEdVal1->SetText(pFormatEntry->GetExpression(maPos, 0));
198 OnEdChanged(*mxEdVal1);
199 mxEdVal2->GetWidget()->show();
200 mxEdVal2->SetText(pFormatEntry->GetExpression(maPos, 1));
201 OnEdChanged(*mxEdVal2);
202 break;
203 }
204 }
205 else
206 {
207 mxLbCondType->set_active(0);
208 mxEdVal2->GetWidget()->hide();
209 mxLbStyle->set_active(1);
210 }
211}
212
214{
215}
216
218{
219 mxEdVal1->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
220 mxEdVal2->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
221
222 mxEdVal1->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) );
223 mxEdVal2->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) );
224
225 FillStyleListBox( mpDoc, *mxLbStyle );
226 mxLbStyle->connect_changed( LINK( this, ScConditionFrmtEntry, StyleSelectHdl ) );
227
228 mxLbCondType->connect_changed( LINK( this, ScConditionFrmtEntry, ConditionTypeSelectHdl ) );
229}
230
232{
234 OUString aExpr1 = mxEdVal1->GetText();
235 OUString aExpr2;
236 if (GetNumberEditFields(eMode) == 2)
237 {
238 aExpr2 = mxEdVal2->GetText();
239 if (aExpr2.isEmpty())
240 {
241 return nullptr;
242 }
243 }
244
245 ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aExpr1, aExpr2, *mpDoc, maPos, mxLbStyle->get_active_text());
246 return pEntry;
247}
248
249IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, formula::RefEdit&, rRefEdit, void)
250{
251 weld::Entry& rEdit = *rRefEdit.GetWidget();
252 OUString aFormula = rEdit.get_text();
253
254 if( aFormula.isEmpty() )
255 {
256 mxFtVal->set_label(ScResId(STR_ENTER_VALUE));
257 return;
258 }
259
260 ScCompiler aComp( *mpDoc, maPos, mpDoc->GetGrammar() );
261 aComp.SetExtendedErrorDetection( ScCompiler::ExtendedErrorDetection::EXTENDED_ERROR_DETECTION_NAME_BREAK);
262 std::unique_ptr<ScTokenArray> ta(aComp.CompileString(aFormula));
263
264 // Error, warn the user if it is not an unknown name.
265 if (ta->GetCodeError() != FormulaError::NoName && (ta->GetCodeError() != FormulaError::NONE || ta->GetLen() == 0))
266 {
268 mxFtVal->set_label(ScResId(STR_VALID_DEFERROR));
269 return;
270 }
271
272 // Unrecognized name, warn the user; i.e. happens when starting to type and
273 // will go away once a valid name is completed.
274 if (ta->GetCodeError() == FormulaError::NoName)
275 {
277 mxFtVal->set_label(ScResId(STR_UNQUOTED_STRING));
278 return;
279 }
280
281 // Generate RPN to detect further errors.
282 if (ta->GetLen() > 0)
283 aComp.CompileTokenArray();
284 // Error, warn the user.
285 if (ta->GetCodeError() != FormulaError::NONE || (ta->GetCodeLen() == 0))
286 {
288 mxFtVal->set_label(ScResId(STR_VALID_DEFERROR));
289 return;
290 }
291
293 mxFtVal->set_label("");
294}
295
297{
298 mxFtVal->show();
300}
301
303{
304 mxFtVal->hide();
306}
307
309{
310 for ( sal_Int32 i = 0; i < NUM_COND_ENTRIES; ++i )
311 {
312 if (mpEntryToCond[i] == eMode)
313 {
314 return i;
315 }
316 }
317 assert(false); // should never get here
318 return 0;
319}
320
322{
323 assert( 0 <= aEntryPos && aEntryPos < NUM_COND_ENTRIES );
324 return mpEntryToCond[aEntryPos];
325}
326
328{
329 switch(eMode)
330 {
347 return 1;
354 return 0;
357 return 2;
358 default:
359 assert(false); // should never get here
360 return 0;
361 }
362}
363
365{
366 return ScCondFormatHelper::GetExpression(CONDITION, mxLbCondType->get_active(), mxEdVal1->GetText(), mxEdVal2->GetText());
367}
368
370{
371 return createConditionEntry();
372}
373
375{
377 mxLbCondType->show();
379 {
380 case 1:
381 mxEdVal1->GetWidget()->show();
382 break;
383 case 2:
384 mxEdVal1->GetWidget()->show();
385 mxEdVal2->GetWidget()->show();
386 break;
387 }
388 mxFtStyle->show();
389 mxLbStyle->show();
390 mxWdPreviewWin->show();
391
392 Select();
393}
394
396{
397 mxLbCondType->hide();
398 mxEdVal1->GetWidget()->hide();
399 mxEdVal2->GetWidget()->hide();
400 mxFtStyle->hide();
401 mxLbStyle->hide();
402 mxWdPreviewWin->hide();
403
404 Deselect();
405}
406
407namespace {
408
409void UpdateStyleList(weld::ComboBox& rLbStyle, const ScDocument* pDoc)
410{
411 OUString aSelectedStyle = rLbStyle.get_active_text();
412 for (sal_Int32 i = rLbStyle.get_count(); i > 1; --i)
413 rLbStyle.remove(i - 1);
414 FillStyleListBox(pDoc, rLbStyle);
415 rLbStyle.set_active_text(aSelectedStyle);
416}
417
418}
419
421{
422 if(rHint.GetId() == SfxHintId::StyleSheetModified)
423 {
425 UpdateStyleList(*mxLbStyle, mpDoc);
426 }
427}
428
429namespace {
430
431void StyleSelect(weld::Window* pDialogParent, weld::ComboBox& rLbStyle, const ScDocument* pDoc, SvxFontPrevWindow& rWdPreview)
432{
433 if (rLbStyle.get_active() == 0)
434 {
435 // call new style dialog
436 SfxUInt16Item aFamilyItem( SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para) );
437 SfxStringItem aRefItem( SID_STYLE_REFERENCE, ScResId(STR_STYLENAME_STANDARD) );
438 css::uno::Any aAny(pDialogParent->GetXWindow());
439 SfxUnoAnyItem aDialogParent( SID_DIALOG_PARENT, aAny );
440
441 // unlock the dispatcher so SID_STYLE_NEW can be executed
442 // (SetDispatcherLock would affect all Calc documents)
444 SfxDispatcher* pDisp = pViewShell->GetDispatcher();
445 bool bLocked = pDisp->IsLocked();
446 if (bLocked)
447 pDisp->Lock(false);
448
449 // Execute the "new style" slot, complete with undo and all necessary updates.
450 // The return value (SfxUInt16Item) is ignored, look for new styles instead.
451 pDisp->ExecuteList(SID_STYLE_NEW,
452 SfxCallMode::SYNCHRON | SfxCallMode::RECORD,
453 { &aFamilyItem, &aRefItem }, { &aDialogParent });
454
455 if (bLocked)
456 pDisp->Lock(true);
457
458 // Find the new style and add it into the style list boxes
459 SfxStyleSheetIterator aStyleIter( pDoc->GetStyleSheetPool(), SfxStyleFamily::Para );
460 bool bFound = false;
461 for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; pStyle = aStyleIter.Next() )
462 {
463 const OUString& aName = pStyle->GetName();
464 if (rLbStyle.find_text(aName) == -1) // all lists contain the same entries
465 {
466 for( sal_Int32 i = 1, n = rLbStyle.get_count(); i <= n && !bFound; ++i)
467 {
468 OUString aStyleName = ScGlobal::getCharClass().uppercase(rLbStyle.get_text(i));
469 if( i == n )
470 {
471 rLbStyle.append_text(aName);
472 rLbStyle.set_active_text(aName);
473 bFound = true;
474 }
475 else if( aStyleName > ScGlobal::getCharClass().uppercase(aName) )
476 {
477 rLbStyle.insert_text(i, aName);
478 rLbStyle.set_active_text(aName);
479 bFound = true;
480 }
481 }
482 }
483 }
484 }
485
486 OUString aStyleName = rLbStyle.get_active_text();
487 SfxStyleSheetBase* pStyleSheet = pDoc->GetStyleSheetPool()->Find( aStyleName, SfxStyleFamily::Para );
488 if(pStyleSheet)
489 {
490 const SfxItemSet& rSet = pStyleSheet->GetItemSet();
491 rWdPreview.SetFromItemSet(rSet, false);
492 }
493}
494
495}
496
498{
499 mbIsInStyleCreate = true;
500 StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mpDoc, maWdPreview);
501 mbIsInStyleCreate = false;
502}
503
504// formula
505
507 : ScCondFrmtEntry(pParent, pDoc, rPos)
508 , mxFtStyle(mxBuilder->weld_label("styleft"))
509 , mxLbStyle(mxBuilder->weld_combo_box("style"))
510 , mxWdPreviewWin(mxBuilder->weld_widget("previewwin"))
511 , mxWdPreview(new weld::CustomWeld(*mxBuilder, "preview", maWdPreview))
512 , mxEdFormula(new formula::RefEdit(mxBuilder->weld_entry("formula")))
513{
514 mxLbType->set_size_request(CommonWidgetWidth, -1);
515 mxWdPreview->set_size_request(-1, mxLbStyle->get_preferred_size().Height());
516
517 Init(pDialogParent);
518
519 mxLbType->set_active(2);
520
521 if(pFormat)
522 {
523 mxEdFormula->SetText(pFormat->GetExpression(rPos, 0, 0, pDoc->GetGrammar()));
524 mxLbStyle->set_active_text(pFormat->GetStyle());
525 }
526 else
527 {
528 mxLbStyle->set_active(1);
529 }
530
531 StyleSelectHdl(*mxLbStyle);
532}
533
535{
536}
537
539{
540 mxEdFormula->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) );
541
542 FillStyleListBox( mpDoc, *mxLbStyle );
543 mxLbStyle->connect_changed( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) );
544}
545
547{
548 StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mpDoc, maWdPreview);
549}
550
552{
553 OUString aFormula = mxEdFormula->GetText();
554 if(aFormula.isEmpty())
555 return nullptr;
556
557 ScFormatEntry* pEntry = new ScCondFormatEntry(ScConditionMode::Direct, aFormula, OUString(), *mpDoc, maPos, mxLbStyle->get_active_text());
558 return pEntry;
559}
560
562{
563 return createFormulaEntry();
564}
565
567{
568 return ScCondFormatHelper::GetExpression(FORMULA, 0, mxEdFormula->GetText());
569}
570
572{
573 mxWdPreviewWin->show();
574 mxFtStyle->show();
575 mxLbStyle->show();
576 mxEdFormula->GetWidget()->show();
577
578 Select();
579}
580
582{
583 mxWdPreviewWin->hide();
584 mxFtStyle->hide();
585 mxLbStyle->hide();
586 mxEdFormula->GetWidget()->hide();
587
588 Deselect();
589}
590
591//color scale
592
593namespace {
594
595OUString convertNumberToString(double nVal, const ScDocument* pDoc)
596{
597 SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
598 OUString aText;
599 pNumberFormatter->GetInputLineString(nVal, 0, aText);
600 return aText;
601}
602
603const struct
604{
606 const char* sId;
607} TypeIdMap[] = {
608 { COLORSCALE_AUTO, "auto" },
609 { COLORSCALE_MIN, "min" },
610 { COLORSCALE_MAX, "max" },
611 { COLORSCALE_PERCENTILE, "percentil" },
612 { COLORSCALE_VALUE, "value" },
613 { COLORSCALE_PERCENT, "percent" },
614 { COLORSCALE_FORMULA, "formula" },
615};
616
617ScColorScaleEntryType getTypeForId(std::u16string_view sId)
618{
619 for (auto& r : TypeIdMap)
620 {
621 if (o3tl::equalsAscii(sId, r.sId))
622 return r.eType;
623 }
624 assert(false); // The id is not in TypeIdMap - something not in sync?
625 return COLORSCALE_AUTO; // invalid id - use default
626}
627
628// Item ids are imported from .ui into OUString* and are referenced by entry data.
629// See commit 83cefb5ceb4428d61a5b9fae80d1e673131e9bfe
630
631ScColorScaleEntryType getSelectedType(const weld::ComboBox& rListBox)
632{
633 return getTypeForId(rListBox.get_active_id());
634}
635
636sal_Int32 getEntryPos(const weld::ComboBox& rListBox, ScColorScaleEntryType eType)
637{
638 const sal_Int32 nSize = rListBox.get_count();
639 for (sal_Int32 i = 0; i < nSize; ++i)
640 {
641 if (getTypeForId(rListBox.get_id(i)) == eType)
642 return i;
643 }
644 return -1;
645}
646
647void selectType(weld::ComboBox& rListBox, ScColorScaleEntryType eType)
648{
649 const sal_Int32 nPos = getEntryPos(rListBox, eType);
650 if (nPos >= 0)
651 rListBox.set_active(nPos);
652}
653
654void removeType(weld::ComboBox& rListBox, ScColorScaleEntryType eType)
655{
656 const sal_Int32 nPos = getEntryPos(rListBox, eType);
657 if (nPos >= 0)
658 rListBox.remove(nPos);
659}
660
661void SetColorScaleEntryTypes( const ScColorScaleEntry& rEntry, weld::ComboBox& rLbType, weld::Entry& rEdit, ColorListBox& rLbCol, const ScDocument* pDoc )
662{
663 // entry Automatic is not available for color scales
664 assert(rEntry.GetType() > COLORSCALE_AUTO);
665 selectType(rLbType, rEntry.GetType());
666 switch(rEntry.GetType())
667 {
668 case COLORSCALE_MIN:
669 case COLORSCALE_MAX:
670 break;
672 case COLORSCALE_VALUE:
674 {
675 double nVal = rEntry.GetValue();
676 rEdit.set_text(convertNumberToString(nVal, pDoc));
677 }
678 break;
681 break;
682 case COLORSCALE_AUTO:
683 abort();
684 break;
685 }
686 rLbCol.SelectEntry(rEntry.GetColor());
687}
688
689void SetColorScaleEntry(ScColorScaleEntry* pEntry, const weld::ComboBox& rType, const weld::Entry& rValue,
690 ScDocument* pDoc, const ScAddress& rPos)
691{
692 ScColorScaleEntryType eType = getSelectedType(rType);
693
694 pEntry->SetType(eType);
695 switch (eType)
696 {
697 case COLORSCALE_AUTO:
698 case COLORSCALE_MIN:
699 case COLORSCALE_MAX:
700 break;
702 case COLORSCALE_VALUE:
704 {
705 sal_uInt32 nIndex = 0;
706 double nVal = 0;
707 SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
708 (void)pNumberFormatter->IsNumberFormat(rValue.get_text(), nIndex, nVal);
709 pEntry->SetValue(nVal);
710 }
711 break;
713 pEntry->SetFormula(rValue.get_text(), *pDoc, rPos);
714 break;
715 default:
716 break;
717 }
718}
719
720ScColorScaleEntry* createColorScaleEntry( const weld::ComboBox& rType, const ColorListBox& rColor, const weld::Entry& rValue, ScDocument* pDoc, const ScAddress& rPos )
721{
722 ScColorScaleEntry* pEntry = new ScColorScaleEntry();
723
724 SetColorScaleEntry(pEntry, rType, rValue, pDoc, rPos);
725 Color aColor = rColor.GetSelectEntryColor();
726 pEntry->SetColor(aColor);
727 return pEntry;
728}
729
730}
731
733 : ScCondFrmtEntry(pParent, pDoc, rPos)
734 , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
735 , mxLbEntryTypeMin(mxBuilder->weld_combo_box("colscalemin"))
736 , mxLbEntryTypeMax(mxBuilder->weld_combo_box("colscalemax"))
737 , mxEdMin(mxBuilder->weld_entry("edcolscalemin"))
738 , mxEdMax(mxBuilder->weld_entry("edcolscalemax"))
739 , mxLbColMin(new ColorListBox(mxBuilder->weld_menu_button("lbcolmin"), [this]{ return mpParent->GetFrameWeld(); }))
740 , mxLbColMax(new ColorListBox(mxBuilder->weld_menu_button("lbcolmax"), [this]{ return mpParent->GetFrameWeld(); }))
741 , mxFtMin(mxBuilder->weld_label("Label_minimum"))
742 , mxFtMax(mxBuilder->weld_label("Label_maximum"))
743{
744 mxLbColorFormat->set_size_request(CommonWidgetWidth, -1);
745 mxLbEntryTypeMin->set_size_request(CommonWidgetWidth, -1);
746 mxLbEntryTypeMax->set_size_request(CommonWidgetWidth, -1);
747 mxLbColMin->get_widget().set_size_request(CommonWidgetWidth, -1);
748 mxLbColMax->get_widget().set_size_request(CommonWidgetWidth, -1);
749
750 mxFtMin->show();
751 mxFtMax->show();
752
753 // remove the automatic entry from color scales
754 removeType(*mxLbEntryTypeMin, COLORSCALE_AUTO);
755 removeType(*mxLbEntryTypeMax, COLORSCALE_AUTO);
756 // "min" selector doesn't need "max" entry, and vice versa
757 removeType(*mxLbEntryTypeMin, COLORSCALE_MAX);
758 removeType(*mxLbEntryTypeMax, COLORSCALE_MIN);
759
760 mxLbType->set_active(0);
761 mxLbColorFormat->set_active(0);
762 Init();
763 if(pFormat)
764 {
765 ScColorScaleEntries::const_iterator itr = pFormat->begin();
766 SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMin, *mxEdMin, *mxLbColMin, pDoc);
767 ++itr;
768 SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMax, *mxEdMax, *mxLbColMax, pDoc);
769 }
770 else
771 {
772 selectType(*mxLbEntryTypeMin, COLORSCALE_MIN);
773 selectType(*mxLbEntryTypeMax, COLORSCALE_MAX);
774 }
775
776 mxLbColorFormat->connect_changed( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
777
778 EntryTypeHdl(*mxLbEntryTypeMin);
779 EntryTypeHdl(*mxLbEntryTypeMax);
780}
781
783{
784}
785
787{
788 mxLbEntryTypeMin->connect_changed( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
789 mxLbEntryTypeMax->connect_changed( LINK( this, ScColorScale2FrmtEntry, EntryTypeHdl ) );
790 mxLbColMin->SelectEntry(Color(0xffff6d)); // Light Yellow 2
791 mxLbColMax->SelectEntry(Color(0x77bc65)); // Light Green 2
792}
793
795{
796 ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
797 pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMin, *mxLbColMin, *mxEdMin, mpDoc, maPos));
798 pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMax, *mxLbColMax, *mxEdMax, mpDoc, maPos));
799 return pColorScale;
800}
801
803{
805}
806
808{
809 return createColorscaleEntry();
810}
811
813{
814 mxLbColorFormat->show();
815
816 mxLbEntryTypeMin->show();
817 mxLbEntryTypeMax->show();
818
819 mxEdMin->show();
820 mxEdMax->show();
821
822 mxLbColMin->show();
823 mxLbColMax->show();
824
825 Select();
826}
827
829{
830 mxLbColorFormat->hide();
831
832 mxLbEntryTypeMin->hide();
833 mxLbEntryTypeMax->hide();
834
835 mxEdMin->hide();
836 mxEdMax->hide();
837
838 mxLbColMin->hide();
839 mxLbColMax->hide();
840
841 Deselect();
842}
843
844IMPL_LINK( ScColorScale2FrmtEntry, EntryTypeHdl, weld::ComboBox&, rBox, void )
845{
846 weld::Entry* pEd = nullptr;
847 if (&rBox == mxLbEntryTypeMin.get())
848 pEd = mxEdMin.get();
849 else if (&rBox == mxLbEntryTypeMax.get())
850 pEd = mxEdMax.get();
851
852 if (!pEd)
853 return;
854
855 bool bEnableEdit = true;
856 if (getSelectedType(rBox) <= COLORSCALE_MAX)
857 {
858 bEnableEdit = false;
859 }
860
861 if (bEnableEdit)
862 pEd->set_sensitive(true);
863 else
864 pEd->set_sensitive(false);
865}
866
868 : ScCondFrmtEntry(pParent, pDoc, rPos)
869 , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
870 , mxLbEntryTypeMin(mxBuilder->weld_combo_box("colscalemin"))
871 , mxLbEntryTypeMiddle(mxBuilder->weld_combo_box("colscalemiddle"))
872 , mxLbEntryTypeMax(mxBuilder->weld_combo_box("colscalemax"))
873 , mxEdMin(mxBuilder->weld_entry("edcolscalemin"))
874 , mxEdMiddle(mxBuilder->weld_entry("edcolscalemiddle"))
875 , mxEdMax(mxBuilder->weld_entry("edcolscalemax"))
876 , mxLbColMin(new ColorListBox(mxBuilder->weld_menu_button("lbcolmin"), [this]{ return mpParent->GetFrameWeld(); }))
877 , mxLbColMiddle(new ColorListBox(mxBuilder->weld_menu_button("lbcolmiddle"), [this]{ return mpParent->GetFrameWeld(); }))
878 , mxLbColMax(new ColorListBox(mxBuilder->weld_menu_button("lbcolmax"), [this]{ return mpParent->GetFrameWeld(); }))
879 , mxFtMin(mxBuilder->weld_label("Label_minimum"))
880 , mxFtMax(mxBuilder->weld_label("Label_maximum"))
881{
882 mxLbColorFormat->set_size_request(CommonWidgetWidth, -1);
883 mxLbEntryTypeMin->set_size_request(CommonWidgetWidth, -1);
884 mxLbEntryTypeMiddle->set_size_request(CommonWidgetWidth, -1);
885 mxLbEntryTypeMax->set_size_request(CommonWidgetWidth, -1);
886 mxLbColMin->get_widget().set_size_request(CommonWidgetWidth, -1);
887 mxLbColMiddle->get_widget().set_size_request(CommonWidgetWidth, -1);
888 mxLbColMax->get_widget().set_size_request(CommonWidgetWidth, -1);
889 mxFtMin->show();
890 mxFtMax->show();
891
892 // remove the automatic entry from color scales
893 removeType(*mxLbEntryTypeMin, COLORSCALE_AUTO);
894 removeType(*mxLbEntryTypeMiddle, COLORSCALE_AUTO);
895 removeType(*mxLbEntryTypeMax, COLORSCALE_AUTO);
896 // "min" selector doesn't need "max" entry, and vice versa
897 removeType(*mxLbEntryTypeMin, COLORSCALE_MAX);
898 removeType(*mxLbEntryTypeMax, COLORSCALE_MIN);
899 mxLbColorFormat->set_active(1);
900
901 Init();
902 mxLbType->set_active(0);
903 if(pFormat)
904 {
905 ScColorScaleEntries::const_iterator itr = pFormat->begin();
906 SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMin, *mxEdMin, *mxLbColMin, pDoc);
907 assert(pFormat->size() == 3);
908 ++itr;
909 SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMiddle, *mxEdMiddle, *mxLbColMiddle, pDoc);
910 ++itr;
911 SetColorScaleEntryTypes(*itr[0], *mxLbEntryTypeMax, *mxEdMax, *mxLbColMax, pDoc);
912 }
913 else
914 {
915 mxLbColorFormat->set_active(1);
916 selectType(*mxLbEntryTypeMin, COLORSCALE_MIN);
917 selectType(*mxLbEntryTypeMiddle, COLORSCALE_PERCENTILE);
918 selectType(*mxLbEntryTypeMax, COLORSCALE_MAX);
919 mxEdMiddle->set_text(OUString::number(50));
920 }
921
922 mxLbColorFormat->connect_changed( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
923 EntryTypeHdl(*mxLbEntryTypeMin);
924 EntryTypeHdl(*mxLbEntryTypeMiddle);
925 EntryTypeHdl(*mxLbEntryTypeMax);
926}
927
929{
930}
931
933{
934 mxLbEntryTypeMin->connect_changed( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
935 mxLbEntryTypeMax->connect_changed( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
936 mxLbEntryTypeMiddle->connect_changed( LINK( this, ScColorScale3FrmtEntry, EntryTypeHdl ) );
937 mxLbColMin->SelectEntry(COL_LIGHTRED);
938 mxLbColMiddle->SelectEntry(COL_YELLOW);
939 mxLbColMax->SelectEntry(Color(0x00a933));
940}
941
943{
944 ScColorScaleFormat* pColorScale = new ScColorScaleFormat(mpDoc);
945 pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMin, *mxLbColMin, *mxEdMin, mpDoc, maPos));
946 if (mxLbColorFormat->get_active() == 1)
947 pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMiddle, *mxLbColMiddle, *mxEdMiddle, mpDoc, maPos));
948 pColorScale->AddEntry(createColorScaleEntry(*mxLbEntryTypeMax, *mxLbColMax, *mxEdMax, mpDoc, maPos));
949 return pColorScale;
950}
951
953{
955}
956
958{
959 return createColorscaleEntry();
960}
961
963{
964 mxLbColorFormat->show();
965 mxLbEntryTypeMin->show();
966 mxLbEntryTypeMiddle->show();
967 mxLbEntryTypeMax->show();
968
969 mxEdMin->show();
970 mxEdMiddle->show();
971 mxEdMax->show();
972
973 mxLbColMin->show();
974 mxLbColMiddle->show();
975 mxLbColMax->show();
976
977 Select();
978}
979
981{
982 mxLbColorFormat->hide();
983
984 mxLbEntryTypeMin->hide();
985 mxLbEntryTypeMiddle->hide();
986 mxLbEntryTypeMax->hide();
987
988 mxEdMin->hide();
989 mxEdMiddle->hide();
990 mxEdMax->hide();
991
992 mxLbColMin->hide();
993 mxLbColMiddle->hide();
994 mxLbColMax->hide();
995
996 Deselect();
997}
998
999IMPL_LINK( ScColorScale3FrmtEntry, EntryTypeHdl, weld::ComboBox&, rBox, void )
1000{
1001 weld::Entry* pEd = nullptr;
1002 if(&rBox == mxLbEntryTypeMin.get())
1003 pEd = mxEdMin.get();
1004 else if(&rBox == mxLbEntryTypeMiddle.get())
1005 pEd = mxEdMiddle.get();
1006 else if(&rBox == mxLbEntryTypeMax.get())
1007 pEd = mxEdMax.get();
1008
1009 if (!pEd)
1010 return;
1011
1012 bool bEnableEdit = true;
1013 if (getSelectedType(rBox) <= COLORSCALE_MAX)
1014 {
1015 bEnableEdit = false;
1016 }
1017
1018 if(bEnableEdit)
1019 pEd->set_sensitive(true);
1020 else
1021 pEd->set_sensitive(false);
1022}
1023
1025{
1026 sal_Int32 nSelectPos = mxLbCondType->get_active();
1027 ScConditionMode eMode = EntryPosToConditionMode(nSelectPos);
1028 switch(GetNumberEditFields(eMode))
1029 {
1030 case 0:
1031 mxEdVal1->GetWidget()->hide();
1032 mxEdVal2->GetWidget()->hide();
1033 mxFtVal->hide();
1034 break;
1035 case 1:
1036 mxEdVal1->GetWidget()->show();
1037 mxEdVal2->GetWidget()->hide();
1038 mxFtVal->show();
1039 break;
1040 case 2:
1041 mxEdVal1->GetWidget()->show();
1042 mxEdVal2->GetWidget()->show();
1043 mxFtVal->show();
1044 break;
1045 }
1046}
1047
1048//databar
1049
1050namespace {
1051
1052void SetDataBarEntryTypes( const ScColorScaleEntry& rEntry, weld::ComboBox& rLbType, weld::Entry& rEdit, const ScDocument* pDoc )
1053{
1054 selectType(rLbType, rEntry.GetType());
1055 switch(rEntry.GetType())
1056 {
1057 case COLORSCALE_AUTO:
1058 case COLORSCALE_MIN:
1059 case COLORSCALE_MAX:
1060 break;
1061 case COLORSCALE_VALUE:
1062 case COLORSCALE_PERCENT:
1064 {
1065 double nVal = rEntry.GetValue();
1066 SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
1067 OUString aText;
1068 pNumberFormatter->GetInputLineString(nVal, 0, aText);
1069 rEdit.set_text(aText);
1070 }
1071 break;
1072 case COLORSCALE_FORMULA:
1074 break;
1075 }
1076}
1077
1078}
1079
1081 : ScCondFrmtEntry(pParent, pDoc, rPos)
1082 , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
1083 , mxLbDataBarMinType(mxBuilder->weld_combo_box("colscalemin"))
1084 , mxLbDataBarMaxType(mxBuilder->weld_combo_box("colscalemax"))
1085 , mxEdDataBarMin(mxBuilder->weld_entry("edcolscalemin"))
1086 , mxEdDataBarMax(mxBuilder->weld_entry("edcolscalemax"))
1087 , mxBtOptions(mxBuilder->weld_button("options"))
1088 , mxFtMin(mxBuilder->weld_label("Label_minimum"))
1089 , mxFtMax(mxBuilder->weld_label("Label_maximum"))
1090{
1091 mxLbColorFormat->set_size_request(CommonWidgetWidth, -1);
1092 mxLbDataBarMinType->set_size_request(CommonWidgetWidth, -1);
1093 mxLbDataBarMaxType->set_size_request(CommonWidgetWidth, -1);
1094
1095 // "min" selector doesn't need "max" entry, and vice versa
1096 removeType(*mxLbDataBarMinType, COLORSCALE_MAX);
1097 removeType(*mxLbDataBarMaxType, COLORSCALE_MIN);
1098
1099 mxFtMin->show();
1100 mxFtMax->show();
1101
1102 mxLbColorFormat->set_active(2);
1103 mxLbType->set_active(0);
1104 if(pFormat)
1105 {
1106 mpDataBarData.reset(new ScDataBarFormatData(*pFormat->GetDataBarData()));
1107 SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, *mxLbDataBarMinType, *mxEdDataBarMin, pDoc);
1108 SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, *mxLbDataBarMaxType, *mxEdDataBarMax, pDoc);
1109 DataBarTypeSelectHdl(*mxLbDataBarMinType);
1110 }
1111 else
1112 {
1113 selectType(*mxLbDataBarMinType, COLORSCALE_AUTO);
1114 selectType(*mxLbDataBarMaxType, COLORSCALE_AUTO);
1115 DataBarTypeSelectHdl(*mxLbDataBarMinType);
1116 }
1117 Init();
1118
1119 mxLbColorFormat->connect_changed( LINK( pParent, ScCondFormatList, ColFormatTypeHdl ) );
1120}
1121
1123{
1124}
1125
1127{
1128 return createDatabarEntry();
1129}
1130
1132{
1133 mxLbDataBarMinType->connect_changed( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
1134 mxLbDataBarMaxType->connect_changed( LINK( this, ScDataBarFrmtEntry, DataBarTypeSelectHdl ) );
1135
1136 mxBtOptions->connect_clicked( LINK( this, ScDataBarFrmtEntry, OptionBtnHdl ) );
1137
1138 if(!mpDataBarData)
1139 {
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 = 0x2a6099;
1146 }
1147}
1148
1150{
1151 SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), *mxLbDataBarMinType,
1153 SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), *mxLbDataBarMaxType,
1155 ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
1157 return pDataBar;
1158}
1159
1161{
1163}
1164
1166{
1167 mxLbColorFormat->show();
1168
1169 mxLbDataBarMinType->show();
1170 mxLbDataBarMaxType->show();
1171 mxEdDataBarMin->show();
1172 mxEdDataBarMax->show();
1173 mxBtOptions->show();
1174
1175 Select();
1176}
1177
1179{
1180 mxLbColorFormat->hide();
1181
1182 mxLbDataBarMinType->hide();
1183 mxLbDataBarMaxType->hide();
1184 mxEdDataBarMin->hide();
1185 mxEdDataBarMax->hide();
1186 mxBtOptions->hide();
1187
1188 Deselect();
1189}
1190
1191IMPL_LINK_NOARG( ScDataBarFrmtEntry, DataBarTypeSelectHdl, weld::ComboBox&, void )
1192{
1193 if (getSelectedType(*mxLbDataBarMinType) <= COLORSCALE_MAX)
1194 mxEdDataBarMin->set_sensitive(false);
1195 else
1196 mxEdDataBarMin->set_sensitive(true);
1197
1198 if (getSelectedType(*mxLbDataBarMaxType) <= COLORSCALE_MAX)
1199 mxEdDataBarMax->set_sensitive(false);
1200 else
1201 mxEdDataBarMax->set_sensitive(true);
1202}
1203
1205{
1206 SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), *mxLbDataBarMinType,
1207 *mxEdDataBarMin, mpDoc, maPos);
1208 SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), *mxLbDataBarMaxType,
1209 *mxEdDataBarMax, mpDoc, maPos);
1210 ScDataBarSettingsDlg aDlg(mpParent->GetFrameWeld(), *mpDataBarData, mpDoc, maPos);
1211 if (aDlg.run() == RET_OK)
1212 {
1213 mpDataBarData.reset(aDlg.GetData());
1214 SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, *mxLbDataBarMinType, *mxEdDataBarMin, mpDoc);
1215 SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, *mxLbDataBarMaxType, *mxEdDataBarMax, mpDoc);
1216 DataBarTypeSelectHdl(*mxLbDataBarMinType);
1217 }
1218}
1219
1221 : ScCondFrmtEntry(pParent, pDoc, ScAddress())
1222 , mxLbDateEntry(mxBuilder->weld_combo_box("datetype"))
1223 , mxFtStyle(mxBuilder->weld_label("styleft"))
1224 , mxLbStyle(mxBuilder->weld_combo_box("style"))
1225 , mxWdPreviewWin(mxBuilder->weld_widget("previewwin"))
1226 , mxWdPreview(new weld::CustomWeld(*mxBuilder, "preview", maWdPreview))
1227 , mbIsInStyleCreate(false)
1228{
1229 mxLbDateEntry->set_size_request(CommonWidgetWidth, -1);
1230 mxLbStyle->set_size_request(CommonWidgetWidth, -1);
1231
1232 mxWdPreview->set_size_request(mxLbStyle->get_preferred_size().Height(), -1);
1233
1234 Init();
1235
1236 StartListening(*pDoc->GetStyleSheetPool(), DuplicateHandling::Prevent);
1237
1238 if(pFormat)
1239 {
1240 sal_Int32 nPos = static_cast<sal_Int32>(pFormat->GetDateType());
1241 mxLbDateEntry->set_active(nPos);
1242
1243 mxLbStyle->set_active_text(pFormat->GetStyleName());
1244 }
1245
1246 StyleSelectHdl(*mxLbStyle);
1247}
1248
1250{
1251}
1252
1254{
1255 mxLbDateEntry->set_active(0);
1256 mxLbType->set_active(3);
1257
1258 FillStyleListBox( mpDoc, *mxLbStyle );
1259 mxLbStyle->connect_changed( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) );
1260 mxLbStyle->set_active(1);
1261}
1262
1264{
1265 mxLbDateEntry->show();
1266 mxFtStyle->show();
1267 mxWdPreviewWin->show();
1268 mxLbStyle->show();
1269
1270 Select();
1271}
1272
1274{
1275 mxLbDateEntry->hide();
1276 mxFtStyle->hide();
1277 mxWdPreviewWin->hide();
1278 mxLbStyle->hide();
1279
1280 Deselect();
1281}
1282
1284{
1285 if(rHint.GetId() == SfxHintId::StyleSheetModified)
1286 {
1288 UpdateStyleList(*mxLbStyle, mpDoc);
1289 }
1290}
1291
1293{
1296 pNewEntry->SetDateType(eType);
1297 pNewEntry->SetStyleName(mxLbStyle->get_active_text());
1298 return pNewEntry;
1299}
1300
1302{
1303 // tdf#124412 - set actual condition for an inactive date entry
1304 return ScCondFormatHelper::GetExpression(DATE, mxLbDateEntry->get_active());
1305}
1306
1308{
1309 mbIsInStyleCreate = true;
1310 StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mpDoc, maWdPreview);
1311 mbIsInStyleCreate = false;
1312}
1313
1315{
1316protected:
1317 std::unique_ptr<weld::Builder> mxBuilder;
1318private:
1319 std::unique_ptr<weld::Container> mxGrid;
1320 std::unique_ptr<weld::Image> mxImgIcon;
1321 std::unique_ptr<weld::Label> mxFtEntry;
1322 std::unique_ptr<weld::Entry> mxEdEntry;
1323 std::unique_ptr<weld::ComboBox> mxLbEntryType;
1325
1326public:
1328 sal_Int32 i, const ScColorScaleEntry* pEntry = nullptr);
1330 void Show() { mxGrid->show(); }
1331 void Hide() { mxGrid->hide(); }
1332 void set_grid_top_attach(int nTop)
1333 {
1334 mxGrid->set_grid_left_attach(0);
1335 mxGrid->set_grid_top_attach(nTop);
1336 }
1337
1338 ScColorScaleEntry* CreateEntry(ScDocument& rDoc, const ScAddress& rPos) const;
1339
1340 void SetFirstEntry();
1341};
1342
1344 : mxBuilder(Application::CreateBuilder(pParent, "modules/scalc/ui/conditionaliconset.ui"))
1345 , mxGrid(mxBuilder->weld_container("ConditionalIconSet"))
1346 , mxImgIcon(mxBuilder->weld_image("icon"))
1347 , mxFtEntry(mxBuilder->weld_label("label"))
1348 , mxEdEntry(mxBuilder->weld_entry("entry"))
1349 , mxLbEntryType(mxBuilder->weld_combo_box("listbox"))
1350 , mpContainer(pParent)
1351{
1352 mxImgIcon->set_from_icon_name(ScIconSetFormat::getIconName(eType, i));
1353 if(pEntry)
1354 {
1355 switch(pEntry->GetType())
1356 {
1357 case COLORSCALE_VALUE:
1358 mxLbEntryType->set_active(0);
1359 mxEdEntry->set_text(convertNumberToString(pEntry->GetValue(), pDoc));
1360 break;
1362 mxLbEntryType->set_active(2);
1363 mxEdEntry->set_text(convertNumberToString(pEntry->GetValue(), pDoc));
1364 break;
1365 case COLORSCALE_PERCENT:
1366 mxLbEntryType->set_active(1);
1367 mxEdEntry->set_text(convertNumberToString(pEntry->GetValue(), pDoc));
1368 break;
1369 case COLORSCALE_FORMULA:
1370 mxLbEntryType->set_active(3);
1372 break;
1373 default:
1374 assert(false);
1375 }
1376 }
1377 else
1378 {
1379 mxLbEntryType->set_active(1);
1380 }
1381}
1382
1384{
1385 mpContainer->move(mxGrid.get(), nullptr);
1386}
1387
1389{
1390 sal_Int32 nPos = mxLbEntryType->get_active();
1391 OUString aText = mxEdEntry->get_text();
1392 ScColorScaleEntry* pEntry = new ScColorScaleEntry();
1393
1394 sal_uInt32 nIndex = 0;
1395 double nVal = 0;
1396 SvNumberFormatter* pNumberFormatter = rDoc.GetFormatTable();
1397 (void)pNumberFormatter->IsNumberFormat(aText, nIndex, nVal);
1398 pEntry->SetValue(nVal);
1399
1400 switch(nPos)
1401 {
1402 case 0:
1403 pEntry->SetType(COLORSCALE_VALUE);
1404 break;
1405 case 1:
1406 pEntry->SetType(COLORSCALE_PERCENT);
1407 break;
1408 case 2:
1410 break;
1411 case 3:
1412 pEntry->SetType(COLORSCALE_FORMULA);
1413 pEntry->SetFormula(aText, rDoc, rPos, rDoc.GetGrammar());
1414 break;
1415 default:
1416 assert(false);
1417 }
1418
1419 return pEntry;
1420}
1421
1423{
1424 mxEdEntry->hide();
1425 mxLbEntryType->hide();
1426 mxFtEntry->hide();
1427 mxEdEntry->set_text("0");
1428 mxLbEntryType->set_active(1);
1429}
1430
1432 : ScCondFrmtEntry(pParent, pDoc, rPos)
1433 , mxLbColorFormat(mxBuilder->weld_combo_box("colorformat"))
1434 , mxLbIconSetType(mxBuilder->weld_combo_box("iconsettype"))
1435 , mxIconParent(mxBuilder->weld_container("iconparent"))
1436{
1437 mxLbColorFormat->set_size_request(CommonWidgetWidth, -1);
1438 mxLbIconSetType->set_size_request(CommonWidgetWidth, -1);
1439
1440 Init();
1441 mxLbColorFormat->connect_changed(LINK(pParent, ScCondFormatList, ColFormatTypeHdl));
1442
1443 if(pFormat)
1444 {
1445 const ScIconSetFormatData* pIconSetFormatData = pFormat->GetIconSetData();
1446 ScIconSetType eType = pIconSetFormatData->eIconSetType;
1447 sal_Int32 nType = static_cast<sal_Int32>(eType);
1448 mxLbIconSetType->set_active(nType);
1449
1450 for (size_t i = 0, n = pIconSetFormatData->m_Entries.size();
1451 i < n; ++i)
1452 {
1453 maEntries.emplace_back(new ScIconSetFrmtDataEntry(
1454 mxIconParent.get(), eType, pDoc, i, pIconSetFormatData->m_Entries[i].get()));
1455 maEntries[i]->set_grid_top_attach(i);
1456 }
1457 maEntries[0]->SetFirstEntry();
1458 }
1459 else
1460 IconSetTypeHdl(*mxLbIconSetType);
1461}
1462
1464{
1465}
1466
1468{
1469 mxLbColorFormat->set_active(3);
1470 mxLbType->set_active(0);
1471 mxLbIconSetType->set_active(0);
1472
1473 mxLbIconSetType->connect_changed(LINK(this, ScIconSetFrmtEntry, IconSetTypeHdl));
1474}
1475
1477{
1479
1480 sal_Int32 nPos = mxLbIconSetType->get_active();
1481 sal_uInt32 nElements = pMap[nPos].nElements;
1482
1483 maEntries.clear();
1484
1485 for(size_t i = 0; i < nElements; ++i)
1486 {
1487 maEntries.emplace_back(new ScIconSetFrmtDataEntry(mxIconParent.get(), static_cast<ScIconSetType>(nPos), mpDoc, i));
1488 maEntries[i]->set_grid_top_attach(i);
1489 maEntries[i]->Show();
1490 }
1491 maEntries[0]->SetFirstEntry();
1492}
1493
1495{
1497}
1498
1500{
1501 mxLbColorFormat->show();
1502 mxLbIconSetType->show();
1503 for(auto& rxEntry : maEntries)
1504 {
1505 rxEntry->Show();
1506 }
1507
1508 Select();
1509}
1510
1512{
1513 mxLbColorFormat->hide();
1514 mxLbIconSetType->hide();
1515 for(auto& rxEntry : maEntries)
1516 {
1517 rxEntry->Hide();
1518 }
1519
1520 Deselect();
1521}
1522
1524{
1525 ScIconSetFormat* pFormat = new ScIconSetFormat(mpDoc);
1526
1528 pData->eIconSetType = static_cast<ScIconSetType>(mxLbIconSetType->get_active());
1529 for(const auto& rxEntry : maEntries)
1530 {
1531 pData->m_Entries.emplace_back(rxEntry->CreateEntry(*mpDoc, maPos));
1532 }
1533 pFormat->SetIconSetData(pData);
1534
1535 return pFormat;
1536}
1537
1538/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString uppercase(const OUString &rStr, sal_Int32 nPos, sal_Int32 nCount) const
Color const & GetSelectEntryColor() const
void SelectEntry(const NamedColor &rColor)
virtual ScFormatEntry * GetEntry() const override
ScFormatEntry * createColorscaleEntry() const
std::unique_ptr< weld::ComboBox > mxLbColorFormat
std::unique_ptr< weld::Entry > mxEdMin
ScColorScale2FrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos, const ScColorScaleFormat *pFormat=nullptr)
std::unique_ptr< weld::Entry > mxEdMax
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMax
virtual ~ScColorScale2FrmtEntry() override
virtual OUString GetExpressionString() override
std::unique_ptr< ColorListBox > mxLbColMax
virtual void SetActive() override
std::unique_ptr< ColorListBox > mxLbColMin
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMin
virtual void SetInactive() override
std::unique_ptr< weld::ComboBox > mxLbColorFormat
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMax
virtual void SetActive() override
std::unique_ptr< ColorListBox > mxLbColMiddle
std::unique_ptr< weld::Entry > mxEdMin
virtual ~ScColorScale3FrmtEntry() override
ScFormatEntry * createColorscaleEntry() const
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMiddle
virtual void SetInactive() override
ScColorScale3FrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos, const ScColorScaleFormat *pFormat=nullptr)
std::unique_ptr< ColorListBox > mxLbColMin
virtual OUString GetExpressionString() override
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::Entry > mxEdMax
std::unique_ptr< weld::ComboBox > mxLbEntryTypeMin
std::unique_ptr< weld::Entry > mxEdMiddle
std::unique_ptr< ColorListBox > mxLbColMax
double GetValue() const
Definition: colorscale.cxx:236
const ScTokenArray * GetFormula() const
Definition: colorscale.cxx:216
void SetType(ScColorScaleEntryType eType)
Definition: colorscale.cxx:323
ScColorScaleEntryType GetType() const
Definition: colorscale.hxx:76
void SetFormula(const OUString &rFormula, ScDocument &rDoc, const ScAddress &rAddr, formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT)
Definition: colorscale.cxx:207
const Color & GetColor() const
Definition: colorscale.hxx:61
void SetValue(double nValue)
Definition: colorscale.cxx:250
void SetColor(const Color &)
Definition: colorscale.cxx:310
void AddEntry(ScColorScaleEntry *pEntry)
Definition: colorscale.cxx:401
void SetExtendedErrorDetection(ExtendedErrorDetection eVal)
Definition: compiler.hxx:478
std::unique_ptr< ScTokenArray > CompileString(const OUString &rFormula)
Tokenize formula expression string into an array of tokens.
Definition: compiler.cxx:4687
void SetDateType(condformat::ScCondFormatDateType eType)
Definition: conditio.cxx:1687
void SetStyleName(const OUString &rStyleName)
Definition: conditio.cxx:1692
condformat::ScCondFormatDateType GetDateType() const
Definition: conditio.hxx:511
const OUString & GetStyleName() const
Definition: conditio.hxx:513
const OUString & GetStyle() const
Definition: conditio.hxx:472
static SC_DLLPUBLIC OUString GetExpression(const ScConditionalFormat &rFormat, const ScAddress &rPos)
weld::Window * GetFrameWeld()
weld::Container * GetContainer()
std::unique_ptr< weld::Label > mxFtCondition
std::unique_ptr< weld::Label > mxFtCondNr
ScCondFormatList * mpParent
std::unique_ptr< weld::Container > mxGrid
std::unique_ptr< weld::ComboBox > mxLbType
OUString const maStrCondition
ScCondFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos)
std::unique_ptr< weld::Widget > mxBorder
virtual OUString GetExpressionString()=0
virtual void Deselect()
void SetIndex(sal_Int32 nIndex)
Link< ScCondFrmtEntry &, void > maClickHdl
virtual void Select()
ScConditionMode GetOperation() const
Definition: conditio.hxx:368
OUString GetExpression(const ScAddress &rCursor, sal_uInt16 nPos, sal_uInt32 nNumFmt=0, const formula::FormulaGrammar::Grammar eGrammar=formula::FormulaGrammar::GRAM_DEFAULT) const
Definition: conditio.cxx:1250
virtual void Deselect() override
std::unique_ptr< weld::Label > mxFtVal
ScConditionFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, ScCondFormatDlg *pDialogParent, const ScAddress &rPos, const ScCondFormatEntry *pFormatEntry=nullptr)
virtual ScFormatEntry * GetEntry() const override
virtual void SetActive() override
std::unique_ptr< formula::RefEdit > mxEdVal2
std::unique_ptr< weld::ComboBox > mxLbStyle
virtual void Select() override
static sal_Int32 ConditionModeToEntryPos(ScConditionMode eMode)
std::unique_ptr< formula::RefEdit > mxEdVal1
std::unique_ptr< weld::Label > mxFtStyle
static const ScConditionMode mpEntryToCond[NUM_COND_ENTRIES]
void Init(ScCondFormatDlg *pDialogParent)
std::unique_ptr< weld::Widget > mxWdPreviewWin
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
virtual OUString GetExpressionString() override
virtual void SetInactive() override
static const sal_Int32 NUM_COND_ENTRIES
static ScConditionMode EntryPosToConditionMode(sal_Int32 aEntryPos)
std::unique_ptr< weld::ComboBox > mxLbCondType
ScFormatEntry * createConditionEntry() const
std::unique_ptr< weld::CustomWeld > mxWdPreview
virtual ~ScConditionFrmtEntry() override
static sal_Int32 GetNumberEditFields(ScConditionMode eMode)
void SetDataBarData(ScDataBarFormatData *pData)
Definition: colorscale.cxx:726
const ScDataBarFormatData * GetDataBarData() const
Definition: colorscale.cxx:741
ScDataBarFrmtEntry(ScCondFormatList *pParemt, ScDocument *pDoc, const ScAddress &rPos, const ScDataBarFormat *pFormat=nullptr)
virtual ~ScDataBarFrmtEntry() override
std::unique_ptr< weld::ComboBox > mxLbDataBarMinType
virtual void SetInactive() override
std::unique_ptr< weld::ComboBox > mxLbDataBarMaxType
std::unique_ptr< weld::Label > mxFtMax
std::unique_ptr< weld::Entry > mxEdDataBarMax
virtual OUString GetExpressionString() override
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::Entry > mxEdDataBarMin
ScFormatEntry * createDatabarEntry() const
std::unique_ptr< ScDataBarFormatData > mpDataBarData
std::unique_ptr< weld::Button > mxBtOptions
virtual void SetActive() override
std::unique_ptr< weld::Label > mxFtMin
std::unique_ptr< weld::ComboBox > mxLbColorFormat
ScDataBarFormatData * GetData()
virtual ScFormatEntry * GetEntry() const override
virtual void SetActive() override
std::unique_ptr< weld::CustomWeld > mxWdPreview
std::unique_ptr< weld::Label > mxFtStyle
virtual ~ScDateFrmtEntry() override
virtual OUString GetExpressionString() override
ScDateFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScCondDateFormatEntry *pFormat=nullptr)
std::unique_ptr< weld::Widget > mxWdPreviewWin
virtual void SetInactive() override
std::unique_ptr< weld::ComboBox > mxLbDateEntry
std::unique_ptr< weld::ComboBox > mxLbStyle
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
SC_DLLPUBLIC formula::FormulaGrammar::Grammar GetGrammar() const
Definition: document.hxx:1008
SC_DLLPUBLIC ScStyleSheetPool * GetStyleSheetPool() const
Definition: document.cxx:6174
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:467
std::unique_ptr< weld::Label > mxFtStyle
std::unique_ptr< weld::ComboBox > mxLbStyle
std::unique_ptr< formula::RefEdit > mxEdFormula
virtual void SetInactive() override
ScFormatEntry * createFormulaEntry() const
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::CustomWeld > mxWdPreview
ScFormulaFrmtEntry(ScCondFormatList *pParent, ScDocument *PDoc, ScCondFormatDlg *pDialogParent, const ScAddress &rPos, const ScCondFormatEntry *pFormatEntry=nullptr)
virtual OUString GetExpressionString() override
virtual void SetActive() override
std::unique_ptr< weld::Widget > mxWdPreviewWin
void Init(ScCondFormatDlg *pDialogParent)
virtual ~ScFormulaFrmtEntry() override
static SC_DLLPUBLIC const CharClass & getCharClass()
Definition: global.cxx:1062
static const ScIconSetMap g_IconSetMap[]
Definition: colorscale.hxx:380
static OUString getIconName(ScIconSetType eType, sal_Int32 nIndex)
void SetIconSetData(ScIconSetFormatData *pData)
const ScIconSetFormatData * GetIconSetData() const
std::unique_ptr< weld::Container > mxGrid
std::unique_ptr< weld::Entry > mxEdEntry
std::unique_ptr< weld::Label > mxFtEntry
std::unique_ptr< weld::Builder > mxBuilder
ScIconSetFrmtDataEntry(weld::Container *pParent, ScIconSetType eType, const ScDocument *pDoc, sal_Int32 i, const ScColorScaleEntry *pEntry=nullptr)
std::unique_ptr< weld::Image > mxImgIcon
std::unique_ptr< weld::ComboBox > mxLbEntryType
ScColorScaleEntry * CreateEntry(ScDocument &rDoc, const ScAddress &rPos) const
std::unique_ptr< weld::ComboBox > mxLbIconSetType
virtual ScFormatEntry * GetEntry() const override
std::unique_ptr< weld::ComboBox > mxLbColorFormat
ScIconSetFrmtDataEntriesType maEntries
virtual ~ScIconSetFrmtEntry() override
virtual OUString GetExpressionString() override
virtual void SetActive() override
ScIconSetFrmtEntry(ScCondFormatList *pParent, ScDocument *pDoc, const ScAddress &rPos, const ScIconSetFormat *pFormat=nullptr)
std::unique_ptr< weld::Container > mxIconParent
virtual void SetInactive() override
static ScTabViewShell * GetActiveViewShell()
Definition: tabvwsh4.cxx:1076
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
bool IsLocked() const
void Lock(bool bLock)
SfxHintId GetId() const
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
SfxDispatcher * GetDispatcher() const
virtual SfxStyleSheetBase * Find(const OUString &, SfxStyleFamily eFam, SfxStyleSearchBits n=SfxStyleSearchBits::All) const
virtual SfxItemSet & GetItemSet()
void GetInputLineString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &rOutString, bool bFiltering=false, bool bForceSystemLocale=false)
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
void SetFromItemSet(const SfxItemSet &rSet, bool bPreviewBackgroundToCharacter)
virtual int find_text(const OUString &rStr) const=0
virtual OUString get_active_id() const=0
virtual OUString get_active_text() const=0
virtual OUString get_id(int pos) const=0
virtual void set_active(int pos)=0
virtual OUString get_text(int pos) const=0
void append_text(const OUString &rStr)
void insert_text(int pos, const OUString &rStr)
virtual void remove(int pos)=0
virtual int get_active() const=0
virtual int get_count() const=0
void set_active_text(const OUString &rStr)
virtual void move(weld::Widget *pWidget, weld::Container *pNewParent)=0
virtual short run()
virtual void set_text(const OUString &rText)=0
virtual void set_message_type(EntryMessageType eType)=0
virtual OUString get_text() const=0
virtual void set_sensitive(bool sensitive)=0
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
constexpr ::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
constexpr ::Color COL_YELLOW(0xFF, 0xFF, 0x00)
ScIconSetType
Definition: colorscale.hxx:189
ScColorScaleEntryType
Definition: colorscale.hxx:32
@ COLORSCALE_MAX
Definition: colorscale.hxx:35
@ COLORSCALE_VALUE
Definition: colorscale.hxx:37
@ COLORSCALE_FORMULA
Definition: colorscale.hxx:39
@ COLORSCALE_PERCENT
Definition: colorscale.hxx:38
@ COLORSCALE_PERCENTILE
Definition: colorscale.hxx:36
@ COLORSCALE_AUTO
Definition: colorscale.hxx:33
@ COLORSCALE_MIN
Definition: colorscale.hxx:34
void Init()
IMPL_LINK_NOARG(ScCondFrmtEntry, EntrySelectHdl, const MouseEvent &, bool)
IMPL_LINK(ScConditionFrmtEntry, OnEdChanged, formula::RefEdit &, rRefEdit, void)
#define CommonWidgetWidth
@ CONDITION
@ ICONSET
@ DATABAR
@ COLORSCALE
ScConditionMode
Definition: conditio.hxx:60
sal_Int32 nElements
RegionData_Impl * mpParent
DocumentType eType
sal_Int32 nIndex
OUString aName
Mode eMode
sal_Int64 n
sal_uInt16 nPos
std::unique_ptr< sal_Int32[]> pData
ScCondFormatDateType
Definition: conditio.hxx:484
int i
bool equalsAscii(std::u16string_view s1, const char *s2)
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
static SfxItemSet & rSet
bool mbActive
ScIconSetType eIconSetType
Definition: colorscale.hxx:333
sal_Int32 nElements
Definition: colorscale.hxx:217
OUString sId
RET_OK