本文整理汇总了C++中KoXmlElement类的典型用法代码示例。如果您正苦于以下问题:C++ KoXmlElement类的具体用法?C++ KoXmlElement怎么用?C++ KoXmlElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KoXmlElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_D
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;
}
示例2: supports
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;
}
示例3: loadFileLayer
KisNodeSP KisKraLoader::loadFileLayer(const KoXmlElement& element, KisImageWSP image, const QString& name, quint32 opacity)
{
QString filename = element.attribute("source", QString());
if (filename.isNull()) return 0;
bool scale = (element.attribute("scale", "true") == "true");
int scalingMethod = element.attribute("scalingmethod", "-1").toInt();
if (scalingMethod < 0) {
if (scale) {
scalingMethod = KisFileLayer::ToImagePPI;
}
else {
scalingMethod = KisFileLayer::None;
}
}
QString documentPath;
if (m_d->document) {
documentPath = m_d->document->url().toLocalFile();
}
QFileInfo info(documentPath);
QString basePath = info.absolutePath();
QString fullPath = basePath + QDir::separator() + filename;
// Entering the event loop to show the messagebox will delete the image, so up the ref by one
image->ref();
if (!QFileInfo(fullPath).exists()) {
qApp->setOverrideCursor(Qt::ArrowCursor);
QString msg = i18nc(
"@info",
"The file associated to a file layer with the name \"%1\" is not found.<nl/><nl/>"
"Expected path:<nl/>"
"%2<nl/><nl/>"
"Do you want to locate it manually?", name, fullPath);
int result = QMessageBox::warning(0, i18nc("@title:window", "File not found"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (result == QMessageBox::Yes) {
KoFileDialog dialog(0, KoFileDialog::OpenFile, "OpenDocument");
dialog.setMimeTypeFilters(KisImportExportManager::mimeFilter("application/x-krita", KisImportExportManager::Import));
dialog.setDefaultDir(basePath);
QString url = dialog.filename();
if (!QFileInfo(basePath).exists()) {
filename = url;
} else {
QDir d(basePath);
filename = d.relativeFilePath(url);
}
}
qApp->restoreOverrideCursor();
}
KisLayer *layer = new KisFileLayer(image, basePath, filename, (KisFileLayer::ScalingMethod)scalingMethod, name, opacity);
Q_CHECK_PTR(layer);
return layer;
}
示例4: applyViewboxTransformation
void KoPathShape::applyViewboxTransformation(const KoXmlElement & element)
{
// apply viewbox transformation
QRectF viewBox = loadOdfViewbox(element);
if (! viewBox.isEmpty()) {
// load the desired size
QSizeF size;
size.setWidth(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "width", QString())));
size.setHeight(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "height", QString())));
// load the desired position
QPointF pos;
pos.setX(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "x", QString())));
pos.setY(KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "y", QString())));
// create matrix to transform original path data into desired size and position
QMatrix viewMatrix;
viewMatrix.translate(-viewBox.left(), -viewBox.top());
viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
viewMatrix.translate(pos.x(), pos.y());
// transform the path data
map(viewMatrix);
}
}
示例5: readMathMLAttributes
bool GlyphElement::readMathMLAttributes( const KoXmlElement& element )
{
// MathML Section 3.2.9.2
m_fontFamily = element.attribute( "fontfamily" );
if ( m_fontFamily.isNull() ) {
kWarning( DEBUGID ) << "Required attribute fontfamily not found in glyph element\n";
return false;
}
QString indexStr = element.attribute( "index" );
if ( indexStr.isNull() ) {
kWarning( DEBUGID ) << "Required attribute index not found in glyph element\n";
return false;
}
bool ok;
ushort index = indexStr.toUShort( &ok );
if ( ! ok ) {
kWarning( DEBUGID ) << "Invalid index value in glyph element\n";
return false;
}
m_char = QChar( index );
m_alt = element.attribute( "alt" );
if ( m_alt.isNull() ) {
kWarning( DEBUGID ) << "Required attribute alt not found in glyph element\n";
return false;
}
// TODO: Check whether we have needed fontfamily
return true;
}
示例6: load
bool MorphologyEffect::load(const KoXmlElement &element, const KoFilterEffectLoadingContext &context)
{
if (element.tagName() != id())
return false;
m_radius = QPointF();
m_operator = Erode;
if (element.hasAttribute("radius")) {
QString radiusStr = element.attribute("radius").trimmed();
QStringList params = radiusStr.replace(',', ' ').simplified().split(' ');
switch (params.count()) {
case 1:
m_radius.rx() = params[0].toDouble()*72./90.;
m_radius.ry() = m_radius.x();
break;
case 2:
m_radius.rx() = params[0].toDouble()*72./90.;
m_radius.ry() = params[1].toDouble()*72./90.;
break;
default:
m_radius = QPointF();
}
}
m_radius = context.convertFilterPrimitiveUnits(m_radius);
if (element.hasAttribute("operator")) {
QString op = element.attribute("operator");
if (op == "dilate")
m_operator = Dilate;
}
return true;
}
示例7: while
// Font size is a bit special. "115%" applies to "the fontsize of the parent style".
// This can be generalized though (hasPropertyThatCanBePercentOfParent() ? :)
qreal KoStyleStack::fontSize(const qreal defaultFontPointSize) const
{
const QString name = "font-size";
qreal percent = 1;
QList<KoXmlElement>::ConstIterator it = m_stack.end(); // reverse iterator
while (it != m_stack.begin()) {
--it;
KoXmlElement properties = KoXml::namedItemNS(*it, m_styleNSURI, m_propertiesTagName).toElement();
if (properties.hasAttributeNS(m_foNSURI, name)) {
const QString value = properties.attributeNS(m_foNSURI, name, QString());
if (value.endsWith('%')) {
//sebsauer, 20070609, the specs don't say that we have to calc them together but
//just that we are looking for a valid parent fontsize. So, let's only take the
//first percent definition into account and keep on to seek for a valid parent,
//percent *= value.left( value.length() - 1 ).toDouble() / 100.0;
if (percent == 1)
percent = value.left(value.length() - 1).toDouble() / 100.0;
} else
return percent * KoUnit::parseValue(value); // e.g. 12pt
}
}
//if there was no valid parent, we return the default fontsize together with an optional calculated percent-value.
return percent * defaultFontPointSize;
}
示例8: loadSvg
bool RectangleShape::loadSvg(const KoXmlElement &element, SvgLoadingContext &context)
{
const qreal x = SvgUtil::parseUnitX(context.currentGC(), element.attribute("x"));
const qreal y = SvgUtil::parseUnitY(context.currentGC(), element.attribute("y"));
const qreal w = SvgUtil::parseUnitX(context.currentGC(), element.attribute("width"));
const qreal h = SvgUtil::parseUnitY(context.currentGC(), element.attribute("height"));
const QString rxStr = element.attribute("rx");
const QString ryStr = element.attribute("ry");
qreal rx = rxStr.isEmpty() ? 0.0 : SvgUtil::parseUnitX(context.currentGC(), rxStr);
qreal ry = ryStr.isEmpty() ? 0.0 : SvgUtil::parseUnitY(context.currentGC(), ryStr);
// if one radius is given but not the other, use the same value for both
if (!rxStr.isEmpty() && ryStr.isEmpty())
ry = rx;
if (rxStr.isEmpty() && !ryStr.isEmpty())
rx = ry;
setSize(QSizeF(w, h));
setPosition(QPointF(x, y));
if (rx >= 0.0)
setCornerRadiusX(qMin(qreal(100.0), qreal(rx / (0.5 * w) * 100.0)));
if (ry >= 0.0)
setCornerRadiusY(qMin(qreal(100.0), qreal(ry / (0.5 * h) * 100.0)));
if (w == 0.0 || h == 0.0)
setVisible(false);
return true;
}
示例9: readMathMLContent
bool UnderOverElement::readMathMLContent( const KoXmlElement& parent )
{
QString name = parent.tagName().toLower();
BasicElement* tmpElement = 0;
KoXmlElement tmp;
forEachElement( tmp, parent ) {
tmpElement = ElementFactory::createElement( tmp.tagName(), this );
if( !tmpElement->readMathML( tmp ) )
return false;
if( m_baseElement->elementType() == Basic ) {
delete m_baseElement;
m_baseElement = tmpElement;
}
else if( name.contains( "under" ) && m_underElement->elementType() == Basic ) {
delete m_underElement;
m_underElement = tmpElement;
}
else if( name.contains( "over" ) && m_overElement->elementType() == Basic ) {
delete m_overElement;
m_overElement = tmpElement;
}
else
return false;
}
示例10: loadOdf
bool RectangleShape::loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context)
{
loadOdfAttributes(element, context, OdfMandatories | OdfGeometry | OdfAdditionalAttributes | OdfCommonChildElements);
if (element.hasAttributeNS(KoXmlNS::svg, "rx") && element.hasAttributeNS(KoXmlNS::svg, "ry")) {
qreal rx = KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "rx", "0"));
qreal ry = KoUnit::parseValue(element.attributeNS(KoXmlNS::svg, "ry", "0"));
m_cornerRadiusX = rx / (0.5 * size().width()) * 100;
m_cornerRadiusY = ry / (0.5 * size().height()) * 100;
} else {
QString cornerRadius = element.attributeNS(KoXmlNS::draw, "corner-radius", "");
if (! cornerRadius.isEmpty()) {
qreal radius = KoUnit::parseValue(cornerRadius);
m_cornerRadiusX = qMin<qreal>(radius / (0.5 * size().width()) * 100, qreal(100));
m_cornerRadiusY = qMin<qreal>(radius / (0.5 * size().height()) * 100, qreal(100));
}
}
updatePath(size());
updateHandles();
loadOdfAttributes(element, context, OdfTransformation);
loadText(element, context);
return true;
}
示例11: supports
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;
}
示例12: load
bool BlurEffect::load(const KoXmlElement &element, const KoFilterEffectLoadingContext &context)
{
if (element.tagName() != id())
return false;
QString deviationStr = element.attribute("stdDeviation");
QStringList params = deviationStr.replace(',', ' ').simplified().split(' ');
switch (params.count()) {
case 1:
m_deviation.rx() = params[0].toDouble();
m_deviation.ry() = m_deviation.x();
break;
case 2:
m_deviation.rx() = params[0].toDouble();
m_deviation.ry() = params[1].toDouble();
break;
default:
return false;
}
m_deviation = context.convertFilterPrimitiveUnits(m_deviation);
return true;
}
示例13: loadContext
bool GanttViewBase::loadContext( const KoXmlElement &settings )
{
KGantt::DateTimeGrid *g = static_cast<KGantt::DateTimeGrid*>( grid() );
g->setScale( static_cast<KGantt::DateTimeGrid::Scale>( settings.attribute( "chart-scale", "0" ).toInt() ) );
g->setDayWidth( settings.attribute( "chart-daywidth", "30" ).toDouble() );
return true;
}
示例14: progressUpdater
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;
}
示例15: loadOdfPageTag
void KoPAPage::loadOdfPageTag( const KoXmlElement &element, KoPALoadingContext &loadingContext )
{
QString master = element.attributeNS (KoXmlNS::draw, "master-page-name" );
KoPAMasterPage *masterPage = loadingContext.masterPageByName(master);
if (masterPage)
setMasterPage(masterPage);
#ifndef NDEBUG
else
kWarning(30010) << "Loading didn't provide a page under name; " << master;
#endif
KoStyleStack& styleStack = loadingContext.odfLoadingContext().styleStack();
int pageProperties = UseMasterBackground | DisplayMasterShapes | DisplayMasterBackground;
if ( styleStack.hasProperty( KoXmlNS::draw, "fill" ) ) {
KoPAPageBase::loadOdfPageTag( element, loadingContext );
pageProperties = DisplayMasterShapes;
}
m_pageProperties = pageProperties;
QString name;
if ( element.hasAttributeNS( KoXmlNS::draw, "name" ) ) {
name = element.attributeNS( KoXmlNS::draw, "name" );
loadingContext.addPage( name, this );
}
if ( element.hasAttributeNS( KoXmlNS::koffice, "name" ) ) {
name = element.attributeNS( KoXmlNS::koffice, "name" );
}
setName( name );
}