本文整理汇总了C++中KoShapeSavingContext::embeddedSaver方法的典型用法代码示例。如果您正苦于以下问题:C++ KoShapeSavingContext::embeddedSaver方法的具体用法?C++ KoShapeSavingContext::embeddedSaver怎么用?C++ KoShapeSavingContext::embeddedSaver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KoShapeSavingContext
的用法示例。
在下文中一共展示了KoShapeSavingContext::embeddedSaver方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveOdf
void ArtisticTextShape::saveOdf(KoShapeSavingContext &context) const
{
SvgWriter svgWriter(QList<KoShape*>() << const_cast<ArtisticTextShape*>(this), size());
QByteArray fileContent;
QBuffer fileContentDevice(&fileContent);
if (!fileContentDevice.open(QIODevice::WriteOnly))
return;
if(!svgWriter.save(fileContentDevice)) {
kWarning() << "Could not write svg content";
return;
}
const QString fileName = context.embeddedSaver().getFilename("SvgImages/Image");
const QString mimeType = "image/svg+xml";
context.xmlWriter().startElement("draw:frame");
context.embeddedSaver().embedFile(context.xmlWriter(), "draw:image", fileName, mimeType.toLatin1(), fileContent);
context.xmlWriter().endElement(); // draw:frame
}
示例2: saveOdf
void MusicShape::saveOdf( KoShapeSavingContext & context ) const
{
// The name of this object in the ODF file.
KoEmbeddedDocumentSaver &fileSaver = context.embeddedSaver();
QString objectName = fileSaver.getFilename("Object");
KoXmlWriter& writer = context.xmlWriter();
writer.startElement("draw:frame");
saveOdfAttributes(context, OdfAllAttributes);
writer.startElement("music:shape");
writer.addAttribute("xmlns:music", "http://www.calligra.org/music");
MusicXmlWriter().writeSheet(writer, m_sheet, false);
writer.endElement(); // music:shape
const qreal previewZoom = 150 / 72.; // 150 DPI
QSizeF imgSize = size(); // in points
imgSize *= previewZoom;
KoViewConverter converter;
// Save a preview SVG image.
// -------------------------
// 1. Set up the svg renderer.
QByteArray svgContents; // The contents
QBuffer svgBuffer(&svgContents); // The corresponding QIODevice
QSvgGenerator svg;
svg.setOutputDevice(&svgBuffer); // Write to the buffer
svg.setSize(imgSize.toSize());
svg.setViewBox(QRect(0, 0, boundingRect().width(), boundingRect().height()));
// 2. Paint the svg preview image.
//
// We need to create all text as paths, because otherwise it
// will be difficult for most people to preview the SVG
// image. Not many people have music fonts installed.
QPainter svgPainter;
svgPainter.begin(&svg);
svgPainter.setRenderHint(QPainter::Antialiasing);
svgPainter.setRenderHint(QPainter::TextAntialiasing);
m_style->setTextAsPath(true);
constPaint(svgPainter, converter);
m_style->setTextAsPath(false);
svgPainter.end();
// 3. Create the xml to embed the svg image and the contents to the file.
writer.startElement("draw:image");
QString name = QString("ObjectReplacements/") + objectName + ".svg";
writer.addAttribute("xlink:type", "simple" );
writer.addAttribute("xlink:show", "embed" );
writer.addAttribute("xlink:actuate", "onLoad");
writer.addAttribute("xlink:href", name);
writer.endElement(); // draw:image
fileSaver.saveFile(name, "image/svg+xml", svgContents);
// Save a preview bitmap image.
// ----------------------------
// 1. Create the image.
QImage img(imgSize.toSize(), QImage::Format_ARGB32);
QPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::TextAntialiasing);
converter.setZoom(previewZoom);
constPaint(painter, converter);
// 2. Create the xml to embed the svg image and the contents to the file.
writer.startElement("draw:image");
name = context.imageHref(img);
// FIXME: Find out how to save a picture using the embeddedSaver and saveFile()
//name = QString("ObjectReplacements/") + objectName + ".png";
writer.addAttribute("xlink:type", "simple" );
writer.addAttribute("xlink:show", "embed" );
writer.addAttribute("xlink:actuate", "onLoad");
writer.addAttribute("xlink:href", name);
writer.endElement(); // draw:image
saveOdfCommonChildElements(context);
writer.endElement(); // draw:frame
}