// NAME: closedoc() // // REMARKS: Simple routine to exercise closing a document in MDI using standard user interface // This API is functionally equivalent to an acedCommand of the OPEN command, // but uses the standard Windows messaging mechanism. // ( PostMessage(hMainWnd, WM_CLOSE, 0, 0); ) // It is cleaner and will handle more situations like command already in progress // and you do not have to worry about nesting of acedCommand if you use this API. // // NOTEs: See the same caveats as activateDocument() example but realize in this case // if the CLOSE completes obviously the calling routine will never be returned to. // // RETURNS: // void // void closedoc() { AcApDocument* pDoc = selectDocument(); if (pDoc == NULL) { acutPrintf("No document selected.\n"); return; } acDocManager->closeDocument(pDoc); // A line of code here will NEVER execute if the close succeeds }
// // NAME: activate // // REMARKS: Simple utility to have the user choose an open document to // be activated programmatically. // NOTE: This and other APIs that change context (switch from one // active document to another) have the effect of suspending the current // document context. What this implies is if the ARX application // had code immediately following the activateDocument() API call // and this command was executed from a current document (ie. NOT // from the application context) The code following the API // call would never execute until that document became activated // again. // // // // RETURNS: // void void activate() { AcApDocument* pDoc = selectDocument(); if (pDoc == NULL) { acutPrintf("No document selected.\n"); return; } acDocManager->activateDocument(pDoc); // A line of code here will not execute until the document // that started this command is activated again. }
// // NAME: send // // REMARKS: Simple routine to exercise switching between documents and sending commands. // // NOTEs: The actual signature for sendStringToExecute is: // virtual Acad::ErrorStatus sendStringToExecute( // AcApDocument* pAcTargetDocument, // const char * pszExecute, // bool bActivate = true, // bool bWrapUpInactiveDoc = false) = 0; // // By default this API activates the document you are sending the string to // to be executed to. The last parameter, bWrapUpInactiveDoc is only applicable // if bActivate == False. This special ability allows you to "clean up" // a document you might have left with some dangling command when constructing // a command that spans documents. One scenario is you are in the middle of // a custom command whose implementation is designed to "follow" the user // as they move from one document to another. If you have registered a reactor // on documentToBeActivated(). When this reactor fires you wish to complete // your current command in the document that is being deactivated and start // a command in the document about to be activated. // Given these conditions, you would possibly send a "return" to the old // document and "execute my new command" string to the one about to activated. // The "return" you would want to process in the background so you would pass // bActivate = False and bWrapUpInactiveDoc = True. // // RETURNS: // void // void send() { AcApDocument* pDoc = selectDocument(); if (pDoc == NULL) { acutPrintf("No document selected.\n"); return; } acDocManager->sendStringToExecute(pDoc, /*NOXLATE*/"_Line\n"); // The API inputPending() allows you to check to see if someone else has already // made a request via sendStringToExecute() to a target document. // You may not care if your command is autonomous and does not depend on the target // document being in a quiescent state. If not call both isQuiescent() and inputPending() acutPrintf("\nSent String to Doc: %s Pending Input %d\n", pDoc->fileName(), acDocManager->inputPending(pDoc)); }
/*! *\~english * Create new record in system journal. * Record create afte crate new document and use information about doc's * database id, prefix and metadata id(type). * Document number generate automatically by nextNumber(). *\~russian * Добавляет запись в системный журнал. * Запись добавляется после создания документа и использует информацию о его * id в базе данных, префиксе номера и id в конфигурации. * Номер досумента генерируется функцией nextNumber() *\~ *\param idd - \~english database document id.\~russian id базы данных.\~ *\param docPrefix - \~english document number prefix. \~russian перфикс номера документа.\~ *\param type - \~english document metadata id. \~russian id документа в конфигурации.\~ *\return \~english error code.\~russian код ошибки.\~ */ ERR_Code aDocJournal::New( qulonglong idd, const QString & docPrefix, int type ) { //qulonglong Uid =0;// db->uid( md_systemjournal ); aDataTable * t = table(); if ( !t ) return err_notable; //t->exec("LOCK TABLE a_journ WRITE"); //printf("insert into ajourn id=%llu idd=%llu, docPrefix=%s, type=%d\n",Uid,idd, (const char*)docPrefix.local8Bit(), type); // t->exec("LOCK TABLE a_journ WRITE"); QSqlRecord *rec; rec = t->primeInsert(); // get edit buffer for table elements // t->primeInsert(); //ide = rec->value("id").toULongLong(); //rec->setValue("id",Uid); rec->setValue("idd",idd); rec->setValue("typed",type); rec->setValue("num",nextNumber(docPrefix,type)); rec->setValue("pnum",docPrefix); rec->setValue("ddate",QDateTime::currentDateTime()); t->insert(); // insert edit buffer as new line in table //TODO: error handle aLog::print(aLog::Info, tr("aDocJournal new document with idd=%1").arg(idd)); /* t->primeInsert(); t->insert(); t->setSysValue( "id", Uid ); t->setSysValue( "idd", idd ); t->setSysValue( "typed", type ); t->setSysValue( "num", nextNumber(docPrefix,type) ); t->setSysValue( "pnum", docPrefix ); t->setSysValue( "ddate", QDateTime::currentDateTime() ); Update(); t->exec("UNLOCK TABLE"); */ int err = selectDocument( idd ); setSelected(!err); return err; }
void ProjectDocumentComboBoxController::selectDocument(Document* d) { assert(filter->matches(d)); selectDocument(d->getURLString()); }