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 #ifndef __EMSCRIPTEN_RENDER__
746  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
747  explicit LayerNode(FS_HANDLE handle = NULL);
748 #endif
749 };
750 
754 class LayerPrintData FS_FINAL : public Object {
755  public:
766  this->subtype = subtype;
767  this->print_state = print_state;
768  }
769 
772  :print_state(LayerTree::e_StateUndefined) {
773  }
774 
781  subtype = data.subtype;
782  print_state = data.print_state;
783  }
784 
793  subtype = data.subtype;
794  print_state = data.print_state;
795  return (*this);
796  }
809  this->subtype = subtype;
810  this->print_state = print_state;
811  }
812 
823 };
824 } // namespace pdf
825 } // namespace foxit
826 #endif // FS_PDFLAYER_H_
827 
Definition: fs_pdfgraphicsobject.h:154
LayerNode GetRootNode()
Get the root layer node.
UsageState
Enumeration for PDF layer base state.
Definition: fs_pdflayer.h:128
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:808
Use for representing a document designer's structural organization of artwork.
Definition: fs_pdflayer.h:257
String subtype
A string that specifies the kind of content controlled by a layer.
Definition: fs_pdflayer.h:814
LayerTree::UsageState GetExportUsage()
Get the state for exporting usage.
Use for zooming.
Definition: fs_pdflayer.h:263
Use for a viewer.
Definition: fs_pdflayer.h:255
bool operator==(const LayerTree &other) const
Equal operator.
CFX_Object Object
Object type.
Definition: fs_basictypes.h:219
The state is undefined.
Definition: fs_pdflayer.h:136
LayerTree(const PDFDoc &document)
Constructor, from a PDF document.
bool operator!=(const LayerContext &other) const
Not equal operator.
~LayerTree()
Destructor.
The state is unchanged.
Definition: fs_pdflayer.h:134
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:780
graphics::GraphicsObjectArray GetGraphicsObjects(const PDFPage &page)
Get all graphics objects related to the layer which is associated with current layer node.
WIDE STRING CLASS.
Definition: fx_string.h:1459
objects::PDFArray * GetOCGs() const
Get the "OCGs" PDF array from current object.
Definition: fs_pdflayer.h:38
bool SetName(const wchar_t *name)
Set the name of current layer node.
Definition: fs_pdflayer.h:754
bool SetPrintUsage(const LayerPrintData &data)
Set data for layer printing usage.
Definition: fs_pdfdoc.h:347
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:121
LayerZoomData()
Constructor.
Definition: fs_pdflayer.h:46
bool operator!=(const LayerTree &other) const
Not equal operator.
Definition: fs_pdflayer.h:43
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:253
LayerNode & operator=(const LayerNode &other)
Assign operator.
LayerZoomData(float min_factor, float max_factor)
Constructor, with parameters.
Definition: fs_pdflayer.h:58
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:68
float max_factor
The magnification factor below which the group should be ON. A negative number means no magnification...
Definition: fs_pdflayer.h:110
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:105
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:1287
bool operator!=(const LayerNode &other) const
Not equal operator.
LayerPrintData(const String &subtype, LayerTree::UsageState print_state)
Constructor, with parameters.
Definition: fs_pdflayer.h:765
Definition: fs_pdfpage.h:313
LayerPrintData & operator=(const LayerPrintData &data)
Assign operator.
Definition: fs_pdflayer.h:792
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:216
Header file for common definitions and classes.
The state is OFF.
Definition: fs_pdflayer.h:132
Definition: fs_basictypes.h:375
Definition: fs_pdflayer.h:246
bool IsLocked()
Check if current layer node is locked.
LayerContext & operator=(const LayerContext &other)
Assign operator.
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:822
Definition: fs_pdflayer.h:403
Use for exporting.
Definition: fs_pdflayer.h:261
Definition: fs_pdfobject.h:763
bool IsEmpty() const
Check whether current object is empty or not.
LayerNode GetChild(int index)
Get a child node.
Foxit namespace.
Definition: fs_compare.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:130
~LayerNode()
Destructor.
BYTE STRING CLASS.
Definition: fx_string.h:317
void Set(float min_factor, float max_factor)
Set value.
Definition: fs_pdflayer.h:96
Use for printing.
Definition: fs_pdflayer.h:259
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:771
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:575
bool HasIntent(const char *intent)
Check if current layer node has a specified intent.
LayerPrintData()
Constructor.
Definition: fs_pdflayer.h:771
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.