merge the formfield patch from ooo-build
[ooovba.git] / sd / source / ui / func / fuformatpaintbrush.cxx
blobba757a30257f620e24a0494713f648610a51e97c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuformatpaintbrush.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sd.hxx"
34 #define _SD_DLL // fuer SD_MOD()
35 #include "sdmod.hxx"
37 #include "fuformatpaintbrush.hxx"
38 #include "formatclipboard.hxx"
39 #include "View.hxx"
40 #include "ViewShell.hxx"
41 #include "DrawDocShell.hxx"
42 // header for class SfxBindings
43 #include <sfx2/bindings.hxx>
45 #include <svx/svxids.hrc>
48 #ifndef SD_WINDOW_SHELL_HXX
49 #include "Window.hxx"
50 #endif
52 namespace sd {
54 TYPEINIT1( FuFormatPaintBrush, FuPoor );
56 FuFormatPaintBrush::FuFormatPaintBrush(
57 ViewShell* pViewSh
58 , ::sd::Window* pWin
59 , ::sd::View* pView
60 , SdDrawDocument* pDoc
61 , SfxRequest& rReq )
62 : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
66 FunctionReference FuFormatPaintBrush::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
68 FunctionReference xFunc( new FuFormatPaintBrush( pViewSh, pWin, pView, pDoc, rReq ) );
69 return xFunc;
72 BOOL FuFormatPaintBrush::MouseButtonDown(const MouseEvent& rMEvt)
74 if(mpView&&mpWindow)
76 USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
77 BOOL bToggle = FALSE;
78 mpView->UnMarkAll();
79 mpView->MarkObj(mpWindow->PixelToLogic( rMEvt.GetPosPixel() ), nHitLog, bToggle, FALSE);
81 return FALSE;
84 BOOL FuFormatPaintBrush::MouseMove(const MouseEvent& rMEvt)
86 SdFormatClipboard* pFormatClipboard = 0;
87 if(mpViewShell)
88 pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
89 if(mpView&&mpWindow&&pFormatClipboard&&pFormatClipboard->HasContent())
91 USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
92 SdrObject* pObj=0;
93 SdrPageView* pPV=0;
94 BOOL bOverMarkableObject = mpView->PickObj(
95 mpWindow->PixelToLogic( rMEvt.GetPosPixel() )
96 ,nHitLog, pObj, pPV, SDRSEARCH_PICKMARKABLE);
98 if(bOverMarkableObject && pFormatClipboard->HasContentForThisType(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
99 mpWindow->SetPointer(Pointer(POINTER_FILL));
100 else
101 mpWindow->SetPointer(Pointer(POINTER_ARROW));
103 else
104 mpWindow->SetPointer(Pointer(POINTER_ARROW));
105 return FALSE;
108 BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt)
110 SdFormatClipboard* pFormatClipboard = 0;
111 if(mpViewShell)
112 pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
113 if( pFormatClipboard && mpView && mpView->AreObjectsMarked() )
115 bool bNoCharacterFormats = false;
116 bool bNoParagraphFormats = false;
118 if( (rMEvt.GetModifier()&KEY_MOD1) && (rMEvt.GetModifier()&KEY_SHIFT) )
119 bNoCharacterFormats = true;
120 else if( rMEvt.GetModifier() & KEY_MOD1 )
121 bNoParagraphFormats = true;
123 pFormatClipboard->Paste( *mpView, bNoCharacterFormats, bNoParagraphFormats );
124 if(mpViewShell)
125 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
127 if(mpViewShell && pFormatClipboard && !pFormatClipboard->HasContent() )
128 mpViewShell->Cancel();
129 return TRUE;
132 BOOL FuFormatPaintBrush::KeyInput(const KeyEvent& rKEvt)
134 if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE && mpViewShell )
136 SdFormatClipboard* pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
137 if(pFormatClipboard)
139 pFormatClipboard->Erase();
140 mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
141 mpViewShell->Cancel();
143 return TRUE;
146 return FuPoor::KeyInput(rKEvt);
149 void FuFormatPaintBrush::Activate()
153 void FuFormatPaintBrush::Deactivate()
156 } // end of namespace sd