[Libreoffice-commits] core.git: oox/source sw/qa
Samuel Mehrbrodt
Samuel.Mehrbrodt at cib.de
Tue Nov 28 11:04:42 UTC 2017
oox/source/vml/vmlshape.cxx | 69 ++++++----
sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 38 +++++
3 files changed, 80 insertions(+), 27 deletions(-)
New commits:
commit d3440e0ebfa68ac8d2cbec9b44d0fc491162ee0e
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Date: Thu Nov 23 15:05:03 2017 +0100
tdf#83877 Unit test for OOXML SignatureLine Roundtrip
Change-Id: I40c116f28c0e8efe81e33e48fa05098d1dd76731
Reviewed-on: https://gerrit.libreoffice.org/45152
Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
Tested-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
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())
diff --git a/sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx b/sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx
new file mode 100644
index 000000000000..2f8401bf5ca1
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index 40081112629d..b139210c3bff 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -109,6 +109,44 @@ DECLARE_OOXMLEXPORT_TEST(testTdf44832_testSectionWithDifferentHeader, "tdf44832_
assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:headerReference", 1);
}
+DECLARE_OOXMLEXPORT_TEST(testSignatureLineShape, "signature-line-all-props-set.docx")
+{
+ uno::Reference<drawing::XShape> xSignatureLineShape = getShape(1);
+ uno::Reference<beans::XPropertySet> xPropSet(xSignatureLineShape, uno::UNO_QUERY);
+
+ bool bIsSignatureLine;
+ xPropSet->getPropertyValue("IsSignatureLine") >>= bIsSignatureLine;
+ CPPUNIT_ASSERT_EQUAL(true, bIsSignatureLine);
+
+ bool bShowSignDate;
+ xPropSet->getPropertyValue("SignatureLineShowSignDate") >>= bShowSignDate;
+ CPPUNIT_ASSERT_EQUAL(true, bShowSignDate);
+
+ bool bCanAddComment;
+ xPropSet->getPropertyValue("SignatureLineCanAddComment") >>= bCanAddComment;
+ CPPUNIT_ASSERT_EQUAL(true, bCanAddComment);
+
+ OUString aSignatureLineId;
+ xPropSet->getPropertyValue("SignatureLineId") >>= aSignatureLineId;
+ CPPUNIT_ASSERT_EQUAL(OUString("{0EBE47D5-A1BD-4C9E-A52E-6256E5C345E9}"), aSignatureLineId);
+
+ OUString aSuggestedSignerName;
+ xPropSet->getPropertyValue("SignatureLineSuggestedSignerName") >>= aSuggestedSignerName;
+ CPPUNIT_ASSERT_EQUAL(OUString("John Doe"), aSuggestedSignerName);
+
+ OUString aSuggestedSignerTitle;
+ xPropSet->getPropertyValue("SignatureLineSuggestedSignerTitle") >>= aSuggestedSignerTitle;
+ CPPUNIT_ASSERT_EQUAL(OUString("Farmer"), aSuggestedSignerTitle);
+
+ OUString aSuggestedSignerEmail;
+ xPropSet->getPropertyValue("SignatureLineSuggestedSignerEmail") >>= aSuggestedSignerEmail;
+ CPPUNIT_ASSERT_EQUAL(OUString("john at thefarmers.com"), aSuggestedSignerEmail);
+
+ OUString aSigningInstructions;
+ xPropSet->getPropertyValue("SignatureLineSigningInstructions") >>= aSigningInstructions;
+ CPPUNIT_ASSERT_EQUAL(OUString("Check the machines!"), aSigningInstructions);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
More information about the Libreoffice-commits
mailing list