1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include "XFormsModelContext.hxx"
23 #include "XFormsBindContext.hxx"
24 #include "XFormsSubmissionContext.hxx"
25 #include "XFormsInstanceContext.hxx"
26 #include "SchemaContext.hxx"
27 #include "xformsapi.hxx"
29 #include <xmloff/xmlimp.hxx>
30 #include "xmloff/xmlnmspe.hxx"
31 #include <xmloff/nmspmap.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include "xmloff/xmlerror.hxx"
35 #include <com/sun/star/beans/XPropertySet.hpp>
36 #include <com/sun/star/xml/dom/XDocument.hpp>
37 #include <com/sun/star/util/XUpdatable.hpp>
38 #include <com/sun/star/xforms/XModel2.hpp>
41 using com::sun::star::xml::sax::XAttributeList
;
42 using com::sun::star::beans::XPropertySet
;
43 using com::sun::star::util::XUpdatable
;
44 using namespace com::sun::star::uno
;
45 using namespace xmloff::token
;
50 static SvXMLTokenMapEntry aAttributes
[] =
52 TOKEN_MAP_ENTRY( NONE
, ID
),
53 TOKEN_MAP_ENTRY( NONE
, SCHEMA
),
57 static SvXMLTokenMapEntry aChildren
[] =
59 TOKEN_MAP_ENTRY( XFORMS
, INSTANCE
),
60 TOKEN_MAP_ENTRY( XFORMS
, BIND
),
61 TOKEN_MAP_ENTRY( XFORMS
, SUBMISSION
),
62 TOKEN_MAP_ENTRY( XSD
, SCHEMA
),
67 XFormsModelContext::XFormsModelContext( SvXMLImport
& rImport
,
69 const OUString
& rLocalName
) :
70 TokenContext( rImport
, nPrefix
, rLocalName
, aAttributes
, aChildren
),
71 mxModel( xforms_createXFormsModel() )
75 XFormsModelContext::~XFormsModelContext()
80 Reference
<css::xforms::XModel2
> XFormsModelContext::getModel()
86 void XFormsModelContext::HandleAttribute(
88 const OUString
& rValue
)
93 mxModel
->setPropertyValue( "ID", makeAny( rValue
) );
96 GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
);
99 OSL_FAIL( "this should not happen" );
104 SvXMLImportContext
* XFormsModelContext::HandleChild(
107 const OUString
& rLocalName
,
108 const Reference
<XAttributeList
>& )
110 SvXMLImportContext
* pContext
= NULL
;
115 pContext
= new XFormsInstanceContext( GetImport(), nPrefix
, rLocalName
,
119 pContext
= new XFormsBindContext( GetImport(), nPrefix
, rLocalName
,
123 pContext
= new XFormsSubmissionContext( GetImport(), nPrefix
,
124 rLocalName
, mxModel
);
127 pContext
= new SchemaContext(
128 GetImport(), nPrefix
, rLocalName
, mxModel
->getDataTypeRepository() );
131 OSL_FAIL( "Boooo!" );
138 void XFormsModelContext::EndElement()
140 // update before putting model into document
141 Reference
<XUpdatable
> xUpdate( mxModel
, UNO_QUERY
);
145 GetImport().initXForms();
146 xforms_addXFormsModel( GetImport().GetModel(), getModel() );
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */