xmloff/source/draw/XMLImageMapContext.cxx | 20 xmloff/source/draw/XMLImageMapExport.cxx | 46 xmloff/source/draw/XMLShapeStyleContext.cxx | 25 xmloff/source/draw/animationexport.cxx | 158 +- xmloff/source/draw/animationimport.cxx | 10 xmloff/source/draw/descriptionimp.cxx | 5 xmloff/source/draw/eventimp.cxx | 40 xmloff/source/draw/layerimp.cxx | 5 xmloff/source/draw/sdxmlexp.cxx | 227 ++-- xmloff/source/draw/sdxmlimp.cxx | 30 xmloff/source/draw/shapeexport.cxx | 973 ++++++++--------- xmloff/source/draw/shapeimport.cxx | 62 - xmloff/source/draw/xexptran.cxx | 534 ++++----- xmloff/source/draw/ximp3dobject.cxx | 150 +- xmloff/source/draw/ximp3dscene.cxx | 188 +-- xmloff/source/draw/ximpcustomshape.cxx | 518 ++++----- xmloff/source/draw/ximppage.cxx | 190 +-- xmloff/source/draw/ximpshap.cxx | 1532 ++++++++++++++-------------- xmloff/source/draw/ximpshow.cxx | 190 +-- xmloff/source/draw/ximpstyl.cxx | 284 ++--- 20 files changed, 2610 insertions(+), 2577 deletions(-)
New commits: commit 1f1f7b89d20f86a46b14674ad3747cbdb899c6ca Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 6 09:02:30 2020 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Aug 6 10:28:06 2020 +0200 loplugin:flatten in xmloff/draw Change-Id: I8eb9afc859727bd4d66d0a4415533d4012ed3c31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100197 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/xmloff/source/draw/XMLImageMapContext.cxx b/xmloff/source/draw/XMLImageMapContext.cxx index 8d0fa86cf0b6..8421dd119c37 100644 --- a/xmloff/source/draw/XMLImageMapContext.cxx +++ b/xmloff/source/draw/XMLImageMapContext.cxx @@ -160,19 +160,19 @@ XMLImageMapObjectContext::XMLImageMapObjectContext( "Please supply the image map object service name"); Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); - if( xFactory.is() ) + if( !xFactory.is() ) + return; + + Reference<XInterface> xIfc = xFactory->createInstance( + OUString::createFromAscii(pServiceName)); + DBG_ASSERT(xIfc.is(), "can't create image map object!"); + if( xIfc.is() ) { - Reference<XInterface> xIfc = xFactory->createInstance( - OUString::createFromAscii(pServiceName)); - DBG_ASSERT(xIfc.is(), "can't create image map object!"); - if( xIfc.is() ) - { - Reference<XPropertySet> xPropertySet( xIfc, UNO_QUERY ); + Reference<XPropertySet> xPropertySet( xIfc, UNO_QUERY ); - xMapEntry = xPropertySet; - } - // else: can't create service -> ignore + xMapEntry = xPropertySet; } + // else: can't create service -> ignore // else: can't even get factory -> ignore } diff --git a/xmloff/source/draw/XMLImageMapExport.cxx b/xmloff/source/draw/XMLImageMapExport.cxx index 5a9827272836..85b29122f6ad 100644 --- a/xmloff/source/draw/XMLImageMapExport.cxx +++ b/xmloff/source/draw/XMLImageMapExport.cxx @@ -92,33 +92,33 @@ void XMLImageMapExport::Export( void XMLImageMapExport::Export( const Reference<XIndexContainer> & rContainer) { - if (rContainer.is()) + if (!rContainer.is()) + return; + + if (!rContainer->hasElements()) + return; + + // image map container element + SvXMLElementExport aImageMapElement( + mrExport, XML_NAMESPACE_DRAW, XML_IMAGE_MAP, + true/*bWhiteSpace*/, true/*bWhiteSpace*/); + + // iterate over image map elements and call ExportMapEntry(...) + // for each + sal_Int32 nLength = rContainer->getCount(); + for(sal_Int32 i = 0; i < nLength; i++) { - if (rContainer->hasElements()) + Any aAny = rContainer->getByIndex(i); + Reference<XPropertySet> rElement; + aAny >>= rElement; + + DBG_ASSERT(rElement.is(), "Image map element is empty!"); + if (rElement.is()) { - // image map container element - SvXMLElementExport aImageMapElement( - mrExport, XML_NAMESPACE_DRAW, XML_IMAGE_MAP, - true/*bWhiteSpace*/, true/*bWhiteSpace*/); - - // iterate over image map elements and call ExportMapEntry(...) - // for each - sal_Int32 nLength = rContainer->getCount(); - for(sal_Int32 i = 0; i < nLength; i++) - { - Any aAny = rContainer->getByIndex(i); - Reference<XPropertySet> rElement; - aAny >>= rElement; - - DBG_ASSERT(rElement.is(), "Image map element is empty!"); - if (rElement.is()) - { - ExportMapEntry(rElement); - } - } + ExportMapEntry(rElement); } - // else: container is empty -> nothing to do } + // else: container is empty -> nothing to do // else: no container -> nothing to do } diff --git a/xmloff/source/draw/XMLShapeStyleContext.cxx b/xmloff/source/draw/XMLShapeStyleContext.cxx index b7036dd5df4e..73ce7f048c28 100644 --- a/xmloff/source/draw/XMLShapeStyleContext.cxx +++ b/xmloff/source/draw/XMLShapeStyleContext.cxx @@ -303,20 +303,21 @@ void XMLShapeStyleContext::FillPropertySet( const Reference< beans::XPropertySet } } - if (!m_sControlDataStyleName.isEmpty()) - { // we had a data-style-name attribute + if (m_sControlDataStyleName.isEmpty()) + return; - // set the formatting on the control model of the control shape - uno::Reference< drawing::XControlShape > xControlShape(rPropSet, uno::UNO_QUERY); - DBG_ASSERT(xControlShape.is(), "XMLShapeStyleContext::FillPropertySet: data style for a non-control shape!"); - if (xControlShape.is()) + // we had a data-style-name attribute + + // set the formatting on the control model of the control shape + uno::Reference< drawing::XControlShape > xControlShape(rPropSet, uno::UNO_QUERY); + DBG_ASSERT(xControlShape.is(), "XMLShapeStyleContext::FillPropertySet: data style for a non-control shape!"); + if (xControlShape.is()) + { + uno::Reference< beans::XPropertySet > xControlModel(xControlShape->getControl(), uno::UNO_QUERY); + DBG_ASSERT(xControlModel.is(), "XMLShapeStyleContext::FillPropertySet: no control model for the shape!"); + if (xControlModel.is()) { - uno::Reference< beans::XPropertySet > xControlModel(xControlShape->getControl(), uno::UNO_QUERY); - DBG_ASSERT(xControlModel.is(), "XMLShapeStyleContext::FillPropertySet: no control model for the shape!"); - if (xControlModel.is()) - { - GetImport().GetFormImport()->applyControlNumberStyle(xControlModel, m_sControlDataStyleName); - } + GetImport().GetFormImport()->applyControlNumberStyle(xControlModel, m_sControlDataStyleName); } } } diff --git a/xmloff/source/draw/animationexport.cxx b/xmloff/source/draw/animationexport.cxx index 76b1fa60ef6b..ad06922257cb 100644 --- a/xmloff/source/draw/animationexport.cxx +++ b/xmloff/source/draw/animationexport.cxx @@ -549,92 +549,95 @@ static OUString lcl_StoreMediaAndGetURL(SvXMLExport & rExport, OUString const& r void AnimationsExporterImpl::exportTransitionNode() { - if( mbHasTransition && mxPageProps.is() ) - { - sal_Int16 nTransition = 0; - mxPageProps->getPropertyValue("TransitionType") >>= nTransition; + if( !(mbHasTransition && mxPageProps.is()) ) + return; - Any aSound( mxPageProps->getPropertyValue("Sound") ); - OUString sSoundURL; - aSound >>= sSoundURL; - bool bStopSound = false; - if( !(aSound >>= bStopSound) ) - bStopSound = false; + sal_Int16 nTransition = 0; + mxPageProps->getPropertyValue("TransitionType") >>= nTransition; + Any aSound( mxPageProps->getPropertyValue("Sound") ); + OUString sSoundURL; + aSound >>= sSoundURL; + bool bStopSound = false; + if( !(aSound >>= bStopSound) ) + bStopSound = false; - OUStringBuffer sTmp; - if( (nTransition != 0) || !sSoundURL.isEmpty() || bStopSound ) - { - Reference< XInterface > xSource( mxPageProps.get() ); - Event aEvent; - aEvent.Source <<= xSource; - aEvent.Trigger = EventTrigger::BEGIN_EVENT; - aEvent.Repeat = 0; - convertTiming( sTmp, Any( aEvent ) ); - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() ); + OUStringBuffer sTmp; + if( !((nTransition != 0) || !sSoundURL.isEmpty() || bStopSound) ) + return; - SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_PAR, true, true ); + Reference< XInterface > xSource( mxPageProps.get() ); + Event aEvent; + aEvent.Source <<= xSource; + aEvent.Trigger = EventTrigger::BEGIN_EVENT; + aEvent.Repeat = 0; - if( nTransition != 0 ) - { - sal_Int16 nSubtype = 0; - bool bDirection = false; - sal_Int32 nFadeColor = 0; - double fDuration = 0.0; - mxPageProps->getPropertyValue("TransitionSubtype") >>= nSubtype; - mxPageProps->getPropertyValue("TransitionDirection") >>= bDirection; - mxPageProps->getPropertyValue("TransitionFadeColor") >>= nFadeColor; - mxPageProps->getPropertyValue("TransitionDuration") >>= fDuration; - - ::sax::Converter::convertDouble( sTmp, fDuration ); - sTmp.append( 's'); - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() ); - - SvXMLUnitConverter::convertEnum( sTmp, nTransition, aAnimations_EnumMap_TransitionType ); - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() ); + convertTiming( sTmp, Any( aEvent ) ); + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_BEGIN, sTmp.makeStringAndClear() ); - if( nSubtype != TransitionSubType::DEFAULT ) - { - SvXMLUnitConverter::convertEnum( sTmp, nSubtype, aAnimations_EnumMap_TransitionSubType ); - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() ); - } + SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_PAR, true, true ); - if( !bDirection ) - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE ); + if( nTransition != 0 ) + { + sal_Int16 nSubtype = 0; + bool bDirection = false; + sal_Int32 nFadeColor = 0; + double fDuration = 0.0; + mxPageProps->getPropertyValue("TransitionSubtype") >>= nSubtype; + mxPageProps->getPropertyValue("TransitionDirection") >>= bDirection; + mxPageProps->getPropertyValue("TransitionFadeColor") >>= nFadeColor; + mxPageProps->getPropertyValue("TransitionDuration") >>= fDuration; + + ::sax::Converter::convertDouble( sTmp, fDuration ); + sTmp.append( 's'); + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DUR, sTmp.makeStringAndClear() ); - if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) )) - { - ::sax::Converter::convertColor( sTmp, nFadeColor ); - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() ); - } - SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, true, true ); - } + SvXMLUnitConverter::convertEnum( sTmp, nTransition, aAnimations_EnumMap_TransitionType ); + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_TYPE, sTmp.makeStringAndClear() ); - if( bStopSound ) - { - mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, XML_STOP_AUDIO ); - SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true ); - } - else if( !sSoundURL.isEmpty()) - { - sSoundURL = lcl_StoreMediaAndGetURL(*mxExport, sSoundURL); - mxExport->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sSoundURL ); + if( nSubtype != TransitionSubType::DEFAULT ) + { + SvXMLUnitConverter::convertEnum( sTmp, nSubtype, aAnimations_EnumMap_TransitionSubType ); + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_SUBTYPE, sTmp.makeStringAndClear() ); + } - bool bLoopSound = false; - mxPageProps->getPropertyValue("LoopSound") >>= bLoopSound; + if( !bDirection ) + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_DIRECTION, XML_REVERSE ); - if( bLoopSound ) - mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE ); - SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true ); - } + if( (nTransition == TransitionType::FADE) && ((nSubtype == TransitionSubType::FADETOCOLOR) || (nSubtype == TransitionSubType::FADEFROMCOLOR) )) + { + ::sax::Converter::convertColor( sTmp, nFadeColor ); + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_FADECOLOR, sTmp.makeStringAndClear() ); } + SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_TRANSITIONFILTER, true, true ); + } + + if( bStopSound ) + { + mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, XML_STOP_AUDIO ); + SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true ); + } + else if( !sSoundURL.isEmpty()) + { + sSoundURL = lcl_StoreMediaAndGetURL(*mxExport, sSoundURL); + mxExport->AddAttribute( XML_NAMESPACE_XLINK, XML_HREF, sSoundURL ); + + bool bLoopSound = false; + mxPageProps->getPropertyValue("LoopSound") >>= bLoopSound; + + if( bLoopSound ) + mxExport->AddAttribute( XML_NAMESPACE_SMIL, XML_REPEATCOUNT, XML_INDEFINITE ); + SvXMLElementExport aElement2( *mxExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true ); } } void AnimationsExporterImpl::prepareTransitionNode() { - if( mxPageProps.is() ) try + if( !mxPageProps.is() ) + return; + + try { sal_Int16 nTransition = 0; mxPageProps->getPropertyValue("TransitionType") >>= nTransition; @@ -662,7 +665,6 @@ void AnimationsExporterImpl::prepareTransitionNode() { OSL_FAIL( "xmloff::AnimationsExporterImpl::prepareNode(), Exception caught!" ); } - } void AnimationsExporterImpl::prepareNode( const Reference< XAnimationNode >& xNode ) @@ -1306,7 +1308,10 @@ void AnimationsExporterImpl::exportAnimate( const Reference< XAnimate >& xAnimat void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio ) { - if( xAudio.is() ) try + if( !xAudio.is() ) + return; + + try { OUString aSourceURL; xAudio->getSource() >>= aSourceURL; @@ -1321,12 +1326,12 @@ void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio ) mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_AUDIO_LEVEL, sTmp.makeStringAndClear() ); } -/* todo? - sal_Int32 nEndAfterSlide = 0; + /* todo? + sal_Int32 nEndAfterSlide = 0; xAudio->getEndAfterSlide() >>= nEndAfterSlide; if( nEndAfterSlide != 0 ) mxExport->AddAttribute( ); -*/ + */ SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_AUDIO, true, true ); } @@ -1338,7 +1343,10 @@ void AnimationsExporterImpl::exportAudio( const Reference< XAudio >& xAudio ) void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xCommand ) { - if( xCommand.is() ) try + if( !xCommand.is() ) + return; + + try { OUStringBuffer sTmp; Any aTemp( xCommand->getTarget() ); @@ -1352,7 +1360,7 @@ void AnimationsExporterImpl::exportCommand( const Reference< XCommand >& xComman SvXMLUnitConverter::convertEnum( sTmp, nCommand, aAnimations_EnumMap_Command ); mxExport->AddAttribute( XML_NAMESPACE_ANIMATION, XML_COMMAND, sTmp.makeStringAndClear() ); -// todo virtual css::uno::Any SAL_CALL getParameter() throw (css::uno::RuntimeException) = 0; + // todo virtual css::uno::Any SAL_CALL getParameter() throw (css::uno::RuntimeException) = 0; SvXMLElementExport aElement( *mxExport, XML_NAMESPACE_ANIMATION, XML_COMMAND, true, true ); diff --git a/xmloff/source/draw/animationimport.cxx b/xmloff/source/draw/animationimport.cxx index 29cfcf79250d..5be84ec67391 100644 --- a/xmloff/source/draw/animationimport.cxx +++ b/xmloff/source/draw/animationimport.cxx @@ -540,7 +540,10 @@ void AnimationNodeContext::startFastElement( sal_Int32 /*nElement*/, const css:: void AnimationNodeContext::init_node( const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) { - if( mxNode.is() ) try + if( !mxNode.is() ) + return; + + try { const sal_Int16 nNodeType = mxNode->getType(); @@ -1224,7 +1227,10 @@ Reference< XAnimationNode > SAL_CALL AnimationsImport::getAnimationNode() void AnimationNodeContext::postProcessRootNode( const Reference< XAnimationNode >& xRootNode, Reference< XPropertySet > const & xPageProps ) { - if( xRootNode.is() && xPageProps.is() ) try + if( !(xRootNode.is() && xPageProps.is()) ) + return; + + try { Reference< XEnumerationAccess > xEnumerationAccess( xRootNode, UNO_QUERY_THROW ); Reference< XEnumeration > xEnumeration( xEnumerationAccess->createEnumeration(), UNO_SET_THROW ); diff --git a/xmloff/source/draw/descriptionimp.cxx b/xmloff/source/draw/descriptionimp.cxx index ca78afbee0ab..c4ca932aff99 100644 --- a/xmloff/source/draw/descriptionimp.cxx +++ b/xmloff/source/draw/descriptionimp.cxx @@ -47,7 +47,10 @@ SdXMLDescriptionContext::~SdXMLDescriptionContext() void SdXMLDescriptionContext::EndElement() { - if( !msText.isEmpty() ) try + if( msText.isEmpty() ) + return; + + try { uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY_THROW); if(IsXMLToken(GetLocalName(),XML_TITLE)) diff --git a/xmloff/source/draw/eventimp.cxx b/xmloff/source/draw/eventimp.cxx index f119c9fd0067..0c3b6a981570 100644 --- a/xmloff/source/draw/eventimp.cxx +++ b/xmloff/source/draw/eventimp.cxx @@ -102,29 +102,29 @@ public: XMLEventSoundContext::XMLEventSoundContext( SvXMLImport& rImp, sal_uInt16 nPrfx, const OUString& rLocalName, const Reference< XAttributeList >& xAttrList, SdXMLEventContext* pParent ) : SvXMLImportContext( rImp, nPrfx, rLocalName ) { - if( pParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND ) ) + if( !(pParent && nPrfx == XML_NAMESPACE_PRESENTATION && IsXMLToken( rLocalName, XML_SOUND )) ) + return; + + const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; + for(sal_Int16 i=0; i < nAttrCount; i++) { - const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; - for(sal_Int16 i=0; i < nAttrCount; i++) - { - OUString sAttrName = xAttrList->getNameByIndex( i ); - OUString aAttrLocalName; - sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aAttrLocalName ); - OUString sValue = xAttrList->getValueByIndex( i ); + OUString sAttrName = xAttrList->getNameByIndex( i ); + OUString aAttrLocalName; + sal_uInt16 nAttrPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aAttrLocalName ); + OUString sValue = xAttrList->getValueByIndex( i ); - switch( nAttrPrefix ) + switch( nAttrPrefix ) + { + case XML_NAMESPACE_XLINK: + if( IsXMLToken( aAttrLocalName, XML_HREF ) ) { - case XML_NAMESPACE_XLINK: - if( IsXMLToken( aAttrLocalName, XML_HREF ) ) - { - pParent->maData.msSoundURL = rImp.GetAbsoluteReference(sValue); - } - break; - case XML_NAMESPACE_PRESENTATION: - if( IsXMLToken( aAttrLocalName, XML_PLAY_FULL ) ) - { - pParent->maData.mbPlayFull = IsXMLToken( sValue, XML_TRUE ); - } + pParent->maData.msSoundURL = rImp.GetAbsoluteReference(sValue); + } + break; + case XML_NAMESPACE_PRESENTATION: + if( IsXMLToken( aAttrLocalName, XML_PLAY_FULL ) ) + { + pParent->maData.mbPlayFull = IsXMLToken( sValue, XML_TRUE ); } } } diff --git a/xmloff/source/draw/layerimp.cxx b/xmloff/source/draw/layerimp.cxx index c17c7cbebc6b..b5ecedf4bc23 100644 --- a/xmloff/source/draw/layerimp.cxx +++ b/xmloff/source/draw/layerimp.cxx @@ -113,7 +113,10 @@ SvXMLImportContextRef SdXMLLayerContext::CreateChildContext( sal_uInt16 nPrefix, void SdXMLLayerContext::EndElement() { SAL_WARN_IF( msName.isEmpty(), "xmloff", "xmloff::SdXMLLayerContext::EndElement(), draw:layer element without draw:name!" ); - if( !msName.isEmpty() ) try + if( msName.isEmpty() ) + return; + + try { Reference< XPropertySet > xLayer; diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx index 25302b2be85a..cc5a588cdc76 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -613,32 +613,32 @@ SdXMLExport::~SdXMLExport() void SdXMLExport::ImpPrepAutoLayoutInfos() { - if(IsImpress()) - { - OUString aStr; + if(!IsImpress()) + return; - Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY ); - if( xHandoutSupp.is() ) + OUString aStr; + + Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY ); + if( xHandoutSupp.is() ) + { + Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() ); + if( xHandoutPage.is() ) { - Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() ); - if( xHandoutPage.is() ) - { - if(ImpPrepAutoLayoutInfo(xHandoutPage, aStr)) - maDrawPagesAutoLayoutNames[0] = aStr; - } + if(ImpPrepAutoLayoutInfo(xHandoutPage, aStr)) + maDrawPagesAutoLayoutNames[0] = aStr; } + } - // prepare name creation - for (sal_Int32 nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++) - { - Any aAny(mxDocDrawPages->getByIndex(nCnt)); - Reference<XDrawPage> xDrawPage; + // prepare name creation + for (sal_Int32 nCnt = 0; nCnt < mnDocDrawPageCount; nCnt++) + { + Any aAny(mxDocDrawPages->getByIndex(nCnt)); + Reference<XDrawPage> xDrawPage; - if((aAny >>= xDrawPage) && xDrawPage.is()) - { - if(ImpPrepAutoLayoutInfo(xDrawPage, aStr)) - maDrawPagesAutoLayoutNames[nCnt+1] = aStr; - } + if((aAny >>= xDrawPage) && xDrawPage.is()) + { + if(ImpPrepAutoLayoutInfo(xDrawPage, aStr)) + maDrawPagesAutoLayoutNames[nCnt+1] = aStr; } } } @@ -1175,34 +1175,34 @@ void SdXMLExport::ImpPrepPageMasterInfos() } // create page master infos for master pages - if(mnDocMasterPageCount) + if(!mnDocMasterPageCount) + return; + + // look for needed page-masters, create these + for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++) { - // look for needed page-masters, create these - for (sal_Int32 nMPageId = 0; nMPageId < mnDocMasterPageCount; nMPageId++) - { - Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY ); - ImpXMLEXPPageMasterInfo* pNewInfo = nullptr; + Reference< XDrawPage > xMasterPage( mxDocMasterPages->getByIndex(nMPageId), UNO_QUERY ); + ImpXMLEXPPageMasterInfo* pNewInfo = nullptr; - if(xMasterPage.is()) - pNewInfo = ImpGetOrCreatePageMasterInfo(xMasterPage); + if(xMasterPage.is()) + pNewInfo = ImpGetOrCreatePageMasterInfo(xMasterPage); - mvPageMasterUsageList.push_back( pNewInfo ); + mvPageMasterUsageList.push_back( pNewInfo ); - // look for page master of handout page - if(IsImpress()) + // look for page master of handout page + if(IsImpress()) + { + pNewInfo = nullptr; + Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY); + if(xPresPage.is()) { - pNewInfo = nullptr; - Reference< presentation::XPresentationPage > xPresPage(xMasterPage, UNO_QUERY); - if(xPresPage.is()) + Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage()); + if(xNotesPage.is()) { - Reference< XDrawPage > xNotesPage(xPresPage->getNotesPage()); - if(xNotesPage.is()) - { - pNewInfo = ImpGetOrCreatePageMasterInfo(xNotesPage); - } + pNewInfo = ImpGetOrCreatePageMasterInfo(xNotesPage); } - mvNotesPageMasterUsageList.push_back( pNewInfo ); } + mvNotesPageMasterUsageList.push_back( pNewInfo ); } } } @@ -1448,28 +1448,28 @@ void SdXMLExport::ImpWriteHeaderFooterDecls() } } - if( !maDateTimeDeclsVector.empty() ) + if( maDateTimeDeclsVector.empty() ) + return; + + // export footer decls + const OUString aPrefix( gpStrDateTimeTextPrefix ); + sal_Int32 nIndex = 1; + for( const auto& rDecl : maDateTimeDeclsVector ) { - // export footer decls - const OUString aPrefix( gpStrDateTimeTextPrefix ); - sal_Int32 nIndex = 1; - for( const auto& rDecl : maDateTimeDeclsVector ) - { - sBuffer.append( aPrefix ); - sBuffer.append( nIndex ); - AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear()); + sBuffer.append( aPrefix ); + sBuffer.append( nIndex ); + AddAttribute( XML_NAMESPACE_PRESENTATION, XML_NAME, sBuffer.makeStringAndClear()); - AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE ); + AddAttribute( XML_NAMESPACE_PRESENTATION, XML_SOURCE, rDecl.mbFixed ? XML_FIXED : XML_CURRENT_DATE ); - if( !rDecl.mbFixed ) - AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, getDataStyleName( rDecl.mnFormat ) ); + if( !rDecl.mbFixed ) + AddAttribute( XML_NAMESPACE_STYLE, XML_DATA_STYLE_NAME, getDataStyleName( rDecl.mnFormat ) ); - SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, false, false); - if( rDecl.mbFixed ) - Characters(rDecl.maStrText); + SvXMLElementExport aElem(*this, XML_NAMESPACE_PRESENTATION, XML_DATE_TIME_DECL, false, false); + if( rDecl.mbFixed ) + Characters(rDecl.maStrText); - ++nIndex; - } + ++nIndex; } } @@ -1557,45 +1557,45 @@ void SdXMLExport::ImpPrepMasterPageInfos() maMasterPagesStyleNames[nCnt] = ImpCreatePresPageStyleName( xDrawPage ); } - if( IsImpress() ) + if( !IsImpress() ) + return; + + Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY ); + if( xHandoutSupp.is() ) { - Reference< presentation::XHandoutMasterSupplier > xHandoutSupp( GetModel(), UNO_QUERY ); - if( xHandoutSupp.is() ) + Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() ); + if( xHandoutPage.is() ) { - Reference< XDrawPage > xHandoutPage( xHandoutSupp->getHandoutMasterPage() ); - if( xHandoutPage.is() ) - { - maHandoutPageHeaderFooterSettings = ImpPrepDrawPageHeaderFooterDecls( xHandoutPage ); - maHandoutMasterStyleName = ImpCreatePresPageStyleName( xHandoutPage, false ); - } + maHandoutPageHeaderFooterSettings = ImpPrepDrawPageHeaderFooterDecls( xHandoutPage ); + maHandoutMasterStyleName = ImpCreatePresPageStyleName( xHandoutPage, false ); } } } void SdXMLExport::ImpWritePresentationStyles() { - if(IsImpress()) + if(!IsImpress()) + return; + + for (sal_Int32 nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++) { - for (sal_Int32 nCnt = 0; nCnt < mnDocMasterPageCount; nCnt++) - { - Any aAny(mxDocMasterPages->getByIndex(nCnt)); - Reference<container::XNamed> xNamed; + Any aAny(mxDocMasterPages->getByIndex(nCnt)); + Reference<container::XNamed> xNamed; - if(aAny >>= xNamed) + if(aAny >>= xNamed) + { + // write presentation styles (ONLY if presentation) + if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is()) { - // write presentation styles (ONLY if presentation) - if(IsImpress() && mxDocStyleFamilies.is() && xNamed.is()) - { - rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(*this, GetAutoStylePool().get())); - const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() ); + rtl::Reference<XMLStyleExport> aStEx(new XMLStyleExport(*this, GetAutoStylePool().get())); + const rtl::Reference< SvXMLExportPropertyMapper > aMapperRef( GetPropertySetMapper() ); - OUString aPrefix( xNamed->getName() + "-" ); + OUString aPrefix( xNamed->getName() + "-" ); - aStEx->exportStyleFamily(xNamed->getName(), - OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME), - aMapperRef, false, - XmlStyleFamily::SD_PRESENTATION_ID, &aPrefix); - } + aStEx->exportStyleFamily(xNamed->getName(), + OUString(XML_STYLE_FAMILY_SD_PRESENTATION_NAME), + aMapperRef, false, + XmlStyleFamily::SD_PRESENTATION_ID, &aPrefix); } } } @@ -2334,20 +2334,20 @@ void SdXMLExport::ExportMasterStyles_() void SdXMLExport::exportFormsElement( const Reference< XDrawPage >& xDrawPage ) { - if( xDrawPage.is() ) + if( !xDrawPage.is() ) + return; + + Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, UNO_QUERY ); + if ( xFormsSupplier.is() && xFormsSupplier->hasForms() ) { - Reference< form::XFormsSupplier2 > xFormsSupplier( xDrawPage, UNO_QUERY ); - if ( xFormsSupplier.is() && xFormsSupplier->hasForms() ) - { - // write masterpage - ::xmloff::OOfficeFormsExport aForms(*this); - GetFormExport()->exportForms( xDrawPage ); - } + // write masterpage + ::xmloff::OOfficeFormsExport aForms(*this); + GetFormExport()->exportForms( xDrawPage ); + } - if(! GetFormExport()->seekPage( xDrawPage ) ) - { - OSL_FAIL( "OFormLayerXMLExport::seekPage failed!" ); - } + if(! GetFormExport()->seekPage( xDrawPage ) ) + { + OSL_FAIL( "OFormLayerXMLExport::seekPage failed!" ); } } @@ -2377,19 +2377,19 @@ void SdXMLExport::GetViewSettings(uno::Sequence<beans::PropertyValue>& rProps) void SdXMLExport::GetConfigurationSettings(uno::Sequence<beans::PropertyValue>& rProps) { Reference< lang::XMultiServiceFactory > xFac( GetModel(), UNO_QUERY ); - if( xFac.is() ) - { - Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY ); - if( xProps.is() ) - SvXMLUnitConverter::convertPropertySet( rProps, xProps ); - DocumentSettingsSerializer *pFilter(dynamic_cast<DocumentSettingsSerializer *>(xProps.get())); - if (!pFilter) - return; - const uno::Reference< embed::XStorage > xStorage(GetTargetStorage()); - if (!xStorage.is()) - return; - rProps = pFilter->filterStreamsToStorage(xStorage, rProps); - } + if( !xFac.is() ) + return; + + Reference< beans::XPropertySet > xProps( xFac->createInstance("com.sun.star.document.Settings"), UNO_QUERY ); + if( xProps.is() ) + SvXMLUnitConverter::convertPropertySet( rProps, xProps ); + DocumentSettingsSerializer *pFilter(dynamic_cast<DocumentSettingsSerializer *>(xProps.get())); + if (!pFilter) + return; + const uno::Reference< embed::XStorage > xStorage(GetTargetStorage()); + if (!xStorage.is()) + return; + rProps = pFilter->filterStreamsToStorage(xStorage, rProps); } void SdXMLExport::addDataStyle(const sal_Int32 nNumberFormat, bool bTimeFormat ) @@ -2475,7 +2475,9 @@ OUString SdXMLExport::getNavigationOrder( const Reference< XDrawPage >& xDrawPag void SdXMLExport::collectAnnotationAutoStyles( const Reference<XDrawPage>& xDrawPage ) { Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY ); - if( xAnnotationAccess.is() ) try + if( !xAnnotationAccess.is() ) return; + + try { Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); if( xAnnotationEnumeration.is() ) @@ -2504,7 +2506,10 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage ) } Reference< XAnnotationAccess > xAnnotationAccess( xDrawPage, UNO_QUERY ); - if( xAnnotationAccess.is() ) try + if( !xAnnotationAccess.is() ) + return; + + try { Reference< XAnnotationEnumeration > xAnnotationEnumeration( xAnnotationAccess->createAnnotationEnumeration() ); if( xAnnotationEnumeration.is() && xAnnotationEnumeration->hasMoreElements() ) diff --git a/xmloff/source/draw/sdxmlimp.cxx b/xmloff/source/draw/sdxmlimp.cxx index 11a3dff5b95d..8cf178cbe73e 100644 --- a/xmloff/source/draw/sdxmlimp.cxx +++ b/xmloff/source/draw/sdxmlimp.cxx @@ -407,25 +407,25 @@ void SAL_CALL SdXMLImport::initialize( const uno::Sequence< uno::Any >& aArgumen SvXMLImport::initialize( aArguments ); uno::Reference< beans::XPropertySet > xInfoSet( getImportInfo() ); - if( xInfoSet.is() ) - { - uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() ); + if( !xInfoSet.is() ) + return; + + uno::Reference< beans::XPropertySetInfo > xInfoSetInfo( xInfoSet->getPropertySetInfo() ); - if( xInfoSetInfo->hasPropertyByName( gsPageLayouts ) ) - xInfoSet->getPropertyValue( gsPageLayouts ) >>= mxPageLayouts; + if( xInfoSetInfo->hasPropertyByName( gsPageLayouts ) ) + xInfoSet->getPropertyValue( gsPageLayouts ) >>= mxPageLayouts; - if( xInfoSetInfo->hasPropertyByName( gsPreview ) ) - xInfoSet->getPropertyValue( gsPreview ) >>= mbPreview; + if( xInfoSetInfo->hasPropertyByName( gsPreview ) ) + xInfoSet->getPropertyValue( gsPreview ) >>= mbPreview; - OUString const sOrganizerMode( - "OrganizerMode"); - if (xInfoSetInfo->hasPropertyByName(sOrganizerMode)) + OUString const sOrganizerMode( + "OrganizerMode"); + if (xInfoSetInfo->hasPropertyByName(sOrganizerMode)) + { + bool bStyleOnly(false); + if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly) { - bool bStyleOnly(false); - if (xInfoSet->getPropertyValue(sOrganizerMode) >>= bStyleOnly) - { - mbLoadDoc = !bStyleOnly; - } + mbLoadDoc = !bStyleOnly; } } } diff --git a/xmloff/source/draw/shapeexport.cxx b/xmloff/source/draw/shapeexport.cxx index c306f30a8aec..5365ce26dc1c 100644 --- a/xmloff/source/draw/shapeexport.cxx +++ b/xmloff/source/draw/shapeexport.cxx @@ -1054,131 +1054,131 @@ void XMLShapeExport::ImpCalcShapeType(const uno::Reference< drawing::XShape >& x // set in every case, so init here eShapeType = XmlShapeTypeUnknown; - if(xShape.is()) - { - OUString aType(xShape->getShapeType()); + if(!xShape.is()) + return; - if(aType.match("com.sun.star.")) - { - if(aType.match("drawing.", 13)) - { - // drawing shapes - if (aType.match("Rectangle", 21)) { eShapeType = XmlShapeTypeDrawRectangleShape; } + OUString aType(xShape->getShapeType()); + + if(!aType.match("com.sun.star.")) + return; - // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6. - // As can be seen at the other compares, the appendix "Shape" is left out of the comparison. - else if(aType.match("Custom", 21)) { eShapeType = XmlShapeTypeDrawCustomShape; } + if(aType.match("drawing.", 13)) + { + // drawing shapes + if (aType.match("Rectangle", 21)) { eShapeType = XmlShapeTypeDrawRectangleShape; } - else if(aType.match("Ellipse", 21)) { eShapeType = XmlShapeTypeDrawEllipseShape; } - else if(aType.match("Control", 21)) { eShapeType = XmlShapeTypeDrawControlShape; } - else if(aType.match("Connector", 21)) { eShapeType = XmlShapeTypeDrawConnectorShape; } - else if(aType.match("Measure", 21)) { eShapeType = XmlShapeTypeDrawMeasureShape; } - else if(aType.match("Line", 21)) { eShapeType = XmlShapeTypeDrawLineShape; } + // #i72177# Note: Correcting CustomShape, CustomShape->Custom, len from 9 (was wrong anyways) to 6. + // As can be seen at the other compares, the appendix "Shape" is left out of the comparison. + else if(aType.match("Custom", 21)) { eShapeType = XmlShapeTypeDrawCustomShape; } - // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape - else if(aType.match("PolyPolygon", 21)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; } + else if(aType.match("Ellipse", 21)) { eShapeType = XmlShapeTypeDrawEllipseShape; } + else if(aType.match("Control", 21)) { eShapeType = XmlShapeTypeDrawControlShape; } + else if(aType.match("Connector", 21)) { eShapeType = XmlShapeTypeDrawConnectorShape; } + else if(aType.match("Measure", 21)) { eShapeType = XmlShapeTypeDrawMeasureShape; } + else if(aType.match("Line", 21)) { eShapeType = XmlShapeTypeDrawLineShape; } - // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape - else if(aType.match("PolyLine", 21)) { eShapeType = XmlShapeTypeDrawPolyLineShape; } + // #i72177# Note: This covers two types by purpose, PolyPolygonShape and PolyPolygonPathShape + else if(aType.match("PolyPolygon", 21)) { eShapeType = XmlShapeTypeDrawPolyPolygonShape; } - else if(aType.match("OpenBezier", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; } - else if(aType.match("ClosedBezier", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; } + // #i72177# Note: This covers two types by purpose, PolyLineShape and PolyLinePathShape + else if(aType.match("PolyLine", 21)) { eShapeType = XmlShapeTypeDrawPolyLineShape; } - // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and - // ClosedFreeHandShape respectively. Represent them as bezier shapes - else if(aType.match("OpenFreeHand", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; } - else if(aType.match("ClosedFreeHand", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; } + else if(aType.match("OpenBezier", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; } + else if(aType.match("ClosedBezier", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; } - else if(aType.match("GraphicObject", 21)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; } - else if(aType.match("Group", 21)) { eShapeType = XmlShapeTypeDrawGroupShape; } - else if(aType.match("Text", 21)) { eShapeType = XmlShapeTypeDrawTextShape; } - else if(aType.match("OLE2", 21)) - { - eShapeType = XmlShapeTypeDrawOLE2Shape; + // #i72177# FreeHand (opened and closed) now supports the types OpenFreeHandShape and + // ClosedFreeHandShape respectively. Represent them as bezier shapes + else if(aType.match("OpenFreeHand", 21)) { eShapeType = XmlShapeTypeDrawOpenBezierShape; } + else if(aType.match("ClosedFreeHand", 21)) { eShapeType = XmlShapeTypeDrawClosedBezierShape; } + + else if(aType.match("GraphicObject", 21)) { eShapeType = XmlShapeTypeDrawGraphicObjectShape; } + else if(aType.match("Group", 21)) { eShapeType = XmlShapeTypeDrawGroupShape; } + else if(aType.match("Text", 21)) { eShapeType = XmlShapeTypeDrawTextShape; } + else if(aType.match("OLE2", 21)) + { + eShapeType = XmlShapeTypeDrawOLE2Shape; - // get info about presentation shape - uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); + // get info about presentation shape + uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) + if(xPropSet.is()) + { + OUString sCLSID; + if(xPropSet->getPropertyValue("CLSID") >>= sCLSID) + { + if (sCLSID == mrExport.GetChartExport()->getChartCLSID() || + sCLSID == SvGlobalName( SO3_RPTCH_CLASSID ).GetHexName() ) { - OUString sCLSID; - if(xPropSet->getPropertyValue("CLSID") >>= sCLSID) - { - if (sCLSID == mrExport.GetChartExport()->getChartCLSID() || - sCLSID == SvGlobalName( SO3_RPTCH_CLASSID ).GetHexName() ) - { - eShapeType = XmlShapeTypeDrawChartShape; - } - else if (sCLSID == SvGlobalName( SO3_SC_CLASSID ).GetHexName() ) - { - eShapeType = XmlShapeTypeDrawSheetShape; - } - else - { - // general OLE2 Object - } - } + eShapeType = XmlShapeTypeDrawChartShape; + } + else if (sCLSID == SvGlobalName( SO3_SC_CLASSID ).GetHexName() ) + { + eShapeType = XmlShapeTypeDrawSheetShape; + } + else + { + // general OLE2 Object } } - else if(aType.match("Page", 21)) { eShapeType = XmlShapeTypeDrawPageShape; } - else if(aType.match("Frame", 21)) { eShapeType = XmlShapeTypeDrawFrameShape; } - else if(aType.match("Caption", 21)) { eShapeType = XmlShapeTypeDrawCaptionShape; } - else if(aType.match("Plugin", 21)) { eShapeType = XmlShapeTypeDrawPluginShape; } - else if(aType.match("Applet", 21)) { eShapeType = XmlShapeTypeDrawAppletShape; } - else if(aType.match("MediaShape", 21)) { eShapeType = XmlShapeTypeDrawMediaShape; } - else if(aType.match("TableShape", 21)) { eShapeType = XmlShapeTypeDrawTableShape; } - - // 3D shapes - else if(aType.match("Scene", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSceneObject; } - else if(aType.match("Cube", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DCubeObject; } - else if(aType.match("Sphere", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSphereObject; } - else if(aType.match("Lathe", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DLatheObject; } - else if(aType.match("Extrude", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; } } - else if(aType.match("presentation.", 13)) - { - // presentation shapes - if (aType.match("TitleText", 26)) { eShapeType = XmlShapeTypePresTitleTextShape; } - else if(aType.match("Outliner", 26)) { eShapeType = XmlShapeTypePresOutlinerShape; } - else if(aType.match("Subtitle", 26)) { eShapeType = XmlShapeTypePresSubtitleShape; } - else if(aType.match("GraphicObject", 26)) { eShapeType = XmlShapeTypePresGraphicObjectShape; } - else if(aType.match("Page", 26)) { eShapeType = XmlShapeTypePresPageShape; } - else if(aType.match("OLE2", 26)) - { - eShapeType = XmlShapeTypePresOLE2Shape; + } + else if(aType.match("Page", 21)) { eShapeType = XmlShapeTypeDrawPageShape; } + else if(aType.match("Frame", 21)) { eShapeType = XmlShapeTypeDrawFrameShape; } + else if(aType.match("Caption", 21)) { eShapeType = XmlShapeTypeDrawCaptionShape; } + else if(aType.match("Plugin", 21)) { eShapeType = XmlShapeTypeDrawPluginShape; } + else if(aType.match("Applet", 21)) { eShapeType = XmlShapeTypeDrawAppletShape; } + else if(aType.match("MediaShape", 21)) { eShapeType = XmlShapeTypeDrawMediaShape; } + else if(aType.match("TableShape", 21)) { eShapeType = XmlShapeTypeDrawTableShape; } + + // 3D shapes + else if(aType.match("Scene", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSceneObject; } + else if(aType.match("Cube", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DCubeObject; } + else if(aType.match("Sphere", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DSphereObject; } + else if(aType.match("Lathe", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DLatheObject; } + else if(aType.match("Extrude", 21 + 7)) { eShapeType = XmlShapeTypeDraw3DExtrudeObject; } + } + else if(aType.match("presentation.", 13)) + { + // presentation shapes + if (aType.match("TitleText", 26)) { eShapeType = XmlShapeTypePresTitleTextShape; } + else if(aType.match("Outliner", 26)) { eShapeType = XmlShapeTypePresOutlinerShape; } + else if(aType.match("Subtitle", 26)) { eShapeType = XmlShapeTypePresSubtitleShape; } + else if(aType.match("GraphicObject", 26)) { eShapeType = XmlShapeTypePresGraphicObjectShape; } + else if(aType.match("Page", 26)) { eShapeType = XmlShapeTypePresPageShape; } + else if(aType.match("OLE2", 26)) + { + eShapeType = XmlShapeTypePresOLE2Shape; - // get info about presentation shape - uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); + // get info about presentation shape + uno::Reference <beans::XPropertySet> xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) try - { - OUString sCLSID; - if(xPropSet->getPropertyValue("CLSID") >>= sCLSID) - { - if( sCLSID == SvGlobalName( SO3_SC_CLASSID ).GetHexName() ) - { - eShapeType = XmlShapeTypePresSheetShape; - } - } - } - catch(const uno::Exception&) + if(xPropSet.is()) try + { + OUString sCLSID; + if(xPropSet->getPropertyValue("CLSID") >>= sCLSID) + { + if( sCLSID == SvGlobalName( SO3_SC_CLASSID ).GetHexName() ) { - SAL_WARN( "xmloff", "XMLShapeExport::ImpCalcShapeType(), expected ole shape to have the CLSID property?" ); + eShapeType = XmlShapeTypePresSheetShape; } } - else if(aType.match("Chart", 26)) { eShapeType = XmlShapeTypePresChartShape; } - else if(aType.match("OrgChart", 26)) { eShapeType = XmlShapeTypePresOrgChartShape; } - else if(aType.match("CalcShape", 26)) { eShapeType = XmlShapeTypePresSheetShape; } - else if(aType.match("TableShape", 26)) { eShapeType = XmlShapeTypePresTableShape; } - else if(aType.match("Notes", 26)) { eShapeType = XmlShapeTypePresNotesShape; } - else if(aType.match("HandoutShape", 26)) { eShapeType = XmlShapeTypeHandoutShape; } - else if(aType.match("HeaderShape", 26)) { eShapeType = XmlShapeTypePresHeaderShape; } - else if(aType.match("FooterShape", 26)) { eShapeType = XmlShapeTypePresFooterShape; } - else if(aType.match("SlideNumberShape", 26)) { eShapeType = XmlShapeTypePresSlideNumberShape; } - else if(aType.match("DateTimeShape", 26)) { eShapeType = XmlShapeTypePresDateTimeShape; } - else if(aType.match("MediaShape", 26)) { eShapeType = XmlShapeTypePresMediaShape; } + } + catch(const uno::Exception&) + { + SAL_WARN( "xmloff", "XMLShapeExport::ImpCalcShapeType(), expected ole shape to have the CLSID property?" ); } } + else if(aType.match("Chart", 26)) { eShapeType = XmlShapeTypePresChartShape; } + else if(aType.match("OrgChart", 26)) { eShapeType = XmlShapeTypePresOrgChartShape; } + else if(aType.match("CalcShape", 26)) { eShapeType = XmlShapeTypePresSheetShape; } + else if(aType.match("TableShape", 26)) { eShapeType = XmlShapeTypePresTableShape; } + else if(aType.match("Notes", 26)) { eShapeType = XmlShapeTypePresNotesShape; } + else if(aType.match("HandoutShape", 26)) { eShapeType = XmlShapeTypeHandoutShape; } + else if(aType.match("HeaderShape", 26)) { eShapeType = XmlShapeTypePresHeaderShape; } + else if(aType.match("FooterShape", 26)) { eShapeType = XmlShapeTypePresFooterShape; } + else if(aType.match("SlideNumberShape", 26)) { eShapeType = XmlShapeTypePresSlideNumberShape; } + else if(aType.match("DateTimeShape", 26)) { eShapeType = XmlShapeTypePresDateTimeShape; } + else if(aType.match("MediaShape", 26)) { eShapeType = XmlShapeTypePresMediaShape; } } } @@ -1285,31 +1285,31 @@ void XMLShapeExport::ImpExportQRCode(const uno::Reference<drawing::XShape>& xSha uno::Any aAny = xPropSet->getPropertyValue("QRCodeProperties"); css::drawing::QRCode aQRCode; - if(aAny >>= aQRCode) - { - mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aQRCode.Payload); - /* Export QR Code as per customised schema, @see OpenDocument-schema-v1.3+libreoffice */ - OUString temp; - switch(aQRCode.ErrorCorrection){ - case css::drawing::QRCodeErrorCorrection::LOW : - temp = "low"; - break; - case css::drawing::QRCodeErrorCorrection::MEDIUM: - temp = "medium"; - break; - case css::drawing::QRCodeErrorCorrection::QUARTILE: - temp = "quartile"; - break; - case css::drawing::QRCodeErrorCorrection::HIGH: - temp = "high"; - break; - } - mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_ERROR_CORRECTION, temp); - mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_BORDER, OUStringBuffer(20).append(aQRCode.Border).makeStringAndClear()); + if(!(aAny >>= aQRCode)) + return; - SvXMLElementExport aQRCodeElement(mrExport, XML_NAMESPACE_LO_EXT, XML_QRCODE, true, - true); + mrExport.AddAttribute(XML_NAMESPACE_OFFICE, XML_STRING_VALUE, aQRCode.Payload); + /* Export QR Code as per customised schema, @see OpenDocument-schema-v1.3+libreoffice */ + OUString temp; + switch(aQRCode.ErrorCorrection){ + case css::drawing::QRCodeErrorCorrection::LOW : + temp = "low"; + break; + case css::drawing::QRCodeErrorCorrection::MEDIUM: + temp = "medium"; + break; + case css::drawing::QRCodeErrorCorrection::QUARTILE: + temp = "quartile"; + break; + case css::drawing::QRCodeErrorCorrection::HIGH: + temp = "high"; + break; } + mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_ERROR_CORRECTION, temp); + mrExport.AddAttribute(XML_NAMESPACE_LO_EXT, XML_QRCODE_BORDER, OUStringBuffer(20).append(aQRCode.Border).makeStringAndClear()); + + SvXMLElementExport aQRCodeElement(mrExport, XML_NAMESPACE_LO_EXT, XML_QRCODE, true, + true); } void XMLShapeExport::ExportGraphicDefaults() @@ -1328,23 +1328,23 @@ void XMLShapeExport::ExportGraphicDefaults() // write graphic family default style uno::Reference< lang::XMultiServiceFactory > xFact( mrExport.GetModel(), uno::UNO_QUERY ); - if( xFact.is() ) + if( !xFact.is() ) + return; + + try { - try + uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance("com.sun.star.drawing.Defaults"), uno::UNO_QUERY ); + if( xDefaults.is() ) { - uno::Reference< beans::XPropertySet > xDefaults( xFact->createInstance("com.sun.star.drawing.Defaults"), uno::UNO_QUERY ); - if( xDefaults.is() ) - { - aStEx->exportDefaultStyle( xDefaults, XML_STYLE_FAMILY_SD_GRAPHICS_NAME, xPropertySetMapper ); + aStEx->exportDefaultStyle( xDefaults, XML_STYLE_FAMILY_SD_GRAPHICS_NAME, xPropertySetMapper ); - // write graphic family styles - aStEx->exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, false, XmlStyleFamily::SD_GRAPHICS_ID); - } - } - catch(const lang::ServiceNotRegisteredException&) - { + // write graphic family styles + aStEx->exportStyleFamily("graphics", OUString(XML_STYLE_FAMILY_SD_GRAPHICS_NAME), xPropertySetMapper, false, XmlStyleFamily::SD_GRAPHICS_ID); } } + catch(const lang::ServiceNotRegisteredException&) + { + } } void XMLShapeExport::onExport( const css::uno::Reference < css::drawing::XShape >& ) @@ -1880,31 +1880,31 @@ void XMLShapeExport::ImpExportDescription( const uno::Reference< drawing::XShape void XMLShapeExport::ImpExportGroupShape( const uno::Reference< drawing::XShape >& xShape, XMLShapeExportFlags nFeatures, awt::Point* pRefPoint) { uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) - { - // write group shape - bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# - SvXMLElementExport aPGR(mrExport, XML_NAMESPACE_DRAW, XML_G, bCreateNewline, true); + if(!(xShapes.is() && xShapes->getCount())) + return; - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); + // write group shape + bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# + SvXMLElementExport aPGR(mrExport, XML_NAMESPACE_DRAW, XML_G, bCreateNewline, true); - // #89764# if export of position is suppressed for group shape, - // positions of contained objects should be written relative to - // the upper left edge of the group. - awt::Point aUpperLeft; + ImpExportDescription( xShape ); // #i68101# + ImpExportEvents( xShape ); + ImpExportGluePoints( xShape ); - if(!(nFeatures & XMLShapeExportFlags::POSITION)) - { - nFeatures |= XMLShapeExportFlags::POSITION; - aUpperLeft = xShape->getPosition(); - pRefPoint = &aUpperLeft; - } + // #89764# if export of position is suppressed for group shape, + // positions of contained objects should be written relative to + // the upper left edge of the group. + awt::Point aUpperLeft; - // write members - exportShapes( xShapes, nFeatures, pRefPoint ); + if(!(nFeatures & XMLShapeExportFlags::POSITION)) + { + nFeatures |= XMLShapeExportFlags::POSITION; + aUpperLeft = xShape->getPosition(); + pRefPoint = &aUpperLeft; } + + // write members + exportShapes( xShapes, nFeatures, pRefPoint ); } void XMLShapeExport::ImpExportTextBoxShape( @@ -2013,31 +2013,31 @@ void XMLShapeExport::ImpExportRectangleShape( XMLShapeExportFlags nFeatures, css::awt::Point* pRefPoint) { const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - // Transformation - ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); - - // evtl. corner radius? - sal_Int32 nCornerRadius(0); - xPropSet->getPropertyValue("CornerRadius") >>= nCornerRadius; - if(nCornerRadius) - { - OUStringBuffer sStringBuffer; - mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, - nCornerRadius); - mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear()); - } + if(!xPropSet.is()) + return; - // write rectangle - bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_RECT, bCreateNewline, true); + // Transformation + ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); - ImpExportGluePoints( xShape ); - ImpExportText( xShape ); + // evtl. corner radius? + sal_Int32 nCornerRadius(0); + xPropSet->getPropertyValue("CornerRadius") >>= nCornerRadius; + if(nCornerRadius) + { + OUStringBuffer sStringBuffer; + mrExport.GetMM100UnitConverter().convertMeasureToXML(sStringBuffer, + nCornerRadius); + mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, sStringBuffer.makeStringAndClear()); } + + // write rectangle + bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_RECT, bCreateNewline, true); + + ImpExportDescription( xShape ); // #i68101# + ImpExportEvents( xShape ); + ImpExportGluePoints( xShape ); + ImpExportText( xShape ); } void XMLShapeExport::ImpExportLineShape( @@ -2972,35 +2972,35 @@ void XMLShapeExport::ImpExportPageShape( XmlShapeType eShapeType, XMLShapeExportFlags nFeatures /* = SEF_DEFAULT */, awt::Point* pRefPoint /* = NULL */) { const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - // #86163# Transformation - ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); + if(!xPropSet.is()) + return; - // export page number used for this page - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - const OUString aPageNumberStr("PageNumber"); - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr)) - { - sal_Int32 nPageNumber = 0; - xPropSet->getPropertyValue(aPageNumberStr) >>= nPageNumber; - if( nPageNumber ) - mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_PAGE_NUMBER, OUString::number(nPageNumber)); - } + // #86163# Transformation + ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); - // a presentation page shape, normally used on notes pages only. If - // it is used not as presentation shape, it may have been created with - // copy-paste exchange between draw and impress (this IS possible...) - if(eShapeType == XmlShapeTypePresPageShape) - { - mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS, - XML_PAGE); - } + // export page number used for this page + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + const OUString aPageNumberStr("PageNumber"); + if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr)) + { + sal_Int32 nPageNumber = 0; + xPropSet->getPropertyValue(aPageNumberStr) >>= nPageNumber; + if( nPageNumber ) + mrExport.AddAttribute(XML_NAMESPACE_DRAW, XML_PAGE_NUMBER, OUString::number(nPageNumber)); + } - // write Page shape - bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PAGE_THUMBNAIL, bCreateNewline, true); + // a presentation page shape, normally used on notes pages only. If + // it is used not as presentation shape, it may have been created with + // copy-paste exchange between draw and impress (this IS possible...) + if(eShapeType == XmlShapeTypePresPageShape) + { + mrExport.AddAttribute(XML_NAMESPACE_PRESENTATION, XML_CLASS, + XML_PAGE); } + + // write Page shape + bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DRAW, XML_PAGE_THUMBNAIL, bCreateNewline, true); } void XMLShapeExport::ImpExportCaptionShape( @@ -3350,44 +3350,44 @@ void XMLShapeExport::ImpExportMediaShape( void XMLShapeExport::ImpExport3DSceneShape( const uno::Reference< drawing::XShape >& xShape, XMLShapeExportFlags nFeatures, awt::Point* pRefPoint) { uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY); - if(xShapes.is() && xShapes->getCount()) - { - uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); - SAL_WARN_IF( !xPropSet.is(), "xmloff", "XMLShapeExport::ImpExport3DSceneShape can't export a scene without a propertyset" ); - if( xPropSet.is() ) - { - // Transformation - ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); + if(!(xShapes.is() && xShapes->getCount())) + return; - // 3d attributes - export3DSceneAttributes( xPropSet ); + uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY ); + SAL_WARN_IF( !xPropSet.is(), "xmloff", "XMLShapeExport::ImpExport3DSceneShape can't export a scene without a propertyset" ); + if( !xPropSet.is() ) + return; - // write 3DScene shape - bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# - SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DR3D, XML_SCENE, bCreateNewline, true); + // Transformation + ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); - ImpExportDescription( xShape ); // #i68101# - ImpExportEvents( xShape ); + // 3d attributes + export3DSceneAttributes( xPropSet ); - // write 3DSceneLights - export3DLamps( xPropSet ); + // write 3DScene shape + bool bCreateNewline( (nFeatures & XMLShapeExportFlags::NO_WS) == XMLShapeExportFlags::NONE ); // #86116#/#92210# + SvXMLElementExport aOBJ( mrExport, XML_NAMESPACE_DR3D, XML_SCENE, bCreateNewline, true); - // #89764# if export of position is suppressed for group shape, - // positions of contained objects should be written relative to - // the upper left edge of the group. - awt::Point aUpperLeft; + ImpExportDescription( xShape ); // #i68101# + ImpExportEvents( xShape ); - if(!(nFeatures & XMLShapeExportFlags::POSITION)) - { - nFeatures |= XMLShapeExportFlags::POSITION; - aUpperLeft = xShape->getPosition(); - pRefPoint = &aUpperLeft; - } + // write 3DSceneLights + export3DLamps( xPropSet ); - // write members - exportShapes( xShapes, nFeatures, pRefPoint ); - } + // #89764# if export of position is suppressed for group shape, + // positions of contained objects should be written relative to + // the upper left edge of the group. + awt::Point aUpperLeft; + + if(!(nFeatures & XMLShapeExportFlags::POSITION)) + { + nFeatures |= XMLShapeExportFlags::POSITION; + aUpperLeft = xShape->getPosition(); + pRefPoint = &aUpperLeft; } + + // write members + exportShapes( xShapes, nFeatures, pRefPoint ); } void XMLShapeExport::ImpExport3DShape( @@ -3395,157 +3395,157 @@ void XMLShapeExport::ImpExport3DShape( XmlShapeType eShapeType) { const uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - OUString aStr; - OUStringBuffer sStringBuffer; + if(!xPropSet.is()) + return; - // transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix") - uno::Any aAny = xPropSet->getPropertyValue("D3DTransformMatrix"); - drawing::HomogenMatrix aHomMat; - aAny >>= aHomMat; - SdXMLImExTransform3D aTransform; - aTransform.AddHomogenMatrix(aHomMat); - if(aTransform.NeedsAction()) - mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter())); + OUString aStr; + OUStringBuffer sStringBuffer; - switch(eShapeType) + // transformation (UNO_NAME_3D_TRANSFORM_MATRIX == "D3DTransformMatrix") + uno::Any aAny = xPropSet->getPropertyValue("D3DTransformMatrix"); + drawing::HomogenMatrix aHomMat; + aAny >>= aHomMat; + SdXMLImExTransform3D aTransform; + aTransform.AddHomogenMatrix(aHomMat); + if(aTransform.NeedsAction()) + mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_TRANSFORM, aTransform.GetExportString(mrExport.GetMM100UnitConverter())); + + switch(eShapeType) + { + case XmlShapeTypeDraw3DCubeObject: { - case XmlShapeTypeDraw3DCubeObject: + // minEdge + aAny = xPropSet->getPropertyValue("D3DPosition"); + drawing::Position3D aPosition3D; + aAny >>= aPosition3D; + ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ); + + // maxEdge + aAny = xPropSet->getPropertyValue("D3DSize"); + drawing::Direction3D aDirection3D; + aAny >>= aDirection3D; + ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ); + + // transform maxEdge from distance to pos + aDir3D = aPos3D + aDir3D; + + // write minEdge + if(aPos3D != ::basegfx::B3DVector(-2500.0, -2500.0, -2500.0)) // write only when not default { - // minEdge - aAny = xPropSet->getPropertyValue("D3DPosition"); - drawing::Position3D aPosition3D; - aAny >>= aPosition3D; - ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ); - - // maxEdge - aAny = xPropSet->getPropertyValue("D3DSize"); - drawing::Direction3D aDirection3D; - aAny >>= aDirection3D; - ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ); - - // transform maxEdge from distance to pos - aDir3D = aPos3D + aDir3D; - - // write minEdge - if(aPos3D != ::basegfx::B3DVector(-2500.0, -2500.0, -2500.0)) // write only when not default - { - SvXMLUnitConverter::convertB3DVector(sStringBuffer, aPos3D); - aStr = sStringBuffer.makeStringAndClear(); - mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MIN_EDGE, aStr); - } + SvXMLUnitConverter::convertB3DVector(sStringBuffer, aPos3D); + aStr = sStringBuffer.makeStringAndClear(); + mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MIN_EDGE, aStr); + } - // write maxEdge - if(aDir3D != ::basegfx::B3DVector(2500.0, 2500.0, 2500.0)) // write only when not default - { - SvXMLUnitConverter::convertB3DVector(sStringBuffer, aDir3D); - aStr = sStringBuffer.makeStringAndClear(); - mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr); - } + // write maxEdge + if(aDir3D != ::basegfx::B3DVector(2500.0, 2500.0, 2500.0)) // write only when not default + { + SvXMLUnitConverter::convertB3DVector(sStringBuffer, aDir3D); + aStr = sStringBuffer.makeStringAndClear(); + mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_MAX_EDGE, aStr); + } - // write 3DCube shape - // #i123542# Do this *after* the attributes are added, else these will be lost since opening - // the scope will clear the global attribute list at the exporter - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, true, true); + // write 3DCube shape + // #i123542# Do this *after* the attributes are added, else these will be lost since opening + // the scope will clear the global attribute list at the exporter + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_CUBE, true, true); - break; + break; + } + case XmlShapeTypeDraw3DSphereObject: + { + // Center + aAny = xPropSet->getPropertyValue("D3DPosition"); + drawing::Position3D aPosition3D; + aAny >>= aPosition3D; + ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ); + + // Size + aAny = xPropSet->getPropertyValue("D3DSize"); + drawing::Direction3D aDirection3D; + aAny >>= aDirection3D; + ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ); + + // write Center + if(aPos3D != ::basegfx::B3DVector(0.0, 0.0, 0.0)) // write only when not default + { + SvXMLUnitConverter::convertB3DVector(sStringBuffer, aPos3D); + aStr = sStringBuffer.makeStringAndClear(); + mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_CENTER, aStr); } - case XmlShapeTypeDraw3DSphereObject: + + // write Size + if(aDir3D != ::basegfx::B3DVector(5000.0, 5000.0, 5000.0)) // write only when not default { - // Center - aAny = xPropSet->getPropertyValue("D3DPosition"); - drawing::Position3D aPosition3D; - aAny >>= aPosition3D; - ::basegfx::B3DVector aPos3D(aPosition3D.PositionX, aPosition3D.PositionY, aPosition3D.PositionZ); - - // Size - aAny = xPropSet->getPropertyValue("D3DSize"); - drawing::Direction3D aDirection3D; - aAny >>= aDirection3D; - ::basegfx::B3DVector aDir3D(aDirection3D.DirectionX, aDirection3D.DirectionY, aDirection3D.DirectionZ); - - // write Center - if(aPos3D != ::basegfx::B3DVector(0.0, 0.0, 0.0)) // write only when not default - { - SvXMLUnitConverter::convertB3DVector(sStringBuffer, aPos3D); - aStr = sStringBuffer.makeStringAndClear(); - mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_CENTER, aStr); - } + SvXMLUnitConverter::convertB3DVector(sStringBuffer, aDir3D); + aStr = sStringBuffer.makeStringAndClear(); + mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr); + } - // write Size - if(aDir3D != ::basegfx::B3DVector(5000.0, 5000.0, 5000.0)) // write only when not default - { - SvXMLUnitConverter::convertB3DVector(sStringBuffer, aDir3D); - aStr = sStringBuffer.makeStringAndClear(); - mrExport.AddAttribute(XML_NAMESPACE_DR3D, XML_SIZE, aStr); - } + // write 3DSphere shape + // #i123542# Do this *after* the attributes are added, else these will be lost since opening + // the scope will clear the global attribute list at the exporter + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, true, true); + + break; + } + case XmlShapeTypeDraw3DLatheObject: + case XmlShapeTypeDraw3DExtrudeObject: + { + // write special 3DLathe/3DExtrude attributes, get 3D tools::PolyPolygon as drawing::PolyPolygonShape3D + aAny = xPropSet->getPropertyValue("D3DPolyPolygon3D"); + drawing::PolyPolygonShape3D aUnoPolyPolygon3D; + aAny >>= aUnoPolyPolygon3D; + + // convert to 3D PolyPolygon + const basegfx::B3DPolyPolygon aPolyPolygon3D( + basegfx::utils::UnoPolyPolygonShape3DToB3DPolyPolygon( + aUnoPolyPolygon3D)); + + // convert to 2D tools::PolyPolygon using identity 3D transformation (just grep X and Y) + const basegfx::B3DHomMatrix aB3DHomMatrixFor2DConversion; + const basegfx::B2DPolyPolygon aPolyPolygon( + basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon( + aPolyPolygon3D, + aB3DHomMatrixFor2DConversion)); + + // get 2D range of it + const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); + + // export ViewBox + SdXMLImExViewBox aViewBox( + aPolyPolygonRange.getMinX(), + aPolyPolygonRange.getMinY(), + aPolyPolygonRange.getWidth(), + aPolyPolygonRange.getHeight()); + + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); + + // prepare svg:d string + const OUString aPolygonString( + basegfx::utils::exportToSvgD( + aPolyPolygon, + true, // bUseRelativeCoordinates + false, // bDetectQuadraticBeziers TTTT: not used in old, but maybe activated now + true)); // bHandleRelativeNextPointCompatible - // write 3DSphere shape - // #i123542# Do this *after* the attributes are added, else these will be lost since opening - // the scope will clear the global attribute list at the exporter - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_SPHERE, true, true); + // write point array + mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); - break; + if(eShapeType == XmlShapeTypeDraw3DLatheObject) + { + // write 3DLathe shape + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_ROTATE, true, true); } - case XmlShapeTypeDraw3DLatheObject: - case XmlShapeTypeDraw3DExtrudeObject: + else { - // write special 3DLathe/3DExtrude attributes, get 3D tools::PolyPolygon as drawing::PolyPolygonShape3D - aAny = xPropSet->getPropertyValue("D3DPolyPolygon3D"); - drawing::PolyPolygonShape3D aUnoPolyPolygon3D; - aAny >>= aUnoPolyPolygon3D; - - // convert to 3D PolyPolygon - const basegfx::B3DPolyPolygon aPolyPolygon3D( - basegfx::utils::UnoPolyPolygonShape3DToB3DPolyPolygon( - aUnoPolyPolygon3D)); - - // convert to 2D tools::PolyPolygon using identity 3D transformation (just grep X and Y) - const basegfx::B3DHomMatrix aB3DHomMatrixFor2DConversion; - const basegfx::B2DPolyPolygon aPolyPolygon( - basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon( - aPolyPolygon3D, - aB3DHomMatrixFor2DConversion)); - - // get 2D range of it - const basegfx::B2DRange aPolyPolygonRange(aPolyPolygon.getB2DRange()); - - // export ViewBox - SdXMLImExViewBox aViewBox( - aPolyPolygonRange.getMinX(), - aPolyPolygonRange.getMinY(), - aPolyPolygonRange.getWidth(), - aPolyPolygonRange.getHeight()); - - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_VIEWBOX, aViewBox.GetExportString()); - - // prepare svg:d string - const OUString aPolygonString( - basegfx::utils::exportToSvgD( - aPolyPolygon, - true, // bUseRelativeCoordinates - false, // bDetectQuadraticBeziers TTTT: not used in old, but maybe activated now - true)); // bHandleRelativeNextPointCompatible - - // write point array - mrExport.AddAttribute(XML_NAMESPACE_SVG, XML_D, aPolygonString); - - if(eShapeType == XmlShapeTypeDraw3DLatheObject) - { - // write 3DLathe shape - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_ROTATE, true, true); - } - else - { - // write 3DExtrude shape - SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_EXTRUDE, true, true); - } - break; + // write 3DExtrude shape + SvXMLElementExport aOBJ(mrExport, XML_NAMESPACE_DR3D, XML_EXTRUDE, true, true); } - default: - break; + break; } + default: + break; } } @@ -3807,142 +3807,142 @@ static void ImpExportEquations( SvXMLExport& rExport, const uno::Sequence< OUStr static void ImpExportHandles( SvXMLExport& rExport, const uno::Sequence< beans::PropertyValues >& rHandles ) { - if ( rHandles.hasElements() ) - { - OUString aStr; - OUStringBuffer aStrBuffer; + if ( !rHandles.hasElements() ) + return; - for ( const uno::Sequence< beans::PropertyValue >& rPropSeq : rHandles ) + OUString aStr; + OUStringBuffer aStrBuffer; + + for ( const uno::Sequence< beans::PropertyValue >& rPropSeq : rHandles ) + { + bool bPosition = false; + for ( const beans::PropertyValue& rPropVal : rPropSeq ) { - bool bPosition = false; - for ( const beans::PropertyValue& rPropVal : rPropSeq ) + switch( EASGet( rPropVal.Name ) ) { - switch( EASGet( rPropVal.Name ) ) + case EAS_Position : { - case EAS_Position : - { - css::drawing::EnhancedCustomShapeParameterPair aPosition; - if ( rPropVal.Value >>= aPosition ) - { - ExportParameter( aStrBuffer, aPosition.First ); - ExportParameter( aStrBuffer, aPosition.Second ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POSITION, aStr ); - bPosition = true; - } - } - break; - case EAS_MirroredX : + css::drawing::EnhancedCustomShapeParameterPair aPosition; + if ( rPropVal.Value >>= aPosition ) { - bool bMirroredX; - if ( rPropVal.Value >>= bMirroredX ) - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_HORIZONTAL, - bMirroredX ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) ); + ExportParameter( aStrBuffer, aPosition.First ); + ExportParameter( aStrBuffer, aPosition.Second ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POSITION, aStr ); + bPosition = true; } - break; - case EAS_MirroredY : - { - bool bMirroredY; - if ( rPropVal.Value >>= bMirroredY ) - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_VERTICAL, - bMirroredY ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) ); - } - break; - case EAS_Switched : + } + break; + case EAS_MirroredX : + { + bool bMirroredX; + if ( rPropVal.Value >>= bMirroredX ) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_HORIZONTAL, + bMirroredX ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) ); + } + break; + case EAS_MirroredY : + { + bool bMirroredY; + if ( rPropVal.Value >>= bMirroredY ) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_MIRROR_VERTICAL, + bMirroredY ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) ); + } + break; + case EAS_Switched : + { + bool bSwitched; + if ( rPropVal.Value >>= bSwitched ) + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_SWITCHED, + bSwitched ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) ); + } + break; + case EAS_Polar : + { + css::drawing::EnhancedCustomShapeParameterPair aPolar; + if ( rPropVal.Value >>= aPolar ) { - bool bSwitched; - if ( rPropVal.Value >>= bSwitched ) - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_SWITCHED, - bSwitched ? GetXMLToken( XML_TRUE ) : GetXMLToken( XML_FALSE ) ); + ExportParameter( aStrBuffer, aPolar.First ); + ExportParameter( aStrBuffer, aPolar.Second ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POLAR, aStr ); } - break; - case EAS_Polar : - { - css::drawing::EnhancedCustomShapeParameterPair aPolar; - if ( rPropVal.Value >>= aPolar ) - { - ExportParameter( aStrBuffer, aPolar.First ); - ExportParameter( aStrBuffer, aPolar.Second ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_POLAR, aStr ); - } - } - break; - case EAS_RadiusRangeMinimum : + } + break; + case EAS_RadiusRangeMinimum : + { + css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; + if ( rPropVal.Value >>= aRadiusRangeMinimum ) { - css::drawing::EnhancedCustomShapeParameter aRadiusRangeMinimum; - if ( rPropVal.Value >>= aRadiusRangeMinimum ) - { - ExportParameter( aStrBuffer, aRadiusRangeMinimum ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MINIMUM, aStr ); - } + ExportParameter( aStrBuffer, aRadiusRangeMinimum ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MINIMUM, aStr ); } - break; - case EAS_RadiusRangeMaximum : + } + break; + case EAS_RadiusRangeMaximum : + { + css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; + if ( rPropVal.Value >>= aRadiusRangeMaximum ) { - css::drawing::EnhancedCustomShapeParameter aRadiusRangeMaximum; - if ( rPropVal.Value >>= aRadiusRangeMaximum ) - { - ExportParameter( aStrBuffer, aRadiusRangeMaximum ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MAXIMUM, aStr ); - } + ExportParameter( aStrBuffer, aRadiusRangeMaximum ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RADIUS_RANGE_MAXIMUM, aStr ); } - break; - case EAS_RangeXMinimum : + } + break; + case EAS_RangeXMinimum : + { + css::drawing::EnhancedCustomShapeParameter aXRangeMinimum; + if ( rPropVal.Value >>= aXRangeMinimum ) { - css::drawing::EnhancedCustomShapeParameter aXRangeMinimum; - if ( rPropVal.Value >>= aXRangeMinimum ) - { - ExportParameter( aStrBuffer, aXRangeMinimum ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MINIMUM, aStr ); - } + ExportParameter( aStrBuffer, aXRangeMinimum ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MINIMUM, aStr ); } - break; - case EAS_RangeXMaximum : + } + break; + case EAS_RangeXMaximum : + { + css::drawing::EnhancedCustomShapeParameter aXRangeMaximum; + if ( rPropVal.Value >>= aXRangeMaximum ) { - css::drawing::EnhancedCustomShapeParameter aXRangeMaximum; - if ( rPropVal.Value >>= aXRangeMaximum ) - { - ExportParameter( aStrBuffer, aXRangeMaximum ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MAXIMUM, aStr ); - } + ExportParameter( aStrBuffer, aXRangeMaximum ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_X_MAXIMUM, aStr ); } - break; - case EAS_RangeYMinimum : + } + break; + case EAS_RangeYMinimum : + { + css::drawing::EnhancedCustomShapeParameter aYRangeMinimum; + if ( rPropVal.Value >>= aYRangeMinimum ) { - css::drawing::EnhancedCustomShapeParameter aYRangeMinimum; - if ( rPropVal.Value >>= aYRangeMinimum ) - { - ExportParameter( aStrBuffer, aYRangeMinimum ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MINIMUM, aStr ); - } + ExportParameter( aStrBuffer, aYRangeMinimum ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MINIMUM, aStr ); } - break; - case EAS_RangeYMaximum : + } + break; + case EAS_RangeYMaximum : + { + css::drawing::EnhancedCustomShapeParameter aYRangeMaximum; + if ( rPropVal.Value >>= aYRangeMaximum ) { - css::drawing::EnhancedCustomShapeParameter aYRangeMaximum; - if ( rPropVal.Value >>= aYRangeMaximum ) - { - ExportParameter( aStrBuffer, aYRangeMaximum ); - aStr = aStrBuffer.makeStringAndClear(); - rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MAXIMUM, aStr ); - } + ExportParameter( aStrBuffer, aYRangeMaximum ); + aStr = aStrBuffer.makeStringAndClear(); + rExport.AddAttribute( XML_NAMESPACE_DRAW, XML_HANDLE_RANGE_Y_MAXIMUM, aStr ); } - break; - default: - break; } + break; + default: + break; } - if ( bPosition ) - SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_HANDLE, true, true ); - else - rExport.ClearAttrList(); } + if ( bPosition ) + SvXMLElementExport aOBJ( rExport, XML_NAMESPACE_DRAW, XML_HANDLE, true, true ); + else + rExport.ClearAttrList(); } } @@ -4804,7 +4804,10 @@ void XMLShapeExport::ImpExportTableShape( const uno::Reference< drawing::XShape uno::Reference< container::XNamed > xNamed(xShape, uno::UNO_QUERY); SAL_WARN_IF( !xPropSet.is() || !xNamed.is(), "xmloff", "xmloff::XMLShapeExport::ImpExportTableShape(), table shape is not implementing needed interfaces"); - if(xPropSet.is() && xNamed.is()) try + if(!(xPropSet.is() && xNamed.is())) + return; + + try { // Transformation ImpExportNewTrans(xPropSet, nFeatures, pRefPoint); diff --git a/xmloff/source/draw/shapeimport.cxx b/xmloff/source/draw/shapeimport.cxx index 9fcae5b8b6a4..11c82de99e52 100644 --- a/xmloff/source/draw/shapeimport.cxx +++ b/xmloff/source/draw/shapeimport.cxx @@ -747,26 +747,26 @@ void ShapeGroupContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos ) uno::Reference< beans::XPropertySet > xPropSet; aAny >>= xPropSet; - if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( "ZOrder" ) ) - { - xPropSet->setPropertyValue( "ZOrder", uno::Any(nDestPos) ); + if( !(xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( "ZOrder" )) ) + return; + + xPropSet->setPropertyValue( "ZOrder", uno::Any(nDestPos) ); - for( ZOrderHint& rHint : maZOrderList ) + for( ZOrderHint& rHint : maZOrderList ) + { + if( rHint.nIs < nSourcePos ) { - if( rHint.nIs < nSourcePos ) - { - DBG_ASSERT(rHint.nIs >= nDestPos, "Shape sorting failed" ); - rHint.nIs++; - } + DBG_ASSERT(rHint.nIs >= nDestPos, "Shape sorting failed" ); + rHint.nIs++; } + } - for( ZOrderHint& rHint : maUnsortedList ) + for( ZOrderHint& rHint : maUnsortedList ) + { + if( rHint.nIs < nSourcePos ) { - if( rHint.nIs < nSourcePos ) - { - SAL_WARN_IF( rHint.nIs < nDestPos, "xmloff", "shape sorting failed" ); - rHint.nIs++; - } + SAL_WARN_IF( rHint.nIs < nDestPos, "xmloff", "shape sorting failed" ); + rHint.nIs++; } } } @@ -917,23 +917,23 @@ void XMLShapeImportHelper::popGroupAndPostProcess() void XMLShapeImportHelper::shapeWithZIndexAdded( css::uno::Reference< css::drawing::XShape > const & xShape, sal_Int32 nZIndex ) { - if( mpImpl->mpGroupContext) - { - ZOrderHint aNewHint; - aNewHint.nIs = mpImpl->mpGroupContext->mnCurrentZ++; - aNewHint.nShould = nZIndex; - aNewHint.xShape = xShape; + if( !mpImpl->mpGroupContext) + return; - if( nZIndex == -1 ) - { - // don't care, so add to unsorted list - mpImpl->mpGroupContext->maUnsortedList.push_back(aNewHint); - } - else - { - // insert into sort list - mpImpl->mpGroupContext->maZOrderList.push_back(aNewHint); - } + ZOrderHint aNewHint; + aNewHint.nIs = mpImpl->mpGroupContext->mnCurrentZ++; + aNewHint.nShould = nZIndex; + aNewHint.xShape = xShape; + + if( nZIndex == -1 ) + { + // don't care, so add to unsorted list + mpImpl->mpGroupContext->maUnsortedList.push_back(aNewHint); + } + else + { + // insert into sort list + mpImpl->mpGroupContext->maZOrderList.push_back(aNewHint); } } diff --git a/xmloff/source/draw/xexptran.cxx b/xmloff/source/draw/xexptran.cxx index 49e003307242..556ac4f950b3 100644 --- a/xmloff/source/draw/xexptran.cxx +++ b/xmloff/source/draw/xexptran.cxx @@ -347,129 +347,129 @@ void SdXMLImExTransform2D::SetString(const OUString& rNew, const SvXMLUnitConver msString = rNew; maList.clear(); - if(!msString.isEmpty()) - { - const OUString aStr = msString; - const sal_Int32 nLen(aStr.getLength()); + if(msString.isEmpty()) + return; - const OUString aString_rotate( "rotate" ); - const OUString aString_scale( "scale" ); - const OUString aString_translate( "translate" ); - const OUString aString_skewX( "skewX" ); - const OUString aString_skewY( "skewY" ); - const OUString aString_matrix( "matrix" ); + const OUString aStr = msString; + const sal_Int32 nLen(aStr.getLength()); + + const OUString aString_rotate( "rotate" ); + const OUString aString_scale( "scale" ); + const OUString aString_translate( "translate" ); + const OUString aString_skewX( "skewX" ); + const OUString aString_skewY( "skewY" ); + const OUString aString_matrix( "matrix" ); - sal_Int32 nPos(0); + sal_Int32 nPos(0); - while(nPos < nLen) + while(nPos < nLen) + { + // skip spaces + Imp_SkipSpaces(aStr, nPos, nLen); + + // look for tag + if(nPos < nLen) { - // skip spaces - Imp_SkipSpaces(aStr, nPos, nLen); + if(nPos == aStr.indexOf(aString_rotate, nPos)) + { + double fValue(0.0); + nPos += 6; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); + if(fValue != 0.0) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DRotate>(fValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_scale, nPos)) + { + ::basegfx::B2DTuple aValue(1.0, 1.0); + nPos += 5; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + aValue.setX(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getX())); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY())); + + if(aValue.getX() != 1.0 || aValue.getY() != 1.0) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DScale>(aValue)); - // look for tag - if(nPos < nLen) + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_translate, nPos)) + { + ::basegfx::B2DTuple aValue; + nPos += 9; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + aValue.setX(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getX(), true)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + aValue.setY(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getY(), true)); + + if(!aValue.equalZero()) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DTranslate>(aValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_skewX, nPos)) + { + double fValue(0.0); + nPos += 5; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); + if(fValue != 0.0) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DSkewX>(fValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_skewY, nPos)) { - if(nPos == aStr.indexOf(aString_rotate, nPos)) - { - double fValue(0.0); - nPos += 6; - Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); - fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); - if(fValue != 0.0) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DRotate>(fValue)); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_scale, nPos)) - { - ::basegfx::B2DTuple aValue(1.0, 1.0); ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits