Kaydet (Commit) 9c2c650c authored tarafından Vasily Melenchuk's avatar Vasily Melenchuk Kaydeden (comit) Eike Rathke

tdf#119178: use current range as a range for conditional format

During addition of new conditional format it is possible to select
different range, not one used initially. And new range should be
used for correct relative reference in formula evaluation.`

Change-Id: If73a0ddbb268c86e8c99f0703db1a5a97fb6ca66
Reviewed-on: https://gerrit.libreoffice.org/58800
Tested-by: Jenkins
Reviewed-by: 's avatarEike Rathke <erack@redhat.com>
üst 94da4277
......@@ -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)
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment