bool KoTosContainer::loadText(const KoXmlElement &element, KoShapeLoadingContext &context) { Q_D(const KoTosContainer); KoXmlElement child; forEachElement(child, element) { // only recreate the text shape if there's something to be loaded if (child.localName() == "p" || child.localName() == "list") { KoShape *textShape = createTextShape(context.documentResourceManager()); if (!textShape) { return false; } //apply the style properties to the loaded text setTextAlignment(d->alignment); // In the case of text on shape, we cannot ask the text shape to load // the odf, since it expects a complete document with style info and // everything, so we have to use the KoTextShapeData object instead. KoTextShapeDataBase *shapeData = qobject_cast<KoTextShapeDataBase*>(textShape->userData()); Q_ASSERT(shapeData); shapeData->loadStyle(element, context); bool loadOdf = shapeData->loadOdf(element, context); return loadOdf; } } return true; }
bool KoPathShape::loadOdf(const KoXmlElement & element, KoShapeLoadingContext &context) { loadOdfAttributes(element, context, OdfMandatories | OdfAdditionalAttributes | OdfCommonChildElements); // first clear the path data from the default path clear(); if (element.localName() == "line") { QPointF start; start.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x1", ""))); start.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y1", ""))); QPointF end; end.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x2", ""))); end.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y2", ""))); moveTo(start); lineTo(end); } else if (element.localName() == "polyline" || element.localName() == "polygon") { QString points = element.attributeNS(KoXmlNS::draw, "points").simplified(); points.replace(',', ' '); points.remove('\r'); points.remove('\n'); bool firstPoint = true; const QStringList coordinateList = points.split(' '); for (QStringList::ConstIterator it = coordinateList.constBegin(); it != coordinateList.constEnd(); ++it) { QPointF point; point.setX((*it).toDouble()); ++it; point.setY((*it).toDouble()); if (firstPoint) { moveTo(point); firstPoint = false; } else lineTo(point); } if (element.localName() == "polygon") close(); } else { // path loading KoPathShapeLoader loader(this); loader.parseSvg(element.attributeNS(KoXmlNS::svg, "d"), true); loadNodeTypes(element); } applyViewboxTransformation(element); QPointF pos = normalize(); setTransformation(QMatrix()); if (element.hasAttributeNS(KoXmlNS::svg, "x") || element.hasAttributeNS(KoXmlNS::svg, "y")) { pos.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x", QString()))); pos.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y", QString()))); } setPosition(pos); loadOdfAttributes(element, context, OdfTransformation); return true; }
bool StarShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext &context) const { Q_UNUSED(context); if (e.localName() == "regular-polygon" && e.namespaceURI() == KoXmlNS::draw) { return true; } return (e.localName() == "custom-shape" && e.namespaceURI() == KoXmlNS::draw && e.attributeNS(KoXmlNS::draw, "engine", "") == "calligra:star"); }
bool KoInlineNote::loadOdf(const KoXmlElement & element, KoShapeLoadingContext &context, KoStyleManager *styleManager, KoChangeTracker *changeTracker) { QTextDocument *document = new QTextDocument(); QTextCursor cursor(document); KoTextDocument textDocument(document); textDocument.setStyleManager(styleManager); d->styleManager = styleManager; textDocument.setChangeTracker(changeTracker); KoTextLoader loader(context); if (element.namespaceURI() == KoXmlNS::text && element.localName() == "note") { QString className = element.attributeNS(KoXmlNS::text, "note-class"); if (className == "footnote") { d->type = Footnote; } else if (className == "endnote") { d->type = Endnote; } else { delete document; return false; } d->id = element.attributeNS(KoXmlNS::text, "id"); for (KoXmlNode node = element.firstChild(); !node.isNull(); node = node.nextSibling()) { setAutoNumbering(false); KoXmlElement ts = node.toElement(); if (ts.namespaceURI() != KoXmlNS::text) continue; if (ts.localName() == "note-body") { loader.loadBody(ts, cursor); } else if (ts.localName() == "note-citation") { d->label = ts.attributeNS(KoXmlNS::text, "label"); if (d->label.isEmpty()) { setAutoNumbering(true); d->label = ts.text(); } } } } else if (element.namespaceURI() == KoXmlNS::office && element.localName() == "annotation") { d->author = element.attributeNS(KoXmlNS::text, "dc-creator"); d->date = QDateTime::fromString(element.attributeNS(KoXmlNS::text, "dc-date"), Qt::ISODate); loader.loadBody(element, cursor); // would skip author and date, and do just the <text-p> and <text-list> elements } else { delete document; return false; } d->text = QTextDocumentFragment(document); delete document; return true; }
bool KoEnhancedPathShape::loadOdf( const KoXmlElement & element, KoShapeLoadingContext &context ) { reset(); KoXmlElement child; forEachElement( child, element ) { if( child.localName() == "enhanced-geometry" && child.namespaceURI() == KoXmlNS::draw ) { // load the viewbox QRectF viewBox = loadOdfViewbox( child ); if( ! viewBox.isEmpty() ) m_viewBox = viewBox; // load the modifiers QString modifiers = child.attributeNS( KoXmlNS::draw, "modifiers", "" ); if( ! modifiers.isEmpty() ) { addModifiers( modifiers ); } KoXmlElement grandChild; forEachElement( grandChild, child ) { if( grandChild.namespaceURI() != KoXmlNS::draw ) continue; if( grandChild.localName() == "equation" ) { QString name = grandChild.attributeNS( KoXmlNS::draw, "name" ); QString formula = grandChild.attributeNS( KoXmlNS::draw, "formula" ); addFormula( name, formula ); } else if( grandChild.localName() == "handle" ) { KoEnhancedPathHandle * handle = new KoEnhancedPathHandle( this ); if( handle->loadOdf( grandChild ) ) { m_enhancedHandles.append( handle ); evaluateHandles(); } else delete handle; } } // load the enhanced path data QString path = child.attributeNS( KoXmlNS::draw, "enhanced-path", "" ); #ifndef NWORKAROUND_ODF_BUGS KoOdfWorkaround::fixEnhancedPath(path, child, context); #endif if ( !path.isEmpty() ) { parsePathData( path ); } } }
bool KoFormulaShapeFactory::supports(const KoXmlElement& e, KoShapeLoadingContext &context) const { Q_UNUSED(context); bool retval = ((e.localName() == "math" && e.namespaceURI() == KoXmlNS::math) || (e.localName() == "object" && e.namespaceURI() == KoXmlNS::draw)); // Should be 39001 (kformula) instead of 31000 (koffice) //kDebug(31000) << e.nodeName() << " - "<< e.namespaceURI(); //kDebug(31000) << "Return value = " << retval; return retval; }
bool PictureShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext &context) const { if (e.localName() == "image" && e.namespaceURI() == KoXmlNS::draw) { QString href = e.attribute("href"); if (!href.isEmpty()) { // check the mimetype if (href.startsWith(QLatin1String("./"))) { href.remove(0, 2); } QString mimetype = context.odfLoadingContext().mimeTypeForPath(href); if (!mimetype.isEmpty()) { return mimetype.startsWith("image"); } else { return ( href.endsWith("bmp") || href.endsWith("jpg") || href.endsWith("gif") || href.endsWith("eps") || href.endsWith("png") || href.endsWith("tif") || href.endsWith("tiff")); } } else { return !KoXml::namedItemNS(e, KoXmlNS::office, "binary-data").isNull(); } } return false; }
bool DocBase::loadOdf(KoOdfReadStore & odfStore) { QPointer<KoUpdater> updater; if (progressUpdater()) { updater = progressUpdater()->startSubtask(1, "KSpread::Doc::loadOdf"); updater->setProgress(0); } d->spellListIgnoreAll.clear(); KoXmlElement content = odfStore.contentDoc().documentElement(); KoXmlElement realBody(KoXml::namedItemNS(content, KoXmlNS::office, "body")); if (realBody.isNull()) { setErrorMessage(i18n("Invalid OASIS OpenDocument file. No office:body tag found.")); map()->deleteLoadingInfo(); return false; } KoXmlElement body = KoXml::namedItemNS(realBody, KoXmlNS::office, "spreadsheet"); if (body.isNull()) { kError(32001) << "No office:spreadsheet found!" << endl; KoXmlElement childElem; QString localName; forEachElement(childElem, realBody) { localName = childElem.localName(); } if (localName.isEmpty()) setErrorMessage(i18n("Invalid OASIS OpenDocument file. No tag found inside office:body.")); else setErrorMessage(i18n("This document is not a spreadsheet, but %1. Please try opening it with the appropriate application." , KoDocument::tagNameToDocumentType(localName))); map()->deleteLoadingInfo(); return false; }
bool VectorShapeFactory::supports(const KoXmlElement & e, KoShapeLoadingContext &context) const { if (e.localName() == "image" && e.namespaceURI() == KoXmlNS::draw) { QString href = e.attribute("href"); if (!href.isEmpty()) { // check the mimetype if (href.startsWith(QLatin1String("./"))) { href.remove(0, 2); } // LO 3.5 does not write a mimetype for embedded wmf files, so guess also from content const QString mimetype = context.odfLoadingContext().mimeTypeForPath(href, true); return mimetype == QLatin1String("image/x-svm") || mimetype == QLatin1String("image/x-emf") || mimetype == QLatin1String("image/x-wmf") || // Note: the Vector Shape supports SVG, but _NOT_ in this method, otherwise it will stomp all over loading the artistic text shape's svg //mimetype == QLatin1String("image/svg+xml") || // next three for backward compatibility with Calligra mimetype == QLatin1String("application/x-svm") || mimetype == QLatin1String("application/x-emf") || mimetype == QLatin1String("application/x-wmf") || // seems like MSO does not always write a mimetype // see jeffcoweb.jeffco.k12.co.us%2Fhigh%2Fchatfield%2Fdepartments%2Fbusiness%2Fbanking_finance%2Funit_Plan_Budget.odp mimetype.isEmpty() || // next for compatibility with OO/LO and our filters // see drwho.virtadpt.net%2Ffiles%2FNOVALUG-Tor.odp mimetype.startsWith(QLatin1String("application/x-openoffice")); } return true; } return false; }
bool KoPathShapeFactory::supports(const KoXmlElement & e, KoShapeLoadingContext &context) const { Q_UNUSED(context); if (e.namespaceURI() == KoXmlNS::draw) { if (e.localName() == "path") return true; if (e.localName() == "line") return true; if (e.localName() == "polyline") return true; if (e.localName() == "polygon") return true; } return false; }
bool KoStyleStack::isUserStyle(const KoXmlElement& e, const QString& family) const { if (e.attributeNS(m_styleNSURI, "family", QString()) != family) return false; const KoXmlElement parent = e.parentNode().toElement(); //kDebug(30003) <<"tagName=" << e.tagName() <<" parent-tagName=" << parent.tagName(); return parent.localName() == "styles" /*&& parent.namespaceURI() == KoXmlNS::office*/; }
bool VideoShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext &context) const { Q_UNUSED(context); if (e.localName() != "plugin" || e.namespaceURI() != KoXmlNS::draw) { return false; } return e.attribute("mime-type") == "application/vnd.sun.star.media"; }
bool KoInlineNote::loadOdf(const KoXmlElement & element) { if (element.namespaceURI() != KoXmlNS::text || element.localName() != "note") return false; QString className = element.attributeNS(KoXmlNS::text, "note-class"); if (className == "footnote") d->type = Footnote; else if (className == "endnote") d->type = Endnote; else return false; d->id = element.attributeNS(KoXmlNS::text, "id"); for (KoXmlNode node = element.firstChild(); !node.isNull(); node = node.nextSibling()) { setAutoNumbering(false); KoXmlElement ts = node.toElement(); if (ts.namespaceURI() != KoXmlNS::text) continue; if (ts.localName() == "note-body") { d->text = ""; KoXmlNode node = ts.firstChild(); while (!node.isNull()) { KoXmlElement commentElement = node.toElement(); if (!commentElement.isNull()) { if (commentElement.localName() == "p" && commentElement.namespaceURI() == KoXmlNS::text) { if (!d->text.isEmpty()) d->text.append('\n'); d->text.append(commentElement.text()); } } node = node.nextSibling(); } } else if (ts.localName() == "note-citation") { d->label = ts.attributeNS(KoXmlNS::text, "label"); if (d->label.isEmpty()) { setAutoNumbering(true); d->label = ts.text(); } } } return true; }
void KoChangeTracker::loadOdfChanges(const KoXmlElement& element) { if (element.namespaceURI() == KoXmlNS::text) { KoXmlElement tag; forEachElement(tag, element) { if (! tag.isNull()) { const QString localName = tag.localName(); if (localName == "changed-region") { KoChangeTrackerElement *changeElement = 0; KoXmlElement region; forEachElement(region, tag) { if (!region.isNull()) { if (region.localName() == "insertion") { changeElement = new KoChangeTrackerElement(kundo2_noi18n(tag.attributeNS(KoXmlNS::text,"id")),KoGenChange::InsertChange); } else if (region.localName() == "format-change") { changeElement = new KoChangeTrackerElement(kundo2_noi18n(tag.attributeNS(KoXmlNS::text,"id")),KoGenChange::FormatChange); } else if (region.localName() == "deletion") { changeElement = new KoChangeTrackerElement(kundo2_noi18n(tag.attributeNS(KoXmlNS::text,"id")),KoGenChange::DeleteChange); } KoXmlElement metadata = region.namedItemNS(KoXmlNS::office,"change-info").toElement(); if (!metadata.isNull()) { KoXmlElement date = metadata.namedItem("dc:date").toElement(); if (!date.isNull()) { changeElement->setDate(date.text()); } KoXmlElement creator = metadata.namedItem("dc:creator").toElement(); if (!date.isNull()) { changeElement->setCreator(creator.text()); } //TODO load comments /* KoXmlElement extra = metadata.namedItem("dc-").toElement(); if (!date.isNull()) { kDebug() << "creator: " << creator.text(); changeElement->setCreator(creator.text()); }*/ } changeElement->setEnabled(d->recordChanges); d->changes.insert( d->changeId, changeElement); d->loadedChanges.insert(tag.attributeNS(KoXmlNS::text,"id"), d->changeId++); } } } } }
bool ThreedShapeFactory::supports(const KoXmlElement &e, KoShapeLoadingContext &context) const { Q_UNUSED(context); if (e.localName() == "scene" && e.namespaceURI() == KoXmlNS::dr3d) { return true; } return false; }
bool KoOdfLoadingContext::parseManifest(const KoXmlDocument &manifestDocument) { // First find the manifest:manifest node. KoXmlNode n = manifestDocument.firstChild(); kDebug(30006) << "Searching for manifest:manifest " << n.toElement().nodeName(); for (; !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) { kDebug(30006) << "NOT element"; continue; } else { kDebug(30006) << "element"; } kDebug(30006) << "name:" << n.toElement().localName() << "namespace:" << n.toElement().namespaceURI(); if (n.toElement().localName() == "manifest" && n.toElement().namespaceURI() == KoXmlNS::manifest) { kDebug(30006) << "found manifest:manifest"; break; } } if (n.isNull()) { kDebug(30006) << "Could not find manifest:manifest"; return false; } // Now loop through the children of the manifest:manifest and // store all the manifest:file-entry elements. const KoXmlElement manifestElement = n.toElement(); for (n = manifestElement.firstChild(); !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) continue; KoXmlElement el = n.toElement(); if (!(el.localName() == "file-entry" && el.namespaceURI() == KoXmlNS::manifest)) continue; QString fullPath = el.attributeNS(KoXmlNS::manifest, "full-path", QString()); QString mediaType = el.attributeNS(KoXmlNS::manifest, "media-type", QString("")); QString version = el.attributeNS(KoXmlNS::manifest, "version", QString()); // Only if fullPath is valid, should we store this entry. // If not, we don't bother to find out exactly what is wrong, we just skip it. if (!fullPath.isNull()) { d->manifestEntries.insert(fullPath, new KoOdfManifestEntry(fullPath, mediaType, version)); } } return true; }
KoOasisSettings::Items KoOasisSettings::NamedMap::entry(const QString& entryName) const { KoXmlElement entry; forEachElement(entry, m_element) { if (entry.localName() == "config-item-map-entry" && entry.namespaceURI() == m_settings->m_configNsUri && entry.attributeNS(m_settings->m_configNsUri, "name", QString()) == entryName) { return Items(entry, m_settings); } } return Items(KoXmlElement(), m_settings); }
KoOasisSettings::NamedMap KoOasisSettings::Items::namedMap(const QString& itemMapName) const { KoXmlElement configItem; forEachElement(configItem, m_element) { if (configItem.localName() == "config-item-map-named" && configItem.namespaceURI() == m_settings->m_configNsUri && configItem.attributeNS(m_settings->m_configNsUri, "name", QString()) == itemMapName) { return NamedMap(configItem, m_settings); } } return NamedMap(KoXmlElement(), m_settings); }
void KoOdfStylesReader::createStyleMap(const KoXmlDocument& doc, bool stylesDotXml) { const KoXmlElement docElement = doc.documentElement(); // We used to have the office:version check here, but better let the apps do that KoXmlElement fontStyles = KoXml::namedItemNS(docElement, KoXmlNS::office, "font-face-decls"); if (!fontStyles.isNull()) { //kDebug(30003) <<"Starting reading in font-face-decls..."; insertStyles(fontStyles, stylesDotXml ? AutomaticInStyles : AutomaticInContent); }// else // kDebug(30003) <<"No items found"; //kDebug(30003) <<"Starting reading in office:automatic-styles. stylesDotXml=" << stylesDotXml; KoXmlElement autoStyles = KoXml::namedItemNS(docElement, KoXmlNS::office, "automatic-styles"); if (!autoStyles.isNull()) { insertStyles(autoStyles, stylesDotXml ? AutomaticInStyles : AutomaticInContent); }// else // kDebug(30003) <<"No items found"; //kDebug(30003) <<"Reading in master styles"; KoXmlNode masterStyles = KoXml::namedItemNS(docElement, KoXmlNS::office, "master-styles"); if (!masterStyles.isNull()) { KoXmlElement master; forEachElement(master, masterStyles) { if (master.localName() == "master-page" && master.namespaceURI() == KoXmlNS::style) { const QString name = master.attributeNS(KoXmlNS::style, "name", QString()); kDebug(30003) << "Master style: '" << name << "' loaded"; d->masterPages.insert(name, new KoXmlElement(master)); } else if (master.localName() == "layer-set" && master.namespaceURI() == KoXmlNS::draw) { kDebug(30003) << "Master style: layer-set loaded"; d->layerSet = master; } else // OASIS docu mentions style:handout-master and draw:layer-set here kWarning(30003) << "Unknown tag " << master.tagName() << " in office:master-styles"; } }
KoOasisSettings::Items KoOasisSettings::itemSet(const QString& itemSetName) const { KoXmlElement e; forEachElement(e, m_settingsElement) { if (e.localName() == "config-item-set" && e.namespaceURI() == m_configNsUri && e.attributeNS(m_configNsUri, "name", QString()) == itemSetName) { return Items(e, this); } } return Items(KoXmlElement(), this); }
bool PageVariable::loadOdf(const KoXmlElement & element, KoShapeLoadingContext & context) { Q_UNUSED(context); const QString localName(element.localName()); if (localName == "page-count") { m_type = PageCount; m_numberFormat.loadOdf(element); } else if (localName == "page-number") { m_type = PageNumber; // The text:select-page attribute is used to display the number of the previous or the following // page rather than the number of the current page. QString pageselect = element.attributeNS(KoXmlNS::text, "select-page", QString()); if (pageselect == "previous") m_pageselect = KoTextPage::PreviousPage; else if (pageselect == "next") m_pageselect = KoTextPage::NextPage; else // "current" m_pageselect = KoTextPage::CurrentPage; // The value of a page number field can be adjusted by a specified number, allowing the display // of page numbers of following or preceding pages. The adjustment amount is specified using // the text:page-adjust attribute. m_pageadjust = element.attributeNS(KoXmlNS::text, "page-adjust", QString()).toInt(); m_numberFormat.loadOdf(element); // The text:fixed attribute specifies whether or not the value of a field element is fixed. If // the value of a field is fixed, the value of the field element to which this attribute is // attached is preserved in all future edits of the document. If the value of the field is not // fixed, the value of the field may be replaced by a new value when the document is edited. m_fixed = element.attributeNS(KoXmlNS::text, "fixed", QString()) == "true"; } else if (localName == "page-continuation-string") { m_type = PageContinuation; // This attribute specifies whether to check for a previous or next page and if the page exists, the // continuation text is printed. QString pageselect = element.attributeNS(KoXmlNS::text, "select-page", QString()); if (pageselect == "previous") m_pageselect = KoTextPage::PreviousPage; else if (pageselect == "next") m_pageselect = KoTextPage::NextPage; else m_pageselect = KoTextPage::CurrentPage; // The text to display m_continuation = element.text(); } return true; }
KoOasisSettings::Items KoOasisSettings::IndexedMap::entry(int entryIndex) const { int i = 0; KoXmlElement entry; forEachElement(entry, m_element) { if (entry.localName() == "config-item-map-entry" && entry.namespaceURI() == m_settings->m_configNsUri) { if (i == entryIndex) return Items(entry, m_settings); else ++i; } } return Items(KoXmlElement(), m_settings); }
// helper method QString KoOasisSettings::Items::findConfigItem(const KoXmlElement& element, const QString& item, bool* ok) const { KoXmlElement it; forEachElement(it, element) { if (it.localName() == "config-item" && it.namespaceURI() == m_settings->m_configNsUri && it.attributeNS(m_settings->m_configNsUri, "name", QString()) == item) { *ok = true; return it.text(); } } *ok = false; return QString(); }
bool PresentationVariable::loadOdf(const KoXmlElement & element, KoShapeLoadingContext & context) { Q_UNUSED(context); const QString localName(element.localName()); if (localName == "footer") { m_type = KPrDeclarations::Footer; } else if (localName == "header") { m_type = KPrDeclarations::Header; } else if (localName == "date-time") { m_type = KPrDeclarations::DateTime; } return true; }
bool EnhancedPathHandle::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) { if (element.localName() != "handle" || element.namespaceURI() != KoXmlNS::draw) { return false; } QString position = element.attributeNS(KoXmlNS::draw, "handle-position"); #ifndef NWORKAROUND_ODF_BUGS KoOdfWorkaround::fixEnhancedPathPolarHandlePosition(position, element, context); #endif QStringList tokens = position.simplified().split(' '); if (tokens.count() != 2) { return false; } setPosition(m_parent->parameter(tokens[0]), m_parent->parameter(tokens[1])); // check if we have a polar handle if (element.hasAttributeNS(KoXmlNS::draw, "handle-polar")) { QString polar = element.attributeNS(KoXmlNS::draw, "handle-polar"); QStringList tokens = polar.simplified().split(' '); if (tokens.count() == 2) { setPolarCenter(m_parent->parameter(tokens[0]), m_parent->parameter(tokens[1])); QString minRadius = element.attributeNS(KoXmlNS::draw, "handle-radius-range-minimum"); QString maxRadius = element.attributeNS(KoXmlNS::draw, "handle-radius-range-maximum"); if (!minRadius.isEmpty() && !maxRadius.isEmpty()) { setRadiusRange(m_parent->parameter(minRadius), m_parent->parameter(maxRadius)); } } } else { QString minX = element.attributeNS(KoXmlNS::draw, "handle-range-x-minimum"); QString maxX = element.attributeNS(KoXmlNS::draw, "handle-range-x-maximum"); if (!minX.isEmpty() && ! maxX.isEmpty()) { setRangeX(m_parent->parameter(minX), m_parent->parameter(maxX)); } QString minY = element.attributeNS(KoXmlNS::draw, "handle-range-y-minimum"); QString maxY = element.attributeNS(KoXmlNS::draw, "handle-range-y-maximum"); if (!minY.isEmpty() && ! maxY.isEmpty()) { setRangeY(m_parent->parameter(minY), m_parent->parameter(maxY)); } } return hasPosition(); }
bool SvgShapeFactory::supports(const KoXmlElement &element, KoShapeLoadingContext &context) const { if (element.localName() == "image" && element.namespaceURI() == KoXmlNS::draw) { QString href = element.attribute("href"); if (href.isEmpty()) return false; // check the mimetype if (href.startsWith("./")) { href.remove(0,2); } QString mimetype = context.odfLoadingContext().mimeTypeForPath(href, true); return (mimetype == "image/svg+xml"); } return false; }
bool InfoVariable::loadOdf(const KoXmlElement & element, KoShapeLoadingContext & /*context*/) { if (!s_loadInfo.exists() ) { for (unsigned int i = 0; i < numPropertyData; ++i) { s_loadInfo->insert(propertyData[i].tag, propertyData[i].property); } } const QString localName(element.localName()); m_type = s_loadInfo->value(localName); for(KoXmlNode node = element.firstChild(); !node.isNull(); node = node.nextSibling() ) { if (node.isText()) { setValue(node.toText().data()); break; } } return true; }
bool CommentShape::loadOdf(const KoXmlElement& element, KoShapeLoadingContext& context) { loadOdfAttributes(element, context, OdfPosition); KoXmlElement child; forEachElement(child, element) { if(child.namespaceURI() == KoXmlNS::dc) { if(child.localName() == "creator") { m_creator = child.text(); QStringList creatorNames = m_creator.split(' '); QString initials; if(KoApplication::isLeftToRight()) { foreach(const QString& name, creatorNames) { initials += name.left(1); } } else { foreach(const QString& name, creatorNames) { initials += name.right(1); } }
bool DatabaseManager::loadOdf(const KoXmlElement& body) { const KoXmlNode databaseRanges = KoXml::namedItemNS(body, KoXmlNS::table, "database-ranges"); KoXmlElement element; forEachElement(element, databaseRanges) { if (element.namespaceURI() != KoXmlNS::table) continue; if (element.localName() == "database-range") { Database database; if (!database.loadOdf(element, d->map)) return false; const Region region = database.range(); if (!region.isValid()) continue; const Sheet* sheet = region.lastSheet(); if (!sheet) continue; sheet->cellStorage()->setDatabase(region, database); } } return true; }
bool KoDocumentInfo::loadOasisAuthorInfo(const KoXmlNode &metaDoc) { KoXmlElement e = KoXml::namedItemNS(metaDoc, KoXmlNS::dc, "creator"); if (!e.isNull() && !e.text().isEmpty()) setActiveAuthorInfo("creator", e.text()); KoXmlNode n = metaDoc.firstChild(); for (; !n.isNull(); n = n.nextSibling()) { if (!n.isElement()) continue; KoXmlElement e = n.toElement(); if (!(e.namespaceURI() == KoXmlNS::meta && e.localName() == "user-defined" && !e.text().isEmpty())) continue; QString name = e.attributeNS(KoXmlNS::meta, "name", QString()); setActiveAuthorInfo(name, e.text()); } return true; }