1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fuformatpaintbrush.cxx,v $
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()
37 #include "fuformatpaintbrush.hxx"
38 #include "formatclipboard.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
54 TYPEINIT1( FuFormatPaintBrush
, FuPoor
);
56 FuFormatPaintBrush::FuFormatPaintBrush(
60 , SdDrawDocument
* pDoc
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
) );
72 BOOL
FuFormatPaintBrush::MouseButtonDown(const MouseEvent
& rMEvt
)
76 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
79 mpView
->MarkObj(mpWindow
->PixelToLogic( rMEvt
.GetPosPixel() ), nHitLog
, bToggle
, FALSE
);
84 BOOL
FuFormatPaintBrush::MouseMove(const MouseEvent
& rMEvt
)
86 SdFormatClipboard
* pFormatClipboard
= 0;
88 pFormatClipboard
= mpViewShell
->GetDocSh()->mpFormatClipboard
;
89 if(mpView
&&mpWindow
&&pFormatClipboard
&&pFormatClipboard
->HasContent())
91 USHORT nHitLog
= USHORT ( mpWindow
->PixelToLogic(Size(HITPIX
,0)).Width() );
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
));
101 mpWindow
->SetPointer(Pointer(POINTER_ARROW
));
104 mpWindow
->SetPointer(Pointer(POINTER_ARROW
));
108 BOOL
FuFormatPaintBrush::MouseButtonUp(const MouseEvent
& rMEvt
)
110 SdFormatClipboard
* pFormatClipboard
= 0;
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
);
125 mpViewShell
->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH
);
127 if(mpViewShell
&& pFormatClipboard
&& !pFormatClipboard
->HasContent() )
128 mpViewShell
->Cancel();
132 BOOL
FuFormatPaintBrush::KeyInput(const KeyEvent
& rKEvt
)
134 if( rKEvt
.GetKeyCode().GetCode() == KEY_ESCAPE
&& mpViewShell
)
136 SdFormatClipboard
* pFormatClipboard
= mpViewShell
->GetDocSh()->mpFormatClipboard
;
139 pFormatClipboard
->Erase();
140 mpViewShell
->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH
);
141 mpViewShell
->Cancel();
146 return FuPoor::KeyInput(rKEvt
);
149 void FuFormatPaintBrush::Activate()
153 void FuFormatPaintBrush::Deactivate()
156 } // end of namespace sd