LCOV - code coverage report
Current view: top level - libreoffice/sc/inc - convuno.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 19 35 54.3 %
Date: 2012-12-27 Functions: 4 10 40.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 SC_CONVUNO_HXX
      21             : #define SC_CONVUNO_HXX
      22             : 
      23             : #include <algorithm>
      24             : #include <i18npool/lang.h>
      25             : #include <com/sun/star/table/CellAddress.hpp>
      26             : #include <com/sun/star/table/CellRangeAddress.hpp>
      27             : #include <com/sun/star/lang/Locale.hpp>
      28             : #include "global.hxx"
      29             : #include "address.hxx"
      30             : 
      31             : 
      32             : class ScUnoConversion
      33             : {
      34             : public:
      35             :     static LanguageType GetLanguage( const com::sun::star::lang::Locale& rLocale );
      36             :     static void FillLocale( com::sun::star::lang::Locale& rLocale, LanguageType eLang );
      37             : 
      38             :     // CellAddress -> ScAddress
      39             :     static inline void  FillScAddress(
      40             :                             ScAddress& rScAddress,
      41             :                             const ::com::sun::star::table::CellAddress& rApiAddress );
      42             :     // ScAddress -> CellAddress
      43             :     static inline void  FillApiAddress(
      44             :                             ::com::sun::star::table::CellAddress& rApiAddress,
      45             :                             const ScAddress& rScAddress );
      46             :     // CellRangeAddress -> ScRange
      47             :     static inline void  FillScRange(
      48             :                             ScRange& rScRange,
      49             :                             const ::com::sun::star::table::CellRangeAddress& rApiRange );
      50             :     // ScRange -> CellRangeAddress
      51             :     static inline void  FillApiRange(
      52             :                             ::com::sun::star::table::CellRangeAddress& rApiRange,
      53             :                             const ScRange& rScRange );
      54             :     // CellAddress -> CellRangeAddress
      55             :     static inline void  FillApiRange(
      56             :                             ::com::sun::star::table::CellRangeAddress& rApiRange,
      57             :                             const ::com::sun::star::table::CellAddress& rApiAddress );
      58             :     // CellRangeAddress-Start -> CellAddress
      59             :     static inline void  FillApiStartAddress(
      60             :                             ::com::sun::star::table::CellAddress& rApiAddress,
      61             :                             const ::com::sun::star::table::CellRangeAddress& rApiRange );
      62             :     // CellRangeAddress-End -> CellAddress
      63             :     static inline void  FillApiEndAddress(
      64             :                             ::com::sun::star::table::CellAddress& rApiAddress,
      65             :                             const ::com::sun::star::table::CellRangeAddress& rApiRange );
      66             : 
      67             :     /** Returns true, if the passed ranges have at least one common cell. */
      68             :     static inline bool  Intersects(
      69             :                             const ::com::sun::star::table::CellRangeAddress& rApiARange1,
      70             :                             const ::com::sun::star::table::CellRangeAddress& rApiARange2 );
      71             :     /** Returns true, if the passed address rApiInner is inside the passed range rApiOuter. */
      72             :     static inline bool  Contains(
      73             :                             const ::com::sun::star::table::CellRangeAddress& rApiOuter,
      74             :                             const ::com::sun::star::table::CellAddress& rApiInner );
      75             :     /** Returns true, if the passed range rApiInner is completely inside the passed range rApiOuter. */
      76             :     static inline bool  Contains(
      77             :                             const ::com::sun::star::table::CellRangeAddress& rApiOuter,
      78             :                             const ::com::sun::star::table::CellRangeAddress& rApiInner );
      79             : };
      80             : 
      81             : 
      82         810 : inline void ScUnoConversion::FillScAddress(
      83             :         ScAddress& rScAddress,
      84             :         const ::com::sun::star::table::CellAddress& rApiAddress )
      85             : {
      86         810 :     rScAddress.Set( (SCCOL)rApiAddress.Column, (SCROW)rApiAddress.Row, (SCTAB)rApiAddress.Sheet );
      87         810 : }
      88             : 
      89           8 : inline void ScUnoConversion::FillApiAddress(
      90             :         ::com::sun::star::table::CellAddress& rApiAddress,
      91             :         const ScAddress& rScAddress )
      92             : {
      93           8 :     rApiAddress.Column = rScAddress.Col();
      94           8 :     rApiAddress.Row = rScAddress.Row();
      95           8 :     rApiAddress.Sheet = rScAddress.Tab();
      96           8 : }
      97             : 
      98         120 : inline void ScUnoConversion::FillScRange(
      99             :         ScRange& rScRange,
     100             :         const ::com::sun::star::table::CellRangeAddress& rApiRange )
     101             : {
     102         120 :     rScRange.aStart.Set( (SCCOL)rApiRange.StartColumn, (SCROW)rApiRange.StartRow, (SCTAB)rApiRange.Sheet );
     103         120 :     rScRange.aEnd.Set( (SCCOL)rApiRange.EndColumn, (SCROW)rApiRange.EndRow, (SCTAB)rApiRange.Sheet );
     104         120 : }
     105             : 
     106         123 : inline void ScUnoConversion::FillApiRange(
     107             :         ::com::sun::star::table::CellRangeAddress& rApiRange,
     108             :         const ScRange& rScRange )
     109             : {
     110         123 :     rApiRange.StartColumn = rScRange.aStart.Col();
     111         123 :     rApiRange.StartRow = rScRange.aStart.Row();
     112         123 :     rApiRange.Sheet = rScRange.aStart.Tab();
     113         123 :     rApiRange.EndColumn = rScRange.aEnd.Col();
     114         123 :     rApiRange.EndRow = rScRange.aEnd.Row();
     115         123 : }
     116             : 
     117             : inline void ScUnoConversion::FillApiRange(
     118             :         ::com::sun::star::table::CellRangeAddress& rApiRange,
     119             :         const ::com::sun::star::table::CellAddress& rApiAddress )
     120             : {
     121             :     rApiRange.StartColumn = rApiRange.EndColumn = rApiAddress.Column;
     122             :     rApiRange.StartRow = rApiRange.EndRow = rApiAddress.Row;
     123             :     rApiRange.Sheet = rApiAddress.Sheet;
     124             : }
     125             : 
     126           0 : inline void ScUnoConversion::FillApiStartAddress(
     127             :         ::com::sun::star::table::CellAddress& rApiAddress,
     128             :         const ::com::sun::star::table::CellRangeAddress& rApiRange )
     129             : {
     130           0 :     rApiAddress.Column = rApiRange.StartColumn;
     131           0 :     rApiAddress.Row = rApiRange.StartRow;
     132           0 :     rApiAddress.Sheet = rApiRange.Sheet;
     133           0 : }
     134             : 
     135             : inline void ScUnoConversion::FillApiEndAddress(
     136             :         ::com::sun::star::table::CellAddress& rApiAddress,
     137             :         const ::com::sun::star::table::CellRangeAddress& rApiRange )
     138             : {
     139             :     rApiAddress.Column = rApiRange.EndColumn;
     140             :     rApiAddress.Row = rApiRange.EndRow;
     141             :     rApiAddress.Sheet = rApiRange.Sheet;
     142             : }
     143             : 
     144           0 : inline bool ScUnoConversion::Intersects(
     145             :         const ::com::sun::star::table::CellRangeAddress& rApiRange1,
     146             :         const ::com::sun::star::table::CellRangeAddress& rApiRange2 )
     147             : {
     148             :     return (rApiRange1.Sheet == rApiRange2.Sheet) &&
     149           0 :         (::std::max( rApiRange1.StartColumn, rApiRange2.StartColumn ) <= ::std::min( rApiRange1.EndColumn, rApiRange2.EndColumn )) &&
     150           0 :         (::std::max( rApiRange1.StartRow, rApiRange2.StartRow ) <= ::std::min( rApiRange1.EndRow, rApiRange2.EndRow ));
     151             : }
     152             : 
     153             : inline bool ScUnoConversion::Contains(
     154             :         const ::com::sun::star::table::CellRangeAddress& rApiOuter,
     155             :         const ::com::sun::star::table::CellAddress& rApiInner )
     156             : {
     157             :     return (rApiOuter.Sheet == rApiInner.Sheet) &&
     158             :         (rApiOuter.StartColumn <= rApiInner.Column) && (rApiInner.Column <= rApiOuter.EndColumn) &&
     159             :         (rApiOuter.StartRow <= rApiInner.Row) && (rApiInner.Row <= rApiOuter.EndRow);
     160             : }
     161             : 
     162           0 : inline bool ScUnoConversion::Contains(
     163             :         const ::com::sun::star::table::CellRangeAddress& rApiOuter,
     164             :         const ::com::sun::star::table::CellRangeAddress& rApiInner )
     165             : {
     166             :     return (rApiOuter.Sheet == rApiInner.Sheet) &&
     167             :         (rApiOuter.StartColumn <= rApiInner.StartColumn) && (rApiInner.EndColumn <= rApiOuter.EndColumn) &&
     168           0 :         (rApiOuter.StartRow <= rApiInner.StartRow) && (rApiInner.EndRow <= rApiOuter.EndRow);
     169             : }
     170             : 
     171             : //___________________________________________________________________
     172             : 
     173           0 : inline sal_Bool operator==(
     174             :         const ::com::sun::star::table::CellAddress& rApiAddress1,
     175             :         const ::com::sun::star::table::CellAddress& rApiAddress2 )
     176             : {
     177             :     return
     178             :         (rApiAddress1.Column == rApiAddress2.Column) &&
     179             :         (rApiAddress1.Row == rApiAddress2.Row) &&
     180           0 :         (rApiAddress1.Sheet == rApiAddress2.Sheet);
     181             : }
     182             : 
     183             : inline sal_Bool operator!=(
     184             :         const ::com::sun::star::table::CellAddress& rApiAddress1,
     185             :         const ::com::sun::star::table::CellAddress& rApiAddress2 )
     186             : {
     187             :     return !(rApiAddress1 == rApiAddress2);
     188             : }
     189             : 
     190           0 : inline sal_Bool operator==(
     191             :         const ::com::sun::star::table::CellRangeAddress& rApiRange1,
     192             :         const ::com::sun::star::table::CellRangeAddress& rApiRange2 )
     193             : {
     194             :     return
     195             :         (rApiRange1.StartColumn == rApiRange2.StartColumn) &&
     196             :         (rApiRange1.StartRow == rApiRange2.StartRow) &&
     197             :         (rApiRange1.EndColumn == rApiRange2.EndColumn) &&
     198             :         (rApiRange1.EndRow == rApiRange2.EndRow) &&
     199           0 :         (rApiRange1.Sheet == rApiRange2.Sheet);
     200             : }
     201             : 
     202           0 : inline sal_Bool operator!=(
     203             :         const ::com::sun::star::table::CellRangeAddress& rApiRange1,
     204             :         const ::com::sun::star::table::CellRangeAddress& rApiRange2 )
     205             : {
     206           0 :     return !(rApiRange1 == rApiRange2);
     207             : }
     208             : 
     209             : #endif
     210             : 
     211             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10