Kaydet (Commit) 1cecb228 authored tarafından Kurt Zenker's avatar Kurt Zenker

CWS-TOOLING: integrate CWS impresspaintbrush01

...@@ -2226,7 +2226,7 @@ interface DrawView ...@@ -2226,7 +2226,7 @@ interface DrawView
SID_FORMATPAINTBRUSH // SID_FORMATPAINTBRUSH //
[ [
ExecMethod = FuTemporary ; ExecMethod = FuPermanent ;
StateMethod = GetMenuState ; StateMethod = GetMenuState ;
] ]
......
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
#include "FrameView.hxx" #include "FrameView.hxx"
#endif #endif
#include "unomodel.hxx" #include "unomodel.hxx"
#include "formatclipboard.hxx"
#include "undo/undomanager.hxx" #include "undo/undomanager.hxx"
#include "undo/undofactory.hxx" #include "undo/undofactory.hxx"
#include "OutlineView.hxx" #include "OutlineView.hxx"
...@@ -169,7 +168,6 @@ DrawDocShell::DrawDocShell(SfxObjectCreateMode eMode, ...@@ -169,7 +168,6 @@ DrawDocShell::DrawDocShell(SfxObjectCreateMode eMode,
BOOL bDataObject, BOOL bDataObject,
DocumentType eDocumentType,BOOL bScriptSupport) : DocumentType eDocumentType,BOOL bScriptSupport) :
SfxObjectShell( eMode == SFX_CREATE_MODE_INTERNAL ? SFX_CREATE_MODE_EMBEDDED : eMode), SfxObjectShell( eMode == SFX_CREATE_MODE_INTERNAL ? SFX_CREATE_MODE_EMBEDDED : eMode),
mpFormatClipboard(new SdFormatClipboard()),
mpDoc(NULL), mpDoc(NULL),
mpUndoManager(NULL), mpUndoManager(NULL),
mpPrinter(NULL), mpPrinter(NULL),
...@@ -196,7 +194,6 @@ DrawDocShell::DrawDocShell(SdDrawDocument* pDoc, SfxObjectCreateMode eMode, ...@@ -196,7 +194,6 @@ DrawDocShell::DrawDocShell(SdDrawDocument* pDoc, SfxObjectCreateMode eMode,
BOOL bDataObject, BOOL bDataObject,
DocumentType eDocumentType) : DocumentType eDocumentType) :
SfxObjectShell(eMode == SFX_CREATE_MODE_INTERNAL ? SFX_CREATE_MODE_EMBEDDED : eMode), SfxObjectShell(eMode == SFX_CREATE_MODE_INTERNAL ? SFX_CREATE_MODE_EMBEDDED : eMode),
mpFormatClipboard(new SdFormatClipboard()),
mpDoc(pDoc), mpDoc(pDoc),
mpUndoManager(NULL), mpUndoManager(NULL),
mpPrinter(NULL), mpPrinter(NULL),
...@@ -235,9 +232,6 @@ DrawDocShell::~DrawDocShell() ...@@ -235,9 +232,6 @@ DrawDocShell::~DrawDocShell()
mpDoc->SetSdrUndoManager( 0 ); mpDoc->SetSdrUndoManager( 0 );
delete mpUndoManager; delete mpUndoManager;
if(mpFormatClipboard)
delete mpFormatClipboard;
if (mbOwnPrinter) if (mbOwnPrinter)
delete mpPrinter; delete mpPrinter;
......
/*************************************************************************
*
* 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;
}
...@@ -47,7 +47,6 @@ AUTOSEG=true ...@@ -47,7 +47,6 @@ AUTOSEG=true
# --- Files -------------------------------------------------------- # --- Files --------------------------------------------------------
SLOFILES = \ SLOFILES = \
$(SLO)$/formatclipboard.obj \
$(SLO)$/docshell.obj \ $(SLO)$/docshell.obj \
$(SLO)$/docshel2.obj \ $(SLO)$/docshel2.obj \
$(SLO)$/docshel3.obj \ $(SLO)$/docshel3.obj \
......
...@@ -31,19 +31,30 @@ ...@@ -31,19 +31,30 @@
// MARKER(update_precomp.py): autogen include statement, do not remove // MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx" #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() #define _SD_DLL // fuer SD_MOD()
#include "sdmod.hxx" #include "sdmod.hxx"
#include "fuformatpaintbrush.hxx" #include "fuformatpaintbrush.hxx"
#include "formatclipboard.hxx" #include "drawview.hxx"
#include "View.hxx"
#include "ViewShell.hxx"
#include "DrawDocShell.hxx" #include "DrawDocShell.hxx"
// header for class SfxBindings #include "DrawViewShell.hxx"
#include <sfx2/bindings.hxx> #include "FrameView.hxx"
/* #include "drawdoc.hxx"
#include <svx/svxids.hrc> #include "Outliner.hxx"
*/ #include "ViewShellBase.hxx"
#ifndef SD_WINDOW_SHELL_HXX #ifndef SD_WINDOW_SHELL_HXX
#include "Window.hxx" #include "Window.hxx"
...@@ -51,66 +62,137 @@ ...@@ -51,66 +62,137 @@
namespace sd { namespace sd {
TYPEINIT1( FuFormatPaintBrush, FuPoor ); TYPEINIT1( FuFormatPaintBrush, FuText );
FuFormatPaintBrush::FuFormatPaintBrush( FuFormatPaintBrush::FuFormatPaintBrush( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
ViewShell* pViewSh : FuText(pViewSh, pWin, pView, pDoc, rReq)
, ::sd::Window* pWin , mbPermanent( false )
, ::sd::View* pView , mbOldIsQuickTextEditMode( true )
, SdDrawDocument* pDoc
, SfxRequest& rReq )
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{ {
} }
FunctionReference FuFormatPaintBrush::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq ) FunctionReference FuFormatPaintBrush::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{ {
FunctionReference xFunc( new FuFormatPaintBrush( pViewSh, pWin, pView, pDoc, rReq ) ); FunctionReference xFunc( new FuFormatPaintBrush( pViewSh, pWin, pView, pDoc, rReq ) );
xFunc->DoExecute( rReq );
return xFunc; 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) BOOL FuFormatPaintBrush::MouseButtonDown(const MouseEvent& rMEvt)
{ {
if(mpView&&mpWindow) if(mpView&&mpWindow)
{ {
USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() ); SdrViewEvent aVEvt;
BOOL bToggle = FALSE; SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);
mpView->UnMarkAll();
mpView->MarkObj(mpWindow->PixelToLogic( rMEvt.GetPosPixel() ), nHitLog, bToggle, FALSE); 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; return FALSE;
} }
BOOL FuFormatPaintBrush::MouseMove(const MouseEvent& rMEvt) BOOL FuFormatPaintBrush::MouseMove(const MouseEvent& rMEvt)
{ {
SdFormatClipboard* pFormatClipboard = 0; BOOL bReturn = FALSE;
if(mpViewShell) if( mpWindow && mpView )
pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
if(mpView&&mpWindow&&pFormatClipboard&&pFormatClipboard->HasContent())
{ {
USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() ); if ( mpView->IsTextEdit() )
SdrObject* pObj=0; {
SdrPageView* pPV=0; bReturn = FuText::MouseMove( rMEvt );
BOOL bOverMarkableObject = mpView->PickObj(
mpWindow->PixelToLogic( rMEvt.GetPosPixel() )
,nHitLog, pObj, pPV, SDRSEARCH_PICKMARKABLE);
if(bOverMarkableObject && pFormatClipboard->HasContentForThisType(pObj->GetObjInventor(),pObj->GetObjIdentifier()) )
mpWindow->SetPointer(Pointer(POINTER_FILL)); mpWindow->SetPointer(Pointer(POINTER_FILL));
}
else 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 return bReturn;
mpWindow->SetPointer(Pointer(POINTER_ARROW));
return FALSE;
} }
BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt) BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt)
{ {
SdFormatClipboard* pFormatClipboard = 0; if( mpItemSet.get() && mpView && mpView->AreObjectsMarked() )
if(mpViewShell)
pFormatClipboard = mpViewShell->GetDocSh()->mpFormatClipboard;
if( pFormatClipboard && mpView && mpView->AreObjectsMarked() )
{ {
bool bNoCharacterFormats = false; bool bNoCharacterFormats = false;
bool bNoParagraphFormats = false; bool bNoParagraphFormats = false;
...@@ -120,37 +202,97 @@ BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt) ...@@ -120,37 +202,97 @@ BOOL FuFormatPaintBrush::MouseButtonUp(const MouseEvent& rMEvt)
else if( rMEvt.GetModifier() & KEY_MOD1 ) else if( rMEvt.GetModifier() & KEY_MOD1 )
bNoParagraphFormats = true; bNoParagraphFormats = true;
} }
pFormatClipboard->Paste( *mpView, bNoCharacterFormats, bNoParagraphFormats );
OutlinerView* pOLV = mpView->GetTextEditOutlinerView();
if( pOLV )
pOLV->MouseButtonUp(rMEvt);
Paste( bNoCharacterFormats, bNoParagraphFormats );
if(mpViewShell) if(mpViewShell)
mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH); mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
if( mbPermanent )
return TRUE;
} }
if(mpViewShell && pFormatClipboard && !pFormatClipboard->HasContent() )
mpViewShell->Cancel(); implcancel();
return TRUE; return TRUE;
} }
BOOL FuFormatPaintBrush::KeyInput(const KeyEvent& rKEvt) 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; implcancel();
if(pFormatClipboard) return TRUE;
{
pFormatClipboard->Erase();
mpViewShell->GetViewFrame()->GetBindings().Invalidate(SID_FORMATPAINTBRUSH);
mpViewShell->Cancel();
return TRUE;
}
} }
return FuPoor::KeyInput(rKEvt); return FuPoor::KeyInput(rKEvt);
} }
void FuFormatPaintBrush::Activate() void FuFormatPaintBrush::Activate()
{ {
mbOldIsQuickTextEditMode = mpViewShell->GetFrameView()->IsQuickEdit();
if( !mbOldIsQuickTextEditMode )
{
mpViewShell->GetFrameView()->SetQuickEdit(TRUE);
mpView->SetQuickTextEditMode(TRUE);
}
} }
void FuFormatPaintBrush::Deactivate() 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 } // end of namespace sd
...@@ -52,7 +52,6 @@ class SfxPrinter; ...@@ -52,7 +52,6 @@ class SfxPrinter;
struct SdrDocumentStreamInfo; struct SdrDocumentStreamInfo;
struct SpellCallbackInfo; struct SpellCallbackInfo;
class AbstractSvxNameDialog; class AbstractSvxNameDialog;
class SdFormatClipboard;
namespace sd { namespace sd {
...@@ -209,9 +208,6 @@ public: ...@@ -209,9 +208,6 @@ public:
void ClearUndoBuffer(); void ClearUndoBuffer();
public:
SdFormatClipboard* mpFormatClipboard;
protected: protected:
SdDrawDocument* mpDoc; SdDrawDocument* mpDoc;
......
...@@ -259,6 +259,10 @@ public: ...@@ -259,6 +259,10 @@ public:
CustomHandleManager& getCustomHandleManager() const; 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: protected:
osl::Mutex maMutex; osl::Mutex maMutex;
......
/*************************************************************************
*
* 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
...@@ -31,15 +31,19 @@ ...@@ -31,15 +31,19 @@
#ifndef SD_FU_FORMATPAINTBRUSH_HXX #ifndef SD_FU_FORMATPAINTBRUSH_HXX
#define SD_FU_FORMATPAINTBRUSH_HXX #define SD_FU_FORMATPAINTBRUSH_HXX
#include "fupoor.hxx" #include "futext.hxx"
// header for class SfxItemSet // header for class SfxItemSet
#include <svtools/itemset.hxx> #include <svtools/itemset.hxx>
#include <boost/scoped_ptr.hpp>
class SfxItemSet;
namespace sd { namespace sd {
class FuFormatPaintBrush class DrawViewShell;
: public FuPoor
class FuFormatPaintBrush : public FuText
{ {
public: public:
TYPEINFO(); TYPEINFO();
...@@ -54,14 +58,22 @@ public: ...@@ -54,14 +58,22 @@ public:
virtual void Activate(); virtual void Activate();
virtual void Deactivate(); virtual void Deactivate();
static void GetMenuState( DrawViewShell& rDrawViewShell, SfxItemSet &rSet );
static bool CanCopyThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier );
private: private:
FuFormatPaintBrush ( FuFormatPaintBrush ( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq);
ViewShell* pViewSh,
::sd::Window* pWin, void DoExecute( SfxRequest& rReq );
::sd::View* pView,
SdDrawDocument* pDoc, bool HasContentForThisType( UINT32 nObjectInventor, UINT16 nObjectIdentifier ) const;
SfxRequest& rReq); void Paste( bool, bool );
void implcancel();
::boost::shared_ptr<SfxItemSet> mpItemSet;
bool mbPermanent;
bool mbOldIsQuickTextEditMode;
}; };
} // end of namespace sd } // end of namespace sd
......
...@@ -31,6 +31,13 @@ ...@@ -31,6 +31,13 @@
// MARKER(update_precomp.py): autogen include statement, do not remove // MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sd.hxx" #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 "ViewShellBase.hxx"
#include <algorithm> #include <algorithm>
#include "EventMultiplexer.hxx" #include "EventMultiplexer.hxx"
...@@ -94,6 +101,11 @@ using namespace sd; ...@@ -94,6 +101,11 @@ using namespace sd;
using ::sd::framework::FrameworkHelper; using ::sd::framework::FrameworkHelper;
using ::rtl::OUString; 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 { namespace {
...@@ -1210,6 +1222,47 @@ CustomHandleManager& ViewShellBase::getCustomHandleManager() const ...@@ -1210,6 +1222,47 @@ CustomHandleManager& ViewShellBase::getCustomHandleManager() const
return *mpImpl->mpCustomHandleManager.get(); 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 ========================================= //===== ViewShellBase::Implementation =========================================
......
...@@ -81,12 +81,8 @@ ...@@ -81,12 +81,8 @@
#include "fusumry.hxx" #include "fusumry.hxx"
#include "fucushow.hxx" #include "fucushow.hxx"
#include "drawview.hxx" #include "drawview.hxx"
#ifndef SD_FRAME_VIEW
#include "FrameView.hxx" #include "FrameView.hxx"
#endif
#include "Window.hxx" #include "Window.hxx"
#include "fuformatpaintbrush.hxx"
#include "formatclipboard.hxx"
#include "DrawDocShell.hxx" #include "DrawDocShell.hxx"
#include "TaskPaneViewShell.hxx" #include "TaskPaneViewShell.hxx"
#include "framework/FrameworkHelper.hxx" #include "framework/FrameworkHelper.hxx"
...@@ -501,35 +497,6 @@ void DrawViewShell::FuTemp04(SfxRequest& rReq) ...@@ -501,35 +497,6 @@ void DrawViewShell::FuTemp04(SfxRequest& rReq)
USHORT nSId = rReq.GetSlot(); USHORT nSId = rReq.GetSlot();
switch( nSId ) 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: case SID_FONTWORK:
{ {
if ( rReq.GetArgs() ) if ( rReq.GetArgs() )
......
...@@ -87,7 +87,6 @@ ...@@ -87,7 +87,6 @@
#include "zoomlist.hxx" #include "zoomlist.hxx"
#include "slideshow.hxx" #include "slideshow.hxx"
#include "drawview.hxx" #include "drawview.hxx"
#include "formatclipboard.hxx"
#include "ViewShellBase.hxx" #include "ViewShellBase.hxx"
#include "ViewShellManager.hxx" #include "ViewShellManager.hxx"
#include "LayerTabBar.hxx" #include "LayerTabBar.hxx"
...@@ -95,6 +94,7 @@ ...@@ -95,6 +94,7 @@
#include "Window.hxx" #include "Window.hxx"
#include "fuediglu.hxx" #include "fuediglu.hxx"
#include "fubullet.hxx" #include "fubullet.hxx"
#include "fuformatpaintbrush.hxx"
using ::rtl::OUString; using ::rtl::OUString;
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -249,19 +249,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet ) ...@@ -249,19 +249,7 @@ void DrawViewShell::GetMenuState( SfxItemSet &rSet )
const ULONG nMarkCount = rMarkList.GetMarkCount(); const ULONG nMarkCount = rMarkList.GetMarkCount();
//format paintbrush //format paintbrush
{ FuFormatPaintBrush::GetMenuState( *this, rSet );
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 );
}
}
// Stati der SfxChild-Windows (Animator, Fontwork etc.) // Stati der SfxChild-Windows (Animator, Fontwork etc.)
SetChildWindowState( rSet ); SetChildWindowState( rSet );
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
#include "anminfo.hxx" #include "anminfo.hxx"
#include "optsitem.hxx" #include "optsitem.hxx"
#include "Window.hxx" #include "Window.hxx"
#include "fuformatpaintbrush.hxx"
using ::rtl::OUString; using ::rtl::OUString;
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -203,13 +203,22 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) ...@@ -203,13 +203,22 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
if(HasCurrentFunction()) 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 && if ( nSId != SID_TEXTEDIT && nSId != SID_ATTR_CHAR && nSId != SID_TEXT_FITTOSIZE &&
nSId != SID_ATTR_CHAR_VERTICAL && nSId != SID_TEXT_FITTOSIZE_VERTICAL && nSId != SID_ATTR_CHAR_VERTICAL && nSId != SID_TEXT_FITTOSIZE_VERTICAL &&
nSId != SID_FORMATPAINTBRUSH &&
mpDrawView->IsTextEdit() ) mpDrawView->IsTextEdit() )
{ {
mpDrawView->SdrEndTextEdit(); mpDrawView->SdrEndTextEdit();
...@@ -526,8 +535,18 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq) ...@@ -526,8 +535,18 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
} }
break; 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: default:
break; break;
} }
if(HasOldFunction()) if(HasOldFunction())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment