LibreOffice Module sw (master)  1
fews.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <svx/svdobj.hxx>
21 #include <osl/diagnose.h>
22 #include <comphelper/lok.hxx>
23 #include <init.hxx>
24 #include <fesh.hxx>
25 #include <tabcol.hxx>
26 #include <pagefrm.hxx>
27 #include <rootfrm.hxx>
28 #include <cntfrm.hxx>
29 #include <doc.hxx>
30 #include <frmtool.hxx>
31 #include <swtable.hxx>
32 #include <viewimp.hxx>
33 #include <dview.hxx>
34 #include <flyfrm.hxx>
35 #include <node.hxx>
36 #include <pam.hxx>
37 #include <sectfrm.hxx>
38 #include <fmtpdsc.hxx>
39 #include <fmtsrnd.hxx>
40 #include <fmtcntnt.hxx>
41 #include <fmtfsize.hxx>
42 #include <tabfrm.hxx>
43 #include <flyfrms.hxx>
44 #include <txtfrm.hxx>
45 #include <mdiexp.hxx>
46 #include <pagedesc.hxx>
47 #include <fmtanchr.hxx>
49 #include <ndtxt.hxx>
50 #include <dflyobj.hxx>
51 #include <dcontact.hxx>
52 #include <UndoInsert.hxx>
53 
54 using namespace com::sun::star;
55 
56 namespace
57 {
62 osl::Mutex& GetPasteMutex()
63 {
64  static osl::Mutex aMutex;
65  return aMutex;
66 }
67 }
68 
70 {
71  for(SwViewShell& rCurrentShell : GetRingContainer())
72  {
73  if( dynamic_cast<const SwCursorShell*>( &rCurrentShell) != nullptr )
74  {
75  static_cast<SwFEShell*>(&rCurrentShell)->EndAction();
76  static_cast<SwFEShell*>(&rCurrentShell)->CallChgLnk();
77  }
78  else
79  rCurrentShell.EndAction();
80  }
81 }
82 
83 // Determine the Content's nearest to the point
84 Point SwFEShell::GetContentPos( const Point& rPoint, bool bNext ) const
85 {
86  CurrShell aCurr( const_cast<SwFEShell*>(this) );
87  return GetLayout()->GetNextPrevContentPos( rPoint, bNext );
88 }
89 
90 const SwRect& SwFEShell::GetAnyCurRect( CurRectType eType, const Point* pPt,
91  const uno::Reference < embed::XEmbeddedObject >& xObj ) const
92 {
93  const SwFrame *pFrame = Imp()->HasDrawView()
94  ? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
95  const_cast<SwFEShell*>(this))
96  : nullptr;
97 
98  if( !pFrame )
99  {
100  if( pPt )
101  {
102  SwPosition aPos( *GetCursor()->GetPoint() );
103  Point aPt( *pPt );
104  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
105  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
106  std::pair<Point, bool> const tmp(*pPt, true);
107  pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
108  }
109  else
110  {
111  const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
112  if( bOldCallbackActionEnabled )
113  GetLayout()->SetCallbackActionEnabled( false );
114  pFrame = GetCurrFrame();
115  if( bOldCallbackActionEnabled )
116  GetLayout()->SetCallbackActionEnabled( true );
117  }
118  }
119 
120  if( !pFrame )
121  return GetLayout()->getFrameArea();
122 
123  bool bFrame = true;
124  switch ( eType )
125  {
126  case CurRectType::PagePrt: bFrame = false;
127  [[fallthrough]];
128  case CurRectType::Page : pFrame = pFrame->FindPageFrame();
129  break;
130 
132  {
133  DisableCallbackAction a(const_cast<SwRootFrame&>(*pFrame->getRootFrame()));
134  pFrame->Calc(Imp()->GetShell()->GetOut());
135  pFrame = pFrame->FindPageFrame();
136  pFrame->Calc(Imp()->GetShell()->GetOut());
137  }
138  break;
139 
141  bFrame = false;
142  [[fallthrough]];
144  {
145  const SwFrame *pFlyFrame = xObj.is() ? FindFlyFrame(xObj) : nullptr;
146  pFrame = pFlyFrame ? pFlyFrame
147  : pFrame->IsFlyFrame()
148  ? pFrame
149  : pFrame->FindFlyFrame();
150  break;
151  }
153  if( pFrame->IsInTab() )
154  pFrame = pFrame->FindTabFrame();
155  else {
156  OSL_FAIL( "Missing Table" );
157  }
158  [[fallthrough]];
161  if( pFrame->IsInSct() )
162  pFrame = pFrame->FindSctFrame();
163  else {
164  OSL_FAIL( "Missing section" );
165  }
166 
167  if( CurRectType::SectionPrt == eType )
168  bFrame = false;
169  break;
170 
172  pFrame = pFrame->FindFooterOrHeader();
173  if( nullptr == pFrame )
174  return GetLayout()->getFrameArea();
175  break;
176 
178  return GetLayout()->GetPagesArea();
179 
180  default: break;
181  }
182  return bFrame ? pFrame->getFrameArea() : pFrame->getFramePrintArea();
183 }
184 
185 sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const
186 {
187  const SwFrame *pPage = GetLayout()->Lower();
188  while ( pPage && !pPage->getFrameArea().IsInside( rPoint ) )
189  pPage = pPage->GetNext();
190  if ( pPage )
191  return static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum();
192  else
193  return 0;
194 }
195 
196 bool SwFEShell::GetPageNumber( tools::Long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay) const
197 {
198  const SwFrame *pPage;
199 
200  if ( bAtCursorPos ) // get page of Cursor
201  {
202  pPage = GetCurrFrame( false );
203  if ( pPage )
204  pPage = pPage->FindPageFrame();
205  }
206  else if ( nYPos > -1 ) // determine page via the position
207  {
208  pPage = GetLayout()->Lower();
209  while( pPage && (pPage->getFrameArea().Bottom() < nYPos ||
210  nYPos < pPage->getFrameArea().Top() ) )
211  pPage = pPage->GetNext();
212  }
213  else // first visible page
214  {
215  pPage = Imp()->GetFirstVisPage(GetOut());
216  if ( pPage && static_cast<const SwPageFrame*>(pPage)->IsEmptyPage() )
217  pPage = pPage->GetNext();
218  }
219 
220  if( pPage )
221  {
222  rPhyNum = static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum();
223  rVirtNum = static_cast<const SwPageFrame*>(pPage)->GetVirtPageNum();
224  const SvxNumberType& rNum = static_cast<const SwPageFrame*>(pPage)->GetPageDesc()->GetNumType();
225  rDisplay = rNum.GetNumStr( rVirtNum );
226  }
227 
228  return nullptr != pPage;
229 }
230 
232 {
233  SwFrame* pFrame = GetCurrFrame( false );
234  return pFrame && pFrame->GetUpper() && pFrame->GetUpper()->IsSctFrame();
235 }
236 
237 FrameTypeFlags SwFEShell::GetFrameType( const Point *pPt, bool bStopAtFly ) const
238 {
240  const SwFrame *pFrame;
241  if ( pPt )
242  {
243  SwPosition aPos( *GetCursor()->GetPoint() );
244  Point aPt( *pPt );
245  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
246  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
247  std::pair<Point, bool> const tmp(*pPt, true);
248  pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
249  }
250  else
251  pFrame = GetCurrFrame( false );
252  while ( pFrame )
253  {
254  switch ( pFrame->GetType() )
255  {
256  case SwFrameType::Column:
257  if( pFrame->GetUpper()->IsSctFrame() )
258  {
259  // Check, if isn't not only a single column
260  // from a section with footnotes at the end.
261  if( pFrame->GetNext() || pFrame->GetPrev() )
262  // Sectioncolumns
263  nReturn |= ( nReturn & FrameTypeFlags::TABLE ) ?
265  }
266  else // only pages and frame columns
267  nReturn |= FrameTypeFlags::COLUMN;
268  break;
269  case SwFrameType::Page:
270  nReturn |= FrameTypeFlags::PAGE;
271  if( static_cast<const SwPageFrame*>(pFrame)->IsFootnotePage() )
272  nReturn |= FrameTypeFlags::FTNPAGE;
273  break;
274  case SwFrameType::Header: nReturn |= FrameTypeFlags::HEADER; break;
275  case SwFrameType::Footer: nReturn |= FrameTypeFlags::FOOTER; break;
276  case SwFrameType::Body:
277  if( pFrame->GetUpper()->IsPageFrame() ) // not for ColumnFrames
278  nReturn |= FrameTypeFlags::BODY;
279  break;
280  case SwFrameType::Ftn: nReturn |= FrameTypeFlags::FOOTNOTE; break;
281  case SwFrameType::Fly:
282  if( static_cast<const SwFlyFrame*>(pFrame)->IsFlyLayFrame() )
283  nReturn |= FrameTypeFlags::FLY_FREE;
284  else if ( static_cast<const SwFlyFrame*>(pFrame)->IsFlyAtContentFrame() )
285  nReturn |= FrameTypeFlags::FLY_ATCNT;
286  else
287  {
288  OSL_ENSURE( static_cast<const SwFlyFrame*>(pFrame)->IsFlyInContentFrame(),
289  "New frametype?" );
290  nReturn |= FrameTypeFlags::FLY_INCNT;
291  }
292  nReturn |= FrameTypeFlags::FLY_ANY;
293  if( bStopAtFly )
294  return nReturn;
295  break;
296  case SwFrameType::Tab:
297  case SwFrameType::Row:
298  case SwFrameType::Cell: nReturn |= FrameTypeFlags::TABLE; break;
299  default: /* do nothing */ break;
300  }
301  if ( pFrame->IsFlyFrame() )
302  pFrame = static_cast<const SwFlyFrame*>(pFrame)->GetAnchorFrame();
303  else
304  pFrame = pFrame->GetUpper();
305  }
306  return nReturn;
307 }
308 
310 {
311  ::SetShell( this );
313 
314  if ( HasDrawView() )
315  {
317  Imp()->GetDrawView()->showMarkHandles();
318  if ( Imp()->GetDrawView()->AreObjectsMarked() )
319  FrameNotify( this, FLY_DRAG_START );
320  }
321 }
322 
324 {
326 
327  if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
328  {
330  Imp()->GetDrawView()->hideMarkHandles();
331  FrameNotify( this, FLY_DRAG_END );
332  }
333 }
334 
335 sal_uInt16 SwFEShell::GetPhyPageNum() const
336 {
337  SwFrame *pFrame = GetCurrFrame();
338  if ( pFrame )
339  return pFrame->GetPhyPageNum();
340  return 0;
341 }
342 
343 sal_uInt16 SwFEShell::GetVirtPageNum() const
344 {
345  SwFrame *pFrame = GetCurrFrame();
346  if ( pFrame )
347  return pFrame->GetVirtPageNum();
348  return 0;
349 }
350 
351 static void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrame* pPage, SwFEShell* pThis )
352 {
353  pThis->StartAllAction();
354  OSL_ENSURE( pPage->FindFirstBodyContent(),
355  "SwFEShell _SetAPageOffset() without ContentFrame" );
356 
357  SwFormatPageDesc aDesc( pPage->GetPageDesc() );
358  aDesc.SetNumOffset( nOffset );
359 
360  SwFrame *pFrame = pThis->GetCurrFrame( false );
361  if ( pFrame->IsInTab() )
362  pThis->GetDoc()->SetAttr( aDesc, *pFrame->FindTabFrame()->GetFormat() );
363  else
364  {
366  *pThis->GetCursor(), aDesc, SetAttrMode::DEFAULT, pThis->GetLayout());
367  }
368 
369  pThis->EndAllAction();
370 }
371 
372 void SwFEShell::SetNewPageOffset( sal_uInt16 nOffset )
373 {
374  GetLayout()->SetVirtPageNum( true );
375  const SwPageFrame *pPage = GetCurrFrame( false )->FindPageFrame();
376  lcl_SetAPageOffset( nOffset, const_cast<SwPageFrame*>(pPage), this );
377 }
378 
379 void SwFEShell::SetPageOffset( sal_uInt16 nOffset )
380 {
381  const SwPageFrame *pPage = GetCurrFrame( false )->FindPageFrame();
382  const SwRootFrame* pDocLayout = GetLayout();
383  while ( pPage )
384  {
385  const SwFrame *pFlow = pPage->FindFirstBodyContent();
386  if ( pFlow )
387  {
388  if ( pFlow->IsInTab() )
389  pFlow = pFlow->FindTabFrame();
390  const SwFormatPageDesc& rPgDesc = pFlow->GetPageDescItem();
391  if ( rPgDesc.GetNumOffset() )
392  {
393  pDocLayout->SetVirtPageNum( true );
394  lcl_SetAPageOffset( nOffset, const_cast<SwPageFrame*>(pPage), this );
395  break;
396  }
397  }
398  pPage = static_cast<const SwPageFrame*>(pPage->GetPrev());
399  }
400 }
401 
402 sal_uInt16 SwFEShell::GetPageOffset() const
403 {
404  const SwPageFrame *pPage = GetCurrFrame()->FindPageFrame();
405  while ( pPage )
406  {
407  const SwFrame *pFlow = pPage->FindFirstBodyContent();
408  if ( pFlow )
409  {
410  if ( pFlow->IsInTab() )
411  pFlow = pFlow->FindTabFrame();
412  ::std::optional<sal_uInt16> oNumOffset = pFlow->GetPageDescItem().GetNumOffset();
413  if ( oNumOffset )
414  return *oNumOffset;
415  }
416  pPage = static_cast<const SwPageFrame*>(pPage->GetPrev());
417  }
418  return 0;
419 }
420 
421 void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, const OUString& rSeparator,
422  const OUString& rNumberSeparator,
423  const bool bBefore, const sal_uInt16 nId,
424  const OUString& rCharacterStyle,
425  const bool bCpyBrd )
426 {
427  // get node index of cursor position, SwDoc can do everything else itself
428  SwContentFrame *pCnt = SwLabelType::Draw==eType ? nullptr : GetCurrFrame( false );
429  if( SwLabelType::Draw!=eType && !pCnt )
430  return;
431 
432  StartAllAction();
434  StartUndo(SwUndoId::INSERTLABEL, &aRewriter);
435 
436  sal_uLong nIdx = 0;
437  bool bInnerCntIsFly = false;
438  SwFlyFrameFormat* pFlyFormat = nullptr;
439  switch( eType )
440  {
441  case SwLabelType::Object:
442  case SwLabelType::Fly:
443  bInnerCntIsFly = pCnt->IsInFly();
444  if (bInnerCntIsFly)
445  {
446  // pass down index to the startnode for flys
447  nIdx = pCnt->FindFlyFrame()->
448  GetFormat()->GetContent().GetContentIdx()->GetIndex();
449  }
450  break;
451  case SwLabelType::Table:
452  if( pCnt->IsInTab() )
453  {
454  // pass down index to the TableNode for tables
455  const SwTable& rTable = *pCnt->FindTabFrame()->GetTable();
456  nIdx = rTable.GetTabSortBoxes()[ 0 ]
457  ->GetSttNd()->FindTableNode()->GetIndex();
458  }
459  break;
460  case SwLabelType::Draw:
461  if( Imp()->GetDrawView() )
462  {
463  SwDrawView *pDView = Imp()->GetDrawView();
464  const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
465 
466  // copy marked drawing objects to
467  // local list to perform the corresponding action for each object
468  std::vector<SdrObject*> aDrawObjs;
469  {
470  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
471  {
472  SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
473  if( pDrawObj )
474  aDrawObjs.push_back( pDrawObj );
475  }
476  }
477  // loop on marked drawing objects
478  while ( !aDrawObjs.empty() )
479  {
480  SdrObject* pDrawObj = aDrawObjs.back();
481  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pDrawObj) == nullptr &&
482  dynamic_cast<const SwFlyDrawObj*>( pDrawObj) == nullptr )
483  {
484  SwFlyFrameFormat *pFormat =
485  GetDoc()->InsertDrawLabel( rText, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj );
486  if( !pFlyFormat )
487  pFlyFormat = pFormat;
488  }
489 
490  aDrawObjs.pop_back();
491  }
492 
493  }
494  break;
495  default:
496  OSL_ENSURE( false, "Cursor neither in table nor in fly." );
497  }
498 
499  if( nIdx )
500  {
501  pFlyFormat = GetDoc()->InsertLabel(eType, rText, rSeparator,
502  rNumberSeparator, bBefore, nId,
503  nIdx, rCharacterStyle, bCpyBrd);
504  }
505 
506  if (pFlyFormat)
507  {
508  const Point aPt(GetCursorDocPos());
509  if (SwFlyFrame* pFrame = pFlyFormat->GetFrame(&aPt))
510  SelectFlyFrame(*pFrame);
511  }
512  EndUndo();
513  EndAllActionAndCall();
514 
515 }
516 
518 {
519  if( !HasSelection() )
520  return false;
521 
522  CurrShell aCurr( this );
523  bool bRet = false;
524  StartAllAction();
525  if(IsTableMode())
526  {
527  // Sort table
528  // check if Point/Mark of current Cursor are in one table
529  SwFrame *pFrame = GetCurrFrame( false );
530  OSL_ENSURE( pFrame->FindTabFrame(), "Cursor not in table." );
531 
532  // search boxes via the layout
533  SwSelBoxes aBoxes;
534  GetTableSel(*this, aBoxes);
535 
536  // The Cursor should be removed from the deletion area.
537  // Always put them behind/on the table; via the
538  // document position they will always be set to the old position
539  while( !pFrame->IsCellFrame() )
540  pFrame = pFrame->GetUpper();
541  {
542  /* ParkCursor->ParkCursorTab */
543  ParkCursorInTab();
544  }
545 
546  // call sorting on document
547  bRet = mxDoc->SortTable(aBoxes, rOpt);
548  }
549  else
550  {
551  // Sort text nothing else
552  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
553  {
554  SwPaM* pPam = &rPaM;
555 
556  SwPosition* pStart = pPam->Start();
557  SwPosition* pEnd = pPam->End();
558 
559  SwNodeIndex aPrevIdx( pStart->nNode, -1 );
560  sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
561  const sal_Int32 nCntStt = pStart->nContent.GetIndex();
562 
563  // Sorting
564  bRet = mxDoc->SortText(*pPam, rOpt);
565 
566  // put selection again
567  pPam->DeleteMark();
568  pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
569  SwContentNode* pCNd = pPam->GetContentNode();
570  sal_Int32 nLen = pCNd->Len();
571  if( nLen > nCntStt )
572  nLen = nCntStt;
573  pPam->GetPoint()->nContent.Assign(pCNd, nLen );
574  pPam->SetMark();
575 
576  pPam->GetPoint()->nNode += nOffset;
577  pCNd = pPam->GetContentNode();
578  pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
579  }
580  }
581 
582  EndAllAction();
583  return bRet;
584 }
585 
587 {
588  SwFrame* pFrame = GetCurrFrame();
589  while (pFrame)
590  {
591  pFrame = pFrame->GetUpper();
592  if (pFrame && pFrame->IsColumnFrame())
593  {
594  return pFrame->IsRightToLeft();
595  }
596  }
597  return false;
598 }
599 
600 sal_uInt16 SwFEShell::GetCurColNum_( const SwFrame *pFrame,
601  SwGetCurColNumPara* pPara )
602 {
603  sal_uInt16 nRet = 0;
604  while ( pFrame )
605  {
606  pFrame = pFrame->GetUpper();
607  if( pFrame && pFrame->IsColumnFrame() )
608  {
609  const SwFrame *pCurFrame = pFrame;
610  do {
611  ++nRet;
612  pFrame = pFrame->GetPrev();
613  } while ( pFrame );
614 
615  if( pPara )
616  {
617  // now search the format, determining the columness
618  pFrame = pCurFrame->GetUpper();
619  while( pFrame )
620  {
622  {
623  pPara->pFrameFormat = static_cast<const SwLayoutFrame*>(pFrame)->GetFormat();
624  pPara->pPrtRect = &pFrame->getFramePrintArea();
625  break;
626  }
627  pFrame = pFrame->GetUpper();
628  }
629  if( !pFrame )
630  {
631  pPara->pFrameFormat = nullptr;
632  pPara->pPrtRect = nullptr;
633  }
634  }
635  break;
636  }
637  }
638  return nRet;
639 }
640 
641 sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
642 {
643  OSL_ENSURE( GetCurrFrame(), "Cursor parked?" );
644  return GetCurColNum_( GetCurrFrame(), pPara );
645 }
646 
647 sal_uInt16 SwFEShell::GetCurOutColNum() const
648 {
649  sal_uInt16 nRet = 0;
650  SwFrame* pFrame = GetCurrFrame();
651  OSL_ENSURE( pFrame, "Cursor parked?" );
652  if( pFrame )
653  {
654  pFrame = pFrame->IsInTab() ? static_cast<SwFrame*>(pFrame->FindTabFrame())
655  : static_cast<SwFrame*>(pFrame->FindSctFrame());
656  OSL_ENSURE( pFrame, "No Tab, no Sect" );
657  if( pFrame )
658  nRet = GetCurColNum_( pFrame, nullptr );
659  }
660  return nRet;
661 }
662 
663 SwFEShell::SwFEShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption *pOptions )
664  : SwEditShell( rDoc, pWindow, pOptions )
665  , m_bCheckForOLEInCaption(false)
666  , m_aPasteListeners(GetPasteMutex())
667  , m_eTableInsertMode(SwTable::SEARCH_NONE)
668  , m_bTableCopied(false)
669 {
670 }
671 
673  : SwEditShell( rShell, pWindow )
674  , m_bCheckForOLEInCaption(false)
675  , m_aPasteListeners(GetPasteMutex())
676  , m_eTableInsertMode(SwTable::SEARCH_NONE)
677  , m_bTableCopied(false)
678 {
679 }
680 
682 {
683 }
684 
685 // #i17567# - adjustments for allowing
686 // negative vertical positions for fly frames anchored to paragraph/to character.
687 // #i22305# - adjustments for option 'Follow text flow'
688 // for to frame anchored objects.
689 // #i22341# - adjustments for vertical alignment at top of line
690 // for to character anchored objects.
692  const RndStdIds _nAnchorId,
693  const sal_Int16 _eHoriRelOrient,
694  const sal_Int16 _eVertRelOrient,
695  const SwPosition* _pToCharContentPos,
696  const bool _bFollowTextFlow,
697  bool _bMirror,
698  Point* _opRef,
699  Size* _opPercent,
700  const SwFormatFrameSize* pFormatFrameSize) const
701 {
702  const SwFrame* pFrame;
703  const SwFlyFrame* pFly;
704  if( _opRef )
705  {
706  pFrame = GetCurrFrame();
707  pFly = pFrame->FindFlyFrame();
708  if( nullptr != pFly )
709  pFrame = pFly->GetAnchorFrame();
710  }
711  else
712  {
713  pFly = GetSelectedFlyFrame();
714  pFrame = pFly ? pFly->GetAnchorFrame() : GetCurrFrame();
715  }
716 
717  bool bWrapThrough = false;
718  if ( pFly )
719  {
720  SwFlyFrameFormat* pFormat = const_cast<SwFlyFrameFormat*>(pFly->GetFormat());
721  const SwFormatSurround& rSurround = pFormat->GetSurround();
722  bWrapThrough = rSurround.GetSurround() == css::text::WrapTextMode_THROUGH;
723  }
724 
725  const SwPageFrame* pPage = pFrame->FindPageFrame();
726  _bMirror = _bMirror && !pPage->OnRightPage();
727 
728  Point aPos;
729  bool bVertic = false;
730  bool bRTL = false;
731  bool bVerticalL2R = false;
732 
733  if ((RndStdIds::FLY_AT_PAGE == _nAnchorId) || (RndStdIds::FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
734  {
735  const SwFrame* pTmp = pFrame;
736  // #i22305#
737  if ((RndStdIds::FLY_AT_PAGE == _nAnchorId) ||
738  ((RndStdIds::FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
739  {
740  pFrame = pPage;
741  }
742  else
743  {
744  pFrame = pFrame->FindFlyFrame();
745  }
746  if ( !pFrame )
747  pFrame = pTmp;
748  _orRect = pFrame->getFrameArea();
749  SwRectFnSet aRectFnSet(pFrame);
750  bRTL = pFrame->IsRightToLeft();
751  if ( bRTL )
752  aPos = pFrame->getFrameArea().TopRight();
753  else
754  aPos = aRectFnSet.GetPos(pFrame->getFrameArea());
755 
756  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
757  {
758  bVertic = aRectFnSet.IsVert();
759  bVerticalL2R = aRectFnSet.IsVertL2R();
760  _bMirror = false; // no mirroring in vertical environment
761  switch ( _eHoriRelOrient )
762  {
763  case text::RelOrientation::PAGE_RIGHT:
764  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustY(pFrame->getFramePrintArea().Height() );
765  [[fallthrough]];
766  case text::RelOrientation::PRINT_AREA:
767  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustY(pFrame->getFramePrintArea().Top() ); break;
768  default: break;
769  }
770  }
771  else if ( _bMirror )
772  {
773  switch ( _eHoriRelOrient )
774  {
775  case text::RelOrientation::PRINT_AREA:
776  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
777  [[fallthrough]];
778  case text::RelOrientation::PAGE_RIGHT:
779  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break;
780  default: aPos.AdjustX(pFrame->getFrameArea().Width() );
781  }
782  }
783  else if ( bRTL )
784  {
785  switch ( _eHoriRelOrient )
786  {
787  case text::RelOrientation::PRINT_AREA:
788  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
789  [[fallthrough]];
790  case text::RelOrientation::PAGE_LEFT:
791  case text::RelOrientation::FRAME_LEFT: aPos.AdjustX(pFrame->getFramePrintArea().Left() -
792  pFrame->getFrameArea().Width() ); break;
793  default: break;
794  }
795  }
796  else
797  {
798  switch ( _eHoriRelOrient )
799  {
800  case text::RelOrientation::PAGE_RIGHT:
801  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
802  [[fallthrough]];
803  case text::RelOrientation::PRINT_AREA:
804  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break;
805  default:break;
806  }
807  }
808 
809  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
810  {
811  switch ( _eVertRelOrient )
812  {
813  case text::RelOrientation::PRINT_AREA:
814  case text::RelOrientation::PAGE_PRINT_AREA:
815  {
816  aPos.AdjustX( -(pFrame->GetRightMargin()) );
817  }
818  break;
819  }
820  }
821  else if ( aRectFnSet.IsVertL2R() )
822  {
823  switch ( _eVertRelOrient )
824  {
825  case text::RelOrientation::PRINT_AREA:
826  case text::RelOrientation::PAGE_PRINT_AREA:
827  {
828  aPos.AdjustX(pFrame->GetLeftMargin() );
829  }
830  break;
831  }
832  }
833  else
834  {
835  switch ( _eVertRelOrient )
836  {
837  case text::RelOrientation::PRINT_AREA:
838  case text::RelOrientation::PAGE_PRINT_AREA:
839  {
840  if ( pFrame->IsPageFrame() )
841  {
842  aPos.setY(
843  static_cast<const SwPageFrame*>(pFrame)->PrtWithoutHeaderAndFooter().Top() );
844  }
845  else
846  {
847  aPos.AdjustY(pFrame->getFramePrintArea().Top() );
848  }
849  }
850  break;
851  }
852  }
853  if ( _opPercent )
854  *_opPercent = pFrame->getFramePrintArea().SSize();
855  }
856  else
857  {
858  const SwFrame* pUpper = ( pFrame->IsPageFrame() || pFrame->IsFlyFrame() ) ?
859  pFrame : pFrame->GetUpper();
860  SwRectFnSet aRectFnSet(pUpper);
861  if ( _opPercent )
862  {
863  // If the size is relative from page, then full size should be counted from the page frame.
864  if (pFormatFrameSize && pFormatFrameSize->GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
865  _opPercent->setWidth(pPage->getFrameArea().Width());
866  else
867  _opPercent->setWidth(pUpper->getFramePrintArea().Width());
868 
869  if (pFormatFrameSize && pFormatFrameSize->GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
870  // If the size is relative from page, then full size should be counted from the page frame.
871  _opPercent->setHeight(pPage->getFrameArea().Height());
872  else
873  _opPercent->setHeight(pUpper->getFramePrintArea().Height());
874  }
875 
876  bRTL = pFrame->IsRightToLeft();
877  if ( bRTL )
878  aPos = pFrame->getFrameArea().TopRight();
879  else
880  aPos = aRectFnSet.GetPos(pFrame->getFrameArea());
881  // #i17567# - allow negative positions
882  // for fly frames anchor to paragraph/to character.
883  if ((_nAnchorId == RndStdIds::FLY_AT_PARA) || (_nAnchorId == RndStdIds::FLY_AT_CHAR))
884  {
885  // The rectangle, the fly frame can be positioned in, is determined
886  // horizontally by the frame area of the horizontal environment
887  // and vertically by the printing area of the vertical environment,
888  // if the object follows the text flow, or by the frame area of the
889  // vertical environment, if the object doesn't follow the text flow.
890  // new class <SwEnvironmentOfAnchoredObject>
892  _bFollowTextFlow );
893  const SwLayoutFrame& rHoriEnvironLayFrame =
894  aEnvOfObj.GetHoriEnvironmentLayoutFrame( *pFrame );
895  const SwLayoutFrame& rVertEnvironLayFrame =
896  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pFrame );
897  const SwRect& aHoriEnvironRect( rHoriEnvironLayFrame.getFrameArea() );
898  SwRect aVertEnvironRect;
899  if ( _bFollowTextFlow )
900  {
901  aVertEnvironRect = rVertEnvironLayFrame.getFramePrintArea();
902  aVertEnvironRect.Pos() += rVertEnvironLayFrame.getFrameArea().Pos();
903  // #i18732# - adjust vertical 'virtual' anchor position
904  // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
905  // to page areas.
906  if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
907  {
908  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
909  {
910  aPos.setX( aVertEnvironRect.Right() );
911  }
912  else if ( aRectFnSet.IsVertL2R() )
913  {
914  aPos.setX( aVertEnvironRect.Left() );
915  }
916  else
917  {
918  aPos.setY( aVertEnvironRect.Top() );
919  }
920  }
921  }
922  else
923  {
924  OSL_ENSURE( rVertEnvironLayFrame.IsPageFrame(),
925  "<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
926  aVertEnvironRect = rVertEnvironLayFrame.getFrameArea();
927  // #i18732# - adjustment vertical 'virtual' anchor position
928  // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
929  // to page areas.
930  if (_eVertRelOrient == text::RelOrientation::PAGE_FRAME
931  || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA
932  || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
933  {
934  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
935  {
936  aPos.setX( aVertEnvironRect.Right() );
937  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
938  {
939  aPos.setX(aPos.getX() - rVertEnvironLayFrame.GetRightMargin());
940  }
941  }
942  else if ( aRectFnSet.IsVertL2R() )
943  {
944  aPos.setX( aVertEnvironRect.Left() );
945  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
946  {
947  aPos.setX(aPos.getX() + rVertEnvironLayFrame.GetLeftMargin());
948  }
949  }
950  else
951  {
952  aPos.setY( aVertEnvironRect.Top() );
953  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
954  {
955  aPos.setY(aPos.getY() + rVertEnvironLayFrame.GetTopMargin());
956  // add height of page header
957  const SwFrame* pTmpFrame = rVertEnvironLayFrame.Lower();
958  if ( pTmpFrame->IsHeaderFrame() )
959  {
960  aPos.setY(aPos.getY() + pTmpFrame->getFrameArea().Height());
961  }
962  }
963  else if (_eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
964  {
965  if (rVertEnvironLayFrame.IsPageFrame())
966  {
967  auto& rPageFrame = static_cast<const SwPageFrame&>(rVertEnvironLayFrame);
968  aPos.setY(rPageFrame.PrtWithoutHeaderAndFooter().Bottom());
969  }
970  else
971  {
972  aPos.AdjustY(rVertEnvironLayFrame.getFramePrintArea().Bottom());
973  }
974  }
975  }
976  }
977  }
978 
979  // #i22341# - adjust vertical 'virtual' anchor position
980  // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
981  // character and vertical aligned at character or top of line
982  // <pFrame>, which is the anchor frame or the proposed anchor frame,
983  // doesn't have to be a text frame (e.g. edit a to-page anchored
984  // fly frame). Thus, assure this.
985  const SwTextFrame* pTextFrame( dynamic_cast<const SwTextFrame*>(pFrame) );
986  if ( pTextFrame &&
987  (_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
988  ( _eVertRelOrient == text::RelOrientation::CHAR ||
989  _eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
990  {
991  SwTwips nTop = 0;
992  if ( _eVertRelOrient == text::RelOrientation::CHAR )
993  {
994  SwRect aChRect;
995  if ( _pToCharContentPos )
996  {
997  pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
998  }
999  else
1000  {
1001  // No content position provided. Thus, use a default one.
1002  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1003  pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
1004  }
1005  nTop = aRectFnSet.GetBottom(aChRect);
1006  }
1007  else
1008  {
1009  if ( _pToCharContentPos )
1010  {
1011  pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos );
1012  }
1013  else
1014  {
1015  // No content position provided. Thus, use a default one.
1016  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1017  pTextFrame->GetTopOfLine( nTop, aDefaultContentPos );
1018  }
1019  }
1020  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1021  {
1022  aPos.setX(nTop);
1023  }
1024  else
1025  {
1026  aPos.setY(nTop);
1027  }
1028  }
1029 
1030  // #i26945# - adjust horizontal 'virtual' anchor
1031  // position (<aPos.X()> respectively <aPos.Y()>), if object is
1032  // anchored to character and horizontal aligned at character.
1033  if ( pTextFrame &&
1034  (_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
1035  _eHoriRelOrient == text::RelOrientation::CHAR )
1036  {
1037  SwTwips nLeft = 0;
1038  SwRect aChRect;
1039  if ( _pToCharContentPos )
1040  {
1041  pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
1042  }
1043  else
1044  {
1045  // No content position provided. Thus, use a default one.
1046  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1047  pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
1048  }
1049  nLeft = aRectFnSet.GetLeft(aChRect);
1050  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1051  {
1052  aPos.setY(nLeft);
1053  }
1054  else
1055  {
1056  aPos.setX(nLeft);
1057  }
1058  }
1059  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1060  {
1061  _orRect = SwRect( aVertEnvironRect.Left(),
1062  aHoriEnvironRect.Top(),
1063  aVertEnvironRect.Width(),
1064  aHoriEnvironRect.Height() );
1065  }
1066  else
1067  {
1068  _orRect = SwRect( aHoriEnvironRect.Left(),
1069  aVertEnvironRect.Top(),
1070  aHoriEnvironRect.Width(),
1071  aVertEnvironRect.Height() );
1072  }
1073  }
1074  else
1075  {
1076  if( _opRef && pFly && pFly->IsFlyInContentFrame() )
1077  *_opRef = static_cast<const SwFlyInContentFrame*>( pFly )->GetRefPoint();
1078 
1079  _orRect = pUpper->getFrameArea();
1080  if( !pUpper->IsBodyFrame() )
1081  {
1082  _orRect += pUpper->getFramePrintArea().Pos();
1083  _orRect.SSize( pUpper->getFramePrintArea().SSize() );
1084  if ( pUpper->IsCellFrame() )//MA_FLY_HEIGHT
1085  {
1086  const SwFrame* pTab = pUpper->FindTabFrame();
1087  tools::Long nBottom = aRectFnSet.GetPrtBottom(*pTab->GetUpper());
1088  aRectFnSet.SetBottom( _orRect, nBottom );
1089  }
1090  }
1091  // only use 90% of height for character bound
1092  {
1093  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1094  _orRect.Width( (_orRect.Width()*9)/10 );
1095  else
1096  _orRect.Height( (_orRect.Height()*9)/10 );
1097  }
1098  }
1099 
1100  const SwTwips nBaseOfstForFly = ( pFrame->IsTextFrame() && pFly ) ?
1101  static_cast<const SwTextFrame*>(pFrame)->GetBaseOffsetForFly( !bWrapThrough ) :
1102  0;
1103  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1104  {
1105  bVertic = aRectFnSet.IsVert();
1106  bVerticalL2R = aRectFnSet.IsVertL2R();
1107  _bMirror = false;
1108 
1109  switch ( _eHoriRelOrient )
1110  {
1111  case text::RelOrientation::FRAME_RIGHT:
1112  {
1113  aPos.setY(aPos.getY() + pFrame->getFramePrintArea().Height());
1114  aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
1115  break;
1116  }
1117  case text::RelOrientation::PRINT_AREA:
1118  {
1119  aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
1120  aPos.setY(aPos.getY() + nBaseOfstForFly);
1121  break;
1122  }
1123  case text::RelOrientation::PAGE_RIGHT:
1124  {
1125  aPos.setY(pPage->getFrameArea().Top() + pPage->getFramePrintArea().Bottom());
1126  break;
1127  }
1128  case text::RelOrientation::PAGE_PRINT_AREA:
1129  {
1130  aPos.setY(pPage->getFrameArea().Top() + pPage->getFramePrintArea().Top());
1131  break;
1132  }
1133  case text::RelOrientation::PAGE_LEFT:
1134  case text::RelOrientation::PAGE_FRAME:
1135  {
1136  aPos.setY(pPage->getFrameArea().Top());
1137  break;
1138  }
1139  case text::RelOrientation::FRAME:
1140  {
1141  aPos.setY(aPos.getY() + nBaseOfstForFly);
1142  break;
1143  }
1144  default: break;
1145  }
1146  }
1147  else if( _bMirror )
1148  {
1149  switch ( _eHoriRelOrient )
1150  {
1151  case text::RelOrientation::FRAME_RIGHT: aPos.setX(aPos.getX() + pFrame->getFramePrintArea().Left()); break;
1152  case text::RelOrientation::FRAME:
1153  case text::RelOrientation::FRAME_LEFT: aPos.setX(aPos.getX() + pFrame->getFrameArea().Width()); break;
1154  case text::RelOrientation::PRINT_AREA: aPos.setX(aPos.getX() + pFrame->getFramePrintArea().Right()); break;
1155  case text::RelOrientation::PAGE_LEFT:
1156  case text::RelOrientation::PAGE_FRAME: aPos.setX(pPage->getFrameArea().Right()); break;
1157  case text::RelOrientation::PAGE_PRINT_AREA: aPos.setX(pPage->getFrameArea().Left()
1158  + pPage->getFramePrintArea().Left()); break;
1159  default: break;
1160  }
1161  }
1162  else if ( bRTL )
1163  {
1164  switch ( _eHoriRelOrient )
1165  {
1166  case text::RelOrientation::FRAME_LEFT:
1167  aPos.setX(pFrame->getFrameArea().Left() +
1168  pFrame->getFramePrintArea().Left());
1169  break;
1170 
1171  case text::RelOrientation::PRINT_AREA:
1172  aPos.setX(pFrame->getFrameArea().Left() + pFrame->getFramePrintArea().Left() +
1173  pFrame->getFramePrintArea().Width());
1174  aPos.setX(aPos.getX() + nBaseOfstForFly);
1175  break;
1176 
1177  case text::RelOrientation::PAGE_LEFT:
1178  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left());
1179  break;
1180 
1181  case text::RelOrientation::PAGE_PRINT_AREA:
1182  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left() +
1183  pPage->getFramePrintArea().Width());
1184  break;
1185 
1186  case text::RelOrientation::PAGE_RIGHT:
1187  case text::RelOrientation::PAGE_FRAME:
1188  aPos.setX(pPage->getFrameArea().Right());
1189  break;
1190 
1191  case text::RelOrientation::FRAME:
1192  aPos.setX(aPos.getX() + nBaseOfstForFly);
1193  break;
1194  default: break;
1195  }
1196  }
1197  else
1198  {
1199  switch ( _eHoriRelOrient )
1200  {
1201  case text::RelOrientation::FRAME_RIGHT:
1202  aPos.AdjustX(pFrame->getFramePrintArea().Width() );
1203  aPos += pFrame->getFramePrintArea().Pos();
1204  break;
1205  case text::RelOrientation::PRINT_AREA:
1206  aPos += pFrame->getFramePrintArea().Pos();
1207  aPos.setX(aPos.getX() + nBaseOfstForFly);
1208  break;
1209  case text::RelOrientation::PAGE_RIGHT:
1210  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Right());
1211  break;
1212  case text::RelOrientation::PAGE_PRINT_AREA:
1213  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left());
1214  break;
1215  case text::RelOrientation::PAGE_LEFT:
1216  case text::RelOrientation::PAGE_FRAME:
1217  aPos.setX(pPage->getFrameArea().Left());
1218  break;
1219  case text::RelOrientation::FRAME:
1220  aPos.setX(aPos.getX() + nBaseOfstForFly);
1221  break;
1222  default: break;
1223  }
1224  }
1225 
1226  }
1227  if( _opRef )
1228  return;
1229 
1230  if( bVertic && !bVerticalL2R )
1231  _orRect.Pos( aPos.getX() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.getY() );
1232  else if( bVerticalL2R )
1233  _orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
1234  else if ( bRTL )
1235  _orRect.Pos( - ( _orRect.Right() - aPos.getX() ), _orRect.Top() - aPos.getY() );
1236  else
1237  _orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
1238  if( _bMirror )
1239  _orRect.Pos( -_orRect.Right(), _orRect.Top() );
1240 }
1241 
1243 {
1244  Size aRet;
1245  SwFlyFrame *pFly = GetSelectedFlyFrame();
1246  if ( pFly )
1247  {
1248  // #i32951# - due to issue #i28701# no format of a
1249  // newly inserted Writer fly frame or its anchor frame is performed
1250  // any more. Thus, it could be possible (e.g. on insert of a horizontal
1251  // line) that the anchor frame isn't formatted and its printing area
1252  // size is (0,0). If this is the case the printing area of the upper
1253  // of the anchor frame is taken.
1254  const SwFrame* pAnchorFrame = pFly->GetAnchorFrame();
1255  aRet = pAnchorFrame->getFramePrintArea().SSize();
1256  if ( aRet.IsEmpty() && pAnchorFrame->GetUpper() )
1257  {
1258  aRet = pAnchorFrame->GetUpper()->getFramePrintArea().SSize();
1259  }
1260 
1261  SwRect aBound;
1262  CalcBoundRect( aBound, pFly->GetFormat()->GetAnchor().GetAnchorId());
1263  if ( pFly->GetAnchorFrame()->IsVertical() )
1264  aRet.setWidth( aBound.Width() );
1265  else
1266  aRet.setHeight( aBound.Height() );
1267  }
1268  return aRet;
1269 }
1270 
1271 bool SwFEShell::IsFrameVertical(const bool bEnvironment, bool& bRTL, bool& bVertL2R) const
1272 {
1273  bool bVert = false;
1274  bRTL = false;
1275  bVertL2R = false;
1276 
1277  if ( Imp()->HasDrawView() )
1278  {
1279  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1280  if( rMrkList.GetMarkCount() != 1 )
1281  return bVert;
1282 
1283  SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1284  if ( !pObj )
1285  {
1286  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation" );
1287  return bVert;
1288  }
1289  // #i26791#
1290  SwContact* pContact = GetUserCall( pObj );
1291  if ( !pContact )
1292  {
1293  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SwContact instance at marked object -> This is a serious situation" );
1294  return bVert;
1295  }
1296  const SwFrame* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrame();
1297  if ( !pRef )
1298  {
1299  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing anchor frame at marked object -> This is a serious situation" );
1300  return bVert;
1301  }
1302 
1303  if ( !bEnvironment )
1304  if ( auto pVirtFly = dynamic_cast<const SwVirtFlyDrawObj*>( pObj) )
1305  pRef = pVirtFly->GetFlyFrame();
1306 
1307  bVert = pRef->IsVertical();
1308  bRTL = pRef->IsRightToLeft();
1309  bVertL2R = pRef->IsVertLR();
1310  }
1311 
1312  return bVert;
1313 }
1314 
1316 {
1317  // does not do anything, only avoids crash if the method is used for wrong shell
1318 }
1319 
1321 {
1322  // Clear objects selection
1323  if ( Imp()->GetDrawView()->AreObjectsMarked() )
1324  {
1325  Imp()->GetDrawView()->UnmarkAll();
1326  ClearMark();
1327  }
1328 
1330 }
1331 
1332 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ShellGetFocus()
Definition: fews.cxx:309
OUString GetNumStr(sal_Int32 nNo) const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:548
SAL_DLLPRIVATE void EndAllActionAndCall()
Terminate actions for all shells and call ChangeLink.
Definition: fews.cxx:69
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx:78
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
Base class of the Writer layout elements.
Definition: frame.hxx:298
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:157
virtual sal_Int32 Len() const
Definition: node.cxx:1245
const ::std::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:64
void DeleteMark()
Definition: pam.hxx:177
void Right(const tools::Long nRight)
Definition: swrect.hxx:200
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1364
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2860
SwLabelType
Definition: swtypes.hxx:87
size_t GetMarkCount() const
Rect of current FlyFrame.
Marks a position in the document model.
Definition: pam.hxx:35
SdrView * GetDrawView()
Definition: vnew.cxx:376
bool IsInFly() const
Definition: frame.hxx:942
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
bool IsInSct() const
Definition: frame.hxx:948
const SwLayoutFrame & GetVertEnvironmentLayoutFrame(const SwFrame &_rVertOrientFrame) const
determine environment layout frame for possible vertical object positions respectively for alignments...
void setWidth(tools::Long nWidth)
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
const SwTable * GetTable() const
Definition: tabfrm.hxx:143
void Left(const tools::Long nLeft)
Definition: swrect.hxx:195
SwNodeIndex nNode
Definition: pam.hxx:37
virtual void MoveObjectIfActive(svt::EmbeddedObjectRef &xObj, const Point &rOffset)
The layout has been changed, so the active object has to be moved after that.
Definition: fews.cxx:1315
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:90
SwFrameType GetType() const
Definition: frame.hxx:503
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
sal_uIntPtr sal_uLong
long Long
sal_uInt16 GetCurColNum(SwGetCurColNumPara *pPara=nullptr) const
The ruler needs some information too.
Definition: fews.cxx:641
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
void ShellLoseFocus()
Hide or show layout-selection and pass call to CursorSh.
Definition: fews.cxx:323
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1212
Definition: doc.hxx:187
void ShellLoseFocus()
Definition: crsrsh.cxx:2424
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:449
bool HasDrawView() const
Definition: vnew.cxx:361
SwNode & GetNode() const
Definition: ndindex.hxx:119
SdrMark * GetMark(size_t nNum) const
bool IsVert() const
Definition: frame.hxx:1348
void Pos(const Point &rNew)
Definition: swrect.hxx:169
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1788
bool IsCellFrame() const
Definition: frame.hxx:1207
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:334
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:660
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:275
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
bool IsDirectlyInSection() const
Definition: fews.cxx:231
void EndAllAction()
Definition: edws.cxx:97
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
CurRectType
Definition: fesh.hxx:135
static SAL_DLLPRIVATE sal_uInt16 GetCurColNum_(const SwFrame *pFrame, SwGetCurColNumPara *pPara)
Definition: fews.cxx:600
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
bool IsFlyFrame() const
Definition: frame.hxx:1191
void SetBottom(SwRect &rRect, tools::Long nNew) const
Definition: frame.hxx:1368
Rect of current PrtArea of section.
SwIndex nContent
Definition: pam.hxx:38
const SwRect & getFrameArea() const
Definition: frame.hxx:178
bool IsInTab() const
Definition: frame.hxx:936
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:451
const SwLayoutFrame & GetHoriEnvironmentLayoutFrame(const SwFrame &_rHoriOrientFrame) const
determine environment layout frame for possible horizontal object positions respectively for alignmen...
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
bool IsTextFrame() const
Definition: frame.hxx:1215
Mutex aMutex
void Width(tools::Long nNew)
Definition: swrect.hxx:187
bool OnRightPage() const
Definition: frame.hxx:716
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
bool IsSctFrame() const
Definition: frame.hxx:1195
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1092
void UnmarkAll()
tools::Long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1360
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:194
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1806
bool IsColumnFrame() const
Definition: frame.hxx:1163
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:261
SdrObject * GetMarkedSdrObj() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:454
bool Sort(const SwSortOptions &)
Definition: fews.cxx:517
SwFEShell(SwDoc &rDoc, vcl::Window *pWin, const SwViewOption *pOpt)
Definition: fews.cxx:663
virtual ~SwFEShell() override
Definition: fews.cxx:681
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:2717
Rect of current PrtArea of page.
bool IsEmpty() const
Shell * GetShell()
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
tools::Long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1391
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:149
uno_Any a
Rect of current section but outside of table.
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SwPageFrame * FindPageFrame()
Definition: frame.hxx:663
sal_uInt16 GetPhyPageNum() const
Phy: real page count.
Definition: fews.cxx:335
const SwFrame * Lower() const
Definition: layfrm.hxx:101
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:127
SwContentNode * GetContentNode()
Definition: node.hxx:619
const SdrMarkList & GetMarkedObjectList() const
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
Size GetGraphicDefaultSize() const
Definition: fews.cxx:1242
SwLayoutFrame * GetUpper()
Definition: frame.hxx:661
sal_uInt16 GetPageOffset() const
Definition: fews.cxx:402
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
SwFrame * GetPrev()
Definition: frame.hxx:660
Marks a node in the document model.
Definition: ndindex.hxx:31
void ToggleHeaderFooterEdit()
Definition: fews.cxx:1320
bool GetTopOfLine(SwTwips &_onTopOfLine, const SwPosition &_rPos) const
Determine top of line for given position in the text frame.
Definition: frmcrsr.cxx:453
void SSize(const Size &rNew)
Definition: swrect.hxx:178
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
sal_uInt16 GetVirtPageNum() const
Definition: fews.cxx:343
A page of the document layout.
Definition: pagefrm.hxx:41
tools::Long SwTwips
Definition: swtypes.hxx:49
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:111
const SwPosition * Start() const
Definition: pam.hxx:212
void SetVirtPageNum(const bool bOf) const
Definition: rootfrm.hxx:442
SwSectionFrame * FindSctFrame()
Definition: frame.hxx:1096
void CalcBoundRect(SwRect &_orRect, const RndStdIds _nAnchorId, const sal_Int16 _eHoriRelOrient=css::text::RelOrientation::FRAME, const sal_Int16 _eVertRelOrient=css::text::RelOrientation::FRAME, const SwPosition *_pToCharContentPos=nullptr, const bool _bFollowTextFlow=false, bool _bMirror=false, Point *_opRef=nullptr, Size *_opPercent=nullptr, const SwFormatFrameSize *pFormatFrameSize=nullptr) const
i#17567 - adjustments to allow negative vertical positions for fly frames anchored to paragraph or to...
Definition: fews.cxx:691
sal_Int16 GetHeightPercentRelation() const
Definition: fmtfsize.hxx:89
Rect of current page.
bool GetAutoPos(SwRect &, const SwPosition &) const
A slimmer version of GetCharRect for autopositioning Frames.
Definition: frmcrsr.cxx:366
bool IsColRightToLeft() const
Definition: fews.cxx:586
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:209
bool IsVertLR() const
Definition: frame.hxx:960
void SetNewPageOffset(sal_uInt16 nOffset)
Definition: fews.cxx:372
bool IsFrameVertical(const bool bEnvironment, bool &bRightToLeft, bool &bVertL2R) const
Determines whether a frame or its environment is vertically formatted and right-to-left.
Definition: fews.cxx:1271
SwDrawView * GetDrawView()
Definition: viewimp.hxx:154
general base class for all free-flowing frames
Definition: flyfrm.hxx:60
Rect covering the pages area.
tools::Long GetRightMargin() const
Definition: ssfrm.cxx:47
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2444
void ToggleHeaderFooterEdit()
Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags.
Definition: viewsh.cxx:107
void ShellGetFocus()
Definition: crsrsh.cxx:2431
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1695
SwFlyFrame * GetFlyFromMarked(const SdrMarkList *pLst, SwViewShell *pSh)
Definition: feshview.cxx:139
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, bool bExpandCharToPara=false, SwTextAttr **ppNewTextAttr=nullptr)=0
Insert an attribute.
sal_uInt16 GetCurOutColNum() const
Current outer column.
Definition: fews.cxx:647
sal_Int32 GetIndex() const
Definition: index.hxx:91
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:105
... page will be formatted if required.
const SwPosition * End() const
Definition: pam.hxx:217
bool IsRightToLeft() const
Definition: frame.hxx:968
void Top(const tools::Long nTop)
Definition: swrect.hxx:204
bool IsVertL2R() const
Definition: frame.hxx:1349
bool IsPageFrame() const
Definition: frame.hxx:1159
static SwRewriter CreateRewriter(const OUString &rStr)
Definition: unins.cxx:1000
Rect of current header/footer.
void ClearMark()
Definition: crsrsh.cxx:938
tools::Long GetTopMargin() const
Definition: ssfrm.cxx:41
const SwRect * pPrtRect
Definition: fesh.hxx:153
void setHeight(tools::Long nHeight)
void SetPageOffset(sal_uInt16 nOffset)
Changes last page offset.
Definition: fews.cxx:379
Point TopRight() const
Definition: swrect.cxx:175
Point GetContentPos(const Point &rPoint, bool bNext) const
Provide information about content situated closes to given Point.
Definition: fews.cxx:84
void InsertLabel(const SwLabelType eType, const OUString &rText, const OUString &rSeparator, const OUString &rNumberSeparator, const bool bBefore, const sal_uInt16 nId, const OUString &rCharacterStyle, const bool bCpyBrd)
Definition: fews.cxx:421
bool IsVertical() const
Definition: frame.hxx:954
tools::Long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1359
const SwFrameFormat * pFrameFormat
Definition: fesh.hxx:152
Rect of current section.
RndStdIds
void SetNumOffset(const ::std::optional< sal_uInt16 > &oNum)
Definition: fmtpdsc.hxx:65
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:185
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
const SwFrame * GetAnchorFrame() const
tools::Long GetLeftMargin() const
Definition: ssfrm.cxx:45
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2067
bool IsBodyFrame() const
Definition: frame.hxx:1187
void Height(tools::Long nNew)
Definition: swrect.hxx:191
Rect of PrtArea of FlyFrame.
FrameTypeFlags GetFrameType(const Point *pPt, bool bStopAtFly) const
For return values see above FrameType.
Definition: fews.cxx:237
sal_Int16 GetWidthPercentRelation() const
Definition: fmtfsize.hxx:92
SwRootFrame * getRootFrame()
Definition: frame.hxx:662
static void lcl_SetAPageOffset(sal_uInt16 nOffset, SwPageFrame *pPage, SwFEShell *pThis)
Definition: fews.cxx:351
bool IsHeaderFrame() const
Definition: frame.hxx:1171
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3065
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:272
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:243
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:395
SwTabFrame * FindTabFrame()
Definition: frame.hxx:1080
SwFrame * GetNext()
Definition: frame.hxx:659