Resolves: tdf#95960 improve custom properties page

wrt widget heights and positions and other flakiness

take the natural combobox height as the line height, use a vclgrid
element for each row to get everything set to the same height

move the positioning code into Resize, etc.

Change-Id: I22de98ef91e39d1e7e45bbe62f68496d55c0c1cb
Reviewed-on: https://gerrit.libreoffice.org/41734
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/include/sfx2/dinfdlg.hxx b/include/sfx2/dinfdlg.hxx
index 1de0c95..a5a0b73 100644
--- a/include/sfx2/dinfdlg.hxx
+++ b/include/sfx2/dinfdlg.hxx
@@ -367,6 +367,7 @@ public:

struct CustomPropertyLine
{
    ScopedVclPtr<VclGrid>                       m_aLine;
    ScopedVclPtr<ComboBox>                      m_aNameBox;
    ScopedVclPtr<CustomPropertiesTypeBox>       m_aTypeBox;
    ScopedVclPtr<CustomPropertiesEdit>          m_aValueEdit;
@@ -391,20 +392,15 @@ struct CustomPropertyLine
class CustomPropertiesWindow : public vcl::Window
{
private:
    VclPtr<HeaderBar>                   m_pHeaderBar;
    VclPtr<ScrollBar>                   m_pScrollBar;
    VclPtr<FixedText>                   m_pHeaderAccName;
    VclPtr<FixedText>                   m_pHeaderAccType;
    VclPtr<FixedText>                   m_pHeaderAccValue;

    VclPtr<ComboBox>                    m_aNameBox;
    VclPtr<ListBox>                     m_aTypeBox;
    VclPtr<Edit>                        m_aValueEdit;
    VclPtr<DateField>                   m_aDateField;
    VclPtr<TimeField>                   m_aTimeField;
    VclPtr<Edit>                        m_aDurationField;
    VclPtr<PushButton>                  m_aEditButton;
    VclPtr<CustomPropertiesYesNoButton> m_aYesNoButton;
    VclPtr<ImageButton>                 m_aRemoveButton;

    sal_Int32                           m_nWidgetHeight;
    sal_Int32                           m_nRemoveButtonWidth;
    sal_Int32                           m_nTypeBoxWidth;
    sal_Int32                           m_nLineHeight;
    sal_Int32                           m_nScrollPos;
    std::vector< CustomPropertyLine* >  m_aCustomPropertiesLines;
@@ -414,10 +410,10 @@ private:
    Idle                                m_aBoxLoseFocusIdle;
    Link<void*,void>                    m_aRemovedHdl;

    DECL_STATIC_LINK( CustomPropertiesWindow, TypeHdl, ListBox&, void );
    DECL_LINK(  RemoveHdl, Button*, void );
    DECL_LINK(  EditLoseFocusHdl, Control&, void );
    DECL_LINK(  BoxLoseFocusHdl, Control&, void );
    DECL_LINK(TypeHdl, ListBox&, void);
    DECL_LINK(RemoveHdl, Button*, void);
    DECL_LINK(EditLoseFocusHdl, Control&, void);
    DECL_LINK(BoxLoseFocusHdl, Control&, void);
    //add lose focus handlers of Date/TimeField?

    DECL_LINK(EditTimeoutHdl, Timer *, void);
@@ -431,10 +427,18 @@ public:
        FixedText *pHeaderAccName,
        FixedText *pHeaderAccType,
        FixedText *pHeaderAccValue);
    void Init(HeaderBar* pHeaderBar, ScrollBar* pScrollBar);
    virtual ~CustomPropertiesWindow() override;
    virtual void dispose() override;

    bool                InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar );
    virtual void Resize() override;
    //these consts are unhelpful, this changes the state of the widgets
    //that belong to CustomPropertyLine, but they are held by VclPtr
    //and operator-> on a VclPtr is a const method that returns the
    //non-const contents of the VclPtr, but loplugin:constparams
    //correctly sees that it could all be set to const, so we end
    //up with this unhappy situation
    void SetWidgetWidths(const CustomPropertyLine* pLine) const;
    sal_uInt16          GetVisibleLineCount() const;
    sal_Int32    GetLineHeight() const { return m_nLineHeight; }
    void                AddLine( const OUString& sName, css::uno::Any const & rAny );
diff --git a/sfx2/source/dialog/dinfdlg.cxx b/sfx2/source/dialog/dinfdlg.cxx
index 36a7774..ee5ac67 100644
--- a/sfx2/source/dialog/dinfdlg.cxx
+++ b/sfx2/source/dialog/dinfdlg.cxx
@@ -1387,11 +1387,11 @@ void CustomPropertiesYesNoButton::Resize()
{
    Size aParentSize(GetSizePixel());
    const long nWidth = aParentSize.Width();
    Size a1Size = LogicToPixel(Size(1, 1), MapUnit::MapAppFont);
    const long n1Width = LogicToPixel(Size(1, 1), MapUnit::MapAppFont).Width();
    const long n3Width = LogicToPixel(Size(3, 3), MapUnit::MapAppFont).Width();
    const long nNewWidth = (nWidth / 2) - n3Width - 2;
    Size aSize(nNewWidth, aParentSize.Height() - 2 * a1Size.Height());
    Point aPos(a1Size.Width(), a1Size.Height());
    Size aSize(nNewWidth, m_aYesButton->get_preferred_size().Height());
    Point aPos(n1Width, (aParentSize.Height() - aSize.Height()) / 2);
    m_aYesButton->SetPosSizePixel(aPos, aSize);
    aPos.X() += aSize.Width() + n3Width;
    m_aNoButton->SetPosSizePixel(aPos, aSize);
@@ -1401,12 +1401,10 @@ namespace
{
    VclPtr<ComboBox> makeComboBox(vcl::Window *pParent)
    {
        VclPtr<ComboBox> aNameBox(VclPtr<ComboBox>::Create(pParent, WB_TABSTOP|WB_DROPDOWN|
                                                                    WB_AUTOSIZE|WB_AUTOHSCROLL));
        aNameBox->SetPosSizePixel(aNameBox->LogicToPixel(Point(0, 2), MapUnit::MapAppFont),
                                  aNameBox->LogicToPixel(Size(60, 72), MapUnit::MapAppFont));
        VclPtr<ComboBox> aNameBox(VclPtr<ComboBox>::Create(pParent, WB_TABSTOP|WB_DROPDOWN|WB_AUTOHSCROLL));
        for (size_t i = 0; i < SAL_N_ELEMENTS(SFX_CB_PROPERTY_STRINGARRAY); ++i)
            aNameBox->InsertEntry(SfxResId(SFX_CB_PROPERTY_STRINGARRAY[i]));
        aNameBox->EnableAutoSize(true);
        return aNameBox;
    }
}
@@ -1415,33 +1413,77 @@ CustomPropertiesTypeBox::CustomPropertiesTypeBox(vcl::Window* pParent, CustomPro
    : ListBox(pParent, WB_BORDER|WB_DROPDOWN)
    , m_pLine(pLine)
{
    SetPosSizePixel(LogicToPixel(Point(63, 2), MapUnit::MapAppFont),
                    LogicToPixel(Size(60, 80), MapUnit::MapAppFont));
    for (size_t i = 0; i < SAL_N_ELEMENTS(SFX_LB_PROPERTY_STRINGARRAY); ++i)
    {
        InsertEntry(SfxResId(SFX_LB_PROPERTY_STRINGARRAY[i].first));
        SetEntryData(i, reinterpret_cast<void*>(SFX_LB_PROPERTY_STRINGARRAY[i].second));
    }
    SelectEntryPos(0);
    EnableAutoSize(true);
}

// struct CustomPropertyLine ---------------------------------------------
CustomPropertyLine::CustomPropertyLine( vcl::Window* pParent ) :
    m_aNameBox      ( makeComboBox(pParent) ),
    m_aTypeBox      ( VclPtr<CustomPropertiesTypeBox>::Create(pParent, this) ),
    m_aValueEdit    ( VclPtr<CustomPropertiesEdit>::Create(pParent, WB_BORDER|WB_TABSTOP|WB_LEFT, this ) ),
    m_aDateField    ( VclPtr<CustomPropertiesDateField>::Create(pParent, WB_BORDER|WB_TABSTOP|WB_SPIN|WB_LEFT ) ),
    m_aTimeField    ( VclPtr<CustomPropertiesTimeField>::Create(pParent, WB_BORDER|WB_TABSTOP|WB_SPIN|WB_LEFT ) ),
    m_aLine         ( VclPtr<VclGrid>::Create(pParent) ),
    m_aNameBox      ( makeComboBox(m_aLine) ),
    m_aTypeBox      ( VclPtr<CustomPropertiesTypeBox>::Create(m_aLine, this) ),
    m_aValueEdit    ( VclPtr<CustomPropertiesEdit>::Create(m_aLine, WB_BORDER|WB_TABSTOP|WB_LEFT, this ) ),
    m_aDateField    ( VclPtr<CustomPropertiesDateField>::Create(m_aLine, WB_BORDER|WB_TABSTOP|WB_SPIN|WB_LEFT ) ),
    m_aTimeField    ( VclPtr<CustomPropertiesTimeField>::Create(m_aLine, WB_BORDER|WB_TABSTOP|WB_SPIN|WB_LEFT ) ),
    m_sDurationFormat( SfxResId( SFX_ST_DURATION_FORMAT ) ),
    m_aDurationField( VclPtr<CustomPropertiesDurationField>::Create(pParent, WB_BORDER|WB_TABSTOP|WB_READONLY, this ) ),
    m_aEditButton   ( VclPtr<CustomPropertiesEditButton>::Create(pParent, WB_TABSTOP, this) ),
    m_aYesNoButton  ( VclPtr<CustomPropertiesYesNoButton>::Create(pParent) ),
    m_aRemoveButton ( VclPtr<CustomPropertiesRemoveButton>::Create(pParent, 0, this) ),
    m_aDurationField( VclPtr<CustomPropertiesDurationField>::Create(m_aLine, WB_BORDER|WB_TABSTOP|WB_READONLY, this ) ),
    m_aEditButton   ( VclPtr<CustomPropertiesEditButton>::Create(m_aLine, WB_TABSTOP, this) ),
    m_aYesNoButton  ( VclPtr<CustomPropertiesYesNoButton>::Create(m_aLine) ),
    m_aRemoveButton ( VclPtr<CustomPropertiesRemoveButton>::Create(m_aLine, 0, this) ),
    m_bIsDate       ( false ),
    m_bIsRemoved    ( false ),
    m_bTypeLostFocus( false )

{
    m_aLine->set_column_spacing(4);

    m_aNameBox->set_grid_left_attach(0);
    m_aNameBox->set_grid_top_attach(0);
    m_aNameBox->set_margin_left(4);
    m_aNameBox->Show();

    m_aTypeBox->set_grid_left_attach(1);
    m_aTypeBox->set_grid_top_attach(0);
    m_aTypeBox->Show();

    m_aValueEdit->set_grid_left_attach(2);
    m_aValueEdit->set_grid_top_attach(0);
    m_aValueEdit->set_hexpand(true);
    m_aValueEdit->Show();

    m_aDateField->set_grid_left_attach(3);
    m_aDateField->set_grid_top_attach(0);
    m_aDateField->set_hexpand(true);
    m_aDateField->Show();

    m_aTimeField->set_grid_left_attach(4);
    m_aTimeField->set_grid_top_attach(0);
    m_aTimeField->set_hexpand(true);
    m_aTimeField->Show();

    m_aDurationField->set_grid_left_attach(5);
    m_aDurationField->set_grid_top_attach(0);
    m_aDurationField->set_hexpand(true);
    m_aDurationField->Show();

    m_aEditButton->set_grid_left_attach(6);
    m_aEditButton->set_grid_top_attach(0);
    m_aEditButton->Show();

    m_aYesNoButton->set_grid_left_attach(7);
    m_aYesNoButton->set_grid_top_attach(0);
    m_aYesNoButton->set_hexpand(true);
    m_aYesNoButton->Show();

    m_aRemoveButton->set_grid_left_attach(8);
    m_aRemoveButton->set_grid_top_attach(0);
    m_aRemoveButton->set_margin_right(4);
    m_aRemoveButton->Show();

    m_aTimeField->SetExtFormat( ExtTimeFieldFormat::Long24H );
    m_aDateField->SetExtDateFormat( ExtDateFieldFormat::SystemShortYYYY );

@@ -1455,77 +1497,41 @@ void CustomPropertyLine::SetRemoved()
{
    DBG_ASSERT( !m_bIsRemoved, "CustomPropertyLine::SetRemoved(): line already removed" );
    m_bIsRemoved = true;
    m_aNameBox->Hide();
    m_aTypeBox->Hide();
    m_aValueEdit->Hide();
    m_aDateField->Hide();
    m_aTimeField->Hide();
    m_aDurationField->Hide();
    m_aEditButton->Hide();
    m_aYesNoButton->Hide();
    m_aRemoveButton->Hide();
    m_aLine->Hide();
}

CustomPropertiesWindow::CustomPropertiesWindow(vcl::Window* pParent,
    FixedText *pHeaderAccName,
    FixedText *pHeaderAccType,
    FixedText *pHeaderAccValue) :
    Window(pParent, WB_HIDE | WB_CLIPCHILDREN | WB_TABSTOP | WB_DIALOGCONTROL),
    Window(pParent, WB_HIDE | WB_TABSTOP | WB_DIALOGCONTROL),
    m_pHeaderAccName(pHeaderAccName),
    m_pHeaderAccType(pHeaderAccType),
    m_pHeaderAccValue(pHeaderAccValue),
    m_aNameBox      ( makeComboBox(this) ),
    m_aTypeBox      ( VclPtr<CustomPropertiesTypeBox>::Create(pParent, nullptr) ),
    m_aValueEdit    ( VclPtr<Edit>::Create( this, WB_BORDER|WB_TABSTOP|WB_LEFT ) ),
    m_aDateField    ( VclPtr<DateField>::Create( this, WB_BORDER|WB_TABSTOP|WB_SPIN|WB_LEFT ) ),
    m_aTimeField    ( VclPtr<TimeField>::Create( this, WB_BORDER|WB_TABSTOP|WB_SPIN|WB_LEFT ) ),
    m_aDurationField( VclPtr<Edit>::Create( this, WB_BORDER|WB_TABSTOP|WB_READONLY ) ),
    m_aEditButton   ( VclPtr<PushButton>::Create( this, WB_TABSTOP ) ),
    m_aYesNoButton  ( VclPtr<CustomPropertiesYesNoButton>::Create(this) ),
    m_aRemoveButton ( VclPtr<ImageButton>::Create( this, 0 ) ),
    m_nScrollPos (0),
    m_pCurrentLine (nullptr),
    m_aNumberFormatter( ::comphelper::getProcessComponentContext(),
                        Application::GetSettings().GetLanguageTag().getLanguageType() )
{
    Point aPos(LogicToPixel(Point(159, 2), MapUnit::MapAppFont));
    m_nRemoveButtonWidth = ScopedVclPtrInstance<CustomPropertiesRemoveButton>(pParent, 0, nullptr)->get_preferred_size().Width();
    Size aSize = ScopedVclPtrInstance<CustomPropertiesTypeBox>(pParent, nullptr)->CalcMinimumSize();
    m_nTypeBoxWidth = aSize.Width();
    m_nWidgetHeight = aSize.Height();

    m_aEditButton->SetPosSizePixel(aPos,
        LogicToPixel(Size(RSC_CD_TEXTBOX_HEIGHT, RSC_CD_TEXTBOX_HEIGHT), MapUnit::MapAppFont));

    m_aRemoveButton->SetSizePixel(LogicToPixel(Size(RSC_CD_PUSHBUTTON_HEIGHT, RSC_CD_PUSHBUTTON_HEIGHT), MapUnit::MapAppFont));

    Size aSize(LogicToPixel(Size(61, RSC_CD_TEXTBOX_HEIGHT), MapUnit::MapAppFont));
    m_aValueEdit->SetPosSizePixel(aPos, aSize);
    m_aDurationField->SetPosSizePixel(aPos, aSize);
    m_aDateField->SetPosSizePixel(aPos, aSize);
    m_aTimeField->SetPosSizePixel(aPos, aSize);
    m_aYesNoButton->SetPosSizePixel(aPos, aSize);
    Point aPos(LogicToPixel(Point(0, 2), MapUnit::MapAppFont));

    m_aEditLoseFocusIdle.SetPriority( TaskPriority::LOWEST );
    m_aEditLoseFocusIdle.SetInvokeHandler( LINK( this, CustomPropertiesWindow, EditTimeoutHdl ) );
    m_aBoxLoseFocusIdle.SetPriority( TaskPriority::LOWEST );
    m_aBoxLoseFocusIdle.SetInvokeHandler( LINK( this, CustomPropertiesWindow, BoxTimeoutHdl ) );

    m_aNameBox->add_mnemonic_label(m_pHeaderAccName);
    m_aNameBox->SetAccessibleName(m_pHeaderAccName->GetText());
    m_aTypeBox->add_mnemonic_label(m_pHeaderAccType);
    m_aTypeBox->SetAccessibleName(m_pHeaderAccType->GetText());
    m_aValueEdit->add_mnemonic_label(m_pHeaderAccValue);
    m_aValueEdit->SetAccessibleName(m_pHeaderAccValue->GetText());
    m_nLineHeight = (aPos.Y() * 2) + m_nWidgetHeight;
}

    m_aNameBox->Hide();
    m_aTypeBox->Hide();
    m_aValueEdit->Hide();
    m_aDateField->Hide();
    m_aTimeField->Hide();
    m_aDurationField->Hide();
    m_aEditButton->Hide();
    m_aYesNoButton->Hide();
    m_aRemoveButton->Hide();

    m_nLineHeight =
        ( m_aRemoveButton->GetPosPixel().Y() * 2 ) + m_aRemoveButton->GetSizePixel().Height();
void CustomPropertiesWindow::Init(HeaderBar* pHeaderBar, ScrollBar* pScrollBar)
{
    m_pHeaderBar = pHeaderBar;
    m_pScrollBar = pScrollBar;
}

CustomPropertiesWindow::~CustomPropertiesWindow()
@@ -1538,23 +1544,15 @@ void CustomPropertiesWindow::dispose()
    m_aEditLoseFocusIdle.Stop();
    m_aBoxLoseFocusIdle.Stop();
    ClearAllLines();
    m_aNameBox.disposeAndClear();
    m_aTypeBox.disposeAndClear();
    m_aValueEdit.disposeAndClear();
    m_aDateField.disposeAndClear();
    m_aTimeField.disposeAndClear();
    m_aDurationField.disposeAndClear();
    m_aEditButton.disposeAndClear();
    m_aYesNoButton.disposeAndClear();
    m_aRemoveButton.disposeAndClear();
    m_pHeaderBar.clear();
    m_pScrollBar.clear();
    m_pHeaderAccName.clear();
    m_pHeaderAccType.clear();
    m_pHeaderAccValue.clear();
    vcl::Window::dispose();
}

IMPL_STATIC_LINK(
    CustomPropertiesWindow, TypeHdl, ListBox&, rListBox, void )
IMPL_LINK(CustomPropertiesWindow, TypeHdl, ListBox&, rListBox, void)
{
    CustomPropertiesTypeBox* pBox = static_cast<CustomPropertiesTypeBox*>(&rListBox);
    long nType = reinterpret_cast<long>( pBox->GetSelectEntryData() );
@@ -1568,17 +1566,11 @@ IMPL_STATIC_LINK(

    //adjust positions of date and time controls
    if ( nType == CUSTOM_TYPE_DATE )
    {
        pLine->m_bIsDate = true;
        pLine->m_aDateField->SetSizePixel( pLine->m_aValueEdit->GetSizePixel() );
    }
    else if ( nType == CUSTOM_TYPE_DATETIME)
    {
        // because m_aDateField and m_aTimeField have the same size for type "DateTime",
        // we just rely on m_aTimeField here.
        pLine->m_bIsDate = false;
        pLine->m_aDateField->SetSizePixel( pLine->m_aTimeField->GetSizePixel() );
    }

    pLine->m_aLine->SetSizePixel(Size(GetSizePixel().Width(), m_nWidgetHeight));
}

IMPL_LINK( CustomPropertiesWindow, RemoveHdl, Button*, pBtn, void )
@@ -1596,21 +1588,11 @@ IMPL_LINK( CustomPropertiesWindow, RemoveHdl, Button*, pBtn, void )
        for ( ; pIter != m_aCustomPropertiesLines.end(); ++pIter )
        {
            pLine = *pIter;
            if ( pLine->m_bIsRemoved )
            if (pLine->m_bIsRemoved)
                continue;

            vcl::Window* pWindows[] = {  pLine->m_aNameBox.get(), pLine->m_aTypeBox.get(), pLine->m_aValueEdit.get(),
                                    pLine->m_aDateField.get(), pLine->m_aTimeField.get(),
                                    pLine->m_aDurationField.get(), pLine->m_aEditButton.get(),
                                    pLine->m_aYesNoButton.get(), pLine->m_aRemoveButton.get(), nullptr };
            vcl::Window** pCurrent = pWindows;
            while ( *pCurrent )
            {
                Point aPos = (*pCurrent)->GetPosPixel();
                aPos.Y() -= nDelta;
                (*pCurrent)->SetPosPixel( aPos );
                pCurrent++;
            }
            Point aPos = pLine->m_aLine->GetPosPixel();
            aPos.Y() -= nDelta;
            pLine->m_aLine->SetPosPixel(aPos);
        }
    }

@@ -1686,74 +1668,51 @@ void CustomPropertiesWindow::ValidateLine( CustomPropertyLine* pLine, bool bIsFr
            pLine->m_bTypeLostFocus = true;
        vcl::Window* pParent = GetParent()->GetParent();
        if (ScopedVclPtrInstance<MessageDialog>(pParent, SfxResId(STR_SFX_QUERY_WRONG_TYPE), VclMessageType::Question, VclButtonsType::OkCancel)->Execute() == RET_OK)
            pLine->m_aTypeBox->SelectEntryPos( m_aTypeBox->GetEntryPos( reinterpret_cast<void*>(CUSTOM_TYPE_TEXT) ) );
            pLine->m_aTypeBox->SelectEntryPos(pLine->m_aTypeBox->GetEntryPos(reinterpret_cast<void*>(CUSTOM_TYPE_TEXT)));
        else
            pLine->m_aValueEdit->GrabFocus();
    }
}

bool CustomPropertiesWindow::InitControls( HeaderBar* pHeaderBar, const ScrollBar* pScrollBar )
void CustomPropertiesWindow::SetWidgetWidths(const CustomPropertyLine* pLine) const
{
    bool bChanged = false;

    DBG_ASSERT( pHeaderBar, "CustomPropertiesWindow::InitControls(): invalid headerbar" );
    DBG_ASSERT( pScrollBar, "CustomPropertiesWindow::InitControls(): invalid scrollbar" );

    const long nOffset = 4;
    const long nScrollBarWidth = pScrollBar->GetSizePixel().Width();
    const long nButtonWidth = m_aRemoveButton->GetSizePixel().Width() + nScrollBarWidth + nOffset;
    long nTypeWidth = m_aTypeBox->CalcMinimumSize().Width() + ( 2 * nOffset );
    long nFullWidth = pHeaderBar->GetSizePixel().Width();
    long nItemWidth = m_pHeaderBar->GetItemSize(HI_NAME);
    nItemWidth -= nOffset;

    pLine->m_aNameBox->set_width_request(nItemWidth);
    pLine->m_aTypeBox->set_width_request(m_nTypeBoxWidth);
    pLine->m_aValueEdit->set_width_request(nItemWidth);

    long nTimeWidth = nItemWidth;
    nTimeWidth /= 2;
    nTimeWidth -= 2;

    pLine->m_aDateField->set_width_request(nTimeWidth);
    pLine->m_aTimeField->set_width_request(nTimeWidth);

    pLine->m_aDurationField->set_width_request(nItemWidth - (pLine->m_aEditButton->get_preferred_size().Width() + nOffset));
    pLine->m_aYesNoButton->set_width_request(nItemWidth);
    pLine->m_aRemoveButton->set_width_request(m_nRemoveButtonWidth);

    pLine->m_aLine->SetSizePixel(Size(GetSizePixel().Width(), m_nWidgetHeight));
}

void CustomPropertiesWindow::Resize()
{
    const long nOffset = 4;
    const long nScrollBarWidth = m_pScrollBar->GetSizePixel().Width();
    long nButtonWidth = m_nRemoveButtonWidth + nScrollBarWidth + nOffset;
    long nTypeWidth = m_nTypeBoxWidth + (2 * nOffset);
    long nFullWidth = m_pHeaderBar->GetSizePixel().Width();
    long nItemWidth = ( nFullWidth - nTypeWidth - nButtonWidth ) / 2;
    pHeaderBar->SetItemSize( HI_NAME, nItemWidth );
    pHeaderBar->SetItemSize( HI_TYPE, nTypeWidth );
    pHeaderBar->SetItemSize( HI_VALUE, nItemWidth );
    pHeaderBar->SetItemSize( HI_ACTION, nButtonWidth );
    m_pHeaderBar->SetItemSize( HI_NAME, nItemWidth );
    m_pHeaderBar->SetItemSize( HI_TYPE, nTypeWidth );
    m_pHeaderBar->SetItemSize( HI_VALUE, nItemWidth );
    m_pHeaderBar->SetItemSize( HI_ACTION, nButtonWidth );

    vcl::Window* pWindows[] = { m_aNameBox.get(), m_aTypeBox.get(), m_aValueEdit.get(), m_aRemoveButton.get(), nullptr };
    vcl::Window** pCurrent = pWindows;
    sal_uInt16 nPos = 0;
    while ( *pCurrent )
    {
        tools::Rectangle aRect = pHeaderBar->GetItemRect( pHeaderBar->GetItemId( nPos++ ) );
        Size aOrigSize = (*pCurrent)->GetSizePixel();
        Point aOrigPos = (*pCurrent)->GetPosPixel();
        Size aSize(aOrigSize);
        Point aPos(aOrigPos);
        long nWidth = aRect.GetWidth() - nOffset;
        if ( *pCurrent == m_aRemoveButton.get() )
            nWidth -= pScrollBar->GetSizePixel().Width();
        aSize.Width() = nWidth;
        aPos.X() = aRect.getX() + ( nOffset / 2 );

        if (aOrigSize != aSize || aOrigPos != aPos)
        {
            (*pCurrent)->SetPosSizePixel(aPos, aSize);
            bChanged = true;
        }

        if ( *pCurrent == m_aValueEdit.get() )
        {
            Point aDurationPos( aPos );
            m_aDurationField->SetPosPixel( aDurationPos );
            Size aDurationSize(aSize);
            aDurationSize.Width() -= (m_aEditButton->GetSizePixel().Width() + 3 );
            m_aDurationField->SetSizePixel(aDurationSize);
            aDurationPos.X() = aPos.X() - m_aEditButton->GetSizePixel().Width() + aSize.Width();
            m_aEditButton->SetPosPixel(aDurationPos);

            m_aYesNoButton->SetPosSizePixel( aPos, aSize );

            aSize.Width() /= 2;
            aSize.Width() -= 2;
            m_aDateField->SetPosSizePixel( aPos, aSize );
            aPos.X() += aSize.Width() + 4;
            m_aTimeField->SetPosSizePixel( aPos, aSize );
        }

        pCurrent++;
    }
    return bChanged;
    for (CustomPropertyLine* pLine : m_aCustomPropertiesLines)
        SetWidgetWidths(pLine);
}

sal_uInt16 CustomPropertiesWindow::GetVisibleLineCount() const
@@ -1770,44 +1729,6 @@ sal_uInt16 CustomPropertiesWindow::GetVisibleLineCount() const
    return nCount;
}

void CustomPropertiesWindow::updateLineWidth()
{
    vcl::Window* pWindows[] = {  m_aNameBox.get(), m_aTypeBox.get(), m_aValueEdit.get(),
                            m_aDateField.get(), m_aTimeField.get(),
                            m_aDurationField.get(), m_aEditButton.get(),
                            m_aYesNoButton.get(), m_aRemoveButton.get(), nullptr };

    for (std::vector< CustomPropertyLine* >::iterator aI =
        m_aCustomPropertiesLines.begin(), aEnd = m_aCustomPropertiesLines.end();
        aI != aEnd; ++aI)
    {
        CustomPropertyLine* pNewLine = *aI;

        vcl::Window* pNewWindows[] =
            {   pNewLine->m_aNameBox.get(), pNewLine->m_aTypeBox.get(), pNewLine->m_aValueEdit.get(),
                pNewLine->m_aDateField.get(), pNewLine->m_aTimeField.get(),
                pNewLine->m_aDurationField.get(), pNewLine->m_aEditButton.get(),
                pNewLine->m_aYesNoButton.get(), pNewLine->m_aRemoveButton.get(), nullptr };

        vcl::Window** pCurrent = pWindows;
        vcl::Window** pNewCurrent = pNewWindows;
        while (*pCurrent)
        {
            Size aSize = (*pNewCurrent)->GetSizePixel();
            aSize.Width() = (*pCurrent)->GetSizePixel().Width();
            Point aPos = (*pNewCurrent)->GetPosPixel();
            aPos.X() = (*pCurrent)->GetPosPixel().X();
            (*pNewCurrent)->SetPosSizePixel(aPos, aSize);
            pCurrent++;
            pNewCurrent++;
        }

        // if we have type "Date", we use the full width, not only the half
        if (pNewLine->m_bIsDate)
            pNewLine->m_aDateField->SetSizePixel( pNewLine->m_aValueEdit->GetSizePixel() );
    }
}

void CustomPropertiesWindow::AddLine( const OUString& sName, Any const & rAny )
{
    CustomPropertyLine* pNewLine = new CustomPropertyLine( this );
@@ -1827,28 +1748,10 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any const & rAny )

    sal_Int32 nPos = GetVisibleLineCount() * GetLineHeight();
    m_aCustomPropertiesLines.push_back( pNewLine );
    vcl::Window* pWindows[] = {  m_aNameBox.get(), m_aTypeBox.get(), m_aValueEdit.get(),
                            m_aDateField.get(), m_aTimeField.get(),
                            m_aDurationField.get(), m_aEditButton.get(),
                            m_aYesNoButton.get(), m_aRemoveButton.get(), nullptr };
    vcl::Window* pNewWindows[] =
        {   pNewLine->m_aNameBox.get(), pNewLine->m_aTypeBox.get(), pNewLine->m_aValueEdit.get(),
            pNewLine->m_aDateField.get(), pNewLine->m_aTimeField.get(),
            pNewLine->m_aDurationField.get(), pNewLine->m_aEditButton.get(),
            pNewLine->m_aYesNoButton.get(), pNewLine->m_aRemoveButton.get(), nullptr };
    vcl::Window** pCurrent = pWindows;
    vcl::Window** pNewCurrent = pNewWindows;
    while ( *pCurrent )
    {
        Size aSize = (*pCurrent)->GetSizePixel();
        Point aPos = (*pCurrent)->GetPosPixel();
        aPos.Y() += nPos;
        aPos.Y() += m_nScrollPos;
        (*pNewCurrent)->SetPosSizePixel( aPos, aSize );
        (*pNewCurrent)->Show();
        pCurrent++;
        pNewCurrent++;
    }

    SetWidgetWidths(pNewLine);
    pNewLine->m_aLine->SetPosSizePixel(Point(0, nPos + m_nScrollPos), Size(GetSizePixel().Width(), m_nWidgetHeight));
    pNewLine->m_aLine->Show();

    double nTmpValue = 0;
    bool bTmpValue = false;
