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