LibreOffice Module xmloff (master)
1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
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::xml::sax::XAttributeList;
38
using
com::sun::star::xforms::XModel2;
39
40
using namespace
com::sun::star::uno
;
41
using namespace
xmloff::token
;
42
43
44
XFormsSubmissionContext::XFormsSubmissionContext
(
45
SvXMLImport
& rImport,
46
const
Reference<XModel2>
& xModel ) :
47
TokenContext
( rImport ),
48
mxSubmission()
49
{
50
// register submission with model
51
SAL_WARN_IF
( !xModel.is(),
"xmloff"
,
"need model"
);
52
mxSubmission
= xModel->createSubmission().get();
53
SAL_WARN_IF
( !mxSubmission.is(),
"xmloff"
,
"can't create submission"
);
54
xModel->getSubmissions()->insert(
makeAny
( mxSubmission ) );
55
}
56
57
namespace
{
58
59
Any
toBool
( std::string_view
rValue
)
60
{
61
Any
aValue;
62
bool
bValue(
false
);
63
if
(::
sax::Converter::convertBool
( bValue, rValue ))
64
{
65
aValue <<= bValue;
66
}
67
return
aValue;
68
}
69
70
}
// namespace
71
72
void
XFormsSubmissionContext::HandleAttribute
(
const
sax_fastparser::FastAttributeList::FastAttributeIter
& aIter )
73
{
74
switch
( aIter.
getToken
() &
TOKEN_MASK
)
75
{
76
case
XML_ID
:
77
xforms_setValue
(
mxSubmission
,
"ID"
, aIter.
toString
() );
78
break
;
79
case
XML_BIND
:
80
xforms_setValue
(
mxSubmission
,
"Bind"
, aIter.
toString
() );
81
break
;
82
case
XML_REF
:
83
xforms_setValue
(
mxSubmission
,
"Ref"
, aIter.
toString
() );
84
break
;
85
case
XML_ACTION
:
86
xforms_setValue
(
mxSubmission
,
"Action"
, aIter.
toString
() );
87
break
;
88
case
XML_METHOD
:
89
xforms_setValue
(
mxSubmission
,
"Method"
, aIter.
toString
() );
90
break
;
91
case
XML_VERSION
:
92
xforms_setValue
(
mxSubmission
,
"Version"
, aIter.
toString
() );
93
break
;
94
case
XML_INDENT
:
95
xforms_setValue
(
mxSubmission
,
"Indent"
,
toBool
( aIter.
toView
() ) );
96
break
;
97
case
XML_MEDIATYPE
:
98
xforms_setValue
(
mxSubmission
,
"MediaType"
, aIter.
toString
() );
99
break
;
100
case
XML_ENCODING
:
101
xforms_setValue
(
mxSubmission
,
"Encoding"
, aIter.
toString
() );
102
break
;
103
case
XML_OMIT_XML_DECLARATION
:
104
xforms_setValue
(
mxSubmission
,
"OmitXmlDeclaration"
,
105
toBool
( aIter.
toView
() ) );
106
break
;
107
case
XML_STANDALONE
:
108
xforms_setValue
(
mxSubmission
,
"Standalone"
,
toBool
( aIter.
toView
() ) );
109
break
;
110
case
XML_CDATA_SECTION_ELEMENTS
:
111
xforms_setValue
(
mxSubmission
,
"CDataSectionElement"
, aIter.
toString
() );
112
break
;
113
case
XML_REPLACE
:
114
xforms_setValue
(
mxSubmission
,
"Replace"
, aIter.
toString
() );
115
break
;
116
case
XML_SEPARATOR
:
117
xforms_setValue
(
mxSubmission
,
"Separator"
, aIter.
toString
() );
118
break
;
119
case
XML_INCLUDENAMESPACEPREFIXES
:
120
xforms_setValue
(
mxSubmission
,
"IncludeNamespacePrefixes"
, aIter.
toString
() );
121
break
;
122
default
:
123
XMLOFF_WARN_UNKNOWN
(
"xmloff"
, aIter);
124
assert
(
false
&&
"unknown attribute"
);
125
break
;
126
}
127
}
128
130
SvXMLImportContext
*
XFormsSubmissionContext::HandleChild
(
131
sal_Int32,
132
const
Reference<css::xml::sax::XFastAttributeList>
& )
133
{
134
assert
(
false
&&
"no children supported"
);
135
return
nullptr
;
136
}
137
138
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
com::sun::star::uno::Reference
Definition:
XMLFootnoteSeparatorImport.hxx:32
XFormsSubmissionContext::mxSubmission
css::uno::Reference< css::beans::XPropertySet > mxSubmission
Definition:
XFormsSubmissionContext.hxx:38
XFormsSubmissionContext.hxx
xmloff::token::XML_SEPARATOR
Definition:
xmltoken.hxx:1669
xmloff::token::XML_ID
Definition:
xmltoken.hxx:1030
xmloff::token::XML_ENCODING
Definition:
xmltoken.hxx:714
xmlimp.hxx
com::sun::star::uno
xmloff::token::XML_INDENT
Definition:
xmltoken.hxx:2757
xmltoken.hxx
XMLImageStyle::rValue
css::uno::Any const & rValue
Definition:
ImageStyle.hxx:38
assert
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
XMLOFF_WARN_UNKNOWN
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition:
xmlictxt.hxx:114
xmloff::token::XML_METHOD
Definition:
xmltoken.hxx:2755
xmloff::token::XML_REPLACE
Definition:
xmltoken.hxx:1583
xmloff::token::XML_STANDALONE
Definition:
xmltoken.hxx:2759
TokenContext
handle attributes through an SvXMLTokenMap
Definition:
TokenContext.hxx:34
xmloff::token::XML_CDATA_SECTION_ELEMENTS
Definition:
xmltoken.hxx:2760
XFormsSubmissionContext::XFormsSubmissionContext
XFormsSubmissionContext(SvXMLImport &rImport, const css::uno::Reference< css::xforms::XModel2 > &xModel)
Definition:
XFormsSubmissionContext.cxx:44
xforms_setValue
void xforms_setValue(css::uno::Reference< css::beans::XPropertySet > &xPropSet, const OUString &rName, const T &aValue)
Definition:
xformsapi.hxx:53
toBool
bool toBool(std::u16string_view rValue)
sax_fastparser::FastAttributeList::FastAttributeIter
converter.hxx
xmloff::token::XML_INCLUDENAMESPACEPREFIXES
Definition:
xmltoken.hxx:2769
sax_fastparser::FastAttributeList::FastAttributeIter::getToken
sal_Int32 getToken() const
namespacemap.hxx
xmloff::token::XML_ACTION
Definition:
xmltoken.hxx:207
log.hxx
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:130
xmloff::token::XML_MEDIATYPE
Definition:
xmltoken.hxx:2768
XFormsSubmissionContext::HandleAttribute
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
Definition:
XFormsSubmissionContext.cxx:72
sax::Converter::convertBool
static bool convertBool(bool &rBool, std::u16string_view rString)
sax_fastparser::FastAttributeList::FastAttributeIter::toString
OUString toString() const
xmltkmap.hxx
SvXMLImportContext
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition:
xmlictxt.hxx:45
xmloff::token::XML_REF
Definition:
xmltoken.hxx:2753
xformsapi.hxx
GotoObjFlags::Any
xmloff::token::XML_BIND
Definition:
xmltoken.hxx:2750
xmloff::token::XML_OMIT_XML_DECLARATION
Definition:
xmltoken.hxx:2758
SAL_WARN_IF
#define SAL_WARN_IF(condition, area, stream)
xmloff::token
Handling of tokens in XML:
Definition:
fasttokenhandler.cxx:31
sax_fastparser::FastAttributeList::FastAttributeIter::toView
std::string_view toView() const
TOKEN_MASK
constexpr sal_Int32 TOKEN_MASK
Definition:
xmlimp.hxx:93
SvXMLImport
Definition:
xmlimp.hxx:177
xmloff::token::XML_VERSION
Definition:
xmltoken.hxx:2055
makeAny
css::uno::Any SAL_CALL makeAny(const SharedUNOComponent< INTERFACE, COMPONENT > &value)
Generated on Sat Feb 27 2021 02:56:24 for LibreOffice Module xmloff (master) by
1.8.10