summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2018-11-16 16:35:09 +0100
committerJan Holesovsky <kendy@collabora.com>2018-12-10 13:01:57 +0100
commitfc0d2f1510d34d675c35d57c21da82612053cf85 (patch)
treef486f226d2dd6d24d65b8be826d3c7a6e39750ed
parente54700c45b22b10ec4f364800e0ad7c0627a6d3b (diff)
lok: Implement SVG export for Calc (SelectionOnly mode)
Change-Id: Ic305e5305890fd1efa3a3130e5216f9c672870e5
-rw-r--r--desktop/source/lib/init.cxx18
-rw-r--r--filter/Configuration_filter.mk2
-rw-r--r--filter/source/config/fragments/filters/calc_svg_Export.xcu30
-rw-r--r--filter/source/svg/svgexport.cxx20
-rw-r--r--filter/source/svg/svgfilter.cxx18
-rw-r--r--filter/source/svg/svgfilter.hxx18
6 files changed, 72 insertions, 34 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index def83bda5dca..42a06ce2be6c 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -2621,13 +2621,19 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aOutStream);
utl::MediaDescriptor aMediaDescriptor;
- if (doc_getDocumentType(pThis) == LOK_DOCTYPE_PRESENTATION)
- {
- aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
- }
- else if(doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
+ switch (doc_getDocumentType(pThis))
{
- aMediaDescriptor["FilterName"] <<= OUString("writer_svg_Export");
+ case LOK_DOCTYPE_PRESENTATION:
+ aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
+ break;
+ case LOK_DOCTYPE_TEXT:
+ aMediaDescriptor["FilterName"] <<= OUString("writer_svg_Export");
+ break;
+ case LOK_DOCTYPE_SPREADSHEET:
+ aMediaDescriptor["FilterName"] <<= OUString("calc_svg_Export");
+ break;
+ default:
+ SAL_WARN("lok", "Failed to render shape selection: Document type is not supported");
}
aMediaDescriptor["SelectionOnly"] <<= true;
aMediaDescriptor["OutputStream"] <<= xOut;
diff --git a/filter/Configuration_filter.mk b/filter/Configuration_filter.mk
index ef8d775432c2..f7ebc3604c9b 100644
--- a/filter/Configuration_filter.mk
+++ b/filter/Configuration_filter.mk
@@ -796,11 +796,13 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writergraphics
# fcfg_calcgraphics
$(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_calcgraphics_types.xcu,filter/source/config/fragments/types,\
png_Portable_Network_Graphic \
+ svg_Scalable_Vector_Graphics \
))
$(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_calcgraphics_filters.xcu,filter/source/config/fragments/filters,\
calc_jpg_Export \
calc_png_Export \
+ calc_svg_Export \
))
# fcfg_internalgraphics
diff --git a/filter/source/config/fragments/filters/calc_svg_Export.xcu b/filter/source/config/fragments/filters/calc_svg_Export.xcu
new file mode 100644
index 000000000000..703ce82e9778
--- /dev/null
+++ b/filter/source/config/fragments/filters/calc_svg_Export.xcu
@@ -0,0 +1,30 @@
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+ <node oor:name="calc_svg_Export" oor:op="replace">
+ <prop oor:name="Flags"><value>EXPORT ALIEN 3RDPARTYFILTER INTERNAL NOTINFILEDIALOG</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Draw.SVGFilter</value></prop>
+ <prop oor:name="UserData"><value></value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">SVG - Scalable Vector Graphics</value>
+ </prop>
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>svg_Scalable_Vector_Graphics</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
+ </node>
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index ecf12a7d8c7d..852411d0e380 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -519,13 +519,13 @@ bool SVGFilter::implExport( const Sequence< PropertyValue >& rDescriptor )
}
}
- if(mbWriterFilter)
- return implExportWriter(xOStm);
+ if(mbWriterOrCalcFilter)
+ return implExportWriterOrCalc(xOStm);
- return implExportImpressDraw(xOStm);
+ return implExportImpressOrDraw(xOStm);
}
-bool SVGFilter::implExportImpressDraw( const Reference< XOutputStream >& rxOStm)
+bool SVGFilter::implExportImpressOrDraw( const Reference< XOutputStream >& rxOStm)
{
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ) ;
bool bRet = false;
@@ -619,7 +619,7 @@ bool SVGFilter::implExportImpressDraw( const Reference< XOutputStream >& rxOStm)
}
-bool SVGFilter::implExportWriter( const Reference< XOutputStream >& rxOStm )
+bool SVGFilter::implExportWriterOrCalc( const Reference< XOutputStream >& rxOStm )
{
Reference< XComponentContext > xContext( ::comphelper::getProcessComponentContext() ) ;
bool bRet = false;
@@ -776,10 +776,10 @@ bool SVGFilter::implExportDocument()
}
}
- if(mbWriterFilter)
- implExportDocumentHeaderWriter(nDocX, nDocY, nDocWidth, nDocHeight);
+ if(mbWriterOrCalcFilter)
+ implExportDocumentHeaderWriterOrCalc(nDocX, nDocY, nDocWidth, nDocHeight);
else
- implExportDocumentHeaderImpressDraw(nDocX, nDocY, nDocWidth, nDocHeight);
+ implExportDocumentHeaderImpressOrDraw(nDocX, nDocY, nDocWidth, nDocHeight);
if( implLookForFirstVisiblePage() ) // OK! We found at least one visible page.
@@ -840,7 +840,7 @@ bool SVGFilter::implExportDocument()
return bRet;
}
-void SVGFilter::implExportDocumentHeaderImpressDraw(sal_Int32 nDocX, sal_Int32 nDocY,
+void SVGFilter::implExportDocumentHeaderImpressOrDraw(sal_Int32 nDocX, sal_Int32 nDocY,
sal_Int32 nDocWidth, sal_Int32 nDocHeight)
{
const Reference< XExtendedDocumentHandler > xExtDocHandler( mpSVGExport->GetDocHandler(), UNO_QUERY );
@@ -933,7 +933,7 @@ void SVGFilter::implExportDocumentHeaderImpressDraw(sal_Int32 nDocX, sal_Int32 n
}
}
-void SVGFilter::implExportDocumentHeaderWriter(sal_Int32 nDocX, sal_Int32 nDocY,
+void SVGFilter::implExportDocumentHeaderWriterOrCalc(sal_Int32 nDocX, sal_Int32 nDocY,
sal_Int32 nDocWidth, sal_Int32 nDocHeight)
{
OUString aAttr;
diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx
index a98d0fd6f326..40c8490a43cd 100644
--- a/filter/source/svg/svgfilter.cxx
+++ b/filter/source/svg/svgfilter.cxx
@@ -78,7 +78,7 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mbExportShapeSelection(false),
maFilterData(),
mxDefaultPage(),
- mbWriterFilter(false),
+ mbWriterOrCalcFilter(false),
mpDefaultSdrPage( nullptr ),
mpSdrModel( nullptr ),
mbPresentation( false ),
@@ -97,10 +97,10 @@ SVGFilter::~SVGFilter()
sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescriptor )
{
- mbWriterFilter = false;
+ mbWriterOrCalcFilter = false;
if(mxDstDoc.is()) // Import works for Impress / draw only
- return filterImpressDraw(rDescriptor);
+ return filterImpressOrDraw(rDescriptor);
if(mxSrcDoc.is())
{
@@ -110,20 +110,20 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
{
OUString sFilterName;
rDescriptor[nInd].Value >>= sFilterName;
- if(sFilterName == "writer_svg_Export")
+ if(sFilterName != "impress_svg_Export")
{
- mbWriterFilter = true;
- return filterWriter(rDescriptor);
+ mbWriterOrCalcFilter = true;
+ return filterWriterOrCalc(rDescriptor);
}
break;
}
}
- return filterImpressDraw(rDescriptor);
+ return filterImpressOrDraw(rDescriptor);
}
return false;
}
-sal_Bool SVGFilter::filterImpressDraw( const Sequence< PropertyValue >& rDescriptor )
+sal_Bool SVGFilter::filterImpressOrDraw( const Sequence< PropertyValue >& rDescriptor )
{
SolarMutexGuard aGuard;
vcl::Window* pFocusWindow = Application::GetFocusWindow();
@@ -314,7 +314,7 @@ sal_Bool SVGFilter::filterImpressDraw( const Sequence< PropertyValue >& rDescrip
return bRet;
}
-sal_Bool SVGFilter::filterWriter( const Sequence< PropertyValue >& rDescriptor )
+sal_Bool SVGFilter::filterWriterOrCalc( const Sequence< PropertyValue >& rDescriptor )
{
bool bSelectionOnly = false;
diff --git a/filter/source/svg/svgfilter.hxx b/filter/source/svg/svgfilter.hxx
index 76121ce04e72..bd7589cb5f20 100644
--- a/filter/source/svg/svgfilter.hxx
+++ b/filter/source/svg/svgfilter.hxx
@@ -215,7 +215,7 @@ private:
Reference< XDrawPage > mxDefaultPage;
std::vector< Reference< XDrawPage > > mSelectedPages;
- bool mbWriterFilter;
+ bool mbWriterOrCalcFilter;
/// Impress / draw only members
@@ -240,8 +240,8 @@ private:
/// @throws css::uno::RuntimeException
bool implExport( const Sequence< PropertyValue >& rDescriptor );
- bool implExportImpressDraw( const Reference< XOutputStream >& rxOStm );
- bool implExportWriter( const Reference< XOutputStream >& rxOStm );
+ bool implExportImpressOrDraw( const Reference< XOutputStream >& rxOStm );
+ bool implExportWriterOrCalc( const Reference< XOutputStream >& rxOStm );
static Reference< XWriter > implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm );
void implGetPagePropSet( const Reference< XDrawPage > & rxPage );
@@ -253,10 +253,10 @@ private:
void implGenerateScript();
bool implExportDocument();
- void implExportDocumentHeaderImpressDraw(sal_Int32 nDocX, sal_Int32 nDocY,
- sal_Int32 nDocWidth, sal_Int32 nDocHeight);
- void implExportDocumentHeaderWriter(sal_Int32 nDocX, sal_Int32 nDocY,
- sal_Int32 nDocWidth, sal_Int32 nDocHeight);
+ void implExportDocumentHeaderImpressOrDraw(sal_Int32 nDocX, sal_Int32 nDocY,
+ sal_Int32 nDocWidth, sal_Int32 nDocHeight);
+ void implExportDocumentHeaderWriterOrCalc(sal_Int32 nDocX, sal_Int32 nDocY,
+ sal_Int32 nDocWidth, sal_Int32 nDocHeight);
void implExportAnimations();
bool implExportMasterPages( const std::vector< Reference< XDrawPage > >& rxPages,
@@ -291,8 +291,8 @@ private:
static bool isStreamGZip(const css::uno::Reference<css::io::XInputStream>& xInput);
static bool isStreamSvg(const css::uno::Reference<css::io::XInputStream>& xInput);
- sal_Bool filterImpressDraw( const Sequence< PropertyValue >& rDescriptor );
- sal_Bool filterWriter( const Sequence< PropertyValue >& rDescriptor );
+ sal_Bool filterImpressOrDraw( const Sequence< PropertyValue >& rDescriptor );
+ sal_Bool filterWriterOrCalc( const Sequence< PropertyValue >& rDescriptor );
protected: