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
22
23#include "XFormsBindContext.hxx"
26#include "SchemaContext.hxx"
27#include "xformsapi.hxx"
28
29#include <xmloff/xmlimp.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
42using com::sun::star::util::XUpdatable;
43using namespace com::sun::star::uno;
44using 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", Any( 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: */
css::uno::Reference< css::frame::XModel2 > mxModel
import the data type declarations from an xsd:schema element
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
handle attributes through an SvXMLTokenMap
import the xforms:binding element
import the xforms:instance element
XFormsModelContext(SvXMLImport &rImport)
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
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 ...
css::uno::Reference< css::xforms::XModel2 > mxModel
virtual SvXMLImportContext * HandleChild(sal_Int32 nElementToken, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
will be called for each child element
import the xforms:submission element
Handling of tokens in XML:
Reference< XModel2 > xforms_createXFormsModel()
Definition: xformsapi.cxx:60
void xforms_addXFormsModel(const Reference< frame::XModel > &xDocument, const Reference< xforms::XModel2 > &xModel)
Definition: xformsapi.cxx:67
#define XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
Definition: xmlerror.hxx:59
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:98
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:95