bump product version to 4.1.6.2
[LibreOffice.git] / xmloff / source / xforms / XFormsSubmissionContext.cxx
blobfb0bdbbf0a3a711be8b72d6d4d88afa527830139
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/xmlerror.hxx"
27 #include <xmloff/xmltoken.hxx>
28 #include <xmloff/xmltkmap.hxx>
29 #include "xmloff/xmlnmspe.hxx"
30 #include <xmloff/nmspmap.hxx>
32 #include <sax/tools/converter.hxx>
34 #include <com/sun/star/container/XNameContainer.hpp>
35 #include <com/sun/star/xforms/XModel2.hpp>
37 #include <tools/debug.hxx>
39 using com::sun::star::beans::XPropertySet;
40 using com::sun::star::container::XNameContainer;
41 using com::sun::star::xml::sax::XAttributeList;
42 using com::sun::star::xforms::XModel2;
44 using namespace com::sun::star::uno;
45 using namespace xmloff::token;
50 static struct SvXMLTokenMapEntry aAttributeMap[] =
52 TOKEN_MAP_ENTRY( NONE, ID ),
53 TOKEN_MAP_ENTRY( NONE, BIND ),
54 TOKEN_MAP_ENTRY( NONE, REF ),
55 TOKEN_MAP_ENTRY( NONE, ACTION ),
56 TOKEN_MAP_ENTRY( NONE, METHOD ),
57 TOKEN_MAP_ENTRY( NONE, VERSION ),
58 TOKEN_MAP_ENTRY( NONE, INDENT ),
59 TOKEN_MAP_ENTRY( NONE, MEDIATYPE ),
60 TOKEN_MAP_ENTRY( NONE, ENCODING ),
61 TOKEN_MAP_ENTRY( NONE, OMIT_XML_DECLARATION ),
62 TOKEN_MAP_ENTRY( NONE, STANDALONE ),
63 TOKEN_MAP_ENTRY( NONE, CDATA_SECTION_ELEMENTS ),
64 TOKEN_MAP_ENTRY( NONE, REPLACE ),
65 TOKEN_MAP_ENTRY( NONE, SEPARATOR ),
66 TOKEN_MAP_ENTRY( NONE, INCLUDENAMESPACEPREFIXES ),
67 XML_TOKEN_MAP_END
70 XFormsSubmissionContext::XFormsSubmissionContext(
71 SvXMLImport& rImport,
72 sal_uInt16 nPrefix,
73 const OUString& rLocalName,
74 const Reference<XModel2>& xModel ) :
75 TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
76 mxSubmission()
78 // register submission with model
79 DBG_ASSERT( xModel.is(), "need model" );
80 mxSubmission = xModel->createSubmission().get();
81 DBG_ASSERT( mxSubmission.is(), "can't create submission" );
82 xModel->getSubmissions()->insert( makeAny( mxSubmission ) );
85 XFormsSubmissionContext::~XFormsSubmissionContext()
89 Any toBool( const OUString& rValue )
91 Any aValue;
92 bool bValue(false);
93 if (::sax::Converter::convertBool( bValue, rValue ))
95 aValue <<= ( bValue ? true : false );
97 return aValue;
100 void XFormsSubmissionContext::HandleAttribute( sal_uInt16 nToken,
101 const OUString& rValue )
103 switch( nToken )
105 case XML_ID:
106 xforms_setValue( mxSubmission, "ID", rValue );
107 break;
108 case XML_BIND:
109 xforms_setValue( mxSubmission, "Bind", rValue );
110 break;
111 case XML_REF:
112 xforms_setValue( mxSubmission, "Ref", rValue );
113 break;
114 case XML_ACTION:
115 xforms_setValue( mxSubmission, "Action", rValue );
116 break;
117 case XML_METHOD:
118 xforms_setValue( mxSubmission, "Method", rValue );
119 break;
120 case XML_VERSION:
121 xforms_setValue( mxSubmission, "Version", rValue );
122 break;
123 case XML_INDENT:
124 xforms_setValue( mxSubmission, "Indent", toBool( rValue ) );
125 break;
126 case XML_MEDIATYPE:
127 xforms_setValue( mxSubmission, "MediaType", rValue );
128 break;
129 case XML_ENCODING:
130 xforms_setValue( mxSubmission, "Encoding", rValue );
131 break;
132 case XML_OMIT_XML_DECLARATION:
133 xforms_setValue( mxSubmission, "OmitXmlDeclaration",
134 toBool( rValue ) );
135 break;
136 case XML_STANDALONE:
137 xforms_setValue( mxSubmission, "Standalone", toBool( rValue ) );
138 break;
139 case XML_CDATA_SECTION_ELEMENTS:
140 xforms_setValue( mxSubmission, "CDataSectionElement", rValue );
141 break;
142 case XML_REPLACE:
143 xforms_setValue( mxSubmission, "Replace", rValue );
144 break;
145 case XML_SEPARATOR:
146 xforms_setValue( mxSubmission, "Separator", rValue );
147 break;
148 case XML_INCLUDENAMESPACEPREFIXES:
149 xforms_setValue( mxSubmission, "IncludeNamespacePrefixes", rValue );
150 break;
151 default:
152 OSL_FAIL( "unknown attribute" );
153 break;
157 /** will be called for each child element */
158 SvXMLImportContext* XFormsSubmissionContext::HandleChild(
159 sal_uInt16,
160 sal_uInt16,
161 const OUString&,
162 const Reference<XAttributeList>& )
164 OSL_FAIL( "no children supported" );
165 return NULL;
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */