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

221 lines
6.7 KiB
C++
Raw Normal View History

2000-09-18 16:07:07 +00:00
/*************************************************************************
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:07:07 +00:00
*
* $RCSfile: fusnapln.cxx,v $
2000-09-18 16:07:07 +00:00
*
* $Revision: 1.8 $
2000-09-18 16:07:07 +00:00
*
* last change: $Author: kz $ $Date: 2006-12-12 17:24:20 $
2000-09-18 16:07:07 +00:00
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
2000-09-18 16:07:07 +00:00
*
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2005 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
2000-09-18 16:07:07 +00:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
2000-09-18 16:07:07 +00:00
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
2000-09-18 16:07:07 +00:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
2000-09-18 16:07:07 +00:00
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
#include "fusnapln.hxx"
2000-09-18 16:07:07 +00:00
#ifndef _AEITEM_HXX //autogen
#include <svtools/aeitem.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif
#include "strings.hrc"
#include "sdattr.hxx"
#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_VIEW_SHELL_HXX
#include "ViewShell.hxx"
#endif
#ifndef SD_DRAW_VIEW_SHELL_HXX
#include "DrawViewShell.hxx"
#endif
#ifndef SD_WINDOW_SHELL_HXX
#include "Window.hxx"
#endif
#include "sdenumdef.hxx"
2000-09-18 16:07:07 +00:00
#include "sdresid.hxx"
#include "sdabstdlg.hxx"
2000-09-18 16:07:07 +00:00
#ifndef _SVDPAGV_HXX //autogen
#include <svx/svdpagv.hxx>
#endif
namespace sd {
2000-09-18 16:07:07 +00:00
TYPEINIT1( FuSnapLine, FuPoor );
/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/
FuSnapLine::FuSnapLine(ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
2000-09-18 16:07:07 +00:00
SdDrawDocument* pDoc, SfxRequest& rReq) :
FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}
FunctionReference FuSnapLine::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
FunctionReference xFunc( new FuSnapLine( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute(rReq);
return xFunc;
}
void FuSnapLine::DoExecute( SfxRequest& rReq )
2000-09-18 16:07:07 +00:00
{
const SfxItemSet* pArgs = rReq.GetArgs();
SdrPageView* pPV = 0;
USHORT nHelpLine = 0;
2000-09-18 16:07:07 +00:00
BOOL bCreateNew = TRUE;
if ( !pArgs )
{
SfxItemSet aNewAttr(mpViewShell->GetPool(), ATTR_SNAPLINE_START,
2000-09-18 16:07:07 +00:00
ATTR_SNAPLINE_END);
Point aLinePos = static_cast<DrawViewShell*>(mpViewShell)->GetMousePos();
static_cast<DrawViewShell*>(mpViewShell)->SetMousePosFreezed( FALSE );
2000-09-18 16:07:07 +00:00
BOOL bLineExist = FALSE;
pPV = mpView->GetSdrPageView();
2000-09-18 16:07:07 +00:00
if ( aLinePos.X() >= 0 )
{
aLinePos = mpWindow->PixelToLogic(aLinePos);
USHORT nHitLog = (USHORT) mpWindow->PixelToLogic(Size(HITPIX,0)).Width();
bLineExist = mpView->PickHelpLine(aLinePos, nHitLog, *mpWindow,
2000-09-18 16:07:07 +00:00
nHelpLine, pPV);
if ( bLineExist )
aLinePos = (pPV->GetHelpLines())[nHelpLine].GetPos();
else
pPV = mpView->GetSdrPageView();
2000-09-18 16:07:07 +00:00
pPV->LogicToPagePos(aLinePos);
}
else
aLinePos = Point(0,0);
aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_X, aLinePos.X()));
aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, aLinePos.Y()));
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdSnapLineDlg* pDlg = pFact ? pFact->CreateSdSnapLineDlg( NULL, aNewAttr, mpView ) : 0;
if( pDlg )
2000-09-18 16:07:07 +00:00
{
if ( bLineExist )
2000-09-18 16:07:07 +00:00
{
pDlg->HideRadioGroup();
const SdrHelpLine& rHelpLine = (pPV->GetHelpLines())[nHelpLine];
2000-09-18 16:07:07 +00:00
if ( rHelpLine.GetKind() == SDRHELPLINE_POINT )
{
pDlg->SetText(String(SdResId(STR_SNAPDLG_SETPOINT)));
pDlg->SetInputFields(TRUE, TRUE);
}
2000-09-18 16:07:07 +00:00
else
{
pDlg->SetText(String(SdResId(STR_SNAPDLG_SETLINE)));
if ( rHelpLine.GetKind() == SDRHELPLINE_VERTICAL )
pDlg->SetInputFields(TRUE, FALSE);
else
pDlg->SetInputFields(FALSE, TRUE);
}
bCreateNew = FALSE;
2000-09-18 16:07:07 +00:00
}
else
pDlg->HideDeleteBtn();
2000-09-18 16:07:07 +00:00
USHORT nResult = pDlg->Execute();
2000-09-18 16:07:07 +00:00
pDlg->GetAttr(aNewAttr);
delete pDlg;
2000-09-18 16:07:07 +00:00
switch( nResult )
{
case RET_OK:
rReq.Done(aNewAttr);
pArgs = rReq.GetArgs();
break;
case RET_SNAP_DELETE:
// Fangobjekt loeschen
if ( !bCreateNew )
pPV->DeleteHelpLine(nHelpLine);
// und weiter wie bei default
default:
return;
}
2000-09-18 16:07:07 +00:00
}
}
Point aHlpPos;
aHlpPos.X() = ((const SfxUInt32Item&) pArgs->Get(ATTR_SNAPLINE_X)).GetValue();
aHlpPos.Y() = ((const SfxUInt32Item&) pArgs->Get(ATTR_SNAPLINE_Y)).GetValue();
pPV->PagePosToLogic(aHlpPos);
if ( bCreateNew )
{
SdrHelpLineKind eKind;
pPV = mpView->GetSdrPageView();
2000-09-18 16:07:07 +00:00
switch ( (SnapKind) ((const SfxAllEnumItem&)
pArgs->Get(ATTR_SNAPLINE_KIND)).GetValue() )
{
case SK_HORIZONTAL : eKind = SDRHELPLINE_HORIZONTAL; break;
case SK_VERTICAL : eKind = SDRHELPLINE_VERTICAL; break;
default : eKind = SDRHELPLINE_POINT; break;
}
pPV->InsertHelpLine(SdrHelpLine(eKind, aHlpPos));
}
else
{
const SdrHelpLine& rHelpLine = (pPV->GetHelpLines())[nHelpLine];
pPV->SetHelpLine(nHelpLine, SdrHelpLine(rHelpLine.GetKind(), aHlpPos));
}
}
void FuSnapLine::Activate()
{
}
2000-09-18 16:07:07 +00:00
void FuSnapLine::Deactivate()
{
}
2000-09-18 16:07:07 +00:00
} // end of namespace sd