本文整理汇总了C++中PP_AttrProp类的典型用法代码示例。如果您正苦于以下问题:C++ PP_AttrProp类的具体用法?C++ PP_AttrProp怎么用?C++ PP_AttrProp使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PP_AttrProp类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void PP_AttrProp::operator = (const PP_AttrProp &Other)
{
UT_uint32 countMyAttrs = ((Other.m_pAttributes) ? Other.m_pAttributes->size() : 0);
UT_uint32 Index;
for(Index = 0; Index < countMyAttrs; Index++)
{
const gchar * szName;
const gchar * szValue;
if(Other.getNthAttribute(Index, szName, szValue))
{
setAttribute(szName, szValue);
}
}
UT_uint32 countMyProps = ((Other.m_pProperties) ? Other.m_pProperties->size() : 0);
for(Index = 0; Index < countMyProps; Index++)
{
const gchar * szName;
const gchar * szValue;
if(Other.getNthProperty(Index, szName, szValue))
{
setProperty(szName, szValue);
}
}
}
示例2: PP_AttrProp
bool pp_TableAttrProp::createAP(UT_sint32 * pSubscript)
{
PP_AttrProp * pNew = new PP_AttrProp();
if (!pNew)
return false;
UT_sint32 u;
if (m_vecTable.addItem(pNew,&u) != 0)
{
delete pNew;
return false;
}
pNew->setIndex(u); //$HACK
if (pSubscript)
{
*pSubscript = u;
}
else
{
// create default empty AP
pNew->markReadOnly();
m_vecTableSorted.addItem(pNew, NULL);
}
return true;
}
示例3: PP_AttrProp
/*! Create a new AttrProp with exactly the attributes/properties given.
\return NULL on failure, the newly-created PP_AttrProp.
*/
PP_AttrProp * PP_AttrProp::createExactly(const gchar ** attributes,
const gchar ** properties) const
{
// first, create a new AttrProp using just the values given.
PP_AttrProp * papNew = new PP_AttrProp();
if (!papNew)
goto Failed;
if (!papNew->setAttributes(attributes) || !papNew->setProperties(properties))
goto Failed;
return papNew;
Failed:
DELETEP(papNew);
return NULL;
}
示例4: createAP
bool pp_TableAttrProp::createAP(const UT_GenericVector<const gchar*> * pVector,
UT_sint32 * pSubscript)
{
UT_sint32 subscript;
if (!createAP(&subscript))
return false;
PP_AttrProp * pAP = m_vecTable.getNthItem(subscript);
UT_return_val_if_fail (pAP, false);
if (!pAP->setAttributes(pVector))
return false;
pAP->markReadOnly();
m_vecTableSorted.addItemSorted(pAP,compareAP);
*pSubscript = subscript;
return true;
}
示例5: setLevelStyle
void ODe_Style_List::setLevelStyle(UT_uint8 level, const PP_AttrProp& rBlockAP) {
UT_UTF8String levelString;
ODe_ListLevelStyle* pLevelStyle;
const gchar* pValue = NULL;
bool ok;
UT_UTF8String_sprintf(levelString, "%u", level);
pLevelStyle = m_levelStyles.pick(levelString.utf8_str());
if (pLevelStyle != NULL) {
// This level style aws already set. There's nothing to be done.
return;
}
ok = rBlockAP.getProperty("list-style", pValue);
UT_return_if_fail(ok && pValue);
if (!strcmp(pValue, "Numbered List") ||
!strcmp(pValue, "Lower Case List") ||
!strcmp(pValue, "Upper Case List") ||
!strcmp(pValue, "Lower Roman List") ||
!strcmp(pValue, "Upper Roman List") ||
!strcmp(pValue, "Hebrew List") ||
!strcmp(pValue, "Arabic List")) {
pLevelStyle = new ODe_Numbered_ListLevelStyle();
} else if (!strcmp(pValue, "Bullet List") ||
!strcmp(pValue, "Dashed List") ||
!strcmp(pValue, "Square List") ||
!strcmp(pValue, "Triangle List") ||
!strcmp(pValue, "Diamond List") ||
!strcmp(pValue, "Star List") ||
!strcmp(pValue, "Tick List") ||
!strcmp(pValue, "Box List") ||
!strcmp(pValue, "Hand List") ||
!strcmp(pValue, "Heart List") ||
!strcmp(pValue, "Implies List")) {
pLevelStyle = new ODe_Bullet_ListLevelStyle();
} else {
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
return;
}
m_levelStyles.insert(levelString.utf8_str(), pLevelStyle);
pLevelStyle->fetchAttributesFromAbiBlock(rBlockAP);
}
示例6: findMatch
bool pp_TableAttrProp::findMatch(const PP_AttrProp * pMatch,
UT_sint32 * pSubscript) const
{
// return true if we find an AP in our table which is
// an exact match for the attributes/properties in pMatch.
// set *pSubscript to the subscript of the matching item.
UT_sint32 kLimit = m_vecTable.getItemCount();
UT_sint32 k;
UT_uint32 checksum = pMatch->getCheckSum();
k = m_vecTableSorted.binarysearch(reinterpret_cast<void *>(&checksum), compareAPBinary);
UT_uint32 cksum = pMatch->getCheckSum();
if (k == -1)
{
k = kLimit;
}
for (; (k < kLimit); k++)
{
PP_AttrProp * pK = (PP_AttrProp *)m_vecTableSorted.getNthItem(k);
if (cksum != pK->getCheckSum())
{
break;
}
if (pMatch->isExactMatch(pK))
{
// Need to return an index of the element in the MAIN
// vector table
*pSubscript = pK->getIndex();
return true;
}
}
return false;
}
示例7: UT_return_if_fail
void AccountHandler::_handlePacket(Packet* packet, BuddyPtr buddy)
{
// packet and buddy must always be set
UT_return_if_fail(packet);
UT_return_if_fail(buddy);
// as must the session manager
AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager();
UT_return_if_fail(pManager);
// manager didn't handle it, see what we can do
switch (packet->getClassType())
{
case PCT_JoinSessionRequestEvent:
{
JoinSessionRequestEvent* jse = static_cast<JoinSessionRequestEvent*>(packet);
// lookup session
AbiCollab* pSession = pManager->getSessionFromSessionId(jse->getSessionId());
UT_return_if_fail(pSession);
// check if this buddy is allowed to access this document
// TODO: this should be done for every session packet, not just join session packets
if (!hasAccess(pSession->getAcl(), buddy))
{
// we should only reach this point if someone is brute forcing trying
// out session IDs while not being on the ACL. Ban this uses.
UT_ASSERT_HARMLESS(UT_SHOULD_NOT_HAPPEN);
return;
}
// lookup exporter
ABI_Collab_Export* pExport = pSession->getExport();
UT_return_if_fail(pExport);
// lookup adjusts
const UT_GenericVector<ChangeAdjust *>* pExpAdjusts = pExport->getAdjusts();
UT_return_if_fail(pExpAdjusts);
PD_Document* pDoc = pSession->getDocument();
// add this author to the document if we don't recognize him
UT_sint32 iAuthorId = -1;
UT_UTF8String buddyDescriptor = buddy->getDescriptor();
UT_GenericVector<pp_Author*> authors = pDoc->getAuthors();
UT_DEBUGMSG(("Scanning %d authors to see if we recognize this buddy\n", authors.getItemCount()));
for (UT_sint32 i = 0; i < authors.getItemCount(); i++)
{
pp_Author* pAuthor = authors.getNthItem(i);
UT_continue_if_fail(pAuthor);
const gchar* szDescriptor = NULL;
pAuthor->getProperty("abicollab-descriptor", szDescriptor);
if (!szDescriptor)
continue;
if (buddyDescriptor != szDescriptor)
continue;
// yay, we know this author!
iAuthorId = pAuthor->getAuthorInt();
UT_DEBUGMSG(("Found known author with descriptior %s, id %d!\n", buddyDescriptor.utf8_str(), iAuthorId));
break;
}
if (iAuthorId == -1)
{
// we don't know this author yet, create a new author object for him
iAuthorId = pDoc->findFirstFreeAuthorInt();
pp_Author * pA = pDoc->addAuthor(iAuthorId);
PP_AttrProp * pPA = pA->getAttrProp();
pPA->setProperty("abicollab-descriptor", buddyDescriptor.utf8_str());
pDoc->sendAddAuthorCR(pA);
UT_DEBUGMSG(("Added a new author to the documument with descriptor %s, id %d\n", buddyDescriptor.utf8_str(), iAuthorId));
}
// 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)
//.........这里部分代码省略.........
示例8: UT_DEBUGMSG
//.........这里部分代码省略.........
if (packet.getClassType() >= _PCT_FirstChangeRecord && packet.getClassType() <= _PCT_LastChangeRecord)
{
const ChangeRecordSessionPacket* crp = static_cast<const ChangeRecordSessionPacket*>(&packet);
UT_DEBUGMSG(("It's safe to import this packet\n"));
UT_DEBUGMSG(("For CR number %d requested point %d adjustment %d \n", crp->getRev(), crp->getPos(), iImportAdjustment));
PT_DocPosition pos = static_cast<PT_DocPosition>(crp->getPos() + iImportAdjustment);
UT_ASSERT(pos <= getEndOfDoc());
if (!inGlob)
{
// store the last seen revision from this collaborator (it is immediately used by the export)
// NOTE: if this changerecord is part of a glob, then we don't do this; we'll have
// already set the revision of the glob itself as the last seen one
m_remoteRevs[pCollaborator] = crp->getRev();
}
// todo: remove these temp vars
PT_DocPosition iPos2 = 0;
// process the packet
switch(crp->getPXType())
{
case PX_ChangeRecord::PXT_GlobMarker:
{
UT_DEBUGMSG(("Found GLOB marker (ignoring)\n"));
return true;
}
case PX_ChangeRecord::PXT_InsertSpan:
{
const InsertSpan_ChangeRecordSessionPacket* icrsp = static_cast<const InsertSpan_ChangeRecordSessionPacket*>( crp );
UT_UCS4String UCSChars = const_cast<UT_UTF8String&>(icrsp->m_sText).ucs4_str(); // ugly, ucs4_str should be const func!
PP_AttrProp attrProp;
attrProp.setAttributes(const_cast<const gchar**>(icrsp->getAtts()));
attrProp.setProperties(const_cast<const gchar**>(icrsp->getProps()));
m_pDoc->insertSpan(pos,UCSChars.ucs4_str(),UCSChars.length(), &attrProp);
break;
}
case PX_ChangeRecord::PXT_DeleteSpan:
{
iPos2 = pos + crp->getLength();
PP_AttrProp *p_AttrProp_Before = NULL;
UT_uint32 icnt = 0;
m_pDoc->deleteSpan(pos,iPos2,p_AttrProp_Before,icnt,true);
break;
}
case PX_ChangeRecord::PXT_ChangeSpan:
{
const Props_ChangeRecordSessionPacket* pcrsp = static_cast<const Props_ChangeRecordSessionPacket*>( crp );
gchar** szAtts = pcrsp->getAtts();
gchar** szProps = pcrsp->getProps();
iPos2 = pos + pcrsp->getLength();
if((szProps == NULL) && (szAtts == NULL))
{
//
// This happens if we remove all formats
// we have to handle this seperately
//
// Get style of containing block
//
pf_Frag_Strux* sdh = NULL;
m_pDoc->getStruxOfTypeFromPosition(pos,PTX_Block,&sdh);
if(!sdh)
{
UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
示例9: UT_return_val_if_fail
//.........这里部分代码省略.........
// with the FmtMark now gone, we make a minor adjustment so that we
// try to append text to the previous rather than prepend to the current.
// this makes us consistent with other places in the code.
if ( (fragOffset==0) && (pf->getPrev()) && (pf->getPrev()->getType() == pf_Frag::PFT_Text) && pf->getPrev()->getField()== NULL )
{
// append to the end of the previous frag rather than prepend to the current one.
pf = pf->getPrev();
fragOffset = pf->getLength();
}
}
else if (pf->getPrev()->getType() == pf_Frag::PFT_Text && pf->getPrev()->getField()==NULL)
{
pf_Frag_Text * pfPrevText = static_cast<pf_Frag_Text *>(pf->getPrev());
indexAP = pfPrevText->getIndexAP();
// append to the end of the previous frag rather than prepend to the current one.
pf = pf->getPrev();
fragOffset = pf->getLength();
}
else
{
indexAP = _chooseIndexAP(pf,fragOffset);
// PLAM: This is the list of field attrs that should not inherit
// PLAM: to the span following a field.
const gchar * pFieldAttrs[12];
pFieldAttrs[0] = "type"; pFieldAttrs[1] = NULL;
pFieldAttrs[2] = "param"; pFieldAttrs[3] = NULL;
pFieldAttrs[4] = "name"; pFieldAttrs[5] = NULL;
pFieldAttrs[6] = "endnote-id"; pFieldAttrs[7] = NULL;
pFieldAttrs[8] = NULL; pFieldAttrs[9] = NULL;
pFieldAttrs[10] = NULL; pFieldAttrs[11] = NULL;
const PP_AttrProp * pAP = NULL;
if (!getAttrProp(indexAP, &pAP))
return false;
if (pAP->areAnyOfTheseNamesPresent(pFieldAttrs, NULL))
{
// We do not want to inherit a char style from a field.
pFieldAttrs[8] = "style";
PP_AttrProp * pAPNew = pAP->cloneWithElimination(pFieldAttrs, NULL);
if (!pAPNew)
return false;
pAPNew->markReadOnly();
if (!m_varset.addIfUniqueAP(pAPNew, &indexAP))
return false;
}
}
}
else
{
// is existing fragment a field? If so do nothing
// Or should we display a message to the user?
if(pf->getField() != NULL)
{
return false;
}
indexAP = _chooseIndexAP(pf,fragOffset);
}
PT_BlockOffset blockOffset = _computeBlockOffset(pfs,pf) + fragOffset;
PX_ChangeRecord_Span * pcr = NULL;
示例10: _openODTextbox
void ODe_Frame_Listener::_openODTextbox(const PP_AttrProp& rAP,
ODe_ListenerAction& /*rAction*/)
{
UT_UTF8String output;
UT_UTF8String str;
bool ok;
const gchar* pValue = NULL;
ODe_Style_Style* pStyle;
pStyle = new ODe_Style_Style();
pStyle->setFamily("graphic");
pStyle->fetchAttributesFromAbiFrame(rAP);
// Abi frames have no padding
// (no margin between frame borders and its content)
pStyle->setPadding("0cm");
// Abi frames are aways positioned from its top-left corner.
pStyle->setHorizontalPos("from-left");
pStyle->setVerticalPos("from-top");
// For OOo to recognize a textbox as being a textbox, it will
// need to have the parent style name "Frame". I can't find it
// in the ODF spec, but without it OOo considers the textbox to
// be a generic drawing object (check the Navigator window in OOo).
pStyle->setParentStyleName("Frame");
// Make sure an (empty) Frame style exists, for completeness sake
// (OOo doesn't seem to care if it exists or not).
if (!m_rStyles.getGraphicsStyle("Frame")) {
ODe_Style_Style* pFrameStyle = new ODe_Style_Style();
pFrameStyle->setStyleName("Frame");
pFrameStyle->setFamily("graphic");
m_rStyles.addGraphicsStyle(pFrameStyle);
}
m_rAutomatiStyles.storeGraphicStyle(pStyle);
////
// Write <draw:frame>
_printSpacesOffset(output);
output += "<draw:frame";
UT_UTF8String_sprintf(str, "Frame%u", m_rAuxiliaryData.m_frameCount+1);
ODe_writeAttribute(output, "draw:name", str);
m_rAuxiliaryData.m_frameCount++;
ODe_writeAttribute(output, "draw:style-name", pStyle->getName());
UT_UTF8String_sprintf(str, "%u", m_zIndex);
ODe_writeAttribute(output, "draw:z-index", str);
ok = rAP.getProperty("position-to", pValue);
if (pValue && !strcmp(pValue, "block-above-text")) {
ODe_writeAttribute(output, "text:anchor-type", "paragraph");
ok = rAP.getProperty("xpos", pValue);
UT_ASSERT(ok && pValue != NULL);
ODe_writeAttribute(output, "svg:x", pValue);
ok = rAP.getProperty("ypos", pValue);
UT_ASSERT(ok && pValue != NULL);
ODe_writeAttribute(output, "svg:y", pValue);
} else {
// Everything else (column and page) will be treated as page
// anchored.
ODe_writeAttribute(output, "text:anchor-type", "page");
if(pValue && !strcmp(pValue, "column-above-text"))
{
//
// Get the most recent page style so we can do the arithmetic
// Won't work for x in multi-columned docs
//
UT_uint32 numPStyles = m_rAutomatiStyles.getSectionStylesCount();
UT_UTF8String stylePName;
UT_UTF8String_sprintf(stylePName, "PLayout%d", numPStyles + 1);
ODe_Style_PageLayout * pPageL = m_rAutomatiStyles.getPageLayout(stylePName.utf8_str());
ok = rAP.getProperty("frame-col-xpos", pValue);
UT_ASSERT(ok && pValue != NULL);
double xCol = UT_convertToInches(pValue);
const gchar* pSVal= pPageL->getPageMarginLeft();
double xPageL = UT_convertToInches(pSVal);
double xTot = xPageL + xCol;
pValue = UT_convertInchesToDimensionString(DIM_IN,xTot,"4");
ODe_writeAttribute(output, "svg:x", pValue);
ok = rAP.getProperty("frame-col-ypos", pValue);
UT_ASSERT(ok && pValue != NULL);
double yCol = UT_convertToInches(pValue);
pSVal= pPageL->getPageMarginTop();
double yPageL = UT_convertToInches(pSVal);
double yTot = yPageL + yCol;
pValue = UT_convertInchesToDimensionString(DIM_IN,yTot,"4");
ODe_writeAttribute(output, "svg:y", pValue);
//.........这里部分代码省略.........
示例11: UT_DEBUGMSG
AbiCollab* AbiCollabSessionManager::startSession(PD_Document* pDoc, UT_UTF8String& sSessionId,
AccountHandler* pAclAccount, bool bLocallyOwned, XAP_Frame* pFrame,
const UT_UTF8String& masterDescriptor)
{
UT_DEBUGMSG(("Starting collaboration session for document with id %s, master descriptor: %s\n",
pDoc->getDocUUIDString(), masterDescriptor.utf8_str()));
UT_return_val_if_fail(pDoc, NULL);
UT_return_val_if_fail(pAclAccount, NULL);
if (sSessionId == "")
{
XAP_App* pApp = XAP_App::getApp();
UT_UUID* pUUID = pApp->getUUIDGenerator()->createUUID();
pUUID->toString(sSessionId);
}
if (masterDescriptor != "")
{
// search for a buddy descriptor in the authors list that matches this
// descriptor, and make that the active author; if such an author does
// not exist, then search for an author with no abicollab property set
// at all, and give it this buddy descriptor (ie, we assume that it is
// "us", even though it might not always be a valid assumption).
int iAuthorId = -1;
UT_GenericVector<pp_Author*> authors = pDoc->getAuthors();
pp_Author* pEmptyAuthor = NULL;
UT_DEBUGMSG(("Scanning %d authors to see if we recognize this master buddy\n", authors.getItemCount()));
for (UT_sint32 i = 0; i < authors.getItemCount(); i++)
{
pp_Author* pAuthor = authors.getNthItem(i);
UT_continue_if_fail(pAuthor);
const gchar* szDescriptor = NULL;
pAuthor->getProperty("abicollab-descriptor", szDescriptor);
if (!szDescriptor)
{
if (!pEmptyAuthor && !pAuthor->getAttrProp()->hasProperties())
pEmptyAuthor = pAuthor;
continue;
}
if (masterDescriptor != szDescriptor)
continue;
// yay, we already editted this document ourselves!
iAuthorId = pAuthor->getAuthorInt();
pDoc->setMyAuthorInt(iAuthorId);
UT_DEBUGMSG(("Found our own author object with descriptior %s, id %d!\n", masterDescriptor.utf8_str(), iAuthorId));
break;
}
if (iAuthorId == -1)
{
if (pEmptyAuthor)
{
// reuse this author object and make it our own
iAuthorId = pEmptyAuthor->getAuthorInt();
PP_AttrProp * pPA = pEmptyAuthor->getAttrProp();
pPA->setProperty("abicollab-descriptor", masterDescriptor.utf8_str());
pDoc->setMyAuthorInt(iAuthorId);
pDoc->sendChangeAuthorCR(pEmptyAuthor);
UT_DEBUGMSG(("Reusing empty author object with id %d, setting descriptor to %s!\n", iAuthorId, masterDescriptor.utf8_str()));
}
else
{
UT_DEBUGMSG(("No suitable author found in the document for descriptor %s\n", masterDescriptor.utf8_str()));
iAuthorId = pDoc->findFirstFreeAuthorInt();
pp_Author * pA = pDoc->addAuthor(iAuthorId);
pDoc->setMyAuthorInt(iAuthorId);
PP_AttrProp * pPA = pA->getAttrProp();
pPA->setProperty("abicollab-descriptor", masterDescriptor.utf8_str());
pDoc->sendAddAuthorCR(pA);
UT_DEBUGMSG(("Added a new author to the documument with descriptor %s, id %d\n", masterDescriptor.utf8_str(), iAuthorId));
}
}
}
UT_DEBUGMSG(("Creating a new collaboration session with UUID: %s\n", sSessionId.utf8_str()));
UT_return_val_if_fail(_setupFrame(&pFrame, pDoc), NULL);
AbiCollab* pAbiCollab = new AbiCollab(pDoc, sSessionId, pAclAccount, bLocallyOwned);
m_vecSessions.push_back(pAbiCollab);
// notify all people we are sharing a new document
// FIXME: since we only allow a session to be shared on 1 account, we should
// only notify the buddies on that account, instead of notifying the buddies
// on all accounts.
StartSessionEvent event;
event.setBroadcast(true);
signal(event);
return pAbiCollab;
}