summaryrefslogtreecommitdiff
path: root/oox
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-11-23 15:05:03 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2017-11-28 12:04:14 +0100
commitd3440e0ebfa68ac8d2cbec9b44d0fc491162ee0e (patch)
tree202246f9b5e5b9d8307e748916ae3f3e97bc106a /oox
parent54ec0aec1308bbbb8c9ab36fc76fe993bb23e5fb (diff)
tdf#83877 Unit test for OOXML SignatureLine Roundtrip
Change-Id: I40c116f28c0e8efe81e33e48fa05098d1dd76731 Reviewed-on: https://gerrit.libreoffice.org/45152 Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de> Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'oox')
-rw-r--r--oox/source/vml/vmlshape.cxx69
1 files changed, 42 insertions, 27 deletions
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 1cec9461e2df..8079f5ef179d 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -1311,40 +1311,55 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
if( getShapeModel().mbIsSignatureLine )
{
- // Get the document signatures
- Reference< security::XDocumentDigitalSignatures > xSignatures(
- security::DocumentDigitalSignatures::createWithVersion(
- comphelper::getProcessComponentContext(), "1.2" ) );
-
- uno::Reference<embed::XStorage> 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 >());
-
OUString aGraphicUrl;
- for (int i=0; i<xSignatureInfo.getLength(); i++)
+ try
{
- // Try to find matching signature line image - if none exists that is fine,
- // then the signature line is not digitally signed.
- if (xSignatureInfo[i].SignatureLineId == getShapeModel().maSignatureId)
+ // Get the document signatures
+ Reference<security::XDocumentDigitalSignatures> xSignatures(
+ security::DocumentDigitalSignatures::createWithVersion(
+ comphelper::getProcessComponentContext(), "1.2"));
+
+ uno::Reference<embed::XStorage> 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 < xSignatureInfo.getLength(); i++)
{
- if (xSignatureInfo[i].SignatureIsValid)
- {
- // Signature is valid, use the 'valid' image
- SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml", "No ValidSignatureLineImage!");
- aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject(xSignatureInfo[i].ValidSignatureLineImage);
- }
- else
+ // Try to find matching signature line image - if none exists that is fine,
+ // then the signature line is not digitally signed.
+ if (xSignatureInfo[i].SignatureLineId == getShapeModel().maSignatureId)
{
- // Signature is invalid, use the 'invalid' image
- SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml", "No InvalidSignatureLineImage!");
- aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject(xSignatureInfo[i].InvalidSignatureLineImage);
+ if (xSignatureInfo[i].SignatureIsValid)
+ {
+ // Signature is valid, use the 'valid' image
+ SAL_WARN_IF(!xSignatureInfo[i].ValidSignatureLineImage.is(), "oox.vml",
+ "No ValidSignatureLineImage!");
+ aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject(
+ xSignatureInfo[i].ValidSignatureLineImage);
+ }
+ else
+ {
+ // Signature is invalid, use the 'invalid' image
+ SAL_WARN_IF(!xSignatureInfo[i].InvalidSignatureLineImage.is(), "oox.vml",
+ "No InvalidSignatureLineImage!");
+ aGraphicUrl = rFilter.getGraphicHelper().createGraphicObject(
+ xSignatureInfo[i].InvalidSignatureLineImage);
+ }
+ break;
}
- break;
}
}
+ catch (css::uno::Exception&)
+ {
+ // DocumentDigitalSignatures service not available.
+ // We continue by rendering the "unsigned" shape instead.
+ }
Reference< XShape > xShape;
if (!aGraphicUrl.isEmpty())