Merge pull request #14898 from bgbsww/bgbsww-toponamingSaveRestoreElementMaps

Toponaming: Fix save and restore of elementmaps
This commit is contained in:
Chris Hennes
2024-06-25 09:58:59 -05:00
committed by GitHub
12 changed files with 229 additions and 43 deletions

View File

@@ -264,8 +264,8 @@ bool Base::XMLReader::isEndOfDocument() const
void Base::XMLReader::readEndElement(const char* ElementName, int level)
{
// if we are already at the end of the current element
if (ReadType == EndElement && ElementName && LocalName == ElementName
&& (level < 0 || level == Level)) {
if ((ReadType == EndElement || ReadType == StartEndElement) && ElementName
&& LocalName == ElementName && (level < 0 || level == Level)) {
return;
}
if (ReadType == EndDocument) {

View File

@@ -320,6 +320,11 @@ void Writer::decInd()
indBuf[indent] = '\0';
}
void Writer::putNextEntry(const char* file, const char* obj)
{
ObjectName = obj ? obj : file;
}
// ----------------------------------------------------------------------------
ZipWriter::ZipWriter(const char* FileName)
@@ -346,6 +351,13 @@ ZipWriter::ZipWriter(std::ostream& os)
ZipStream.setf(ios::fixed, ios::floatfield);
}
void ZipWriter::putNextEntry(const char* file, const char* obj)
{
Writer::putNextEntry(file, obj);
ZipStream.putNextEntry(file);
}
void ZipWriter::writeFiles()
{
// use a while loop because it is possible that while
@@ -353,7 +365,9 @@ void ZipWriter::writeFiles()
size_t index = 0;
while (index < FileList.size()) {
FileEntry entry = FileList[index];
ZipStream.putNextEntry(entry.FileName);
putNextEntry(entry.FileName.c_str());
indent = 0;
indBuf[0] = 0;
entry.Object->SaveDocFile(*this);
index++;
}
@@ -372,8 +386,10 @@ FileWriter::FileWriter(const char* DirName)
FileWriter::~FileWriter() = default;
void FileWriter::putNextEntry(const char* file)
void FileWriter::putNextEntry(const char* file, const char* obj)
{
Writer::putNextEntry(file, obj);
std::string fileName = DirName + "/" + file;
this->FileStream.open(fileName.c_str(), std::ios::out | std::ios::binary);
}
@@ -402,8 +418,9 @@ void FileWriter::writeFiles()
fi.createDirectory();
}
std::string fileName = DirName + "/" + entry.FileName;
this->FileStream.open(fileName.c_str(), std::ios::out | std::ios::binary);
putNextEntry(entry.FileName.c_str());
indent = 0;
indBuf[0] = 0;
entry.Object->SaveDocFile(*this);
this->FileStream.close();
}

View File

@@ -68,6 +68,9 @@ public:
void setFileVersion(int);
int getFileVersion() const;
/// put the next entry with a give name
virtual void putNextEntry(const char* filename, const char* objName = nullptr);
/// insert a file as CDATA section in the XML file
void insertAsciiFile(const char* FileName);
/// insert a binary file BASE64 coded as CDATA section in the XML file
@@ -206,10 +209,7 @@ public:
{
ZipStream.setLevel(level);
}
void putNextEntry(const char* str)
{
ZipStream.putNextEntry(str);
}
void putNextEntry(const char* filename, const char* objName = nullptr) override;
ZipWriter(const ZipWriter&) = delete;
ZipWriter(ZipWriter&&) = delete;
@@ -256,7 +256,7 @@ public:
explicit FileWriter(const char* DirName);
~FileWriter() override;
void putNextEntry(const char* file);
void putNextEntry(const char* filename, const char* objName = nullptr) override;
void writeFiles() override;
std::ostream& Stream() override