fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sd / source / ui / view / sdruler.cxx
blob66bed37aa4ec4e171e6ac3961949f2c25244aa7c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 #include "View.hxx"
30 #include "DrawViewShell.hxx"
31 #include "Window.hxx"
33 #include "helpids.h"
35 namespace sd {
37 /**
38 * Controller-Item for ruler
40 class RulerCtrlItem : public SfxControllerItem
42 Ruler &rRuler;
44 protected:
45 virtual void StateChanged( sal_uInt16 nSId, SfxItemState eState,
46 const SfxPoolItem* pItem );
48 public:
49 RulerCtrlItem(sal_uInt16 nId, Ruler& rRlr, SfxBindings& rBind);
52 RulerCtrlItem::RulerCtrlItem(sal_uInt16 _nId, Ruler& rRlr, SfxBindings& rBind)
53 : SfxControllerItem(_nId, rBind)
54 , rRuler(rRlr)
58 void RulerCtrlItem::StateChanged( sal_uInt16 nSId, SfxItemState, const SfxPoolItem* pState )
60 switch( nSId )
62 case SID_RULER_NULL_OFFSET:
64 const SfxPointItem* pItem = dynamic_cast< const SfxPointItem* >(pState);
65 DBG_ASSERT(pState ? pItem != NULL : sal_True, "SfxPointItem expected");
66 if ( pItem )
67 rRuler.SetNullOffset(pItem->GetValue());
69 break;
75 Ruler::Ruler( DrawViewShell& rViewSh, ::Window* pParent, ::sd::Window* pWin, sal_uInt16 nRulerFlags, SfxBindings& rBindings, WinBits nWinStyle)
76 : SvxRuler(pParent, pWin, nRulerFlags, rBindings, nWinStyle)
77 , pSdWin(pWin)
78 , pDrViewShell(&rViewSh)
80 rBindings.EnterRegistrations();
81 pCtrlItem = new RulerCtrlItem(SID_RULER_NULL_OFFSET, *this, rBindings);
82 rBindings.LeaveRegistrations();
84 if ( nWinStyle & WB_HSCROLL )
86 bHorz = sal_True;
87 SetHelpId( HID_SD_RULER_HORIZONTAL );
89 else
91 bHorz = sal_False;
92 SetHelpId( HID_SD_RULER_VERTICAL );
97 Ruler::~Ruler()
99 SfxBindings& rBindings = pCtrlItem->GetBindings();
100 rBindings.EnterRegistrations();
101 delete pCtrlItem;
102 rBindings.LeaveRegistrations();
106 void Ruler::MouseButtonDown(const MouseEvent& rMEvt)
108 Point aMPos = rMEvt.GetPosPixel();
109 RulerType eType = GetType(aMPos);
111 if ( !pDrViewShell->GetView()->IsTextEdit() &&
112 rMEvt.IsLeft() && rMEvt.GetClicks() == 1 &&
113 (eType == RULER_TYPE_DONTKNOW || eType == RULER_TYPE_OUTSIDE) )
115 pDrViewShell->StartRulerDrag(*this, rMEvt);
117 else
118 SvxRuler::MouseButtonDown(rMEvt);
122 void Ruler::MouseMove(const MouseEvent& rMEvt)
124 SvxRuler::MouseMove(rMEvt);
128 void Ruler::MouseButtonUp(const MouseEvent& rMEvt)
130 SvxRuler::MouseButtonUp(rMEvt);
134 void Ruler::SetNullOffset(const Point& rOffset)
136 long nOffset;
138 if ( bHorz ) nOffset = rOffset.X();
139 else nOffset = rOffset.Y();
141 SetNullOffsetLogic(nOffset);
145 void Ruler::Command(const CommandEvent& rCEvt)
147 if( rCEvt.GetCommand() == COMMAND_CONTEXTMENU &&
148 !pDrViewShell->GetView()->IsTextEdit() )
150 SvxRuler::Command( rCEvt );
155 void Ruler::ExtraDown()
157 if( !pDrViewShell->GetView()->IsTextEdit() )
158 SvxRuler::ExtraDown();
161 } // end of namespace sd
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */