本文整理汇总了C++中KHTMLPart::document方法的典型用法代码示例。如果您正苦于以下问题:C++ KHTMLPart::document方法的具体用法?C++ KHTMLPart::document怎么用?C++ KHTMLPart::document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KHTMLPart
的用法示例。
在下文中一共展示了KHTMLPart::document方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: orientationMediaFeatureEval
static bool orientationMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix /*op*/)
{
if (value) {
CSSPrimitiveValueImpl *pv = static_cast<CSSPrimitiveValueImpl *>(value);
if (!value->isPrimitiveValue() || pv->primitiveType() != CSSPrimitiveValue::CSS_IDENT ||
(pv->getIdent() != CSS_VAL_PORTRAIT && pv->getIdent() != CSS_VAL_LANDSCAPE)) {
return false;
}
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
if (printing) {
if (pd->width() > pd->height()) {
return (pv->getIdent() == CSS_VAL_LANDSCAPE);
}
} else {
if (part->view()->visibleWidth() > part->view()->visibleHeight()) {
return (pv->getIdent() == CSS_VAL_LANDSCAPE);
}
}
return (pv->getIdent() == CSS_VAL_PORTRAIT);
}
return false;
}
示例2: monochromeMediaFeatureEval
static bool monochromeMediaFeatureEval(CSSValueImpl* value, RenderStyle*, KHTMLPart* part, MediaFeaturePrefix op)
{
KHTMLPart* rootPart = part;
while (rootPart->parentPart()) rootPart = rootPart->parentPart();
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl*>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int depth = 0;
if (printing) {
if (pd->numColors() < 2)
depth = 1;
// assume printer is either b&w or color.
} else {
int sn = QApplication::desktop()->screenNumber( rootPart->view() );
if (QApplication::desktop()->screen(sn)->depth() == 1)
depth = 1;
else if (QColormap::instance(sn).mode() == QColormap::Gray)
depth = QApplication::desktop()->screen(sn)->depth();
}
if (value)
{
float number = 0;
return numberValue(value, number) && compareValue(depth, static_cast<int>(number), op);
}
return depth;
}
示例3: aspect_ratioMediaFeatureEval
static bool aspect_ratioMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
if (value) {
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
QSize vs;
int h = 0, v = 0;
if (printing) {
vs = QSize(pd->width(), pd->height());
} else {
vs = QSize(part->view()->visibleWidth(), part->view()->visibleHeight());
}
if (parseAspectRatio(value, h, v)) {
return v != 0 && compareValue(vs.width() * v, vs.height() * h, op);
}
return false;
}
// ({,min-,max-}aspect-ratio)
// assume if we have a viewport, its aspect ratio is non-zero
return true;
}
示例4: device_aspect_ratioMediaFeatureEval
static bool device_aspect_ratioMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
if (value) {
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
QRect sg;
int h = 0, v = 0;
if (printing) {
sg = QRect(0, 0, pd->width(), pd->height());
} else {
sg = QApplication::desktop()->screen(QApplication::desktop()->screenNumber(rootPart->view()))->rect();
}
if (parseAspectRatio(value, h, v)) {
return v != 0 && compareValue(sg.width() * v, sg.height() * h, op);
}
return false;
}
// ({,min-,max-}device-aspect-ratio)
// assume if we have a device, its aspect ratio is non-zero
return true;
}
示例5: colorMediaFeatureEval
static bool colorMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int bitsPerComponent = 0;
if (printing) {
if (pd->colorCount() > 2) {
bitsPerComponent = pd->depth() / 3;
}
// assume printer is either b&w or color.
} else {
int sn = QApplication::desktop()->screenNumber(rootPart->view());
if (QColormap::instance(sn).mode() != QColormap::Gray) {
bitsPerComponent = QApplication::desktop()->screen(sn)->depth() / 3;
}
}
if (value && bitsPerComponent) {
float number = 0;
return numberValue(value, number) && compareValue(bitsPerComponent, static_cast<int>(number), op);
}
return bitsPerComponent;
}
示例6: color_indexMediaFeatureEval
static bool color_indexMediaFeatureEval(CSSValueImpl *value, RenderStyle *, KHTMLPart *part, MediaFeaturePrefix op)
{
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
unsigned int numColors = 0;
if (printing) {
numColors = pd->colorCount();
} else {
int sn = QApplication::desktop()->screenNumber(rootPart->view());
numColors = QApplication::desktop()->screen(sn)->colorCount();
}
if (numColors == INT_MAX) {
numColors = UINT_MAX;
}
if (value) {
float number = 0;
return numberValue(value, number) && compareValue(numColors, static_cast<unsigned int>(number), op);
}
return numColors;
}
示例7: heightMediaFeatureEval
static bool heightMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, KHTMLPart* part, MediaFeaturePrefix op)
{
KHTMLPart* rootPart = part;
while (rootPart->parentPart()) rootPart = rootPart->parentPart();
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl*>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int height;
if (printing)
height = pd->height();
else {
height = part->view()->visibleHeight();
doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
if (value)
return value->isPrimitiveValue() && compareValue(height, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style, logicalDpiY), op);
return height > 0;
}
示例8: device_widthMediaFeatureEval
static bool device_widthMediaFeatureEval(CSSValueImpl* value, RenderStyle* style, KHTMLPart* part, MediaFeaturePrefix op)
{
if (value) {
KHTMLPart* rootPart = part;
while (rootPart->parentPart()) rootPart = rootPart->parentPart();
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl*>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int width;
if (printing)
width = pd->width();
else {
width = QApplication::desktop()->screen(QApplication::desktop()->screenNumber( rootPart->view() ))->rect().width();
doc = static_cast<DOM::DocumentImpl*>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl*>(value)->computeLength(style,logicalDpiY), op);
}
// ({,min-,max-}device-width)
// assume if we have a device, assume non-zero
return true;
}
示例9: widthMediaFeatureEval
static bool widthMediaFeatureEval(CSSValueImpl *value, RenderStyle *style, KHTMLPart *part, MediaFeaturePrefix op)
{
KHTMLPart *rootPart = part;
while (rootPart->parentPart()) {
rootPart = rootPart->parentPart();
}
DOM::DocumentImpl *doc = static_cast<DOM::DocumentImpl *>(rootPart->document().handle());
QPaintDevice *pd = doc->paintDevice();
bool printing = pd ? (pd->devType() == QInternal::Printer) : false;
int width;
if (printing) {
width = pd->width();
} else {
width = part->view()->visibleWidth();
doc = static_cast<DOM::DocumentImpl *>(part->document().handle());
}
int logicalDpiY = doc->logicalDpiY();
if (value) {
return value->isPrimitiveValue() && compareValue(width, static_cast<CSSPrimitiveValueImpl *>(value)->computeLength(style, style, logicalDpiY), op);
}
return width > 0;
}
示例10: partLoadingErrorNotify
bool RenderPartObject::partLoadingErrorNotify( khtml::ChildFrame *childFrame, const KURL& url, const QString& serviceType )
{
KHTMLPart *part = static_cast<KHTMLView *>(m_view)->part();
//kdDebug() << "RenderPartObject::partLoadingErrorNotify serviceType=" << serviceType << endl;
// Check if we just tried with e.g. nsplugin
// and fallback to the activexhandler if there is a classid
// and a codebase, where we may download the ocx if it's missing
if( (serviceType != "application/x-activex-handler") && (element()->id()==ID_OBJECT) ) {
// check for embed child object
HTMLObjectElementImpl *o = static_cast<HTMLObjectElementImpl *>(element());
HTMLEmbedElementImpl *embed = 0;
NodeImpl *child = o->firstChild();
while ( child ) {
if ( child->id() == ID_EMBED )
embed = static_cast<HTMLEmbedElementImpl *>( child );
child = child->nextSibling();
}
if( embed && !o->classId.isEmpty() &&
!( static_cast<ElementImpl *>(o)->getAttribute(ATTR_CODEBASE).string() ).isEmpty() )
{
KParts::URLArgs args;
args.serviceType = "application/x-activex-handler";
if (part->requestObject( childFrame, url, args ))
return true; // success
}
}
// Dissociate ourselves from the current event loop (to prevent crashes
// due to the message box staying up)
QTimer::singleShot( 0, this, SLOT( slotPartLoadingErrorNotify() ) );
Tokenizer *tokenizer = static_cast<DOM::DocumentImpl *>(part->document().handle())->tokenizer();
if (tokenizer) tokenizer->setOnHold( true );
slotPartLoadingErrorNotify();
if (tokenizer) tokenizer->setOnHold( false );
return false;
}
示例11: slotReadOut
void KHTMLPluginKTTSD::slotReadOut()
{
// The parent is assumed to be a KHTMLPart
if(!parent()->inherits("KHTMLPart"))
QMessageBox::warning(0, i18n("Cannot Read source"), i18n("You cannot read anything except web pages with\n"
"this plugin, sorry."));
else
{
// If KTTSD not running, start it.
DCOPClient *client = kapp->dcopClient();
if(!client->isApplicationRegistered("kttsd"))
{
QString error;
if(kapp->startServiceByDesktopName("kttsd", QStringList(), &error))
QMessageBox::warning(0, i18n("Starting KTTSD Failed"), error);
}
// Find out if KTTSD supports xhtml (rich speak).
QByteArray data;
QBuffer dataBuf(data);
QDataStream arg;
dataBuf.open(IO_WriteOnly);
arg.setDevice(&dataBuf);
arg << "" << KSpeech::mtHtml;
QCString replyType;
QByteArray replyData;
bool supportsXhtml = false;
if(!client->call("kttsd", "KSpeech", "supportsMarkup(QString,uint)", data, replyType, replyData, true))
QMessageBox::warning(0, i18n("DCOP Call Failed"), i18n("The DCOP call supportsMarkup failed."));
else
{
QDataStream reply(replyData, IO_ReadOnly);
reply >> supportsXhtml;
}
KHTMLPart *part = (KHTMLPart *)parent();
QString query;
if(supportsXhtml)
{
kdDebug() << "KTTS claims to support rich speak (XHTML to SSML)." << endl;
if(part->hasSelection())
query = part->selectedTextAsHTML();
else
{
// TODO: Fooling around with the selection probably has unwanted
// side effects, but until a method is supplied to get valid xhtml
// from entire document..
// query = part->document().toString().string();
part->selectAll();
query = part->selectedTextAsHTML();
// Restore no selection.
part->setSelection(part->document().createRange());
}
}
else
{
if(part->hasSelection())
query = part->selectedText();
else
query = part->htmlDocument().body().innerText().string();
}
// kdDebug() << "KHTMLPluginKTTSD::slotReadOut: query = " << query << endl;
dataBuf.at(0); // reset data
arg << query << "";
if(!client->call("kttsd", "KSpeech", "setText(QString,QString)", data, replyType, replyData, true))
QMessageBox::warning(0, i18n("DCOP Call Failed"), i18n("The DCOP call setText failed."));
dataBuf.at(0);
arg << 0;
if(!client->call("kttsd", "KSpeech", "startText(uint)", data, replyType, replyData, true))
QMessageBox::warning(0, i18n("DCOP Call Failed"), i18n("The DCOP call startText failed."));
}
}