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::xml::sax::XAttributeList
;
38 using com::sun::star::xforms::XModel2
;
40 using namespace com::sun::star::uno
;
41 using namespace xmloff::token
;
44 XFormsSubmissionContext::XFormsSubmissionContext(
46 const Reference
<XModel2
>& xModel
) :
47 TokenContext( rImport
),
50 // register submission with model
51 SAL_WARN_IF( !xModel
.is(), "xmloff", "need model" );
52 mxSubmission
= xModel
->createSubmission().get();
53 SAL_WARN_IF( !mxSubmission
.is(), "xmloff", "can't create submission" );
54 xModel
->getSubmissions()->insert( makeAny( mxSubmission
) );
59 Any
toBool( const OUString
& rValue
)
63 if (::sax::Converter::convertBool( bValue
, rValue
))
72 void XFormsSubmissionContext::HandleAttribute( sal_Int32 nAttributeToken
,
73 const OUString
& rValue
)
75 switch( nAttributeToken
)
77 case XML_ELEMENT(NONE
, XML_ID
):
78 xforms_setValue( mxSubmission
, "ID", rValue
);
80 case XML_ELEMENT(NONE
, XML_BIND
):
81 xforms_setValue( mxSubmission
, "Bind", rValue
);
83 case XML_ELEMENT(NONE
, XML_REF
):
84 xforms_setValue( mxSubmission
, "Ref", rValue
);
86 case XML_ELEMENT(NONE
, XML_ACTION
):
87 xforms_setValue( mxSubmission
, "Action", rValue
);
89 case XML_ELEMENT(NONE
, XML_METHOD
):
90 xforms_setValue( mxSubmission
, "Method", rValue
);
92 case XML_ELEMENT(NONE
, XML_VERSION
):
93 xforms_setValue( mxSubmission
, "Version", rValue
);
95 case XML_ELEMENT(NONE
, XML_INDENT
):
96 xforms_setValue( mxSubmission
, "Indent", toBool( rValue
) );
98 case XML_ELEMENT(NONE
, XML_MEDIATYPE
):
99 xforms_setValue( mxSubmission
, "MediaType", rValue
);
101 case XML_ELEMENT(NONE
, XML_ENCODING
):
102 xforms_setValue( mxSubmission
, "Encoding", rValue
);
104 case XML_ELEMENT(NONE
, XML_OMIT_XML_DECLARATION
):
105 xforms_setValue( mxSubmission
, "OmitXmlDeclaration",
108 case XML_ELEMENT(NONE
, XML_STANDALONE
):
109 xforms_setValue( mxSubmission
, "Standalone", toBool( rValue
) );
111 case XML_ELEMENT(NONE
, XML_CDATA_SECTION_ELEMENTS
):
112 xforms_setValue( mxSubmission
, "CDataSectionElement", rValue
);
114 case XML_ELEMENT(NONE
, XML_REPLACE
):
115 xforms_setValue( mxSubmission
, "Replace", rValue
);
117 case XML_ELEMENT(NONE
, XML_SEPARATOR
):
118 xforms_setValue( mxSubmission
, "Separator", rValue
);
120 case XML_ELEMENT(NONE
, XML_INCLUDENAMESPACEPREFIXES
):
121 xforms_setValue( mxSubmission
, "IncludeNamespacePrefixes", rValue
);
124 OSL_FAIL( "unknown attribute" );
129 /** will be called for each child element */
130 SvXMLImportContext
* XFormsSubmissionContext::HandleChild(
132 const Reference
<css::xml::sax::XFastAttributeList
>& )
134 OSL_FAIL( "no children supported" );
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */