From acd10a61cd461b61c671a1b8529da8374b28245c Mon Sep 17 00:00:00 2001 From: stv Date: Fri, 5 Jun 2015 14:33:05 +0300 Subject: [PATCH] Added overloaded methods SaveAs() with 3rd parameter status message string. --- src/TDocStd/TDocStd_Application.cdl | 37 ++++--- src/TDocStd/TDocStd_Application.cxx | 160 +++++++++++++--------------- 2 files changed, 97 insertions(+), 100 deletions(-) diff --git a/src/TDocStd/TDocStd_Application.cdl b/src/TDocStd/TDocStd_Application.cdl index 8993c82922..1d63b54789 100644 --- a/src/TDocStd/TDocStd_Application.cdl +++ b/src/TDocStd/TDocStd_Application.cdl @@ -215,16 +215,37 @@ is -- path ; overwrites the file if it already exists. returns StoreStatus from PCDM; + SaveAs (me : mutable; theDoc : Document from TDocStd; + thePath: ExtendedString from TCollection; + theStatusMessage: out ExtendedString from TCollection) + ---Purpose: Save the active document in the + -- path ; overwrites the file if it already exists. + returns StoreStatus from PCDM; + + SaveAs (me : mutable; theDoc : Document from TDocStd; + theOStream: in out OStream from Standard) + ---Purpose: Save the active document in the stream ; + returns StoreStatus from PCDM; + + SaveAs (me : mutable; theDoc : Document from TDocStd; + theOStream: in out OStream from Standard; + theStatusMessage: out ExtendedString from TCollection) + ---Purpose: Save the active document in the stream ; + returns StoreStatus from PCDM; + SaveAs (me : mutable; theDoc : Document from TDocStd; theDevice: IODevice from Storage) ---Purpose: Save the active document in the device ; -- overwrites the file if it already exists. returns StoreStatus from PCDM is protected; - SaveAs (me : mutable; theDoc : Document from TDocStd; - theOStream: in out OStream from Standard) - ---Purpose: Save the active document in the stream ; - returns StoreStatus from PCDM; + SaveAs (me : mutable; aDoc : Document from TDocStd; + aDev : IODevice from Storage; + theStatusMessage: out ExtendedString from TCollection) + ---Purpose: Save the active document in the file in the + -- path . overwrite the file if it + -- already exist. + returns StoreStatus from PCDM is protected; Save (me : mutable; aDoc : Document from TDocStd) ---Purpose: Save aDoc active document. @@ -233,14 +254,6 @@ is -- was not retrieved in the applicative session by using Open. returns StoreStatus from PCDM; - SaveAs (me : mutable; aDoc : Document from TDocStd; - aDev : IODevice from Storage; - theStatusMessage: out ExtendedString from TCollection) - ---Purpose: Save the active document in the file in the - -- path . overwrite the file if it - -- already exist. - returns StoreStatus from PCDM; - Save (me : mutable; aDoc : Document from TDocStd; theStatusMessage: out ExtendedString from TCollection) ---Purpose: Save the document overwriting the previous file diff --git a/src/TDocStd/TDocStd_Application.cxx b/src/TDocStd/TDocStd_Application.cxx index 588ee15a28..c05e613ffe 100644 --- a/src/TDocStd/TDocStd_Application.cxx +++ b/src/TDocStd/TDocStd_Application.cxx @@ -259,8 +259,8 @@ PCDM_ReaderStatus TDocStd_Application::Open( Standard_IStream& theIStream, PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& theDoc, const TCollection_ExtendedString& thePath) { - Handle(Storage_File) aDevice = new Storage_File(thePath); - return SaveAs (theDoc, aDevice); + Handle(Storage_File) aDevice = new Storage_File( thePath ); + return SaveAs( theDoc, aDevice ); } //======================================================================= @@ -268,57 +268,85 @@ PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& the //purpose : //======================================================================= -PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D, - const Handle(Storage_IODevice)& aDevice) - { - /* - TDocStd_PathParser tool (path); - TCollection_ExtendedString directory = tool.Trek(); - TCollection_ExtendedString file = tool.Name(); - file+="."; - file+=tool.Extension(); - */ - D->Open(this); - CDF_Store storer (D); - if (!storer.SetDevice(aDevice)) - { - TCollection_ExtendedString aMsg ("TDocStd_Application::SaveAs() - device "); - aMsg += " not valid"; - if(!MessageDriver().IsNull()) - MessageDriver()->Write(aMsg.ToExtString()); - return storer.StoreStatus(); //CDF_SS_Failure; - } - // storer.SetName (file); - try { - OCC_CATCH_SIGNALS - storer.Realize(); - } - catch (Standard_Failure) { - Handle(Standard_Failure) F = Standard_Failure::Caught(); - if (!F.IsNull() && !MessageDriver().IsNull()) { - TCollection_ExtendedString aString (F->GetMessageString()); - MessageDriver()->Write(aString.ToExtString()); - } - } - if(storer.StoreStatus() == PCDM_SS_OK) - D->SetSaved(); -#ifdef OCCT_DEBUG - cout<<"TDocStd_Application::SaveAs(): The status = "<Open(this); + CDF_Store storer (D); + if (storer.SetDevice(aDev)) { + try { + OCC_CATCH_SIGNALS + storer.Realize(); + } + catch (Standard_Failure) { + Handle(Standard_Failure) F = Standard_Failure::Caught(); + if (!F.IsNull() && !MessageDriver().IsNull()) { + TCollection_ExtendedString aString (F->GetMessageString()); + MessageDriver()->Write(aString.ToExtString()); + } + } + if(storer.StoreStatus() == PCDM_SS_OK) + D->SetSaved(); + theStatusMessage = storer.AssociatedStatusText(); + aStatus = storer.StoreStatus(); + } else { + theStatusMessage = + TCollection_ExtendedString("TDocStd_Application::SaveAs: No valid device "); + aStatus = PCDM_SS_Failure; + } + return aStatus; } //======================================================================= @@ -383,50 +411,6 @@ PCDM_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D) { // } -//======================================================================= -//function : SaveAs -//purpose : -//======================================================================= - -PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D, - const Handle(Storage_IODevice)& aDev, - TCollection_ExtendedString& theStatusMessage) -{ - PCDM_StoreStatus aStatus = PCDM_SS_Failure; - /* - TDocStd_PathParser tool (path); - TCollection_ExtendedString directory = tool.Trek(); - TCollection_ExtendedString file = tool.Name(); - file+="."; - file+=tool.Extension(); - */ - D->Open(this); - CDF_Store storer (D); - if (storer.SetDevice(aDev)) { - // storer.SetName (file); - try { - OCC_CATCH_SIGNALS - storer.Realize(); - } - catch (Standard_Failure) { - Handle(Standard_Failure) F = Standard_Failure::Caught(); - if (!F.IsNull() && !MessageDriver().IsNull()) { - TCollection_ExtendedString aString (F->GetMessageString()); - MessageDriver()->Write(aString.ToExtString()); - } - } - if(storer.StoreStatus() == PCDM_SS_OK) - D->SetSaved(); - theStatusMessage = storer.AssociatedStatusText(); - aStatus = storer.StoreStatus(); - } else { - theStatusMessage = - TCollection_ExtendedString("TDocStd_Application::SaveAs: No valid device "); - aStatus = PCDM_SS_Failure; - } - return aStatus; -} - //======================================================================= //function : Save //purpose : -- 2.39.5