From 396f188f303a9eae33a8f32ef2f5b98360672287 Mon Sep 17 00:00:00 2001 From: jriegel Date: Tue, 9 Sep 2014 17:09:26 +0200 Subject: [PATCH] Tip property in Document and special load save handling --- src/App/Document.cpp | 14 +++++++++++++- src/App/Document.h | 9 +++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 4bbd347b1..3f729d917 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -74,7 +74,6 @@ recompute path. Also enables more complicated dependencies beyond trees. #include "DocumentPy.h" #include "Application.h" #include "DocumentObject.h" -#include "PropertyLinks.h" #include "MergeDocuments.h" #include @@ -987,6 +986,10 @@ Document::Document(void) // this creates and sets 'TransientDir' in onChanged() ADD_PROPERTY_TYPE(TransientDir,(""),0,PropertyType(Prop_Transient|Prop_ReadOnly), "Transient directory, where the files live while the document is open"); + ADD_PROPERTY_TYPE(Tip,(0),0,PropertyType(Prop_Transient), + "Link of the tip object of the document"); + ADD_PROPERTY_TYPE(TipName,(""),0,PropertyType(Prop_Hidden|Prop_ReadOnly), + "Link of the tip object of the document"); Uid.touch(); } @@ -1134,6 +1137,10 @@ void Document::Restore(Base::XMLReader &reader) else if ( scheme >= 3 ) { // read the feature types readObjects(reader); + + // tip object handling. First the whole document has to be read, then we + // can restore the Tip link out of the TipName Property: + Tip.setValue(getObject(TipName.getValue())); } reader.readEndElement("Document"); @@ -1340,6 +1347,11 @@ bool Document::save (void) compression = Base::clamp(compression, Z_NO_COMPRESSION, Z_BEST_COMPRESSION); if (*(FileName.getValue()) != '\0') { + // Save the name of the tip object in order to handle in Restore() + if(Tip.getValue()) { + TipName.setValue(Tip.getValue()->getNameInDocument()); + } + std::string LastModifiedDateString = Base::TimeInfo::currentDateTimeString(); LastModifiedDate.setValue(LastModifiedDateString.c_str()); // set author if needed diff --git a/src/App/Document.h b/src/App/Document.h index 7d1b1d921..ef310e280 100644 --- a/src/App/Document.h +++ b/src/App/Document.h @@ -30,6 +30,7 @@ #include "PropertyContainer.h" #include "PropertyStandard.h" +#include "PropertyLinks.h" #include #include @@ -91,10 +92,14 @@ public: App::PropertyString LicenseURL; /// Meta descriptons App::PropertyMap Meta; - /// Meta descriptons + /// Material descriptons, used and defined in the Material module. App::PropertyMap Material; /// read-only name of the temp dir created wen the document is opened - PropertyString TransientDir; + PropertyString TransientDir; + /// Tip object of the document (if any) + PropertyLink Tip; + /// Tip object of the document (if any) + PropertyString TipName; //@} /** @name Signals of the document */