Files
libreoffice/sw/source/core/draw/dview.cxx

965 lines
34 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Oliver-Rainer Wittmann sw34bf06: #i117783# - Writer's implementation of XPagePrintable - apply print settings to new printing routines http://svn.apache.org/viewvc?view=revision&revision=1172115 sw34bf06: #o12311627# use <rtl_random> methods to create unique ids for list styles and list ids http://svn.apache.org/viewvc?view=revision&revision=1172112 sw34bf06 #i114725#,#i115828# - method <SwDoc::ClearDoc()> - clear list structures completely http://svn.apache.org/viewvc?view=revision&revision=1172122 i#118572 - remove ui string and help content regarding usage of Java Mail in Writer's Mail Merge as Java Mail is not used. http://svn.apache.org/viewvc?view=revision&revision=1197035 Patches contributed by Mathias Bauer cws mba34issues01: #i117718#: provide filter name in case storage of medium does not allow to detect one http://svn.apache.org/viewvc?view=revision&revision=1172350 cws mba34issues01: #i117721#: directly provide parameters retrieved from SfxMedium http://svn.apache.org/viewvc?view=revision&revision=1172353 gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 cws mba34issues01: #i117723#: convert assertion into trace http://svn.apache.org/viewvc?view=revision&revision=1172355 cws mba34issues01: #i117699#: keep layout alive until swdoc dies http://svn.apache.org/viewvc?view=revision&revision=1172362 cws mba34issues01: #i117943#: missing color attributes in RTF clipboard http://svn.apache.org/viewvc?view=revision&revision=1172363 Patch contributed by Henning Brinkmann imported patch i#103878 http://svn.apache.org/viewvc?view=revision&revision=1172109 Patches contributed by Michael Stahl sw34bf06: #i117955#: WW8 export: disable storing of section breaks in endnotes http://svn.apache.org/viewvc?view=revision&revision=1172119 Patch contributed by imacat Fixed the Asian language work count. http://svn.apache.org/viewvc?view=revision&revision=1241345 Patch contributed by Pedro Giffuni i#20878 - Add comment with BZ issue for reference. http://svn.apache.org/viewvc?view=revision&revision=1244517 Patch contributed by Andre Fischer Do not add targets for junit tests when junit is disabled. http://svn.apache.org/viewvc?view=revision&revision=1241508 add writerperfect dependency.
2011-03-31 10:05:04 +02:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2000-09-18 23:08:29 +00:00
#include "hintids.hxx"
#include <editeng/protitem.hxx>
2000-09-18 23:08:29 +00:00
#include <svx/svdpagv.hxx>
#include <svx/fmmodel.hxx>
#include <sot/exchange.hxx>
#include <svx/sdrundomanager.hxx>
#include <editeng/outliner.hxx>
#include <com/sun/star/embed/EmbedMisc.hpp>
2000-09-18 23:08:29 +00:00
#include "swtypes.hxx"
#include "pagefrm.hxx"
#include "rootfrm.hxx"
#include "cntfrm.hxx"
#include "flyfrm.hxx"
#include "frmfmt.hxx"
#include "dflyobj.hxx"
#include "dcontact.hxx"
#include "frmatr.hxx"
#include "viewsh.hxx"
#include "viewimp.hxx"
#include "dview.hxx"
#include "dpage.hxx"
#include "doc.hxx"
#include "mdiexp.hxx"
#include <ndole.hxx>
#include <fmtanchr.hxx>
#include "shellres.hxx"
#include <IDocumentUndoRedo.hxx>
2000-09-18 23:08:29 +00:00
// #i7672#
#include <com/sun/star/embed/Aspects.hpp>
#include <vector>
// #i28701#
#include <sortedobjs.hxx>
#include <flyfrms.hxx>
#include <UndoManager.hxx>
using namespace com::sun::star;
2002-05-28 13:05:17 +00:00
class SwSdrHdl : public SdrHdl
{
public:
SwSdrHdl(const Point& rPnt, bool bTopRight ) :
SdrHdl( rPnt, bTopRight ? HDL_ANCHOR_TR : HDL_ANCHOR ) {}
virtual sal_Bool IsFocusHdl() const;
2002-05-28 13:05:17 +00:00
};
sal_Bool SwSdrHdl::IsFocusHdl() const
2002-05-28 13:05:17 +00:00
{
if( HDL_ANCHOR == eKind || HDL_ANCHOR_TR == eKind )
return sal_True;
2002-05-28 13:05:17 +00:00
return SdrHdl::IsFocusHdl();
}
2000-09-18 23:08:29 +00:00
static const SwFrm *lcl_FindAnchor( const SdrObject *pObj, sal_Bool bAll )
2000-09-18 23:08:29 +00:00
{
const SwVirtFlyDrawObj *pVirt = pObj->ISA(SwVirtFlyDrawObj) ?
2000-09-18 23:08:29 +00:00
(SwVirtFlyDrawObj*)pObj : 0;
if ( pVirt )
{
if ( bAll || !pVirt->GetFlyFrm()->IsFlyInCntFrm() )
return pVirt->GetFlyFrm()->GetAnchorFrm();
2000-09-18 23:08:29 +00:00
}
else
{
const SwDrawContact *pCont = (const SwDrawContact*)GetUserCall(pObj);
if ( pCont )
return pCont->GetAnchorFrm( pObj );
2000-09-18 23:08:29 +00:00
}
return 0;
}
// SwDrawView
2000-09-18 23:08:29 +00:00
SwDrawView::SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice *pOutDev) :
FmFormView( (FmFormModel*)pMd, pOutDev ),
rImp( rI )
{
SetPageVisible( false );
SetBordVisible( false );
SetGridVisible( false );
SetHlplVisible( false );
SetGlueVisible( false );
SetFrameDragSingles( sal_True );
SetVirtualObjectBundling( sal_True );
SetSwapAsynchron( sal_True );
EnableExtendedKeyInputDispatcher( sal_False );
EnableExtendedMouseEventDispatcher( sal_False );
EnableExtendedCommandEventDispatcher( sal_False );
2000-09-18 23:08:29 +00:00
SetHitTolerancePixel( GetMarkHdlSizePixel()/2 );
SetPrintPreview( rI.GetShell()->IsPreview() );
// #i73602# Use default from the configuration
SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Writer());
// #i74769#, #i75172# Use default from the configuration
SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Writer());
2000-09-18 23:08:29 +00:00
}
// #i99665#
sal_Bool SwDrawView::IsAntiAliasing() const
{
return getOptionsDrawinglayer().IsAntiAliasing();
}
SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol, const SdrMarkList &rMrkList)
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
{
if(!nTol)
{
// the old method forced back to outer bounds test when nTol == 0, so
// do not try to correct when nTol is not set (used from HelpContent)
}
else
{
// rebuild logic from former SwVirtFlyDrawObj::CheckSdrObjectHit. This is needed since
// the SdrObject-specific CheckHit implementations are now replaced with primitives and
// 'tricks' like in the old implementation (e.g. using a view from a model-data class to
// detect if object is selected) are no longer valid.
// The standard primitive hit-test for SwVirtFlyDrawObj now is the outer bound. The old
// implementation reduced this excluding the inner bound when the object was not selected.
SwVirtFlyDrawObj* pSwVirtFlyDrawObj = dynamic_cast< SwVirtFlyDrawObj* >(pRetval);
if(pSwVirtFlyDrawObj)
{
if(pSwVirtFlyDrawObj->GetFlyFrm()->Lower() && pSwVirtFlyDrawObj->GetFlyFrm()->Lower()->IsNoTxtFrm())
{
// the old method used IsNoTxtFrm (should be for SW's own OLE and
// graphic's) to accept hit only based on outer bounds; nothing to do
}
else
{
// check if the object is selected in this view
const sal_uInt32 nMarkCount(rMrkList.GetMarkCount());
bool bSelected(false);
for(sal_uInt32 a(0); !bSelected && a < nMarkCount; a++)
{
if(pSwVirtFlyDrawObj == rMrkList.GetMark(a)->GetMarkedSdrObj())
{
bSelected = true;
}
}
if(!bSelected)
{
// when not selected, the object is not hit when hit position is inside
// inner range. Get and shrink inner range
basegfx::B2DRange aInnerBound(pSwVirtFlyDrawObj->getInnerBound());
aInnerBound.grow(-1.0 * nTol);
if(aInnerBound.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
{
// exclude this hit
pRetval = 0;
}
}
}
}
}
return pRetval;
}
SdrObject* SwDrawView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const
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
{
// call parent
SdrObject* pRetval = FmFormView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
if(pRetval)
{
// overloaded to allow extra handling when picking SwVirtFlyDrawObj's
pRetval = impLocalHitCorrection(pRetval, rPnt, nTol, GetMarkedObjectList());
}
return pRetval;
}
/// Gets called every time the handles need to be build
2000-09-18 23:08:29 +00:00
void SwDrawView::AddCustomHdl()
{
const SdrMarkList &rMrkList = GetMarkedObjectList();
2000-09-18 23:08:29 +00:00
if(rMrkList.GetMarkCount() != 1 || !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()))
2000-09-18 23:08:29 +00:00
return;
SdrObject *pObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
2011-02-08 08:51:51 +01:00
// make code robust
SwFrmFmt* pFrmFmt( ::FindFrmFmt( pObj ) );
if ( !pFrmFmt )
{
OSL_FAIL( "<SwDrawView::AddCustomHdl()> - missing frame format!" );
return;
}
const SwFmtAnchor &rAnchor = pFrmFmt->GetAnchor();
2000-09-18 23:08:29 +00:00
if (FLY_AS_CHAR == rAnchor.GetAnchorId())
2000-09-18 23:08:29 +00:00
return;
const SwFrm* pAnch;
if(0 == (pAnch = CalcAnchor()))
return;
Point aPos(aAnchorPoint);
if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
2000-09-18 23:08:29 +00:00
{
// #i28701# - use last character rectangle saved at object
// in order to avoid a format of the anchor frame
SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
SwRect aAutoPos = pAnchoredObj->GetLastCharRect();
if ( aAutoPos.Height() )
{
aPos = aAutoPos.Pos();
}
2000-09-18 23:08:29 +00:00
}
// add anchor handle:
2009-03-04 16:19:59 +00:00
//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
aHdl.AddHdl( new SwSdrHdl( aPos, ( pAnch->IsVertical() && !pAnch->IsVertLR() ) ||
pAnch->IsRightToLeft() ) );
2000-09-18 23:08:29 +00:00
}
SdrObject* SwDrawView::GetMaxToTopObj( SdrObject* pObj ) const
{
if ( GetUserCall(pObj) )
{
const SwFrm *pAnch = ::lcl_FindAnchor( pObj, sal_False );
2000-09-18 23:08:29 +00:00
if ( pAnch )
{
//The topmost Obj within the anchor must not be overtaken.
2000-09-18 23:08:29 +00:00
const SwFlyFrm *pFly = pAnch->FindFlyFrm();
if ( pFly )
{
const SwPageFrm *pPage = pFly->FindPageFrm();
if ( pPage->GetSortedObjs() )
{
sal_uInt32 nOrdNum = 0;
for ( sal_uInt16 i = 0; i < pPage->GetSortedObjs()->Count(); ++i )
2000-09-18 23:08:29 +00:00
{
const SdrObject *pO =
(*pPage->GetSortedObjs())[i]->GetDrawObj();
2000-09-18 23:08:29 +00:00
if ( pO->GetOrdNumDirect() > nOrdNum )
{
const SwFrm *pTmpAnch = ::lcl_FindAnchor( pO, sal_False );
if ( pFly->IsAnLower( pTmpAnch ) )
2000-09-18 23:08:29 +00:00
{
nOrdNum = pO->GetOrdNumDirect();
}
}
}
if ( nOrdNum )
{
SdrPage *pTmpPage = GetModel()->GetPage( 0 );
2000-09-18 23:08:29 +00:00
++nOrdNum;
if ( nOrdNum < pTmpPage->GetObjCount() )
2000-09-18 23:08:29 +00:00
{
return pTmpPage->GetObj( nOrdNum );
2000-09-18 23:08:29 +00:00
}
}
}
}
}
}
return 0;
}
SdrObject* SwDrawView::GetMaxToBtmObj(SdrObject* pObj) const
{
if ( GetUserCall(pObj) )
{
const SwFrm *pAnch = ::lcl_FindAnchor( pObj, sal_False );
2000-09-18 23:08:29 +00:00
if ( pAnch )
{
//The Fly of the anchor must not be "flying under".
2000-09-18 23:08:29 +00:00
const SwFlyFrm *pFly = pAnch->FindFlyFrm();
if ( pFly )
{
SdrObject *pRet = (SdrObject*)pFly->GetVirtDrawObj();
return pRet != pObj ? pRet : 0;
}
}
}
return 0;
}
/// determine maximal order number for a 'child' object of given 'parent' object
sal_uInt32 SwDrawView::_GetMaxChildOrdNum( const SwFlyFrm& _rParentObj,
const SdrObject* _pExclChildObj ) const
2000-09-18 23:08:29 +00:00
{
sal_uInt32 nMaxChildOrdNum = _rParentObj.GetDrawObj()->GetOrdNum();
const SdrPage* pDrawPage = _rParentObj.GetDrawObj()->GetPage();
OSL_ENSURE( pDrawPage,
"<SwDrawView::_GetMaxChildOrdNum(..) - missing drawing page at parent object - crash!" );
sal_uInt32 nObjCount = pDrawPage->GetObjCount();
for ( sal_uInt32 i = nObjCount-1; i > _rParentObj.GetDrawObj()->GetOrdNum() ; --i )
2000-09-18 23:08:29 +00:00
{
const SdrObject* pObj = pDrawPage->GetObj( i );
// Don't consider 'child' object <_pExclChildObj>
if ( pObj == _pExclChildObj )
{
continue;
}
if ( pObj->GetOrdNum() > nMaxChildOrdNum &&
_rParentObj.IsAnLower( lcl_FindAnchor( pObj, sal_True ) ) )
2000-09-18 23:08:29 +00:00
{
nMaxChildOrdNum = pObj->GetOrdNum();
break;
2000-09-18 23:08:29 +00:00
}
}
return nMaxChildOrdNum;
}
/// method to move 'repeated' objects of the given moved object to the according level
void SwDrawView::_MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
const std::vector<SdrObject*>& _rMovedChildObjs ) const
{
// determine 'repeated' objects of already moved object <_rMovedAnchoredObj>
std::list<SwAnchoredObject*> aAnchoredObjs;
2000-09-18 23:08:29 +00:00
{
const SwContact* pContact = ::GetUserCall( _rMovedAnchoredObj.GetDrawObj() );
OSL_ENSURE( pContact,
"SwDrawView::_MoveRepeatedObjs(..) - missing contact object -> crash." );
pContact->GetAnchoredObjs( aAnchoredObjs );
2000-09-18 23:08:29 +00:00
}
// check, if 'repeated' objects exists.
if ( aAnchoredObjs.size() > 1 )
2000-09-18 23:08:29 +00:00
{
SdrPage* pDrawPage = GetModel()->GetPage( 0 );
// move 'repeated' ones to the same order number as the already moved one.
sal_uInt32 nNewPos = _rMovedAnchoredObj.GetDrawObj()->GetOrdNum();
while ( !aAnchoredObjs.empty() )
2000-09-18 23:08:29 +00:00
{
SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
if ( pAnchoredObj != &_rMovedAnchoredObj )
2000-09-18 23:08:29 +00:00
{
pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
nNewPos );
pDrawPage->RecalcObjOrdNums();
// adjustments for accessibility API
if ( pAnchoredObj->ISA(SwFlyFrm) )
{
const SwFlyFrm *pTmpFlyFrm = static_cast<SwFlyFrm*>(pAnchoredObj);
rImp.DisposeAccessibleFrm( pTmpFlyFrm );
rImp.AddAccessibleFrm( pTmpFlyFrm );
}
else
{
rImp.DisposeAccessibleObj( pAnchoredObj->GetDrawObj() );
rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
}
2000-09-18 23:08:29 +00:00
}
aAnchoredObjs.pop_back();
2000-09-18 23:08:29 +00:00
}
// move 'repeated' ones of 'child' objects
for ( std::vector<SdrObject*>::const_iterator aObjIter = _rMovedChildObjs.begin();
aObjIter != _rMovedChildObjs.end(); ++aObjIter )
2000-09-18 23:08:29 +00:00
{
SdrObject* pChildObj = (*aObjIter);
2000-09-18 23:08:29 +00:00
{
const SwContact* pContact = ::GetUserCall( pChildObj );
OSL_ENSURE( pContact,
"SwDrawView::_MoveRepeatedObjs(..) - missing contact object -> crash." );
pContact->GetAnchoredObjs( aAnchoredObjs );
}
// move 'repeated' ones to the same order number as the already moved one.
const sal_uInt32 nTmpNewPos = pChildObj->GetOrdNum();
while ( !aAnchoredObjs.empty() )
{
SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
if ( pAnchoredObj->GetDrawObj() != pChildObj )
2000-09-18 23:08:29 +00:00
{
pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
nTmpNewPos );
pDrawPage->RecalcObjOrdNums();
// adjustments for accessibility API
if ( pAnchoredObj->ISA(SwFlyFrm) )
{
const SwFlyFrm *pTmpFlyFrm = static_cast<SwFlyFrm*>(pAnchoredObj);
rImp.DisposeAccessibleFrm( pTmpFlyFrm );
rImp.AddAccessibleFrm( pTmpFlyFrm );
}
else
{
rImp.DisposeAccessibleObj( pAnchoredObj->GetDrawObj() );
rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
}
2000-09-18 23:08:29 +00:00
}
aAnchoredObjs.pop_back();
2000-09-18 23:08:29 +00:00
}
}
}
}
2011-02-08 08:51:51 +01:00
// --> adjustment and re-factoring of method
void SwDrawView::ObjOrderChanged( SdrObject* pObj, sal_uLong nOldPos,
sal_uLong nNewPos )
{
2011-02-08 08:51:51 +01:00
// nothing to do for group members
if ( pObj->GetUpGroup() )
2000-09-18 23:08:29 +00:00
{
return;
2000-09-18 23:08:29 +00:00
}
// determine drawing page and assure that the order numbers are correct.
SdrPage* pDrawPage = GetModel()->GetPage( 0 );
if ( pDrawPage->IsObjOrdNumsDirty() )
pDrawPage->RecalcObjOrdNums();
const sal_uInt32 nObjCount = pDrawPage->GetObjCount();
SwAnchoredObject* pMovedAnchoredObj =
::GetUserCall( pObj )->GetAnchoredObj( pObj );
const SwFlyFrm* pParentAnchoredObj =
pMovedAnchoredObj->GetAnchorFrm()->FindFlyFrm();
2000-09-18 23:08:29 +00:00
const bool bMovedForward = nOldPos < nNewPos;
// assure for a 'child' object, that it doesn't exceed the limits of its 'parent'
if ( pParentAnchoredObj )
2000-09-18 23:08:29 +00:00
{
if ( bMovedForward )
2000-09-18 23:08:29 +00:00
{
sal_uInt32 nMaxChildOrdNumWithoutMoved =
_GetMaxChildOrdNum( *pParentAnchoredObj, pMovedAnchoredObj->GetDrawObj() );
if ( nNewPos > nMaxChildOrdNumWithoutMoved+1 )
{
// set position to the top of the 'child' object group
pDrawPage->SetObjectOrdNum( nNewPos, nMaxChildOrdNumWithoutMoved+1 );
nNewPos = nMaxChildOrdNumWithoutMoved+1;
}
}
else
{
const sal_uInt32 nParentOrdNum = pParentAnchoredObj->GetDrawObj()->GetOrdNum();
if ( nNewPos < nParentOrdNum )
{
// set position to the bottom of the 'child' object group
pDrawPage->SetObjectOrdNum( nNewPos, nParentOrdNum );
nNewPos = nParentOrdNum;
}
}
if ( pDrawPage->IsObjOrdNumsDirty() )
pDrawPage->RecalcObjOrdNums();
}
// Assure, that object isn't positioned between 'repeated' ones
if ( ( bMovedForward && nNewPos < nObjCount - 1 ) ||
( !bMovedForward && nNewPos > 0 ) )
{
const SdrObject* pTmpObj =
pDrawPage->GetObj( bMovedForward ? nNewPos - 1 : nNewPos + 1 );
if ( pTmpObj )
{
sal_uInt32 nTmpNewPos( nNewPos );
if ( bMovedForward )
{
// move before the top 'repeated' object
const sal_uInt32 nTmpMaxOrdNum =
::GetUserCall( pTmpObj )->GetMaxOrdNum();
if ( nTmpMaxOrdNum > nNewPos )
nTmpNewPos = nTmpMaxOrdNum;
}
2000-09-18 23:08:29 +00:00
else
{
// move behind the bottom 'repeated' object
const sal_uInt32 nTmpMinOrdNum =
::GetUserCall( pTmpObj )->GetMinOrdNum();
if ( nTmpMinOrdNum < nNewPos )
nTmpNewPos = nTmpMinOrdNum;
}
if ( nTmpNewPos != nNewPos )
{
pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
nNewPos = nTmpNewPos;
pDrawPage->RecalcObjOrdNums();
}
}
}
2011-12-07 02:33:51 -08:00
// On move forward, assure that object is moved before its own children.
// Only Writer fly frames can have children.
if ( pMovedAnchoredObj->ISA(SwFlyFrm) &&
bMovedForward && nNewPos < nObjCount - 1 )
{
sal_uInt32 nMaxChildOrdNum =
_GetMaxChildOrdNum( *(static_cast<const SwFlyFrm*>(pMovedAnchoredObj)) );
if ( nNewPos < nMaxChildOrdNum )
{
// determine position before the object before its top 'child' object
const SdrObject* pTmpObj = pDrawPage->GetObj( nMaxChildOrdNum );
sal_uInt32 nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum() + 1;
if ( nTmpNewPos >= nObjCount )
{
--nTmpNewPos;
}
// assure, that determined position isn't between 'repeated' objects
pTmpObj = pDrawPage->GetObj( nTmpNewPos );
nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum();
// apply new position
pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
nNewPos = nTmpNewPos;
pDrawPage->RecalcObjOrdNums();
}
}
// Assure, that object isn't positioned between nested objects
if ( ( bMovedForward && nNewPos < nObjCount - 1 ) ||
( !bMovedForward && nNewPos > 0 ) )
{
sal_uInt32 nTmpNewPos( nNewPos );
const SwFrmFmt* pParentFrmFmt =
pParentAnchoredObj ? &(pParentAnchoredObj->GetFrmFmt()) : 0L;
const SdrObject* pTmpObj = pDrawPage->GetObj( nNewPos + 1 );
while ( pTmpObj )
{
// #i38563# - assure, that anchor frame exists.
// If object is anchored inside a invisible part of the document
// (e.g. page header, whose page style isn't applied, or hidden
// section), no anchor frame exists.
const SwFrm* pTmpAnchorFrm = lcl_FindAnchor( pTmpObj, sal_True );
const SwFlyFrm* pTmpParentObj = pTmpAnchorFrm
? pTmpAnchorFrm->FindFlyFrm() : 0L;
if ( pTmpParentObj &&
&(pTmpParentObj->GetFrmFmt()) != pParentFrmFmt )
2000-09-18 23:08:29 +00:00
{
if ( bMovedForward )
{
nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum();
pTmpObj = pDrawPage->GetObj( nTmpNewPos + 1 );
}
else
2002-04-05 11:27:40 +00:00
{
nTmpNewPos = ::GetUserCall( pTmpParentObj->GetDrawObj() )
->GetMinOrdNum();
pTmpObj = pTmpParentObj->GetDrawObj();
2002-04-05 11:27:40 +00:00
}
2000-09-18 23:08:29 +00:00
}
else
break;
2000-09-18 23:08:29 +00:00
}
if ( nTmpNewPos != nNewPos )
{
pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
nNewPos = nTmpNewPos;
pDrawPage->RecalcObjOrdNums();
}
}
// setup collection of moved 'child' objects to move its 'repeated' objects.
std::vector< SdrObject* > aMovedChildObjs;
2011-12-07 02:33:51 -08:00
// move 'children' accordingly
if ( pMovedAnchoredObj->ISA(SwFlyFrm) )
{
const SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pMovedAnchoredObj);
// adjustments for accessibility API
rImp.DisposeAccessibleFrm( pFlyFrm );
rImp.AddAccessibleFrm( pFlyFrm );
const sal_uInt32 nChildNewPos = bMovedForward ? nNewPos : nNewPos+1;
sal_uInt32 i = bMovedForward ? nOldPos : nObjCount-1;
do
{
SdrObject* pTmpObj = pDrawPage->GetObj( i );
if ( pTmpObj == pObj )
break;
// #i38563# - assure, that anchor frame exists.
// If object is anchored inside a invisible part of the document
// (e.g. page header, whose page style isn't applied, or hidden
// section), no anchor frame exists.
const SwFrm* pTmpAnchorFrm = lcl_FindAnchor( pTmpObj, sal_True );
const SwFlyFrm* pTmpParentObj = pTmpAnchorFrm
? pTmpAnchorFrm->FindFlyFrm() : 0L;
if ( pTmpParentObj &&
( ( pTmpParentObj == pFlyFrm ) ||
( pFlyFrm->IsUpperOf( *pTmpParentObj ) ) ) )
{
// move child object.,
pDrawPage->SetObjectOrdNum( i, nChildNewPos );
pDrawPage->RecalcObjOrdNums();
// collect 'child' object
aMovedChildObjs.push_back( pTmpObj );
// adjustments for accessibility API
if ( pTmpObj->ISA(SwVirtFlyDrawObj) )
{
const SwFlyFrm *pTmpFlyFrm =
static_cast<SwVirtFlyDrawObj*>(pTmpObj)->GetFlyFrm();
rImp.DisposeAccessibleFrm( pTmpFlyFrm );
rImp.AddAccessibleFrm( pTmpFlyFrm );
}
else
{
rImp.DisposeAccessibleObj( pTmpObj );
rImp.AddAccessibleObj( pTmpObj );
}
}
else
{
// adjust loop counter
if ( bMovedForward )
++i;
else if ( !bMovedForward && i > 0 )
--i;
}
} while ( ( bMovedForward && i < ( nObjCount - aMovedChildObjs.size() ) ) ||
( !bMovedForward && i > ( nNewPos + aMovedChildObjs.size() ) ) );
2000-09-18 23:08:29 +00:00
}
2002-05-15 12:32:21 +00:00
else
{
// adjustments for accessibility API
2002-05-15 12:32:21 +00:00
rImp.DisposeAccessibleObj( pObj );
rImp.AddAccessibleObj( pObj );
}
_MoveRepeatedObjs( *pMovedAnchoredObj, aMovedChildObjs );
2000-09-18 23:08:29 +00:00
}
sal_Bool SwDrawView::TakeDragLimit( SdrDragMode eMode,
2000-09-18 23:08:29 +00:00
Rectangle& rRect ) const
{
const SdrMarkList &rMrkList = GetMarkedObjectList();
sal_Bool bRet = sal_False;
2000-09-18 23:08:29 +00:00
if( 1 == rMrkList.GetMarkCount() )
{
const SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
2000-09-18 23:08:29 +00:00
SwRect aRect;
if( ::CalcClipRect( pObj, aRect, eMode == SDRDRAG_MOVE ) )
{
rRect = aRect.SVRect();
bRet = sal_True;
2000-09-18 23:08:29 +00:00
}
}
return bRet;
}
const SwFrm* SwDrawView::CalcAnchor()
2000-09-18 23:08:29 +00:00
{
const SdrMarkList &rMrkList = GetMarkedObjectList();
2000-09-18 23:08:29 +00:00
if ( rMrkList.GetMarkCount() != 1 )
return NULL;
SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
2000-09-18 23:08:29 +00:00
//Search for paragraph bound objects, otherwise only the
//current anchor. Search only if we currently drag.
const SwFrm* pAnch;
Rectangle aMyRect;
const sal_Bool bFly = pObj->ISA(SwVirtFlyDrawObj);
2000-09-18 23:08:29 +00:00
if ( bFly )
{
pAnch = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetAnchorFrm();
aMyRect = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->Frm().SVRect();
2000-09-18 23:08:29 +00:00
}
else
{
SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
2011-02-08 08:51:51 +01:00
// determine correct anchor position for 'virtual' drawing objects.
// #i26791#
pAnch = pC->GetAnchorFrm( pObj );
2000-09-18 23:08:29 +00:00
if( !pAnch )
{
pC->ConnectToLayout();
2011-02-08 08:51:51 +01:00
// determine correct anchor position for 'virtual' drawing objects.
// #i26791#
pAnch = pC->GetAnchorFrm( pObj );
2000-09-18 23:08:29 +00:00
}
aMyRect = pObj->GetSnapRect();
}
2009-03-04 16:19:59 +00:00
//Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
const sal_Bool bTopRight = pAnch && ( ( pAnch->IsVertical() &&
!pAnch->IsVertLR() ) ||
pAnch->IsRightToLeft() );
const Point aMyPt = bTopRight ? aMyRect.TopRight() : aMyRect.TopLeft();
Point aPt;
if ( IsAction() )
{
if ( !TakeDragObjAnchorPos( aPt, bTopRight ) )
return NULL;
}
else
{
Rectangle aRect = pObj->GetSnapRect();
aPt = bTopRight ? aRect.TopRight() : aRect.TopLeft();
2000-09-18 23:08:29 +00:00
}
if ( aPt != aMyPt )
{
if ( pAnch->IsCntntFrm() )
{
2011-02-08 08:51:51 +01:00
// allow drawing objects in header/footer,
// but exclude control objects.
bool bBodyOnly = CheckControlLayer( pObj );
pAnch = ::FindAnchor( (SwCntntFrm*)pAnch, aPt, bBodyOnly );
}
2000-09-18 23:08:29 +00:00
else if ( !bFly )
{
const SwRect aRect( aPt.getX(), aPt.getY(), 1, 1 );
2000-09-18 23:08:29 +00:00
SwDrawContact* pContact = (SwDrawContact*)GetUserCall(pObj);
if ( pContact->GetAnchorFrm( pObj ) &&
pContact->GetAnchorFrm( pObj )->IsPageFrm() )
pAnch = pContact->GetPageFrm();
2000-09-18 23:08:29 +00:00
else
pAnch = pContact->FindPage( aRect );
}
}
if( pAnch && !pAnch->IsProtected() )
aAnchorPoint = pAnch->GetFrmAnchorPos( ::HasWrap( pObj ) );
2000-09-18 23:08:29 +00:00
else
pAnch = 0;
return pAnch;
}
void SwDrawView::ShowDragAnchor()
{
SdrHdl* pHdl = aHdl.GetHdl(HDL_ANCHOR);
if ( ! pHdl )
pHdl = aHdl.GetHdl(HDL_ANCHOR_TR);
2000-09-18 23:08:29 +00:00
if(pHdl)
{
CalcAnchor();
pHdl->SetPos(aAnchorPoint);
}
}
void SwDrawView::MarkListHasChanged()
{
Imp().GetShell()->DrawSelChanged();
2000-09-18 23:08:29 +00:00
FmFormView::MarkListHasChanged();
}
// #i7672#
void SwDrawView::ModelHasChanged()
{
// The ModelHasChanged() call in DrawingLayer also updates
// a eventually active text edit view (OutlinerView). This also leads
// to newly setting the background color for that edit view. Thus,
// this method rescues the current background color if a OutlinerView
// exists and re-establishes it then. To be more safe, the OutlinerView
// will be fetched again (maybe textedit has ended).
OutlinerView* pView = GetTextEditOutlinerView();
Color aBackColor;
bool bColorWasSaved(false);
if(pView)
{
aBackColor = pView->GetBackgroundColor();
bColorWasSaved = true;
}
// call parent
FmFormView::ModelHasChanged();
if(bColorWasSaved)
{
pView = GetTextEditOutlinerView();
if(pView)
{
pView->SetBackgroundColor(aBackColor);
}
}
}
2000-09-18 23:08:29 +00:00
void SwDrawView::MakeVisible( const Rectangle &rRect, Window & )
2000-09-18 23:08:29 +00:00
{
OSL_ENSURE( rImp.GetShell()->GetWin(), "MakeVisible, unknown Window");
2000-09-18 23:08:29 +00:00
rImp.GetShell()->MakeVisible( SwRect( rRect ) );
}
void SwDrawView::CheckPossibilities()
{
FmFormView::CheckPossibilities();
//In addition to the existing flags of the objects themselves,
//which are evaluated by the DrawingEngine, other circumstances
//lead to a protection.
//Objects that are anchored in frames need to be protected
//if the content of the frame is protected.
//OLE-Objects may themselves wish a resize protection (StarMath)
2000-09-18 23:08:29 +00:00
const SdrMarkList &rMrkList = GetMarkedObjectList();
bool bProtect = false;
bool bSzProtect = false;
for ( sal_uInt16 i = 0; !bProtect && i < rMrkList.GetMarkCount(); ++i )
2000-09-18 23:08:29 +00:00
{
const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
2000-09-18 23:08:29 +00:00
const SwFrm *pFrm = NULL;
if ( pObj->ISA(SwVirtFlyDrawObj) )
2000-09-18 23:08:29 +00:00
{
const SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
if ( pFly )
{
pFrm = pFly->GetAnchorFrm();
2000-09-18 23:08:29 +00:00
if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
{
SwOLENode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetOLENode();
if ( pNd )
{
uno::Reference < embed::XEmbeddedObject > xObj = pNd->GetOLEObj().GetOleRef();
if ( xObj.is() )
2000-09-18 23:08:29 +00:00
{
2011-02-08 08:51:51 +01:00
// --> improvement for the future, when more
// than one Writer fly frame can be selected.
// TODO/LATER: retrieve Aspect - from where?!
bSzProtect |= ( embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ) ) != 0;
// #i972: protect position if it is a Math object anchored 'as char' and baseline alignment is activated
SwDoc* pDoc = Imp().GetShell()->GetDoc();
const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
&& FLY_AS_CHAR == pFly->GetFmt()->GetAnchor().GetAnchorId()
&& pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
if (bProtectMathPos)
bMoveProtect = true;
2000-09-18 23:08:29 +00:00
}
}
}
}
}
else
{
SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
if ( pC )
pFrm = pC->GetAnchorFrm( pObj );
2000-09-18 23:08:29 +00:00
}
if ( pFrm )
bProtect = pFrm->IsProtected(); //Frames, areas etc.
{
SwFrmFmt* pFrmFmt( ::FindFrmFmt( const_cast<SdrObject*>(pObj) ) );
if ( !pFrmFmt )
{
OSL_FAIL( "<SwDrawView::CheckPossibilities()> - missing frame format" );
bProtect = true;
}
else if ((FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) &&
rMrkList.GetMarkCount() > 1 )
{
bProtect = true;
}
}
2000-09-18 23:08:29 +00:00
}
bMoveProtect |= bProtect;
bResizeProtect |= bProtect || bSzProtect;
2000-09-18 23:08:29 +00:00
}
/// replace marked <SwDrawVirtObj>-objects by its reference object for delete marked objects.
void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView )
{
SdrPageView* pDrawPageView = _rMarkView.GetSdrPageView();
const SdrMarkList& rMarkList = _rMarkView.GetMarkedObjectList();
if( rMarkList.GetMarkCount() )
{
// collect marked objects in a local data structure
std::vector<SdrObject*> aMarkedObjs;
for( sal_uInt32 i = 0; i < rMarkList.GetMarkCount(); ++i )
{
SdrObject* pMarkedObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
aMarkedObjs.push_back( pMarkedObj );
}
// unmark all objects
_rMarkView.UnmarkAllObj();
// re-mark objects, but for marked <SwDrawVirtObj>-objects marked its
// reference object.
while ( !aMarkedObjs.empty() )
{
SdrObject* pMarkObj = aMarkedObjs.back();
if ( pMarkObj->ISA(SwDrawVirtObj) )
{
SdrObject* pRefObj = &(static_cast<SwDrawVirtObj*>(pMarkObj)->ReferencedObj());
if ( !_rMarkView.IsObjMarked( pRefObj ) )
{
_rMarkView.MarkObj( pRefObj, pDrawPageView );
}
}
else
{
_rMarkView.MarkObj( pMarkObj, pDrawPageView );
}
aMarkedObjs.pop_back();
}
// sort marked list in order to assure consistent state in drawing layer
_rMarkView.SortMarkedObjects();
}
}
2000-09-18 23:08:29 +00:00
void SwDrawView::DeleteMarked()
{
SwDoc* pDoc = Imp().GetShell()->GetDoc();
SwRootFrm *pTmpRoot = pDoc->GetCurrentLayout();
if ( pTmpRoot )
pTmpRoot->StartAllAction();
pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
2011-02-08 08:51:51 +01:00
// replace marked <SwDrawVirtObj>-objects by its reference objects.
{
SdrPageView* pDrawPageView = rImp.GetPageView();
if ( pDrawPageView )
{
SdrMarkView* pMarkView = PTR_CAST( SdrMarkView, &(pDrawPageView->GetView()) );
if ( pMarkView )
{
ReplaceMarkedDrawVirtObjs( *pMarkView );
}
}
}
if ( pDoc->DeleteSelection( *this ) )
2000-09-18 23:08:29 +00:00
{
FmFormView::DeleteMarked();
::FrameNotify( Imp().GetShell(), FLY_DRAG_END );
}
pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
if( pTmpRoot )
pTmpRoot->EndAllAction();
2000-09-18 23:08:29 +00:00
}
// support enhanced text edit for draw objects
SdrUndoManager* SwDrawView::getSdrUndoManagerForEnhancedTextEdit() const
{
SwDoc* pDoc = Imp().GetShell()->GetDoc();
return pDoc ? dynamic_cast< SdrUndoManager* >(&(pDoc->GetUndoManager())) : 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */