LibreOffice Module xmloff (master) 1
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
22
23#include "xformsapi.hxx"
24
25#include <xmloff/xmlimp.hxx>
26#include <xmloff/xmltoken.hxx>
27#include <xmloff/xmltkmap.hxx>
29
31
32#include <com/sun/star/xforms/XModel2.hpp>
33
34#include <osl/diagnose.h>
35#include <sal/log.hxx>
36
37using com::sun::star::xforms::XModel2;
38
39using namespace com::sun::star::uno;
40using namespace xmloff::token;
41
42
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
55namespace {
56
57Any 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
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;
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;
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;
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
129 sal_Int32,
131{
132 assert( false && "no children supported" );
133 return nullptr;
134}
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VCL_DLLPUBLIC bool toBool(std::u16string_view rValue)
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
handle attributes through an SvXMLTokenMap
virtual SvXMLImportContext * HandleChild(sal_Int32 nElementToken, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
will be called for each child element
css::uno::Reference< css::beans::XPropertySet > mxSubmission
XFormsSubmissionContext(SvXMLImport &rImport, const css::uno::Reference< css::xforms::XModel2 > &xModel)
virtual void HandleAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter &aIter) override
will be called for each attribute
static bool convertBool(bool &rBool, std::u16string_view rString)
#define SAL_WARN_IF(condition, area, stream)
Handling of tokens in XML:
@ XML_INCLUDENAMESPACEPREFIXES
Definition: xmltoken.hxx:2835
@ XML_OMIT_XML_DECLARATION
Definition: xmltoken.hxx:2824
@ XML_CDATA_SECTION_ELEMENTS
Definition: xmltoken.hxx:2826
Reference< XModel > xModel
void xforms_setValue(const css::uno::Reference< css::beans::XPropertySet > &xPropSet, const OUString &rName, const T &aValue)
Definition: xformsapi.hxx:52
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94