[Libreoffice-commits] core.git: include/svx solenv/sanitizers svx/source sw/inc sw/source sw/uiconfig

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Tue Jan 14 12:46:20 UTC 2020


 include/svx/sidebar/ValueSetWithTextControl.hxx      |    6 -
 solenv/sanitizers/ui/modules/swriter.suppr           |    1 
 svx/source/sidebar/tools/ValueSetWithTextControl.cxx |   18 ++-
 sw/inc/PageSizePopup.hxx                             |    1 
 sw/source/uibase/sidebar/PageSizeControl.cxx         |  114 ++++++++-----------
 sw/source/uibase/sidebar/PageSizeControl.hxx         |   25 +---
 sw/source/uibase/sidebar/PageSizePopup.cxx           |   14 ++
 sw/uiconfig/swriter/ui/pagesizecontrol.ui            |   77 +++++++++---
 8 files changed, 148 insertions(+), 108 deletions(-)

New commits:
commit 53d2a0390473319555f244f0ac3cf9a44b5ac7a0
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Tue Jan 14 10:48:18 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Tue Jan 14 13:45:44 2020 +0100

    weld PageSizePopup
    
    Change-Id: I989e2a6337f368ec388290f1e4af329865af9ec7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86749
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svx/sidebar/ValueSetWithTextControl.hxx b/include/svx/sidebar/ValueSetWithTextControl.hxx
index a7c6641f519b..6fed356191db 100644
--- a/include/svx/sidebar/ValueSetWithTextControl.hxx
+++ b/include/svx/sidebar/ValueSetWithTextControl.hxx
@@ -33,10 +33,12 @@ namespace svx { namespace sidebar {
 
     Especially, used for sidebar related controls.
 */
-class SVX_DLLPUBLIC ValueSetWithTextControl final : public ValueSet
+class SVX_DLLPUBLIC ValueSetWithTextControl final : public SvtValueSet
 {
 public:
-    ValueSetWithTextControl(Window* pParent, WinBits nBits);
+    ValueSetWithTextControl();
+
+    virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
 
     void AddItem(
         const OUString& rItemText,
diff --git a/solenv/sanitizers/ui/modules/swriter.suppr b/solenv/sanitizers/ui/modules/swriter.suppr
index 9fad88ba117b..661023b6ce0e 100644
--- a/solenv/sanitizers/ui/modules/swriter.suppr
+++ b/solenv/sanitizers/ui/modules/swriter.suppr
@@ -181,6 +181,7 @@ sw/uiconfig/swriter/ui/pagemargincontrol.ui://GtkSpinButton[@id='left:0cm'] no-l
 sw/uiconfig/swriter/ui/pagemargincontrol.ui://GtkSpinButton[@id='right:0cm'] no-labelled-by
 sw/uiconfig/swriter/ui/pagemargincontrol.ui://GtkSpinButton[@id='top:0cm'] no-labelled-by
 sw/uiconfig/swriter/ui/pagemargincontrol.ui://GtkSpinButton[@id='bottom:0cm'] no-labelled-by
+sw/uiconfig/swriter/ui/pagesizecontrol.ui://GtkSpinButton[@id='metric'] no-labelled-by
 sw/uiconfig/swriter/ui/printmonitordialog.ui://GtkLabel[@id='docname'] orphan-label
 sw/uiconfig/swriter/ui/printmonitordialog.ui://GtkLabel[@id='printing'] orphan-label
 sw/uiconfig/swriter/ui/printmonitordialog.ui://GtkLabel[@id='printer'] orphan-label
diff --git a/svx/source/sidebar/tools/ValueSetWithTextControl.cxx b/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
index 5b1e74d2dff9..c26a3220089b 100644
--- a/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
+++ b/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
@@ -26,15 +26,25 @@
 #include <vcl/graph.hxx>
 #include <vcl/event.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
 
 namespace svx { namespace sidebar {
 
-ValueSetWithTextControl::ValueSetWithTextControl(Window* pParent, WinBits nBits)
-    : ValueSet( pParent, nBits )
+ValueSetWithTextControl::ValueSetWithTextControl()
+    : SvtValueSet(nullptr)
 {
-    SetColCount();
 }
 
+void ValueSetWithTextControl::SetDrawingArea(weld::DrawingArea* pDrawingArea)
+{
+    SvtValueSet::SetDrawingArea(pDrawingArea);
+
+    Size aSize(250, 300);
+    pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
+    SetOutputSizePixel(aSize);
+
+    SetColCount();
+}
 
 void ValueSetWithTextControl::AddItem(
     const OUString& rItemText,
@@ -88,7 +98,7 @@ void ValueSetWithTextControl::UserDraw( const UserDrawEvent& rUDEvt )
         }
         else
         {
-            aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
+            aFont.SetColor( Application::GetSettings().GetStyleSettings().GetFieldTextColor() );
         }
 
         tools::Rectangle aStrRect = aRect;
diff --git a/sw/inc/PageSizePopup.hxx b/sw/inc/PageSizePopup.hxx
index 5f7354bb3da1..497f76dce24a 100644
--- a/sw/inc/PageSizePopup.hxx
+++ b/sw/inc/PageSizePopup.hxx
@@ -28,6 +28,7 @@ public:
     PageSizePopup(const css::uno::Reference<css::uno::XComponentContext>& rContext);
     virtual ~PageSizePopup() override;
 
+    virtual std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override;
     using svt::ToolboxController::createPopupWindow;
     virtual VclPtr<vcl::Window> createPopupWindow( vcl::Window* pParent ) override;
 
diff --git a/sw/source/uibase/sidebar/PageSizeControl.cxx b/sw/source/uibase/sidebar/PageSizeControl.cxx
index dc33541466b9..2bc18689dd4b 100644
--- a/sw/source/uibase/sidebar/PageSizeControl.cxx
+++ b/sw/source/uibase/sidebar/PageSizeControl.cxx
@@ -70,27 +70,20 @@ namespace
 
 namespace sw { namespace sidebar {
 
-PageSizeControl::PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent)
-    : ToolbarPopup(pControl->getFrameInterface(), pParent, "PageSizeControl", "modules/swriter/ui/pagesizecontrol.ui")
+PageSizeControl::PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent)
+    : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "modules/swriter/ui/pagesizecontrol.ui", "PageSizeControl")
+    , mxMoreButton(m_xBuilder->weld_button("moreoptions"))
+    , mxWidthHeightField(m_xBuilder->weld_metric_spin_button("metric", FieldUnit::CM))
+    , mxSizeValueSet(new svx::sidebar::ValueSetWithTextControl)
+    , mxSizeValueSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxSizeValueSet))
+    , mxControl(pControl)
     , maPaperList()
 {
-    get(maMoreButton, "moreoptions");
-    get(maContainer, "container");
-    mpSizeValueSet = VclPtr<svx::sidebar::ValueSetWithTextControl>::Create( maContainer.get(), WB_BORDER );
-
-    // Avoid flicker when hovering over the menu items.
-    if (!IsNativeControlSupported(ControlType::Pushbutton, ControlPart::Focus))
-        // If NWF renders the focus rects itself, that breaks double-buffering.
-        mpSizeValueSet->RequestDoubleBuffering(true);
-
-    maWidthHeightField = VclPtr<MetricField>::Create( maContainer.get(), 0 );
-    maWidthHeightField->Hide();
-    maWidthHeightField->SetUnit(FieldUnit::CM);
-    maWidthHeightField->SetMax(9999);
-    maWidthHeightField->SetDecimalDigits(2);
-    maWidthHeightField->SetSpinSize(10);
-    maWidthHeightField->SetLast(9999);
-    SetFieldUnit( *maWidthHeightField, lcl_GetFieldUnit() );
+    mxWidthHeightField->set_unit(FieldUnit::CM);
+    mxWidthHeightField->set_range(0, 9999, FieldUnit::NONE);
+    mxWidthHeightField->set_digits(2);
+    mxWidthHeightField->set_increments(10, 100, FieldUnit::NONE);
+    SetFieldUnit( *mxWidthHeightField, lcl_GetFieldUnit() );
 
     maPaperList.push_back( PAPER_A3 );
     maPaperList.push_back( PAPER_A4 );
@@ -101,14 +94,14 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent)
     maPaperList.push_back( PAPER_LETTER );
     maPaperList.push_back( PAPER_LEGAL );
 
-    mpSizeValueSet->SetStyle( mpSizeValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
-    mpSizeValueSet->SetColor( GetSettings().GetStyleSettings().GetMenuColor() );
+    mxSizeValueSet->SetStyle( mxSizeValueSet->GetStyle() | WB_3DLOOK | WB_NO_DIRECTSELECT );
+    mxSizeValueSet->SetColor( Application::GetSettings().GetStyleSettings().GetMenuColor() );
 
     sal_uInt16 nSelectedItem = 0;
     {
         OUString aMetricStr;
         {
-            const OUString aText = maWidthHeightField->GetText();
+            const OUString aText = mxWidthHeightField->get_text();
             for (short i = aText.getLength() - 1; i >= 0; i--)
             {
                 sal_Unicode c = aText[i];
@@ -137,7 +130,7 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent)
             pSize = static_cast<const SvxSizeItem*>(pItem);
         }
 
-        const LocaleDataWrapper& localeDataWrapper = maWidthHeightField->GetLocaleDataWrapper();
+        const LocaleDataWrapper& localeDataWrapper = Application::GetSettings().GetLocaleDataWrapper();
         OUString aWidthStr;
         OUString aHeightStr;
         OUString aItemText2;
@@ -151,23 +144,23 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent)
                 Swap( aPaperSize );
             }
 
-            maWidthHeightField->SetValue( maWidthHeightField->Normalize( aPaperSize.Width() ), FieldUnit::TWIP );
+            mxWidthHeightField->set_value( mxWidthHeightField->normalize( aPaperSize.Width() ), FieldUnit::TWIP );
             aWidthStr = localeDataWrapper.getNum(
-                maWidthHeightField->GetValue(),
-                maWidthHeightField->GetDecimalDigits(),
-                maWidthHeightField->IsUseThousandSep(),
-                maWidthHeightField->IsShowTrailingZeros() );
+                mxWidthHeightField->get_value(FieldUnit::NONE),
+                mxWidthHeightField->get_digits(),
+                true,
+                true );
 
-            maWidthHeightField->SetValue( maWidthHeightField->Normalize( aPaperSize.Height() ), FieldUnit::TWIP);
+            mxWidthHeightField->set_value( mxWidthHeightField->normalize( aPaperSize.Height() ), FieldUnit::TWIP);
             aHeightStr = localeDataWrapper.getNum(
-                maWidthHeightField->GetValue(),
-                maWidthHeightField->GetDecimalDigits(),
-                maWidthHeightField->IsUseThousandSep(),
-                maWidthHeightField->IsShowTrailingZeros() );
+                mxWidthHeightField->get_value(FieldUnit::NONE),
+                mxWidthHeightField->get_digits(),
+                true,
+                true );
 
             aItemText2 = aWidthStr + " x " + aHeightStr + " " + aMetricStr;
 
-            mpSizeValueSet->AddItem(
+            mxSizeValueSet->AddItem(
                 SvxPaperInfo::GetName( maPaperList[ nPaperIdx ] ),
                 aItemText2 );
 
@@ -177,32 +170,26 @@ PageSizeControl::PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent)
             }
         }
     }
-    mpSizeValueSet->SetNoSelection();
-    mpSizeValueSet->SetSelectHdl( LINK(this, PageSizeControl, ImplSizeHdl ) );
-    mpSizeValueSet->Show();
-    mpSizeValueSet->Resize();
-
-    mpSizeValueSet->SelectItem( nSelectedItem );
-    mpSizeValueSet->SetFormat();
-    mpSizeValueSet->Invalidate();
-    mpSizeValueSet->StartSelection();
-
-    maMoreButton->SetClickHdl( LINK( this, PageSizeControl, MoreButtonClickHdl_Impl ) );
-    maMoreButton->GrabFocus();
+    mxSizeValueSet->SetNoSelection();
+    mxSizeValueSet->SetSelectHdl( LINK(this, PageSizeControl, ImplSizeHdl ) );
+    mxSizeValueSet->Show();
+    mxSizeValueSet->Resize();
+
+    mxSizeValueSet->SelectItem( nSelectedItem );
+    mxSizeValueSet->SetFormat();
+    mxSizeValueSet->Invalidate();
+
+    mxMoreButton->connect_clicked( LINK( this, PageSizeControl, MoreButtonClickHdl_Impl ) );
+    mxMoreButton->grab_focus();
 }
 
-PageSizeControl::~PageSizeControl()
+void PageSizeControl::GrabFocus()
 {
-    disposeOnce();
+    mxSizeValueSet->GrabFocus();
 }
 
