Ignore:
Timestamp:
Mar 26, 2010, 10:19:31 PM (12 years ago)
Author:
dmik
Message:

branches/kmk: Implemented LuPopplerDocument::getInputFields() and LuPopplerInputField?.

Location:
branches/kmk/Lucide/plugins
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/kmk/Lucide/plugins/ludoc/ludoc.cpp

    r319 r321  
    476476}
    477477
     478
     479SOM_Scope void  SOMLINK freeInputFields(Environment *ev, LuDocument_LuInputFieldSequence* aInputFields)
     480{
     481    if ( aInputFields != NULL ) {
     482        if ( ( ( aInputFields->_maximum != 0 ) ||
     483               ( aInputFields->_length != 0 ) ) &&
     484                   ( aInputFields->_buffer != NULL ) ) {
     485            for ( size_t i = 0; i < aInputFields->_length; ++i )
     486                delete aInputFields->_buffer[i];
     487            SOMFree( aInputFields->_buffer );
     488        }
     489        SOMFree( aInputFields );
     490    }
     491}
     492
     493
    478494SOM_Scope void SOMLINK somDefaultInit(LuDocument *somSelf, som3InitCtrl* ctrl)
    479495{
  • branches/kmk/Lucide/plugins/ludoc/ludoc.idl

    r319 r321  
    559559     * This sequence must be freed with freeInputFields() when done.
    560560     *
    561      * Note: SOMMalloc() must be used for all memory allocations.
     561     * Note: The returned sequence must be allocated with SOMMalloc(),
     562     * each element must be a newly created SOM object.
    562563     *
    563564     * Return value: A pointer to sequence of LuInputField.
     
    566567     **/
    567568    LuInputFieldSequence *getInputFields( in long pagenum );
     569
     570
     571    /**
     572     * Frees the input field sequence returned by getInputFields().
     573     *
     574     * Subclasses should never override this method.
     575     */
     576    void freeInputFields(in LuInputFieldSequence aInputFields);
    568577
    569578
     
    584593                      freeDocumentInfo, getThumbnailSize, getThumbnail,
    585594                      searchText, isFixedImage, isCreateFileThumbnail,
    586                       isHaveInputFields, getInputFields;
     595                      isHaveInputFields, getInputFields, freeInputFields;
    587596
    588597
     
    593602        freeFontInfo: procedure, noself;
    594603        freeDocumentInfo: procedure, noself;
    595 
     604        freeInputFields: procedure, noself;
    596605
    597606        passthru C_h_before =  ""
  • branches/kmk/Lucide/plugins/ludoc/luibutton.cpp

    r319 r321  
    7777SOM_Scope void  SOMLINK freeSiblings(Environment *ev, LuInputButton_SiblingSequence* aSiblings)
    7878{
    79     if ( aSiblings != NULL )
    80     {
     79    if ( aSiblings != NULL ) {
    8180        if ( ( ( aSiblings->_maximum != 0 ) ||
    8281               ( aSiblings->_length != 0 ) ) &&
    83                    ( aSiblings->_buffer != NULL ) )
    84         {
     82                   ( aSiblings->_buffer != NULL ) ) {
    8583            SOMFree( aSiblings->_buffer );
    8684        }
  • branches/kmk/Lucide/plugins/ludoc/luibutton.idl

    r319 r321  
    5353     * Radio button. For other button types, returns NULL.
    5454     *
    55      * Note: SOMMalloc() must be used for all memory allocations.
     55     * Note: The returned sequence and elements must be allocated with
     56     * SOMMalloc().
    5657     */
    5758    SiblingSequence *getSiblings();
  • branches/kmk/Lucide/plugins/lupoppler/lupifield.cpp

    r320 r321  
     1
     2/*
     3 *  This file was generated by the SOM Compiler.
     4 *  Generated using:
     5 *     SOM incremental update: 2.24
     6 */
     7
     8
    19/* ***** BEGIN LICENSE BLOCK *****
    210 * Version: CDDL 1.0/LGPL 2.1
     
    4856
    4957
     58SOM_Scope void SOMLINK LuPopplerInputField_init(LuPopplerInputField *somSelf,
     59                                                 Environment *ev,
     60                                                somInitCtrl* ctrl,
     61                                                FormWidget* aFormWidget)
     62{
     63    LuPopplerInputFieldData *somThis; /* set in BeginInitializer */
     64    somInitCtrl globalCtrl;
     65    somBooleanVector myMask;
     66    LuPopplerInputField_BeginInitializer_LuPopplerInputField_init;
     67
     68    LuPopplerInputField_Init_LuInputField_somDefaultInit(somSelf, ctrl);
     69
     70    /* local LuPopplerInputField initialization code */
     71printf("%s:%d\n", __PRETTY_FUNCTION__, __LINE__);
     72
     73    somThis->data = aFormWidget;
     74}
     75
     76
     77SOM_Scope void SOMLINK somDestruct(LuPopplerInputField *somSelf,
     78                                   octet doFree, som3DestructCtrl* ctrl)
     79{
     80    LuPopplerInputFieldData *somThis; /* set in BeginDestructor */
     81    somDestructCtrl globalCtrl;
     82    somBooleanVector myMask;
     83    LuPopplerInputField_BeginDestructor;
     84
     85    /* local LuPopplerInputField deinitialization code */
     86printf("%s:%d\n", __PRETTY_FUNCTION__, __LINE__);
     87
     88    LuPopplerInputField_EndDestructor;
     89}
     90
     91
    5092SOM_Scope LuInputField_Type  SOMLINK getType(LuPopplerInputField *somSelf,
    5193                                              Environment *ev)
    5294{
    5395    LuPopplerInputFieldData *somThis = LuPopplerInputFieldGetData(somSelf);
    54     LuPopplerInputFieldMethodDebug("LuPopplerInputField","getType");
    5596
    56     return (LuPopplerInputField_parent_LuInputField_getType(somSelf,
    57                                                             ev));
     97    LuInputField_Type type = LuInputField_Undefined;
     98    switch( somThis->data->getType() ) {
     99        case formButton:    type = LuInputField_Button; break;
     100        case formText:      type = LuInputField_Text; break;
     101        case formChoice:    type = LuInputField_Choice; break;
     102        case formSignature: type = LuInputField_Signature; break;
     103        default: break;
     104    }
     105
     106    return type;
    58107}
    59108
     
    62111{
    63112    LuPopplerInputFieldData *somThis = LuPopplerInputFieldGetData(somSelf);
    64     LuPopplerInputFieldMethodDebug("LuPopplerInputField","getRectangle");
    65113
    66     return (LuPopplerInputField_parent_LuInputField_getRectangle(somSelf,
    67                                                                  ev));
     114    LuRectangle *rect = (LuRectangle *)SOMMalloc( sizeof( LuRectangle ) );
     115
     116    somThis->data->getRect(&rect->x1, &rect->y1, &rect->x2, &rect->y2);
     117
     118    return rect;
    68119}
    69120
     
    72123{
    73124    LuPopplerInputFieldData *somThis = LuPopplerInputFieldGetData(somSelf);
    74     LuPopplerInputFieldMethodDebug("LuPopplerInputField","getID");
    75125
    76     return (LuPopplerInputField_parent_LuInputField_getID(somSelf,
    77                                                           ev));
     126    return somThis->data->getID();
    78127}
    79128
     
    82131{
    83132    LuPopplerInputFieldData *somThis = LuPopplerInputFieldGetData(somSelf);
    84     LuPopplerInputFieldMethodDebug("LuPopplerInputField","isModified");
    85133
    86     return (LuPopplerInputField_parent_LuInputField_isModified(somSelf,
    87                                                                ev));
     134    return somThis->data->isModified();
    88135}
    89136
     
    92139{
    93140    LuPopplerInputFieldData *somThis = LuPopplerInputFieldGetData(somSelf);
    94     LuPopplerInputFieldMethodDebug("LuPopplerInputField","isReadOnly");
    95141
    96     return (LuPopplerInputField_parent_LuInputField_isReadOnly(somSelf,
    97                                                                ev));
     142    return somThis->data->isReadOnly();
    98143}
    99144
  • branches/kmk/Lucide/plugins/lupoppler/lupifield.idl

    r320 r321  
    33
    44#include <luifield.idl>
     5
     6interface FormWidget; // declared in poppler/Form.h
    57
    68/**
     
    1113interface LuPopplerInputField : LuInputField
    1214{
     15    void LuPopplerInputField_init( inout somInitCtrl ctrl,
     16                                   in FormWidget aFormWidget );
    1317
    1418#ifdef __SOMIDL__
     
    1620    implementation
    1721    {
     22        releaseorder: LuPopplerInputField_init;
     23
     24        LuPopplerInputField_init: init;
     25        somDestruct: override;
     26
    1827        getType: override;
    1928        getRectangle: override;
     
    2231        isReadOnly: override;
    2332
    24         LuInputField::Type mType;
    25         LuRectangle mRectangle;
    26         unsigned long mID;
    27         boolean mIsModified;
    28         boolean mIsReadOnly;
     33        FormWidget data;
     34
     35        passthru C_h_before =  ""
     36            ""
     37            "#include <Form.h>"
     38            "";
     39
     40        passthru C_xh_before =  ""
     41            ""
     42            "#include <Form.h>"
     43            "";
    2944    };
    3045
  • branches/kmk/Lucide/plugins/lupoppler/lupoppler.cpp

    r306 r321  
    5858#include <Gfx.h>
    5959#include <Link.h>
     60#include <Form.h>
    6061
    6162#include "lupoppler.xih"
     63#include "lupifield.xih"
    6264#include "cpconv.h"
    6365
     
    14751477}
    14761478
     1479
     1480SOM_Scope boolean  SOMLINK isHaveInputFields(LuPopplerDocument *somSelf,
     1481                                              Environment *ev)
     1482{
     1483    LuPopplerDocumentData *somThis = LuPopplerDocumentGetData(somSelf);
     1484
     1485    PopplerDocument *doc = (PopplerDocument *)somThis->data;
     1486    for (int i = 0; i < doc->doc->getNumPages(); ++i) {
     1487        Page *page = doc->pages[ i ].page;
     1488        FormPageWidgets *widgets = page->getPageWidgets();
     1489        if (widgets == NULL || widgets->getNumWidgets() > 0)
     1490            return TRUE;
     1491    }
     1492
     1493    return FALSE;
     1494}
     1495
     1496SOM_Scope LuDocument_LuInputFieldSequence*  SOMLINK getInputFields(LuPopplerDocument *somSelf,
     1497                                                                    Environment *ev,
     1498                                                                   long pagenum)
     1499{
     1500    LuPopplerDocumentData *somThis = LuPopplerDocumentGetData(somSelf);
     1501
     1502    Page *page = ((PopplerDocument *)somThis->data)->pages[ pagenum ].page;
     1503
     1504    FormPageWidgets *widgets = page->getPageWidgets();
     1505
     1506    int count;
     1507    if (widgets == NULL || (count = widgets->getNumWidgets()) <= 0)
     1508        return NULL;
     1509
     1510    LuDocument_LuInputFieldSequence *fields = NULL;
     1511
     1512    fields = (LuDocument_LuInputFieldSequence *)
     1513        SOMMalloc( sizeof( LuDocument_LuInputFieldSequence ) );
     1514    fields->_maximum = count;
     1515    fields->_length = count;
     1516    fields->_buffer = (LuInputField **)SOMMalloc( sizeof( LuInputField * ) * count );
     1517
     1518    for (int i = 0; i < widgets->getNumWidgets(); ++i) {
     1519        fields->_buffer[i] = new LuPopplerInputField(ev, widgets->getWidget(i));
     1520    }
     1521
     1522    return fields;
     1523}
    14771524
    14781525SOM_Scope void SOMLINK somDefaultInit(LuPopplerDocument *somSelf,
  • branches/kmk/Lucide/plugins/lupoppler/lupoppler.idl

    r153 r321  
    1919#ifdef __SOMIDL__
    2020
    21     implementation 
     21    implementation
    2222    {
    2323
    2424            void *data;
    25        
     25
    2626        loadFile: override;
    2727        getBpp: override;
     
    5252        isFixedImage: override;
    5353        isCreateFileThumbnail: override;
    54        
     54        isHaveInputFields: override;
     55        getInputFields: override;
     56
    5557        somDefaultInit: override, init;
    5658        somDestruct: override;
    5759    };
    58    
     60
    5961#endif // __SOMIDL__
    6062
Note: See TracChangeset for help on using the changeset viewer.