Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "XFormsModelContext.hxx"
31 : :
32 : : #include "XFormsBindContext.hxx"
33 : : #include "XFormsSubmissionContext.hxx"
34 : : #include "XFormsInstanceContext.hxx"
35 : : #include "SchemaContext.hxx"
36 : : #include "xformsapi.hxx"
37 : :
38 : : #include <xmloff/xmlimp.hxx>
39 : : #include "xmloff/xmlnmspe.hxx"
40 : : #include <xmloff/nmspmap.hxx>
41 : : #include <xmloff/xmltoken.hxx>
42 : : #include "xmloff/xmlerror.hxx"
43 : :
44 : : #include <com/sun/star/beans/XPropertySet.hpp>
45 : : #include <com/sun/star/xml/dom/XDocument.hpp>
46 : : #include <com/sun/star/util/XUpdatable.hpp>
47 : : #include <com/sun/star/xforms/XModel.hpp>
48 : :
49 : :
50 : : using rtl::OUString;
51 : : using com::sun::star::xml::sax::XAttributeList;
52 : : using com::sun::star::beans::XPropertySet;
53 : : using com::sun::star::util::XUpdatable;
54 : : using namespace com::sun::star::uno;
55 : : using namespace xmloff::token;
56 : :
57 : :
58 : :
59 : :
60 : : static SvXMLTokenMapEntry aAttributes[] =
61 : : {
62 : : TOKEN_MAP_ENTRY( NONE, ID ),
63 : : TOKEN_MAP_ENTRY( NONE, SCHEMA ),
64 : : XML_TOKEN_MAP_END
65 : : };
66 : :
67 : : static SvXMLTokenMapEntry aChildren[] =
68 : : {
69 : : TOKEN_MAP_ENTRY( XFORMS, INSTANCE ),
70 : : TOKEN_MAP_ENTRY( XFORMS, BIND ),
71 : : TOKEN_MAP_ENTRY( XFORMS, SUBMISSION ),
72 : : TOKEN_MAP_ENTRY( XSD, SCHEMA ),
73 : : XML_TOKEN_MAP_END
74 : : };
75 : :
76 : :
77 : 0 : XFormsModelContext::XFormsModelContext( SvXMLImport& rImport,
78 : : sal_uInt16 nPrefix,
79 : : const OUString& rLocalName ) :
80 : : TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
81 [ # # ]: 0 : mxModel( lcl_createXFormsModel() )
82 : : {
83 : 0 : }
84 : :
85 : 0 : XFormsModelContext::~XFormsModelContext()
86 : : {
87 [ # # ]: 0 : }
88 : :
89 : :
90 : 0 : Reference<XPropertySet> XFormsModelContext::getModel()
91 : : {
92 : 0 : return mxModel;
93 : : }
94 : :
95 : :
96 : 0 : void XFormsModelContext::HandleAttribute(
97 : : sal_uInt16 nToken,
98 : : const OUString& rValue )
99 : : {
100 [ # # # ]: 0 : switch( nToken )
101 : : {
102 : : case XML_ID:
103 [ # # ][ # # ]: 0 : mxModel->setPropertyValue( OUSTRING("ID"), makeAny( rValue ) );
104 : 0 : break;
105 : : case XML_SCHEMA:
106 : 0 : GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT );
107 : 0 : break;
108 : : default:
109 : : OSL_FAIL( "this should not happen" );
110 : 0 : break;
111 : : }
112 : 0 : }
113 : :
114 : 0 : SvXMLImportContext* XFormsModelContext::HandleChild(
115 : : sal_uInt16 nToken,
116 : : sal_uInt16 nPrefix,
117 : : const OUString& rLocalName,
118 : : const Reference<XAttributeList>& )
119 : : {
120 : 0 : SvXMLImportContext* pContext = NULL;
121 : :
122 [ # # # # : 0 : switch( nToken )
# ]
123 : : {
124 : : case XML_INSTANCE:
125 : 0 : pContext = new XFormsInstanceContext( GetImport(), nPrefix, rLocalName,
126 [ # # ][ # # ]: 0 : mxModel );
127 : 0 : break;
128 : : case XML_BIND:
129 : 0 : pContext = new XFormsBindContext( GetImport(), nPrefix, rLocalName,
130 [ # # ]: 0 : mxModel );
131 : 0 : break;
132 : : case XML_SUBMISSION:
133 : 0 : pContext = new XFormsSubmissionContext( GetImport(), nPrefix,
134 [ # # ]: 0 : rLocalName, mxModel );
135 : 0 : break;
136 : : case XML_SCHEMA:
137 : : pContext = new SchemaContext(
138 : 0 : GetImport(), nPrefix, rLocalName,
139 : : Reference<com::sun::star::xforms::XModel>( mxModel,
140 : : UNO_QUERY_THROW )
141 [ # # ][ # # ]: 0 : ->getDataTypeRepository() );
[ # # ][ # # ]
142 : 0 : break;
143 : : default:
144 : : OSL_FAIL( "Boooo!" );
145 : 0 : break;
146 : : }
147 : :
148 : 0 : return pContext;
149 : : }
150 : :
151 : 0 : void XFormsModelContext::EndElement()
152 : : {
153 : : // update before putting model into document
154 [ # # ]: 0 : Reference<XUpdatable> xUpdate( mxModel, UNO_QUERY );
155 [ # # ]: 0 : if( xUpdate.is() )
156 [ # # ][ # # ]: 0 : xUpdate->update();
157 : :
158 [ # # ]: 0 : GetImport().initXForms();
159 [ # # ][ # # ]: 0 : lcl_addXFormsModel( GetImport().GetModel(), getModel() );
160 : 0 : }
161 : :
162 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|