SignDocSDK-cpp.h

Go to the documentation of this file.
00001 /*=============================================== -*- C++ -*- ==*
00002  * SOFTPRO SignDoc                                              *
00003  *                                                              *
00004  * Copyright Kofax Deutschland AG                               *
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 SignDocChange;
00051 class SignDocSignature;
00052 class SignDocVerificationResult;
00053 class SignECDSA;
00054 class SignPKCS7;
00055 class SignRSA;
00056 
00057 #ifdef _MSC_VER
00058 #pragma warning(push)
00059 // C4800: forcing value to bool 'true' or 'false' (performance warning)
00060 #pragma warning(disable:4800)
00061 #endif
00062 
00067 inline void
00068 SignDoc_throw (SIGNDOC_Exception *aEx)
00069 {
00070   int type = SIGNDOC_Exception_getType (aEx);
00071   if (type == SIGNDOC_EXCEPTION_TYPE_BAD_ALLOC)
00072     throw (std::bad_alloc ());
00073   std::string msg;
00074   const char *text = SIGNDOC_Exception_getText (aEx);
00075   if (text != NULL)
00076     msg = text;
00077   SIGNDOC_Exception_delete (aEx);
00078 #if defined (SPOOC_EXCEPTION_H__) || defined (SPOOC_EXCEPTION_H_INCLUDED_)
00079   switch (type)
00080     {
00081     case SIGNDOC_EXCEPTION_TYPE_SPOOC_IO:
00082       throw spooc::IOError (msg);
00083     case SIGNDOC_EXCEPTION_TYPE_SPOOC_ENCODING_ERROR:
00084       throw spooc::EncodingError (msg);
00085     case SIGNDOC_EXCEPTION_TYPE_SPOOC_GENERIC:
00086       throw spooc::Exception (msg);
00087     case SIGNDOC_EXCEPTION_TYPE_INVALID_ARGUMENT:
00088       throw std::invalid_argument (msg);
00089     default:
00090       throw std::runtime_error (msg);
00091     }
00092 #else
00093   if (type == SIGNDOC_EXCEPTION_TYPE_INVALID_ARGUMENT)
00094     throw std::invalid_argument (msg);
00095   else
00096     throw std::runtime_error (msg);
00097 #endif
00098 }
00099 
00104 inline void
00105 SIGNDOC_catch (SIGNDOC_Exception **aEx, std::exception &aInput)
00106 {
00107   *aEx = SIGNDOC_Exception_new (SIGNDOC_EXCEPTION_TYPE_GENERIC,
00108                                 aInput.what ());
00109 }
00110 
00115 inline SignDocVerificationResult *
00116 makeSignDocVerificationResult (SIGNDOC_VerificationResult *aP);
00117 
00118 inline void assignArray (std::vector<unsigned char> &aDst,
00119                          SIGNDOC_ByteArray *aSrc)
00120 {
00121   unsigned n = 0;
00122   if (aSrc != NULL)
00123     n = SIGNDOC_ByteArray_count (aSrc);
00124   if (n == 0)
00125     aDst.clear ();
00126   else
00127     {
00128       const unsigned char *p = SIGNDOC_ByteArray_data (aSrc);
00129       aDst.assign (p, p + n);
00130     }
00131 }
00132 
00137 inline void assignArray (std::vector<std::vector<unsigned char> > &aDst,
00138                          SIGNDOC_ByteArrayArray *aSrc)
00139 {
00140   unsigned n = SIGNDOC_ByteArrayArray_count (aSrc);
00141   aDst.resize (n);
00142   for (unsigned i = 0; i < n; ++i)
00143     assignArray (aDst[i], SIGNDOC_ByteArrayArray_at (aSrc, i));
00144 }
00145 
00150 inline void assignArray (std::vector<std::string> &aDst,
00151                          SIGNDOC_StringArray *aSrc)
00152 {
00153   unsigned n = SIGNDOC_StringArray_count (aSrc);
00154   aDst.resize (n);
00155   for (unsigned i = 0; i < n; ++i)
00156     aDst[i] = SIGNDOC_StringArray_at (aSrc, i);
00157 }
00158 
00159 //----------------------------------------------------------------------------
00160 
00168 class InputStream
00169 {
00170 public:
00176   InputStream (SIGNDOC_InputStream *aImpl) : p (aImpl) { }
00177 
00181   virtual ~InputStream ()
00182   {
00183     SIGNDOC_InputStream_delete (p);
00184   }
00185 
00201   virtual int read (void *aDst, int aLen) = 0;
00202 
00209   virtual void close () = 0;
00210 
00219   virtual void seek (int aPos) = 0;
00220 
00229   virtual int tell () const = 0;
00230 
00243   virtual int getAvailable () = 0;
00244 
00249   SIGNDOC_InputStream *getImpl () { return p; }
00250 
00251 protected:
00255   SIGNDOC_InputStream *p;
00256 
00257 private:
00261   InputStream (const InputStream &);
00262 
00266   InputStream &operator= (const InputStream &);
00267 };
00268 
00274 class UserInputStream : public InputStream
00275 {
00276 public:
00280   UserInputStream ()
00281     : InputStream (NULL)
00282   {
00283     SIGNDOC_Exception *ex = NULL;
00284     p = SIGNDOC_UserInputStream_new (&ex, this,
00285                                      closeC, readC, seekC, tellC,
00286                                      getAvailableC);
00287     if (ex != NULL) SignDoc_throw (ex);
00288   }
00289 
00290 private:
00294   static void SDCAPI closeC (SIGNDOC_Exception **aEx,
00295                              void *aClosure)
00296   {
00297     *aEx = NULL;
00298     try
00299       {
00300         reinterpret_cast<UserInputStream*>(aClosure)->close ();
00301       }
00302     catch (std::exception &e)
00303       {
00304         SIGNDOC_catch (aEx, e);
00305       }
00306   }
00307 
00311   static int SDCAPI readC (SIGNDOC_Exception **aEx,
00312                            void *aClosure,
00313                            void *aDst, int aLen)
00314   {
00315     *aEx = NULL;
00316     try
00317       {
00318         return reinterpret_cast<UserInputStream*>(aClosure)->read (aDst, aLen);
00319       }
00320     catch (std::exception &e)
00321       {
00322         SIGNDOC_catch (aEx, e);
00323         return 0;
00324       }
00325   }
00326 
00330   static void SDCAPI seekC (SIGNDOC_Exception **aEx,
00331                             void *aClosure,
00332                             int aPos)
00333   {
00334     *aEx = NULL;
00335     try
00336       {
00337         return reinterpret_cast<UserInputStream*>(aClosure)->seek (aPos);
00338       }
00339     catch (std::exception &e)
00340       {
00341         SIGNDOC_catch (aEx, e);
00342       }
00343   }
00344 
00348   static int SDCAPI tellC (SIGNDOC_Exception **aEx,
00349                            const void *aClosure)
00350   {
00351     *aEx = NULL;
00352     try
00353       {
00354         return reinterpret_cast<const UserInputStream*>(aClosure)->tell ();
00355       }
00356     catch (std::exception &e)
00357       {
00358         SIGNDOC_catch (aEx, e);
00359         return 0;
00360       }
00361   }
00362 
00366   static int SDCAPI getAvailableC (SIGNDOC_Exception **aEx,
00367                                    void *aClosure)
00368   {
00369     *aEx = NULL;
00370     try
00371       {
00372         return reinterpret_cast<UserInputStream*>(aClosure)->getAvailable ();
00373       }
00374     catch (std::exception &e)
00375       {
00376         SIGNDOC_catch (aEx, e);
00377         return 0;
00378       }
00379   }
00380 };
00381 
00385 class LibraryInputStream : public InputStream
00386 {
00387 public:
00393   LibraryInputStream (SIGNDOC_InputStream *aImpl)
00394     : InputStream (aImpl) { }
00395 
00396   virtual int read (void *aDst, int aLen)
00397   {
00398     SIGNDOC_Exception *ex = NULL;
00399     int r = SIGNDOC_InputStream_read (&ex, p, aDst, aLen);
00400     if (ex != NULL) SignDoc_throw (ex);
00401     return r;
00402   }
00403 
00404   virtual void close ()
00405   {
00406     SIGNDOC_Exception *ex = NULL;
00407     SIGNDOC_InputStream_close (&ex, p);
00408     if (ex != NULL) SignDoc_throw (ex);
00409   }
00410 
00411   virtual void seek (int aPos)
00412   {
00413     SIGNDOC_Exception *ex = NULL;
00414     SIGNDOC_InputStream_seek (&ex, p, aPos);
00415     if (ex != NULL) SignDoc_throw (ex);
00416   }
00417 
00418   virtual int tell () const
00419   {
00420     SIGNDOC_Exception *ex = NULL;
00421     int r = SIGNDOC_InputStream_tell (&ex, p);
00422     if (ex != NULL) SignDoc_throw (ex);
00423     return r;
00424   }
00425 
00426   virtual int getAvailable ()
00427   {
00428     SIGNDOC_Exception *ex = NULL;
00429     int r = SIGNDOC_InputStream_getAvailable (&ex, p);
00430     if (ex != NULL) SignDoc_throw (ex);
00431     return r;
00432   }
00433 };
00434 
00435 #if defined (SPOOC_INPUTSTREAM_H__) || defined (SPOOC_INPUTSTREAM_H_INCLUDED_)
00436 
00437 class Spooc1InputStream : public spooc::InputStream
00438 {
00439 public:
00440   Spooc1InputStream (de::softpro::doc::InputStream &aStream)
00441      : mStream (aStream) { }
00442   virtual int read (void *aDst, int aLen) { return mStream.read (aDst, aLen); }
00443   virtual void close () { mStream.close (); }
00444   virtual void seek (int aPos) { mStream.seek (aPos); }
00445   virtual int tell () const { return mStream.tell (); }
00446   virtual int avail () { return mStream.getAvailable (); }
00447 private:
00448   de::softpro::doc::InputStream &mStream;
00449 };
00450 
00451 class Spooc2InputStream : public UserInputStream
00452 {
00453 public:
00454   Spooc2InputStream (spooc::InputStream &aStream)
00455      : mStream (aStream) { }
00456   virtual int read (void *aDst, int aLen) { return mStream.read (aDst, aLen); }
00457   virtual void close () { mStream.close (); }
00458   virtual void seek (int aPos) { mStream.seek (aPos); }
00459   virtual int tell () const { return mStream.tell (); }
00460   virtual int getAvailable () { return mStream.avail (); }
00461 private:
00462   spooc::InputStream &mStream;
00463 };
00464 
00465 #endif
00466 
00467 //----------------------------------------------------------------------------
00468 
00475 class FileInputStream : public LibraryInputStream
00476 {
00477 public:
00483   FileInputStream (FILE *aFile)
00484     : LibraryInputStream (NULL)
00485   {
00486     SIGNDOC_Exception *ex = NULL;
00487     p = SIGNDOC_FileInputStream_newWithFile (&ex, aFile);
00488     if (ex != NULL) SignDoc_throw (ex);
00489   };
00490 
00498   FileInputStream (FILE *aFile, const char *aPath)
00499     : LibraryInputStream (NULL)
00500   {
00501     SIGNDOC_Exception *ex = NULL;
00502     p = SIGNDOC_FileInputStream_newWithFileAndPath (&ex, aFile, aPath);
00503     if (ex != NULL) SignDoc_throw (ex);
00504   };
00505 
00513   FileInputStream (const char *aPath)
00514     : LibraryInputStream (NULL)
00515   {
00516     SIGNDOC_Exception *ex = NULL;
00517     p = SIGNDOC_FileInputStream_newWithPath (&ex, aPath);
00518     if (ex != NULL) SignDoc_throw (ex);
00519   };
00520 
00528   FileInputStream (const wchar_t *aPath)
00529     : LibraryInputStream (NULL)
00530   {
00531     SIGNDOC_Exception *ex = NULL;
00532     p = SIGNDOC_FileInputStream_newWithPathW (&ex, aPath);
00533     if (ex != NULL) SignDoc_throw (ex);
00534   };
00535 };
00536 
00537 //----------------------------------------------------------------------------
00538 
00542 class MemoryInputStream : public LibraryInputStream
00543 {
00544 public:
00555   MemoryInputStream (const unsigned char *aSrc, size_t aLen)
00556     : LibraryInputStream (NULL)
00557   {
00558     SIGNDOC_Exception *ex = NULL;
00559     p = SIGNDOC_MemoryInputStream_new (&ex, aSrc, aLen);
00560     if (ex != NULL) SignDoc_throw (ex);
00561   };
00562 };
00563 
00564 //----------------------------------------------------------------------------
00565 
00573 class OutputStream
00574 {
00575 public:
00581   OutputStream (SIGNDOC_OutputStream *aImpl) : p (aImpl) { }
00582 
00586   virtual ~OutputStream ()
00587   {
00588     SIGNDOC_OutputStream_delete (p);
00589   }
00590 
00602   virtual void close () = 0;
00603 
00612   virtual void flush () = 0;
00613 
00622   virtual void seek (int aPos) = 0;
00623 
00632   virtual int tell () const = 0;
00633 
00642   virtual void write (const void *aSrc, int aLen) = 0;
00643 
00648   SIGNDOC_OutputStream *getImpl () { return p; }
00649 
00650 protected:
00654   SIGNDOC_OutputStream *p;
00655 
00656 private:
00660   OutputStream (const OutputStream &);
00661 
00665   OutputStream &operator= (const OutputStream &);
00666 };
00667 
00673 class UserOutputStream : public OutputStream
00674 {
00675 public:
00679   UserOutputStream ()
00680     : OutputStream (NULL)
00681   {
00682     SIGNDOC_Exception *ex = NULL;
00683     p = SIGNDOC_UserOutputStream_new (&ex, this,
00684                                       closeC, flushC, writeC, seekC,
00685                                       tellC);
00686     if (ex != NULL) SignDoc_throw (ex);
00687   }
00688 
00689 private:
00693   static void SDCAPI closeC (SIGNDOC_Exception **aEx,
00694                              void *aClosure)
00695   {
00696     *aEx = NULL;
00697     try
00698       {
00699         reinterpret_cast<UserOutputStream*>(aClosure)->close ();
00700       }
00701     catch (std::exception &e)
00702       {
00703         SIGNDOC_catch (aEx, e);
00704       }
00705   }
00706 
00710   static void SDCAPI flushC (SIGNDOC_Exception **aEx,
00711                              void *aClosure)
00712   {
00713     *aEx = NULL;
00714     try
00715       {
00716         reinterpret_cast<UserOutputStream*>(aClosure)->flush ();
00717       }
00718     catch (std::exception &e)
00719       {
00720         SIGNDOC_catch (aEx, e);
00721       }
00722   }
00723 
00727   static void SDCAPI writeC (SIGNDOC_Exception **aEx,
00728                              void *aClosure,
00729                              const void *aSrc, int aLen)
00730   {
00731     *aEx = NULL;
00732     try
00733       {
00734         reinterpret_cast<UserOutputStream*>(aClosure)->write (aSrc, aLen);
00735       }
00736     catch (std::exception &e)
00737       {
00738         SIGNDOC_catch (aEx, e);
00739       }
00740   }
00741 
00745   static void SDCAPI seekC (SIGNDOC_Exception **aEx,
00746                             void *aClosure,
00747                             int aPos)
00748   {
00749     *aEx = NULL;
00750     try
00751       {
00752         return reinterpret_cast<UserOutputStream*>(aClosure)->seek (aPos);
00753       }
00754     catch (std::exception &e)
00755       {
00756         SIGNDOC_catch (aEx, e);
00757       }
00758   }
00759 
00763   static int SDCAPI tellC (SIGNDOC_Exception **aEx,
00764                            const void *aClosure)
00765   {
00766     *aEx = NULL;
00767     try
00768       {
00769         return reinterpret_cast<const UserOutputStream*>(aClosure)->tell ();
00770       }
00771     catch (std::exception &e)
00772       {
00773         SIGNDOC_catch (aEx, e);
00774         return 0;
00775       }
00776   }
00777 };
00778 
00782 class LibraryOutputStream : public OutputStream
00783 {
00784 public:
00790   LibraryOutputStream (SIGNDOC_OutputStream *aImpl)
00791     : OutputStream (aImpl) { }
00792 
00793   virtual void close ()
00794   {
00795     SIGNDOC_Exception *ex = NULL;
00796     SIGNDOC_OutputStream_close (&ex, p);
00797     if (ex != NULL) SignDoc_throw (ex);
00798   }
00799 
00800   virtual void flush ()
00801   {
00802     SIGNDOC_Exception *ex = NULL;
00803     SIGNDOC_OutputStream_flush (&ex, p);
00804     if (ex != NULL) SignDoc_throw (ex);
00805   }
00806 
00807   virtual void write (const void *aSrc, int aLen)
00808   {
00809     SIGNDOC_Exception *ex = NULL;
00810     SIGNDOC_OutputStream_write (&ex, p, aSrc, aLen);
00811     if (ex != NULL) SignDoc_throw (ex);
00812   }
00813 
00814   virtual void seek (int aPos)
00815   {
00816     SIGNDOC_Exception *ex = NULL;
00817     SIGNDOC_OutputStream_seek (&ex, p, aPos);
00818     if (ex != NULL) SignDoc_throw (ex);
00819   }
00820 
00821   virtual int tell () const
00822   {
00823     SIGNDOC_Exception *ex = NULL;
00824     int r = SIGNDOC_OutputStream_tell (&ex, p);
00825     if (ex != NULL) SignDoc_throw (ex);
00826     return r;
00827   }
00828 };
00829 
00830 #if defined (SPOOC_OUTPUTSTREAM_H__) || defined (SPOOC_OUTPUTSTREAM_H_INCLUDED_)
00831 
00832 class Spooc1OutputStream : public spooc::OutputStream
00833 {
00834 public:
00835   Spooc1OutputStream (de::softpro::doc::OutputStream &aStream)
00836     : mStream (aStream) { }
00837   virtual void close () { mStream.close (); }
00838   virtual void flush () { mStream.flush (); }
00839   virtual void write (const void *aSrc, int aLen) { mStream.write (aSrc, aLen); }
00840   virtual void seek (int aPos) { mStream.seek (aPos); }
00841   virtual int tell () const { return mStream.tell (); }
00842 private:
00843   de::softpro::doc::OutputStream &mStream;
00844 };
00845 
00846 class Spooc2OutputStream : public UserOutputStream
00847 {
00848 public:
00849   Spooc2OutputStream (spooc::OutputStream &aStream)
00850     : mStream (aStream) { }
00851   ~Spooc2OutputStream () { }
00852   virtual void close () { mStream.close (); }
00853   virtual void flush () { mStream.flush (); }
00854   virtual void write (const void *aSrc, int aLen) { mStream.write (aSrc, aLen); }
00855   virtual void seek (int aPos) { mStream.seek (aPos); }
00856   virtual int tell () const { return mStream.tell (); }
00857 private:
00858   spooc::OutputStream &mStream;
00859 };
00860 
00861 #endif
00862 
00863 //----------------------------------------------------------------------------
00864 
00871 class FileOutputStream : public LibraryOutputStream
00872 {
00873 public:
00879   FileOutputStream (FILE *aFile)
00880     : LibraryOutputStream (NULL)
00881   {
00882     SIGNDOC_Exception *ex = NULL;
00883     p = SIGNDOC_FileOutputStream_newWithFile (&ex, aFile);
00884     if (ex != NULL) SignDoc_throw (ex);
00885   };
00886 
00894   FileOutputStream (FILE *aFile, const char *aPath)
00895     : LibraryOutputStream (NULL)
00896   {
00897     SIGNDOC_Exception *ex = NULL;
00898     p = SIGNDOC_FileOutputStream_newWithFileAndPath (&ex, aFile, aPath);
00899     if (ex != NULL) SignDoc_throw (ex);
00900   };
00901 
00910   FileOutputStream (const char *aPath)
00911     : LibraryOutputStream (NULL)
00912   {
00913     SIGNDOC_Exception *ex = NULL;
00914     p = SIGNDOC_FileOutputStream_newWithPath (&ex, aPath);
00915     if (ex != NULL) SignDoc_throw (ex);
00916   };
00917 
00926   FileOutputStream (const wchar_t *aPath)
00927     : LibraryOutputStream (NULL)
00928   {
00929     SIGNDOC_Exception *ex = NULL;
00930     p = SIGNDOC_FileOutputStream_newWithPathW (&ex, aPath);
00931     if (ex != NULL) SignDoc_throw (ex);
00932   };
00933 };
00934 
00935 //----------------------------------------------------------------------------
00936 
00941 class MemoryOutputStream : public LibraryOutputStream
00942 {
00943 public:
00947   MemoryOutputStream ()
00948     : LibraryOutputStream (NULL)
00949   {
00950     SIGNDOC_Exception *ex = NULL;
00951     p = SIGNDOC_MemoryOutputStream_new (&ex);
00952     if (ex != NULL) SignDoc_throw (ex);
00953   };
00954 
00963   const unsigned char *data ()
00964   {
00965     SIGNDOC_Exception *ex = NULL;
00966     const unsigned char *r = SIGNDOC_MemoryOutputStream_data (&ex, p);
00967     if (ex != NULL) SignDoc_throw (ex);
00968     return r;
00969   }
00970 
00974   size_t length ()
00975   {
00976     SIGNDOC_Exception *ex = NULL;
00977     size_t r = SIGNDOC_MemoryOutputStream_length (&ex, p);
00978     if (ex != NULL) SignDoc_throw (ex);
00979     return r;
00980   }
00981 
00989   void clear ()
00990   {
00991     SIGNDOC_Exception *ex = NULL;
00992     SIGNDOC_MemoryOutputStream_clear (&ex, p);
00993     if (ex != NULL) SignDoc_throw (ex);
00994   }
00995 };
00999 enum Encoding
01000 {
01001   enc_native,      
01002   enc_utf_8,       
01003   enc_latin_1      
01004 };
01005 
01009 // cppcheck-suppress copyCtorAndEqOperator
01010 class Point 
01011 {
01012 public:
01018   Point ()
01019     : mX (0), mY (0)
01020   {
01021   }
01022 
01029   Point (double aX, double aY)
01030     : mX (aX), mY (aY)
01031   {
01032   }
01033 
01039   Point (const Point &aSrc)
01040     : mX (aSrc.mX), mY (aSrc.mY)
01041   {
01042   }
01043 
01047   ~Point ()
01048   {
01049   }
01050 
01057   void set (double aX, double aY)
01058   {
01059     SIGNDOC_Point_setXY ((SIGNDOC_Point*)this, aX, aY);
01060   }
01061 
01062 public:
01066   double mX;
01067 
01071   double mY;
01072 };
01073 
01080 // cppcheck-suppress copyCtorAndEqOperator
01081 class Rect 
01082 {
01083 public:
01089   Rect ()
01090     : mX1 (0), mY1 (0), mX2 (0), mY2 (0)
01091   {
01092   }
01093 
01102   Rect (double aX1, double aY1, double aX2, double aY2)
01103     : mX1 (aX1), mY1 (aY1), mX2 (aX2), mY2 (aY2)
01104   {
01105   }
01106 
01112   Rect (const Rect &aSrc)
01113     : mX1 (aSrc.mX1), mY1 (aSrc.mY1), mX2 (aSrc.mX2), mY2 (aSrc.mY2)
01114   {
01115   }
01116 
01120   ~Rect ()
01121   {
01122   }
01123 
01132   void get (double &aX1, double &aY1, double &aX2, double &aY2) const
01133   {
01134     SIGNDOC_Rect_get ((const SIGNDOC_Rect*)this, &aX1, &aY1, &aX2, &aY2);
01135   }
01136 
01145   void set (double aX1, double aY1, double aX2, double aY2)
01146   {
01147     SIGNDOC_Rect_setXY ((SIGNDOC_Rect*)this, aX1, aY1, aX2, aY2);
01148   }
01149 
01155   double getWidth () const
01156   {
01157     return SIGNDOC_Rect_getWidth ((const SIGNDOC_Rect*)this);
01158   }
01159 
01165   double getHeight () const
01166   {
01167     return SIGNDOC_Rect_getHeight ((const SIGNDOC_Rect*)this);
01168   }
01169 
01177   void normalize ()
01178   {
01179     SIGNDOC_Rect_normalize ((SIGNDOC_Rect*)this);
01180   }
01181 
01187   void scale (double aFactor)
01188   {
01189     SIGNDOC_Rect_scale ((SIGNDOC_Rect*)this, aFactor);
01190   }
01191 
01200   void scale (double aFactorX, double aFactorY)
01201   {
01202     SIGNDOC_Rect_scaleXY ((SIGNDOC_Rect*)this, aFactorX, aFactorY);
01203   }
01204 
01211   double getX1 () const
01212   {
01213     return mX1;
01214   }
01215 
01222   double getY1 () const
01223   {
01224     return mY1;
01225   }
01226 
01233   double getX2 () const
01234   {
01235     return mX2;
01236   }
01237 
01244   double getY2 () const
01245   {
01246     return mY2;
01247   }
01248 
01249 public:
01253   double mX1;
01254 
01258   double mY1;
01259 
01263   double mX2;
01264 
01268   double mY2;
01269 };
01270 
01274 class TimeStamper 
01275 {
01276 public:
01280   enum StampResult
01281   {
01285     sr_ok,
01286 
01290     sr_invalid_input,
01291 
01295     sr_timeout,
01296 
01300     sr_stopped,
01301 
01305     sr_tcp_error,
01306 
01310     sr_ssl_error,
01311 
01315     sr_http_error,
01316 
01321     sr_server_error,
01322 
01326     sr_invalid_response
01327   };
01328 
01332   enum StampFlags
01333   {
01339     sf_dont_check_revocation = 0x01,
01340 
01344     sf_dont_hash = 0x02
01345   };
01346 
01347 public:
01354   const char *getHashAlgorithm () const
01355   {
01356     return SIGNDOC_TimeStamper_getHashAlgorithm (p);
01357   }
01358 
01365   const char *getFallbackHashAlgorithm () const
01366   {
01367     return SIGNDOC_TimeStamper_getFallbackHashAlgorithm (p);
01368   }
01369 
01401   StampResult stamp (const unsigned char *aHashPtr, size_t aHashSize,
01402                      unsigned aRandomNonceSize, int aFlags,
01403                      std::vector<unsigned char> &aOutput, int &aStatus,
01404                      unsigned &aFailureInfo)
01405   {
01406     SIGNDOC_Exception *ex = NULL;
01407     SIGNDOC_ByteArray *tempOutput = NULL;
01408     StampResult r;
01409     try
01410       {
01411         tempOutput = SIGNDOC_ByteArray_new (&ex);
01412         if (ex != NULL) SignDoc_throw (ex);
01413         r = (StampResult)SIGNDOC_TimeStamper_stamp (&ex, p, aHashPtr, aHashSize, aRandomNonceSize, aFlags, tempOutput, &aStatus, &aFailureInfo);
01414         assignArray (aOutput, tempOutput);
01415       }
01416     catch (...)
01417       {
01418         if (tempOutput != NULL)
01419           SIGNDOC_ByteArray_delete (tempOutput);
01420         throw;
01421       }
01422     if (tempOutput != NULL)
01423       SIGNDOC_ByteArray_delete (tempOutput);
01424     if (ex != NULL) SignDoc_throw (ex);
01425     return r;
01426   }
01427 
01434   void stop ()
01435   {
01436     SIGNDOC_TimeStamper_stop (p);
01437   }
01438 
01449   const char *getErrorMessage () const
01450   {
01451     return SIGNDOC_TimeStamper_getErrorMessage (p);
01452   }
01453 
01454 protected:
01455 public:
01459   ~TimeStamper ()
01460   {
01461   }
01466   TimeStamper (SIGNDOC_TimeStamper *aP) : p (aP) { }
01467 
01472   SIGNDOC_TimeStamper *getImpl () { return p; }
01473 
01478   const SIGNDOC_TimeStamper *getImpl () const { return p; }
01479 
01480 private:
01481   SIGNDOC_TimeStamper *p;
01482 };
01483 
01489 class Source
01490 {
01491 public:
01497   Source (struct SIGNDOC_Source *aImpl)
01498     : p (aImpl) { }
01499 
01503   virtual ~Source () { }
01504 
01515   int fetch (const void *&aPtr, int aMaxSize)
01516   {
01517     struct SIGNDOC_Exception *ex = NULL;
01518     int r = SIGNDOC_Source_fetch (&ex, p, &aPtr, aMaxSize);
01519     if (ex != NULL) SignDoc_throw (ex);
01520     return r;
01521   }
01522 
01523 private:
01524   SIGNDOC_Source *p;
01525 };
01526 
01535 class SignPKCS7
01536 {
01537 public:
01541   enum HashAlgorithm
01542   {
01543     ha_none,                    
01544     ha_sha1,                    
01545     ha_sha256,                  
01546     ha_md5,                     
01547     ha_sha384,                  
01548     ha_sha512,                  
01549     ha_ripemd160,               
01550     ha_sha224                   
01551   };
01552 
01556   SignPKCS7 ()
01557     : p (NULL), mBadAlloc (false)
01558   {
01559     struct SIGNDOC_Exception *ex = NULL;
01560     p = SIGNDOC_SignPKCS7_new (&ex, this, signC, getSignatureSizeC,
01561                                getSubjectCommonNameC, getErrorMessageC);
01562     if (ex != NULL) SignDoc_throw (ex);
01563   }
01564 
01571   virtual ~SignPKCS7 ()
01572   {
01573     SIGNDOC_SignPKCS7_delete (p);
01574   }
01575 
01597   virtual bool sign (Source &aSource, bool aDetached,
01598                      HashAlgorithm aHashAlgorithm,
01599                      TimeStamper *aTimeStamper,
01600                      std::vector<unsigned char> &aOutput) = 0;
01601 
01622   virtual size_t getSignatureSize (bool aDetached,
01623                                    HashAlgorithm aHashAlgorithm) = 0;
01624 
01634   virtual bool getSubjectCommonName (std::string &aOutput) const = 0;
01635 
01650   virtual const char *getErrorMessage () const = 0;
01651 
01656   SIGNDOC_SignPKCS7 *getImpl () { return p; }
01657 
01658 private:
01659   static SIGNDOC_Boolean SDCAPI
01660   signC (void *aClosure, struct SIGNDOC_Source *aSource,
01661          SIGNDOC_Boolean aDetached, int aHashAlgorithm,
01662          struct SIGNDOC_TimeStamper *aTimeStamper,
01663          struct SIGNDOC_ByteArray *aOutput)
01664   {
01665     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01666     s->mBadAlloc = false;
01667     try
01668       {
01669         SIGNDOC_ByteArray_clear (aOutput);
01670         std::vector<unsigned char> output;
01671         Source src (aSource);
01672         TimeStamper ts (aTimeStamper);
01673         bool ok = s->sign (src, aDetached, (HashAlgorithm)aHashAlgorithm,
01674                            (aTimeStamper != NULL) ? &ts : NULL,
01675                            output);
01676         if (ok)
01677           assignByteArray (aOutput, output);
01678         return ok;
01679       }
01680     catch (std::bad_alloc &)
01681       {
01682         s->mBadAlloc = true;
01683         return SIGNDOC_FALSE;
01684       }
01685   }
01686 
01687   static size_t SDCAPI
01688   getSignatureSizeC (void *aClosure, SIGNDOC_Boolean aDetached,
01689                      int aHashAlgorithm)
01690   {
01691     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01692     s->mBadAlloc = false;
01693     try
01694       {
01695         return s->getSignatureSize (aDetached, (HashAlgorithm)aHashAlgorithm);
01696       }
01697     catch (std::bad_alloc &)
01698       {
01699         s->mBadAlloc = true;
01700         return 0;
01701       }
01702   }
01703 
01704   static SIGNDOC_Boolean SDCAPI
01705   getSubjectCommonNameC (void *aClosure, char **aOutput)
01706   {
01707     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01708     s->mBadAlloc = false;
01709     try
01710       {
01711         *aOutput = NULL;
01712         std::string output;
01713         bool ok = s->getSubjectCommonName (output);
01714         if (ok)
01715           assignString (aOutput, output);
01716         return ok;
01717       }
01718     catch (std::bad_alloc &)
01719       {
01720         s->mBadAlloc = true;
01721         return SIGNDOC_FALSE;
01722       }
01723   }
01724 
01725   static const char * SDCAPI
01726   getErrorMessageC (void *aClosure)
01727   {
01728     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01729     if (s->mBadAlloc)
01730       return "out of memory";
01731     try
01732       {
01733         return s->getErrorMessage ();
01734       }
01735     catch (std::bad_alloc &)
01736       {
01737         s->mBadAlloc = true;
01738         return "out of memory";
01739       }
01740   }
01741 
01742   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
01743                                const std::vector<unsigned char> &aInput)
01744   {
01745     if (aInput.empty ())
01746       SIGNDOC_ByteArray_clear (aOutput);
01747     else
01748       {
01749         struct SIGNDOC_Exception *ex = NULL;
01750         SIGNDOC_ByteArray_set (&ex, aOutput,
01751                                &aInput[0], aInput.size ());
01752         if (ex != NULL) SignDoc_throw (ex);
01753       }
01754   }
01755 
01756   static void assignString (char **aOutput, const std::string &aInput)
01757   {
01758     struct SIGNDOC_Exception *ex = NULL;
01759     *aOutput = SIGNDOC_strdup (&ex, aInput.c_str ());
01760     if (ex != NULL) SignDoc_throw (ex);
01761   }
01762 
01763 private:
01764   SIGNDOC_SignPKCS7 *p;
01765   bool mBadAlloc;
01766 };
01767 
01773 class SignRSA
01774 {
01775 public:
01779   enum Version
01780   {
01784     v_1_5,
01785 
01794     v_2_0_salt0,
01795 
01805     v_2_0_salt32,
01806 
01810     v_2_0 = v_2_0_salt0
01811   };
01812 
01816   enum HashAlgorithm
01817   {
01821     ha_sha1 = 1,
01822 
01826     ha_sha256 = 2,
01827 
01831     ha_sha384 = 3,
01832 
01836     ha_sha512 = 4,
01837 
01841     ha_ripemd160 = 5
01842   };
01843 
01844 public:
01848   SignRSA ()
01849     : p (NULL), mBadAlloc (false)
01850   {
01851     struct SIGNDOC_Exception *ex = NULL;
01852     p = SIGNDOC_SignRSA_new (&ex, this, signC, getSignatureSizeC,
01853                              getSigningCertificateC,
01854                              getCertificateCountC, getCertificateC,
01855                              getErrorMessageC);
01856     if (ex != NULL) SignDoc_throw (ex);
01857   }
01858 
01864   virtual ~SignRSA ()
01865   {
01866     SIGNDOC_SignRSA_delete (p);
01867   }
01868 
01883   virtual bool sign (Source &aSource,
01884                      Version aVersion, HashAlgorithm aHashAlgorithm,
01885                      std::vector<unsigned char> &aOutput) = 0;
01886 
01895   virtual int getSignatureSize () = 0;
01896 
01907   virtual bool getSigningCertificate (std::vector<unsigned char> &aOutput) const = 0;
01908 
01914   virtual int getCertificateCount () const = 0;
01915 
01928   virtual bool getCertificate (int aIndex,
01929                                std::vector<unsigned char> &aOutput) const = 0;
01930 
01943   virtual const char *getErrorMessage () const = 0;
01944 
01949   SIGNDOC_SignRSA *getImpl () { return p; }
01950 
01951 private:
01952   static SIGNDOC_Boolean SDCAPI
01953   signC (void *aClosure, struct SIGNDOC_Source *aSource,
01954          int aVersion, int aHashAlgorithm,
01955          struct SIGNDOC_ByteArray *aOutput)
01956   {
01957     SignRSA *s = static_cast<SignRSA*>(aClosure);
01958     s->mBadAlloc = false;
01959     try
01960       {
01961         std::vector<unsigned char> output;
01962         Source src (aSource);
01963         bool ok = s->sign (src, (Version)aVersion,
01964                            (HashAlgorithm)aHashAlgorithm, output);
01965         if (ok)
01966           assignByteArray (aOutput, output);
01967         return ok;
01968       }
01969     catch (std::bad_alloc &)
01970       {
01971         s->mBadAlloc = true;
01972         return SIGNDOC_FALSE;
01973       }
01974   }
01975 
01976   static int SDCAPI
01977   getSignatureSizeC (void *aClosure)
01978   {
01979     SignRSA *s = static_cast<SignRSA*>(aClosure);
01980     s->mBadAlloc = false;
01981     try
01982       {
01983         return s->getSignatureSize ();
01984       }
01985     catch (std::bad_alloc &)
01986       {
01987         s->mBadAlloc = true;
01988         return -1;
01989       }
01990   }
01991 
01992   static SIGNDOC_Boolean SDCAPI
01993   getSigningCertificateC (const void *aClosure,
01994                           struct SIGNDOC_ByteArray *aOutput)
01995   {
01996     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
01997     s->mBadAlloc = false;
01998     try
01999       {
02000         std::vector<unsigned char> output;
02001         bool ok = s->getSigningCertificate (output);
02002         if (ok)
02003           assignByteArray (aOutput, output);
02004         return ok;
02005       }
02006     catch (std::bad_alloc &)
02007       {
02008         s->mBadAlloc = true;
02009         return SIGNDOC_FALSE;
02010       }
02011   }
02012 
02013   static int SDCAPI
02014   getCertificateCountC (const void *aClosure)
02015   {
02016     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
02017     s->mBadAlloc = false;
02018     try
02019       {
02020         return s->getCertificateCount ();
02021       }
02022     catch (std::bad_alloc &)
02023       {
02024         s->mBadAlloc = true;
02025         return 0;
02026       }
02027   }
02028 
02029   static SIGNDOC_Boolean SDCAPI
02030   getCertificateC (const void *aClosure, int aIndex,
02031                    struct SIGNDOC_ByteArray *aOutput)
02032   {
02033     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
02034     s->mBadAlloc = false;
02035     try
02036       {
02037         std::vector<unsigned char> output;
02038         bool ok = s->getCertificate (aIndex, output);
02039         if (ok)
02040           assignByteArray (aOutput, output);
02041         return ok;
02042       }
02043     catch (std::bad_alloc &)
02044       {
02045         s->mBadAlloc = true;
02046         return SIGNDOC_FALSE;
02047       }
02048   }
02049 
02050   static const char * SDCAPI
02051   getErrorMessageC (const void *aClosure)
02052   {
02053     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
02054     if (s->mBadAlloc)
02055       return "out of memory";
02056     try
02057       {
02058         return s->getErrorMessage ();
02059       }
02060     catch (std::bad_alloc &)
02061       {
02062         s->mBadAlloc = true;
02063         return "out of memory";
02064       }
02065   }
02066 
02067   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
02068                                const std::vector<unsigned char> &aInput)
02069   {
02070     if (aInput.empty ())
02071       SIGNDOC_ByteArray_clear (aOutput);
02072     else
02073       {
02074         struct SIGNDOC_Exception *ex = NULL;
02075         SIGNDOC_ByteArray_set (&ex, aOutput,
02076                                &aInput[0], aInput.size ());
02077         if (ex != NULL) SignDoc_throw (ex);
02078       }
02079   }
02080 
02081 private:
02082   SIGNDOC_SignRSA *p;
02083   mutable bool mBadAlloc;
02084 };
02085 
02091 class SignECDSA
02092 {
02093 public:
02097   enum HashAlgorithm
02098   {
02102     ha_sha1 = 1,
02103 
02107     ha_sha256 = 2,
02108 
02112     ha_sha384 = 3,
02113 
02117     ha_sha512 = 4,
02118 
02122     ha_sha224 = 7
02123   };
02124 
02125 public:
02129   SignECDSA ()
02130     : p (NULL), mBadAlloc (false)
02131   {
02132     struct SIGNDOC_Exception *ex = NULL;
02133     p = SIGNDOC_SignECDSA_new (&ex, this, signC, getSignatureSizeC,
02134                                getSigningCertificateC,
02135                                getCertificateCountC, getCertificateC,
02136                                getErrorMessageC);
02137     if (ex != NULL) SignDoc_throw (ex);
02138   }
02139 
02145   virtual ~SignECDSA ()
02146   {
02147     SIGNDOC_SignECDSA_delete (p);
02148   }
02149 
02163   virtual bool sign (Source &aSource, HashAlgorithm aHashAlgorithm,
02164                      std::vector<unsigned char> &aOutput) = 0;
02165 
02173   virtual int getSignatureSize () = 0;
02174 
02185   virtual bool getSigningCertificate (std::vector<unsigned char> &aOutput) const = 0;
02186 
02192   virtual int getCertificateCount () const = 0;
02193 
02206   virtual bool getCertificate (int aIndex,
02207                                std::vector<unsigned char> &aOutput) const = 0;
02208 
02221   virtual const char *getErrorMessage () const = 0;
02222 
02227   SIGNDOC_SignECDSA *getImpl () { return p; }
02228 
02229 private:
02230   static SIGNDOC_Boolean SDCAPI
02231   signC (void *aClosure, struct SIGNDOC_Source *aSource, int aHashAlgorithm,
02232          struct SIGNDOC_ByteArray *aOutput)
02233   {
02234     SignECDSA *s = static_cast<SignECDSA*>(aClosure);
02235     s->mBadAlloc = false;
02236     try
02237       {
02238         std::vector<unsigned char> output;
02239         Source src (aSource);
02240         bool ok = s->sign (src, (HashAlgorithm)aHashAlgorithm, output);
02241         if (ok)
02242           assignByteArray (aOutput, output);
02243         return ok;
02244       }
02245     catch (std::bad_alloc &)
02246       {
02247         s->mBadAlloc = true;
02248         return SIGNDOC_FALSE;
02249       }
02250   }
02251 
02252   static int SDCAPI
02253   getSignatureSizeC (void *aClosure)
02254   {
02255     SignECDSA *s = static_cast<SignECDSA*>(aClosure);
02256     s->mBadAlloc = false;
02257     try
02258       {
02259         return s->getSignatureSize ();
02260       }
02261     catch (std::bad_alloc &)
02262       {
02263         s->mBadAlloc = true;
02264         return -1;
02265       }
02266   }
02267 
02268   static SIGNDOC_Boolean SDCAPI
02269   getSigningCertificateC (const void *aClosure,
02270                           struct SIGNDOC_ByteArray *aOutput)
02271   {
02272     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02273     s->mBadAlloc = false;
02274     try
02275       {
02276         std::vector<unsigned char> output;
02277         bool ok = s->getSigningCertificate (output);
02278         if (ok)
02279           assignByteArray (aOutput, output);
02280         return ok;
02281       }
02282     catch (std::bad_alloc &)
02283       {
02284         s->mBadAlloc = true;
02285         return SIGNDOC_FALSE;
02286       }
02287   }
02288 
02289   static int SDCAPI
02290   getCertificateCountC (const void *aClosure)
02291   {
02292     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02293     s->mBadAlloc = false;
02294     try
02295       {
02296         return s->getCertificateCount ();
02297       }
02298     catch (std::bad_alloc &)
02299       {
02300         s->mBadAlloc = true;
02301         return 0;
02302       }
02303   }
02304 
02305   static SIGNDOC_Boolean SDCAPI
02306   getCertificateC (const void *aClosure, int aIndex,
02307                    struct SIGNDOC_ByteArray *aOutput)
02308   {
02309     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02310     s->mBadAlloc = false;
02311     try
02312       {
02313         std::vector<unsigned char> output;
02314         bool ok = s->getCertificate (aIndex, output);
02315         if (ok)
02316           assignByteArray (aOutput, output);
02317         return ok;
02318       }
02319     catch (std::bad_alloc &)
02320       {
02321         s->mBadAlloc = true;
02322         return SIGNDOC_FALSE;
02323       }
02324   }
02325 
02326   static const char * SDCAPI
02327   getErrorMessageC (const void *aClosure)
02328   {
02329     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02330     if (s->mBadAlloc)
02331       return "out of memory";
02332     try
02333       {
02334         return s->getErrorMessage ();
02335       }
02336     catch (std::bad_alloc &)
02337       {
02338         s->mBadAlloc = true;
02339         return "out of memory";
02340       }
02341   }
02342 
02343   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
02344                                const std::vector<unsigned char> &aInput)
02345   {
02346     if (aInput.empty ())
02347       SIGNDOC_ByteArray_clear (aOutput);
02348     else
02349       {
02350         struct SIGNDOC_Exception *ex = NULL;
02351         SIGNDOC_ByteArray_set (&ex, aOutput,
02352                                &aInput[0], aInput.size ());
02353         if (ex != NULL) SignDoc_throw (ex);
02354       }
02355   }
02356 
02357 private:
02358   SIGNDOC_SignECDSA *p;
02359   mutable bool mBadAlloc;
02360 };
02361 
02370 class SignDocColor 
02371 {
02372 public:
02373   enum Type
02374   {
02378     t_gray,
02379 
02383     t_rgb
02384   };
02385 
02386 public:
02390   ~SignDocColor ()
02391   {
02392     SIGNDOC_Color_delete (p);
02393   }
02394 
02400   SignDocColor *clone () const
02401   {
02402     SIGNDOC_Exception *ex = NULL;
02403     SIGNDOC_Color *r;
02404     r = SIGNDOC_Color_clone (&ex, p);
02405     if (ex != NULL) SignDoc_throw (ex);
02406     if (r == NULL)
02407       return NULL;
02408     try
02409       {
02410         return new SignDocColor (r);
02411       }
02412     catch (...)
02413       {
02414         SIGNDOC_Color_delete (r);
02415         throw;
02416       }
02417   }
02418 
02424   Type getType () const
02425   {
02426     return (Type)SIGNDOC_Color_getType (p);
02427   }
02428 
02434   unsigned getNumberOfComponents () const
02435   {
02436     return SIGNDOC_Color_getNumberOfComponents (p);
02437   }
02438 
02448   unsigned char getComponent (unsigned aIndex) const
02449   {
02450     return SIGNDOC_Color_getComponent (p, aIndex);
02451   }
02452 
02459   unsigned char getIntensity () const
02460   {
02461     return SIGNDOC_Color_getIntensity (p);
02462   }
02463 
02470   unsigned char getRed () const
02471   {
02472     return SIGNDOC_Color_getRed (p);
02473   }
02474 
02481   unsigned char getGreen () const
02482   {
02483     return SIGNDOC_Color_getGreen (p);
02484   }
02485 
02492   unsigned char getBlue () const
02493   {
02494     return SIGNDOC_Color_getBlue (p);
02495   }
02496 
02505   static SignDocColor *createGray (unsigned char aIntensity)
02506   {
02507     SIGNDOC_Exception *ex = NULL;
02508     SIGNDOC_Color *r;
02509     r = SIGNDOC_Color_createGray (&ex, aIntensity);
02510     if (ex != NULL) SignDoc_throw (ex);
02511     if (r == NULL)
02512       return NULL;
02513     try
02514       {
02515         return new SignDocColor (r);
02516       }
02517     catch (...)
02518       {
02519         SIGNDOC_Color_delete (r);
02520         throw;
02521       }
02522   }
02523 
02536   static SignDocColor *createRGB (unsigned char aRed, unsigned char aGreen,
02537                                   unsigned char aBlue)
02538   {
02539     SIGNDOC_Exception *ex = NULL;
02540     SIGNDOC_Color *r;
02541     r = SIGNDOC_Color_createRGB (&ex, aRed, aGreen, aBlue);
02542     if (ex != NULL) SignDoc_throw (ex);
02543     if (r == NULL)
02544       return NULL;
02545     try
02546       {
02547         return new SignDocColor (r);
02548       }
02549     catch (...)
02550       {
02551         SIGNDOC_Color_delete (r);
02552         throw;
02553       }
02554   }
02555 
02556 private:
02562   SignDocColor ();
02563 
02569   // cppcheck-suppress noExplicitCopyMoveConstructor
02570   SignDocColor (const SignDocColor &);
02571 
02577   SignDocColor &operator= (const SignDocColor &);
02578 
02579 public:
02584   SignDocColor (SIGNDOC_Color *aP) : p (aP) { }
02585 
02590   SIGNDOC_Color *getImpl () { return p; }
02591 
02596   const SIGNDOC_Color *getImpl () const { return p; }
02597 
02602   void setImpl (SIGNDOC_Color *aP) { SIGNDOC_Color_delete (p); p  = aP; }
02603 
02604 private:
02605   SIGNDOC_Color *p;
02606 };
02607 
02622 class SignDocTextFieldAttributes 
02623 {
02624 public:
02625 
02626 public:
02630   SignDocTextFieldAttributes ()
02631     : p (NULL)
02632   {
02633     SIGNDOC_Exception *ex = NULL;
02634     p = SIGNDOC_TextFieldAttributes_new (&ex);
02635     if (ex != NULL) SignDoc_throw (ex);
02636   }
02637 
02643   SignDocTextFieldAttributes (const SignDocTextFieldAttributes &aSource)
02644     : p (NULL)
02645   {
02646     SIGNDOC_Exception *ex = NULL;
02647     p = SIGNDOC_TextFieldAttributes_clone (&ex, aSource.getImpl ());
02648     if (ex != NULL) SignDoc_throw (ex);
02649   }
02650 
02654   ~SignDocTextFieldAttributes ()
02655   {
02656     SIGNDOC_TextFieldAttributes_delete (p);
02657   }
02658 
02664   SignDocTextFieldAttributes &operator= (const SignDocTextFieldAttributes &aSource)
02665   {
02666     SIGNDOC_Exception *ex = NULL;
02667     SIGNDOC_TextFieldAttributes_assign (&ex, p, aSource.getImpl ());
02668     if (ex != NULL) SignDoc_throw (ex);
02669     return *this;
02670   }
02671 
02677   void swap (SignDocTextFieldAttributes &aOther)
02678   {
02679     std::swap (p, aOther.p);
02680   }
02681 
02697   bool isSet () const
02698   {
02699     SIGNDOC_Exception *ex = NULL;
02700     bool r;
02701     r = (bool)SIGNDOC_TextFieldAttributes_isSet (&ex, p);
02702     if (ex != NULL) SignDoc_throw (ex);
02703     return r;
02704   }
02705 
02717   bool isValid () const
02718   {
02719     SIGNDOC_Exception *ex = NULL;
02720     bool r;
02721     r = (bool)SIGNDOC_TextFieldAttributes_isValid (&ex, p);
02722     if (ex != NULL) SignDoc_throw (ex);
02723     return r;
02724   }
02725 
02731   void clear ()
02732   {
02733     SIGNDOC_Exception *ex = NULL;
02734     SIGNDOC_TextFieldAttributes_clear (&ex, p);
02735     if (ex != NULL) SignDoc_throw (ex);
02736   }
02737 
02749   std::string getFontName (Encoding aEncoding) const
02750   {
02751     SIGNDOC_Exception *ex = NULL;
02752     std::string r;
02753     char *s = SIGNDOC_TextFieldAttributes_getFontName (&ex, p, aEncoding);
02754     if (ex != NULL) SignDoc_throw (ex);
02755     try
02756       {
02757         r = s;
02758       }
02759     catch (...)
02760       {
02761         SIGNDOC_free (s);
02762         throw;
02763       }
02764     SIGNDOC_free (s);
02765     return r;
02766   }
02767 
02786   void setFontName (Encoding aEncoding, const std::string &aFontName)
02787   {
02788     SIGNDOC_Exception *ex = NULL;
02789     SIGNDOC_TextFieldAttributes_setFontName (&ex, p, aEncoding, aFontName.c_str ());
02790     if (ex != NULL) SignDoc_throw (ex);
02791   }
02792 
02806   std::string getFontResourceName (Encoding aEncoding) const
02807   {
02808     SIGNDOC_Exception *ex = NULL;
02809     std::string r;
02810     char *s = SIGNDOC_TextFieldAttributes_getFontResourceName (&ex, p, aEncoding);
02811     if (ex != NULL) SignDoc_throw (ex);
02812     try
02813       {
02814         r = s;
02815       }
02816     catch (...)
02817       {
02818         SIGNDOC_free (s);
02819         throw;
02820       }
02821     SIGNDOC_free (s);
02822     return r;
02823   }
02824 
02836   double getFontSize () const
02837   {
02838     SIGNDOC_Exception *ex = NULL;
02839     double r;
02840     r = SIGNDOC_TextFieldAttributes_getFontSize (&ex, p);
02841     if (ex != NULL) SignDoc_throw (ex);
02842     return r;
02843   }
02844 
02858   void setFontSize (double aFontSize)
02859   {
02860     SIGNDOC_Exception *ex = NULL;
02861     SIGNDOC_TextFieldAttributes_setFontSize (&ex, p, aFontSize);
02862     if (ex != NULL) SignDoc_throw (ex);
02863   }
02864 
02876   SignDocColor *getTextColor () const
02877   {
02878     SIGNDOC_Exception *ex = NULL;
02879     SIGNDOC_Color *r;
02880     r = SIGNDOC_TextFieldAttributes_getTextColor (&ex, p);
02881     if (ex != NULL) SignDoc_throw (ex);
02882     if (r == NULL)
02883       return NULL;
02884     try
02885       {
02886         return new SignDocColor (r);
02887       }
02888     catch (...)
02889       {
02890         SIGNDOC_Color_delete (r);
02891         throw;
02892       }
02893   }
02894 
02900   void setTextColor (const SignDocColor &aTextColor)
02901   {
02902     SIGNDOC_Exception *ex = NULL;
02903     SIGNDOC_TextFieldAttributes_setTextColor (&ex, p, aTextColor.getImpl ());
02904     if (ex != NULL) SignDoc_throw (ex);
02905   }
02906 
02922   std::string getRest (Encoding aEncoding) const
02923   {
02924     SIGNDOC_Exception *ex = NULL;
02925     std::string r;
02926     char *s = SIGNDOC_TextFieldAttributes_getRest (&ex, p, aEncoding);
02927     if (ex != NULL) SignDoc_throw (ex);
02928     try
02929       {
02930         r = s;
02931       }
02932     catch (...)
02933       {
02934         SIGNDOC_free (s);
02935         throw;
02936       }
02937     SIGNDOC_free (s);
02938     return r;
02939   }
02940 
02950   void setRest (Encoding aEncoding, const std::string &aInput)
02951   {
02952     SIGNDOC_Exception *ex = NULL;
02953     SIGNDOC_TextFieldAttributes_setRest (&ex, p, aEncoding, aInput.c_str ());
02954     if (ex != NULL) SignDoc_throw (ex);
02955   }
02956 
02957 private:
02958 public:
02963   SignDocTextFieldAttributes (SIGNDOC_TextFieldAttributes *aP) : p (aP) { }
02964 
02969   SIGNDOC_TextFieldAttributes *getImpl () { return p; }
02970 
02975   const SIGNDOC_TextFieldAttributes *getImpl () const { return p; }
02976 
02981   void setImpl (SIGNDOC_TextFieldAttributes *aP) { SIGNDOC_TextFieldAttributes_delete (p); p  = aP; }
02982 
02983 private:
02984   SIGNDOC_TextFieldAttributes *p;
02985 };
02986 
03310 class SignDocField 
03311 {
03312 public:
03313 
03314 public:
03320   enum Type
03321   {
03322     t_unknown,              
03323     t_pushbutton,           
03324     t_check_box,            
03325     t_radio_button,         
03326     t_text,                 
03327     t_list_box,             
03328     t_signature_digsig,     
03329     t_signature_signdoc,    
03330     t_combo_box             
03331   };
03332 
03382   enum Flag
03383   {
03384     f_ReadOnly          = 1 << 0,  
03385     f_Required          = 1 << 1,  
03386     f_NoExport          = 1 << 2,  
03387     f_NoToggleToOff     = 1 << 3,  
03388     f_Radio             = 1 << 4,  
03389     f_Pushbutton        = 1 << 5,  
03390     f_RadiosInUnison    = 1 << 6,  
03391 
03401     f_MultiLine         = 1 << 7,
03402 
03403     f_Password          = 1 << 8,  
03404     f_FileSelect        = 1 << 9,  
03405     f_DoNotSpellCheck   = 1 << 10, 
03406     f_DoNotScroll       = 1 << 11, 
03407     f_Comb              = 1 << 12, 
03408     f_RichText          = 1 << 13, 
03409     f_Combo             = 1 << 14, 
03410     f_Edit              = 1 << 15, 
03411     f_Sort              = 1 << 16, 
03412     f_MultiSelect       = 1 << 17, 
03413     f_CommitOnSelChange = 1 << 18, 
03414     f_SinglePage        = 1 << 28, 
03415     f_EnableAddAfterSigning = 1 << 29, 
03416     f_Invisible         = 1 << 30  
03417   };
03418 
03428   enum WidgetFlag
03429   {
03430     wf_Invisible      = 1 << (1 - 1), 
03431     wf_Hidden         = 1 << (2 - 1), 
03432     wf_Print          = 1 << (3 - 1), 
03433     wf_NoZoom         = 1 << (4 - 1), 
03434     wf_NoRotate       = 1 << (5 - 1), 
03435     wf_NoView         = 1 << (6 - 1), 
03436     wf_ReadOnly       = 1 << (7 - 1), 
03437     wf_Locked         = 1 << (8 - 1), 
03438     wf_ToggleNoView   = 1 << (9 - 1), 
03439     wf_LockedContents = 1 << (10 - 1) 
03440   };
03441 
03447   enum Justification
03448   {
03449     j_none,             
03450     j_left,             
03451     j_center,           
03452     j_right             
03453   };
03454 
03460   enum BorderStyle
03461   {
03462     bos_other,                  
03463     bos_solid,                  
03464     bos_dashed,                 
03465     bos_beveled,                
03466     bos_inset,                  
03467     bos_underline               
03468   };
03469 
03475   enum ButtonStyle
03476   {
03477     bus_default,        
03478     bus_other,          
03479     bus_check_mark,     
03480     bus_cross,          
03481     bus_star,           
03482     bus_circle,         
03483     bus_square,         
03484     bus_diamond         
03485   };
03486 
03492   enum LockType
03493   {
03494     lt_na,              
03495     lt_none,            
03496     lt_all,             
03497     lt_include,         
03498     lt_exclude          
03499   };
03500 
03504   enum SignatureType
03505   {
03506     st_not_a_signature_field,  
03507     st_not_signed,             
03508     st_approval,               
03509     st_certification,          
03510     st_document_time_stamp     
03511   };
03512 
03518   enum CertSeedValueFlag
03519   {
03520     csvf_SubjectCert = 0x01,    
03521     csvf_IssuerCert  = 0x02,    
03522     csvf_Policy      = 0x04,    
03523     csvf_SubjectDN   = 0x08,    
03524     csvf_KeyUsage    = 0x20,    
03525     csvf_URL         = 0x40     
03526   };
03527 
03528 public:
03534   SignDocField ()
03535     : p (NULL)
03536   {
03537     SIGNDOC_Exception *ex = NULL;
03538     p = SIGNDOC_Field_new (&ex);
03539     if (ex != NULL) SignDoc_throw (ex);
03540   }
03541 
03547   SignDocField (const SignDocField &aSource)
03548     : p (NULL)
03549   {
03550     SIGNDOC_Exception *ex = NULL;
03551     p = SIGNDOC_Field_clone (&ex, aSource.getImpl ());
03552     if (ex != NULL) SignDoc_throw (ex);
03553   }
03554 
03558   ~SignDocField ()
03559   {
03560     SIGNDOC_Field_delete (p);
03561   }
03562 
03568   SignDocField &operator= (const SignDocField &aSource)
03569   {
03570     SIGNDOC_Exception *ex = NULL;
03571     SIGNDOC_Field_assign (&ex, p, aSource.getImpl ());
03572     if (ex != NULL) SignDoc_throw (ex);
03573     return *this;
03574   }
03575 
03581   void swap (SignDocField &aOther)
03582   {
03583     std::swap (p, aOther.p);
03584   }
03585 
03601   std::string getName (Encoding aEncoding) const
03602   {
03603     SIGNDOC_Exception *ex = NULL;
03604     std::string r;
03605     char *s = SIGNDOC_Field_getName (&ex, p, aEncoding);
03606     if (ex != NULL) SignDoc_throw (ex);
03607     try
03608       {
03609         r = s;
03610       }
03611     catch (...)
03612       {
03613         SIGNDOC_free (s);
03614         throw;
03615       }
03616     SIGNDOC_free (s);
03617     return r;
03618   }
03619 
03629   const char *getNameUTF8 () const
03630   {
03631     SIGNDOC_Exception *ex = NULL;
03632     const char *r;
03633     r = SIGNDOC_Field_getNameUTF8 (&ex, p);
03634     if (ex != NULL) SignDoc_throw (ex);
03635     return r;
03636   }
03637 
03659   void setName (Encoding aEncoding, const std::string &aName)
03660   {
03661     SIGNDOC_Exception *ex = NULL;
03662     SIGNDOC_Field_setName (&ex, p, aEncoding, aName.c_str ());
03663     if (ex != NULL) SignDoc_throw (ex);
03664   }
03665 
03682   void setName (const wchar_t *aName)
03683   {
03684     SIGNDOC_Exception *ex = NULL;
03685     SIGNDOC_Field_setNameW (&ex, p, aName);
03686     if (ex != NULL) SignDoc_throw (ex);
03687   }
03688 
03709   std::string getAlternateName (Encoding aEncoding) const
03710   {
03711     SIGNDOC_Exception *ex = NULL;
03712     std::string r;
03713     char *s = SIGNDOC_Field_getAlternateName (&ex, p, aEncoding);
03714     if (ex != NULL) SignDoc_throw (ex);
03715     try
03716       {
03717         r = s;
03718       }
03719     catch (...)
03720       {
03721         SIGNDOC_free (s);
03722         throw;
03723       }
03724     SIGNDOC_free (s);
03725     return r;
03726   }
03727 
03748   void setAlternateName (Encoding aEncoding, const std::string &aName)
03749   {
03750     SIGNDOC_Exception *ex = NULL;
03751     SIGNDOC_Field_setAlternateName (&ex, p, aEncoding, aName.c_str ());
03752     if (ex != NULL) SignDoc_throw (ex);
03753   }
03754 
03774   std::string getMappingName (Encoding aEncoding) const
03775   {
03776     SIGNDOC_Exception *ex = NULL;
03777     std::string r;
03778     char *s = SIGNDOC_Field_getMappingName (&ex, p, aEncoding);
03779     if (ex != NULL) SignDoc_throw (ex);
03780     try
03781       {
03782         r = s;
03783       }
03784     catch (...)
03785       {
03786         SIGNDOC_free (s);
03787         throw;
03788       }
03789     SIGNDOC_free (s);
03790     return r;
03791   }
03792 
03809   void setMappingName (Encoding aEncoding, const std::string &aName)
03810   {
03811     SIGNDOC_Exception *ex = NULL;
03812     SIGNDOC_Field_setMappingName (&ex, p, aEncoding, aName.c_str ());
03813     if (ex != NULL) SignDoc_throw (ex);
03814   }
03815 
03827   int getValueCount () const
03828   {
03829     SIGNDOC_Exception *ex = NULL;
03830     int r;
03831     r = SIGNDOC_Field_getValueCount (&ex, p);
03832     if (ex != NULL) SignDoc_throw (ex);
03833     return r;
03834   }
03835 
03859   std::string getValue (Encoding aEncoding, int aIndex) const
03860   {
03861     SIGNDOC_Exception *ex = NULL;
03862     std::string r;
03863     char *s = SIGNDOC_Field_getValue (&ex, p, aEncoding, aIndex);
03864     if (ex != NULL) SignDoc_throw (ex);
03865     try
03866       {
03867         r = s;
03868       }
03869     catch (...)
03870       {
03871         SIGNDOC_free (s);
03872         throw;
03873       }
03874     SIGNDOC_free (s);
03875     return r;
03876   }
03877 
03896   const char *getValueUTF8 (int aIndex) const
03897   {
03898     SIGNDOC_Exception *ex = NULL;
03899     const char *r;
03900     r = SIGNDOC_Field_getValueUTF8 (&ex, p, aIndex);
03901     if (ex != NULL) SignDoc_throw (ex);
03902     return r;
03903   }
03904 
03913   void clearValues ()
03914   {
03915     SIGNDOC_Exception *ex = NULL;
03916     SIGNDOC_Field_clearValues (&ex, p);
03917     if (ex != NULL) SignDoc_throw (ex);
03918   }
03919 
03944   void addValue (Encoding aEncoding, const std::string &aValue)
03945   {
03946     SIGNDOC_Exception *ex = NULL;
03947     SIGNDOC_Field_addValue (&ex, p, aEncoding, aValue.c_str ());
03948     if (ex != NULL) SignDoc_throw (ex);
03949   }
03950 
03979   bool setValue (int aIndex, Encoding aEncoding, const std::string &aValue)
03980   {
03981     SIGNDOC_Exception *ex = NULL;
03982     bool r;
03983     r = (bool)SIGNDOC_Field_setValueByIndex (&ex, p, aIndex, aEncoding, aValue.c_str ());
03984     if (ex != NULL) SignDoc_throw (ex);
03985     return r;
03986   }
03987 
04015   void setValue (Encoding aEncoding, const std::string &aValue)
04016   {
04017     SIGNDOC_Exception *ex = NULL;
04018     SIGNDOC_Field_setValue (&ex, p, aEncoding, aValue.c_str ());
04019     if (ex != NULL) SignDoc_throw (ex);
04020   }
04021 
04033   bool removeValue (int aIndex)
04034   {
04035     SIGNDOC_Exception *ex = NULL;
04036     bool r;
04037     r = (bool)SIGNDOC_Field_removeValue (&ex, p, aIndex);
04038     if (ex != NULL) SignDoc_throw (ex);
04039     return r;
04040   }
04041 
04069   int getValueIndex () const
04070   {
04071     SIGNDOC_Exception *ex = NULL;
04072     int r;
04073     r = SIGNDOC_Field_getValueIndex (&ex, p);
04074     if (ex != NULL) SignDoc_throw (ex);
04075     return r;
04076   }
04077 
04130   void setValueIndex (int aIndex)
04131   {
04132     SIGNDOC_Exception *ex = NULL;
04133     SIGNDOC_Field_setValueIndex (&ex, p, aIndex);
04134     if (ex != NULL) SignDoc_throw (ex);
04135   }
04136 
04158   bool clickButton (int aIndex)
04159   {
04160     SIGNDOC_Exception *ex = NULL;
04161     bool r;
04162     r = (bool)SIGNDOC_Field_clickButton (&ex, p, aIndex);
04163     if (ex != NULL) SignDoc_throw (ex);
04164     return r;
04165   }
04166 
04178   int getChoiceCount () const
04179   {
04180     SIGNDOC_Exception *ex = NULL;
04181     int r;
04182     r = SIGNDOC_Field_getChoiceCount (&ex, p);
04183     if (ex != NULL) SignDoc_throw (ex);
04184     return r;
04185   }
04186 
04213   std::string getChoiceValue (Encoding aEncoding, int aIndex) const
04214   {
04215     SIGNDOC_Exception *ex = NULL;
04216     std::string r;
04217     char *s = SIGNDOC_Field_getChoiceValue (&ex, p, aEncoding, aIndex);
04218     if (ex != NULL) SignDoc_throw (ex);
04219     try
04220       {
04221         r = s;
04222       }
04223     catch (...)
04224       {
04225         SIGNDOC_free (s);
04226         throw;
04227       }
04228     SIGNDOC_free (s);
04229     return r;
04230   }
04231 
04257   const char *getChoiceValueUTF8 (int aIndex) const
04258   {
04259     SIGNDOC_Exception *ex = NULL;
04260     const char *r;
04261     r = SIGNDOC_Field_getChoiceValueUTF8 (&ex, p, aIndex);
04262     if (ex != NULL) SignDoc_throw (ex);
04263     return r;
04264   }
04265 
04292   std::string getChoiceExport (Encoding aEncoding, int aIndex) const
04293   {
04294     SIGNDOC_Exception *ex = NULL;
04295     std::string r;
04296     char *s = SIGNDOC_Field_getChoiceExport (&ex, p, aEncoding, aIndex);
04297     if (ex != NULL) SignDoc_throw (ex);
04298     try
04299       {
04300         r = s;
04301       }
04302     catch (...)
04303       {
04304         SIGNDOC_free (s);
04305         throw;
04306       }
04307     SIGNDOC_free (s);
04308     return r;
04309   }
04310 
04336   const char *getChoiceExportUTF8 (int aIndex) const
04337   {
04338     SIGNDOC_Exception *ex = NULL;
04339     const char *r;
04340     r = SIGNDOC_Field_getChoiceExportUTF8 (&ex, p, aIndex);
04341     if (ex != NULL) SignDoc_throw (ex);
04342     return r;
04343   }
04344 
04352   void clearChoices ()
04353   {
04354     SIGNDOC_Exception *ex = NULL;
04355     SIGNDOC_Field_clearChoices (&ex, p);
04356     if (ex != NULL) SignDoc_throw (ex);
04357   }
04358 
04377   void addChoice (Encoding aEncoding, const std::string &aValue)
04378   {
04379     SIGNDOC_Exception *ex = NULL;
04380     SIGNDOC_Field_addChoice (&ex, p, aEncoding, aValue.c_str ());
04381     if (ex != NULL) SignDoc_throw (ex);
04382   }
04383 
04401   void addChoice (Encoding aEncoding, const std::string &aValue,
04402                   const std::string &aExport)
04403   {
04404     SIGNDOC_Exception *ex = NULL;
04405     SIGNDOC_Field_addChoiceWithExport (&ex, p, aEncoding, aValue.c_str (), aExport.c_str ());
04406     if (ex != NULL) SignDoc_throw (ex);
04407   }
04408 
04432   bool setChoice (int aIndex, Encoding aEncoding, const std::string &aValue)
04433   {
04434     SIGNDOC_Exception *ex = NULL;
04435     bool r;
04436     r = (bool)SIGNDOC_Field_setChoice (&ex, p, aIndex, aEncoding, aValue.c_str ());
04437     if (ex != NULL) SignDoc_throw (ex);
04438     return r;
04439   }
04440 
04463   bool setChoice (int aIndex, Encoding aEncoding, const std::string &aValue,
04464                   const std::string &aExport)
04465   {
04466     SIGNDOC_Exception *ex = NULL;
04467     bool r;
04468     r = (bool)SIGNDOC_Field_setChoiceWithExport (&ex, p, aIndex, aEncoding, aValue.c_str (), aExport.c_str ());
04469     if (ex != NULL) SignDoc_throw (ex);
04470     return r;
04471   }
04472 
04482   bool removeChoice (int aIndex)
04483   {
04484     SIGNDOC_Exception *ex = NULL;
04485     bool r;
04486     r = (bool)SIGNDOC_Field_removeChoice (&ex, p, aIndex);
04487     if (ex != NULL) SignDoc_throw (ex);
04488     return r;
04489   }
04490 
04500   Type getType () const
04501   {
04502     SIGNDOC_Exception *ex = NULL;
04503     Type r;
04504     r = (Type)SIGNDOC_Field_getType (&ex, p);
04505     if (ex != NULL) SignDoc_throw (ex);
04506     return r;
04507   }
04508 
04520   void setType (Type aType)
04521   {
04522     SIGNDOC_Exception *ex = NULL;
04523     SIGNDOC_Field_setType (&ex, p, aType);
04524     if (ex != NULL) SignDoc_throw (ex);
04525   }
04526 
04541   int getFlags () const
04542   {
04543     SIGNDOC_Exception *ex = NULL;
04544     int r;
04545     r = SIGNDOC_Field_getFlags (&ex, p);
04546     if (ex != NULL) SignDoc_throw (ex);
04547     return r;
04548   }
04549 
04560   void setFlags (int aFlags)
04561   {
04562     SIGNDOC_Exception *ex = NULL;
04563     SIGNDOC_Field_setFlags (&ex, p, aFlags);
04564     if (ex != NULL) SignDoc_throw (ex);
04565   }
04566 
04579   SignatureType getSignatureType () const
04580   {
04581     SIGNDOC_Exception *ex = NULL;
04582     SignatureType r;
04583     r = (SignatureType)SIGNDOC_Field_getSignatureType (&ex, p);
04584     if (ex != NULL) SignDoc_throw (ex);
04585     return r;
04586   }
04587 
04607   int getDocMDP () const
04608   {
04609     SIGNDOC_Exception *ex = NULL;
04610     int r;
04611     r = SIGNDOC_Field_getDocMDP (&ex, p);
04612     if (ex != NULL) SignDoc_throw (ex);
04613     return r;
04614   }
04615 
04629   bool isSigned () const
04630   {
04631     SIGNDOC_Exception *ex = NULL;
04632     bool r;
04633     r = (bool)SIGNDOC_Field_isSigned (&ex, p);
04634     if (ex != NULL) SignDoc_throw (ex);
04635     return r;
04636   }
04637 
04655   bool isCurrentlyClearable () const
04656   {
04657     SIGNDOC_Exception *ex = NULL;
04658     bool r;
04659     r = (bool)SIGNDOC_Field_isCurrentlyClearable (&ex, p);
04660     if (ex != NULL) SignDoc_throw (ex);
04661     return r;
04662   }
04663 
04675   int getMaxLen () const
04676   {
04677     SIGNDOC_Exception *ex = NULL;
04678     int r;
04679     r = SIGNDOC_Field_getMaxLen (&ex, p);
04680     if (ex != NULL) SignDoc_throw (ex);
04681     return r;
04682   }
04683 
04692   void setMaxLen (int aMaxLen)
04693   {
04694     SIGNDOC_Exception *ex = NULL;
04695     SIGNDOC_Field_setMaxLen (&ex, p, aMaxLen);
04696     if (ex != NULL) SignDoc_throw (ex);
04697   }
04698 
04710   int getTopIndex () const
04711   {
04712     SIGNDOC_Exception *ex = NULL;
04713     int r;
04714     r = SIGNDOC_Field_getTopIndex (&ex, p);
04715     if (ex != NULL) SignDoc_throw (ex);
04716     return r;
04717   }
04718 
04730   void setTopIndex (int aTopIndex)
04731   {
04732     SIGNDOC_Exception *ex = NULL;
04733     SIGNDOC_Field_setTopIndex (&ex, p, aTopIndex);
04734     if (ex != NULL) SignDoc_throw (ex);
04735   }
04736 
04749   int getWidget () const
04750   {
04751     SIGNDOC_Exception *ex = NULL;
04752     int r;
04753     r = SIGNDOC_Field_getWidget (&ex, p);
04754     if (ex != NULL) SignDoc_throw (ex);
04755     return r;
04756   }
04757 
04768   int getWidgetCount () const
04769   {
04770     SIGNDOC_Exception *ex = NULL;
04771     int r;
04772     r = SIGNDOC_Field_getWidgetCount (&ex, p);
04773     if (ex != NULL) SignDoc_throw (ex);
04774     return r;
04775   }
04776 
04796   bool selectWidget (int aIndex)
04797   {
04798     SIGNDOC_Exception *ex = NULL;
04799     bool r;
04800     r = (bool)SIGNDOC_Field_selectWidget (&ex, p, aIndex);
04801     if (ex != NULL) SignDoc_throw (ex);
04802     return r;
04803   }
04804 
04820   bool addWidget ()
04821   {
04822     SIGNDOC_Exception *ex = NULL;
04823     bool r;
04824     r = (bool)SIGNDOC_Field_addWidget (&ex, p);
04825     if (ex != NULL) SignDoc_throw (ex);
04826     return r;
04827   }
04828 
04849   bool insertWidget (int aIndex)
04850   {
04851     SIGNDOC_Exception *ex = NULL;
04852     bool r;
04853     r = (bool)SIGNDOC_Field_insertWidget (&ex, p, aIndex);
04854     if (ex != NULL) SignDoc_throw (ex);
04855     return r;
04856   }
04857 
04883   bool removeWidget (int aIndex)
04884   {
04885     SIGNDOC_Exception *ex = NULL;
04886     bool r;
04887     r = (bool)SIGNDOC_Field_removeWidget (&ex, p, aIndex);
04888     if (ex != NULL) SignDoc_throw (ex);
04889     return r;
04890   }
04891 
04904   int getWidgetFlags () const
04905   {
04906     SIGNDOC_Exception *ex = NULL;
04907     int r;
04908     r = SIGNDOC_Field_getWidgetFlags (&ex, p);
04909     if (ex != NULL) SignDoc_throw (ex);
04910     return r;
04911   }
04912 
04925   void setWidgetFlags (int aFlags)
04926   {
04927     SIGNDOC_Exception *ex = NULL;
04928     SIGNDOC_Field_setWidgetFlags (&ex, p, aFlags);
04929     if (ex != NULL) SignDoc_throw (ex);
04930   }
04931 
04943   int getPage () const
04944   {
04945     SIGNDOC_Exception *ex = NULL;
04946     int r;
04947     r = SIGNDOC_Field_getPage (&ex, p);
04948     if (ex != NULL) SignDoc_throw (ex);
04949     return r;
04950   }
04951 
04968   void setPage (int aPage)
04969   {
04970     SIGNDOC_Exception *ex = NULL;
04971     SIGNDOC_Field_setPage (&ex, p, aPage);
04972     if (ex != NULL) SignDoc_throw (ex);
04973   }
04974 
04985   double getLeft () const
04986   {
04987     SIGNDOC_Exception *ex = NULL;
04988     double r;
04989     r = SIGNDOC_Field_getLeft (&ex, p);
04990     if (ex != NULL) SignDoc_throw (ex);
04991     return r;
04992   }
04993 
05004   void setLeft (double aLeft)
05005   {
05006     SIGNDOC_Exception *ex = NULL;
05007     SIGNDOC_Field_setLeft (&ex, p, aLeft);
05008     if (ex != NULL) SignDoc_throw (ex);
05009   }
05010 
05021   double getBottom () const
05022   {
05023     SIGNDOC_Exception *ex = NULL;
05024     double r;
05025     r = SIGNDOC_Field_getBottom (&ex, p);
05026     if (ex != NULL) SignDoc_throw (ex);
05027     return r;
05028   }
05029 
05040   void setBottom (double aBottom)
05041   {
05042     SIGNDOC_Exception *ex = NULL;
05043     SIGNDOC_Field_setBottom (&ex, p, aBottom);
05044     if (ex != NULL) SignDoc_throw (ex);
05045   }
05046 
05059   double getRight () const
05060   {
05061     SIGNDOC_Exception *ex = NULL;
05062     double r;
05063     r = SIGNDOC_Field_getRight (&ex, p);
05064     if (ex != NULL) SignDoc_throw (ex);
05065     return r;
05066   }
05067 
05080   void setRight (double aRight)
05081   {
05082     SIGNDOC_Exception *ex = NULL;
05083     SIGNDOC_Field_setRight (&ex, p, aRight);
05084     if (ex != NULL) SignDoc_throw (ex);
05085   }
05086 
05099   double getTop () const
05100   {
05101     SIGNDOC_Exception *ex = NULL;
05102     double r;
05103     r = SIGNDOC_Field_getTop (&ex, p);
05104     if (ex != NULL) SignDoc_throw (ex);
05105     return r;
05106   }
05107 
05120   void setTop (double aTop)
05121   {
05122     SIGNDOC_Exception *ex = NULL;
05123     SIGNDOC_Field_setTop (&ex, p, aTop);
05124     if (ex != NULL) SignDoc_throw (ex);
05125   }
05126 
05151   std::string getButtonValue (Encoding aEncoding) const
05152   {
05153     SIGNDOC_Exception *ex = NULL;
05154     std::string r;
05155     char *s = SIGNDOC_Field_getButtonValue (&ex, p, aEncoding);
05156     if (ex != NULL) SignDoc_throw (ex);
05157     try
05158       {
05159         r = s;
05160       }
05161     catch (...)
05162       {
05163         SIGNDOC_free (s);
05164         throw;
05165       }
05166     SIGNDOC_free (s);
05167     return r;
05168   }
05169 
05183   const char *getButtonValueUTF8 () const
05184   {
05185     SIGNDOC_Exception *ex = NULL;
05186     const char *r;
05187     r = SIGNDOC_Field_getButtonValueUTF8 (&ex, p);
05188     if (ex != NULL) SignDoc_throw (ex);
05189     return r;
05190   }
05191 
05216   void setButtonValue (Encoding aEncoding, const std::string &aValue)
05217   {
05218     SIGNDOC_Exception *ex = NULL;
05219     SIGNDOC_Field_setButtonValue (&ex, p, aEncoding, aValue.c_str ());
05220     if (ex != NULL) SignDoc_throw (ex);
05221   }
05222 
05233   Justification getJustification () const
05234   {
05235     SIGNDOC_Exception *ex = NULL;
05236     Justification r;
05237     r = (Justification)SIGNDOC_Field_getJustification (&ex, p);
05238     if (ex != NULL) SignDoc_throw (ex);
05239     return r;
05240   }
05241 
05255   void setJustification (Justification aJustification)
05256   {
05257     SIGNDOC_Exception *ex = NULL;
05258     SIGNDOC_Field_setJustification (&ex, p, aJustification);
05259     if (ex != NULL) SignDoc_throw (ex);
05260   }
05261 
05275   int getRotation () const
05276   {
05277     SIGNDOC_Exception *ex = NULL;
05278     int r;
05279     r = SIGNDOC_Field_getRotation (&ex, p);
05280     if (ex != NULL) SignDoc_throw (ex);
05281     return r;
05282   }
05283 
05299   void setRotation (int aRotation)
05300   {
05301     SIGNDOC_Exception *ex = NULL;
05302     SIGNDOC_Field_setRotation (&ex, p, aRotation);
05303     if (ex != NULL) SignDoc_throw (ex);
05304   }
05305 
05321   bool getTextFieldAttributes (SignDocTextFieldAttributes &aOutput) const
05322   {
05323     SIGNDOC_Exception *ex = NULL;
05324     bool r;
05325     r = (bool)SIGNDOC_Field_getTextFieldAttributes (&ex, p, aOutput.getImpl ());
05326     if (ex != NULL) SignDoc_throw (ex);
05327     return r;
05328   }
05329 
05368   bool setTextFieldAttributes (const SignDocTextFieldAttributes &aInput)
05369   {
05370     SIGNDOC_Exception *ex = NULL;
05371     bool r;
05372     r = (bool)SIGNDOC_Field_setTextFieldAttributes (&ex, p, aInput.getImpl ());
05373     if (ex != NULL) SignDoc_throw (ex);
05374     return r;
05375   }
05376 
05389   SignDocColor *getBackgroundColor () const
05390   {
05391     SIGNDOC_Exception *ex = NULL;
05392     SIGNDOC_Color *r;
05393     r = SIGNDOC_Field_getBackgroundColor (&ex, p);
05394     if (ex != NULL) SignDoc_throw (ex);
05395     if (r == NULL)
05396       return NULL;
05397     try
05398       {
05399         return new SignDocColor (r);
05400       }
05401     catch (...)
05402       {
05403         SIGNDOC_Color_delete (r);
05404         throw;
05405       }
05406   }
05407 
05420   void setBackgroundColor (const SignDocColor *aColor)
05421   {
05422     SIGNDOC_Exception *ex = NULL;
05423     SIGNDOC_Field_setBackgroundColor (&ex, p, aColor == NULL ? NULL : aColor->getImpl ());
05424     if (ex != NULL) SignDoc_throw (ex);
05425   }
05426 
05440   SignDocColor *getBorderColor () const
05441   {
05442     SIGNDOC_Exception *ex = NULL;
05443     SIGNDOC_Color *r;
05444     r = SIGNDOC_Field_getBorderColor (&ex, p);
05445     if (ex != NULL) SignDoc_throw (ex);
05446     if (r == NULL)
05447       return NULL;
05448     try
05449       {
05450         return new SignDocColor (r);
05451       }
05452     catch (...)
05453       {
05454         SIGNDOC_Color_delete (r);
05455         throw;
05456       }
05457   }
05458 
05478   void setBorderColor (const SignDocColor *aColor)
05479   {
05480     SIGNDOC_Exception *ex = NULL;
05481     SIGNDOC_Field_setBorderColor (&ex, p, aColor == NULL ? NULL : aColor->getImpl ());
05482     if (ex != NULL) SignDoc_throw (ex);
05483   }
05484 
05494   double getBorderWidth () const
05495   {
05496     SIGNDOC_Exception *ex = NULL;
05497     double r;
05498     r = SIGNDOC_Field_getBorderWidth (&ex, p);
05499     if (ex != NULL) SignDoc_throw (ex);
05500     return r;
05501   }
05502 
05514   void setBorderWidth (double aWidth)
05515   {
05516     SIGNDOC_Exception *ex = NULL;
05517     SIGNDOC_Field_setBorderWidth (&ex, p, aWidth);
05518     if (ex != NULL) SignDoc_throw (ex);
05519   }
05520 
05530   BorderStyle getBorderStyle () const
05531   {
05532     SIGNDOC_Exception *ex = NULL;
05533     BorderStyle r;
05534     r = (BorderStyle)SIGNDOC_Field_getBorderStyle (&ex, p);
05535     if (ex != NULL) SignDoc_throw (ex);
05536     return r;
05537   }
05538 
05552   void setBorderStyle (BorderStyle aStyle)
05553   {
05554     SIGNDOC_Exception *ex = NULL;
05555     SIGNDOC_Field_setBorderStyle (&ex, p, aStyle);
05556     if (ex != NULL) SignDoc_throw (ex);
05557   }
05558 
05569   ButtonStyle getButtonStyle () const
05570   {
05571     SIGNDOC_Exception *ex = NULL;
05572     ButtonStyle r;
05573     r = (ButtonStyle)SIGNDOC_Field_getButtonStyle (&ex, p);
05574     if (ex != NULL) SignDoc_throw (ex);
05575     return r;
05576   }
05577 
05591   void setButtonStyle (ButtonStyle aStyle)
05592   {
05593     SIGNDOC_Exception *ex = NULL;
05594     SIGNDOC_Field_setButtonStyle (&ex, p, aStyle);
05595     if (ex != NULL) SignDoc_throw (ex);
05596   }
05597 
05608   LockType getLockType () const
05609   {
05610     SIGNDOC_Exception *ex = NULL;
05611     LockType r;
05612     r = (LockType)SIGNDOC_Field_getLockType (&ex, p);
05613     if (ex != NULL) SignDoc_throw (ex);
05614     return r;
05615   }
05616 
05627   void setLockType (LockType aLockType)
05628   {
05629     SIGNDOC_Exception *ex = NULL;
05630     SIGNDOC_Field_setLockType (&ex, p, aLockType);
05631     if (ex != NULL) SignDoc_throw (ex);
05632   }
05633 
05641   int getLockFieldCount () const
05642   {
05643     SIGNDOC_Exception *ex = NULL;
05644     int r;
05645     r = SIGNDOC_Field_getLockFieldCount (&ex, p);
05646     if (ex != NULL) SignDoc_throw (ex);
05647     return r;
05648   }
05649 
05667   std::string getLockField (Encoding aEncoding, int aIndex) const
05668   {
05669     SIGNDOC_Exception *ex = NULL;
05670     std::string r;
05671     char *s = SIGNDOC_Field_getLockField (&ex, p, aEncoding, aIndex);
05672     if (ex != NULL) SignDoc_throw (ex);
05673     try
05674       {
05675         r = s;
05676       }
05677     catch (...)
05678       {
05679         SIGNDOC_free (s);
05680         throw;
05681       }
05682     SIGNDOC_free (s);
05683     return r;
05684   }
05685 
05701   const char *getLockFieldUTF8 (int aIndex) const
05702   {
05703     SIGNDOC_Exception *ex = NULL;
05704     const char *r;
05705     r = SIGNDOC_Field_getLockFieldUTF8 (&ex, p, aIndex);
05706     if (ex != NULL) SignDoc_throw (ex);
05707     return r;
05708   }
05709 
05717   void clearLockFields ()
05718   {
05719     SIGNDOC_Exception *ex = NULL;
05720     SIGNDOC_Field_clearLockFields (&ex, p);
05721     if (ex != NULL) SignDoc_throw (ex);
05722   }
05723 
05736   void addLockField (Encoding aEncoding, const std::string &aName)
05737   {
05738     SIGNDOC_Exception *ex = NULL;
05739     SIGNDOC_Field_addLockField (&ex, p, aEncoding, aName.c_str ());
05740     if (ex != NULL) SignDoc_throw (ex);
05741   }
05742 
05760   bool setLockField (int aIndex, Encoding aEncoding, const std::string &aName)
05761   {
05762     SIGNDOC_Exception *ex = NULL;
05763     bool r;
05764     r = (bool)SIGNDOC_Field_setLockFieldByIndex (&ex, p, aIndex, aEncoding, aName.c_str ());
05765     if (ex != NULL) SignDoc_throw (ex);
05766     return r;
05767   }
05768 
05785   void setLockField (Encoding aEncoding, const std::string &aName)
05786   {
05787     SIGNDOC_Exception *ex = NULL;
05788     SIGNDOC_Field_setLockField (&ex, p, aEncoding, aName.c_str ());
05789     if (ex != NULL) SignDoc_throw (ex);
05790   }
05791 
05801   bool removeLockField (int aIndex)
05802   {
05803     SIGNDOC_Exception *ex = NULL;
05804     bool r;
05805     r = (bool)SIGNDOC_Field_removeLockField (&ex, p, aIndex);
05806     if (ex != NULL) SignDoc_throw (ex);
05807     return r;
05808   }
05809 
05824   int getLockMDP () const
05825   {
05826     SIGNDOC_Exception *ex = NULL;
05827     int r;
05828     r = SIGNDOC_Field_getLockMDP (&ex, p);
05829     if (ex != NULL) SignDoc_throw (ex);
05830     return r;
05831   }
05832 
05847   void setLockMDP (int aMDP)
05848   {
05849     SIGNDOC_Exception *ex = NULL;
05850     SIGNDOC_Field_setLockMDP (&ex, p, aMDP);
05851     if (ex != NULL) SignDoc_throw (ex);
05852   }
05853 
05864   unsigned getCertSeedValueFlags () const
05865   {
05866     SIGNDOC_Exception *ex = NULL;
05867     unsigned r;
05868     r = SIGNDOC_Field_getCertSeedValueFlags (&ex, p);
05869     if (ex != NULL) SignDoc_throw (ex);
05870     return r;
05871   }
05872 
05884   void setCertSeedValueFlags (unsigned aFlags)
05885   {
05886     SIGNDOC_Exception *ex = NULL;
05887     SIGNDOC_Field_setCertSeedValueFlags (&ex, p, aFlags);
05888     if (ex != NULL) SignDoc_throw (ex);
05889   }
05890 
05902   int getCertSeedValueSubjectDNCount () const
05903   {
05904     SIGNDOC_Exception *ex = NULL;
05905     int r;
05906     r = SIGNDOC_Field_getCertSeedValueSubjectDNCount (&ex, p);
05907     if (ex != NULL) SignDoc_throw (ex);
05908     return r;
05909   }
05910 
05930   std::string getCertSeedValueSubjectDN (Encoding aEncoding, int aIndex) const
05931   {
05932     SIGNDOC_Exception *ex = NULL;
05933     std::string r;
05934     char *s = SIGNDOC_Field_getCertSeedValueSubjectDN (&ex, p, aEncoding, aIndex);
05935     if (ex != NULL) SignDoc_throw (ex);
05936     try
05937       {
05938         r = s;
05939       }
05940     catch (...)
05941       {
05942         SIGNDOC_free (s);
05943         throw;
05944       }
05945     SIGNDOC_free (s);
05946     return r;
05947   }
05948 
05968   const char *getCertSeedValueSubjectDNUTF8 (int aIndex) const
05969   {
05970     SIGNDOC_Exception *ex = NULL;
05971     const char *r;
05972     r = SIGNDOC_Field_getCertSeedValueSubjectDNUTF8 (&ex, p, aIndex);
05973     if (ex != NULL) SignDoc_throw (ex);
05974     return r;
05975   }
05976 
05987   void clearCertSeedValueSubjectDNs ()
05988   {
05989     SIGNDOC_Exception *ex = NULL;
05990     SIGNDOC_Field_clearCertSeedValueSubjectDNs (&ex, p);
05991     if (ex != NULL) SignDoc_throw (ex);
05992   }
05993 
06014   bool addCertSeedValueSubjectDN (Encoding aEncoding, const std::string &aName)
06015   {
06016     SIGNDOC_Exception *ex = NULL;
06017     bool r;
06018     r = (bool)SIGNDOC_Field_addCertSeedValueSubjectDN (&ex, p, aEncoding, aName.c_str ());
06019     if (ex != NULL) SignDoc_throw (ex);
06020     return r;
06021   }
06022 
06047   bool setCertSeedValueSubjectDN (int aIndex, Encoding aEncoding,
06048                                   const std::string &aName)
06049   {
06050     SIGNDOC_Exception *ex = NULL;
06051     bool r;
06052     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectDNByIndex (&ex, p, aIndex, aEncoding, aName.c_str ());
06053     if (ex != NULL) SignDoc_throw (ex);
06054     return r;
06055   }
06056 
06081   bool setCertSeedValueSubjectDN (Encoding aEncoding, const std::string &aName)
06082   {
06083     SIGNDOC_Exception *ex = NULL;
06084     bool r;
06085     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectDN (&ex, p, aEncoding, aName.c_str ());
06086     if (ex != NULL) SignDoc_throw (ex);
06087     return r;
06088   }
06089 
06102   bool removeCertSeedValueSubjectDN (int aIndex)
06103   {
06104     SIGNDOC_Exception *ex = NULL;
06105     bool r;
06106     r = (bool)SIGNDOC_Field_removeCertSeedValueSubjectDN (&ex, p, aIndex);
06107     if (ex != NULL) SignDoc_throw (ex);
06108     return r;
06109   }
06110 
06121   int getCertSeedValueSubjectCertificateCount () const
06122   {
06123     SIGNDOC_Exception *ex = NULL;
06124     int r;
06125     r = SIGNDOC_Field_getCertSeedValueSubjectCertificateCount (&ex, p);
06126     if (ex != NULL) SignDoc_throw (ex);
06127     return r;
06128   }
06129 
06142   bool getCertSeedValueSubjectCertificate (int aIndex,
06143                                            std::vector<unsigned char> &aOutput) const
06144   {
06145     SIGNDOC_Exception *ex = NULL;
06146     SIGNDOC_ByteArray *tempOutput = NULL;
06147     bool r;
06148     try
06149       {
06150         tempOutput = SIGNDOC_ByteArray_new (&ex);
06151         if (ex != NULL) SignDoc_throw (ex);
06152         r = (bool)SIGNDOC_Field_getCertSeedValueSubjectCertificate (&ex, p, aIndex, tempOutput);
06153         assignArray (aOutput, tempOutput);
06154       }
06155     catch (...)
06156       {
06157         if (tempOutput != NULL)
06158           SIGNDOC_ByteArray_delete (tempOutput);
06159         throw;
06160       }
06161     if (tempOutput != NULL)
06162       SIGNDOC_ByteArray_delete (tempOutput);
06163     if (ex != NULL) SignDoc_throw (ex);
06164     return r;
06165   }
06166 
06176   void clearCertSeedValueSubjectCertificates ()
06177   {
06178     SIGNDOC_Exception *ex = NULL;
06179     SIGNDOC_Field_clearCertSeedValueSubjectCertificates (&ex, p);
06180     if (ex != NULL) SignDoc_throw (ex);
06181   }
06182 
06194   void addCertSeedValueSubjectCertificate (const void *aPtr, size_t aSize)
06195   {
06196     SIGNDOC_Exception *ex = NULL;
06197     SIGNDOC_Field_addCertSeedValueSubjectCertificate (&ex, p, aPtr, aSize);
06198     if (ex != NULL) SignDoc_throw (ex);
06199   }
06200 
06217   bool setCertSeedValueSubjectCertificate (int aIndex, const void *aPtr,
06218                                            size_t aSize)
06219   {
06220     SIGNDOC_Exception *ex = NULL;
06221     bool r;
06222     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectCertificateByIndex (&ex, p, aIndex, aPtr, aSize);
06223     if (ex != NULL) SignDoc_throw (ex);
06224     return r;
06225   }
06226 
06241   void setCertSeedValueSubjectCertificate (const void *aPtr, size_t aSize)
06242   {
06243     SIGNDOC_Exception *ex = NULL;
06244     SIGNDOC_Field_setCertSeedValueSubjectCertificate (&ex, p, aPtr, aSize);
06245     if (ex != NULL) SignDoc_throw (ex);
06246   }
06247 
06261   bool removeCertSeedValueSubjectCertificate (int aIndex)
06262   {
06263     SIGNDOC_Exception *ex = NULL;
06264     bool r;
06265     r = (bool)SIGNDOC_Field_removeCertSeedValueSubjectCertificate (&ex, p, aIndex);
06266     if (ex != NULL) SignDoc_throw (ex);
06267     return r;
06268   }
06269 
06280   int getCertSeedValueIssuerCertificateCount () const
06281   {
06282     SIGNDOC_Exception *ex = NULL;
06283     int r;
06284     r = SIGNDOC_Field_getCertSeedValueIssuerCertificateCount (&ex, p);
06285     if (ex != NULL) SignDoc_throw (ex);
06286     return r;
06287   }
06288 
06301   bool getCertSeedValueIssuerCertificate (int aIndex,
06302                                           std::vector<unsigned char> &aOutput) const
06303   {
06304     SIGNDOC_Exception *ex = NULL;
06305     SIGNDOC_ByteArray *tempOutput = NULL;
06306     bool r;
06307     try
06308       {
06309         tempOutput = SIGNDOC_ByteArray_new (&ex);
06310         if (ex != NULL) SignDoc_throw (ex);
06311         r = (bool)SIGNDOC_Field_getCertSeedValueIssuerCertificate (&ex, p, aIndex, tempOutput);
06312         assignArray (aOutput, tempOutput);
06313       }
06314     catch (...)
06315       {
06316         if (tempOutput != NULL)
06317           SIGNDOC_ByteArray_delete (tempOutput);
06318         throw;
06319       }
06320     if (tempOutput != NULL)
06321       SIGNDOC_ByteArray_delete (tempOutput);
06322     if (ex != NULL) SignDoc_throw (ex);
06323     return r;
06324   }
06325 
06335   void clearCertSeedValueIssuerCertificates ()
06336   {
06337     SIGNDOC_Exception *ex = NULL;
06338     SIGNDOC_Field_clearCertSeedValueIssuerCertificates (&ex, p);
06339     if (ex != NULL) SignDoc_throw (ex);
06340   }
06341 
06353   void addCertSeedValueIssuerCertificate (const void *aPtr, size_t aSize)
06354   {
06355     SIGNDOC_Exception *ex = NULL;
06356     SIGNDOC_Field_addCertSeedValueIssuerCertificate (&ex, p, aPtr, aSize);
06357     if (ex != NULL) SignDoc_throw (ex);
06358   }
06359 
06376   bool setCertSeedValueIssuerCertificate (int aIndex, const void *aPtr,
06377                                           size_t aSize)
06378   {
06379     SIGNDOC_Exception *ex = NULL;
06380     bool r;
06381     r = (bool)SIGNDOC_Field_setCertSeedValueIssuerCertificateByIndex (&ex, p, aIndex, aPtr, aSize);
06382     if (ex != NULL) SignDoc_throw (ex);
06383     return r;
06384   }
06385 
06400   void setCertSeedValueIssuerCertificate (const void *aPtr, size_t aSize)
06401   {
06402     SIGNDOC_Exception *ex = NULL;
06403     SIGNDOC_Field_setCertSeedValueIssuerCertificate (&ex, p, aPtr, aSize);
06404     if (ex != NULL) SignDoc_throw (ex);
06405   }
06406 
06420   bool removeCertSeedValueIssuerCertificate (int aIndex)
06421   {
06422     SIGNDOC_Exception *ex = NULL;
06423     bool r;
06424     r = (bool)SIGNDOC_Field_removeCertSeedValueIssuerCertificate (&ex, p, aIndex);
06425     if (ex != NULL) SignDoc_throw (ex);
06426     return r;
06427   }
06428 
06438   int getCertSeedValuePolicyCount () const
06439   {
06440     SIGNDOC_Exception *ex = NULL;
06441     int r;
06442     r = SIGNDOC_Field_getCertSeedValuePolicyCount (&ex, p);
06443     if (ex != NULL) SignDoc_throw (ex);
06444     return r;
06445   }
06446 
06465   std::string getCertSeedValuePolicy (Encoding aEncoding, int aIndex) const
06466   {
06467     SIGNDOC_Exception *ex = NULL;
06468     std::string r;
06469     char *s = SIGNDOC_Field_getCertSeedValuePolicy (&ex, p, aEncoding, aIndex);
06470     if (ex != NULL) SignDoc_throw (ex);
06471     try
06472       {
06473         r = s;
06474       }
06475     catch (...)
06476       {
06477         SIGNDOC_free (s);
06478         throw;
06479       }
06480     SIGNDOC_free (s);
06481     return r;
06482   }
06483 
06501   const char *getCertSeedValuePolicyUTF8 (int aIndex) const
06502   {
06503     SIGNDOC_Exception *ex = NULL;
06504     const char *r;
06505     r = SIGNDOC_Field_getCertSeedValuePolicyUTF8 (&ex, p, aIndex);
06506     if (ex != NULL) SignDoc_throw (ex);
06507     return r;
06508   }
06509 
06519   void clearCertSeedValuePolicies ()
06520   {
06521     SIGNDOC_Exception *ex = NULL;
06522     SIGNDOC_Field_clearCertSeedValuePolicies (&ex, p);
06523     if (ex != NULL) SignDoc_throw (ex);
06524   }
06525 
06542   void addCertSeedValuePolicy (Encoding aEncoding, const std::string &aOID)
06543   {
06544     SIGNDOC_Exception *ex = NULL;
06545     SIGNDOC_Field_addCertSeedValuePolicy (&ex, p, aEncoding, aOID.c_str ());
06546     if (ex != NULL) SignDoc_throw (ex);
06547   }
06548 
06570   bool setCertSeedValuePolicy (int aIndex, Encoding aEncoding,
06571                                const std::string &aOID)
06572   {
06573     SIGNDOC_Exception *ex = NULL;
06574     bool r;
06575     r = (bool)SIGNDOC_Field_setCertSeedValuePolicyByIndex (&ex, p, aIndex, aEncoding, aOID.c_str ());
06576     if (ex != NULL) SignDoc_throw (ex);
06577     return r;
06578   }
06579 
06600   void setCertSeedValuePolicy (Encoding aEncoding, const std::string &aOID)
06601   {
06602     SIGNDOC_Exception *ex = NULL;
06603     SIGNDOC_Field_setCertSeedValuePolicy (&ex, p, aEncoding, aOID.c_str ());
06604     if (ex != NULL) SignDoc_throw (ex);
06605   }
06606 
06618   bool removeCertSeedValuePolicy (int aIndex)
06619   {
06620     SIGNDOC_Exception *ex = NULL;
06621     bool r;
06622     r = (bool)SIGNDOC_Field_removeCertSeedValuePolicy (&ex, p, aIndex);
06623     if (ex != NULL) SignDoc_throw (ex);
06624     return r;
06625   }
06626 
06643   std::string getSeedValueTimeStampServerURL (Encoding aEncoding) const
06644   {
06645     SIGNDOC_Exception *ex = NULL;
06646     std::string r;
06647     char *s = SIGNDOC_Field_getSeedValueTimeStampServerURL (&ex, p, aEncoding);
06648     if (ex != NULL) SignDoc_throw (ex);
06649     try
06650       {
06651         r = s;
06652       }
06653     catch (...)
06654       {
06655         SIGNDOC_free (s);
06656         throw;
06657       }
06658     SIGNDOC_free (s);
06659     return r;
06660   }
06661 
06676   bool getSeedValueTimeStampRequired () const
06677   {
06678     SIGNDOC_Exception *ex = NULL;
06679     bool r;
06680     r = (bool)SIGNDOC_Field_getSeedValueTimeStampRequired (&ex, p);
06681     if (ex != NULL) SignDoc_throw (ex);
06682     return r;
06683   }
06684 
06706   bool setSeedValueTimeStamp (Encoding aEncoding, const std::string &aURL,
06707                               bool aRequired)
06708   {
06709     SIGNDOC_Exception *ex = NULL;
06710     bool r;
06711     r = (bool)SIGNDOC_Field_setSeedValueTimeStamp (&ex, p, aEncoding, aURL.c_str (), aRequired);
06712     if (ex != NULL) SignDoc_throw (ex);
06713     return r;
06714   }
06715 
06733   std::string getSeedValueFilter (Encoding aEncoding) const
06734   {
06735     SIGNDOC_Exception *ex = NULL;
06736     std::string r;
06737     char *s = SIGNDOC_Field_getSeedValueFilter (&ex, p, aEncoding);
06738     if (ex != NULL) SignDoc_throw (ex);
06739     try
06740       {
06741         r = s;
06742       }
06743     catch (...)
06744       {
06745         SIGNDOC_free (s);
06746         throw;
06747       }
06748     SIGNDOC_free (s);
06749     return r;
06750   }
06751 
06767   bool getSeedValueFilterRequired () const
06768   {
06769     SIGNDOC_Exception *ex = NULL;
06770     bool r;
06771     r = (bool)SIGNDOC_Field_getSeedValueFilterRequired (&ex, p);
06772     if (ex != NULL) SignDoc_throw (ex);
06773     return r;
06774   }
06775 
06798   bool setSeedValueFilter (Encoding aEncoding, const std::string &aFilter,
06799                            bool aRequired)
06800   {
06801     SIGNDOC_Exception *ex = NULL;
06802     bool r;
06803     r = (bool)SIGNDOC_Field_setSeedValueFilter (&ex, p, aEncoding, aFilter.c_str (), aRequired);
06804     if (ex != NULL) SignDoc_throw (ex);
06805     return r;
06806   }
06807 
06817   int getSeedValueSubFilterCount () const
06818   {
06819     SIGNDOC_Exception *ex = NULL;
06820     int r;
06821     r = SIGNDOC_Field_getSeedValueSubFilterCount (&ex, p);
06822     if (ex != NULL) SignDoc_throw (ex);
06823     return r;
06824   }
06825 
06849   std::string getSeedValueSubFilter (Encoding aEncoding, int aIndex) const
06850   {
06851     SIGNDOC_Exception *ex = NULL;
06852     std::string r;
06853     char *s = SIGNDOC_Field_getSeedValueSubFilter (&ex, p, aEncoding, aIndex);
06854     if (ex != NULL) SignDoc_throw (ex);
06855     try
06856       {
06857         r = s;
06858       }
06859     catch (...)
06860       {
06861         SIGNDOC_free (s);
06862         throw;
06863       }
06864     SIGNDOC_free (s);
06865     return r;
06866   }
06867 
06882   bool getSeedValueSubFilterRequired () const
06883   {
06884     SIGNDOC_Exception *ex = NULL;
06885     bool r;
06886     r = (bool)SIGNDOC_Field_getSeedValueSubFilterRequired (&ex, p);
06887     if (ex != NULL) SignDoc_throw (ex);
06888     return r;
06889   }
06890 
06904   void setSeedValueSubFilterRequired (bool aRequired) const
06905   {
06906     SIGNDOC_Exception *ex = NULL;
06907     SIGNDOC_Field_setSeedValueSubFilterRequired (&ex, p, aRequired);
06908     if (ex != NULL) SignDoc_throw (ex);
06909   }
06910 
06926   const char *getSeedValueSubFilterUTF8 (int aIndex) const
06927   {
06928     SIGNDOC_Exception *ex = NULL;
06929     const char *r;
06930     r = SIGNDOC_Field_getSeedValueSubFilterUTF8 (&ex, p, aIndex);
06931     if (ex != NULL) SignDoc_throw (ex);
06932     return r;
06933   }
06934 
06944   void clearSeedValueSubFilters ()
06945   {
06946     SIGNDOC_Exception *ex = NULL;
06947     SIGNDOC_Field_clearSeedValueSubFilters (&ex, p);
06948     if (ex != NULL) SignDoc_throw (ex);
06949   }
06950 
06965   void addSeedValueSubFilter (Encoding aEncoding,
06966                               const std::string &aSubFilter)
06967   {
06968     SIGNDOC_Exception *ex = NULL;
06969     SIGNDOC_Field_addSeedValueSubFilter (&ex, p, aEncoding, aSubFilter.c_str ());
06970     if (ex != NULL) SignDoc_throw (ex);
06971   }
06972 
06992   bool setSeedValueSubFilter (int aIndex, Encoding aEncoding,
06993                               const std::string &aSubFilter)
06994   {
06995     SIGNDOC_Exception *ex = NULL;
06996     bool r;
06997     r = (bool)SIGNDOC_Field_setSeedValueSubFilterByIndex (&ex, p, aIndex, aEncoding, aSubFilter.c_str ());
06998     if (ex != NULL) SignDoc_throw (ex);
06999     return r;
07000   }
07001 
07021   void setSeedValueSubFilter (Encoding aEncoding,
07022                               const std::string &aSubFilter)
07023   {
07024     SIGNDOC_Exception *ex = NULL;
07025     SIGNDOC_Field_setSeedValueSubFilter (&ex, p, aEncoding, aSubFilter.c_str ());
07026     if (ex != NULL) SignDoc_throw (ex);
07027   }
07028 
07041   bool removeSeedValueSubFilter (int aIndex)
07042   {
07043     SIGNDOC_Exception *ex = NULL;
07044     bool r;
07045     r = (bool)SIGNDOC_Field_removeSeedValueSubFilter (&ex, p, aIndex);
07046     if (ex != NULL) SignDoc_throw (ex);
07047     return r;
07048   }
07049 
07059   int getSeedValueDigestMethodCount () const
07060   {
07061     SIGNDOC_Exception *ex = NULL;
07062     int r;
07063     r = SIGNDOC_Field_getSeedValueDigestMethodCount (&ex, p);
07064     if (ex != NULL) SignDoc_throw (ex);
07065     return r;
07066   }
07067 
07099   std::string getSeedValueDigestMethod (Encoding aEncoding, int aIndex) const
07100   {
07101     SIGNDOC_Exception *ex = NULL;
07102     std::string r;
07103     char *s = SIGNDOC_Field_getSeedValueDigestMethod (&ex, p, aEncoding, aIndex);
07104     if (ex != NULL) SignDoc_throw (ex);
07105     try
07106       {
07107         r = s;
07108       }
07109     catch (...)
07110       {
07111         SIGNDOC_free (s);
07112         throw;
07113       }
07114     SIGNDOC_free (s);
07115     return r;
07116   }
07117 
07132   bool getSeedValueDigestMethodRequired () const
07133   {
07134     SIGNDOC_Exception *ex = NULL;
07135     bool r;
07136     r = (bool)SIGNDOC_Field_getSeedValueDigestMethodRequired (&ex, p);
07137     if (ex != NULL) SignDoc_throw (ex);
07138     return r;
07139   }
07140 
07154   void setSeedValueDigestMethodRequired (bool aRequired) const
07155   {
07156     SIGNDOC_Exception *ex = NULL;
07157     SIGNDOC_Field_setSeedValueDigestMethodRequired (&ex, p, aRequired);
07158     if (ex != NULL) SignDoc_throw (ex);
07159   }
07160 
07176   const char *getSeedValueDigestMethodUTF8 (int aIndex) const
07177   {
07178     SIGNDOC_Exception *ex = NULL;
07179     const char *r;
07180     r = SIGNDOC_Field_getSeedValueDigestMethodUTF8 (&ex, p, aIndex);
07181     if (ex != NULL) SignDoc_throw (ex);
07182     return r;
07183   }
07184 
07194   void clearSeedValueDigestMethods ()
07195   {
07196     SIGNDOC_Exception *ex = NULL;
07197     SIGNDOC_Field_clearSeedValueDigestMethods (&ex, p);
07198     if (ex != NULL) SignDoc_throw (ex);
07199   }
07200 
07215   void addSeedValueDigestMethod (Encoding aEncoding,
07216                                  const std::string &aDigestMethod)
07217   {
07218     SIGNDOC_Exception *ex = NULL;
07219     SIGNDOC_Field_addSeedValueDigestMethod (&ex, p, aEncoding, aDigestMethod.c_str ());
07220     if (ex != NULL) SignDoc_throw (ex);
07221   }
07222 
07242   bool setSeedValueDigestMethod (int aIndex, Encoding aEncoding,
07243                                  const std::string &aDigestMethod)
07244   {
07245     SIGNDOC_Exception *ex = NULL;
07246     bool r;
07247     r = (bool)SIGNDOC_Field_setSeedValueDigestMethodByIndex (&ex, p, aIndex, aEncoding, aDigestMethod.c_str ());
07248     if (ex != NULL) SignDoc_throw (ex);
07249     return r;
07250   }
07251 
07271   void setSeedValueDigestMethod (Encoding aEncoding,
07272                                  const std::string &aDigestMethod)
07273   {
07274     SIGNDOC_Exception *ex = NULL;
07275     SIGNDOC_Field_setSeedValueDigestMethod (&ex, p, aEncoding, aDigestMethod.c_str ());
07276     if (ex != NULL) SignDoc_throw (ex);
07277   }
07278 
07291   bool removeSeedValueDigestMethod (int aIndex)
07292   {
07293     SIGNDOC_Exception *ex = NULL;
07294     bool r;
07295     r = (bool)SIGNDOC_Field_removeSeedValueDigestMethod (&ex, p, aIndex);
07296     if (ex != NULL) SignDoc_throw (ex);
07297     return r;
07298   }
07299 
07313   bool getSeedValueAddRevInfo () const
07314   {
07315     SIGNDOC_Exception *ex = NULL;
07316     bool r;
07317     r = (bool)SIGNDOC_Field_getSeedValueAddRevInfo (&ex, p);
07318     if (ex != NULL) SignDoc_throw (ex);
07319     return r;
07320   }
07321 
07337   void setSeedValueAddRevInfo (bool aAddRevInfo)
07338   {
07339     SIGNDOC_Exception *ex = NULL;
07340     SIGNDOC_Field_setSeedValueAddRevInfo (&ex, p, aAddRevInfo);
07341     if (ex != NULL) SignDoc_throw (ex);
07342   }
07343 
07361   int getSeedValueMDP () const
07362   {
07363     SIGNDOC_Exception *ex = NULL;
07364     int r;
07365     r = SIGNDOC_Field_getSeedValueMDP (&ex, p);
07366     if (ex != NULL) SignDoc_throw (ex);
07367     return r;
07368   }
07369 
07392   bool setSeedValueMDP (int aMDP)
07393   {
07394     SIGNDOC_Exception *ex = NULL;
07395     bool r;
07396     r = (bool)SIGNDOC_Field_setSeedValueMDP (&ex, p, aMDP);
07397     if (ex != NULL) SignDoc_throw (ex);
07398     return r;
07399   }
07400 
07413   SignDocColor *getEmptyFieldColor () const
07414   {
07415     SIGNDOC_Exception *ex = NULL;
07416     SIGNDOC_Color *r;
07417     r = SIGNDOC_Field_getEmptyFieldColor (&ex, p);
07418     if (ex != NULL) SignDoc_throw (ex);
07419     if (r == NULL)
07420       return NULL;
07421     try
07422       {
07423         return new SignDocColor (r);
07424       }
07425     catch (...)
07426       {
07427         SIGNDOC_Color_delete (r);
07428         throw;
07429       }
07430   }
07431 
07443   void setEmptyFieldColor (const SignDocColor &aColor)
07444   {
07445     SIGNDOC_Exception *ex = NULL;
07446     SIGNDOC_Field_setEmptyFieldColor (&ex, p, aColor.getImpl ());
07447     if (ex != NULL) SignDoc_throw (ex);
07448   }
07449 
07450 private:
07451 public:
07456   SignDocField (SIGNDOC_Field *aP) : p (aP) { }
07457 
07462   SIGNDOC_Field *getImpl () { return p; }
07463 
07468   const SIGNDOC_Field *getImpl () const { return p; }
07469 
07474   void setImpl (SIGNDOC_Field *aP) { SIGNDOC_Field_delete (p); p  = aP; }
07475 
07476 private:
07477   SIGNDOC_Field *p;
07478 };
07479 
07484 inline void assignArray (std::vector<SignDocField> &aDst,
07485                          SIGNDOC_FieldArray *aSrc)
07486 {
07487   aDst.clear ();
07488   unsigned n = SIGNDOC_FieldArray_count (aSrc);
07489   if (aSrc == NULL)
07490     return;
07491   aDst.resize (n);
07492   for (unsigned i = 0; i < n; ++i)
07493     {
07494       SIGNDOC_Exception *ex = NULL;
07495       SIGNDOC_Field *p = SIGNDOC_Field_clone (&ex, SIGNDOC_FieldArray_at (aSrc, i));
07496       if (ex != NULL) SignDoc_throw (ex);
07497       aDst[i].setImpl (p);
07498     }
07499 }
07500 
07941 class SignDocSignatureParameters 
07942 {
07943 public:
07952   enum Method
07953   {
07968     m_default,
07969 
07975     m_digsig_pkcs1,
07976 
07980     m_digsig_pkcs7_detached,
07981 
07982     /*+
07983      * @brief PKCS #7 with SHA-1 (deprecated).
07984      */
07985     m_digsig_pkcs7_sha1,
07986 
07987     /*+
07988      * @brief The signature is just a hash (TIFF only).
07989      */
07990     m_hash,
07991 
07992     /*+
07993      * @brief Detached ETSI CAdES (PAdES-BES).
07994      */
07995     m_digsig_cades_detached,
07996 
07997     /*+
07998      * @brief ETSI CAdES RFC 3161 time stamp.
07999      */
08000     m_digsig_cades_rfc3161
08001   };
08002 
08019   enum DetachedHashAlgorithm
08020   {
08032     dha_default,
08033 
08034     dha_sha1,                  
08035     dha_sha256,                
08036     dha_sha384,                
08037     dha_sha512,                
08038     dha_ripemd160,             
08039     dha_sha224                 
08040   };
08041 
08047   enum AddCertificates
08048   {
08057     ac_all,
08058 
08066     ac_none,
08067 
08076     ac_trusted
08077   };
08078 
08084   enum AddRevocationInfo
08085   {
08094     ari_add = 0x01
08095   };
08096 
08102   enum RemoveXFA
08103   {
08111     rx_always,
08112 
08120     rx_if_allowed,
08121 
08128     rx_never
08129   };
08130 
08141   enum TimeStampHashAlgorithm
08142   {
08159     tsha_default,
08160 
08161     tsha_sha1,                  
08162     tsha_sha256,                
08163     tsha_sha384,                
08164     tsha_sha512                 
08165   };
08166 
08174   enum Optimize
08175   {
08176     o_optimize,               
08177     o_dont_optimize           
08178   };
08179 
08193   enum PDFAButtons
08194   {
08206     pb_freeze,
08207 
08215     pb_dont_freeze,
08216 
08231     pb_auto
08232   };
08233 
08241   enum CertificateSigningAlgorithm
08242   {
08243     csa_sha1_rsa,               
08244     csa_md5_rsa,                
08245     csa_sha256_rsa,             
08246     csa_sha384_rsa,             
08247     csa_sha512_rsa,             
08248     csa_ripemd160_rsa,          
08249     csa_ecdsa_sha1,             
08250     csa_ecdsa_sha224,           
08251     csa_ecdsa_sha256,           
08252     csa_ecdsa_sha384,           
08253     csa_ecdsa_sha512            
08254   };
08255 
08261   enum RSASignatureScheme
08262   {
08270     rss_pkcs1,
08271 
08285     rss_pss
08286   };
08287 
08297   enum BiometricEncryption
08298   {
08307     be_rsa,
08308 
08312     be_fixed,
08313 
08319     be_binary,
08320 
08326     be_passphrase,
08327 
08337     be_dont_store
08338   };
08339 
08348   enum BiometricHashLocation
08349   {
08361     bhl_attr,
08362 
08370     bhl_contents
08371   };
08372 
08379   enum HAlignment
08380   {
08384     ha_left,
08385 
08389     ha_center,
08390 
08394     ha_right,
08395 
08402     ha_justify,
08403 
08408     ha_auto,
08409 
08413     ha_default = -1
08414   };
08415 
08422   enum VAlignment
08423   {
08427     va_top,
08428 
08432     va_center,
08433 
08437     va_bottom
08438   };
08439 
08445   enum TextPosition
08446   {
08447     tp_overlay,       
08448     tp_below,         
08449     tp_underlay,      
08450     tp_right_of,      
08451     tp_above,         
08452     tp_left_of        
08453   };
08454 
08460   enum ValueType
08461   {
08462     vt_abs,                   
08463     vt_field_height,          
08464     vt_field_width            
08465   };
08466 
08472   enum TextItem
08473   {
08474     ti_signer,                
08475     ti_sign_time,             
08476     ti_comment,               
08477     ti_adviser,               
08478     ti_contact_info,          
08479     ti_location,              
08480     ti_reason,                
08481     ti_text1,                 
08482     ti_text2,                 
08483     ti_text3,                 
08484     ti_text4,                 
08485     ti_text5,                 
08486     ti_text6,                 
08487     ti_text7,                 
08488     ti_text8,                 
08489     ti_text9                  
08490   };
08491 
08507   enum TextGroup
08508   {
08509     tg_master,                
08510     tg_slave                  
08511   };
08512 
08516   enum TextItemDirection
08517   {
08521     tid_ltr = 0x1000,
08522 
08526     tid_rtl = 0x2000,
08527 
08538     tid_default_ltr = 0x4000,
08539 
08550     tid_default_rtl = 0x8000
08551   };
08552 
08563   enum IgnoreSeedValues
08564   {
08578     isv_SubFilter = 0x01,
08579 
08594     isv_DigestMethod = 0x02
08595   };
08596 
08604   enum CertificateSelectionFlags
08605   {
08616     csf_software = 0x01,
08617 
08628     csf_hardware = 0x02,
08629 
08630     csf_use_certificate_seed_values = 0x10, 
08631     csf_ask_if_ambiguous = 0x20, 
08632     csf_never_ask = 0x40,       
08633     csf_create_self_signed = 0x80 
08634   };
08635 
08645   enum RenderSignatureFlags
08646   {
08650     rsf_bw   = 0x01,
08651 
08655     rsf_gray = 0x02,
08656 
08660     rsf_antialias = 0x04,
08661 
08674     rsf_limit_size = 0x08
08675   };
08676 
08693   enum ImageTransparency
08694   {
08700     it_opaque,
08701 
08710     it_brightest
08711   };
08712 
08716   enum ReturnCode
08717   {
08718     rc_ok,                      
08719     rc_unknown,                 
08720     rc_not_supported,           
08721     rc_invalid_value            
08722   };
08723 
08732   enum ParameterState
08733   {
08734     ps_set,             
08735     ps_missing,         
08736     ps_supported,       
08737     ps_ignored,         
08738     ps_not_supported,   
08739     ps_unknown          
08740   };
08741 
08742 public:
08749   SignDocSignatureParameters ()
08750     : p (NULL)
08751   {
08752   }
08753 
08760   ~SignDocSignatureParameters ()
08761   {
08762     SIGNDOC_SignatureParameters_delete (p);
08763   }
08764 
08772   ParameterState getState (const std::string &aName)
08773   {
08774     SIGNDOC_Exception *ex = NULL;
08775     ParameterState r;
08776     r = (ParameterState)SIGNDOC_SignatureParameters_getState (&ex, p, aName.c_str ());
08777     if (ex != NULL) SignDoc_throw (ex);
08778     return r;
08779   }
08780 
09096   ReturnCode setString (Encoding aEncoding, const std::string &aName,
09097                         const std::string &aValue)
09098   {
09099     SIGNDOC_Exception *ex = NULL;
09100     ReturnCode r;
09101     r = (ReturnCode)SIGNDOC_SignatureParameters_setString (&ex, p, aEncoding, aName.c_str (), aValue.c_str ());
09102     if (ex != NULL) SignDoc_throw (ex);
09103     return r;
09104   }
09105 
09117   ReturnCode setString (const std::string &aName, const wchar_t *aValue)
09118   {
09119     SIGNDOC_Exception *ex = NULL;
09120     ReturnCode r;
09121     r = (ReturnCode)SIGNDOC_SignatureParameters_setStringW (&ex, p, aName.c_str (), aValue);
09122     if (ex != NULL) SignDoc_throw (ex);
09123     return r;
09124   }
09125 
09452   ReturnCode setInteger (const std::string &aName, int aValue)
09453   {
09454     SIGNDOC_Exception *ex = NULL;
09455     ReturnCode r;
09456     r = (ReturnCode)SIGNDOC_SignatureParameters_setInteger (&ex, p, aName.c_str (), aValue);
09457     if (ex != NULL) SignDoc_throw (ex);
09458     return r;
09459   }
09460 
09594   ReturnCode setBlob (const std::string &aName, const unsigned char *aData,
09595                       size_t aSize)
09596   {
09597     SIGNDOC_Exception *ex = NULL;
09598     ReturnCode r;
09599     r = (ReturnCode)SIGNDOC_SignatureParameters_setBlob (&ex, p, aName.c_str (), aData, aSize);
09600     if (ex != NULL) SignDoc_throw (ex);
09601     return r;
09602   }
09603 
09660   ReturnCode setLength (const std::string &aName, ValueType aType,
09661                         double aValue)
09662   {
09663     SIGNDOC_Exception *ex = NULL;
09664     ReturnCode r;
09665     r = (ReturnCode)SIGNDOC_SignatureParameters_setLength (&ex, p, aName.c_str (), aType, aValue);
09666     if (ex != NULL) SignDoc_throw (ex);
09667     return r;
09668   }
09669 
09694   ReturnCode setColor (const std::string &aName, const SignDocColor &aValue)
09695   {
09696     SIGNDOC_Exception *ex = NULL;
09697     ReturnCode r;
09698     r = (ReturnCode)SIGNDOC_SignatureParameters_setColor (&ex, p, aName.c_str (), aValue.getImpl ());
09699     if (ex != NULL) SignDoc_throw (ex);
09700     return r;
09701   }
09702 
09727   ReturnCode addTextItem (TextItem aItem, TextGroup aGroup)
09728   {
09729     SIGNDOC_Exception *ex = NULL;
09730     ReturnCode r;
09731     r = (ReturnCode)SIGNDOC_SignatureParameters_addTextItem (&ex, p, aItem, aGroup);
09732     if (ex != NULL) SignDoc_throw (ex);
09733     return r;
09734   }
09735 
09766   ReturnCode addTextItem2 (TextItem aItem, TextGroup aGroup,
09767                            HAlignment aHAlignment, int aDirection)
09768   {
09769     SIGNDOC_Exception *ex = NULL;
09770     ReturnCode r;
09771     r = (ReturnCode)SIGNDOC_SignatureParameters_addTextItem2 (&ex, p, aItem, aGroup, aHAlignment, aDirection);
09772     if (ex != NULL) SignDoc_throw (ex);
09773     return r;
09774   }
09775 
09788   ReturnCode clearTextItems ()
09789   {
09790     SIGNDOC_Exception *ex = NULL;
09791     ReturnCode r;
09792     r = (ReturnCode)SIGNDOC_SignatureParameters_clearTextItems (&ex, p);
09793     if (ex != NULL) SignDoc_throw (ex);
09794     return r;
09795   }
09796 
09817   ReturnCode setTextItemDirection (TextItem aItem, HAlignment aHAlignment,
09818                                    int aDirection)
09819   {
09820     SIGNDOC_Exception *ex = NULL;
09821     ReturnCode r;
09822     r = (ReturnCode)SIGNDOC_SignatureParameters_setTextItemDirection (&ex, p, aItem, aHAlignment, aDirection);
09823     if (ex != NULL) SignDoc_throw (ex);
09824     return r;
09825   }
09826 
09869   ReturnCode setPKCS7 (SignPKCS7 *aPKCS7)
09870   {
09871     SIGNDOC_Exception *ex = NULL;
09872     ReturnCode r;
09873     r = (ReturnCode)SIGNDOC_SignatureParameters_setPKCS7 (&ex, p, aPKCS7 == NULL ? NULL : aPKCS7->getImpl ());
09874     if (ex != NULL) SignDoc_throw (ex);
09875     return r;
09876   }
09877 
09907   ReturnCode setRSA (SignRSA *aRSA)
09908   {
09909     SIGNDOC_Exception *ex = NULL;
09910     ReturnCode r;
09911     r = (ReturnCode)SIGNDOC_SignatureParameters_setRSA (&ex, p, aRSA == NULL ? NULL : aRSA->getImpl ());
09912     if (ex != NULL) SignDoc_throw (ex);
09913     return r;
09914   }
09915 
09945   ReturnCode setECDSA (SignECDSA *aECDSA)
09946   {
09947     SIGNDOC_Exception *ex = NULL;
09948     ReturnCode r;
09949     r = (ReturnCode)SIGNDOC_SignatureParameters_setECDSA (&ex, p, aECDSA == NULL ? NULL : aECDSA->getImpl ());
09950     if (ex != NULL) SignDoc_throw (ex);
09951     return r;
09952   }
09953 
09962   int getAvailableMethods ()
09963   {
09964     SIGNDOC_Exception *ex = NULL;
09965     int r;
09966     r = SIGNDOC_SignatureParameters_getAvailableMethods (&ex, p);
09967     if (ex != NULL) SignDoc_throw (ex);
09968     return r;
09969   }
09970 
09983   ReturnCode getTemplate (std::vector<unsigned char> &aOutput)
09984   {
09985     SIGNDOC_Exception *ex = NULL;
09986     SIGNDOC_ByteArray *tempOutput = NULL;
09987     ReturnCode r;
09988     try
09989       {
09990         tempOutput = SIGNDOC_ByteArray_new (&ex);
09991         if (ex != NULL) SignDoc_throw (ex);
09992         r = (ReturnCode)SIGNDOC_SignatureParameters_getTemplate (&ex, p, tempOutput);
09993         assignArray (aOutput, tempOutput);
09994       }
09995     catch (...)
09996       {
09997         if (tempOutput != NULL)
09998           SIGNDOC_ByteArray_delete (tempOutput);
09999         throw;
10000       }
10001     if (tempOutput != NULL)
10002       SIGNDOC_ByteArray_delete (tempOutput);
10003     if (ex != NULL) SignDoc_throw (ex);
10004     return r;
10005   }
10006 
10020   const char *getErrorMessage (Encoding aEncoding) const
10021   {
10022     SIGNDOC_Exception *ex = NULL;
10023     const char *r;
10024     r = SIGNDOC_SignatureParameters_getErrorMessage (&ex, p, aEncoding);
10025     if (ex != NULL) SignDoc_throw (ex);
10026     return r;
10027   }
10028 
10040   const wchar_t *getErrorMessageW () const
10041   {
10042     SIGNDOC_Exception *ex = NULL;
10043     const wchar_t *r;
10044     r = SIGNDOC_SignatureParameters_getErrorMessageW (&ex, p);
10045     if (ex != NULL) SignDoc_throw (ex);
10046     return r;
10047   }
10048 
10049 private:
10053   SignDocSignatureParameters (const SignDocSignatureParameters &);
10054 
10058   SignDocSignatureParameters &operator= (const SignDocSignatureParameters &);
10059 public:
10064   SignDocSignatureParameters (SIGNDOC_SignatureParameters *aP) : p (aP) { }
10065 
10070   SIGNDOC_SignatureParameters *getImpl () { return p; }
10071 
10076   const SIGNDOC_SignatureParameters *getImpl () const { return p; }
10077 
10082   void setImpl (SIGNDOC_SignatureParameters *aP) { SIGNDOC_SignatureParameters_delete (p); p  = aP; }
10083 
10084 private:
10085   SIGNDOC_SignatureParameters *p;
10086 };
10087 
10096 class SignDocProperty 
10097 {
10098 public:
10099 
10100 public:
10104   enum Type
10105   {
10106     t_string,
10107     t_integer,
10108     t_boolean
10109   };
10110 
10111 public:
10115   SignDocProperty ()
10116     : p (NULL)
10117   {
10118     SIGNDOC_Exception *ex = NULL;
10119     p = SIGNDOC_Property_new (&ex);
10120     if (ex != NULL) SignDoc_throw (ex);
10121   }
10122 
10128   SignDocProperty (const SignDocProperty &aSource)
10129     : p (NULL)
10130   {
10131     SIGNDOC_Exception *ex = NULL;
10132     p = SIGNDOC_Property_clone (&ex, aSource.getImpl ());
10133     if (ex != NULL) SignDoc_throw (ex);
10134   }
10135 
10139   ~SignDocProperty ()
10140   {
10141     SIGNDOC_Property_delete (p);
10142   }
10143 
10149   void swap (SignDocProperty &aOther)
10150   {
10151     std::swap (p, aOther.p);
10152   }
10153 
10169   std::string getName (Encoding aEncoding) const
10170   {
10171     SIGNDOC_Exception *ex = NULL;
10172     std::string r;
10173     char *s = SIGNDOC_Property_getName (&ex, p, aEncoding);
10174     if (ex != NULL) SignDoc_throw (ex);
10175     try
10176       {
10177         r = s;
10178       }
10179     catch (...)
10180       {
10181         SIGNDOC_free (s);
10182         throw;
10183       }
10184     SIGNDOC_free (s);
10185     return r;
10186   }
10187 
10199   const char *getNameUTF8 () const
10200   {
10201     SIGNDOC_Exception *ex = NULL;
10202     const char *r;
10203     r = SIGNDOC_Property_getNameUTF8 (&ex, p);
10204     if (ex != NULL) SignDoc_throw (ex);
10205     return r;
10206   }
10207 
10213   Type getType () const
10214   {
10215     SIGNDOC_Exception *ex = NULL;
10216     Type r;
10217     r = (Type)SIGNDOC_Property_getType (&ex, p);
10218     if (ex != NULL) SignDoc_throw (ex);
10219     return r;
10220   }
10221 
10222 private:
10223 public:
10228   SignDocProperty (SIGNDOC_Property *aP) : p (aP) { }
10229 
10234   SIGNDOC_Property *getImpl () { return p; }
10235 
10240   const SIGNDOC_Property *getImpl () const { return p; }
10241 
10246   void setImpl (SIGNDOC_Property *aP) { SIGNDOC_Property_delete (p); p  = aP; }
10247 
10248 private:
10249   SIGNDOC_Property *p;
10250 };
10251 
10256 inline void assignArray (std::vector<SignDocProperty> &aDst,
10257                          SIGNDOC_PropertyArray *aSrc)
10258 {
10259   aDst.clear ();
10260   unsigned n = SIGNDOC_PropertyArray_count (aSrc);
10261   if (aSrc == NULL)
10262     return;
10263   aDst.resize (n);
10264   for (unsigned i = 0; i < n; ++i)
10265     {
10266       SIGNDOC_Exception *ex = NULL;
10267       SIGNDOC_Property *p = SIGNDOC_Property_clone (&ex, SIGNDOC_PropertyArray_at (aSrc, i));
10268       if (ex != NULL) SignDoc_throw (ex);
10269       aDst[i].setImpl (p);
10270     }
10271 }
10272 
10280 class SignDocAnnotation 
10281 {
10282 public:
10288   enum Type
10289   {
10290     t_unknown,              
10291     t_line,                 
10292     t_scribble,             
10293     t_freetext              
10294   };
10295 
10299   enum LineEnding
10300   {
10301     le_unknown,             
10302     le_none,                
10303     le_arrow                
10304   };
10305 
10309   enum HAlignment
10310   {
10314     ha_left,
10315 
10319     ha_center,
10320 
10324     ha_right
10325   };
10326 
10330   enum Flags
10331   {
10340     f_auto_alignment = 0x200,
10341 
10353     f_ltr = 0x1000,
10354 
10374     f_rtl = 0x2000,
10375 
10402     f_default_ltr = 0x4000,
10403 
10430     f_default_rtl = 0x8000
10431   };
10432 
10436   enum ReturnCode
10437   {
10438     rc_ok,                      
10439     rc_not_supported,           
10440     rc_invalid_value,           
10441     rc_not_available            
10442   };
10443 
10444 protected:
10448   SignDocAnnotation ()
10449     : p (NULL)
10450   {
10451   }
10452 
10453 public:
10457   ~SignDocAnnotation ()
10458   {
10459     SIGNDOC_Annotation_delete (p);
10460   }
10461 
10467   Type getType () const
10468   {
10469     SIGNDOC_Exception *ex = NULL;
10470     Type r;
10471     r = (Type)SIGNDOC_Annotation_getType (&ex, p);
10472     if (ex != NULL) SignDoc_throw (ex);
10473     return r;
10474   }
10475 
10487   std::string getName (Encoding aEncoding) const
10488   {
10489     SIGNDOC_Exception *ex = NULL;
10490     std::string r;
10491     char *s = SIGNDOC_Annotation_getName (&ex, p, aEncoding);
10492     if (ex != NULL) SignDoc_throw (ex);
10493     try
10494       {
10495         r = s;
10496       }
10497     catch (...)
10498       {
10499         SIGNDOC_free (s);
10500         throw;
10501       }
10502     SIGNDOC_free (s);
10503     return r;
10504   }
10505 
10515   int getPage () const
10516   {
10517     SIGNDOC_Exception *ex = NULL;
10518     int r;
10519     r = SIGNDOC_Annotation_getPage (&ex, p);
10520     if (ex != NULL) SignDoc_throw (ex);
10521     return r;
10522   }
10523 
10535   ReturnCode getBoundingBox (Rect &aOutput) const
10536   {
10537     SIGNDOC_Exception *ex = NULL;
10538     ReturnCode r;
10539     r = (ReturnCode)SIGNDOC_Annotation_getBoundingBox (&ex, p, (SIGNDOC_Rect*)&aOutput);
10540     if (ex != NULL) SignDoc_throw (ex);
10541     return r;
10542   }
10543 
10556   ReturnCode setName (Encoding aEncoding, const std::string &aName)
10557   {
10558     SIGNDOC_Exception *ex = NULL;
10559     ReturnCode r;
10560     r = (ReturnCode)SIGNDOC_Annotation_setName (&ex, p, aEncoding, aName.c_str ());
10561     if (ex != NULL) SignDoc_throw (ex);
10562     return r;
10563   }
10564 
10576   ReturnCode setName (const wchar_t *aName)
10577   {
10578     SIGNDOC_Exception *ex = NULL;
10579     ReturnCode r;
10580     r = (ReturnCode)SIGNDOC_Annotation_setNameW (&ex, p, aName);
10581     if (ex != NULL) SignDoc_throw (ex);
10582     return r;
10583   }
10584 
10596   ReturnCode setLineEnding (LineEnding aStart, LineEnding aEnd)
10597   {
10598     SIGNDOC_Exception *ex = NULL;
10599     ReturnCode r;
10600     r = (ReturnCode)SIGNDOC_Annotation_setLineEnding (&ex, p, aStart, aEnd);
10601     if (ex != NULL) SignDoc_throw (ex);
10602     return r;
10603   }
10604 
10617   ReturnCode setColor (const SignDocColor &aColor)
10618   {
10619     SIGNDOC_Exception *ex = NULL;
10620     ReturnCode r;
10621     r = (ReturnCode)SIGNDOC_Annotation_setColor (&ex, p, aColor.getImpl ());
10622     if (ex != NULL) SignDoc_throw (ex);
10623     return r;
10624   }
10625 
10637   ReturnCode setBackgroundColor (const SignDocColor &aColor)
10638   {
10639     SIGNDOC_Exception *ex = NULL;
10640     ReturnCode r;
10641     r = (ReturnCode)SIGNDOC_Annotation_setBackgroundColor (&ex, p, aColor.getImpl ());
10642     if (ex != NULL) SignDoc_throw (ex);
10643     return r;
10644   }
10645 
10659   ReturnCode setBorderColor (const SignDocColor &aColor)
10660   {
10661     SIGNDOC_Exception *ex = NULL;
10662     ReturnCode r;
10663     r = (ReturnCode)SIGNDOC_Annotation_setBorderColor (&ex, p, aColor.getImpl ());
10664     if (ex != NULL) SignDoc_throw (ex);
10665     return r;
10666   }
10667 
10681   ReturnCode setOpacity (double aOpacity)
10682   {
10683     SIGNDOC_Exception *ex = NULL;
10684     ReturnCode r;
10685     r = (ReturnCode)SIGNDOC_Annotation_setOpacity (&ex, p, aOpacity);
10686     if (ex != NULL) SignDoc_throw (ex);
10687     return r;
10688   }
10689 
10700   ReturnCode setLineWidthInPoints (double aWidth)
10701   {
10702     SIGNDOC_Exception *ex = NULL;
10703     ReturnCode r;
10704     r = (ReturnCode)SIGNDOC_Annotation_setLineWidthInPoints (&ex, p, aWidth);
10705     if (ex != NULL) SignDoc_throw (ex);
10706     return r;
10707   }
10708 
10722   ReturnCode setBorderLineWidthInPoints (double aWidth)
10723   {
10724     SIGNDOC_Exception *ex = NULL;
10725     ReturnCode r;
10726     r = (ReturnCode)SIGNDOC_Annotation_setBorderLineWidthInPoints (&ex, p, aWidth);
10727     if (ex != NULL) SignDoc_throw (ex);
10728     return r;
10729   }
10730 
10742   ReturnCode newStroke ()
10743   {
10744     SIGNDOC_Exception *ex = NULL;
10745     ReturnCode r;
10746     r = (ReturnCode)SIGNDOC_Annotation_newStroke (&ex, p);
10747     if (ex != NULL) SignDoc_throw (ex);
10748     return r;
10749   }
10750 
10765   ReturnCode addPoint (const Point &aPoint)
10766   {
10767     SIGNDOC_Exception *ex = NULL;
10768     ReturnCode r;
10769     r = (ReturnCode)SIGNDOC_Annotation_addPoint (&ex, p, (const SIGNDOC_Point*)&aPoint);
10770     if (ex != NULL) SignDoc_throw (ex);
10771     return r;
10772   }
10773 
10789   ReturnCode addPoint (double aX, double aY)
10790   {
10791     SIGNDOC_Exception *ex = NULL;
10792     ReturnCode r;
10793     r = (ReturnCode)SIGNDOC_Annotation_addPointXY (&ex, p, aX, aY);
10794     if (ex != NULL) SignDoc_throw (ex);
10795     return r;
10796   }
10797 
10836   ReturnCode setPlainText (Encoding aEncoding, const std::string &aText,
10837                            const std::string &aFont, double aFontSize,
10838                            HAlignment aHAlignment)
10839   {
10840     SIGNDOC_Exception *ex = NULL;
10841     ReturnCode r;
10842     r = (ReturnCode)SIGNDOC_Annotation_setPlainText (&ex, p, aEncoding, aText.c_str (), aFont.c_str (), aFontSize, aHAlignment);
10843     if (ex != NULL) SignDoc_throw (ex);
10844     return r;
10845   }
10846 
10864   ReturnCode getPlainText (Encoding aEncoding, std::string &aText)
10865   {
10866     SIGNDOC_Exception *ex = NULL;
10867     char *tempText = NULL;
10868     ReturnCode r;
10869     try
10870       {
10871         r = (ReturnCode)SIGNDOC_Annotation_getPlainText (&ex, p, aEncoding, &tempText);
10872         if (tempText != NULL)
10873           aText = tempText;
10874       }
10875     catch (...)
10876       {
10877         SIGNDOC_free (tempText);
10878         throw;
10879       }
10880     SIGNDOC_free (tempText);
10881     if (ex != NULL) SignDoc_throw (ex);
10882     return r;
10883   }
10884 
10901   ReturnCode getFont (Encoding aEncoding, std::string &aFont,
10902                       double &aFontSize)
10903   {
10904     SIGNDOC_Exception *ex = NULL;
10905     char *tempFont = NULL;
10906     ReturnCode r;
10907     try
10908       {
10909         r = (ReturnCode)SIGNDOC_Annotation_getFont (&ex, p, aEncoding, &tempFont, &aFontSize);
10910         if (tempFont != NULL)
10911           aFont = tempFont;
10912       }
10913     catch (...)
10914       {
10915         SIGNDOC_free (tempFont);
10916         throw;
10917       }
10918     SIGNDOC_free (tempFont);
10919     if (ex != NULL) SignDoc_throw (ex);
10920     return r;
10921   }
10922 
10935   ReturnCode setFlags (int aFlags)
10936   {
10937     SIGNDOC_Exception *ex = NULL;
10938     ReturnCode r;
10939     r = (ReturnCode)SIGNDOC_Annotation_setFlags (&ex, p, aFlags);
10940     if (ex != NULL) SignDoc_throw (ex);
10941     return r;
10942   }
10947   SignDocAnnotation (SIGNDOC_Annotation *aP) : p (aP) { }
10948 
10953   SIGNDOC_Annotation *getImpl () { return p; }
10954 
10959   const SIGNDOC_Annotation *getImpl () const { return p; }
10960 
10965   void setImpl (SIGNDOC_Annotation *aP) { SIGNDOC_Annotation_delete (p); p  = aP; }
10966 
10967 private:
10968   SIGNDOC_Annotation *p;
10969 };
10970 
10976 class SignDocCharacterPosition 
10977 {
10978 public:
10979   int mPage;                    
10980   Point mRef; 
10981   Rect mBox;  
10982 };
10983 
10987 class SignDocFindTextPosition 
10988 {
10989 public:
10990   SignDocCharacterPosition mFirst;   
10991   SignDocCharacterPosition mLast;    
10992 };
10993 
10998 inline void assignArray (std::vector<SignDocFindTextPosition> &aDst,
10999                          SIGNDOC_FindTextPositionArray *aSrc)
11000 {
11001   if (aSrc == NULL)
11002     aDst.clear ();
11003   else
11004     {
11005       unsigned n = SIGNDOC_FindTextPositionArray_count (aSrc);
11006       aDst.resize (n);
11007       for (unsigned i = 0; i < n; ++i)
11008         aDst[i] = *(const SignDocFindTextPosition*)SIGNDOC_FindTextPositionArray_at (aSrc, i);
11009     }
11010 }
11011 
11015 class SignDocRenderParameters 
11016 {
11017 public:
11021   enum Interlacing
11022   {
11026     i_off,
11027 
11033     i_on
11034   };
11035 
11039   enum Quality
11040   {
11044     q_low,
11045 
11049     q_high
11050   };
11051 
11055   enum PixelFormat
11056   {
11060     pf_default,
11061 
11065     pf_bw
11066   };
11067 
11074   enum Compression
11075   {
11076     c_default,     
11077     c_none,        
11078     c_group4,      
11079     c_lzw,         
11080     c_rle,         
11081     c_zip          
11082   };
11083 
11089   enum DecorationState
11090   {
11091     ds_auto,       
11092     ds_empty,      
11093     ds_ok,         
11094     ds_problem,    
11095     ds_broken      
11096   };
11097 
11098 public:
11102   SignDocRenderParameters ()
11103     : p (NULL)
11104   {
11105     SIGNDOC_Exception *ex = NULL;
11106     p = SIGNDOC_RenderParameters_new (&ex);
11107     if (ex != NULL) SignDoc_throw (ex);
11108   }
11109 
11115   SignDocRenderParameters (const SignDocRenderParameters &aSource)
11116     : p (NULL)
11117   {
11118     SIGNDOC_Exception *ex = NULL;
11119     p = SIGNDOC_RenderParameters_clone (&ex, aSource.getImpl ());
11120     if (ex != NULL) SignDoc_throw (ex);
11121   }
11122 
11126   ~SignDocRenderParameters ()
11127   {
11128     SIGNDOC_RenderParameters_delete (p);
11129   }
11130 
11136   SignDocRenderParameters &operator= (const SignDocRenderParameters &aSource)
11137   {
11138     SIGNDOC_Exception *ex = NULL;
11139     SIGNDOC_RenderParameters_assign (&ex, p, aSource.getImpl ());
11140     if (ex != NULL) SignDoc_throw (ex);
11141     return *this;
11142   }
11143 
11156   bool setPage (int aPage)
11157   {
11158     SIGNDOC_Exception *ex = NULL;
11159     bool r;
11160     r = (bool)SIGNDOC_RenderParameters_setPage (&ex, p, aPage);
11161     if (ex != NULL) SignDoc_throw (ex);
11162     return r;
11163   }
11164 
11177   bool getPage (int &aPage) const
11178   {
11179     SIGNDOC_Exception *ex = NULL;
11180     bool r;
11181     r = (bool)SIGNDOC_RenderParameters_getPage (&ex, p, &aPage);
11182     if (ex != NULL) SignDoc_throw (ex);
11183     return r;
11184   }
11185 
11205   bool setPages (int aFirst, int aLast)
11206   {
11207     SIGNDOC_Exception *ex = NULL;
11208     bool r;
11209     r = (bool)SIGNDOC_RenderParameters_setPages (&ex, p, aFirst, aLast);
11210     if (ex != NULL) SignDoc_throw (ex);
11211     return r;
11212   }
11213 
11229   bool getPages (int &aFirst, int &aLast) const
11230   {
11231     SIGNDOC_Exception *ex = NULL;
11232     bool r;
11233     r = (bool)SIGNDOC_RenderParameters_getPages (&ex, p, &aFirst, &aLast);
11234     if (ex != NULL) SignDoc_throw (ex);
11235     return r;
11236   }
11237 
11254   bool setResolution (double aResX, double aResY)
11255   {
11256     SIGNDOC_Exception *ex = NULL;
11257     bool r;
11258     r = (bool)SIGNDOC_RenderParameters_setResolution (&ex, p, aResX, aResY);
11259     if (ex != NULL) SignDoc_throw (ex);
11260     return r;
11261   }
11262 
11273   bool getResolution (double &aResX, double &aResY) const
11274   {
11275     SIGNDOC_Exception *ex = NULL;
11276     bool r;
11277     r = (bool)SIGNDOC_RenderParameters_getResolution (&ex, p, &aResX, &aResY);
11278     if (ex != NULL) SignDoc_throw (ex);
11279     return r;
11280   }
11281 
11295   bool setZoom (double aZoom)
11296   {
11297     SIGNDOC_Exception *ex = NULL;
11298     bool r;
11299     r = (bool)SIGNDOC_RenderParameters_setZoom (&ex, p, aZoom);
11300     if (ex != NULL) SignDoc_throw (ex);
11301     return r;
11302   }
11303 
11318   bool getZoom (double &aZoom) const
11319   {
11320     SIGNDOC_Exception *ex = NULL;
11321     bool r;
11322     r = (bool)SIGNDOC_RenderParameters_getZoom (&ex, p, &aZoom);
11323     if (ex != NULL) SignDoc_throw (ex);
11324     return r;
11325   }
11326 
11340   bool fitWidth (int aWidth)
11341   {
11342     SIGNDOC_Exception *ex = NULL;
11343     bool r;
11344     r = (bool)SIGNDOC_RenderParameters_fitWidth (&ex, p, aWidth);
11345     if (ex != NULL) SignDoc_throw (ex);
11346     return r;
11347   }
11348 
11359   bool getFitWidth (int &aWidth) const
11360   {
11361     SIGNDOC_Exception *ex = NULL;
11362     bool r;
11363     r = (bool)SIGNDOC_RenderParameters_getFitWidth (&ex, p, &aWidth);
11364     if (ex != NULL) SignDoc_throw (ex);
11365     return r;
11366   }
11367 
11381   bool fitHeight (int aHeight)
11382   {
11383     SIGNDOC_Exception *ex = NULL;
11384     bool r;
11385     r = (bool)SIGNDOC_RenderParameters_fitHeight (&ex, p, aHeight);
11386     if (ex != NULL) SignDoc_throw (ex);
11387     return r;
11388   }
11389 
11400   bool getFitHeight (int &aHeight) const
11401   {
11402     SIGNDOC_Exception *ex = NULL;
11403     bool r;
11404     r = (bool)SIGNDOC_RenderParameters_getFitHeight (&ex, p, &aHeight);
11405     if (ex != NULL) SignDoc_throw (ex);
11406     return r;
11407   }
11408 
11425   bool fitRect (int aWidth, int aHeight)
11426   {
11427     SIGNDOC_Exception *ex = NULL;
11428     bool r;
11429     r = (bool)SIGNDOC_RenderParameters_fitRect (&ex, p, aWidth, aHeight);
11430     if (ex != NULL) SignDoc_throw (ex);
11431     return r;
11432   }
11433 
11445   bool getFitRect (int &aWidth, int &aHeight) const
11446   {
11447     SIGNDOC_Exception *ex = NULL;
11448     bool r;
11449     r = (bool)SIGNDOC_RenderParameters_getFitRect (&ex, p, &aWidth, &aHeight);
11450     if (ex != NULL) SignDoc_throw (ex);
11451     return r;
11452   }
11453 
11468   bool setFormat (const std::string &aFormat)
11469   {
11470     SIGNDOC_Exception *ex = NULL;
11471     bool r;
11472     r = (bool)SIGNDOC_RenderParameters_setFormat (&ex, p, aFormat.c_str ());
11473     if (ex != NULL) SignDoc_throw (ex);
11474     return r;
11475   }
11476 
11487   bool getFormat (std::string &aFormat) const
11488   {
11489     SIGNDOC_Exception *ex = NULL;
11490     char *tempFormat = NULL;
11491     bool r;
11492     try
11493       {
11494         r = (bool)SIGNDOC_RenderParameters_getFormat (&ex, p, &tempFormat);
11495         if (tempFormat != NULL)
11496           aFormat = tempFormat;
11497       }
11498     catch (...)
11499       {
11500         SIGNDOC_free (tempFormat);
11501         throw;
11502       }
11503     SIGNDOC_free (tempFormat);
11504     if (ex != NULL) SignDoc_throw (ex);
11505     return r;
11506   }
11507 
11520   bool setInterlacing (Interlacing aInterlacing)
11521   {
11522     SIGNDOC_Exception *ex = NULL;
11523     bool r;
11524     r = (bool)SIGNDOC_RenderParameters_setInterlacing (&ex, p, aInterlacing);
11525     if (ex != NULL) SignDoc_throw (ex);
11526     return r;
11527   }
11528 
11539   bool getInterlacing (Interlacing &aInterlacing) const
11540   {
11541     SIGNDOC_Exception *ex = NULL;
11542     int tempInterlacing = 0;
11543     bool r;
11544     try
11545       {
11546         r = (bool)SIGNDOC_RenderParameters_getInterlacing (&ex, p, &tempInterlacing);
11547         aInterlacing = (Interlacing )tempInterlacing;
11548       }
11549     catch (...)
11550       {
11551         throw;
11552       }
11553     if (ex != NULL) SignDoc_throw (ex);
11554     return r;
11555   }
11556 
11569   bool setQuality (Quality aQuality)
11570   {
11571     SIGNDOC_Exception *ex = NULL;
11572     bool r;
11573     r = (bool)SIGNDOC_RenderParameters_setQuality (&ex, p, aQuality);
11574     if (ex != NULL) SignDoc_throw (ex);
11575     return r;
11576   }
11577 
11587   bool getQuality (Quality &aQuality) const
11588   {
11589     SIGNDOC_Exception *ex = NULL;
11590     int tempQuality = 0;
11591     bool r;
11592     try
11593       {
11594         r = (bool)SIGNDOC_RenderParameters_getQuality (&ex, p, &tempQuality);
11595         aQuality = (Quality )tempQuality;
11596       }
11597     catch (...)
11598       {
11599         throw;
11600       }
11601     if (ex != NULL) SignDoc_throw (ex);
11602     return r;
11603   }
11604 
11616   bool setPixelFormat (PixelFormat aPixelFormat)
11617   {
11618     SIGNDOC_Exception *ex = NULL;
11619     bool r;
11620     r = (bool)SIGNDOC_RenderParameters_setPixelFormat (&ex, p, aPixelFormat);
11621     if (ex != NULL) SignDoc_throw (ex);
11622     return r;
11623   }
11624 
11634   bool getPixelFormat (PixelFormat &aPixelFormat) const
11635   {
11636     SIGNDOC_Exception *ex = NULL;
11637     int tempPixelFormat = 0;
11638     bool r;
11639     try
11640       {
11641         r = (bool)SIGNDOC_RenderParameters_getPixelFormat (&ex, p, &tempPixelFormat);
11642         aPixelFormat = (PixelFormat )tempPixelFormat;
11643       }
11644     catch (...)
11645       {
11646         throw;
11647       }
11648     if (ex != NULL) SignDoc_throw (ex);
11649     return r;
11650   }
11651 
11663   bool setCompression (Compression aCompression)
11664   {
11665     SIGNDOC_Exception *ex = NULL;
11666     bool r;
11667     r = (bool)SIGNDOC_RenderParameters_setCompression (&ex, p, aCompression);
11668     if (ex != NULL) SignDoc_throw (ex);
11669     return r;
11670   }
11671 
11681   bool getCompression (Compression &aCompression) const
11682   {
11683     SIGNDOC_Exception *ex = NULL;
11684     int tempCompression = 0;
11685     bool r;
11686     try
11687       {
11688         r = (bool)SIGNDOC_RenderParameters_getCompression (&ex, p, &tempCompression);
11689         aCompression = (Compression )tempCompression;
11690       }
11691     catch (...)
11692       {
11693         throw;
11694       }
11695     if (ex != NULL) SignDoc_throw (ex);
11696     return r;
11697   }
11698 
11737   bool setDecorations (bool aDecorations)
11738   {
11739     SIGNDOC_Exception *ex = NULL;
11740     bool r;
11741     r = (bool)SIGNDOC_RenderParameters_setDecorations (&ex, p, aDecorations);
11742     if (ex != NULL) SignDoc_throw (ex);
11743     return r;
11744   }
11745 
11755   bool getDecorations (bool &aDecorations) const
11756   {
11757     SIGNDOC_Exception *ex = NULL;
11758     SIGNDOC_Boolean tempDecorations = 0;
11759     bool r;
11760     try
11761       {
11762         r = (bool)SIGNDOC_RenderParameters_getDecorations (&ex, p, &tempDecorations);
11763         aDecorations = (bool )tempDecorations;
11764       }
11765     catch (...)
11766       {
11767         throw;
11768       }
11769     if (ex != NULL) SignDoc_throw (ex);
11770     return r;
11771   }
11772 
11793   bool setDecorationState (Encoding aEncoding, const std::string &aName,
11794                            DecorationState aDecorationState)
11795   {
11796     SIGNDOC_Exception *ex = NULL;
11797     bool r;
11798     r = (bool)SIGNDOC_RenderParameters_setDecorationState (&ex, p, aEncoding, aName.c_str (), aDecorationState);
11799     if (ex != NULL) SignDoc_throw (ex);
11800     return r;
11801   }
11802 
11822   bool setDecorationState (const wchar_t *aName,
11823                            DecorationState aDecorationState)
11824   {
11825     SIGNDOC_Exception *ex = NULL;
11826     bool r;
11827     r = (bool)SIGNDOC_RenderParameters_setDecorationStateW (&ex, p, aName, aDecorationState);
11828     if (ex != NULL) SignDoc_throw (ex);
11829     return r;
11830   }
11831 
11846   bool getDecorationState (Encoding aEncoding, const std::string &aName,
11847                            DecorationState &aDecorationState) const
11848   {
11849     SIGNDOC_Exception *ex = NULL;
11850     int tempDecorationState = 0;
11851     bool r;
11852     try
11853       {
11854         r = (bool)SIGNDOC_RenderParameters_getDecorationState (&ex, p, aEncoding, aName.c_str (), &tempDecorationState);
11855         aDecorationState = (DecorationState )tempDecorationState;
11856       }
11857     catch (...)
11858       {
11859         throw;
11860       }
11861     if (ex != NULL) SignDoc_throw (ex);
11862     return r;
11863   }
11864 
11878   bool getDecorationState (const wchar_t *aName,
11879                            DecorationState &aDecorationState) const
11880   {
11881     SIGNDOC_Exception *ex = NULL;
11882     int tempDecorationState = 0;
11883     bool r;
11884     try
11885       {
11886         r = (bool)SIGNDOC_RenderParameters_getDecorationStateW (&ex, p, aName, &tempDecorationState);
11887         aDecorationState = (DecorationState )tempDecorationState;
11888       }
11889     catch (...)
11890       {
11891         throw;
11892       }
11893     if (ex != NULL) SignDoc_throw (ex);
11894     return r;
11895   }
11896                                
11909   bool setPrint (bool aPrint)
11910   {
11911     SIGNDOC_Exception *ex = NULL;
11912     bool r;
11913     r = (bool)SIGNDOC_RenderParameters_setPrint (&ex, p, aPrint);
11914     if (ex != NULL) SignDoc_throw (ex);
11915     return r;
11916   }
11917 
11927   bool getPrint (bool &aPrint) const
11928   {
11929     SIGNDOC_Exception *ex = NULL;
11930     SIGNDOC_Boolean tempPrint = 0;
11931     bool r;
11932     try
11933       {
11934         r = (bool)SIGNDOC_RenderParameters_getPrint (&ex, p, &tempPrint);
11935         aPrint = (bool )tempPrint;
11936       }
11937     catch (...)
11938       {
11939         throw;
11940       }
11941     if (ex != NULL) SignDoc_throw (ex);
11942     return r;
11943   }
11944 
11958   bool setModificationState (bool aCheck)
11959   {
11960     SIGNDOC_Exception *ex = NULL;
11961     bool r;
11962     r = (bool)SIGNDOC_RenderParameters_setModificationState (&ex, p, aCheck);
11963     if (ex != NULL) SignDoc_throw (ex);
11964     return r;
11965   }
11966 
11976   bool getModificationState (bool &aCheck) const
11977   {
11978     SIGNDOC_Exception *ex = NULL;
11979     SIGNDOC_Boolean tempCheck = 0;
11980     bool r;
11981     try
11982       {
11983         r = (bool)SIGNDOC_RenderParameters_getModificationState (&ex, p, &tempCheck);
11984         aCheck = (bool )tempCheck;
11985       }
11986     catch (...)
11987       {
11988         throw;
11989       }
11990     if (ex != NULL) SignDoc_throw (ex);
11991     return r;
11992   }
11993 
12001   bool operator== (const SignDocRenderParameters &aRHS) const
12002   {
12003     SIGNDOC_Exception *ex = NULL;
12004     bool r;
12005     r = (bool)SIGNDOC_RenderParameters_equals (&ex, p, aRHS.getImpl ());
12006     if (ex != NULL) SignDoc_throw (ex);
12007     return r;
12008   }
12009 
12010 private:
12011 public:
12016   SignDocRenderParameters (SIGNDOC_RenderParameters *aP) : p (aP) { }
12017 
12022   SIGNDOC_RenderParameters *getImpl () { return p; }
12023 
12028   const SIGNDOC_RenderParameters *getImpl () const { return p; }
12029 
12034   void setImpl (SIGNDOC_RenderParameters *aP) { SIGNDOC_RenderParameters_delete (p); p  = aP; }
12035 
12036 private:
12037   SIGNDOC_RenderParameters *p;
12038 };
12039 
12046 class SignDocRenderOutput 
12047 {
12048 public:
12052   int mWidth;
12053 
12057   int mHeight;
12058 };
12059 
12063 class SignDocAttachment 
12064 {
12065 public:
12066 
12067 public:
12071   SignDocAttachment ()
12072     : p (NULL)
12073   {
12074     SIGNDOC_Exception *ex = NULL;
12075     p = SIGNDOC_Attachment_new (&ex);
12076     if (ex != NULL) SignDoc_throw (ex);
12077   }
12078 
12084   SignDocAttachment (const SignDocAttachment &aSource)
12085     : p (NULL)
12086   {
12087     SIGNDOC_Exception *ex = NULL;
12088     p = SIGNDOC_Attachment_clone (&ex, aSource.getImpl ());
12089     if (ex != NULL) SignDoc_throw (ex);
12090   }
12091 
12095   ~SignDocAttachment ()
12096   {
12097     SIGNDOC_Attachment_delete (p);
12098   }
12099 
12105   SignDocAttachment &operator= (const SignDocAttachment &aSource)
12106   {
12107     SIGNDOC_Exception *ex = NULL;
12108     SIGNDOC_Attachment_assign (&ex, p, aSource.getImpl ());
12109     if (ex != NULL) SignDoc_throw (ex);
12110     return *this;
12111   }
12112 
12118   void swap (SignDocAttachment &aOther)
12119   {
12120     std::swap (p, aOther.p);
12121   }
12122 
12135   std::string getName (Encoding aEncoding) const
12136   {
12137     SIGNDOC_Exception *ex = NULL;
12138     std::string r;
12139     char *s = SIGNDOC_Attachment_getName (&ex, p, aEncoding);
12140     if (ex != NULL) SignDoc_throw (ex);
12141     try
12142       {
12143         r = s;
12144       }
12145     catch (...)
12146       {
12147         SIGNDOC_free (s);
12148         throw;
12149       }
12150     SIGNDOC_free (s);
12151     return r;
12152   }
12153 
12162   const char *getNameUTF8 () const
12163   {
12164     SIGNDOC_Exception *ex = NULL;
12165     const char *r;
12166     r = SIGNDOC_Attachment_getNameUTF8 (&ex, p);
12167     if (ex != NULL) SignDoc_throw (ex);
12168     return r;
12169   }
12170 
12183   std::string getFileName (Encoding aEncoding) const
12184   {
12185     SIGNDOC_Exception *ex = NULL;
12186     std::string r;
12187     char *s = SIGNDOC_Attachment_getFileName (&ex, p, aEncoding);
12188     if (ex != NULL) SignDoc_throw (ex);
12189     try
12190       {
12191         r = s;
12192       }
12193     catch (...)
12194       {
12195         SIGNDOC_free (s);
12196         throw;
12197       }
12198     SIGNDOC_free (s);
12199     return r;
12200   }
12201 
12210   const char *getFileNameUTF8 () const
12211   {
12212     SIGNDOC_Exception *ex = NULL;
12213     const char *r;
12214     r = SIGNDOC_Attachment_getFileNameUTF8 (&ex, p);
12215     if (ex != NULL) SignDoc_throw (ex);
12216     return r;
12217   }
12218 
12233   std::string getDescription (Encoding aEncoding) const
12234   {
12235     SIGNDOC_Exception *ex = NULL;
12236     std::string r;
12237     char *s = SIGNDOC_Attachment_getDescription (&ex, p, aEncoding);
12238     if (ex != NULL) SignDoc_throw (ex);
12239     try
12240       {
12241         r = s;
12242       }
12243     catch (...)
12244       {
12245         SIGNDOC_free (s);
12246         throw;
12247       }
12248     SIGNDOC_free (s);
12249     return r;
12250   }
12251 
12262   const char *getDescriptionUTF8 () const
12263   {
12264     SIGNDOC_Exception *ex = NULL;
12265     const char *r;
12266     r = SIGNDOC_Attachment_getDescriptionUTF8 (&ex, p);
12267     if (ex != NULL) SignDoc_throw (ex);
12268     return r;
12269   }
12270 
12281   int getSize () const
12282   {
12283     SIGNDOC_Exception *ex = NULL;
12284     int r;
12285     r = SIGNDOC_Attachment_getSize (&ex, p);
12286     if (ex != NULL) SignDoc_throw (ex);
12287     return r;
12288   }
12289 
12297   int getCompressedSize () const
12298   {
12299     SIGNDOC_Exception *ex = NULL;
12300     int r;
12301     r = SIGNDOC_Attachment_getCompressedSize (&ex, p);
12302     if (ex != NULL) SignDoc_throw (ex);
12303     return r;
12304   }
12305 
12314   const char *getType () const
12315   {
12316     SIGNDOC_Exception *ex = NULL;
12317     const char *r;
12318     r = SIGNDOC_Attachment_getType (&ex, p);
12319     if (ex != NULL) SignDoc_throw (ex);
12320     return r;
12321   }
12322 
12342   const char *getCreationTime () const
12343   {
12344     SIGNDOC_Exception *ex = NULL;
12345     const char *r;
12346     r = SIGNDOC_Attachment_getCreationTime (&ex, p);
12347     if (ex != NULL) SignDoc_throw (ex);
12348     return r;
12349   }
12350 
12371   const char *getModificationTime () const
12372   {
12373     SIGNDOC_Exception *ex = NULL;
12374     const char *r;
12375     r = SIGNDOC_Attachment_getModificationTime (&ex, p);
12376     if (ex != NULL) SignDoc_throw (ex);
12377     return r;
12378   }
12379 
12380 private:
12381 public:
12386   SignDocAttachment (SIGNDOC_Attachment *aP) : p (aP) { }
12387 
12392   SIGNDOC_Attachment *getImpl () { return p; }
12393 
12398   const SIGNDOC_Attachment *getImpl () const { return p; }
12399 
12404   void setImpl (SIGNDOC_Attachment *aP) { SIGNDOC_Attachment_delete (p); p  = aP; }
12405 
12406 private:
12407   SIGNDOC_Attachment *p;
12408 };
12409 
12418 class SignDocWatermark 
12419 {
12420 public:
12421 
12425   enum Justification
12426   {
12427     j_left, j_center, j_right
12428   };
12429 
12433   enum Location
12434   {
12435     l_overlay,                  
12436     l_underlay                  
12437   };
12438 
12442   enum HAlignment
12443   {
12447     ha_left,
12448 
12452     ha_center,
12453 
12457     ha_right
12458   };
12459 
12463   enum VAlignment
12464   {
12468     va_top,
12469 
12473     va_center,
12474 
12478     va_bottom
12479   };
12480 
12484   enum Flags
12485   {
12495     f_ltr = 0x1000,
12496 
12506     f_rtl = 0x2000,
12507 
12524     f_default_ltr = 0x4000,
12525 
12542     f_default_rtl = 0x8000
12543   };
12544 
12545 public:
12551   SignDocWatermark ()
12552     : p (NULL)
12553   {
12554     SIGNDOC_Exception *ex = NULL;
12555     p = SIGNDOC_Watermark_new (&ex);
12556     if (ex != NULL) SignDoc_throw (ex);
12557   }
12558 
12564   SignDocWatermark (const SignDocWatermark &aSource)
12565     : p (NULL)
12566   {
12567     SIGNDOC_Exception *ex = NULL;
12568     p = SIGNDOC_Watermark_clone (&ex, aSource.getImpl ());
12569     if (ex != NULL) SignDoc_throw (ex);
12570   }
12571 
12575   ~SignDocWatermark ()
12576   {
12577     SIGNDOC_Watermark_delete (p);
12578   }
12579 
12585   SignDocWatermark &operator= (const SignDocWatermark &aSource)
12586   {
12587     SIGNDOC_Exception *ex = NULL;
12588     SIGNDOC_Watermark_assign (&ex, p, aSource.getImpl ());
12589     if (ex != NULL) SignDoc_throw (ex);
12590     return *this;
12591   }
12592 
12598   void swap (SignDocWatermark &aOther)
12599   {
12600     std::swap (p, aOther.p);
12601   }
12602 
12606   void clear ()
12607   {
12608     SIGNDOC_Exception *ex = NULL;
12609     SIGNDOC_Watermark_clear (&ex, p);
12610     if (ex != NULL) SignDoc_throw (ex);
12611   }
12612 
12633   void setText (Encoding aEncoding, const std::string &aText)
12634   {
12635     SIGNDOC_Exception *ex = NULL;
12636     SIGNDOC_Watermark_setText (&ex, p, aEncoding, aText.c_str ());
12637     if (ex != NULL) SignDoc_throw (ex);
12638   }
12639 
12654   void setFontName (Encoding aEncoding, const std::string &aFontName)
12655   {
12656     SIGNDOC_Exception *ex = NULL;
12657     SIGNDOC_Watermark_setFontName (&ex, p, aEncoding, aFontName.c_str ());
12658     if (ex != NULL) SignDoc_throw (ex);
12659   }
12660 
12670   void setFontSize (double aFontSize)
12671   {
12672     SIGNDOC_Exception *ex = NULL;
12673     SIGNDOC_Watermark_setFontSize (&ex, p, aFontSize);
12674     if (ex != NULL) SignDoc_throw (ex);
12675   }
12676 
12684   void setTextColor (const SignDocColor &aTextColor)
12685   {
12686     SIGNDOC_Exception *ex = NULL;
12687     SIGNDOC_Watermark_setTextColor (&ex, p, aTextColor.getImpl ());
12688     if (ex != NULL) SignDoc_throw (ex);
12689   }
12690 
12703   void setJustification (Justification aJustification)
12704   {
12705     SIGNDOC_Exception *ex = NULL;
12706     SIGNDOC_Watermark_setJustification (&ex, p, aJustification);
12707     if (ex != NULL) SignDoc_throw (ex);
12708   }
12709 
12719   void setRotation (double aRotation)
12720   {
12721     SIGNDOC_Exception *ex = NULL;
12722     SIGNDOC_Watermark_setRotation (&ex, p, aRotation);
12723     if (ex != NULL) SignDoc_throw (ex);
12724   }
12725 
12736   void setOpacity (double aOpacity)
12737   {
12738     SIGNDOC_Exception *ex = NULL;
12739     SIGNDOC_Watermark_setOpacity (&ex, p, aOpacity);
12740     if (ex != NULL) SignDoc_throw (ex);
12741   }
12742 
12752   void setScale (double aScale)
12753   {
12754     SIGNDOC_Exception *ex = NULL;
12755     SIGNDOC_Watermark_setScale (&ex, p, aScale);
12756     if (ex != NULL) SignDoc_throw (ex);
12757   }
12758 
12769   void setLocation (Location aLocation)
12770   {
12771     SIGNDOC_Exception *ex = NULL;
12772     SIGNDOC_Watermark_setLocation (&ex, p, aLocation);
12773     if (ex != NULL) SignDoc_throw (ex);
12774   }
12775 
12795   void setHorizontalPosition (HAlignment aAlignment, double aDistance)
12796   {
12797     SIGNDOC_Exception *ex = NULL;
12798     SIGNDOC_Watermark_setHorizontalPosition (&ex, p, aAlignment, aDistance);
12799     if (ex != NULL) SignDoc_throw (ex);
12800   }
12801 
12820   void setVerticalPosition (VAlignment aAlignment, double aDistance)
12821   {
12822     SIGNDOC_Exception *ex = NULL;
12823     SIGNDOC_Watermark_setVerticalPosition (&ex, p, aAlignment, aDistance);
12824     if (ex != NULL) SignDoc_throw (ex);
12825   }
12826 
12836   void setFirstPage (int aPage)
12837   {
12838     SIGNDOC_Exception *ex = NULL;
12839     SIGNDOC_Watermark_setFirstPage (&ex, p, aPage);
12840     if (ex != NULL) SignDoc_throw (ex);
12841   }
12842 
12853   void setLastPage (int aPage)
12854   {
12855     SIGNDOC_Exception *ex = NULL;
12856     SIGNDOC_Watermark_setLastPage (&ex, p, aPage);
12857     if (ex != NULL) SignDoc_throw (ex);
12858   }
12859 
12871   void setPageIncrement (int aIncr)
12872   {
12873     SIGNDOC_Exception *ex = NULL;
12874     SIGNDOC_Watermark_setPageIncrement (&ex, p, aIncr);
12875     if (ex != NULL) SignDoc_throw (ex);
12876   }
12877 
12887   void setFlags (int aFlags)
12888   {
12889     SIGNDOC_Exception *ex = NULL;
12890     SIGNDOC_Watermark_setFlags (&ex, p, aFlags);
12891     if (ex != NULL) SignDoc_throw (ex);
12892   }
12893 
12894 private:
12895 public:
12900   SignDocWatermark (SIGNDOC_Watermark *aP) : p (aP) { }
12901 
12906   SIGNDOC_Watermark *getImpl () { return p; }
12907 
12912   const SIGNDOC_Watermark *getImpl () const { return p; }
12913 
12918   void setImpl (SIGNDOC_Watermark *aP) { SIGNDOC_Watermark_delete (p); p  = aP; }
12919 
12920 private:
12921   SIGNDOC_Watermark *p;
12922 };
12923 
12971 class SignDocVerificationParameters 
12972 {
12973 public:
12979   enum CertificateChainVerificationPolicy
12980   {
12986     ccvp_dont_verify,
12987 
12994     ccvp_accept_self_signed,
12995 
13003     ccvp_accept_self_signed_with_bio,
13004 
13017     ccvp_accept_self_signed_with_rsa_bio,
13018 
13025     ccvp_require_trusted_root
13026   };
13027 
13034   enum CertificateRevocationVerificationPolicy
13035   {
13041     crvp_dont_check,
13042 
13047     crvp_offline,
13048 
13053     crvp_online
13054   };
13055 
13061   enum VerificationFlags
13062   {
13066     vf_check_revocation = 0x01,
13067 
13075     vf_use_crl_only = 0x02,
13076 
13084     vf_use_ocsp_only = 0x04,
13085 
13094     vf_offline = 0x08,
13095 
13108     vf_enforce_next_update = 0x10,
13109 
13122     vf_enforce_ocsp_signer = 0x20,
13123 
13131     vf_online = 0x40,
13132 
13143     vf_no_ocsp_nonce = 0x80,
13144 
13156     vf_crl_first = 0x100,
13157 
13175     vf_ignore_no_revocation = 0x200
13176   };
13177 
13183   enum VerificationModel
13184   {
13191     vm_minimal,
13192 
13201     vm_chain,
13202 
13208     vm_modified_shell,
13209 
13221     vm_shell
13222   };
13223 
13227   enum ReturnCode
13228   {
13229     rc_ok,                      
13230     rc_unknown,                 
13231     rc_not_supported,           
13232     rc_invalid_value            
13233   };
13234 
13235 public:
13243   SignDocVerificationParameters ()
13244     : p (NULL)
13245   {
13246     SIGNDOC_Exception *ex = NULL;
13247     p = SIGNDOC_VerificationParameters_new (&ex);
13248     if (ex != NULL) SignDoc_throw (ex);
13249   }
13250 
13256   SignDocVerificationParameters (const SignDocVerificationParameters &aSource)
13257     : p (NULL)
13258   {
13259     SIGNDOC_Exception *ex = NULL;
13260     p = SIGNDOC_VerificationParameters_clone (&ex, aSource.getImpl ());
13261     if (ex != NULL) SignDoc_throw (ex);
13262   }
13263 
13267   ~SignDocVerificationParameters ()
13268   {
13269     SIGNDOC_VerificationParameters_delete (p);
13270   }
13271 
13277   SignDocVerificationParameters &operator= (const SignDocVerificationParameters &aSource)
13278   {
13279     SIGNDOC_Exception *ex = NULL;
13280     SIGNDOC_VerificationParameters_assign (&ex, p, aSource.getImpl ());
13281     if (ex != NULL) SignDoc_throw (ex);
13282     return *this;
13283   }
13284 
13292   bool operator== (const SignDocVerificationParameters &aRHS) const
13293   {
13294     SIGNDOC_Exception *ex = NULL;
13295     bool r;
13296     r = (bool)SIGNDOC_VerificationParameters_equals (&ex, p, aRHS.getImpl ());
13297     if (ex != NULL) SignDoc_throw (ex);
13298     return r;
13299   }
13300 
13307   void setForUpdateDSS ()
13308   {
13309     SIGNDOC_Exception *ex = NULL;
13310     SIGNDOC_VerificationParameters_setForUpdateDSS (&ex, p);
13311     if (ex != NULL) SignDoc_throw (ex);
13312   }
13313 
13341   ReturnCode setString (Encoding aEncoding, const std::string &aName,
13342                         const std::string &aValue)
13343   {
13344     SIGNDOC_Exception *ex = NULL;
13345     ReturnCode r;
13346     r = (ReturnCode)SIGNDOC_VerificationParameters_setString (&ex, p, aEncoding, aName.c_str (), aValue.c_str ());
13347     if (ex != NULL) SignDoc_throw (ex);
13348     return r;
13349   }
13350 
13362   ReturnCode setString (const std::string &aName, const wchar_t *aValue)
13363   {
13364     SIGNDOC_Exception *ex = NULL;
13365     ReturnCode r;
13366     r = (ReturnCode)SIGNDOC_VerificationParameters_setStringW (&ex, p, aName.c_str (), aValue);
13367     if (ex != NULL) SignDoc_throw (ex);
13368     return r;
13369   }
13370 
13446   ReturnCode setInteger (const std::string &aName, int aValue)
13447   {
13448     SIGNDOC_Exception *ex = NULL;
13449     ReturnCode r;
13450     r = (ReturnCode)SIGNDOC_VerificationParameters_setInteger (&ex, p, aName.c_str (), aValue);
13451     if (ex != NULL) SignDoc_throw (ex);
13452     return r;
13453   }
13454 
13477   ReturnCode setBlob (const std::string &aName, const unsigned char *aData,
13478                       size_t aSize)
13479   {
13480     SIGNDOC_Exception *ex = NULL;
13481     ReturnCode r;
13482     r = (ReturnCode)SIGNDOC_VerificationParameters_setBlob (&ex, p, aName.c_str (), aData, aSize);
13483     if (ex != NULL) SignDoc_throw (ex);
13484     return r;
13485   }
13486 
13500   const char *getErrorMessage (Encoding aEncoding) const
13501   {
13502     SIGNDOC_Exception *ex = NULL;
13503     const char *r;
13504     r = SIGNDOC_VerificationParameters_getErrorMessage (&ex, p, aEncoding);
13505     if (ex != NULL) SignDoc_throw (ex);
13506     return r;
13507   }
13508 
13520   const wchar_t *getErrorMessageW () const
13521   {
13522     SIGNDOC_Exception *ex = NULL;
13523     const wchar_t *r;
13524     r = SIGNDOC_VerificationParameters_getErrorMessageW (&ex, p);
13525     if (ex != NULL) SignDoc_throw (ex);
13526     return r;
13527   }
13528 
13529 private:
13530 public:
13535   SignDocVerificationParameters (SIGNDOC_VerificationParameters *aP) : p (aP) { }
13536 
13541   SIGNDOC_VerificationParameters *getImpl () { return p; }
13542 
13547   const SIGNDOC_VerificationParameters *getImpl () const { return p; }
13548 
13553   void setImpl (SIGNDOC_VerificationParameters *aP) { SIGNDOC_VerificationParameters_delete (p); p  = aP; }
13554 
13555 private:
13556   SIGNDOC_VerificationParameters *p;
13557 };
13558 
13564 class SignDocChange 
13565 {
13566 public:
13572   enum Type
13573   {
13581     t_other,
13582 
13591     t_field_added,
13592 
13601     t_field_removed,
13602 
13611     t_field_modified,
13612 
13621     t_field_filled_in,
13622 
13631     t_annotation_added,
13632 
13641     t_annotation_removed,
13642 
13651     t_annotation_modified,
13652 
13659     t_attachment_added,
13660 
13667     t_attachment_removed,
13668 
13675     t_attachment_modified,
13676 
13683     t_page_added,
13684 
13691     t_page_removed,
13692 
13698     t_page_modified
13699   };
13700 
13701 public:
13705   ~SignDocChange ()
13706   {
13707     SIGNDOC_Change_delete (p);
13708   }
13709 
13715   Type getType () const
13716   {
13717     SIGNDOC_Exception *ex = NULL;
13718     Type r;
13719     r = (Type)SIGNDOC_Change_getType (&ex, p);
13720     if (ex != NULL) SignDoc_throw (ex);
13721     return r;
13722   }
13723 
13744   std::string getName (Encoding aEncoding) const
13745   {
13746     SIGNDOC_Exception *ex = NULL;
13747     std::string r;
13748     char *s = SIGNDOC_Change_getName (&ex, p, aEncoding);
13749     if (ex != NULL) SignDoc_throw (ex);
13750     try
13751       {
13752         r = s;
13753       }
13754     catch (...)
13755       {
13756         SIGNDOC_free (s);
13757         throw;
13758       }
13759     SIGNDOC_free (s);
13760     return r;
13761   }
13762 
13780   const char *getNameUTF8 () const
13781   {
13782     SIGNDOC_Exception *ex = NULL;
13783     const char *r;
13784     r = SIGNDOC_Change_getNameUTF8 (&ex, p);
13785     if (ex != NULL) SignDoc_throw (ex);
13786     return r;
13787   }
13788 
13801   int getPage () const
13802   {
13803     SIGNDOC_Exception *ex = NULL;
13804     int r;
13805     r = SIGNDOC_Change_getPage (&ex, p);
13806     if (ex != NULL) SignDoc_throw (ex);
13807     return r;
13808   }
13809 
13816   SignDocField::Type getFieldType () const
13817   {
13818     SIGNDOC_Exception *ex = NULL;
13819     SignDocField::Type r;
13820     r = (SignDocField::Type)SIGNDOC_Change_getFieldType (&ex, p);
13821     if (ex != NULL) SignDoc_throw (ex);
13822     return r;
13823   }
13824 
13832   const char *getAnnotationType () const
13833   {
13834     SIGNDOC_Exception *ex = NULL;
13835     const char *r;
13836     r = SIGNDOC_Change_getAnnotationType (&ex, p);
13837     if (ex != NULL) SignDoc_throw (ex);
13838     return r;
13839   }
13840 
13841 protected:
13847   SignDocChange ()
13848     : p (NULL)
13849   {
13850   }
13851 
13852 public:
13857   SignDocChange (SIGNDOC_Change *aP) : p (aP) { }
13858 
13863   SIGNDOC_Change *getImpl () { return p; }
13864 
13869   const SIGNDOC_Change *getImpl () const { return p; }
13870 
13875   void setImpl (SIGNDOC_Change *aP) { SIGNDOC_Change_delete (p); p  = aP; }
13876 
13877 private:
13878   SIGNDOC_Change *p;
13879 };
13880 
13888 class SignDocSignature 
13889 {
13890 public:
13894   ~SignDocSignature ()
13895   {
13896     SIGNDOC_Signature_delete (p);
13897   }
13898 
13911   std::string getFieldName (Encoding aEncoding) const
13912   {
13913     SIGNDOC_Exception *ex = NULL;
13914     std::string r;
13915     char *s = SIGNDOC_Signature_getFieldName (&ex, p, aEncoding);
13916     if (ex != NULL) SignDoc_throw (ex);
13917     try
13918       {
13919         r = s;
13920       }
13921     catch (...)
13922       {
13923         SIGNDOC_free (s);
13924         throw;
13925       }
13926     SIGNDOC_free (s);
13927     return r;
13928   }
13929 
13938   const char *getFieldNameUTF8 () const
13939   {
13940     SIGNDOC_Exception *ex = NULL;
13941     const char *r;
13942     r = SIGNDOC_Signature_getFieldNameUTF8 (&ex, p);
13943     if (ex != NULL) SignDoc_throw (ex);
13944     return r;
13945   }
13946 
13952   int getFieldPage () const
13953   {
13954     SIGNDOC_Exception *ex = NULL;
13955     int r;
13956     r = SIGNDOC_Signature_getFieldPage (&ex, p);
13957     if (ex != NULL) SignDoc_throw (ex);
13958     return r;
13959   }
13960 
13967   SignDocField::SignatureType getSignatureType () const
13968   {
13969     SIGNDOC_Exception *ex = NULL;
13970     SignDocField::SignatureType r;
13971     r = (SignDocField::SignatureType)SIGNDOC_Signature_getSignatureType (&ex, p);
13972     if (ex != NULL) SignDoc_throw (ex);
13973     return r;
13974   }
13975 
13993   int getClearedIndex () const
13994   {
13995     SIGNDOC_Exception *ex = NULL;
13996     int r;
13997     r = SIGNDOC_Signature_getClearedIndex (&ex, p);
13998     if (ex != NULL) SignDoc_throw (ex);
13999     return r;
14000   }
14001 
14019   int getDocMDP () const
14020   {
14021     SIGNDOC_Exception *ex = NULL;
14022     int r;
14023     r = SIGNDOC_Signature_getDocMDP (&ex, p);
14024     if (ex != NULL) SignDoc_throw (ex);
14025     return r;
14026   }
14027 
14045   int getLockMDP () const
14046   {
14047     SIGNDOC_Exception *ex = NULL;
14048     int r;
14049     r = SIGNDOC_Signature_getLockMDP (&ex, p);
14050     if (ex != NULL) SignDoc_throw (ex);
14051     return r;
14052   }
14053 
14062   bool getSigningCertificate (std::vector<unsigned char> &aOutput) const
14063   {
14064     SIGNDOC_Exception *ex = NULL;
14065     SIGNDOC_ByteArray *tempOutput = NULL;
14066     bool r;
14067     try
14068       {
14069         tempOutput = SIGNDOC_ByteArray_new (&ex);
14070         if (ex != NULL) SignDoc_throw (ex);
14071         r = (bool)SIGNDOC_Signature_getSigningCertificate (&ex, p, tempOutput);
14072         assignArray (aOutput, tempOutput);
14073       }
14074     catch (...)
14075       {
14076         if (tempOutput != NULL)
14077           SIGNDOC_ByteArray_delete (tempOutput);
14078         throw;
14079       }
14080     if (tempOutput != NULL)
14081       SIGNDOC_ByteArray_delete (tempOutput);
14082     if (ex != NULL) SignDoc_throw (ex);
14083     return r;
14084   }
14085 
14098   std::string getSignerCommonName (Encoding aEncoding) const
14099   {
14100     SIGNDOC_Exception *ex = NULL;
14101     std::string r;
14102     char *s = SIGNDOC_Signature_getSignerCommonName (&ex, p, aEncoding);
14103     if (ex != NULL) SignDoc_throw (ex);
14104     try
14105       {
14106         r = s;
14107       }
14108     catch (...)
14109       {
14110         SIGNDOC_free (s);
14111         throw;
14112       }
14113     SIGNDOC_free (s);
14114     return r;
14115   }
14116 
14126   const char *getSignerCommonNameUTF8 () const
14127   {
14128     SIGNDOC_Exception *ex = NULL;
14129     const char *r;
14130     r = SIGNDOC_Signature_getSignerCommonNameUTF8 (&ex, p);
14131     if (ex != NULL) SignDoc_throw (ex);
14132     return r;
14133   }
14134 
14147   std::string getSignerEmail (Encoding aEncoding) const
14148   {
14149     SIGNDOC_Exception *ex = NULL;
14150     std::string r;
14151     char *s = SIGNDOC_Signature_getSignerEmail (&ex, p, aEncoding);
14152     if (ex != NULL) SignDoc_throw (ex);
14153     try
14154       {
14155         r = s;
14156       }
14157     catch (...)
14158       {
14159         SIGNDOC_free (s);
14160         throw;
14161       }
14162     SIGNDOC_free (s);
14163     return r;
14164   }
14165 
14175   const char *getSignerEmailUTF8 () const
14176   {
14177     SIGNDOC_Exception *ex = NULL;
14178     const char *r;
14179     r = SIGNDOC_Signature_getSignerEmailUTF8 (&ex, p);
14180     if (ex != NULL) SignDoc_throw (ex);
14181     return r;
14182   }
14183 
14194   const char *getTimeStamp () const
14195   {
14196     SIGNDOC_Exception *ex = NULL;
14197     const char *r;
14198     r = SIGNDOC_Signature_getTimeStamp (&ex, p);
14199     if (ex != NULL) SignDoc_throw (ex);
14200     return r;
14201   }
14202 
14223   int getChangeCount () const
14224   {
14225     SIGNDOC_Exception *ex = NULL;
14226     int r;
14227     r = SIGNDOC_Signature_getChangeCount (&ex, p);
14228     if (ex != NULL) SignDoc_throw (ex);
14229     return r;
14230   }
14231 
14244   bool getChange (int aIndex, SIGNDOC_PTR<SignDocChange> &aOutput) const
14245   {
14246     SIGNDOC_Exception *ex = NULL;
14247     SIGNDOC_Change *tempOutput = NULL;
14248     aOutput.reset ((SignDocChange*)NULL);
14249     bool r;
14250     try
14251       {
14252         r = (bool)SIGNDOC_Signature_getChange (&ex, p, aIndex, &tempOutput);
14253         if (tempOutput != NULL)
14254           {
14255             aOutput.reset (new SignDocChange (tempOutput));
14256             tempOutput = NULL;
14257           }
14258       }
14259     catch (...)
14260       {
14261         if (tempOutput != NULL)
14262           SIGNDOC_Change_delete (tempOutput);
14263         throw;
14264       }
14265     if (tempOutput != NULL)
14266       SIGNDOC_Change_delete (tempOutput);
14267     if (ex != NULL) SignDoc_throw (ex);
14268     return r;
14269   }
14270 
14283   int getBiometricEncryption () const
14284   {
14285     SIGNDOC_Exception *ex = NULL;
14286     int r;
14287     r = SIGNDOC_Signature_getBiometricEncryption (&ex, p);
14288     if (ex != NULL) SignDoc_throw (ex);
14289     return r;
14290   }
14291 
14292 protected:
14298   SignDocSignature ()
14299     : p (NULL)
14300   {
14301   }
14302 
14303 private:
14307   // cppcheck-suppress noExplicitCopyMoveConstructor
14308   SignDocSignature (const SignDocSignature &);
14309 
14313   SignDocSignature &operator= (const SignDocSignature &);
14314 public:
14319   SignDocSignature (SIGNDOC_Signature *aP) : p (aP) { }
14320 
14325   SIGNDOC_Signature *getImpl () { return p; }
14326 
14331   const SIGNDOC_Signature *getImpl () const { return p; }
14332 
14337   void setImpl (SIGNDOC_Signature *aP) { SIGNDOC_Signature_delete (p); p  = aP; }
14338 
14339 private:
14340   SIGNDOC_Signature *p;
14341 };
14342 
14516 class SignDocDocument 
14517 {
14518 public:
14522   enum DocumentType
14523   {
14524     dt_unknown,                 
14525     dt_pdf,                     
14526     dt_tiff,                    
14527     dt_other,                   
14528     dt_fdf                      
14529   };
14530 
14534   enum SaveFlags
14535   {
14541     sf_incremental   = 0x01,
14542 
14548     sf_remove_unused = 0x02,
14549 
14560     sf_linearized    = 0x04,
14561 
14567     sf_pdf_1_4       = 0x08,
14568 
14593     sf_pdfa_buttons  = 0x10,
14594 
14604     sf_auto_incremental = 0x20
14605   };
14606 
14610   enum CopyToStreamFlags
14611   {
14617     ctsf_unsaved = 0x01
14618   };
14619 
14624   enum SetFieldFlags
14625   {
14637     sff_font_fail    = 0x01,
14638 
14657     sff_move = 0x08,
14658 
14676     sff_keep_ap = 0x10,
14677 
14698     sff_update_ap = 0x20,
14699 
14721     sff_fit_height_only = 0x40,
14722 
14733     sff_force_border_width = 0x80,
14734 
14741     sff_dont_break_lines = 0x100,
14742 
14752     sff_auto_alignment = 0x200,
14753 
14765     sff_ltr = 0x1000,
14766 
14786     sff_rtl = 0x2000,
14787 
14814     sff_default_ltr = 0x4000,
14815 
14842     sff_default_rtl = 0x8000
14843   };
14844 
14848   enum FlattenFieldsFlags
14849   {
14853     fff_include_signature_unsigned      = 0x01,
14854 
14858     fff_include_signature_signed        = 0x02,
14859 
14863     fff_include_hidden                  = 0x04,
14864 
14875     fff_keep_structure                  = 0x08
14876   };
14877 
14881   enum FlattenAnnotationsFlags
14882   {
14886     faf_include_hidden                  = 0x04,
14887 
14898     faf_keep_structure                  = 0x08
14899   };
14900 
14904   enum FindTextFlags
14905   {
14906     ftf_ignore_hspace      = 0x0001,  
14907     ftf_ignore_hyphenation = 0x0002,  
14908     ftf_ignore_sequence    = 0x0004   
14909   };
14910 
14914   enum ExportFlags
14915   {
14916     e_top = 0x01  
14917   };
14918 
14922   enum ImportFlags
14923   {
14924     i_atomic = 0x01  
14925   };
14926 
14934   enum ImportImageFlags
14935   {
14939     ii_keep_aspect_ratio = 0x01,
14940 
14971     ii_brightest_transparent = 0x02
14972   };
14973 
14977   enum KeepOrRemove
14978   {
14979     kor_keep,                   
14980     kor_remove                  
14981   };
14982 
14988   enum ReturnCode
14989   {
14990     rc_ok,                    
14991     rc_invalid_argument,      
14992     rc_field_not_found,       
14993     rc_invalid_profile,       
14994     rc_invalid_image,         
14995     rc_type_mismatch,         
14996     rc_font_not_found,        
14997     rc_no_datablock,          
14998     rc_not_supported,         
14999     rc_io_error,              
15000     rc_not_verified,          
15001     rc_property_not_found,    
15002     rc_page_not_found,        
15003     rc_wrong_collection,      
15004     rc_field_exists,          
15005     rc_license_error,         
15006     rc_unexpected_error,      
15007     rc_cancelled,             
15008     rc_no_biometric_data,     
15009     rc_parameter_not_set,     
15010     rc_field_not_signed,      
15011     rc_invalid_signature,     
15012     rc_annotation_not_found,  
15013     rc_attachment_not_found,  
15014     rc_attachment_exists,     
15015     rc_no_certificate,        
15016     rc_ambiguous_certificate, 
15017     rc_not_allowed,           
15018     rc_invalid_structure      
15019   };
15020 
15024   enum CheckAttachmentResult
15025   {
15026     car_match,                  
15027     car_no_checksum,            
15028     car_mismatch                
15029   };
15030 
15034   enum HAlignment
15035   {
15039     ha_left,
15040 
15044     ha_center,
15045 
15049     ha_right,
15050 
15056     ha_do_not_uses_this,
15057 
15062     ha_auto
15063   };
15064 
15068   enum VAlignment
15069   {
15073     va_top,
15074 
15078     va_center,
15079 
15083     va_bottom
15084   };
15085 
15089   enum AddTextRectFlags
15090   {
15111     atrf_compat = 0x01,
15112 
15122     atrf_ltr = 0x1000,
15123 
15135     atrf_rtl = 0x2000,
15136 
15155     atrf_default_ltr = 0x4000,
15156 
15175     atrf_default_rtl = 0x8000
15176   };
15177 
15183   enum Flags
15184   {
15201     f_relax_byte_range = 0x01,
15202 
15222     f_ambiguous_button_value_empty = 0x02,
15223 
15234     f_use_dss_only = 0x04,
15235 
15241     f_no_kerning_for_standard_fonts = 0x08,
15242 
15258     f_prevent_breaking_tagged_pdf = 0x10,
15259 
15275     f_keep_escape_sequences = 0x20,
15276 
15302     f_require_alternate_field_name = 0x40,
15303 
15320     f_require_lang = 0x80,
15321 
15330     f_insert_at_end = 0x100,
15331 
15358     f_use_escape_sequences = 0x200,
15359 
15371     f_fail_for_broken_target_structure = 0x400
15372   };
15373 
15377   enum ShootInFootFlags
15378   {
15385     siff_allow_breaking_signatures  = 0x01,
15386 
15392     siff_allow_breaking_permissions = 0x02,
15393 
15399     siff_allow_invalid_certificate  = 0x04,
15400 
15413     siff_allow_non_standard_external_fonts = 0x08,
15414 
15427     siff_assume_ap_not_shared = 0x10,
15428 
15442     siff_assume_ap_shared = 0x20,
15443 
15451     siff_dont_verify_after_signing = 0x40,
15452 
15475     siff_allow_all_curves = 0x80
15476   };
15477 
15481   enum UpdateDSSFlags
15482   {
15486     udf_simulate = 0x01,
15487 
15493     udf_vri      = 0x02
15494   };
15495 
15504   SignDocDocument ()
15505     : p (NULL)
15506   {
15507   }
15508 
15514   ~SignDocDocument ()
15515   {
15516     SIGNDOC_Document_delete (p);
15517   }
15518 
15524   DocumentType getType () const
15525   {
15526     SIGNDOC_Exception *ex = NULL;
15527     DocumentType r;
15528     r = (DocumentType)SIGNDOC_Document_getType (&ex, p);
15529     if (ex != NULL) SignDoc_throw (ex);
15530     return r;
15531   }
15532 
15540   int getPageCount () const
15541   {
15542     SIGNDOC_Exception *ex = NULL;
15543     int r;
15544     r = SIGNDOC_Document_getPageCount (&ex, p);
15545     if (ex != NULL) SignDoc_throw (ex);
15546     return r;
15547   }
15548 
15587   ReturnCode createSignatureParameters (Encoding aEncoding,
15588                                         const std::string &aFieldName,
15589                                         const std::string &aProfile,
15590                                         SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
15591   {
15592     SIGNDOC_Exception *ex = NULL;
15593     SIGNDOC_SignatureParameters *tempOutput = NULL;
15594     aOutput.reset ((SignDocSignatureParameters*)NULL);
15595     ReturnCode r;
15596     try
15597       {
15598         r = (ReturnCode)SIGNDOC_Document_createSignatureParameters (&ex, p, aEncoding, aFieldName.c_str (), aProfile.c_str (), &tempOutput);
15599         if (tempOutput != NULL)
15600           {
15601             aOutput.reset (new SignDocSignatureParameters (tempOutput));
15602             tempOutput = NULL;
15603           }
15604       }
15605     catch (...)
15606       {
15607         if (tempOutput != NULL)
15608           SIGNDOC_SignatureParameters_delete (tempOutput);
15609         throw;
15610       }
15611     if (tempOutput != NULL)
15612       SIGNDOC_SignatureParameters_delete (tempOutput);
15613     if (ex != NULL) SignDoc_throw (ex);
15614     return r;
15615   }
15616 
15653   ReturnCode createSignatureParameters (const wchar_t *aFieldName,
15654                                         const wchar_t *aProfile,
15655                                         SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
15656   {
15657     SIGNDOC_Exception *ex = NULL;
15658     SIGNDOC_SignatureParameters *tempOutput = NULL;
15659     aOutput.reset ((SignDocSignatureParameters*)NULL);
15660     ReturnCode r;
15661     try
15662       {
15663         r = (ReturnCode)SIGNDOC_Document_createSignatureParametersW (&ex, p, aFieldName, aProfile, &tempOutput);
15664         if (tempOutput != NULL)
15665           {
15666             aOutput.reset (new SignDocSignatureParameters (tempOutput));
15667             tempOutput = NULL;
15668           }
15669       }
15670     catch (...)
15671       {
15672         if (tempOutput != NULL)
15673           SIGNDOC_SignatureParameters_delete (tempOutput);
15674         throw;
15675       }
15676     if (tempOutput != NULL)
15677       SIGNDOC_SignatureParameters_delete (tempOutput);
15678     if (ex != NULL) SignDoc_throw (ex);
15679     return r;
15680   }
15681 
15701   ReturnCode createSignatureParametersForTimeStamp (SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
15702   {
15703     SIGNDOC_Exception *ex = NULL;
15704     SIGNDOC_SignatureParameters *tempOutput = NULL;
15705     aOutput.reset ((SignDocSignatureParameters*)NULL);
15706     ReturnCode r;
15707     try
15708       {
15709         r = (ReturnCode)SIGNDOC_Document_createSignatureParametersForTimeStamp (&ex, p, &tempOutput);
15710         if (tempOutput != NULL)
15711           {
15712             aOutput.reset (new SignDocSignatureParameters (tempOutput));
15713             tempOutput = NULL;
15714           }
15715       }
15716     catch (...)
15717       {
15718         if (tempOutput != NULL)
15719           SIGNDOC_SignatureParameters_delete (tempOutput);
15720         throw;
15721       }
15722     if (tempOutput != NULL)
15723       SIGNDOC_SignatureParameters_delete (tempOutput);
15724     if (ex != NULL) SignDoc_throw (ex);
15725     return r;
15726   }
15727 
15743   ReturnCode getProfiles (Encoding aEncoding, const std::string &aFieldName,
15744                           std::vector<std::string> &aOutput)
15745   {
15746     SIGNDOC_Exception *ex = NULL;
15747     SIGNDOC_StringArray *tempOutput = NULL;
15748     ReturnCode r;
15749     try
15750       {
15751         tempOutput = SIGNDOC_StringArray_new (&ex);
15752         if (ex != NULL) SignDoc_throw (ex);
15753         r = (ReturnCode)SIGNDOC_Document_getProfiles (&ex, p, aEncoding, aFieldName.c_str (), tempOutput);
15754         assignArray (aOutput, tempOutput);
15755       }
15756     catch (...)
15757       {
15758         if (tempOutput != NULL)
15759           SIGNDOC_StringArray_delete (tempOutput);
15760         throw;
15761       }
15762     if (tempOutput != NULL)
15763       SIGNDOC_StringArray_delete (tempOutput);
15764     if (ex != NULL) SignDoc_throw (ex);
15765     return r;
15766   }
15767 
15828   ReturnCode addSignature (SignDocSignatureParameters *aSignatureParameters,
15829                            const SignDocVerificationParameters *aVerificationParameters)
15830   {
15831     SIGNDOC_Exception *ex = NULL;
15832     ReturnCode r;
15833     r = (ReturnCode)SIGNDOC_Document_addSignature (&ex, p, aSignatureParameters == NULL ? NULL : aSignatureParameters->getImpl (), aVerificationParameters == NULL ? NULL : aVerificationParameters->getImpl ());
15834     if (ex != NULL) SignDoc_throw (ex);
15835     return r;
15836   }
15837 
15855   ReturnCode getLastTimestamp (std::string &aTime)
15856   {
15857     SIGNDOC_Exception *ex = NULL;
15858     char *tempTime = NULL;
15859     ReturnCode r;
15860     try
15861       {
15862         r = (ReturnCode)SIGNDOC_Document_getLastTimestamp (&ex, p, &tempTime);
15863         if (tempTime != NULL)
15864           aTime = tempTime;
15865       }
15866     catch (...)
15867       {
15868         SIGNDOC_free (tempTime);
15869         throw;
15870       }
15871     SIGNDOC_free (tempTime);
15872     if (ex != NULL) SignDoc_throw (ex);
15873     return r;
15874   }
15875 
15890   ReturnCode getPathname (Encoding aEncoding, std::string &aPath)
15891   {
15892     SIGNDOC_Exception *ex = NULL;
15893     char *tempPath = NULL;
15894     ReturnCode r;
15895     try
15896       {
15897         r = (ReturnCode)SIGNDOC_Document_getPathname (&ex, p, aEncoding, &tempPath);
15898         if (tempPath != NULL)
15899           aPath = tempPath;
15900       }
15901     catch (...)
15902       {
15903         SIGNDOC_free (tempPath);
15904         throw;
15905       }
15906     SIGNDOC_free (tempPath);
15907     if (ex != NULL) SignDoc_throw (ex);
15908     return r;
15909   }
15910 
15922   int getAvailableMethods ()
15923   {
15924     SIGNDOC_Exception *ex = NULL;
15925     int r;
15926     r = SIGNDOC_Document_getAvailableMethods (&ex, p);
15927     if (ex != NULL) SignDoc_throw (ex);
15928     return r;
15929   }
15930 
15940   int getSignatureCount ()
15941   {
15942     SIGNDOC_Exception *ex = NULL;
15943     int r;
15944     r = SIGNDOC_Document_getSignatureCount (&ex, p);
15945     if (ex != NULL) SignDoc_throw (ex);
15946     return r;
15947   }
15948 
15968   ReturnCode getSignature (int aIndex, SIGNDOC_PTR<SignDocSignature> &aOutput)
15969   {
15970     SIGNDOC_Exception *ex = NULL;
15971     SIGNDOC_Signature *tempOutput = NULL;
15972     aOutput.reset ((SignDocSignature*)NULL);
15973     ReturnCode r;
15974     try
15975       {
15976         r = (ReturnCode)SIGNDOC_Document_getSignature (&ex, p, aIndex, &tempOutput);
15977         if (tempOutput != NULL)
15978           {
15979             aOutput.reset (new SignDocSignature (tempOutput));
15980             tempOutput = NULL;
15981           }
15982       }
15983     catch (...)
15984       {
15985         if (tempOutput != NULL)
15986           SIGNDOC_Signature_delete (tempOutput);
15987         throw;
15988       }
15989     if (tempOutput != NULL)
15990       SIGNDOC_Signature_delete (tempOutput);
15991     if (ex != NULL) SignDoc_throw (ex);
15992     return r;
15993   }
15994 
16012   ReturnCode verifySignature (Encoding aEncoding,
16013                               const std::string &aFieldName,
16014                               SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
16015   {
16016     SIGNDOC_Exception *ex = NULL;
16017     SIGNDOC_VerificationResult *tempOutput = NULL;
16018     aOutput.reset ((SignDocVerificationResult*)NULL);
16019     ReturnCode r;
16020     try
16021       {
16022         r = (ReturnCode)SIGNDOC_Document_verifySignature (&ex, p, aEncoding, aFieldName.c_str (), &tempOutput);
16023         if (tempOutput != NULL)
16024           {
16025             aOutput.reset (makeSignDocVerificationResult (tempOutput));
16026             tempOutput = NULL;
16027           }
16028       }
16029     catch (...)
16030       {
16031         if (tempOutput != NULL)
16032           SIGNDOC_VerificationResult_delete (tempOutput);
16033         throw;
16034       }
16035     if (tempOutput != NULL)
16036       SIGNDOC_VerificationResult_delete (tempOutput);
16037     if (ex != NULL) SignDoc_throw (ex);
16038     return r;
16039   }
16040 
16056   ReturnCode verifySignature (const wchar_t *aFieldName,
16057                               SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
16058   {
16059     SIGNDOC_Exception *ex = NULL;
16060     SIGNDOC_VerificationResult *tempOutput = NULL;
16061     aOutput.reset ((SignDocVerificationResult*)NULL);
16062     ReturnCode r;
16063     try
16064       {
16065         r = (ReturnCode)SIGNDOC_Document_verifySignatureW (&ex, p, aFieldName, &tempOutput);
16066         if (tempOutput != NULL)
16067           {
16068             aOutput.reset (makeSignDocVerificationResult (tempOutput));
16069             tempOutput = NULL;
16070           }
16071       }
16072     catch (...)
16073       {
16074         if (tempOutput != NULL)
16075           SIGNDOC_VerificationResult_delete (tempOutput);
16076         throw;
16077       }
16078     if (tempOutput != NULL)
16079       SIGNDOC_VerificationResult_delete (tempOutput);
16080     if (ex != NULL) SignDoc_throw (ex);
16081     return r;
16082   }
16083 
16111   ReturnCode verifySignature2 (const SignDocSignature &aSignature,
16112                                SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
16113   {
16114     SIGNDOC_Exception *ex = NULL;
16115     SIGNDOC_VerificationResult *tempOutput = NULL;
16116     aOutput.reset ((SignDocVerificationResult*)NULL);
16117     ReturnCode r;
16118     try
16119       {
16120         r = (ReturnCode)SIGNDOC_Document_verifySignature2 (&ex, p, aSignature.getImpl (), &tempOutput);
16121         if (tempOutput != NULL)
16122           {
16123             aOutput.reset (makeSignDocVerificationResult (tempOutput));
16124             tempOutput = NULL;
16125           }
16126       }
16127     catch (...)
16128       {
16129         if (tempOutput != NULL)
16130           SIGNDOC_VerificationResult_delete (tempOutput);
16131         throw;
16132       }
16133     if (tempOutput != NULL)
16134       SIGNDOC_VerificationResult_delete (tempOutput);
16135     if (ex != NULL) SignDoc_throw (ex);
16136     return r;
16137   }
16138 
16153   ReturnCode clearSignature (Encoding aEncoding, const std::string &aFieldName)
16154   {
16155     SIGNDOC_Exception *ex = NULL;
16156     ReturnCode r;
16157     r = (ReturnCode)SIGNDOC_Document_clearSignature (&ex, p, aEncoding, aFieldName.c_str ());
16158     if (ex != NULL) SignDoc_throw (ex);
16159     return r;
16160   }
16161 
16171   ReturnCode clearAllSignatures ()
16172   {
16173     SIGNDOC_Exception *ex = NULL;
16174     ReturnCode r;
16175     r = (ReturnCode)SIGNDOC_Document_clearAllSignatures (&ex, p);
16176     if (ex != NULL) SignDoc_throw (ex);
16177     return r;
16178   }
16179 
16189   ReturnCode clearApprovalSignatures ()
16190   {
16191     SIGNDOC_Exception *ex = NULL;
16192     ReturnCode r;
16193     r = (ReturnCode)SIGNDOC_Document_clearApprovalSignatures (&ex, p);
16194     if (ex != NULL) SignDoc_throw (ex);
16195     return r;
16196   }
16197 
16230   ReturnCode updateDSS (const SignDocVerificationParameters *aParameters,
16231                         unsigned aFlags, int &aCount)
16232   {
16233     SIGNDOC_Exception *ex = NULL;
16234     ReturnCode r;
16235     r = (ReturnCode)SIGNDOC_Document_updateDSS (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), aFlags, &aCount);
16236     if (ex != NULL) SignDoc_throw (ex);
16237     return r;
16238   }
16239 
16278   ReturnCode updateDSS2 (Encoding aEncoding, const std::string &aFieldName,
16279                          const SignDocVerificationParameters *aParameters,
16280                          unsigned aFlags)
16281   {
16282     SIGNDOC_Exception *ex = NULL;
16283     ReturnCode r;
16284     r = (ReturnCode)SIGNDOC_Document_updateDSS2 (&ex, p, aEncoding, aFieldName.c_str (), aParameters == NULL ? NULL : aParameters->getImpl (), aFlags);
16285     if (ex != NULL) SignDoc_throw (ex);
16286     return r;
16287   }
16288 
16308   ReturnCode saveToStream (OutputStream &aStream, int aFlags)
16309   {
16310     SIGNDOC_Exception *ex = NULL;
16311     ReturnCode r;
16312     r = (ReturnCode)SIGNDOC_Document_saveToStream (&ex, p, aStream.getImpl (), aFlags);
16313     if (ex != NULL) SignDoc_throw (ex);
16314     return r;
16315   }
16316 
16348   ReturnCode saveToFile (Encoding aEncoding, const char *aPath, int aFlags)
16349   {
16350     SIGNDOC_Exception *ex = NULL;
16351     ReturnCode r;
16352     r = (ReturnCode)SIGNDOC_Document_saveToFile (&ex, p, aEncoding, aPath, aFlags);
16353     if (ex != NULL) SignDoc_throw (ex);
16354     return r;
16355   }
16356 
16382   ReturnCode saveToFile (const wchar_t *aPath, int aFlags)
16383   {
16384     SIGNDOC_Exception *ex = NULL;
16385     ReturnCode r;
16386     r = (ReturnCode)SIGNDOC_Document_saveToFileW (&ex, p, aPath, aFlags);
16387     if (ex != NULL) SignDoc_throw (ex);
16388     return r;
16389   }
16390 
16417   ReturnCode copyToStream (OutputStream &aStream, unsigned aFlags)
16418   {
16419     SIGNDOC_Exception *ex = NULL;
16420     ReturnCode r;
16421     r = (ReturnCode)SIGNDOC_Document_copyToStream (&ex, p, aStream.getImpl (), aFlags);
16422     if (ex != NULL) SignDoc_throw (ex);
16423     return r;
16424   }
16425 
16444   ReturnCode copyAsSignedToStream (Encoding aEncoding,
16445                                    const std::string &aFieldName,
16446                                    OutputStream &aStream)
16447   {
16448     SIGNDOC_Exception *ex = NULL;
16449     ReturnCode r;
16450     r = (ReturnCode)SIGNDOC_Document_copyAsSignedToStream (&ex, p, aEncoding, aFieldName.c_str (), aStream.getImpl ());
16451     if (ex != NULL) SignDoc_throw (ex);
16452     return r;
16453   }
16454 
16470   ReturnCode getSaveToStreamFlags (int &aOutput)
16471   {
16472     SIGNDOC_Exception *ex = NULL;
16473     ReturnCode r;
16474     r = (ReturnCode)SIGNDOC_Document_getSaveToStreamFlags (&ex, p, &aOutput);
16475     if (ex != NULL) SignDoc_throw (ex);
16476     return r;
16477   }
16478 
16493   ReturnCode getSaveToFileFlags (int &aOutput)
16494   {
16495     SIGNDOC_Exception *ex = NULL;
16496     ReturnCode r;
16497     r = (ReturnCode)SIGNDOC_Document_getSaveToFileFlags (&ex, p, &aOutput);
16498     if (ex != NULL) SignDoc_throw (ex);
16499     return r;
16500   }
16501 
16515   ReturnCode getRequiredSaveToFileFlags (int &aOutput)
16516   {
16517     SIGNDOC_Exception *ex = NULL;
16518     ReturnCode r;
16519     r = (ReturnCode)SIGNDOC_Document_getRequiredSaveToFileFlags (&ex, p, &aOutput);
16520     if (ex != NULL) SignDoc_throw (ex);
16521     return r;
16522   }
16523 
16541   ReturnCode getFields (int aTypes, std::vector<SignDocField> &aOutput)
16542   {
16543     SIGNDOC_Exception *ex = NULL;
16544     SIGNDOC_FieldArray *tempOutput = NULL;
16545     ReturnCode r;
16546     try
16547       {
16548         tempOutput = SIGNDOC_FieldArray_new (&ex);
16549         if (ex != NULL) SignDoc_throw (ex);
16550         r = (ReturnCode)SIGNDOC_Document_getFields (&ex, p, aTypes, tempOutput);
16551         assignArray (aOutput, tempOutput);
16552       }
16553     catch (...)
16554       {
16555         if (tempOutput != NULL)
16556           SIGNDOC_FieldArray_delete (tempOutput);
16557         throw;
16558       }
16559     if (tempOutput != NULL)
16560       SIGNDOC_FieldArray_delete (tempOutput);
16561     if (ex != NULL) SignDoc_throw (ex);
16562     return r;
16563   }
16564 
16591   ReturnCode getFieldsOfPage (int aPage, int aTypes,
16592                               std::vector<SignDocField> &aOutput)
16593   {
16594     SIGNDOC_Exception *ex = NULL;
16595     SIGNDOC_FieldArray *tempOutput = NULL;
16596     ReturnCode r;
16597     try
16598       {
16599         tempOutput = SIGNDOC_FieldArray_new (&ex);
16600         if (ex != NULL) SignDoc_throw (ex);
16601         r = (ReturnCode)SIGNDOC_Document_getFieldsOfPage (&ex, p, aPage, aTypes, tempOutput);
16602         assignArray (aOutput, tempOutput);
16603       }
16604     catch (...)
16605       {
16606         if (tempOutput != NULL)
16607           SIGNDOC_FieldArray_delete (tempOutput);
16608         throw;
16609       }
16610     if (tempOutput != NULL)
16611       SIGNDOC_FieldArray_delete (tempOutput);
16612     if (ex != NULL) SignDoc_throw (ex);
16613     return r;
16614   }
16615 
16630   ReturnCode getField (Encoding aEncoding, const std::string &aName,
16631                        SignDocField &aOutput)
16632   {
16633     SIGNDOC_Exception *ex = NULL;
16634     ReturnCode r;
16635     r = (ReturnCode)SIGNDOC_Document_getField (&ex, p, aEncoding, aName.c_str (), aOutput.getImpl ());
16636     if (ex != NULL) SignDoc_throw (ex);
16637     return r;
16638   }
16639 
16683   ReturnCode setField (SignDocField &aField, unsigned aFlags)
16684   {
16685     SIGNDOC_Exception *ex = NULL;
16686     ReturnCode r;
16687     r = (ReturnCode)SIGNDOC_Document_setField (&ex, p, aField.getImpl (), aFlags);
16688     if (ex != NULL) SignDoc_throw (ex);
16689     return r;
16690   }
16691 
16740   ReturnCode addField (SignDocField &aField, unsigned aFlags)
16741   {
16742     SIGNDOC_Exception *ex = NULL;
16743     ReturnCode r;
16744     r = (ReturnCode)SIGNDOC_Document_addField (&ex, p, aField.getImpl (), aFlags);
16745     if (ex != NULL) SignDoc_throw (ex);
16746     return r;
16747   }
16748 
16761   ReturnCode removeField (Encoding aEncoding, const std::string &aName)
16762   {
16763     SIGNDOC_Exception *ex = NULL;
16764     ReturnCode r;
16765     r = (ReturnCode)SIGNDOC_Document_removeField (&ex, p, aEncoding, aName.c_str ());
16766     if (ex != NULL) SignDoc_throw (ex);
16767     return r;
16768   }
16769 
16797   ReturnCode flattenField (Encoding aEncoding, const std::string &aName,
16798                            int aWidget)
16799   {
16800     SIGNDOC_Exception *ex = NULL;
16801     ReturnCode r;
16802     r = (ReturnCode)SIGNDOC_Document_flattenField (&ex, p, aEncoding, aName.c_str (), aWidget);
16803     if (ex != NULL) SignDoc_throw (ex);
16804     return r;
16805   }
16806 
16838   ReturnCode flattenFields (int aFirstPage, int aLastPage, unsigned aFlags)
16839   {
16840     SIGNDOC_Exception *ex = NULL;
16841     ReturnCode r;
16842     r = (ReturnCode)SIGNDOC_Document_flattenFields (&ex, p, aFirstPage, aLastPage, aFlags);
16843     if (ex != NULL) SignDoc_throw (ex);
16844     return r;
16845   }
16846 
16866   ReturnCode exportFields (OutputStream &aStream, int aFlags)
16867   {
16868     SIGNDOC_Exception *ex = NULL;
16869     ReturnCode r;
16870     r = (ReturnCode)SIGNDOC_Document_exportFields (&ex, p, aStream.getImpl (), aFlags);
16871     if (ex != NULL) SignDoc_throw (ex);
16872     return r;
16873   }
16874 
16889   ReturnCode applyFdf (Encoding aEncoding, const char *aPath, unsigned aFlags)
16890   {
16891     SIGNDOC_Exception *ex = NULL;
16892     ReturnCode r;
16893     r = (ReturnCode)SIGNDOC_Document_applyFdf (&ex, p, aEncoding, aPath, aFlags);
16894     if (ex != NULL) SignDoc_throw (ex);
16895     return r;
16896   }
16897 
16909   ReturnCode applyFdf (const wchar_t *aPath, unsigned aFlags)
16910   {
16911     SIGNDOC_Exception *ex = NULL;
16912     ReturnCode r;
16913     r = (ReturnCode)SIGNDOC_Document_applyFdfW (&ex, p, aPath, aFlags);
16914     if (ex != NULL) SignDoc_throw (ex);
16915     return r;
16916   }
16917 
16927   ReturnCode getTextFieldAttributes (SignDocTextFieldAttributes &aOutput)
16928   {
16929     SIGNDOC_Exception *ex = NULL;
16930     ReturnCode r;
16931     r = (ReturnCode)SIGNDOC_Document_getTextFieldAttributes (&ex, p, aOutput.getImpl ());
16932     if (ex != NULL) SignDoc_throw (ex);
16933     return r;
16934   }
16935 
16954   ReturnCode setTextFieldAttributes (SignDocTextFieldAttributes &aData)
16955   {
16956     SIGNDOC_Exception *ex = NULL;
16957     ReturnCode r;
16958     r = (ReturnCode)SIGNDOC_Document_setTextFieldAttributes (&ex, p, aData.getImpl ());
16959     if (ex != NULL) SignDoc_throw (ex);
16960     return r;
16961   }
16962 
17032   ReturnCode getProperties (const std::string &aCollection,
17033                             std::vector<SignDocProperty> &aOutput)
17034   {
17035     SIGNDOC_Exception *ex = NULL;
17036     SIGNDOC_PropertyArray *tempOutput = NULL;
17037     ReturnCode r;
17038     try
17039       {
17040         tempOutput = SIGNDOC_PropertyArray_new (&ex);
17041         if (ex != NULL) SignDoc_throw (ex);
17042         r = (ReturnCode)SIGNDOC_Document_getProperties (&ex, p, aCollection.c_str (), tempOutput);
17043         assignArray (aOutput, tempOutput);
17044       }
17045     catch (...)
17046       {
17047         if (tempOutput != NULL)
17048           SIGNDOC_PropertyArray_delete (tempOutput);
17049         throw;
17050       }
17051     if (tempOutput != NULL)
17052       SIGNDOC_PropertyArray_delete (tempOutput);
17053     if (ex != NULL) SignDoc_throw (ex);
17054     return r;
17055   }
17056 
17073   ReturnCode getIntegerProperty (Encoding aEncoding,
17074                                  const std::string &aCollection,
17075                                  const std::string &aName, long &aValue)
17076   {
17077     SIGNDOC_Exception *ex = NULL;
17078     ReturnCode r;
17079     r = (ReturnCode)SIGNDOC_Document_getIntegerProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &aValue);
17080     if (ex != NULL) SignDoc_throw (ex);
17081     return r;
17082   }
17083 
17101   ReturnCode getStringProperty (Encoding aEncoding,
17102                                 const std::string &aCollection,
17103                                 const std::string &aName, std::string &aValue)
17104   {
17105     SIGNDOC_Exception *ex = NULL;
17106     char *tempValue = NULL;
17107     ReturnCode r;
17108     try
17109       {
17110         r = (ReturnCode)SIGNDOC_Document_getStringProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &tempValue);
17111         if (tempValue != NULL)
17112           aValue = tempValue;
17113       }
17114     catch (...)
17115       {
17116         SIGNDOC_free (tempValue);
17117         throw;
17118       }
17119     SIGNDOC_free (tempValue);
17120     if (ex != NULL) SignDoc_throw (ex);
17121     return r;
17122   }
17123 
17140   ReturnCode getBooleanProperty (Encoding aEncoding,
17141                                  const std::string &aCollection,
17142                                  const std::string &aName, bool &aValue)
17143   {
17144     SIGNDOC_Exception *ex = NULL;
17145     SIGNDOC_Boolean tempValue = 0;
17146     ReturnCode r;
17147     try
17148       {
17149         r = (ReturnCode)SIGNDOC_Document_getBooleanProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &tempValue);
17150         aValue = (bool )tempValue;
17151       }
17152     catch (...)
17153       {
17154         throw;
17155       }
17156     if (ex != NULL) SignDoc_throw (ex);
17157     return r;
17158   }
17159 
17178   ReturnCode setIntegerProperty (Encoding aEncoding,
17179                                  const std::string &aCollection,
17180                                  const std::string &aName, long aValue)
17181   {
17182     SIGNDOC_Exception *ex = NULL;
17183     ReturnCode r;
17184     r = (ReturnCode)SIGNDOC_Document_setIntegerProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue);
17185     if (ex != NULL) SignDoc_throw (ex);
17186     return r;
17187   }
17188 
17208   ReturnCode setStringProperty (Encoding aEncoding,
17209                                 const std::string &aCollection,
17210                                 const std::string &aName,
17211                                 const std::string &aValue)
17212   {
17213     SIGNDOC_Exception *ex = NULL;
17214     ReturnCode r;
17215     r = (ReturnCode)SIGNDOC_Document_setStringProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue.c_str ());
17216     if (ex != NULL) SignDoc_throw (ex);
17217     return r;
17218   }
17219 
17238   ReturnCode setBooleanProperty (Encoding aEncoding,
17239                                  const std::string &aCollection,
17240                                  const std::string &aName, bool aValue)
17241   {
17242     SIGNDOC_Exception *ex = NULL;
17243     ReturnCode r;
17244     r = (ReturnCode)SIGNDOC_Document_setBooleanProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue);
17245     if (ex != NULL) SignDoc_throw (ex);
17246     return r;
17247   }
17248 
17264   ReturnCode removeProperty (Encoding aEncoding,
17265                              const std::string &aCollection,
17266                              const std::string &aName)
17267   {
17268     SIGNDOC_Exception *ex = NULL;
17269     ReturnCode r;
17270     r = (ReturnCode)SIGNDOC_Document_removeProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str ());
17271     if (ex != NULL) SignDoc_throw (ex);
17272     return r;
17273   }
17274 
17295   ReturnCode exportProperties (const std::string &aCollection,
17296                                OutputStream &aStream, int aFlags)
17297   {
17298     SIGNDOC_Exception *ex = NULL;
17299     ReturnCode r;
17300     r = (ReturnCode)SIGNDOC_Document_exportProperties (&ex, p, aCollection.c_str (), aStream.getImpl (), aFlags);
17301     if (ex != NULL) SignDoc_throw (ex);
17302     return r;
17303   }
17304 
17327   ReturnCode importProperties (const std::string &aCollection,
17328                                InputStream &aStream, int aFlags)
17329   {
17330     SIGNDOC_Exception *ex = NULL;
17331     ReturnCode r;
17332     r = (ReturnCode)SIGNDOC_Document_importProperties (&ex, p, aCollection.c_str (), aStream.getImpl (), aFlags);
17333     if (ex != NULL) SignDoc_throw (ex);
17334     return r;
17335   }
17336 
17356   ReturnCode getResolution (int aPage, double &aResX, double &aResY)
17357   {
17358     SIGNDOC_Exception *ex = NULL;
17359     ReturnCode r;
17360     r = (ReturnCode)SIGNDOC_Document_getResolution (&ex, p, aPage, &aResX, &aResY);
17361     if (ex != NULL) SignDoc_throw (ex);
17362     return r;
17363   }
17364 
17386   ReturnCode getConversionFactors (int aPage, double &aFactorX,
17387                                    double &aFactorY)
17388   {
17389     SIGNDOC_Exception *ex = NULL;
17390     ReturnCode r;
17391     r = (ReturnCode)SIGNDOC_Document_getConversionFactors (&ex, p, aPage, &aFactorX, &aFactorY);
17392     if (ex != NULL) SignDoc_throw (ex);
17393     return r;
17394   }
17395 
17413   ReturnCode getPageSize (int aPage, double &aWidth, double &aHeight)
17414   {
17415     SIGNDOC_Exception *ex = NULL;
17416     ReturnCode r;
17417     r = (ReturnCode)SIGNDOC_Document_getPageSize (&ex, p, aPage, &aWidth, &aHeight);
17418     if (ex != NULL) SignDoc_throw (ex);
17419     return r;
17420   }
17421 
17436   ReturnCode getBitsPerPixel (int aPage, int &aBPP)
17437   {
17438     SIGNDOC_Exception *ex = NULL;
17439     ReturnCode r;
17440     r = (ReturnCode)SIGNDOC_Document_getBitsPerPixel (&ex, p, aPage, &aBPP);
17441     if (ex != NULL) SignDoc_throw (ex);
17442     return r;
17443   }
17444 
17463   ReturnCode computeZoom (double &aOutput,
17464                           const SignDocRenderParameters &aParams)
17465   {
17466     SIGNDOC_Exception *ex = NULL;
17467     ReturnCode r;
17468     r = (ReturnCode)SIGNDOC_Document_computeZoom (&ex, p, &aOutput, aParams.getImpl ());
17469     if (ex != NULL) SignDoc_throw (ex);
17470     return r;
17471   }
17472 
17494   ReturnCode convCanvasPointToPagePoint (Point &aPoint,
17495                                          const SignDocRenderParameters &aParams)
17496   {
17497     SIGNDOC_Exception *ex = NULL;
17498     ReturnCode r;
17499     r = (ReturnCode)SIGNDOC_Document_convCanvasPointToPagePoint (&ex, p, (SIGNDOC_Point*)&aPoint, aParams.getImpl ());
17500     if (ex != NULL) SignDoc_throw (ex);
17501     return r;
17502   }
17503 
17524   ReturnCode convPagePointToCanvasPoint (Point &aPoint,
17525                                          const SignDocRenderParameters &aParams)
17526   {
17527     SIGNDOC_Exception *ex = NULL;
17528     ReturnCode r;
17529     r = (ReturnCode)SIGNDOC_Document_convPagePointToCanvasPoint (&ex, p, (SIGNDOC_Point*)&aPoint, aParams.getImpl ());
17530     if (ex != NULL) SignDoc_throw (ex);
17531     return r;
17532   }
17533 
17560   ReturnCode renderPageAsImage (std::vector<unsigned char> &aImage,
17561                                 SignDocRenderOutput &aOutput,
17562                                 const SignDocRenderParameters &aRenderParameters,
17563                                 const SignDocVerificationParameters *aVerificationParameters,
17564                                 const Rect *aClipRect)
17565   {
17566     SIGNDOC_Exception *ex = NULL;
17567     SIGNDOC_ByteArray *tempImage = NULL;
17568     ReturnCode r;
17569     try
17570       {
17571         tempImage = SIGNDOC_ByteArray_new (&ex);
17572         if (ex != NULL) SignDoc_throw (ex);
17573         r = (ReturnCode)SIGNDOC_Document_renderPageAsImage (&ex, p, tempImage, (SIGNDOC_RenderOutput*)&aOutput, aRenderParameters.getImpl (), aVerificationParameters == NULL ? NULL : aVerificationParameters->getImpl (), (const SIGNDOC_Rect*)aClipRect);
17574         assignArray (aImage, tempImage);
17575       }
17576     catch (...)
17577       {
17578         if (tempImage != NULL)
17579           SIGNDOC_ByteArray_delete (tempImage);
17580         throw;
17581       }
17582     if (tempImage != NULL)
17583       SIGNDOC_ByteArray_delete (tempImage);
17584     if (ex != NULL) SignDoc_throw (ex);
17585     return r;
17586   }
17587 
17605   ReturnCode getRenderedSize (SignDocRenderOutput &aOutput,
17606                               const SignDocRenderParameters &aRenderParameters)
17607   {
17608     SIGNDOC_Exception *ex = NULL;
17609     ReturnCode r;
17610     r = (ReturnCode)SIGNDOC_Document_getRenderedSize (&ex, p, (SIGNDOC_RenderOutput*)&aOutput, aRenderParameters.getImpl ());
17611     if (ex != NULL) SignDoc_throw (ex);
17612     return r;
17613   }
17614 
17631   SignDocAnnotation *createLineAnnotation (const Point &aStart,
17632                                            const Point &aEnd)
17633   {
17634     SIGNDOC_Exception *ex = NULL;
17635     SIGNDOC_Annotation *r;
17636     r = SIGNDOC_Document_createLineAnnotation (&ex, p, (const SIGNDOC_Point*)&aStart, (const SIGNDOC_Point*)&aEnd);
17637     if (ex != NULL) SignDoc_throw (ex);
17638     if (r == NULL)
17639       return NULL;
17640     try
17641       {
17642         return new SignDocAnnotation (r);
17643       }
17644     catch (...)
17645       {
17646         SIGNDOC_Annotation_delete (r);
17647         throw;
17648       }
17649   }
17650 
17668   SignDocAnnotation *createLineAnnotation (double aStartX, double aStartY,
17669                                            double aEndX, double aEndY)
17670   {
17671     SIGNDOC_Exception *ex = NULL;
17672     SIGNDOC_Annotation *r;
17673     r = SIGNDOC_Document_createLineAnnotationXY (&ex, p, aStartX, aStartY, aEndX, aEndY);
17674     if (ex != NULL) SignDoc_throw (ex);
17675     if (r == NULL)
17676       return NULL;
17677     try
17678       {
17679         return new SignDocAnnotation (r);
17680       }
17681     catch (...)
17682       {
17683         SIGNDOC_Annotation_delete (r);
17684         throw;
17685       }
17686   }
17687 
17700   SignDocAnnotation *createScribbleAnnotation ()
17701   {
17702     SIGNDOC_Exception *ex = NULL;
17703     SIGNDOC_Annotation *r;
17704     r = SIGNDOC_Document_createScribbleAnnotation (&ex, p);
17705     if (ex != NULL) SignDoc_throw (ex);
17706     if (r == NULL)
17707       return NULL;
17708     try
17709       {
17710         return new SignDocAnnotation (r);
17711       }
17712     catch (...)
17713       {
17714         SIGNDOC_Annotation_delete (r);
17715         throw;
17716       }
17717   }
17718 
17734   SignDocAnnotation *createFreeTextAnnotation (const Point &aLowerLeft,
17735                                                const Point &aUpperRight)
17736   {
17737     SIGNDOC_Exception *ex = NULL;
17738     SIGNDOC_Annotation *r;
17739     r = SIGNDOC_Document_createFreeTextAnnotation (&ex, p, (const SIGNDOC_Point*)&aLowerLeft, (const SIGNDOC_Point*)&aUpperRight);
17740     if (ex != NULL) SignDoc_throw (ex);
17741     if (r == NULL)
17742       return NULL;
17743     try
17744       {
17745         return new SignDocAnnotation (r);
17746       }
17747     catch (...)
17748       {
17749         SIGNDOC_Annotation_delete (r);
17750         throw;
17751       }
17752   }
17753 
17771   SignDocAnnotation *createFreeTextAnnotation (double aX0, double aY0,
17772                                                double aX1, double aY1)
17773   {
17774     SIGNDOC_Exception *ex = NULL;
17775     SIGNDOC_Annotation *r;
17776     r = SIGNDOC_Document_createFreeTextAnnotationXY (&ex, p, aX0, aY0, aX1, aY1);
17777     if (ex != NULL) SignDoc_throw (ex);
17778     if (r == NULL)
17779       return NULL;
17780     try
17781       {
17782         return new SignDocAnnotation (r);
17783       }
17784     catch (...)
17785       {
17786         SIGNDOC_Annotation_delete (r);
17787         throw;
17788       }
17789   }
17790 
17804   ReturnCode addAnnotation (int aPage, const SignDocAnnotation *aAnnot)
17805   {
17806     SIGNDOC_Exception *ex = NULL;
17807     ReturnCode r;
17808     r = (ReturnCode)SIGNDOC_Document_addAnnotation (&ex, p, aPage, aAnnot == NULL ? NULL : aAnnot->getImpl ());
17809     if (ex != NULL) SignDoc_throw (ex);
17810     return r;
17811   }
17812 
17832   ReturnCode getAnnotations (Encoding aEncoding, int aPage,
17833                              std::vector<std::string> &aOutput)
17834   {
17835     SIGNDOC_Exception *ex = NULL;
17836     SIGNDOC_StringArray *tempOutput = NULL;
17837     ReturnCode r;
17838     try
17839       {
17840         tempOutput = SIGNDOC_StringArray_new (&ex);
17841         if (ex != NULL) SignDoc_throw (ex);
17842         r = (ReturnCode)SIGNDOC_Document_getAnnotations (&ex, p, aEncoding, aPage, tempOutput);
17843         assignArray (aOutput, tempOutput);
17844       }
17845     catch (...)
17846       {
17847         if (tempOutput != NULL)
17848           SIGNDOC_StringArray_delete (tempOutput);
17849         throw;
17850       }
17851     if (tempOutput != NULL)
17852       SIGNDOC_StringArray_delete (tempOutput);
17853     if (ex != NULL) SignDoc_throw (ex);
17854     return r;
17855   }
17856 
17873   ReturnCode getAnnotation (Encoding aEncoding, int aPage,
17874                             const std::string &aName,
17875                             SIGNDOC_PTR<SignDocAnnotation> &aOutput)
17876   {
17877     SIGNDOC_Exception *ex = NULL;
17878     SIGNDOC_Annotation *tempOutput = NULL;
17879     aOutput.reset ((SignDocAnnotation*)NULL);
17880     ReturnCode r;
17881     try
17882       {
17883         r = (ReturnCode)SIGNDOC_Document_getAnnotation (&ex, p, aEncoding, aPage, aName.c_str (), &tempOutput);
17884         if (tempOutput != NULL)
17885           {
17886             aOutput.reset (new SignDocAnnotation (tempOutput));
17887             tempOutput = NULL;
17888           }
17889       }
17890     catch (...)
17891       {
17892         if (tempOutput != NULL)
17893           SIGNDOC_Annotation_delete (tempOutput);
17894         throw;
17895       }
17896     if (tempOutput != NULL)
17897       SIGNDOC_Annotation_delete (tempOutput);
17898     if (ex != NULL) SignDoc_throw (ex);
17899     return r;
17900   }
17901 
17914   ReturnCode removeAnnotation (Encoding aEncoding, int aPage,
17915                                const std::string &aName)
17916   {
17917     SIGNDOC_Exception *ex = NULL;
17918     ReturnCode r;
17919     r = (ReturnCode)SIGNDOC_Document_removeAnnotation (&ex, p, aEncoding, aPage, aName.c_str ());
17920     if (ex != NULL) SignDoc_throw (ex);
17921     return r;
17922   }
17923 
17964   ReturnCode addText (Encoding aEncoding, const std::string &aText, int aPage,
17965                       double aX, double aY, const std::string &aFontName,
17966                       double aFontSize, const SignDocColor &aTextColor,
17967                       double aOpacity, int aFlags)
17968   {
17969     SIGNDOC_Exception *ex = NULL;
17970     ReturnCode r;
17971     r = (ReturnCode)SIGNDOC_Document_addText (&ex, p, aEncoding, aText.c_str (), aPage, aX, aY, aFontName.c_str (), aFontSize, aTextColor.getImpl (), aOpacity, aFlags);
17972     if (ex != NULL) SignDoc_throw (ex);
17973     return r;
17974   }
17975 
18026   ReturnCode addText2 (Encoding aEncoding, const std::string &aText, int aPage,
18027                        double aX, double aY, const std::string &aFontName,
18028                        double aFontSize, const SignDocColor &aTextColor,
18029                        double aOpacity, int aFlags, const std::string &aLang)
18030   {
18031     SIGNDOC_Exception *ex = NULL;
18032     ReturnCode r;
18033     r = (ReturnCode)SIGNDOC_Document_addText2 (&ex, p, aEncoding, aText.c_str (), aPage, aX, aY, aFontName.c_str (), aFontSize, aTextColor.getImpl (), aOpacity, aFlags, aLang.c_str ());
18034     if (ex != NULL) SignDoc_throw (ex);
18035     return r;
18036   }
18037 
18079   ReturnCode addTextRect (Encoding aEncoding, const std::string &aText,
18080                           int aPage, double aX0, double aY0, double aX1,
18081                           double aY1, const std::string &aFontName,
18082                           double aFontSize, double aLineSkip,
18083                           const SignDocColor &aTextColor, double aOpacity,
18084                           HAlignment aHAlignment, VAlignment aVAlignment,
18085                           int aFlags)
18086   {
18087     SIGNDOC_Exception *ex = NULL;
18088     ReturnCode r;
18089     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);
18090     if (ex != NULL) SignDoc_throw (ex);
18091     return r;
18092   }
18093 
18146   ReturnCode addTextRect2 (Encoding aEncoding, const std::string &aText,
18147                            int aPage, double aX0, double aY0, double aX1,
18148                            double aY1, const std::string &aFontName,
18149                            double aFontSize, double aLineSkip,
18150                            const SignDocColor &aTextColor, double aOpacity,
18151                            HAlignment aHAlignment, VAlignment aVAlignment,
18152                            int aFlags, const std::string &aLang)
18153   {
18154     SIGNDOC_Exception *ex = NULL;
18155     ReturnCode r;
18156     r = (ReturnCode)SIGNDOC_Document_addTextRect2 (&ex, p, aEncoding, aText.c_str (), aPage, aX0, aY0, aX1, aY1, aFontName.c_str (), aFontSize, aLineSkip, aTextColor.getImpl (), aOpacity, aHAlignment, aVAlignment, aFlags, aLang.c_str ());
18157     if (ex != NULL) SignDoc_throw (ex);
18158     return r;
18159   }
18160 
18172   ReturnCode addWatermark (const SignDocWatermark &aInput)
18173   {
18174     SIGNDOC_Exception *ex = NULL;
18175     ReturnCode r;
18176     r = (ReturnCode)SIGNDOC_Document_addWatermark (&ex, p, aInput.getImpl ());
18177     if (ex != NULL) SignDoc_throw (ex);
18178     return r;
18179   }
18180 
18200   ReturnCode findText (Encoding aEncoding, int aFirstPage, int aLastPage,
18201                        const std::string &aText, int aFlags,
18202                        std::vector<SignDocFindTextPosition> &aOutput)
18203   {
18204     SIGNDOC_Exception *ex = NULL;
18205     SIGNDOC_FindTextPositionArray *tempOutput = NULL;
18206     ReturnCode r;
18207     try
18208       {
18209         tempOutput = SIGNDOC_FindTextPositionArray_new (&ex);
18210         if (ex != NULL) SignDoc_throw (ex);
18211         r = (ReturnCode)SIGNDOC_Document_findText (&ex, p, aEncoding, aFirstPage, aLastPage, aText.c_str (), aFlags, tempOutput);
18212         assignArray (aOutput, tempOutput);
18213       }
18214     catch (...)
18215       {
18216         if (tempOutput != NULL)
18217           SIGNDOC_FindTextPositionArray_delete (tempOutput);
18218         throw;
18219       }
18220     if (tempOutput != NULL)
18221       SIGNDOC_FindTextPositionArray_delete (tempOutput);
18222     if (ex != NULL) SignDoc_throw (ex);
18223     return r;
18224   }
18225 
18252   ReturnCode addAttachmentBlob (Encoding aEncoding, const std::string &aName,
18253                                 const std::string &aDescription,
18254                                 const std::string &aType,
18255                                 const std::string &aModificationTime,
18256                                 const void *aPtr, size_t aSize, int aFlags)
18257   {
18258     SIGNDOC_Exception *ex = NULL;
18259     ReturnCode r;
18260     r = (ReturnCode)SIGNDOC_Document_addAttachmentBlob (&ex, p, aEncoding, aName.c_str (), aDescription.c_str (), aType.c_str (), aModificationTime.c_str (), aPtr, aSize, aFlags);
18261     if (ex != NULL) SignDoc_throw (ex);
18262     return r;
18263   }
18264 
18286   ReturnCode addAttachmentFile (Encoding aEncoding1, const std::string &aName,
18287                                 const std::string &aDescription,
18288                                 const std::string &aType, Encoding aEncoding2,
18289                                 const std::string &aPath, int aFlags)
18290   {
18291     SIGNDOC_Exception *ex = NULL;
18292     ReturnCode r;
18293     r = (ReturnCode)SIGNDOC_Document_addAttachmentFile (&ex, p, aEncoding1, aName.c_str (), aDescription.c_str (), aType.c_str (), aEncoding2, aPath.c_str (), aFlags);
18294     if (ex != NULL) SignDoc_throw (ex);
18295     return r;
18296   }
18297 
18310   ReturnCode removeAttachment (Encoding aEncoding, const std::string &aName)
18311   {
18312     SIGNDOC_Exception *ex = NULL;
18313     ReturnCode r;
18314     r = (ReturnCode)SIGNDOC_Document_removeAttachment (&ex, p, aEncoding, aName.c_str ());
18315     if (ex != NULL) SignDoc_throw (ex);
18316     return r;
18317   }
18318 
18332   ReturnCode changeAttachmentDescription (Encoding aEncoding,
18333                                           const std::string &aName,
18334                                           const std::string &aDescription)
18335   {
18336     SIGNDOC_Exception *ex = NULL;
18337     ReturnCode r;
18338     r = (ReturnCode)SIGNDOC_Document_changeAttachmentDescription (&ex, p, aEncoding, aName.c_str (), aDescription.c_str ());
18339     if (ex != NULL) SignDoc_throw (ex);
18340     return r;
18341   }
18342 
18358   ReturnCode getAttachments (Encoding aEncoding,
18359                              std::vector<std::string> &aOutput)
18360   {
18361     SIGNDOC_Exception *ex = NULL;
18362     SIGNDOC_StringArray *tempOutput = NULL;
18363     ReturnCode r;
18364     try
18365       {
18366         tempOutput = SIGNDOC_StringArray_new (&ex);
18367         if (ex != NULL) SignDoc_throw (ex);
18368         r = (ReturnCode)SIGNDOC_Document_getAttachments (&ex, p, aEncoding, tempOutput);
18369         assignArray (aOutput, tempOutput);
18370       }
18371     catch (...)
18372       {
18373         if (tempOutput != NULL)
18374           SIGNDOC_StringArray_delete (tempOutput);
18375         throw;
18376       }
18377     if (tempOutput != NULL)
18378       SIGNDOC_StringArray_delete (tempOutput);
18379     if (ex != NULL) SignDoc_throw (ex);
18380     return r;
18381   }
18382 
18397   ReturnCode getAttachment (Encoding aEncoding, const std::string &aName,
18398                             SignDocAttachment &aOutput)
18399   {
18400     SIGNDOC_Exception *ex = NULL;
18401     ReturnCode r;
18402     r = (ReturnCode)SIGNDOC_Document_getAttachment (&ex, p, aEncoding, aName.c_str (), aOutput.getImpl ());
18403     if (ex != NULL) SignDoc_throw (ex);
18404     return r;
18405   }
18406 
18420   ReturnCode checkAttachment (Encoding aEncoding, const std::string &aName,
18421                               CheckAttachmentResult &aOutput)
18422   {
18423     SIGNDOC_Exception *ex = NULL;
18424     int tempOutput = 0;
18425     ReturnCode r;
18426     try
18427       {
18428         r = (ReturnCode)SIGNDOC_Document_checkAttachment (&ex, p, aEncoding, aName.c_str (), &tempOutput);
18429         aOutput = (CheckAttachmentResult )tempOutput;
18430       }
18431     catch (...)
18432       {
18433         throw;
18434       }
18435     if (ex != NULL) SignDoc_throw (ex);
18436     return r;
18437   }
18438 
18452   ReturnCode getAttachmentBlob (Encoding aEncoding, const std::string &aName,
18453                                 std::vector<unsigned char> &aOutput)
18454   {
18455     SIGNDOC_Exception *ex = NULL;
18456     SIGNDOC_ByteArray *tempOutput = NULL;
18457     ReturnCode r;
18458     try
18459       {
18460         tempOutput = SIGNDOC_ByteArray_new (&ex);
18461         if (ex != NULL) SignDoc_throw (ex);
18462         r = (ReturnCode)SIGNDOC_Document_getAttachmentBlob (&ex, p, aEncoding, aName.c_str (), tempOutput);
18463         assignArray (aOutput, tempOutput);
18464       }
18465     catch (...)
18466       {
18467         if (tempOutput != NULL)
18468           SIGNDOC_ByteArray_delete (tempOutput);
18469         throw;
18470       }
18471     if (tempOutput != NULL)
18472       SIGNDOC_ByteArray_delete (tempOutput);
18473     if (ex != NULL) SignDoc_throw (ex);
18474     return r;
18475   }
18476 
18493   ReturnCode getAttachmentStream (Encoding aEncoding, const std::string &aName,
18494                                   SIGNDOC_PTR<InputStream> &aOutput)
18495   {
18496     SIGNDOC_Exception *ex = NULL;
18497     SIGNDOC_InputStream *tempOutput = NULL;
18498     aOutput.reset ((InputStream*)NULL);
18499     ReturnCode r;
18500     try
18501       {
18502         r = (ReturnCode)SIGNDOC_Document_getAttachmentStream (&ex, p, aEncoding, aName.c_str (), &tempOutput);
18503         if (tempOutput != NULL)
18504           {
18505             aOutput.reset (new LibraryInputStream (tempOutput));
18506             tempOutput = NULL;
18507           }
18508       }
18509     catch (...)
18510       {
18511         if (tempOutput != NULL)
18512           SIGNDOC_InputStream_delete (tempOutput);
18513         throw;
18514       }
18515     if (tempOutput != NULL)
18516       SIGNDOC_InputStream_delete (tempOutput);
18517     if (ex != NULL) SignDoc_throw (ex);
18518     return r;
18519   }
18520 
18536   ReturnCode addPage (int aTargetPage, double aWidth, double aHeight)
18537   {
18538     SIGNDOC_Exception *ex = NULL;
18539     ReturnCode r;
18540     r = (ReturnCode)SIGNDOC_Document_addPage (&ex, p, aTargetPage, aWidth, aHeight);
18541     if (ex != NULL) SignDoc_throw (ex);
18542     return r;
18543   }
18544 
18577   ReturnCode importPages (int aTargetPage, SignDocDocument *aSource,
18578                           int aSourcePage, int aPageCount, int aFlags)
18579   {
18580     SIGNDOC_Exception *ex = NULL;
18581     ReturnCode r;
18582     r = (ReturnCode)SIGNDOC_Document_importPages (&ex, p, aTargetPage, aSource == NULL ? NULL : aSource->getImpl (), aSourcePage, aPageCount, aFlags);
18583     if (ex != NULL) SignDoc_throw (ex);
18584     return r;
18585   }
18586 
18632   ReturnCode importPageFromImageBlob (int aTargetPage,
18633                                       const unsigned char *aPtr, size_t aSize,
18634                                       double aZoom, double aWidth,
18635                                       double aHeight, int aFlags)
18636   {
18637     SIGNDOC_Exception *ex = NULL;
18638     ReturnCode r;
18639     r = (ReturnCode)SIGNDOC_Document_importPageFromImageBlob (&ex, p, aTargetPage, aPtr, aSize, aZoom, aWidth, aHeight, aFlags);
18640     if (ex != NULL) SignDoc_throw (ex);
18641     return r;
18642   }
18643 
18695   ReturnCode importPageFromImageBlob2 (int aTargetPage,
18696                                        const unsigned char *aPtr, size_t aSize,
18697                                        double aZoom, double aWidth,
18698                                        double aHeight, int aFlags,
18699                                        Encoding aEncoding,
18700                                        const std::string &aDescription,
18701                                        const std::string &aLang)
18702   {
18703     SIGNDOC_Exception *ex = NULL;
18704     ReturnCode r;
18705     r = (ReturnCode)SIGNDOC_Document_importPageFromImageBlob2 (&ex, p, aTargetPage, aPtr, aSize, aZoom, aWidth, aHeight, aFlags, aEncoding, aDescription.c_str (), aLang.c_str ());
18706     if (ex != NULL) SignDoc_throw (ex);
18707     return r;
18708   }
18709 
18753   ReturnCode importPageFromImageFile (int aTargetPage, Encoding aEncoding,
18754                                       const std::string &aPath, double aZoom,
18755                                       double aWidth, double aHeight,
18756                                       int aFlags)
18757   {
18758     SIGNDOC_Exception *ex = NULL;
18759     ReturnCode r;
18760     r = (ReturnCode)SIGNDOC_Document_importPageFromImageFile (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aWidth, aHeight, aFlags);
18761     if (ex != NULL) SignDoc_throw (ex);
18762     return r;
18763   }
18764 
18814   ReturnCode importPageFromImageFile2 (int aTargetPage, Encoding aEncoding,
18815                                        const std::string &aPath, double aZoom,
18816                                        double aWidth, double aHeight,
18817                                        int aFlags, Encoding aEncoding2,
18818                                        const std::string &aDescription,
18819                                        const std::string &aLang)
18820   {
18821     SIGNDOC_Exception *ex = NULL;
18822     ReturnCode r;
18823     r = (ReturnCode)SIGNDOC_Document_importPageFromImageFile2 (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aWidth, aHeight, aFlags, aEncoding2, aDescription.c_str (), aLang.c_str ());
18824     if (ex != NULL) SignDoc_throw (ex);
18825     return r;
18826   }
18827 
18874   ReturnCode addImageFromBlob (int aTargetPage, const unsigned char *aPtr,
18875                                size_t aSize, double aZoom, double aX,
18876                                double aY, double aWidth, double aHeight,
18877                                int aFlags)
18878   {
18879     SIGNDOC_Exception *ex = NULL;
18880     ReturnCode r;
18881     r = (ReturnCode)SIGNDOC_Document_addImageFromBlob (&ex, p, aTargetPage, aPtr, aSize, aZoom, aX, aY, aWidth, aHeight, aFlags);
18882     if (ex != NULL) SignDoc_throw (ex);
18883     return r;
18884   }
18885 
18939   ReturnCode addImageFromBlob2 (int aTargetPage, const unsigned char *aPtr,
18940                                 size_t aSize, double aZoom, double aX,
18941                                 double aY, double aWidth, double aHeight,
18942                                 int aFlags, Encoding aEncoding,
18943                                 const std::string &aDescription,
18944                                 const std::string &aLang)
18945   {
18946     SIGNDOC_Exception *ex = NULL;
18947     ReturnCode r;
18948     r = (ReturnCode)SIGNDOC_Document_addImageFromBlob2 (&ex, p, aTargetPage, aPtr, aSize, aZoom, aX, aY, aWidth, aHeight, aFlags, aEncoding, aDescription.c_str (), aLang.c_str ());
18949     if (ex != NULL) SignDoc_throw (ex);
18950     return r;
18951   }
18952 
18997   ReturnCode addImageFromFile (int aTargetPage, Encoding aEncoding,
18998                                const std::string &aPath, double aZoom,
18999                                double aX, double aY, double aWidth,
19000                                double aHeight, int aFlags)
19001   {
19002     SIGNDOC_Exception *ex = NULL;
19003     ReturnCode r;
19004     r = (ReturnCode)SIGNDOC_Document_addImageFromFile (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aX, aY, aWidth, aHeight, aFlags);
19005     if (ex != NULL) SignDoc_throw (ex);
19006     return r;
19007   }
19008 
19060   ReturnCode addImageFromFile2 (int aTargetPage, Encoding aEncoding,
19061                                 const std::string &aPath, double aZoom,
19062                                 double aX, double aY, double aWidth,
19063                                 double aHeight, int aFlags,
19064                                 Encoding aEncoding2,
19065                                 const std::string &aDescription,
19066                                 const std::string &aLang)
19067   {
19068     SIGNDOC_Exception *ex = NULL;
19069     ReturnCode r;
19070     r = (ReturnCode)SIGNDOC_Document_addImageFromFile2 (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aX, aY, aWidth, aHeight, aFlags, aEncoding2, aDescription.c_str (), aLang.c_str ());
19071     if (ex != NULL) SignDoc_throw (ex);
19072     return r;
19073   }
19074 
19095   ReturnCode removePages (const int *aPagesPtr, int aPagesCount,
19096                           KeepOrRemove aMode)
19097   {
19098     SIGNDOC_Exception *ex = NULL;
19099     ReturnCode r;
19100     r = (ReturnCode)SIGNDOC_Document_removePages (&ex, p, aPagesPtr, aPagesCount, aMode);
19101     if (ex != NULL) SignDoc_throw (ex);
19102     return r;
19103   }
19104 
19119   ReturnCode setCompatibility (int aMajor, int aMinor)
19120   {
19121     SIGNDOC_Exception *ex = NULL;
19122     ReturnCode r;
19123     r = (ReturnCode)SIGNDOC_Document_setCompatibility (&ex, p, aMajor, aMinor);
19124     if (ex != NULL) SignDoc_throw (ex);
19125     return r;
19126   }
19127 
19137   ReturnCode isModified (bool &aModified) const
19138   {
19139     SIGNDOC_Exception *ex = NULL;
19140     SIGNDOC_Boolean tempModified = 0;
19141     ReturnCode r;
19142     try
19143       {
19144         r = (ReturnCode)SIGNDOC_Document_isModified (&ex, p, &tempModified);
19145         aModified = (bool )tempModified;
19146       }
19147     catch (...)
19148       {
19149         throw;
19150       }
19151     if (ex != NULL) SignDoc_throw (ex);
19152     return r;
19153   }
19154 
19163   ReturnCode isTaggedPDF (bool &aTaggedPDF) const
19164   {
19165     SIGNDOC_Exception *ex = NULL;
19166     SIGNDOC_Boolean tempTaggedPDF = 0;
19167     ReturnCode r;
19168     try
19169       {
19170         r = (ReturnCode)SIGNDOC_Document_isTaggedPDF (&ex, p, &tempTaggedPDF);
19171         aTaggedPDF = (bool )tempTaggedPDF;
19172       }
19173     catch (...)
19174       {
19175         throw;
19176       }
19177     if (ex != NULL) SignDoc_throw (ex);
19178     return r;
19179   }
19180 
19192   ReturnCode setFlags (unsigned aFlags)
19193   {
19194     SIGNDOC_Exception *ex = NULL;
19195     ReturnCode r;
19196     r = (ReturnCode)SIGNDOC_Document_setFlags (&ex, p, aFlags);
19197     if (ex != NULL) SignDoc_throw (ex);
19198     return r;
19199   }
19200 
19208   unsigned getFlags () const
19209   {
19210     SIGNDOC_Exception *ex = NULL;
19211     unsigned r;
19212     r = SIGNDOC_Document_getFlags (&ex, p);
19213     if (ex != NULL) SignDoc_throw (ex);
19214     return r;
19215   }
19216 
19234   ReturnCode setCompressionLevel (int aLevel)
19235   {
19236     SIGNDOC_Exception *ex = NULL;
19237     ReturnCode r;
19238     r = (ReturnCode)SIGNDOC_Document_setCompressionLevel (&ex, p, aLevel);
19239     if (ex != NULL) SignDoc_throw (ex);
19240     return r;
19241   }
19242 
19262   int getDocMDP () const
19263   {
19264     SIGNDOC_Exception *ex = NULL;
19265     int r;
19266     r = SIGNDOC_Document_getDocMDP (&ex, p);
19267     if (ex != NULL) SignDoc_throw (ex);
19268     return r;
19269   }
19270 
19290   int getLockMDP () const
19291   {
19292     SIGNDOC_Exception *ex = NULL;
19293     int r;
19294     r = SIGNDOC_Document_getLockMDP (&ex, p);
19295     if (ex != NULL) SignDoc_throw (ex);
19296     return r;
19297   }
19298 
19309   ReturnCode removeDocMDP ()
19310   {
19311     SIGNDOC_Exception *ex = NULL;
19312     ReturnCode r;
19313     r = (ReturnCode)SIGNDOC_Document_removeDocMDP (&ex, p);
19314     if (ex != NULL) SignDoc_throw (ex);
19315     return r;
19316   }
19317 
19340   ReturnCode removePermissions (unsigned aFlags)
19341   {
19342     SIGNDOC_Exception *ex = NULL;
19343     ReturnCode r;
19344     r = (ReturnCode)SIGNDOC_Document_removePermissions (&ex, p, aFlags);
19345     if (ex != NULL) SignDoc_throw (ex);
19346     return r;
19347   }
19348 
19364   ReturnCode removePDFA (unsigned aFlags)
19365   {
19366     SIGNDOC_Exception *ex = NULL;
19367     ReturnCode r;
19368     r = (ReturnCode)SIGNDOC_Document_removePDFA (&ex, p, aFlags);
19369     if (ex != NULL) SignDoc_throw (ex);
19370     return r;
19371   }
19372 
19388   ReturnCode removePDFUA (unsigned aFlags)
19389   {
19390     SIGNDOC_Exception *ex = NULL;
19391     ReturnCode r;
19392     r = (ReturnCode)SIGNDOC_Document_removePDFUA (&ex, p, aFlags);
19393     if (ex != NULL) SignDoc_throw (ex);
19394     return r;
19395   }
19396 
19408   ReturnCode removeLogicalStructure (unsigned aFlags)
19409   {
19410     SIGNDOC_Exception *ex = NULL;
19411     ReturnCode r;
19412     r = (ReturnCode)SIGNDOC_Document_removeLogicalStructure (&ex, p, aFlags);
19413     if (ex != NULL) SignDoc_throw (ex);
19414     return r;
19415   }
19416 
19436   ReturnCode removeXFA (unsigned aFlags)
19437   {
19438     SIGNDOC_Exception *ex = NULL;
19439     ReturnCode r;
19440     r = (ReturnCode)SIGNDOC_Document_removeXFA (&ex, p, aFlags);
19441     if (ex != NULL) SignDoc_throw (ex);
19442     return r;
19443   }
19444 
19462   std::string getDocumentLanguage (Encoding aEncoding) const
19463   {
19464     SIGNDOC_Exception *ex = NULL;
19465     std::string r;
19466     char *s = SIGNDOC_Document_getDocumentLanguage (&ex, p, aEncoding);
19467     if (ex != NULL) SignDoc_throw (ex);
19468     try
19469       {
19470         r = s;
19471       }
19472     catch (...)
19473       {
19474         SIGNDOC_free (s);
19475         throw;
19476       }
19477     SIGNDOC_free (s);
19478     return r;
19479   }
19480 
19497   ReturnCode setDocumentLanguage (Encoding aEncoding, const std::string &aLang)
19498   {
19499     SIGNDOC_Exception *ex = NULL;
19500     ReturnCode r;
19501     r = (ReturnCode)SIGNDOC_Document_setDocumentLanguage (&ex, p, aEncoding, aLang.c_str ());
19502     if (ex != NULL) SignDoc_throw (ex);
19503     return r;
19504   }
19505 
19522   ReturnCode setDefaultDocumentLanguage (Encoding aEncoding,
19523                                          const std::string &aLang)
19524   {
19525     SIGNDOC_Exception *ex = NULL;
19526     ReturnCode r;
19527     r = (ReturnCode)SIGNDOC_Document_setDefaultDocumentLanguage (&ex, p, aEncoding, aLang.c_str ());
19528     if (ex != NULL) SignDoc_throw (ex);
19529     return r;
19530   }
19531 
19547   ReturnCode setShootInFoot (unsigned aFlags)
19548   {
19549     SIGNDOC_Exception *ex = NULL;
19550     ReturnCode r;
19551     r = (ReturnCode)SIGNDOC_Document_setShootInFoot (&ex, p, aFlags);
19552     if (ex != NULL) SignDoc_throw (ex);
19553     return r;
19554   }
19555 
19563   unsigned getShootInFoot () const
19564   {
19565     SIGNDOC_Exception *ex = NULL;
19566     unsigned r;
19567     r = SIGNDOC_Document_getShootInFoot (&ex, p);
19568     if (ex != NULL) SignDoc_throw (ex);
19569     return r;
19570   }
19571 
19585   const char *getErrorMessage (Encoding aEncoding) const
19586   {
19587     SIGNDOC_Exception *ex = NULL;
19588     const char *r;
19589     r = SIGNDOC_Document_getErrorMessage (&ex, p, aEncoding);
19590     if (ex != NULL) SignDoc_throw (ex);
19591     return r;
19592   }
19593 
19605   const wchar_t *getErrorMessageW () const
19606   {
19607     SIGNDOC_Exception *ex = NULL;
19608     const wchar_t *r;
19609     r = SIGNDOC_Document_getErrorMessageW (&ex, p);
19610     if (ex != NULL) SignDoc_throw (ex);
19611     return r;
19612   }
19613 
19635   SPPDF_Document *getSPPDFDocument (bool aDestroy)
19636   {
19637     SIGNDOC_Exception *ex = NULL;
19638     SPPDF_Document *r;
19639     r = SIGNDOC_Document_getSPPDFDocument (&ex, p, aDestroy);
19640     if (ex != NULL) SignDoc_throw (ex);
19641     return r;
19642   }
19643 
19657   ReturnCode getPageLabel (int aPage, std::string &aOutput)
19658   {
19659     SIGNDOC_Exception *ex = NULL;
19660     char *tempOutput = NULL;
19661     ReturnCode r;
19662     try
19663       {
19664         r = (ReturnCode)SIGNDOC_Document_getPageLabel (&ex, p, aPage, &tempOutput);
19665         if (tempOutput != NULL)
19666           aOutput = tempOutput;
19667       }
19668     catch (...)
19669       {
19670         SIGNDOC_free (tempOutput);
19671         throw;
19672       }
19673     SIGNDOC_free (tempOutput);
19674     if (ex != NULL) SignDoc_throw (ex);
19675     return r;
19676   }
19677 
19705   ReturnCode flattenAnnotations (int aFirstPage, int aLastPage,
19706                                  unsigned aFlags)
19707   {
19708     SIGNDOC_Exception *ex = NULL;
19709     ReturnCode r;
19710     r = (ReturnCode)SIGNDOC_Document_flattenAnnotations (&ex, p, aFirstPage, aLastPage, aFlags);
19711     if (ex != NULL) SignDoc_throw (ex);
19712     return r;
19713   }
19714 
19729   static void splitEscapeSequences (const std::string &aInput,
19730                                     std::vector<std::string> &aOutput)
19731   {
19732     SIGNDOC_Exception *ex = NULL;
19733     SIGNDOC_StringArray *tempOutput = NULL;
19734     try
19735       {
19736         tempOutput = SIGNDOC_StringArray_new (&ex);
19737         if (ex != NULL) SignDoc_throw (ex);
19738         SIGNDOC_Document_splitEscapeSequences (&ex, aInput.c_str (), tempOutput);
19739         assignArray (aOutput, tempOutput);
19740       }
19741     catch (...)
19742       {
19743         if (tempOutput != NULL)
19744           SIGNDOC_StringArray_delete (tempOutput);
19745         throw;
19746       }
19747     if (tempOutput != NULL)
19748       SIGNDOC_StringArray_delete (tempOutput);
19749     if (ex != NULL) SignDoc_throw (ex);
19750   }
19751 
19765   static std::string withoutEscapeSequences (const std::string &aInput)
19766   {
19767     SIGNDOC_Exception *ex = NULL;
19768     std::string r;
19769     char *s = SIGNDOC_Document_withoutEscapeSequences (&ex, aInput.c_str ());
19770     if (ex != NULL) SignDoc_throw (ex);
19771     try
19772       {
19773         r = s;
19774       }
19775     catch (...)
19776       {
19777         SIGNDOC_free (s);
19778         throw;
19779       }
19780     SIGNDOC_free (s);
19781     return r;
19782   }
19783 
19803   static std::string withEscapeSequence (const std::string &aText,
19804                                          const std::string &aLang)
19805   {
19806     SIGNDOC_Exception *ex = NULL;
19807     std::string r;
19808     char *s = SIGNDOC_Document_withEscapeSequence (&ex, aText.c_str (), aLang.c_str ());
19809     if (ex != NULL) SignDoc_throw (ex);
19810     try
19811       {
19812         r = s;
19813       }
19814     catch (...)
19815       {
19816         SIGNDOC_free (s);
19817         throw;
19818       }
19819     SIGNDOC_free (s);
19820     return r;
19821   }
19822 
19823 private:
19827   SignDocDocument (const SignDocDocument &);
19828 
19832   SignDocDocument &operator= (const SignDocDocument &);
19833 public:
19838   SignDocDocument (SIGNDOC_Document *aP) : p (aP) { }
19839 
19844   SIGNDOC_Document *getImpl () { return p; }
19845 
19850   const SIGNDOC_Document *getImpl () const { return p; }
19851 
19856   void setImpl (SIGNDOC_Document *aP) { SIGNDOC_Document_delete (p); p  = aP; }
19857 
19858 private:
19859   SIGNDOC_Document *p;
19860 };
19861 
19865 class SignDocDocumentHandler 
19866 {
19867 public:
19873   SignDocDocumentHandler ()
19874     : p (NULL)
19875   {
19876   }
19877 
19883   virtual ~SignDocDocumentHandler ()
19884   {
19885     SIGNDOC_DocumentHandler_delete (p);
19886   }
19887 
19888 private:
19892   SignDocDocumentHandler (const SignDocDocumentHandler &);
19893 
19894 public:
19899   SignDocDocumentHandler (SIGNDOC_DocumentHandler *aP) : p (aP) { }
19900 
19905   SIGNDOC_DocumentHandler *getImpl () { return p; }
19906 
19911   const SIGNDOC_DocumentHandler *getImpl () const { return p; }
19912 
19917   void destroyWithoutImpl () { p = NULL; delete this; }
19918 
19923   void setImpl (SIGNDOC_DocumentHandler *aP) { SIGNDOC_DocumentHandler_delete (p); p  = aP; }
19924 
19925 protected:
19926   SIGNDOC_DocumentHandler *p;
19927 };
19928 
19948 class SignDocDocumentLoader 
19949 {
19950 public:
19954   enum RemainingDays
19955   {
19959     rd_product,
19960 
19964     rd_signing
19965   };
19966 
19970   enum Flags
19971   {
19982     f_map_into_memory = 0x01
19983   };
19984 
19985 public:
19989   SignDocDocumentLoader ()
19990     : p (NULL)
19991   {
19992     SIGNDOC_Exception *ex = NULL;
19993     p = SIGNDOC_DocumentLoader_new (&ex);
19994     if (ex != NULL) SignDoc_throw (ex);
19995   }
19996 
20000   ~SignDocDocumentLoader ()
20001   {
20002     SIGNDOC_DocumentLoader_delete (p);
20003   }
20004 
20021   static bool initLicenseManager (int aWho1, int aWho2)
20022   {
20023     SIGNDOC_Exception *ex = NULL;
20024     bool r;
20025     r = (bool)SIGNDOC_DocumentLoader_initLicenseManager (&ex, aWho1, aWho2);
20026     if (ex != NULL) SignDoc_throw (ex);
20027     return r;
20028   }
20029 
20049   static bool setLicenseKey (const void *aKeyPtr, size_t aKeySize,
20050                              const char *aProduct, const char *aVersion,
20051                              const void *aTokenPtr, size_t aTokenSize)
20052   {
20053     SIGNDOC_Exception *ex = NULL;
20054     bool r;
20055     r = (bool)SIGNDOC_DocumentLoader_setLicenseKey (&ex, aKeyPtr, aKeySize, aProduct, aVersion, aTokenPtr, aTokenSize);
20056     if (ex != NULL) SignDoc_throw (ex);
20057     return r;
20058   }
20059 
20072   static bool generateLicenseToken (const char *aProduct,
20073                                     std::vector<unsigned char> &aOutput)
20074   {
20075     SIGNDOC_Exception *ex = NULL;
20076     SIGNDOC_ByteArray *tempOutput = NULL;
20077     bool r;
20078     try
20079       {
20080         tempOutput = SIGNDOC_ByteArray_new (&ex);
20081         if (ex != NULL) SignDoc_throw (ex);
20082         r = (bool)SIGNDOC_DocumentLoader_generateLicenseToken (&ex, aProduct, tempOutput);
20083         assignArray (aOutput, tempOutput);
20084       }
20085     catch (...)
20086       {
20087         if (tempOutput != NULL)
20088           SIGNDOC_ByteArray_delete (tempOutput);
20089         throw;
20090       }
20091     if (tempOutput != NULL)
20092       SIGNDOC_ByteArray_delete (tempOutput);
20093     if (ex != NULL) SignDoc_throw (ex);
20094     return r;
20095   }
20096 
20109   static int getRemainingDays (RemainingDays aWhat)
20110   {
20111     SIGNDOC_Exception *ex = NULL;
20112     int r;
20113     r = SIGNDOC_DocumentLoader_getRemainingDays (&ex, aWhat);
20114     if (ex != NULL) SignDoc_throw (ex);
20115     return r;
20116   }
20117 
20126   static bool getInstallationCode (std::string &aCode)
20127   {
20128     SIGNDOC_Exception *ex = NULL;
20129     char *tempCode = NULL;
20130     bool r;
20131     try
20132       {
20133         r = (bool)SIGNDOC_DocumentLoader_getInstallationCode (&ex, &tempCode);
20134         if (tempCode != NULL)
20135           aCode = tempCode;
20136       }
20137     catch (...)
20138       {
20139         SIGNDOC_free (tempCode);
20140         throw;
20141       }
20142     SIGNDOC_free (tempCode);
20143     if (ex != NULL) SignDoc_throw (ex);
20144     return r;
20145   }
20146 
20158   static bool getVersionNumber (std::string &aVersion)
20159   {
20160     SIGNDOC_Exception *ex = NULL;
20161     char *tempVersion = NULL;
20162     bool r;
20163     try
20164       {
20165         r = (bool)SIGNDOC_DocumentLoader_getVersionNumber (&ex, &tempVersion);
20166         if (tempVersion != NULL)
20167           aVersion = tempVersion;
20168       }
20169     catch (...)
20170       {
20171         SIGNDOC_free (tempVersion);
20172         throw;
20173       }
20174     SIGNDOC_free (tempVersion);
20175     if (ex != NULL) SignDoc_throw (ex);
20176     return r;
20177   }
20178 
20192   static bool getComponentVersionNumber (const char *aComponent,
20193                                          std::string &aVersion)
20194   {
20195     SIGNDOC_Exception *ex = NULL;
20196     char *tempVersion = NULL;
20197     bool r;
20198     try
20199       {
20200         r = (bool)SIGNDOC_DocumentLoader_getComponentVersionNumber (&ex, aComponent, &tempVersion);
20201         if (tempVersion != NULL)
20202           aVersion = tempVersion;
20203       }
20204     catch (...)
20205       {
20206         SIGNDOC_free (tempVersion);
20207         throw;
20208       }
20209     SIGNDOC_free (tempVersion);
20210     if (ex != NULL) SignDoc_throw (ex);
20211     return r;
20212   }
20213 
20224   static int getLicenseTextCount ()
20225   {
20226     SIGNDOC_Exception *ex = NULL;
20227     int r;
20228     r = SIGNDOC_DocumentLoader_getLicenseTextCount (&ex);
20229     if (ex != NULL) SignDoc_throw (ex);
20230     return r;
20231   }
20232 
20247   static const char *getLicenseText (int aIndex)
20248   {
20249     SIGNDOC_Exception *ex = NULL;
20250     const char *r;
20251     r = SIGNDOC_DocumentLoader_getLicenseText (&ex, aIndex);
20252     if (ex != NULL) SignDoc_throw (ex);
20253     return r;
20254   }
20255 
20272   SignDocDocument *loadFromMemory (const unsigned char *aData, size_t aSize,
20273                                    bool aCopy)
20274   {
20275     SIGNDOC_Exception *ex = NULL;
20276     SIGNDOC_Document *r;
20277     r = SIGNDOC_DocumentLoader_loadFromMemory (&ex, p, aData, aSize, aCopy);
20278     if (ex != NULL) SignDoc_throw (ex);
20279     if (r == NULL)
20280       return NULL;
20281     try
20282       {
20283         return new SignDocDocument (r);
20284       }
20285     catch (...)
20286       {
20287         SIGNDOC_Document_delete (r);
20288         throw;
20289       }
20290   }
20291 
20318   SignDocDocument *loadFromFile (Encoding aEncoding, const char *aPath,
20319                                  bool aWritable)
20320   {
20321     SIGNDOC_Exception *ex = NULL;
20322     SIGNDOC_Document *r;
20323     r = SIGNDOC_DocumentLoader_loadFromFile (&ex, p, aEncoding, aPath, aWritable);
20324     if (ex != NULL) SignDoc_throw (ex);
20325     if (r == NULL)
20326       return NULL;
20327     try
20328       {
20329         return new SignDocDocument (r);
20330       }
20331     catch (...)
20332       {
20333         SIGNDOC_Document_delete (r);
20334         throw;
20335       }
20336   }
20337 
20360   SignDocDocument *loadFromFile (const wchar_t *aPath, bool aWritable)
20361   {
20362     SIGNDOC_Exception *ex = NULL;
20363     SIGNDOC_Document *r;
20364     r = SIGNDOC_DocumentLoader_loadFromFileW (&ex, p, aPath, aWritable);
20365     if (ex != NULL) SignDoc_throw (ex);
20366     if (r == NULL)
20367       return NULL;
20368     try
20369       {
20370         return new SignDocDocument (r);
20371       }
20372     catch (...)
20373       {
20374         SIGNDOC_Document_delete (r);
20375         throw;
20376       }
20377   }
20378 
20394   SignDocDocument *createPDF (int aMajor, int aMinor)
20395   {
20396     SIGNDOC_Exception *ex = NULL;
20397     SIGNDOC_Document *r;
20398     r = SIGNDOC_DocumentLoader_createPDF (&ex, p, aMajor, aMinor);
20399     if (ex != NULL) SignDoc_throw (ex);
20400     if (r == NULL)
20401       return NULL;
20402     try
20403       {
20404         return new SignDocDocument (r);
20405       }
20406     catch (...)
20407       {
20408         SIGNDOC_Document_delete (r);
20409         throw;
20410       }
20411   }
20412 
20442   SignDocDocument *createPDFA (int aMajor, int aMinor,
20443                                const char *aConformance,
20444                                const unsigned char *aICCPtr, size_t aICCSize)
20445   {
20446     SIGNDOC_Exception *ex = NULL;
20447     SIGNDOC_Document *r;
20448     r = SIGNDOC_DocumentLoader_createPDFA (&ex, p, aMajor, aMinor, aConformance, aICCPtr, aICCSize);
20449     if (ex != NULL) SignDoc_throw (ex);
20450     if (r == NULL)
20451       return NULL;
20452     try
20453       {
20454         return new SignDocDocument (r);
20455       }
20456     catch (...)
20457       {
20458         SIGNDOC_Document_delete (r);
20459         throw;
20460       }
20461   }
20462 
20472   SignDocDocument::DocumentType ping (InputStream &aStream)
20473   {
20474     SIGNDOC_Exception *ex = NULL;
20475     SignDocDocument::DocumentType r;
20476     r = (SignDocDocument::DocumentType)SIGNDOC_DocumentLoader_ping (&ex, p, aStream.getImpl ());
20477     if (ex != NULL) SignDoc_throw (ex);
20478     return r;
20479   }
20480 
20506   bool loadFontConfigFile (Encoding aEncoding, const char *aPath)
20507   {
20508     SIGNDOC_Exception *ex = NULL;
20509     bool r;
20510     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigFile (&ex, p, aEncoding, aPath);
20511     if (ex != NULL) SignDoc_throw (ex);
20512     return r;
20513   }
20514 
20536   bool loadFontConfigFile (const wchar_t *aPath)
20537   {
20538     SIGNDOC_Exception *ex = NULL;
20539     bool r;
20540     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigFileW (&ex, p, aPath);
20541     if (ex != NULL) SignDoc_throw (ex);
20542     return r;
20543   }
20544 
20569   bool loadFontConfigEnvironment (const char *aName)
20570   {
20571     SIGNDOC_Exception *ex = NULL;
20572     bool r;
20573     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigEnvironment (&ex, p, aName);
20574     if (ex != NULL) SignDoc_throw (ex);
20575     return r;
20576   }
20577 
20609   bool loadFontConfigStream (InputStream &aStream, Encoding aEncoding,
20610                              const char *aDirectory)
20611   {
20612     SIGNDOC_Exception *ex = NULL;
20613     bool r;
20614     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigStream (&ex, p, aStream.getImpl (), aEncoding, aDirectory);
20615     if (ex != NULL) SignDoc_throw (ex);
20616     return r;
20617   }
20618 
20646   bool loadFontConfigStream (InputStream &aStream, const wchar_t *aDirectory)
20647   {
20648     SIGNDOC_Exception *ex = NULL;
20649     bool r;
20650     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigStreamW (&ex, p, aStream.getImpl (), aDirectory);
20651     if (ex != NULL) SignDoc_throw (ex);
20652     return r;
20653   }
20654 
20680   bool loadPdfFontConfigFile (Encoding aEncoding, const char *aPath)
20681   {
20682     SIGNDOC_Exception *ex = NULL;
20683     bool r;
20684     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigFile (&ex, p, aEncoding, aPath);
20685     if (ex != NULL) SignDoc_throw (ex);
20686     return r;
20687   }
20688 
20710   bool loadPdfFontConfigFile (const wchar_t *aPath)
20711   {
20712     SIGNDOC_Exception *ex = NULL;
20713     bool r;
20714     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigFileW (&ex, p, aPath);
20715     if (ex != NULL) SignDoc_throw (ex);
20716     return r;
20717   }
20718 
20746   bool loadPdfFontConfigEnvironment (const char *aName)
20747   {
20748     SIGNDOC_Exception *ex = NULL;
20749     bool r;
20750     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigEnvironment (&ex, p, aName);
20751     if (ex != NULL) SignDoc_throw (ex);
20752     return r;
20753   }
20754 
20786   bool loadPdfFontConfigStream (InputStream &aStream, Encoding aEncoding,
20787                                 const char *aDirectory)
20788   {
20789     SIGNDOC_Exception *ex = NULL;
20790     bool r;
20791     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigStream (&ex, p, aStream.getImpl (), aEncoding, aDirectory);
20792     if (ex != NULL) SignDoc_throw (ex);
20793     return r;
20794   }
20795 
20823   bool loadPdfFontConfigStream (InputStream &aStream,
20824                                 const wchar_t *aDirectory)
20825   {
20826     SIGNDOC_Exception *ex = NULL;
20827     bool r;
20828     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigStreamW (&ex, p, aStream.getImpl (), aDirectory);
20829     if (ex != NULL) SignDoc_throw (ex);
20830     return r;
20831   }
20832 
20849   void getFailedFontFiles (std::vector<std::string> &aOutput)
20850   {
20851     SIGNDOC_Exception *ex = NULL;
20852     SIGNDOC_StringArray *tempOutput = NULL;
20853     try
20854       {
20855         tempOutput = SIGNDOC_StringArray_new (&ex);
20856         if (ex != NULL) SignDoc_throw (ex);
20857         SIGNDOC_DocumentLoader_getFailedFontFiles (&ex, p, tempOutput);
20858         assignArray (aOutput, tempOutput);
20859       }
20860     catch (...)
20861       {
20862         if (tempOutput != NULL)
20863           SIGNDOC_StringArray_delete (tempOutput);
20864         throw;
20865       }
20866     if (tempOutput != NULL)
20867       SIGNDOC_StringArray_delete (tempOutput);
20868     if (ex != NULL) SignDoc_throw (ex);
20869   }
20870 
20895   bool loadTrustedCertificatesFromFile (Encoding aEncoding, const char *aPath)
20896   {
20897     SIGNDOC_Exception *ex = NULL;
20898     bool r;
20899     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromFile (&ex, p, aEncoding, aPath);
20900     if (ex != NULL) SignDoc_throw (ex);
20901     return r;
20902   }
20903 
20923   bool loadTrustedCertificatesFromFile (const wchar_t *aPath)
20924   {
20925     SIGNDOC_Exception *ex = NULL;
20926     bool r;
20927     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromFileW (&ex, p, aPath);
20928     if (ex != NULL) SignDoc_throw (ex);
20929     return r;
20930   }
20931 
20951   bool loadTrustedCertificatesFromStream (InputStream &aStream)
20952   {
20953     SIGNDOC_Exception *ex = NULL;
20954     bool r;
20955     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromStream (&ex, p, aStream.getImpl ());
20956     if (ex != NULL) SignDoc_throw (ex);
20957     return r;
20958   }
20959 
20981   bool initLogging (Encoding aEncoding, const char *aLevel,
20982                     const char *aPathname)
20983   {
20984     SIGNDOC_Exception *ex = NULL;
20985     bool r;
20986     r = (bool)SIGNDOC_DocumentLoader_initLogging (&ex, p, aEncoding, aLevel, aPathname);
20987     if (ex != NULL) SignDoc_throw (ex);
20988     return r;
20989   }
20990 
21005   const char *getErrorMessage (Encoding aEncoding) const
21006   {
21007     SIGNDOC_Exception *ex = NULL;
21008     const char *r;
21009     r = SIGNDOC_DocumentLoader_getErrorMessage (&ex, p, aEncoding);
21010     if (ex != NULL) SignDoc_throw (ex);
21011     return r;
21012   }
21013 
21026   const wchar_t *getErrorMessageW () const
21027   {
21028     SIGNDOC_Exception *ex = NULL;
21029     const wchar_t *r;
21030     r = SIGNDOC_DocumentLoader_getErrorMessageW (&ex, p);
21031     if (ex != NULL) SignDoc_throw (ex);
21032     return r;
21033   }
21034 
21046   bool registerDocumentHandler (SignDocDocumentHandler *aHandler)
21047   {
21048     SIGNDOC_Exception *ex = NULL;
21049     bool r;
21050     r = (bool)SIGNDOC_DocumentLoader_registerDocumentHandler (&ex, p, aHandler == NULL ? NULL : aHandler->getImpl ());
21051     if (ex == NULL) aHandler->destroyWithoutImpl ();
21052     if (ex != NULL) SignDoc_throw (ex);
21053     return r;
21054   }
21055 
21062   void setFlags (unsigned aFlags)
21063   {
21064     SIGNDOC_Exception *ex = NULL;
21065     SIGNDOC_DocumentLoader_setFlags (&ex, p, aFlags);
21066     if (ex != NULL) SignDoc_throw (ex);
21067   }
21068 
21069 private:
21073   SignDocDocumentLoader (const SignDocDocumentLoader &);
21074 
21078   SignDocDocumentLoader &operator= (const SignDocDocumentLoader &);
21079 
21080 private:
21081 public:
21086   SignDocDocumentLoader (SIGNDOC_DocumentLoader *aP) : p (aP) { }
21087 
21092   SIGNDOC_DocumentLoader *getImpl () { return p; }
21093 
21098   const SIGNDOC_DocumentLoader *getImpl () const { return p; }
21099 
21104   void setImpl (SIGNDOC_DocumentLoader *aP) { SIGNDOC_DocumentLoader_delete (p); p  = aP; }
21105 
21106 private:
21107   SIGNDOC_DocumentLoader *p;
21108 };
21109 
21119 class SignDocVerificationResult 
21120 {
21121 public:
21127   enum ReturnCode
21128   {
21129     rc_ok = SignDocDocument::rc_ok, 
21130     rc_invalid_argument = SignDocDocument::rc_invalid_argument, 
21131     rc_not_supported = SignDocDocument::rc_not_supported, 
21132     rc_not_verified = SignDocDocument::rc_not_verified, 
21133     rc_property_not_found = SignDocDocument::rc_property_not_found, 
21134     rc_no_biometric_data = SignDocDocument::rc_no_biometric_data, 
21135     rc_unexpected_error = SignDocDocument::rc_unexpected_error 
21136   };
21137 
21141   enum SignatureState
21142   {
21143     ss_unmodified,            
21144     ss_document_extended,     
21145     ss_document_modified,     
21146     ss_unsupported_signature, 
21147     ss_invalid_certificate,   
21148     ss_empty                  
21149   };
21150 
21154   enum ModificationState
21155   {
21160     ms_unmodified,
21161 
21165     ms_allowed,
21166 
21170     ms_prohibited
21171   };
21172 
21176   enum TimeStampState
21177   {
21178     tss_valid,                
21179     tss_missing,              
21180     tss_invalid               
21181   };
21182 
21187   enum CertificateChainState
21188   {
21189     ccs_ok,                   
21190     ccs_broken_chain,         
21191     ccs_untrusted_root,       
21192     ccs_critical_extension,   
21193     ccs_not_time_valid,       
21194     ccs_path_length,          
21195     ccs_invalid,              
21196     ccs_error                 
21197   };
21198 
21203   enum CertificateRevocationState
21204   {
21205     crs_ok,                     
21206     crs_not_checked,            
21207     crs_offline,                
21208     crs_revoked,                
21209     crs_error                   
21210   };
21211 
21212 public:
21216   SignDocVerificationResult ()
21217     : p (NULL)
21218   {
21219   }
21220 
21224   ~SignDocVerificationResult ()
21225   {
21226     SIGNDOC_VerificationResult_delete (p);
21227   }
21228 
21255   ReturnCode getState (SignatureState &aOutput)
21256   {
21257     SIGNDOC_Exception *ex = NULL;
21258     int tempOutput = 0;
21259     ReturnCode r;
21260     try
21261       {
21262         r = (ReturnCode)SIGNDOC_VerificationResult_getState (&ex, p, &tempOutput);
21263         aOutput = (SignatureState )tempOutput;
21264       }
21265     catch (...)
21266       {
21267         throw;
21268       }
21269     if (ex != NULL) SignDoc_throw (ex);
21270     return r;
21271   }
21272 
21295   ReturnCode getModificationState (ModificationState &aOutput)
21296   {
21297     SIGNDOC_Exception *ex = NULL;
21298     int tempOutput = 0;
21299     ReturnCode r;
21300     try
21301       {
21302         r = (ReturnCode)SIGNDOC_VerificationResult_getModificationState (&ex, p, &tempOutput);
21303         aOutput = (ModificationState )tempOutput;
21304       }
21305     catch (...)
21306       {
21307         throw;
21308       }
21309     if (ex != NULL) SignDoc_throw (ex);
21310     return r;
21311   }
21312 
21328   ReturnCode getMethod (SignDocSignatureParameters::Method &aOutput)
21329   {
21330     SIGNDOC_Exception *ex = NULL;
21331     int tempOutput = 0;
21332     ReturnCode r;
21333     try
21334       {
21335         r = (ReturnCode)SIGNDOC_VerificationResult_getMethod (&ex, p, &tempOutput);
21336         aOutput = (SignDocSignatureParameters::Method )tempOutput;
21337       }
21338     catch (...)
21339       {
21340         throw;
21341       }
21342     if (ex != NULL) SignDoc_throw (ex);
21343     return r;
21344   }
21345 
21363   int getDocMDP ()
21364   {
21365     SIGNDOC_Exception *ex = NULL;
21366     int r;
21367     r = SIGNDOC_VerificationResult_getDocMDP (&ex, p);
21368     if (ex != NULL) SignDoc_throw (ex);
21369     return r;
21370   }
21371 
21389   int getLockMDP ()
21390   {
21391     SIGNDOC_Exception *ex = NULL;
21392     int r;
21393     r = SIGNDOC_VerificationResult_getLockMDP (&ex, p);
21394     if (ex != NULL) SignDoc_throw (ex);
21395     return r;
21396   }
21397 
21423   ReturnCode getDigestAlgorithm (std::string &aOutput)
21424   {
21425     SIGNDOC_Exception *ex = NULL;
21426     char *tempOutput = NULL;
21427     ReturnCode r;
21428     try
21429       {
21430         r = (ReturnCode)SIGNDOC_VerificationResult_getDigestAlgorithm (&ex, p, &tempOutput);
21431         if (tempOutput != NULL)
21432           aOutput = tempOutput;
21433       }
21434     catch (...)
21435       {
21436         SIGNDOC_free (tempOutput);
21437         throw;
21438       }
21439     SIGNDOC_free (tempOutput);
21440     if (ex != NULL) SignDoc_throw (ex);
21441     return r;
21442   }
21443 
21459   ReturnCode getCertificates (std::vector<std::vector<unsigned char> > &aOutput)
21460   {
21461     SIGNDOC_Exception *ex = NULL;
21462     SIGNDOC_ByteArrayArray *tempOutput = NULL;
21463     ReturnCode r;
21464     try
21465       {
21466         tempOutput = SIGNDOC_ByteArrayArray_new (&ex);
21467         if (ex != NULL) SignDoc_throw (ex);
21468         r = (ReturnCode)SIGNDOC_VerificationResult_getCertificates (&ex, p, tempOutput);
21469         assignArray (aOutput, tempOutput);
21470       }
21471     catch (...)
21472       {
21473         if (tempOutput != NULL)
21474           SIGNDOC_ByteArrayArray_delete (tempOutput);
21475         throw;
21476       }
21477     if (tempOutput != NULL)
21478       SIGNDOC_ByteArrayArray_delete (tempOutput);
21479     if (ex != NULL) SignDoc_throw (ex);
21480     return r;
21481   }
21482 
21505   ReturnCode verifyCertificateChain (const SignDocVerificationParameters *aParameters,
21506                                      CertificateChainState &aOutput)
21507   {
21508     SIGNDOC_Exception *ex = NULL;
21509     int tempOutput = 0;
21510     ReturnCode r;
21511     try
21512       {
21513         r = (ReturnCode)SIGNDOC_VerificationResult_verifyCertificateChain (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), &tempOutput);
21514         aOutput = (CertificateChainState )tempOutput;
21515       }
21516     catch (...)
21517       {
21518         throw;
21519       }
21520     if (ex != NULL) SignDoc_throw (ex);
21521     return r;
21522   }
21523 
21547   ReturnCode getCertificateRevocationState (CertificateRevocationState &aOutput)
21548   {
21549     SIGNDOC_Exception *ex = NULL;
21550     int tempOutput = 0;
21551     ReturnCode r;
21552     try
21553       {
21554         r = (ReturnCode)SIGNDOC_VerificationResult_getCertificateRevocationState (&ex, p, &tempOutput);
21555         aOutput = (CertificateRevocationState )tempOutput;
21556       }
21557     catch (...)
21558       {
21559         throw;
21560       }
21561     if (ex != NULL) SignDoc_throw (ex);
21562     return r;
21563   }
21564 
21587   ReturnCode verifyCertificateSimplified (const SignDocVerificationParameters *aParameters)
21588   {
21589     SIGNDOC_Exception *ex = NULL;
21590     ReturnCode r;
21591     r = (ReturnCode)SIGNDOC_VerificationResult_verifyCertificateSimplified (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl ());
21592     if (ex != NULL) SignDoc_throw (ex);
21593     return r;
21594   }
21595 
21614   ReturnCode getCertificateChainLength (int &aOutput)
21615   {
21616     SIGNDOC_Exception *ex = NULL;
21617     ReturnCode r;
21618     r = (ReturnCode)SIGNDOC_VerificationResult_getCertificateChainLength (&ex, p, &aOutput);
21619     if (ex != NULL) SignDoc_throw (ex);
21620     return r;
21621   }
21622 
21677   ReturnCode getSignatureString (Encoding aEncoding, const std::string &aName,
21678                                  std::string &aOutput)
21679   {
21680     SIGNDOC_Exception *ex = NULL;
21681     char *tempOutput = NULL;
21682     ReturnCode r;
21683     try
21684       {
21685         r = (ReturnCode)SIGNDOC_VerificationResult_getSignatureString (&ex, p, aEncoding, aName.c_str (), &tempOutput);
21686         if (tempOutput != NULL)
21687           aOutput = tempOutput;
21688       }
21689     catch (...)
21690       {
21691         SIGNDOC_free (tempOutput);
21692         throw;
21693       }
21694     SIGNDOC_free (tempOutput);
21695     if (ex != NULL) SignDoc_throw (ex);
21696     return r;
21697   }
21698 
21727   ReturnCode getSignatureBlob (const std::string &aName,
21728                                std::vector<unsigned char> &aOutput)
21729   {
21730     SIGNDOC_Exception *ex = NULL;
21731     SIGNDOC_ByteArray *tempOutput = NULL;
21732     ReturnCode r;
21733     try
21734       {
21735         tempOutput = SIGNDOC_ByteArray_new (&ex);
21736         if (ex != NULL) SignDoc_throw (ex);
21737         r = (ReturnCode)SIGNDOC_VerificationResult_getSignatureBlob (&ex, p, aName.c_str (), tempOutput);
21738         assignArray (aOutput, tempOutput);
21739       }
21740     catch (...)
21741       {
21742         if (tempOutput != NULL)
21743           SIGNDOC_ByteArray_delete (tempOutput);
21744         throw;
21745       }
21746     if (tempOutput != NULL)
21747       SIGNDOC_ByteArray_delete (tempOutput);
21748     if (ex != NULL) SignDoc_throw (ex);
21749     return r;
21750   }
21751 
21795   ReturnCode getBiometricData (const unsigned char *aKeyPtr, size_t aKeySize,
21796                                const wchar_t *aKeyPath,
21797                                const char *aPassphrase,
21798                                std::vector<unsigned char> &aOutput)
21799   {
21800     SIGNDOC_Exception *ex = NULL;
21801     SIGNDOC_ByteArray *tempOutput = NULL;
21802     ReturnCode r;
21803     try
21804       {
21805         tempOutput = SIGNDOC_ByteArray_new (&ex);
21806         if (ex != NULL) SignDoc_throw (ex);
21807         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricDataW (&ex, p, aKeyPtr, aKeySize, aKeyPath, aPassphrase, tempOutput);
21808         assignArray (aOutput, tempOutput);
21809       }
21810     catch (...)
21811       {
21812         if (tempOutput != NULL)
21813           SIGNDOC_ByteArray_delete (tempOutput);
21814         throw;
21815       }
21816     if (tempOutput != NULL)
21817       SIGNDOC_ByteArray_delete (tempOutput);
21818     if (ex != NULL) SignDoc_throw (ex);
21819     return r;
21820   }
21821 
21867   ReturnCode getBiometricData (Encoding aEncoding,
21868                                const unsigned char *aKeyPtr, size_t aKeySize,
21869                                const char *aKeyPath, const char *aPassphrase,
21870                                std::vector<unsigned char> &aOutput)
21871   {
21872     SIGNDOC_Exception *ex = NULL;
21873     SIGNDOC_ByteArray *tempOutput = NULL;
21874     ReturnCode r;
21875     try
21876       {
21877         tempOutput = SIGNDOC_ByteArray_new (&ex);
21878         if (ex != NULL) SignDoc_throw (ex);
21879         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricData (&ex, p, aEncoding, aKeyPtr, aKeySize, aKeyPath, aPassphrase, tempOutput);
21880         assignArray (aOutput, tempOutput);
21881       }
21882     catch (...)
21883       {
21884         if (tempOutput != NULL)
21885           SIGNDOC_ByteArray_delete (tempOutput);
21886         throw;
21887       }
21888     if (tempOutput != NULL)
21889       SIGNDOC_ByteArray_delete (tempOutput);
21890     if (ex != NULL) SignDoc_throw (ex);
21891     return r;
21892   }
21893 
21957   ReturnCode getEncryptedBiometricData (std::vector<unsigned char> &aOutput)
21958   {
21959     SIGNDOC_Exception *ex = NULL;
21960     SIGNDOC_ByteArray *tempOutput = NULL;
21961     ReturnCode r;
21962     try
21963       {
21964         tempOutput = SIGNDOC_ByteArray_new (&ex);
21965         if (ex != NULL) SignDoc_throw (ex);
21966         r = (ReturnCode)SIGNDOC_VerificationResult_getEncryptedBiometricData (&ex, p, tempOutput);
21967         assignArray (aOutput, tempOutput);
21968       }
21969     catch (...)
21970       {
21971         if (tempOutput != NULL)
21972           SIGNDOC_ByteArray_delete (tempOutput);
21973         throw;
21974       }
21975     if (tempOutput != NULL)
21976       SIGNDOC_ByteArray_delete (tempOutput);
21977     if (ex != NULL) SignDoc_throw (ex);
21978     return r;
21979   }
21980 
21994   ReturnCode getBiometricEncryption (SignDocSignatureParameters::BiometricEncryption &aOutput)
21995   {
21996     SIGNDOC_Exception *ex = NULL;
21997     int tempOutput = 0;
21998     ReturnCode r;
21999     try
22000       {
22001         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricEncryption (&ex, p, &tempOutput);
22002         aOutput = (SignDocSignatureParameters::BiometricEncryption )tempOutput;
22003       }
22004     catch (...)
22005       {
22006         throw;
22007       }
22008     if (ex != NULL) SignDoc_throw (ex);
22009     return r;
22010   }
22011 
22028   ReturnCode checkBiometricHash (const unsigned char *aBioPtr, size_t aBioSize,
22029                                  bool &aOutput)
22030   {
22031     SIGNDOC_Exception *ex = NULL;
22032     SIGNDOC_Boolean tempOutput = 0;
22033     ReturnCode r;
22034     try
22035       {
22036         r = (ReturnCode)SIGNDOC_VerificationResult_checkBiometricHash (&ex, p, aBioPtr, aBioSize, &tempOutput);
22037         aOutput = (bool )tempOutput;
22038       }
22039     catch (...)
22040       {
22041         throw;
22042       }
22043     if (ex != NULL) SignDoc_throw (ex);
22044     return r;
22045   }
22046 
22054   ReturnCode getTimeStampState (TimeStampState &aOutput)
22055   {
22056     SIGNDOC_Exception *ex = NULL;
22057     int tempOutput = 0;
22058     ReturnCode r;
22059     try
22060       {
22061         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampState (&ex, p, &tempOutput);
22062         aOutput = (TimeStampState )tempOutput;
22063       }
22064     catch (...)
22065       {
22066         throw;
22067       }
22068     if (ex != NULL) SignDoc_throw (ex);
22069     return r;
22070   }
22071 
22094   ReturnCode getTimeStampDigestAlgorithm (std::string &aOutput)
22095   {
22096     SIGNDOC_Exception *ex = NULL;
22097     char *tempOutput = NULL;
22098     ReturnCode r;
22099     try
22100       {
22101         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampDigestAlgorithm (&ex, p, &tempOutput);
22102         if (tempOutput != NULL)
22103           aOutput = tempOutput;
22104       }
22105     catch (...)
22106       {
22107         SIGNDOC_free (tempOutput);
22108         throw;
22109       }
22110     SIGNDOC_free (tempOutput);
22111     if (ex != NULL) SignDoc_throw (ex);
22112     return r;
22113   }
22114 
22133   ReturnCode verifyTimeStampCertificateChain (const SignDocVerificationParameters *aParameters,
22134                                               CertificateChainState &aOutput)
22135   {
22136     SIGNDOC_Exception *ex = NULL;
22137     int tempOutput = 0;
22138     ReturnCode r;
22139     try
22140       {
22141         r = (ReturnCode)SIGNDOC_VerificationResult_verifyTimeStampCertificateChain (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), &tempOutput);
22142         aOutput = (CertificateChainState )tempOutput;
22143       }
22144     catch (...)
22145       {
22146         throw;
22147       }
22148     if (ex != NULL) SignDoc_throw (ex);
22149     return r;
22150   }
22151 
22173   ReturnCode getTimeStampCertificateRevocationState (CertificateRevocationState &aOutput)
22174   {
22175     SIGNDOC_Exception *ex = NULL;
22176     int tempOutput = 0;
22177     ReturnCode r;
22178     try
22179       {
22180         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampCertificateRevocationState (&ex, p, &tempOutput);
22181         aOutput = (CertificateRevocationState )tempOutput;
22182       }
22183     catch (...)
22184       {
22185         throw;
22186       }
22187     if (ex != NULL) SignDoc_throw (ex);
22188     return r;
22189   }
22190 
22219   ReturnCode verifyTimeStampCertificateSimplified (const SignDocVerificationParameters *aParameters)
22220   {
22221     SIGNDOC_Exception *ex = NULL;
22222     ReturnCode r;
22223     r = (ReturnCode)SIGNDOC_VerificationResult_verifyTimeStampCertificateSimplified (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl ());
22224     if (ex != NULL) SignDoc_throw (ex);
22225     return r;
22226   }
22227 
22248   ReturnCode getTimeStamp (std::string &aOutput)
22249   {
22250     SIGNDOC_Exception *ex = NULL;
22251     char *tempOutput = NULL;
22252     ReturnCode r;
22253     try
22254       {
22255         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStamp (&ex, p, &tempOutput);
22256         if (tempOutput != NULL)
22257           aOutput = tempOutput;
22258       }
22259     catch (...)
22260       {
22261         SIGNDOC_free (tempOutput);
22262         throw;
22263       }
22264     SIGNDOC_free (tempOutput);
22265     if (ex != NULL) SignDoc_throw (ex);
22266     return r;
22267   }
22268 
22279   ReturnCode getTimeStampCertificates (std::vector<std::vector<unsigned char> > &aOutput)
22280   {
22281     SIGNDOC_Exception *ex = NULL;
22282     SIGNDOC_ByteArrayArray *tempOutput = NULL;
22283     ReturnCode r;
22284     try
22285       {
22286         tempOutput = SIGNDOC_ByteArrayArray_new (&ex);
22287         if (ex != NULL) SignDoc_throw (ex);
22288         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampCertificates (&ex, p, tempOutput);
22289         assignArray (aOutput, tempOutput);
22290       }
22291     catch (...)
22292       {
22293         if (tempOutput != NULL)
22294           SIGNDOC_ByteArrayArray_delete (tempOutput);
22295         throw;
22296       }
22297     if (tempOutput != NULL)
22298       SIGNDOC_ByteArrayArray_delete (tempOutput);
22299     if (ex != NULL) SignDoc_throw (ex);
22300     return r;
22301   }
22302 
22316   const char *getErrorMessage (Encoding aEncoding) const
22317   {
22318     SIGNDOC_Exception *ex = NULL;
22319     const char *r;
22320     r = SIGNDOC_VerificationResult_getErrorMessage (&ex, p, aEncoding);
22321     if (ex != NULL) SignDoc_throw (ex);
22322     return r;
22323   }
22324 
22336   const wchar_t *getErrorMessageW () const
22337   {
22338     SIGNDOC_Exception *ex = NULL;
22339     const wchar_t *r;
22340     r = SIGNDOC_VerificationResult_getErrorMessageW (&ex, p);
22341     if (ex != NULL) SignDoc_throw (ex);
22342     return r;
22343   }
22348   SignDocVerificationResult (SIGNDOC_VerificationResult *aP) : p (aP) { }
22349 
22354   SIGNDOC_VerificationResult *getImpl () { return p; }
22355 
22360   const SIGNDOC_VerificationResult *getImpl () const { return p; }
22361 
22366   void setImpl (SIGNDOC_VerificationResult *aP) { SIGNDOC_VerificationResult_delete (p); p  = aP; }
22367 
22368 private:
22369   SIGNDOC_VerificationResult *p;
22370 };
22371 
22375 class SignDocPdfDocumentHandler : public SignDocDocumentHandler
22376 {
22377 public:
22378 
22384   static SignDocDocumentHandler *create ()
22385   {
22386     SIGNDOC_Exception *ex = NULL;
22387     SIGNDOC_DocumentHandler *r;
22388     r = SIGNDOC_PdfDocumentHandler_new (&ex);
22389     if (ex != NULL) SignDoc_throw (ex);
22390     if (r == NULL)
22391       return NULL;
22392     try
22393       {
22394         return new SignDocDocumentHandler (r);
22395       }
22396     catch (...)
22397       {
22398         SIGNDOC_DocumentHandler_delete (r);
22399         throw;
22400       }
22401   }
22402 
22403 private:
22408   SignDocPdfDocumentHandler ();
22409 
22414   SignDocPdfDocumentHandler (const SIGNDOC_PdfDocumentHandler &);
22415 
22420   SignDocPdfDocumentHandler& operator= (const SIGNDOC_PdfDocumentHandler &);
22421 };
22422 
22426 class SignDocTiffDocumentHandler : public SignDocDocumentHandler
22427 {
22428 public:
22429 
22435   static SignDocDocumentHandler *create ()
22436   {
22437     SIGNDOC_Exception *ex = NULL;
22438     SIGNDOC_DocumentHandler *r;
22439     r = SIGNDOC_TiffDocumentHandler_new (&ex);
22440     if (ex != NULL) SignDoc_throw (ex);
22441     if (r == NULL)
22442       return NULL;
22443     try
22444       {
22445         return new SignDocDocumentHandler (r);
22446       }
22447     catch (...)
22448       {
22449         SIGNDOC_DocumentHandler_delete (r);
22450         throw;
22451       }
22452   }
22453 
22454 private:
22459   SignDocTiffDocumentHandler ();
22460 
22465   SignDocTiffDocumentHandler (const SIGNDOC_TiffDocumentHandler &);
22466 
22471   SignDocTiffDocumentHandler& operator= (const SIGNDOC_TiffDocumentHandler &);
22472 };
22473 
22474 inline SignDocVerificationResult *
22475 makeSignDocVerificationResult (SIGNDOC_VerificationResult *aP)
22476 {
22477   if (aP == NULL)
22478     return NULL;
22479   return new SignDocVerificationResult (aP);
22480 }
22481 
22482 #ifdef _MSC_VER
22483 #pragma warning(pop)
22484 #endif
22485 
22486 }}}
22487 
22488 #endif