Element.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------------------
00002 // Copyright (c) 2001-2008 by PDFTron Systems Inc. All Rights Reserved.
00003 // Consult legal.txt regarding legal and license information.    
00004 //---------------------------------------------------------------------------------------
00005 
00006 #ifndef   H_CPPPDFElement
00007 #define   H_CPPPDFElement
00008 
00009 #include <SDF/Obj.h>
00010 #include <PDF/GState.h>
00011 #include <PDF/Rect.h>
00012 #include <PDF/CharData.h> 
00013 #include <PDF/Struct/SElement.h>
00014 #include <C/PDF/TRN_Element.h>
00015 
00016 namespace pdftron { 
00017         namespace PDF {
00018 
00019 
00032 class Element 
00033 {
00034 public:
00035         // Common Methods ---------------------------------------------------------------
00036 
00037         enum Type
00038         {
00039                 e_null,                  // undefined element type
00040                 e_path,                  // path object
00041                 e_text_begin,            // marks the beginning of a text container
00042                 e_text,                  // text object within a text container
00043                 e_text_new_line,         // indicates the start of the new text line
00044                 e_text_end,              // marks the end of text container
00045                 e_image,                 // image XObject
00046                 e_inline_image,          // inline image object
00047                 e_shading,               // shading object
00048                 e_form,                  // a form XObject 
00049                 e_group_begin,           // push graphics state operator (q)
00050                 e_group_end,             // pop graphics state operator (Q)
00051                 e_marked_content_begin,  // marks the beginning of marked content sequence (BMC, BDC)
00052                 e_marked_content_end,    // marks the end of marked content sequence (EMC)
00053                 e_marked_content_point   // designate a marked-content point (MP, DP) 
00054         };
00055 
00056         Element();
00057         Element(const Element& c);
00058         Element& operator=(const Element&c);
00059         operator bool () { return mp_elem!=0;}
00060 
00064         Type GetType();
00065 
00069         GState GetGState();
00070 
00075         Common::Matrix2D GetCTM();
00076 
00097         bool GetBBox(Rect& out_bbox);
00098         
00104         Struct::SElement GetParentStructElement();
00105 
00113         int GetStructMCID();
00114 
00125         bool IsOCVisible();
00126         
00127         // Path Element (e_path) Get Methods --------------------------------------------
00128 
00133         bool IsClippingPath();
00134 
00138         bool IsStroked();
00139 
00143         bool IsFilled();
00144         
00162          bool IsWindingFill();
00163 
00168          bool IsClipWindingFill();
00169 
00170         enum PathSegmentType
00171         {
00172                 // Start a new sub-path at the given (x,y) coordinate.
00173                 // Number of arguments: 2
00174                 e_moveto = 1,
00175 
00176                 // A line from the current point to the given (x,y) coordinate which becomes 
00177                 // the new current point.
00178                 // Number of arguments: 2
00179                 e_lineto,                
00180 
00181                 // A cubic Bézier curve from the current point to (x,y) using (x1,y1) as
00182                 // the control point at the beginning of the curve and (x2,y2) as the control
00183                 // point at the end of the curve.
00184                 // Number of arguments: 6
00185                 e_cubicto,
00186 
00187                 // A quadratic Bézier curve from the current point to (x,y) using (x1,y1) as
00188                 // the control point. Note that e_conicto does not appear in PDF content streams.
00189                 // This operator is only used to represent glyph outlines (e.g. PDF::Font::GetGlyphPath()
00190                 // may return a path containing e_conicto operator).
00191                 // Number of arguments: 4
00192                 e_conicto,              
00193 
00194                 // A rectangle at the given (x,y) coordinate and the given width and height (w, h).
00195                 // Number of arguments: 4
00196                 e_rect,
00197 
00198                 // Close the current subpath by drawing a straight line from the current point 
00199                 // to current subpath's initial point.
00200                 // Number of arguments: 0
00201                 e_closepath
00202         };      
00203 
00211          const char* GetPathTypes();
00212 
00216          int GetPathTypesCount();
00217 
00226          const double* GetPathPoints();
00227 
00231          int GetPointCount();
00232 
00233 
00234         // Path Element (e_path) Set Methods --------------------------------------------
00235 
00239          void SetPathClip(bool clip);
00240 
00244          void SetPathStroke(bool stroke);
00245 
00249          void SetPathFill(bool fill);
00250 
00256          void SetWindingFill(bool winding_rule);
00257 
00264          void SetClipWindingFill(bool winding_rule);
00265 
00266 
00275          void SetPathPoints(const double* in_points, int count);
00276 
00284          void SetPathTypes(const char* in_seg_types, int count);
00285 
00286 
00287         // XObject Element (e_image or e_form_begin) Methods ----------------------------
00288 
00292          SDF::Obj GetXObject();
00293 
00294 
00295         // Image (e_image and e_inline_image) Element Methods ---------------------------
00296 
00300          Filters::Filter GetImageData();
00301 
00305          int GetImageDataSize();
00306 
00318         #if defined(_WIN32) && !defined(WINCE)
00319          Gdiplus::Bitmap* GetBitmap();
00320         #endif
00321 
00330          SDF::Obj GetImageColorSpace();
00331 
00335          int GetImageWidth();
00336 
00340          int GetImageHeight();
00341 
00350          SDF::Obj GetDecodeArray();
00351 
00357          int GetBitsPerComponent();
00358 
00362          int GetComponentNum();
00363 
00364 
00368          bool IsImageMask();
00369 
00373          bool IsImageInterpolate(); 
00374 
00382          SDF::Obj GetMask(); 
00383 
00387          GState::RenderingIntent GetImageRenderingIntent();
00388 
00389         // Text Element (e_text) Get Methods --------------------------------------------
00390 
00408          const UString* GetTextString();
00409 
00424          const UChar* GetTextData();
00425         
00429          UInt GetTextDataSize();
00430 
00434          Common::Matrix2D GetTextMatrix();
00435 
00466          CharIterator GetCharIterator();
00467 
00482          double GetTextLength();
00483         
00493          double GetPosAdjustment();
00494 
00495         // Text New Line Element (e_text_new_line) Methods ------------------------------
00496 
00504          void GetNewTextLineOffset(double& out_x, double& out_y);
00505 
00506         // Text Element (e_text and e_text_new_line) Methods ----------------------------
00507 
00513           bool HasTextMatrix();
00514 
00515 
00516         // Text Element (e_text) Set Methods --------------------------------------------
00517 
00523          void SetTextData(const UChar* text_data, int text_data_size);
00524         
00530          void SetTextMatrix(Common::Matrix2D& mtx);
00531 
00551          void SetTextMatrix(double a, double b, double c, double d, double h, double v);
00552         
00556          void SetPosAdjustment(double adjust);
00557 
00567          void UpdateTextMetrics();
00568 
00569 
00570         // Text New Line Element (e_text_new_line) Methods ------------------------------
00571 
00576          void SetNewTextLineOffset(double dx, double dy);
00577 
00578 
00579         // Shading Element (e_shading) Methods ------------------------------------------
00580 
00584          SDF::Obj GetShading();
00585 
00586         // Marked Content Elements 
00587         // (e_marked_content_begin and e_marked_content_point) Methods ------------------
00588 
00597          SDF::Obj GetMCPropertyDict();
00598         
00603          SDF::Obj GetMCTag();
00604         
00605          ~Element() {}
00606 
00607 
00609          Element(TRN_Element impl);
00610         TRN_Element mp_elem;
00612 };
00613 
00614 
00615 #include <Impl/Element.inl>
00616 
00617         };      // namespace PDF
00618 };      // namespace pdftron
00619 
00620 #endif

© 2002-2008 PDFTron Systems Inc.