| 354 | } |
| 355 | |
| 356 | void PropertyFileIncluded::Save(Base::Writer& writer) const |
| 357 | { |
| 358 | // when saving a document under a new file name the transient directory |
| 359 | // name changes and thus the stored file name doesn't work any more. |
| 360 | if (!_cValue.empty() && !Base::FileInfo(_cValue).exists()) { |
| 361 | Base::FileInfo fi(getDocTransientPath() + "/" + _BaseFileName); |
| 362 | if (fi.exists()) { |
| 363 | _cValue = fi.filePath(); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | if (writer.isForceXML()) { |
| 368 | if (!_cValue.empty()) { |
| 369 | Base::FileInfo file(_cValue.c_str()); |
| 370 | writer.Stream() << writer.ind() << "<FileIncluded data=\"" << file.fileName() << "\">" |
| 371 | << std::endl; |
| 372 | // write the file in the XML stream |
| 373 | writer.incInd(); |
| 374 | writer.insertBinFile(_cValue.c_str()); |
| 375 | writer.decInd(); |
| 376 | writer.Stream() << writer.ind() << "</FileIncluded>" << endl; |
| 377 | } |
| 378 | else { |
| 379 | writer.Stream() << writer.ind() << "<FileIncluded data=\"\"/>" << std::endl; |
| 380 | } |
| 381 | } |
| 382 | else { |
| 383 | // instead initiate an extra file |
| 384 | if (!_cValue.empty()) { |
| 385 | Base::FileInfo file(_cValue.c_str()); |
| 386 | std::string filename = writer.addFile(file.fileName().c_str(), this); |
| 387 | filename = encodeAttribute(filename); |
| 388 | writer.Stream() << writer.ind() << "<FileIncluded file=\"" << filename << "\"/>" |
| 389 | << std::endl; |
| 390 | } |
| 391 | else { |
| 392 | writer.Stream() << writer.ind() << "<FileIncluded file=\"\"/>" << std::endl; |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | void PropertyFileIncluded::Restore(Base::XMLReader& reader) |
| 398 | { |
nothing calls this directly
no test coverage detected