- std::set<std::string>::iterator aSubIter = mySubs.begin();
- for (; aSubIter != mySubs.end() && isDone; aSubIter++) {
- isDone = subDoc(*aSubIter)->save(theFileName, theResults);
- }
- if (isDone) { // also try to copy the not-activated sub-documents
- // they are not in mySubs but as ResultParts
- int aPartsNum = size(ModelAPI_ResultPart::group());
- for(int aPart = 0; aPart < aPartsNum; aPart++) {
- ResultPartPtr aPartRes = std::dynamic_pointer_cast<ModelAPI_ResultPart>
- (object(ModelAPI_ResultPart::group(), aPart));
- if (aPartRes) {
- std::string aDocName = aPartRes->data()->name();
- if (!aDocName.empty() && mySubs.find(aDocName) == mySubs.end()) {
- // just copy file
- TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName));
- OSD_Path aPath(aSubPath);
- OSD_File aFile(aPath);
- if (aFile.Exists()) {
- TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName));
- OSD_Path aDestination(aDestinationDir);
- aFile.Copy(aDestination);
- theResults.push_back(aDestinationDir.ToCString());
- } else {
- Events_Error::send(
- std::string("Can not open file ") + aSubPath.ToCString() + " for saving");
- }
+ const std::set<std::string> aSubs = subDocuments(false);
+ std::set<std::string>::iterator aSubIter = aSubs.begin();
+ for (; aSubIter != aSubs.end() && isDone; aSubIter++) {
+ if (anApp->isLoadByDemand(*aSubIter)) {
+ // copy not-activated document that is not in the memory
+ std::string aDocName = *aSubIter;
+ if (!aDocName.empty()) {
+ // just copy file
+ TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName));
+ OSD_Path aPath(aSubPath);
+ OSD_File aFile(aPath);
+ if (aFile.Exists()) {
+ TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName));
+ OSD_Path aDestination(aDestinationDir);
+ aFile.Copy(aDestination);
+ theResults.push_back(aDestinationDir.ToCString());
+ } else {
+ Events_Error::send(
+ std::string("Can not open file ") + aSubPath.ToCString() + " for saving");