SignDocSDK-cpp.h

Go to the documentation of this file.
00001 /*=============================================== -*- C++ -*- ==*
00002  * SOFTPRO SignDoc                                              *
00003  *                                                              *
00004  * Copyright SOFTPRO GmbH                                       *
00005  * Wilhelmstrasse 34, D-71034 Boeblingen                        *
00006  * All rights reserved.                                         *
00007  *                                                              *
00008  * This software is the confidential and proprietary            *
00009  * information of SOFTPRO ("Confidential Information"). You     *
00010  * shall not disclose such Confidential Information and shall   *
00011  * use it only in accordance with the terms of the license      *
00012  * agreement you entered into with SOFTPRO.                     *
00013  *==============================================================*/
00014 
00025 #ifndef SIGNDOCSDK_SIGNDOCDOCUMENT_H_INCLUDED
00026 #define SIGNDOCSDK_SIGNDOCDOCUMENT_H_INCLUDED
00027 
00028 #include <stddef.h>
00029 #include <memory>
00030 #include <string>
00031 #include <vector>
00032 #include <stdexcept>
00033 #include "SignDocSDK-c.h"
00034 
00035 #ifndef SIGNDOC_PTR
00036 
00043 #define SIGNDOC_PTR std::auto_ptr
00044 #endif
00045 
00046 struct SPPDF_Document;
00047 
00048 namespace de { namespace softpro { namespace doc {
00049 
00050 class SignDocVerificationResult;
00051 class SignPKCS7;
00052 class SignRSA;
00053 
00054 #ifdef _MSC_VER
00055 #pragma warning(push)
00056 // C4800: forcing value to bool 'true' or 'false' (performance warning)
00057 #pragma warning(disable:4800)
00058 #endif
00059 
00064 inline void
00065 SignDoc_throw (SIGNDOC_Exception *aEx)
00066 {
00067   int type = SIGNDOC_Exception_getType (aEx);
00068   if (type == SIGNDOC_EXCEPTION_TYPE_BAD_ALLOC)
00069     throw (std::bad_alloc ());
00070   std::string msg;
00071   const char *text = SIGNDOC_Exception_getText (aEx);
00072   if (text != NULL)
00073     msg = text;
00074   SIGNDOC_Exception_delete (aEx);
00075 #if defined (SPOOC_EXCEPTION_H__) || defined (SPOOC_EXCEPTION_H_INCLUDED_)
00076   switch (type)
00077     {
00078     case SIGNDOC_EXCEPTION_TYPE_SPOOC_IO:
00079       throw spooc::IOError (msg);
00080     case SIGNDOC_EXCEPTION_TYPE_SPOOC_ENCODING_ERROR:
00081       throw spooc::EncodingError (msg);
00082     case SIGNDOC_EXCEPTION_TYPE_SPOOC_GENERIC:
00083       throw spooc::Exception (msg);
00084     default:
00085       throw std::runtime_error (msg);
00086     }
00087 #else
00088   throw std::runtime_error (msg);
00089 #endif
00090 }
00091 
00096 inline void
00097 SIGNDOC_catch (SIGNDOC_Exception **aEx, std::exception &aInput)
00098 {
00099   *aEx = SIGNDOC_Exception_new (SIGNDOC_EXCEPTION_TYPE_GENERIC,
00100                                 aInput.what ());
00101 }
00102 
00107 inline SignDocVerificationResult *
00108 makeSignDocVerificationResult (SIGNDOC_VerificationResult *aP);
00109 
00110 inline void assignArray (std::vector<unsigned char> &aDst,
00111                          SIGNDOC_ByteArray *aSrc)
00112 {
00113   unsigned n = 0;
00114   if (aSrc != NULL)
00115     n = SIGNDOC_ByteArray_count (aSrc);
00116   if (n == 0)
00117     aDst.clear ();
00118   else
00119     {
00120       const unsigned char *p = SIGNDOC_ByteArray_data (aSrc);
00121       aDst.assign (p, p + n);
00122     }
00123 }
00124 
00129 inline void assignArray (std::vector<std::vector<unsigned char> > &aDst,
00130                          SIGNDOC_ByteArrayArray *aSrc)
00131 {
00132   unsigned n = SIGNDOC_ByteArrayArray_count (aSrc);
00133   aDst.resize (n);
00134   for (unsigned i = 0; i < n; ++i)
00135     assignArray (aDst[i], SIGNDOC_ByteArrayArray_at (aSrc, i));
00136 }
00137 
00142 inline void assignArray (std::vector<std::string> &aDst,
00143                          SIGNDOC_StringArray *aSrc)
00144 {
00145   unsigned n = SIGNDOC_StringArray_count (aSrc);
00146   aDst.resize (n);
00147   for (unsigned i = 0; i < n; ++i)
00148     aDst[i] = SIGNDOC_StringArray_at (aSrc, i);
00149 }
00150 
00151 //----------------------------------------------------------------------------
00152 
00160 class InputStream
00161 {
00162 public:
00168   InputStream (SIGNDOC_InputStream *aImpl) : p (aImpl) { }
00169 
00173   virtual ~InputStream ()
00174   {
00175     SIGNDOC_InputStream_delete (p);
00176   }
00177 
00193   virtual int read (void *aDst, int aLen) = 0;
00194 
00201   virtual void close () = 0;
00202 
00211   virtual void seek (int aPos) = 0;
00212 
00221   virtual int tell () const = 0;
00222 
00235   virtual int getAvailable () = 0;
00236 
00241   SIGNDOC_InputStream *getImpl () { return p; }
00242 
00243 protected:
00247   SIGNDOC_InputStream *p;
00248 
00249 private:
00253   InputStream (const InputStream &);
00254 
00258   InputStream &operator= (const InputStream &);
00259 };
00260 
00266 class UserInputStream : public InputStream
00267 {
00268 public:
00272   UserInputStream ()
00273     : InputStream (NULL)
00274   {
00275     SIGNDOC_Exception *ex = NULL;
00276     p = SIGNDOC_UserInputStream_new (&ex, this,
00277                                      closeC, readC, seekC, tellC,
00278                                      getAvailableC);
00279     if (ex != NULL) SignDoc_throw (ex);
00280   }
00281 
00282 private:
00286   static void SDCAPI closeC (SIGNDOC_Exception **aEx,
00287                              void *aClosure)
00288   {
00289     *aEx = NULL;
00290     try
00291       {
00292         reinterpret_cast<UserInputStream*>(aClosure)->close ();
00293       }
00294     catch (std::exception &e)
00295       {
00296         SIGNDOC_catch (aEx, e);
00297       }
00298   }
00299 
00303   static int SDCAPI readC (SIGNDOC_Exception **aEx,
00304                            void *aClosure,
00305                            void *aDst, int aLen)
00306   {
00307     *aEx = NULL;
00308     try
00309       {
00310         return reinterpret_cast<UserInputStream*>(aClosure)->read (aDst, aLen);
00311       }
00312     catch (std::exception &e)
00313       {
00314         SIGNDOC_catch (aEx, e);
00315         return 0;
00316       }
00317   }
00318 
00322   static void SDCAPI seekC (SIGNDOC_Exception **aEx,
00323                             void *aClosure,
00324                             int aPos)
00325   {
00326     *aEx = NULL;
00327     try
00328       {
00329         return reinterpret_cast<UserInputStream*>(aClosure)->seek (aPos);
00330       }
00331     catch (std::exception &e)
00332       {
00333         SIGNDOC_catch (aEx, e);
00334       }
00335   }
00336 
00340   static int SDCAPI tellC (SIGNDOC_Exception **aEx,
00341                            const void *aClosure)
00342   {
00343     *aEx = NULL;
00344     try
00345       {
00346         return reinterpret_cast<const UserInputStream*>(aClosure)->tell ();
00347       }
00348     catch (std::exception &e)
00349       {
00350         SIGNDOC_catch (aEx, e);
00351         return 0;
00352       }
00353   }
00354 
00358   static int SDCAPI getAvailableC (SIGNDOC_Exception **aEx,
00359                                    void *aClosure)
00360   {
00361     *aEx = NULL;
00362     try
00363       {
00364         return reinterpret_cast<UserInputStream*>(aClosure)->getAvailable ();
00365       }
00366     catch (std::exception &e)
00367       {
00368         SIGNDOC_catch (aEx, e);
00369         return 0;
00370       }
00371   }
00372 };
00373 
00377 class LibraryInputStream : public InputStream
00378 {
00379 public:
00385   LibraryInputStream (SIGNDOC_InputStream *aImpl)
00386     : InputStream (aImpl) { }
00387 
00388   virtual int read (void *aDst, int aLen)
00389   {
00390     SIGNDOC_Exception *ex = NULL;
00391     int r = SIGNDOC_InputStream_read (&ex, p, aDst, aLen);
00392     if (ex != NULL) SignDoc_throw (ex);
00393     return r;
00394   }
00395 
00396   virtual void close ()
00397   {
00398     SIGNDOC_Exception *ex = NULL;
00399     SIGNDOC_InputStream_close (&ex, p);
00400     if (ex != NULL) SignDoc_throw (ex);
00401   }
00402 
00403   virtual void seek (int aPos)
00404   {
00405     SIGNDOC_Exception *ex = NULL;
00406     SIGNDOC_InputStream_seek (&ex, p, aPos);
00407     if (ex != NULL) SignDoc_throw (ex);
00408   }
00409 
00410   virtual int tell () const
00411   {
00412     SIGNDOC_Exception *ex = NULL;
00413     int r = SIGNDOC_InputStream_tell (&ex, p);
00414     if (ex != NULL) SignDoc_throw (ex);
00415     return r;
00416   }
00417 
00418   virtual int getAvailable ()
00419   {
00420     SIGNDOC_Exception *ex = NULL;
00421     int r = SIGNDOC_InputStream_getAvailable (&ex, p);
00422     if (ex != NULL) SignDoc_throw (ex);
00423     return r;
00424   }
00425 };
00426 
00427 #if defined (SPOOC_INPUTSTREAM_H__) || defined (SPOOC_INPUTSTREAM_H_INCLUDED_)
00428 
00429 class Spooc1InputStream : public spooc::InputStream
00430 {
00431 public:
00432   Spooc1InputStream (de::softpro::doc::InputStream &aStream)
00433      : mStream (aStream) { }
00434   virtual int read (void *aDst, int aLen) { return mStream.read (aDst, aLen); }
00435   virtual void close () { mStream.close (); }
00436   virtual void seek (int aPos) { mStream.seek (aPos); }
00437   virtual int tell () const { return mStream.tell (); }
00438   virtual int avail () { return mStream.getAvailable (); }
00439 private:
00440   de::softpro::doc::InputStream &mStream;
00441 };
00442 
00443 class Spooc2InputStream : public UserInputStream
00444 {
00445 public:
00446   Spooc2InputStream (spooc::InputStream &aStream)
00447      : mStream (aStream) { }
00448   virtual int read (void *aDst, int aLen) { return mStream.read (aDst, aLen); }
00449   virtual void close () { mStream.close (); }
00450   virtual void seek (int aPos) { mStream.seek (aPos); }
00451   virtual int tell () const { return mStream.tell (); }
00452   virtual int getAvailable () { return mStream.avail (); }
00453 private:
00454   spooc::InputStream &mStream;
00455 };
00456 
00457 #endif
00458 
00459 //----------------------------------------------------------------------------
00460 
00467 class FileInputStream : public LibraryInputStream
00468 {
00469 public:
00475   FileInputStream (FILE *aFile)
00476     : LibraryInputStream (NULL)
00477   {
00478     SIGNDOC_Exception *ex = NULL;
00479     p = SIGNDOC_FileInputStream_newWithFile (&ex, aFile);
00480     if (ex != NULL) SignDoc_throw (ex);
00481   };
00482 
00490   FileInputStream (FILE *aFile, const char *aPath)
00491     : LibraryInputStream (NULL)
00492   {
00493     SIGNDOC_Exception *ex = NULL;
00494     p = SIGNDOC_FileInputStream_newWithFileAndPath (&ex, aFile, aPath);
00495     if (ex != NULL) SignDoc_throw (ex);
00496   };
00497 
00505   FileInputStream (const char *aPath)
00506     : LibraryInputStream (NULL)
00507   {
00508     SIGNDOC_Exception *ex = NULL;
00509     p = SIGNDOC_FileInputStream_newWithPath (&ex, aPath);
00510     if (ex != NULL) SignDoc_throw (ex);
00511   };
00512 
00520   FileInputStream (const wchar_t *aPath)
00521     : LibraryInputStream (NULL)
00522   {
00523     SIGNDOC_Exception *ex = NULL;
00524     p = SIGNDOC_FileInputStream_newWithPathW (&ex, aPath);
00525     if (ex != NULL) SignDoc_throw (ex);
00526   };
00527 };
00528 
00529 //----------------------------------------------------------------------------
00530 
00534 class MemoryInputStream : public LibraryInputStream
00535 {
00536 public:
00547   MemoryInputStream (const unsigned char *aSrc, size_t aLen)
00548     : LibraryInputStream (NULL)
00549   {
00550     SIGNDOC_Exception *ex = NULL;
00551     p = SIGNDOC_MemoryInputStream_new (&ex, aSrc, aLen);
00552     if (ex != NULL) SignDoc_throw (ex);
00553   };
00554 };
00555 
00556 //----------------------------------------------------------------------------
00557 
00565 class OutputStream
00566 {
00567 public:
00573   OutputStream (SIGNDOC_OutputStream *aImpl) : p (aImpl) { }
00574 
00578   virtual ~OutputStream ()
00579   {
00580     SIGNDOC_OutputStream_delete (p);
00581   }
00582 
00594   virtual void close () = 0;
00595 
00604   virtual void flush () = 0;
00605 
00614   virtual void seek (int aPos) = 0;
00615 
00624   virtual int tell () const = 0;
00625 
00634   virtual void write (const void *aSrc, int aLen) = 0;
00635 
00640   SIGNDOC_OutputStream *getImpl () { return p; }
00641 
00642 protected:
00646   SIGNDOC_OutputStream *p;
00647 
00648 private:
00652   OutputStream (const OutputStream &);
00653 
00657   OutputStream &operator= (const OutputStream &);
00658 };
00659 
00665 class UserOutputStream : public OutputStream
00666 {
00667 public:
00671   UserOutputStream ()
00672     : OutputStream (NULL)
00673   {
00674     SIGNDOC_Exception *ex = NULL;
00675     p = SIGNDOC_UserOutputStream_new (&ex, this,
00676                                       closeC, flushC, writeC, seekC,
00677                                       tellC);
00678     if (ex != NULL) SignDoc_throw (ex);
00679   }
00680 
00681 private:
00685   static void SDCAPI closeC (SIGNDOC_Exception **aEx,
00686                              void *aClosure)
00687   {
00688     *aEx = NULL;
00689     try
00690       {
00691         reinterpret_cast<UserOutputStream*>(aClosure)->close ();
00692       }
00693     catch (std::exception &e)
00694       {
00695         SIGNDOC_catch (aEx, e);
00696       }
00697   }
00698 
00702   static void SDCAPI flushC (SIGNDOC_Exception **aEx,
00703                              void *aClosure)
00704   {
00705     *aEx = NULL;
00706     try
00707       {
00708         reinterpret_cast<UserOutputStream*>(aClosure)->flush ();
00709       }
00710     catch (std::exception &e)
00711       {
00712         SIGNDOC_catch (aEx, e);
00713       }
00714   }
00715 
00719   static void SDCAPI writeC (SIGNDOC_Exception **aEx,
00720                              void *aClosure,
00721                              const void *aSrc, int aLen)
00722   {
00723     *aEx = NULL;
00724     try
00725       {
00726         reinterpret_cast<UserOutputStream*>(aClosure)->write (aSrc, aLen);
00727       }
00728     catch (std::exception &e)
00729       {
00730         SIGNDOC_catch (aEx, e);
00731       }
00732   }
00733 
00737   static void SDCAPI seekC (SIGNDOC_Exception **aEx,
00738                             void *aClosure,
00739                             int aPos)
00740   {
00741     *aEx = NULL;
00742     try
00743       {
00744         return reinterpret_cast<UserOutputStream*>(aClosure)->seek (aPos);
00745       }
00746     catch (std::exception &e)
00747       {
00748         SIGNDOC_catch (aEx, e);
00749       }
00750   }
00751 
00755   static int SDCAPI tellC (SIGNDOC_Exception **aEx,
00756                            const void *aClosure)
00757   {
00758     *aEx = NULL;
00759     try
00760       {
00761         return reinterpret_cast<const UserOutputStream*>(aClosure)->tell ();
00762       }
00763     catch (std::exception &e)
00764       {
00765         SIGNDOC_catch (aEx, e);
00766         return 0;
00767       }
00768   }
00769 };
00770 
00774 class LibraryOutputStream : public OutputStream
00775 {
00776 public:
00782   LibraryOutputStream (SIGNDOC_OutputStream *aImpl)
00783     : OutputStream (aImpl) { }
00784 
00785   virtual void close ()
00786   {
00787     SIGNDOC_Exception *ex = NULL;
00788     SIGNDOC_OutputStream_close (&ex, p);
00789     if (ex != NULL) SignDoc_throw (ex);
00790   }
00791 
00792   virtual void flush ()
00793   {
00794     SIGNDOC_Exception *ex = NULL;
00795     SIGNDOC_OutputStream_flush (&ex, p);
00796     if (ex != NULL) SignDoc_throw (ex);
00797   }
00798 
00799   virtual void write (const void *aSrc, int aLen)
00800   {
00801     SIGNDOC_Exception *ex = NULL;
00802     SIGNDOC_OutputStream_write (&ex, p, aSrc, aLen);
00803     if (ex != NULL) SignDoc_throw (ex);
00804   }
00805 
00806   virtual void seek (int aPos)
00807   {
00808     SIGNDOC_Exception *ex = NULL;
00809     SIGNDOC_OutputStream_seek (&ex, p, aPos);
00810     if (ex != NULL) SignDoc_throw (ex);
00811   }
00812 
00813   virtual int tell () const
00814   {
00815     SIGNDOC_Exception *ex = NULL;
00816     int r = SIGNDOC_OutputStream_tell (&ex, p);
00817     if (ex != NULL) SignDoc_throw (ex);
00818     return r;
00819   }
00820 };
00821 
00822 #if defined (SPOOC_OUTPUTSTREAM_H__) || defined (SPOOC_OUTPUTSTREAM_H_INCLUDED_)
00823 
00824 class Spooc1OutputStream : public spooc::OutputStream
00825 {
00826 public:
00827   Spooc1OutputStream (de::softpro::doc::OutputStream &aStream)
00828     : mStream (aStream) { }
00829   virtual void close () { mStream.close (); }
00830   virtual void flush () { mStream.flush (); }
00831   virtual void write (const void *aSrc, int aLen) { mStream.write (aSrc, aLen); }
00832   virtual void seek (int aPos) { mStream.seek (aPos); }
00833   virtual int tell () const { return mStream.tell (); }
00834 private:
00835   de::softpro::doc::OutputStream &mStream;
00836 };
00837 
00838 class Spooc2OutputStream : public UserOutputStream
00839 {
00840 public:
00841   Spooc2OutputStream (spooc::OutputStream &aStream)
00842     : mStream (aStream) { }
00843   ~Spooc2OutputStream () { }
00844   virtual void close () { mStream.close (); }
00845   virtual void flush () { mStream.flush (); }
00846   virtual void write (const void *aSrc, int aLen) { mStream.write (aSrc, aLen); }
00847   virtual void seek (int aPos) { mStream.seek (aPos); }
00848   virtual int tell () const { return mStream.tell (); }
00849 private:
00850   spooc::OutputStream &mStream;
00851 };
00852 
00853 #endif
00854 
00855 //----------------------------------------------------------------------------
00856 
00863 class FileOutputStream : public LibraryOutputStream
00864 {
00865 public:
00871   FileOutputStream (FILE *aFile)
00872     : LibraryOutputStream (NULL)
00873   {
00874     SIGNDOC_Exception *ex = NULL;
00875     p = SIGNDOC_FileOutputStream_newWithFile (&ex, aFile);
00876     if (ex != NULL) SignDoc_throw (ex);
00877   };
00878 
00886   FileOutputStream (FILE *aFile, const char *aPath)
00887     : LibraryOutputStream (NULL)
00888   {
00889     SIGNDOC_Exception *ex = NULL;
00890     p = SIGNDOC_FileOutputStream_newWithFileAndPath (&ex, aFile, aPath);
00891     if (ex != NULL) SignDoc_throw (ex);
00892   };
00893 
00902   FileOutputStream (const char *aPath)
00903     : LibraryOutputStream (NULL)
00904   {
00905     SIGNDOC_Exception *ex = NULL;
00906     p = SIGNDOC_FileOutputStream_newWithPath (&ex, aPath);
00907     if (ex != NULL) SignDoc_throw (ex);
00908   };
00909 
00918   FileOutputStream (const wchar_t *aPath)
00919     : LibraryOutputStream (NULL)
00920   {
00921     SIGNDOC_Exception *ex = NULL;
00922     p = SIGNDOC_FileOutputStream_newWithPathW (&ex, aPath);
00923     if (ex != NULL) SignDoc_throw (ex);
00924   };
00925 };
00926 
00927 //----------------------------------------------------------------------------
00928 
00933 class MemoryOutputStream : public LibraryOutputStream
00934 {
00935 public:
00939   MemoryOutputStream ()
00940     : LibraryOutputStream (NULL)
00941   {
00942     SIGNDOC_Exception *ex = NULL;
00943     p = SIGNDOC_MemoryOutputStream_new (&ex);
00944     if (ex != NULL) SignDoc_throw (ex);
00945   };
00946 
00955   const unsigned char *data ()
00956   {
00957     SIGNDOC_Exception *ex = NULL;
00958     const unsigned char *r = SIGNDOC_MemoryOutputStream_data (&ex, p);
00959     if (ex != NULL) SignDoc_throw (ex);
00960     return r;
00961   }
00962 
00966   size_t length ()
00967   {
00968     SIGNDOC_Exception *ex = NULL;
00969     size_t r = SIGNDOC_MemoryOutputStream_length (&ex, p);
00970     if (ex != NULL) SignDoc_throw (ex);
00971     return r;
00972   }
00973 
00981   void clear ()
00982   {
00983     SIGNDOC_Exception *ex = NULL;
00984     SIGNDOC_MemoryOutputStream_clear (&ex, p);
00985     if (ex != NULL) SignDoc_throw (ex);
00986   }
00987 };
00991 enum Encoding
00992 {
00993   enc_native,      
00994   enc_utf_8,       
00995   enc_latin_1      
00996 };
00997 
01001 class Point 
01002 {
01003 public:
01009   Point ()
01010     : mX (0), mY (0)
01011   {
01012   }
01013 
01020   Point (double aX, double aY)
01021     : mX (aX), mY (aY)
01022   {
01023   }
01024 
01030   Point (const Point &aSrc)
01031     : mX (aSrc.mX), mY (aSrc.mY)
01032   {
01033   }
01034 
01038   ~Point ()
01039   {
01040   }
01041 
01048   void set (double aX, double aY)
01049   {
01050     SIGNDOC_Point_setXY ((SIGNDOC_Point*)this, aX, aY);
01051   }
01052 
01053 public:
01057   double mX;
01058 
01062   double mY;
01063 };
01064 
01071 class Rect 
01072 {
01073 public:
01079   Rect ()
01080     : mX1 (0), mY1 (0), mX2 (0), mY2 (0)
01081   {
01082   }
01083 
01092   Rect (double aX1, double aY1, double aX2, double aY2)
01093     : mX1 (aX1), mY1 (aY1), mX2 (aX2), mY2 (aY2)
01094   {
01095   }
01096 
01102   Rect (const Rect &aSrc)
01103     : mX1 (aSrc.mX1), mY1 (aSrc.mY1), mX2 (aSrc.mX2), mY2 (aSrc.mY2)
01104   {
01105   }
01106 
01110   ~Rect ()
01111   {
01112   }
01113 
01122   void get (double &aX1, double &aY1, double &aX2, double &aY2) const
01123   {
01124     SIGNDOC_Rect_get ((const SIGNDOC_Rect*)this, &aX1, &aY1, &aX2, &aY2);
01125   }
01126 
01135   void set (double aX1, double aY1, double aX2, double aY2)
01136   {
01137     SIGNDOC_Rect_setXY ((SIGNDOC_Rect*)this, aX1, aY1, aX2, aY2);
01138   }
01139 
01145   double getWidth () const
01146   {
01147     return SIGNDOC_Rect_getWidth ((const SIGNDOC_Rect*)this);
01148   }
01149 
01155   double getHeight () const
01156   {
01157     return SIGNDOC_Rect_getHeight ((const SIGNDOC_Rect*)this);
01158   }
01159 
01167   void normalize ()
01168   {
01169     SIGNDOC_Rect_normalize ((SIGNDOC_Rect*)this);
01170   }
01171 
01177   void scale (double aFactor)
01178   {
01179     SIGNDOC_Rect_scale ((SIGNDOC_Rect*)this, aFactor);
01180   }
01181 
01190   void scale (double aFactorX, double aFactorY)
01191   {
01192     SIGNDOC_Rect_scaleXY ((SIGNDOC_Rect*)this, aFactorX, aFactorY);
01193   }
01194 
01201   double getX1 () const
01202   {
01203     return mX1;
01204   }
01205 
01212   double getY1 () const
01213   {
01214     return mY1;
01215   }
01216 
01223   double getX2 () const
01224   {
01225     return mX2;
01226   }
01227 
01234   double getY2 () const
01235   {
01236     return mY2;
01237   }
01238 
01239 public:
01243   double mX1;
01244 
01248   double mY1;
01249 
01253   double mX2;
01254 
01258   double mY2;
01259 };
01260 
01264 class TimeStamper 
01265 {
01266 public:
01270   enum StampResult
01271   {
01275     sr_ok,
01276 
01280     sr_invalid_input,
01281 
01285     sr_timeout,
01286 
01290     sr_stopped,
01291 
01295     sr_tcp_error,
01296 
01300     sr_ssl_error,
01301 
01305     sr_http_error,
01306 
01311     sr_server_error,
01312 
01316     sr_invalid_response
01317   };
01318 
01322   enum StampFlags
01323   {
01329     sf_dont_check_revocation = 0x01
01330   };
01331 
01332 public:
01339   const char *getHashAlgorithm () const
01340   {
01341     return SIGNDOC_TimeStamper_getHashAlgorithm (p);
01342   }
01343 
01350   const char *getFallbackHashAlgorithm () const
01351   {
01352     return SIGNDOC_TimeStamper_getFallbackHashAlgorithm (p);
01353   }
01354 
01385   StampResult stamp (const unsigned char *aHashPtr, size_t aHashSize,
01386                      unsigned aRandomNonceSize, int aFlags,
01387                      std::vector<unsigned char> &aOutput, int &aStatus,
01388                      unsigned &aFailureInfo)
01389   {
01390     SIGNDOC_Exception *ex = NULL;
01391     SIGNDOC_ByteArray *tempOutput = NULL;
01392     StampResult r;
01393     try
01394       {
01395         tempOutput = SIGNDOC_ByteArray_new (&ex);
01396         if (ex != NULL) SignDoc_throw (ex);
01397         r = (StampResult)SIGNDOC_TimeStamper_stamp (&ex, p, aHashPtr, aHashSize, aRandomNonceSize, aFlags, tempOutput, &aStatus, &aFailureInfo);
01398         assignArray (aOutput, tempOutput);
01399       }
01400     catch (...)
01401       {
01402         if (tempOutput != NULL)
01403           SIGNDOC_ByteArray_delete (tempOutput);
01404         throw;
01405       }
01406     if (tempOutput != NULL)
01407       SIGNDOC_ByteArray_delete (tempOutput);
01408     if (ex != NULL) SignDoc_throw (ex);
01409     return r;
01410   }
01411 
01418   void stop ()
01419   {
01420     SIGNDOC_TimeStamper_stop (p);
01421   }
01422 
01433   const char *getErrorMessage () const
01434   {
01435     return SIGNDOC_TimeStamper_getErrorMessage (p);
01436   }
01437 
01438 protected:
01439 public:
01443   ~TimeStamper ()
01444   {
01445   }
01450   TimeStamper (SIGNDOC_TimeStamper *aP) : p (aP) { }
01451 
01456   SIGNDOC_TimeStamper *getImpl () { return p; }
01457 
01462   const SIGNDOC_TimeStamper *getImpl () const { return p; }
01463 
01464 private:
01465   SIGNDOC_TimeStamper *p;
01466 };
01467 
01473 class Source
01474 {
01475 public:
01481   Source (struct SIGNDOC_Source *aImpl)
01482     : p (aImpl) { }
01483 
01487   virtual ~Source () { }
01488 
01499   int fetch (const void *&aPtr, int aMaxSize)
01500   {
01501     struct SIGNDOC_Exception *ex = NULL;
01502     int r = SIGNDOC_Source_fetch (&ex, p, &aPtr, aMaxSize);
01503     if (ex != NULL) SignDoc_throw (ex);
01504     return r;
01505   }
01506 
01507 private:
01508   SIGNDOC_Source *p;
01509 };
01510 
01519 class SignPKCS7
01520 {
01521 public:
01525   enum HashAlgorithm
01526   {
01527     ha_none,                    
01528     ha_sha1,                    
01529     ha_sha256,                  
01530     ha_md5,                     
01531     ha_sha384,                  
01532     ha_sha512,                  
01533     ha_ripemd160                
01534   };
01535 
01539   SignPKCS7 ()
01540     : p (NULL), mBadAlloc (false)
01541   {
01542     struct SIGNDOC_Exception *ex = NULL;
01543     p = SIGNDOC_SignPKCS7_new (&ex, this, signC, getSignatureSizeC,
01544                                getSubjectCommonNameC, getErrorMessageC);
01545     if (ex != NULL) SignDoc_throw (ex);
01546   }
01547 
01553   virtual ~SignPKCS7 ()
01554   {
01555     SIGNDOC_SignPKCS7_delete (p);
01556   }
01557 
01576   virtual bool sign (Source &aSource, bool aDetached,
01577                      HashAlgorithm aHashAlgorithm,
01578                      TimeStamper *aTimeStamper,
01579                      std::vector<unsigned char> &aOutput) = 0;
01580 
01597   virtual size_t getSignatureSize (bool aDetached,
01598                                    HashAlgorithm aHashAlgorithm) = 0;
01599 
01609   virtual bool getSubjectCommonName (std::string &aOutput) const = 0;
01610 
01623   virtual const char *getErrorMessage () const = 0;
01624 
01629   SIGNDOC_SignPKCS7 *getImpl () { return p; }
01630 
01631 private:
01632   static SIGNDOC_Boolean SDCAPI
01633   signC (void *aClosure, struct SIGNDOC_Source *aSource,
01634          SIGNDOC_Boolean aDetached, int aHashAlgorithm,
01635          struct SIGNDOC_TimeStamper *aTimeStamper,
01636          struct SIGNDOC_ByteArray *aOutput)
01637   {
01638     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01639     s->mBadAlloc = false;
01640     try
01641       {
01642         SIGNDOC_ByteArray_clear (aOutput);
01643         std::vector<unsigned char> output;
01644         Source src (aSource);
01645         TimeStamper ts (aTimeStamper);
01646         bool ok = s->sign (src, aDetached, (HashAlgorithm)aHashAlgorithm,
01647                            (aTimeStamper != NULL) ? &ts : NULL,
01648                            output);
01649         if (ok)
01650           assignByteArray (aOutput, output);
01651         return ok;
01652       }
01653     catch (std::bad_alloc &)
01654       {
01655         s->mBadAlloc = true;
01656         return SIGNDOC_FALSE;
01657       }
01658   }
01659 
01660   static size_t SDCAPI
01661   getSignatureSizeC (void *aClosure, SIGNDOC_Boolean aDetached,
01662                      int aHashAlgorithm)
01663   {
01664     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01665     s->mBadAlloc = false;
01666     try
01667       {
01668         return s->getSignatureSize (aDetached, (HashAlgorithm)aHashAlgorithm);
01669       }
01670     catch (std::bad_alloc &)
01671       {
01672         s->mBadAlloc = true;
01673         return 0;
01674       }
01675   }
01676 
01677   static SIGNDOC_Boolean SDCAPI
01678   getSubjectCommonNameC (void *aClosure, char **aOutput)
01679   {
01680     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01681     s->mBadAlloc = false;
01682     try
01683       {
01684         *aOutput = NULL;
01685         std::string output;
01686         bool ok = s->getSubjectCommonName (output);
01687         if (ok)
01688           assignString (aOutput, output);
01689         return ok;
01690       }
01691     catch (std::bad_alloc &)
01692       {
01693         s->mBadAlloc = true;
01694         return SIGNDOC_FALSE;
01695       }
01696   }
01697 
01698   static const char * SDCAPI
01699   getErrorMessageC (void *aClosure)
01700   {
01701     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01702     if (s->mBadAlloc)
01703       return "out of memory";
01704     try
01705       {
01706         return s->getErrorMessage ();
01707       }
01708     catch (std::bad_alloc &)
01709       {
01710         s->mBadAlloc = true;
01711         return "out of memory";
01712       }
01713   }
01714 
01715   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
01716                                const std::vector<unsigned char> &aInput)
01717   {
01718     if (aInput.empty ())
01719       SIGNDOC_ByteArray_clear (aOutput);
01720     else
01721       {
01722         struct SIGNDOC_Exception *ex = NULL;
01723         SIGNDOC_ByteArray_set (&ex, aOutput,
01724                                &aInput[0], aInput.size ());
01725         if (ex != NULL) SignDoc_throw (ex);
01726       }
01727   }
01728 
01729   static void assignString (char **aOutput, const std::string &aInput)
01730   {
01731     struct SIGNDOC_Exception *ex = NULL;
01732     *aOutput = SIGNDOC_strdup (&ex, aInput.c_str ());
01733     if (ex != NULL) SignDoc_throw (ex);
01734   }
01735 
01736 private:
01737   SIGNDOC_SignPKCS7 *p;
01738   bool mBadAlloc;
01739 };
01740 
01746 class SignRSA
01747 {
01748 public:
01752   enum Version
01753   {
01757     v_1_5,
01758 
01764     v_2_0
01765   };
01766 
01770   enum HashAlgorithm
01771   {
01775     ha_sha1 = 1,
01776 
01780     ha_sha256 = 2,
01781 
01785     ha_sha384 = 3,
01786 
01790     ha_sha512 = 4,
01791 
01795     ha_ripemd160 = 5
01796   };
01797 
01798 public:
01802   SignRSA ()
01803     : p (NULL), mBadAlloc (false)
01804   {
01805     struct SIGNDOC_Exception *ex = NULL;
01806     p = SIGNDOC_SignRSA_new (&ex, this, signC, getSignatureSizeC,
01807                              getSigningCertificateC,
01808                              getCertificateCountC, getCertificateC,
01809                              getErrorMessageC);
01810     if (ex != NULL) SignDoc_throw (ex);
01811   }
01812 
01818   virtual ~SignRSA ()
01819   {
01820     SIGNDOC_SignRSA_delete (p);
01821   }
01822 
01837   virtual bool sign (Source &aSource,
01838                      Version aVersion, HashAlgorithm aHashAlgorithm,
01839                      std::vector<unsigned char> &aOutput) = 0;
01840 
01849   virtual int getSignatureSize () = 0;
01850 
01861   virtual bool getSigningCertificate (std::vector<unsigned char> &aOutput) const = 0;
01862 
01868   virtual int getCertificateCount () const = 0;
01869 
01882   virtual bool getCertificate (int aIndex,
01883                                std::vector<unsigned char> &aOutput) const = 0;
01884 
01897   virtual const char *getErrorMessage () const = 0;
01898 
01903   SIGNDOC_SignRSA *getImpl () { return p; }
01904 
01905 private:
01906   static SIGNDOC_Boolean SDCAPI
01907   signC (void *aClosure, struct SIGNDOC_Source *aSource,
01908          int aVersion, int aHashAlgorithm,
01909          struct SIGNDOC_ByteArray *aOutput)
01910   {
01911     SignRSA *s = static_cast<SignRSA*>(aClosure);
01912     s->mBadAlloc = false;
01913     try
01914       {
01915         std::vector<unsigned char> output;
01916         Source src (aSource);
01917         bool ok = s->sign (src, (Version)aVersion,
01918                            (HashAlgorithm)aHashAlgorithm, output);
01919         if (ok)
01920           assignByteArray (aOutput, output);
01921         return ok;
01922       }
01923     catch (std::bad_alloc &)
01924       {
01925         s->mBadAlloc = true;
01926         return SIGNDOC_FALSE;
01927       }
01928   }
01929 
01930   static int SDCAPI
01931   getSignatureSizeC (void *aClosure)
01932   {
01933     SignRSA *s = static_cast<SignRSA*>(aClosure);
01934     s->mBadAlloc = false;
01935     try
01936       {
01937         return s->getSignatureSize ();
01938       }
01939     catch (std::bad_alloc &)
01940       {
01941         s->mBadAlloc = true;
01942         return -1;
01943       }
01944   }
01945 
01946   static SIGNDOC_Boolean SDCAPI
01947   getSigningCertificateC (const void *aClosure,
01948                           struct SIGNDOC_ByteArray *aOutput)
01949   {
01950     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
01951     s->mBadAlloc = false;
01952     try
01953       {
01954         std::vector<unsigned char> output;
01955         bool ok = s->getSigningCertificate (output);
01956         if (ok)
01957           assignByteArray (aOutput, output);
01958         return ok;
01959       }
01960     catch (std::bad_alloc &)
01961       {
01962         s->mBadAlloc = true;
01963         return SIGNDOC_FALSE;
01964       }
01965   }
01966 
01967   static int SDCAPI
01968   getCertificateCountC (const void *aClosure)
01969   {
01970     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
01971     s->mBadAlloc = false;
01972     try
01973       {
01974         return s->getCertificateCount ();
01975       }
01976     catch (std::bad_alloc &)
01977       {
01978         s->mBadAlloc = true;
01979         return 0;
01980       }
01981   }
01982 
01983   static SIGNDOC_Boolean SDCAPI
01984   getCertificateC (const void *aClosure, int aIndex,
01985                    struct SIGNDOC_ByteArray *aOutput)
01986   {
01987     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
01988     s->mBadAlloc = false;
01989     try
01990       {
01991         std::vector<unsigned char> output;
01992         bool ok = s->getCertificate (aIndex, output);
01993         if (ok)
01994           assignByteArray (aOutput, output);
01995         return ok;
01996       }
01997     catch (std::bad_alloc &)
01998       {
01999         s->mBadAlloc = true;
02000         return SIGNDOC_FALSE;
02001       }
02002   }
02003 
02004   static const char * SDCAPI
02005   getErrorMessageC (const void *aClosure)
02006   {
02007     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
02008     if (s->mBadAlloc)
02009       return "out of memory";
02010     try
02011       {
02012         return s->getErrorMessage ();
02013       }
02014     catch (std::bad_alloc &)
02015       {
02016         s->mBadAlloc = true;
02017         return "out of memory";
02018       }
02019   }
02020 
02021   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
02022                                const std::vector<unsigned char> &aInput)
02023   {
02024     if (aInput.empty ())
02025       SIGNDOC_ByteArray_clear (aOutput);
02026     else
02027       {
02028         struct SIGNDOC_Exception *ex = NULL;
02029         SIGNDOC_ByteArray_set (&ex, aOutput,
02030                                &aInput[0], aInput.size ());
02031         if (ex != NULL) SignDoc_throw (ex);
02032       }
02033   }
02034 
02035 private:
02036   SIGNDOC_SignRSA *p;
02037   mutable bool mBadAlloc;
02038 };
02039 
02048 class SignDocColor 
02049 {
02050 public:
02051   enum Type
02052   {
02056     t_gray,
02057 
02061     t_rgb
02062   };
02063 
02064 public:
02068   ~SignDocColor ()
02069   {
02070     SIGNDOC_Color_delete (p);
02071   }
02072 
02078   SignDocColor *clone () const
02079   {
02080     SIGNDOC_Exception *ex = NULL;
02081     SIGNDOC_Color *r;
02082     r = SIGNDOC_Color_clone (&ex, p);
02083     if (ex != NULL) SignDoc_throw (ex);
02084     if (r == NULL)
02085       return NULL;
02086     try
02087       {
02088         return new SignDocColor (r);
02089       }
02090     catch (...)
02091       {
02092         SIGNDOC_Color_delete (r);
02093         throw;
02094       }
02095   }
02096 
02102   Type getType () const
02103   {
02104     return (Type)SIGNDOC_Color_getType (p);
02105   }
02106 
02112   unsigned getNumberOfComponents () const
02113   {
02114     return SIGNDOC_Color_getNumberOfComponents (p);
02115   }
02116 
02126   unsigned char getComponent (unsigned aIndex) const
02127   {
02128     return SIGNDOC_Color_getComponent (p, aIndex);
02129   }
02130 
02137   unsigned char getIntensity () const
02138   {
02139     return SIGNDOC_Color_getIntensity (p);
02140   }
02141 
02148   unsigned char getRed () const
02149   {
02150     return SIGNDOC_Color_getRed (p);
02151   }
02152 
02159   unsigned char getGreen () const
02160   {
02161     return SIGNDOC_Color_getGreen (p);
02162   }
02163 
02170   unsigned char getBlue () const
02171   {
02172     return SIGNDOC_Color_getBlue (p);
02173   }
02174 
02183   static SignDocColor *createGray (unsigned char aIntensity)
02184   {
02185     SIGNDOC_Exception *ex = NULL;
02186     SIGNDOC_Color *r;
02187     r = SIGNDOC_Color_createGray (&ex, aIntensity);
02188     if (ex != NULL) SignDoc_throw (ex);
02189     if (r == NULL)
02190       return NULL;
02191     try
02192       {
02193         return new SignDocColor (r);
02194       }
02195     catch (...)
02196       {
02197         SIGNDOC_Color_delete (r);
02198         throw;
02199       }
02200   }
02201 
02214   static SignDocColor *createRGB (unsigned char aRed, unsigned char aGreen,
02215                                   unsigned char aBlue)
02216   {
02217     SIGNDOC_Exception *ex = NULL;
02218     SIGNDOC_Color *r;
02219     r = SIGNDOC_Color_createRGB (&ex, aRed, aGreen, aBlue);
02220     if (ex != NULL) SignDoc_throw (ex);
02221     if (r == NULL)
02222       return NULL;
02223     try
02224       {
02225         return new SignDocColor (r);
02226       }
02227     catch (...)
02228       {
02229         SIGNDOC_Color_delete (r);
02230         throw;
02231       }
02232   }
02233 
02234 private:
02240   SignDocColor ();
02241 
02247   // cppcheck-suppress noExplicitCopyMoveConstructor
02248   SignDocColor (const SignDocColor &);
02249 
02255   SignDocColor &operator= (const SignDocColor &);
02256 
02257 public:
02262   SignDocColor (SIGNDOC_Color *aP) : p (aP) { }
02263 
02268   SIGNDOC_Color *getImpl () { return p; }
02269 
02274   const SIGNDOC_Color *getImpl () const { return p; }
02275 
02280   void setImpl (SIGNDOC_Color *aP) { SIGNDOC_Color_delete (p); p  = aP; }
02281 
02282 private:
02283   SIGNDOC_Color *p;
02284 };
02285 
02300 class SignDocTextFieldAttributes 
02301 {
02302 public:
02303 
02304 public:
02308   SignDocTextFieldAttributes ()
02309     : p (NULL)
02310   {
02311     SIGNDOC_Exception *ex = NULL;
02312     p = SIGNDOC_TextFieldAttributes_new (&ex);
02313     if (ex != NULL) SignDoc_throw (ex);
02314   }
02315 
02321   SignDocTextFieldAttributes (const SignDocTextFieldAttributes &aSource)
02322     : p (NULL)
02323   {
02324     SIGNDOC_Exception *ex = NULL;
02325     p = SIGNDOC_TextFieldAttributes_clone (&ex, aSource.getImpl ());
02326     if (ex != NULL) SignDoc_throw (ex);
02327   }
02328 
02332   ~SignDocTextFieldAttributes ()
02333   {
02334     SIGNDOC_TextFieldAttributes_delete (p);
02335   }
02336 
02342   SignDocTextFieldAttributes &operator= (const SignDocTextFieldAttributes &aSource)
02343   {
02344     SIGNDOC_Exception *ex = NULL;
02345     SIGNDOC_TextFieldAttributes_assign (&ex, p, aSource.getImpl ());
02346     if (ex != NULL) SignDoc_throw (ex);
02347     return *this;
02348   }
02349 
02355   void swap (SignDocTextFieldAttributes &aOther)
02356   {
02357     std::swap (p, aOther.p);
02358   }
02359 
02375   bool isSet () const
02376   {
02377     SIGNDOC_Exception *ex = NULL;
02378     bool r;
02379     r = (bool)SIGNDOC_TextFieldAttributes_isSet (&ex, p);
02380     if (ex != NULL) SignDoc_throw (ex);
02381     return r;
02382   }
02383 
02395   bool isValid () const
02396   {
02397     SIGNDOC_Exception *ex = NULL;
02398     bool r;
02399     r = (bool)SIGNDOC_TextFieldAttributes_isValid (&ex, p);
02400     if (ex != NULL) SignDoc_throw (ex);
02401     return r;
02402   }
02403 
02409   void clear ()
02410   {
02411     SIGNDOC_Exception *ex = NULL;
02412     SIGNDOC_TextFieldAttributes_clear (&ex, p);
02413     if (ex != NULL) SignDoc_throw (ex);
02414   }
02415 
02427   std::string getFontName (Encoding aEncoding) const
02428   {
02429     SIGNDOC_Exception *ex = NULL;
02430     std::string r;
02431     char *s = SIGNDOC_TextFieldAttributes_getFontName (&ex, p, aEncoding);
02432     if (ex != NULL) SignDoc_throw (ex);
02433     try
02434       {
02435         r = s;
02436       }
02437     catch (...)
02438       {
02439         SIGNDOC_free (s);
02440         throw;
02441       }
02442     SIGNDOC_free (s);
02443     return r;
02444   }
02445 
02458   void setFontName (Encoding aEncoding, const std::string &aFontName)
02459   {
02460     SIGNDOC_Exception *ex = NULL;
02461     SIGNDOC_TextFieldAttributes_setFontName (&ex, p, aEncoding, aFontName.c_str ());
02462     if (ex != NULL) SignDoc_throw (ex);
02463   }
02464 
02478   std::string getFontResourceName (Encoding aEncoding) const
02479   {
02480     SIGNDOC_Exception *ex = NULL;
02481     std::string r;
02482     char *s = SIGNDOC_TextFieldAttributes_getFontResourceName (&ex, p, aEncoding);
02483     if (ex != NULL) SignDoc_throw (ex);
02484     try
02485       {
02486         r = s;
02487       }
02488     catch (...)
02489       {
02490         SIGNDOC_free (s);
02491         throw;
02492       }
02493     SIGNDOC_free (s);
02494     return r;
02495   }
02496 
02508   double getFontSize () const
02509   {
02510     SIGNDOC_Exception *ex = NULL;
02511     double r;
02512     r = SIGNDOC_TextFieldAttributes_getFontSize (&ex, p);
02513     if (ex != NULL) SignDoc_throw (ex);
02514     return r;
02515   }
02516 
02526   void setFontSize (double aFontSize)
02527   {
02528     SIGNDOC_Exception *ex = NULL;
02529     SIGNDOC_TextFieldAttributes_setFontSize (&ex, p, aFontSize);
02530     if (ex != NULL) SignDoc_throw (ex);
02531   }
02532 
02544   SignDocColor *getTextColor () const
02545   {
02546     SIGNDOC_Exception *ex = NULL;
02547     SIGNDOC_Color *r;
02548     r = SIGNDOC_TextFieldAttributes_getTextColor (&ex, p);
02549     if (ex != NULL) SignDoc_throw (ex);
02550     if (r == NULL)
02551       return NULL;
02552     try
02553       {
02554         return new SignDocColor (r);
02555       }
02556     catch (...)
02557       {
02558         SIGNDOC_Color_delete (r);
02559         throw;
02560       }
02561   }
02562 
02568   void setTextColor (const SignDocColor &aTextColor)
02569   {
02570     SIGNDOC_Exception *ex = NULL;
02571     SIGNDOC_TextFieldAttributes_setTextColor (&ex, p, aTextColor.getImpl ());
02572     if (ex != NULL) SignDoc_throw (ex);
02573   }
02574 
02590   std::string getRest (Encoding aEncoding) const
02591   {
02592     SIGNDOC_Exception *ex = NULL;
02593     std::string r;
02594     char *s = SIGNDOC_TextFieldAttributes_getRest (&ex, p, aEncoding);
02595     if (ex != NULL) SignDoc_throw (ex);
02596     try
02597       {
02598         r = s;
02599       }
02600     catch (...)
02601       {
02602         SIGNDOC_free (s);
02603         throw;
02604       }
02605     SIGNDOC_free (s);
02606     return r;
02607   }
02608 
02618   void setRest (Encoding aEncoding, const std::string &aInput)
02619   {
02620     SIGNDOC_Exception *ex = NULL;
02621     SIGNDOC_TextFieldAttributes_setRest (&ex, p, aEncoding, aInput.c_str ());
02622     if (ex != NULL) SignDoc_throw (ex);
02623   }
02624 
02625 private:
02626 public:
02631   SignDocTextFieldAttributes (SIGNDOC_TextFieldAttributes *aP) : p (aP) { }
02632 
02637   SIGNDOC_TextFieldAttributes *getImpl () { return p; }
02638 
02643   const SIGNDOC_TextFieldAttributes *getImpl () const { return p; }
02644 
02649   void setImpl (SIGNDOC_TextFieldAttributes *aP) { SIGNDOC_TextFieldAttributes_delete (p); p  = aP; }
02650 
02651 private:
02652   SIGNDOC_TextFieldAttributes *p;
02653 };
02654 
02963 class SignDocField 
02964 {
02965 public:
02966 
02967 public:
02973   enum Type
02974   {
02975     t_unknown,              
02976     t_pushbutton,           
02977     t_check_box,            
02978     t_radio_button,         
02979     t_text,                 
02980     t_list_box,             
02981     t_signature_digsig,     
02982     t_signature_signdoc,    
02983     t_combo_box             
02984   };
02985 
03035   enum Flag
03036   {
03037     f_ReadOnly          = 1 << 0,  
03038     f_Required          = 1 << 1,  
03039     f_NoExport          = 1 << 2,  
03040     f_NoToggleToOff     = 1 << 3,  
03041     f_Radio             = 1 << 4,  
03042     f_Pushbutton        = 1 << 5,  
03043     f_RadiosInUnison    = 1 << 6,  
03044 
03055     f_MultiLine         = 1 << 7,
03056 
03057     f_Password          = 1 << 8,  
03058     f_FileSelect        = 1 << 9,  
03059     f_DoNotSpellCheck   = 1 << 10, 
03060     f_DoNotScroll       = 1 << 11, 
03061     f_Comb              = 1 << 12, 
03062     f_RichText          = 1 << 13, 
03063     f_Combo             = 1 << 14, 
03064     f_Edit              = 1 << 15, 
03065     f_Sort              = 1 << 16, 
03066     f_MultiSelect       = 1 << 17, 
03067     f_CommitOnSelChange = 1 << 18, 
03068     f_SinglePage        = 1 << 28, 
03069     f_EnableAddAfterSigning = 1 << 29, 
03070     f_Invisible         = 1 << 30  
03071   };
03072 
03082   enum WidgetFlag
03083   {
03084     wf_Invisible      = 1 << (1 - 1), 
03085     wf_Hidden         = 1 << (2 - 1), 
03086     wf_Print          = 1 << (3 - 1), 
03087     wf_NoZoom         = 1 << (4 - 1), 
03088     wf_NoRotate       = 1 << (5 - 1), 
03089     wf_NoView         = 1 << (6 - 1), 
03090     wf_ReadOnly       = 1 << (7 - 1), 
03091     wf_Locked         = 1 << (8 - 1), 
03092     wf_ToggleNoView   = 1 << (9 - 1), 
03093     wf_LockedContents = 1 << (10 - 1) 
03094   };
03095 
03101   enum Justification
03102   {
03103     j_none,             
03104     j_left,             
03105     j_center,           
03106     j_right             
03107   };
03108 
03114   enum BorderStyle
03115   {
03116     bos_other,                  
03117     bos_solid,                  
03118     bos_dashed,                 
03119     bos_beveled,                
03120     bos_inset,                  
03121     bos_underline               
03122   };
03123 
03129   enum ButtonStyle
03130   {
03131     bus_default,        
03132     bus_other,          
03133     bus_check_mark,     
03134     bus_cross,          
03135     bus_star,           
03136     bus_circle,         
03137     bus_square,         
03138     bus_diamond         
03139   };
03140 
03146   enum LockType
03147   {
03148     lt_na,              
03149     lt_none,            
03150     lt_all,             
03151     lt_include,         
03152     lt_exclude          
03153   };
03154 
03160   enum CertSeedValueFlag
03161   {
03162     csvf_SubjectCert = 0x01,    
03163     csvf_IssuerCert  = 0x02,    
03164     csvf_Policy      = 0x04,    
03165     csvf_SubjectDN   = 0x08,    
03166     csvf_KeyUsage    = 0x20,    
03167     csvf_URL         = 0x40     
03168   };
03169 
03170 public:
03176   SignDocField ()
03177     : p (NULL)
03178   {
03179     SIGNDOC_Exception *ex = NULL;
03180     p = SIGNDOC_Field_new (&ex);
03181     if (ex != NULL) SignDoc_throw (ex);
03182   }
03183 
03189   SignDocField (const SignDocField &aSource)
03190     : p (NULL)
03191   {
03192     SIGNDOC_Exception *ex = NULL;
03193     p = SIGNDOC_Field_clone (&ex, aSource.getImpl ());
03194     if (ex != NULL) SignDoc_throw (ex);
03195   }
03196 
03200   ~SignDocField ()
03201   {
03202     SIGNDOC_Field_delete (p);
03203   }
03204 
03210   SignDocField &operator= (const SignDocField &aSource)
03211   {
03212     SIGNDOC_Exception *ex = NULL;
03213     SIGNDOC_Field_assign (&ex, p, aSource.getImpl ());
03214     if (ex != NULL) SignDoc_throw (ex);
03215     return *this;
03216   }
03217 
03223   void swap (SignDocField &aOther)
03224   {
03225     std::swap (p, aOther.p);
03226   }
03227 
03240   std::string getName (Encoding aEncoding) const
03241   {
03242     SIGNDOC_Exception *ex = NULL;
03243     std::string r;
03244     char *s = SIGNDOC_Field_getName (&ex, p, aEncoding);
03245     if (ex != NULL) SignDoc_throw (ex);
03246     try
03247       {
03248         r = s;
03249       }
03250     catch (...)
03251       {
03252         SIGNDOC_free (s);
03253         throw;
03254       }
03255     SIGNDOC_free (s);
03256     return r;
03257   }
03258 
03265   const char *getNameUTF8 () const
03266   {
03267     SIGNDOC_Exception *ex = NULL;
03268     const char *r;
03269     r = SIGNDOC_Field_getNameUTF8 (&ex, p);
03270     if (ex != NULL) SignDoc_throw (ex);
03271     return r;
03272   }
03273 
03295   void setName (Encoding aEncoding, const std::string &aName)
03296   {
03297     SIGNDOC_Exception *ex = NULL;
03298     SIGNDOC_Field_setName (&ex, p, aEncoding, aName.c_str ());
03299     if (ex != NULL) SignDoc_throw (ex);
03300   }
03301 
03318   void setName (const wchar_t *aName)
03319   {
03320     SIGNDOC_Exception *ex = NULL;
03321     SIGNDOC_Field_setNameW (&ex, p, aName);
03322     if (ex != NULL) SignDoc_throw (ex);
03323   }
03324 
03342   std::string getAlternateName (Encoding aEncoding) const
03343   {
03344     SIGNDOC_Exception *ex = NULL;
03345     std::string r;
03346     char *s = SIGNDOC_Field_getAlternateName (&ex, p, aEncoding);
03347     if (ex != NULL) SignDoc_throw (ex);
03348     try
03349       {
03350         r = s;
03351       }
03352     catch (...)
03353       {
03354         SIGNDOC_free (s);
03355         throw;
03356       }
03357     SIGNDOC_free (s);
03358     return r;
03359   }
03360 
03378   void setAlternateName (Encoding aEncoding, const std::string &aName)
03379   {
03380     SIGNDOC_Exception *ex = NULL;
03381     SIGNDOC_Field_setAlternateName (&ex, p, aEncoding, aName.c_str ());
03382     if (ex != NULL) SignDoc_throw (ex);
03383   }
03384 
03401   std::string getMappingName (Encoding aEncoding) const
03402   {
03403     SIGNDOC_Exception *ex = NULL;
03404     std::string r;
03405     char *s = SIGNDOC_Field_getMappingName (&ex, p, aEncoding);
03406     if (ex != NULL) SignDoc_throw (ex);
03407     try
03408       {
03409         r = s;
03410       }
03411     catch (...)
03412       {
03413         SIGNDOC_free (s);
03414         throw;
03415       }
03416     SIGNDOC_free (s);
03417     return r;
03418   }
03419 
03436   void setMappingName (Encoding aEncoding, const std::string &aName)
03437   {
03438     SIGNDOC_Exception *ex = NULL;
03439     SIGNDOC_Field_setMappingName (&ex, p, aEncoding, aName.c_str ());
03440     if (ex != NULL) SignDoc_throw (ex);
03441   }
03442 
03454   int getValueCount () const
03455   {
03456     SIGNDOC_Exception *ex = NULL;
03457     int r;
03458     r = SIGNDOC_Field_getValueCount (&ex, p);
03459     if (ex != NULL) SignDoc_throw (ex);
03460     return r;
03461   }
03462 
03483   std::string getValue (Encoding aEncoding, int aIndex) const
03484   {
03485     SIGNDOC_Exception *ex = NULL;
03486     std::string r;
03487     char *s = SIGNDOC_Field_getValue (&ex, p, aEncoding, aIndex);
03488     if (ex != NULL) SignDoc_throw (ex);
03489     try
03490       {
03491         r = s;
03492       }
03493     catch (...)
03494       {
03495         SIGNDOC_free (s);
03496         throw;
03497       }
03498     SIGNDOC_free (s);
03499     return r;
03500   }
03501 
03520   const char *getValueUTF8 (int aIndex) const
03521   {
03522     SIGNDOC_Exception *ex = NULL;
03523     const char *r;
03524     r = SIGNDOC_Field_getValueUTF8 (&ex, p, aIndex);
03525     if (ex != NULL) SignDoc_throw (ex);
03526     return r;
03527   }
03528 
03537   void clearValues ()
03538   {
03539     SIGNDOC_Exception *ex = NULL;
03540     SIGNDOC_Field_clearValues (&ex, p);
03541     if (ex != NULL) SignDoc_throw (ex);
03542   }
03543 
03568   void addValue (Encoding aEncoding, const std::string &aValue)
03569   {
03570     SIGNDOC_Exception *ex = NULL;
03571     SIGNDOC_Field_addValue (&ex, p, aEncoding, aValue.c_str ());
03572     if (ex != NULL) SignDoc_throw (ex);
03573   }
03574 
03603   bool setValue (int aIndex, Encoding aEncoding, const std::string &aValue)
03604   {
03605     SIGNDOC_Exception *ex = NULL;
03606     bool r;
03607     r = (bool)SIGNDOC_Field_setValueByIndex (&ex, p, aIndex, aEncoding, aValue.c_str ());
03608     if (ex != NULL) SignDoc_throw (ex);
03609     return r;
03610   }
03611 
03639   void setValue (Encoding aEncoding, const std::string &aValue)
03640   {
03641     SIGNDOC_Exception *ex = NULL;
03642     SIGNDOC_Field_setValue (&ex, p, aEncoding, aValue.c_str ());
03643     if (ex != NULL) SignDoc_throw (ex);
03644   }
03645 
03657   bool removeValue (int aIndex)
03658   {
03659     SIGNDOC_Exception *ex = NULL;
03660     bool r;
03661     r = (bool)SIGNDOC_Field_removeValue (&ex, p, aIndex);
03662     if (ex != NULL) SignDoc_throw (ex);
03663     return r;
03664   }
03665 
03693   int getValueIndex () const
03694   {
03695     SIGNDOC_Exception *ex = NULL;
03696     int r;
03697     r = SIGNDOC_Field_getValueIndex (&ex, p);
03698     if (ex != NULL) SignDoc_throw (ex);
03699     return r;
03700   }
03701 
03754   void setValueIndex (int aIndex)
03755   {
03756     SIGNDOC_Exception *ex = NULL;
03757     SIGNDOC_Field_setValueIndex (&ex, p, aIndex);
03758     if (ex != NULL) SignDoc_throw (ex);
03759   }
03760 
03782   bool clickButton (int aIndex)
03783   {
03784     SIGNDOC_Exception *ex = NULL;
03785     bool r;
03786     r = (bool)SIGNDOC_Field_clickButton (&ex, p, aIndex);
03787     if (ex != NULL) SignDoc_throw (ex);
03788     return r;
03789   }
03790 
03802   int getChoiceCount () const
03803   {
03804     SIGNDOC_Exception *ex = NULL;
03805     int r;
03806     r = SIGNDOC_Field_getChoiceCount (&ex, p);
03807     if (ex != NULL) SignDoc_throw (ex);
03808     return r;
03809   }
03810 
03834   std::string getChoiceValue (Encoding aEncoding, int aIndex) const
03835   {
03836     SIGNDOC_Exception *ex = NULL;
03837     std::string r;
03838     char *s = SIGNDOC_Field_getChoiceValue (&ex, p, aEncoding, aIndex);
03839     if (ex != NULL) SignDoc_throw (ex);
03840     try
03841       {
03842         r = s;
03843       }
03844     catch (...)
03845       {
03846         SIGNDOC_free (s);
03847         throw;
03848       }
03849     SIGNDOC_free (s);
03850     return r;
03851   }
03852 
03875   const char *getChoiceValueUTF8 (int aIndex) const
03876   {
03877     SIGNDOC_Exception *ex = NULL;
03878     const char *r;
03879     r = SIGNDOC_Field_getChoiceValueUTF8 (&ex, p, aIndex);
03880     if (ex != NULL) SignDoc_throw (ex);
03881     return r;
03882   }
03883 
03907   std::string getChoiceExport (Encoding aEncoding, int aIndex) const
03908   {
03909     SIGNDOC_Exception *ex = NULL;
03910     std::string r;
03911     char *s = SIGNDOC_Field_getChoiceExport (&ex, p, aEncoding, aIndex);
03912     if (ex != NULL) SignDoc_throw (ex);
03913     try
03914       {
03915         r = s;
03916       }
03917     catch (...)
03918       {
03919         SIGNDOC_free (s);
03920         throw;
03921       }
03922     SIGNDOC_free (s);
03923     return r;
03924   }
03925 
03948   const char *getChoiceExportUTF8 (int aIndex) const
03949   {
03950     SIGNDOC_Exception *ex = NULL;
03951     const char *r;
03952     r = SIGNDOC_Field_getChoiceExportUTF8 (&ex, p, aIndex);
03953     if (ex != NULL) SignDoc_throw (ex);
03954     return r;
03955   }
03956 
03964   void clearChoices ()
03965   {
03966     SIGNDOC_Exception *ex = NULL;
03967     SIGNDOC_Field_clearChoices (&ex, p);
03968     if (ex != NULL) SignDoc_throw (ex);
03969   }
03970 
03989   void addChoice (Encoding aEncoding, const std::string &aValue)
03990   {
03991     SIGNDOC_Exception *ex = NULL;
03992     SIGNDOC_Field_addChoice (&ex, p, aEncoding, aValue.c_str ());
03993     if (ex != NULL) SignDoc_throw (ex);
03994   }
03995 
04013   void addChoice (Encoding aEncoding, const std::string &aValue,
04014                   const std::string &aExport)
04015   {
04016     SIGNDOC_Exception *ex = NULL;
04017     SIGNDOC_Field_addChoiceWithExport (&ex, p, aEncoding, aValue.c_str (), aExport.c_str ());
04018     if (ex != NULL) SignDoc_throw (ex);
04019   }
04020 
04044   bool setChoice (int aIndex, Encoding aEncoding, const std::string &aValue)
04045   {
04046     SIGNDOC_Exception *ex = NULL;
04047     bool r;
04048     r = (bool)SIGNDOC_Field_setChoice (&ex, p, aIndex, aEncoding, aValue.c_str ());
04049     if (ex != NULL) SignDoc_throw (ex);
04050     return r;
04051   }
04052 
04075   bool setChoice (int aIndex, Encoding aEncoding, const std::string &aValue,
04076                   const std::string &aExport)
04077   {
04078     SIGNDOC_Exception *ex = NULL;
04079     bool r;
04080     r = (bool)SIGNDOC_Field_setChoiceWithExport (&ex, p, aIndex, aEncoding, aValue.c_str (), aExport.c_str ());
04081     if (ex != NULL) SignDoc_throw (ex);
04082     return r;
04083   }
04084 
04094   bool removeChoice (int aIndex)
04095   {
04096     SIGNDOC_Exception *ex = NULL;
04097     bool r;
04098     r = (bool)SIGNDOC_Field_removeChoice (&ex, p, aIndex);
04099     if (ex != NULL) SignDoc_throw (ex);
04100     return r;
04101   }
04102 
04112   Type getType () const
04113   {
04114     SIGNDOC_Exception *ex = NULL;
04115     Type r;
04116     r = (Type)SIGNDOC_Field_getType (&ex, p);
04117     if (ex != NULL) SignDoc_throw (ex);
04118     return r;
04119   }
04120 
04132   void setType (Type aType)
04133   {
04134     SIGNDOC_Exception *ex = NULL;
04135     SIGNDOC_Field_setType (&ex, p, aType);
04136     if (ex != NULL) SignDoc_throw (ex);
04137   }
04138 
04148   int getFlags () const
04149   {
04150     SIGNDOC_Exception *ex = NULL;
04151     int r;
04152     r = SIGNDOC_Field_getFlags (&ex, p);
04153     if (ex != NULL) SignDoc_throw (ex);
04154     return r;
04155   }
04156 
04166   void setFlags (int aFlags)
04167   {
04168     SIGNDOC_Exception *ex = NULL;
04169     SIGNDOC_Field_setFlags (&ex, p, aFlags);
04170     if (ex != NULL) SignDoc_throw (ex);
04171   }
04172 
04185   bool isSigned () const
04186   {
04187     SIGNDOC_Exception *ex = NULL;
04188     bool r;
04189     r = (bool)SIGNDOC_Field_isSigned (&ex, p);
04190     if (ex != NULL) SignDoc_throw (ex);
04191     return r;
04192   }
04193 
04211   bool isCurrentlyClearable () const
04212   {
04213     SIGNDOC_Exception *ex = NULL;
04214     bool r;
04215     r = (bool)SIGNDOC_Field_isCurrentlyClearable (&ex, p);
04216     if (ex != NULL) SignDoc_throw (ex);
04217     return r;
04218   }
04219 
04231   int getMaxLen () const
04232   {
04233     SIGNDOC_Exception *ex = NULL;
04234     int r;
04235     r = SIGNDOC_Field_getMaxLen (&ex, p);
04236     if (ex != NULL) SignDoc_throw (ex);
04237     return r;
04238   }
04239 
04248   void setMaxLen (int aMaxLen)
04249   {
04250     SIGNDOC_Exception *ex = NULL;
04251     SIGNDOC_Field_setMaxLen (&ex, p, aMaxLen);
04252     if (ex != NULL) SignDoc_throw (ex);
04253   }
04254 
04266   int getTopIndex () const
04267   {
04268     SIGNDOC_Exception *ex = NULL;
04269     int r;
04270     r = SIGNDOC_Field_getTopIndex (&ex, p);
04271     if (ex != NULL) SignDoc_throw (ex);
04272     return r;
04273   }
04274 
04286   void setTopIndex (int aTopIndex)
04287   {
04288     SIGNDOC_Exception *ex = NULL;
04289     SIGNDOC_Field_setTopIndex (&ex, p, aTopIndex);
04290     if (ex != NULL) SignDoc_throw (ex);
04291   }
04292 
04305   int getWidget () const
04306   {
04307     SIGNDOC_Exception *ex = NULL;
04308     int r;
04309     r = SIGNDOC_Field_getWidget (&ex, p);
04310     if (ex != NULL) SignDoc_throw (ex);
04311     return r;
04312   }
04313 
04324   int getWidgetCount () const
04325   {
04326     SIGNDOC_Exception *ex = NULL;
04327     int r;
04328     r = SIGNDOC_Field_getWidgetCount (&ex, p);
04329     if (ex != NULL) SignDoc_throw (ex);
04330     return r;
04331   }
04332 
04352   bool selectWidget (int aIndex)
04353   {
04354     SIGNDOC_Exception *ex = NULL;
04355     bool r;
04356     r = (bool)SIGNDOC_Field_selectWidget (&ex, p, aIndex);
04357     if (ex != NULL) SignDoc_throw (ex);
04358     return r;
04359   }
04360 
04376   bool addWidget ()
04377   {
04378     SIGNDOC_Exception *ex = NULL;
04379     bool r;
04380     r = (bool)SIGNDOC_Field_addWidget (&ex, p);
04381     if (ex != NULL) SignDoc_throw (ex);
04382     return r;
04383   }
04384 
04405   bool insertWidget (int aIndex)
04406   {
04407     SIGNDOC_Exception *ex = NULL;
04408     bool r;
04409     r = (bool)SIGNDOC_Field_insertWidget (&ex, p, aIndex);
04410     if (ex != NULL) SignDoc_throw (ex);
04411     return r;
04412   }
04413 
04439   bool removeWidget (int aIndex)
04440   {
04441     SIGNDOC_Exception *ex = NULL;
04442     bool r;
04443     r = (bool)SIGNDOC_Field_removeWidget (&ex, p, aIndex);
04444     if (ex != NULL) SignDoc_throw (ex);
04445     return r;
04446   }
04447 
04460   int getWidgetFlags () const
04461   {
04462     SIGNDOC_Exception *ex = NULL;
04463     int r;
04464     r = SIGNDOC_Field_getWidgetFlags (&ex, p);
04465     if (ex != NULL) SignDoc_throw (ex);
04466     return r;
04467   }
04468 
04481   void setWidgetFlags (int aFlags)
04482   {
04483     SIGNDOC_Exception *ex = NULL;
04484     SIGNDOC_Field_setWidgetFlags (&ex, p, aFlags);
04485     if (ex != NULL) SignDoc_throw (ex);
04486   }
04487 
04499   int getPage () const
04500   {
04501     SIGNDOC_Exception *ex = NULL;
04502     int r;
04503     r = SIGNDOC_Field_getPage (&ex, p);
04504     if (ex != NULL) SignDoc_throw (ex);
04505     return r;
04506   }
04507 
04524   void setPage (int aPage)
04525   {
04526     SIGNDOC_Exception *ex = NULL;
04527     SIGNDOC_Field_setPage (&ex, p, aPage);
04528     if (ex != NULL) SignDoc_throw (ex);
04529   }
04530 
04541   double getLeft () const
04542   {
04543     SIGNDOC_Exception *ex = NULL;
04544     double r;
04545     r = SIGNDOC_Field_getLeft (&ex, p);
04546     if (ex != NULL) SignDoc_throw (ex);
04547     return r;
04548   }
04549 
04560   void setLeft (double aLeft)
04561   {
04562     SIGNDOC_Exception *ex = NULL;
04563     SIGNDOC_Field_setLeft (&ex, p, aLeft);
04564     if (ex != NULL) SignDoc_throw (ex);
04565   }
04566 
04577   double getBottom () const
04578   {
04579     SIGNDOC_Exception *ex = NULL;
04580     double r;
04581     r = SIGNDOC_Field_getBottom (&ex, p);
04582     if (ex != NULL) SignDoc_throw (ex);
04583     return r;
04584   }
04585 
04596   void setBottom (double aBottom)
04597   {
04598     SIGNDOC_Exception *ex = NULL;
04599     SIGNDOC_Field_setBottom (&ex, p, aBottom);
04600     if (ex != NULL) SignDoc_throw (ex);
04601   }
04602 
04615   double getRight () const
04616   {
04617     SIGNDOC_Exception *ex = NULL;
04618     double r;
04619     r = SIGNDOC_Field_getRight (&ex, p);
04620     if (ex != NULL) SignDoc_throw (ex);
04621     return r;
04622   }
04623 
04636   void setRight (double aRight)
04637   {
04638     SIGNDOC_Exception *ex = NULL;
04639     SIGNDOC_Field_setRight (&ex, p, aRight);
04640     if (ex != NULL) SignDoc_throw (ex);
04641   }
04642 
04655   double getTop () const
04656   {
04657     SIGNDOC_Exception *ex = NULL;
04658     double r;
04659     r = SIGNDOC_Field_getTop (&ex, p);
04660     if (ex != NULL) SignDoc_throw (ex);
04661     return r;
04662   }
04663 
04676   void setTop (double aTop)
04677   {
04678     SIGNDOC_Exception *ex = NULL;
04679     SIGNDOC_Field_setTop (&ex, p, aTop);
04680     if (ex != NULL) SignDoc_throw (ex);
04681   }
04682 
04704   std::string getButtonValue (Encoding aEncoding) const
04705   {
04706     SIGNDOC_Exception *ex = NULL;
04707     std::string r;
04708     char *s = SIGNDOC_Field_getButtonValue (&ex, p, aEncoding);
04709     if (ex != NULL) SignDoc_throw (ex);
04710     try
04711       {
04712         r = s;
04713       }
04714     catch (...)
04715       {
04716         SIGNDOC_free (s);
04717         throw;
04718       }
04719     SIGNDOC_free (s);
04720     return r;
04721   }
04722 
04736   const char *getButtonValueUTF8 () const
04737   {
04738     SIGNDOC_Exception *ex = NULL;
04739     const char *r;
04740     r = SIGNDOC_Field_getButtonValueUTF8 (&ex, p);
04741     if (ex != NULL) SignDoc_throw (ex);
04742     return r;
04743   }
04744 
04769   void setButtonValue (Encoding aEncoding, const std::string &aValue)
04770   {
04771     SIGNDOC_Exception *ex = NULL;
04772     SIGNDOC_Field_setButtonValue (&ex, p, aEncoding, aValue.c_str ());
04773     if (ex != NULL) SignDoc_throw (ex);
04774   }
04775 
04786   Justification getJustification () const
04787   {
04788     SIGNDOC_Exception *ex = NULL;
04789     Justification r;
04790     r = (Justification)SIGNDOC_Field_getJustification (&ex, p);
04791     if (ex != NULL) SignDoc_throw (ex);
04792     return r;
04793   }
04794 
04808   void setJustification (Justification aJustification)
04809   {
04810     SIGNDOC_Exception *ex = NULL;
04811     SIGNDOC_Field_setJustification (&ex, p, aJustification);
04812     if (ex != NULL) SignDoc_throw (ex);
04813   }
04814 
04828   int getRotation () const
04829   {
04830     SIGNDOC_Exception *ex = NULL;
04831     int r;
04832     r = SIGNDOC_Field_getRotation (&ex, p);
04833     if (ex != NULL) SignDoc_throw (ex);
04834     return r;
04835   }
04836 
04852   void setRotation (int aRotation)
04853   {
04854     SIGNDOC_Exception *ex = NULL;
04855     SIGNDOC_Field_setRotation (&ex, p, aRotation);
04856     if (ex != NULL) SignDoc_throw (ex);
04857   }
04858 
04874   bool getTextFieldAttributes (SignDocTextFieldAttributes &aOutput) const
04875   {
04876     SIGNDOC_Exception *ex = NULL;
04877     bool r;
04878     r = (bool)SIGNDOC_Field_getTextFieldAttributes (&ex, p, aOutput.getImpl ());
04879     if (ex != NULL) SignDoc_throw (ex);
04880     return r;
04881   }
04882 
04921   bool setTextFieldAttributes (const SignDocTextFieldAttributes &aInput)
04922   {
04923     SIGNDOC_Exception *ex = NULL;
04924     bool r;
04925     r = (bool)SIGNDOC_Field_setTextFieldAttributes (&ex, p, aInput.getImpl ());
04926     if (ex != NULL) SignDoc_throw (ex);
04927     return r;
04928   }
04929 
04942   SignDocColor *getBackgroundColor () const
04943   {
04944     SIGNDOC_Exception *ex = NULL;
04945     SIGNDOC_Color *r;
04946     r = SIGNDOC_Field_getBackgroundColor (&ex, p);
04947     if (ex != NULL) SignDoc_throw (ex);
04948     if (r == NULL)
04949       return NULL;
04950     try
04951       {
04952         return new SignDocColor (r);
04953       }
04954     catch (...)
04955       {
04956         SIGNDOC_Color_delete (r);
04957         throw;
04958       }
04959   }
04960 
04973   void setBackgroundColor (const SignDocColor *aColor)
04974   {
04975     SIGNDOC_Exception *ex = NULL;
04976     SIGNDOC_Field_setBackgroundColor (&ex, p, aColor == NULL ? NULL : aColor->getImpl ());
04977     if (ex != NULL) SignDoc_throw (ex);
04978   }
04979 
04993   SignDocColor *getBorderColor () const
04994   {
04995     SIGNDOC_Exception *ex = NULL;
04996     SIGNDOC_Color *r;
04997     r = SIGNDOC_Field_getBorderColor (&ex, p);
04998     if (ex != NULL) SignDoc_throw (ex);
04999     if (r == NULL)
05000       return NULL;
05001     try
05002       {
05003         return new SignDocColor (r);
05004       }
05005     catch (...)
05006       {
05007         SIGNDOC_Color_delete (r);
05008         throw;
05009       }
05010   }
05011 
05031   void setBorderColor (const SignDocColor *aColor)
05032   {
05033     SIGNDOC_Exception *ex = NULL;
05034     SIGNDOC_Field_setBorderColor (&ex, p, aColor == NULL ? NULL : aColor->getImpl ());
05035     if (ex != NULL) SignDoc_throw (ex);
05036   }
05037 
05047   double getBorderWidth () const
05048   {
05049     SIGNDOC_Exception *ex = NULL;
05050     double r;
05051     r = SIGNDOC_Field_getBorderWidth (&ex, p);
05052     if (ex != NULL) SignDoc_throw (ex);
05053     return r;
05054   }
05055 
05067   void setBorderWidth (double aWidth)
05068   {
05069     SIGNDOC_Exception *ex = NULL;
05070     SIGNDOC_Field_setBorderWidth (&ex, p, aWidth);
05071     if (ex != NULL) SignDoc_throw (ex);
05072   }
05073 
05083   BorderStyle getBorderStyle () const
05084   {
05085     SIGNDOC_Exception *ex = NULL;
05086     BorderStyle r;
05087     r = (BorderStyle)SIGNDOC_Field_getBorderStyle (&ex, p);
05088     if (ex != NULL) SignDoc_throw (ex);
05089     return r;
05090   }
05091 
05105   void setBorderStyle (BorderStyle aStyle)
05106   {
05107     SIGNDOC_Exception *ex = NULL;
05108     SIGNDOC_Field_setBorderStyle (&ex, p, aStyle);
05109     if (ex != NULL) SignDoc_throw (ex);
05110   }
05111 
05122   ButtonStyle getButtonStyle () const
05123   {
05124     SIGNDOC_Exception *ex = NULL;
05125     ButtonStyle r;
05126     r = (ButtonStyle)SIGNDOC_Field_getButtonStyle (&ex, p);
05127     if (ex != NULL) SignDoc_throw (ex);
05128     return r;
05129   }
05130 
05144   void setButtonStyle (ButtonStyle aStyle)
05145   {
05146     SIGNDOC_Exception *ex = NULL;
05147     SIGNDOC_Field_setButtonStyle (&ex, p, aStyle);
05148     if (ex != NULL) SignDoc_throw (ex);
05149   }
05150 
05161   LockType getLockType () const
05162   {
05163     SIGNDOC_Exception *ex = NULL;
05164     LockType r;
05165     r = (LockType)SIGNDOC_Field_getLockType (&ex, p);
05166     if (ex != NULL) SignDoc_throw (ex);
05167     return r;
05168   }
05169 
05180   void setLockType (LockType aLockType)
05181   {
05182     SIGNDOC_Exception *ex = NULL;
05183     SIGNDOC_Field_setLockType (&ex, p, aLockType);
05184     if (ex != NULL) SignDoc_throw (ex);
05185   }
05186 
05194   int getLockFieldCount () const
05195   {
05196     SIGNDOC_Exception *ex = NULL;
05197     int r;
05198     r = SIGNDOC_Field_getLockFieldCount (&ex, p);
05199     if (ex != NULL) SignDoc_throw (ex);
05200     return r;
05201   }
05202 
05217   std::string getLockField (Encoding aEncoding, int aIndex) const
05218   {
05219     SIGNDOC_Exception *ex = NULL;
05220     std::string r;
05221     char *s = SIGNDOC_Field_getLockField (&ex, p, aEncoding, aIndex);
05222     if (ex != NULL) SignDoc_throw (ex);
05223     try
05224       {
05225         r = s;
05226       }
05227     catch (...)
05228       {
05229         SIGNDOC_free (s);
05230         throw;
05231       }
05232     SIGNDOC_free (s);
05233     return r;
05234   }
05235 
05248   const char *getLockFieldUTF8 (int aIndex) const
05249   {
05250     SIGNDOC_Exception *ex = NULL;
05251     const char *r;
05252     r = SIGNDOC_Field_getLockFieldUTF8 (&ex, p, aIndex);
05253     if (ex != NULL) SignDoc_throw (ex);
05254     return r;
05255   }
05256 
05264   void clearLockFields ()
05265   {
05266     SIGNDOC_Exception *ex = NULL;
05267     SIGNDOC_Field_clearLockFields (&ex, p);
05268     if (ex != NULL) SignDoc_throw (ex);
05269   }
05270 
05283   void addLockField (Encoding aEncoding, const std::string &aName)
05284   {
05285     SIGNDOC_Exception *ex = NULL;
05286     SIGNDOC_Field_addLockField (&ex, p, aEncoding, aName.c_str ());
05287     if (ex != NULL) SignDoc_throw (ex);
05288   }
05289 
05307   bool setLockField (int aIndex, Encoding aEncoding, const std::string &aName)
05308   {
05309     SIGNDOC_Exception *ex = NULL;
05310     bool r;
05311     r = (bool)SIGNDOC_Field_setLockFieldByIndex (&ex, p, aIndex, aEncoding, aName.c_str ());
05312     if (ex != NULL) SignDoc_throw (ex);
05313     return r;
05314   }
05315 
05332   void setLockField (Encoding aEncoding, const std::string &aName)
05333   {
05334     SIGNDOC_Exception *ex = NULL;
05335     SIGNDOC_Field_setLockField (&ex, p, aEncoding, aName.c_str ());
05336     if (ex != NULL) SignDoc_throw (ex);
05337   }
05338 
05348   bool removeLockField (int aIndex)
05349   {
05350     SIGNDOC_Exception *ex = NULL;
05351     bool r;
05352     r = (bool)SIGNDOC_Field_removeLockField (&ex, p, aIndex);
05353     if (ex != NULL) SignDoc_throw (ex);
05354     return r;
05355   }
05356 
05367   unsigned getCertSeedValueFlags () const
05368   {
05369     SIGNDOC_Exception *ex = NULL;
05370     unsigned r;
05371     r = SIGNDOC_Field_getCertSeedValueFlags (&ex, p);
05372     if (ex != NULL) SignDoc_throw (ex);
05373     return r;
05374   }
05375 
05387   void setCertSeedValueFlags (unsigned aFlags)
05388   {
05389     SIGNDOC_Exception *ex = NULL;
05390     SIGNDOC_Field_setCertSeedValueFlags (&ex, p, aFlags);
05391     if (ex != NULL) SignDoc_throw (ex);
05392   }
05393 
05402   int getCertSeedValueSubjectDNCount () const
05403   {
05404     SIGNDOC_Exception *ex = NULL;
05405     int r;
05406     r = SIGNDOC_Field_getCertSeedValueSubjectDNCount (&ex, p);
05407     if (ex != NULL) SignDoc_throw (ex);
05408     return r;
05409   }
05410 
05430   std::string getCertSeedValueSubjectDN (Encoding aEncoding, int aIndex) const
05431   {
05432     SIGNDOC_Exception *ex = NULL;
05433     std::string r;
05434     char *s = SIGNDOC_Field_getCertSeedValueSubjectDN (&ex, p, aEncoding, aIndex);
05435     if (ex != NULL) SignDoc_throw (ex);
05436     try
05437       {
05438         r = s;
05439       }
05440     catch (...)
05441       {
05442         SIGNDOC_free (s);
05443         throw;
05444       }
05445     SIGNDOC_free (s);
05446     return r;
05447   }
05448 
05468   const char *getCertSeedValueSubjectDNUTF8 (int aIndex) const
05469   {
05470     SIGNDOC_Exception *ex = NULL;
05471     const char *r;
05472     r = SIGNDOC_Field_getCertSeedValueSubjectDNUTF8 (&ex, p, aIndex);
05473     if (ex != NULL) SignDoc_throw (ex);
05474     return r;
05475   }
05476 
05487   void clearCertSeedValueSubjectDNs ()
05488   {
05489     SIGNDOC_Exception *ex = NULL;
05490     SIGNDOC_Field_clearCertSeedValueSubjectDNs (&ex, p);
05491     if (ex != NULL) SignDoc_throw (ex);
05492   }
05493 
05514   bool addCertSeedValueSubjectDN (Encoding aEncoding, const std::string &aName)
05515   {
05516     SIGNDOC_Exception *ex = NULL;
05517     bool r;
05518     r = (bool)SIGNDOC_Field_addCertSeedValueSubjectDN (&ex, p, aEncoding, aName.c_str ());
05519     if (ex != NULL) SignDoc_throw (ex);
05520     return r;
05521   }
05522 
05547   bool setCertSeedValueSubjectDN (int aIndex, Encoding aEncoding,
05548                                   const std::string &aName)
05549   {
05550     SIGNDOC_Exception *ex = NULL;
05551     bool r;
05552     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectDNByIndex (&ex, p, aIndex, aEncoding, aName.c_str ());
05553     if (ex != NULL) SignDoc_throw (ex);
05554     return r;
05555   }
05556 
05581   bool setCertSeedValueSubjectDN (Encoding aEncoding, const std::string &aName)
05582   {
05583     SIGNDOC_Exception *ex = NULL;
05584     bool r;
05585     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectDN (&ex, p, aEncoding, aName.c_str ());
05586     if (ex != NULL) SignDoc_throw (ex);
05587     return r;
05588   }
05589 
05602   bool removeCertSeedValueSubjectDN (int aIndex)
05603   {
05604     SIGNDOC_Exception *ex = NULL;
05605     bool r;
05606     r = (bool)SIGNDOC_Field_removeCertSeedValueSubjectDN (&ex, p, aIndex);
05607     if (ex != NULL) SignDoc_throw (ex);
05608     return r;
05609   }
05610 
05621   int getCertSeedValueSubjectCertificateCount () const
05622   {
05623     SIGNDOC_Exception *ex = NULL;
05624     int r;
05625     r = SIGNDOC_Field_getCertSeedValueSubjectCertificateCount (&ex, p);
05626     if (ex != NULL) SignDoc_throw (ex);
05627     return r;
05628   }
05629 
05642   bool getCertSeedValueSubjectCertificate (int aIndex,
05643                                            std::vector<unsigned char> &aOutput) const
05644   {
05645     SIGNDOC_Exception *ex = NULL;
05646     SIGNDOC_ByteArray *tempOutput = NULL;
05647     bool r;
05648     try
05649       {
05650         tempOutput = SIGNDOC_ByteArray_new (&ex);
05651         if (ex != NULL) SignDoc_throw (ex);
05652         r = (bool)SIGNDOC_Field_getCertSeedValueSubjectCertificate (&ex, p, aIndex, tempOutput);
05653         assignArray (aOutput, tempOutput);
05654       }
05655     catch (...)
05656       {
05657         if (tempOutput != NULL)
05658           SIGNDOC_ByteArray_delete (tempOutput);
05659         throw;
05660       }
05661     if (tempOutput != NULL)
05662       SIGNDOC_ByteArray_delete (tempOutput);
05663     if (ex != NULL) SignDoc_throw (ex);
05664     return r;
05665   }
05666 
05676   void clearCertSeedValueSubjectCertificates ()
05677   {
05678     SIGNDOC_Exception *ex = NULL;
05679     SIGNDOC_Field_clearCertSeedValueSubjectCertificates (&ex, p);
05680     if (ex != NULL) SignDoc_throw (ex);
05681   }
05682 
05694   void addCertSeedValueSubjectCertificate (const void *aPtr, size_t aSize)
05695   {
05696     SIGNDOC_Exception *ex = NULL;
05697     SIGNDOC_Field_addCertSeedValueSubjectCertificate (&ex, p, aPtr, aSize);
05698     if (ex != NULL) SignDoc_throw (ex);
05699   }
05700 
05717   bool setCertSeedValueSubjectCertificate (int aIndex, const void *aPtr,
05718                                            size_t aSize)
05719   {
05720     SIGNDOC_Exception *ex = NULL;
05721     bool r;
05722     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectCertificateByIndex (&ex, p, aIndex, aPtr, aSize);
05723     if (ex != NULL) SignDoc_throw (ex);
05724     return r;
05725   }
05726 
05741   void setCertSeedValueSubjectCertificate (const void *aPtr, size_t aSize)
05742   {
05743     SIGNDOC_Exception *ex = NULL;
05744     SIGNDOC_Field_setCertSeedValueSubjectCertificate (&ex, p, aPtr, aSize);
05745     if (ex != NULL) SignDoc_throw (ex);
05746   }
05747 
05761   bool removeCertSeedValueSubjectCertificate (int aIndex)
05762   {
05763     SIGNDOC_Exception *ex = NULL;
05764     bool r;
05765     r = (bool)SIGNDOC_Field_removeCertSeedValueSubjectCertificate (&ex, p, aIndex);
05766     if (ex != NULL) SignDoc_throw (ex);
05767     return r;
05768   }
05769 
05780   int getCertSeedValueIssuerCertificateCount () const
05781   {
05782     SIGNDOC_Exception *ex = NULL;
05783     int r;
05784     r = SIGNDOC_Field_getCertSeedValueIssuerCertificateCount (&ex, p);
05785     if (ex != NULL) SignDoc_throw (ex);
05786     return r;
05787   }
05788 
05801   bool getCertSeedValueIssuerCertificate (int aIndex,
05802                                           std::vector<unsigned char> &aOutput) const
05803   {
05804     SIGNDOC_Exception *ex = NULL;
05805     SIGNDOC_ByteArray *tempOutput = NULL;
05806     bool r;
05807     try
05808       {
05809         tempOutput = SIGNDOC_ByteArray_new (&ex);
05810         if (ex != NULL) SignDoc_throw (ex);
05811         r = (bool)SIGNDOC_Field_getCertSeedValueIssuerCertificate (&ex, p, aIndex, tempOutput);
05812         assignArray (aOutput, tempOutput);
05813       }
05814     catch (...)
05815       {
05816         if (tempOutput != NULL)
05817           SIGNDOC_ByteArray_delete (tempOutput);
05818         throw;
05819       }
05820     if (tempOutput != NULL)
05821       SIGNDOC_ByteArray_delete (tempOutput);
05822     if (ex != NULL) SignDoc_throw (ex);
05823     return r;
05824   }
05825 
05835   void clearCertSeedValueIssuerCertificates ()
05836   {
05837     SIGNDOC_Exception *ex = NULL;
05838     SIGNDOC_Field_clearCertSeedValueIssuerCertificates (&ex, p);
05839     if (ex != NULL) SignDoc_throw (ex);
05840   }
05841 
05853   void addCertSeedValueIssuerCertificate (const void *aPtr, size_t aSize)
05854   {
05855     SIGNDOC_Exception *ex = NULL;
05856     SIGNDOC_Field_addCertSeedValueIssuerCertificate (&ex, p, aPtr, aSize);
05857     if (ex != NULL) SignDoc_throw (ex);
05858   }
05859 
05876   bool setCertSeedValueIssuerCertificate (int aIndex, const void *aPtr,
05877                                           size_t aSize)
05878   {
05879     SIGNDOC_Exception *ex = NULL;
05880     bool r;
05881     r = (bool)SIGNDOC_Field_setCertSeedValueIssuerCertificateByIndex (&ex, p, aIndex, aPtr, aSize);
05882     if (ex != NULL) SignDoc_throw (ex);
05883     return r;
05884   }
05885 
05900   void setCertSeedValueIssuerCertificate (const void *aPtr, size_t aSize)
05901   {
05902     SIGNDOC_Exception *ex = NULL;
05903     SIGNDOC_Field_setCertSeedValueIssuerCertificate (&ex, p, aPtr, aSize);
05904     if (ex != NULL) SignDoc_throw (ex);
05905   }
05906 
05920   bool removeCertSeedValueIssuerCertificate (int aIndex)
05921   {
05922     SIGNDOC_Exception *ex = NULL;
05923     bool r;
05924     r = (bool)SIGNDOC_Field_removeCertSeedValueIssuerCertificate (&ex, p, aIndex);
05925     if (ex != NULL) SignDoc_throw (ex);
05926     return r;
05927   }
05928 
05938   int getCertSeedValuePolicyCount () const
05939   {
05940     SIGNDOC_Exception *ex = NULL;
05941     int r;
05942     r = SIGNDOC_Field_getCertSeedValuePolicyCount (&ex, p);
05943     if (ex != NULL) SignDoc_throw (ex);
05944     return r;
05945   }
05946 
05965   std::string getCertSeedValuePolicy (Encoding aEncoding, int aIndex) const
05966   {
05967     SIGNDOC_Exception *ex = NULL;
05968     std::string r;
05969     char *s = SIGNDOC_Field_getCertSeedValuePolicy (&ex, p, aEncoding, aIndex);
05970     if (ex != NULL) SignDoc_throw (ex);
05971     try
05972       {
05973         r = s;
05974       }
05975     catch (...)
05976       {
05977         SIGNDOC_free (s);
05978         throw;
05979       }
05980     SIGNDOC_free (s);
05981     return r;
05982   }
05983 
06001   const char *getCertSeedValuePolicyUTF8 (int aIndex) const
06002   {
06003     SIGNDOC_Exception *ex = NULL;
06004     const char *r;
06005     r = SIGNDOC_Field_getCertSeedValuePolicyUTF8 (&ex, p, aIndex);
06006     if (ex != NULL) SignDoc_throw (ex);
06007     return r;
06008   }
06009 
06019   void clearCertSeedValuePolicies ()
06020   {
06021     SIGNDOC_Exception *ex = NULL;
06022     SIGNDOC_Field_clearCertSeedValuePolicies (&ex, p);
06023     if (ex != NULL) SignDoc_throw (ex);
06024   }
06025 
06042   void addCertSeedValuePolicy (Encoding aEncoding, const std::string &aOID)
06043   {
06044     SIGNDOC_Exception *ex = NULL;
06045     SIGNDOC_Field_addCertSeedValuePolicy (&ex, p, aEncoding, aOID.c_str ());
06046     if (ex != NULL) SignDoc_throw (ex);
06047   }
06048 
06070   bool setCertSeedValuePolicy (int aIndex, Encoding aEncoding,
06071                                const std::string &aOID)
06072   {
06073     SIGNDOC_Exception *ex = NULL;
06074     bool r;
06075     r = (bool)SIGNDOC_Field_setCertSeedValuePolicyByIndex (&ex, p, aIndex, aEncoding, aOID.c_str ());
06076     if (ex != NULL) SignDoc_throw (ex);
06077     return r;
06078   }
06079 
06100   void setCertSeedValuePolicy (Encoding aEncoding, const std::string &aOID)
06101   {
06102     SIGNDOC_Exception *ex = NULL;
06103     SIGNDOC_Field_setCertSeedValuePolicy (&ex, p, aEncoding, aOID.c_str ());
06104     if (ex != NULL) SignDoc_throw (ex);
06105   }
06106 
06118   bool removeCertSeedValuePolicy (int aIndex)
06119   {
06120     SIGNDOC_Exception *ex = NULL;
06121     bool r;
06122     r = (bool)SIGNDOC_Field_removeCertSeedValuePolicy (&ex, p, aIndex);
06123     if (ex != NULL) SignDoc_throw (ex);
06124     return r;
06125   }
06126 
06143   std::string getSeedValueTimeStampServerURL (Encoding aEncoding) const
06144   {
06145     SIGNDOC_Exception *ex = NULL;
06146     std::string r;
06147     char *s = SIGNDOC_Field_getSeedValueTimeStampServerURL (&ex, p, aEncoding);
06148     if (ex != NULL) SignDoc_throw (ex);
06149     try
06150       {
06151         r = s;
06152       }
06153     catch (...)
06154       {
06155         SIGNDOC_free (s);
06156         throw;
06157       }
06158     SIGNDOC_free (s);
06159     return r;
06160   }
06161 
06176   bool getSeedValueTimeStampRequired () const
06177   {
06178     SIGNDOC_Exception *ex = NULL;
06179     bool r;
06180     r = (bool)SIGNDOC_Field_getSeedValueTimeStampRequired (&ex, p);
06181     if (ex != NULL) SignDoc_throw (ex);
06182     return r;
06183   }
06184 
06206   bool setSeedValueTimeStamp (Encoding aEncoding, const std::string &aURL,
06207                               bool aRequired)
06208   {
06209     SIGNDOC_Exception *ex = NULL;
06210     bool r;
06211     r = (bool)SIGNDOC_Field_setSeedValueTimeStamp (&ex, p, aEncoding, aURL.c_str (), aRequired);
06212     if (ex != NULL) SignDoc_throw (ex);
06213     return r;
06214   }
06215 
06233   std::string getSeedValueFilter (Encoding aEncoding) const
06234   {
06235     SIGNDOC_Exception *ex = NULL;
06236     std::string r;
06237     char *s = SIGNDOC_Field_getSeedValueFilter (&ex, p, aEncoding);
06238     if (ex != NULL) SignDoc_throw (ex);
06239     try
06240       {
06241         r = s;
06242       }
06243     catch (...)
06244       {
06245         SIGNDOC_free (s);
06246         throw;
06247       }
06248     SIGNDOC_free (s);
06249     return r;
06250   }
06251 
06267   bool getSeedValueFilterRequired () const
06268   {
06269     SIGNDOC_Exception *ex = NULL;
06270     bool r;
06271     r = (bool)SIGNDOC_Field_getSeedValueFilterRequired (&ex, p);
06272     if (ex != NULL) SignDoc_throw (ex);
06273     return r;
06274   }
06275 
06298   bool setSeedValueFilter (Encoding aEncoding, const std::string &aFilter,
06299                            bool aRequired)
06300   {
06301     SIGNDOC_Exception *ex = NULL;
06302     bool r;
06303     r = (bool)SIGNDOC_Field_setSeedValueFilter (&ex, p, aEncoding, aFilter.c_str (), aRequired);
06304     if (ex != NULL) SignDoc_throw (ex);
06305     return r;
06306   }
06307 
06317   int getSeedValueSubFilterCount () const
06318   {
06319     SIGNDOC_Exception *ex = NULL;
06320     int r;
06321     r = SIGNDOC_Field_getSeedValueSubFilterCount (&ex, p);
06322     if (ex != NULL) SignDoc_throw (ex);
06323     return r;
06324   }
06325 
06349   std::string getSeedValueSubFilter (Encoding aEncoding, int aIndex) const
06350   {
06351     SIGNDOC_Exception *ex = NULL;
06352     std::string r;
06353     char *s = SIGNDOC_Field_getSeedValueSubFilter (&ex, p, aEncoding, aIndex);
06354     if (ex != NULL) SignDoc_throw (ex);
06355     try
06356       {
06357         r = s;
06358       }
06359     catch (...)
06360       {
06361         SIGNDOC_free (s);
06362         throw;
06363       }
06364     SIGNDOC_free (s);
06365     return r;
06366   }
06367 
06382   bool getSeedValueSubFilterRequired () const
06383   {
06384     SIGNDOC_Exception *ex = NULL;
06385     bool r;
06386     r = (bool)SIGNDOC_Field_getSeedValueSubFilterRequired (&ex, p);
06387     if (ex != NULL) SignDoc_throw (ex);
06388     return r;
06389   }
06390 
06404   void setSeedValueSubFilterRequired (bool aRequired) const
06405   {
06406     SIGNDOC_Exception *ex = NULL;
06407     SIGNDOC_Field_setSeedValueSubFilterRequired (&ex, p, aRequired);
06408     if (ex != NULL) SignDoc_throw (ex);
06409   }
06410 
06426   const char *getSeedValueSubFilterUTF8 (int aIndex) const
06427   {
06428     SIGNDOC_Exception *ex = NULL;
06429     const char *r;
06430     r = SIGNDOC_Field_getSeedValueSubFilterUTF8 (&ex, p, aIndex);
06431     if (ex != NULL) SignDoc_throw (ex);
06432     return r;
06433   }
06434 
06444   void clearSeedValueSubFilters ()
06445   {
06446     SIGNDOC_Exception *ex = NULL;
06447     SIGNDOC_Field_clearSeedValueSubFilters (&ex, p);
06448     if (ex != NULL) SignDoc_throw (ex);
06449   }
06450 
06465   void addSeedValueSubFilter (Encoding aEncoding,
06466                               const std::string &aSubFilter)
06467   {
06468     SIGNDOC_Exception *ex = NULL;
06469     SIGNDOC_Field_addSeedValueSubFilter (&ex, p, aEncoding, aSubFilter.c_str ());
06470     if (ex != NULL) SignDoc_throw (ex);
06471   }
06472 
06492   bool setSeedValueSubFilter (int aIndex, Encoding aEncoding,
06493                               const std::string &aSubFilter)
06494   {
06495     SIGNDOC_Exception *ex = NULL;
06496     bool r;
06497     r = (bool)SIGNDOC_Field_setSeedValueSubFilterByIndex (&ex, p, aIndex, aEncoding, aSubFilter.c_str ());
06498     if (ex != NULL) SignDoc_throw (ex);
06499     return r;
06500   }
06501 
06521   void setSeedValueSubFilter (Encoding aEncoding,
06522                               const std::string &aSubFilter)
06523   {
06524     SIGNDOC_Exception *ex = NULL;
06525     SIGNDOC_Field_setSeedValueSubFilter (&ex, p, aEncoding, aSubFilter.c_str ());
06526     if (ex != NULL) SignDoc_throw (ex);
06527   }
06528 
06541   bool removeSeedValueSubFilter (int aIndex)
06542   {
06543     SIGNDOC_Exception *ex = NULL;
06544     bool r;
06545     r = (bool)SIGNDOC_Field_removeSeedValueSubFilter (&ex, p, aIndex);
06546     if (ex != NULL) SignDoc_throw (ex);
06547     return r;
06548   }
06549 
06559   int getSeedValueDigestMethodCount () const
06560   {
06561     SIGNDOC_Exception *ex = NULL;
06562     int r;
06563     r = SIGNDOC_Field_getSeedValueDigestMethodCount (&ex, p);
06564     if (ex != NULL) SignDoc_throw (ex);
06565     return r;
06566   }
06567 
06598   std::string getSeedValueDigestMethod (Encoding aEncoding, int aIndex) const
06599   {
06600     SIGNDOC_Exception *ex = NULL;
06601     std::string r;
06602     char *s = SIGNDOC_Field_getSeedValueDigestMethod (&ex, p, aEncoding, aIndex);
06603     if (ex != NULL) SignDoc_throw (ex);
06604     try
06605       {
06606         r = s;
06607       }
06608     catch (...)
06609       {
06610         SIGNDOC_free (s);
06611         throw;
06612       }
06613     SIGNDOC_free (s);
06614     return r;
06615   }
06616 
06631   bool getSeedValueDigestMethodRequired () const
06632   {
06633     SIGNDOC_Exception *ex = NULL;
06634     bool r;
06635     r = (bool)SIGNDOC_Field_getSeedValueDigestMethodRequired (&ex, p);
06636     if (ex != NULL) SignDoc_throw (ex);
06637     return r;
06638   }
06639 
06653   void setSeedValueDigestMethodRequired (bool aRequired) const
06654   {
06655     SIGNDOC_Exception *ex = NULL;
06656     SIGNDOC_Field_setSeedValueDigestMethodRequired (&ex, p, aRequired);
06657     if (ex != NULL) SignDoc_throw (ex);
06658   }
06659 
06675   const char *getSeedValueDigestMethodUTF8 (int aIndex) const
06676   {
06677     SIGNDOC_Exception *ex = NULL;
06678     const char *r;
06679     r = SIGNDOC_Field_getSeedValueDigestMethodUTF8 (&ex, p, aIndex);
06680     if (ex != NULL) SignDoc_throw (ex);
06681     return r;
06682   }
06683 
06693   void clearSeedValueDigestMethods ()
06694   {
06695     SIGNDOC_Exception *ex = NULL;
06696     SIGNDOC_Field_clearSeedValueDigestMethods (&ex, p);
06697     if (ex != NULL) SignDoc_throw (ex);
06698   }
06699 
06714   void addSeedValueDigestMethod (Encoding aEncoding,
06715                                  const std::string &aDigestMethod)
06716   {
06717     SIGNDOC_Exception *ex = NULL;
06718     SIGNDOC_Field_addSeedValueDigestMethod (&ex, p, aEncoding, aDigestMethod.c_str ());
06719     if (ex != NULL) SignDoc_throw (ex);
06720   }
06721 
06741   bool setSeedValueDigestMethod (int aIndex, Encoding aEncoding,
06742                                  const std::string &aDigestMethod)
06743   {
06744     SIGNDOC_Exception *ex = NULL;
06745     bool r;
06746     r = (bool)SIGNDOC_Field_setSeedValueDigestMethodByIndex (&ex, p, aIndex, aEncoding, aDigestMethod.c_str ());
06747     if (ex != NULL) SignDoc_throw (ex);
06748     return r;
06749   }
06750 
06770   void setSeedValueDigestMethod (Encoding aEncoding,
06771                                  const std::string &aDigestMethod)
06772   {
06773     SIGNDOC_Exception *ex = NULL;
06774     SIGNDOC_Field_setSeedValueDigestMethod (&ex, p, aEncoding, aDigestMethod.c_str ());
06775     if (ex != NULL) SignDoc_throw (ex);
06776   }
06777 
06790   bool removeSeedValueDigestMethod (int aIndex)
06791   {
06792     SIGNDOC_Exception *ex = NULL;
06793     bool r;
06794     r = (bool)SIGNDOC_Field_removeSeedValueDigestMethod (&ex, p, aIndex);
06795     if (ex != NULL) SignDoc_throw (ex);
06796     return r;
06797   }
06798 
06812   bool getSeedValueAddRevInfo () const
06813   {
06814     SIGNDOC_Exception *ex = NULL;
06815     bool r;
06816     r = (bool)SIGNDOC_Field_getSeedValueAddRevInfo (&ex, p);
06817     if (ex != NULL) SignDoc_throw (ex);
06818     return r;
06819   }
06820 
06840   void setSeedValueAddRevInfo (bool aAddRevInfo)
06841   {
06842     SIGNDOC_Exception *ex = NULL;
06843     SIGNDOC_Field_setSeedValueAddRevInfo (&ex, p, aAddRevInfo);
06844     if (ex != NULL) SignDoc_throw (ex);
06845   }
06846 
06859   SignDocColor *getEmptyFieldColor () const
06860   {
06861     SIGNDOC_Exception *ex = NULL;
06862     SIGNDOC_Color *r;
06863     r = SIGNDOC_Field_getEmptyFieldColor (&ex, p);
06864     if (ex != NULL) SignDoc_throw (ex);
06865     if (r == NULL)
06866       return NULL;
06867     try
06868       {
06869         return new SignDocColor (r);
06870       }
06871     catch (...)
06872       {
06873         SIGNDOC_Color_delete (r);
06874         throw;
06875       }
06876   }
06877 
06889   void setEmptyFieldColor (const SignDocColor &aColor)
06890   {
06891     SIGNDOC_Exception *ex = NULL;
06892     SIGNDOC_Field_setEmptyFieldColor (&ex, p, aColor.getImpl ());
06893     if (ex != NULL) SignDoc_throw (ex);
06894   }
06895 
06896 private:
06897 public:
06902   SignDocField (SIGNDOC_Field *aP) : p (aP) { }
06903 
06908   SIGNDOC_Field *getImpl () { return p; }
06909 
06914   const SIGNDOC_Field *getImpl () const { return p; }
06915 
06920   void setImpl (SIGNDOC_Field *aP) { SIGNDOC_Field_delete (p); p  = aP; }
06921 
06922 private:
06923   SIGNDOC_Field *p;
06924 };
06925 
06930 inline void assignArray (std::vector<SignDocField> &aDst,
06931                          SIGNDOC_FieldArray *aSrc)
06932 {
06933   aDst.clear ();
06934   unsigned n = SIGNDOC_FieldArray_count (aSrc);
06935   if (aSrc == NULL)
06936     return;
06937   aDst.resize (n);
06938   for (unsigned i = 0; i < n; ++i)
06939     {
06940       SIGNDOC_Exception *ex = NULL;
06941       SIGNDOC_Field *p = SIGNDOC_Field_clone (&ex, SIGNDOC_FieldArray_at (aSrc, i));
06942       if (ex != NULL) SignDoc_throw (ex);
06943       aDst[i].setImpl (p);
06944     }
06945 }
06946 
07374 class SignDocSignatureParameters 
07375 {
07376 public:
07385   enum Method
07386   {
07397     m_default,
07398 
07399     m_digsig_pkcs1,           
07400     m_digsig_pkcs7_detached,  
07401     m_digsig_pkcs7_sha1,      
07402     m_hash,                   
07403     m_digsig_cades_detached,  
07404     m_digsig_cades_rfc3161    
07405   };
07406 
07421   enum DetachedHashAlgorithm
07422   {
07430     dha_default,
07431 
07432     dha_sha1,                  
07433     dha_sha256,                
07434     dha_sha384,                
07435     dha_sha512,                
07436     dha_ripemd160              
07437   };
07438 
07444   enum AddCertificates
07445   {
07454     ac_all,
07455 
07463     ac_none,
07464 
07473     ac_trusted
07474   };
07475 
07481   enum AddRevocationInfo
07482   {
07491     ari_add = 0x01
07492   };
07493 
07504   enum TimeStampHashAlgorithm
07505   {
07515     tsha_default,
07516 
07517     tsha_sha1,                  
07518     tsha_sha256,                
07519     tsha_sha384,                
07520     tsha_sha512                 
07521   };
07522 
07530   enum Optimize
07531   {
07532     o_optimize,               
07533     o_dont_optimize           
07534   };
07535 
07549   enum PDFAButtons
07550   {
07554     pb_freeze,
07555 
07559     pb_dont_freeze,
07560 
07567     pb_auto
07568   };
07569 
07577   enum CertificateSigningAlgorithm
07578   {
07579     csa_sha1_rsa,               
07580     csa_md5_rsa,                
07581     csa_sha256_rsa,             
07582     csa_sha384_rsa,             
07583     csa_sha512_rsa,             
07584     csa_ripemd160_rsa           
07585   };
07586 
07596   enum BiometricEncryption
07597   {
07606     be_rsa,
07607 
07611     be_fixed,
07612 
07618     be_binary,
07619 
07625     be_passphrase,
07626 
07636     be_dont_store
07637   };
07638 
07645   enum HAlignment
07646   {
07647     ha_left, ha_center, ha_right, ha_justify
07648   };
07649 
07656   enum VAlignment
07657   {
07658     va_top, va_center, va_bottom
07659   };
07660 
07666   enum TextPosition
07667   {
07668     tp_overlay,       
07669     tp_below,         
07670     tp_underlay,      
07671     tp_right_of,      
07672     tp_above,         
07673     tp_left_of        
07674   };
07675 
07681   enum ValueType
07682   {
07683     vt_abs,                   
07684     vt_field_height,          
07685     vt_field_width            
07686   };
07687 
07693   enum TextItem
07694   {
07695     ti_signer,                
07696     ti_sign_time,             
07697     ti_comment,               
07698     ti_adviser,               
07699     ti_contact_info,          
07700     ti_location,              
07701     ti_reason,                
07702     ti_text1,                 
07703     ti_text2,                 
07704     ti_text3,                 
07705     ti_text4,                 
07706     ti_text5,                 
07707     ti_text6,                 
07708     ti_text7,                 
07709     ti_text8,                 
07710     ti_text9                  
07711   };
07712 
07728   enum TextGroup
07729   {
07730     tg_master,                
07731     tg_slave                  
07732   };
07733 
07744   enum IgnoreSeedValues
07745   {
07759     isv_SubFilter = 0x01,
07760 
07775     isv_DigestMethod = 0x02
07776   };
07777 
07788   enum CertificateSelectionFlags
07789   {
07790     csf_software = 0x01,        
07791     csf_hardware = 0x02,        
07792     csf_use_certificate_seed_values = 0x10, 
07793     csf_ask_if_ambiguous = 0x20, 
07794     csf_never_ask = 0x40,       
07795     csf_create_self_signed = 0x80 
07796   };
07797 
07807   enum RenderSignatureFlags
07808   {
07812     rsf_bw   = 0x01,
07813 
07817     rsf_gray = 0x02,
07818 
07822     rsf_antialias = 0x04
07823   };
07824 
07841   enum ImageTransparency
07842   {
07848     it_opaque,
07849 
07858     it_brightest
07859   };
07860 
07864   enum ReturnCode
07865   {
07866     rc_ok,                      
07867     rc_unknown,                 
07868     rc_not_supported,           
07869     rc_invalid_value            
07870   };
07871 
07880   enum ParameterState
07881   {
07882     ps_set,             
07883     ps_missing,         
07884     ps_supported,       
07885     ps_ignored,         
07886     ps_not_supported,   
07887     ps_unknown          
07888   };
07889 
07890 public:
07896   SignDocSignatureParameters ()
07897     : p (NULL)
07898   {
07899   }
07900 
07907   ~SignDocSignatureParameters ()
07908   {
07909     SIGNDOC_SignatureParameters_delete (p);
07910   }
07911 
07919   ParameterState getState (const std::string &aName)
07920   {
07921     SIGNDOC_Exception *ex = NULL;
07922     ParameterState r;
07923     r = (ParameterState)SIGNDOC_SignatureParameters_getState (&ex, p, aName.c_str ());
07924     if (ex != NULL) SignDoc_throw (ex);
07925     return r;
07926   }
07927 
08225   ReturnCode setString (Encoding aEncoding, const std::string &aName,
08226                         const std::string &aValue)
08227   {
08228     SIGNDOC_Exception *ex = NULL;
08229     ReturnCode r;
08230     r = (ReturnCode)SIGNDOC_SignatureParameters_setString (&ex, p, aEncoding, aName.c_str (), aValue.c_str ());
08231     if (ex != NULL) SignDoc_throw (ex);
08232     return r;
08233   }
08234 
08246   ReturnCode setString (const std::string &aName, const wchar_t *aValue)
08247   {
08248     SIGNDOC_Exception *ex = NULL;
08249     ReturnCode r;
08250     r = (ReturnCode)SIGNDOC_SignatureParameters_setStringW (&ex, p, aName.c_str (), aValue);
08251     if (ex != NULL) SignDoc_throw (ex);
08252     return r;
08253   }
08254 
08511   ReturnCode setInteger (const std::string &aName, int aValue)
08512   {
08513     SIGNDOC_Exception *ex = NULL;
08514     ReturnCode r;
08515     r = (ReturnCode)SIGNDOC_SignatureParameters_setInteger (&ex, p, aName.c_str (), aValue);
08516     if (ex != NULL) SignDoc_throw (ex);
08517     return r;
08518   }
08519 
08619   ReturnCode setBlob (const std::string &aName, const unsigned char *aData,
08620                       size_t aSize)
08621   {
08622     SIGNDOC_Exception *ex = NULL;
08623     ReturnCode r;
08624     r = (ReturnCode)SIGNDOC_SignatureParameters_setBlob (&ex, p, aName.c_str (), aData, aSize);
08625     if (ex != NULL) SignDoc_throw (ex);
08626     return r;
08627   }
08628 
08684   ReturnCode setLength (const std::string &aName, ValueType aType,
08685                         double aValue)
08686   {
08687     SIGNDOC_Exception *ex = NULL;
08688     ReturnCode r;
08689     r = (ReturnCode)SIGNDOC_SignatureParameters_setLength (&ex, p, aName.c_str (), aType, aValue);
08690     if (ex != NULL) SignDoc_throw (ex);
08691     return r;
08692   }
08693 
08717   ReturnCode setColor (const std::string &aName, const SignDocColor &aValue)
08718   {
08719     SIGNDOC_Exception *ex = NULL;
08720     ReturnCode r;
08721     r = (ReturnCode)SIGNDOC_SignatureParameters_setColor (&ex, p, aName.c_str (), aValue.getImpl ());
08722     if (ex != NULL) SignDoc_throw (ex);
08723     return r;
08724   }
08725 
08747   ReturnCode addTextItem (TextItem aItem, TextGroup aGroup)
08748   {
08749     SIGNDOC_Exception *ex = NULL;
08750     ReturnCode r;
08751     r = (ReturnCode)SIGNDOC_SignatureParameters_addTextItem (&ex, p, aItem, aGroup);
08752     if (ex != NULL) SignDoc_throw (ex);
08753     return r;
08754   }
08755 
08766   ReturnCode clearTextItems ()
08767   {
08768     SIGNDOC_Exception *ex = NULL;
08769     ReturnCode r;
08770     r = (ReturnCode)SIGNDOC_SignatureParameters_clearTextItems (&ex, p);
08771     if (ex != NULL) SignDoc_throw (ex);
08772     return r;
08773   }
08774 
08814   ReturnCode setPKCS7 (SignPKCS7 *aPKCS7)
08815   {
08816     SIGNDOC_Exception *ex = NULL;
08817     ReturnCode r;
08818     r = (ReturnCode)SIGNDOC_SignatureParameters_setPKCS7 (&ex, p, aPKCS7 == NULL ? NULL : aPKCS7->getImpl ());
08819     if (ex != NULL) SignDoc_throw (ex);
08820     return r;
08821   }
08822 
08847   ReturnCode setRSA (SignRSA *aRSA)
08848   {
08849     SIGNDOC_Exception *ex = NULL;
08850     ReturnCode r;
08851     r = (ReturnCode)SIGNDOC_SignatureParameters_setRSA (&ex, p, aRSA == NULL ? NULL : aRSA->getImpl ());
08852     if (ex != NULL) SignDoc_throw (ex);
08853     return r;
08854   }
08855 
08864   int getAvailableMethods ()
08865   {
08866     SIGNDOC_Exception *ex = NULL;
08867     int r;
08868     r = SIGNDOC_SignatureParameters_getAvailableMethods (&ex, p);
08869     if (ex != NULL) SignDoc_throw (ex);
08870     return r;
08871   }
08872 
08886   const char *getErrorMessage (Encoding aEncoding) const
08887   {
08888     SIGNDOC_Exception *ex = NULL;
08889     const char *r;
08890     r = SIGNDOC_SignatureParameters_getErrorMessage (&ex, p, aEncoding);
08891     if (ex != NULL) SignDoc_throw (ex);
08892     return r;
08893   }
08894 
08906   const wchar_t *getErrorMessageW () const
08907   {
08908     SIGNDOC_Exception *ex = NULL;
08909     const wchar_t *r;
08910     r = SIGNDOC_SignatureParameters_getErrorMessageW (&ex, p);
08911     if (ex != NULL) SignDoc_throw (ex);
08912     return r;
08913   }
08914 
08915 private:
08919   SignDocSignatureParameters (const SignDocSignatureParameters &);
08920 
08924   SignDocSignatureParameters &operator= (const SignDocSignatureParameters &);
08925 public:
08930   SignDocSignatureParameters (SIGNDOC_SignatureParameters *aP) : p (aP) { }
08931 
08936   SIGNDOC_SignatureParameters *getImpl () { return p; }
08937 
08942   const SIGNDOC_SignatureParameters *getImpl () const { return p; }
08943 
08948   void setImpl (SIGNDOC_SignatureParameters *aP) { SIGNDOC_SignatureParameters_delete (p); p  = aP; }
08949 
08950 private:
08951   SIGNDOC_SignatureParameters *p;
08952 };
08953 
08962 class SignDocProperty 
08963 {
08964 public:
08965 
08966 public:
08970   enum Type
08971   {
08972     t_string,
08973     t_integer,
08974     t_boolean
08975   };
08976 
08977 public:
08981   SignDocProperty ()
08982     : p (NULL)
08983   {
08984     SIGNDOC_Exception *ex = NULL;
08985     p = SIGNDOC_Property_new (&ex);
08986     if (ex != NULL) SignDoc_throw (ex);
08987   }
08988 
08994   SignDocProperty (const SignDocProperty &aSource)
08995     : p (NULL)
08996   {
08997     SIGNDOC_Exception *ex = NULL;
08998     p = SIGNDOC_Property_clone (&ex, aSource.getImpl ());
08999     if (ex != NULL) SignDoc_throw (ex);
09000   }
09001 
09005   ~SignDocProperty ()
09006   {
09007     SIGNDOC_Property_delete (p);
09008   }
09009 
09015   void swap (SignDocProperty &aOther)
09016   {
09017     std::swap (p, aOther.p);
09018   }
09019 
09035   std::string getName (Encoding aEncoding) const
09036   {
09037     SIGNDOC_Exception *ex = NULL;
09038     std::string r;
09039     char *s = SIGNDOC_Property_getName (&ex, p, aEncoding);
09040     if (ex != NULL) SignDoc_throw (ex);
09041     try
09042       {
09043         r = s;
09044       }
09045     catch (...)
09046       {
09047         SIGNDOC_free (s);
09048         throw;
09049       }
09050     SIGNDOC_free (s);
09051     return r;
09052   }
09053 
09065   const char *getNameUTF8 () const
09066   {
09067     SIGNDOC_Exception *ex = NULL;
09068     const char *r;
09069     r = SIGNDOC_Property_getNameUTF8 (&ex, p);
09070     if (ex != NULL) SignDoc_throw (ex);
09071     return r;
09072   }
09073 
09079   Type getType () const
09080   {
09081     SIGNDOC_Exception *ex = NULL;
09082     Type r;
09083     r = (Type)SIGNDOC_Property_getType (&ex, p);
09084     if (ex != NULL) SignDoc_throw (ex);
09085     return r;
09086   }
09087 
09088 private:
09089 public:
09094   SignDocProperty (SIGNDOC_Property *aP) : p (aP) { }
09095 
09100   SIGNDOC_Property *getImpl () { return p; }
09101 
09106   const SIGNDOC_Property *getImpl () const { return p; }
09107 
09112   void setImpl (SIGNDOC_Property *aP) { SIGNDOC_Property_delete (p); p  = aP; }
09113 
09114 private:
09115   SIGNDOC_Property *p;
09116 };
09117 
09122 inline void assignArray (std::vector<SignDocProperty> &aDst,
09123                          SIGNDOC_PropertyArray *aSrc)
09124 {
09125   aDst.clear ();
09126   unsigned n = SIGNDOC_PropertyArray_count (aSrc);
09127   if (aSrc == NULL)
09128     return;
09129   aDst.resize (n);
09130   for (unsigned i = 0; i < n; ++i)
09131     {
09132       SIGNDOC_Exception *ex = NULL;
09133       SIGNDOC_Property *p = SIGNDOC_Property_clone (&ex, SIGNDOC_PropertyArray_at (aSrc, i));
09134       if (ex != NULL) SignDoc_throw (ex);
09135       aDst[i].setImpl (p);
09136     }
09137 }
09138 
09146 class SignDocAnnotation 
09147 {
09148 public:
09154   enum Type
09155   {
09156     t_unknown,              
09157     t_line,                 
09158     t_scribble,             
09159     t_freetext              
09160   };
09161 
09165   enum LineEnding
09166   {
09167     le_unknown,             
09168     le_none,                
09169     le_arrow                
09170   };
09171 
09175   enum HAlignment
09176   {
09177     ha_left, ha_center, ha_right
09178   };
09179 
09183   enum ReturnCode
09184   {
09185     rc_ok,                      
09186     rc_not_supported,           
09187     rc_invalid_value,           
09188     rc_not_available            
09189   };
09190 
09191 protected:
09195   SignDocAnnotation ()
09196     : p (NULL)
09197   {
09198   }
09199 
09200 public:
09204   ~SignDocAnnotation ()
09205   {
09206     SIGNDOC_Annotation_delete (p);
09207   }
09208 
09214   Type getType () const
09215   {
09216     SIGNDOC_Exception *ex = NULL;
09217     Type r;
09218     r = (Type)SIGNDOC_Annotation_getType (&ex, p);
09219     if (ex != NULL) SignDoc_throw (ex);
09220     return r;
09221   }
09222 
09231   std::string getName (Encoding aEncoding) const
09232   {
09233     SIGNDOC_Exception *ex = NULL;
09234     std::string r;
09235     char *s = SIGNDOC_Annotation_getName (&ex, p, aEncoding);
09236     if (ex != NULL) SignDoc_throw (ex);
09237     try
09238       {
09239         r = s;
09240       }
09241     catch (...)
09242       {
09243         SIGNDOC_free (s);
09244         throw;
09245       }
09246     SIGNDOC_free (s);
09247     return r;
09248   }
09249 
09259   int getPage () const
09260   {
09261     SIGNDOC_Exception *ex = NULL;
09262     int r;
09263     r = SIGNDOC_Annotation_getPage (&ex, p);
09264     if (ex != NULL) SignDoc_throw (ex);
09265     return r;
09266   }
09267 
09279   ReturnCode getBoundingBox (Rect &aOutput) const
09280   {
09281     SIGNDOC_Exception *ex = NULL;
09282     ReturnCode r;
09283     r = (ReturnCode)SIGNDOC_Annotation_getBoundingBox (&ex, p, (SIGNDOC_Rect*)&aOutput);
09284     if (ex != NULL) SignDoc_throw (ex);
09285     return r;
09286   }
09287 
09300   ReturnCode setName (Encoding aEncoding, const std::string &aName)
09301   {
09302     SIGNDOC_Exception *ex = NULL;
09303     ReturnCode r;
09304     r = (ReturnCode)SIGNDOC_Annotation_setName (&ex, p, aEncoding, aName.c_str ());
09305     if (ex != NULL) SignDoc_throw (ex);
09306     return r;
09307   }
09308 
09320   ReturnCode setName (const wchar_t *aName)
09321   {
09322     SIGNDOC_Exception *ex = NULL;
09323     ReturnCode r;
09324     r = (ReturnCode)SIGNDOC_Annotation_setNameW (&ex, p, aName);
09325     if (ex != NULL) SignDoc_throw (ex);
09326     return r;
09327   }
09328 
09340   ReturnCode setLineEnding (LineEnding aStart, LineEnding aEnd)
09341   {
09342     SIGNDOC_Exception *ex = NULL;
09343     ReturnCode r;
09344     r = (ReturnCode)SIGNDOC_Annotation_setLineEnding (&ex, p, aStart, aEnd);
09345     if (ex != NULL) SignDoc_throw (ex);
09346     return r;
09347   }
09348 
09361   ReturnCode setColor (const SignDocColor &aColor)
09362   {
09363     SIGNDOC_Exception *ex = NULL;
09364     ReturnCode r;
09365     r = (ReturnCode)SIGNDOC_Annotation_setColor (&ex, p, aColor.getImpl ());
09366     if (ex != NULL) SignDoc_throw (ex);
09367     return r;
09368   }
09369 
09381   ReturnCode setBackgroundColor (const SignDocColor &aColor)
09382   {
09383     SIGNDOC_Exception *ex = NULL;
09384     ReturnCode r;
09385     r = (ReturnCode)SIGNDOC_Annotation_setBackgroundColor (&ex, p, aColor.getImpl ());
09386     if (ex != NULL) SignDoc_throw (ex);
09387     return r;
09388   }
09389 
09403   ReturnCode setBorderColor (const SignDocColor &aColor)
09404   {
09405     SIGNDOC_Exception *ex = NULL;
09406     ReturnCode r;
09407     r = (ReturnCode)SIGNDOC_Annotation_setBorderColor (&ex, p, aColor.getImpl ());
09408     if (ex != NULL) SignDoc_throw (ex);
09409     return r;
09410   }
09411 
09425   ReturnCode setOpacity (double aOpacity)
09426   {
09427     SIGNDOC_Exception *ex = NULL;
09428     ReturnCode r;
09429     r = (ReturnCode)SIGNDOC_Annotation_setOpacity (&ex, p, aOpacity);
09430     if (ex != NULL) SignDoc_throw (ex);
09431     return r;
09432   }
09433 
09444   ReturnCode setLineWidthInPoints (double aWidth)
09445   {
09446     SIGNDOC_Exception *ex = NULL;
09447     ReturnCode r;
09448     r = (ReturnCode)SIGNDOC_Annotation_setLineWidthInPoints (&ex, p, aWidth);
09449     if (ex != NULL) SignDoc_throw (ex);
09450     return r;
09451   }
09452 
09466   ReturnCode setBorderLineWidthInPoints (double aWidth)
09467   {
09468     SIGNDOC_Exception *ex = NULL;
09469     ReturnCode r;
09470     r = (ReturnCode)SIGNDOC_Annotation_setBorderLineWidthInPoints (&ex, p, aWidth);
09471     if (ex != NULL) SignDoc_throw (ex);
09472     return r;
09473   }
09474 
09486   ReturnCode newStroke ()
09487   {
09488     SIGNDOC_Exception *ex = NULL;
09489     ReturnCode r;
09490     r = (ReturnCode)SIGNDOC_Annotation_newStroke (&ex, p);
09491     if (ex != NULL) SignDoc_throw (ex);
09492     return r;
09493   }
09494 
09509   ReturnCode addPoint (const Point &aPoint)
09510   {
09511     SIGNDOC_Exception *ex = NULL;
09512     ReturnCode r;
09513     r = (ReturnCode)SIGNDOC_Annotation_addPoint (&ex, p, (const SIGNDOC_Point*)&aPoint);
09514     if (ex != NULL) SignDoc_throw (ex);
09515     return r;
09516   }
09517 
09533   ReturnCode addPoint (double aX, double aY)
09534   {
09535     SIGNDOC_Exception *ex = NULL;
09536     ReturnCode r;
09537     r = (ReturnCode)SIGNDOC_Annotation_addPointXY (&ex, p, aX, aY);
09538     if (ex != NULL) SignDoc_throw (ex);
09539     return r;
09540   }
09541 
09574   ReturnCode setPlainText (Encoding aEncoding, const std::string &aText,
09575                            const std::string &aFont, double aFontSize,
09576                            HAlignment aHAlignment)
09577   {
09578     SIGNDOC_Exception *ex = NULL;
09579     ReturnCode r;
09580     r = (ReturnCode)SIGNDOC_Annotation_setPlainText (&ex, p, aEncoding, aText.c_str (), aFont.c_str (), aFontSize, aHAlignment);
09581     if (ex != NULL) SignDoc_throw (ex);
09582     return r;
09583   }
09584 
09599   ReturnCode getPlainText (Encoding aEncoding, std::string &aText)
09600   {
09601     SIGNDOC_Exception *ex = NULL;
09602     char *tempText = NULL;
09603     ReturnCode r;
09604     try
09605       {
09606         r = (ReturnCode)SIGNDOC_Annotation_getPlainText (&ex, p, aEncoding, &tempText);
09607         if (tempText != NULL)
09608           aText = tempText;
09609       }
09610     catch (...)
09611       {
09612         SIGNDOC_free (tempText);
09613         throw;
09614       }
09615     SIGNDOC_free (tempText);
09616     if (ex != NULL) SignDoc_throw (ex);
09617     return r;
09618   }
09619 
09636   ReturnCode getFont (Encoding aEncoding, std::string &aFont,
09637                       double &aFontSize)
09638   {
09639     SIGNDOC_Exception *ex = NULL;
09640     char *tempFont = NULL;
09641     ReturnCode r;
09642     try
09643       {
09644         r = (ReturnCode)SIGNDOC_Annotation_getFont (&ex, p, aEncoding, &tempFont, &aFontSize);
09645         if (tempFont != NULL)
09646           aFont = tempFont;
09647       }
09648     catch (...)
09649       {
09650         SIGNDOC_free (tempFont);
09651         throw;
09652       }
09653     SIGNDOC_free (tempFont);
09654     if (ex != NULL) SignDoc_throw (ex);
09655     return r;
09656   }
09661   SignDocAnnotation (SIGNDOC_Annotation *aP) : p (aP) { }
09662 
09667   SIGNDOC_Annotation *getImpl () { return p; }
09668 
09673   const SIGNDOC_Annotation *getImpl () const { return p; }
09674 
09679   void setImpl (SIGNDOC_Annotation *aP) { SIGNDOC_Annotation_delete (p); p  = aP; }
09680 
09681 private:
09682   SIGNDOC_Annotation *p;
09683 };
09684 
09690 class SignDocCharacterPosition 
09691 {
09692 public:
09693   int mPage;                    
09694   Point mRef; 
09695   Rect mBox;  
09696 };
09697 
09701 class SignDocFindTextPosition 
09702 {
09703 public:
09704   SignDocCharacterPosition mFirst;   
09705   SignDocCharacterPosition mLast;    
09706 };
09707 
09712 inline void assignArray (std::vector<SignDocFindTextPosition> &aDst,
09713                          SIGNDOC_FindTextPositionArray *aSrc)
09714 {
09715   if (aSrc == NULL)
09716     aDst.clear ();
09717   else
09718     {
09719       unsigned n = SIGNDOC_FindTextPositionArray_count (aSrc);
09720       aDst.resize (n);
09721       for (unsigned i = 0; i < n; ++i)
09722         aDst[i] = *(const SignDocFindTextPosition*)SIGNDOC_FindTextPositionArray_at (aSrc, i);
09723     }
09724 }
09725 
09729 class SignDocRenderParameters 
09730 {
09731 public:
09735   enum Interlacing
09736   {
09740     i_off,
09741 
09747     i_on
09748   };
09749 
09753   enum Quality
09754   {
09758     q_low,
09759 
09763     q_high
09764   };
09765 
09769   enum PixelFormat
09770   {
09774     pf_default,
09775 
09779     pf_bw
09780   };
09781 
09788   enum Compression
09789   {
09790     c_default,     
09791     c_none,        
09792     c_group4,      
09793     c_lzw,         
09794     c_rle,         
09795     c_zip          
09796   };
09797 
09798 public:
09802   SignDocRenderParameters ()
09803     : p (NULL)
09804   {
09805     SIGNDOC_Exception *ex = NULL;
09806     p = SIGNDOC_RenderParameters_new (&ex);
09807     if (ex != NULL) SignDoc_throw (ex);
09808   }
09809 
09815   SignDocRenderParameters (const SignDocRenderParameters &aSource)
09816     : p (NULL)
09817   {
09818     SIGNDOC_Exception *ex = NULL;
09819     p = SIGNDOC_RenderParameters_clone (&ex, aSource.getImpl ());
09820     if (ex != NULL) SignDoc_throw (ex);
09821   }
09822 
09826   ~SignDocRenderParameters ()
09827   {
09828     SIGNDOC_RenderParameters_delete (p);
09829   }
09830 
09836   SignDocRenderParameters &operator= (const SignDocRenderParameters &aSource)
09837   {
09838     SIGNDOC_Exception *ex = NULL;
09839     SIGNDOC_RenderParameters_assign (&ex, p, aSource.getImpl ());
09840     if (ex != NULL) SignDoc_throw (ex);
09841     return *this;
09842   }
09843 
09856   bool setPage (int aPage)
09857   {
09858     SIGNDOC_Exception *ex = NULL;
09859     bool r;
09860     r = (bool)SIGNDOC_RenderParameters_setPage (&ex, p, aPage);
09861     if (ex != NULL) SignDoc_throw (ex);
09862     return r;
09863   }
09864 
09877   bool getPage (int &aPage) const
09878   {
09879     SIGNDOC_Exception *ex = NULL;
09880     bool r;
09881     r = (bool)SIGNDOC_RenderParameters_getPage (&ex, p, &aPage);
09882     if (ex != NULL) SignDoc_throw (ex);
09883     return r;
09884   }
09885 
09905   bool setPages (int aFirst, int aLast)
09906   {
09907     SIGNDOC_Exception *ex = NULL;
09908     bool r;
09909     r = (bool)SIGNDOC_RenderParameters_setPages (&ex, p, aFirst, aLast);
09910     if (ex != NULL) SignDoc_throw (ex);
09911     return r;
09912   }
09913 
09929   bool getPages (int &aFirst, int &aLast) const
09930   {
09931     SIGNDOC_Exception *ex = NULL;
09932     bool r;
09933     r = (bool)SIGNDOC_RenderParameters_getPages (&ex, p, &aFirst, &aLast);
09934     if (ex != NULL) SignDoc_throw (ex);
09935     return r;
09936   }
09937 
09954   bool setResolution (double aResX, double aResY)
09955   {
09956     SIGNDOC_Exception *ex = NULL;
09957     bool r;
09958     r = (bool)SIGNDOC_RenderParameters_setResolution (&ex, p, aResX, aResY);
09959     if (ex != NULL) SignDoc_throw (ex);
09960     return r;
09961   }
09962 
09973   bool getResolution (double &aResX, double &aResY) const
09974   {
09975     SIGNDOC_Exception *ex = NULL;
09976     bool r;
09977     r = (bool)SIGNDOC_RenderParameters_getResolution (&ex, p, &aResX, &aResY);
09978     if (ex != NULL) SignDoc_throw (ex);
09979     return r;
09980   }
09981 
09995   bool setZoom (double aZoom)
09996   {
09997     SIGNDOC_Exception *ex = NULL;
09998     bool r;
09999     r = (bool)SIGNDOC_RenderParameters_setZoom (&ex, p, aZoom);
10000     if (ex != NULL) SignDoc_throw (ex);
10001     return r;
10002   }
10003 
10018   bool getZoom (double &aZoom) const
10019   {
10020     SIGNDOC_Exception *ex = NULL;
10021     bool r;
10022     r = (bool)SIGNDOC_RenderParameters_getZoom (&ex, p, &aZoom);
10023     if (ex != NULL) SignDoc_throw (ex);
10024     return r;
10025   }
10026 
10040   bool fitWidth (int aWidth)
10041   {
10042     SIGNDOC_Exception *ex = NULL;
10043     bool r;
10044     r = (bool)SIGNDOC_RenderParameters_fitWidth (&ex, p, aWidth);
10045     if (ex != NULL) SignDoc_throw (ex);
10046     return r;
10047   }
10048 
10059   bool getFitWidth (int &aWidth) const
10060   {
10061     SIGNDOC_Exception *ex = NULL;
10062     bool r;
10063     r = (bool)SIGNDOC_RenderParameters_getFitWidth (&ex, p, &aWidth);
10064     if (ex != NULL) SignDoc_throw (ex);
10065     return r;
10066   }
10067 
10081   bool fitHeight (int aHeight)
10082   {
10083     SIGNDOC_Exception *ex = NULL;
10084     bool r;
10085     r = (bool)SIGNDOC_RenderParameters_fitHeight (&ex, p, aHeight);
10086     if (ex != NULL) SignDoc_throw (ex);
10087     return r;
10088   }
10089 
10100   bool getFitHeight (int &aHeight) const
10101   {
10102     SIGNDOC_Exception *ex = NULL;
10103     bool r;
10104     r = (bool)SIGNDOC_RenderParameters_getFitHeight (&ex, p, &aHeight);
10105     if (ex != NULL) SignDoc_throw (ex);
10106     return r;
10107   }
10108 
10125   bool fitRect (int aWidth, int aHeight)
10126   {
10127     SIGNDOC_Exception *ex = NULL;
10128     bool r;
10129     r = (bool)SIGNDOC_RenderParameters_fitRect (&ex, p, aWidth, aHeight);
10130     if (ex != NULL) SignDoc_throw (ex);
10131     return r;
10132   }
10133 
10145   bool getFitRect (int &aWidth, int &aHeight) const
10146   {
10147     SIGNDOC_Exception *ex = NULL;
10148     bool r;
10149     r = (bool)SIGNDOC_RenderParameters_getFitRect (&ex, p, &aWidth, &aHeight);
10150     if (ex != NULL) SignDoc_throw (ex);
10151     return r;
10152   }
10153 
10168   bool setFormat (const std::string &aFormat)
10169   {
10170     SIGNDOC_Exception *ex = NULL;
10171     bool r;
10172     r = (bool)SIGNDOC_RenderParameters_setFormat (&ex, p, aFormat.c_str ());
10173     if (ex != NULL) SignDoc_throw (ex);
10174     return r;
10175   }
10176 
10187   bool getFormat (std::string &aFormat) const
10188   {
10189     SIGNDOC_Exception *ex = NULL;
10190     char *tempFormat = NULL;
10191     bool r;
10192     try
10193       {
10194         r = (bool)SIGNDOC_RenderParameters_getFormat (&ex, p, &tempFormat);
10195         if (tempFormat != NULL)
10196           aFormat = tempFormat;
10197       }
10198     catch (...)
10199       {
10200         SIGNDOC_free (tempFormat);
10201         throw;
10202       }
10203     SIGNDOC_free (tempFormat);
10204     if (ex != NULL) SignDoc_throw (ex);
10205     return r;
10206   }
10207 
10220   bool setInterlacing (Interlacing aInterlacing)
10221   {
10222     SIGNDOC_Exception *ex = NULL;
10223     bool r;
10224     r = (bool)SIGNDOC_RenderParameters_setInterlacing (&ex, p, aInterlacing);
10225     if (ex != NULL) SignDoc_throw (ex);
10226     return r;
10227   }
10228 
10239   bool getInterlacing (Interlacing &aInterlacing) const
10240   {
10241     SIGNDOC_Exception *ex = NULL;
10242     int tempInterlacing = 0;
10243     bool r;
10244     try
10245       {
10246         r = (bool)SIGNDOC_RenderParameters_getInterlacing (&ex, p, &tempInterlacing);
10247         aInterlacing = (Interlacing )tempInterlacing;
10248       }
10249     catch (...)
10250       {
10251         throw;
10252       }
10253     if (ex != NULL) SignDoc_throw (ex);
10254     return r;
10255   }
10256 
10269   bool setQuality (Quality aQuality)
10270   {
10271     SIGNDOC_Exception *ex = NULL;
10272     bool r;
10273     r = (bool)SIGNDOC_RenderParameters_setQuality (&ex, p, aQuality);
10274     if (ex != NULL) SignDoc_throw (ex);
10275     return r;
10276   }
10277 
10287   bool getQuality (Quality &aQuality) const
10288   {
10289     SIGNDOC_Exception *ex = NULL;
10290     int tempQuality = 0;
10291     bool r;
10292     try
10293       {
10294         r = (bool)SIGNDOC_RenderParameters_getQuality (&ex, p, &tempQuality);
10295         aQuality = (Quality )tempQuality;
10296       }
10297     catch (...)
10298       {
10299         throw;
10300       }
10301     if (ex != NULL) SignDoc_throw (ex);
10302     return r;
10303   }
10304 
10316   bool setPixelFormat (PixelFormat aPixelFormat)
10317   {
10318     SIGNDOC_Exception *ex = NULL;
10319     bool r;
10320     r = (bool)SIGNDOC_RenderParameters_setPixelFormat (&ex, p, aPixelFormat);
10321     if (ex != NULL) SignDoc_throw (ex);
10322     return r;
10323   }
10324 
10334   bool getPixelFormat (PixelFormat &aPixelFormat) const
10335   {
10336     SIGNDOC_Exception *ex = NULL;
10337     int tempPixelFormat = 0;
10338     bool r;
10339     try
10340       {
10341         r = (bool)SIGNDOC_RenderParameters_getPixelFormat (&ex, p, &tempPixelFormat);
10342         aPixelFormat = (PixelFormat )tempPixelFormat;
10343       }
10344     catch (...)
10345       {
10346         throw;
10347       }
10348     if (ex != NULL) SignDoc_throw (ex);
10349     return r;
10350   }
10351 
10363   bool setCompression (Compression aCompression)
10364   {
10365     SIGNDOC_Exception *ex = NULL;
10366     bool r;
10367     r = (bool)SIGNDOC_RenderParameters_setCompression (&ex, p, aCompression);
10368     if (ex != NULL) SignDoc_throw (ex);
10369     return r;
10370   }
10371 
10381   bool getCompression (Compression &aCompression) const
10382   {
10383     SIGNDOC_Exception *ex = NULL;
10384     int tempCompression = 0;
10385     bool r;
10386     try
10387       {
10388         r = (bool)SIGNDOC_RenderParameters_getCompression (&ex, p, &tempCompression);
10389         aCompression = (Compression )tempCompression;
10390       }
10391     catch (...)
10392       {
10393         throw;
10394       }
10395     if (ex != NULL) SignDoc_throw (ex);
10396     return r;
10397   }
10398 
10424   bool setDecorations (bool aDecorations)
10425   {
10426     SIGNDOC_Exception *ex = NULL;
10427     bool r;
10428     r = (bool)SIGNDOC_RenderParameters_setDecorations (&ex, p, aDecorations);
10429     if (ex != NULL) SignDoc_throw (ex);
10430     return r;
10431   }
10432 
10442   bool getDecorations (bool &aDecorations) const
10443   {
10444     SIGNDOC_Exception *ex = NULL;
10445     SIGNDOC_Boolean tempDecorations = 0;
10446     bool r;
10447     try
10448       {
10449         r = (bool)SIGNDOC_RenderParameters_getDecorations (&ex, p, &tempDecorations);
10450         aDecorations = (bool )tempDecorations;
10451       }
10452     catch (...)
10453       {
10454         throw;
10455       }
10456     if (ex != NULL) SignDoc_throw (ex);
10457     return r;
10458   }
10459 
10472   bool setPrint (bool aPrint)
10473   {
10474     SIGNDOC_Exception *ex = NULL;
10475     bool r;
10476     r = (bool)SIGNDOC_RenderParameters_setPrint (&ex, p, aPrint);
10477     if (ex != NULL) SignDoc_throw (ex);
10478     return r;
10479   }
10480 
10490   bool getPrint (bool &aPrint) const
10491   {
10492     SIGNDOC_Exception *ex = NULL;
10493     SIGNDOC_Boolean tempPrint = 0;
10494     bool r;
10495     try
10496       {
10497         r = (bool)SIGNDOC_RenderParameters_getPrint (&ex, p, &tempPrint);
10498         aPrint = (bool )tempPrint;
10499       }
10500     catch (...)
10501       {
10502         throw;
10503       }
10504     if (ex != NULL) SignDoc_throw (ex);
10505     return r;
10506   }
10507 
10515   bool operator== (const SignDocRenderParameters &aRHS) const
10516   {
10517     SIGNDOC_Exception *ex = NULL;
10518     bool r;
10519     r = (bool)SIGNDOC_RenderParameters_equals (&ex, p, aRHS.getImpl ());
10520     if (ex != NULL) SignDoc_throw (ex);
10521     return r;
10522   }
10523 
10524 private:
10525 public:
10530   SignDocRenderParameters (SIGNDOC_RenderParameters *aP) : p (aP) { }
10531 
10536   SIGNDOC_RenderParameters *getImpl () { return p; }
10537 
10542   const SIGNDOC_RenderParameters *getImpl () const { return p; }
10543 
10548   void setImpl (SIGNDOC_RenderParameters *aP) { SIGNDOC_RenderParameters_delete (p); p  = aP; }
10549 
10550 private:
10551   SIGNDOC_RenderParameters *p;
10552 };
10553 
10560 class SignDocRenderOutput 
10561 {
10562 public:
10566   int mWidth;
10567 
10571   int mHeight;
10572 };
10573 
10577 class SignDocAttachment 
10578 {
10579 public:
10580 
10581 public:
10585   SignDocAttachment ()
10586     : p (NULL)
10587   {
10588     SIGNDOC_Exception *ex = NULL;
10589     p = SIGNDOC_Attachment_new (&ex);
10590     if (ex != NULL) SignDoc_throw (ex);
10591   }
10592 
10598   SignDocAttachment (const SignDocAttachment &aSource)
10599     : p (NULL)
10600   {
10601     SIGNDOC_Exception *ex = NULL;
10602     p = SIGNDOC_Attachment_clone (&ex, aSource.getImpl ());
10603     if (ex != NULL) SignDoc_throw (ex);
10604   }
10605 
10609   ~SignDocAttachment ()
10610   {
10611     SIGNDOC_Attachment_delete (p);
10612   }
10613 
10619   SignDocAttachment &operator= (const SignDocAttachment &aSource)
10620   {
10621     SIGNDOC_Exception *ex = NULL;
10622     SIGNDOC_Attachment_assign (&ex, p, aSource.getImpl ());
10623     if (ex != NULL) SignDoc_throw (ex);
10624     return *this;
10625   }
10626 
10632   void swap (SignDocAttachment &aOther)
10633   {
10634     std::swap (p, aOther.p);
10635   }
10636 
10649   std::string getName (Encoding aEncoding) const
10650   {
10651     SIGNDOC_Exception *ex = NULL;
10652     std::string r;
10653     char *s = SIGNDOC_Attachment_getName (&ex, p, aEncoding);
10654     if (ex != NULL) SignDoc_throw (ex);
10655     try
10656       {
10657         r = s;
10658       }
10659     catch (...)
10660       {
10661         SIGNDOC_free (s);
10662         throw;
10663       }
10664     SIGNDOC_free (s);
10665     return r;
10666   }
10667 
10676   const char *getNameUTF8 () const
10677   {
10678     SIGNDOC_Exception *ex = NULL;
10679     const char *r;
10680     r = SIGNDOC_Attachment_getNameUTF8 (&ex, p);
10681     if (ex != NULL) SignDoc_throw (ex);
10682     return r;
10683   }
10684 
10697   std::string getFileName (Encoding aEncoding) const
10698   {
10699     SIGNDOC_Exception *ex = NULL;
10700     std::string r;
10701     char *s = SIGNDOC_Attachment_getFileName (&ex, p, aEncoding);
10702     if (ex != NULL) SignDoc_throw (ex);
10703     try
10704       {
10705         r = s;
10706       }
10707     catch (...)
10708       {
10709         SIGNDOC_free (s);
10710         throw;
10711       }
10712     SIGNDOC_free (s);
10713     return r;
10714   }
10715 
10724   const char *getFileNameUTF8 () const
10725   {
10726     SIGNDOC_Exception *ex = NULL;
10727     const char *r;
10728     r = SIGNDOC_Attachment_getFileNameUTF8 (&ex, p);
10729     if (ex != NULL) SignDoc_throw (ex);
10730     return r;
10731   }
10732 
10747   std::string getDescription (Encoding aEncoding) const
10748   {
10749     SIGNDOC_Exception *ex = NULL;
10750     std::string r;
10751     char *s = SIGNDOC_Attachment_getDescription (&ex, p, aEncoding);
10752     if (ex != NULL) SignDoc_throw (ex);
10753     try
10754       {
10755         r = s;
10756       }
10757     catch (...)
10758       {
10759         SIGNDOC_free (s);
10760         throw;
10761       }
10762     SIGNDOC_free (s);
10763     return r;
10764   }
10765 
10776   const char *getDescriptionUTF8 () const
10777   {
10778     SIGNDOC_Exception *ex = NULL;
10779     const char *r;
10780     r = SIGNDOC_Attachment_getDescriptionUTF8 (&ex, p);
10781     if (ex != NULL) SignDoc_throw (ex);
10782     return r;
10783   }
10784 
10795   int getSize () const
10796   {
10797     SIGNDOC_Exception *ex = NULL;
10798     int r;
10799     r = SIGNDOC_Attachment_getSize (&ex, p);
10800     if (ex != NULL) SignDoc_throw (ex);
10801     return r;
10802   }
10803 
10811   int getCompressedSize () const
10812   {
10813     SIGNDOC_Exception *ex = NULL;
10814     int r;
10815     r = SIGNDOC_Attachment_getCompressedSize (&ex, p);
10816     if (ex != NULL) SignDoc_throw (ex);
10817     return r;
10818   }
10819 
10828   const char *getType () const
10829   {
10830     SIGNDOC_Exception *ex = NULL;
10831     const char *r;
10832     r = SIGNDOC_Attachment_getType (&ex, p);
10833     if (ex != NULL) SignDoc_throw (ex);
10834     return r;
10835   }
10836 
10856   const char *getCreationTime () const
10857   {
10858     SIGNDOC_Exception *ex = NULL;
10859     const char *r;
10860     r = SIGNDOC_Attachment_getCreationTime (&ex, p);
10861     if (ex != NULL) SignDoc_throw (ex);
10862     return r;
10863   }
10864 
10885   const char *getModificationTime () const
10886   {
10887     SIGNDOC_Exception *ex = NULL;
10888     const char *r;
10889     r = SIGNDOC_Attachment_getModificationTime (&ex, p);
10890     if (ex != NULL) SignDoc_throw (ex);
10891     return r;
10892   }
10893 
10894 private:
10895 public:
10900   SignDocAttachment (SIGNDOC_Attachment *aP) : p (aP) { }
10901 
10906   SIGNDOC_Attachment *getImpl () { return p; }
10907 
10912   const SIGNDOC_Attachment *getImpl () const { return p; }
10913 
10918   void setImpl (SIGNDOC_Attachment *aP) { SIGNDOC_Attachment_delete (p); p  = aP; }
10919 
10920 private:
10921   SIGNDOC_Attachment *p;
10922 };
10923 
10932 class SignDocWatermark 
10933 {
10934 public:
10935 
10939   enum Justification
10940   {
10941     j_left, j_center, j_right
10942   };
10943 
10947   enum Location
10948   {
10949     l_overlay,                  
10950     l_underlay                  
10951   };
10952 
10956   enum HAlignment
10957   {
10958     ha_left, ha_center, ha_right
10959   };
10960 
10964   enum VAlignment
10965   {
10966     va_top, va_center, va_bottom
10967   };
10968 
10969 public:
10975   SignDocWatermark ()
10976     : p (NULL)
10977   {
10978     SIGNDOC_Exception *ex = NULL;
10979     p = SIGNDOC_Watermark_new (&ex);
10980     if (ex != NULL) SignDoc_throw (ex);
10981   }
10982 
10988   SignDocWatermark (const SignDocWatermark &aSource)
10989     : p (NULL)
10990   {
10991     SIGNDOC_Exception *ex = NULL;
10992     p = SIGNDOC_Watermark_clone (&ex, aSource.getImpl ());
10993     if (ex != NULL) SignDoc_throw (ex);
10994   }
10995 
10999   ~SignDocWatermark ()
11000   {
11001     SIGNDOC_Watermark_delete (p);
11002   }
11003 
11009   SignDocWatermark &operator= (const SignDocWatermark &aSource)
11010   {
11011     SIGNDOC_Exception *ex = NULL;
11012     SIGNDOC_Watermark_assign (&ex, p, aSource.getImpl ());
11013     if (ex != NULL) SignDoc_throw (ex);
11014     return *this;
11015   }
11016 
11022   void swap (SignDocWatermark &aOther)
11023   {
11024     std::swap (p, aOther.p);
11025   }
11026 
11030   void clear ()
11031   {
11032     SIGNDOC_Exception *ex = NULL;
11033     SIGNDOC_Watermark_clear (&ex, p);
11034     if (ex != NULL) SignDoc_throw (ex);
11035   }
11036 
11052   void setText (Encoding aEncoding, const std::string &aText)
11053   {
11054     SIGNDOC_Exception *ex = NULL;
11055     SIGNDOC_Watermark_setText (&ex, p, aEncoding, aText.c_str ());
11056     if (ex != NULL) SignDoc_throw (ex);
11057   }
11058 
11073   void setFontName (Encoding aEncoding, const std::string &aFontName)
11074   {
11075     SIGNDOC_Exception *ex = NULL;
11076     SIGNDOC_Watermark_setFontName (&ex, p, aEncoding, aFontName.c_str ());
11077     if (ex != NULL) SignDoc_throw (ex);
11078   }
11079 
11089   void setFontSize (double aFontSize)
11090   {
11091     SIGNDOC_Exception *ex = NULL;
11092     SIGNDOC_Watermark_setFontSize (&ex, p, aFontSize);
11093     if (ex != NULL) SignDoc_throw (ex);
11094   }
11095 
11103   void setTextColor (const SignDocColor &aTextColor)
11104   {
11105     SIGNDOC_Exception *ex = NULL;
11106     SIGNDOC_Watermark_setTextColor (&ex, p, aTextColor.getImpl ());
11107     if (ex != NULL) SignDoc_throw (ex);
11108   }
11109 
11122   void setJustification (Justification aJustification)
11123   {
11124     SIGNDOC_Exception *ex = NULL;
11125     SIGNDOC_Watermark_setJustification (&ex, p, aJustification);
11126     if (ex != NULL) SignDoc_throw (ex);
11127   }
11128 
11138   void setRotation (double aRotation)
11139   {
11140     SIGNDOC_Exception *ex = NULL;
11141     SIGNDOC_Watermark_setRotation (&ex, p, aRotation);
11142     if (ex != NULL) SignDoc_throw (ex);
11143   }
11144 
11155   void setOpacity (double aOpacity)
11156   {
11157     SIGNDOC_Exception *ex = NULL;
11158     SIGNDOC_Watermark_setOpacity (&ex, p, aOpacity);
11159     if (ex != NULL) SignDoc_throw (ex);
11160   }
11161 
11171   void setScale (double aScale)
11172   {
11173     SIGNDOC_Exception *ex = NULL;
11174     SIGNDOC_Watermark_setScale (&ex, p, aScale);
11175     if (ex != NULL) SignDoc_throw (ex);
11176   }
11177 
11188   void setLocation (Location aLocation)
11189   {
11190     SIGNDOC_Exception *ex = NULL;
11191     SIGNDOC_Watermark_setLocation (&ex, p, aLocation);
11192     if (ex != NULL) SignDoc_throw (ex);
11193   }
11194 
11214   void setHorizontalPosition (HAlignment aAlignment, double aDistance)
11215   {
11216     SIGNDOC_Exception *ex = NULL;
11217     SIGNDOC_Watermark_setHorizontalPosition (&ex, p, aAlignment, aDistance);
11218     if (ex != NULL) SignDoc_throw (ex);
11219   }
11220 
11239   void setVerticalPosition (VAlignment aAlignment, double aDistance)
11240   {
11241     SIGNDOC_Exception *ex = NULL;
11242     SIGNDOC_Watermark_setVerticalPosition (&ex, p, aAlignment, aDistance);
11243     if (ex != NULL) SignDoc_throw (ex);
11244   }
11245 
11255   void setFirstPage (int aPage)
11256   {
11257     SIGNDOC_Exception *ex = NULL;
11258     SIGNDOC_Watermark_setFirstPage (&ex, p, aPage);
11259     if (ex != NULL) SignDoc_throw (ex);
11260   }
11261 
11272   void setLastPage (int aPage)
11273   {
11274     SIGNDOC_Exception *ex = NULL;
11275     SIGNDOC_Watermark_setLastPage (&ex, p, aPage);
11276     if (ex != NULL) SignDoc_throw (ex);
11277   }
11278 
11290   void setPageIncrement (int aIncr)
11291   {
11292     SIGNDOC_Exception *ex = NULL;
11293     SIGNDOC_Watermark_setPageIncrement (&ex, p, aIncr);
11294     if (ex != NULL) SignDoc_throw (ex);
11295   }
11296 
11297 private:
11298 public:
11303   SignDocWatermark (SIGNDOC_Watermark *aP) : p (aP) { }
11304 
11309   SIGNDOC_Watermark *getImpl () { return p; }
11310 
11315   const SIGNDOC_Watermark *getImpl () const { return p; }
11316 
11321   void setImpl (SIGNDOC_Watermark *aP) { SIGNDOC_Watermark_delete (p); p  = aP; }
11322 
11323 private:
11324   SIGNDOC_Watermark *p;
11325 };
11326 
11359 class SignDocVerificationParameters 
11360 {
11361 public:
11367   enum CertificateChainVerificationPolicy
11368   {
11374     ccvp_dont_verify,
11375 
11382     ccvp_accept_self_signed,
11383 
11391     ccvp_accept_self_signed_with_bio,
11392 
11402     ccvp_accept_self_signed_with_rsa_bio,
11403 
11410     ccvp_require_trusted_root
11411   };
11412 
11419   enum CertificateRevocationVerificationPolicy
11420   {
11426     crvp_dont_check,
11427 
11432     crvp_offline,
11433 
11438     crvp_online
11439   };
11440 
11446   enum VerificationFlags
11447   {
11451     vf_check_revocation = 0x01,
11452 
11460     vf_use_crl_only = 0x02,
11461 
11469     vf_use_ocsp_only = 0x04,
11470 
11479     vf_offline = 0x08,
11480 
11493     vf_enforce_next_update = 0x10,
11494 
11507     vf_enforce_ocsp_signer = 0x20,
11508 
11516     vf_online = 0x40,
11517 
11528     vf_no_ocsp_nonce = 0x80,
11529 
11541     vf_crl_first = 0x100,
11542 
11560     vf_ignore_no_revocation = 0x200
11561   };
11562 
11568   enum VerificationModel
11569   {
11576     vm_minimal,
11577 
11586     vm_chain,
11587 
11593     vm_modified_shell,
11594 
11604     vm_shell
11605   };
11606 
11610   enum ReturnCode
11611   {
11612     rc_ok,                      
11613     rc_unknown,                 
11614     rc_not_supported,           
11615     rc_invalid_value            
11616   };
11617 
11618 public:
11624   SignDocVerificationParameters ()
11625     : p (NULL)
11626   {
11627     SIGNDOC_Exception *ex = NULL;
11628     p = SIGNDOC_VerificationParameters_new (&ex);
11629     if (ex != NULL) SignDoc_throw (ex);
11630   }
11631 
11637   SignDocVerificationParameters (const SignDocVerificationParameters &aSource)
11638     : p (NULL)
11639   {
11640     SIGNDOC_Exception *ex = NULL;
11641     p = SIGNDOC_VerificationParameters_clone (&ex, aSource.getImpl ());
11642     if (ex != NULL) SignDoc_throw (ex);
11643   }
11644 
11648   ~SignDocVerificationParameters ()
11649   {
11650     SIGNDOC_VerificationParameters_delete (p);
11651   }
11652 
11658   SignDocVerificationParameters &operator= (const SignDocVerificationParameters &aSource)
11659   {
11660     SIGNDOC_Exception *ex = NULL;
11661     SIGNDOC_VerificationParameters_assign (&ex, p, aSource.getImpl ());
11662     if (ex != NULL) SignDoc_throw (ex);
11663     return *this;
11664   }
11665 
11673   bool operator== (const SignDocVerificationParameters &aRHS) const
11674   {
11675     SIGNDOC_Exception *ex = NULL;
11676     bool r;
11677     r = (bool)SIGNDOC_VerificationParameters_equals (&ex, p, aRHS.getImpl ());
11678     if (ex != NULL) SignDoc_throw (ex);
11679     return r;
11680   }
11681 
11709   ReturnCode setString (Encoding aEncoding, const std::string &aName,
11710                         const std::string &aValue)
11711   {
11712     SIGNDOC_Exception *ex = NULL;
11713     ReturnCode r;
11714     r = (ReturnCode)SIGNDOC_VerificationParameters_setString (&ex, p, aEncoding, aName.c_str (), aValue.c_str ());
11715     if (ex != NULL) SignDoc_throw (ex);
11716     return r;
11717   }
11718 
11730   ReturnCode setString (const std::string &aName, const wchar_t *aValue)
11731   {
11732     SIGNDOC_Exception *ex = NULL;
11733     ReturnCode r;
11734     r = (ReturnCode)SIGNDOC_VerificationParameters_setStringW (&ex, p, aName.c_str (), aValue);
11735     if (ex != NULL) SignDoc_throw (ex);
11736     return r;
11737   }
11738 
11806   ReturnCode setInteger (const std::string &aName, int aValue)
11807   {
11808     SIGNDOC_Exception *ex = NULL;
11809     ReturnCode r;
11810     r = (ReturnCode)SIGNDOC_VerificationParameters_setInteger (&ex, p, aName.c_str (), aValue);
11811     if (ex != NULL) SignDoc_throw (ex);
11812     return r;
11813   }
11814 
11828   const char *getErrorMessage (Encoding aEncoding) const
11829   {
11830     SIGNDOC_Exception *ex = NULL;
11831     const char *r;
11832     r = SIGNDOC_VerificationParameters_getErrorMessage (&ex, p, aEncoding);
11833     if (ex != NULL) SignDoc_throw (ex);
11834     return r;
11835   }
11836 
11848   const wchar_t *getErrorMessageW () const
11849   {
11850     SIGNDOC_Exception *ex = NULL;
11851     const wchar_t *r;
11852     r = SIGNDOC_VerificationParameters_getErrorMessageW (&ex, p);
11853     if (ex != NULL) SignDoc_throw (ex);
11854     return r;
11855   }
11856 
11857 private:
11858 public:
11863   SignDocVerificationParameters (SIGNDOC_VerificationParameters *aP) : p (aP) { }
11864 
11869   SIGNDOC_VerificationParameters *getImpl () { return p; }
11870 
11875   const SIGNDOC_VerificationParameters *getImpl () const { return p; }
11876 
11881   void setImpl (SIGNDOC_VerificationParameters *aP) { SIGNDOC_VerificationParameters_delete (p); p  = aP; }
11882 
11883 private:
11884   SIGNDOC_VerificationParameters *p;
11885 };
11886 
11887 class SignDocVerificationResult;
11888 
12035 class SignDocDocument 
12036 {
12037 public:
12041   enum DocumentType
12042   {
12043     dt_unknown,                 
12044     dt_pdf,                     
12045     dt_tiff,                    
12046     dt_other,                   
12047     dt_fdf                      
12048   };
12049 
12053   enum SaveFlags
12054   {
12058     sf_incremental   = 0x01,
12059 
12065     sf_remove_unused = 0x02,
12066 
12077     sf_linearized    = 0x04,
12078 
12084     sf_pdf_1_4       = 0x08,
12085 
12107     sf_pdfa_buttons  = 0x10
12108   };
12109 
12113   enum CopyToStreamFlags
12114   {
12120     ctsf_unsaved = 0x01
12121   };
12122 
12130   enum SetFieldFlags
12131   {
12139     sff_font_fail    = 0x01,
12140 
12150     sff_font_warn    = 0x02,
12151 
12161     sff_font_ignore  = 0x04,
12162 
12178     sff_move = 0x08,
12179 
12197     sff_keep_ap = 0x10,
12198 
12219     sff_update_ap = 0x20,
12220 
12242     sff_fit_height_only = 0x40,
12243 
12254     sff_force_border_width = 0x80,
12255 
12262     sff_dont_break_lines = 0x100
12263   };
12264 
12268   enum FlattenFieldsFlags
12269   {
12273     fff_include_signature_unsigned      = 0x01,
12274 
12278     fff_include_signature_signed        = 0x02,
12279 
12283     fff_include_hidden                  = 0x04,
12284 
12295     fff_keep_structure                  = 0x08
12296   };
12297 
12301   enum FindTextFlags
12302   {
12303     ftf_ignore_hspace      = 0x0001,  
12304     ftf_ignore_hyphenation = 0x0002,  
12305     ftf_ignore_sequence    = 0x0004   
12306   };
12307 
12311   enum ExportFlags
12312   {
12313     e_top = 0x01  
12314   };
12315 
12319   enum ImportFlags
12320   {
12321     i_atomic = 0x01  
12322   };
12323 
12329   enum ImportImageFlags
12330   {
12334     ii_keep_aspect_ratio = 0x01,
12335 
12363     ii_brightest_transparent = 0x02
12364   };
12365 
12369   enum KeepOrRemove
12370   {
12371     kor_keep,                   
12372     kor_remove                  
12373   };
12374 
12380   enum ReturnCode
12381   {
12382     rc_ok,                    
12383     rc_invalid_argument,      
12384     rc_field_not_found,       
12385     rc_invalid_profile,       
12386     rc_invalid_image,         
12387     rc_type_mismatch,         
12388     rc_font_not_found,        
12389     rc_no_datablock,          
12390     rc_not_supported,         
12391     rc_io_error,              
12392     rc_not_verified,          
12393     rc_property_not_found,    
12394     rc_page_not_found,        
12395     rc_wrong_collection,      
12396     rc_field_exists,          
12397     rc_license_error,         
12398     rc_unexpected_error,      
12399     rc_cancelled,             
12400     rc_no_biometric_data,     
12401     rc_parameter_not_set,     
12402     rc_field_not_signed,      
12403     rc_invalid_signature,     
12404     rc_annotation_not_found,  
12405     rc_attachment_not_found,  
12406     rc_attachment_exists,     
12407     rc_no_certificate,        
12408     rc_ambiguous_certificate, 
12409     rc_not_allowed            
12410   };
12411 
12415   enum CheckAttachmentResult
12416   {
12417     car_match,                  
12418     car_no_checksum,            
12419     car_mismatch                
12420   };
12421 
12425   enum HAlignment
12426   {
12427     ha_left, ha_center, ha_right
12428   };
12429 
12433   enum VAlignment
12434   {
12435     va_top, va_center, va_bottom
12436   };
12437 
12443   enum Flags
12444   {
12460     f_relax_byte_range = 0x01,
12461 
12481     f_ambiguous_button_value_empty = 0x02
12482   };
12483 
12487   enum ShootInFootFlags
12488   {
12495     siff_allow_breaking_signatures  = 0x01,
12496 
12502     siff_allow_breaking_permissions = 0x02,
12503 
12509     siff_allow_invalid_certificate  = 0x04,
12510 
12523     siff_allow_non_standard_external_fonts = 0x08,
12524 
12537     siff_assume_ap_not_shared = 0x10,
12538 
12552     siff_assume_ap_shared = 0x20
12553   };
12554 
12562   SignDocDocument ()
12563     : p (NULL)
12564   {
12565   }
12566 
12572   ~SignDocDocument ()
12573   {
12574     SIGNDOC_Document_delete (p);
12575   }
12576 
12582   DocumentType getType () const
12583   {
12584     SIGNDOC_Exception *ex = NULL;
12585     DocumentType r;
12586     r = (DocumentType)SIGNDOC_Document_getType (&ex, p);
12587     if (ex != NULL) SignDoc_throw (ex);
12588     return r;
12589   }
12590 
12596   int getPageCount () const
12597   {
12598     SIGNDOC_Exception *ex = NULL;
12599     int r;
12600     r = SIGNDOC_Document_getPageCount (&ex, p);
12601     if (ex != NULL) SignDoc_throw (ex);
12602     return r;
12603   }
12604 
12637   ReturnCode createSignatureParameters (Encoding aEncoding,
12638                                         const std::string &aFieldName,
12639                                         const std::string &aProfile,
12640                                         SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
12641   {
12642     SIGNDOC_Exception *ex = NULL;
12643     SIGNDOC_SignatureParameters *tempOutput = NULL;
12644     aOutput.reset ((SignDocSignatureParameters*)NULL);
12645     ReturnCode r;
12646     try
12647       {
12648         r = (ReturnCode)SIGNDOC_Document_createSignatureParameters (&ex, p, aEncoding, aFieldName.c_str (), aProfile.c_str (), &tempOutput);
12649         if (tempOutput != NULL)
12650           {
12651             aOutput.reset (new SignDocSignatureParameters (tempOutput));
12652             tempOutput = NULL;
12653           }
12654       }
12655     catch (...)
12656       {
12657         if (tempOutput != NULL)
12658           SIGNDOC_SignatureParameters_delete (tempOutput);
12659         throw;
12660       }
12661     if (tempOutput != NULL)
12662       SIGNDOC_SignatureParameters_delete (tempOutput);
12663     if (ex != NULL) SignDoc_throw (ex);
12664     return r;
12665   }
12666 
12697   ReturnCode createSignatureParameters (const wchar_t *aFieldName,
12698                                         const wchar_t *aProfile,
12699                                         SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
12700   {
12701     SIGNDOC_Exception *ex = NULL;
12702     SIGNDOC_SignatureParameters *tempOutput = NULL;
12703     aOutput.reset ((SignDocSignatureParameters*)NULL);
12704     ReturnCode r;
12705     try
12706       {
12707         r = (ReturnCode)SIGNDOC_Document_createSignatureParametersW (&ex, p, aFieldName, aProfile, &tempOutput);
12708         if (tempOutput != NULL)
12709           {
12710             aOutput.reset (new SignDocSignatureParameters (tempOutput));
12711             tempOutput = NULL;
12712           }
12713       }
12714     catch (...)
12715       {
12716         if (tempOutput != NULL)
12717           SIGNDOC_SignatureParameters_delete (tempOutput);
12718         throw;
12719       }
12720     if (tempOutput != NULL)
12721       SIGNDOC_SignatureParameters_delete (tempOutput);
12722     if (ex != NULL) SignDoc_throw (ex);
12723     return r;
12724   }
12725 
12741   ReturnCode getProfiles (Encoding aEncoding, const std::string &aFieldName,
12742                           std::vector<std::string> &aOutput)
12743   {
12744     SIGNDOC_Exception *ex = NULL;
12745     SIGNDOC_StringArray *tempOutput = NULL;
12746     ReturnCode r;
12747     try
12748       {
12749         tempOutput = SIGNDOC_StringArray_new (&ex);
12750         if (ex != NULL) SignDoc_throw (ex);
12751         r = (ReturnCode)SIGNDOC_Document_getProfiles (&ex, p, aEncoding, aFieldName.c_str (), tempOutput);
12752         assignArray (aOutput, tempOutput);
12753       }
12754     catch (...)
12755       {
12756         if (tempOutput != NULL)
12757           SIGNDOC_StringArray_delete (tempOutput);
12758         throw;
12759       }
12760     if (tempOutput != NULL)
12761       SIGNDOC_StringArray_delete (tempOutput);
12762     if (ex != NULL) SignDoc_throw (ex);
12763     return r;
12764   }
12765 
12817   ReturnCode addSignature (SignDocSignatureParameters *aSignatureParameters,
12818                            const SignDocVerificationParameters *aVerificationParameters)
12819   {
12820     SIGNDOC_Exception *ex = NULL;
12821     ReturnCode r;
12822     r = (ReturnCode)SIGNDOC_Document_addSignature (&ex, p, aSignatureParameters == NULL ? NULL : aSignatureParameters->getImpl (), aVerificationParameters == NULL ? NULL : aVerificationParameters->getImpl ());
12823     if (ex != NULL) SignDoc_throw (ex);
12824     return r;
12825   }
12826 
12844   ReturnCode getLastTimestamp (std::string &aTime)
12845   {
12846     SIGNDOC_Exception *ex = NULL;
12847     char *tempTime = NULL;
12848     ReturnCode r;
12849     try
12850       {
12851         r = (ReturnCode)SIGNDOC_Document_getLastTimestamp (&ex, p, &tempTime);
12852         if (tempTime != NULL)
12853           aTime = tempTime;
12854       }
12855     catch (...)
12856       {
12857         SIGNDOC_free (tempTime);
12858         throw;
12859       }
12860     SIGNDOC_free (tempTime);
12861     if (ex != NULL) SignDoc_throw (ex);
12862     return r;
12863   }
12864 
12879   ReturnCode getPathname (Encoding aEncoding, std::string &aPath)
12880   {
12881     SIGNDOC_Exception *ex = NULL;
12882     char *tempPath = NULL;
12883     ReturnCode r;
12884     try
12885       {
12886         r = (ReturnCode)SIGNDOC_Document_getPathname (&ex, p, aEncoding, &tempPath);
12887         if (tempPath != NULL)
12888           aPath = tempPath;
12889       }
12890     catch (...)
12891       {
12892         SIGNDOC_free (tempPath);
12893         throw;
12894       }
12895     SIGNDOC_free (tempPath);
12896     if (ex != NULL) SignDoc_throw (ex);
12897     return r;
12898   }
12899 
12911   int getAvailableMethods ()
12912   {
12913     SIGNDOC_Exception *ex = NULL;
12914     int r;
12915     r = SIGNDOC_Document_getAvailableMethods (&ex, p);
12916     if (ex != NULL) SignDoc_throw (ex);
12917     return r;
12918   }
12919 
12937   ReturnCode verifySignature (Encoding aEncoding,
12938                               const std::string &aFieldName,
12939                               SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
12940   {
12941     SIGNDOC_Exception *ex = NULL;
12942     SIGNDOC_VerificationResult *tempOutput = NULL;
12943     aOutput.reset ((SignDocVerificationResult*)NULL);
12944     ReturnCode r;
12945     try
12946       {
12947         r = (ReturnCode)SIGNDOC_Document_verifySignature (&ex, p, aEncoding, aFieldName.c_str (), &tempOutput);
12948         if (tempOutput != NULL)
12949           {
12950             aOutput.reset (makeSignDocVerificationResult (tempOutput));
12951             tempOutput = NULL;
12952           }
12953       }
12954     catch (...)
12955       {
12956         if (tempOutput != NULL)
12957           SIGNDOC_VerificationResult_delete (tempOutput);
12958         throw;
12959       }
12960     if (tempOutput != NULL)
12961       SIGNDOC_VerificationResult_delete (tempOutput);
12962     if (ex != NULL) SignDoc_throw (ex);
12963     return r;
12964   }
12965 
12978   ReturnCode verifySignature (const wchar_t *aFieldName,
12979                               SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
12980   {
12981     SIGNDOC_Exception *ex = NULL;
12982     SIGNDOC_VerificationResult *tempOutput = NULL;
12983     aOutput.reset ((SignDocVerificationResult*)NULL);
12984     ReturnCode r;
12985     try
12986       {
12987         r = (ReturnCode)SIGNDOC_Document_verifySignatureW (&ex, p, aFieldName, &tempOutput);
12988         if (tempOutput != NULL)
12989           {
12990             aOutput.reset (makeSignDocVerificationResult (tempOutput));
12991             tempOutput = NULL;
12992           }
12993       }
12994     catch (...)
12995       {
12996         if (tempOutput != NULL)
12997           SIGNDOC_VerificationResult_delete (tempOutput);
12998         throw;
12999       }
13000     if (tempOutput != NULL)
13001       SIGNDOC_VerificationResult_delete (tempOutput);
13002     if (ex != NULL) SignDoc_throw (ex);
13003     return r;
13004   }
13005 
13020   ReturnCode clearSignature (Encoding aEncoding, const std::string &aFieldName)
13021   {
13022     SIGNDOC_Exception *ex = NULL;
13023     ReturnCode r;
13024     r = (ReturnCode)SIGNDOC_Document_clearSignature (&ex, p, aEncoding, aFieldName.c_str ());
13025     if (ex != NULL) SignDoc_throw (ex);
13026     return r;
13027   }
13028 
13036   ReturnCode clearAllSignatures ()
13037   {
13038     SIGNDOC_Exception *ex = NULL;
13039     ReturnCode r;
13040     r = (ReturnCode)SIGNDOC_Document_clearAllSignatures (&ex, p);
13041     if (ex != NULL) SignDoc_throw (ex);
13042     return r;
13043   }
13044 
13064   ReturnCode saveToStream (OutputStream &aStream, int aFlags)
13065   {
13066     SIGNDOC_Exception *ex = NULL;
13067     ReturnCode r;
13068     r = (ReturnCode)SIGNDOC_Document_saveToStream (&ex, p, aStream.getImpl (), aFlags);
13069     if (ex != NULL) SignDoc_throw (ex);
13070     return r;
13071   }
13072 
13100   ReturnCode saveToFile (Encoding aEncoding, const char *aPath, int aFlags)
13101   {
13102     SIGNDOC_Exception *ex = NULL;
13103     ReturnCode r;
13104     r = (ReturnCode)SIGNDOC_Document_saveToFile (&ex, p, aEncoding, aPath, aFlags);
13105     if (ex != NULL) SignDoc_throw (ex);
13106     return r;
13107   }
13108 
13133   ReturnCode saveToFile (const wchar_t *aPath, int aFlags)
13134   {
13135     SIGNDOC_Exception *ex = NULL;
13136     ReturnCode r;
13137     r = (ReturnCode)SIGNDOC_Document_saveToFileW (&ex, p, aPath, aFlags);
13138     if (ex != NULL) SignDoc_throw (ex);
13139     return r;
13140   }
13141 
13168   ReturnCode copyToStream (OutputStream &aStream, unsigned aFlags)
13169   {
13170     SIGNDOC_Exception *ex = NULL;
13171     ReturnCode r;
13172     r = (ReturnCode)SIGNDOC_Document_copyToStream (&ex, p, aStream.getImpl (), aFlags);
13173     if (ex != NULL) SignDoc_throw (ex);
13174     return r;
13175   }
13176 
13195   ReturnCode copyAsSignedToStream (Encoding aEncoding,
13196                                    const std::string &aFieldName,
13197                                    OutputStream &aStream)
13198   {
13199     SIGNDOC_Exception *ex = NULL;
13200     ReturnCode r;
13201     r = (ReturnCode)SIGNDOC_Document_copyAsSignedToStream (&ex, p, aEncoding, aFieldName.c_str (), aStream.getImpl ());
13202     if (ex != NULL) SignDoc_throw (ex);
13203     return r;
13204   }
13205 
13221   ReturnCode getSaveToStreamFlags (int &aOutput)
13222   {
13223     SIGNDOC_Exception *ex = NULL;
13224     ReturnCode r;
13225     r = (ReturnCode)SIGNDOC_Document_getSaveToStreamFlags (&ex, p, &aOutput);
13226     if (ex != NULL) SignDoc_throw (ex);
13227     return r;
13228   }
13229 
13244   ReturnCode getSaveToFileFlags (int &aOutput)
13245   {
13246     SIGNDOC_Exception *ex = NULL;
13247     ReturnCode r;
13248     r = (ReturnCode)SIGNDOC_Document_getSaveToFileFlags (&ex, p, &aOutput);
13249     if (ex != NULL) SignDoc_throw (ex);
13250     return r;
13251   }
13252 
13266   ReturnCode getRequiredSaveToFileFlags (int &aOutput)
13267   {
13268     SIGNDOC_Exception *ex = NULL;
13269     ReturnCode r;
13270     r = (ReturnCode)SIGNDOC_Document_getRequiredSaveToFileFlags (&ex, p, &aOutput);
13271     if (ex != NULL) SignDoc_throw (ex);
13272     return r;
13273   }
13274 
13292   ReturnCode getFields (int aTypes, std::vector<SignDocField> &aOutput)
13293   {
13294     SIGNDOC_Exception *ex = NULL;
13295     SIGNDOC_FieldArray *tempOutput = NULL;
13296     ReturnCode r;
13297     try
13298       {
13299         tempOutput = SIGNDOC_FieldArray_new (&ex);
13300         if (ex != NULL) SignDoc_throw (ex);
13301         r = (ReturnCode)SIGNDOC_Document_getFields (&ex, p, aTypes, tempOutput);
13302         assignArray (aOutput, tempOutput);
13303       }
13304     catch (...)
13305       {
13306         if (tempOutput != NULL)
13307           SIGNDOC_FieldArray_delete (tempOutput);
13308         throw;
13309       }
13310     if (tempOutput != NULL)
13311       SIGNDOC_FieldArray_delete (tempOutput);
13312     if (ex != NULL) SignDoc_throw (ex);
13313     return r;
13314   }
13315 
13342   ReturnCode getFieldsOfPage (int aPage, int aTypes,
13343                               std::vector<SignDocField> &aOutput)
13344   {
13345     SIGNDOC_Exception *ex = NULL;
13346     SIGNDOC_FieldArray *tempOutput = NULL;
13347     ReturnCode r;
13348     try
13349       {
13350         tempOutput = SIGNDOC_FieldArray_new (&ex);
13351         if (ex != NULL) SignDoc_throw (ex);
13352         r = (ReturnCode)SIGNDOC_Document_getFieldsOfPage (&ex, p, aPage, aTypes, tempOutput);
13353         assignArray (aOutput, tempOutput);
13354       }
13355     catch (...)
13356       {
13357         if (tempOutput != NULL)
13358           SIGNDOC_FieldArray_delete (tempOutput);
13359         throw;
13360       }
13361     if (tempOutput != NULL)
13362       SIGNDOC_FieldArray_delete (tempOutput);
13363     if (ex != NULL) SignDoc_throw (ex);
13364     return r;
13365   }
13366 
13381   ReturnCode getField (Encoding aEncoding, const std::string &aName,
13382                        SignDocField &aOutput)
13383   {
13384     SIGNDOC_Exception *ex = NULL;
13385     ReturnCode r;
13386     r = (ReturnCode)SIGNDOC_Document_getField (&ex, p, aEncoding, aName.c_str (), aOutput.getImpl ());
13387     if (ex != NULL) SignDoc_throw (ex);
13388     return r;
13389   }
13390 
13427   ReturnCode setField (SignDocField &aField, unsigned aFlags)
13428   {
13429     SIGNDOC_Exception *ex = NULL;
13430     ReturnCode r;
13431     r = (ReturnCode)SIGNDOC_Document_setField (&ex, p, aField.getImpl (), aFlags);
13432     if (ex != NULL) SignDoc_throw (ex);
13433     return r;
13434   }
13435 
13482   ReturnCode addField (SignDocField &aField, unsigned aFlags)
13483   {
13484     SIGNDOC_Exception *ex = NULL;
13485     ReturnCode r;
13486     r = (ReturnCode)SIGNDOC_Document_addField (&ex, p, aField.getImpl (), aFlags);
13487     if (ex != NULL) SignDoc_throw (ex);
13488     return r;
13489   }
13490 
13503   ReturnCode removeField (Encoding aEncoding, const std::string &aName)
13504   {
13505     SIGNDOC_Exception *ex = NULL;
13506     ReturnCode r;
13507     r = (ReturnCode)SIGNDOC_Document_removeField (&ex, p, aEncoding, aName.c_str ());
13508     if (ex != NULL) SignDoc_throw (ex);
13509     return r;
13510   }
13511 
13539   ReturnCode flattenField (Encoding aEncoding, const std::string &aName,
13540                            int aWidget)
13541   {
13542     SIGNDOC_Exception *ex = NULL;
13543     ReturnCode r;
13544     r = (ReturnCode)SIGNDOC_Document_flattenField (&ex, p, aEncoding, aName.c_str (), aWidget);
13545     if (ex != NULL) SignDoc_throw (ex);
13546     return r;
13547   }
13548 
13580   ReturnCode flattenFields (int aFirstPage, int aLastPage, unsigned aFlags)
13581   {
13582     SIGNDOC_Exception *ex = NULL;
13583     ReturnCode r;
13584     r = (ReturnCode)SIGNDOC_Document_flattenFields (&ex, p, aFirstPage, aLastPage, aFlags);
13585     if (ex != NULL) SignDoc_throw (ex);
13586     return r;
13587   }
13588 
13608   ReturnCode exportFields (OutputStream &aStream, int aFlags)
13609   {
13610     SIGNDOC_Exception *ex = NULL;
13611     ReturnCode r;
13612     r = (ReturnCode)SIGNDOC_Document_exportFields (&ex, p, aStream.getImpl (), aFlags);
13613     if (ex != NULL) SignDoc_throw (ex);
13614     return r;
13615   }
13616 
13631   ReturnCode applyFdf (Encoding aEncoding, const char *aPath, unsigned aFlags)
13632   {
13633     SIGNDOC_Exception *ex = NULL;
13634     ReturnCode r;
13635     r = (ReturnCode)SIGNDOC_Document_applyFdf (&ex, p, aEncoding, aPath, aFlags);
13636     if (ex != NULL) SignDoc_throw (ex);
13637     return r;
13638   }
13639 
13651   ReturnCode applyFdf (const wchar_t *aPath, unsigned aFlags)
13652   {
13653     SIGNDOC_Exception *ex = NULL;
13654     ReturnCode r;
13655     r = (ReturnCode)SIGNDOC_Document_applyFdfW (&ex, p, aPath, aFlags);
13656     if (ex != NULL) SignDoc_throw (ex);
13657     return r;
13658   }
13659 
13669   ReturnCode getTextFieldAttributes (SignDocTextFieldAttributes &aOutput)
13670   {
13671     SIGNDOC_Exception *ex = NULL;
13672     ReturnCode r;
13673     r = (ReturnCode)SIGNDOC_Document_getTextFieldAttributes (&ex, p, aOutput.getImpl ());
13674     if (ex != NULL) SignDoc_throw (ex);
13675     return r;
13676   }
13677 
13696   ReturnCode setTextFieldAttributes (SignDocTextFieldAttributes &aData)
13697   {
13698     SIGNDOC_Exception *ex = NULL;
13699     ReturnCode r;
13700     r = (ReturnCode)SIGNDOC_Document_setTextFieldAttributes (&ex, p, aData.getImpl ());
13701     if (ex != NULL) SignDoc_throw (ex);
13702     return r;
13703   }
13704 
13764   ReturnCode getProperties (const std::string &aCollection,
13765                             std::vector<SignDocProperty> &aOutput)
13766   {
13767     SIGNDOC_Exception *ex = NULL;
13768     SIGNDOC_PropertyArray *tempOutput = NULL;
13769     ReturnCode r;
13770     try
13771       {
13772         tempOutput = SIGNDOC_PropertyArray_new (&ex);
13773         if (ex != NULL) SignDoc_throw (ex);
13774         r = (ReturnCode)SIGNDOC_Document_getProperties (&ex, p, aCollection.c_str (), tempOutput);
13775         assignArray (aOutput, tempOutput);
13776       }
13777     catch (...)
13778       {
13779         if (tempOutput != NULL)
13780           SIGNDOC_PropertyArray_delete (tempOutput);
13781         throw;
13782       }
13783     if (tempOutput != NULL)
13784       SIGNDOC_PropertyArray_delete (tempOutput);
13785     if (ex != NULL) SignDoc_throw (ex);
13786     return r;
13787   }
13788 
13805   ReturnCode getIntegerProperty (Encoding aEncoding,
13806                                  const std::string &aCollection,
13807                                  const std::string &aName, long &aValue)
13808   {
13809     SIGNDOC_Exception *ex = NULL;
13810     ReturnCode r;
13811     r = (ReturnCode)SIGNDOC_Document_getIntegerProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &aValue);
13812     if (ex != NULL) SignDoc_throw (ex);
13813     return r;
13814   }
13815 
13833   ReturnCode getStringProperty (Encoding aEncoding,
13834                                 const std::string &aCollection,
13835                                 const std::string &aName, std::string &aValue)
13836   {
13837     SIGNDOC_Exception *ex = NULL;
13838     char *tempValue = NULL;
13839     ReturnCode r;
13840     try
13841       {
13842         r = (ReturnCode)SIGNDOC_Document_getStringProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &tempValue);
13843         if (tempValue != NULL)
13844           aValue = tempValue;
13845       }
13846     catch (...)
13847       {
13848         SIGNDOC_free (tempValue);
13849         throw;
13850       }
13851     SIGNDOC_free (tempValue);
13852     if (ex != NULL) SignDoc_throw (ex);
13853     return r;
13854   }
13855 
13872   ReturnCode getBooleanProperty (Encoding aEncoding,
13873                                  const std::string &aCollection,
13874                                  const std::string &aName, bool &aValue)
13875   {
13876     SIGNDOC_Exception *ex = NULL;
13877     SIGNDOC_Boolean tempValue = 0;
13878     ReturnCode r;
13879     try
13880       {
13881         r = (ReturnCode)SIGNDOC_Document_getBooleanProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &tempValue);
13882         aValue = (bool )tempValue;
13883       }
13884     catch (...)
13885       {
13886         throw;
13887       }
13888     if (ex != NULL) SignDoc_throw (ex);
13889     return r;
13890   }
13891 
13910   ReturnCode setIntegerProperty (Encoding aEncoding,
13911                                  const std::string &aCollection,
13912                                  const std::string &aName, long aValue)
13913   {
13914     SIGNDOC_Exception *ex = NULL;
13915     ReturnCode r;
13916     r = (ReturnCode)SIGNDOC_Document_setIntegerProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue);
13917     if (ex != NULL) SignDoc_throw (ex);
13918     return r;
13919   }
13920 
13940   ReturnCode setStringProperty (Encoding aEncoding,
13941                                 const std::string &aCollection,
13942                                 const std::string &aName,
13943                                 const std::string &aValue)
13944   {
13945     SIGNDOC_Exception *ex = NULL;
13946     ReturnCode r;
13947     r = (ReturnCode)SIGNDOC_Document_setStringProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue.c_str ());
13948     if (ex != NULL) SignDoc_throw (ex);
13949     return r;
13950   }
13951 
13970   ReturnCode setBooleanProperty (Encoding aEncoding,
13971                                  const std::string &aCollection,
13972                                  const std::string &aName, bool aValue)
13973   {
13974     SIGNDOC_Exception *ex = NULL;
13975     ReturnCode r;
13976     r = (ReturnCode)SIGNDOC_Document_setBooleanProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue);
13977     if (ex != NULL) SignDoc_throw (ex);
13978     return r;
13979   }
13980 
13996   ReturnCode removeProperty (Encoding aEncoding,
13997                              const std::string &aCollection,
13998                              const std::string &aName)
13999   {
14000     SIGNDOC_Exception *ex = NULL;
14001     ReturnCode r;
14002     r = (ReturnCode)SIGNDOC_Document_removeProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str ());
14003     if (ex != NULL) SignDoc_throw (ex);
14004     return r;
14005   }
14006 
14027   ReturnCode exportProperties (const std::string &aCollection,
14028                                OutputStream &aStream, int aFlags)
14029   {
14030     SIGNDOC_Exception *ex = NULL;
14031     ReturnCode r;
14032     r = (ReturnCode)SIGNDOC_Document_exportProperties (&ex, p, aCollection.c_str (), aStream.getImpl (), aFlags);
14033     if (ex != NULL) SignDoc_throw (ex);
14034     return r;
14035   }
14036 
14059   ReturnCode importProperties (const std::string &aCollection,
14060                                InputStream &aStream, int aFlags)
14061   {
14062     SIGNDOC_Exception *ex = NULL;
14063     ReturnCode r;
14064     r = (ReturnCode)SIGNDOC_Document_importProperties (&ex, p, aCollection.c_str (), aStream.getImpl (), aFlags);
14065     if (ex != NULL) SignDoc_throw (ex);
14066     return r;
14067   }
14068 
14079   ReturnCode getDataBlock (std::vector<unsigned char> &aOutput)
14080   {
14081     SIGNDOC_Exception *ex = NULL;
14082     SIGNDOC_ByteArray *tempOutput = NULL;
14083     ReturnCode r;
14084     try
14085       {
14086         tempOutput = SIGNDOC_ByteArray_new (&ex);
14087         if (ex != NULL) SignDoc_throw (ex);
14088         r = (ReturnCode)SIGNDOC_Document_getDataBlock (&ex, p, tempOutput);
14089         assignArray (aOutput, tempOutput);
14090       }
14091     catch (...)
14092       {
14093         if (tempOutput != NULL)
14094           SIGNDOC_ByteArray_delete (tempOutput);
14095         throw;
14096       }
14097     if (tempOutput != NULL)
14098       SIGNDOC_ByteArray_delete (tempOutput);
14099     if (ex != NULL) SignDoc_throw (ex);
14100     return r;
14101   }
14102 
14114   ReturnCode setDataBlock (const unsigned char *aData, size_t aSize)
14115   {
14116     SIGNDOC_Exception *ex = NULL;
14117     ReturnCode r;
14118     r = (ReturnCode)SIGNDOC_Document_setDataBlock (&ex, p, aData, aSize);
14119     if (ex != NULL) SignDoc_throw (ex);
14120     return r;
14121   }
14122 
14142   ReturnCode getResolution (int aPage, double &aResX, double &aResY)
14143   {
14144     SIGNDOC_Exception *ex = NULL;
14145     ReturnCode r;
14146     r = (ReturnCode)SIGNDOC_Document_getResolution (&ex, p, aPage, &aResX, &aResY);
14147     if (ex != NULL) SignDoc_throw (ex);
14148     return r;
14149   }
14150 
14172   ReturnCode getConversionFactors (int aPage, double &aFactorX,
14173                                    double &aFactorY)
14174   {
14175     SIGNDOC_Exception *ex = NULL;
14176     ReturnCode r;
14177     r = (ReturnCode)SIGNDOC_Document_getConversionFactors (&ex, p, aPage, &aFactorX, &aFactorY);
14178     if (ex != NULL) SignDoc_throw (ex);
14179     return r;
14180   }
14181 
14199   ReturnCode getPageSize (int aPage, double &aWidth, double &aHeight)
14200   {
14201     SIGNDOC_Exception *ex = NULL;
14202     ReturnCode r;
14203     r = (ReturnCode)SIGNDOC_Document_getPageSize (&ex, p, aPage, &aWidth, &aHeight);
14204     if (ex != NULL) SignDoc_throw (ex);
14205     return r;
14206   }
14207 
14222   ReturnCode getBitsPerPixel (int aPage, int &aBPP)
14223   {
14224     SIGNDOC_Exception *ex = NULL;
14225     ReturnCode r;
14226     r = (ReturnCode)SIGNDOC_Document_getBitsPerPixel (&ex, p, aPage, &aBPP);
14227     if (ex != NULL) SignDoc_throw (ex);
14228     return r;
14229   }
14230 
14249   ReturnCode computeZoom (double &aOutput,
14250                           const SignDocRenderParameters &aParams)
14251   {
14252     SIGNDOC_Exception *ex = NULL;
14253     ReturnCode r;
14254     r = (ReturnCode)SIGNDOC_Document_computeZoom (&ex, p, &aOutput, aParams.getImpl ());
14255     if (ex != NULL) SignDoc_throw (ex);
14256     return r;
14257   }
14258 
14280   ReturnCode convCanvasPointToPagePoint (Point &aPoint,
14281                                          const SignDocRenderParameters &aParams)
14282   {
14283     SIGNDOC_Exception *ex = NULL;
14284     ReturnCode r;
14285     r = (ReturnCode)SIGNDOC_Document_convCanvasPointToPagePoint (&ex, p, (SIGNDOC_Point*)&aPoint, aParams.getImpl ());
14286     if (ex != NULL) SignDoc_throw (ex);
14287     return r;
14288   }
14289 
14310   ReturnCode convPagePointToCanvasPoint (Point &aPoint,
14311                                          const SignDocRenderParameters &aParams)
14312   {
14313     SIGNDOC_Exception *ex = NULL;
14314     ReturnCode r;
14315     r = (ReturnCode)SIGNDOC_Document_convPagePointToCanvasPoint (&ex, p, (SIGNDOC_Point*)&aPoint, aParams.getImpl ());
14316     if (ex != NULL) SignDoc_throw (ex);
14317     return r;
14318   }
14319 
14346   ReturnCode renderPageAsImage (std::vector<unsigned char> &aImage,
14347                                 SignDocRenderOutput &aOutput,
14348                                 const SignDocRenderParameters &aRenderParameters,
14349                                 const SignDocVerificationParameters *aVerificationParameters,
14350                                 const Rect *aClipRect)
14351   {
14352     SIGNDOC_Exception *ex = NULL;
14353     SIGNDOC_ByteArray *tempImage = NULL;
14354     ReturnCode r;
14355     try
14356       {
14357         tempImage = SIGNDOC_ByteArray_new (&ex);
14358         if (ex != NULL) SignDoc_throw (ex);
14359         r = (ReturnCode)SIGNDOC_Document_renderPageAsImage (&ex, p, tempImage, (SIGNDOC_RenderOutput*)&aOutput, aRenderParameters.getImpl (), aVerificationParameters == NULL ? NULL : aVerificationParameters->getImpl (), (const SIGNDOC_Rect*)aClipRect);
14360         assignArray (aImage, tempImage);
14361       }
14362     catch (...)
14363       {
14364         if (tempImage != NULL)
14365           SIGNDOC_ByteArray_delete (tempImage);
14366         throw;
14367       }
14368     if (tempImage != NULL)
14369       SIGNDOC_ByteArray_delete (tempImage);
14370     if (ex != NULL) SignDoc_throw (ex);
14371     return r;
14372   }
14373 
14391   ReturnCode getRenderedSize (SignDocRenderOutput &aOutput,
14392                               const SignDocRenderParameters &aRenderParameters)
14393   {
14394     SIGNDOC_Exception *ex = NULL;
14395     ReturnCode r;
14396     r = (ReturnCode)SIGNDOC_Document_getRenderedSize (&ex, p, (SIGNDOC_RenderOutput*)&aOutput, aRenderParameters.getImpl ());
14397     if (ex != NULL) SignDoc_throw (ex);
14398     return r;
14399   }
14400 
14417   SignDocAnnotation *createLineAnnotation (const Point &aStart,
14418                                            const Point &aEnd)
14419   {
14420     SIGNDOC_Exception *ex = NULL;
14421     SIGNDOC_Annotation *r;
14422     r = SIGNDOC_Document_createLineAnnotation (&ex, p, (const SIGNDOC_Point*)&aStart, (const SIGNDOC_Point*)&aEnd);
14423     if (ex != NULL) SignDoc_throw (ex);
14424     if (r == NULL)
14425       return NULL;
14426     try
14427       {
14428         return new SignDocAnnotation (r);
14429       }
14430     catch (...)
14431       {
14432         SIGNDOC_Annotation_delete (r);
14433         throw;
14434       }
14435   }
14436 
14454   SignDocAnnotation *createLineAnnotation (double aStartX, double aStartY,
14455                                            double aEndX, double aEndY)
14456   {
14457     SIGNDOC_Exception *ex = NULL;
14458     SIGNDOC_Annotation *r;
14459     r = SIGNDOC_Document_createLineAnnotationXY (&ex, p, aStartX, aStartY, aEndX, aEndY);
14460     if (ex != NULL) SignDoc_throw (ex);
14461     if (r == NULL)
14462       return NULL;
14463     try
14464       {
14465         return new SignDocAnnotation (r);
14466       }
14467     catch (...)
14468       {
14469         SIGNDOC_Annotation_delete (r);
14470         throw;
14471       }
14472   }
14473 
14486   SignDocAnnotation *createScribbleAnnotation ()
14487   {
14488     SIGNDOC_Exception *ex = NULL;
14489     SIGNDOC_Annotation *r;
14490     r = SIGNDOC_Document_createScribbleAnnotation (&ex, p);
14491     if (ex != NULL) SignDoc_throw (ex);
14492     if (r == NULL)
14493       return NULL;
14494     try
14495       {
14496         return new SignDocAnnotation (r);
14497       }
14498     catch (...)
14499       {
14500         SIGNDOC_Annotation_delete (r);
14501         throw;
14502       }
14503   }
14504 
14520   SignDocAnnotation *createFreeTextAnnotation (const Point &aLowerLeft,
14521                                                const Point &aUpperRight)
14522   {
14523     SIGNDOC_Exception *ex = NULL;
14524     SIGNDOC_Annotation *r;
14525     r = SIGNDOC_Document_createFreeTextAnnotation (&ex, p, (const SIGNDOC_Point*)&aLowerLeft, (const SIGNDOC_Point*)&aUpperRight);
14526     if (ex != NULL) SignDoc_throw (ex);
14527     if (r == NULL)
14528       return NULL;
14529     try
14530       {
14531         return new SignDocAnnotation (r);
14532       }
14533     catch (...)
14534       {
14535         SIGNDOC_Annotation_delete (r);
14536         throw;
14537       }
14538   }
14539 
14557   SignDocAnnotation *createFreeTextAnnotation (double aX0, double aY0,
14558                                                double aX1, double aY1)
14559   {
14560     SIGNDOC_Exception *ex = NULL;
14561     SIGNDOC_Annotation *r;
14562     r = SIGNDOC_Document_createFreeTextAnnotationXY (&ex, p, aX0, aY0, aX1, aY1);
14563     if (ex != NULL) SignDoc_throw (ex);
14564     if (r == NULL)
14565       return NULL;
14566     try
14567       {
14568         return new SignDocAnnotation (r);
14569       }
14570     catch (...)
14571       {
14572         SIGNDOC_Annotation_delete (r);
14573         throw;
14574       }
14575   }
14576 
14590   ReturnCode addAnnotation (int aPage, const SignDocAnnotation *aAnnot)
14591   {
14592     SIGNDOC_Exception *ex = NULL;
14593     ReturnCode r;
14594     r = (ReturnCode)SIGNDOC_Document_addAnnotation (&ex, p, aPage, aAnnot == NULL ? NULL : aAnnot->getImpl ());
14595     if (ex != NULL) SignDoc_throw (ex);
14596     return r;
14597   }
14598 
14613   ReturnCode getAnnotations (Encoding aEncoding, int aPage,
14614                              std::vector<std::string> &aOutput)
14615   {
14616     SIGNDOC_Exception *ex = NULL;
14617     SIGNDOC_StringArray *tempOutput = NULL;
14618     ReturnCode r;
14619     try
14620       {
14621         tempOutput = SIGNDOC_StringArray_new (&ex);
14622         if (ex != NULL) SignDoc_throw (ex);
14623         r = (ReturnCode)SIGNDOC_Document_getAnnotations (&ex, p, aEncoding, aPage, tempOutput);
14624         assignArray (aOutput, tempOutput);
14625       }
14626     catch (...)
14627       {
14628         if (tempOutput != NULL)
14629           SIGNDOC_StringArray_delete (tempOutput);
14630         throw;
14631       }
14632     if (tempOutput != NULL)
14633       SIGNDOC_StringArray_delete (tempOutput);
14634     if (ex != NULL) SignDoc_throw (ex);
14635     return r;
14636   }
14637 
14654   ReturnCode getAnnotation (Encoding aEncoding, int aPage,
14655                             const std::string &aName,
14656                             SIGNDOC_PTR<SignDocAnnotation> &aOutput)
14657   {
14658     SIGNDOC_Exception *ex = NULL;
14659     SIGNDOC_Annotation *tempOutput = NULL;
14660     aOutput.reset ((SignDocAnnotation*)NULL);
14661     ReturnCode r;
14662     try
14663       {
14664         r = (ReturnCode)SIGNDOC_Document_getAnnotation (&ex, p, aEncoding, aPage, aName.c_str (), &tempOutput);
14665         if (tempOutput != NULL)
14666           {
14667             aOutput.reset (new SignDocAnnotation (tempOutput));
14668             tempOutput = NULL;
14669           }
14670       }
14671     catch (...)
14672       {
14673         if (tempOutput != NULL)
14674           SIGNDOC_Annotation_delete (tempOutput);
14675         throw;
14676       }
14677     if (tempOutput != NULL)
14678       SIGNDOC_Annotation_delete (tempOutput);
14679     if (ex != NULL) SignDoc_throw (ex);
14680     return r;
14681   }
14682 
14695   ReturnCode removeAnnotation (Encoding aEncoding, int aPage,
14696                                const std::string &aName)
14697   {
14698     SIGNDOC_Exception *ex = NULL;
14699     ReturnCode r;
14700     r = (ReturnCode)SIGNDOC_Document_removeAnnotation (&ex, p, aEncoding, aPage, aName.c_str ());
14701     if (ex != NULL) SignDoc_throw (ex);
14702     return r;
14703   }
14704 
14735   ReturnCode addText (Encoding aEncoding, const std::string &aText, int aPage,
14736                       double aX, double aY, const std::string &aFontName,
14737                       double aFontSize, const SignDocColor &aTextColor,
14738                       double aOpacity, int aFlags)
14739   {
14740     SIGNDOC_Exception *ex = NULL;
14741     ReturnCode r;
14742     r = (ReturnCode)SIGNDOC_Document_addText (&ex, p, aEncoding, aText.c_str (), aPage, aX, aY, aFontName.c_str (), aFontSize, aTextColor.getImpl (), aOpacity, aFlags);
14743     if (ex != NULL) SignDoc_throw (ex);
14744     return r;
14745   }
14746 
14791   ReturnCode addTextRect (Encoding aEncoding, const std::string &aText,
14792                           int aPage, double aX0, double aY0, double aX1,
14793                           double aY1, const std::string &aFontName,
14794                           double aFontSize, double aLineSkip,
14795                           const SignDocColor &aTextColor, double aOpacity,
14796                           HAlignment aHAlignment, VAlignment aVAlignment,
14797                           int aFlags)
14798   {
14799     SIGNDOC_Exception *ex = NULL;
14800     ReturnCode r;
14801     r = (ReturnCode)SIGNDOC_Document_addTextRect (&ex, p, aEncoding, aText.c_str (), aPage, aX0, aY0, aX1, aY1, aFontName.c_str (), aFontSize, aLineSkip, aTextColor.getImpl (), aOpacity, aHAlignment, aVAlignment, aFlags);
14802     if (ex != NULL) SignDoc_throw (ex);
14803     return r;
14804   }
14805 
14815   ReturnCode addWatermark (const SignDocWatermark &aInput)
14816   {
14817     SIGNDOC_Exception *ex = NULL;
14818     ReturnCode r;
14819     r = (ReturnCode)SIGNDOC_Document_addWatermark (&ex, p, aInput.getImpl ());
14820     if (ex != NULL) SignDoc_throw (ex);
14821     return r;
14822   }
14823 
14841   ReturnCode findText (Encoding aEncoding, int aFirstPage, int aLastPage,
14842                        const std::string &aText, int aFlags,
14843                        std::vector<SignDocFindTextPosition> &aOutput)
14844   {
14845     SIGNDOC_Exception *ex = NULL;
14846     SIGNDOC_FindTextPositionArray *tempOutput = NULL;
14847     ReturnCode r;
14848     try
14849       {
14850         tempOutput = SIGNDOC_FindTextPositionArray_new (&ex);
14851         if (ex != NULL) SignDoc_throw (ex);
14852         r = (ReturnCode)SIGNDOC_Document_findText (&ex, p, aEncoding, aFirstPage, aLastPage, aText.c_str (), aFlags, tempOutput);
14853         assignArray (aOutput, tempOutput);
14854       }
14855     catch (...)
14856       {
14857         if (tempOutput != NULL)
14858           SIGNDOC_FindTextPositionArray_delete (tempOutput);
14859         throw;
14860       }
14861     if (tempOutput != NULL)
14862       SIGNDOC_FindTextPositionArray_delete (tempOutput);
14863     if (ex != NULL) SignDoc_throw (ex);
14864     return r;
14865   }
14866 
14893   ReturnCode addAttachmentBlob (Encoding aEncoding, const std::string &aName,
14894                                 const std::string &aDescription,
14895                                 const std::string &aType,
14896                                 const std::string &aModificationTime,
14897                                 const void *aPtr, size_t aSize, int aFlags)
14898   {
14899     SIGNDOC_Exception *ex = NULL;
14900     ReturnCode r;
14901     r = (ReturnCode)SIGNDOC_Document_addAttachmentBlob (&ex, p, aEncoding, aName.c_str (), aDescription.c_str (), aType.c_str (), aModificationTime.c_str (), aPtr, aSize, aFlags);
14902     if (ex != NULL) SignDoc_throw (ex);
14903     return r;
14904   }
14905 
14927   ReturnCode addAttachmentFile (Encoding aEncoding1, const std::string &aName,
14928                                 const std::string &aDescription,
14929                                 const std::string &aType, Encoding aEncoding2,
14930                                 const std::string &aPath, int aFlags)
14931   {
14932     SIGNDOC_Exception *ex = NULL;
14933     ReturnCode r;
14934     r = (ReturnCode)SIGNDOC_Document_addAttachmentFile (&ex, p, aEncoding1, aName.c_str (), aDescription.c_str (), aType.c_str (), aEncoding2, aPath.c_str (), aFlags);
14935     if (ex != NULL) SignDoc_throw (ex);
14936     return r;
14937   }
14938 
14951   ReturnCode removeAttachment (Encoding aEncoding, const std::string &aName)
14952   {
14953     SIGNDOC_Exception *ex = NULL;
14954     ReturnCode r;
14955     r = (ReturnCode)SIGNDOC_Document_removeAttachment (&ex, p, aEncoding, aName.c_str ());
14956     if (ex != NULL) SignDoc_throw (ex);
14957     return r;
14958   }
14959 
14973   ReturnCode changeAttachmentDescription (Encoding aEncoding,
14974                                           const std::string &aName,
14975                                           const std::string &aDescription)
14976   {
14977     SIGNDOC_Exception *ex = NULL;
14978     ReturnCode r;
14979     r = (ReturnCode)SIGNDOC_Document_changeAttachmentDescription (&ex, p, aEncoding, aName.c_str (), aDescription.c_str ());
14980     if (ex != NULL) SignDoc_throw (ex);
14981     return r;
14982   }
14983 
14999   ReturnCode getAttachments (Encoding aEncoding,
15000                              std::vector<std::string> &aOutput)
15001   {
15002     SIGNDOC_Exception *ex = NULL;
15003     SIGNDOC_StringArray *tempOutput = NULL;
15004     ReturnCode r;
15005     try
15006       {
15007         tempOutput = SIGNDOC_StringArray_new (&ex);
15008         if (ex != NULL) SignDoc_throw (ex);
15009         r = (ReturnCode)SIGNDOC_Document_getAttachments (&ex, p, aEncoding, tempOutput);
15010         assignArray (aOutput, tempOutput);
15011       }
15012     catch (...)
15013       {
15014         if (tempOutput != NULL)
15015           SIGNDOC_StringArray_delete (tempOutput);
15016         throw;
15017       }
15018     if (tempOutput != NULL)
15019       SIGNDOC_StringArray_delete (tempOutput);
15020     if (ex != NULL) SignDoc_throw (ex);
15021     return r;
15022   }
15023 
15038   ReturnCode getAttachment (Encoding aEncoding, const std::string &aName,
15039                             SignDocAttachment &aOutput)
15040   {
15041     SIGNDOC_Exception *ex = NULL;
15042     ReturnCode r;
15043     r = (ReturnCode)SIGNDOC_Document_getAttachment (&ex, p, aEncoding, aName.c_str (), aOutput.getImpl ());
15044     if (ex != NULL) SignDoc_throw (ex);
15045     return r;
15046   }
15047 
15061   ReturnCode checkAttachment (Encoding aEncoding, const std::string &aName,
15062                               CheckAttachmentResult &aOutput)
15063   {
15064     SIGNDOC_Exception *ex = NULL;
15065     int tempOutput = 0;
15066     ReturnCode r;
15067     try
15068       {
15069         r = (ReturnCode)SIGNDOC_Document_checkAttachment (&ex, p, aEncoding, aName.c_str (), &tempOutput);
15070         aOutput = (CheckAttachmentResult )tempOutput;
15071       }
15072     catch (...)
15073       {
15074         throw;
15075       }
15076     if (ex != NULL) SignDoc_throw (ex);
15077     return r;
15078   }
15079 
15093   ReturnCode getAttachmentBlob (Encoding aEncoding, const std::string &aName,
15094                                 std::vector<unsigned char> &aOutput)
15095   {
15096     SIGNDOC_Exception *ex = NULL;
15097     SIGNDOC_ByteArray *tempOutput = NULL;
15098     ReturnCode r;
15099     try
15100       {
15101         tempOutput = SIGNDOC_ByteArray_new (&ex);
15102         if (ex != NULL) SignDoc_throw (ex);
15103         r = (ReturnCode)SIGNDOC_Document_getAttachmentBlob (&ex, p, aEncoding, aName.c_str (), tempOutput);
15104         assignArray (aOutput, tempOutput);
15105       }
15106     catch (...)
15107       {
15108         if (tempOutput != NULL)
15109           SIGNDOC_ByteArray_delete (tempOutput);
15110         throw;
15111       }
15112     if (tempOutput != NULL)
15113       SIGNDOC_ByteArray_delete (tempOutput);
15114     if (ex != NULL) SignDoc_throw (ex);
15115     return r;
15116   }
15117 
15134   ReturnCode getAttachmentStream (Encoding aEncoding, const std::string &aName,
15135                                   SIGNDOC_PTR<InputStream> &aOutput)
15136   {
15137     SIGNDOC_Exception *ex = NULL;
15138     SIGNDOC_InputStream *tempOutput = NULL;
15139     aOutput.reset ((InputStream*)NULL);
15140     ReturnCode r;
15141     try
15142       {
15143         r = (ReturnCode)SIGNDOC_Document_getAttachmentStream (&ex, p, aEncoding, aName.c_str (), &tempOutput);
15144         if (tempOutput != NULL)
15145           {
15146             aOutput.reset (new LibraryInputStream (tempOutput));
15147             tempOutput = NULL;
15148           }
15149       }
15150     catch (...)
15151       {
15152         if (tempOutput != NULL)
15153           SIGNDOC_InputStream_delete (tempOutput);
15154         throw;
15155       }
15156     if (tempOutput != NULL)
15157       SIGNDOC_InputStream_delete (tempOutput);
15158     if (ex != NULL) SignDoc_throw (ex);
15159     return r;
15160   }
15161 
15177   ReturnCode addPage (int aTargetPage, double aWidth, double aHeight)
15178   {
15179     SIGNDOC_Exception *ex = NULL;
15180     ReturnCode r;
15181     r = (ReturnCode)SIGNDOC_Document_addPage (&ex, p, aTargetPage, aWidth, aHeight);
15182     if (ex != NULL) SignDoc_throw (ex);
15183     return r;
15184   }
15185 
15213   ReturnCode importPages (int aTargetPage, SignDocDocument *aSource,
15214                           int aSourcePage, int aPageCount, int aFlags)
15215   {
15216     SIGNDOC_Exception *ex = NULL;
15217     ReturnCode r;
15218     r = (ReturnCode)SIGNDOC_Document_importPages (&ex, p, aTargetPage, aSource == NULL ? NULL : aSource->getImpl (), aSourcePage, aPageCount, aFlags);
15219     if (ex != NULL) SignDoc_throw (ex);
15220     return r;
15221   }
15222 
15260   ReturnCode importPageFromImageBlob (int aTargetPage,
15261                                       const unsigned char *aPtr, size_t aSize,
15262                                       double aZoom, double aWidth,
15263                                       double aHeight, int aFlags)
15264   {
15265     SIGNDOC_Exception *ex = NULL;
15266     ReturnCode r;
15267     r = (ReturnCode)SIGNDOC_Document_importPageFromImageBlob (&ex, p, aTargetPage, aPtr, aSize, aZoom, aWidth, aHeight, aFlags);
15268     if (ex != NULL) SignDoc_throw (ex);
15269     return r;
15270   }
15271 
15307   ReturnCode importPageFromImageFile (int aTargetPage, Encoding aEncoding,
15308                                       const std::string &aPath, double aZoom,
15309                                       double aWidth, double aHeight,
15310                                       int aFlags)
15311   {
15312     SIGNDOC_Exception *ex = NULL;
15313     ReturnCode r;
15314     r = (ReturnCode)SIGNDOC_Document_importPageFromImageFile (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aWidth, aHeight, aFlags);
15315     if (ex != NULL) SignDoc_throw (ex);
15316     return r;
15317   }
15318 
15358   ReturnCode addImageFromBlob (int aTargetPage, const unsigned char *aPtr,
15359                                size_t aSize, double aZoom, double aX,
15360                                double aY, double aWidth, double aHeight,
15361                                int aFlags)
15362   {
15363     SIGNDOC_Exception *ex = NULL;
15364     ReturnCode r;
15365     r = (ReturnCode)SIGNDOC_Document_addImageFromBlob (&ex, p, aTargetPage, aPtr, aSize, aZoom, aX, aY, aWidth, aHeight, aFlags);
15366     if (ex != NULL) SignDoc_throw (ex);
15367     return r;
15368   }
15369 
15407   ReturnCode addImageFromFile (int aTargetPage, Encoding aEncoding,
15408                                const std::string &aPath, double aZoom,
15409                                double aX, double aY, double aWidth,
15410                                double aHeight, int aFlags)
15411   {
15412     SIGNDOC_Exception *ex = NULL;
15413     ReturnCode r;
15414     r = (ReturnCode)SIGNDOC_Document_addImageFromFile (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aX, aY, aWidth, aHeight, aFlags);
15415     if (ex != NULL) SignDoc_throw (ex);
15416     return r;
15417   }
15418 
15439   ReturnCode removePages (const int *aPagesPtr, int aPagesCount,
15440                           KeepOrRemove aMode)
15441   {
15442     SIGNDOC_Exception *ex = NULL;
15443     ReturnCode r;
15444     r = (ReturnCode)SIGNDOC_Document_removePages (&ex, p, aPagesPtr, aPagesCount, aMode);
15445     if (ex != NULL) SignDoc_throw (ex);
15446     return r;
15447   }
15448 
15463   ReturnCode setCompatibility (int aMajor, int aMinor)
15464   {
15465     SIGNDOC_Exception *ex = NULL;
15466     ReturnCode r;
15467     r = (ReturnCode)SIGNDOC_Document_setCompatibility (&ex, p, aMajor, aMinor);
15468     if (ex != NULL) SignDoc_throw (ex);
15469     return r;
15470   }
15471 
15481   ReturnCode isModified (bool &aModified) const
15482   {
15483     SIGNDOC_Exception *ex = NULL;
15484     SIGNDOC_Boolean tempModified = 0;
15485     ReturnCode r;
15486     try
15487       {
15488         r = (ReturnCode)SIGNDOC_Document_isModified (&ex, p, &tempModified);
15489         aModified = (bool )tempModified;
15490       }
15491     catch (...)
15492       {
15493         throw;
15494       }
15495     if (ex != NULL) SignDoc_throw (ex);
15496     return r;
15497   }
15498 
15510   ReturnCode setFlags (unsigned aFlags)
15511   {
15512     SIGNDOC_Exception *ex = NULL;
15513     ReturnCode r;
15514     r = (ReturnCode)SIGNDOC_Document_setFlags (&ex, p, aFlags);
15515     if (ex != NULL) SignDoc_throw (ex);
15516     return r;
15517   }
15518 
15526   unsigned getFlags () const
15527   {
15528     SIGNDOC_Exception *ex = NULL;
15529     unsigned r;
15530     r = SIGNDOC_Document_getFlags (&ex, p);
15531     if (ex != NULL) SignDoc_throw (ex);
15532     return r;
15533   }
15534 
15552   ReturnCode setCompressionLevel (int aLevel)
15553   {
15554     SIGNDOC_Exception *ex = NULL;
15555     ReturnCode r;
15556     r = (ReturnCode)SIGNDOC_Document_setCompressionLevel (&ex, p, aLevel);
15557     if (ex != NULL) SignDoc_throw (ex);
15558     return r;
15559   }
15560 
15581   ReturnCode removePermissions (unsigned aFlags)
15582   {
15583     SIGNDOC_Exception *ex = NULL;
15584     ReturnCode r;
15585     r = (ReturnCode)SIGNDOC_Document_removePermissions (&ex, p, aFlags);
15586     if (ex != NULL) SignDoc_throw (ex);
15587     return r;
15588   }
15589 
15603   ReturnCode removePDFA (unsigned aFlags)
15604   {
15605     SIGNDOC_Exception *ex = NULL;
15606     ReturnCode r;
15607     r = (ReturnCode)SIGNDOC_Document_removePDFA (&ex, p, aFlags);
15608     if (ex != NULL) SignDoc_throw (ex);
15609     return r;
15610   }
15611 
15627   ReturnCode setShootInFoot (unsigned aFlags)
15628   {
15629     SIGNDOC_Exception *ex = NULL;
15630     ReturnCode r;
15631     r = (ReturnCode)SIGNDOC_Document_setShootInFoot (&ex, p, aFlags);
15632     if (ex != NULL) SignDoc_throw (ex);
15633     return r;
15634   }
15635 
15643   unsigned getShootInFoot () const
15644   {
15645     SIGNDOC_Exception *ex = NULL;
15646     unsigned r;
15647     r = SIGNDOC_Document_getShootInFoot (&ex, p);
15648     if (ex != NULL) SignDoc_throw (ex);
15649     return r;
15650   }
15651 
15665   const char *getErrorMessage (Encoding aEncoding) const
15666   {
15667     SIGNDOC_Exception *ex = NULL;
15668     const char *r;
15669     r = SIGNDOC_Document_getErrorMessage (&ex, p, aEncoding);
15670     if (ex != NULL) SignDoc_throw (ex);
15671     return r;
15672   }
15673 
15685   const wchar_t *getErrorMessageW () const
15686   {
15687     SIGNDOC_Exception *ex = NULL;
15688     const wchar_t *r;
15689     r = SIGNDOC_Document_getErrorMessageW (&ex, p);
15690     if (ex != NULL) SignDoc_throw (ex);
15691     return r;
15692   }
15693 
15715   SPPDF_Document *getSPPDFDocument (bool aDestroy)
15716   {
15717     SIGNDOC_Exception *ex = NULL;
15718     SPPDF_Document *r;
15719     r = SIGNDOC_Document_getSPPDFDocument (&ex, p, aDestroy);
15720     if (ex != NULL) SignDoc_throw (ex);
15721     return r;
15722   }
15723 
15724 private:
15728   SignDocDocument (const SignDocDocument &);
15729 
15733   SignDocDocument &operator= (const SignDocDocument &);
15734 public:
15739   SignDocDocument (SIGNDOC_Document *aP) : p (aP) { }
15740 
15745   SIGNDOC_Document *getImpl () { return p; }
15746 
15751   const SIGNDOC_Document *getImpl () const { return p; }
15752 
15757   void setImpl (SIGNDOC_Document *aP) { SIGNDOC_Document_delete (p); p  = aP; }
15758 
15759 private:
15760   SIGNDOC_Document *p;
15761 };
15762 
15766 class SignDocDocumentHandler 
15767 {
15768 public:
15774   SignDocDocumentHandler ()
15775     : p (NULL)
15776   {
15777   }
15778 
15784   virtual ~SignDocDocumentHandler ()
15785   {
15786     SIGNDOC_DocumentHandler_delete (p);
15787   }
15788 
15789 private:
15793   SignDocDocumentHandler (const SignDocDocumentHandler &);
15794 
15795 public:
15800   SignDocDocumentHandler (SIGNDOC_DocumentHandler *aP) : p (aP) { }
15801 
15806   SIGNDOC_DocumentHandler *getImpl () { return p; }
15807 
15812   const SIGNDOC_DocumentHandler *getImpl () const { return p; }
15813 
15818   void destroyWithoutImpl () { p = NULL; delete this; }
15819 
15824   void setImpl (SIGNDOC_DocumentHandler *aP) { SIGNDOC_DocumentHandler_delete (p); p  = aP; }
15825 
15826 protected:
15827   SIGNDOC_DocumentHandler *p;
15828 };
15829 
15849 class SignDocDocumentLoader 
15850 {
15851 public:
15855   enum RemainingDays
15856   {
15860     rd_product,
15861 
15865     rd_signing
15866   };
15867 
15871   enum Flags
15872   {
15883     f_map_into_memory = 0x01
15884   };
15885 
15886 public:
15890   SignDocDocumentLoader ()
15891     : p (NULL)
15892   {
15893     SIGNDOC_Exception *ex = NULL;
15894     p = SIGNDOC_DocumentLoader_new (&ex);
15895     if (ex != NULL) SignDoc_throw (ex);
15896   }
15897 
15901   ~SignDocDocumentLoader ()
15902   {
15903     SIGNDOC_DocumentLoader_delete (p);
15904   }
15905 
15922   static bool initLicenseManager (int aWho1, int aWho2)
15923   {
15924     SIGNDOC_Exception *ex = NULL;
15925     bool r;
15926     r = (bool)SIGNDOC_DocumentLoader_initLicenseManager (&ex, aWho1, aWho2);
15927     if (ex != NULL) SignDoc_throw (ex);
15928     return r;
15929   }
15930 
15950   static bool setLicenseKey (const void *aKeyPtr, size_t aKeySize,
15951                              const char *aProduct, const char *aVersion,
15952                              const void *aTokenPtr, size_t aTokenSize)
15953   {
15954     SIGNDOC_Exception *ex = NULL;
15955     bool r;
15956     r = (bool)SIGNDOC_DocumentLoader_setLicenseKey (&ex, aKeyPtr, aKeySize, aProduct, aVersion, aTokenPtr, aTokenSize);
15957     if (ex != NULL) SignDoc_throw (ex);
15958     return r;
15959   }
15960 
15973   static bool generateLicenseToken (const char *aProduct,
15974                                     std::vector<unsigned char> &aOutput)
15975   {
15976     SIGNDOC_Exception *ex = NULL;
15977     SIGNDOC_ByteArray *tempOutput = NULL;
15978     bool r;
15979     try
15980       {
15981         tempOutput = SIGNDOC_ByteArray_new (&ex);
15982         if (ex != NULL) SignDoc_throw (ex);
15983         r = (bool)SIGNDOC_DocumentLoader_generateLicenseToken (&ex, aProduct, tempOutput);
15984         assignArray (aOutput, tempOutput);
15985       }
15986     catch (...)
15987       {
15988         if (tempOutput != NULL)
15989           SIGNDOC_ByteArray_delete (tempOutput);
15990         throw;
15991       }
15992     if (tempOutput != NULL)
15993       SIGNDOC_ByteArray_delete (tempOutput);
15994     if (ex != NULL) SignDoc_throw (ex);
15995     return r;
15996   }
15997 
16010   static int getRemainingDays (RemainingDays aWhat)
16011   {
16012     SIGNDOC_Exception *ex = NULL;
16013     int r;
16014     r = SIGNDOC_DocumentLoader_getRemainingDays (&ex, aWhat);
16015     if (ex != NULL) SignDoc_throw (ex);
16016     return r;
16017   }
16018 
16027   static bool getInstallationCode (std::string &aCode)
16028   {
16029     SIGNDOC_Exception *ex = NULL;
16030     char *tempCode = NULL;
16031     bool r;
16032     try
16033       {
16034         r = (bool)SIGNDOC_DocumentLoader_getInstallationCode (&ex, &tempCode);
16035         if (tempCode != NULL)
16036           aCode = tempCode;
16037       }
16038     catch (...)
16039       {
16040         SIGNDOC_free (tempCode);
16041         throw;
16042       }
16043     SIGNDOC_free (tempCode);
16044     if (ex != NULL) SignDoc_throw (ex);
16045     return r;
16046   }
16047 
16059   static bool getVersionNumber (std::string &aVersion)
16060   {
16061     SIGNDOC_Exception *ex = NULL;
16062     char *tempVersion = NULL;
16063     bool r;
16064     try
16065       {
16066         r = (bool)SIGNDOC_DocumentLoader_getVersionNumber (&ex, &tempVersion);
16067         if (tempVersion != NULL)
16068           aVersion = tempVersion;
16069       }
16070     catch (...)
16071       {
16072         SIGNDOC_free (tempVersion);
16073         throw;
16074       }
16075     SIGNDOC_free (tempVersion);
16076     if (ex != NULL) SignDoc_throw (ex);
16077     return r;
16078   }
16079 
16093   static bool getComponentVersionNumber (const char *aComponent,
16094                                          std::string &aVersion)
16095   {
16096     SIGNDOC_Exception *ex = NULL;
16097     char *tempVersion = NULL;
16098     bool r;
16099     try
16100       {
16101         r = (bool)SIGNDOC_DocumentLoader_getComponentVersionNumber (&ex, aComponent, &tempVersion);
16102         if (tempVersion != NULL)
16103           aVersion = tempVersion;
16104       }
16105     catch (...)
16106       {
16107         SIGNDOC_free (tempVersion);
16108         throw;
16109       }
16110     SIGNDOC_free (tempVersion);
16111     if (ex != NULL) SignDoc_throw (ex);
16112     return r;
16113   }
16114 
16125   static int getLicenseTextCount ()
16126   {
16127     SIGNDOC_Exception *ex = NULL;
16128     int r;
16129     r = SIGNDOC_DocumentLoader_getLicenseTextCount (&ex);
16130     if (ex != NULL) SignDoc_throw (ex);
16131     return r;
16132   }
16133 
16148   static const char *getLicenseText (int aIndex)
16149   {
16150     SIGNDOC_Exception *ex = NULL;
16151     const char *r;
16152     r = SIGNDOC_DocumentLoader_getLicenseText (&ex, aIndex);
16153     if (ex != NULL) SignDoc_throw (ex);
16154     return r;
16155   }
16156 
16173   SignDocDocument *loadFromMemory (const unsigned char *aData, size_t aSize,
16174                                    bool aCopy)
16175   {
16176     SIGNDOC_Exception *ex = NULL;
16177     SIGNDOC_Document *r;
16178     r = SIGNDOC_DocumentLoader_loadFromMemory (&ex, p, aData, aSize, aCopy);
16179     if (ex != NULL) SignDoc_throw (ex);
16180     if (r == NULL)
16181       return NULL;
16182     try
16183       {
16184         return new SignDocDocument (r);
16185       }
16186     catch (...)
16187       {
16188         SIGNDOC_Document_delete (r);
16189         throw;
16190       }
16191   }
16192 
16213   SignDocDocument *loadFromFile (Encoding aEncoding, const char *aPath,
16214                                  bool aWritable)
16215   {
16216     SIGNDOC_Exception *ex = NULL;
16217     SIGNDOC_Document *r;
16218     r = SIGNDOC_DocumentLoader_loadFromFile (&ex, p, aEncoding, aPath, aWritable);
16219     if (ex != NULL) SignDoc_throw (ex);
16220     if (r == NULL)
16221       return NULL;
16222     try
16223       {
16224         return new SignDocDocument (r);
16225       }
16226     catch (...)
16227       {
16228         SIGNDOC_Document_delete (r);
16229         throw;
16230       }
16231   }
16232 
16249   SignDocDocument *loadFromFile (const wchar_t *aPath, bool aWritable)
16250   {
16251     SIGNDOC_Exception *ex = NULL;
16252     SIGNDOC_Document *r;
16253     r = SIGNDOC_DocumentLoader_loadFromFileW (&ex, p, aPath, aWritable);
16254     if (ex != NULL) SignDoc_throw (ex);
16255     if (r == NULL)
16256       return NULL;
16257     try
16258       {
16259         return new SignDocDocument (r);
16260       }
16261     catch (...)
16262       {
16263         SIGNDOC_Document_delete (r);
16264         throw;
16265       }
16266   }
16267 
16282   SignDocDocument *createPDF (int aMajor, int aMinor)
16283   {
16284     SIGNDOC_Exception *ex = NULL;
16285     SIGNDOC_Document *r;
16286     r = SIGNDOC_DocumentLoader_createPDF (&ex, p, aMajor, aMinor);
16287     if (ex != NULL) SignDoc_throw (ex);
16288     if (r == NULL)
16289       return NULL;
16290     try
16291       {
16292         return new SignDocDocument (r);
16293       }
16294     catch (...)
16295       {
16296         SIGNDOC_Document_delete (r);
16297         throw;
16298       }
16299   }
16300 
16310   SignDocDocument::DocumentType ping (InputStream &aStream)
16311   {
16312     SIGNDOC_Exception *ex = NULL;
16313     SignDocDocument::DocumentType r;
16314     r = (SignDocDocument::DocumentType)SIGNDOC_DocumentLoader_ping (&ex, p, aStream.getImpl ());
16315     if (ex != NULL) SignDoc_throw (ex);
16316     return r;
16317   }
16318 
16341   bool loadFontConfigFile (Encoding aEncoding, const char *aPath)
16342   {
16343     SIGNDOC_Exception *ex = NULL;
16344     bool r;
16345     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigFile (&ex, p, aEncoding, aPath);
16346     if (ex != NULL) SignDoc_throw (ex);
16347     return r;
16348   }
16349 
16368   bool loadFontConfigFile (const wchar_t *aPath)
16369   {
16370     SIGNDOC_Exception *ex = NULL;
16371     bool r;
16372     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigFileW (&ex, p, aPath);
16373     if (ex != NULL) SignDoc_throw (ex);
16374     return r;
16375   }
16376 
16398   bool loadFontConfigEnvironment (const char *aName)
16399   {
16400     SIGNDOC_Exception *ex = NULL;
16401     bool r;
16402     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigEnvironment (&ex, p, aName);
16403     if (ex != NULL) SignDoc_throw (ex);
16404     return r;
16405   }
16406 
16435   bool loadFontConfigStream (InputStream &aStream, Encoding aEncoding,
16436                              const char *aDirectory)
16437   {
16438     SIGNDOC_Exception *ex = NULL;
16439     bool r;
16440     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigStream (&ex, p, aStream.getImpl (), aEncoding, aDirectory);
16441     if (ex != NULL) SignDoc_throw (ex);
16442     return r;
16443   }
16444 
16469   bool loadFontConfigStream (InputStream &aStream, const wchar_t *aDirectory)
16470   {
16471     SIGNDOC_Exception *ex = NULL;
16472     bool r;
16473     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigStreamW (&ex, p, aStream.getImpl (), aDirectory);
16474     if (ex != NULL) SignDoc_throw (ex);
16475     return r;
16476   }
16477 
16502   bool loadPdfFontConfigFile (Encoding aEncoding, const char *aPath)
16503   {
16504     SIGNDOC_Exception *ex = NULL;
16505     bool r;
16506     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigFile (&ex, p, aEncoding, aPath);
16507     if (ex != NULL) SignDoc_throw (ex);
16508     return r;
16509   }
16510 
16531   bool loadPdfFontConfigFile (const wchar_t *aPath)
16532   {
16533     SIGNDOC_Exception *ex = NULL;
16534     bool r;
16535     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigFileW (&ex, p, aPath);
16536     if (ex != NULL) SignDoc_throw (ex);
16537     return r;
16538   }
16539 
16568   bool loadPdfFontConfigEnvironment (const char *aName)
16569   {
16570     SIGNDOC_Exception *ex = NULL;
16571     bool r;
16572     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigEnvironment (&ex, p, aName);
16573     if (ex != NULL) SignDoc_throw (ex);
16574     return r;
16575   }
16576 
16607   bool loadPdfFontConfigStream (InputStream &aStream, Encoding aEncoding,
16608                                 const char *aDirectory)
16609   {
16610     SIGNDOC_Exception *ex = NULL;
16611     bool r;
16612     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigStream (&ex, p, aStream.getImpl (), aEncoding, aDirectory);
16613     if (ex != NULL) SignDoc_throw (ex);
16614     return r;
16615   }
16616 
16643   bool loadPdfFontConfigStream (InputStream &aStream,
16644                                 const wchar_t *aDirectory)
16645   {
16646     SIGNDOC_Exception *ex = NULL;
16647     bool r;
16648     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigStreamW (&ex, p, aStream.getImpl (), aDirectory);
16649     if (ex != NULL) SignDoc_throw (ex);
16650     return r;
16651   }
16652 
16669   void getFailedFontFiles (std::vector<std::string> &aOutput)
16670   {
16671     SIGNDOC_Exception *ex = NULL;
16672     SIGNDOC_StringArray *tempOutput = NULL;
16673     try
16674       {
16675         tempOutput = SIGNDOC_StringArray_new (&ex);
16676         if (ex != NULL) SignDoc_throw (ex);
16677         SIGNDOC_DocumentLoader_getFailedFontFiles (&ex, p, tempOutput);
16678         assignArray (aOutput, tempOutput);
16679       }
16680     catch (...)
16681       {
16682         if (tempOutput != NULL)
16683           SIGNDOC_StringArray_delete (tempOutput);
16684         throw;
16685       }
16686     if (tempOutput != NULL)
16687       SIGNDOC_StringArray_delete (tempOutput);
16688     if (ex != NULL) SignDoc_throw (ex);
16689   }
16690 
16712   bool loadTrustedCertificatesFromFile (Encoding aEncoding, const char *aPath)
16713   {
16714     SIGNDOC_Exception *ex = NULL;
16715     bool r;
16716     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromFile (&ex, p, aEncoding, aPath);
16717     if (ex != NULL) SignDoc_throw (ex);
16718     return r;
16719   }
16720 
16740   bool loadTrustedCertificatesFromFile (const wchar_t *aPath)
16741   {
16742     SIGNDOC_Exception *ex = NULL;
16743     bool r;
16744     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromFileW (&ex, p, aPath);
16745     if (ex != NULL) SignDoc_throw (ex);
16746     return r;
16747   }
16748 
16768   bool loadTrustedCertificatesFromStream (InputStream &aStream)
16769   {
16770     SIGNDOC_Exception *ex = NULL;
16771     bool r;
16772     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromStream (&ex, p, aStream.getImpl ());
16773     if (ex != NULL) SignDoc_throw (ex);
16774     return r;
16775   }
16776 
16798   bool initLogging (Encoding aEncoding, const char *aLevel,
16799                     const char *aPathname)
16800   {
16801     SIGNDOC_Exception *ex = NULL;
16802     bool r;
16803     r = (bool)SIGNDOC_DocumentLoader_initLogging (&ex, p, aEncoding, aLevel, aPathname);
16804     if (ex != NULL) SignDoc_throw (ex);
16805     return r;
16806   }
16807 
16822   const char *getErrorMessage (Encoding aEncoding) const
16823   {
16824     SIGNDOC_Exception *ex = NULL;
16825     const char *r;
16826     r = SIGNDOC_DocumentLoader_getErrorMessage (&ex, p, aEncoding);
16827     if (ex != NULL) SignDoc_throw (ex);
16828     return r;
16829   }
16830 
16843   const wchar_t *getErrorMessageW () const
16844   {
16845     SIGNDOC_Exception *ex = NULL;
16846     const wchar_t *r;
16847     r = SIGNDOC_DocumentLoader_getErrorMessageW (&ex, p);
16848     if (ex != NULL) SignDoc_throw (ex);
16849     return r;
16850   }
16851 
16863   bool registerDocumentHandler (SignDocDocumentHandler *aHandler)
16864   {
16865     SIGNDOC_Exception *ex = NULL;
16866     bool r;
16867     r = (bool)SIGNDOC_DocumentLoader_registerDocumentHandler (&ex, p, aHandler == NULL ? NULL : aHandler->getImpl ());
16868     if (ex == NULL) aHandler->destroyWithoutImpl ();
16869     if (ex != NULL) SignDoc_throw (ex);
16870     return r;
16871   }
16872 
16879   void setFlags (unsigned aFlags)
16880   {
16881     SIGNDOC_Exception *ex = NULL;
16882     SIGNDOC_DocumentLoader_setFlags (&ex, p, aFlags);
16883     if (ex != NULL) SignDoc_throw (ex);
16884   }
16885 
16886 private:
16890   SignDocDocumentLoader (const SignDocDocumentLoader &);
16891 
16895   SignDocDocumentLoader &operator= (const SignDocDocumentLoader &);
16896 
16897 private:
16898 public:
16903   SignDocDocumentLoader (SIGNDOC_DocumentLoader *aP) : p (aP) { }
16904 
16909   SIGNDOC_DocumentLoader *getImpl () { return p; }
16910 
16915   const SIGNDOC_DocumentLoader *getImpl () const { return p; }
16916 
16921   void setImpl (SIGNDOC_DocumentLoader *aP) { SIGNDOC_DocumentLoader_delete (p); p  = aP; }
16922 
16923 private:
16924   SIGNDOC_DocumentLoader *p;
16925 };
16926 
16931 class SignDocVerificationResult 
16932 {
16933 public:
16939   enum ReturnCode
16940   {
16941     rc_ok = SignDocDocument::rc_ok, 
16942     rc_invalid_argument = SignDocDocument::rc_invalid_argument, 
16943     rc_not_supported = SignDocDocument::rc_not_supported, 
16944     rc_not_verified = SignDocDocument::rc_not_verified, 
16945     rc_property_not_found = SignDocDocument::rc_property_not_found, 
16946     rc_no_biometric_data = SignDocDocument::rc_no_biometric_data, 
16947     rc_unexpected_error = SignDocDocument::rc_unexpected_error 
16948   };
16949 
16953   enum SignatureState
16954   {
16955     ss_unmodified,            
16956     ss_document_extended,     
16957     ss_document_modified,     
16958     ss_unsupported_signature, 
16959     ss_invalid_certificate,   
16960     ss_empty                  
16961   };
16962 
16966   enum TimeStampState
16967   {
16968     tss_valid,                
16969     tss_missing,              
16970     tss_invalid               
16971   };
16972 
16977   enum CertificateChainState
16978   {
16979     ccs_ok,                   
16980     ccs_broken_chain,         
16981     ccs_untrusted_root,       
16982     ccs_critical_extension,   
16983     ccs_not_time_valid,       
16984     ccs_path_length,          
16985     ccs_invalid,              
16986     ccs_error                 
16987   };
16988 
16993   enum CertificateRevocationState
16994   {
16995     crs_ok,                     
16996     crs_not_checked,            
16997     crs_offline,                
16998     crs_revoked,                
16999     crs_error                   
17000   };
17001 
17002 public:
17006   SignDocVerificationResult ()
17007     : p (NULL)
17008   {
17009   }
17010 
17014   ~SignDocVerificationResult ()
17015   {
17016     SIGNDOC_VerificationResult_delete (p);
17017   }
17018 
17039   ReturnCode getState (SignatureState &aOutput)
17040   {
17041     SIGNDOC_Exception *ex = NULL;
17042     int tempOutput = 0;
17043     ReturnCode r;
17044     try
17045       {
17046         r = (ReturnCode)SIGNDOC_VerificationResult_getState (&ex, p, &tempOutput);
17047         aOutput = (SignatureState )tempOutput;
17048       }
17049     catch (...)
17050       {
17051         throw;
17052       }
17053     if (ex != NULL) SignDoc_throw (ex);
17054     return r;
17055   }
17056 
17072   ReturnCode getMethod (SignDocSignatureParameters::Method &aOutput)
17073   {
17074     SIGNDOC_Exception *ex = NULL;
17075     int tempOutput = 0;
17076     ReturnCode r;
17077     try
17078       {
17079         r = (ReturnCode)SIGNDOC_VerificationResult_getMethod (&ex, p, &tempOutput);
17080         aOutput = (SignDocSignatureParameters::Method )tempOutput;
17081       }
17082     catch (...)
17083       {
17084         throw;
17085       }
17086     if (ex != NULL) SignDoc_throw (ex);
17087     return r;
17088   }
17089 
17114   ReturnCode getDigestAlgorithm (std::string &aOutput)
17115   {
17116     SIGNDOC_Exception *ex = NULL;
17117     char *tempOutput = NULL;
17118     ReturnCode r;
17119     try
17120       {
17121         r = (ReturnCode)SIGNDOC_VerificationResult_getDigestAlgorithm (&ex, p, &tempOutput);
17122         if (tempOutput != NULL)
17123           aOutput = tempOutput;
17124       }
17125     catch (...)
17126       {
17127         SIGNDOC_free (tempOutput);
17128         throw;
17129       }
17130     SIGNDOC_free (tempOutput);
17131     if (ex != NULL) SignDoc_throw (ex);
17132     return r;
17133   }
17134 
17150   ReturnCode getCertificates (std::vector<std::vector<unsigned char> > &aOutput)
17151   {
17152     SIGNDOC_Exception *ex = NULL;
17153     SIGNDOC_ByteArrayArray *tempOutput = NULL;
17154     ReturnCode r;
17155     try
17156       {
17157         tempOutput = SIGNDOC_ByteArrayArray_new (&ex);
17158         if (ex != NULL) SignDoc_throw (ex);
17159         r = (ReturnCode)SIGNDOC_VerificationResult_getCertificates (&ex, p, tempOutput);
17160         assignArray (aOutput, tempOutput);
17161       }
17162     catch (...)
17163       {
17164         if (tempOutput != NULL)
17165           SIGNDOC_ByteArrayArray_delete (tempOutput);
17166         throw;
17167       }
17168     if (tempOutput != NULL)
17169       SIGNDOC_ByteArrayArray_delete (tempOutput);
17170     if (ex != NULL) SignDoc_throw (ex);
17171     return r;
17172   }
17173 
17196   ReturnCode verifyCertificateChain (const SignDocVerificationParameters *aParameters,
17197                                      CertificateChainState &aOutput)
17198   {
17199     SIGNDOC_Exception *ex = NULL;
17200     int tempOutput = 0;
17201     ReturnCode r;
17202     try
17203       {
17204         r = (ReturnCode)SIGNDOC_VerificationResult_verifyCertificateChain (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), &tempOutput);
17205         aOutput = (CertificateChainState )tempOutput;
17206       }
17207     catch (...)
17208       {
17209         throw;
17210       }
17211     if (ex != NULL) SignDoc_throw (ex);
17212     return r;
17213   }
17214 
17238   ReturnCode getCertificateRevocationState (CertificateRevocationState &aOutput)
17239   {
17240     SIGNDOC_Exception *ex = NULL;
17241     int tempOutput = 0;
17242     ReturnCode r;
17243     try
17244       {
17245         r = (ReturnCode)SIGNDOC_VerificationResult_getCertificateRevocationState (&ex, p, &tempOutput);
17246         aOutput = (CertificateRevocationState )tempOutput;
17247       }
17248     catch (...)
17249       {
17250         throw;
17251       }
17252     if (ex != NULL) SignDoc_throw (ex);
17253     return r;
17254   }
17255 
17278   ReturnCode verifyCertificateSimplified (const SignDocVerificationParameters *aParameters)
17279   {
17280     SIGNDOC_Exception *ex = NULL;
17281     ReturnCode r;
17282     r = (ReturnCode)SIGNDOC_VerificationResult_verifyCertificateSimplified (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl ());
17283     if (ex != NULL) SignDoc_throw (ex);
17284     return r;
17285   }
17286 
17305   ReturnCode getCertificateChainLength (int &aOutput)
17306   {
17307     SIGNDOC_Exception *ex = NULL;
17308     ReturnCode r;
17309     r = (ReturnCode)SIGNDOC_VerificationResult_getCertificateChainLength (&ex, p, &aOutput);
17310     if (ex != NULL) SignDoc_throw (ex);
17311     return r;
17312   }
17313 
17351   ReturnCode getSignatureString (Encoding aEncoding, const std::string &aName,
17352                                  std::string &aOutput)
17353   {
17354     SIGNDOC_Exception *ex = NULL;
17355     char *tempOutput = NULL;
17356     ReturnCode r;
17357     try
17358       {
17359         r = (ReturnCode)SIGNDOC_VerificationResult_getSignatureString (&ex, p, aEncoding, aName.c_str (), &tempOutput);
17360         if (tempOutput != NULL)
17361           aOutput = tempOutput;
17362       }
17363     catch (...)
17364       {
17365         SIGNDOC_free (tempOutput);
17366         throw;
17367       }
17368     SIGNDOC_free (tempOutput);
17369     if (ex != NULL) SignDoc_throw (ex);
17370     return r;
17371   }
17372 
17398   ReturnCode getSignatureBlob (const std::string &aName,
17399                                std::vector<unsigned char> &aOutput)
17400   {
17401     SIGNDOC_Exception *ex = NULL;
17402     SIGNDOC_ByteArray *tempOutput = NULL;
17403     ReturnCode r;
17404     try
17405       {
17406         tempOutput = SIGNDOC_ByteArray_new (&ex);
17407         if (ex != NULL) SignDoc_throw (ex);
17408         r = (ReturnCode)SIGNDOC_VerificationResult_getSignatureBlob (&ex, p, aName.c_str (), tempOutput);
17409         assignArray (aOutput, tempOutput);
17410       }
17411     catch (...)
17412       {
17413         if (tempOutput != NULL)
17414           SIGNDOC_ByteArray_delete (tempOutput);
17415         throw;
17416       }
17417     if (tempOutput != NULL)
17418       SIGNDOC_ByteArray_delete (tempOutput);
17419     if (ex != NULL) SignDoc_throw (ex);
17420     return r;
17421   }
17422 
17466   ReturnCode getBiometricData (const unsigned char *aKeyPtr, size_t aKeySize,
17467                                const wchar_t *aKeyPath,
17468                                const char *aPassphrase,
17469                                std::vector<unsigned char> &aOutput)
17470   {
17471     SIGNDOC_Exception *ex = NULL;
17472     SIGNDOC_ByteArray *tempOutput = NULL;
17473     ReturnCode r;
17474     try
17475       {
17476         tempOutput = SIGNDOC_ByteArray_new (&ex);
17477         if (ex != NULL) SignDoc_throw (ex);
17478         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricDataW (&ex, p, aKeyPtr, aKeySize, aKeyPath, aPassphrase, tempOutput);
17479         assignArray (aOutput, tempOutput);
17480       }
17481     catch (...)
17482       {
17483         if (tempOutput != NULL)
17484           SIGNDOC_ByteArray_delete (tempOutput);
17485         throw;
17486       }
17487     if (tempOutput != NULL)
17488       SIGNDOC_ByteArray_delete (tempOutput);
17489     if (ex != NULL) SignDoc_throw (ex);
17490     return r;
17491   }
17492 
17538   ReturnCode getBiometricData (Encoding aEncoding,
17539                                const unsigned char *aKeyPtr, size_t aKeySize,
17540                                const char *aKeyPath, const char *aPassphrase,
17541                                std::vector<unsigned char> &aOutput)
17542   {
17543     SIGNDOC_Exception *ex = NULL;
17544     SIGNDOC_ByteArray *tempOutput = NULL;
17545     ReturnCode r;
17546     try
17547       {
17548         tempOutput = SIGNDOC_ByteArray_new (&ex);
17549         if (ex != NULL) SignDoc_throw (ex);
17550         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricData (&ex, p, aEncoding, aKeyPtr, aKeySize, aKeyPath, aPassphrase, tempOutput);
17551         assignArray (aOutput, tempOutput);
17552       }
17553     catch (...)
17554       {
17555         if (tempOutput != NULL)
17556           SIGNDOC_ByteArray_delete (tempOutput);
17557         throw;
17558       }
17559     if (tempOutput != NULL)
17560       SIGNDOC_ByteArray_delete (tempOutput);
17561     if (ex != NULL) SignDoc_throw (ex);
17562     return r;
17563   }
17564 
17628   ReturnCode getEncryptedBiometricData (std::vector<unsigned char> &aOutput)
17629   {
17630     SIGNDOC_Exception *ex = NULL;
17631     SIGNDOC_ByteArray *tempOutput = NULL;
17632     ReturnCode r;
17633     try
17634       {
17635         tempOutput = SIGNDOC_ByteArray_new (&ex);
17636         if (ex != NULL) SignDoc_throw (ex);
17637         r = (ReturnCode)SIGNDOC_VerificationResult_getEncryptedBiometricData (&ex, p, tempOutput);
17638         assignArray (aOutput, tempOutput);
17639       }
17640     catch (...)
17641       {
17642         if (tempOutput != NULL)
17643           SIGNDOC_ByteArray_delete (tempOutput);
17644         throw;
17645       }
17646     if (tempOutput != NULL)
17647       SIGNDOC_ByteArray_delete (tempOutput);
17648     if (ex != NULL) SignDoc_throw (ex);
17649     return r;
17650   }
17651 
17665   ReturnCode getBiometricEncryption (SignDocSignatureParameters::BiometricEncryption &aOutput)
17666   {
17667     SIGNDOC_Exception *ex = NULL;
17668     int tempOutput = 0;
17669     ReturnCode r;
17670     try
17671       {
17672         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricEncryption (&ex, p, &tempOutput);
17673         aOutput = (SignDocSignatureParameters::BiometricEncryption )tempOutput;
17674       }
17675     catch (...)
17676       {
17677         throw;
17678       }
17679     if (ex != NULL) SignDoc_throw (ex);
17680     return r;
17681   }
17682 
17699   ReturnCode checkBiometricHash (const unsigned char *aBioPtr, size_t aBioSize,
17700                                  bool &aOutput)
17701   {
17702     SIGNDOC_Exception *ex = NULL;
17703     SIGNDOC_Boolean tempOutput = 0;
17704     ReturnCode r;
17705     try
17706       {
17707         r = (ReturnCode)SIGNDOC_VerificationResult_checkBiometricHash (&ex, p, aBioPtr, aBioSize, &tempOutput);
17708         aOutput = (bool )tempOutput;
17709       }
17710     catch (...)
17711       {
17712         throw;
17713       }
17714     if (ex != NULL) SignDoc_throw (ex);
17715     return r;
17716   }
17717 
17725   ReturnCode getTimeStampState (TimeStampState &aOutput)
17726   {
17727     SIGNDOC_Exception *ex = NULL;
17728     int tempOutput = 0;
17729     ReturnCode r;
17730     try
17731       {
17732         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampState (&ex, p, &tempOutput);
17733         aOutput = (TimeStampState )tempOutput;
17734       }
17735     catch (...)
17736       {
17737         throw;
17738       }
17739     if (ex != NULL) SignDoc_throw (ex);
17740     return r;
17741   }
17742 
17765   ReturnCode getTimeStampDigestAlgorithm (std::string &aOutput)
17766   {
17767     SIGNDOC_Exception *ex = NULL;
17768     char *tempOutput = NULL;
17769     ReturnCode r;
17770     try
17771       {
17772         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampDigestAlgorithm (&ex, p, &tempOutput);
17773         if (tempOutput != NULL)
17774           aOutput = tempOutput;
17775       }
17776     catch (...)
17777       {
17778         SIGNDOC_free (tempOutput);
17779         throw;
17780       }
17781     SIGNDOC_free (tempOutput);
17782     if (ex != NULL) SignDoc_throw (ex);
17783     return r;
17784   }
17785 
17804   ReturnCode verifyTimeStampCertificateChain (const SignDocVerificationParameters *aParameters,
17805                                               CertificateChainState &aOutput)
17806   {
17807     SIGNDOC_Exception *ex = NULL;
17808     int tempOutput = 0;
17809     ReturnCode r;
17810     try
17811       {
17812         r = (ReturnCode)SIGNDOC_VerificationResult_verifyTimeStampCertificateChain (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), &tempOutput);
17813         aOutput = (CertificateChainState )tempOutput;
17814       }
17815     catch (...)
17816       {
17817         throw;
17818       }
17819     if (ex != NULL) SignDoc_throw (ex);
17820     return r;
17821   }
17822 
17844   ReturnCode getTimeStampCertificateRevocationState (CertificateRevocationState &aOutput)
17845   {
17846     SIGNDOC_Exception *ex = NULL;
17847     int tempOutput = 0;
17848     ReturnCode r;
17849     try
17850       {
17851         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampCertificateRevocationState (&ex, p, &tempOutput);
17852         aOutput = (CertificateRevocationState )tempOutput;
17853       }
17854     catch (...)
17855       {
17856         throw;
17857       }
17858     if (ex != NULL) SignDoc_throw (ex);
17859     return r;
17860   }
17861 
17890   ReturnCode verifyTimeStampCertificateSimplified (const SignDocVerificationParameters *aParameters)
17891   {
17892     SIGNDOC_Exception *ex = NULL;
17893     ReturnCode r;
17894     r = (ReturnCode)SIGNDOC_VerificationResult_verifyTimeStampCertificateSimplified (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl ());
17895     if (ex != NULL) SignDoc_throw (ex);
17896     return r;
17897   }
17898 
17919   ReturnCode getTimeStamp (std::string &aOutput)
17920   {
17921     SIGNDOC_Exception *ex = NULL;
17922     char *tempOutput = NULL;
17923     ReturnCode r;
17924     try
17925       {
17926         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStamp (&ex, p, &tempOutput);
17927         if (tempOutput != NULL)
17928           aOutput = tempOutput;
17929       }
17930     catch (...)
17931       {
17932         SIGNDOC_free (tempOutput);
17933         throw;
17934       }
17935     SIGNDOC_free (tempOutput);
17936     if (ex != NULL) SignDoc_throw (ex);
17937     return r;
17938   }
17939 
17950   ReturnCode getTimeStampCertificates (std::vector<std::vector<unsigned char> > &aOutput)
17951   {
17952     SIGNDOC_Exception *ex = NULL;
17953     SIGNDOC_ByteArrayArray *tempOutput = NULL;
17954     ReturnCode r;
17955     try
17956       {
17957         tempOutput = SIGNDOC_ByteArrayArray_new (&ex);
17958         if (ex != NULL) SignDoc_throw (ex);
17959         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampCertificates (&ex, p, tempOutput);
17960         assignArray (aOutput, tempOutput);
17961       }
17962     catch (...)
17963       {
17964         if (tempOutput != NULL)
17965           SIGNDOC_ByteArrayArray_delete (tempOutput);
17966         throw;
17967       }
17968     if (tempOutput != NULL)
17969       SIGNDOC_ByteArrayArray_delete (tempOutput);
17970     if (ex != NULL) SignDoc_throw (ex);
17971     return r;
17972   }
17973 
17987   const char *getErrorMessage (Encoding aEncoding) const
17988   {
17989     SIGNDOC_Exception *ex = NULL;
17990     const char *r;
17991     r = SIGNDOC_VerificationResult_getErrorMessage (&ex, p, aEncoding);
17992     if (ex != NULL) SignDoc_throw (ex);
17993     return r;
17994   }
17995 
18007   const wchar_t *getErrorMessageW () const
18008   {
18009     SIGNDOC_Exception *ex = NULL;
18010     const wchar_t *r;
18011     r = SIGNDOC_VerificationResult_getErrorMessageW (&ex, p);
18012     if (ex != NULL) SignDoc_throw (ex);
18013     return r;
18014   }
18019   SignDocVerificationResult (SIGNDOC_VerificationResult *aP) : p (aP) { }
18020 
18025   SIGNDOC_VerificationResult *getImpl () { return p; }
18026 
18031   const SIGNDOC_VerificationResult *getImpl () const { return p; }
18032 
18037   void setImpl (SIGNDOC_VerificationResult *aP) { SIGNDOC_VerificationResult_delete (p); p  = aP; }
18038 
18039 private:
18040   SIGNDOC_VerificationResult *p;
18041 };
18042 
18046 class SignDocPdfDocumentHandler : public SignDocDocumentHandler
18047 {
18048 public:
18049 
18055   static SignDocDocumentHandler *create ()
18056   {
18057     SIGNDOC_Exception *ex = NULL;
18058     SIGNDOC_DocumentHandler *r;
18059     r = SIGNDOC_PdfDocumentHandler_new (&ex);
18060     if (ex != NULL) SignDoc_throw (ex);
18061     if (r == NULL)
18062       return NULL;
18063     try
18064       {
18065         return new SignDocDocumentHandler (r);
18066       }
18067     catch (...)
18068       {
18069         SIGNDOC_DocumentHandler_delete (r);
18070         throw;
18071       }
18072   }
18073 
18074 private:
18079   SignDocPdfDocumentHandler ();
18080 
18085   SignDocPdfDocumentHandler (const SIGNDOC_PdfDocumentHandler &);
18086 
18091   SignDocPdfDocumentHandler& operator= (const SIGNDOC_PdfDocumentHandler &);
18092 };
18093 
18097 class SignDocTiffDocumentHandler : public SignDocDocumentHandler
18098 {
18099 public:
18100 
18106   static SignDocDocumentHandler *create ()
18107   {
18108     SIGNDOC_Exception *ex = NULL;
18109     SIGNDOC_DocumentHandler *r;
18110     r = SIGNDOC_TiffDocumentHandler_new (&ex);
18111     if (ex != NULL) SignDoc_throw (ex);
18112     if (r == NULL)
18113       return NULL;
18114     try
18115       {
18116         return new SignDocDocumentHandler (r);
18117       }
18118     catch (...)
18119       {
18120         SIGNDOC_DocumentHandler_delete (r);
18121         throw;
18122       }
18123   }
18124 
18125 private:
18130   SignDocTiffDocumentHandler ();
18131 
18136   SignDocTiffDocumentHandler (const SIGNDOC_TiffDocumentHandler &);
18137 
18142   SignDocTiffDocumentHandler& operator= (const SIGNDOC_TiffDocumentHandler &);
18143 };
18144 
18145 inline SignDocVerificationResult *
18146 makeSignDocVerificationResult (SIGNDOC_VerificationResult *aP)
18147 {
18148   if (aP == NULL)
18149     return NULL;
18150   return new SignDocVerificationResult (aP);
18151 }
18152 
18153 #ifdef _MSC_VER
18154 #pragma warning(pop)
18155 #endif
18156 
18157 }}}
18158 
18159 #endif