[Libreoffice-commits] core.git: sw/source

Caolán McNamara caolanm at redhat.com
Fri Oct 16 09:15:11 PDT 2015


 sw/source/filter/ww8/docxattributeoutput.cxx |   12 ++++-----
 sw/source/filter/ww8/writerhelper.hxx        |   35 ---------------------------
 sw/source/filter/ww8/writerwordglue.cxx      |    6 ++--
 sw/source/filter/ww8/wrtww8gr.cxx            |    4 ---
 sw/source/filter/ww8/ww8atr.cxx              |   10 ++-----
 sw/source/filter/ww8/ww8par3.cxx             |    5 ---
 6 files changed, 14 insertions(+), 58 deletions(-)

New commits:
commit 71ec25ea725ee887a789fdb9dc2b221b8525bc61
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Oct 16 12:50:37 2015 +0100

    drop templated HasItem in favour of new templated SfxItemSet::GetItem
    
    Change-Id: Ia753e8728a68b90cbf7fe3adda1de8a3297bd782

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index c961698..24b943d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2970,7 +2970,7 @@ void DocxAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Point
                 FSEND );
     }
 
-    if (const SfxGrabBagItem* pItem = sw::util::HasItem<SfxGrabBagItem>(pTableBox->GetFrameFormat()->GetAttrSet(), RES_FRMATR_GRABBAG))
+    if (const SfxGrabBagItem* pItem = pTableBox->GetFrameFormat()->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG))
     {
         const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag();
         std::map<OUString, uno::Any>::const_iterator it = rGrabBag.find("CellCnfStyle");
@@ -3081,7 +3081,7 @@ void DocxAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t p
 
     const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox();
     const SwTableLine* pTableLine = pTableBox->GetUpper();
-    if (const SfxGrabBagItem* pItem = sw::util::HasItem<SfxGrabBagItem>(pTableLine->GetFrameFormat()->GetAttrSet(), RES_FRMATR_GRABBAG))
+    if (const SfxGrabBagItem* pItem = pTableLine->GetFrameFormat()->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG))
     {
         const std::map<OUString, uno::Any>& rGrabBag = pItem->GetGrabBag();
         std::map<OUString, uno::Any>::const_iterator it = rGrabBag.find("RowCnfStyle");
@@ -3241,7 +3241,7 @@ void DocxAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t
 
     // Look for the table style property in the table grab bag
     std::map<OUString, com::sun::star::uno::Any> aGrabBag =
-            sw::util::HasItem<SfxGrabBagItem>( pTableFormat->GetAttrSet(), RES_FRMATR_GRABBAG )->GetGrabBag();
+            pTableFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag();
 
     // We should clear the TableStyle map. In case of Table inside multiple tables it contains the
     // table border style of the previous table.
@@ -3463,12 +3463,12 @@ void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_
     const SwTableBox *pTableBox = pTableTextNodeInfoInner->getTableBox( );
     const SwFrameFormat *pFormat = pTableBox->GetFrameFormat( );
 
-    const SvxBrushItem *aColorProp = sw::util::HasItem<SvxBrushItem>( pFormat->GetAttrSet(), RES_BACKGROUND );
-    Color aColor = aColorProp ? aColorProp->GetColor() : COL_AUTO;
+    const SvxBrushItem *pColorProp = pFormat->GetAttrSet().GetItem<SvxBrushItem>(RES_BACKGROUND);
+    Color aColor = pColorProp ? pColorProp->GetColor() : COL_AUTO;
     OString sColor = msfilter::util::ConvertColor( aColor );
 
     std::map<OUString, com::sun::star::uno::Any> aGrabBag =
-            sw::util::HasItem<SfxGrabBagItem>( pFormat->GetAttrSet(), RES_FRMATR_GRABBAG )->GetGrabBag();
+            pFormat->GetAttrSet().GetItem<SfxGrabBagItem>(RES_FRMATR_GRABBAG)->GetGrabBag();
 
     OString sOriginalColor;
     std::map<OUString, com::sun::star::uno::Any>::iterator aGrabBagElement = aGrabBag.find("originalColor");
diff --git a/sw/source/filter/ww8/writerhelper.hxx b/sw/source/filter/ww8/writerhelper.hxx
index 29f231a..0f5f528 100644
--- a/sw/source/filter/ww8/writerhelper.hxx
+++ b/sw/source/filter/ww8/writerhelper.hxx
@@ -428,41 +428,6 @@ namespace sw
             return DefaultItemGet<T>(rDoc.GetAttrPool(), eType);
         }
 
