Teach symstore more duplicated DLLs
[LibreOffice.git] / xmloff / source / xforms / XFormsModelContext.cxx
blobbeee7e080bd06fd05022749ce22076d96b5eb4dc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <osl/diagnose.h>
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::util::XUpdatable;
43 using namespace com::sun::star::uno;
44 using namespace xmloff::token;
47 static const SvXMLTokenMapEntry aAttributes[] =
49 TOKEN_MAP_ENTRY( NONE, ID ),
50 TOKEN_MAP_ENTRY( NONE, SCHEMA ),
51 XML_TOKEN_MAP_END
54 static const SvXMLTokenMapEntry aChildren[] =
56 TOKEN_MAP_ENTRY( XFORMS, INSTANCE ),
57 TOKEN_MAP_ENTRY( XFORMS, BIND ),
58 TOKEN_MAP_ENTRY( XFORMS, SUBMISSION ),
59 TOKEN_MAP_ENTRY( XSD, SCHEMA ),
60 XML_TOKEN_MAP_END
64 XFormsModelContext::XFormsModelContext( SvXMLImport& rImport,
65 sal_uInt16 nPrefix,
66 const OUString& rLocalName ) :
67 TokenContext( rImport, nPrefix, rLocalName, aAttributes, aChildren ),
68 mxModel( xforms_createXFormsModel() )
72 void XFormsModelContext::HandleAttribute(
73 sal_uInt16 nToken,
74 const OUString& rValue )
76 switch( nToken )
78 case XML_ID:
79 mxModel->setPropertyValue( "ID", makeAny( rValue ) );
80 break;
81 case XML_SCHEMA:
82 GetImport().SetError( XMLERROR_XFORMS_NO_SCHEMA_SUPPORT );
83 break;
84 default:
85 OSL_FAIL( "this should not happen" );
86 break;
90 SvXMLImportContext* XFormsModelContext::HandleChild(
91 sal_uInt16 nToken,
92 sal_uInt16 nPrefix,
93 const OUString& rLocalName,
94 const Reference<XAttributeList>& )
96 SvXMLImportContext* pContext = nullptr;
98 switch( nToken )
100 case XML_INSTANCE:
101 pContext = new XFormsInstanceContext( GetImport(), nPrefix, rLocalName,
102 mxModel );
103 break;
104 case XML_BIND:
105 pContext = new XFormsBindContext( GetImport(), nPrefix, rLocalName,
106 mxModel );
107 break;
108 case XML_SUBMISSION:
109 pContext = new XFormsSubmissionContext( GetImport(), nPrefix,
110 rLocalName, mxModel );
111 break;
112 case XML_SCHEMA:
113 pContext = new SchemaContext(
114 GetImport(), nPrefix, rLocalName, mxModel->getDataTypeRepository() );
115 break;
116 default:
117 OSL_FAIL( "Boooo!" );
118 break;
121 return pContext;
124 void XFormsModelContext::EndElement()
126 // update before putting model into document
127 Reference<XUpdatable> xUpdate( mxModel, UNO_QUERY );
128 if( xUpdate.is() )
129 xUpdate->update();
131 GetImport().initXForms();
132 xforms_addXFormsModel( GetImport().GetModel(), getModel() );
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */