diff options
author | Henning Brinkmann[hbrinkm] <hbrinkm@openoffice.org> | 2009-12-08 14:48:12 +0100 |
---|---|---|
committer | Henning Brinkmann[hbrinkm] <hbrinkm@openoffice.org> | 2009-12-08 14:48:12 +0100 |
commit | 09a845b6b6be65d27671f59a6444779c480bcd08 (patch) | |
tree | 996e5b0e60c7acbe5d0defb52a4a5cc96f68dd6f /writerfilter/source/dmapper/GraphicImport.cxx | |
parent | writerfilter07: model_preprocessed needs to be generated from only one play w... (diff) | |
parent | #i10000# fix for wrong merge (diff) | |
download | core-09a845b6b6be65d27671f59a6444779c480bcd08.tar.gz core-09a845b6b6be65d27671f59a6444779c480bcd08.zip |
writerfilter07: merged DEV300_m66
Diffstat (limited to 'writerfilter/source/dmapper/GraphicImport.cxx')
-rw-r--r-- | writerfilter/source/dmapper/GraphicImport.cxx | 184 |
1 files changed, 138 insertions, 46 deletions
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx index 0f33171a2c2b..94c60af6413b 100644 --- a/writerfilter/source/dmapper/GraphicImport.cxx +++ b/writerfilter/source/dmapper/GraphicImport.cxx @@ -29,7 +29,9 @@ * ************************************************************************/ -#include <GraphicImport.hxx> +#include "GraphicImport.hxx" +#include "GraphicHelpers.hxx" + #include <dmapper/DomainMapper.hxx> #include <PropertyMap.hxx> #include <doctok/resourceids.hxx> @@ -1043,35 +1045,79 @@ void GraphicImport::attribute(Id nName, Value & val) case NS_ooxml::LN_shape: /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ { - val.getAny() >>= m_xShape; + uno::Reference< drawing::XShape> xShape; + val.getAny( ) >>= xShape; - if (m_xShape.is()) + if ( xShape.is( ) ) { - uno::Reference< beans::XPropertySet > xShapeProps - (m_xShape, uno::UNO_QUERY_THROW); - - PropertyNameSupplier& rPropNameSupplier = - PropertyNameSupplier::GetPropertyNameSupplier(); - xShapeProps->setPropertyValue - (rPropNameSupplier.GetName(PROP_ANCHOR_TYPE), - uno::makeAny - (text::TextContentAnchorType_AS_CHARACTER)); - xShapeProps->setPropertyValue - (rPropNameSupplier.GetName(PROP_TEXT_RANGE), - uno::makeAny - (m_pImpl->rDomainMapper.GetCurrentTextRange())); - - awt::Point aPoint(m_xShape->getPosition()); - awt::Size aSize(m_xShape->getSize()); - - if (m_pImpl->isXSizeValid()) - aSize.Width = m_pImpl->getXSize(); - if (m_pImpl->isYSizeValis()) - aSize.Height = m_pImpl->getYSize(); - - m_xShape->setSize(aSize); - - m_pImpl->bIsGraphic = true; + // Is it a graphic image + bool bUseShape = true; + try + { + uno::Reference< beans::XPropertySet > xShapeProps + ( xShape, uno::UNO_QUERY_THROW ); + + rtl::OUString sUrl; + xShapeProps->getPropertyValue( rtl::OUString::createFromAscii( "GraphicURL" ) ) >>= sUrl; + + ::com::sun::star::beans::PropertyValues aMediaProperties( 1 ); + aMediaProperties[0].Name = rtl::OUString::createFromAscii( "URL" ); + aMediaProperties[0].Value <<= sUrl; + + m_xGraphicObject = createGraphicObject( aMediaProperties ); + + bUseShape = !m_xGraphicObject.is( ); + + if ( !bUseShape ) + { + // Define the object size + uno::Reference< beans::XPropertySet > xGraphProps( m_xGraphicObject, + uno::UNO_QUERY ); + awt::Size aSize = xShape->getSize( ); + xGraphProps->setPropertyValue( rtl::OUString::createFromAscii( "Height" ), + uno::makeAny( aSize.Height ) ); + xGraphProps->setPropertyValue( rtl::OUString::createFromAscii( "Width" ), + uno::makeAny( aSize.Width ) ); + } + } + catch( const beans::UnknownPropertyException e ) + { + // It isn't a graphic image + } + + if ( bUseShape ) + m_xShape = xShape; + + + if ( m_xShape.is( ) ) + { + uno::Reference< beans::XPropertySet > xShapeProps + (m_xShape, uno::UNO_QUERY_THROW); + + + PropertyNameSupplier& rPropNameSupplier = + PropertyNameSupplier::GetPropertyNameSupplier(); + xShapeProps->setPropertyValue + (rPropNameSupplier.GetName(PROP_ANCHOR_TYPE), + uno::makeAny + (text::TextContentAnchorType_AS_CHARACTER)); + xShapeProps->setPropertyValue + (rPropNameSupplier.GetName(PROP_TEXT_RANGE), + uno::makeAny + (m_pImpl->rDomainMapper.GetCurrentTextRange())); + + awt::Point aPoint(m_xShape->getPosition()); + awt::Size aSize(m_xShape->getSize()); + + if (m_pImpl->isXSizeValid()) + aSize.Width = m_pImpl->getXSize(); + if (m_pImpl->isYSizeValis()) + aSize.Height = m_pImpl->getYSize(); + + m_xShape->setSize(aSize); + + m_pImpl->bIsGraphic = true; + } } } break; @@ -1340,8 +1386,6 @@ void GraphicImport::sprm(Sprm & rSprm) case NS_ooxml::LN_CT_NonVisualGraphicFrameProperties_graphicFrameLocks:// 90657 case NS_ooxml::LN_CT_Inline_a_graphic:// 90915 case NS_ooxml::LN_CT_Anchor_simplePos_elem: // 90975; - case NS_ooxml::LN_CT_Anchor_positionH: // 90976; - case NS_ooxml::LN_CT_Anchor_positionV: // 90977; case NS_ooxml::LN_CT_Anchor_extent: // 90978; case NS_ooxml::LN_CT_Anchor_effectExtent: // 90979; case NS_ooxml::LN_EG_WrapType_wrapSquare: // 90945; @@ -1363,6 +1407,36 @@ void GraphicImport::sprm(Sprm & rSprm) } } break; + case NS_ooxml::LN_CT_Anchor_positionH: // 90976; + { + // Use a special handler for the positionning + PositionHandlerPtr pHandler( new PositionHandler ); + writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); + if( pProperties.get( ) ) + { + pProperties->resolve( *pHandler ); + + m_pImpl->nHoriRelation = pHandler->m_nRelation; + m_pImpl->nHoriOrient = pHandler->m_nOrient; + m_pImpl->nLeftPosition = pHandler->m_nPosition; + } + } + break; + case NS_ooxml::LN_CT_Anchor_positionV: // 90977; + { + // Use a special handler for the positionning + PositionHandlerPtr pHandler( new PositionHandler ); + writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); + if( pProperties.get( ) ) + { + pProperties->resolve( *pHandler ); + + m_pImpl->nVertRelation = pHandler->m_nRelation; + m_pImpl->nVertOrient = pHandler->m_nOrient; + m_pImpl->nTopPosition = pHandler->m_nPosition; + } + } + break; case 0x271b: case 0x271c: { @@ -1434,11 +1508,9 @@ void lcl_CalcCrop( sal_Int32& nCrop, sal_Int32 nRef ) + (((nCrop & 0xffff) * nRef ) >> 16); } -/*-- 01.11.2006 09:45:02--------------------------------------------------- - - -----------------------------------------------------------------------*/ -void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t /*ref*/) +uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const beans::PropertyValues& aMediaProperties ) { + uno::Reference< text::XTextContent > xGraphicObject; try { uno::Reference< graphic::XGraphicProvider > xGraphicProvider( @@ -1446,28 +1518,22 @@ void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Referen ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.graphic.GraphicProvider")), m_xComponentContext), uno::UNO_QUERY_THROW ); - uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len, m_pImpl->bIsBitmap ); - - PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); - ::com::sun::star::beans::PropertyValues aMediaProperties( 1 ); - aMediaProperties[0].Name = rPropNameSupplier.GetName(PROP_INPUT_STREAM); - aMediaProperties[0].Value <<= xIStream; uno::Reference< graphic::XGraphic > xGraphic = xGraphicProvider->queryGraphic( aMediaProperties ); - // + if(xGraphic.is()) { - clog << "Graphic loaded" << endl; + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); uno::Reference< beans::XPropertySet > xGraphicObjectProperties( m_xTextFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextGraphicObject"))), - uno::UNO_QUERY_THROW); + uno::UNO_QUERY_THROW); xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_GRAPHIC), uno::makeAny( xGraphic )); xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_ANCHOR_TYPE), uno::makeAny( m_pImpl->eGraphicImportType == IMPORT_AS_SHAPE || m_pImpl->eGraphicImportType == IMPORT_AS_DETECTED_ANCHOR ? text::TextContentAnchorType_AT_CHARACTER : text::TextContentAnchorType_AS_CHARACTER )); - m_xGraphicObject = uno::Reference< text::XTextContent >( xGraphicObjectProperties, uno::UNO_QUERY_THROW ); + xGraphicObject = uno::Reference< text::XTextContent >( xGraphicObjectProperties, uno::UNO_QUERY_THROW ); //shapes have only one border, PICF might have four table::BorderLine aBorderLine; @@ -1659,11 +1725,28 @@ void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Referen } } } - catch( const uno::Exception& ) + catch( const uno::Exception& e ) { - clog << __FILE__ << __LINE__ << " failed!" << endl; + clog << __FILE__ << ":" << __LINE__ << " failed. Message :" ; + clog << rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr( ) << endl; } + return xGraphicObject; +} +/*-- 01.11.2006 09:45:02--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void GraphicImport::data(const sal_uInt8* buf, size_t len, writerfilter::Reference<Properties>::Pointer_t /*ref*/) +{ + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); + + ::com::sun::star::beans::PropertyValues aMediaProperties( 1 ); + aMediaProperties[0].Name = rPropNameSupplier.GetName(PROP_INPUT_STREAM); + + uno::Reference< io::XInputStream > xIStream = new XInputStreamHelper( buf, len, m_pImpl->bIsBitmap ); + aMediaProperties[0].Value <<= xIStream; + + m_xGraphicObject = createGraphicObject( aMediaProperties ); } /*-- 01.11.2006 09:45:03--------------------------------------------------- @@ -1737,6 +1820,15 @@ void GraphicImport::substream(Id /*name*/, ::writerfilter::Reference<Stream>::Po void GraphicImport::info(const string & /*info*/) { } + +void GraphicImport::startShape( ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > /*xShape*/ ) +{ +} + +void GraphicImport::endShape( ) +{ +} + /*-- 09.08.2007 10:17:00--------------------------------------------------- -----------------------------------------------------------------------*/ |