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 <cellfrm.hxx>
44 #include <flyfrms.hxx>
45 #include <txtfrm.hxx>
46 #include <mdiexp.hxx>
47 #include <edimp.hxx>
48 #include <pagedesc.hxx>
49 #include <fmtanchr.hxx>
51 #include <ndtxt.hxx>
52 #include <dflyobj.hxx>
53 #include <dcontact.hxx>
54 #include <UndoInsert.hxx>
55 
56 using namespace com::sun::star;
57 
58 namespace
59 {
64 osl::Mutex& GetPasteMutex()
65 {
66  static osl::Mutex aMutex;
67  return aMutex;
68 }
69 }
70 
72 {
73  for(SwViewShell& rCurrentShell : GetRingContainer())
74  {
75  if( dynamic_cast<const SwCursorShell*>( &rCurrentShell) != nullptr )
76  {
77  static_cast<SwFEShell*>(&rCurrentShell)->EndAction();
78  static_cast<SwFEShell*>(&rCurrentShell)->CallChgLnk();
79  }
80  else
81  rCurrentShell.EndAction();
82  }
83 }
84 
85 // Determine the Content's nearest to the point
86 Point SwFEShell::GetContentPos( const Point& rPoint, bool bNext ) const
87 {
88  SET_CURR_SHELL( const_cast<SwFEShell*>(this) );
89  return GetLayout()->GetNextPrevContentPos( rPoint, bNext );
90 }
91 
93  const uno::Reference < embed::XEmbeddedObject >& xObj ) const
94 {
95  const SwFrame *pFrame = Imp()->HasDrawView()
96  ? ::GetFlyFromMarked( &Imp()->GetDrawView()->GetMarkedObjectList(),
97  const_cast<SwFEShell*>(this))
98  : nullptr;
99 
100  if( !pFrame )
101  {
102  if( pPt )
103  {
104  SwPosition aPos( *GetCursor()->GetPoint() );
105  Point aPt( *pPt );
106  GetLayout()->GetCursorOfst( &aPos, aPt );
107  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
108  std::pair<Point, bool> const tmp(*pPt, true);
109  pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
110  }
111  else
112  {
113  const bool bOldCallbackActionEnabled = GetLayout()->IsCallbackActionEnabled();
114  if( bOldCallbackActionEnabled )
115  GetLayout()->SetCallbackActionEnabled( false );
116  pFrame = GetCurrFrame();
117  if( bOldCallbackActionEnabled )
118  GetLayout()->SetCallbackActionEnabled( true );
119  }
120  }
121 
122  if( !pFrame )
123  return GetLayout()->getFrameArea();
124 
125  bool bFrame = true;
126  switch ( eType )
127  {
128  case CurRectType::PagePrt: bFrame = false;
129  [[fallthrough]];
130  case CurRectType::Page : pFrame = pFrame->FindPageFrame();
131  break;
132 
134  {
135  DisableCallbackAction a(const_cast<SwRootFrame&>(*pFrame->getRootFrame()));
136  pFrame->Calc(Imp()->GetShell()->GetOut());
137  pFrame = pFrame->FindPageFrame();
138  pFrame->Calc(Imp()->GetShell()->GetOut());
139  }
140  break;
141 
143  bFrame = false;
144  [[fallthrough]];
146  {
147  const SwFrame *pFlyFrame = xObj.is() ? FindFlyFrame(xObj) : nullptr;
148  pFrame = pFlyFrame ? pFlyFrame
149  : pFrame->IsFlyFrame()
150  ? pFrame
151  : pFrame->FindFlyFrame();
152  break;
153  }
155  if( pFrame->IsInTab() )
156  pFrame = pFrame->FindTabFrame();
157  else {
158  OSL_FAIL( "Missing Table" );
159  }
160  [[fallthrough]];
163  if( pFrame->IsInSct() )
164  pFrame = pFrame->FindSctFrame();
165  else {
166  OSL_FAIL( "Missing section" );
167  }
168 
169  if( CurRectType::SectionPrt == eType )
170  bFrame = false;
171  break;
172 
174  if( nullptr == (pFrame = pFrame->FindFooterOrHeader()) )
175  return GetLayout()->getFrameArea();
176  break;
177 
179  return GetLayout()->GetPagesArea();
180 
181  default: break;
182  }
183  return bFrame ? pFrame->getFrameArea() : pFrame->getFramePrintArea();
184 }
185 
186 sal_uInt16 SwFEShell::GetPageNumber( const Point &rPoint ) const
187 {
188  const SwFrame *pPage = GetLayout()->Lower();
189  while ( pPage && !pPage->getFrameArea().IsInside( rPoint ) )
190  pPage = pPage->GetNext();
191  if ( pPage )
192  return static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum();
193  else
194  return 0;
195 }
196 
197 bool SwFEShell::GetPageNumber( long nYPos, bool bAtCursorPos, sal_uInt16& rPhyNum, sal_uInt16& rVirtNum, OUString &rDisplay) const
198 {
199  const SwFrame *pPage;
200 
201  if ( bAtCursorPos ) // get page of Cursor
202  {
203  pPage = GetCurrFrame( false );
204  if ( pPage )
205  pPage = pPage->FindPageFrame();
206  }
207  else if ( nYPos > -1 ) // determine page via the position
208  {
209  pPage = GetLayout()->Lower();
210  while( pPage && (pPage->getFrameArea().Bottom() < nYPos ||
211  nYPos < pPage->getFrameArea().Top() ) )
212  pPage = pPage->GetNext();
213  }
214  else // first visible page
215  {
216  pPage = Imp()->GetFirstVisPage(GetOut());
217  if ( pPage && static_cast<const SwPageFrame*>(pPage)->IsEmptyPage() )
218  pPage = pPage->GetNext();
219  }
220 
221  if( pPage )
222  {
223  rPhyNum = static_cast<const SwPageFrame*>(pPage)->GetPhyPageNum();
224  rVirtNum = static_cast<const SwPageFrame*>(pPage)->GetVirtPageNum();
225  const SvxNumberType& rNum = static_cast<const SwPageFrame*>(pPage)->GetPageDesc()->GetNumType();
226  rDisplay = rNum.GetNumStr( rVirtNum );
227  }
228 
229  return nullptr != pPage;
230 }
231 
233 {
234  SwFrame* pFrame = GetCurrFrame( false );
235  return pFrame && pFrame->GetUpper() && pFrame->GetUpper()->IsSctFrame();
236 }
237 
238 FrameTypeFlags SwFEShell::GetFrameType( const Point *pPt, bool bStopAtFly ) const
239 {
241  const SwFrame *pFrame;
242  if ( pPt )
243  {
244  SwPosition aPos( *GetCursor()->GetPoint() );
245  Point aPt( *pPt );
246  GetLayout()->GetCursorOfst( &aPos, aPt );
247  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
248  std::pair<Point, bool> const tmp(*pPt, true);
249  pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp);
250  }
251  else
252  pFrame = GetCurrFrame( false );
253  while ( pFrame )
254  {
255  switch ( pFrame->GetType() )
256  {
257  case SwFrameType::Column:
258  if( pFrame->GetUpper()->IsSctFrame() )
259  {
260  // Check, if isn't not only a single column
261  // from a section with footnotes at the end.
262  if( pFrame->GetNext() || pFrame->GetPrev() )
263  // Sectioncolumns
264  nReturn |= ( nReturn & FrameTypeFlags::TABLE ) ?
266  }
267  else // only pages and frame columns
268  nReturn |= FrameTypeFlags::COLUMN;
269  break;
270  case SwFrameType::Page:
271  nReturn |= FrameTypeFlags::PAGE;
272  if( static_cast<const SwPageFrame*>(pFrame)->IsFootnotePage() )
273  nReturn |= FrameTypeFlags::FTNPAGE;
274  break;
275  case SwFrameType::Header: nReturn |= FrameTypeFlags::HEADER; break;
276  case SwFrameType::Footer: nReturn |= FrameTypeFlags::FOOTER; break;
277  case SwFrameType::Body:
278  if( pFrame->GetUpper()->IsPageFrame() ) // not for ColumnFrames
279  nReturn |= FrameTypeFlags::BODY;
280  break;
281  case SwFrameType::Ftn: nReturn |= FrameTypeFlags::FOOTNOTE; break;
282  case SwFrameType::Fly:
283  if( static_cast<const SwFlyFrame*>(pFrame)->IsFlyLayFrame() )
284  nReturn |= FrameTypeFlags::FLY_FREE;
285  else if ( static_cast<const SwFlyFrame*>(pFrame)->IsFlyAtContentFrame() )
286  nReturn |= FrameTypeFlags::FLY_ATCNT;
287  else
288  {
289  OSL_ENSURE( static_cast<const SwFlyFrame*>(pFrame)->IsFlyInContentFrame(),
290  "New frametype?" );
291  nReturn |= FrameTypeFlags::FLY_INCNT;
292  }
293  nReturn |= FrameTypeFlags::FLY_ANY;
294  if( bStopAtFly )
295  return nReturn;
296  break;
297  case SwFrameType::Tab:
298  case SwFrameType::Row:
299  case SwFrameType::Cell: nReturn |= FrameTypeFlags::TABLE; break;
300  default: /* do nothing */ break;
301  }
302  if ( pFrame->IsFlyFrame() )
303  pFrame = static_cast<const SwFlyFrame*>(pFrame)->GetAnchorFrame();
304  else
305  pFrame = pFrame->GetUpper();
306  }
307  return nReturn;
308 }
309 
311 {
312  ::SetShell( this );
314 
315  if ( HasDrawView() )
316  {
318  Imp()->GetDrawView()->showMarkHandles();
319  if ( Imp()->GetDrawView()->AreObjectsMarked() )
320  FrameNotify( this, FLY_DRAG_START );
321  }
322 }
323 
325 {
327 
328  if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
329  {
331  Imp()->GetDrawView()->hideMarkHandles();
332  FrameNotify( this, FLY_DRAG_END );
333  }
334 }
335 
337 {
338  SwFrame *pFrame = GetCurrFrame();
339  if ( pFrame )
340  return pFrame->GetPhyPageNum();
341  return 0;
342 }
343 
345 {
346  SwFrame *pFrame = GetCurrFrame();
347  if ( pFrame )
348  return pFrame->GetVirtPageNum();
349  return 0;
350 }
351 
352 static void lcl_SetAPageOffset( sal_uInt16 nOffset, SwPageFrame* pPage, SwFEShell* pThis )
353 {
354  pThis->StartAllAction();
355  OSL_ENSURE( pPage->FindFirstBodyContent(),
356  "SwFEShell _SetAPageOffset() without ContentFrame" );
357 
358  SwFormatPageDesc aDesc( pPage->GetPageDesc() );
359  aDesc.SetNumOffset( nOffset );
360 
361  SwFrame *pFrame = pThis->GetCurrFrame( false );
362  if ( pFrame->IsInTab() )
363  pThis->GetDoc()->SetAttr( aDesc, *pFrame->FindTabFrame()->GetFormat() );
364  else
365  {
367  *pThis->GetCursor(), aDesc, SetAttrMode::DEFAULT, pThis->GetLayout());
368  }
369 
370  pThis->EndAllAction();
371 }
372 
373 void SwFEShell::SetNewPageOffset( sal_uInt16 nOffset )
374 {
375  GetLayout()->SetVirtPageNum( true );
376  const SwPageFrame *pPage = GetCurrFrame( false )->FindPageFrame();
377  lcl_SetAPageOffset( nOffset, const_cast<SwPageFrame*>(pPage), this );
378 }
379 
380 void SwFEShell::SetPageOffset( sal_uInt16 nOffset )
381 {
382  const SwPageFrame *pPage = GetCurrFrame( false )->FindPageFrame();
383  const SwRootFrame* pDocLayout = GetLayout();
384  while ( pPage )
385  {
386  const SwFrame *pFlow = pPage->FindFirstBodyContent();
387  if ( pFlow )
388  {
389  if ( pFlow->IsInTab() )
390  pFlow = pFlow->FindTabFrame();
391  const SwFormatPageDesc& rPgDesc = pFlow->GetPageDescItem();
392  if ( rPgDesc.GetNumOffset() )
393  {
394  pDocLayout->SetVirtPageNum( true );
395  lcl_SetAPageOffset( nOffset, const_cast<SwPageFrame*>(pPage), this );
396  break;
397  }
398  }
399  pPage = static_cast<const SwPageFrame*>(pPage->GetPrev());
400  }
401 }
402 
403 sal_uInt16 SwFEShell::GetPageOffset() const
404 {
405  const SwPageFrame *pPage = GetCurrFrame()->FindPageFrame();
406  while ( pPage )
407  {
408  const SwFrame *pFlow = pPage->FindFirstBodyContent();
409  if ( pFlow )
410  {
411  if ( pFlow->IsInTab() )
412  pFlow = pFlow->FindTabFrame();
414  if ( oNumOffset )
415  return oNumOffset.get();
416  }
417  pPage = static_cast<const SwPageFrame*>(pPage->GetPrev());
418  }
419  return 0;
420 }
421 
422 void SwFEShell::InsertLabel( const SwLabelType eType, const OUString &rText, const OUString& rSeparator,
423  const OUString& rNumberSeparator,
424  const bool bBefore, const sal_uInt16 nId,
425  const OUString& rCharacterStyle,
426  const bool bCpyBrd )
427 {
428  // get node index of cursor position, SwDoc can do everything else itself
429  SwContentFrame *pCnt = LTYPE_DRAW==eType ? nullptr : GetCurrFrame( false );
430  if( LTYPE_DRAW!=eType && !pCnt )
431  return;
432 
433  StartAllAction();
435  StartUndo(SwUndoId::INSERTLABEL, &aRewriter);
436 
437  sal_uLong nIdx = 0;
438  bool bInnerCntIsFly = false;
439  SwFlyFrameFormat* pFlyFormat = nullptr;
440  switch( eType )
441  {
442  case LTYPE_OBJECT:
443  case LTYPE_FLY:
444  bInnerCntIsFly = pCnt->IsInFly();
445  if (bInnerCntIsFly)
446  {
447  // pass down index to the startnode for flys
448  nIdx = pCnt->FindFlyFrame()->
449  GetFormat()->GetContent().GetContentIdx()->GetIndex();
450  }
451  break;
452  case LTYPE_TABLE:
453  if( pCnt->IsInTab() )
454  {
455  // pass down index to the TableNode for tables
456  const SwTable& rTable = *pCnt->FindTabFrame()->GetTable();
457  nIdx = rTable.GetTabSortBoxes()[ 0 ]
458  ->GetSttNd()->FindTableNode()->GetIndex();
459  }
460  break;
461  case LTYPE_DRAW:
462  if( Imp()->GetDrawView() )
463  {
464  SwDrawView *pDView = Imp()->GetDrawView();
465  const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
466 
467  // copy marked drawing objects to
468  // local list to perform the corresponding action for each object
469  std::vector<SdrObject*> aDrawObjs;
470  {
471  for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
472  {
473  SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj();
474  if( pDrawObj )
475  aDrawObjs.push_back( pDrawObj );
476  }
477  }
478  // loop on marked drawing objects
479  while ( !aDrawObjs.empty() )
480  {
481  SdrObject* pDrawObj = aDrawObjs.back();
482  if ( dynamic_cast<const SwVirtFlyDrawObj*>( pDrawObj) == nullptr &&
483  dynamic_cast<const SwFlyDrawObj*>( pDrawObj) == nullptr )
484  {
485  SwFlyFrameFormat *pFormat =
486  GetDoc()->InsertDrawLabel( rText, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj );
487  if( !pFlyFormat )
488  pFlyFormat = pFormat;
489  }
490 
491  aDrawObjs.pop_back();
492  }
493 
494  }
495  break;
496  default:
497  OSL_ENSURE( false, "Cursor neither in table nor in fly." );
498  }
499 
500  if( nIdx )
501  {
502  pFlyFormat = GetDoc()->InsertLabel(eType, rText, rSeparator,
503  rNumberSeparator, bBefore, nId,
504  nIdx, rCharacterStyle, bCpyBrd);
505 
506  //if we succeeded in putting a caption on the content, and the
507  //content was a frame/graphic, then set the contained element
508  //to as-char anchoring because that's all msword is able to
509  //do when inside a frame, and in writer for freshly captioned
510  //elements it's largely irrelevant what the anchor of the contained
511  //type is but making it as-char by default results in very
512  //good roundtripping
513  if (pFlyFormat && bInnerCntIsFly)
514  {
515  SwNodeIndex aAnchIdx(*pFlyFormat->GetContent().GetContentIdx(), 1);
516  SwTextNode *pTextNode = aAnchIdx.GetNode().GetTextNode();
517 
518  SwFormatAnchor aAnc(RndStdIds::FLY_AS_CHAR);
519  sal_Int32 nInsertPos = bBefore ? pTextNode->Len() : 0;
520  SwPosition aPos(*pTextNode, nInsertPos);
521 
522  aAnc.SetAnchor(&aPos);
523 
524  SwFlyFrame *pFly = GetSelectedOrCurrFlyFrame();
525  OSL_ENSURE(pFly, "SetFlyFrameAttr, no Fly selected.");
526  if (pFly)
527  {
528  SfxItemSet aSet(makeItemSetFromFormatAnchor(GetDoc()->GetAttrPool(), aAnc));
529  SwFlyFrameFormat* pInnerFlyFormat = pFly->GetFormat();
530  GetDoc()->SetFlyFrameAttr(*pInnerFlyFormat, aSet);
531  }
532  //put a hard-break after the graphic to keep it separated
533  //from the caption text if the outer frame is resized
534  const sal_Int32 nIndex = bBefore ? nInsertPos : 1;
535  SwIndex aIdx(pTextNode, nIndex);
536  pTextNode->InsertText("\n", aIdx);
537  //set the hard-break to be hidden, otherwise it has
538  //non-zero width in word and so hard-break flows on
539  //the next line, pushing the caption text out of
540  //the frame making the caption apparently disappear
541  SvxCharHiddenItem aHidden(true, RES_CHRATR_HIDDEN);
542  SfxItemSet aSet(GetDoc()->GetAttrPool(), {{aHidden.Which(), aHidden.Which()}});
543  aSet.Put(aHidden);
544  SwPaM aPam(*pTextNode, nIndex, *pTextNode, nIndex + 1);
545  SetAttrSet(aSet, SetAttrMode::DEFAULT, &aPam);
546  }
547  }
548 
549  if (pFlyFormat)
550  {
551  const Point aPt(GetCursorDocPos());
552  if (SwFlyFrame* pFrame = pFlyFormat->GetFrame(&aPt))
553  SelectFlyFrame(*pFrame);
554  }
555  EndUndo();
556  EndAllActionAndCall();
557 
558 }
559 
561 {
562  if( !HasSelection() )
563  return false;
564 
565  SET_CURR_SHELL( this );
566  bool bRet = false;
567  StartAllAction();
568  if(IsTableMode())
569  {
570  // Sort table
571  // check if Point/Mark of current Cursor are in one table
572  SwFrame *pFrame = GetCurrFrame( false );
573  OSL_ENSURE( pFrame->FindTabFrame(), "Cursor not in table." );
574 
575  // search boxes via the layout
576  SwSelBoxes aBoxes;
577  GetTableSel(*this, aBoxes);
578 
579  // The Cursor should be removed from the deletion area.
580  // Always put them behind/on the table; via the
581  // document position they will always be set to the old position
582  while( !pFrame->IsCellFrame() )
583  pFrame = pFrame->GetUpper();
584  {
585  /* ParkCursor->ParkCursorTab */
586  ParkCursorInTab();
587  }
588 
589  // call sorting on document
590  bRet = mxDoc->SortTable(aBoxes, rOpt);
591  }
592  else
593  {
594  // Sort text nothing else
595  for(SwPaM& rPaM : GetCursor()->GetRingContainer())
596  {
597  SwPaM* pPam = &rPaM;
598 
599  SwPosition* pStart = pPam->Start();
600  SwPosition* pEnd = pPam->End();
601 
602  SwNodeIndex aPrevIdx( pStart->nNode, -1 );
603  sal_uLong nOffset = pEnd->nNode.GetIndex() - pStart->nNode.GetIndex();
604  const sal_Int32 nCntStt = pStart->nContent.GetIndex();
605 
606  // Sorting
607  bRet = mxDoc->SortText(*pPam, rOpt);
608 
609  // put selection again
610  pPam->DeleteMark();
611  pPam->GetPoint()->nNode.Assign( aPrevIdx.GetNode(), +1 );
612  SwContentNode* pCNd = pPam->GetContentNode();
613  sal_Int32 nLen = pCNd->Len();
614  if( nLen > nCntStt )
615  nLen = nCntStt;
616  pPam->GetPoint()->nContent.Assign(pCNd, nLen );
617  pPam->SetMark();
618 
619  pPam->GetPoint()->nNode += nOffset;
620  pCNd = pPam->GetContentNode();
621  pPam->GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
622  }
623  }
624 
625  EndAllAction();
626  return bRet;
627 }
628 
630 {
631  SwFrame* pFrame = GetCurrFrame();
632  while (pFrame)
633  {
634  pFrame = pFrame->GetUpper();
635  if (pFrame && pFrame->IsColumnFrame())
636  {
637  return pFrame->IsRightToLeft();
638  }
639  }
640  return false;
641 }
642 
643 sal_uInt16 SwFEShell::GetCurColNum_( const SwFrame *pFrame,
644  SwGetCurColNumPara* pPara )
645 {
646  sal_uInt16 nRet = 0;
647  while ( pFrame )
648  {
649  pFrame = pFrame->GetUpper();
650  if( pFrame && pFrame->IsColumnFrame() )
651  {
652  const SwFrame *pCurFrame = pFrame;
653  do {
654  ++nRet;
655  pFrame = pFrame->GetPrev();
656  } while ( pFrame );
657 
658  if( pPara )
659  {
660  // now search the format, determining the columness
661  pFrame = pCurFrame->GetUpper();
662  while( pFrame )
663  {
665  {
666  pPara->pFrameFormat = static_cast<const SwLayoutFrame*>(pFrame)->GetFormat();
667  pPara->pPrtRect = &pFrame->getFramePrintArea();
668  break;
669  }
670  pFrame = pFrame->GetUpper();
671  }
672  if( !pFrame )
673  {
674  pPara->pFrameFormat = nullptr;
675  pPara->pPrtRect = nullptr;
676  }
677  }
678  break;
679  }
680  }
681  return nRet;
682 }
683 
684 sal_uInt16 SwFEShell::GetCurColNum( SwGetCurColNumPara* pPara ) const
685 {
686  OSL_ENSURE( GetCurrFrame(), "Cursor parked?" );
687  return GetCurColNum_( GetCurrFrame(), pPara );
688 }
689 
690 sal_uInt16 SwFEShell::GetCurOutColNum() const
691 {
692  sal_uInt16 nRet = 0;
693  SwFrame* pFrame = GetCurrFrame();
694  OSL_ENSURE( pFrame, "Cursor parked?" );
695  if( pFrame )
696  {
697  pFrame = pFrame->IsInTab() ? static_cast<SwFrame*>(pFrame->FindTabFrame())
698  : static_cast<SwFrame*>(pFrame->FindSctFrame());
699  OSL_ENSURE( pFrame, "No Tab, no Sect" );
700  if( pFrame )
701  nRet = GetCurColNum_( pFrame, nullptr );
702  }
703  return nRet;
704 }
705 
706 SwFEShell::SwFEShell( SwDoc& rDoc, vcl::Window *pWindow, const SwViewOption *pOptions )
707  : SwEditShell( rDoc, pWindow, pOptions )
708  , m_bCheckForOLEInCaption(false)
709  , m_aPasteListeners(GetPasteMutex())
710 {
711 }
712 
714  : SwEditShell( rShell, pWindow )
715  , m_bCheckForOLEInCaption(false)
716  , m_aPasteListeners(GetPasteMutex())
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:310
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:71
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:1183
void DeleteMark()
Definition: pam.hxx:177
sal_uInt16 GetPhyPageNum()
Phy: real page count.
Definition: fews.cxx:336
Point GetPos(const SwRect &rRect) const
Definition: frame.hxx:1344
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2814
SwLabelType
Definition: swtypes.hxx:87
size_t GetMarkCount() const
Rect of current FlyFrame.
Marks a position in the document model.
Definition: pam.hxx:35
SdrView * GetDrawView()
Definition: vnew.cxx:376
bool IsInFly() const
Definition: frame.hxx: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:185
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:142
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:92
SwFrameType GetType() const
Definition: frame.hxx:498
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, bool bExpandCharToPara=false)=0
Insert an attribute.
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:354
sal_uIntPtr sal_uLong
sal_uInt16 GetCurColNum(SwGetCurColNumPara *pPara=nullptr) const
The ruler needs some information too.
Definition: fews.cxx:684
const SwRect & getFramePrintArea() const
Definition: frame.hxx:176
void ShellLoseFocus()
Hide or show layout-selection and pass call to CursorSh.
Definition: fews.cxx:324
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1150
Definition: doc.hxx:185
void ShellLoseFocus()
Definition: crsrsh.cxx:2330
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:1339
bool HasDrawView() const
Definition: vnew.cxx:361
SwNode & GetNode() const
Definition: ndindex.hxx:118
long SwTwips
Definition: swtypes.hxx:49
SdrMark * GetMark(size_t nNum) const
bool IsVert() const
Definition: frame.hxx:1328
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:332
virtual const SwFormatPageDesc & GetPageDescItem() const
Definition: findfrm.cxx:659
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:281
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:347
bool IsDirectlyInSection() const
Definition: fews.cxx:232
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:176
CurRectType
Definition: fesh.hxx:135
static SAL_DLLPRIVATE sal_uInt16 GetCurColNum_(const SwFrame *pFrame, SwGetCurColNumPara *pPara)
Definition: fews.cxx:643
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
sal_uInt16 GetVirtPageNum()
Definition: fews.cxx:344
bool IsFlyFrame() const
Definition: frame.hxx:1186
long GetPrtBottom(const SwFrame &rFrame) const
Definition: frame.hxx:1371
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:478
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:151
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:1340
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:1348
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:560
SwFEShell(SwDoc &rDoc, vcl::Window *pWin, const SwViewOption *pOpt)
Definition: fews.cxx:706
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:144
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:229
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
SwPageFrame * FindPageFrame()
Definition: frame.hxx:658
const SwFrame * Lower() const
Definition: layfrm.hxx:100
int i
SwPageDesc * GetPageDesc()
Definition: pagefrm.hxx:128
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:403
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
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:629
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:373
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:2348
void ToggleHeaderFooterEdit()
Acts both for headers / footers, depending on the bShow(Header|Footer)Separator flags.
Definition: viewsh.cxx:114
void ShellGetFocus()
Definition: crsrsh.cxx:2337
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:147
sal_uInt16 GetCurOutColNum() const
Current outer column.
Definition: fews.cxx:690
sal_Int32 GetIndex() const
Definition: index.hxx:95
bool IsInside(const Point &rPOINT) const
Definition: swrect.cxx:110
... 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:1329
bool IsPageFrame() const
Definition: frame.hxx:1154
const Point TopRight() const
Definition: swrect.cxx:178
static SwRewriter CreateRewriter(const OUString &rStr)
Definition: unins.cxx:1018
Rect of current header/footer.
void ClearMark()
Definition: crsrsh.cxx:927
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:380
#define RES_CHRATR_HIDDEN
Definition: hintids.hxx:105
Point GetContentPos(const Point &rPoint, bool bNext) const
Provide information about content situated closes to given Point.
Definition: fews.cxx:86
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:422
bool IsVertical() const
Definition: frame.hxx:949
const SwFrameFormat * pFrameFormat
Definition: fesh.hxx:152
Rect of current section.
RndStdIds
sal_uInt16 GetPageNumber(const Point &rPoint) const
Page number of the page containing Point, O if no page.
Definition: fews.cxx:186
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
const SwFrame * GetAnchorFrame() const
void StartAllAction()
For all views of this document.
Definition: edws.cxx:85
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2072
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:238
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:352
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:3033
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1486
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:271
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)