[Libreoffice-commits] core.git: Branch 'libreoffice-6-1-3' - reportdesign/inc reportdesign/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Oct 18 10:51:09 UTC 2018


 reportdesign/inc/RptObject.hxx             |    4 ++
 reportdesign/source/core/sdr/RptObject.cxx |   55 ++++++++++++++++++-----------
 2 files changed, 40 insertions(+), 19 deletions(-)

New commits:
commit d68ac1325924f7280545e61b7dff0072a959d4ab
Author:     Armin Le Grand <Armin.Le.Grand at cib.de>
AuthorDate: Wed Oct 10 16:02:05 2018 +0200
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Oct 18 12:50:21 2018 +0200

    tdf#119067 DefaultLabel only for interactively created OBJs
    
    Both have to work - the Wizard-created report which this report
    defines and the interactively created ones (see tdf#118730). The
    second was moved to OUnoObject::CreateMediator and by error
    sets the default text (e.g. 'Label') now all the time. This
    was wrong.
    To solve, remember if the Object was created interactively
    (which is the case when ::EndCreate was called which is needed
    again) and set the default only when that is the case.
    
    Change-Id: Id26e701d863b098a77db5f6419bcabf1f2ec5017
    Reviewed-on: https://gerrit.libreoffice.org/61620
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <Armin.Le.Grand at cib.de>
    Reviewed-on: https://gerrit.libreoffice.org/61654
    Tested-by: Xisco FaulĂ­ <xiscofauli at libreoffice.org>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/reportdesign/inc/RptObject.hxx b/reportdesign/inc/RptObject.hxx
index 3a4c6cbe35de..31e3346c074d 100644
--- a/reportdesign/inc/RptObject.hxx
+++ b/reportdesign/inc/RptObject.hxx
@@ -229,6 +229,9 @@ class REPORTDESIGN_DLLPUBLIC OUnoObject: public SdrUnoObj , public OObjectBase
     friend class DlgEdFactory;
 
     sal_uInt16   m_nObjectType;
+    // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
+    bool         m_bSetDefaultLabel;
+
 protected:
     OUnoObject(SdrModel& rSdrModel,
         const OUString& _sComponentName,
@@ -246,6 +249,7 @@ protected:
     virtual void NbcMove( const Size& rSize ) override;
     virtual void NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact) override;
     virtual void NbcSetLogicRect(const tools::Rectangle& rRect) override;
+    virtual bool EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd) override;
 
     virtual SdrPage* GetImplPage() const override;
 
diff --git a/reportdesign/source/core/sdr/RptObject.cxx b/reportdesign/source/core/sdr/RptObject.cxx
index 16435cdf5d83..0bb74d0a31e4 100644
--- a/reportdesign/source/core/sdr/RptObject.cxx
+++ b/reportdesign/source/core/sdr/RptObject.cxx
@@ -596,6 +596,8 @@ OUnoObject::OUnoObject(
 :   SdrUnoObj(rSdrModel, rModelName)
     ,OObjectBase(_sComponentName)
     ,m_nObjectType(_nObjectType)
+    // tdf#119067
+    ,m_bSetDefaultLabel(false)
 {
     if ( !rModelName.isEmpty() )
         impl_initializeModel_nothrow();
@@ -609,6 +611,8 @@ OUnoObject::OUnoObject(
 :   SdrUnoObj(rSdrModel, rModelName)
     ,OObjectBase(_xComponent)
     ,m_nObjectType(_nObjectType)
+    // tdf#119067
+    ,m_bSetDefaultLabel(false)
 {
     impl_setUnoShape( uno::Reference< uno::XInterface >( _xComponent, uno::UNO_QUERY ) );
 
@@ -731,6 +735,22 @@ void OUnoObject::NbcSetLogicRect(const tools::Rectangle& rRect)
     OObjectBase::StartListening();
 }
 
+bool OUnoObject::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
+{
+    const bool bResult(SdrUnoObj::EndCreate(rStat, eCmd));
+
+    if(bResult)
+    {
+        // tdf#118730 remember if this object was created interactively (due to ::EndCreate being called)
+        m_bSetDefaultLabel = true;
+
+        // set geometry properties
+        SetPropsFromRect(GetLogicRect());
+    }
+
+    return bResult;
+}
+
 OUString OUnoObject::GetDefaultName(const OUnoObject* _pObj)
 {
     OUString aDefaultName = "HERE WE HAVE TO INSERT OUR NAME!";
@@ -825,32 +845,29 @@ void OUnoObject::CreateMediator(bool _bReverse)
             impl_initializeModel_nothrow();
         }
 
-        // tdf#118730 Directly do thinigs formerly done in
-        // OUnoObject::EndCreate here
-        if(m_xReportComponent.is())
+        if(m_xReportComponent.is() && m_bSetDefaultLabel)
         {
-            // set labels
-            if ( m_xReportComponent.is() )
+            // tdf#118730 Directly do things formerly done in
+            // OUnoObject::EndCreate here
+            // tdf#119067 ...but *only* if result of interactive
+            // creation in Report DesignView
+            m_bSetDefaultLabel = false;
+
+            try
             {
-                try
+                if ( supportsService( SERVICE_FIXEDTEXT ) )
                 {
-                    if ( supportsService( SERVICE_FIXEDTEXT ) )
-                    {
-                        m_xReportComponent->setPropertyValue( PROPERTY_LABEL, uno::makeAny(GetDefaultName(this)) );
-                    }
+                    m_xReportComponent->setPropertyValue(
+                        PROPERTY_LABEL,
+                        uno::makeAny(GetDefaultName(this)));
                 }
-                catch(const uno::Exception&)
-                {
-                    DBG_UNHANDLED_EXCEPTION("reportdesign");
-                }
-
-                impl_initializeModel_nothrow();
+            }
+            catch(const uno::Exception&)
+            {
+                DBG_UNHANDLED_EXCEPTION("reportdesign");
             }
         }
 
-        // tdf#118730 set geometry properties
-        SetPropsFromRect(GetLogicRect());
-
         if(!m_xMediator.is() && m_xReportComponent.is())
         {
             Reference<XPropertySet> xControlModel(GetUnoControlModel(),uno::UNO_QUERY);


More information about the Libreoffice-commits mailing list