LibreOffice Module forms (master) 1
convert.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/uno/Sequence.hxx>
23#include <map>
24
25namespace com::sun::star::uno
26{
27 class Any;
28 class Type;
29}
30
31namespace xforms
32{
33
35{
36 bool operator()( const css::uno::Type& rType1,
37 const css::uno::Type& rType2 ) const
38 { return rType1.getTypeName() < rType2.getTypeName(); }
39};
40
42{
43 // hold conversion objects
44 typedef OUString (*fn_toXSD)( const css::uno::Any& );
45 typedef css::uno::Any (*fn_toAny)( const OUString& );
46 typedef std::pair<fn_toXSD,fn_toAny> Convert_t;
47 typedef std::map<css::uno::Type, Convert_t, TypeLess> Map_t;
49
50 Convert();
51
52 void init();
53
54public:
56 static Convert& get();
57
59 bool hasType( const css::uno::Type& );
60
62 css::uno::Sequence<css::uno::Type> getTypes() const;
63
65 OUString toXSD( const css::uno::Any& rAny );
66
68 css::uno::Any toAny( const OUString&, const css::uno::Type& );
69
73 static OUString collapseWhitespace( const OUString& _rString );
74};
75
76} // namespace xforms
77
78/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< css::uno::Type > getTypes() const
get list of convertible types
Definition: convert.cxx:286
static OUString collapseWhitespace(const OUString &_rString)
replace all sequences of 0x08, 0x0A, 0x0D, 0x20 with a single 0x20.
Definition: convert.cxx:305
std::pair< fn_toXSD, fn_toAny > Convert_t
Definition: convert.hxx:46
css::uno::Any(* fn_toAny)(const OUString &)
Definition: convert.hxx:45
bool hasType(const css::uno::Type &)
can we convert this type?
Definition: convert.cxx:281
static Convert & get()
get/create Singleton class
Definition: convert.cxx:274
OUString(* fn_toXSD)(const css::uno::Any &)
Definition: convert.hxx:44
css::uno::Any toAny(const OUString &, const css::uno::Type &)
convert XML representation to Any of given type
Definition: convert.cxx:297
OUString toXSD(const css::uno::Any &rAny)
convert any to XML representation
Definition: convert.cxx:291
std::map< css::uno::Type, Convert_t, TypeLess > Map_t
Definition: convert.hxx:47
Type
bool operator()(const css::uno::Type &rType1, const css::uno::Type &rType2) const
Definition: convert.hxx:36