int32_t DMGPartition::read(void* buf, int32_t count, uint64_t offset) { int32_t done = 0; while (done < count) { std::map<uint64_t, uint32_t>::iterator itRun = m_sectors.upper_bound((offset + done) / SECTOR_SIZE); uint64_t offsetInSector = 0; int32_t thistime; if (offset+done > length()) break; // read beyond EOF if (itRun == m_sectors.begin()) throw io_error("Invalid run sector data"); itRun--; // move to the sector we want to read //std::cout << "Reading from offset " << offset << " " << count << " bytes\n"; //std::cout << "Run sector " << itRun->first << " run index=" << itRun->second << std::endl; if (!done) offsetInSector = offset - itRun->first*SECTOR_SIZE; thistime = readRun(((char*)buf) + done, itRun->second, offsetInSector, count-done); if (!thistime) throw io_error("Unexpected EOF from readRun"); done += thistime; } return done; }
void DocxReader::readParagraph() { bool has_children = m_xml.readNextStartElement(); // Style paragraph bool changedstate = false; if (has_children && (m_xml.qualifiedName() == "w:pPr")) { changedstate = true; m_previous_styles.push(m_current_style); readParagraphProperties(m_current_style); } // Create paragraph if (!m_in_block) { m_cursor.insertBlock(m_current_style.block_format, m_current_style.char_format); m_in_block = true; } else { m_cursor.mergeBlockFormat(m_current_style.block_format); m_cursor.mergeBlockCharFormat(m_current_style.char_format); } // Read paragraph text if (has_children) { do { if (m_xml.qualifiedName() == "w:r") { readRun(); } else if (m_xml.tokenType() != QXmlStreamReader::EndElement) { m_xml.skipCurrentElement(); } } while (m_xml.readNextStartElement()); } m_in_block = false; // Reset paragraph styling if (changedstate) { m_current_style = m_previous_styles.pop(); } QCoreApplication::processEvents(); }