diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 09:02:30 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-08-06 10:28:06 +0200 |
commit | 1f1f7b89d20f86a46b14674ad3747cbdb899c6ca (patch) | |
tree | eb65761f2cf59d17f855313fb4cf7e3cc2bf5c0a /xmloff/source/draw | |
parent | 5633b217a6b5f6e1bb673d468fa8cb7ac66ceb54 (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'xmloff/source/draw')
-rw-r--r-- | xmloff/source/draw/XMLImageMapContext.cxx | 20 | ||||
-rw-r--r-- | xmloff/source/draw/XMLImageMapExport.cxx | 46 | ||||
-rw-r--r-- | xmloff/source/draw/XMLShapeStyleContext.cxx | 25 | ||||
-rw-r--r-- | xmloff/source/draw/animationexport.cxx | 158 | ||||
-rw-r--r-- | xmloff/source/draw/animationimport.cxx | 10 | ||||
-rw-r--r-- | xmloff/source/draw/descriptionimp.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/draw/eventimp.cxx | 40 | ||||
-rw-r--r-- | xmloff/source/draw/layerimp.cxx | 5 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 227 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlimp.cxx | 30 | ||||
-rw-r--r-- | xmloff/source/draw/shapeexport.cxx | 973 | ||||
-rw-r--r-- | xmloff/source/draw/shapeimport.cxx | 62 | ||||
-rw-r--r-- | xmloff/source/draw/xexptran.cxx | 534 | ||||
-rw-r--r-- | xmloff/source/draw/ximp3dobject.cxx | 150 | ||||
-rw-r--r-- | xmloff/source/draw/ximp3dscene.cxx | 188 | ||||
-rw-r--r-- | xmloff/source/draw/ximpcustomshape.cxx | 518 | ||||
-rw-r--r-- | xmloff/source/draw/ximppage.cxx | 190 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshap.cxx | 1532 | ||||
-rw-r--r-- | xmloff/source/draw/ximpshow.cxx | 190 | ||||
-rw-r--r-- | xmloff/source/draw/ximpstyl.cxx | 284 |
20 files changed, 2610 insertions, 2577 deletions
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); - 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)); - - 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)) - { - 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<ImpSdXMLExpTransObj2DSkewY>(fValue)); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_matrix, nPos)) - { - ::basegfx::B2DHomMatrix aValue; - - nPos += 6; - Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); - - // a - aValue.set(0, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 0))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // b - aValue.set(1, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 0))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // c - aValue.set(0, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 1))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // d - aValue.set(1, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 1))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // e - aValue.set(0, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 2), true)); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // f - aValue.set(1, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 2), true)); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - if(!aValue.isIdentity()) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DMatrix>(aValue)); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else - { - 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<ImpSdXMLExpTransObj2DSkewY>(fValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_matrix, nPos)) + { + ::basegfx::B2DHomMatrix aValue; + + nPos += 6; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + + // a + aValue.set(0, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 0))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // b + aValue.set(1, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 0))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // c + aValue.set(0, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 1))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // d + aValue.set(1, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 1))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // e + aValue.set(0, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 2), true)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // f + aValue.set(1, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 2), true)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + if(!aValue.isIdentity()) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj2DMatrix>(aValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else + { + nPos++; } } } @@ -754,162 +754,162 @@ void SdXMLImExTransform3D::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 aStr = msString; + const sal_Int32 nLen(aStr.getLength()); + + const OUString aString_rotatex( "rotatex" ); + const OUString aString_rotatey( "rotatey" ); + const OUString aString_rotatez( "rotatez" ); + const OUString aString_scale( "scale" ); + const OUString aString_translate( "translate" ); + const OUString aString_matrix( "matrix" ); - const OUString aString_rotatex( "rotatex" ); - const OUString aString_rotatey( "rotatey" ); - const OUString aString_rotatez( "rotatez" ); - const OUString aString_scale( "scale" ); - const OUString aString_translate( "translate" ); - const OUString aString_matrix( "matrix" ); + sal_Int32 nPos(0); - sal_Int32 nPos(0); + while(nPos < nLen) + { + // skip spaces + Imp_SkipSpaces(aStr, nPos, nLen); - while(nPos < nLen) + // look for tag + if(nPos < nLen) { - // skip spaces - Imp_SkipSpaces(aStr, nPos, nLen); + if(nPos == aStr.indexOf(aString_rotatex, nPos)) + { + double fValue(0.0); - // look for tag - if(nPos < nLen) + nPos += 7; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); + if(fValue != 0.0) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DRotateX>(basegfx::deg2rad(fValue))); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_rotatey, nPos)) + { + double fValue(0.0); + + nPos += 7; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); + if(fValue != 0.0) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DRotateY>(basegfx::deg2rad(fValue))); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_rotatez, nPos)) + { + double fValue(0.0); + + nPos += 7; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); + if(fValue != 0.0) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DRotateZ>(basegfx::deg2rad(fValue))); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_scale, nPos)) + { + ::basegfx::B3DTuple aValue(1.0, 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())); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ())); + + if(1.0 != aValue.getX() || 1.0 != aValue.getY() || 1.0 != aValue.getZ()) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DScale>(aValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_translate, nPos)) + { + ::basegfx::B3DTuple 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)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ(), true)); + + if(!aValue.equalZero()) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DTranslate>(aValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else if(nPos == aStr.indexOf(aString_matrix, nPos)) + { + ::basegfx::B3DHomMatrix aValue; + + nPos += 6; + Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); + + // a + aValue.set(0, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 0))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // b + aValue.set(1, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 0))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // c + aValue.set(2, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 0))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // d + aValue.set(0, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 1))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // e + aValue.set(1, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 1))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // f + aValue.set(2, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 1))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // g + aValue.set(0, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 2))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // h + aValue.set(1, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 2))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // i + aValue.set(2, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 2))); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // j + aValue.set(0, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 3), true)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // k + aValue.set(1, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 3), true)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + // l + aValue.set(2, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 3), true)); + Imp_SkipSpacesAndCommas(aStr, nPos, nLen); + + if(!aValue.isIdentity()) + maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DMatrix>(aValue)); + + Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); + } + else { - if(nPos == aStr.indexOf(aString_rotatex, nPos)) - { - double fValue(0.0); - - nPos += 7; - Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); - fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); - if(fValue != 0.0) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DRotateX>(basegfx::deg2rad(fValue))); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_rotatey, nPos)) - { - double fValue(0.0); - - nPos += 7; - Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); - fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); - if(fValue != 0.0) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DRotateY>(basegfx::deg2rad(fValue))); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_rotatez, nPos)) - { - double fValue(0.0); - - nPos += 7; - Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); - fValue = Imp_GetDoubleChar(aStr, nPos, nLen, rConv, fValue); - if(fValue != 0.0) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DRotateZ>(basegfx::deg2rad(fValue))); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_scale, nPos)) - { - ::basegfx::B3DTuple aValue(1.0, 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())); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ())); - - if(1.0 != aValue.getX() || 1.0 != aValue.getY() || 1.0 != aValue.getZ()) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DScale>(aValue)); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_translate, nPos)) - { - ::basegfx::B3DTuple 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)); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - aValue.setZ(Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.getZ(), true)); - - if(!aValue.equalZero()) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DTranslate>(aValue)); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else if(nPos == aStr.indexOf(aString_matrix, nPos)) - { - ::basegfx::B3DHomMatrix aValue; - - nPos += 6; - Imp_SkipSpacesAndOpeningBraces(aStr, nPos, nLen); - - // a - aValue.set(0, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 0))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // b - aValue.set(1, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 0))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // c - aValue.set(2, 0, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 0))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // d - aValue.set(0, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 1))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // e - aValue.set(1, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 1))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // f - aValue.set(2, 1, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 1))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // g - aValue.set(0, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 2))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // h - aValue.set(1, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 2))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // i - aValue.set(2, 2, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 2))); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // j - aValue.set(0, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(0, 3), true)); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // k - aValue.set(1, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(1, 3), true)); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - // l - aValue.set(2, 3, Imp_GetDoubleChar(aStr, nPos, nLen, rConv, aValue.get(2, 3), true)); - Imp_SkipSpacesAndCommas(aStr, nPos, nLen); - - if(!aValue.isIdentity()) - maList.push_back(std::make_shared<ImpSdXMLExpTransObj3DMatrix>(aValue)); - - Imp_SkipSpacesAndClosingBraces(aStr, nPos, nLen); - } - else - { - nPos++; - } + nPos++; } } } diff --git a/xmloff/source/draw/ximp3dobject.cxx b/xmloff/source/draw/ximp3dobject.cxx index 3c0ccec851de..22ffddffea7d 100644 --- a/xmloff/source/draw/ximp3dobject.cxx +++ b/xmloff/source/draw/ximp3dobject.cxx @@ -139,35 +139,35 @@ void SdXML3DCubeObjectShapeContext::StartElement(const uno::Reference< xml::sax: { // create shape AddShape( "com.sun.star.drawing.Shape3DCubeObject" ); - if(mxShape.is()) - { - // add, set style and properties from base shape - SetStyle(); - SdXML3DObjectContext::StartElement(xAttrList); + if(!mxShape.is()) + return; - // set local parameters on shape - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - // set parameters - drawing::Position3D aPosition3D; - drawing::Direction3D aDirection3D; + // add, set style and properties from base shape + SetStyle(); + SdXML3DObjectContext::StartElement(xAttrList); - // convert from min, max to size to be set - maMaxEdge = maMaxEdge - maMinEdge; + // set local parameters on shape + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(!xPropSet.is()) + return; - aPosition3D.PositionX = maMinEdge.getX(); - aPosition3D.PositionY = maMinEdge.getY(); - aPosition3D.PositionZ = maMinEdge.getZ(); + // set parameters + drawing::Position3D aPosition3D; + drawing::Direction3D aDirection3D; - aDirection3D.DirectionX = maMaxEdge.getX(); - aDirection3D.DirectionY = maMaxEdge.getY(); - aDirection3D.DirectionZ = maMaxEdge.getZ(); + // convert from min, max to size to be set + maMaxEdge = maMaxEdge - maMinEdge; - xPropSet->setPropertyValue("D3DPosition", uno::Any(aPosition3D)); - xPropSet->setPropertyValue("D3DSize", uno::Any(aDirection3D)); - } - } + aPosition3D.PositionX = maMinEdge.getX(); + aPosition3D.PositionY = maMinEdge.getY(); + aPosition3D.PositionZ = maMinEdge.getZ(); + + aDirection3D.DirectionX = maMaxEdge.getX(); + aDirection3D.DirectionY = maMaxEdge.getY(); + aDirection3D.DirectionZ = maMaxEdge.getZ(); + + xPropSet->setPropertyValue("D3DPosition", uno::Any(aPosition3D)); + xPropSet->setPropertyValue("D3DSize", uno::Any(aDirection3D)); } SdXML3DSphereObjectShapeContext::SdXML3DSphereObjectShapeContext( @@ -221,32 +221,32 @@ void SdXML3DSphereObjectShapeContext::StartElement(const uno::Reference< xml::sa { // create shape AddShape( "com.sun.star.drawing.Shape3DSphereObject" ); - if(mxShape.is()) - { - // add, set style and properties from base shape - SetStyle(); - SdXML3DObjectContext::StartElement(xAttrList); + if(!mxShape.is()) + return; - // set local parameters on shape - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - // set parameters - drawing::Position3D aPosition3D; - drawing::Direction3D aDirection3D; + // add, set style and properties from base shape + SetStyle(); + SdXML3DObjectContext::StartElement(xAttrList); - aPosition3D.PositionX = maCenter.getX(); - aPosition3D.PositionY = maCenter.getY(); - aPosition3D.PositionZ = maCenter.getZ(); + // set local parameters on shape + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(!xPropSet.is()) + return; - aDirection3D.DirectionX = maSphereSize.getX(); - aDirection3D.DirectionY = maSphereSize.getY(); - aDirection3D.DirectionZ = maSphereSize.getZ(); + // set parameters + drawing::Position3D aPosition3D; + drawing::Direction3D aDirection3D; - xPropSet->setPropertyValue("D3DPosition", uno::Any(aPosition3D)); - xPropSet->setPropertyValue("D3DSize", uno::Any(aDirection3D)); - } - } + aPosition3D.PositionX = maCenter.getX(); + aPosition3D.PositionY = maCenter.getY(); + aPosition3D.PositionZ = maCenter.getZ(); + + aDirection3D.DirectionX = maSphereSize.getX(); + aDirection3D.DirectionY = maSphereSize.getY(); + aDirection3D.DirectionZ = maSphereSize.getZ(); + + xPropSet->setPropertyValue("D3DPosition", uno::Any(aPosition3D)); + xPropSet->setPropertyValue("D3DSize", uno::Any(aDirection3D)); } SdXML3DPolygonBasedShapeContext::SdXML3DPolygonBasedShapeContext( @@ -290,39 +290,39 @@ void SdXML3DPolygonBasedShapeContext::StartElement(const uno::Reference< xml::sa { uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) + if(!xPropSet.is()) + return; + + // set parameters + if(!maPoints.isEmpty() && !maViewBox.isEmpty()) { - // set parameters - if(!maPoints.isEmpty() && !maViewBox.isEmpty()) - { - // import 2d tools::PolyPolygon from svg:d - basegfx::B2DPolyPolygon aPolyPolygon; + // import 2d tools::PolyPolygon from svg:d + basegfx::B2DPolyPolygon aPolyPolygon; - if(basegfx::utils::importFromSvgD(aPolyPolygon, maPoints, GetImport().needFixPositionAfterZ(), nullptr)) - { - // convert to 3D PolyPolygon - const basegfx::B3DPolyPolygon aB3DPolyPolygon( - basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon( - aPolyPolygon)); - - // convert to UNO API class PolyPolygonShape3D - drawing::PolyPolygonShape3D aPolyPolygon3D; - basegfx::utils::B3DPolyPolygonToUnoPolyPolygonShape3D( - aB3DPolyPolygon, - aPolyPolygon3D); - - // set polygon data - xPropSet->setPropertyValue("D3DPolyPolygon3D", uno::Any(aPolyPolygon3D)); - } - else - { - OSL_ENSURE(false, "Error on importing svg:d for 3D tools::PolyPolygon (!)"); - } + if(basegfx::utils::importFromSvgD(aPolyPolygon, maPoints, GetImport().needFixPositionAfterZ(), nullptr)) + { + // convert to 3D PolyPolygon + const basegfx::B3DPolyPolygon aB3DPolyPolygon( + basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon( + aPolyPolygon)); + + // convert to UNO API class PolyPolygonShape3D + drawing::PolyPolygonShape3D aPolyPolygon3D; + basegfx::utils::B3DPolyPolygonToUnoPolyPolygonShape3D( + aB3DPolyPolygon, + aPolyPolygon3D); + + // set polygon data + xPropSet->setPropertyValue("D3DPolyPolygon3D", uno::Any(aPolyPolygon3D)); + } + else + { + OSL_ENSURE(false, "Error on importing svg:d for 3D tools::PolyPolygon (!)"); } - - // call parent - SdXML3DObjectContext::StartElement(xAttrList); } + + // call parent + SdXML3DObjectContext::StartElement(xAttrList); } diff --git a/xmloff/source/draw/ximp3dscene.cxx b/xmloff/source/draw/ximp3dscene.cxx index 5fe0674c429a..55625f18a027 100644 --- a/xmloff/source/draw/ximp3dscene.cxx +++ b/xmloff/source/draw/ximp3dscene.cxx @@ -153,20 +153,20 @@ void SdXML3DSceneShapeContext::StartElement(const uno::Reference< xml::sax::XAtt void SdXML3DSceneShapeContext::EndElement() { - if(mxShape.is()) + if(!mxShape.is()) + return; + + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - setSceneAttributes( xPropSet ); - } + setSceneAttributes( xPropSet ); + } - if( mxChildren.is() ) - GetImport().GetShapeImport()->popGroupAndPostProcess(); + if( mxChildren.is() ) + GetImport().GetShapeImport()->popGroupAndPostProcess(); - // call parent - SdXMLShapeContext::EndElement(); - } + // call parent + SdXMLShapeContext::EndElement(); } SvXMLImportContextRef SdXML3DSceneShapeContext::CreateChildContext( sal_uInt16 nPrefix, @@ -235,98 +235,98 @@ SvXMLImportContext * SdXML3DSceneAttributesHelper::create3DLightContext( sal_uIn /** this should be called for each scene attribute */ void SdXML3DSceneAttributesHelper::processSceneAttribute( sal_uInt16 nPrefix, const OUString& rLocalName, const OUString& rValue ) { - if( XML_NAMESPACE_DR3D == nPrefix ) + if( XML_NAMESPACE_DR3D != nPrefix ) + return; + + if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) { - if( IsXMLToken( rLocalName, XML_TRANSFORM ) ) - { - SdXMLImExTransform3D aTransform(rValue, mrImport.GetMM100UnitConverter()); - if(aTransform.NeedsAction()) - mbSetTransform = aTransform.GetFullHomogenTransform(mxHomMat); - return; - } - else if( IsXMLToken( rLocalName, XML_VRP ) ) - { - ::basegfx::B3DVector aNewVec; - SvXMLUnitConverter::convertB3DVector(aNewVec, rValue); + SdXMLImExTransform3D aTransform(rValue, mrImport.GetMM100UnitConverter()); + if(aTransform.NeedsAction()) + mbSetTransform = aTransform.GetFullHomogenTransform(mxHomMat); + return; + } + else if( IsXMLToken( rLocalName, XML_VRP ) ) + { + ::basegfx::B3DVector aNewVec; + SvXMLUnitConverter::convertB3DVector(aNewVec, rValue); - if(aNewVec != maVRP) - { - maVRP = aNewVec; - mbVRPUsed = true; - } - return; - } - else if( IsXMLToken( rLocalName, XML_VPN ) ) + if(aNewVec != maVRP) { - ::basegfx::B3DVector aNewVec; - SvXMLUnitConverter::convertB3DVector(aNewVec, rValue); - - if(aNewVec != maVPN) - { - maVPN = aNewVec; - mbVPNUsed = true; - } - return; + maVRP = aNewVec; + mbVRPUsed = true; } - else if( IsXMLToken( rLocalName, XML_VUP ) ) - { - ::basegfx::B3DVector aNewVec; - SvXMLUnitConverter::convertB3DVector(aNewVec, rValue); + return; + } + else if( IsXMLToken( rLocalName, XML_VPN ) ) + { + ::basegfx::B3DVector aNewVec; + SvXMLUnitConverter::convertB3DVector(aNewVec, rValue); - if(aNewVec != maVUP) - { - maVUP = aNewVec; - mbVUPUsed = true; - } - return; - } - else if( IsXMLToken( rLocalName, XML_PROJECTION ) ) + if(aNewVec != maVPN) { - if( IsXMLToken( rValue, XML_PARALLEL ) ) - mxPrjMode = drawing::ProjectionMode_PARALLEL; - else - mxPrjMode = drawing::ProjectionMode_PERSPECTIVE; - return; + maVPN = aNewVec; + mbVPNUsed = true; } - else if( IsXMLToken( rLocalName, XML_DISTANCE ) ) - { - mrImport.GetMM100UnitConverter().convertMeasureToCore(mnDistance, - rValue); - return; - } - else if( IsXMLToken( rLocalName, XML_FOCAL_LENGTH ) ) - { - mrImport.GetMM100UnitConverter().convertMeasureToCore(mnFocalLength, - rValue); - return; - } - else if( IsXMLToken( rLocalName, XML_SHADOW_SLANT ) ) - { - ::sax::Converter::convertNumber(mnShadowSlant, rValue); - return; - } - else if( IsXMLToken( rLocalName, XML_SHADE_MODE ) ) - { - if( IsXMLToken( rValue, XML_FLAT ) ) - mxShadeMode = drawing::ShadeMode_FLAT; - else if( IsXMLToken( rValue, XML_PHONG ) ) - mxShadeMode = drawing::ShadeMode_PHONG; - else if( IsXMLToken( rValue, XML_GOURAUD ) ) - mxShadeMode = drawing::ShadeMode_SMOOTH; - else - mxShadeMode = drawing::ShadeMode_DRAFT; - return; - } - else if( IsXMLToken( rLocalName, XML_AMBIENT_COLOR ) ) - { - ::sax::Converter::convertColor(maAmbientColor, rValue); - return; - } - else if( IsXMLToken( rLocalName, XML_LIGHTING_MODE ) ) + return; + } + else if( IsXMLToken( rLocalName, XML_VUP ) ) + { + ::basegfx::B3DVector aNewVec; + SvXMLUnitConverter::convertB3DVector(aNewVec, rValue); + + if(aNewVec != maVUP) { - (void)::sax::Converter::convertBool(mbLightingMode, rValue); - return; + maVUP = aNewVec; + mbVUPUsed = true; } + return; + } + else if( IsXMLToken( rLocalName, XML_PROJECTION ) ) + { + if( IsXMLToken( rValue, XML_PARALLEL ) ) + mxPrjMode = drawing::ProjectionMode_PARALLEL; + else + mxPrjMode = drawing::ProjectionMode_PERSPECTIVE; + return; + } + else if( IsXMLToken( rLocalName, XML_DISTANCE ) ) + { + mrImport.GetMM100UnitConverter().convertMeasureToCore(mnDistance, + rValue); + return; + } + else if( IsXMLToken( rLocalName, XML_FOCAL_LENGTH ) ) + { + mrImport.GetMM100UnitConverter().convertMeasureToCore(mnFocalLength, + rValue); + return; + } + else if( IsXMLToken( rLocalName, XML_SHADOW_SLANT ) ) + { + ::sax::Converter::convertNumber(mnShadowSlant, rValue); + return; + } + else if( IsXMLToken( rLocalName, XML_SHADE_MODE ) ) + { + if( IsXMLToken( rValue, XML_FLAT ) ) + mxShadeMode = drawing::ShadeMode_FLAT; + else if( IsXMLToken( rValue, XML_PHONG ) ) + mxShadeMode = drawing::ShadeMode_PHONG; + else if( IsXMLToken( rValue, XML_GOURAUD ) ) + mxShadeMode = drawing::ShadeMode_SMOOTH; + else + mxShadeMode = drawing::ShadeMode_DRAFT; + return; + } + else if( IsXMLToken( rLocalName, XML_AMBIENT_COLOR ) ) + { + ::sax::Converter::convertColor(maAmbientColor, rValue); + return; + } + else if( IsXMLToken( rLocalName, XML_LIGHTING_MODE ) ) + { + (void)::sax::Converter::convertBool(mbLightingMode, rValue); + return; } } diff --git a/xmloff/source/draw/ximpcustomshape.cxx b/xmloff/source/draw/ximpcustomshape.cxx index e7b1ba31211e..b265671baf9a 100644 --- a/xmloff/source/draw/ximpcustomshape.cxx +++ b/xmloff/source/draw/ximpcustomshape.cxx @@ -139,18 +139,18 @@ static void GetDoublePercentage( std::vector< css::beans::PropertyValue >& rDest { sal_Int16 const eSrcUnit = ::sax::Converter::GetUnitFromString( rValue, util::MeasureUnit::MM_100TH); - if (util::MeasureUnit::PERCENT == eSrcUnit) + if (util::MeasureUnit::PERCENT != eSrcUnit) + return; + + rtl_math_ConversionStatus eStatus; + double fAttrDouble = ::rtl::math::stringToDouble( rValue, + '.', ',', &eStatus ); + if ( eStatus == rtl_math_ConversionStatus_Ok ) { - rtl_math_ConversionStatus eStatus; - double fAttrDouble = ::rtl::math::stringToDouble( rValue, - '.', ',', &eStatus ); - if ( eStatus == rtl_math_ConversionStatus_Ok ) - { - beans::PropertyValue aProp; - aProp.Name = EASGet( eDestProp ); - aProp.Value <<= fAttrDouble; - rDest.push_back( aProp ); - } + beans::PropertyValue aProp; + aProp.Name = EASGet( eDestProp ); + aProp.Value <<= fAttrDouble; + rDest.push_back( aProp ); } } @@ -478,25 +478,25 @@ static void GetSizeSequence( std::vector< css::beans::PropertyValue >& rDest, } while ( nIndex >= 0 ); - if ( !vNum.empty() ) - { - uno::Sequence< awt::Size > aSizeSeq((vNum.size() + 1) / 2); - std::vector< sal_Int32 >::const_iterator aIter = vNum.begin(); - std::vector< sal_Int32 >::const_iterator aEnd = vNum.end(); - awt::Size* pValues = aSizeSeq.getArray(); - - while ( aIter != aEnd ) { - pValues->Width = *aIter++; - if ( aIter != aEnd ) - pValues->Height = *aIter++; - pValues ++; - } + if ( vNum.empty() ) + return; - beans::PropertyValue aProp; - aProp.Name = EASGet( eDestProp ); - aProp.Value <<= aSizeSeq; - rDest.push_back( aProp ); + uno::Sequence< awt::Size > aSizeSeq((vNum.size() + 1) / 2); + std::vector< sal_Int32 >::const_iterator aIter = vNum.begin(); + std::vector< sal_Int32 >::const_iterator aEnd = vNum.end(); + awt::Size* pValues = aSizeSeq.getArray(); + + while ( aIter != aEnd ) { + pValues->Width = *aIter++; + if ( aIter != aEnd ) + pValues->Height = *aIter++; + pValues ++; } + + beans::PropertyValue aProp; + aProp.Name = EASGet( eDestProp ); + aProp.Value <<= aSizeSeq; + rDest.push_back( aProp ); } static void GetEnhancedParameter( std::vector< css::beans::PropertyValue >& rDest, // e.g. draw:handle-position @@ -862,258 +862,258 @@ static void GetAdjustmentValues( std::vector< css::beans::PropertyValue >& rDest void XMLEnhancedCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAttributeList >& xAttrList ) { sal_Int16 nLength = xAttrList->getLength(); - if ( nLength ) + if ( !nLength ) + return; + + sal_Int32 nAttrNumber; + for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) { - sal_Int32 nAttrNumber; - for( sal_Int16 nAttr = 0; nAttr < nLength; nAttr++ ) - { - OUString aLocalName; - const OUString& rValue = xAttrList->getValueByIndex( nAttr ); - /* sven fixme, this must be checked! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); + OUString aLocalName; + const OUString& rValue = xAttrList->getValueByIndex( nAttr ); + /* sven fixme, this must be checked! sal_uInt16 nPrefix = */ GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( nAttr ), &aLocalName ); - switch( EASGet( aLocalName ) ) + switch( EASGet( aLocalName ) ) + { + case EAS_type : + GetString( mrCustomShapeGeometry, rValue, EAS_Type ); + break; + case EAS_mirror_horizontal : + GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredX ); + break; + case EAS_mirror_vertical : + GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredY ); + break; + case EAS_viewBox : { - case EAS_type : - GetString( mrCustomShapeGeometry, rValue, EAS_Type ); - break; - case EAS_mirror_horizontal : - GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredX ); - break; - case EAS_mirror_vertical : - GetBool( mrCustomShapeGeometry, rValue, EAS_MirroredY ); - break; - case EAS_viewBox : - { - SdXMLImExViewBox aViewBox( rValue, GetImport().GetMM100UnitConverter() ); - awt::Rectangle aRect( aViewBox.GetX(), aViewBox.GetY(), aViewBox.GetWidth(), aViewBox.GetHeight() ); - beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_ViewBox ); - aProp.Value <<= aRect; - mrCustomShapeGeometry.push_back( aProp ); - } - break; - case EAS_sub_view_size: - GetSizeSequence( maPath, rValue, EAS_SubViewSize ); - break; - case EAS_text_rotate_angle : - GetDouble( mrCustomShapeGeometry, rValue, EAS_TextRotateAngle ); - break; - case EAS_extrusion_allowed : - GetBool( maPath, rValue, EAS_ExtrusionAllowed ); - break; - case EAS_text_path_allowed : - GetBool( maPath, rValue, EAS_TextPathAllowed ); - break; - case EAS_concentric_gradient_fill_allowed : - GetBool( maPath, rValue, EAS_ConcentricGradientFillAllowed ); - break; - case EAS_extrusion : - GetBool( maExtrusion, rValue, EAS_Extrusion ); - break; - case EAS_extrusion_brightness : - GetDoublePercentage( maExtrusion, rValue, EAS_Brightness ); - break; - case EAS_extrusion_depth : + SdXMLImExViewBox aViewBox( rValue, GetImport().GetMM100UnitConverter() ); + awt::Rectangle aRect( aViewBox.GetX(), aViewBox.GetY(), aViewBox.GetWidth(), aViewBox.GetHeight() ); + beans::PropertyValue aProp; + aProp.Name = EASGet( EAS_ViewBox ); + aProp.Value <<= aRect; + mrCustomShapeGeometry.push_back( aProp ); + } + break; + case EAS_sub_view_size: + GetSizeSequence( maPath, rValue, EAS_SubViewSize ); + break; + case EAS_text_rotate_angle : + GetDouble( mrCustomShapeGeometry, rValue, EAS_TextRotateAngle ); + break; + case EAS_extrusion_allowed : + GetBool( maPath, rValue, EAS_ExtrusionAllowed ); + break; + case EAS_text_path_allowed : + GetBool( maPath, rValue, EAS_TextPathAllowed ); + break; + case EAS_concentric_gradient_fill_allowed : + GetBool( maPath, rValue, EAS_ConcentricGradientFillAllowed ); + break; + case EAS_extrusion : + GetBool( maExtrusion, rValue, EAS_Extrusion ); + break; + case EAS_extrusion_brightness : + GetDoublePercentage( maExtrusion, rValue, EAS_Brightness ); + break; + case EAS_extrusion_depth : + { + sal_Int32 nIndex = 0; + css::drawing::EnhancedCustomShapeParameterPair aParameterPair; + css::drawing::EnhancedCustomShapeParameter& rDepth = aParameterPair.First; + if ( GetNextParameter( rDepth, nIndex, rValue ) ) { - sal_Int32 nIndex = 0; - css::drawing::EnhancedCustomShapeParameterPair aParameterPair; - css::drawing::EnhancedCustomShapeParameter& rDepth = aParameterPair.First; - if ( GetNextParameter( rDepth, nIndex, rValue ) ) + css::drawing::EnhancedCustomShapeParameter& rFraction = aParameterPair.Second; + // try to catch the unit for the depth + sal_Int16 const eSrcUnit( + ::sax::Converter::GetUnitFromString( + rValue, util::MeasureUnit::MM_100TH)); + + OUStringBuffer aUnitStr; + double fFactor = ::sax::Converter::GetConversionFactor( + aUnitStr, util::MeasureUnit::MM_100TH, eSrcUnit); + if ( ( fFactor != 1.0 ) && ( fFactor != 0.0 ) ) { - css::drawing::EnhancedCustomShapeParameter& rFraction = aParameterPair.Second; - // try to catch the unit for the depth - sal_Int16 const eSrcUnit( - ::sax::Converter::GetUnitFromString( - rValue, util::MeasureUnit::MM_100TH)); - - OUStringBuffer aUnitStr; - double fFactor = ::sax::Converter::GetConversionFactor( - aUnitStr, util::MeasureUnit::MM_100TH, eSrcUnit); - if ( ( fFactor != 1.0 ) && ( fFactor != 0.0 ) ) - { - double fDepth(0.0); - if ( rDepth.Value >>= fDepth ) - { - fDepth /= fFactor; - rDepth.Value <<= fDepth; - } - } - if ( rValue.matchIgnoreAsciiCase( aUnitStr.toString(), nIndex ) ) - nIndex += aUnitStr.getLength(); - - // skipping white spaces - while( ( nIndex < rValue.getLength() ) && rValue[ nIndex ] == ' ' ) - nIndex++; - - if ( GetNextParameter( rFraction, nIndex, rValue ) ) + double fDepth(0.0); + if ( rDepth.Value >>= fDepth ) { - beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_Depth ); - aProp.Value <<= aParameterPair; - maExtrusion.push_back( aProp ); + fDepth /= fFactor; + rDepth.Value <<= fDepth; } } - } - break; - case EAS_extrusion_diffusion : - GetDoublePercentage( maExtrusion, rValue, EAS_Diffusion ); - break; - case EAS_extrusion_number_of_line_segments : - GetInt32( maExtrusion, rValue, EAS_NumberOfLineSegments ); - break; - case EAS_extrusion_light_face : - GetBool( maExtrusion, rValue, EAS_LightFace ); - break; - case EAS_extrusion_first_light_harsh : - GetBool( maExtrusion, rValue, EAS_FirstLightHarsh ); - break; - case EAS_extrusion_second_light_harsh : - GetBool( maExtrusion, rValue, EAS_SecondLightHarsh ); - break; - case EAS_extrusion_first_light_level : - GetDoublePercentage( maExtrusion, rValue, EAS_FirstLightLevel ); - break; - case EAS_extrusion_second_light_level : - GetDoublePercentage( maExtrusion, rValue, EAS_SecondLightLevel ); - break; - case EAS_extrusion_first_light_direction : - GetB3DVector( maExtrusion, rValue, EAS_FirstLightDirection ); - break; - case EAS_extrusion_second_light_direction : - GetB3DVector( maExtrusion, rValue, EAS_SecondLightDirection ); - break; - case EAS_extrusion_metal : - GetBool( maExtrusion, rValue, EAS_Metal ); - break; - case EAS_shade_mode : - { - drawing::ShadeMode eShadeMode( drawing::ShadeMode_FLAT ); - if( IsXMLToken( rValue, XML_PHONG ) ) - eShadeMode = drawing::ShadeMode_PHONG; - else if ( IsXMLToken( rValue, XML_GOURAUD ) ) - eShadeMode = drawing::ShadeMode_SMOOTH; - else if ( IsXMLToken( rValue, XML_DRAFT ) ) - eShadeMode = drawing::ShadeMode_DRAFT; + if ( rValue.matchIgnoreAsciiCase( aUnitStr.toString(), nIndex ) ) + nIndex += aUnitStr.getLength(); - beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_ShadeMode ); - aProp.Value <<= eShadeMode; - maExtrusion.push_back( aProp ); - } - break; - case EAS_extrusion_rotation_angle : - GetEnhancedParameterPair( maExtrusion, rValue, EAS_RotateAngle ); - break; - case EAS_extrusion_rotation_center : - GetB3DVector( maExtrusion, rValue, EAS_RotationCenter ); - break; - case EAS_extrusion_shininess : - GetDoublePercentage( maExtrusion, rValue, EAS_Shininess ); - break; - case EAS_extrusion_skew : - GetEnhancedParameterPair( maExtrusion, rValue, EAS_Skew ); - break; - case EAS_extrusion_specularity : - GetDoublePercentage( maExtrusion, rValue, EAS_Specularity ); - break; - case EAS_projection : - { - drawing::ProjectionMode eProjectionMode( drawing::ProjectionMode_PERSPECTIVE ); - if( IsXMLToken( rValue, XML_PARALLEL ) ) - eProjectionMode = drawing::ProjectionMode_PARALLEL; + // skipping white spaces + while( ( nIndex < rValue.getLength() ) && rValue[ nIndex ] == ' ' ) + nIndex++; - beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_ProjectionMode ); - aProp.Value <<= eProjectionMode; - maExtrusion.push_back( aProp ); - } - break; - case EAS_extrusion_viewpoint : - GetPosition3D( maExtrusion, rValue, EAS_ViewPoint, mrUnitConverter ); - break; - case EAS_extrusion_origin : - GetEnhancedParameterPair( maExtrusion, rValue, EAS_Origin ); - break; - case EAS_extrusion_color : - GetBool( maExtrusion, rValue, EAS_Color ); - break; - case EAS_enhanced_path : - GetEnhancedPath( maPath, rValue ); - break; - case EAS_path_stretchpoint_x : - { - if (::sax::Converter::convertNumber(nAttrNumber, rValue)) - { - beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_StretchX ); - aProp.Value <<= nAttrNumber; - maPath.push_back( aProp ); - } - } - break; - case EAS_path_stretchpoint_y : - { - if (::sax::Converter::convertNumber(nAttrNumber, rValue)) + if ( GetNextParameter( rFraction, nIndex, rValue ) ) { beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_StretchY ); - aProp.Value <<= nAttrNumber; - maPath.push_back( aProp ); + aProp.Name = EASGet( EAS_Depth ); + aProp.Value <<= aParameterPair; + maExtrusion.push_back( aProp ); } } - break; - case EAS_text_areas : - GetEnhancedRectangleSequence( maPath, rValue, EAS_TextFrames ); - break; - case EAS_glue_points : - { - sal_Int32 i, nPairs = GetEnhancedParameterPairSequence( maPath, rValue, EAS_GluePoints ); - GetImport().GetShapeImport()->moveGluePointMapping( mrxShape, nPairs ); - for ( i = 0; i < nPairs; i++ ) - GetImport().GetShapeImport()->addGluePointMapping( mrxShape, i + 4, i + 4 ); - } - break; - case EAS_glue_point_type : - GetEnum( maPath, rValue, EAS_GluePointType, *aXML_GluePointEnumMap ); - break; - case EAS_glue_point_leaving_directions : - GetDoubleSequence( maPath, rValue, EAS_GluePointLeavingDirections ); - break; - case EAS_text_path : - GetBool( maTextPath, rValue, EAS_TextPath ); - break; - case EAS_text_path_mode : + } + break; + case EAS_extrusion_diffusion : + GetDoublePercentage( maExtrusion, rValue, EAS_Diffusion ); + break; + case EAS_extrusion_number_of_line_segments : + GetInt32( maExtrusion, rValue, EAS_NumberOfLineSegments ); + break; + case EAS_extrusion_light_face : + GetBool( maExtrusion, rValue, EAS_LightFace ); + break; + case EAS_extrusion_first_light_harsh : + GetBool( maExtrusion, rValue, EAS_FirstLightHarsh ); + break; + case EAS_extrusion_second_light_harsh : + GetBool( maExtrusion, rValue, EAS_SecondLightHarsh ); + break; + case EAS_extrusion_first_light_level : + GetDoublePercentage( maExtrusion, rValue, EAS_FirstLightLevel ); + break; + case EAS_extrusion_second_light_level : + GetDoublePercentage( maExtrusion, rValue, EAS_SecondLightLevel ); + break; + case EAS_extrusion_first_light_direction : + GetB3DVector( maExtrusion, rValue, EAS_FirstLightDirection ); + break; + case EAS_extrusion_second_light_direction : + GetB3DVector( maExtrusion, rValue, EAS_SecondLightDirection ); + break; + case EAS_extrusion_metal : + GetBool( maExtrusion, rValue, EAS_Metal ); + break; + case EAS_shade_mode : + { + drawing::ShadeMode eShadeMode( drawing::ShadeMode_FLAT ); + if( IsXMLToken( rValue, XML_PHONG ) ) + eShadeMode = drawing::ShadeMode_PHONG; + else if ( IsXMLToken( rValue, XML_GOURAUD ) ) + eShadeMode = drawing::ShadeMode_SMOOTH; + else if ( IsXMLToken( rValue, XML_DRAFT ) ) + eShadeMode = drawing::ShadeMode_DRAFT; + + beans::PropertyValue aProp; + aProp.Name = EASGet( EAS_ShadeMode ); + aProp.Value <<= eShadeMode; + maExtrusion.push_back( aProp ); + } + break; + case EAS_extrusion_rotation_angle : + GetEnhancedParameterPair( maExtrusion, rValue, EAS_RotateAngle ); + break; + case EAS_extrusion_rotation_center : + GetB3DVector( maExtrusion, rValue, EAS_RotationCenter ); + break; + case EAS_extrusion_shininess : + GetDoublePercentage( maExtrusion, rValue, EAS_Shininess ); + break; + case EAS_extrusion_skew : + GetEnhancedParameterPair( maExtrusion, rValue, EAS_Skew ); + break; + case EAS_extrusion_specularity : + GetDoublePercentage( maExtrusion, rValue, EAS_Specularity ); + break; + case EAS_projection : + { + drawing::ProjectionMode eProjectionMode( drawing::ProjectionMode_PERSPECTIVE ); + if( IsXMLToken( rValue, XML_PARALLEL ) ) + eProjectionMode = drawing::ProjectionMode_PARALLEL; + + beans::PropertyValue aProp; + aProp.Name = EASGet( EAS_ProjectionMode ); + aProp.Value <<= eProjectionMode; + maExtrusion.push_back( aProp ); + } + break; + case EAS_extrusion_viewpoint : + GetPosition3D( maExtrusion, rValue, EAS_ViewPoint, mrUnitConverter ); + break; + case EAS_extrusion_origin : + GetEnhancedParameterPair( maExtrusion, rValue, EAS_Origin ); + break; + case EAS_extrusion_color : + GetBool( maExtrusion, rValue, EAS_Color ); + break; + case EAS_enhanced_path : + GetEnhancedPath( maPath, rValue ); + break; + case EAS_path_stretchpoint_x : + { + if (::sax::Converter::convertNumber(nAttrNumber, rValue)) { - css::drawing::EnhancedCustomShapeTextPathMode eTextPathMode( css::drawing::EnhancedCustomShapeTextPathMode_NORMAL ); - if( IsXMLToken( rValue, XML_PATH ) ) - eTextPathMode = css::drawing::EnhancedCustomShapeTextPathMode_PATH; - else if ( IsXMLToken( rValue, XML_SHAPE ) ) - eTextPathMode = css::drawing::EnhancedCustomShapeTextPathMode_SHAPE; - beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_TextPathMode ); - aProp.Value <<= eTextPathMode; - maTextPath.push_back( aProp ); + aProp.Name = EASGet( EAS_StretchX ); + aProp.Value <<= nAttrNumber; + maPath.push_back( aProp ); } - break; - case EAS_text_path_scale : + } + break; + case EAS_path_stretchpoint_y : + { + if (::sax::Converter::convertNumber(nAttrNumber, rValue)) { - bool bScaleX = IsXMLToken( rValue, XML_SHAPE ); beans::PropertyValue aProp; - aProp.Name = EASGet( EAS_ScaleX ); - aProp.Value <<= bScaleX; - maTextPath.push_back( aProp ); + aProp.Name = EASGet( EAS_StretchY ); + aProp.Value <<= nAttrNumber; + maPath.push_back( aProp ); } - break; - case EAS_text_path_same_letter_heights : - GetBool( maTextPath, rValue, EAS_SameLetterHeights ); - break; - case EAS_modifiers : - GetAdjustmentValues( mrCustomShapeGeometry, rValue ); - break; - default: - break; } + break; + case EAS_text_areas : + GetEnhancedRectangleSequence( maPath, rValue, EAS_TextFrames ); + break; + case EAS_glue_points : + { + sal_Int32 i, nPairs = GetEnhancedParameterPairSequence( maPath, rValue, EAS_GluePoints ); + GetImport().GetShapeImport()->moveGluePointMapping( mrxShape, nPairs ); + for ( i = 0; i < nPairs; i++ ) + GetImport().GetShapeImport()->addGluePointMapping( mrxShape, i + 4, i + 4 ); + } + break; + case EAS_glue_point_type : + GetEnum( maPath, rValue, EAS_GluePointType, *aXML_GluePointEnumMap ); + break; + case EAS_glue_point_leaving_directions : + GetDoubleSequence( maPath, rValue, EAS_GluePointLeavingDirections ); + break; + case EAS_text_path : + GetBool( maTextPath, rValue, EAS_TextPath ); + break; + case EAS_text_path_mode : + { + css::drawing::EnhancedCustomShapeTextPathMode eTextPathMode( css::drawing::EnhancedCustomShapeTextPathMode_NORMAL ); + if( IsXMLToken( rValue, XML_PATH ) ) + eTextPathMode = css::drawing::EnhancedCustomShapeTextPathMode_PATH; + else if ( IsXMLToken( rValue, XML_SHAPE ) ) + eTextPathMode = css::drawing::EnhancedCustomShapeTextPathMode_SHAPE; + + beans::PropertyValue aProp; + aProp.Name = EASGet( EAS_TextPathMode ); + aProp.Value <<= eTextPathMode; + maTextPath.push_back( aProp ); + } + break; + case EAS_text_path_scale : + { + bool bScaleX = IsXMLToken( rValue, XML_SHAPE ); + beans::PropertyValue aProp; + aProp.Name = EASGet( EAS_ScaleX ); + aProp.Value <<= bScaleX; + maTextPath.push_back( aProp ); + } + break; + case EAS_text_path_same_letter_heights : + GetBool( maTextPath, rValue, EAS_SameLetterHeights ); + break; + case EAS_modifiers : + GetAdjustmentValues( mrCustomShapeGeometry, rValue ); + break; + default: + break; } } } diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index e803eda3a8f5..a089f45b03f3 100644 --- a/xmloff/source/draw/ximppage.cxx +++ b/xmloff/source/draw/ximppage.cxx @@ -391,100 +391,100 @@ void SdXMLGenericPageContext::endFastElement(sal_Int32 ) void SdXMLGenericPageContext::SetStyle( OUString const & rStyleName ) { // set PageProperties? - if(!rStyleName.isEmpty()) + if(rStyleName.isEmpty()) + return; + + try { - try + const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetAutoStylesContext(); + + if (const SdXMLStylesContext* pStyles = dynamic_cast<const SdXMLStylesContext *>(pContext)) { - const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetAutoStylesContext(); + const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext( + XmlStyleFamily::SD_DRAWINGPAGE_ID, rStyleName); - if (const SdXMLStylesContext* pStyles = dynamic_cast<const SdXMLStylesContext *>(pContext)) + if (const XMLPropStyleContext* pPropStyle = dynamic_cast<const XMLPropStyleContext*>(pStyle)) { - const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext( - XmlStyleFamily::SD_DRAWINGPAGE_ID, rStyleName); - - if (const XMLPropStyleContext* pPropStyle = dynamic_cast<const XMLPropStyleContext*>(pStyle)) + Reference <beans::XPropertySet> xPropSet1(mxShapes, uno::UNO_QUERY); + if(xPropSet1.is()) { - Reference <beans::XPropertySet> xPropSet1(mxShapes, uno::UNO_QUERY); - if(xPropSet1.is()) - { - Reference< beans::XPropertySet > xPropSet( xPropSet1 ); - Reference< beans::XPropertySet > xBackgroundSet; + Reference< beans::XPropertySet > xPropSet( xPropSet1 ); + Reference< beans::XPropertySet > xBackgroundSet; - const OUString aBackground("Background"); - if( xPropSet1->getPropertySetInfo()->hasPropertyByName( aBackground ) ) + const OUString aBackground("Background"); + if( xPropSet1->getPropertySetInfo()->hasPropertyByName( aBackground ) ) + { + Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() ); + if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) ) { - Reference< beans::XPropertySetInfo > xInfo( xPropSet1->getPropertySetInfo() ); - if( xInfo.is() && xInfo->hasPropertyByName( aBackground ) ) + Reference< lang::XMultiServiceFactory > xServiceFact(GetSdImport().GetModel(), uno::UNO_QUERY); + if(xServiceFact.is()) { - Reference< lang::XMultiServiceFactory > xServiceFact(GetSdImport().GetModel(), uno::UNO_QUERY); - if(xServiceFact.is()) - { - xBackgroundSet.set(xServiceFact->createInstance("com.sun.star.drawing.Background"), UNO_QUERY); - } + xBackgroundSet.set(xServiceFact->createInstance("com.sun.star.drawing.Background"), UNO_QUERY); } - - if( xBackgroundSet.is() ) - xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xBackgroundSet ); } - if(xPropSet.is()) - { - const_cast<XMLPropStyleContext*>(pPropStyle)->FillPropertySet(xPropSet); + if( xBackgroundSet.is() ) + xPropSet = PropertySetMerger_CreateInstance( xPropSet1, xBackgroundSet ); + } - if( xBackgroundSet.is() ) - xPropSet1->setPropertyValue( aBackground, uno::makeAny( xBackgroundSet ) ); - } + if(xPropSet.is()) + { + const_cast<XMLPropStyleContext*>(pPropStyle)->FillPropertySet(xPropSet); + + if( xBackgroundSet.is() ) + xPropSet1->setPropertyValue( aBackground, uno::makeAny( xBackgroundSet ) ); } } } } - catch (const uno::Exception&) - { - OSL_FAIL( "SdXMLGenericPageContext::SetStyle(): uno::Exception caught!" ); - } + } + catch (const uno::Exception&) + { + OSL_FAIL( "SdXMLGenericPageContext::SetStyle(): uno::Exception caught!" ); } } void SdXMLGenericPageContext::SetLayout() { // set PresentationPageLayout? - if(GetSdImport().IsImpress() && !maPageLayoutName.isEmpty()) - { - sal_Int32 nType = -1; + if(!(GetSdImport().IsImpress() && !maPageLayoutName.isEmpty())) + return; - const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetStylesContext(); + sal_Int32 nType = -1; - if (const SdXMLStylesContext* pStyles = dynamic_cast<const SdXMLStylesContext *>(pContext)) - { - const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext( XmlStyleFamily::SD_PRESENTATIONPAGELAYOUT_ID, maPageLayoutName); + const SvXMLImportContext* pContext = GetSdImport().GetShapeImport()->GetStylesContext(); - if (const SdXMLPresentationPageLayoutContext* pLayout = dynamic_cast<const SdXMLPresentationPageLayoutContext*>(pStyle)) - { - nType = pLayout->GetTypeId(); - } - } + if (const SdXMLStylesContext* pStyles = dynamic_cast<const SdXMLStylesContext *>(pContext)) + { + const SvXMLStyleContext* pStyle = pStyles->FindStyleChildContext( XmlStyleFamily::SD_PRESENTATIONPAGELAYOUT_ID, maPageLayoutName); - if( -1 == nType ) + if (const SdXMLPresentationPageLayoutContext* pLayout = dynamic_cast<const SdXMLPresentationPageLayoutContext*>(pStyle)) { - Reference< container::XNameAccess > xPageLayouts( GetSdImport().getPageLayouts() ); - if( xPageLayouts.is() ) - { - if( xPageLayouts->hasByName( maPageLayoutName ) ) - xPageLayouts->getByName( maPageLayoutName ) >>= nType; - } + nType = pLayout->GetTypeId(); + } + } + if( -1 == nType ) + { + Reference< container::XNameAccess > xPageLayouts( GetSdImport().getPageLayouts() ); + if( xPageLayouts.is() ) + { + if( xPageLayouts->hasByName( maPageLayoutName ) ) + xPageLayouts->getByName( maPageLayoutName ) >>= nType; } - if( -1 != nType ) + } + + if( -1 != nType ) + { + Reference <beans::XPropertySet> xPropSet(mxShapes, uno::UNO_QUERY); + if(xPropSet.is()) { - Reference <beans::XPropertySet> xPropSet(mxShapes, uno::UNO_QUERY); - if(xPropSet.is()) - { - OUString aPropName("Layout"); - Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() ); - if( xInfo.is() && xInfo->hasPropertyByName( aPropName ) ) - xPropSet->setPropertyValue(aPropName, uno::makeAny( static_cast<sal_Int16>(nType) ) ); - } + OUString aPropName("Layout"); + Reference< beans::XPropertySetInfo > xInfo( xPropSet->getPropertySetInfo() ); + if( xInfo.is() && xInfo->hasPropertyByName( aPropName ) ) + xPropSet->setPropertyValue(aPropName, uno::makeAny( static_cast<sal_Int16>(nType) ) ); } } } @@ -509,39 +509,40 @@ void SdXMLGenericPageContext::DeleteAllShapes() void SdXMLGenericPageContext::SetPageMaster( OUString const & rsPageMasterName ) { - if (GetSdImport().GetShapeImport()->GetStylesContext()) - { - // look for PageMaster with this name + if (!GetSdImport().GetShapeImport()->GetStylesContext()) + return; - // #80012# GetStylesContext() replaced with GetAutoStylesContext() - const SvXMLStylesContext* pAutoStyles = GetSdImport().GetShapeImport()->GetAutoStylesContext(); + // look for PageMaster with this name - const SvXMLStyleContext* pStyle = pAutoStyles ? pAutoStyles->FindStyleChildContext(XmlStyleFamily::SD_PAGEMASTERCONEXT_ID, rsPageMasterName) : nullptr; + // #80012# GetStylesContext() replaced with GetAutoStylesContext() + const SvXMLStylesContext* pAutoStyles = GetSdImport().GetShapeImport()->GetAutoStylesContext(); - if (const SdXMLPageMasterContext* pPageMaster = dynamic_cast<const SdXMLPageMasterContext*>(pStyle)) - { - const SdXMLPageMasterStyleContext* pPageMasterContext = pPageMaster->GetPageMasterStyle(); + const SvXMLStyleContext* pStyle = pAutoStyles ? pAutoStyles->FindStyleChildContext(XmlStyleFamily::SD_PAGEMASTERCONEXT_ID, rsPageMasterName) : nullptr; - if (pPageMasterContext) - { - Reference< drawing::XDrawPage > xMasterPage(GetLocalShapesContext(), uno::UNO_QUERY); - if (xMasterPage.is()) - { - // set sizes for this masterpage - Reference <beans::XPropertySet> xPropSet(xMasterPage, uno::UNO_QUERY); - if (xPropSet.is()) - { - xPropSet->setPropertyValue("BorderBottom", Any(pPageMasterContext->GetBorderBottom())); - xPropSet->setPropertyValue("BorderLeft", Any(pPageMasterContext->GetBorderLeft())); - xPropSet->setPropertyValue("BorderRight", Any(pPageMasterContext->GetBorderRight())); - xPropSet->setPropertyValue("BorderTop", Any(pPageMasterContext->GetBorderTop())); - xPropSet->setPropertyValue("Width", Any(pPageMasterContext->GetWidth())); - xPropSet->setPropertyValue("Height", Any(pPageMasterContext->GetHeight())); - xPropSet->setPropertyValue("Orientation", Any(pPageMasterContext->GetOrientation())); - } - } - } - } + const SdXMLPageMasterContext* pPageMaster = dynamic_cast<const SdXMLPageMasterContext*>(pStyle); + if (!pPageMaster) + return; + + const SdXMLPageMasterStyleContext* pPageMasterContext = pPageMaster->GetPageMasterStyle(); + + if (!pPageMasterContext) + return; + + Reference< drawing::XDrawPage > xMasterPage(GetLocalShapesContext(), uno::UNO_QUERY); + if (!xMasterPage.is()) + return; + + // set sizes for this masterpage + Reference <beans::XPropertySet> xPropSet(xMasterPage, uno::UNO_QUERY); + if (xPropSet.is()) + { + xPropSet->setPropertyValue("BorderBottom", Any(pPageMasterContext->GetBorderBottom())); + xPropSet->setPropertyValue("BorderLeft", Any(pPageMasterContext->GetBorderLeft())); + xPropSet->setPropertyValue("BorderRight", Any(pPageMasterContext->GetBorderRight())); + xPropSet->setPropertyValue("BorderTop", Any(pPageMasterContext->GetBorderTop())); + xPropSet->setPropertyValue("Width", Any(pPageMasterContext->GetWidth())); + xPropSet->setPropertyValue("Height", Any(pPageMasterContext->GetHeight())); + xPropSet->setPropertyValue("Orientation", Any(pPageMasterContext->GetOrientation())); } } @@ -598,7 +599,10 @@ sal_Bool SAL_CALL XoNavigationOrderAccess::hasElements( ) void SdXMLGenericPageContext::SetNavigationOrder() { - if( !msNavOrder.isEmpty() ) try + if( msNavOrder.isEmpty() ) + return; + + try { sal_uInt32 nIndex; const sal_uInt32 nCount = static_cast< sal_uInt32 >( mxShapes->getCount() ); diff --git a/xmloff/source/draw/ximpshap.cxx b/xmloff/source/draw/ximpshap.cxx index 5027b8a57867..52a635a82a7a 100644 --- a/xmloff/source/draw/ximpshap.cxx +++ b/xmloff/source/draw/ximpshap.cxx @@ -489,123 +489,123 @@ void SdXMLShapeContext::AddShape(uno::Reference< drawing::XShape >& xShape) void SdXMLShapeContext::AddShape(OUString const & serviceName) { uno::Reference< lang::XMultiServiceFactory > xServiceFact(GetImport().GetModel(), uno::UNO_QUERY); - if(xServiceFact.is()) + if(!xServiceFact.is()) + return; + + try { - try + /* Since fix for issue i33294 the Writer model doesn't support + com.sun.star.drawing.OLE2Shape anymore. + To handle Draw OLE objects it's decided to import these + objects as com.sun.star.drawing.OLE2Shape and convert these + objects after the import into com.sun.star.drawing.GraphicObjectShape. + */ + uno::Reference< drawing::XShape > xShape; + if ( serviceName == "com.sun.star.drawing.OLE2Shape" && + uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) { - /* Since fix for issue i33294 the Writer model doesn't support - com.sun.star.drawing.OLE2Shape anymore. - To handle Draw OLE objects it's decided to import these - objects as com.sun.star.drawing.OLE2Shape and convert these - objects after the import into com.sun.star.drawing.GraphicObjectShape. - */ - uno::Reference< drawing::XShape > xShape; - if ( serviceName == "com.sun.star.drawing.OLE2Shape" && - uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) - { - xShape.set(xServiceFact->createInstance("com.sun.star.drawing.temporaryForXMLImportOLE2Shape"), uno::UNO_QUERY); - } - else if (serviceName == "com.sun.star.drawing.GraphicObjectShape" - || serviceName == "com.sun.star.drawing.MediaShape" - || serviceName == "com.sun.star.presentation.MediaShape") - { - css::uno::Sequence<css::uno::Any> args(1); - args[0] <<= GetImport().GetDocumentBase(); - xShape.set( xServiceFact->createInstanceWithArguments(serviceName, args), - css::uno::UNO_QUERY); - } - else - { - xShape.set(xServiceFact->createInstance(serviceName), uno::UNO_QUERY); - } - if( xShape.is() ) - AddShape( xShape ); + xShape.set(xServiceFact->createInstance("com.sun.star.drawing.temporaryForXMLImportOLE2Shape"), uno::UNO_QUERY); } - catch(const uno::Exception& e) + else if (serviceName == "com.sun.star.drawing.GraphicObjectShape" + || serviceName == "com.sun.star.drawing.MediaShape" + || serviceName == "com.sun.star.presentation.MediaShape") { - uno::Sequence<OUString> aSeq { serviceName }; - GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_API, - aSeq, e.Message, nullptr ); + css::uno::Sequence<css::uno::Any> args(1); + args[0] <<= GetImport().GetDocumentBase(); + xShape.set( xServiceFact->createInstanceWithArguments(serviceName, args), + css::uno::UNO_QUERY); } + else + { + xShape.set(xServiceFact->createInstance(serviceName), uno::UNO_QUERY); + } + if( xShape.is() ) + AddShape( xShape ); + } + catch(const uno::Exception& e) + { + uno::Sequence<OUString> aSeq { serviceName }; + GetImport().SetError( XMLERROR_FLAG_ERROR | XMLERROR_API, + aSeq, e.Message, nullptr ); } } void SdXMLShapeContext::SetTransformation() { - if(mxShape.is()) - { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - maUsedTransformation.identity(); + if(!mxShape.is()) + return; - if(maSize.Width != 1 || maSize.Height != 1) - { - // take care there are no zeros used by error - if(0 == maSize.Width) - maSize.Width = 1; - if(0 == maSize.Height) - maSize.Height = 1; + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(!xPropSet.is()) + return; - // set global size. This should always be used. - maUsedTransformation.scale(maSize.Width, maSize.Height); - } + maUsedTransformation.identity(); - if(maPosition.X != 0 || maPosition.Y != 0) - { - // if global position is used, add it to transformation - maUsedTransformation.translate(maPosition.X, maPosition.Y); - } + if(maSize.Width != 1 || maSize.Height != 1) + { + // take care there are no zeros used by error + if(0 == maSize.Width) + maSize.Width = 1; + if(0 == maSize.Height) + maSize.Height = 1; - if(mnTransform.NeedsAction()) - { - // transformation is used, apply to object. - // NOTICE: The transformation is applied AFTER evtl. used - // global positioning and scaling is used, so any shear or - // rotate used herein is applied around the (0,0) position - // of the PAGE object !!! - ::basegfx::B2DHomMatrix aMat; - mnTransform.GetFullTransform(aMat); + // set global size. This should always be used. + maUsedTransformation.scale(maSize.Width, maSize.Height); + } - // now add to transformation - maUsedTransformation *= aMat; - } + if(maPosition.X != 0 || maPosition.Y != 0) + { + // if global position is used, add it to transformation + maUsedTransformation.translate(maPosition.X, maPosition.Y); + } - // now set transformation for this object + if(mnTransform.NeedsAction()) + { + // transformation is used, apply to object. + // NOTICE: The transformation is applied AFTER evtl. used + // global positioning and scaling is used, so any shear or + // rotate used herein is applied around the (0,0) position + // of the PAGE object !!! + ::basegfx::B2DHomMatrix aMat; + mnTransform.GetFullTransform(aMat); - // maUsedTransformtion contains the mathematical correct matrix, which if - // applied to a unit square would generate the transformed shape. But the property - // "Transformation" contains a matrix, which can be used in TRSetBaseGeometry - // and would be created by TRGetBaseGeometry. And those use a mathematically wrong - // sign for the shearing angle. So we need to adapt the matrix here. - basegfx::B2DTuple aScale; - basegfx::B2DTuple aTranslate; - double fRotate; - double fShearX; - maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX); - basegfx::B2DHomMatrix aB2DHomMatrix; - aB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( - aScale, - basegfx::fTools::equalZero(fShearX) ? 0.0 : -fShearX, - basegfx::fTools::equalZero(fRotate) ? 0.0 : fRotate, - aTranslate); - drawing::HomogenMatrix3 aUnoMatrix; + // now add to transformation + maUsedTransformation *= aMat; + } - aUnoMatrix.Line1.Column1 = aB2DHomMatrix.get(0, 0); - aUnoMatrix.Line1.Column2 = aB2DHomMatrix.get(0, 1); - aUnoMatrix.Line1.Column3 = aB2DHomMatrix.get(0, 2); + // now set transformation for this object - aUnoMatrix.Line2.Column1 = aB2DHomMatrix.get(1, 0); - aUnoMatrix.Line2.Column2 = aB2DHomMatrix.get(1, 1); - aUnoMatrix.Line2.Column3 = aB2DHomMatrix.get(1, 2); + // maUsedTransformtion contains the mathematical correct matrix, which if + // applied to a unit square would generate the transformed shape. But the property + // "Transformation" contains a matrix, which can be used in TRSetBaseGeometry + // and would be created by TRGetBaseGeometry. And those use a mathematically wrong + // sign for the shearing angle. So we need to adapt the matrix here. + basegfx::B2DTuple aScale; + basegfx::B2DTuple aTranslate; + double fRotate; + double fShearX; + maUsedTransformation.decompose(aScale, aTranslate, fRotate, fShearX); + basegfx::B2DHomMatrix aB2DHomMatrix; + aB2DHomMatrix = basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix( + aScale, + basegfx::fTools::equalZero(fShearX) ? 0.0 : -fShearX, + basegfx::fTools::equalZero(fRotate) ? 0.0 : fRotate, + aTranslate); + drawing::HomogenMatrix3 aUnoMatrix; - aUnoMatrix.Line3.Column1 = aB2DHomMatrix.get(2, 0); - aUnoMatrix.Line3.Column2 = aB2DHomMatrix.get(2, 1); - aUnoMatrix.Line3.Column3 = aB2DHomMatrix.get(2, 2); + aUnoMatrix.Line1.Column1 = aB2DHomMatrix.get(0, 0); + aUnoMatrix.Line1.Column2 = aB2DHomMatrix.get(0, 1); + aUnoMatrix.Line1.Column3 = aB2DHomMatrix.get(0, 2); - xPropSet->setPropertyValue("Transformation", Any(aUnoMatrix)); - } - } + aUnoMatrix.Line2.Column1 = aB2DHomMatrix.get(1, 0); + aUnoMatrix.Line2.Column2 = aB2DHomMatrix.get(1, 1); + aUnoMatrix.Line2.Column3 = aB2DHomMatrix.get(1, 2); + + aUnoMatrix.Line3.Column1 = aB2DHomMatrix.get(2, 0); + aUnoMatrix.Line3.Column2 = aB2DHomMatrix.get(2, 1); + aUnoMatrix.Line3.Column3 = aB2DHomMatrix.get(2, 2); + + xPropSet->setPropertyValue("Transformation", Any(aUnoMatrix)); } void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */) @@ -758,21 +758,21 @@ void SdXMLShapeContext::SetStyle( bool bSupportsStyle /* = true */) void SdXMLShapeContext::SetLayer() { - if( !maLayerName.isEmpty() ) + if( maLayerName.isEmpty() ) + return; + + try { - try - { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is() ) - { - xPropSet->setPropertyValue("LayerName", Any(maLayerName)); - return; - } - } - catch(const uno::Exception&) + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is() ) { + xPropSet->setPropertyValue("LayerName", Any(maLayerName)); + return; } } + catch(const uno::Exception&) + { + } } void SdXMLShapeContext::SetThumbnail() @@ -978,32 +978,32 @@ void SdXMLRectShapeContext::StartElement(const uno::Reference< xml::sax::XAttrib { // create rectangle shape AddShape("com.sun.star.drawing.RectangleShape"); - if(mxShape.is()) - { - // Add, set Style and properties from base shape - SetStyle(); - SetLayer(); + if(!mxShape.is()) + return; - // set pos, size, shear and rotate - SetTransformation(); + // Add, set Style and properties from base shape + SetStyle(); + SetLayer(); - if(mnRadius) + // set pos, size, shear and rotate + SetTransformation(); + + if(mnRadius) + { + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) + try { - try - { - xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) ); - } - catch(const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius"); - } + xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) ); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius"); } } - SdXMLShapeContext::StartElement(xAttrList); } + SdXMLShapeContext::StartElement(xAttrList); } @@ -1210,37 +1210,37 @@ void SdXMLEllipseShapeContext::StartElement(const uno::Reference< xml::sax::XAtt { // create rectangle shape AddShape("com.sun.star.drawing.EllipseShape"); - if(mxShape.is()) - { - // Add, set Style and properties from base shape - SetStyle(); - SetLayer(); + if(!mxShape.is()) + return; - if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1) - { - // #i121972# center/radius is used, put to pos and size - maSize.Width = 2 * mnRX; - maSize.Height = 2 * mnRY; - maPosition.X = mnCX - mnRX; - maPosition.Y = mnCY - mnRY; - } + // Add, set Style and properties from base shape + SetStyle(); + SetLayer(); - // set pos, size, shear and rotate - SetTransformation(); + if(mnCX != 0 || mnCY != 0 || mnRX != 1 || mnRY != 1) + { + // #i121972# center/radius is used, put to pos and size + maSize.Width = 2 * mnRX; + maSize.Height = 2 * mnRY; + maPosition.X = mnCX - mnRX; + maPosition.Y = mnCY - mnRY; + } + + // set pos, size, shear and rotate + SetTransformation(); - if( meKind != drawing::CircleKind_FULL ) + if( meKind != drawing::CircleKind_FULL ) + { + uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); + if( xPropSet.is() ) { - uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); - if( xPropSet.is() ) - { - xPropSet->setPropertyValue("CircleKind", Any( meKind) ); - xPropSet->setPropertyValue("CircleStartAngle", Any(mnStartAngle) ); - xPropSet->setPropertyValue("CircleEndAngle", Any(mnEndAngle) ); - } + xPropSet->setPropertyValue("CircleKind", Any( meKind) ); + xPropSet->setPropertyValue("CircleStartAngle", Any(mnStartAngle) ); + xPropSet->setPropertyValue("CircleEndAngle", Any(mnEndAngle) ); } - - SdXMLShapeContext::StartElement(xAttrList); } + + SdXMLShapeContext::StartElement(xAttrList); } @@ -1290,66 +1290,66 @@ void SdXMLPolygonShapeContext::StartElement(const uno::Reference< xml::sax::XAtt else AddShape("com.sun.star.drawing.PolyLineShape"); - if( mxShape.is() ) - { - SetStyle(); - SetLayer(); + if( !mxShape.is() ) + return; - // set local parameters on shape - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) + SetStyle(); + SetLayer(); + + // set local parameters on shape + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + // set polygon + if(!maPoints.isEmpty() && !maViewBox.isEmpty()) { - // set polygon - if(!maPoints.isEmpty() && !maViewBox.isEmpty()) - { - const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); - basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); + const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - // Is this correct? It overrides ViewBox stuff; OTOH it makes no - // sense to have the geometry content size different from object size - if(maSize.Width != 0 && maSize.Height != 0) - { - aSize = basegfx::B2DVector(maSize.Width, maSize.Height); - } + // Is this correct? It overrides ViewBox stuff; OTOH it makes no + // sense to have the geometry content size different from object size + if(maSize.Width != 0 && maSize.Height != 0) + { + aSize = basegfx::B2DVector(maSize.Width, maSize.Height); + } - basegfx::B2DPolygon aPolygon; + basegfx::B2DPolygon aPolygon; - if(basegfx::utils::importFromSvgPoints(aPolygon, maPoints)) + if(basegfx::utils::importFromSvgPoints(aPolygon, maPoints)) + { + if(aPolygon.count()) { - if(aPolygon.count()) + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); + + if(!aSourceRange.equal(aTargetRange)) { - const basegfx::B2DRange aSourceRange( - aViewBox.GetX(), aViewBox.GetY(), - aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); - const basegfx::B2DRange aTargetRange( - aViewBox.GetX(), aViewBox.GetY(), - aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); - - if(!aSourceRange.equal(aTargetRange)) - { - aPolygon.transform( - basegfx::utils::createSourceRangeTargetRangeTransform( - aSourceRange, - aTargetRange)); - } - - css::drawing::PointSequenceSequence aPointSequenceSequence; - basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence); - xPropSet->setPropertyValue("Geometry", Any(aPointSequenceSequence)); - // Size is now contained in the point coordinates, adapt maSize for - // to use the correct transformation matrix in SetTransformation() - maSize.Width = 1; - maSize.Height = 1; + aPolygon.transform( + basegfx::utils::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); } + + css::drawing::PointSequenceSequence aPointSequenceSequence; + basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence(basegfx::B2DPolyPolygon(aPolygon), aPointSequenceSequence); + xPropSet->setPropertyValue("Geometry", Any(aPointSequenceSequence)); + // Size is now contained in the point coordinates, adapt maSize for + // to use the correct transformation matrix in SetTransformation() + maSize.Width = 1; + maSize.Height = 1; } } } + } - // set pos, size, shear and rotate and get copy of matrix - SetTransformation(); + // set pos, size, shear and rotate and get copy of matrix + SetTransformation(); - SdXMLShapeContext::StartElement(xAttrList); - } + SdXMLShapeContext::StartElement(xAttrList); } @@ -1391,118 +1391,118 @@ void SdXMLPathShapeContext::processAttribute( sal_uInt16 nPrefix, const OUString void SdXMLPathShapeContext::StartElement(const uno::Reference< xml::sax::XAttributeList>& xAttrList) { // create polygon shape - if(!maD.isEmpty()) - { - const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); - basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); + if(maD.isEmpty()) + return; - // Is this correct? It overrides ViewBox stuff; OTOH it makes no - // sense to have the geometry content size different from object size - if(maSize.Width != 0 && maSize.Height != 0) - { - aSize = basegfx::B2DVector(maSize.Width, maSize.Height); - } + const SdXMLImExViewBox aViewBox(maViewBox, GetImport().GetMM100UnitConverter()); + basegfx::B2DVector aSize(aViewBox.GetWidth(), aViewBox.GetHeight()); - basegfx::B2DPolyPolygon aPolyPolygon; + // Is this correct? It overrides ViewBox stuff; OTOH it makes no + // sense to have the geometry content size different from object size + if(maSize.Width != 0 && maSize.Height != 0) + { + aSize = basegfx::B2DVector(maSize.Width, maSize.Height); + } - if(basegfx::utils::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), nullptr)) - { - if(aPolyPolygon.count()) - { - const basegfx::B2DRange aSourceRange( - aViewBox.GetX(), aViewBox.GetY(), - aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); - const basegfx::B2DRange aTargetRange( - aViewBox.GetX(), aViewBox.GetY(), - aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); + basegfx::B2DPolyPolygon aPolyPolygon; - if(!aSourceRange.equal(aTargetRange)) - { - aPolyPolygon.transform( - basegfx::utils::createSourceRangeTargetRangeTransform( - aSourceRange, - aTargetRange)); - } + if(!basegfx::utils::importFromSvgD(aPolyPolygon, maD, GetImport().needFixPositionAfterZ(), nullptr)) + return; - // create shape - OUString service; + if(!aPolyPolygon.count()) + return; - if(aPolyPolygon.areControlPointsUsed()) - { - if(aPolyPolygon.isClosed()) - { - service = "com.sun.star.drawing.ClosedBezierShape"; - } - else - { - service = "com.sun.star.drawing.OpenBezierShape"; - } - } - else - { - if(aPolyPolygon.isClosed()) - { - service = "com.sun.star.drawing.PolyPolygonShape"; - } - else - { - service = "com.sun.star.drawing.PolyLineShape"; - } - } + const basegfx::B2DRange aSourceRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight()); + const basegfx::B2DRange aTargetRange( + aViewBox.GetX(), aViewBox.GetY(), + aViewBox.GetX() + aSize.getX(), aViewBox.GetY() + aSize.getY()); - // Add, set Style and properties from base shape - AddShape(service); + if(!aSourceRange.equal(aTargetRange)) + { + aPolyPolygon.transform( + basegfx::utils::createSourceRangeTargetRangeTransform( + aSourceRange, + aTargetRange)); + } - // #89344# test for mxShape.is() and not for mxShapes.is() to support - // shape import helper classes WITHOUT XShapes (member mxShapes). This - // is used by the writer. - if( mxShape.is() ) - { - SetStyle(); - SetLayer(); + // create shape + OUString service; - // set local parameters on shape - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(aPolyPolygon.areControlPointsUsed()) + { + if(aPolyPolygon.isClosed()) + { + service = "com.sun.star.drawing.ClosedBezierShape"; + } + else + { + service = "com.sun.star.drawing.OpenBezierShape"; + } + } + else + { + if(aPolyPolygon.isClosed()) + { + service = "com.sun.star.drawing.PolyPolygonShape"; + } + else + { + service = "com.sun.star.drawing.PolyLineShape"; + } + } - if(xPropSet.is()) - { - uno::Any aAny; + // Add, set Style and properties from base shape + AddShape(service); - // set polygon data - if(aPolyPolygon.areControlPointsUsed()) - { - drawing::PolyPolygonBezierCoords aSourcePolyPolygon; + // #89344# test for mxShape.is() and not for mxShapes.is() to support + // shape import helper classes WITHOUT XShapes (member mxShapes). This + // is used by the writer. + if( !mxShape.is() ) + return; - basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( - aPolyPolygon, - aSourcePolyPolygon); - aAny <<= aSourcePolyPolygon; - } - else - { - drawing::PointSequenceSequence aSourcePolyPolygon; + SetStyle(); + SetLayer(); - basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence( - aPolyPolygon, - aSourcePolyPolygon); - aAny <<= aSourcePolyPolygon; - } + // set local parameters on shape + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - xPropSet->setPropertyValue("Geometry", aAny); - // Size is now contained in the point coordinates, adapt maSize for - // to use the correct transformation matrix in SetTransformation() - maSize.Width = 1; - maSize.Height = 1; - } + if(xPropSet.is()) + { + uno::Any aAny; - // set pos, size, shear and rotate - SetTransformation(); + // set polygon data + if(aPolyPolygon.areControlPointsUsed()) + { + drawing::PolyPolygonBezierCoords aSourcePolyPolygon; - SdXMLShapeContext::StartElement(xAttrList); - } - } + basegfx::utils::B2DPolyPolygonToUnoPolyPolygonBezierCoords( + aPolyPolygon, + aSourcePolyPolygon); + aAny <<= aSourcePolyPolygon; + } + else + { + drawing::PointSequenceSequence aSourcePolyPolygon; + + basegfx::utils::B2DPolyPolygonToUnoPointSequenceSequence( + aPolyPolygon, + aSourcePolyPolygon); + aAny <<= aSourcePolyPolygon; } + + xPropSet->setPropertyValue("Geometry", aAny); + // Size is now contained in the point coordinates, adapt maSize for + // to use the correct transformation matrix in SetTransformation() + maSize.Width = 1; + maSize.Height = 1; } + + // set pos, size, shear and rotate + SetTransformation(); + + SdXMLShapeContext::StartElement(xAttrList); } @@ -1615,35 +1615,36 @@ void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAtt // Add, set Style and properties from base shape AddShape(service); - if( mxShape.is() ) - { - SetStyle(); - SetLayer(); + if( !mxShape.is() ) + return; - if(bIsPresShape) + SetStyle(); + SetLayer(); + + if(bIsPresShape) + { + uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); + if(xProps.is()) { - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(xProps.is()) + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() ) - { - if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) - xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); + if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) + xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); - if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) - xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); - } + if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) + xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); } } + } - if( bClearText ) - { - uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); - xText->setString( "" ); - } + if( bClearText ) + { + uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); + xText->setString( "" ); + } - // set parameters on shape + // set parameters on shape //A AW->CL: Eventually You need to strip scale and translate from the transformation //A to reach the same goal again. //A if(!bIsPresShape || mbIsUserTransformed) @@ -1653,44 +1654,43 @@ void SdXMLTextBoxShapeContext::StartElement(const uno::Reference< xml::sax::XAtt //A SetSizeAndPosition(); //A } - // set pos, size, shear and rotate - SetTransformation(); + // set pos, size, shear and rotate + SetTransformation(); - if(mnRadius) + if(mnRadius) + { + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) + try { - try - { - xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) ); - } - catch(const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius"); - } + xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) ); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius"); } } + } - if(!maChainNextName.isEmpty()) + if(!maChainNextName.isEmpty()) + { + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) + try { - try - { - xPropSet->setPropertyValue("TextChainNextName", - uno::makeAny( maChainNextName ) ); - } - catch(const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION( "xmloff", "setting name of next chain link"); - } + xPropSet->setPropertyValue("TextChainNextName", + uno::makeAny( maChainNextName ) ); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION( "xmloff", "setting name of next chain link"); } } - - SdXMLShapeContext::StartElement(mxAttrList); } + + SdXMLShapeContext::StartElement(mxAttrList); } @@ -1729,32 +1729,32 @@ void SdXMLControlShapeContext::StartElement(const uno::Reference< xml::sax::XAtt // create Control shape // add, set style and properties from base shape AddShape("com.sun.star.drawing.ControlShape"); - if( mxShape.is() ) + if( !mxShape.is() ) + return; + + SAL_WARN_IF( !!maFormId.isEmpty(), "xmloff", "draw:control without a form:id attribute!" ); + if( !maFormId.isEmpty() ) { - SAL_WARN_IF( !!maFormId.isEmpty(), "xmloff", "draw:control without a form:id attribute!" ); - if( !maFormId.isEmpty() ) + if( GetImport().IsFormsSupported() ) { - if( GetImport().IsFormsSupported() ) + uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY ); + if( xControlModel.is() ) { - uno::Reference< awt::XControlModel > xControlModel( GetImport().GetFormImport()->lookupControl( maFormId ), uno::UNO_QUERY ); - if( xControlModel.is() ) - { - uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY ); - if( xControl.is() ) - xControl->setControl( xControlModel ); + uno::Reference< drawing::XControlShape > xControl( mxShape, uno::UNO_QUERY ); + if( xControl.is() ) + xControl->setControl( xControlModel ); - } } } + } - SetStyle(); - SetLayer(); + SetStyle(); + SetLayer(); - // set pos, size, shear and rotate - SetTransformation(); + // set pos, size, shear and rotate + SetTransformation(); - SdXMLShapeContext::StartElement(xAttrList); - } + SdXMLShapeContext::StartElement(xAttrList); } @@ -1928,139 +1928,139 @@ void SdXMLConnectorShapeContext::StartElement(const uno::Reference< xml::sax::XA bDoAdd = false; } - if(bDoAdd) + if(!bDoAdd) + return; + + // create Connector shape + // add, set style and properties from base shape + AddShape("com.sun.star.drawing.ConnectorShape"); + if(!mxShape.is()) + return; + + // #121965# if draw:transform is used, apply directly to the start + // and end positions before using these + if(mnTransform.NeedsAction()) { - // create Connector shape - // add, set style and properties from base shape - AddShape("com.sun.star.drawing.ConnectorShape"); - if(mxShape.is()) + // transformation is used, apply to object. + ::basegfx::B2DHomMatrix aMat; + mnTransform.GetFullTransform(aMat); + + if(!aMat.isIdentity()) { - // #121965# if draw:transform is used, apply directly to the start - // and end positions before using these - if(mnTransform.NeedsAction()) - { - // transformation is used, apply to object. - ::basegfx::B2DHomMatrix aMat; - mnTransform.GetFullTransform(aMat); + basegfx::B2DPoint aStart(maStart.X, maStart.Y); + basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y); - if(!aMat.isIdentity()) - { - basegfx::B2DPoint aStart(maStart.X, maStart.Y); - basegfx::B2DPoint aEnd(maEnd.X, maEnd.Y); + aStart = aMat * aStart; + aEnd = aMat * aEnd; - aStart = aMat * aStart; - aEnd = aMat * aEnd; + maStart.X = basegfx::fround(aStart.getX()); + maStart.Y = basegfx::fround(aStart.getY()); + maEnd.X = basegfx::fround(aEnd.getX()); + maEnd.Y = basegfx::fround(aEnd.getY()); + } + } - maStart.X = basegfx::fround(aStart.getX()); - maStart.Y = basegfx::fround(aStart.getY()); - maEnd.X = basegfx::fround(aEnd.getX()); - maEnd.Y = basegfx::fround(aEnd.getY()); - } - } + // add connection ids + if( !maStartShapeId.isEmpty() ) + GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId ); + if( !maEndShapeId.isEmpty() ) + GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId ); - // add connection ids - if( !maStartShapeId.isEmpty() ) - GetImport().GetShapeImport()->addShapeConnection( mxShape, true, maStartShapeId, mnStartGlueId ); - if( !maEndShapeId.isEmpty() ) - GetImport().GetShapeImport()->addShapeConnection( mxShape, false, maEndShapeId, mnEndGlueId ); + uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + if( xProps.is() ) + { + xProps->setPropertyValue("StartPosition", Any(maStart)); + xProps->setPropertyValue("EndPosition", Any(maEnd) ); + xProps->setPropertyValue("EdgeKind", Any(mnType) ); + xProps->setPropertyValue("EdgeLine1Delta", Any(mnDelta1) ); + xProps->setPropertyValue("EdgeLine2Delta", Any(mnDelta2) ); + xProps->setPropertyValue("EdgeLine3Delta", Any(mnDelta3) ); + } + SetStyle(); + SetLayer(); - uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); - if( xProps.is() ) + if ( maPath.hasValue() ) + { + // #i115492# + // Ignore svg:d attribute for text documents created by OpenOffice.org + // versions before OOo 3.3, because these OOo versions are storing + // svg:d values not using the correct unit. + bool bApplySVGD( true ); + if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) + { + sal_Int32 nUPD( 0 ); + sal_Int32 nBuild( 0 ); + const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); + if ( GetImport().IsTextDocInOOoFileFormat() || + ( bBuildIdFound && + ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 + ( nUPD == 680 ) || // OOo 2.x + ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1 + ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1 + ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1 { - xProps->setPropertyValue("StartPosition", Any(maStart)); - xProps->setPropertyValue("EndPosition", Any(maEnd) ); - xProps->setPropertyValue("EdgeKind", Any(mnType) ); - xProps->setPropertyValue("EdgeLine1Delta", Any(mnDelta1) ); - xProps->setPropertyValue("EdgeLine2Delta", Any(mnDelta2) ); - xProps->setPropertyValue("EdgeLine3Delta", Any(mnDelta3) ); + bApplySVGD = false; } - SetStyle(); - SetLayer(); + } - if ( maPath.hasValue() ) + if ( bApplySVGD ) + { + // tdf#83360 use path data only when redundant data of start and end point coordinates of + // path start/end and connector start/end is equal. This is to avoid using erraneous + // or inconsistent path data at import of foreign formats. Office itself always + // writes out a consistent data set. Not using it when there is inconsistency + // is okay since the path data is redundant, buffered data just to avoid recalculation + // of the connector's layout at load time, no real information would be lost. + // A 'connected' end has prio to direct coordinate data in Start/EndPosition + // to the path data (which should have the start/end redundant in the path) + const drawing::PolyPolygonBezierCoords* pSource = static_cast< const drawing::PolyPolygonBezierCoords* >(maPath.getValue()); + const sal_uInt32 nSequenceCount(pSource->Coordinates.getLength()); + bool bStartEqual(false); + bool bEndEqual(false); + + if(nSequenceCount) { - // #i115492# - // Ignore svg:d attribute for text documents created by OpenOffice.org - // versions before OOo 3.3, because these OOo versions are storing - // svg:d values not using the correct unit. - bool bApplySVGD( true ); - if ( uno::Reference< text::XTextDocument >(GetImport().GetModel(), uno::UNO_QUERY).is() ) + const drawing::PointSequence& rStartSeq = pSource->Coordinates[0]; + const sal_uInt32 nStartCount = rStartSeq.getLength(); + + if(nStartCount) { - sal_Int32 nUPD( 0 ); - sal_Int32 nBuild( 0 ); - const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); - if ( GetImport().IsTextDocInOOoFileFormat() || - ( bBuildIdFound && - ( ( nUPD == 641 ) || ( nUPD == 645 ) || // prior OOo 2.0 - ( nUPD == 680 ) || // OOo 2.x - ( nUPD == 300 ) || // OOo 3.0 - OOo 3.0.1 - ( nUPD == 310 ) || // OOo 3.1 - OOo 3.1.1 - ( nUPD == 320 ) ) ) ) // OOo 3.2 - OOo 3.2.1 + const awt::Point& rStartPoint = rStartSeq.getConstArray()[0]; + + if(rStartPoint.X == maStart.X && rStartPoint.Y == maStart.Y) { - bApplySVGD = false; + bStartEqual = true; } } - if ( bApplySVGD ) - { - // tdf#83360 use path data only when redundant data of start and end point coordinates of - // path start/end and connector start/end is equal. This is to avoid using erraneous - // or inconsistent path data at import of foreign formats. Office itself always - // writes out a consistent data set. Not using it when there is inconsistency - // is okay since the path data is redundant, buffered data just to avoid recalculation - // of the connector's layout at load time, no real information would be lost. - // A 'connected' end has prio to direct coordinate data in Start/EndPosition - // to the path data (which should have the start/end redundant in the path) - const drawing::PolyPolygonBezierCoords* pSource = static_cast< const drawing::PolyPolygonBezierCoords* >(maPath.getValue()); - const sal_uInt32 nSequenceCount(pSource->Coordinates.getLength()); - bool bStartEqual(false); - bool bEndEqual(false); - - if(nSequenceCount) - { - const drawing::PointSequence& rStartSeq = pSource->Coordinates[0]; - const sal_uInt32 nStartCount = rStartSeq.getLength(); - - if(nStartCount) - { - const awt::Point& rStartPoint = rStartSeq.getConstArray()[0]; - - if(rStartPoint.X == maStart.X && rStartPoint.Y == maStart.Y) - { - bStartEqual = true; - } - } - - const drawing::PointSequence& rEndSeq = pSource->Coordinates[nSequenceCount - 1]; - const sal_uInt32 nEndCount = rEndSeq.getLength(); + const drawing::PointSequence& rEndSeq = pSource->Coordinates[nSequenceCount - 1]; + const sal_uInt32 nEndCount = rEndSeq.getLength(); - if(nEndCount) - { - const awt::Point& rEndPoint = rEndSeq.getConstArray()[nEndCount - 1]; - - if(rEndPoint.X == maEnd.X && rEndPoint.Y == maEnd.Y) - { - bEndEqual = true; - } - } - } + if(nEndCount) + { + const awt::Point& rEndPoint = rEndSeq.getConstArray()[nEndCount - 1]; - if(!bStartEqual || !bEndEqual) + if(rEndPoint.X == maEnd.X && rEndPoint.Y == maEnd.Y) { - bApplySVGD = false; + bEndEqual = true; } } + } - if ( bApplySVGD ) - { - assert(maPath.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get()); - xProps->setPropertyValue("PolyPolygonBezier", maPath); - } + if(!bStartEqual || !bEndEqual) + { + bApplySVGD = false; } + } - SdXMLShapeContext::StartElement(xAttrList); + if ( bApplySVGD ) + { + assert(maPath.getValueType() == cppu::UnoType<drawing::PolyPolygonBezierCoords>::get()); + xProps->setPropertyValue("PolyPolygonBezier", maPath); } } + + SdXMLShapeContext::StartElement(xAttrList); } @@ -2123,27 +2123,27 @@ void SdXMLMeasureShapeContext::StartElement(const uno::Reference< xml::sax::XAtt // create Measure shape // add, set style and properties from base shape AddShape("com.sun.star.drawing.MeasureShape"); - if(mxShape.is()) - { - SetStyle(); - SetLayer(); + if(!mxShape.is()) + return; - uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); - if( xProps.is() ) - { - xProps->setPropertyValue("StartPosition", Any(maStart)); - xProps->setPropertyValue("EndPosition", Any(maEnd) ); - } + SetStyle(); + SetLayer(); - // delete pre created fields - uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); - if( xText.is() ) - { - xText->setString( " " ); - } + uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + if( xProps.is() ) + { + xProps->setPropertyValue("StartPosition", Any(maStart)); + xProps->setPropertyValue("EndPosition", Any(maEnd) ); + } - SdXMLShapeContext::StartElement(xAttrList); + // delete pre created fields + uno::Reference< text::XText > xText( mxShape, uno::UNO_QUERY ); + if( xText.is() ) + { + xText->setString( " " ); } + + SdXMLShapeContext::StartElement(xAttrList); } void SdXMLMeasureShapeContext::EndElement() @@ -2234,25 +2234,25 @@ void SdXMLPageShapeContext::StartElement(const uno::Reference< xml::sax::XAttrib } } - if(mxShape.is()) - { - SetStyle(); - SetLayer(); + if(!mxShape.is()) + return; - // set pos, size, shear and rotate - SetTransformation(); + SetStyle(); + SetLayer(); - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); - const OUString aPageNumberStr("PageNumber"); - if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr)) - xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber )); - } + // set pos, size, shear and rotate + SetTransformation(); - SdXMLShapeContext::StartElement(xAttrList); + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xPropSet->getPropertySetInfo() ); + const OUString aPageNumberStr("PageNumber"); + if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(aPageNumberStr)) + xPropSet->setPropertyValue(aPageNumberStr, uno::makeAny( mnPageNumber )); } + + SdXMLShapeContext::StartElement(xAttrList); } @@ -2278,54 +2278,54 @@ void SdXMLCaptionShapeContext::StartElement(const uno::Reference< xml::sax::XAtt // create Caption shape // add, set style and properties from base shape AddShape("com.sun.star.drawing.CaptionShape"); - if( mxShape.is() ) - { - SetStyle(); - SetLayer(); - - uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + if( !mxShape.is() ) + return; - // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect - // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment - // is the default setting, so the top left reference point that is used by the caption point is - // no longer correct) There are two ways to solve this problem, temporarily disabling the - // autogrowwidth as we are doing here or to apply the CaptionPoint after setting text - bool bIsAutoGrowWidth = false; - if ( xProps.is() ) - { - uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") ); - aAny >>= bIsAutoGrowWidth; + SetStyle(); + SetLayer(); - if ( bIsAutoGrowWidth ) - xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( false ) ); - } + uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); - // set pos, size, shear and rotate - SetTransformation(); - if( xProps.is() ) - xProps->setPropertyValue("CaptionPoint", uno::makeAny( maCaptionPoint ) ); + // SJ: If AutoGrowWidthItem is set, SetTransformation will lead to the wrong SnapRect + // because NbcAdjustTextFrameWidthAndHeight() is called (text is set later and center alignment + // is the default setting, so the top left reference point that is used by the caption point is + // no longer correct) There are two ways to solve this problem, temporarily disabling the + // autogrowwidth as we are doing here or to apply the CaptionPoint after setting text + bool bIsAutoGrowWidth = false; + if ( xProps.is() ) + { + uno::Any aAny( xProps->getPropertyValue("TextAutoGrowWidth") ); + aAny >>= bIsAutoGrowWidth; if ( bIsAutoGrowWidth ) - xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( true ) ); + xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( false ) ); + } + + // set pos, size, shear and rotate + SetTransformation(); + if( xProps.is() ) + xProps->setPropertyValue("CaptionPoint", uno::makeAny( maCaptionPoint ) ); + + if ( bIsAutoGrowWidth ) + xProps->setPropertyValue("TextAutoGrowWidth", uno::makeAny( true ) ); - if(mnRadius) + if(mnRadius) + { + uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); + if(xPropSet.is()) { - uno::Reference< beans::XPropertySet > xPropSet(mxShape, uno::UNO_QUERY); - if(xPropSet.is()) + try { - try - { - xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) ); - } - catch(const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius"); - } + xPropSet->setPropertyValue("CornerRadius", uno::makeAny( mnRadius ) ); + } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION( "xmloff", "setting corner radius"); } } - - SdXMLShapeContext::StartElement(xAttrList); } + + SdXMLShapeContext::StartElement(xAttrList); } // this is called from the parent group for each unparsed attribute in the attribute list @@ -2398,62 +2398,62 @@ void SdXMLGraphicObjectShapeContext::StartElement( const css::uno::Reference< cs AddShape(service); - if(mxShape.is()) - { - SetStyle(); - SetLayer(); + if(!mxShape.is()) + return; + + SetStyle(); + SetLayer(); - uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY); - if(xPropset.is()) + uno::Reference< beans::XPropertySet > xPropset(mxShape, uno::UNO_QUERY); + if(xPropset.is()) + { + // since OOo 1.x had no line or fill style for graphics, but may create + // documents with them, we have to override them here + sal_Int32 nUPD, nBuildId; + if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try { - // since OOo 1.x had no line or fill style for graphics, but may create - // documents with them, we have to override them here - sal_Int32 nUPD, nBuildId; - if( GetImport().getBuildIds( nUPD, nBuildId ) && (nUPD == 645) ) try - { - xPropset->setPropertyValue("FillStyle", Any( FillStyle_NONE ) ); - xPropset->setPropertyValue("LineStyle", Any( LineStyle_NONE ) ); - } - catch(const Exception&) - { - } + xPropset->setPropertyValue("FillStyle", Any( FillStyle_NONE ) ); + xPropset->setPropertyValue("LineStyle", Any( LineStyle_NONE ) ); + } + catch(const Exception&) + { + } - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() ); - if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) - xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::makeAny( mbIsPlaceholder ) ); + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xPropset->getPropertySetInfo() ); + if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) + xPropset->setPropertyValue("IsEmptyPresentationObject", css::uno::makeAny( mbIsPlaceholder ) ); - if( !mbIsPlaceholder ) + if( !mbIsPlaceholder ) + { + if( !maURL.isEmpty() ) { - if( !maURL.isEmpty() ) + uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maURL); + if (xGraphic.is()) { - uno::Reference<graphic::XGraphic> xGraphic = GetImport().loadGraphicByURL(maURL); - if (xGraphic.is()) - { - xPropset->setPropertyValue("Graphic", uno::makeAny(xGraphic)); - } + xPropset->setPropertyValue("Graphic", uno::makeAny(xGraphic)); } } } + } - if(mbIsUserTransformed) + if(mbIsUserTransformed) + { + uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); + if(xProps.is()) { - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(xProps.is()) + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() ) - { - if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) - xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); - } + if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) + xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); } } + } - // set pos, size, shear and rotate - SetTransformation(); + // set pos, size, shear and rotate + SetTransformation(); - SdXMLShapeContext::StartElement(mxAttrList); - } + SdXMLShapeContext::StartElement(mxAttrList); } void SdXMLGraphicObjectShapeContext::EndElement() @@ -2527,55 +2527,55 @@ void SdXMLChartShapeContext::StartElement(const uno::Reference< xml::sax::XAttri ? OUString("com.sun.star.presentation.ChartShape") : OUString("com.sun.star.drawing.OLE2Shape")); - if(mxShape.is()) - { - SetStyle(); - SetLayer(); + if(!mxShape.is()) + return; - if( !mbIsPlaceholder ) + SetStyle(); + SetLayer(); + + if( !mbIsPlaceholder ) + { + uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); + if(xProps.is()) { - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(xProps.is()) - { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) - xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) + xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); - uno::Any aAny; + uno::Any aAny; - xProps->setPropertyValue("CLSID", Any(OUString("12DCAE26-281F-416F-a234-c3086127382e")) ); + xProps->setPropertyValue("CLSID", Any(OUString("12DCAE26-281F-416F-a234-c3086127382e")) ); - aAny = xProps->getPropertyValue("Model"); - uno::Reference< frame::XModel > xChartModel; - if( aAny >>= xChartModel ) - { - mxChartContext.set( GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList ) ); - } + aAny = xProps->getPropertyValue("Model"); + uno::Reference< frame::XModel > xChartModel; + if( aAny >>= xChartModel ) + { + mxChartContext.set( GetImport().GetChartImport()->CreateChartContext( GetImport(), XML_NAMESPACE_SVG, GetXMLToken(XML_CHART), xChartModel, xAttrList ) ); } } + } - if(mbIsUserTransformed) + if(mbIsUserTransformed) + { + uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); + if(xProps.is()) { - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(xProps.is()) + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() ) - { - if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) - xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); - } + if( xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) + xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); } } + } - // set pos, size, shear and rotate - SetTransformation(); + // set pos, size, shear and rotate + SetTransformation(); - SdXMLShapeContext::StartElement(xAttrList); + SdXMLShapeContext::StartElement(xAttrList); - if( mxChartContext.is() ) - mxChartContext->StartElement( xAttrList ); - } + if( mxChartContext.is() ) + mxChartContext->StartElement( xAttrList ); } void SdXMLChartShapeContext::EndElement() @@ -2652,61 +2652,61 @@ void SdXMLObjectShapeContext::StartElement( const css::uno::Reference< css::xml: AddShape(service); - if( mxShape.is() ) - { - SetLayer(); + if( !mxShape.is() ) + return; + + SetLayer(); - if(bIsPresShape) + if(bIsPresShape) + { + uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); + if(xProps.is()) { - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(xProps.is()) + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() ) - { - if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) - xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); + if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) + xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); - if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) - xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); - } + if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) + xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); } } + } + + if( !mbIsPlaceholder && !maHref.isEmpty() ) + { + uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); - if( !mbIsPlaceholder && !maHref.isEmpty() ) + if( xProps.is() ) { - uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID ); - if( xProps.is() ) + if ( GetImport().IsPackageURL( maHref ) ) { - OUString aPersistName = GetImport().ResolveEmbeddedObjectURL( maHref, maCLSID ); - - if ( GetImport().IsPackageURL( maHref ) ) - { - const OUString sURL( "vnd.sun.star.EmbeddedObject:" ); + const OUString sURL( "vnd.sun.star.EmbeddedObject:" ); - if ( aPersistName.startsWith( sURL ) ) - aPersistName = aPersistName.copy( sURL.getLength() ); + if ( aPersistName.startsWith( sURL ) ) + aPersistName = aPersistName.copy( sURL.getLength() ); - xProps->setPropertyValue("PersistName", - uno::makeAny( aPersistName ) ); - } - else - { - // this is OOo link object - xProps->setPropertyValue("LinkURL", - uno::makeAny( aPersistName ) ); - } + xProps->setPropertyValue("PersistName", + uno::makeAny( aPersistName ) ); + } + else + { + // this is OOo link object + xProps->setPropertyValue("LinkURL", + uno::makeAny( aPersistName ) ); } } + } - // set pos, size, shear and rotate - SetTransformation(); + // set pos, size, shear and rotate + SetTransformation(); - SetStyle(); + SetStyle(); - GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); - } + GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); } void SdXMLObjectShapeContext::EndElement() @@ -3016,31 +3016,31 @@ void SdXMLPluginShapeContext::StartElement( const css::uno::Reference< css::xml: AddShape(service); - if( mxShape.is() ) - { - SetLayer(); + if( !mxShape.is() ) + return; + + SetLayer(); - if(bIsPresShape) + if(bIsPresShape) + { + uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + if(xProps.is()) { - uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); - if(xProps.is()) + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() ) - { - if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) - xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); + if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) + xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); - if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) - xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); - } + if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) + xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); } } - - // set pos, size, shear and rotate - SetTransformation(); - GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); } + + // set pos, size, shear and rotate + SetTransformation(); + GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); } static OUString @@ -3245,31 +3245,31 @@ void SdXMLFloatingFrameShapeContext::StartElement( const css::uno::Reference< cs { AddShape("com.sun.star.drawing.FrameShape"); - if( mxShape.is() ) - { - SetLayer(); + if( !mxShape.is() ) + return; - // set pos, size, shear and rotate - SetTransformation(); + SetLayer(); - uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); - if( xProps.is() ) + // set pos, size, shear and rotate + SetTransformation(); + + uno::Reference< beans::XPropertySet > xProps( mxShape, uno::UNO_QUERY ); + if( xProps.is() ) + { + if( !maFrameName.isEmpty() ) { - if( !maFrameName.isEmpty() ) - { - xProps->setPropertyValue("FrameName", Any(maFrameName) ); - } + xProps->setPropertyValue("FrameName", Any(maFrameName) ); + } - if( !maHref.isEmpty() ) - { - xProps->setPropertyValue("FrameURL", Any(maHref) ); - } + if( !maHref.isEmpty() ) + { + xProps->setPropertyValue("FrameURL", Any(maHref) ); } + } - SetStyle(); + SetStyle(); - GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); - } + GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); } // this is called from the parent group for each unparsed attribute in the attribute list @@ -3342,30 +3342,30 @@ void SdXMLFrameShapeContext::removeGraphicFromImportContext(const SvXMLImportCon { const SdXMLGraphicObjectShapeContext* pSdXMLGraphicObjectShapeContext = dynamic_cast< const SdXMLGraphicObjectShapeContext* >(&rContext); - if(pSdXMLGraphicObjectShapeContext) + if(!pSdXMLGraphicObjectShapeContext) + return; + + try { - try - { - uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW); + uno::Reference< container::XChild > xChild(pSdXMLGraphicObjectShapeContext->getShape(), uno::UNO_QUERY_THROW); - uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW); + uno::Reference< drawing::XShapes > xParent(xChild->getParent(), uno::UNO_QUERY_THROW); - // remove from parent - xParent->remove(pSdXMLGraphicObjectShapeContext->getShape()); + // remove from parent + xParent->remove(pSdXMLGraphicObjectShapeContext->getShape()); - // dispose - uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY); + // dispose + uno::Reference< lang::XComponent > xComp(pSdXMLGraphicObjectShapeContext->getShape(), UNO_QUERY); - if(xComp.is()) - { - xComp->dispose(); - } - } - catch( uno::Exception& ) + if(xComp.is()) { - DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." ); + xComp->dispose(); } } + catch( uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION( "xmloff", "Error in cleanup of multiple graphic object import." ); + } } namespace @@ -3719,36 +3719,36 @@ void SdXMLCustomShapeContext::StartElement( const uno::Reference< xml::sax::XAtt { // create rectangle shape AddShape("com.sun.star.drawing.CustomShape"); - if ( mxShape.is() ) - { - // Add, set Style and properties from base shape - SetStyle(); - SetLayer(); + if ( !mxShape.is() ) + return; - // set pos, size, shear and rotate - SetTransformation(); + // Add, set Style and properties from base shape + SetStyle(); + SetLayer(); - try + // set pos, size, shear and rotate + SetTransformation(); + + try + { + uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); + if( xPropSet.is() ) { - uno::Reference< beans::XPropertySet > xPropSet( mxShape, uno::UNO_QUERY ); - if( xPropSet.is() ) + if ( !maCustomShapeEngine.isEmpty() ) { - if ( !maCustomShapeEngine.isEmpty() ) - { - xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), Any(maCustomShapeEngine) ); - } - if ( !maCustomShapeData.isEmpty() ) - { - xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), Any(maCustomShapeData) ); - } + xPropSet->setPropertyValue( EASGet( EAS_CustomShapeEngine ), Any(maCustomShapeEngine) ); + } + if ( !maCustomShapeData.isEmpty() ) + { + xPropSet->setPropertyValue( EASGet( EAS_CustomShapeData ), Any(maCustomShapeData) ); } } - catch(const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" ); - } - SdXMLShapeContext::StartElement(xAttrList); } + catch(const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION( "xmloff", "setting enhanced customshape geometry" ); + } + SdXMLShapeContext::StartElement(xAttrList); } void SdXMLCustomShapeContext::EndElement() @@ -3918,71 +3918,71 @@ void SdXMLTableShapeContext::StartElement( const css::uno::Reference< css::xml:: AddShape(service); - if( mxShape.is() ) - { - SetLayer(); + if( !mxShape.is() ) + return; - uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); + SetLayer(); + + uno::Reference< beans::XPropertySet > xProps(mxShape, uno::UNO_QUERY); - if(bIsPresShape && xProps.is()) + if(bIsPresShape && xProps.is()) + { + uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); + if( xPropsInfo.is() ) { - uno::Reference< beans::XPropertySetInfo > xPropsInfo( xProps->getPropertySetInfo() ); - if( xPropsInfo.is() ) - { - if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) - xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); + if( !mbIsPlaceholder && xPropsInfo->hasPropertyByName("IsEmptyPresentationObject")) + xProps->setPropertyValue("IsEmptyPresentationObject", css::uno::Any(false) ); - if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) - xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); - } + if( mbIsUserTransformed && xPropsInfo->hasPropertyByName("IsPlaceholderDependent")) + xProps->setPropertyValue("IsPlaceholderDependent", css::uno::Any(false) ); } + } - SetStyle(); + SetStyle(); - if( xProps.is() ) + if( xProps.is() ) + { + if( !msTemplateStyleName.isEmpty() ) try + { + Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW ); + Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() ); + Reference< XNameAccess > xTableFamily( xFamilies->getByName( "table" ), UNO_QUERY_THROW ); + Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW ); + xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) ); + } + catch(const Exception&) + { + DBG_UNHANDLED_EXCEPTION("xmloff.draw"); + } + + const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; + for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ ) { - if( !msTemplateStyleName.isEmpty() ) try + try { - Reference< XStyleFamiliesSupplier > xFamiliesSupp( GetImport().GetModel(), UNO_QUERY_THROW ); - Reference< XNameAccess > xFamilies( xFamiliesSupp->getStyleFamilies() ); - Reference< XNameAccess > xTableFamily( xFamilies->getByName( "table" ), UNO_QUERY_THROW ); - Reference< XStyle > xTableStyle( xTableFamily->getByName( msTemplateStyleName ), UNO_QUERY_THROW ); - xProps->setPropertyValue("TableTemplate", Any( xTableStyle ) ); + const OUString sAPIPropertyName( pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ); + xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) ); } catch(const Exception&) { DBG_UNHANDLED_EXCEPTION("xmloff.draw"); } - - const XMLPropertyMapEntry* pEntry = &aXMLTableShapeAttributes[0]; - for( int i = 0; pEntry->msApiName && (i < 6); i++, pEntry++ ) - { - try - { - const OUString sAPIPropertyName( pEntry->msApiName, pEntry->nApiNameLength, RTL_TEXTENCODING_ASCII_US ); - xProps->setPropertyValue( sAPIPropertyName, Any( maTemplateStylesUsed[i] ) ); - } - catch(const Exception&) - { - DBG_UNHANDLED_EXCEPTION("xmloff.draw"); - } - } } + } - GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); + GetImport().GetShapeImport()->finishShape( mxShape, mxAttrList, mxShapes ); - const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() ); - if( xTableImport.is() && xProps.is() ) - { - uno::Reference< table::XColumnRowRange > xColumnRowRange( - xProps->getPropertyValue("Model"), uno::UNO_QUERY ); + const rtl::Reference< XMLTableImport >& xTableImport( GetImport().GetShapeImport()->GetShapeTableImport() ); + if( xTableImport.is() && xProps.is() ) + { + uno::Reference< table::XColumnRowRange > xColumnRowRange( + xProps->getPropertyValue("Model"), uno::UNO_QUERY ); - if( xColumnRowRange.is() ) - mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange ); + if( xColumnRowRange.is() ) + mxTableImportContext = xTableImport->CreateTableContext( GetPrefix(), GetLocalName(), xColumnRowRange ); - if( mxTableImportContext.is() ) - mxTableImportContext->StartElement( xAttrList ); - } + if( mxTableImportContext.is() ) + mxTableImportContext->StartElement( xAttrList ); } } diff --git a/xmloff/source/draw/ximpshow.cxx b/xmloff/source/draw/ximpshow.cxx index 29da608f20fc..4b36605ac09a 100644 --- a/xmloff/source/draw/ximpshow.cxx +++ b/xmloff/source/draw/ximpshow.cxx @@ -79,109 +79,109 @@ SdXMLShowsContext::SdXMLShowsContext( SdXMLImport& rImport, const Reference< XFa if( xPresentationSupplier.is() ) mpImpl->mxPresProps.set( xPresentationSupplier->getPresentation(), UNO_QUERY ); - if( mpImpl->mxPresProps.is() ) + if( !mpImpl->mxPresProps.is() ) + return; + + bool bAll = true; + uno::Any aAny; + // Per ODF this is default, but we did it wrong before LO 6.0 (tdf#108824) + bool bIsMouseVisible = true; + if (rImport.getGeneratorVersion() < SvXMLImport::LO_6x) + bIsMouseVisible = false; + + // read attributes + for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) { - bool bAll = true; - uno::Any aAny; - // Per ODF this is default, but we did it wrong before LO 6.0 (tdf#108824) - bool bIsMouseVisible = true; - if (rImport.getGeneratorVersion() < SvXMLImport::LO_6x) - bIsMouseVisible = false; + OUString sValue = aIter.toString(); - // read attributes - for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList )) + switch( aIter.getToken() ) { - OUString sValue = aIter.toString(); - - switch( aIter.getToken() ) + case XML_ELEMENT(PRESENTATION, XML_START_PAGE): { - case XML_ELEMENT(PRESENTATION, XML_START_PAGE): - { - mpImpl->mxPresProps->setPropertyValue("FirstPage", Any(sValue) ); - bAll = false; - break; - } - case XML_ELEMENT(PRESENTATION, XML_SHOW): - { - mpImpl->maCustomShowName = sValue; - bAll = false; - break; - } - case XML_ELEMENT(PRESENTATION, XML_PAUSE): - { - Duration aDuration; - if (!::sax::Converter::convertDuration(aDuration, sValue)) - continue; + mpImpl->mxPresProps->setPropertyValue("FirstPage", Any(sValue) ); + bAll = false; + break; + } + case XML_ELEMENT(PRESENTATION, XML_SHOW): + { + mpImpl->maCustomShowName = sValue; + bAll = false; + break; + } + case XML_ELEMENT(PRESENTATION, XML_PAUSE): + { + Duration aDuration; + if (!::sax::Converter::convertDuration(aDuration, sValue)) + continue; - const sal_Int32 nMS = (aDuration.Hours * 60 + - aDuration.Minutes) * 60 + aDuration.Seconds; - mpImpl->mxPresProps->setPropertyValue("Pause", Any(nMS) ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_ANIMATIONS): - { - aAny <<= IsXMLToken( sValue, XML_ENABLED ); - mpImpl->mxPresProps->setPropertyValue("AllowAnimations", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_STAY_ON_TOP): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("IsAlwaysOnTop", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_FORCE_MANUAL): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("IsAutomatic", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_ENDLESS): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("IsEndless", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_FULL_SCREEN): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("IsFullScreen", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_MOUSE_VISIBLE): - { - bIsMouseVisible = IsXMLToken( sValue, XML_TRUE ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_START_WITH_NAVIGATOR): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("StartWithNavigator", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_MOUSE_AS_PEN): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("UsePen", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_TRANSITION_ON_CLICK): - { - aAny <<= IsXMLToken( sValue, XML_ENABLED ); - mpImpl->mxPresProps->setPropertyValue("IsTransitionOnClick", aAny ); - break; - } - case XML_ELEMENT(PRESENTATION, XML_SHOW_LOGO): - { - aAny <<= IsXMLToken( sValue, XML_TRUE ); - mpImpl->mxPresProps->setPropertyValue("IsShowLogo", aAny ); - break; - } + const sal_Int32 nMS = (aDuration.Hours * 60 + + aDuration.Minutes) * 60 + aDuration.Seconds; + mpImpl->mxPresProps->setPropertyValue("Pause", Any(nMS) ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_ANIMATIONS): + { + aAny <<= IsXMLToken( sValue, XML_ENABLED ); + mpImpl->mxPresProps->setPropertyValue("AllowAnimations", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_STAY_ON_TOP): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("IsAlwaysOnTop", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_FORCE_MANUAL): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("IsAutomatic", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_ENDLESS): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("IsEndless", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_FULL_SCREEN): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("IsFullScreen", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_MOUSE_VISIBLE): + { + bIsMouseVisible = IsXMLToken( sValue, XML_TRUE ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_START_WITH_NAVIGATOR): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("StartWithNavigator", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_MOUSE_AS_PEN): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("UsePen", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_TRANSITION_ON_CLICK): + { + aAny <<= IsXMLToken( sValue, XML_ENABLED ); + mpImpl->mxPresProps->setPropertyValue("IsTransitionOnClick", aAny ); + break; + } + case XML_ELEMENT(PRESENTATION, XML_SHOW_LOGO): + { + aAny <<= IsXMLToken( sValue, XML_TRUE ); + mpImpl->mxPresProps->setPropertyValue("IsShowLogo", aAny ); + break; } } - mpImpl->mxPresProps->setPropertyValue("IsShowAll", Any(bAll) ); - mpImpl->mxPresProps->setPropertyValue("IsMouseVisible", Any(bIsMouseVisible) ); } + mpImpl->mxPresProps->setPropertyValue("IsShowAll", Any(bAll) ); + mpImpl->mxPresProps->setPropertyValue("IsMouseVisible", Any(bIsMouseVisible) ); } SdXMLShowsContext::~SdXMLShowsContext() diff --git a/xmloff/source/draw/ximpstyl.cxx b/xmloff/source/draw/ximpstyl.cxx index 59046ccbc8da..11d249726d21 100644 --- a/xmloff/source/draw/ximpstyl.cxx +++ b/xmloff/source/draw/ximpstyl.cxx @@ -479,205 +479,205 @@ void SdXMLPresentationPageLayoutContext::EndElement() // build presentation page layout type here // calc mnTpeId due to content of maList // at the moment only use number of types used there - if( !maList.empty() ) + if( maList.empty() ) + return; + + SdXMLPresentationPlaceholderContext* pObj0 = maList[ 0 ].get(); + if( pObj0->GetName() == "handout" ) { - SdXMLPresentationPlaceholderContext* pObj0 = maList[ 0 ].get(); - if( pObj0->GetName() == "handout" ) + switch( maList.size() ) + { + case 1: + mnTypeId = AUTOLAYOUT_HANDOUT1; + break; + case 2: + mnTypeId = AUTOLAYOUT_HANDOUT2; + break; + case 3: + mnTypeId = AUTOLAYOUT_HANDOUT3; + break; + case 4: + mnTypeId = AUTOLAYOUT_HANDOUT4; + break; + case 9: + mnTypeId = AUTOLAYOUT_HANDOUT9; + break; + default: + mnTypeId = AUTOLAYOUT_HANDOUT6; + } + } + else + { + switch( maList.size() ) { - switch( maList.size() ) - { case 1: - mnTypeId = AUTOLAYOUT_HANDOUT1; - break; - case 2: - mnTypeId = AUTOLAYOUT_HANDOUT2; - break; - case 3: - mnTypeId = AUTOLAYOUT_HANDOUT3; - break; - case 4: - mnTypeId = AUTOLAYOUT_HANDOUT4; - break; - case 9: - mnTypeId = AUTOLAYOUT_HANDOUT9; + { + if( pObj0->GetName() == "title" ) + { + mnTypeId = AUTOLAYOUT_TITLE_ONLY; + } + else + { + mnTypeId = AUTOLAYOUT_ONLY_TEXT; + } break; - default: - mnTypeId = AUTOLAYOUT_HANDOUT6; } - } - else - { - switch( maList.size() ) + case 2: { - case 1: + SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); + + if( pObj1->GetName() == "subtitle" ) { - if( pObj0->GetName() == "title" ) + mnTypeId = AUTOLAYOUT_TITLE; + } + else if( pObj1->GetName() == "outline" ) + { + mnTypeId = AUTOLAYOUT_TITLE_CONTENT; + } + else if( pObj1->GetName() == "chart" ) + { + mnTypeId = AUTOLAYOUT_CHART; + } + else if( pObj1->GetName() == "table" ) + { + mnTypeId = AUTOLAYOUT_TAB; + } + else if( pObj1->GetName() == "object" ) + { + mnTypeId = AUTOLAYOUT_OBJ; + } + else if( pObj1->GetName() == "vertical_outline" ) + { + if( pObj0->GetName() == "vertical_title" ) { - mnTypeId = AUTOLAYOUT_TITLE_ONLY; + mnTypeId = AUTOLAYOUT_VTITLE_VCONTENT; } else { - mnTypeId = AUTOLAYOUT_ONLY_TEXT; + mnTypeId = AUTOLAYOUT_TITLE_VCONTENT; } - break; } - case 2: + else { - SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); + mnTypeId = AUTOLAYOUT_NOTES; + } + break; + } + case 3: + { + SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); + SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get(); - if( pObj1->GetName() == "subtitle" ) - { - mnTypeId = AUTOLAYOUT_TITLE; - } - else if( pObj1->GetName() == "outline" ) - { - mnTypeId = AUTOLAYOUT_TITLE_CONTENT; - } - else if( pObj1->GetName() == "chart" ) + if( pObj1->GetName() == "outline" ) + { + if( pObj2->GetName() == "outline" ) { - mnTypeId = AUTOLAYOUT_CHART; + mnTypeId = AUTOLAYOUT_TITLE_2CONTENT; } - else if( pObj1->GetName() == "table" ) + else if( pObj2->GetName() == "chart" ) { - mnTypeId = AUTOLAYOUT_TAB; + mnTypeId = AUTOLAYOUT_TEXTCHART; } - else if( pObj1->GetName() == "object" ) + else if( pObj2->GetName() == "graphic" ) { - mnTypeId = AUTOLAYOUT_OBJ; + mnTypeId = AUTOLAYOUT_TEXTCLIP; } - else if( pObj1->GetName() == "vertical_outline" ) + else { - if( pObj0->GetName() == "vertical_title" ) + if(pObj1->GetX() < pObj2->GetX()) { - mnTypeId = AUTOLAYOUT_VTITLE_VCONTENT; + mnTypeId = AUTOLAYOUT_TEXTOBJ; // outline left, object right } else { - mnTypeId = AUTOLAYOUT_TITLE_VCONTENT; + mnTypeId = AUTOLAYOUT_TEXTOVEROBJ; // outline top, object right } } - else - { - mnTypeId = AUTOLAYOUT_NOTES; - } - break; } - case 3: + else if( pObj1->GetName() == "chart" ) { - SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); - SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get(); - - if( pObj1->GetName() == "outline" ) - { - if( pObj2->GetName() == "outline" ) - { - mnTypeId = AUTOLAYOUT_TITLE_2CONTENT; - } - else if( pObj2->GetName() == "chart" ) - { - mnTypeId = AUTOLAYOUT_TEXTCHART; - } - else if( pObj2->GetName() == "graphic" ) - { - mnTypeId = AUTOLAYOUT_TEXTCLIP; - } - else - { - if(pObj1->GetX() < pObj2->GetX()) - { - mnTypeId = AUTOLAYOUT_TEXTOBJ; // outline left, object right - } - else - { - mnTypeId = AUTOLAYOUT_TEXTOVEROBJ; // outline top, object right - } - } - } - else if( pObj1->GetName() == "chart" ) - { - mnTypeId = AUTOLAYOUT_CHARTTEXT; - } - else if( pObj1->GetName() == "graphic" ) - { - if( pObj2->GetName() == "vertical_outline" ) - { - mnTypeId = AUTOLAYOUT_TITLE_2VTEXT; - } - else - { - mnTypeId = AUTOLAYOUT_CLIPTEXT; - } - } - else if( pObj1->GetName() == "vertical_outline" ) + mnTypeId = AUTOLAYOUT_CHARTTEXT; + } + else if( pObj1->GetName() == "graphic" ) + { + if( pObj2->GetName() == "vertical_outline" ) { - mnTypeId = AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT; + mnTypeId = AUTOLAYOUT_TITLE_2VTEXT; } else { - if(pObj1->GetX() < pObj2->GetX()) - { - mnTypeId = AUTOLAYOUT_OBJTEXT; // left, right - } - else - { - mnTypeId = AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT; // top, bottom - } + mnTypeId = AUTOLAYOUT_CLIPTEXT; } - break; } - case 4: + else if( pObj1->GetName() == "vertical_outline" ) { - SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); - SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get(); - - if( pObj1->GetName() == "object" ) + mnTypeId = AUTOLAYOUT_VTITLE_VCONTENT_OVER_VCONTENT; + } + else + { + if(pObj1->GetX() < pObj2->GetX()) { - if(pObj1->GetX() < pObj2->GetX()) - { - mnTypeId = AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT; - } - else - { - mnTypeId = AUTOLAYOUT_TITLE_2CONTENT_CONTENT; - } + mnTypeId = AUTOLAYOUT_OBJTEXT; // left, right } else { - mnTypeId = AUTOLAYOUT_TITLE_CONTENT_2CONTENT; + mnTypeId = AUTOLAYOUT_TITLE_CONTENT_OVER_CONTENT; // top, bottom } - break; } - case 5: - { - SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); + break; + } + case 4: + { + SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); + SdXMLPresentationPlaceholderContext* pObj2 = maList[ 2 ].get(); - if( pObj1->GetName() == "object" ) + if( pObj1->GetName() == "object" ) + { + if(pObj1->GetX() < pObj2->GetX()) { - mnTypeId = AUTOLAYOUT_TITLE_4CONTENT; + mnTypeId = AUTOLAYOUT_TITLE_2CONTENT_OVER_CONTENT; } else { - mnTypeId = AUTOLAYOUT_4CLIPART; + mnTypeId = AUTOLAYOUT_TITLE_2CONTENT_CONTENT; } - break; - } - case 7: + else { - mnTypeId = AUTOLAYOUT_4CLIPART; // FIXME: not AUTOLAYOUT_TITLE_6CONTENT? - break; + mnTypeId = AUTOLAYOUT_TITLE_CONTENT_2CONTENT; } - default: + break; + } + case 5: + { + SdXMLPresentationPlaceholderContext* pObj1 = maList[ 1 ].get(); + + if( pObj1->GetName() == "object" ) + { + mnTypeId = AUTOLAYOUT_TITLE_4CONTENT; + } + else { - mnTypeId = AUTOLAYOUT_NONE; - break; + mnTypeId = AUTOLAYOUT_4CLIPART; } + break; + + } + case 7: + { + mnTypeId = AUTOLAYOUT_4CLIPART; // FIXME: not AUTOLAYOUT_TITLE_6CONTENT? + break; + } + default: + { + mnTypeId = AUTOLAYOUT_NONE; + break; } } - - // release remembered contexts, they are no longer needed - maList.clear(); } + + // release remembered contexts, they are no longer needed + maList.clear(); } SdXMLPresentationPlaceholderContext::SdXMLPresentationPlaceholderContext( |