Foxit PDF SDK
fs_pdflayer.h
Go to the documentation of this file.
1 
15 #ifndef FS_PDFLAYER_H_
16 #define FS_PDFLAYER_H_
17 
18 #include "common/fs_common.h"
20 
26 namespace foxit {
30 namespace pdf {
31 // forward declaration
32 class PDFDoc;
33 class PDFPage;
34 class LayerPrintData;
35 class LayerNode;
36 namespace annots {
37 class AnnotArray;
38 }
39 
41 FSDK_DEFINE_ARRAY(LayerNodeArray, LayerNode)
42 
43 
46 class LayerZoomData FS_FINAL : public Object {
47  public:
50  : min_factor(0)
51  , max_factor(0) {}
52 
61  LayerZoomData(float min_factor, float max_factor) {
62  this->min_factor = min_factor;
63  this->max_factor = max_factor;
64  }
65 
72  min_factor = data.min_factor;
73  max_factor = data.max_factor;
74  }
75 
83  LayerZoomData &operator = (const LayerZoomData& data) {
84  min_factor = data.min_factor;
85  max_factor = data.max_factor;
86  return (*this);
87  }
88 
99  void Set(float min_factor, float max_factor) {
100  this->min_factor = min_factor;
101  this->max_factor = max_factor;
102  }
103 
108  float min_factor;
113  float max_factor;
114 };
115 
124 class LayerTree FS_FINAL : public Base {
125  public:
131  typedef enum _UsageState {
133  e_StateON = 0x0000,
135  e_StateOFF = 0x0001,
140  } UsageState;
141 
142 
152  explicit LayerTree(const PDFDoc& document);
158  LayerTree(const LayerTree& other);
166  LayerTree& operator = (const LayerTree& other);
167 
175  bool operator == (const LayerTree& other) const;
183  bool operator != (const LayerTree& other) const;
184 
192  bool IsEmpty() const;
193 
195  ~LayerTree();
196 
208  bool SetBaseState(UsageState state);
209 
219 
228 
237  objects::PDFArray* GetOCGs() const;
238 
247  LayerNodeArray GetOCGsByPageIndex(int page_index);
248 
249 #ifndef __EMSCRIPTEN_RENDER__
250  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
251  explicit LayerTree(FS_HANDLE handle = NULL);
252 #endif
253 };
254 
258 class LayerPrintData FS_FINAL : public Object{
259  public:
270  this->subtype = subtype;
271  this->print_state = print_state;
272  }
273 
276  :print_state(LayerTree::e_StateUndefined) {
277  }
278 
285  subtype = data.subtype;
286  print_state = data.print_state;
287  }
288 
297  subtype = data.subtype;
298  print_state = data.print_state;
299  return (*this);
300  }
301 
314  this->subtype = subtype;
315  this->print_state = print_state;
316  }
317 
320 
329 };
330 
338 class LayerContext FS_FINAL : public Base {
339  public:
345  typedef enum _UsageType {
347  e_UsageView = 0x0000,
349  e_UsageDesign = 0x0001,
351  e_UsagePrint = 0x0002,
353  e_UsageExport = 0x0003,
355  e_UsageZoom = 0x0004
356  } UsageType;
357 
358 
366  explicit LayerContext(const PDFDoc& document, UsageType usage_type);
367 
373  LayerContext(const LayerContext& other);
381  LayerContext& operator = (const LayerContext& other);
382 
390  bool operator == (const LayerContext& other) const;
398  bool operator != (const LayerContext& other) const;
400  ~LayerContext();
408  bool IsEmpty() const;
409 
428  bool Reset();
436  bool CopyStates(const LayerContext& source_context);
445  bool MergeStates(const LayerContext& source_context);
454  bool IsVisible(const LayerNode& layer);
464  bool SetVisible(const LayerNode& layer, bool is_visible);
465 #ifndef __EMSCRIPTEN_RENDER__
466  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
467  explicit LayerContext(FS_HANDLE handle = NULL);
468 #endif
469 };
470 
495 class LayerNode FS_FINAL : public Base{
496  public:
502  LayerNode(const LayerNode& other);
510  LayerNode& operator = (const LayerNode& other);
511 
519  bool operator == (const LayerNode& other) const;
527  bool operator != (const LayerNode& other) const;
528 
536  bool IsEmpty() const;
537 
539  ~LayerNode();
540 
546  int GetChildrenCount();
555  LayerNode GetChild(int index);
564  bool RemoveChild(int index);
565 
580  bool MoveTo(LayerNode parent_layer_node, int index);
581 
594  LayerNode AddChild(int index, const wchar_t* name, bool has_Layer);
595 
601  WString GetName();
602 
609  bool IsLocked();
610 
617  bool HasLayer();
618 
635  bool HasIntent(const char* intent);
636 
649  bool IsInPage(const PDFPage& page);
650 
662 
674 
685 
696 
708  bool SetName(const wchar_t* name);
709 
721  bool SetDefaultVisible(bool is_visible);
722 
743 
763 
783  bool SetPrintUsage(const LayerPrintData& data);
784 
796  bool SetZoomUsage(const LayerZoomData& data);
797 
810 
823  bool AddGraphicsObject(const PDFPage& page, graphics::GraphicsObject* graphicsobject);
824 
838  bool RemoveGraphicsObject(graphics::GraphicsObject* graphics_object);
839 
854  bool RemoveUsage(LayerContext::UsageType usage_type);
855 
865 
875 
876 #ifndef __EMSCRIPTEN_RENDER__
877  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
878  explicit LayerNode(FS_HANDLE handle = NULL);
879 #endif
880 };
881 } // namespace pdf
882 } // namespace foxit
883 #endif // FS_PDFLAYER_H_
884 
Definition: fs_pdfgraphicsobject.h:241
LayerNode GetRootNode()
Get the root layer node.
UsageState
Enumeration for PDF layer base state.
Definition: fs_pdflayer.h:131
bool Reset()
Reset current layer context, back to the initialized state.
void Set(const String &subtype, LayerTree::UsageState print_state)
Set value.
Definition: fs_pdflayer.h:313
Use for representing a document designer's structural organization of artwork.
Definition: fs_pdflayer.h:349
String subtype
A string that specifies the kind of content controlled by a layer.
Definition: fs_pdflayer.h:319
LayerTree::UsageState GetExportUsage()
Get the state for exporting usage.
Use for zooming.
Definition: fs_pdflayer.h:355
Use for a viewer.
Definition: fs_pdflayer.h:347
bool operator==(const LayerTree &other) const
Equal operator.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:221
The state is undefined.
Definition: fs_pdflayer.h:139
Definition: fs_annot.h:1657
LayerTree(const PDFDoc &document)
Constructor, from a PDF document.
~LayerTree()
Destructor.
The state is unchanged.
Definition: fs_pdflayer.h:137
bool SetZoomUsage(const LayerZoomData &data)
Set data for layer zooming usage.
bool CopyStates(const LayerContext &source_context)
Copy states from another layer context.
LayerNode AddChild(int index, const wchar_t *name, bool has_Layer)
Add a new layer node as a child for current layer node.
bool SetExportUsage(LayerTree::UsageState state)
Set state for exporting usage.
LayerNode(const LayerNode &other)
Constructor, with another layer node object.
LayerPrintData(const LayerPrintData &data)
Constructor, with another layer print data object.
Definition: fs_pdflayer.h:284
graphics::GraphicsObjectArray GetGraphicsObjects(const PDFPage &page)
Get all graphics objects related to the layer which is associated with current layer node.
bool operator !=(const LayerTree &other) const
Not equal operator.
WIDE STRING CLASS.
Definition: fx_string.h:1461
objects::PDFArray * GetOCGs() const
Get the "OCGs" PDF array from current object.
Definition: fs_pdflayer.h:41
bool SetName(const wchar_t *name)
Set the name of current layer node.
Definition: fs_pdflayer.h:258
bool SetPrintUsage(const LayerPrintData &data)
Set data for layer printing usage.
LayerNodeArray GetOCGsByPageIndex(int page_index)
Get an array of OCG objects found on a specified page.
Definition: fs_pdfdoc.h:772
objects::PDFDictionary * GetDict() const
Get the dictionary of current object.
~LayerContext()
Destructor.
bool SetBaseState(UsageState state)
Set the base state for all layers in the default configuration.
Definition: fs_pdflayer.h:124
LayerZoomData()
Constructor.
Definition: fs_pdflayer.h:49
Definition: fs_pdflayer.h:46
LayerContext(const PDFDoc &document, UsageType usage_type)
Constructor, based on a PDF document and specified layer usage type.
bool operator==(const LayerNode &other) const
Equal operator.
PDFDoc GetDocument()
Get the related PDF document.
bool RemoveUsage(LayerContext::UsageType usage_type)
Remove a kind of usage property.
UsageType
Enumeration for PDF layer usage type.
Definition: fs_pdflayer.h:345
LayerNode & operator=(const LayerNode &other)
Assign operator.
LayerZoomData(float min_factor, float max_factor)
Constructor, with parameters.
Definition: fs_pdflayer.h:61
int GetChildrenCount()
Get the count of children nodes.
bool AddGraphicsObject(const PDFPage &page, graphics::GraphicsObject *graphicsobject)
Add a graphics object to current layer node.
bool SetVisible(const LayerNode &layer, bool is_visible)
Set the visibility of a specified layer node in current layer context.
bool RemoveGraphicsObject(graphics::GraphicsObject *graphics_object)
Remove a graphics object from current layer node.
bool MoveTo(LayerNode parent_layer_node, int index)
Move current layer node to be one of the children of another layer node.
LayerZoomData(const LayerZoomData &data)
Constructor, with another layer zoom data object.
Definition: fs_pdflayer.h:71
float max_factor
The magnification factor below which the group should be ON. A negative number means no magnification...
Definition: fs_pdflayer.h:113
bool IsVisible(const LayerNode &layer)
Check if a specified layer node is visible in current layer context.
float min_factor
The minimum recommended magnification factor at which the group should be ON. A negative number means...
Definition: fs_pdflayer.h:108
UsageType GetUsageType()
Get the layer usage type for rendering.
LayerPrintData GetPrintUsage()
Get the data for printing usage.
LayerZoomData GetZoomUsage()
Get the data for zooming usage.
Definition: fx_basic.h:1297
LayerPrintData(const String &subtype, LayerTree::UsageState print_state)
Constructor, with parameters.
Definition: fs_pdflayer.h:269
Definition: fs_pdfpage.h:412
LayerPrintData & operator=(const LayerPrintData &data)
Assign operator.
Definition: fs_pdflayer.h:296
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:214
Header file for common definitions and classes.
The state is OFF.
Definition: fs_pdflayer.h:135
Definition: fs_basictypes.h:449
Definition: fs_pdflayer.h:338
bool IsLocked()
Check if current layer node is locked.
LayerContext & operator=(const LayerContext &other)
Assign operator.
foxit::pdf::annots::AnnotArray GetAnnots()
Get an array of annotations which are related to current layer node.
LayerTree::UsageState print_state
Layer usage state, indicating that the group should be set to that state when the document is printed...
Definition: fs_pdflayer.h:328
bool operator !=(const LayerNode &other) const
Not equal operator.
Definition: fs_pdflayer.h:495
Use for exporting.
Definition: fs_pdflayer.h:353
Definition: fs_pdfobject.h:850
bool IsEmpty() const
Check whether current object is empty or not.
objects::PDFDictionary * GetDict() const
Get the PDF dictionary of current object.
LayerNode GetChild(int index)
Get a child node.
Foxit namespace.
Definition: fs_pdf3d.h:27
bool IsEmpty() const
Check whether current object is empty or not.
bool HasLayer()
Check if current layer node is associated with a layer.
The state is ON.
Definition: fs_pdflayer.h:133
~LayerNode()
Destructor.
BYTE STRING CLASS.
Definition: fx_string.h:317
void Set(float min_factor, float max_factor)
Set value.
Definition: fs_pdflayer.h:99
Use for printing.
Definition: fs_pdflayer.h:351
bool IsInPage(const PDFPage &page)
Check if current layer node is in a specified PDF page.
bool SetDefaultVisible(bool is_visible)
Set default visibility.
#define NULL
The null-pointer value.
Definition: fx_system.h:792
Header file for PDF graphics object related definitions and classes.
bool operator==(const LayerContext &other) const
Equal operator.
LayerTree & operator=(const LayerTree &other)
Assign operator.
bool MergeStates(const LayerContext &source_context)
Merge states from another layer context.
Definition: fs_pdfobject.h:640
bool operator !=(const LayerContext &other) const
Not equal operator.
bool HasIntent(const char *intent)
Check if current layer node has a specified intent.
LayerPrintData()
Constructor.
Definition: fs_pdflayer.h:275
WString GetName()
Get the name of current layer node.
bool SetViewUsage(LayerTree::UsageState state)
Set state for viewing usage.
bool IsEmpty() const
Check whether current object is empty or not.
bool RemoveChild(int index)
Remove a child node by index.
LayerTree::UsageState GetViewUsage()
Get the state for viewing usage.