1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: XFormsModelContext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
34 #include "XFormsModelContext.hxx"
36 #include "XFormsBindContext.hxx"
37 #include "XFormsSubmissionContext.hxx"
38 #include "XFormsInstanceContext.hxx"
39 #include "SchemaContext.hxx"
40 #include "xformsapi.hxx"
42 #include <xmloff/xmlimp.hxx>
43 #include "xmlnmspe.hxx"
44 #include <xmloff/nmspmap.hxx>
45 #include <xmloff/xmltoken.hxx>
46 #include "xmlerror.hxx"
48 #include <com/sun/star/beans/XPropertySet.hpp>
49 #include <com/sun/star/xml/dom/XDocument.hpp>
50 #include <com/sun/star/util/XUpdatable.hpp>
51 #include <com/sun/star/xforms/XModel.hpp>
53 #include <tools/debug.hxx>
57 using com::sun::star::xml::sax::XAttributeList
;
58 using com::sun::star::beans::XPropertySet
;
59 using com::sun::star::util::XUpdatable
;
60 using namespace com::sun::star::uno
;
61 using namespace xmloff::token
;
66 static SvXMLTokenMapEntry aAttributes
[] =
68 TOKEN_MAP_ENTRY( NONE
, ID
),
69 TOKEN_MAP_ENTRY( NONE
, SCHEMA
),
73 static SvXMLTokenMapEntry aChildren
[] =
75 TOKEN_MAP_ENTRY( XFORMS
, INSTANCE
),
76 TOKEN_MAP_ENTRY( XFORMS
, BIND
),
77 TOKEN_MAP_ENTRY( XFORMS
, SUBMISSION
),
78 TOKEN_MAP_ENTRY( XSD
, SCHEMA
),
83 XFormsModelContext::XFormsModelContext( SvXMLImport
& rImport
,
85 const OUString
& rLocalName
) :
86 TokenContext( rImport
, nPrefix
, rLocalName
, aAttributes
, aChildren
),
87 mxModel( lcl_createXFormsModel() )
91 XFormsModelContext::~XFormsModelContext()
96 Reference
<XPropertySet
> XFormsModelContext::getModel()
102 void XFormsModelContext::HandleAttribute(
104 const OUString
& rValue
)
109 mxModel
->setPropertyValue( OUSTRING("ID"), makeAny( rValue
) );
112 GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
);
115 DBG_ERROR( "this should not happen" );
120 SvXMLImportContext
* XFormsModelContext::HandleChild(
123 const OUString
& rLocalName
,
124 const Reference
<XAttributeList
>& )
126 SvXMLImportContext
* pContext
= NULL
;
131 pContext
= new XFormsInstanceContext( GetImport(), nPrefix
, rLocalName
,
135 pContext
= new XFormsBindContext( GetImport(), nPrefix
, rLocalName
,
139 pContext
= new XFormsSubmissionContext( GetImport(), nPrefix
,
140 rLocalName
, mxModel
);
143 pContext
= new SchemaContext(
144 GetImport(), nPrefix
, rLocalName
,
145 Reference
<com::sun::star::xforms::XModel
>( mxModel
,
147 ->getDataTypeRepository() );
150 DBG_ERROR( "Boooo!" );
157 void XFormsModelContext::EndElement()
159 // update before putting model into document
160 Reference
<XUpdatable
> xUpdate( mxModel
, UNO_QUERY
);
164 GetImport().initXForms();
165 lcl_addXFormsModel( GetImport().GetModel(), getModel() );