2004-08-02 09:09:13 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* $RCSfile: fuformatpaintbrush.cxx,v $
|
|
|
|
* $Revision: 1.8 $
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* OpenOffice.org 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 version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
2008-04-10 19:19:37 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-08-02 09:09:13 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 17:50:20 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
2004-08-02 09:09:13 +00:00
|
|
|
#define _SD_DLL // fuer SD_MOD()
|
|
|
|
#include "sdmod.hxx"
|
|
|
|
|
|
|
|
#include "fuformatpaintbrush.hxx"
|
|
|
|
#include "formatclipboard.hxx"
|
|
|
|
#include "View.hxx"
|
|
|
|
#include "ViewShell.hxx"
|
|
|
|
#include "DrawDocShell.hxx"
|
|
|
|
// header for class SfxBindings
|
|
|
|
#include <sfx2/bindings.hxx>
|
|
|
|
/*
|
|
|
|
#include <svx/svxids.hrc>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SD_WINDOW_SHELL_HXX
|
|
|
|
#include "Window.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace sd {
|
|
|
|
|
|
|
|
TYPEINIT1( FuFormatPaintBrush, FuPoor );
|
|
|
|
|
|
|
|
FuFormatPaintBrush::FuFormatPaintBrush(
|
|
|
|
ViewShell* pViewSh
|
|
|
|
, ::sd::Window* pWin
|
|
|
|
, ::sd::View* pView
|
|
|
|
, SdDrawDocument* pDoc
|
|
|
|
, SfxRequest& rReq )
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-12-14 15:58:40 +00:00
|
|
|
FunctionReference FuFormatPaintBrush::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
2004-08-02 09:09:13 +00:00
|
|
|
{
|
2005-12-14 15:58:40 +00:00
|
|
|
FunctionReference xFunc( new FuFormatPaintBrush( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
return xFunc;
|
2004-08-02 09:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FuFormatPaintBrush::MouseButtonDown(const MouseEvent& rMEvt)
|
|
|
|
{
|
2006-12-12 16:18:07 +00:00
|
|
|
if(mpView&&mpWindow)
|
2004-08-02 09:09:13 +00:00
|
|
|
{
|
2006-12-12 16:18:07 +00:00
|
|
|
USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
|
2004-08-02 09:09:13 +00:00
|
|
|
BOOL bToggle = FALSE;
|
2006-12-12 16:18:07 +00:00
|
|
|
mpView->UnMarkAll();
|
|
|
|
mpView->MarkObj(mpWindow->PixelToLogic( rMEvt.GetPosPixel() ), nHitLog, bToggle, FALSE);
|
2004-08-02 09:09:13 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FuFormatPaintBrush::MouseMove(const MouseEvent& rMEvt)
|
|
|
|
{
|
|
|
|
SdFormatClipboard* pFormatClipboard = 0;
|
2006-12-12 16:18:07 +00:00
|
|
|
if(mpViewShell)
|
|
|
|
pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
|
|
|
|
if(mpView&&mpWindow&&pFormatClipboard&&pFormatClipboard->HasContent())
|
2004-08-02 09:09:13 +00:00
|
|
|
{
|
2006-12-12 16:18:07 +00:00
|
|
|
USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
|
2004-08-02 09:09:13 +00:00
|
|
|
SdrObject* pObj=0;
|
|
|
|
SdrPageView* pPV=0;
|
2006-12-12 16:18:07 +00:00
|
|
|
BOOL bOverMarkableObject = mpView->PickObj(
|
|
|
|
mpWindow->PixelToLogic( rMEvt.GetPosPixel() )
|
2004-08-02 09:09:13 +00:00
|
|
|
,nHitLog, pObj, pPV, SDRSEARCH_PICKMARKABLE);
|
|
|
|
|
|
|
|
if(bOverMarkableObject && pFormatClipboard->HasContentForThisType(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
|
2006-12-12 16:18:07 +00:00
|
|
|
mpWindow->SetPointer(Pointer(POINTER_FILL));
|
2004-08-02 09:09:13 +00:00
|
|
|
else
|
2006-12-12 16:18:07 +00:00
|
|
|
mpWindow->SetPointer(Pointer(POINTER_ARROW));
|
2004-08-02 09:09:13 +00:00
|
|
|
}
|
|
|
|
else
|
2006-12-12 16:18:07 +00:00
|
|
|
mpWindow->SetPointer(Pointer(POINTER_ARROW));
|
2004-08-02 09:09:13 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt)
|
|
|
|
{
|
|
|
|
SdFormatClipboard* pFormatClipboard = 0;
|
2006-12-12 16:18:07 +00:00
|
|
|
if(mpViewShell)
|
|
|
|
pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
|
|
|
|
if( pFormatClipboard && mpView && mpView->AreObjectsMarked() )
|
2004-08-02 09:09:13 +00:00
|
|
|
{
|
|
|
|
bool bNoCharacterFormats = false;
|
|
|
|
bool bNoParagraphFormats = false;
|
|
|
|
{
|
|
|
|
if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
|
|
|
|
bNoCharacterFormats = true;
|
|
|
|
else if( rMEvt.GetModifier() & KEY_MOD1 )
|
|
|
|
bNoParagraphFormats = true;
|
|
|
|
}
|
2006-12-12 16:18:07 +00:00
|
|
|
pFormatClipboard->Paste( *mpView, bNoCharacterFormats, bNoParagraphFormats );
|
|
|
|
if(mpViewShell)
|
|
|
|
mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
|
2004-08-02 09:09:13 +00:00
|
|
|
}
|
2006-12-12 16:18:07 +00:00
|
|
|
if(mpViewShell && pFormatClipboard && !pFormatClipboard->HasContent() )
|
|
|
|
mpViewShell->Cancel();
|
2004-08-02 09:09:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL FuFormatPaintBrush::KeyInput(const KeyEvent& rKEvt)
|
|
|
|
{
|
2006-12-12 16:18:07 +00:00
|
|
|
if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE && mpViewShell )
|
2004-08-02 09:09:13 +00:00
|
|
|
{
|
2006-12-12 16:18:07 +00:00
|
|
|
SdFormatClipboard* pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
|
2004-08-02 09:09:13 +00:00
|
|
|
if(pFormatClipboard)
|
|
|
|
{
|
|
|
|
pFormatClipboard->Erase();
|
2006-12-12 16:18:07 +00:00
|
|
|
mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
|
|
|
|
mpViewShell->Cancel();
|
2004-08-02 09:09:13 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FuPoor::KeyInput(rKEvt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuFormatPaintBrush::Activate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuFormatPaintBrush::Deactivate()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
} // end of namespace sd
|