/******************************************************************************************** > virtual BOOL WizOpStyleRefRecordHandler::HandleRecord(CXaraFileRecord* pRecord) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 27/06/97 Purpose: Handles the given TAG_WIZOP record. Inputs: pCXaraFileRecord = ptr to record to handle Returns: TRUE if handled successfuly FALSE otherwise Errors: If pCXaraFileRecord isn't a TAG_WIZOP record ********************************************************************************************/ BOOL WizOpStyleRefRecordHandler::HandleRecord(CXaraFileRecord* pRecord) { ERROR2IF(pRecord == NULL,FALSE,"pCXaraFileRecord is NULL"); ERROR2IF(pRecord->GetTag() != TAG_WIZOP_STYLEREF, FALSE, "I don't handle this tag type"); XFileRef StyleRecordRef; BOOL Ok = pRecord->ReadINT32(&StyleRecordRef); if (Ok) { WizOpStyle* const pStyle = GetImportedStyles().FindStyleFromRecordReference(StyleRecordRef); if (pStyle != NULL) { // We managed to read it all OK so add a new StyleRefAttribute to the tree StyleReferenceAttribute* const pNewAttribute = new StyleReferenceAttribute(*pStyle); if (pNewAttribute != NULL) { Ok = InsertNode(pNewAttribute); } else { Ok = FALSE; } } else { BaseCamelotFilter* const pFilter = GetBaseCamelotFilter(); ENSURE_NOT_NULL(pFilter); pFilter->AppendWarning(_R(IDS_STYLE_NOT_FOUND)); } } return Ok; }
/******************************************************************************************* > virtual BOOL VisibleList::DeleteSelectedEntries() Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 09/06/97 Purpose: Deletes the selected entries in this list Returns: FALSE if it fails *******************************************************************************************/ BOOL VisibleList::DeleteSelectedEntries() { ENSURE_NOT_NULL(m_pUIElement); // Delete the selected argument from the used list and copy it to the available list INT32* pIndexes = NULL; BOOL Success = m_pUIElement->GetSelectedIndexes(&pIndexes); UINT32 ArrayIndex = 0; UINT32 EntriesDeleted = 0; while (Success && pIndexes[ArrayIndex] != -1) { const UINT32 IndexOfEntryToDelete = pIndexes[ArrayIndex] - EntriesDeleted; Success = DeleteEntryAtIndex(IndexOfEntryToDelete); ++EntriesDeleted; ++ArrayIndex; } if (pIndexes != NULL) { delete pIndexes; pIndexes = NULL; } return Success; }
int neo4j_ios_nonconst_writev_all(neo4j_iostream_t *stream, struct iovec *iov, unsigned int iovcnt, size_t *written) { assert(stream != NULL); assert(iov != NULL); assert(iovcnt > 0); ENSURE_NOT_NULL(size_t, written, 0); size_t total = iovlen(iov, iovcnt); if (total > SSIZE_MAX) { errno = EMSGSIZE; return -1; } *written = 0; do { ssize_t result = neo4j_ios_writev(stream, iov, iovcnt); if (result < 0 && errno == EINTR) { continue; } if (result < 0) { return -1; } *written += result; assert(*written <= total); iovcnt = iov_skip(iov, iov, iovcnt, result); } while (iovcnt > 0); assert(*written == total); return 0; }
int neo4j_ios_write_all(neo4j_iostream_t *stream, const void *buf, size_t nbyte, size_t *written) { assert(stream != NULL); assert(buf != NULL); assert(nbyte > 0); ENSURE_NOT_NULL(size_t, written, 0); if (nbyte > SSIZE_MAX) { errno = EMSGSIZE; return -1; } *written = 0; ssize_t result; do { result = neo4j_ios_write(stream, buf, nbyte); if (result < 0 && errno == EINTR) { continue; } if (result < 0) { // only partially written return -1; } assert((size_t)result <= nbyte); *written += result; buf = ((const uint8_t *)buf) + result; nbyte -= result; } while (nbyte > 0); return 0; }
/******************************************************************************************** > virtual VisibleAttribute* StyleReferenceAttribute::CreateVisibleAttribute() const Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 09/06/97 Purpose: Creates the user with something to look at in the Wizard Properties dialog Returns: A pointer to a new VisibleStyleReference (or NULL if not) ********************************************************************************************/ VisibleAttribute* StyleReferenceAttribute::CreateVisibleAttribute() const { ENSURE_NOT_NULL(Value.m_pStyle); ENSURE_KIND(Value.m_pStyle, WizOpStyle); const WizOpStyle& ActualStyle = (WizOpStyle&)*Value.m_pStyle; return new VisibleStyleReference(ActualStyle); }
/******************************************************************************************** > virtual BOOL StyleReferenceAttribute::CopyComponentData(BaseDocument* pSrcDoc, BaseDocument* pTargetDoc) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 09/06/97 Purpose: Ensures that the style to which this refers is in the target document. Inputs: pSrcDoc: The document from where this node was copied pTargetDoc: The document where this node lives Returns: FALSE if unable to copy data SeeAlso: NodeAttribute::CopyComponentData ********************************************************************************************/ BOOL StyleReferenceAttribute::CopyComponentData(BaseDocument* pSourceDoc, BaseDocument* pTargetDoc) { ENSURE_NOT_NULL(Value.m_pStyle); ENSURE_NOT_NULL(pSourceDoc); ENSURE_NOT_NULL(pTargetDoc); // Ask the base class to copy its data BOOL Ok = TemplateAttribute::CopyComponentData(pSourceDoc, pTargetDoc); // Get the style in our document WizOpStyles* pTargetStyles = NULL; if (Ok) { pTargetStyles = GetStylesForDoc(*pTargetDoc); Ok = (pTargetStyles != NULL); } if (Ok) { // Attempt to add the style that was in the old (source) document and to which this // StyleReferenceAttribute currently refers, to the new (target) document // If the new document already has a style of the same name, but different // characteristics it will return a style with a different name, which we will need // to use as our reference. ENSURE_KIND(Value.m_pStyle, WizOpStyle); const WizOpStyle& SourceStyle = (WizOpStyle&)*Value.m_pStyle; WizOpStyle* const pTargetStyle = (WizOpStyle*)pTargetStyles->CopyComponentData(SourceStyle); if (pTargetStyle != NULL) { SetStyle(*pTargetStyle); } else { Ok = FALSE; } } return Ok; }
int neo4j_ios_readv_all(neo4j_iostream_t *stream, const struct iovec *iov, unsigned int iovcnt, size_t *received) { assert(stream != NULL); assert(iov != NULL); assert(iovcnt > 0); ENSURE_NOT_NULL(size_t, received, 0); size_t total = iovlen(iov, iovcnt); if (total > SSIZE_MAX || iovcnt > IOV_MAX) { errno = EMSGSIZE; return -1; } // first try to read with the provided iovec ssize_t result; do { result = neo4j_ios_readv(stream, iov, iovcnt); } while (result < 0 && errno == EINTR); if (result < 0) { return -1; } *received = result; if ((size_t)result == total) { return 0; } if (result == 0) { errno = NEO4J_CONNECTION_CLOSED; return -1; } // read isn't complete - duplicate the iovec and do a nonconst read ALLOC_IOVEC(diov, iovcnt); if (diov == NULL) { return -1; } unsigned int diovcnt = iov_skip(diov, iov, iovcnt, *received); assert(diovcnt > 0); size_t additional; int r = neo4j_ios_nonconst_readv_all(stream, diov, diovcnt, &additional); int errsv = errno; *received += additional; FREE_IOVEC(diov); errno = errsv; return r; }
/******************************************************************************************** > Node* StyleReferenceAttribute::SimpleCopy() Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 27/06/97 Purpose: Creates a new copy of this StyleReferenceAttribute Returns: A new Node ********************************************************************************************/ Node* StyleReferenceAttribute::SimpleCopy() { ENSURE_NOT_NULL(Value.m_pStyle); ENSURE_KIND(Value.m_pStyle, WizOpStyle); WizOpStyle& TrueStyle = (WizOpStyle&)*Value.m_pStyle; StyleReferenceAttribute* pNodeCopy = new StyleReferenceAttribute(TrueStyle); ERRORIF(pNodeCopy == NULL, _R(IDE_NOMORE_MEMORY), NULL); CopyNodeContents(pNodeCopy); return pNodeCopy; }
int neo4j_ios_writev_all(neo4j_iostream_t *stream, const struct iovec *iov, unsigned int iovcnt, size_t *written) { assert(stream != NULL); assert(iov != NULL); assert(iovcnt > 0); ENSURE_NOT_NULL(size_t, written, 0); size_t total = iovlen(iov, iovcnt); if (total > SSIZE_MAX || iovcnt > IOV_MAX) { errno = EMSGSIZE; return -1; } // first try to write with the provided iovec ssize_t result; do { result = neo4j_ios_writev(stream, iov, iovcnt); } while (result < 0 && errno == EINTR); if (result < 0) { return -1; } *written = result; if ((size_t)result == total) { return 0; } // write isn't complete - duplicate the iovec and do a nonconst write ALLOC_IOVEC(diov, iovcnt); if (diov == NULL) { return -1; } assert(*written > 0); unsigned int diovcnt = iov_skip(diov, iov, iovcnt, *written); assert(diovcnt > 0); size_t additional; int n = neo4j_ios_nonconst_writev_all(stream, diov, diovcnt, &additional); *written += additional; FREE_IOVEC(diov); return n; }
/******************************************************************************************** > virtual BOOL StyleReferenceAttribute::WritePreChildrenWeb(BaseCamelotFilter* pFilter) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 09/06/97 Purpose: Writes this StyleReferenceAttribute via the given filter. Inputs: pFilter: The filter to use Returns: FALSE if it failed Notes: this StyleReferenceAttribute attempts to write the referenced style out first. ********************************************************************************************/ BOOL StyleReferenceAttribute::WritePreChildrenWeb(BaseCamelotFilter* pFilter) { #ifdef DO_EXPORT ENSURE_NOT_NULL(Value.m_pStyle); ERROR2IF(pFilter == NULL,FALSE,"NULL filter param"); // Must write out the style first ENSURE_KIND(Value.m_pStyle, WizOpStyle); const WizOpStyle& ActualStyle = (WizOpStyle&)*Value.m_pStyle; WizOpStyles* const pStyles = GetStylesForFilter(*pFilter); BOOL Ok = (pStyles != NULL); XFileRef RecordRef = 0; if (Ok) { RecordRef = pStyles->GetRecordRefForStyle(ActualStyle); // Is the style reference ok? Ok = (RecordRef != 0); } if (Ok) { // Add a description of the TAG_WIZOP_STYLEREF record for older importers pFilter->AddTagDescription(TAG_WIZOP_STYLEREF, _R(IDS_TAG_WIZOP_STYLEREF)); } if (Ok) { CamelotFileRecord Rec(pFilter, TAG_WIZOP_STYLEREF, TAG_WIZOP_STYLEREF_SIZE); if (Ok) Ok = Rec.Init(); if (Ok) Ok = Rec.WriteReference(RecordRef); if (Ok) Ok = pFilter->Write(&Rec); } if (!Ok) pFilter->GotError(_R(IDE_FILE_WRITE_ERROR)); return Ok; #else return FALSE; #endif }
int neo4j_ios_read_all(neo4j_iostream_t *stream, void *buf, size_t nbyte, size_t *received) { assert(stream != NULL); assert(buf != NULL); assert(nbyte > 0); ENSURE_NOT_NULL(size_t, received, 0); if (nbyte > SSIZE_MAX) { errno = EMSGSIZE; return -1; } *received = 0; ssize_t result; do { result = neo4j_ios_read(stream, buf, nbyte); if (result < 0 && errno == EINTR) { continue; } if (result < 0) { // only partially received return -1; } if (result == 0 && nbyte > 0) { errno = NEO4J_CONNECTION_CLOSED; return -1; } assert((size_t)result <= nbyte); *received += result; buf = ((uint8_t *)buf) + result; nbyte -= result; } while (nbyte > 0); return 0; }
int neo4j_ios_nonconst_readv_all(neo4j_iostream_t *stream, struct iovec *iov, unsigned int iovcnt, size_t *received) { assert(stream != NULL); assert(iov != NULL); assert(iovcnt > 0); ENSURE_NOT_NULL(size_t, received, 0); size_t total = iovlen(iov, iovcnt); if (total > SSIZE_MAX) { errno = EMSGSIZE; return -1; } *received = 0; do { ssize_t result = neo4j_ios_readv(stream, iov, iovcnt); if (result < 0 && errno == EINTR) { continue; } if (result < 0) { return -1; } if (result == 0 && total > 0) { errno = NEO4J_CONNECTION_CLOSED; return -1; } *received += result; assert(*received <= total); iovcnt = iov_skip(iov, iov, iovcnt, result); } while (iovcnt > 0); assert(*received == total); return 0; }
/******************************************************************************************** > virtual BOOL TemplateAttrRecordHandler::HandleRecord(CXaraFileRecord* pCXaraFileRecord) Author: Colin_Barfoot (Xara Group Ltd) <*****@*****.**> Created: 27/06/97 Purpose: Handles the given TAG_WIZOP record. Inputs: pCXaraFileRecord = ptr to record to handle Returns: TRUE if handled successfuly FALSE otherwise Errors: If pCXaraFileRecord isn't a TAG_WIZOP record ********************************************************************************************/ BOOL TemplateAttrRecordHandler::HandleRecord(CXaraFileRecord* pRecord) { ERROR2IF(pRecord == NULL,FALSE,"pCXaraFileRecord is NULL"); ERROR2IF(pRecord->GetTag() != TAG_WIZOP, FALSE, "I don't handle this tag type"); String_64 OpName; String_256 Question; String_256 Param; String_256 PatchSpace; BOOL ok = pRecord->ReadUnicode(OpName, 64); if (ok) { ok = pRecord->ReadUnicode(Question, 256); } if (ok) { ok = pRecord->ReadUnicode(Param, 256); } if (ok) { ok = pRecord->ReadUnicode(PatchSpace, 256); } BaseCamelotFilter* pFilter = GetBaseCamelotFilter(); if (ok) { NodeSetSentinel * pNodeSetSentinel = pFilter->GetDocument()->GetSetSentinel(); if (pNodeSetSentinel) { Node * pContextNode = pFilter->GetInsertContextNode(); // dont add the attrib if it is a duplicate and it is in the sentinel if ((pNodeSetSentinel != pContextNode->FindParent() && pNodeSetSentinel != pContextNode ) || SliceHelper::LookupNameGalleryItem(Param) == NULL) { // We managed to read it all OK so add a new TemplateAttribute to the tree TemplateAttribute* pNewAttribute = new TemplateAttribute(OpName, Question, Param); ok = (pNewAttribute != 0) && InsertNode(pNewAttribute); // JCF: Web files don't include records for the NodeSetSentinel or its child // ObjectName attributes, so make sure that a copy of the TemplateAttribute // is inserted as a child of the sentinel as well, if there isn't one already // in place. if (ok && pNewAttribute->IsAnObjectName()) { // Register/insert the imported ObjectName with the doc's NodeSetSentinel. ok = pNodeSetSentinel->OnLoadName(pFilter, pNewAttribute); } } } } if (!ok) { ENSURE_NOT_NULL(pFilter); pFilter->GotError(_R(IDE_FILE_READ_ERROR)); } return ok; }