LCOV - code coverage report
Current view: top level - sw/source/core/inc - docsort.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 6 6 100.0 %
Date: 2012-08-25 Functions: 7 7 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #ifndef _SORT_HXX
      30                 :            : #define _SORT_HXX
      31                 :            : 
      32                 :            : #include <ndindex.hxx>
      33                 :            : #include <vector>
      34                 :            : 
      35                 :            : class SwDoc;
      36                 :            : class SwTableBox;
      37                 :            : class SwUndoSort;
      38                 :            : class FlatFndBox;
      39                 :            : struct SwSortOptions;
      40                 :            : struct SwSortElement;
      41                 :            : class _FndBox;
      42                 :            : class _FndLine;
      43                 :            : class CollatorWrapper;
      44                 :            : class LocaleDataWrapper;
      45                 :            : 
      46                 :            : namespace com {
      47                 :            :     namespace sun {
      48                 :            :         namespace star {
      49                 :            :             namespace lang {
      50                 :            :                 struct Locale;
      51                 :            :             }
      52                 :            :         }
      53                 :            :     }
      54                 :            : }
      55                 :            : 
      56                 :         16 : class SwMovedBoxes : public std::vector<const SwTableBox*>
      57                 :            : {
      58                 :            : public:
      59                 :            :     sal_uInt16 GetPos(const SwTableBox* pTableBox) const;
      60                 :            : };
      61                 :            : 
      62                 :            : // Functions for moving boxes
      63                 :            : void MoveCol(SwDoc* pDoc, const FlatFndBox& rBox,
      64                 :            :              sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
      65                 :            : void MoveRow(SwDoc* pDoc, const FlatFndBox& rBox,
      66                 :            :              sal_uInt16 nS, sal_uInt16 nT, SwMovedBoxes& rMovedList, SwUndoSort* pUD=0);
      67                 :            : void MoveCell(SwDoc* pDoc, const SwTableBox* pSource,
      68                 :            :               const SwTableBox* pTar, sal_Bool bMovedBefore, SwUndoSort* pUD=0);
      69                 :            : 
      70                 :            : // Elements for sorting text and table content
      71                 :        104 : struct SwSortElement
      72                 :            : {
      73                 :            :     static SwSortOptions*       pOptions;
      74                 :            :     static SwDoc*               pDoc;
      75                 :            :     static const FlatFndBox*    pBox;
      76                 :            :     static CollatorWrapper*     pSortCollator;
      77                 :            :     static ::com::sun::star::lang::Locale* pLocale;
      78                 :            :     static String*              pLastAlgorithm;
      79                 :            :     static LocaleDataWrapper*   pLclData;
      80                 :            : 
      81                 :            :     static void Init( SwDoc*, const SwSortOptions& rOpt, FlatFndBox* = 0 );
      82                 :            :     static void Finit();
      83                 :            : 
      84                 :            :     virtual ~SwSortElement();
      85                 :            : 
      86                 :            :     virtual String GetKey(sal_uInt16 nKey ) const = 0;
      87                 :            :     virtual double GetValue(sal_uInt16 nKey ) const;
      88                 :            : 
      89                 :            :     sal_Bool operator==(const SwSortElement& ) const;
      90                 :            :     sal_Bool operator<(const SwSortElement& ) const;
      91                 :            : 
      92                 :            :     double StrToDouble(const String& rStr) const;
      93                 :            : private:
      94                 :            :     int keycompare(const SwSortElement& rCmp, sal_uInt16 nKey) const;
      95                 :            : };
      96                 :            : 
      97                 :            : // sort text
      98                 :            : struct SwSortTxtElement : public SwSortElement
      99                 :            : {
     100                 :            :     sal_uLong   nOrg;
     101                 :            :     SwNodeIndex aPos;
     102                 :            : 
     103                 :            :     SwSortTxtElement( const SwNodeIndex& rPos );
     104                 :            :     virtual ~SwSortTxtElement();
     105                 :            : 
     106                 :            :     virtual String GetKey( sal_uInt16 nKey ) const;
     107                 :            : };
     108                 :            : 
     109                 :            : // sort table
     110                 :            : struct SwSortBoxElement : public SwSortElement
     111                 :            : {
     112                 :            :     sal_uInt16 nRow;
     113                 :            : 
     114                 :            :     SwSortBoxElement( sal_uInt16 nRC );
     115                 :            :     virtual ~SwSortBoxElement();
     116                 :            : 
     117                 :            :     virtual String GetKey( sal_uInt16 nKey ) const;
     118                 :            :     virtual double GetValue( sal_uInt16 nKey ) const;
     119                 :            : };
     120                 :            : 
     121                 :            : // two-dimensional array of FndBoxes
     122                 :            : class FlatFndBox
     123                 :            : {
     124                 :            : public:
     125                 :            :     FlatFndBox(SwDoc* pDocPtr, const _FndBox& rBox);
     126                 :            :     ~FlatFndBox();
     127                 :            : 
     128                 :          8 :     sal_Bool            IsSymmetric() const { return bSym;  }
     129                 :          8 :     sal_uInt16          GetRows()     const { return nRows; }
     130                 :        144 :     sal_uInt16          GetCols()     const { return nCols; }
     131                 :            : 
     132                 :            :     const _FndBox*      GetBox(sal_uInt16 nCol, sal_uInt16 nRow) const;
     133                 :            : 
     134                 :            :     inline sal_Bool     HasItemSets() const;
     135                 :            :     const SfxItemSet*   GetItemSet(sal_uInt16 nCol, sal_uInt16 nRow) const;
     136                 :            : 
     137                 :            : private:
     138                 :            :     sal_Bool            CheckLineSymmetry(const _FndBox& rBox);
     139                 :            :     sal_Bool            CheckBoxSymmetry(const _FndLine& rLn);
     140                 :            :     sal_uInt16          GetColCount(const _FndBox& rBox);
     141                 :            :     sal_uInt16          GetRowCount(const _FndBox& rBox);
     142                 :            :     void                FillFlat(const _FndBox&, sal_Bool bLastBox=sal_False);
     143                 :            : 
     144                 :            :     SwDoc*              pDoc;
     145                 :            :     const _FndBox&      rBoxRef;
     146                 :            :     const _FndBox**     pArr;
     147                 :            :     SfxItemSet**        ppItemSets;
     148                 :            : 
     149                 :            :     sal_uInt16          nRows;
     150                 :            :     sal_uInt16          nCols;
     151                 :            :     sal_uInt16          nRow;
     152                 :            :     sal_uInt16          nCol;
     153                 :            : 
     154                 :            :     sal_Bool            bSym;
     155                 :            : };
     156                 :            : 
     157                 :          8 : inline sal_Bool FlatFndBox::HasItemSets() const { return 0 != ppItemSets; }
     158                 :            : 
     159                 :            : #endif
     160                 :            : 
     161                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10