/** * Traverses the vertical outer borders of the given render flow's line * boxes and appends the point coordinates to the given point array. * @param line line box to begin traversal * @param pointArray point array * @param left \c true, traverse the left vertical coordinates, * \c false, traverse the right vertical coordinates. * @param lastline if not 0, returns the pointer to the last line box traversed */ static void collectVerticalBoxCoordinates(InlineRunBox *line, QValueVector< QPoint > &pointArray, bool left, int offset, InlineRunBox **lastline = 0) { InlineRunBox *last = 0; offset = left ? -offset : offset; for(InlineRunBox *curr = line; curr && !last; curr = left ? curr->prevLineBox() : curr->nextLineBox()) { InlineBox *root = curr; bool isLast = lineBoxesDisjoint(curr, kAbs(offset), left); if(isLast) last = curr; if(root != line && !isLast) while(root->parent()) root = root->parent(); QPoint newPnt(curr->xPos() + !left * curr->width() + offset, (left ? root->topOverflow() : root->bottomOverflow()) + offset); if(!pointArray.isEmpty()) { QPoint lastPnt = pointArray.back(); if(newPnt.x() > lastPnt.x() && !left) pointArray.back().setY(kMin(lastPnt.y(), root->topOverflow() - offset)); else if(newPnt.x() < lastPnt.x() && left) pointArray.back().setY(kMax(lastPnt.y(), root->bottomOverflow() + offset)); QPoint insPnt(newPnt.x(), pointArray.back().y()); // kdDebug(6040) << "left: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl; appendPoint(pointArray, insPnt); } appendPoint(pointArray, newPnt); } if(lastline) *lastline = last; }
bool endElement( const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& /*qName*/ ) { cElement* element = elements.pop(); if ( --( levels.back() ) == 0 ) { // Ignore root return true; } if ( element == elements.current() ) { // Ignore include return true; } // Did we complete a parent node? if ( elements.current() == NULL ) { // Find a category node unsigned int i = 0; // Sort it into a category. while ( categories[i].name != 0 ) { if ( element->name() == categories[i].name ) { QString tagId = element->getAttribute( "id" ); // If the element has an id, if ( !tagId.isEmpty() ) { if ( impl->unique[categories[i].key].contains( tagId ) && !Config::instance()->overwriteDefinitions() ) { Console::instance()->log( LOG_WARNING, tr( "Duplicate %1: %2\n[File: %3, Line: %4]\n" ) .arg( element->name() ).arg( tagId ).arg( filenames.back() ).arg( locators.current()->lineNumber() ) ); delete element; } else { impl->unique[categories[i].key].insert( tagId, element, true ); } } else { impl->nonunique[categories[i].key].push_back( element ); } return true; } ++i; } Console::instance()->log( LOG_WARNING, tr( "Unknown element: %1\n[File: %2, Line: %3]\n" ) .arg( element->name() ).arg( filenames.back() ).arg( locators.current()->lineNumber() ) ); delete element; } return true; }
/** * Traverses the horizontal inline boxes and appends the point coordinates to * the given array. * @param box inline box * @param pointArray array collecting coordinates * @param bottom \c true, collect bottom coordinates, \c false, collect top * coordinates. * @param limit lower limit that an y-coordinate must at least reach. Note * that limit designates the highest y-coordinate for \c bottom, and * the lowest for !\c bottom. */ static void collectHorizontalBoxCoordinates(InlineBox *box, QValueVector< QPoint > &pointArray, bool bottom, int offset, int limit = -500000) { // kdDebug(6000) << "collectHorizontalBoxCoordinates: " << endl; offset = bottom ? offset : -offset; int y = box->yPos() + bottom * box->height() + offset; if(limit != -500000 && (bottom ? y < limit : y > limit)) y = limit; int x = box->xPos() + bottom * box->width() + offset; QPoint newPnt(x, y); // Add intersection point if point-array not empty. if(!pointArray.isEmpty()) { QPoint lastPnt = pointArray.back(); QPoint insPnt(newPnt.x(), lastPnt.y()); if(offset && ((bottom && lastPnt.y() > y) || (!bottom && lastPnt.y() < y))) { insPnt.rx() = lastPnt.x(); insPnt.ry() = y; } // kdDebug(6040) << "left: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl; appendPoint(pointArray, insPnt); } // Insert starting point of box appendPoint(pointArray, newPnt); newPnt.rx() += (bottom ? -box->width() : box->width()) - 2 * offset; if(box->isInlineFlowBox()) { InlineFlowBox *flowBox = static_cast< InlineFlowBox * >(box); for(InlineBox *b = bottom ? flowBox->lastChild() : flowBox->firstChild(); b; b = bottom ? b->prevOnLine() : b->nextOnLine()) { // Don't let boxes smaller than this flow box' height influence // the vertical position of the outline if they have a different // x-coordinate int l2; if(b->xPos() != box->xPos() && b->xPos() + b->width() != box->xPos() + box->width()) l2 = y; else l2 = limit; collectHorizontalBoxCoordinates(b, pointArray, bottom, kAbs(offset), l2); } // Add intersection point if flow box contained any children if(flowBox->firstChild()) { QPoint lastPnt = pointArray.back(); QPoint insPnt(lastPnt.x(), newPnt.y()); // kdDebug(6040) << "right: " << lastPnt << " == " << insPnt << ": " << (insPnt == lastPnt) << endl; appendPoint(pointArray, insPnt); } } // Insert ending point of box appendPoint(pointArray, newPnt); // kdDebug(6000) << "collectHorizontalBoxCoordinates: " << "ende" << endl; }
bool startElement( const QString& /*namespaceURI*/, const QString& localName, const QString& qName, const QXmlAttributes& atts ) { levels.back()++; // Ignore document root if ( levels.back() == 1 ) { if ( levels.isEmpty() ) { // Top level elements.push( NULL ); } else { // Within an include elements.push( elements.current() ); } return true; } // Include another file if ( qName == "include" ) { QString value = atts.value( "file" ); load( value ); elements.push( elements.current() ); return true; } cElement* element = new cElement; element->setName( localName.latin1() ); element->copyAttributes( atts ); // Child Element? if ( elements.current() != NULL ) { cElement* parent = elements.current(); // Pop the potential parent parent->addChild( element ); // Add the child to it's parent element->setParent( parent ); } else { Definitions::instance()->addElement(element); } elements.push( element ); // Push our element (there may be children) return true; }
/** * Appends the given coordinate-pair to the point-array if it is not * equal to the last element. * @param pointArray point-array * @param pnt point to append * @return \c true if \c pnt has actually been appended */ inline static bool appendIfNew(QValueVector< QPoint > &pointArray, const QPoint &pnt) { // if (!pointArray.isEmpty()) kdDebug(6040) << "appifnew: " << pointArray.back() << " == " << pnt << ": " << (pointArray.back() == pnt) << endl; // else kdDebug(6040) << "appifnew: " << pnt << " (unconditional)" << endl; if(!pointArray.isEmpty() && pointArray.back() == pnt) return false; pointArray.append(pnt); return true; }
bool fatalError( const QXmlParseException& exception ) { Console::instance()->log( LOG_ERROR, tr( "%1\n[File: %2, Line: %3, Column: %4]" ) .arg( exception.message(), filenames.back() ).arg( exception.lineNumber() ).arg( exception.columnNumber() ) ); return true; // continue }