1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 SC_STRINGUTIL_HXX
21 #define SC_STRINGUTIL_HXX
23 #include "rtl/ustring.hxx"
24 #include "tools/string.hxx"
27 class SvNumberFormatter
;
30 * Store parameters used in the ScDocument::SetString() method. Various
31 * options for string-setting operation are specified herein.
33 struct SC_DLLPUBLIC ScSetStringParam
38 * Set Text number format no matter what the input string is.
43 * Set Text number format only when the input string is considered a
44 * special number but we only want to detect a simple number.
49 * Never set Text number format.
55 * Stores the pointer to the number formatter instance to be used during
56 * number format detection. The caller must manage the life cycle of the
59 SvNumberFormatter
* mpNumFormatter
;
62 * When true, we try to detect special number format (dates etc) from the
63 * input string, when false, we only try to detect a basic decimal number
66 bool mbDetectNumberFormat
;
69 * Determine when to set the 'Text' number format to the cell where the
70 * input string is being set.
72 TextFormatPolicy meSetTextNumFormat
;
75 * When true, treat input with a leading apostrophe / single quote special
76 * in that it escapes numeric or date/time input such that it is not
77 * interpreted and the input string is taken instead. This can be used
78 * during text file import so the leading apostrophe is not lost if it
79 * precedes a numeric value.
80 * Usually set mbHandleApostrophe = !mbSetTextCellFormat
82 bool mbHandleApostrophe
;
87 // ============================================================================
93 * Check if a given string is a simple decimal number (e.g. 12.345). We
94 * don't do any elaborate parsing here; we only check for the simplest
95 * case of decimal number format.
97 * Note that preceding and trailing spaces are ignored during parsing.
99 * @param rStr string to parse
100 * @param dsep decimal separator
101 * @param gsep group separator (aka thousands separator)
102 * @param rVal value of successfully parsed number
104 * @return true if the string is a valid number, false otherwise.
106 static bool parseSimpleNumber(
107 const ::rtl::OUString
& rStr
, sal_Unicode dsep
, sal_Unicode gsep
, double& rVal
);
109 static xub_StrLen SC_DLLPUBLIC
GetQuotedTokenCount(const UniString
&rIn
, const UniString
& rQuotedPairs
, sal_Unicode cTok
= ';' );
110 static UniString SC_DLLPUBLIC
GetQuotedToken(const UniString
&rIn
, xub_StrLen nToken
, const UniString
& rQuotedPairs
,
111 sal_Unicode cTok
, xub_StrLen
& rIndex
);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */