Acad::ErrorStatus
ArxDbgUtils::cloneObjects(AcDbDatabase* db, const AcDbObjectId& entToClone,
                        const AcDbObjectId& ownerBlockId, bool debugSpeak)
{
	ASSERT(db != NULL);

    AcDbObjectIdArray objIdList;
    objIdList.append(entToClone);

    return cloneObjects(db, objIdList, ownerBlockId, debugSpeak);
}
示例#2
0
Document* DbiDocumentFormat::loadDocument(IOAdapter* io, const U2DbiRef& dstDbiRef, const QVariantMap& fs, U2OpStatus& os){
    //1. open db
    //2. read all objects
    //3. if there is a DEEP_COPY_OBJECT hint, all objects are cloned to the db defined by dstDbiRef
    //3. close db
    QString url = io->getURL().getURLString();
    U2DbiRef srcDbiRef(id, url);
    DbiConnection handle(srcDbiRef, true, os);
    CHECK_OP(os, NULL);

    U2ObjectDbi* odbi = handle.dbi->getObjectDbi();
    QList<U2DataId> objectIds = odbi->getObjects(U2ObjectDbi::ROOT_FOLDER, 0, U2DbiOptions::U2_DBI_NO_LIMIT, os);
    CHECK_OP(os, NULL);

    QList<GObject*> objects;
    U2EntityRef ref;
    ref.dbiRef = srcDbiRef;

    objects << prepareObjects(handle, objectIds);

    if (fs.value(DEEP_COPY_OBJECT, false).toBool()) {
        QList<GObject *> clonedObjects = cloneObjects(objects, dstDbiRef, fs, os);
        qDeleteAll(objects);
        CHECK_OP_EXT(os, qDeleteAll(clonedObjects), NULL);
        objects = clonedObjects;
    } else {
        renameObjectsIfNamesEqual(objects);
    }

    QString lockReason = handle.dbi->isReadOnly() ? "The database is read-only" : "";
    Document* d = new Document(this, io->getFactory(), io->getURL(), dstDbiRef, objects, fs, lockReason);
    d->setDocumentOwnsDbiResources(false);
    d->setModificationTrack(false);

    return d;
}