2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-11-16 09:15:18 +00:00
|
|
|
|
2006-09-17 10:31:41 +00:00
|
|
|
|
2004-11-16 09:15:18 +00:00
|
|
|
#include "XFormsSubmissionContext.hxx"
|
|
|
|
|
|
|
|
#include "xformsapi.hxx"
|
|
|
|
|
2007-06-27 15:28:37 +00:00
|
|
|
#include <xmloff/xmlimp.hxx>
|
2010-04-16 23:04:00 +02:00
|
|
|
#include "xmloff/xmlerror.hxx"
|
2007-06-27 15:28:37 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
|
|
|
#include <xmloff/xmltkmap.hxx>
|
2010-04-16 23:04:00 +02:00
|
|
|
#include "xmloff/xmlnmspe.hxx"
|
2007-06-27 15:28:37 +00:00
|
|
|
#include <xmloff/nmspmap.hxx>
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
|
|
|
|
#include <sax/tools/converter.hxx>
|
2004-11-16 09:15:18 +00:00
|
|
|
|
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
2013-03-01 16:32:32 +02:00
|
|
|
#include <com/sun/star/xforms/XModel2.hpp>
|
2004-11-16 09:15:18 +00:00
|
|
|
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
|
|
|
|
using com::sun::star::beans::XPropertySet;
|
|
|
|
using com::sun::star::container::XNameContainer;
|
|
|
|
using com::sun::star::xml::sax::XAttributeList;
|
2013-03-01 16:32:32 +02:00
|
|
|
using com::sun::star::xforms::XModel2;
|
2004-11-16 09:15:18 +00:00
|
|
|
|
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace xmloff::token;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct SvXMLTokenMapEntry aAttributeMap[] =
|
|
|
|
{
|
|
|
|
TOKEN_MAP_ENTRY( NONE, ID ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, BIND ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, REF ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, ACTION ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, METHOD ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, VERSION ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, INDENT ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, MEDIATYPE ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, ENCODING ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, OMIT_XML_DECLARATION ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, STANDALONE ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, CDATA_SECTION_ELEMENTS ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, REPLACE ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, SEPARATOR ),
|
|
|
|
TOKEN_MAP_ENTRY( NONE, INCLUDENAMESPACEPREFIXES ),
|
|
|
|
XML_TOKEN_MAP_END
|
|
|
|
};
|
|
|
|
|
|
|
|
XFormsSubmissionContext::XFormsSubmissionContext(
|
|
|
|
SvXMLImport& rImport,
|
2010-11-10 13:50:33 +08:00
|
|
|
sal_uInt16 nPrefix,
|
2004-11-16 09:15:18 +00:00
|
|
|
const OUString& rLocalName,
|
2013-03-01 16:32:32 +02:00
|
|
|
const Reference<XModel2>& xModel ) :
|
2004-11-16 09:15:18 +00:00
|
|
|
TokenContext( rImport, nPrefix, rLocalName, aAttributeMap, aEmptyMap ),
|
|
|
|
mxSubmission()
|
|
|
|
{
|
|
|
|
// register submission with model
|
|
|
|
DBG_ASSERT( xModel.is(), "need model" );
|
2013-03-01 16:32:32 +02:00
|
|
|
mxSubmission = xModel->createSubmission().get();
|
2004-11-16 09:15:18 +00:00
|
|
|
DBG_ASSERT( mxSubmission.is(), "can't create submission" );
|
2013-03-01 16:32:32 +02:00
|
|
|
xModel->getSubmissions()->insert( makeAny( mxSubmission ) );
|
2004-11-16 09:15:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XFormsSubmissionContext::~XFormsSubmissionContext()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Any toBool( const OUString& rValue )
|
|
|
|
{
|
|
|
|
Any aValue;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
bool bValue(false);
|
|
|
|
if (::sax::Converter::convertBool( bValue, rValue ))
|
2004-11-16 09:15:18 +00:00
|
|
|
{
|
|
|
|
aValue <<= ( bValue ? true : false );
|
|
|
|
}
|
|
|
|
return aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
void XFormsSubmissionContext::HandleAttribute( sal_uInt16 nToken,
|
|
|
|
const OUString& rValue )
|
|
|
|
{
|
|
|
|
switch( nToken )
|
|
|
|
{
|
|
|
|
case XML_ID:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "ID", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_BIND:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Bind", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_REF:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Ref", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_ACTION:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Action", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_METHOD:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Method", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_VERSION:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Version", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_INDENT:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Indent", toBool( rValue ) );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_MEDIATYPE:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "MediaType", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_ENCODING:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Encoding", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_OMIT_XML_DECLARATION:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "OmitXmlDeclaration",
|
2004-11-16 09:15:18 +00:00
|
|
|
toBool( rValue ) );
|
|
|
|
break;
|
|
|
|
case XML_STANDALONE:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Standalone", toBool( rValue ) );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_CDATA_SECTION_ELEMENTS:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "CDataSectionElement", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_REPLACE:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Replace", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_SEPARATOR:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "Separator", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
case XML_INCLUDENAMESPACEPREFIXES:
|
2013-01-29 09:43:53 +01:00
|
|
|
xforms_setValue( mxSubmission, "IncludeNamespacePrefixes", rValue );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "unknown attribute" );
|
2004-11-16 09:15:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** will be called for each child element */
|
|
|
|
SvXMLImportContext* XFormsSubmissionContext::HandleChild(
|
2006-06-19 17:57:52 +00:00
|
|
|
sal_uInt16,
|
|
|
|
sal_uInt16,
|
|
|
|
const OUString&,
|
|
|
|
const Reference<XAttributeList>& )
|
2004-11-16 09:15:18 +00:00
|
|
|
{
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL( "no children supported" );
|
2004-11-16 09:15:18 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|