diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 09:19:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 10:15:18 +0200 |
commit | c525288fee6db8fde5a4ae3ffc22634fb6ea7805 (patch) | |
tree | e10da81654a120a61b477a139ac7cc6dc0aef658 /xmloff | |
parent | f016f9016f5139791d544b5e5aa2ac438227b735 (diff) |
loplugin:flatten in xmloff
Change-Id: Id35bf564b3fa2c9094f10b0d2030dae853fcd673
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100200
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/source/core/ProgressBarHelper.cxx | 80 | ||||
-rw-r--r-- | xmloff/source/core/XMLEmbeddedObjectImportContext.cxx | 64 | ||||
-rw-r--r-- | xmloff/source/core/xmlexp.cxx | 478 | ||||
-rw-r--r-- | xmloff/source/core/xmlimp.cxx | 157 | ||||
-rw-r--r-- | xmloff/source/core/xmluconv.cxx | 110 | ||||
-rw-r--r-- | xmloff/source/forms/elementexport.cxx | 64 | ||||
-rw-r--r-- | xmloff/source/forms/elementimport.cxx | 115 | ||||
-rw-r--r-- | xmloff/source/forms/layerexport.cxx | 42 | ||||
-rw-r--r-- | xmloff/source/forms/layerimport.cxx | 58 | ||||
-rw-r--r-- | xmloff/source/meta/xmlmetae.cxx | 70 | ||||
-rw-r--r-- | xmloff/source/meta/xmlmetai.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/meta/xmlversion.cxx | 62 | ||||
-rw-r--r-- | xmloff/source/script/XMLEventExport.cxx | 56 | ||||
-rw-r--r-- | xmloff/source/script/XMLEventImportHelper.cxx | 28 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableExport.cxx | 26 | ||||
-rw-r--r-- | xmloff/source/table/XMLTableImport.cxx | 40 | ||||
-rw-r--r-- | xmloff/source/xforms/xformsexport.cxx | 22 |
17 files changed, 744 insertions, 733 deletions
diff --git a/xmloff/source/core/ProgressBarHelper.cxx b/xmloff/source/core/ProgressBarHelper.cxx index 07a103466666..fd5c295a6d5d 100644 --- a/xmloff/source/core/ProgressBarHelper.cxx +++ b/xmloff/source/core/ProgressBarHelper.cxx @@ -47,61 +47,61 @@ ProgressBarHelper::~ProgressBarHelper() void ProgressBarHelper::ChangeReference(sal_Int32 nNewReference) { - if((nNewReference > 0) && (nNewReference != nReference)) + if((nNewReference <= 0) || (nNewReference == nReference)) + return; + + if (nReference) { - if (nReference) - { - double fPercent(static_cast<double>(nNewReference) / nReference); - double fValue(nValue * fPercent); - nValue = static_cast<sal_Int32>(fValue); - nReference = nNewReference; - } - else - { - nReference = nNewReference; - nValue = 0; - } + double fPercent(static_cast<double>(nNewReference) / nReference); + double fValue(nValue * fPercent); + nValue = static_cast<sal_Int32>(fValue); + nReference = nNewReference; + } + else + { + nReference = nNewReference; + nValue = 0; } } void ProgressBarHelper::SetValue(sal_Int32 nTempValue) { - if (xStatusIndicator.is() && (nReference > 0)) + if (!xStatusIndicator.is() || (nReference <= 0)) + return; + + if ((nTempValue >= nValue) && (!bStrict || (nTempValue <= nReference))) { - if ((nTempValue >= nValue) && (!bStrict || (nTempValue <= nReference))) + // #91317# no progress bar with values > 100% + if (nTempValue > nReference) { - // #91317# no progress bar with values > 100% - if (nTempValue > nReference) - { - if (!bRepeat) - nValue = nReference; - else - { - xStatusIndicator->reset(); - nValue = 0; - } - } + if (!bRepeat) + nValue = nReference; else - nValue = nTempValue; - - double fValue(nValue); - double fNewValue ((fValue * nRange) / nReference); - - double fPercent((fNewValue * 100) / nRange); - if (fPercent >= (fOldPercent + fProgressStep) || fPercent < fOldPercent) { - xStatusIndicator->setValue(static_cast<sal_Int32>(fNewValue)); - fOldPercent = fPercent; + xStatusIndicator->reset(); + nValue = 0; } } -#ifdef DBG_UTIL - else if (!bFailure) + else + nValue = nTempValue; + + double fValue(nValue); + double fNewValue ((fValue * nRange) / nReference); + + double fPercent((fNewValue * 100) / nRange); + if (fPercent >= (fOldPercent + fProgressStep) || fPercent < fOldPercent) { - OSL_FAIL("tried to set a wrong value on the progressbar"); - bFailure = true; + xStatusIndicator->setValue(static_cast<sal_Int32>(fNewValue)); + fOldPercent = fPercent; } -#endif } +#ifdef DBG_UTIL + else if (!bFailure) + { + OSL_FAIL("tried to set a wrong value on the progressbar"); + bFailure = true; + } +#endif } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx index abb6601cb9cb..06e1d8cd5b87 100644 --- a/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx +++ b/xmloff/source/core/XMLEmbeddedObjectImportContext.cxx @@ -240,47 +240,47 @@ SvXMLImportContextRef XMLEmbeddedObjectImportContext::CreateChildContext( void XMLEmbeddedObjectImportContext::StartElement( const Reference< XAttributeList >& rAttrList ) { - if( xHandler.is() ) + if( !xHandler.is() ) + return; + + xHandler->startDocument(); + // #i34042: copy namepspace declarations + SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList ); + Reference< XAttributeList > xAttrList( pAttrList ); + const SvXMLNamespaceMap& rNamespaceMap = GetImport().GetNamespaceMap(); + sal_uInt16 nPos = rNamespaceMap.GetFirstKey(); + while( USHRT_MAX != nPos ) { - xHandler->startDocument(); - // #i34042: copy namepspace declarations - SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList ); - Reference< XAttributeList > xAttrList( pAttrList ); - const SvXMLNamespaceMap& rNamespaceMap = GetImport().GetNamespaceMap(); - sal_uInt16 nPos = rNamespaceMap.GetFirstKey(); - while( USHRT_MAX != nPos ) + OUString aAttrName( rNamespaceMap.GetAttrNameByKey( nPos ) ); + if( xAttrList->getValueByName( aAttrName ).isEmpty() ) { - OUString aAttrName( rNamespaceMap.GetAttrNameByKey( nPos ) ); - if( xAttrList->getValueByName( aAttrName ).isEmpty() ) - { - pAttrList->AddAttribute( aAttrName, - rNamespaceMap.GetNameByKey( nPos ) ); - } - nPos = rNamespaceMap.GetNextKey( nPos ); + pAttrList->AddAttribute( aAttrName, + rNamespaceMap.GetNameByKey( nPos ) ); } - xHandler->startElement( GetImport().GetNamespaceMap().GetQNameByKey( - GetPrefix(), GetLocalName() ), - xAttrList ); + nPos = rNamespaceMap.GetNextKey( nPos ); } + xHandler->startElement( GetImport().GetNamespaceMap().GetQNameByKey( + GetPrefix(), GetLocalName() ), + xAttrList ); } void XMLEmbeddedObjectImportContext::EndElement() { - if( xHandler.is() ) - { - xHandler->endElement( GetImport().GetNamespaceMap().GetQNameByKey( - GetPrefix(), GetLocalName() ) ); - xHandler->endDocument(); + if( !xHandler.is() ) + return; - try - { - Reference < XModifiable2 > xModifiable2( xComp, UNO_QUERY_THROW ); - xModifiable2->enableSetModified(); - xModifiable2->setModified( true ); // trigger new replacement image generation - } - catch( Exception& ) - { - } + xHandler->endElement( GetImport().GetNamespaceMap().GetQNameByKey( + GetPrefix(), GetLocalName() ) ); + xHandler->endDocument(); + + try + { + Reference < XModifiable2 > xModifiable2( xComp, UNO_QUERY_THROW ); + xModifiable2->enableSetModified(); + xModifiable2->setModified( true ); // trigger new replacement image generation + } + catch( Exception& ) + { } } diff --git a/xmloff/source/core/xmlexp.cxx b/xmloff/source/core/xmlexp.cxx index 7c9a6b52e19c..313d74c02994 100644 --- a/xmloff/source/core/xmlexp.cxx +++ b/xmloff/source/core/xmlexp.cxx @@ -1096,20 +1096,20 @@ void SvXMLExport::ImplExportStyles() } // transfer style names (+ families) TO other components (if appropriate) - if( ( !( mnExportFlags & SvXMLExportFlags::CONTENT ) ) && mxExportInfo.is() ) + if( ( mnExportFlags & SvXMLExportFlags::CONTENT ) || !mxExportInfo.is() ) + return; + + static OUString sStyleNames( "StyleNames" ); + static OUString sStyleFamilies( "StyleFamilies" ); + uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo(); + if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) ) { - static OUString sStyleNames( "StyleNames" ); - static OUString sStyleFamilies( "StyleFamilies" ); - uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxExportInfo->getPropertySetInfo(); - if ( xPropertySetInfo->hasPropertyByName( sStyleNames ) && xPropertySetInfo->hasPropertyByName( sStyleFamilies ) ) - { - Sequence<sal_Int32> aStyleFamilies; - Sequence<OUString> aStyleNames; - mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames ); - mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) ); - mxExportInfo->setPropertyValue( sStyleFamilies, - makeAny( aStyleFamilies ) ); - } + Sequence<sal_Int32> aStyleFamilies; + Sequence<OUString> aStyleNames; + mxAutoStylePool->GetRegisteredNames( aStyleFamilies, aStyleNames ); + mxExportInfo->setPropertyValue( sStyleNames, makeAny( aStyleNames ) ); + mxExportInfo->setPropertyValue( sStyleFamilies, + makeAny( aStyleFamilies ) ); } } @@ -1507,184 +1507,184 @@ void SvXMLExport::ExportFontDecls_() void SvXMLExport::ExportStyles_( bool ) { uno::Reference< lang::XMultiServiceFactory > xFact( GetModel(), uno::UNO_QUERY ); - if( xFact.is()) + if( !xFact.is()) + return; + + // export (fill-)gradient-styles + try { - // export (fill-)gradient-styles - try + uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); + if( xGradient.is() ) { - uno::Reference< container::XNameAccess > xGradient( xFact->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); - if( xGradient.is() ) - { - XMLGradientStyleExport aGradientStyle( *this ); + XMLGradientStyleExport aGradientStyle( *this ); - if( xGradient->hasElements() ) + if( xGradient->hasElements() ) + { + const uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() ); + for( const OUString& rStrName : aNamesSeq ) { - const uno::Sequence< OUString > aNamesSeq ( xGradient->getElementNames() ); - for( const OUString& rStrName : aNamesSeq ) + try + { + uno::Any aValue = xGradient->getByName( rStrName ); + + aGradientStyle.exportXML( rStrName, aValue ); + } + catch(const container::NoSuchElementException&) { - try - { - uno::Any aValue = xGradient->getByName( rStrName ); - - aGradientStyle.exportXML( rStrName, aValue ); - } - catch(const container::NoSuchElementException&) - { - } } } } } - catch(const lang::ServiceNotRegisteredException&) - { - } + } + catch(const lang::ServiceNotRegisteredException&) + { + } - // export (fill-)hatch-styles - try + // export (fill-)hatch-styles + try + { + uno::Reference< container::XNameAccess > xHatch( xFact->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY ); + if( xHatch.is() ) { - uno::Reference< container::XNameAccess > xHatch( xFact->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY ); - if( xHatch.is() ) - { - XMLHatchStyleExport aHatchStyle( *this ); + XMLHatchStyleExport aHatchStyle( *this ); - if( xHatch->hasElements() ) + if( xHatch->hasElements() ) + { + const uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() ); + for( const OUString& rStrName : aNamesSeq ) { - const uno::Sequence< OUString > aNamesSeq ( xHatch->getElementNames() ); - for( const OUString& rStrName : aNamesSeq ) + try { - try - { - uno::Any aValue = xHatch->getByName( rStrName ); - - aHatchStyle.exportXML( rStrName, aValue ); - } - catch(const container::NoSuchElementException&) - {} + uno::Any aValue = xHatch->getByName( rStrName ); + + aHatchStyle.exportXML( rStrName, aValue ); } + catch(const container::NoSuchElementException&) + {} } } } - catch(const lang::ServiceNotRegisteredException&) - { - } + } + catch(const lang::ServiceNotRegisteredException&) + { + } - // export (fill-)bitmap-styles - try + // export (fill-)bitmap-styles + try + { + uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); + if( xBitmap.is() ) { - uno::Reference< container::XNameAccess > xBitmap( xFact->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); - if( xBitmap.is() ) + if( xBitmap->hasElements() ) { - if( xBitmap->hasElements() ) + const uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() ); + for( const OUString& rStrName : aNamesSeq ) { - const uno::Sequence< OUString > aNamesSeq ( xBitmap->getElementNames() ); - for( const OUString& rStrName : aNamesSeq ) + try + { + uno::Any aValue = xBitmap->getByName( rStrName ); + + XMLImageStyle::exportXML( rStrName, aValue, *this ); + } + catch(const container::NoSuchElementException&) { - try - { - uno::Any aValue = xBitmap->getByName( rStrName ); - - XMLImageStyle::exportXML( rStrName, aValue, *this ); - } - catch(const container::NoSuchElementException&) - { - } } } } } - catch(const lang::ServiceNotRegisteredException&) - { - } + } + catch(const lang::ServiceNotRegisteredException&) + { + } - // export transparency-gradient -styles - try + // export transparency-gradient -styles + try + { + uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY ); + if( xTransGradient.is() ) { - uno::Reference< container::XNameAccess > xTransGradient( xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY ); - if( xTransGradient.is() ) - { - XMLTransGradientStyleExport aTransGradientstyle( *this ); + XMLTransGradientStyleExport aTransGradientstyle( *this ); - if( xTransGradient->hasElements() ) + if( xTransGradient->hasElements() ) + { + const uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() ); + for( const OUString& rStrName : aNamesSeq ) { - const uno::Sequence< OUString > aNamesSeq ( xTransGradient->getElementNames() ); - for( const OUString& rStrName : aNamesSeq ) + try + { + uno::Any aValue = xTransGradient->getByName( rStrName ); + + aTransGradientstyle.exportXML( rStrName, aValue ); + } + catch(const container::NoSuchElementException&) { - try - { - uno::Any aValue = xTransGradient->getByName( rStrName ); - - aTransGradientstyle.exportXML( rStrName, aValue ); - } - catch(const container::NoSuchElementException&) - { - } } } } } - catch(const lang::ServiceNotRegisteredException&) - { - } + } + catch(const lang::ServiceNotRegisteredException&) + { + } - // export marker-styles - try + // export marker-styles + try + { + uno::Reference< container::XNameAccess > xMarker( xFact->createInstance("com.sun.star.drawing.MarkerTable"), uno::UNO_QUERY ); + if( xMarker.is() ) { - uno::Reference< container::XNameAccess > xMarker( xFact->createInstance("com.sun.star.drawing.MarkerTable"), uno::UNO_QUERY ); - if( xMarker.is() ) - { - XMLMarkerStyleExport aMarkerStyle( *this ); + XMLMarkerStyleExport aMarkerStyle( *this ); - if( xMarker->hasElements() ) + if( xMarker->hasElements() ) + { + const uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() ); + for( const OUString& rStrName : aNamesSeq ) { - const uno::Sequence< OUString > aNamesSeq ( xMarker->getElementNames() ); - for( const OUString& rStrName : aNamesSeq ) + try + { + uno::Any aValue = xMarker->getByName( rStrName ); + + aMarkerStyle.exportXML( rStrName, aValue ); + } + catch(const container::NoSuchElementException&) { - try - { - uno::Any aValue = xMarker->getByName( rStrName ); - - aMarkerStyle.exportXML( rStrName, aValue ); - } - catch(const container::NoSuchElementException&) - { - } } } } } - catch(const lang::ServiceNotRegisteredException&) - { - } + } + catch(const lang::ServiceNotRegisteredException&) + { + } - // export dash-styles - try + // export dash-styles + try + { + uno::Reference< container::XNameAccess > xDashes( xFact->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY ); + if( xDashes.is() ) { - uno::Reference< container::XNameAccess > xDashes( xFact->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY ); - if( xDashes.is() ) - { - XMLDashStyleExport aDashStyle( *this ); + XMLDashStyleExport aDashStyle( *this ); - if( xDashes->hasElements() ) + if( xDashes->hasElements() ) + { + const uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() ); + for( const OUString& rStrName : aNamesSeq ) { - const uno::Sequence< OUString > aNamesSeq ( xDashes->getElementNames() ); - for( const OUString& rStrName : aNamesSeq ) + try + { + uno::Any aValue = xDashes->getByName( rStrName ); + + aDashStyle.exportXML( rStrName, aValue ); + } + catch(const container::NoSuchElementException&) { - try - { - uno::Any aValue = xDashes->getByName( rStrName ); - - aDashStyle.exportXML( rStrName, aValue ); - } - catch(const container::NoSuchElementException&) - { - } } } } } - catch(const lang::ServiceNotRegisteredException&) - { - } + } + catch(const lang::ServiceNotRegisteredException&) + { } } @@ -1731,44 +1731,44 @@ void SvXMLExport::GetViewSettingsAndViews(uno::Sequence<beans::PropertyValue>& r { GetViewSettings(rProps); uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetModel(), uno::UNO_QUERY); - if(xViewDataSupplier.is()) + if(!xViewDataSupplier.is()) + return; + + uno::Reference<container::XIndexAccess> xIndexAccess; + xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence { - uno::Reference<container::XIndexAccess> xIndexAccess; - xViewDataSupplier->setViewData( xIndexAccess ); // make sure we get a newly created sequence - { - // tdf#130559: don't export preview view data if active - css::uno::ContextLayer layer(comphelper::NewFlagContext("NoPreviewData")); - xIndexAccess = xViewDataSupplier->getViewData(); - } - bool bAdd = false; - uno::Any aAny; - if(xIndexAccess.is() && xIndexAccess->hasElements() ) + // tdf#130559: don't export preview view data if active + css::uno::ContextLayer layer(comphelper::NewFlagContext("NoPreviewData")); + xIndexAccess = xViewDataSupplier->getViewData(); + } + bool bAdd = false; + uno::Any aAny; + if(xIndexAccess.is() && xIndexAccess->hasElements() ) + { + sal_Int32 nCount = xIndexAccess->getCount(); + for (sal_Int32 i = 0; i < nCount; i++) { - sal_Int32 nCount = xIndexAccess->getCount(); - for (sal_Int32 i = 0; i < nCount; i++) + aAny = xIndexAccess->getByIndex(i); + uno::Sequence<beans::PropertyValue> aProps; + if( aAny >>= aProps ) { - aAny = xIndexAccess->getByIndex(i); - uno::Sequence<beans::PropertyValue> aProps; - if( aAny >>= aProps ) + if( aProps.hasElements() ) { - if( aProps.hasElements() ) - { - bAdd = true; - break; - } + bAdd = true; + break; } } } + } - if( bAdd ) - { - sal_Int32 nOldLength(rProps.getLength()); - rProps.realloc(nOldLength + 1); - beans::PropertyValue aProp; - aProp.Name = "Views"; - aProp.Value <<= xIndexAccess; - rProps[nOldLength] = aProp; - } + if( bAdd ) + { + sal_Int32 nOldLength(rProps.getLength()); + rProps.realloc(nOldLength + 1); + beans::PropertyValue aProp; + aProp.Name = "Views"; + aProp.Value <<= xIndexAccess; + rProps[nOldLength] = aProp; } } @@ -2157,23 +2157,23 @@ void SvXMLExport::StartElement(const OUString& rName, void SvXMLExport::Characters(const OUString& rChars) { - if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) != SvXMLErrorFlags::DO_NOTHING) + if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING) + return; + + try { - try - { - mxHandler->characters(rChars); - } - catch (const SAXInvalidCharacterException& e) - { - Sequence<OUString> aPars { rChars }; - SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr ); - } - catch (const SAXException& e) - { - Sequence<OUString> aPars { rChars }; - SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, - aPars, e.Message, nullptr ); - } + mxHandler->characters(rChars); + } + catch (const SAXInvalidCharacterException& e) + { + Sequence<OUString> aPars { rChars }; + SetError( XMLERROR_SAX|XMLERROR_FLAG_WARNING, aPars, e.Message, nullptr ); + } + catch (const SAXException& e) + { + Sequence<OUString> aPars { rChars }; + SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, + aPars, e.Message, nullptr ); } } @@ -2199,20 +2199,20 @@ void SvXMLExport::EndElement(const OUString& rName, SAL_WARN_IF(!mpImpl->mNamespaceMaps.empty() && (mpImpl->mNamespaceMaps.top().second >= mpImpl->mDepth), "xmloff.core", "SvXMLExport: NamespaceMaps corrupted"); - if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) != SvXMLErrorFlags::DO_NOTHING) + if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING) + return; + + try { - try - { - if( bIgnWSInside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY)) - mxHandler->ignorableWhitespace( msWS ); - mxHandler->endElement( rName ); - } - catch (const SAXException& e) - { - Sequence<OUString> aPars { rName }; - SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, - aPars, e.Message, nullptr ); - } + if( bIgnWSInside && ((mnExportFlags & SvXMLExportFlags::PRETTY) == SvXMLExportFlags::PRETTY)) + mxHandler->ignorableWhitespace( msWS ); + mxHandler->endElement( rName ); + } + catch (const SAXException& e) + { + Sequence<OUString> aPars { rName }; + SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, + aPars, e.Message, nullptr ); } } @@ -2221,18 +2221,18 @@ void SvXMLExport::IgnorableWhitespace() if ((mnExportFlags & SvXMLExportFlags::PRETTY) != SvXMLExportFlags::PRETTY) return; - if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) != SvXMLErrorFlags::DO_NOTHING) + if ((mnErrorFlags & SvXMLErrorFlags::DO_NOTHING) == SvXMLErrorFlags::DO_NOTHING) + return; + + try { - try - { - mxHandler->ignorableWhitespace( msWS ); - } - catch (const SAXException& e) - { - Sequence<OUString> aPars(0); - SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, - aPars, e.Message, nullptr ); - } + mxHandler->ignorableWhitespace( msWS ); + } + catch (const SAXException& e) + { + Sequence<OUString> aPars(0); + SetError( XMLERROR_SAX|XMLERROR_FLAG_ERROR|XMLERROR_FLAG_SEVERE, + aPars, e.Message, nullptr ); } } @@ -2331,40 +2331,40 @@ SvXMLExport::AddAttributeXmlId(uno::Reference<uno::XInterface> const & i_xIfc) const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc, uno::UNO_QUERY); //FIXME not yet... - if ( xMeta.is() ) + if ( !xMeta.is() ) + return; + + const beans::StringPair mdref( xMeta->getMetadataReference() ); + if ( mdref.Second.isEmpty() ) + return; + + const OUString streamName = mpImpl->mStreamName; + if ( !streamName.isEmpty() ) { - const beans::StringPair mdref( xMeta->getMetadataReference() ); - if ( !mdref.Second.isEmpty() ) + if ( streamName == mdref.First ) { - const OUString streamName = mpImpl->mStreamName; - if ( !streamName.isEmpty() ) - { - if ( streamName == mdref.First ) - { - AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second ); - } - else - { - SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name"); - } - } - else - { - // FIXME: this is ugly - // there is no stream name (e.g. XSLT, flat-xml format)! - // but how do we ensure uniqueness in this case? - // a) just omit styles.xml ids -- they are unlikely anyway... - // b) somehow find out whether we are currently exporting styles - // or content, and prefix "s" or "c" => unique - if ( mdref.First == "content.xml" ) - { - AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second ); - } - else - { - SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id"); - } - } + AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second ); + } + else + { + SAL_WARN("xmloff.core","SvXMLExport::AddAttributeXmlId: invalid stream name"); + } + } + else + { + // FIXME: this is ugly + // there is no stream name (e.g. XSLT, flat-xml format)! + // but how do we ensure uniqueness in this case? + // a) just omit styles.xml ids -- they are unlikely anyway... + // b) somehow find out whether we are currently exporting styles + // or content, and prefix "s" or "c" => unique + if ( mdref.First == "content.xml" ) + { + AddAttribute( XML_NAMESPACE_XML, XML_ID, mdref.Second ); + } + else + { + SAL_INFO("xmloff.core", "SvXMLExport::AddAttributeXmlId: no stream name given: dropping styles.xml xml:id"); } } } diff --git a/xmloff/source/core/xmlimp.cxx b/xmloff/source/core/xmlimp.cxx index 479faef73416..6d44d2db58cf 100644 --- a/xmloff/source/core/xmlimp.cxx +++ b/xmloff/source/core/xmlimp.cxx @@ -211,46 +211,46 @@ public: } } sal_Int32 nUPD, nBuild; - if ( rImport.getBuildIds( nUPD, nBuild ) ) + if ( !rImport.getBuildIds( nUPD, nBuild ) ) + return; + + if ( nUPD >= 640 && nUPD <= 645 ) { - if ( nUPD >= 640 && nUPD <= 645 ) - { - mnGeneratorVersion = SvXMLImport::OOo_1x; - } - else if ( nUPD == 680 ) - { - mnGeneratorVersion = SvXMLImport::OOo_2x; - } - else if ( nUPD == 300 && nBuild <= 9379 ) - { - mnGeneratorVersion = SvXMLImport::OOo_30x; - } - else if ( nUPD == 310 ) - { - mnGeneratorVersion = SvXMLImport::OOo_31x; - } - else if ( nUPD == 320 ) - { - mnGeneratorVersion = SvXMLImport::OOo_32x; - } - else if ( nUPD == 330 ) - { - mnGeneratorVersion = SvXMLImport::OOo_33x; - } - else if ( nUPD == 340 ) - { - mnGeneratorVersion = SvXMLImport::OOo_34x; - } - else if (nUPD == 400 || nUPD == 401) - { - mnGeneratorVersion = SvXMLImport::AOO_40x; - } - else if (nUPD >= 410) - { - // effectively this means "latest", see use - // in XMLGraphicsDefaultStyle::SetDefaults()! - mnGeneratorVersion = SvXMLImport::AOO_4x; - } + mnGeneratorVersion = SvXMLImport::OOo_1x; + } + else if ( nUPD == 680 ) + { + mnGeneratorVersion = SvXMLImport::OOo_2x; + } + else if ( nUPD == 300 && nBuild <= 9379 ) + { + mnGeneratorVersion = SvXMLImport::OOo_30x; + } + else if ( nUPD == 310 ) + { + mnGeneratorVersion = SvXMLImport::OOo_31x; + } + else if ( nUPD == 320 ) + { + mnGeneratorVersion = SvXMLImport::OOo_32x; + } + else if ( nUPD == 330 ) + { + mnGeneratorVersion = SvXMLImport::OOo_33x; + } + else if ( nUPD == 340 ) + { + mnGeneratorVersion = SvXMLImport::OOo_34x; + } + else if (nUPD == 400 || nUPD == 401) + { + mnGeneratorVersion = SvXMLImport::AOO_40x; + } + else if (nUPD >= 410) + { + // effectively this means "latest", see use + // in XMLGraphicsDefaultStyle::SetDefaults()! + mnGeneratorVersion = SvXMLImport::AOO_4x; } } @@ -545,36 +545,36 @@ void SAL_CALL SvXMLImport::setNamespaceHandler( const uno::Reference< xml::sax:: void SAL_CALL SvXMLImport::startDocument() { SAL_INFO( "xmloff.core", "{ SvXMLImport::startDocument" ); - if (!mxGraphicStorageHandler.is() || !mxEmbeddedResolver.is()) + if (mxGraphicStorageHandler.is() && mxEmbeddedResolver.is()) + return; + + Reference< lang::XMultiServiceFactory > xFactory( mxModel, UNO_QUERY ); + if( !xFactory.is() ) + return; + + try { - Reference< lang::XMultiServiceFactory > xFactory( mxModel, UNO_QUERY ); - if( xFactory.is() ) + if (!mxGraphicStorageHandler.is()) { - try - { - if (!mxGraphicStorageHandler.is()) - { - // #99870# Import... instead of Export... - mxGraphicStorageHandler.set( - xFactory->createInstance("com.sun.star.document.ImportGraphicStorageHandler"), - UNO_QUERY); - mpImpl->mbOwnGraphicResolver = mxGraphicStorageHandler.is(); - } + // #99870# Import... instead of Export... + mxGraphicStorageHandler.set( + xFactory->createInstance("com.sun.star.document.ImportGraphicStorageHandler"), + UNO_QUERY); + mpImpl->mbOwnGraphicResolver = mxGraphicStorageHandler.is(); + } - if( !mxEmbeddedResolver.is() ) - { - // #99870# Import... instead of Export... - mxEmbeddedResolver.set( - xFactory->createInstance("com.sun.star.document.ImportEmbeddedObjectResolver"), - UNO_QUERY); - mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is(); - } - } - catch( css::uno::Exception& ) - { - } + if( !mxEmbeddedResolver.is() ) + { + // #99870# Import... instead of Export... + mxEmbeddedResolver.set( + xFactory->createInstance("com.sun.star.document.ImportEmbeddedObjectResolver"), + UNO_QUERY); + mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is(); } } + catch( css::uno::Exception& ) + { + } } void SAL_CALL SvXMLImport::endDocument() @@ -1975,23 +1975,24 @@ bool SvXMLImport::IsOOoXML() const void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc, OUString const & i_rXmlId) { - if (!i_rXmlId.isEmpty()) { - try { - const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc, - uno::UNO_QUERY); + if (i_rXmlId.isEmpty()) + return; + + try { + const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc, + uno::UNO_QUERY); //FIXME: not yet - if (xMeta.is()) { - const beans::StringPair mdref( mpImpl->mStreamName, i_rXmlId ); - try { - xMeta->setMetadataReference(mdref); - } catch (lang::IllegalArgumentException &) { - // probably duplicate; ignore - SAL_INFO("xmloff.core", "SvXMLImport::SetXmlId: cannot set xml:id"); - } + if (xMeta.is()) { + const beans::StringPair mdref( mpImpl->mStreamName, i_rXmlId ); + try { + xMeta->setMetadataReference(mdref); + } catch (lang::IllegalArgumentException &) { + // probably duplicate; ignore + SAL_INFO("xmloff.core", "SvXMLImport::SetXmlId: cannot set xml:id"); } - } catch (uno::Exception &) { - TOOLS_WARN_EXCEPTION("xmloff.core","SvXMLImport::SetXmlId"); } + } catch (uno::Exception &) { + TOOLS_WARN_EXCEPTION("xmloff.core","SvXMLImport::SetXmlId"); } } diff --git a/xmloff/source/core/xmluconv.cxx b/xmloff/source/core/xmluconv.cxx index 133613784e84..b18972ba29f2 100644 --- a/xmloff/source/core/xmluconv.cxx +++ b/xmloff/source/core/xmluconv.cxx @@ -366,51 +366,51 @@ void SvXMLUnitConverter::convertDateTime( OUStringBuffer& rBuffer, if (nTemp < 10) rBuffer.append( '0'); rBuffer.append( sal_Int32( nTemp)); - if (bHasTime || bAddTimeIf0AM) + if (!(bHasTime || bAddTimeIf0AM)) + return; + + double fCount; + if (nDays > 0) + fCount = ::rtl::math::approxFloor (log10(static_cast<double>(nDays))) + 1; + else if (nDays < 0) + fCount = ::rtl::math::approxFloor (log10(static_cast<double>(nDays * -1))) + 1; + else + fCount = 0.0; + const int nDigits = sal_Int16(fCount) + 4; // +4 for *86400 in seconds + const int nFractionDecimals = std::max( XML_MAXDIGITSCOUNT_TIME - nDigits, 0); + + sal_uInt16 nHour, nMinute, nSecond; + double fFractionOfSecond; + // Pass the original date+time value for proper scaling and rounding. + tools::Time::GetClock( fDateTime, nHour, nMinute, nSecond, fFractionOfSecond, nFractionDecimals); + + rBuffer.append( 'T'); + if (nHour < 10) + rBuffer.append( '0'); + rBuffer.append( sal_Int32( nHour)); + rBuffer.append( ':'); + if (nMinute < 10) + rBuffer.append( '0'); + rBuffer.append( sal_Int32( nMinute)); + rBuffer.append( ':'); + if (nSecond < 10) + rBuffer.append( '0'); + rBuffer.append( sal_Int32( nSecond)); + if (!nFractionDecimals) + return; + + // nFractionDecimals+1 to not round up what GetClock() carefully + // truncated. + OUString aFraction( ::rtl::math::doubleToUString( fFractionOfSecond, + rtl_math_StringFormat_F, + nFractionDecimals + 1, '.', true)); + const sal_Int32 nLen = aFraction.getLength(); + if ( nLen > 2 ) { - double fCount; - if (nDays > 0) - fCount = ::rtl::math::approxFloor (log10(static_cast<double>(nDays))) + 1; - else if (nDays < 0) - fCount = ::rtl::math::approxFloor (log10(static_cast<double>(nDays * -1))) + 1; - else - fCount = 0.0; - const int nDigits = sal_Int16(fCount) + 4; // +4 for *86400 in seconds - const int nFractionDecimals = std::max( XML_MAXDIGITSCOUNT_TIME - nDigits, 0); - - sal_uInt16 nHour, nMinute, nSecond; - double fFractionOfSecond; - // Pass the original date+time value for proper scaling and rounding. - tools::Time::GetClock( fDateTime, nHour, nMinute, nSecond, fFractionOfSecond, nFractionDecimals); - - rBuffer.append( 'T'); - if (nHour < 10) - rBuffer.append( '0'); - rBuffer.append( sal_Int32( nHour)); - rBuffer.append( ':'); - if (nMinute < 10) - rBuffer.append( '0'); - rBuffer.append( sal_Int32( nMinute)); - rBuffer.append( ':'); - if (nSecond < 10) - rBuffer.append( '0'); - rBuffer.append( sal_Int32( nSecond)); - if (nFractionDecimals) - { - // nFractionDecimals+1 to not round up what GetClock() carefully - // truncated. - OUString aFraction( ::rtl::math::doubleToUString( fFractionOfSecond, - rtl_math_StringFormat_F, - nFractionDecimals + 1, '.', true)); - const sal_Int32 nLen = aFraction.getLength(); - if ( nLen > 2 ) - { - // Truncate nFractionDecimals+1 digit if it was not rounded to zero. - const sal_Int32 nCount = nLen - 2 - static_cast<int>(nLen > nFractionDecimals + 2); - rBuffer.append( '.'); - rBuffer.append( std::u16string_view(aFraction).substr(2, nCount)); // strip 0. - } - } + // Truncate nFractionDecimals+1 digit if it was not rounded to zero. + const sal_Int32 nCount = nLen - 2 - static_cast<int>(nLen > nFractionDecimals + 2); + rBuffer.append( '.'); + rBuffer.append( std::u16string_view(aFraction).substr(2, nCount)); // strip 0. } } @@ -701,19 +701,19 @@ void SvXMLUnitConverter::convertPropertySet(uno::Sequence<beans::PropertyValue>& const uno::Reference<beans::XPropertySet>& aProperties) { uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = aProperties->getPropertySetInfo(); - if (xPropertySetInfo.is()) + if (!xPropertySetInfo.is()) + return; + + const uno::Sequence< beans::Property > aProps = xPropertySetInfo->getProperties(); + if (aProps.hasElements()) { - const uno::Sequence< beans::Property > aProps = xPropertySetInfo->getProperties(); - if (aProps.hasElements()) + rProps.realloc(aProps.getLength()); + beans::PropertyValue* pProps = rProps.getArray(); + for (const auto& rProp : aProps) { - rProps.realloc(aProps.getLength()); - beans::PropertyValue* pProps = rProps.getArray(); - for (const auto& rProp : aProps) - { - pProps->Name = rProp.Name; - pProps->Value = aProperties->getPropertyValue(rProp.Name); - ++pProps; - } + pProps->Name = rProp.Name; + pProps->Value = aProperties->getPropertyValue(rProp.Name); + ++pProps; } } } diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 5f99693d204c..74bcc4570c5f 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -1321,43 +1321,43 @@ namespace xmloff // one or both of the selected flags. // 21.05.2001 - 85388 - frank.schoenheit@germany.sun.com - if ( !aSelection.empty() || !aDefaultSelection.empty() ) - { - sal_Int16 nLastSelected = -1; - if ( !aSelection.empty() ) - nLastSelected = *(--aSelection.end()); + if (aSelection.empty() && aDefaultSelection.empty()) + return; - sal_Int16 nLastDefaultSelected = -1; - if ( !aDefaultSelection.empty() ) - nLastDefaultSelected = *(--aDefaultSelection.end()); + sal_Int16 nLastSelected = -1; + if ( !aSelection.empty() ) + nLastSelected = *(--aSelection.end()); - // the maximum element in both sets - sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected); - OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!"); - // if the maximum (selected or default selected) entry number is less than the maximum item count - // in both lists, the entry number should have been removed from the set + sal_Int16 nLastDefaultSelected = -1; + if ( !aDefaultSelection.empty() ) + nLastDefaultSelected = *(--aDefaultSelection.end()); - for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i) - { - if (aSelection.end() != aSelection.find(i)) - { // the (not existent) item at this position is selected - AddAttribute( - OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentSelected), - OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentSelected), - sTrue - ); - } + // the maximum element in both sets + sal_Int16 nLastReferredEntry = std::max(nLastSelected, nLastDefaultSelected); + OSL_ENSURE(nLastReferredEntry >= nMaxLen, "OControlExport::exportListSourceAsElements: inconsistence!"); + // if the maximum (selected or default selected) entry number is less than the maximum item count + // in both lists, the entry number should have been removed from the set - if (aDefaultSelection.end() != aDefaultSelection.find(i)) - { // the (not existent) item at this position is selected as default - AddAttribute( - OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Selected), - OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Selected), - sTrue - ); - } - SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true); + for (sal_Int16 i=nMaxLen; i<=nLastReferredEntry; ++i) + { + if (aSelection.end() != aSelection.find(i)) + { // the (not existent) item at this position is selected + AddAttribute( + OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::CurrentSelected), + OAttributeMetaData::getCommonControlAttributeName(CCAFlags::CurrentSelected), + sTrue + ); } + + if (aDefaultSelection.end() != aDefaultSelection.find(i)) + { // the (not existent) item at this position is selected as default + AddAttribute( + OAttributeMetaData::getCommonControlAttributeNamespace(CCAFlags::Selected), + OAttributeMetaData::getCommonControlAttributeName(CCAFlags::Selected), + sTrue + ); + } + SvXMLElementExport aFormElement(m_rContext.getGlobalContext(), XML_NAMESPACE_FORM, "option", true, true); } } diff --git a/xmloff/source/forms/elementimport.cxx b/xmloff/source/forms/elementimport.cxx index 14178490f7b1..7552d118b4a0 100644 --- a/xmloff/source/forms/elementimport.cxx +++ b/xmloff/source/forms/elementimport.cxx @@ -272,23 +272,24 @@ namespace xmloff } } - if (!bSuccess) - { // no XMultiPropertySet or setting all properties at once failed - for ( const auto& rPropValues : m_aValues ) + if (bSuccess) + return; + + // no XMultiPropertySet or setting all properties at once failed + for ( const auto& rPropValues : m_aValues ) + { + // this try/catch here is expensive, but because this is just a fallback which should normally not be + // used it's acceptable this way ... + try { - // this try/catch here is expensive, but because this is just a fallback which should normally not be - // used it's acceptable this way ... - try - { - m_xElement->setPropertyValue(rPropValues.Name, rPropValues.Value); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("xmloff.forms"); - OSL_FAIL(OStringBuffer("OElementImport::implApplySpecificProperties: could not set the property \""). - append(OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US)). - append("\"!").getStr()); - } + m_xElement->setPropertyValue(rPropValues.Name, rPropValues.Value); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("xmloff.forms"); + OSL_FAIL(OStringBuffer("OElementImport::implApplySpecificProperties: could not set the property \""). + append(OUStringToOString(rPropValues.Name, RTL_TEXTENCODING_ASCII_US)). + append("\"!").getStr()); } } } @@ -1099,21 +1100,21 @@ namespace xmloff aGraphicProperty.Value <<= m_xGraphic; implPushBackPropertyValue(aGraphicProperty); } - if ( m_bHaveImagePosition ) - { - sal_Int16 nUnoImagePosition = ImagePosition::Centered; - if ( m_nImagePosition >= 0 ) - { - OSL_ENSURE( ( m_nImagePosition <= 3 ) && ( m_nImageAlign >= 0 ) && ( m_nImageAlign < 3 ), - "OImagePositionImport::StartElement: unknown image align and/or position!" ); - nUnoImagePosition = m_nImagePosition * 3 + m_nImageAlign; - } + if ( !m_bHaveImagePosition ) + return; - PropertyValue aImagePosition; - aImagePosition.Name = PROPERTY_IMAGE_POSITION; - aImagePosition.Value <<= nUnoImagePosition; - implPushBackPropertyValue( aImagePosition ); + sal_Int16 nUnoImagePosition = ImagePosition::Centered; + if ( m_nImagePosition >= 0 ) + { + OSL_ENSURE( ( m_nImagePosition <= 3 ) && ( m_nImageAlign >= 0 ) && ( m_nImageAlign < 3 ), + "OImagePositionImport::StartElement: unknown image align and/or position!" ); + nUnoImagePosition = m_nImagePosition * 3 + m_nImageAlign; } + + PropertyValue aImagePosition; + aImagePosition.Name = PROPERTY_IMAGE_POSITION; + aImagePosition.Value <<= nUnoImagePosition; + implPushBackPropertyValue( aImagePosition ); } //= OReferredControlImport @@ -1370,37 +1371,37 @@ namespace xmloff void OTextLikeImport::removeRedundantCurrentValue() { - if ( m_bEncounteredTextPara ) - { - // In case the text is written in the text:p elements, we need to ignore what we read as - // current-value attribute, since it's redundant. - // fortunately, OElementImport tagged the value property with the PROPID_CURRENT_VALUE - // handle, so we do not need to determine the name of our value property here - // (normally, it should be "Text", since no other controls than the edit field should - // have the text:p elements) - PropertyValueArray::iterator aValuePropertyPos = ::std::find_if( - m_aValues.begin(), - m_aValues.end(), - EqualHandle( PROPID_CURRENT_VALUE ) - ); - if ( aValuePropertyPos != m_aValues.end() ) + if ( !m_bEncounteredTextPara ) + return; + + // In case the text is written in the text:p elements, we need to ignore what we read as + // current-value attribute, since it's redundant. + // fortunately, OElementImport tagged the value property with the PROPID_CURRENT_VALUE + // handle, so we do not need to determine the name of our value property here + // (normally, it should be "Text", since no other controls than the edit field should + // have the text:p elements) + PropertyValueArray::iterator aValuePropertyPos = ::std::find_if( + m_aValues.begin(), + m_aValues.end(), + EqualHandle( PROPID_CURRENT_VALUE ) + ); + if ( aValuePropertyPos != m_aValues.end() ) + { + OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" ); + if ( aValuePropertyPos->Name == PROPERTY_TEXT ) { - OSL_ENSURE( aValuePropertyPos->Name == PROPERTY_TEXT, "OTextLikeImport::EndElement: text:p was present, but our value property is *not* 'Text'!" ); - if ( aValuePropertyPos->Name == PROPERTY_TEXT ) - { - m_aValues.erase(aValuePropertyPos); - } + m_aValues.erase(aValuePropertyPos); } - - // additionally, we need to set the "RichText" property of our element to sal_True - // (the presence of the text:p is used as indicator for the value of the RichText property) - bool bHasRichTextProperty = false; - if ( m_xInfo.is() ) - bHasRichTextProperty = m_xInfo->hasPropertyByName( PROPERTY_RICH_TEXT ); - OSL_ENSURE( bHasRichTextProperty, "OTextLikeImport::EndElement: text:p, but no rich text control?" ); - if ( bHasRichTextProperty ) - m_xElement->setPropertyValue( PROPERTY_RICH_TEXT, makeAny( true ) ); } + + // additionally, we need to set the "RichText" property of our element to sal_True + // (the presence of the text:p is used as indicator for the value of the RichText property) + bool bHasRichTextProperty = false; + if ( m_xInfo.is() ) + bHasRichTextProperty = m_xInfo->hasPropertyByName( PROPERTY_RICH_TEXT ); + OSL_ENSURE( bHasRichTextProperty, "OTextLikeImport::EndElement: text:p, but no rich text control?" ); + if ( bHasRichTextProperty ) + m_xElement->setPropertyValue( PROPERTY_RICH_TEXT, makeAny( true ) ); // Note that we do *not* set the RichText property (in case our element has one) to sal_False here // since this is the default of this property, anyway. } diff --git a/xmloff/source/forms/layerexport.cxx b/xmloff/source/forms/layerexport.cxx index e5516d64cfea..87488959c029 100644 --- a/xmloff/source/forms/layerexport.cxx +++ b/xmloff/source/forms/layerexport.cxx @@ -679,31 +679,31 @@ namespace xmloff void OFormLayerXMLExport_Impl::ensureControlNumberStyleExport() { - if (!m_pControlNumberStyles) - { - // create our number formats supplier (if necessary) - Reference< XNumberFormatsSupplier > xFormatsSupplier; - - OSL_ENSURE(!m_xControlNumberFormats.is(), "OFormLayerXMLExport_Impl::getControlNumberStyleExport: inconsistence!"); - // the m_xControlNumberFormats and m_pControlNumberStyles should be maintained together + if (m_pControlNumberStyles) + return; - try - { - // create it for en-US (does not really matter, as we will specify a locale for every - // concrete language to use) - Locale aLocale ( "en", "US", OUString() ); - xFormatsSupplier = NumberFormatsSupplier::createWithLocale( m_rContext.getComponentContext(), aLocale ); - m_xControlNumberFormats = xFormatsSupplier->getNumberFormats(); - } - catch(const Exception&) - { - } + // create our number formats supplier (if necessary) + Reference< XNumberFormatsSupplier > xFormatsSupplier; - OSL_ENSURE(m_xControlNumberFormats.is(), "OFormLayerXMLExport_Impl::getControlNumberStyleExport: could not obtain my default number formats!"); + OSL_ENSURE(!m_xControlNumberFormats.is(), "OFormLayerXMLExport_Impl::getControlNumberStyleExport: inconsistence!"); + // the m_xControlNumberFormats and m_pControlNumberStyles should be maintained together - // create the exporter - m_pControlNumberStyles = new SvXMLNumFmtExport(m_rContext, xFormatsSupplier, getControlNumberStyleNamePrefix()); + try + { + // create it for en-US (does not really matter, as we will specify a locale for every + // concrete language to use) + Locale aLocale ( "en", "US", OUString() ); + xFormatsSupplier = NumberFormatsSupplier::createWithLocale( m_rContext.getComponentContext(), aLocale ); + m_xControlNumberFormats = xFormatsSupplier->getNumberFormats(); } + catch(const Exception&) + { + } + + OSL_ENSURE(m_xControlNumberFormats.is(), "OFormLayerXMLExport_Impl::getControlNumberStyleExport: could not obtain my default number formats!"); + + // create the exporter + m_pControlNumberStyles = new SvXMLNumFmtExport(m_rContext, xFormatsSupplier, getControlNumberStyleNamePrefix()); } SvXMLNumFmtExport* OFormLayerXMLExport_Impl::getControlNumberStyleExport() diff --git a/xmloff/source/forms/layerimport.cxx b/xmloff/source/forms/layerimport.cxx index 0263989f07d1..6014111e4fcb 100644 --- a/xmloff/source/forms/layerimport.cxx +++ b/xmloff/source/forms/layerimport.cxx @@ -233,42 +233,42 @@ void OFormLayerXMLImport_Impl::applyControlNumberStyle(const Reference< XPropert m_xAutoStyles.set(m_rImporter.GetShapeImport()->GetAutoStylesContext()); } - if (m_xAutoStyles.is()) + if (!m_xAutoStyles.is()) + return; + + const SvXMLStyleContext* pStyle = m_xAutoStyles->FindStyleChildContext(XmlStyleFamily::DATA_STYLE, _rControlNumerStyleName); + if (pStyle) { - const SvXMLStyleContext* pStyle = m_xAutoStyles->FindStyleChildContext(XmlStyleFamily::DATA_STYLE, _rControlNumerStyleName); - if (pStyle) - { - const SvXMLNumFormatContext* pDataStyle = static_cast<const SvXMLNumFormatContext*>(pStyle); + const SvXMLNumFormatContext* pDataStyle = static_cast<const SvXMLNumFormatContext*>(pStyle); - // set this format at the control model - try + // set this format at the control model + try + { + // the models number format supplier and formats + Reference< XNumberFormatsSupplier > xFormatsSupplier; + _rxControlModel->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xFormatsSupplier; + Reference< XNumberFormats > xFormats; + if (xFormatsSupplier.is()) + xFormats = xFormatsSupplier->getNumberFormats(); + OSL_ENSURE(xFormats.is(), "OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain the controls number formats!"); + + // obtain a key + if (xFormats.is()) { - // the models number format supplier and formats - Reference< XNumberFormatsSupplier > xFormatsSupplier; - _rxControlModel->getPropertyValue(PROPERTY_FORMATSSUPPLIER) >>= xFormatsSupplier; - Reference< XNumberFormats > xFormats; - if (xFormatsSupplier.is()) - xFormats = xFormatsSupplier->getNumberFormats(); - OSL_ENSURE(xFormats.is(), "OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain the controls number formats!"); - - // obtain a key - if (xFormats.is()) - { - sal_Int32 nFormatKey = const_cast<SvXMLNumFormatContext*>(pDataStyle)->CreateAndInsert( xFormatsSupplier ); - OSL_ENSURE(-1 != nFormatKey, "OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain a format key!"); + sal_Int32 nFormatKey = const_cast<SvXMLNumFormatContext*>(pDataStyle)->CreateAndInsert( xFormatsSupplier ); + OSL_ENSURE(-1 != nFormatKey, "OFormLayerXMLImport_Impl::applyControlNumberStyle: could not obtain a format key!"); - // set the format on the control model - _rxControlModel->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey)); - } - } - catch(const Exception&) - { - OSL_FAIL("OFormLayerXMLImport_Impl::applyControlNumberStyle: couldn't set the format!"); + // set the format on the control model + _rxControlModel->setPropertyValue(PROPERTY_FORMATKEY, makeAny(nFormatKey)); } } - else - OSL_FAIL("OFormLayerXMLImport_Impl::applyControlNumberStyle: did not find the style with the given name!"); + catch(const Exception&) + { + OSL_FAIL("OFormLayerXMLImport_Impl::applyControlNumberStyle: couldn't set the format!"); + } } + else + OSL_FAIL("OFormLayerXMLImport_Impl::applyControlNumberStyle: did not find the style with the given name!"); } void OFormLayerXMLImport_Impl::registerCellValueBinding( const Reference< XPropertySet >& _rxControlModel, const OUString& _rCellAddress ) diff --git a/xmloff/source/meta/xmlmetae.cxx b/xmloff/source/meta/xmlmetae.cxx index 45c16b31dde5..81f58a5da3c2 100644 --- a/xmloff/source/meta/xmlmetae.cxx +++ b/xmloff/source/meta/xmlmetae.cxx @@ -251,47 +251,47 @@ void SvXMLMetaExport::MExport_() const uno::Sequence< beans::NamedValue > aDocStatistic = mxDocProps->getDocumentStatistics(); // write document statistic if there is any provided - if ( aDocStatistic.hasElements() ) + if ( !aDocStatistic.hasElements() ) + return; + + for ( const auto& rDocStat : aDocStatistic ) { - for ( const auto& rDocStat : aDocStatistic ) + sal_Int32 nValue = 0; + if ( rDocStat.Value >>= nValue ) { - sal_Int32 nValue = 0; - if ( rDocStat.Value >>= nValue ) + OUString aValue = OUString::number( nValue ); + if ( rDocStat.Name == "TableCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_TABLE_COUNT, aValue ); + else if ( rDocStat.Name == "ObjectCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_OBJECT_COUNT, aValue ); + else if ( rDocStat.Name == "ImageCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_IMAGE_COUNT, aValue ); + else if ( rDocStat.Name == "PageCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_PAGE_COUNT, aValue ); + else if ( rDocStat.Name == "ParagraphCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_PARAGRAPH_COUNT, aValue ); + else if ( rDocStat.Name == "WordCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_WORD_COUNT, aValue ); + else if ( rDocStat.Name == "CharacterCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_CHARACTER_COUNT, aValue ); + else if ( rDocStat.Name == "CellCount" ) + mrExport.AddAttribute( + XML_NAMESPACE_META, XML_CELL_COUNT, aValue ); + else { - OUString aValue = OUString::number( nValue ); - if ( rDocStat.Name == "TableCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_TABLE_COUNT, aValue ); - else if ( rDocStat.Name == "ObjectCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_OBJECT_COUNT, aValue ); - else if ( rDocStat.Name == "ImageCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_IMAGE_COUNT, aValue ); - else if ( rDocStat.Name == "PageCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_PAGE_COUNT, aValue ); - else if ( rDocStat.Name == "ParagraphCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_PARAGRAPH_COUNT, aValue ); - else if ( rDocStat.Name == "WordCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_WORD_COUNT, aValue ); - else if ( rDocStat.Name == "CharacterCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_CHARACTER_COUNT, aValue ); - else if ( rDocStat.Name == "CellCount" ) - mrExport.AddAttribute( - XML_NAMESPACE_META, XML_CELL_COUNT, aValue ); - else - { - SAL_WARN("xmloff", "Unknown statistic value!"); - } + SAL_WARN("xmloff", "Unknown statistic value!"); } } - SvXMLElementExport aElem( mrExport, - XML_NAMESPACE_META, XML_DOCUMENT_STATISTIC, true, true ); } + SvXMLElementExport aElem( mrExport, + XML_NAMESPACE_META, XML_DOCUMENT_STATISTIC, true, true ); } const char s_xmlns[] = "xmlns"; diff --git a/xmloff/source/meta/xmlmetai.cxx b/xmloff/source/meta/xmlmetai.cxx index 2f818681a8a5..99964774c555 100644 --- a/xmloff/source/meta/xmlmetai.cxx +++ b/xmloff/source/meta/xmlmetai.cxx @@ -307,7 +307,10 @@ void SvXMLMetaDocumentContext::setBuildId(OUString const& i_rBuildId, const uno: } } - if ( !sBuildId.isEmpty() ) try + if ( sBuildId.isEmpty() ) + return; + + try { if( xImportInfo.is() ) { diff --git a/xmloff/source/meta/xmlversion.cxx b/xmloff/source/meta/xmlversion.cxx index df81f7d836c1..aef970778267 100644 --- a/xmloff/source/meta/xmlversion.cxx +++ b/xmloff/source/meta/xmlversion.cxx @@ -302,42 +302,42 @@ bool XMLVersionContext::ParseISODateTimeString( void SAL_CALL XMLVersionListPersistence::store( const uno::Reference< embed::XStorage >& xRoot, const uno::Sequence< util::RevisionTag >& rVersions ) { // no storage, no version list! - if ( xRoot.is() ) - { - // get the services needed for writing the xml data - Reference< uno::XComponentContext > xContext = - comphelper::getProcessComponentContext(); - - Reference< XWriter > xWriter = Writer::create(xContext); - - // check whether there's already a sub storage with the version info - // and delete it - OUString sVerName( XMLN_VERSIONSLIST ); - - try { - // open (create) the sub storage with the version info - uno::Reference< io::XStream > xVerStream = xRoot->openStreamElement( - sVerName, - embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); - if ( !xVerStream.is() ) - throw uno::RuntimeException(); + if ( !xRoot.is() ) + return; + + // get the services needed for writing the xml data + Reference< uno::XComponentContext > xContext = + comphelper::getProcessComponentContext(); - Reference< io::XOutputStream > xOut = xVerStream->getOutputStream(); - if ( !xOut.is() ) - throw uno::RuntimeException(); // the stream was successfully opened for writing already + Reference< XWriter > xWriter = Writer::create(xContext); - xWriter->setOutputStream(xOut); + // check whether there's already a sub storage with the version info + // and delete it + OUString sVerName( XMLN_VERSIONSLIST ); - rtl::Reference< XMLVersionListExport > xExp( new XMLVersionListExport( xContext, rVersions, sVerName, xWriter ) ); + try { + // open (create) the sub storage with the version info + uno::Reference< io::XStream > xVerStream = xRoot->openStreamElement( + sVerName, + embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ); + if ( !xVerStream.is() ) + throw uno::RuntimeException(); - xExp->exportDoc( ::xmloff::token::XML_VERSION ); + Reference< io::XOutputStream > xOut = xVerStream->getOutputStream(); + if ( !xOut.is() ) + throw uno::RuntimeException(); // the stream was successfully opened for writing already - xVerStream.clear(); // use refcounting for now to dispose - } - catch( uno::Exception& ) - { - // TODO: error handling - } + xWriter->setOutputStream(xOut); + + rtl::Reference< XMLVersionListExport > xExp( new XMLVersionListExport( xContext, rVersions, sVerName, xWriter ) ); + + xExp->exportDoc( ::xmloff::token::XML_VERSION ); + + xVerStream.clear(); // use refcounting for now to dispose + } + catch( uno::Exception& ) + { + // TODO: error handling } } diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx index 71c5bed2dc18..4d48107168cf 100644 --- a/xmloff/source/script/XMLEventExport.cxx +++ b/xmloff/source/script/XMLEventExport.cxx @@ -189,39 +189,39 @@ void XMLEventExport::ExportEvent( const PropertyValue* pValue = std::find_if(rEventValues.begin(), rEventValues.end(), [](const PropertyValue& rValue) { return gsEventType == rValue.Name; }); - if (pValue != rEventValues.end()) - { - // found! Now find handler and delegate - OUString sType; - pValue->Value >>= sType; + if (pValue == rEventValues.end()) + return; + + // found! Now find handler and delegate + OUString sType; + pValue->Value >>= sType; - if (aHandlerMap.count(sType)) + if (aHandlerMap.count(sType)) + { + if (! rExported) { - if (! rExported) - { - // OK, we have't yet exported the enclosing - // element. So we do that now. - rExported = true; - StartElement(bUseWhitespace); - } - - OUString aEventQName( - rExport.GetNamespaceMap().GetQNameByKey( - rXmlEventName.m_nPrefix, rXmlEventName.m_aName ) ); - - // delegate to proper ExportEventHandler - aHandlerMap[sType]->Export(rExport, aEventQName, - rEventValues, bUseWhitespace); + // OK, we have't yet exported the enclosing + // element. So we do that now. + rExported = true; + StartElement(bUseWhitespace); } - else + + OUString aEventQName( + rExport.GetNamespaceMap().GetQNameByKey( + rXmlEventName.m_nPrefix, rXmlEventName.m_aName ) ); + + // delegate to proper ExportEventHandler + aHandlerMap[sType]->Export(rExport, aEventQName, + rEventValues, bUseWhitespace); + } + else + { + if ( sType != "None" ) { - if ( sType != "None" ) - { - OSL_FAIL("unknown event type returned by API"); - // unknown type -> error (ignore) - } - // else: we ignore None fields + OSL_FAIL("unknown event type returned by API"); + // unknown type -> error (ignore) } + // else: we ignore None fields } } diff --git a/xmloff/source/script/XMLEventImportHelper.cxx b/xmloff/source/script/XMLEventImportHelper.cxx index f657198dc910..9399477e4d1b 100644 --- a/xmloff/source/script/XMLEventImportHelper.cxx +++ b/xmloff/source/script/XMLEventImportHelper.cxx @@ -56,23 +56,23 @@ void XMLEventImportHelper::RegisterFactory( void XMLEventImportHelper::AddTranslationTable( const XMLEventNameTranslation* pTransTable ) { - if (nullptr != pTransTable) + if (nullptr == pTransTable) + return; + + // put translation table into map + for(const XMLEventNameTranslation* pTrans = pTransTable; + pTrans->sAPIName != nullptr; + pTrans++) { - // put translation table into map - for(const XMLEventNameTranslation* pTrans = pTransTable; - pTrans->sAPIName != nullptr; - pTrans++) - { - XMLEventName aName( pTrans->nPrefix, pTrans->sXMLName ); + XMLEventName aName( pTrans->nPrefix, pTrans->sXMLName ); - // check for conflicting entries - DBG_ASSERT(pEventNameMap->find(aName) == pEventNameMap->end(), - "conflicting event translations"); + // check for conflicting entries + DBG_ASSERT(pEventNameMap->find(aName) == pEventNameMap->end(), + "conflicting event translations"); - // assign new translation - (*pEventNameMap)[aName] = - OUString::createFromAscii(pTrans->sAPIName); - } + // assign new translation + (*pEventNameMap)[aName] = + OUString::createFromAscii(pTrans->sAPIName); } // else? ignore! } diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx index 8df080843e63..582e77524505 100644 --- a/xmloff/source/table/XMLTableExport.cxx +++ b/xmloff/source/table/XMLTableExport.cxx @@ -686,21 +686,21 @@ void XMLCellStyleExport::exportStyleContent(const Reference<XStyle>& /*rStyle*/) void XMLCellStyleExport::exportStyleAttributes(const Reference<XStyle>& rStyle) { Reference<XPropertySet> xPropSet(rStyle, UNO_QUERY); - if (xPropSet.is()) + if (!xPropSet.is()) + return; + + Reference<XPropertySetInfo> xPropSetInfo(xPropSet->getPropertySetInfo()); + const OUString sNumberFormat("NumberFormat"); + if (xPropSetInfo->hasPropertyByName(sNumberFormat)) { - Reference<XPropertySetInfo> xPropSetInfo(xPropSet->getPropertySetInfo()); - const OUString sNumberFormat("NumberFormat"); - if (xPropSetInfo->hasPropertyByName(sNumberFormat)) + Reference<XPropertyState> xPropState(xPropSet, UNO_QUERY); + if (xPropState.is() && (PropertyState_DIRECT_VALUE == + xPropState->getPropertyState(sNumberFormat))) { - Reference<XPropertyState> xPropState(xPropSet, UNO_QUERY); - if (xPropState.is() && (PropertyState_DIRECT_VALUE == - xPropState->getPropertyState(sNumberFormat))) - { - sal_Int32 nNumberFormat = 0; - if (xPropSet->getPropertyValue(sNumberFormat) >>= nNumberFormat) - GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, - GetExport().getDataStyleName(nNumberFormat)); - } + sal_Int32 nNumberFormat = 0; + if (xPropSet->getPropertyValue(sNumberFormat) >>= nNumberFormat) + GetExport().AddAttribute(XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, + GetExport().getDataStyleName(nNumberFormat)); } } } diff --git a/xmloff/source/table/XMLTableImport.cxx b/xmloff/source/table/XMLTableImport.cxx index 09a158845ef7..22871a2a24b3 100644 --- a/xmloff/source/table/XMLTableImport.cxx +++ b/xmloff/source/table/XMLTableImport.cxx @@ -307,7 +307,10 @@ void XMLTableImport::insertTabletemplate(const OUString& rsStyleName, bool bOver void XMLTableImport::finishStyles() { - if( !maTableTemplates.empty() ) try + if( maTableTemplates.empty() ) + return; + + try { Reference< XStyleFamiliesSupplier > xFamiliesSupp( mrImport.GetModel(), UNO_QUERY_THROW ); Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() ); @@ -424,7 +427,10 @@ SvXMLImportContextRef XMLTableImportContext::ImportColumn( sal_uInt16 /*nPrefix* void XMLTableImportContext::InitColumns() { - if( mxColumns.is() ) try + if( !mxColumns.is() ) + return; + + try { const sal_Int32 nCount1 = mxColumns->getCount(); const sal_Int32 nCount2 = sal::static_int_cast< sal_Int32 >( maColumnInfos.size() ); @@ -665,22 +671,22 @@ XMLCellImportContext::XMLCellImportContext( SvXMLImport& rImport, const Referenc if( sStyleName.isEmpty() ) sStyleName = sDefaultCellStyleName; - if( !sStyleName.isEmpty() ) - { - SvXMLStylesContext * pAutoStyles = GetImport().GetShapeImport()->GetAutoStylesContext(); - if( pAutoStyles ) - { - const XMLPropStyleContext* pStyle = - dynamic_cast< const XMLPropStyleContext* >( - pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_CELL, sStyleName) ); + if( sStyleName.isEmpty() ) + return; - if( pStyle ) - { - Reference< XPropertySet > xCellSet( mxCell, UNO_QUERY ); - if( xCellSet.is() ) - const_cast< XMLPropStyleContext* >( pStyle )->FillPropertySet( xCellSet ); - } - } + SvXMLStylesContext * pAutoStyles = GetImport().GetShapeImport()->GetAutoStylesContext(); + if( !pAutoStyles ) + return; + + const XMLPropStyleContext* pStyle = + dynamic_cast< const XMLPropStyleContext* >( + pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_CELL, sStyleName) ); + + if( pStyle ) + { + Reference< XPropertySet > xCellSet( mxCell, UNO_QUERY ); + if( xCellSet.is() ) + const_cast< XMLPropStyleContext* >( pStyle )->FillPropertySet( xCellSet ); } } diff --git a/xmloff/source/xforms/xformsexport.cxx b/xmloff/source/xforms/xformsexport.cxx index 151e043840bd..d3348b00b54c 100644 --- a/xmloff/source/xforms/xformsexport.cxx +++ b/xmloff/source/xforms/xformsexport.cxx @@ -79,19 +79,19 @@ using com::sun::star::util::Duration; void exportXForms( SvXMLExport& rExport ) { Reference<XFormsSupplier> xSupplier( rExport.GetModel(), UNO_QUERY ); - if( xSupplier.is() ) + if( !xSupplier.is() ) + return; + + Reference<XNameContainer> xForms = xSupplier->getXForms(); + if( xForms.is() ) { - Reference<XNameContainer> xForms = xSupplier->getXForms(); - if( xForms.is() ) - { - const Sequence<OUString> aNames = xForms->getElementNames(); + const Sequence<OUString> aNames = xForms->getElementNames(); - for( const auto& rName : aNames ) - { - Reference<XPropertySet> xModel( xForms->getByName( rName ), - UNO_QUERY ); - exportXFormsModel( rExport, xModel ); - } + for( const auto& rName : aNames ) + { + Reference<XPropertySet> xModel( xForms->getByName( rName ), + UNO_QUERY ); + exportXFormsModel( rExport, xModel ); } } } |