tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / forms / source / xforms / convert.hxx
blobc7073f7c36cdf63ca9c3874930a54cf130f278cc
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 #pragma once
22 #include <com/sun/star/uno/Sequence.hxx>
23 #include <map>
25 namespace com::sun::star::uno
27 class Any;
28 class Type;
31 namespace xforms
34 struct TypeLess
36 bool operator()( const css::uno::Type& rType1,
37 const css::uno::Type& rType2 ) const
38 { return rType1.getTypeName() < rType2.getTypeName(); }
41 class Convert
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;
48 Map_t maMap;
50 Convert();
52 void init();
54 public:
55 /** get/create Singleton class */
56 static Convert& get();
58 /// can we convert this type?
59 bool hasType( const css::uno::Type& );
61 /// get list of convertible types
62 css::uno::Sequence<css::uno::Type> getTypes() const;
64 /// convert any to XML representation
65 OUString toXSD( const css::uno::Any& rAny );
67 /// convert XML representation to Any of given type
68 css::uno::Any toAny( const OUString&, const css::uno::Type& );
70 /** replace all sequences of 0x08, 0x0A, 0x0D, 0x20 with a single 0x20.
71 also strip leading/trailing whitespace.
73 static OUString collapseWhitespace( const OUString& _rString );
76 } // namespace xforms
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */