[Libreoffice-commits] core.git: 4 commits - sw/source unusedcode.easy writerfilter/source

Caolán McNamara caolanm at redhat.com
Mon Feb 2 10:24:08 PST 2015


 sw/source/core/table/swnewtable.cxx                   |    8 +-
 sw/source/filter/html/htmlflywriter.cxx               |    3 -
 sw/source/filter/html/htmlforw.cxx                    |   49 +++++-------------
 sw/source/filter/html/wrthtml.hxx                     |    3 -
 sw/source/filter/ww8/wrtw8esh.cxx                     |   23 ++------
 sw/source/filter/ww8/wrtw8sty.cxx                     |    5 +
 sw/source/filter/ww8/wrtww8.hxx                       |    3 -
 sw/source/filter/ww8/ww8par.hxx                       |    3 -
 unusedcode.easy                                       |    1 
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |    9 +--
 writerfilter/source/rtftok/rtfdocumentimpl.cxx        |    8 +-
 11 files changed, 43 insertions(+), 72 deletions(-)

New commits:
commit 04e52fd93098acb604c28a315aa3578e5010039b
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 2 17:35:28 2015 +0000

    drop now fixed OOoEmbeddedObjectFactory::createInstanceLinkUserInit from list
    
    Change-Id: Ic9480340e2a9255aae6d0f97e180e3e68cf97e42

diff --git a/unusedcode.easy b/unusedcode.easy
index c288793..17cdc31 100644
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -5,7 +5,6 @@ FontCharMap::GetDefaultMap(bool)
 LineListBox::Clear()
 LineListBox::InsertEntry(rtl::OUString const&, int)
 LineListBox::RemoveEntry(int)
-OOoEmbeddedObjectFactory::createInstanceLinkUserInit(com::sun::star::uno::Sequence<signed char> const&, rtl::OUString const&, com::sun::star::uno::Reference<com::sun::star::embed::XStorage> const&, rtl::OUString const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&, com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> const&)
 OpenGLContext::init(_XDisplay*, unsigned long, unsigned int, unsigned int, int)
 OpenGLContext::renderToFile()
 OpenGLContext::requestSingleBufferedRendering()
commit 012607dc600d85553f5a1db68ae9c36797000474
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 2 16:49:39 2015 +0000

    unwind the casts to initial entry points
    
    Change-Id: Id8d90569c079a753314ba88b419de9a08b0b6a8b

diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index dfbb5d0..4a3c7d2 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -32,6 +32,7 @@
 #include <svtools/imap.hxx>
 #include <svtools/imapobj.hxx>
 #include <svtools/htmlcfg.hxx>
+#include <svx/svdouno.hxx>
 #include <svx/xoutbmp.hxx>
 #include <editeng/boxitem.hxx>
 #include <editeng/lrspitem.hxx>
@@ -490,7 +491,7 @@ void SwHTMLWriter::OutFrmFmt( sal_uInt8 nMode, const SwFrmFmt& rFrmFmt,
         break;
     case HTML_OUT_CONTROL:      // OK
         OutHTML_DrawFrmFmtAsControl( *this,
-                                    static_cast<const SwDrawFrmFmt &>(rFrmFmt), *pSdrObject,
+                                    static_cast<const SwDrawFrmFmt &>(rFrmFmt), dynamic_cast<const SdrUnoObj&>(*pSdrObject),
                                     pCntnrStr != 0 );
         break;
     case HTML_OUT_AMARQUEE:
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
index 2e95323..a73b92e 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -641,12 +641,9 @@ const SdrObject *SwHTMLWriter::GetHTMLControl( const SwDrawFrmFmt& rFmt )
     if( !pObj || FmFormInventor != pObj->GetObjInventor() )
         return 0;
 
-    const SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pObj );
-    assert(pFormObj);
-    if (!pFormObj)
-        return 0;
+    const SdrUnoObj& rFormObj = dynamic_cast<const SdrUnoObj&>(*pObj);
     uno::Reference< awt::XControlModel >  xControlModel =
-            pFormObj->GetUnoControlModel();
+            rFormObj.GetUnoControlModel();
 
     OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
     if( !xControlModel.is() )
@@ -668,22 +665,17 @@ const SdrObject *SwHTMLWriter::GetHTMLControl( const SwDrawFrmFmt& rFmt )
     return 0;
 }
 
-static void GetControlSize( const SdrObject& rSdrObj, Size& rSz,
-                            SwDoc *pDoc )
+static void GetControlSize(const SdrUnoObj& rFormObj, Size& rSz, SwDoc *pDoc)
 {
     SwViewShell *pVSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
     if( !pVSh )
         return;
 
-    const SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, &rSdrObj );
-    assert(pFormObj);
-    if (!pFormObj)
-        return;
     uno::Reference< awt::XControl >  xControl;
     SdrView* pDrawView = pVSh->GetDrawView();
     OSL_ENSURE( pDrawView && pVSh->GetWin(), "no DrawView or window!" );
     if ( pDrawView && pVSh->GetWin() )
-        xControl = pFormObj->GetUnoControl( *pDrawView, *pVSh->GetWin() );
+        xControl = rFormObj.GetUnoControl( *pDrawView, *pVSh->GetWin() );
     uno::Reference< awt::XTextLayoutConstrains > xLC( xControl, uno::UNO_QUERY );
     OSL_ENSURE( xLC.is(), "kein XTextLayoutConstrains" );
     if( !xLC.is() )
@@ -697,17 +689,11 @@ static void GetControlSize( const SdrObject& rSdrObj, Size& rSz,
 
 Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
                                      const SwDrawFrmFmt& rFmt,
-                                     const SdrObject& rSdrObject,
+                                     const SdrUnoObj& rFormObj,
                                      bool bInCntnr )
 {
-    SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
-
-    const SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, &rSdrObject );
-    assert(pFormObj);
-    if (!pFormObj)
-        return rWrt;
     uno::Reference< awt::XControlModel > xControlModel =
-        pFormObj->GetUnoControlModel();
+        rFormObj.GetUnoControlModel();
 
     OSL_ENSURE( xControlModel.is(), "UNO-Control ohne Model" );
     if( !xControlModel.is() )
@@ -717,6 +703,7 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
     uno::Reference< beans::XPropertySetInfo > xPropSetInfo =
             xPropSet->getPropertySetInfo();
 
+    SwHTMLWriter & rHTMLWrt = static_cast<SwHTMLWriter&>(rWrt);
     rHTMLWrt.nFormCntrlCnt++;
 
     enum Tag { TAG_INPUT, TAG_SELECT, TAG_TEXTAREA, TAG_NONE };
@@ -807,7 +794,7 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
             !*(sal_Bool*)aTmp.getValue() )
         {
             Size aSz( 0, 0 );
-            GetControlSize( rSdrObject, aSz, rWrt.pDoc );
+            GetControlSize( rFormObj, aSz, rWrt.pDoc );
 
             // wieviele sind sichtbar ??
             if( aSz.Height() )
@@ -828,7 +815,7 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
     case form::FormComponentType::TEXTFIELD:
         {
             Size aSz( 0, 0 );
-            GetControlSize( rSdrObject, aSz, rWrt.pDoc );
+            GetControlSize( rFormObj, aSz, rWrt.pDoc );
 
             bool bMultiLine = false;
             OUString sMultiLine("MultiLine");
@@ -913,7 +900,7 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
     case form::FormComponentType::FILECONTROL:
         {
             Size aSz( 0, 0 );
-            GetControlSize( rSdrObject, aSz, rWrt.pDoc );
+            GetControlSize( rFormObj, aSz, rWrt.pDoc );
             eType = TYPE_FILE;
 
             if( aSz.Width() )
@@ -989,7 +976,7 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
             sOut = "\"";
         }
 
-        Size aTwipSz( rSdrObject.GetLogicRect().GetSize() );
+        Size aTwipSz( rFormObj.GetLogicRect().GetSize() );
         Size aPixelSz( 0, 0 );
         if( (aTwipSz.Width() || aTwipSz.Height()) &&
             Application::GetDefaultDevice() )
@@ -1152,7 +1139,7 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
             }
         }
 
-        rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmOpts, &rSdrObject,
+        rHTMLWrt.OutCSS1_FrmFmtOptions( rFmt, nFrmOpts, &rFormObj,
                                         &aItemSet );
     }
 
@@ -1291,15 +1278,11 @@ Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt,
 // Ermitteln, ob eine Format zu einem Control gehoert und wenn ja
 // dessen Form zurueckgeben
 static void AddControl( HTMLControls& rControls,
-                        const SdrObject *pSdrObj,
+                        const SdrUnoObj& rFormObj,
                         sal_uInt32 nNodeIdx )
 {
-    const SdrUnoObj *pFormObj = PTR_CAST( SdrUnoObj, pSdrObj );
-    assert(pFormObj); //Doch kein FormObj
-    if (!pFormObj)
-        return;
     uno::Reference< awt::XControlModel > xControlModel =
-            pFormObj->GetUnoControlModel();
+            rFormObj.GetUnoControlModel();
     if( !xControlModel.is() )
         return;
 
@@ -1346,7 +1329,7 @@ void SwHTMLWriter::GetControls()
             if( !pSdrObj )
                 continue;
 
-            AddControl( aHTMLControls, pSdrObj,
+            AddControl( aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj),
                         pPosFlyFrm->GetNdIndex().GetIndex() );
         }
     }
@@ -1369,7 +1352,7 @@ void SwHTMLWriter::GetControls()
         if( !pSdrObj )
             continue;
 
-        AddControl( aHTMLControls, pSdrObj, pPos->nNode.GetIndex() );
+        AddControl( aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), pPos->nNode.GetIndex() );
     }
 }
 
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 53c2552..b0e92e3 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -48,6 +48,7 @@ class SwNodeIndex;
 class ImageMap;
 class SwNumRule;
 class SdrObject;
+class SdrUnoObj;
 class SvxBrushItem;
 class SvxFontItem;
 class SwHTMLNumRuleInfo;
@@ -649,7 +650,7 @@ Writer& OutHTML_SwTblNode( Writer& , SwTableNode &, const SwFrmFmt *,
                            const OUString* pCaption=0, bool bTopCaption=false );
 
 Writer& OutHTML_DrawFrmFmtAsControl( Writer& rWrt, const SwDrawFrmFmt& rFmt,
-                                     const SdrObject& rSdrObj, bool bInCntnr );
+                                     const SdrUnoObj& rSdrObj, bool bInCntnr );
 Writer& OutHTML_DrawFrmFmtAsMarquee( Writer& rWrt, const SwDrawFrmFmt& rFmt,
                                      const SdrObject& rSdrObj );
 
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index d5f0ae0..acb862b 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1310,13 +1310,8 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr)
     }
 }
 
-void WW8Export::WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp)
+void WW8Export::WriteSdrTextObj(const SdrTextObj& rTxtObj, sal_uInt8 nTyp)
 {
-    const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, &rObj);
-    OSL_ENSURE(pTxtObj, "That is no SdrTextObj!");
-    if (!pTxtObj)
-        return;
-
     const OutlinerParaObject* pParaObj = 0;
     bool bOwnParaObj = false;
 
@@ -1325,14 +1320,14 @@ void WW8Export::WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp)
     When the object is actively being edited, that text is not set into
     the objects normal text object, but lives in a separate object.
     */
-    if (pTxtObj->IsTextEditActive())
+    if (rTxtObj.IsTextEditActive())
     {
-        pParaObj = pTxtObj->GetEditOutlinerParaObject();
+        pParaObj = rTxtObj.GetEditOutlinerParaObject();
         bOwnParaObj = true;
     }
     else
     {
-        pParaObj = pTxtObj->GetOutlinerParaObject();
+        pParaObj = rTxtObj.GetOutlinerParaObject();
     }
 
     if( pParaObj )
@@ -3112,23 +3107,19 @@ bool  SwMSConvertControls::ReadOCXStream( SotStorageRef& rSrc1,
     return bRes;
 }
 
-bool SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrObject *pObj)
+bool SwMSConvertControls::ExportControl(WW8Export &rWW8Wrt, const SdrUnoObj& rFormObj)
 {
     if (!rWW8Wrt.bWrtWW8)
         return false;
 
-    const SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObj);
-    assert(pFormObj);
-    if (!pFormObj)
-        return false;
     uno::Reference< awt::XControlModel > xControlModel =
-    pFormObj->GetUnoControlModel();
+        rFormObj.GetUnoControlModel();
 
     //Why oh lord do we use so many different units ?
     //I think I painted myself into a little bit of a
     //corner by trying to use the uno interface for
     //controls export
-    Rectangle aRect = pFormObj->GetLogicRect();
+    Rectangle aRect = rFormObj.GetLogicRect();
     aRect.SetPos(Point(0,0));
     awt::Size aSize;
     aSize.Width = TWIPS_TO_MM(aRect.Right());
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 74134b3..b46f2b4 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -30,6 +30,7 @@
 #include <editeng/fontitem.hxx>
 #include <svx/svdobj.hxx>
 #include <svx/svdotext.hxx>
+#include <svx/svdouno.hxx>
 #include <svx/fmglob.hxx>
 #include <editeng/frmdiritem.hxx>
 #include <editeng/lrspitem.hxx>
@@ -2165,11 +2166,11 @@ bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
                     {
                         sal_uInt8 nOldTyp = rWrt.nTxtTyp;
                         rWrt.nTxtTyp = nTTyp;
-                        rWrt.GetOCXExp().ExportControl(rWrt,&rObj);
+                        rWrt.GetOCXExp().ExportControl(rWrt, dynamic_cast<const SdrUnoObj&>(rObj));
                         rWrt.nTxtTyp = nOldTyp;
                     }
                     else if( rObj.ISA( SdrTextObj ) )
-                        rWrt.WriteSdrTextObj(rObj, nTTyp);
+                        rWrt.WriteSdrTextObj(dynamic_cast<const SdrTextObj&>(rObj), nTTyp);
                     else
                     {
                         const SwFrmFmt* pFmt = ::FindFrmFmt( &rObj );
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index 3478521..a029063 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -61,6 +61,7 @@ class DateTime;
 namespace vcl { class Font; }
 class MSWordExportBase;
 class SdrObject;
+class SdrTextObj;
 class SfxItemSet;
 class SvStream;
 class SvxFontItem;
@@ -1038,7 +1039,7 @@ public:
 
     void AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft);
     void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
-    void WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp);
+    void WriteSdrTextObj(const SdrTextObj& rObj, sal_uInt8 nTyp);
 
     sal_uInt32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const;
     void CreateEscher();
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index da3610b..ca6b5fa 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -89,6 +89,7 @@ class SdrModel;
 class SdrPage;
 class SdrObject;
 class SdrTextObj;
+class SdrUnoObj;
 class Size;
 class EditEngine;
 struct SwPosition;
@@ -749,7 +750,7 @@ public:
         const ::com::sun::star::awt::Size& rSize,
         com::sun::star::uno::Reference <
         com::sun::star::drawing::XShape > *pShape, bool bFloatingCtrl) SAL_OVERRIDE;
-    bool ExportControl(WW8Export &rWrt, const SdrObject *pObj);
+    bool ExportControl(WW8Export &rWrt, const SdrUnoObj& rFormObj);
     bool ReadOCXStream( SotStorageRef& rSrc1,
         com::sun::star::uno::Reference<
         com::sun::star::drawing::XShape > *pShapeRef=0,
commit b6ac3a95570a1e648e030994c33a5a6c570e266c
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 2 17:14:33 2015 +0000

    coverity#705106 rearrange the assert and condition
    
    Change-Id: I40c0f00af941d0aa25e99bdd772b1ac4258cddd6

diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 8051639..a184f98 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1323,13 +1323,11 @@ static sal_uInt16 lcl_CalculateSplitLineHeights( SwSplitLines &rCurr, SwSplitLin
         }
     }
 
-    if( aBoxes.empty() )
-        return 0;
-
-    //coverity#705106, help coverity out here
-    assert(nFirst != USHRT_MAX);
     if (nFirst == USHRT_MAX)
+    {
+        assert(aBoxes.empty());
         return 0;
+    }
 
     SwTwips nHeight = 0;
     SwTwips* pLines = new SwTwips[ nLast + 1 - nFirst ];
commit fd35fad16a656d333bdbf1cc9214d1185d33ceb3
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Feb 2 16:40:49 2015 +0000

    coverity#1267629 Logically dead code
    
    Change-Id: I5ac6fd2507bda0c985abb54e2269563ed79afc6a

diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 509637d..3a47a8a 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -2031,15 +2031,12 @@ void OOXMLFastContextHandlerMath::process()
     assert(ref.is());
     if (!ref.is())
         return;
-    uno::Reference< uno::XInterface > component( ref->getComponent(), uno::UNO_QUERY );
+    uno::Reference< uno::XInterface > component(ref->getComponent(), uno::UNO_QUERY_THROW);
 // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
 // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
 // to RTLD_GLOBAL, so most probably a gcc bug.
-    oox::FormulaImportBase* import = dynamic_cast< oox::FormulaImportBase* >( dynamic_cast< SfxBaseModel* >(component.get()));
-    assert( import != nullptr );
-    if (!import)
-        return;
-    import->readFormulaOoxml( buffer );
+    oox::FormulaImportBase& import = dynamic_cast<oox::FormulaImportBase&>(dynamic_cast<SfxBaseModel&>(*component.get()));
+    import.readFormulaOoxml(buffer);
     if (isForwardEvents())
     {
         OOXMLPropertySet * pProps = new OOXMLPropertySetImpl();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index d24b5d2..28607ea 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -5539,14 +5539,12 @@ RTFError RTFDocumentImpl::popState()
         comphelper::EmbeddedObjectContainer aContainer;
         OUString aName;
         uno::Reference<embed::XEmbeddedObject> xObject = aContainer.CreateEmbeddedObject(aGlobalName.GetByteSequence(), aName);
-        uno::Reference<util::XCloseable> xComponent(xObject->getComponent(), uno::UNO_QUERY);
+        uno::Reference<util::XCloseable> xComponent(xObject->getComponent(), uno::UNO_QUERY_THROW);
         // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
         // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
         // to RTLD_GLOBAL, so most probably a gcc bug.
-        oox::FormulaImportBase* pImport = dynamic_cast<oox::FormulaImportBase*>(dynamic_cast<SfxBaseModel*>(xComponent.get()));
-        assert(pImport != nullptr);
-        if (pImport)
-            pImport->readFormulaOoxml(m_aMathBuffer);
+        oox::FormulaImportBase& rImport = dynamic_cast<oox::FormulaImportBase&>(dynamic_cast<SfxBaseModel&>(*xComponent.get()));
+        rImport.readFormulaOoxml(m_aMathBuffer);
         auto pValue = std::make_shared<RTFValue>(xObject);
         RTFSprms aMathAttributes;
         aMathAttributes.set(NS_ooxml::LN_starmath, pValue);


More information about the Libreoffice-commits mailing list