Kaydet (Commit) f7f48dd4 authored tarafından Michael Stahl's avatar Michael Stahl

xmloff: convert legacy assertions in XMLStyleExport

Change-Id: I39146bc6005c43b034243d587dda17839b8e72e7
üst 9beae152
...@@ -240,17 +240,13 @@ bool XMLStyleExport::exportStyle( ...@@ -240,17 +240,13 @@ bool XMLStyleExport::exportStyle(
{ {
Reference< XIndexReplace > xNumRule Reference< XIndexReplace > xNumRule
( xCNSupplier->getChapterNumberingRules() ); ( xCNSupplier->getChapterNumberingRules() );
DBG_ASSERT( xNumRule.is(), "no chapter numbering rules" ); assert(xNumRule.is());
if (xNumRule.is()) Reference< XPropertySet > xNumRulePropSet
{ (xNumRule, UNO_QUERY);
Reference< XPropertySet > xNumRulePropSet xNumRulePropSet->getPropertyValue("Name")
(xNumRule, UNO_QUERY); >>= sOutlineName;
xNumRulePropSet->getPropertyValue( bSuppressListStyle = sListName == sOutlineName;
OUString("Name") )
>>= sOutlineName;
bSuppressListStyle = ( sListName == sOutlineName );
}
} }
} }
} }
...@@ -379,7 +375,7 @@ void XMLStyleExport::exportStyleFamily( ...@@ -379,7 +375,7 @@ void XMLStyleExport::exportStyleFamily(
const rtl::Reference < SvXMLExportPropertyMapper >& rPropMapper, const rtl::Reference < SvXMLExportPropertyMapper >& rPropMapper,
bool bUsed, sal_uInt16 nFamily, const OUString* pPrefix) 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 ); Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetExport().GetModel(), UNO_QUERY );
if( !xFamiliesSupp.is() ) if( !xFamiliesSupp.is() )
return; // family not available in current model return; // family not available in current model
...@@ -418,38 +414,35 @@ void XMLStyleExport::exportStyleFamily( ...@@ -418,38 +414,35 @@ void XMLStyleExport::exportStyleFamily(
continue; continue;
} }
DBG_ASSERT( xStyle.is(), "Style not found for export!" ); assert(xStyle.is());
if( 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, // If this is the first style, find out whether next styles
xStyleCont,pPrefix ); // are supported.
if( bUsed && bFirstStyle && bExported ) Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
{ Reference< XPropertySetInfo > xPropSetInfo =
// If this is the first style, find out whether next styles xPropSet->getPropertySetInfo();
// 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( pExportedStyles && bExported ) if (xPropSetInfo->hasPropertyByName( sFollowStyle ))
{ pExportedStyles.reset(new std::set<OUString>());
// If next styles are supported, remember this style's name. bFirstStyle = false;
pExportedStyles->insert( xStyle->getName() );
}
} }
// if an auto style pool is given, remember this style's name as a if (pExportedStyles && bExported)
// style name that must not be used by automatic styles. {
if( pAutoStylePool ) // If next styles are supported, remember this style's name.
pAutoStylePool->RegisterName( nFamily, xStyle->getName() ); 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 ) if( pExportedStyles )
...@@ -462,43 +455,40 @@ void XMLStyleExport::exportStyleFamily( ...@@ -462,43 +455,40 @@ void XMLStyleExport::exportStyleFamily(
Reference< XStyle > xStyle; Reference< XStyle > xStyle;
xStyleCont->getByName( *pIter ) >>= xStyle; xStyleCont->getByName( *pIter ) >>= xStyle;
DBG_ASSERT( xStyle.is(), "Style not found for export!" ); assert(xStyle.is());
if( xStyle.is() )
{
Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
// styles that aren't existing really are ignored. Reference< XPropertySet > xPropSet( xStyle, UNO_QUERY );
if( xPropSetInfo->hasPropertyByName( sIsPhysical ) ) Reference< XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() );
{
Any aAny( xPropSet->getPropertyValue( sIsPhysical ) );
if( !*static_cast<sal_Bool const *>(aAny.getValue()) )
continue;
}
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; continue;
}
if( !xPropSetInfo->hasPropertyByName( sFollowStyle ) ) if (!xStyle->isInUse())
{ continue;
DBG_ASSERT( sFollowStyle.isEmpty(), "no follow style???" );
continue;
}
OUString sNextName; if (!xPropSetInfo->hasPropertyByName( sFollowStyle ))
xPropSet->getPropertyValue( sFollowStyle ) >>= sNextName; {
OUString sTmp( sNextName ); continue;
// 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( xStyle.is() && exportStyle( xStyle, rXMLFamily, rPropMapper, xStyleCont, pPrefix ) ) OUString sNextName;
pExportedStyles->insert( sTmp ); 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 );
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment