Files
libreoffice/sd/source/ui/func/fuediglu.cxx

475 lines
14 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 16:07:07 +00:00
#include <fuediglu.hxx>
#include <svl/eitem.hxx>
2000-09-18 16:07:07 +00:00
#include <svx/dialogs.hrc>
#include <svx/svdglue.hxx>
#include <sfx2/request.hxx>
#include <app.hrc>
migrate to boost::gettext * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a
2017-06-11 20:56:30 +01:00
#include <Window.hxx>
#include <drawdoc.hxx>
#include <FrameView.hxx>
#include <View.hxx>
#include <ViewShell.hxx>
#include <ViewShellBase.hxx>
#include <ToolBarManager.hxx>
2000-09-18 16:07:07 +00:00
namespace sd {
2000-09-18 16:07:07 +00:00
FuEditGluePoints::FuEditGluePoints (
ViewShell* pViewSh,
::sd::Window* pWin,
::sd::View* pView,
SdDrawDocument* pDoc,
SfxRequest& rReq)
: FuDraw(pViewSh, pWin, pView, pDoc, rReq)
//Add Shift+UP/DOWN/LEFT/RIGHT key to move the position of insert point,
2014-04-10 10:46:50 +02:00
//and SHIFT+ENTER key to decide the position and draw the new insert point
,bBeginInsertPoint(false),
oldPoint(0,0)
2000-09-18 16:07:07 +00:00
{
}
rtl::Reference<FuPoor> FuEditGluePoints::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
{
FuEditGluePoints* pFunc;
rtl::Reference<FuPoor> xFunc( pFunc = new FuEditGluePoints( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
pFunc->SetPermanent( bPermanent );
return xFunc;
}
void FuEditGluePoints::DoExecute( SfxRequest& rReq )
{
FuDraw::DoExecute( rReq );
mpView->SetInsGluePointMode(false);
mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBar(
ToolBarManager::ToolBarGroup::Function,
ToolBarManager::msGluePointsToolBar);
2000-09-18 16:07:07 +00:00
}
FuEditGluePoints::~FuEditGluePoints()
{
mpView->BrkAction();
mpView->UnmarkAllGluePoints();
mpView->SetInsGluePointMode(false);
2000-09-18 16:07:07 +00:00
}
bool FuEditGluePoints::MouseButtonDown(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
mpView->SetActualWin( mpWindow );
2000-09-18 16:07:07 +00:00
bool bReturn = FuDraw::MouseButtonDown(rMEvt);
2000-09-18 16:07:07 +00:00
if (mpView->IsAction())
2000-09-18 16:07:07 +00:00
{
if (rMEvt.IsRight())
mpView->BckAction();
2000-09-18 16:07:07 +00:00
return true;
2000-09-18 16:07:07 +00:00
}
if (rMEvt.IsLeft())
{
bReturn = true;
sal_uInt16 nHitLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
mpWindow->CaptureMouse();
2000-09-18 16:07:07 +00:00
SdrViewEvent aVEvt;
SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
2000-09-18 16:07:07 +00:00
if (eHit == SdrHitKind::Handle)
2000-09-18 16:07:07 +00:00
{
// drag handle
2000-09-18 16:07:07 +00:00
SdrHdl* pHdl = aVEvt.pHdl;
if (mpView->IsGluePointMarked(aVEvt.pObj, aVEvt.nGlueId) && rMEvt.IsShift())
2000-09-18 16:07:07 +00:00
{
mpView->UnmarkGluePoint(aVEvt.pObj, aVEvt.nGlueId);
pHdl = nullptr;
2000-09-18 16:07:07 +00:00
}
if (pHdl)
{
// drag handle
mpView->BegDragObj(aMDPos, nullptr, aVEvt.pHdl, nDrgLog);
2000-09-18 16:07:07 +00:00
}
}
else if (eHit == SdrHitKind::MarkedObject && mpView->IsInsGluePointMode())
2000-09-18 16:07:07 +00:00
{
// insert glue points
mpView->BegInsGluePoint(aMDPos);
2000-09-18 16:07:07 +00:00
}
else if (eHit == SdrHitKind::MarkedObject && rMEvt.IsMod1())
2000-09-18 16:07:07 +00:00
{
// select glue points
2000-09-18 16:07:07 +00:00
if (!rMEvt.IsShift())
mpView->UnmarkAllGluePoints();
2000-09-18 16:07:07 +00:00
mpView->BegMarkGluePoints(aMDPos);
2000-09-18 16:07:07 +00:00
}
else if (eHit == SdrHitKind::MarkedObject && !rMEvt.IsShift() && !rMEvt.IsMod2())
2000-09-18 16:07:07 +00:00
{
// move object
mpView->BegDragObj(aMDPos, nullptr, nullptr, nDrgLog);
2000-09-18 16:07:07 +00:00
}
else if (eHit == SdrHitKind::Gluepoint)
2000-09-18 16:07:07 +00:00
{
// select glue points
2000-09-18 16:07:07 +00:00
if (!rMEvt.IsShift())
mpView->UnmarkAllGluePoints();
2000-09-18 16:07:07 +00:00
mpView->MarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, false);
SdrHdl* pHdl = mpView->GetGluePointHdl(aVEvt.pObj, aVEvt.nGlueId);
2000-09-18 16:07:07 +00:00
if (pHdl)
{
mpView->BegDragObj(aMDPos, nullptr, pHdl, nDrgLog);
2000-09-18 16:07:07 +00:00
}
}
else
{
// select or drag object
if (!rMEvt.IsShift() && !rMEvt.IsMod2() && eHit == SdrHitKind::UnmarkedObject)
2000-09-18 16:07:07 +00:00
{
mpView->UnmarkAllObj();
2000-09-18 16:07:07 +00:00
}
bool bMarked = false;
2000-09-18 16:07:07 +00:00
if (!rMEvt.IsMod1())
{
if (rMEvt.IsMod2())
{
bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift());
2000-09-18 16:07:07 +00:00
}
else
{
bMarked = mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift());
2000-09-18 16:07:07 +00:00
}
}
if (bMarked &&
(!rMEvt.IsShift() || eHit == SdrHitKind::MarkedObject))
2000-09-18 16:07:07 +00:00
{
// move object
mpView->BegDragObj(aMDPos, nullptr, aVEvt.pHdl, nDrgLog);
2000-09-18 16:07:07 +00:00
}
else if (mpView->AreObjectsMarked())
2000-09-18 16:07:07 +00:00
{
// select glue point
2000-09-18 16:07:07 +00:00
if (!rMEvt.IsShift())
mpView->UnmarkAllGluePoints();
2000-09-18 16:07:07 +00:00
mpView->BegMarkGluePoints(aMDPos);
2000-09-18 16:07:07 +00:00
}
else
{
// select object
mpView->BegMarkObj(aMDPos);
2000-09-18 16:07:07 +00:00
}
}
ForcePointer(&rMEvt);
}
return bReturn;
}
bool FuEditGluePoints::MouseMove(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
mpView->SetActualWin( mpWindow );
2000-09-18 16:07:07 +00:00
FuDraw::MouseMove(rMEvt);
if (mpView->IsAction())
2000-09-18 16:07:07 +00:00
{
Point aPix(rMEvt.GetPosPixel());
Point aPnt( mpWindow->PixelToLogic(aPix) );
2000-09-18 16:07:07 +00:00
ForceScroll(aPix);
mpView->MovAction(aPnt);
2000-09-18 16:07:07 +00:00
}
ForcePointer(&rMEvt);
return true;
2000-09-18 16:07:07 +00:00
}
bool FuEditGluePoints::MouseButtonUp(const MouseEvent& rMEvt)
2000-09-18 16:07:07 +00:00
{
mpView->SetActualWin( mpWindow );
2000-09-18 16:07:07 +00:00
bool bReturn = false;
2000-09-18 16:07:07 +00:00
if (mpView->IsAction())
2000-09-18 16:07:07 +00:00
{
bReturn = true;
mpView->EndAction();
2000-09-18 16:07:07 +00:00
}
FuDraw::MouseButtonUp(rMEvt);
sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );
2000-09-18 16:07:07 +00:00
if (std::abs(aMDPos.X() - aPos.X()) < nDrgLog &&
std::abs(aMDPos.Y() - aPos.Y()) < nDrgLog &&
2000-09-18 16:07:07 +00:00
!rMEvt.IsShift() && !rMEvt.IsMod2())
{
SdrViewEvent aVEvt;
SdrHitKind eHit = mpView->PickAnything(rMEvt, SdrMouseEventKind::BUTTONDOWN, aVEvt);
2000-09-18 16:07:07 +00:00
if (eHit == SdrHitKind::NONE)
2000-09-18 16:07:07 +00:00
{
// click on position: deselect
mpView->UnmarkAllObj();
2000-09-18 16:07:07 +00:00
}
}
mpWindow->ReleaseMouse();
2000-09-18 16:07:07 +00:00
return bReturn;
}
/**
* Process keyboard input
* @returns sal_True if a KeyEvent is being processed, sal_False otherwise
*/
bool FuEditGluePoints::KeyInput(const KeyEvent& rKEvt)
2000-09-18 16:07:07 +00:00
{
mpView->SetActualWin( mpWindow );
2000-09-18 16:07:07 +00:00
//Add Shift+UP/DOWN/LEFT/RIGHT key to move the position of insert point,
2014-04-10 10:46:50 +02:00
//and SHIFT+ENTER key to decide the position and draw the new insert point
bool bReturn = false;
switch (rKEvt.GetKeyCode().GetCode())
{
case KEY_UP:
case KEY_DOWN:
case KEY_LEFT:
case KEY_RIGHT:
{
if(rKEvt.GetKeyCode().IsShift()&& mpView->IsInsGluePointMode() ){
long nX = 0;
long nY = 0;
sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
if (nCode == KEY_UP)
{
// scroll up
nX = 0;
nY =-1;
}
else if (nCode == KEY_DOWN)
{
// scroll down
nX = 0;
nY = 1;
}
else if (nCode == KEY_LEFT)
{
// scroll left
nX =-1;
nY = 0;
}
else if (nCode == KEY_RIGHT)
{
// scroll right
nX = 1;
nY = 0;
}
Point centerPoint;
::tools::Rectangle rect = mpView->GetMarkedObjRect();
centerPoint = mpWindow->LogicToPixel(rect.Center());
Point aPoint = bBeginInsertPoint? oldPoint:centerPoint;
Point ePoint = aPoint + Point(nX,nY);
mpWindow->SetPointerPosPixel(ePoint);
//simulate mouse move action
MouseEvent eMevt(ePoint, 1, MouseEventModifiers::DRAGMOVE, MOUSE_LEFT, 0);
MouseMove(eMevt);
oldPoint = ePoint;
bBeginInsertPoint = true;
bReturn = true;
}
}
break;
case KEY_RETURN:
if(rKEvt.GetKeyCode().IsShift() && mpView->IsInsGluePointMode() )
{
if(bBeginInsertPoint)
{
mpWindow->SetPointerPosPixel(oldPoint);
//simulate mouse button down action
MouseEvent aMevt(oldPoint, 1,
MouseEventModifiers::SIMPLEMOVE | MouseEventModifiers::DRAGMOVE,
MOUSE_LEFT, KEY_SHIFT);
// MT IA2: Not used?
// sal_uInt16 ubuttons = aMevt.GetButtons();
// sal_uInt16 uMod = aMevt.GetModifier();
MouseButtonDown(aMevt);
mpWindow->CaptureMouse();
//simulate mouse button up action
MouseEvent rMEvt(oldPoint+Point(0,0), 1,
MouseEventModifiers::SIMPLEMOVE | MouseEventModifiers::ENTERWINDOW,
MOUSE_LEFT, KEY_SHIFT);
MouseButtonUp(rMEvt);
bReturn= true;
}
}
break;
}
if(!bReturn)
bReturn = FuDraw::KeyInput(rKEvt);
2000-09-18 16:07:07 +00:00
return bReturn;
}
//Add Shift+UP/DOWN/LEFT/RIGHT key to move the position of insert point, and
2014-04-10 10:46:50 +02:00
//SHIFT+ENTER key to decide the position and draw the new insert point
void FuEditGluePoints::ForcePointer(const MouseEvent* pMEvt)
{
if(bBeginInsertPoint && pMEvt)
{
MouseEvent aMEvt(pMEvt->GetPosPixel(), pMEvt->GetClicks(),
pMEvt->GetMode(), pMEvt->GetButtons(), pMEvt->GetModifier() & ~KEY_SHIFT);
FuDraw::ForcePointer(&aMEvt);
}
else
{
FuDraw::ForcePointer(pMEvt);
}
}
2000-09-18 16:07:07 +00:00
bool FuEditGluePoints::Command(const CommandEvent& rCEvt)
2000-09-18 16:07:07 +00:00
{
mpView->SetActualWin( mpWindow );
return FuPoor::Command( rCEvt );
2000-09-18 16:07:07 +00:00
}
void FuEditGluePoints::Activate()
{
mpView->SetGluePointEditMode();
2000-09-18 16:07:07 +00:00
FuDraw::Activate();
}
void FuEditGluePoints::Deactivate()
{
mpView->SetGluePointEditMode( false );
2000-09-18 16:07:07 +00:00
FuDraw::Deactivate();
}
void FuEditGluePoints::ReceiveRequest(SfxRequest& rReq)
{
switch (rReq.GetSlot())
{
case SID_GLUE_INSERT_POINT:
{
mpView->SetInsGluePointMode(!mpView->IsInsGluePointMode());
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_ESCDIR_LEFT:
{
mpView->SetMarkedGluePointsEscDir( SdrEscapeDirection::LEFT,
!mpView->IsMarkedGluePointsEscDir( SdrEscapeDirection::LEFT ) );
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_ESCDIR_RIGHT:
{
mpView->SetMarkedGluePointsEscDir( SdrEscapeDirection::RIGHT,
!mpView->IsMarkedGluePointsEscDir( SdrEscapeDirection::RIGHT ) );
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_ESCDIR_TOP:
{
mpView->SetMarkedGluePointsEscDir( SdrEscapeDirection::TOP,
!mpView->IsMarkedGluePointsEscDir( SdrEscapeDirection::TOP ) );
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_ESCDIR_BOTTOM:
{
mpView->SetMarkedGluePointsEscDir( SdrEscapeDirection::BOTTOM,
!mpView->IsMarkedGluePointsEscDir( SdrEscapeDirection::BOTTOM ) );
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_PERCENT:
{
const SfxItemSet* pSet = rReq.GetArgs();
const SfxPoolItem& rItem = pSet->Get(SID_GLUE_PERCENT);
bool bPercent = static_cast<const SfxBoolItem&>(rItem).GetValue();
mpView->SetMarkedGluePointsPercent(bPercent);
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_HORZALIGN_CENTER:
{
mpView->SetMarkedGluePointsAlign(false, SdrAlign::HORZ_CENTER);
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_HORZALIGN_LEFT:
{
mpView->SetMarkedGluePointsAlign(false, SdrAlign::HORZ_LEFT);
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_HORZALIGN_RIGHT:
{
mpView->SetMarkedGluePointsAlign(false, SdrAlign::HORZ_RIGHT);
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_VERTALIGN_CENTER:
{
mpView->SetMarkedGluePointsAlign(true, SdrAlign::VERT_CENTER);
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_VERTALIGN_TOP:
{
mpView->SetMarkedGluePointsAlign(true, SdrAlign::VERT_TOP);
2000-09-18 16:07:07 +00:00
}
break;
case SID_GLUE_VERTALIGN_BOTTOM:
{
mpView->SetMarkedGluePointsAlign(true, SdrAlign::VERT_BOTTOM);
2000-09-18 16:07:07 +00:00
}
break;
}
// at the end, call base class
2000-09-18 16:07:07 +00:00
FuPoor::ReceiveRequest(rReq);
}
} // end of namespace sd
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */