From a631ee21f2478c976bce23898d84a6529296087f Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 16 Feb 2015 18:07:47 +0200 Subject: tdf#88428: Add GUI to select one of user-configured Time Stamp Authorities Work in progress. The selection not used for anything yet. (cherry picked from commit b8b9d51b8cf1cafe1a94e1baf957f3f282abb32f) Conflicts: filter/source/pdf/impdialog.cxx include/sal/log-areas.dox Change-Id: Ia86fa0f59dcfee8e9d332a028a3fad37f4019fe0 --- cui/source/options/tsaurls.cxx | 4 ++-- cui/source/options/tsaurls.hxx | 2 +- filter/Library_pdffilter.mk | 4 ++++ filter/source/pdf/impdialog.cxx | 28 ++++++++++++++++++++++++++++ filter/source/pdf/impdialog.hxx | 2 ++ filter/uiconfig/ui/pdfsignpage.ui | 28 ++++++++++++++++++++++++++++ include/sal/log-areas.dox | 1 + vcl/source/gdi/pdfwriter_impl.cxx | 6 ++++-- 8 files changed, 70 insertions(+), 5 deletions(-) diff --git a/cui/source/options/tsaurls.cxx b/cui/source/options/tsaurls.cxx index 9db380135ed7..cf50fbca3db3 100644 --- a/cui/source/options/tsaurls.cxx +++ b/cui/source/options/tsaurls.cxx @@ -17,7 +17,7 @@ using namespace ::com::sun::star; -TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent) +TSAURLsDialog::TSAURLsDialog(Window* pParent) : ModalDialog(pParent, "TSAURLDialog", "cui/ui/tsaurldialog.ui") { get(m_pAddBtn, "add"); @@ -50,7 +50,7 @@ TSAURLsDialog::TSAURLsDialog(vcl::Window* pParent) IMPL_LINK_NOARG(TSAURLsDialog, OKHdl_Impl) { - std::shared_ptr batch(comphelper::ConfigurationChanges::create()); + boost::shared_ptr batch(comphelper::ConfigurationChanges::create()); css::uno::Sequence aNewValue(m_aURLs.size()); size_t n(0); diff --git a/cui/source/options/tsaurls.hxx b/cui/source/options/tsaurls.hxx index aba749181ac5..cc9f2de1bd24 100644 --- a/cui/source/options/tsaurls.hxx +++ b/cui/source/options/tsaurls.hxx @@ -30,7 +30,7 @@ private: void AddTSAURL(const OUString &rURL); public: - TSAURLsDialog(vcl::Window* pParent); + TSAURLsDialog(Window* pParent); virtual ~TSAURLsDialog(); }; diff --git a/filter/Library_pdffilter.mk b/filter/Library_pdffilter.mk index b3a62d76f352..6de7d341367e 100644 --- a/filter/Library_pdffilter.mk +++ b/filter/Library_pdffilter.mk @@ -30,6 +30,10 @@ $(eval $(call gb_Library_set_include,pdffilter,\ $$(INCLUDE) \ )) +$(eval $(call gb_Library_use_custom_headers,pdffilter,\ + officecfg/registry \ +)) + $(eval $(call gb_Library_use_libraries,pdffilter,\ svt \ sfx \ diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 63e446f36fa0..005dd2fceccb 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -21,6 +21,7 @@ #include "impdialog.hxx" #include "impdialog.hrc" +#include #include "vcl/svapp.hxx" #include "vcl/msgbox.hxx" #include @@ -1541,10 +1542,12 @@ ImpPDFTabSigningPage::ImpPDFTabSigningPage(Window* pParent, const SfxItemSet& rC get(mpEdSignLocation, "location"); get(mpEdSignContactInfo, "contact"); get(mpEdSignReason, "reason"); + get(mpLBSignTSA, "tsa"); mpPbSignCertSelect->Enable( true ); mpPbSignCertSelect->SetClickHdl( LINK( this, ImpPDFTabSigningPage, ClickmaPbSignCertSelect ) ); mpPbSignCertClear->SetClickHdl( LINK( this, ImpPDFTabSigningPage, ClickmaPbSignCertClear ) ); + mpLBSignTSA->SetSelectHdl( LINK( this, ImpPDFTabSigningPage, SelectLBSignTSA ) ); } @@ -1569,6 +1572,24 @@ IMPL_LINK_NOARG( ImpPDFTabSigningPage, ClickmaPbSignCertSelect ) mpEdSignPassword->Enable( true ); mpEdSignContactInfo->Enable( true ); mpEdSignReason->Enable( true ); + + try + { + css::uno::Sequence aTSAURLs(officecfg::Office::Common::Security::Scripting::TSAURLs::get()); + + for (auto i = aTSAURLs.begin(); i != aTSAURLs.end(); ++i) + { + mpLBSignTSA->InsertEntry( *i ); + } + } + catch (const uno::Exception &e) + { + SAL_INFO("filter.pdf", "TSAURLsDialog::TSAURLsDialog(): caught exception" << e.Message); + } + + // If more than only the "None" entry is there, enable the ListBox + if (mpLBSignTSA->GetEntryCount() > 1) + mpLBSignTSA->Enable(); } return 0; @@ -1583,11 +1604,17 @@ IMPL_LINK_NOARG( ImpPDFTabSigningPage, ClickmaPbSignCertClear ) mpEdSignPassword->Enable( false ); mpEdSignContactInfo->Enable( false ); mpEdSignReason->Enable( false ); + mpLBSignTSA->Enable( false ); return 0; } +IMPL_LINK_NOARG( ImpPDFTabSigningPage, SelectLBSignTSA ) +{ + return 0; +} + SfxTabPage* ImpPDFTabSigningPage::Create( Window* pParent, const SfxItemSet& rAttrSet) { @@ -1616,6 +1643,7 @@ void ImpPDFTabSigningPage::SetFilterConfigItem( const ImpPDFTabDialog* paParent mpEdSignPassword->Enable( false ); mpEdSignContactInfo->Enable( false ); mpEdSignReason->Enable( false ); + mpLBSignTSA->Enable( false ); mpPbSignCertClear->Enable( false ); if (paParent->mbSignPDF) diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index c6238ea3de02..50bba414023d 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -420,10 +420,12 @@ class ImpPDFTabSigningPage : public SfxTabPage Edit* mpEdSignLocation; Edit* mpEdSignContactInfo; Edit* mpEdSignReason; + ListBox* mpLBSignTSA; com::sun::star::uno::Reference< com::sun::star::security::XCertificate > maSignCertificate; DECL_LINK( ClickmaPbSignCertSelect, void* ); DECL_LINK( ClickmaPbSignCertClear, void* ); + DECL_LINK( SelectLBSignTSA, void* ); public: ImpPDFTabSigningPage( Window* pParent, diff --git a/filter/uiconfig/ui/pdfsignpage.ui b/filter/uiconfig/ui/pdfsignpage.ui index ff9395fc766d..73c61aebe58e 100644 --- a/filter/uiconfig/ui/pdfsignpage.ui +++ b/filter/uiconfig/ui/pdfsignpage.ui @@ -172,6 +172,20 @@ 1 + + + True + True + False + + None + + + + 1 + 4 + + True @@ -236,6 +250,20 @@ 1 + + + True + False + 1 + Time Stamp Authority: + True + reason + + + 0 + 4 + + 0 diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox index c12740c8e08a..6d7e8e701ada 100644 --- a/include/sal/log-areas.dox +++ b/include/sal/log-areas.dox @@ -172,6 +172,7 @@ certain functionality. @li @c filter.ms - escher import/export @li @c filter.odfflatxml @li @c filter.os2met +@li @c filter.pdf @li @c filter.tiff @li @c filter.xslt - xslt import/export @li @c oox.cscode - see oox/source/drawingml/customshapes/README diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index e7a18b78ee42..7fa5b14ab815 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6943,7 +6943,8 @@ bool PDFWriterImpl::finalizeSignature() src.reqPolicy.data = NULL; src.reqPolicy.len = 0; - unsigned int nNonce = comphelper::rng::uniform_uint_distribution(0, SAL_MAX_UINT32); + srand( unsigned( time( NULL ) )); + unsigned int nNonce = rand(); src.nonce.type = siUnsignedInteger; src.nonce.data = reinterpret_cast(&nNonce); src.nonce.len = sizeof(nNonce); @@ -7414,7 +7415,8 @@ bool PDFWriterImpl::finalizeSignature() CMSG_SIGNER_INFO *pDecodedSignerInfo = (CMSG_SIGNER_INFO *) pDecodedSignerInfoBuf.get(); CRYPT_TIMESTAMP_PARA aTsPara; - unsigned int nNonce = comphelper::rng::uniform_uint_distribution(0, SAL_MAX_UINT32); + srand( unsigned( time( NULL ) )); + unsigned int nNonce = rand(); aTsPara.pszTSAPolicyId = NULL; aTsPara.fRequestCerts = TRUE; -- cgit v1.2.3