diff options
Diffstat (limited to 'sc/source/ui/drawfunc')
31 files changed, 12444 insertions, 0 deletions
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx new file mode 100644 index 000000000000..77823a9b37d3 --- /dev/null +++ b/sc/source/ui/drawfunc/chartsh.cxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------ +#include <editeng/eeitem.hxx> +#include <svx/fontwork.hxx> +#include <svl/srchitem.hxx> +#include <svx/tabarea.hxx> +#include <svx/tabline.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/request.hxx> +#include <svl/whiter.hxx> +#include <vcl/msgbox.hxx> + +#include "chartsh.hxx" +#include "drwlayer.hxx" +#include "sc.hrc" +#include "viewdata.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "drawview.hxx" +#include "scresid.hxx" +#include <svx/svdobj.hxx> + +#define ScChartShell +#include "scslots.hxx" + + +SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell, ScResId(SCSTR_CHARTSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, + ScResId(RID_DRAW_OBJECTBAR) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_CHART) ); + //SFX_OBJECTMENU_REGISTRATION( SID_OBJECTMENU0, ScResId(RID_OBJECTMENU_DRAW) ); +} + +TYPEINIT1( ScChartShell, ScDrawShell ); + +ScChartShell::ScChartShell(ScViewData* pData) : + ScDrawShell(pData) +{ + SetHelpId(HID_SCSHELL_CHARTSH); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ChartObject"))); +} + +ScChartShell::~ScChartShell() +{ +} + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx new file mode 100644 index 000000000000..5da044f24d89 --- /dev/null +++ b/sc/source/ui/drawfunc/drawsh.cxx @@ -0,0 +1,485 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> + +#include "scitems.hxx" + +#include <editeng/eeitem.hxx> +#include <svx/fontwork.hxx> +#include <svl/srchitem.hxx> +#include <svx/tabarea.hxx> +#include <svx/tabline.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <sfx2/dispatch.hxx> +#include <svl/whiter.hxx> +#include <vcl/msgbox.hxx> + +#include "drawsh.hxx" +#include "drwlayer.hxx" +#include "sc.hrc" +#include "viewdata.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "drawview.hxx" +#include "scresid.hxx" +#include <svx/svdobj.hxx> +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include <svx/drawitem.hxx> +#include <svx/xtable.hxx> + +#define ScDrawShell +#include "scslots.hxx" + +#include "userdat.hxx" +#include <sfx2/objsh.hxx> +#include <svl/macitem.hxx> +#include <sfx2/evntconf.hxx> +#include <sfx2/viewsh.hxx> +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/frame/XFrame.hpp> + +//------------------------------------------------------------------ + +TYPEINIT1( ScDrawShell, SfxShell ); + +SFX_IMPL_INTERFACE(ScDrawShell, SfxShell, ScResId(SCSTR_DRAWSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, + ScResId(RID_DRAW_OBJECTBAR) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAW) ); + SFX_CHILDWINDOW_REGISTRATION( SvxFontWorkChildWindow::GetChildWindowId() ); +} + + +// abschalten der nicht erwuenschten Acceleratoren: + +void ScDrawShell::StateDisableItems( SfxItemSet &rSet ) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + +void lcl_setModified( SfxObjectShell* pShell ) +{ + if ( pShell ) + { + com::sun::star::uno::Reference< com::sun::star::util::XModifiable > xModif( pShell->GetModel(), com::sun::star::uno::UNO_QUERY ); + if ( xModif.is() ) + xModif->setModified( sal_True ); + } +} + +void ScDrawShell::ExecDrawAttr( SfxRequest& rReq ) +{ + USHORT nSlot = rReq.GetSlot(); + Window* pWin = pViewData->GetActiveWin(); +// SfxViewFrame* pViewFrame = SfxViewShell::Current()->GetViewFrame(); //!!! koennte knallen + ScDrawView* pView = pViewData->GetScDrawView(); + SdrModel* pDoc = pViewData->GetDocument()->GetDrawLayer(); + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + ULONG nMarkCount = rMarkList.GetMarkCount(); + SdrObject* pSingleSelectedObj = NULL; + if ( nMarkCount > 0 ) + pSingleSelectedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + switch ( nSlot ) + { + case SID_ASSIGNMACRO: + { + if ( pSingleSelectedObj ) + ExecuteMacroAssign( pSingleSelectedObj, pWin ); + } + break; + + case SID_TEXT_STANDARD: // Harte Textattributierung loeschen + { + SfxItemSet aEmptyAttr(GetPool(), EE_ITEMS_START, EE_ITEMS_END); + pView->SetAttributes(aEmptyAttr, TRUE); + } + break; + + case SID_ATTR_LINE_STYLE: + case SID_ATTR_LINEEND_STYLE: + case SID_ATTR_LINE_DASH: + case SID_ATTR_LINE_WIDTH: + case SID_ATTR_LINE_COLOR: + case SID_ATTR_FILL_STYLE: + case SID_ATTR_FILL_COLOR: + case SID_ATTR_FILL_GRADIENT: + case SID_ATTR_FILL_HATCH: + case SID_ATTR_FILL_BITMAP: + + // #i25616# + case SID_ATTR_FILL_SHADOW: + { + // Wenn ToolBar vertikal : + if ( !rReq.GetArgs() ) + { + switch ( nSlot ) + { + case SID_ATTR_LINE_STYLE: + case SID_ATTR_LINE_DASH: + case SID_ATTR_LINE_WIDTH: + case SID_ATTR_LINE_COLOR: + ExecuteLineDlg( rReq ); + break; + + case SID_ATTR_FILL_STYLE: + case SID_ATTR_FILL_COLOR: + case SID_ATTR_FILL_GRADIENT: + case SID_ATTR_FILL_HATCH: + case SID_ATTR_FILL_BITMAP: + + // #i25616# + case SID_ATTR_FILL_SHADOW: + + ExecuteAreaDlg( rReq ); + break; + + default: + break; + } + + //===== + return; + //===== + } + + if( pView->AreObjectsMarked() ) + pView->SetAttrToMarked( *rReq.GetArgs(), FALSE ); + else + pView->SetDefaultAttr( *rReq.GetArgs(), FALSE); + pView->InvalidateAttribs(); + } + break; + + case SID_ATTRIBUTES_LINE: + ExecuteLineDlg( rReq ); + break; + + case SID_ATTRIBUTES_AREA: + ExecuteAreaDlg( rReq ); + break; + + case SID_DRAWTEXT_ATTR_DLG: + ExecuteTextAttrDlg( rReq ); + break; + + case SID_DRAW_HLINK_EDIT: + if ( pSingleSelectedObj ) + pViewData->GetDispatcher().Execute( SID_HYPERLINK_DIALOG ); + break; + + case SID_DRAW_HLINK_DELETE: + if ( pSingleSelectedObj ) + SetHlinkForObject( pSingleSelectedObj, rtl::OUString() ); + break; + + case SID_OPEN_HYPERLINK: + if ( nMarkCount == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if ( pObj->IsGroupObject() ) + { + SdrPageView* pPV = 0; + SdrObject* pHit = 0; + if ( pView->PickObj( pWin->PixelToLogic( pViewData->GetMousePosPixel() ), pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) ) + pObj = pHit; + } + + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); + if ( pInfo && (pInfo->GetHlink().getLength() > 0) ) + ScGlobal::OpenURL( pInfo->GetHlink(), String::EmptyString() ); + } + break; + + case SID_ATTR_TRANSFORM: + { + if ( pView->AreObjectsMarked() ) + { + const SfxItemSet* pArgs = rReq.GetArgs(); + + if( !pArgs ) + { + // const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( rMarkList.GetMark(0) != 0 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if( pObj->GetObjIdentifier() == OBJ_CAPTION ) + { + // --------- Itemset fuer Caption -------- + SfxItemSet aNewAttr(pDoc->GetItemPool()); + pView->GetAttributes(aNewAttr); + // --------- Itemset fuer Groesse und Position -------- + SfxItemSet aNewGeoAttr(pView->GetGeoAttrFromMarked()); + + //SvxCaptionTabDialog* pDlg = new SvxCaptionTabDialog(pWin, pView); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if ( pFact ) + { + SfxAbstractTabDialog *pDlg = pFact->CreateCaptionDialog( pWin, pView ); + + const USHORT* pRange = pDlg->GetInputRanges( *aNewAttr.GetPool() ); + SfxItemSet aCombSet( *aNewAttr.GetPool(), pRange ); + aCombSet.Put( aNewAttr ); + aCombSet.Put( aNewGeoAttr ); + pDlg->SetInputSet( &aCombSet ); + + if (pDlg->Execute() == RET_OK) + { + rReq.Done(*(pDlg->GetOutputItemSet())); + pView->SetAttributes(*pDlg->GetOutputItemSet()); + pView->SetGeoAttrToMarked(*pDlg->GetOutputItemSet()); + } + + delete pDlg; + } + } + else + { + SfxItemSet aNewAttr(pView->GetGeoAttrFromMarked()); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + if(pFact) + { + SfxAbstractTabDialog* pDlg = pFact->CreateSvxTransformTabDialog( pWin, &aNewAttr,pView ); + DBG_ASSERT(pDlg, "Dialog creation failed!"); + if (pDlg->Execute() == RET_OK) + { + rReq.Done(*(pDlg->GetOutputItemSet())); + pView->SetGeoAttrToMarked(*pDlg->GetOutputItemSet()); + } + delete pDlg; + } + } + } + + + } + else + pView->SetGeoAttrToMarked( *pArgs ); + } + } + break; + + default: + break; + } +} + +void ScDrawShell::ExecuteMacroAssign( SdrObject* pObj, Window* pWin ) +{ + SvxMacroItem aItem ( SFX_APP()->GetPool().GetWhich( SID_ATTR_MACROITEM ) ); + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE ); + if ( pInfo->GetMacro().getLength() > 0 ) + { + SvxMacroTableDtor aTab; + String sMacro( pInfo->GetMacro() ); + aTab.Insert( SFX_EVENT_MOUSECLICK_OBJECT, new SvxMacro( sMacro, String() ) ); + aItem.SetMacroTable( aTab ); + } + + // create empty itemset for macro-dlg + SfxItemSet* pItemSet = new SfxItemSet(SFX_APP()->GetPool(), SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 ); + pItemSet->Put ( aItem, SID_ATTR_MACROITEM ); + + SfxEventNamesItem aNamesItem(SID_EVENTCONFIG); + aNamesItem.AddEvent( ScResId(RID_SCSTR_ONCLICK), String(), SFX_EVENT_MOUSECLICK_OBJECT ); + pItemSet->Put( aNamesItem, SID_EVENTCONFIG ); + + com::sun::star::uno::Reference < com::sun::star::frame::XFrame > xFrame; + if (GetViewShell()) + xFrame = GetViewShell()->GetViewFrame()->GetFrame().GetFrameInterface(); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( pWin, *pItemSet, xFrame, SID_EVENTCONFIG ); + if ( pMacroDlg && pMacroDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutSet = pMacroDlg->GetOutputItemSet(); + const SfxPoolItem* pItem; + if( SFX_ITEM_SET == pOutSet->GetItemState( SID_ATTR_MACROITEM, FALSE, &pItem )) + { + rtl::OUString sMacro; + SvxMacro* pMacro = ((SvxMacroItem*)pItem)->GetMacroTable().Get( SFX_EVENT_MOUSECLICK_OBJECT ); + if ( pMacro ) + sMacro = pMacro->GetMacName(); + + if ( pObj->IsGroupObject() ) + { + SdrObjList* pOL = pObj->GetSubList(); + ULONG nObj = pOL->GetObjCount(); + for ( ULONG index=0; index<nObj; ++index ) + { + pInfo = ScDrawLayer::GetMacroInfo( pOL->GetObj(index), TRUE ); + pInfo->SetMacro( sMacro ); + } + } + else + pInfo->SetMacro( sMacro ); + lcl_setModified( GetObjectShell() ); + } + } + + delete pMacroDlg; + delete pItemSet; +} + +void ScDrawShell::ExecuteLineDlg( SfxRequest& rReq, USHORT nTabPage ) +{ + ScDrawView* pView = pViewData->GetScDrawView(); + BOOL bHasMarked = pView->AreObjectsMarked(); + const SdrObject* pObj = NULL; + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + + if( rMarkList.GetMarkCount() == 1 ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + SfxItemSet aNewAttr( pView->GetDefaultAttr() ); + if( bHasMarked ) + pView->MergeAttrFromMarked( aNewAttr, FALSE ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); + SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( pViewData->GetDialogParent(), + &aNewAttr, + pViewData->GetDocument()->GetDrawLayer(), + pObj, + bHasMarked); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + if ( nTabPage != 0xffff ) + pDlg->SetCurPageId( nTabPage ); + + if ( pDlg->Execute() == RET_OK ) + { + if( bHasMarked ) + pView->SetAttrToMarked( *pDlg->GetOutputItemSet(), FALSE ); + else + pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), FALSE ); + + pView->InvalidateAttribs(); + rReq.Done(); + } + + delete pDlg; +} + +void ScDrawShell::ExecuteAreaDlg( SfxRequest& rReq, USHORT nTabPage ) +{ + ScDrawView* pView = pViewData->GetScDrawView(); + BOOL bHasMarked = pView->AreObjectsMarked(); + + SfxItemSet aNewAttr( pView->GetDefaultAttr() ); + if( bHasMarked ) + pView->MergeAttrFromMarked( aNewAttr, FALSE ); + + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); + AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( pViewData->GetDialogParent(), + &aNewAttr, + pViewData->GetDocument()->GetDrawLayer(), + pView); + DBG_ASSERT(pDlg, "Dialogdiet fail!"); + + // #i74099# by default, the dialog deletes the current color table if a different one is loaded + // (see SwDrawShell::ExecDrawDlg) + const SvxColorTableItem* pColorItem = + static_cast<const SvxColorTableItem*>( pViewData->GetSfxDocShell()->GetItem(SID_COLOR_TABLE) ); + if (pColorItem->GetColorTable() == XColorTable::GetStdColorTable()) + pDlg->DontDeleteColorTable(); + + if ( nTabPage != 0xffff ) + pDlg->SetCurPageId( nTabPage ); + + if ( pDlg->Execute() == RET_OK ) + { + if( bHasMarked ) + pView->SetAttrToMarked( *pDlg->GetOutputItemSet(), FALSE ); + else + pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), FALSE ); + + pView->InvalidateAttribs(); + rReq.Done(); + } + + delete pDlg; +} + +void ScDrawShell::ExecuteTextAttrDlg( SfxRequest& rReq, USHORT /* nTabPage */ ) +{ + ScDrawView* pView = pViewData->GetScDrawView(); + BOOL bHasMarked = pView->AreObjectsMarked(); + SfxItemSet aNewAttr ( pView->GetDefaultAttr() ); + + if( bHasMarked ) + pView->MergeAttrFromMarked( aNewAttr, FALSE ); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aNewAttr, pView ); + + USHORT nResult = pDlg->Execute(); + + if ( RET_OK == nResult ) + { + if ( bHasMarked ) + pView->SetAttributes( *pDlg->GetOutputItemSet() ); + else + pView->SetDefaultAttr( *pDlg->GetOutputItemSet(), FALSE ); + + pView->InvalidateAttribs(); + rReq.Done(); + } + delete( pDlg ); +} + +void ScDrawShell::SetHlinkForObject( SdrObject* pObj, const rtl::OUString& rHlnk ) +{ + if ( pObj ) + { + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE ); + pInfo->SetHlink( rHlnk ); + lcl_setModified( GetObjectShell() ); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drawsh2.cxx b/sc/source/ui/drawfunc/drawsh2.cxx new file mode 100644 index 000000000000..0a5b5ad7c21f --- /dev/null +++ b/sc/source/ui/drawfunc/drawsh2.cxx @@ -0,0 +1,397 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +//------------------------------------------------------------------ +#include <com/sun/star/embed/EmbedMisc.hpp> + +#include "scitems.hxx" +#include <editeng/eeitem.hxx> +#include <editeng/sizeitem.hxx> +#include <svx/svdpagv.hxx> +#include <svx/xdef.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewfrm.hxx> +#include <svl/ptitem.hxx> +#include <svl/whiter.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdouno.hxx> +#include <svx/extrusionbar.hxx> +#include <svx/fontworkbar.hxx> + +#include "drawsh.hxx" +#include "drawview.hxx" +#include "viewdata.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "drwlayer.hxx" +#include "userdat.hxx" +#include <svx/svdoole2.hxx> +#include <svx/svdocapt.hxx> + +USHORT ScGetFontWorkId(); // in drtxtob + +using namespace com::sun::star; + +//------------------------------------------------------------------ + +ScDrawShell::ScDrawShell( ScViewData* pData ) : + SfxShell(pData->GetViewShell()), + pViewData( pData ) +{ + SetPool( &pViewData->GetScDrawView()->GetModel()->GetItemPool() ); + SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager(); + SetUndoManager( pMgr ); + if ( !pViewData->GetDocument()->IsUndoEnabled() ) + { + pMgr->SetMaxUndoActionCount( 0 ); + } + SetHelpId( HID_SCSHELL_DRAWSH ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("Drawing"))); +} + +ScDrawShell::~ScDrawShell() +{ +} + +void ScDrawShell::GetState( SfxItemSet& rSet ) // Zustaende / Toggles +{ + ScDrawView* pView = pViewData->GetScDrawView(); + SdrDragMode eMode = pView->GetDragMode(); + + rSet.Put( SfxBoolItem( SID_OBJECT_ROTATE, eMode == SDRDRAG_ROTATE ) ); + rSet.Put( SfxBoolItem( SID_OBJECT_MIRROR, eMode == SDRDRAG_MIRROR ) ); + rSet.Put( SfxBoolItem( SID_BEZIER_EDIT, !pView->IsFrameDragSingles() ) ); + + USHORT nFWId = ScGetFontWorkId(); + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + rSet.Put(SfxBoolItem(SID_FONTWORK, pViewFrm->HasChildWindow(nFWId))); + + // Notes always default to Page anchor. + bool bDisableAnchor = false; + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + ULONG nMarkCount = rMarkList.GetMarkCount(); + if ( nMarkCount == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if( ScDrawLayer::IsNoteCaption( pObj ) ) + { + bDisableAnchor = true; + rSet.DisableItem( SID_ANCHOR_PAGE ); + rSet.DisableItem( SID_ANCHOR_CELL ); + } + } + + if ( !bDisableAnchor ) + { + switch( pView->GetAnchor() ) + { + case SCA_PAGE: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, TRUE ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, FALSE ) ); + break; + + case SCA_CELL: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, FALSE ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, TRUE ) ); + break; + + default: + rSet.Put( SfxBoolItem( SID_ANCHOR_PAGE, FALSE ) ); + rSet.Put( SfxBoolItem( SID_ANCHOR_CELL, FALSE ) ); + break; + } + } +} + +void ScDrawShell::GetDrawFuncState( SfxItemSet& rSet ) // Funktionen disablen +{ + ScDrawView* pView = pViewData->GetScDrawView(); + + // #111711# call IsMirrorAllowed first to make sure ForcePossibilities (and thus CheckMarked) + // is called before GetMarkCount, so the nMarkCount value is valid for the rest of this method. + if (!pView->IsMirrorAllowed(TRUE,TRUE)) + { + rSet.DisableItem( SID_MIRROR_HORIZONTAL ); + rSet.DisableItem( SID_MIRROR_VERTICAL ); + } + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + ULONG nMarkCount = rMarkList.GetMarkCount(); + + if ( nMarkCount <= 1 || !pView->IsGroupPossible() ) + rSet.DisableItem( SID_GROUP ); + if ( nMarkCount == 0 || !pView->IsUnGroupPossible() ) + rSet.DisableItem( SID_UNGROUP ); + if ( nMarkCount != 1 || !pView->IsGroupEnterPossible() ) + rSet.DisableItem( SID_ENTER_GROUP ); + if ( !pView->IsGroupEntered() ) + rSet.DisableItem( SID_LEAVE_GROUP ); + + if ( nMarkCount <= 1 ) // nichts oder nur ein Objekt selektiert + { + // Ausrichtung + rSet.DisableItem( SID_OBJECT_ALIGN_LEFT ); // keine Ausrichtung an der Seite + rSet.DisableItem( SID_OBJECT_ALIGN_CENTER ); + rSet.DisableItem( SID_OBJECT_ALIGN_RIGHT ); + rSet.DisableItem( SID_OBJECT_ALIGN_UP ); + rSet.DisableItem( SID_OBJECT_ALIGN_MIDDLE ); + rSet.DisableItem( SID_OBJECT_ALIGN_DOWN ); + + // pseudo slots for Format menu + rSet.DisableItem( SID_ALIGN_ANY_LEFT ); + rSet.DisableItem( SID_ALIGN_ANY_HCENTER ); + rSet.DisableItem( SID_ALIGN_ANY_RIGHT ); + rSet.DisableItem( SID_ALIGN_ANY_TOP ); + rSet.DisableItem( SID_ALIGN_ANY_VCENTER ); + rSet.DisableItem( SID_ALIGN_ANY_BOTTOM ); + } + + // do not change layer of form controls + // #158385# #i83729# do not change layer of cell notes (on internal layer) + if ( !nMarkCount || pView->HasMarkedControl() || pView->HasMarkedInternal() ) + { + rSet.DisableItem( SID_OBJECT_HEAVEN ); + rSet.DisableItem( SID_OBJECT_HELL ); + } + else + { + if(AreAllObjectsOnLayer(SC_LAYER_FRONT,rMarkList)) + { + rSet.DisableItem( SID_OBJECT_HEAVEN ); + } + else if(AreAllObjectsOnLayer(SC_LAYER_BACK,rMarkList)) + { + rSet.DisableItem( SID_OBJECT_HELL ); + } + } + + BOOL bCanRename = FALSE; + if ( nMarkCount > 1 ) + { + // no hypelink options for a selected group + rSet.DisableItem( SID_DRAW_HLINK_EDIT ); + rSet.DisableItem( SID_DRAW_HLINK_DELETE ); + rSet.DisableItem( SID_OPEN_HYPERLINK ); + } + else if ( nMarkCount == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); + if ( !pInfo || (pInfo->GetHlink().getLength() == 0) ) + { + rSet.DisableItem( SID_DRAW_HLINK_DELETE ); + rSet.DisableItem( SID_OPEN_HYPERLINK ); + } + SdrLayerID nLayerID = pObj->GetLayer(); + if ( nLayerID != SC_LAYER_INTERN ) + bCanRename = TRUE; // #i51351# anything except internal objects can be renamed + + // #91929#; don't show original size entry if not possible + UINT16 nObjType = pObj->GetObjIdentifier(); + if ( nObjType == OBJ_OLE2 ) + { + SdrOle2Obj* pOleObj = static_cast<SdrOle2Obj*>(rMarkList.GetMark( 0 )->GetMarkedSdrObj()); + if (pOleObj->GetObjRef().is() && + ((pOleObj->GetObjRef()->getStatus( pOleObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) ) ) + //TODO/LATER: why different slots in Draw and Calc? + rSet.DisableItem(SID_ORIGINALSIZE); + } + else if ( nObjType == OBJ_CAPTION ) + { + if ( nLayerID == SC_LAYER_INTERN ) + { + // SdrCaptionObj() Notes cannot be cut/copy in isolation from + // their cells. + rSet.DisableItem( SID_CUT ); + rSet.DisableItem( SID_COPY ); + // Notes always default to Page anchor. + rSet.DisableItem( SID_ANCHOR_TOGGLE ); + } + } + } + if ( !bCanRename ) + { + // #i68101# + rSet.DisableItem( SID_RENAME_OBJECT ); + rSet.DisableItem( SID_TITLE_DESCRIPTION_OBJECT ); + } + + if ( !nMarkCount ) // nichts selektiert + { + // Anordnung + rSet.DisableItem( SID_FRAME_UP ); + rSet.DisableItem( SID_FRAME_DOWN ); + rSet.DisableItem( SID_FRAME_TO_TOP ); + rSet.DisableItem( SID_FRAME_TO_BOTTOM ); + // Clipboard / loeschen + rSet.DisableItem( SID_DELETE ); + rSet.DisableItem( SID_DELETE_CONTENTS ); + rSet.DisableItem( SID_CUT ); + rSet.DisableItem( SID_COPY ); + // sonstiges + rSet.DisableItem( SID_ANCHOR_TOGGLE ); + rSet.DisableItem( SID_ORIGINALSIZE ); + rSet.DisableItem( SID_ATTR_TRANSFORM ); + } + + if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN ) + { + SfxItemSet aAttrs( pView->GetModel()->GetItemPool() ); + pView->GetAttributes( aAttrs ); + if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE ) + { + BOOL bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue(); + rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) ); + } + } + + svx::ExtrusionBar::getState( pView, rSet ); + svx::FontworkBar::getState( pView, rSet ); +} + +// +// Attribute fuer Drawing-Objekte +// + +void ScDrawShell::GetDrawAttrState( SfxItemSet& rSet ) +{ + Point aMousePos = pViewData->GetMousePosPixel(); + Window* pWindow = pViewData->GetActiveWin(); + ScDrawView* pDrView = pViewData->GetScDrawView(); + Point aPos = pWindow->PixelToLogic(aMousePos); + BOOL bHasMarked = pDrView->AreObjectsMarked(); + + if( bHasMarked ) + { + rSet.Put( pDrView->GetAttrFromMarked(FALSE) ); + + // Wenn die View selektierte Objekte besitzt, muessen entspr. Items + // von SFX_ITEM_DEFAULT (_ON) auf SFX_ITEM_DISABLED geaendert werden + + SfxWhichIter aIter( rSet, XATTR_LINE_FIRST, XATTR_FILL_LAST ); + USHORT nWhich = aIter.FirstWhich(); + while( nWhich ) + { + if( SFX_ITEM_DEFAULT == rSet.GetItemState( nWhich ) ) + rSet.DisableItem( nWhich ); + + nWhich = aIter.NextWhich(); + } + } + else + rSet.Put( pDrView->GetDefaultAttr() ); + + SdrPageView* pPV = pDrView->GetSdrPageView(); + if ( pPV ) + { + // #i52073# when a sheet with an active OLE object is deleted, + // the slot state is queried without an active page view + + // Items for position and size (see ScGridWindow::UpdateStatusPosSize, #108137#) + + // #i34458# The SvxSizeItem in SID_TABLE_CELL is no longer needed by + // SvxPosSizeStatusBarControl, it's enough to have it in SID_ATTR_SIZE. + + BOOL bActionItem = FALSE; + if ( pDrView->IsAction() ) // action rectangle + { + Rectangle aRect; + pDrView->TakeActionRect( aRect ); + if ( !aRect.IsEmpty() ) + { + pPV->LogicToPagePos(aRect); + rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); + Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); + rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) ); + bActionItem = TRUE; + } + } + if ( !bActionItem ) + { + if ( pDrView->AreObjectsMarked() ) // selected objects + { + Rectangle aRect = pDrView->GetAllMarkedRect(); + pPV->LogicToPagePos(aRect); + rSet.Put( SfxPointItem( SID_ATTR_POSITION, aRect.TopLeft() ) ); + Size aSize( aRect.Right() - aRect.Left(), aRect.Bottom() - aRect.Top() ); + rSet.Put( SvxSizeItem( SID_ATTR_SIZE, aSize ) ); + } + else // mouse position + { + // aPos is initialized above + pPV->LogicToPagePos(aPos); + rSet.Put( SfxPointItem( SID_ATTR_POSITION, aPos ) ); + rSet.Put( SvxSizeItem( SID_ATTR_SIZE, Size( 0, 0 ) ) ); + } + } + } +} + +void ScDrawShell::GetAttrFuncState(SfxItemSet &rSet) +{ + // Dialoge fuer Draw-Attribute disablen, wenn noetig + + ScDrawView* pDrView = pViewData->GetScDrawView(); + SfxItemSet aViewSet = pDrView->GetAttrFromMarked(FALSE); + + if ( aViewSet.GetItemState( XATTR_LINESTYLE ) == SFX_ITEM_DEFAULT ) + { + rSet.DisableItem( SID_ATTRIBUTES_LINE ); + rSet.DisableItem( SID_ATTR_LINEEND_STYLE ); // Tbx-Controller + } + + if ( aViewSet.GetItemState( XATTR_FILLSTYLE ) == SFX_ITEM_DEFAULT ) + rSet.DisableItem( SID_ATTRIBUTES_AREA ); +} + +BOOL ScDrawShell::AreAllObjectsOnLayer(USHORT nLayerNo,const SdrMarkList& rMark) +{ + BOOL bResult=TRUE; + ULONG nCount = rMark.GetMarkCount(); + for (ULONG i=0; i<nCount; i++) + { + SdrObject* pObj = rMark.GetMark(i)->GetMarkedSdrObj(); + if ( !pObj->ISA(SdrUnoObj) ) + { + if(nLayerNo!=pObj->GetLayer()) + { + bResult=FALSE; + break; + } + } + } + return bResult; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drawsh4.cxx b/sc/source/ui/drawfunc/drawsh4.cxx new file mode 100644 index 000000000000..fe432103a912 --- /dev/null +++ b/sc/source/ui/drawfunc/drawsh4.cxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------ + +#include "scitems.hxx" +#include <svx/drawitem.hxx> +#include <svx/fontwork.hxx> +#include <svx/svdotext.hxx> +#include <svx/xdef.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/viewfrm.hxx> + +#include "drawsh.hxx" +#include "drawview.hxx" +#include "viewdata.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" + + +//------------------------------------------------------------------ + +void ScDrawShell::GetFormTextState(SfxItemSet& rSet) +{ + const SdrObject* pObj = NULL; + SvxFontWorkDialog* pDlg = NULL; + ScDrawView* pDrView = pViewData->GetScDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + if ( pViewFrm->HasChildWindow(nId) ) + pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow()); + + if ( rMarkList.GetMarkCount() == 1 ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + if ( pObj == NULL || !pObj->ISA(SdrTextObj) || + !((SdrTextObj*) pObj)->HasText() ) + { + if ( pDlg ) + pDlg->SetActive(FALSE); + + rSet.DisableItem(XATTR_FORMTXTSTYLE); + rSet.DisableItem(XATTR_FORMTXTADJUST); + rSet.DisableItem(XATTR_FORMTXTDISTANCE); + rSet.DisableItem(XATTR_FORMTXTSTART); + rSet.DisableItem(XATTR_FORMTXTMIRROR); + rSet.DisableItem(XATTR_FORMTXTSTDFORM); + rSet.DisableItem(XATTR_FORMTXTHIDEFORM); + rSet.DisableItem(XATTR_FORMTXTOUTLINE); + rSet.DisableItem(XATTR_FORMTXTSHADOW); + rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR); + rSet.DisableItem(XATTR_FORMTXTSHDWXVAL); + rSet.DisableItem(XATTR_FORMTXTSHDWYVAL); + } + else + { + if ( pDlg ) + { + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + + if ( pDocSh ) + { + const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); + XColorTable* pColorTable = NULL; + + if ( pItem ) + pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); + + pDlg->SetActive(); + + if ( pColorTable ) + pDlg->SetColorTable( pColorTable ); + else + { DBG_ERROR( "ColorList not found :-/" ); } + } + } + SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool()); + pDrView->GetAttributes(aViewAttr); + rSet.Set(aViewAttr); + } +} + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drawsh5.cxx b/sc/source/ui/drawfunc/drawsh5.cxx new file mode 100644 index 000000000000..6db7faf051a5 --- /dev/null +++ b/sc/source/ui/drawfunc/drawsh5.cxx @@ -0,0 +1,752 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------ + +#include <editeng/eeitem.hxx> + +#include <sfx2/viewfrm.hxx> +#include <sfx2/request.hxx> +#include <sfx2/bindings.hxx> +#include <tools/urlobj.hxx> +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include <svx/fmglob.hxx> +#include <svx/hlnkitem.hxx> +#include <svx/fontwork.hxx> +#include <svx/svdocapt.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdundo.hxx> +#include <svx/xdef.hxx> +#include <svx/xftsfit.hxx> +#include <vcl/msgbox.hxx> +#include <svx/extrusionbar.hxx> +#include <svx/fontworkbar.hxx> +#include <sfx2/docfile.hxx> + +#include <com/sun/star/form/FormButtonType.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/awt/XControlModel.hpp> + +#include "drawsh.hxx" +#include "drawview.hxx" +#include "viewdata.hxx" +#include "tabvwsh.hxx" +#include "docsh.hxx" +#include "scresid.hxx" +#include "undotab.hxx" +#include "drwlayer.hxx" +#include "userdat.hxx" +#include "postit.hxx" + +#include "sc.hrc" + +using namespace com::sun::star; + +//------------------------------------------------------------------ + +void ScDrawShell::GetHLinkState( SfxItemSet& rSet ) // Hyperlink +{ + ScDrawView* pView = pViewData->GetScDrawView(); + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + ULONG nMarkCount = rMarkList.GetMarkCount(); + + // Hyperlink + + SvxHyperlinkItem aHLinkItem; + + if ( nMarkCount == 1 ) // URL-Button markiert ? + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj ); + if ( pInfo && (pInfo->GetHlink().getLength() > 0) ) + { + aHLinkItem.SetURL( pInfo->GetHlink() ); + aHLinkItem.SetInsertMode(HLINK_FIELD); + } + SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj); + if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) + { + uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel(); + DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); + if( !xControlModel.is() ) + return; + + uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); + + rtl::OUString sPropButtonType(RTL_CONSTASCII_USTRINGPARAM( "ButtonType" )); + rtl::OUString sPropTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )); + rtl::OUString sPropTargetFrame(RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )); + rtl::OUString sPropLabel(RTL_CONSTASCII_USTRINGPARAM( "Label" )); + + if(xInfo->hasPropertyByName( sPropButtonType )) + { + uno::Any aAny = xPropSet->getPropertyValue( sPropButtonType ); + form::FormButtonType eTmp; + if ( (aAny >>= eTmp) && eTmp == form::FormButtonType_URL ) + { + rtl::OUString sTmp; + // Label + if(xInfo->hasPropertyByName( sPropLabel )) + { + aAny = xPropSet->getPropertyValue( sPropLabel ); + if ( (aAny >>= sTmp) && sTmp.getLength() ) + { + aHLinkItem.SetName(sTmp); + } + } + // URL + if(xInfo->hasPropertyByName( sPropTargetURL )) + { + aAny = xPropSet->getPropertyValue( sPropTargetURL ); + if ( (aAny >>= sTmp) && sTmp.getLength() ) + { + aHLinkItem.SetURL(sTmp); + } + } + // Target + if(xInfo->hasPropertyByName( sPropTargetFrame )) + { + aAny = xPropSet->getPropertyValue( sPropTargetFrame ); + if ( (aAny >>= sTmp) && sTmp.getLength() ) + { + aHLinkItem.SetTargetFrame(sTmp); + } + } + aHLinkItem.SetInsertMode(HLINK_BUTTON); + } + } + } + } + + rSet.Put(aHLinkItem); +} + +void ScDrawShell::ExecuteHLink( SfxRequest& rReq ) +{ + const SfxItemSet* pReqArgs = rReq.GetArgs(); + + USHORT nSlot = rReq.GetSlot(); + switch ( nSlot ) + { + case SID_HYPERLINK_SETLINK: + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, TRUE, &pItem ) == SFX_ITEM_SET ) + { + const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; + const String& rName = pHyper->GetName(); + const String& rURL = pHyper->GetURL(); + const String& rTarget = pHyper->GetTargetFrame(); + SvxLinkInsertMode eMode = pHyper->GetInsertMode(); + + BOOL bDone = FALSE; + if ( eMode == HLINK_FIELD || eMode == HLINK_BUTTON ) + { + ScDrawView* pView = pViewData->GetScDrawView(); + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if ( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj ); + if (pUnoCtrl && FmFormInventor == pUnoCtrl->GetObjInventor()) + { + uno::Reference<awt::XControlModel> xControlModel = + pUnoCtrl->GetUnoControlModel(); + DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); + if( !xControlModel.is() ) + return; + + uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySetInfo > xInfo = xPropSet->getPropertySetInfo(); + + rtl::OUString sPropTargetURL(RTL_CONSTASCII_USTRINGPARAM( "TargetURL" )); + + // Darf man eine URL an dem Objekt setzen? + if (xInfo->hasPropertyByName( sPropTargetURL )) + { + // Ja! + + rtl::OUString sPropButtonType(RTL_CONSTASCII_USTRINGPARAM( "ButtonType") ); + rtl::OUString sPropTargetFrame(RTL_CONSTASCII_USTRINGPARAM( "TargetFrame" )); + rtl::OUString sPropLabel(RTL_CONSTASCII_USTRINGPARAM( "Label" )); + + uno::Any aAny; + if ( xInfo->hasPropertyByName( sPropLabel ) ) + { + aAny <<= rtl::OUString(rName); + xPropSet->setPropertyValue( sPropLabel, aAny ); + } + + ::rtl::OUString aTmp = INetURLObject::GetAbsURL( pViewData->GetDocShell()->GetMedium()->GetBaseURL(), rURL ); + aAny <<= aTmp; + xPropSet->setPropertyValue( sPropTargetURL, aAny ); + + if( rTarget.Len() && xInfo->hasPropertyByName( sPropTargetFrame ) ) + { + aAny <<= rtl::OUString(rTarget); + xPropSet->setPropertyValue( sPropTargetFrame, aAny ); + } + + if ( xInfo->hasPropertyByName( sPropButtonType ) ) + { + form::FormButtonType eButtonType = form::FormButtonType_URL; + aAny <<= eButtonType; + xPropSet->setPropertyValue( sPropButtonType, aAny ); + } + + //! Undo ??? + pViewData->GetDocShell()->SetDocumentModified(); + bDone = TRUE; + } + } + else + { + SetHlinkForObject( pObj, rURL ); + bDone = TRUE; + } + } + } + + if (!bDone) + pViewData->GetViewShell()-> + InsertURL( rName, rURL, rTarget, (USHORT) eMode ); + + // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!! + } + } + break; + default: + DBG_ERROR("falscher Slot"); + } +} + +USHORT ScGetFontWorkId(); // wegen CLOOKs - in drtxtob2 + +//------------------------------------------------------------------ + +// +// Funktionen auf Drawing-Objekten +// + +void ScDrawShell::ExecDrawFunc( SfxRequest& rReq ) +{ + SfxBindings& rBindings = pViewData->GetBindings(); + ScTabView* pTabView = pViewData->GetView(); + ScDrawView* pView = pTabView->GetScDrawView(); + const SfxItemSet *pArgs = rReq.GetArgs(); + USHORT nSlotId = rReq.GetSlot(); + + //!!! + // wer weiss, wie lange das funktioniert? (->vom Abreisscontrol funktioniert es) + // + if (nSlotId == SID_OBJECT_ALIGN && pArgs) + nSlotId = SID_OBJECT_ALIGN + ((SfxEnumItem&)pArgs->Get(SID_OBJECT_ALIGN)).GetValue() + 1; + + switch (nSlotId) + { + case SID_OBJECT_HEAVEN: + pView->SetMarkedToLayer( SC_LAYER_FRONT ); + rBindings.Invalidate(SID_OBJECT_HEAVEN); + rBindings.Invalidate(SID_OBJECT_HELL); + break; + case SID_OBJECT_HELL: + pView->SetMarkedToLayer( SC_LAYER_BACK ); + rBindings.Invalidate(SID_OBJECT_HEAVEN); + rBindings.Invalidate(SID_OBJECT_HELL); + // leave draw shell if nothing selected (layer may be locked) + if ( pView->GetMarkedObjectList().GetMarkCount() == 0 ) + pViewData->GetViewShell()->SetDrawShell( FALSE ); + break; + + case SID_FRAME_TO_TOP: + pView->PutMarkedToTop(); + break; + case SID_FRAME_TO_BOTTOM: + pView->PutMarkedToBtm(); + break; + case SID_FRAME_UP: + pView->MovMarkedToTop(); + break; + case SID_FRAME_DOWN: + pView->MovMarkedToBtm(); + break; + + case SID_GROUP: + pView->GroupMarked(); + break; + case SID_UNGROUP: + pView->UnGroupMarked(); + break; + case SID_ENTER_GROUP: + pView->EnterMarkedGroup(); + break; + case SID_LEAVE_GROUP: + pView->LeaveOneGroup(); + break; + + case SID_MIRROR_HORIZONTAL: + pView->MirrorAllMarkedHorizontal(); + break; + case SID_MIRROR_VERTICAL: + pView->MirrorAllMarkedVertical(); + break; + + case SID_OBJECT_ALIGN_LEFT: + case SID_ALIGN_ANY_LEFT: + if (pView->IsAlignPossible()) + pView->AlignMarkedObjects(SDRHALIGN_LEFT, SDRVALIGN_NONE); + break; + case SID_OBJECT_ALIGN_CENTER: + case SID_ALIGN_ANY_HCENTER: + if (pView->IsAlignPossible()) + pView->AlignMarkedObjects(SDRHALIGN_CENTER, SDRVALIGN_NONE); + break; + case SID_OBJECT_ALIGN_RIGHT: + case SID_ALIGN_ANY_RIGHT: + if (pView->IsAlignPossible()) + pView->AlignMarkedObjects(SDRHALIGN_RIGHT, SDRVALIGN_NONE); + break; + case SID_OBJECT_ALIGN_UP: + case SID_ALIGN_ANY_TOP: + if (pView->IsAlignPossible()) + pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_TOP); + break; + case SID_OBJECT_ALIGN_MIDDLE: + case SID_ALIGN_ANY_VCENTER: + if (pView->IsAlignPossible()) + pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_CENTER); + break; + case SID_OBJECT_ALIGN_DOWN: + case SID_ALIGN_ANY_BOTTOM: + if (pView->IsAlignPossible()) + pView->AlignMarkedObjects(SDRHALIGN_NONE, SDRVALIGN_BOTTOM); + break; + + case SID_DELETE: + case SID_DELETE_CONTENTS: + pView->DeleteMarked(); + if (!pTabView->IsDrawSelMode()) + pViewData->GetViewShell()->SetDrawShell( FALSE ); + break; + + case SID_CUT: + pView->DoCut(); + if (!pTabView->IsDrawSelMode()) + pViewData->GetViewShell()->SetDrawShell( FALSE ); + break; + + case SID_COPY: + pView->DoCopy(); + break; + + case SID_PASTE: + DBG_ERROR( "SdrView::PasteClipboard not supported anymore" ); + // pView->PasteClipboard( pWin ); + break; + + case SID_SELECTALL: + pView->MarkAll(); + break; + + case SID_ANCHOR_PAGE: + pView->SetAnchor( SCA_PAGE ); + rBindings.Invalidate( SID_ANCHOR_PAGE ); + rBindings.Invalidate( SID_ANCHOR_CELL ); + break; + + case SID_ANCHOR_CELL: + pView->SetAnchor( SCA_CELL ); + rBindings.Invalidate( SID_ANCHOR_PAGE ); + rBindings.Invalidate( SID_ANCHOR_CELL ); + break; + + case SID_ANCHOR_TOGGLE: + { + switch( pView->GetAnchor() ) + { + case SCA_CELL: + pView->SetAnchor( SCA_PAGE ); + break; + default: + pView->SetAnchor( SCA_CELL ); + break; + } + } + rBindings.Invalidate( SID_ANCHOR_PAGE ); + rBindings.Invalidate( SID_ANCHOR_CELL ); + break; + + case SID_OBJECT_ROTATE: + { + SdrDragMode eMode; + if (pView->GetDragMode() == SDRDRAG_ROTATE) + eMode = SDRDRAG_MOVE; + else + eMode = SDRDRAG_ROTATE; + pView->SetDragMode( eMode ); + rBindings.Invalidate( SID_OBJECT_ROTATE ); + rBindings.Invalidate( SID_OBJECT_MIRROR ); + if (eMode == SDRDRAG_ROTATE && !pView->IsFrameDragSingles()) + { + pView->SetFrameDragSingles( TRUE ); + rBindings.Invalidate( SID_BEZIER_EDIT ); + } + } + break; + case SID_OBJECT_MIRROR: + { + SdrDragMode eMode; + if (pView->GetDragMode() == SDRDRAG_MIRROR) + eMode = SDRDRAG_MOVE; + else + eMode = SDRDRAG_MIRROR; + pView->SetDragMode( eMode ); + rBindings.Invalidate( SID_OBJECT_ROTATE ); + rBindings.Invalidate( SID_OBJECT_MIRROR ); + if (eMode == SDRDRAG_MIRROR && !pView->IsFrameDragSingles()) + { + pView->SetFrameDragSingles( TRUE ); + rBindings.Invalidate( SID_BEZIER_EDIT ); + } + } + break; + case SID_BEZIER_EDIT: + { + BOOL bOld = pView->IsFrameDragSingles(); + pView->SetFrameDragSingles( !bOld ); + rBindings.Invalidate( SID_BEZIER_EDIT ); + if (bOld && pView->GetDragMode() != SDRDRAG_MOVE) + { + pView->SetDragMode( SDRDRAG_MOVE ); + rBindings.Invalidate( SID_OBJECT_ROTATE ); + rBindings.Invalidate( SID_OBJECT_MIRROR ); + } + } + break; + + case SID_FONTWORK: + { + USHORT nId = ScGetFontWorkId(); + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + + if ( rReq.GetArgs() ) + pViewFrm->SetChildWindow( nId, + ((const SfxBoolItem&) + (rReq.GetArgs()->Get(SID_FONTWORK))). + GetValue() ); + else + pViewFrm->ToggleChildWindow( nId ); + + rBindings.Invalidate( SID_FONTWORK ); + rReq.Done(); + } + break; + + case SID_ORIGINALSIZE: + pView->SetMarkedOriginalSize(); + break; + + case SID_ENABLE_HYPHENATION: + { + SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, FALSE); + if( pItem ) + { + SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE ); + BOOL bValue = ( (const SfxBoolItem*) pItem)->GetValue(); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); + pView->SetAttributes( aSet ); + } + rReq.Done(); + } + break; + + case SID_RENAME_OBJECT: + { + if(1L == pView->GetMarkedObjectCount()) + { + // #i68101# + SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L); + OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)"); + + if(SC_LAYER_INTERN != pSelected->GetLayer()) + { + String aName(pSelected->GetName()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + + pDlg->SetCheckNameHdl(LINK(this, ScDrawShell, NameObjectHdl)); + + if(RET_OK == pDlg->Execute()) + { + ScDocShell* pDocSh = pViewData->GetDocShell(); + pDlg->GetName(aName); + + if(aName != pSelected->GetName()) + { + // handle name change + const sal_uInt16 nObjType(pSelected->GetObjIdentifier()); + + if(OBJ_GRAF == nObjType && 0L == aName.Len()) + { + // graphics objects must have names + // (all graphics are supposed to be in the navigator) + ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer(); + + if(pModel) + { + aName = pModel->GetNewGraphicName(); + } + } + + // An undo action for renaming is missing in svdraw (99363). + // For OLE objects (which can be identified using the persist name), + // ScUndoRenameObject can be used until there is a common action for all objects. + if(OBJ_OLE2 == nObjType) + { + const String aPersistName = static_cast<SdrOle2Obj*>(pSelected)->GetPersistName(); + + if(aPersistName.Len()) + { + pDocSh->GetUndoManager()->AddUndoAction( + new ScUndoRenameObject(pDocSh, aPersistName, pSelected->GetName(), aName)); + } + } + + // set new name + pSelected->SetName(aName); + } + + // ChartListenerCollectionNeedsUpdate is needed for Navigator update + pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( TRUE ); + pDocSh->SetDrawModified(); + } + + delete pDlg; + } + } + break; + } + + // #i68101# + case SID_TITLE_DESCRIPTION_OBJECT: + { + if(1L == pView->GetMarkedObjectCount()) + { + SdrObject* pSelected = pView->GetMarkedObjectByIndex(0L); + OSL_ENSURE(pSelected, "ScDrawShell::ExecDrawFunc: nMarkCount, but no object (!)"); + + if(SC_LAYER_INTERN != pSelected->GetLayer()) + { + String aTitle(pSelected->GetTitle()); + String aDescription(pSelected->GetDescription()); + + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + OSL_ENSURE(pFact, "Dialogdiet fail!"); + AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription); + OSL_ENSURE(pDlg, "Dialogdiet fail!"); + + if(RET_OK == pDlg->Execute()) + { + ScDocShell* pDocSh = pViewData->GetDocShell(); + + // handle Title and Description + pDlg->GetTitle(aTitle); + pDlg->GetDescription(aDescription); + pSelected->SetTitle(aTitle); + pSelected->SetDescription(aDescription); + + // ChartListenerCollectionNeedsUpdate is needed for Navigator update + pDocSh->GetDocument()->SetChartListenerCollectionNeedsUpdate( TRUE ); + pDocSh->SetDrawModified(); + } + + delete pDlg; + } + } + break; + } + + case SID_EXTRUSION_TOOGLE: + case SID_EXTRUSION_TILT_DOWN: + case SID_EXTRUSION_TILT_UP: + case SID_EXTRUSION_TILT_LEFT: + case SID_EXTRUSION_TILT_RIGHT: + case SID_EXTRUSION_3D_COLOR: + case SID_EXTRUSION_DEPTH: + case SID_EXTRUSION_DIRECTION: + case SID_EXTRUSION_PROJECTION: + case SID_EXTRUSION_LIGHTING_DIRECTION: + case SID_EXTRUSION_LIGHTING_INTENSITY: + case SID_EXTRUSION_SURFACE: + case SID_EXTRUSION_DEPTH_FLOATER: + case SID_EXTRUSION_DIRECTION_FLOATER: + case SID_EXTRUSION_LIGHTING_FLOATER: + case SID_EXTRUSION_SURFACE_FLOATER: + case SID_EXTRUSION_DEPTH_DIALOG: + svx::ExtrusionBar::execute( pView, rReq, rBindings ); + rReq.Ignore (); + break; + + case SID_FONTWORK_SHAPE: + case SID_FONTWORK_SHAPE_TYPE: + case SID_FONTWORK_ALIGNMENT: + case SID_FONTWORK_SAME_LETTER_HEIGHTS: + case SID_FONTWORK_CHARACTER_SPACING: + case SID_FONTWORK_KERN_CHARACTER_PAIRS: + case SID_FONTWORK_CHARACTER_SPACING_FLOATER: + case SID_FONTWORK_ALIGNMENT_FLOATER: + case SID_FONTWORK_CHARACTER_SPACING_DIALOG: + svx::FontworkBar::execute( pView, rReq, rBindings ); + rReq.Ignore (); + break; + + default: + break; + } +} + +IMPL_LINK( ScDrawShell, NameObjectHdl, AbstractSvxNameDialog*, pDialog ) +{ + String aName; + + if( pDialog ) + pDialog->GetName( aName ); + + ScDrawLayer* pModel = pViewData->GetDocument()->GetDrawLayer(); + if ( aName.Len() && pModel ) + { + SCTAB nDummyTab; + if ( pModel->GetNamedObject( aName, 0, nDummyTab ) ) + { + // existing object found -> name invalid + return 0; + } + } + + return 1; // name is valid +} + +//------------------------------------------------------------------ + +void ScDrawShell::ExecFormText(SfxRequest& rReq) +{ + ScDrawView* pDrView = pViewData->GetScDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + + if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) + { + const SfxItemSet& rSet = *rReq.GetArgs(); + const SfxPoolItem* pItem; + + if ( pDrView->IsTextEdit() ) + pDrView->ScEndTextEdit(); + + if ( SFX_ITEM_SET == + rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem) + && XFTFORM_NONE != + ((const XFormTextStdFormItem*) pItem)->GetValue() ) + { + + USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*) + (pViewFrm-> + GetChildWindow(nId)->GetWindow()); + + pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(), + rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(), + ((const XFormTextStdFormItem*) pItem)-> + GetValue()); + } + else + pDrView->SetAttributes(rSet); + } +} + +//------------------------------------------------------------------ + +void ScDrawShell::ExecFormatPaintbrush( SfxRequest& rReq ) +{ + ScViewFunc* pView = pViewData->GetView(); + if ( pView->HasPaintBrush() ) + { + // cancel paintbrush mode + pView->ResetBrushDocument(); + } + else + { + BOOL bLock = FALSE; + const SfxItemSet *pArgs = rReq.GetArgs(); + if( pArgs && pArgs->Count() >= 1 ) + bLock = static_cast<const SfxBoolItem&>(pArgs->Get(SID_FORMATPAINTBRUSH)).GetValue(); + + ScDrawView* pDrawView = pViewData->GetScDrawView(); + if ( pDrawView && pDrawView->AreObjectsMarked() ) + { + BOOL bOnlyHardAttr = TRUE; + SfxItemSet* pItemSet = new SfxItemSet( pDrawView->GetAttrFromMarked(bOnlyHardAttr) ); + pView->SetDrawBrushSet( pItemSet, bLock ); + } + } +} + +void ScDrawShell::StateFormatPaintbrush( SfxItemSet& rSet ) +{ + ScDrawView* pDrawView = pViewData->GetScDrawView(); + BOOL bSelection = pDrawView && pDrawView->AreObjectsMarked(); + BOOL bHasPaintBrush = pViewData->GetView()->HasPaintBrush(); + + if ( !bHasPaintBrush && !bSelection ) + rSet.DisableItem( SID_FORMATPAINTBRUSH ); + else + rSet.Put( SfxBoolItem( SID_FORMATPAINTBRUSH, bHasPaintBrush ) ); +} + +ScDrawView* ScDrawShell::GetDrawView() +{ + return pViewData->GetView()->GetScDrawView(); +} + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drformsh.cxx b/sc/source/ui/drawfunc/drformsh.cxx new file mode 100644 index 000000000000..e9a986cac5f9 --- /dev/null +++ b/sc/source/ui/drawfunc/drformsh.cxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------ + +#include <editeng/eeitem.hxx> +#include <svx/fontwork.hxx> +#include <svl/srchitem.hxx> +#include <svx/tabarea.hxx> +#include <svx/tabline.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/request.hxx> +#include <svl/whiter.hxx> +#include <vcl/msgbox.hxx> + +#include "drformsh.hxx" +#include "drwlayer.hxx" +#include "sc.hrc" +#include "viewdata.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "drawview.hxx" +#include "scresid.hxx" +#include <svx/svdobj.hxx> + +#define ScDrawFormShell +#include "scslots.hxx" + + +SFX_IMPL_INTERFACE(ScDrawFormShell, ScDrawShell, ScResId(SCSTR_DRAWFORMSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, + ScResId(RID_OBJECTBAR_FORMAT) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWFORM) ); +} + +TYPEINIT1( ScDrawFormShell, ScDrawShell ); + +ScDrawFormShell::ScDrawFormShell(ScViewData* pData) : + ScDrawShell(pData) +{ + SetHelpId(HID_SCSHELL_DRAWFORMSH); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawForm"))); +} + +ScDrawFormShell::~ScDrawFormShell() +{ +} + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drformsh.src b/sc/source/ui/drawfunc/drformsh.src new file mode 100644 index 000000000000..751c2ea86db5 --- /dev/null +++ b/sc/source/ui/drawfunc/drformsh.src @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ + +#include "sc.hrc" +#include "submenu.hrc" +#include <svx/globlmn.hrc> + // + // Defines ------------------------------------------------------------------------------- + // +#define MN_LAYER\ + ToolBoxItem\ + {\ + Identifier = SID_FRAME_TO_TOP ; \ + HelpID = SID_FRAME_TO_TOP ; \ + };\ + ToolBoxItem\ + {\ + Identifier = SID_FRAME_TO_BOTTOM ; \ + HelpID = SID_FRAME_TO_BOTTOM ; \ + }; + +#define MN_RENAME_OBJECT \ + MenuItem\ + {\ + Identifier = SID_RENAME_OBJECT ; \ + HelpId = SID_RENAME_OBJECT ; \ + Text [ en-US ] = "Name...";\ + }; + +// #i68101# +#define MN_TITLE_DESCRIPTION_OBJECT \ + MenuItem\ + {\ + Identifier = SID_TITLE_DESCRIPTION_OBJECT; \ + HelpId = SID_TITLE_DESCRIPTION_OBJECT; \ + Text [ en-US ] = "Description...";\ + }; + +#define MN_ARRANGESUB \ + MenuItem\ + {\ + Identifier = SUBMENU_OBJARRANGE ; \ + HelpID = HID_SCMENU_OBJARRANGE ; \ + Text [ en-US ] = "~Arrange" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + ITEM_FORMAT_FRAME_TO_TOP\ + };\ + MenuItem\ + {\ + Identifier = SID_FRAME_UP ; \ + HelpId = SID_FRAME_UP ; \ + /* ### ACHTUNG: Neuer Text in Resource? W~eiter nach vorn : Weiter nach vorn */\ + Text [ en-US ] = "Bring ~Forward" ; \ + };\ + MenuItem\ + {\ + Identifier = SID_FRAME_DOWN ; \ + HelpId = SID_FRAME_DOWN ; \ + /* ### ACHTUNG: Neuer Text in Resource? Weiter ~nach hinten : Weiter nach hinten */\ + Text [ en-US ] = "Send Back~ward" ; \ + };\ + MenuItem\ + {\ + ITEM_FORMAT_FRAME_TO_BOTTOM\ + };\ + MenuItem { Separator = TRUE ; }; \ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_HEAVEN\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_HELL\ + };\ + };\ + };\ + }; + +#define MN_ANCHORSUB \ + MenuItem\ + {\ + Identifier = SUBMENU_ANCHOR ; \ + HelpID = HID_SCMENU_ANCHOR ; \ + Text [ en-US ] = "An~chor" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + RadioCheck = TRUE ; \ + Identifier = SID_ANCHOR_PAGE ; \ + HelpId = SID_ANCHOR_PAGE ; \ + Text [ en-US ] = "To P~age" ; \ + };\ + MenuItem\ + {\ + RadioCheck = TRUE ; \ + Identifier = SID_ANCHOR_CELL ; \ + HelpId = SID_ANCHOR_CELL ; \ + Text [ en-US ] = "To ~Cell" ; \ + };\ + };\ + };\ + }; + +#define MN_ALIGNSUB \ + MenuItem\ + {\ + Identifier = SID_OBJECT_ALIGN ; \ + HelpId = SID_OBJECT_ALIGN ; \ + Text [ en-US ] = "A~lignment" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_LEFT\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_CENTER\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_RIGHT\ + };\ + MenuItem\ + {\ + Separator = TRUE ; \ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_UP\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_MIDDLE\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_DOWN\ + };\ + };\ + };\ + }; + + + // Popup-Menues --------------------------------------------------------------------- + // +String RID_POPUP_DRAWFORM +{ + /* ### ACHTUNG: Neuer Text in Resource? Popup-Menü für Zeichenobjekte : Popup-Men³ f³r Zeichenobjekte */ + Text [ en-US ] = "Popup menu for form objects"; +}; + // + // Popup-Menue fuer (Uno-) Controls + // +Menu RID_POPUP_DRAWFORM +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MenuItem { ITEM_FORM_CONTROL_PROPERTIES }; + MenuItem { ITEM_FORM_PROPERTIES }; + MenuItem { ITEM_REPLACE_CONTROL }; + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + }; +}; diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx new file mode 100644 index 000000000000..aba4cfa8eabe --- /dev/null +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -0,0 +1,1076 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------------- + +#include <com/sun/star/linguistic2/XThesaurus.hpp> +#include <com/sun/star/lang/Locale.hpp> + +#include "scitems.hxx" + +#include <editeng/adjitem.hxx> +#include <svx/clipfmtitem.hxx> +#include <editeng/cntritem.hxx> +#include <editeng/crsditem.hxx> +#include <editeng/editeng.hxx> +#include <editeng/escpitem.hxx> +#include <editeng/flditem.hxx> +#include <editeng/fontitem.hxx> +#include <editeng/frmdiritem.hxx> +#include <svx/hlnkitem.hxx> +#include <editeng/lspcitem.hxx> +#include <svx/svdoutl.hxx> +#include <editeng/unolingu.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/postitem.hxx> +#include <editeng/scripttypeitem.hxx> +#include <editeng/shdditem.hxx> +#include <svl/srchitem.hxx> +#include <editeng/udlnitem.hxx> +#include <editeng/wghtitem.hxx> +#include <editeng/writingmodeitem.hxx> +#include <sfx2/app.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <sfx2/viewfrm.hxx> +#include <svtools/cliplistener.hxx> +#include <svtools/transfer.hxx> +#include <svl/whiter.hxx> +#include <svl/languageoptions.hxx> +#include <vcl/msgbox.hxx> + +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> + +#include "sc.hrc" +#include "globstr.hrc" +#include "scmod.hxx" +#include "drtxtob.hxx" +#include "fudraw.hxx" +#include "viewdata.hxx" +#include "document.hxx" +#include "drawview.hxx" +#include "viewutil.hxx" +#include "scresid.hxx" +#include "tabvwsh.hxx" + +#define ScDrawTextObjectBar +#include "scslots.hxx" + + +using namespace ::com::sun::star; + + +SFX_IMPL_INTERFACE( ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, + ScResId(RID_TEXT_TOOLBOX) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_DRAWTEXT) ); + SFX_CHILDWINDOW_REGISTRATION( ScGetFontWorkId() ); +} + +TYPEINIT1( ScDrawTextObjectBar, SfxShell ); + + + +// abschalten der nicht erwuenschten Acceleratoren: + +void ScDrawTextObjectBar::StateDisableItems( SfxItemSet &rSet ) +{ + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + +ScDrawTextObjectBar::ScDrawTextObjectBar(ScViewData* pData) : + SfxShell(pData->GetViewShell()), + pViewData(pData), + pClipEvtLstnr(NULL), + bPastePossible(FALSE) +{ + SetPool( pViewData->GetScDrawView()->GetDefaultAttr().GetPool() ); + + // UndoManager wird beim Umschalten in den Edit-Modus umgesetzt... + SfxUndoManager* pMgr = pViewData->GetSfxDocShell()->GetUndoManager(); + SetUndoManager( pMgr ); + if ( !pViewData->GetDocument()->IsUndoEnabled() ) + { + pMgr->SetMaxUndoActionCount( 0 ); + } + + SetHelpId( HID_SCSHELL_DRTXTOB ); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("DrawText"))); +} + +__EXPORT ScDrawTextObjectBar::~ScDrawTextObjectBar() +{ + if ( pClipEvtLstnr ) + { + pClipEvtLstnr->AddRemoveListener( pViewData->GetActiveWin(), FALSE ); + + // #122057# The listener may just now be waiting for the SolarMutex and call the link + // afterwards, in spite of RemoveListener. So the link has to be reset, too. + pClipEvtLstnr->ClearCallbackLink(); + + pClipEvtLstnr->release(); + } +} + +//======================================================================== +// +// Funktionen +// +//======================================================================== + +void __EXPORT ScDrawTextObjectBar::Execute( SfxRequest &rReq ) +{ + ScDrawView* pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + Outliner* pOutliner = pView->GetTextEditOutliner(); + + if (!pOutView || !pOutliner) + { + ExecuteGlobal( rReq ); // auf ganze Objekte + return; + } + + const SfxItemSet* pReqArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + switch ( nSlot ) + { + case SID_COPY: + pOutView->Copy(); + break; + + case SID_CUT: + pOutView->Cut(); + break; + + case SID_PASTE: + pOutView->PasteSpecial(); + break; + + case SID_CLIPBOARD_FORMAT_ITEMS: + { + ULONG nFormat = 0; + const SfxPoolItem* pItem; + if ( pReqArgs && + pReqArgs->GetItemState(nSlot, TRUE, &pItem) == SFX_ITEM_SET && + pItem->ISA(SfxUInt32Item) ) + { + nFormat = ((const SfxUInt32Item*)pItem)->GetValue(); + } + + if ( nFormat ) + { + if (nFormat == SOT_FORMAT_STRING) + pOutView->Paste(); + else + pOutView->PasteSpecial(); + } + } + break; + + case SID_PASTE_SPECIAL: + ExecutePasteContents( rReq ); + break; + + case SID_SELECTALL: + { + ULONG nCount = pOutliner->GetParagraphCount(); + ESelection aSel( 0,0,(USHORT)nCount,0 ); + pOutView->SetSelection( aSel ); + } + break; + + case SID_CHARMAP: + { + const SvxFontItem& rItem = (const SvxFontItem&) + pOutView->GetAttribs().Get(EE_CHAR_FONTINFO); + + String aString; + SvxFontItem aNewItem( EE_CHAR_FONTINFO ); + + const SfxItemSet *pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem = 0; + if( pArgs ) + pArgs->GetItemState(GetPool().GetWhich(SID_CHARMAP), FALSE, &pItem); + + if ( pItem ) + { + aString = ((const SfxStringItem*)pItem)->GetValue(); + const SfxPoolItem* pFtItem = NULL; + pArgs->GetItemState( GetPool().GetWhich(SID_ATTR_SPECIALCHAR), FALSE, &pFtItem); + const SfxStringItem* pFontItem = PTR_CAST( SfxStringItem, pFtItem ); + if ( pFontItem ) + { + String aFontName(pFontItem->GetValue()); + Font aFont(aFontName, Size(1,1)); // Size nur wg. CTOR + aNewItem = SvxFontItem( aFont.GetFamily(), aFont.GetName(), + aFont.GetStyleName(), aFont.GetPitch(), + aFont.GetCharSet(), ATTR_FONT ); + } + else + aNewItem = rItem; + } + else + ScViewUtil::ExecuteCharMap( rItem, *pViewData->GetViewShell()->GetViewFrame(), aNewItem, aString ); + + if ( aString.Len() ) + { + SfxItemSet aSet( pOutliner->GetEmptyItemSet() ); + aSet.Put( aNewItem ); + // SetAttribs an der View selektiert ein Wort, wenn nichts selektiert ist + pOutView->GetOutliner()->QuickSetAttribs( aSet, pOutView->GetSelection() ); + pOutView->InsertText(aString); + } + + Invalidate( SID_ATTR_CHAR_FONT ); + } + break; + + case SID_HYPERLINK_SETLINK: + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if ( pReqArgs->GetItemState( SID_HYPERLINK_SETLINK, TRUE, &pItem ) == SFX_ITEM_SET ) + { + const SvxHyperlinkItem* pHyper = (const SvxHyperlinkItem*) pItem; + const String& rName = pHyper->GetName(); + const String& rURL = pHyper->GetURL(); + const String& rTarget = pHyper->GetTargetFrame(); + SvxLinkInsertMode eMode = pHyper->GetInsertMode(); + + BOOL bDone = FALSE; + if ( pOutView && ( eMode == HLINK_DEFAULT || eMode == HLINK_FIELD ) ) + { + const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + if ( pField && pField->ISA(SvxURLField) ) + { + // altes Feld selektieren + + ESelection aSel = pOutView->GetSelection(); + aSel.Adjust(); + aSel.nEndPara = aSel.nStartPara; + aSel.nEndPos = aSel.nStartPos + 1; + pOutView->SetSelection( aSel ); + } + } + + // neues Feld einfuegen + + SvxURLField aURLField( rURL, rName, SVXURLFORMAT_REPR ); + aURLField.SetTargetFrame( rTarget ); + SvxFieldItem aURLItem( aURLField, EE_FEATURE_FIELD ); + pOutView->InsertField( aURLItem ); + + // select new field + + ESelection aSel = pOutView->GetSelection(); + if ( aSel.nStartPos == aSel.nEndPos && aSel.nStartPos > 0 ) + { + // Cursor is behind the inserted field -> extend selection to the left + + --aSel.nStartPos; + pOutView->SetSelection( aSel ); + } + + bDone = TRUE; + } + + if (!bDone) + ExecuteGlobal( rReq ); // normal an der View + + // InsertURL an der ViewShell schaltet bei "Text" die DrawShell ab !!! + } + } + break; + + case SID_OPEN_HYPERLINK: + { + if ( pOutView ) + { + const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); + if ( pFieldItem ) + { + const SvxFieldData* pField = pFieldItem->GetField(); + if( pField && pField->ISA( SvxURLField ) ) + { + const SvxURLField* pURLField = static_cast< const SvxURLField* >( pField ); + ScGlobal::OpenURL( pURLField->GetURL(), pURLField->GetTargetFrame() ); + } + } + } + } + break; + + case SID_ENABLE_HYPHENATION: + case SID_TEXTDIRECTION_LEFT_TO_RIGHT: + case SID_TEXTDIRECTION_TOP_TO_BOTTOM: + pView->ScEndTextEdit(); // end text edit before switching direction + ExecuteGlobal( rReq ); + // restore consistent state between shells and functions: + pViewData->GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + break; + + case SID_THES: + { + String aReplaceText; + SFX_REQUEST_ARG( rReq, pItem2, SfxStringItem, SID_THES, sal_False ); + if (pItem2) + aReplaceText = pItem2->GetValue(); + if (aReplaceText.Len() > 0) + ReplaceTextWithSynonym( pOutView->GetEditView(), aReplaceText ); + } + break; + + case SID_THESAURUS: + { + pOutView->StartThesaurus(); + } + break; + + } +} + +void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) +{ + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + BOOL bHasFontWork = pViewFrm->HasChildWindow(SID_FONTWORK); + BOOL bDisableFontWork = FALSE; + + if (IsNoteEdit()) + { + // #i21255# notes now support rich text formatting (#i74140# but not fontwork) + bDisableFontWork = TRUE; + } + + if ( bDisableFontWork ) + rSet.DisableItem( SID_FONTWORK ); + else + rSet.Put(SfxBoolItem(SID_FONTWORK, bHasFontWork)); + + if ( rSet.GetItemState( SID_HYPERLINK_GETLINK ) != SFX_ITEM_UNKNOWN ) + { + SvxHyperlinkItem aHLinkItem; + SdrView* pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + if ( pOutView ) + { + BOOL bField = FALSE; + const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); + if (pFieldItem) + { + const SvxFieldData* pField = pFieldItem->GetField(); + if ( pField && pField->ISA(SvxURLField) ) + { + const SvxURLField* pURLField = (const SvxURLField*) pField; + aHLinkItem.SetName( pURLField->GetRepresentation() ); + aHLinkItem.SetURL( pURLField->GetURL() ); + aHLinkItem.SetTargetFrame( pURLField->GetTargetFrame() ); + bField = TRUE; + } + } + if (!bField) + { + // use selected text as name for urls + String sReturn = pOutView->GetSelected(); + sReturn.Erase(255); + sReturn.EraseTrailingChars(); + aHLinkItem.SetName(sReturn); + } + } + rSet.Put(aHLinkItem); + } + + if ( rSet.GetItemState( SID_OPEN_HYPERLINK ) != SFX_ITEM_UNKNOWN ) + { + SdrView* pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + bool bEnable = false; + if ( pOutView ) + { + const SvxFieldItem* pFieldItem = pOutView->GetFieldAtSelection(); + if ( pFieldItem ) + { + const SvxFieldData* pField = pFieldItem->GetField(); + bEnable = pField && pField->ISA( SvxURLField ); + } + } + if( !bEnable ) + rSet.DisableItem( SID_OPEN_HYPERLINK ); + } + + if( rSet.GetItemState( SID_TRANSLITERATE_HALFWIDTH ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HALFWIDTH ); + if( rSet.GetItemState( SID_TRANSLITERATE_FULLWIDTH ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_FULLWIDTH ); + if( rSet.GetItemState( SID_TRANSLITERATE_HIRAGANA ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_HIRAGANA ); + if( rSet.GetItemState( SID_TRANSLITERATE_KATAGANA ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::HideDisabledSlot( rSet, pViewFrm->GetBindings(), SID_TRANSLITERATE_KATAGANA ); + + if ( rSet.GetItemState( SID_ENABLE_HYPHENATION ) != SFX_ITEM_UNKNOWN ) + { + SdrView* pView = pViewData->GetScDrawView(); + SfxItemSet aAttrs( pView->GetModel()->GetItemPool() ); + pView->GetAttributes( aAttrs ); + if( aAttrs.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE ) + { + BOOL bValue = ( (const SfxBoolItem&) aAttrs.Get( EE_PARA_HYPHENATE ) ).GetValue(); + rSet.Put( SfxBoolItem( SID_ENABLE_HYPHENATION, bValue ) ); + } + } + + if ( rSet.GetItemState( SID_THES ) != SFX_ITEM_UNKNOWN || + rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN ) + { + SdrView * pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + + String aStatusVal; + LanguageType nLang = LANGUAGE_NONE; + bool bIsLookUpWord = false; + if ( pOutView ) + { + EditView& rEditView = pOutView->GetEditView(); + bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + } + rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); + + // disable thesaurus main menu and context menu entry if there is nothing to look up + BOOL bCanDoThesaurus = ScModule::HasThesaurusLanguage( nLang ); + if (!bIsLookUpWord || !bCanDoThesaurus) + rSet.DisableItem( SID_THES ); + if (!bCanDoThesaurus) + rSet.DisableItem( SID_THESAURUS ); + } +} + +IMPL_LINK( ScDrawTextObjectBar, ClipboardChanged, TransferableDataHelper*, pDataHelper ) +{ + if ( pDataHelper ) + { + bPastePossible = ( pDataHelper->HasFormat( SOT_FORMAT_STRING ) || pDataHelper->HasFormat( SOT_FORMAT_RTF ) ); + + SfxBindings& rBindings = pViewData->GetBindings(); + rBindings.Invalidate( SID_PASTE ); + rBindings.Invalidate( SID_PASTE_SPECIAL ); + rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS ); + } + return 0; +} + +void __EXPORT ScDrawTextObjectBar::GetClipState( SfxItemSet& rSet ) +{ + SdrView* pView = pViewData->GetScDrawView(); + if ( !pView->GetTextEditOutlinerView() ) + { + GetGlobalClipState( rSet ); + return; + } + + if ( !pClipEvtLstnr ) + { + // create listener + pClipEvtLstnr = new TransferableClipboardListener( LINK( this, ScDrawTextObjectBar, ClipboardChanged ) ); + pClipEvtLstnr->acquire(); + Window* pWin = pViewData->GetActiveWin(); + pClipEvtLstnr->AddRemoveListener( pWin, TRUE ); + + // get initial state + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); + bPastePossible = ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) || aDataHelper.HasFormat( SOT_FORMAT_RTF ) ); + } + + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + switch (nWhich) + { + case SID_PASTE: + case SID_PASTE_SPECIAL: + if( !bPastePossible ) + rSet.DisableItem( nWhich ); + break; + case SID_CLIPBOARD_FORMAT_ITEMS: + if ( bPastePossible ) + { + SvxClipboardFmtItem aFormats( SID_CLIPBOARD_FORMAT_ITEMS ); + TransferableDataHelper aDataHelper( + TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); + + if ( aDataHelper.HasFormat( SOT_FORMAT_STRING ) ) + aFormats.AddClipbrdFormat( SOT_FORMAT_STRING ); + if ( aDataHelper.HasFormat( SOT_FORMAT_RTF ) ) + aFormats.AddClipbrdFormat( SOT_FORMAT_RTF ); + + rSet.Put( aFormats ); + } + else + rSet.DisableItem( nWhich ); + break; + } + nWhich = aIter.NextWhich(); + } +} + +//======================================================================== +// +// Attribute +// +//======================================================================== + +void __EXPORT ScDrawTextObjectBar::ExecuteToggle( SfxRequest &rReq ) +{ + // Unterstreichung + + SdrView* pView = pViewData->GetScDrawView(); + + USHORT nSlot = rReq.GetSlot(); + + SfxItemSet aSet( pView->GetDefaultAttr() ); + + SfxItemSet aViewAttr(pView->GetModel()->GetItemPool()); + pView->GetAttributes(aViewAttr); + + // Unterstreichung + FontUnderline eOld = ((const SvxUnderlineItem&) aViewAttr. + Get(EE_CHAR_UNDERLINE)).GetLineStyle(); + FontUnderline eNew = eOld; + switch (nSlot) + { + case SID_ULINE_VAL_NONE: + eNew = UNDERLINE_NONE; + break; + case SID_ULINE_VAL_SINGLE: + eNew = ( eOld == UNDERLINE_SINGLE ) ? UNDERLINE_NONE : UNDERLINE_SINGLE; + break; + case SID_ULINE_VAL_DOUBLE: + eNew = ( eOld == UNDERLINE_DOUBLE ) ? UNDERLINE_NONE : UNDERLINE_DOUBLE; + break; + case SID_ULINE_VAL_DOTTED: + eNew = ( eOld == UNDERLINE_DOTTED ) ? UNDERLINE_NONE : UNDERLINE_DOTTED; + break; + default: + break; + } + aSet.Put( SvxUnderlineItem( eNew, EE_CHAR_UNDERLINE ) ); + + pView->SetAttributes( aSet ); + rReq.Done(); + pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); +} + +void lcl_RemoveFields( OutlinerView& rOutView ) +{ + //! Outliner should have RemoveFields with a selection + + Outliner* pOutliner = rOutView.GetOutliner(); + if (!pOutliner) return; + + ESelection aOldSel = rOutView.GetSelection(); + ESelection aSel = aOldSel; + aSel.Adjust(); + xub_StrLen nNewEnd = aSel.nEndPos; + + BOOL bUpdate = pOutliner->GetUpdateMode(); + BOOL bChanged = FALSE; + + //! GetPortions and GetAttribs should be const! + EditEngine& rEditEng = (EditEngine&)pOutliner->GetEditEngine(); + + ULONG nParCount = pOutliner->GetParagraphCount(); + for (ULONG nPar=0; nPar<nParCount; nPar++) + if ( nPar >= aSel.nStartPara && nPar <= aSel.nEndPara ) + { + SvUShorts aPortions; + rEditEng.GetPortions( (USHORT)nPar, aPortions ); + //! GetPortions should use xub_StrLen instead of USHORT + + for ( USHORT nPos = aPortions.Count(); nPos; ) + { + --nPos; + USHORT nEnd = aPortions.GetObject( nPos ); + USHORT nStart = nPos ? aPortions.GetObject( nPos - 1 ) : 0; + // fields are single characters + if ( nEnd == nStart+1 && + ( nPar > aSel.nStartPara || nStart >= aSel.nStartPos ) && + ( nPar < aSel.nEndPara || nEnd <= aSel.nEndPos ) ) + { + ESelection aFieldSel( (USHORT)nPar, nStart, (USHORT)nPar, nEnd ); + SfxItemSet aSet = rEditEng.GetAttribs( aFieldSel ); + if ( aSet.GetItemState( EE_FEATURE_FIELD ) == SFX_ITEM_ON ) + { + if (!bChanged) + { + if (bUpdate) + pOutliner->SetUpdateMode( FALSE ); + String aName = ScGlobal::GetRscString( STR_UNDO_DELETECONTENTS ); + pOutliner->GetUndoManager().EnterListAction( aName, aName ); + bChanged = TRUE; + } + + String aFieldText = rEditEng.GetText( aFieldSel ); + pOutliner->QuickInsertText( aFieldText, aFieldSel ); + if ( nPar == aSel.nEndPara ) + { + nNewEnd = sal::static_int_cast<xub_StrLen>( nNewEnd + aFieldText.Len() ); + --nNewEnd; + } + } + } + } + } + + if (bUpdate && bChanged) + { + pOutliner->GetUndoManager().LeaveListAction(); + pOutliner->SetUpdateMode( TRUE ); + } + + if ( aOldSel.IsEqual( aSel ) ) // aSel is adjusted + aOldSel.nEndPos = nNewEnd; + else + aOldSel.nStartPos = nNewEnd; // if aOldSel is backwards + rOutView.SetSelection( aOldSel ); +} + +void __EXPORT ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq ) +{ + SdrView* pView = pViewData->GetScDrawView(); + const SfxItemSet* pArgs = rReq.GetArgs(); + USHORT nSlot = rReq.GetSlot(); + + BOOL bArgsInReq = ( pArgs != NULL ); + if ( !bArgsInReq ) + { + SfxItemSet aEditAttr(pView->GetModel()->GetItemPool()); + pView->GetAttributes(aEditAttr); + SfxItemSet aNewAttr( *aEditAttr.GetPool(), aEditAttr.GetRanges() ); + BOOL bDone = TRUE; + + switch ( nSlot ) + { + case SID_TEXT_STANDARD: // Harte Textattributierung loeschen + { + OutlinerView* pOutView = pView->IsTextEdit() ? + pView->GetTextEditOutlinerView() : NULL; + if ( pOutView ) + pOutView->Paint( Rectangle() ); + + SfxItemSet aEmptyAttr( *aEditAttr.GetPool(), EE_ITEMS_START, EE_ITEMS_END ); + pView->SetAttributes( aEmptyAttr, TRUE ); + + if ( pOutView ) + { + lcl_RemoveFields( *pOutView ); + pOutView->ShowCursor(); + } + + rReq.Done( aEmptyAttr ); + pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); + bDone = FALSE; // bereits hier passiert + } + break; + + case SID_CHAR_DLG: // Dialog-Button + case SID_ATTR_CHAR_FONT: // Controller nicht angezeigt + case SID_ATTR_CHAR_FONTHEIGHT: + bDone = ExecuteCharDlg( aEditAttr, aNewAttr ); + break; + + case SID_PARA_DLG: + bDone = ExecuteParaDlg( aEditAttr, aNewAttr ); + break; + + case SID_ATTR_CHAR_WEIGHT: + aNewAttr.Put( (const SvxWeightItem&)aEditAttr.Get( EE_CHAR_WEIGHT ) ); + break; + + case SID_ATTR_CHAR_POSTURE: + aNewAttr.Put( (const SvxPostureItem&)aEditAttr.Get( EE_CHAR_ITALIC ) ); + break; + + case SID_ATTR_CHAR_UNDERLINE: + aNewAttr.Put( (const SvxUnderlineItem&)aEditAttr.Get( EE_CHAR_UNDERLINE ) ); + break; + + case SID_ATTR_CHAR_OVERLINE: + aNewAttr.Put( (const SvxOverlineItem&)aEditAttr.Get( EE_CHAR_OVERLINE ) ); + break; + + case SID_ATTR_CHAR_CONTOUR: + aNewAttr.Put( (const SvxContourItem&)aEditAttr.Get( EE_CHAR_OUTLINE ) ); + break; + + case SID_ATTR_CHAR_SHADOWED: + aNewAttr.Put( (const SvxShadowedItem&)aEditAttr.Get( EE_CHAR_SHADOW ) ); + break; + + case SID_ATTR_CHAR_STRIKEOUT: + aNewAttr.Put( (const SvxCrossedOutItem&)aEditAttr.Get( EE_CHAR_STRIKEOUT ) ); + break; + + case SID_ALIGNLEFT: + case SID_ALIGN_ANY_LEFT: + aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_LEFT, EE_PARA_JUST ) ); + break; + + case SID_ALIGNCENTERHOR: + case SID_ALIGN_ANY_HCENTER: + aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_CENTER, EE_PARA_JUST ) ); + break; + + case SID_ALIGNRIGHT: + case SID_ALIGN_ANY_RIGHT: + aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); + break; + + case SID_ALIGNBLOCK: + case SID_ALIGN_ANY_JUSTIFIED: + aNewAttr.Put( SvxAdjustItem( SVX_ADJUST_BLOCK, EE_PARA_JUST ) ); + break; + + case SID_ATTR_PARA_LINESPACE_10: + { + SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_LINE, EE_PARA_SBL ); + aItem.SetPropLineSpace( 100 ); + aNewAttr.Put( aItem ); + } + break; + + case SID_ATTR_PARA_LINESPACE_15: + { + SvxLineSpacingItem aItem( SVX_LINESPACE_ONE_POINT_FIVE_LINES, EE_PARA_SBL ); + aItem.SetPropLineSpace( 150 ); + aNewAttr.Put( aItem ); + } + break; + + case SID_ATTR_PARA_LINESPACE_20: + { + SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL ); + aItem.SetPropLineSpace( 200 ); + aNewAttr.Put( aItem ); + } + break; + + case SID_SET_SUPER_SCRIPT: + { + SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); + SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) + aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + + if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) + aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); + else + aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT ); + aNewAttr.Put( aItem ); + } + break; + case SID_SET_SUB_SCRIPT: + { + SvxEscapementItem aItem(EE_CHAR_ESCAPEMENT); + SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) + aEditAttr.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + + if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) + aItem.SetEscapement( SVX_ESCAPEMENT_OFF ); + else + aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT ); + aNewAttr.Put( aItem ); + } + break; + + case SID_DRAWTEXT_ATTR_DLG: + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView ); + + bDone = ( RET_OK == pDlg->Execute() ); + + if ( bDone ) + aNewAttr.Put( *pDlg->GetOutputItemSet() ); + + delete pDlg; + } + break; + } + + if ( bDone ) // wurden Attribute geaendert? + { + rReq.Done( aNewAttr ); + pArgs = rReq.GetArgs(); + } + } + + if ( pArgs ) + { + if ( bArgsInReq && + ( nSlot == SID_ATTR_CHAR_FONT || nSlot == SID_ATTR_CHAR_FONTHEIGHT || + nSlot == SID_ATTR_CHAR_WEIGHT || nSlot == SID_ATTR_CHAR_POSTURE ) ) + { + // font items from toolbox controller have to be applied for the right script type + + // #i78017 establish the same behaviour as in Writer + USHORT nScript = SCRIPTTYPE_LATIN | SCRIPTTYPE_ASIAN | SCRIPTTYPE_COMPLEX; + if (nSlot == SID_ATTR_CHAR_FONT) + nScript = pView->GetScriptType(); + + SfxItemPool& rPool = GetPool(); + SvxScriptSetItem aSetItem( nSlot, rPool ); + USHORT nWhich = rPool.GetWhich( nSlot ); + aSetItem.PutItemForScriptType( nScript, pArgs->Get( nWhich ) ); + + pView->SetAttributes( aSetItem.GetItemSet() ); + } + else + { + // use args directly + + pView->SetAttributes( *pArgs ); + } + pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); + } +} + +void __EXPORT ScDrawTextObjectBar::GetAttrState( SfxItemSet& rDestSet ) +{ + if ( IsNoteEdit() ) + { + // issue 21255 - Notes now support rich text formatting. + } + + SvtLanguageOptions aLangOpt; + BOOL bDisableCTLFont = !aLangOpt.IsCTLFontEnabled(); + BOOL bDisableVerticalText = !aLangOpt.IsVerticalTextEnabled(); + + SdrView* pView = pViewData->GetScDrawView(); + SfxItemSet aAttrSet(pView->GetModel()->GetItemPool()); + pView->GetAttributes(aAttrSet); + + // direkte Attribute + + rDestSet.Put( aAttrSet ); + + // choose font info according to selection script type + + USHORT nScript = pView->GetScriptType(); + + // #i55929# input-language-dependent script type (depends on input language if nothing selected) + USHORT nInputScript = nScript; + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + if (pOutView && !pOutView->GetSelection().HasRange()) + { + LanguageType nInputLang = pViewData->GetActiveWin()->GetInputLanguage(); + if (nInputLang != LANGUAGE_DONTKNOW && nInputLang != LANGUAGE_SYSTEM) + nInputScript = SvtLanguageOptions::GetScriptTypeOfLanguage( nInputLang ); + } + + // #i55929# according to spec, nInputScript is used for font and font height only + if ( rDestSet.GetItemState( EE_CHAR_FONTINFO ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTINFO, nInputScript ); + if ( rDestSet.GetItemState( EE_CHAR_FONTHEIGHT ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_FONTHEIGHT, nInputScript ); + if ( rDestSet.GetItemState( EE_CHAR_WEIGHT ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_WEIGHT, nScript ); + if ( rDestSet.GetItemState( EE_CHAR_ITALIC ) != SFX_ITEM_UNKNOWN ) + ScViewUtil::PutItemScript( rDestSet, aAttrSet, EE_CHAR_ITALIC, nScript ); + + // Ausrichtung + + SvxAdjust eAdj = ((const SvxAdjustItem&)aAttrSet.Get(EE_PARA_JUST)).GetAdjust(); + switch( eAdj ) + { + case SVX_ADJUST_LEFT: + rDestSet.Put( SfxBoolItem( SID_ALIGNLEFT, TRUE ) ); + break; + case SVX_ADJUST_CENTER: + rDestSet.Put( SfxBoolItem( SID_ALIGNCENTERHOR, TRUE ) ); + break; + case SVX_ADJUST_RIGHT: + rDestSet.Put( SfxBoolItem( SID_ALIGNRIGHT, TRUE ) ); + break; + case SVX_ADJUST_BLOCK: + rDestSet.Put( SfxBoolItem( SID_ALIGNBLOCK, TRUE ) ); + break; + default: + { + // added to avoid warnings + } + } + // pseudo slots for Format menu + rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_LEFT, eAdj == SVX_ADJUST_LEFT ) ); + rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_HCENTER, eAdj == SVX_ADJUST_CENTER ) ); + rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_RIGHT, eAdj == SVX_ADJUST_RIGHT ) ); + rDestSet.Put( SfxBoolItem( SID_ALIGN_ANY_JUSTIFIED, eAdj == SVX_ADJUST_BLOCK ) ); + + // Zeilenabstand + + USHORT nLineSpace = (USHORT) + ((const SvxLineSpacingItem&)aAttrSet. + Get( EE_PARA_SBL )).GetPropLineSpace(); + switch( nLineSpace ) + { + case 100: + rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_10, TRUE ) ); + break; + case 150: + rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_15, TRUE ) ); + break; + case 200: + rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LINESPACE_20, TRUE ) ); + break; + } + + // hoch-/tiefgestellt + + SvxEscapement eEsc = (SvxEscapement) ( (const SvxEscapementItem&) + aAttrSet.Get( EE_CHAR_ESCAPEMENT ) ).GetEnumValue(); + if( eEsc == SVX_ESCAPEMENT_SUPERSCRIPT ) + rDestSet.Put( SfxBoolItem( SID_SET_SUPER_SCRIPT, TRUE ) ); + else if( eEsc == SVX_ESCAPEMENT_SUBSCRIPT ) + rDestSet.Put( SfxBoolItem( SID_SET_SUB_SCRIPT, TRUE ) ); + + // Unterstreichung + + SfxItemState eState = aAttrSet.GetItemState( EE_CHAR_UNDERLINE, TRUE ); + if ( eState == SFX_ITEM_DONTCARE ) + { + rDestSet.InvalidateItem( SID_ULINE_VAL_NONE ); + rDestSet.InvalidateItem( SID_ULINE_VAL_SINGLE ); + rDestSet.InvalidateItem( SID_ULINE_VAL_DOUBLE ); + rDestSet.InvalidateItem( SID_ULINE_VAL_DOTTED ); + } + else + { + FontUnderline eUnderline = ((const SvxUnderlineItem&) + aAttrSet.Get(EE_CHAR_UNDERLINE)).GetLineStyle(); + USHORT nId = SID_ULINE_VAL_NONE; + switch (eUnderline) + { + case UNDERLINE_SINGLE: nId = SID_ULINE_VAL_SINGLE; break; + case UNDERLINE_DOUBLE: nId = SID_ULINE_VAL_DOUBLE; break; + case UNDERLINE_DOTTED: nId = SID_ULINE_VAL_DOTTED; break; + default: + break; + } + rDestSet.Put( SfxBoolItem( nId, TRUE ) ); + } + + // horizontal / vertical + + BOOL bLeftToRight = TRUE; + + SdrOutliner* pOutl = pView->GetTextEditOutliner(); + if( pOutl ) + { + if( pOutl->IsVertical() ) + bLeftToRight = FALSE; + } + else + bLeftToRight = ( (const SvxWritingModeItem&) aAttrSet.Get( SDRATTR_TEXTDIRECTION ) ).GetValue() == com::sun::star::text::WritingMode_LR_TB; + + if ( bDisableVerticalText ) + { + rDestSet.DisableItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT ); + rDestSet.DisableItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM ); + } + else + { + rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_LEFT_TO_RIGHT, bLeftToRight ) ); + rDestSet.Put( SfxBoolItem( SID_TEXTDIRECTION_TOP_TO_BOTTOM, !bLeftToRight ) ); + } + + // left-to-right or right-to-left + + if ( !bLeftToRight || bDisableCTLFont ) + { + // disabled if vertical + rDestSet.DisableItem( SID_ATTR_PARA_LEFT_TO_RIGHT ); + rDestSet.DisableItem( SID_ATTR_PARA_RIGHT_TO_LEFT ); + } + else if ( aAttrSet.GetItemState( EE_PARA_WRITINGDIR ) == SFX_ITEM_DONTCARE ) + { + rDestSet.InvalidateItem( SID_ATTR_PARA_LEFT_TO_RIGHT ); + rDestSet.InvalidateItem( SID_ATTR_PARA_RIGHT_TO_LEFT ); + } + else + { + SvxFrameDirection eAttrDir = (SvxFrameDirection)((const SvxFrameDirectionItem&) + aAttrSet.Get( EE_PARA_WRITINGDIR )).GetValue(); + if ( eAttrDir == FRMDIR_ENVIRONMENT ) + { + // get "environment" direction from page style + if ( pViewData->GetDocument()->GetEditTextDirection( pViewData->GetTabNo() ) == EE_HTEXTDIR_R2L ) + eAttrDir = FRMDIR_HORI_RIGHT_TOP; + else + eAttrDir = FRMDIR_HORI_LEFT_TOP; + } + rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_LEFT_TO_RIGHT, ( eAttrDir == FRMDIR_HORI_LEFT_TOP ) ) ); + rDestSet.Put( SfxBoolItem( SID_ATTR_PARA_RIGHT_TO_LEFT, ( eAttrDir == FRMDIR_HORI_RIGHT_TOP ) ) ); + } +} + +void ScDrawTextObjectBar::ExecuteTrans( SfxRequest& rReq ) +{ + sal_Int32 nType = ScViewUtil::GetTransliterationType( rReq.GetSlot() ); + if ( nType ) + { + ScDrawView* pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + if ( pOutView ) + { + // change selected text in object + pOutView->TransliterateText( nType ); + } + else + { + //! apply to whole objects? + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drtxtob1.cxx b/sc/source/ui/drawfunc/drtxtob1.cxx new file mode 100644 index 000000000000..e3ab9efcd409 --- /dev/null +++ b/sc/source/ui/drawfunc/drtxtob1.cxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------------ + +#include "scitems.hxx" +#include <editeng/eeitem.hxx> + +#include <svx/svxdlg.hxx> +#include <editeng/brkitem.hxx> +#include <editeng/hyznitem.hxx> +#include <editeng/orphitem.hxx> +#include <editeng/outliner.hxx> +#include <editeng/spltitem.hxx> +#include <editeng/widwitem.hxx> +#include <sot/exchange.hxx> +#include <vcl/msgbox.hxx> +#include <svtools/transfer.hxx> + +#include "sc.hrc" +#include "drtxtob.hxx" +#include "drawview.hxx" +#include "viewdata.hxx" +#include "scresid.hxx" + +#include "scabstdlg.hxx" +//------------------------------------------------------------------------ + +BOOL ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& rArgs, + SfxItemSet& rOutSet ) +{ + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "ScAbstractFactory create fail!"); + + SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg( pViewData->GetDialogParent(), &rArgs, + pViewData->GetSfxDocShell(),RID_SCDLG_CHAR ); + DBG_ASSERT(pDlg, "Dialog create fail!"); + BOOL bRet = ( pDlg->Execute() == RET_OK ); + + if ( bRet ) + { + const SfxItemSet* pNewAttrs = pDlg->GetOutputItemSet(); + if ( pNewAttrs ) + rOutSet.Put( *pNewAttrs ); + } + delete pDlg; + + return bRet; +} + +BOOL ScDrawTextObjectBar::ExecuteParaDlg( const SfxItemSet& rArgs, + SfxItemSet& rOutSet ) +{ + SfxItemPool* pArgPool = rArgs.GetPool(); + SfxItemSet aNewAttr( *pArgPool, + EE_ITEMS_START, EE_ITEMS_END, + SID_ATTR_PARA_HYPHENZONE, SID_ATTR_PARA_HYPHENZONE, + SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_PAGEBREAK, + SID_ATTR_PARA_SPLIT, SID_ATTR_PARA_SPLIT, + SID_ATTR_PARA_WIDOWS, SID_ATTR_PARA_WIDOWS, + SID_ATTR_PARA_ORPHANS, SID_ATTR_PARA_ORPHANS, + 0 ); + aNewAttr.Put( rArgs ); + + // Die Werte sind erst einmal uebernommen worden, um den Dialog anzuzeigen. + // Muss natuerlich noch geaendert werden + // aNewAttr.Put( SvxParaDlgLimitsItem( 567 * 50, 5670) ); + + aNewAttr.Put( SvxHyphenZoneItem( sal_False, SID_ATTR_PARA_HYPHENZONE ) ); + aNewAttr.Put( SvxFmtBreakItem( SVX_BREAK_NONE, SID_ATTR_PARA_PAGEBREAK ) ); + aNewAttr.Put( SvxFmtSplitItem( sal_True, SID_ATTR_PARA_SPLIT) ); + aNewAttr.Put( SvxWidowsItem( 0, SID_ATTR_PARA_WIDOWS) ); + aNewAttr.Put( SvxOrphansItem( 0, SID_ATTR_PARA_ORPHANS) ); + + ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create(); + DBG_ASSERT(pFact, "ScAbstractFactory create fail!"); + + SfxAbstractTabDialog* pDlg = pFact->CreateScParagraphDlg( pViewData->GetDialogParent(), &aNewAttr, RID_SCDLG_PARAGRAPH); + DBG_ASSERT(pDlg, "Dialog create fail!"); + BOOL bRet = ( pDlg->Execute() == RET_OK ); + + if ( bRet ) + { + const SfxItemSet* pNewAttrs = pDlg->GetOutputItemSet(); + if ( pNewAttrs ) + rOutSet.Put( *pNewAttrs ); + } + delete pDlg; + + return bRet; +} + +void ScDrawTextObjectBar::ExecutePasteContents( SfxRequest & /* rReq */ ) +{ + SdrView* pView = pViewData->GetScDrawView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() ); + + pDlg->Insert( SOT_FORMAT_STRING, EMPTY_STRING ); + pDlg->Insert( SOT_FORMAT_RTF, EMPTY_STRING ); + + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) ); + + ULONG nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() ); + + //! test if outliner view is still valid + + if (nFormat > 0) + { + if (nFormat == SOT_FORMAT_STRING) + pOutView->Paste(); + else + pOutView->PasteSpecial(); + } + delete pDlg; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/drtxtob2.cxx b/sc/source/ui/drawfunc/drtxtob2.cxx new file mode 100644 index 000000000000..aef408544aa4 --- /dev/null +++ b/sc/source/ui/drawfunc/drtxtob2.cxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include "scitems.hxx" +#include <editeng/adjitem.hxx> +#include <svx/drawitem.hxx> +#include <svx/fontwork.hxx> +#include <editeng/frmdiritem.hxx> +#include <editeng/outlobj.hxx> +#include <svx/svdocapt.hxx> +#include <svx/xtextit.hxx> +#include <editeng/writingmodeitem.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/request.hxx> +#include <sot/formats.hxx> +#include <svl/whiter.hxx> + +#include "sc.hrc" +#include "drtxtob.hxx" +#include "viewdata.hxx" +#include "drawview.hxx" +#include "tabvwsh.hxx" +#include "impex.hxx" +#include "docsh.hxx" +#include "transobj.hxx" +#include "drwtrans.hxx" +#include "drwlayer.hxx" + +//------------------------------------------------------------------------ + +USHORT ScGetFontWorkId() +{ + return SvxFontWorkChildWindow::GetChildWindowId(); +} + +BOOL ScDrawTextObjectBar::IsNoteEdit() +{ + return ScDrawLayer::IsNoteCaption( pViewData->GetView()->GetSdrView()->GetTextEditObject() ); +} + +// wenn kein Text editiert wird, Funktionen wie in drawsh + +void __EXPORT ScDrawTextObjectBar::ExecuteGlobal( SfxRequest &rReq ) +{ + ScTabView* pTabView = pViewData->GetView(); + ScDrawView* pView = pTabView->GetScDrawView(); + + USHORT nSlot = rReq.GetSlot(); + switch ( nSlot ) + { + case SID_COPY: + pView->DoCopy(); + break; + + case SID_CUT: + pView->DoCut(); + if (!pTabView->IsDrawSelMode()) + pViewData->GetViewShell()->SetDrawShell( FALSE ); + break; + + case SID_PASTE: + case SID_PASTE_SPECIAL: + case SID_CLIPBOARD_FORMAT_ITEMS: + case SID_HYPERLINK_SETLINK: + { + // cell methods are at cell shell, which is not available if + // ScDrawTextObjectBar is active + //! move paste etc. to view shell? + } + break; + + case SID_SELECTALL: + pView->MarkAll(); + break; + + case SID_TEXTDIRECTION_LEFT_TO_RIGHT: + case SID_TEXTDIRECTION_TOP_TO_BOTTOM: + { + SfxItemSet aAttr( pView->GetModel()->GetItemPool(), SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 0 ); + aAttr.Put( SvxWritingModeItem( + nSlot == SID_TEXTDIRECTION_LEFT_TO_RIGHT ? + com::sun::star::text::WritingMode_LR_TB : com::sun::star::text::WritingMode_TB_RL, + SDRATTR_TEXTDIRECTION ) ); + pView->SetAttributes( aAttr ); + pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); // Bidi slots may be disabled + rReq.Done( aAttr ); + } + break; + + case SID_ENABLE_HYPHENATION: + { + SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, SID_ENABLE_HYPHENATION, FALSE); + if( pItem ) + { + SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE ); + BOOL bValue = ( (const SfxBoolItem*) pItem)->GetValue(); + aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); + pView->SetAttributes( aSet ); + } + rReq.Done(); + } + break; + } +} + +void ScDrawTextObjectBar::GetGlobalClipState( SfxItemSet& rSet ) +{ + // cell methods are at cell shell, which is not available if + // ScDrawTextObjectBar is active -> disable everything + //! move paste etc. to view shell? + + SfxWhichIter aIter(rSet); + USHORT nWhich = aIter.FirstWhich(); + while (nWhich) + { + rSet.DisableItem( nWhich ); + nWhich = aIter.NextWhich(); + } +} + +void __EXPORT ScDrawTextObjectBar::ExecuteExtra( SfxRequest &rReq ) +{ + ScTabView* pTabView = pViewData->GetView(); + ScDrawView* pView = pTabView->GetScDrawView(); + + USHORT nSlot = rReq.GetSlot(); + switch ( nSlot ) + { + case SID_FONTWORK: + { + USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + + if ( rReq.GetArgs() ) + pViewFrm->SetChildWindow( nId, + ((const SfxBoolItem&) + (rReq.GetArgs()->Get(SID_FONTWORK))). + GetValue() ); + else + pViewFrm->ToggleChildWindow( nId ); + + pViewFrm->GetBindings().Invalidate( SID_FONTWORK ); + rReq.Done(); + } + break; + + case SID_ATTR_PARA_LEFT_TO_RIGHT: + case SID_ATTR_PARA_RIGHT_TO_LEFT: + { + SfxItemSet aAttr( pView->GetModel()->GetItemPool(), + EE_PARA_WRITINGDIR, EE_PARA_WRITINGDIR, + EE_PARA_JUST, EE_PARA_JUST, + 0 ); + BOOL bLeft = ( nSlot == SID_ATTR_PARA_LEFT_TO_RIGHT ); + aAttr.Put( SvxFrameDirectionItem( + bLeft ? FRMDIR_HORI_LEFT_TOP : FRMDIR_HORI_RIGHT_TOP, + EE_PARA_WRITINGDIR ) ); + aAttr.Put( SvxAdjustItem( + bLeft ? SVX_ADJUST_LEFT : SVX_ADJUST_RIGHT, + EE_PARA_JUST ) ); + pView->SetAttributes( aAttr ); + pViewData->GetScDrawView()->InvalidateDrawTextAttrs(); + rReq.Done(); //! Done(aAttr) ? + + } + break; + } +} + +void ScDrawTextObjectBar::ExecFormText(SfxRequest& rReq) +{ + ScTabView* pTabView = pViewData->GetView(); + ScDrawView* pDrView = pTabView->GetScDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + + if ( rMarkList.GetMarkCount() == 1 && rReq.GetArgs() ) + { + const SfxItemSet& rSet = *rReq.GetArgs(); + const SfxPoolItem* pItem; + + if ( pDrView->IsTextEdit() ) + pDrView->ScEndTextEdit(); + + if ( SFX_ITEM_SET == + rSet.GetItemState(XATTR_FORMTXTSTDFORM, TRUE, &pItem) + && XFTFORM_NONE != + ((const XFormTextStdFormItem*) pItem)->GetValue() ) + { + + USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + SvxFontWorkDialog* pDlg = (SvxFontWorkDialog*) + (pViewFrm-> + GetChildWindow(nId)->GetWindow()); + + pDlg->CreateStdFormObj(*pDrView, *pDrView->GetSdrPageView(), + rSet, *rMarkList.GetMark(0)->GetMarkedSdrObj(), + ((const XFormTextStdFormItem*) pItem)-> + GetValue()); + } + else + pDrView->SetAttributes(rSet); + } +} + +void ScDrawTextObjectBar::GetFormTextState(SfxItemSet& rSet) +{ + const SdrObject* pObj = NULL; + SvxFontWorkDialog* pDlg = NULL; + ScDrawView* pDrView = pViewData->GetView()->GetScDrawView(); + const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); + USHORT nId = SvxFontWorkChildWindow::GetChildWindowId(); + + SfxViewFrame* pViewFrm = pViewData->GetViewShell()->GetViewFrame(); + if ( pViewFrm->HasChildWindow(nId) ) + pDlg = (SvxFontWorkDialog*)(pViewFrm->GetChildWindow(nId)->GetWindow()); + + if ( rMarkList.GetMarkCount() == 1 ) + pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + if ( pObj == NULL || !pObj->ISA(SdrTextObj) || + !((SdrTextObj*) pObj)->HasText() ) + { + if ( pDlg ) + pDlg->SetActive(FALSE); + + rSet.DisableItem(XATTR_FORMTXTSTYLE); + rSet.DisableItem(XATTR_FORMTXTADJUST); + rSet.DisableItem(XATTR_FORMTXTDISTANCE); + rSet.DisableItem(XATTR_FORMTXTSTART); + rSet.DisableItem(XATTR_FORMTXTMIRROR); + rSet.DisableItem(XATTR_FORMTXTSTDFORM); + rSet.DisableItem(XATTR_FORMTXTHIDEFORM); + rSet.DisableItem(XATTR_FORMTXTOUTLINE); + rSet.DisableItem(XATTR_FORMTXTSHADOW); + rSet.DisableItem(XATTR_FORMTXTSHDWCOLOR); + rSet.DisableItem(XATTR_FORMTXTSHDWXVAL); + rSet.DisableItem(XATTR_FORMTXTSHDWYVAL); + } + else + { + if ( pDlg ) + { + SfxObjectShell* pDocSh = SfxObjectShell::Current(); + + if ( pDocSh ) + { + const SfxPoolItem* pItem = pDocSh->GetItem( SID_COLOR_TABLE ); + XColorTable* pColorTable = NULL; + + if ( pItem ) + pColorTable = ((SvxColorTableItem*)pItem)->GetColorTable(); + + pDlg->SetActive(); + + if ( pColorTable ) + pDlg->SetColorTable( pColorTable ); + else + { DBG_ERROR( "ColorList not found :-/" ); } + } + } + SfxItemSet aViewAttr(pDrView->GetModel()->GetItemPool()); + pDrView->GetAttributes(aViewAttr); + rSet.Set(aViewAttr); + } +} + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuconarc.cxx b/sc/source/ui/drawfunc/fuconarc.cxx new file mode 100644 index 000000000000..48c529d923e6 --- /dev/null +++ b/sc/source/ui/drawfunc/fuconarc.cxx @@ -0,0 +1,236 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include "fuconarc.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "drawview.hxx" + +// #98185# Create default drawing objects via keyboard +#include <svx/svdocirc.hxx> +#include <svx/sxciaitm.hxx> + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuConstArc::FuConstArc( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq ) + : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq ) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuConstArc::~FuConstArc() +{ +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstArc::MouseButtonDown( const MouseEvent& rMEvt ) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuConstruct::MouseButtonDown( rMEvt ); + + if ( rMEvt.IsLeft() && !pView->IsAction() ) + { + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pWindow->CaptureMouse(); + pView->BegCreateObj( aPnt ); + bReturn = TRUE; + } + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstArc::MouseMove( const MouseEvent& rMEvt ) +{ + return FuConstruct::MouseMove(rMEvt); +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstArc::MouseButtonUp( const MouseEvent& rMEvt ) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FALSE; + + if ( pView->IsCreateObj() && rMEvt.IsLeft() ) + { + // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pView->EndCreateObj( SDRCREATE_NEXTPOINT ); + bReturn = TRUE; + } +/* + else if ( pView->IsCreateObj() && rMEvt.IsRight() ) + { + // Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pView->EndCreateObj( SDRCREATE_FORCEEND ); + bReturn = TRUE; + } +*/ + return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuConstArc::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FuConstruct::KeyInput(rKEvt); + return(bReturn); +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuConstArc::Activate() +{ + SdrObjKind aObjKind; + + switch (aSfxRequest.GetSlot() ) + { + case SID_DRAW_ARC: + aNewPointer = Pointer( POINTER_DRAW_ARC ); + aObjKind = OBJ_CARC; + break; + + case SID_DRAW_PIE: + aNewPointer = Pointer( POINTER_DRAW_PIE ); + aObjKind = OBJ_SECT; + break; + + case SID_DRAW_CIRCLECUT: + aNewPointer = Pointer( POINTER_DRAW_CIRCLECUT ); + aObjKind = OBJ_CCUT; + break; + + default: + aNewPointer = Pointer( POINTER_CROSS ); + aObjKind = OBJ_CARC; + break; + } + + pView->SetCurrentObj( sal::static_int_cast<UINT16>( aObjKind ) ); + + aOldPointer = pWindow->GetPointer(); + pViewShell->SetActivePointer( aNewPointer ); + + FuDraw::Activate(); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuConstArc::Deactivate() +{ + FuDraw::Deactivate(); + pViewShell->SetActivePointer( aOldPointer ); +} + +// #98185# Create default drawing objects via keyboard +SdrObject* FuConstArc::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) +{ + // case SID_DRAW_ARC: + // case SID_DRAW_PIE: + // case SID_DRAW_CIRCLECUT: + + SdrObject* pObj = SdrObjFactory::MakeNewObject( + pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), + 0L, pDrDoc); + + if(pObj) + { + if(pObj->ISA(SdrCircObj)) + { + Rectangle aRect(rRectangle); + + if(SID_DRAW_ARC == nID || SID_DRAW_CIRCLECUT == nID) + { + // force quadratic + ImpForceQuadratic(aRect); + } + + pObj->SetLogicRect(aRect); + + SfxItemSet aAttr(pDrDoc->GetItemPool()); + aAttr.Put(SdrCircStartAngleItem(9000)); + aAttr.Put(SdrCircEndAngleItem(0)); + + pObj->SetMergedItemSet(aAttr); + } + else + { + DBG_ERROR("Object is NO circle object"); + } + } + + return pObj; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuconcustomshape.cxx b/sc/source/ui/drawfunc/fuconcustomshape.cxx new file mode 100644 index 000000000000..dfcbdb2f5d49 --- /dev/null +++ b/sc/source/ui/drawfunc/fuconcustomshape.cxx @@ -0,0 +1,291 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include "fuconcustomshape.hxx" +#include <editeng/svxenum.hxx> +#include <svx/gallery.hxx> +#include <sfx2/request.hxx> +#include <svx/fmmodel.hxx> +#include <svl/itempool.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdoashp.hxx> +#include <editeng/eeitem.hxx> +#include <svx/sdtagitm.hxx> +#include "fuconuno.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "drawview.hxx" +#include <editeng/adjitem.hxx> + +#include <math.h> + +//------------------------------------------------------------------------ + +FuConstCustomShape::FuConstCustomShape( ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, SdrModel* pDoc, SfxRequest& rReq ) + : FuConstruct( pViewSh, pWin, pViewP, pDoc, rReq ) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + if ( pArgs ) + { + const SfxStringItem& rItm = (const SfxStringItem&)pArgs->Get( rReq.GetSlot() ); + aCustomShape = rItm.GetValue(); + } +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuConstCustomShape::~FuConstCustomShape() +{ +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstCustomShape::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt); + if ( rMEvt.IsLeft() && !pView->IsAction() ) + { + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pWindow->CaptureMouse(); + pView->BegCreateObj(aPnt); + + SdrObject* pObj = pView->GetCreateObj(); + if ( pObj ) + { + SetAttributes( pObj ); + sal_Bool bForceFillStyle = sal_True; + sal_Bool bForceNoFillStyle = sal_False; + if ( ((SdrObjCustomShape*)pObj)->UseNoFillStyle() ) + { + bForceFillStyle = sal_False; + bForceNoFillStyle = sal_True; + } + if ( bForceNoFillStyle ) + pObj->SetMergedItem( XFillStyleItem( XFILL_NONE ) ); + } + + bReturn = TRUE; + } + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstCustomShape::MouseMove(const MouseEvent& rMEvt) +{ + return FuConstruct::MouseMove(rMEvt); +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstCustomShape::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FALSE; + + if ( pView->IsCreateObj() && rMEvt.IsLeft() ) + { + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pView->EndCreateObj(SDRCREATE_FORCEEND); + bReturn = TRUE; + } + return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuConstCustomShape::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FuConstruct::KeyInput(rKEvt); + return(bReturn); +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuConstCustomShape::Activate() +{ + pView->SetCurrentObj( OBJ_CUSTOMSHAPE, SdrInventor ); + + aNewPointer = Pointer( POINTER_DRAW_RECT ); + aOldPointer = pWindow->GetPointer(); + pViewShell->SetActivePointer( aNewPointer ); + + SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS); + if (pLayer) + pView->SetActiveLayer( pLayer->GetName() ); + + FuConstruct::Activate(); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuConstCustomShape::Deactivate() +{ + FuConstruct::Deactivate(); + + SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT); + if (pLayer) + pView->SetActiveLayer( pLayer->GetName() ); + + pViewShell->SetActivePointer( aOldPointer ); +} + +// #98185# Create default drawing objects via keyboard +SdrObject* FuConstCustomShape::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle) +{ + SdrObject* pObj = SdrObjFactory::MakeNewObject( + pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), + 0L, pDrDoc); + if( pObj ) + { + Rectangle aRectangle( rRectangle ); + SetAttributes( pObj ); + if ( SdrObjCustomShape::doConstructOrthogonal( aCustomShape ) ) + ImpForceQuadratic( aRectangle ); + pObj->SetLogicRect( aRectangle ); + } + return pObj; +} + +/************************************************************************* +|* +|* applying attributes +|* +\************************************************************************/ + +void FuConstCustomShape::SetAttributes( SdrObject* pObj ) +{ + sal_Bool bAttributesAppliedFromGallery = sal_False; + + if ( GalleryExplorer::GetSdrObjCount( GALLERY_THEME_POWERPOINT ) ) + { + std::vector< rtl::OUString > aObjList; + if ( GalleryExplorer::FillObjListTitle( GALLERY_THEME_POWERPOINT, aObjList ) ) + { + sal_uInt16 i; + for ( i = 0; i < aObjList.size(); i++ ) + { + if ( aObjList[ i ].equalsIgnoreAsciiCase( aCustomShape ) ) + { + FmFormModel aFormModel; + SfxItemPool& rPool = aFormModel.GetItemPool(); + rPool.FreezeIdRanges(); + if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aFormModel ) ) + { + const SdrObject* pSourceObj = aFormModel.GetPage( 0 )->GetObj( 0 ); + if( pSourceObj ) + { + const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); + SfxItemSet aDest( pObj->GetModel()->GetItemPool(), // ranges from SdrAttrObj + SDRATTR_START, SDRATTR_SHADOW_LAST, + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, + SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, + // Graphic Attributes + SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, + // 3d Properties + SDRATTR_3D_FIRST, SDRATTR_3D_LAST, + // CustomShape properties + SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST, + // range from SdrTextObj + EE_ITEMS_START, EE_ITEMS_END, + // end + 0, 0); + aDest.Set( rSource ); + pObj->SetMergedItemSet( aDest ); + sal_Int32 nAngle = pSourceObj->GetRotateAngle(); + if ( nAngle ) + { + double a = nAngle * F_PI18000; + pObj->NbcRotate( pObj->GetSnapRect().Center(), nAngle, sin( a ), cos( a ) ); + } + bAttributesAppliedFromGallery = sal_True; + } + } + break; + } + } + } + } + if ( !bAttributesAppliedFromGallery ) + { + pObj->SetMergedItem( SvxAdjustItem( SVX_ADJUST_CENTER, 0 ) ); + pObj->SetMergedItem( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_CENTER ) ); + pObj->SetMergedItem( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); + pObj->SetMergedItem( SdrTextAutoGrowHeightItem( sal_False ) ); + ((SdrObjCustomShape*)pObj)->MergeDefaultAttributes( &aCustomShape ); + } +} + +// #i33136# +bool FuConstCustomShape::doConstructOrthogonal() const +{ + return SdrObjCustomShape::doConstructOrthogonal(aCustomShape); +} + +// eof + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuconpol.cxx b/sc/source/ui/drawfunc/fuconpol.cxx new file mode 100644 index 000000000000..d10259e3456e --- /dev/null +++ b/sc/source/ui/drawfunc/fuconpol.cxx @@ -0,0 +1,358 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include "fuconpol.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "drawview.hxx" + +// #98185# Create default drawing objects via keyboard +#include <svx/svdopath.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/point/b2dpoint.hxx> + +// Pixelabstand zum Schliessen von Freihand-Zeichnungen +#ifndef CLOSE_PIXDIST +#define CLOSE_PIXDIST 5 +#endif + +//------------------------------------------------------------------------ + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuConstPolygon::FuConstPolygon(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) + : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuConstPolygon::~FuConstPolygon() +{ +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstPolygon::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt); + + SdrViewEvent aVEvt; + (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt); + if (aVEvt.eEvent == SDREVENT_BEGTEXTEDIT) + { + // Texteingabe hier nicht zulassen + aVEvt.eEvent = SDREVENT_BEGDRAGOBJ; + pView->EnableExtendedMouseEventDispatcher(FALSE); + } + else + { + pView->EnableExtendedMouseEventDispatcher(TRUE); + } + + if ( pView->MouseButtonDown(rMEvt, pWindow) ) + bReturn = TRUE; + + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstPolygon::MouseMove(const MouseEvent& rMEvt) +{ + pView->MouseMove(rMEvt, pWindow); + BOOL bReturn = FuConstruct::MouseMove(rMEvt); + return bReturn; +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstPolygon::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FALSE; + BOOL bSimple = FALSE; + + SdrViewEvent aVEvt; + (void)pView->PickAnything(rMEvt, SDRMOUSEBUTTONUP, aVEvt); + + pView->MouseButtonUp(rMEvt, pWindow); + + if (aVEvt.eEvent == SDREVENT_ENDCREATE) + { + bReturn = TRUE; + bSimple = TRUE; // Doppelklick nicht weiterreichen + } + + BOOL bParent; + if (bSimple) + bParent = FuConstruct::SimpleMouseButtonUp(rMEvt); + else + bParent = FuConstruct::MouseButtonUp(rMEvt); + + return (bParent || bReturn); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuConstPolygon::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FuConstruct::KeyInput(rKEvt); + + return(bReturn); +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuConstPolygon::Activate() +{ + pView->EnableExtendedMouseEventDispatcher(TRUE); + + SdrObjKind eKind; + + switch (GetSlotID()) + { + case SID_DRAW_POLYGON_NOFILL: + case SID_DRAW_XPOLYGON_NOFILL: + { + eKind = OBJ_PLIN; + } + break; + + case SID_DRAW_POLYGON: + case SID_DRAW_XPOLYGON: + { + eKind = OBJ_POLY; + } + break; + + case SID_DRAW_BEZIER_NOFILL: + { + eKind = OBJ_PATHLINE; + } + break; + + case SID_DRAW_BEZIER_FILL: + { + eKind = OBJ_PATHFILL; + } + break; + + case SID_DRAW_FREELINE_NOFILL: + { + eKind = OBJ_FREELINE; + } + break; + + case SID_DRAW_FREELINE: + { + eKind = OBJ_FREEFILL; + } + break; + + default: + { + eKind = OBJ_PATHLINE; + } + break; + } + + pView->SetCurrentObj(sal::static_int_cast<UINT16>(eKind)); + + pView->SetEditMode(SDREDITMODE_CREATE); + + FuConstruct::Activate(); + + aNewPointer = Pointer( POINTER_DRAW_POLYGON ); + aOldPointer = pWindow->GetPointer(); + pViewShell->SetActivePointer( aNewPointer ); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuConstPolygon::Deactivate() +{ + pView->SetEditMode(SDREDITMODE_EDIT); + + pView->EnableExtendedMouseEventDispatcher(FALSE); + + FuConstruct::Deactivate(); + + pViewShell->SetActivePointer( aOldPointer ); +} + +// #98185# Create default drawing objects via keyboard +SdrObject* FuConstPolygon::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) +{ + // case SID_DRAW_POLYGON: + // case SID_DRAW_POLYGON_NOFILL: + // case SID_DRAW_BEZIER_NOFILL: + // case SID_DRAW_FREELINE_NOFILL: + + SdrObject* pObj = SdrObjFactory::MakeNewObject( + pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), + 0L, pDrDoc); + + if(pObj) + { + if(pObj->ISA(SdrPathObj)) + { + basegfx::B2DPolyPolygon aPoly; + + switch(nID) + { + case SID_DRAW_BEZIER_NOFILL: + { + basegfx::B2DPolygon aInnerPoly; + + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom())); + + const basegfx::B2DPoint aCenterBottom(rRectangle.Center().X(), rRectangle.Bottom()); + aInnerPoly.appendBezierSegment( + aCenterBottom, + aCenterBottom, + basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y())); + + const basegfx::B2DPoint aCenterTop(rRectangle.Center().X(), rRectangle.Top()); + aInnerPoly.appendBezierSegment( + aCenterTop, + aCenterTop, + basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top())); + + aPoly.append(aInnerPoly); + break; + } + case SID_DRAW_FREELINE_NOFILL: + { + basegfx::B2DPolygon aInnerPoly; + + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom())); + + aInnerPoly.appendBezierSegment( + basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top()), + basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Top()), + basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Center().Y())); + + aInnerPoly.appendBezierSegment( + basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom()), + basegfx::B2DPoint(rRectangle.Right(), rRectangle.Bottom()), + basegfx::B2DPoint(rRectangle.Right(), rRectangle.Top())); + + aPoly.append(aInnerPoly); + break; + } + case SID_DRAW_POLYGON: + case SID_DRAW_POLYGON_NOFILL: + { + basegfx::B2DPolygon aInnerPoly; + const sal_Int32 nWdt(rRectangle.GetWidth()); + const sal_Int32 nHgt(rRectangle.GetHeight()); + + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Bottom())); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 30) / 100, rRectangle.Top() + (nHgt * 70) / 100)); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left(), rRectangle.Top() + (nHgt * 15) / 100)); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 65) / 100, rRectangle.Top())); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + nWdt, rRectangle.Top() + (nHgt * 30) / 100)); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 50) / 100)); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Left() + (nWdt * 80) / 100, rRectangle.Top() + (nHgt * 75) / 100)); + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Bottom(), rRectangle.Right())); + + if(SID_DRAW_POLYGON_NOFILL == nID) + { + aInnerPoly.append(basegfx::B2DPoint(rRectangle.Center().X(), rRectangle.Bottom())); + } + else + { + aInnerPoly.setClosed(true); + } + + aPoly.append(aInnerPoly); + break; + } + } + + ((SdrPathObj*)pObj)->SetPathPoly(aPoly); + } + else + { + DBG_ERROR("Object is NO path object"); + } + + pObj->SetLogicRect(rRectangle); + } + + return pObj; +} + +// eof + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuconrec.cxx b/sc/source/ui/drawfunc/fuconrec.cxx new file mode 100644 index 000000000000..71d46ea98b7c --- /dev/null +++ b/sc/source/ui/drawfunc/fuconrec.cxx @@ -0,0 +1,317 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include "fuconrec.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "drawview.hxx" + +#include <editeng/outlobj.hxx> +// #98185# Create default drawing objects via keyboard +#include <svx/svdopath.hxx> +#include <svx/svdocapt.hxx> +#include <basegfx/polygon/b2dpolygon.hxx> +#include <basegfx/point/b2dpoint.hxx> + +#include "scresid.hxx" + +//------------------------------------------------------------------------ + + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuConstRectangle::FuConstRectangle(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) + : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuConstRectangle::~FuConstRectangle() +{ +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstRectangle::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt); + + if ( rMEvt.IsLeft() && !pView->IsAction() ) + { + Point aPos( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + + pWindow->CaptureMouse(); + + if ( pView->GetCurrentObjIdentifier() == OBJ_CAPTION ) + { + Size aCaptionSize ( 2268, 1134 ); // 4x2cm + + bReturn = pView->BegCreateCaptionObj( aPos, aCaptionSize ); + + // wie stellt man den Font ein, mit dem geschrieben wird + } + else + bReturn = pView->BegCreateObj(aPos); + } + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstRectangle::MouseMove(const MouseEvent& rMEvt) +{ + return FuConstruct::MouseMove(rMEvt); +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstRectangle::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FALSE; + + if ( pView->IsCreateObj() && rMEvt.IsLeft() ) + { + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pView->EndCreateObj(SDRCREATE_FORCEEND); + + if (aSfxRequest.GetSlot() == SID_DRAW_CAPTION_VERTICAL) + { + // set vertical flag for caption object + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMark(0)) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + // create OutlinerParaObject now so it can be set to vertical + if ( pObj->ISA(SdrTextObj) ) + ((SdrTextObj*)pObj)->ForceOutlinerParaObject(); + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + if( pOPO && !pOPO->IsVertical() ) + pOPO->SetVertical( TRUE ); + } + } + + bReturn = TRUE; + } + return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuConstRectangle::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FuConstruct::KeyInput(rKEvt); + return(bReturn); +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuConstRectangle::Activate() +{ + SdrObjKind aObjKind; + + switch (aSfxRequest.GetSlot() ) + { + case SID_DRAW_LINE: + aNewPointer = Pointer( POINTER_DRAW_LINE ); + aObjKind = OBJ_LINE; + break; + + case SID_DRAW_RECT: + aNewPointer = Pointer( POINTER_DRAW_RECT ); + aObjKind = OBJ_RECT; + break; + + case SID_DRAW_ELLIPSE: + aNewPointer = Pointer( POINTER_DRAW_ELLIPSE ); + aObjKind = OBJ_CIRC; + break; + + case SID_DRAW_CAPTION: + case SID_DRAW_CAPTION_VERTICAL: + aNewPointer = Pointer( POINTER_DRAW_CAPTION ); + aObjKind = OBJ_CAPTION; + break; + + default: + aNewPointer = Pointer( POINTER_CROSS ); + aObjKind = OBJ_RECT; + break; + } + + pView->SetCurrentObj(sal::static_int_cast<UINT16>(aObjKind)); + + aOldPointer = pWindow->GetPointer(); + pViewShell->SetActivePointer( aNewPointer ); + + FuConstruct::Activate(); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuConstRectangle::Deactivate() +{ + FuConstruct::Deactivate(); + pViewShell->SetActivePointer( aOldPointer ); +} + +// #98185# Create default drawing objects via keyboard +SdrObject* FuConstRectangle::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) +{ + // case SID_DRAW_LINE: + // case SID_DRAW_RECT: + // case SID_DRAW_ELLIPSE: + // case SID_DRAW_CAPTION: + // case SID_DRAW_CAPTION_VERTICAL: + + SdrObject* pObj = SdrObjFactory::MakeNewObject( + pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), + 0L, pDrDoc); + + if(pObj) + { + Rectangle aRect(rRectangle); + Point aStart = aRect.TopLeft(); + Point aEnd = aRect.BottomRight(); + + switch(nID) + { + case SID_DRAW_LINE: + { + if(pObj->ISA(SdrPathObj)) + { + sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2); + basegfx::B2DPolygon aPoly; + aPoly.append(basegfx::B2DPoint(aStart.X(), nYMiddle)); + aPoly.append(basegfx::B2DPoint(aEnd.X(), nYMiddle)); + ((SdrPathObj*)pObj)->SetPathPoly(basegfx::B2DPolyPolygon(aPoly)); + } + else + { + DBG_ERROR("Object is NO line object"); + } + + break; + } + case SID_DRAW_CAPTION: + case SID_DRAW_CAPTION_VERTICAL: + { + if(pObj->ISA(SdrCaptionObj)) + { + sal_Bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID); + + ((SdrTextObj*)pObj)->SetVerticalWriting(bIsVertical); + + if(bIsVertical) + { + SfxItemSet aSet(pObj->GetMergedItemSet()); + aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); + aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); + pObj->SetMergedItemSet(aSet); + } + + // #105815# don't set default text, start edit mode instead + // (Edit mode is started in ScTabViewShell::ExecDraw, because + // it must be handled by FuText) + // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT)); + // ((SdrCaptionObj*)pObj)->SetText(aText); + + ((SdrCaptionObj*)pObj)->SetLogicRect(aRect); + ((SdrCaptionObj*)pObj)->SetTailPos( + aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2)); + } + else + { + DBG_ERROR("Object is NO caption object"); + } + + break; + } + + default: + { + pObj->SetLogicRect(aRect); + + break; + } + } + + SfxItemSet aAttr(pDrDoc->GetItemPool()); + pObj->SetMergedItemSet(aAttr); + } + + return pObj; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuconstr.cxx b/sc/source/ui/drawfunc/fuconstr.cxx new file mode 100644 index 000000000000..63b1a34ac221 --- /dev/null +++ b/sc/source/ui/drawfunc/fuconstr.cxx @@ -0,0 +1,337 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <editeng/outliner.hxx> +#include <editeng/outlobj.hxx> +#include <svx/svdotext.hxx> +#include <svx/svdouno.hxx> +#include <sfx2/dispatch.hxx> + +#include "fuconstr.hxx" +#include "fudraw.hxx" +#include "tabvwsh.hxx" +#include "futext.hxx" +#include "sc.hrc" +#include "drawview.hxx" + +// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten +//! fusel,fuconstr,futext - zusammenfassen! +#define SC_MAXDRAGMOVE 3 + +//------------------------------------------------------------------------ + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuConstruct::FuConstruct(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) : + FuDraw(pViewSh, pWin, pViewP, pDoc, rReq) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuConstruct::~FuConstruct() +{ +} + +BYTE FuConstruct::Command(const CommandEvent& rCEvt) +{ + // special code for non-VCL OS2/UNX removed + + return FuDraw::Command( rCEvt ); +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstruct::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuDraw::MouseButtonDown(rMEvt); + + if ( pView->IsAction() ) + { + if ( rMEvt.IsRight() ) + pView->BckAction(); + return TRUE; + } + + aDragTimer.Start(); + + aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); + + if ( rMEvt.IsLeft() ) + { + pWindow->CaptureMouse(); + + SdrHdl* pHdl = pView->PickHandle(aMDPos); + + if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) ) + { + pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, 1); + bReturn = TRUE; + } + else if ( pView->AreObjectsMarked() ) + { + pView->UnmarkAll(); + bReturn = TRUE; + } + } + + bIsInDragMode = FALSE; + + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstruct::MouseMove(const MouseEvent& rMEvt) +{ + FuDraw::MouseMove(rMEvt); + + if (aDragTimer.IsActive() ) + { + Point aOldPixel = pWindow->LogicToPixel( aMDPos ); + Point aNewPixel = rMEvt.GetPosPixel(); + if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE || + Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE ) + aDragTimer.Stop(); + } + + Point aPix(rMEvt.GetPosPixel()); + Point aPnt( pWindow->PixelToLogic(aPix) ); + + if ( pView->IsAction() ) + { + ForceScroll(aPix); + pView->MovAction(aPnt); + } + else + { + SdrHdl* pHdl=pView->PickHandle(aPnt); + + if ( pHdl != NULL ) + { + pViewShell->SetActivePointer(pHdl->GetPointer()); + } + else if ( pView->IsMarkedHit(aPnt) ) + { + pViewShell->SetActivePointer(Pointer(POINTER_MOVE)); + } + else + { + pViewShell->SetActivePointer( aNewPointer ); + } + } + return TRUE; +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstruct::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = SimpleMouseButtonUp( rMEvt ); + + // Doppelklick auf Textobjekt? (->fusel) + + USHORT nClicks = rMEvt.GetClicks(); + if ( nClicks == 2 && rMEvt.IsLeft() ) + { + if ( pView->AreObjectsMarked() ) + { + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + + // #49458# bei Uno-Controls nicht in Textmodus + if ( pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) ) + { + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + BOOL bVertical = ( pOPO && pOPO->IsVertical() ); + USHORT nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT; + + pViewShell->GetViewData()->GetDispatcher(). + Execute(nTextSlotId, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + + // jetzt den erzeugten FuText holen und in den EditModus setzen + FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); + if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // hat keine RTTI + { + FuText* pText = (FuText*)pPoor; + Point aMousePixel = rMEvt.GetPosPixel(); + pText->SetInEditMode( pObj, &aMousePixel ); + } + bReturn = TRUE; + } + } + } + } + + FuDraw::MouseButtonUp(rMEvt); + + return bReturn; +} + +// SimpleMouseButtonUp - ohne Test auf Doppelklick + +BOOL FuConstruct::SimpleMouseButtonUp(const MouseEvent& rMEvt) +{ + BOOL bReturn = TRUE; + + if (aDragTimer.IsActive() ) + { + aDragTimer.Stop(); + } + + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + + if ( pView->IsDragObj() ) + pView->EndDragObj( rMEvt.IsMod1() ); + + else if ( pView->IsMarkObj() ) + pView->EndMarkObj(); + + else bReturn = FALSE; + + if ( !pView->IsAction() ) + { + pWindow->ReleaseMouse(); + + if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 ) + { + pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1()); + + SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher(); + if ( pView->AreObjectsMarked() ) + rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + else + rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + } + } + + return bReturn; +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuConstruct::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FALSE; + + switch ( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_ESCAPE: + if ( pView->IsAction() ) + { + pView->BrkAction(); + pWindow->ReleaseMouse(); + bReturn = TRUE; + } + else // Zeichenmodus beenden + { + pViewShell->GetViewData()->GetDispatcher(). + Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + } + break; + + case KEY_DELETE: + pView->DeleteMarked(); + bReturn = TRUE; + break; + } + + if ( !bReturn ) + { + bReturn = FuDraw::KeyInput(rKEvt); + } + + return(bReturn); +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuConstruct::Activate() +{ + FuDraw::Activate(); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuConstruct::Deactivate() +{ + FuDraw::Deactivate(); +} + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuconuno.cxx b/sc/source/ui/drawfunc/fuconuno.cxx new file mode 100644 index 000000000000..45df699b3e75 --- /dev/null +++ b/sc/source/ui/drawfunc/fuconuno.cxx @@ -0,0 +1,192 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include "fuconuno.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "drawview.hxx" + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuConstUnoControl::FuConstUnoControl(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) + : FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq) +{ + SFX_REQUEST_ARG( rReq, pInventorItem, SfxUInt32Item, SID_FM_CONTROL_INVENTOR, FALSE ); + SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, FALSE ); + if( pInventorItem ) + nInventor = pInventorItem->GetValue(); + if( pIdentifierItem ) + nIdentifier = pIdentifierItem->GetValue(); +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuConstUnoControl::~FuConstUnoControl() +{ +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstUnoControl::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuConstruct::MouseButtonDown(rMEvt); + + if ( rMEvt.IsLeft() && !pView->IsAction() ) + { + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pWindow->CaptureMouse(); + pView->BegCreateObj(aPnt); + bReturn = TRUE; + } + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstUnoControl::MouseMove(const MouseEvent& rMEvt) +{ + return FuConstruct::MouseMove(rMEvt); +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuConstUnoControl::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FALSE; + + if ( pView->IsCreateObj() && rMEvt.IsLeft() ) + { + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + pView->EndCreateObj(SDRCREATE_FORCEEND); + bReturn = TRUE; + } + return (FuConstruct::MouseButtonUp(rMEvt) || bReturn); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuConstUnoControl::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FuConstruct::KeyInput(rKEvt); + return(bReturn); +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuConstUnoControl::Activate() +{ + pView->SetCurrentObj( nIdentifier, nInventor ); + + aNewPointer = Pointer( POINTER_DRAW_RECT ); + aOldPointer = pWindow->GetPointer(); + pViewShell->SetActivePointer( aNewPointer ); + + SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_CONTROLS); + if (pLayer) + pView->SetActiveLayer( pLayer->GetName() ); + + FuConstruct::Activate(); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuConstUnoControl::Deactivate() +{ + FuConstruct::Deactivate(); + + SdrLayer* pLayer = pView->GetModel()->GetLayerAdmin().GetLayerPerID(SC_LAYER_FRONT); + if (pLayer) + pView->SetActiveLayer( pLayer->GetName() ); + + pViewShell->SetActivePointer( aOldPointer ); +} + +// #98185# Create default drawing objects via keyboard +SdrObject* FuConstUnoControl::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& rRectangle) +{ + // case SID_FM_CREATE_CONTROL: + + SdrObject* pObj = SdrObjFactory::MakeNewObject( + pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), + 0L, pDrDoc); + + if(pObj) + { + pObj->SetLogicRect(rRectangle); + } + + return pObj; +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fudraw.cxx b/sc/source/ui/drawfunc/fudraw.cxx new file mode 100644 index 000000000000..db719ce4d901 --- /dev/null +++ b/sc/source/ui/drawfunc/fudraw.cxx @@ -0,0 +1,843 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +//------------------------------------------------------------------------ + +#include <editeng/editeng.hxx> // EditEngine::IsSimpleCharInput +#include <editeng/outlobj.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdocapt.hxx> +#include <svx/svdpage.hxx> +#include <svx/svditer.hxx> +#include <svx/svdundo.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> + +#include "sc.hrc" +#include "fudraw.hxx" +#include "futext.hxx" +#include "tabvwsh.hxx" +#include "drwlayer.hxx" +#include "scresid.hxx" +#include "userdat.hxx" +#include "docsh.hxx" +#include "postit.hxx" +#include "globstr.hrc" +#include "drawview.hxx" + +/************************************************************************* +|* +|* Basisklasse fuer alle Drawmodul-spezifischen Funktionen +|* +\************************************************************************/ + +FuDraw::FuDraw(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) : + FuPoor (pViewSh, pWin, pViewP, pDoc, rReq), + aNewPointer ( POINTER_ARROW ), + aOldPointer ( POINTER_ARROW ) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuDraw::~FuDraw() +{ +} + +/************************************************************************* +|* +|* Modifier-Tasten auswerten +|* +\************************************************************************/ + +void FuDraw::DoModifiers(const MouseEvent& rMEvt) +{ + // Shift = Ortho und AngleSnap + // Control = Snap (Toggle) + // Alt = zentrisch + + BOOL bShift = rMEvt.IsShift(); +// BOOL bCtrl = rMEvt.IsMod1(); + BOOL bAlt = rMEvt.IsMod2(); + +// ScViewData* pViewData = pViewShell->GetViewData(); +// const ScViewOptions& rOpt = pViewData->GetOptions(); +// const ScGridOptions& rGrid = rOpt.GetGridOptions(); +// BOOL bGridOpt = rGrid.GetUseGridSnap(); + + BOOL bOrtho = bShift; + BOOL bAngleSnap = bShift; +// BOOL bGridSnap = ( bGridOpt != bCtrl ); // andere Snap's nicht unterstuetzt + BOOL bCenter = bAlt; + + // #i33136# + if(doConstructOrthogonal()) + { + bOrtho = !bShift; + } + + if (pView->IsOrtho() != bOrtho) + pView->SetOrtho(bOrtho); + if (pView->IsAngleSnapEnabled() != bAngleSnap) + pView->SetAngleSnapEnabled(bAngleSnap); + +/* Control fuer Snap beisst sich beim Verschieben mit "kopieren" !!! + + if (pView->IsGridSnap() != bGridSnap) + pView->SetGridSnap(bGridSnap); + if (pView->IsSnapEnabled() != bGridSnap) + pView->SetSnapEnabled(bGridSnap); +*/ + if (pView->IsCreate1stPointAsCenter() != bCenter) + pView->SetCreate1stPointAsCenter(bCenter); + if (pView->IsResizeAtCenter() != bCenter) + pView->SetResizeAtCenter(bCenter); + +} + +void FuDraw::ResetModifiers() +{ + ScViewData* pViewData = pViewShell->GetViewData(); + const ScViewOptions& rOpt = pViewData->GetOptions(); + const ScGridOptions& rGrid = rOpt.GetGridOptions(); + BOOL bGridOpt = rGrid.GetUseGridSnap(); + + if (pView->IsOrtho()) + pView->SetOrtho(FALSE); + if (pView->IsAngleSnapEnabled()) + pView->SetAngleSnapEnabled(FALSE); + + if (pView->IsGridSnap() != bGridOpt) + pView->SetGridSnap(bGridOpt); + if (pView->IsSnapEnabled() != bGridOpt) + pView->SetSnapEnabled(bGridOpt); + + if (pView->IsCreate1stPointAsCenter()) + pView->SetCreate1stPointAsCenter(FALSE); + if (pView->IsResizeAtCenter()) + pView->SetResizeAtCenter(FALSE); +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuDraw::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + DoModifiers( rMEvt ); + return FALSE; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuDraw::MouseMove(const MouseEvent& rMEvt) +{ + // #106438# evaluate modifiers only if in a drawing layer action + // (don't interfere with keyboard shortcut handling) + if (pView->IsAction()) + DoModifiers( rMEvt ); + + return FALSE; +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuDraw::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + ResetModifiers(); + return FALSE; +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL lcl_KeyEditMode( SdrObject* pObj, ScTabViewShell* pViewShell, const KeyEvent* pInitialKey ) +{ + BOOL bReturn = FALSE; + if ( pObj && pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) ) + { + // start text edit - like FuSelection::MouseButtonUp, + // but with bCursorToEnd instead of mouse position + + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + BOOL bVertical = ( pOPO && pOPO->IsVertical() ); + USHORT nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT; + + // don't switch shells if text shell is already active + FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); + if ( !pPoor || pPoor->GetSlotID() != nTextSlotId ) + { + pViewShell->GetViewData()->GetDispatcher(). + Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); + } + + // get the resulting FuText and set in edit mode + pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); + if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // no RTTI + { + FuText* pText = (FuText*)pPoor; + pText->SetInEditMode( pObj, NULL, TRUE, pInitialKey ); + //! set cursor to end of text + } + bReturn = TRUE; + } + return bReturn; +} + +BOOL __EXPORT FuDraw::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FALSE; + ScViewData& rViewData = *pViewShell->GetViewData(); + + switch ( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_ESCAPE: + if ( pViewShell->IsDrawTextShell() || aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT ) + { + // in normale Draw-Shell, wenn Objekt selektiert, sonst Zeichnen aus + rViewData.GetDispatcher().Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + bReturn = TRUE; + } + else if ( pViewShell->IsDrawSelMode() ) + { + pView->UnmarkAll(); + rViewData.GetDispatcher().Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + bReturn = TRUE; + } + else if ( pView->AreObjectsMarked() ) + { + // #97016# III + SdrHdlList& rHdlList = const_cast< SdrHdlList& >( pView->GetHdlList() ); + if( rHdlList.GetFocusHdl() ) + rHdlList.ResetFocusHdl(); + else + pView->UnmarkAll(); + + // Beim Bezier-Editieren ist jetzt wieder das Objekt selektiert + if (!pView->AreObjectsMarked()) + pViewShell->SetDrawShell( FALSE ); + + bReturn = TRUE; + } + break; + + case KEY_DELETE: //! ueber Accelerator + pView->DeleteMarked(); + bReturn = TRUE; + break; + + case KEY_RETURN: + { + if( rKEvt.GetKeyCode().GetModifier() == 0 ) + { + // #98256# activate OLE object on RETURN for selected object + // #98198# put selected text object in edit mode + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() ) + { + BOOL bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace(); + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if( pObj && pObj->ISA( SdrOle2Obj ) && !bOle ) + { + //HMHpView->HideMarkHdl(); + pViewShell->ActivateObject( static_cast< SdrOle2Obj* >( pObj ), 0 ); + + // consumed + bReturn = TRUE; + } + else if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) ) // start text edit for suitable object + bReturn = TRUE; + } + } + } + break; + + case KEY_F2: + { + if( rKEvt.GetKeyCode().GetModifier() == 0 ) + { + // #98198# put selected text object in edit mode + // (this is not SID_SETINPUTMODE, but F2 hardcoded, like in Writer) + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if ( lcl_KeyEditMode( pObj, pViewShell, NULL ) ) // start text edit for suitable object + bReturn = TRUE; + } + } + } + break; + + // #97016# + case KEY_TAB: + { + // in calc do NOT start draw object selection using TAB/SHIFT-TAB when + // there is not yet a object selected + if(pView->AreObjectsMarked()) + { + KeyCode aCode = rKEvt.GetKeyCode(); + + if ( !aCode.IsMod1() && !aCode.IsMod2() ) + { + // changeover to the next object + if(!pView->MarkNextObj( !aCode.IsShift() )) + { + // #97016# No next object: go over open end and + // get first from the other side + pView->UnmarkAllObj(); + pView->MarkNextObj(!aCode.IsShift()); + } + + // #97016# II + if(pView->AreObjectsMarked()) + pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow); + + bReturn = TRUE; + } + + // #98994# handle Mod1 and Mod2 to get travelling running on different systems + if(rKEvt.GetKeyCode().IsMod1() || rKEvt.GetKeyCode().IsMod2()) + { + // #97016# II do something with a selected handle? + const SdrHdlList& rHdlList = pView->GetHdlList(); + sal_Bool bForward(!rKEvt.GetKeyCode().IsShift()); + + ((SdrHdlList&)rHdlList).TravelFocusHdl(bForward); + + // guarantee visibility of focused handle + SdrHdl* pHdl = rHdlList.GetFocusHdl(); + + if(pHdl) + { + Point aHdlPosition(pHdl->GetPos()); + Rectangle aVisRect(aHdlPosition - Point(100, 100), Size(200, 200)); + pView->MakeVisible(aVisRect, *pWindow); + } + + // consumed + bReturn = TRUE; + } + } + } + break; + + // #97016# + case KEY_END: + { + // in calc do NOT select the last draw object when + // there is not yet a object selected + if(pView->AreObjectsMarked()) + { + KeyCode aCode = rKEvt.GetKeyCode(); + + if ( aCode.IsMod1() ) + { + // #97016# mark last object + pView->UnmarkAllObj(); + pView->MarkNextObj(FALSE); + + // #97016# II + if(pView->AreObjectsMarked()) + pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow); + + bReturn = TRUE; + } + } + } + break; + + // #97016# + case KEY_HOME: + { + // in calc do NOT select the first draw object when + // there is not yet a object selected + if(pView->AreObjectsMarked()) + { + KeyCode aCode = rKEvt.GetKeyCode(); + + if ( aCode.IsMod1() ) + { + // #97016# mark first object + pView->UnmarkAllObj(); + pView->MarkNextObj(TRUE); + + // #97016# II + if(pView->AreObjectsMarked()) + pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow); + + bReturn = TRUE; + } + } + } + break; + + // #97016# + case KEY_UP: + case KEY_DOWN: + case KEY_LEFT: + case KEY_RIGHT: + { + // in calc do cursor travelling of draw objects only when + // there is a object selected yet + if(pView->AreObjectsMarked()) + { + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if(rMarkList.GetMarkCount() == 1) + { + // disable cursor travelling on note objects as the tail connector position + // must not move. + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if( ScDrawLayer::IsNoteCaption( pObj ) ) + break; + } + + long nX = 0; + long nY = 0; + USHORT nCode = rKEvt.GetKeyCode().GetCode(); + + if (nCode == KEY_UP) + { + // Scroll nach oben + nX = 0; + nY =-1; + } + else if (nCode == KEY_DOWN) + { + // Scroll nach unten + nX = 0; + nY = 1; + } + else if (nCode == KEY_LEFT) + { + // Scroll nach links + nX =-1; + nY = 0; + } + else if (nCode == KEY_RIGHT) + { + // Scroll nach rechts + nX = 1; + nY = 0; + } + + BOOL bReadOnly = rViewData.GetDocShell()->IsReadOnly(); + + if(!rKEvt.GetKeyCode().IsMod1() && !bReadOnly) + { + if(rKEvt.GetKeyCode().IsMod2()) + { + // #97016# move in 1 pixel distance + Size aLogicSizeOnePixel = (pWindow) ? pWindow->PixelToLogic(Size(1,1)) : Size(100, 100); + nX *= aLogicSizeOnePixel.Width(); + nY *= aLogicSizeOnePixel.Height(); + } + else + { + // old, fixed move distance + nX *= 100; + nY *= 100; + } + + // is there a movement to do? + if(0 != nX || 0 != nY) + { + // #97016# II + const SdrHdlList& rHdlList = pView->GetHdlList(); + SdrHdl* pHdl = rHdlList.GetFocusHdl(); + + if(0L == pHdl) + { + // #107086# only take action when move is allowed + if(pView->IsMoveAllowed()) + { + // #90129# restrict movement to WorkArea + const Rectangle& rWorkArea = pView->GetWorkArea(); + + if(!rWorkArea.IsEmpty()) + { + Rectangle aMarkRect(pView->GetMarkedObjRect()); + aMarkRect.Move(nX, nY); + + if(!aMarkRect.IsInside(rWorkArea)) + { + if(aMarkRect.Left() < rWorkArea.Left()) + { + nX += rWorkArea.Left() - aMarkRect.Left(); + } + + if(aMarkRect.Right() > rWorkArea.Right()) + { + nX -= aMarkRect.Right() - rWorkArea.Right(); + } + + if(aMarkRect.Top() < rWorkArea.Top()) + { + nY += rWorkArea.Top() - aMarkRect.Top(); + } + + if(aMarkRect.Bottom() > rWorkArea.Bottom()) + { + nY -= aMarkRect.Bottom() - rWorkArea.Bottom(); + } + } + } + + // now move the selected draw objects + pView->MoveAllMarked(Size(nX, nY)); + + // #97016# II + pView->MakeVisible(pView->GetAllMarkedRect(), *pWindow); + + bReturn = TRUE; + } + } + else + { + // move handle with index nHandleIndex + if(pHdl && (nX || nY)) + { + // now move the Handle (nX, nY) + Point aStartPoint(pHdl->GetPos()); + Point aEndPoint(pHdl->GetPos() + Point(nX, nY)); + const SdrDragStat& rDragStat = pView->GetDragStat(); + + // start dragging + pView->BegDragObj(aStartPoint, 0, pHdl, 0); + + if(pView->IsDragObj()) + { + bool bWasNoSnap = rDragStat.IsNoSnap(); + BOOL bWasSnapEnabled = pView->IsSnapEnabled(); + + // switch snapping off + if(!bWasNoSnap) + ((SdrDragStat&)rDragStat).SetNoSnap(TRUE); + if(bWasSnapEnabled) + pView->SetSnapEnabled(FALSE); + + pView->MovAction(aEndPoint); + pView->EndDragObj(); + + // restore snap + if(!bWasNoSnap) + ((SdrDragStat&)rDragStat).SetNoSnap(bWasNoSnap); + if(bWasSnapEnabled) + pView->SetSnapEnabled(bWasSnapEnabled); + } + + // make moved handle visible + Rectangle aVisRect(aEndPoint - Point(100, 100), Size(200, 200)); + pView->MakeVisible(aVisRect, *pWindow); + + bReturn = TRUE; + } + } + } + } + } + } + break; + + // #97016# + case KEY_SPACE: + { + // in calc do only something when draw objects are selected + if(pView->AreObjectsMarked()) + { + const SdrHdlList& rHdlList = pView->GetHdlList(); + SdrHdl* pHdl = rHdlList.GetFocusHdl(); + + if(pHdl) + { + if(pHdl->GetKind() == HDL_POLY) + { + // rescue ID of point with focus + sal_uInt32 nPol(pHdl->GetPolyNum()); + sal_uInt32 nPnt(pHdl->GetPointNum()); + + if(pView->IsPointMarked(*pHdl)) + { + if(rKEvt.GetKeyCode().IsShift()) + { + pView->UnmarkPoint(*pHdl); + } + } + else + { + if(!rKEvt.GetKeyCode().IsShift()) + { + pView->UnmarkAllPoints(); + } + + pView->MarkPoint(*pHdl); + } + + if(0L == rHdlList.GetFocusHdl()) + { + // restore point with focus + SdrHdl* pNewOne = 0L; + + for(sal_uInt32 a(0); !pNewOne && a < rHdlList.GetHdlCount(); a++) + { + SdrHdl* pAct = rHdlList.GetHdl(a); + + if(pAct + && pAct->GetKind() == HDL_POLY + && pAct->GetPolyNum() == nPol + && pAct->GetPointNum() == nPnt) + { + pNewOne = pAct; + } + } + + if(pNewOne) + { + ((SdrHdlList&)rHdlList).SetFocusHdl(pNewOne); + } + } + + bReturn = TRUE; + } + } + } + } + break; + } + + if (!bReturn) + { + bReturn = FuPoor::KeyInput(rKEvt); + } + + if (!bReturn) + { + // #98198# allow direct typing into a selected text object + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( !pView->IsTextEdit() && 1 == rMarkList.GetMarkCount() && EditEngine::IsSimpleCharInput(rKEvt) ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + // start text edit for suitable object, pass key event to OutlinerView + if ( lcl_KeyEditMode( pObj, pViewShell, &rKEvt ) ) + bReturn = TRUE; + } + } + + return (bReturn); +} + +// #97016# II +void FuDraw::SelectionHasChanged() +{ + const SdrHdlList& rHdlList = pView->GetHdlList(); + ((SdrHdlList&)rHdlList).ResetFocusHdl(); +} + +/************************************************************************* +|* +|* Vor dem Scrollen Selektionsdarstellung ausblenden +|* +\************************************************************************/ + +void FuDraw::ScrollStart() +{ +// HideShownXor in Gridwin +} + +/************************************************************************* +|* +|* Nach dem Scrollen Selektionsdarstellung wieder anzeigen +|* +\************************************************************************/ + +void FuDraw::ScrollEnd() +{ +// ShowShownXor in Gridwin +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuDraw::Activate() +{ + FuPoor::Activate(); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuDraw::Deactivate() +{ + FuPoor::Deactivate(); +} + +/************************************************************************* +|* +|* Maus-Pointer umschalten +|* +\************************************************************************/ + +BOOL lcl_UrlHit( SdrView* pView, const Point& rPosPixel, Window* pWindow ) +{ + SdrViewEvent aVEvt; + MouseEvent aMEvt( rPosPixel, 1, 0, MOUSE_LEFT ); + SdrHitKind eHit = pView->PickAnything( aMEvt, SDRMOUSEBUTTONDOWN, aVEvt ); + + if ( eHit != SDRHIT_NONE && aVEvt.pObj != NULL ) + { + if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) && ScDrawLayer::GetHitIMapObject( + aVEvt.pObj, pWindow->PixelToLogic(rPosPixel), *pWindow ) ) + return TRUE; + + if ( aVEvt.eEvent == SDREVENT_EXECUTEURL ) + return TRUE; + } + + return FALSE; +} + +void FuDraw::ForcePointer(const MouseEvent* pMEvt) +{ + if ( !pView->IsAction() ) + { + Point aPosPixel = pWindow->GetPointerPosPixel(); + BOOL bAlt = pMEvt && pMEvt->IsMod2(); + Point aPnt = pWindow->PixelToLogic( aPosPixel ); + SdrHdl* pHdl = pView->PickHandle(aPnt); + SdrObject* pObj; + SdrPageView* pPV; + + ScMacroInfo* pInfo = 0; + if ( pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER) ) + { + if ( pObj->IsGroupObject() ) + { + SdrObject* pHit = 0; + if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) ) + pObj = pHit; + } + pInfo = ScDrawLayer::GetMacroInfo( pObj ); + } + + if ( pView->IsTextEdit() ) + { + pViewShell->SetActivePointer(Pointer(POINTER_TEXT)); // kann nicht sein ? + } + else if ( pHdl ) + { + pViewShell->SetActivePointer( + pView->GetPreferedPointer( aPnt, pWindow ) ); + } + else if ( pView->IsMarkedHit(aPnt) ) + { + pViewShell->SetActivePointer( Pointer(POINTER_MOVE) ); + } + else if ( !bAlt && ( !pMEvt || !pMEvt->GetButtons() ) + && lcl_UrlHit( pView, aPosPixel, pWindow ) ) + { + // kann mit ALT unterdrueckt werden + pWindow->SetPointer( Pointer( POINTER_REFHAND ) ); // Text-URL / ImageMap + } + else if ( !bAlt && pView->PickObj(aPnt, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) ) + { + // kann mit ALT unterdrueckt werden + SdrObjMacroHitRec aHitRec; //! muss da noch irgendwas gesetzt werden ???? + pViewShell->SetActivePointer( pObj->GetMacroPointer(aHitRec) ); + } + else if ( !bAlt && pInfo && ((pInfo->GetMacro().getLength() > 0) || (pInfo->GetHlink().getLength() > 0)) ) + pWindow->SetPointer( Pointer( POINTER_REFHAND ) ); + else if ( IsDetectiveHit( aPnt ) ) + pViewShell->SetActivePointer( Pointer( POINTER_DETECTIVE ) ); + else + pViewShell->SetActivePointer( aNewPointer ); //! in Gridwin? + } +} + +BOOL FuDraw::IsSizingOrMovingNote( const MouseEvent& rMEvt ) const +{ + BOOL bIsSizingOrMoving = FALSE; + if ( rMEvt.IsLeft() ) + { + const SdrMarkList& rNoteMarkList = pView->GetMarkedObjectList(); + if(rNoteMarkList.GetMarkCount() == 1) + { + SdrObject* pObj = rNoteMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if ( ScDrawLayer::IsNoteCaption( pObj ) ) + { + Point aMPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); + bIsSizingOrMoving = + pView->PickHandle( aMPos ) || // handles to resize the note + pView->IsTextEditFrameHit( aMPos ); // frame for moving the note + } + } + } + return bIsSizingOrMoving; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuins1.cxx b/sc/source/ui/drawfunc/fuins1.cxx new file mode 100644 index 000000000000..41501905fe61 --- /dev/null +++ b/sc/source/ui/drawfunc/fuins1.cxx @@ -0,0 +1,436 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <sfx2/opengrf.hxx> +#include <svx/svdograf.hxx> +#include <svx/svdomedia.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdview.hxx> +#include <svx/linkwarn.hxx> +#include <svtools/filter.hxx> +#include <svl/stritem.hxx> +#include <svtools/miscopt.hxx> +#include <vcl/msgbox.hxx> +#include <tools/urlobj.hxx> +#include <avmedia/mediawindow.hxx> +#include <vcl/svapp.hxx> + +#include "fuinsert.hxx" +#include "tabvwsh.hxx" +#include "drwlayer.hxx" +#include "drawview.hxx" +#include "document.hxx" +#include "scresid.hxx" +#include "progress.hxx" +#include "sc.hrc" + + + +////======================================================================== +//// class ImportProgress +//// +//// Bemerkung: +//// Diese Klasse stellt lediglich den Handler fuer den ImportProgress des +//// Grafikfilters bereit. +////======================================================================== +// +//class ImportProgress +//{ +//public: +// ImportProgress( GraphicFilter& rFilter ); +// ~ImportProgress(); +// +// DECL_LINK( Update, GraphicFilter* ); +// +//private: +// ScProgress aProgress; +//}; +// +////------------------------------------------------------------------------ +// +//ImportProgress::ImportProgress( GraphicFilter& rFilter ) +// : aProgress( NULL, // SfxViewFrame*, NULL == alle Docs locken +// String( ScResId(STR_INSERTGRAPHIC) ), +// 100 ) +//{ +// rFilter.SetUpdatePercentHdl( LINK( this, ImportProgress, Update) ); +//} +// +////------------------------------------------------------------------------ +// +//__EXPORT ImportProgress::~ImportProgress() +//{ +// aProgress.SetState( 100 ); +//} +// +////------------------------------------------------------------------------ +// +//IMPL_LINK( ImportProgress, Update, GraphicFilter*, pGraphicFilter ) +//{ +// aProgress.SetState( pGraphicFilter->GetPercent() ); +// return 0; +//} + + +//------------------------------------------------------------------------ + +void SC_DLLPUBLIC ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage ) +{ + if ( !rPage.Width() || !rPage.Height() ) + return; + + Size aPageSize = rPage; + BOOL bNegative = aPageSize.Width() < 0; + if ( bNegative ) + { + // make everything positive temporarily + aPageSize.Width() = -aPageSize.Width(); + rPos.X() = -rPos.X() - rSize.Width(); + } + + if ( rSize.Width() > aPageSize.Width() || rSize.Height() > aPageSize.Height() ) + { + double fX = aPageSize.Width() / (double) rSize.Width(); + double fY = aPageSize.Height() / (double) rSize.Height(); + + if ( fX < fY ) + { + rSize.Width() = aPageSize.Width(); + rSize.Height() = (long) ( rSize.Height() * fX ); + } + else + { + rSize.Height() = aPageSize.Height(); + rSize.Width() = (long) ( rSize.Width() * fY ); + } + + if (!rSize.Width()) + rSize.Width() = 1; + if (!rSize.Height()) + rSize.Height() = 1; + } + + if ( rPos.X() + rSize.Width() > aPageSize.Width() ) + rPos.X() = aPageSize.Width() - rSize.Width(); + if ( rPos.Y() + rSize.Height() > aPageSize.Height() ) + rPos.Y() = aPageSize.Height() - rSize.Height(); + + if ( bNegative ) + rPos.X() = -rPos.X() - rSize.Width(); // back to real position +} + +//------------------------------------------------------------------------ + +void lcl_InsertGraphic( const Graphic& rGraphic, + const String& rFileName, const String& rFilterName, BOOL bAsLink, BOOL bApi, + ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView ) +{ + // #74778# set the size so the graphic has its original pixel size + // at 100% view scale (as in SetMarkedOriginalSize), + // instead of respecting the current view scale + + ScDrawView* pDrawView = pViewSh->GetScDrawView(); + MapMode aSourceMap = rGraphic.GetPrefMapMode(); + MapMode aDestMap( MAP_100TH_MM ); + if ( aSourceMap.GetMapUnit() == MAP_PIXEL && pDrawView ) + { + Fraction aScaleX, aScaleY; + pDrawView->CalcNormScale( aScaleX, aScaleY ); + aDestMap.SetScaleX(aScaleX); + aDestMap.SetScaleY(aScaleY); + } + Size aLogicSize = pWindow->LogicToLogic( + rGraphic.GetPrefSize(), &aSourceMap, &aDestMap ); + + // Limit size + + SdrPageView* pPV = pView->GetSdrPageView(); + SdrPage* pPage = pPV->GetPage(); + Point aInsertPos = pViewSh->GetInsertPos(); + + ScViewData* pData = pViewSh->GetViewData(); + if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) ) + aInsertPos.X() -= aLogicSize.Width(); // move position to left edge + + ScLimitSizeOnDrawPage( aLogicSize, aInsertPos, pPage->GetSize() ); + + Rectangle aRect ( aInsertPos, aLogicSize ); + + SdrGrafObj* pObj = new SdrGrafObj( rGraphic, aRect ); + + // #118522# calling SetGraphicLink here doesn't work + + // #49961# Path is no longer used as name for the graphics object + + ScDrawLayer* pLayer = (ScDrawLayer*) pView->GetModel(); + String aName = pLayer->GetNewGraphicName(); // "Grafik x" + pObj->SetName(aName); + + // don't select if from (dispatch) API, to allow subsequent cell operations + ULONG nInsOptions = bApi ? SDRINSERT_DONTMARK : 0; + pView->InsertObjectAtView( pObj, *pPV, nInsOptions ); + + // #118522# SetGraphicLink has to be used after inserting the object, + // otherwise an empty graphic is swapped in and the contact stuff crashes. + // See #i37444#. + if ( bAsLink ) + pObj->SetGraphicLink( rFileName, rFilterName ); +} + +//------------------------------------------------------------------------ + +void lcl_InsertMedia( const ::rtl::OUString& rMediaURL, bool bApi, + ScTabViewShell* pViewSh, Window* pWindow, SdrView* pView, + const Size& rPrefSize ) +{ + SdrPageView* pPV = pView->GetSdrPageView(); + SdrPage* pPage = pPV->GetPage(); + ScViewData* pData = pViewSh->GetViewData(); + Point aInsertPos( pViewSh->GetInsertPos() ); + Size aSize; + + if( rPrefSize.Width() && rPrefSize.Height() ) + { + if( pWindow ) + aSize = pWindow->PixelToLogic( rPrefSize, MAP_100TH_MM ); + else + aSize = Application::GetDefaultDevice()->PixelToLogic( rPrefSize, MAP_100TH_MM ); + } + else + aSize = Size( 5000, 5000 ); + + ScLimitSizeOnDrawPage( aSize, aInsertPos, pPage->GetSize() ); + + if( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) ) + aInsertPos.X() -= aSize.Width(); + + SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aInsertPos, aSize ) ); + + pObj->setURL( rMediaURL ); + pView->InsertObjectAtView( pObj, *pPV, bApi ? SDRINSERT_DONTMARK : 0 ); +} + +/************************************************************************* +|* +|* FuInsertGraphic::Konstruktor +|* +\************************************************************************/ + +#ifdef _MSC_VER +#pragma optimize("",off) +#endif + +FuInsertGraphic::FuInsertGraphic( ScTabViewShell* pViewSh, + Window* pWin, + ScDrawView* pViewP, + SdrModel* pDoc, + SfxRequest& rReq ) + : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq) +{ + const SfxItemSet* pReqArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + if ( pReqArgs && + pReqArgs->GetItemState( SID_INSERT_GRAPHIC, TRUE, &pItem ) == SFX_ITEM_SET ) + { + String aFileName = ((const SfxStringItem*)pItem)->GetValue(); + + String aFilterName; + if ( pReqArgs->GetItemState( FN_PARAM_FILTER, TRUE, &pItem ) == SFX_ITEM_SET ) + aFilterName = ((const SfxStringItem*)pItem)->GetValue(); + + BOOL bAsLink = FALSE; + if ( pReqArgs->GetItemState( FN_PARAM_1, TRUE, &pItem ) == SFX_ITEM_SET ) + bAsLink = ((const SfxBoolItem*)pItem)->GetValue(); + + Graphic aGraphic; + int nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, GraphicFilter::GetGraphicFilter() ); + if ( nError == GRFILTER_OK ) + { + lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, TRUE, pViewSh, pWindow, pView ); + } + } + else + { + SvxOpenGraphicDialog aDlg(ScResId(STR_INSERTGRAPHIC)); + + if( aDlg.Execute() == GRFILTER_OK ) + { + Graphic aGraphic; + int nError = aDlg.GetGraphic(aGraphic); + if( nError == GRFILTER_OK ) + { + String aFileName = aDlg.GetPath(); + String aFilterName = aDlg.GetCurrentFilter(); + BOOL bAsLink = aDlg.IsAsLink(); + + // really store as link only? + if( bAsLink && SvtMiscOptions().ShowLinkWarningDialog() ) + { + SvxLinkWarningDialog aWarnDlg(pWin,aFileName); + if( aWarnDlg.Execute() != RET_OK ) + bAsLink = sal_False; // don't store as link + } + + lcl_InsertGraphic( aGraphic, aFileName, aFilterName, bAsLink, FALSE, pViewSh, pWindow, pView ); + + // append items for recording + rReq.AppendItem( SfxStringItem( SID_INSERT_GRAPHIC, aFileName ) ); + rReq.AppendItem( SfxStringItem( FN_PARAM_FILTER, aFilterName ) ); + rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bAsLink ) ); + rReq.Done(); + } + else + { + // error is handled in SvxOpenGraphicDialog::GetGraphic + } + } + } +} + +/************************************************************************* +|* +|* FuInsertGraphic::Destruktor +|* +\************************************************************************/ + +FuInsertGraphic::~FuInsertGraphic() +{ +} + +/************************************************************************* +|* +|* FuInsertGraphic::Function aktivieren +|* +\************************************************************************/ + +void FuInsertGraphic::Activate() +{ + FuPoor::Activate(); +} + +/************************************************************************* +|* +|* FuInsertGraphic::Function deaktivieren +|* +\************************************************************************/ + +void FuInsertGraphic::Deactivate() +{ + FuPoor::Deactivate(); +} + +/************************************************************************* +|* +|* FuInsertMedia::Konstruktor +|* +\************************************************************************/ + +FuInsertMedia::FuInsertMedia( ScTabViewShell* pViewSh, + Window* pWin, + ScDrawView* pViewP, + SdrModel* pDoc, + SfxRequest& rReq ) : + FuPoor(pViewSh, pWin, pViewP, pDoc, rReq) +{ + ::rtl::OUString aURL; + const SfxItemSet* pReqArgs = rReq.GetArgs(); + bool bAPI = false; + + if( pReqArgs ) + { + const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) ); + + if( pStringItem ) + { + aURL = pStringItem->GetValue(); + bAPI = aURL.getLength(); + } + } + + if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) ) + { + Size aPrefSize; + + if( pWin ) + pWin->EnterWait(); + + if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) ) + { + if( pWin ) + pWin->LeaveWait(); + + if( !bAPI ) + ::avmedia::MediaWindow::executeFormatErrorBox( pWindow ); + } + else + { + lcl_InsertMedia( aURL, bAPI, pViewSh, pWindow, pView, aPrefSize ); + + if( pWin ) + pWin->LeaveWait(); + } + } +} + +/************************************************************************* +|* +|* FuInsertMedia::Destruktor +|* +\************************************************************************/ + +FuInsertMedia::~FuInsertMedia() +{ +} + +/************************************************************************* +|* +|* FuInsertMedia::Function aktivieren +|* +\************************************************************************/ + +void FuInsertMedia::Activate() +{ + FuPoor::Activate(); +} + +/************************************************************************* +|* +|* FuInsertMedia::Function deaktivieren +|* +\************************************************************************/ + +void FuInsertMedia::Deactivate() +{ + FuPoor::Deactivate(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx new file mode 100644 index 000000000000..c45ae623912d --- /dev/null +++ b/sc/source/ui/drawfunc/fuins2.cxx @@ -0,0 +1,851 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + +#include <com/sun/star/embed/NoVisualAreaSizeException.hpp> +#include <com/sun/star/embed/Aspects.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +//------------------------------------------------------------------------ + +#include <toolkit/helper/vclunohelper.hxx> +#include <sot/exchange.hxx> +#include <svl/globalnameitem.hxx> +#include <sfx2/viewfrm.hxx> +#include <sfx2/docfile.hxx> +#include <svl/stritem.hxx> +#include <svx/svdoole2.hxx> +#include <svx/pfiledlg.hxx> +#include <tools/urlobj.hxx> +#include <vcl/msgbox.hxx> +#include <svl/urihelper.hxx> +#include <unotools/moduleoptions.hxx> +#include <svtools/insdlg.hxx> +#include <svtools/soerr.hxx> +#include <svx/svxdlg.hxx> +#include <sot/clsids.hxx> +#include <svx/svdpagv.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdundo.hxx> + + +// BM/IHA -- +#include <cppuhelper/component_context.hxx> +#include <comphelper/processfactory.hxx> +#include <comphelper/storagehelper.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XSynchronousFrameLoader.hpp> +#include <com/sun/star/frame/XComponentLoader.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/chart2/data/XDataProvider.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <cppuhelper/bootstrap.hxx> + +using namespace ::com::sun::star; +// BM/IHA -- + +// erAck +#include "chart2uno.hxx" +// erAck + +#include "fuinsert.hxx" +#include "tabvwsh.hxx" +#include "sc.hrc" +#include "chartarr.hxx" +#include "docsh.hxx" +#include "document.hxx" +#include "undotab.hxx" +#include "chartlis.hxx" +#include "uiitems.hxx" +#include "globstr.hrc" +#include "drawview.hxx" + +extern SdrObject* pSkipPaintObj; // output.cxx - dieses Objekt nicht zeichnen + +//------------------------------------------------------------------------ + +#define IS_AVAILABLE(WhichId,ppItem) \ + (pReqArgs->GetItemState((WhichId), TRUE, ppItem ) == SFX_ITEM_SET) + +void lcl_ChartInit( const uno::Reference < embed::XEmbeddedObject >& xObj, ScViewData* pViewData, + const rtl::OUString& rRangeParam ) +{ + ScDocShell* pDocShell = pViewData->GetDocShell(); + ScDocument* pScDoc = pDocShell->GetDocument(); + + rtl::OUString aRangeString( rRangeParam ); + if ( !aRangeString.getLength() ) + { + SCCOL nCol1 = 0; + SCROW nRow1 = 0; + SCTAB nTab1 = 0; + SCCOL nCol2 = 0; + SCROW nRow2 = 0; + SCTAB nTab2 = 0; + + ScMarkData& rMark = pViewData->GetMarkData(); + if ( !rMark.IsMarked() ) + pViewData->GetView()->MarkDataArea( TRUE ); + + if ( pViewData->GetSimpleArea( nCol1,nRow1,nTab1, nCol2,nRow2,nTab2 ) == SC_MARK_SIMPLE ) + { + PutInOrder( nCol1, nCol2 ); + PutInOrder( nRow1, nRow2 ); + if ( nCol2>nCol1 || nRow2>nRow1 ) + { + ScDocument* pDoc = pViewData->GetDocument(); + pDoc->LimitChartArea( nTab1, nCol1,nRow1, nCol2,nRow2 ); + + String aStr; + ScRange aRange( nCol1, nRow1, nTab1, nCol2, nRow2, nTab2 ); + aRange.Format( aStr, SCR_ABS_3D, pScDoc ); + aRangeString = aStr; + } + } + } + + if ( aRangeString.getLength() ) + { + // connect to Calc data (if no range string, leave chart alone, with its own data) + + uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver; + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is()) + xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); + OSL_ASSERT( xReceiver.is()); + if( xReceiver.is() ) + { + uno::Reference< chart2::data::XDataProvider > xDataProvider = new ScChart2DataProvider( pScDoc ); + xReceiver->attachDataProvider( xDataProvider ); + + uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( pDocShell->GetModel(), uno::UNO_QUERY ); + xReceiver->attachNumberFormatsSupplier( xNumberFormatsSupplier ); + + // Same behavior as with old chart: Always assume data series in columns + chart::ChartDataRowSource eDataRowSource = chart::ChartDataRowSource_COLUMNS; + bool bHasCategories = false; + bool bFirstCellAsLabel = false; + + // use ScChartPositioner to auto-detect column/row headers (like ScChartArray in old version) + ScRangeListRef aRangeListRef( new ScRangeList ); + aRangeListRef->Parse( aRangeString, pScDoc ); + if ( aRangeListRef->Count() ) + { + pScDoc->LimitChartIfAll( aRangeListRef ); // limit whole columns/rows to used area + + // update string from modified ranges. The ranges must be in the current formula syntax. + String aTmpStr; + aRangeListRef->Format( aTmpStr, SCR_ABS_3D, pScDoc, pScDoc->GetAddressConvention() ); + aRangeString = aTmpStr; + + ScChartPositioner aChartPositioner( pScDoc, aRangeListRef ); + const ScChartPositionMap* pPositionMap( aChartPositioner.GetPositionMap() ); + if( pPositionMap ) + { + SCSIZE nRowCount = pPositionMap->GetRowCount(); + if( 1==nRowCount ) + eDataRowSource = chart::ChartDataRowSource_ROWS; + } + if ( eDataRowSource == chart::ChartDataRowSource_COLUMNS ) + { + bHasCategories = aChartPositioner.HasRowHeaders(); + bFirstCellAsLabel = aChartPositioner.HasColHeaders(); + } + else // in case the default is changed + { + bHasCategories = aChartPositioner.HasColHeaders(); + bFirstCellAsLabel = aChartPositioner.HasRowHeaders(); + } + } + + uno::Sequence< beans::PropertyValue > aArgs( 4 ); + aArgs[0] = beans::PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CellRangeRepresentation")), -1, + uno::makeAny( aRangeString ), beans::PropertyState_DIRECT_VALUE ); + aArgs[1] = beans::PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HasCategories")), -1, + uno::makeAny( bHasCategories ), beans::PropertyState_DIRECT_VALUE ); + aArgs[2] = beans::PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FirstCellAsLabel")), -1, + uno::makeAny( bFirstCellAsLabel ), beans::PropertyState_DIRECT_VALUE ); + aArgs[3] = beans::PropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataRowSource")), -1, + uno::makeAny( eDataRowSource ), beans::PropertyState_DIRECT_VALUE ); + xReceiver->setArguments( aArgs ); + + // don't create chart listener here (range may be modified in chart dialog) + } + } +} + +/************************************************************************* +|* +|* FuInsertOLE::Konstruktor +|* +\************************************************************************/ + +FuInsertOLE::FuInsertOLE(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) + : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq) +{ + if( ! rReq.IsAPI() ) + rReq.Done(); + + //! hier DLL's initalisieren, damit die Factories existieren? + + uno::Reference < embed::XEmbeddedObject > xObj; + uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage(); + BOOL bIsFromFile = FALSE; + ::rtl::OUString aName; + + sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; + ::rtl::OUString aIconMediaType; + uno::Reference< io::XInputStream > xIconMetaFile; + + + USHORT nSlot = rReq.GetSlot(); + SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False ); + if ( nSlot == SID_INSERT_OBJECT && pNameItem ) + { + SvGlobalName aClassName = pNameItem->GetValue(); + xObj = pViewShell->GetViewFrame()->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aName ); + } + else if ( nSlot == SID_INSERT_SMATH ) + { + if ( SvtModuleOptions().IsMath() ) + { + nSlot = SID_INSERT_OBJECT; + xObj = pViewShell->GetViewFrame()->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SM_CLASSID_60 ).GetByteSequence(), aName ); + rReq.AppendItem( SfxGlobalNameItem( SID_INSERT_OBJECT, SvGlobalName( SO3_SM_CLASSID_60 ) ) ); + } + } + else + { + SvObjectServerList aServerLst; + switch ( nSlot ) + { + case SID_INSERT_OBJECT : + aServerLst.FillInsertObjects(); + aServerLst.Remove( ScDocShell::Factory().GetClassId() ); // Starcalc nicht anzeigen + //TODO/LATER: currently no inserting of ClassId into SfxRequest! + case SID_INSERT_PLUGIN : + case SID_INSERT_APPLET : + case SID_INSERT_FLOATINGFRAME : + { + SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); + SfxAbstractInsertObjectDialog* pDlg = + pFact->CreateInsertObjectDialog( pViewShell->GetWindow(), nSlot, + xStorage, &aServerLst ); + if ( pDlg ) + { + pDlg->Execute(); + xObj = pDlg->GetObject(); + + xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType ); + if ( xIconMetaFile.is() ) + nAspect = embed::Aspects::MSOLE_ICON; + + if ( xObj.is() ) + pViewSh->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName ); + // damit DrawShell eingeschaltet wird (Objekt aktivieren ist unnoetig): + bIsFromFile = !pDlg->IsCreateNew(); + DELETEZ( pDlg ); + } + + break; + } + case SID_INSERT_SOUND : + case SID_INSERT_VIDEO : + { + // create special filedialog for plugins + SvxPluginFileDlg aPluginFileDialog(pWin, nSlot); + + // open filedlg + if ( ERRCODE_NONE == aPluginFileDialog.Execute() ) + { + // get URL + INetURLObject aURL; + aURL.SetSmartProtocol( INET_PROT_FILE ); + if ( aURL.SetURL( aPluginFileDialog.GetPath() ) ) + { + // create a plugin object + ::rtl::OUString aObjName; + SvGlobalName aClassId( SO3_PLUGIN_CLASSID ); + comphelper::EmbeddedObjectContainer aCnt( xStorage ); + xObj = aCnt.CreateEmbeddedObject( aClassId.GetByteSequence(), aObjName ); + if ( xObj.is() && svt::EmbeddedObjectRef::TryRunningState( xObj ) ) + { + // set properties from dialog + uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY ); + if ( xSet.is() ) + { + xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PluginURL")), + uno::makeAny( ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) ); + } + } + } + else + { + DBG_ERROR("Invalid URL!"); + //! error message + //! can this happen??? + } + } + } + } + } + + // SvInsertObjectDialog (alles in einem Dialog) wird nicht mehr benutzt + if (xObj.is()) + { + pView->UnmarkAll(); + + try + { + ::svt::EmbeddedObjectRef aObjRef( xObj, nAspect ); + Size aSize; + MapMode aMap100( MAP_100TH_MM ); + MapUnit aMapUnit = MAP_100TH_MM; + + if ( nAspect == embed::Aspects::MSOLE_ICON ) + { + aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType ); + aSize = aObjRef.GetSize( &aMap100 ); + } + else + { + awt::Size aSz; + try + { + aSz = xObj->getVisualAreaSize( nAspect ); + } + catch( embed::NoVisualAreaSizeException& ) + { + // the default size will be set later + } + + aSize = Size( aSz.Width, aSz.Height ); + + aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); + if (aSize.Height() == 0 || aSize.Width() == 0) + { + // Rechteck mit ausgewogenem Kantenverhaeltnis + aSize.Width() = 5000; + aSize.Height() = 5000; + Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aMapUnit ); + aSz.Width = aTmp.Width(); + aSz.Height = aTmp.Height(); + xObj->setVisualAreaSize( nAspect, aSz ); + + // re-convert aSize to 1/100th mm to avoid rounding errors in comparison below + aSize = Window::LogicToLogic( aTmp, + MapMode( aMapUnit ), aMap100 ); + } + else + aSize = Window::LogicToLogic( aSize, + MapMode( aMapUnit ), aMap100 ); + } + + // Chart initialisieren ? + if ( SvtModuleOptions().IsChart() && SotExchange::IsChart( SvGlobalName( xObj->getClassID() ) ) ) + lcl_ChartInit( xObj, pViewSh->GetViewData(), rtl::OUString() ); + + ScViewData* pData = pViewSh->GetViewData(); + + Point aPnt = pViewSh->GetInsertPos(); + if ( pData->GetDocument()->IsNegativePage( pData->GetTabNo() ) ) + aPnt.X() -= aSize.Width(); // move position to left edge + Rectangle aRect (aPnt, aSize); + SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect); + + // Dieses Objekt nicht vor dem Aktivieren zeichnen + // (in MarkListHasChanged kommt ein Update) + if (!bIsFromFile) + pSkipPaintObj = pObj; + + SdrPageView* pPV = pView->GetSdrPageView(); + pView->InsertObjectAtView(pObj, *pPV); + + if ( nAspect != embed::Aspects::MSOLE_ICON ) + { + // #73279# Math objects change their object size during InsertObject. + // New size must be set in SdrObject, or a wrong scale will be set at + // ActivateObject. + + try + { + awt::Size aSz = xObj->getVisualAreaSize( nAspect ); + + Size aNewSize( aSz.Width, aSz.Height ); + aNewSize = OutputDevice::LogicToLogic( aNewSize, aMapUnit, MAP_100TH_MM ); + + if ( aNewSize != aSize ) + { + aRect.SetSize( aNewSize ); + pObj->SetLogicRect( aRect ); + } + } + catch( embed::NoVisualAreaSizeException& ) + {} + } + + if ( !rReq.IsAPI() ) + { + // XXX Activate aus Makro ist toedlich !!! ??? + if (bIsFromFile) + { + // #45012# Objekt ist selektiert, also Draw-Shell aktivieren + pViewShell->SetDrawShell( TRUE ); + } + else + { + pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW ); + pSkipPaintObj = NULL; + } + } + + rReq.Done(); + } + catch( uno::Exception& ) + { + OSL_ASSERT( "May need error handling here!\n" ); + } + } + else + rReq.Ignore(); +} + +/************************************************************************* +|* +|* FuInsertOLE::Destruktor +|* +\************************************************************************/ + +FuInsertOLE::~FuInsertOLE() +{ +} + +/************************************************************************* +|* +|* FuInsertOLE::Function aktivieren +|* +\************************************************************************/ + +void FuInsertOLE::Activate() +{ + FuPoor::Activate(); +} + +/************************************************************************* +|* +|* FuInsertOLE::Function deaktivieren +|* +\************************************************************************/ + +void FuInsertOLE::Deactivate() +{ + FuPoor::Deactivate(); +} + +/************************************************************************* +|* +|* FuInsertChart::Konstruktor +|* +\************************************************************************/ + +FuInsertChart::FuInsertChart(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) + : FuPoor(pViewSh, pWin, pViewP, pDoc, rReq) +{ + const SfxItemSet* pReqArgs = rReq.GetArgs(); + + if( ! rReq.IsAPI() ) + rReq.Done(); + + if( SvtModuleOptions().IsChart() ) + { + // ---------------------------------------- + // BM/IHA -- + + // get range + ::rtl::OUString aRangeString; + ScRange aPositionRange; // cell range for chart positioning + if( pReqArgs ) + { + const SfxPoolItem* pItem; + if( IS_AVAILABLE( FN_PARAM_5, &pItem ) ) + aRangeString = ::rtl::OUString( ((const SfxStringItem*)pItem)->GetValue()); + + aPositionRange = pViewSh->GetViewData()->GetCurPos(); + } + else + { + ScMarkData& rMark = pViewSh->GetViewData()->GetMarkData(); + bool bAutomaticMark = false; + if ( !rMark.IsMarked() && !rMark.IsMultiMarked() ) + { + pViewSh->GetViewData()->GetView()->MarkDataArea( TRUE ); + bAutomaticMark = true; + } + + ScMarkData aMultiMark( rMark ); + aMultiMark.MarkToMulti(); + + ScRangeList aRanges; + aMultiMark.FillRangeListWithMarks( &aRanges, FALSE ); + String aStr; + ScDocument* pDocument = pViewSh->GetViewData()->GetDocument(); + aRanges.Format( aStr, SCR_ABS_3D, pDocument, pDocument->GetAddressConvention() ); + aRangeString = aStr; + + // get "total" range for positioning + ULONG nCount = aRanges.Count(); + if ( nCount > 0 ) + { + aPositionRange = *aRanges.GetObject(0); + for (ULONG i=1; i<nCount; i++) + aPositionRange.ExtendTo( *aRanges.GetObject(i) ); + } + + if(bAutomaticMark) + pViewSh->GetViewData()->GetView()->Unmark(); + } + + // ---------------------------------------- + // adapted old code + pView->UnmarkAll(); + + ::rtl::OUString aName; + const sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; + + uno::Reference < embed::XEmbeddedObject > xObj = + pViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_SCH_CLASSID_60 ).GetByteSequence(), aName ); + + uno::Reference< ::com::sun::star::chart2::data::XDataReceiver > xReceiver; + uno::Reference< embed::XComponentSupplier > xCompSupp( xObj, uno::UNO_QUERY ); + if( xCompSupp.is()) + xReceiver.set( xCompSupp->getComponent(), uno::UNO_QUERY ); + + // lock the model to suppress any internal updates + uno::Reference< frame::XModel > xChartModel( xReceiver, uno::UNO_QUERY ); + if( xChartModel.is() ) + xChartModel->lockControllers(); + + ScRangeListRef aDummy; + Rectangle aMarkDest; + SCTAB nMarkTab; + BOOL bDrawRect = pViewShell->GetChartArea( aDummy, aMarkDest, nMarkTab ); + + // Objekt-Groesse + awt::Size aSz = xObj->getVisualAreaSize( nAspect ); + Size aSize( aSz.Width, aSz.Height ); + + MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) ); + + BOOL bSizeCh = FALSE; + if (bDrawRect && !aMarkDest.IsEmpty()) + { + aSize = aMarkDest.GetSize(); + bSizeCh = TRUE; + } + if (aSize.Height() <= 0 || aSize.Width() <= 0) + { + aSize.Width() = 5000; + aSize.Height() = 5000; + bSizeCh = TRUE; + } + if (bSizeCh) + { + aSize = Window::LogicToLogic( aSize, MapMode( MAP_100TH_MM ), MapMode( aMapUnit ) ); + aSz.Width = aSize.Width(); + aSz.Height = aSize.Height(); + xObj->setVisualAreaSize( nAspect, aSz ); + } + + ScViewData* pData = pViewSh->GetViewData(); + ScDocShell* pScDocSh = pData->GetDocShell(); + ScDocument* pScDoc = pScDocSh->GetDocument(); + BOOL bUndo (pScDoc->IsUndoEnabled()); + + if( pReqArgs ) + { + const SfxPoolItem* pItem; + UINT16 nToTable = 0; + + if( IS_AVAILABLE( FN_PARAM_4, &pItem ) ) + { + if ( pItem->ISA( SfxUInt16Item ) ) + nToTable = ((const SfxUInt16Item*)pItem)->GetValue(); + else if ( pItem->ISA( SfxBoolItem ) ) + { + // #46033# in der idl fuer Basic steht FN_PARAM_4 als SfxBoolItem + // -> wenn gesetzt, neue Tabelle, sonst aktuelle Tabelle + + if ( ((const SfxBoolItem*)pItem)->GetValue() ) + nToTable = static_cast<UINT16>(pScDoc->GetTableCount()); + else + nToTable = static_cast<UINT16>(pData->GetTabNo()); + } + } + else + { + if (bDrawRect) + nToTable = static_cast<UINT16>(nMarkTab); + rReq.AppendItem( SfxUInt16Item( FN_PARAM_4, nToTable ) ); + } + + // auf neue Tabelle ausgeben? + if ( nToTable == pScDoc->GetTableCount() ) + { + // dann los... + String aTabName; + SCTAB nNewTab = pScDoc->GetTableCount(); + + pScDoc->CreateValidTabName( aTabName ); + + if ( pScDoc->InsertTab( nNewTab, aTabName ) ) + { + BOOL bAppend = TRUE; + + if (bUndo) + { + pScDocSh->GetUndoManager()->AddUndoAction( + new ScUndoInsertTab( pScDocSh, nNewTab, + bAppend, aTabName ) ); + } + + pScDocSh->Broadcast( ScTablesHint( SC_TAB_INSERTED, nNewTab ) ); + pViewSh->SetTabNo( nNewTab, TRUE ); + pScDocSh->PostPaintExtras(); //! erst hinterher ??? + } + else + { + DBG_ERROR( "Could not create new table :-/" ); + } + } + else if ( nToTable != pData->GetTabNo() ) + { + pViewSh->SetTabNo( nToTable, TRUE ); + } + } + + lcl_ChartInit( xObj, pData, aRangeString ); // set source range, auto-detect column/row headers + + // Objekt-Position + + Point aStart; + if ( bDrawRect ) + aStart = aMarkDest.TopLeft(); // marked by hand + else + { + // get chart position (from window size and data range) + aStart = pViewSh->GetChartInsertPos( aSize, aPositionRange ); + } + + Rectangle aRect (aStart, aSize); + SdrOle2Obj* pObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aName, aRect); + + // Dieses Objekt nicht vor dem Aktivieren zeichnen + // (in MarkListHasChanged kommt ein Update) + pSkipPaintObj = pObj; + + SdrPageView* pPV = pView->GetSdrPageView(); + +// pView->InsertObjectAtView(pObj, *pPV);//this call leads to an immidiate redraw and asks the chart for a visual representation + + // use the page instead of the view to insert, so no undo action is created yet + SdrPage* pInsPage = pPV->GetPage(); + pInsPage->InsertObject( pObj ); + pView->UnmarkAllObj(); + pView->MarkObj( pObj, pPV ); + bool bAddUndo = true; // add undo action later, unless the dialog is canceled + + if (rReq.IsAPI()) + { + if( xChartModel.is() ) + xChartModel->unlockControllers(); + } + else + { + //the controller will be unlocked by the dialog when the dialog is told to do so + + // only activate object if not called via API (e.g. macro) + pViewShell->ActivateObject( (SdrOle2Obj*) pObj, SVVERB_SHOW ); + + //open wizard + //@todo get context from calc if that has one + uno::Reference< uno::XComponentContext > xContext( + ::cppu::defaultBootstrap_InitialComponentContext() ); + if(xContext.is()) + { + uno::Reference< lang::XMultiComponentFactory > xMCF( xContext->getServiceManager() ); + if(xMCF.is()) + { + uno::Reference< ui::dialogs::XExecutableDialog > xDialog( + xMCF->createInstanceWithContext( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.chart2.WizardDialog")) + , xContext), uno::UNO_QUERY); + uno::Reference< lang::XInitialization > xInit( xDialog, uno::UNO_QUERY ); + if( xChartModel.is() && xInit.is() ) + { + uno::Reference< awt::XWindow > xDialogParentWindow(0); + // initialize dialog + uno::Sequence<uno::Any> aSeq(2); + uno::Any* pArray = aSeq.getArray(); + beans::PropertyValue aParam1; + aParam1.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")); + aParam1.Value <<= uno::makeAny(xDialogParentWindow); + beans::PropertyValue aParam2; + aParam2.Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ChartModel")); + aParam2.Value <<= uno::makeAny(xChartModel); + pArray[0] <<= uno::makeAny(aParam1); + pArray[1] <<= uno::makeAny(aParam2); + xInit->initialize( aSeq ); + + // try to set the dialog's position so it doesn't hide the chart + uno::Reference < beans::XPropertySet > xDialogProps( xDialog, uno::UNO_QUERY ); + if ( xDialogProps.is() ) + { + try + { + //get dialog size: + awt::Size aDialogAWTSize; + if( xDialogProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Size")) ) + >>= aDialogAWTSize ) + { + Size aDialogSize( aDialogAWTSize.Width, aDialogAWTSize.Height ); + if ( aDialogSize.Width() > 0 && aDialogSize.Height() > 0 ) + { + //calculate and set new position + Point aDialogPos = pViewShell->GetChartDialogPos( aDialogSize, aRect ); + xDialogProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Position")), + uno::makeAny( awt::Point(aDialogPos.getX(),aDialogPos.getY()) ) ); + } + } + //tell the dialog to unlock controller + xDialogProps->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UnlockControllersOnExecute")), + uno::makeAny( sal_True ) ); + + } + catch( uno::Exception& ) + { + OSL_ASSERT( "Chart wizard couldn't be positioned automatically\n" ); + } + } + + sal_Int16 nDialogRet = xDialog->execute(); + if( nDialogRet == ui::dialogs::ExecutableDialogResults::CANCEL ) + { + // leave OLE inplace mode and unmark + OSL_ASSERT( pViewShell ); + OSL_ASSERT( pView ); + pViewShell->DeactivateOle(); + pView->UnmarkAll(); + + // old page view pointer is invalid after switching sheets + pPV = pView->GetSdrPageView(); + + // remove the chart + OSL_ASSERT( pPV ); + SdrPage * pPage( pPV->GetPage()); + OSL_ASSERT( pPage ); + OSL_ASSERT( pObj ); + if( pPage ) + pPage->RemoveObject( pObj->GetOrdNum()); + + bAddUndo = false; // don't create the undo action for inserting + + // leave the draw shell + pViewShell->SetDrawShell( FALSE ); + } + else + { + OSL_ASSERT( nDialogRet == ui::dialogs::ExecutableDialogResults::OK ); + //@todo maybe move chart to different table + } + } + uno::Reference< lang::XComponent > xComponent( xDialog, uno::UNO_QUERY ); + if( xComponent.is()) + xComponent->dispose(); + } + } + } + + if ( bAddUndo ) + { + // add undo action the same way as in SdrEditView::InsertObjectAtView + // (using UndoActionHdl etc.) + pView->AddUndo(pDoc->GetSdrUndoFactory().CreateUndoNewObject(*pObj)); + } + + // BM/IHA -- + } +} + +/************************************************************************* +|* +|* FuInsertChart::Destruktor +|* +\************************************************************************/ + +FuInsertChart::~FuInsertChart() +{ +} + +/************************************************************************* +|* +|* FuInsertChart::Function aktivieren +|* +\************************************************************************/ + +void FuInsertChart::Activate() +{ + FuPoor::Activate(); +} + +/************************************************************************* +|* +|* FuInsertChart::Function deaktivieren +|* +\************************************************************************/ + +void FuInsertChart::Deactivate() +{ + FuPoor::Deactivate(); +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fumark.cxx b/sc/source/ui/drawfunc/fumark.cxx new file mode 100644 index 000000000000..dfbf584bc8bd --- /dev/null +++ b/sc/source/ui/drawfunc/fumark.cxx @@ -0,0 +1,292 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> + +#include "fumark.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "scmod.hxx" +#include "reffact.hxx" +#include "document.hxx" +#include "scresid.hxx" +#include "drawview.hxx" + +//------------------------------------------------------------------ + +/************************************************************************* +|* +|* Funktion zum Aufziehen eines Rechtecks +|* +\************************************************************************/ + +FuMarkRect::FuMarkRect(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) : + FuPoor(pViewSh, pWin, pViewP, pDoc, rReq), + bVisible(FALSE), + bStartDrag(FALSE) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuMarkRect::~FuMarkRect() +{ +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL FuMarkRect::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + pWindow->CaptureMouse(); + pView->UnmarkAll(); // der Einheitlichkeit halber und wegen #50558# + bStartDrag = TRUE; + + aBeginPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); + aZoomRect = Rectangle( aBeginPos, Size() ); + return TRUE; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL FuMarkRect::MouseMove(const MouseEvent& rMEvt) +{ + if ( bStartDrag ) + { + if ( bVisible ) + pViewShell->DrawMarkRect(aZoomRect); + Point aPixPos= rMEvt.GetPosPixel(); + ForceScroll(aPixPos); + + Point aEndPos = pWindow->PixelToLogic(aPixPos); + Rectangle aRect(aBeginPos, aEndPos); + aZoomRect = aRect; + aZoomRect.Justify(); + pViewShell->DrawMarkRect(aZoomRect); + bVisible = TRUE; + } + + ForcePointer(&rMEvt); + + return bStartDrag; +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL FuMarkRect::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + if ( bVisible ) + { + // Hide ZoomRect + pViewShell->DrawMarkRect(aZoomRect); + bVisible = FALSE; + } + + Size aZoomSizePixel = pWindow->LogicToPixel(aZoomRect).GetSize(); + + USHORT nMinMove = pView->GetMinMoveDistancePixel(); + if ( aZoomSizePixel.Width() < nMinMove || aZoomSizePixel.Height() < nMinMove ) + { + // Klick auf der Stelle + + aZoomRect.SetSize(Size()); // dann ganz leer + } + + bStartDrag = FALSE; + pWindow->ReleaseMouse(); + + pViewShell->GetViewData()->GetDispatcher(). + Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); + + // Daten an der View merken + + pViewShell->SetChartArea( aSourceRange, aZoomRect ); + + // Chart-Dialog starten: + +// USHORT nId = ScChartDlgWrapper::GetChildWindowId(); +// SfxChildWindow* pWnd = pViewShell->GetViewFrame()->GetChildWindow( nId ); +// SC_MOD()->SetRefDialog( nId, pWnd ? FALSE : TRUE ); + + return TRUE; +} + +/************************************************************************* +|* +|* Command-event +|* +\************************************************************************/ + +BYTE FuMarkRect::Command(const CommandEvent& rCEvt) +{ + if ( COMMAND_STARTDRAG == rCEvt.GetCommand() ) + { + // #29877# nicht anfangen, auf der Tabelle rumzudraggen, + // aber Maus-Status nicht zuruecksetzen + return SC_CMD_IGNORE; + } + else + return FuPoor::Command(rCEvt); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL FuMarkRect::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FALSE; + + switch ( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_ESCAPE: + // beenden + pViewShell->GetViewData()->GetDispatcher(). + Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + bReturn = TRUE; + break; + } + + if (!bReturn) + { + bReturn = FuPoor::KeyInput(rKEvt); + } + + return (bReturn); +} + +/************************************************************************* +|* +|* Vor dem Scrollen Selektionsdarstellung ausblenden +|* +\************************************************************************/ + +void FuMarkRect::ScrollStart() +{ +} + +/************************************************************************* +|* +|* Nach dem Scrollen Selektionsdarstellung wieder anzeigen +|* +\************************************************************************/ + +void FuMarkRect::ScrollEnd() +{ +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuMarkRect::Activate() +{ + FuPoor::Activate(); + + // Markierung merken, bevor evtl. Tabelle umgeschaltet wird + + ScViewData* pViewData = pViewShell->GetViewData(); + ScMarkData& rMark = pViewData->GetMarkData(); + + if ( !rMark.IsMultiMarked() && !rMark.IsMarked() ) + pViewShell->MarkDataArea( TRUE ); + + pViewData->GetMultiArea( aSourceRange ); // Mehrfachselektion erlaubt + +// pViewShell->Unmark(); + + ForcePointer(NULL); +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuMarkRect::Deactivate() +{ + FuPoor::Deactivate(); + + if (bVisible) + { + // Hide ZoomRect + pViewShell->DrawMarkRect(aZoomRect); + bVisible = FALSE; + bStartDrag = FALSE; + } +} + +/************************************************************************* +|* +|* Maus-Pointer umschalten +|* +\************************************************************************/ + +void FuMarkRect::ForcePointer(const MouseEvent* /* pMEvt */) +{ + pViewShell->SetActivePointer( Pointer( POINTER_CHART ) ); +} + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fupoor.cxx b/sc/source/ui/drawfunc/fupoor.cxx new file mode 100644 index 000000000000..370385aace20 --- /dev/null +++ b/sc/source/ui/drawfunc/fupoor.cxx @@ -0,0 +1,388 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <editeng/outliner.hxx> +#include <svx/svditer.hxx> +#include <svx/svdobj.hxx> +#include <svx/svdpagv.hxx> + +#include "fupoor.hxx" +#include "tabvwsh.hxx" +#include "drawview.hxx" +#include "detfunc.hxx" +#include "document.hxx" +#include <vcl/svapp.hxx> +#include <svx/sdrhittesthelper.hxx> + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuPoor::FuPoor(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) : + pView(pViewP), + pViewShell(pViewSh), + pWindow(pWin), + pDrDoc(pDoc), + aSfxRequest(rReq), + pDialog(NULL), + bIsInDragMode(FALSE), + // #95491# remember MouseButton state + mnCode(0) +{ + aScrollTimer.SetTimeoutHdl( LINK(this, FuPoor, ScrollHdl) ); + aScrollTimer.SetTimeout(SELENG_AUTOREPEAT_INTERVAL); + + aDragTimer.SetTimeoutHdl( LINK(this, FuPoor, DragTimerHdl) ); + aDragTimer.SetTimeout(SELENG_DRAGDROP_TIMEOUT); +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuPoor::~FuPoor() +{ + aDragTimer.Stop(); + aScrollTimer.Stop(); + + if (pDialog) + delete pDialog; +} + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuPoor::Activate() +{ + if (pDialog) + { + pDialog->Show(); + } +} + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuPoor::Deactivate() +{ + aDragTimer.Stop(); + aScrollTimer.Stop(); + + if (pDialog) + { + pDialog->Hide(); + } +} + +/************************************************************************* +|* +|* Scrollen bei Erreichen des Fensterrandes; wird von +|* MouseMove aufgerufen +|* +\************************************************************************/ + +void FuPoor::ForceScroll(const Point& aPixPos) +{ + aScrollTimer.Stop(); + + Size aSize = pWindow->GetSizePixel(); + SCsCOL dx = 0; + SCsROW dy = 0; + + if ( aPixPos.X() <= 0 ) dx = -1; + if ( aPixPos.X() >= aSize.Width() ) dx = 1; + if ( aPixPos.Y() <= 0 ) dy = -1; + if ( aPixPos.Y() >= aSize.Height() ) dy = 1; + + ScViewData* pViewData = pViewShell->GetViewData(); + if ( pViewData->GetDocument()->IsNegativePage( pViewData->GetTabNo() ) ) + dx = -dx; + + ScSplitPos eWhich = pViewData->GetActivePart(); + if ( dx > 0 && pViewData->GetHSplitMode() == SC_SPLIT_FIX && WhichH(eWhich) == SC_SPLIT_LEFT ) + { + pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ? + SC_SPLIT_TOPRIGHT : SC_SPLIT_BOTTOMRIGHT ); + dx = 0; + } + if ( dy > 0 && pViewData->GetVSplitMode() == SC_SPLIT_FIX && WhichV(eWhich) == SC_SPLIT_TOP ) + { + pViewShell->ActivatePart( ( eWhich == SC_SPLIT_TOPLEFT ) ? + SC_SPLIT_BOTTOMLEFT : SC_SPLIT_BOTTOMRIGHT ); + dy = 0; + } + + if ( dx != 0 || dy != 0 ) + { + ScrollStart(); // Scrollaktion in abgeleiteter Klasse + pViewShell->ScrollLines(2*dx, 4*dy); + ScrollEnd(); + aScrollTimer.Start(); + } +} + +/************************************************************************* +|* +|* Timer-Handler fuer Fensterscrolling +|* +\************************************************************************/ + +IMPL_LINK_INLINE_START( FuPoor, ScrollHdl, Timer *, EMPTYARG ) +{ + Point aPosPixel = pWindow->GetPointerPosPixel(); + + // #95491# use remembered MouseButton state to create correct + // MouseEvents for this artifical MouseMove. + MouseMove(MouseEvent(aPosPixel, 1, 0, GetMouseButtonCode())); + + return 0; +} +IMPL_LINK_INLINE_END( FuPoor, ScrollHdl, Timer *, pTimer ) + +// #95491# moved from inline to *.cxx +BOOL FuPoor::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + return FALSE; +} + +// #95491# moved from inline to *.cxx +BOOL FuPoor::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + return FALSE; +} + +/************************************************************************* +|* +|* String in Applikations-Statuszeile ausgeben +|* +\************************************************************************/ + +// WriteStatus gibt's nicht mehr + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL FuPoor::KeyInput(const KeyEvent& /* rKEvt */) +{ + BOOL bReturn = FALSE; + + return(bReturn); +} + +BYTE FuPoor::Command(const CommandEvent& rCEvt) +{ + if ( COMMAND_STARTDRAG == rCEvt.GetCommand() ) + { + //!!! sollte Joe eigentlich machen: + // nur, wenn im Outliner was selektiert ist, darf + // Command TRUE zurueckliefern: + + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); + + if ( pOutView ) + return pOutView->HasSelection() ? pView->Command(rCEvt,pWindow) : SC_CMD_NONE; + else + return pView->Command(rCEvt,pWindow); + } + else + return pView->Command(rCEvt,pWindow); +} + +/************************************************************************* +|* +|* Cut object to clipboard +|* +\************************************************************************/ + +void FuPoor::DoCut() +{ + if (pView) + { +//! pView->DoCut(pWindow); + } +} + +/************************************************************************* +|* +|* Copy object to clipboard +|* +\************************************************************************/ + +void FuPoor::DoCopy() +{ + if (pView) + { +//! pView->DoCopy(pWindow); + } +} + +/************************************************************************* +|* +|* Paste object from clipboard +|* +\************************************************************************/ + +void FuPoor::DoPaste() +{ + if (pView) + { +//! pView->DoPaste(pWindow); + } +} + +/************************************************************************* +|* +|* Timer-Handler fuer Drag&Drop +|* +\************************************************************************/ + +IMPL_LINK( FuPoor, DragTimerHdl, Timer *, EMPTYARG ) +{ + // ExecuteDrag (und das damit verbundene Reschedule) direkt aus dem Timer + // aufzurufen, bringt die VCL-Timer-Verwaltung durcheinander, wenn dabei + // (z.B. im Drop) wieder ein Timer gestartet wird (z.B. ComeBack-Timer der + // DrawView fuer Solid Handles / ModelHasChanged) - der neue Timer laeuft + // dann um die Dauer des Drag&Drop zu spaet ab. + // Darum Drag&Drop aus eigenem Event: + + Application::PostUserEvent( LINK( this, FuPoor, DragHdl ) ); + return 0; +} + +IMPL_LINK( FuPoor, DragHdl, void *, EMPTYARG ) +{ + SdrHdl* pHdl = pView->PickHandle(aMDPos); + + if ( pHdl==NULL && pView->IsMarkedHit(aMDPos) ) + { + pWindow->ReleaseMouse(); + bIsInDragMode = TRUE; + +// pView->BeginDrag(pWindow, aMDPos); + pViewShell->GetScDrawView()->BeginDrag(pWindow, aMDPos); + } + return 0; +} + +// Detektiv-Linie + +BOOL FuPoor::IsDetectiveHit( const Point& rLogicPos ) +{ + SdrPageView* pPV = pView->GetSdrPageView(); + if (!pPV) + return FALSE; + + BOOL bFound = FALSE; + SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT ); + SdrObject* pObject = aIter.Next(); + while (pObject && !bFound) + { + if (ScDetectiveFunc::IsNonAlienArrow( pObject )) + { + USHORT nHitLog = (USHORT) pWindow->PixelToLogic( + Size(pView->GetHitTolerancePixel(),0)).Width(); + if(SdrObjectPrimitiveHit(*pObject, rLogicPos, nHitLog, *pPV, 0, false)) + { + bFound = TRUE; + } + } + + pObject = aIter.Next(); + } + return bFound; +} + +void FuPoor::StopDragTimer() +{ + if (aDragTimer.IsActive() ) + aDragTimer.Stop(); +} + +/************************************************************************* +|* +|* #98185# Create default drawing objects via keyboard +|* +\************************************************************************/ + +SdrObject* FuPoor::CreateDefaultObject(const sal_uInt16 /* nID */, const Rectangle& /* rRectangle */) +{ + // empty base implementation + return 0L; +} + +void FuPoor::ImpForceQuadratic(Rectangle& rRect) +{ + if(rRect.GetWidth() > rRect.GetHeight()) + { + rRect = Rectangle( + Point(rRect.Left() + ((rRect.GetWidth() - rRect.GetHeight()) / 2), rRect.Top()), + Size(rRect.GetHeight(), rRect.GetHeight())); + } + else + { + rRect = Rectangle( + Point(rRect.Left(), rRect.Top() + ((rRect.GetHeight() - rRect.GetWidth()) / 2)), + Size(rRect.GetWidth(), rRect.GetWidth())); + } +} + +// #i33136# +bool FuPoor::doConstructOrthogonal() const +{ + return false; +} + +// eof + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fusel.cxx b/sc/source/ui/drawfunc/fusel.cxx new file mode 100644 index 000000000000..27bce1f384e5 --- /dev/null +++ b/sc/source/ui/drawfunc/fusel.cxx @@ -0,0 +1,657 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +// INCLUDE --------------------------------------------------------------- + +#include <com/sun/star/embed/EmbedStates.hpp> + +#include <editeng/eeitem.hxx> +#include <editeng/flditem.hxx> +#include <svx/svdoole2.hxx> +#include <svx/svdotext.hxx> +#include <sfx2/dispatch.hxx> +#include <svtools/imapobj.hxx> +#include <svx/svdouno.hxx> +#include <svx/svdomedia.hxx> +#include <svx/svdpagv.hxx> +#include <editeng/outlobj.hxx> +#include <svx/svdocapt.hxx> +#include <sfx2/app.hxx> + +#include "fusel.hxx" +#include "sc.hrc" +#include "fudraw.hxx" +#include "futext.hxx" +#include "drawview.hxx" +#include "tabvwsh.hxx" +#include "drawpage.hxx" +#include "globstr.hrc" +#include "drwlayer.hxx" +#include "userdat.hxx" +#include "scmod.hxx" + +// ----------------------------------------------------------------------- + +// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten +//! fusel,fuconstr,futext - zusammenfassen! +#define SC_MAXDRAGMOVE 3 + +// ----------------------------------------------------------------------- + +#ifdef _MSC_VER +#pragma optimize ( "", off ) +#endif + +using namespace com::sun::star; + +/************************************************************************* +|* +|* Konstruktor +|* +\************************************************************************/ + +FuSelection::FuSelection(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq ) : + FuDraw(pViewSh, pWin, pViewP, pDoc, rReq), + bVCAction(FALSE) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuSelection::~FuSelection() +{ +} + +BYTE FuSelection::Command(const CommandEvent& rCEvt) +{ + // special code for non-VCL OS2/UNX removed + + return FuDraw::Command( rCEvt ); +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuSelection::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + const bool bSelectionOnly = rMEvt.IsRight(); + if ( pView->IsAction() ) + { + if ( bSelectionOnly ) + pView->BckAction(); + return TRUE; + } + + bVCAction = FALSE; + bIsInDragMode = FALSE; // irgendwo muss es ja zurueckgesetzt werden (#50033#) + + BOOL bReturn = FuDraw::MouseButtonDown(rMEvt); + + aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); + + if ( rMEvt.IsLeft() ) + { + SdrHdl* pHdl = pView->PickHandle(aMDPos); + SdrObject* pObj; + SdrPageView* pPV; + + if ( pHdl!=NULL || pView->IsMarkedHit(aMDPos) ) + { + // Determine if this is the tail of a SdrCaptionObj i.e. + // we need to disable the drag option on the tail of a note + // object. Also, disable the ability to use the circular + // drag of a note object. + bool bDrag = false; + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if( ScDrawLayer::IsNoteCaption( pMarkedObj ) ) + { + // move using the valid caption handles for note text box. + if(pHdl && (pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC)) + bDrag = true; + // move the complete note box. + else if(!pHdl) + bDrag = true; + } + else + bDrag = true; // different object + } + else + bDrag = true; // several objects + + if ( bDrag ) + { + aDragTimer.Start(); + pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl); + bReturn = TRUE; + } + } + else + { + BOOL bAlt = rMEvt.IsMod2(); + if ( !bAlt && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) ) + { + pView->BegMacroObj(aMDPos, pObj, pPV, pWindow); + bReturn = TRUE; + } + else + { + String sURL, sTarget; + if ( !bAlt && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_ALSOONMASTER)) + { + // Support for imported Excel docs + // Excel is of course not consistent and allows + // a hyperlink to be assigned for an object group + // and even though the hyperlink is exported in the Escher layer + // its never used, when dealing with a group object the link + // associated with the clicked object is used only + + // additionally you can also select a macro in Excel for a grouped + // objects and this results in the macro being set for the elements + // in the group and no macro is exported for the group + + // if a macro and hlink are defined favour the hlink + + // If a group object has no hyperlink use the hyperlink of the + // object clicked + + if ( pObj->IsGroupObject() ) + { + SdrObject* pHit = NULL; + if ( pView->PickObj(aMDPos, pView->getHitTolLog(), pHit, pPV, SDRSEARCH_DEEP ) ) + pObj = pHit; + } + + ScMacroInfo* pInfo = ScDrawLayer::GetMacroInfo( pObj, TRUE ); + // For interoperability favour links over macros if both are defined + if ( pInfo->GetHlink().getLength() > 0 ) + { + OSL_TRACE("** Got URL"); + sURL = pInfo->GetHlink(); + } + else if ( pInfo->GetMacro().getLength() > 0 ) + { + SfxObjectShell* pObjSh = SfxObjectShell::Current(); + if ( pObjSh && SfxApplication::IsXScriptURL( pInfo->GetMacro() ) ) + { + uno::Reference< beans::XPropertySet > xProps( pObj->getUnoShape(), uno::UNO_QUERY ); + uno::Any aCaller; + if ( xProps.is() ) + { + try + { + aCaller = xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")) ); + } + catch( uno::Exception& ) {} + } + uno::Any aRet; + uno::Sequence< sal_Int16 > aOutArgsIndex; + uno::Sequence< uno::Any > aOutArgs; + uno::Sequence< uno::Any >* pInArgs = + new uno::Sequence< uno::Any >(0); + pObjSh->CallXScript( pInfo->GetMacro(), + *pInArgs, aRet, aOutArgsIndex, aOutArgs, true, &aCaller ); + pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() ); + return TRUE; // kein CaptureMouse etc. + } + } + } + + // URL / ImageMap + + SdrViewEvent aVEvt; + if ( !bAlt && + pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt ) != SDRHIT_NONE && + aVEvt.pObj != NULL ) + { + if ( ScDrawLayer::GetIMapInfo( aVEvt.pObj ) ) // ImageMap + { + const IMapObject* pIMapObj = + ScDrawLayer::GetHitIMapObject( aVEvt.pObj, aMDPos, *pWindow ); + if ( pIMapObj && pIMapObj->GetURL().Len() ) + { + sURL = pIMapObj->GetURL(); + sTarget = pIMapObj->GetTarget(); + } + } + if ( aVEvt.eEvent == SDREVENT_EXECUTEURL && aVEvt.pURLField ) // URL + { + sURL = aVEvt.pURLField->GetURL(); + sTarget = aVEvt.pURLField->GetTargetFrame(); + } + } + + // open hyperlink, if found at object or in object's text + if ( sURL.Len() > 0 ) + { + ScGlobal::OpenURL( sURL, sTarget ); + pViewShell->FakeButtonUp( pViewShell->GetViewData()->GetActivePart() ); + return TRUE; // kein CaptureMouse etc. + } + + // Is another object being edited in this view? + // (Editing is ended in MarkListHasChanged - test before UnmarkAll) + SfxInPlaceClient* pClient = pViewShell->GetIPClient(); + BOOL bWasOleActive = ( pClient && pClient->IsObjectInPlaceActive() ); + + // Markieren + + // do not allow multiselection with note caption + bool bCaptionClicked = IsNoteCaptionClicked( aMDPos ); + if ( !rMEvt.IsShift() || bCaptionClicked || IsNoteCaptionMarked() ) + pView->UnmarkAll(); + + /* Unlock internal layer, if a note caption is clicked. The + layer will be relocked in ScDrawView::MarkListHasChanged(). */ + if( bCaptionClicked ) + pView->UnlockInternalLayer(); + + // try to select the clicked object + if ( pView->MarkObj( aMDPos, -2, FALSE, rMEvt.IsMod1() ) ) + { + //********************************************************* + //Objekt verschieben + //******************************************************** + if (pView->IsMarkedHit(aMDPos)) + { + // #95834# Don't start drag timer if inplace editing of an OLE object + // was just ended with this mouse click - the view will be moved + // (different tool bars) and the object that was clicked on would + // be moved unintentionally. + if ( !bWasOleActive ) + aDragTimer.Start(); + + pHdl=pView->PickHandle(aMDPos); + pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl); + bReturn = TRUE; + } + else // Objekt am Rand getroffen + if (pViewShell->IsDrawSelMode()) + bReturn = TRUE; + } + else + { + // nichts getroffen + + if (pViewShell->IsDrawSelMode()) + { + //********************************************************* + //Objekt selektieren + //******************************************************** + pView->BegMarkObj(aMDPos); + bReturn = TRUE; + } + } + } + } + + } + + if (!bIsInDragMode) + { + if (!bVCAction) // VC rufen selber CaptureMouse + pWindow->CaptureMouse(); + ForcePointer(&rMEvt); + } + + return bReturn; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuSelection::MouseMove(const MouseEvent& rMEvt) +{ + BOOL bReturn = FuDraw::MouseMove(rMEvt); + + if (aDragTimer.IsActive() ) + { + Point aOldPixel = pWindow->LogicToPixel( aMDPos ); + Point aNewPixel = rMEvt.GetPosPixel(); + if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE || + Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE ) + aDragTimer.Stop(); + } + + if ( pView->IsAction() ) + { + Point aPix(rMEvt.GetPosPixel()); + Point aPnt(pWindow->PixelToLogic(aPix)); + + ForceScroll(aPix); + pView->MovAction(aPnt); + bReturn = TRUE; + } + + // Ein VCControl ist aktiv + // Event an den Manager weiterleiten + if( bVCAction ) + { + // GetSbxForm gibts nicht mehr - Basic-Controls sind tot + //SdrPageView* pPgView = pView->GetPageViewByIndex(0); + //ScDrawPage* pPage = (ScDrawPage*)pPgView->GetPage(); + //VCSbxForm* pForm = (VCSbxForm*)(SbxObject*)(pPage->GetSbxForm()); + //((VCManager*)(pForm->GetVCContainer()))-> + // MouseMove( pWindow, rMEvt ); + bReturn = TRUE; + } + + ForcePointer(&rMEvt); + + return (bReturn); +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuSelection::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FuDraw::MouseButtonUp(rMEvt); +// BOOL bOle = pViewShell->GetViewData()->IsOle(); + BOOL bOle = pViewShell->GetViewFrame()->GetFrame().IsInPlace(); + + if (aDragTimer.IsActive() ) + { + aDragTimer.Stop(); + } + + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + + if ( rMEvt.IsLeft() ) + { + if ( pView->IsDragObj() ) + { + /****************************************************************** + * Objekt wurde verschoben + ******************************************************************/ + pView->EndDragObj( rMEvt.IsMod1() ); + pView->ForceMarkedToAnotherPage(); + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); + FuText* pText = static_cast<FuText*>(pPoor); + pText->StopDragMode(pObj ); + } + bReturn = TRUE; + } + else if (pView->IsAction() ) + { + // unlock internal layer to include note captions + pView->UnlockInternalLayer(); + pView->EndAction(); + if ( pView->AreObjectsMarked() ) + { + bReturn = TRUE; + + /* if multi-selection contains a note caption object, remove + all other objects from selection. */ + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + ULONG nCount = rMarkList.GetMarkCount(); + if( nCount > 1 ) + { + bool bFound = false; + for( ULONG nIdx = 0; !bFound && (nIdx < nCount); ++nIdx ) + { + SdrObject* pObj = rMarkList.GetMark( nIdx )->GetMarkedSdrObj(); + bFound = ScDrawLayer::IsNoteCaption( pObj ); + if( bFound ) + { + pView->UnMarkAll(); + pView->MarkObj( pObj, pView->GetSdrPageView() ); + } + } + } + } + } + } + +/* + if ( pView->IsObjEdit() ) + { + BOOL bShowCursor = TRUE; +//! pOutlinerView = pView->GetOutlinerView(pWindow, bShowCursor); + bReturn = TRUE; + } +*/ + /************************************************************************** + * Ggf. OLE-Objekt beruecksichtigen + **************************************************************************/ + SfxInPlaceClient* pIPClient = pViewShell->GetIPClient(); + + if (pIPClient) + { + ScModule* pScMod = SC_MOD(); + bool bUnoRefDialog = pScMod->IsRefDialogOpen() && pScMod->GetCurRefDlgId() == WID_SIMPLE_REF; + + if ( pIPClient->IsObjectInPlaceActive() && !bUnoRefDialog ) + pIPClient->DeactivateObject(); + } + + USHORT nClicks = rMEvt.GetClicks(); + if ( nClicks == 2 && rMEvt.IsLeft() ) + { + if ( pView->AreObjectsMarked() ) + { + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + + // #43984# aktivieren nur, wenn die Maus auch (noch) ueber dem + // selektierten Objekt steht + + SdrViewEvent aVEvt; + SdrHitKind eHit = pView->PickAnything( rMEvt, SDRMOUSEBUTTONDOWN, aVEvt ); + if ( eHit != SDRHIT_NONE && aVEvt.pObj == pObj ) + { + UINT16 nSdrObjKind = pObj->GetObjIdentifier(); + + // + // OLE: aktivieren + // + + if (nSdrObjKind == OBJ_OLE2) + { + if (!bOle) + { + if (((SdrOle2Obj*) pObj)->GetObjRef().is()) + { + //HMHpView->HideMarkHdl(); + pViewShell->ActivateObject( (SdrOle2Obj*) pObj, 0 ); + } + } + } + + // + // Edit text + // #49458# not in UNO controls + // #i32352# not in media objects + // + else if ( pObj->ISA(SdrTextObj) && !pObj->ISA(SdrUnoObj) && !pObj->ISA(SdrMediaObj) ) + { + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + BOOL bVertical = ( pOPO && pOPO->IsVertical() ); + USHORT nTextSlotId = bVertical ? SID_DRAW_TEXT_VERTICAL : SID_DRAW_TEXT; + + pViewShell->GetViewData()->GetDispatcher(). + Execute(nTextSlotId, SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD); + + // jetzt den erzeugten FuText holen und in den EditModus setzen + FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); + if ( pPoor && pPoor->GetSlotID() == nTextSlotId ) // hat keine RTTI + { + FuText* pText = (FuText*)pPoor; + Point aMousePixel = rMEvt.GetPosPixel(); + pText->SetInEditMode( pObj, &aMousePixel ); + } + bReturn = TRUE; + } + } + } + } + else if ( TestDetective( pView->GetSdrPageView(), aPnt ) ) + bReturn = TRUE; + } + + // Ein VCControl ist aktiv + // Event an den Manager weiterleiten + if( bVCAction ) + { + // GetSbxForm gibts nicht mehr - Basic-Controls sind tot + //SdrPageView* pPgView = pView->GetPageViewByIndex(0); + //ScDrawPage* pPage = (ScDrawPage*)pPgView->GetPage(); + //VCSbxForm* pForm = (VCSbxForm*)(SbxObject*)(pPage->GetSbxForm()); + //((VCManager*)(pForm->GetVCContainer()))-> + // MouseButtonUp( pWindow, rMEvt ); + //HMHpView->ShowMarkHdl(); + bVCAction = FALSE; + bReturn = TRUE; + } + + ForcePointer(&rMEvt); + + pWindow->ReleaseMouse(); + + // Command-Handler fuer Kontext-Menue kommt erst nach MouseButtonUp, + // darum hier die harte IsLeft-Abfrage + if ( !bReturn && rMEvt.IsLeft() ) + if (pViewShell->IsDrawSelMode()) + pViewShell->GetViewData()->GetDispatcher(). + Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + + return (bReturn); +} + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL FuSelection::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FALSE; + + if (!bReturn) + { + bReturn = FuDraw::KeyInput(rKEvt); + } + + return(bReturn); +} + + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuSelection::Activate() +{ +/* + SdrDragMode eMode; + switch (aSfxRequest.GetSlot() ) + { + case SID_OBJECT_SELECT: + eMode = SDRDRAG_MOVE; + break; + case SID_OBJECT_ROTATE: + eMode = SDRDRAG_ROTATE; + break; + case SID_OBJECT_MIRROR: + eMode = SDRDRAG_MIRROR; + break; + } + pView->SetDragMode(eMode); +*/ + FuDraw::Activate(); +} + + + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuSelection::Deactivate() +{ + /************************************************************************** + * Hide Cursor + **************************************************************************/ +// BOOL bShowCursor = FALSE; +//! pOutlinerView = pView->GetOutlinerView(pWindow, bShowCursor); + +// pView->SetDragMode(SDRDRAG_MOVE); + FuDraw::Deactivate(); +} + + +#ifdef _MSC_VER +#pragma optimize ( "", on ) +#endif + + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/fusel2.cxx b/sc/source/ui/drawfunc/fusel2.cxx new file mode 100644 index 000000000000..8e884ee45a61 --- /dev/null +++ b/sc/source/ui/drawfunc/fusel2.cxx @@ -0,0 +1,187 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +// INCLUDE --------------------------------------------------------------- + +#include <svx/svditer.hxx> +#include <svx/svdocapt.hxx> +#include <svx/svdpagv.hxx> +#include <sfx2/dispatch.hxx> +#include <editeng/outliner.hxx> + +#include "fusel.hxx" +#include "tabvwsh.hxx" +#include "document.hxx" +#include "detfunc.hxx" +#include "futext.hxx" +#include "sc.hrc" +#include "attrib.hxx" +#include "scitems.hxx" +#include "userdat.hxx" +#include "drwlayer.hxx" +#include "docsh.hxx" +#include "drawview.hxx" +#include <svx/sdrhittesthelper.hxx> + +// ----------------------------------------------------------------------- + +inline long Diff( const Point& rP1, const Point& rP2 ) +{ + long nX = rP1.X() - rP2.X(); + if (nX<0) nX = -nX; + long nY = rP1.Y() - rP2.Y(); + if (nY<0) nY = -nY; + return nX+nY; +} + +BOOL FuSelection::TestDetective( SdrPageView* pPV, const Point& rPos ) +{ + if (!pPV) + return FALSE; + + BOOL bFound = FALSE; + SdrObjListIter aIter( *pPV->GetObjList(), IM_FLAT ); + SdrObject* pObject = aIter.Next(); + while (pObject && !bFound) + { + if (ScDetectiveFunc::IsNonAlienArrow( pObject )) + { + USHORT nHitLog = (USHORT) pWindow->PixelToLogic( + Size(pView->GetHitTolerancePixel(),0)).Width(); + if (SdrObjectPrimitiveHit(*pObject, rPos, nHitLog, *pPV, 0, false)) + { + ScViewData* pViewData = pViewShell->GetViewData(); + ScSplitPos ePos = pViewShell->FindWindow( pWindow ); + Point aLineStart = pObject->GetPoint(0); + Point aLineEnd = pObject->GetPoint(1); + Point aPixel = pWindow->LogicToPixel( aLineStart ); + SCsCOL nStartCol; + SCsROW nStartRow; + pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), ePos, nStartCol, nStartRow ); + aPixel = pWindow->LogicToPixel( aLineEnd ); + SCsCOL nEndCol; + SCsROW nEndRow; + pViewData->GetPosFromPixel( aPixel.X(), aPixel.Y(), ePos, nEndCol, nEndRow ); + SCsCOL nCurX = (SCsCOL) pViewData->GetCurX(); + SCsROW nCurY = (SCsROW) pViewData->GetCurY(); + BOOL bStart = ( Diff( rPos,aLineStart ) > Diff( rPos,aLineEnd ) ); + if ( nCurX == nStartCol && nCurY == nStartRow ) + bStart = FALSE; + else if ( nCurX == nEndCol && nCurY == nEndRow ) + bStart = TRUE; + + SCsCOL nDifX; + SCsROW nDifY; + if ( bStart ) + { + nDifX = nStartCol - nCurX; + nDifY = nStartRow - nCurY; + } + else + { + nDifX = nEndCol - nCurX; + nDifY = nEndRow - nCurY; + } + pViewShell->MoveCursorRel( nDifX, nDifY, SC_FOLLOW_JUMP, FALSE ); + + bFound = TRUE; + } + } + + pObject = aIter.Next(); + } + return bFound; +} + +bool FuSelection::IsNoteCaptionMarked() const +{ + if( pView ) + { + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + return ScDrawLayer::IsNoteCaption( pObj ); + } + } + return false; +} + +bool FuSelection::IsNoteCaptionClicked( const Point& rPos ) const +{ + SdrPageView* pPageView = pView ? pView->GetSdrPageView() : 0; + if( pPageView ) + { + const ScViewData& rViewData = *pViewShell->GetViewData(); + ScDocument& rDoc = *rViewData.GetDocument(); + SCTAB nTab = rViewData.GetTabNo(); + ScDocShell* pDocSh = rViewData.GetDocShell(); + bool bProtectDoc = rDoc.IsTabProtected( nTab ) || (pDocSh && pDocSh->IsReadOnly()); + + // search the last object (on top) in the object list + SdrObjListIter aIter( *pPageView->GetObjList(), IM_DEEPNOGROUPS, TRUE ); + for( SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next() ) + { + if( pObj->GetLogicRect().IsInside( rPos ) ) + { + if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObj, nTab ) ) + { + const ScAddress& rNotePos = pCaptData->maStart; + // skip caption objects of notes in protected cells + const ScProtectionAttr* pProtAttr = static_cast< const ScProtectionAttr* >( rDoc.GetAttr( rNotePos.Col(), rNotePos.Row(), nTab, ATTR_PROTECTION ) ); + bool bProtectAttr = pProtAttr->GetProtection() || pProtAttr->GetHideCell(); + if( !bProtectAttr || !bProtectDoc ) + return true; + } + } + } + } + return false; +} + +void FuSelection::ActivateNoteHandles(SdrObject* pObject) +{ + if( pView && ScDrawLayer::IsNoteCaption( pObject ) ) + { + // Leave the internal layer unlocked - relock in ScDrawView::MarkListHasChanged() + pView->UnlockInternalLayer(); + pView->MarkObj( pObject, pView->GetSdrPageView() ); + } +} + +//================================================================== + + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/futext.cxx b/sc/source/ui/drawfunc/futext.cxx new file mode 100644 index 000000000000..6742ea4c8186 --- /dev/null +++ b/sc/source/ui/drawfunc/futext.cxx @@ -0,0 +1,884 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <svx/svddef.hxx> +#include <svx/svdoutl.hxx> +#include <editeng/outlobj.hxx> +#include <svx/sdtaaitm.hxx> +#include <svx/sdtacitm.hxx> +#include <svx/svdotext.hxx> +#include <editeng/unolingu.hxx> +#include <svx/svdocapt.hxx> +#include <sfx2/bindings.hxx> +#include <sfx2/dispatch.hxx> +#include <sfx2/viewfrm.hxx> +#include <svx/svxids.hrc> +#include <editeng/eeitem.hxx> +#include <svl/itemset.hxx> + +#include "futext.hxx" +#include "drwlayer.hxx" +#include "sc.hrc" +#include "tabvwsh.hxx" +#include "drawview.hxx" + +// #98185# Create default drawing objects via keyboard +#include "scresid.hxx" + +// Maximal erlaubte Mausbewegung um noch Drag&Drop zu starten +//! fusel,fuconstr,futext - zusammenfassen! +#define SC_MAXDRAGMOVE 3 + +//------------------------------------------------------------------ + +void lcl_InvalidateAttribs( SfxBindings& rBindings ) +{ + rBindings.Invalidate( SID_ATTR_CHAR_WEIGHT ); + rBindings.Invalidate( SID_ATTR_CHAR_POSTURE ); + rBindings.Invalidate( SID_ATTR_CHAR_UNDERLINE ); + rBindings.Invalidate( SID_ULINE_VAL_NONE ); + rBindings.Invalidate( SID_ULINE_VAL_SINGLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOUBLE ); + rBindings.Invalidate( SID_ULINE_VAL_DOTTED ); + rBindings.Invalidate( SID_ATTR_CHAR_OVERLINE ); + rBindings.Invalidate( SID_ATTR_CHAR_COLOR ); + rBindings.Invalidate( SID_ATTR_CHAR_FONT ); + rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); + rBindings.Invalidate( SID_ALIGNLEFT ); + rBindings.Invalidate( SID_ALIGNCENTERHOR ); + rBindings.Invalidate( SID_ALIGNRIGHT ); + rBindings.Invalidate( SID_ALIGNBLOCK ); + rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_10 ); + rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_15 ); + rBindings.Invalidate( SID_ATTR_PARA_LINESPACE_20 ); + rBindings.Invalidate( SID_SET_SUPER_SCRIPT ); + rBindings.Invalidate( SID_SET_SUB_SCRIPT ); + rBindings.Invalidate( SID_HYPERLINK_GETLINK ); + rBindings.Invalidate( SID_TEXTDIRECTION_LEFT_TO_RIGHT ); + rBindings.Invalidate( SID_TEXTDIRECTION_TOP_TO_BOTTOM ); + rBindings.Invalidate( SID_ATTR_PARA_LEFT_TO_RIGHT ); + rBindings.Invalidate( SID_ATTR_PARA_RIGHT_TO_LEFT ); + // pseudo slots for Format menu + rBindings.Invalidate( SID_ALIGN_ANY_LEFT ); + rBindings.Invalidate( SID_ALIGN_ANY_HCENTER ); + rBindings.Invalidate( SID_ALIGN_ANY_RIGHT ); + rBindings.Invalidate( SID_ALIGN_ANY_JUSTIFIED ); +} + +void lcl_UpdateHyphenator( Outliner& rOutliner, SdrObject* pObj ) +{ + // use hyphenator only if hyphenation attribute is set + if ( pObj && ((const SfxBoolItem&)pObj->GetMergedItem(EE_PARA_HYPHENATE)).GetValue() ) { + com::sun::star::uno::Reference<com::sun::star::linguistic2::XHyphenator> xHyphenator( LinguMgr::GetHyphenator() ); + rOutliner.SetHyphenator( xHyphenator ); + } +} + +/************************************************************************* +|* +|* Basisklasse fuer Textfunktionen +|* +\************************************************************************/ + +FuText::FuText(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pViewP, + SdrModel* pDoc, SfxRequest& rReq) : + FuConstruct(pViewSh, pWin, pViewP, pDoc, rReq), + pTextObj(NULL) +{ +} + +/************************************************************************* +|* +|* Destruktor +|* +\************************************************************************/ + +FuText::~FuText() +{ +// StopEditMode(); // in Deactivate ! +} + +/************************************************************************* +|* +|* MouseButtonDown-event +|* +\************************************************************************/ + +BOOL __EXPORT FuText::MouseButtonDown(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + if ( pView->MouseButtonDown(rMEvt, pWindow) ) + return (TRUE); // Event von der SdrView ausgewertet + + if ( pView->IsTextEdit() ) + { + if( !IsSizingOrMovingNote(rMEvt) ) + StopEditMode(); // Danebengeklickt, Ende mit Edit + pView->SetCreateMode(); + } + + aMDPos = pWindow->PixelToLogic( rMEvt.GetPosPixel() ); + + if ( rMEvt.IsLeft() ) + { + SdrHdl* pHdl = pView->PickHandle(aMDPos); + + ULONG nHdlNum = pView->GetHdlNum(pHdl); + + if (pHdl != NULL) + { + if (pView->HasMarkablePoints() && pView->IsPointMarkable(*pHdl)) + { + BOOL bPointMarked=pView->IsPointMarked(*pHdl); + + if ( rMEvt.IsShift() ) + { + if (!bPointMarked) + { + pView->MarkPoint(*pHdl); + } + else + { + pView->UnmarkPoint(*pHdl); + } + } + else + { + if (!bPointMarked) + { + pView->UnmarkAllPoints(); + pView->MarkPoint(*pHdl); + } + } + pHdl=pView->GetHdl(nHdlNum); + } + } + + SdrObject* pObj; + SdrPageView* pPV; + + if ( pHdl != NULL || pView->IsMarkedHit(aMDPos) ) + { + if (pHdl == NULL && +// pView->TakeTextEditObject(aMDPos, pObj, pPV) ) + pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT) ) + { + SdrOutliner* pO = MakeOutliner(); + lcl_UpdateHyphenator( *pO, pObj ); + + // vertical flag: + // deduced from slot ids only if text object has no content + + USHORT nSlotID = aSfxRequest.GetSlot(); + BOOL bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL ); + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + if ( pOPO ) + bVertical = pOPO->IsVertical(); // content wins + pO->SetVertical( bVertical ); + + //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!? + if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) ) + { + // EditEngine-UndoManager anmelden + pViewShell->SetDrawTextUndo( &pO->GetUndoManager() ); + + OutlinerView* pOLV = pView->GetTextEditOutlinerView(); + if ( pOLV->MouseButtonDown(rMEvt) ) + return (TRUE); // Event an den Outliner + } + } + else + { + // disable tail & circular move for caption objects. + bool bDrag = false; + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pMarkedObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + if( ScDrawLayer::IsNoteCaption( pMarkedObj ) ) + { + if(pHdl->GetKind() != HDL_POLY && pHdl->GetKind() != HDL_CIRC) + bDrag = true; + } + else + bDrag = true; // different object + } + else + bDrag = true; // several objects + + if ( bDrag ) + { + aDragTimer.Start(); + pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl); + } + } + } + else + { + BOOL bMacro = FALSE; + +// if (bMacro && pView->TakeMacroObject(aMDPos,pObj,pPV)) + if (bMacro && pView->PickObj(aMDPos, pView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKMACRO) ) + + { + pView->BegMacroObj(aMDPos,pObj,pPV,pWindow); + } + else + { + if (pView->IsEditMode()) + { + BOOL bPointMode=pView->HasMarkablePoints(); + + if (!rMEvt.IsShift()) + { + if (bPointMode) + { + pView->UnmarkAllPoints(); + } + else + { + pView->UnmarkAll(); + } + + pView->SetDragMode(SDRDRAG_MOVE); + SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_OBJECT_ROTATE ); + rBindings.Invalidate( SID_OBJECT_MIRROR ); + pHdl=pView->GetHdl(nHdlNum); + } + + if ( pView->MarkObj(aMDPos, -2, FALSE, rMEvt.IsMod1()) ) + { + aDragTimer.Start(); + + pHdl=pView->PickHandle(aMDPos); + + if (pHdl!=NULL) + { + pView->MarkPoint(*pHdl); + pHdl=pView->GetHdl(nHdlNum); + } + + pView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl); + } + else + { + if (bPointMode) + { + pView->BegMarkPoints(aMDPos); + } + else + { + pView->BegMarkObj(aMDPos); + } + } + } + else if (aSfxRequest.GetSlot() == SID_DRAW_NOTEEDIT ) + { + // Notizen editieren -> keine neuen Textobjekte erzeugen, + // stattdessen Textmodus verlassen + + pViewShell->GetViewData()->GetDispatcher(). + Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + } + else + { + /********************************************************** + * Objekt erzeugen + **********************************************************/ + pView->BegCreateObj(aMDPos, (OutputDevice*) NULL); + } + } + } + } + + + if (!bIsInDragMode) + { + pWindow->CaptureMouse(); +// ForcePointer(&rMEvt); + lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() ); + } + + pViewShell->SetActivePointer(pView->GetPreferedPointer( + pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow )); + +// return (bReturn); + return TRUE; +} + +/************************************************************************* +|* +|* MouseMove-event +|* +\************************************************************************/ + +BOOL __EXPORT FuText::MouseMove(const MouseEvent& rMEvt) +{ + BOOL bReturn = FALSE; + +// pViewShell->SetActivePointer(aNewPointer); + + pViewShell->SetActivePointer(pView->GetPreferedPointer( + pWindow->PixelToLogic(rMEvt.GetPosPixel()), pWindow )); + + if (aDragTimer.IsActive() ) + { + Point aOldPixel = pWindow->LogicToPixel( aMDPos ); + Point aNewPixel = rMEvt.GetPosPixel(); + if ( Abs( aOldPixel.X() - aNewPixel.X() ) > SC_MAXDRAGMOVE || + Abs( aOldPixel.Y() - aNewPixel.Y() ) > SC_MAXDRAGMOVE ) + aDragTimer.Stop(); + } + + if ( pView->MouseMove(rMEvt, pWindow) ) + return (TRUE); // Event von der SdrView ausgewertet + + if ( pView->IsAction() ) + { +/* aNewPointer = Pointer(POINTER_TEXT); + pViewShell->SetActivePointer(aNewPointer); +*/ + Point aPix(rMEvt.GetPosPixel()); + Point aPnt(pWindow->PixelToLogic(aPix)); + + ForceScroll(aPix); + pView->MovAction(aPnt); + } + +// ForcePointer(&rMEvt); + + return (bReturn); +} + +/************************************************************************* +|* +|* MouseButtonUp-event +|* +\************************************************************************/ + +BOOL __EXPORT FuText::MouseButtonUp(const MouseEvent& rMEvt) +{ + // #95491# remember button state for creation of own MouseEvents + SetMouseButtonCode(rMEvt.GetButtons()); + + BOOL bReturn = FALSE; + + if (aDragTimer.IsActive() ) + { + aDragTimer.Stop(); + } + + lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() ); + + Point aPnt( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + + if ( pView->MouseButtonUp(rMEvt, pWindow) ) + return (TRUE); // Event von der SdrView ausgewertet + + if ( pView->IsDragObj() ) + { + pView->EndDragObj( rMEvt.IsShift() ); + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + FuPoor* pPoor = pViewShell->GetViewData()->GetView()->GetDrawFuncPtr(); + FuText* pText = static_cast<FuText*>(pPoor); + pText->StopDragMode(pObj ); + } + pView->ForceMarkedToAnotherPage(); + } + else if ( pView->IsCreateObj() ) + { + if (rMEvt.IsLeft()) + { + pView->EndCreateObj(SDRCREATE_FORCEEND); + if (aSfxRequest.GetSlot() == SID_DRAW_TEXT_MARQUEE) + { + // Lauftext-Objekt erzeugen? + + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMark(0)) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + + // die fuer das Scrollen benoetigten Attribute setzen + SfxItemSet aItemSet( pDrDoc->GetItemPool(), + SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST); + + aItemSet.Put( SdrTextAutoGrowWidthItem( FALSE ) ); + aItemSet.Put( SdrTextAutoGrowHeightItem( FALSE ) ); + aItemSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) ); + aItemSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) ); + aItemSet.Put( SdrTextAniCountItem( 1 ) ); + aItemSet.Put( SdrTextAniAmountItem( + (INT16)pWindow->PixelToLogic(Size(2,1)).Width()) ); + pObj->SetMergedItemSetAndBroadcast(aItemSet); + } + } + + // #93382# init object different when vertical writing + sal_uInt16 nSlotID(aSfxRequest.GetSlot()); + BOOL bVertical = (SID_DRAW_TEXT_VERTICAL == nSlotID); + if(bVertical) + { + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if(rMarkList.GetMark(0)) + { + SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); + if(pObj && pObj->ISA(SdrTextObj)) + { + SdrTextObj* pText = (SdrTextObj*)pObj; + SfxItemSet aSet(pDrDoc->GetItemPool()); + + pText->SetVerticalWriting(TRUE); + + aSet.Put(SdrTextAutoGrowWidthItem(TRUE)); + aSet.Put(SdrTextAutoGrowHeightItem(FALSE)); + aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); + aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); + + pText->SetMergedItemSet(aSet); + } + } + } + + SetInEditMode(); + + // Modus verlassen bei einzelnem Klick + // (-> fuconstr) + + if ( !pView->AreObjectsMarked() ) + { + pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1()); + + SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher(); + if ( pView->AreObjectsMarked() ) + rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + else + rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + } + } + } + else if ( pView->IsAction() ) + { + pView->EndAction(); + } + else if( !pView->IsAction() ) + { + pWindow->ReleaseMouse(); + + if ( !pView->AreObjectsMarked() && rMEvt.GetClicks() < 2 ) + { + pView->MarkObj(aPnt, -2, FALSE, rMEvt.IsMod1()); + + SfxDispatcher& rDisp = pViewShell->GetViewData()->GetDispatcher(); + if ( pView->AreObjectsMarked() ) + rDisp.Execute(SID_OBJECT_SELECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + else + rDisp.Execute(aSfxRequest.GetSlot(), SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD); + } + } + + return (bReturn); +} + +/************************************************************************* +|* +|* Maus-Pointer umschalten +|* +\************************************************************************/ + +void FuText::ForcePointer(const MouseEvent* /* pMEvt */) +{ + pViewShell->SetActivePointer( aNewPointer ); + +/* + if ( !pView->IsAction() ) + { + Point aPnt(pWindow->PixelToLogic( pWindow->ScreenToOutputPixel( + Pointer::GetPosPixel() ) ) ); + SdrHdl* pHdl=pView->HitHandle(aPnt, *pWindow); + + if (pHdl!=NULL) + { + pViewShell->SetActivePointer(pHdl->GetPointer() ); + } + else + { + SdrObject* pObj; + SdrPageView* pPV; + + if ( pView->IsMarkedHit(aPnt) ) + { + if ( pView->TakeTextEditObject(aPnt, pObj, pPV) ) + { + pViewShell->SetActivePointer(Pointer(POINTER_TEXT)); + } + else + { + pViewShell->SetActivePointer(Pointer(POINTER_MOVE)); + } + } + else + { +// if ( pView->TakeMacroObject(aPnt, pObj, pPV) ) + if ( pView->PickObj(aPnt, pObj, pPV, SDRSEARCH_PICKMACRO) ) + { + pViewShell->SetActivePointer( pObj->GetMacroPointer() ); + } + else + { + pViewShell->SetActivePointer( aNewPointer ); + } + } + } + } +*/ +} + + + +/************************************************************************* +|* +|* Tastaturereignisse bearbeiten +|* +|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls +|* FALSE. +|* +\************************************************************************/ + +BOOL __EXPORT FuText::KeyInput(const KeyEvent& rKEvt) +{ + BOOL bReturn = FALSE; + + if ( pView->KeyInput(rKEvt, pWindow) ) + { + bReturn = TRUE; + lcl_InvalidateAttribs( pViewShell->GetViewFrame()->GetBindings() ); + } + else + { + bReturn = FuDraw::KeyInput(rKEvt); + } + + return (bReturn); +} + + + +/************************************************************************* +|* +|* Function aktivieren +|* +\************************************************************************/ + +void FuText::Activate() +{ + pView->SetDragMode(SDRDRAG_MOVE); + SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_OBJECT_ROTATE ); + rBindings.Invalidate( SID_OBJECT_MIRROR ); + +// Sofort in den Edit Mode setzen +// SetInEditMode(); + +// if (!pTextObj) + { + /********************************************************************** + * Kein Textobjekt im EditMode, daher CreateMode setzen + **********************************************************************/ + USHORT nObj = OBJ_TEXT; + +/* UINT16 nIdent; + UINT32 nInvent; + pView->TakeCurrentObj(nIdent, nInvent); +*/ + pView->SetCurrentObj(nObj); + + pView->SetCreateMode(); + } + + aNewPointer = Pointer(POINTER_TEXT); +// aNewPointer = Pointer(POINTER_CROSS); //! ??? + + aOldPointer = pWindow->GetPointer(); + pViewShell->SetActivePointer( aNewPointer ); + + FuConstruct::Activate(); +} + + +/************************************************************************* +|* +|* Function deaktivieren +|* +\************************************************************************/ + +void FuText::Deactivate() +{ + FuConstruct::Deactivate(); + pViewShell->SetActivePointer( aOldPointer ); + StopEditMode(); +} + + +/************************************************************************* +|* +|* Selektion hat sich geaendert +|* +\************************************************************************/ + +void FuText::SelectionHasChanged() +{ + pView->SetDragMode(SDRDRAG_MOVE); + SfxBindings& rBindings = pViewShell->GetViewFrame()->GetBindings(); + rBindings.Invalidate( SID_OBJECT_ROTATE ); + rBindings.Invalidate( SID_OBJECT_MIRROR ); + + pTextObj = NULL; + + if ( pView->AreObjectsMarked() ) + { + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + SdrObject* pObj = pMark->GetMarkedSdrObj(); + + UINT16 nSdrObjKind = pObj->GetObjIdentifier(); + + if (nSdrObjKind == OBJ_TEXT || + nSdrObjKind == OBJ_TITLETEXT || + nSdrObjKind == OBJ_OUTLINETEXT /* || + pObj->ISA(SdrTextObj) */ ) + { + pTextObj = (SdrTextObj*) pObj; + } + } + } + + if (!pTextObj) + { + /********************************************************************** + * Kein Textobjekt im EditMode, daher CreateMode setzen + **********************************************************************/ + USHORT nObj = OBJ_TEXT; + UINT16 nIdent; + UINT32 nInvent; + pView->TakeCurrentObj(nIdent, nInvent); + +// if (! pView->IsEditMode() ) +// { +// if (nIdent == OBJ_TEXT) +// { +// nObj = OBJ_TEXT; +// } +// else if (nIdent == OBJ_OUTLINETEXT) +// { +// nObj = OBJ_OUTLINETEXT; +// } +// else if (nIdent == OBJ_TITLETEXT) +// { +// nObj = OBJ_TITLETEXT; +// } +// } + + pView->SetCurrentObj(nObj); + + pView->SetCreateMode(); + } +} + +/************************************************************************* +|* +|* Objekt in Edit-Mode setzen +|* +\************************************************************************/ + +void FuText::SetInEditMode(SdrObject* pObj, const Point* pMousePixel, + BOOL bCursorToEnd, const KeyEvent* pInitialKey) +{ + /* It is possible to pass a special (unselected) object in pObj, e.g. the + caption object of a cell note. If pObj is 0, then the selected object + is used. The layer will be relocked in FuText::StopEditMode(). */ + if ( pObj && (pObj->GetLayer() == SC_LAYER_INTERN) ) + pView->UnlockInternalLayer(); + + if ( !pObj && pView->AreObjectsMarked() ) + { + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + if (rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + pObj = pMark->GetMarkedSdrObj(); + } + } + + pTextObj = NULL; + + if ( pObj ) + { + UINT16 nSdrObjKind = pObj->GetObjIdentifier(); + + if (nSdrObjKind == OBJ_TEXT || + nSdrObjKind == OBJ_TITLETEXT || + nSdrObjKind == OBJ_OUTLINETEXT || + pObj->ISA(SdrTextObj)) + { + SdrPageView* pPV = pView->GetSdrPageView(); + Rectangle aRect = pObj->GetLogicRect(); + Point aPnt = aRect.Center(); + + if ( pObj->HasTextEdit() ) + { + SdrOutliner* pO = MakeOutliner(); + lcl_UpdateHyphenator( *pO, pObj ); + + // vertical flag: + // deduced from slot ids only if text object has no content + + USHORT nSlotID = aSfxRequest.GetSlot(); + BOOL bVertical = ( nSlotID == SID_DRAW_TEXT_VERTICAL ); + OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); + if ( pOPO ) + bVertical = pOPO->IsVertical(); // content wins + pO->SetVertical( bVertical ); + + //!?? ohne uebergebenen Outliner stimmen die Defaults nicht ???!? + if ( pView->SdrBeginTextEdit(pObj, pPV, pWindow, sal_True, pO) ) + { + // EditEngine-UndoManager anmelden + pViewShell->SetDrawTextUndo( &pO->GetUndoManager() ); + + pTextObj = (SdrTextObj*) pObj; + pView->SetEditMode(); + + // set text cursor to click position or to end, + // pass initial key event to outliner view + if ( pMousePixel || bCursorToEnd || pInitialKey ) + { + OutlinerView* pOLV = pView->GetTextEditOutlinerView(); + if (pOLV) + { + if ( pMousePixel ) + { + MouseEvent aEditEvt( *pMousePixel, 1, MOUSE_SYNTHETIC, MOUSE_LEFT, 0 ); + pOLV->MouseButtonDown(aEditEvt); + pOLV->MouseButtonUp(aEditEvt); + } + else if ( bCursorToEnd ) + { + ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND); + pOLV->SetSelection(aNewSelection); + } + + if ( pInitialKey ) + pOLV->PostKeyEvent( *pInitialKey ); + } + } + } + } + } + } +} + +// #98185# Create default drawing objects via keyboard +SdrObject* FuText::CreateDefaultObject(const sal_uInt16 nID, const Rectangle& rRectangle) +{ + // case SID_DRAW_TEXT: + // case SID_DRAW_TEXT_VERTICAL: + // case SID_DRAW_TEXT_MARQUEE: + // case SID_DRAW_NOTEEDIT: + + SdrObject* pObj = SdrObjFactory::MakeNewObject( + pView->GetCurrentObjInventor(), pView->GetCurrentObjIdentifier(), + 0L, pDrDoc); + + if(pObj) + { + if(pObj->ISA(SdrTextObj)) + { + SdrTextObj* pText = (SdrTextObj*)pObj; + pText->SetLogicRect(rRectangle); + + // #105815# don't set default text, start edit mode instead + // String aText(ScResId(STR_CAPTION_DEFAULT_TEXT)); + // pText->SetText(aText); + + sal_Bool bVertical = (SID_DRAW_TEXT_VERTICAL == nID); + sal_Bool bMarquee = (SID_DRAW_TEXT_MARQUEE == nID); + + pText->SetVerticalWriting(bVertical); + + if(bVertical) + { + SfxItemSet aSet(pDrDoc->GetItemPool()); + + aSet.Put(SdrTextAutoGrowWidthItem(TRUE)); + aSet.Put(SdrTextAutoGrowHeightItem(FALSE)); + aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_TOP)); + aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT)); + + pText->SetMergedItemSet(aSet); + } + + if(bMarquee) + { + SfxItemSet aSet(pDrDoc->GetItemPool(), SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST); + + aSet.Put( SdrTextAutoGrowWidthItem( FALSE ) ); + aSet.Put( SdrTextAutoGrowHeightItem( FALSE ) ); + aSet.Put( SdrTextAniKindItem( SDRTEXTANI_SLIDE ) ); + aSet.Put( SdrTextAniDirectionItem( SDRTEXTANI_LEFT ) ); + aSet.Put( SdrTextAniCountItem( 1 ) ); + aSet.Put( SdrTextAniAmountItem( (INT16)pWindow->PixelToLogic(Size(2,1)).Width()) ); + + pObj->SetMergedItemSetAndBroadcast(aSet); + } + + SetInEditMode( pObj ); // #105815# start edit mode + } + else + { + DBG_ERROR("Object is NO text object"); + } + } + + return pObj; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/futext2.cxx b/sc/source/ui/drawfunc/futext2.cxx new file mode 100644 index 000000000000..354339dd0d75 --- /dev/null +++ b/sc/source/ui/drawfunc/futext2.cxx @@ -0,0 +1,309 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------------ + +// TOOLS +#define _BIGINT_HXX +#define _SFXMULTISEL_HXX +#define _STACK_HXX +#define _QUEUE_HXX +#define _DYNARR_HXX +#define _TREELIST_HXX +#define _CACHESTR_HXX +#define _NEW_HXX +//#define _SHL_HXX +//#define _LINK_HXX +//#define _ERRCODE_HXX +//#define _GEN_HXX +//#define _FRACT_HXX +//#define _STRING_HXX +//#define _MTF_HXX +//#define _CONTNR_HXX +//#define _LIST_HXX +//#define _TABLE_HXX +#define _DYNARY_HXX +//#define _UNQIDX_HXX +#define _SVMEMPOOL_HXX +//#define _UNQID_HXX +//#define _DEBUG_HXX +//#define _DATE_HXX +//#define _TIME_HXX +//#define _DATETIME_HXX +//#define _INTN_HXX +//#define _WLDCRD_HXX +//#define _FSYS_HXX +//#define _STREAM_HXX +#define _CACHESTR_HXX +#define _SV_MULTISEL_HXX + +//SV +//#define _CLIP_HXX *** +#define _CONFIG_HXX +#define _CURSOR_HXX +#define _FONTDLG_HXX +#define _PRVWIN_HXX +//#define _COLOR_HXX +//#define _PAL_HXX +//#define _BITMAP_HXX +//#define _GDIOBJ_HXX +//#define _POINTR_HXX +//#define _ICON_HXX +//#define _IMAGE_HXX +//#define _KEYCOD_HXX +//#define _EVENT_HXX +#define _HELP_HXX +//#define _APP_HXX +//#define _MDIAPP_HXX +//#define _TIMER_HXX +//#define _METRIC_HXX +//#define _REGION_HXX +//#define _OUTDEV_HXX +//#define _SYSTEM_HXX +//#define _VIRDEV_HXX +//#define _JOBSET_HXX +//#define _PRINT_HXX +//#define _WINDOW_HXX +//#define _SYSWIN_HXX +//#define _WRKWIN_HXX +#define _MDIWIN_HXX +//#define _FLOATWIN_HXX +//#define _DOCKWIN_HXX +//#define _CTRL_HXX +//#define _SCRBAR_HXX +//#define _BUTTON_HXX +//#define _IMAGEBTN_HXX +//#define _FIXED_HXX +//#define _GROUP_HXX +//#define _EDIT_HXX +//#define _COMBOBOX_HXX +//#define _LSTBOX_HXX +//#define _SELENG_HXX *** +//#define _SPLIT_HXX +#define _SPIN_HXX +//#define _FIELD_HXX +//#define _MOREBTN_HXX *** +//#define _TOOLBOX_HXX +#define _STATUS_HXX +#define _SVTCTRL3_HXX +//#define _DIALOG_HXX +//#define _MSGBOX_HXX +//#define _SYSDLG_HXX +//#define _FILDLG_HXX *** +//#define _PRNDLG_HXX +#define _COLDLG_HXX +//#define _TABDLG_HXX +//#define _MENU_HXX *** +//#define _GDIMTF_HXX +//#define _POLY_HXX +//#define _ACCEL_HXX +//#define _GRAPH_HXX +#define _SOUND_HXX + +#if defined WIN +#define _MENUBTN_HXX +#endif + +//svtools +#define _SCRWIN_HXX +#define _RULER_HXX +//#define _TABBAR_HXX +//#define _VALUESET_HXX +#define _STDMENU_HXX +//#define _STDCTRL_HXX +//#define _CTRLBOX_HXX +#define _CTRLTOOL_HXX +#define _EXTATTR_HXX +#define _FRM3D_HXX +#define _EXTATTR_HXX + +//SVTOOLS +//#define _SVTREELIST_HXX +#define _FILTER_HXX +//#define _SVLBOXITM_HXX +//#define _SVTREEBOX_HXX +#define _SVICNVW_HXX +#define _SVTABBX_HXX + +//sfxcore.hxx +//#define _SFXINIMGR_HXX +//#define _SFXCFGITEM_HXX +//#define _SFX_PRINTER_HXX +#define _SFXGENLINK_HXX +#define _SFXHINTPOST_HXX +#define _SFXDOCINF_HXX +#define _SFXLINKHDL_HXX +//#define _SFX_PROGRESS_HXX + +//sfxsh.hxx +//#define _SFX_SHELL_HXX +//#define _SFXAPP_HXX +//#define _SFXDISPATCH_HXX +//#define _SFXMSG_HXX +//#define _SFXOBJFACE_HXX +//#define _SFXREQUEST_HXX +#define _SFXMACRO_HXX + +// SFX +//#define _SFXAPPWIN_HXX +#define _SFX_SAVEOPT_HXX +//#define _SFX_CHILDWIN_HXX +//#define _SFXCTRLITEM_HXX +#define _SFXPRNMON_HXX +#define _INTRO_HXX +#define _SFXMSGDESCR_HXX +#define _SFXMSGPOOL_HXX +#define _SFXFILEDLG_HXX +#define _PASSWD_HXX +#define _SFXTBXCTRL_HXX +#define _SFXSTBITEM_HXX +#define _SFXMNUITEM_HXX +#define _SFXIMGMGR_HXX +#define _SFXTBXMGR_HXX +#define _SFXSTBMGR_HXX +#define _SFX_MINFITEM_HXX +#define _SFXEVENT_HXX + +//sfxdoc.hxx +//#define _SFX_OBJSH_HXX +//#define _SFX_CLIENTSH_HXX +//#define _SFXDOCINF_HXX +//#define _SFX_OBJFAC_HXX +#define _SFX_DOCFILT_HXX +//#define _SFXDOCFILE_HXX +//define _VIEWFAC_HXX +//#define _SFXVIEWFRM_HXX +//#define _SFXVIEWSH_HXX +//#define _MDIFRM_HXX +#define _SFX_IPFRM_HXX +//#define _SFX_INTERNO_HXX + +//sfxdlg.hxx +//#define _SFXTABDLG_HXX +//#define _BASEDLGS_HXX +#define _SFX_DINFDLG_HXX +#define _SFXDINFEDT_HXX +#define _SFX_MGETEMPL_HXX +#define _SFX_TPLPITEM_HXX +//#define _SFX_STYLEDLG_HXX +#define _NEWSTYLE_HXX +//#define _SFXDOCTEMPL_HXX +//#define _SFXDOCTDLG_HXX +//#define _SFX_TEMPLDLG_HXX +//#define _SFXNEW_HXX +#define _SFXDOCMAN_HXX +//#define _SFXDOCKWIN_HXX ** + +//sfxitems.hxx +#define _SFX_WHMAP_HXX +//#define _ARGS_HXX *** +//#define _SFXPOOLITEM_HXX +//#define _SFXINTITEM_HXX +//#define _SFXENUMITEM_HXX +#define _SFXFLAGITEM_HXX +//#define _SFXSTRITEM_HXX +#define _SFXPTITEM_HXX +#define _SFXRECTITEM_HXX +//#define _SFXITEMPOOL_HXX +//#define _SFXITEMSET_HXX +#define _SFXITEMITER_HXX +#define _SFX_WHITER_HXX +#define _SFXPOOLCACH_HXX +//#define _AEITEM_HXX +#define _SFXRNGITEM_HXX +//#define _SFXSLSTITM_HXX +//#define _SFXSTYLE_HXX + +//xout.hxx +//#define _XENUM_HXX +//#define _XPOLY_HXX +//#define _XATTR_HXX +//#define _XOUTX_HXX +//#define _XPOOL_HXX +//#define _XTABLE_HXX + +//svdraw.hxx +#define _SDR_NOITEMS +#define _SDR_NOTOUCH +#define _SDR_NOTRANSFORM +//#define _SDR_NOOBJECTS +//#define _SDR_NOVIEWS + +//#define SI_NOITEMS +//#define SI_NODRW +#define _SI_NOSBXCONTROLS +#define _VCATTR_HXX +#define _VCONT_HXX +//#define _VCSBX_HXX *** +#define _SI_NOOTHERFORMS +#define _VCTRLS_HXX +//#define _VCDRWOBJ_HXX *** +#define _SI_NOCONTROL +#define _SETBRW_HXX +#define _VCBRW_HXX +#define _SI_NOSBXCONTROLS +#define _SIDLL_HXX + +//------------------------------------------------------------------------ + +#include <svx/svdmodel.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svdetc.hxx> + +#include "futext.hxx" +#include "tabvwsh.hxx" + +//------------------------------------------------------------------------ + +SdrOutliner* FuText::MakeOutliner() +{ + ScViewData* pViewData = pViewShell->GetViewData(); + SdrOutliner* pOutl = SdrMakeOutliner(OUTLINERMODE_OUTLINEOBJECT, pDrDoc); + + pViewData->UpdateOutlinerFlags(*pOutl); + + // Die EditEngine benutzt beim RTF Export (Clipboard / Drag&Drop) + // den MapMode des RefDevices, um die Fontgroesse zu setzen + + // #i10426# The ref device isn't set to the EditEngine before SdrBeginTextEdit now, + // so the device must be taken from the model here. + OutputDevice* pRef = pDrDoc->GetRefDevice(); + if (pRef && pRef != pWindow) + pRef->SetMapMode( MapMode(MAP_100TH_MM) ); + + return pOutl; +} + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx new file mode 100644 index 000000000000..09a4240c0678 --- /dev/null +++ b/sc/source/ui/drawfunc/futext3.cxx @@ -0,0 +1,200 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <editeng/editeng.hxx> +#include <editeng/outlobj.hxx> +#include <svx/svdocapt.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdundo.hxx> +#include <svx/svdview.hxx> +#include <editeng/editobj.hxx> +#include <vcl/cursor.hxx> +#include <sfx2/objsh.hxx> +#include <editeng/writingmodeitem.hxx> + +#include "global.hxx" +#include "drwlayer.hxx" +#include "userdat.hxx" +#include "tabvwsh.hxx" // oder GetDocument irgendwo +#include "document.hxx" +#include "editutil.hxx" +#include "futext.hxx" +#include "docsh.hxx" +#include "postit.hxx" +#include "globstr.hrc" +#include "attrib.hxx" +#include "scitems.hxx" +#include "drawview.hxx" +#include "undocell.hxx" + +// ------------------------------------------------------------------------------------ +// Editieren von Notiz-Legendenobjekten muss immer ueber StopEditMode beendet werden, +// damit die Aenderungen ins Dokument uebernommen werden! +// (Fontwork-Execute in drawsh und drtxtob passiert nicht fuer Legendenobjekte) +// bTextDirection=TRUE means that this function is called from SID_TEXTDIRECTION_XXX(drtxtob.cxx). +// ------------------------------------------------------------------------------------ + +void FuText::StopEditMode(BOOL /*bTextDirection*/) +{ + SdrObject* pObject = pView->GetTextEditObject(); + if( !pObject ) return; + + // relock the internal layer that has been unlocked in FuText::SetInEditMode() + if ( pObject->GetLayer() == SC_LAYER_INTERN ) + pView->LockInternalLayer(); + + ScViewData& rViewData = *pViewShell->GetViewData(); + ScDocument& rDoc = *rViewData.GetDocument(); + ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer(); + DBG_ASSERT( pDrawLayer && (pDrawLayer == pDrDoc), "FuText::StopEditMode - missing or different drawing layers" ); + + ScAddress aNotePos; + ScPostIt* pNote = 0; + if( const ScDrawObjData* pCaptData = ScDrawLayer::GetNoteCaptionData( pObject, rViewData.GetTabNo() ) ) + { + aNotePos = pCaptData->maStart; + pNote = rDoc.GetNote( aNotePos ); + DBG_ASSERT( pNote && (pNote->GetCaption() == pObject), "FuText::StopEditMode - missing or invalid cell note" ); + } + + ScDocShell* pDocShell = rViewData.GetDocShell(); + SfxUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? pDocShell->GetUndoManager() : 0; + bool bNewNote = false; + if( pNote && pUndoMgr ) + { + /* Put all undo actions already collected (e.g. create caption object) + and all following undo actions (text changed) together into a ListAction. */ + String aUndoStr = ScGlobal::GetRscString( STR_UNDO_EDITNOTE ); + pUndoMgr->EnterListAction( aUndoStr, aUndoStr ); + if( SdrUndoGroup* pCalcUndo = pDrawLayer->GetCalcUndo() ) + { + /* Note has been created before editing, if first undo action is + an insert action. Needed below to decide whether to drop the + undo if editing a new note has been cancelled. */ + bNewNote = (pCalcUndo->GetActionCount() > 0) && pCalcUndo->GetAction( 0 )->ISA( SdrUndoNewObj ); + // create a "insert note" undo action if needed + if( bNewNote ) + pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, pNote->GetNoteData(), true, pCalcUndo ) ); + else + pUndoMgr->AddUndoAction( pCalcUndo ); + } + } + + if( pNote ) + rDoc.LockStreamValid(true); // only the affected sheet is invalidated below + + /* SdrObjEditView::SdrEndTextEdit() may try to delete the entire drawing + object, if it does not contain text and has invisible border and fill. + This must not happen for note caption objects. They will be removed + below together with the cell note if the text is empty (independent of + border and area formatting). It is possible to prevent automatic + deletion by passing sal_True to this function. The return value changes + from SDRENDTEXTEDIT_DELETED to SDRENDTEXTEDIT_SHOULDBEDELETED in this + case. */ + /*SdrEndTextEditKind eResult =*/ pView->SdrEndTextEdit( pNote != 0 ); + + // or ScEndTextEdit (with drawview.hxx) + pViewShell->SetDrawTextUndo( 0 ); + + Cursor* pCur = pWindow->GetCursor(); + if( pCur && pCur->IsVisible() ) + pCur->Hide(); + + if( pNote ) + { + // hide the caption object if it is in hidden state + pNote->ShowCaptionTemp( aNotePos, false ); + + // update author and date + pNote->AutoStamp(); + + /* If the entire text has been cleared, the cell note and its caption + object have to be removed. */ + SdrTextObj* pTextObject = dynamic_cast< SdrTextObj* >( pObject ); + bool bDeleteNote = !pTextObject || !pTextObject->HasText(); + if( bDeleteNote ) + { + if( pUndoMgr ) + { + // collect the "remove object" drawing undo action created by DeleteNote() + pDrawLayer->BeginCalcUndo(); + // rescue note data before deletion + ScNoteData aNoteData( pNote->GetNoteData() ); + // delete note from document (removes caption, but does not delete it) + rDoc.DeleteNote( aNotePos ); + // create undo action for removed note + pUndoMgr->AddUndoAction( new ScUndoReplaceNote( *pDocShell, aNotePos, aNoteData, false, pDrawLayer->GetCalcUndo() ) ); + } + else + { + rDoc.DeleteNote( aNotePos ); + } + // ScDocument::DeleteNote has deleted the note that pNote points to + pNote = 0; + } + + // finalize the undo list action + if( pUndoMgr ) + { + pUndoMgr->LeaveListAction(); + + /* #i94039# Update the default name "Edit Note" of the undo action + if the note has been created before editing or is deleted due + to deleted text. If the note has been created *and* is deleted, + the last undo action can be removed completely. Note: The + function LeaveListAction() removes the last action by itself, + if it is empty (when result is SDRENDTEXTEDIT_UNCHANGED). */ + if( bNewNote && bDeleteNote ) + { + pUndoMgr->RemoveLastUndoAction(); + } + else if( bNewNote || bDeleteNote ) + { + SfxListUndoAction* pAction = dynamic_cast< SfxListUndoAction* >( pUndoMgr->GetUndoAction() ); + DBG_ASSERT( pAction, "FuText::StopEditMode - list undo action expected" ); + if( pAction ) + pAction->SetComment( ScGlobal::GetRscString( bNewNote ? STR_UNDO_INSERTNOTE : STR_UNDO_DELETENOTE ) ); + } + } + + // invalidate stream positions only for the affected sheet + rDoc.LockStreamValid(false); + if (rDoc.IsStreamValid(aNotePos.Tab())) + rDoc.SetStreamValid(aNotePos.Tab(), FALSE); + } +} + +// Called following an EndDragObj() to update the new note rectangle position +void FuText::StopDragMode(SdrObject* /*pObject*/) +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/graphsh.cxx b/sc/source/ui/drawfunc/graphsh.cxx new file mode 100644 index 000000000000..101ce8578f05 --- /dev/null +++ b/sc/source/ui/drawfunc/graphsh.cxx @@ -0,0 +1,150 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------ + +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/request.hxx> +#include <svl/whiter.hxx> +#include <svx/svdograf.hxx> +#include <svx/grfflt.hxx> +#include <svx/grafctrl.hxx> + +#include "graphsh.hxx" +#include "sc.hrc" +#include "viewdata.hxx" +#include "drawview.hxx" +#include "scresid.hxx" + +#define ScGraphicShell +#include "scslots.hxx" + +#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() + + +SFX_IMPL_INTERFACE(ScGraphicShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, + ScResId(RID_GRAPHIC_OBJECTBAR) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_GRAPHIC) ); +} + +TYPEINIT1( ScGraphicShell, ScDrawShell ); + +ScGraphicShell::ScGraphicShell(ScViewData* pData) : + ScDrawShell(pData) +{ + SetHelpId(HID_SCSHELL_GRAPHIC); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GraphicObject"))); +} + +ScGraphicShell::~ScGraphicShell() +{ +} + +void ScGraphicShell::GetAttrState( SfxItemSet& rSet ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + + if( pView ) + SvxGrafAttrHelper::GetGrafAttrState( rSet, *pView ); +} + +void ScGraphicShell::Execute( SfxRequest& rReq ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + + if( pView ) + { + SvxGrafAttrHelper::ExecuteGrafAttr( rReq, *pView ); + Invalidate(); + } +} + +void ScGraphicShell::GetFilterState( SfxItemSet& rSet ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + BOOL bEnable = FALSE; + + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrGrafObj ) && ( ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) ) + bEnable = TRUE; + } + + if( !bEnable ) + SvxGraphicFilter::DisableGraphicFilterSlots( rSet ); +} + +void ScGraphicShell::ExecuteFilter( SfxRequest& rReq ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + const SdrMarkList& rMarkList = pView->GetMarkedObjectList(); + + if( rMarkList.GetMarkCount() == 1 ) + { + SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrGrafObj ) && ( (SdrGrafObj*) pObj )->GetGraphicType() == GRAPHIC_BITMAP ) + { + GraphicObject aFilterObj( ( (SdrGrafObj*) pObj )->GetGraphicObject() ); + + if( SVX_GRAPHICFILTER_ERRCODE_NONE == + SvxGraphicFilter::ExecuteGrfFilterSlot( rReq, aFilterObj ) ) + { + SdrPageView* pPageView = pView->GetSdrPageView(); + + if( pPageView ) + { + SdrGrafObj* pFilteredObj = (SdrGrafObj*) pObj->Clone(); + String aStr( pView->GetDescriptionOfMarkedObjects() ); + + aStr.Append( sal_Unicode(' ') ); + aStr.Append( String( ScResId( SCSTR_UNDO_GRAFFILTER ) ) ); + pView->BegUndo( aStr ); + pFilteredObj->SetGraphicObject( aFilterObj ); + pView->ReplaceObjectAtView( pObj, *pPageView, pFilteredObj ); + pView->EndUndo(); + } + } + } + } + + Invalidate(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/makefile.mk b/sc/source/ui/drawfunc/makefile.mk new file mode 100644 index 000000000000..41aa76331df5 --- /dev/null +++ b/sc/source/ui/drawfunc/makefile.mk @@ -0,0 +1,84 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=sc +TARGET=drawfunc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SRS1NAME=$(TARGET) +SRC1FILES = \ + objdraw.src\ + drformsh.src + +SLOFILES = \ + $(EXCEPTIONSFILES) + +EXCEPTIONSFILES= \ + $(SLO)$/chartsh.obj \ + $(SLO)$/drawsh.obj \ + $(SLO)$/drawsh2.obj \ + $(SLO)$/drawsh4.obj \ + $(SLO)$/drawsh5.obj \ + $(SLO)$/drformsh.obj \ + $(SLO)$/drtxtob.obj \ + $(SLO)$/drtxtob1.obj \ + $(SLO)$/drtxtob2.obj \ + $(SLO)$/fuconarc.obj \ + $(SLO)$/fuconcustomshape.obj \ + $(SLO)$/fuconpol.obj \ + $(SLO)$/fuconrec.obj \ + $(SLO)$/fuconstr.obj \ + $(SLO)$/fuconuno.obj \ + $(SLO)$/fudraw.obj \ + $(SLO)$/fuins1.obj \ + $(SLO)$/fuins2.obj \ + $(SLO)$/fumark.obj \ + $(SLO)$/fupoor.obj \ + $(SLO)$/fusel.obj \ + $(SLO)$/fusel2.obj \ + $(SLO)$/futext.obj \ + $(SLO)$/futext2.obj \ + $(SLO)$/futext3.obj \ + $(SLO)$/graphsh.obj \ + $(SLO)$/mediash.obj \ + $(SLO)$/oleobjsh.obj + +NOOPTFILES=\ + $(SLO)$/fusel.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + diff --git a/sc/source/ui/drawfunc/mediash.cxx b/sc/source/ui/drawfunc/mediash.cxx new file mode 100644 index 000000000000..542573e39fa9 --- /dev/null +++ b/sc/source/ui/drawfunc/mediash.cxx @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/request.hxx> +#include <avmedia/mediaitem.hxx> +#include <svl/whiter.hxx> +#include <svx/svdomedia.hxx> +#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx> + +#include "mediash.hxx" +#include "sc.hrc" +#include "viewdata.hxx" +#include "drawview.hxx" +#include "scresid.hxx" + +#define ScMediaShell +#include "scslots.hxx" + +#define ITEMVALUE(ItemSet,Id,Cast) ((const Cast&)(ItemSet).Get(Id)).GetValue() + + +SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell, ScResId(SCSTR_GRAPHICSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, ScResId(RID_MEDIA_OBJECTBAR) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_MEDIA) ); +} + +TYPEINIT1( ScMediaShell, ScDrawShell ); + +ScMediaShell::ScMediaShell(ScViewData* pData) : + ScDrawShell(pData) +{ + SetHelpId(HID_SCSHELL_MEDIA); + SetName( String( ScResId( SCSTR_MEDIASHELL ) ) ); +} + +ScMediaShell::~ScMediaShell() +{ +} + +void ScMediaShell::GetMediaState( SfxItemSet& rSet ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + + if( pView ) + { + SfxWhichIter aIter( rSet ); + USHORT nWhich = aIter.FirstWhich(); + + while( nWhich ) + { + if( SID_AVMEDIA_TOOLBOX == nWhich ) + { + SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() ); + bool bDisable = true; + + if( 1 == pMarkList->GetMarkCount() ) + { + SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrMediaObj ) ) + { + ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX ); + + static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem ); + rSet.Put( aItem ); + bDisable = false; + } + } + + if( bDisable ) + rSet.DisableItem( SID_AVMEDIA_TOOLBOX ); + + delete pMarkList; + } + + nWhich = aIter.NextWhich(); + } + } +} + +void ScMediaShell::ExecuteMedia( SfxRequest& rReq ) +{ + ScDrawView* pView = GetViewData()->GetScDrawView(); + + if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() ) + { + const SfxItemSet* pArgs = rReq.GetArgs(); + const SfxPoolItem* pItem; + + if( !pArgs || ( SFX_ITEM_SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, FALSE, &pItem ) ) ) + pItem = NULL; + + if( pItem ) + { + SdrMarkList* pMarkList = new SdrMarkList( pView->GetMarkedObjectList() ); + + if( 1 == pMarkList->GetMarkCount() ) + { + SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); + + if( pObj && pObj->ISA( SdrMediaObj ) ) + { + static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( + static_cast< const ::avmedia::MediaItem& >( *pItem ) ); + } + + delete pMarkList; + } + } + } + + Invalidate(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/drawfunc/objdraw.src b/sc/source/ui/drawfunc/objdraw.src new file mode 100644 index 000000000000..c221567f3671 --- /dev/null +++ b/sc/source/ui/drawfunc/objdraw.src @@ -0,0 +1,1541 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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. + * + ************************************************************************/ + +#include "sc.hrc" +#include "submenu.hrc" +#include <svx/globlmn.hrc> + // + // Defines ------------------------------------------------------------------------------- + // +#define MN_RESET\ + MenuItem\ + {\ + Identifier = SID_TEXT_STANDARD ; \ + HelpID = SID_TEXT_STANDARD ; \ + Text [ en-US ] = "~Default" ; \ + Text [ x-comment ] = " ";\ + }; + + // Font (SID_ATTR_CHAR_FONT) und Groesse (SID_ATTR_CHAR_FONTHEIGHT) duerfen nicht im + // Formatmenue auftauchen, weil die Controller im ExeEnv sonst im Container angelegt werden +#define MN_TEXT_ATTR\ + MenuItem\ + {\ + Identifier = RID_MN_FORMAT_STYLE ; \ + HelpID = RID_MN_FORMAT_STYLE ; \ + Text [ en-US ] = "~Style" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_WEIGHT\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_POSTURE\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_OVERLINE\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_UNDERLINE\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_STRIKEOUT\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_SHADOWED\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_ATTR_CHAR_CONTOUR\ + };\ + MenuItem\ + {\ + Separator = TRUE ; \ + };\ + MenuItem\ + {\ + Identifier = SID_SET_SUPER_SCRIPT ; \ + HelpID = SID_SET_SUPER_SCRIPT ; \ + Text [ en-US ] = "~Superscript" ; \ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + Identifier = SID_SET_SUB_SCRIPT ; \ + HelpID = SID_SET_SUB_SCRIPT ; \ + Text [ en-US ] = "S~ubscript" ; \ + Text [ x-comment ] = " ";\ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + Identifier = RID_MN_FORMAT_ALGN ; \ + HelpID = RID_MN_FORMAT_ALGN ; \ + Text [ en-US ] = "~Alignment" ; \ + RadioCheck = TRUE ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + Identifier = SID_ALIGNLEFT ; \ + HelpID = SID_ATTR_PARA_ADJUST_LEFT ; \ + RadioCheck = TRUE ; \ + Text [ en-US ] = "~Left" ;\ + Text [ x-comment ] = " "; \ + };\ + MenuItem\ + {\ + Identifier = SID_ALIGNRIGHT ; \ + HelpID = SID_ATTR_PARA_ADJUST_RIGHT ; \ + RadioCheck = TRUE ; \ + Text [ en-US ] = "~Right" ;\ + };\ + MenuItem\ + {\ + Identifier = SID_ALIGNCENTERHOR ; \ + HelpID = SID_ATTR_PARA_ADJUST_CENTER ; \ + RadioCheck = TRUE ; \ + Text [ en-US ] = "~Centered" ;\ + };\ + MenuItem\ + {\ + Identifier = SID_ALIGNBLOCK ; \ + HelpID = SID_ATTR_PARA_ADJUST_BLOCK ; \ + RadioCheck = TRUE ; \ + Text [ en-US ] = "~Justified" ; \ + Text [ x-comment ] = " ";\ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + Identifier = RID_MN_FORMAT_LINESPACE ; \ + HelpID = RID_MN_FORMAT_LINESPACE ; \ + Text [ en-US ] = "~Line Spacing" ; \ + _MenuItemFlags = MIB_RADIOCHECK ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + ITEM_FORMAT_PARA_LINESPACE_10\ + RadioCheck = TRUE ; \ + };\ + MenuItem\ + {\ + ITEM_FORMAT_PARA_LINESPACE_15\ + RadioCheck = TRUE ; \ + };\ + MenuItem\ + {\ + ITEM_FORMAT_PARA_LINESPACE_20\ + RadioCheck = TRUE ; \ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + }; + +#define MN_DRWTXT \ + MenuItem\ + {\ + ITEM_FORMAT_CHAR_DLG\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_PARA_DLG\ + }; + +#define MN_EDITLNK \ + MenuItem\ + {\ + Identifier = SID_DRAW_HLINK_EDIT ; \ + HelpID = SID_DRAW_HLINK_EDIT ; \ + Text [ en-US ] = "~Hyperlink..." ; \ + }; + +#define MN_DELLNK \ + MenuItem\ + {\ + Identifier = SID_DRAW_HLINK_DELETE ; \ + HelpID = SID_DRAW_HLINK_DELETE ; \ + Text [ en-US ] = "~Remove Hyperlink" ; \ + }; + +#define MN_DRWTXTATTR \ + MenuItem\ + {\ + Identifier = SID_DRAWTEXT_ATTR_DLG ; \ + HelpID = SID_DRAWTEXT_ATTR_DLG ; \ + Text [ en-US ] = "Te~xt..." ; \ + /* ### ACHTUNG: Neuer Text in Resource? Textattribute für die selektierten Textobjekte festlegen : Textattribute f³r die selektierten Textobjekte festlegen */\ + Text [ x-comment ] = " ";\ + }; + +#define MN_ASSIGNMACRO \ + MenuItem\ + {\ + Identifier = SID_ASSIGNMACRO ; \ + HelpID = SID_ASSIGNMACRO ; \ + Text [ en-US ] = "Assig~n Macro..." ; \ + Text [ x-comment ] = " ";\ + }; + +#define MN_ORIGINALSIZE \ + MenuItem\ + {\ + Identifier = SID_ORIGINALSIZE ; \ + HelpId = SID_ORIGINALSIZE ; \ + /* ### ACHTUNG: Neuer Text in Resource? Originalgröße : Originalgr÷˜e */\ + Text [ en-US ] = "~Original Size" ; \ + Text [ x-comment ] = " ";\ + }; + +#define MN_RENAME_OBJECT \ + MenuItem\ + {\ + Identifier = SID_RENAME_OBJECT ; \ + HelpId = SID_RENAME_OBJECT ; \ + Text [ en-US ] = "Name...";\ + }; + +// #i68101# +#define MN_TITLE_DESCRIPTION_OBJECT \ + MenuItem\ + {\ + Identifier = SID_TITLE_DESCRIPTION_OBJECT; \ + HelpId = SID_TITLE_DESCRIPTION_OBJECT; \ + Text [ en-US ] = "Description...";\ + }; + +#define MN_MIRRORSUB \ + MenuItem\ + {\ + Identifier = SUBMENU_OBJMIRROR ; \ + HelpID = HID_SCMENU_OBJMIRROR ; \ + Text [ en-US ] = "~Flip" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + Identifier = SID_MIRROR_VERTICAL ; \ + HelpId = SID_MIRROR_VERTICAL ; \ + Text [ en-US ] = "~Vertically" ; \ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + Identifier = SID_MIRROR_HORIZONTAL ; \ + HelpId = SID_MIRROR_HORIZONTAL ; \ + Text [ en-US ] = "~Horizontal" ; \ + Text [ x-comment ] = " ";\ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + }; + +#define MN_ARRANGESUB \ + MenuItem\ + {\ + Identifier = SUBMENU_OBJARRANGE ; \ + HelpID = HID_SCMENU_OBJARRANGE ; \ + Text [ en-US ] = "~Arrange" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + ITEM_FORMAT_FRAME_TO_TOP\ + };\ + MenuItem\ + {\ + Identifier = SID_FRAME_UP ; \ + HelpId = SID_FRAME_UP ; \ + /* ### ACHTUNG: Neuer Text in Resource? W~eiter nach vorn : Weiter nach vorn */\ + Text [ en-US ] = "Bring ~Forward" ; \ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + Identifier = SID_FRAME_DOWN ; \ + HelpId = SID_FRAME_DOWN ; \ + /* ### ACHTUNG: Neuer Text in Resource? Weiter ~nach hinten : Weiter nach hinten */\ + Text [ en-US ] = "Send Back~ward" ; \ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_FRAME_TO_BOTTOM\ + };\ + MenuItem { Separator = TRUE ; }; \ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_HEAVEN\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_HELL\ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + }; + +#define MN_ANCHORSUB \ + MenuItem\ + {\ + Identifier = SUBMENU_ANCHOR ; \ + HelpID = HID_SCMENU_ANCHOR ; \ + Text [ en-US ] = "An~chor" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + RadioCheck = TRUE ; \ + Identifier = SID_ANCHOR_PAGE ; \ + HelpId = SID_ANCHOR_PAGE ; \ + Text [ en-US ] = "To P~age" ; \ + Text [ x-comment ] = " ";\ + };\ + MenuItem\ + {\ + RadioCheck = TRUE ; \ + Identifier = SID_ANCHOR_CELL ; \ + HelpId = SID_ANCHOR_CELL ; \ + Text [ en-US ] = "To ~Cell" ; \ + Text [ x-comment ] = " ";\ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + }; + +#define MN_ALIGNSUB \ + MenuItem\ + {\ + Identifier = SID_OBJECT_ALIGN ; \ + HelpId = SID_OBJECT_ALIGN ; \ + Text [ en-US ] = "A~lignment" ; \ + SubMenu = Menu\ + {\ + ItemList = \ + {\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_LEFT\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_CENTER\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_RIGHT\ + };\ + MenuItem\ + {\ + Separator = TRUE ; \ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_UP\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_MIDDLE\ + };\ + MenuItem\ + {\ + ITEM_FORMAT_OBJECT_ALIGN_DOWN\ + };\ + };\ + };\ + Text [ x-comment ] = " ";\ + }; + + // + // ------------------------------------------------------------------------------ + // + // + // Objekt-Leisten + // +String RID_DRAW_OBJECTBAR +{ + Text [ en-US ] = "Drawing Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_DRAW_OBJECTBAR +{ + HelpId = HID_SC_TOOLBOX_DRAW ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + Customize = TRUE ; + HideWhenDeactivate = TRUE ; + LineSpacing = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + MenuStrings = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_BEZIER_EDIT ; + HelpID = SID_BEZIER_EDIT ; + + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + // Linien + ToolBoxItem + { + Identifier = SID_ATTRIBUTES_LINE ; + HelpId = SID_ATTRIBUTES_LINE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_LINEEND_STYLE ; + HelpID = SID_ATTR_LINEEND_STYLE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_LINE_STYLE ; + HelpId = SID_ATTR_LINE_STYLE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_LINE_WIDTH ; + HelpId = SID_ATTR_LINE_WIDTH ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_LINE_COLOR ; + HelpId = SID_ATTR_LINE_COLOR ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTRIBUTES_AREA ; + HelpId = SID_ATTRIBUTES_AREA ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_FILL_STYLE ; + HelpId = SID_ATTR_FILL_STYLE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + // Rest + ToolBoxItem + { + Identifier = SID_OBJECT_ROTATE ; + HelpId = SID_OBJECT_ROTATE ; + }; + ToolBoxItem + { + Identifier = SID_ANCHOR_TOGGLE ; + HelpId = SID_ANCHOR_TOGGLE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_FRAME_TO_TOP ; + HelpId = SID_FRAME_TO_TOP ; + }; + ToolBoxItem + { + Identifier = SID_FRAME_TO_BOTTOM ; + HelpId = SID_FRAME_TO_BOTTOM ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_HEAVEN ; + HelpID = SID_OBJECT_HEAVEN ; + + }; + ToolBoxItem + { + Identifier = SID_OBJECT_HELL ; + HelpID = SID_OBJECT_HELL ; + + }; + + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + + ToolBoxItem + { + Identifier = SID_GRID_VISIBLE; + HelpID = SID_GRID_VISIBLE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_GRID_USE; + HelpID = SID_GRID_USE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_HELPLINES_MOVE; + HelpID = SID_HELPLINES_MOVE; + Hide = TRUE; + }; + + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN ; + HelpId = SID_OBJECT_ALIGN ; + }; + }; + Scroll = TRUE ; +}; + // + // Text-Toolbox + // +String RID_TEXT_TOOLBOX +{ + Text [ en-US ] = "Text Object Bar" ; + Text [ x-comment ] = " "; +}; +ToolBox RID_TEXT_TOOLBOX +{ + HelpId = HID_SC_TOOLBOX_DRTEXT ; + LineSpacing = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + Scroll = TRUE ; + Customize = TRUE ; + HideWhenDeactivate = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 0 , 0 ) ; + Align = BOXALIGN_TOP ; + MenuStrings = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_FONT ; + HelpId = SID_ATTR_CHAR_FONT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_FONTHEIGHT ; + HelpId = SID_ATTR_CHAR_FONTHEIGHT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_WEIGHT ; + HelpId = SID_ATTR_CHAR_WEIGHT ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_POSTURE ; + HelpId = SID_ATTR_CHAR_POSTURE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_UNDERLINE ; + HelpId = SID_ATTR_CHAR_UNDERLINE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ULINE_VAL_DOUBLE; + HelpId = SID_ULINE_VAL_DOUBLE; + AutoCheck = TRUE ; + Hide=TRUE; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_COLOR ; + HelpId = SID_ATTR_CHAR_COLOR ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_10 ; + HelpId = SID_ATTR_PARA_LINESPACE_10 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_15 ; + HelpId = SID_ATTR_PARA_LINESPACE_15 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_20 ; + HelpId = SID_ATTR_PARA_LINESPACE_20 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ALIGNLEFT ; + HelpId = SID_ATTR_PARA_ADJUST_LEFT ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNCENTERHOR ; + HelpId = SID_ATTR_PARA_ADJUST_CENTER ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNRIGHT ; + HelpId = SID_ATTR_PARA_ADJUST_RIGHT ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNBLOCK ; + HelpId = SID_ATTR_PARA_ADJUST_BLOCK ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LEFT_TO_RIGHT; + HelpID = SID_ATTR_PARA_LEFT_TO_RIGHT; + RadioCheck = TRUE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_RIGHT_TO_LEFT; + HelpID = SID_ATTR_PARA_RIGHT_TO_LEFT; + RadioCheck = TRUE; + Hide = TRUE; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_SET_SUPER_SCRIPT ; + HelpID = SID_SET_SUPER_SCRIPT ; + }; + ToolBoxItem + { + Identifier = SID_SET_SUB_SCRIPT ; + HelpID = SID_SET_SUB_SCRIPT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_CHAR_DLG ; + HelpID = SID_CHAR_DLG ; + }; + ToolBoxItem + { + Identifier = SID_PARA_DLG ; + HelpID = SID_PARA_DLG ; + }; + }; + ItemList[ ar ] = + { + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_FONT ; + HelpId = SID_ATTR_CHAR_FONT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_FONTHEIGHT ; + HelpId = SID_ATTR_CHAR_FONTHEIGHT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_WEIGHT ; + HelpId = SID_ATTR_CHAR_WEIGHT ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_POSTURE ; + HelpId = SID_ATTR_CHAR_POSTURE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_UNDERLINE ; + HelpId = SID_ATTR_CHAR_UNDERLINE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ULINE_VAL_DOUBLE; + HelpId = SID_ULINE_VAL_DOUBLE; + AutoCheck = TRUE ; + Hide=TRUE; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_COLOR ; + HelpId = SID_ATTR_CHAR_COLOR ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_10 ; + HelpId = SID_ATTR_PARA_LINESPACE_10 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_15 ; + HelpId = SID_ATTR_PARA_LINESPACE_15 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_20 ; + HelpId = SID_ATTR_PARA_LINESPACE_20 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ALIGNRIGHT ; + HelpId = SID_ATTR_PARA_ADJUST_RIGHT ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNCENTERHOR ; + HelpId = SID_ATTR_PARA_ADJUST_CENTER ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNLEFT ; + HelpId = SID_ATTR_PARA_ADJUST_LEFT ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNBLOCK ; + HelpId = SID_ATTR_PARA_ADJUST_BLOCK ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_PARA_RIGHT_TO_LEFT; + HelpID = SID_ATTR_PARA_RIGHT_TO_LEFT; + RadioCheck = TRUE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LEFT_TO_RIGHT; + HelpID = SID_ATTR_PARA_LEFT_TO_RIGHT; + RadioCheck = TRUE; + Hide = TRUE; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_SET_SUPER_SCRIPT ; + HelpID = SID_SET_SUPER_SCRIPT ; + }; + ToolBoxItem + { + Identifier = SID_SET_SUB_SCRIPT ; + HelpID = SID_SET_SUB_SCRIPT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_CHAR_DLG ; + HelpID = SID_CHAR_DLG ; + }; + ToolBoxItem + { + Identifier = SID_PARA_DLG ; + HelpID = SID_PARA_DLG ; + }; + }; + ItemList[ he ] = + { + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_FONT ; + HelpId = SID_ATTR_CHAR_FONT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_FONTHEIGHT ; + HelpId = SID_ATTR_CHAR_FONTHEIGHT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_WEIGHT ; + HelpId = SID_ATTR_CHAR_WEIGHT ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_POSTURE ; + HelpId = SID_ATTR_CHAR_POSTURE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_UNDERLINE ; + HelpId = SID_ATTR_CHAR_UNDERLINE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ULINE_VAL_DOUBLE; + HelpId = SID_ULINE_VAL_DOUBLE; + AutoCheck = TRUE ; + Hide=TRUE; + }; + ToolBoxItem + { + Identifier = SID_ATTR_CHAR_COLOR ; + HelpId = SID_ATTR_CHAR_COLOR ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_10 ; + HelpId = SID_ATTR_PARA_LINESPACE_10 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_15 ; + HelpId = SID_ATTR_PARA_LINESPACE_15 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LINESPACE_20 ; + HelpId = SID_ATTR_PARA_LINESPACE_20 ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ALIGNRIGHT ; + HelpId = SID_ATTR_PARA_ADJUST_RIGHT ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNCENTERHOR ; + HelpId = SID_ATTR_PARA_ADJUST_CENTER ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNLEFT ; + HelpId = SID_ATTR_PARA_ADJUST_LEFT ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + ToolBoxItem + { + Identifier = SID_ALIGNBLOCK ; + HelpId = SID_ATTR_PARA_ADJUST_BLOCK ; + RadioCheck = TRUE ; + AutoCheck = TRUE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ATTR_PARA_RIGHT_TO_LEFT; + HelpID = SID_ATTR_PARA_RIGHT_TO_LEFT; + RadioCheck = TRUE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_ATTR_PARA_LEFT_TO_RIGHT; + HelpID = SID_ATTR_PARA_LEFT_TO_RIGHT; + RadioCheck = TRUE; + Hide = TRUE; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_SET_SUPER_SCRIPT ; + HelpID = SID_SET_SUPER_SCRIPT ; + }; + ToolBoxItem + { + Identifier = SID_SET_SUB_SCRIPT ; + HelpID = SID_SET_SUB_SCRIPT ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + HelpID = SID_TEXTDIRECTION_LEFT_TO_RIGHT ; + }; + ToolBoxItem + { + Identifier = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + HelpID = SID_TEXTDIRECTION_TOP_TO_BOTTOM ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_CHAR_DLG ; + HelpID = SID_CHAR_DLG ; + }; + ToolBoxItem + { + Identifier = SID_PARA_DLG ; + HelpID = SID_PARA_DLG ; + }; + }; +}; + // + // Graphics toolbox + // +String RID_GRAPHIC_OBJECTBAR +{ + Text [ en-US ] = "Graphics Object Bar"; +}; +ToolBox RID_GRAPHIC_OBJECTBAR +{ + HelpId = HID_SC_TOOLBOX_GRAPHIC ; + LineSpacing = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + Scroll = TRUE ; + Customize = TRUE ; + HideWhenDeactivate = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 0 , 0 ) ; + Align = BOXALIGN_TOP ; + MenuStrings = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_GRFFILTER; + HelpID = SID_GRFFILTER; + DropDown = TRUE ; + Checkable = FALSE ; + RadioCheck = FALSE ; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_MODE; + HelpID = SID_ATTR_GRAF_MODE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_RED; + HelpID = SID_ATTR_GRAF_RED; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_GREEN; + HelpID = SID_ATTR_GRAF_GREEN; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_BLUE; + HelpID = SID_ATTR_GRAF_BLUE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_LUMINANCE; + HelpID = SID_ATTR_GRAF_LUMINANCE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_CONTRAST; + HelpID = SID_ATTR_GRAF_CONTRAST; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_GAMMA; + HelpID = SID_ATTR_GRAF_GAMMA; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_TRANSPARENCE; + HelpID = SID_ATTR_GRAF_TRANSPARENCE; + }; + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + + // #i25616# + ToolBoxItem + { + Identifier = SID_ATTRIBUTES_LINE; + HelpID = SID_ATTRIBUTES_LINE; + }; + ToolBoxItem + { + Identifier = SID_ATTRIBUTES_AREA; + HelpID = SID_ATTRIBUTES_AREA; + }; + ToolBoxItem + { + Identifier = SID_ATTR_FILL_SHADOW; + HelpID = SID_ATTR_FILL_SHADOW; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + + ToolBoxItem + { + Identifier = SID_ATTR_GRAF_CROP; + HelpID = SID_ATTR_GRAF_CROP; + }; + + // copied from the "normal" drawing toolbar: + + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_ANCHOR_TOGGLE ; + HelpId = SID_ANCHOR_TOGGLE ; + }; + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_FRAME_TO_TOP ; + HelpId = SID_FRAME_TO_TOP ; + }; + ToolBoxItem + { + Identifier = SID_FRAME_TO_BOTTOM ; + HelpId = SID_FRAME_TO_BOTTOM ; + }; + ToolBoxItem + { + Identifier = SID_OBJECT_HEAVEN ; + HelpID = SID_OBJECT_HEAVEN ; + + }; + ToolBoxItem + { + Identifier = SID_OBJECT_HELL ; + HelpID = SID_OBJECT_HELL ; + + }; + + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + + ToolBoxItem + { + Identifier = SID_GRID_VISIBLE; + HelpID = SID_GRID_VISIBLE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_GRID_USE; + HelpID = SID_GRID_USE; + Hide = TRUE; + }; + ToolBoxItem + { + Identifier = SID_HELPLINES_MOVE; + HelpID = SID_HELPLINES_MOVE; + Hide = TRUE; + }; + + //--------------------------------------------- + ToolBoxItem { Type = TOOLBOXITEM_SEPARATOR ; }; + //--------------------------------------------- + ToolBoxItem + { + Identifier = SID_OBJECT_ALIGN ; + HelpId = SID_OBJECT_ALIGN ; + }; + }; +}; + // + // Popup-Menues --------------------------------------------------------------------- + // +String RID_POPUP_DRAW +{ + /* ### ACHTUNG: Neuer Text in Resource? Popup-Menü für Zeichenobjekte : Popup-Men³ f³r Zeichenobjekte */ + Text [ en-US ] = "Pop-up menu for drawing objects" ; + Text [ x-comment ] = " "; +}; + // + // Popup-Menue fuer (allgemeine) Zeichenobjekte + // +Menu RID_POPUP_DRAW +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTRIBUTES_LINE }; + MenuItem { ITEM_FORMAT_ATTRIBUTES_AREA }; + MN_DRWTXTATTR // Text... + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_MIRRORSUB + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + MN_ASSIGNMACRO + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MenuItem + { + ITEM_FORMAT_BEZIER_EDIT + RadioCheck = FALSE ; + AutoCheck = TRUE ; + }; + MenuItem + { + ITEM_FORMAT_FONTWORK + }; + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_EDITLNK + MN_DELLNK + MenuItem { ITEM_OPEN_HYPERLINK }; + }; +}; + + // + // Popup-Menue fuer (Uno-) Controls + // + +Menu RID_POPUP_CONTROL +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MenuItem { ITEM_FORM_CONTROL_PROPERTIES }; + MenuItem { ITEM_FORM_PROPERTIES }; + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + }; +}; + + // + // Grafik + // + +Menu RID_POPUP_GRAPHIC +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTRIBUTES_LINE }; // #i25616# + MenuItem { ITEM_FORMAT_ATTRIBUTES_AREA }; // #i25616# + MN_DRWTXTATTR + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + MN_ORIGINALSIZE + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_MIRRORSUB + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + MN_ASSIGNMACRO + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_EDITLNK + MN_DELLNK + MenuItem { ITEM_OPEN_HYPERLINK }; + }; +}; + + // + // Media + // + +Menu RID_POPUP_MEDIA +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_MIRRORSUB + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + }; +}; + +ToolBox RID_MEDIA_OBJECTBAR +{ + //HelpId = HID_SC_TOOLBOX_MEDIA ; + LineSpacing = TRUE ; + Dockable = TRUE ; + Moveable = TRUE ; + Sizeable = TRUE ; + Closeable = TRUE ; + Zoomable = TRUE ; + Scroll = TRUE ; + Customize = TRUE ; + HideWhenDeactivate = TRUE ; + Border = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 0 , 0 ) ; + Align = BOXALIGN_TOP ; + MenuStrings = TRUE ; + ItemList = + { + ToolBoxItem + { + Identifier = SID_AVMEDIA_TOOLBOX; + HelpID = SID_AVMEDIA_TOOLBOX; + DropDown = FALSE ; + Checkable = FALSE ; + RadioCheck = FALSE ; + }; + }; +}; + + // + // Ole-Objekt + // + +Menu RID_POPUP_OLE +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + MN_ORIGINALSIZE + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + }; +}; + + // + // Charts + // + +Menu RID_POPUP_CHART +{ + ItemList = + { + MenuItem { ITEM_FORMAT_ATTR_TRANSFORM }; + MN_ORIGINALSIZE + + //-#i68101#---------------------- + MenuItem { Separator = TRUE ; }; + MN_TITLE_DESCRIPTION_OBJECT + MN_RENAME_OBJECT + //-#i68101#---------------------- + + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + MN_ARRANGESUB + MN_ALIGNSUB + MN_ANCHORSUB + //------------------------------ + MenuItem { Separator = TRUE ; }; + //------------------------------ + ITEM_GROUP_MENU + }; +}; + + // + // PopUpDraw Text + // + +String RID_POPUP_DRAWTEXT +{ + /* ### ACHTUNG: Neuer Text in Resource? Popup-Menü für Text-Objekte : Popup-Men³ f³r Text-Objekte */ + Text [ en-US ] = "Pop-up menu for text objects" ; + Text [ x-comment ] = " "; +}; + +Menu RID_POPUP_DRAWTEXT +{ + ItemList = + { + MN_RESET + MenuItem { Separator = TRUE ; }; + MN_DRWTXTATTR + MenuItem { Separator = TRUE ; }; + MenuItem + { + ITEM_FORMAT_ATTR_CHAR_FONT + }; + MenuItem + { + ITEM_FORMAT_ATTR_CHAR_FONTHEIGHT + }; + // Stil, Ausrichtung, Zeilenabstand + MN_TEXT_ATTR + MenuItem { Separator = TRUE ; }; + // Zeichen, Absatz + MN_DRWTXT + MenuItem { Separator = TRUE ; }; + MenuItem + { + ITEM_OPEN_HYPERLINK + }; + }; +}; + diff --git a/sc/source/ui/drawfunc/oleobjsh.cxx b/sc/source/ui/drawfunc/oleobjsh.cxx new file mode 100644 index 000000000000..d8a0b8c052ac --- /dev/null +++ b/sc/source/ui/drawfunc/oleobjsh.cxx @@ -0,0 +1,83 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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_sc.hxx" + + + +//------------------------------------------------------------------ + +#include <editeng/eeitem.hxx> +#include <svx/fontwork.hxx> +#include <svl/srchitem.hxx> +#include <svx/tabarea.hxx> +#include <svx/tabline.hxx> +#include <sfx2/app.hxx> +#include <sfx2/objface.hxx> +#include <sfx2/request.hxx> +#include <svl/whiter.hxx> +#include <vcl/msgbox.hxx> + +#include "oleobjsh.hxx" +#include "drwlayer.hxx" +#include "sc.hrc" +#include "viewdata.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "drawview.hxx" +#include "scresid.hxx" +#include <svx/svdobj.hxx> + +#define ScOleObjectShell +#include "scslots.hxx" + + +SFX_IMPL_INTERFACE(ScOleObjectShell, ScDrawShell, ScResId(SCSTR_OLEOBJECTSHELL) ) +{ + SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT|SFX_VISIBILITY_STANDARD|SFX_VISIBILITY_SERVER, + ScResId(RID_DRAW_OBJECTBAR) ); + SFX_POPUPMENU_REGISTRATION( ScResId(RID_POPUP_OLE) ); +} + +TYPEINIT1( ScOleObjectShell, ScDrawShell ); + +ScOleObjectShell::ScOleObjectShell(ScViewData* pData) : + ScDrawShell(pData) +{ + SetHelpId(HID_SCSHELL_OLEOBEJCTSH); + SetName(String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("OleObject"))); +} + +ScOleObjectShell::~ScOleObjectShell() +{ +} + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |