LibreOffice Module xmloff (master)  1
XFormsModelContext.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
21 #include "XFormsModelContext.hxx"
22 
23 #include "XFormsBindContext.hxx"
26 #include "SchemaContext.hxx"
27 #include "xformsapi.hxx"
28 
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>
34 
35 #include <osl/diagnose.h>
36 #include <sal/log.hxx>
37 
38 #include <com/sun/star/util/XUpdatable.hpp>
39 #include <com/sun/star/xforms/XModel2.hpp>
40 
41 
42 using com::sun::star::util::XUpdatable;
43 using namespace com::sun::star::uno;
44 using namespace xmloff::token;
45 
46 
48  TokenContext( rImport ),
50 {
51 }
52 
54 {
55  switch( aIter.getToken() & TOKEN_MASK)
56  {
57  case XML_ID:
58  mxModel->setPropertyValue( "ID", makeAny( aIter.toString() ) );
59  break;
60  case XML_SCHEMA:
62  break;
63  default:
64  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
65  assert( false && "this should not happen" );
66  break;
67  }
68 }
69 
71  sal_Int32 nElementToken,
73 {
74  SvXMLImportContext* pContext = nullptr;
75 
76  switch( nElementToken )
77  {
79  pContext = new XFormsInstanceContext( GetImport(), mxModel );
80  break;
82  pContext = new XFormsBindContext( GetImport(), mxModel );
83  break;
85  pContext = new XFormsSubmissionContext( GetImport(), mxModel );
86  break;
87  case XML_ELEMENT(XSD, XML_SCHEMA):
88  pContext = new SchemaContext( GetImport(), mxModel->getDataTypeRepository() );
89  break;
90  default:
91  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElementToken);
92  assert( false && "Boooo!" );
93  break;
94  }
95 
96  return pContext;
97 }
98 
100 {
101  // update before putting model into document
102  Reference<XUpdatable> xUpdate( mxModel, UNO_QUERY );
103  if( xUpdate.is() )
104  xUpdate->update();
105 
106  GetImport().initXForms();
107  xforms_addXFormsModel( GetImport().GetModel(), mxModel );
108 }
109 
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
import the xforms:binding element
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:56
css::uno::Reference< css::frame::XModel2 > mxModel
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:110
handle attributes through an SvXMLTokenMap
Reference< XModel2 > xforms_createXFormsModel()
Definition: xformsapi.cxx:61
css::uno::Reference< css::xforms::XModel2 > mxModel
import the data type declarations from an xsd:schema element
import the xforms:instance element
void xforms_addXFormsModel(const Reference< frame::XModel > &xDocument, const Reference< xforms::XModel2 > &xModel)
Definition: xformsapi.cxx:68
import the xforms:submission element
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
virtual SvXMLImportContext * HandleChild(sal_Int32 nElementToken, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
will be called for each child element
Handling of tokens in XML:
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:96
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Record an error condition that occurred during import.
virtual void initXForms()
Definition: xmlimp.cxx:1796
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:93
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:116
XFormsModelContext(SvXMLImport &rImport)
#define XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
Definition: xmlerror.hxx:59
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)