void
ArxDbgUiTdcWblockClone::OnWblockBlkDef()
{
        // get the block we're suppose to be wblocking
    int index = m_puBlockDef.GetCurSel();
    ASSERT(index != CB_ERR);

    CString str;
    AcDbObjectId blkDefId;
    if (!m_blockList.GetAtIndex(index, str, blkDefId)) {
        ASSERT(0);
        return;
    }

    AcDbDatabase* sourceDb = getSourceDb();
    ASSERT(sourceDb != NULL);

        // lock the document we are wblocking from
    ArxDbgDocLockWrite docLock(sourceDb);
    if (docLock.lock() != Acad::eOk)
        return;

    // restore database to non-xref state (xes returns eOk if this
    // was necessary, and something else if it wasn't).
    Acad::ErrorStatus xes = sourceDb->restoreOriginalXrefSymbols();
    AcDbDatabase* tmpDb = NULL;
    Acad::ErrorStatus es = sourceDb->wblock(tmpDb, blkDefId);
    if (xes ==Acad::eOk)
        xes = sourceDb->restoreForwardingXrefSymbols();
    if (es == Acad::eOk) {
        doInsertOption(tmpDb);

        delete tmpDb;   // we're done with it
    }
    else {
        CString str;
        str.Format(_T("Wblock failed: %s"), ArxDbgUtils::rxErrorStr(es));
        ArxDbgUtils::stopAlertBox(str);

        delete tmpDb;   // yes, a failed wblock can leave a partially created database!
                        // so always delete it.
    }
}
void
ArxDbgUiTdcWblockClone::OnWblockObjects() 
{
    AcDbDatabase* sourceDb = getSourceDb();
    ASSERT(sourceDb != NULL);

    AcDbObjectIdArray objIds;
    m_cloneSet.getObjectsForDatabase(sourceDb, objIds);

    // unfortunately, wblock is a little restrictive on what
    // it will allow to be cloned automatically.  So, we factor
    // out all the entities and allow those to be cloned, and
    // then our ArxDbgAppEditorReactor will handle the rest by hand.
    AcDbObjectIdArray okToClone, mustCloneByHand;
    divideCloneSet(objIds, mustCloneByHand, okToClone);

    // lock the document we are wblocking from
    ArxDbgDocLockWrite docLock(sourceDb);
    if (docLock.lock() != Acad::eOk)
        return;
    // restore database to non-xref state (xes returns eOk if this
    // was necessary, and something else if it wasn't).
    Acad::ErrorStatus xes = sourceDb->restoreOriginalXrefSymbols();
    AcDbDatabase* tmpDb = NULL;
    Acad::ErrorStatus es = sourceDb->wblock(tmpDb, okToClone, m_basePt);
    if (xes ==Acad::eOk)
        xes = sourceDb->restoreForwardingXrefSymbols();
    if (es == Acad::eOk) {
        doInsertOption(tmpDb);

        delete tmpDb;   // we're done with it
    }
    else {
        CString str;
        str.Format(_T("Wblock failed: %s"), ArxDbgUtils::rxErrorStr(es));
        ArxDbgUtils::stopAlertBox(str);

        delete tmpDb;   // yes, a failed wblock can leave a partially created database!
                        // so always delete it.
    }
}
void
ArxDbgUiTdcWblockClone::OnWblockAll()
{
    UpdateData(TRUE);

    AcDbDatabase* sourceDb = getSourceDb();
    ASSERT(sourceDb != NULL);

    if (m_doForceCopy)
        sourceDb->forceWblockDatabaseCopy();

        // lock the document we are wblocking from
    ArxDbgDocLockWrite docLock(sourceDb);
    if (docLock.lock() != Acad::eOk)
        return;

    // restore database to non-xref state (xes returns eOk if this
    // was necessary, and something else if it wasn't).
    Acad::ErrorStatus xes = sourceDb->restoreOriginalXrefSymbols();
    AcDbDatabase* tmpDb = NULL;
    Acad::ErrorStatus es = sourceDb->wblock(tmpDb);
    if (xes ==Acad::eOk)
        xes = sourceDb->restoreForwardingXrefSymbols();
    if (es == Acad::eOk) {
        doInsertOption(tmpDb);

        delete tmpDb;   // we're done with it
    }
    else {
        CString str;
        str.Format(_T("Wblock failed: %s"), ArxDbgUtils::rxErrorStr(es));
        ArxDbgUtils::stopAlertBox(str);

        delete tmpDb;   // yes, a failed wblock can leave a partially created database!
                        // so always delete it.
    }
}