bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / xforms / convert.hxx
blob7784fc6d8458a1ae416e4097bfa82a429fc8d372
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 #ifndef INCLUDED_FORMS_SOURCE_XFORMS_CONVERT_HXX
21 #define INCLUDED_FORMS_SOURCE_XFORMS_CONVERT_HXX
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <map>
26 namespace com { namespace sun { namespace star { namespace uno
28 class Any;
29 class Type;
30 } } } }
32 namespace xforms
35 struct TypeLess
37 bool operator()( const com::sun::star::uno::Type& rType1,
38 const com::sun::star::uno::Type& rType2 ) const
39 { return rType1.getTypeName() < rType2.getTypeName(); }
42 class Convert
44 typedef com::sun::star::uno::Type Type_t;
45 typedef com::sun::star::uno::Sequence<com::sun::star::uno::Type> Types_t;
46 typedef com::sun::star::uno::Any Any_t;
48 // hold conversion objects
49 typedef OUString (*fn_toXSD)( const Any_t& );
50 typedef Any_t (*fn_toAny)( const OUString& );
51 typedef std::pair<fn_toXSD,fn_toAny> Convert_t;
52 typedef std::map<Type_t,Convert_t,TypeLess> Map_t;
53 Map_t maMap;
55 Convert();
57 void init();
59 public:
60 /** get/create Singleton class */
61 static Convert& get();
63 /// can we convert this type?
64 bool hasType( const Type_t& );
66 /// get list of convertible types
67 Types_t getTypes();
69 /// convert any to XML representation
70 OUString toXSD( const Any_t& rAny );
72 /// convert XML representation to Any of given type
73 Any_t toAny( const OUString&, const Type_t& );
75 /** replace all sequences of 0x08, 0x0A, 0x0D, 0x20 with a single 0x20.
76 also strip leading/trailing whitespace.
78 static OUString collapseWhitespace( const OUString& _rString );
81 } // namespace xforms
83 #endif
85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */