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/xmlnamespace.hxx>
31 #include <xmloff/namespacemap.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <xmloff/xmlerror.hxx>
35 #include <osl/diagnose.h>
36 #include <sal/log.hxx>
38 #include <com/sun/star/util/XUpdatable.hpp>
39 #include <com/sun/star/xforms/XModel2.hpp>
42 using com::sun::star::util::XUpdatable
;
43 using namespace com::sun::star::uno
;
44 using namespace xmloff::token
;
47 XFormsModelContext::XFormsModelContext( SvXMLImport
& rImport
) :
48 TokenContext( rImport
),
49 mxModel( xforms_createXFormsModel() )
53 void XFormsModelContext::HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter
& aIter
)
55 switch( aIter
.getToken() & TOKEN_MASK
)
58 mxModel
->setPropertyValue( "ID", Any( aIter
.toString() ) );
61 GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
);
64 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
65 assert( false && "this should not happen" );
70 SvXMLImportContext
* XFormsModelContext::HandleChild(
71 sal_Int32 nElementToken
,
72 const Reference
<css::xml::sax::XFastAttributeList
>& )
74 SvXMLImportContext
* pContext
= nullptr;
76 switch( nElementToken
)
78 case XML_ELEMENT(XFORMS
, XML_INSTANCE
):
79 pContext
= new XFormsInstanceContext( GetImport(), mxModel
);
81 case XML_ELEMENT(XFORMS
, XML_BIND
):
82 pContext
= new XFormsBindContext( GetImport(), mxModel
);
84 case XML_ELEMENT(XFORMS
, XML_SUBMISSION
):
85 pContext
= new XFormsSubmissionContext( GetImport(), mxModel
);
87 case XML_ELEMENT(XSD
, XML_SCHEMA
):
88 pContext
= new SchemaContext( GetImport(), mxModel
->getDataTypeRepository() );
91 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken
);
92 assert( false && "Boooo!" );
99 void XFormsModelContext::endFastElement(sal_Int32
)
101 // update before putting model into document
102 Reference
<XUpdatable
> xUpdate( mxModel
, UNO_QUERY
);
106 GetImport().initXForms();
107 xforms_addXFormsModel( GetImport().GetModel(), mxModel
);
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */