diff options
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 69 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx | bin | 0 -> 13169 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 38 |
3 files changed, 80 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()) 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 Binary files differnew file mode 100644 index 000000000000..2f8401bf5ca1 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/signature-line-all-props-set.docx 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@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: */ |