summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/source/ui/condformat/condformatdlg.cxx23
-rw-r--r--sc/source/ui/inc/condformatdlg.hxx3
-rw-r--r--sc/source/ui/inc/condformatdlgentry.hxx1
3 files changed, 25 insertions, 2 deletions
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index eddbb1514f53..64952101d0ea 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -38,6 +38,7 @@ ScCondFormatList::ScCondFormatList(vcl::Window* pParent, WinBits nStyle)
: Control(pParent, nStyle | WB_DIALOGCONTROL)
, mbHasScrollBar(false)
, mbFrozen(false)
+ , mbNewEntry(false)
, mpScrollBar(VclPtr<ScrollBar>::Create(this, WB_VERT ))
, mpDoc(nullptr)
, mpDialogParent(nullptr)
@@ -138,6 +139,7 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
case condformat::dialog::NONE:
break;
}
+ mbNewEntry = true;
}
Thaw();
RecalcAll();
@@ -150,6 +152,11 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
RecalcAll();
}
+void ScCondFormatList::SetRange(const ScRangeList& rRange)
+{
+ maRanges = rRange;
+}
+
VCL_BUILDER_FACTORY_CONSTRUCTOR(ScCondFormatList, 0)
Size ScCondFormatList::GetOptimalSize() const
@@ -179,9 +186,20 @@ ScConditionalFormat* ScCondFormatList::GetConditionalFormat() const
ScConditionalFormat* pFormat = new ScConditionalFormat(0, mpDoc);
pFormat->SetRange(maRanges);
- for(EntryContainer::const_iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+ for(auto & rEntry: maEntries)
{
- ScFormatEntry* pEntry = (*itr)->GetEntry();
+ // tdf#119178: Sometimes initial apply-to range (the one this dialog
+ // was opened with) is different from the final apply-to range
+ // (as edited by the user)
+
+ // If this format entry is new, take top-left corner of the final range
+ // and use it to create the initial entry (token array therein, if applicable)
+ if (mbNewEntry)
+ rEntry->SetPos(maRanges.GetTopLeftCorner());
+ // else do nothing: setting new position when editing recompiles formulas
+ // in entries and nobody wants that
+
+ ScFormatEntry* pEntry = rEntry->GetEntry();
if(pEntry)
pFormat->AddEntry(pEntry);
}
@@ -672,6 +690,7 @@ ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
ScRangeList aRange;
ScRefFlags nFlags = aRange.Parse(aRangeStr, mpViewData->GetDocument(),
mpViewData->GetDocument()->GetAddressConvention(), maPos.Tab());
+ mpCondFormList->SetRange(aRange);
ScConditionalFormat* pFormat = mpCondFormList->GetConditionalFormat();
if((nFlags & ScRefFlags::VALID) && !aRange.empty() && pFormat)
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 684fd75a68c3..9c9706c19f25 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -39,6 +39,7 @@ private:
bool mbHasScrollBar;
bool mbFrozen;
+ bool mbNewEntry;
VclPtr<ScrollBar> mpScrollBar;
ScDocument* mpDoc;
@@ -57,6 +58,8 @@ public:
const ScRangeList& rRanges, const ScAddress& rPos,
condformat::dialog::ScCondFormatDialogType eType);
+ void SetRange(const ScRangeList& rRange);
+
virtual Size GetOptimalSize() const override;
virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
virtual void Resize() override;
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index f949b0c15b38..223d1796cab4 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -79,6 +79,7 @@ public:
virtual bool EventNotify( NotifyEvent& rNEvt ) override;
+ virtual void SetPos(const ScAddress& rPos) { maPos = rPos; };
bool IsSelected() const { return mbActive;}
void SetIndex(sal_Int32 nIndex);
void SetHeight();