1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/***************************************************************************
* Copyright (C) 2008 by Pino Toscano <pino@kde.org> *
* Copyright (C) 2008 by Harri Porten <porten@kde.org> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "kjs_data_p.h"
#include <kjs/kjsobject.h>
#include <kjs/kjsprototype.h>
#include <qdatetime.h>
#include "../document.h"
using namespace Okular;
static KJSPrototype *g_dataProto;
static KJSObject dataGetCreationDate( KJSContext *ctx, void *object )
{
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
return KJSDate( ctx, file->creationDate() );
}
static KJSObject dataGetDescription( KJSContext *, void *object )
{
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
return KJSString( file->description() );
}
static KJSObject dataGetMIMEType( KJSContext *, void *object )
{
return KJSString( "" );
}
static KJSObject dataGetModDate( KJSContext *ctx, void *object )
{
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
return KJSDate( ctx, file->modificationDate() );
}
static KJSObject dataGetName( KJSContext *, void *object )
{
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
return KJSString( file->name() );
}
static KJSObject dataGetPath( KJSContext *, void *object )
{
return KJSString( "" );
}
static KJSObject dataGetSize( KJSContext *, void *object )
{
const EmbeddedFile *file = reinterpret_cast< EmbeddedFile * >( object );
return KJSNumber( file->size() );
}
void JSData::initType( KJSContext *ctx )
{
static bool initialized = false;
if ( initialized )
return;
initialized = true;
if ( !g_dataProto )
g_dataProto = new KJSPrototype();
g_dataProto->defineProperty( ctx, "creationDate", dataGetCreationDate );
g_dataProto->defineProperty( ctx, "description", dataGetDescription );
g_dataProto->defineProperty( ctx, "MIMEType", dataGetMIMEType );
g_dataProto->defineProperty( ctx, "modDate", dataGetModDate );
g_dataProto->defineProperty( ctx, "name", dataGetName );
g_dataProto->defineProperty( ctx, "path", dataGetPath );
g_dataProto->defineProperty( ctx, "size", dataGetSize );
}
KJSObject JSData::wrapFile( KJSContext *ctx, EmbeddedFile *f )
{
return g_dataProto->constructObject( ctx, f );
}
|