diff options
author | Pranam Lashkari <lpranam@collabora.com> | 2024-11-25 19:44:43 +0530 |
---|---|---|
committer | Pranam Lashkari <lpranam@collabora.com> | 2024-12-03 16:08:26 +0100 |
commit | eb933099a537da8d667c5921d73196401ac23b89 (patch) | |
tree | 29e6b4e11659fb9b5ca4f6d50b65fd4181f047b2 /sc/source | |
parent | 904b5157824f3d3920c8422dba277824e0d2bd88 (diff) |
Revert "sc: preview style in easy format dialog"
This reverts commit 2661be5f8fb28ada80b4f5336d59f54b520bf614.
Change-Id: Ie3482641cbbb34baa866a679c782221d2d513df1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177287
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177338
Tested-by: Jenkins
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/ui/condformat/condformatdlgentry.cxx | 127 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformateasydlg.cxx | 38 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformathelper.cxx | 102 | ||||
-rw-r--r-- | sc/source/ui/inc/condformateasydlg.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/inc/condformathelper.hxx | 10 |
5 files changed, 147 insertions, 136 deletions
diff --git a/sc/source/ui/condformat/condformatdlgentry.cxx b/sc/source/ui/condformat/condformatdlgentry.cxx index 4582c6b62508..1f8ad16a42bb 100644 --- a/sc/source/ui/condformat/condformatdlgentry.cxx +++ b/sc/source/ui/condformat/condformatdlgentry.cxx @@ -108,6 +108,27 @@ void ScCondFrmtEntry::Deselect() mbActive = false; } +//condition + +namespace +{ + +void FillStyleListBox(const ScDocument* pDoc, weld::ComboBox& rLbStyle) +{ + std::set<OUString> aStyleNames; + SfxStyleSheetIterator aStyleIter(pDoc->GetStyleSheetPool(), SfxStyleFamily::Para); + for (SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next()) + { + aStyleNames.insert(pStyle->GetName()); + } + for (const auto& rStyleName : aStyleNames) + { + rLbStyle.append_text(rStyleName); + } +} + +} + const ScConditionMode ScConditionFrmtEntry::mpEntryToCond[ScConditionFrmtEntry::NUM_COND_ENTRIES] = { ScConditionMode::Equal, ScConditionMode::Less, @@ -221,7 +242,7 @@ void ScConditionFrmtEntry::Init(ScCondFormatDlg* pDialogParent) mxEdVal1->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) ); mxEdVal2->SetModifyHdl( LINK( this, ScConditionFrmtEntry, OnEdChanged ) ); - ScCondFormatHelper::FillStyleListBox(mrDoc, *mxLbStyle); + FillStyleListBox(&mrDoc, *mxLbStyle); mxLbStyle->connect_changed( LINK( this, ScConditionFrmtEntry, StyleSelectHdl ) ); mxLbCondType->connect_changed( LINK( this, ScConditionFrmtEntry, ConditionTypeSelectHdl ) ); @@ -419,19 +440,109 @@ void ScConditionFrmtEntry::SetInactive() Deselect(); } +namespace +{ + +void UpdateStyleList(weld::ComboBox& rLbStyle, const ScDocument* pDoc) +{ + OUString aSelectedStyle = rLbStyle.get_active_text(); + for (sal_Int32 i = rLbStyle.get_count(); i > 1; --i) + rLbStyle.remove(i - 1); + FillStyleListBox(pDoc, rLbStyle); + rLbStyle.set_active_text(aSelectedStyle); +} + +} + void ScConditionFrmtEntry::Notify(SfxBroadcaster&, const SfxHint& rHint) { if(rHint.GetId() == SfxHintId::StyleSheetModified || rHint.GetId() == SfxHintId::StyleSheetModifiedExtended) { if(!mbIsInStyleCreate) - ScCondFormatHelper::UpdateStyleList(*mxLbStyle, mrDoc); + UpdateStyleList(*mxLbStyle, &mrDoc); } } +namespace +{ + +void StyleSelect(weld::Window* pDialogParent, weld::ComboBox& rLbStyle, const ScDocument* pDoc, + SvxFontPrevWindow& rWdPreview) +{ + if (rLbStyle.get_active() == 0) + { + // call new style dialog + SfxUInt16Item aFamilyItem(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para)); + SfxStringItem aRefItem(SID_STYLE_REFERENCE, ScResId(STR_STYLENAME_STANDARD)); + css::uno::Any aAny(pDialogParent->GetXWindow()); + SfxUnoAnyItem aDialogParent(SID_DIALOG_PARENT, aAny); + + // unlock the dispatcher so SID_STYLE_NEW can be executed + // (SetDispatcherLock would affect all Calc documents) + if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell()) + { + if (SfxDispatcher* pDisp = pViewShell->GetDispatcher()) + { + bool bLocked = pDisp->IsLocked(); + if (bLocked) + pDisp->Lock(false); + + // Execute the "new style" slot, complete with undo and all necessary updates. + // The return value (SfxUInt16Item) is ignored, look for new styles instead. + pDisp->ExecuteList(SID_STYLE_NEW, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, + { &aFamilyItem, &aRefItem }, { &aDialogParent }); + + if (bLocked) + pDisp->Lock(true); + + // Find the new style and add it into the style list boxes + SfxStyleSheetIterator aStyleIter(pDoc->GetStyleSheetPool(), SfxStyleFamily::Para); + bool bFound = false; + for (SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; + pStyle = aStyleIter.Next()) + { + const OUString& aName = pStyle->GetName(); + if (rLbStyle.find_text(aName) == -1) // all lists contain the same entries + { + for (sal_Int32 i = 1, n = rLbStyle.get_count(); i <= n && !bFound; ++i) + { + OUString aStyleName + = ScGlobal::getCharClass().uppercase(rLbStyle.get_text(i)); + if (i == n) + { + rLbStyle.append_text(aName); + rLbStyle.set_active_text(aName); + bFound = true; + } + else if (aStyleName > ScGlobal::getCharClass().uppercase(aName)) + { + rLbStyle.insert_text(i, aName); + rLbStyle.set_active_text(aName); + bFound = true; + } + } + } + } + } + } + } + + OUString aStyleName = rLbStyle.get_active_text(); + SfxStyleSheetBase* pStyleSheet + = pDoc->GetStyleSheetPool()->Find(aStyleName, SfxStyleFamily::Para); + if (pStyleSheet) + { + const SfxItemSet& rSet = pStyleSheet->GetItemSet(); + rWdPreview.SetFromItemSet(rSet, false); + } +} + +} + IMPL_LINK_NOARG(ScConditionFrmtEntry, StyleSelectHdl, weld::ComboBox&, void) { mbIsInStyleCreate = true; - ScCondFormatHelper::StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mrDoc, maWdPreview); + StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, &mrDoc, maWdPreview); mbIsInStyleCreate = false; } @@ -473,13 +584,13 @@ void ScFormulaFrmtEntry::Init(ScCondFormatDlg* pDialogParent) { mxEdFormula->SetGetFocusHdl( LINK( pDialogParent, ScCondFormatDlg, RangeGetFocusHdl ) ); - ScCondFormatHelper::FillStyleListBox(mrDoc, *mxLbStyle); + FillStyleListBox(&mrDoc, *mxLbStyle); mxLbStyle->connect_changed( LINK( this, ScFormulaFrmtEntry, StyleSelectHdl ) ); } IMPL_LINK_NOARG(ScFormulaFrmtEntry, StyleSelectHdl, weld::ComboBox&, void) { - ScCondFormatHelper::StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mrDoc, maWdPreview); + StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, &mrDoc, maWdPreview); } ScFormatEntry* ScFormulaFrmtEntry::createFormulaEntry() const @@ -1186,7 +1297,7 @@ void ScDateFrmtEntry::Init() mxLbDateEntry->set_active(0); mxLbType->set_active(3); - ScCondFormatHelper::FillStyleListBox(mrDoc, *mxLbStyle); + FillStyleListBox(&mrDoc, *mxLbStyle); mxLbStyle->connect_changed( LINK( this, ScDateFrmtEntry, StyleSelectHdl ) ); mxLbStyle->set_active(1); } @@ -1216,7 +1327,7 @@ void ScDateFrmtEntry::Notify( SfxBroadcaster&, const SfxHint& rHint ) if(rHint.GetId() == SfxHintId::StyleSheetModified || rHint.GetId() == SfxHintId::StyleSheetModifiedExtended) { if(!mbIsInStyleCreate) - ScCondFormatHelper::UpdateStyleList(*mxLbStyle, mrDoc); + UpdateStyleList(*mxLbStyle, &mrDoc); } } @@ -1238,7 +1349,7 @@ OUString ScDateFrmtEntry::GetExpressionString() IMPL_LINK_NOARG( ScDateFrmtEntry, StyleSelectHdl, weld::ComboBox&, void ) { mbIsInStyleCreate = true; - ScCondFormatHelper::StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, mrDoc, maWdPreview); + StyleSelect(mpParent->GetFrameWeld(), *mxLbStyle, &mrDoc, maWdPreview); mbIsInStyleCreate = false; } diff --git a/sc/source/ui/condformat/condformateasydlg.cxx b/sc/source/ui/condformat/condformateasydlg.cxx index 1e0323af7ca3..faef213042ef 100644 --- a/sc/source/ui/condformat/condformateasydlg.cxx +++ b/sc/source/ui/condformat/condformateasydlg.cxx @@ -15,10 +15,32 @@ #include <scresid.hxx> #include <svl/style.hxx> #include <strings.hrc> -#include <condformathelper.hxx> namespace { +void FillStyleListBox(const ScDocument* pDocument, weld::ComboBox& rCombo) +{ + std::set<OUString> aStyleNames; + SfxStyleSheetIterator aStyleIter(pDocument->GetStyleSheetPool(), SfxStyleFamily::Para); + for (SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next()) + { + aStyleNames.insert(pStyle->GetName()); + } + for (const auto& rStyleName : aStyleNames) + { + rCombo.append_text(rStyleName); + } +} + +void UpdateStyleList(const ScDocument* pDocument, weld::ComboBox& rCombo) +{ + OUString sSelectedStyle = rCombo.get_active_text(); + for (sal_Int32 i = rCombo.get_count(); i > 1; --i) + rCombo.remove(i - 1); + FillStyleListBox(pDocument, rCombo); + rCombo.set_active_text(sSelectedStyle); +} + condformat::ScCondFormatDateType GetScCondFormatDateType(ScConditionMode mode) { switch (mode) @@ -69,7 +91,6 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, : ScAnyRefDlgController(pBindings, pChildWindow, pParent, u"modules/scalc/ui/conditionaleasydialog.ui"_ustr, u"CondFormatEasyDlg"_ustr) - , mpParent(pParent) , mpViewData(pViewData) , mrDocument(mpViewData->GetDocument()) , mbIsManaged(false) @@ -79,8 +100,6 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, , mxRangeEntry(new formula::RefEdit(m_xBuilder->weld_entry(u"entryRange"_ustr))) , mxButtonRangeEdit(new formula::RefButton(m_xBuilder->weld_button(u"rbassign"_ustr))) , mxStyles(m_xBuilder->weld_combo_box(u"themeCombo"_ustr)) - , mxWdPreviewWin(m_xBuilder->weld_widget(u"previewwin"_ustr)) - , mxWdPreview(new weld::CustomWeld(*m_xBuilder, "preview", maWdPreview)) , mxDescription(m_xBuilder->weld_label(u"description"_ustr)) , mxButtonOk(m_xBuilder->weld_button(u"ok"_ustr)) , mxButtonCancel(m_xBuilder->weld_button(u"cancel"_ustr)) @@ -252,7 +271,6 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, mxButtonOk->connect_clicked(LINK(this, ConditionalFormatEasyDialog, ButtonPressed)); mxButtonCancel->connect_clicked(LINK(this, ConditionalFormatEasyDialog, ButtonPressed)); - mxStyles->connect_changed(LINK(this, ConditionalFormatEasyDialog, StyleSelectHdl)); ScRangeList aRange; mpViewData->GetMarkData().FillRangeListWithMarks(&aRange, false); @@ -268,10 +286,9 @@ ConditionalFormatEasyDialog::ConditionalFormatEasyDialog(SfxBindings* pBindings, mxRangeEntry->SetText(sRangeString); StartListening(*(mrDocument.GetStyleSheetPool()), DuplicateHandling::Prevent); - ScCondFormatHelper::FillStyleListBox(mrDocument, *mxStyles); + FillStyleListBox(&mrDocument, *mxStyles); mxStyles->set_active(1); - mxWdPreviewWin->show(); } ConditionalFormatEasyDialog::~ConditionalFormatEasyDialog() @@ -287,7 +304,7 @@ void ConditionalFormatEasyDialog::Notify(SfxBroadcaster&, const SfxHint& rHint) { if (rHint.GetId() == SfxHintId::StyleSheetModified || rHint.GetId() == SfxHintId::StyleSheetModifiedExtended) - ScCondFormatHelper::UpdateStyleList(*mxStyles, mrDocument); + UpdateStyleList(&mrDocument, *mxStyles); } void ConditionalFormatEasyDialog::SetReference(const ScRange& rRange, ScDocument&) @@ -384,11 +401,6 @@ IMPL_LINK(ConditionalFormatEasyDialog, ButtonPressed, weld::Button&, rButton, vo m_xDialog->response(RET_CANCEL); } -IMPL_LINK_NOARG(ConditionalFormatEasyDialog, StyleSelectHdl, weld::ComboBox&, void) -{ - ScCondFormatHelper::StyleSelect(mpParent, *mxStyles, mpViewData->GetDocument(), maWdPreview); -} - } // namespace sc /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/sc/source/ui/condformat/condformathelper.cxx b/sc/source/ui/condformat/condformathelper.cxx index 3092d5f74aee..2bee433a7295 100644 --- a/sc/source/ui/condformat/condformathelper.cxx +++ b/sc/source/ui/condformat/condformathelper.cxx @@ -15,14 +15,6 @@ #include <globstr.hrc> #include <scresid.hxx> #include <conditio.hxx> -#include <stlpool.hxx> -#include <svl/lstner.hxx> -#include <svl/stritem.hxx> -#include <svl/intitem.hxx> -#include <sfx2/dispatch.hxx> -#include <sfx2/frame.hxx> -#include <tabvwsh.hxx> -#include <svx/fntctrl.hxx> namespace { @@ -226,98 +218,4 @@ OUString ScCondFormatHelper::GetExpression( ScCondFormatEntryType eType, sal_Int return aBuffer.makeStringAndClear(); } -void ScCondFormatHelper::StyleSelect(weld::Window* pDialogParent, weld::ComboBox& rLbStyle, - const ScDocument& rDoc, SvxFontPrevWindow& rWdPreview) -{ - if (rLbStyle.get_active() == 0) - { - // call new style dialog - SfxUInt16Item aFamilyItem(SID_STYLE_FAMILY, sal_uInt16(SfxStyleFamily::Para)); - SfxStringItem aRefItem(SID_STYLE_REFERENCE, ScResId(STR_STYLENAME_STANDARD)); - css::uno::Any aAny(pDialogParent->GetXWindow()); - SfxUnoAnyItem aDialogParent(SID_DIALOG_PARENT, aAny); - - // unlock the dispatcher so SID_STYLE_NEW can be executed - // (SetDispatcherLock would affect all Calc documents) - if (ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell()) - { - if (SfxDispatcher* pDisp = pViewShell->GetDispatcher()) - { - bool bLocked = pDisp->IsLocked(); - if (bLocked) - pDisp->Lock(false); - - // Execute the "new style" slot, complete with undo and all necessary updates. - // The return value (SfxUInt16Item) is ignored, look for new styles instead. - pDisp->ExecuteList(SID_STYLE_NEW, SfxCallMode::SYNCHRON | SfxCallMode::RECORD, - { &aFamilyItem, &aRefItem }, { &aDialogParent }); - - if (bLocked) - pDisp->Lock(true); - - // Find the new style and add it into the style list boxes - SfxStyleSheetIterator aStyleIter(rDoc.GetStyleSheetPool(), SfxStyleFamily::Para); - bool bFound = false; - for (SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle && !bFound; - pStyle = aStyleIter.Next()) - { - const OUString& aName = pStyle->GetName(); - if (rLbStyle.find_text(aName) == -1) // all lists contain the same entries - { - for (sal_Int32 i = 1, n = rLbStyle.get_count(); i <= n && !bFound; ++i) - { - OUString aStyleName - = ScGlobal::getCharClass().uppercase(rLbStyle.get_text(i)); - if (i == n) - { - rLbStyle.append_text(aName); - rLbStyle.set_active_text(aName); - bFound = true; - } - else if (aStyleName > ScGlobal::getCharClass().uppercase(aName)) - { - rLbStyle.insert_text(i, aName); - rLbStyle.set_active_text(aName); - bFound = true; - } - } - } - } - } - } - } - - OUString aStyleName = rLbStyle.get_active_text(); - SfxStyleSheetBase* pStyleSheet - = rDoc.GetStyleSheetPool()->Find(aStyleName, SfxStyleFamily::Para); - if (pStyleSheet) - { - const SfxItemSet& rSet = pStyleSheet->GetItemSet(); - rWdPreview.SetFromItemSet(rSet, false); - } -} - -void ScCondFormatHelper::FillStyleListBox(const ScDocument& rDocument, weld::ComboBox& rCombo) -{ - std::set<OUString> aStyleNames; - SfxStyleSheetIterator aStyleIter(rDocument.GetStyleSheetPool(), SfxStyleFamily::Para); - for (SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next()) - { - aStyleNames.insert(pStyle->GetName()); - } - for (const auto& rStyleName : aStyleNames) - { - rCombo.append_text(rStyleName); - } -} - -void ScCondFormatHelper::UpdateStyleList(weld::ComboBox& rLbStyle, const ScDocument& rDoc) -{ - OUString aSelectedStyle = rLbStyle.get_active_text(); - for (sal_Int32 i = rLbStyle.get_count(); i > 1; --i) - rLbStyle.remove(i - 1); - ScCondFormatHelper::FillStyleListBox(rDoc, rLbStyle); - rLbStyle.set_active_text(aSelectedStyle); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformateasydlg.hxx b/sc/source/ui/inc/condformateasydlg.hxx index 7880862d8535..2b34a15fefee 100644 --- a/sc/source/ui/inc/condformateasydlg.hxx +++ b/sc/source/ui/inc/condformateasydlg.hxx @@ -12,7 +12,6 @@ #include "anyrefdg.hxx" #include <svl/lstner.hxx> #include <conditio.hxx> -#include <svx/fntctrl.hxx> class ScViewData; class ScConditionalFormat; @@ -33,12 +32,10 @@ public: virtual void Notify(SfxBroadcaster&, const SfxHint&) override; DECL_LINK(ButtonPressed, weld::Button&, void); - DECL_LINK(StyleSelectHdl, weld::ComboBox&, void); private: void SetDescription(std::u16string_view rCondition); - weld::Window* mpParent; ScViewData* mpViewData; ScDocument& mrDocument; ScConditionMode meMode; @@ -46,15 +43,12 @@ private: OUString msFormula; ScAddress maPosition; - SvxFontPrevWindow maWdPreview; std::unique_ptr<weld::Entry> mxNumberEntry; std::unique_ptr<weld::Entry> mxNumberEntry2; std::unique_ptr<weld::Container> mxAllInputs; std::unique_ptr<formula::RefEdit> mxRangeEntry; std::unique_ptr<formula::RefButton> mxButtonRangeEdit; std::unique_ptr<weld::ComboBox> mxStyles; - std::unique_ptr<weld::Widget> mxWdPreviewWin; - std::unique_ptr<weld::CustomWeld> mxWdPreview; std::unique_ptr<weld::Label> mxDescription; std::unique_ptr<weld::Button> mxButtonOk; std::unique_ptr<weld::Button> mxButtonCancel; diff --git a/sc/source/ui/inc/condformathelper.hxx b/sc/source/ui/inc/condformathelper.hxx index daf91a7a7276..29baf8d9ec44 100644 --- a/sc/source/ui/inc/condformathelper.hxx +++ b/sc/source/ui/inc/condformathelper.hxx @@ -11,7 +11,6 @@ #include <rtl/ustring.hxx> #include <address.hxx> -#include <svx/fntctrl.hxx> class ScConditionalFormat; @@ -30,12 +29,9 @@ class ScCondFormatHelper public: static SC_DLLPUBLIC OUString GetExpression(const ScConditionalFormat& rFormat, const ScAddress& rPos); - static SC_DLLPUBLIC OUString GetExpression( ScCondFormatEntryType eType, sal_Int32 nIndex, - std::u16string_view aStr1 = std::u16string_view(), std::u16string_view aStr2 = std::u16string_view() ); - static SC_DLLPUBLIC void StyleSelect(weld::Window* pDialogParent, weld::ComboBox& rLbStyle, - const ScDocument& rDoc, SvxFontPrevWindow& rWdPreview); - static SC_DLLPUBLIC void FillStyleListBox(const ScDocument& rDocument, weld::ComboBox& rCombo); - static SC_DLLPUBLIC void UpdateStyleList(weld::ComboBox& rLbStyle, const ScDocument& rDoc); + static SC_DLLPUBLIC OUString GetExpression(ScCondFormatEntryType eType, sal_Int32 nIndex, + std::u16string_view aStr1 = std::u16string_view(), + std::u16string_view aStr2 = std::u16string_view()); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |