diff options
Diffstat (limited to 'filter/source/svg/svgexport.cxx')
-rw-r--r-- | filter/source/svg/svgexport.cxx | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx index 852411d0e380..49e52bf6af27 100644 --- a/filter/source/svg/svgexport.cxx +++ b/filter/source/svg/svgexport.cxx @@ -32,6 +32,8 @@ #include <com/sun/star/text/textfield/Type.hpp> #include <com/sun/star/util/MeasureUnit.hpp> #include <com/sun/star/xml/sax/Writer.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/drawing/ShapeCollection.hpp> #include <comphelper/lok.hxx> #include <rtl/bootstrap.hxx> @@ -52,6 +54,8 @@ #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> #include <xmloff/animationexport.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdpage.hxx> #include <memory> @@ -519,7 +523,7 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor ) } } - if(mbWriterOrCalcFilter) + if(mbWriterFilter || mbCalcFilter) return implExportWriterOrCalc(xOStm); return implExportImpressOrDraw(xOStm); @@ -663,6 +667,40 @@ bool SVGFilter::implExportWriterOrCalc( const Reference< XOutputStream >& rxOStm return bRet; } +bool SVGFilter::implExportWriterTextGraphic( const Reference< view::XSelectionSupplier >& xSelectionSupplier ) +{ + Any selection = xSelectionSupplier->getSelection(); + uno::Reference<lang::XServiceInfo> xSelection; + selection >>= xSelection; + if (xSelection.is() && xSelection->supportsService("com.sun.star.text.TextGraphicObject")) + { + uno::Reference<beans::XPropertySet> xPropertySet(xSelection, uno::UNO_QUERY); + uno::Reference<graphic::XGraphic> xGraphic; + xPropertySet->getPropertyValue("Graphic") >>= xGraphic; + + if (!xGraphic.is()) + return false; + + const Graphic aGraphic(xGraphic); + + // Calculate size from Graphic + Point aPos( OutputDevice::LogicToLogic(aGraphic.GetPrefMapMode().GetOrigin(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) ); + Size aSize( OutputDevice::LogicToLogic(aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), MapMode(MapUnit::Map100thMM)) ); + + SdrGrafObj* pGraphicObj = new SdrGrafObj(aGraphic, tools::Rectangle( aPos, aSize )); + uno::Reference< drawing::XShape > xShape = GetXShapeForSdrObject(pGraphicObj); + uno::Reference< XPropertySet > xShapePropSet(xShape, uno::UNO_QUERY); + css::awt::Rectangle aBoundRect (aPos.X(), aPos.Y(), aSize.Width(), aSize.Height()); + xShapePropSet->setPropertyValue("BoundRect", uno::Any(aBoundRect)); + xShapePropSet->setPropertyValue("Graphic", uno::Any(xGraphic)); + + maShapeSelection = drawing::ShapeCollection::create(comphelper::getProcessComponentContext()); + maShapeSelection->add(xShape); + } + + return true; +} + Reference< XWriter > SVGFilter::implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm ) { @@ -776,7 +814,7 @@ bool SVGFilter::implExportDocument() } } - if(mbWriterOrCalcFilter) + if(mbWriterFilter || mbCalcFilter) implExportDocumentHeaderWriterOrCalc(nDocX, nDocY, nDocWidth, nDocHeight); else implExportDocumentHeaderImpressOrDraw(nDocX, nDocY, nDocWidth, nDocHeight); @@ -2050,6 +2088,22 @@ bool SVGFilter::implCreateObjectsFromShape( const Reference< XDrawPage > & rxPag { Graphic aGraphic( SdrExchangeView::GetObjGraphic( pObj->GetModel(), pObj ) ); + // Writer graphic shapes are handled differently + if( mbWriterFilter && aGraphic.GetType() == GraphicType::NONE ) + { + if (rxShape->getShapeType() == "com.sun.star.drawing.GraphicObjectShape") + { + uno::Reference<beans::XPropertySet> xPropertySet(rxShape, uno::UNO_QUERY); + uno::Reference<graphic::XGraphic> xGraphic; + xPropertySet->getPropertyValue("Graphic") >>= xGraphic; + + if (!xGraphic.is()) + return false; + + aGraphic = Graphic(xGraphic); + } + } + if( aGraphic.GetType() != GraphicType::NONE ) { if( aGraphic.GetType() == GraphicType::Bitmap ) |