LibreOffice Module xmloff (master)
1
xmloff
source
xforms
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
"
24
#include "
XFormsSubmissionContext.hxx
"
25
#include "
XFormsInstanceContext.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
47
XFormsModelContext::XFormsModelContext
( SvXMLImport& rImport ) :
48
TokenContext
( rImport ),
49
mxModel
(
xforms_createXFormsModel
() )
50
{
51
}
52
53
void
XFormsModelContext::HandleAttribute
(
const
sax_fastparser::FastAttributeList::FastAttributeIter
& aIter )
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
:
61
GetImport
().SetError(
XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
);
62
break
;
63
default
:
64
XMLOFF_WARN_UNKNOWN
(
"xmloff"
, aIter);
65
assert(
false
&&
"this should not happen"
);
66
break
;
67
}
68
}
69
70
SvXMLImportContext
*
XFormsModelContext::HandleChild
(
71
sal_Int32 nElementToken,
72
const
Reference<css::xml::sax::XFastAttributeList>
& )
73
{
74
SvXMLImportContext
* pContext =
nullptr
;
75
76
switch
( nElementToken )
77
{
78
case
XML_ELEMENT
(
XFORMS
,
XML_INSTANCE
):
79
pContext =
new
XFormsInstanceContext
(
GetImport
(),
mxModel
);
80
break
;
81
case
XML_ELEMENT
(
XFORMS
,
XML_BIND
):
82
pContext =
new
XFormsBindContext
(
GetImport
(),
mxModel
);
83
break
;
84
case
XML_ELEMENT
(
XFORMS
,
XML_SUBMISSION
):
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
99
void
XFormsModelContext::endFastElement
(sal_Int32 )
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: */
mxModel
css::uno::Reference< css::frame::XModel2 > mxModel
SchemaContext.hxx
XFormsBindContext.hxx
XFormsInstanceContext.hxx
XFormsModelContext.hxx
XFormsSubmissionContext.hxx
SchemaContext
import the data type declarations from an xsd:schema element
Definition:
SchemaContext.hxx:36
SvXMLImportContext
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition:
xmlictxt.hxx:48
SvXMLImportContext::GetImport
SvXMLImport & GetImport()
Definition:
xmlictxt.hxx:60
TokenContext
handle attributes through an SvXMLTokenMap
Definition:
TokenContext.hxx:34
XFormsBindContext
import the xforms:binding element
Definition:
XFormsBindContext.hxx:36
XFormsInstanceContext
import the xforms:instance element
Definition:
XFormsInstanceContext.hxx:37
XFormsModelContext::XFormsModelContext
XFormsModelContext(SvXMLImport &rImport)
Definition:
XFormsModelContext.cxx:47
XFormsModelContext::HandleAttribute
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
Definition:
XFormsModelContext.cxx:53
XFormsModelContext::endFastElement
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 ...
Definition:
XFormsModelContext.cxx:99
XFormsModelContext::mxModel
css::uno::Reference< css::xforms::XModel2 > mxModel
Definition:
XFormsModelContext.hxx:37
XFormsModelContext::HandleChild
virtual SvXMLImportContext * HandleChild(sal_Int32 nElementToken, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
will be called for each child element
Definition:
XFormsModelContext.cxx:70
XFormsSubmissionContext
import the xforms:submission element
Definition:
XFormsSubmissionContext.hxx:36
com::sun::star::uno::Reference
sax_fastparser::FastAttributeList::FastAttributeIter
sax_fastparser::FastAttributeList::FastAttributeIter::getToken
sal_Int32 getToken() const
sax_fastparser::FastAttributeList::FastAttributeIter::toString
OUString toString() const
GotoObjFlags::Any
@ Any
SotClipboardFormatId::XFORMS
@ XFORMS
log.hxx
com::sun::star::uno
namespacemap.hxx
xmloff::token
Handling of tokens in XML:
Definition:
fasttokenhandler.cxx:31
xmloff::token::XML_INSTANCE
@ XML_INSTANCE
Definition:
xmltoken.hxx:2817
xmloff::token::XML_ID
@ XML_ID
Definition:
xmltoken.hxx:1064
xmloff::token::XML_BIND
@ XML_BIND
Definition:
xmltoken.hxx:2816
xmloff::token::XML_SCHEMA
@ XML_SCHEMA
Definition:
xmltoken.hxx:2815
xmloff::token::XML_SUBMISSION
@ XML_SUBMISSION
Definition:
xmltoken.hxx:2818
xforms_createXFormsModel
Reference< XModel2 > xforms_createXFormsModel()
Definition:
xformsapi.cxx:60
xforms_addXFormsModel
void xforms_addXFormsModel(const Reference< frame::XModel > &xDocument, const Reference< xforms::XModel2 > &xModel)
Definition:
xformsapi.cxx:67
xformsapi.hxx
xmlerror.hxx
XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
#define XMLERROR_XFORMS_NO_SCHEMA_SUPPORT
Definition:
xmlerror.hxx:59
XMLOFF_WARN_UNKNOWN_ELEMENT
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition:
xmlictxt.hxx:120
XMLOFF_WARN_UNKNOWN
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition:
xmlictxt.hxx:114
xmlimp.hxx
XML_ELEMENT
#define XML_ELEMENT(prefix, name)
Definition:
xmlimp.hxx:97
TOKEN_MASK
constexpr sal_Int32 TOKEN_MASK
Definition:
xmlimp.hxx:94
xmlnamespace.hxx
xmltoken.hxx
Generated on Sun Jul 30 2023 04:40:48 for LibreOffice Module xmloff (master) by
1.9.3