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