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 
233  objects::PDFArray* GetOCGs() const;
234 #ifndef __EMSCRIPTEN_RENDER__
235  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
236  explicit LayerTree(FS_HANDLE handle = NULL);
237 #endif
238 };
239 
243 class LayerPrintData FS_FINAL : public Object{
244  public:
255  this->subtype = subtype;
256  this->print_state = print_state;
257  }
258 
261  :print_state(LayerTree::e_StateUndefined) {
262  }
263 
270  subtype = data.subtype;
271  print_state = data.print_state;
272  }
273 
282  subtype = data.subtype;
283  print_state = data.print_state;
284  return (*this);
285  }
286 
299  this->subtype = subtype;
300  this->print_state = print_state;
301  }
302 
305 
314 };
315 
323 class LayerContext FS_FINAL : public Base {
324  public:
330  typedef enum _UsageType {
332  e_UsageView = 0x0000,
334  e_UsageDesign = 0x0001,
336  e_UsagePrint = 0x0002,
338  e_UsageExport = 0x0003,
340  e_UsageZoom = 0x0004
341  } UsageType;
342 
343 
351  explicit LayerContext(const PDFDoc& document, UsageType usage_type);
352 
358  LayerContext(const LayerContext& other);
366  LayerContext& operator = (const LayerContext& other);
367 
375  bool operator == (const LayerContext& other) const;
383  bool operator != (const LayerContext& other) const;
385  ~LayerContext();
393  bool IsEmpty() const;
394 
413  bool Reset();
421  bool CopyStates(const LayerContext& source_context);
430  bool MergeStates(const LayerContext& source_context);
439  bool IsVisible(const LayerNode& layer);
449  bool SetVisible(const LayerNode& layer, bool is_visible);
450 #ifndef __EMSCRIPTEN_RENDER__
451  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
452  explicit LayerContext(FS_HANDLE handle = NULL);
453 #endif
454 };
455 
480 class LayerNode FS_FINAL : public Base{
481  public:
487  LayerNode(const LayerNode& other);
495  LayerNode& operator = (const LayerNode& other);
496 
504  bool operator == (const LayerNode& other) const;
512  bool operator != (const LayerNode& other) const;
513 
521  bool IsEmpty() const;
522 
524  ~LayerNode();
525 
531  int GetChildrenCount();
540  LayerNode GetChild(int index);
549  bool RemoveChild(int index);
550 
565  bool MoveTo(LayerNode parent_layer_node, int index);
566 
579  LayerNode AddChild(int index, const wchar_t* name, bool has_Layer);
580 
586  WString GetName();
587 
594  bool IsLocked();
595 
602  bool HasLayer();
603 
620  bool HasIntent(const char* intent);
621 
634  bool IsInPage(const PDFPage& page);
635 
647 
659 
670 
681 
693  bool SetName(const wchar_t* name);
694 
706  bool SetDefaultVisible(bool is_visible);
707 
728 
748 
768  bool SetPrintUsage(const LayerPrintData& data);
769 
781  bool SetZoomUsage(const LayerZoomData& data);
782 
795 
808  bool AddGraphicsObject(const PDFPage& page, graphics::GraphicsObject* graphicsobject);
809 
823  bool RemoveGraphicsObject(graphics::GraphicsObject* graphics_object);
824 
839  bool RemoveUsage(LayerContext::UsageType usage_type);
840 
850 
851 #ifndef __EMSCRIPTEN_RENDER__
852  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
853  explicit LayerNode(FS_HANDLE handle = NULL);
854 #endif
855 };
856 } // namespace pdf
857 } // namespace foxit
858 #endif // FS_PDFLAYER_H_
859 
foxit::pdf::LayerNodeArray
Definition: fs_pdflayer.h:38
foxit::pdf::LayerTree::GetRootNode
LayerNode GetRootNode()
Get the root layer node.
foxit::pdf::LayerNode::GetExportUsage
LayerTree::UsageState GetExportUsage()
Get the state for exporting usage.
foxit::FS_HANDLE
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:214
foxit::pdf::objects::PDFArray
Definition: fs_pdfobject.h:614
foxit::pdf::LayerContext::e_UsageView
Use for a viewer.
Definition: fs_pdflayer.h:332
foxit::pdf::LayerTree::~LayerTree
~LayerTree()
Destructor.
foxit::pdf::LayerPrintData::LayerPrintData
LayerPrintData()
Constructor.
Definition: fs_pdflayer.h:260
foxit::pdf::LayerContext::Reset
bool Reset()
Reset current layer context, back to the initialized state.
foxit::pdf::LayerZoomData::max_factor
float max_factor
The magnification factor below which the group should be ON. A negative number means no magnification...
Definition: fs_pdflayer.h:110
foxit::pdf::LayerNode::GetZoomUsage
LayerZoomData GetZoomUsage()
Get the data for zooming usage.
foxit::pdf::LayerNode::HasLayer
bool HasLayer()
Check if current layer node is associated with a layer.
foxit::pdf::LayerTree::operator==
bool operator==(const LayerTree &other) const
Equal operator.
foxit::Object
CFX_Object Object
Object type.
Definition: fs_basictypes.h:221
foxit::pdf::LayerNode::operator=
LayerNode & operator=(const LayerNode &other)
Assign operator.
foxit::pdf::LayerZoomData
Definition: fs_pdflayer.h:43
foxit::pdf::LayerNode::RemoveChild
bool RemoveChild(int index)
Remove a child node by index.
foxit::pdf::LayerTree::LayerTree
LayerTree(const PDFDoc &document)
Constructor, from a PDF document.
foxit::pdf::LayerContext::operator==
bool operator==(const LayerContext &other) const
Equal operator.
fs_common.h
Header file for common definitions and classes.
foxit::pdf::LayerZoomData::min_factor
float min_factor
The minimum recommended magnification factor at which the group should be ON. A negative number means...
Definition: fs_pdflayer.h:105
foxit::pdf::LayerPrintData
Definition: fs_pdflayer.h:243
foxit::pdf::LayerNode::operator!=
bool operator!=(const LayerNode &other) const
Not equal operator.
foxit::pdf::LayerTree::GetDict
objects::PDFDictionary * GetDict() const
Get the dictionary of current object.
foxit::pdf::LayerNode::~LayerNode
~LayerNode()
Destructor.
foxit::pdf::LayerContext::GetUsageType
UsageType GetUsageType()
Get the layer usage type for rendering.
CFX_ArrayTemplate
Definition: fx_basic.h:1297
foxit::pdf::LayerNode::SetExportUsage
bool SetExportUsage(LayerTree::UsageState state)
Set state for exporting usage.
foxit::pdf::LayerContext::e_UsageDesign
Use for representing a document designer's structural organization of artwork.
Definition: fs_pdflayer.h:334
foxit::pdf::LayerNode::SetDefaultVisible
bool SetDefaultVisible(bool is_visible)
Set default visibility.
foxit::pdf::LayerZoomData::LayerZoomData
LayerZoomData(const LayerZoomData &data)
Constructor, with another layer zoom data object.
Definition: fs_pdflayer.h:68
foxit::pdf::LayerContext::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::pdf::LayerNode::LayerNode
LayerNode(const LayerNode &other)
Constructor, with another layer node object.
foxit::pdf::LayerNode::GetDict
objects::PDFDictionary * GetDict() const
Get the PDF dictionary of current object.
foxit::pdf::LayerNode::RemoveGraphicsObject
bool RemoveGraphicsObject(graphics::GraphicsObject *graphics_object)
Remove a graphics object from current layer node.
foxit::pdf::LayerNode::GetChild
LayerNode GetChild(int index)
Get a child node.
foxit::pdf::LayerTree
Definition: fs_pdflayer.h:121
foxit::pdf::LayerNode::operator==
bool operator==(const LayerNode &other) const
Equal operator.
foxit::pdf::LayerTree::SetBaseState
bool SetBaseState(UsageState state)
Set the base state for all layers in the default configuration.
foxit::pdf::LayerNode::RemoveUsage
bool RemoveUsage(LayerContext::UsageType usage_type)
Remove a kind of usage property.
foxit::pdf::LayerContext::operator=
LayerContext & operator=(const LayerContext &other)
Assign operator.
foxit::pdf::LayerPrintData::LayerPrintData
LayerPrintData(const String &subtype, LayerTree::UsageState print_state)
Constructor, with parameters.
Definition: fs_pdflayer.h:254
foxit::pdf::LayerPrintData::subtype
String subtype
A string that specifies the kind of content controlled by a layer.
Definition: fs_pdflayer.h:304
foxit::pdf::LayerContext::CopyStates
bool CopyStates(const LayerContext &source_context)
Copy states from another layer context.
foxit::pdf::LayerContext
Definition: fs_pdflayer.h:323
foxit::pdf::LayerNode::AddGraphicsObject
bool AddGraphicsObject(const PDFPage &page, graphics::GraphicsObject *graphicsobject)
Add a graphics object to current layer node.
CFX_ByteString
BYTE STRING CLASS.
Definition: fx_string.h:317
foxit::pdf::LayerTree::e_StateON
The state is ON.
Definition: fs_pdflayer.h:130
foxit::pdf::LayerNode::MoveTo
bool MoveTo(LayerNode parent_layer_node, int index)
Move current layer node to be one of the children of another layer node.
foxit::pdf::LayerZoomData::LayerZoomData
LayerZoomData()
Constructor.
Definition: fs_pdflayer.h:46
foxit::pdf::LayerContext::e_UsageZoom
Use for zooming.
Definition: fs_pdflayer.h:340
foxit::pdf::LayerNode::HasIntent
bool HasIntent(const char *intent)
Check if current layer node has a specified intent.
foxit::pdf::graphics::GraphicsObject
Definition: fs_pdfgraphicsobject.h:241
foxit::pdf::LayerNode::SetZoomUsage
bool SetZoomUsage(const LayerZoomData &data)
Set data for layer zooming usage.
foxit
Foxit namespace.
Definition: fs_taggedpdf.h:27
foxit::pdf::LayerPrintData::Set
void Set(const String &subtype, LayerTree::UsageState print_state)
Set value.
Definition: fs_pdflayer.h:298
foxit::pdf::LayerPrintData::LayerPrintData
LayerPrintData(const LayerPrintData &data)
Constructor, with another layer print data object.
Definition: fs_pdflayer.h:269
foxit::pdf::LayerNode::IsInPage
bool IsInPage(const PDFPage &page)
Check if current layer node is in a specified PDF page.
foxit::pdf::LayerTree::GetOCGs
objects::PDFArray * GetOCGs() const
Get the "OCGs" PDF array from current object.
foxit::pdf::LayerContext::MergeStates
bool MergeStates(const LayerContext &source_context)
Merge states from another layer context.
foxit::pdf::LayerContext::e_UsagePrint
Use for printing.
Definition: fs_pdflayer.h:336
foxit::pdf::LayerContext::GetDocument
PDFDoc GetDocument()
Get the related PDF document.
foxit::pdf::LayerNode::GetPrintUsage
LayerPrintData GetPrintUsage()
Get the data for printing usage.
foxit::pdf::objects::PDFDictionary
Definition: fs_pdfobject.h:809
foxit::pdf::LayerContext::operator!=
bool operator!=(const LayerContext &other) const
Not equal operator.
foxit::pdf::LayerPrintData::print_state
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:313
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:780
foxit::pdf::LayerNode::SetPrintUsage
bool SetPrintUsage(const LayerPrintData &data)
Set data for layer printing usage.
foxit::pdf::LayerZoomData::LayerZoomData
LayerZoomData(float min_factor, float max_factor)
Constructor, with parameters.
Definition: fs_pdflayer.h:58
foxit::pdf::LayerTree::operator!=
bool operator!=(const LayerTree &other) const
Not equal operator.
foxit::pdf::PDFDoc
Definition: fs_pdfdoc.h:610
foxit::pdf::LayerTree::e_StateUndefined
The state is undefined.
Definition: fs_pdflayer.h:136
foxit::pdf::LayerNode::GetGraphicsObjects
graphics::GraphicsObjectArray GetGraphicsObjects(const PDFPage &page)
Get all graphics objects related to the layer which is associated with current layer node.
foxit::pdf::PDFPage
Definition: fs_pdfpage.h:412
foxit::pdf::LayerTree::e_StateUnchanged
The state is unchanged.
Definition: fs_pdflayer.h:134
foxit::pdf::LayerTree::e_StateOFF
The state is OFF.
Definition: fs_pdflayer.h:132
foxit::pdf::LayerNode::AddChild
LayerNode AddChild(int index, const wchar_t *name, bool has_Layer)
Add a new layer node as a child for current layer node.
fs_pdfgraphicsobject.h
Header file for PDF graphics object related definitions and classes.
foxit::pdf::LayerContext::UsageType
UsageType
Enumeration for PDF layer usage type.
Definition: fs_pdflayer.h:330
foxit::pdf::LayerPrintData::operator=
LayerPrintData & operator=(const LayerPrintData &data)
Assign operator.
Definition: fs_pdflayer.h:281
foxit::pdf::LayerNode::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::pdf::LayerTree::UsageState
UsageState
Enumeration for PDF layer base state.
Definition: fs_pdflayer.h:128
foxit::pdf::LayerNode::GetChildrenCount
int GetChildrenCount()
Get the count of children nodes.
foxit::pdf::LayerContext::e_UsageExport
Use for exporting.
Definition: fs_pdflayer.h:338
foxit::pdf::LayerContext::IsVisible
bool IsVisible(const LayerNode &layer)
Check if a specified layer node is visible in current layer context.
CFX_WideString
WIDE STRING CLASS.
Definition: fx_string.h:1452
foxit::pdf::LayerZoomData::Set
void Set(float min_factor, float max_factor)
Set value.
Definition: fs_pdflayer.h:96
foxit::pdf::LayerNode::GetName
WString GetName()
Get the name of current layer node.
foxit::pdf::LayerNode::IsLocked
bool IsLocked()
Check if current layer node is locked.
foxit::pdf::LayerNode
Definition: fs_pdflayer.h:480
foxit::pdf::LayerNode::SetViewUsage
bool SetViewUsage(LayerTree::UsageState state)
Set state for viewing usage.
foxit::pdf::LayerContext::~LayerContext
~LayerContext()
Destructor.
foxit::pdf::LayerContext::LayerContext
LayerContext(const PDFDoc &document, UsageType usage_type)
Constructor, based on a PDF document and specified layer usage type.
foxit::pdf::LayerNode::SetName
bool SetName(const wchar_t *name)
Set the name of current layer node.
foxit::pdf::LayerNode::GetViewUsage
LayerTree::UsageState GetViewUsage()
Get the state for viewing usage.
foxit::pdf::LayerTree::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::Base
Definition: fs_basictypes.h:427
foxit::pdf::LayerTree::operator=
LayerTree & operator=(const LayerTree &other)
Assign operator.
foxit::pdf::LayerContext::SetVisible
bool SetVisible(const LayerNode &layer, bool is_visible)
Set the visibility of a specified layer node in current layer context.