@@ -1924,10 +1827,10 @@ void CustomPropertiesWindow::AddLine( const OUString& sName, Any const & rAny )
            else
                pNewLine->m_aYesNoButton->CheckNo();
        }
        pNewLine->m_aTypeBox->SelectEntryPos( m_aTypeBox->GetEntryPos( reinterpret_cast<void*>(nType) ) );
        pNewLine->m_aTypeBox->SelectEntryPos(pNewLine->m_aTypeBox->GetEntryPos(reinterpret_cast<void*>(nType)));
    }

    TypeHdl( nullptr, *pNewLine->m_aTypeBox.get() );
    TypeHdl(*pNewLine->m_aTypeBox.get());
    pNewLine->m_aNameBox->GrabFocus();
}

@@ -1966,24 +1869,13 @@ void CustomPropertiesWindow::ClearAllLines()
void CustomPropertiesWindow::DoScroll( sal_Int32 nNewPos )
{
    m_nScrollPos += nNewPos;
    std::vector< CustomPropertyLine* >::iterator pIter;
    for ( pIter = m_aCustomPropertiesLines.begin();
            pIter != m_aCustomPropertiesLines.end(); ++pIter )
    for (CustomPropertyLine* pLine : m_aCustomPropertiesLines)
    {
        CustomPropertyLine* pLine = *pIter;
        if ( pLine->m_bIsRemoved )
        if (pLine->m_bIsRemoved)
            continue;

        vcl::Window* pWindows[] = {  pLine->m_aNameBox.get(), pLine->m_aTypeBox.get(), pLine->m_aValueEdit.get(), pLine->m_aDateField.get(), pLine->m_aTimeField.get(),
                                pLine->m_aDurationField.get(), pLine->m_aEditButton.get(), pLine->m_aYesNoButton.get(), pLine->m_aRemoveButton.get(), nullptr };
        vcl::Window** pCurrent = pWindows;
        while ( *pCurrent )
        {
            Point aPos = (*pCurrent)->GetPosPixel();
            aPos.Y() += nNewPos;
            (*pCurrent)->SetPosPixel( aPos );
            pCurrent++;
        }
        Point aPos = pLine->m_aLine->GetPosPixel();
        aPos.Y() += nNewPos;
        pLine->m_aLine->SetPosPixel(aPos);
    }
}

@@ -2094,6 +1986,7 @@ void CustomPropertiesControl::Init(VclBuilderContainer& rBuilder)
    OUString sValue = pValue->GetText();
    m_pPropertiesWin = VclPtr<CustomPropertiesWindow>::Create(m_pBody, pName, pType, pValue);
    m_pVertScroll = VclPtr<ScrollBar>::Create(m_pBody, WB_VERT);
    m_pPropertiesWin->Init(m_pHeaderBar, m_pVertScroll);

    set_hexpand(true);
    set_vexpand(true);
@@ -2144,22 +2037,15 @@ void CustomPropertiesControl::Init(VclBuilderContainer& rBuilder)

void CustomPropertiesControl::Resize()
{
    Window::Resize();

    if (!m_pVBox)
        return;

    m_pVBox->SetSizePixel(GetSizePixel());

    bool bWidgetsResized = m_pPropertiesWin->InitControls( m_pHeaderBar, m_pVertScroll );
    sal_Int32 nScrollOffset = m_pPropertiesWin->GetLineHeight();
    sal_Int32 nVisibleEntries = m_pPropertiesWin->GetSizePixel().Height() / nScrollOffset;
    m_pVertScroll->SetPageSize( nVisibleEntries - 1 );
    m_pVertScroll->SetVisibleSize( nVisibleEntries );
    if (bWidgetsResized)
    if (m_pVBox)
    {
        m_pPropertiesWin->updateLineWidth();
        m_pVBox->SetSizePixel(GetSizePixel());
        sal_Int32 nScrollOffset = m_pPropertiesWin->GetLineHeight();
        sal_Int32 nVisibleEntries = m_pPropertiesWin->GetSizePixel().Height() / nScrollOffset;
        m_pVertScroll->SetPageSize( nVisibleEntries - 1 );
        m_pVertScroll->SetVisibleSize( nVisibleEntries );
    }
    Window::Resize();
}

VCL_BUILDER_FACTORY(CustomPropertiesControl)