-        /** Return a pointer to a SfxPoolItem derived class if it exists in an
-            SfxItemSet
-
-            Writer's attributes are retrieved by passing a numeric identifier
-            and receiving a SfxPoolItem reference which must then typically be
-            cast back to its original type which is both tedious and verbose.
-
-            HasItem returns a pointer to the requested SfxPoolItem for a given
-            property id if it exists in the SfxItemSet or its chain of parents,
-            e.g. fontsize
-
-            HasItem uses item_cast () on the retrieved pointer to test that the
-            retrieved property is of the type that the developer thinks it is.
-
-            @param rSet
-            The SfxItemSet whose property we want
-
-            @param eType
-            The numeric identifier of the default property to be retrieved
-
-            @tplparam T
-            A SfxPoolItem derived class of the retrieved property
-
-            @return The T requested or 0 if no T found with id eType
-
-            @author
-            <a href="mailto:cmc at openoffice.org">Caolán McNamara</a>
-        */
-        template<class T> const T* HasItem(const SfxItemSet &rSet,
-            sal_uInt16 eType)
-        {
-            return item_cast<T>(rSet.GetItem(eType));
-        }
-
-
         /** Get the Paragraph Styles of a SwDoc
 
             Writer's styles are in one of those dreaded macro based pre-STL
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 9827113..a7fe1f0 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -392,7 +392,7 @@ namespace sw
 
         HdFtDistanceGlue::HdFtDistanceGlue(const SfxItemSet &rPage)
         {
-            if (const SvxBoxItem *pBox = HasItem<SvxBoxItem>(rPage, RES_BOX))
+            if (const SvxBoxItem *pBox = rPage.GetItem<SvxBoxItem>(RES_BOX))
             {
                 dyaHdrTop = pBox->CalcLineSpace(SvxBoxItemLine::TOP);
                 dyaHdrBottom = pBox->CalcLineSpace(SvxBoxItemLine::BOTTOM);
@@ -410,7 +410,7 @@ namespace sw
             dyaTop = dyaHdrTop;
             dyaBottom = dyaHdrBottom;
 
-            const SwFormatHeader *pHd = HasItem<SwFormatHeader>(rPage, RES_HEADER);
+            const SwFormatHeader *pHd = rPage.GetItem<SwFormatHeader>(RES_HEADER);
             if (pHd && pHd->IsActive() && pHd->GetHeaderFormat())
             {
                 mbHasHeader = true;
@@ -419,7 +419,7 @@ namespace sw
             else
                 mbHasHeader = false;
 
-            const SwFormatFooter *pFt = HasItem<SwFormatFooter>(rPage, RES_FOOTER);
+            const SwFormatFooter *pFt = rPage.GetItem<SwFormatFooter>(RES_FOOTER);
             if (pFt && pFt->IsActive() && pFt->GetFooterFormat())
             {
                 mbHasFooter = true;
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index 3ce1b18..ab7edbb 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -536,9 +536,7 @@ void SwWW8WrGrf::WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly,
         if( pBox )
         {
             bool bShadow = false;               // Shadow ?
-            const SvxShadowItem* pSI =
-                sw::util::HasItem<SvxShadowItem>(rAttrSet, RES_SHADOW);
-            if (pSI)
+            if (const SvxShadowItem* pSI = rAttrSet.GetItem<SvxShadowItem>(RES_SHADOW))
             {
                 bShadow = (pSI->GetLocation() != SVX_SHADOW_NONE) &&
                     (pSI->GetWidth() != 0);
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 303f338..54e35d0 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -623,10 +623,7 @@ void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet,
 
 void MSWordExportBase::CorrectTabStopInSet( SfxItemSet& rSet, sal_uInt16 nAbsLeft )
 {
-    const SvxTabStopItem *pItem =
-        sw::util::HasItem<SvxTabStopItem>( rSet, RES_PARATR_TABSTOP );
-
-    if ( pItem )
+    if (const SvxTabStopItem *pItem = rSet.GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP))
     {
         // dann muss das fuer die Ausgabe korrigiert werden
         SvxTabStopItem aTStop(*pItem);
@@ -4751,8 +4748,7 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
         SvxTabStopItem aParentTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
         const SwFormat *pParentStyle = m_rWW8Export.m_pCurrentStyle->DerivedFrom();
         {
-            const SvxTabStopItem* pParentTabs = HasItem<SvxTabStopItem>( pParentStyle->GetAttrSet(), RES_PARATR_TABSTOP );
-            if ( pParentTabs )
+            if (const SvxTabStopItem* pParentTabs = pParentStyle->GetAttrSet().GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP))
             {
                 aParentTabs.Insert( pParentTabs );
             }
@@ -4773,7 +4769,7 @@ void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
     const SvxTabStopItem* pStyleTabs = 0;
     if ( !m_rWW8Export.m_bStyDef && m_rWW8Export.m_pStyAttr )
     {
-        pStyleTabs = HasItem<SvxTabStopItem>( *m_rWW8Export.m_pStyAttr, RES_PARATR_TABSTOP );
+        pStyleTabs = m_rWW8Export.m_pStyAttr->GetItem<SvxTabStopItem>(RES_PARATR_TABSTOP);
     }
 
     if ( !pStyleTabs )
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index a6d0fc5..4ddc311 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1912,10 +1912,7 @@ void SwWW8ImplReader::RegisterNumFormatOnTextNode(sal_uInt16 nActLFO,
                     SetAktItemSet(pOldAktItemSet);
                 }
 
-                const SvxLRSpaceItem *pLR =
-                    HasItem<SvxLRSpaceItem>(aListIndent, RES_LR_SPACE);
-                OSL_ENSURE(pLR, "Impossible");
-                if (pLR)
+                if (const SvxLRSpaceItem *pLR = aListIndent.GetItem<SvxLRSpaceItem>(RES_LR_SPACE))
                 {
                     m_pCtrlStck->NewAttr(*m_pPaM->GetPoint(), *pLR);
                     m_pCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_LR_SPACE);


More information about the Libreoffice-commits mailing list