LibreOffice Module xmloff (master)
1
xmloff
source
xforms
XFormsSubmissionContext.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 "
XFormsSubmissionContext.hxx
"
22
23
#include "
xformsapi.hxx
"
24
25
#include <
xmloff/xmlimp.hxx
>
26
#include <
xmloff/xmltoken.hxx
>
27
#include <
xmloff/xmltkmap.hxx
>
28
#include <
xmloff/namespacemap.hxx
>
29
30
#include <
sax/tools/converter.hxx
>
31
32
#include <com/sun/star/xforms/XModel2.hpp>
33
34
#include <osl/diagnose.h>
35
#include <
sal/log.hxx
>
36
37
using
com::sun::star::xforms::XModel2;
38
39
using namespace
com::sun::star::uno
;
40
using namespace
xmloff::token
;
41
42
43
XFormsSubmissionContext::XFormsSubmissionContext
(
44
SvXMLImport& rImport,
45
const
Reference<XModel2>
& xModel ) :
46
TokenContext
( rImport )
47
{
48
// register submission with model
49
SAL_WARN_IF
( !
xModel
.is(),
"xmloff"
,
"need model"
);
50
mxSubmission
=
xModel
->createSubmission().get();
51
SAL_WARN_IF
( !
mxSubmission
.is(),
"xmloff"
,
"can't create submission"
);
52
xModel
->getSubmissions()->insert(
Any
(
mxSubmission
) );
53
}
54
55
namespace
{
56
57
Any
toBool
( std::string_view rValue )
58
{
59
Any
aValue;
60
bool
bValue(
false
);
61
if
(
::sax::Converter::convertBool
( bValue, rValue ))
62
{
63
aValue <<= bValue;
64
}
65
return
aValue;
66
}
67
68
}
// namespace
69
70
void
XFormsSubmissionContext::HandleAttribute
(
const
sax_fastparser::FastAttributeList::FastAttributeIter
& aIter )
71
{
72
switch
( aIter.
getToken
() &
TOKEN_MASK
)
73
{
74
case
XML_ID
:
75
xforms_setValue
(
mxSubmission
,
"ID"
, aIter.
toString
() );
76
break
;
77
case
XML_BIND
:
78
xforms_setValue
(
mxSubmission
,
"Bind"
, aIter.
toString
() );
79
break
;
80
case
XML_REF
:
81
xforms_setValue
(
mxSubmission
,
"Ref"
, aIter.
toString
() );
82
break
;
83
case
XML_ACTION
:
84
xforms_setValue
(
mxSubmission
,
"Action"
, aIter.
toString
() );
85
break
;
86
case
XML_METHOD
:
87
xforms_setValue
(
mxSubmission
,
"Method"
, aIter.
toString
() );
88
break
;
89
case
XML_VERSION
:
90
xforms_setValue
(
mxSubmission
,
"Version"
, aIter.
toString
() );
91
break
;
92
case
XML_INDENT
:
93
xforms_setValue
(
mxSubmission
,
"Indent"
,
toBool
( aIter.
toView
() ) );
94
break
;
95
case
XML_MEDIATYPE
:
96
xforms_setValue
(
mxSubmission
,
"MediaType"
, aIter.
toString
() );
97
break
;
98
case
XML_ENCODING
:
99
xforms_setValue
(
mxSubmission
,
"Encoding"
, aIter.
toString
() );
100
break
;
101
case
XML_OMIT_XML_DECLARATION
:
102
xforms_setValue
(
mxSubmission
,
"OmitXmlDeclaration"
,
103
toBool
( aIter.
toView
() ) );
104
break
;
105
case
XML_STANDALONE
:
106
xforms_setValue
(
mxSubmission
,
"Standalone"
,
toBool
( aIter.
toView
() ) );
107
break
;
108
case
XML_CDATA_SECTION_ELEMENTS
:
109
xforms_setValue
(
mxSubmission
,
"CDataSectionElement"
, aIter.
toString
() );
110
break
;
111
case
XML_REPLACE
:
112
xforms_setValue
(
mxSubmission
,
"Replace"
, aIter.
toString
() );
113
break
;
114
case
XML_SEPARATOR
:
115
xforms_setValue
(
mxSubmission
,
"Separator"
, aIter.
toString
() );
116
break
;
117
case
XML_INCLUDENAMESPACEPREFIXES
:
118
xforms_setValue
(
mxSubmission
,
"IncludeNamespacePrefixes"
, aIter.
toString
() );
119
break
;
120
default
:
121
XMLOFF_WARN_UNKNOWN
(
"xmloff"
, aIter);
122
assert(
false
&&
"unknown attribute"
);
123
break
;
124
}
125
}
126
128
SvXMLImportContext
*
XFormsSubmissionContext::HandleChild
(
129
sal_Int32,
130
const
Reference<css::xml::sax::XFastAttributeList>
& )
131
{
132
assert(
false
&&
"no children supported"
);
133
return
nullptr
;
134
}
135
136
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
XFormsSubmissionContext.hxx
toBool
VCL_DLLPUBLIC bool toBool(std::u16string_view rValue)
SvXMLImportContext
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition:
xmlictxt.hxx:48
TokenContext
handle attributes through an SvXMLTokenMap
Definition:
TokenContext.hxx:34
XFormsSubmissionContext::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:
XFormsSubmissionContext.cxx:128
XFormsSubmissionContext::mxSubmission
css::uno::Reference< css::beans::XPropertySet > mxSubmission
Definition:
XFormsSubmissionContext.hxx:37
XFormsSubmissionContext::XFormsSubmissionContext
XFormsSubmissionContext(SvXMLImport &rImport, const css::uno::Reference< css::xforms::XModel2 > &xModel)
Definition:
XFormsSubmissionContext.cxx:43
XFormsSubmissionContext::HandleAttribute
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
Definition:
XFormsSubmissionContext.cxx:70
com::sun::star::uno::Reference
sax::Converter::convertBool
static bool convertBool(bool &rBool, std::u16string_view rString)
sax_fastparser::FastAttributeList::FastAttributeIter
sax_fastparser::FastAttributeList::FastAttributeIter::getToken
sal_Int32 getToken() const
sax_fastparser::FastAttributeList::FastAttributeIter::toString
OUString toString() const
sax_fastparser::FastAttributeList::FastAttributeIter::toView
std::string_view toView() const
converter.hxx
GotoObjFlags::Any
@ Any
log.hxx
SAL_WARN_IF
#define SAL_WARN_IF(condition, area, stream)
com::sun::star::uno
namespacemap.hxx
xmloff::token
Handling of tokens in XML:
Definition:
fasttokenhandler.cxx:31
xmloff::token::XML_STANDALONE
@ XML_STANDALONE
Definition:
xmltoken.hxx:2825
xmloff::token::XML_INCLUDENAMESPACEPREFIXES
@ XML_INCLUDENAMESPACEPREFIXES
Definition:
xmltoken.hxx:2835
xmloff::token::XML_REF
@ XML_REF
Definition:
xmltoken.hxx:2819
xmloff::token::XML_OMIT_XML_DECLARATION
@ XML_OMIT_XML_DECLARATION
Definition:
xmltoken.hxx:2824
xmloff::token::XML_ENCODING
@ XML_ENCODING
Definition:
xmltoken.hxx:745
xmloff::token::XML_SEPARATOR
@ XML_SEPARATOR
Definition:
xmltoken.hxx:1719
xmloff::token::XML_ID
@ XML_ID
Definition:
xmltoken.hxx:1064
xmloff::token::XML_INDENT
@ XML_INDENT
Definition:
xmltoken.hxx:2823
xmloff::token::XML_BIND
@ XML_BIND
Definition:
xmltoken.hxx:2816
xmloff::token::XML_MEDIATYPE
@ XML_MEDIATYPE
Definition:
xmltoken.hxx:2834
xmloff::token::XML_VERSION
@ XML_VERSION
Definition:
xmltoken.hxx:2115
xmloff::token::XML_REPLACE
@ XML_REPLACE
Definition:
xmltoken.hxx:1632
xmloff::token::XML_CDATA_SECTION_ELEMENTS
@ XML_CDATA_SECTION_ELEMENTS
Definition:
xmltoken.hxx:2826
xmloff::token::XML_METHOD
@ XML_METHOD
Definition:
xmltoken.hxx:2821
xmloff::token::XML_ACTION
@ XML_ACTION
Definition:
xmltoken.hxx:220
xModel
Reference< XModel > xModel
xformsapi.hxx
xforms_setValue
void xforms_setValue(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const OUString &rName, const T &aValue)
Definition:
xformsapi.hxx:52
XMLOFF_WARN_UNKNOWN
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition:
xmlictxt.hxx:114
xmlimp.hxx
TOKEN_MASK
constexpr sal_Int32 TOKEN_MASK
Definition:
xmlimp.hxx:94
xmltkmap.hxx
xmltoken.hxx
Generated on Sun Jul 30 2023 04:40:48 for LibreOffice Module xmloff (master) by
1.9.3