RevisionCollection.h
1 //////////////////////////////////////////////////////////////////////////
2 // Copyright 2001-2020 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 <system/shared_ptr.h>
12 #include <system/collections/list.h>
13 #include <system/collections/ilist.h>
14 #include <system/collections/ienumerator.h>
15 #include <system/collections/ienumerable.h>
16 #include <cstdint>
17 
18 #include "Aspose.Words.Cpp/Model/Revisions/Revision.h"
19 
20 namespace Aspose { namespace Words { class Document; } }
21 namespace Aspose { namespace Words { class StyleCollection; } }
22 namespace Aspose { namespace Words { class RevisionGroupCollection; } }
23 namespace Aspose { namespace Words { class DocumentBase; } }
24 namespace Aspose { namespace Words { class RevisionNodeMatcher; } }
25 namespace Aspose { namespace Words { class Style; } }
26 namespace Aspose { namespace Words { class RevisionGroup; } }
27 namespace Aspose { namespace Words { class WordAttrCollection; } }
28 namespace Aspose { namespace Words { class Node; } }
29 namespace Aspose { namespace Words { enum class RevisionType; } }
30 namespace Aspose { namespace Words { namespace Revisions { class RevisionBase; } } }
31 namespace Aspose { template<typename> class EnumeratorWrapperPalGeneric; }
32 
33 namespace Aspose {
34 
35 namespace Words {
36 
37 
38 /// <summary>
39 /// A collection of <see cref="Aspose::Words::Revision" /> objects that represent revisions in the document.
40 /// </summary>
41 /// <remarks>
42 /// <para>You do not create instances of this class directly. Use the <see cref="Aspose::Words::Document::get_Revisions" /> property to get revisions present in a document.</para>
43 /// </remarks>
44 class RevisionCollection : public System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Revision>>
45 {
46  typedef RevisionCollection ThisType;
47  typedef System::Collections::Generic::IEnumerable<System::SharedPtr<Aspose::Words::Revision>> BaseType;
48 
49  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
51 
52  FRIEND_FUNCTION_System_MakeObject;
53  friend class Aspose::Words::Revision;
54  friend class Aspose::Words::Document;
55  friend class Aspose::Words::StyleCollection;
56 
57 private:
58 
59  class RevisionIterator FINAL : public System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Words::Revision>>
60  {
61  typedef RevisionIterator ThisType;
62  typedef System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Words::Revision>> BaseType;
63 
64  typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
65  RTTI_INFO_DECL();
66 
67  public:
68 
69  System::SharedPtr<Aspose::Words::Revision> get_Current() ASPOSE_CONST;
70 
71  RevisionIterator(System::SharedPtr<Aspose::Words::RevisionCollection> revisions);
72 
73  void Dispose();
74  bool MoveNext();
75  void Reset();
76 
77  protected:
78 
79  System::Object::shared_members_type GetSharedMembers() override;
80 
81  private:
82 
83  System::WeakPtr<Aspose::Words::RevisionCollection> mCollection;
84  int32_t mCollectionChangeCount;
85  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mNodeRevisions;
86  System::SharedPtr<Aspose::EnumeratorWrapperPalGeneric<System::SharedPtr<Aspose::Words::Revision>>> mStyleRevisions;
87  int32_t mIndex;
88  System::SharedPtr<Aspose::Words::Revision> mCurNode;
89 
90  static const System::String& ExceptionMessage();
91 
92  };
93 
94 
95 public:
96 
97  /// <summary>
98  /// Returns the number of revisions in the collection.
99  /// </summary>
101  /// <summary>
102  /// Collection of revision groups.
103  /// </summary>
104  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::RevisionGroupCollection> get_Groups();
105 
106  /// <summary>
107  /// Accepts all revisions in this collection.
108  /// </summary>
110  /// <summary>
111  /// Rejects all revisions in this collection.
112  /// </summary>
114 
115  /// <summary>
116  /// Returns a Revision at the specified index.
117  /// </summary>
118  /// <remarks>
119  /// <remarks>
120  /// <p>The index is zero-based.</p>
121  /// <p>Negative indexes are allowed and indicate access from the back of the collection.
122  /// For example -1 means the last item, -2 means the second before last and so on.</p>
123  /// <p>If index is greater than or equal to the number of items in the list, this returns a null reference.</p>
124  /// <p>If index is negative and its absolute value is greater than the number of items in the list, this returns a null reference.</p>
125  /// </remarks>
126  /// </remarks>
127  /// <param name="index">An index into the collection.</param>
128  ASPOSE_WORDS_SHARED_API System::SharedPtr<Aspose::Words::Revision> idx_get(int32_t index);
129 
130  /// <summary>
131  /// Returns an enumerator object.
132  /// </summary>
133  ASPOSE_WORDS_SHARED_API System::SharedPtr<System::Collections::Generic::IEnumerator<System::SharedPtr<Aspose::Words::Revision>>> GetEnumerator();
134 
135 protected:
136 
137  int32_t get_EmptyFormatRevisionsCount();
138  int32_t get_ChangeCount() const;
139 
140  RevisionCollection(System::SharedPtr<Aspose::Words::DocumentBase> doc);
141 
142  void Invalidate(System::SharedPtr<Aspose::Words::Revision> revision);
143  void Remove(System::SharedPtr<Aspose::Words::Style> style);
144  void AddStyleRevisions(System::SharedPtr<Aspose::Words::Style> style);
145  System::SharedPtr<Aspose::Words::RevisionGroup> GetGroupByRevision(System::SharedPtr<Aspose::Words::Revision> revision);
146  System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<Aspose::Words::Revision>>> ToList();
147 
148  virtual ASPOSE_WORDS_SHARED_API ~RevisionCollection();
149 
150  ASPOSE_WORDS_SHARED_API System::Object::shared_members_type GetSharedMembers() override;
151 
152 private:
153 
154  int32_t get_DocumentChangeCount();
155 
156  int32_t mChangeCount;
157  int32_t mDocumentChangeCount;
158  System::WeakPtr<Aspose::Words::DocumentBase> mDocument;
159  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mNodeRevisions;
160  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mEmptyFormatRevisions;
161  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mStyleRevisions;
162 
163  static System::SharedPtr<Aspose::Words::RevisionNodeMatcher>& gRevisionNodeMatcher();
164 
165  System::SharedPtr<Aspose::Words::RevisionGroupCollection> mRevisionGroups;
166 
167  void InvalidateAll();
168  void CollectRevisions();
169  void CheckInvalidate();
170  void AddEmptyStyleFormatRevision(System::SharedPtr<Aspose::Words::Style> style);
171  void AddNodeRevisions(System::SharedPtr<Aspose::Words::WordAttrCollection> attrCollection, System::SharedPtr<Aspose::Words::Node> node);
172  void AddNodeRevision(System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<Aspose::Words::Revision>>> revArr, Aspose::Words::RevisionType type, System::SharedPtr<Aspose::Words::Revisions::RevisionBase> revision, System::SharedPtr<Aspose::Words::Node> nodeWithRevisions, bool incChangeCount);
173  void AddStyleRevision(System::SharedPtr<System::Collections::Generic::IList<System::SharedPtr<Aspose::Words::Revision>>> revArr, System::SharedPtr<Aspose::Words::Revisions::RevisionBase> revision, System::SharedPtr<Aspose::Words::Style> styleWithRevisions, bool incChangeCount);
174  void IncrementChangeCount(bool incChangeCount);
175 
176 };
177 
178 }
179 }
Base class for all nodes of a Word document.
Definition: Node.h:209
Represents a group of sequential Aspose::Words::Revision objects.
Definition: RevisionGroup.h:39
Definition: IFontData.h:18
Definition: Hyphenation.h:18
#define ASPOSE_WORDS_SHARED_RTTI_INFO_DECL()
Definition: aspose_words_api_defs.h:12
Represents a Word document.
Definition: Document.h:266
A collection of Aspose::Words::Revision objects that represent revisions in the document.
Definition: RevisionCollection.h:44
A collection of Style objects that represent both the built-in and user-defined styles in a document.
Definition: StyleCollection.h:122
RevisionType
Specifies the type of change being tracked in Aspose::Words::Revision.
Definition: RevisionType.h:23
Provides the abstract base class for a main document and a glossary document of a Word document.
Definition: DocumentBase.h:210
int32_t get_Count()
Returns the number of revisions in the collection.
#define ASPOSE_WORDS_SHARED_API
Definition: aspose_words_api_defs.h:10
System::SharedPtr< System::Collections::Generic::IEnumerator< System::SharedPtr< Aspose::Words::Revision > > > GetEnumerator()
Returns an enumerator object.
void AcceptAll()
Accepts all revisions in this collection.
Represents a single built-in or user-defined style.
Definition: Style.h:140
Represents a revision (tracked change) in a document node or style. Use Aspose::Words::Revision::get_...
Definition: Revision.h:36
void RejectAll()
Rejects all revisions in this collection.
Definition: Style.h:24
System::SharedPtr< Aspose::Words::RevisionGroupCollection > get_Groups()
Collection of revision groups.
System::SharedPtr< Aspose::Words::Revision > idx_get(int32_t index)
Returns a Revision at the specified index.