Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "hintids.hxx"
31 : : #include <editeng/protitem.hxx>
32 : : #include <svx/svdpagv.hxx>
33 : : #include <svx/fmmodel.hxx>
34 : : #include <sot/exchange.hxx>
35 : :
36 : : #include "swtypes.hxx"
37 : : #include "pagefrm.hxx"
38 : : #include "rootfrm.hxx"
39 : : #include "cntfrm.hxx"
40 : : #include "flyfrm.hxx"
41 : : #include "frmfmt.hxx"
42 : : #include "dflyobj.hxx"
43 : : #include "dcontact.hxx"
44 : : #include "frmatr.hxx"
45 : : #include "viewsh.hxx"
46 : : #include "viewimp.hxx"
47 : : #include "dview.hxx"
48 : : #include "dpage.hxx"
49 : : #include "doc.hxx"
50 : : #include "mdiexp.hxx"
51 : : #include <ndole.hxx>
52 : : #include <fmtanchr.hxx>
53 : : #include "shellres.hxx"
54 : : #include <IDocumentUndoRedo.hxx>
55 : :
56 : : // #i7672#
57 : : #include <editeng/outliner.hxx>
58 : :
59 : : #include <com/sun/star/embed/EmbedMisc.hpp>
60 : :
61 : : #include <vector>
62 : : // #i28701#
63 : : #include <sortedobjs.hxx>
64 : : #include <flyfrms.hxx>
65 : :
66 : :
67 : : using namespace com::sun::star;
68 : :
69 : :
70 [ # # ]: 0 : class SwSdrHdl : public SdrHdl
71 : : {
72 : : public:
73 : 0 : SwSdrHdl(const Point& rPnt, bool bTopRight ) :
74 [ # # ]: 0 : SdrHdl( rPnt, bTopRight ? HDL_ANCHOR_TR : HDL_ANCHOR ) {}
75 : : virtual sal_Bool IsFocusHdl() const;
76 : : };
77 : :
78 : 0 : sal_Bool SwSdrHdl::IsFocusHdl() const
79 : : {
80 [ # # ][ # # ]: 0 : if( HDL_ANCHOR == eKind || HDL_ANCHOR_TR == eKind )
81 : 0 : return sal_True;
82 : 0 : return SdrHdl::IsFocusHdl();
83 : : }
84 : :
85 : 0 : const SwFrm *lcl_FindAnchor( const SdrObject *pObj, sal_Bool bAll )
86 : : {
87 : 0 : const SwVirtFlyDrawObj *pVirt = pObj->ISA(SwVirtFlyDrawObj) ?
88 [ # # ]: 0 : (SwVirtFlyDrawObj*)pObj : 0;
89 [ # # ]: 0 : if ( pVirt )
90 : : {
91 [ # # ][ # # ]: 0 : if ( bAll || !pVirt->GetFlyFrm()->IsFlyInCntFrm() )
[ # # ]
92 : 0 : return pVirt->GetFlyFrm()->GetAnchorFrm();
93 : : }
94 : : else
95 : : {
96 : 0 : const SwDrawContact *pCont = (const SwDrawContact*)GetUserCall(pObj);
97 [ # # ]: 0 : if ( pCont )
98 : 0 : return pCont->GetAnchorFrm( pObj );
99 : : }
100 : 0 : return 0;
101 : : }
102 : :
103 : : /*************************************************************************
104 : : |*
105 : : |* SwDrawView::Ctor
106 : : |*
107 : : *************************************************************************/
108 : :
109 : :
110 : :
111 : 1337 : SwDrawView::SwDrawView( SwViewImp &rI, SdrModel *pMd, OutputDevice *pOutDev) :
112 : : FmFormView( (FmFormModel*)pMd, pOutDev ),
113 : 1337 : rImp( rI )
114 : : {
115 [ + - ]: 1337 : SetPageVisible( sal_False );
116 [ + - ]: 1337 : SetBordVisible( sal_False );
117 [ + - ]: 1337 : SetGridVisible( sal_False );
118 [ + - ]: 1337 : SetHlplVisible( sal_False );
119 [ + - ]: 1337 : SetGlueVisible( sal_False );
120 [ + - ]: 1337 : SetFrameDragSingles( sal_True );
121 : 1337 : SetVirtualObjectBundling( sal_True );
122 : 1337 : SetSwapAsynchron( sal_True );
123 : :
124 : 1337 : EnableExtendedKeyInputDispatcher( sal_False );
125 : 1337 : EnableExtendedMouseEventDispatcher( sal_False );
126 : 1337 : EnableExtendedCommandEventDispatcher( sal_False );
127 : :
128 [ + - ][ + - ]: 1337 : SetHitTolerancePixel( GetMarkHdlSizePixel()/2 );
129 : :
130 : 1337 : SetPrintPreview( rI.GetShell()->IsPreView() );
131 : :
132 : : // #i73602# Use default from the configuration
133 [ + - ][ + - ]: 1337 : SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_Writer());
134 : :
135 : : // #i74769#, #i75172# Use default from the configuration
136 [ + - ][ + - ]: 1337 : SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_Writer());
137 : 1337 : }
138 : :
139 : : // #i99665#
140 : 526 : sal_Bool SwDrawView::IsAntiAliasing() const
141 : : {
142 : 526 : return getOptionsDrawinglayer().IsAntiAliasing();
143 : : }
144 : :
145 : : //////////////////////////////////////////////////////////////////////////////
146 : :
147 : 2 : SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol, const SdrMarkList &rMrkList)
148 : : {
149 [ + - ]: 2 : if(!nTol)
150 : : {
151 : : // the old method forced back to outer bounds test when nTol == 0, so
152 : : // do not try to correct when nTol is not set (used from HelpContent)
153 : : }
154 : : else
155 : : {
156 : : // rebuild logic from former SwVirtFlyDrawObj::CheckSdrObjectHit. This is needed since
157 : : // the SdrObject-specific CheckHit implementations are now replaced with primitives and
158 : : // 'tricks' like in the old implementation (e.g. using a view from a model-data class to
159 : : // detect if object is selected) are no longer valid.
160 : : // The standard primitive hit-test for SwVirtFlyDrawObj now is the outer bound. The old
161 : : // implementation reduced this excluding the inner bound when the object was not selected.
162 [ - + ]: 2 : SwVirtFlyDrawObj* pSwVirtFlyDrawObj = dynamic_cast< SwVirtFlyDrawObj* >(pRetval);
163 : :
164 [ + - ]: 2 : if(pSwVirtFlyDrawObj)
165 : : {
166 [ + - ][ + - ]: 2 : if(pSwVirtFlyDrawObj->GetFlyFrm()->Lower() && pSwVirtFlyDrawObj->GetFlyFrm()->Lower()->IsNoTxtFrm())
[ - + ]
167 : : {
168 : : // the old method used IsNoTxtFrm (should be for SW's own OLE and
169 : : // graphic's) to accept hit only based on outer bounds; nothing to do
170 : : }
171 : : else
172 : : {
173 : : // check if the object is selected in this view
174 : 0 : const sal_uInt32 nMarkCount(rMrkList.GetMarkCount());
175 : 0 : bool bSelected(false);
176 : :
177 [ # # ][ # # ]: 0 : for(sal_uInt32 a(0); !bSelected && a < nMarkCount; a++)
[ # # ]
178 : : {
179 [ # # ]: 0 : if(pSwVirtFlyDrawObj == rMrkList.GetMark(a)->GetMarkedSdrObj())
180 : : {
181 : 0 : bSelected = true;
182 : : }
183 : : }
184 : :
185 [ # # ]: 0 : if(!bSelected)
186 : : {
187 : : // when not selected, the object is not hit when hit position is inside
188 : : // inner range. Get and shrink inner range
189 [ # # ]: 0 : basegfx::B2DRange aInnerBound(pSwVirtFlyDrawObj->getInnerBound());
190 : :
191 [ # # ]: 0 : aInnerBound.grow(-1.0 * nTol);
192 : :
193 [ # # ][ # # ]: 0 : if(aInnerBound.isInside(basegfx::B2DPoint(rPnt.X(), rPnt.Y())))
194 : : {
195 : : // exclude this hit
196 : 0 : pRetval = 0;
197 : : }
198 : : }
199 : : }
200 : : }
201 : : }
202 : :
203 : 2 : return pRetval;
204 : : }
205 : :
206 : 322 : SdrObject* SwDrawView::CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObject* pObj, SdrPageView* pPV, sal_uLong nOptions, const SetOfByte* pMVisLay) const
207 : : {
208 : : // call parent
209 : 322 : SdrObject* pRetval = FmFormView::CheckSingleSdrObjectHit(rPnt, nTol, pObj, pPV, nOptions, pMVisLay);
210 : :
211 [ + + ]: 322 : if(pRetval)
212 : : {
213 : : // overloaded to allow extra handling when picking SwVirtFlyDrawObj's
214 : 2 : pRetval = impLocalHitCorrection(pRetval, rPnt, nTol, GetMarkedObjectList());
215 : : }
216 : :
217 : 322 : return pRetval;
218 : : }
219 : :
220 : : /*************************************************************************
221 : : |*
222 : : |* SwDrawView::AddCustomHdl()
223 : : |*
224 : : |* Gets called every time the handles need to be build
225 : : |*
226 : : *************************************************************************/
227 : :
228 : 9180 : void SwDrawView::AddCustomHdl()
229 : : {
230 : 9180 : const SdrMarkList &rMrkList = GetMarkedObjectList();
231 : :
232 [ # # ][ # # ]: 9180 : if(rMrkList.GetMarkCount() != 1 || !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()))
[ # # ][ # # ]
[ - + ][ - + ]
233 : : return;
234 : :
235 [ # # ][ # # ]: 0 : SdrObject *pObj = rMrkList.GetMark(0)->GetMarkedSdrObj();
236 : : // make code robust
237 [ # # ]: 0 : SwFrmFmt* pFrmFmt( ::FindFrmFmt( pObj ) );
238 [ # # ]: 0 : if ( !pFrmFmt )
239 : : {
240 : : OSL_FAIL( "<SwDrawView::AddCustomHdl()> - missing frame format!" );
241 : : return;
242 : : }
243 [ # # ]: 0 : const SwFmtAnchor &rAnchor = pFrmFmt->GetAnchor();
244 : :
245 [ # # ]: 0 : if (FLY_AS_CHAR == rAnchor.GetAnchorId())
246 : : return;
247 : :
248 : : const SwFrm* pAnch;
249 [ # # ][ # # ]: 0 : if(0 == (pAnch = CalcAnchor()))
250 : : return;
251 : :
252 : 0 : Point aPos(aAnchorPoint);
253 : :
254 [ # # ]: 0 : if ( FLY_AT_CHAR == rAnchor.GetAnchorId() )
255 : : {
256 : : // #i28701# - use last character rectangle saved at object
257 : : // in order to avoid a format of the anchor frame
258 [ # # ][ # # ]: 0 : SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
259 [ # # ]: 0 : SwRect aAutoPos = pAnchoredObj->GetLastCharRect();
260 [ # # ]: 0 : if ( aAutoPos.Height() )
261 : : {
262 : 0 : aPos = aAutoPos.Pos();
263 : : }
264 : : }
265 : :
266 : : // add anchor handle:
267 : : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
268 [ # # ]: 0 : aHdl.AddHdl( new SwSdrHdl( aPos, ( pAnch->IsVertical() && !pAnch->IsVertLR() ) ||
269 [ # # # # ]: 9180 : pAnch->IsRightToLeft() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
270 : : }
271 : :
272 : : /*************************************************************************
273 : : |*
274 : : |* SwDrawView::GetMaxToTopObj(), _GetMaxToTopObj()
275 : : |*
276 : : *************************************************************************/
277 : :
278 : :
279 : 0 : SdrObject* SwDrawView::GetMaxToTopObj( SdrObject* pObj ) const
280 : : {
281 [ # # ]: 0 : if ( GetUserCall(pObj) )
282 : : {
283 : 0 : const SwFrm *pAnch = ::lcl_FindAnchor( pObj, sal_False );
284 [ # # ]: 0 : if ( pAnch )
285 : : {
286 : : //Das oberste Obj innerhalb des Ankers darf nicht ueberholt
287 : : //werden.
288 : 0 : const SwFlyFrm *pFly = pAnch->FindFlyFrm();
289 [ # # ]: 0 : if ( pFly )
290 : : {
291 : 0 : const SwPageFrm *pPage = pFly->FindPageFrm();
292 [ # # ]: 0 : if ( pPage->GetSortedObjs() )
293 : : {
294 : 0 : sal_uInt32 nOrdNum = 0;
295 [ # # ]: 0 : for ( sal_uInt16 i = 0; i < pPage->GetSortedObjs()->Count(); ++i )
296 : : {
297 : : const SdrObject *pO =
298 : 0 : (*pPage->GetSortedObjs())[i]->GetDrawObj();
299 : :
300 [ # # ]: 0 : if ( pO->GetOrdNumDirect() > nOrdNum )
301 : : {
302 : 0 : const SwFrm *pTmpAnch = ::lcl_FindAnchor( pO, sal_False );
303 [ # # ]: 0 : if ( pFly->IsAnLower( pTmpAnch ) )
304 : : {
305 : 0 : nOrdNum = pO->GetOrdNumDirect();
306 : : }
307 : : }
308 : : }
309 [ # # ]: 0 : if ( nOrdNum )
310 : : {
311 : 0 : SdrPage *pTmpPage = GetModel()->GetPage( 0 );
312 : 0 : ++nOrdNum;
313 [ # # ]: 0 : if ( nOrdNum < pTmpPage->GetObjCount() )
314 : : {
315 : 0 : return pTmpPage->GetObj( nOrdNum );
316 : : }
317 : : }
318 : : }
319 : : }
320 : : }
321 : : }
322 : 0 : return 0;
323 : : }
324 : :
325 : : /*************************************************************************
326 : : |*
327 : : |* SwDrawView::GetMaxToBtmObj()
328 : : |*
329 : : *************************************************************************/
330 : :
331 : :
332 : 0 : SdrObject* SwDrawView::GetMaxToBtmObj(SdrObject* pObj) const
333 : : {
334 [ # # ]: 0 : if ( GetUserCall(pObj) )
335 : : {
336 : 0 : const SwFrm *pAnch = ::lcl_FindAnchor( pObj, sal_False );
337 [ # # ]: 0 : if ( pAnch )
338 : : {
339 : : //Der Fly des Ankers darf nicht "unterflogen" werden.
340 : 0 : const SwFlyFrm *pFly = pAnch->FindFlyFrm();
341 [ # # ]: 0 : if ( pFly )
342 : : {
343 : 0 : SdrObject *pRet = (SdrObject*)pFly->GetVirtDrawObj();
344 [ # # ]: 0 : return pRet != pObj ? pRet : 0;
345 : : }
346 : : }
347 : : }
348 : 0 : return 0;
349 : : }
350 : :
351 : : /*************************************************************************
352 : : |*
353 : : |* SwDrawView::ObjOrderChanged()
354 : : |*
355 : : *************************************************************************/
356 : :
357 : : inline sal_Bool lcl_IsChild( SdrObject *pParent, SdrObject *pChild )
358 : : {
359 : : if ( pParent->ISA(SwVirtFlyDrawObj) )
360 : : {
361 : : const SwFrm *pAnch = lcl_FindAnchor( pChild, sal_False );
362 : : if ( pAnch && ((SwVirtFlyDrawObj*)pParent)->GetFlyFrm()->IsAnLower( pAnch ))
363 : : {
364 : : return sal_True;
365 : : }
366 : : }
367 : : return sal_False;
368 : : }
369 : :
370 : : inline SdrObject *lcl_FindParent( SdrObject *pObj )
371 : : {
372 : : const SwFrm *pAnch = lcl_FindAnchor( pObj, sal_False );
373 : : if ( pAnch && pAnch->IsInFly() )
374 : : return (SdrObject*)pAnch->FindFlyFrm()->GetVirtDrawObj();
375 : : return 0;
376 : : }
377 : :
378 : : /** determine maximal order number for a 'child' object of given 'parent' object
379 : :
380 : : @author OD
381 : : */
382 : 0 : sal_uInt32 SwDrawView::_GetMaxChildOrdNum( const SwFlyFrm& _rParentObj,
383 : : const SdrObject* _pExclChildObj ) const
384 : : {
385 : 0 : sal_uInt32 nMaxChildOrdNum = _rParentObj.GetDrawObj()->GetOrdNum();
386 : :
387 : 0 : const SdrPage* pDrawPage = _rParentObj.GetDrawObj()->GetPage();
388 : : OSL_ENSURE( pDrawPage,
389 : : "<SwDrawView::_GetMaxChildOrdNum(..) - missing drawing page at parent object - crash!" );
390 : :
391 : 0 : sal_uInt32 nObjCount = pDrawPage->GetObjCount();
392 [ # # ]: 0 : for ( sal_uInt32 i = nObjCount-1; i > _rParentObj.GetDrawObj()->GetOrdNum() ; --i )
393 : : {
394 : 0 : const SdrObject* pObj = pDrawPage->GetObj( i );
395 : :
396 : : // Don't consider 'child' object <_pExclChildObj>
397 [ # # ]: 0 : if ( pObj == _pExclChildObj )
398 : : {
399 : 0 : continue;
400 : : }
401 : :
402 [ # # # # ]: 0 : if ( pObj->GetOrdNum() > nMaxChildOrdNum &&
[ # # ]
403 : 0 : _rParentObj.IsAnLower( lcl_FindAnchor( pObj, sal_True ) ) )
404 : : {
405 : 0 : nMaxChildOrdNum = pObj->GetOrdNum();
406 : 0 : break;
407 : : }
408 : : }
409 : :
410 : 0 : return nMaxChildOrdNum;
411 : : }
412 : :
413 : : /** method to move 'repeated' objects of the given moved object to the
414 : : according level
415 : :
416 : : @author OD
417 : : */
418 : 0 : void SwDrawView::_MoveRepeatedObjs( const SwAnchoredObject& _rMovedAnchoredObj,
419 : : const std::vector<SdrObject*>& _rMovedChildObjs ) const
420 : : {
421 : : // determine 'repeated' objects of already moved object <_rMovedAnchoredObj>
422 [ # # ]: 0 : std::list<SwAnchoredObject*> aAnchoredObjs;
423 : : {
424 [ # # ][ # # ]: 0 : const SwContact* pContact = ::GetUserCall( _rMovedAnchoredObj.GetDrawObj() );
425 : : OSL_ENSURE( pContact,
426 : : "SwDrawView::_MoveRepeatedObjs(..) - missing contact object -> crash." );
427 [ # # ]: 0 : pContact->GetAnchoredObjs( aAnchoredObjs );
428 : : }
429 : :
430 : : // check, if 'repeated' objects exists.
431 [ # # ]: 0 : if ( aAnchoredObjs.size() > 1 )
432 : : {
433 [ # # ]: 0 : SdrPage* pDrawPage = GetModel()->GetPage( 0 );
434 : :
435 : : // move 'repeated' ones to the same order number as the already moved one.
436 [ # # ][ # # ]: 0 : sal_uInt32 nNewPos = _rMovedAnchoredObj.GetDrawObj()->GetOrdNum();
437 [ # # ]: 0 : while ( !aAnchoredObjs.empty() )
438 : : {
439 [ # # ]: 0 : SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
440 [ # # ]: 0 : if ( pAnchoredObj != &_rMovedAnchoredObj )
441 : : {
442 : : pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
443 [ # # ][ # # ]: 0 : nNewPos );
[ # # ]
444 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
445 : : // adjustments for accessibility API
446 [ # # ][ # # ]: 0 : if ( pAnchoredObj->ISA(SwFlyFrm) )
[ # # ]
447 : : {
448 [ # # ]: 0 : const SwFlyFrm *pTmpFlyFrm = static_cast<SwFlyFrm*>(pAnchoredObj);
449 [ # # ]: 0 : rImp.DisposeAccessibleFrm( pTmpFlyFrm );
450 [ # # ]: 0 : rImp.AddAccessibleFrm( pTmpFlyFrm );
451 : : }
452 : : else
453 : : {
454 [ # # ][ # # ]: 0 : rImp.DisposeAccessibleObj( pAnchoredObj->GetDrawObj() );
455 [ # # ][ # # ]: 0 : rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
456 : : }
457 : : }
458 [ # # ]: 0 : aAnchoredObjs.pop_back();
459 : : }
460 : :
461 : : // move 'repeated' ones of 'child' objects
462 [ # # # # ]: 0 : for ( std::vector<SdrObject*>::const_iterator aObjIter = _rMovedChildObjs.begin();
[ # # ]
463 : 0 : aObjIter != _rMovedChildObjs.end(); ++aObjIter )
464 : : {
465 [ # # ]: 0 : SdrObject* pChildObj = (*aObjIter);
466 : : {
467 [ # # ]: 0 : const SwContact* pContact = ::GetUserCall( pChildObj );
468 : : OSL_ENSURE( pContact,
469 : : "SwDrawView::_MoveRepeatedObjs(..) - missing contact object -> crash." );
470 [ # # ]: 0 : pContact->GetAnchoredObjs( aAnchoredObjs );
471 : : }
472 : : // move 'repeated' ones to the same order number as the already moved one.
473 [ # # ]: 0 : const sal_uInt32 nTmpNewPos = pChildObj->GetOrdNum();
474 [ # # ]: 0 : while ( !aAnchoredObjs.empty() )
475 : : {
476 [ # # ]: 0 : SwAnchoredObject* pAnchoredObj = aAnchoredObjs.back();
477 [ # # ][ # # ]: 0 : if ( pAnchoredObj->GetDrawObj() != pChildObj )
478 : : {
479 : : pDrawPage->SetObjectOrdNum( pAnchoredObj->GetDrawObj()->GetOrdNum(),
480 [ # # ][ # # ]: 0 : nTmpNewPos );
[ # # ]
481 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
482 : : // adjustments for accessibility API
483 [ # # ][ # # ]: 0 : if ( pAnchoredObj->ISA(SwFlyFrm) )
[ # # ]
484 : : {
485 [ # # ]: 0 : const SwFlyFrm *pTmpFlyFrm = static_cast<SwFlyFrm*>(pAnchoredObj);
486 [ # # ]: 0 : rImp.DisposeAccessibleFrm( pTmpFlyFrm );
487 [ # # ]: 0 : rImp.AddAccessibleFrm( pTmpFlyFrm );
488 : : }
489 : : else
490 : : {
491 [ # # ][ # # ]: 0 : rImp.DisposeAccessibleObj( pAnchoredObj->GetDrawObj() );
492 [ # # ][ # # ]: 0 : rImp.AddAccessibleObj( pAnchoredObj->GetDrawObj() );
493 : : }
494 : : }
495 [ # # ]: 0 : aAnchoredObjs.pop_back();
496 : : }
497 : : }
498 : 0 : }
499 : 0 : }
500 : :
501 : : // --> adjustment and re-factoring of method
502 : 0 : void SwDrawView::ObjOrderChanged( SdrObject* pObj, sal_uLong nOldPos,
503 : : sal_uLong nNewPos )
504 : : {
505 : : // nothing to do for group members
506 [ # # ][ # # ]: 0 : if ( pObj->GetUpGroup() )
507 : : {
508 : 0 : return;
509 : : }
510 : :
511 : : // determine drawing page and assure that the order numbers are correct.
512 [ # # ]: 0 : SdrPage* pDrawPage = GetModel()->GetPage( 0 );
513 [ # # ]: 0 : if ( pDrawPage->IsObjOrdNumsDirty() )
514 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
515 [ # # ]: 0 : const sal_uInt32 nObjCount = pDrawPage->GetObjCount();
516 : :
517 : : SwAnchoredObject* pMovedAnchoredObj =
518 [ # # ][ # # ]: 0 : ::GetUserCall( pObj )->GetAnchoredObj( pObj );
519 : : const SwFlyFrm* pParentAnchoredObj =
520 [ # # ][ # # ]: 0 : pMovedAnchoredObj->GetAnchorFrm()->FindFlyFrm();
521 : :
522 : 0 : const bool bMovedForward = nOldPos < nNewPos;
523 : :
524 : : // assure for a 'child' object, that it doesn't exceed the limits of its 'parent'
525 [ # # ]: 0 : if ( pParentAnchoredObj )
526 : : {
527 [ # # ]: 0 : if ( bMovedForward )
528 : : {
529 : : sal_uInt32 nMaxChildOrdNumWithoutMoved =
530 [ # # ][ # # ]: 0 : _GetMaxChildOrdNum( *pParentAnchoredObj, pMovedAnchoredObj->GetDrawObj() );
531 [ # # ]: 0 : if ( nNewPos > nMaxChildOrdNumWithoutMoved+1 )
532 : : {
533 : : // set position to the top of the 'child' object group
534 [ # # ]: 0 : pDrawPage->SetObjectOrdNum( nNewPos, nMaxChildOrdNumWithoutMoved+1 );
535 : 0 : nNewPos = nMaxChildOrdNumWithoutMoved+1;
536 : : }
537 : : }
538 : : else
539 : : {
540 [ # # ][ # # ]: 0 : const sal_uInt32 nParentOrdNum = pParentAnchoredObj->GetDrawObj()->GetOrdNum();
541 [ # # ]: 0 : if ( nNewPos < nParentOrdNum )
542 : : {
543 : : // set position to the bottom of the 'child' object group
544 [ # # ]: 0 : pDrawPage->SetObjectOrdNum( nNewPos, nParentOrdNum );
545 : 0 : nNewPos = nParentOrdNum;
546 : : }
547 : : }
548 [ # # ]: 0 : if ( pDrawPage->IsObjOrdNumsDirty() )
549 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
550 : : }
551 : :
552 : : // Assure, that object isn't positioned between 'repeated' ones
553 [ # # ][ # # ]: 0 : if ( ( bMovedForward && nNewPos < nObjCount - 1 ) ||
[ # # ][ # # ]
554 : 0 : ( !bMovedForward && nNewPos > 0 ) )
555 : : {
556 : : const SdrObject* pTmpObj =
557 [ # # ][ # # ]: 0 : pDrawPage->GetObj( bMovedForward ? nNewPos - 1 : nNewPos + 1 );
558 [ # # ]: 0 : if ( pTmpObj )
559 : : {
560 : 0 : sal_uInt32 nTmpNewPos( nNewPos );
561 [ # # ]: 0 : if ( bMovedForward )
562 : : {
563 : : // move before the top 'repeated' object
564 : : const sal_uInt32 nTmpMaxOrdNum =
565 [ # # ][ # # ]: 0 : ::GetUserCall( pTmpObj )->GetMaxOrdNum();
566 [ # # ]: 0 : if ( nTmpMaxOrdNum > nNewPos )
567 : 0 : nTmpNewPos = nTmpMaxOrdNum;
568 : : }
569 : : else
570 : : {
571 : : // move behind the bottom 'repeated' object
572 : : const sal_uInt32 nTmpMinOrdNum =
573 [ # # ][ # # ]: 0 : ::GetUserCall( pTmpObj )->GetMinOrdNum();
574 [ # # ]: 0 : if ( nTmpMinOrdNum < nNewPos )
575 : 0 : nTmpNewPos = nTmpMinOrdNum;
576 : : }
577 [ # # ]: 0 : if ( nTmpNewPos != nNewPos )
578 : : {
579 [ # # ]: 0 : pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
580 : 0 : nNewPos = nTmpNewPos;
581 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
582 : : }
583 : : }
584 : : }
585 : :
586 : : // On move forward, assure that object is moved before its own children.
587 : : // Only Writer fly frames can have children.
588 [ # # ][ # # ]: 0 : if ( pMovedAnchoredObj->ISA(SwFlyFrm) &&
[ # # ][ # # ]
[ # # ][ # # ]
589 : : bMovedForward && nNewPos < nObjCount - 1 )
590 : : {
591 : : sal_uInt32 nMaxChildOrdNum =
592 [ # # ][ # # ]: 0 : _GetMaxChildOrdNum( *(static_cast<const SwFlyFrm*>(pMovedAnchoredObj)) );
593 [ # # ]: 0 : if ( nNewPos < nMaxChildOrdNum )
594 : : {
595 : : // determine position before the object before its top 'child' object
596 [ # # ]: 0 : const SdrObject* pTmpObj = pDrawPage->GetObj( nMaxChildOrdNum );
597 [ # # ][ # # ]: 0 : sal_uInt32 nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum() + 1;
598 [ # # ]: 0 : if ( nTmpNewPos >= nObjCount )
599 : : {
600 : 0 : --nTmpNewPos;
601 : : }
602 : : // assure, that determined position isn't between 'repeated' objects
603 [ # # ]: 0 : pTmpObj = pDrawPage->GetObj( nTmpNewPos );
604 [ # # ][ # # ]: 0 : nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum();
605 : : // apply new position
606 [ # # ]: 0 : pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
607 : 0 : nNewPos = nTmpNewPos;
608 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
609 : : }
610 : : }
611 : :
612 : : // Assure, that object isn't positioned between nested objects
613 [ # # ][ # # ]: 0 : if ( ( bMovedForward && nNewPos < nObjCount - 1 ) ||
[ # # ][ # # ]
614 : 0 : ( !bMovedForward && nNewPos > 0 ) )
615 : : {
616 : 0 : sal_uInt32 nTmpNewPos( nNewPos );
617 : : const SwFrmFmt* pParentFrmFmt =
618 [ # # ][ # # ]: 0 : pParentAnchoredObj ? &(pParentAnchoredObj->GetFrmFmt()) : 0L;
619 [ # # ]: 0 : const SdrObject* pTmpObj = pDrawPage->GetObj( nNewPos + 1 );
620 [ # # ]: 0 : while ( pTmpObj )
621 : : {
622 : : // #i38563# - assure, that anchor frame exists.
623 : : // If object is anchored inside a invisible part of the document
624 : : // (e.g. page header, whose page style isn't applied, or hidden
625 : : // section), no anchor frame exists.
626 [ # # ]: 0 : const SwFrm* pTmpAnchorFrm = lcl_FindAnchor( pTmpObj, sal_True );
627 : : const SwFlyFrm* pTmpParentObj = pTmpAnchorFrm
628 [ # # ][ # # ]: 0 : ? pTmpAnchorFrm->FindFlyFrm() : 0L;
629 [ # # ][ # # ]: 0 : if ( pTmpParentObj &&
[ # # ]
630 [ # # ]: 0 : &(pTmpParentObj->GetFrmFmt()) != pParentFrmFmt )
631 : : {
632 [ # # ]: 0 : if ( bMovedForward )
633 : : {
634 [ # # ][ # # ]: 0 : nTmpNewPos = ::GetUserCall( pTmpObj )->GetMaxOrdNum();
635 [ # # ]: 0 : pTmpObj = pDrawPage->GetObj( nTmpNewPos + 1 );
636 : : }
637 : : else
638 : : {
639 : : nTmpNewPos = ::GetUserCall( pTmpParentObj->GetDrawObj() )
640 [ # # ][ # # ]: 0 : ->GetMinOrdNum();
[ # # ]
641 [ # # ]: 0 : pTmpObj = pTmpParentObj->GetDrawObj();
642 : : }
643 : : }
644 : : else
645 : 0 : break;
646 : : }
647 [ # # ]: 0 : if ( nTmpNewPos != nNewPos )
648 : : {
649 [ # # ]: 0 : pDrawPage->SetObjectOrdNum( nNewPos, nTmpNewPos );
650 : 0 : nNewPos = nTmpNewPos;
651 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
652 : : }
653 : : }
654 : :
655 : : // setup collection of moved 'child' objects to move its 'repeated' objects.
656 [ # # ]: 0 : std::vector< SdrObject* > aMovedChildObjs;
657 : :
658 : : // move 'children' accordingly
659 [ # # ][ # # ]: 0 : if ( pMovedAnchoredObj->ISA(SwFlyFrm) )
[ # # ]
660 : : {
661 [ # # ]: 0 : const SwFlyFrm* pFlyFrm = static_cast<SwFlyFrm*>(pMovedAnchoredObj);
662 : :
663 : : // adjustments for accessibility API
664 [ # # ]: 0 : rImp.DisposeAccessibleFrm( pFlyFrm );
665 [ # # ]: 0 : rImp.AddAccessibleFrm( pFlyFrm );
666 : :
667 [ # # ]: 0 : const sal_uInt32 nChildNewPos = bMovedForward ? nNewPos : nNewPos+1;
668 [ # # ]: 0 : sal_uInt32 i = bMovedForward ? nOldPos : nObjCount-1;
669 [ # # ][ # # ]: 0 : do
[ # # # # ]
[ # # ]
670 : : {
671 [ # # ]: 0 : SdrObject* pTmpObj = pDrawPage->GetObj( i );
672 [ # # ]: 0 : if ( pTmpObj == pObj )
673 : : break;
674 : :
675 : : // #i38563# - assure, that anchor frame exists.
676 : : // If object is anchored inside a invisible part of the document
677 : : // (e.g. page header, whose page style isn't applied, or hidden
678 : : // section), no anchor frame exists.
679 [ # # ]: 0 : const SwFrm* pTmpAnchorFrm = lcl_FindAnchor( pTmpObj, sal_True );
680 : : const SwFlyFrm* pTmpParentObj = pTmpAnchorFrm
681 [ # # ][ # # ]: 0 : ? pTmpAnchorFrm->FindFlyFrm() : 0L;
682 [ # # ][ # # ]: 0 : if ( pTmpParentObj &&
[ # # ][ # # ]
683 : : ( ( pTmpParentObj == pFlyFrm ) ||
684 [ # # ]: 0 : ( pFlyFrm->IsUpperOf( *pTmpParentObj ) ) ) )
685 : : {
686 : : // move child object.,
687 [ # # ]: 0 : pDrawPage->SetObjectOrdNum( i, nChildNewPos );
688 [ # # ]: 0 : pDrawPage->RecalcObjOrdNums();
689 : : // collect 'child' object
690 [ # # ]: 0 : aMovedChildObjs.push_back( pTmpObj );
691 : : // adjustments for accessibility API
692 [ # # ][ # # ]: 0 : if ( pTmpObj->ISA(SwVirtFlyDrawObj) )
[ # # ]
693 : : {
694 : : const SwFlyFrm *pTmpFlyFrm =
695 : 0 : static_cast<SwVirtFlyDrawObj*>(pTmpObj)->GetFlyFrm();
696 [ # # ]: 0 : rImp.DisposeAccessibleFrm( pTmpFlyFrm );
697 [ # # ]: 0 : rImp.AddAccessibleFrm( pTmpFlyFrm );
698 : : }
699 : : else
700 : : {
701 [ # # ]: 0 : rImp.DisposeAccessibleObj( pTmpObj );
702 [ # # ]: 0 : rImp.AddAccessibleObj( pTmpObj );
703 : : }
704 : : }
705 : : else
706 : : {
707 : : // adjust loop counter
708 [ # # ]: 0 : if ( bMovedForward )
709 : 0 : ++i;
710 [ # # ][ # # ]: 0 : else if ( !bMovedForward && i > 0 )
711 : 0 : --i;
712 : : }
713 : :
714 : 0 : } while ( ( bMovedForward && i < ( nObjCount - aMovedChildObjs.size() ) ) ||
715 : 0 : ( !bMovedForward && i > ( nNewPos + aMovedChildObjs.size() ) ) );
716 : : }
717 : : else
718 : : {
719 : : // adjustments for accessibility API
720 [ # # ]: 0 : rImp.DisposeAccessibleObj( pObj );
721 [ # # ]: 0 : rImp.AddAccessibleObj( pObj );
722 : : }
723 : :
724 [ # # ]: 0 : _MoveRepeatedObjs( *pMovedAnchoredObj, aMovedChildObjs );
725 : : }
726 : :
727 : : /*************************************************************************
728 : : |*
729 : : |* SwDrawView::TakeDragLimit()
730 : : |*
731 : : *************************************************************************/
732 : :
733 : :
734 : 0 : sal_Bool SwDrawView::TakeDragLimit( SdrDragMode eMode,
735 : : Rectangle& rRect ) const
736 : : {
737 : 0 : const SdrMarkList &rMrkList = GetMarkedObjectList();
738 : 0 : sal_Bool bRet = sal_False;
739 [ # # ]: 0 : if( 1 == rMrkList.GetMarkCount() )
740 : : {
741 [ # # ][ # # ]: 0 : const SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
742 : 0 : SwRect aRect;
743 [ # # ][ # # ]: 0 : if( ::CalcClipRect( pObj, aRect, eMode == SDRDRAG_MOVE ) )
744 : : {
745 [ # # ]: 0 : rRect = aRect.SVRect();
746 : 0 : bRet = sal_True;
747 : : }
748 : : }
749 : 0 : return bRet;
750 : : }
751 : :
752 : : /*************************************************************************
753 : : |*
754 : : |* SwDrawView::CalcAnchor()
755 : : |*
756 : : *************************************************************************/
757 : :
758 : :
759 : 0 : const SwFrm* SwDrawView::CalcAnchor()
760 : : {
761 : 0 : const SdrMarkList &rMrkList = GetMarkedObjectList();
762 [ # # ]: 0 : if ( rMrkList.GetMarkCount() != 1 )
763 : 0 : return NULL;
764 : :
765 [ # # ][ # # ]: 0 : SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
766 : :
767 : : //Fuer Absatzgebundene Objekte suchen, andernfalls einfach nur
768 : : //der aktuelle Anker. Nur suchen wenn wir gerade draggen.
769 : : const SwFrm* pAnch;
770 [ # # ]: 0 : Rectangle aMyRect;
771 [ # # ][ # # ]: 0 : const sal_Bool bFly = pObj->ISA(SwVirtFlyDrawObj);
772 [ # # ]: 0 : if ( bFly )
773 : : {
774 [ # # ]: 0 : pAnch = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetAnchorFrm();
775 [ # # ]: 0 : aMyRect = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->Frm().SVRect();
776 : : }
777 : : else
778 : : {
779 [ # # ]: 0 : SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
780 : : // determine correct anchor position for 'virtual' drawing objects.
781 : : // #i26791#
782 [ # # ]: 0 : pAnch = pC->GetAnchorFrm( pObj );
783 [ # # ]: 0 : if( !pAnch )
784 : : {
785 [ # # ]: 0 : pC->ConnectToLayout();
786 : : // determine correct anchor position for 'virtual' drawing objects.
787 : : // #i26791#
788 [ # # ]: 0 : pAnch = pC->GetAnchorFrm( pObj );
789 : : }
790 [ # # ]: 0 : aMyRect = pObj->GetSnapRect();
791 : : }
792 : :
793 : : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
794 [ # # ]: 0 : const sal_Bool bTopRight = pAnch && ( ( pAnch->IsVertical() &&
795 : 0 : !pAnch->IsVertLR() ) ||
796 [ # # ]: 0 : pAnch->IsRightToLeft() );
[ # # # # ]
[ # # ][ # # ]
797 [ # # ][ # # ]: 0 : const Point aMyPt = bTopRight ? aMyRect.TopRight() : aMyRect.TopLeft();
798 : :
799 : 0 : Point aPt;
800 [ # # ][ # # ]: 0 : if ( IsAction() )
801 : : {
802 [ # # ][ # # ]: 0 : if ( !TakeDragObjAnchorPos( aPt, bTopRight ) )
803 : 0 : return NULL;
804 : : }
805 : : else
806 : : {
807 [ # # ]: 0 : Rectangle aRect = pObj->GetSnapRect();
808 [ # # ][ # # ]: 0 : aPt = bTopRight ? aRect.TopRight() : aRect.TopLeft();
809 : : }
810 : :
811 [ # # ]: 0 : if ( aPt != aMyPt )
812 : : {
813 [ # # ]: 0 : if ( pAnch->IsCntntFrm() )
814 : : {
815 : : // allow drawing objects in header/footer,
816 : : // but exclude control objects.
817 [ # # ]: 0 : bool bBodyOnly = CheckControlLayer( pObj );
818 [ # # ]: 0 : pAnch = ::FindAnchor( (SwCntntFrm*)pAnch, aPt, bBodyOnly );
819 : : }
820 [ # # ]: 0 : else if ( !bFly )
821 : : {
822 : 0 : const SwRect aRect( aPt.X(), aPt.Y(), 1, 1 );
823 : :
824 [ # # ]: 0 : SwDrawContact* pContact = (SwDrawContact*)GetUserCall(pObj);
825 [ # # ]: 0 : if ( pContact->GetAnchorFrm( pObj ) &&
[ # # # # ]
[ # # ]
826 [ # # ]: 0 : pContact->GetAnchorFrm( pObj )->IsPageFrm() )
827 [ # # ]: 0 : pAnch = pContact->GetPageFrm();
828 : : else
829 [ # # ]: 0 : pAnch = pContact->FindPage( aRect );
830 : : }
831 : : }
832 [ # # ][ # # ]: 0 : if( pAnch && !pAnch->IsProtected() )
[ # # ][ # # ]
833 [ # # ][ # # ]: 0 : aAnchorPoint = pAnch->GetFrmAnchorPos( ::HasWrap( pObj ) );
834 : : else
835 : 0 : pAnch = 0;
836 : 0 : return pAnch;
837 : : }
838 : :
839 : : /*************************************************************************
840 : : |*
841 : : |* SwDrawView::ShowDragXor(), HideDragXor()
842 : : |*
843 : : *************************************************************************/
844 : :
845 : :
846 : 0 : void SwDrawView::ShowDragAnchor()
847 : : {
848 : 0 : SdrHdl* pHdl = aHdl.GetHdl(HDL_ANCHOR);
849 [ # # ]: 0 : if ( ! pHdl )
850 : 0 : pHdl = aHdl.GetHdl(HDL_ANCHOR_TR);
851 : :
852 [ # # ]: 0 : if(pHdl)
853 : : {
854 : 0 : CalcAnchor();
855 : 0 : pHdl->SetPos(aAnchorPoint);
856 : : }
857 : 0 : }
858 : :
859 : : /*************************************************************************
860 : : |*
861 : : |* SwDrawView::MarkListHasChanged()
862 : : |*
863 : : *************************************************************************/
864 : :
865 : :
866 : 1339 : void SwDrawView::MarkListHasChanged()
867 : : {
868 : 1339 : Imp().GetShell()->DrawSelChanged();
869 : 1339 : FmFormView::MarkListHasChanged();
870 : 1339 : }
871 : :
872 : : // #i7672#
873 : 829 : void SwDrawView::ModelHasChanged()
874 : : {
875 : : // The ModelHasChanged() call in DrawingLayer also updates
876 : : // a eventually active text edit view (OutlinerView). This also leads
877 : : // to newly setting the background color for that edit view. Thus,
878 : : // this method rescues the current background color if a OutlinerView
879 : : // exists and re-establishes it then. To be more safe, the OutlinerView
880 : : // will be fetched again (maybe textedit has ended).
881 : 829 : OutlinerView* pView = GetTextEditOutlinerView();
882 : 829 : Color aBackColor;
883 : 829 : sal_Bool bColorWasSaved(sal_False);
884 : :
885 [ - + ]: 829 : if(pView)
886 : : {
887 [ # # ]: 0 : aBackColor = pView->GetBackgroundColor();
888 : 0 : bColorWasSaved = sal_True;
889 : : }
890 : :
891 : : // call parent
892 [ + - ]: 829 : FmFormView::ModelHasChanged();
893 : :
894 [ - + ]: 829 : if(bColorWasSaved)
895 : : {
896 : 0 : pView = GetTextEditOutlinerView();
897 : :
898 [ # # ]: 0 : if(pView)
899 : : {
900 [ # # ]: 0 : pView->SetBackgroundColor(aBackColor);
901 : : }
902 : : }
903 : 829 : }
904 : :
905 : 8 : void SwDrawView::MakeVisible( const Rectangle &rRect, Window & )
906 : : {
907 : : OSL_ENSURE( rImp.GetShell()->GetWin(), "MakeVisible, unknown Window");
908 [ + - ]: 8 : rImp.GetShell()->MakeVisible( SwRect( rRect ) );
909 : 8 : }
910 : :
911 : 0 : void SwDrawView::CheckPossibilities()
912 : : {
913 : 0 : FmFormView::CheckPossibilities();
914 : :
915 : : //Zusaetzlich zu den bestehenden Flags der Objekte selbst, die von der
916 : : //DrawingEngine ausgewertet werden, koennen weitere Umstaende zu einem
917 : : //Schutz fuehren.
918 : : //Objekte, die in Rahmen verankert sind, muessen genau dann geschuetzt
919 : : //sein, wenn der Inhalt des Rahmens geschuetzt ist.
920 : : //OLE-Objekte konnen selbst einen Resize-Schutz wuenschen (StarMath)
921 : :
922 : 0 : const SdrMarkList &rMrkList = GetMarkedObjectList();
923 : 0 : sal_Bool bProtect = sal_False,
924 : 0 : bSzProtect = sal_False;
925 [ # # ][ # # ]: 0 : for ( sal_uInt16 i = 0; !bProtect && i < rMrkList.GetMarkCount(); ++i )
[ # # ]
926 : : {
927 : 0 : const SdrObject *pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
928 : 0 : const SwFrm *pFrm = NULL;
929 [ # # ]: 0 : if ( pObj->ISA(SwVirtFlyDrawObj) )
930 : : {
931 : 0 : const SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pObj)->GetFlyFrm();
932 [ # # ]: 0 : if ( pFly )
933 : : {
934 : 0 : pFrm = pFly->GetAnchorFrm();
935 [ # # ][ # # ]: 0 : if ( pFly->Lower() && pFly->Lower()->IsNoTxtFrm() )
[ # # ]
936 : : {
937 : 0 : SwOLENode *pNd = ((SwCntntFrm*)pFly->Lower())->GetNode()->GetOLENode();
938 [ # # ]: 0 : if ( pNd )
939 : : {
940 [ # # ]: 0 : uno::Reference < embed::XEmbeddedObject > xObj = pNd->GetOLEObj().GetOleRef();
941 [ # # ]: 0 : if ( xObj.is() )
942 : : {
943 : : // --> improvement for the future, when more
944 : : // than one Writer fly frame can be selected.
945 : :
946 : : // TODO/LATER: retrieve Aspect - from where?!
947 [ # # ][ # # ]: 0 : bSzProtect |= ( embed::EmbedMisc::EMBED_NEVERRESIZE & xObj->getStatus( embed::Aspects::MSOLE_CONTENT ) ) ? sal_True : sal_False;
[ # # ]
948 : :
949 : :
950 : : // #i972: protect position if it is a Math object anchored 'as char' and baseline alignment is activated
951 : 0 : SwDoc* pDoc = Imp().GetShell()->GetDoc();
952 [ # # ][ # # ]: 0 : const bool bProtectMathPos = SotExchange::IsMath( xObj->getClassID() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
[ # # # # ]
[ # # ]
953 [ # # ][ # # ]: 0 : && FLY_AS_CHAR == pFly->GetFmt()->GetAnchor().GetAnchorId()
954 [ # # # # ]: 0 : && pDoc->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT );
[ # # ][ # # ]
955 [ # # ]: 0 : if (bProtectMathPos)
956 : 0 : bMoveProtect = true;
957 : 0 : }
958 : : }
959 : : }
960 : : }
961 : : }
962 : : else
963 : : {
964 : 0 : SwDrawContact *pC = (SwDrawContact*)GetUserCall(pObj);
965 [ # # ]: 0 : if ( pC )
966 : 0 : pFrm = pC->GetAnchorFrm( pObj );
967 : : }
968 [ # # ]: 0 : if ( pFrm )
969 : 0 : bProtect = pFrm->IsProtected(); //Rahmen, Bereiche usw.
970 : : {
971 : 0 : SwFrmFmt* pFrmFmt( ::FindFrmFmt( const_cast<SdrObject*>(pObj) ) );
972 [ # # ]: 0 : if ( !pFrmFmt )
973 : : {
974 : : OSL_FAIL( "<SwDrawView::CheckPossibilities()> - missing frame format" );
975 : 0 : bProtect = sal_True;
976 : : }
977 [ # # # # ]: 0 : else if ((FLY_AS_CHAR == pFrmFmt->GetAnchor().GetAnchorId()) &&
[ # # ]
978 : 0 : rMrkList.GetMarkCount() > 1 )
979 : : {
980 : 0 : bProtect = sal_True;
981 : : }
982 : : }
983 : : }
984 : 0 : bMoveProtect |= bProtect;
985 : 0 : bResizeProtect |= bProtect | bSzProtect;
986 : 0 : }
987 : :
988 : : /** replace marked <SwDrawVirtObj>-objects by its reference object for delete
989 : : marked objects.
990 : :
991 : : @author OD
992 : : */
993 : 0 : void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView )
994 : : {
995 : 0 : SdrPageView* pDrawPageView = _rMarkView.GetSdrPageView();
996 : 0 : const SdrMarkList& rMarkList = _rMarkView.GetMarkedObjectList();
997 : :
998 [ # # ]: 0 : if( rMarkList.GetMarkCount() )
999 : : {
1000 : : // collect marked objects in a local data structure
1001 [ # # ]: 0 : std::vector<SdrObject*> aMarkedObjs;
1002 [ # # ]: 0 : for( sal_uInt32 i = 0; i < rMarkList.GetMarkCount(); ++i )
1003 : : {
1004 [ # # ][ # # ]: 0 : SdrObject* pMarkedObj = rMarkList.GetMark( i )->GetMarkedSdrObj();
1005 [ # # ]: 0 : aMarkedObjs.push_back( pMarkedObj );
1006 : : }
1007 : : // unmark all objects
1008 [ # # ]: 0 : _rMarkView.UnmarkAllObj();
1009 : : // re-mark objects, but for marked <SwDrawVirtObj>-objects marked its
1010 : : // reference object.
1011 [ # # ]: 0 : while ( !aMarkedObjs.empty() )
1012 : : {
1013 [ # # ]: 0 : SdrObject* pMarkObj = aMarkedObjs.back();
1014 [ # # ][ # # ]: 0 : if ( pMarkObj->ISA(SwDrawVirtObj) )
[ # # ]
1015 : : {
1016 [ # # ]: 0 : SdrObject* pRefObj = &(static_cast<SwDrawVirtObj*>(pMarkObj)->ReferencedObj());
1017 [ # # ][ # # ]: 0 : if ( !_rMarkView.IsObjMarked( pRefObj ) )
1018 : : {
1019 [ # # ]: 0 : _rMarkView.MarkObj( pRefObj, pDrawPageView );
1020 : : }
1021 : : }
1022 : : else
1023 : : {
1024 [ # # ]: 0 : _rMarkView.MarkObj( pMarkObj, pDrawPageView );
1025 : : }
1026 : :
1027 [ # # ]: 0 : aMarkedObjs.pop_back();
1028 : : }
1029 : : // sort marked list in order to assure consistent state in drawing layer
1030 [ # # ]: 0 : _rMarkView.SortMarkedObjects();
1031 : : }
1032 : 0 : }
1033 : :
1034 : 0 : void SwDrawView::DeleteMarked()
1035 : : {
1036 : 0 : SwDoc* pDoc = Imp().GetShell()->GetDoc();
1037 : 0 : SwRootFrm *pTmpRoot = pDoc->GetCurrentLayout();//swmod 080317
1038 [ # # ]: 0 : if ( pTmpRoot )
1039 : 0 : pTmpRoot->StartAllAction();
1040 : 0 : pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL);
1041 : : // replace marked <SwDrawVirtObj>-objects by its reference objects.
1042 : : {
1043 : 0 : SdrPageView* pDrawPageView = rImp.GetPageView();
1044 [ # # ]: 0 : if ( pDrawPageView )
1045 : : {
1046 [ # # ][ # # ]: 0 : SdrMarkView* pMarkView = PTR_CAST( SdrMarkView, &(pDrawPageView->GetView()) );
1047 [ # # ]: 0 : if ( pMarkView )
1048 : : {
1049 : 0 : ReplaceMarkedDrawVirtObjs( *pMarkView );
1050 : : }
1051 : : }
1052 : : }
1053 [ # # ]: 0 : if ( pDoc->DeleteSelection( *this ) )
1054 : : {
1055 : 0 : FmFormView::DeleteMarked();
1056 : 0 : ::FrameNotify( Imp().GetShell(), FLY_DRAG_END );
1057 : : }
1058 : 0 : pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_EMPTY, NULL);
1059 [ # # ]: 0 : if( pTmpRoot )
1060 : 0 : pTmpRoot->EndAllAction(); //swmod 080218
1061 : 0 : }
1062 : :
1063 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|