Incorrect OSL_ENSURE -> SAL_WARN_IF conversions (Re: [Libreoffice-commits] .: sw/source)

Lubos Lunak l.lunak at suse.cz
Wed Jun 6 09:28:48 PDT 2012


 Hello,

 please note that when convering from the obsolete OSL_ENSURE or similar 
macros to SAL_WARN_IF, the condition needs to be inverted. OSL_ENSURE is a 
(broken) assert-like macro and so it requires the condition to be true or it 
warns. SAL_WARN_IF, as the name says, requires the condition to be false and 
warns on true.

On Wednesday 06 of June 2012, Lubos Lunak wrote:
>  sw/source/core/unocore/unodraw.cxx |   18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> New commits:
> commit dfc4832049c140b7442c085062599aef1953e8fd
> Author: Luboš Luňák <l.lunak at suse.cz>
> Date:   Wed Jun 6 18:17:50 2012 +0200
>
>     fix incorrect OSL_ENSURE -> SAL_WARN_IF conversion (condition not
> inverted)
>
>     Change-Id: I57dfa64c55e046ed51797b2abeb7ba3242e637da
>
> diff --git a/sw/source/core/unocore/unodraw.cxx
> b/sw/source/core/unocore/unodraw.cxx index 662a8ff..329bed9 100644
> --- a/sw/source/core/unocore/unodraw.cxx
> +++ b/sw/source/core/unocore/unodraw.cxx
> @@ -1174,7 +1174,7 @@ void SwXShape::setPropertyValue(const rtl::OUString&
> rPropertyName, const uno::A else if(RES_OPAQUE == pEntry->nWID)
>                  {
>                      SvxShape* pSvxShape = GetSvxShape();
> -                    SAL_WARN_IF(pSvxShape, "sw.uno", "No SvxShape
> found!"); +                    SAL_WARN_IF(!pSvxShape, "sw.uno", "No
> SvxShape found!"); if(pSvxShape)
>                      {
>                          SdrObject* pObj = pSvxShape->GetSdrObject();
> @@ -1220,14 +1220,14 @@ void SwXShape::setPropertyValue(const
> rtl::OUString& rPropertyName, const uno::A //To prevent this the connection
> between format and attribute has to be broken before. const SwPosition
> *pPos = aAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode =
> pPos->nNode.GetNode().GetTxtNode(); -                               
> SAL_WARN_IF( pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." ); + 
>                               SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno",
> "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx =
> pPos->nContent.GetIndex(); SwTxtAttr * const pHnt =
>                                      pTxtNode->GetTxtAttrForCharAt(
>                                          nIdx, RES_TXTATR_FLYCNT );
> -                                SAL_WARN_IF( pHnt && pHnt->Which() ==
> RES_TXTATR_FLYCNT, +                                SAL_WARN_IF( !pHnt ||
> pHnt->Which() != RES_TXTATR_FLYCNT, "sw.uno", "Missing FlyInCnt-Hint." ); -
>                                SAL_WARN_IF( pHnt &&
> pHnt->GetFlyCnt().GetFrmFmt() == pFmt, +                               
> SAL_WARN_IF( !pHnt || pHnt->GetFlyCnt().GetFrmFmt() != pFmt, "sw.uno",
> "Wrong TxtFlyCnt-Hint." ); const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
> .SetFlyFmt();
> @@ -1237,7 +1237,7 @@ void SwXShape::setPropertyValue(const rtl::OUString&
> rPropertyName, const uno::A RES_TXTATR_FLYCNT, nIdx );
>                                  //create a new one
>                                  SwTxtNode *pNd =
> pInternalPam->GetNode()->GetTxtNode(); -                               
> SAL_WARN_IF( pNd, "sw.uno", "Cursor not at TxtNode." ); +                  
>              SAL_WARN_IF( !pNd, "sw.uno", "Cursor not at TxtNode." );
> SwFmtFlyCnt aFmt( pFmt );
>                                  pNd->InsertItem(aFmt,
> pInternalPam->GetPoint() ->nContent.GetIndex(), 0 ); @@ -1306,14 +1306,14
> @@ void SwXShape::setPropertyValue(const rtl::OUString& rPropertyName,
> const uno::A //To prevent this the connection between format and attribute
> has to be broken before. const SwPosition *pPos =
> rOldAnchor.GetCntntAnchor(); SwTxtNode *pTxtNode =
> pPos->nNode.GetNode().GetTxtNode(); -                           
> SAL_WARN_IF( pTxtNode->HasHints(), "sw.uno", "Missing FlyInCnt-Hint." ); + 
>                           SAL_WARN_IF( !pTxtNode->HasHints(), "sw.uno",
> "Missing FlyInCnt-Hint." ); const xub_StrLen nIdx =
> pPos->nContent.GetIndex(); SwTxtAttr * const pHnt =
>                                  pTxtNode->GetTxtAttrForCharAt(
>                                      nIdx, RES_TXTATR_FLYCNT );
> -                            SAL_WARN_IF( pHnt && pHnt->Which() ==
> RES_TXTATR_FLYCNT, +                            SAL_WARN_IF( !pHnt ||
> pHnt->Which() != RES_TXTATR_FLYCNT, "sw.uno", "Missing FlyInCnt-Hint." ); -
>                            SAL_WARN_IF( pHnt &&
> pHnt->GetFlyCnt().GetFrmFmt() == pFlyFmt, +                           
> SAL_WARN_IF( !pHnt || pHnt->GetFlyCnt().GetFrmFmt() != pFlyFmt, "sw.uno",
> "Wrong TxtFlyCnt-Hint." ); const_cast<SwFmtFlyCnt&>(pHnt->GetFlyCnt())
> .SetFlyFmt();
> @@ -1349,7 +1349,7 @@ void SwXShape::setPropertyValue(const rtl::OUString&
> rPropertyName, const uno::A {
>                                  //the RES_TXTATR_FLYCNT needs to be added
> now SwTxtNode *pNd = aPam.GetNode()->GetTxtNode(); -                       
>         SAL_WARN_IF( pNd, "sw.uno", "Crsr is not in a TxtNode." ); +       
>                         SAL_WARN_IF( !pNd, "sw.uno", "Crsr is not in a
> TxtNode." ); SwFmtFlyCnt aFmt( pFlyFmt );
>                                  pNd->InsertItem(aFmt,
>                                      aPam.GetPoint()->nContent.GetIndex(),
> 0 );
-- 
 Lubos Lunak
 l.lunak at suse.cz


More information about the LibreOffice mailing list