[Libreoffice-commits] core.git: 2 commits - lotuswordpro/qa lotuswordpro/source solenv/sanitizers svx/source svx/uiconfig svx/UIConfig_svx.mk

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Feb 7 19:49:24 UTC 2020


 lotuswordpro/qa/cppunit/data/pass/ofz20517-1.lwp |binary
 lotuswordpro/source/filter/lwprowlayout.cxx      |    4 
 solenv/sanitizers/ui/svx.suppr                   |    1 
 svx/UIConfig_svx.mk                              |    1 
 svx/source/tbxctrls/grafctrl.cxx                 |  191 +++++++----------------
 svx/uiconfig/ui/grafctrlbox.ui                   |   41 ++++
 6 files changed, 112 insertions(+), 126 deletions(-)

New commits:
commit 75bd1ba4cd4eea179092f3c8fd7aa6b903b17993
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 7 13:25:08 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 7 20:49:04 2020 +0100

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

diff --git a/solenv/sanitizers/ui/svx.suppr b/solenv/sanitizers/ui/svx.suppr
index 0c4cd85cf614..2037cc5c2d90 100644
--- a/solenv/sanitizers/ui/svx.suppr
+++ b/solenv/sanitizers/ui/svx.suppr
@@ -40,6 +40,7 @@ svx/uiconfig/ui/findreplacedialog.ui://GtkLabel[@id='searchdir'] orphan-label
 svx/uiconfig/ui/floatingcontour.ui://GtkLabel[@id='statuspos'] orphan-label
 svx/uiconfig/ui/floatingcontour.ui://GtkLabel[@id='statussize'] orphan-label
 svx/uiconfig/ui/fontworkgallerydialog.ui://GtkLabel[@id='label1'] orphan-label
+svx/uiconfig/ui/grafctrlbox.ui://GtkSpinButton[@id='spinfield'] no-labelled-by
 svx/uiconfig/ui/headfootformatpage.ui://GtkLabel[@id='labelHeaderFormat'] orphan-label
 svx/uiconfig/ui/headfootformatpage.ui://GtkLabel[@id='labelFooterFormat'] orphan-label
 svx/uiconfig/ui/imapdialog.ui://GtkLabel[@id='statusurl'] orphan-label
diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk
index d43fb789f426..69a7e7ea6e92 100644
--- a/svx/UIConfig_svx.mk
+++ b/svx/UIConfig_svx.mk
@@ -68,6 +68,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\
 	svx/uiconfig/ui/functionmenu \
 	svx/uiconfig/ui/gallerymenu1 \
 	svx/uiconfig/ui/gallerymenu2 \
+	svx/uiconfig/ui/grafctrlbox \
 	svx/uiconfig/ui/grafmodebox \
 	svx/uiconfig/ui/headfootformatpage \
 	svx/uiconfig/ui/imapdialog \
diff --git a/svx/source/tbxctrls/grafctrl.cxx b/svx/source/tbxctrls/grafctrl.cxx
index 3f8c084e06f7..dbbea77c8d37 100644
--- a/svx/source/tbxctrls/grafctrl.cxx
+++ b/svx/source/tbxctrls/grafctrl.cxx
@@ -72,78 +72,50 @@ using namespace ::com::sun::star::lang;
 
 #include <svx/svxdlg.hxx>
 
-#define SYMBOL_TO_FIELD_OFFSET      4
 #define TOOLBOX_NAME                "colorbar"
 #define RID_SVXSTR_UNDO_GRAFCROP    RID_SVXSTR_GRAFCROP
 
 namespace {
 
-class ImplGrafMetricField : public MetricField
+class ImplGrafControl final : public InterimItemWindow
 {
-    using Window::Update;
-
 private:
-    Idle                maIdle;
-    OUString const      maCommand;
-    Reference< XFrame > mxFrame;
-
-                    DECL_LINK(ImplModifyHdl, Timer *, void);
-
-protected:
+    Idle maIdle;
+    OUString maCommand;
+    Reference<XFrame> mxFrame;
+    std::unique_ptr<weld::Image> mxImage;
+    std::unique_ptr<weld::MetricSpinButton> mxField;
 
-    virtual void    Modify() override;
+    DECL_LINK(ValueChangedHdl, weld::MetricSpinButton&, void);
+    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+    DECL_LINK(ImplModifyHdl, Timer*, void);
 
 public:
-                    ImplGrafMetricField( vcl::Window* pParent, const OUString& aCmd, const Reference< XFrame >& rFrame );
-
-    void            Update( const SfxPoolItem* pItem );
-};
-
-}
-
-ImplGrafMetricField::ImplGrafMetricField( vcl::Window* pParent, const OUString& rCmd, const Reference< XFrame >& rFrame ) :
-    MetricField( pParent, WB_BORDER | WB_SPIN | WB_REPEAT | WB_3DLOOK ),
-    maCommand( rCmd ),
-    mxFrame( rFrame )
-{
-    Size aSize(CalcMinimumSizeForText(unicode::formatPercent(-100, Application::GetSettings().GetUILanguageTag())));
-    SetSizePixel(aSize);
-
-    if ( maCommand == ".uno:GrafGamma" )
-    {
-        SetDecimalDigits( 2 );
+    ImplGrafControl( vcl::Window* pParent, const OUString& rCmd, const Reference< XFrame >& rFrame );
+    virtual ~ImplGrafControl() override;
+    virtual void            dispose() override;
 
-        SetMin( 10 );
-        SetFirst( 10 );
-        SetMax( 1000 );
-        SetLast( 1000 );
-        SetSpinSize( 10 );
-    }
-    else
+    virtual void            GetFocus() override;
+    void Update( const SfxPoolItem* pItem );
+    void set_field_text(const OUString& rStr) { mxField->set_text(rStr); }
+    void set_sensitive(bool bSensitive)
     {
-        const long nMinVal = maCommand == ".uno:GrafTransparence" ? 0 : -100;
-
-        SetUnit(FieldUnit::PERCENT);
-        SetDecimalDigits( 0 );
-
-        SetMin( nMinVal );
-        SetFirst( nMinVal );
-        SetMax( 100 );
-        SetLast( 100 );
-        SetSpinSize( 1 );
+        Enable(bSensitive);
+        mxImage->set_sensitive(bSensitive);
+        mxField->set_sensitive(bSensitive);
     }
+};
 
-    maIdle.SetInvokeHandler( LINK( this, ImplGrafMetricField, ImplModifyHdl ) );
 }
 
-void ImplGrafMetricField::Modify()
+IMPL_LINK_NOARG(ImplGrafControl, ValueChangedHdl, weld::MetricSpinButton&, void)
 {
     maIdle.Start();
 }
 
-IMPL_LINK_NOARG(ImplGrafMetricField, ImplModifyHdl, Timer *, void)
+IMPL_LINK_NOARG(ImplGrafControl, ImplModifyHdl, Timer*, void)
 {
-    const sal_Int64 nVal = GetValue();
+    const sal_Int64 nVal = mxField->get_value(FieldUnit::NONE);
 
     // Convert value to an any to be usable with dispatch API
     Any a;
@@ -172,7 +144,7 @@ IMPL_LINK_NOARG(ImplGrafMetricField, ImplModifyHdl, Timer *, void)
     }
 }
 
-void ImplGrafMetricField::Update( const SfxPoolItem* pItem )
+void ImplGrafControl::Update( const SfxPoolItem* pItem )
 {
     if( pItem )
     {
@@ -185,10 +157,10 @@ void ImplGrafMetricField::Update( const SfxPoolItem* pItem )
         else
             nValue = static_cast<const SfxInt16Item*>( pItem )->GetValue();
 
-        SetValue( nValue );
+        mxField->set_value(nValue, FieldUnit::NONE);
     }
     else
-        SetText( OUString() );
+        mxField->set_text(OUString());
 }
 
 namespace {
@@ -231,76 +203,56 @@ static OUString ImplGetRID( const OUString& aCommand )
     return sRID;
 }
 
-namespace {
-
-class ImplGrafControl : public Control
-{
-    using Window::Update;
-private:
-    VclPtr<FixedImage>          maImage;
-    VclPtr<ImplGrafMetricField> maField;
-
-protected:
-
-    virtual void            GetFocus() override;
-
-public:
-
-                            ImplGrafControl( vcl::Window* pParent, const OUString& rCmd, const Reference< XFrame >& rFrame );
-                            virtual ~ImplGrafControl() override;
-    virtual void            dispose() override;
-
-    void                    Update( const SfxPoolItem* pItem ) { maField->Update( pItem ); }
-    void                    SetText( const OUString& rStr ) override { maField->SetText( rStr ); }
-    virtual void            Resize() override;
-};
-
-}
-
 ImplGrafControl::ImplGrafControl(
     vcl::Window* pParent,
     const OUString& rCmd,
-    const Reference< XFrame >& rFrame
-)   : Control( pParent, WB_TABSTOP )
-    , maImage( VclPtr<FixedImage>::Create(this) )
-    , maField( VclPtr<ImplGrafMetricField>::Create(this, rCmd, rFrame) )
+    const Reference< XFrame >& rFrame)
+    : InterimItemWindow(pParent, "svx/ui/grafctrlbox.ui", "GrafCtrlBox")
+    , maCommand(rCmd)
+    , mxFrame(rFrame)
+    , mxImage(m_xBuilder->weld_image("image"))
+    , mxField(m_xBuilder->weld_metric_spin_button("spinfield", FieldUnit::NONE))
 {
     OUString sResId(ImplGetRID(rCmd));
-    BitmapEx aBitmapEx(sResId);
-
-    Size    aImgSize(aBitmapEx.GetSizePixel());
-    Size    aFldSize(maField->GetSizePixel());
-    long    nFldY, nImgY;
-
-    maImage->SetImage(Image(aBitmapEx));
-    maImage->SetSizePixel( aImgSize );
+    mxImage->set_from_icon_name(sResId);
+#if 0
     // we want to see the background of the toolbox, not of the FixedImage or Control
     maImage->SetBackground( Wallpaper( COL_TRANSPARENT ) );
     SetBackground( Wallpaper( COL_TRANSPARENT ) );
+#endif
 
-    if( aImgSize.Height() > aFldSize.Height() )
+    SetBackground( Wallpaper() ); // transparent background
+
+    mxField->set_help_id(OUStringToOString(rCmd, RTL_TEXTENCODING_UTF8));
+    mxField->get_widget().connect_key_press(LINK(this, ImplGrafControl, KeyInputHdl));
+    mxField->connect_value_changed(LINK(this, ImplGrafControl, ValueChangedHdl));
+
+    if (maCommand == ".uno:GrafGamma")
     {
-        nImgY = 0;
-        nFldY = ( aImgSize.Height() - aFldSize.Height() ) >> 1;
+        mxField->set_digits(2);
+
+        mxField->set_range(10, 1000, FieldUnit::NONE);
+        mxField->set_increments(10, 100, FieldUnit::NONE);
     }
     else
     {
-        nFldY = 0;
-        nImgY = ( aFldSize.Height() - aImgSize.Height() ) >> 1;
-    }
+        const long nMinVal = maCommand == ".uno:GrafTransparence" ? 0 : -100;
 
-    long nOffset = SYMBOL_TO_FIELD_OFFSET / 2;
-    maImage->SetPosPixel( Point( nOffset, nImgY ) );
-    maField->SetPosPixel( Point( aImgSize.Width() + SYMBOL_TO_FIELD_OFFSET, nFldY ) );
-    SetSizePixel( Size( aImgSize.Width() + aFldSize.Width() + SYMBOL_TO_FIELD_OFFSET + nOffset,
-                  std::max( aImgSize.Height(), aFldSize.Height() ) ) );
+        mxField->set_unit(FieldUnit::PERCENT);
+        mxField->set_digits(0);
 
-    SetBackground( Wallpaper() ); // transparent background
+        mxField->set_range(nMinVal, 100, FieldUnit::PERCENT);
+        mxField->set_increments(1, 10, FieldUnit::PERCENT);
+    }
 
-    maImage->Show();
+    maIdle.SetInvokeHandler( LINK( this, ImplGrafControl, ImplModifyHdl ) );
 
-    maField->SetHelpId( OUStringToOString( rCmd, RTL_TEXTENCODING_UTF8 ) );
-    maField->Show();
+    SetSizePixel(m_xContainer->get_preferred_size());
+}
+
+IMPL_LINK(ImplGrafControl, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+    return ChildKeyInput(rKEvt);
 }
 
 ImplGrafControl::~ImplGrafControl()
@@ -310,24 +262,14 @@ ImplGrafControl::~ImplGrafControl()
 
 void ImplGrafControl::dispose()
 {
-    maImage.disposeAndClear();
-    maField.disposeAndClear();
-    Control::dispose();
+    mxImage.reset();
+    mxField.reset();
+    InterimItemWindow::dispose();
 }
 
 void ImplGrafControl::GetFocus()
 {
-    if (maField)
-        maField->GrabFocus();
-}
-
-void ImplGrafControl::Resize()
-{
-    Size aFldSize(maField->GetSizePixel());
-    aFldSize.setWidth( GetSizePixel().Width() - SYMBOL_TO_FIELD_OFFSET - maImage->GetSizePixel().Width() );
-    maField->SetSizePixel(aFldSize);
-
-    Control::Resize();
+    mxField->grab_focus();
 }
 
 namespace {
@@ -467,19 +409,18 @@ SvxGrafToolBoxControl::~SvxGrafToolBoxControl()
 }
 
 void SvxGrafToolBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPoolItem* pState )
-
 {
     ImplGrafControl* pCtrl = static_cast<ImplGrafControl*>( GetToolBox().GetItemWindow( GetId() ) );
     DBG_ASSERT( pCtrl, "Control not found" );
 
     if( eState == SfxItemState::DISABLED )
     {
-        pCtrl->Disable();
-        pCtrl->SetText( OUString() );
+        pCtrl->set_sensitive(false);
+        pCtrl->set_field_text( OUString() );
     }
     else
     {
-        pCtrl->Enable();
+        pCtrl->set_sensitive(true);
 
         if( eState == SfxItemState::DEFAULT )
             pCtrl->Update( pState );
diff --git a/svx/uiconfig/ui/grafctrlbox.ui b/svx/uiconfig/ui/grafctrlbox.ui
new file mode 100644
index 000000000000..b5088dd3337c
--- /dev/null
+++ b/svx/uiconfig/ui/grafctrlbox.ui
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="svx">
+  <requires lib="gtk+" version="3.18"/>
+  <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="GtkBox" id="GrafCtrlBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="hexpand">True</property>
+    <property name="spacing">4</property>
+    <child>
+      <object class="GtkImage" id="image">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="stock">gtk-missing-image</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkSpinButton" id="spinfield">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="hexpand">True</property>
+        <property name="adjustment">adjustment1</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+  </object>
+</interface>
commit 08695569fd4fccc1722e7e3c7e0a234699199196
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Feb 7 14:09:57 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Feb 7 20:48:51 2020 +0100

    ofz#20517 null-dereference
    
    Change-Id: I443869f848925911ed46e2f547f0dc652b1ff290
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88214
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/lotuswordpro/qa/cppunit/data/pass/ofz20517-1.lwp b/lotuswordpro/qa/cppunit/data/pass/ofz20517-1.lwp
new file mode 100644
index 000000000000..de6dcbf1c5d5
Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/pass/ofz20517-1.lwp differ
diff --git a/lotuswordpro/source/filter/lwprowlayout.cxx b/lotuswordpro/source/filter/lwprowlayout.cxx
index 7a564bdd5849..811b7abb762e 100644
--- a/lotuswordpro/source/filter/lwprowlayout.cxx
+++ b/lotuswordpro/source/filter/lwprowlayout.cxx
@@ -379,11 +379,13 @@ void LwpRowLayout::ConvertCommonRow(rtl::Reference<XFTable> const & pXFTable, sa
     LwpTableLayout* pTableLayout = GetParentTableLayout();
     if (!pTableLayout)
         return;
+    LwpTable* pTable = pTableLayout->GetTable();
+    if (!pTable)
+        return;
 
     rtl::Reference<XFRow> xRow(new XFRow);
     xRow->SetStyleName(m_StyleName);
 
-    LwpTable* pTable = pTableLayout->GetTable();
     sal_uInt8 nCellStartCol,nCellEndCol;
 
     for (sal_uInt8 i = nStartCol; i < nEndCol ; i++)


More information about the Libreoffice-commits mailing list