xref: /aoo41x/main/sw/source/core/frmedt/fews.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #include <tools/list.hxx>
32 #include <svx/svdobj.hxx>
33 #include <init.hxx>
34 #include <fesh.hxx>
35 #include <pagefrm.hxx>
36 #include <rootfrm.hxx>
37 #include <cntfrm.hxx>
38 #include <doc.hxx>
39 #include <frmtool.hxx>
40 #include <swtable.hxx>
41 #include <viewimp.hxx>
42 #include <dview.hxx>
43 #include <flyfrm.hxx>
44 #include <node.hxx>
45 #include <pam.hxx>
46 #include <sectfrm.hxx>
47 #include <fmtpdsc.hxx>
48 #include <fmtsrnd.hxx>
49 #include <fmtcntnt.hxx>
50 #include <tabfrm.hxx>
51 #include <cellfrm.hxx>
52 #include <flyfrms.hxx>
53 #include <txtfrm.hxx>		// SwTxtFrm
54 #include <mdiexp.hxx>
55 #include <edimp.hxx>
56 #include <pagedesc.hxx>
57 #include <fmtanchr.hxx>
58 // OD 29.10.2003 #113049#
59 #include <environmentofanchoredobject.hxx>
60 // OD 12.11.2003 #i22341#
61 #include <ndtxt.hxx>
62 // OD 27.11.2003 #112045#
63 #include <dflyobj.hxx>
64 // OD 2004-03-29 #i26791#
65 #include <dcontact.hxx>
66 
67 
68 using namespace com::sun::star;
69 
70 
71 TYPEINIT1(SwFEShell,SwEditShell)
72 
73 /***********************************************************************
74 #*	Class	   :  SwFEShell
75 #*	Methode    :  EndAllActionAndCall()
76 #*
77 #*	Datum	   :  MA 03. May. 93
78 #*	Update	   :  MA 31. Oct. 95
79 #***********************************************************************/
80 
81 void SwFEShell::EndAllActionAndCall()
82 {
83 	ViewShell *pTmp = this;
84 	do {
85 		if( pTmp->IsA( TYPE(SwCrsrShell) ) )
86 		{
87 			((SwFEShell*)pTmp)->EndAction();
88 			((SwFEShell*)pTmp)->CallChgLnk();
89 		}
90 		else
91 			pTmp->EndAction();
92 	} while( this != ( pTmp = (ViewShell*)pTmp->GetNext() ));
93 }
94 
95 
96 /***********************************************************************
97 #*	Class		:  SwFEShell
98 #*	Methode 	:  GetCntntPos
99 #*	Beschreibung:  Ermitteln des Cntnt's der dem Punkt am naechsten liegt
100 #*	Datum		:  MA 02. Jun. 92
101 #*	Update		:  MA 02. May. 95
102 #***********************************************************************/
103 
104 Point SwFEShell::GetCntntPos( const Point& rPoint, sal_Bool bNext ) const
105 {
106 	SET_CURR_SHELL( (ViewShell*)this );
107 	return GetLayout()->GetNextPrevCntntPos( rPoint, bNext );
108 }
109 
110 
111 const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt,
112                                         const uno::Reference < embed::XEmbeddedObject >& xObj ) const
113 {
114 	const SwFrm *pFrm = Imp()->HasDrawView()
115 				? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
116 									  (ViewShell*)this)
117 				: 0;
118 
119 	if( !pFrm )
120 	{
121 		if( pPt )
122 		{
123 			SwPosition aPos( *GetCrsr()->GetPoint() );
124 			Point aPt( *pPt );
125 			GetLayout()->GetCrsrOfst( &aPos, aPt );
126 			SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
127 			pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
128 		}
129 		else
130         {
131             const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
132             if( bOldCallbackActionEnabled )
133                 GetLayout()->SetCallbackActionEnabled( sal_False );
134 			pFrm = GetCurrFrm();
135             if( bOldCallbackActionEnabled )
136                 GetLayout()->SetCallbackActionEnabled( sal_True );
137         }
138 	}
139 
140 	if( !pFrm )
141 		return GetLayout()->Frm();
142 
143 	sal_Bool  bFrm 	= sal_True;
144 	switch ( eType )
145 	{
146 		case RECT_PAGE_PRT:			bFrm = sal_False; /* no break */
147 		case RECT_PAGE :			pFrm = pFrm->FindPageFrm();
148 									break;
149 
150 		case RECT_PAGE_CALC:		pFrm->Calc();
151 									pFrm = pFrm->FindPageFrm();
152 									pFrm->Calc();
153 									break;
154 
155 		case RECT_FLY_PRT_EMBEDDED:	bFrm = sal_False; /* no break */
156         case RECT_FLY_EMBEDDED:     pFrm = xObj.is() ? FindFlyFrm( xObj )
157 												: pFrm->IsFlyFrm()
158 													? pFrm
159 													: pFrm->FindFlyFrm();
160 									break;
161 
162 		case RECT_OUTTABSECTION_PRT:
163 		case RECT_OUTTABSECTION :   if( pFrm->IsInTab() )
164 										pFrm = pFrm->FindTabFrm();
165 									else {
166 										ASSERT( sal_False, "Missing Table" );
167                                     }
168 									/* KEIN BREAK */
169 		case RECT_SECTION_PRT:
170 		case RECT_SECTION:			if( pFrm->IsInSct() )
171 										pFrm = pFrm->FindSctFrm();
172 									else {
173 										ASSERT( sal_False, "Missing section" );
174                                     }
175 
176 									if( RECT_OUTTABSECTION_PRT == eType ||
177 										RECT_SECTION_PRT == eType )
178 										bFrm = sal_False;
179 									break;
180 
181 		case RECT_HEADERFOOTER_PRT:	bFrm = sal_False; /* no break */
182 		case RECT_HEADERFOOTER:	   	if( 0 == (pFrm = pFrm->FindFooterOrHeader()) )
183 										return GetLayout()->Frm();
184 									break;
185 
186         case RECT_PAGES_AREA:       return GetLayout()->GetPagesArea();
187 
188         default:                    break;
189 	}
190 	return bFrm ? pFrm->Frm() : pFrm->Prt();
191 }
192 
193 
194 sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const
195 {
196 	const SwFrm *pPage = GetLayout()->Lower();
197 	while ( pPage && !pPage->Frm().IsInside( rPoint ) )
198 		pPage = pPage->GetNext();
199 	if ( pPage )
200 		return ((const SwPageFrm*)pPage)->GetPhyPageNum();
201 	else
202 		return 0;
203 }
204 
205 
206 sal_Bool SwFEShell::GetPageNumber( long nYPos, sal_Bool bAtCrsrPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, String &rDisplay) const
207 {
208 	const SwFrm *pPage;
209 
210 	if ( bAtCrsrPos )					//Seite vom Crsr besorgen
211 	{
212 		pPage = GetCurrFrm( sal_False );
213 		if ( pPage )
214 			pPage = pPage->FindPageFrm();
215 	}
216 	else if ( nYPos > -1 )				//Seite ueber die Positon ermitteln
217 	{
218 		pPage = GetLayout()->Lower();
219 		while( pPage &&  (pPage->Frm().Bottom() < nYPos ||
220 							nYPos < pPage->Frm().Top() ) )
221 			pPage = pPage->GetNext();
222 	}
223 	else								//Die erste sichtbare Seite
224 	{
225 		pPage = Imp()->GetFirstVisPage();
226 		if ( pPage && ((SwPageFrm*)pPage)->IsEmptyPage() )
227 			pPage = pPage->GetNext();
228 	}
229 
230 	if( pPage )
231 	{
232 		rPhyNum  = ((const SwPageFrm*)pPage)->GetPhyPageNum();
233 		rVirtNum = ((const SwPageFrm*)pPage)->GetVirtPageNum();
234 		const SvxNumberType& rNum = ((const SwPageFrm*)pPage)->GetPageDesc()->GetNumType();
235 		rDisplay = rNum.GetNumStr( rVirtNum );
236 	}
237 
238 	return 0 != pPage;
239 }
240 
241 /*************************************************************************
242 |*
243 |*  SwFEShell::IsDirectlyInSection()
244 |*
245 |*  Hack for OS:
246 |*
247 *************************************************************************/
248 
249 bool SwFEShell::IsDirectlyInSection() const
250 {
251     SwFrm* pFrm = GetCurrFrm( sal_False );
252     return pFrm && pFrm->GetUpper() && pFrm->GetUpper()->IsSctFrm();
253 }
254 
255 /*************************************************************************
256 |*
257 |*	SwFEShell::GetFrmType()
258 |*
259 |*	Ersterstellung		MA 12. Jan. 93
260 |*	Letzte Aenderung	AMA 25. Nov. 98
261 |*
262 *************************************************************************/
263 
264 sal_uInt16 SwFEShell::GetFrmType( const Point *pPt, sal_Bool bStopAtFly ) const
265 {
266 	sal_uInt16 nReturn = FRMTYPE_NONE;
267     const SwFrm *pFrm;
268 	if ( pPt )
269 	{
270 		SwPosition aPos( *GetCrsr()->GetPoint() );
271 		Point aPt( *pPt );
272 		GetLayout()->GetCrsrOfst( &aPos, aPt );
273 		SwCntntNode *pNd = aPos.nNode.GetNode().GetCntntNode();
274 		pFrm = pNd->getLayoutFrm( GetLayout(), pPt );
275 	}
276 	else
277 		pFrm = GetCurrFrm( sal_False );
278 	while ( pFrm )
279 	{
280 		switch ( pFrm->GetType() )
281 		{
282 			case FRM_COLUMN:	if( pFrm->GetUpper()->IsSctFrm() )
283 								{
284 									// Check, if isn't not only a single column
285 									// from a section with footnotes at the end.
286 									if( pFrm->GetNext() || pFrm->GetPrev() )
287 										// Sectioncolumns
288 										nReturn |= ( nReturn & FRMTYPE_TABLE ) ?
289 											FRMTYPE_COLSECTOUTTAB : FRMTYPE_COLSECT;
290 								}
291 								else // nur Seiten und Rahmenspalten
292 									nReturn |= FRMTYPE_COLUMN;
293 								break;
294 			case FRM_PAGE:		nReturn |= FRMTYPE_PAGE;
295 								if(	((SwPageFrm*)pFrm)->IsFtnPage() )
296 									nReturn |= FRMTYPE_FTNPAGE;
297 								break;
298 			case FRM_HEADER:	nReturn |= FRMTYPE_HEADER;		break;
299 			case FRM_FOOTER:	nReturn |= FRMTYPE_FOOTER;		break;
300 			case FRM_BODY:		if( pFrm->GetUpper()->IsPageFrm() ) // nicht bei ColumnFrms
301 									nReturn |= FRMTYPE_BODY;
302 								break;
303 			case FRM_FTN:		nReturn |= FRMTYPE_FOOTNOTE;	break;
304 			case FRM_FLY:       if( ((SwFlyFrm*)pFrm)->IsFlyLayFrm() )
305 									nReturn |= FRMTYPE_FLY_FREE;
306 								else if ( ((SwFlyFrm*)pFrm)->IsFlyAtCntFrm() )
307 									nReturn |= FRMTYPE_FLY_ATCNT;
308 								else
309 								{
310 									ASSERT( ((SwFlyFrm*)pFrm)->IsFlyInCntFrm(),
311 											"Neuer Rahmentyp?" );
312 									nReturn |= FRMTYPE_FLY_INCNT;
313 								}
314 								nReturn |= FRMTYPE_FLY_ANY;
315 								if( bStopAtFly )
316 									return nReturn;
317 								break;
318 			case FRM_TAB:
319 			case FRM_ROW:
320 			case FRM_CELL:		nReturn |= FRMTYPE_TABLE;		break;
321 			default:			/* do nothing */				break;
322 		}
323 		if ( pFrm->IsFlyFrm() )
324             pFrm = ((SwFlyFrm*)pFrm)->GetAnchorFrm();
325 		else
326 			pFrm = pFrm->GetUpper();
327 	}
328 	return nReturn;
329 }
330 
331 /*************************************************************************
332 |*
333 |*	SwFEShell::ShLooseFcs(), ShGetFcs()
334 |*
335 |*	Ersterstellung		MA 10. May. 93
336 |*	Letzte Aenderung	MA 09. Sep. 98
337 |*
338 *************************************************************************/
339 
340 void SwFEShell::ShGetFcs( sal_Bool bUpdate )
341 {
342 	::SetShell( this );
343 	SwCrsrShell::ShGetFcs( bUpdate );
344 
345 	if ( HasDrawView() )
346 	{
347 		Imp()->GetDrawView()->showMarkHandles();
348 		if ( Imp()->GetDrawView()->AreObjectsMarked() )
349 			FrameNotify( this, FLY_DRAG_START );
350 	}
351 }
352 
353 void SwFEShell::ShLooseFcs()
354 {
355 	SwCrsrShell::ShLooseFcs();
356 
357 	if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
358 	{
359 		Imp()->GetDrawView()->hideMarkHandles();
360 		FrameNotify( this, FLY_DRAG_END );
361 	}
362 //	::ResetShell();
363 }
364 
365 /*************************************************************************
366 |*
367 |*	SwFEShell::GetPhyPageNum()
368 |*	SwFEShell::GetVirtPageNum()
369 |*
370 |*	Ersterstellung		OK 07.07.93 08:20
371 |*	Letzte Aenderung	MA 03. Jan. 94
372 |*
373 *************************************************************************/
374 
375 sal_uInt16 SwFEShell::GetPhyPageNum()
376 {
377 	SwFrm *pFrm = GetCurrFrm();
378 	if ( pFrm )
379 		return pFrm->GetPhyPageNum();
380 	return 0;
381 }
382 
383 sal_uInt16 SwFEShell::GetVirtPageNum( const sal_Bool bCalcFrm )
384 {
385 	SwFrm *pFrm = GetCurrFrm( bCalcFrm );
386 	if ( pFrm )
387 		return pFrm->GetVirtPageNum();
388 	return 0;
389 }
390 
391 /*************************************************************************
392 |*
393 |*	void lcl_SetAPageOffset()
394 |*	void SwFEShell::SetNewPageOffset()
395 |*	void SwFEShell::SetPageOffset()
396 |*	sal_uInt16 SwFEShell::GetPageOffset() const
397 |*
398 |*	Ersterstellung		OK 07.07.93 08:20
399 |*	Letzte Aenderung	MA 30. Mar. 95
400 |*
401 *************************************************************************/
402 
403 void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrm* pPage, SwFEShell* pThis )
404 {
405 	pThis->StartAllAction();
406 	ASSERT( pPage->FindFirstBodyCntnt(),
407 			"SwFEShell _SetAPageOffset() ohne CntntFrm" );
408 
409 	SwFmtPageDesc aDesc( pPage->GetPageDesc() );
410 	aDesc.SetNumOffset( nOffset );
411 
412 	SwFrm *pFrm = pThis->GetCurrFrm( sal_False );
413 	if ( pFrm->IsInTab() )
414 		pThis->GetDoc()->SetAttr( aDesc, *pFrm->FindTabFrm()->GetFmt() );
415 	else
416     {
417         pThis->GetDoc()->InsertPoolItem( *pThis->GetCrsr(), aDesc, 0 );
418     }
419 
420 	pThis->EndAllAction();
421 }
422 
423 void SwFEShell::SetNewPageOffset( sal_uInt16 nOffset )
424 {
425 	GetLayout()->SetVirtPageNum( sal_True );
426 	const SwPageFrm *pPage = GetCurrFrm( sal_False )->FindPageFrm();
427 	lcl_SetAPageOffset( nOffset, (SwPageFrm*)pPage, this );
428 }
429 
430 void SwFEShell::SetPageOffset( sal_uInt16 nOffset )
431 {
432 	const SwPageFrm *pPage = GetCurrFrm( sal_False )->FindPageFrm();
433 	const SwRootFrm* pDocLayout = GetLayout();
434 	while ( pPage )
435 	{
436 		const SwFrm *pFlow = pPage->FindFirstBodyCntnt();
437 		if ( pFlow )
438 		{
439 			if ( pFlow->IsInTab() )
440 				pFlow = pFlow->FindTabFrm();
441 			const SwFmtPageDesc& rPgDesc = pFlow->GetAttrSet()->GetPageDesc();
442 			if ( rPgDesc.GetNumOffset() )
443 			{
444 				pDocLayout->SetVirtPageNum( sal_True );
445 				lcl_SetAPageOffset( nOffset, (SwPageFrm*)pPage, this );
446 				break;
447 			}
448 		}
449 		pPage = (SwPageFrm*)pPage->GetPrev();
450 	}
451 }
452 
453 sal_uInt16 SwFEShell::GetPageOffset() const
454 {
455 	const SwPageFrm *pPage = GetCurrFrm()->FindPageFrm();
456 	while ( pPage )
457 	{
458 		const SwFrm *pFlow = pPage->FindFirstBodyCntnt();
459 		if ( pFlow )
460 		{
461 			if ( pFlow->IsInTab() )
462 				pFlow = pFlow->FindTabFrm();
463 			const sal_uInt16 nOffset = pFlow->GetAttrSet()->GetPageDesc().GetNumOffset();
464 			if ( nOffset )
465 				return nOffset;
466 		}
467 		pPage = (SwPageFrm*)pPage->GetPrev();
468 	}
469 	return 0;
470 }
471 
472 /*************************************************************************
473 |*
474 |*	SwFEShell::InsertLabel()
475 |*
476 |*	Ersterstellung		MA 10. Feb. 94
477 |*	Letzte Aenderung	MA 10. Feb. 94
478 |*
479 *************************************************************************/
480 
481 void SwFEShell::InsertLabel( const SwLabelType eType, const String &rTxt, const String& rSeparator,
482                              const String& rNumberSeparator,
483 							 const sal_Bool bBefore, const sal_uInt16 nId,
484                              const String& rCharacterStyle,
485 							 const sal_Bool bCpyBrd )
486 {
487 	//NodeIndex der CrsrPosition besorgen, den Rest kann das Dokument
488 	//selbst erledigen.
489 	SwCntntFrm *pCnt = LTYPE_DRAW==eType ? 0 : GetCurrFrm( sal_False );
490 	if( LTYPE_DRAW==eType || pCnt )
491 	{
492 		StartAllAction();
493 
494 		sal_uLong nIdx = 0;
495 		SwFlyFrmFmt* pFlyFmt = 0;
496 		switch( eType )
497 		{
498 		case LTYPE_OBJECT:
499 		case LTYPE_FLY:
500 			if( pCnt->IsInFly() )
501 			{
502 				//Bei Flys den Index auf den StartNode herunterreichen.
503 				nIdx = pCnt->FindFlyFrm()->
504 							GetFmt()->GetCntnt().GetCntntIdx()->GetIndex();
505 //warum?? Bug 61913		ParkCrsr( GetCrsr()->GetPoint()->nNode );
506 			}
507 			break;
508 		case LTYPE_TABLE:
509 			if( pCnt->IsInTab() )
510 			{
511 				//Bei Tabellen den Index auf den TblNode herunterreichen.
512 				const SwTable& rTbl = *pCnt->FindTabFrm()->GetTable();
513 				nIdx = rTbl.GetTabSortBoxes()[ 0 ]
514 							->GetSttNd()->FindTableNode()->GetIndex();
515 			}
516 			break;
517 		case LTYPE_DRAW:
518 			if( Imp()->GetDrawView() )
519 			{
520 				SwDrawView *pDView = Imp()->GetDrawView();
521 				const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
522 				StartUndo();
523 
524                 // OD 27.11.2003 #112045# - copy marked drawing objects to
525                 // local list to perform the corresponding action for each object
526                 std::vector<SdrObject*> aDrawObjs;
527                 {
528                     for ( sal_uInt16 i = 0; i < rMrkList.GetMarkCount(); ++i )
529                     {
530                         SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
531                         if( pDrawObj )
532                         aDrawObjs.push_back( pDrawObj );
533                     }
534                 }
535                 // loop on marked drawing objects
536                 while ( !aDrawObjs.empty() )
537                 {
538                     SdrObject* pDrawObj = aDrawObjs.back();
539                     if ( !pDrawObj->ISA(SwVirtFlyDrawObj) &&
540                          !pDrawObj->ISA(SwFlyDrawObj) )
541                     {
542                         SwFlyFrmFmt *pFmt =
543                             GetDoc()->InsertDrawLabel( rTxt, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj );
544                         if( !pFlyFmt )
545                             pFlyFmt = pFmt;
546                     }
547 
548                     aDrawObjs.pop_back();
549                 }
550 
551 				EndUndo();
552 			}
553 			break;
554 		default:
555 			ASSERT( !this, "Crsr weder in Tabelle noch in Fly." );
556 		}
557 
558 		if( nIdx )
559             pFlyFmt = GetDoc()->InsertLabel( eType, rTxt, rSeparator, rNumberSeparator, bBefore, nId,
560                                              nIdx, rCharacterStyle, bCpyBrd );
561 
562         SwFlyFrm* pFrm;
563 		const Point aPt( GetCrsrDocPos() );
564 		if( pFlyFmt && 0 != ( pFrm = pFlyFmt->GetFrm( &aPt )))
565 			SelectFlyFrm( *pFrm, sal_True );
566 
567 		EndAllActionAndCall();
568 	}
569 }
570 
571 
572 /***********************************************************************
573 #*	Class		:  SwFEShell
574 #*	Methoden	:  Sort
575 #*	Datum		:  ??
576 #*	Update		:  ??
577 #***********************************************************************/
578 
579 sal_Bool SwFEShell::Sort(const SwSortOptions& rOpt)
580 {
581 	if( !HasSelection() )
582 		return sal_False;
583 
584 	SET_CURR_SHELL( this );
585 	sal_Bool bRet;
586 	StartAllAction();
587 	if(IsTableMode())
588 	{
589 		// Tabelle sortieren
590 		// pruefe ob vom aktuellen Crsr der SPoint/Mark in einer Tabelle stehen
591 		SwFrm *pFrm = GetCurrFrm( sal_False );
592 		ASSERT( pFrm->FindTabFrm(), "Crsr nicht in Tabelle." );
593 
594 		// lasse ueber das Layout die Boxen suchen
595 		SwSelBoxes	aBoxes;
596 		GetTblSel(*this, aBoxes);
597 
598 		// die Crsr muessen noch aus dem Loesch Bereich entfernt
599 		// werden. Setze sie immer hinter/auf die Tabelle; ueber die
600 		// Dokument-Position werden sie dann immer an die alte Position gesetzt.
601 		while( !pFrm->IsCellFrm() )
602 			pFrm = pFrm->GetUpper();
603 		{
604             /* #107993# ParkCursor->ParkCursorTab */
605 			ParkCursorInTab();
606 		}
607 
608 		// Sorting am Dokument aufrufen
609 		bRet = pDoc->SortTbl(aBoxes, rOpt);
610 	}
611 	else
612 	{
613 		// Text sortieren und nichts anderes
614 		FOREACHPAM_START(this)
615 
616 			SwPaM* pPam = PCURCRSR;
617 
618 			SwPosition* pStart = pPam->Start();
619 			SwPosition* pEnd   = pPam->End();
620 
621 			SwNodeIndex aPrevIdx( pStart->nNode, -1 );
622 			sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
623 			xub_StrLen nCntStt	= pStart->nContent.GetIndex();
624 
625 			// Das Sortieren
626 			bRet = pDoc->SortText(*pPam, rOpt);
627 
628 			// Selektion wieder setzen
629 			pPam->DeleteMark();
630 			pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
631 			SwCntntNode* pCNd = pPam->GetCntntNode();
632 			xub_StrLen nLen = pCNd->Len();
633 			if( nLen > nCntStt )
634 				nLen = nCntStt;
635 			pPam->GetPoint()->nContent.Assign(pCNd, nLen );
636 			pPam->SetMark();
637 
638 			pPam->GetPoint()->nNode += nOffset;
639 			pCNd = pPam->GetCntntNode();
640 			pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
641 
642 		FOREACHPAM_END()
643 	}
644 
645 	EndAllAction();
646 	return bRet;
647 }
648 
649 /*************************************************************************
650 |*
651 |*	SwFEShell::GetCurColNum(), _GetColNum()
652 |*
653 |*	Ersterstellung		MA 03. Feb. 95
654 |*	Letzte Aenderung	MA 20. Apr. 95
655 |
656 |*************************************************************************/
657 
658 sal_uInt16 SwFEShell::_GetCurColNum( const SwFrm *pFrm,
659 								SwGetCurColNumPara* pPara ) const
660 {
661 	sal_uInt16 nRet = 0;
662 	while ( pFrm )
663 	{
664 		pFrm = pFrm->GetUpper();
665 		if( pFrm && pFrm->IsColumnFrm() )
666 		{
667 			const SwFrm *pCurFrm = pFrm;
668 			do {
669 				++nRet;
670 				pFrm = pFrm->GetPrev();
671 			} while ( pFrm );
672 
673 			if( pPara )
674 			{
675 				// dann suche mal das Format, was diese Spaltigkeit bestimmt
676 				pFrm = pCurFrm->GetUpper();
677 				while( pFrm )
678 				{
679 					if( ( FRM_PAGE | FRM_FLY | FRM_SECTION ) & pFrm->GetType() )
680 					{
681 						pPara->pFrmFmt = ((SwLayoutFrm*)pFrm)->GetFmt();
682 						pPara->pPrtRect = &pFrm->Prt();
683 						pPara->pFrmRect = &pFrm->Frm();
684 						break;
685 					}
686 					pFrm = pFrm->GetUpper();
687 				}
688 				if( !pFrm )
689 				{
690 					pPara->pFrmFmt = 0;
691 					pPara->pPrtRect = 0;
692 					pPara->pFrmRect = 0;
693 				}
694 			}
695 			break;
696 		}
697 	}
698 	return nRet;
699 }
700 
701 sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
702 {
703 	ASSERT( GetCurrFrm(), "Crsr geparkt?" );
704 	return _GetCurColNum( GetCurrFrm(), pPara );
705 }
706 
707 sal_uInt16 SwFEShell::GetCurOutColNum( SwGetCurColNumPara* pPara ) const
708 {
709 	sal_uInt16 nRet = 0;
710 	SwFrm* pFrm = GetCurrFrm();
711 	ASSERT( pFrm, "Crsr geparkt?" );
712 	if( pFrm )
713 	{
714 		pFrm = pFrm->IsInTab() ? (SwFrm*)pFrm->FindTabFrm()
715 							   : (SwFrm*)pFrm->FindSctFrm();
716 		ASSERT( pFrm, "No Tab, no Sect" );
717 		if( pFrm )
718 			nRet = _GetCurColNum( pFrm, pPara );
719 	}
720 	return nRet;
721 }
722 
723 SwFEShell::SwFEShell( SwDoc& rDoc, Window *pWindow, const SwViewOption *pOptions )
724     : SwEditShell( rDoc, pWindow, pOptions ),
725 	pChainFrom( 0 ), pChainTo( 0 ), bCheckForOLEInCaption( sal_False )
726 {
727 }
728 
729 SwFEShell::SwFEShell( SwEditShell& rShell, Window *pWindow )
730     : SwEditShell( rShell, pWindow ),
731 	pChainFrom( 0 ), pChainTo( 0 ), bCheckForOLEInCaption( sal_False )
732 {
733 }
734 
735 SwFEShell::~SwFEShell()
736 {
737 	delete pChainFrom;
738 	delete pChainTo;
739 }
740 
741 // OD 18.09.2003 #i17567#, #108749#, #110354# - adjustments for allowing
742 //          negative vertical positions for fly frames anchored to paragraph/to character.
743 // OD 06.11.2003 #i22305# - adjustments for option 'Follow text flow'
744 //          for to frame anchored objects.
745 // OD 12.11.2003 #i22341# - adjustments for vertical alignment at top of line
746 //          for to character anchored objects.
747 void SwFEShell::CalcBoundRect( SwRect& _orRect,
748                                const RndStdIds _nAnchorId,
749                                const sal_Int16 _eHoriRelOrient,
750                                const sal_Int16 _eVertRelOrient,
751                                const SwPosition* _pToCharCntntPos,
752                                const bool _bFollowTextFlow,
753                                bool _bMirror,
754                                Point* _opRef,
755                                Size* _opPercent ) const
756 {
757     const SwFrm* pFrm;
758     const SwFlyFrm* pFly;
759     if( _opRef )
760 	{
761 		pFrm = GetCurrFrm();
762 		if( 0 != ( pFly = pFrm->FindFlyFrm() ) )
763             pFrm = pFly->GetAnchorFrm();
764 	}
765 	else
766 	{
767 		pFly = FindFlyFrm();
768         pFrm = pFly ? pFly->GetAnchorFrm() : GetCurrFrm();
769 	}
770 
771     sal_Bool bWrapThrough = sal_False;
772     if ( pFly )
773     {
774         SwFlyFrmFmt* pFmt = (SwFlyFrmFmt*)pFly->GetFmt();
775         const SwFmtSurround& rSurround = pFmt->GetSurround();
776         bWrapThrough = rSurround.GetSurround() == SURROUND_THROUGHT;
777     }
778 
779     const SwPageFrm* pPage = pFrm->FindPageFrm();
780     _bMirror = _bMirror && !pPage->OnRightPage();
781 
782 	Point aPos;
783     bool bVertic = false;
784     sal_Bool bRTL = sal_False;
785     // --> OD 2009-09-01 #mongolianlayout#
786     bool bVerticalL2R = false;
787     // <--
788 
789     if ((FLY_AT_PAGE == _nAnchorId) || (FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
790     {
791         const SwFrm* pTmp = pFrm;
792         // OD 06.11.2003 #i22305#
793         if ((FLY_AT_PAGE == _nAnchorId) ||
794             ((FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
795         {
796 			pFrm = pPage;
797         }
798 		else
799         {
800 			pFrm = pFrm->FindFlyFrm();
801         }
802         if ( !pFrm )
803 			pFrm = pTmp;
804         _orRect = pFrm->Frm();
805         SWRECTFN( pFrm )
806         bRTL = pFrm->IsRightToLeft();
807 		if ( bRTL )
808 			aPos = pFrm->Frm().TopRight();
809 		else
810 	        aPos = (pFrm->Frm().*fnRect->fnGetPos)();
811 
812         // --> OD 2009-09-01 #mongolianlayout#
813         if( bVert || bVertL2R )
814         // <--
815 		{
816             // --> OD 2009-09-01 #mongolianlayout#
817             bVertic = bVert ? true : false;
818             bVerticalL2R = bVertL2R ? true : false;
819             // <--
820             _bMirror = false; // no mirroring in vertical environment
821             switch ( _eHoriRelOrient )
822 			{
823                 case text::RelOrientation::PAGE_RIGHT:
824                 case text::RelOrientation::FRAME_RIGHT: aPos.Y() += pFrm->Prt().Height();
825                 // no break!
826                 case text::RelOrientation::PRINT_AREA:
827                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.Y() += pFrm->Prt().Top(); break;
828                 default: break;
829 			}
830 		}
831         else if ( _bMirror )
832 		{
833             switch ( _eHoriRelOrient )
834 			{
835                 case text::RelOrientation::PRINT_AREA:
836                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Width();
837 				// kein break
838                 case text::RelOrientation::PAGE_RIGHT:
839                 case text::RelOrientation::FRAME_RIGHT: aPos.X() += pFrm->Prt().Left(); break;
840 				default: aPos.X() += pFrm->Frm().Width();
841 			}
842 		}
843         else if ( bRTL )
844         {
845             switch ( _eHoriRelOrient )
846             {
847                 case text::RelOrientation::PRINT_AREA:
848                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Width();
849                 // kein break!
850                 case text::RelOrientation::PAGE_LEFT:
851                 case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrm->Prt().Left() -
852 											   pFrm->Frm().Width(); break;
853                 default: break;
854             }
855         }
856         else
857         {
858             switch ( _eHoriRelOrient )
859 			{
860                 case text::RelOrientation::PAGE_RIGHT:
861                 case text::RelOrientation::FRAME_RIGHT:   aPos.X() += pFrm->Prt().Width();
862 				// kein break!
863                 case text::RelOrientation::PRINT_AREA:
864                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() += pFrm->Prt().Left(); break;
865                 default:break;
866 			}
867 		}
868         // --> OD 2009-09-01 #mongolianlayout#
869         if ( bVert && !bVertL2R )
870         // <--
871         {
872             switch ( _eVertRelOrient )
873             {
874                 case text::RelOrientation::PRINT_AREA:
875                 case text::RelOrientation::PAGE_PRINT_AREA:
876                 {
877                     aPos.X() -= pFrm->GetRightMargin();
878                 }
879                 break;
880             }
881         }
882         // --> OD 2009-09-01 #mongolianlayout#
883         else if ( bVertL2R )
884         {
885             switch ( _eVertRelOrient )
886             {
887                 case text::RelOrientation::PRINT_AREA:
888                 case text::RelOrientation::PAGE_PRINT_AREA:
889                 {
890                     aPos.X() += pFrm->GetLeftMargin();
891                 }
892                 break;
893             }
894         }
895         // <--
896         else
897         {
898             switch ( _eVertRelOrient )
899             {
900                 case text::RelOrientation::PRINT_AREA:
901                 case text::RelOrientation::PAGE_PRINT_AREA:
902                 {
903                     if ( pFrm->IsPageFrm() )
904                     {
905                         aPos.Y() =
906                             static_cast<const SwPageFrm*>(pFrm)->PrtWithoutHeaderAndFooter().Top();
907                     }
908                     else
909                     {
910                         aPos.Y() += pFrm->Prt().Top();
911                     }
912                 }
913                 break;
914             }
915         }
916         // <--
917         if ( _opPercent )
918             *_opPercent = pFrm->Prt().SSize();
919 	}
920 	else
921 	{
922         const SwFrm* pUpper = ( pFrm->IsPageFrm() || pFrm->IsFlyFrm() ) ?
923                               pFrm : pFrm->GetUpper();
924         SWRECTFN( pUpper );
925         if ( _opPercent )
926             *_opPercent = pUpper->Prt().SSize();
927 
928         bRTL = pFrm->IsRightToLeft();
929         if ( bRTL )
930             aPos = pFrm->Frm().TopRight();
931         else
932             aPos = (pFrm->Frm().*fnRect->fnGetPos)();
933         // OD 08.09.2003 #i17567#, #108749#, #110354# - allow negative positions
934         // for fly frames anchor to paragraph/to character.
935         if ((_nAnchorId == FLY_AT_PARA) || (_nAnchorId == FLY_AT_CHAR))
936         {
937             // The rectangle, the fly frame can be positioned in, is determined
938             // horizontally by the frame area of the horizontal environment
939             // and vertically by the printing area of the vertical environment,
940             // if the object follows the text flow, or by the frame area of the
941             // vertical environment, if the object doesn't follow the text flow.
942             // OD 29.10.2003 #113049# - new class <SwEnvironmentOfAnchoredObject>
943             objectpositioning::SwEnvironmentOfAnchoredObject aEnvOfObj(
944                                                             _bFollowTextFlow );
945             const SwLayoutFrm& rHoriEnvironLayFrm =
946                                 aEnvOfObj.GetHoriEnvironmentLayoutFrm( *pFrm );
947             const SwLayoutFrm& rVertEnvironLayFrm =
948                                 aEnvOfObj.GetVertEnvironmentLayoutFrm( *pFrm );
949             SwRect aHoriEnvironRect( rHoriEnvironLayFrm.Frm() );
950             SwRect aVertEnvironRect;
951             if ( _bFollowTextFlow )
952             {
953                 aVertEnvironRect = rVertEnvironLayFrm.Prt();
954                 aVertEnvironRect.Pos() += rVertEnvironLayFrm.Frm().Pos();
955                 // OD 19.09.2003 #i18732# - adjust vertical 'virtual' anchor position
956                 // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
957                 // to page areas.
958                 if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
959                 {
960                     // --> OD 2009-09-01 #mongolianlayout#
961                     if ( bVert && !bVertL2R )
962                     // <--
963                     {
964                         aPos.X() = aVertEnvironRect.Right();
965                     }
966                     // --> OD 2009-09-01 #mongolianlayout#
967                     else if ( bVertL2R )
968                     {
969                         aPos.X() = aVertEnvironRect.Left();
970                     }
971                     else
972                     {
973                         aPos.Y() = aVertEnvironRect.Top();
974                     }
975                 }
976             }
977             else
978             {
979                 ASSERT( rVertEnvironLayFrm.IsPageFrm(),
980                         "<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
981                 aVertEnvironRect = rVertEnvironLayFrm.Frm();
982                 // OD 19.09.2003 #i18732# - adjustment vertical 'virtual' anchor position
983                 // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
984                 // to page areas.
985                 if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
986                 {
987                     // --> OD 2009-09-01 #mongolianlayout#
988                     if ( bVert && !bVertL2R )
989                     // <--
990                     {
991                         aPos.X() = aVertEnvironRect.Right();
992                         if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
993                         {
994                             aPos.X() -= rVertEnvironLayFrm.GetRightMargin();
995                         }
996                     }
997                     // --> OD 2009-09-01 #mongolianlayout#
998                     else if ( bVertL2R )
999                     {
1000                         aPos.X() = aVertEnvironRect.Left();
1001                         if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
1002                         {
1003                             aPos.X() += rVertEnvironLayFrm.GetLeftMargin();
1004                         }
1005                     }
1006                     // <--
1007                     else
1008                     {
1009                         aPos.Y() = aVertEnvironRect.Top();
1010                         if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
1011                         {
1012                             aPos.Y() += rVertEnvironLayFrm.GetTopMargin();
1013                             // add height of page header
1014                             const SwFrm* pTmpFrm = rVertEnvironLayFrm.Lower();
1015                             if ( pTmpFrm->IsHeaderFrm() )
1016                             {
1017                                 aPos.Y() += pTmpFrm->Frm().Height();
1018                             }
1019                         }
1020                     }
1021                 }
1022             }
1023 
1024             // OD 12.11.2003 #i22341# - adjust vertical 'virtual' anchor position
1025             // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
1026             // character and vertical aligned at character or top of line
1027             // --> OD 2005-12-29 #125800#
1028             // <pFrm>, which is the anchor frame or the proposed anchor frame,
1029             // doesn't have to be a text frame (e.g. edit a to-page anchored
1030             // fly frame). Thus, assure this.
1031             const SwTxtFrm* pTxtFrm( dynamic_cast<const SwTxtFrm*>(pFrm) );
1032             if ( pTxtFrm &&
1033                  (_nAnchorId == FLY_AT_CHAR) &&
1034                  ( _eVertRelOrient == text::RelOrientation::CHAR ||
1035                    _eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
1036             {
1037                 SwTwips nTop = 0L;
1038                 if ( _eVertRelOrient == text::RelOrientation::CHAR )
1039                 {
1040                     SwRect aChRect;
1041                     if ( _pToCharCntntPos )
1042                     {
1043                         pTxtFrm->GetAutoPos( aChRect, *_pToCharCntntPos );
1044                     }
1045                     else
1046                     {
1047                         // No content position provided. Thus, use a default one.
1048                         SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
1049                         pTxtFrm->GetAutoPos( aChRect, aDefaultCntntPos );
1050                     }
1051                     nTop = (aChRect.*fnRect->fnGetBottom)();
1052                 }
1053                 else
1054                 {
1055                     if ( _pToCharCntntPos )
1056                     {
1057                         pTxtFrm->GetTopOfLine( nTop, *_pToCharCntntPos );
1058                     }
1059                     else
1060                     {
1061                         // No content position provided. Thus, use a default one.
1062                         SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
1063                         pTxtFrm->GetTopOfLine( nTop, aDefaultCntntPos );
1064                     }
1065                 }
1066                 // --> OD 2009-09-01 #mongolianlayout#
1067                 if ( bVert || bVertL2R )
1068                 {
1069                     aPos.X() = nTop;
1070                 }
1071                 // <--
1072                 else
1073                 {
1074                     aPos.Y() = nTop;
1075                 }
1076             }
1077 
1078             // --> OD 2004-10-05 #i26945# - adjust horizontal 'virtual' anchor
1079             // position (<aPos.X()> respectively <aPos.Y()>), if object is
1080             // anchored to character and horizontal aligned at character.
1081             if ( pTxtFrm &&
1082                  (_nAnchorId == FLY_AT_CHAR) &&
1083                  _eHoriRelOrient == text::RelOrientation::CHAR )
1084             {
1085                 SwTwips nLeft = 0L;
1086                 SwRect aChRect;
1087                 if ( _pToCharCntntPos )
1088                 {
1089                     pTxtFrm->GetAutoPos( aChRect, *_pToCharCntntPos );
1090                 }
1091                 else
1092                 {
1093                     // No content position provided. Thus, use a default one.
1094                     SwPosition aDefaultCntntPos( *(pTxtFrm->GetTxtNode()) );
1095                     pTxtFrm->GetAutoPos( aChRect, aDefaultCntntPos );
1096                 }
1097                 nLeft = (aChRect.*fnRect->fnGetLeft)();
1098                 // --> OD 2009-09-01 #mongolianlayout#
1099                 if ( bVert || bVertL2R )
1100                 {
1101                     aPos.Y() = nLeft;
1102                 }
1103                 // <--
1104                 else
1105                 {
1106                     aPos.X() = nLeft;
1107                 }
1108             }
1109             // <--
1110 
1111             // --> OD 2009-09-01 #mongolianlayout#
1112             if ( bVert || bVertL2R )
1113             // <--
1114             {
1115                 _orRect = SwRect( aVertEnvironRect.Left(),
1116                                   aHoriEnvironRect.Top(),
1117                                   aVertEnvironRect.Width(),
1118                                   aHoriEnvironRect.Height() );
1119             }
1120             else
1121             {
1122                 _orRect = SwRect( aHoriEnvironRect.Left(),
1123                                   aVertEnvironRect.Top(),
1124                                   aHoriEnvironRect.Width(),
1125                                   aVertEnvironRect.Height() );
1126             }
1127         }
1128         else
1129         {
1130             if( _opRef && pFly && pFly->IsFlyInCntFrm() )
1131                 *_opRef = ( (SwFlyInCntFrm*)pFly )->GetRefPoint();
1132 
1133             _orRect = pUpper->Frm();
1134             if( !pUpper->IsBodyFrm() )
1135             {
1136                 _orRect += pUpper->Prt().Pos();
1137                 _orRect.SSize( pUpper->Prt().SSize() );
1138                 if ( pUpper->IsCellFrm() )//MA_FLY_HEIGHT
1139                 {
1140                     const SwFrm* pTab = pUpper->FindTabFrm();
1141                     long nBottom = (pTab->GetUpper()->*fnRect->fnGetPrtBottom)();
1142                     (_orRect.*fnRect->fnSetBottom)( nBottom );
1143                 }
1144             }
1145             // bei zeichengebundenen lieber nur 90% der Hoehe ausnutzen
1146             {
1147                 // --> OD 2009-09-01 #mongolianlayout#
1148                 if( bVert || bVertL2R )
1149                 // <--
1150                     _orRect.Width( (_orRect.Width()*9)/10 );
1151                 else
1152                     _orRect.Height( (_orRect.Height()*9)/10 );
1153             }
1154         }
1155 
1156         const SwTwips nBaseOfstForFly = ( pFrm->IsTxtFrm() && pFly ) ?
1157                                         ((SwTxtFrm*)pFrm)->GetBaseOfstForFly( !bWrapThrough ) :
1158                                          0;
1159         // --> OD 2009-09-01 #mongolianlayout#
1160         if( bVert || bVertL2R )
1161         // <--
1162 		{
1163             // --> OD 2009-09-01 #mongolianlayout#
1164             bVertic = bVert ? true : false;
1165             bVerticalL2R = bVertL2R ? true : false;
1166             // <--
1167             _bMirror = false;
1168 
1169             switch ( _eHoriRelOrient )
1170 			{
1171                 case text::RelOrientation::FRAME_RIGHT:
1172                 {
1173                     aPos.Y() += pFrm->Prt().Height();
1174                     aPos += (pFrm->Prt().*fnRect->fnGetPos)();
1175                     break;
1176                 }
1177                 case text::RelOrientation::PRINT_AREA:
1178                 {
1179                     aPos += (pFrm->Prt().*fnRect->fnGetPos)();
1180                     aPos.Y() += nBaseOfstForFly;
1181                     break;
1182                 }
1183                 case text::RelOrientation::PAGE_RIGHT:
1184                 {
1185                     aPos.Y() = pPage->Frm().Top() + pPage->Prt().Bottom();
1186                     break;
1187                 }
1188                 case text::RelOrientation::PAGE_PRINT_AREA:
1189                 {
1190                     aPos.Y() = pPage->Frm().Top() + pPage->Prt().Top();
1191                     break;
1192                 }
1193                 case text::RelOrientation::PAGE_LEFT:
1194                 case text::RelOrientation::PAGE_FRAME:
1195                 {
1196                     aPos.Y() = pPage->Frm().Top();
1197                     break;
1198                 }
1199                 case text::RelOrientation::FRAME:
1200                 {
1201                     aPos.Y() += nBaseOfstForFly;
1202                     break;
1203                 }
1204                 default: break;
1205 			}
1206 		}
1207         else if( _bMirror )
1208 		{
1209             switch ( _eHoriRelOrient )
1210 			{
1211                 case text::RelOrientation::FRAME_RIGHT:   aPos.X() += pFrm->Prt().Left(); break;
1212                 case text::RelOrientation::FRAME:
1213                 case text::RelOrientation::FRAME_LEFT: aPos.X() += pFrm->Frm().Width(); break;
1214                 case text::RelOrientation::PRINT_AREA: aPos.X() += pFrm->Prt().Right(); break;
1215                 case text::RelOrientation::PAGE_LEFT:
1216                 case text::RelOrientation::PAGE_FRAME: aPos.X() = pPage->Frm().Right(); break;
1217                 case text::RelOrientation::PAGE_PRINT_AREA: aPos.X() = pPage->Frm().Left()
1218 											  + pPage->Prt().Left(); break;
1219                 default: break;
1220             }
1221 		}
1222         else if ( bRTL )
1223         {
1224             switch ( _eHoriRelOrient )
1225             {
1226                 case text::RelOrientation::FRAME_LEFT:
1227                     aPos.X() = pFrm->Frm().Left() +
1228                                pFrm->Prt().Left();
1229                     break;
1230 
1231                 case text::RelOrientation::PRINT_AREA:
1232                     aPos.X() = pFrm->Frm().Left() + pFrm->Prt().Left() +
1233                                pFrm->Prt().Width();
1234                     aPos.X() += nBaseOfstForFly;
1235                     break;
1236 
1237                 case text::RelOrientation::PAGE_LEFT:
1238                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Left();
1239                     break;
1240 
1241                 case text::RelOrientation::PAGE_PRINT_AREA:
1242                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Left() +
1243                                pPage->Prt().Width() ;
1244                     break;
1245 
1246                 case text::RelOrientation::PAGE_RIGHT:
1247                 case text::RelOrientation::PAGE_FRAME:
1248                     aPos.X() = pPage->Frm().Right();
1249                     break;
1250 
1251                 case text::RelOrientation::FRAME:
1252                     aPos.X() += nBaseOfstForFly;
1253                     break;
1254                 default: break;
1255             }
1256         }
1257 		else
1258 		{
1259             switch ( _eHoriRelOrient )
1260 			{
1261                 case text::RelOrientation::FRAME_RIGHT:
1262                     aPos.X() += pFrm->Prt().Width();
1263                     aPos += pFrm->Prt().Pos();
1264                     break;
1265                 case text::RelOrientation::PRINT_AREA:
1266                     aPos += pFrm->Prt().Pos();
1267                     aPos.X() += nBaseOfstForFly;
1268                     break;
1269                 case text::RelOrientation::PAGE_RIGHT:
1270                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Right();
1271                     break;
1272                 case text::RelOrientation::PAGE_PRINT_AREA:
1273                     aPos.X() = pPage->Frm().Left() + pPage->Prt().Left();
1274                     break;
1275                 case text::RelOrientation::PAGE_LEFT:
1276                 case text::RelOrientation::PAGE_FRAME:
1277                     aPos.X() = pPage->Frm().Left();
1278                     break;
1279                 case text::RelOrientation::FRAME:
1280                     aPos.X() += nBaseOfstForFly;
1281                     break;
1282                 default: break;
1283             }
1284 		}
1285 
1286 	}
1287     if( !_opRef )
1288 	{
1289         if( bVertic && !bVerticalL2R )
1290             _orRect.Pos( aPos.X() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.Y() );
1291         // --> OD 2009-09-01 #mongolianlayout#
1292         else if( bVerticalL2R )
1293             _orRect.Pos( _orRect.Left() - aPos.X(), _orRect.Top() - aPos.Y() );
1294         // <--
1295         else if ( bRTL )
1296             _orRect.Pos( - ( _orRect.Right() - aPos.X() ), _orRect.Top() - aPos.Y() );
1297 		else
1298             _orRect.Pos( _orRect.Left() - aPos.X(), _orRect.Top() - aPos.Y() );
1299         if( _bMirror )
1300             _orRect.Pos( -_orRect.Right(), _orRect.Top() );
1301 	}
1302 }
1303 
1304 Size SwFEShell::GetGraphicDefaultSize() const
1305 {
1306 	Size aRet;
1307 	SwFlyFrm *pFly = FindFlyFrm();
1308 	if ( pFly )
1309 	{
1310         // --> OD 2004-09-24 #i32951# - due to issue #i28701# no format of a
1311         // newly inserted Writer fly frame or its anchor frame is performed
1312         // any more. Thus, it could be possible (e.g. on insert of a horizontal
1313         // line) that the anchor frame isn't formatted and its printing area
1314         // size is (0,0). If this is the case the printing area of the upper
1315         // of the anchor frame is taken.
1316         const SwFrm* pAnchorFrm = pFly->GetAnchorFrm();
1317         aRet = pAnchorFrm->Prt().SSize();
1318         if ( aRet.Width() == 0 && aRet.Height() == 0 &&
1319              pAnchorFrm->GetUpper() )
1320         {
1321             aRet = pAnchorFrm->GetUpper()->Prt().SSize();
1322         }
1323         // <--
1324 
1325 		SwRect aBound;
1326 		CalcBoundRect( aBound, pFly->GetFmt()->GetAnchor().GetAnchorId());
1327         if ( pFly->GetAnchorFrm()->IsVertical() )
1328 			aRet.Width() = aBound.Width();
1329 		else
1330 			aRet.Height() = aBound.Height();
1331 	}
1332 	return aRet;
1333 }
1334 /* -----------------------------12.08.2002 12:51------------------------------
1335 
1336  ---------------------------------------------------------------------------*/
1337 // --> OD 2009-08-31 #mongolianlayou#
1338 // add output parameter <bVertL2R>
1339 sal_Bool SwFEShell::IsFrmVertical(const sal_Bool bEnvironment, sal_Bool& bRTL, sal_Bool& bVertL2R) const
1340 {
1341     sal_Bool bVert = sal_False;
1342     bRTL = sal_False;
1343     bVertL2R = sal_False;
1344 
1345     if ( Imp()->HasDrawView() )
1346     {
1347         const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1348         if( rMrkList.GetMarkCount() != 1 )
1349             return bVert;
1350 
1351         SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1352         // --> OD 2006-01-06 #123831# - make code robust:
1353         if ( !pObj )
1354         {
1355             ASSERT( false,
1356                     "<SwFEShell::IsFrmVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation, please inform OD" );
1357             return bVert;
1358         }
1359         // <--
1360         // OD 2004-03-29 #i26791#
1361         SwContact* pContact = static_cast<SwContact*>(GetUserCall( pObj ));
1362         // --> OD 2006-01-06 #123831# - make code robust:
1363         if ( !pContact )
1364         {
1365             ASSERT( false,
1366                     "<SwFEShell::IsFrmVertical(..)> - missing SwContact instance at marked object -> This is a serious situation, please inform OD" );
1367             return bVert;
1368         }
1369         // <--
1370         const SwFrm* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrm();
1371         // --> OD 2006-01-06 #123831# - make code robust:
1372         if ( !pRef )
1373         {
1374             ASSERT( false,
1375                     "<SwFEShell::IsFrmVertical(..)> - missing anchor frame at marked object -> This is a serious situation, please inform OD" );
1376             return bVert;
1377         }
1378         // <--
1379 
1380         if ( pObj->ISA(SwVirtFlyDrawObj) && !bEnvironment )
1381             pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrm();
1382 
1383         bVert = pRef->IsVertical();
1384         bRTL = pRef->IsRightToLeft();
1385         bVertL2R = pRef->IsVertLR();
1386     }
1387 
1388     return bVert;
1389 }
1390 // <--
1391 
1392 void SwFEShell::MoveObjectIfActive( svt::EmbeddedObjectRef&, const Point& )
1393 {
1394     // does not do anything, only avoids crash if the method is used for wrong shell
1395 }
1396 
1397