Blob Blame History Raw
From c8bc15772d69e60334b53aa73832d4a719676f59 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 8 Dec 2014 09:56:33 +0000
Subject: [PATCH] Resolves: rhbz#1164614 xslt dialog crashes if there are no
 entries

Change-Id: Id7d967389cbc9f8ae120749bbe1c79bbbe46b212
---
 filter/source/xsltdialog/xmlfiltersettingsdialog.cxx | 15 +++++++++++++++
 filter/source/xsltdialog/xmlfiltersettingsdialog.hxx |  1 +
 2 files changed, 16 insertions(+)

diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index 17095fa..62bf721 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -1355,6 +1355,16 @@ SvxPathControl::SvxPathControl(Window* pParent)
 #define ITEMID_NAME     1
 #define ITEMID_TYPE     2
 
+Size SvxPathControl::GetOptimalSize() const
+{
+    Size aDefSize(LogicToPixel(Size(150, 0), MapMode(MAP_APPFONT)));
+    Size aOptSize(VclVBox::GetOptimalSize());
+    long nRowHeight(GetTextHeight());
+    aOptSize.Height() = nRowHeight * 10;
+    aOptSize.Width() = std::max(aDefSize.Width(), aOptSize.Width());
+    return aOptSize;
+}
+
 void SvxPathControl::setAllocation(const Size &rAllocation)
 {
     VclVBox::setAllocation(rAllocation);
@@ -1366,6 +1376,11 @@ void SvxPathControl::setAllocation(const Size &rAllocation)
     {
         std::vector<long> aWidths;
         m_pFocusCtrl->getPreferredDimensions(aWidths);
+        if (aWidths.empty())
+        {
+            bHasBeenShown = false;
+            return;
+        }
         long nFirstColumnWidth = aWidths[1];
         m_pHeaderBar->SetItemSize(ITEMID_NAME, nFirstColumnWidth);
         m_pHeaderBar->SetItemSize(ITEMID_TYPE, 0xFFFF);
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx
index 60b9983..c7630de 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.hxx
@@ -44,6 +44,7 @@ private:
     HeaderBar* m_pHeaderBar;
     XMLFilterListBox* m_pFocusCtrl;
 protected:
+    virtual Size GetOptimalSize() const;
     virtual void setAllocation(const Size &rAllocation);
 public:
     SvxPathControl(Window* pParent);
-- 
1.9.3