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>
23 #include <init.hxx>
24 #include <fesh.hxx>
25 #include <tabcol.hxx>
26 #include <pagefrm.hxx>
27 #include <rootfrm.hxx>
28 #include <cntfrm.hxx>
29 #include <doc.hxx>
30 #include <frmtool.hxx>
31 #include <swtable.hxx>
32 #include <viewimp.hxx>
33 #include <dview.hxx>
34 #include <flyfrm.hxx>
35 #include <node.hxx>
36 #include <pam.hxx>
37 #include <sectfrm.hxx>
38 #include <fmtpdsc.hxx>
39 #include <fmtsrnd.hxx>
40 #include <fmtcntnt.hxx>
41 #include <fmtfsize.hxx>
42 #include <tabfrm.hxx>
43 #include <flyfrms.hxx>
44 #include <txtfrm.hxx>
45 #include <mdiexp.hxx>
46 #include <pagedesc.hxx>
47 #include <fmtanchr.hxx>
49 #include <ndtxt.hxx>
50 #include <dflyobj.hxx>
51 #include <dcontact.hxx>
52 #include <UndoInsert.hxx>
53 
54 using namespace com::sun::star;
55 
56 namespace
57 {
62 osl::Mutex& GetPasteMutex()
63 {
64  static osl::Mutex aMutex;
65  return aMutex;
66 }
67 }
68 
70 {
71  for(SwViewShell& rCurrentShell : GetRingContainer())
72  {
73  if( dynamic_cast<const SwCursorShell*>( &rCurrentShell) != nullptr )
74  {
75  static_cast<SwFEShell*>(&rCurrentShell)->EndAction();
76  static_cast<SwFEShell*>(&rCurrentShell)->CallChgLnk();
77  }
78  else
79  rCurrentShell.EndAction();
80  }
81 }
82 
83 // Determine the Content's nearest to the point
84 Point SwFEShell::GetContentPos( const Point& rPoint, bool bNext ) const
85 {
86  SET_CURR_SHELL( const_cast<SwFEShell*>(this) );
87  return GetLayout()->GetNextPrevContentPos( rPoint, bNext );
88 }
89 
91  const uno::Reference < embed::XEmbeddedObject >& xObj ) const
92 {
93  const SwFrame *pFrame = Imp()->HasDrawView()
94  ? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
95  const_cast<SwFEShell*>(this))
96  : nullptr;
97 
98  if( !pFrame )
99  {
100  if( pPt )
101  {
102  SwPosition aPos( *GetCursor()->GetPoint() );
103  Point aPt( *pPt );
104  GetLayout()->GetCursorOfst( &aPos, aPt );
105  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
106  std::pair<Point, bool> const tmp(*pPt, true);
107  pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
108  }
109  else
110  {
111  const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
112  if( bOldCallbackActionEnabled )
113  GetLayout()->SetCallbackActionEnabled( false );
114  pFrame = GetCurrFrame();
115  if( bOldCallbackActionEnabled )
116  GetLayout()->SetCallbackActionEnabled( true );
117  }
118  }
119 
120  if( !pFrame )
121  return GetLayout()->getFrameArea();
122 
123  bool bFrame = true;
124  switch ( eType )
125  {
126  case CurRectType::PagePrt: bFrame = false;
127  [[fallthrough]];
128  case CurRectType::Page : pFrame = pFrame->FindPageFrame();
129  break;
130 
132  {
133  DisableCallbackAction a(const_cast<SwRootFrame&>(*pFrame->getRootFrame()));
134  pFrame->Calc(Imp()->GetShell()->GetOut());
135  pFrame = pFrame->FindPageFrame();
136  pFrame->Calc(Imp()->GetShell()->GetOut());
137  }
138  break;
139 
141  bFrame = false;
142  [[fallthrough]];
144  {
145  const SwFrame *pFlyFrame = xObj.is() ? FindFlyFrame(xObj) : nullptr;
146  pFrame = pFlyFrame ? pFlyFrame
147  : pFrame->IsFlyFrame()
148  ? pFrame
149  : pFrame->FindFlyFrame();
150  break;
151  }
153  if( pFrame->IsInTab() )
154  pFrame = pFrame->FindTabFrame();
155  else {
156  OSL_FAIL( "Missing Table" );
157  }
158  [[fallthrough]];
161  if( pFrame->IsInSct() )
162  pFrame = pFrame->FindSctFrame();
163  else {
164  OSL_FAIL( "Missing section" );
165  }
166 
167  if( CurRectType::SectionPrt == eType )
168  bFrame = false;
169  break;
170 
172  if( nullptr == (pFrame = pFrame->FindFooterOrHeader()) )
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( 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()->GetCursorOfst( &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  ::o3tl::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  //if we succeeded in putting a caption on the content, and the
505  //content was a frame/graphic, then set the contained element
506  //to as-char anchoring because that's all msword is able to
507  //do when inside a frame, and in writer for freshly captioned
508  //elements it's largely irrelevant what the anchor of the contained
509  //type is but making it as-char by default results in very
510  //good roundtripping
511  if (pFlyFormat && bInnerCntIsFly)
512  {
513  SwNodeIndex aAnchIdx(*pFlyFormat->GetContent().GetContentIdx(), 1);
514  SwTextNode *pTextNode = aAnchIdx.GetNode().GetTextNode();
515 
516  SwFormatAnchor aAnc(RndStdIds::FLY_AS_CHAR);
517  sal_Int32 nInsertPos = bBefore ? pTextNode->Len() : 0;
518  SwPosition aPos(*pTextNode, nInsertPos);
519 
520  aAnc.SetAnchor(&aPos);
521 
522  SwFlyFrame *pFly = GetSelectedOrCurrFlyFrame();
523  OSL_ENSURE(pFly, "SetFlyFrameAttr, no Fly selected.");
524  if (pFly)
525  {
526  SfxItemSet aSet(makeItemSetFromFormatAnchor(GetDoc()->GetAttrPool(), aAnc));
527  SwFlyFrameFormat* pInnerFlyFormat = pFly->GetFormat();
528  GetDoc()->SetFlyFrameAttr(*pInnerFlyFormat, aSet);
529  }
530  //put a hard-break after the graphic to keep it separated
531  //from the caption text if the outer frame is resized
532  const sal_Int32 nIndex = bBefore ? nInsertPos : 1;
533  SwIndex aIdx(pTextNode, nIndex);
534  pTextNode->InsertText("\n", aIdx);
535  //set the hard-break to be hidden, otherwise it has
536  //non-zero width in word and so hard-break flows on
537  //the next line, pushing the caption text out of
538  //the frame making the caption apparently disappear
539  SvxCharHiddenItem aHidden(true, RES_CHRATR_HIDDEN);
540  SfxItemSet aSet(GetDoc()->GetAttrPool(), {{aHidden.Which(), aHidden.Which()}});
541  aSet.Put(aHidden);
542  SwPaM aPam(*pTextNode, nIndex, *pTextNode, nIndex + 1);
543  SetAttrSet(aSet, SetAttrMode::DEFAULT, &aPam);
544  }
545  }
546 
547  if (pFlyFormat)
548  {
549  const Point aPt(GetCursorDocPos());
550  if (SwFlyFrame* pFrame = pFlyFormat->GetFrame(&aPt))
551  SelectFlyFrame(*pFrame);
552  }
553  EndUndo();
554  EndAllActionAndCall();
555 
556 }
557 
559 {
560  if( !HasSelection() )
561  return false;
562 
563  SET_CURR_SHELL( this );
564  bool bRet = false;
565  StartAllAction();
566  if(IsTableMode())
567  {
568  // Sort table
569  // check if Point/Mark of current Cursor are in one table
570  SwFrame *pFrame = GetCurrFrame( false );
571  OSL_ENSURE( pFrame->FindTabFrame(), "Cursor not in table." );
572 
573  // search boxes via the layout
574  SwSelBoxes aBoxes;
575  GetTableSel(*this, aBoxes);
576 
577  // The Cursor should be removed from the deletion area.
578  // Always put them behind/on the table; via the
579  // document position they will always be set to the old position
580  while( !pFrame->IsCellFrame() )
581  pFrame = pFrame->GetUpper();
582  {
583  /* ParkCursor->ParkCursorTab */
584  ParkCursorInTab();
585  }
586 
587  // call sorting on document
588  bRet = mxDoc->SortTable(aBoxes, rOpt);
589  }
590  else
591  {
592  // Sort text nothing else
593  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
594  {
595  SwPaM* pPam = &rPaM;
596 
597  SwPosition* pStart = pPam->Start();
598  SwPosition* pEnd = pPam->End();
599 
600  SwNodeIndex aPrevIdx( pStart->nNode, -1 );
601  sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
602  const sal_Int32 nCntStt = pStart->nContent.GetIndex();
603 
604  // Sorting
605  bRet = mxDoc->SortText(*pPam, rOpt);
606 
607  // put selection again
608  pPam->DeleteMark();
609  pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
610  SwContentNode* pCNd = pPam->GetContentNode();
611  sal_Int32 nLen = pCNd->Len();
612  if( nLen > nCntStt )
613  nLen = nCntStt;
614  pPam->GetPoint()->nContent.Assign(pCNd, nLen );
615  pPam->SetMark();
616 
617  pPam->GetPoint()->nNode += nOffset;
618  pCNd = pPam->GetContentNode();
619  pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
620  }
621  }
622 
623  EndAllAction();
624  return bRet;
625 }
626 
628 {
629  SwFrame* pFrame = GetCurrFrame();
630  while (pFrame)
631  {
632  pFrame = pFrame->GetUpper();
633  if (pFrame && pFrame->IsColumnFrame())
634  {
635  return pFrame->IsRightToLeft();
636  }
637  }
638  return false;
639 }
640 
641 sal_uInt16 SwFEShell::GetCurColNum_( const SwFrame *pFrame,
642  SwGetCurColNumPara* pPara )
643 {
644  sal_uInt16 nRet = 0;
645  while ( pFrame )
646  {
647  pFrame = pFrame->GetUpper();
648  if( pFrame && pFrame->IsColumnFrame() )
649  {
650  const SwFrame *pCurFrame = pFrame;
651  do {
652  ++nRet;
653  pFrame = pFrame->GetPrev();
654  } while ( pFrame );
655 
656  if( pPara )
657  {
658  // now search the format, determining the columness
659  pFrame = pCurFrame->GetUpper();
660  while( pFrame )
661  {
663  {
664  pPara->pFrameFormat = static_cast<const SwLayoutFrame*>(pFrame)->GetFormat();
665  pPara->pPrtRect = &pFrame->getFramePrintArea();
666  break;
667  }
668  pFrame = pFrame->GetUpper();
669  }
670  if( !pFrame )
671  {
672  pPara->pFrameFormat = nullptr;
673  pPara->pPrtRect = nullptr;
674  }
675  }
676  break;
677  }
678  }
679  return nRet;
680 }
681 
682 sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
683 {
684  OSL_ENSURE( GetCurrFrame(), "Cursor parked?" );
685  return GetCurColNum_( GetCurrFrame(), pPara );
686 }
687 
688 sal_uInt16 SwFEShell::GetCurOutColNum() const
689 {
690  sal_uInt16 nRet = 0;
691  SwFrame* pFrame = GetCurrFrame();
692  OSL_ENSURE( pFrame, "Cursor parked?" );
693  if( pFrame )
694  {
695  pFrame = pFrame->IsInTab() ? static_cast<SwFrame*>(pFrame->FindTabFrame())
696  : static_cast<SwFrame*>(pFrame->FindSctFrame());
697  OSL_ENSURE( pFrame, "No Tab, no Sect" );
698  if( pFrame )
699  nRet = GetCurColNum_( pFrame, nullptr );
700  }
701  return nRet;
702 }
703 
704 SwFEShell::SwFEShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption *pOptions )
705  : SwEditShell( rDoc, pWindow, pOptions )
706  , m_bCheckForOLEInCaption(false)
707  , m_aPasteListeners(GetPasteMutex())
708  , m_eTableInsertMode(SwTable::SEARCH_NONE)
709  , m_bTableCopied(false)
710 {
711 }
712 
714  : SwEditShell( rShell, pWindow )
715  , m_bCheckForOLEInCaption(false)
716  , m_aPasteListeners(GetPasteMutex())
717  , m_eTableInsertMode(SwTable::SEARCH_NONE)
718  , m_bTableCopied(false)
719 {
720 }
721 
723 {
724 }
725 
726 // #i17567# - adjustments for allowing
727 // negative vertical positions for fly frames anchored to paragraph/to character.
728 // #i22305# - adjustments for option 'Follow text flow'
729 // for to frame anchored objects.
730 // #i22341# - adjustments for vertical alignment at top of line
731 // for to character anchored objects.
733  const RndStdIds _nAnchorId,
734  const sal_Int16 _eHoriRelOrient,
735  const sal_Int16 _eVertRelOrient,
736  const SwPosition* _pToCharContentPos,
737  const bool _bFollowTextFlow,
738  bool _bMirror,
739  Point* _opRef,
740  Size* _opPercent,
741  const SwFormatFrameSize* pFormatFrameSize) const
742 {
743  const SwFrame* pFrame;
744  const SwFlyFrame* pFly;
745  if( _opRef )
746  {
747  pFrame = GetCurrFrame();
748  if( nullptr != ( pFly = pFrame->FindFlyFrame() ) )
749  pFrame = pFly->GetAnchorFrame();
750  }
751  else
752  {
753  pFly = GetSelectedFlyFrame();
754  pFrame = pFly ? pFly->GetAnchorFrame() : GetCurrFrame();
755  }
756 
757  bool bWrapThrough = false;
758  if ( pFly )
759  {
760  SwFlyFrameFormat* pFormat = const_cast<SwFlyFrameFormat*>(pFly->GetFormat());
761  const SwFormatSurround& rSurround = pFormat->GetSurround();
762  bWrapThrough = rSurround.GetSurround() == css::text::WrapTextMode_THROUGH;
763  }
764 
765  const SwPageFrame* pPage = pFrame->FindPageFrame();
766  _bMirror = _bMirror && !pPage->OnRightPage();
767 
768  Point aPos;
769  bool bVertic = false;
770  bool bRTL = false;
771  bool bVerticalL2R = false;
772 
773  if ((RndStdIds::FLY_AT_PAGE == _nAnchorId) || (RndStdIds::FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
774  {
775  const SwFrame* pTmp = pFrame;
776  // #i22305#
777  if ((RndStdIds::FLY_AT_PAGE == _nAnchorId) ||
778  ((RndStdIds::FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
779  {
780  pFrame = pPage;
781  }
782  else
783  {
784  pFrame = pFrame->FindFlyFrame();
785  }
786  if ( !pFrame )
787  pFrame = pTmp;
788  _orRect = pFrame->getFrameArea();
789  SwRectFnSet aRectFnSet(pFrame);
790  bRTL = pFrame->IsRightToLeft();
791  if ( bRTL )
792  aPos = pFrame->getFrameArea().TopRight();
793  else
794  aPos = aRectFnSet.GetPos(pFrame->getFrameArea());
795 
796  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
797  {
798  bVertic = aRectFnSet.IsVert();
799  bVerticalL2R = aRectFnSet.IsVertL2R();
800  _bMirror = false; // no mirroring in vertical environment
801  switch ( _eHoriRelOrient )
802  {
803  case text::RelOrientation::PAGE_RIGHT:
804  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustY(pFrame->getFramePrintArea().Height() );
805  [[fallthrough]];
806  case text::RelOrientation::PRINT_AREA:
807  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustY(pFrame->getFramePrintArea().Top() ); break;
808  default: break;
809  }
810  }
811  else if ( _bMirror )
812  {
813  switch ( _eHoriRelOrient )
814  {
815  case text::RelOrientation::PRINT_AREA:
816  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
817  [[fallthrough]];
818  case text::RelOrientation::PAGE_RIGHT:
819  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break;
820  default: aPos.AdjustX(pFrame->getFrameArea().Width() );
821  }
822  }
823  else if ( bRTL )
824  {
825  switch ( _eHoriRelOrient )
826  {
827  case text::RelOrientation::PRINT_AREA:
828  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
829  [[fallthrough]];
830  case text::RelOrientation::PAGE_LEFT:
831  case text::RelOrientation::FRAME_LEFT: aPos.AdjustX(pFrame->getFramePrintArea().Left() -
832  pFrame->getFrameArea().Width() ); break;
833  default: break;
834  }
835  }
836  else
837  {
838  switch ( _eHoriRelOrient )
839  {
840  case text::RelOrientation::PAGE_RIGHT:
841  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
842  [[fallthrough]];
843  case text::RelOrientation::PRINT_AREA:
844  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break;
845  default:break;
846  }
847  }
848 
849  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
850  {
851  switch ( _eVertRelOrient )
852  {
853  case text::RelOrientation::PRINT_AREA:
854  case text::RelOrientation::PAGE_PRINT_AREA:
855  {
856  aPos.AdjustX( -(pFrame->GetRightMargin()) );
857  }
858  break;
859  }
860  }
861  else if ( aRectFnSet.IsVertL2R() )
862  {
863  switch ( _eVertRelOrient )
864  {
865  case text::RelOrientation::PRINT_AREA:
866  case text::RelOrientation::PAGE_PRINT_AREA:
867  {
868  aPos.AdjustX(pFrame->GetLeftMargin() );
869  }
870  break;
871  }
872  }
873  else
874  {
875  switch ( _eVertRelOrient )
876  {
877  case text::RelOrientation::PRINT_AREA:
878  case text::RelOrientation::PAGE_PRINT_AREA:
879  {
880  if ( pFrame->IsPageFrame() )
881  {
882  aPos.setY(
883  static_cast<const SwPageFrame*>(pFrame)->PrtWithoutHeaderAndFooter().Top() );
884  }
885  else
886  {
887  aPos.AdjustY(pFrame->getFramePrintArea().Top() );
888  }
889  }
890  break;
891  }
892  }
893  if ( _opPercent )
894  *_opPercent = pFrame->getFramePrintArea().SSize();
895  }
896  else
897  {
898  const SwFrame* pUpper = ( pFrame->IsPageFrame() || pFrame->IsFlyFrame() ) ?
899  pFrame : pFrame->GetUpper();
900  SwRectFnSet aRectFnSet(pUpper);
901  if ( _opPercent )
902  {
903  // If the size is relative from page, then full size should be counted from the page frame.
904  if (pFormatFrameSize && pFormatFrameSize->GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
905  _opPercent->setWidth(pPage->getFrameArea().Width());
906  else
907  _opPercent->setWidth(pUpper->getFramePrintArea().Width());
908 
909  if (pFormatFrameSize && pFormatFrameSize->GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
910  // If the size is relative from page, then full size should be counted from the page frame.
911  _opPercent->setHeight(pPage->getFrameArea().Height());
912  else
913  _opPercent->setHeight(pUpper->getFramePrintArea().Height());
914  }
915 
916  bRTL = pFrame->IsRightToLeft();
917  if ( bRTL )
918  aPos = pFrame->getFrameArea().TopRight();
919  else
920  aPos = aRectFnSet.GetPos(pFrame->getFrameArea());
921  // #i17567# - allow negative positions
922  // for fly frames anchor to paragraph/to character.
923  if ((_nAnchorId == RndStdIds::FLY_AT_PARA) || (_nAnchorId == RndStdIds::FLY_AT_CHAR))
924  {
925  // The rectangle, the fly frame can be positioned in, is determined
926  // horizontally by the frame area of the horizontal environment
927  // and vertically by the printing area of the vertical environment,
928  // if the object follows the text flow, or by the frame area of the
929  // vertical environment, if the object doesn't follow the text flow.
930  // new class <SwEnvironmentOfAnchoredObject>
932  _bFollowTextFlow );
933  const SwLayoutFrame& rHoriEnvironLayFrame =
934  aEnvOfObj.GetHoriEnvironmentLayoutFrame( *pFrame );
935  const SwLayoutFrame& rVertEnvironLayFrame =
936  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pFrame );
937  const SwRect& aHoriEnvironRect( rHoriEnvironLayFrame.getFrameArea() );
938  SwRect aVertEnvironRect;
939  if ( _bFollowTextFlow )
940  {
941  aVertEnvironRect = rVertEnvironLayFrame.getFramePrintArea();
942  aVertEnvironRect.Pos() += rVertEnvironLayFrame.getFrameArea().Pos();
943  // #i18732# - adjust vertical 'virtual' anchor position
944  // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
945  // to page areas.
946  if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
947  {
948  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
949  {
950  aPos.setX( aVertEnvironRect.Right() );
951  }
952  else if ( aRectFnSet.IsVertL2R() )
953  {
954  aPos.setX( aVertEnvironRect.Left() );
955  }
956  else
957  {
958  aPos.setY( aVertEnvironRect.Top() );
959  }
960  }
961  }
962  else
963  {
964  OSL_ENSURE( rVertEnvironLayFrame.IsPageFrame(),
965  "<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
966  aVertEnvironRect = rVertEnvironLayFrame.getFrameArea();
967  // #i18732# - adjustment vertical 'virtual' anchor position
968  // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
969  // to page areas.
970  if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
971  {
972  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
973  {
974  aPos.setX( aVertEnvironRect.Right() );
975  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
976  {
977  aPos.setX(aPos.getX() - rVertEnvironLayFrame.GetRightMargin());
978  }
979  }
980  else if ( aRectFnSet.IsVertL2R() )
981  {
982  aPos.setX( aVertEnvironRect.Left() );
983  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
984  {
985  aPos.setX(aPos.getX() + rVertEnvironLayFrame.GetLeftMargin());
986  }
987  }
988  else
989  {
990  aPos.setY( aVertEnvironRect.Top() );
991  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
992  {
993  aPos.setY(aPos.getY() + rVertEnvironLayFrame.GetTopMargin());
994  // add height of page header
995  const SwFrame* pTmpFrame = rVertEnvironLayFrame.Lower();
996  if ( pTmpFrame->IsHeaderFrame() )
997  {
998  aPos.setY(aPos.getY() + pTmpFrame->getFrameArea().Height());
999  }
1000  }
1001  }
1002  }
1003  }
1004 
1005  // #i22341# - adjust vertical 'virtual' anchor position
1006  // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
1007  // character and vertical aligned at character or top of line
1008  // <pFrame>, which is the anchor frame or the proposed anchor frame,
1009  // doesn't have to be a text frame (e.g. edit a to-page anchored
1010  // fly frame). Thus, assure this.
1011  const SwTextFrame* pTextFrame( dynamic_cast<const SwTextFrame*>(pFrame) );
1012  if ( pTextFrame &&
1013  (_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
1014  ( _eVertRelOrient == text::RelOrientation::CHAR ||
1015  _eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
1016  {
1017  SwTwips nTop = 0;
1018  if ( _eVertRelOrient == text::RelOrientation::CHAR )
1019  {
1020  SwRect aChRect;
1021  if ( _pToCharContentPos )
1022  {
1023  pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
1024  }
1025  else
1026  {
1027  // No content position provided. Thus, use a default one.
1028  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1029  pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
1030  }
1031  nTop = aRectFnSet.GetBottom(aChRect);
1032  }
1033  else
1034  {
1035  if ( _pToCharContentPos )
1036  {
1037  pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos );
1038  }
1039  else
1040  {
1041  // No content position provided. Thus, use a default one.
1042  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1043  pTextFrame->GetTopOfLine( nTop, aDefaultContentPos );
1044  }
1045  }
1046  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1047  {
1048  aPos.setX(nTop);
1049  }
1050  else
1051  {
1052  aPos.setY(nTop);
1053  }
1054  }
1055 
1056  // #i26945# - adjust horizontal 'virtual' anchor
1057  // position (<aPos.X()> respectively <aPos.Y()>), if object is
1058  // anchored to character and horizontal aligned at character.
1059  if ( pTextFrame &&
1060  (_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
1061  _eHoriRelOrient == text::RelOrientation::CHAR )
1062  {
1063  SwTwips nLeft = 0;
1064  SwRect aChRect;
1065  if ( _pToCharContentPos )
1066  {
1067  pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
1068  }
1069  else
1070  {
1071  // No content position provided. Thus, use a default one.
1072  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1073  pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
1074  }
1075  nLeft = aRectFnSet.GetLeft(aChRect);
1076  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1077  {
1078  aPos.setY(nLeft);
1079  }
1080  else
1081  {
1082  aPos.setX(nLeft);
1083  }
1084  }
1085  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1086  {
1087  _orRect = SwRect( aVertEnvironRect.Left(),
1088  aHoriEnvironRect.Top(),
1089  aVertEnvironRect.Width(),
1090  aHoriEnvironRect.Height() );
1091  }
1092  else
1093  {
1094  _orRect = SwRect( aHoriEnvironRect.Left(),
1095  aVertEnvironRect.Top(),
1096  aHoriEnvironRect.Width(),
1097  aVertEnvironRect.Height() );
1098  }
1099  }
1100  else
1101  {
1102  if( _opRef && pFly && pFly->IsFlyInContentFrame() )
1103  *_opRef = static_cast<const SwFlyInContentFrame*>( pFly )->GetRefPoint();
1104 
1105  _orRect = pUpper->getFrameArea();
1106  if( !pUpper->IsBodyFrame() )
1107  {
1108  _orRect += pUpper->getFramePrintArea().Pos();
1109  _orRect.SSize( pUpper->getFramePrintArea().SSize() );
1110  if ( pUpper->IsCellFrame() )//MA_FLY_HEIGHT
1111  {
1112  const SwFrame* pTab = pUpper->FindTabFrame();
1113  long nBottom = aRectFnSet.GetPrtBottom(*pTab->GetUpper());
1114  aRectFnSet.SetBottom( _orRect, nBottom );
1115  }
1116  }
1117  // only use 90% of height for character bound
1118  {
1119  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1120  _orRect.Width( (_orRect.Width()*9)/10 );
1121  else
1122  _orRect.Height( (_orRect.Height()*9)/10 );
1123  }
1124  }
1125 
1126  const SwTwips nBaseOfstForFly = ( pFrame->IsTextFrame() && pFly ) ?
1127  static_cast<const SwTextFrame*>(pFrame)->GetBaseOfstForFly( !bWrapThrough ) :
1128  0;
1129  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1130  {
1131  bVertic = aRectFnSet.IsVert();
1132  bVerticalL2R = aRectFnSet.IsVertL2R();
1133  _bMirror = false;
1134 
1135  switch ( _eHoriRelOrient )
1136  {
1137  case text::RelOrientation::FRAME_RIGHT:
1138  {
1139  aPos.setY(aPos.getY() + pFrame->getFramePrintArea().Height());
1140  aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
1141  break;
1142  }
1143  case text::RelOrientation::PRINT_AREA:
1144  {
1145  aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
1146  aPos.setY(aPos.getY() + nBaseOfstForFly);
1147  break;
1148  }
1149  case text::RelOrientation::PAGE_RIGHT:
1150  {
1151  aPos.setY(pPage->getFrameArea().Top() + pPage->getFramePrintArea().Bottom());
1152  break;
1153  }
1154  case text::RelOrientation::PAGE_PRINT_AREA:
1155  {
1156  aPos.setY(pPage->getFrameArea().Top() + pPage->getFramePrintArea().Top());
1157  break;
1158  }
1159  case text::RelOrientation::PAGE_LEFT:
1160  case text::RelOrientation::PAGE_FRAME:
1161  {
1162  aPos.setY(pPage->getFrameArea().Top());
1163  break;
1164  }
1165  case text::RelOrientation::FRAME:
1166  {
1167  aPos.setY(aPos.getY() + nBaseOfstForFly);
1168  break;
1169  }
1170  default: break;
1171  }
1172  }
1173  else if( _bMirror )
1174  {
1175  switch ( _eHoriRelOrient )
1176  {
1177  case text::RelOrientation::FRAME_RIGHT: aPos.setX(aPos.getX() + pFrame->getFramePrintArea().Left()); break;
1178  case text::RelOrientation::FRAME:
1179  case text::RelOrientation::FRAME_LEFT: aPos.setX(aPos.getX() + pFrame->getFrameArea().Width()); break;
1180  case text::RelOrientation::PRINT_AREA: aPos.setX(aPos.getX() + pFrame->getFramePrintArea().Right()); break;
1181  case text::RelOrientation::PAGE_LEFT:
1182  case text::RelOrientation::PAGE_FRAME: aPos.setX(pPage->getFrameArea().Right()); break;
1183  case text::RelOrientation::PAGE_PRINT_AREA: aPos.setX(pPage->getFrameArea().Left()
1184  + pPage->getFramePrintArea().Left()); break;
1185  default: break;
1186  }
1187  }
1188  else if ( bRTL )
1189  {
1190  switch ( _eHoriRelOrient )
1191  {
1192  case text::RelOrientation::FRAME_LEFT:
1193  aPos.setX(pFrame->getFrameArea().Left() +
1194  pFrame->getFramePrintArea().Left());
1195  break;
1196 
1197  case text::RelOrientation::PRINT_AREA:
1198  aPos.setX(pFrame->getFrameArea().Left() + pFrame->getFramePrintArea().Left() +
1199  pFrame->getFramePrintArea().Width());
1200  aPos.setX(aPos.getX() + nBaseOfstForFly);
1201  break;
1202 
1203  case text::RelOrientation::PAGE_LEFT:
1204  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left());
1205  break;
1206 
1207  case text::RelOrientation::PAGE_PRINT_AREA:
1208  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left() +
1209  pPage->getFramePrintArea().Width());
1210  break;
1211 
1212  case text::RelOrientation::PAGE_RIGHT:
1213  case text::RelOrientation::PAGE_FRAME:
1214  aPos.setX(pPage->getFrameArea().Right());
1215  break;
1216 
1217  case text::RelOrientation::FRAME:
1218  aPos.setX(aPos.getX() + nBaseOfstForFly);
1219  break;
1220  default: break;
1221  }
1222  }
1223  else
1224  {
1225  switch ( _eHoriRelOrient )
1226  {
1227  case text::RelOrientation::FRAME_RIGHT:
1228  aPos.AdjustX(pFrame->getFramePrintArea().Width() );
1229  aPos += pFrame->getFramePrintArea().Pos();
1230  break;
1231  case text::RelOrientation::PRINT_AREA:
1232  aPos += pFrame->getFramePrintArea().Pos();
1233  aPos.setX(aPos.getX() + nBaseOfstForFly);
1234  break;
1235  case text::RelOrientation::PAGE_RIGHT:
1236  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Right());
1237  break;
1238  case text::RelOrientation::PAGE_PRINT_AREA:
1239  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left());
1240  break;
1241  case text::RelOrientation::PAGE_LEFT:
1242  case text::RelOrientation::PAGE_FRAME:
1243  aPos.setX(pPage->getFrameArea().Left());
1244  break;
1245  case text::RelOrientation::FRAME:
1246  aPos.setX(aPos.getX() + nBaseOfstForFly);
1247  break;
1248  default: break;
1249  }
1250  }
1251 
1252  }
1253  if( !_opRef )
1254  {
1255  if( bVertic && !bVerticalL2R )
1256  _orRect.Pos( aPos.getX() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.getY() );
1257  else if( bVerticalL2R )
1258  _orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
1259  else if ( bRTL )
1260  _orRect.Pos( - ( _orRect.Right() - aPos.getX() ), _orRect.Top() - aPos.getY() );
1261  else
1262  _orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
1263  if( _bMirror )
1264  _orRect.Pos( -_orRect.Right(), _orRect.Top() );
1265  }
1266 }
1267 
1269 {
1270  Size aRet;
1271  SwFlyFrame *pFly = GetSelectedFlyFrame();
1272  if ( pFly )
1273  {
1274  // #i32951# - due to issue #i28701# no format of a
1275  // newly inserted Writer fly frame or its anchor frame is performed
1276  // any more. Thus, it could be possible (e.g. on insert of a horizontal
1277  // line) that the anchor frame isn't formatted and its printing area
1278  // size is (0,0). If this is the case the printing area of the upper
1279  // of the anchor frame is taken.
1280  const SwFrame* pAnchorFrame = pFly->GetAnchorFrame();
1281  aRet = pAnchorFrame->getFramePrintArea().SSize();
1282  if ( aRet.Width() == 0 && aRet.Height() == 0 &&
1283  pAnchorFrame->GetUpper() )
1284  {
1285  aRet = pAnchorFrame->GetUpper()->getFramePrintArea().SSize();
1286  }
1287 
1288  SwRect aBound;
1289  CalcBoundRect( aBound, pFly->GetFormat()->GetAnchor().GetAnchorId());
1290  if ( pFly->GetAnchorFrame()->IsVertical() )
1291  aRet.setWidth( aBound.Width() );
1292  else
1293  aRet.setHeight( aBound.Height() );
1294  }
1295  return aRet;
1296 }
1297 
1298 bool SwFEShell::IsFrameVertical(const bool bEnvironment, bool& bRTL, bool& bVertL2R) const
1299 {
1300  bool bVert = false;
1301  bRTL = false;
1302  bVertL2R = false;
1303 
1304  if ( Imp()->HasDrawView() )
1305  {
1306  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1307  if( rMrkList.GetMarkCount() != 1 )
1308  return bVert;
1309 
1310  SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1311  if ( !pObj )
1312  {
1313  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation" );
1314  return bVert;
1315  }
1316  // #i26791#
1317  SwContact* pContact = GetUserCall( pObj );
1318  if ( !pContact )
1319  {
1320  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SwContact instance at marked object -> This is a serious situation" );
1321  return bVert;
1322  }
1323  const SwFrame* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrame();
1324  if ( !pRef )
1325  {
1326  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing anchor frame at marked object -> This is a serious situation" );
1327  return bVert;
1328  }
1329 
1330  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr && !bEnvironment )
1331  pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
1332 
1333  bVert = pRef->IsVertical();
1334  bRTL = pRef->IsRightToLeft();
1335  bVertL2R = pRef->IsVertLR();
1336  }
1337 
1338  return bVert;
1339 }
1340 
1342 {
1343  // does not do anything, only avoids crash if the method is used for wrong shell
1344 }
1345 
1347 {
1348  // Clear objects selection
1349  if ( Imp()->GetDrawView()->AreObjectsMarked() )
1350  {
1351  Imp()->GetDrawView()->UnmarkAll();
1352  ClearMark();
1353  }
1354 
1356 }
1357 
1358 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void ShellGetFocus()
Definition: fews.cxx:308
OUString GetNumStr(sal_Int32 nNo) const
long Width() const
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:547
SAL_DLLPRIVATE void EndAllActionAndCall()
Terminate actions for all shells and call ChangeLink.
Definition: fews.cxx:69
void FrameNotify(SwViewShell *pVwSh, FlyMode eMode)
Definition: edtwin3.cxx: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:295
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:149
virtual sal_Int32 Len() const
Definition: node.cxx:1180
void DeleteMark()
Definition: pam.hxx:177
sal_Int32 nIndex
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1359
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2810
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:937
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:943
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
long AdjustX(long nHorzMove)
long Height() const
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:1341
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:90
SwFrameType GetType() const
Definition: frame.hxx:498
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
sal_uIntPtr sal_uLong
sal_uInt16 GetCurColNum(SwGetCurColNumPara *pPara=nullptr) const
The ruler needs some information too.
Definition: fews.cxx:682
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
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:1147
Definition: doc.hxx:185
void ShellLoseFocus()
Definition: crsrsh.cxx:2416
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:189
long GetBottom(const SwRect &rRect) const
Definition: frame.hxx:1354
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:1343
void Pos(const Point &rNew)
Definition: swrect.hxx:167
virtual void Calc(vcl::RenderContext *pRenderContext) const
Definition: trvlfrm.cxx:1791
bool IsCellFrame() const
Definition: frame.hxx:1202
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwContentFrame * FindFirstBodyContent()
Definition: pagefrm.hxx:333
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:659
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:273
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:314
bool IsDirectlyInSection() const
Definition: fews.cxx:230
void EndAllAction()
Definition: edws.cxx:96
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:170
CurRectType
Definition: fesh.hxx:135
static SAL_DLLPRIVATE sal_uInt16 GetCurColNum_(const SwFrame *pFrame, SwGetCurColNumPara *pPara)
Definition: fews.cxx:641
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
bool IsFlyFrame() const
Definition: frame.hxx:1186
long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1386
Rect of current PrtArea of section.
void Top(const long nTop)
Definition: swrect.hxx:202
SwIndex nContent
Definition: pam.hxx:38
const SwRect & getFrameArea() const
Definition: frame.hxx:175
void setX(long nX)
bool IsInTab() const
Definition: frame.hxx:931
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:448
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:1210
Mutex aMutex
bool OnRightPage() const
Definition: frame.hxx:711
const SwFormatSurround & GetSurround(bool=true) const
Definition: fmtsrnd.hxx:66
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
bool IsSctFrame() const
Definition: frame.hxx:1190
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1087
long GetLeft(const SwRect &rRect) const
Definition: frame.hxx:1355
void Right(const long nRight)
Definition: swrect.hxx:198
void UnmarkAll()
void setY(long nY)
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:193
void SetBottom(SwRect &rRect, long nNew) const
Definition: frame.hxx:1363
long getY() const
sal_uInt16 GetVirtPageNum() const
Definition: trvlfrm.cxx:1809
bool IsColumnFrame() const
Definition: frame.hxx:1158
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:259
SdrObject * GetMarkedSdrObj() const
long getX() const
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:447
bool Sort(const SwSortOptions &)
Definition: fews.cxx:558
SwFEShell(SwDoc &rDoc, vcl::Window *pWin, const SwViewOption *pOpt)
Definition: fews.cxx:704
virtual ~SwFEShell() override
Definition: fews.cxx:722
Rect of current PrtArea of page.
Shell * GetShell()
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:148
long AdjustY(long nVertMove)
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:232
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
sal_uInt16 GetPhyPageNum() const
Phy: real page count.
Definition: fews.cxx:334
const SwFrame * Lower() const
Definition: layfrm.hxx:101
int i
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:129
SwContentNode * GetContentNode()
Definition: node.hxx:615
const SdrMarkList & GetMarkedObjectList() const
FlyAnchors.
Definition: fmtanchr.hxx:34
FrameTypeFlags
values can be combined via logical or
Definition: fesh.hxx:62
Size GetGraphicDefaultSize() const
Definition: fews.cxx:1268
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
void SetNumOffset(const ::o3tl::optional< sal_uInt16 > &oNum)
Definition: fmtpdsc.hxx:66
Marks a character position inside a document model node.
Definition: index.hxx:37
sal_uInt16 GetPageOffset() const
Definition: fews.cxx:401
css::text::WrapTextMode GetSurround() const
Definition: fmtsrnd.hxx:51
SwFrame * GetPrev()
Definition: frame.hxx:655
#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:1346
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:176
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: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:1091
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:732
sal_Int16 GetHeightPercentRelation() const
Definition: fmtfsize.hxx:89
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
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:627
void Left(const long nLeft)
Definition: swrect.hxx:193
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void Bottom(const long nBottom)
Definition: swrect.hxx:207
bool IsVertLR() const
Definition: frame.hxx:955
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:1298
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:2434
void ToggleHeaderFooterEdit()
Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags.
Definition: viewsh.cxx:103
void ShellGetFocus()
Definition: crsrsh.cxx:2423
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1692
void Width(long nNew)
Definition: swrect.hxx:185
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:688
sal_Int32 GetIndex() const
Definition: index.hxx:95
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:107
Reference< XComponent > mxDoc
... page will be formatted if required.
const SwPosition * End() const
Definition: pam.hxx:217
bool IsRightToLeft() const
Definition: frame.hxx:963
bool IsVertL2R() const
Definition: frame.hxx:1344
bool IsPageFrame() const
Definition: frame.hxx:1154
static SwRewriter CreateRewriter(const OUString &rStr)
Definition: unins.cxx:1008
Rect of current header/footer.
void ClearMark()
Definition: crsrsh.cxx:930
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
const SwRect * pPrtRect
Definition: fesh.hxx:153
void SetPageOffset(sal_uInt16 nOffset)
Changes last page offset.
Definition: fews.cxx:378
Point TopRight() const
Definition: swrect.cxx:175
#define RES_CHRATR_HIDDEN
Definition: hintids.hxx:199
Point GetContentPos(const Point &rPoint, bool bNext) const
Provide information about content situated closes to given Point.
Definition: fews.cxx:84
void InsertLabel(const SwLabelType eType, const OUString &rText, const OUString &rSeparator, const OUString &rNumberSeparator, const bool bBefore, const sal_uInt16 nId, const OUString &rCharacterStyle, const bool bCpyBrd)
Definition: fews.cxx:420
bool IsVertical() const
Definition: frame.hxx:949
const SwFrameFormat * pFrameFormat
Definition: fesh.hxx:152
Rect of current section.
RndStdIds
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:469
const SwFrame * GetAnchorFrame() const
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2062
long GetLeftMargin() const
Definition: ssfrm.cxx:43
bool IsBodyFrame() const
Definition: frame.hxx:1182
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:236
sal_Int16 GetWidthPercentRelation() const
Definition: fmtfsize.hxx:92
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
static void lcl_SetAPageOffset(sal_uInt16 nOffset, SwPageFrame *pPage, SwFEShell *pThis)
Definition: fews.cxx:350
const ::o3tl::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:65
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
bool IsHeaderFrame() const
Definition: frame.hxx:1166
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3052
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1477
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:1075
SwFrame * GetNext()
Definition: frame.hxx:654
void setHeight(long nHeight)