[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-5-2+backports' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Nov 16 09:00:33 UTC 2018


 sc/source/ui/condformat/condformatdlg.cxx |   23 +++++++++++++++++++++--
 sc/source/ui/inc/condformatdlg.hxx        |    2 ++
 sc/source/ui/inc/condformatdlgentry.hxx   |    1 +
 3 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 52fd6a3169b3f0343eb3319dee6f9350e1df2a3c
Author:     Vasily Melenchuk <vasily.melenchuk at cib.de>
AuthorDate: Thu Nov 15 18:03:32 2018 +0100
Commit:     Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Thu Nov 15 18:03:32 2018 +0100

    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: Ic53c8081ba568be6dabda9b0787c186cb40d326d

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 6f9cfbef23cb..7208a9c1921c 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -40,6 +40,7 @@
 ScCondFormatList::ScCondFormatList(vcl::Window* pParent, WinBits nStyle)
     : Control(pParent, nStyle | WB_DIALOGCONTROL)
     , mbHasScrollBar(false)
+    , mbNewEntry(false)
     , mpScrollBar(VclPtr<ScrollBar>::Create(this, WB_VERT ))
     , mpDoc(nullptr)
     , mpDialogParent(nullptr)
@@ -137,6 +138,7 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
             case condformat::dialog::NONE:
                 break;
         }
+        mbNewEntry = true;
     }
     RecalcAll();
     if (!maEntries.empty())
@@ -167,6 +169,11 @@ void ScCondFormatList::Resize()
     RecalcAll();
 }
 
+void ScCondFormatList::SetRange(const ScRangeList& rRange)
+{
+    maRanges = rRange;
+}
+
 ScConditionalFormat* ScCondFormatList::GetConditionalFormat() const
 {
     if(maEntries.empty())
@@ -175,9 +182,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);
     }
@@ -583,6 +601,7 @@ ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
     ScRangeList aRange;
     ScRefFlags nFlags = aRange.Parse(aRangeStr, mpViewData->GetDocument(),
         ScRefFlags::VALID, 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 42b39a8bcad1..d04e4f017299 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -47,6 +47,7 @@ private:
     EntryContainer maEntries;
 
     bool mbHasScrollBar;
+    bool mbNewEntry;
     VclPtr<ScrollBar> mpScrollBar;
 
     ScDocument* mpDoc;
@@ -64,6 +65,7 @@ public:
     void init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent, const ScConditionalFormat* pFormat,
         const ScRangeList& rRanges, const ScAddress& rPos,
         condformat::dialog::ScCondFormatDialogType eType);
+    void SetRange(const ScRangeList& rRange);
 
     virtual Size GetOptimalSize() const override;
     virtual void Resize() override;
diff --git a/sc/source/ui/inc/condformatdlgentry.hxx b/sc/source/ui/inc/condformatdlgentry.hxx
index 4ca6a9f1a38c..07f208e0bef9 100644
--- a/sc/source/ui/inc/condformatdlgentry.hxx
+++ b/sc/source/ui/inc/condformatdlgentry.hxx
@@ -69,6 +69,7 @@ public:
 
     virtual bool Notify( NotifyEvent& rNEvt ) override;
 
+    virtual void SetPos(const ScAddress& rPos) { maPos = rPos; };
     bool IsSelected() const { return mbActive;}
     void SetIndex(sal_Int32 nIndex);
     void SetHeight();


More information about the Libreoffice-commits mailing list