xref: /aoo4110/main/sc/inc/reftokenhelper.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_REFTOKENHELPER_HXX
25 #define SC_REFTOKENHELPER_HXX
26 
27 #include "token.hxx"
28 
29 #include <vector>
30 
31 namespace rtl {
32     class OUString;
33 }
34 
35 class ScDocument;
36 class ScRange;
37 class ScRangeList;
38 
39 class ScRefTokenHelper
40 {
41 private:
42     ScRefTokenHelper();
43     ScRefTokenHelper(const ScRefTokenHelper&);
44     ~ScRefTokenHelper();
45 
46 public:
47     /**
48      * Compile an array of reference tokens from a data source range string.
49      * The source range may consist of multiple ranges separated by ';'s.
50      */
51     static void compileRangeRepresentation(
52         ::std::vector<ScSharedTokenRef>& rRefTokens, const ::rtl::OUString& rRangeStr, ScDocument* pDoc,
53         ::formula::FormulaGrammar::Grammar eGrammar = ::formula::FormulaGrammar::GRAM_ENGLISH);
54 
55     static bool getRangeFromToken(ScRange& rRange, const ScSharedTokenRef& pToken, bool bExternal = false);
56 
57     static void getRangeListFromTokens(ScRangeList& rRangeList, const ::std::vector<ScSharedTokenRef>& pTokens);
58 
59     /**
60      * Create a double reference token from a range object.
61      */
62     static void getTokenFromRange(ScSharedTokenRef& pToken, const ScRange& rRange);
63 
64     static void getTokensFromRangeList(::std::vector<ScSharedTokenRef>& pTokens, const ScRangeList& rRanges);
65 
66     static bool SC_DLLPUBLIC isRef(const ScSharedTokenRef& pToken);
67     static bool SC_DLLPUBLIC isExternalRef(const ScSharedTokenRef& pToken);
68 
69     static bool SC_DLLPUBLIC intersects(const ::std::vector<ScSharedTokenRef>& rTokens, const ScSharedTokenRef& pToken);
70 
71     static void SC_DLLPUBLIC join(::std::vector<ScSharedTokenRef>& rTokens, const ScSharedTokenRef& pToken);
72 
73     static bool getDoubleRefDataFromToken(ScComplexRefData& rData, const ScSharedTokenRef& pToken);
74 };
75 
76 #endif
77