[Libreoffice-commits] core.git: 2 commits - include/svx sc/source sd/source svx/source sw/source unoxml/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Oct 20 06:01:05 UTC 2018


 include/svx/fmview.hxx                   |    6 +++---
 sc/source/ui/view/tabvwshb.cxx           |    8 ++++----
 sc/source/ui/view/viewfun5.cxx           |    8 ++++----
 sd/source/ui/view/drviewse.cxx           |    4 ++--
 sd/source/ui/view/sdview3.cxx            |    4 ++--
 svx/source/form/fmview.cxx               |    6 +++---
 svx/source/form/fmvwimp.cxx              |   14 +++++++-------
 svx/source/inc/fmvwimp.hxx               |    4 ++--
 svx/source/smarttags/SmartTagMgr.cxx     |    5 ++---
 sw/source/uibase/dochdl/swdtflvr.cxx     |   12 ++++++------
 sw/source/uibase/uiview/viewdraw.cxx     |    6 +++---
 unoxml/source/events/eventdispatcher.cxx |    5 ++---
 12 files changed, 40 insertions(+), 42 deletions(-)

New commits:
commit 722cb06e71539e108f663ca1c2dd6baf7f4adc64
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Oct 15 13:58:32 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Oct 20 08:00:58 2018 +0200

    return by unique_ptr from CreateFieldControl
    
    Change-Id: Ic8bf9829c3320aca452fd1a40e9843fdbdbfa219
    Reviewed-on: https://gerrit.libreoffice.org/61906
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/svx/fmview.hxx b/include/svx/fmview.hxx
index 106e83131733..853a6bccfe39 100644
--- a/include/svx/fmview.hxx
+++ b/include/svx/fmview.hxx
@@ -72,15 +72,15 @@ public:
         @deprecated
             This method is deprecated. Use the version with a ODataAccessDescriptor instead.
     */
-    SdrObject*   CreateFieldControl(const OUString& rFieldDesc) const;
+    SdrObjectUniquePtr CreateFieldControl(const OUString& rFieldDesc) const;
 
     /** create a control pair (label/bound control) for the database field description given.
     */
-    SdrObject*   CreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
+    SdrObjectUniquePtr CreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
 
     /** create a control pair (label/bound control) for the xforms description given.
     */
-    SdrObject*   CreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
+    SdrObjectUniquePtr CreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
 
     virtual void MarkListHasChanged() override;
     virtual void AddWindowToPaintView(OutputDevice* pNewWin, vcl::Window* pWindow) override;
diff --git a/sc/source/ui/view/tabvwshb.cxx b/sc/source/ui/view/tabvwshb.cxx
index d4e88c791f21..3cd9c496d56e 100644
--- a/sc/source/ui/view/tabvwshb.cxx
+++ b/sc/source/ui/view/tabvwshb.cxx
@@ -448,7 +448,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                     if(pPageView)
                     {
                         svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
-                        SdrObject* pNewDBField = pDrView->CreateFieldControl(aDescriptor);
+                        SdrObjectUniquePtr pNewDBField = pDrView->CreateFieldControl(aDescriptor);
 
                         if(pNewDBField)
                         {
@@ -462,11 +462,11 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                             pNewDBField->SetLogicRect(aNewObjectRectangle);
 
                             // controls must be on control layer, groups on front layer
-                            if ( dynamic_cast<const SdrUnoObj*>( pNewDBField) !=  nullptr )
+                            if ( dynamic_cast<const SdrUnoObj*>( pNewDBField.get() ) !=  nullptr )
                                 pNewDBField->NbcSetLayer(SC_LAYER_CONTROLS);
                             else
                                 pNewDBField->NbcSetLayer(SC_LAYER_FRONT);
-                            if (dynamic_cast<const SdrObjGroup*>( pNewDBField) !=  nullptr)
+                            if (dynamic_cast<const SdrObjGroup*>( pNewDBField.get() ) !=  nullptr)
                             {
                                 SdrObjListIter aIter( *pNewDBField, SdrIterMode::DeepWithGroups );
                                 SdrObject* pSubObj = aIter.Next();
@@ -480,7 +480,7 @@ void ScTabViewShell::ExecDrawIns(SfxRequest& rReq)
                                 }
                             }
 
-                            pView->InsertObjectAtView(pNewDBField, *pPageView);
+                            pView->InsertObjectAtView(pNewDBField.release(), *pPageView);
                         }
                     }
                 }
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index bc44c67a900f..68751d4e148b 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -442,7 +442,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
         {
             MakeDrawLayer();
             ScDrawView* pScDrawView = GetScDrawView();
-            SdrObject* pObj = pScDrawView->CreateFieldControl( svx::OColumnTransferable::extractColumnDescriptor( aDataHelper ) );
+            SdrObjectUniquePtr pObj = pScDrawView->CreateFieldControl( svx::OColumnTransferable::extractColumnDescriptor( aDataHelper ) );
             if (pObj)
             {
                 Point aInsPos = aPos;
@@ -454,11 +454,11 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
                 aRect.SetPos(aInsPos);
                 pObj->SetLogicRect(aRect);
 
-                if ( dynamic_cast<const SdrUnoObj*>( pObj) !=  nullptr )
+                if ( dynamic_cast<const SdrUnoObj*>( pObj.get() ) !=  nullptr )
                     pObj->NbcSetLayer(SC_LAYER_CONTROLS);
                 else
                     pObj->NbcSetLayer(SC_LAYER_FRONT);
-                if (dynamic_cast<const SdrObjGroup*>( pObj) !=  nullptr)
+                if (dynamic_cast<const SdrObjGroup*>( pObj.get() ) !=  nullptr)
                 {
                     SdrObjListIter aIter( *pObj, SdrIterMode::DeepWithGroups );
                     SdrObject* pSubObj = aIter.Next();
@@ -472,7 +472,7 @@ bool ScViewFunc::PasteDataFormat( SotClipboardFormatId nFormatId,
                     }
                 }
 
-                pScDrawView->InsertObjectSafe(pObj, *pScDrawView->GetSdrPageView());
+                pScDrawView->InsertObjectSafe(pObj.release(), *pScDrawView->GetSdrPageView());
 
                 GetViewData().GetViewShell()->SetDrawShell( true );
                 bRet = true;
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index 91a10f0aa275..05f8b041be60 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -272,7 +272,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
                 if(pPageView)
                 {
                     svx::ODataAccessDescriptor aDescriptor(pDescriptorItem->GetValue());
-                    SdrObject* pNewDBField = pFormView->CreateFieldControl(aDescriptor);
+                    SdrObjectUniquePtr pNewDBField = pFormView->CreateFieldControl(aDescriptor);
 
                     if(pNewDBField)
                     {
@@ -285,7 +285,7 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
 
                         pNewDBField->SetLogicRect(aNewObjectRectangle);
 
-                        GetView()->InsertObjectAtView(pNewDBField, *pPageView);
+                        GetView()->InsertObjectAtView(pNewDBField.release(), *pPageView);
                     }
                 }
             }
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 06d66260dd7a..e15e67a860de 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -842,7 +842,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
 
         if( aDataHelper.GetString( SotClipboardFormatId::SBA_FIELDDATAEXCHANGE, aOUString ) )
         {
-            SdrObject* pObj = CreateFieldControl( aOUString );
+            SdrObjectUniquePtr pObj = CreateFieldControl( aOUString );
 
             if( pObj )
             {
@@ -854,7 +854,7 @@ bool View::InsertData( const TransferableDataHelper& rDataHelper,
 
                 aRect.SetPos( maDropPos );
                 pObj->SetLogicRect( aRect );
-                InsertObjectAtView( pObj, *GetSdrPageView(), SdrInsertFlags::SETDEFLAYER );
+                InsertObjectAtView( pObj.release(), *GetSdrPageView(), SdrInsertFlags::SETDEFLAYER );
                 bReturn = true;
             }
         }
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
index 5f93b1750b85..025ceff9d991 100644
--- a/svx/source/form/fmview.cxx
+++ b/svx/source/form/fmview.cxx
@@ -387,19 +387,19 @@ void FmFormView::DeactivateControls(SdrPageView const * pPageView)
 }
 
 
-SdrObject* FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
+SdrObjectUniquePtr FmFormView::CreateFieldControl( const ODataAccessDescriptor& _rColumnDescriptor )
 {
     return pImpl->implCreateFieldControl( _rColumnDescriptor );
 }
 
 
-SdrObject* FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc )
+SdrObjectUniquePtr FmFormView::CreateXFormsControl( const OXFormsDescriptor &_rDesc )
 {
     return pImpl->implCreateXFormsControl(_rDesc);
 }
 
 
-SdrObject* FmFormView::CreateFieldControl(const OUString& rFieldDesc) const
+SdrObjectUniquePtr FmFormView::CreateFieldControl(const OUString& rFieldDesc) const
 {
     OUString sDataSource     = rFieldDesc.getToken(0,u'\x000B');
     OUString sObjectName     = rFieldDesc.getToken(1,u'\x000B');
diff --git a/svx/source/form/fmvwimp.cxx b/svx/source/form/fmvwimp.cxx
index 7c2311948a8a..48f0b2220bec 100644
--- a/svx/source/form/fmvwimp.cxx
+++ b/svx/source/form/fmvwimp.cxx
@@ -1146,7 +1146,7 @@ namespace
 }
 
 
-SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor )
+SdrObjectUniquePtr FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor )
 {
     // not if we're in design mode
     if ( !m_pView->IsDesignMode() )
@@ -1347,7 +1347,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor
         bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
         OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateFieldControl: why was there a label created for a check box?" );
         if ( bCheckbox )
-            return pControl.release();
+            return SdrObjectUniquePtr(pControl.release());
 
         SdrObjGroup* pGroup  = new SdrObjGroup(getView()->getSdrModelFromSdrView());
         SdrObjList* pObjList = pGroup->GetSubList();
@@ -1366,7 +1366,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor
             }
         }
 
-        return pGroup; // and done
+        return SdrObjectUniquePtr(pGroup); // and done
     }
     catch (const Exception&)
     {
@@ -1378,7 +1378,7 @@ SdrObject* FmXFormView::implCreateFieldControl( const svx::ODataAccessDescriptor
 }
 
 
-SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc )
+SdrObjectUniquePtr FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc )
 {
     // not if we're in design mode
     if ( !m_pView->IsDesignMode() )
@@ -1456,7 +1456,7 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
             bool bCheckbox = ( OBJ_FM_CHECKBOX == nOBJID );
             OSL_ENSURE( !bCheckbox || !pLabel, "FmXFormView::implCreateXFormsControl: why was there a label created for a check box?" );
             if ( bCheckbox )
-                return pControl.release();
+                return SdrObjectUniquePtr(pControl.release());
 
 
             // group objects
@@ -1465,7 +1465,7 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
             pObjList->InsertObject(pLabel.release());
             pObjList->InsertObject(pControl.release());
 
-            return pGroup;
+            return SdrObjectUniquePtr(pGroup);
         }
         else {
 
@@ -1495,7 +1495,7 @@ SdrObject* FmXFormView::implCreateXFormsControl( const svx::OXFormsDescriptor &_
             Reference< css::form::submission::XSubmissionSupplier > xSubmissionSupplier(pControl->GetUnoControlModel(), UNO_QUERY);
             xSubmissionSupplier->setSubmission(xSubmission);
 
-            return pControl;
+            return SdrObjectUniquePtr(pControl);
         }
     }
     catch (const Exception&)
diff --git a/svx/source/inc/fmvwimp.hxx b/svx/source/inc/fmvwimp.hxx
index 13749dedf391..f10068daee90 100644
--- a/svx/source/inc/fmvwimp.hxx
+++ b/svx/source/inc/fmvwimp.hxx
@@ -247,8 +247,8 @@ private:
     void Activate(bool bSync = false);
     void Deactivate(bool bDeactivateController = true);
 
-    SdrObject*  implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
-    SdrObject*  implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
+    SdrObjectUniquePtr implCreateFieldControl( const svx::ODataAccessDescriptor& _rColumnDescriptor );
+    SdrObjectUniquePtr implCreateXFormsControl( const svx::OXFormsDescriptor &_rDesc );
 
     static bool createControlLabelPair(
         OutputDevice const & _rOutDev,
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx
index 61abefb4ffaa..a67f021e72d4 100644
--- a/sw/source/uibase/dochdl/swdtflvr.cxx
+++ b/sw/source/uibase/dochdl/swdtflvr.cxx
@@ -2688,10 +2688,10 @@ bool SwTransferable::PasteDBData( TransferableDataHelper& rData,
             if (pFmView && pDragPt)
             {
                 const OXFormsDescriptor &rDesc = OXFormsTransferable::extractDescriptor(rData);
-                SdrObject* pObj = pFmView->CreateXFormsControl(rDesc);
-                if(nullptr != pObj)
+                SdrObjectUniquePtr pObj = pFmView->CreateXFormsControl(rDesc);
+                if(pObj)
                 {
-                    rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
+                    rSh.SwFEShell::InsertDrawObj( *(pObj.release()), *pDragPt );
                 }
             }
         }
@@ -2745,9 +2745,9 @@ bool SwTransferable::PasteDBData( TransferableDataHelper& rData,
             FmFormView* pFmView = dynamic_cast<FmFormView*>( rSh.GetDrawView()  );
             if (pFmView && bHaveColumnDescriptor && pDragPt)
             {
-                SdrObject* pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) );
-                if ( nullptr != pObj)
-                    rSh.SwFEShell::InsertDrawObj( *pObj, *pDragPt );
+                SdrObjectUniquePtr pObj = pFmView->CreateFieldControl( OColumnTransferable::extractColumnDescriptor(rData) );
+                if (pObj)
+                    rSh.SwFEShell::InsertDrawObj( *(pObj.release()), *pDragPt );
             }
         }
         bRet = true;
