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

CWS-TOOLING: integrate CWS impresspaintbrush01

......@@ -2226,7 +2226,7 @@ interface DrawView
SID_FORMATPAINTBRUSH //
[
ExecMethod = FuTemporary ;
ExecMethod = FuPermanent ;
StateMethod = GetMenuState ;
]
......
......@@ -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;
......
/*************************************************************************
*
* 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
# --- Files --------------------------------------------------------
SLOFILES = \
$(SLO)$/formatclipboard.obj \
$(SLO)$/docshell.obj \
$(SLO)$/docshel2.obj \
$(SLO)$/docshel3.obj \
......
......@@ -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;
......
......@@ -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;
......
/*************************************************************************
*
* 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 @@
#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,22 @@ 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;
bool mbOldIsQuickTextEditMode;
};
} // end of namespace sd
......
......@@ -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 =========================================
......
......@@ -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() )
......
......@@ -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 );
......
......@@ -106,7 +106,7 @@
#include "anminfo.hxx"
#include "optsitem.hxx"
#include "Window.hxx"
#include "fuformatpaintbrush.hxx"
using ::rtl::OUString;
using namespace ::com::sun::star;
......@@ -202,14 +202,23 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
return;
if(HasCurrentFunction())
{
if( (nSId == SID_FORMATPAINTBRUSH) && (GetCurrentFunction()->GetSlotID() == SID_TEXTEDIT) )
{
// save text edit mode for format paintbrush!
SetOldFunction( GetCurrentFunction() );
}
else
{
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,6 +535,16 @@ 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;
}
......
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