Cell.h
1 //////////////////////////////////////////////////////////////////////////
2 // Copyright 2001-2019 Aspose Pty Ltd. All Rights Reserved.
3 //
4 // This file is part of Aspose.Words. The source code in this file
5 // is only intended as a supplement to the documentation, and is provided
6 // "as is", without warranty of any kind, either expressed or implied.
7 //////////////////////////////////////////////////////////////////////////
8 #pragma once
9 
10 
11 #include "Aspose.Words.Cpp/Model/Revisions/ITrackableNode.h"
12 #include "Aspose.Words.Cpp/Model/Nodes/CompositeNode.h"
13 #include "Aspose.Words.Cpp/Model/Formatting/ICellAttrSource.h"
14 
15 namespace Aspose { namespace Words { namespace Themes { class ThemeColorRemover; } } }
16 namespace Aspose { namespace Words { namespace Comparison { class FormattingComparer; } } }
17 namespace Aspose { namespace Words { namespace Comparison { class RowComparer; } } }
18 namespace Aspose { namespace Words { namespace Comparison { class TableComparer; } } }
19 namespace Aspose { namespace Words { namespace Themes { class ThemeColorUpdater; } } }
20 namespace Aspose { namespace Words { class DocumentInserter; } }
21 namespace Aspose { namespace Words { namespace Formatting { namespace Intern { class InternManager; } } } }
22 namespace Aspose { namespace Words { namespace Tables { class DocRtfGridHandler; } } }
23 namespace Aspose { namespace Words { namespace Tables { class TableMerger; } } }
24 namespace Aspose { namespace Words { namespace RW { namespace Nrx { namespace Reader { class NrxCellReaderBase; } } } } }
25 namespace Aspose { namespace Words { namespace RW { namespace Html { namespace Css { namespace New { class DocumentFormatter; } } } } } }
26 namespace Aspose { namespace Words { class RevisionGroupCollection; } }
27 namespace Aspose { namespace Words { namespace Drawing { class ShapeSizeValidationHelper; } } }
28 namespace Aspose { namespace Words { namespace Fields { namespace Expressions { class FieldContext; } } } }
29 namespace Aspose { namespace Words { namespace Revisions { class RevisionUtil; } } }
30 namespace Aspose { namespace Words { namespace Tables { class CellSpan; } } }
31 namespace Aspose { namespace Words { namespace Tables { class RowSpan; } } }
32 namespace Aspose { namespace Words { namespace Tables { class FixedGridCalculator; } } }
33 namespace Aspose { namespace Words { namespace RW { namespace Doc { namespace Writer { class TablePrWriter; } } } } }
34 namespace Aspose { namespace Words { namespace Fields { namespace Expressions { class OneDimensionCellRangeEnumerator; } } } }
35 namespace Aspose { namespace Words { namespace Fields { namespace Expressions { class UpDownCellRangeEnumerator; } } } }
36 namespace Aspose { namespace Words { namespace Markup { class StructuredDocumentTag; } } }
37 namespace Aspose { namespace Words { class NodeUtil; } }
38 namespace Aspose { namespace Words { namespace Layout { class AttributeConverter; } } }
39 namespace Aspose { namespace Words { namespace Layout { namespace Core { class SpanGenerator; } } } }
40 namespace Aspose { namespace Words { namespace Fields { namespace Expressions { class CellPosition; } } } }
41 namespace Aspose { namespace Words { namespace Fields { class NewResultEnumerator; } } }
42 namespace Aspose { namespace Words { class TableStyle; } }
43 namespace Aspose { namespace Words { namespace TableLayout { class Extensions; } } }
44 namespace Aspose { namespace Words { namespace Tables { class TableFormattingExpander; } } }
45 namespace Aspose { namespace Words { class DocumentBuilder; } }
46 namespace Aspose { namespace Words { namespace Validation { class DocumentPostLoader; } } }
47 namespace Aspose { namespace Words { namespace Validation { class DocumentValidator; } } }
48 namespace Aspose { namespace Words { class TableBuilder; } }
49 namespace Aspose { namespace Words { namespace Validation { class TableValidator; } } }
50 namespace Aspose { namespace Words { namespace RW { namespace Html { namespace Css { namespace New { class CssBackgroundColorPropertyDef; } } } } } }
51 namespace Aspose { namespace Words { namespace RW { namespace Html { namespace Writer { class HtmlTableWriter; } } } } }
52 namespace Aspose { namespace Words { namespace RW { namespace MarkupLanguage { namespace Writer { class MarkupLanguageTableWriterBase; } } } } }
53 namespace Aspose { namespace Words { namespace RW { namespace MarkupLanguage { namespace Writer { class MarkupLanguageDocumentTreeWriter; } } } } }
54 namespace Aspose { namespace Words { namespace RW { class MarkupResolver; } } }
55 namespace Aspose { namespace Words { namespace Lists { class ListLabelUtil; } } }
56 namespace Aspose { namespace Words { namespace TableLayout { class TableLayouter; } } }
57 namespace Aspose { namespace Words { namespace Tables { class CellCollection; } } }
58 namespace Aspose { namespace Words { namespace Tables { class Row; } } }
59 namespace Aspose { namespace Words { namespace Tables { class Table; } } }
60 namespace Aspose { namespace Words { class InlineHelper; } }
61 namespace Aspose { namespace Words { class Paragraph; } }
62 namespace Aspose { namespace Words { namespace RW { namespace Docx { namespace Writer { class DocxDocumentWriterBase; } } } } }
63 namespace Aspose { namespace Words { namespace RW { namespace Nrx { class NrxTableGrid; } } } }
64 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Reader { class OdtTableCellReader; } } } } }
65 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Reader { class OdtTableReader; } } } } }
66 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Reader { class OdtParagraphReader; } } } } }
67 namespace Aspose { namespace Words { namespace RW { namespace Celler { class CellerTable; } } } }
68 namespace Aspose { namespace Words { namespace RW { namespace Doc { namespace Reader { class ModelBuilder; } } } } }
69 namespace Aspose { namespace Words { namespace RW { namespace Html { class CssTable; } } } }
70 namespace Aspose { namespace Words { namespace RW { namespace Html { namespace Reader { class HtmlReader; } } } } }
71 namespace Aspose { namespace Words { namespace RW { namespace Html { namespace Reader { class HtmlTableReader; } } } } }
72 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Writer { class OdtTextPropertiesWriter; } } } } }
73 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Writer { class OdtCellPropertiesWriter; } } } } }
74 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Writer { class OdtTableWriter; } } } } }
75 namespace Aspose { namespace Words { namespace RW { namespace Odt { namespace Writer { class OdtParagraphPropertiesWriter; } } } } }
76 namespace Aspose { namespace Words { namespace RW { namespace Txt { namespace Writer { class TxtTableBuilder; } } } } }
77 namespace Aspose { namespace Words { namespace Tables { class TableGridFromCellWidth; } } }
78 namespace Aspose { namespace Words { namespace RW { namespace Rtf { namespace Reader { class RtfModelBuilder; } } } } }
79 namespace Aspose { namespace Words { namespace RW { namespace Rtf { namespace Writer { class RtfTableDefWriter; } } } } }
80 namespace Aspose { namespace Words { namespace RW { namespace Rtf { namespace Writer { class RtfWriter; } } } } }
81 namespace Aspose { namespace Words { namespace RW { namespace Txt { namespace Writer { class TxtWriter; } } } } }
82 namespace Aspose { namespace Words { namespace RW { namespace Wml { namespace Reader { class WmlRunPrReader; } } } } }
83 namespace Aspose { namespace Words { namespace RW { namespace Wml { namespace Writer { class WmlWriter; } } } } }
84 namespace Aspose { namespace Words { namespace Tables { class CellFormat; } } }
85 namespace Aspose { namespace Words { class ParagraphCollection; } }
86 namespace Aspose { namespace Words { namespace Tables { class TableCollection; } } }
87 namespace Aspose { namespace Words { namespace Tables { class CellPr; } } }
88 namespace Aspose { namespace Words { namespace Revisions { class EditRevision; } } }
89 namespace Aspose { namespace Words { namespace Revisions { class MoveRevision; } } }
90 namespace Aspose { namespace Words { class DocumentBase; } }
91 namespace Aspose { namespace Words { class Node; } }
92 namespace Aspose { namespace Words { class INodeCloningListener; } }
93 namespace Aspose { namespace Words { class DocumentVisitor; } }
94 namespace Aspose { namespace Words { enum class VisitorAction; } }
95 
96 namespace Aspose {
97 
98 namespace Words {
99 
100 namespace Tables {
101 
102 
103 /// <summary>
104 /// Represents a table cell.
105 /// </summary>
106 /// <remarks>
107 /// <p>
108 /// <b>Cell</b> can only be a child of a <b>Row</b>.</p>
109 /// <p>
110 /// <b>Cell</b> can contain block-level nodes <b>Paragraph</b> and <b>Table</b>.</p>
111 /// <p>A minimal valid cell needs to have at least one <b>Paragraph</b>.</p>
112 /// </remarks>
113 class Cell : public Aspose::Words::CompositeNode, public Aspose::Words::ICellAttrSource, public Aspose::Words::Revisions::ITrackableNode
114 {
115  typedef Cell ThisType;
116  typedef Aspose::Words::CompositeNode BaseType;
117  typedef Aspose::Words::ICellAttrSource BaseType1;
118  typedef Aspose::Words::Revisions::ITrackableNode BaseType2;
119 
120  typedef ::System::BaseTypesInfo<BaseType, BaseType1, BaseType2> ThisTypeBaseTypesInfo;
121  ASPOSE_WORDS_SHARED_RTTI_INFO_DECL();
122 
123  FRIEND_FUNCTION_System_MakeObject;
124  friend class Aspose::Words::Themes::ThemeColorRemover;
125  friend class Aspose::Words::Comparison::FormattingComparer;
126  friend class Aspose::Words::Comparison::RowComparer;
127  friend class Aspose::Words::Comparison::TableComparer;
128  friend class Aspose::Words::Themes::ThemeColorUpdater;
129  friend class Aspose::Words::DocumentInserter;
130  friend class Aspose::Words::Formatting::Intern::InternManager;
131  friend class Aspose::Words::Tables::DocRtfGridHandler;
132  friend class Aspose::Words::Tables::TableMerger;
133  friend class Aspose::Words::RW::Nrx::Reader::NrxCellReaderBase;
134  friend class Aspose::Words::RW::Html::Css::New::DocumentFormatter;
135  friend class Aspose::Words::RevisionGroupCollection;
136  friend class Aspose::Words::Drawing::ShapeSizeValidationHelper;
137  friend class Aspose::Words::Fields::Expressions::FieldContext;
138  friend class Aspose::Words::Revisions::RevisionUtil;
139  friend class Aspose::Words::Tables::CellSpan;
140  friend class Aspose::Words::Tables::RowSpan;
141  friend class Aspose::Words::Tables::FixedGridCalculator;
142  friend class Aspose::Words::RW::Doc::Writer::TablePrWriter;
143  friend class Aspose::Words::Fields::Expressions::OneDimensionCellRangeEnumerator;
144  friend class Aspose::Words::Fields::Expressions::UpDownCellRangeEnumerator;
145  friend class Aspose::Words::Markup::StructuredDocumentTag;
146  friend class Aspose::Words::NodeUtil;
147  friend class Aspose::Words::Layout::AttributeConverter;
148  friend class Aspose::Words::Layout::Core::SpanGenerator;
149  friend class Aspose::Words::Fields::Expressions::CellPosition;
150  friend class Aspose::Words::Fields::NewResultEnumerator;
151  friend class Aspose::Words::TableStyle;
152  friend class Aspose::Words::TableLayout::Extensions;
153  friend class Aspose::Words::Tables::TableFormattingExpander;
154  friend class Aspose::Words::DocumentBuilder;
155  friend class Aspose::Words::Validation::DocumentPostLoader;
156  friend class Aspose::Words::Validation::DocumentValidator;
157  friend class Aspose::Words::TableBuilder;
158  friend class Aspose::Words::Validation::TableValidator;
159  friend class Aspose::Words::RW::Html::Css::New::CssBackgroundColorPropertyDef;
160  friend class Aspose::Words::RW::Html::Writer::HtmlTableWriter;
161  friend class Aspose::Words::RW::MarkupLanguage::Writer::MarkupLanguageTableWriterBase;
162  friend class Aspose::Words::RW::MarkupLanguage::Writer::MarkupLanguageDocumentTreeWriter;
163  friend class Aspose::Words::RW::MarkupResolver;
164  friend class Aspose::Words::Lists::ListLabelUtil;
165  friend class Aspose::Words::TableLayout::TableLayouter;
166  friend class Aspose::Words::Tables::CellCollection;
167  friend class Aspose::Words::Tables::Row;
168  friend class Aspose::Words::Tables::Table;
169  friend class Aspose::Words::InlineHelper;
170  friend class Aspose::Words::Paragraph;
171  friend class Aspose::Words::RW::Docx::Writer::DocxDocumentWriterBase;
172  friend class Aspose::Words::RW::Nrx::NrxTableGrid;
173  friend class Aspose::Words::RW::Odt::Reader::OdtTableCellReader;
174  friend class Aspose::Words::RW::Odt::Reader::OdtTableReader;
175  friend class Aspose::Words::RW::Odt::Reader::OdtParagraphReader;
176  friend class Aspose::Words::RW::Celler::CellerTable;
177  friend class Aspose::Words::RW::Doc::Reader::ModelBuilder;
178  friend class Aspose::Words::RW::Html::CssTable;
179  friend class Aspose::Words::RW::Html::Reader::HtmlReader;
180  friend class Aspose::Words::RW::Html::Reader::HtmlTableReader;
181  friend class Aspose::Words::RW::Odt::Writer::OdtTextPropertiesWriter;
182  friend class Aspose::Words::RW::Odt::Writer::OdtCellPropertiesWriter;
183  friend class Aspose::Words::RW::Odt::Writer::OdtTableWriter;
184  friend class Aspose::Words::RW::Odt::Writer::OdtParagraphPropertiesWriter;
185  friend class Aspose::Words::RW::Txt::Writer::TxtTableBuilder;
186  friend class Aspose::Words::Tables::TableGridFromCellWidth;
187  friend class Aspose::Words::RW::Rtf::Reader::RtfModelBuilder;
188  friend class Aspose::Words::RW::Rtf::Writer::RtfTableDefWriter;
189  friend class Aspose::Words::RW::Rtf::Writer::RtfWriter;
190  friend class Aspose::Words::RW::Txt::Writer::TxtWriter;
191  friend class Aspose::Words::RW::Wml::Reader::WmlRunPrReader;
192  friend class Aspose::Words::RW::Wml::Writer::WmlWriter;
193 
194 public:
195  using Aspose::Words::CompositeNode::Clone;
196 
197 public:
198 
199  /// <summary>
200  /// Returns <b>NodeType.Cell</b>.
201  /// </summary>
202  virtual ASPOSE_WORDS_SHARED_API Aspose::Words::NodeType get_NodeType() const;
203  /// <summary>
204  /// Returns the parent row of the cell.
205  /// </summary>
206  /// <remarks>Equivalent to <c>(Row)FirstNonMarkupParentNode</c>.</remarks>
207  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Tables::Row> get_ParentRow();
208  /// <summary>
209  /// Gets the first paragraph among the immediate children.
210  /// </summary>
211  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Paragraph> get_FirstParagraph();
212  /// <summary>
213  /// Gets the last paragraph among the immediate children.
214  /// </summary>
215  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Paragraph> get_LastParagraph();
216  /// <summary>
217  /// True if this is the first cell inside a row; false otherwise.
218  /// </summary>
219  ASPOSE_WORDS_SHARED_API bool get_IsFirstCell();
220  /// <summary>
221  /// True if this is the last cell inside a row; false otherwise.
222  /// </summary>
223  ASPOSE_WORDS_SHARED_API bool get_IsLastCell();
224  /// <summary>
225  /// Provides access to the formatting properties of the cell.
226  /// </summary>
227  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Tables::CellFormat> get_CellFormat();
228  /// <summary>
229  /// Gets a collection of paragraphs that are immediate children of the cell.
230  /// </summary>
231  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::ParagraphCollection> get_Paragraphs();
232  /// <summary>
233  /// Gets a collection of tables that are immediate children of the cell.
234  /// </summary>
235  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Tables::TableCollection> get_Tables();
236  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Revisions::EditRevision> get_InsertRevision();
237  ASPOSE_WORDS_SHARED_API void set_InsertRevision(System::SharedPtr<Aspose::Words::Revisions::EditRevision> value);
238  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Revisions::EditRevision> get_DeleteRevision();
239  ASPOSE_WORDS_SHARED_API void set_DeleteRevision(System::SharedPtr<Aspose::Words::Revisions::EditRevision> value);
240  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Revisions::MoveRevision> get_MoveFromRevision();
241  ASPOSE_WORDS_SHARED_API void set_MoveFromRevision(System::SharedPtr<Aspose::Words::Revisions::MoveRevision> value);
242  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Revisions::MoveRevision> get_MoveToRevision();
243  ASPOSE_WORDS_SHARED_API void set_MoveToRevision(System::SharedPtr<Aspose::Words::Revisions::MoveRevision> value);
244 
245  /// <summary>
246  /// Initializes a new instance of the <b>Cell</b> class.
247  /// </summary>
248  /// <remarks>
249  /// <p>When <b>Cell</b> is created, it belongs to the specified document, but is not
250  /// yet part of the document and <b>ParentNode</b> is null.</p>
251  /// <p>To append <b>Cell</b> to the document use InsertAfter or InsertBefore
252  /// on the row where you want the cell inserted.</p>
253  /// </remarks>
254  /// <param name="doc">The owner document.</param>
255  ASPOSE_WORDS_SHARED_API Cell(System::SharedPtr<Aspose::Words::DocumentBase> doc);
256 
257  /// <summary>
258  /// Accepts a visitor.
259  /// </summary>
260  /// <remarks>
261  /// <p>Enumerates over this node and all of its children. Each node calls a corresponding method on DocumentVisitor.</p>
262  /// <p>For more info see the Visitor design pattern.</p>
263  /// </remarks>
264  /// <param name="visitor">The visitor that will visit the nodes.</param>
265  /// <returns>True if all nodes were visited; false if DocumentVisitor stopped the operation before visiting all nodes.</returns>
266  /// <remarks>
267  /// Calls DocumentVisitor.VisitCellStart, then calls Accept for all child nodes of the section
268  /// and calls DocumentVisitor.VisitCellEnd at the end.
269  /// </remarks>
270  virtual ASPOSE_WORDS_SHARED_API bool Accept(System::SharedPtr<Aspose::Words::DocumentVisitor> visitor);
271  /// <summary>
272  /// If the last child is not a paragraph, creates and appends one empty paragraph.
273  /// </summary>
274  ASPOSE_WORDS_SHARED_API void EnsureMinimum();
275  ASPOSE_WORDS_SHARED_API System::SharedPtr<System::Object> GetDirectCellAttr(int32_t key);
276  ASPOSE_WORDS_SHARED_API System::SharedPtr<System::Object> FetchCellAttr(int32_t key);
277  ASPOSE_WORDS_SHARED_API System::SharedPtr<System::Object> FetchInheritedCellAttr(int32_t key);
278  ASPOSE_WORDS_SHARED_API void SetCellAttr(int32_t key, System::SharedPtr<System::Object> value);
279  ASPOSE_WORDS_SHARED_API void ClearCellAttrs();
280 
281 protected:
282 
283  System::SharedPtr<Aspose::Words::Tables::Table> get_ParentTable();
284  System::SharedPtr<Aspose::Words::Tables::Cell> get_NextCell();
285  System::SharedPtr<Aspose::Words::Tables::Cell> get_PreviousCell();
286  int32_t get_ColumnIndex();
287  int32_t get_RowIndex();
288  System::SharedPtr<Aspose::Words::Tables::CellPr> get_CellPr() const;
289  void set_CellPr(System::SharedPtr<Aspose::Words::Tables::CellPr> value);
290 
291  Cell(System::SharedPtr<Aspose::Words::DocumentBase> doc, System::SharedPtr<Aspose::Words::Tables::CellPr> cellPr);
292 
293  virtual ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Node> Clone(bool isCloneChildren, System::SharedPtr<Aspose::Words::INodeCloningListener> cloningListener);
294  virtual ASPOSE_WORDS_SHARED_API Aspose::Words::VisitorAction AcceptStart(System::SharedPtr<Aspose::Words::DocumentVisitor> visitor);
295  virtual ASPOSE_WORDS_SHARED_API Aspose::Words::VisitorAction AcceptEnd(System::SharedPtr<Aspose::Words::DocumentVisitor> visitor);
296  virtual ASPOSE_WORDS_SHARED_API bool CanInsert(System::SharedPtr<Aspose::Words::Node> newChild);
297  System::SharedPtr<System::Object> GetInheritedCellAttr(int32_t key);
298  System::SharedPtr<Aspose::Words::Tables::CellPr> GetExpandedCellPr();
299  ASPOSE_WORDS_SHARED_API System::Object::shared_members_type GetSharedMembers() override;
300 
301 private:
302 
303  System::SharedPtr<Aspose::Words::Tables::CellPr> mCellPr;
304  System::SharedPtr<Aspose::Words::Tables::CellFormat> mCellFormat;
305  System::SharedPtr<Aspose::Words::ParagraphCollection> mParagraphs;
306  System::SharedPtr<Aspose::Words::Tables::TableCollection> mTables;
307 
308  void ExpandAttr(int32_t key, System::SharedPtr<Aspose::Words::Tables::CellPr> dstCellPr);
309  ThisType* CppMemberwiseClone() ASPOSE_CONST override { return new ThisType(*this); }
310 
311 };
312 
313 }
314 }
315 }
System::ArrayPtr< System::SharedPtr< Aspose::Words::Tables::Table > > ToArray()
Copies all tables from the collection to a new array of tables.
Definition: IFontData.h:19
Definition: CompareOptions.h:16
Definition: Hyphenation.h:18
Definition: Border.h:47
Definition: Border.h:65
System::ArrayPtr< System::SharedPtr< Aspose::Words::Tables::Cell > > ToArray()
Copies all cells from the collection to a new array of cells.
VisitorAction
Allows the visitor to control the enumeration of nodes.
Definition: VisitorAction.h:23
System::ArrayPtr< System::SharedPtr< Aspose::Words::Paragraph > > ToArray()
Copies all paragraphs from the collection to a new array of paragraphs.