LCOV - code coverage report
Current view: top level - sc/source/ui/inc - csvruler.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 8 0.0 %
Date: 2012-08-25 Functions: 0 6 0.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                 :            :  * 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                 :            : // ============================================================================
      21                 :            : 
      22                 :            : #ifndef _SC_CSVRULER_HXX
      23                 :            : #define _SC_CSVRULER_HXX
      24                 :            : 
      25                 :            : #include <vcl/virdev.hxx>
      26                 :            : #include "csvcontrol.hxx"
      27                 :            : #include "csvsplits.hxx"
      28                 :            : #include "scdllapi.h"
      29                 :            : 
      30                 :            : class ScAccessibleCsvControl;
      31                 :            : 
      32                 :            : 
      33                 :            : // ============================================================================
      34                 :            : 
      35                 :            : /** A ruler control for the CSV import dialog. Supports setting and moving
      36                 :            :     splits (which divide lines of data into several columns). */
      37                 :            : class SC_DLLPUBLIC ScCsvRuler : public ScCsvControl
      38                 :            : {
      39                 :            : private:
      40                 :            :     VirtualDevice               maBackgrDev;        /// Ruler background, scaling.
      41                 :            :     VirtualDevice               maRulerDev;         /// Ruler with splits and cursor.
      42                 :            : 
      43                 :            :     Color                       maBackColor;        /// Background color.
      44                 :            :     Color                       maActiveColor;      /// Color for active part of ruler.
      45                 :            :     Color                       maTextColor;        /// Text and scale color.
      46                 :            :     Color                       maSplitColor;       /// Split area color.
      47                 :            : 
      48                 :            :     ScCsvSplits                 maSplits;           /// Vector with split positions.
      49                 :            :     ScCsvSplits                 maOldSplits;        /// Old state for cancellation.
      50                 :            : 
      51                 :            :     sal_Int32                   mnPosCursorLast;    /// Last valid position of cursor.
      52                 :            :     sal_Int32                   mnPosMTStart;       /// Start position of mouse tracking.
      53                 :            :     sal_Int32                   mnPosMTCurr;        /// Current position of mouse tracking.
      54                 :            :     bool                        mbPosMTMoved;       /// Tracking: Anytime moved to another position?
      55                 :            : 
      56                 :            :     Size                        maWinSize;          /// Size of the control.
      57                 :            :     Rectangle                   maActiveRect;       /// The active area of the ruler.
      58                 :            :     sal_Int32                   mnSplitSize;        /// Size of a split circle.
      59                 :            : 
      60                 :            :     // ------------------------------------------------------------------------
      61                 :            : public:
      62                 :            :     explicit                    ScCsvRuler( ScCsvControl& rParent );
      63                 :            :                                 ~ScCsvRuler();
      64                 :            : 
      65                 :            :     // common ruler handling --------------------------------------------------
      66                 :            : public:
      67                 :            :     using Window::SetPosSizePixel;
      68                 :            :     /** Sets position and size of the ruler. The height is calculated internally. */
      69                 :            :     virtual void                SetPosSizePixel(
      70                 :            :                                     long nX, long nY,
      71                 :            :                                     long nWidth, long nHeight,
      72                 :            :                                     sal_uInt16 nFlags = WINDOW_POSSIZE_ALL );
      73                 :            : 
      74                 :            :     /** Apply current layout data to the ruler. */
      75                 :            :     void                        ApplyLayout( const ScCsvLayoutData& rOldData );
      76                 :            : 
      77                 :            : private:
      78                 :            :     /** Reads colors from system settings. */
      79                 :            :     SC_DLLPRIVATE void                        InitColors();
      80                 :            :     /** Initializes all data dependent from the control's size. */
      81                 :            :     SC_DLLPRIVATE void                        InitSizeData();
      82                 :            : 
      83                 :            :     /** Moves cursor to a new position.
      84                 :            :         @param bScroll  sal_True = The method may scroll the ruler. */
      85                 :            :     SC_DLLPRIVATE void                        MoveCursor( sal_Int32 nPos, bool bScroll = true );
      86                 :            :     /** Moves cursor to the given direction. */
      87                 :            :     SC_DLLPRIVATE void                        MoveCursorRel( ScMoveMode eDir );
      88                 :            :     /** Sets cursor to an existing split, according to eDir. */
      89                 :            :     SC_DLLPRIVATE void                        MoveCursorToSplit( ScMoveMode eDir );
      90                 :            :     /** Scrolls data grid vertically. */
      91                 :            :     SC_DLLPRIVATE void                        ScrollVertRel( ScMoveMode eDir );
      92                 :            : 
      93                 :            :     // split handling ---------------------------------------------------------
      94                 :            : public:
      95                 :            :     /** Returns the split array. */
      96                 :          0 :     inline const ScCsvSplits&   GetSplits() const { return maSplits; }
      97                 :            :     /** Returns the number of splits. */
      98                 :          0 :     inline sal_uInt32           GetSplitCount() const
      99                 :          0 :                                     { return maSplits.Count(); }
     100                 :            :     /** Returns the position of the specified split. */
     101                 :          0 :     inline sal_Int32            GetSplitPos( sal_uInt32 nIndex ) const
     102                 :          0 :                                     { return maSplits[ nIndex ]; }
     103                 :            :     /** Finds a position nearest to nPos which does not cause scrolling the visible area. */
     104                 :            :     sal_Int32                   GetNoScrollPos( sal_Int32 nPos ) const;
     105                 :            : 
     106                 :            :     /** Returns true if at position nPos is a split. */
     107                 :          0 :     inline bool                 HasSplit( sal_Int32 nPos ) const { return maSplits.HasSplit( nPos ); }
     108                 :            :     /** Inserts a split. */
     109                 :            :     void                        InsertSplit( sal_Int32 nPos );
     110                 :            :     /** Removes a split. */
     111                 :            :     void                        RemoveSplit( sal_Int32 nPos );
     112                 :            :     /** Moves a split from nPos to nNewPos. */
     113                 :            :     void                        MoveSplit( sal_Int32 nPos, sal_Int32 nNewPos );
     114                 :            :     /** Removes all splits of the ruler. */
     115                 :            :     void                        RemoveAllSplits();
     116                 :            : 
     117                 :            : private:
     118                 :            :     /** Finds next position without a split. */
     119                 :            :     SC_DLLPRIVATE sal_Int32                   FindEmptyPos( sal_Int32 nPos, ScMoveMode eDir ) const;
     120                 :            : 
     121                 :            :     /** Moves split and cursor to nNewPos and commits event. */
     122                 :            :     SC_DLLPRIVATE void                        MoveCurrSplit( sal_Int32 nNewPos );
     123                 :            :     /** Moves split and cursor to the given direction and commits event. */
     124                 :            :     SC_DLLPRIVATE void                        MoveCurrSplitRel( ScMoveMode eDir );
     125                 :            : 
     126                 :            :     // event handling ---------------------------------------------------------
     127                 :            : protected:
     128                 :            :     virtual void                Resize();
     129                 :            :     virtual void                GetFocus();
     130                 :            :     virtual void                LoseFocus();
     131                 :            :     virtual void                DataChanged( const DataChangedEvent& rDCEvt );
     132                 :            : 
     133                 :            :     virtual void                MouseButtonDown( const MouseEvent& rMEvt );
     134                 :            :     virtual void                MouseMove( const MouseEvent& rMEvt );
     135                 :            :     virtual void                Tracking( const TrackingEvent& rTEvt );
     136                 :            : 
     137                 :            :     virtual void                KeyInput( const KeyEvent& rKEvt );
     138                 :            : 
     139                 :            : private:
     140                 :            :     /** Starts tracking at the specified position. */
     141                 :            :     SC_DLLPRIVATE void                        StartMouseTracking( sal_Int32 nPos );
     142                 :            :     /** Moves tracking to a new position. */
     143                 :            :     SC_DLLPRIVATE void                        MoveMouseTracking( sal_Int32 nPos );
     144                 :            :     /** Applies tracking action for the current tracking position.
     145                 :            :         @param bApply  sal_True = apply action, sal_False = cancel action. */
     146                 :            :     SC_DLLPRIVATE void                        EndMouseTracking( bool bApply );
     147                 :            : 
     148                 :            :     // painting ---------------------------------------------------------------
     149                 :            : protected:
     150                 :            :     virtual void                Paint( const Rectangle& );
     151                 :            : 
     152                 :            : public:
     153                 :            :     /** Redraws the entire ruler. */
     154                 :            :     void                        ImplRedraw();
     155                 :            : 
     156                 :            : private:
     157                 :            :     /** Returns the width of the control. */
     158                 :          0 :     inline sal_Int32            GetWidth() const { return maWinSize.Width(); }
     159                 :            :     /** Returns the height of the control. */
     160                 :          0 :     inline sal_Int32            GetHeight() const { return maWinSize.Height(); }
     161                 :            : 
     162                 :            :     /** Draws the background and active area to maBackgrDev (only the given X range). */
     163                 :            :     SC_DLLPRIVATE void                        ImplDrawArea( sal_Int32 nPosX, sal_Int32 nWidth );
     164                 :            :     /** Draws the entire ruler background with scaling to maBackgrDev. */
     165                 :            :     SC_DLLPRIVATE void                        ImplDrawBackgrDev();
     166                 :            : 
     167                 :            :     /** Draws a split to maRulerDev. */
     168                 :            :     SC_DLLPRIVATE void                        ImplDrawSplit( sal_Int32 nPos );
     169                 :            :     /** Erases a split from maRulerDev. */
     170                 :            :     SC_DLLPRIVATE void                        ImplEraseSplit( sal_Int32 nPos );
     171                 :            :     /** Draws the ruler background, all splits and the cursor to maRulerDev. */
     172                 :            :     SC_DLLPRIVATE void                        ImplDrawRulerDev();
     173                 :            : 
     174                 :            :     /** Inverts the cursor bar at the specified position in maRulerDev. */
     175                 :            :     SC_DLLPRIVATE void                        ImplInvertCursor( sal_Int32 nPos );
     176                 :            :     /** Draws directly tracking rectangle to the column with the specified index. */
     177                 :            :     SC_DLLPRIVATE void                        ImplDrawTrackingRect();
     178                 :            : 
     179                 :            :     /** Sets arrow or horizontal split pointer. */
     180                 :            :     SC_DLLPRIVATE void                        ImplSetMousePointer( sal_Int32 nPos );
     181                 :            : 
     182                 :            :     // accessibility ----------------------------------------------------------
     183                 :            : protected:
     184                 :            :     /** Creates a new accessible object. */
     185                 :            :     virtual ScAccessibleCsvControl* ImplCreateAccessible();
     186                 :            : };
     187                 :            : 
     188                 :            : 
     189                 :            : // ============================================================================
     190                 :            : 
     191                 :            : #endif
     192                 :            : 
     193                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10