00001
00002
00003
00004
00005
00006 #ifndef PDFTRON_H_CPPPDFAnnot
00007 #define PDFTRON_H_CPPPDFAnnot
00008
00009 #include <SDF/Obj.h>
00010 #include <PDF/Date.h>
00011 #include <SDF/SDFDoc.h>
00012 #include <PDF/Rect.h>
00013 #include <PDF/ColorSpace.h>
00014 #include <PDF/FileSpec.h>
00015 #include <C/PDF/TRN_Annot.h>
00016 #include <vector>
00017
00018 namespace pdftron {
00019 namespace PDF {
00020
00032 class Annot
00033 {
00034 public:
00035
00040 enum Type
00041 {
00042 e_Text,
00043 e_Link,
00044 e_FreeText,
00045 e_Line,
00046 e_Square,
00047 e_Circle,
00048 e_Polygon,
00049 e_Polyline,
00050 e_Highlight,
00051 e_Underline,
00052 e_Squiggly,
00053 e_StrikeOut,
00054 e_Stamp,
00055 e_Caret,
00056 e_Ink,
00057 e_Popup,
00058 e_FileAttachment,
00059 e_Sound,
00060 e_Movie,
00061 e_Widget,
00062 e_Screen,
00063 e_PrinterMark,
00064 e_TrapNet,
00065 e_Watermark,
00066 e_3D,
00067 e_Redact,
00068 e_Projection,
00069 e_RichMedia,
00070 e_Unknown
00071 };
00072
00089 static Annot Create(SDF::SDFDoc& doc, Type type, const Rect& pos);
00090
00096 Annot (SDF::Obj d = 0);
00097
00101 Annot (const Annot& d);
00102
00106 Annot& operator=(const Annot& d);
00107
00112 bool operator==(const Annot& d);
00113
00119 bool IsValid() const;
00120
00124 SDF::Obj GetSDFObj () const;
00125
00130 Type GetType() const;
00131
00140 Rect GetRect() const;
00141
00147 bool IsMarkup() const;
00148
00158 void SetRect(const Rect& p);
00159
00170 Page GetPage() const;
00171
00182 void SetPage(const Page& page);
00183
00189 SDF::Obj GetUniqueID() const;
00190
00197 void SetUniqueID(const char* id, int id_buf_sz = 0);
00198
00204 Date GetDate() const;
00205
00210 void SetDate(const Date& date);
00211
00257 enum Flag
00258 {
00259 e_invisible,
00260 e_hidden,
00261 e_print,
00262 e_no_zoom,
00263 e_no_rotate,
00264 e_no_view,
00265 e_read_only,
00266 e_locked,
00267 e_toggle_no_view,
00268 e_locked_contents
00269 };
00270
00271
00276 bool GetFlag(Flag flag) const;
00277
00284 void SetFlag(Flag flag, bool value);
00285
00290 class BorderStyle
00291 {
00292 public:
00296 enum Style {
00297 e_solid,
00298 e_dashed,
00299 e_beveled,
00300 e_inset,
00301 e_underline
00302 };
00303
00317 BorderStyle(Style s, double b_width, double b_hr =0, double b_vr =0);
00318 BorderStyle(Style s, double b_width, double b_hr, double b_vr, const std::vector<double>& b_dash);
00319 BorderStyle(const BorderStyle&);
00320 ~BorderStyle();
00321
00322 BorderStyle& operator=(const BorderStyle&);
00323 friend inline bool operator==( const BorderStyle& a, const BorderStyle& b );
00324 friend inline bool operator!=( const BorderStyle& a, const BorderStyle& b ) { return !( a == b ); }
00325
00329 Style GetStyle() const;
00330
00334 void SetStyle(Style style);
00335
00339 double GetHR() const;
00340
00344 void SetHR(double hr);
00345
00349 double GetVR() const;
00350
00354 void SetVR(double vr);
00355
00359 double GetWidth() const;
00360
00364 void SetWidth(double width);
00365
00370 std::vector<double> GetDash() const;
00371
00376 void SetDash( const std::vector<double>& dash);
00377
00378 BorderStyle(TRN_AnnotBorderStyle impl);
00379 private:
00380 friend class PDF::Annot;
00381 TRN_AnnotBorderStyle mp_bs;
00382 };
00383
00389 BorderStyle GetBorderStyle() const;
00390
00401 void SetBorderStyle( const BorderStyle& bs, bool oldStyleOnly = false );
00402
00415 enum AnnotationState
00416 {
00417 e_normal,
00418 e_rollover,
00419 e_down
00420 };
00421
00439 SDF::Obj GetAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
00440
00456 void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state = e_normal, const char* app_state = 0);
00457
00470 void RemoveAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
00471
00484 void Flatten(class Page page);
00485
00493 const char* GetActiveAppearanceState() const;
00494
00503 void SetActiveAppearanceState(const char* astate);
00504
00505
00518 ColorPt GetColorAsRGB() const;
00519
00532 ColorPt GetColorAsCMYK() const;
00533
00544 ColorPt GetColorAsGray() const;
00545
00552 int GetColorCompNum() const;
00553
00554
00573 void SetColor(const ColorPt& c, int comp_num=3);
00574
00575
00586 int GetStructParent() const;
00587
00598 void SetStructParent(const int keyval);
00599
00600
00611 SDF::Obj GetOptionalContent() const;
00612
00623 void SetOptionalContent(SDF::Obj oc);
00624
00632 void SetContents(const UString& contents);
00633
00641 UString GetContents() const;
00642
00643
00650 void RefreshAppearance();
00651
00661 void Resize(const Rect& newrect);
00662
00663
00665 Annot(TRN_Annot annot);
00666 TRN_Annot mp_annot;
00668
00669 };
00670
00671
00672 }
00673 }
00674
00675 #include <Impl/Page.inl>
00676 #endif