xmloff/inc/MultiPropertySetHelper.hxx | 13 +-- xmloff/source/core/xmltoken.cxx | 12 +-- xmloff/source/style/impastpl.cxx | 58 ++++----------- xmloff/source/style/styleexp.cxx | 128 +++++++++++++++------------------- xmloff/source/style/xmlaustp.cxx | 9 +- xmloff/source/style/xmlstyle.cxx | 18 ++-- 6 files changed, 100 insertions(+), 138 deletions(-)
New commits: commit 4b08e98630f3ff81879b787f6597f1f8401bbad8 Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 14:35:54 2015 +0200 xmloff: convert legacy assertions in SvXMLAutoStylePoolP Change-Id: Ibf3afcfb3f4dc400faa18a726ec47d58a230de65 diff --git a/xmloff/source/style/xmlaustp.cxx b/xmloff/source/style/xmlaustp.cxx index b541766..0a8e22e 100644 --- a/xmloff/source/style/xmlaustp.cxx +++ b/xmloff/source/style/xmlaustp.cxx @@ -44,11 +44,11 @@ namespace static void lcl_exportDataStyle( SvXMLExport& _rExport, const rtl::Reference< XMLPropertySetMapper >& _rxMapper, const XMLPropertyState& _rProperty ) { - DBG_ASSERT( _rxMapper.is(), "xmloff::lcl_exportDataStyle: invalid property mapper!" ); + assert(_rxMapper.is()); // obtain the data style name OUString sDataStyleName; _rProperty.maValue >>= sDataStyleName; - DBG_ASSERT( !sDataStyleName.isEmpty(), "xmloff::lcl_exportDataStyle: invalid property value for the data style name!" ); + assert(!sDataStyleName.isEmpty() && "xmloff::lcl_exportDataStyle: invalid property value for the data style name!"); // add the attribute _rExport.AddAttribute( @@ -88,7 +88,7 @@ void SvXMLAutoStylePoolP::exportStyleAttributes( if( (XML_STYLE_FAMILY_SD_GRAPHICS_ID == nFamily) || (XML_STYLE_FAMILY_SD_PRESENTATION_ID == nFamily) ) { // it's a graphics style rtl::Reference< XMLPropertySetMapper > aPropertyMapper = rPropExp.getPropertySetMapper(); - DBG_ASSERT(aPropertyMapper.is(), "SvXMLAutoStylePoolP::exportStyleAttributes: invalid property set mapper!"); + assert(aPropertyMapper.is()); bool bFoundControlShapeDataStyle = false; bool bFoundNumberingRulesName = false; @@ -322,8 +322,7 @@ void SvXMLAutoStylePoolP::RegisterNames( uno::Sequence<sal_Int32>& aFamilies, uno::Sequence<OUString>& aNames ) { - DBG_ASSERT( aFamilies.getLength() == aNames.getLength(), - "aFamilies != aNames" ); + assert(aFamilies.getLength() == aNames.getLength()); // iterate over sequence(s) and call RegisterName(..) for each pair const sal_Int32* pFamilies = aFamilies.getConstArray(); commit f7f48dd4bb8c20d9165b13f79df25da5f2e27bc8 Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 14:22:41 2015 +0200 xmloff: convert legacy assertions in XMLStyleExport Change-Id: I39146bc6005c43b034243d587dda17839b8e72e7 diff --git a/xmloff/source/style/styleexp.cxx b/xmloff/source/style/styleexp.cxx index 43fbab8..c6b62e8 100644 --- a/xmloff/source/style/styleexp.cxx +++ b/xmloff/source/style/styleexp.cxx @@ -240,17 +240,13 @@ bool XMLStyleExport::exportStyle( { Reference< XIndexReplace > xNumRule ( xCNSupplier->getChapterNumberingRules() ); - DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" ); - - if (xNumRule.is()) - { - Reference< XPropertySet > xNumRulePropSet - (xNumRule, UNO_QUERY); - xNumRulePropSet->getPropertyValue( - OUString("Name") ) - >>= sOutlineName; - bSuppressListStyle = ( sListName == sOutlineName ); - } + assert(xNumRule.is()); + + Reference< XPropertySet > xNumRulePropSet + (xNumRule, UNO_QUERY); + xNumRulePropSet->getPropertyValue("Name") + >>= sOutlineName; + bSuppressListStyle = sListName == sOutlineName; } } } @@ -379,7 +375,7 @@ void XMLStyleExport::exportStyleFamily( const rtl::Reference < SvXMLExportPropertyMapper >& rPropMapper, bool bUsed, sal_uInt16 nFamily, const OUString* pPrefix) { - DBG_ASSERT( GetExport().GetModel().is(), "There is the model?" ); + assert(GetExport().GetModel().is()); Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetExport().GetModel(), UNO_QUERY ); if( !xFamiliesSupp.is() ) return; // family not available in current model @@ -418,38 +414,35 @@ void XMLStyleExport::exportStyleFamily( continue; } - DBG_ASSERT( xStyle.is(), "Style not found for export!" ); - if( xStyle.is() ) + assert(xStyle.is()); + if (!bUsed || xStyle->isInUse()) { - if( !bUsed || xStyle->isInUse() ) + bool bExported = exportStyle( xStyle, rXMLFamily, rPropMapper, + xStyleCont,pPrefix ); + if (bUsed && bFirstStyle && bExported) { - bool bExported = exportStyle( xStyle, rXMLFamily, rPropMapper, - xStyleCont,pPrefix ); - if( bUsed && bFirstStyle && bExported ) - { - // If this is the first style, find out whether next styles - // are supported. - Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY ); - Reference< XPropertySetInfo > xPropSetInfo = - xPropSet->getPropertySetInfo(); - - if( xPropSetInfo->hasPropertyByName( sFollowStyle ) ) - pExportedStyles.reset(new std::set<OUString>()); - bFirstStyle = false; - } + // If this is the first style, find out whether next styles + // are supported. + Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY ); + Reference< XPropertySetInfo > xPropSetInfo = + xPropSet->getPropertySetInfo(); - if( pExportedStyles && bExported ) - { - // If next styles are supported, remember this style's name. - pExportedStyles->insert( xStyle->getName() ); - } + if (xPropSetInfo->hasPropertyByName( sFollowStyle )) + pExportedStyles.reset(new std::set<OUString>()); + bFirstStyle = false; } - // if an auto style pool is given, remember this style's name as a - // style name that must not be used by automatic styles. - if( pAutoStylePool ) - pAutoStylePool->RegisterName( nFamily, xStyle->getName() ); + if (pExportedStyles && bExported) + { + // If next styles are supported, remember this style's name. + pExportedStyles->insert( xStyle->getName() ); + } } + + // if an auto style pool is given, remember this style's name as a + // style name that must not be used by automatic styles. + if (pAutoStylePool) + pAutoStylePool->RegisterName( nFamily, xStyle->getName() ); } if( pExportedStyles ) @@ -462,43 +455,40 @@ void XMLStyleExport::exportStyleFamily( Reference< XStyle > xStyle; xStyleCont->getByName( *pIter ) >>= xStyle; - DBG_ASSERT( xStyle.is(), "Style not found for export!" ); - if( xStyle.is() ) - { - Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY ); - Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + assert(xStyle.is()); - // styles that aren't existing really are ignored. - if( xPropSetInfo->hasPropertyByName( sIsPhysical ) ) - { - Any aAny( xPropSet->getPropertyValue( sIsPhysical ) ); - if( !*static_cast<sal_Bool const *>(aAny.getValue()) ) - continue; - } + Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY ); + Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - if( !xStyle->isInUse() ) + // styles that aren't existing really are ignored. + if (xPropSetInfo->hasPropertyByName( sIsPhysical )) + { + Any aAny( xPropSet->getPropertyValue( sIsPhysical ) ); + if (!*static_cast<sal_Bool const *>(aAny.getValue())) continue; + } - if( !xPropSetInfo->hasPropertyByName( sFollowStyle ) ) - { - DBG_ASSERT( sFollowStyle.isEmpty(), "no follow style???" ); - continue; - } + if (!xStyle->isInUse()) + continue; - OUString sNextName; - xPropSet->getPropertyValue( sFollowStyle ) >>= sNextName; - OUString sTmp( sNextName ); - // if the next style hasn't been exported by now, export it now - // and remember its name. - if( xStyle->getName() != sNextName && - 0 == pExportedStyles->count( sTmp ) ) - { - xStyleCont->getByName( sNextName ) >>= xStyle; - DBG_ASSERT( xStyle.is(), "Style not found for export!" ); + if (!xPropSetInfo->hasPropertyByName( sFollowStyle )) + { + continue; + } - if( xStyle.is() && exportStyle( xStyle, rXMLFamily, rPropMapper, xStyleCont, pPrefix ) ) - pExportedStyles->insert( sTmp ); - } + OUString sNextName; + xPropSet->getPropertyValue( sFollowStyle ) >>= sNextName; + OUString sTmp( sNextName ); + // if the next style hasn't been exported by now, export it now + // and remember its name. + if (xStyle->getName() != sNextName && + 0 == pExportedStyles->count( sTmp )) + { + xStyleCont->getByName( sNextName ) >>= xStyle; + assert(xStyle.is()); + + if (exportStyle(xStyle, rXMLFamily, rPropMapper, xStyleCont, pPrefix)) + pExportedStyles->insert( sTmp ); } } } commit 9beae152a30baeab8d2d461410d83de1c7c1f7f2 Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 14:09:29 2015 +0200 xmloff: convert legacy assertions in SvXMLAutoStylePoolP_Impl::exportXML Change-Id: I9f21ad73a8a30e0b9d0d515713cc95b303f973f7 diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index 0312386..a2a34ff 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -484,7 +484,7 @@ void SvXMLAutoStylePoolP_Impl::GetRegisteredNames( } // copy the families + names into the sequence types - DBG_ASSERT( aFamilies.size() == aNames.size(), "families != names" ); + assert(aFamilies.size() == aNames.size()); rFamilies.realloc( aFamilies.size() ); std::copy( aFamilies.begin(), aFamilies.end(), rFamilies.getArray() ); @@ -638,15 +638,10 @@ void SvXMLAutoStylePoolP_Impl::exportXML( XMLAutoStylePoolProperties* pProperties = &rParent.GetPropertiesList()[j]; sal_uLong nPos = pProperties->GetPos(); - DBG_ASSERT( nPos < nCount, - "SvXMLAutoStylePool_Impl::exportXML: wrong position" ); - if( nPos < nCount ) - { - DBG_ASSERT( !aExpStyles[nPos].mpProperties, - "SvXMLAutoStylePool_Impl::exportXML: double position" ); - aExpStyles[nPos].mpProperties = pProperties; - aExpStyles[nPos].mpParent = &rParent.GetParent(); - } + assert(nPos < nCount); + assert(!aExpStyles[nPos].mpProperties); + aExpStyles[nPos].mpProperties = pProperties; + aExpStyles[nPos].mpParent = &rParent.GetParent(); } } @@ -674,8 +669,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML( for( size_t i = 0; i < nCount; i++ ) { - DBG_ASSERT( aExpStyles[i].mpProperties, - "SvXMLAutoStylePool_Impl::exportXML: empty position" ); + assert(aExpStyles[i].mpProperties); if( aExpStyles[i].mpProperties ) { commit ce0ed76f5a8cb3efe61a6d483e43b1f363b6080d Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 13:53:22 2015 +0200 xmloff: assert when a non-existent auto style pool is requested Change-Id: Ibff35f5c88d50f9e28c5e0c4e3dfb59f62d679a8 diff --git a/xmloff/source/style/impastpl.cxx b/xmloff/source/style/impastpl.cxx index 83d42ca..0312386 100644 --- a/xmloff/source/style/impastpl.cxx +++ b/xmloff/source/style/impastpl.cxx @@ -453,13 +453,9 @@ void SvXMLAutoStylePoolP_Impl::RegisterName( sal_Int32 nFamily, const OUString& { XMLAutoStyleFamily aTmp( nFamily ); FamilySetType::iterator aFind = maFamilySet.find(aTmp); - DBG_ASSERT( aFind != maFamilySet.end(), - "SvXMLAutoStylePool_Impl::RegisterName: unknown family" ); - if (aFind != maFamilySet.end()) - { - // SAL_DEBUG("SvXMLAutoStylePoolP_Impl::RegisterName: " << nFamily << ", '" << rName << "'"); - aFind->maNameSet.insert(rName); - } + assert(aFind != maFamilySet.end()); // family must be known + // SAL_DEBUG("SvXMLAutoStylePoolP_Impl::RegisterName: " << nFamily << ", '" << rName << "'"); + aFind->maNameSet.insert(rName); } @@ -506,10 +502,7 @@ bool SvXMLAutoStylePoolP_Impl::Add( { XMLAutoStyleFamily aTemporary( nFamily ); FamilySetType::iterator aFind = maFamilySet.find(aTemporary); - DBG_ASSERT(aFind != maFamilySet.end(), "SvXMLAutoStylePool_Impl::Add: unknown family"); - - if (aFind == maFamilySet.end()) - return false; + assert(aFind != maFamilySet.end()); // family must be known XMLAutoStyleFamily &rFamily = *aFind; @@ -542,10 +535,7 @@ bool SvXMLAutoStylePoolP_Impl::AddNamed( XMLAutoStyleFamily aTemporary( nFamily ); FamilySetType::iterator aFind = maFamilySet.find(aTemporary); - DBG_ASSERT(aFind != maFamilySet.end(), "SvXMLAutoStylePool_Impl::Add: unknown family"); - - if (aFind == maFamilySet.end()) - return false; + assert(aFind != maFamilySet.end()); // family must be known XMLAutoStyleFamily &rFamily = *aFind; @@ -582,17 +572,14 @@ OUString SvXMLAutoStylePoolP_Impl::Find( sal_Int32 nFamily, XMLAutoStyleFamily aTemporary( nFamily ); FamilySetType::const_iterator const iter = maFamilySet.find(aTemporary); - OSL_ENSURE(iter != maFamilySet.end(), "SvXMLAutoStylePool_Impl::Find: unknown family"); + assert(iter != maFamilySet.end()); // family must be known - if (iter != maFamilySet.end()) + XMLAutoStyleFamily const& rFamily = *iter; + XMLAutoStylePoolParent aTmp( rParent ); + XMLAutoStyleFamily::ParentSetType::const_iterator it2 = rFamily.maParentSet.find(aTmp); + if (it2 != rFamily.maParentSet.end()) { - XMLAutoStyleFamily const& rFamily = *iter; - XMLAutoStylePoolParent aTmp( rParent ); - XMLAutoStyleFamily::ParentSetType::const_iterator it2 = rFamily.maParentSet.find(aTmp); - if (it2 != rFamily.maParentSet.end()) - { - sName = it2->Find(rFamily, rProperties); - } + sName = it2->Find(rFamily, rProperties); } return sName; @@ -629,10 +616,7 @@ void SvXMLAutoStylePoolP_Impl::exportXML( // Get list of parents for current family (nFamily) XMLAutoStyleFamily aTmp( nFamily ); FamilySetType::const_iterator aFind = maFamilySet.find(aTmp); - DBG_ASSERT( aFind != maFamilySet.end(), - "SvXMLAutoStylePool_Impl::exportXML: unknown family" ); - if (aFind == maFamilySet.end()) - return; + assert(aFind != maFamilySet.end()); // family must be known const XMLAutoStyleFamily &rFamily = *aFind; sal_uInt32 nCount = rFamily.mnCount; commit 466f543825223388e75b03a628977ba95ae71c2e Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 13:44:38 2015 +0200 xmloff: convert legacy asserts in SvXMLStylesContext_Impl Change-Id: Ib9caf65f8cf1dc4ef9729f178fbe4ed032437be2 diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 93ede07..bd32909 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -255,8 +255,8 @@ class SvXMLStylesContext_Impl mutable IndicesType* pIndices; bool bAutomaticStyle; -#ifdef DBG_UTIL - mutable sal_uInt32 nIndexCreated; +#if OSL_DEBUG_LEVEL > 0 + mutable sal_uInt32 m_nIndexCreated; #endif void FlushIndex() { delete pIndices; pIndices = 0; } @@ -284,8 +284,8 @@ public: SvXMLStylesContext_Impl::SvXMLStylesContext_Impl( bool bAuto ) : pIndices( 0 ), bAutomaticStyle( bAuto ) -#ifdef DBG_UTIL -, nIndexCreated( 0 ) +#if OSL_DEBUG_LEVEL > 0 + , m_nIndexCreated( 0 ) #endif {} @@ -329,14 +329,12 @@ const SvXMLStyleContext *SvXMLStylesContext_Impl::FindStyleChildContext( sal_uIn if( !pIndices && bCreateIndex && !aStyles.empty() ) { -#ifdef DBG_UTIL - DBG_ASSERT( 0==nIndexCreated, - "Performance warning: sdbcx::Index created multiple times" ); -#endif + SAL_WARN_IF(0 != m_nIndexCreated, "xmloff.style", + "Performance warning: sdbcx::Index created multiple times"); pIndices = new IndicesType(aStyles.begin(), aStyles.end()); SAL_WARN_IF(pIndices->size() != aStyles.size(), "xmloff", "Here is a duplicate Style"); -#ifdef DBG_UTIL - ++nIndexCreated; +#if OSL_DEBUG_LEVEL > 0 + ++m_nIndexCreated; #endif } commit 227be0d87edcc3b92b90ccb4c0678d376d1dd6d4 Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 13:39:00 2015 +0200 xmloff: convert legacy asserts in MultiPropertySetHelper Change-Id: Ie4fb04d1c8d29eb5c7d9da4076c793a69954ab29 diff --git a/xmloff/inc/MultiPropertySetHelper.hxx b/xmloff/inc/MultiPropertySetHelper.hxx index 8467c16..f6a248d 100644 --- a/xmloff/inc/MultiPropertySetHelper.hxx +++ b/xmloff/inc/MultiPropertySetHelper.hxx @@ -172,11 +172,9 @@ public: const ::com::sun::star::uno::Any& MultiPropertySetHelper::getValue( sal_Int16 nValueNo ) { - DBG_ASSERT( pValues != NULL, - "called getValue() without calling getValues() before"); - DBG_ASSERT( pSequenceIndex != NULL, - "called getValue() without calling hasProperties() before" ); - DBG_ASSERT( nValueNo < nLength, "index out of range" ); + assert(pValues && "called getValue() without calling getValues()"); + assert(pSequenceIndex && "called getValue() without calling hasProperties()"); + assert(nValueNo < nLength); sal_Int16 nIndex = pSequenceIndex[ nValueNo ]; return ( nIndex != -1 ) ? pValues[ nIndex ] : aEmptyAny; @@ -184,9 +182,8 @@ const ::com::sun::star::uno::Any& MultiPropertySetHelper::getValue( bool MultiPropertySetHelper::hasProperty( sal_Int16 nValueNo ) { - DBG_ASSERT( pSequenceIndex != NULL, - "called getValue() without calling hasProperties() before" ); - DBG_ASSERT( nValueNo < nLength, "index out of range" ); + assert(pSequenceIndex && "called hasProperty() without calling hasProperties()"); + assert(nValueNo < nLength); return pSequenceIndex[ nValueNo ] != -1; } commit 42773c66d0239eccd4ad147c61c931b98fc9f5f0 Author: Michael Stahl <mst...@redhat.com> Date: Mon May 18 13:25:06 2015 +0200 xmloff: convert legacy assertions in xmltoken.cxx Change-Id: I852e6a6d805cc03920a467bf7f9739181b6c77d4 diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index e242f8c..b22c1ac 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3281,11 +3281,11 @@ namespace xmloff { namespace token { s_bChecked = true; // it's all static, checking once is enough } #endif - DBG_ASSERT( eToken > XML_TOKEN_INVALID, "token value too low!" ); - DBG_ASSERT( eToken < XML_TOKEN_END, "token value too high!" ); - DBG_ASSERT(sal_uInt16(eToken) < sizeof(aTokenList)/sizeof(aTokenList[0]),"Illegal position!"); + assert(XML_TOKEN_INVALID < eToken); + assert(eToken < XML_TOKEN_END); + assert(sal_uInt16(eToken) < SAL_N_ELEMENTS(aTokenList)); - XMLTokenEntry* pToken = &aTokenList[(sal_uInt16)eToken]; + XMLTokenEntry* pToken = &aTokenList[static_cast<sal_uInt16>(eToken)]; if (!pToken->pOUString) pToken->pOUString = new OUString( pToken->pChar, pToken->nLength, RTL_TEXTENCODING_ASCII_US ); @@ -3297,8 +3297,8 @@ namespace xmloff { namespace token { const OUString& rString, enum XMLTokenEnum eToken ) { - DBG_ASSERT( eToken > XML_TOKEN_INVALID, "token value too low!" ); - DBG_ASSERT( eToken < XML_TOKEN_END, "token value too high!" ); + assert(XML_TOKEN_INVALID < eToken); + assert(eToken < XML_TOKEN_END); const XMLTokenEntry* pToken = &aTokenList[(sal_uInt16)eToken]; return rString.equalsAsciiL( pToken->pChar, pToken->nLength ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits