Avoid potential negative array index access to cached text.
[LibreOffice.git] / include / connectivity / formattedcolumnvalue.hxx
blob9fdf227edb9eb03b80693aa634e76544832330fd
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_CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX
21 #define INCLUDED_CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX
23 #include <connectivity/dbtoolsdllapi.hxx>
24 #include <rtl/ustring.hxx>
25 #include <memory>
27 namespace com::sun::star::beans { class XPropertySet; }
28 namespace com::sun::star::sdbc { class XRowSet; }
29 namespace com::sun::star::sdb { class XColumn; }
30 namespace com::sun::star::uno { class XComponentContext; }
31 namespace com::sun::star::uno { template <typename > class Reference; }
32 namespace com::sun::star::util { class XNumberFormatter; }
34 namespace dbtools
36 struct FormattedColumnValue_Data;
38 //= FormattedColumnValue
40 /** a class which helps retrieving and setting the value of a database column
41 as formatted string.
43 class OOO_DLLPUBLIC_DBTOOLS FormattedColumnValue final
45 public:
46 /** constructs an instance
48 The format key for the string value exchange is taken from the given column object.
49 If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken.
50 Otherwise, a default format matching the column type is determined.
52 The locale of this fallback format is the current system locale.
54 The number formats supplier is determined from the given <code>RowSet</code>, by
55 examining its <code>ActiveConnection</code>.
57 FormattedColumnValue(
58 const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
59 const css::uno::Reference< css::sdbc::XRowSet >& _rxRowSet,
60 const css::uno::Reference< css::beans::XPropertySet >& _rxColumn
63 /** constructs an instance
65 The format key for the string value exchange is taken from the given column object.
66 If it has a non-<NULL/> property value <code>FormatKey</code>, this key is taken.
67 Otherwise, a default format matching the column type is determined.
69 The locale of this fallback format is the current system locale.
71 FormattedColumnValue(
72 const css::uno::Reference< css::util::XNumberFormatter >& i_rNumberFormatter,
73 const css::uno::Reference< css::beans::XPropertySet >& i_rColumn
76 ~FormattedColumnValue();
78 // access to the details of the formatting we determined
79 sal_Int16 getKeyType() const;
80 const css::uno::Reference< css::sdb::XColumn >&
81 getColumn() const;
83 bool setFormattedValue( const OUString& _rFormattedStringValue ) const;
84 OUString getFormattedValue() const;
86 private:
87 FormattedColumnValue(const FormattedColumnValue&) = delete;
88 FormattedColumnValue& operator=(const FormattedColumnValue&) = delete;
89 std::unique_ptr< FormattedColumnValue_Data > m_pData;
93 } // namespace dbtools
96 #endif // INCLUDED_CONNECTIVITY_FORMATTEDCOLUMNVALUE_HXX
98 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */