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"
19 #include "pdf/graphics/fs_pdfgraphicsobject.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:
49 LayerZoomData()
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
71 LayerZoomData(const LayerZoomData& data) {
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,
137 e_StateUnchanged = 0x0002,
139 e_StateUndefined = 0x0003
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
218 LayerNode GetRootNode();
219
227 objects::PDFDictionary* GetDict() const;
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:
269 LayerPrintData(const String &subtype, LayerTree::UsageState print_state) {
270 this->subtype = subtype;
271 this->print_state = print_state;
272 }
273
275 LayerPrintData()
276 :print_state(LayerTree::e_StateUndefined) {
277 }
278
284 LayerPrintData(const LayerPrintData& data) {
285 subtype = data.subtype;
286 print_state = data.print_state;
287 }
288
296 LayerPrintData &operator = (const LayerPrintData& data) {
297 subtype = data.subtype;
298 print_state = data.print_state;
299 return (*this);
300 }
301
313 void Set(const String &subtype, LayerTree::UsageState print_state) {
314 this->subtype = subtype;
315 this->print_state = print_state;
316 }
317
319 String subtype;
320
328 LayerTree::UsageState print_state;
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
415 PDFDoc GetDocument();
422 UsageType GetUsageType();
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
661 LayerTree::UsageState GetViewUsage();
662
673 LayerTree::UsageState GetExportUsage();
674
684 LayerPrintData GetPrintUsage();
685
695 LayerZoomData GetZoomUsage();
696
708 bool SetName(const wchar_t* name);
709
721 bool SetDefaultVisible(bool is_visible);
722
742 bool SetViewUsage(LayerTree::UsageState state);
743
762 bool SetExportUsage(LayerTree::UsageState state);
763
783 bool SetPrintUsage(const LayerPrintData& data);
784
796 bool SetZoomUsage(const LayerZoomData& data);
797
809 graphics::GraphicsObjectArray GetGraphicsObjects(const PDFPage& page);
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
864 objects::PDFDictionary* GetDict() const;
865
874 foxit::pdf::annots::AnnotArray GetAnnots();
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
foxit::pdf::LayerNodeArray
Definition: fs_pdflayer.h:41
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:213
foxit::pdf::objects::PDFArray
Definition: fs_pdfobject.h:640
foxit::pdf::LayerContext::e_UsageView
Use for a viewer.
Definition: fs_pdflayer.h:347
foxit::pdf::LayerTree::~LayerTree
~LayerTree()
Destructor.
foxit::pdf::LayerPrintData::LayerPrintData
LayerPrintData()
Constructor.
Definition: fs_pdflayer.h:275
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:113
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:220
foxit::pdf::LayerNode::operator=
LayerNode & operator=(const LayerNode &other)
Assign operator.
foxit::pdf::LayerZoomData
Definition: fs_pdflayer.h:46
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.
foxit::pdf::LayerTree::GetOCGsByPageIndex
LayerNodeArray GetOCGsByPageIndex(int page_index)
Get an array of OCG objects found on a specified page.
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:108
foxit::pdf::LayerPrintData
Definition: fs_pdflayer.h:258
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:349
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:71
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:124
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:269
foxit::pdf::LayerPrintData::subtype
String subtype
A string that specifies the kind of content controlled by a layer.
Definition: fs_pdflayer.h:319
foxit::pdf::LayerContext::CopyStates
bool CopyStates(const LayerContext &source_context)
Copy states from another layer context.
foxit::pdf::LayerContext
Definition: fs_pdflayer.h:338
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::annots::AnnotArray
Definition: fs_annot.h:1666
foxit::pdf::LayerTree::e_StateON
The state is ON.
Definition: fs_pdflayer.h:133
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:49
foxit::pdf::LayerContext::e_UsageZoom
Use for zooming.
Definition: fs_pdflayer.h:355
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:313
foxit::pdf::LayerPrintData::LayerPrintData
LayerPrintData(const LayerPrintData &data)
Constructor, with another layer print data object.
Definition: fs_pdflayer.h:284
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:351
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:850
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:328
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:792
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:61
foxit::pdf::LayerTree::operator!=
bool operator!=(const LayerTree &other) const
Not equal operator.
foxit::pdf::PDFDoc
Definition: fs_pdfdoc.h:776
foxit::pdf::LayerTree::e_StateUndefined
The state is undefined.
Definition: fs_pdflayer.h:139
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:137
foxit::pdf::LayerTree::e_StateOFF
The state is OFF.
Definition: fs_pdflayer.h:135
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:345
foxit::pdf::LayerPrintData::operator=
LayerPrintData & operator=(const LayerPrintData &data)
Assign operator.
Definition: fs_pdflayer.h:296
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:131
foxit::pdf::LayerNode::GetChildrenCount
int GetChildrenCount()
Get the count of children nodes.
foxit::pdf::LayerNode::GetAnnots
foxit::pdf::annots::AnnotArray GetAnnots()
Get an array of annotations which are related to current layer node.
foxit::pdf::LayerContext::e_UsageExport
Use for exporting.
Definition: fs_pdflayer.h:353
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:1461
foxit::pdf::LayerZoomData::Set
void Set(float min_factor, float max_factor)
Set value.
Definition: fs_pdflayer.h:99
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:495
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:451
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.