94
|
1 |
/*
|
|
2 |
* Copyright (c) 2000 - 2001 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "nw_xhtml_textelementhandleri.h"
|
|
20 |
|
|
21 |
#include "nw_lmgr_textbox.h"
|
|
22 |
#include <nw_dom_text.h>
|
|
23 |
#include "nw_xhtml_xhtmlcontenthandler.h"
|
|
24 |
#include "nw_hed_documentroot.h"
|
|
25 |
#include "nw_hed_hedeventhandler.h"
|
|
26 |
#include "nw_adt_types.h"
|
|
27 |
#include "BrsrStatusCodes.h"
|
|
28 |
|
|
29 |
/* ------------------------------------------------------------------------- *
|
|
30 |
class definition
|
|
31 |
* ------------------------------------------------------------------------- */
|
|
32 |
|
|
33 |
/* ------------------------------------------------------------------------- */
|
|
34 |
const
|
|
35 |
NW_XHTML_TextElementHandler_Class_t NW_XHTML_TextElementHandler_Class = {
|
|
36 |
{ /* NW_Object_Core */
|
|
37 |
/* super */ &NW_XHTML_ElementHandler_Class,
|
|
38 |
/* queryInterface */ _NW_Object_Core_QueryInterface
|
|
39 |
},
|
|
40 |
{ /* NW_XHTML_ElementHandler */
|
|
41 |
/* initialize */ _NW_XHTML_ElementHandler_Initialize,
|
|
42 |
/* createBoxTree */ _NW_XHTML_TextElementHandler_CreateBoxTree,
|
|
43 |
/* processEvent */ _NW_XHTML_ElementHandler_ProcessEvent
|
|
44 |
},
|
|
45 |
{ /* NW_XHTML_TextElementHandler */
|
|
46 |
/* unused */ NW_Object_Unused
|
|
47 |
}
|
|
48 |
};
|
|
49 |
|
|
50 |
/* ------------------------------------------------------------------------- *
|
|
51 |
singleton definition
|
|
52 |
* ------------------------------------------------------------------------- */
|
|
53 |
|
|
54 |
/* ------------------------------------------------------------------------- */
|
|
55 |
const NW_XHTML_TextElementHandler_t NW_XHTML_TextElementHandler = {
|
|
56 |
{ { &NW_XHTML_TextElementHandler_Class } }
|
|
57 |
};
|
|
58 |
|
|
59 |
/* ------------------------------------------------------------------------- *
|
|
60 |
virtual methods
|
|
61 |
* ------------------------------------------------------------------------- */
|
|
62 |
|
|
63 |
TBrowserStatusCode /*ARGSUSED*/
|
|
64 |
_NW_XHTML_TextElementHandler_CreateBoxTree (const NW_XHTML_ElementHandler_t* elementHandler,
|
|
65 |
NW_XHTML_ContentHandler_t* contentHandler,
|
|
66 |
NW_DOM_ElementNode_t* elementNode,
|
|
67 |
NW_LMgr_ContainerBox_t* containerBox)
|
|
68 |
{
|
|
69 |
NW_Text_t* text = NULL;
|
|
70 |
NW_LMgr_TextBox_t* textBox = NULL;
|
|
71 |
NW_LMgr_ContainerBox_t *parentBox = NULL;
|
|
72 |
NW_Text_Length_t textLen,i;
|
|
73 |
|
|
74 |
NW_TRY (status) {
|
|
75 |
|
|
76 |
NW_REQUIRED_PARAM(elementHandler);
|
|
77 |
|
|
78 |
text = NW_XHTML_GetDOMTextNodeData(contentHandler, (NW_DOM_TextNode_t*) elementNode);
|
|
79 |
|
|
80 |
// check for whitespace
|
|
81 |
textLen = NW_Text_GetCharCount(text);
|
|
82 |
|
|
83 |
for (i = 0; i < textLen; i++)
|
|
84 |
{
|
|
85 |
if (!NW_Str_Isspace((NW_Ucs2)NW_Text_GetAt(text, i)))
|
|
86 |
{
|
|
87 |
contentHandler->ignoreFramesetElement = NW_TRUE;
|
|
88 |
break;
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
if (text == NULL) {
|
|
93 |
return KBrsrSuccess; /* TODO: should we discriminate our "success"? */
|
|
94 |
}
|
|
95 |
parentBox = containerBox;
|
|
96 |
|
|
97 |
/* create the TextBox and insert it into our parent */
|
|
98 |
textBox = (NW_LMgr_TextBox_t*) NW_LMgr_TextBox_New (0, text);
|
|
99 |
NW_THROW_OOM_ON_NULL (textBox, status);
|
|
100 |
text = NULL;
|
|
101 |
|
|
102 |
status = NW_LMgr_ContainerBox_AddChild (parentBox, NW_LMgr_BoxOf (textBox));
|
|
103 |
_NW_THROW_ON_ERROR(status);
|
|
104 |
textBox = NULL;
|
|
105 |
|
|
106 |
} NW_CATCH (status) {
|
|
107 |
if(textBox) {
|
|
108 |
NW_Object_Delete(textBox);
|
|
109 |
}
|
|
110 |
if(text) {
|
|
111 |
NW_Object_Delete (text);
|
|
112 |
}
|
|
113 |
} NW_FINALLY {
|
|
114 |
return status;
|
|
115 |
} NW_END_TRY
|
|
116 |
}
|
|
117 |
|