summaryrefslogtreecommitdiff
path: root/sd/source/ui
diff options
context:
space:
mode:
authorChristian Lippka <cl@openoffice.org>2009-10-23 11:25:33 +0000
committerChristian Lippka <cl@openoffice.org>2009-10-23 11:25:33 +0000
commit367b1a6aec6c09a3eeae328ecedc184440db45ee (patch)
treecafbfad06d48825a7b9cb119cfb5a57fb065695d /sd/source/ui
parentc1c224778cd5bf8d74b0bf45d0cd70fcc8ad35a4 (diff)
#i57928# reworked formatpaintbrush feature to support more shapes and text selection
Diffstat (limited to 'sd/source/ui')
-rw-r--r--sd/source/ui/docshell/docshell.cxx6
-rw-r--r--sd/source/ui/docshell/formatclipboard.cxx237
-rw-r--r--sd/source/ui/docshell/makefile.mk1
-rw-r--r--sd/source/ui/func/fuformatpaintbrush.cxx242
-rw-r--r--sd/source/ui/inc/DrawDocShell.hxx4
-rw-r--r--sd/source/ui/inc/ViewShellBase.hxx4
-rw-r--r--sd/source/ui/inc/formatclipboard.hxx64
-rw-r--r--sd/source/ui/inc/fuformatpaintbrush.hxx29
-rw-r--r--sd/source/ui/view/ViewShellBase.cxx53
-rw-r--r--sd/source/ui/view/drviews6.cxx33
-rw-r--r--sd/source/ui/view/drviews7.cxx16
-rw-r--r--sd/source/ui/view/drviewse.cxx27
12 files changed, 291 insertions, 425 deletions
diff --git a/sd/source/ui/docshell/docshell.cxx b/sd/source/ui/docshell/docshell.cxx
index 1ecfaa6ab..e25f3c180 100644
--- a/sd/source/ui/docshell/docshell.cxx
+++ b/sd/source/ui/docshell/docshell.cxx
@@ -92,7 +92,6 @@
#include "FrameView.hxx"
#endif
#include "unomodel.hxx"
-#include "formatclipboard.hxx"
#include "undo/undomanager.hxx"
#include "undo/undofactory.hxx"
#include "OutlineView.hxx"
@@ -169,7 +168,6 @@ DrawDocShell::DrawDocShell(SfxObjectCreateMode eMode,
BOOL bDataObject,
DocumentType eDocumentType,BOOL bScriptSupport) :
SfxObjectShell( eMode == SFX_CREATE_MODE_INTERNAL ? SFX_CREATE_MODE_EMBEDDED : eMode),
- mpFormatClipboard(new SdFormatClipboard()),
mpDoc(NULL),
mpUndoManager(NULL),
mpPrinter(NULL),
@@ -196,7 +194,6 @@ DrawDocShell::DrawDocShell(SdDrawDocument* pDoc, SfxObjectCreateMode eMode,
BOOL bDataObject,
DocumentType eDocumentType) :
SfxObjectShell(eMode == SFX_CREATE_MODE_INTERNAL ? SFX_CREATE_MODE_EMBEDDED : eMode),
- mpFormatClipboard(new SdFormatClipboard()),
mpDoc(pDoc),
mpUndoManager(NULL),
mpPrinter(NULL),
@@ -235,9 +232,6 @@ DrawDocShell::~DrawDocShell()
mpDoc->SetSdrUndoManager( 0 );
delete mpUndoManager;
- if(mpFormatClipboard)
- delete mpFormatClipboard;
-
if (mbOwnPrinter)
delete mpPrinter;
diff --git a/sd/source/ui/docshell/formatclipboard.cxx b/sd/source/ui/docshell/formatclipboard.cxx
deleted file mode 100644
index 0bc6d6fcd..000000000
--- a/sd/source/ui/docshell/formatclipboard.cxx
+++ /dev/null
@@ -1,237 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: formatclipboard.cxx,v $
- * $Revision: 1.10 $
- *
- * This file is part of OpenOffice.org.
- *
- * 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.
- *
- * 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).
- *
- * 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.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_sd.hxx"
-
-#include "formatclipboard.hxx"
-#include <svx/globl3d.hxx>
-
-// header for class SfxItemIter
-#include <svtools/itemiter.hxx>
-
-// header for class SfxStyleSheet
-#include <svtools/style.hxx>
-
-/*--------------------------------------------------------------------
- --------------------------------------------------------------------*/
-
-SdFormatClipboard::SdFormatClipboard()
- : m_pItemSet(0)
- , m_bPersistentCopy(false)
- , m_nType_Inventor(0)
- , m_nType_Identifier(0)
-{
-}
-SdFormatClipboard::~SdFormatClipboard()
-{
- if(m_pItemSet)
- delete m_pItemSet;
-}
-
-bool SdFormatClipboard::HasContent() const
-{
- return m_pItemSet!=0;
-}
-
-bool SdFormatClipboard::CanCopyThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const
-{
- if( nObjectInventor != SdrInventor && nObjectInventor != E3dInventor )
- return false;
- switch(nObjectIdentifier)
- {
- case OBJ_NONE:
- case OBJ_GRUP:
- return false;
- case OBJ_LINE:
- case OBJ_RECT:
- case OBJ_CIRC:
- case OBJ_SECT:
- case OBJ_CARC:
- case OBJ_CCUT:
- case OBJ_POLY:
- case OBJ_PLIN:
- case OBJ_PATHLINE:
- case OBJ_PATHFILL:
- case OBJ_FREELINE:
- case OBJ_FREEFILL:
- case OBJ_SPLNLINE:
- case OBJ_SPLNFILL:
- case OBJ_TEXT:
- case OBJ_TEXTEXT:
- case OBJ_TITLETEXT:
- return true;
- case OBJ_OUTLINETEXT:
- case OBJ_GRAF:
- case OBJ_OLE2:
- case OBJ_EDGE:
- case OBJ_CAPTION:
- return false;
- case OBJ_PATHPOLY:
- case OBJ_PATHPLIN:
- return true;
- case OBJ_PAGE:
- case OBJ_MEASURE:
- case OBJ_DUMMY:
- case OBJ_FRAME:
- case OBJ_UNO:
- return false;
- case OBJ_CUSTOMSHAPE:
- return true;
- default:
- return false;
- }
-}
-
-bool SdFormatClipboard::HasContentForThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const
-{
- if( !HasContent() )
- return false;
- if( !CanCopyThisType( nObjectInventor, nObjectIdentifier ) )
- return false;
- return true;
-}
-
-void SdFormatClipboard::Copy( ::sd::View& rDrawView, bool bPersistentCopy )
-{
- this->Erase();
- m_bPersistentCopy = bPersistentCopy;
-
- const SdrMarkList& rMarkList = rDrawView.GetMarkedObjectList();
- if( rMarkList.GetMarkCount() >= 1 )
- {
- BOOL bOnlyHardAttr = FALSE;
- m_pItemSet = new SfxItemSet( rDrawView.GetAttrFromMarked(bOnlyHardAttr) );
-
- SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- m_nType_Inventor = pObj->GetObjInventor();
- m_nType_Identifier = pObj->GetObjIdentifier();
- }
-}
-
-void SdFormatClipboard::Paste( ::sd::View& rDrawView, bool, bool )
-{
- if( !rDrawView.AreObjectsMarked() )
- {
- if(!m_bPersistentCopy)
- this->Erase();
- return;
- }
-
- SdrObject* pObj = 0;
-
- bool bWrongTargetType = false;
- {
- const SdrMarkList& rMarkList = rDrawView.GetMarkedObjectList();
- if( rMarkList.GetMarkCount() != 1 )
- bWrongTargetType = true;
- else
- {
- pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- if( pObj && pObj->GetStyleSheet() )
- bWrongTargetType = !this->HasContentForThisType( pObj->GetObjInventor(), pObj->GetObjIdentifier() );
- }
- }
- if( bWrongTargetType )
- {
- if(!m_bPersistentCopy)
- this->Erase();
- return;
- }
- if(m_pItemSet)
- {
- //modify source itemset
- {
- boost::shared_ptr< SfxItemSet > pTargetSet;
-
- if( pObj->GetStyleSheet() )
- {
- pTargetSet.reset( new SfxItemSet( pObj->GetStyleSheet()->GetItemSet() ) );
- }
- else
- {
- SdrModel* pModel = pObj->GetModel();
- if( pModel )
- {
- pTargetSet.reset( new SfxItemSet( pModel->GetItemPool() ) );
- }
- }
-
- if( pTargetSet.get() )
- {
- USHORT nWhich=0;
- SfxItemState nSourceState;
- SfxItemState nTargetState;
- const SfxPoolItem* pSourceItem=0;
- const SfxPoolItem* pTargetItem=0;
- SfxItemIter aSourceIter(*m_pItemSet);
- pSourceItem = aSourceIter.FirstItem();
- while( pSourceItem!=NULL )
- {
- if (!IsInvalidItem(pSourceItem))
- {
- nWhich = pSourceItem->Which();
- if(nWhich)
- {
- nSourceState = m_pItemSet->GetItemState( nWhich );
- nTargetState = pTargetSet->GetItemState( nWhich );
- pTargetItem = pTargetSet->GetItem( nWhich );
-
- if(!pTargetItem)
- m_pItemSet->ClearItem(nWhich);
- else if( (*pSourceItem) == (*pTargetItem) )
- {
- //do not set items which have the same content in source and target
- m_pItemSet->ClearItem(nWhich);
- }
- }
- }
- pSourceItem = aSourceIter.NextItem();
- }//end while
- }
- }
- BOOL bReplaceAll = TRUE;
- rDrawView.SetAttrToMarked(*m_pItemSet, bReplaceAll);
- }
- if(!m_bPersistentCopy)
- this->Erase();
-}
-
-void SdFormatClipboard::Erase()
-{
- if(m_pItemSet)
- {
- delete m_pItemSet;
- m_pItemSet = 0;
- }
- m_nType_Inventor=0;
- m_nType_Identifier=0;
- m_bPersistentCopy = false;
-}
diff --git a/sd/source/ui/docshell/makefile.mk b/sd/source/ui/docshell/makefile.mk
index f9e34eb03..d33faaf69 100644
--- a/sd/source/ui/docshell/makefile.mk
+++ b/sd/source/ui/docshell/makefile.mk
@@ -47,7 +47,6 @@ AUTOSEG=true
# --- Files --------------------------------------------------------
SLOFILES = \
- $(SLO)$/formatclipboard.obj \
$(SLO)$/docshell.obj \
$(SLO)$/docshel2.obj \
$(SLO)$/docshel3.obj \
diff --git a/sd/source/ui/func/fuformatpaintbrush.cxx b/sd/source/ui/func/fuformatpaintbrush.cxx
index ba757a302..4437bb4e1 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,142 @@
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 )
{
}
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);
+
+ BOOL bTextEdit = 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);
+ }
+ else
+ {
+ unmarkimpl( mpView );
+
+ }
+ }
+ else
+ {
+ unmarkimpl( mpView );
+
+ if( aVEvt.pObj && !aVEvt.pObj->IsEmptyPresObj() )
+ {
+ 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()) && !pObj->IsEmptyPresObj() )
+ 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,28 +207,29 @@ 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);
}
@@ -153,4 +241,52 @@ void FuFormatPaintBrush::Activate()
void FuFormatPaintBrush::Deactivate()
{
}
+
+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
diff --git a/sd/source/ui/inc/DrawDocShell.hxx b/sd/source/ui/inc/DrawDocShell.hxx
index 43099ef56..ccea601a2 100644
--- a/sd/source/ui/inc/DrawDocShell.hxx
+++ b/sd/source/ui/inc/DrawDocShell.hxx
@@ -52,7 +52,6 @@ class SfxPrinter;
struct SdrDocumentStreamInfo;
struct SpellCallbackInfo;
class AbstractSvxNameDialog;
-class SdFormatClipboard;
namespace sd {
@@ -209,9 +208,6 @@ public:
void ClearUndoBuffer();
-public:
- SdFormatClipboard* mpFormatClipboard;
-
protected:
SdDrawDocument* mpDoc;
diff --git a/sd/source/ui/inc/ViewShellBase.hxx b/sd/source/ui/inc/ViewShellBase.hxx
index 2fc8268f7..9d724bbcd 100644
--- a/sd/source/ui/inc/ViewShellBase.hxx
+++ b/sd/source/ui/inc/ViewShellBase.hxx
@@ -259,6 +259,10 @@ public:
CustomHandleManager& getCustomHandleManager() const;
+ /** returns the ui descriptive name for the given uno slot. The result is taken from the configuration
+ and not cached, so do not use it excessive (f.e. in status updates) */
+ ::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const;
+
protected:
osl::Mutex maMutex;
diff --git a/sd/source/ui/inc/formatclipboard.hxx b/sd/source/ui/inc/formatclipboard.hxx
deleted file mode 100644
index 02583faaa..000000000
--- a/sd/source/ui/inc/formatclipboard.hxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: formatclipboard.hxx,v $
- * $Revision: 1.4 $
- *
- * This file is part of OpenOffice.org.
- *
- * 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.
- *
- * 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).
- *
- * 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.
- *
- ************************************************************************/
-
-#ifndef _SDFORMATCLIPBOARD_HXX
-#define _SDFORMATCLIPBOARD_HXX
-
-#include "View.hxx"
-// header for class SfxItemSet
-#include <svtools/itemset.hxx>
-
-//-----------------------------------------------------------------------------
-/** This class acts as data container and execution class for the format paintbrush feature in draw and impress.
-*/
-
-class SdFormatClipboard
-{
-public:
- SdFormatClipboard();
- virtual ~SdFormatClipboard();
-
- bool HasContent() const;
- bool CanCopyThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const;
- bool HasContentForThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const;
-
- void Copy( ::sd::View& rDrawView, bool bPersistentCopy=false );
- void Paste( ::sd::View& rDrawView
- , bool bNoCharacterFormats=false, bool bNoParagraphFormats=false );
- void Erase();
-
-private:
- SfxItemSet* m_pItemSet;
- bool m_bPersistentCopy;
- UINT32 m_nType_Inventor;
- UINT16 m_nType_Identifier;
-};
-
-#endif
diff --git a/sd/source/ui/inc/fuformatpaintbrush.hxx b/sd/source/ui/inc/fuformatpaintbrush.hxx
index 5685ce6fd..6b8f07426 100644
--- a/sd/source/ui/inc/fuformatpaintbrush.hxx
+++ b/sd/source/ui/inc/fuformatpaintbrush.hxx
@@ -31,15 +31,19 @@
#ifndef SD_FU_FORMATPAINTBRUSH_HXX
#define SD_FU_FORMATPAINTBRUSH_HXX
-#include "fupoor.hxx"
+#include "futext.hxx"
// header for class SfxItemSet
#include <svtools/itemset.hxx>
+#include <boost/scoped_ptr.hpp>
+
+class SfxItemSet;
namespace sd {
-class FuFormatPaintBrush
- : public FuPoor
+class DrawViewShell;
+
+class FuFormatPaintBrush : public FuText
{
public:
TYPEINFO();
@@ -54,14 +58,21 @@ public:
virtual void Activate();
virtual void Deactivate();
+ static void GetMenuState( DrawViewShell& rDrawViewShell, SfxItemSet &rSet );
+ static bool CanCopyThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier );
+
private:
- FuFormatPaintBrush (
- ViewShell* pViewSh,
- ::sd::Window* pWin,
- ::sd::View* pView,
- SdDrawDocument* pDoc,
- SfxRequest& rReq);
+ FuFormatPaintBrush ( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq);
+ void DoExecute( SfxRequest& rReq );
+
+ bool HasContentForThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const;
+ void Paste( bool, bool );
+
+ void implcancel();
+
+ ::boost::shared_ptr<SfxItemSet> mpItemSet;
+ bool mbPermanent;
};
} // end of namespace sd
diff --git a/sd/source/ui/view/ViewShellBase.cxx b/sd/source/ui/view/ViewShellBase.cxx
index 56dbac92e..f5ad2a2c0 100644
--- a/sd/source/ui/view/ViewShellBase.cxx
+++ b/sd/source/ui/view/ViewShellBase.cxx
@@ -31,6 +31,13 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx"
+#include <comphelper/processfactory.hxx>
+
+#include <com/sun/star/frame/UnknownModuleException.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
#include "ViewShellBase.hxx"
#include <algorithm>
#include "EventMultiplexer.hxx"
@@ -94,6 +101,11 @@ using namespace sd;
using ::sd::framework::FrameworkHelper;
using ::rtl::OUString;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
namespace {
@@ -1210,6 +1222,47 @@ CustomHandleManager& ViewShellBase::getCustomHandleManager() const
return *mpImpl->mpCustomHandleManager.get();
}
+::rtl::OUString ViewShellBase::RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL ) const
+{
+ ::rtl::OUString aLabel;
+
+ if ( aCmdURL.getLength() > 0 ) try
+ {
+ Reference< XMultiServiceFactory > xServiceManager( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW );
+
+ Reference< XModuleManager > xModuleManager( xServiceManager->createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ModuleManager") ) ), UNO_QUERY_THROW );
+ Reference< XInterface > xIfac( GetMainViewShell()->GetViewFrame()->GetFrame()->GetFrameInterface(), UNO_QUERY_THROW );
+
+ ::rtl::OUString aModuleIdentifier( xModuleManager->identify( xIfac ) );
+
+ if( aModuleIdentifier.getLength() > 0 )
+ {
+ Reference< XNameAccess > xNameAccess( xServiceManager->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.UICommandDescription" ) ) ), UNO_QUERY );
+ if( xNameAccess.is() )
+ {
+ Reference< ::com::sun::star::container::XNameAccess > m_xUICommandLabels( xNameAccess->getByName( aModuleIdentifier ), UNO_QUERY_THROW );
+ Sequence< PropertyValue > aPropSeq;
+ if( m_xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
+ {
+ for( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ {
+ if( aPropSeq[i].Name.equalsAscii( "Name" ))
+ {
+ aPropSeq[i].Value >>= aLabel;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+
+ return aLabel;
+}
+
//===== ViewShellBase::Implementation =========================================
diff --git a/sd/source/ui/view/drviews6.cxx b/sd/source/ui/view/drviews6.cxx
index 5f8e75d2d..e8bd90493 100644
--- a/sd/source/ui/view/drviews6.cxx
+++ b/sd/source/ui/view/drviews6.cxx
@@ -81,12 +81,8 @@
#include "fusumry.hxx"
#include "fucushow.hxx"
#include "drawview.hxx"
-#ifndef SD_FRAME_VIEW
#include "FrameView.hxx"
-#endif
#include "Window.hxx"
-#include "fuformatpaintbrush.hxx"
-#include "formatclipboard.hxx"
#include "DrawDocShell.hxx"
#include "TaskPaneViewShell.hxx"
#include "framework/FrameworkHelper.hxx"
@@ -501,35 +497,6 @@ void DrawViewShell::FuTemp04(SfxRequest& rReq)
USHORT nSId = rReq.GetSlot();
switch( nSId )
{
- case SID_FORMATPAINTBRUSH:
- {
- SdFormatClipboard* pFormatClipboard = GetDocSh()->mpFormatClipboard;
- if(pFormatClipboard)
- {
- if( pFormatClipboard->HasContent() )
- {
- pFormatClipboard->Erase();
- GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
- Cancel();
- rReq.Ignore ();
- }
- else
- {
- bool bPersistentCopy = false;
- const SfxItemSet *pArgs = rReq.GetArgs();
- if( pArgs && pArgs->Count() >= 1 )
- {
- bPersistentCopy = static_cast<bool>(((SfxBoolItem &)pArgs->Get(
- SID_FORMATPAINTBRUSH)).GetValue());
- }
-
- pFormatClipboard->Copy( *mpDrawView, bPersistentCopy );
- SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
- GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
- }
- }
- }
- break;
case SID_FONTWORK:
{
if ( rReq.GetArgs() )
diff --git a/sd/source/ui/view/drviews7.cxx b/sd/source/ui/view/drviews7.cxx
index c4864e51d..1fc2f2076 100644
--- a/sd/source/ui/view/drviews7.cxx
+++ b/sd/source/ui/view/drviews7.cxx
@@ -87,7 +87,6 @@
#include "zoomlist.hxx"
#include "slideshow.hxx"
#include "drawview.hxx"
-#include "formatclipboard.hxx"
#include "ViewShellBase.hxx"
#include "ViewShellManager.hxx"
#include "LayerTabBar.hxx"
@@ -95,6 +94,7 @@
#include "Window.hxx"
#include "fuediglu.hxx"
#include "fubullet.hxx"
+#include "fuformatpaintbrush.hxx"
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -249,19 +249,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
const ULONG nMarkCount = rMarkList.GetMarkCount();
//format paintbrush
- {
- SdFormatClipboard* pFormatClipboard = GetDocSh()->mpFormatClipboard;
- bool bHasContent = pFormatClipboard && pFormatClipboard->HasContent();
- rSet.Put(SfxBoolItem(SID_FORMATPAINTBRUSH,bHasContent));
- if( ( nMarkCount!=1 && !bHasContent ) || mpDrawView->IsTextEdit() )
- rSet.DisableItem( SID_FORMATPAINTBRUSH );
- if( !bHasContent && nMarkCount==1 )
- {
- SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- if( !pFormatClipboard->CanCopyThisType(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
- rSet.DisableItem( SID_FORMATPAINTBRUSH );
- }
- }
+ FuFormatPaintBrush::GetMenuState( *this, rSet );
// Stati der SfxChild-Windows (Animator, Fontwork etc.)
SetChildWindowState( rSet );
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
index d580c4423..291e48a03 100644
--- a/sd/source/ui/view/drviewse.cxx
+++ b/sd/source/ui/view/drviewse.cxx
@@ -106,7 +106,7 @@
#include "anminfo.hxx"
#include "optsitem.hxx"
#include "Window.hxx"
-
+#include "fuformatpaintbrush.hxx"
using ::rtl::OUString;
using namespace ::com::sun::star;
@@ -203,13 +203,22 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
if(HasCurrentFunction())
{
- if(GetOldFunction() == GetCurrentFunction())
+ if( (nSId == SID_FORMATPAINTBRUSH) && (GetCurrentFunction()->GetSlotID() == SID_TEXTEDIT) )
+ {
+ // save text edit mode for format paintbrush!
+ SetOldFunction( GetCurrentFunction() );
+ }
+ else
{
- SetOldFunction(0);
+ if(GetOldFunction() == GetCurrentFunction())
+ {
+ SetOldFunction(0);
+ }
}
if ( nSId != SID_TEXTEDIT && nSId != SID_ATTR_CHAR && nSId != SID_TEXT_FITTOSIZE &&
nSId != SID_ATTR_CHAR_VERTICAL && nSId != SID_TEXT_FITTOSIZE_VERTICAL &&
+ nSId != SID_FORMATPAINTBRUSH &&
mpDrawView->IsTextEdit() )
{
mpDrawView->SdrEndTextEdit();
@@ -526,8 +535,18 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
}
break;
+ case SID_FORMATPAINTBRUSH:
+ {
+ SetCurrentFunction( FuFormatPaintBrush::Create( this, GetActiveWindow(), mpDrawView, GetDoc(), rReq ) );
+ rReq.Done();
+ SfxBindings& rBind = GetViewFrame()->GetBindings();
+ rBind.Invalidate( nSId );
+ rBind.Update( nSId );
+ break;
+ }
+
default:
- break;
+ break;
}
if(HasOldFunction())