diff --git a/sw/source/uibase/uiview/viewdraw.cxx b/sw/source/uibase/uiview/viewdraw.cxx
index 8a94bb84f346..974add36a258 100644
--- a/sw/source/uibase/uiview/viewdraw.cxx
+++ b/sw/source/uibase/uiview/viewdraw.cxx
@@ -115,7 +115,7 @@ void SwView::ExecDraw(SfxRequest& rReq)
             if( pDescriptorItem )
             {
                 svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
-                SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
+                SdrObjectUniquePtr pObj = pFormView->CreateFieldControl( aDescriptor );
 
                 if ( pObj )
                 {
@@ -130,14 +130,14 @@ void SwView::ExecDraw(SfxRequest& rReq)
                     //determine the size of the object
                     if(pObj->IsGroupObject())
                     {
-                        const tools::Rectangle& rBoundRect = static_cast<SdrObjGroup*>(pObj)->GetCurrentBoundRect();
+                        const tools::Rectangle& rBoundRect = static_cast<SdrObjGroup*>(pObj.get())->GetCurrentBoundRect();
                         aStartPos.AdjustX( -(rBoundRect.GetWidth()/2) );
                         aStartPos.AdjustY( -(rBoundRect.GetHeight()/2) );
                     }
 
                     // TODO: unmark all other
                     m_pWrtShell->EnterStdMode();
-                    m_pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
+                    m_pWrtShell->SwFEShell::InsertDrawObj( *(pObj.release()), aStartPos );
                 }
             }
         }
commit 587bd15487f78dc0e973ea811a4200612ceeda5d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Oct 19 16:08:49 2018 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sat Oct 20 08:00:44 2018 +0200

    use equal_range instead of lower_bound+upper_bound
    
    Change-Id: I7cc1c95b3a55630e3571cac5fe22be6c2f3a1bc9
    Reviewed-on: https://gerrit.libreoffice.org/62015
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/svx/source/smarttags/SmartTagMgr.cxx b/svx/source/smarttags/SmartTagMgr.cxx
index 8ffebc7cc27d..b7cb3a3dbf2f 100644
--- a/svx/source/smarttags/SmartTagMgr.cxx
+++ b/svx/source/smarttags/SmartTagMgr.cxx
@@ -160,10 +160,9 @@ void SmartTagMgr::GetActionSequences( std::vector< OUString >& rSmartTagTypes,
         Sequence< sal_Int32 > aIndices( nNumberOfActionRefs );
 
         sal_uInt16 i = 0;
-        auto aActionsIter = maSmartTagMap.lower_bound( rSmartTagType );
-        auto aEnd = maSmartTagMap.upper_bound( rSmartTagType );
+        auto iters = maSmartTagMap.equal_range( rSmartTagType );
 
-        for ( ; aActionsIter != aEnd; ++aActionsIter )
+        for ( auto aActionsIter = iters.first; aActionsIter != iters.second; ++aActionsIter )
         {
             aActions[ i ] = (*aActionsIter).second.mxSmartTagAction;
             aIndices[ i++ ] = (*aActionsIter).second.mnSmartTagIndex;
diff --git a/unoxml/source/events/eventdispatcher.cxx b/unoxml/source/events/eventdispatcher.cxx
index ff5ce7aa8889..b5d5ef705b31 100644
--- a/unoxml/source/events/eventdispatcher.cxx
+++ b/unoxml/source/events/eventdispatcher.cxx
@@ -92,9 +92,8 @@ namespace DOM { namespace events {
         TypeListenerMap::const_iterator tIter = rTMap.find(aType);
         if (tIter != rTMap.end()) {
             ListenerMap const& rMap = tIter->second;
-            auto iter = rMap.lower_bound(pNode);
-            auto const ibound = rMap.upper_bound(pNode);
-            for( ; iter != ibound; ++iter )
+            auto iterRange = rMap.equal_range(pNode);
+            for( auto iter = iterRange.first; iter != iterRange.second; ++iter )
             {
                 if(iter->second.is())
                     (iter->second)->handleEvent(xEvent);


More information about the Libreoffice-commits mailing list