1 // Copyright (c) 2006-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <TDocStd_Document.hxx>
16 #include <CDM_Document.hxx>
17 #include <CDM_MetaData.hxx>
18 #include <Standard_Dump.hxx>
19 #include <Standard_Type.hxx>
20 #include <TCollection_AsciiString.hxx>
21 #include <TCollection_ExtendedString.hxx>
22 #include <TDF_AttributeDelta.hxx>
23 #include <TDF_AttributeDeltaList.hxx>
24 #include <TDF_AttributeIterator.hxx>
25 #include <TDF_AttributeList.hxx>
26 #include <TDF_Data.hxx>
27 #include <TDF_Delta.hxx>
28 #include <TDF_IDMap.hxx>
29 #include <TDF_Label.hxx>
30 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
31 #include <TDF_ListIteratorOfAttributeList.hxx>
32 #include <TDF_ListIteratorOfDeltaList.hxx>
33 #include <TDF_Reference.hxx>
34 #include <TDocStd.hxx>
35 #include <TDocStd_Application.hxx>
36 #include <TDocStd_CompoundDelta.hxx>
37 #include <TDocStd_Context.hxx>
38 #include <TDocStd_LabelIDMapDataMap.hxx>
39 #include <TDocStd_Modified.hxx>
40 #include <TDocStd_Owner.hxx>
41 #include <TDocStd_XLink.hxx>
42 #include <TDocStd_XLinkIterator.hxx>
44 IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Document,CDM_Document)
46 // List should have a RemoveLast...
47 #define TDocStd_List_RemoveLast(theList) \
48 TDF_ListIteratorOfDeltaList it(theList); \
49 Standard_Integer i,n = theList.Extent(); \
50 for (i = 1; i < n; i++) it.Next(); \
57 #define SRN_DELTA_COMPACT
59 //=======================================================================
62 //=======================================================================
64 Handle(TDocStd_Document) TDocStd_Document::Get (const TDF_Label& acces)
66 // avoid creation of Handle(TDF_Data) during TDF_Data destruction
67 if (acces.Root().HasAttribute()) {
68 return TDocStd_Owner::GetDocument(acces.Data());
70 return Handle(TDocStd_Document)();
73 //=======================================================================
74 //function : TDocStd_Document
76 //=======================================================================
79 TDocStd_Document::TDocStd_Document(const TCollection_ExtendedString& aStorageFormat) :
80 myStorageFormat(aStorageFormat),
81 myData (new TDF_Data()),
83 myUndoTransaction ("UNDO"),
85 myIsNestedTransactionMode(0),
86 mySaveEmptyLabels(Standard_False)
88 myUndoTransaction.Initialize (myData);
89 TDocStd_Owner::SetDocument(myData,this);
91 #ifdef SRN_DELTA_COMPACT
98 //=======================================================================
101 //=======================================================================
103 Standard_Boolean TDocStd_Document::IsSaved() const
105 return CDM_Document::IsStored();
109 //=======================================================================
112 //=======================================================================
114 TCollection_ExtendedString TDocStd_Document::GetName () const
116 return CDM_Document::MetaData()->Name();
119 //=======================================================================
122 //=======================================================================
124 TCollection_ExtendedString TDocStd_Document::GetPath () const
126 return CDM_Document::MetaData()->Path();
130 //=======================================================================
133 //=======================================================================
135 void TDocStd_Document::SetData (const Handle(TDF_Data)& D)
138 myUndoTransaction.Initialize (myData);
141 //=======================================================================
144 //=======================================================================
146 Handle(TDF_Data) TDocStd_Document::GetData () const
151 //=======================================================================
154 //=======================================================================
156 TDF_Label TDocStd_Document::Main () const
158 return myData->Root().FindChild(1,Standard_True);
161 //=======================================================================
164 //=======================================================================
166 Standard_Boolean TDocStd_Document::IsEmpty() const
168 TDF_AttributeIterator It (Main());
172 //=======================================================================
175 //=======================================================================
177 Standard_Boolean TDocStd_Document::IsValid() const
179 return TDocStd_Modified::IsEmpty(Main());
182 //=======================================================================
183 //function : SetModified
185 //=======================================================================
187 void TDocStd_Document::SetModified (const TDF_Label& L)
189 TDocStd_Modified::Add(L);
192 //=======================================================================
193 //function : IsModified
195 //=======================================================================
196 //Standard_Boolean TDocStd_Document::IsModified (const TDF_Label& L) const
198 // return TDocStd_Modified::Contains(L);
201 //=======================================================================
202 //function : PurgeModified
204 //=======================================================================
206 void TDocStd_Document::PurgeModified()
208 TDocStd_Modified::Clear(Main());
211 //=======================================================================
212 //function : GetModified
214 //=======================================================================
216 const TDF_LabelMap& TDocStd_Document::GetModified() const
218 return TDocStd_Modified::Get(Main());
223 //=======================================================================
226 //=======================================================================
228 void TDocStd_Document::Update(const Handle(CDM_Document)& /*aToDocument*/,
229 const Standard_Integer aReferenceIdentifier,
230 const Standard_Address aModifContext)
232 const TDocStd_Context* CC = static_cast<TDocStd_Context*> (aModifContext);
233 if (CC->ModifiedReferences() || !IsUpToDate(aReferenceIdentifier)) {
234 TCollection_AsciiString aDocEntry(aReferenceIdentifier);
235 UpdateReferences(aDocEntry);
236 SetIsUpToDate(aReferenceIdentifier);
240 //=======================================================================
241 //function : NewCommand
243 //=======================================================================
245 void TDocStd_Document::NewCommand()
247 #ifdef OCCT_DEBUG_TRANS
248 if (myUndoTransaction.IsOpen() && myData->Transaction() > 1) {
249 throw Standard_DomainError("NewCommand : many open transactions");
256 #ifdef OCCT_DEBUG_TRANS
257 std::cout<<"End NewCommand"<<std::endl;
262 //=======================================================================
263 //function : HasOpenCommand
265 //=======================================================================
266 Standard_Boolean TDocStd_Document::HasOpenCommand() const
268 return myUndoTransaction.IsOpen();
271 //=======================================================================
272 //function : OpenCommand
274 //=======================================================================
276 void TDocStd_Document::OpenCommand ()
278 if (!myIsNestedTransactionMode && myUndoTransaction.IsOpen()) {
279 throw Standard_DomainError("TDocStd_Document::OpenCommand : already open");
282 // if (myUndoLimit != 0) myUndoTransaction.Open();
285 //=======================================================================
286 //function : CommitCommand
288 //=======================================================================
290 Standard_Boolean TDocStd_Document::CommitCommand ()
292 return CommitTransaction();
296 //=======================================================================
297 //function : AbortCommand
299 //=======================================================================
301 void TDocStd_Document::AbortCommand ()
307 //=======================================================================
308 //function : CommitTransaction
309 //purpose : Private method.
310 //=======================================================================
312 Standard_Boolean TDocStd_Document::CommitTransaction()
314 myData->AllowModification(Standard_True);
316 Standard_Boolean isDone = Standard_False;
317 // nested transaction mode
318 if (myIsNestedTransactionMode && myUndoTransaction.IsOpen()) {
320 Handle(TDF_Delta) D = myUndoTransaction.Commit(Standard_True);
321 Handle(TDocStd_CompoundDelta) aCompDelta =
322 Handle(TDocStd_CompoundDelta)::DownCast(myUndoFILO.First());
323 AppendDeltaToTheFirst(aCompDelta, D);
325 myUndoFILO.RemoveFirst();
326 if(myUndoFILO.Extent()) {
327 aCompDelta = Handle(TDocStd_CompoundDelta)::DownCast(myUndoFILO.First());
328 AppendDeltaToTheFirst(aCompDelta, D);
329 myUndoTransaction.Open();
334 myRedos.Clear(); // if we push an Undo we clear the redos
335 isDone = Standard_True;
339 // deny modifications if the transaction is not opened
340 if(myOnlyTransactionModification) {
341 myData->AllowModification(myUndoTransaction.IsOpen() && myUndoLimit
342 ? Standard_True :Standard_False);
348 if (myUndoLimit != 0 && myUndoTransaction.IsOpen()) {
350 Handle(TDF_Delta) D = myUndoTransaction.Commit(Standard_True);
351 if (!(D.IsNull() || D->IsEmpty())) {
352 isDone = Standard_True;
354 myRedos.Clear(); // if we push an Undo we clear the redos
355 myUndos.Append(D); // New undos are at the end of the list
356 // Check the limit to remove the oldest one
357 if (myUndos.Extent() > myUndoLimit) {
358 #ifdef SRN_DELTA_COMPACT
359 Handle(TDF_Delta) aDelta = myUndos.First();
361 myUndos.RemoveFirst();
362 #ifdef SRN_DELTA_COMPACT
363 if(myFromUndo == aDelta) {
364 //The oldest Undo delta coincides with `from` delta
365 if(myUndos.Extent() == 1) { //There is the only Undo
366 myFromUndo.Nullify();
367 myFromRedo.Nullify();
370 myFromUndo = myUndos.First();
378 // deny or allow modifications acording to transaction state
379 if(myOnlyTransactionModification) {
380 myData->AllowModification (myUndoTransaction.IsOpen() && myUndoLimit
381 ? Standard_True :Standard_False);
384 // Notify CDM_Application of the successful commit
385 if (isDone && IsOpened()) {
386 const Handle(TDocStd_Application) anAppli =
387 Handle(TDocStd_Application)::DownCast(Application());
388 if (!anAppli.IsNull())
389 anAppli -> OnCommitTransaction (this);
395 //=======================================================================
396 //function : AbortTransaction
397 //purpose : Private method.
398 //=======================================================================
400 void TDocStd_Document::AbortTransaction()
402 myData->AllowModification(Standard_True);
404 if (myUndoTransaction.IsOpen())
405 if (myUndoLimit != 0)
406 myUndoTransaction.Abort();
408 if (myIsNestedTransactionMode && myUndoFILO.Extent()) {
409 if (!myUndoFILO.First()->IsEmpty())
410 myData->Undo(myUndoFILO.First(),Standard_True);
411 myUndoFILO.RemoveFirst();
412 if (myUndoFILO.Extent())
413 myUndoTransaction.Open();
415 // deny or allow modifications acording to transaction state
416 if (myOnlyTransactionModification) {
417 myData->AllowModification (myUndoTransaction.IsOpen() && myUndoLimit
418 ? Standard_True :Standard_False);
420 // Notify CDM_Application of the event
422 const Handle(TDocStd_Application) anAppli =
423 Handle(TDocStd_Application)::DownCast(Application());
424 if (!anAppli.IsNull())
425 anAppli -> OnAbortTransaction (this);
430 //=======================================================================
431 //function :OpenTransaction
432 //purpose : Private method.
433 //=======================================================================
435 void TDocStd_Document::OpenTransaction()
437 myData->AllowModification(Standard_True);
439 // nested transaction mode
440 if (myIsNestedTransactionMode) {
442 if (myUndoTransaction.IsOpen()) {
443 Handle(TDF_Delta) D = myUndoTransaction.Commit(Standard_True);
444 Handle(TDocStd_CompoundDelta) aCompDelta =
445 Handle(TDocStd_CompoundDelta)::DownCast(myUndoFILO.First());
446 AppendDeltaToTheFirst(aCompDelta, D);
448 Standard_Integer aLastTime = myData->Time();
449 if (myUndoFILO.Extent())
450 aLastTime = myUndoFILO.First()->EndTime();
451 Handle(TDocStd_CompoundDelta) aCompoundDelta =
452 new TDocStd_CompoundDelta;
453 aCompoundDelta->Validity(aLastTime, aLastTime);
454 myUndoFILO.Prepend(aCompoundDelta);
457 if (myUndoLimit != 0) myUndoTransaction.Open();
459 // deny or allow modifications acording to transaction state
460 if (myOnlyTransactionModification) {
461 myData->AllowModification (myUndoTransaction.IsOpen() && myUndoLimit
462 ? Standard_True :Standard_False);
464 // Notify CDM_Application of the event
466 const Handle(TDocStd_Application) anAppli =
467 Handle(TDocStd_Application)::DownCast(Application());
468 if (!anAppli.IsNull())
469 anAppli -> OnOpenTransaction (this);
473 //=======================================================================
474 //function : SetUndoLimit
476 //=======================================================================
478 void TDocStd_Document::SetUndoLimit(const Standard_Integer L)
480 #ifdef SRN_DELTA_COMPACT
481 myFromUndo.Nullify(); //Compaction has to aborted
482 myFromRedo.Nullify();
485 CommitTransaction ();
486 myUndoLimit = (L > 0) ? L : 0;
487 Standard_Integer n = myUndos.Extent() - myUndoLimit;
489 myUndos.RemoveFirst();
492 // deny or allow modifications acording to transaction state
493 if(myOnlyTransactionModification) {
494 myData->AllowModification(myUndoTransaction.IsOpen() && myUndoLimit
495 ? Standard_True :Standard_False);
497 //OpenTransaction(); dp 15/10/99
500 //=======================================================================
501 //function : GetUndoLimit
503 //=======================================================================
505 Standard_Integer TDocStd_Document::GetUndoLimit() const
510 //=======================================================================
513 //=======================================================================
515 Standard_Integer TDocStd_Document::GetAvailableUndos() const
517 return myUndos.Extent();
520 //=======================================================================
521 //function : ClearUndos
523 //=======================================================================
525 void TDocStd_Document::ClearUndos()
529 #ifdef SRN_DELTA_COMPACT
530 myFromRedo.Nullify();
531 myFromUndo.Nullify();
535 //=======================================================================
536 //function : ClearRedos
538 //=======================================================================
540 void TDocStd_Document::ClearRedos()
543 #ifdef SRN_DELTA_COMPACT
544 myFromRedo.Nullify();
548 //=======================================================================
551 // Some importante notice:
552 // 1) The most recent undo delta is at the end of the list.
553 // 2) Removing the LAST item of a list is tedious, but it is done only on
554 // Undo. Remove first is done at each command if the limit is reached!
555 // 3) To make fun, the redos are not like the undos: the most recent delta
556 // is at the beginning! Like this, it is easier to remove it after use.
557 //=======================================================================
558 Standard_Boolean TDocStd_Document::Undo()
560 // Don't call NewCommand(), because it may commit Interactive Attributes
561 // and generate a undesirable Delta!
563 Standard_Boolean isOpened = myUndoTransaction.IsOpen();
564 Standard_Boolean undoDone = Standard_False;
565 //TDF_Label currentObjectLabel = CurrentLabel (); //Sauve pour usage ulterieur.
567 if (!myUndos.IsEmpty()) {
568 // Reset the transaction
571 // only for nested transaction mode
572 while(myIsNestedTransactionMode && myUndoFILO.Extent())
575 // allow modifications
576 myData->AllowModification(Standard_True);
579 // should test the applicability before.
580 #ifdef OCCT_DEBUG_DELTA
581 std::cout<<"DF before Undo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
583 Handle(TDF_Delta) D = myData->Undo(myUndos.Last(),Standard_True);
584 D->SetName(myUndos.Last()->Name());
585 #ifdef OCCT_DEBUG_DELTA
586 std::cout<<"DF after Undo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
590 // Remove the last Undo
591 TDocStd_List_RemoveLast(myUndos);
592 undoDone = Standard_True;
595 if (isOpened && undoDone) OpenTransaction();
597 // deny or allow modifications acording to transaction state
598 if(myOnlyTransactionModification) {
599 myData->AllowModification(myUndoTransaction.IsOpen() && myUndoLimit
600 ? Standard_True :Standard_False);
606 //=======================================================================
607 //function : GetAvailableRedos
609 //=======================================================================
611 Standard_Integer TDocStd_Document:: GetAvailableRedos() const
613 // should test the applicability before.
614 return myRedos.Extent();
617 //=======================================================================
620 //=======================================================================
621 Standard_Boolean TDocStd_Document::Redo()
623 Standard_Boolean isOpened = myUndoTransaction.IsOpen();
624 Standard_Boolean undoDone = Standard_False;
625 // TDF_Label currentObjectLabel = CurrentLabel();//Sauve pour usage ulterieur.
626 if (!myRedos.IsEmpty()) {
627 // should test the applicability before.
628 // Reset the transaction
631 // only for nested transaction mode
632 while(myIsNestedTransactionMode && myUndoFILO.Extent())
635 // allow modifications
636 myData->AllowModification(Standard_True);
639 #ifdef OCCT_DEBUG_DELTA
640 std::cout<<"DF before Redo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
642 Handle(TDF_Delta) D = myData->Undo(myRedos.First(),Standard_True);
643 D->SetName(myRedos.First()->Name());
644 #ifdef OCCT_DEBUG_DELTA
645 std::cout<<"DF after Redo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
647 // Push the redo of the redo as an undo (got it !)
649 // remove the Redo from the head
650 myRedos.RemoveFirst();
651 undoDone = Standard_True;
654 if (isOpened && undoDone) OpenTransaction();
656 // deny or allow modifications acording to transaction state
657 if(myOnlyTransactionModification) {
658 myData->AllowModification(myUndoTransaction.IsOpen() && myUndoLimit
659 ? Standard_True :Standard_False);
665 //=======================================================================
666 //function : UpdateReferences
668 //=======================================================================
670 void TDocStd_Document::UpdateReferences(const TCollection_AsciiString& aDocEntry)
673 TDF_AttributeList aRefList;
674 TDocStd_XLink* xRefPtr;
675 for (TDocStd_XLinkIterator xItr (this); xItr.More(); xItr.Next()) {
676 xRefPtr = xItr.Value();
677 if (xRefPtr->DocumentEntry() == aDocEntry) {
678 aRefList.Append(xRefPtr->Update());
681 TDF_ListIteratorOfAttributeList It(aRefList);
682 for (;It.More();It.Next()) {
683 // // mise a jour import
684 SetModified(It.Value()->Label());
689 //=======================================================================
690 //function : GetUndos
692 //=======================================================================
694 const TDF_DeltaList& TDocStd_Document::GetUndos() const
700 //=======================================================================
701 //function : GetRedos
703 //=======================================================================
705 const TDF_DeltaList& TDocStd_Document::GetRedos() const
710 //=======================================================================
711 //function : InitDeltaCompaction
713 //=======================================================================
715 Standard_Boolean TDocStd_Document::InitDeltaCompaction()
717 #ifdef SRN_DELTA_COMPACT
718 if (myUndoLimit == 0 || myUndos.Extent() == 0) {
719 myFromRedo.Nullify();
720 myFromUndo.Nullify();
721 return Standard_False; //No Undos to compact
724 myFromRedo.Nullify();
726 myFromUndo = myUndos.Last();
727 if(myRedos.Extent() > 0) myFromRedo = myRedos.First();
729 return Standard_True;
732 //=======================================================================
733 //function : PerformDeltaCompaction
735 //=======================================================================
737 Standard_Boolean TDocStd_Document::PerformDeltaCompaction()
739 #ifdef SRN_DELTA_COMPACT
740 if(myFromUndo.IsNull()) return Standard_False; //Redo can be Null for this operation
743 Handle(TDocStd_CompoundDelta) aCompoundDelta = new TDocStd_CompoundDelta;
744 TDF_ListIteratorOfDeltaList anIterator(myUndos);
745 TDF_ListIteratorOfAttributeDeltaList aDeltasIterator;
746 TDocStd_LabelIDMapDataMap aMap;
747 Standard_Boolean isFound = Standard_False, isTimeSet = Standard_False;
751 for(; anIterator.More(); anIterator.Next()) {
753 if(myFromUndo == anIterator.Value()) isFound = Standard_True;
754 aList.Append(anIterator.Value()); //Fill the list of deltas that precede compound delta
758 if(!isTimeSet) { //Set begin and end time when the compound delta is valid
759 aCompoundDelta->Validity(anIterator.Value()->BeginTime(), myUndos.Last()->EndTime());
760 isTimeSet = Standard_True;
763 aDeltasIterator.Initialize(anIterator.Value()->AttributeDeltas());
764 for(; aDeltasIterator.More(); aDeltasIterator.Next()) {
765 if(!aMap.IsBound(aDeltasIterator.Value()->Label())) {
766 TDF_IDMap* pIDMap = new TDF_IDMap();
767 aMap.Bind(aDeltasIterator.Value()->Label(), *pIDMap);
770 if(aMap(aDeltasIterator.Value()->Label()).Add(aDeltasIterator.Value()->ID())) //The attribute is not
771 aCompoundDelta->AddAttributeDelta(aDeltasIterator.Value()); //already in the delta
776 myUndos.Assign(aList);
777 myUndos.Append(aCompoundDelta);
781 if(myFromRedo.IsNull()) {
783 return Standard_True;
788 for(anIterator.Initialize(myRedos); anIterator.More(); anIterator.Next()) {
789 aList.Append(anIterator.Value());
790 if(anIterator.Value() == myFromRedo) break;
794 myRedos.Assign(aList);
796 return Standard_True;
800 //=======================================================================
801 //function : StorageFormat
803 //=======================================================================
805 TCollection_ExtendedString TDocStd_Document::StorageFormat() const
807 return myStorageFormat;
811 //=======================================================================
812 //function : ChangeStorageFormat
814 //=======================================================================
816 void TDocStd_Document::ChangeStorageFormat (const TCollection_ExtendedString& newStorageFormat)
818 if (newStorageFormat != myStorageFormat) {
819 myStorageFormat = newStorageFormat;
820 myResourcesAreLoaded = Standard_False;
821 CDM_Document::LoadResources ();
828 //=======================================================================
829 //function : Recompute
831 //=======================================================================
833 void TDocStd_Document::Recompute ()
835 if (IsValid()) return;
836 // find the top function and execute it
837 // Handle(TDesign_Function) F;
838 // if (Main().FindAttribute(TDesign_Function::GetID(),F)) {
839 // TFunction_Solver slv;
840 // slv.SetTouched(GetModified());
841 // slv.ExecuteFrom(F);
845 //=======================================================================
846 //function : AppendDeltaToTheFirst
847 //purpose : Appends delta to the first delta in the myUndoFILO
848 //=======================================================================
850 void TDocStd_Document::AppendDeltaToTheFirst
851 (const Handle(TDocStd_CompoundDelta)& theDelta1,
852 const Handle(TDF_Delta)& theDelta2)
854 if(theDelta2->IsEmpty()) return;
855 TDocStd_LabelIDMapDataMap aMap;
857 TDF_ListIteratorOfAttributeDeltaList aDeltasIterator1
858 (theDelta1->AttributeDeltas());
859 for(; aDeltasIterator1.More(); aDeltasIterator1.Next()) {
860 TDF_Label aLabel = aDeltasIterator1.Value()->Label();
861 if(!aMap.IsBound(aLabel)) {
863 aMap.Bind(aLabel, aTmpIDMap);
865 Standard_GUID anID = aDeltasIterator1.Value()->ID();
866 TDF_IDMap& anIDMap = aMap.ChangeFind(aLabel);
870 theDelta1->Validity(theDelta1->BeginTime(), theDelta2->EndTime());
871 TDF_ListIteratorOfAttributeDeltaList aDeltasIterator2
872 (theDelta2->AttributeDeltas());
873 for(; aDeltasIterator2.More(); aDeltasIterator2.Next()) {
874 TDF_Label aLabel = aDeltasIterator2.Value()->Label();
875 Standard_GUID anID = aDeltasIterator2.Value()->ID();
876 if(aMap.IsBound(aLabel)) {
877 const TDF_IDMap& anIDMap = aMap.Find(aLabel);
878 if(anIDMap.Contains(anID)) continue;
880 theDelta1->AddAttributeDelta(aDeltasIterator2.Value());
884 //=======================================================================
885 //function : RemoveFirstUndo
887 //=======================================================================
888 void TDocStd_Document::RemoveFirstUndo() {
889 if (myUndos.IsEmpty()) return;
890 myUndos.RemoveFirst();
893 //=======================================================================
894 //function : BeforeClose
896 //=======================================================================
897 void TDocStd_Document::BeforeClose()
899 SetModificationMode(Standard_False);
901 if(myIsNestedTransactionMode)
906 //=======================================================================
907 //function : DumpJson
909 //=======================================================================
910 void TDocStd_Document::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
912 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
914 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, CDM_Document)
916 OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myStorageFormat)
918 for (TDF_DeltaList::Iterator anUndoIt (myUndos); anUndoIt.More(); anUndoIt.Next())
920 const Handle(TDF_Delta)& anUndo = anUndoIt.Value();
921 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anUndo.get())
924 for (TDF_DeltaList::Iterator aRedoIt (myRedos); aRedoIt.More(); aRedoIt.Next())
926 const Handle(TDF_Delta)& aRedo = aRedoIt.Value();
927 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aRedo.get())
930 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myData.get())
931 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUndoLimit)
932 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUndoTransaction)
933 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFromUndo.get())
934 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFromRedo.get())
935 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySaveTime)
936 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsNestedTransactionMode)
938 for (TDF_DeltaList::Iterator anUndoFILOIt (myUndoFILO); anUndoFILOIt.More(); anUndoFILOIt.Next())
940 const Handle(TDF_Delta)& anUndoFILO = anUndoFILOIt.Value();
941 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anUndoFILO.get())
944 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOnlyTransactionModification)
945 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySaveEmptyLabels)