+ Keep trailing digits when loading project file

This commit is contained in:
wmayer 2013-12-30 12:54:45 +01:00
parent 775e6eba4f
commit 365099a2bd
4 changed files with 18 additions and 3 deletions

View File

@ -144,6 +144,7 @@ struct DocumentP
std::map<Vertex,DocumentObject*> vertexMap;
bool rollback;
bool closable;
bool keepTrailingDigits;
int iUndoMode;
unsigned int UndoMemSize;
unsigned int UndoMaxStackSize;
@ -158,6 +159,7 @@ struct DocumentP
iTransactionCount = 0;
rollback = false;
closable = true;
keepTrailingDigits = true;
iUndoMode = 0;
UndoMemSize = 0;
UndoMaxStackSize = 20;
@ -807,6 +809,7 @@ void Document::writeObjects(const std::vector<App::DocumentObject*>& obj,
std::vector<App::DocumentObject*>
Document::readObjects(Base::XMLReader& reader)
{
d->keepTrailingDigits = !reader.doNameMapping();
std::vector<App::DocumentObject*> objs;
// read the object types
@ -1802,9 +1805,11 @@ std::string Document::getUniqueObjectName(const char *Name) const
std::string CleanName = Base::Tools::getIdentifier(Name);
// remove also trailing digits from clean name which is to avoid to create lengthy names
// like 'Box001001'
std::string::size_type index = CleanName.find_last_not_of("0123456789");
if (index+1 < CleanName.size()) {
CleanName = CleanName.substr(0,index+1);
if (!d->keepTrailingDigits) {
std::string::size_type index = CleanName.find_last_not_of("0123456789");
if (index+1 < CleanName.size()) {
CleanName = CleanName.substr(0,index+1);
}
}
// name in use?

View File

@ -370,6 +370,11 @@ const char* Base::XMLReader::getName(const char* name) const
return name;
}
bool Base::XMLReader::doNameMapping() const
{
return false;
}
// ---------------------------------------------------------------------------
// Base::XMLReader: Implementation of the SAX DocumentHandler interface
// ---------------------------------------------------------------------------

View File

@ -161,6 +161,7 @@ public:
bool isRegistered(Base::Persistence *Object) const;
virtual void addName(const char*, const char*);
virtual const char* getName(const char*) const;
virtual bool doNameMapping() const;
//@}
/// Schema Version of the document

View File

@ -58,6 +58,10 @@ public:
else
return name;
}
bool doNameMapping() const
{
return true;
}
protected:
void startElement(const XMLCh* const uri, const XMLCh* const localname,
const XMLCh* const qname,