+ always keep digits at end when using copyObject, remove deprecated third parameter
This commit is contained in:
parent
1811795e41
commit
11239b034c
|
@ -890,6 +890,7 @@ void Document::writeObjects(const std::vector<App::DocumentObject*>& obj,
|
|||
std::vector<App::DocumentObject*>
|
||||
Document::readObjects(Base::XMLReader& reader)
|
||||
{
|
||||
bool keepDigits = d->keepTrailingDigits;
|
||||
d->keepTrailingDigits = !reader.doNameMapping();
|
||||
std::vector<App::DocumentObject*> objs;
|
||||
|
||||
|
@ -919,6 +920,7 @@ Document::readObjects(Base::XMLReader& reader)
|
|||
}
|
||||
}
|
||||
reader.readEndElement("Objects");
|
||||
d->keepTrailingDigits = keepDigits;
|
||||
|
||||
// read the features itself
|
||||
reader.readElement("ObjectData");
|
||||
|
@ -1757,7 +1759,7 @@ void Document::breakDependency(DocumentObject* pcObject, bool clear)
|
|||
}
|
||||
}
|
||||
|
||||
DocumentObject* Document::copyObject(DocumentObject* obj, bool recursive, bool /*keepdigitsatend*/)
|
||||
DocumentObject* Document::copyObject(DocumentObject* obj, bool recursive)
|
||||
{
|
||||
std::vector<DocumentObject*> objs;
|
||||
objs.push_back(obj);
|
||||
|
@ -1862,14 +1864,6 @@ std::string Document::getUniqueObjectName(const char *Name) const
|
|||
if (!Name || *Name == '\0')
|
||||
return std::string();
|
||||
std::string CleanName = Base::Tools::getIdentifier(Name);
|
||||
// remove also trailing digits from clean name which is to avoid to create lengthy names
|
||||
// like 'Box001001'
|
||||
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?
|
||||
std::map<std::string,DocumentObject*>::const_iterator pos;
|
||||
|
@ -1880,6 +1874,15 @@ std::string Document::getUniqueObjectName(const char *Name) const
|
|||
return CleanName;
|
||||
}
|
||||
else {
|
||||
// remove also trailing digits from clean name which is to avoid to create lengthy names
|
||||
// like 'Box001001'
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> names;
|
||||
names.reserve(d->objectMap.size());
|
||||
for (pos = d->objectMap.begin();pos != d->objectMap.end();++pos) {
|
||||
|
|
|
@ -168,7 +168,7 @@ public:
|
|||
* are copied as well. By default \a recursive is false.
|
||||
* Returns the copy of the object or 0 if the creation failed.
|
||||
*/
|
||||
DocumentObject* copyObject(DocumentObject* obj, bool recursive=false, bool keepdigitsatend=false);
|
||||
DocumentObject* copyObject(DocumentObject* obj, bool recursive=false);
|
||||
/** Move an object from another document to this document
|
||||
* If \a recursive is true then all objects this object depends on
|
||||
* are moved as well. By default \a recursive is false.
|
||||
|
|
|
@ -242,14 +242,14 @@ PyObject* DocumentPy::removeObject(PyObject *args)
|
|||
|
||||
PyObject* DocumentPy::copyObject(PyObject *args)
|
||||
{
|
||||
// 'keep' is not needed any more but leave it there for backward compatibility
|
||||
PyObject *obj, *rec=Py_False, *keep=Py_False;
|
||||
if (!PyArg_ParseTuple(args, "O!|O!O!",&(DocumentObjectPy::Type),&obj,&PyBool_Type,&rec,&PyBool_Type,&keep))
|
||||
return NULL; // NULL triggers exception
|
||||
|
||||
DocumentObjectPy* docObj = static_cast<DocumentObjectPy*>(obj);
|
||||
DocumentObject* copy = getDocumentPtr()->copyObject(docObj->getDocumentObjectPtr(),
|
||||
PyObject_IsTrue(rec) ? true : false,
|
||||
PyObject_IsTrue(keep)? true : false);
|
||||
PyObject_IsTrue(rec) ? true : false);
|
||||
if (copy) {
|
||||
return copy->getPyObject();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user