-void PageSizeControl::dispose()
+PageSizeControl::~PageSizeControl()
 {
-    mpSizeValueSet.disposeAndClear();
-    maMoreButton.disposeAndClear();
-    maWidthHeightField.disposeAndClear();
-    maContainer.disposeAndClear();
-    ToolbarPopup::dispose();
 }
 
 void PageSizeControl::ExecuteSizeChange( const Paper ePaper )
@@ -229,24 +216,21 @@ void PageSizeControl::ExecuteSizeChange( const Paper ePaper )
 }
 
 
-IMPL_LINK(PageSizeControl, ImplSizeHdl, ValueSet*, pControl, void)
+IMPL_LINK_NOARG(PageSizeControl, ImplSizeHdl, SvtValueSet*, void)
 {
-    mpSizeValueSet->SetNoSelection();
-    if ( pControl == mpSizeValueSet )
-    {
-        const sal_uInt16 nSelectedPaper = mpSizeValueSet->GetSelectedItemId();
-        const Paper ePaper = maPaperList[nSelectedPaper - 1];
-        ExecuteSizeChange( ePaper );
-    }
+    mxSizeValueSet->SetNoSelection();
+    const sal_uInt16 nSelectedPaper = mxSizeValueSet->GetSelectedItemId();
+    const Paper ePaper = maPaperList[nSelectedPaper - 1];
+    ExecuteSizeChange( ePaper );
 
-    EndPopupMode();
+    mxControl->EndPopupMode();
 }
 
-IMPL_LINK_NOARG(PageSizeControl, MoreButtonClickHdl_Impl, Button*, void)
+IMPL_LINK_NOARG(PageSizeControl, MoreButtonClickHdl_Impl, weld::Button&, void)
 {
     if ( SfxViewFrame::Current() )
         SfxViewFrame::Current()->GetDispatcher()->Execute( FN_FORMAT_PAGE_SETTING_DLG, SfxCallMode::ASYNCHRON );
-    EndPopupMode();
+    mxControl->EndPopupMode();
 }
 
 } } // end of namespace sw::sidebar
diff --git a/sw/source/uibase/sidebar/PageSizeControl.hxx b/sw/source/uibase/sidebar/PageSizeControl.hxx
index 695140f6a4f6..fe9fea33a3cf 100644
--- a/sw/source/uibase/sidebar/PageSizeControl.hxx
+++ b/sw/source/uibase/sidebar/PageSizeControl.hxx
@@ -21,10 +21,6 @@
 
 #include <i18nutil/paper.hxx>
 
-#include <vcl/button.hxx>
-#include <vcl/field.hxx>
-#include <vcl/layout.hxx>
-
 #include <svtools/toolbarmenu.hxx>
 #include <svtools/valueset.hxx>
 
@@ -35,30 +31,31 @@ namespace svx { namespace sidebar {
 } }
 
 class PageSizePopup;
-class ValueSet;
+class SvtValueSet;
 
 namespace sw { namespace sidebar {
 
-class PageSizeControl final : public svtools::ToolbarPopup
+class PageSizeControl final : public WeldToolbarPopup
 {
 public:
-    explicit PageSizeControl(PageSizePopup* pControl, vcl::Window* pParent);
+    explicit PageSizeControl(PageSizePopup* pControl, weld::Widget* pParent);
+    virtual void GrabFocus() override;
     virtual ~PageSizeControl() override;
-    virtual void dispose() override;
 
 private:
-    VclPtr<VclVBox> maContainer;
-    VclPtr<svx::sidebar::ValueSetWithTextControl> mpSizeValueSet;
-    VclPtr<PushButton> maMoreButton;
+    std::unique_ptr<weld::Button> mxMoreButton;
     // hidden metric field
-    VclPtr<MetricField> maWidthHeightField;
+    std::unique_ptr<weld::MetricSpinButton> mxWidthHeightField;
+    std::unique_ptr<svx::sidebar::ValueSetWithTextControl> mxSizeValueSet;
+    std::unique_ptr<weld::CustomWeld> mxSizeValueSetWin;
+    rtl::Reference<PageSizePopup> mxControl;
 
     std::vector< Paper > maPaperList;
 
     static void ExecuteSizeChange( const Paper ePaper );
 
-    DECL_LINK(ImplSizeHdl, ::ValueSet*, void);
-    DECL_LINK(MoreButtonClickHdl_Impl, Button*, void);
+    DECL_LINK(ImplSizeHdl, SvtValueSet*, void);
+    DECL_LINK(MoreButtonClickHdl_Impl, weld::Button&, void);
 };
 
 } } // end of namespace sw::sidebar
diff --git a/sw/source/uibase/sidebar/PageSizePopup.cxx b/sw/source/uibase/sidebar/PageSizePopup.cxx
index b68e714d1713..0ff79de5743b 100644
--- a/sw/source/uibase/sidebar/PageSizePopup.cxx
+++ b/sw/source/uibase/sidebar/PageSizePopup.cxx
@@ -40,9 +40,19 @@ PageSizePopup::~PageSizePopup()
 {
 }
 
-VclPtr<vcl::Window> PageSizePopup::createPopupWindow(vcl::Window* pParent)
+std::unique_ptr<WeldToolbarPopup> PageSizePopup::weldPopupWindow()
 {
-    return VclPtr<sw::sidebar::PageSizeControl>::Create(this, pParent);
+    return std::make_unique<sw::sidebar::PageSizeControl>(this, m_pToolbar);
+}
+
+VclPtr<vcl::Window> PageSizePopup::createPopupWindow( vcl::Window* pParent )
+{
+    mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
+        std::make_unique<sw::sidebar::PageSizeControl>(this, pParent->GetFrameWeld()));
+
+    mxInterimPopover->Show();
+
+    return mxInterimPopover;
 }
 
 OUString PageSizePopup::getImplementationName()
diff --git a/sw/uiconfig/swriter/ui/pagesizecontrol.ui b/sw/uiconfig/swriter/ui/pagesizecontrol.ui
index 541d357e96c8..45d25b371513 100644
--- a/sw/uiconfig/swriter/ui/pagesizecontrol.ui
+++ b/sw/uiconfig/swriter/ui/pagesizecontrol.ui
@@ -1,43 +1,68 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
 <interface domain="sw">
   <requires lib="gtk+" version="3.18"/>
-  <object class="GtkImage" id="image_portrait7">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="pixbuf">cmd/lc_orientation.png</property>
-  </object>
-  <object class="GtkWindow" id="PageSizeControl">
+  <object class="GtkPopover" id="PageSizeControl">
     <property name="can_focus">False</property>
-    <property name="hexpand">True</property>
-    <property name="vexpand">True</property>
+    <property name="no_show_all">True</property>
     <property name="border_width">4</property>
-    <property name="resizable">False</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="type_hint">popup-menu</property>
-    <property name="skip_pager_hint">True</property>
-    <property name="deletable">False</property>
     <child>
-      <object class="GtkBox" id="box">
+      <object class="GtkBox" id="container">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
-        <property name="margin_right">6</property>
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
         <property name="orientation">vertical</property>
         <property name="spacing">6</property>
         <child>
-          <object class="GtkBox" id="container">
-            <property name="width_request">250</property>
-            <property name="height_request">300</property>
+          <object class="GtkBox" id="box">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="hexpand">True</property>
             <property name="vexpand">True</property>
             <property name="orientation">vertical</property>
-            <property name="homogeneous">True</property>
             <child>
-              <placeholder/>
+              <object class="GtkScrolledWindow" id="valuesetwin">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="hscrollbar_policy">never</property>
+                <property name="vscrollbar_policy">never</property>
+                <property name="shadow_type">in</property>
+                <child>
+                  <object class="GtkViewport">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkDrawingArea" id="valueset">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="events">GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK</property>
+                        <property name="hexpand">True</property>
+                        <property name="vexpand">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSpinButton" id="metric">
+                <property name="can_focus">True</property>
+                <property name="no_show_all">True</property>
+                <property name="adjustment">adjustment1</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
             </child>
           </object>
           <packing>
@@ -66,4 +91,14 @@
       </object>
     </child>
   </object>
+  <object class="GtkAdjustment" id="adjustment1">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkImage" id="image_portrait7">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="icon_name">cmd/lc_orientation.png</property>
+  </object>
 </interface>


More information about the Libreoffice-commits mailing list