Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1999-06-30 |
2 | // Created by: Denis PASCAL | |
3 | // Copyright (c) 1999-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
7fd59977 | 17 | |
7fd59977 | 18 | #include <CDF_Directory.hxx> |
42cf5bc1 | 19 | #include <CDF_DirectoryIterator.hxx> |
20 | #include <CDF_Session.hxx> | |
21 | #include <CDF_Store.hxx> | |
6fe96f84 | 22 | #include <CDM_COutMessageDriver.hxx> |
23 | #include <PCDM_RetrievalDriver.hxx> | |
4ff92abe | 24 | #include <PCDM_StorageDriver.hxx> |
25 | #include <Plugin.hxx> | |
42cf5bc1 | 26 | #include <Plugin_Failure.hxx> |
27 | #include <Resource_Manager.hxx> | |
28 | #include <Standard_DomainError.hxx> | |
7fd59977 | 29 | #include <Standard_ErrorHandler.hxx> |
42cf5bc1 | 30 | #include <Standard_NoSuchObject.hxx> |
7fd59977 | 31 | #include <Standard_NotImplemented.hxx> |
42cf5bc1 | 32 | #include <Standard_Type.hxx> |
33 | #include <TCollection_ExtendedString.hxx> | |
7fd59977 | 34 | #include <TDF_Label.hxx> |
42cf5bc1 | 35 | #include <TDocStd_Application.hxx> |
36 | #include <TDocStd_Document.hxx> | |
37 | #include <TDocStd_Owner.hxx> | |
7fd59977 | 38 | #include <TDocStd_PathParser.hxx> |
39 | ||
92efcf78 | 40 | IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Application,CDF_Application) |
41 | ||
7fd59977 | 42 | // TDocStd_Owner attribute have pointer of closed TDocStd_Document |
7fd59977 | 43 | //======================================================================= |
44 | //function : TDocStd_Application | |
45 | //purpose : | |
46 | //======================================================================= | |
7fd59977 | 47 | TDocStd_Application::TDocStd_Application() |
48 | : myIsDriverLoaded (Standard_True) | |
49 | { | |
6fe96f84 | 50 | myMessageDriver = new CDM_COutMessageDriver; |
51 | ||
7fd59977 | 52 | Handle(CDF_Session) S; |
53 | if (!CDF_Session::Exists()) S = new CDF_Session(); | |
54 | else S = CDF_Session::CurrentSession(); | |
55 | S->SetCurrentApplication(this); | |
56 | try | |
57 | { | |
58 | OCC_CATCH_SIGNALS | |
59 | S->LoadDriver(); | |
60 | } | |
61 | catch (Plugin_Failure) | |
62 | { | |
63 | myIsDriverLoaded = Standard_False; | |
64 | } | |
65 | } | |
66 | ||
67 | ||
68 | //======================================================================= | |
69 | //function : IsDriverLoaded | |
70 | //purpose : | |
71 | //======================================================================= | |
72 | Standard_Boolean TDocStd_Application::IsDriverLoaded() const | |
73 | { | |
74 | return myIsDriverLoaded; | |
75 | } | |
76 | ||
6fe96f84 | 77 | //======================================================================= |
78 | //function : MessageDriver | |
79 | //purpose : | |
80 | //======================================================================= | |
81 | Handle(CDM_MessageDriver) TDocStd_Application::MessageDriver() | |
82 | { | |
83 | return myMessageDriver; | |
84 | } | |
85 | ||
7fd59977 | 86 | //======================================================================= |
87 | //function : Resources | |
88 | //purpose : | |
89 | //======================================================================= | |
90 | ||
91 | Handle(Resource_Manager) TDocStd_Application::Resources() { | |
92 | if (myResources.IsNull()) { | |
93 | myResources = new Resource_Manager(ResourcesName()); | |
94 | } | |
95 | return myResources; | |
96 | } | |
97 | ||
6fe96f84 | 98 | //======================================================================= |
99 | //function : ResourcesName | |
100 | //purpose : | |
101 | //======================================================================= | |
102 | ||
103 | Standard_CString TDocStd_Application::ResourcesName() | |
104 | { | |
105 | return ""; | |
106 | } | |
107 | ||
108 | //======================================================================= | |
109 | //function : DefineFormat | |
110 | //purpose : | |
111 | //======================================================================= | |
112 | void TDocStd_Application::DefineFormat (const TCollection_AsciiString& theFormat, | |
113 | const TCollection_AsciiString& theDescription, | |
114 | const TCollection_AsciiString& theExtension, | |
115 | const Handle(PCDM_RetrievalDriver)& theReader, | |
116 | const Handle(PCDM_StorageDriver)& theWriter) | |
117 | { | |
118 | // register resources for CDM mechanics to work | |
119 | Handle(Resource_Manager) aResources = Resources(); | |
120 | aResources->SetResource ((theFormat + ".Description" ).ToCString(), theDescription.ToCString()); | |
121 | aResources->SetResource ((theFormat + ".FileExtension").ToCString(), theExtension.ToCString()); | |
122 | aResources->SetResource ((theExtension + ".FileFormat").ToCString(), theFormat.ToCString()); | |
123 | ||
124 | // set format ID in the drivers to allow them putting it in | |
125 | // the OCAF documents opened by these drivers | |
126 | if (!theReader.IsNull()) | |
127 | theReader->SetFormat(theFormat); | |
128 | if (!theWriter.IsNull()) | |
129 | theWriter->SetFormat(theFormat); | |
130 | ||
131 | // register drivers | |
132 | myReaders.Bind (theFormat, theReader); | |
133 | myWriters.Bind (theFormat, theWriter); | |
134 | } | |
7fd59977 | 135 | |
136 | //======================================================================= | |
137 | //function : NbDocuments | |
138 | //purpose : | |
139 | //======================================================================= | |
140 | ||
141 | Standard_Integer TDocStd_Application::NbDocuments() const | |
142 | { | |
143 | if (!CDF_Session::Exists()) | |
144 | Standard_DomainError::Raise("TDocStd_Application::NbDocuments"); | |
145 | Handle(CDF_Session) S = CDF_Session::CurrentSession(); | |
146 | return S->Directory()->Length(); | |
147 | } | |
148 | ||
149 | //======================================================================= | |
150 | //function : GetDocument | |
151 | //purpose : | |
152 | //======================================================================= | |
153 | ||
154 | void TDocStd_Application::GetDocument(const Standard_Integer index,Handle(TDocStd_Document)& aDoc) const | |
155 | { | |
156 | if (!CDF_Session::Exists()) | |
157 | Standard_DomainError::Raise("TDocStd_Application::NbDocuments"); | |
158 | Handle(CDF_Session) S = CDF_Session::CurrentSession(); | |
159 | CDF_DirectoryIterator it (S->Directory()); | |
160 | Standard_Integer current = 0; | |
161 | for (;it.MoreDocument();it.NextDocument()) { | |
162 | current++; | |
163 | if (index == current) { | |
164 | Handle(TDocStd_Document) D = | |
165 | Handle(TDocStd_Document)::DownCast(it.Document()); | |
166 | aDoc = D; | |
167 | return; | |
168 | } | |
169 | } | |
170 | } | |
171 | ||
172 | //======================================================================= | |
173 | //function : NewDocument | |
174 | //purpose : | |
175 | //======================================================================= | |
176 | ||
177 | void TDocStd_Application::NewDocument(const TCollection_ExtendedString& format,Handle(TDocStd_Document)& aDoc) | |
178 | { | |
179 | Handle(TDocStd_Document) D = new TDocStd_Document(format); | |
180 | InitDocument (D); | |
181 | CDF_Application::Open(D); // add the document in the session | |
182 | aDoc = D; | |
183 | } | |
184 | ||
185 | //======================================================================= | |
186 | //function : InitDocument | |
187 | //purpose : do nothing | |
188 | //======================================================================= | |
189 | ||
190 | void TDocStd_Application::InitDocument(const Handle(TDocStd_Document)& /*aDoc*/) const | |
191 | { | |
192 | } | |
193 | ||
7fd59977 | 194 | //======================================================================= |
195 | //function : Close | |
196 | //purpose : | |
197 | //======================================================================= | |
198 | ||
199 | void TDocStd_Application::Close(const Handle(TDocStd_Document)& aDoc) | |
200 | { | |
b6c0b841 RL |
201 | if (aDoc.IsNull()) |
202 | { | |
203 | return; | |
204 | } | |
205 | ||
7fd59977 | 206 | Handle(TDocStd_Owner) Owner; |
207 | if (aDoc->Main().Root().FindAttribute(TDocStd_Owner::GetID(),Owner)) { | |
208 | Handle(TDocStd_Document) emptyDoc; | |
209 | Owner->SetDocument(emptyDoc); | |
210 | } | |
1c9cffdb | 211 | aDoc->BeforeClose(); |
7fd59977 | 212 | CDF_Application::Close(aDoc); |
213 | } | |
7fd59977 | 214 | |
215 | //======================================================================= | |
216 | //function : IsInSession | |
217 | //purpose : | |
218 | //======================================================================= | |
219 | ||
220 | Standard_Integer TDocStd_Application::IsInSession (const TCollection_ExtendedString& path) const | |
221 | { | |
bcb0fd43 V |
222 | TCollection_ExtendedString unifiedPath(path); |
223 | unifiedPath.ChangeAll('/', '|'); | |
224 | unifiedPath.ChangeAll('\\', '|'); | |
225 | ||
226 | Standard_Integer nbdoc = NbDocuments(); | |
227 | Handle(TDocStd_Document) D; | |
228 | for (Standard_Integer i = 1; i <= nbdoc; i++) | |
229 | { | |
230 | GetDocument(i,D); | |
231 | if (D->IsSaved()) | |
232 | { | |
233 | TCollection_ExtendedString unifiedDocPath(D->GetPath()); | |
234 | unifiedDocPath.ChangeAll('/', '|'); | |
235 | unifiedDocPath.ChangeAll('\\', '|'); | |
236 | ||
237 | if (unifiedPath == unifiedDocPath) | |
238 | return i; | |
239 | } | |
7fd59977 | 240 | } |
bcb0fd43 | 241 | return 0; |
7fd59977 | 242 | } |
243 | ||
244 | //======================================================================= | |
245 | //function : Open | |
246 | //purpose : | |
247 | //======================================================================= | |
248 | ||
15e8b082 M |
249 | PCDM_ReaderStatus TDocStd_Application::Open(const TCollection_ExtendedString& path,Handle(TDocStd_Document)& aDoc) { |
250 | PCDM_ReaderStatus status = PCDM_RS_DriverFailure; | |
7fd59977 | 251 | TDocStd_PathParser tool (path); |
252 | TCollection_ExtendedString directory = tool.Trek(); | |
253 | TCollection_ExtendedString file = tool.Name(); | |
254 | file+="."; | |
255 | file+=tool.Extension(); | |
7fd59977 | 256 | status = CanRetrieve(directory,file); |
15e8b082 | 257 | if (status != PCDM_RS_OK) return status; |
7fd59977 | 258 | try { |
259 | OCC_CATCH_SIGNALS | |
260 | Handle(TDocStd_Document) D = | |
261 | Handle(TDocStd_Document)::DownCast(Retrieve(directory,file)); | |
262 | CDF_Application::Open(D); | |
263 | aDoc = D; | |
264 | } | |
265 | catch (Standard_Failure) { | |
266 | // status = GetRetrieveStatus(); | |
267 | Handle(Standard_Failure) F = Standard_Failure::Caught(); | |
268 | if (!F.IsNull() && !MessageDriver().IsNull()) { | |
269 | // Standard_SStream aMsg; | |
270 | // aMsg << Standard_Failure::Caught() << endl; | |
271 | // cout << "TDocStd_Application::Open(): " << aMsg.rdbuf()->str() << endl; | |
272 | TCollection_ExtendedString aString (F->GetMessageString()); | |
273 | MessageDriver()->Write(aString.ToExtString()); | |
274 | } | |
275 | } | |
276 | status = GetRetrieveStatus(); | |
0797d9d3 | 277 | #ifdef OCCT_DEBUG |
7fd59977 | 278 | cout<<"TDocStd_Application::Open(): The status = "<<status<<endl; |
279 | #endif | |
280 | return status; | |
281 | } | |
282 | ||
4ff92abe | 283 | //======================================================================= |
284 | //function : Open | |
285 | //purpose : | |
286 | //======================================================================= | |
287 | PCDM_ReaderStatus TDocStd_Application::Open (Standard_IStream& theIStream, Handle(TDocStd_Document)& theDoc) | |
288 | { | |
289 | try | |
290 | { | |
291 | OCC_CATCH_SIGNALS | |
292 | ||
293 | Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast (Read (theIStream)); | |
294 | if (!D.IsNull()) | |
295 | { | |
296 | CDF_Application::Open(D); | |
297 | theDoc = D; | |
298 | } | |
299 | } | |
300 | catch (Standard_Failure) | |
301 | { | |
302 | Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); | |
303 | if (!aFailure.IsNull() && !MessageDriver().IsNull()) | |
304 | { | |
305 | TCollection_ExtendedString aFailureMessage (aFailure->GetMessageString()); | |
306 | MessageDriver()->Write (aFailureMessage.ToExtString()); | |
307 | } | |
308 | } | |
309 | ||
310 | return GetRetrieveStatus(); | |
311 | } | |
312 | ||
7fd59977 | 313 | //======================================================================= |
314 | //function : SaveAs | |
315 | //purpose : | |
316 | //======================================================================= | |
317 | ||
15e8b082 | 318 | PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D,const TCollection_ExtendedString& path) { |
7fd59977 | 319 | TDocStd_PathParser tool (path); |
320 | TCollection_ExtendedString directory = tool.Trek(); | |
321 | TCollection_ExtendedString file = tool.Name(); | |
322 | file+="."; | |
323 | file+=tool.Extension(); | |
324 | D->Open(this); | |
325 | CDF_Store storer (D); | |
7fd59977 | 326 | if (!storer.SetFolder(directory)) |
327 | { | |
328 | TCollection_ExtendedString aMsg ("TDocStd_Application::SaveAs() - folder "); | |
329 | aMsg += directory; | |
330 | aMsg += " does not exist"; | |
331 | if(!MessageDriver().IsNull()) | |
332 | MessageDriver()->Write(aMsg.ToExtString()); | |
333 | return storer.StoreStatus(); //CDF_SS_Failure; | |
334 | } | |
7fd59977 | 335 | storer.SetName (file); |
336 | try { | |
337 | OCC_CATCH_SIGNALS | |
338 | storer.Realize(); | |
339 | } | |
340 | catch (Standard_Failure) { | |
341 | Handle(Standard_Failure) F = Standard_Failure::Caught(); | |
342 | if (!F.IsNull() && !MessageDriver().IsNull()) { | |
343 | TCollection_ExtendedString aString (F->GetMessageString()); | |
344 | MessageDriver()->Write(aString.ToExtString()); | |
345 | } | |
346 | } | |
15e8b082 | 347 | if(storer.StoreStatus() == PCDM_SS_OK) |
7fd59977 | 348 | D->SetSaved(); |
0797d9d3 | 349 | #ifdef OCCT_DEBUG |
7fd59977 | 350 | cout<<"TDocStd_Application::SaveAs(): The status = "<<storer.StoreStatus()<<endl; |
351 | #endif | |
352 | return storer.StoreStatus(); | |
7fd59977 | 353 | } |
354 | ||
4ff92abe | 355 | //======================================================================= |
356 | //function : SaveAs | |
357 | //purpose : | |
358 | //======================================================================= | |
359 | PCDM_StoreStatus TDocStd_Application::SaveAs (const Handle(TDocStd_Document)& theDoc, Standard_OStream& theOStream) | |
360 | { | |
6fe96f84 | 361 | try |
4ff92abe | 362 | { |
6fe96f84 | 363 | Handle(PCDM_StorageDriver) aDocStorageDriver = WriterFromFormat(theDoc->StorageFormat()); |
4ff92abe | 364 | |
6fe96f84 | 365 | if (aDocStorageDriver.IsNull()) |
366 | { | |
367 | return PCDM_SS_DriverFailure; | |
368 | } | |
4ff92abe | 369 | |
6fe96f84 | 370 | aDocStorageDriver->SetFormat(theDoc->StorageFormat()); |
371 | aDocStorageDriver->Write(theDoc, theOStream); | |
4ff92abe | 372 | |
6fe96f84 | 373 | if (aDocStorageDriver->GetStoreStatus() == PCDM_SS_OK) |
4ff92abe | 374 | { |
6fe96f84 | 375 | theDoc->SetSaved(); |
4ff92abe | 376 | } |
6fe96f84 | 377 | |
378 | return aDocStorageDriver->GetStoreStatus(); | |
4ff92abe | 379 | } |
6fe96f84 | 380 | catch (Standard_Failure) |
4ff92abe | 381 | { |
6fe96f84 | 382 | Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); |
383 | if (!aFailure.IsNull() && !MessageDriver().IsNull()) | |
384 | { | |
385 | TCollection_ExtendedString aString(aFailure->GetMessageString()); | |
386 | MessageDriver()->Write(aString.ToExtString()); | |
387 | } | |
4ff92abe | 388 | } |
6fe96f84 | 389 | return PCDM_SS_Failure; |
4ff92abe | 390 | } |
391 | ||
7fd59977 | 392 | //======================================================================= |
393 | //function : Save | |
394 | //purpose : | |
395 | //======================================================================= | |
396 | ||
15e8b082 | 397 | PCDM_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D) { |
15e8b082 | 398 | PCDM_StoreStatus status = PCDM_SS_OK; |
7fd59977 | 399 | if (D->IsSaved()) { |
400 | CDF_Store storer (D); | |
401 | try{ | |
402 | OCC_CATCH_SIGNALS | |
403 | storer.Realize(); | |
404 | } | |
405 | catch (Standard_Failure) { | |
406 | Handle(Standard_Failure) F = Standard_Failure::Caught(); | |
407 | if (!F.IsNull() && !MessageDriver().IsNull()) { | |
408 | TCollection_ExtendedString aString (F->GetMessageString()); | |
409 | MessageDriver()->Write(aString.ToExtString()); | |
410 | } | |
411 | } | |
15e8b082 | 412 | if(storer.StoreStatus() == PCDM_SS_OK) |
7fd59977 | 413 | D->SetSaved(); |
7fd59977 | 414 | status = storer.StoreStatus(); |
7fd59977 | 415 | } else { |
7fd59977 | 416 | if(!MessageDriver().IsNull()) { |
15e8b082 | 417 | TCollection_ExtendedString aMsg("Document has not been saved yet"); |
7fd59977 | 418 | MessageDriver()->Write(aMsg.ToExtString()); |
419 | } | |
15e8b082 | 420 | status = PCDM_SS_Failure; |
7fd59977 | 421 | } |
0797d9d3 | 422 | #ifdef OCCT_DEBUG |
7fd59977 | 423 | cout<<"TDocStd_Application::Save(): The status = "<<status<<endl; |
424 | #endif | |
425 | return status; | |
7fd59977 | 426 | } |
427 | ||
7fd59977 | 428 | //======================================================================= |
429 | //function : SaveAs | |
430 | //purpose : | |
431 | //======================================================================= | |
432 | ||
15e8b082 | 433 | PCDM_StoreStatus TDocStd_Application::SaveAs(const Handle(TDocStd_Document)& D, |
7fd59977 | 434 | const TCollection_ExtendedString& path, |
435 | TCollection_ExtendedString& theStatusMessage) | |
436 | { | |
437 | TDocStd_PathParser tool (path); | |
15e8b082 | 438 | PCDM_StoreStatus aStatus = PCDM_SS_Failure; |
7fd59977 | 439 | TCollection_ExtendedString directory = tool.Trek(); |
440 | TCollection_ExtendedString file = tool.Name(); | |
441 | file+="."; | |
442 | file+=tool.Extension(); | |
443 | D->Open(this); | |
444 | CDF_Store storer (D); | |
445 | if (storer.SetFolder(directory)) { | |
446 | storer.SetName (file); | |
447 | try { | |
448 | OCC_CATCH_SIGNALS | |
449 | storer.Realize(); | |
450 | } | |
451 | catch (Standard_Failure) { | |
452 | Handle(Standard_Failure) F = Standard_Failure::Caught(); | |
453 | if (!F.IsNull() && !MessageDriver().IsNull()) { | |
454 | TCollection_ExtendedString aString (F->GetMessageString()); | |
455 | MessageDriver()->Write(aString.ToExtString()); | |
456 | } | |
457 | } | |
15e8b082 | 458 | if(storer.StoreStatus() == PCDM_SS_OK) |
7fd59977 | 459 | D->SetSaved(); |
460 | theStatusMessage = storer.AssociatedStatusText(); | |
461 | aStatus = storer.StoreStatus(); | |
462 | } else { | |
463 | theStatusMessage = | |
464 | TCollection_ExtendedString("TDocStd_Application::SaveAs" | |
465 | ": No such directory ") + directory; | |
15e8b082 | 466 | aStatus = PCDM_SS_Failure; |
7fd59977 | 467 | } |
468 | return aStatus; | |
469 | } | |
470 | ||
4ff92abe | 471 | //======================================================================= |
472 | //function : SaveAs | |
473 | //purpose : | |
474 | //======================================================================= | |
475 | ||
476 | PCDM_StoreStatus TDocStd_Application::SaveAs (const Handle(TDocStd_Document)& theDoc, | |
477 | Standard_OStream& theOStream, | |
478 | TCollection_ExtendedString& theStatusMessage) | |
479 | { | |
6fe96f84 | 480 | try |
4ff92abe | 481 | { |
6fe96f84 | 482 | Handle(PCDM_StorageDriver) aDocStorageDriver = WriterFromFormat (theDoc->StorageFormat()); |
483 | if (aDocStorageDriver.IsNull()) | |
4ff92abe | 484 | { |
6fe96f84 | 485 | theStatusMessage = TCollection_ExtendedString("TDocStd_Application::SaveAs: no storage driver"); |
486 | return PCDM_SS_DriverFailure; | |
487 | } | |
4ff92abe | 488 | |
6fe96f84 | 489 | aDocStorageDriver->SetFormat(theDoc->StorageFormat()); |
490 | aDocStorageDriver->Write(theDoc, theOStream); | |
4ff92abe | 491 | |
6fe96f84 | 492 | if (aDocStorageDriver->GetStoreStatus() == PCDM_SS_OK) |
4ff92abe | 493 | { |
6fe96f84 | 494 | theDoc->SetSaved(); |
4ff92abe | 495 | } |
6fe96f84 | 496 | |
497 | return aDocStorageDriver->GetStoreStatus(); | |
4ff92abe | 498 | } |
6fe96f84 | 499 | catch (Standard_Failure) |
4ff92abe | 500 | { |
6fe96f84 | 501 | Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); |
502 | if (!aFailure.IsNull() && !MessageDriver().IsNull()) | |
503 | { | |
504 | TCollection_ExtendedString aString(aFailure->GetMessageString()); | |
505 | MessageDriver()->Write(aString.ToExtString()); | |
506 | } | |
4ff92abe | 507 | } |
6fe96f84 | 508 | return PCDM_SS_Failure; |
4ff92abe | 509 | } |
510 | ||
7fd59977 | 511 | //======================================================================= |
512 | //function : Save | |
513 | //purpose : | |
514 | //======================================================================= | |
515 | ||
15e8b082 | 516 | PCDM_StoreStatus TDocStd_Application::Save (const Handle(TDocStd_Document)& D, |
7fd59977 | 517 | TCollection_ExtendedString& theStatusMessage) |
518 | { | |
15e8b082 | 519 | PCDM_StoreStatus status = PCDM_SS_OK; |
7fd59977 | 520 | if (D->IsSaved()) { |
521 | CDF_Store storer (D); | |
522 | try { | |
523 | OCC_CATCH_SIGNALS | |
524 | storer.Realize(); | |
525 | } | |
526 | catch (Standard_Failure) { | |
527 | Handle(Standard_Failure) F = Standard_Failure::Caught(); | |
528 | if (!F.IsNull() && !MessageDriver().IsNull()) { | |
529 | TCollection_ExtendedString aString (F->GetMessageString()); | |
530 | MessageDriver()->Write(aString.ToExtString()); | |
531 | } | |
532 | } | |
15e8b082 | 533 | if(storer.StoreStatus() == PCDM_SS_OK) |
7fd59977 | 534 | D->SetSaved(); |
535 | status = storer.StoreStatus(); | |
536 | theStatusMessage = storer.AssociatedStatusText(); | |
537 | } else { | |
15e8b082 M |
538 | theStatusMessage = "TDocStd_Application::the document has not been saved yet"; |
539 | status = PCDM_SS_Failure; | |
7fd59977 | 540 | } |
541 | return status; | |
542 | } | |
543 | ||
544 | ||
545 | //======================================================================= | |
546 | //function : OnOpenTransaction | |
547 | //purpose : | |
548 | //======================================================================= | |
549 | ||
550 | void TDocStd_Application::OnOpenTransaction (const Handle(TDocStd_Document)&) | |
551 | { | |
552 | // nothing to do on this level | |
553 | } | |
554 | ||
555 | //======================================================================= | |
556 | //function : OnAbortTransaction | |
557 | //purpose : | |
558 | //======================================================================= | |
559 | ||
560 | void TDocStd_Application::OnAbortTransaction (const Handle(TDocStd_Document)&) | |
561 | { | |
562 | // nothing to do on this level | |
563 | } | |
564 | ||
565 | //======================================================================= | |
566 | //function : OnCommitTransaction | |
567 | //purpose : | |
568 | //======================================================================= | |
569 | ||
570 | void TDocStd_Application::OnCommitTransaction (const Handle(TDocStd_Document)&) | |
571 | { | |
572 | // nothing to do on this level | |
573 | } |