[Libreoffice-commits] .: Branch 'feature/pdf-signing' - filter/inc filter/source

Gökcen Eraslan gokcen at kemper.freedesktop.org
Sun Jun 24 06:28:40 PDT 2012


 filter/inc/filter.hrc           |    1 
 filter/source/pdf/impdialog.cxx |  107 +++++++++++++++++++++++++++++++++++++++-
 filter/source/pdf/impdialog.hrc |   11 ++++
 filter/source/pdf/impdialog.hxx |   32 +++++++++++
 filter/source/pdf/impdialog.src |   67 +++++++++++++++++++++++++
 5 files changed, 216 insertions(+), 2 deletions(-)

New commits:
commit 2a537c6d96bac3ef0661bf59375e4061342c0aca
Author: Gökçen Eraslan <gokcen.eraslan at gmail.com>
Date:   Sun Jun 24 16:25:39 2012 +0300

    Add a simple GUI for digital signatures.
    
    Right now, there is no certificate selection and password
    edit but this GUI will make things easier to test. If Sign PDF
    checkbox is checked, I will create the necessary data in PDF file
    with a garbage PKCS7 object, for now.
    
    Change-Id: Ib9f0b33d3be31cb3eb8acb12a6aa2e37f2d3beeb

diff --git a/filter/inc/filter.hrc b/filter/inc/filter.hrc
index 8c50b5a..8a18d6f 100644
--- a/filter/inc/filter.hrc
+++ b/filter/inc/filter.hrc
@@ -59,6 +59,7 @@
 #define HID_FILTER_PDF_USER_INTERFACE "HID_FILTER_PDF_USER_INTERFACE"
 #define HID_FILTER_PDF_SECURITY       "HID_FILTER_PDF_SECURITY"
 #define HID_FILTER_PDF_LINKS          "HID_FILTER_PDF_LINKS"
+#define HID_FILTER_PDF_SIGNING        "HID_FILTER_PDF_SIGNING"
 
 #endif
 
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 03de749..4e4b04a 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -124,7 +124,13 @@ ImpPDFTabDialog::ImpPDFTabDialog( Window* pParent,
     mbExportRelativeFsysLinks( sal_False ),
     mnViewPDFMode( 0 ),
     mbConvertOOoTargets( sal_False ),
-    mbExportBmkToPDFDestination( sal_False )
+    mbExportBmkToPDFDestination( sal_False ),
+
+    mbSignPDF( sal_False ),
+    msSignLocation ( ' ' ),
+    msSignContact( ' ' ),
+    msSignReason( ' ' )
+
 {
     FreeResource();
 // check for selection
@@ -241,7 +247,14 @@ ImpPDFTabDialog::ImpPDFTabDialog( Window* pParent,
     mbConvertOOoTargets = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ConvertOOoTargetToPDFTarget" ) ), sal_False );
     mbExportBmkToPDFDestination = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarksToPDFDestination" ) ), sal_False );
 
+//prepare values for digital signatures
+    mbSignPDF = maConfigItem.ReadBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignPDF" ) ), sal_False );
+    //msSignLocation = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureLocation" ) ), "" );
+    //msSignContact = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureContactInfo" ) ), "" );
+    //msSignReason = maConfigItem.ReadString( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureReason" ) ), "" );
+
 //queue the tab pages for later creation (created when first shown)
+    AddTabPage( RID_PDF_TAB_SIGNING, ImpPDFTabSigningPage::Create, 0 );
     AddTabPage( RID_PDF_TAB_SECURITY, ImpPDFTabSecurityPage::Create, 0 );
     AddTabPage( RID_PDF_TAB_LINKS, ImpPDFTabLinksPage::Create, 0 );
     AddTabPage( RID_PDF_TAB_VPREFER, ImpPDFTabViewerPage::Create, 0 );
@@ -281,6 +294,7 @@ ImpPDFTabDialog::~ImpPDFTabDialog()
     RemoveTabPage( RID_PDF_TAB_OPNFTR );
     RemoveTabPage( RID_PDF_TAB_LINKS );
     RemoveTabPage( RID_PDF_TAB_SECURITY );
+    RemoveTabPage( RID_PDF_TAB_SIGNING );
 }
 
 // -----------------------------------------------------------------------------
@@ -304,6 +318,9 @@ void ImpPDFTabDialog::PageCreated( sal_uInt16 _nId,
     case RID_PDF_TAB_SECURITY:
         ( ( ImpPDFTabSecurityPage* )&_rPage )->SetFilterConfigItem( this );
         break;
+    case RID_PDF_TAB_SIGNING:
+        ( ( ImpPDFTabSigningPage* )&_rPage )->SetFilterConfigItem( this );
+        break;
     }
 }
 
@@ -329,6 +346,8 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
         ( ( ImpPDFTabLinksPage* )GetTabPage( RID_PDF_TAB_LINKS ) )->GetFilterConfigItem( this );
     if( GetTabPage( RID_PDF_TAB_SECURITY ) )
         ( ( ImpPDFTabSecurityPage* )GetTabPage( RID_PDF_TAB_SECURITY ) )->GetFilterConfigItem( this );
+    if( GetTabPage( RID_PDF_TAB_SIGNING ) )
+        ( ( ImpPDFTabSigningPage* )GetTabPage( RID_PDF_TAB_SIGNING ) )->GetFilterConfigItem( this );
 
 //prepare the items to be returned
     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "UseLosslessCompression" ) ), mbUseLosslessCompression );
@@ -379,6 +398,8 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ConvertOOoTargetToPDFTarget" ) ), mbConvertOOoTargets );
     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "ExportBookmarksToPDFDestination" ) ), mbExportBmkToPDFDestination );
 
+    maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "SignPDF" ) ), mbSignPDF );
+
     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Printing" ) ), mnPrint );
     maConfigItem.WriteInt32( OUString( RTL_CONSTASCII_USTRINGPARAM( "Changes" ) ), mnChangesAllowed );
     maConfigItem.WriteBool( OUString( RTL_CONSTASCII_USTRINGPARAM( "EnableCopyingOfContent" ) ), mbCanCopyOrExtract );
@@ -386,7 +407,7 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
 
     Sequence< PropertyValue > aRet( maConfigItem.GetFilterData() );
 
-    int nElementAdded = 6;
+    int nElementAdded = 9;
 
     aRet.realloc( aRet.getLength() + nElementAdded );
 
@@ -421,13 +442,27 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData()
     {
         aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "PageRange" ) );
         aRet[ nLength - nElementAdded ].Value <<= OUString( msPageRange );
+        nElementAdded--;
     }
     else if( mbSelectionIsChecked )
     {
         aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Selection" ) );
         aRet[ nLength - nElementAdded ].Value <<= maSelection;
+        nElementAdded--;
     }
 
+    aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureLocation" ) );
+    aRet[ nLength - nElementAdded ].Value <<= OUString( msSignLocation );
+    nElementAdded--;
+
+    aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureReason" ) );
+    aRet[ nLength - nElementAdded ].Value <<= OUString( msSignReason );
+    nElementAdded--;
+
+    aRet[ nLength - nElementAdded ].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "SignatureContactInfo" ) );
+    aRet[ nLength - nElementAdded ].Value <<= OUString( msSignContact );
+    nElementAdded--;
+
     return aRet;
 }
 
@@ -1626,4 +1661,72 @@ IMPL_LINK_NOARG(ImplErrorDialog, SelectHdl)
     return 0;
 }
 
+////////////////////////////////////////////////////////
+// The digital signatures tab page
+// -----------------------------------------------------------------------------
+ImpPDFTabSigningPage::ImpPDFTabSigningPage( Window* pParent,
+                                              const SfxItemSet& rCoreSet ) :
+    SfxTabPage( pParent, PDFFilterResId( RID_PDF_TAB_SIGNING ), rCoreSet ),
+
+    maCbSignPDF( this, PDFFilterResId( CB_SIGN_PDF ) ),
+    maFtSignLocation( this, PDFFilterResId( FT_SIGN_LOCATION ) ),
+    maEdSignLocation( this, PDFFilterResId( ED_SIGN_LOCATION ) ),
+    maFtSignContactInfo( this, PDFFilterResId( FT_SIGN_CONTACT ) ),
+    maEdSignContactInfo( this, PDFFilterResId( ED_SIGN_CONTACT ) ),
+    maFtSignReason( this, PDFFilterResId( FT_SIGN_REASON ) ),
+    maEdSignReason( this, PDFFilterResId( ED_SIGN_REASON ) )
+{
+    FreeResource();
+}
+
+// -----------------------------------------------------------------------------
+ImpPDFTabSigningPage::~ImpPDFTabSigningPage()
+{
+}
+
+// -----------------------------------------------------------------------------
+SfxTabPage*  ImpPDFTabSigningPage::Create( Window* pParent,
+                                          const SfxItemSet& rAttrSet)
+{
+    return ( new  ImpPDFTabSigningPage( pParent, rAttrSet ) );
+}
+
+// -----------------------------------------------------------------------------
+void ImpPDFTabSigningPage::GetFilterConfigItem( ImpPDFTabDialog* paParent  )
+{
+    paParent->mbSignPDF = maCbSignPDF.IsChecked();
+    paParent->msSignLocation = maEdSignLocation.GetText();
+    paParent->msSignContact = maEdSignContactInfo.GetText();
+    paParent->msSignReason = maEdSignReason.GetText();
+
+}
+
+// -----------------------------------------------------------------------------
+void ImpPDFTabSigningPage::SetFilterConfigItem( const  ImpPDFTabDialog* paParent )
+{
+
+    maCbSignPDF.SetToggleHdl( LINK( this, ImpPDFTabSigningPage, ToggleSignPDFHdl ) );
+    maEdSignLocation.Enable( false );
+    maEdSignContactInfo.Enable( false );
+    maEdSignReason.Enable( false );
+
+    if (paParent->mbSignPDF)
+    {
+        maCbSignPDF.Check();
+        maEdSignLocation.SetText(paParent->msSignLocation);
+        maEdSignContactInfo.SetText(paParent->msSignContact);
+        maEdSignReason.SetText(paParent->msSignReason);
+    }
+}
+
+// -----------------------------------------------------------------------------
+IMPL_LINK_NOARG(ImpPDFTabSigningPage, ToggleSignPDFHdl)
+{
+    maEdSignLocation.Enable( maCbSignPDF.IsChecked() );
+    maEdSignContactInfo.Enable( maCbSignPDF.IsChecked() );
+    maEdSignReason.Enable( maCbSignPDF.IsChecked() );
+
+    return 0;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/filter/source/pdf/impdialog.hrc b/filter/source/pdf/impdialog.hrc
index 25c46ce..ea5cade 100644
--- a/filter/source/pdf/impdialog.hrc
+++ b/filter/source/pdf/impdialog.hrc
@@ -33,6 +33,7 @@
 #define RID_PDF_TAB_OPNFTR          (RID_PDF_DIALOG_START +   3)
 #define RID_PDF_TAB_SECURITY        (RID_PDF_DIALOG_START +   4)
 #define RID_PDF_TAB_LINKS           (RID_PDF_DIALOG_START +   12)
+#define RID_PDF_TAB_SIGNING         (RID_PDF_DIALOG_START +   13)
 #define RID_PDF_WARNPDFAPASSWORD    (RID_PDF_DIALOG_START +   6)
 
 //strings
@@ -198,3 +199,13 @@
 #define FL_INITVIEW_VERTICAL 158
 #define FL_VPREFER_VERTICAL  158
 #define FL_SECURITY_VERTICAL 160
+
+//controls for digital signatures tab page
+#define CB_SIGN_PDF          170
+#define FT_SIGN_LOCATION     171
+#define ED_SIGN_LOCATION     172
+#define FT_SIGN_CONTACT      173
+#define ED_SIGN_CONTACT      174
+#define FT_SIGN_REASON       175
+#define ED_SIGN_REASON       176
+
diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx
index f3330c0..87327a0 100644
--- a/filter/source/pdf/impdialog.hxx
+++ b/filter/source/pdf/impdialog.hxx
@@ -149,6 +149,12 @@ protected:
     sal_Int32                   mnViewPDFMode;
     sal_Bool                    mbConvertOOoTargets;
     sal_Bool                    mbExportBmkToPDFDestination;
+
+    sal_Bool                    mbSignPDF;
+    String                      msSignLocation;
+    String                      msSignContact;
+    String                      msSignReason;
+
     ::rtl::OUString             maWatermarkText;
 
 public:
@@ -158,6 +164,7 @@ public:
     friend class                ImpPDFTabOpnFtrPage;
     friend class                ImpPDFTabSecurityPage;
     friend class                ImpPDFTabLinksPage;
+    friend class                ImpPDFTabSigningPage;
 
     ImpPDFTabDialog( Window* pParent,
                      Sequence< PropertyValue >& rFilterData,
@@ -430,6 +437,31 @@ public:
     void    ImplPDFALinkControl( sal_Bool bEnableLaunch );
 };
 
+//class to implement the digital signing
+class ImpPDFTabSigningPage : public SfxTabPage
+{
+    CheckBox                    maCbSignPDF;
+    FixedText                   maFtSignLocation;
+    Edit                        maEdSignLocation;
+    FixedText                   maFtSignContactInfo;
+    Edit                        maEdSignContactInfo;
+    FixedText                   maFtSignReason;
+    Edit                        maEdSignReason;
+
+    DECL_LINK( ToggleSignPDFHdl, void* );
+
+public:
+    ImpPDFTabSigningPage( Window* pParent,
+                          const SfxItemSet& rSet );
+
+    ~ImpPDFTabSigningPage();
+    static SfxTabPage*      Create( Window* pParent,
+                                    const SfxItemSet& rAttrSet );
+
+    void    GetFilterConfigItem( ImpPDFTabDialog* paParent);
+    void    SetFilterConfigItem( const ImpPDFTabDialog* paParent );
+};
+
 #endif // IMPDIALOG_HXX
 
 
diff --git a/filter/source/pdf/impdialog.src b/filter/source/pdf/impdialog.src
index 8c73d20..92bf696 100644
--- a/filter/source/pdf/impdialog.src
+++ b/filter/source/pdf/impdialog.src
@@ -817,6 +817,68 @@ TabPage  RID_PDF_TAB_SECURITY
 };
 
 //----------------------------------------------------------
+//tab page for PDF Export, digital signatures
+TabPage  RID_PDF_TAB_SIGNING
+{
+    HelpId = HID_FILTER_PDF_SIGNING ;
+    Text [ en-US ] = "Digital Signatures";
+    TAB_PDF_SIZE;
+    Hide = TRUE;
+
+    CheckBox CB_SIGN_PDF
+    {
+        Pos = MAP_APPFONT ( 6 , 3 ) ;
+        Size = MAP_APPFONT ( 164 , 16 ) ;
+        TabStop = TRUE ;
+        WordBreak = TRUE ;
+        Text[ en-US ] = "Sign PDF file" ;
+    };
+
+    FixedText FT_SIGN_LOCATION
+    {
+        Pos = MAP_APPFONT( 12, 15 );
+        Size = MAP_APPFONT( 109, 10 );
+        Text[ en-US ] = "Location";
+    };
+
+    Edit ED_SIGN_LOCATION
+    {
+        Border = TRUE ;
+        Pos = MAP_APPFONT ( 122, 15 ) ;
+        Size = MAP_APPFONT ( 48 , 12 ) ;
+    };
+
+    FixedText FT_SIGN_CONTACT
+    {
+        Pos = MAP_APPFONT( 12, 28 );
+        Size = MAP_APPFONT( 109, 10 );
+        Text[ en-US ] = "Contact Information";
+    };
+
+    Edit ED_SIGN_CONTACT
+    {
+        Border = TRUE ;
+        Pos = MAP_APPFONT ( 122, 28 ) ;
+        Size = MAP_APPFONT ( 48 , 12 ) ;
+    };
+
+    FixedText FT_SIGN_REASON
+    {
+        Pos = MAP_APPFONT( 12, 41 );
+        Size = MAP_APPFONT( 109, 10 );
+        Text[ en-US ] = "Reason";
+    };
+
+    Edit ED_SIGN_REASON
+    {
+        Border = TRUE ;
+        Pos = MAP_APPFONT ( 122, 41 ) ;
+        Size = MAP_APPFONT ( 48 , 12 ) ;
+    };
+
+};
+
+//----------------------------------------------------------
 //tab page for PDF Export, links management
 TabPage  RID_PDF_TAB_LINKS
 {
@@ -930,6 +992,11 @@ TabDialog  RID_PDF_EXPORT_DLG
                 Identifier = RID_PDF_TAB_SECURITY;
                 Text [ en-US ] = "Security";
             };
+            PageItem
+            {
+                Identifier = RID_PDF_TAB_SIGNING;
+                Text [ en-US ] = "Digital Signatures";
+            };
         };
     };
 };


More information about the Libreoffice-commits mailing list