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

Generated by: LCOV version 1.10