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();
412  if ( oNumOffset )
413  return oNumOffset.get();
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 = LTYPE_DRAW==eType ? nullptr : GetCurrFrame( false );
428  if( LTYPE_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 LTYPE_OBJECT:
441  case LTYPE_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 LTYPE_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 LTYPE_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 {
710 }
711 
713  : SwEditShell( rShell, pWindow )
714  , m_bCheckForOLEInCaption(false)
715  , m_aPasteListeners(GetPasteMutex())
716  , m_eTableInsertMode(SwTable::SEARCH_NONE)
717 {
718 }
719 
721 {
722 }
723 
724 // #i17567# - adjustments for allowing
725 // negative vertical positions for fly frames anchored to paragraph/to character.
726 // #i22305# - adjustments for option 'Follow text flow'
727 // for to frame anchored objects.
728 // #i22341# - adjustments for vertical alignment at top of line
729 // for to character anchored objects.
731  const RndStdIds _nAnchorId,
732  const sal_Int16 _eHoriRelOrient,
733  const sal_Int16 _eVertRelOrient,
734  const SwPosition* _pToCharContentPos,
735  const bool _bFollowTextFlow,
736  bool _bMirror,
737  Point* _opRef,
738  Size* _opPercent,
739  const SwFormatFrameSize* pFormatFrameSize) const
740 {
741  const SwFrame* pFrame;
742  const SwFlyFrame* pFly;
743  if( _opRef )
744  {
745  pFrame = GetCurrFrame();
746  if( nullptr != ( pFly = pFrame->FindFlyFrame() ) )
747  pFrame = pFly->GetAnchorFrame();
748  }
749  else
750  {
751  pFly = GetSelectedFlyFrame();
752  pFrame = pFly ? pFly->GetAnchorFrame() : GetCurrFrame();
753  }
754 
755  bool bWrapThrough = false;
756  if ( pFly )
757  {
758  SwFlyFrameFormat* pFormat = const_cast<SwFlyFrameFormat*>(pFly->GetFormat());
759  const SwFormatSurround& rSurround = pFormat->GetSurround();
760  bWrapThrough = rSurround.GetSurround() == css::text::WrapTextMode_THROUGH;
761  }
762 
763  const SwPageFrame* pPage = pFrame->FindPageFrame();
764  _bMirror = _bMirror && !pPage->OnRightPage();
765 
766  Point aPos;
767  bool bVertic = false;
768  bool bRTL = false;
769  bool bVerticalL2R = false;
770 
771  if ((RndStdIds::FLY_AT_PAGE == _nAnchorId) || (RndStdIds::FLY_AT_FLY == _nAnchorId)) // LAYER_IMPL
772  {
773  const SwFrame* pTmp = pFrame;
774  // #i22305#
775  if ((RndStdIds::FLY_AT_PAGE == _nAnchorId) ||
776  ((RndStdIds::FLY_AT_FLY == _nAnchorId) && !_bFollowTextFlow))
777  {
778  pFrame = pPage;
779  }
780  else
781  {
782  pFrame = pFrame->FindFlyFrame();
783  }
784  if ( !pFrame )
785  pFrame = pTmp;
786  _orRect = pFrame->getFrameArea();
787  SwRectFnSet aRectFnSet(pFrame);
788  bRTL = pFrame->IsRightToLeft();
789  if ( bRTL )
790  aPos = pFrame->getFrameArea().TopRight();
791  else
792  aPos = aRectFnSet.GetPos(pFrame->getFrameArea());
793 
794  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
795  {
796  bVertic = aRectFnSet.IsVert();
797  bVerticalL2R = aRectFnSet.IsVertL2R();
798  _bMirror = false; // no mirroring in vertical environment
799  switch ( _eHoriRelOrient )
800  {
801  case text::RelOrientation::PAGE_RIGHT:
802  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustY(pFrame->getFramePrintArea().Height() );
803  [[fallthrough]];
804  case text::RelOrientation::PRINT_AREA:
805  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustY(pFrame->getFramePrintArea().Top() ); break;
806  default: break;
807  }
808  }
809  else if ( _bMirror )
810  {
811  switch ( _eHoriRelOrient )
812  {
813  case text::RelOrientation::PRINT_AREA:
814  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
815  [[fallthrough]];
816  case text::RelOrientation::PAGE_RIGHT:
817  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break;
818  default: aPos.AdjustX(pFrame->getFrameArea().Width() );
819  }
820  }
821  else if ( bRTL )
822  {
823  switch ( _eHoriRelOrient )
824  {
825  case text::RelOrientation::PRINT_AREA:
826  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
827  [[fallthrough]];
828  case text::RelOrientation::PAGE_LEFT:
829  case text::RelOrientation::FRAME_LEFT: aPos.AdjustX(pFrame->getFramePrintArea().Left() -
830  pFrame->getFrameArea().Width() ); break;
831  default: break;
832  }
833  }
834  else
835  {
836  switch ( _eHoriRelOrient )
837  {
838  case text::RelOrientation::PAGE_RIGHT:
839  case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
840  [[fallthrough]];
841  case text::RelOrientation::PRINT_AREA:
842  case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break;
843  default:break;
844  }
845  }
846 
847  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
848  {
849  switch ( _eVertRelOrient )
850  {
851  case text::RelOrientation::PRINT_AREA:
852  case text::RelOrientation::PAGE_PRINT_AREA:
853  {
854  aPos.AdjustX( -(pFrame->GetRightMargin()) );
855  }
856  break;
857  }
858  }
859  else if ( aRectFnSet.IsVertL2R() )
860  {
861  switch ( _eVertRelOrient )
862  {
863  case text::RelOrientation::PRINT_AREA:
864  case text::RelOrientation::PAGE_PRINT_AREA:
865  {
866  aPos.AdjustX(pFrame->GetLeftMargin() );
867  }
868  break;
869  }
870  }
871  else
872  {
873  switch ( _eVertRelOrient )
874  {
875  case text::RelOrientation::PRINT_AREA:
876  case text::RelOrientation::PAGE_PRINT_AREA:
877  {
878  if ( pFrame->IsPageFrame() )
879  {
880  aPos.setY(
881  static_cast<const SwPageFrame*>(pFrame)->PrtWithoutHeaderAndFooter().Top() );
882  }
883  else
884  {
885  aPos.AdjustY(pFrame->getFramePrintArea().Top() );
886  }
887  }
888  break;
889  }
890  }
891  if ( _opPercent )
892  *_opPercent = pFrame->getFramePrintArea().SSize();
893  }
894  else
895  {
896  const SwFrame* pUpper = ( pFrame->IsPageFrame() || pFrame->IsFlyFrame() ) ?
897  pFrame : pFrame->GetUpper();
898  SwRectFnSet aRectFnSet(pUpper);
899  if ( _opPercent )
900  {
901  // If the size is relative from page, then full size should be counted from the page frame.
902  if (pFormatFrameSize && pFormatFrameSize->GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
903  _opPercent->setWidth(pPage->getFrameArea().Width());
904  else
905  _opPercent->setWidth(pUpper->getFramePrintArea().Width());
906 
907  if (pFormatFrameSize && pFormatFrameSize->GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME)
908  // If the size is relative from page, then full size should be counted from the page frame.
909  _opPercent->setHeight(pPage->getFrameArea().Height());
910  else
911  _opPercent->setHeight(pUpper->getFramePrintArea().Height());
912  }
913 
914  bRTL = pFrame->IsRightToLeft();
915  if ( bRTL )
916  aPos = pFrame->getFrameArea().TopRight();
917  else
918  aPos = aRectFnSet.GetPos(pFrame->getFrameArea());
919  // #i17567# - allow negative positions
920  // for fly frames anchor to paragraph/to character.
921  if ((_nAnchorId == RndStdIds::FLY_AT_PARA) || (_nAnchorId == RndStdIds::FLY_AT_CHAR))
922  {
923  // The rectangle, the fly frame can be positioned in, is determined
924  // horizontally by the frame area of the horizontal environment
925  // and vertically by the printing area of the vertical environment,
926  // if the object follows the text flow, or by the frame area of the
927  // vertical environment, if the object doesn't follow the text flow.
928  // new class <SwEnvironmentOfAnchoredObject>
930  _bFollowTextFlow );
931  const SwLayoutFrame& rHoriEnvironLayFrame =
932  aEnvOfObj.GetHoriEnvironmentLayoutFrame( *pFrame );
933  const SwLayoutFrame& rVertEnvironLayFrame =
934  aEnvOfObj.GetVertEnvironmentLayoutFrame( *pFrame );
935  const SwRect& aHoriEnvironRect( rHoriEnvironLayFrame.getFrameArea() );
936  SwRect aVertEnvironRect;
937  if ( _bFollowTextFlow )
938  {
939  aVertEnvironRect = rVertEnvironLayFrame.getFramePrintArea();
940  aVertEnvironRect.Pos() += rVertEnvironLayFrame.getFrameArea().Pos();
941  // #i18732# - adjust vertical 'virtual' anchor position
942  // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
943  // to page areas.
944  if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
945  {
946  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
947  {
948  aPos.setX( aVertEnvironRect.Right() );
949  }
950  else if ( aRectFnSet.IsVertL2R() )
951  {
952  aPos.setX( aVertEnvironRect.Left() );
953  }
954  else
955  {
956  aPos.setY( aVertEnvironRect.Top() );
957  }
958  }
959  }
960  else
961  {
962  OSL_ENSURE( rVertEnvironLayFrame.IsPageFrame(),
963  "<SwFEShell::CalcBoundRect(..)> - not following text flow, but vertical environment *not* page!" );
964  aVertEnvironRect = rVertEnvironLayFrame.getFrameArea();
965  // #i18732# - adjustment vertical 'virtual' anchor position
966  // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned
967  // to page areas.
968  if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
969  {
970  if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
971  {
972  aPos.setX( aVertEnvironRect.Right() );
973  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
974  {
975  aPos.setX(aPos.getX() - rVertEnvironLayFrame.GetRightMargin());
976  }
977  }
978  else if ( aRectFnSet.IsVertL2R() )
979  {
980  aPos.setX( aVertEnvironRect.Left() );
981  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
982  {
983  aPos.setX(aPos.getX() + rVertEnvironLayFrame.GetLeftMargin());
984  }
985  }
986  else
987  {
988  aPos.setY( aVertEnvironRect.Top() );
989  if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
990  {
991  aPos.setY(aPos.getY() + rVertEnvironLayFrame.GetTopMargin());
992  // add height of page header
993  const SwFrame* pTmpFrame = rVertEnvironLayFrame.Lower();
994  if ( pTmpFrame->IsHeaderFrame() )
995  {
996  aPos.setY(aPos.getY() + pTmpFrame->getFrameArea().Height());
997  }
998  }
999  }
1000  }
1001  }
1002 
1003  // #i22341# - adjust vertical 'virtual' anchor position
1004  // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to
1005  // character and vertical aligned at character or top of line
1006  // <pFrame>, which is the anchor frame or the proposed anchor frame,
1007  // doesn't have to be a text frame (e.g. edit a to-page anchored
1008  // fly frame). Thus, assure this.
1009  const SwTextFrame* pTextFrame( dynamic_cast<const SwTextFrame*>(pFrame) );
1010  if ( pTextFrame &&
1011  (_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
1012  ( _eVertRelOrient == text::RelOrientation::CHAR ||
1013  _eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
1014  {
1015  SwTwips nTop = 0;
1016  if ( _eVertRelOrient == text::RelOrientation::CHAR )
1017  {
1018  SwRect aChRect;
1019  if ( _pToCharContentPos )
1020  {
1021  pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
1022  }
1023  else
1024  {
1025  // No content position provided. Thus, use a default one.
1026  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1027  pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
1028  }
1029  nTop = aRectFnSet.GetBottom(aChRect);
1030  }
1031  else
1032  {
1033  if ( _pToCharContentPos )
1034  {
1035  pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos );
1036  }
1037  else
1038  {
1039  // No content position provided. Thus, use a default one.
1040  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1041  pTextFrame->GetTopOfLine( nTop, aDefaultContentPos );
1042  }
1043  }
1044  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1045  {
1046  aPos.setX(nTop);
1047  }
1048  else
1049  {
1050  aPos.setY(nTop);
1051  }
1052  }
1053 
1054  // #i26945# - adjust horizontal 'virtual' anchor
1055  // position (<aPos.X()> respectively <aPos.Y()>), if object is
1056  // anchored to character and horizontal aligned at character.
1057  if ( pTextFrame &&
1058  (_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
1059  _eHoriRelOrient == text::RelOrientation::CHAR )
1060  {
1061  SwTwips nLeft = 0;
1062  SwRect aChRect;
1063  if ( _pToCharContentPos )
1064  {
1065  pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos );
1066  }
1067  else
1068  {
1069  // No content position provided. Thus, use a default one.
1070  SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
1071  pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
1072  }
1073  nLeft = aRectFnSet.GetLeft(aChRect);
1074  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1075  {
1076  aPos.setY(nLeft);
1077  }
1078  else
1079  {
1080  aPos.setX(nLeft);
1081  }
1082  }
1083  if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1084  {
1085  _orRect = SwRect( aVertEnvironRect.Left(),
1086  aHoriEnvironRect.Top(),
1087  aVertEnvironRect.Width(),
1088  aHoriEnvironRect.Height() );
1089  }
1090  else
1091  {
1092  _orRect = SwRect( aHoriEnvironRect.Left(),
1093  aVertEnvironRect.Top(),
1094  aHoriEnvironRect.Width(),
1095  aVertEnvironRect.Height() );
1096  }
1097  }
1098  else
1099  {
1100  if( _opRef && pFly && pFly->IsFlyInContentFrame() )
1101  *_opRef = static_cast<const SwFlyInContentFrame*>( pFly )->GetRefPoint();
1102 
1103  _orRect = pUpper->getFrameArea();
1104  if( !pUpper->IsBodyFrame() )
1105  {
1106  _orRect += pUpper->getFramePrintArea().Pos();
1107  _orRect.SSize( pUpper->getFramePrintArea().SSize() );
1108  if ( pUpper->IsCellFrame() )//MA_FLY_HEIGHT
1109  {
1110  const SwFrame* pTab = pUpper->FindTabFrame();
1111  long nBottom = aRectFnSet.GetPrtBottom(*pTab->GetUpper());
1112  aRectFnSet.SetBottom( _orRect, nBottom );
1113  }
1114  }
1115  // only use 90% of height for character bound
1116  {
1117  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1118  _orRect.Width( (_orRect.Width()*9)/10 );
1119  else
1120  _orRect.Height( (_orRect.Height()*9)/10 );
1121  }
1122  }
1123 
1124  const SwTwips nBaseOfstForFly = ( pFrame->IsTextFrame() && pFly ) ?
1125  static_cast<const SwTextFrame*>(pFrame)->GetBaseOfstForFly( !bWrapThrough ) :
1126  0;
1127  if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
1128  {
1129  bVertic = aRectFnSet.IsVert();
1130  bVerticalL2R = aRectFnSet.IsVertL2R();
1131  _bMirror = false;
1132 
1133  switch ( _eHoriRelOrient )
1134  {
1135  case text::RelOrientation::FRAME_RIGHT:
1136  {
1137  aPos.setY(aPos.getY() + pFrame->getFramePrintArea().Height());
1138  aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
1139  break;
1140  }
1141  case text::RelOrientation::PRINT_AREA:
1142  {
1143  aPos += aRectFnSet.GetPos(pFrame->getFramePrintArea());
1144  aPos.setY(aPos.getY() + nBaseOfstForFly);
1145  break;
1146  }
1147  case text::RelOrientation::PAGE_RIGHT:
1148  {
1149  aPos.setY(pPage->getFrameArea().Top() + pPage->getFramePrintArea().Bottom());
1150  break;
1151  }
1152  case text::RelOrientation::PAGE_PRINT_AREA:
1153  {
1154  aPos.setY(pPage->getFrameArea().Top() + pPage->getFramePrintArea().Top());
1155  break;
1156  }
1157  case text::RelOrientation::PAGE_LEFT:
1158  case text::RelOrientation::PAGE_FRAME:
1159  {
1160  aPos.setY(pPage->getFrameArea().Top());
1161  break;
1162  }
1163  case text::RelOrientation::FRAME:
1164  {
1165  aPos.setY(aPos.getY() + nBaseOfstForFly);
1166  break;
1167  }
1168  default: break;
1169  }
1170  }
1171  else if( _bMirror )
1172  {
1173  switch ( _eHoriRelOrient )
1174  {
1175  case text::RelOrientation::FRAME_RIGHT: aPos.setX(aPos.getX() + pFrame->getFramePrintArea().Left()); break;
1176  case text::RelOrientation::FRAME:
1177  case text::RelOrientation::FRAME_LEFT: aPos.setX(aPos.getX() + pFrame->getFrameArea().Width()); break;
1178  case text::RelOrientation::PRINT_AREA: aPos.setX(aPos.getX() + pFrame->getFramePrintArea().Right()); break;
1179  case text::RelOrientation::PAGE_LEFT:
1180  case text::RelOrientation::PAGE_FRAME: aPos.setX(pPage->getFrameArea().Right()); break;
1181  case text::RelOrientation::PAGE_PRINT_AREA: aPos.setX(pPage->getFrameArea().Left()
1182  + pPage->getFramePrintArea().Left()); break;
1183  default: break;
1184  }
1185  }
1186  else if ( bRTL )
1187  {
1188  switch ( _eHoriRelOrient )
1189  {
1190  case text::RelOrientation::FRAME_LEFT:
1191  aPos.setX(pFrame->getFrameArea().Left() +
1192  pFrame->getFramePrintArea().Left());
1193  break;
1194 
1195  case text::RelOrientation::PRINT_AREA:
1196  aPos.setX(pFrame->getFrameArea().Left() + pFrame->getFramePrintArea().Left() +
1197  pFrame->getFramePrintArea().Width());
1198  aPos.setX(aPos.getX() + nBaseOfstForFly);
1199  break;
1200 
1201  case text::RelOrientation::PAGE_LEFT:
1202  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left());
1203  break;
1204 
1205  case text::RelOrientation::PAGE_PRINT_AREA:
1206  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left() +
1207  pPage->getFramePrintArea().Width());
1208  break;
1209 
1210  case text::RelOrientation::PAGE_RIGHT:
1211  case text::RelOrientation::PAGE_FRAME:
1212  aPos.setX(pPage->getFrameArea().Right());
1213  break;
1214 
1215  case text::RelOrientation::FRAME:
1216  aPos.setX(aPos.getX() + nBaseOfstForFly);
1217  break;
1218  default: break;
1219  }
1220  }
1221  else
1222  {
1223  switch ( _eHoriRelOrient )
1224  {
1225  case text::RelOrientation::FRAME_RIGHT:
1226  aPos.AdjustX(pFrame->getFramePrintArea().Width() );
1227  aPos += pFrame->getFramePrintArea().Pos();
1228  break;
1229  case text::RelOrientation::PRINT_AREA:
1230  aPos += pFrame->getFramePrintArea().Pos();
1231  aPos.setX(aPos.getX() + nBaseOfstForFly);
1232  break;
1233  case text::RelOrientation::PAGE_RIGHT:
1234  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Right());
1235  break;
1236  case text::RelOrientation::PAGE_PRINT_AREA:
1237  aPos.setX(pPage->getFrameArea().Left() + pPage->getFramePrintArea().Left());
1238  break;
1239  case text::RelOrientation::PAGE_LEFT:
1240  case text::RelOrientation::PAGE_FRAME:
1241  aPos.setX(pPage->getFrameArea().Left());
1242  break;
1243  case text::RelOrientation::FRAME:
1244  aPos.setX(aPos.getX() + nBaseOfstForFly);
1245  break;
1246  default: break;
1247  }
1248  }
1249 
1250  }
1251  if( !_opRef )
1252  {
1253  if( bVertic && !bVerticalL2R )
1254  _orRect.Pos( aPos.getX() - _orRect.Width() - _orRect.Left(), _orRect.Top() - aPos.getY() );
1255  else if( bVerticalL2R )
1256  _orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
1257  else if ( bRTL )
1258  _orRect.Pos( - ( _orRect.Right() - aPos.getX() ), _orRect.Top() - aPos.getY() );
1259  else
1260  _orRect.Pos( _orRect.Left() - aPos.getX(), _orRect.Top() - aPos.getY() );
1261  if( _bMirror )
1262  _orRect.Pos( -_orRect.Right(), _orRect.Top() );
1263  }
1264 }
1265 
1267 {
1268  Size aRet;
1269  SwFlyFrame *pFly = GetSelectedFlyFrame();
1270  if ( pFly )
1271  {
1272  // #i32951# - due to issue #i28701# no format of a
1273  // newly inserted Writer fly frame or its anchor frame is performed
1274  // any more. Thus, it could be possible (e.g. on insert of a horizontal
1275  // line) that the anchor frame isn't formatted and its printing area
1276  // size is (0,0). If this is the case the printing area of the upper
1277  // of the anchor frame is taken.
1278  const SwFrame* pAnchorFrame = pFly->GetAnchorFrame();
1279  aRet = pAnchorFrame->getFramePrintArea().SSize();
1280  if ( aRet.Width() == 0 && aRet.Height() == 0 &&
1281  pAnchorFrame->GetUpper() )
1282  {
1283  aRet = pAnchorFrame->GetUpper()->getFramePrintArea().SSize();
1284  }
1285 
1286  SwRect aBound;
1287  CalcBoundRect( aBound, pFly->GetFormat()->GetAnchor().GetAnchorId());
1288  if ( pFly->GetAnchorFrame()->IsVertical() )
1289  aRet.setWidth( aBound.Width() );
1290  else
1291  aRet.setHeight( aBound.Height() );
1292  }
1293  return aRet;
1294 }
1295 
1296 bool SwFEShell::IsFrameVertical(const bool bEnvironment, bool& bRTL, bool& bVertL2R) const
1297 {
1298  bool bVert = false;
1299  bRTL = false;
1300  bVertL2R = false;
1301 
1302  if ( Imp()->HasDrawView() )
1303  {
1304  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1305  if( rMrkList.GetMarkCount() != 1 )
1306  return bVert;
1307 
1308  SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1309  if ( !pObj )
1310  {
1311  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SdrObject instance in marked object list -> This is a serious situation" );
1312  return bVert;
1313  }
1314  // #i26791#
1315  SwContact* pContact = GetUserCall( pObj );
1316  if ( !pContact )
1317  {
1318  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing SwContact instance at marked object -> This is a serious situation" );
1319  return bVert;
1320  }
1321  const SwFrame* pRef = pContact->GetAnchoredObj( pObj )->GetAnchorFrame();
1322  if ( !pRef )
1323  {
1324  OSL_FAIL( "<SwFEShell::IsFrameVertical(..)> - missing anchor frame at marked object -> This is a serious situation" );
1325  return bVert;
1326  }
1327 
1328  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) != nullptr && !bEnvironment )
1329  pRef = static_cast<const SwVirtFlyDrawObj*>(pObj)->GetFlyFrame();
1330 
1331  bVert = pRef->IsVertical();
1332  bRTL = pRef->IsRightToLeft();
1333  bVertL2R = pRef->IsVertLR();
1334  }
1335 
1336  return bVert;
1337 }
1338 
1340 {
1341  // does not do anything, only avoids crash if the method is used for wrong shell
1342 }
1343 
1345 {
1346  // Clear objects selection
1347  if ( Imp()->GetDrawView()->AreObjectsMarked() )
1348  {
1349  Imp()->GetDrawView()->UnmarkAll();
1350  ClearMark();
1351  }
1352 
1354 }
1355 
1356 /* 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:85
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
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:184
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:1339
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:2408
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:1787
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
void SetNumOffset(const ::boost::optional< sal_uInt16 > &oNum)
Definition: fmtpdsc.hxx:66
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:1805
bool IsColumnFrame() const
Definition: frame.hxx:1158
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:259
SdrObject * GetMarkedSdrObj() const
long getX() const
const ::boost::optional< sal_uInt16 > & GetNumOffset() const
Definition: fmtpdsc.hxx:65
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwTextNode * GetTextNodeFirst()
Definition: txtfrm.hxx:445
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:720
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:141
long AdjustY(long nVertMove)
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:228
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:1266
SwLayoutFrame * GetUpper()
Definition: frame.hxx:656
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:1344
bool GetTopOfLine(SwTwips &_onTopOfLine, const SwPosition &_rPos) const
Determine top of line for given position in the text frame.
Definition: frmcrsr.cxx:454
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:730
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:367
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:1296
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:2426
void ToggleHeaderFooterEdit()
Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags.
Definition: viewsh.cxx:116
void ShellGetFocus()
Definition: crsrsh.cxx:2415
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1688
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
... 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:1013
Rect of current header/footer.
void ClearMark()
Definition: crsrsh.cxx:926
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:106
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:459
const SwFrame * GetAnchorFrame() const
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2075
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
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:1476
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)