kjs_display.cpp 1.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/***************************************************************************
 *   Copyright (C) 2019 by João Netto <joaonetto901@gmail.com>             *
 *                                                                         *
 *   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_display_p.h"
11
#include "../form.h"
12 13 14 15 16 17 18 19 20 21

#include <kjs/kjsobject.h>
#include <kjs/kjsprototype.h>

#include <QString>

#include <memory>

using namespace Okular;

22
static KJSPrototype *g_displayProto;
23 24 25 26

// display.hidden
static KJSObject displayGetHidden( KJSContext *, void *  )
{
27
    return KJSNumber( FormField::FormHidden );
28 29 30 31 32
}

// display.visible
static KJSObject displayGetVisible( KJSContext *, void *  )
{
33 34 35 36 37 38 39 40 41 42 43 44 45
    return KJSNumber( FormField::FormVisible );
}

// display.noView
static KJSObject displayGetNoView( KJSContext *, void *  )
{
    return KJSNumber( FormField::FormNoView );
}

// display.noPrint
static KJSObject displayGetNoPrint( KJSContext *, void *  )
{
    return KJSNumber( FormField::FormNoPrint );
46 47 48
}

void JSDisplay::initType( KJSContext *ctx )
49 50 51
{      
    static bool initialized = false;
    if ( initialized )
52
        return;
53
    initialized = true;
54

55
    g_displayProto = new KJSPrototype();
56 57 58

    g_displayProto->defineProperty( ctx, QStringLiteral("hidden"), displayGetHidden );
    g_displayProto->defineProperty( ctx, QStringLiteral("visible"), displayGetVisible );
59 60
    g_displayProto->defineProperty( ctx, QStringLiteral("noView"), displayGetNoView );
    g_displayProto->defineProperty( ctx, QStringLiteral("noPrint"), displayGetNoPrint );
61 62 63 64 65 66
}

KJSObject JSDisplay::object( KJSContext *ctx )
{
    return g_displayProto->constructObject( ctx, nullptr );
}