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
00325 void Destroy();
00326
00327 BorderStyle& operator=(const BorderStyle&);
00328 friend inline bool operator==( const BorderStyle& a, const BorderStyle& b );
00329 friend inline bool operator!=( const BorderStyle& a, const BorderStyle& b ) { return !( a == b ); }
00330
00334 Style GetStyle() const;
00335
00339 void SetStyle(Style style);
00340
00344 double GetHR() const;
00345
00349 void SetHR(double hr);
00350
00354 double GetVR() const;
00355
00359 void SetVR(double vr);
00360
00364 double GetWidth() const;
00365
00369 void SetWidth(double width);
00370
00375 std::vector<double> GetDash() const;
00376
00381 void SetDash( const std::vector<double>& dash);
00382
00383 BorderStyle(TRN_AnnotBorderStyle impl);
00384 BorderStyle() : mp_bs(0) {}
00385 private:
00386 friend class PDF::Annot;
00387 TRN_AnnotBorderStyle mp_bs;
00388 };
00389
00395 BorderStyle GetBorderStyle() const;
00396
00407 void SetBorderStyle( const BorderStyle& bs, bool oldStyleOnly = false );
00408
00421 enum AnnotationState
00422 {
00423 e_normal,
00424 e_rollover,
00425 e_down
00426 };
00427
00445 SDF::Obj GetAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
00446
00462 void SetAppearance(SDF::Obj app_stream, AnnotationState annot_state = e_normal, const char* app_state = 0);
00463
00476 void RemoveAppearance(AnnotationState annot_state = e_normal, const char* app_state = 0);
00477
00490 void Flatten(class Page page);
00491
00499 const char* GetActiveAppearanceState() const;
00500
00509 void SetActiveAppearanceState(const char* astate);
00510
00511
00524 ColorPt GetColorAsRGB() const;
00525
00538 ColorPt GetColorAsCMYK() const;
00539
00550 ColorPt GetColorAsGray() const;
00551
00558 int GetColorCompNum() const;
00559
00560
00579 void SetColor(const ColorPt& c, int comp_num=3);
00580
00581
00592 int GetStructParent() const;
00593
00604 void SetStructParent(const int keyval);
00605
00606
00617 SDF::Obj GetOptionalContent() const;
00618
00629 void SetOptionalContent(SDF::Obj oc);
00630
00638 void SetContents(const UString& contents);
00639
00647 UString GetContents() const;
00648
00649
00656 void RefreshAppearance();
00657
00667 void Resize(const Rect& newrect);
00668
00670 #ifndef SWIGHIDDEN
00671 Annot(TRN_Annot annot);
00672 TRN_Annot mp_annot;
00673 #endif
00675
00676 };
00677
00678
00679 }
00680 }
00681
00682 #include <Impl/Page.inl>
00683 #endif