+ Keep trailing digits when loading project file
This commit is contained in:
parent
775e6eba4f
commit
365099a2bd
|
@ -144,6 +144,7 @@ struct DocumentP
|
||||||
std::map<Vertex,DocumentObject*> vertexMap;
|
std::map<Vertex,DocumentObject*> vertexMap;
|
||||||
bool rollback;
|
bool rollback;
|
||||||
bool closable;
|
bool closable;
|
||||||
|
bool keepTrailingDigits;
|
||||||
int iUndoMode;
|
int iUndoMode;
|
||||||
unsigned int UndoMemSize;
|
unsigned int UndoMemSize;
|
||||||
unsigned int UndoMaxStackSize;
|
unsigned int UndoMaxStackSize;
|
||||||
|
@ -158,6 +159,7 @@ struct DocumentP
|
||||||
iTransactionCount = 0;
|
iTransactionCount = 0;
|
||||||
rollback = false;
|
rollback = false;
|
||||||
closable = true;
|
closable = true;
|
||||||
|
keepTrailingDigits = true;
|
||||||
iUndoMode = 0;
|
iUndoMode = 0;
|
||||||
UndoMemSize = 0;
|
UndoMemSize = 0;
|
||||||
UndoMaxStackSize = 20;
|
UndoMaxStackSize = 20;
|
||||||
|
@ -807,6 +809,7 @@ void Document::writeObjects(const std::vector<App::DocumentObject*>& obj,
|
||||||
std::vector<App::DocumentObject*>
|
std::vector<App::DocumentObject*>
|
||||||
Document::readObjects(Base::XMLReader& reader)
|
Document::readObjects(Base::XMLReader& reader)
|
||||||
{
|
{
|
||||||
|
d->keepTrailingDigits = !reader.doNameMapping();
|
||||||
std::vector<App::DocumentObject*> objs;
|
std::vector<App::DocumentObject*> objs;
|
||||||
|
|
||||||
// read the object types
|
// read the object types
|
||||||
|
@ -1802,10 +1805,12 @@ std::string Document::getUniqueObjectName(const char *Name) const
|
||||||
std::string CleanName = Base::Tools::getIdentifier(Name);
|
std::string CleanName = Base::Tools::getIdentifier(Name);
|
||||||
// remove also trailing digits from clean name which is to avoid to create lengthy names
|
// remove also trailing digits from clean name which is to avoid to create lengthy names
|
||||||
// like 'Box001001'
|
// like 'Box001001'
|
||||||
|
if (!d->keepTrailingDigits) {
|
||||||
std::string::size_type index = CleanName.find_last_not_of("0123456789");
|
std::string::size_type index = CleanName.find_last_not_of("0123456789");
|
||||||
if (index+1 < CleanName.size()) {
|
if (index+1 < CleanName.size()) {
|
||||||
CleanName = CleanName.substr(0,index+1);
|
CleanName = CleanName.substr(0,index+1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// name in use?
|
// name in use?
|
||||||
std::map<std::string,DocumentObject*>::const_iterator pos;
|
std::map<std::string,DocumentObject*>::const_iterator pos;
|
||||||
|
|
|
@ -370,6 +370,11 @@ const char* Base::XMLReader::getName(const char* name) const
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Base::XMLReader::doNameMapping() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Base::XMLReader: Implementation of the SAX DocumentHandler interface
|
// Base::XMLReader: Implementation of the SAX DocumentHandler interface
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -161,6 +161,7 @@ public:
|
||||||
bool isRegistered(Base::Persistence *Object) const;
|
bool isRegistered(Base::Persistence *Object) const;
|
||||||
virtual void addName(const char*, const char*);
|
virtual void addName(const char*, const char*);
|
||||||
virtual const char* getName(const char*) const;
|
virtual const char* getName(const char*) const;
|
||||||
|
virtual bool doNameMapping() const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// Schema Version of the document
|
/// Schema Version of the document
|
||||||
|
|
|
@ -58,6 +58,10 @@ public:
|
||||||
else
|
else
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
bool doNameMapping() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
void startElement(const XMLCh* const uri, const XMLCh* const localname,
|
void startElement(const XMLCh* const uri, const XMLCh* const localname,
|
||||||
const XMLCh* const qname,
|
const XMLCh* const qname,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user