Blame SOURCES/0060-Related-fdo-81457-skip-setting-an-empty-allocation.patch

f085be
From aeef56b3731e746406b441550aea217dcb39371d Mon Sep 17 00:00:00 2001
f085be
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f085be
Date: Tue, 22 Jul 2014 14:20:33 +0100
f085be
Subject: [PATCH 060/137] Related: fdo#81457 skip setting an empty allocation
f085be
f085be
if the dimension is 0, don't bother calculating
f085be
a bunch of <= 0 sizes, rely on the parents clipping
f085be
to hide the lot instead
f085be
f085be
(cherry picked from commit 13807fbf9f3a4aae6767da8bcf796bea4b065159)
f085be
f085be
and
f085be
f085be
Related: fdo#81457 quadratic time required when setting a11y name
f085be
f085be
when calling SetAccessibleName GetAccessibleName is called
f085be
in order to send a name changed a11y event. Getting an Accessible
f085be
Name is very slow in a non-layout aware widget because it scans
f085be
for a "nearby" label and there is none in this widget, but it
f085be
has a huge pile of other widgets to iterate over.
f085be
f085be
call add_mnemonic_label before hand to cut off that entire
f085be
branch.
f085be
f085be
While we're at it, only call InitControl to adjust to a new
f085be
width if the new width is different from the old width
f085be
f085be
(cherry picked from commit aff263c8b814c6bf352312403d3c1e448c8013a3)
f085be
f085be
Conflicts:
f085be
	include/sfx2/dinfdlg.hxx
f085be
f085be
Change-Id: Ie4ba1276127226e49442278e46447b84bbeb1cde
f085be
Reviewed-on: https://gerrit.libreoffice.org/10463
f085be
Reviewed-by: David Tardon <dtardon@redhat.com>
f085be
Tested-by: David Tardon <dtardon@redhat.com>
f085be
---
f085be
 include/sfx2/dinfdlg.hxx       | 14 ++++++----
f085be
 sfx2/source/dialog/dinfdlg.cxx | 63 +++++++++++++++++++++++++++++-------------
f085be
 vcl/source/window/tabpage.cxx  | 11 +++++---
f085be
 3 files changed, 60 insertions(+), 28 deletions(-)
f085be
f085be
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
f085be
index a4d6acd..81b57bc 100644
f085be
--- a/include/sfx2/dinfdlg.hxx
f085be
+++ b/include/sfx2/dinfdlg.hxx
f085be
@@ -407,6 +407,10 @@ struct CustomPropertyLine
f085be
 class CustomPropertiesWindow : public Window
f085be
 {
f085be
 private:
f085be
+    FixedText*                          m_pHeaderAccName;
f085be
+    FixedText*                          m_pHeaderAccType;
f085be
+    FixedText*                          m_pHeaderAccValue;
f085be
+
f085be
     ComboBox                            m_aNameBox;
f085be
     ListBox                             m_aTypeBox;
f085be
     Edit                                m_aValueEdit;
f085be
@@ -441,13 +445,13 @@ private:
f085be
 
f085be
 public:
f085be
     CustomPropertiesWindow(Window* pParent,
f085be
-        const OUString &rHeaderAccName,
f085be
-        const OUString &rHeaderAccType,
f085be
-        const OUString &rHeaderAccValue);
f085be
+        FixedText *pHeaderAccName,
f085be
+        FixedText *pHeaderAccType,
f085be
+        FixedText *pHeaderAccValue);
f085be
     ~CustomPropertiesWindow();
f085be
 
f085be
-    void                InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar );
f085be
-    sal_uInt16              GetVisibleLineCount() const;
f085be
+    bool                InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar );
f085be
+    sal_uInt16          GetVisibleLineCount() const;
f085be
     inline sal_Int32    GetLineHeight() const { return m_nLineHeight; }
f085be
     void                AddLine( const OUString& sName, com::sun::star::uno::Any& rAny );
f085be
     bool                AreAllLinesValid() const;
f085be
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
f085be
index a7c6c95..4a278c1 100644
f085be
--- a/sfx2/source/dialog/dinfdlg.cxx
f085be
+++ b/sfx2/source/dialog/dinfdlg.cxx
f085be
@@ -1401,10 +1401,13 @@ void CustomPropertyLine::SetRemoved()
f085be
 }
f085be
 
f085be
 CustomPropertiesWindow::CustomPropertiesWindow(Window* pParent,
f085be
-    const OUString &rHeaderAccName,
f085be
-    const OUString &rHeaderAccType,
f085be
-    const OUString &rHeaderAccValue) :
f085be
+    FixedText *pHeaderAccName,
f085be
+    FixedText *pHeaderAccType,
f085be
+    FixedText *pHeaderAccValue) :
f085be
     Window(pParent),
f085be
+    m_pHeaderAccName(pHeaderAccName),
f085be
+    m_pHeaderAccType(pHeaderAccType),
f085be
+    m_pHeaderAccValue(pHeaderAccValue),
f085be
     m_aNameBox      ( this, SfxResId( SFX_CB_PROPERTY_NAME ) ),
f085be
     m_aTypeBox      ( this, SfxResId( SFX_LB_PROPERTY_TYPE ) ),
f085be
     m_aValueEdit    ( this, SfxResId( SFX_ED_PROPERTY_VALUE ) ),
f085be
@@ -1424,9 +1427,12 @@ CustomPropertiesWindow::CustomPropertiesWindow(Window* pParent,
f085be
     m_aBoxLoseFocusTimer.SetTimeout( 300 );
f085be
     m_aBoxLoseFocusTimer.SetTimeoutHdl( LINK( this, CustomPropertiesWindow, BoxTimeoutHdl ) );
f085be
 
f085be
-    m_aNameBox.SetAccessibleName(rHeaderAccName);
f085be
-    m_aTypeBox.SetAccessibleName(rHeaderAccType);
f085be
-    m_aValueEdit.SetAccessibleName(rHeaderAccValue);
f085be
+    m_aNameBox.add_mnemonic_label(m_pHeaderAccName);
f085be
+    m_aNameBox.SetAccessibleName(m_pHeaderAccName->GetText());
f085be
+    m_aTypeBox.add_mnemonic_label(m_pHeaderAccType);
f085be
+    m_aTypeBox.SetAccessibleName(m_pHeaderAccType->GetText());
f085be
+    m_aValueEdit.add_mnemonic_label(m_pHeaderAccValue);
f085be
+    m_aValueEdit.SetAccessibleName(m_pHeaderAccValue->GetText());
f085be
 
f085be
     m_aNameBox.Hide();
f085be
     m_aTypeBox.Hide();
f085be
@@ -1592,8 +1598,10 @@ void CustomPropertiesWindow::ValidateLine( CustomPropertyLine* pLine, bool bIsFr
f085be
     }
f085be
 }
f085be
 
f085be
-void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar )
f085be
+bool CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar )
f085be
 {
f085be
+    bool bChanged = false;
f085be
+
f085be
     DBG_ASSERT( pHeaderBar, "CustomPropertiesWindow::InitControls(): invalid headerbar" );
f085be
     DBG_ASSERT( pScrollBar, "CustomPropertiesWindow::InitControls(): invalid scrollbar" );
f085be
 
f085be
@@ -1614,14 +1622,21 @@ void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBa
f085be
     while ( *pCurrent )
f085be
     {
f085be
         Rectangle aRect = pHeaderBar->GetItemRect( pHeaderBar->GetItemId( nPos++ ) );
f085be
-        Size aSize = (*pCurrent)->GetSizePixel();
f085be
-        Point aPos = (*pCurrent)->GetPosPixel();
f085be
+        Size aOrigSize = (*pCurrent)->GetSizePixel();
f085be
+        Point aOrigPos = (*pCurrent)->GetPosPixel();
f085be
+        Size aSize(aOrigSize);
f085be
+        Point aPos(aOrigPos);
f085be
         long nWidth = aRect.GetWidth() - nOffset;
f085be
         if ( *pCurrent == &m_aRemoveButton )
f085be
             nWidth -= pScrollBar->GetSizePixel().Width();
f085be
         aSize.Width() = nWidth;
f085be
         aPos.X() = aRect.getX() + ( nOffset / 2 );
f085be
-        (*pCurrent)->SetPosSizePixel( aPos, aSize );
f085be
+
f085be
+        if (aOrigSize != aSize || aOrigPos != aPos)
f085be
+        {
f085be
+            (*pCurrent)->SetPosSizePixel(aPos, aSize);
f085be
+            bChanged = true;
f085be
+        }
f085be
 
f085be
         if ( *pCurrent == &m_aValueEdit )
f085be
         {
f085be
@@ -1646,6 +1661,7 @@ void CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBa
f085be
 
f085be
         pCurrent++;
f085be
     }
f085be
+    return bChanged;
f085be
 }
f085be
 
f085be
 sal_uInt16 CustomPropertiesWindow::GetVisibleLineCount() const
f085be
@@ -1705,9 +1721,12 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any& rAny )
f085be
 
f085be
     pNewLine->m_aTypeBox.SetLoseFocusHdl( LINK( this, CustomPropertiesWindow, BoxLoseFocusHdl ) );
f085be
 
f085be
-    pNewLine->m_aNameBox.SetAccessibleName(m_aNameBox.GetAccessibleName());
f085be
-    pNewLine->m_aTypeBox.SetAccessibleName(m_aTypeBox.GetAccessibleName());
f085be
-    pNewLine->m_aValueEdit.SetAccessibleName(m_aValueEdit.GetAccessibleName());
f085be
+    pNewLine->m_aNameBox.add_mnemonic_label(m_pHeaderAccName);
f085be
+    pNewLine->m_aNameBox.SetAccessibleName(m_pHeaderAccName->GetText());
f085be
+    pNewLine->m_aTypeBox.add_mnemonic_label(m_pHeaderAccType);
f085be
+    pNewLine->m_aTypeBox.SetAccessibleName(m_pHeaderAccType->GetText());
f085be
+    pNewLine->m_aValueEdit.add_mnemonic_label(m_pHeaderAccValue);
f085be
+    pNewLine->m_aValueEdit.SetAccessibleName(m_pHeaderAccValue->GetText());
f085be
 
f085be
     long nPos = GetVisibleLineCount() * GetLineHeight();
f085be
     m_aCustomPropertiesLines.push_back( pNewLine );
f085be
@@ -1967,10 +1986,13 @@ void CustomPropertiesControl::Init(VclBuilderContainer& rBuilder)
f085be
 {
f085be
     m_pHeaderBar = new HeaderBar(this, WB_BUTTONSTYLE | WB_BOTTOMBORDER);
f085be
     m_pBody = new VclHBox(this);
f085be
-    OUString sName = rBuilder.get<FixedText>("name")->GetText();
f085be
-    OUString sType = rBuilder.get<FixedText>("type")->GetText();
f085be
-    OUString sValue = rBuilder.get<FixedText>("value")->GetText();
f085be
-    m_pPropertiesWin = new CustomPropertiesWindow(m_pBody, sName, sType, sValue);
f085be
+    FixedText* pName = rBuilder.get<FixedText>("name");
f085be
+    FixedText* pType = rBuilder.get<FixedText>("type");
f085be
+    FixedText* pValue = rBuilder.get<FixedText>("value");
f085be
+    OUString sName = pName->GetText();
f085be
+    OUString sType = pType->GetText();
f085be
+    OUString sValue = pValue->GetText();
f085be
+    m_pPropertiesWin = new CustomPropertiesWindow(m_pBody, pName, pType, pValue);
f085be
     m_pVertScroll = new ScrollBar(m_pBody, WB_VERT);
f085be
 
f085be
     set_hexpand(true);
f085be
@@ -2018,12 +2040,15 @@ void CustomPropertiesControl::setAllocation(const Size &rAllocation)
f085be
 {
f085be
     VclVBox::setAllocation(rAllocation);
f085be
 
f085be
-    m_pPropertiesWin->InitControls( m_pHeaderBar, m_pVertScroll );
f085be
+    bool bWidgetsResized = m_pPropertiesWin->InitControls( m_pHeaderBar, m_pVertScroll );
f085be
     sal_Int32 nScrollOffset = m_pPropertiesWin->GetLineHeight();
f085be
     sal_Int32 nVisibleEntries = m_pPropertiesWin->GetSizePixel().Height() / nScrollOffset;
f085be
     m_pVertScroll->SetPageSize( nVisibleEntries - 1 );
f085be
     m_pVertScroll->SetVisibleSize( nVisibleEntries );
f085be
-    m_pPropertiesWin->updateLineWidth();
f085be
+    if (bWidgetsResized)
f085be
+    {
f085be
+        m_pPropertiesWin->updateLineWidth();
f085be
+    }
f085be
 }
f085be
 
f085be
 extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeCustomPropertiesControl(Window *pParent,
f085be
diff --git a/vcl/source/window/tabpage.cxx b/vcl/source/window/tabpage.cxx
f085be
index 67225ea..8d472c1 100644
f085be
--- a/vcl/source/window/tabpage.cxx
f085be
+++ b/vcl/source/window/tabpage.cxx
f085be
@@ -210,22 +210,25 @@ Size TabPage::GetOptimalSize() const
f085be
 void TabPage::SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation)
f085be
 {
f085be
     Window::SetPosSizePixel(rAllocPos, rAllocation);
f085be
-    if (isLayoutEnabled(this))
f085be
+    if (isLayoutEnabled(this) && rAllocation.Width() && rAllocation.Height())
f085be
         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
f085be
 }
f085be
 
f085be
 void TabPage::SetSizePixel(const Size& rAllocation)
f085be
 {
f085be
     Window::SetSizePixel(rAllocation);
f085be
-    if (isLayoutEnabled(this))
f085be
+    if (isLayoutEnabled(this) && rAllocation.Width() && rAllocation.Height())
f085be
         VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), rAllocation);
f085be
 }
f085be
 
f085be
 void TabPage::SetPosPixel(const Point& rAllocPos)
f085be
 {
f085be
     Window::SetPosPixel(rAllocPos);
f085be
-    if (isLayoutEnabled(this))
f085be
-        VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), GetOutputSizePixel());
f085be
+    Size aAllocation(GetOutputSizePixel());
f085be
+    if (isLayoutEnabled(this) && aAllocation.Width() && aAllocation.Height())
f085be
+    {
f085be
+        VclContainer::setLayoutAllocation(*GetWindow(WINDOW_FIRSTCHILD), Point(0, 0), aAllocation);
f085be
+    }
f085be
 }
f085be
 
f085be
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
f085be
-- 
f085be
1.9.3
f085be