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     default:
00088       throw std::runtime_error (msg);
00089     }
00090 #else
00091   throw std::runtime_error (msg);
00092 #endif
00093 }
00094 
00099 inline void
00100 SIGNDOC_catch (SIGNDOC_Exception **aEx, std::exception &aInput)
00101 {
00102   *aEx = SIGNDOC_Exception_new (SIGNDOC_EXCEPTION_TYPE_GENERIC,
00103                                 aInput.what ());
00104 }
00105 
00110 inline SignDocVerificationResult *
00111 makeSignDocVerificationResult (SIGNDOC_VerificationResult *aP);
00112 
00113 inline void assignArray (std::vector<unsigned char> &aDst,
00114                          SIGNDOC_ByteArray *aSrc)
00115 {
00116   unsigned n = 0;
00117   if (aSrc != NULL)
00118     n = SIGNDOC_ByteArray_count (aSrc);
00119   if (n == 0)
00120     aDst.clear ();
00121   else
00122     {
00123       const unsigned char *p = SIGNDOC_ByteArray_data (aSrc);
00124       aDst.assign (p, p + n);
00125     }
00126 }
00127 
00132 inline void assignArray (std::vector<std::vector<unsigned char> > &aDst,
00133                          SIGNDOC_ByteArrayArray *aSrc)
00134 {
00135   unsigned n = SIGNDOC_ByteArrayArray_count (aSrc);
00136   aDst.resize (n);
00137   for (unsigned i = 0; i < n; ++i)
00138     assignArray (aDst[i], SIGNDOC_ByteArrayArray_at (aSrc, i));
00139 }
00140 
00145 inline void assignArray (std::vector<std::string> &aDst,
00146                          SIGNDOC_StringArray *aSrc)
00147 {
00148   unsigned n = SIGNDOC_StringArray_count (aSrc);
00149   aDst.resize (n);
00150   for (unsigned i = 0; i < n; ++i)
00151     aDst[i] = SIGNDOC_StringArray_at (aSrc, i);
00152 }
00153 
00154 //----------------------------------------------------------------------------
00155 
00163 class InputStream
00164 {
00165 public:
00171   InputStream (SIGNDOC_InputStream *aImpl) : p (aImpl) { }
00172 
00176   virtual ~InputStream ()
00177   {
00178     SIGNDOC_InputStream_delete (p);
00179   }
00180 
00196   virtual int read (void *aDst, int aLen) = 0;
00197 
00204   virtual void close () = 0;
00205 
00214   virtual void seek (int aPos) = 0;
00215 
00224   virtual int tell () const = 0;
00225 
00238   virtual int getAvailable () = 0;
00239 
00244   SIGNDOC_InputStream *getImpl () { return p; }
00245 
00246 protected:
00250   SIGNDOC_InputStream *p;
00251 
00252 private:
00256   InputStream (const InputStream &);
00257 
00261   InputStream &operator= (const InputStream &);
00262 };
00263 
00269 class UserInputStream : public InputStream
00270 {
00271 public:
00275   UserInputStream ()
00276     : InputStream (NULL)
00277   {
00278     SIGNDOC_Exception *ex = NULL;
00279     p = SIGNDOC_UserInputStream_new (&ex, this,
00280                                      closeC, readC, seekC, tellC,
00281                                      getAvailableC);
00282     if (ex != NULL) SignDoc_throw (ex);
00283   }
00284 
00285 private:
00289   static void SDCAPI closeC (SIGNDOC_Exception **aEx,
00290                              void *aClosure)
00291   {
00292     *aEx = NULL;
00293     try
00294       {
00295         reinterpret_cast<UserInputStream*>(aClosure)->close ();
00296       }
00297     catch (std::exception &e)
00298       {
00299         SIGNDOC_catch (aEx, e);
00300       }
00301   }
00302 
00306   static int SDCAPI readC (SIGNDOC_Exception **aEx,
00307                            void *aClosure,
00308                            void *aDst, int aLen)
00309   {
00310     *aEx = NULL;
00311     try
00312       {
00313         return reinterpret_cast<UserInputStream*>(aClosure)->read (aDst, aLen);
00314       }
00315     catch (std::exception &e)
00316       {
00317         SIGNDOC_catch (aEx, e);
00318         return 0;
00319       }
00320   }
00321 
00325   static void SDCAPI seekC (SIGNDOC_Exception **aEx,
00326                             void *aClosure,
00327                             int aPos)
00328   {
00329     *aEx = NULL;
00330     try
00331       {
00332         return reinterpret_cast<UserInputStream*>(aClosure)->seek (aPos);
00333       }
00334     catch (std::exception &e)
00335       {
00336         SIGNDOC_catch (aEx, e);
00337       }
00338   }
00339 
00343   static int SDCAPI tellC (SIGNDOC_Exception **aEx,
00344                            const void *aClosure)
00345   {
00346     *aEx = NULL;
00347     try
00348       {
00349         return reinterpret_cast<const UserInputStream*>(aClosure)->tell ();
00350       }
00351     catch (std::exception &e)
00352       {
00353         SIGNDOC_catch (aEx, e);
00354         return 0;
00355       }
00356   }
00357 
00361   static int SDCAPI getAvailableC (SIGNDOC_Exception **aEx,
00362                                    void *aClosure)
00363   {
00364     *aEx = NULL;
00365     try
00366       {
00367         return reinterpret_cast<UserInputStream*>(aClosure)->getAvailable ();
00368       }
00369     catch (std::exception &e)
00370       {
00371         SIGNDOC_catch (aEx, e);
00372         return 0;
00373       }
00374   }
00375 };
00376 
00380 class LibraryInputStream : public InputStream
00381 {
00382 public:
00388   LibraryInputStream (SIGNDOC_InputStream *aImpl)
00389     : InputStream (aImpl) { }
00390 
00391   virtual int read (void *aDst, int aLen)
00392   {
00393     SIGNDOC_Exception *ex = NULL;
00394     int r = SIGNDOC_InputStream_read (&ex, p, aDst, aLen);
00395     if (ex != NULL) SignDoc_throw (ex);
00396     return r;
00397   }
00398 
00399   virtual void close ()
00400   {
00401     SIGNDOC_Exception *ex = NULL;
00402     SIGNDOC_InputStream_close (&ex, p);
00403     if (ex != NULL) SignDoc_throw (ex);
00404   }
00405 
00406   virtual void seek (int aPos)
00407   {
00408     SIGNDOC_Exception *ex = NULL;
00409     SIGNDOC_InputStream_seek (&ex, p, aPos);
00410     if (ex != NULL) SignDoc_throw (ex);
00411   }
00412 
00413   virtual int tell () const
00414   {
00415     SIGNDOC_Exception *ex = NULL;
00416     int r = SIGNDOC_InputStream_tell (&ex, p);
00417     if (ex != NULL) SignDoc_throw (ex);
00418     return r;
00419   }
00420 
00421   virtual int getAvailable ()
00422   {
00423     SIGNDOC_Exception *ex = NULL;
00424     int r = SIGNDOC_InputStream_getAvailable (&ex, p);
00425     if (ex != NULL) SignDoc_throw (ex);
00426     return r;
00427   }
00428 };
00429 
00430 #if defined (SPOOC_INPUTSTREAM_H__) || defined (SPOOC_INPUTSTREAM_H_INCLUDED_)
00431 
00432 class Spooc1InputStream : public spooc::InputStream
00433 {
00434 public:
00435   Spooc1InputStream (de::softpro::doc::InputStream &aStream)
00436      : mStream (aStream) { }
00437   virtual int read (void *aDst, int aLen) { return mStream.read (aDst, aLen); }
00438   virtual void close () { mStream.close (); }
00439   virtual void seek (int aPos) { mStream.seek (aPos); }
00440   virtual int tell () const { return mStream.tell (); }
00441   virtual int avail () { return mStream.getAvailable (); }
00442 private:
00443   de::softpro::doc::InputStream &mStream;
00444 };
00445 
00446 class Spooc2InputStream : public UserInputStream
00447 {
00448 public:
00449   Spooc2InputStream (spooc::InputStream &aStream)
00450      : mStream (aStream) { }
00451   virtual int read (void *aDst, int aLen) { return mStream.read (aDst, aLen); }
00452   virtual void close () { mStream.close (); }
00453   virtual void seek (int aPos) { mStream.seek (aPos); }
00454   virtual int tell () const { return mStream.tell (); }
00455   virtual int getAvailable () { return mStream.avail (); }
00456 private:
00457   spooc::InputStream &mStream;
00458 };
00459 
00460 #endif
00461 
00462 //----------------------------------------------------------------------------
00463 
00470 class FileInputStream : public LibraryInputStream
00471 {
00472 public:
00478   FileInputStream (FILE *aFile)
00479     : LibraryInputStream (NULL)
00480   {
00481     SIGNDOC_Exception *ex = NULL;
00482     p = SIGNDOC_FileInputStream_newWithFile (&ex, aFile);
00483     if (ex != NULL) SignDoc_throw (ex);
00484   };
00485 
00493   FileInputStream (FILE *aFile, const char *aPath)
00494     : LibraryInputStream (NULL)
00495   {
00496     SIGNDOC_Exception *ex = NULL;
00497     p = SIGNDOC_FileInputStream_newWithFileAndPath (&ex, aFile, aPath);
00498     if (ex != NULL) SignDoc_throw (ex);
00499   };
00500 
00508   FileInputStream (const char *aPath)
00509     : LibraryInputStream (NULL)
00510   {
00511     SIGNDOC_Exception *ex = NULL;
00512     p = SIGNDOC_FileInputStream_newWithPath (&ex, aPath);
00513     if (ex != NULL) SignDoc_throw (ex);
00514   };
00515 
00523   FileInputStream (const wchar_t *aPath)
00524     : LibraryInputStream (NULL)
00525   {
00526     SIGNDOC_Exception *ex = NULL;
00527     p = SIGNDOC_FileInputStream_newWithPathW (&ex, aPath);
00528     if (ex != NULL) SignDoc_throw (ex);
00529   };
00530 };
00531 
00532 //----------------------------------------------------------------------------
00533 
00537 class MemoryInputStream : public LibraryInputStream
00538 {
00539 public:
00550   MemoryInputStream (const unsigned char *aSrc, size_t aLen)
00551     : LibraryInputStream (NULL)
00552   {
00553     SIGNDOC_Exception *ex = NULL;
00554     p = SIGNDOC_MemoryInputStream_new (&ex, aSrc, aLen);
00555     if (ex != NULL) SignDoc_throw (ex);
00556   };
00557 };
00558 
00559 //----------------------------------------------------------------------------
00560 
00568 class OutputStream
00569 {
00570 public:
00576   OutputStream (SIGNDOC_OutputStream *aImpl) : p (aImpl) { }
00577 
00581   virtual ~OutputStream ()
00582   {
00583     SIGNDOC_OutputStream_delete (p);
00584   }
00585 
00597   virtual void close () = 0;
00598 
00607   virtual void flush () = 0;
00608 
00617   virtual void seek (int aPos) = 0;
00618 
00627   virtual int tell () const = 0;
00628 
00637   virtual void write (const void *aSrc, int aLen) = 0;
00638 
00643   SIGNDOC_OutputStream *getImpl () { return p; }
00644 
00645 protected:
00649   SIGNDOC_OutputStream *p;
00650 
00651 private:
00655   OutputStream (const OutputStream &);
00656 
00660   OutputStream &operator= (const OutputStream &);
00661 };
00662 
00668 class UserOutputStream : public OutputStream
00669 {
00670 public:
00674   UserOutputStream ()
00675     : OutputStream (NULL)
00676   {
00677     SIGNDOC_Exception *ex = NULL;
00678     p = SIGNDOC_UserOutputStream_new (&ex, this,
00679                                       closeC, flushC, writeC, seekC,
00680                                       tellC);
00681     if (ex != NULL) SignDoc_throw (ex);
00682   }
00683 
00684 private:
00688   static void SDCAPI closeC (SIGNDOC_Exception **aEx,
00689                              void *aClosure)
00690   {
00691     *aEx = NULL;
00692     try
00693       {
00694         reinterpret_cast<UserOutputStream*>(aClosure)->close ();
00695       }
00696     catch (std::exception &e)
00697       {
00698         SIGNDOC_catch (aEx, e);
00699       }
00700   }
00701 
00705   static void SDCAPI flushC (SIGNDOC_Exception **aEx,
00706                              void *aClosure)
00707   {
00708     *aEx = NULL;
00709     try
00710       {
00711         reinterpret_cast<UserOutputStream*>(aClosure)->flush ();
00712       }
00713     catch (std::exception &e)
00714       {
00715         SIGNDOC_catch (aEx, e);
00716       }
00717   }
00718 
00722   static void SDCAPI writeC (SIGNDOC_Exception **aEx,
00723                              void *aClosure,
00724                              const void *aSrc, int aLen)
00725   {
00726     *aEx = NULL;
00727     try
00728       {
00729         reinterpret_cast<UserOutputStream*>(aClosure)->write (aSrc, aLen);
00730       }
00731     catch (std::exception &e)
00732       {
00733         SIGNDOC_catch (aEx, e);
00734       }
00735   }
00736 
00740   static void SDCAPI seekC (SIGNDOC_Exception **aEx,
00741                             void *aClosure,
00742                             int aPos)
00743   {
00744     *aEx = NULL;
00745     try
00746       {
00747         return reinterpret_cast<UserOutputStream*>(aClosure)->seek (aPos);
00748       }
00749     catch (std::exception &e)
00750       {
00751         SIGNDOC_catch (aEx, e);
00752       }
00753   }
00754 
00758   static int SDCAPI tellC (SIGNDOC_Exception **aEx,
00759                            const void *aClosure)
00760   {
00761     *aEx = NULL;
00762     try
00763       {
00764         return reinterpret_cast<const UserOutputStream*>(aClosure)->tell ();
00765       }
00766     catch (std::exception &e)
00767       {
00768         SIGNDOC_catch (aEx, e);
00769         return 0;
00770       }
00771   }
00772 };
00773 
00777 class LibraryOutputStream : public OutputStream
00778 {
00779 public:
00785   LibraryOutputStream (SIGNDOC_OutputStream *aImpl)
00786     : OutputStream (aImpl) { }
00787 
00788   virtual void close ()
00789   {
00790     SIGNDOC_Exception *ex = NULL;
00791     SIGNDOC_OutputStream_close (&ex, p);
00792     if (ex != NULL) SignDoc_throw (ex);
00793   }
00794 
00795   virtual void flush ()
00796   {
00797     SIGNDOC_Exception *ex = NULL;
00798     SIGNDOC_OutputStream_flush (&ex, p);
00799     if (ex != NULL) SignDoc_throw (ex);
00800   }
00801 
00802   virtual void write (const void *aSrc, int aLen)
00803   {
00804     SIGNDOC_Exception *ex = NULL;
00805     SIGNDOC_OutputStream_write (&ex, p, aSrc, aLen);
00806     if (ex != NULL) SignDoc_throw (ex);
00807   }
00808 
00809   virtual void seek (int aPos)
00810   {
00811     SIGNDOC_Exception *ex = NULL;
00812     SIGNDOC_OutputStream_seek (&ex, p, aPos);
00813     if (ex != NULL) SignDoc_throw (ex);
00814   }
00815 
00816   virtual int tell () const
00817   {
00818     SIGNDOC_Exception *ex = NULL;
00819     int r = SIGNDOC_OutputStream_tell (&ex, p);
00820     if (ex != NULL) SignDoc_throw (ex);
00821     return r;
00822   }
00823 };
00824 
00825 #if defined (SPOOC_OUTPUTSTREAM_H__) || defined (SPOOC_OUTPUTSTREAM_H_INCLUDED_)
00826 
00827 class Spooc1OutputStream : public spooc::OutputStream
00828 {
00829 public:
00830   Spooc1OutputStream (de::softpro::doc::OutputStream &aStream)
00831     : mStream (aStream) { }
00832   virtual void close () { mStream.close (); }
00833   virtual void flush () { mStream.flush (); }
00834   virtual void write (const void *aSrc, int aLen) { mStream.write (aSrc, aLen); }
00835   virtual void seek (int aPos) { mStream.seek (aPos); }
00836   virtual int tell () const { return mStream.tell (); }
00837 private:
00838   de::softpro::doc::OutputStream &mStream;
00839 };
00840 
00841 class Spooc2OutputStream : public UserOutputStream
00842 {
00843 public:
00844   Spooc2OutputStream (spooc::OutputStream &aStream)
00845     : mStream (aStream) { }
00846   ~Spooc2OutputStream () { }
00847   virtual void close () { mStream.close (); }
00848   virtual void flush () { mStream.flush (); }
00849   virtual void write (const void *aSrc, int aLen) { mStream.write (aSrc, aLen); }
00850   virtual void seek (int aPos) { mStream.seek (aPos); }
00851   virtual int tell () const { return mStream.tell (); }
00852 private:
00853   spooc::OutputStream &mStream;
00854 };
00855 
00856 #endif
00857 
00858 //----------------------------------------------------------------------------
00859 
00866 class FileOutputStream : public LibraryOutputStream
00867 {
00868 public:
00874   FileOutputStream (FILE *aFile)
00875     : LibraryOutputStream (NULL)
00876   {
00877     SIGNDOC_Exception *ex = NULL;
00878     p = SIGNDOC_FileOutputStream_newWithFile (&ex, aFile);
00879     if (ex != NULL) SignDoc_throw (ex);
00880   };
00881 
00889   FileOutputStream (FILE *aFile, const char *aPath)
00890     : LibraryOutputStream (NULL)
00891   {
00892     SIGNDOC_Exception *ex = NULL;
00893     p = SIGNDOC_FileOutputStream_newWithFileAndPath (&ex, aFile, aPath);
00894     if (ex != NULL) SignDoc_throw (ex);
00895   };
00896 
00905   FileOutputStream (const char *aPath)
00906     : LibraryOutputStream (NULL)
00907   {
00908     SIGNDOC_Exception *ex = NULL;
00909     p = SIGNDOC_FileOutputStream_newWithPath (&ex, aPath);
00910     if (ex != NULL) SignDoc_throw (ex);
00911   };
00912 
00921   FileOutputStream (const wchar_t *aPath)
00922     : LibraryOutputStream (NULL)
00923   {
00924     SIGNDOC_Exception *ex = NULL;
00925     p = SIGNDOC_FileOutputStream_newWithPathW (&ex, aPath);
00926     if (ex != NULL) SignDoc_throw (ex);
00927   };
00928 };
00929 
00930 //----------------------------------------------------------------------------
00931 
00936 class MemoryOutputStream : public LibraryOutputStream
00937 {
00938 public:
00942   MemoryOutputStream ()
00943     : LibraryOutputStream (NULL)
00944   {
00945     SIGNDOC_Exception *ex = NULL;
00946     p = SIGNDOC_MemoryOutputStream_new (&ex);
00947     if (ex != NULL) SignDoc_throw (ex);
00948   };
00949 
00958   const unsigned char *data ()
00959   {
00960     SIGNDOC_Exception *ex = NULL;
00961     const unsigned char *r = SIGNDOC_MemoryOutputStream_data (&ex, p);
00962     if (ex != NULL) SignDoc_throw (ex);
00963     return r;
00964   }
00965 
00969   size_t length ()
00970   {
00971     SIGNDOC_Exception *ex = NULL;
00972     size_t r = SIGNDOC_MemoryOutputStream_length (&ex, p);
00973     if (ex != NULL) SignDoc_throw (ex);
00974     return r;
00975   }
00976 
00984   void clear ()
00985   {
00986     SIGNDOC_Exception *ex = NULL;
00987     SIGNDOC_MemoryOutputStream_clear (&ex, p);
00988     if (ex != NULL) SignDoc_throw (ex);
00989   }
00990 };
00994 enum Encoding
00995 {
00996   enc_native,      
00997   enc_utf_8,       
00998   enc_latin_1      
00999 };
01000 
01004 // cppcheck-suppress copyCtorAndEqOperator
01005 class Point 
01006 {
01007 public:
01013   Point ()
01014     : mX (0), mY (0)
01015   {
01016   }
01017 
01024   Point (double aX, double aY)
01025     : mX (aX), mY (aY)
01026   {
01027   }
01028 
01034   Point (const Point &aSrc)
01035     : mX (aSrc.mX), mY (aSrc.mY)
01036   {
01037   }
01038 
01042   ~Point ()
01043   {
01044   }
01045 
01052   void set (double aX, double aY)
01053   {
01054     SIGNDOC_Point_setXY ((SIGNDOC_Point*)this, aX, aY);
01055   }
01056 
01057 public:
01061   double mX;
01062 
01066   double mY;
01067 };
01068 
01075 // cppcheck-suppress copyCtorAndEqOperator
01076 class Rect 
01077 {
01078 public:
01084   Rect ()
01085     : mX1 (0), mY1 (0), mX2 (0), mY2 (0)
01086   {
01087   }
01088 
01097   Rect (double aX1, double aY1, double aX2, double aY2)
01098     : mX1 (aX1), mY1 (aY1), mX2 (aX2), mY2 (aY2)
01099   {
01100   }
01101 
01107   Rect (const Rect &aSrc)
01108     : mX1 (aSrc.mX1), mY1 (aSrc.mY1), mX2 (aSrc.mX2), mY2 (aSrc.mY2)
01109   {
01110   }
01111 
01115   ~Rect ()
01116   {
01117   }
01118 
01127   void get (double &aX1, double &aY1, double &aX2, double &aY2) const
01128   {
01129     SIGNDOC_Rect_get ((const SIGNDOC_Rect*)this, &aX1, &aY1, &aX2, &aY2);
01130   }
01131 
01140   void set (double aX1, double aY1, double aX2, double aY2)
01141   {
01142     SIGNDOC_Rect_setXY ((SIGNDOC_Rect*)this, aX1, aY1, aX2, aY2);
01143   }
01144 
01150   double getWidth () const
01151   {
01152     return SIGNDOC_Rect_getWidth ((const SIGNDOC_Rect*)this);
01153   }
01154 
01160   double getHeight () const
01161   {
01162     return SIGNDOC_Rect_getHeight ((const SIGNDOC_Rect*)this);
01163   }
01164 
01172   void normalize ()
01173   {
01174     SIGNDOC_Rect_normalize ((SIGNDOC_Rect*)this);
01175   }
01176 
01182   void scale (double aFactor)
01183   {
01184     SIGNDOC_Rect_scale ((SIGNDOC_Rect*)this, aFactor);
01185   }
01186 
01195   void scale (double aFactorX, double aFactorY)
01196   {
01197     SIGNDOC_Rect_scaleXY ((SIGNDOC_Rect*)this, aFactorX, aFactorY);
01198   }
01199 
01206   double getX1 () const
01207   {
01208     return mX1;
01209   }
01210 
01217   double getY1 () const
01218   {
01219     return mY1;
01220   }
01221 
01228   double getX2 () const
01229   {
01230     return mX2;
01231   }
01232 
01239   double getY2 () const
01240   {
01241     return mY2;
01242   }
01243 
01244 public:
01248   double mX1;
01249 
01253   double mY1;
01254 
01258   double mX2;
01259 
01263   double mY2;
01264 };
01265 
01269 class TimeStamper 
01270 {
01271 public:
01275   enum StampResult
01276   {
01280     sr_ok,
01281 
01285     sr_invalid_input,
01286 
01290     sr_timeout,
01291 
01295     sr_stopped,
01296 
01300     sr_tcp_error,
01301 
01305     sr_ssl_error,
01306 
01310     sr_http_error,
01311 
01316     sr_server_error,
01317 
01321     sr_invalid_response
01322   };
01323 
01327   enum StampFlags
01328   {
01334     sf_dont_check_revocation = 0x01,
01335 
01339     sf_dont_hash = 0x02
01340   };
01341 
01342 public:
01349   const char *getHashAlgorithm () const
01350   {
01351     return SIGNDOC_TimeStamper_getHashAlgorithm (p);
01352   }
01353 
01360   const char *getFallbackHashAlgorithm () const
01361   {
01362     return SIGNDOC_TimeStamper_getFallbackHashAlgorithm (p);
01363   }
01364 
01396   StampResult stamp (const unsigned char *aHashPtr, size_t aHashSize,
01397                      unsigned aRandomNonceSize, int aFlags,
01398                      std::vector<unsigned char> &aOutput, int &aStatus,
01399                      unsigned &aFailureInfo)
01400   {
01401     SIGNDOC_Exception *ex = NULL;
01402     SIGNDOC_ByteArray *tempOutput = NULL;
01403     StampResult r;
01404     try
01405       {
01406         tempOutput = SIGNDOC_ByteArray_new (&ex);
01407         if (ex != NULL) SignDoc_throw (ex);
01408         r = (StampResult)SIGNDOC_TimeStamper_stamp (&ex, p, aHashPtr, aHashSize, aRandomNonceSize, aFlags, tempOutput, &aStatus, &aFailureInfo);
01409         assignArray (aOutput, tempOutput);
01410       }
01411     catch (...)
01412       {
01413         if (tempOutput != NULL)
01414           SIGNDOC_ByteArray_delete (tempOutput);
01415         throw;
01416       }
01417     if (tempOutput != NULL)
01418       SIGNDOC_ByteArray_delete (tempOutput);
01419     if (ex != NULL) SignDoc_throw (ex);
01420     return r;
01421   }
01422 
01429   void stop ()
01430   {
01431     SIGNDOC_TimeStamper_stop (p);
01432   }
01433 
01444   const char *getErrorMessage () const
01445   {
01446     return SIGNDOC_TimeStamper_getErrorMessage (p);
01447   }
01448 
01449 protected:
01450 public:
01454   ~TimeStamper ()
01455   {
01456   }
01461   TimeStamper (SIGNDOC_TimeStamper *aP) : p (aP) { }
01462 
01467   SIGNDOC_TimeStamper *getImpl () { return p; }
01468 
01473   const SIGNDOC_TimeStamper *getImpl () const { return p; }
01474 
01475 private:
01476   SIGNDOC_TimeStamper *p;
01477 };
01478 
01484 class Source
01485 {
01486 public:
01492   Source (struct SIGNDOC_Source *aImpl)
01493     : p (aImpl) { }
01494 
01498   virtual ~Source () { }
01499 
01510   int fetch (const void *&aPtr, int aMaxSize)
01511   {
01512     struct SIGNDOC_Exception *ex = NULL;
01513     int r = SIGNDOC_Source_fetch (&ex, p, &aPtr, aMaxSize);
01514     if (ex != NULL) SignDoc_throw (ex);
01515     return r;
01516   }
01517 
01518 private:
01519   SIGNDOC_Source *p;
01520 };
01521 
01530 class SignPKCS7
01531 {
01532 public:
01536   enum HashAlgorithm
01537   {
01538     ha_none,                    
01539     ha_sha1,                    
01540     ha_sha256,                  
01541     ha_md5,                     
01542     ha_sha384,                  
01543     ha_sha512,                  
01544     ha_ripemd160,               
01545     ha_sha224                   
01546   };
01547 
01551   SignPKCS7 ()
01552     : p (NULL), mBadAlloc (false)
01553   {
01554     struct SIGNDOC_Exception *ex = NULL;
01555     p = SIGNDOC_SignPKCS7_new (&ex, this, signC, getSignatureSizeC,
01556                                getSubjectCommonNameC, getErrorMessageC);
01557     if (ex != NULL) SignDoc_throw (ex);
01558   }
01559 
01566   virtual ~SignPKCS7 ()
01567   {
01568     SIGNDOC_SignPKCS7_delete (p);
01569   }
01570 
01592   virtual bool sign (Source &aSource, bool aDetached,
01593                      HashAlgorithm aHashAlgorithm,
01594                      TimeStamper *aTimeStamper,
01595                      std::vector<unsigned char> &aOutput) = 0;
01596 
01617   virtual size_t getSignatureSize (bool aDetached,
01618                                    HashAlgorithm aHashAlgorithm) = 0;
01619 
01629   virtual bool getSubjectCommonName (std::string &aOutput) const = 0;
01630 
01645   virtual const char *getErrorMessage () const = 0;
01646 
01651   SIGNDOC_SignPKCS7 *getImpl () { return p; }
01652 
01653 private:
01654   static SIGNDOC_Boolean SDCAPI
01655   signC (void *aClosure, struct SIGNDOC_Source *aSource,
01656          SIGNDOC_Boolean aDetached, int aHashAlgorithm,
01657          struct SIGNDOC_TimeStamper *aTimeStamper,
01658          struct SIGNDOC_ByteArray *aOutput)
01659   {
01660     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01661     s->mBadAlloc = false;
01662     try
01663       {
01664         SIGNDOC_ByteArray_clear (aOutput);
01665         std::vector<unsigned char> output;
01666         Source src (aSource);
01667         TimeStamper ts (aTimeStamper);
01668         bool ok = s->sign (src, aDetached, (HashAlgorithm)aHashAlgorithm,
01669                            (aTimeStamper != NULL) ? &ts : NULL,
01670                            output);
01671         if (ok)
01672           assignByteArray (aOutput, output);
01673         return ok;
01674       }
01675     catch (std::bad_alloc &)
01676       {
01677         s->mBadAlloc = true;
01678         return SIGNDOC_FALSE;
01679       }
01680   }
01681 
01682   static size_t SDCAPI
01683   getSignatureSizeC (void *aClosure, SIGNDOC_Boolean aDetached,
01684                      int aHashAlgorithm)
01685   {
01686     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01687     s->mBadAlloc = false;
01688     try
01689       {
01690         return s->getSignatureSize (aDetached, (HashAlgorithm)aHashAlgorithm);
01691       }
01692     catch (std::bad_alloc &)
01693       {
01694         s->mBadAlloc = true;
01695         return 0;
01696       }
01697   }
01698 
01699   static SIGNDOC_Boolean SDCAPI
01700   getSubjectCommonNameC (void *aClosure, char **aOutput)
01701   {
01702     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01703     s->mBadAlloc = false;
01704     try
01705       {
01706         *aOutput = NULL;
01707         std::string output;
01708         bool ok = s->getSubjectCommonName (output);
01709         if (ok)
01710           assignString (aOutput, output);
01711         return ok;
01712       }
01713     catch (std::bad_alloc &)
01714       {
01715         s->mBadAlloc = true;
01716         return SIGNDOC_FALSE;
01717       }
01718   }
01719 
01720   static const char * SDCAPI
01721   getErrorMessageC (void *aClosure)
01722   {
01723     SignPKCS7 *s = static_cast<SignPKCS7*>(aClosure);
01724     if (s->mBadAlloc)
01725       return "out of memory";
01726     try
01727       {
01728         return s->getErrorMessage ();
01729       }
01730     catch (std::bad_alloc &)
01731       {
01732         s->mBadAlloc = true;
01733         return "out of memory";
01734       }
01735   }
01736 
01737   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
01738                                const std::vector<unsigned char> &aInput)
01739   {
01740     if (aInput.empty ())
01741       SIGNDOC_ByteArray_clear (aOutput);
01742     else
01743       {
01744         struct SIGNDOC_Exception *ex = NULL;
01745         SIGNDOC_ByteArray_set (&ex, aOutput,
01746                                &aInput[0], aInput.size ());
01747         if (ex != NULL) SignDoc_throw (ex);
01748       }
01749   }
01750 
01751   static void assignString (char **aOutput, const std::string &aInput)
01752   {
01753     struct SIGNDOC_Exception *ex = NULL;
01754     *aOutput = SIGNDOC_strdup (&ex, aInput.c_str ());
01755     if (ex != NULL) SignDoc_throw (ex);
01756   }
01757 
01758 private:
01759   SIGNDOC_SignPKCS7 *p;
01760   bool mBadAlloc;
01761 };
01762 
01768 class SignRSA
01769 {
01770 public:
01774   enum Version
01775   {
01779     v_1_5,
01780 
01786     v_2_0
01787   };
01788 
01792   enum HashAlgorithm
01793   {
01797     ha_sha1 = 1,
01798 
01802     ha_sha256 = 2,
01803 
01807     ha_sha384 = 3,
01808 
01812     ha_sha512 = 4,
01813 
01817     ha_ripemd160 = 5
01818   };
01819 
01820 public:
01824   SignRSA ()
01825     : p (NULL), mBadAlloc (false)
01826   {
01827     struct SIGNDOC_Exception *ex = NULL;
01828     p = SIGNDOC_SignRSA_new (&ex, this, signC, getSignatureSizeC,
01829                              getSigningCertificateC,
01830                              getCertificateCountC, getCertificateC,
01831                              getErrorMessageC);
01832     if (ex != NULL) SignDoc_throw (ex);
01833   }
01834 
01840   virtual ~SignRSA ()
01841   {
01842     SIGNDOC_SignRSA_delete (p);
01843   }
01844 
01859   virtual bool sign (Source &aSource,
01860                      Version aVersion, HashAlgorithm aHashAlgorithm,
01861                      std::vector<unsigned char> &aOutput) = 0;
01862 
01871   virtual int getSignatureSize () = 0;
01872 
01883   virtual bool getSigningCertificate (std::vector<unsigned char> &aOutput) const = 0;
01884 
01890   virtual int getCertificateCount () const = 0;
01891 
01904   virtual bool getCertificate (int aIndex,
01905                                std::vector<unsigned char> &aOutput) const = 0;
01906 
01919   virtual const char *getErrorMessage () const = 0;
01920 
01925   SIGNDOC_SignRSA *getImpl () { return p; }
01926 
01927 private:
01928   static SIGNDOC_Boolean SDCAPI
01929   signC (void *aClosure, struct SIGNDOC_Source *aSource,
01930          int aVersion, int aHashAlgorithm,
01931          struct SIGNDOC_ByteArray *aOutput)
01932   {
01933     SignRSA *s = static_cast<SignRSA*>(aClosure);
01934     s->mBadAlloc = false;
01935     try
01936       {
01937         std::vector<unsigned char> output;
01938         Source src (aSource);
01939         bool ok = s->sign (src, (Version)aVersion,
01940                            (HashAlgorithm)aHashAlgorithm, output);
01941         if (ok)
01942           assignByteArray (aOutput, output);
01943         return ok;
01944       }
01945     catch (std::bad_alloc &)
01946       {
01947         s->mBadAlloc = true;
01948         return SIGNDOC_FALSE;
01949       }
01950   }
01951 
01952   static int SDCAPI
01953   getSignatureSizeC (void *aClosure)
01954   {
01955     SignRSA *s = static_cast<SignRSA*>(aClosure);
01956     s->mBadAlloc = false;
01957     try
01958       {
01959         return s->getSignatureSize ();
01960       }
01961     catch (std::bad_alloc &)
01962       {
01963         s->mBadAlloc = true;
01964         return -1;
01965       }
01966   }
01967 
01968   static SIGNDOC_Boolean SDCAPI
01969   getSigningCertificateC (const void *aClosure,
01970                           struct SIGNDOC_ByteArray *aOutput)
01971   {
01972     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
01973     s->mBadAlloc = false;
01974     try
01975       {
01976         std::vector<unsigned char> output;
01977         bool ok = s->getSigningCertificate (output);
01978         if (ok)
01979           assignByteArray (aOutput, output);
01980         return ok;
01981       }
01982     catch (std::bad_alloc &)
01983       {
01984         s->mBadAlloc = true;
01985         return SIGNDOC_FALSE;
01986       }
01987   }
01988 
01989   static int SDCAPI
01990   getCertificateCountC (const void *aClosure)
01991   {
01992     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
01993     s->mBadAlloc = false;
01994     try
01995       {
01996         return s->getCertificateCount ();
01997       }
01998     catch (std::bad_alloc &)
01999       {
02000         s->mBadAlloc = true;
02001         return 0;
02002       }
02003   }
02004 
02005   static SIGNDOC_Boolean SDCAPI
02006   getCertificateC (const void *aClosure, int aIndex,
02007                    struct SIGNDOC_ByteArray *aOutput)
02008   {
02009     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
02010     s->mBadAlloc = false;
02011     try
02012       {
02013         std::vector<unsigned char> output;
02014         bool ok = s->getCertificate (aIndex, output);
02015         if (ok)
02016           assignByteArray (aOutput, output);
02017         return ok;
02018       }
02019     catch (std::bad_alloc &)
02020       {
02021         s->mBadAlloc = true;
02022         return SIGNDOC_FALSE;
02023       }
02024   }
02025 
02026   static const char * SDCAPI
02027   getErrorMessageC (const void *aClosure)
02028   {
02029     const SignRSA *s = static_cast<const SignRSA*>(aClosure);
02030     if (s->mBadAlloc)
02031       return "out of memory";
02032     try
02033       {
02034         return s->getErrorMessage ();
02035       }
02036     catch (std::bad_alloc &)
02037       {
02038         s->mBadAlloc = true;
02039         return "out of memory";
02040       }
02041   }
02042 
02043   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
02044                                const std::vector<unsigned char> &aInput)
02045   {
02046     if (aInput.empty ())
02047       SIGNDOC_ByteArray_clear (aOutput);
02048     else
02049       {
02050         struct SIGNDOC_Exception *ex = NULL;
02051         SIGNDOC_ByteArray_set (&ex, aOutput,
02052                                &aInput[0], aInput.size ());
02053         if (ex != NULL) SignDoc_throw (ex);
02054       }
02055   }
02056 
02057 private:
02058   SIGNDOC_SignRSA *p;
02059   mutable bool mBadAlloc;
02060 };
02061 
02067 class SignECDSA
02068 {
02069 public:
02073   enum HashAlgorithm
02074   {
02078     ha_sha1 = 1,
02079 
02083     ha_sha256 = 2,
02084 
02088     ha_sha384 = 3,
02089 
02093     ha_sha512 = 4,
02094 
02098     ha_sha224 = 7
02099   };
02100 
02101 public:
02105   SignECDSA ()
02106     : p (NULL), mBadAlloc (false)
02107   {
02108     struct SIGNDOC_Exception *ex = NULL;
02109     p = SIGNDOC_SignECDSA_new (&ex, this, signC, getSignatureSizeC,
02110                                getSigningCertificateC,
02111                                getCertificateCountC, getCertificateC,
02112                                getErrorMessageC);
02113     if (ex != NULL) SignDoc_throw (ex);
02114   }
02115 
02121   virtual ~SignECDSA ()
02122   {
02123     SIGNDOC_SignECDSA_delete (p);
02124   }
02125 
02139   virtual bool sign (Source &aSource, HashAlgorithm aHashAlgorithm,
02140                      std::vector<unsigned char> &aOutput) = 0;
02141 
02149   virtual int getSignatureSize () = 0;
02150 
02161   virtual bool getSigningCertificate (std::vector<unsigned char> &aOutput) const = 0;
02162 
02168   virtual int getCertificateCount () const = 0;
02169 
02182   virtual bool getCertificate (int aIndex,
02183                                std::vector<unsigned char> &aOutput) const = 0;
02184 
02197   virtual const char *getErrorMessage () const = 0;
02198 
02203   SIGNDOC_SignECDSA *getImpl () { return p; }
02204 
02205 private:
02206   static SIGNDOC_Boolean SDCAPI
02207   signC (void *aClosure, struct SIGNDOC_Source *aSource, int aHashAlgorithm,
02208          struct SIGNDOC_ByteArray *aOutput)
02209   {
02210     SignECDSA *s = static_cast<SignECDSA*>(aClosure);
02211     s->mBadAlloc = false;
02212     try
02213       {
02214         std::vector<unsigned char> output;
02215         Source src (aSource);
02216         bool ok = s->sign (src, (HashAlgorithm)aHashAlgorithm, output);
02217         if (ok)
02218           assignByteArray (aOutput, output);
02219         return ok;
02220       }
02221     catch (std::bad_alloc &)
02222       {
02223         s->mBadAlloc = true;
02224         return SIGNDOC_FALSE;
02225       }
02226   }
02227 
02228   static int SDCAPI
02229   getSignatureSizeC (void *aClosure)
02230   {
02231     SignECDSA *s = static_cast<SignECDSA*>(aClosure);
02232     s->mBadAlloc = false;
02233     try
02234       {
02235         return s->getSignatureSize ();
02236       }
02237     catch (std::bad_alloc &)
02238       {
02239         s->mBadAlloc = true;
02240         return -1;
02241       }
02242   }
02243 
02244   static SIGNDOC_Boolean SDCAPI
02245   getSigningCertificateC (const void *aClosure,
02246                           struct SIGNDOC_ByteArray *aOutput)
02247   {
02248     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02249     s->mBadAlloc = false;
02250     try
02251       {
02252         std::vector<unsigned char> output;
02253         bool ok = s->getSigningCertificate (output);
02254         if (ok)
02255           assignByteArray (aOutput, output);
02256         return ok;
02257       }
02258     catch (std::bad_alloc &)
02259       {
02260         s->mBadAlloc = true;
02261         return SIGNDOC_FALSE;
02262       }
02263   }
02264 
02265   static int SDCAPI
02266   getCertificateCountC (const void *aClosure)
02267   {
02268     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02269     s->mBadAlloc = false;
02270     try
02271       {
02272         return s->getCertificateCount ();
02273       }
02274     catch (std::bad_alloc &)
02275       {
02276         s->mBadAlloc = true;
02277         return 0;
02278       }
02279   }
02280 
02281   static SIGNDOC_Boolean SDCAPI
02282   getCertificateC (const void *aClosure, int aIndex,
02283                    struct SIGNDOC_ByteArray *aOutput)
02284   {
02285     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02286     s->mBadAlloc = false;
02287     try
02288       {
02289         std::vector<unsigned char> output;
02290         bool ok = s->getCertificate (aIndex, output);
02291         if (ok)
02292           assignByteArray (aOutput, output);
02293         return ok;
02294       }
02295     catch (std::bad_alloc &)
02296       {
02297         s->mBadAlloc = true;
02298         return SIGNDOC_FALSE;
02299       }
02300   }
02301 
02302   static const char * SDCAPI
02303   getErrorMessageC (const void *aClosure)
02304   {
02305     const SignECDSA *s = static_cast<const SignECDSA*>(aClosure);
02306     if (s->mBadAlloc)
02307       return "out of memory";
02308     try
02309       {
02310         return s->getErrorMessage ();
02311       }
02312     catch (std::bad_alloc &)
02313       {
02314         s->mBadAlloc = true;
02315         return "out of memory";
02316       }
02317   }
02318 
02319   static void assignByteArray (SIGNDOC_ByteArray *aOutput,
02320                                const std::vector<unsigned char> &aInput)
02321   {
02322     if (aInput.empty ())
02323       SIGNDOC_ByteArray_clear (aOutput);
02324     else
02325       {
02326         struct SIGNDOC_Exception *ex = NULL;
02327         SIGNDOC_ByteArray_set (&ex, aOutput,
02328                                &aInput[0], aInput.size ());
02329         if (ex != NULL) SignDoc_throw (ex);
02330       }
02331   }
02332 
02333 private:
02334   SIGNDOC_SignECDSA *p;
02335   mutable bool mBadAlloc;
02336 };
02337 
02346 class SignDocColor 
02347 {
02348 public:
02349   enum Type
02350   {
02354     t_gray,
02355 
02359     t_rgb
02360   };
02361 
02362 public:
02366   ~SignDocColor ()
02367   {
02368     SIGNDOC_Color_delete (p);
02369   }
02370 
02376   SignDocColor *clone () const
02377   {
02378     SIGNDOC_Exception *ex = NULL;
02379     SIGNDOC_Color *r;
02380     r = SIGNDOC_Color_clone (&ex, p);
02381     if (ex != NULL) SignDoc_throw (ex);
02382     if (r == NULL)
02383       return NULL;
02384     try
02385       {
02386         return new SignDocColor (r);
02387       }
02388     catch (...)
02389       {
02390         SIGNDOC_Color_delete (r);
02391         throw;
02392       }
02393   }
02394 
02400   Type getType () const
02401   {
02402     return (Type)SIGNDOC_Color_getType (p);
02403   }
02404 
02410   unsigned getNumberOfComponents () const
02411   {
02412     return SIGNDOC_Color_getNumberOfComponents (p);
02413   }
02414 
02424   unsigned char getComponent (unsigned aIndex) const
02425   {
02426     return SIGNDOC_Color_getComponent (p, aIndex);
02427   }
02428 
02435   unsigned char getIntensity () const
02436   {
02437     return SIGNDOC_Color_getIntensity (p);
02438   }
02439 
02446   unsigned char getRed () const
02447   {
02448     return SIGNDOC_Color_getRed (p);
02449   }
02450 
02457   unsigned char getGreen () const
02458   {
02459     return SIGNDOC_Color_getGreen (p);
02460   }
02461 
02468   unsigned char getBlue () const
02469   {
02470     return SIGNDOC_Color_getBlue (p);
02471   }
02472 
02481   static SignDocColor *createGray (unsigned char aIntensity)
02482   {
02483     SIGNDOC_Exception *ex = NULL;
02484     SIGNDOC_Color *r;
02485     r = SIGNDOC_Color_createGray (&ex, aIntensity);
02486     if (ex != NULL) SignDoc_throw (ex);
02487     if (r == NULL)
02488       return NULL;
02489     try
02490       {
02491         return new SignDocColor (r);
02492       }
02493     catch (...)
02494       {
02495         SIGNDOC_Color_delete (r);
02496         throw;
02497       }
02498   }
02499 
02512   static SignDocColor *createRGB (unsigned char aRed, unsigned char aGreen,
02513                                   unsigned char aBlue)
02514   {
02515     SIGNDOC_Exception *ex = NULL;
02516     SIGNDOC_Color *r;
02517     r = SIGNDOC_Color_createRGB (&ex, aRed, aGreen, aBlue);
02518     if (ex != NULL) SignDoc_throw (ex);
02519     if (r == NULL)
02520       return NULL;
02521     try
02522       {
02523         return new SignDocColor (r);
02524       }
02525     catch (...)
02526       {
02527         SIGNDOC_Color_delete (r);
02528         throw;
02529       }
02530   }
02531 
02532 private:
02538   SignDocColor ();
02539 
02545   // cppcheck-suppress noExplicitCopyMoveConstructor
02546   SignDocColor (const SignDocColor &);
02547 
02553   SignDocColor &operator= (const SignDocColor &);
02554 
02555 public:
02560   SignDocColor (SIGNDOC_Color *aP) : p (aP) { }
02561 
02566   SIGNDOC_Color *getImpl () { return p; }
02567 
02572   const SIGNDOC_Color *getImpl () const { return p; }
02573 
02578   void setImpl (SIGNDOC_Color *aP) { SIGNDOC_Color_delete (p); p  = aP; }
02579 
02580 private:
02581   SIGNDOC_Color *p;
02582 };
02583 
02598 class SignDocTextFieldAttributes 
02599 {
02600 public:
02601 
02602 public:
02606   SignDocTextFieldAttributes ()
02607     : p (NULL)
02608   {
02609     SIGNDOC_Exception *ex = NULL;
02610     p = SIGNDOC_TextFieldAttributes_new (&ex);
02611     if (ex != NULL) SignDoc_throw (ex);
02612   }
02613 
02619   SignDocTextFieldAttributes (const SignDocTextFieldAttributes &aSource)
02620     : p (NULL)
02621   {
02622     SIGNDOC_Exception *ex = NULL;
02623     p = SIGNDOC_TextFieldAttributes_clone (&ex, aSource.getImpl ());
02624     if (ex != NULL) SignDoc_throw (ex);
02625   }
02626 
02630   ~SignDocTextFieldAttributes ()
02631   {
02632     SIGNDOC_TextFieldAttributes_delete (p);
02633   }
02634 
02640   SignDocTextFieldAttributes &operator= (const SignDocTextFieldAttributes &aSource)
02641   {
02642     SIGNDOC_Exception *ex = NULL;
02643     SIGNDOC_TextFieldAttributes_assign (&ex, p, aSource.getImpl ());
02644     if (ex != NULL) SignDoc_throw (ex);
02645     return *this;
02646   }
02647 
02653   void swap (SignDocTextFieldAttributes &aOther)
02654   {
02655     std::swap (p, aOther.p);
02656   }
02657 
02673   bool isSet () const
02674   {
02675     SIGNDOC_Exception *ex = NULL;
02676     bool r;
02677     r = (bool)SIGNDOC_TextFieldAttributes_isSet (&ex, p);
02678     if (ex != NULL) SignDoc_throw (ex);
02679     return r;
02680   }
02681 
02693   bool isValid () const
02694   {
02695     SIGNDOC_Exception *ex = NULL;
02696     bool r;
02697     r = (bool)SIGNDOC_TextFieldAttributes_isValid (&ex, p);
02698     if (ex != NULL) SignDoc_throw (ex);
02699     return r;
02700   }
02701 
02707   void clear ()
02708   {
02709     SIGNDOC_Exception *ex = NULL;
02710     SIGNDOC_TextFieldAttributes_clear (&ex, p);
02711     if (ex != NULL) SignDoc_throw (ex);
02712   }
02713 
02725   std::string getFontName (Encoding aEncoding) const
02726   {
02727     SIGNDOC_Exception *ex = NULL;
02728     std::string r;
02729     char *s = SIGNDOC_TextFieldAttributes_getFontName (&ex, p, aEncoding);
02730     if (ex != NULL) SignDoc_throw (ex);
02731     try
02732       {
02733         r = s;
02734       }
02735     catch (...)
02736       {
02737         SIGNDOC_free (s);
02738         throw;
02739       }
02740     SIGNDOC_free (s);
02741     return r;
02742   }
02743 
02762   void setFontName (Encoding aEncoding, const std::string &aFontName)
02763   {
02764     SIGNDOC_Exception *ex = NULL;
02765     SIGNDOC_TextFieldAttributes_setFontName (&ex, p, aEncoding, aFontName.c_str ());
02766     if (ex != NULL) SignDoc_throw (ex);
02767   }
02768 
02782   std::string getFontResourceName (Encoding aEncoding) const
02783   {
02784     SIGNDOC_Exception *ex = NULL;
02785     std::string r;
02786     char *s = SIGNDOC_TextFieldAttributes_getFontResourceName (&ex, p, aEncoding);
02787     if (ex != NULL) SignDoc_throw (ex);
02788     try
02789       {
02790         r = s;
02791       }
02792     catch (...)
02793       {
02794         SIGNDOC_free (s);
02795         throw;
02796       }
02797     SIGNDOC_free (s);
02798     return r;
02799   }
02800 
02812   double getFontSize () const
02813   {
02814     SIGNDOC_Exception *ex = NULL;
02815     double r;
02816     r = SIGNDOC_TextFieldAttributes_getFontSize (&ex, p);
02817     if (ex != NULL) SignDoc_throw (ex);
02818     return r;
02819   }
02820 
02834   void setFontSize (double aFontSize)
02835   {
02836     SIGNDOC_Exception *ex = NULL;
02837     SIGNDOC_TextFieldAttributes_setFontSize (&ex, p, aFontSize);
02838     if (ex != NULL) SignDoc_throw (ex);
02839   }
02840 
02852   SignDocColor *getTextColor () const
02853   {
02854     SIGNDOC_Exception *ex = NULL;
02855     SIGNDOC_Color *r;
02856     r = SIGNDOC_TextFieldAttributes_getTextColor (&ex, p);
02857     if (ex != NULL) SignDoc_throw (ex);
02858     if (r == NULL)
02859       return NULL;
02860     try
02861       {
02862         return new SignDocColor (r);
02863       }
02864     catch (...)
02865       {
02866         SIGNDOC_Color_delete (r);
02867         throw;
02868       }
02869   }
02870 
02876   void setTextColor (const SignDocColor &aTextColor)
02877   {
02878     SIGNDOC_Exception *ex = NULL;
02879     SIGNDOC_TextFieldAttributes_setTextColor (&ex, p, aTextColor.getImpl ());
02880     if (ex != NULL) SignDoc_throw (ex);
02881   }
02882 
02898   std::string getRest (Encoding aEncoding) const
02899   {
02900     SIGNDOC_Exception *ex = NULL;
02901     std::string r;
02902     char *s = SIGNDOC_TextFieldAttributes_getRest (&ex, p, aEncoding);
02903     if (ex != NULL) SignDoc_throw (ex);
02904     try
02905       {
02906         r = s;
02907       }
02908     catch (...)
02909       {
02910         SIGNDOC_free (s);
02911         throw;
02912       }
02913     SIGNDOC_free (s);
02914     return r;
02915   }
02916 
02926   void setRest (Encoding aEncoding, const std::string &aInput)
02927   {
02928     SIGNDOC_Exception *ex = NULL;
02929     SIGNDOC_TextFieldAttributes_setRest (&ex, p, aEncoding, aInput.c_str ());
02930     if (ex != NULL) SignDoc_throw (ex);
02931   }
02932 
02933 private:
02934 public:
02939   SignDocTextFieldAttributes (SIGNDOC_TextFieldAttributes *aP) : p (aP) { }
02940 
02945   SIGNDOC_TextFieldAttributes *getImpl () { return p; }
02946 
02951   const SIGNDOC_TextFieldAttributes *getImpl () const { return p; }
02952 
02957   void setImpl (SIGNDOC_TextFieldAttributes *aP) { SIGNDOC_TextFieldAttributes_delete (p); p  = aP; }
02958 
02959 private:
02960   SIGNDOC_TextFieldAttributes *p;
02961 };
02962 
03286 class SignDocField 
03287 {
03288 public:
03289 
03290 public:
03296   enum Type
03297   {
03298     t_unknown,              
03299     t_pushbutton,           
03300     t_check_box,            
03301     t_radio_button,         
03302     t_text,                 
03303     t_list_box,             
03304     t_signature_digsig,     
03305     t_signature_signdoc,    
03306     t_combo_box             
03307   };
03308 
03358   enum Flag
03359   {
03360     f_ReadOnly          = 1 << 0,  
03361     f_Required          = 1 << 1,  
03362     f_NoExport          = 1 << 2,  
03363     f_NoToggleToOff     = 1 << 3,  
03364     f_Radio             = 1 << 4,  
03365     f_Pushbutton        = 1 << 5,  
03366     f_RadiosInUnison    = 1 << 6,  
03367 
03377     f_MultiLine         = 1 << 7,
03378 
03379     f_Password          = 1 << 8,  
03380     f_FileSelect        = 1 << 9,  
03381     f_DoNotSpellCheck   = 1 << 10, 
03382     f_DoNotScroll       = 1 << 11, 
03383     f_Comb              = 1 << 12, 
03384     f_RichText          = 1 << 13, 
03385     f_Combo             = 1 << 14, 
03386     f_Edit              = 1 << 15, 
03387     f_Sort              = 1 << 16, 
03388     f_MultiSelect       = 1 << 17, 
03389     f_CommitOnSelChange = 1 << 18, 
03390     f_SinglePage        = 1 << 28, 
03391     f_EnableAddAfterSigning = 1 << 29, 
03392     f_Invisible         = 1 << 30  
03393   };
03394 
03404   enum WidgetFlag
03405   {
03406     wf_Invisible      = 1 << (1 - 1), 
03407     wf_Hidden         = 1 << (2 - 1), 
03408     wf_Print          = 1 << (3 - 1), 
03409     wf_NoZoom         = 1 << (4 - 1), 
03410     wf_NoRotate       = 1 << (5 - 1), 
03411     wf_NoView         = 1 << (6 - 1), 
03412     wf_ReadOnly       = 1 << (7 - 1), 
03413     wf_Locked         = 1 << (8 - 1), 
03414     wf_ToggleNoView   = 1 << (9 - 1), 
03415     wf_LockedContents = 1 << (10 - 1) 
03416   };
03417 
03423   enum Justification
03424   {
03425     j_none,             
03426     j_left,             
03427     j_center,           
03428     j_right             
03429   };
03430 
03436   enum BorderStyle
03437   {
03438     bos_other,                  
03439     bos_solid,                  
03440     bos_dashed,                 
03441     bos_beveled,                
03442     bos_inset,                  
03443     bos_underline               
03444   };
03445 
03451   enum ButtonStyle
03452   {
03453     bus_default,        
03454     bus_other,          
03455     bus_check_mark,     
03456     bus_cross,          
03457     bus_star,           
03458     bus_circle,         
03459     bus_square,         
03460     bus_diamond         
03461   };
03462 
03468   enum LockType
03469   {
03470     lt_na,              
03471     lt_none,            
03472     lt_all,             
03473     lt_include,         
03474     lt_exclude          
03475   };
03476 
03480   enum SignatureType
03481   {
03482     st_not_a_signature_field,  
03483     st_not_signed,             
03484     st_approval,               
03485     st_certification,          
03486     st_document_time_stamp     
03487   };
03488 
03494   enum CertSeedValueFlag
03495   {
03496     csvf_SubjectCert = 0x01,    
03497     csvf_IssuerCert  = 0x02,    
03498     csvf_Policy      = 0x04,    
03499     csvf_SubjectDN   = 0x08,    
03500     csvf_KeyUsage    = 0x20,    
03501     csvf_URL         = 0x40     
03502   };
03503 
03504 public:
03510   SignDocField ()
03511     : p (NULL)
03512   {
03513     SIGNDOC_Exception *ex = NULL;
03514     p = SIGNDOC_Field_new (&ex);
03515     if (ex != NULL) SignDoc_throw (ex);
03516   }
03517 
03523   SignDocField (const SignDocField &aSource)
03524     : p (NULL)
03525   {
03526     SIGNDOC_Exception *ex = NULL;
03527     p = SIGNDOC_Field_clone (&ex, aSource.getImpl ());
03528     if (ex != NULL) SignDoc_throw (ex);
03529   }
03530 
03534   ~SignDocField ()
03535   {
03536     SIGNDOC_Field_delete (p);
03537   }
03538 
03544   SignDocField &operator= (const SignDocField &aSource)
03545   {
03546     SIGNDOC_Exception *ex = NULL;
03547     SIGNDOC_Field_assign (&ex, p, aSource.getImpl ());
03548     if (ex != NULL) SignDoc_throw (ex);
03549     return *this;
03550   }
03551 
03557   void swap (SignDocField &aOther)
03558   {
03559     std::swap (p, aOther.p);
03560   }
03561 
03574   std::string getName (Encoding aEncoding) const
03575   {
03576     SIGNDOC_Exception *ex = NULL;
03577     std::string r;
03578     char *s = SIGNDOC_Field_getName (&ex, p, aEncoding);
03579     if (ex != NULL) SignDoc_throw (ex);
03580     try
03581       {
03582         r = s;
03583       }
03584     catch (...)
03585       {
03586         SIGNDOC_free (s);
03587         throw;
03588       }
03589     SIGNDOC_free (s);
03590     return r;
03591   }
03592 
03599   const char *getNameUTF8 () const
03600   {
03601     SIGNDOC_Exception *ex = NULL;
03602     const char *r;
03603     r = SIGNDOC_Field_getNameUTF8 (&ex, p);
03604     if (ex != NULL) SignDoc_throw (ex);
03605     return r;
03606   }
03607 
03629   void setName (Encoding aEncoding, const std::string &aName)
03630   {
03631     SIGNDOC_Exception *ex = NULL;
03632     SIGNDOC_Field_setName (&ex, p, aEncoding, aName.c_str ());
03633     if (ex != NULL) SignDoc_throw (ex);
03634   }
03635 
03652   void setName (const wchar_t *aName)
03653   {
03654     SIGNDOC_Exception *ex = NULL;
03655     SIGNDOC_Field_setNameW (&ex, p, aName);
03656     if (ex != NULL) SignDoc_throw (ex);
03657   }
03658 
03676   std::string getAlternateName (Encoding aEncoding) const
03677   {
03678     SIGNDOC_Exception *ex = NULL;
03679     std::string r;
03680     char *s = SIGNDOC_Field_getAlternateName (&ex, p, aEncoding);
03681     if (ex != NULL) SignDoc_throw (ex);
03682     try
03683       {
03684         r = s;
03685       }
03686     catch (...)
03687       {
03688         SIGNDOC_free (s);
03689         throw;
03690       }
03691     SIGNDOC_free (s);
03692     return r;
03693   }
03694 
03712   void setAlternateName (Encoding aEncoding, const std::string &aName)
03713   {
03714     SIGNDOC_Exception *ex = NULL;
03715     SIGNDOC_Field_setAlternateName (&ex, p, aEncoding, aName.c_str ());
03716     if (ex != NULL) SignDoc_throw (ex);
03717   }
03718 
03735   std::string getMappingName (Encoding aEncoding) const
03736   {
03737     SIGNDOC_Exception *ex = NULL;
03738     std::string r;
03739     char *s = SIGNDOC_Field_getMappingName (&ex, p, aEncoding);
03740     if (ex != NULL) SignDoc_throw (ex);
03741     try
03742       {
03743         r = s;
03744       }
03745     catch (...)
03746       {
03747         SIGNDOC_free (s);
03748         throw;
03749       }
03750     SIGNDOC_free (s);
03751     return r;
03752   }
03753 
03770   void setMappingName (Encoding aEncoding, const std::string &aName)
03771   {
03772     SIGNDOC_Exception *ex = NULL;
03773     SIGNDOC_Field_setMappingName (&ex, p, aEncoding, aName.c_str ());
03774     if (ex != NULL) SignDoc_throw (ex);
03775   }
03776 
03788   int getValueCount () const
03789   {
03790     SIGNDOC_Exception *ex = NULL;
03791     int r;
03792     r = SIGNDOC_Field_getValueCount (&ex, p);
03793     if (ex != NULL) SignDoc_throw (ex);
03794     return r;
03795   }
03796 
03817   std::string getValue (Encoding aEncoding, int aIndex) const
03818   {
03819     SIGNDOC_Exception *ex = NULL;
03820     std::string r;
03821     char *s = SIGNDOC_Field_getValue (&ex, p, aEncoding, aIndex);
03822     if (ex != NULL) SignDoc_throw (ex);
03823     try
03824       {
03825         r = s;
03826       }
03827     catch (...)
03828       {
03829         SIGNDOC_free (s);
03830         throw;
03831       }
03832     SIGNDOC_free (s);
03833     return r;
03834   }
03835 
03854   const char *getValueUTF8 (int aIndex) const
03855   {
03856     SIGNDOC_Exception *ex = NULL;
03857     const char *r;
03858     r = SIGNDOC_Field_getValueUTF8 (&ex, p, aIndex);
03859     if (ex != NULL) SignDoc_throw (ex);
03860     return r;
03861   }
03862 
03871   void clearValues ()
03872   {
03873     SIGNDOC_Exception *ex = NULL;
03874     SIGNDOC_Field_clearValues (&ex, p);
03875     if (ex != NULL) SignDoc_throw (ex);
03876   }
03877 
03902   void addValue (Encoding aEncoding, const std::string &aValue)
03903   {
03904     SIGNDOC_Exception *ex = NULL;
03905     SIGNDOC_Field_addValue (&ex, p, aEncoding, aValue.c_str ());
03906     if (ex != NULL) SignDoc_throw (ex);
03907   }
03908 
03937   bool setValue (int aIndex, Encoding aEncoding, const std::string &aValue)
03938   {
03939     SIGNDOC_Exception *ex = NULL;
03940     bool r;
03941     r = (bool)SIGNDOC_Field_setValueByIndex (&ex, p, aIndex, aEncoding, aValue.c_str ());
03942     if (ex != NULL) SignDoc_throw (ex);
03943     return r;
03944   }
03945 
03973   void setValue (Encoding aEncoding, const std::string &aValue)
03974   {
03975     SIGNDOC_Exception *ex = NULL;
03976     SIGNDOC_Field_setValue (&ex, p, aEncoding, aValue.c_str ());
03977     if (ex != NULL) SignDoc_throw (ex);
03978   }
03979 
03991   bool removeValue (int aIndex)
03992   {
03993     SIGNDOC_Exception *ex = NULL;
03994     bool r;
03995     r = (bool)SIGNDOC_Field_removeValue (&ex, p, aIndex);
03996     if (ex != NULL) SignDoc_throw (ex);
03997     return r;
03998   }
03999 
04027   int getValueIndex () const
04028   {
04029     SIGNDOC_Exception *ex = NULL;
04030     int r;
04031     r = SIGNDOC_Field_getValueIndex (&ex, p);
04032     if (ex != NULL) SignDoc_throw (ex);
04033     return r;
04034   }
04035 
04088   void setValueIndex (int aIndex)
04089   {
04090     SIGNDOC_Exception *ex = NULL;
04091     SIGNDOC_Field_setValueIndex (&ex, p, aIndex);
04092     if (ex != NULL) SignDoc_throw (ex);
04093   }
04094 
04116   bool clickButton (int aIndex)
04117   {
04118     SIGNDOC_Exception *ex = NULL;
04119     bool r;
04120     r = (bool)SIGNDOC_Field_clickButton (&ex, p, aIndex);
04121     if (ex != NULL) SignDoc_throw (ex);
04122     return r;
04123   }
04124 
04136   int getChoiceCount () const
04137   {
04138     SIGNDOC_Exception *ex = NULL;
04139     int r;
04140     r = SIGNDOC_Field_getChoiceCount (&ex, p);
04141     if (ex != NULL) SignDoc_throw (ex);
04142     return r;
04143   }
04144 
04168   std::string getChoiceValue (Encoding aEncoding, int aIndex) const
04169   {
04170     SIGNDOC_Exception *ex = NULL;
04171     std::string r;
04172     char *s = SIGNDOC_Field_getChoiceValue (&ex, p, aEncoding, aIndex);
04173     if (ex != NULL) SignDoc_throw (ex);
04174     try
04175       {
04176         r = s;
04177       }
04178     catch (...)
04179       {
04180         SIGNDOC_free (s);
04181         throw;
04182       }
04183     SIGNDOC_free (s);
04184     return r;
04185   }
04186 
04209   const char *getChoiceValueUTF8 (int aIndex) const
04210   {
04211     SIGNDOC_Exception *ex = NULL;
04212     const char *r;
04213     r = SIGNDOC_Field_getChoiceValueUTF8 (&ex, p, aIndex);
04214     if (ex != NULL) SignDoc_throw (ex);
04215     return r;
04216   }
04217 
04241   std::string getChoiceExport (Encoding aEncoding, int aIndex) const
04242   {
04243     SIGNDOC_Exception *ex = NULL;
04244     std::string r;
04245     char *s = SIGNDOC_Field_getChoiceExport (&ex, p, aEncoding, aIndex);
04246     if (ex != NULL) SignDoc_throw (ex);
04247     try
04248       {
04249         r = s;
04250       }
04251     catch (...)
04252       {
04253         SIGNDOC_free (s);
04254         throw;
04255       }
04256     SIGNDOC_free (s);
04257     return r;
04258   }
04259 
04282   const char *getChoiceExportUTF8 (int aIndex) const
04283   {
04284     SIGNDOC_Exception *ex = NULL;
04285     const char *r;
04286     r = SIGNDOC_Field_getChoiceExportUTF8 (&ex, p, aIndex);
04287     if (ex != NULL) SignDoc_throw (ex);
04288     return r;
04289   }
04290 
04298   void clearChoices ()
04299   {
04300     SIGNDOC_Exception *ex = NULL;
04301     SIGNDOC_Field_clearChoices (&ex, p);
04302     if (ex != NULL) SignDoc_throw (ex);
04303   }
04304 
04323   void addChoice (Encoding aEncoding, const std::string &aValue)
04324   {
04325     SIGNDOC_Exception *ex = NULL;
04326     SIGNDOC_Field_addChoice (&ex, p, aEncoding, aValue.c_str ());
04327     if (ex != NULL) SignDoc_throw (ex);
04328   }
04329 
04347   void addChoice (Encoding aEncoding, const std::string &aValue,
04348                   const std::string &aExport)
04349   {
04350     SIGNDOC_Exception *ex = NULL;
04351     SIGNDOC_Field_addChoiceWithExport (&ex, p, aEncoding, aValue.c_str (), aExport.c_str ());
04352     if (ex != NULL) SignDoc_throw (ex);
04353   }
04354 
04378   bool setChoice (int aIndex, Encoding aEncoding, const std::string &aValue)
04379   {
04380     SIGNDOC_Exception *ex = NULL;
04381     bool r;
04382     r = (bool)SIGNDOC_Field_setChoice (&ex, p, aIndex, aEncoding, aValue.c_str ());
04383     if (ex != NULL) SignDoc_throw (ex);
04384     return r;
04385   }
04386 
04409   bool setChoice (int aIndex, Encoding aEncoding, const std::string &aValue,
04410                   const std::string &aExport)
04411   {
04412     SIGNDOC_Exception *ex = NULL;
04413     bool r;
04414     r = (bool)SIGNDOC_Field_setChoiceWithExport (&ex, p, aIndex, aEncoding, aValue.c_str (), aExport.c_str ());
04415     if (ex != NULL) SignDoc_throw (ex);
04416     return r;
04417   }
04418 
04428   bool removeChoice (int aIndex)
04429   {
04430     SIGNDOC_Exception *ex = NULL;
04431     bool r;
04432     r = (bool)SIGNDOC_Field_removeChoice (&ex, p, aIndex);
04433     if (ex != NULL) SignDoc_throw (ex);
04434     return r;
04435   }
04436 
04446   Type getType () const
04447   {
04448     SIGNDOC_Exception *ex = NULL;
04449     Type r;
04450     r = (Type)SIGNDOC_Field_getType (&ex, p);
04451     if (ex != NULL) SignDoc_throw (ex);
04452     return r;
04453   }
04454 
04466   void setType (Type aType)
04467   {
04468     SIGNDOC_Exception *ex = NULL;
04469     SIGNDOC_Field_setType (&ex, p, aType);
04470     if (ex != NULL) SignDoc_throw (ex);
04471   }
04472 
04487   int getFlags () const
04488   {
04489     SIGNDOC_Exception *ex = NULL;
04490     int r;
04491     r = SIGNDOC_Field_getFlags (&ex, p);
04492     if (ex != NULL) SignDoc_throw (ex);
04493     return r;
04494   }
04495 
04506   void setFlags (int aFlags)
04507   {
04508     SIGNDOC_Exception *ex = NULL;
04509     SIGNDOC_Field_setFlags (&ex, p, aFlags);
04510     if (ex != NULL) SignDoc_throw (ex);
04511   }
04512 
04525   SignatureType getSignatureType () const
04526   {
04527     SIGNDOC_Exception *ex = NULL;
04528     SignatureType r;
04529     r = (SignatureType)SIGNDOC_Field_getSignatureType (&ex, p);
04530     if (ex != NULL) SignDoc_throw (ex);
04531     return r;
04532   }
04533 
04553   int getDocMDP () const
04554   {
04555     SIGNDOC_Exception *ex = NULL;
04556     int r;
04557     r = SIGNDOC_Field_getDocMDP (&ex, p);
04558     if (ex != NULL) SignDoc_throw (ex);
04559     return r;
04560   }
04561 
04575   bool isSigned () const
04576   {
04577     SIGNDOC_Exception *ex = NULL;
04578     bool r;
04579     r = (bool)SIGNDOC_Field_isSigned (&ex, p);
04580     if (ex != NULL) SignDoc_throw (ex);
04581     return r;
04582   }
04583 
04601   bool isCurrentlyClearable () const
04602   {
04603     SIGNDOC_Exception *ex = NULL;
04604     bool r;
04605     r = (bool)SIGNDOC_Field_isCurrentlyClearable (&ex, p);
04606     if (ex != NULL) SignDoc_throw (ex);
04607     return r;
04608   }
04609 
04621   int getMaxLen () const
04622   {
04623     SIGNDOC_Exception *ex = NULL;
04624     int r;
04625     r = SIGNDOC_Field_getMaxLen (&ex, p);
04626     if (ex != NULL) SignDoc_throw (ex);
04627     return r;
04628   }
04629 
04638   void setMaxLen (int aMaxLen)
04639   {
04640     SIGNDOC_Exception *ex = NULL;
04641     SIGNDOC_Field_setMaxLen (&ex, p, aMaxLen);
04642     if (ex != NULL) SignDoc_throw (ex);
04643   }
04644 
04656   int getTopIndex () const
04657   {
04658     SIGNDOC_Exception *ex = NULL;
04659     int r;
04660     r = SIGNDOC_Field_getTopIndex (&ex, p);
04661     if (ex != NULL) SignDoc_throw (ex);
04662     return r;
04663   }
04664 
04676   void setTopIndex (int aTopIndex)
04677   {
04678     SIGNDOC_Exception *ex = NULL;
04679     SIGNDOC_Field_setTopIndex (&ex, p, aTopIndex);
04680     if (ex != NULL) SignDoc_throw (ex);
04681   }
04682 
04695   int getWidget () const
04696   {
04697     SIGNDOC_Exception *ex = NULL;
04698     int r;
04699     r = SIGNDOC_Field_getWidget (&ex, p);
04700     if (ex != NULL) SignDoc_throw (ex);
04701     return r;
04702   }
04703 
04714   int getWidgetCount () const
04715   {
04716     SIGNDOC_Exception *ex = NULL;
04717     int r;
04718     r = SIGNDOC_Field_getWidgetCount (&ex, p);
04719     if (ex != NULL) SignDoc_throw (ex);
04720     return r;
04721   }
04722 
04742   bool selectWidget (int aIndex)
04743   {
04744     SIGNDOC_Exception *ex = NULL;
04745     bool r;
04746     r = (bool)SIGNDOC_Field_selectWidget (&ex, p, aIndex);
04747     if (ex != NULL) SignDoc_throw (ex);
04748     return r;
04749   }
04750 
04766   bool addWidget ()
04767   {
04768     SIGNDOC_Exception *ex = NULL;
04769     bool r;
04770     r = (bool)SIGNDOC_Field_addWidget (&ex, p);
04771     if (ex != NULL) SignDoc_throw (ex);
04772     return r;
04773   }
04774 
04795   bool insertWidget (int aIndex)
04796   {
04797     SIGNDOC_Exception *ex = NULL;
04798     bool r;
04799     r = (bool)SIGNDOC_Field_insertWidget (&ex, p, aIndex);
04800     if (ex != NULL) SignDoc_throw (ex);
04801     return r;
04802   }
04803 
04829   bool removeWidget (int aIndex)
04830   {
04831     SIGNDOC_Exception *ex = NULL;
04832     bool r;
04833     r = (bool)SIGNDOC_Field_removeWidget (&ex, p, aIndex);
04834     if (ex != NULL) SignDoc_throw (ex);
04835     return r;
04836   }
04837 
04850   int getWidgetFlags () const
04851   {
04852     SIGNDOC_Exception *ex = NULL;
04853     int r;
04854     r = SIGNDOC_Field_getWidgetFlags (&ex, p);
04855     if (ex != NULL) SignDoc_throw (ex);
04856     return r;
04857   }
04858 
04871   void setWidgetFlags (int aFlags)
04872   {
04873     SIGNDOC_Exception *ex = NULL;
04874     SIGNDOC_Field_setWidgetFlags (&ex, p, aFlags);
04875     if (ex != NULL) SignDoc_throw (ex);
04876   }
04877 
04889   int getPage () const
04890   {
04891     SIGNDOC_Exception *ex = NULL;
04892     int r;
04893     r = SIGNDOC_Field_getPage (&ex, p);
04894     if (ex != NULL) SignDoc_throw (ex);
04895     return r;
04896   }
04897 
04914   void setPage (int aPage)
04915   {
04916     SIGNDOC_Exception *ex = NULL;
04917     SIGNDOC_Field_setPage (&ex, p, aPage);
04918     if (ex != NULL) SignDoc_throw (ex);
04919   }
04920 
04931   double getLeft () const
04932   {
04933     SIGNDOC_Exception *ex = NULL;
04934     double r;
04935     r = SIGNDOC_Field_getLeft (&ex, p);
04936     if (ex != NULL) SignDoc_throw (ex);
04937     return r;
04938   }
04939 
04950   void setLeft (double aLeft)
04951   {
04952     SIGNDOC_Exception *ex = NULL;
04953     SIGNDOC_Field_setLeft (&ex, p, aLeft);
04954     if (ex != NULL) SignDoc_throw (ex);
04955   }
04956 
04967   double getBottom () const
04968   {
04969     SIGNDOC_Exception *ex = NULL;
04970     double r;
04971     r = SIGNDOC_Field_getBottom (&ex, p);
04972     if (ex != NULL) SignDoc_throw (ex);
04973     return r;
04974   }
04975 
04986   void setBottom (double aBottom)
04987   {
04988     SIGNDOC_Exception *ex = NULL;
04989     SIGNDOC_Field_setBottom (&ex, p, aBottom);
04990     if (ex != NULL) SignDoc_throw (ex);
04991   }
04992 
05005   double getRight () const
05006   {
05007     SIGNDOC_Exception *ex = NULL;
05008     double r;
05009     r = SIGNDOC_Field_getRight (&ex, p);
05010     if (ex != NULL) SignDoc_throw (ex);
05011     return r;
05012   }
05013 
05026   void setRight (double aRight)
05027   {
05028     SIGNDOC_Exception *ex = NULL;
05029     SIGNDOC_Field_setRight (&ex, p, aRight);
05030     if (ex != NULL) SignDoc_throw (ex);
05031   }
05032 
05045   double getTop () const
05046   {
05047     SIGNDOC_Exception *ex = NULL;
05048     double r;
05049     r = SIGNDOC_Field_getTop (&ex, p);
05050     if (ex != NULL) SignDoc_throw (ex);
05051     return r;
05052   }
05053 
05066   void setTop (double aTop)
05067   {
05068     SIGNDOC_Exception *ex = NULL;
05069     SIGNDOC_Field_setTop (&ex, p, aTop);
05070     if (ex != NULL) SignDoc_throw (ex);
05071   }
05072 
05094   std::string getButtonValue (Encoding aEncoding) const
05095   {
05096     SIGNDOC_Exception *ex = NULL;
05097     std::string r;
05098     char *s = SIGNDOC_Field_getButtonValue (&ex, p, aEncoding);
05099     if (ex != NULL) SignDoc_throw (ex);
05100     try
05101       {
05102         r = s;
05103       }
05104     catch (...)
05105       {
05106         SIGNDOC_free (s);
05107         throw;
05108       }
05109     SIGNDOC_free (s);
05110     return r;
05111   }
05112 
05126   const char *getButtonValueUTF8 () const
05127   {
05128     SIGNDOC_Exception *ex = NULL;
05129     const char *r;
05130     r = SIGNDOC_Field_getButtonValueUTF8 (&ex, p);
05131     if (ex != NULL) SignDoc_throw (ex);
05132     return r;
05133   }
05134 
05159   void setButtonValue (Encoding aEncoding, const std::string &aValue)
05160   {
05161     SIGNDOC_Exception *ex = NULL;
05162     SIGNDOC_Field_setButtonValue (&ex, p, aEncoding, aValue.c_str ());
05163     if (ex != NULL) SignDoc_throw (ex);
05164   }
05165 
05176   Justification getJustification () const
05177   {
05178     SIGNDOC_Exception *ex = NULL;
05179     Justification r;
05180     r = (Justification)SIGNDOC_Field_getJustification (&ex, p);
05181     if (ex != NULL) SignDoc_throw (ex);
05182     return r;
05183   }
05184 
05198   void setJustification (Justification aJustification)
05199   {
05200     SIGNDOC_Exception *ex = NULL;
05201     SIGNDOC_Field_setJustification (&ex, p, aJustification);
05202     if (ex != NULL) SignDoc_throw (ex);
05203   }
05204 
05218   int getRotation () const
05219   {
05220     SIGNDOC_Exception *ex = NULL;
05221     int r;
05222     r = SIGNDOC_Field_getRotation (&ex, p);
05223     if (ex != NULL) SignDoc_throw (ex);
05224     return r;
05225   }
05226 
05242   void setRotation (int aRotation)
05243   {
05244     SIGNDOC_Exception *ex = NULL;
05245     SIGNDOC_Field_setRotation (&ex, p, aRotation);
05246     if (ex != NULL) SignDoc_throw (ex);
05247   }
05248 
05264   bool getTextFieldAttributes (SignDocTextFieldAttributes &aOutput) const
05265   {
05266     SIGNDOC_Exception *ex = NULL;
05267     bool r;
05268     r = (bool)SIGNDOC_Field_getTextFieldAttributes (&ex, p, aOutput.getImpl ());
05269     if (ex != NULL) SignDoc_throw (ex);
05270     return r;
05271   }
05272 
05311   bool setTextFieldAttributes (const SignDocTextFieldAttributes &aInput)
05312   {
05313     SIGNDOC_Exception *ex = NULL;
05314     bool r;
05315     r = (bool)SIGNDOC_Field_setTextFieldAttributes (&ex, p, aInput.getImpl ());
05316     if (ex != NULL) SignDoc_throw (ex);
05317     return r;
05318   }
05319 
05332   SignDocColor *getBackgroundColor () const
05333   {
05334     SIGNDOC_Exception *ex = NULL;
05335     SIGNDOC_Color *r;
05336     r = SIGNDOC_Field_getBackgroundColor (&ex, p);
05337     if (ex != NULL) SignDoc_throw (ex);
05338     if (r == NULL)
05339       return NULL;
05340     try
05341       {
05342         return new SignDocColor (r);
05343       }
05344     catch (...)
05345       {
05346         SIGNDOC_Color_delete (r);
05347         throw;
05348       }
05349   }
05350 
05363   void setBackgroundColor (const SignDocColor *aColor)
05364   {
05365     SIGNDOC_Exception *ex = NULL;
05366     SIGNDOC_Field_setBackgroundColor (&ex, p, aColor == NULL ? NULL : aColor->getImpl ());
05367     if (ex != NULL) SignDoc_throw (ex);
05368   }
05369 
05383   SignDocColor *getBorderColor () const
05384   {
05385     SIGNDOC_Exception *ex = NULL;
05386     SIGNDOC_Color *r;
05387     r = SIGNDOC_Field_getBorderColor (&ex, p);
05388     if (ex != NULL) SignDoc_throw (ex);
05389     if (r == NULL)
05390       return NULL;
05391     try
05392       {
05393         return new SignDocColor (r);
05394       }
05395     catch (...)
05396       {
05397         SIGNDOC_Color_delete (r);
05398         throw;
05399       }
05400   }
05401 
05421   void setBorderColor (const SignDocColor *aColor)
05422   {
05423     SIGNDOC_Exception *ex = NULL;
05424     SIGNDOC_Field_setBorderColor (&ex, p, aColor == NULL ? NULL : aColor->getImpl ());
05425     if (ex != NULL) SignDoc_throw (ex);
05426   }
05427 
05437   double getBorderWidth () const
05438   {
05439     SIGNDOC_Exception *ex = NULL;
05440     double r;
05441     r = SIGNDOC_Field_getBorderWidth (&ex, p);
05442     if (ex != NULL) SignDoc_throw (ex);
05443     return r;
05444   }
05445 
05457   void setBorderWidth (double aWidth)
05458   {
05459     SIGNDOC_Exception *ex = NULL;
05460     SIGNDOC_Field_setBorderWidth (&ex, p, aWidth);
05461     if (ex != NULL) SignDoc_throw (ex);
05462   }
05463 
05473   BorderStyle getBorderStyle () const
05474   {
05475     SIGNDOC_Exception *ex = NULL;
05476     BorderStyle r;
05477     r = (BorderStyle)SIGNDOC_Field_getBorderStyle (&ex, p);
05478     if (ex != NULL) SignDoc_throw (ex);
05479     return r;
05480   }
05481 
05495   void setBorderStyle (BorderStyle aStyle)
05496   {
05497     SIGNDOC_Exception *ex = NULL;
05498     SIGNDOC_Field_setBorderStyle (&ex, p, aStyle);
05499     if (ex != NULL) SignDoc_throw (ex);
05500   }
05501 
05512   ButtonStyle getButtonStyle () const
05513   {
05514     SIGNDOC_Exception *ex = NULL;
05515     ButtonStyle r;
05516     r = (ButtonStyle)SIGNDOC_Field_getButtonStyle (&ex, p);
05517     if (ex != NULL) SignDoc_throw (ex);
05518     return r;
05519   }
05520 
05534   void setButtonStyle (ButtonStyle aStyle)
05535   {
05536     SIGNDOC_Exception *ex = NULL;
05537     SIGNDOC_Field_setButtonStyle (&ex, p, aStyle);
05538     if (ex != NULL) SignDoc_throw (ex);
05539   }
05540 
05551   LockType getLockType () const
05552   {
05553     SIGNDOC_Exception *ex = NULL;
05554     LockType r;
05555     r = (LockType)SIGNDOC_Field_getLockType (&ex, p);
05556     if (ex != NULL) SignDoc_throw (ex);
05557     return r;
05558   }
05559 
05570   void setLockType (LockType aLockType)
05571   {
05572     SIGNDOC_Exception *ex = NULL;
05573     SIGNDOC_Field_setLockType (&ex, p, aLockType);
05574     if (ex != NULL) SignDoc_throw (ex);
05575   }
05576 
05584   int getLockFieldCount () const
05585   {
05586     SIGNDOC_Exception *ex = NULL;
05587     int r;
05588     r = SIGNDOC_Field_getLockFieldCount (&ex, p);
05589     if (ex != NULL) SignDoc_throw (ex);
05590     return r;
05591   }
05592 
05607   std::string getLockField (Encoding aEncoding, int aIndex) const
05608   {
05609     SIGNDOC_Exception *ex = NULL;
05610     std::string r;
05611     char *s = SIGNDOC_Field_getLockField (&ex, p, aEncoding, aIndex);
05612     if (ex != NULL) SignDoc_throw (ex);
05613     try
05614       {
05615         r = s;
05616       }
05617     catch (...)
05618       {
05619         SIGNDOC_free (s);
05620         throw;
05621       }
05622     SIGNDOC_free (s);
05623     return r;
05624   }
05625 
05638   const char *getLockFieldUTF8 (int aIndex) const
05639   {
05640     SIGNDOC_Exception *ex = NULL;
05641     const char *r;
05642     r = SIGNDOC_Field_getLockFieldUTF8 (&ex, p, aIndex);
05643     if (ex != NULL) SignDoc_throw (ex);
05644     return r;
05645   }
05646 
05654   void clearLockFields ()
05655   {
05656     SIGNDOC_Exception *ex = NULL;
05657     SIGNDOC_Field_clearLockFields (&ex, p);
05658     if (ex != NULL) SignDoc_throw (ex);
05659   }
05660 
05673   void addLockField (Encoding aEncoding, const std::string &aName)
05674   {
05675     SIGNDOC_Exception *ex = NULL;
05676     SIGNDOC_Field_addLockField (&ex, p, aEncoding, aName.c_str ());
05677     if (ex != NULL) SignDoc_throw (ex);
05678   }
05679 
05697   bool setLockField (int aIndex, Encoding aEncoding, const std::string &aName)
05698   {
05699     SIGNDOC_Exception *ex = NULL;
05700     bool r;
05701     r = (bool)SIGNDOC_Field_setLockFieldByIndex (&ex, p, aIndex, aEncoding, aName.c_str ());
05702     if (ex != NULL) SignDoc_throw (ex);
05703     return r;
05704   }
05705 
05722   void setLockField (Encoding aEncoding, const std::string &aName)
05723   {
05724     SIGNDOC_Exception *ex = NULL;
05725     SIGNDOC_Field_setLockField (&ex, p, aEncoding, aName.c_str ());
05726     if (ex != NULL) SignDoc_throw (ex);
05727   }
05728 
05738   bool removeLockField (int aIndex)
05739   {
05740     SIGNDOC_Exception *ex = NULL;
05741     bool r;
05742     r = (bool)SIGNDOC_Field_removeLockField (&ex, p, aIndex);
05743     if (ex != NULL) SignDoc_throw (ex);
05744     return r;
05745   }
05746 
05761   int getLockMDP () const
05762   {
05763     SIGNDOC_Exception *ex = NULL;
05764     int r;
05765     r = SIGNDOC_Field_getLockMDP (&ex, p);
05766     if (ex != NULL) SignDoc_throw (ex);
05767     return r;
05768   }
05769 
05784   void setLockMDP (int aMDP)
05785   {
05786     SIGNDOC_Exception *ex = NULL;
05787     SIGNDOC_Field_setLockMDP (&ex, p, aMDP);
05788     if (ex != NULL) SignDoc_throw (ex);
05789   }
05790 
05801   unsigned getCertSeedValueFlags () const
05802   {
05803     SIGNDOC_Exception *ex = NULL;
05804     unsigned r;
05805     r = SIGNDOC_Field_getCertSeedValueFlags (&ex, p);
05806     if (ex != NULL) SignDoc_throw (ex);
05807     return r;
05808   }
05809 
05821   void setCertSeedValueFlags (unsigned aFlags)
05822   {
05823     SIGNDOC_Exception *ex = NULL;
05824     SIGNDOC_Field_setCertSeedValueFlags (&ex, p, aFlags);
05825     if (ex != NULL) SignDoc_throw (ex);
05826   }
05827 
05839   int getCertSeedValueSubjectDNCount () const
05840   {
05841     SIGNDOC_Exception *ex = NULL;
05842     int r;
05843     r = SIGNDOC_Field_getCertSeedValueSubjectDNCount (&ex, p);
05844     if (ex != NULL) SignDoc_throw (ex);
05845     return r;
05846   }
05847 
05867   std::string getCertSeedValueSubjectDN (Encoding aEncoding, int aIndex) const
05868   {
05869     SIGNDOC_Exception *ex = NULL;
05870     std::string r;
05871     char *s = SIGNDOC_Field_getCertSeedValueSubjectDN (&ex, p, aEncoding, aIndex);
05872     if (ex != NULL) SignDoc_throw (ex);
05873     try
05874       {
05875         r = s;
05876       }
05877     catch (...)
05878       {
05879         SIGNDOC_free (s);
05880         throw;
05881       }
05882     SIGNDOC_free (s);
05883     return r;
05884   }
05885 
05905   const char *getCertSeedValueSubjectDNUTF8 (int aIndex) const
05906   {
05907     SIGNDOC_Exception *ex = NULL;
05908     const char *r;
05909     r = SIGNDOC_Field_getCertSeedValueSubjectDNUTF8 (&ex, p, aIndex);
05910     if (ex != NULL) SignDoc_throw (ex);
05911     return r;
05912   }
05913 
05924   void clearCertSeedValueSubjectDNs ()
05925   {
05926     SIGNDOC_Exception *ex = NULL;
05927     SIGNDOC_Field_clearCertSeedValueSubjectDNs (&ex, p);
05928     if (ex != NULL) SignDoc_throw (ex);
05929   }
05930 
05951   bool addCertSeedValueSubjectDN (Encoding aEncoding, const std::string &aName)
05952   {
05953     SIGNDOC_Exception *ex = NULL;
05954     bool r;
05955     r = (bool)SIGNDOC_Field_addCertSeedValueSubjectDN (&ex, p, aEncoding, aName.c_str ());
05956     if (ex != NULL) SignDoc_throw (ex);
05957     return r;
05958   }
05959 
05984   bool setCertSeedValueSubjectDN (int aIndex, Encoding aEncoding,
05985                                   const std::string &aName)
05986   {
05987     SIGNDOC_Exception *ex = NULL;
05988     bool r;
05989     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectDNByIndex (&ex, p, aIndex, aEncoding, aName.c_str ());
05990     if (ex != NULL) SignDoc_throw (ex);
05991     return r;
05992   }
05993 
06018   bool setCertSeedValueSubjectDN (Encoding aEncoding, const std::string &aName)
06019   {
06020     SIGNDOC_Exception *ex = NULL;
06021     bool r;
06022     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectDN (&ex, p, aEncoding, aName.c_str ());
06023     if (ex != NULL) SignDoc_throw (ex);
06024     return r;
06025   }
06026 
06039   bool removeCertSeedValueSubjectDN (int aIndex)
06040   {
06041     SIGNDOC_Exception *ex = NULL;
06042     bool r;
06043     r = (bool)SIGNDOC_Field_removeCertSeedValueSubjectDN (&ex, p, aIndex);
06044     if (ex != NULL) SignDoc_throw (ex);
06045     return r;
06046   }
06047 
06058   int getCertSeedValueSubjectCertificateCount () const
06059   {
06060     SIGNDOC_Exception *ex = NULL;
06061     int r;
06062     r = SIGNDOC_Field_getCertSeedValueSubjectCertificateCount (&ex, p);
06063     if (ex != NULL) SignDoc_throw (ex);
06064     return r;
06065   }
06066 
06079   bool getCertSeedValueSubjectCertificate (int aIndex,
06080                                            std::vector<unsigned char> &aOutput) const
06081   {
06082     SIGNDOC_Exception *ex = NULL;
06083     SIGNDOC_ByteArray *tempOutput = NULL;
06084     bool r;
06085     try
06086       {
06087         tempOutput = SIGNDOC_ByteArray_new (&ex);
06088         if (ex != NULL) SignDoc_throw (ex);
06089         r = (bool)SIGNDOC_Field_getCertSeedValueSubjectCertificate (&ex, p, aIndex, tempOutput);
06090         assignArray (aOutput, tempOutput);
06091       }
06092     catch (...)
06093       {
06094         if (tempOutput != NULL)
06095           SIGNDOC_ByteArray_delete (tempOutput);
06096         throw;
06097       }
06098     if (tempOutput != NULL)
06099       SIGNDOC_ByteArray_delete (tempOutput);
06100     if (ex != NULL) SignDoc_throw (ex);
06101     return r;
06102   }
06103 
06113   void clearCertSeedValueSubjectCertificates ()
06114   {
06115     SIGNDOC_Exception *ex = NULL;
06116     SIGNDOC_Field_clearCertSeedValueSubjectCertificates (&ex, p);
06117     if (ex != NULL) SignDoc_throw (ex);
06118   }
06119 
06131   void addCertSeedValueSubjectCertificate (const void *aPtr, size_t aSize)
06132   {
06133     SIGNDOC_Exception *ex = NULL;
06134     SIGNDOC_Field_addCertSeedValueSubjectCertificate (&ex, p, aPtr, aSize);
06135     if (ex != NULL) SignDoc_throw (ex);
06136   }
06137 
06154   bool setCertSeedValueSubjectCertificate (int aIndex, const void *aPtr,
06155                                            size_t aSize)
06156   {
06157     SIGNDOC_Exception *ex = NULL;
06158     bool r;
06159     r = (bool)SIGNDOC_Field_setCertSeedValueSubjectCertificateByIndex (&ex, p, aIndex, aPtr, aSize);
06160     if (ex != NULL) SignDoc_throw (ex);
06161     return r;
06162   }
06163 
06178   void setCertSeedValueSubjectCertificate (const void *aPtr, size_t aSize)
06179   {
06180     SIGNDOC_Exception *ex = NULL;
06181     SIGNDOC_Field_setCertSeedValueSubjectCertificate (&ex, p, aPtr, aSize);
06182     if (ex != NULL) SignDoc_throw (ex);
06183   }
06184 
06198   bool removeCertSeedValueSubjectCertificate (int aIndex)
06199   {
06200     SIGNDOC_Exception *ex = NULL;
06201     bool r;
06202     r = (bool)SIGNDOC_Field_removeCertSeedValueSubjectCertificate (&ex, p, aIndex);
06203     if (ex != NULL) SignDoc_throw (ex);
06204     return r;
06205   }
06206 
06217   int getCertSeedValueIssuerCertificateCount () const
06218   {
06219     SIGNDOC_Exception *ex = NULL;
06220     int r;
06221     r = SIGNDOC_Field_getCertSeedValueIssuerCertificateCount (&ex, p);
06222     if (ex != NULL) SignDoc_throw (ex);
06223     return r;
06224   }
06225 
06238   bool getCertSeedValueIssuerCertificate (int aIndex,
06239                                           std::vector<unsigned char> &aOutput) const
06240   {
06241     SIGNDOC_Exception *ex = NULL;
06242     SIGNDOC_ByteArray *tempOutput = NULL;
06243     bool r;
06244     try
06245       {
06246         tempOutput = SIGNDOC_ByteArray_new (&ex);
06247         if (ex != NULL) SignDoc_throw (ex);
06248         r = (bool)SIGNDOC_Field_getCertSeedValueIssuerCertificate (&ex, p, aIndex, tempOutput);
06249         assignArray (aOutput, tempOutput);
06250       }
06251     catch (...)
06252       {
06253         if (tempOutput != NULL)
06254           SIGNDOC_ByteArray_delete (tempOutput);
06255         throw;
06256       }
06257     if (tempOutput != NULL)
06258       SIGNDOC_ByteArray_delete (tempOutput);
06259     if (ex != NULL) SignDoc_throw (ex);
06260     return r;
06261   }
06262 
06272   void clearCertSeedValueIssuerCertificates ()
06273   {
06274     SIGNDOC_Exception *ex = NULL;
06275     SIGNDOC_Field_clearCertSeedValueIssuerCertificates (&ex, p);
06276     if (ex != NULL) SignDoc_throw (ex);
06277   }
06278 
06290   void addCertSeedValueIssuerCertificate (const void *aPtr, size_t aSize)
06291   {
06292     SIGNDOC_Exception *ex = NULL;
06293     SIGNDOC_Field_addCertSeedValueIssuerCertificate (&ex, p, aPtr, aSize);
06294     if (ex != NULL) SignDoc_throw (ex);
06295   }
06296 
06313   bool setCertSeedValueIssuerCertificate (int aIndex, const void *aPtr,
06314                                           size_t aSize)
06315   {
06316     SIGNDOC_Exception *ex = NULL;
06317     bool r;
06318     r = (bool)SIGNDOC_Field_setCertSeedValueIssuerCertificateByIndex (&ex, p, aIndex, aPtr, aSize);
06319     if (ex != NULL) SignDoc_throw (ex);
06320     return r;
06321   }
06322 
06337   void setCertSeedValueIssuerCertificate (const void *aPtr, size_t aSize)
06338   {
06339     SIGNDOC_Exception *ex = NULL;
06340     SIGNDOC_Field_setCertSeedValueIssuerCertificate (&ex, p, aPtr, aSize);
06341     if (ex != NULL) SignDoc_throw (ex);
06342   }
06343 
06357   bool removeCertSeedValueIssuerCertificate (int aIndex)
06358   {
06359     SIGNDOC_Exception *ex = NULL;
06360     bool r;
06361     r = (bool)SIGNDOC_Field_removeCertSeedValueIssuerCertificate (&ex, p, aIndex);
06362     if (ex != NULL) SignDoc_throw (ex);
06363     return r;
06364   }
06365 
06375   int getCertSeedValuePolicyCount () const
06376   {
06377     SIGNDOC_Exception *ex = NULL;
06378     int r;
06379     r = SIGNDOC_Field_getCertSeedValuePolicyCount (&ex, p);
06380     if (ex != NULL) SignDoc_throw (ex);
06381     return r;
06382   }
06383 
06402   std::string getCertSeedValuePolicy (Encoding aEncoding, int aIndex) const
06403   {
06404     SIGNDOC_Exception *ex = NULL;
06405     std::string r;
06406     char *s = SIGNDOC_Field_getCertSeedValuePolicy (&ex, p, aEncoding, aIndex);
06407     if (ex != NULL) SignDoc_throw (ex);
06408     try
06409       {
06410         r = s;
06411       }
06412     catch (...)
06413       {
06414         SIGNDOC_free (s);
06415         throw;
06416       }
06417     SIGNDOC_free (s);
06418     return r;
06419   }
06420 
06438   const char *getCertSeedValuePolicyUTF8 (int aIndex) const
06439   {
06440     SIGNDOC_Exception *ex = NULL;
06441     const char *r;
06442     r = SIGNDOC_Field_getCertSeedValuePolicyUTF8 (&ex, p, aIndex);
06443     if (ex != NULL) SignDoc_throw (ex);
06444     return r;
06445   }
06446 
06456   void clearCertSeedValuePolicies ()
06457   {
06458     SIGNDOC_Exception *ex = NULL;
06459     SIGNDOC_Field_clearCertSeedValuePolicies (&ex, p);
06460     if (ex != NULL) SignDoc_throw (ex);
06461   }
06462 
06479   void addCertSeedValuePolicy (Encoding aEncoding, const std::string &aOID)
06480   {
06481     SIGNDOC_Exception *ex = NULL;
06482     SIGNDOC_Field_addCertSeedValuePolicy (&ex, p, aEncoding, aOID.c_str ());
06483     if (ex != NULL) SignDoc_throw (ex);
06484   }
06485 
06507   bool setCertSeedValuePolicy (int aIndex, Encoding aEncoding,
06508                                const std::string &aOID)
06509   {
06510     SIGNDOC_Exception *ex = NULL;
06511     bool r;
06512     r = (bool)SIGNDOC_Field_setCertSeedValuePolicyByIndex (&ex, p, aIndex, aEncoding, aOID.c_str ());
06513     if (ex != NULL) SignDoc_throw (ex);
06514     return r;
06515   }
06516 
06537   void setCertSeedValuePolicy (Encoding aEncoding, const std::string &aOID)
06538   {
06539     SIGNDOC_Exception *ex = NULL;
06540     SIGNDOC_Field_setCertSeedValuePolicy (&ex, p, aEncoding, aOID.c_str ());
06541     if (ex != NULL) SignDoc_throw (ex);
06542   }
06543 
06555   bool removeCertSeedValuePolicy (int aIndex)
06556   {
06557     SIGNDOC_Exception *ex = NULL;
06558     bool r;
06559     r = (bool)SIGNDOC_Field_removeCertSeedValuePolicy (&ex, p, aIndex);
06560     if (ex != NULL) SignDoc_throw (ex);
06561     return r;
06562   }
06563 
06580   std::string getSeedValueTimeStampServerURL (Encoding aEncoding) const
06581   {
06582     SIGNDOC_Exception *ex = NULL;
06583     std::string r;
06584     char *s = SIGNDOC_Field_getSeedValueTimeStampServerURL (&ex, p, aEncoding);
06585     if (ex != NULL) SignDoc_throw (ex);
06586     try
06587       {
06588         r = s;
06589       }
06590     catch (...)
06591       {
06592         SIGNDOC_free (s);
06593         throw;
06594       }
06595     SIGNDOC_free (s);
06596     return r;
06597   }
06598 
06613   bool getSeedValueTimeStampRequired () const
06614   {
06615     SIGNDOC_Exception *ex = NULL;
06616     bool r;
06617     r = (bool)SIGNDOC_Field_getSeedValueTimeStampRequired (&ex, p);
06618     if (ex != NULL) SignDoc_throw (ex);
06619     return r;
06620   }
06621 
06643   bool setSeedValueTimeStamp (Encoding aEncoding, const std::string &aURL,
06644                               bool aRequired)
06645   {
06646     SIGNDOC_Exception *ex = NULL;
06647     bool r;
06648     r = (bool)SIGNDOC_Field_setSeedValueTimeStamp (&ex, p, aEncoding, aURL.c_str (), aRequired);
06649     if (ex != NULL) SignDoc_throw (ex);
06650     return r;
06651   }
06652 
06670   std::string getSeedValueFilter (Encoding aEncoding) const
06671   {
06672     SIGNDOC_Exception *ex = NULL;
06673     std::string r;
06674     char *s = SIGNDOC_Field_getSeedValueFilter (&ex, p, aEncoding);
06675     if (ex != NULL) SignDoc_throw (ex);
06676     try
06677       {
06678         r = s;
06679       }
06680     catch (...)
06681       {
06682         SIGNDOC_free (s);
06683         throw;
06684       }
06685     SIGNDOC_free (s);
06686     return r;
06687   }
06688 
06704   bool getSeedValueFilterRequired () const
06705   {
06706     SIGNDOC_Exception *ex = NULL;
06707     bool r;
06708     r = (bool)SIGNDOC_Field_getSeedValueFilterRequired (&ex, p);
06709     if (ex != NULL) SignDoc_throw (ex);
06710     return r;
06711   }
06712 
06735   bool setSeedValueFilter (Encoding aEncoding, const std::string &aFilter,
06736                            bool aRequired)
06737   {
06738     SIGNDOC_Exception *ex = NULL;
06739     bool r;
06740     r = (bool)SIGNDOC_Field_setSeedValueFilter (&ex, p, aEncoding, aFilter.c_str (), aRequired);
06741     if (ex != NULL) SignDoc_throw (ex);
06742     return r;
06743   }
06744 
06754   int getSeedValueSubFilterCount () const
06755   {
06756     SIGNDOC_Exception *ex = NULL;
06757     int r;
06758     r = SIGNDOC_Field_getSeedValueSubFilterCount (&ex, p);
06759     if (ex != NULL) SignDoc_throw (ex);
06760     return r;
06761   }
06762 
06786   std::string getSeedValueSubFilter (Encoding aEncoding, int aIndex) const
06787   {
06788     SIGNDOC_Exception *ex = NULL;
06789     std::string r;
06790     char *s = SIGNDOC_Field_getSeedValueSubFilter (&ex, p, aEncoding, aIndex);
06791     if (ex != NULL) SignDoc_throw (ex);
06792     try
06793       {
06794         r = s;
06795       }
06796     catch (...)
06797       {
06798         SIGNDOC_free (s);
06799         throw;
06800       }
06801     SIGNDOC_free (s);
06802     return r;
06803   }
06804 
06819   bool getSeedValueSubFilterRequired () const
06820   {
06821     SIGNDOC_Exception *ex = NULL;
06822     bool r;
06823     r = (bool)SIGNDOC_Field_getSeedValueSubFilterRequired (&ex, p);
06824     if (ex != NULL) SignDoc_throw (ex);
06825     return r;
06826   }
06827 
06841   void setSeedValueSubFilterRequired (bool aRequired) const
06842   {
06843     SIGNDOC_Exception *ex = NULL;
06844     SIGNDOC_Field_setSeedValueSubFilterRequired (&ex, p, aRequired);
06845     if (ex != NULL) SignDoc_throw (ex);
06846   }
06847 
06863   const char *getSeedValueSubFilterUTF8 (int aIndex) const
06864   {
06865     SIGNDOC_Exception *ex = NULL;
06866     const char *r;
06867     r = SIGNDOC_Field_getSeedValueSubFilterUTF8 (&ex, p, aIndex);
06868     if (ex != NULL) SignDoc_throw (ex);
06869     return r;
06870   }
06871 
06881   void clearSeedValueSubFilters ()
06882   {
06883     SIGNDOC_Exception *ex = NULL;
06884     SIGNDOC_Field_clearSeedValueSubFilters (&ex, p);
06885     if (ex != NULL) SignDoc_throw (ex);
06886   }
06887 
06902   void addSeedValueSubFilter (Encoding aEncoding,
06903                               const std::string &aSubFilter)
06904   {
06905     SIGNDOC_Exception *ex = NULL;
06906     SIGNDOC_Field_addSeedValueSubFilter (&ex, p, aEncoding, aSubFilter.c_str ());
06907     if (ex != NULL) SignDoc_throw (ex);
06908   }
06909 
06929   bool setSeedValueSubFilter (int aIndex, Encoding aEncoding,
06930                               const std::string &aSubFilter)
06931   {
06932     SIGNDOC_Exception *ex = NULL;
06933     bool r;
06934     r = (bool)SIGNDOC_Field_setSeedValueSubFilterByIndex (&ex, p, aIndex, aEncoding, aSubFilter.c_str ());
06935     if (ex != NULL) SignDoc_throw (ex);
06936     return r;
06937   }
06938 
06958   void setSeedValueSubFilter (Encoding aEncoding,
06959                               const std::string &aSubFilter)
06960   {
06961     SIGNDOC_Exception *ex = NULL;
06962     SIGNDOC_Field_setSeedValueSubFilter (&ex, p, aEncoding, aSubFilter.c_str ());
06963     if (ex != NULL) SignDoc_throw (ex);
06964   }
06965 
06978   bool removeSeedValueSubFilter (int aIndex)
06979   {
06980     SIGNDOC_Exception *ex = NULL;
06981     bool r;
06982     r = (bool)SIGNDOC_Field_removeSeedValueSubFilter (&ex, p, aIndex);
06983     if (ex != NULL) SignDoc_throw (ex);
06984     return r;
06985   }
06986 
06996   int getSeedValueDigestMethodCount () const
06997   {
06998     SIGNDOC_Exception *ex = NULL;
06999     int r;
07000     r = SIGNDOC_Field_getSeedValueDigestMethodCount (&ex, p);
07001     if (ex != NULL) SignDoc_throw (ex);
07002     return r;
07003   }
07004 
07036   std::string getSeedValueDigestMethod (Encoding aEncoding, int aIndex) const
07037   {
07038     SIGNDOC_Exception *ex = NULL;
07039     std::string r;
07040     char *s = SIGNDOC_Field_getSeedValueDigestMethod (&ex, p, aEncoding, aIndex);
07041     if (ex != NULL) SignDoc_throw (ex);
07042     try
07043       {
07044         r = s;
07045       }
07046     catch (...)
07047       {
07048         SIGNDOC_free (s);
07049         throw;
07050       }
07051     SIGNDOC_free (s);
07052     return r;
07053   }
07054 
07069   bool getSeedValueDigestMethodRequired () const
07070   {
07071     SIGNDOC_Exception *ex = NULL;
07072     bool r;
07073     r = (bool)SIGNDOC_Field_getSeedValueDigestMethodRequired (&ex, p);
07074     if (ex != NULL) SignDoc_throw (ex);
07075     return r;
07076   }
07077 
07091   void setSeedValueDigestMethodRequired (bool aRequired) const
07092   {
07093     SIGNDOC_Exception *ex = NULL;
07094     SIGNDOC_Field_setSeedValueDigestMethodRequired (&ex, p, aRequired);
07095     if (ex != NULL) SignDoc_throw (ex);
07096   }
07097 
07113   const char *getSeedValueDigestMethodUTF8 (int aIndex) const
07114   {
07115     SIGNDOC_Exception *ex = NULL;
07116     const char *r;
07117     r = SIGNDOC_Field_getSeedValueDigestMethodUTF8 (&ex, p, aIndex);
07118     if (ex != NULL) SignDoc_throw (ex);
07119     return r;
07120   }
07121 
07131   void clearSeedValueDigestMethods ()
07132   {
07133     SIGNDOC_Exception *ex = NULL;
07134     SIGNDOC_Field_clearSeedValueDigestMethods (&ex, p);
07135     if (ex != NULL) SignDoc_throw (ex);
07136   }
07137 
07152   void addSeedValueDigestMethod (Encoding aEncoding,
07153                                  const std::string &aDigestMethod)
07154   {
07155     SIGNDOC_Exception *ex = NULL;
07156     SIGNDOC_Field_addSeedValueDigestMethod (&ex, p, aEncoding, aDigestMethod.c_str ());
07157     if (ex != NULL) SignDoc_throw (ex);
07158   }
07159 
07179   bool setSeedValueDigestMethod (int aIndex, Encoding aEncoding,
07180                                  const std::string &aDigestMethod)
07181   {
07182     SIGNDOC_Exception *ex = NULL;
07183     bool r;
07184     r = (bool)SIGNDOC_Field_setSeedValueDigestMethodByIndex (&ex, p, aIndex, aEncoding, aDigestMethod.c_str ());
07185     if (ex != NULL) SignDoc_throw (ex);
07186     return r;
07187   }
07188 
07208   void setSeedValueDigestMethod (Encoding aEncoding,
07209                                  const std::string &aDigestMethod)
07210   {
07211     SIGNDOC_Exception *ex = NULL;
07212     SIGNDOC_Field_setSeedValueDigestMethod (&ex, p, aEncoding, aDigestMethod.c_str ());
07213     if (ex != NULL) SignDoc_throw (ex);
07214   }
07215 
07228   bool removeSeedValueDigestMethod (int aIndex)
07229   {
07230     SIGNDOC_Exception *ex = NULL;
07231     bool r;
07232     r = (bool)SIGNDOC_Field_removeSeedValueDigestMethod (&ex, p, aIndex);
07233     if (ex != NULL) SignDoc_throw (ex);
07234     return r;
07235   }
07236 
07250   bool getSeedValueAddRevInfo () const
07251   {
07252     SIGNDOC_Exception *ex = NULL;
07253     bool r;
07254     r = (bool)SIGNDOC_Field_getSeedValueAddRevInfo (&ex, p);
07255     if (ex != NULL) SignDoc_throw (ex);
07256     return r;
07257   }
07258 
07274   void setSeedValueAddRevInfo (bool aAddRevInfo)
07275   {
07276     SIGNDOC_Exception *ex = NULL;
07277     SIGNDOC_Field_setSeedValueAddRevInfo (&ex, p, aAddRevInfo);
07278     if (ex != NULL) SignDoc_throw (ex);
07279   }
07280 
07298   int getSeedValueMDP () const
07299   {
07300     SIGNDOC_Exception *ex = NULL;
07301     int r;
07302     r = SIGNDOC_Field_getSeedValueMDP (&ex, p);
07303     if (ex != NULL) SignDoc_throw (ex);
07304     return r;
07305   }
07306 
07329   bool setSeedValueMDP (int aMDP)
07330   {
07331     SIGNDOC_Exception *ex = NULL;
07332     bool r;
07333     r = (bool)SIGNDOC_Field_setSeedValueMDP (&ex, p, aMDP);
07334     if (ex != NULL) SignDoc_throw (ex);
07335     return r;
07336   }
07337 
07350   SignDocColor *getEmptyFieldColor () const
07351   {
07352     SIGNDOC_Exception *ex = NULL;
07353     SIGNDOC_Color *r;
07354     r = SIGNDOC_Field_getEmptyFieldColor (&ex, p);
07355     if (ex != NULL) SignDoc_throw (ex);
07356     if (r == NULL)
07357       return NULL;
07358     try
07359       {
07360         return new SignDocColor (r);
07361       }
07362     catch (...)
07363       {
07364         SIGNDOC_Color_delete (r);
07365         throw;
07366       }
07367   }
07368 
07380   void setEmptyFieldColor (const SignDocColor &aColor)
07381   {
07382     SIGNDOC_Exception *ex = NULL;
07383     SIGNDOC_Field_setEmptyFieldColor (&ex, p, aColor.getImpl ());
07384     if (ex != NULL) SignDoc_throw (ex);
07385   }
07386 
07387 private:
07388 public:
07393   SignDocField (SIGNDOC_Field *aP) : p (aP) { }
07394 
07399   SIGNDOC_Field *getImpl () { return p; }
07400 
07405   const SIGNDOC_Field *getImpl () const { return p; }
07406 
07411   void setImpl (SIGNDOC_Field *aP) { SIGNDOC_Field_delete (p); p  = aP; }
07412 
07413 private:
07414   SIGNDOC_Field *p;
07415 };
07416 
07421 inline void assignArray (std::vector<SignDocField> &aDst,
07422                          SIGNDOC_FieldArray *aSrc)
07423 {
07424   aDst.clear ();
07425   unsigned n = SIGNDOC_FieldArray_count (aSrc);
07426   if (aSrc == NULL)
07427     return;
07428   aDst.resize (n);
07429   for (unsigned i = 0; i < n; ++i)
07430     {
07431       SIGNDOC_Exception *ex = NULL;
07432       SIGNDOC_Field *p = SIGNDOC_Field_clone (&ex, SIGNDOC_FieldArray_at (aSrc, i));
07433       if (ex != NULL) SignDoc_throw (ex);
07434       aDst[i].setImpl (p);
07435     }
07436 }
07437 
07877 class SignDocSignatureParameters 
07878 {
07879 public:
07888   enum Method
07889   {
07904     m_default,
07905 
07911     m_digsig_pkcs1,
07912 
07916     m_digsig_pkcs7_detached,
07917 
07918     /*+
07919      * @brief PKCS #7 with SHA-1 (deprecated).
07920      */
07921     m_digsig_pkcs7_sha1,
07922 
07923     /*+
07924      * @brief The signature is just a hash (TIFF only).
07925      */
07926     m_hash,
07927 
07928     /*+
07929      * @brief Detached ETSI CAdES (PAdES-BES).
07930      */
07931     m_digsig_cades_detached,
07932 
07933     /*+
07934      * @brief ETSI CAdES RFC 3161 time stamp.
07935      */
07936     m_digsig_cades_rfc3161
07937   };
07938 
07955   enum DetachedHashAlgorithm
07956   {
07968     dha_default,
07969 
07970     dha_sha1,                  
07971     dha_sha256,                
07972     dha_sha384,                
07973     dha_sha512,                
07974     dha_ripemd160,             
07975     dha_sha224                 
07976   };
07977 
07983   enum AddCertificates
07984   {
07993     ac_all,
07994 
08002     ac_none,
08003 
08012     ac_trusted
08013   };
08014 
08020   enum AddRevocationInfo
08021   {
08030     ari_add = 0x01
08031   };
08032 
08038   enum RemoveXFA
08039   {
08047     rx_always,
08048 
08056     rx_if_allowed,
08057 
08064     rx_never
08065   };
08066 
08077   enum TimeStampHashAlgorithm
08078   {
08095     tsha_default,
08096 
08097     tsha_sha1,                  
08098     tsha_sha256,                
08099     tsha_sha384,                
08100     tsha_sha512                 
08101   };
08102 
08110   enum Optimize
08111   {
08112     o_optimize,               
08113     o_dont_optimize           
08114   };
08115 
08129   enum PDFAButtons
08130   {
08142     pb_freeze,
08143 
08151     pb_dont_freeze,
08152 
08167     pb_auto
08168   };
08169 
08177   enum CertificateSigningAlgorithm
08178   {
08179     csa_sha1_rsa,               
08180     csa_md5_rsa,                
08181     csa_sha256_rsa,             
08182     csa_sha384_rsa,             
08183     csa_sha512_rsa,             
08184     csa_ripemd160_rsa,          
08185     csa_ecdsa_sha1,             
08186     csa_ecdsa_sha224,           
08187     csa_ecdsa_sha256,           
08188     csa_ecdsa_sha384,           
08189     csa_ecdsa_sha512            
08190   };
08191 
08201   enum BiometricEncryption
08202   {
08211     be_rsa,
08212 
08216     be_fixed,
08217 
08223     be_binary,
08224 
08230     be_passphrase,
08231 
08241     be_dont_store
08242   };
08243 
08252   enum BiometricHashLocation
08253   {
08265     bhl_attr,
08266 
08274     bhl_contents
08275   };
08276 
08283   enum HAlignment
08284   {
08288     ha_left,
08289 
08293     ha_center,
08294 
08298     ha_right,
08299 
08306     ha_justify,
08307 
08312     ha_auto,
08313 
08317     ha_default = -1
08318   };
08319 
08326   enum VAlignment
08327   {
08331     va_top,
08332 
08336     va_center,
08337 
08341     va_bottom
08342   };
08343 
08349   enum TextPosition
08350   {
08351     tp_overlay,       
08352     tp_below,         
08353     tp_underlay,      
08354     tp_right_of,      
08355     tp_above,         
08356     tp_left_of        
08357   };
08358 
08364   enum ValueType
08365   {
08366     vt_abs,                   
08367     vt_field_height,          
08368     vt_field_width            
08369   };
08370 
08376   enum TextItem
08377   {
08378     ti_signer,                
08379     ti_sign_time,             
08380     ti_comment,               
08381     ti_adviser,               
08382     ti_contact_info,          
08383     ti_location,              
08384     ti_reason,                
08385     ti_text1,                 
08386     ti_text2,                 
08387     ti_text3,                 
08388     ti_text4,                 
08389     ti_text5,                 
08390     ti_text6,                 
08391     ti_text7,                 
08392     ti_text8,                 
08393     ti_text9                  
08394   };
08395 
08411   enum TextGroup
08412   {
08413     tg_master,                
08414     tg_slave                  
08415   };
08416 
08420   enum TextItemDirection
08421   {
08425     tid_ltr = 0x1000,
08426 
08430     tid_rtl = 0x2000,
08431 
08442     tid_default_ltr = 0x4000,
08443 
08454     tid_default_rtl = 0x8000
08455   };
08456 
08467   enum IgnoreSeedValues
08468   {
08482     isv_SubFilter = 0x01,
08483 
08498     isv_DigestMethod = 0x02
08499   };
08500 
08508   enum CertificateSelectionFlags
08509   {
08520     csf_software = 0x01,
08521 
08532     csf_hardware = 0x02,
08533 
08534     csf_use_certificate_seed_values = 0x10, 
08535     csf_ask_if_ambiguous = 0x20, 
08536     csf_never_ask = 0x40,       
08537     csf_create_self_signed = 0x80 
08538   };
08539 
08549   enum RenderSignatureFlags
08550   {
08554     rsf_bw   = 0x01,
08555 
08559     rsf_gray = 0x02,
08560 
08564     rsf_antialias = 0x04,
08565 
08578     rsf_limit_size = 0x08
08579   };
08580 
08597   enum ImageTransparency
08598   {
08604     it_opaque,
08605 
08614     it_brightest
08615   };
08616 
08620   enum ReturnCode
08621   {
08622     rc_ok,                      
08623     rc_unknown,                 
08624     rc_not_supported,           
08625     rc_invalid_value            
08626   };
08627 
08636   enum ParameterState
08637   {
08638     ps_set,             
08639     ps_missing,         
08640     ps_supported,       
08641     ps_ignored,         
08642     ps_not_supported,   
08643     ps_unknown          
08644   };
08645 
08646 public:
08653   SignDocSignatureParameters ()
08654     : p (NULL)
08655   {
08656   }
08657 
08664   ~SignDocSignatureParameters ()
08665   {
08666     SIGNDOC_SignatureParameters_delete (p);
08667   }
08668 
08676   ParameterState getState (const std::string &aName)
08677   {
08678     SIGNDOC_Exception *ex = NULL;
08679     ParameterState r;
08680     r = (ParameterState)SIGNDOC_SignatureParameters_getState (&ex, p, aName.c_str ());
08681     if (ex != NULL) SignDoc_throw (ex);
08682     return r;
08683   }
08684 
09000   ReturnCode setString (Encoding aEncoding, const std::string &aName,
09001                         const std::string &aValue)
09002   {
09003     SIGNDOC_Exception *ex = NULL;
09004     ReturnCode r;
09005     r = (ReturnCode)SIGNDOC_SignatureParameters_setString (&ex, p, aEncoding, aName.c_str (), aValue.c_str ());
09006     if (ex != NULL) SignDoc_throw (ex);
09007     return r;
09008   }
09009 
09021   ReturnCode setString (const std::string &aName, const wchar_t *aValue)
09022   {
09023     SIGNDOC_Exception *ex = NULL;
09024     ReturnCode r;
09025     r = (ReturnCode)SIGNDOC_SignatureParameters_setStringW (&ex, p, aName.c_str (), aValue);
09026     if (ex != NULL) SignDoc_throw (ex);
09027     return r;
09028   }
09029 
09349   ReturnCode setInteger (const std::string &aName, int aValue)
09350   {
09351     SIGNDOC_Exception *ex = NULL;
09352     ReturnCode r;
09353     r = (ReturnCode)SIGNDOC_SignatureParameters_setInteger (&ex, p, aName.c_str (), aValue);
09354     if (ex != NULL) SignDoc_throw (ex);
09355     return r;
09356   }
09357 
09491   ReturnCode setBlob (const std::string &aName, const unsigned char *aData,
09492                       size_t aSize)
09493   {
09494     SIGNDOC_Exception *ex = NULL;
09495     ReturnCode r;
09496     r = (ReturnCode)SIGNDOC_SignatureParameters_setBlob (&ex, p, aName.c_str (), aData, aSize);
09497     if (ex != NULL) SignDoc_throw (ex);
09498     return r;
09499   }
09500 
09557   ReturnCode setLength (const std::string &aName, ValueType aType,
09558                         double aValue)
09559   {
09560     SIGNDOC_Exception *ex = NULL;
09561     ReturnCode r;
09562     r = (ReturnCode)SIGNDOC_SignatureParameters_setLength (&ex, p, aName.c_str (), aType, aValue);
09563     if (ex != NULL) SignDoc_throw (ex);
09564     return r;
09565   }
09566 
09591   ReturnCode setColor (const std::string &aName, const SignDocColor &aValue)
09592   {
09593     SIGNDOC_Exception *ex = NULL;
09594     ReturnCode r;
09595     r = (ReturnCode)SIGNDOC_SignatureParameters_setColor (&ex, p, aName.c_str (), aValue.getImpl ());
09596     if (ex != NULL) SignDoc_throw (ex);
09597     return r;
09598   }
09599 
09624   ReturnCode addTextItem (TextItem aItem, TextGroup aGroup)
09625   {
09626     SIGNDOC_Exception *ex = NULL;
09627     ReturnCode r;
09628     r = (ReturnCode)SIGNDOC_SignatureParameters_addTextItem (&ex, p, aItem, aGroup);
09629     if (ex != NULL) SignDoc_throw (ex);
09630     return r;
09631   }
09632 
09663   ReturnCode addTextItem2 (TextItem aItem, TextGroup aGroup,
09664                            HAlignment aHAlignment, int aDirection)
09665   {
09666     SIGNDOC_Exception *ex = NULL;
09667     ReturnCode r;
09668     r = (ReturnCode)SIGNDOC_SignatureParameters_addTextItem2 (&ex, p, aItem, aGroup, aHAlignment, aDirection);
09669     if (ex != NULL) SignDoc_throw (ex);
09670     return r;
09671   }
09672 
09685   ReturnCode clearTextItems ()
09686   {
09687     SIGNDOC_Exception *ex = NULL;
09688     ReturnCode r;
09689     r = (ReturnCode)SIGNDOC_SignatureParameters_clearTextItems (&ex, p);
09690     if (ex != NULL) SignDoc_throw (ex);
09691     return r;
09692   }
09693 
09714   ReturnCode setTextItemDirection (TextItem aItem, HAlignment aHAlignment,
09715                                    int aDirection)
09716   {
09717     SIGNDOC_Exception *ex = NULL;
09718     ReturnCode r;
09719     r = (ReturnCode)SIGNDOC_SignatureParameters_setTextItemDirection (&ex, p, aItem, aHAlignment, aDirection);
09720     if (ex != NULL) SignDoc_throw (ex);
09721     return r;
09722   }
09723 
09766   ReturnCode setPKCS7 (SignPKCS7 *aPKCS7)
09767   {
09768     SIGNDOC_Exception *ex = NULL;
09769     ReturnCode r;
09770     r = (ReturnCode)SIGNDOC_SignatureParameters_setPKCS7 (&ex, p, aPKCS7 == NULL ? NULL : aPKCS7->getImpl ());
09771     if (ex != NULL) SignDoc_throw (ex);
09772     return r;
09773   }
09774 
09804   ReturnCode setRSA (SignRSA *aRSA)
09805   {
09806     SIGNDOC_Exception *ex = NULL;
09807     ReturnCode r;
09808     r = (ReturnCode)SIGNDOC_SignatureParameters_setRSA (&ex, p, aRSA == NULL ? NULL : aRSA->getImpl ());
09809     if (ex != NULL) SignDoc_throw (ex);
09810     return r;
09811   }
09812 
09842   ReturnCode setECDSA (SignECDSA *aECDSA)
09843   {
09844     SIGNDOC_Exception *ex = NULL;
09845     ReturnCode r;
09846     r = (ReturnCode)SIGNDOC_SignatureParameters_setECDSA (&ex, p, aECDSA == NULL ? NULL : aECDSA->getImpl ());
09847     if (ex != NULL) SignDoc_throw (ex);
09848     return r;
09849   }
09850 
09859   int getAvailableMethods ()
09860   {
09861     SIGNDOC_Exception *ex = NULL;
09862     int r;
09863     r = SIGNDOC_SignatureParameters_getAvailableMethods (&ex, p);
09864     if (ex != NULL) SignDoc_throw (ex);
09865     return r;
09866   }
09867 
09880   ReturnCode getTemplate (std::vector<unsigned char> &aOutput)
09881   {
09882     SIGNDOC_Exception *ex = NULL;
09883     SIGNDOC_ByteArray *tempOutput = NULL;
09884     ReturnCode r;
09885     try
09886       {
09887         tempOutput = SIGNDOC_ByteArray_new (&ex);
09888         if (ex != NULL) SignDoc_throw (ex);
09889         r = (ReturnCode)SIGNDOC_SignatureParameters_getTemplate (&ex, p, tempOutput);
09890         assignArray (aOutput, tempOutput);
09891       }
09892     catch (...)
09893       {
09894         if (tempOutput != NULL)
09895           SIGNDOC_ByteArray_delete (tempOutput);
09896         throw;
09897       }
09898     if (tempOutput != NULL)
09899       SIGNDOC_ByteArray_delete (tempOutput);
09900     if (ex != NULL) SignDoc_throw (ex);
09901     return r;
09902   }
09903 
09917   const char *getErrorMessage (Encoding aEncoding) const
09918   {
09919     SIGNDOC_Exception *ex = NULL;
09920     const char *r;
09921     r = SIGNDOC_SignatureParameters_getErrorMessage (&ex, p, aEncoding);
09922     if (ex != NULL) SignDoc_throw (ex);
09923     return r;
09924   }
09925 
09937   const wchar_t *getErrorMessageW () const
09938   {
09939     SIGNDOC_Exception *ex = NULL;
09940     const wchar_t *r;
09941     r = SIGNDOC_SignatureParameters_getErrorMessageW (&ex, p);
09942     if (ex != NULL) SignDoc_throw (ex);
09943     return r;
09944   }
09945 
09946 private:
09950   SignDocSignatureParameters (const SignDocSignatureParameters &);
09951 
09955   SignDocSignatureParameters &operator= (const SignDocSignatureParameters &);
09956 public:
09961   SignDocSignatureParameters (SIGNDOC_SignatureParameters *aP) : p (aP) { }
09962 
09967   SIGNDOC_SignatureParameters *getImpl () { return p; }
09968 
09973   const SIGNDOC_SignatureParameters *getImpl () const { return p; }
09974 
09979   void setImpl (SIGNDOC_SignatureParameters *aP) { SIGNDOC_SignatureParameters_delete (p); p  = aP; }
09980 
09981 private:
09982   SIGNDOC_SignatureParameters *p;
09983 };
09984 
09993 class SignDocProperty 
09994 {
09995 public:
09996 
09997 public:
10001   enum Type
10002   {
10003     t_string,
10004     t_integer,
10005     t_boolean
10006   };
10007 
10008 public:
10012   SignDocProperty ()
10013     : p (NULL)
10014   {
10015     SIGNDOC_Exception *ex = NULL;
10016     p = SIGNDOC_Property_new (&ex);
10017     if (ex != NULL) SignDoc_throw (ex);
10018   }
10019 
10025   SignDocProperty (const SignDocProperty &aSource)
10026     : p (NULL)
10027   {
10028     SIGNDOC_Exception *ex = NULL;
10029     p = SIGNDOC_Property_clone (&ex, aSource.getImpl ());
10030     if (ex != NULL) SignDoc_throw (ex);
10031   }
10032 
10036   ~SignDocProperty ()
10037   {
10038     SIGNDOC_Property_delete (p);
10039   }
10040 
10046   void swap (SignDocProperty &aOther)
10047   {
10048     std::swap (p, aOther.p);
10049   }
10050 
10066   std::string getName (Encoding aEncoding) const
10067   {
10068     SIGNDOC_Exception *ex = NULL;
10069     std::string r;
10070     char *s = SIGNDOC_Property_getName (&ex, p, aEncoding);
10071     if (ex != NULL) SignDoc_throw (ex);
10072     try
10073       {
10074         r = s;
10075       }
10076     catch (...)
10077       {
10078         SIGNDOC_free (s);
10079         throw;
10080       }
10081     SIGNDOC_free (s);
10082     return r;
10083   }
10084 
10096   const char *getNameUTF8 () const
10097   {
10098     SIGNDOC_Exception *ex = NULL;
10099     const char *r;
10100     r = SIGNDOC_Property_getNameUTF8 (&ex, p);
10101     if (ex != NULL) SignDoc_throw (ex);
10102     return r;
10103   }
10104 
10110   Type getType () const
10111   {
10112     SIGNDOC_Exception *ex = NULL;
10113     Type r;
10114     r = (Type)SIGNDOC_Property_getType (&ex, p);
10115     if (ex != NULL) SignDoc_throw (ex);
10116     return r;
10117   }
10118 
10119 private:
10120 public:
10125   SignDocProperty (SIGNDOC_Property *aP) : p (aP) { }
10126 
10131   SIGNDOC_Property *getImpl () { return p; }
10132 
10137   const SIGNDOC_Property *getImpl () const { return p; }
10138 
10143   void setImpl (SIGNDOC_Property *aP) { SIGNDOC_Property_delete (p); p  = aP; }
10144 
10145 private:
10146   SIGNDOC_Property *p;
10147 };
10148 
10153 inline void assignArray (std::vector<SignDocProperty> &aDst,
10154                          SIGNDOC_PropertyArray *aSrc)
10155 {
10156   aDst.clear ();
10157   unsigned n = SIGNDOC_PropertyArray_count (aSrc);
10158   if (aSrc == NULL)
10159     return;
10160   aDst.resize (n);
10161   for (unsigned i = 0; i < n; ++i)
10162     {
10163       SIGNDOC_Exception *ex = NULL;
10164       SIGNDOC_Property *p = SIGNDOC_Property_clone (&ex, SIGNDOC_PropertyArray_at (aSrc, i));
10165       if (ex != NULL) SignDoc_throw (ex);
10166       aDst[i].setImpl (p);
10167     }
10168 }
10169 
10177 class SignDocAnnotation 
10178 {
10179 public:
10185   enum Type
10186   {
10187     t_unknown,              
10188     t_line,                 
10189     t_scribble,             
10190     t_freetext              
10191   };
10192 
10196   enum LineEnding
10197   {
10198     le_unknown,             
10199     le_none,                
10200     le_arrow                
10201   };
10202 
10206   enum HAlignment
10207   {
10211     ha_left,
10212 
10216     ha_center,
10217 
10221     ha_right
10222   };
10223 
10227   enum Flags
10228   {
10237     f_auto_alignment = 0x200,
10238 
10250     f_ltr = 0x1000,
10251 
10271     f_rtl = 0x2000,
10272 
10299     f_default_ltr = 0x4000,
10300 
10327     f_default_rtl = 0x8000
10328   };
10329 
10333   enum ReturnCode
10334   {
10335     rc_ok,                      
10336     rc_not_supported,           
10337     rc_invalid_value,           
10338     rc_not_available            
10339   };
10340 
10341 protected:
10345   SignDocAnnotation ()
10346     : p (NULL)
10347   {
10348   }
10349 
10350 public:
10354   ~SignDocAnnotation ()
10355   {
10356     SIGNDOC_Annotation_delete (p);
10357   }
10358 
10364   Type getType () const
10365   {
10366     SIGNDOC_Exception *ex = NULL;
10367     Type r;
10368     r = (Type)SIGNDOC_Annotation_getType (&ex, p);
10369     if (ex != NULL) SignDoc_throw (ex);
10370     return r;
10371   }
10372 
10381   std::string getName (Encoding aEncoding) const
10382   {
10383     SIGNDOC_Exception *ex = NULL;
10384     std::string r;
10385     char *s = SIGNDOC_Annotation_getName (&ex, p, aEncoding);
10386     if (ex != NULL) SignDoc_throw (ex);
10387     try
10388       {
10389         r = s;
10390       }
10391     catch (...)
10392       {
10393         SIGNDOC_free (s);
10394         throw;
10395       }
10396     SIGNDOC_free (s);
10397     return r;
10398   }
10399 
10409   int getPage () const
10410   {
10411     SIGNDOC_Exception *ex = NULL;
10412     int r;
10413     r = SIGNDOC_Annotation_getPage (&ex, p);
10414     if (ex != NULL) SignDoc_throw (ex);
10415     return r;
10416   }
10417 
10429   ReturnCode getBoundingBox (Rect &aOutput) const
10430   {
10431     SIGNDOC_Exception *ex = NULL;
10432     ReturnCode r;
10433     r = (ReturnCode)SIGNDOC_Annotation_getBoundingBox (&ex, p, (SIGNDOC_Rect*)&aOutput);
10434     if (ex != NULL) SignDoc_throw (ex);
10435     return r;
10436   }
10437 
10450   ReturnCode setName (Encoding aEncoding, const std::string &aName)
10451   {
10452     SIGNDOC_Exception *ex = NULL;
10453     ReturnCode r;
10454     r = (ReturnCode)SIGNDOC_Annotation_setName (&ex, p, aEncoding, aName.c_str ());
10455     if (ex != NULL) SignDoc_throw (ex);
10456     return r;
10457   }
10458 
10470   ReturnCode setName (const wchar_t *aName)
10471   {
10472     SIGNDOC_Exception *ex = NULL;
10473     ReturnCode r;
10474     r = (ReturnCode)SIGNDOC_Annotation_setNameW (&ex, p, aName);
10475     if (ex != NULL) SignDoc_throw (ex);
10476     return r;
10477   }
10478 
10490   ReturnCode setLineEnding (LineEnding aStart, LineEnding aEnd)
10491   {
10492     SIGNDOC_Exception *ex = NULL;
10493     ReturnCode r;
10494     r = (ReturnCode)SIGNDOC_Annotation_setLineEnding (&ex, p, aStart, aEnd);
10495     if (ex != NULL) SignDoc_throw (ex);
10496     return r;
10497   }
10498 
10511   ReturnCode setColor (const SignDocColor &aColor)
10512   {
10513     SIGNDOC_Exception *ex = NULL;
10514     ReturnCode r;
10515     r = (ReturnCode)SIGNDOC_Annotation_setColor (&ex, p, aColor.getImpl ());
10516     if (ex != NULL) SignDoc_throw (ex);
10517     return r;
10518   }
10519 
10531   ReturnCode setBackgroundColor (const SignDocColor &aColor)
10532   {
10533     SIGNDOC_Exception *ex = NULL;
10534     ReturnCode r;
10535     r = (ReturnCode)SIGNDOC_Annotation_setBackgroundColor (&ex, p, aColor.getImpl ());
10536     if (ex != NULL) SignDoc_throw (ex);
10537     return r;
10538   }
10539 
10553   ReturnCode setBorderColor (const SignDocColor &aColor)
10554   {
10555     SIGNDOC_Exception *ex = NULL;
10556     ReturnCode r;
10557     r = (ReturnCode)SIGNDOC_Annotation_setBorderColor (&ex, p, aColor.getImpl ());
10558     if (ex != NULL) SignDoc_throw (ex);
10559     return r;
10560   }
10561 
10575   ReturnCode setOpacity (double aOpacity)
10576   {
10577     SIGNDOC_Exception *ex = NULL;
10578     ReturnCode r;
10579     r = (ReturnCode)SIGNDOC_Annotation_setOpacity (&ex, p, aOpacity);
10580     if (ex != NULL) SignDoc_throw (ex);
10581     return r;
10582   }
10583 
10594   ReturnCode setLineWidthInPoints (double aWidth)
10595   {
10596     SIGNDOC_Exception *ex = NULL;
10597     ReturnCode r;
10598     r = (ReturnCode)SIGNDOC_Annotation_setLineWidthInPoints (&ex, p, aWidth);
10599     if (ex != NULL) SignDoc_throw (ex);
10600     return r;
10601   }
10602 
10616   ReturnCode setBorderLineWidthInPoints (double aWidth)
10617   {
10618     SIGNDOC_Exception *ex = NULL;
10619     ReturnCode r;
10620     r = (ReturnCode)SIGNDOC_Annotation_setBorderLineWidthInPoints (&ex, p, aWidth);
10621     if (ex != NULL) SignDoc_throw (ex);
10622     return r;
10623   }
10624 
10636   ReturnCode newStroke ()
10637   {
10638     SIGNDOC_Exception *ex = NULL;
10639     ReturnCode r;
10640     r = (ReturnCode)SIGNDOC_Annotation_newStroke (&ex, p);
10641     if (ex != NULL) SignDoc_throw (ex);
10642     return r;
10643   }
10644 
10659   ReturnCode addPoint (const Point &aPoint)
10660   {
10661     SIGNDOC_Exception *ex = NULL;
10662     ReturnCode r;
10663     r = (ReturnCode)SIGNDOC_Annotation_addPoint (&ex, p, (const SIGNDOC_Point*)&aPoint);
10664     if (ex != NULL) SignDoc_throw (ex);
10665     return r;
10666   }
10667 
10683   ReturnCode addPoint (double aX, double aY)
10684   {
10685     SIGNDOC_Exception *ex = NULL;
10686     ReturnCode r;
10687     r = (ReturnCode)SIGNDOC_Annotation_addPointXY (&ex, p, aX, aY);
10688     if (ex != NULL) SignDoc_throw (ex);
10689     return r;
10690   }
10691 
10729   ReturnCode setPlainText (Encoding aEncoding, const std::string &aText,
10730                            const std::string &aFont, double aFontSize,
10731                            HAlignment aHAlignment)
10732   {
10733     SIGNDOC_Exception *ex = NULL;
10734     ReturnCode r;
10735     r = (ReturnCode)SIGNDOC_Annotation_setPlainText (&ex, p, aEncoding, aText.c_str (), aFont.c_str (), aFontSize, aHAlignment);
10736     if (ex != NULL) SignDoc_throw (ex);
10737     return r;
10738   }
10739 
10754   ReturnCode getPlainText (Encoding aEncoding, std::string &aText)
10755   {
10756     SIGNDOC_Exception *ex = NULL;
10757     char *tempText = NULL;
10758     ReturnCode r;
10759     try
10760       {
10761         r = (ReturnCode)SIGNDOC_Annotation_getPlainText (&ex, p, aEncoding, &tempText);
10762         if (tempText != NULL)
10763           aText = tempText;
10764       }
10765     catch (...)
10766       {
10767         SIGNDOC_free (tempText);
10768         throw;
10769       }
10770     SIGNDOC_free (tempText);
10771     if (ex != NULL) SignDoc_throw (ex);
10772     return r;
10773   }
10774 
10791   ReturnCode getFont (Encoding aEncoding, std::string &aFont,
10792                       double &aFontSize)
10793   {
10794     SIGNDOC_Exception *ex = NULL;
10795     char *tempFont = NULL;
10796     ReturnCode r;
10797     try
10798       {
10799         r = (ReturnCode)SIGNDOC_Annotation_getFont (&ex, p, aEncoding, &tempFont, &aFontSize);
10800         if (tempFont != NULL)
10801           aFont = tempFont;
10802       }
10803     catch (...)
10804       {
10805         SIGNDOC_free (tempFont);
10806         throw;
10807       }
10808     SIGNDOC_free (tempFont);
10809     if (ex != NULL) SignDoc_throw (ex);
10810     return r;
10811   }
10812 
10825   ReturnCode setFlags (int aFlags)
10826   {
10827     SIGNDOC_Exception *ex = NULL;
10828     ReturnCode r;
10829     r = (ReturnCode)SIGNDOC_Annotation_setFlags (&ex, p, aFlags);
10830     if (ex != NULL) SignDoc_throw (ex);
10831     return r;
10832   }
10837   SignDocAnnotation (SIGNDOC_Annotation *aP) : p (aP) { }
10838 
10843   SIGNDOC_Annotation *getImpl () { return p; }
10844 
10849   const SIGNDOC_Annotation *getImpl () const { return p; }
10850 
10855   void setImpl (SIGNDOC_Annotation *aP) { SIGNDOC_Annotation_delete (p); p  = aP; }
10856 
10857 private:
10858   SIGNDOC_Annotation *p;
10859 };
10860 
10866 class SignDocCharacterPosition 
10867 {
10868 public:
10869   int mPage;                    
10870   Point mRef; 
10871   Rect mBox;  
10872 };
10873 
10877 class SignDocFindTextPosition 
10878 {
10879 public:
10880   SignDocCharacterPosition mFirst;   
10881   SignDocCharacterPosition mLast;    
10882 };
10883 
10888 inline void assignArray (std::vector<SignDocFindTextPosition> &aDst,
10889                          SIGNDOC_FindTextPositionArray *aSrc)
10890 {
10891   if (aSrc == NULL)
10892     aDst.clear ();
10893   else
10894     {
10895       unsigned n = SIGNDOC_FindTextPositionArray_count (aSrc);
10896       aDst.resize (n);
10897       for (unsigned i = 0; i < n; ++i)
10898         aDst[i] = *(const SignDocFindTextPosition*)SIGNDOC_FindTextPositionArray_at (aSrc, i);
10899     }
10900 }
10901 
10905 class SignDocRenderParameters 
10906 {
10907 public:
10911   enum Interlacing
10912   {
10916     i_off,
10917 
10923     i_on
10924   };
10925 
10929   enum Quality
10930   {
10934     q_low,
10935 
10939     q_high
10940   };
10941 
10945   enum PixelFormat
10946   {
10950     pf_default,
10951 
10955     pf_bw
10956   };
10957 
10964   enum Compression
10965   {
10966     c_default,     
10967     c_none,        
10968     c_group4,      
10969     c_lzw,         
10970     c_rle,         
10971     c_zip          
10972   };
10973 
10979   enum DecorationState
10980   {
10981     ds_auto,       
10982     ds_empty,      
10983     ds_ok,         
10984     ds_problem,    
10985     ds_broken      
10986   };
10987 
10988 public:
10992   SignDocRenderParameters ()
10993     : p (NULL)
10994   {
10995     SIGNDOC_Exception *ex = NULL;
10996     p = SIGNDOC_RenderParameters_new (&ex);
10997     if (ex != NULL) SignDoc_throw (ex);
10998   }
10999 
11005   SignDocRenderParameters (const SignDocRenderParameters &aSource)
11006     : p (NULL)
11007   {
11008     SIGNDOC_Exception *ex = NULL;
11009     p = SIGNDOC_RenderParameters_clone (&ex, aSource.getImpl ());
11010     if (ex != NULL) SignDoc_throw (ex);
11011   }
11012 
11016   ~SignDocRenderParameters ()
11017   {
11018     SIGNDOC_RenderParameters_delete (p);
11019   }
11020 
11026   SignDocRenderParameters &operator= (const SignDocRenderParameters &aSource)
11027   {
11028     SIGNDOC_Exception *ex = NULL;
11029     SIGNDOC_RenderParameters_assign (&ex, p, aSource.getImpl ());
11030     if (ex != NULL) SignDoc_throw (ex);
11031     return *this;
11032   }
11033 
11046   bool setPage (int aPage)
11047   {
11048     SIGNDOC_Exception *ex = NULL;
11049     bool r;
11050     r = (bool)SIGNDOC_RenderParameters_setPage (&ex, p, aPage);
11051     if (ex != NULL) SignDoc_throw (ex);
11052     return r;
11053   }
11054 
11067   bool getPage (int &aPage) const
11068   {
11069     SIGNDOC_Exception *ex = NULL;
11070     bool r;
11071     r = (bool)SIGNDOC_RenderParameters_getPage (&ex, p, &aPage);
11072     if (ex != NULL) SignDoc_throw (ex);
11073     return r;
11074   }
11075 
11095   bool setPages (int aFirst, int aLast)
11096   {
11097     SIGNDOC_Exception *ex = NULL;
11098     bool r;
11099     r = (bool)SIGNDOC_RenderParameters_setPages (&ex, p, aFirst, aLast);
11100     if (ex != NULL) SignDoc_throw (ex);
11101     return r;
11102   }
11103 
11119   bool getPages (int &aFirst, int &aLast) const
11120   {
11121     SIGNDOC_Exception *ex = NULL;
11122     bool r;
11123     r = (bool)SIGNDOC_RenderParameters_getPages (&ex, p, &aFirst, &aLast);
11124     if (ex != NULL) SignDoc_throw (ex);
11125     return r;
11126   }
11127 
11144   bool setResolution (double aResX, double aResY)
11145   {
11146     SIGNDOC_Exception *ex = NULL;
11147     bool r;
11148     r = (bool)SIGNDOC_RenderParameters_setResolution (&ex, p, aResX, aResY);
11149     if (ex != NULL) SignDoc_throw (ex);
11150     return r;
11151   }
11152 
11163   bool getResolution (double &aResX, double &aResY) const
11164   {
11165     SIGNDOC_Exception *ex = NULL;
11166     bool r;
11167     r = (bool)SIGNDOC_RenderParameters_getResolution (&ex, p, &aResX, &aResY);
11168     if (ex != NULL) SignDoc_throw (ex);
11169     return r;
11170   }
11171 
11185   bool setZoom (double aZoom)
11186   {
11187     SIGNDOC_Exception *ex = NULL;
11188     bool r;
11189     r = (bool)SIGNDOC_RenderParameters_setZoom (&ex, p, aZoom);
11190     if (ex != NULL) SignDoc_throw (ex);
11191     return r;
11192   }
11193 
11208   bool getZoom (double &aZoom) const
11209   {
11210     SIGNDOC_Exception *ex = NULL;
11211     bool r;
11212     r = (bool)SIGNDOC_RenderParameters_getZoom (&ex, p, &aZoom);
11213     if (ex != NULL) SignDoc_throw (ex);
11214     return r;
11215   }
11216 
11230   bool fitWidth (int aWidth)
11231   {
11232     SIGNDOC_Exception *ex = NULL;
11233     bool r;
11234     r = (bool)SIGNDOC_RenderParameters_fitWidth (&ex, p, aWidth);
11235     if (ex != NULL) SignDoc_throw (ex);
11236     return r;
11237   }
11238 
11249   bool getFitWidth (int &aWidth) const
11250   {
11251     SIGNDOC_Exception *ex = NULL;
11252     bool r;
11253     r = (bool)SIGNDOC_RenderParameters_getFitWidth (&ex, p, &aWidth);
11254     if (ex != NULL) SignDoc_throw (ex);
11255     return r;
11256   }
11257 
11271   bool fitHeight (int aHeight)
11272   {
11273     SIGNDOC_Exception *ex = NULL;
11274     bool r;
11275     r = (bool)SIGNDOC_RenderParameters_fitHeight (&ex, p, aHeight);
11276     if (ex != NULL) SignDoc_throw (ex);
11277     return r;
11278   }
11279 
11290   bool getFitHeight (int &aHeight) const
11291   {
11292     SIGNDOC_Exception *ex = NULL;
11293     bool r;
11294     r = (bool)SIGNDOC_RenderParameters_getFitHeight (&ex, p, &aHeight);
11295     if (ex != NULL) SignDoc_throw (ex);
11296     return r;
11297   }
11298 
11315   bool fitRect (int aWidth, int aHeight)
11316   {
11317     SIGNDOC_Exception *ex = NULL;
11318     bool r;
11319     r = (bool)SIGNDOC_RenderParameters_fitRect (&ex, p, aWidth, aHeight);
11320     if (ex != NULL) SignDoc_throw (ex);
11321     return r;
11322   }
11323 
11335   bool getFitRect (int &aWidth, int &aHeight) const
11336   {
11337     SIGNDOC_Exception *ex = NULL;
11338     bool r;
11339     r = (bool)SIGNDOC_RenderParameters_getFitRect (&ex, p, &aWidth, &aHeight);
11340     if (ex != NULL) SignDoc_throw (ex);
11341     return r;
11342   }
11343 
11358   bool setFormat (const std::string &aFormat)
11359   {
11360     SIGNDOC_Exception *ex = NULL;
11361     bool r;
11362     r = (bool)SIGNDOC_RenderParameters_setFormat (&ex, p, aFormat.c_str ());
11363     if (ex != NULL) SignDoc_throw (ex);
11364     return r;
11365   }
11366 
11377   bool getFormat (std::string &aFormat) const
11378   {
11379     SIGNDOC_Exception *ex = NULL;
11380     char *tempFormat = NULL;
11381     bool r;
11382     try
11383       {
11384         r = (bool)SIGNDOC_RenderParameters_getFormat (&ex, p, &tempFormat);
11385         if (tempFormat != NULL)
11386           aFormat = tempFormat;
11387       }
11388     catch (...)
11389       {
11390         SIGNDOC_free (tempFormat);
11391         throw;
11392       }
11393     SIGNDOC_free (tempFormat);
11394     if (ex != NULL) SignDoc_throw (ex);
11395     return r;
11396   }
11397 
11410   bool setInterlacing (Interlacing aInterlacing)
11411   {
11412     SIGNDOC_Exception *ex = NULL;
11413     bool r;
11414     r = (bool)SIGNDOC_RenderParameters_setInterlacing (&ex, p, aInterlacing);
11415     if (ex != NULL) SignDoc_throw (ex);
11416     return r;
11417   }
11418 
11429   bool getInterlacing (Interlacing &aInterlacing) const
11430   {
11431     SIGNDOC_Exception *ex = NULL;
11432     int tempInterlacing = 0;
11433     bool r;
11434     try
11435       {
11436         r = (bool)SIGNDOC_RenderParameters_getInterlacing (&ex, p, &tempInterlacing);
11437         aInterlacing = (Interlacing )tempInterlacing;
11438       }
11439     catch (...)
11440       {
11441         throw;
11442       }
11443     if (ex != NULL) SignDoc_throw (ex);
11444     return r;
11445   }
11446 
11459   bool setQuality (Quality aQuality)
11460   {
11461     SIGNDOC_Exception *ex = NULL;
11462     bool r;
11463     r = (bool)SIGNDOC_RenderParameters_setQuality (&ex, p, aQuality);
11464     if (ex != NULL) SignDoc_throw (ex);
11465     return r;
11466   }
11467 
11477   bool getQuality (Quality &aQuality) const
11478   {
11479     SIGNDOC_Exception *ex = NULL;
11480     int tempQuality = 0;
11481     bool r;
11482     try
11483       {
11484         r = (bool)SIGNDOC_RenderParameters_getQuality (&ex, p, &tempQuality);
11485         aQuality = (Quality )tempQuality;
11486       }
11487     catch (...)
11488       {
11489         throw;
11490       }
11491     if (ex != NULL) SignDoc_throw (ex);
11492     return r;
11493   }
11494 
11506   bool setPixelFormat (PixelFormat aPixelFormat)
11507   {
11508     SIGNDOC_Exception *ex = NULL;
11509     bool r;
11510     r = (bool)SIGNDOC_RenderParameters_setPixelFormat (&ex, p, aPixelFormat);
11511     if (ex != NULL) SignDoc_throw (ex);
11512     return r;
11513   }
11514 
11524   bool getPixelFormat (PixelFormat &aPixelFormat) const
11525   {
11526     SIGNDOC_Exception *ex = NULL;
11527     int tempPixelFormat = 0;
11528     bool r;
11529     try
11530       {
11531         r = (bool)SIGNDOC_RenderParameters_getPixelFormat (&ex, p, &tempPixelFormat);
11532         aPixelFormat = (PixelFormat )tempPixelFormat;
11533       }
11534     catch (...)
11535       {
11536         throw;
11537       }
11538     if (ex != NULL) SignDoc_throw (ex);
11539     return r;
11540   }
11541 
11553   bool setCompression (Compression aCompression)
11554   {
11555     SIGNDOC_Exception *ex = NULL;
11556     bool r;
11557     r = (bool)SIGNDOC_RenderParameters_setCompression (&ex, p, aCompression);
11558     if (ex != NULL) SignDoc_throw (ex);
11559     return r;
11560   }
11561 
11571   bool getCompression (Compression &aCompression) const
11572   {
11573     SIGNDOC_Exception *ex = NULL;
11574     int tempCompression = 0;
11575     bool r;
11576     try
11577       {
11578         r = (bool)SIGNDOC_RenderParameters_getCompression (&ex, p, &tempCompression);
11579         aCompression = (Compression )tempCompression;
11580       }
11581     catch (...)
11582       {
11583         throw;
11584       }
11585     if (ex != NULL) SignDoc_throw (ex);
11586     return r;
11587   }
11588 
11627   bool setDecorations (bool aDecorations)
11628   {
11629     SIGNDOC_Exception *ex = NULL;
11630     bool r;
11631     r = (bool)SIGNDOC_RenderParameters_setDecorations (&ex, p, aDecorations);
11632     if (ex != NULL) SignDoc_throw (ex);
11633     return r;
11634   }
11635 
11645   bool getDecorations (bool &aDecorations) const
11646   {
11647     SIGNDOC_Exception *ex = NULL;
11648     SIGNDOC_Boolean tempDecorations = 0;
11649     bool r;
11650     try
11651       {
11652         r = (bool)SIGNDOC_RenderParameters_getDecorations (&ex, p, &tempDecorations);
11653         aDecorations = (bool )tempDecorations;
11654       }
11655     catch (...)
11656       {
11657         throw;
11658       }
11659     if (ex != NULL) SignDoc_throw (ex);
11660     return r;
11661   }
11662 
11683   bool setDecorationState (Encoding aEncoding, const std::string &aName,
11684                            DecorationState aDecorationState)
11685   {
11686     SIGNDOC_Exception *ex = NULL;
11687     bool r;
11688     r = (bool)SIGNDOC_RenderParameters_setDecorationState (&ex, p, aEncoding, aName.c_str (), aDecorationState);
11689     if (ex != NULL) SignDoc_throw (ex);
11690     return r;
11691   }
11692 
11712   bool setDecorationState (const wchar_t *aName,
11713                            DecorationState aDecorationState)
11714   {
11715     SIGNDOC_Exception *ex = NULL;
11716     bool r;
11717     r = (bool)SIGNDOC_RenderParameters_setDecorationStateW (&ex, p, aName, aDecorationState);
11718     if (ex != NULL) SignDoc_throw (ex);
11719     return r;
11720   }
11721 
11736   bool getDecorationState (Encoding aEncoding, const std::string &aName,
11737                            DecorationState &aDecorationState) const
11738   {
11739     SIGNDOC_Exception *ex = NULL;
11740     int tempDecorationState = 0;
11741     bool r;
11742     try
11743       {
11744         r = (bool)SIGNDOC_RenderParameters_getDecorationState (&ex, p, aEncoding, aName.c_str (), &tempDecorationState);
11745         aDecorationState = (DecorationState )tempDecorationState;
11746       }
11747     catch (...)
11748       {
11749         throw;
11750       }
11751     if (ex != NULL) SignDoc_throw (ex);
11752     return r;
11753   }
11754 
11768   bool getDecorationState (const wchar_t *aName,
11769                            DecorationState &aDecorationState) const
11770   {
11771     SIGNDOC_Exception *ex = NULL;
11772     int tempDecorationState = 0;
11773     bool r;
11774     try
11775       {
11776         r = (bool)SIGNDOC_RenderParameters_getDecorationStateW (&ex, p, aName, &tempDecorationState);
11777         aDecorationState = (DecorationState )tempDecorationState;
11778       }
11779     catch (...)
11780       {
11781         throw;
11782       }
11783     if (ex != NULL) SignDoc_throw (ex);
11784     return r;
11785   }
11786                                
11799   bool setPrint (bool aPrint)
11800   {
11801     SIGNDOC_Exception *ex = NULL;
11802     bool r;
11803     r = (bool)SIGNDOC_RenderParameters_setPrint (&ex, p, aPrint);
11804     if (ex != NULL) SignDoc_throw (ex);
11805     return r;
11806   }
11807 
11817   bool getPrint (bool &aPrint) const
11818   {
11819     SIGNDOC_Exception *ex = NULL;
11820     SIGNDOC_Boolean tempPrint = 0;
11821     bool r;
11822     try
11823       {
11824         r = (bool)SIGNDOC_RenderParameters_getPrint (&ex, p, &tempPrint);
11825         aPrint = (bool )tempPrint;
11826       }
11827     catch (...)
11828       {
11829         throw;
11830       }
11831     if (ex != NULL) SignDoc_throw (ex);
11832     return r;
11833   }
11834 
11848   bool setModificationState (bool aCheck)
11849   {
11850     SIGNDOC_Exception *ex = NULL;
11851     bool r;
11852     r = (bool)SIGNDOC_RenderParameters_setModificationState (&ex, p, aCheck);
11853     if (ex != NULL) SignDoc_throw (ex);
11854     return r;
11855   }
11856 
11866   bool getModificationState (bool &aCheck) const
11867   {
11868     SIGNDOC_Exception *ex = NULL;
11869     SIGNDOC_Boolean tempCheck = 0;
11870     bool r;
11871     try
11872       {
11873         r = (bool)SIGNDOC_RenderParameters_getModificationState (&ex, p, &tempCheck);
11874         aCheck = (bool )tempCheck;
11875       }
11876     catch (...)
11877       {
11878         throw;
11879       }
11880     if (ex != NULL) SignDoc_throw (ex);
11881     return r;
11882   }
11883 
11891   bool operator== (const SignDocRenderParameters &aRHS) const
11892   {
11893     SIGNDOC_Exception *ex = NULL;
11894     bool r;
11895     r = (bool)SIGNDOC_RenderParameters_equals (&ex, p, aRHS.getImpl ());
11896     if (ex != NULL) SignDoc_throw (ex);
11897     return r;
11898   }
11899 
11900 private:
11901 public:
11906   SignDocRenderParameters (SIGNDOC_RenderParameters *aP) : p (aP) { }
11907 
11912   SIGNDOC_RenderParameters *getImpl () { return p; }
11913 
11918   const SIGNDOC_RenderParameters *getImpl () const { return p; }
11919 
11924   void setImpl (SIGNDOC_RenderParameters *aP) { SIGNDOC_RenderParameters_delete (p); p  = aP; }
11925 
11926 private:
11927   SIGNDOC_RenderParameters *p;
11928 };
11929 
11936 class SignDocRenderOutput 
11937 {
11938 public:
11942   int mWidth;
11943 
11947   int mHeight;
11948 };
11949 
11953 class SignDocAttachment 
11954 {
11955 public:
11956 
11957 public:
11961   SignDocAttachment ()
11962     : p (NULL)
11963   {
11964     SIGNDOC_Exception *ex = NULL;
11965     p = SIGNDOC_Attachment_new (&ex);
11966     if (ex != NULL) SignDoc_throw (ex);
11967   }
11968 
11974   SignDocAttachment (const SignDocAttachment &aSource)
11975     : p (NULL)
11976   {
11977     SIGNDOC_Exception *ex = NULL;
11978     p = SIGNDOC_Attachment_clone (&ex, aSource.getImpl ());
11979     if (ex != NULL) SignDoc_throw (ex);
11980   }
11981 
11985   ~SignDocAttachment ()
11986   {
11987     SIGNDOC_Attachment_delete (p);
11988   }
11989 
11995   SignDocAttachment &operator= (const SignDocAttachment &aSource)
11996   {
11997     SIGNDOC_Exception *ex = NULL;
11998     SIGNDOC_Attachment_assign (&ex, p, aSource.getImpl ());
11999     if (ex != NULL) SignDoc_throw (ex);
12000     return *this;
12001   }
12002 
12008   void swap (SignDocAttachment &aOther)
12009   {
12010     std::swap (p, aOther.p);
12011   }
12012 
12025   std::string getName (Encoding aEncoding) const
12026   {
12027     SIGNDOC_Exception *ex = NULL;
12028     std::string r;
12029     char *s = SIGNDOC_Attachment_getName (&ex, p, aEncoding);
12030     if (ex != NULL) SignDoc_throw (ex);
12031     try
12032       {
12033         r = s;
12034       }
12035     catch (...)
12036       {
12037         SIGNDOC_free (s);
12038         throw;
12039       }
12040     SIGNDOC_free (s);
12041     return r;
12042   }
12043 
12052   const char *getNameUTF8 () const
12053   {
12054     SIGNDOC_Exception *ex = NULL;
12055     const char *r;
12056     r = SIGNDOC_Attachment_getNameUTF8 (&ex, p);
12057     if (ex != NULL) SignDoc_throw (ex);
12058     return r;
12059   }
12060 
12073   std::string getFileName (Encoding aEncoding) const
12074   {
12075     SIGNDOC_Exception *ex = NULL;
12076     std::string r;
12077     char *s = SIGNDOC_Attachment_getFileName (&ex, p, aEncoding);
12078     if (ex != NULL) SignDoc_throw (ex);
12079     try
12080       {
12081         r = s;
12082       }
12083     catch (...)
12084       {
12085         SIGNDOC_free (s);
12086         throw;
12087       }
12088     SIGNDOC_free (s);
12089     return r;
12090   }
12091 
12100   const char *getFileNameUTF8 () const
12101   {
12102     SIGNDOC_Exception *ex = NULL;
12103     const char *r;
12104     r = SIGNDOC_Attachment_getFileNameUTF8 (&ex, p);
12105     if (ex != NULL) SignDoc_throw (ex);
12106     return r;
12107   }
12108 
12123   std::string getDescription (Encoding aEncoding) const
12124   {
12125     SIGNDOC_Exception *ex = NULL;
12126     std::string r;
12127     char *s = SIGNDOC_Attachment_getDescription (&ex, p, aEncoding);
12128     if (ex != NULL) SignDoc_throw (ex);
12129     try
12130       {
12131         r = s;
12132       }
12133     catch (...)
12134       {
12135         SIGNDOC_free (s);
12136         throw;
12137       }
12138     SIGNDOC_free (s);
12139     return r;
12140   }
12141 
12152   const char *getDescriptionUTF8 () const
12153   {
12154     SIGNDOC_Exception *ex = NULL;
12155     const char *r;
12156     r = SIGNDOC_Attachment_getDescriptionUTF8 (&ex, p);
12157     if (ex != NULL) SignDoc_throw (ex);
12158     return r;
12159   }
12160 
12171   int getSize () const
12172   {
12173     SIGNDOC_Exception *ex = NULL;
12174     int r;
12175     r = SIGNDOC_Attachment_getSize (&ex, p);
12176     if (ex != NULL) SignDoc_throw (ex);
12177     return r;
12178   }
12179 
12187   int getCompressedSize () const
12188   {
12189     SIGNDOC_Exception *ex = NULL;
12190     int r;
12191     r = SIGNDOC_Attachment_getCompressedSize (&ex, p);
12192     if (ex != NULL) SignDoc_throw (ex);
12193     return r;
12194   }
12195 
12204   const char *getType () const
12205   {
12206     SIGNDOC_Exception *ex = NULL;
12207     const char *r;
12208     r = SIGNDOC_Attachment_getType (&ex, p);
12209     if (ex != NULL) SignDoc_throw (ex);
12210     return r;
12211   }
12212 
12232   const char *getCreationTime () const
12233   {
12234     SIGNDOC_Exception *ex = NULL;
12235     const char *r;
12236     r = SIGNDOC_Attachment_getCreationTime (&ex, p);
12237     if (ex != NULL) SignDoc_throw (ex);
12238     return r;
12239   }
12240 
12261   const char *getModificationTime () const
12262   {
12263     SIGNDOC_Exception *ex = NULL;
12264     const char *r;
12265     r = SIGNDOC_Attachment_getModificationTime (&ex, p);
12266     if (ex != NULL) SignDoc_throw (ex);
12267     return r;
12268   }
12269 
12270 private:
12271 public:
12276   SignDocAttachment (SIGNDOC_Attachment *aP) : p (aP) { }
12277 
12282   SIGNDOC_Attachment *getImpl () { return p; }
12283 
12288   const SIGNDOC_Attachment *getImpl () const { return p; }
12289 
12294   void setImpl (SIGNDOC_Attachment *aP) { SIGNDOC_Attachment_delete (p); p  = aP; }
12295 
12296 private:
12297   SIGNDOC_Attachment *p;
12298 };
12299 
12308 class SignDocWatermark 
12309 {
12310 public:
12311 
12315   enum Justification
12316   {
12317     j_left, j_center, j_right
12318   };
12319 
12323   enum Location
12324   {
12325     l_overlay,                  
12326     l_underlay                  
12327   };
12328 
12332   enum HAlignment
12333   {
12337     ha_left,
12338 
12342     ha_center,
12343 
12347     ha_right
12348   };
12349 
12353   enum VAlignment
12354   {
12358     va_top,
12359 
12363     va_center,
12364 
12368     va_bottom
12369   };
12370 
12374   enum Flags
12375   {
12385     f_ltr = 0x1000,
12386 
12396     f_rtl = 0x2000,
12397 
12414     f_default_ltr = 0x4000,
12415 
12432     f_default_rtl = 0x8000
12433   };
12434 
12435 public:
12441   SignDocWatermark ()
12442     : p (NULL)
12443   {
12444     SIGNDOC_Exception *ex = NULL;
12445     p = SIGNDOC_Watermark_new (&ex);
12446     if (ex != NULL) SignDoc_throw (ex);
12447   }
12448 
12454   SignDocWatermark (const SignDocWatermark &aSource)
12455     : p (NULL)
12456   {
12457     SIGNDOC_Exception *ex = NULL;
12458     p = SIGNDOC_Watermark_clone (&ex, aSource.getImpl ());
12459     if (ex != NULL) SignDoc_throw (ex);
12460   }
12461 
12465   ~SignDocWatermark ()
12466   {
12467     SIGNDOC_Watermark_delete (p);
12468   }
12469 
12475   SignDocWatermark &operator= (const SignDocWatermark &aSource)
12476   {
12477     SIGNDOC_Exception *ex = NULL;
12478     SIGNDOC_Watermark_assign (&ex, p, aSource.getImpl ());
12479     if (ex != NULL) SignDoc_throw (ex);
12480     return *this;
12481   }
12482 
12488   void swap (SignDocWatermark &aOther)
12489   {
12490     std::swap (p, aOther.p);
12491   }
12492 
12496   void clear ()
12497   {
12498     SIGNDOC_Exception *ex = NULL;
12499     SIGNDOC_Watermark_clear (&ex, p);
12500     if (ex != NULL) SignDoc_throw (ex);
12501   }
12502 
12523   void setText (Encoding aEncoding, const std::string &aText)
12524   {
12525     SIGNDOC_Exception *ex = NULL;
12526     SIGNDOC_Watermark_setText (&ex, p, aEncoding, aText.c_str ());
12527     if (ex != NULL) SignDoc_throw (ex);
12528   }
12529 
12544   void setFontName (Encoding aEncoding, const std::string &aFontName)
12545   {
12546     SIGNDOC_Exception *ex = NULL;
12547     SIGNDOC_Watermark_setFontName (&ex, p, aEncoding, aFontName.c_str ());
12548     if (ex != NULL) SignDoc_throw (ex);
12549   }
12550 
12560   void setFontSize (double aFontSize)
12561   {
12562     SIGNDOC_Exception *ex = NULL;
12563     SIGNDOC_Watermark_setFontSize (&ex, p, aFontSize);
12564     if (ex != NULL) SignDoc_throw (ex);
12565   }
12566 
12574   void setTextColor (const SignDocColor &aTextColor)
12575   {
12576     SIGNDOC_Exception *ex = NULL;
12577     SIGNDOC_Watermark_setTextColor (&ex, p, aTextColor.getImpl ());
12578     if (ex != NULL) SignDoc_throw (ex);
12579   }
12580 
12593   void setJustification (Justification aJustification)
12594   {
12595     SIGNDOC_Exception *ex = NULL;
12596     SIGNDOC_Watermark_setJustification (&ex, p, aJustification);
12597     if (ex != NULL) SignDoc_throw (ex);
12598   }
12599 
12609   void setRotation (double aRotation)
12610   {
12611     SIGNDOC_Exception *ex = NULL;
12612     SIGNDOC_Watermark_setRotation (&ex, p, aRotation);
12613     if (ex != NULL) SignDoc_throw (ex);
12614   }
12615 
12626   void setOpacity (double aOpacity)
12627   {
12628     SIGNDOC_Exception *ex = NULL;
12629     SIGNDOC_Watermark_setOpacity (&ex, p, aOpacity);
12630     if (ex != NULL) SignDoc_throw (ex);
12631   }
12632 
12642   void setScale (double aScale)
12643   {
12644     SIGNDOC_Exception *ex = NULL;
12645     SIGNDOC_Watermark_setScale (&ex, p, aScale);
12646     if (ex != NULL) SignDoc_throw (ex);
12647   }
12648 
12659   void setLocation (Location aLocation)
12660   {
12661     SIGNDOC_Exception *ex = NULL;
12662     SIGNDOC_Watermark_setLocation (&ex, p, aLocation);
12663     if (ex != NULL) SignDoc_throw (ex);
12664   }
12665 
12685   void setHorizontalPosition (HAlignment aAlignment, double aDistance)
12686   {
12687     SIGNDOC_Exception *ex = NULL;
12688     SIGNDOC_Watermark_setHorizontalPosition (&ex, p, aAlignment, aDistance);
12689     if (ex != NULL) SignDoc_throw (ex);
12690   }
12691 
12710   void setVerticalPosition (VAlignment aAlignment, double aDistance)
12711   {
12712     SIGNDOC_Exception *ex = NULL;
12713     SIGNDOC_Watermark_setVerticalPosition (&ex, p, aAlignment, aDistance);
12714     if (ex != NULL) SignDoc_throw (ex);
12715   }
12716 
12726   void setFirstPage (int aPage)
12727   {
12728     SIGNDOC_Exception *ex = NULL;
12729     SIGNDOC_Watermark_setFirstPage (&ex, p, aPage);
12730     if (ex != NULL) SignDoc_throw (ex);
12731   }
12732 
12743   void setLastPage (int aPage)
12744   {
12745     SIGNDOC_Exception *ex = NULL;
12746     SIGNDOC_Watermark_setLastPage (&ex, p, aPage);
12747     if (ex != NULL) SignDoc_throw (ex);
12748   }
12749 
12761   void setPageIncrement (int aIncr)
12762   {
12763     SIGNDOC_Exception *ex = NULL;
12764     SIGNDOC_Watermark_setPageIncrement (&ex, p, aIncr);
12765     if (ex != NULL) SignDoc_throw (ex);
12766   }
12767 
12777   void setFlags (int aFlags)
12778   {
12779     SIGNDOC_Exception *ex = NULL;
12780     SIGNDOC_Watermark_setFlags (&ex, p, aFlags);
12781     if (ex != NULL) SignDoc_throw (ex);
12782   }
12783 
12784 private:
12785 public:
12790   SignDocWatermark (SIGNDOC_Watermark *aP) : p (aP) { }
12791 
12796   SIGNDOC_Watermark *getImpl () { return p; }
12797 
12802   const SIGNDOC_Watermark *getImpl () const { return p; }
12803 
12808   void setImpl (SIGNDOC_Watermark *aP) { SIGNDOC_Watermark_delete (p); p  = aP; }
12809 
12810 private:
12811   SIGNDOC_Watermark *p;
12812 };
12813 
12861 class SignDocVerificationParameters 
12862 {
12863 public:
12869   enum CertificateChainVerificationPolicy
12870   {
12876     ccvp_dont_verify,
12877 
12884     ccvp_accept_self_signed,
12885 
12893     ccvp_accept_self_signed_with_bio,
12894 
12907     ccvp_accept_self_signed_with_rsa_bio,
12908 
12915     ccvp_require_trusted_root
12916   };
12917 
12924   enum CertificateRevocationVerificationPolicy
12925   {
12931     crvp_dont_check,
12932 
12937     crvp_offline,
12938 
12943     crvp_online
12944   };
12945 
12951   enum VerificationFlags
12952   {
12956     vf_check_revocation = 0x01,
12957 
12965     vf_use_crl_only = 0x02,
12966 
12974     vf_use_ocsp_only = 0x04,
12975 
12984     vf_offline = 0x08,
12985 
12998     vf_enforce_next_update = 0x10,
12999 
13012     vf_enforce_ocsp_signer = 0x20,
13013 
13021     vf_online = 0x40,
13022 
13033     vf_no_ocsp_nonce = 0x80,
13034 
13046     vf_crl_first = 0x100,
13047 
13065     vf_ignore_no_revocation = 0x200
13066   };
13067 
13073   enum VerificationModel
13074   {
13081     vm_minimal,
13082 
13091     vm_chain,
13092 
13098     vm_modified_shell,
13099 
13111     vm_shell
13112   };
13113 
13117   enum ReturnCode
13118   {
13119     rc_ok,                      
13120     rc_unknown,                 
13121     rc_not_supported,           
13122     rc_invalid_value            
13123   };
13124 
13125 public:
13133   SignDocVerificationParameters ()
13134     : p (NULL)
13135   {
13136     SIGNDOC_Exception *ex = NULL;
13137     p = SIGNDOC_VerificationParameters_new (&ex);
13138     if (ex != NULL) SignDoc_throw (ex);
13139   }
13140 
13146   SignDocVerificationParameters (const SignDocVerificationParameters &aSource)
13147     : p (NULL)
13148   {
13149     SIGNDOC_Exception *ex = NULL;
13150     p = SIGNDOC_VerificationParameters_clone (&ex, aSource.getImpl ());
13151     if (ex != NULL) SignDoc_throw (ex);
13152   }
13153 
13157   ~SignDocVerificationParameters ()
13158   {
13159     SIGNDOC_VerificationParameters_delete (p);
13160   }
13161 
13167   SignDocVerificationParameters &operator= (const SignDocVerificationParameters &aSource)
13168   {
13169     SIGNDOC_Exception *ex = NULL;
13170     SIGNDOC_VerificationParameters_assign (&ex, p, aSource.getImpl ());
13171     if (ex != NULL) SignDoc_throw (ex);
13172     return *this;
13173   }
13174 
13182   bool operator== (const SignDocVerificationParameters &aRHS) const
13183   {
13184     SIGNDOC_Exception *ex = NULL;
13185     bool r;
13186     r = (bool)SIGNDOC_VerificationParameters_equals (&ex, p, aRHS.getImpl ());
13187     if (ex != NULL) SignDoc_throw (ex);
13188     return r;
13189   }
13190 
13197   void setForUpdateDSS ()
13198   {
13199     SIGNDOC_Exception *ex = NULL;
13200     SIGNDOC_VerificationParameters_setForUpdateDSS (&ex, p);
13201     if (ex != NULL) SignDoc_throw (ex);
13202   }
13203 
13231   ReturnCode setString (Encoding aEncoding, const std::string &aName,
13232                         const std::string &aValue)
13233   {
13234     SIGNDOC_Exception *ex = NULL;
13235     ReturnCode r;
13236     r = (ReturnCode)SIGNDOC_VerificationParameters_setString (&ex, p, aEncoding, aName.c_str (), aValue.c_str ());
13237     if (ex != NULL) SignDoc_throw (ex);
13238     return r;
13239   }
13240 
13252   ReturnCode setString (const std::string &aName, const wchar_t *aValue)
13253   {
13254     SIGNDOC_Exception *ex = NULL;
13255     ReturnCode r;
13256     r = (ReturnCode)SIGNDOC_VerificationParameters_setStringW (&ex, p, aName.c_str (), aValue);
13257     if (ex != NULL) SignDoc_throw (ex);
13258     return r;
13259   }
13260 
13336   ReturnCode setInteger (const std::string &aName, int aValue)
13337   {
13338     SIGNDOC_Exception *ex = NULL;
13339     ReturnCode r;
13340     r = (ReturnCode)SIGNDOC_VerificationParameters_setInteger (&ex, p, aName.c_str (), aValue);
13341     if (ex != NULL) SignDoc_throw (ex);
13342     return r;
13343   }
13344 
13367   ReturnCode setBlob (const std::string &aName, const unsigned char *aData,
13368                       size_t aSize)
13369   {
13370     SIGNDOC_Exception *ex = NULL;
13371     ReturnCode r;
13372     r = (ReturnCode)SIGNDOC_VerificationParameters_setBlob (&ex, p, aName.c_str (), aData, aSize);
13373     if (ex != NULL) SignDoc_throw (ex);
13374     return r;
13375   }
13376 
13390   const char *getErrorMessage (Encoding aEncoding) const
13391   {
13392     SIGNDOC_Exception *ex = NULL;
13393     const char *r;
13394     r = SIGNDOC_VerificationParameters_getErrorMessage (&ex, p, aEncoding);
13395     if (ex != NULL) SignDoc_throw (ex);
13396     return r;
13397   }
13398 
13410   const wchar_t *getErrorMessageW () const
13411   {
13412     SIGNDOC_Exception *ex = NULL;
13413     const wchar_t *r;
13414     r = SIGNDOC_VerificationParameters_getErrorMessageW (&ex, p);
13415     if (ex != NULL) SignDoc_throw (ex);
13416     return r;
13417   }
13418 
13419 private:
13420 public:
13425   SignDocVerificationParameters (SIGNDOC_VerificationParameters *aP) : p (aP) { }
13426 
13431   SIGNDOC_VerificationParameters *getImpl () { return p; }
13432 
13437   const SIGNDOC_VerificationParameters *getImpl () const { return p; }
13438 
13443   void setImpl (SIGNDOC_VerificationParameters *aP) { SIGNDOC_VerificationParameters_delete (p); p  = aP; }
13444 
13445 private:
13446   SIGNDOC_VerificationParameters *p;
13447 };
13448 
13454 class SignDocChange 
13455 {
13456 public:
13462   enum Type
13463   {
13471     t_other,
13472 
13481     t_field_added,
13482 
13491     t_field_removed,
13492 
13501     t_field_modified,
13502 
13511     t_field_filled_in,
13512 
13521     t_annotation_added,
13522 
13531     t_annotation_removed,
13532 
13541     t_annotation_modified,
13542 
13549     t_attachment_added,
13550 
13557     t_attachment_removed,
13558 
13565     t_attachment_modified,
13566 
13573     t_page_added,
13574 
13581     t_page_removed,
13582 
13588     t_page_modified
13589   };
13590 
13591 public:
13595   ~SignDocChange ()
13596   {
13597     SIGNDOC_Change_delete (p);
13598   }
13599 
13605   Type getType () const
13606   {
13607     SIGNDOC_Exception *ex = NULL;
13608     Type r;
13609     r = (Type)SIGNDOC_Change_getType (&ex, p);
13610     if (ex != NULL) SignDoc_throw (ex);
13611     return r;
13612   }
13613 
13631   std::string getName (Encoding aEncoding) const
13632   {
13633     SIGNDOC_Exception *ex = NULL;
13634     std::string r;
13635     char *s = SIGNDOC_Change_getName (&ex, p, aEncoding);
13636     if (ex != NULL) SignDoc_throw (ex);
13637     try
13638       {
13639         r = s;
13640       }
13641     catch (...)
13642       {
13643         SIGNDOC_free (s);
13644         throw;
13645       }
13646     SIGNDOC_free (s);
13647     return r;
13648   }
13649 
13667   const char *getNameUTF8 () const
13668   {
13669     SIGNDOC_Exception *ex = NULL;
13670     const char *r;
13671     r = SIGNDOC_Change_getNameUTF8 (&ex, p);
13672     if (ex != NULL) SignDoc_throw (ex);
13673     return r;
13674   }
13675 
13688   int getPage () const
13689   {
13690     SIGNDOC_Exception *ex = NULL;
13691     int r;
13692     r = SIGNDOC_Change_getPage (&ex, p);
13693     if (ex != NULL) SignDoc_throw (ex);
13694     return r;
13695   }
13696 
13703   SignDocField::Type getFieldType () const
13704   {
13705     SIGNDOC_Exception *ex = NULL;
13706     SignDocField::Type r;
13707     r = (SignDocField::Type)SIGNDOC_Change_getFieldType (&ex, p);
13708     if (ex != NULL) SignDoc_throw (ex);
13709     return r;
13710   }
13711 
13719   const char *getAnnotationType () const
13720   {
13721     SIGNDOC_Exception *ex = NULL;
13722     const char *r;
13723     r = SIGNDOC_Change_getAnnotationType (&ex, p);
13724     if (ex != NULL) SignDoc_throw (ex);
13725     return r;
13726   }
13727 
13728 protected:
13734   SignDocChange ()
13735     : p (NULL)
13736   {
13737   }
13738 
13739 public:
13744   SignDocChange (SIGNDOC_Change *aP) : p (aP) { }
13745 
13750   SIGNDOC_Change *getImpl () { return p; }
13751 
13756   const SIGNDOC_Change *getImpl () const { return p; }
13757 
13762   void setImpl (SIGNDOC_Change *aP) { SIGNDOC_Change_delete (p); p  = aP; }
13763 
13764 private:
13765   SIGNDOC_Change *p;
13766 };
13767 
13775 class SignDocSignature 
13776 {
13777 public:
13781   ~SignDocSignature ()
13782   {
13783     SIGNDOC_Signature_delete (p);
13784   }
13785 
13798   std::string getFieldName (Encoding aEncoding) const
13799   {
13800     SIGNDOC_Exception *ex = NULL;
13801     std::string r;
13802     char *s = SIGNDOC_Signature_getFieldName (&ex, p, aEncoding);
13803     if (ex != NULL) SignDoc_throw (ex);
13804     try
13805       {
13806         r = s;
13807       }
13808     catch (...)
13809       {
13810         SIGNDOC_free (s);
13811         throw;
13812       }
13813     SIGNDOC_free (s);
13814     return r;
13815   }
13816 
13825   const char *getFieldNameUTF8 () const
13826   {
13827     SIGNDOC_Exception *ex = NULL;
13828     const char *r;
13829     r = SIGNDOC_Signature_getFieldNameUTF8 (&ex, p);
13830     if (ex != NULL) SignDoc_throw (ex);
13831     return r;
13832   }
13833 
13839   int getFieldPage () const
13840   {
13841     SIGNDOC_Exception *ex = NULL;
13842     int r;
13843     r = SIGNDOC_Signature_getFieldPage (&ex, p);
13844     if (ex != NULL) SignDoc_throw (ex);
13845     return r;
13846   }
13847 
13854   SignDocField::SignatureType getSignatureType () const
13855   {
13856     SIGNDOC_Exception *ex = NULL;
13857     SignDocField::SignatureType r;
13858     r = (SignDocField::SignatureType)SIGNDOC_Signature_getSignatureType (&ex, p);
13859     if (ex != NULL) SignDoc_throw (ex);
13860     return r;
13861   }
13862 
13880   int getClearedIndex () const
13881   {
13882     SIGNDOC_Exception *ex = NULL;
13883     int r;
13884     r = SIGNDOC_Signature_getClearedIndex (&ex, p);
13885     if (ex != NULL) SignDoc_throw (ex);
13886     return r;
13887   }
13888 
13906   int getDocMDP () const
13907   {
13908     SIGNDOC_Exception *ex = NULL;
13909     int r;
13910     r = SIGNDOC_Signature_getDocMDP (&ex, p);
13911     if (ex != NULL) SignDoc_throw (ex);
13912     return r;
13913   }
13914 
13932   int getLockMDP () const
13933   {
13934     SIGNDOC_Exception *ex = NULL;
13935     int r;
13936     r = SIGNDOC_Signature_getLockMDP (&ex, p);
13937     if (ex != NULL) SignDoc_throw (ex);
13938     return r;
13939   }
13940 
13949   bool getSigningCertificate (std::vector<unsigned char> &aOutput) const
13950   {
13951     SIGNDOC_Exception *ex = NULL;
13952     SIGNDOC_ByteArray *tempOutput = NULL;
13953     bool r;
13954     try
13955       {
13956         tempOutput = SIGNDOC_ByteArray_new (&ex);
13957         if (ex != NULL) SignDoc_throw (ex);
13958         r = (bool)SIGNDOC_Signature_getSigningCertificate (&ex, p, tempOutput);
13959         assignArray (aOutput, tempOutput);
13960       }
13961     catch (...)
13962       {
13963         if (tempOutput != NULL)
13964           SIGNDOC_ByteArray_delete (tempOutput);
13965         throw;
13966       }
13967     if (tempOutput != NULL)
13968       SIGNDOC_ByteArray_delete (tempOutput);
13969     if (ex != NULL) SignDoc_throw (ex);
13970     return r;
13971   }
13972 
13985   std::string getSignerCommonName (Encoding aEncoding) const
13986   {
13987     SIGNDOC_Exception *ex = NULL;
13988     std::string r;
13989     char *s = SIGNDOC_Signature_getSignerCommonName (&ex, p, aEncoding);
13990     if (ex != NULL) SignDoc_throw (ex);
13991     try
13992       {
13993         r = s;
13994       }
13995     catch (...)
13996       {
13997         SIGNDOC_free (s);
13998         throw;
13999       }
14000     SIGNDOC_free (s);
14001     return r;
14002   }
14003 
14013   const char *getSignerCommonNameUTF8 () const
14014   {
14015     SIGNDOC_Exception *ex = NULL;
14016     const char *r;
14017     r = SIGNDOC_Signature_getSignerCommonNameUTF8 (&ex, p);
14018     if (ex != NULL) SignDoc_throw (ex);
14019     return r;
14020   }
14021 
14034   std::string getSignerEmail (Encoding aEncoding) const
14035   {
14036     SIGNDOC_Exception *ex = NULL;
14037     std::string r;
14038     char *s = SIGNDOC_Signature_getSignerEmail (&ex, p, aEncoding);
14039     if (ex != NULL) SignDoc_throw (ex);
14040     try
14041       {
14042         r = s;
14043       }
14044     catch (...)
14045       {
14046         SIGNDOC_free (s);
14047         throw;
14048       }
14049     SIGNDOC_free (s);
14050     return r;
14051   }
14052 
14062   const char *getSignerEmailUTF8 () const
14063   {
14064     SIGNDOC_Exception *ex = NULL;
14065     const char *r;
14066     r = SIGNDOC_Signature_getSignerEmailUTF8 (&ex, p);
14067     if (ex != NULL) SignDoc_throw (ex);
14068     return r;
14069   }
14070 
14081   const char *getTimeStamp () const
14082   {
14083     SIGNDOC_Exception *ex = NULL;
14084     const char *r;
14085     r = SIGNDOC_Signature_getTimeStamp (&ex, p);
14086     if (ex != NULL) SignDoc_throw (ex);
14087     return r;
14088   }
14089 
14110   int getChangeCount () const
14111   {
14112     SIGNDOC_Exception *ex = NULL;
14113     int r;
14114     r = SIGNDOC_Signature_getChangeCount (&ex, p);
14115     if (ex != NULL) SignDoc_throw (ex);
14116     return r;
14117   }
14118 
14131   bool getChange (int aIndex, SIGNDOC_PTR<SignDocChange> &aOutput) const
14132   {
14133     SIGNDOC_Exception *ex = NULL;
14134     SIGNDOC_Change *tempOutput = NULL;
14135     aOutput.reset ((SignDocChange*)NULL);
14136     bool r;
14137     try
14138       {
14139         r = (bool)SIGNDOC_Signature_getChange (&ex, p, aIndex, &tempOutput);
14140         if (tempOutput != NULL)
14141           {
14142             aOutput.reset (new SignDocChange (tempOutput));
14143             tempOutput = NULL;
14144           }
14145       }
14146     catch (...)
14147       {
14148         if (tempOutput != NULL)
14149           SIGNDOC_Change_delete (tempOutput);
14150         throw;
14151       }
14152     if (tempOutput != NULL)
14153       SIGNDOC_Change_delete (tempOutput);
14154     if (ex != NULL) SignDoc_throw (ex);
14155     return r;
14156   }
14157 
14170   int getBiometricEncryption () const
14171   {
14172     SIGNDOC_Exception *ex = NULL;
14173     int r;
14174     r = SIGNDOC_Signature_getBiometricEncryption (&ex, p);
14175     if (ex != NULL) SignDoc_throw (ex);
14176     return r;
14177   }
14178 
14179 protected:
14185   SignDocSignature ()
14186     : p (NULL)
14187   {
14188   }
14189 
14190 private:
14194   // cppcheck-suppress noExplicitCopyMoveConstructor
14195   SignDocSignature (const SignDocSignature &);
14196 
14200   SignDocSignature &operator= (const SignDocSignature &);
14201 public:
14206   SignDocSignature (SIGNDOC_Signature *aP) : p (aP) { }
14207 
14212   SIGNDOC_Signature *getImpl () { return p; }
14213 
14218   const SIGNDOC_Signature *getImpl () const { return p; }
14219 
14224   void setImpl (SIGNDOC_Signature *aP) { SIGNDOC_Signature_delete (p); p  = aP; }
14225 
14226 private:
14227   SIGNDOC_Signature *p;
14228 };
14229 
14393 class SignDocDocument 
14394 {
14395 public:
14399   enum DocumentType
14400   {
14401     dt_unknown,                 
14402     dt_pdf,                     
14403     dt_tiff,                    
14404     dt_other,                   
14405     dt_fdf                      
14406   };
14407 
14411   enum SaveFlags
14412   {
14418     sf_incremental   = 0x01,
14419 
14425     sf_remove_unused = 0x02,
14426 
14437     sf_linearized    = 0x04,
14438 
14444     sf_pdf_1_4       = 0x08,
14445 
14470     sf_pdfa_buttons  = 0x10,
14471 
14481     sf_auto_incremental = 0x20
14482   };
14483 
14487   enum CopyToStreamFlags
14488   {
14494     ctsf_unsaved = 0x01
14495   };
14496 
14501   enum SetFieldFlags
14502   {
14514     sff_font_fail    = 0x01,
14515 
14531     sff_move = 0x08,
14532 
14550     sff_keep_ap = 0x10,
14551 
14572     sff_update_ap = 0x20,
14573 
14595     sff_fit_height_only = 0x40,
14596 
14607     sff_force_border_width = 0x80,
14608 
14615     sff_dont_break_lines = 0x100,
14616 
14626     sff_auto_alignment = 0x200,
14627 
14639     sff_ltr = 0x1000,
14640 
14660     sff_rtl = 0x2000,
14661 
14688     sff_default_ltr = 0x4000,
14689 
14716     sff_default_rtl = 0x8000
14717   };
14718 
14722   enum FlattenFieldsFlags
14723   {
14727     fff_include_signature_unsigned      = 0x01,
14728 
14732     fff_include_signature_signed        = 0x02,
14733 
14737     fff_include_hidden                  = 0x04,
14738 
14749     fff_keep_structure                  = 0x08
14750   };
14751 
14755   enum FlattenAnnotationsFlags
14756   {
14760     faf_include_hidden                  = 0x04,
14761 
14772     faf_keep_structure                  = 0x08
14773   };
14774 
14778   enum FindTextFlags
14779   {
14780     ftf_ignore_hspace      = 0x0001,  
14781     ftf_ignore_hyphenation = 0x0002,  
14782     ftf_ignore_sequence    = 0x0004   
14783   };
14784 
14788   enum ExportFlags
14789   {
14790     e_top = 0x01  
14791   };
14792 
14796   enum ImportFlags
14797   {
14798     i_atomic = 0x01  
14799   };
14800 
14806   enum ImportImageFlags
14807   {
14811     ii_keep_aspect_ratio = 0x01,
14812 
14840     ii_brightest_transparent = 0x02
14841   };
14842 
14846   enum KeepOrRemove
14847   {
14848     kor_keep,                   
14849     kor_remove                  
14850   };
14851 
14857   enum ReturnCode
14858   {
14859     rc_ok,                    
14860     rc_invalid_argument,      
14861     rc_field_not_found,       
14862     rc_invalid_profile,       
14863     rc_invalid_image,         
14864     rc_type_mismatch,         
14865     rc_font_not_found,        
14866     rc_no_datablock,          
14867     rc_not_supported,         
14868     rc_io_error,              
14869     rc_not_verified,          
14870     rc_property_not_found,    
14871     rc_page_not_found,        
14872     rc_wrong_collection,      
14873     rc_field_exists,          
14874     rc_license_error,         
14875     rc_unexpected_error,      
14876     rc_cancelled,             
14877     rc_no_biometric_data,     
14878     rc_parameter_not_set,     
14879     rc_field_not_signed,      
14880     rc_invalid_signature,     
14881     rc_annotation_not_found,  
14882     rc_attachment_not_found,  
14883     rc_attachment_exists,     
14884     rc_no_certificate,        
14885     rc_ambiguous_certificate, 
14886     rc_not_allowed            
14887   };
14888 
14892   enum CheckAttachmentResult
14893   {
14894     car_match,                  
14895     car_no_checksum,            
14896     car_mismatch                
14897   };
14898 
14902   enum HAlignment
14903   {
14907     ha_left,
14908 
14912     ha_center,
14913 
14917     ha_right,
14918 
14924     ha_do_not_uses_this,
14925 
14930     ha_auto
14931   };
14932 
14936   enum VAlignment
14937   {
14941     va_top,
14942 
14946     va_center,
14947 
14951     va_bottom
14952   };
14953 
14957   enum AddTextRectFlags
14958   {
14979     atrf_compat = 0x01,
14980 
14990     atrf_ltr = 0x1000,
14991 
15003     atrf_rtl = 0x2000,
15004 
15023     atrf_default_ltr = 0x4000,
15024 
15043     atrf_default_rtl = 0x8000
15044   };
15045 
15051   enum Flags
15052   {
15069     f_relax_byte_range = 0x01,
15070 
15090     f_ambiguous_button_value_empty = 0x02,
15091 
15102     f_use_dss_only = 0x04,
15103 
15109     f_no_kerning_for_standard_fonts = 0x08,
15110 
15131     f_prevent_breaking_tagged_pdf = 0x10
15132   };
15133 
15137   enum ShootInFootFlags
15138   {
15145     siff_allow_breaking_signatures  = 0x01,
15146 
15152     siff_allow_breaking_permissions = 0x02,
15153 
15159     siff_allow_invalid_certificate  = 0x04,
15160 
15173     siff_allow_non_standard_external_fonts = 0x08,
15174 
15187     siff_assume_ap_not_shared = 0x10,
15188 
15202     siff_assume_ap_shared = 0x20,
15203 
15211     siff_dont_verify_after_signing = 0x40,
15212 
15235     siff_allow_all_curves = 0x80
15236   };
15237 
15241   enum UpdateDSSFlags
15242   {
15246     udf_simulate = 0x01,
15247 
15253     udf_vri      = 0x02
15254   };
15255 
15264   SignDocDocument ()
15265     : p (NULL)
15266   {
15267   }
15268 
15274   ~SignDocDocument ()
15275   {
15276     SIGNDOC_Document_delete (p);
15277   }
15278 
15284   DocumentType getType () const
15285   {
15286     SIGNDOC_Exception *ex = NULL;
15287     DocumentType r;
15288     r = (DocumentType)SIGNDOC_Document_getType (&ex, p);
15289     if (ex != NULL) SignDoc_throw (ex);
15290     return r;
15291   }
15292 
15300   int getPageCount () const
15301   {
15302     SIGNDOC_Exception *ex = NULL;
15303     int r;
15304     r = SIGNDOC_Document_getPageCount (&ex, p);
15305     if (ex != NULL) SignDoc_throw (ex);
15306     return r;
15307   }
15308 
15347   ReturnCode createSignatureParameters (Encoding aEncoding,
15348                                         const std::string &aFieldName,
15349                                         const std::string &aProfile,
15350                                         SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
15351   {
15352     SIGNDOC_Exception *ex = NULL;
15353     SIGNDOC_SignatureParameters *tempOutput = NULL;
15354     aOutput.reset ((SignDocSignatureParameters*)NULL);
15355     ReturnCode r;
15356     try
15357       {
15358         r = (ReturnCode)SIGNDOC_Document_createSignatureParameters (&ex, p, aEncoding, aFieldName.c_str (), aProfile.c_str (), &tempOutput);
15359         if (tempOutput != NULL)
15360           {
15361             aOutput.reset (new SignDocSignatureParameters (tempOutput));
15362             tempOutput = NULL;
15363           }
15364       }
15365     catch (...)
15366       {
15367         if (tempOutput != NULL)
15368           SIGNDOC_SignatureParameters_delete (tempOutput);
15369         throw;
15370       }
15371     if (tempOutput != NULL)
15372       SIGNDOC_SignatureParameters_delete (tempOutput);
15373     if (ex != NULL) SignDoc_throw (ex);
15374     return r;
15375   }
15376 
15413   ReturnCode createSignatureParameters (const wchar_t *aFieldName,
15414                                         const wchar_t *aProfile,
15415                                         SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
15416   {
15417     SIGNDOC_Exception *ex = NULL;
15418     SIGNDOC_SignatureParameters *tempOutput = NULL;
15419     aOutput.reset ((SignDocSignatureParameters*)NULL);
15420     ReturnCode r;
15421     try
15422       {
15423         r = (ReturnCode)SIGNDOC_Document_createSignatureParametersW (&ex, p, aFieldName, aProfile, &tempOutput);
15424         if (tempOutput != NULL)
15425           {
15426             aOutput.reset (new SignDocSignatureParameters (tempOutput));
15427             tempOutput = NULL;
15428           }
15429       }
15430     catch (...)
15431       {
15432         if (tempOutput != NULL)
15433           SIGNDOC_SignatureParameters_delete (tempOutput);
15434         throw;
15435       }
15436     if (tempOutput != NULL)
15437       SIGNDOC_SignatureParameters_delete (tempOutput);
15438     if (ex != NULL) SignDoc_throw (ex);
15439     return r;
15440   }
15441 
15461   ReturnCode createSignatureParametersForTimeStamp (SIGNDOC_PTR<SignDocSignatureParameters> &aOutput)
15462   {
15463     SIGNDOC_Exception *ex = NULL;
15464     SIGNDOC_SignatureParameters *tempOutput = NULL;
15465     aOutput.reset ((SignDocSignatureParameters*)NULL);
15466     ReturnCode r;
15467     try
15468       {
15469         r = (ReturnCode)SIGNDOC_Document_createSignatureParametersForTimeStamp (&ex, p, &tempOutput);
15470         if (tempOutput != NULL)
15471           {
15472             aOutput.reset (new SignDocSignatureParameters (tempOutput));
15473             tempOutput = NULL;
15474           }
15475       }
15476     catch (...)
15477       {
15478         if (tempOutput != NULL)
15479           SIGNDOC_SignatureParameters_delete (tempOutput);
15480         throw;
15481       }
15482     if (tempOutput != NULL)
15483       SIGNDOC_SignatureParameters_delete (tempOutput);
15484     if (ex != NULL) SignDoc_throw (ex);
15485     return r;
15486   }
15487 
15503   ReturnCode getProfiles (Encoding aEncoding, const std::string &aFieldName,
15504                           std::vector<std::string> &aOutput)
15505   {
15506     SIGNDOC_Exception *ex = NULL;
15507     SIGNDOC_StringArray *tempOutput = NULL;
15508     ReturnCode r;
15509     try
15510       {
15511         tempOutput = SIGNDOC_StringArray_new (&ex);
15512         if (ex != NULL) SignDoc_throw (ex);
15513         r = (ReturnCode)SIGNDOC_Document_getProfiles (&ex, p, aEncoding, aFieldName.c_str (), tempOutput);
15514         assignArray (aOutput, tempOutput);
15515       }
15516     catch (...)
15517       {
15518         if (tempOutput != NULL)
15519           SIGNDOC_StringArray_delete (tempOutput);
15520         throw;
15521       }
15522     if (tempOutput != NULL)
15523       SIGNDOC_StringArray_delete (tempOutput);
15524     if (ex != NULL) SignDoc_throw (ex);
15525     return r;
15526   }
15527 
15588   ReturnCode addSignature (SignDocSignatureParameters *aSignatureParameters,
15589                            const SignDocVerificationParameters *aVerificationParameters)
15590   {
15591     SIGNDOC_Exception *ex = NULL;
15592     ReturnCode r;
15593     r = (ReturnCode)SIGNDOC_Document_addSignature (&ex, p, aSignatureParameters == NULL ? NULL : aSignatureParameters->getImpl (), aVerificationParameters == NULL ? NULL : aVerificationParameters->getImpl ());
15594     if (ex != NULL) SignDoc_throw (ex);
15595     return r;
15596   }
15597 
15615   ReturnCode getLastTimestamp (std::string &aTime)
15616   {
15617     SIGNDOC_Exception *ex = NULL;
15618     char *tempTime = NULL;
15619     ReturnCode r;
15620     try
15621       {
15622         r = (ReturnCode)SIGNDOC_Document_getLastTimestamp (&ex, p, &tempTime);
15623         if (tempTime != NULL)
15624           aTime = tempTime;
15625       }
15626     catch (...)
15627       {
15628         SIGNDOC_free (tempTime);
15629         throw;
15630       }
15631     SIGNDOC_free (tempTime);
15632     if (ex != NULL) SignDoc_throw (ex);
15633     return r;
15634   }
15635 
15650   ReturnCode getPathname (Encoding aEncoding, std::string &aPath)
15651   {
15652     SIGNDOC_Exception *ex = NULL;
15653     char *tempPath = NULL;
15654     ReturnCode r;
15655     try
15656       {
15657         r = (ReturnCode)SIGNDOC_Document_getPathname (&ex, p, aEncoding, &tempPath);
15658         if (tempPath != NULL)
15659           aPath = tempPath;
15660       }
15661     catch (...)
15662       {
15663         SIGNDOC_free (tempPath);
15664         throw;
15665       }
15666     SIGNDOC_free (tempPath);
15667     if (ex != NULL) SignDoc_throw (ex);
15668     return r;
15669   }
15670 
15682   int getAvailableMethods ()
15683   {
15684     SIGNDOC_Exception *ex = NULL;
15685     int r;
15686     r = SIGNDOC_Document_getAvailableMethods (&ex, p);
15687     if (ex != NULL) SignDoc_throw (ex);
15688     return r;
15689   }
15690 
15700   int getSignatureCount ()
15701   {
15702     SIGNDOC_Exception *ex = NULL;
15703     int r;
15704     r = SIGNDOC_Document_getSignatureCount (&ex, p);
15705     if (ex != NULL) SignDoc_throw (ex);
15706     return r;
15707   }
15708 
15728   ReturnCode getSignature (int aIndex, SIGNDOC_PTR<SignDocSignature> &aOutput)
15729   {
15730     SIGNDOC_Exception *ex = NULL;
15731     SIGNDOC_Signature *tempOutput = NULL;
15732     aOutput.reset ((SignDocSignature*)NULL);
15733     ReturnCode r;
15734     try
15735       {
15736         r = (ReturnCode)SIGNDOC_Document_getSignature (&ex, p, aIndex, &tempOutput);
15737         if (tempOutput != NULL)
15738           {
15739             aOutput.reset (new SignDocSignature (tempOutput));
15740             tempOutput = NULL;
15741           }
15742       }
15743     catch (...)
15744       {
15745         if (tempOutput != NULL)
15746           SIGNDOC_Signature_delete (tempOutput);
15747         throw;
15748       }
15749     if (tempOutput != NULL)
15750       SIGNDOC_Signature_delete (tempOutput);
15751     if (ex != NULL) SignDoc_throw (ex);
15752     return r;
15753   }
15754 
15772   ReturnCode verifySignature (Encoding aEncoding,
15773                               const std::string &aFieldName,
15774                               SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
15775   {
15776     SIGNDOC_Exception *ex = NULL;
15777     SIGNDOC_VerificationResult *tempOutput = NULL;
15778     aOutput.reset ((SignDocVerificationResult*)NULL);
15779     ReturnCode r;
15780     try
15781       {
15782         r = (ReturnCode)SIGNDOC_Document_verifySignature (&ex, p, aEncoding, aFieldName.c_str (), &tempOutput);
15783         if (tempOutput != NULL)
15784           {
15785             aOutput.reset (makeSignDocVerificationResult (tempOutput));
15786             tempOutput = NULL;
15787           }
15788       }
15789     catch (...)
15790       {
15791         if (tempOutput != NULL)
15792           SIGNDOC_VerificationResult_delete (tempOutput);
15793         throw;
15794       }
15795     if (tempOutput != NULL)
15796       SIGNDOC_VerificationResult_delete (tempOutput);
15797     if (ex != NULL) SignDoc_throw (ex);
15798     return r;
15799   }
15800 
15816   ReturnCode verifySignature (const wchar_t *aFieldName,
15817                               SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
15818   {
15819     SIGNDOC_Exception *ex = NULL;
15820     SIGNDOC_VerificationResult *tempOutput = NULL;
15821     aOutput.reset ((SignDocVerificationResult*)NULL);
15822     ReturnCode r;
15823     try
15824       {
15825         r = (ReturnCode)SIGNDOC_Document_verifySignatureW (&ex, p, aFieldName, &tempOutput);
15826         if (tempOutput != NULL)
15827           {
15828             aOutput.reset (makeSignDocVerificationResult (tempOutput));
15829             tempOutput = NULL;
15830           }
15831       }
15832     catch (...)
15833       {
15834         if (tempOutput != NULL)
15835           SIGNDOC_VerificationResult_delete (tempOutput);
15836         throw;
15837       }
15838     if (tempOutput != NULL)
15839       SIGNDOC_VerificationResult_delete (tempOutput);
15840     if (ex != NULL) SignDoc_throw (ex);
15841     return r;
15842   }
15843 
15871   ReturnCode verifySignature2 (const SignDocSignature &aSignature,
15872                                SIGNDOC_PTR<SignDocVerificationResult> &aOutput)
15873   {
15874     SIGNDOC_Exception *ex = NULL;
15875     SIGNDOC_VerificationResult *tempOutput = NULL;
15876     aOutput.reset ((SignDocVerificationResult*)NULL);
15877     ReturnCode r;
15878     try
15879       {
15880         r = (ReturnCode)SIGNDOC_Document_verifySignature2 (&ex, p, aSignature.getImpl (), &tempOutput);
15881         if (tempOutput != NULL)
15882           {
15883             aOutput.reset (makeSignDocVerificationResult (tempOutput));
15884             tempOutput = NULL;
15885           }
15886       }
15887     catch (...)
15888       {
15889         if (tempOutput != NULL)
15890           SIGNDOC_VerificationResult_delete (tempOutput);
15891         throw;
15892       }
15893     if (tempOutput != NULL)
15894       SIGNDOC_VerificationResult_delete (tempOutput);
15895     if (ex != NULL) SignDoc_throw (ex);
15896     return r;
15897   }
15898 
15913   ReturnCode clearSignature (Encoding aEncoding, const std::string &aFieldName)
15914   {
15915     SIGNDOC_Exception *ex = NULL;
15916     ReturnCode r;
15917     r = (ReturnCode)SIGNDOC_Document_clearSignature (&ex, p, aEncoding, aFieldName.c_str ());
15918     if (ex != NULL) SignDoc_throw (ex);
15919     return r;
15920   }
15921 
15931   ReturnCode clearAllSignatures ()
15932   {
15933     SIGNDOC_Exception *ex = NULL;
15934     ReturnCode r;
15935     r = (ReturnCode)SIGNDOC_Document_clearAllSignatures (&ex, p);
15936     if (ex != NULL) SignDoc_throw (ex);
15937     return r;
15938   }
15939 
15949   ReturnCode clearApprovalSignatures ()
15950   {
15951     SIGNDOC_Exception *ex = NULL;
15952     ReturnCode r;
15953     r = (ReturnCode)SIGNDOC_Document_clearApprovalSignatures (&ex, p);
15954     if (ex != NULL) SignDoc_throw (ex);
15955     return r;
15956   }
15957 
15990   ReturnCode updateDSS (const SignDocVerificationParameters *aParameters,
15991                         unsigned aFlags, int &aCount)
15992   {
15993     SIGNDOC_Exception *ex = NULL;
15994     ReturnCode r;
15995     r = (ReturnCode)SIGNDOC_Document_updateDSS (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), aFlags, &aCount);
15996     if (ex != NULL) SignDoc_throw (ex);
15997     return r;
15998   }
15999 
16038   ReturnCode updateDSS2 (Encoding aEncoding, const std::string &aFieldName,
16039                          const SignDocVerificationParameters *aParameters,
16040                          unsigned aFlags)
16041   {
16042     SIGNDOC_Exception *ex = NULL;
16043     ReturnCode r;
16044     r = (ReturnCode)SIGNDOC_Document_updateDSS2 (&ex, p, aEncoding, aFieldName.c_str (), aParameters == NULL ? NULL : aParameters->getImpl (), aFlags);
16045     if (ex != NULL) SignDoc_throw (ex);
16046     return r;
16047   }
16048 
16068   ReturnCode saveToStream (OutputStream &aStream, int aFlags)
16069   {
16070     SIGNDOC_Exception *ex = NULL;
16071     ReturnCode r;
16072     r = (ReturnCode)SIGNDOC_Document_saveToStream (&ex, p, aStream.getImpl (), aFlags);
16073     if (ex != NULL) SignDoc_throw (ex);
16074     return r;
16075   }
16076 
16108   ReturnCode saveToFile (Encoding aEncoding, const char *aPath, int aFlags)
16109   {
16110     SIGNDOC_Exception *ex = NULL;
16111     ReturnCode r;
16112     r = (ReturnCode)SIGNDOC_Document_saveToFile (&ex, p, aEncoding, aPath, aFlags);
16113     if (ex != NULL) SignDoc_throw (ex);
16114     return r;
16115   }
16116 
16142   ReturnCode saveToFile (const wchar_t *aPath, int aFlags)
16143   {
16144     SIGNDOC_Exception *ex = NULL;
16145     ReturnCode r;
16146     r = (ReturnCode)SIGNDOC_Document_saveToFileW (&ex, p, aPath, aFlags);
16147     if (ex != NULL) SignDoc_throw (ex);
16148     return r;
16149   }
16150 
16177   ReturnCode copyToStream (OutputStream &aStream, unsigned aFlags)
16178   {
16179     SIGNDOC_Exception *ex = NULL;
16180     ReturnCode r;
16181     r = (ReturnCode)SIGNDOC_Document_copyToStream (&ex, p, aStream.getImpl (), aFlags);
16182     if (ex != NULL) SignDoc_throw (ex);
16183     return r;
16184   }
16185 
16204   ReturnCode copyAsSignedToStream (Encoding aEncoding,
16205                                    const std::string &aFieldName,
16206                                    OutputStream &aStream)
16207   {
16208     SIGNDOC_Exception *ex = NULL;
16209     ReturnCode r;
16210     r = (ReturnCode)SIGNDOC_Document_copyAsSignedToStream (&ex, p, aEncoding, aFieldName.c_str (), aStream.getImpl ());
16211     if (ex != NULL) SignDoc_throw (ex);
16212     return r;
16213   }
16214 
16230   ReturnCode getSaveToStreamFlags (int &aOutput)
16231   {
16232     SIGNDOC_Exception *ex = NULL;
16233     ReturnCode r;
16234     r = (ReturnCode)SIGNDOC_Document_getSaveToStreamFlags (&ex, p, &aOutput);
16235     if (ex != NULL) SignDoc_throw (ex);
16236     return r;
16237   }
16238 
16253   ReturnCode getSaveToFileFlags (int &aOutput)
16254   {
16255     SIGNDOC_Exception *ex = NULL;
16256     ReturnCode r;
16257     r = (ReturnCode)SIGNDOC_Document_getSaveToFileFlags (&ex, p, &aOutput);
16258     if (ex != NULL) SignDoc_throw (ex);
16259     return r;
16260   }
16261 
16275   ReturnCode getRequiredSaveToFileFlags (int &aOutput)
16276   {
16277     SIGNDOC_Exception *ex = NULL;
16278     ReturnCode r;
16279     r = (ReturnCode)SIGNDOC_Document_getRequiredSaveToFileFlags (&ex, p, &aOutput);
16280     if (ex != NULL) SignDoc_throw (ex);
16281     return r;
16282   }
16283 
16301   ReturnCode getFields (int aTypes, std::vector<SignDocField> &aOutput)
16302   {
16303     SIGNDOC_Exception *ex = NULL;
16304     SIGNDOC_FieldArray *tempOutput = NULL;
16305     ReturnCode r;
16306     try
16307       {
16308         tempOutput = SIGNDOC_FieldArray_new (&ex);
16309         if (ex != NULL) SignDoc_throw (ex);
16310         r = (ReturnCode)SIGNDOC_Document_getFields (&ex, p, aTypes, tempOutput);
16311         assignArray (aOutput, tempOutput);
16312       }
16313     catch (...)
16314       {
16315         if (tempOutput != NULL)
16316           SIGNDOC_FieldArray_delete (tempOutput);
16317         throw;
16318       }
16319     if (tempOutput != NULL)
16320       SIGNDOC_FieldArray_delete (tempOutput);
16321     if (ex != NULL) SignDoc_throw (ex);
16322     return r;
16323   }
16324 
16351   ReturnCode getFieldsOfPage (int aPage, int aTypes,
16352                               std::vector<SignDocField> &aOutput)
16353   {
16354     SIGNDOC_Exception *ex = NULL;
16355     SIGNDOC_FieldArray *tempOutput = NULL;
16356     ReturnCode r;
16357     try
16358       {
16359         tempOutput = SIGNDOC_FieldArray_new (&ex);
16360         if (ex != NULL) SignDoc_throw (ex);
16361         r = (ReturnCode)SIGNDOC_Document_getFieldsOfPage (&ex, p, aPage, aTypes, tempOutput);
16362         assignArray (aOutput, tempOutput);
16363       }
16364     catch (...)
16365       {
16366         if (tempOutput != NULL)
16367           SIGNDOC_FieldArray_delete (tempOutput);
16368         throw;
16369       }
16370     if (tempOutput != NULL)
16371       SIGNDOC_FieldArray_delete (tempOutput);
16372     if (ex != NULL) SignDoc_throw (ex);
16373     return r;
16374   }
16375 
16390   ReturnCode getField (Encoding aEncoding, const std::string &aName,
16391                        SignDocField &aOutput)
16392   {
16393     SIGNDOC_Exception *ex = NULL;
16394     ReturnCode r;
16395     r = (ReturnCode)SIGNDOC_Document_getField (&ex, p, aEncoding, aName.c_str (), aOutput.getImpl ());
16396     if (ex != NULL) SignDoc_throw (ex);
16397     return r;
16398   }
16399 
16441   ReturnCode setField (SignDocField &aField, unsigned aFlags)
16442   {
16443     SIGNDOC_Exception *ex = NULL;
16444     ReturnCode r;
16445     r = (ReturnCode)SIGNDOC_Document_setField (&ex, p, aField.getImpl (), aFlags);
16446     if (ex != NULL) SignDoc_throw (ex);
16447     return r;
16448   }
16449 
16496   ReturnCode addField (SignDocField &aField, unsigned aFlags)
16497   {
16498     SIGNDOC_Exception *ex = NULL;
16499     ReturnCode r;
16500     r = (ReturnCode)SIGNDOC_Document_addField (&ex, p, aField.getImpl (), aFlags);
16501     if (ex != NULL) SignDoc_throw (ex);
16502     return r;
16503   }
16504 
16517   ReturnCode removeField (Encoding aEncoding, const std::string &aName)
16518   {
16519     SIGNDOC_Exception *ex = NULL;
16520     ReturnCode r;
16521     r = (ReturnCode)SIGNDOC_Document_removeField (&ex, p, aEncoding, aName.c_str ());
16522     if (ex != NULL) SignDoc_throw (ex);
16523     return r;
16524   }
16525 
16553   ReturnCode flattenField (Encoding aEncoding, const std::string &aName,
16554                            int aWidget)
16555   {
16556     SIGNDOC_Exception *ex = NULL;
16557     ReturnCode r;
16558     r = (ReturnCode)SIGNDOC_Document_flattenField (&ex, p, aEncoding, aName.c_str (), aWidget);
16559     if (ex != NULL) SignDoc_throw (ex);
16560     return r;
16561   }
16562 
16594   ReturnCode flattenFields (int aFirstPage, int aLastPage, unsigned aFlags)
16595   {
16596     SIGNDOC_Exception *ex = NULL;
16597     ReturnCode r;
16598     r = (ReturnCode)SIGNDOC_Document_flattenFields (&ex, p, aFirstPage, aLastPage, aFlags);
16599     if (ex != NULL) SignDoc_throw (ex);
16600     return r;
16601   }
16602 
16622   ReturnCode exportFields (OutputStream &aStream, int aFlags)
16623   {
16624     SIGNDOC_Exception *ex = NULL;
16625     ReturnCode r;
16626     r = (ReturnCode)SIGNDOC_Document_exportFields (&ex, p, aStream.getImpl (), aFlags);
16627     if (ex != NULL) SignDoc_throw (ex);
16628     return r;
16629   }
16630 
16645   ReturnCode applyFdf (Encoding aEncoding, const char *aPath, unsigned aFlags)
16646   {
16647     SIGNDOC_Exception *ex = NULL;
16648     ReturnCode r;
16649     r = (ReturnCode)SIGNDOC_Document_applyFdf (&ex, p, aEncoding, aPath, aFlags);
16650     if (ex != NULL) SignDoc_throw (ex);
16651     return r;
16652   }
16653 
16665   ReturnCode applyFdf (const wchar_t *aPath, unsigned aFlags)
16666   {
16667     SIGNDOC_Exception *ex = NULL;
16668     ReturnCode r;
16669     r = (ReturnCode)SIGNDOC_Document_applyFdfW (&ex, p, aPath, aFlags);
16670     if (ex != NULL) SignDoc_throw (ex);
16671     return r;
16672   }
16673 
16683   ReturnCode getTextFieldAttributes (SignDocTextFieldAttributes &aOutput)
16684   {
16685     SIGNDOC_Exception *ex = NULL;
16686     ReturnCode r;
16687     r = (ReturnCode)SIGNDOC_Document_getTextFieldAttributes (&ex, p, aOutput.getImpl ());
16688     if (ex != NULL) SignDoc_throw (ex);
16689     return r;
16690   }
16691 
16710   ReturnCode setTextFieldAttributes (SignDocTextFieldAttributes &aData)
16711   {
16712     SIGNDOC_Exception *ex = NULL;
16713     ReturnCode r;
16714     r = (ReturnCode)SIGNDOC_Document_setTextFieldAttributes (&ex, p, aData.getImpl ());
16715     if (ex != NULL) SignDoc_throw (ex);
16716     return r;
16717   }
16718 
16788   ReturnCode getProperties (const std::string &aCollection,
16789                             std::vector<SignDocProperty> &aOutput)
16790   {
16791     SIGNDOC_Exception *ex = NULL;
16792     SIGNDOC_PropertyArray *tempOutput = NULL;
16793     ReturnCode r;
16794     try
16795       {
16796         tempOutput = SIGNDOC_PropertyArray_new (&ex);
16797         if (ex != NULL) SignDoc_throw (ex);
16798         r = (ReturnCode)SIGNDOC_Document_getProperties (&ex, p, aCollection.c_str (), tempOutput);
16799         assignArray (aOutput, tempOutput);
16800       }
16801     catch (...)
16802       {
16803         if (tempOutput != NULL)
16804           SIGNDOC_PropertyArray_delete (tempOutput);
16805         throw;
16806       }
16807     if (tempOutput != NULL)
16808       SIGNDOC_PropertyArray_delete (tempOutput);
16809     if (ex != NULL) SignDoc_throw (ex);
16810     return r;
16811   }
16812 
16829   ReturnCode getIntegerProperty (Encoding aEncoding,
16830                                  const std::string &aCollection,
16831                                  const std::string &aName, long &aValue)
16832   {
16833     SIGNDOC_Exception *ex = NULL;
16834     ReturnCode r;
16835     r = (ReturnCode)SIGNDOC_Document_getIntegerProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &aValue);
16836     if (ex != NULL) SignDoc_throw (ex);
16837     return r;
16838   }
16839 
16857   ReturnCode getStringProperty (Encoding aEncoding,
16858                                 const std::string &aCollection,
16859                                 const std::string &aName, std::string &aValue)
16860   {
16861     SIGNDOC_Exception *ex = NULL;
16862     char *tempValue = NULL;
16863     ReturnCode r;
16864     try
16865       {
16866         r = (ReturnCode)SIGNDOC_Document_getStringProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &tempValue);
16867         if (tempValue != NULL)
16868           aValue = tempValue;
16869       }
16870     catch (...)
16871       {
16872         SIGNDOC_free (tempValue);
16873         throw;
16874       }
16875     SIGNDOC_free (tempValue);
16876     if (ex != NULL) SignDoc_throw (ex);
16877     return r;
16878   }
16879 
16896   ReturnCode getBooleanProperty (Encoding aEncoding,
16897                                  const std::string &aCollection,
16898                                  const std::string &aName, bool &aValue)
16899   {
16900     SIGNDOC_Exception *ex = NULL;
16901     SIGNDOC_Boolean tempValue = 0;
16902     ReturnCode r;
16903     try
16904       {
16905         r = (ReturnCode)SIGNDOC_Document_getBooleanProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), &tempValue);
16906         aValue = (bool )tempValue;
16907       }
16908     catch (...)
16909       {
16910         throw;
16911       }
16912     if (ex != NULL) SignDoc_throw (ex);
16913     return r;
16914   }
16915 
16934   ReturnCode setIntegerProperty (Encoding aEncoding,
16935                                  const std::string &aCollection,
16936                                  const std::string &aName, long aValue)
16937   {
16938     SIGNDOC_Exception *ex = NULL;
16939     ReturnCode r;
16940     r = (ReturnCode)SIGNDOC_Document_setIntegerProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue);
16941     if (ex != NULL) SignDoc_throw (ex);
16942     return r;
16943   }
16944 
16964   ReturnCode setStringProperty (Encoding aEncoding,
16965                                 const std::string &aCollection,
16966                                 const std::string &aName,
16967                                 const std::string &aValue)
16968   {
16969     SIGNDOC_Exception *ex = NULL;
16970     ReturnCode r;
16971     r = (ReturnCode)SIGNDOC_Document_setStringProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue.c_str ());
16972     if (ex != NULL) SignDoc_throw (ex);
16973     return r;
16974   }
16975 
16994   ReturnCode setBooleanProperty (Encoding aEncoding,
16995                                  const std::string &aCollection,
16996                                  const std::string &aName, bool aValue)
16997   {
16998     SIGNDOC_Exception *ex = NULL;
16999     ReturnCode r;
17000     r = (ReturnCode)SIGNDOC_Document_setBooleanProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str (), aValue);
17001     if (ex != NULL) SignDoc_throw (ex);
17002     return r;
17003   }
17004 
17020   ReturnCode removeProperty (Encoding aEncoding,
17021                              const std::string &aCollection,
17022                              const std::string &aName)
17023   {
17024     SIGNDOC_Exception *ex = NULL;
17025     ReturnCode r;
17026     r = (ReturnCode)SIGNDOC_Document_removeProperty (&ex, p, aEncoding, aCollection.c_str (), aName.c_str ());
17027     if (ex != NULL) SignDoc_throw (ex);
17028     return r;
17029   }
17030 
17051   ReturnCode exportProperties (const std::string &aCollection,
17052                                OutputStream &aStream, int aFlags)
17053   {
17054     SIGNDOC_Exception *ex = NULL;
17055     ReturnCode r;
17056     r = (ReturnCode)SIGNDOC_Document_exportProperties (&ex, p, aCollection.c_str (), aStream.getImpl (), aFlags);
17057     if (ex != NULL) SignDoc_throw (ex);
17058     return r;
17059   }
17060 
17083   ReturnCode importProperties (const std::string &aCollection,
17084                                InputStream &aStream, int aFlags)
17085   {
17086     SIGNDOC_Exception *ex = NULL;
17087     ReturnCode r;
17088     r = (ReturnCode)SIGNDOC_Document_importProperties (&ex, p, aCollection.c_str (), aStream.getImpl (), aFlags);
17089     if (ex != NULL) SignDoc_throw (ex);
17090     return r;
17091   }
17092 
17112   ReturnCode getResolution (int aPage, double &aResX, double &aResY)
17113   {
17114     SIGNDOC_Exception *ex = NULL;
17115     ReturnCode r;
17116     r = (ReturnCode)SIGNDOC_Document_getResolution (&ex, p, aPage, &aResX, &aResY);
17117     if (ex != NULL) SignDoc_throw (ex);
17118     return r;
17119   }
17120 
17142   ReturnCode getConversionFactors (int aPage, double &aFactorX,
17143                                    double &aFactorY)
17144   {
17145     SIGNDOC_Exception *ex = NULL;
17146     ReturnCode r;
17147     r = (ReturnCode)SIGNDOC_Document_getConversionFactors (&ex, p, aPage, &aFactorX, &aFactorY);
17148     if (ex != NULL) SignDoc_throw (ex);
17149     return r;
17150   }
17151 
17169   ReturnCode getPageSize (int aPage, double &aWidth, double &aHeight)
17170   {
17171     SIGNDOC_Exception *ex = NULL;
17172     ReturnCode r;
17173     r = (ReturnCode)SIGNDOC_Document_getPageSize (&ex, p, aPage, &aWidth, &aHeight);
17174     if (ex != NULL) SignDoc_throw (ex);
17175     return r;
17176   }
17177 
17192   ReturnCode getBitsPerPixel (int aPage, int &aBPP)
17193   {
17194     SIGNDOC_Exception *ex = NULL;
17195     ReturnCode r;
17196     r = (ReturnCode)SIGNDOC_Document_getBitsPerPixel (&ex, p, aPage, &aBPP);
17197     if (ex != NULL) SignDoc_throw (ex);
17198     return r;
17199   }
17200 
17219   ReturnCode computeZoom (double &aOutput,
17220                           const SignDocRenderParameters &aParams)
17221   {
17222     SIGNDOC_Exception *ex = NULL;
17223     ReturnCode r;
17224     r = (ReturnCode)SIGNDOC_Document_computeZoom (&ex, p, &aOutput, aParams.getImpl ());
17225     if (ex != NULL) SignDoc_throw (ex);
17226     return r;
17227   }
17228 
17250   ReturnCode convCanvasPointToPagePoint (Point &aPoint,
17251                                          const SignDocRenderParameters &aParams)
17252   {
17253     SIGNDOC_Exception *ex = NULL;
17254     ReturnCode r;
17255     r = (ReturnCode)SIGNDOC_Document_convCanvasPointToPagePoint (&ex, p, (SIGNDOC_Point*)&aPoint, aParams.getImpl ());
17256     if (ex != NULL) SignDoc_throw (ex);
17257     return r;
17258   }
17259 
17280   ReturnCode convPagePointToCanvasPoint (Point &aPoint,
17281                                          const SignDocRenderParameters &aParams)
17282   {
17283     SIGNDOC_Exception *ex = NULL;
17284     ReturnCode r;
17285     r = (ReturnCode)SIGNDOC_Document_convPagePointToCanvasPoint (&ex, p, (SIGNDOC_Point*)&aPoint, aParams.getImpl ());
17286     if (ex != NULL) SignDoc_throw (ex);
17287     return r;
17288   }
17289 
17316   ReturnCode renderPageAsImage (std::vector<unsigned char> &aImage,
17317                                 SignDocRenderOutput &aOutput,
17318                                 const SignDocRenderParameters &aRenderParameters,
17319                                 const SignDocVerificationParameters *aVerificationParameters,
17320                                 const Rect *aClipRect)
17321   {
17322     SIGNDOC_Exception *ex = NULL;
17323     SIGNDOC_ByteArray *tempImage = NULL;
17324     ReturnCode r;
17325     try
17326       {
17327         tempImage = SIGNDOC_ByteArray_new (&ex);
17328         if (ex != NULL) SignDoc_throw (ex);
17329         r = (ReturnCode)SIGNDOC_Document_renderPageAsImage (&ex, p, tempImage, (SIGNDOC_RenderOutput*)&aOutput, aRenderParameters.getImpl (), aVerificationParameters == NULL ? NULL : aVerificationParameters->getImpl (), (const SIGNDOC_Rect*)aClipRect);
17330         assignArray (aImage, tempImage);
17331       }
17332     catch (...)
17333       {
17334         if (tempImage != NULL)
17335           SIGNDOC_ByteArray_delete (tempImage);
17336         throw;
17337       }
17338     if (tempImage != NULL)
17339       SIGNDOC_ByteArray_delete (tempImage);
17340     if (ex != NULL) SignDoc_throw (ex);
17341     return r;
17342   }
17343 
17361   ReturnCode getRenderedSize (SignDocRenderOutput &aOutput,
17362                               const SignDocRenderParameters &aRenderParameters)
17363   {
17364     SIGNDOC_Exception *ex = NULL;
17365     ReturnCode r;
17366     r = (ReturnCode)SIGNDOC_Document_getRenderedSize (&ex, p, (SIGNDOC_RenderOutput*)&aOutput, aRenderParameters.getImpl ());
17367     if (ex != NULL) SignDoc_throw (ex);
17368     return r;
17369   }
17370 
17387   SignDocAnnotation *createLineAnnotation (const Point &aStart,
17388                                            const Point &aEnd)
17389   {
17390     SIGNDOC_Exception *ex = NULL;
17391     SIGNDOC_Annotation *r;
17392     r = SIGNDOC_Document_createLineAnnotation (&ex, p, (const SIGNDOC_Point*)&aStart, (const SIGNDOC_Point*)&aEnd);
17393     if (ex != NULL) SignDoc_throw (ex);
17394     if (r == NULL)
17395       return NULL;
17396     try
17397       {
17398         return new SignDocAnnotation (r);
17399       }
17400     catch (...)
17401       {
17402         SIGNDOC_Annotation_delete (r);
17403         throw;
17404       }
17405   }
17406 
17424   SignDocAnnotation *createLineAnnotation (double aStartX, double aStartY,
17425                                            double aEndX, double aEndY)
17426   {
17427     SIGNDOC_Exception *ex = NULL;
17428     SIGNDOC_Annotation *r;
17429     r = SIGNDOC_Document_createLineAnnotationXY (&ex, p, aStartX, aStartY, aEndX, aEndY);
17430     if (ex != NULL) SignDoc_throw (ex);
17431     if (r == NULL)
17432       return NULL;
17433     try
17434       {
17435         return new SignDocAnnotation (r);
17436       }
17437     catch (...)
17438       {
17439         SIGNDOC_Annotation_delete (r);
17440         throw;
17441       }
17442   }
17443 
17456   SignDocAnnotation *createScribbleAnnotation ()
17457   {
17458     SIGNDOC_Exception *ex = NULL;
17459     SIGNDOC_Annotation *r;
17460     r = SIGNDOC_Document_createScribbleAnnotation (&ex, p);
17461     if (ex != NULL) SignDoc_throw (ex);
17462     if (r == NULL)
17463       return NULL;
17464     try
17465       {
17466         return new SignDocAnnotation (r);
17467       }
17468     catch (...)
17469       {
17470         SIGNDOC_Annotation_delete (r);
17471         throw;
17472       }
17473   }
17474 
17490   SignDocAnnotation *createFreeTextAnnotation (const Point &aLowerLeft,
17491                                                const Point &aUpperRight)
17492   {
17493     SIGNDOC_Exception *ex = NULL;
17494     SIGNDOC_Annotation *r;
17495     r = SIGNDOC_Document_createFreeTextAnnotation (&ex, p, (const SIGNDOC_Point*)&aLowerLeft, (const SIGNDOC_Point*)&aUpperRight);
17496     if (ex != NULL) SignDoc_throw (ex);
17497     if (r == NULL)
17498       return NULL;
17499     try
17500       {
17501         return new SignDocAnnotation (r);
17502       }
17503     catch (...)
17504       {
17505         SIGNDOC_Annotation_delete (r);
17506         throw;
17507       }
17508   }
17509 
17527   SignDocAnnotation *createFreeTextAnnotation (double aX0, double aY0,
17528                                                double aX1, double aY1)
17529   {
17530     SIGNDOC_Exception *ex = NULL;
17531     SIGNDOC_Annotation *r;
17532     r = SIGNDOC_Document_createFreeTextAnnotationXY (&ex, p, aX0, aY0, aX1, aY1);
17533     if (ex != NULL) SignDoc_throw (ex);
17534     if (r == NULL)
17535       return NULL;
17536     try
17537       {
17538         return new SignDocAnnotation (r);
17539       }
17540     catch (...)
17541       {
17542         SIGNDOC_Annotation_delete (r);
17543         throw;
17544       }
17545   }
17546 
17560   ReturnCode addAnnotation (int aPage, const SignDocAnnotation *aAnnot)
17561   {
17562     SIGNDOC_Exception *ex = NULL;
17563     ReturnCode r;
17564     r = (ReturnCode)SIGNDOC_Document_addAnnotation (&ex, p, aPage, aAnnot == NULL ? NULL : aAnnot->getImpl ());
17565     if (ex != NULL) SignDoc_throw (ex);
17566     return r;
17567   }
17568 
17588   ReturnCode getAnnotations (Encoding aEncoding, int aPage,
17589                              std::vector<std::string> &aOutput)
17590   {
17591     SIGNDOC_Exception *ex = NULL;
17592     SIGNDOC_StringArray *tempOutput = NULL;
17593     ReturnCode r;
17594     try
17595       {
17596         tempOutput = SIGNDOC_StringArray_new (&ex);
17597         if (ex != NULL) SignDoc_throw (ex);
17598         r = (ReturnCode)SIGNDOC_Document_getAnnotations (&ex, p, aEncoding, aPage, tempOutput);
17599         assignArray (aOutput, tempOutput);
17600       }
17601     catch (...)
17602       {
17603         if (tempOutput != NULL)
17604           SIGNDOC_StringArray_delete (tempOutput);
17605         throw;
17606       }
17607     if (tempOutput != NULL)
17608       SIGNDOC_StringArray_delete (tempOutput);
17609     if (ex != NULL) SignDoc_throw (ex);
17610     return r;
17611   }
17612 
17629   ReturnCode getAnnotation (Encoding aEncoding, int aPage,
17630                             const std::string &aName,
17631                             SIGNDOC_PTR<SignDocAnnotation> &aOutput)
17632   {
17633     SIGNDOC_Exception *ex = NULL;
17634     SIGNDOC_Annotation *tempOutput = NULL;
17635     aOutput.reset ((SignDocAnnotation*)NULL);
17636     ReturnCode r;
17637     try
17638       {
17639         r = (ReturnCode)SIGNDOC_Document_getAnnotation (&ex, p, aEncoding, aPage, aName.c_str (), &tempOutput);
17640         if (tempOutput != NULL)
17641           {
17642             aOutput.reset (new SignDocAnnotation (tempOutput));
17643             tempOutput = NULL;
17644           }
17645       }
17646     catch (...)
17647       {
17648         if (tempOutput != NULL)
17649           SIGNDOC_Annotation_delete (tempOutput);
17650         throw;
17651       }
17652     if (tempOutput != NULL)
17653       SIGNDOC_Annotation_delete (tempOutput);
17654     if (ex != NULL) SignDoc_throw (ex);
17655     return r;
17656   }
17657 
17670   ReturnCode removeAnnotation (Encoding aEncoding, int aPage,
17671                                const std::string &aName)
17672   {
17673     SIGNDOC_Exception *ex = NULL;
17674     ReturnCode r;
17675     r = (ReturnCode)SIGNDOC_Document_removeAnnotation (&ex, p, aEncoding, aPage, aName.c_str ());
17676     if (ex != NULL) SignDoc_throw (ex);
17677     return r;
17678   }
17679 
17714   ReturnCode addText (Encoding aEncoding, const std::string &aText, int aPage,
17715                       double aX, double aY, const std::string &aFontName,
17716                       double aFontSize, const SignDocColor &aTextColor,
17717                       double aOpacity, int aFlags)
17718   {
17719     SIGNDOC_Exception *ex = NULL;
17720     ReturnCode r;
17721     r = (ReturnCode)SIGNDOC_Document_addText (&ex, p, aEncoding, aText.c_str (), aPage, aX, aY, aFontName.c_str (), aFontSize, aTextColor.getImpl (), aOpacity, aFlags);
17722     if (ex != NULL) SignDoc_throw (ex);
17723     return r;
17724   }
17725 
17761   ReturnCode addTextRect (Encoding aEncoding, const std::string &aText,
17762                           int aPage, double aX0, double aY0, double aX1,
17763                           double aY1, const std::string &aFontName,
17764                           double aFontSize, double aLineSkip,
17765                           const SignDocColor &aTextColor, double aOpacity,
17766                           HAlignment aHAlignment, VAlignment aVAlignment,
17767                           int aFlags)
17768   {
17769     SIGNDOC_Exception *ex = NULL;
17770     ReturnCode r;
17771     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);
17772     if (ex != NULL) SignDoc_throw (ex);
17773     return r;
17774   }
17775 
17785   ReturnCode addWatermark (const SignDocWatermark &aInput)
17786   {
17787     SIGNDOC_Exception *ex = NULL;
17788     ReturnCode r;
17789     r = (ReturnCode)SIGNDOC_Document_addWatermark (&ex, p, aInput.getImpl ());
17790     if (ex != NULL) SignDoc_throw (ex);
17791     return r;
17792   }
17793 
17813   ReturnCode findText (Encoding aEncoding, int aFirstPage, int aLastPage,
17814                        const std::string &aText, int aFlags,
17815                        std::vector<SignDocFindTextPosition> &aOutput)
17816   {
17817     SIGNDOC_Exception *ex = NULL;
17818     SIGNDOC_FindTextPositionArray *tempOutput = NULL;
17819     ReturnCode r;
17820     try
17821       {
17822         tempOutput = SIGNDOC_FindTextPositionArray_new (&ex);
17823         if (ex != NULL) SignDoc_throw (ex);
17824         r = (ReturnCode)SIGNDOC_Document_findText (&ex, p, aEncoding, aFirstPage, aLastPage, aText.c_str (), aFlags, tempOutput);
17825         assignArray (aOutput, tempOutput);
17826       }
17827     catch (...)
17828       {
17829         if (tempOutput != NULL)
17830           SIGNDOC_FindTextPositionArray_delete (tempOutput);
17831         throw;
17832       }
17833     if (tempOutput != NULL)
17834       SIGNDOC_FindTextPositionArray_delete (tempOutput);
17835     if (ex != NULL) SignDoc_throw (ex);
17836     return r;
17837   }
17838 
17865   ReturnCode addAttachmentBlob (Encoding aEncoding, const std::string &aName,
17866                                 const std::string &aDescription,
17867                                 const std::string &aType,
17868                                 const std::string &aModificationTime,
17869                                 const void *aPtr, size_t aSize, int aFlags)
17870   {
17871     SIGNDOC_Exception *ex = NULL;
17872     ReturnCode r;
17873     r = (ReturnCode)SIGNDOC_Document_addAttachmentBlob (&ex, p, aEncoding, aName.c_str (), aDescription.c_str (), aType.c_str (), aModificationTime.c_str (), aPtr, aSize, aFlags);
17874     if (ex != NULL) SignDoc_throw (ex);
17875     return r;
17876   }
17877 
17899   ReturnCode addAttachmentFile (Encoding aEncoding1, const std::string &aName,
17900                                 const std::string &aDescription,
17901                                 const std::string &aType, Encoding aEncoding2,
17902                                 const std::string &aPath, int aFlags)
17903   {
17904     SIGNDOC_Exception *ex = NULL;
17905     ReturnCode r;
17906     r = (ReturnCode)SIGNDOC_Document_addAttachmentFile (&ex, p, aEncoding1, aName.c_str (), aDescription.c_str (), aType.c_str (), aEncoding2, aPath.c_str (), aFlags);
17907     if (ex != NULL) SignDoc_throw (ex);
17908     return r;
17909   }
17910 
17923   ReturnCode removeAttachment (Encoding aEncoding, const std::string &aName)
17924   {
17925     SIGNDOC_Exception *ex = NULL;
17926     ReturnCode r;
17927     r = (ReturnCode)SIGNDOC_Document_removeAttachment (&ex, p, aEncoding, aName.c_str ());
17928     if (ex != NULL) SignDoc_throw (ex);
17929     return r;
17930   }
17931 
17945   ReturnCode changeAttachmentDescription (Encoding aEncoding,
17946                                           const std::string &aName,
17947                                           const std::string &aDescription)
17948   {
17949     SIGNDOC_Exception *ex = NULL;
17950     ReturnCode r;
17951     r = (ReturnCode)SIGNDOC_Document_changeAttachmentDescription (&ex, p, aEncoding, aName.c_str (), aDescription.c_str ());
17952     if (ex != NULL) SignDoc_throw (ex);
17953     return r;
17954   }
17955 
17971   ReturnCode getAttachments (Encoding aEncoding,
17972                              std::vector<std::string> &aOutput)
17973   {
17974     SIGNDOC_Exception *ex = NULL;
17975     SIGNDOC_StringArray *tempOutput = NULL;
17976     ReturnCode r;
17977     try
17978       {
17979         tempOutput = SIGNDOC_StringArray_new (&ex);
17980         if (ex != NULL) SignDoc_throw (ex);
17981         r = (ReturnCode)SIGNDOC_Document_getAttachments (&ex, p, aEncoding, tempOutput);
17982         assignArray (aOutput, tempOutput);
17983       }
17984     catch (...)
17985       {
17986         if (tempOutput != NULL)
17987           SIGNDOC_StringArray_delete (tempOutput);
17988         throw;
17989       }
17990     if (tempOutput != NULL)
17991       SIGNDOC_StringArray_delete (tempOutput);
17992     if (ex != NULL) SignDoc_throw (ex);
17993     return r;
17994   }
17995 
18010   ReturnCode getAttachment (Encoding aEncoding, const std::string &aName,
18011                             SignDocAttachment &aOutput)
18012   {
18013     SIGNDOC_Exception *ex = NULL;
18014     ReturnCode r;
18015     r = (ReturnCode)SIGNDOC_Document_getAttachment (&ex, p, aEncoding, aName.c_str (), aOutput.getImpl ());
18016     if (ex != NULL) SignDoc_throw (ex);
18017     return r;
18018   }
18019 
18033   ReturnCode checkAttachment (Encoding aEncoding, const std::string &aName,
18034                               CheckAttachmentResult &aOutput)
18035   {
18036     SIGNDOC_Exception *ex = NULL;
18037     int tempOutput = 0;
18038     ReturnCode r;
18039     try
18040       {
18041         r = (ReturnCode)SIGNDOC_Document_checkAttachment (&ex, p, aEncoding, aName.c_str (), &tempOutput);
18042         aOutput = (CheckAttachmentResult )tempOutput;
18043       }
18044     catch (...)
18045       {
18046         throw;
18047       }
18048     if (ex != NULL) SignDoc_throw (ex);
18049     return r;
18050   }
18051 
18065   ReturnCode getAttachmentBlob (Encoding aEncoding, const std::string &aName,
18066                                 std::vector<unsigned char> &aOutput)
18067   {
18068     SIGNDOC_Exception *ex = NULL;
18069     SIGNDOC_ByteArray *tempOutput = NULL;
18070     ReturnCode r;
18071     try
18072       {
18073         tempOutput = SIGNDOC_ByteArray_new (&ex);
18074         if (ex != NULL) SignDoc_throw (ex);
18075         r = (ReturnCode)SIGNDOC_Document_getAttachmentBlob (&ex, p, aEncoding, aName.c_str (), tempOutput);
18076         assignArray (aOutput, tempOutput);
18077       }
18078     catch (...)
18079       {
18080         if (tempOutput != NULL)
18081           SIGNDOC_ByteArray_delete (tempOutput);
18082         throw;
18083       }
18084     if (tempOutput != NULL)
18085       SIGNDOC_ByteArray_delete (tempOutput);
18086     if (ex != NULL) SignDoc_throw (ex);
18087     return r;
18088   }
18089 
18106   ReturnCode getAttachmentStream (Encoding aEncoding, const std::string &aName,
18107                                   SIGNDOC_PTR<InputStream> &aOutput)
18108   {
18109     SIGNDOC_Exception *ex = NULL;
18110     SIGNDOC_InputStream *tempOutput = NULL;
18111     aOutput.reset ((InputStream*)NULL);
18112     ReturnCode r;
18113     try
18114       {
18115         r = (ReturnCode)SIGNDOC_Document_getAttachmentStream (&ex, p, aEncoding, aName.c_str (), &tempOutput);
18116         if (tempOutput != NULL)
18117           {
18118             aOutput.reset (new LibraryInputStream (tempOutput));
18119             tempOutput = NULL;
18120           }
18121       }
18122     catch (...)
18123       {
18124         if (tempOutput != NULL)
18125           SIGNDOC_InputStream_delete (tempOutput);
18126         throw;
18127       }
18128     if (tempOutput != NULL)
18129       SIGNDOC_InputStream_delete (tempOutput);
18130     if (ex != NULL) SignDoc_throw (ex);
18131     return r;
18132   }
18133 
18149   ReturnCode addPage (int aTargetPage, double aWidth, double aHeight)
18150   {
18151     SIGNDOC_Exception *ex = NULL;
18152     ReturnCode r;
18153     r = (ReturnCode)SIGNDOC_Document_addPage (&ex, p, aTargetPage, aWidth, aHeight);
18154     if (ex != NULL) SignDoc_throw (ex);
18155     return r;
18156   }
18157 
18185   ReturnCode importPages (int aTargetPage, SignDocDocument *aSource,
18186                           int aSourcePage, int aPageCount, int aFlags)
18187   {
18188     SIGNDOC_Exception *ex = NULL;
18189     ReturnCode r;
18190     r = (ReturnCode)SIGNDOC_Document_importPages (&ex, p, aTargetPage, aSource == NULL ? NULL : aSource->getImpl (), aSourcePage, aPageCount, aFlags);
18191     if (ex != NULL) SignDoc_throw (ex);
18192     return r;
18193   }
18194 
18232   ReturnCode importPageFromImageBlob (int aTargetPage,
18233                                       const unsigned char *aPtr, size_t aSize,
18234                                       double aZoom, double aWidth,
18235                                       double aHeight, int aFlags)
18236   {
18237     SIGNDOC_Exception *ex = NULL;
18238     ReturnCode r;
18239     r = (ReturnCode)SIGNDOC_Document_importPageFromImageBlob (&ex, p, aTargetPage, aPtr, aSize, aZoom, aWidth, aHeight, aFlags);
18240     if (ex != NULL) SignDoc_throw (ex);
18241     return r;
18242   }
18243 
18279   ReturnCode importPageFromImageFile (int aTargetPage, Encoding aEncoding,
18280                                       const std::string &aPath, double aZoom,
18281                                       double aWidth, double aHeight,
18282                                       int aFlags)
18283   {
18284     SIGNDOC_Exception *ex = NULL;
18285     ReturnCode r;
18286     r = (ReturnCode)SIGNDOC_Document_importPageFromImageFile (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aWidth, aHeight, aFlags);
18287     if (ex != NULL) SignDoc_throw (ex);
18288     return r;
18289   }
18290 
18330   ReturnCode addImageFromBlob (int aTargetPage, const unsigned char *aPtr,
18331                                size_t aSize, double aZoom, double aX,
18332                                double aY, double aWidth, double aHeight,
18333                                int aFlags)
18334   {
18335     SIGNDOC_Exception *ex = NULL;
18336     ReturnCode r;
18337     r = (ReturnCode)SIGNDOC_Document_addImageFromBlob (&ex, p, aTargetPage, aPtr, aSize, aZoom, aX, aY, aWidth, aHeight, aFlags);
18338     if (ex != NULL) SignDoc_throw (ex);
18339     return r;
18340   }
18341 
18379   ReturnCode addImageFromFile (int aTargetPage, Encoding aEncoding,
18380                                const std::string &aPath, double aZoom,
18381                                double aX, double aY, double aWidth,
18382                                double aHeight, int aFlags)
18383   {
18384     SIGNDOC_Exception *ex = NULL;
18385     ReturnCode r;
18386     r = (ReturnCode)SIGNDOC_Document_addImageFromFile (&ex, p, aTargetPage, aEncoding, aPath.c_str (), aZoom, aX, aY, aWidth, aHeight, aFlags);
18387     if (ex != NULL) SignDoc_throw (ex);
18388     return r;
18389   }
18390 
18411   ReturnCode removePages (const int *aPagesPtr, int aPagesCount,
18412                           KeepOrRemove aMode)
18413   {
18414     SIGNDOC_Exception *ex = NULL;
18415     ReturnCode r;
18416     r = (ReturnCode)SIGNDOC_Document_removePages (&ex, p, aPagesPtr, aPagesCount, aMode);
18417     if (ex != NULL) SignDoc_throw (ex);
18418     return r;
18419   }
18420 
18435   ReturnCode setCompatibility (int aMajor, int aMinor)
18436   {
18437     SIGNDOC_Exception *ex = NULL;
18438     ReturnCode r;
18439     r = (ReturnCode)SIGNDOC_Document_setCompatibility (&ex, p, aMajor, aMinor);
18440     if (ex != NULL) SignDoc_throw (ex);
18441     return r;
18442   }
18443 
18453   ReturnCode isModified (bool &aModified) const
18454   {
18455     SIGNDOC_Exception *ex = NULL;
18456     SIGNDOC_Boolean tempModified = 0;
18457     ReturnCode r;
18458     try
18459       {
18460         r = (ReturnCode)SIGNDOC_Document_isModified (&ex, p, &tempModified);
18461         aModified = (bool )tempModified;
18462       }
18463     catch (...)
18464       {
18465         throw;
18466       }
18467     if (ex != NULL) SignDoc_throw (ex);
18468     return r;
18469   }
18470 
18482   ReturnCode setFlags (unsigned aFlags)
18483   {
18484     SIGNDOC_Exception *ex = NULL;
18485     ReturnCode r;
18486     r = (ReturnCode)SIGNDOC_Document_setFlags (&ex, p, aFlags);
18487     if (ex != NULL) SignDoc_throw (ex);
18488     return r;
18489   }
18490 
18498   unsigned getFlags () const
18499   {
18500     SIGNDOC_Exception *ex = NULL;
18501     unsigned r;
18502     r = SIGNDOC_Document_getFlags (&ex, p);
18503     if (ex != NULL) SignDoc_throw (ex);
18504     return r;
18505   }
18506 
18524   ReturnCode setCompressionLevel (int aLevel)
18525   {
18526     SIGNDOC_Exception *ex = NULL;
18527     ReturnCode r;
18528     r = (ReturnCode)SIGNDOC_Document_setCompressionLevel (&ex, p, aLevel);
18529     if (ex != NULL) SignDoc_throw (ex);
18530     return r;
18531   }
18532 
18552   int getDocMDP () const
18553   {
18554     SIGNDOC_Exception *ex = NULL;
18555     int r;
18556     r = SIGNDOC_Document_getDocMDP (&ex, p);
18557     if (ex != NULL) SignDoc_throw (ex);
18558     return r;
18559   }
18560 
18580   int getLockMDP () const
18581   {
18582     SIGNDOC_Exception *ex = NULL;
18583     int r;
18584     r = SIGNDOC_Document_getLockMDP (&ex, p);
18585     if (ex != NULL) SignDoc_throw (ex);
18586     return r;
18587   }
18588 
18599   ReturnCode removeDocMDP ()
18600   {
18601     SIGNDOC_Exception *ex = NULL;
18602     ReturnCode r;
18603     r = (ReturnCode)SIGNDOC_Document_removeDocMDP (&ex, p);
18604     if (ex != NULL) SignDoc_throw (ex);
18605     return r;
18606   }
18607 
18630   ReturnCode removePermissions (unsigned aFlags)
18631   {
18632     SIGNDOC_Exception *ex = NULL;
18633     ReturnCode r;
18634     r = (ReturnCode)SIGNDOC_Document_removePermissions (&ex, p, aFlags);
18635     if (ex != NULL) SignDoc_throw (ex);
18636     return r;
18637   }
18638 
18654   ReturnCode removePDFA (unsigned aFlags)
18655   {
18656     SIGNDOC_Exception *ex = NULL;
18657     ReturnCode r;
18658     r = (ReturnCode)SIGNDOC_Document_removePDFA (&ex, p, aFlags);
18659     if (ex != NULL) SignDoc_throw (ex);
18660     return r;
18661   }
18662 
18678   ReturnCode removePDFUA (unsigned aFlags)
18679   {
18680     SIGNDOC_Exception *ex = NULL;
18681     ReturnCode r;
18682     r = (ReturnCode)SIGNDOC_Document_removePDFUA (&ex, p, aFlags);
18683     if (ex != NULL) SignDoc_throw (ex);
18684     return r;
18685   }
18686 
18696   ReturnCode removeLogicalStructure (unsigned aFlags)
18697   {
18698     SIGNDOC_Exception *ex = NULL;
18699     ReturnCode r;
18700     r = (ReturnCode)SIGNDOC_Document_removeLogicalStructure (&ex, p, aFlags);
18701     if (ex != NULL) SignDoc_throw (ex);
18702     return r;
18703   }
18704 
18724   ReturnCode removeXFA (unsigned aFlags)
18725   {
18726     SIGNDOC_Exception *ex = NULL;
18727     ReturnCode r;
18728     r = (ReturnCode)SIGNDOC_Document_removeXFA (&ex, p, aFlags);
18729     if (ex != NULL) SignDoc_throw (ex);
18730     return r;
18731   }
18732 
18748   ReturnCode setShootInFoot (unsigned aFlags)
18749   {
18750     SIGNDOC_Exception *ex = NULL;
18751     ReturnCode r;
18752     r = (ReturnCode)SIGNDOC_Document_setShootInFoot (&ex, p, aFlags);
18753     if (ex != NULL) SignDoc_throw (ex);
18754     return r;
18755   }
18756 
18764   unsigned getShootInFoot () const
18765   {
18766     SIGNDOC_Exception *ex = NULL;
18767     unsigned r;
18768     r = SIGNDOC_Document_getShootInFoot (&ex, p);
18769     if (ex != NULL) SignDoc_throw (ex);
18770     return r;
18771   }
18772 
18786   const char *getErrorMessage (Encoding aEncoding) const
18787   {
18788     SIGNDOC_Exception *ex = NULL;
18789     const char *r;
18790     r = SIGNDOC_Document_getErrorMessage (&ex, p, aEncoding);
18791     if (ex != NULL) SignDoc_throw (ex);
18792     return r;
18793   }
18794 
18806   const wchar_t *getErrorMessageW () const
18807   {
18808     SIGNDOC_Exception *ex = NULL;
18809     const wchar_t *r;
18810     r = SIGNDOC_Document_getErrorMessageW (&ex, p);
18811     if (ex != NULL) SignDoc_throw (ex);
18812     return r;
18813   }
18814 
18836   SPPDF_Document *getSPPDFDocument (bool aDestroy)
18837   {
18838     SIGNDOC_Exception *ex = NULL;
18839     SPPDF_Document *r;
18840     r = SIGNDOC_Document_getSPPDFDocument (&ex, p, aDestroy);
18841     if (ex != NULL) SignDoc_throw (ex);
18842     return r;
18843   }
18844 
18858   ReturnCode getPageLabel (int aPage, std::string &aOutput)
18859   {
18860     SIGNDOC_Exception *ex = NULL;
18861     char *tempOutput = NULL;
18862     ReturnCode r;
18863     try
18864       {
18865         r = (ReturnCode)SIGNDOC_Document_getPageLabel (&ex, p, aPage, &tempOutput);
18866         if (tempOutput != NULL)
18867           aOutput = tempOutput;
18868       }
18869     catch (...)
18870       {
18871         SIGNDOC_free (tempOutput);
18872         throw;
18873       }
18874     SIGNDOC_free (tempOutput);
18875     if (ex != NULL) SignDoc_throw (ex);
18876     return r;
18877   }
18878 
18906   ReturnCode flattenAnnotations (int aFirstPage, int aLastPage,
18907                                  unsigned aFlags)
18908   {
18909     SIGNDOC_Exception *ex = NULL;
18910     ReturnCode r;
18911     r = (ReturnCode)SIGNDOC_Document_flattenAnnotations (&ex, p, aFirstPage, aLastPage, aFlags);
18912     if (ex != NULL) SignDoc_throw (ex);
18913     return r;
18914   }
18915 
18916 private:
18920   SignDocDocument (const SignDocDocument &);
18921 
18925   SignDocDocument &operator= (const SignDocDocument &);
18926 public:
18931   SignDocDocument (SIGNDOC_Document *aP) : p (aP) { }
18932 
18937   SIGNDOC_Document *getImpl () { return p; }
18938 
18943   const SIGNDOC_Document *getImpl () const { return p; }
18944 
18949   void setImpl (SIGNDOC_Document *aP) { SIGNDOC_Document_delete (p); p  = aP; }
18950 
18951 private:
18952   SIGNDOC_Document *p;
18953 };
18954 
18958 class SignDocDocumentHandler 
18959 {
18960 public:
18966   SignDocDocumentHandler ()
18967     : p (NULL)
18968   {
18969   }
18970 
18976   virtual ~SignDocDocumentHandler ()
18977   {
18978     SIGNDOC_DocumentHandler_delete (p);
18979   }
18980 
18981 private:
18985   SignDocDocumentHandler (const SignDocDocumentHandler &);
18986 
18987 public:
18992   SignDocDocumentHandler (SIGNDOC_DocumentHandler *aP) : p (aP) { }
18993 
18998   SIGNDOC_DocumentHandler *getImpl () { return p; }
18999 
19004   const SIGNDOC_DocumentHandler *getImpl () const { return p; }
19005 
19010   void destroyWithoutImpl () { p = NULL; delete this; }
19011 
19016   void setImpl (SIGNDOC_DocumentHandler *aP) { SIGNDOC_DocumentHandler_delete (p); p  = aP; }
19017 
19018 protected:
19019   SIGNDOC_DocumentHandler *p;
19020 };
19021 
19041 class SignDocDocumentLoader 
19042 {
19043 public:
19047   enum RemainingDays
19048   {
19052     rd_product,
19053 
19057     rd_signing
19058   };
19059 
19063   enum Flags
19064   {
19075     f_map_into_memory = 0x01
19076   };
19077 
19078 public:
19082   SignDocDocumentLoader ()
19083     : p (NULL)
19084   {
19085     SIGNDOC_Exception *ex = NULL;
19086     p = SIGNDOC_DocumentLoader_new (&ex);
19087     if (ex != NULL) SignDoc_throw (ex);
19088   }
19089 
19093   ~SignDocDocumentLoader ()
19094   {
19095     SIGNDOC_DocumentLoader_delete (p);
19096   }
19097 
19114   static bool initLicenseManager (int aWho1, int aWho2)
19115   {
19116     SIGNDOC_Exception *ex = NULL;
19117     bool r;
19118     r = (bool)SIGNDOC_DocumentLoader_initLicenseManager (&ex, aWho1, aWho2);
19119     if (ex != NULL) SignDoc_throw (ex);
19120     return r;
19121   }
19122 
19142   static bool setLicenseKey (const void *aKeyPtr, size_t aKeySize,
19143                              const char *aProduct, const char *aVersion,
19144                              const void *aTokenPtr, size_t aTokenSize)
19145   {
19146     SIGNDOC_Exception *ex = NULL;
19147     bool r;
19148     r = (bool)SIGNDOC_DocumentLoader_setLicenseKey (&ex, aKeyPtr, aKeySize, aProduct, aVersion, aTokenPtr, aTokenSize);
19149     if (ex != NULL) SignDoc_throw (ex);
19150     return r;
19151   }
19152 
19165   static bool generateLicenseToken (const char *aProduct,
19166                                     std::vector<unsigned char> &aOutput)
19167   {
19168     SIGNDOC_Exception *ex = NULL;
19169     SIGNDOC_ByteArray *tempOutput = NULL;
19170     bool r;
19171     try
19172       {
19173         tempOutput = SIGNDOC_ByteArray_new (&ex);
19174         if (ex != NULL) SignDoc_throw (ex);
19175         r = (bool)SIGNDOC_DocumentLoader_generateLicenseToken (&ex, aProduct, tempOutput);
19176         assignArray (aOutput, tempOutput);
19177       }
19178     catch (...)
19179       {
19180         if (tempOutput != NULL)
19181           SIGNDOC_ByteArray_delete (tempOutput);
19182         throw;
19183       }
19184     if (tempOutput != NULL)
19185       SIGNDOC_ByteArray_delete (tempOutput);
19186     if (ex != NULL) SignDoc_throw (ex);
19187     return r;
19188   }
19189 
19202   static int getRemainingDays (RemainingDays aWhat)
19203   {
19204     SIGNDOC_Exception *ex = NULL;
19205     int r;
19206     r = SIGNDOC_DocumentLoader_getRemainingDays (&ex, aWhat);
19207     if (ex != NULL) SignDoc_throw (ex);
19208     return r;
19209   }
19210 
19219   static bool getInstallationCode (std::string &aCode)
19220   {
19221     SIGNDOC_Exception *ex = NULL;
19222     char *tempCode = NULL;
19223     bool r;
19224     try
19225       {
19226         r = (bool)SIGNDOC_DocumentLoader_getInstallationCode (&ex, &tempCode);
19227         if (tempCode != NULL)
19228           aCode = tempCode;
19229       }
19230     catch (...)
19231       {
19232         SIGNDOC_free (tempCode);
19233         throw;
19234       }
19235     SIGNDOC_free (tempCode);
19236     if (ex != NULL) SignDoc_throw (ex);
19237     return r;
19238   }
19239 
19251   static bool getVersionNumber (std::string &aVersion)
19252   {
19253     SIGNDOC_Exception *ex = NULL;
19254     char *tempVersion = NULL;
19255     bool r;
19256     try
19257       {
19258         r = (bool)SIGNDOC_DocumentLoader_getVersionNumber (&ex, &tempVersion);
19259         if (tempVersion != NULL)
19260           aVersion = tempVersion;
19261       }
19262     catch (...)
19263       {
19264         SIGNDOC_free (tempVersion);
19265         throw;
19266       }
19267     SIGNDOC_free (tempVersion);
19268     if (ex != NULL) SignDoc_throw (ex);
19269     return r;
19270   }
19271 
19285   static bool getComponentVersionNumber (const char *aComponent,
19286                                          std::string &aVersion)
19287   {
19288     SIGNDOC_Exception *ex = NULL;
19289     char *tempVersion = NULL;
19290     bool r;
19291     try
19292       {
19293         r = (bool)SIGNDOC_DocumentLoader_getComponentVersionNumber (&ex, aComponent, &tempVersion);
19294         if (tempVersion != NULL)
19295           aVersion = tempVersion;
19296       }
19297     catch (...)
19298       {
19299         SIGNDOC_free (tempVersion);
19300         throw;
19301       }
19302     SIGNDOC_free (tempVersion);
19303     if (ex != NULL) SignDoc_throw (ex);
19304     return r;
19305   }
19306 
19317   static int getLicenseTextCount ()
19318   {
19319     SIGNDOC_Exception *ex = NULL;
19320     int r;
19321     r = SIGNDOC_DocumentLoader_getLicenseTextCount (&ex);
19322     if (ex != NULL) SignDoc_throw (ex);
19323     return r;
19324   }
19325 
19340   static const char *getLicenseText (int aIndex)
19341   {
19342     SIGNDOC_Exception *ex = NULL;
19343     const char *r;
19344     r = SIGNDOC_DocumentLoader_getLicenseText (&ex, aIndex);
19345     if (ex != NULL) SignDoc_throw (ex);
19346     return r;
19347   }
19348 
19365   SignDocDocument *loadFromMemory (const unsigned char *aData, size_t aSize,
19366                                    bool aCopy)
19367   {
19368     SIGNDOC_Exception *ex = NULL;
19369     SIGNDOC_Document *r;
19370     r = SIGNDOC_DocumentLoader_loadFromMemory (&ex, p, aData, aSize, aCopy);
19371     if (ex != NULL) SignDoc_throw (ex);
19372     if (r == NULL)
19373       return NULL;
19374     try
19375       {
19376         return new SignDocDocument (r);
19377       }
19378     catch (...)
19379       {
19380         SIGNDOC_Document_delete (r);
19381         throw;
19382       }
19383   }
19384 
19411   SignDocDocument *loadFromFile (Encoding aEncoding, const char *aPath,
19412                                  bool aWritable)
19413   {
19414     SIGNDOC_Exception *ex = NULL;
19415     SIGNDOC_Document *r;
19416     r = SIGNDOC_DocumentLoader_loadFromFile (&ex, p, aEncoding, aPath, aWritable);
19417     if (ex != NULL) SignDoc_throw (ex);
19418     if (r == NULL)
19419       return NULL;
19420     try
19421       {
19422         return new SignDocDocument (r);
19423       }
19424     catch (...)
19425       {
19426         SIGNDOC_Document_delete (r);
19427         throw;
19428       }
19429   }
19430 
19453   SignDocDocument *loadFromFile (const wchar_t *aPath, bool aWritable)
19454   {
19455     SIGNDOC_Exception *ex = NULL;
19456     SIGNDOC_Document *r;
19457     r = SIGNDOC_DocumentLoader_loadFromFileW (&ex, p, aPath, aWritable);
19458     if (ex != NULL) SignDoc_throw (ex);
19459     if (r == NULL)
19460       return NULL;
19461     try
19462       {
19463         return new SignDocDocument (r);
19464       }
19465     catch (...)
19466       {
19467         SIGNDOC_Document_delete (r);
19468         throw;
19469       }
19470   }
19471 
19487   SignDocDocument *createPDF (int aMajor, int aMinor)
19488   {
19489     SIGNDOC_Exception *ex = NULL;
19490     SIGNDOC_Document *r;
19491     r = SIGNDOC_DocumentLoader_createPDF (&ex, p, aMajor, aMinor);
19492     if (ex != NULL) SignDoc_throw (ex);
19493     if (r == NULL)
19494       return NULL;
19495     try
19496       {
19497         return new SignDocDocument (r);
19498       }
19499     catch (...)
19500       {
19501         SIGNDOC_Document_delete (r);
19502         throw;
19503       }
19504   }
19505 
19535   SignDocDocument *createPDFA (int aMajor, int aMinor,
19536                                const char *aConformance,
19537                                const unsigned char *aICCPtr, size_t aICCSize)
19538   {
19539     SIGNDOC_Exception *ex = NULL;
19540     SIGNDOC_Document *r;
19541     r = SIGNDOC_DocumentLoader_createPDFA (&ex, p, aMajor, aMinor, aConformance, aICCPtr, aICCSize);
19542     if (ex != NULL) SignDoc_throw (ex);
19543     if (r == NULL)
19544       return NULL;
19545     try
19546       {
19547         return new SignDocDocument (r);
19548       }
19549     catch (...)
19550       {
19551         SIGNDOC_Document_delete (r);
19552         throw;
19553       }
19554   }
19555 
19565   SignDocDocument::DocumentType ping (InputStream &aStream)
19566   {
19567     SIGNDOC_Exception *ex = NULL;
19568     SignDocDocument::DocumentType r;
19569     r = (SignDocDocument::DocumentType)SIGNDOC_DocumentLoader_ping (&ex, p, aStream.getImpl ());
19570     if (ex != NULL) SignDoc_throw (ex);
19571     return r;
19572   }
19573 
19599   bool loadFontConfigFile (Encoding aEncoding, const char *aPath)
19600   {
19601     SIGNDOC_Exception *ex = NULL;
19602     bool r;
19603     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigFile (&ex, p, aEncoding, aPath);
19604     if (ex != NULL) SignDoc_throw (ex);
19605     return r;
19606   }
19607 
19629   bool loadFontConfigFile (const wchar_t *aPath)
19630   {
19631     SIGNDOC_Exception *ex = NULL;
19632     bool r;
19633     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigFileW (&ex, p, aPath);
19634     if (ex != NULL) SignDoc_throw (ex);
19635     return r;
19636   }
19637 
19662   bool loadFontConfigEnvironment (const char *aName)
19663   {
19664     SIGNDOC_Exception *ex = NULL;
19665     bool r;
19666     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigEnvironment (&ex, p, aName);
19667     if (ex != NULL) SignDoc_throw (ex);
19668     return r;
19669   }
19670 
19702   bool loadFontConfigStream (InputStream &aStream, Encoding aEncoding,
19703                              const char *aDirectory)
19704   {
19705     SIGNDOC_Exception *ex = NULL;
19706     bool r;
19707     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigStream (&ex, p, aStream.getImpl (), aEncoding, aDirectory);
19708     if (ex != NULL) SignDoc_throw (ex);
19709     return r;
19710   }
19711 
19739   bool loadFontConfigStream (InputStream &aStream, const wchar_t *aDirectory)
19740   {
19741     SIGNDOC_Exception *ex = NULL;
19742     bool r;
19743     r = (bool)SIGNDOC_DocumentLoader_loadFontConfigStreamW (&ex, p, aStream.getImpl (), aDirectory);
19744     if (ex != NULL) SignDoc_throw (ex);
19745     return r;
19746   }
19747 
19773   bool loadPdfFontConfigFile (Encoding aEncoding, const char *aPath)
19774   {
19775     SIGNDOC_Exception *ex = NULL;
19776     bool r;
19777     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigFile (&ex, p, aEncoding, aPath);
19778     if (ex != NULL) SignDoc_throw (ex);
19779     return r;
19780   }
19781 
19803   bool loadPdfFontConfigFile (const wchar_t *aPath)
19804   {
19805     SIGNDOC_Exception *ex = NULL;
19806     bool r;
19807     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigFileW (&ex, p, aPath);
19808     if (ex != NULL) SignDoc_throw (ex);
19809     return r;
19810   }
19811 
19839   bool loadPdfFontConfigEnvironment (const char *aName)
19840   {
19841     SIGNDOC_Exception *ex = NULL;
19842     bool r;
19843     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigEnvironment (&ex, p, aName);
19844     if (ex != NULL) SignDoc_throw (ex);
19845     return r;
19846   }
19847 
19879   bool loadPdfFontConfigStream (InputStream &aStream, Encoding aEncoding,
19880                                 const char *aDirectory)
19881   {
19882     SIGNDOC_Exception *ex = NULL;
19883     bool r;
19884     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigStream (&ex, p, aStream.getImpl (), aEncoding, aDirectory);
19885     if (ex != NULL) SignDoc_throw (ex);
19886     return r;
19887   }
19888 
19916   bool loadPdfFontConfigStream (InputStream &aStream,
19917                                 const wchar_t *aDirectory)
19918   {
19919     SIGNDOC_Exception *ex = NULL;
19920     bool r;
19921     r = (bool)SIGNDOC_DocumentLoader_loadPdfFontConfigStreamW (&ex, p, aStream.getImpl (), aDirectory);
19922     if (ex != NULL) SignDoc_throw (ex);
19923     return r;
19924   }
19925 
19942   void getFailedFontFiles (std::vector<std::string> &aOutput)
19943   {
19944     SIGNDOC_Exception *ex = NULL;
19945     SIGNDOC_StringArray *tempOutput = NULL;
19946     try
19947       {
19948         tempOutput = SIGNDOC_StringArray_new (&ex);
19949         if (ex != NULL) SignDoc_throw (ex);
19950         SIGNDOC_DocumentLoader_getFailedFontFiles (&ex, p, tempOutput);
19951         assignArray (aOutput, tempOutput);
19952       }
19953     catch (...)
19954       {
19955         if (tempOutput != NULL)
19956           SIGNDOC_StringArray_delete (tempOutput);
19957         throw;
19958       }
19959     if (tempOutput != NULL)
19960       SIGNDOC_StringArray_delete (tempOutput);
19961     if (ex != NULL) SignDoc_throw (ex);
19962   }
19963 
19988   bool loadTrustedCertificatesFromFile (Encoding aEncoding, const char *aPath)
19989   {
19990     SIGNDOC_Exception *ex = NULL;
19991     bool r;
19992     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromFile (&ex, p, aEncoding, aPath);
19993     if (ex != NULL) SignDoc_throw (ex);
19994     return r;
19995   }
19996 
20016   bool loadTrustedCertificatesFromFile (const wchar_t *aPath)
20017   {
20018     SIGNDOC_Exception *ex = NULL;
20019     bool r;
20020     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromFileW (&ex, p, aPath);
20021     if (ex != NULL) SignDoc_throw (ex);
20022     return r;
20023   }
20024 
20044   bool loadTrustedCertificatesFromStream (InputStream &aStream)
20045   {
20046     SIGNDOC_Exception *ex = NULL;
20047     bool r;
20048     r = (bool)SIGNDOC_DocumentLoader_loadTrustedCertificatesFromStream (&ex, p, aStream.getImpl ());
20049     if (ex != NULL) SignDoc_throw (ex);
20050     return r;
20051   }
20052 
20074   bool initLogging (Encoding aEncoding, const char *aLevel,
20075                     const char *aPathname)
20076   {
20077     SIGNDOC_Exception *ex = NULL;
20078     bool r;
20079     r = (bool)SIGNDOC_DocumentLoader_initLogging (&ex, p, aEncoding, aLevel, aPathname);
20080     if (ex != NULL) SignDoc_throw (ex);
20081     return r;
20082   }
20083 
20098   const char *getErrorMessage (Encoding aEncoding) const
20099   {
20100     SIGNDOC_Exception *ex = NULL;
20101     const char *r;
20102     r = SIGNDOC_DocumentLoader_getErrorMessage (&ex, p, aEncoding);
20103     if (ex != NULL) SignDoc_throw (ex);
20104     return r;
20105   }
20106 
20119   const wchar_t *getErrorMessageW () const
20120   {
20121     SIGNDOC_Exception *ex = NULL;
20122     const wchar_t *r;
20123     r = SIGNDOC_DocumentLoader_getErrorMessageW (&ex, p);
20124     if (ex != NULL) SignDoc_throw (ex);
20125     return r;
20126   }
20127 
20139   bool registerDocumentHandler (SignDocDocumentHandler *aHandler)
20140   {
20141     SIGNDOC_Exception *ex = NULL;
20142     bool r;
20143     r = (bool)SIGNDOC_DocumentLoader_registerDocumentHandler (&ex, p, aHandler == NULL ? NULL : aHandler->getImpl ());
20144     if (ex == NULL) aHandler->destroyWithoutImpl ();
20145     if (ex != NULL) SignDoc_throw (ex);
20146     return r;
20147   }
20148 
20155   void setFlags (unsigned aFlags)
20156   {
20157     SIGNDOC_Exception *ex = NULL;
20158     SIGNDOC_DocumentLoader_setFlags (&ex, p, aFlags);
20159     if (ex != NULL) SignDoc_throw (ex);
20160   }
20161 
20162 private:
20166   SignDocDocumentLoader (const SignDocDocumentLoader &);
20167 
20171   SignDocDocumentLoader &operator= (const SignDocDocumentLoader &);
20172 
20173 private:
20174 public:
20179   SignDocDocumentLoader (SIGNDOC_DocumentLoader *aP) : p (aP) { }
20180 
20185   SIGNDOC_DocumentLoader *getImpl () { return p; }
20186 
20191   const SIGNDOC_DocumentLoader *getImpl () const { return p; }
20192 
20197   void setImpl (SIGNDOC_DocumentLoader *aP) { SIGNDOC_DocumentLoader_delete (p); p  = aP; }
20198 
20199 private:
20200   SIGNDOC_DocumentLoader *p;
20201 };
20202 
20212 class SignDocVerificationResult 
20213 {
20214 public:
20220   enum ReturnCode
20221   {
20222     rc_ok = SignDocDocument::rc_ok, 
20223     rc_invalid_argument = SignDocDocument::rc_invalid_argument, 
20224     rc_not_supported = SignDocDocument::rc_not_supported, 
20225     rc_not_verified = SignDocDocument::rc_not_verified, 
20226     rc_property_not_found = SignDocDocument::rc_property_not_found, 
20227     rc_no_biometric_data = SignDocDocument::rc_no_biometric_data, 
20228     rc_unexpected_error = SignDocDocument::rc_unexpected_error 
20229   };
20230 
20234   enum SignatureState
20235   {
20236     ss_unmodified,            
20237     ss_document_extended,     
20238     ss_document_modified,     
20239     ss_unsupported_signature, 
20240     ss_invalid_certificate,   
20241     ss_empty                  
20242   };
20243 
20247   enum ModificationState
20248   {
20253     ms_unmodified,
20254 
20258     ms_allowed,
20259 
20263     ms_prohibited
20264   };
20265 
20269   enum TimeStampState
20270   {
20271     tss_valid,                
20272     tss_missing,              
20273     tss_invalid               
20274   };
20275 
20280   enum CertificateChainState
20281   {
20282     ccs_ok,                   
20283     ccs_broken_chain,         
20284     ccs_untrusted_root,       
20285     ccs_critical_extension,   
20286     ccs_not_time_valid,       
20287     ccs_path_length,          
20288     ccs_invalid,              
20289     ccs_error                 
20290   };
20291 
20296   enum CertificateRevocationState
20297   {
20298     crs_ok,                     
20299     crs_not_checked,            
20300     crs_offline,                
20301     crs_revoked,                
20302     crs_error                   
20303   };
20304 
20305 public:
20309   SignDocVerificationResult ()
20310     : p (NULL)
20311   {
20312   }
20313 
20317   ~SignDocVerificationResult ()
20318   {
20319     SIGNDOC_VerificationResult_delete (p);
20320   }
20321 
20348   ReturnCode getState (SignatureState &aOutput)
20349   {
20350     SIGNDOC_Exception *ex = NULL;
20351     int tempOutput = 0;
20352     ReturnCode r;
20353     try
20354       {
20355         r = (ReturnCode)SIGNDOC_VerificationResult_getState (&ex, p, &tempOutput);
20356         aOutput = (SignatureState )tempOutput;
20357       }
20358     catch (...)
20359       {
20360         throw;
20361       }
20362     if (ex != NULL) SignDoc_throw (ex);
20363     return r;
20364   }
20365 
20388   ReturnCode getModificationState (ModificationState &aOutput)
20389   {
20390     SIGNDOC_Exception *ex = NULL;
20391     int tempOutput = 0;
20392     ReturnCode r;
20393     try
20394       {
20395         r = (ReturnCode)SIGNDOC_VerificationResult_getModificationState (&ex, p, &tempOutput);
20396         aOutput = (ModificationState )tempOutput;
20397       }
20398     catch (...)
20399       {
20400         throw;
20401       }
20402     if (ex != NULL) SignDoc_throw (ex);
20403     return r;
20404   }
20405 
20421   ReturnCode getMethod (SignDocSignatureParameters::Method &aOutput)
20422   {
20423     SIGNDOC_Exception *ex = NULL;
20424     int tempOutput = 0;
20425     ReturnCode r;
20426     try
20427       {
20428         r = (ReturnCode)SIGNDOC_VerificationResult_getMethod (&ex, p, &tempOutput);
20429         aOutput = (SignDocSignatureParameters::Method )tempOutput;
20430       }
20431     catch (...)
20432       {
20433         throw;
20434       }
20435     if (ex != NULL) SignDoc_throw (ex);
20436     return r;
20437   }
20438 
20456   int getDocMDP ()
20457   {
20458     SIGNDOC_Exception *ex = NULL;
20459     int r;
20460     r = SIGNDOC_VerificationResult_getDocMDP (&ex, p);
20461     if (ex != NULL) SignDoc_throw (ex);
20462     return r;
20463   }
20464 
20482   int getLockMDP ()
20483   {
20484     SIGNDOC_Exception *ex = NULL;
20485     int r;
20486     r = SIGNDOC_VerificationResult_getLockMDP (&ex, p);
20487     if (ex != NULL) SignDoc_throw (ex);
20488     return r;
20489   }
20490 
20516   ReturnCode getDigestAlgorithm (std::string &aOutput)
20517   {
20518     SIGNDOC_Exception *ex = NULL;
20519     char *tempOutput = NULL;
20520     ReturnCode r;
20521     try
20522       {
20523         r = (ReturnCode)SIGNDOC_VerificationResult_getDigestAlgorithm (&ex, p, &tempOutput);
20524         if (tempOutput != NULL)
20525           aOutput = tempOutput;
20526       }
20527     catch (...)
20528       {
20529         SIGNDOC_free (tempOutput);
20530         throw;
20531       }
20532     SIGNDOC_free (tempOutput);
20533     if (ex != NULL) SignDoc_throw (ex);
20534     return r;
20535   }
20536 
20552   ReturnCode getCertificates (std::vector<std::vector<unsigned char> > &aOutput)
20553   {
20554     SIGNDOC_Exception *ex = NULL;
20555     SIGNDOC_ByteArrayArray *tempOutput = NULL;
20556     ReturnCode r;
20557     try
20558       {
20559         tempOutput = SIGNDOC_ByteArrayArray_new (&ex);
20560         if (ex != NULL) SignDoc_throw (ex);
20561         r = (ReturnCode)SIGNDOC_VerificationResult_getCertificates (&ex, p, tempOutput);
20562         assignArray (aOutput, tempOutput);
20563       }
20564     catch (...)
20565       {
20566         if (tempOutput != NULL)
20567           SIGNDOC_ByteArrayArray_delete (tempOutput);
20568         throw;
20569       }
20570     if (tempOutput != NULL)
20571       SIGNDOC_ByteArrayArray_delete (tempOutput);
20572     if (ex != NULL) SignDoc_throw (ex);
20573     return r;
20574   }
20575 
20598   ReturnCode verifyCertificateChain (const SignDocVerificationParameters *aParameters,
20599                                      CertificateChainState &aOutput)
20600   {
20601     SIGNDOC_Exception *ex = NULL;
20602     int tempOutput = 0;
20603     ReturnCode r;
20604     try
20605       {
20606         r = (ReturnCode)SIGNDOC_VerificationResult_verifyCertificateChain (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), &tempOutput);
20607         aOutput = (CertificateChainState )tempOutput;
20608       }
20609     catch (...)
20610       {
20611         throw;
20612       }
20613     if (ex != NULL) SignDoc_throw (ex);
20614     return r;
20615   }
20616 
20640   ReturnCode getCertificateRevocationState (CertificateRevocationState &aOutput)
20641   {
20642     SIGNDOC_Exception *ex = NULL;
20643     int tempOutput = 0;
20644     ReturnCode r;
20645     try
20646       {
20647         r = (ReturnCode)SIGNDOC_VerificationResult_getCertificateRevocationState (&ex, p, &tempOutput);
20648         aOutput = (CertificateRevocationState )tempOutput;
20649       }
20650     catch (...)
20651       {
20652         throw;
20653       }
20654     if (ex != NULL) SignDoc_throw (ex);
20655     return r;
20656   }
20657 
20680   ReturnCode verifyCertificateSimplified (const SignDocVerificationParameters *aParameters)
20681   {
20682     SIGNDOC_Exception *ex = NULL;
20683     ReturnCode r;
20684     r = (ReturnCode)SIGNDOC_VerificationResult_verifyCertificateSimplified (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl ());
20685     if (ex != NULL) SignDoc_throw (ex);
20686     return r;
20687   }
20688 
20707   ReturnCode getCertificateChainLength (int &aOutput)
20708   {
20709     SIGNDOC_Exception *ex = NULL;
20710     ReturnCode r;
20711     r = (ReturnCode)SIGNDOC_VerificationResult_getCertificateChainLength (&ex, p, &aOutput);
20712     if (ex != NULL) SignDoc_throw (ex);
20713     return r;
20714   }
20715 
20763   ReturnCode getSignatureString (Encoding aEncoding, const std::string &aName,
20764                                  std::string &aOutput)
20765   {
20766     SIGNDOC_Exception *ex = NULL;
20767     char *tempOutput = NULL;
20768     ReturnCode r;
20769     try
20770       {
20771         r = (ReturnCode)SIGNDOC_VerificationResult_getSignatureString (&ex, p, aEncoding, aName.c_str (), &tempOutput);
20772         if (tempOutput != NULL)
20773           aOutput = tempOutput;
20774       }
20775     catch (...)
20776       {
20777         SIGNDOC_free (tempOutput);
20778         throw;
20779       }
20780     SIGNDOC_free (tempOutput);
20781     if (ex != NULL) SignDoc_throw (ex);
20782     return r;
20783   }
20784 
20811   ReturnCode getSignatureBlob (const std::string &aName,
20812                                std::vector<unsigned char> &aOutput)
20813   {
20814     SIGNDOC_Exception *ex = NULL;
20815     SIGNDOC_ByteArray *tempOutput = NULL;
20816     ReturnCode r;
20817     try
20818       {
20819         tempOutput = SIGNDOC_ByteArray_new (&ex);
20820         if (ex != NULL) SignDoc_throw (ex);
20821         r = (ReturnCode)SIGNDOC_VerificationResult_getSignatureBlob (&ex, p, aName.c_str (), tempOutput);
20822         assignArray (aOutput, tempOutput);
20823       }
20824     catch (...)
20825       {
20826         if (tempOutput != NULL)
20827           SIGNDOC_ByteArray_delete (tempOutput);
20828         throw;
20829       }
20830     if (tempOutput != NULL)
20831       SIGNDOC_ByteArray_delete (tempOutput);
20832     if (ex != NULL) SignDoc_throw (ex);
20833     return r;
20834   }
20835 
20879   ReturnCode getBiometricData (const unsigned char *aKeyPtr, size_t aKeySize,
20880                                const wchar_t *aKeyPath,
20881                                const char *aPassphrase,
20882                                std::vector<unsigned char> &aOutput)
20883   {
20884     SIGNDOC_Exception *ex = NULL;
20885     SIGNDOC_ByteArray *tempOutput = NULL;
20886     ReturnCode r;
20887     try
20888       {
20889         tempOutput = SIGNDOC_ByteArray_new (&ex);
20890         if (ex != NULL) SignDoc_throw (ex);
20891         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricDataW (&ex, p, aKeyPtr, aKeySize, aKeyPath, aPassphrase, tempOutput);
20892         assignArray (aOutput, tempOutput);
20893       }
20894     catch (...)
20895       {
20896         if (tempOutput != NULL)
20897           SIGNDOC_ByteArray_delete (tempOutput);
20898         throw;
20899       }
20900     if (tempOutput != NULL)
20901       SIGNDOC_ByteArray_delete (tempOutput);
20902     if (ex != NULL) SignDoc_throw (ex);
20903     return r;
20904   }
20905 
20951   ReturnCode getBiometricData (Encoding aEncoding,
20952                                const unsigned char *aKeyPtr, size_t aKeySize,
20953                                const char *aKeyPath, const char *aPassphrase,
20954                                std::vector<unsigned char> &aOutput)
20955   {
20956     SIGNDOC_Exception *ex = NULL;
20957     SIGNDOC_ByteArray *tempOutput = NULL;
20958     ReturnCode r;
20959     try
20960       {
20961         tempOutput = SIGNDOC_ByteArray_new (&ex);
20962         if (ex != NULL) SignDoc_throw (ex);
20963         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricData (&ex, p, aEncoding, aKeyPtr, aKeySize, aKeyPath, aPassphrase, tempOutput);
20964         assignArray (aOutput, tempOutput);
20965       }
20966     catch (...)
20967       {
20968         if (tempOutput != NULL)
20969           SIGNDOC_ByteArray_delete (tempOutput);
20970         throw;
20971       }
20972     if (tempOutput != NULL)
20973       SIGNDOC_ByteArray_delete (tempOutput);
20974     if (ex != NULL) SignDoc_throw (ex);
20975     return r;
20976   }
20977 
21041   ReturnCode getEncryptedBiometricData (std::vector<unsigned char> &aOutput)
21042   {
21043     SIGNDOC_Exception *ex = NULL;
21044     SIGNDOC_ByteArray *tempOutput = NULL;
21045     ReturnCode r;
21046     try
21047       {
21048         tempOutput = SIGNDOC_ByteArray_new (&ex);
21049         if (ex != NULL) SignDoc_throw (ex);
21050         r = (ReturnCode)SIGNDOC_VerificationResult_getEncryptedBiometricData (&ex, p, tempOutput);
21051         assignArray (aOutput, tempOutput);
21052       }
21053     catch (...)
21054       {
21055         if (tempOutput != NULL)
21056           SIGNDOC_ByteArray_delete (tempOutput);
21057         throw;
21058       }
21059     if (tempOutput != NULL)
21060       SIGNDOC_ByteArray_delete (tempOutput);
21061     if (ex != NULL) SignDoc_throw (ex);
21062     return r;
21063   }
21064 
21078   ReturnCode getBiometricEncryption (SignDocSignatureParameters::BiometricEncryption &aOutput)
21079   {
21080     SIGNDOC_Exception *ex = NULL;
21081     int tempOutput = 0;
21082     ReturnCode r;
21083     try
21084       {
21085         r = (ReturnCode)SIGNDOC_VerificationResult_getBiometricEncryption (&ex, p, &tempOutput);
21086         aOutput = (SignDocSignatureParameters::BiometricEncryption )tempOutput;
21087       }
21088     catch (...)
21089       {
21090         throw;
21091       }
21092     if (ex != NULL) SignDoc_throw (ex);
21093     return r;
21094   }
21095 
21112   ReturnCode checkBiometricHash (const unsigned char *aBioPtr, size_t aBioSize,
21113                                  bool &aOutput)
21114   {
21115     SIGNDOC_Exception *ex = NULL;
21116     SIGNDOC_Boolean tempOutput = 0;
21117     ReturnCode r;
21118     try
21119       {
21120         r = (ReturnCode)SIGNDOC_VerificationResult_checkBiometricHash (&ex, p, aBioPtr, aBioSize, &tempOutput);
21121         aOutput = (bool )tempOutput;
21122       }
21123     catch (...)
21124       {
21125         throw;
21126       }
21127     if (ex != NULL) SignDoc_throw (ex);
21128     return r;
21129   }
21130 
21138   ReturnCode getTimeStampState (TimeStampState &aOutput)
21139   {
21140     SIGNDOC_Exception *ex = NULL;
21141     int tempOutput = 0;
21142     ReturnCode r;
21143     try
21144       {
21145         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampState (&ex, p, &tempOutput);
21146         aOutput = (TimeStampState )tempOutput;
21147       }
21148     catch (...)
21149       {
21150         throw;
21151       }
21152     if (ex != NULL) SignDoc_throw (ex);
21153     return r;
21154   }
21155 
21178   ReturnCode getTimeStampDigestAlgorithm (std::string &aOutput)
21179   {
21180     SIGNDOC_Exception *ex = NULL;
21181     char *tempOutput = NULL;
21182     ReturnCode r;
21183     try
21184       {
21185         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampDigestAlgorithm (&ex, p, &tempOutput);
21186         if (tempOutput != NULL)
21187           aOutput = tempOutput;
21188       }
21189     catch (...)
21190       {
21191         SIGNDOC_free (tempOutput);
21192         throw;
21193       }
21194     SIGNDOC_free (tempOutput);
21195     if (ex != NULL) SignDoc_throw (ex);
21196     return r;
21197   }
21198 
21217   ReturnCode verifyTimeStampCertificateChain (const SignDocVerificationParameters *aParameters,
21218                                               CertificateChainState &aOutput)
21219   {
21220     SIGNDOC_Exception *ex = NULL;
21221     int tempOutput = 0;
21222     ReturnCode r;
21223     try
21224       {
21225         r = (ReturnCode)SIGNDOC_VerificationResult_verifyTimeStampCertificateChain (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl (), &tempOutput);
21226         aOutput = (CertificateChainState )tempOutput;
21227       }
21228     catch (...)
21229       {
21230         throw;
21231       }
21232     if (ex != NULL) SignDoc_throw (ex);
21233     return r;
21234   }
21235 
21257   ReturnCode getTimeStampCertificateRevocationState (CertificateRevocationState &aOutput)
21258   {
21259     SIGNDOC_Exception *ex = NULL;
21260     int tempOutput = 0;
21261     ReturnCode r;
21262     try
21263       {
21264         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampCertificateRevocationState (&ex, p, &tempOutput);
21265         aOutput = (CertificateRevocationState )tempOutput;
21266       }
21267     catch (...)
21268       {
21269         throw;
21270       }
21271     if (ex != NULL) SignDoc_throw (ex);
21272     return r;
21273   }
21274 
21303   ReturnCode verifyTimeStampCertificateSimplified (const SignDocVerificationParameters *aParameters)
21304   {
21305     SIGNDOC_Exception *ex = NULL;
21306     ReturnCode r;
21307     r = (ReturnCode)SIGNDOC_VerificationResult_verifyTimeStampCertificateSimplified (&ex, p, aParameters == NULL ? NULL : aParameters->getImpl ());
21308     if (ex != NULL) SignDoc_throw (ex);
21309     return r;
21310   }
21311 
21332   ReturnCode getTimeStamp (std::string &aOutput)
21333   {
21334     SIGNDOC_Exception *ex = NULL;
21335     char *tempOutput = NULL;
21336     ReturnCode r;
21337     try
21338       {
21339         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStamp (&ex, p, &tempOutput);
21340         if (tempOutput != NULL)
21341           aOutput = tempOutput;
21342       }
21343     catch (...)
21344       {
21345         SIGNDOC_free (tempOutput);
21346         throw;
21347       }
21348     SIGNDOC_free (tempOutput);
21349     if (ex != NULL) SignDoc_throw (ex);
21350     return r;
21351   }
21352 
21363   ReturnCode getTimeStampCertificates (std::vector<std::vector<unsigned char> > &aOutput)
21364   {
21365     SIGNDOC_Exception *ex = NULL;
21366     SIGNDOC_ByteArrayArray *tempOutput = NULL;
21367     ReturnCode r;
21368     try
21369       {
21370         tempOutput = SIGNDOC_ByteArrayArray_new (&ex);
21371         if (ex != NULL) SignDoc_throw (ex);
21372         r = (ReturnCode)SIGNDOC_VerificationResult_getTimeStampCertificates (&ex, p, tempOutput);
21373         assignArray (aOutput, tempOutput);
21374       }
21375     catch (...)
21376       {
21377         if (tempOutput != NULL)
21378           SIGNDOC_ByteArrayArray_delete (tempOutput);
21379         throw;
21380       }
21381     if (tempOutput != NULL)
21382       SIGNDOC_ByteArrayArray_delete (tempOutput);
21383     if (ex != NULL) SignDoc_throw (ex);
21384     return r;
21385   }
21386 
21400   const char *getErrorMessage (Encoding aEncoding) const
21401   {
21402     SIGNDOC_Exception *ex = NULL;
21403     const char *r;
21404     r = SIGNDOC_VerificationResult_getErrorMessage (&ex, p, aEncoding);
21405     if (ex != NULL) SignDoc_throw (ex);
21406     return r;
21407   }
21408 
21420   const wchar_t *getErrorMessageW () const
21421   {
21422     SIGNDOC_Exception *ex = NULL;
21423     const wchar_t *r;
21424     r = SIGNDOC_VerificationResult_getErrorMessageW (&ex, p);
21425     if (ex != NULL) SignDoc_throw (ex);
21426     return r;
21427   }
21432   SignDocVerificationResult (SIGNDOC_VerificationResult *aP) : p (aP) { }
21433 
21438   SIGNDOC_VerificationResult *getImpl () { return p; }
21439 
21444   const SIGNDOC_VerificationResult *getImpl () const { return p; }
21445 
21450   void setImpl (SIGNDOC_VerificationResult *aP) { SIGNDOC_VerificationResult_delete (p); p  = aP; }
21451 
21452 private:
21453   SIGNDOC_VerificationResult *p;
21454 };
21455 
21459 class SignDocPdfDocumentHandler : public SignDocDocumentHandler
21460 {
21461 public:
21462 
21468   static SignDocDocumentHandler *create ()
21469   {
21470     SIGNDOC_Exception *ex = NULL;
21471     SIGNDOC_DocumentHandler *r;
21472     r = SIGNDOC_PdfDocumentHandler_new (&ex);
21473     if (ex != NULL) SignDoc_throw (ex);
21474     if (r == NULL)
21475       return NULL;
21476     try
21477       {
21478         return new SignDocDocumentHandler (r);
21479       }
21480     catch (...)
21481       {
21482         SIGNDOC_DocumentHandler_delete (r);
21483         throw;
21484       }
21485   }
21486 
21487 private:
21492   SignDocPdfDocumentHandler ();
21493 
21498   SignDocPdfDocumentHandler (const SIGNDOC_PdfDocumentHandler &);
21499 
21504   SignDocPdfDocumentHandler& operator= (const SIGNDOC_PdfDocumentHandler &);
21505 };
21506 
21510 class SignDocTiffDocumentHandler : public SignDocDocumentHandler
21511 {
21512 public:
21513 
21519   static SignDocDocumentHandler *create ()
21520   {
21521     SIGNDOC_Exception *ex = NULL;
21522     SIGNDOC_DocumentHandler *r;
21523     r = SIGNDOC_TiffDocumentHandler_new (&ex);
21524     if (ex != NULL) SignDoc_throw (ex);
21525     if (r == NULL)
21526       return NULL;
21527     try
21528       {
21529         return new SignDocDocumentHandler (r);
21530       }
21531     catch (...)
21532       {
21533         SIGNDOC_DocumentHandler_delete (r);
21534         throw;
21535       }
21536   }
21537 
21538 private:
21543   SignDocTiffDocumentHandler ();
21544 
21549   SignDocTiffDocumentHandler (const SIGNDOC_TiffDocumentHandler &);
21550 
21555   SignDocTiffDocumentHandler& operator= (const SIGNDOC_TiffDocumentHandler &);
21556 };
21557 
21558 inline SignDocVerificationResult *
21559 makeSignDocVerificationResult (SIGNDOC_VerificationResult *aP)
21560 {
21561   if (aP == NULL)
21562     return NULL;
21563   return new SignDocVerificationResult (aP);
21564 }
21565 
21566 #ifdef _MSC_VER
21567 #pragma warning(pop)
21568 #endif
21569 
21570 }}}
21571 
21572 #endif