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 
38 FSDK_DEFINE_ARRAY(LayerNodeArray, LayerNode)
39 
40 
43 class LayerZoomData FS_FINAL : public Object {
44  public:
47  : min_factor(0)
48  , max_factor(0) {}
49 
58  LayerZoomData(float min_factor, float max_factor) {
59  this->min_factor = min_factor;
60  this->max_factor = max_factor;
61  }
62 
69  min_factor = data.min_factor;
70  max_factor = data.max_factor;
71  }
72 
80  LayerZoomData &operator = (const LayerZoomData& data) {
81  min_factor = data.min_factor;
82  max_factor = data.max_factor;
83  return (*this);
84  }
85 
96  void Set(float min_factor, float max_factor) {
97  this->min_factor = min_factor;
98  this->max_factor = max_factor;
99  }
100 
105  float min_factor;
110  float max_factor;
111 };
112 
121 class LayerTree FS_FINAL : public Base {
122  public:
128  typedef enum _UsageState {
130  e_StateON = 0x0000,
132  e_StateOFF = 0x0001,
137  } UsageState;
138 
139 
149  explicit LayerTree(const PDFDoc& document);
155  LayerTree(const LayerTree& other);
163  LayerTree& operator = (const LayerTree& other);
164 
172  bool operator == (const LayerTree& other) const;
180  bool operator != (const LayerTree& other) const;
181 
189  bool IsEmpty() const;
191  ~LayerTree();
192 
204  bool SetBaseState(UsageState state);
205 
215 
224 
232  objects::PDFArray* GetOCGs() const;
233 #ifndef __EMSCRIPTEN_RENDER__
234  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
235  explicit LayerTree(FS_HANDLE handle = NULL);
236 #endif
237 };
238 
246 class LayerContext FS_FINAL : public Base {
247  public:
253  typedef enum _UsageType {
255  e_UsageView = 0x0000,
257  e_UsageDesign = 0x0001,
259  e_UsagePrint = 0x0002,
261  e_UsageExport = 0x0003,
263  e_UsageZoom = 0x0004
264  } UsageType;
265 
266 
274  explicit LayerContext(const PDFDoc& document, UsageType usage_type);
275 
281  LayerContext(const LayerContext& other);
289  LayerContext& operator = (const LayerContext& other);
290 
298  bool operator == (const LayerContext& other) const;
306  bool operator != (const LayerContext& other) const;
308  ~LayerContext();
316  bool IsEmpty() const;
317 
336  bool Reset();
344  bool CopyStates(const LayerContext& source_context);
353  bool MergeStates(const LayerContext& source_context);
362  bool IsVisible(const LayerNode& layer);
372  bool SetVisible(const LayerNode& layer, bool is_visible);
373 #ifndef __EMSCRIPTEN_RENDER__
374  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
375  explicit LayerContext(FS_HANDLE handle = NULL);
376 #endif
377 };
378 
403 class LayerNode FS_FINAL : public Base{
404  public:
410  LayerNode(const LayerNode& other);
418  LayerNode& operator = (const LayerNode& other);
419 
427  bool operator == (const LayerNode& other) const;
435  bool operator != (const LayerNode& other) const;
436 
444  bool IsEmpty() const;
446  ~LayerNode();
447 
453  int GetChildrenCount();
462  LayerNode GetChild(int index);
471  bool RemoveChild(int index);
486  bool MoveTo(LayerNode parent_layer_node, int index);
499  LayerNode AddChild(int index, const wchar_t* name, bool has_Layer);
505  WString GetName();
506 
513  bool IsLocked();
514 
521  bool HasLayer();
538  bool HasIntent(const char* intent);
551  bool IsInPage(const PDFPage& page);
605  bool SetName(const wchar_t* name);
617  bool SetDefaultVisible(bool is_visible);
676  bool SetPrintUsage(const LayerPrintData& data);
688  bool SetZoomUsage(const LayerZoomData& data);
689 
702 
715  bool AddGraphicsObject(const PDFPage& page, graphics::GraphicsObject* graphicsobject);
729  bool RemoveGraphicsObject(graphics::GraphicsObject* graphics_object);
744  bool RemoveUsage(LayerContext::UsageType usage_type);
745 
755 
756 #ifndef __EMSCRIPTEN_RENDER__
757  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
758  explicit LayerNode(FS_HANDLE handle = NULL);
759 #endif
760 };
761 
765 class LayerPrintData FS_FINAL : public Object {
766  public:
777  this->subtype = subtype;
778  this->print_state = print_state;
779  }
780 
783  :print_state(LayerTree::e_StateUndefined) {
784  }
785 
792  subtype = data.subtype;
793  print_state = data.print_state;
794  }
795 
804  subtype = data.subtype;
805  print_state = data.print_state;
806  return (*this);
807  }
820  this->subtype = subtype;
821  this->print_state = print_state;
822  }
823 
834 };
835 } // namespace pdf
836 } // namespace foxit
837 #endif // FS_PDFLAYER_H_
838 
Definition: fs_pdflayer.h:38
LayerNode GetRootNode()
Get the root layer node.
LayerTree::UsageState GetExportUsage()
Get the state for exporting usage.
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:216
Definition: fs_pdfobject.h:575
Use for a viewer.
Definition: fs_pdflayer.h:255
~LayerTree()
Destructor.
LayerPrintData()
Constructor.
Definition: fs_pdflayer.h:782
bool Reset()
Reset current layer context, back to the initialized state.
float max_factor
The magnification factor below which the group should be ON. A negative number means no magnification...
Definition: fs_pdflayer.h:110
LayerZoomData GetZoomUsage()
Get the data for zooming usage.
bool HasLayer()
Check if current layer node is associated with a layer.
bool operator==(const LayerTree &other) const
Equal operator.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:219
LayerNode & operator=(const LayerNode &other)
Assign operator.
Definition: fs_pdflayer.h:43
bool RemoveChild(int index)
Remove a child node by index.
LayerTree(const PDFDoc &document)
Constructor, from a PDF document.
bool operator==(const LayerContext &other) const
Equal operator.
Header file for common definitions and classes.
float min_factor
The minimum recommended magnification factor at which the group should be ON. A negative number means...
Definition: fs_pdflayer.h:105
Definition: fs_pdflayer.h:765
objects::PDFDictionary * GetDict() const
Get the dictionary of current object.
~LayerNode()
Destructor.
UsageType GetUsageType()
Get the layer usage type for rendering.
Definition: fx_basic.h:1288
bool SetExportUsage(LayerTree::UsageState state)
Set state for exporting usage.
Use for representing a document designer's structural organization of artwork.
Definition: fs_pdflayer.h:257
bool SetDefaultVisible(bool is_visible)
Set default visibility.
LayerZoomData(const LayerZoomData &data)
Constructor, with another layer zoom data object.
Definition: fs_pdflayer.h:68
bool IsEmpty() const
Check whether current object is empty or not.
LayerNode(const LayerNode &other)
Constructor, with another layer node object.
objects::PDFDictionary * GetDict() const
Get the PDF dictionary of current object.
bool RemoveGraphicsObject(graphics::GraphicsObject *graphics_object)
Remove a graphics object from current layer node.
LayerNode GetChild(int index)
Get a child node.
Definition: fs_pdflayer.h:121
bool operator==(const LayerNode &other) const
Equal operator.
bool SetBaseState(UsageState state)
Set the base state for all layers in the default configuration.
bool RemoveUsage(LayerContext::UsageType usage_type)
Remove a kind of usage property.
LayerContext & operator=(const LayerContext &other)
Assign operator.
bool operator !=(const LayerNode &other) const
Not equal operator.
LayerPrintData(const String &subtype, LayerTree::UsageState print_state)
Constructor, with parameters.
Definition: fs_pdflayer.h:776
String subtype
A string that specifies the kind of content controlled by a layer.
Definition: fs_pdflayer.h:825
bool CopyStates(const LayerContext &source_context)
Copy states from another layer context.
Definition: fs_pdflayer.h:246
bool AddGraphicsObject(const PDFPage &page, graphics::GraphicsObject *graphicsobject)
Add a graphics object to current layer node.
BYTE STRING CLASS.
Definition: fx_string.h:317
The state is ON.
Definition: fs_pdflayer.h:130
bool MoveTo(LayerNode parent_layer_node, int index)
Move current layer node to be one of the children of another layer node.
LayerZoomData()
Constructor.
Definition: fs_pdflayer.h:46
Use for zooming.
Definition: fs_pdflayer.h:263
bool HasIntent(const char *intent)
Check if current layer node has a specified intent.
Definition: fs_pdfgraphicsobject.h:241
bool SetZoomUsage(const LayerZoomData &data)
Set data for layer zooming usage.
Foxit namespace.
Definition: fs_compare.h:27
void Set(const String &subtype, LayerTree::UsageState print_state)
Set value.
Definition: fs_pdflayer.h:819
LayerPrintData(const LayerPrintData &data)
Constructor, with another layer print data object.
Definition: fs_pdflayer.h:791
bool operator !=(const LayerTree &other) const
Not equal operator.
bool IsInPage(const PDFPage &page)
Check if current layer node is in a specified PDF page.
objects::PDFArray * GetOCGs() const
Get the "OCGs" PDF array from current object.
bool MergeStates(const LayerContext &source_context)
Merge states from another layer context.
Use for printing.
Definition: fs_pdflayer.h:259
PDFDoc GetDocument()
Get the related PDF document.
LayerPrintData GetPrintUsage()
Get the data for printing usage.
Definition: fs_pdfobject.h:763
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:833
#define NULL
The null-pointer value.
Definition: fx_system.h:767
bool SetPrintUsage(const LayerPrintData &data)
Set data for layer printing usage.
LayerZoomData(float min_factor, float max_factor)
Constructor, with parameters.
Definition: fs_pdflayer.h:58
Definition: fs_pdfdoc.h:389
The state is undefined.
Definition: fs_pdflayer.h:136
graphics::GraphicsObjectArray GetGraphicsObjects(const PDFPage &page)
Get all graphics objects related to the layer which is associated with current layer node.
Definition: fs_pdfpage.h:342
The state is unchanged.
Definition: fs_pdflayer.h:134
The state is OFF.
Definition: fs_pdflayer.h:132
LayerNode AddChild(int index, const wchar_t *name, bool has_Layer)
Add a new layer node as a child for current layer node.
Header file for PDF graphics object related definitions and classes.
UsageType
Enumeration for PDF layer usage type.
Definition: fs_pdflayer.h:253
LayerPrintData & operator=(const LayerPrintData &data)
Assign operator.
Definition: fs_pdflayer.h:803
bool IsEmpty() const
Check whether current object is empty or not.
UsageState
Enumeration for PDF layer base state.
Definition: fs_pdflayer.h:128
int GetChildrenCount()
Get the count of children nodes.
Use for exporting.
Definition: fs_pdflayer.h:261
bool IsVisible(const LayerNode &layer)
Check if a specified layer node is visible in current layer context.
WIDE STRING CLASS.
Definition: fx_string.h:1452
bool operator !=(const LayerContext &other) const
Not equal operator.
void Set(float min_factor, float max_factor)
Set value.
Definition: fs_pdflayer.h:96
WString GetName()
Get the name of current layer node.
bool IsLocked()
Check if current layer node is locked.
Definition: fs_pdflayer.h:403
bool SetViewUsage(LayerTree::UsageState state)
Set state for viewing usage.
~LayerContext()
Destructor.
LayerContext(const PDFDoc &document, UsageType usage_type)
Constructor, based on a PDF document and specified layer usage type.
bool SetName(const wchar_t *name)
Set the name of current layer node.
LayerTree::UsageState GetViewUsage()
Get the state for viewing usage.
bool IsEmpty() const
Check whether current object is empty or not.
Definition: fs_basictypes.h:399
LayerTree & operator=(const LayerTree &other)
Assign operator.
bool SetVisible(const LayerNode &layer, bool is_visible)
Set the visibility of a specified layer node in current layer context.