summaryrefslogtreecommitdiff
path: root/sd/source/ui/func
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-12-09 22:07:29 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2009-12-09 22:07:29 +0100
commit5b2f8a623d8eef6a03f9ff36d36811c784005ce0 (patch)
treeb17fc65848f4489bedf13b985b92787f36e71b49 /sd/source/ui/func
parentc5a3b3f07931b4bba47c4cb327dd394c85272f45 (diff)
parentf06dd4493d6bdc97371138ae1e28ac5d37bc188e (diff)
dba33b: merge CWS head with head resulting from pulling DEV300_m67
Diffstat (limited to 'sd/source/ui/func')
-rw-r--r--sd/source/ui/func/fuformatpaintbrush.cxx248
1 files changed, 195 insertions, 53 deletions
diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx b/sd/source/ui/func/fuformatpaintbrush.cxx
index 1eaee6385175..eb4ca01ba621 100644
--- a/sd/source/ui/func/fuformatpaintbrush.cxx
+++ b/sd/source/ui/func/fuformatpaintbrush.cxx
@@ -31,19 +31,30 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
+#include <sfx2/request.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+
+#include <svtools/itemiter.hxx>
+
+#include <svx/globl3d.hxx>
+#include <svx/svxids.hrc>
+#include <svx/svdotable.hxx>
+#include <svx/outliner.hxx>
+#include <svx/eeitem.hxx>
+#include <svx/editeng.hxx>
+
#define _SD_DLL // fuer SD_MOD()
#include "sdmod.hxx"
#include "fuformatpaintbrush.hxx"
-#include "formatclipboard.hxx"
-#include "View.hxx"
-#include "ViewShell.hxx"
+#include "drawview.hxx"
#include "DrawDocShell.hxx"
-// header for class SfxBindings
-#include <sfx2/bindings.hxx>
-/*
-#include <svx/svxids.hrc>
-*/
+#include "DrawViewShell.hxx"
+#include "FrameView.hxx"
+#include "drawdoc.hxx"
+#include "Outliner.hxx"
+#include "ViewShellBase.hxx"
#ifndef SD_WINDOW_SHELL_HXX
#include "Window.hxx"
@@ -51,66 +62,137 @@
namespace sd {
-TYPEINIT1( FuFormatPaintBrush, FuPoor );
+TYPEINIT1( FuFormatPaintBrush, FuText );
-FuFormatPaintBrush::FuFormatPaintBrush(
- ViewShell* pViewSh
- , ::sd::Window* pWin
- , ::sd::View* pView
- , SdDrawDocument* pDoc
- , SfxRequest& rReq )
- : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
+FuFormatPaintBrush::FuFormatPaintBrush( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
+: FuText(pViewSh, pWin, pView, pDoc, rReq)
+, mbPermanent( false )
+, mbOldIsQuickTextEditMode( true )
{
}
FunctionReference FuFormatPaintBrush::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
FunctionReference xFunc( new FuFormatPaintBrush( pViewSh, pWin, pView, pDoc, rReq ) );
+ xFunc->DoExecute( rReq );
return xFunc;
}
+void FuFormatPaintBrush::DoExecute( SfxRequest& rReq )
+{
+ const SfxItemSet *pArgs = rReq.GetArgs();
+ if( pArgs && pArgs->Count() >= 1 )
+ {
+ mbPermanent = static_cast<bool>(((SfxBoolItem &)pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue());
+ }
+
+ if( mpView )
+ {
+ mpView->TakeFormatPaintBrush( mpItemSet );
+ }
+}
+
+void FuFormatPaintBrush::implcancel()
+{
+ if( mpViewShell && mpViewShell->GetViewFrame() )
+ {
+ SfxViewFrame* pViewFrame = mpViewShell->GetViewFrame();
+ pViewFrame->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+ pViewFrame->GetDispatcher()->Execute(SID_OBJECT_SELECT, SFX_CALLMODE_ASYNCHRON);
+ }
+}
+
+static void unmarkimpl( SdrView* pView )
+{
+ pView->SdrEndTextEdit();
+ pView->UnMarkAll();
+}
+
BOOL FuFormatPaintBrush::MouseButtonDown(const MouseEvent& rMEvt)
{
if(mpView&&mpWindow)
{
- USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
- BOOL bToggle = FALSE;
- mpView->UnMarkAll();
- mpView->MarkObj(mpWindow->PixelToLogic( rMEvt.GetPosPixel() ), nHitLog, bToggle, FALSE);
+ SdrViewEvent aVEvt;
+ SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
+
+ if( (eHit == SDRHIT_TEXTEDIT) || (eHit == SDRHIT_TEXTEDITOBJ && ( mpViewShell->GetFrameView()->IsQuickEdit() || dynamic_cast< sdr::table::SdrTableObj* >( aVEvt.pObj ) != NULL ) ))
+ {
+ SdrObject* pPickObj=0;
+ SdrPageView* pPV=0;
+ USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
+ mpView->PickObj( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ),nHitLog, pPickObj, pPV, SDRSEARCH_PICKMARKABLE);
+
+ if( (pPickObj != 0) && !pPickObj->IsEmptyPresObj() )
+ {
+ // if we text hit another shape than the one currently selected, unselect the old one now
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+ if( rMarkList.GetMarkCount() >= 1 )
+ {
+ if( rMarkList.GetMarkCount() == 1 )
+ {
+ if( rMarkList.GetMark(0)->GetMarkedSdrObj() != pPickObj )
+ {
+
+ // if current selected shape is not that of the hit text edit, deselect it
+ unmarkimpl( mpView );
+ }
+ }
+ else
+ {
+ // more than one shape selected, deselect all of them
+ unmarkimpl( mpView );
+ }
+ }
+ MouseEvent aMEvt( rMEvt.GetPosPixel(), rMEvt.GetClicks(), rMEvt.GetMode(), rMEvt.GetButtons(), 0 );
+ return FuText::MouseButtonDown(aMEvt);
+ }
+
+ if( aVEvt.pObj == 0 )
+ aVEvt.pObj = pPickObj;
+ }
+
+ unmarkimpl( mpView );
+
+ if( aVEvt.pObj )
+ {
+ USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
+ BOOL bToggle = FALSE;
+ mpView->MarkObj(mpWindow->PixelToLogic( rMEvt.GetPosPixel() ), nHitLog, bToggle, FALSE);
+ return TRUE;
+ }
}
return FALSE;
}
BOOL FuFormatPaintBrush::MouseMove(const MouseEvent& rMEvt)
{
- SdFormatClipboard* pFormatClipboard = 0;
- if(mpViewShell)
- pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
- if(mpView&&mpWindow&&pFormatClipboard&&pFormatClipboard->HasContent())
+ BOOL bReturn = FALSE;
+ if( mpWindow && mpView )
{
- USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
- SdrObject* pObj=0;
- SdrPageView* pPV=0;
- BOOL bOverMarkableObject = mpView->PickObj(
- mpWindow->PixelToLogic( rMEvt.GetPosPixel() )
- ,nHitLog, pObj, pPV, SDRSEARCH_PICKMARKABLE);
-
- if(bOverMarkableObject && pFormatClipboard->HasContentForThisType(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
+ if ( mpView->IsTextEdit() )
+ {
+ bReturn = FuText::MouseMove( rMEvt );
mpWindow->SetPointer(Pointer(POINTER_FILL));
+ }
else
- mpWindow->SetPointer(Pointer(POINTER_ARROW));
+ {
+ USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
+ SdrObject* pObj=0;
+ SdrPageView* pPV=0;
+ BOOL bOverMarkableObject = mpView->PickObj( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ),nHitLog, pObj, pPV, SDRSEARCH_PICKMARKABLE);
+
+ if(bOverMarkableObject && HasContentForThisType(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
+ mpWindow->SetPointer(Pointer(POINTER_FILL));
+ else
+ mpWindow->SetPointer(Pointer(POINTER_ARROW));
+ }
}
- else
- mpWindow->SetPointer(Pointer(POINTER_ARROW));
- return FALSE;
+ return bReturn;
}
BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt)
{
- SdFormatClipboard* pFormatClipboard = 0;
- if(mpViewShell)
- pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
- if( pFormatClipboard && mpView && mpView->AreObjectsMarked() )
+ if( mpItemSet.get() && mpView && mpView->AreObjectsMarked() )
{
bool bNoCharacterFormats = false;
bool bNoParagraphFormats = false;
@@ -120,37 +202,97 @@ BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt)
else if( rMEvt.GetModifier() & KEY_MOD1 )
bNoParagraphFormats = true;
}
- pFormatClipboard->Paste( *mpView, bNoCharacterFormats, bNoParagraphFormats );
+
+ OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
+ if( pOLV )
+ pOLV->MouseButtonUp(rMEvt);
+
+ Paste( bNoCharacterFormats, bNoParagraphFormats );
if(mpViewShell)
mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
+
+ if( mbPermanent )
+ return TRUE;
}
- if(mpViewShell && pFormatClipboard && !pFormatClipboard->HasContent() )
- mpViewShell->Cancel();
+
+ implcancel();
return TRUE;
}
BOOL FuFormatPaintBrush::KeyInput(const KeyEvent& rKEvt)
{
- if( rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE && mpViewShell )
+ if( (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE) && mpViewShell )
{
- SdFormatClipboard* pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
- if(pFormatClipboard)
- {
- pFormatClipboard->Erase();
- mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
- mpViewShell->Cancel();
-
- return TRUE;
- }
+ implcancel();
+ return TRUE;
}
return FuPoor::KeyInput(rKEvt);
}
void FuFormatPaintBrush::Activate()
{
+ mbOldIsQuickTextEditMode = mpViewShell->GetFrameView()->IsQuickEdit();
+ if( !mbOldIsQuickTextEditMode )
+ {
+ mpViewShell->GetFrameView()->SetQuickEdit(TRUE);
+ mpView->SetQuickTextEditMode(TRUE);
+ }
}
void FuFormatPaintBrush::Deactivate()
{
+ if( !mbOldIsQuickTextEditMode )
+ {
+ mpViewShell->GetFrameView()->SetQuickEdit(FALSE);
+ mpView->SetQuickTextEditMode(FALSE);
+ }
+}
+
+bool FuFormatPaintBrush::HasContentForThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const
+{
+ if( mpItemSet.get() == 0 )
+ return false;
+ if( !mpView || (!mpView->SupportsFormatPaintbrush( nObjectInventor, nObjectIdentifier) ) )
+ return false;
+ return true;
+}
+
+void FuFormatPaintBrush::Paste( bool bNoCharacterFormats, bool bNoParagraphFormats )
+{
+ const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
+ if(mpItemSet.get() && (rMarkList.GetMarkCount() == 1) )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+
+ if( mpDoc->IsUndoEnabled() )
+ {
+ String sLabel( mpViewShell->GetViewShellBase().RetrieveLabelFromCommand( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FormatPaintbrush" ) ) ) );
+ mpDoc->BegUndo( sLabel );
+ mpDoc->AddUndo(mpDoc->GetSdrUndoFactory().CreateUndoAttrObject(*pObj,FALSE,TRUE));
+ }
+
+ mpView->ApplyFormatPaintBrush( *mpItemSet.get(), bNoCharacterFormats, bNoParagraphFormats );
+
+ if( mpDoc->IsUndoEnabled() )
+ {
+ mpDoc->EndUndo();
+ }
+ }
}
+
+/* static */ void FuFormatPaintBrush::GetMenuState( DrawViewShell& rDrawViewShell, SfxItemSet &rSet )
+{
+ const SdrMarkList& rMarkList = rDrawViewShell.GetDrawView()->GetMarkedObjectList();
+ const ULONG nMarkCount = rMarkList.GetMarkCount();
+
+ if( nMarkCount == 1 )
+ {
+ SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
+ if( pObj && rDrawViewShell.GetDrawView()->SupportsFormatPaintbrush(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
+ return;
+ }
+ rSet.DisableItem( SID_FORMATPAINTBRUSH );
+}
+
+
} // end of namespace sd