RevisionCollection.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 <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;
50  ASPOSE_WORDS_SHARED_RTTI_INFO_DECL();
51 
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;
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>
100  ASPOSE_WORDS_SHARED_API int32_t get_Count();
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>
109  ASPOSE_WORDS_SHARED_API void AcceptAll();
110  /// <summary>
111  /// Rejects all revisions in this collection.
112  /// </summary>
113  ASPOSE_WORDS_SHARED_API void RejectAll();
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  ASPOSE_WORDS_SHARED_API System::Object::shared_members_type GetSharedMembers() override;
148 
149 private:
150 
151  int32_t get_DocumentChangeCount();
152 
153  int32_t mChangeCount;
154  int32_t mDocumentChangeCount;
155  System::WeakPtr<Aspose::Words::DocumentBase> mDocument;
156  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mNodeRevisions;
157  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mEmptyFormatRevisions;
158  System::SharedPtr<System::Collections::Generic::List<System::SharedPtr<Aspose::Words::Revision>>> mStyleRevisions;
159 
160  static System::SharedPtr<Aspose::Words::RevisionNodeMatcher>& gRevisionNodeMatcher();
161 
162  System::SharedPtr<Aspose::Words::RevisionGroupCollection> mRevisionGroups;
163 
164  void InvalidateAll();
165  void CollectRevisions();
166  void CheckInvalidate();
167  void AddEmptyStyleFormatRevision(System::SharedPtr<Aspose::Words::Style> style);
168  void AddNodeRevisions(System::SharedPtr<Aspose::Words::WordAttrCollection> attrCollection, System::SharedPtr<Aspose::Words::Node> node);
169  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);
170  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);
171  void IncrementChangeCount(bool incChangeCount);
172 
173 };
174 
175 }
176 }
Definition: IFontData.h:19
#define FINAL
Final keyword definition.
Definition: defines.h:33
A collection of Aspose::Words::Revision objects that represent revisions in the document.
Definition: RevisionCollection.h:44
#define RTTI_INFO_DECL()
Definition: reflection_seprt.h:77
A collection of Style objects that represent both the built-in and user-defined styles in a document.
Definition: StyleCollection.h:121
RevisionType
Specifies the type of change being tracked in Aspose::Words::Revision.
Definition: RevisionType.h:23
#define ASPOSE_CONST
Makes methods labelled as ASPOSE_CONST const.
Definition: defines.h:43
#define FRIEND_FUNCTION_System_MakeObject
Macro to befriend MakeObject function.
Definition: smart_ptr.h:1366