Gtk-WARNING gtktreestore.c:1047: Invalid column number 1 added to iter
[LibreOffice.git] / xmloff / source / xforms / TokenContext.cxx
blob6275bad5c73f2336194597bc7626c112da3d3813
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 .
20 #include <sal/config.h>
22 #include "TokenContext.hxx"
23 #include <xmloff/xmlimp.hxx>
24 #include <xmloff/xmlerror.hxx>
26 #include <algorithm>
28 using com::sun::star::uno::Reference;
30 TokenContext::TokenContext( SvXMLImport& rImport )
31 : SvXMLImportContext( rImport )
35 void TokenContext::startFastElement(
36 sal_Int32 /*nElement*/,
37 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
39 // iterate over attributes
40 // - if in map: call HandleAttribute
41 // - xmlns:... : ignore
42 // - other: warning
44 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
45 HandleAttribute( aIter );
48 css::uno::Reference< css::xml::sax::XFastContextHandler > TokenContext::createFastChildContext(
49 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
51 // call handle child, and pass down arguments
52 SvXMLImportContext* pContext = HandleChild( nElement, xAttrList );
53 // error handling: create default context and generate warning
54 if( pContext == nullptr )
56 GetImport().SetError( XMLERROR_UNKNOWN_ELEMENT, SvXMLImport::getNameFromToken( nElement ) );
58 return pContext;
61 css::uno::Reference< css::xml::sax::XFastContextHandler > TokenContext::createUnknownChildContext(
62 const OUString& Namespace, const OUString& Name, const css::uno::Reference< css::xml::sax::XFastAttributeList >& )
64 GetImport().SetError( XMLERROR_UNKNOWN_ELEMENT, Namespace + " " + Name );
65 return nullptr;
68 static bool lcl_IsWhiteSpace( sal_Unicode c )
70 return c == ' '
71 || c == u'\x0009'
72 || c == u'\x000A'
73 || c == u'\x000D';
76 void TokenContext::characters( const OUString& rCharacters )
78 // get iterators for string data
79 const sal_Unicode* pBegin = rCharacters.getStr();
80 const sal_Unicode* pEnd = &( pBegin[ rCharacters.getLength() ] );
82 // raise error if non-whitespace character is found
83 if( !::std::all_of( pBegin, pEnd, lcl_IsWhiteSpace ) )
84 GetImport().SetError( XMLERROR_UNKNOWN_CHARACTERS, rCharacters );
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */