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>
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(
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
) );
57 Any
toBool( std::string_view rValue
)
61 if (::sax::Converter::convertBool( bValue
, rValue
))
70 void XFormsSubmissionContext::HandleAttribute( const sax_fastparser::FastAttributeList::FastAttributeIter
& aIter
)
72 switch( aIter
.getToken() & TOKEN_MASK
)
75 xforms_setValue( mxSubmission
, "ID", aIter
.toString() );
78 xforms_setValue( mxSubmission
, "Bind", aIter
.toString() );
81 xforms_setValue( mxSubmission
, "Ref", aIter
.toString() );
84 xforms_setValue( mxSubmission
, "Action", aIter
.toString() );
87 xforms_setValue( mxSubmission
, "Method", aIter
.toString() );
90 xforms_setValue( mxSubmission
, "Version", aIter
.toString() );
93 xforms_setValue( mxSubmission
, "Indent", toBool( aIter
.toView() ) );
96 xforms_setValue( mxSubmission
, "MediaType", aIter
.toString() );
99 xforms_setValue( mxSubmission
, "Encoding", aIter
.toString() );
101 case XML_OMIT_XML_DECLARATION
:
102 xforms_setValue( mxSubmission
, "OmitXmlDeclaration",
103 toBool( aIter
.toView() ) );
106 xforms_setValue( mxSubmission
, "Standalone", toBool( aIter
.toView() ) );
108 case XML_CDATA_SECTION_ELEMENTS
:
109 xforms_setValue( mxSubmission
, "CDataSectionElement", aIter
.toString() );
112 xforms_setValue( mxSubmission
, "Replace", aIter
.toString() );
115 xforms_setValue( mxSubmission
, "Separator", aIter
.toString() );
117 case XML_INCLUDENAMESPACEPREFIXES
:
118 xforms_setValue( mxSubmission
, "IncludeNamespacePrefixes", aIter
.toString() );
121 XMLOFF_WARN_UNKNOWN("xmloff", aIter
);
122 assert( false && "unknown attribute" );
127 /** will be called for each child element */
128 SvXMLImportContext
* XFormsSubmissionContext::HandleChild(
130 const Reference
<css::xml::sax::XFastAttributeList
>& )
132 assert( false && "no children supported" );
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */