1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "XFormsSubmissionContext.hxx"
23 #include "xformsapi.hxx"
25 #include <xmloff/xmlimp.hxx>
26 #include <xmloff/xmltoken.hxx>
28 #include <sax/tools/converter.hxx>
30 #include <com/sun/star/xforms/XModel2.hpp>
32 #include <sal/log.hxx>
34 using com::sun::star::xforms::XModel2
;
36 using namespace com::sun::star::uno
;
37 using namespace xmloff::token
;
40 XFormsSubmissionContext::XFormsSubmissionContext(
42 const Reference
<XModel2
>& xModel
) :
43 TokenContext( rImport
)
45 // register submission with model
46 SAL_WARN_IF( !xModel
.is(), "xmloff", "need model" );
47 mxSubmission
= xModel
->createSubmission().get();
48 SAL_WARN_IF( !mxSubmission
.is(), "xmloff", "can't create submission" );
49 xModel
->getSubmissions()->insert( Any( mxSubmission
) );
54 Any
toBool( std::string_view rValue
)
58 if (::sax::Converter::convertBool( bValue
, rValue
))
67 void XFormsSubmissionContext::HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter
& aIter
)
69 switch( aIter
.getToken() & TOKEN_MASK
)
72 xforms_setValue( mxSubmission
, u
"ID"_ustr
, aIter
.toString() );
75 xforms_setValue( mxSubmission
, u
"Bind"_ustr
, aIter
.toString() );
78 xforms_setValue( mxSubmission
, u
"Ref"_ustr
, aIter
.toString() );
81 xforms_setValue( mxSubmission
, u
"Action"_ustr
, aIter
.toString() );
84 xforms_setValue( mxSubmission
, u
"Method"_ustr
, aIter
.toString() );
87 xforms_setValue( mxSubmission
, u
"Version"_ustr
, aIter
.toString() );
90 xforms_setValue( mxSubmission
, u
"Indent"_ustr
, toBool( aIter
.toView() ) );
93 xforms_setValue( mxSubmission
, u
"MediaType"_ustr
, aIter
.toString() );
96 xforms_setValue( mxSubmission
, u
"Encoding"_ustr
, aIter
.toString() );
98 case XML_OMIT_XML_DECLARATION
:
99 xforms_setValue( mxSubmission
, u
"OmitXmlDeclaration"_ustr
,
100 toBool( aIter
.toView() ) );
103 xforms_setValue( mxSubmission
, u
"Standalone"_ustr
, toBool( aIter
.toView() ) );
105 case XML_CDATA_SECTION_ELEMENTS
:
106 xforms_setValue( mxSubmission
, u
"CDataSectionElement"_ustr
, aIter
.toString() );
109 xforms_setValue( mxSubmission
, u
"Replace"_ustr
, aIter
.toString() );
112 xforms_setValue( mxSubmission
, u
"Separator"_ustr
, aIter
.toString() );
114 case XML_INCLUDENAMESPACEPREFIXES
:
115 xforms_setValue( mxSubmission
, u
"IncludeNamespacePrefixes"_ustr
, aIter
.toString() );
118 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
119 assert( false && "unknown attribute" );
124 /** will be called for each child element */
125 SvXMLImportContext
* XFormsSubmissionContext::HandleChild(
127 const Reference
<css::xml::sax::XFastAttributeList
>& )
129 assert( false && "no children supported" );
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */