Bump version to 24.04.3.4
[LibreOffice.git] / xmloff / source / xforms / XFormsSubmissionContext.cxx
blob49369765820a00909e00fa0a07f5259a1a16ab3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
27 #include <xmloff/xmltkmap.hxx>
28 #include <xmloff/namespacemap.hxx>
30 #include <sax/tools/converter.hxx>
32 #include <com/sun/star/xforms/XModel2.hpp>
34 #include <osl/diagnose.h>
35 #include <sal/log.hxx>
37 using com::sun::star::xforms::XModel2;
39 using namespace com::sun::star::uno;
40 using namespace xmloff::token;
43 XFormsSubmissionContext::XFormsSubmissionContext(
44 SvXMLImport& rImport,
45 const Reference<XModel2>& xModel ) :
46 TokenContext( rImport )
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 ) );
55 namespace {
57 Any toBool( std::string_view rValue )
59 Any aValue;
60 bool bValue(false);
61 if (::sax::Converter::convertBool( bValue, rValue ))
63 aValue <<= bValue;
65 return aValue;
68 } // namespace
70 void XFormsSubmissionContext::HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter & aIter )
72 switch( aIter.getToken() & TOKEN_MASK )
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;
127 /** will be called for each child element */
128 SvXMLImportContext* XFormsSubmissionContext::HandleChild(
129 sal_Int32,
130 const Reference<css::xml::sax::XFastAttributeList>& )
132 assert( false && "no children supported" );
133 return nullptr;
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */