LCOV - code coverage report
Current view: top level - sd/source/ui/view - sdruler.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 57 0.0 %
Date: 2014-04-14 Functions: 0 13 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             : 
      21             : #include "Ruler.hxx"
      22             : #include <svl/ptitem.hxx>
      23             : #include <svx/ruler.hxx>
      24             : #include <svx/svxids.hrc>
      25             : #include <sfx2/ctrlitem.hxx>
      26             : #include <sfx2/bindings.hxx>
      27             : 
      28             : 
      29             : #include "View.hxx"
      30             : #include "DrawViewShell.hxx"
      31             : #include "Window.hxx"
      32             : 
      33             : #include "helpids.h"
      34             : 
      35             : namespace sd {
      36             : 
      37             : /**
      38             :  * Controller-Item for ruler
      39             :  */
      40           0 : class RulerCtrlItem : public SfxControllerItem
      41             : {
      42             :     Ruler &rRuler;
      43             : 
      44             :  protected:
      45             :     virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
      46             :                                 const SfxPoolItem* pItem ) SAL_OVERRIDE;
      47             : 
      48             :  public:
      49             :     RulerCtrlItem(sal_uInt16 nId, Ruler& rRlr, SfxBindings& rBind);
      50             : };
      51             : 
      52           0 : RulerCtrlItem::RulerCtrlItem(sal_uInt16 _nId, Ruler& rRlr, SfxBindings& rBind)
      53             : : SfxControllerItem(_nId, rBind)
      54           0 : , rRuler(rRlr)
      55             : {
      56           0 : }
      57             : 
      58           0 : void RulerCtrlItem::StateChanged( sal_uInt16 nSId, SfxItemState, const SfxPoolItem* pState )
      59             : {
      60           0 :     switch( nSId )
      61             :     {
      62             :         case SID_RULER_NULL_OFFSET:
      63             :         {
      64           0 :             const SfxPointItem* pItem = dynamic_cast< const SfxPointItem* >(pState);
      65             :             DBG_ASSERT(pState ? pItem != NULL : sal_True, "SfxPointItem expected");
      66           0 :             if ( pItem )
      67           0 :                 rRuler.SetNullOffset(pItem->GetValue());
      68             :         }
      69           0 :         break;
      70             :     }
      71           0 : }
      72             : 
      73             : 
      74             : 
      75           0 : Ruler::Ruler( DrawViewShell& rViewSh, ::Window* pParent, ::sd::Window* pWin, sal_uInt16 nRulerFlags,  SfxBindings& rBindings, WinBits nWinStyle)
      76             :     : SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle)
      77             :     , pSdView(NULL)
      78             :     , pSdWin(pWin)
      79           0 :     , pDrViewShell(&rViewSh)
      80             : {
      81           0 :     rBindings.EnterRegistrations();
      82           0 :     pCtrlItem = new RulerCtrlItem(SID_RULER_NULL_OFFSET, *this, rBindings);
      83           0 :     rBindings.LeaveRegistrations();
      84             : 
      85           0 :     if ( nWinStyle & WB_HSCROLL )
      86             :     {
      87           0 :         bHorz = sal_True;
      88           0 :         SetHelpId( HID_SD_RULER_HORIZONTAL );
      89             :     }
      90             :     else
      91             :     {
      92           0 :         bHorz = sal_False;
      93           0 :         SetHelpId( HID_SD_RULER_VERTICAL );
      94             :     }
      95           0 : }
      96             : 
      97             : 
      98           0 : Ruler::~Ruler()
      99             : {
     100           0 :     SfxBindings& rBindings = pCtrlItem->GetBindings();
     101           0 :     rBindings.EnterRegistrations();
     102           0 :     delete pCtrlItem;
     103           0 :     rBindings.LeaveRegistrations();
     104           0 : }
     105             : 
     106             : 
     107           0 : void Ruler::MouseButtonDown(const MouseEvent& rMEvt)
     108             : {
     109           0 :     Point aMPos = rMEvt.GetPosPixel();
     110           0 :     RulerType eType = GetType(aMPos);
     111             : 
     112           0 :     if ( !pDrViewShell->GetView()->IsTextEdit() &&
     113           0 :         rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
     114           0 :         (eType == RULER_TYPE_DONTKNOW || eType == RULER_TYPE_OUTSIDE) )
     115             :     {
     116           0 :         pDrViewShell->StartRulerDrag(*this, rMEvt);
     117             :     }
     118             :     else
     119           0 :         SvxRuler::MouseButtonDown(rMEvt);
     120           0 : }
     121             : 
     122             : 
     123           0 : void Ruler::MouseMove(const MouseEvent& rMEvt)
     124             : {
     125           0 :     SvxRuler::MouseMove(rMEvt);
     126           0 : }
     127             : 
     128             : 
     129           0 : void Ruler::MouseButtonUp(const MouseEvent& rMEvt)
     130             : {
     131           0 :     SvxRuler::MouseButtonUp(rMEvt);
     132           0 : }
     133             : 
     134             : 
     135           0 : void Ruler::SetNullOffset(const Point& rOffset)
     136             : {
     137             :     long nOffset;
     138             : 
     139           0 :     if ( bHorz )    nOffset = rOffset.X();
     140           0 :     else            nOffset = rOffset.Y();
     141             : 
     142           0 :     SetNullOffsetLogic(nOffset);
     143           0 : }
     144             : 
     145             : 
     146           0 : void Ruler::Command(const CommandEvent& rCEvt)
     147             : {
     148           0 :     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
     149           0 :         !pDrViewShell->GetView()->IsTextEdit() )
     150             :     {
     151           0 :         SvxRuler::Command( rCEvt );
     152             :     }
     153           0 : }
     154             : 
     155             : 
     156           0 : void Ruler::ExtraDown()
     157             : {
     158           0 :     if( !pDrViewShell->GetView()->IsTextEdit() )
     159           0 :         SvxRuler::ExtraDown();
     160           0 : }
     161             : 
     162             : } // end of namespace sd
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10