tdf#125181 maxY is 50000 in prstGeom for star24 and star32
[LibreOffice.git] / sc / inc / convuno.hxx
blob389badf0eb849cc3ef346d878a4b595527bb1781
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_SC_INC_CONVUNO_HXX
21 #define INCLUDED_SC_INC_CONVUNO_HXX
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"
29 namespace com { namespace sun { namespace star { namespace lang { struct Locale; } } } }
31 class ScUnoConversion
33 public:
34 static LanguageType GetLanguage( const css::lang::Locale& rLocale );
35 static void FillLocale( css::lang::Locale& rLocale, LanguageType eLang );
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 );
54 /** Returns true, if the passed ranges have at least one common cell. */
55 static inline bool Intersects(
56 const css::table::CellRangeAddress& rApiARange1,
57 const css::table::CellRangeAddress& rApiARange2 );
58 /** Returns true, if the passed range rApiInner is completely inside the passed range rApiOuter. */
59 static inline bool Contains(
60 const css::table::CellRangeAddress& rApiOuter,
61 const css::table::CellRangeAddress& rApiInner );
64 inline void ScUnoConversion::FillScAddress(
65 ScAddress& rScAddress,
66 const css::table::CellAddress& rApiAddress )
68 rScAddress.Set( static_cast<SCCOL>(rApiAddress.Column), static_cast<SCROW>(rApiAddress.Row), static_cast<SCTAB>(rApiAddress.Sheet) );
71 inline void ScUnoConversion::FillApiAddress(
72 css::table::CellAddress& rApiAddress,
73 const ScAddress& rScAddress )
75 rApiAddress.Column = rScAddress.Col();
76 rApiAddress.Row = rScAddress.Row();
77 rApiAddress.Sheet = rScAddress.Tab();
80 inline void ScUnoConversion::FillScRange(
81 ScRange& rScRange,
82 const css::table::CellRangeAddress& rApiRange )
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) );
88 inline void ScUnoConversion::FillApiRange(
89 css::table::CellRangeAddress& rApiRange,
90 const ScRange& rScRange )
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();
99 inline bool ScUnoConversion::Intersects(
100 const css::table::CellRangeAddress& rApiRange1,
101 const css::table::CellRangeAddress& rApiRange2 )
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 ));
108 inline bool ScUnoConversion::Contains(
109 const css::table::CellRangeAddress& rApiOuter,
110 const css::table::CellRangeAddress& rApiInner )
112 return (rApiOuter.Sheet == rApiInner.Sheet) &&
113 (rApiOuter.StartColumn <= rApiInner.StartColumn) && (rApiInner.EndColumn <= rApiOuter.EndColumn) &&
114 (rApiOuter.StartRow <= rApiInner.StartRow) && (rApiInner.EndRow <= rApiOuter.EndRow);
117 #endif
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */