本文整理汇总了C++中DocumentWriter类的典型用法代码示例。如果您正苦于以下问题:C++ DocumentWriter类的具体用法?C++ DocumentWriter怎么用?C++ DocumentWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DocumentWriter类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addProperty
static void addProperty(const char* name, unsigned value, DocumentWriter& writer)
{
writer.addData(name, strlen(name));
addLiteral(": ", writer);
addString(String::number(value), writer);
addLiteral(",\n", writer);
}
示例2: fillWithEmptyClients
bool SVGImage::dataChanged(bool allDataReceived)
{
// Don't do anything if is an empty image.
if (!data()->size())
return true;
if (allDataReceived) {
static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient;
Page::PageClients pageClients;
fillWithEmptyClients(pageClients);
m_chromeClient = adoptPtr(new SVGImageChromeClient(this));
pageClients.chromeClient = m_chromeClient.get();
// FIXME: If this SVG ends up loading itself, we might leak the world.
// The Cache code does not know about ImageResources holding Frames and
// won't know to break the cycle.
// This will become an issue when SVGImage will be able to load other
// SVGImage objects, but we're safe now, because SVGImage can only be
// loaded by a top-level document.
m_page = adoptPtr(new Page(pageClients));
m_page->settings().setMediaEnabled(false);
m_page->settings().setScriptEnabled(false);
m_page->settings().setPluginsEnabled(false);
m_page->settings().setAcceleratedCompositingEnabled(false);
RefPtr<Frame> frame = Frame::create(m_page.get(), 0, dummyFrameLoaderClient);
frame->setView(FrameView::create(frame.get()));
frame->init();
FrameLoader* loader = frame->loader();
loader->forceSandboxFlags(SandboxAll);
frame->view()->setScrollbarsSuppressed(true);
frame->view()->setCanHaveScrollbars(false); // SVG Images will always synthesize a viewBox, if it's not available, and thus never see scrollbars.
frame->view()->setTransparent(true); // SVG Images are transparent.
ASSERT(loader->activeDocumentLoader()); // DocumentLoader should have been created by frame->init().
DocumentWriter* writer = loader->activeDocumentLoader()->beginWriting("image/svg+xml", "UTF-8");
writer->addData(data()->data(), data()->size());
loader->activeDocumentLoader()->endWriting(writer);
// Set the intrinsic size before a container size is available.
m_intrinsicSize = containerSize();
}
return m_page;
}
示例3: generateHTML
void PagePopupBlackBerry::generateHTML(WebPage* webpage)
{
DocumentWriter* writer = webpage->d->mainFrame()->loader()->activeDocumentLoader()->writer();
writer->setMIMEType("text/html");
writer->begin(KURL());
// All the popups have the same html head and the page content should be non-zoomable.
StringBuilder source;
// FIXME: the hardcoding padding will be removed soon.
int screenWidth = webpage->d->screenSize().width() - PADDING;
source.appendLiteral("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n");
source.append("<meta name=\"viewport\" content=\"width=" + String::number(screenWidth));
source.appendLiteral(", user-scalable=no\" />\n");
writer->addData(source.toString().utf8().data(), source.toString().utf8().length());
m_client->writeDocument(*writer);
writer->end();
}
示例4: writeDocument
void ColorChooserPopupUIController::writeDocument(DocumentWriter& writer)
{
Vector<ColorSuggestion> suggestions = m_client->suggestions();
Vector<String> suggestionValues;
for (unsigned i = 0; i < suggestions.size(); i++)
suggestionValues.append(suggestions[i].color.serialized());
IntRect anchorRectInScreen = m_chromeClient->rootViewToScreen(m_client->elementRectRelativeToRootView());
PagePopupClient::addString("<!DOCTYPE html><head><meta charset='UTF-8'><style>\n", writer);
writer.addData(pickerCommonCss, sizeof(pickerCommonCss));
writer.addData(colorSuggestionPickerCss, sizeof(colorSuggestionPickerCss));
PagePopupClient::addString("</style></head><body><div id=main>Loading...</div><script>\n"
"window.dialogArguments = {\n", writer);
PagePopupClient::addProperty("values", suggestionValues, writer);
PagePopupClient::addProperty("otherColorLabel", locale().queryString(WebLocalizedString::OtherColorLabel), writer);
addProperty("anchorRectInScreen", anchorRectInScreen, writer);
PagePopupClient::addString("};\n", writer);
writer.addData(pickerCommonJs, sizeof(pickerCommonJs));
writer.addData(colorSuggestionPickerJs, sizeof(colorSuggestionPickerJs));
PagePopupClient::addString("</script></body>\n", writer);
}
示例5: m_popupClient
inline MockPagePopup::MockPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView, Frame* mainFrame)
: m_popupClient(client)
, m_closeTimer(this, &MockPagePopup::close)
{
Document* document = mainFrame->document();
ASSERT(document);
m_iframe = HTMLIFrameElement::create(HTMLNames::iframeTag, *document);
m_iframe->setIdAttribute("mock-page-popup");
m_iframe->setInlineStyleProperty(CSSPropertyBorderWidth, 0.0, CSSPrimitiveValue::CSS_PX);
m_iframe->setInlineStyleProperty(CSSPropertyPosition, CSSValueAbsolute);
m_iframe->setInlineStyleProperty(CSSPropertyLeft, originBoundsInRootView.x(), CSSPrimitiveValue::CSS_PX, true);
m_iframe->setInlineStyleProperty(CSSPropertyTop, originBoundsInRootView.maxY(), CSSPrimitiveValue::CSS_PX, true);
if (document->body())
document->body()->appendChild(m_iframe.get());
Frame* contentFrame = m_iframe->contentFrame();
DocumentWriter* writer = contentFrame->loader().activeDocumentLoader()->beginWriting("text/html", "UTF-8");
const char scriptToSetUpPagePopupController[] = "<script>window.pagePopupController = parent.internals.pagePopupController;</script>";
writer->addData(scriptToSetUpPagePopupController, sizeof(scriptToSetUpPagePopupController));
m_popupClient->writeDocument(*writer);
contentFrame->loader().activeDocumentLoader()->endWriting(writer);
}
示例6: cache
void Document::cache()
{
if (m_cache_outdated) {
m_cache_outdated = false;
DocumentWriter* writer = new DocumentWriter;
writer->setFileName(g_cache_path + m_cache_filename);
writer->setType(m_filename.section(QLatin1Char('.'), -1));
writer->setRichText(m_rich_text);
writer->setCodePage(m_codepage);
writer->setDocument(m_text->document()->clone());
emit cacheFile(writer);
}
}
示例7: saveAs
bool Document::save()
{
// Save progress
QSettings settings;
settings.setValue("Progress/Words", m_current_wordcount);
settings.setValue("Progress/Time", m_current_time);
if (m_filename.isEmpty()) {
return saveAs();
}
// Write file to disk
DocumentWatcher::instance()->removeWatch(this);
DocumentWriter writer;
writer.setFileName(m_filename);
writer.setType(m_filename.section(QLatin1Char('.'), -1));
writer.setRichText(m_rich_text);
writer.setCodePage(m_codepage);
writer.setDocument(m_text->document());
bool saved = writer.write();
m_codepage = writer.codePage();
if (saved) {
m_cache_outdated = false;
QFile::remove(g_cache_path + m_cache_filename);
QFile::copy(m_filename, g_cache_path + m_cache_filename);
} else {
cache();
}
DocumentWatcher::instance()->addWatch(this);
if (!saved) {
QMessageBox::critical(window(), tr("Sorry"), tr("Unable to save '%1'.").arg(QDir::toNativeSeparators(m_filename)));
return false;
}
m_text->document()->setModified(false);
return true;
}
示例8: saveAs
bool Document::save()
{
// Save progress
m_daily_progress->save();
if (m_filename.isEmpty() || !processFileName(m_filename)) {
return saveAs();
}
// Write file to disk
DocumentWatcher::instance()->pauseWatch(this);
DocumentWriter writer;
writer.setFileName(m_filename);
writer.setType(m_filename.section(QLatin1Char('.'), -1));
writer.setEncoding(m_encoding);
writer.setWriteByteOrderMark(Preferences::instance().writeByteOrderMark());
writer.setDocument(m_text->document());
bool saved = writer.write();
m_encoding = writer.encoding();
if (saved) {
m_cache_outdated = false;
emit replaceCacheFile(this, m_filename);
} else {
cache();
}
DocumentWatcher::instance()->resumeWatch(this);
if (!saved) {
QMessageBox::critical(window(), tr("Sorry"), tr("Unable to save '%1'.").arg(QDir::toNativeSeparators(m_filename)));
return false;
}
m_saved_wordcount = m_document_stats.wordCount();
m_text->document()->setModified(false);
return true;
}
示例9: assert
void
Server::addHeaders(Context *ctx) {
DocumentWriter* writer = ctx->documentWriter();
assert(NULL != writer);
writer->addHeaders(ctx->response());
}
示例10: addString
static inline void addString(const String& str, DocumentWriter& writer)
{
CString str8 = str.utf8();
writer.addData(str8.data(), str8.length());
}
示例11: onJob
/**
* [working thread]
*/
virtual void onJob()
{
UndoTransaction undoTransaction(m_document, "Rotate Canvas");
// get all sprite cels
CelList cels;
m_sprite->getCels(cels);
// for each cel...
for (CelIterator it = cels.begin(); it != cels.end(); ++it) {
Cel* cel = *it;
Image* image = m_sprite->getStock()->getImage(cel->getImage());
// change it location
switch (m_angle) {
case 180:
undoTransaction.setCelPosition(cel,
m_sprite->getWidth() - cel->getX() - image->w,
m_sprite->getHeight() - cel->getY() - image->h);
break;
case 90:
undoTransaction.setCelPosition(cel, m_sprite->getHeight() - cel->getY() - image->h, cel->getX());
break;
case -90:
undoTransaction.setCelPosition(cel, cel->getY(), m_sprite->getWidth() - cel->getX() - image->w);
break;
}
}
// for each stock's image
for (int i=0; i<m_sprite->getStock()->size(); ++i) {
Image* image = m_sprite->getStock()->getImage(i);
if (!image)
continue;
// rotate the image
Image* new_image = image_new(image->imgtype,
m_angle == 180 ? image->w: image->h,
m_angle == 180 ? image->h: image->w);
image_rotate(image, new_image, m_angle);
undoTransaction.replaceStockImage(i, new_image);
jobProgress((float)i / m_sprite->getStock()->size());
// cancel all the operation?
if (isCanceled())
return; // UndoTransaction destructor will undo all operations
}
// rotate mask
if (m_document->isMaskVisible()) {
Mask* origMask = m_document->getMask();
Mask* new_mask = mask_new();
int x = 0, y = 0;
switch (m_angle) {
case 180:
x = m_sprite->getWidth() - origMask->x - origMask->w;
y = m_sprite->getHeight() - origMask->y - origMask->h;
break;
case 90:
x = m_sprite->getHeight() - origMask->y - origMask->h;
y = origMask->x;
break;
case -90:
x = origMask->y;
y = m_sprite->getWidth() - origMask->x - origMask->w;
break;
}
// create the new rotated mask
mask_replace(new_mask, x, y,
m_angle == 180 ? origMask->w: origMask->h,
m_angle == 180 ? origMask->h: origMask->w);
image_rotate(origMask->bitmap, new_mask->bitmap, m_angle);
// copy new mask
undoTransaction.copyToCurrentMask(new_mask);
mask_free(new_mask);
// regenerate mask
m_document->generateMaskBoundaries();
}
// change the sprite's size
if (m_angle != 180)
undoTransaction.setSpriteSize(m_sprite->getHeight(), m_sprite->getWidth());
// commit changes
undoTransaction.commit();
}