// writes ae desc data out to the stream void CNewHandleStream::WriteAEDescData( const AEDesc &inDesc) { Size byteCount=::AEGetDescDataSize(&inDesc); ExceptionCode err = noErr; SInt32 endOfWrite = GetMarker() + byteCount; if (endOfWrite > GetLength()) { // Need to grow Handle try { SetLength(endOfWrite); } catch (ExceptionCode inErr) { // Grow failed. Write only what fits. byteCount = GetLength() - GetMarker(); err = inErr; } catch (const LException& inException) { byteCount = GetLength() - GetMarker(); err = inException.GetErrorCode(); } } // Copy bytes into Handle if (byteCount > 0) { // Byte count will be zero if // mDataH is nil // ::BlockMoveData(inBuffer, *mDataH + GetMarker(), ioByteCount); UHandleLocker locked(mDataH); err=::AEGetDescData(&inDesc,*mDataH + GetMarker(), byteCount); SetMarker(byteCount, streamFrom_Marker); } ThrowIfOSErr_(err); }
Slider::Slider() : _orientation(ORIENTATION_HORIZONTAL), onValueChanged(0), _markerOffsetX(0), _markerOffsetY(0), _value(0), _minValue(0), _maxValue(0) { _marker = new Button(); AddChild(GetMarker()); GetMarker()->onMouseMove.bind(this, &Slider::MarkerOnMouseMove); GetMarker()->onMouseButtonDown.bind(this, &Slider::MarkerOnMouseButtonDown); }
Slider::Slider(tinyxml2::XMLElement* element, Control* parent) : Button(element, parent), _orientation(ORIENTATION_HORIZONTAL), onValueChanged(0), _markerOffsetX(0), _markerOffsetY(0), _value(0), _minValue(0), _maxValue(0) { _marker = new Button(); AddChild(GetMarker()); GetMarker()->onMouseMove.bind(this, &Slider::MarkerOnMouseMove); GetMarker()->onMouseButtonDown.bind(this, &Slider::MarkerOnMouseButtonDown); ReadProperties(element); }
void Slider::Render() { if (IsVisible()) { Button::Render(); GetMarker()->Render(); } }
static void DebugDeallocator(void* block, ALLOCATION_TYPE type) { void* realBlock = block? ToReal(block) : nullptr; if (realBlock) { auto Info = static_cast<MEMINFO*>(realBlock); assert(Info->AllocationType == type); assert(GetMarker(Info) == EndMarker); UnregisterBlock(Info); } free(realBlock); }
void ScrollBar::SetValue(int32_t value) { if (value < GetMinValue()) { value = GetMinValue(); } else if (value > GetMaxValue()) { value = GetMaxValue(); } _value = value; (onValueChanged != 0) ? onValueChanged(this) : OnValueChanged(); if (GetOrientation() == ORIENTATION_HORIZONTAL) { GetMarker()->SetX(static_cast<PosType>(GetMarkerOffsetX() + (Slider::GetWidth() - GetMarker()->GetWidth()) / ((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue())))); GetMarker()->SetY(GetMarkerOffsetY()); } else { GetMarker()->SetX(GetMarkerOffsetX()); GetMarker()->SetY(static_cast<PosType>(GetMarkerOffsetY() + (Slider::GetHeight() - GetMarker()->GetHeight()) / ((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue())))); } }
void Slider::SetValue(int value) { if (value < GetMinValue()) { value = GetMinValue(); } else if (value > GetMaxValue()) { value = GetMaxValue(); } _value = value; (onValueChanged != 0) ? onValueChanged(this) : OnValueChangedEvent(); if (GetOrientation() == ORIENTATION_VERTICAL) { GetMarker()->SetX(GetMarkerOffsetX()); GetMarker()->SetY(static_cast<sint>(GetMarkerOffsetY() + GetHeight() / ((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue())) - GetMarker()->GetHeight() / 2.0f)); } else { GetMarker()->SetX(static_cast<sint>(GetMarkerOffsetX() + GetWidth() / ((GetMaxValue() - GetMinValue()) / static_cast<float>(GetValue())) - GetMarker()->GetWidth() / 2.0f)); GetMarker()->SetY(GetMarkerOffsetY()); } }
void Slider::MarkerOnMouseMove(Control* control, int x, int y) { if (GetMarker()->IsPressed()) { if (GetOrientation() == ORIENTATION_VERTICAL) { SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / static_cast<float>(GetHeight() / static_cast<float>(y - GetAbsY())))); } else { SetValue(static_cast<int>((GetMaxValue() - GetMinValue()) / static_cast<float>(GetWidth() / static_cast<float>(x - GetAbsX())))); } } }
bool CVarDataFile::FindRecord(DatabaseRec *ioRecP, LComparator *inComparator) { #warning FIXME: pretty sure the loop below is broken and will stay stuck on the same record bool found = false; SInt32 slotSize; SInt32 recPos; ASSERT(mLargestRecSize > (SInt32)sizeof(DatabaseRec)); // this assertion will fail if no recs in file DatabaseRecPtr recP = (DatabaseRec*) std::malloc(mLargestRecSize); ThrowIfNil_(recP); if (NULL == inComparator) { inComparator = itsDefaultComparator; // use one of the comparators } SetMarker(mFirstItemPos + kVarDBFileSlotSizeOffset, streamFrom_Start); // move to start of the 1st record for (UInt32 i = 0; i<mItemCount; i++) { // look at all the records in the datafile recPos = GetMarker(); ReadBlock(&slotSize, kSizeOfSlotSize); // read the slot size into the pointer #if PLATFORM_LITTLE_ENDIAN slotSize = BigEndian32_ToNative(slotSize); #endif // PLATFORM_LITTLE_ENDIAN ReadBlock(&recP->recID, slotSize - kSizeOfSlotSize); // read the contents of the slot #if PLATFORM_LITTLE_ENDIAN recP->recID = BigEndian32_ToNative(recP->recID); #endif // PLATFORM_LITTLE_ENDIAN recP->recSize = SlotSizeToRecSize(slotSize); if (inComparator->IsEqualTo(ioRecP, recP, recP->recSize, recP->recSize) ) { // compare the current rec to the source еее CW 8 mod - added sizes found = true; ioRecP->recPos = recPos; // return the found recPos in the DatabaseRecPtr if (SlotSizeToRecSize(slotSize) < ioRecP->recSize) { ioRecP->recSize = SlotSizeToRecSize(slotSize); // return the found recSize in the DatabaseRecPtr } UInt8 *dst = (UInt8*)&ioRecP->recSize; UInt8 *src = (UInt8*)&recP->recSize; // include recSize & recID in copy for (SInt32 n = RecSizeToSlotSize(ioRecP->recSize); n>0; n--) { // copy the data to be returned *dst++ = *src++; } break; } } #if DB_DEBUG_MODE if (found && (ioRecP->recID > mLastRecID)) { DB_DEBUG("ERROR: Invalid Record ID "<<ioRecP->recID<<" returned. Last ID is "<<mLastRecID, DEBUG_ERROR); } #endif std::free(recP); // free the temporary buffer return found; // return true if found }
static void* DebugAllocator(size_t size, bool Noexcept, ALLOCATION_TYPE type,const char* Function, const char* File, int Line) { size_t realSize = GetRequiredSize(size); auto Info = static_cast<MEMINFO*>(malloc(realSize)); if (!Info) { if (Noexcept) return nullptr; else throw far_bad_alloc(File, Line, Function, type, size); } Info->AllocationType = type; Info->Size = realSize; Info->Function = Function; Info->File = File; Info->Line = Line; GetMarker(Info) = EndMarker; RegisterBlock(Info); return ToUser(Info); }
// return true if checks pass (or repairs successful) bool CVarDataFile::CheckDatabaseIntegrity(bool inRepairProblems) { // #warning never repairing problems in CheckDatabaseIntegrity // inRepairProblems = false; // we don't know that this works yet bool bResult = true; bool bRepairsWereAttempted = false; #warning FIXME: extensive checks completely disabled until user feedback provided for this long process bool bExtensiveChecks = false; //mFileIsDamaged; // always do extensive checks if we've detected problems try { if (IsReadOnly() && inRepairProblems) { inRepairProblems = false; // we don't know that this works yet DB_LOG("Integrity Check Warning: Database is read only"); } // load all items that are in the master index and validate them against the db contents long fileLen = GetLength(); if ((mAllocatedBytes + mFirstItemPos) != fileLen) { DB_LOG("INTEGRITY CHECK ERROR: Header thought file was "<<mAllocatedBytes<<" bytes long, but file is really " <<fileLen <<" bytes long"); if (inRepairProblems) { bRepairsWereAttempted = true; mAllocatedBytes = fileLen - mFirstItemPos; WriteHeader(kFileIsOpen); DB_LOG("Integrity Check Repair: Told header that file is " << fileLen << " bytes long"); } } long bytesUsed = mBytesUsed; if ( (bytesUsed < 0) || (bytesUsed > fileLen)) { bytesUsed = fileLen; } long largestSize = mLargestRecSize; if ( (largestSize < 0) || (largestSize > bytesUsed) ) { largestSize = bytesUsed; } // load all items that are in the master index and validate them against the db contents // we track an actualLargestSize as well as the largestSize, since the later refects a maximum // value that is physically possible, whereas the former tracks what we've found as we go through // the records long actualLargestRecSize = 0; long actualLargestSlotSize = 0; long numRecords = itsMasterIndex->GetEntryCount(); long lastIndex = numRecords; SInt32 slotSize = 0; RecIDT recID = kInvalidRecord; SInt32 recPos = 0; IndexEntryT entry; for (int i = lastIndex; i>=1; --i) { bool bBadIndexEntry = false; bool bBadSlotSize = false; slotSize = 0; try { itsMasterIndex->FetchEntryAt(i, entry); // can throw dbItemNotFound or read errors DB_DEBUG("Checking index entry "<<i<<": Record ID "<<entry.recID<<" size "<<entry.recSize <<" dbpos "<<entry.recPos, DEBUG_TRIVIA); SInt32 nextRecPos = 0; if (bExtensiveChecks) { // look at what the index thinks the next slot is if ( !itsMasterIndex->FindFirstSlotFromDatabasePos(entry.recPos+1L, nextRecPos) ) { // this is the last record, make sure we update bytesUsed as necessary // this should only happen once, might want to check that if (bytesUsed < (entry.recPos + entry.recSize)) { bytesUsed = entry.recPos + entry.recSize; if (bytesUsed > fileLen) { bytesUsed = fileLen; } } nextRecPos = bytesUsed; } } else { // since we aren't doing extensive checking, we don't actually know exactly where // the next record starts, but we know it isn't allowed to be closer than recSize // bytes away nextRecPos = entry.recPos + entry.recSize; } // extensive checks recID = kInvalidRecord; SetMarker(entry.recPos + kVarDBFileSlotSizeOffset, streamFrom_Start); ReadBlock(&slotSize, kSizeOfSlotSize); ReadBlock(&recID, kSizeOfRecID); #if PLATFORM_LITTLE_ENDIAN slotSize = BigEndian32_ToNative(slotSize); recID = BigEndian32_ToNative(recID); #endif // PLATFORM_LITTLE_ENDIAN if (recID != entry.recID) { DB_LOG("INTEGRITY CHECK ERROR: Bad Entry at index slot "<<i<<" dbpos "<<entry.recPos <<"; slot contains record id "<<recID<<" ("<<slotSize<<"B) but index expected record id " <<entry.recID<<" ("<<entry.recSize<<"B)"); bBadIndexEntry = true; } SInt32 nextRecOffset = nextRecPos - entry.recPos; if ( (slotSize < RecSizeToSlotSize(entry.recSize)) || ((entry.recPos + slotSize) > fileLen) ) { if (!bExtensiveChecks) { // we aren't doing extensive checks, so we don't know where the index believes the // next record needs to be. However, this information is crucial for a proper repair // so we will figure it out now if ( !itsMasterIndex->FindFirstSlotFromDatabasePos(entry.recPos+1L, nextRecPos) ) { // this is the last record, make sure we update bytesUsed as necessary // this should only happen once, might want to check that if (bytesUsed < (entry.recPos + entry.recSize)) { bytesUsed = entry.recPos + entry.recSize; if (bytesUsed > fileLen) { bytesUsed = fileLen; } } nextRecPos = bytesUsed; } } DB_LOG("INTEGRITY CHECK ERROR: Damaged database file, affects index entry "<<i<<" dbpos " <<entry.recPos<<"; slot for record id "<<recID<<" ("<<entry.recSize<<"B) is an impossible " <<slotSize<<" bytes, but it should be "<<nextRecOffset); bBadSlotSize = true; slotSize = nextRecOffset; } else if (bExtensiveChecks) { // these checks rely on the nextRecOffset being correct, which it might not be if // we aren't doing extensive checks. So we skip them. if (slotSize > nextRecOffset) { DB_LOG("INTEGRITY CHECK ERROR: Bad Entry at index slot "<<i<<" dbpos "<<entry.recPos <<"; index thinks record id "<<recID<<" ("<<entry.recSize <<"B) is at that position, co-located with next record at dbpos "<<nextRecPos <<" leaving only "<<nextRecOffset<<" bytes in this slot"); bBadIndexEntry = true; bBadSlotSize = true; slotSize = nextRecOffset; } else if (slotSize < nextRecOffset) { DB_LOG("INTEGRITY CHECK ERROR: Minor damage to database file, affects index entry "<<i<<" dbpos " <<entry.recPos<<"; slot for record id "<<recID<<" ("<<entry.recSize<<"B) should be " <<nextRecOffset<<" bytes, not " << slotSize); bBadSlotSize = true; slotSize = nextRecOffset; } } // update the largest record size if this was a good index entry if ( !bBadIndexEntry && (actualLargestRecSize < entry.recSize) ) { actualLargestRecSize = entry.recSize; } // calculate the largest slot size if ( actualLargestSlotSize < slotSize ) { actualLargestSlotSize = slotSize; } } // end Try catch (...) { DB_LOG("INTEGRITY CHECK ERROR: Exception reading entry at index slot "<<i<<" dbpos "<<entry.recPos); bBadIndexEntry = true; } // end Catch if (bBadIndexEntry) { bResult = false; if (inRepairProblems) { bRepairsWereAttempted = true; itsMasterIndex->DeleteEntry(entry.recID); --numRecords; DB_LOG("Integrity Check Repair: Deleted index entry for record " << entry.recID); // we don't mark the slot deleted because this could be part of an entirely // different record that is valid. Overwriting a zero into four bytes of it // would be damaging, so we don't screw with it /* // slot size is okay, so this is RecIDT deletedRecID = Native_ToBigEndian32(kInvalidRecord); SetMarker(entry.recPos + kVarDBFileRecIDOffset, streamFrom_Start); WriteBlock(&deletedRecID, kSizeOfRecID); DB_LOG("Integrity Check Repair: Deleted index entry and slot for record " << entry.recID); */ } } else if (bBadSlotSize) { // in this case, only the slot size was wrong, but the record pointed to the right // place, so we will try to update that. There is no guarantee that the data is good though, // most likely this was stomped by something else, but at least this seems to have a valid // record id tag bResult = false; if (inRepairProblems) { bRepairsWereAttempted = true; SetMarker(entry.recPos + kVarDBFileSlotSizeOffset, streamFrom_Start); SInt32 outSize = Native_ToBigEndian32(slotSize); WriteBlock(&outSize, kSizeOfSlotSize); DB_LOG("Integrity Check Repair: Updated slot size for record " << entry.recID << " at dbpos "<<entry.recPos<<" to " << slotSize << " bytes"); } } } // only do this if extensive checks have been done, since we are relying on all the slot sizes being // correct and the stuff above may have set some of them incorrectly. if (bExtensiveChecks) { // now that we know that the index is good, go through the database file and check // each item to see if it has a corresponding index entry. SetMarker(mFirstItemPos + kVarDBFileSlotSizeOffset, streamFrom_Start); // move to start of the 1st record while (true) { // look at all the records in the datafile slotSize = 0; recID = kInvalidRecord; recPos = GetMarker(); ReadBlock(&slotSize, kSizeOfSlotSize); // read the slot size into the pointer ReadBlock(&recID, kSizeOfRecID); // read the record id #if PLATFORM_LITTLE_ENDIAN slotSize = BigEndian32_ToNative(slotSize); recID = BigEndian32_ToNative(recID); #endif // PLATFORM_LITTLE_ENDIAN // basic checks: the slot size and recID reasonable? if ( (slotSize < 0) || (slotSize < (SInt32)RecSizeToSlotSize(sizeof(DatabaseRec))) || ((recID != kInvalidRecord) && (slotSize > (actualLargestRecSize + kSlotSizeSlop))) ) { DB_LOG("INTEGRITY CHECK ERROR: Slot at dbpos "<<recPos<<" is impossible ("<<slotSize<<"B)"); bResult = false; // scan index for the next record that comes right after this one. SInt32 nextRecPos = 0; itsMasterIndex->FindFirstSlotFromDatabasePos(recPos + kVarDBFileRecDataOffset, nextRecPos); slotSize = nextRecPos - recPos; if (inRepairProblems) { bRepairsWereAttempted = true; SetMarker(recPos + kVarDBFileSlotSizeOffset, streamFrom_Start); SInt32 outSize = Native_ToBigEndian32(slotSize); WriteBlock(&outSize, kSizeOfSlotSize); DB_LOG("Integrity Check Repair: Set slot size at dbpos "<<recPos<<" to "<<slotSize<<" bytes"); } } if ( (recID < 0) || (recID > mLastRecID) ) { DB_LOG("INTEGRITY CHECK ERROR: Slot at dbpos "<<recPos<<" has invalid record id ("<<recID<<")"); bResult = false; recID = kInvalidRecord; // this should be in the delete list, so we will check it in the next conditional if (inRepairProblems) { bRepairsWereAttempted = true; SetMarker(recPos + kVarDBFileRecIDOffset, streamFrom_Start); WriteBlock(&recID, kSizeOfRecID); // writing zero, don't worry about endian swap DB_LOG("Integrity Check Repair: Marked slot at dbpos "<<recPos<<" as deleted"); } } if (recID == 0) { if (!itsMasterIndex->CheckDeletedSlot(recPos, slotSize)) { DB_LOG("INTEGRITY CHECK ERROR: Slot at dbpos "<<recPos << " ("<<slotSize <<"B) is marked deleted but is not in delete list"); bResult = false; if (inRepairProblems) { bRepairsWereAttempted = true; // add this slot to the delete list CDeleteList* deleteList = itsMasterIndex->GetDeleteList(); deleteList->SlotWasDeleted(recPos, slotSize); DB_LOG("Integrity Check Repair: Added slot at dbpos "<<recPos<<" to delete list"); } } } else { try { itsMasterIndex->FetchEntry(recID, entry); if (entry.recPos != recPos) { DB_LOG("INTEGRITY CHECK ERROR: Slot at dbpos "<<recPos<<" for record id "<<recID <<" ("<<slotSize<<"B) has an index entry that says it should be at dbpos " <<entry.recPos); bResult = false; // Not sure how this could ever happen given the index validation // we already did. Perhaps via a duplicate entry in database file #warning TODO: repair dbpos wrong in index problem in CheckDatabaseIntegrity() } } catch (LException& e) { if (e.GetErrorCode() == dbItemNotFound) { DB_LOG("INTEGRITY CHECK ERROR: Slot at dbpos "<<recPos<<" for record id "<<recID <<" ("<<slotSize<<"B) has no index entry"); bResult = false; if (inRepairProblems) { bRepairsWereAttempted = true; recID = kInvalidRecord; // if it's not in the index, delete it, // we don't have any other choice because the index // insists we add things in order SetMarker(recPos + kVarDBFileRecIDOffset, streamFrom_Start); WriteBlock(&recID, kSizeOfRecID); // writing zero, don't worry about endian swap DB_LOG("Integrity Check Repair: Marked record "<< entry.recID <<" in slot at dbpos "<<recPos<<" as deleted"); } // end repair problems } // end (e.GetErrorCode() == dbItemNotFound) } // end catch } // end (recID != 0) if ( (recPos + slotSize) >= bytesUsed) { break; // break out of the while loop } SetMarker(recPos + slotSize, streamFrom_Start); // move to start of the next record } // end while loop #warning TODO: Perhaps rebuild delete list from scratch? } // end bExtensiveChecks // fix the record count in the header if ((long)mNumValidRecs != numRecords) { DB_LOG("INTEGRITY CHECK ERROR: Header has incorrect record count ("<<mNumValidRecs<<"); correct count is " <<numRecords); if (inRepairProblems) { bRepairsWereAttempted = true; mNumValidRecs = numRecords; WriteHeader(kFileIsOpen); DB_LOG("Integrity Check Repair: Set header record count to "<<mNumValidRecs); } } // fix the record count in the header if (mBytesUsed != bytesUsed) { DB_LOG("INTEGRITY CHECK ERROR: Header has incorrect bytes used ("<<mBytesUsed<<"); correct count is " <<bytesUsed); if (inRepairProblems) { bRepairsWereAttempted = true; mBytesUsed = bytesUsed; WriteHeader(kFileIsOpen); DB_LOG("Integrity Check Repair: Set header bytes used to "<<mBytesUsed); } } // fix the largest rec size in the header if (mLargestRecSize != actualLargestRecSize) { DB_LOG("INTEGRITY CHECK WARNING: Header has incorrect largest rec size ("<<mLargestRecSize <<"); correct largest size is " <<actualLargestRecSize); if (inRepairProblems) { mLargestRecSize = actualLargestRecSize; WriteHeader(kFileIsOpen); DB_LOG("Integrity Check Repair: Set header largest rec size to "<<mLargestRecSize); } } } // end main try block catch(...) { DB_LOG("INTEGRITY CHECK ERROR: Unexpected exception, failing check"); bResult = false; // unknown error, so we fail } // if there were problems found and we attempted to fix them, recheck if (bRepairsWereAttempted) { CMasterIndexFile* index = static_cast<CMasterIndexFile*>(itsMasterIndex); index->WriteHeader(kFileIsClosed); // this will update the delete list index->WriteHeader(kFileIsOpen); DB_LOG("================================================================================"); DB_LOG("INTEGRITY CHECK COMPLETE. Verifying Repairs."); DB_LOG("--------------------------------------------------------------------------------"); bResult = CheckDatabaseIntegrity(kCheckOnly); // will not attempt repair on this pass DB_LOG("================================================================================"); if (bResult == false) { mFileIsDamaged = true; WriteHeader(kFileIsOpen); DB_LOG("INTEGRITY CHECK FAILED. Marking file as damaged for extensive checks at next open."); } } else if (inRepairProblems) { DB_LOG("Integrity check passed."); } #warning TODO: Put the asserts below in the proper place or make them fix the file // haven't decided what to do with these yet ASSERT(mBytesUsed <= mAllocatedBytes); // can't use more than we've allocated ASSERT((mAllocatedBytes+mFirstItemPos) == GetLength()); // LFileStream needs to be in synch ASSERT(mAllocatedBytes >= (SInt32)(mItemCount*sizeof(DatabaseRec)));// recs must have at least a header return bResult; }
void Slider::ReadProperties(tinyxml2::XMLElement* element) { cchar* cstring = element->Attribute("orientation"); if (cstring != 0) { if (strcmp(cstring, "VERTICAL") == 0) { SetOrientation(ORIENTATION_VERTICAL); } else { SetOrientation(ORIENTATION_HORIZONTAL); } } cstring = element->Attribute("mOffsetX"); if (cstring != 0) SetMarkerOffsetX(xaih::StrToInt(cstring)); cstring = element->Attribute("mOffsetY"); if (cstring != 0) SetMarkerOffsetY(xaih::StrToInt(cstring)); cstring = element->Attribute("mW"); if (cstring != 0) { std::string string = cstring; if (string.compare("AUTO") == 0) { GetMarker()->SetAutoWidth(); } else if (*string.rbegin() == 'r') { GetMarker()->SetRatioWidth(xaih::StrToDouble(xaih::ParseString(string, "r").c_str())); } else { GetMarker()->SetWidth(xaih::StrToUInt(string.c_str())); } } else { GetMarker()->SetWidth(0); } cstring = element->Attribute("mH"); if (cstring != 0) { std::string string = cstring; if (string.compare("AUTO") == 0) { GetMarker()->SetAutoHeight(); } else if (*string.rbegin() == 'r') { GetMarker()->SetRatioHeight(xaih::StrToDouble(xaih::ParseString(string, "r").c_str())); } else { GetMarker()->SetHeight(xaih::StrToUInt(string.c_str())); } } else { GetMarker()->SetHeight(0); } cstring = element->Attribute("mSrcX"); if (cstring != 0) GetMarker()->SetSrcX(CONTROL_STATE_NORMAL, xaih::StrToUInt(cstring)); cstring = element->Attribute("mSrcY"); if (cstring != 0) GetMarker()->SetSrcY(CONTROL_STATE_NORMAL, xaih::StrToUInt(cstring)); cstring = element->Attribute("mhSrcX"); if (cstring != 0) { GetMarker()->SetSrcX(CONTROL_STATE_HOVER, xaih::StrToUInt(cstring)); } else { GetMarker()->SetSrcX(CONTROL_STATE_HOVER, GetMarker()->GetSrcX(CONTROL_STATE_NORMAL)); } cstring = element->Attribute("mhSrcY"); if (cstring != 0) { GetMarker()->SetSrcY(CONTROL_STATE_HOVER, xaih::StrToUInt(cstring)); } else { GetMarker()->SetSrcY(CONTROL_STATE_HOVER, GetMarker()->GetSrcY(CONTROL_STATE_NORMAL)); } cstring = element->Attribute("maSrcX"); if (cstring != 0) { GetMarker()->SetSrcX(CONTROL_STATE_ACTIVE, xaih::StrToUInt(cstring)); } else { GetMarker()->SetSrcX(CONTROL_STATE_ACTIVE, GetMarker()->GetSrcX(CONTROL_STATE_NORMAL)); } cstring = element->Attribute("maSrcY"); if (cstring != 0) { GetMarker()->SetSrcY(CONTROL_STATE_ACTIVE, xaih::StrToUInt(cstring)); } else { GetMarker()->SetSrcY(CONTROL_STATE_ACTIVE, GetMarker()->GetSrcY(CONTROL_STATE_NORMAL)); } cstring = element->Attribute("mdSrcX"); if (cstring != 0) { GetMarker()->SetSrcX(CONTROL_STATE_DISABLED, xaih::StrToUInt(cstring)); } else { GetMarker()->SetSrcX(CONTROL_STATE_DISABLED, GetMarker()->GetSrcX(CONTROL_STATE_NORMAL)); } cstring = element->Attribute("mdSrcY"); if (cstring != 0) { GetMarker()->SetSrcY(CONTROL_STATE_DISABLED, xaih::StrToUInt(cstring)); } else { GetMarker()->SetSrcY(CONTROL_STATE_DISABLED, GetMarker()->GetSrcY(CONTROL_STATE_NORMAL)); } cstring = element->Attribute("mSrcW"); if (cstring != 0) GetMarker()->SetSrcWidth(xaih::StrToUInt(cstring)); cstring = element->Attribute("mSrcH"); if (cstring != 0) GetMarker()->SetSrcHeight(xaih::StrToUInt(cstring)); cstring = element->Attribute("minValue"); if (cstring != 0) SetMinValue(xaih::StrToInt(cstring)); cstring = element->Attribute("maxValue"); if (cstring != 0) SetMaxValue(xaih::StrToInt(cstring)); cstring = element->Attribute("value"); if (cstring != 0) SetValue(xaih::StrToInt(cstring)); }
int ieJpegDecoder::ParseTables() // // Scan and process JPEG markers that can appear in any order // Return when an SOI, EOI, SOFn, or SOS is found // { for (;;) { int c = GetMarker(); switch (c) { case M_SOF0: case M_SOF1: case M_SOF2: case M_SOF3: case M_SOF5: case M_SOF6: case M_SOF7: case M_JPG: case M_SOF9: case M_SOF10: case M_SOF11: case M_SOF13: case M_SOF14: case M_SOF15: case M_SOI: case M_EOI: case M_SOS: return c; case M_DHT: if (!GetDHT()) return M_ERROR; break; case M_DAC: if (!GetDAC()) return M_ERROR; break; case M_DQT: if (!GetDQT()) return M_ERROR; break; case M_DRI: if (!GetDRI()) return M_ERROR; break; case M_RST0: case M_RST1: case M_RST2: case M_RST3: case M_RST4: case M_RST5: case M_RST6: case M_RST7: case M_TEM: break; case M_APP14: if (!GetAPP14()) return M_ERROR; break; case M_APP0: case M_APP1: case M_APP2: case M_APP3: case M_APP4: case M_APP5: case M_APP6: case M_APP7: case M_APP8: case M_APP9: case M_APP10: case M_APP11: case M_APP12: case M_APP13: case M_APP15: case M_COM: case M_DNL: // Ignore DNL ... perhaps the wrong thing pbStream += (GetWord() - 2); break; default: // Must be DHP, EXP, JPGn, or RESn // For now, we treat the reserved markers as fatal errors since they are // likely to be used to signal incompatible JPEG Part 3 extensions. return M_ERROR; } } }