void TLib::loadIndex() { uint16 resNum, configId, fileOffset; // Load the root resources section loadSection(0); // Get the single resource from it const byte *pData = getResource(0); const byte *p = pData; _sections.clear(); // Loop through reading the entries while ((resNum = READ_LE_UINT16(p)) != 0xffff) { configId = READ_LE_UINT16(p + 2); fileOffset = READ_LE_UINT16(p + 4); p += 6; SectionEntry se; se.resNum = resNum; se.resType = (ResourceType)(configId & 0x1f); se.fileOffset = (((configId >> 5) & 0x7ff) << 16) | fileOffset; _sections.push_back(se); } _memoryManager.deallocate(pData); }
//----------------------------------------------------------------------------------------------------- void Section::fadeUpdate(){ if(fadeInFlag) { fadeOverlayAlpha+=fadeStep; if (fadeOverlayAlpha> 255) { fadeInFlag = false; fadeOveylayOn= true; fadeOverlayAlpha = 255; try { loadSection(nextSection); } catch( std::exception& e) { std::cout << " IN BERKELIUM UPDATE EVETN" << e.what() << "'\n"; } } } else if (fadeOutFlag) { fadeOverlayAlpha-=fadeStep; if (fadeOverlayAlpha< 0) { fadeOutFlag = false; fadeOveylayOn= false; for(int i =0;i< screens;i++) { screensVector[i]->overlaySetDraw(false); } fadeOverlayAlpha = 0; } } }
void FourSectionDictionary::import(Dictionary *other, ProgressListener *listener) { try { IntermediateListener iListener(listener); NOTIFY(listener, "DictionaryPFC loading subjects", 0, 100); iListener.setRange(0, 20); IteratorUCharString *itSubj = other->getSubjects(); delete subjects; subjects = loadSection(itSubj, blocksize, &iListener); delete itSubj; NOTIFY(listener, "DictionaryPFC loading predicates", 25, 30); iListener.setRange(20, 21); IteratorUCharString *itPred = other->getPredicates(); delete predicates; predicates = loadSection(itPred, blocksize, &iListener); delete itPred; NOTIFY(listener, "DictionaryPFC loading objects", 30, 90); iListener.setRange(21, 90); IteratorUCharString *itObj = other->getObjects(); delete objects; objects = loadSection(itObj, blocksize, &iListener); delete itObj; NOTIFY(listener, "DictionaryPFC loading shared", 90, 100); iListener.setRange(90, 100); IteratorUCharString *itShared = other->getShared(); delete shared; shared = loadSection(itShared, blocksize, &iListener); delete itShared; this->sizeStrings = other->size(); this->mapping = other->getMapping(); } catch (const char *e) { delete subjects; delete predicates; delete objects; delete shared; subjects = new csd::CSD_PFC(); predicates = new csd::CSD_PFC(); objects = new csd::CSD_PFC(); shared = new csd::CSD_PFC(); throw e; } }
// --------------------------------------------------------------------- // Loads the symbol for the subcircuit from the schematic file and // returns the number of painting elements. int LibComp::loadSymbol() { int z, Result; QString FileString, Line; z = loadSection("Symbol", FileString); if(z < 0) { if(z != -7) return z; // If library component not defined as subcircuit, then load // new component and transfer data to this component. z = loadSection("Model", Line); if(z < 0) return z; Component *pc = getComponentFromName(Line); if(pc == 0) return -20; copyComponent(pc); pc->Props.setAutoDelete(false); delete pc; return 1; } z = 0; x1 = y1 = INT_MAX; x2 = y2 = INT_MIN; QTextStream stream(&FileString, QIODevice::ReadOnly); while(!stream.atEnd()) { Line = stream.readLine(); Line = Line.trimmed(); if(Line.isEmpty()) continue; if(Line.at(0) != '<') return -11; if(Line.at(Line.length()-1) != '>') return -12; Line = Line.mid(1, Line.length()-2); // cut off start and end character Result = analyseLine(Line, 2); if(Result < 0) return -13; // line format error z += Result; } x1 -= 4; x2 += 4; // enlarge component boundings a little y1 -= 4; y2 += 4; return z; // return number of ports }
// ------------------------------------------------------- bool LibComp::createSubNetlist(QTextStream *stream, QStringList &FileList, int type) { int r = -1; QString FileString; QStringList Includes; if(type&1) { r = loadSection("Model", FileString, &Includes); } else if(type&2) { r = loadSection("VHDLModel", FileString, &Includes); } else if(type&4) { r = loadSection("VerilogModel", FileString, &Includes); } if(r < 0) return false; // also include files int error = 0; for(QStringList::Iterator it = Includes.begin(); it != Includes.end(); ++it ) { QString s = getSubcircuitFile()+"/"+*it; if(FileList.findIndex(s) >= 0) continue; FileList.append(s); // load file and stuff into stream QFile file(s); if(!file.open(QIODevice::ReadOnly)) { error++; } else { QByteArray FileContent = file.readAll(); file.close(); //?stream->writeRawBytes(FileContent.data(), FileContent.size()); (*stream) << FileContent.data(); qDebug() << "hi from libcomp"; } } (*stream) << "\n" << FileString << "\n"; return error > 0 ? false : true; }
/** * Finds the correct section and loads the specified resource within it */ byte *TLib::getResource(ResourceType resType, uint16 resNum, uint16 rlbNum, bool suppressErrors) { SectionList::iterator i = _sections.begin(); while ((i != _sections.end()) && ((*i).resType != resType || (*i).resNum != resNum)) ++i; if (i == _sections.end()) { if (suppressErrors) return NULL; error("Unknown resource type %d num %d", resType, resNum); } loadSection((*i).fileOffset); return getResource(rlbNum, suppressErrors); }
bool Configurator::loadSettingsFile() { // check if we can read the file QFile configurationFile( _configurationFileName ); if( false == configurationFile.open(QIODevice::ReadOnly) ) return false; // loading settings file into memory if( false == _domDocument.setContent(&configurationFile) ) { configurationFile.close(); return false; } configurationFile.close(); // validating the root node QDomNode configurator = _domDocument.documentElement(); if( configurator.isNull() ) return false; if( configurator.nodeName() != c_configuratorNodeName ) return false; if( false == configurator.hasChildNodes() ) return false; // set title text QDomNamedNodeMap configuratorAttributes = configurator.attributes(); setWindowTitle( configuratorAttributes.namedItem(c_attributeTitleText).nodeValue() ); // validating and adding the sections nodes QDomNode section = configurator.firstChild(); while( false == section.isNull() ) { if( QDomNode::CommentNode != section.nodeType() ) if( false == loadSection(section) ) return false; section = section.nextSibling(); } return true; }
void KoTextLoader::loadBody(const KoXmlElement &bodyElem, QTextCursor &cursor) { const QTextBlockFormat defaultBlockFormat = cursor.blockFormat(); const QTextCharFormat defaultCharFormat = cursor.charFormat(); const QTextDocument *document = cursor.block().document(); d->styleManager = KoTextDocument(document).styleManager(); Q_ASSERT(d->styleManager); d->changeTracker = KoTextDocument(document).changeTracker(); // if (!d->changeTracker) // d->changeTracker = dynamic_cast<KoChangeTracker *>(d->context.dataCenterMap().value("ChangeTracker")); // Q_ASSERT(d->changeTracker); kDebug(32500) << "text-style:" << KoTextDebug::textAttributes( cursor.blockCharFormat() ); #if 0 if ((document->isEmpty()) && (d->styleManager)) { QTextBlock block = cursor.block(); d->styleManager->defaultParagraphStyle()->applyStyle(block); } #endif startBody(KoXml::childNodesCount(bodyElem)); KoXmlElement tag; bool usedParagraph = false; // set to true if we found a tag that used the paragraph, indicating that the next round needs to start a new one. forEachElement(tag, bodyElem) { if (! tag.isNull()) { const QString localName = tag.localName(); if (tag.namespaceURI() == KoXmlNS::text) { if (usedParagraph) cursor.insertBlock(defaultBlockFormat, defaultCharFormat); usedParagraph = true; if (d->changeTracker && localName == "tracked-changes") { d->changeTracker->loadOdfChanges(tag); usedParagraph = false; } else if (d->changeTracker && localName == "change-start") { loadChangedRegion(tag, cursor); usedParagraph = false; } else if (d->changeTracker && localName == "change-end") { d->currentChangeId = 0; usedParagraph = false; } else if (localName == "p") { // text paragraph loadParagraph(tag, cursor); } else if (localName == "h") { // heading loadHeading(tag, cursor); } else if (localName == "unordered-list" || localName == "ordered-list" // OOo-1.1 || localName == "list" || localName == "numbered-paragraph") { // OASIS loadList(tag, cursor); } else if (localName == "section") { // Temporary support (###TODO) loadSection(tag, cursor); } else { KoVariable *var = KoVariableRegistry::instance()->createFromOdf(tag, d->context); if (var) { KoTextDocumentLayout *layout = dynamic_cast<KoTextDocumentLayout*>(cursor.block().document()->documentLayout()); if (layout) { KoInlineTextObjectManager *textObjectManager = layout->inlineTextObjectManager(); if (textObjectManager) { KoVariableManager *varManager = textObjectManager->variableManager(); if (varManager) { textObjectManager->insertInlineObject(cursor, var); } } } } else { usedParagraph = false; kWarning(32500) << "unhandled text:" << localName; } } } else if (tag.namespaceURI() == KoXmlNS::draw) { loadShape(tag, cursor); } else if (tag.namespaceURI() == KoXmlNS::table) { if (localName == "table") { loadTable(tag, cursor); } else { kWarning(32500) << "unhandled table:" << localName; } #if 0 // TODO commented out for now if (localName == "table") { cursor.insertText("\n"); cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1); QTextTable *tbl = cursor.insertTable(1, 1); int rows = 0; int columns = 0; kDebug(32500) << "Table inserted"; KoXmlElement tblTag; forEachElement(tblTag, tag) { if (! tblTag.isNull()) { const QString tblLocalName = tblTag.localName(); if (tblTag.namespaceURI() == KoXmlNS::table) { if (tblLocalName == "table-column") { // Do some parsing with the column, see §8.2.1, ODF 1.1 spec int repeatColumn = tblTag.attributeNS(KoXmlNS::table, "number-columns-repeated", "1").toInt(); columns = columns + repeatColumn; if (rows > 0) tbl->resize(rows, columns); else tbl->resize(1, columns); } else if (tblLocalName == "table-row") { // Lot of work to do here... rows++; if (columns > 0) tbl->resize(rows, columns); else tbl->resize(rows, 1); // Added a row int currentCell = 0; KoXmlElement rowTag; forEachElement(rowTag, tblTag) { if (!rowTag.isNull()) { const QString rowLocalName = rowTag.localName(); if (rowTag.namespaceURI() == KoXmlNS::table) { if (rowLocalName == "table-cell") { // Ok, it's a cell... const int currentRow = tbl->rows() - 1; QTextTableCell cell = tbl->cellAt(currentRow, currentCell); if (cell.isValid()) { cursor = cell.firstCursorPosition(); loadBody(context, rowTag, cursor); } else kDebug(32500) << "Invalid table-cell row=" << currentRow << " column=" << currentCell; currentCell++; } } } } } } } } cursor = tbl->lastCursorPosition(); cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, 1); } else { kWarning(32500) << "KoTextLoader::loadBody unhandled table::" << localName; } #endif }