Files
libreoffice/sw/source/ui/uiview/viewdraw.cxx

772 lines
26 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 16:15:01 +00:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 16:15:01 +00:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 16:15:01 +00:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 16:15:01 +00:00
*
* This file is part of OpenOffice.org.
2000-09-18 16:15:01 +00:00
*
* 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.
2000-09-18 16:15:01 +00:00
*
* 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).
2000-09-18 16:15:01 +00:00
*
* 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.
2000-09-18 16:15:01 +00:00
*
************************************************************************/
2000-09-18 16:15:01 +00:00
#include "hintids.hxx"
#include <svl/aeitem.hxx>
#include <svl/itempool.hxx>
2000-09-18 16:15:01 +00:00
#include <svx/svdobj.hxx>
#include <svx/svdview.hxx>
#include <svx/svdpage.hxx>
#include <editeng/editview.hxx>
#include <editeng/editeng.hxx>
#include <editeng/outliner.hxx>
#include <svx/fmview.hxx>
#include <svx/dataaccessdescriptor.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/viewfrm.hxx>
#include <doc.hxx>
#include <editeng/langitem.hxx>
2000-11-19 10:41:10 +00:00
#include <linguistic/lngprops.hxx>
#include <editeng/unolingu.hxx>
#include <svx/fontworkbar.hxx>
#include <svx/fontworkgallery.hxx>
#include <editeng/eeitem.hxx>
#include <svx/svdogrp.hxx>
2000-09-18 16:15:01 +00:00
#include <svx/svdetc.hxx>
#include <editeng/editstat.hxx>
2000-09-18 16:15:01 +00:00
#include <sfx2/request.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/printer.hxx>
#include <svx/fmglob.hxx>
#include <sfx2/dispatch.hxx>
#include <svx/svdoutl.hxx>
#include "view.hxx"
#include "wrtsh.hxx"
#include "viewopt.hxx"
#include "cmdid.h"
#include "drawsh.hxx"
#include "drwbassh.hxx"
#include "beziersh.hxx"
#include "conrect.hxx"
#include "conpoly.hxx"
#include "conarc.hxx"
#include "conform.hxx"
#include "concustomshape.hxx"
2000-09-18 16:15:01 +00:00
#include "dselect.hxx"
#include "edtwin.hxx"
#include <dcontact.hxx>
#include <svx/svdpagv.hxx>
#include <svx/extrusionbar.hxx>
#include <vcl/svapp.hxx>
2000-09-18 16:15:01 +00:00
using namespace ::com::sun::star;
2010-10-11 17:38:56 -05:00
2000-09-18 16:15:01 +00:00
/*--------------------------------------------------------------------
Beschreibung: Drawing-Ids ausfuehren
--------------------------------------------------------------------*/
void SwView::ExecDraw(SfxRequest& rReq)
{
const SfxItemSet *pArgs = rReq.GetArgs();
const SfxPoolItem* pItem;
const SfxAllEnumItem* pEItem = 0;
const SfxStringItem* pStringItem = 0;
2000-09-18 16:15:01 +00:00
SdrView *pSdrView = pWrtShell->GetDrawView();
sal_Bool bDeselect = sal_False;
sal_uInt16 nSlotId = rReq.GetSlot();
if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlotId), sal_False, &pItem))
{
pEItem = dynamic_cast< const SfxAllEnumItem*>(pItem);
pStringItem = dynamic_cast< const SfxStringItem*>(pItem);
2000-09-18 16:15:01 +00:00
}
if (SID_INSERT_DRAW == nSlotId && pEItem)
switch ( pEItem->GetValue() )
2000-09-18 16:15:01 +00:00
{
case SVX_SNAP_DRAW_SELECT: nSlotId = SID_OBJECT_SELECT; break;
case SVX_SNAP_DRAW_LINE: nSlotId = SID_DRAW_LINE; break;
case SVX_SNAP_DRAW_RECT: nSlotId = SID_DRAW_RECT; break;
case SVX_SNAP_DRAW_ELLIPSE: nSlotId = SID_DRAW_ELLIPSE; break;
case SVX_SNAP_DRAW_POLYGON_NOFILL: nSlotId = SID_DRAW_POLYGON_NOFILL; break;
case SVX_SNAP_DRAW_BEZIER_NOFILL: nSlotId = SID_DRAW_BEZIER_NOFILL; break;
case SVX_SNAP_DRAW_FREELINE_NOFILL: nSlotId = SID_DRAW_FREELINE_NOFILL; break;
case SVX_SNAP_DRAW_ARC: nSlotId = SID_DRAW_ARC; break;
case SVX_SNAP_DRAW_PIE: nSlotId = SID_DRAW_PIE; break;
case SVX_SNAP_DRAW_CIRCLECUT: nSlotId = SID_DRAW_CIRCLECUT; break;
case SVX_SNAP_DRAW_TEXT: nSlotId = SID_DRAW_TEXT; break;
case SVX_SNAP_DRAW_TEXT_VERTICAL: nSlotId = SID_DRAW_TEXT_VERTICAL; break;
case SVX_SNAP_DRAW_TEXT_MARQUEE: nSlotId = SID_DRAW_TEXT_MARQUEE; break;
case SVX_SNAP_DRAW_CAPTION: nSlotId = SID_DRAW_CAPTION; break;
case SVX_SNAP_DRAW_CAPTION_VERTICAL: nSlotId = SID_DRAW_CAPTION_VERTICAL; break;
2001-03-16 13:42:55 +00:00
}
2000-09-18 16:15:01 +00:00
if (nSlotId == SID_OBJECT_SELECT && nFormSfxId == nSlotId)
{
bDeselect = sal_True;
}
else if (nSlotId == SID_FM_CREATE_CONTROL)
{
SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
if( pIdentifierItem )
{
sal_uInt16 nNewId = pIdentifierItem->GetValue();
if (nNewId == nFormSfxId)
{
bDeselect = sal_True;
GetViewFrame()->GetDispatcher()->Execute(SID_FM_LEAVE_CREATE); // Button soll rauspoppen
}
}
}
else if( nSlotId == SID_FM_CREATE_FIELDCONTROL)
{
FmFormView* pFormView = PTR_CAST( FmFormView, pSdrView );
if ( pFormView )
{
SFX_REQUEST_ARG( rReq, pDescriptorItem, SfxUnoAnyItem, SID_FM_DATACCESS_DESCRIPTOR, sal_False );
OSL_ENSURE( pDescriptorItem, "SwView::ExecDraw(SID_FM_CREATE_FIELDCONTROL): invalid request args!" );
if( pDescriptorItem )
{
::svx::ODataAccessDescriptor aDescriptor( pDescriptorItem->GetValue() );
SdrObject* pObj = pFormView->CreateFieldControl( aDescriptor );
if ( pObj )
{
Size aDocSize(pWrtShell->GetDocSize());
const SwRect& rVisArea = pWrtShell->VisArea();
Point aStartPos = rVisArea.Center();
if(rVisArea.Width() > aDocSize.Width())
aStartPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
if(rVisArea.Height() > aDocSize.Height())
aStartPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
//determine the size of the object
if(pObj->IsGroupObject())
{
const Rectangle& rBoundRect = ((SdrObjGroup*)pObj)->GetCurrentBoundRect();
aStartPos.X() -= rBoundRect.GetWidth()/2;
aStartPos.Y() -= rBoundRect.GetHeight()/2;
}
// TODO: unmark all other
pWrtShell->EnterStdMode();
pWrtShell->SwFEShell::InsertDrawObj( *pObj, aStartPos );
}
}
}
}
else if ( nSlotId == SID_FONTWORK_GALLERY_FLOATER )
{
Window* pWin = &( pWrtShell->GetView().GetViewFrame()->GetWindow() );
if ( pWin )
pWin->EnterWait();
if( !pWrtShell->HasDrawView() )
pWrtShell->MakeDrawView();
pSdrView = pWrtShell->GetDrawView();
if ( pSdrView )
{
SdrObject* pObj = NULL;
svx::FontWorkGalleryDialog aDlg( pSdrView, pWin, nSlotId );
aDlg.SetSdrObjectRef( &pObj, pSdrView->GetModel() );
aDlg.Execute();
if ( pObj )
{
Size aDocSize( pWrtShell->GetDocSize() );
const SwRect& rVisArea = pWrtShell->VisArea();
Point aPos( rVisArea.Center() );
Size aSize;
Size aPrefSize( pObj->GetSnapRect().GetSize() );
if( rVisArea.Width() > aDocSize.Width())
aPos.X() = aDocSize.Width() / 2 + rVisArea.Left();
if(rVisArea.Height() > aDocSize.Height())
aPos.Y() = aDocSize.Height() / 2 + rVisArea.Top();
if( aPrefSize.Width() && aPrefSize.Height() )
{
if( pWin )
aSize = pWin->PixelToLogic( aPrefSize, MAP_TWIP );
else
aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
}
else
aSize = Size( 2835, 2835 );
pWrtShell->EnterStdMode();
pWrtShell->SwFEShell::InsertDrawObj( *pObj, aPos );
rReq.Ignore ();
}
}
if( pWin )
pWin->LeaveWait();
}
2000-09-18 16:15:01 +00:00
if( nSlotId == SID_DRAW_CS_ID )
{
//deselect if same custom shape is selected again
SwDrawBase* pFuncPtr = GetDrawFuncPtr();
if( pFuncPtr && pFuncPtr->GetSlotId() == SID_DRAW_CS_ID )
{
ConstCustomShape* pConstCustomShape = (ConstCustomShape*)(pFuncPtr);
rtl::OUString aNew = ConstCustomShape::GetShapeTypeFromRequest( rReq );
rtl::OUString aOld = pConstCustomShape->GetShapeType();
if( aNew == aOld )
{
bDeselect = true;
}
}
}
//deselect if same shape is selected again (but different custom shapes do have same slot id)
if ( bDeselect || (nSlotId == nDrawSfxId &&
(!pStringItem || (pStringItem->GetValue() == sDrawCustom))
&& (nSlotId != SID_DRAW_CS_ID) ) )
2000-09-18 16:15:01 +00:00
{
if (GetDrawFuncPtr())
{
GetDrawFuncPtr()->Deactivate();
SetDrawFuncPtr(NULL);
}
if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
pWrtShell->EnterSelFrmMode(NULL);
LeaveDrawCreate();
GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
AttrChangedNotify(pWrtShell);
return;
}
LeaveDrawCreate();
if (pWrtShell->IsFrmSelected())
pWrtShell->EnterStdMode(); // wegen Bug #45639
SwDrawBase* pFuncPtr = NULL;
switch (nSlotId)
{
case SID_OBJECT_SELECT:
case SID_DRAW_SELECT:
pFuncPtr = new DrawSelection(pWrtShell, pEditWin, this);
nDrawSfxId = nFormSfxId = SID_OBJECT_SELECT;
sDrawCustom.Erase();
2000-09-18 16:15:01 +00:00
break;
case SID_DRAW_LINE:
case SID_DRAW_RECT:
case SID_DRAW_ELLIPSE:
case SID_DRAW_TEXT:
2001-03-16 13:42:55 +00:00
case SID_DRAW_TEXT_VERTICAL:
2000-09-18 16:15:01 +00:00
case SID_DRAW_TEXT_MARQUEE:
case SID_DRAW_CAPTION:
2001-03-16 13:42:55 +00:00
case SID_DRAW_CAPTION_VERTICAL:
2000-09-18 16:15:01 +00:00
pFuncPtr = new ConstRectangle(pWrtShell, pEditWin, this);
nDrawSfxId = nSlotId;
sDrawCustom.Erase();
2000-09-18 16:15:01 +00:00
break;
case SID_DRAW_POLYGON_NOFILL:
case SID_DRAW_BEZIER_NOFILL:
case SID_DRAW_FREELINE_NOFILL:
pFuncPtr = new ConstPolygon(pWrtShell, pEditWin, this);
nDrawSfxId = nSlotId;
sDrawCustom.Erase();
2000-09-18 16:15:01 +00:00
break;
case SID_DRAW_ARC:
case SID_DRAW_PIE:
case SID_DRAW_CIRCLECUT:
pFuncPtr = new ConstArc(pWrtShell, pEditWin, this);
nDrawSfxId = nSlotId;
sDrawCustom.Erase();
2000-09-18 16:15:01 +00:00
break;
case SID_FM_CREATE_CONTROL:
{
SFX_REQUEST_ARG( rReq, pIdentifierItem, SfxUInt16Item, SID_FM_CONTROL_IDENTIFIER, sal_False );
if( pIdentifierItem )
nSlotId = pIdentifierItem->GetValue();
pFuncPtr = new ConstFormControl(pWrtShell, pEditWin, this);
nFormSfxId = nSlotId;
}
break;
case SID_DRAWTBX_CS_BASIC :
case SID_DRAWTBX_CS_SYMBOL :
case SID_DRAWTBX_CS_ARROW :
case SID_DRAWTBX_CS_FLOWCHART :
case SID_DRAWTBX_CS_CALLOUT :
case SID_DRAWTBX_CS_STAR :
case SID_DRAW_CS_ID :
{
pFuncPtr = new ConstCustomShape(pWrtShell, pEditWin, this, rReq );
nDrawSfxId = nSlotId;
if ( nSlotId != SID_DRAW_CS_ID )
{
if ( pStringItem )
{
sDrawCustom = pStringItem->GetValue();
aCurrShapeEnumCommand[ nSlotId - SID_DRAWTBX_CS_BASIC ] = sDrawCustom;
SfxBindings& rBind = GetViewFrame()->GetBindings();
rBind.Invalidate( nSlotId );
rBind.Update( nSlotId );
}
}
}
break;
2000-09-18 16:15:01 +00:00
default:
break;
}
static sal_uInt16 const aInval[] =
2000-09-18 16:15:01 +00:00
{
// Slot-Ids muessen beim Aufruf von Invalidate sortiert sein!
SID_ATTRIBUTES_AREA,
SID_INSERT_DRAW,
0
};
GetViewFrame()->GetBindings().Invalidate(aInval);
sal_Bool bEndTextEdit = sal_True;
2000-09-18 16:15:01 +00:00
if (pFuncPtr)
{
if (GetDrawFuncPtr())
{
GetDrawFuncPtr()->Deactivate();
SetDrawFuncPtr(NULL);
}
SetDrawFuncPtr(pFuncPtr);
AttrChangedNotify(pWrtShell);
pFuncPtr->Activate(nSlotId);
NoRotate();
if(rReq.GetModifier() == KEY_MOD1)
{
if(SID_OBJECT_SELECT == nDrawSfxId )
{
pWrtShell->GotoObj(sal_True);
}
else
{
pFuncPtr->CreateDefaultObject();
pFuncPtr->Deactivate();
SetDrawFuncPtr(NULL);
LeaveDrawCreate();
pWrtShell->EnterStdMode();
SdrView *pTmpSdrView = pWrtShell->GetDrawView();
const SdrMarkList& rMarkList = pTmpSdrView->GetMarkedObjectList();
if(rMarkList.GetMarkCount() == 1 &&
(SID_DRAW_TEXT == nSlotId || SID_DRAW_TEXT_VERTICAL == nSlotId ||
SID_DRAW_TEXT_MARQUEE == nSlotId ))
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
BeginTextEdit(pObj);
bEndTextEdit = sal_False;
}
}
}
2000-09-18 16:15:01 +00:00
}
else
{
if (pWrtShell->IsObjSelected() && !pWrtShell->IsSelFrmMode())
pWrtShell->EnterSelFrmMode(NULL);
}
if(bEndTextEdit && pSdrView && pSdrView->IsTextEdit())
pSdrView->SdrEndTextEdit( sal_True );
2000-09-18 16:15:01 +00:00
AttrChangedNotify(pWrtShell);
}
/*--------------------------------------------------------------------
Beschreibung: Drawing beenden
--------------------------------------------------------------------*/
void SwView::ExitDraw()
{
NoRotate();
if(pShell)
2000-09-18 16:15:01 +00:00
{
2011-01-29 10:26:56 +09:00
// the shell may be invalid at close/reload/SwitchToViewShell
SfxDispatcher* pDispatch = GetViewFrame()->GetDispatcher();
sal_uInt16 nIdx = 0;
SfxShell* pTest = 0;
do
2000-09-18 16:15:01 +00:00
{
pTest = pDispatch->GetShell(nIdx++);
2000-09-18 16:15:01 +00:00
}
while( pTest && pTest != this && pTest != pShell);
if(pTest == pShell &&
// don't call LeaveSelFrmMode() etc. for the below,
// because objects may still be selected:
!pShell->ISA(SwDrawBaseShell) &&
!pShell->ISA(SwBezierShell) &&
!pShell->ISA(svx::ExtrusionBar) &&
!pShell->ISA(svx::FontworkBar))
2000-09-18 16:15:01 +00:00
{
SdrView *pSdrView = pWrtShell->GetDrawView();
2000-09-18 16:15:01 +00:00
if (pSdrView && pSdrView->IsGroupEntered())
{
pSdrView->LeaveOneGroup();
pSdrView->UnmarkAll();
GetViewFrame()->GetBindings().Invalidate(SID_ENTER_GROUP);
}
2000-09-18 16:15:01 +00:00
if (GetDrawFuncPtr())
{
if (pWrtShell->IsSelFrmMode())
pWrtShell->LeaveSelFrmMode();
GetDrawFuncPtr()->Deactivate();
SetDrawFuncPtr(NULL);
LeaveDrawCreate();
GetViewFrame()->GetBindings().Invalidate(SID_INSERT_DRAW);
}
GetEditWin().SetPointer(Pointer(POINTER_TEXT));
2000-09-18 16:15:01 +00:00
}
}
}
/*--------------------------------------------------------------------
Beschreibung: Rotate-Mode abschalten
--------------------------------------------------------------------*/
void SwView::NoRotate()
{
if (IsDrawRotate())
{
pWrtShell->SetDragMode(SDRDRAG_MOVE);
FlipDrawRotate();
const SfxBoolItem aTmp( SID_OBJECT_ROTATE, sal_False );
GetViewFrame()->GetBindings().SetState( aTmp );
}
}
/******************************************************************************
* Beschreibung: DrawTextEditMode einschalten
******************************************************************************/
sal_Bool SwView::EnterDrawTextMode(const Point& aDocPos)
{
SdrObject* pObj;
SdrPageView* pPV;
SwWrtShell *pSh = &GetWrtShell();
SdrView *pSdrView = pSh->GetDrawView();
OSL_ENSURE( pSdrView, "EnterDrawTextMode without DrawView?" );
2000-09-18 16:15:01 +00:00
sal_Bool bReturn = sal_False;
sal_uInt16 nOld = pSdrView->GetHitTolerancePixel();
pSdrView->SetHitTolerancePixel( 2 );
if( pSdrView->IsMarkedHit( aDocPos ) &&
!pSdrView->PickHandle( aDocPos ) && IsTextTool() &&
CWS-TOOLING: integrate CWS aw065 2009-06-17 13:48:12 +0200 aw r273068 : #99385# corrected small error in SCs selection visualisation 2009-06-16 15:45:28 +0200 wg r273021 : i102838 2009-06-16 12:46:07 +0200 wg r273016 : i102833 2009-06-11 17:40:29 +0200 aw r272895 : #i98870# added implementation for getPageCount helper 2009-06-11 16:39:54 +0200 aw r272885 : #i102663#, #i102667#, #i98870# incluide file typo corrected 2009-06-11 16:24:07 +0200 aw r272881 : #i102663#, #i102667#, #i98870# changes to SdrText, it's usage in SdrTextPrimitive2D and to OverlayObject base implementation. Also support for PageCountField added 2009-06-11 16:23:52 +0200 aw r272880 : #i102663#, #i102667#, #i98870# changes to SdrText, it's usage in SdrTextPrimitive2D and to OverlayObject base implementation. Also support for PageCountField added 2009-06-09 13:50:29 +0200 aw r272769 : #i98917# added support for the OverlayHatchRectanglePrimitive to follow rotation with it's hatch; simplified OverlayHatchRect 2009-06-09 13:04:06 +0200 aw r272766 : #i98870# re-added PageNumber identification in SdrTextPrimitive2D::get2DDecomposition 2009-06-08 18:56:05 +0200 aw r272744 : #i99385# added some last corrections to OverlayObjects in SD (had to do some merges on resync, needed to optically check and correct) 2009-06-08 11:17:57 +0200 aw r272725 : cws aw065: corrections after resync 2009-06-08 11:02:25 +0200 aw r272723 : cws aw065: corrections after resync 2009-06-08 10:36:22 +0200 aw r272722 : cws aw065: corrections after resync 2009-06-05 18:57:06 +0200 aw r272712 : CWS-TOOLING: rebase CWS aw065 to trunk@272291 (milestone: DEV300:m49) 2009-06-05 14:56:34 +0200 aw r272690 : #i89784# stripped old stuff no longer needed due to text-to-polygon conversion using primitives 2009-06-05 14:50:07 +0200 aw r272688 : #102091# removed on-model-lock suppression for SdrObject::ActionChanged() 2009-06-05 14:47:29 +0200 aw r272687 : #102091# corrected local value buffering in ScenePrimitive2D::get2DDecomposition 2009-06-03 17:53:32 +0200 aw r272599 : #i89784# version before stripping 2009-06-03 17:52:18 +0200 aw r272598 : #i89784# version before stripping 2009-05-28 17:15:47 +0200 aw r272420 : #i101872# old stuff removed/stripped 2009-05-28 17:15:32 +0200 aw r272419 : #i101872# old stuff removed/stripped 2009-05-28 17:15:15 +0200 aw r272418 : #i101872# old stuff removed/stripped 2009-05-28 17:14:45 +0200 aw r272417 : #i101872# old stuff removed/stripped 2009-05-28 12:13:56 +0200 aw r272396 : #i101872# stable hybrid state 2009-05-28 12:13:46 +0200 aw r272395 : #i101872# stable hybrid state 2009-05-28 12:13:35 +0200 aw r272394 : #i101872# stable hybrid state 2009-05-28 12:13:20 +0200 aw r272393 : #i101872# stable hybrid state 2009-05-28 12:13:05 +0200 aw r272392 : #i101872# stable hybrid state 2009-05-28 12:12:51 +0200 aw r272391 : #i101872# stable hybrid state 2009-05-15 16:56:02 +0200 aw r271952 : #i101872# HitTest unifications 2009-05-15 16:55:22 +0200 aw r271951 : #i101872# HitTest unifications 2009-05-15 16:55:12 +0200 aw r271950 : #i101872# HitTest unifications 2009-05-15 16:55:01 +0200 aw r271949 : #i101872# HitTest unifications 2009-05-15 16:54:51 +0200 aw r271948 : #i101872# HitTest unifications 2009-05-15 16:54:35 +0200 aw r271947 : #i101872# HitTest unifications 2009-05-15 16:54:22 +0200 aw r271946 : #i101872# HitTest unifications 2009-05-12 19:08:38 +0200 aw r271834 : #i101684# corrected AutoShape's preparation of text transformation due to different definitions in TextBounds 2009-05-12 15:44:49 +0200 aw r271827 : #i89784# expanded TextLayouterDevice::getTextOutlines() to support DXArray and X-Font scaling 2009-05-11 19:40:40 +0200 aw r271790 : #i99385# extended HitTest primitive usage, removed IsHdlHit implementations; prepared further HitTest simplifications 2009-05-11 19:40:25 +0200 aw r271789 : #i99385# extended HitTest primitive usage, removed IsHdlHit implementations; prepared further HitTest simplifications 2009-05-11 19:40:12 +0200 aw r271788 : #i99385# extended HitTest primitive usage, removed IsHdlHit implementations; prepared further HitTest simplifications 2009-05-11 13:01:53 +0200 aw r271765 : #i99385# corrections and optimizations 2009-05-08 14:48:40 +0200 aw r271718 : #i1016180# added optimizations in model operations when model is locked 2009-05-08 14:11:45 +0200 aw r271716 : #i101679# added flush() calls to OverlayManager when interaction step is prepared 2009-05-07 17:44:03 +0200 aw r271689 : #i99385# last corrections/changes 2009-05-07 17:43:47 +0200 aw r271688 : #i99385# last corrections/changes 2009-05-07 13:20:09 +0200 aw r271654 : #i99385# added changes from WFH 2009-05-07 13:19:38 +0200 aw r271653 : #i99385# added changes from WFH 2009-05-07 13:19:11 +0200 aw r271652 : #i99385# added changes from WFH 2009-05-07 11:33:17 +0200 aw r271643 : #i99385# corrections after resync 2009-05-07 11:17:31 +0200 aw r271642 : #i99385# corrections after resync 2009-05-06 18:46:53 +0200 aw r271609 : CWS-TOOLING: rebase CWS aw065 to trunk@271427 (milestone: DEV300:m47) 2009-05-05 18:24:03 +0200 aw r271548 : #i101443# force new text decomposition when TextBackgroundColor has changed 2009-05-05 17:44:42 +0200 aw r271542 : #i99385# 3rd round, simplifications and corrections done 2009-05-05 17:44:32 +0200 aw r271541 : #i99385# 3rd round, simplifications and corrections done 2009-05-05 17:44:20 +0200 aw r271540 : #i99385# 3rd round, simplifications and corrections done 2009-05-05 17:44:09 +0200 aw r271539 : #i99385# 3rd round, simplifications and corrections done 2009-05-05 15:48:38 +0200 aw r271527 : #i99385# 2nd round, usages checked and corrected 2009-05-05 15:48:15 +0200 aw r271526 : #i99385# 2nd round, usages checked and corrected 2009-05-05 15:48:03 +0200 aw r271525 : #i99385# 2nd round, usages checked and corrected 2009-05-05 15:47:51 +0200 aw r271524 : #i99385# 2nd round, usages checked and corrected 2009-04-27 18:33:10 +0200 aw r271300 : #i99385# state commit after all implementations are done 2009-04-27 15:36:53 +0200 aw r271283 : #i99385# state commit after all implementations are done 2009-04-27 15:27:49 +0200 aw r271280 : #i99385# state commit after all implementations are done 2009-04-27 15:27:33 +0200 aw r271279 : #i99385# state commit after all implementations are done 2009-04-27 15:27:00 +0200 aw r271278 : #i99385# state commit after all implementations are done 2009-04-27 15:26:15 +0200 aw r271277 : #i99385# state commit after all implementations are done 2009-04-27 15:25:40 +0200 aw r271275 : #i99385# state commit after all implementations are done 2009-04-27 15:25:19 +0200 aw r271274 : #i99385# state commit after all implementations are done 2009-04-27 15:24:00 +0200 aw r271272 : #i99385# state commit after all implementations are done 2009-03-19 17:12:00 +0100 aw r269757 : #i100360# corrected bitmap's PefSize calculation for bitmap filled objects when Bitmap is Pixel-based on it's mapping 2009-02-19 17:09:47 +0100 aw r268298 : #i98917# corrected attributes 2009-02-19 17:09:30 +0100 aw r268297 : #i98917# corrected attributes 2009-02-19 17:08:22 +0100 aw r268296 : #i98917# corrected attributes 2009-02-19 11:56:25 +0100 aw r268268 : #i98870# added extra code to react on PageNumber change 2009-02-18 16:57:24 +0100 aw r268243 : #i98917# in OverlayHatchRect::getGeometry the rotation was not applied to the TopLeft of the centered rectangle, but to the already extended one, thus the visualisation was rotating around the wrong edge
2009-07-02 14:28:15 +00:00
pSdrView->PickObj( aDocPos, pSdrView->getHitTolLog(), pObj, pPV, SDRSEARCH_PICKTEXTEDIT ) &&
// To allow SwDrawVirtObj text objects to be activated, allow their type, too.
( pObj->ISA( SdrTextObj ) ||
( pObj->ISA(SwDrawVirtObj) &&
((SwDrawVirtObj*)pObj)->GetReferencedObj().ISA(SdrTextObj) ) ) &&
2000-09-18 16:15:01 +00:00
!pWrtShell->IsSelObjProtected(FLYPROTECT_CONTENT))
{
bReturn = BeginTextEdit( pObj, pPV, pEditWin, sal_False );
}
2000-09-18 16:15:01 +00:00
pSdrView->SetHitTolerancePixel( nOld );
return bReturn;
}
/******************************************************************************
* Beschreibung: DrawTextEditMode einschalten
******************************************************************************/
sal_Bool SwView::BeginTextEdit(SdrObject* pObj, SdrPageView* pPV, Window* pWin,
bool bIsNewObj, bool bSetSelectionToStart)
2000-09-18 16:15:01 +00:00
{
SwWrtShell *pSh = &GetWrtShell();
SdrView *pSdrView = pSh->GetDrawView();
SdrOutliner* pOutliner = ::SdrMakeOutliner(OUTLINERMODE_TEXTOBJECT, pSdrView->GetModel());
2000-10-27 11:27:09 +00:00
uno::Reference< linguistic2::XSpellChecker1 > xSpell( ::GetSpellChecker() );
2000-09-18 16:15:01 +00:00
if (pOutliner)
{
pOutliner->SetRefDevice(pSh->getIDocumentDeviceAccess()->getReferenceDevice(false));
2000-09-18 16:15:01 +00:00
pOutliner->SetSpeller(xSpell);
2001-10-18 15:34:58 +00:00
uno::Reference<linguistic2::XHyphenator> xHyphenator( ::GetHyphenator() );
pOutliner->SetHyphenator( xHyphenator );
2000-09-18 16:15:01 +00:00
pSh->SetCalcFieldValueHdl(pOutliner);
sal_uInt32 nCntrl = pOutliner->GetControlWord();
nCntrl |= EE_CNTRL_ALLOWBIGOBJS;
nCntrl |= EE_CNTRL_URLSFXEXECUTE;
const SwViewOption *pOpt = pSh->GetViewOptions();
if (SwViewOption::IsFieldShadings())
2000-09-18 16:15:01 +00:00
nCntrl |= EE_CNTRL_MARKFIELDS;
else
nCntrl &= ~EE_CNTRL_MARKFIELDS;
if (pOpt->IsOnlineSpell())
nCntrl |= EE_CNTRL_ONLINESPELLING;
else
nCntrl &= ~EE_CNTRL_ONLINESPELLING;
pOutliner->SetControlWord(nCntrl);
const SfxPoolItem& rItem = pSh->GetDoc()->GetDefault(RES_CHRATR_LANGUAGE);
pOutliner->SetDefaultLanguage(((const SvxLanguageItem&)rItem).GetLanguage());
2001-03-16 13:42:55 +00:00
if( bIsNewObj )
pOutliner->SetVertical( SID_DRAW_TEXT_VERTICAL == nDrawSfxId ||
SID_DRAW_CAPTION_VERTICAL == nDrawSfxId );
2011-01-29 10:26:56 +09:00
// set default horizontal text direction at outliner
EEHorizontalTextDirection aDefHoriTextDir =
pSh->IsShapeDefaultHoriTextDirR2L() ? EE_HTEXTDIR_R2L : EE_HTEXTDIR_L2R;
pOutliner->SetDefaultHorizontalTextDirection( aDefHoriTextDir );
2000-09-18 16:15:01 +00:00
}
// To allow editing the referenced object from a SwDrawVirtObj here
// the original needs to be fetched evenually. This ATM activates the
// text edit mode for the original object.
SdrObject* pToBeActivated = pObj;
// Always the original object is edited. To allow the TextEdit to happen
// where the VirtObj is positioned, on demand a occurring offset is set at
// the TextEdit object. That offset is used for creating and managing the
// OutlinerView.
Point aNewTextEditOffset(0, 0);
if(pObj->ISA(SwDrawVirtObj))
{
SwDrawVirtObj* pVirtObj = (SwDrawVirtObj*)pObj;
pToBeActivated = &((SdrObject&)pVirtObj->GetReferencedObj());
aNewTextEditOffset = pVirtObj->GetOffset();
}
// set in each case, thus it will be correct for all objects
((SdrTextObj*)pToBeActivated)->SetTextEditOffset(aNewTextEditOffset);
sal_Bool bRet(pSdrView->SdrBeginTextEdit( pToBeActivated, pPV, pWin, sal_True, pOutliner, 0, sal_False, sal_False, sal_False ));
2000-09-18 16:15:01 +00:00
// #i7672#
// Since SdrBeginTextEdit actually creates the OutlinerView and thus also
// sets the background color, an own background color needs to be set
// after TextEditing was started. This is now done here.
if(bRet)
{
OutlinerView* pView = pSdrView->GetTextEditOutlinerView();
if(pView)
{
Color aBackground(pSh->GetShapeBackgrd());
pView->SetBackgroundColor(aBackground);
}
// editing should start at the end of text, spell checking at the beginning ...
ESelection aNewSelection(EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND, EE_PARA_NOT_FOUND, EE_INDEX_NOT_FOUND);
if (bSetSelectionToStart)
aNewSelection = ESelection();
pView->SetSelection(aNewSelection);
}
2000-09-18 16:15:01 +00:00
return bRet;
}
/******************************************************************************
* Beschreibung: Ist ein DrawTextObjekt selektiert?
******************************************************************************/
sal_Bool SwView::IsTextTool() const
{
sal_uInt16 nId;
sal_uInt32 nInvent;
SdrView *pSdrView = GetWrtShell().GetDrawView();
OSL_ENSURE( pSdrView, "IsTextTool without DrawView?" );
2000-09-18 16:15:01 +00:00
if (pSdrView->IsCreateMode())
pSdrView->SetCreateMode(sal_False);
pSdrView->TakeCurrentObj(nId,nInvent);
return (nInvent==SdrInventor);
}
SdrView* SwView::GetDrawView() const
{
return GetWrtShell().GetDrawView();
}
sal_Bool SwView::IsBezierEditMode()
{
return (!IsDrawSelMode() && GetWrtShell().GetDrawView()->HasMarkablePoints());
}
sal_Bool SwView::IsFormMode() const
{
if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
{
return (GetDrawFuncPtr()->IsInsertForm());
2000-09-18 16:15:01 +00:00
}
return AreOnlyFormsSelected();
}
void SwView::SetDrawFuncPtr(SwDrawBase* pFuncPtr)
{
2011-11-17 22:13:42 +04:00
delete pDrawActual;
2000-09-18 16:15:01 +00:00
pDrawActual = pFuncPtr;
}
void SwView::SetSelDrawSlot()
{
nDrawSfxId = SID_OBJECT_SELECT;
sDrawCustom.Erase();
2000-09-18 16:15:01 +00:00
}
sal_Bool SwView::AreOnlyFormsSelected() const
{
if ( GetWrtShell().IsFrmSelected() )
return sal_False;
sal_Bool bForm = sal_True;
SdrView* pSdrView = GetWrtShell().GetDrawView();
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
2000-09-18 16:15:01 +00:00
sal_uInt32 nCount = rMarkList.GetMarkCount();
if (nCount)
{
for (sal_uInt32 i = 0; i < nCount; i++)
{
// Sind ausser Controls noch normale Draw-Objekte selektiert?
SdrObject *pSdrObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
2000-09-18 16:15:01 +00:00
if (!HasOnlyObj(pSdrObj, FmFormInventor))
{
bForm = sal_False;
break;
}
}
}
else
bForm = sal_False;
return bForm;
}
sal_Bool SwView::HasDrwObj(SdrObject *pSdrObj) const
{
sal_Bool bRet = sal_False;
if (pSdrObj->IsGroupObject())
{
SdrObjList* pList = pSdrObj->GetSubList();
sal_uInt32 nCnt = pList->GetObjCount();
for (sal_uInt32 i = 0; i < nCnt; i++)
if ((bRet = HasDrwObj(pList->GetObj(i))) == sal_True)
break;
}
else if (SdrInventor == pSdrObj->GetObjInventor() || pSdrObj->Is3DObj())
return sal_True;
return bRet;
}
sal_Bool SwView::HasOnlyObj(SdrObject *pSdrObj, sal_uInt32 eObjInventor) const
{
sal_Bool bRet = sal_False;
if (pSdrObj->IsGroupObject())
{
SdrObjList* pList = pSdrObj->GetSubList();
sal_uInt32 nCnt = pList->GetObjCount();
for (sal_uInt32 i = 0; i < nCnt; i++)
if ((bRet = HasOnlyObj(pList->GetObj(i), eObjInventor)) == sal_False)
break;
}
else if (eObjInventor == pSdrObj->GetObjInventor())
return sal_True;
return bRet;
}
//#i87414# mod
IMPL_LINK(SwView, OnlineSpellCallback, SpellCallbackInfo*, pInfo)
{
if (pInfo->nCommand == SPELLCMD_STARTSPELLDLG)
GetViewFrame()->GetDispatcher()->Execute( FN_SPELL_GRAMMAR_DIALOG, SFX_CALLMODE_ASYNCHRON);
return 0;
}
2000-09-18 16:15:01 +00:00
sal_Bool SwView::ExecDrwTxtSpellPopup(const Point& rPt)
{
sal_Bool bRet = sal_False;
SdrView *pSdrView = pWrtShell->GetDrawView();
OutlinerView* pOLV = pSdrView->GetTextEditOutlinerView();
Point aPos( GetEditWin().LogicToPixel( rPt ) );
if (pOLV->IsWrongSpelledWordAtPos( aPos ))
{
bRet = sal_True;
Link aLink = LINK(this, SwView, OnlineSpellCallback);
pOLV->ExecuteSpellPopup( aPos,&aLink );
2000-09-18 16:15:01 +00:00
}
return bRet;
}
sal_Bool SwView::IsDrawTextHyphenate()
{
SdrView *pSdrView = pWrtShell->GetDrawView();
sal_Bool bHyphenate = sal_False;
SfxItemSet aNewAttr( pSdrView->GetModel()->GetItemPool(),
EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
if( pSdrView->GetAttributes( aNewAttr ) &&
aNewAttr.GetItemState( EE_PARA_HYPHENATE ) >= SFX_ITEM_AVAILABLE )
bHyphenate = ((const SfxBoolItem&)aNewAttr.Get( EE_PARA_HYPHENATE )).
GetValue();
return bHyphenate;
}
void SwView::HyphenateDrawText()
{
SdrView *pSdrView = pWrtShell->GetDrawView();
sal_Bool bHyphenate = IsDrawTextHyphenate();
SfxItemSet aSet( GetPool(), EE_PARA_HYPHENATE, EE_PARA_HYPHENATE );
aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, !bHyphenate ) );
pSdrView->SetAttributes( aSet );
GetViewFrame()->GetBindings().Invalidate(FN_HYPHENATE_OPT_DLG);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */