Okular
8 #include "kjs_document_p.h"
12 #include <kjs/kjsarguments.h>
13 #include <kjs/kjsobject.h>
14 #include <kjs/kjsprototype.h>
19 #include "../document_p.h"
22 #include "kjs_data_p.h"
23 #include "kjs_field_p.h"
24 #include "kjs_ocg_p.h"
33 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
35 return KJSNumber(doc->m_pagesVector.count());
41 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
43 return KJSNumber(doc->m_parent->currentPage());
49 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
53 if (page == (
int)doc->m_parent->currentPage()) {
57 doc->m_parent->setViewportPage(page);
63 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
71 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
79 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
87 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
89 return KJSString(doc->m_url.toDisplayString());
101 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
108 for (
int i = 0; it != itEnd; ++it, ++i) {
109 KJSObject newdata = JSData::wrapFile(ctx, *it);
119 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
120 QWidget *widget = doc->m_widget;
129 const DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
131 unsigned int numFields = 0;
133 for (
const Page *pIt : qAsConst(doc->m_pagesVector)) {
134 numFields += pIt->formFields().size();
142 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
147 const DocumentInfo docinfo = doc->m_parent->documentInfo(keys);
148 #define KEY_GET(key, property) \
150 const QString data = docinfo.get(key); \
151 if (!data.isEmpty()) { \
152 const KJSString newval(data); \
153 obj.setProperty(ctx, QStringLiteral(property), newval); \
154 obj.setProperty(ctx, QStringLiteral(property).toLower(), newval); \
167 #define DOCINFO_GET_METHOD(key, name) \
168 static KJSObject docGet##name(KJSContext *, void *object) \
170 DocumentPrivate *doc = reinterpret_cast<DocumentPrivate *>(object); \
171 const DocumentInfo docinfo = doc->m_parent->documentInfo(QSet<DocumentInfo::Key>() << key); \
172 return KJSString(docinfo.get(key)); \
182 #undef DOCINFO_GET_METHOD
187 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
192 for (; pIt != pEnd; ++pIt) {
195 if (form->fullyQualifiedName() == cName) {
196 return JSField::wrapField(context, form, *pIt);
206 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
207 int nPage = arguments.
at(0).
toInt32(ctx);
208 Page *p = doc->m_pagesVector.value(nPage);
215 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
216 int nPage = arguments.
at(0).
toInt32(ctx);
217 Page *p = doc->m_pagesVector.value(nPage);
224 DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
229 if (!viewport.isValid()) {
233 doc->m_parent->setViewport(viewport);
247 const DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
249 int numField = arguments.
at(0).
toInt32(ctx);
251 for (
const Page *pIt : qAsConst(doc->m_pagesVector)) {
254 if (numField < pageFields.
size()) {
260 numField -= pageFields.
size();
268 const DocumentPrivate *doc =
reinterpret_cast<DocumentPrivate *
>(object);
274 for (
int i = 0; i < model->
rowCount(); ++i) {
278 KJSObject item = JSOCG::wrapOCGObject(ctx, model, i, j);
293 static bool initialized =
false;
299 g_docProto->
defineProperty(ctx, QStringLiteral(
"numPages"), docGetNumPages);
300 g_docProto->
defineProperty(ctx, QStringLiteral(
"pageNum"), docGetPageNum, docSetPageNum);
301 g_docProto->
defineProperty(ctx, QStringLiteral(
"documentFileName"), docGetDocumentFileName);
302 g_docProto->
defineProperty(ctx, QStringLiteral(
"filesize"), docGetFilesize);
303 g_docProto->
defineProperty(ctx, QStringLiteral(
"path"), docGetPath);
304 g_docProto->
defineProperty(ctx, QStringLiteral(
"URL"), docGetURL);
305 g_docProto->
defineProperty(ctx, QStringLiteral(
"permStatusReady"), docGetPermStatusReady);
306 g_docProto->
defineProperty(ctx, QStringLiteral(
"dataObjects"), docGetDataObjects);
307 g_docProto->
defineProperty(ctx, QStringLiteral(
"external"), docGetExternal);
308 g_docProto->
defineProperty(ctx, QStringLiteral(
"numFields"), docGetNumFields);
311 g_docProto->
defineProperty(ctx, QStringLiteral(
"info"), docGetInfo);
312 g_docProto->
defineProperty(ctx, QStringLiteral(
"author"), docGetAuthor);
313 g_docProto->
defineProperty(ctx, QStringLiteral(
"creator"), docGetCreator);
314 g_docProto->
defineProperty(ctx, QStringLiteral(
"keywords"), docGetKeywords);
315 g_docProto->
defineProperty(ctx, QStringLiteral(
"producer"), docGetProducer);
316 g_docProto->
defineProperty(ctx, QStringLiteral(
"title"), docGetTitle);
317 g_docProto->
defineProperty(ctx, QStringLiteral(
"subject"), docGetSubject);
319 g_docProto->
defineFunction(ctx, QStringLiteral(
"getField"), docGetField);
320 g_docProto->
defineFunction(ctx, QStringLiteral(
"getPageLabel"), docGetPageLabel);
321 g_docProto->
defineFunction(ctx, QStringLiteral(
"getPageRotation"), docGetPageRotation);
322 g_docProto->
defineFunction(ctx, QStringLiteral(
"gotoNamedDest"), docGotoNamedDest);
323 g_docProto->
defineFunction(ctx, QStringLiteral(
"syncAnnotScan"), docSyncAnnotScan);
324 g_docProto->
defineFunction(ctx, QStringLiteral(
"getNthFieldName"), docGetNthFieldName);
325 g_docProto->
defineFunction(ctx, QStringLiteral(
"getOCGs"), docGetOCGs);
@ Author
The author of the document.
Collector for all the data belonging to a page.
QString number(int n, int base)
virtual int rowCount(const QModelIndex &parent) const const=0
The documentation to the global Okular namespace.
virtual QVariant data(const QModelIndex &index, int role) const const=0
@ Producer
The producer of the document (e.g. some software)
int count(const T &value) const const
@ Creator
The creator of the document (this can be different from the author)
@ Title
The title of the document.
Rotation orientation() const
Returns the orientation of the page as defined by the document.
KJSObject at(int idx) const
char * toString(const T &value)
int toInt32(KJSContext *ctx)
void defineProperty(KJSContext *ctx, const QString &name, PropertyGetter getter, PropertySetter setter=nullptr)
virtual int columnCount(const QModelIndex &parent) const const=0
KJSGlobalObject constructGlobalObject(void *internalValue=nullptr)
@ Keywords
The keywords which describe the content of the document.
@ Subject
The subject of the document.
bool toBool() const const
void defineFunction(KJSContext *ctx, const QString &name, FunctionCall callback)
QString label() const
Returns the label of the page, or a null string if not set.
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const=0
QString toString(KJSContext *ctx)
QVector::const_iterator constBegin() const const
The DocumentInfo structure can be filled in by generators to display metadata about the currently ope...
void setProperty(KJSContext *ctx, const QString &name, bool value)
QString toString() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:04:24 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.