Also reflected on PdfCheckbox and PdfSignature
---
 src/doc/PdfAnnotation.cpp     | 24 +++++++++++++++++-------
 src/doc/PdfAnnotation.h       | 11 ++++++++++-
 src/doc/PdfField.cpp          | 18 ++++++++++++++----
 src/doc/PdfField.h            | 18 ++++++++++++++++--
 src/doc/PdfSignatureField.cpp |  7 ++++++-
 src/doc/PdfSignatureField.h   |  8 ++++++++
 6 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/src/doc/PdfAnnotation.cpp b/src/doc/PdfAnnotation.cpp
index f95e82c..765da2f 100644
--- a/src/doc/PdfAnnotation.cpp
+++ b/src/doc/PdfAnnotation.cpp
@@ -127,9 +127,14 @@ void PdfAnnotation::SetRect(const PdfRect & rrect)
     rrect.ToVariant(rect);
     this->GetObject()->GetDictionary().AddKey( PdfName::KeyRect, rect );
+}
+
+void SetAppearanceStreamForObject(PdfObject* pForObject, PdfXObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state)
+{
+    SetAppearanceStreamForObject( pForObject, pObject->GetObject(), 
eAppearance, state );
 }
-void SetAppearanceStreamForObject( PdfObject* pForObject, PdfXObject* pObject, EPdfAnnotationAppearance eAppearance, const PdfName & state )
+void SetAppearanceStreamForObject( PdfObject* pForObject, PdfObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state )
 {
     PdfDictionary dict;
     PdfDictionary internal;
@@ -183,7 +188,7 @@ void SetAppearanceStreamForObject( PdfObject* pForObject, 
PdfXObject* pObject, E
                 PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
             }
- objAP->GetDictionary().AddKey( name, pObject->GetObject()->Reference() );
+            objAP->GetDictionary().AddKey( name, pObject->Reference() );
         }
         else
         {
@@ -195,11 +200,11 @@ void SetAppearanceStreamForObject( PdfObject* pForObject, 
PdfXObject* pObject, E
if( objAP->GetDictionary().HasKey( name ) )
             {
-                objAP->GetDictionary().GetKey( name )->GetDictionary().AddKey( 
state, pObject->GetObject()->Reference() );
+                objAP->GetDictionary().GetKey( name )->GetDictionary().AddKey( 
state, pObject->Reference() );
             }
             else
             {
-                internal.AddKey( state, pObject->GetObject()->Reference() );
+                internal.AddKey( state, pObject->Reference() );
                 objAP->GetDictionary().AddKey( name, internal );
             }
         }
@@ -208,12 +213,12 @@ void SetAppearanceStreamForObject( PdfObject* pForObject, 
PdfXObject* pObject, E
     {
         if( !state.GetLength() )
         {
-            dict.AddKey( name, pObject->GetObject()->Reference() );
+            dict.AddKey( name, pObject->Reference() );
             pForObject->GetDictionary().AddKey( "AP", dict );
         }
         else
         {
-            internal.AddKey( state, pObject->GetObject()->Reference() );
+            internal.AddKey( state, pObject->Reference() );
             dict.AddKey( name, internal );
             pForObject->GetDictionary().AddKey( "AP", dict );
         }
@@ -227,8 +232,13 @@ void SetAppearanceStreamForObject( PdfObject* pForObject, 
PdfXObject* pObject, E
         }
     }
 }
+
+void PdfAnnotation::SetAppearanceStream(PdfXObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state)
+{
+    SetAppearanceStream( pObject->GetObject(), eAppearance, state );
+}
-void PdfAnnotation::SetAppearanceStream( PdfXObject* pObject, EPdfAnnotationAppearance eAppearance, const PdfName & state )
+void PdfAnnotation::SetAppearanceStream( PdfObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state )
 {
     SetAppearanceStreamForObject( this->GetObject(), pObject, eAppearance, 
state );
 }
diff --git a/src/doc/PdfAnnotation.h b/src/doc/PdfAnnotation.h
index b774af7..ccbd504 100644
--- a/src/doc/PdfAnnotation.h
+++ b/src/doc/PdfAnnotation.h
@@ -152,6 +152,14 @@ class PODOFO_DOC_API PdfAnnotation : public PdfElement {
      *  \param state the state for which set it the pObject; states depend on 
the annotation type
      */
     void SetAppearanceStream( PdfXObject* pObject, EPdfAnnotationAppearance eAppearance = 
ePdfAnnotationAppearance_Normal, const PdfName & state = "" );
+
+    /** Set an appearance stream for this object
+    *  to specify its visual appearance
+    *  \param pObject an Object
+    *  \param eApperance an apperance type to set
+    *  \param state the state for which set it the pObject; states depend on 
the annotation type
+    */
+    void SetAppearanceStream( PdfObject* pObject, EPdfAnnotationAppearance eAppearance = 
ePdfAnnotationAppearance_Normal, const PdfName & state = "" );
/**
      * \returns true if this annotation has an appearance stream
@@ -413,8 +421,9 @@ class PODOFO_DOC_API PdfAnnotation : public PdfElement {
     PdfPage*       m_pPage;
 };
-// helper function, to avoid code duplication
+// helper functions, to avoid code duplication
 void SetAppearanceStreamForObject( PdfObject* pForObject, PdfXObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state );
+void SetAppearanceStreamForObject( PdfObject* pForObject, PdfObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state );
// -----------------------------------------------------
 //
diff --git a/src/doc/PdfField.cpp b/src/doc/PdfField.cpp
index 334a245..d06e891 100644
--- a/src/doc/PdfField.cpp
+++ b/src/doc/PdfField.cpp
@@ -672,15 +672,25 @@ void PdfCheckBox::AddAppearanceStream( const PdfName & 
rName, const PdfReference
     m_pObject->GetDictionary().GetKey( PdfName("AP") )->
         GetDictionary().GetKey( PdfName("N") )->GetDictionary().AddKey( rName, 
rReference );
 }
+
+void PdfCheckBox::SetAppearanceChecked( const PdfXObject & rXObject )
+{
+    SetAppearanceChecked(*rXObject.GetObject());
+}
-void PdfCheckBox::SetAppearanceChecked( const PdfXObject & rXObject )
+void PdfCheckBox::SetAppearanceChecked( const PdfObject & rObject)
 {
-    this->AddAppearanceStream( PdfName("Yes"), 
rXObject.GetObject()->Reference() );
+    this->AddAppearanceStream( PdfName("Yes"), rObject.Reference() );
 }
+
+void PdfCheckBox::SetAppearanceUnchecked( const PdfXObject & rXObject )
+{
+    SetAppearanceUnchecked(*rXObject.GetObject());
+}
-void PdfCheckBox::SetAppearanceUnchecked( const PdfXObject & rXObject )
+void PdfCheckBox::SetAppearanceUnchecked( const PdfObject & rObject )
 {
-    this->AddAppearanceStream( PdfName("Off"), 
rXObject.GetObject()->Reference() );
+    this->AddAppearanceStream( PdfName("Off"), rObject.Reference() );
 }
void PdfCheckBox::SetChecked( bool bChecked )
diff --git a/src/doc/PdfField.h b/src/doc/PdfField.h
index a5669d0..0645b70 100644
--- a/src/doc/PdfField.h
+++ b/src/doc/PdfField.h
@@ -741,7 +741,7 @@ class PODOFO_DOC_API PdfCheckBox : public PdfButton {
      *  Raises an error if PdfField::GetType() != ePdfField_CheckBox
      */
     PdfCheckBox( const PdfField & rhs );
-
+
     /** Set the appearance stream which is displayed when the checkbox
      *  is checked.
      *
@@ -754,7 +754,21 @@ class PODOFO_DOC_API PdfCheckBox : public PdfButton {
      *
      *  \param rXObject an xobject which contains the drawing commands for an 
unchecked checkbox
      */
-    void SetAppearanceUnchecked( const PdfXObject & rXObject );
+    void SetAppearanceUnchecked( const PdfXObject & rXObject );
+
+    /** Set the appearance stream which is displayed when the checkbox
+     *  is checked.
+     *
+     *  \param rObject an object which contains the drawing commands for a 
checked checkbox
+     */
+    void SetAppearanceChecked( const PdfObject & rObject );
+
+    /** Set the appearance stream which is displayed when the checkbox
+     *  is unchecked.
+     *
+     *  \param rObject an object which contains the drawing commands for an 
unchecked checkbox
+     */
+    void SetAppearanceUnchecked( const PdfObject & rObject);
/** Sets the state of this checkbox
      *
diff --git a/src/doc/PdfSignatureField.cpp b/src/doc/PdfSignatureField.cpp
index 6f3a149..92a92d7 100644
--- a/src/doc/PdfSignatureField.cpp
+++ b/src/doc/PdfSignatureField.cpp
@@ -67,9 +67,14 @@ PdfSignatureField::PdfSignatureField( PdfAnnotation* pWidget 
)
     {
         m_pSignatureObj = this->GetFieldObject()->GetOwner()->GetObject( 
this->GetFieldObject()->GetDictionary().GetKey( "V" )->GetReference() );
     }
+}
+
+void PdfSignatureField::SetAppearanceStream( PdfXObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state )
+{
+    SetAppearanceStream(pObject->GetObject(), eAppearance, state);
 }
-void PdfSignatureField::SetAppearanceStream( PdfXObject* pObject, EPdfAnnotationAppearance eAppearance, const PdfName & state )
+void PdfSignatureField::SetAppearanceStream( PdfObject* pObject, 
EPdfAnnotationAppearance eAppearance, const PdfName & state )
 {
     if( !pObject )
     {
diff --git a/src/doc/PdfSignatureField.h b/src/doc/PdfSignatureField.h
index f24087e..31d6106 100644
--- a/src/doc/PdfSignatureField.h
+++ b/src/doc/PdfSignatureField.h
@@ -72,6 +72,14 @@ public:
      * \param pWidget the annotation to create from
      */
     PdfSignatureField( PdfAnnotation* pWidget );
+
+    /** Set an appearance stream for this signature field
+    *  to specify its visual appearance
+    *  \param pObject an XObject
+    *  \param eAppearance an appearance type to set
+    *  \param state the state for which set it the pObject; states depend on 
the annotation type
+    */
+    void SetAppearanceStream( PdfObject *pObject, EPdfAnnotationAppearance eAppearance = 
ePdfAnnotationAppearance_Normal, const PdfName & state = "" );
/** Set an appearance stream for this signature field
      *  to specify its visual appearance
--
2.16.1.windows.1



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to