Kaydet (Commit) b052974a authored tarafından Tamás Zolnai's avatar Tamás Zolnai

lok: Implement SVG export for Writer (SelectionOnly mode)

Separate generic code from Impress / Draw specific code
and implement shape selection handling in case of Writer.
This is an internal filter, so it can be called only from
the code.

Change-Id: I807e04a0949530d6029037bb964c10c80197ff33
Reviewed-on: https://gerrit.libreoffice.org/65174
Tested-by: Jenkins
Reviewed-by: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst 68aef0a3
......@@ -2618,7 +2618,14 @@ static size_t doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char** pOu
uno::Reference<io::XOutputStream> xOut = new utl::OOutputStreamWrapper(aOutStream);
utl::MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
if (doc_getDocumentType(pThis) == LOK_DOCTYPE_PRESENTATION)
{
aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export");
}
else if(doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT)
{
aMediaDescriptor["FilterName"] <<= OUString("writer_svg_Export");
}
aMediaDescriptor["SelectionOnly"] <<= true;
aMediaDescriptor["OutputStream"] <<= xOut;
......
......@@ -790,11 +790,13 @@ $(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_impressgraphic
$(eval $(call filter_Configuration_add_types,fcfg_langpack,fcfg_writergraphics_types.xcu,filter/source/config/fragments/types,\
jpg_JPEG \
png_Portable_Network_Graphic \
svg_Scalable_Vector_Graphics \
))
$(eval $(call filter_Configuration_add_filters,fcfg_langpack,fcfg_writergraphics_filters.xcu,filter/source/config/fragments/filters,\
writer_jpg_Export \
writer_png_Export \
writer_svg_Export \
))
# fcfg_calcgraphics
......
<!--
* 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="writer_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.text.TextDocument</value></prop>
</node>
This diff is collapsed.
......@@ -24,6 +24,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/servicedecl.hxx>
#include <uno/environment.h>
#include <com/sun/star/text/XTextDocument.hpp>
#include <com/sun/star/drawing/XDrawPage.hpp>
#include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
#include <com/sun/star/drawing/XDrawView.hpp>
......@@ -78,17 +79,19 @@ SVGFilter::SVGFilter( const Reference< XComponentContext >& rxCtx ) :
mpSVGExport( nullptr ),
mpSVGFontExport( nullptr ),
mpSVGWriter( nullptr ),
mpDefaultSdrPage( nullptr ),
mbPresentation( false ),
mbSinglePage( false ),
mnVisiblePage( -1 ),
mpObjects( nullptr ),
mxSrcDoc(),
mxDstDoc(),
mxDefaultPage(),
maFilterData(),
maShapeSelection(),
mbExportShapeSelection(false),
maFilterData(),
mxDefaultPage(),
mbWriterFilter(false),
mpDefaultSdrPage( nullptr ),
mpSdrModel( nullptr ),
mbPresentation( false ),
maOldFieldHdl()
{
}
......@@ -103,6 +106,34 @@ SVGFilter::~SVGFilter()
}
sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescriptor )
{
mbWriterFilter = false;
if(mxDstDoc.is()) // Import works for Impress / draw only
return filterImpressDraw(rDescriptor);
if(mxSrcDoc.is())
{
for (sal_Int32 nInd = 0; nInd < rDescriptor.getLength(); nInd++)
{
if (rDescriptor[nInd].Name == "FilterName")
{
OUString sFilterName;
rDescriptor[nInd].Value >>= sFilterName;
if(sFilterName == "writer_svg_Export")
{
mbWriterFilter = true;
return filterWriter(rDescriptor);
}
break;
}
}
return filterImpressDraw(rDescriptor);
}
return false;
}
bool SVGFilter::filterImpressDraw( const Sequence< PropertyValue >& rDescriptor )
{
SolarMutexGuard aGuard;
vcl::Window* pFocusWindow(Application::GetFocusWindow());
......@@ -505,6 +536,49 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto
return bRet;
}
bool SVGFilter::filterWriter( const Sequence< PropertyValue >& rDescriptor )
{
bool bSelectionOnly = false;
for (sal_Int32 nInd = 0; nInd < rDescriptor.getLength(); nInd++)
{
if (rDescriptor[nInd].Name == "SelectionOnly")
{
rDescriptor[nInd].Value >>= bSelectionOnly;
break;
}
}
if(!bSelectionOnly) // For Writer onéy the selection-only mode is supported
return false;
uno::Reference<frame::XDesktop2> xDesktop(frame::Desktop::create(mxContext));
uno::Reference<frame::XController > xController;
if (xDesktop->getCurrentFrame().is())
{
uno::Reference<frame::XFrame> xFrame(xDesktop->getCurrentFrame(), uno::UNO_QUERY_THROW);
xController.set(xFrame->getController(), uno::UNO_QUERY_THROW);
}
Reference< view::XSelectionSupplier > xSelection (xController, UNO_QUERY);
if (!xSelection.is())
return false;
xSelection->getSelection() >>= maShapeSelection;
if (!maShapeSelection)
return false;
// Select only one draw page
uno::Reference< drawing::XDrawPagesSupplier > xDrawPagesSupplier( mxSrcDoc, uno::UNO_QUERY );
uno::Reference<drawing::XDrawPages> xDrawPages = xDrawPagesSupplier->getDrawPages();
uno::Reference< drawing::XDrawPage > xDrawPage( xDrawPages->getByIndex(0), uno::UNO_QUERY );
mSelectedPages.resize( 1 );
mSelectedPages[0] = xDrawPage;
return implExport( rDescriptor );
}
void SAL_CALL SVGFilter::cancel( )
{
}
......
......@@ -192,31 +192,40 @@ public:
private:
/// Generally use members
Reference< XComponentContext > mxContext;
SvXMLElementExport* mpSVGDoc;
SVGExport* mpSVGExport;
SVGFontExport* mpSVGFontExport;
SVGActionWriter* mpSVGWriter;
SdrPage* mpDefaultSdrPage;
bool mbPresentation;
bool mbSinglePage;
bool mbSinglePage;
sal_Int32 mnVisiblePage;
PagePropertySet mVisiblePagePropSet;
OUString msClipPathId;
UCharSetMapMap mTextFieldCharSets;
Reference< XInterface > mCreateOjectsCurrentMasterPage;
UOStringMap mTextShapeIdListMap;
MetaBitmapActionSet mEmbeddedBitmapActionSet;
ObjectMap mEmbeddedBitmapActionMap;
ObjectMap* mpObjects;
Reference< XComponent > mxSrcDoc;
Reference< XComponent > mxDstDoc;
Reference< css::drawing::XDrawPage > mxDefaultPage;
Sequence< PropertyValue > maFilterData;
// #i124608# explicit ShapeSelection for export when export of the selection is wanted
Reference< css::drawing::XShapes > maShapeSelection;
bool mbExportShapeSelection;
Sequence< PropertyValue > maFilterData;
Reference< css::drawing::XDrawPage > mxDefaultPage;
std::vector< Reference< css::drawing::XDrawPage > > mSelectedPages;
bool mbWriterFilter;
/// Impress / draw only members
SdrPage* mpDefaultSdrPage;
SdrModel* mpSdrModel;
bool mbPresentation;
PagePropertySet mVisiblePagePropSet;
OUString msClipPathId;
UCharSetMapMap mTextFieldCharSets;
Reference< XInterface > mCreateOjectsCurrentMasterPage;
UOStringMap mTextShapeIdListMap;
MetaBitmapActionSet mEmbeddedBitmapActionSet;
ObjectMap mEmbeddedBitmapActionMap;
std::vector< Reference< css::drawing::XDrawPage > > mMasterPageTargets;
Link<EditFieldInfo*,void> maOldFieldHdl;
......@@ -224,6 +233,8 @@ private:
/// @throws css::uno::RuntimeException
bool implExport( const Sequence< PropertyValue >& rDescriptor );
bool implExportImpressDraw( const Reference< XOutputStream >& rxOStm );
bool implExportWriter( const Reference< XOutputStream >& rxOStm );
static Reference< XWriter > implCreateExportDocumentHandler( const Reference< XOutputStream >& rxOStm );
void implGetPagePropSet( const Reference< css::drawing::XDrawPage > & rxPage );
......@@ -235,6 +246,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 implExportAnimations();
bool implExportMasterPages( const std::vector< Reference< css::drawing::XDrawPage > >& rxPages,
......@@ -266,6 +281,9 @@ private:
const Reference< XPropertySetInfo > & rxPropSetInfo );
DECL_LINK( CalcFieldHdl, EditFieldInfo*, void );
bool filterImpressDraw( const Sequence< PropertyValue >& rDescriptor );
bool filterWriter( const Sequence< PropertyValue >& rDescriptor );
protected:
// XFilter
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment