本文整理汇总了C++中UT_GenericVector::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_GenericVector::addItem方法的具体用法?C++ UT_GenericVector::addItem怎么用?C++ UT_GenericVector::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_GenericVector
的用法示例。
在下文中一共展示了UT_GenericVector::addItem方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _handlePacket
//.........这里部分代码省略.........
// serialize entire document into string
JoinSessionRequestResponseEvent jsre(jse->getSessionId(), iAuthorId);
if (AbiCollabSessionManager::serializeDocument(pDoc, jsre.m_sZABW, false /* no base64 */) == UT_OK)
{
// set more document properties
jsre.m_iRev = pDoc->getCRNumber();
jsre.m_sDocumentId = pDoc->getDocUUIDString();
if (pDoc->getFilename())
jsre.m_sDocumentName = UT_go_basename_from_uri(pDoc->getFilename());
// send to buddy!
send(&jsre, buddy);
// add this buddy to the collaboration session
pSession->addCollaborator(buddy);
}
break;
}
case PCT_JoinSessionRequestResponseEvent:
{
JoinSessionRequestResponseEvent* jsre = static_cast<JoinSessionRequestResponseEvent*>( packet );
PD_Document* pDoc = 0;
if (AbiCollabSessionManager::deserializeDocument(&pDoc, jsre->m_sZABW, false) == UT_OK)
{
if (pDoc)
{
// NOTE: we could adopt the same document name here, but i'd
// rather not at the moment - MARCM
pDoc->forceDirty();
if (jsre->m_sDocumentName.size() > 0)
{
gchar* fname = g_strdup(jsre->m_sDocumentName.utf8_str());
pDoc->setFilename(fname);
}
// The default ownership when joining is FALSE, as that seems
// to make sense for the generic case. The person sharing the
// document by default owns the document (and is thus allowed
// to modify the ACL).
pManager->joinSession(jsre->getSessionId(), pDoc, jsre->m_sDocumentId, jsre->m_iRev, jsre->getAuthorId(), buddy, this, false, NULL);
}
else
{
UT_DEBUGMSG(("AccountHandler::_handlePacket() - deserializing document failed!\n"));
}
}
break;
}
case PCT_GetSessionsEvent:
{
GetSessionsResponseEvent gsre;
const UT_GenericVector<AbiCollab *> sessions = pManager->getSessions();
for (UT_sint32 i = 0; i < sessions.getItemCount(); i++)
{
AbiCollab* pSession = sessions.getNthItem(i);
if (pSession && pSession->isLocallyControlled())
{
// check if the buddy has access to this session
if (!hasAccess(pSession->getAcl(), buddy))
{
UT_DEBUGMSG(("Buddy %s denied access to session %s by ALC\n", buddy->getDescriptor(true).utf8_str(), pSession->getSessionId().utf8_str()));
continue;
}
const PD_Document * pDoc = pSession->getDocument();
UT_continue_if_fail(pDoc);
// determine name
UT_UTF8String documentBaseName;
if (pDoc->getFilename())
documentBaseName = UT_go_basename_from_uri(pDoc->getFilename());
// set session info
gsre.m_Sessions[ pSession->getSessionId() ] = documentBaseName;
}
}
send(&gsre, buddy);
break;
}
case PCT_GetSessionsResponseEvent:
{
GetSessionsResponseEvent* gsre = static_cast<GetSessionsResponseEvent*>( packet );
UT_GenericVector<DocHandle*> vDocHandles;
for (std::map<UT_UTF8String,UT_UTF8String>::iterator it=gsre->m_Sessions.begin(); it!=gsre->m_Sessions.end(); ++it) {
DocHandle* pDocHandle = new DocHandle((*it).first, (*it).second);
vDocHandles.addItem(pDocHandle);
}
pManager->setDocumentHandles(buddy, vDocHandles);
break;
}
default:
{
UT_DEBUGMSG(("Unhandled packet class: 0x%x\n", packet->getClassType()));
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
break;
}
}
}
示例2: getBlocksAroundFrame
/*!
* Fill the supplied vector with a list of the blocks whose lines are affected
* by the Frame.
*/
void fp_FrameContainer::getBlocksAroundFrame(UT_GenericVector<fl_BlockLayout *> & vecBlocks)
{
fp_Page * pPage = getPage();
if(pPage == NULL)
{
return;
}
UT_sint32 iColLeader = 0;
fp_Column * pCol = NULL;
fl_BlockLayout * pCurBlock = NULL;
fp_Line * pCurLine = NULL;
fp_Container * pCurCon = NULL;
if(pPage->countColumnLeaders() == 0)
{
UT_sint32 iPage = getPreferedPageNo();
if(iPage >0)
setPreferedPageNo(iPage-1);
return;
}
for(iColLeader = 0; iColLeader < pPage->countColumnLeaders(); iColLeader++)
{
pCol = pPage->getNthColumnLeader(iColLeader);
while(pCol)
{
UT_sint32 i = 0;
UT_sint32 iYCol = pCol->getY(); // Vertical position relative to page.
for(i=0; i< pCol->countCons(); i++)
{
pCurCon = static_cast<fp_Container *>(pCol->getNthCon(i));
if(pCurCon->getContainerType() == FP_CONTAINER_LINE)
{
pCurLine = static_cast<fp_Line *>(pCurCon);
UT_sint32 iYLine = iYCol + pCurLine->getY();
xxx_UT_DEBUGMSG(("iYLine %d FullY %d FullHeight %d \n",iYLine,getFullY(),getFullHeight()));
if((iYLine + pCurLine->getHeight() > getFullY()) && (iYLine < (getFullY() + getFullHeight())))
{
//
// Line overlaps frame in Height. Add it's block to the vector.
//
if(pCurLine->getBlock() != pCurBlock)
{
pCurBlock = pCurLine->getBlock();
vecBlocks.addItem(pCurBlock);
xxx_UT_DEBUGMSG(("Add Block %x to vector \n",pCurBlock));
}
}
}
}
pCol = pCol->getFollower();
}
}
if(vecBlocks.getItemCount() == 0)
{
pCol = pPage->getNthColumnLeader(0);
fp_Container * pCon = pCol->getFirstContainer();
fl_BlockLayout * pB = NULL;
if(pCon && pCon->getContainerType() == FP_CONTAINER_LINE)
{
pB = static_cast<fp_Line *>(pCon)->getBlock();
}
else if(pCon)
{
fl_ContainerLayout * pCL = static_cast<fl_ContainerLayout *>(pCon->getSectionLayout());
pB = pCL->getNextBlockInDocument();
}
if(pB != NULL)
vecBlocks.addItem(pB);
}
}
示例3:
/*!
* Massage the byte buffer into an array of strings that can be loaded by
* gdk-pixbuf
*/
GdkPixbuf * IE_ImpGraphic_GdkPixbuf::_loadXPM(UT_ByteBuf * pBB)
{
GdkPixbuf * pixbuf = NULL;
const char * pBC = reinterpret_cast<const char *>(pBB->getPointer(0));
UT_GenericVector<char*> vecStr;
UT_sint32 k =0;
UT_sint32 iBase =0;
//
// Find dimension line to start with.
//
UT_sint32 length = static_cast<UT_sint32>(pBB->getLength());
for(k =0; (*(pBC+k) != '"') &&( k < length); k++)
;
if(k >= length)
{
return NULL;
}
k++;
iBase = k;
for(; (*(pBC+k) != '"') && (k < length); k++)
;
if(k >= length)
{
return NULL;
}
char * sz = NULL;
UT_sint32 kLen = k-iBase+1;
sz = static_cast<char *>(UT_calloc(kLen,sizeof(char)));
UT_sint32 i =0;
for(i=0; i< (kLen -1); i++)
{
*(sz+i) = *(pBC+iBase+i);
}
*(sz+i) = 0;
vecStr.addItem(sz);
//
// Now loop through all the lines until we get to "}" outside the
// '"'
while((*(pBC+k) != '}') && (k < length) )
{
k++;
//
// Load a single string of data into our vector.
//
if(*(pBC+k) =='"')
{
//
// Start of a line
//
k++;
iBase = k;
for(; (*(pBC+k) != '"') && (k < length); k++)
{
}
if(k >= length)
{
return NULL;
}
sz = NULL;
kLen = k-iBase+1;
sz = static_cast<char *>(UT_calloc(kLen,sizeof(char)));
for(i=0; i<(kLen -1); i++)
{
*(sz+i) = *(pBC+iBase+i);
}
*(sz +i) = 0;
vecStr.addItem(sz);
}
}
if(k >= length)
{
for(i=0; i< vecStr.getItemCount(); i++)
{
char * psz = vecStr.getNthItem(i);
FREEP(psz);
}
return NULL;
}
const char ** pszStr = static_cast<const char **>(UT_calloc(vecStr.getItemCount(),sizeof(char *)));
for(i=0; i< vecStr.getItemCount(); i++)
pszStr[i] = vecStr.getNthItem(i);
pixbuf = gdk_pixbuf_new_from_xpm_data(pszStr);
DELETEP(pszStr);
return pixbuf;
}