From bd3c5c4c234e3dc6b89cd235321945a41a08d562 Mon Sep 17 00:00:00 2001 From: Samuel Mehrbrodt Date: Tue, 8 Aug 2017 16:23:07 +0200 Subject: [API CHANGE] tdf#65393 Import signature line images from ooxml showing whether the signature behind the signature line is valid or not. Change-Id: Ia6cca62812019f26d55d234cac767a9b4b7c8175 Reviewed-on: https://gerrit.libreoffice.org/40980 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt --- oox/source/vml/vmlshape.cxx | 74 +++++++++++++++++++++++++++++++++----- oox/source/vml/vmlshapecontext.cxx | 7 ++++ 2 files changed, 72 insertions(+), 9 deletions(-) (limited to 'oox/source') diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 74ae15f848f3..7679ca838f67 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -44,9 +44,11 @@ #include #include #include - #include +#include #include #include +#include +#include #include #include #include @@ -67,7 +69,9 @@ #include #include #include +#include #include +#include using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::uno::Any; @@ -249,7 +253,8 @@ ClientData::ClientData() : { } -ShapeModel::ShapeModel() +ShapeModel::ShapeModel() : + mbIsSignatureLine(false) { } @@ -852,17 +857,23 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes return xShape; } -Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const +Reference< XShape > SimpleShape::createEmbeddedPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const +{ + XmlFilterBase& rFilter = mrDrawing.getFilter(); + OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath ); + return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicUrl); +} + +Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicUrl ) const { Reference< XShape > xShape = mrDrawing.createAndInsertXShape( "com.sun.star.drawing.GraphicObjectShape", rxShapes, rShapeRect ); if( xShape.is() ) { - XmlFilterBase& rFilter = mrDrawing.getFilter(); - OUString aGraphicUrl = rFilter.getGraphicHelper().importEmbeddedGraphicObject( rGraphicPath ); + PropertySet aPropSet( xShape ); - if( !aGraphicUrl.isEmpty() ) + if( !rGraphicUrl.isEmpty() ) { - aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl ); + aPropSet.setProperty( PROP_GraphicURL, rGraphicUrl ); } uno::Reference< lang::XServiceInfo > xServiceInfo(rxShapes, uno::UNO_QUERY); // If the shape has an absolute position, set the properties accordingly, unless we're inside a group shape. @@ -912,7 +923,7 @@ Reference RectangleShape::implConvertAndInsert(const Reference& // try to create a picture object if(!aGraphicPath.isEmpty()) - return SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath); + return SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath); // default: try to create a rectangle shape Reference xShape = SimpleShape::implConvertAndInsert(rxShapes, rShapeRect); @@ -1231,15 +1242,60 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes return xShape; } + + if( getShapeModel().mbIsSignatureLine ) + { + // Get the document signatures + Reference< security::XDocumentDigitalSignatures > xSignatures( + security::DocumentDigitalSignatures::createWithVersion( + comphelper::getProcessComponentContext(), "1.2" ) ); + + uno::Reference xStorage = comphelper::OStorageHelper::GetStorageOfFormatFromURL( + ZIP_STORAGE_FORMAT_STRING, mrDrawing.getFilter().getFileUrl(), embed::ElementModes::READ); + SAL_WARN_IF(!xStorage.is(), "oox.vml", "No xStorage!"); + + uno::Sequence< security::DocumentSignatureInformation > xSignatureInfo = + xSignatures->verifyScriptingContentSignatures(xStorage, uno::Reference< io::XInputStream >()); + + for (int i=0; i xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicUrl); + PropertySet aPropSet(xShape); + aPropSet.setProperty(PROP_GraphicURL, aGraphicUrl); + + return xShape; + } + } + // In case no matching signature line is found, render the unsigned signature line image (next if branch) + } + // try to create a picture object if( !aGraphicPath.isEmpty() ) { - Reference< XShape > xShape = SimpleShape::createPictureObject(rxShapes, rShapeRect, aGraphicPath); + Reference< XShape > xShape = SimpleShape::createEmbeddedPictureObject(rxShapes, rShapeRect, aGraphicPath); // AS_CHARACTER shape: vertical orientation default is bottom, MSO default is top. if ( maTypeModel.maPosition != "absolute" && maTypeModel.maPosition != "relative" ) PropertySet( xShape ).setAnyProperty( PROP_VertOrient, makeAny(text::VertOrientation::TOP)); return xShape; } + // default: try to create a custom shape return CustomShape::implConvertAndInsert( rxShapes, rShapeRect ); } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 1d1851d87ef1..151f28585a70 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -491,6 +491,13 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri "com.sun.star.drawing.RectangleShape"); mrShapeModel.maLegacyDiagramPath = getFragmentPathFromRelId(rAttribs.getString(XML_id, OUString())); break; + case O_TOKEN( signatureline ): + mrShapeModel.mbIsSignatureLine = true; + mrShapeModel.maSignatureId = rAttribs.getString(XML_id, OUString()); + break; + case O_TOKEN( lock ): + // TODO + break; } // handle remaining stuff in base class return ShapeTypeContext::onCreateContext( nElement, rAttribs ); -- cgit