[Libreoffice-commits] core.git: extras/source include/svtools sd/source sd/uiconfig solenv/bin

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Dec 20 16:41:52 UTC 2019


 extras/source/glade/libreoffice-catalog.xml.in |    3 
 include/svtools/valueset.hxx                   |    4 +
 sd/source/ui/table/TableDesignPane.cxx         |   92 ++++++++++++-------------
 sd/source/ui/table/TableDesignPane.hxx         |   30 ++++----
 sd/uiconfig/simpress/ui/tabledesignpanel.ui    |   25 +++++-
 solenv/bin/native-code.py                      |    1 
 6 files changed, 91 insertions(+), 64 deletions(-)

New commits:
commit a9f116527351a2e3fccee6152afb58c89226d0b2
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Dec 20 12:02:33 2019 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Dec 20 17:40:33 2019 +0100

    weld TableDesignPane
    
    Change-Id: Ia5a83df5e509f899ec9248272c9b9fb43d4444f7
    Reviewed-on: https://gerrit.libreoffice.org/85599
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 318bee73db31..0b645e40484a 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -86,9 +86,6 @@
     <glade-widget-class title="SvxColorValueSet" name="svxcorelo-SvxColorValueSet"
                         generic-name="Set of Value Options" parent="GtkDrawingArea"
                         icon-name="widget-gtk-drawingarea"/>
-    <glade-widget-class title="TableValueSet" name="sdlo-TableValueSet"
-                        generic-name="Set of Table Value Options" parent="GtkDrawingArea"
-                        icon-name="widget-gtk-drawingarea"/>
 
     <glade-widget-class title="Content List Box" name="sfxlo-ContentListBox"
                         generic-name="Content List Box" parent="GtkTreeView"
diff --git a/include/svtools/valueset.hxx b/include/svtools/valueset.hxx
index cc56488e4c01..72d6fc0a38c7 100644
--- a/include/svtools/valueset.hxx
+++ b/include/svtools/valueset.hxx
@@ -554,6 +554,10 @@ public:
     void            SetItemText( sal_uInt16 nItemId, const OUString& rStr );
     OUString        GetItemText( sal_uInt16 nItemId ) const;
     void            SetColor( const Color& rColor );
+    void            SetColor()
+    {
+        SetColor(COL_TRANSPARENT);
+    }
     bool            IsColor() const
     {
         return maColor.GetTransparency() == 0;
diff --git a/sd/source/ui/table/TableDesignPane.cxx b/sd/source/ui/table/TableDesignPane.cxx
index 0c482885de2d..a9204c29c3df 100644
--- a/sd/source/ui/table/TableDesignPane.cxx
+++ b/sd/source/ui/table/TableDesignPane.cxx
@@ -83,20 +83,21 @@ static const OUStringLiteral gPropNames[CB_COUNT] =
     "UseBandingColumnStyle"
 };
 
-TableDesignWidget::TableDesignWidget( VclBuilderContainer* pParent, ViewShellBase& rBase )
+TableDesignWidget::TableDesignWidget(weld::Builder& rBuilder, ViewShellBase& rBase)
     : mrBase(rBase)
+    , m_xValueSet(new TableValueSet(rBuilder.weld_scrolled_window("previewswin")))
+    , m_xValueSetWin(new weld::CustomWeld(rBuilder, "previews", *m_xValueSet))
 {
-    pParent->get(m_pValueSet, "previews");
-    m_pValueSet->SetStyle(m_pValueSet->GetStyle() | WB_NO_DIRECTSELECT | WB_FLATVALUESET | WB_ITEMBORDER);
-    m_pValueSet->SetExtraSpacing(8);
-    m_pValueSet->setModal(false);
-    m_pValueSet->SetColor();
-    m_pValueSet->SetSelectHdl (LINK(this, TableDesignWidget, implValueSetHdl));
+    m_xValueSet->SetStyle(m_xValueSet->GetStyle() | WB_NO_DIRECTSELECT | WB_FLATVALUESET | WB_ITEMBORDER);
+    m_xValueSet->SetExtraSpacing(8);
+    m_xValueSet->setModal(false);
+    m_xValueSet->SetColor();
+    m_xValueSet->SetSelectHdl(LINK(this, TableDesignWidget, implValueSetHdl));
 
     for (sal_uInt16 i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i)
     {
-        pParent->get(m_aCheckBoxes[i], OString(gPropNames[i].data, gPropNames[i].size));
-        m_aCheckBoxes[i]->SetClickHdl( LINK( this, TableDesignWidget, implCheckBoxHdl ) );
+        m_aCheckBoxes[i] = rBuilder.weld_check_button(OString(gPropNames[i].data, gPropNames[i].size));
+        m_aCheckBoxes[i]->connect_toggled(LINK(this, TableDesignWidget, implCheckBoxHdl));
     }
 
     // get current controller and initialize listeners
@@ -141,7 +142,7 @@ static SfxDispatcher* getDispatcher( ViewShellBase const & rBase )
         return nullptr;
 }
 
-IMPL_LINK_NOARG(TableDesignWidget, implValueSetHdl, ValueSet*, void)
+IMPL_LINK_NOARG(TableDesignWidget, implValueSetHdl, SvtValueSet*, void)
 {
     ApplyStyle();
 }
@@ -151,7 +152,7 @@ void TableDesignWidget::ApplyStyle()
     try
     {
         OUString sStyleName;
-        sal_Int32 nIndex = static_cast< sal_Int32 >( m_pValueSet->GetSelectedItemId() ) - 1;
+        sal_Int32 nIndex = static_cast< sal_Int32 >( m_xValueSet->GetSelectedItemId() ) - 1;
 
         if( (nIndex >= 0) && (nIndex < mxTableFamily->getCount()) )
         {
@@ -196,7 +197,7 @@ void TableDesignWidget::ApplyStyle()
     }
 }
 
-IMPL_LINK_NOARG(TableDesignWidget, implCheckBoxHdl, Button*, void)
+IMPL_LINK_NOARG(TableDesignWidget, implCheckBoxHdl, weld::ToggleButton&, void)
 {
     ApplyOptions();
     FillDesignPreviewControl();
@@ -217,7 +218,7 @@ void TableDesignWidget::ApplyOptions()
 
     for( sal_uInt16 i = CB_HEADER_ROW; i <= CB_BANDED_COLUMNS; ++i )
     {
-        aReq.AppendItem( SfxBoolItem( gParamIds[i], m_aCheckBoxes[i]->IsChecked() ) );
+        aReq.AppendItem( SfxBoolItem( gParamIds[i], m_aCheckBoxes[i]->get_active() ) );
     }
 
     SdrView* pView = mrBase.GetDrawView();
@@ -279,12 +280,12 @@ void TableDesignWidget::onSelectionChanged()
 
 void TableValueSet::Resize()
 {
-    ValueSet::Resize();
+    SvtValueSet::Resize();
     // Calculate the number of rows and columns.
     if( GetItemCount() <= 0 )
         return;
 
-    Size aValueSetSize = GetSizePixel();
+    Size aValueSetSize = GetOutputSizePixel();
 
     Image aImage = GetItemImage(GetItemId(0));
     Size aItemSize = aImage.GetSizePixel();
@@ -314,13 +315,13 @@ void TableValueSet::Resize()
     }
 }
 
-TableValueSet::TableValueSet(Window *pParent, WinBits nStyle)
-    : ValueSet(pParent, nStyle)
+TableValueSet::TableValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow)
+    : SvtValueSet(std::move(pScrolledWindow))
     , m_bModal(false)
 {
 }
 
-void TableValueSet::DataChanged( const DataChangedEvent& /*rDCEvt*/ )
+void TableValueSet::StyleUpdated()
 {
     updateSettings();
 }
@@ -329,14 +330,12 @@ void TableValueSet::updateSettings()
 {
     if( !m_bModal )
     {
-        SetBackground( GetSettings().GetStyleSettings().GetWindowColor() );
-        SetColor( GetSettings().GetStyleSettings().GetWindowColor() );
+        Color aColor = Application::GetSettings().GetStyleSettings().GetWindowColor();
+        SetColor(aColor);
         SetExtraSpacing(8);
     }
 }
 
-VCL_BUILDER_FACTORY_CONSTRUCTOR(TableValueSet, WB_TABSTOP)
-
 void TableDesignWidget::updateControls()
 {
     static const bool gDefaults[CB_COUNT] = { true, false, true, false, false, false };
@@ -354,13 +353,13 @@ void TableDesignWidget::updateControls()
         {
             OSL_FAIL("sd::TableDesignWidget::updateControls(), exception caught!");
         }
-        m_aCheckBoxes[i]->Check(bUse);
-        m_aCheckBoxes[i]->Enable(bHasTable);
+        m_aCheckBoxes[i]->set_active(bUse);
+        m_aCheckBoxes[i]->set_sensitive(bHasTable);
     }
 
     FillDesignPreviewControl();
-    m_pValueSet->updateSettings();
-    m_pValueSet->Resize();
+    m_xValueSet->updateSettings();
+    m_xValueSet->Resize();
 
     sal_uInt16 nSelection = 0;
     if( mxSelectedTable.is() )
@@ -380,7 +379,7 @@ void TableDesignWidget::updateControls()
             }
         }
     }
-    m_pValueSet->SelectItem( nSelection );
+    m_xValueSet->SelectItem( nSelection );
 }
 
 void TableDesignWidget::addListener()
@@ -697,19 +696,19 @@ static BitmapEx CreateDesignPreview( const Reference< XIndexAccess >& xTableStyl
 
 void TableDesignWidget::FillDesignPreviewControl()
 {
-    sal_uInt16 nSelectedItem = m_pValueSet->GetSelectedItemId();
-    m_pValueSet->Clear();
+    sal_uInt16 nSelectedItem = m_xValueSet->GetSelectedItemId();
+    m_xValueSet->Clear();
     try
     {
         TableStyleSettings aSettings;
         if( mxSelectedTable.is() )
         {
-            aSettings.mbUseFirstRow = m_aCheckBoxes[CB_HEADER_ROW]->IsChecked();
-            aSettings.mbUseLastRow = m_aCheckBoxes[CB_TOTAL_ROW]->IsChecked();
-            aSettings.mbUseRowBanding = m_aCheckBoxes[CB_BANDED_ROWS]->IsChecked();
-            aSettings.mbUseFirstColumn = m_aCheckBoxes[CB_FIRST_COLUMN]->IsChecked();
-            aSettings.mbUseLastColumn = m_aCheckBoxes[CB_LAST_COLUMN]->IsChecked();
-            aSettings.mbUseColumnBanding = m_aCheckBoxes[CB_BANDED_COLUMNS]->IsChecked();
+            aSettings.mbUseFirstRow = m_aCheckBoxes[CB_HEADER_ROW]->get_active();
+            aSettings.mbUseLastRow = m_aCheckBoxes[CB_TOTAL_ROW]->get_active();
+            aSettings.mbUseRowBanding = m_aCheckBoxes[CB_BANDED_ROWS]->get_active();
+            aSettings.mbUseFirstColumn = m_aCheckBoxes[CB_FIRST_COLUMN]->get_active();
+            aSettings.mbUseLastColumn = m_aCheckBoxes[CB_LAST_COLUMN]->get_active();
+            aSettings.mbUseColumnBanding = m_aCheckBoxes[CB_BANDED_COLUMNS]->get_active();
         }
 
         bool bIsPageDark = false;
@@ -728,7 +727,7 @@ void TableDesignWidget::FillDesignPreviewControl()
         {
             Reference< XIndexAccess > xTableStyle( mxTableFamily->getByIndex( nIndex ), UNO_QUERY );
             if( xTableStyle.is() )
-                m_pValueSet->InsertItem( sal::static_int_cast<sal_uInt16>( nIndex + 1 ), Image( CreateDesignPreview( xTableStyle, aSettings, bIsPageDark ) ) );
+                m_xValueSet->InsertItem( sal::static_int_cast<sal_uInt16>( nIndex + 1 ), Image( CreateDesignPreview( xTableStyle, aSettings, bIsPageDark ) ) );
         }
         catch( Exception& )
         {
@@ -736,22 +735,25 @@ void TableDesignWidget::FillDesignPreviewControl()
         }
         sal_Int32 nCols = 3;
         sal_Int32 nRows = (nCount+2)/3;
-        m_pValueSet->SetColCount(nCols);
-        m_pValueSet->SetLineCount(nRows);
-        WinBits nStyle = m_pValueSet->GetStyle() & ~WB_VSCROLL;
-        m_pValueSet->SetStyle(nStyle);
-        Size aSize(m_pValueSet->GetOptimalSize());
+        m_xValueSet->SetColCount(nCols);
+        m_xValueSet->SetLineCount(nRows);
+        WinBits nStyle = m_xValueSet->GetStyle() & ~WB_VSCROLL;
+        m_xValueSet->SetStyle(nStyle);
+
+        m_xValueSet->SetOptimalSize();
+        weld::DrawingArea* pDrawingArea = m_xValueSet->GetDrawingArea();
+        Size aSize = pDrawingArea->get_preferred_size();
         aSize.AdjustWidth(10 * nCols);
         aSize.AdjustHeight(10 * nRows);
-        m_pValueSet->set_width_request(aSize.Width());
-        m_pValueSet->set_height_request(aSize.Height());
-        m_pValueSet->Resize();
+        pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
+
+        m_xValueSet->Resize();
     }
     catch( Exception& )
     {
         OSL_FAIL("sd::TableDesignWidget::FillDesignPreviewControl(), exception caught!");
     }
-    m_pValueSet->SelectItem(nSelectedItem);
+    m_xValueSet->SelectItem(nSelectedItem);
 }
 
 VclPtr<vcl::Window> createTableDesignPanel( vcl::Window* pParent, ViewShellBase& rBase )
diff --git a/sd/source/ui/table/TableDesignPane.hxx b/sd/source/ui/table/TableDesignPane.hxx
index cdc86851ea9f..305036d2a405 100644
--- a/sd/source/ui/table/TableDesignPane.hxx
+++ b/sd/source/ui/table/TableDesignPane.hxx
@@ -21,8 +21,8 @@
 #define INCLUDED_SD_SOURCE_UI_TABLE_TABLEDESIGNPANE_HXX
 
 #include <svtools/valueset.hxx>
-#include <vcl/button.hxx>
 #include <svx/sidebar/PanelLayout.hxx>
+#include <vcl/weld.hxx>
 
 namespace com { namespace sun { namespace star { namespace beans { class XPropertySet; } } } }
 namespace com { namespace sun { namespace star { namespace container { class XIndexAccess; } } } }
@@ -48,14 +48,14 @@ enum TableCheckBox : sal_uInt16
     CB_COUNT            = CB_BANDED_COLUMNS + 1
 };
 
-class TableValueSet : public ValueSet
+class TableValueSet : public SvtValueSet
 {
 private:
     bool m_bModal;
 public:
-    TableValueSet(vcl::Window *pParent, WinBits nStyle);
+    TableValueSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow);
     virtual void Resize() override;
-    virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
+    virtual void StyleUpdated() override;
     void updateSettings();
     void setModal(bool bModal) { m_bModal = bModal; }
 };
@@ -63,7 +63,7 @@ public:
 class TableDesignWidget final
 {
 public:
-    TableDesignWidget( VclBuilderContainer* pParent, ViewShellBase& rBase );
+    TableDesignWidget(weld::Builder& rBuilder, ViewShellBase& rBase);
     ~TableDesignWidget();
 
     // callbacks
@@ -80,14 +80,15 @@ private:
     void FillDesignPreviewControl();
 
     DECL_LINK(EventMultiplexerListener, tools::EventMultiplexerEvent&, void);
-    DECL_LINK(implValueSetHdl, ValueSet*, void);
-    DECL_LINK(implCheckBoxHdl, Button*, void);
+    DECL_LINK(implValueSetHdl, SvtValueSet*, void);
+    DECL_LINK(implCheckBoxHdl, weld::ToggleButton&, void);
 
 private:
     ViewShellBase& mrBase;
 
-    VclPtr<TableValueSet> m_pValueSet;
-    VclPtr<CheckBox> m_aCheckBoxes[CB_COUNT];
+    std::unique_ptr<TableValueSet> m_xValueSet;
+    std::unique_ptr<weld::CustomWeld> m_xValueSetWin;
+    std::unique_ptr<weld::CheckButton> m_aCheckBoxes[CB_COUNT];
 
     css::uno::Reference< css::beans::XPropertySet > mxSelectedTable;
     css::uno::Reference< css::drawing::XDrawView > mxView;
@@ -97,14 +98,19 @@ private:
 class TableDesignPane : public PanelLayout
 {
 private:
-    TableDesignWidget const aImpl;
+    std::unique_ptr<TableDesignWidget> m_xImpl;
 public:
     TableDesignPane( vcl::Window* pParent, ViewShellBase& rBase )
         : PanelLayout(pParent, "TableDesignPanel",
-        "modules/simpress/ui/tabledesignpanel.ui", css::uno::Reference<css::frame::XFrame>())
-        , aImpl(this, rBase)
+            "modules/simpress/ui/tabledesignpanel.ui", css::uno::Reference<css::frame::XFrame>(), true)
+        , m_xImpl(new TableDesignWidget(*m_xBuilder, rBase))
     {
     }
+    virtual void dispose() override
+    {
+        m_xImpl.reset();
+        PanelLayout::dispose();
+    }
 };
 
 }
diff --git a/sd/uiconfig/simpress/ui/tabledesignpanel.ui b/sd/uiconfig/simpress/ui/tabledesignpanel.ui
index 28833b46e9ea..9fb14cecce6f 100644
--- a/sd/uiconfig/simpress/ui/tabledesignpanel.ui
+++ b/sd/uiconfig/simpress/ui/tabledesignpanel.ui
@@ -2,10 +2,10 @@
 <!-- Generated with glade 3.22.1 -->
 <interface domain="sd">
   <requires lib="gtk+" version="3.18"/>
-  <requires lib="LibreOffice" version="1.0"/>
   <object class="GtkBox" id="TableDesignPanel">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
+    <property name="valign">start</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
     <property name="orientation">vertical</property>
@@ -109,10 +109,29 @@
           </packing>
         </child>
         <child>
-          <object class="sdlo-TableValueSet" id="previews:border">
+          <object class="GtkScrolledWindow" id="previewswin">
             <property name="visible">True</property>
-            <property name="can_focus">False</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="previews">
+                    <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="left_attach">0</property>
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 8b5dee4022d0..ef08aa6c618f 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -508,7 +508,6 @@ custom_widgets = [
     'SvxLightCtl3D',
     'SvxRelativeField',
     'SwNavHelpToolBox',
-    'TableValueSet',
     'TemplateDefaultView',
     ]
 


More information about the Libreoffice-commits mailing list