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#pragma once
21
22#include <algorithm>
23#include <i18nlangtag/lang.h>
24#include <com/sun/star/table/CellAddress.hpp>
25#include <com/sun/star/table/CellRangeAddress.hpp>
26#include "address.hxx"
27
28namespace com::sun::star::lang { struct Locale; }
29
31{
32public:
33 static LanguageType GetLanguage( const css::lang::Locale& rLocale );
34 static void FillLocale( css::lang::Locale& rLocale, LanguageType eLang );
35
36 // CellAddress -> ScAddress
37 static inline void FillScAddress(
38 ScAddress& rScAddress,
39 const css::table::CellAddress& rApiAddress );
40 // ScAddress -> CellAddress
41 static inline void FillApiAddress(
42 css::table::CellAddress& rApiAddress,
43 const ScAddress& rScAddress );
44 // CellRangeAddress -> ScRange
45 static inline void FillScRange(
46 ScRange& rScRange,
47 const css::table::CellRangeAddress& rApiRange );
48 // ScRange -> CellRangeAddress
49 static inline void FillApiRange(
50 css::table::CellRangeAddress& rApiRange,
51 const ScRange& rScRange );
52
54 static inline bool Intersects(
55 const css::table::CellRangeAddress& rApiARange1,
56 const css::table::CellRangeAddress& rApiARange2 );
58 static inline bool Contains(
59 const css::table::CellRangeAddress& rApiOuter,
60 const css::table::CellRangeAddress& rApiInner );
61};
62
64 ScAddress& rScAddress,
65 const css::table::CellAddress& rApiAddress )
66{
67 rScAddress.Set( static_cast<SCCOL>(rApiAddress.Column), static_cast<SCROW>(rApiAddress.Row), static_cast<SCTAB>(rApiAddress.Sheet) );
68}
69
71 css::table::CellAddress& rApiAddress,
72 const ScAddress& rScAddress )
73{
74 rApiAddress.Column = rScAddress.Col();
75 rApiAddress.Row = rScAddress.Row();
76 rApiAddress.Sheet = rScAddress.Tab();
77}
78
80 ScRange& rScRange,
81 const css::table::CellRangeAddress& rApiRange )
82{
83 rScRange.aStart.Set( static_cast<SCCOL>(rApiRange.StartColumn), static_cast<SCROW>(rApiRange.StartRow), static_cast<SCTAB>(rApiRange.Sheet) );
84 rScRange.aEnd.Set( static_cast<SCCOL>(rApiRange.EndColumn), static_cast<SCROW>(rApiRange.EndRow), static_cast<SCTAB>(rApiRange.Sheet) );
85}
86
88 css::table::CellRangeAddress& rApiRange,
89 const ScRange& rScRange )
90{
91 rApiRange.StartColumn = rScRange.aStart.Col();
92 rApiRange.StartRow = rScRange.aStart.Row();
93 rApiRange.Sheet = rScRange.aStart.Tab();
94 rApiRange.EndColumn = rScRange.aEnd.Col();
95 rApiRange.EndRow = rScRange.aEnd.Row();
96}
97
99 const css::table::CellRangeAddress& rApiRange1,
100 const css::table::CellRangeAddress& rApiRange2 )
101{
102 return (rApiRange1.Sheet == rApiRange2.Sheet) &&
103 (::std::max( rApiRange1.StartColumn, rApiRange2.StartColumn ) <= ::std::min( rApiRange1.EndColumn, rApiRange2.EndColumn )) &&
104 (::std::max( rApiRange1.StartRow, rApiRange2.StartRow ) <= ::std::min( rApiRange1.EndRow, rApiRange2.EndRow ));
105}
106
108 const css::table::CellRangeAddress& rApiOuter,
109 const css::table::CellRangeAddress& rApiInner )
110{
111 return (rApiOuter.Sheet == rApiInner.Sheet) &&
112 (rApiOuter.StartColumn <= rApiInner.StartColumn) && (rApiInner.EndColumn <= rApiOuter.EndColumn) &&
113 (rApiOuter.StartRow <= rApiInner.StartRow) && (rApiInner.EndRow <= rApiOuter.EndRow);
114}
115
116/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SCTAB Tab() const
Definition: address.hxx:283
void Set(SCCOL nCol, SCROW nRow, SCTAB nTab)
Definition: address.hxx:403
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
static void FillScAddress(ScAddress &rScAddress, const css::table::CellAddress &rApiAddress)
Definition: convuno.hxx:63
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:98
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:107
static void FillLocale(css::lang::Locale &rLocale, LanguageType eLang)
Definition: convuno.cxx:41
static void FillScRange(ScRange &rScRange, const css::table::CellRangeAddress &rApiRange)
Definition: convuno.hxx:79
static LanguageType GetLanguage(const css::lang::Locale &rLocale)
Definition: convuno.cxx:28
static void FillApiAddress(css::table::CellAddress &rApiAddress, const ScAddress &rScAddress)
Definition: convuno.hxx:70
static void FillApiRange(css::table::CellRangeAddress &rApiRange, const ScRange &rScRange)
Definition: convuno.hxx:87
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
sal_Int32 SCROW
Definition: types.hxx:17