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