1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: convuno.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SC_CONVUNO_HXX
32 #define SC_CONVUNO_HXX
34 #include <i18npool/lang.h>
35 #include <com/sun/star/table/CellAddress.hpp>
36 #include <com/sun/star/table/CellRangeAddress.hpp>
37 #include <com/sun/star/lang/Locale.hpp>
39 #include "address.hxx"
45 static LanguageType
GetLanguage( const com::sun::star::lang::Locale
& rLocale
);
46 static void FillLocale( com::sun::star::lang::Locale
& rLocale
, LanguageType eLang
);
48 // CellAddress -> ScAddress
49 static inline void FillScAddress(
50 ScAddress
& rScAddress
,
51 const ::com::sun::star::table::CellAddress
& rApiAddress
);
52 // ScAddress -> CellAddress
53 static inline void FillApiAddress(
54 ::com::sun::star::table::CellAddress
& rApiAddress
,
55 const ScAddress
& rScAddress
);
56 // CellRangeAddress -> ScRange
57 static inline void FillScRange(
59 const ::com::sun::star::table::CellRangeAddress
& rApiRange
);
60 // ScRange -> CellRangeAddress
61 static inline void FillApiRange(
62 ::com::sun::star::table::CellRangeAddress
& rApiRange
,
63 const ScRange
& rScRange
);
64 // CellAddress -> CellRangeAddress
65 static inline void FillApiRange(
66 ::com::sun::star::table::CellRangeAddress
& rApiRange
,
67 const ::com::sun::star::table::CellAddress
& rApiAddress
);
68 // CellRangeAddress-Start -> CellAddress
69 static inline void FillApiStartAddress(
70 ::com::sun::star::table::CellAddress
& rApiAddress
,
71 const ::com::sun::star::table::CellRangeAddress
& rApiRange
);
72 // CellRangeAddress-End -> CellAddress
73 static inline void FillApiEndAddress(
74 ::com::sun::star::table::CellAddress
& rApiAddress
,
75 const ::com::sun::star::table::CellRangeAddress
& rApiRange
);
79 inline void ScUnoConversion::FillScAddress(
80 ScAddress
& rScAddress
,
81 const ::com::sun::star::table::CellAddress
& rApiAddress
)
83 rScAddress
.Set( (SCCOL
)rApiAddress
.Column
, (SCROW
)rApiAddress
.Row
, (SCTAB
)rApiAddress
.Sheet
);
86 inline void ScUnoConversion::FillApiAddress(
87 ::com::sun::star::table::CellAddress
& rApiAddress
,
88 const ScAddress
& rScAddress
)
90 rApiAddress
.Column
= rScAddress
.Col();
91 rApiAddress
.Row
= rScAddress
.Row();
92 rApiAddress
.Sheet
= rScAddress
.Tab();
95 inline void ScUnoConversion::FillScRange(
97 const ::com::sun::star::table::CellRangeAddress
& rApiRange
)
99 rScRange
.aStart
.Set( (SCCOL
)rApiRange
.StartColumn
, (SCROW
)rApiRange
.StartRow
, (SCTAB
)rApiRange
.Sheet
);
100 rScRange
.aEnd
.Set( (SCCOL
)rApiRange
.EndColumn
, (SCROW
)rApiRange
.EndRow
, (SCTAB
)rApiRange
.Sheet
);
103 inline void ScUnoConversion::FillApiRange(
104 ::com::sun::star::table::CellRangeAddress
& rApiRange
,
105 const ScRange
& rScRange
)
107 rApiRange
.StartColumn
= rScRange
.aStart
.Col();
108 rApiRange
.StartRow
= rScRange
.aStart
.Row();
109 rApiRange
.Sheet
= rScRange
.aStart
.Tab();
110 rApiRange
.EndColumn
= rScRange
.aEnd
.Col();
111 rApiRange
.EndRow
= rScRange
.aEnd
.Row();
114 inline void ScUnoConversion::FillApiRange(
115 ::com::sun::star::table::CellRangeAddress
& rApiRange
,
116 const ::com::sun::star::table::CellAddress
& rApiAddress
)
118 rApiRange
.StartColumn
= rApiRange
.EndColumn
= rApiAddress
.Column
;
119 rApiRange
.StartRow
= rApiRange
.EndRow
= rApiAddress
.Row
;
120 rApiRange
.Sheet
= rApiAddress
.Sheet
;
123 inline void ScUnoConversion::FillApiStartAddress(
124 ::com::sun::star::table::CellAddress
& rApiAddress
,
125 const ::com::sun::star::table::CellRangeAddress
& rApiRange
)
127 rApiAddress
.Column
= rApiRange
.StartColumn
;
128 rApiAddress
.Row
= rApiRange
.StartRow
;
129 rApiAddress
.Sheet
= rApiRange
.Sheet
;
132 inline void ScUnoConversion::FillApiEndAddress(
133 ::com::sun::star::table::CellAddress
& rApiAddress
,
134 const ::com::sun::star::table::CellRangeAddress
& rApiRange
)
136 rApiAddress
.Column
= rApiRange
.EndColumn
;
137 rApiAddress
.Row
= rApiRange
.EndRow
;
138 rApiAddress
.Sheet
= rApiRange
.Sheet
;
141 //___________________________________________________________________
143 inline sal_Bool
operator==(
144 const ::com::sun::star::table::CellAddress
& rApiAddress1
,
145 const ::com::sun::star::table::CellAddress
& rApiAddress2
)
148 (rApiAddress1
.Column
== rApiAddress2
.Column
) &&
149 (rApiAddress1
.Row
== rApiAddress2
.Row
) &&
150 (rApiAddress1
.Sheet
== rApiAddress2
.Sheet
);
153 inline sal_Bool
operator!=(
154 const ::com::sun::star::table::CellAddress
& rApiAddress1
,
155 const ::com::sun::star::table::CellAddress
& rApiAddress2
)
157 return !(rApiAddress1
== rApiAddress2
);
160 inline sal_Bool
operator==(
161 const ::com::sun::star::table::CellRangeAddress
& rApiRange1
,
162 const ::com::sun::star::table::CellRangeAddress
& rApiRange2
)
165 (rApiRange1
.StartColumn
== rApiRange2
.StartColumn
) &&
166 (rApiRange1
.StartRow
== rApiRange2
.StartRow
) &&
167 (rApiRange1
.EndColumn
== rApiRange2
.EndColumn
) &&
168 (rApiRange1
.EndRow
== rApiRange2
.EndRow
) &&
169 (rApiRange1
.Sheet
== rApiRange2
.Sheet
);
172 inline sal_Bool
operator!=(
173 const ::com::sun::star::table::CellRangeAddress
& rApiRange1
,
174 const ::com::sun::star::table::CellRangeAddress
& rApiRange2
)
176 return !(rApiRange1
== rApiRange2
);