LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/view - sdruler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 56 0.0 %
Date: 2012-12-27 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             : |*
      39             : |* Controller-Item fuer Ruler
      40             : |*
      41             : \************************************************************************/
      42             : 
      43           0 : class RulerCtrlItem : public SfxControllerItem
      44             : {
      45             :     Ruler &rRuler;
      46             : 
      47             :  protected:
      48             :     virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
      49             :                                 const SfxPoolItem* pItem );
      50             : 
      51             :  public:
      52             :     RulerCtrlItem(sal_uInt16 nId, Ruler& rRlr, SfxBindings& rBind);
      53             : };
      54             : 
      55           0 : RulerCtrlItem::RulerCtrlItem(sal_uInt16 _nId, Ruler& rRlr, SfxBindings& rBind)
      56             : : SfxControllerItem(_nId, rBind)
      57           0 : , rRuler(rRlr)
      58             : {
      59           0 : }
      60             : 
      61           0 : void RulerCtrlItem::StateChanged( sal_uInt16 nSId, SfxItemState, const SfxPoolItem* pState )
      62             : {
      63           0 :     switch( nSId )
      64             :     {
      65             :         case SID_RULER_NULL_OFFSET:
      66             :         {
      67           0 :             const SfxPointItem* pItem = dynamic_cast< const SfxPointItem* >(pState);
      68             :             DBG_ASSERT(pState ? pItem != NULL : sal_True, "SfxPointItem erwartet");
      69           0 :             if ( pItem )
      70           0 :                 rRuler.SetNullOffset(pItem->GetValue());
      71             :         }
      72           0 :         break;
      73             :     }
      74           0 : }
      75             : 
      76             : 
      77             : /*************************************************************************
      78             : |*
      79             : |* Konstruktor
      80             : |*
      81             : \************************************************************************/
      82             : 
      83           0 : Ruler::Ruler( DrawViewShell& rViewSh, ::Window* pParent, ::sd::Window* pWin, sal_uInt16 nRulerFlags,  SfxBindings& rBindings, WinBits nWinStyle)
      84             : : SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle)
      85             : , pSdWin(pWin)
      86           0 : , pDrViewShell(&rViewSh)
      87             : {
      88           0 :     rBindings.EnterRegistrations();
      89           0 :     pCtrlItem = new RulerCtrlItem(SID_RULER_NULL_OFFSET, *this, rBindings);
      90           0 :     rBindings.LeaveRegistrations();
      91             : 
      92           0 :     if ( nWinStyle & WB_HSCROLL )
      93             :     {
      94           0 :         bHorz = sal_True;
      95           0 :         SetHelpId( HID_SD_RULER_HORIZONTAL );
      96             :     }
      97             :     else
      98             :     {
      99           0 :         bHorz = sal_False;
     100           0 :         SetHelpId( HID_SD_RULER_VERTICAL );
     101             :     }
     102           0 : }
     103             : 
     104             : /*************************************************************************
     105             : |*
     106             : |* Destruktor
     107             : |*
     108             : \************************************************************************/
     109             : 
     110           0 : Ruler::~Ruler()
     111             : {
     112           0 :     SfxBindings& rBindings = pCtrlItem->GetBindings();
     113           0 :     rBindings.EnterRegistrations();
     114           0 :     delete pCtrlItem;
     115           0 :     rBindings.LeaveRegistrations();
     116           0 : }
     117             : 
     118             : /*************************************************************************
     119             : |*
     120             : |* MouseButtonDown-Handler
     121             : |*
     122             : \************************************************************************/
     123             : 
     124           0 : void Ruler::MouseButtonDown(const MouseEvent& rMEvt)
     125             : {
     126           0 :     Point aMPos = rMEvt.GetPosPixel();
     127           0 :     RulerType eType = GetType(aMPos);
     128             : 
     129           0 :     if ( !pDrViewShell->GetView()->IsTextEdit() &&
     130           0 :         rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
     131             :         (eType == RULER_TYPE_DONTKNOW || eType == RULER_TYPE_OUTSIDE) )
     132             :     {
     133           0 :         pDrViewShell->StartRulerDrag(*this, rMEvt);
     134             :     }
     135             :     else
     136           0 :         SvxRuler::MouseButtonDown(rMEvt);
     137           0 : }
     138             : 
     139             : /*************************************************************************
     140             : |*
     141             : |* MouseMove-Handler
     142             : |*
     143             : \************************************************************************/
     144             : 
     145           0 : void Ruler::MouseMove(const MouseEvent& rMEvt)
     146             : {
     147           0 :     SvxRuler::MouseMove(rMEvt);
     148           0 : }
     149             : 
     150             : /*************************************************************************
     151             : |*
     152             : |* MouseButtonUp-Handler
     153             : |*
     154             : \************************************************************************/
     155             : 
     156           0 : void Ruler::MouseButtonUp(const MouseEvent& rMEvt)
     157             : {
     158           0 :     SvxRuler::MouseButtonUp(rMEvt);
     159           0 : }
     160             : 
     161             : /*************************************************************************
     162             : |*
     163             : |* NullOffset setzen
     164             : |*
     165             : \************************************************************************/
     166             : 
     167           0 : void Ruler::SetNullOffset(const Point& rOffset)
     168             : {
     169             :     long nOffset;
     170             : 
     171           0 :     if ( bHorz )    nOffset = rOffset.X();
     172           0 :     else            nOffset = rOffset.Y();
     173             : 
     174           0 :     SetNullOffsetLogic(nOffset);
     175           0 : }
     176             : 
     177             : /*************************************************************************
     178             : |*
     179             : |* Command event
     180             : |*
     181             : \************************************************************************/
     182             : 
     183           0 : void Ruler::Command(const CommandEvent& rCEvt)
     184             : {
     185           0 :     if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
     186           0 :         !pDrViewShell->GetView()->IsTextEdit() )
     187             :     {
     188           0 :         SvxRuler::Command( rCEvt );
     189             :     }
     190           0 : }
     191             : 
     192             : /*************************************************************************
     193             : |*
     194             : |* ExtraDown
     195             : |*
     196             : \************************************************************************/
     197             : 
     198           0 : void Ruler::ExtraDown()
     199             : {
     200           0 :     if( !pDrViewShell->GetView()->IsTextEdit() )
     201           0 :         SvxRuler::ExtraDown();
     202           0 : }
     203             : 
     204             : } // end of namespace sd
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10