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/source/core | |
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/source/core')
-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 |
5 files changed, 445 insertions, 444 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; } } } |