LibreOffice Module sc (master)  1
convuno.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 #ifndef INCLUDED_SC_INC_CONVUNO_HXX
21 #define INCLUDED_SC_INC_CONVUNO_HXX
22 
23 #include <algorithm>
24 #include <i18nlangtag/lang.h>
25 #include <com/sun/star/table/CellAddress.hpp>
26 #include <com/sun/star/table/CellRangeAddress.hpp>
27 #include "address.hxx"
28 
29 namespace com::sun::star::lang { struct Locale; }
30 
32 {
33 public:
34  static LanguageType GetLanguage( const css::lang::Locale& rLocale );
35  static void FillLocale( css::lang::Locale& rLocale, LanguageType eLang );
36 
37  // CellAddress -> ScAddress
38  static inline void FillScAddress(
39  ScAddress& rScAddress,
40  const css::table::CellAddress& rApiAddress );
41  // ScAddress -> CellAddress
42  static inline void FillApiAddress(
43  css::table::CellAddress& rApiAddress,
44  const ScAddress& rScAddress );
45  // CellRangeAddress -> ScRange
46  static inline void FillScRange(
47  ScRange& rScRange,
48  const css::table::CellRangeAddress& rApiRange );
49  // ScRange -> CellRangeAddress
50  static inline void FillApiRange(
51  css::table::CellRangeAddress& rApiRange,
52  const ScRange& rScRange );
53 
55  static inline bool Intersects(
56  const css::table::CellRangeAddress& rApiARange1,
57  const css::table::CellRangeAddress& rApiARange2 );
59  static inline bool Contains(
60  const css::table::CellRangeAddress& rApiOuter,
61  const css::table::CellRangeAddress& rApiInner );
62 };
63 
65  ScAddress& rScAddress,
66  const css::table::CellAddress& rApiAddress )
67 {
68  rScAddress.Set( static_cast<SCCOL>(rApiAddress.Column), static_cast<SCROW>(rApiAddress.Row), static_cast<SCTAB>(rApiAddress.Sheet) );
69 }
70 
72  css::table::CellAddress& rApiAddress,
73  const ScAddress& rScAddress )
74 {
75  rApiAddress.Column = rScAddress.Col();
76  rApiAddress.Row = rScAddress.Row();
77  rApiAddress.Sheet = rScAddress.Tab();
78 }
79 
81  ScRange& rScRange,
82  const css::table::CellRangeAddress& rApiRange )
83 {
84  rScRange.aStart.Set( static_cast<SCCOL>(rApiRange.StartColumn), static_cast<SCROW>(rApiRange.StartRow), static_cast<SCTAB>(rApiRange.Sheet) );
85  rScRange.aEnd.Set( static_cast<SCCOL>(rApiRange.EndColumn), static_cast<SCROW>(rApiRange.EndRow), static_cast<SCTAB>(rApiRange.Sheet) );
86 }
87 
89  css::table::CellRangeAddress& rApiRange,
90  const ScRange& rScRange )
91 {
92  rApiRange.StartColumn = rScRange.aStart.Col();
93  rApiRange.StartRow = rScRange.aStart.Row();
94  rApiRange.Sheet = rScRange.aStart.Tab();
95  rApiRange.EndColumn = rScRange.aEnd.Col();
96  rApiRange.EndRow = rScRange.aEnd.Row();
97 }
98 
100  const css::table::CellRangeAddress& rApiRange1,
101  const css::table::CellRangeAddress& rApiRange2 )
102 {
103  return (rApiRange1.Sheet == rApiRange2.Sheet) &&
104  (::std::max( rApiRange1.StartColumn, rApiRange2.StartColumn ) <= ::std::min( rApiRange1.EndColumn, rApiRange2.EndColumn )) &&
105  (::std::max( rApiRange1.StartRow, rApiRange2.StartRow ) <= ::std::min( rApiRange1.EndRow, rApiRange2.EndRow ));
106 }
107 
109  const css::table::CellRangeAddress& rApiOuter,
110  const css::table::CellRangeAddress& rApiInner )
111 {
112  return (rApiOuter.Sheet == rApiInner.Sheet) &&
113  (rApiOuter.StartColumn <= rApiInner.StartColumn) && (rApiInner.EndColumn <= rApiOuter.EndColumn) &&
114  (rApiOuter.StartRow <= rApiInner.StartRow) && (rApiInner.EndRow <= rApiOuter.EndRow);
115 }
116 
117 #endif
118 
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScAddress aStart
Definition: address.hxx:500
SCROW Row() const
Definition: address.hxx:262
static void FillLocale(css::lang::Locale &rLocale, LanguageType eLang)
Definition: convuno.cxx:41
ScAddress aEnd
Definition: address.hxx:501
static void FillApiAddress(css::table::CellAddress &rApiAddress, const ScAddress &rScAddress)
Definition: convuno.hxx:71
static bool Contains(const css::table::CellRangeAddress &rApiOuter, const css::table::CellRangeAddress &rApiInner)
Returns true, if the passed range rApiInner is completely inside the passed range rApiOuter...
Definition: convuno.hxx:108
static LanguageType GetLanguage(const css::lang::Locale &rLocale)
Definition: convuno.cxx:28
static bool Intersects(const css::table::CellRangeAddress &rApiARange1, const css::table::CellRangeAddress &rApiARange2)
Returns true, if the passed ranges have at least one common cell.
Definition: convuno.hxx:99
SCTAB Tab() const
Definition: address.hxx:271
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:406
static void FillScAddress(ScAddress &rScAddress, const css::table::CellAddress &rApiAddress)
Definition: convuno.hxx:64
SCCOL Col() const
Definition: address.hxx:267
static void FillApiRange(css::table::CellRangeAddress &rApiRange, const ScRange &rScRange)
Definition: convuno.hxx:88
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
Definition: convuno.hxx:80