LibreOffice Module sw (master)  1
fefly1.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 <hintids.hxx>
21 #include <o3tl/any.hxx>
22 #include <svl/itemiter.hxx>
23 #include <vcl/imapobj.hxx>
24 #include <editeng/protitem.hxx>
25 #include <svx/svdogrp.hxx>
26 #include <svx/svdouno.hxx>
27 #include <tools/globname.hxx>
28 #include <sot/exchange.hxx>
29 #include <com/sun/star/form/FormButtonType.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/embed/XEmbeddedObject.hpp>
32 #include <comphelper/types.hxx>
33 #include <osl/diagnose.h>
34 #include <fmtanchr.hxx>
35 #include <fmtcntnt.hxx>
36 #include <fmtornt.hxx>
37 #include <fmturl.hxx>
38 #include <fmtfsize.hxx>
39 #include <fesh.hxx>
40 #include <rootfrm.hxx>
41 #include <pagefrm.hxx>
42 #include <cntfrm.hxx>
43 #include <txtfrm.hxx>
44 #include <viewimp.hxx>
45 #include <viscrs.hxx>
46 #include <doc.hxx>
48 #include <IDocumentUndoRedo.hxx>
49 #include <IDocumentState.hxx>
52 #include <redline.hxx>
53 #include <dview.hxx>
54 #include <dflyobj.hxx>
55 #include <dcontact.hxx>
56 #include <frmfmt.hxx>
57 #include <flyfrm.hxx>
58 #include <ndtxt.hxx>
59 #include <swtable.hxx>
60 #include <ndgrf.hxx>
61 #include <flyfrms.hxx>
62 #include <fldbas.hxx>
63 #include <fmtfld.hxx>
64 #include <swundo.hxx>
65 #include <txatbase.hxx>
66 #include <frame.hxx>
67 #include <notxtfrm.hxx>
68 #include <HandleAnchorNodeChg.hxx>
69 #include <frmatr.hxx>
70 #include <fmtsrnd.hxx>
71 #include <ndole.hxx>
72 #include <fefly.hxx>
73 #include <fmtcnct.hxx>
74 #include <frameformats.hxx>
75 #include <textboxhelper.hxx>
76 
77 
78 using namespace ::com::sun::star;
79 
80 // Based on the request, changes to the specific layouts will be made, to
81 // fit to the format
82 static bool lcl_SetNewFlyPos( const SwNode& rNode, SwFormatAnchor& rAnchor,
83  const Point& rPt )
84 {
85  bool bRet = false;
86  const SwStartNode* pStNode = rNode.FindFlyStartNode();
87  if( pStNode )
88  {
89  SwPosition aPos( *pStNode );
90  rAnchor.SetAnchor( &aPos );
91  bRet = true;
92  }
93  else
94  {
95  const SwContentNode *pCntNd = rNode.GetContentNode();
96  std::pair<Point, bool> const tmp(rPt, false);
97  const SwContentFrame* pCFrame = pCntNd ? pCntNd->getLayoutFrame(
99  nullptr, &tmp) : nullptr;
100  const SwPageFrame *pPg = pCFrame ? pCFrame->FindPageFrame() : nullptr;
101 
102  rAnchor.SetPageNum( pPg ? pPg->GetPhyPageNum() : 1 );
103  rAnchor.SetType( RndStdIds::FLY_AT_PAGE );
104  }
105  return bRet;
106 }
107 
108 static bool lcl_FindAnchorPos(
109  SwDoc& rDoc,
110  const Point& rPt,
111  const SwFrame& rFrame,
112  SfxItemSet& rSet )
113 {
114  bool bRet = true;
115  SwFormatAnchor aNewAnch( rSet.Get( RES_ANCHOR ) );
116  RndStdIds nNew = aNewAnch.GetAnchorId();
117  const SwFrame *pNewAnch;
118 
119  //determine new anchor
120  Point aTmpPnt( rPt );
121  switch( nNew )
122  {
123  case RndStdIds::FLY_AS_CHAR: // also include this?
124  case RndStdIds::FLY_AT_PARA:
125  case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
126  {
127  // starting from the upper-left corner of the Fly,
128  // search nearest ContentFrame
129  const SwFrame* pFrame = rFrame.IsFlyFrame() ? static_cast<const SwFlyFrame&>(rFrame).GetAnchorFrame()
130  : &rFrame;
131  pNewAnch = ::FindAnchor( pFrame, aTmpPnt );
132  if( pNewAnch->IsProtected() )
133  {
134  bRet = false;
135  break;
136  }
137  SwPosition aPos( pNewAnch->IsTextFrame()
138  ? *static_cast<SwTextFrame const*>(pNewAnch)->GetTextNodeForParaProps()
139  : *static_cast<const SwNoTextFrame*>(pNewAnch)->GetNode() );
140  if ((RndStdIds::FLY_AT_CHAR == nNew) || (RndStdIds::FLY_AS_CHAR == nNew))
141  {
142  // textnode should be found, as only in those
143  // a content bound frame can be anchored
145  aTmpPnt.setX(aTmpPnt.getX() - 1); // do not land in the fly!
146  if( !pNewAnch->GetModelPositionForViewPoint( &aPos, aTmpPnt, &aState ) )
147  {
148  assert(pNewAnch->IsTextFrame()); // because AT_CHAR/AS_CHAR
149  SwTextFrame const*const pTextFrame(
150  static_cast<SwTextFrame const*>(pNewAnch));
151  if( pNewAnch->getFrameArea().Bottom() < aTmpPnt.Y() )
152  {
153  aPos = pTextFrame->MapViewToModelPos(TextFrameIndex(0));
154  }
155  else
156  {
157  aPos = pTextFrame->MapViewToModelPos(
158  TextFrameIndex(pTextFrame->GetText().getLength()));
159  }
160  }
161  else
162  {
164  {
165  aPos.nContent = SwCursorShell::StartOfInputFieldAtPos( aPos );
166  }
167  }
168  }
169  aNewAnch.SetAnchor( &aPos );
170  }
171  break;
172 
173  case RndStdIds::FLY_AT_FLY: // LAYER_IMPL
174  {
175  // starting from the upper-left corner of the Fly
176  // search nearest SwFlyFrame
178  SwPosition aPos( rDoc.GetNodes() );
179  aTmpPnt.setX(aTmpPnt.getX() - 1); // do not land in the fly!
180  rDoc.getIDocumentLayoutAccess().GetCurrentLayout()->GetModelPositionForViewPoint( &aPos, aTmpPnt, &aState );
181  pNewAnch = ::FindAnchor(
182  aPos.nNode.GetNode().GetContentNode()->getLayoutFrame(rFrame.getRootFrame(), nullptr, nullptr),
183  aTmpPnt )->FindFlyFrame();
184 
185  if( pNewAnch && &rFrame != pNewAnch && !pNewAnch->IsProtected() )
186  {
187  aPos.nNode = *static_cast<const SwFlyFrame*>(pNewAnch)->GetFormat()->GetContent().
188  GetContentIdx();
189  aNewAnch.SetAnchor( &aPos );
190  break;
191  }
192  }
193 
194  nNew = RndStdIds::FLY_AT_PAGE;
195  aNewAnch.SetType( nNew );
196  [[fallthrough]];
197 
198  case RndStdIds::FLY_AT_PAGE:
199  pNewAnch = rFrame.FindPageFrame();
200  aNewAnch.SetPageNum( pNewAnch->GetPhyPageNum() );
201  break;
202 
203  default:
204  OSL_ENSURE( false, "Wrong Id for new anchor." );
205  }
206 
207  rSet.Put( aNewAnch );
208  return bRet;
209 }
210 
212 
214  const SwFlyFrame& rFly,
215  SfxItemSet& rSet )
216 {
217  const SwFrameFormat& rFormat = *rFly.GetFormat();
218  const SwFormatAnchor &rOldAnch = rFormat.GetAnchor();
219  const RndStdIds nOld = rOldAnch.GetAnchorId();
220 
221  RndStdIds nNew = rSet.Get( RES_ANCHOR ).GetAnchorId();
222 
223  if( nOld == nNew )
224  return false;
225 
226  SwDoc* pDoc = const_cast<SwDoc*>(rFormat.GetDoc());
227 
228 #if OSL_DEBUG_LEVEL > 0
229  OSL_ENSURE( !(nNew == RndStdIds::FLY_AT_PAGE &&
230  (RndStdIds::FLY_AT_PARA==nOld || RndStdIds::FLY_AT_CHAR==nOld || RndStdIds::FLY_AS_CHAR==nOld ) &&
231  pDoc->IsInHeaderFooter( rOldAnch.GetContentAnchor()->nNode )),
232  "forbidden anchor change in Head/Foot." );
233 #endif
234 
235  return ::lcl_FindAnchorPos( *pDoc, rFly.getFrameArea().Pos(), rFly, rSet );
236 }
237 
239 {
240  CurrShell aCurr( this );
241 
242  // The frame is new, thus select it.
243  // !! Always select the frame, if it's not selected.
244  // - it could be a new "old" one because the anchor was changed
245  // - "old" frames have had to be selected previously otherwise they could
246  // not have been changed
247  // The frames should not be selected by the document position, because
248  // it should have been selected!
249  SwViewShellImp *pImpl = Imp();
250  if( !GetWin() )
251  return;
252 
253  OSL_ENSURE( rFrame.IsFlyFrame(), "SelectFlyFrame wants a Fly" );
254 
255  // nothing to be done if the Fly already was selected
256  if (GetSelectedFlyFrame() == &rFrame)
257  return;
258 
259  // assure the anchor is drawn
260  if( rFrame.IsFlyInContentFrame() && rFrame.GetAnchorFrame() )
261  rFrame.GetAnchorFrame()->SetCompletePaint();
262 
263  if( pImpl->GetDrawView()->AreObjectsMarked() )
264  pImpl->GetDrawView()->UnmarkAll();
265 
266  pImpl->GetDrawView()->MarkObj( rFrame.GetVirtDrawObj(),
267  pImpl->GetPageView() );
268 
269  rFrame.SelectionHasChanged(this);
270 
271  KillPams();
272  ClearMark();
274 }
275 
276 // Get selected fly
278 {
279  if ( Imp()->HasDrawView() )
280  {
281  // A Fly is only accessible if it is selected
282  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
283  if( rMrkList.GetMarkCount() != 1 )
284  return nullptr;
285 
286  SdrObject *pO = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
287 
288  SwVirtFlyDrawObj *pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pO);
289 
290  return pFlyObj ? pFlyObj->GetFlyFrame() : nullptr;
291  }
292  return nullptr;
293 }
294 
295 // Get current fly in which the cursor is positioned
296 SwFlyFrame* SwFEShell::GetCurrFlyFrame(const bool bCalcFrame) const
297 {
298  SwContentFrame *pContent = GetCurrFrame(bCalcFrame);
299  return pContent ? pContent->FindFlyFrame() : nullptr;
300 }
301 
302 // Get selected fly, but if none Get current fly in which the cursor is positioned
304 {
306  if (pFly)
307  return pFly;
308  return GetCurrFlyFrame();
309 }
310 
311 // Returns non-null pointer, if the current Fly could be anchored to another one (so it is inside)
313 {
314  CurrShell aCurr( this );
315 
316  if ( !Imp()->HasDrawView() )
317  return nullptr;
318 
319  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
320  if ( !rMrkList.GetMarkCount() )
321  {
322  SwFlyFrame *pFly = GetCurrFlyFrame(false);
323  if (!pFly)
324  return nullptr;
325  return pFly->GetFormat();
326  }
327  else if ( rMrkList.GetMarkCount() != 1 ||
328  !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) )
329  return nullptr;
330 
331  SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
332 
333  SwFrameFormat *pFormat = FindFrameFormat( pObj );
334  if( pFormat && RndStdIds::FLY_AT_FLY == pFormat->GetAnchor().GetAnchorId() )
335  {
336  const SwFrame* pFly;
337  if (SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj *>(pObj))
338  {
339  pFly = pFlyObj->GetFlyFrame()->GetAnchorFrame();
340  }
341  else
342  {
343  pFly = static_cast<SwDrawContact*>(GetUserCall(pObj))->GetAnchorFrame(pObj);
344  }
345 
346  OSL_ENSURE( pFly, "IsFlyInFly: Where's my anchor?" );
347  OSL_ENSURE( pFly->IsFlyFrame(), "IsFlyInFly: Funny anchor!" );
348  return static_cast<const SwFlyFrame*>(pFly)->GetFormat();
349  }
350 
351  Point aTmpPos = pObj->GetCurrentBoundRect().TopLeft();
352 
353  SwFrame *pTextFrame;
354  {
356  SwNodeIndex aSwNodeIndex( GetDoc()->GetNodes() );
357  SwPosition aPos( aSwNodeIndex );
358  Point aPoint( aTmpPos );
359  aPoint.setX(aPoint.getX() - 1); //do not land in the fly!!
360  GetLayout()->GetModelPositionForViewPoint( &aPos, aPoint, &aState );
361  // determine text frame by left-top-corner of object
362  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
363  std::pair<Point, bool> const tmp(aTmpPos, false);
364  pTextFrame = pNd ? pNd->getLayoutFrame(GetLayout(), nullptr, &tmp) : nullptr;
365  }
366  const SwFrame *pTmp = pTextFrame ? ::FindAnchor(pTextFrame, aTmpPos) : nullptr;
367  const SwFlyFrame *pFly = pTmp ? pTmp->FindFlyFrame() : nullptr;
368  if( pFly )
369  return pFly->GetFormat();
370  return nullptr;
371 }
372 
373 void SwFEShell::SetFlyPos( const Point& rAbsPos )
374 {
375  CurrShell aCurr( this );
376 
377  // Determine reference point in document coordinates
378  SwFlyFrame *pFly = GetCurrFlyFrame(false);
379  if (!pFly)
380  return;
381 
382  //SwSaveHdl aSaveX( Imp() );
383 
384  // Set an anchor starting from the absolute position for paragraph bound Flys
385  // Anchor and new RelPos will be calculated and set by the Fly
386  if ( pFly->IsFlyAtContentFrame() )
387  {
388  if(pFly->IsFlyFreeFrame() && static_cast< SwFlyFreeFrame* >(pFly)->isTransformableSwFrame())
389  {
390  // RotateFlyFrame3: When we have a change and are in transformed state (e.g. rotation used),
391  // we need to correct the absolute position (rAbsPos) which was created in
392  // transformed coordinates to untransformed state
393  TransformableSwFrame* pTransformableSwFrame(static_cast<SwFlyFreeFrame*>(pFly)->getTransformableSwFrame());
394  const SwRect aUntransformedFrameArea(pTransformableSwFrame->getUntransformedFrameArea());
395  const Point aNewAbsPos(
396  rAbsPos.X() + aUntransformedFrameArea.Left() - pFly->getFrameArea().Left(),
397  rAbsPos.Y() + aUntransformedFrameArea.Top() - pFly->getFrameArea().Top());
398  static_cast<SwFlyAtContentFrame*>(pFly)->SetAbsPos(aNewAbsPos);
399  }
400  else
401  {
402  static_cast<SwFlyAtContentFrame*>(pFly)->SetAbsPos( rAbsPos );
403  }
404  }
405  else
406  {
407  const SwFrame *pAnch = pFly->GetAnchorFrame();
408  Point aOrient( pAnch->getFrameArea().Pos() );
409 
410  if ( pFly->IsFlyInContentFrame() )
411  aOrient.setX(rAbsPos.getX());
412 
413  // calculate RelPos.
414  aOrient.setX(rAbsPos.getX() - aOrient.getX());
415  aOrient.setY(rAbsPos.getY() - aOrient.getY());
416  pFly->ChgRelPos( aOrient );
417  }
418  CallChgLnk(); // call the AttrChangeNotify on the UI-side.
419 }
420 
421 Point SwFEShell::FindAnchorPos( const Point& rAbsPos, bool bMoveIt )
422 {
423  Point aRet;
424 
425  CurrShell aCurr( this );
426 
427  if ( !Imp()->HasDrawView() )
428  return aRet;
429 
430  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
431  if ( rMrkList.GetMarkCount() != 1 ||
432  !GetUserCall(rMrkList.GetMark( 0 )->GetMarkedSdrObj()) )
433  return aRet;
434 
435  SdrObject* pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
436  // #i28701#
437  SwAnchoredObject* pAnchoredObj = ::GetUserCall( pObj )->GetAnchoredObj( pObj );
438  SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
439  const RndStdIds nAnchorId = rFormat.GetAnchor().GetAnchorId();
440 
441  if ( RndStdIds::FLY_AS_CHAR == nAnchorId )
442  return aRet;
443 
444  bool bFlyFrame = dynamic_cast<SwVirtFlyDrawObj *>(pObj) != nullptr;
445 
446  bool bTextBox = false;
447  if (rFormat.Which() == RES_DRAWFRMFMT)
448  {
449  bTextBox = SwTextBoxHelper::isTextBox(&rFormat, RES_DRAWFRMFMT);
450  }
451 
452  SwFlyFrame* pFly = nullptr;
453  const SwFrame* pFooterOrHeader = nullptr;
454 
455  if( bFlyFrame )
456  {
457  // Calculate reference point in document coordinates
459  if( !pContent )
460  return aRet;
461  pFly = pContent->FindFlyFrame();
462  if ( !pFly )
463  return aRet;
464  const SwFrame* pOldAnch = pFly->GetAnchorFrame();
465  if( !pOldAnch )
466  return aRet;
467  if ( RndStdIds::FLY_AT_PAGE != nAnchorId )
468  {
469  pFooterOrHeader = pContent->FindFooterOrHeader();
470  }
471  }
472  else if (bTextBox)
473  {
474  auto pFlyFormat = dynamic_cast<const SwFlyFrameFormat*>(
476  if (pFlyFormat)
477  {
478  pFly = pFlyFormat->GetFrame();
479  }
480  }
481 
482  // set <pFooterOrHeader> also for drawing
483  // objects, but not for control objects.
484  // Necessary for moving 'anchor symbol' at the user interface inside header/footer.
485  else if ( !::CheckControlLayer( pObj ) )
486  {
488  if( !pContent )
489  return aRet;
490  pFooterOrHeader = pContent->FindFooterOrHeader();
491  }
492 
493  // Search nearest SwFlyFrame starting from the upper-left corner
494  // of the fly
495  SwContentFrame *pTextFrame = nullptr;
496  {
498  SwPosition aPos( GetDoc()->GetNodes().GetEndOfExtras() );
499  Point aTmpPnt( rAbsPos );
500  GetLayout()->GetModelPositionForViewPoint( &aPos, aTmpPnt, &aState );
501  if (aPos.nNode != GetDoc()->GetNodes().GetEndOfExtras().GetIndex()
502  && (nAnchorId != RndStdIds::FLY_AT_CHAR || !PosInsideInputField(aPos)))
503  {
504  SwContentNode* pCNode = aPos.nNode.GetNode().GetContentNode();
505  assert(pCNode);
506  pTextFrame = pCNode->getLayoutFrame(GetLayout(), &aPos, nullptr);
507  }
508  }
509  const SwFrame *pNewAnch = nullptr;
510  if( pTextFrame != nullptr )
511  {
512  if ( RndStdIds::FLY_AT_PAGE == nAnchorId )
513  {
514  pNewAnch = pTextFrame->FindPageFrame();
515  }
516  else
517  {
518  pNewAnch = ::FindAnchor( pTextFrame, rAbsPos );
519 
520  if( RndStdIds::FLY_AT_FLY == nAnchorId ) // LAYER_IMPL
521  {
522  pNewAnch = pNewAnch->FindFlyFrame();
523  }
524  }
525  }
526 
527  if( pNewAnch && !pNewAnch->IsProtected() )
528  {
529  const SwFlyFrame* pCheck = (bFlyFrame || bTextBox) ? pNewAnch->FindFlyFrame() : nullptr;
530  // If we land inside the frame, make sure
531  // that the frame does not land inside its own content
532  while( pCheck )
533  {
534  if( pCheck == pFly )
535  break;
536  const SwFrame *pTmp = pCheck->GetAnchorFrame();
537  pCheck = pTmp ? pTmp->FindFlyFrame() : nullptr;
538  }
539 
540  // Do not switch from header/footer to another area,
541  // do not switch to a header/footer
542  if( !pCheck &&
543  pFooterOrHeader == pNewAnch->FindFooterOrHeader() )
544  {
545  aRet = pNewAnch->GetFrameAnchorPos( ::HasWrap( pObj ) );
546 
547  if ( bMoveIt || (nAnchorId == RndStdIds::FLY_AT_CHAR) )
548  {
549  SwFormatAnchor aAnch( rFormat.GetAnchor() );
550  switch ( nAnchorId )
551  {
552  case RndStdIds::FLY_AT_PARA:
553  {
554  SwPosition pos = *aAnch.GetContentAnchor();
555  pos.nNode = pTextFrame->IsTextFrame()
556  ? *static_cast<SwTextFrame const*>(pTextFrame)->GetTextNodeForParaProps()
557  : *static_cast<const SwNoTextFrame*>(pTextFrame)->GetNode();
558  pos.nContent.Assign(nullptr,0);
559  aAnch.SetAnchor( &pos );
560  break;
561  }
562  case RndStdIds::FLY_AT_PAGE:
563  {
564  aAnch.SetPageNum( static_cast<const SwPageFrame*>(pNewAnch)->
565  GetPhyPageNum() );
566  break;
567  }
568 
569  case RndStdIds::FLY_AT_FLY:
570  {
571  SwPosition aPos( *static_cast<const SwFlyFrame*>(pNewAnch)->GetFormat()->
572  GetContent().GetContentIdx() );
573  aAnch.SetAnchor( &aPos );
574  break;
575  }
576 
577  case RndStdIds::FLY_AT_CHAR:
578  {
579  SwPosition pos = *aAnch.GetContentAnchor();
580  Point aTmpPnt( rAbsPos );
581  if( pTextFrame->GetModelPositionForViewPoint( &pos, aTmpPnt ) )
582  {
583  SwRect aTmpRect;
584  pTextFrame->GetCharRect( aTmpRect, pos );
585  aRet = aTmpRect.Pos();
586  }
587  else
588  {
589  pos = static_cast<SwTextFrame const*>(pTextFrame)->MapViewToModelPos(TextFrameIndex(0));
590  }
591  aAnch.SetAnchor( &pos );
592  break;
593  }
594  default:
595  break;
596 
597  }
598 
599  if( bMoveIt )
600  {
601  StartAllAction();
602  // --> handle change of anchor node:
603  // if count of the anchor frame also change, the fly frames have to be
604  // re-created. Thus, delete all fly frames except the <this> before the
605  // anchor attribute is change and re-create them afterwards.
606  {
607  std::unique_ptr<SwHandleAnchorNodeChg, o3tl::default_delete<SwHandleAnchorNodeChg>> pHandleAnchorNodeChg;
608  SwFlyFrameFormat* pFlyFrameFormat( dynamic_cast<SwFlyFrameFormat*>(&rFormat) );
609  if ( pFlyFrameFormat )
610  {
611  pHandleAnchorNodeChg.reset(
612  new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch ));
613  }
614  rFormat.GetDoc()->SetAttr( aAnch, rFormat );
616  {
617  SwTextBoxHelper::syncFlyFrameAttr(rFormat, rFormat.GetAttrSet());
618  }
619  }
620  // #i28701# - no call of method
621  // <CheckCharRectAndTopOfLine()> for to-character anchored
622  // Writer fly frame needed. This method call can cause a
623  // format of the anchor frame, which is no longer intended.
624  // Instead clear the anchor character rectangle and
625  // the top of line values for all to-character anchored objects.
626  pAnchoredObj->ClearCharRectAndTopOfLine();
627  EndAllAction();
628  }
629  }
630 
631  SwRect aTmpRect( aRet, rAbsPos );
632  if( aTmpRect.HasArea() )
633  MakeVisible( aTmpRect );
634 #if OSL_DEBUG_LEVEL > 0
635  //TODO: That doesn't seem to be intended
636  if( COL_TRANSPARENT != GetOut()->GetLineColor() )
637  {
638  OSL_FAIL( "Hey, Joe: Where's my Null Pen?" );
640  }
641 #endif
642  }
643  }
644 
645  return aRet;
646 }
647 
648 const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchValid,
649  SwFrameFormat *pParent )
650 {
651  CurrShell aCurr( this );
652  StartAllAction();
653 
654  SwPaM* pCursor = GetCursor();
655  const Point aPt( GetCursorDocPos() );
656 
657  SwSelBoxes aBoxes;
658  bool bMoveContent = true;
659  if( IsTableMode() )
660  {
661  GetTableSel( *this, aBoxes );
662  if( !aBoxes.empty() )
663  {
664  // Cursor should be removed from the removal area.
665  // Always put it after/on the table; via the
666  // document position they will be set to the old
667  // position
668  ParkCursor( SwNodeIndex( *aBoxes[0]->GetSttNd() ));
669 
670  // #i127787# pCurrentCursor will be deleted in ParkCursor,
671  // we better get the current pCurrentCursor instead of working with the
672  // deleted one:
673  pCursor = GetCursor();
674  }
675  else
676  bMoveContent = false;
677  }
678  else if( !pCursor->HasMark() && !pCursor->IsMultiSelection() )
679  bMoveContent = false;
680 
681  const SwPosition& rPos = *pCursor->Start();
682 
683  SwFormatAnchor& rAnch = const_cast<SwFormatAnchor&>(rSet.Get( RES_ANCHOR ));
684  RndStdIds eRndId = rAnch.GetAnchorId();
685  switch( eRndId )
686  {
687  case RndStdIds::FLY_AT_PAGE:
688  if( !rAnch.GetPageNum() ) //HotFix: Bug in UpdateByExample
689  rAnch.SetPageNum( 1 );
690  break;
691 
692  case RndStdIds::FLY_AT_FLY:
693  case RndStdIds::FLY_AT_PARA:
694  case RndStdIds::FLY_AT_CHAR:
695  case RndStdIds::FLY_AS_CHAR:
696  if( !bAnchValid )
697  {
698  if( RndStdIds::FLY_AT_FLY != eRndId )
699  {
700  rAnch.SetAnchor( &rPos );
701  }
702  else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) )
703  {
704  eRndId = RndStdIds::FLY_AT_PAGE;
705  }
706  }
707  break;
708 
709  default:
710  OSL_ENSURE( false, "What is the purpose of this Fly?" );
711  break;
712  }
713 
714  SwFlyFrameFormat *pRet;
715  if( bMoveContent )
716  {
718  std::unique_ptr<SwFormatAnchor> pOldAnchor;
719  bool bHOriChgd = false, bVOriChgd = false;
720  std::shared_ptr<SwFormatVertOrient> aOldV;
721  std::shared_ptr<SwFormatHoriOrient> aOldH;
722 
723  if ( RndStdIds::FLY_AT_PAGE != eRndId )
724  {
725  // First as with page link. Paragraph/character link on if
726  // everything was shifted. Then the position is valid!
727  // JP 13.05.98: if necessary also convert the horizontal/vertical
728  // orientation, to prevent correction during re-anchoring
729  pOldAnchor.reset(new SwFormatAnchor( rAnch ));
730  const_cast<SfxItemSet&>(rSet).Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 ) );
731 
732  const SfxPoolItem* pItem;
733  if( SfxItemState::SET == rSet.GetItemState( RES_HORI_ORIENT, false, &pItem )
734  && text::HoriOrientation::NONE == static_cast<const SwFormatHoriOrient*>(pItem)->GetHoriOrient() )
735  {
736  bHOriChgd = true;
737  aOldH.reset(static_cast<SwFormatHoriOrient*>(pItem->Clone()));
738  const_cast<SfxItemSet&>(rSet).Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT ) );
739  }
740  if( SfxItemState::SET == rSet.GetItemState( RES_VERT_ORIENT, false, &pItem )
741  && text::VertOrientation::NONE == static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
742  {
743  bVOriChgd = true;
744  aOldV.reset(static_cast<SwFormatVertOrient*>(pItem->Clone()));
745  const_cast<SfxItemSet&>(rSet).Put( SwFormatVertOrient( 0, text::VertOrientation::TOP ) );
746  }
747  }
748 
749  pRet = GetDoc()->MakeFlyAndMove( *pCursor, rSet, &aBoxes, pParent );
750 
751  KillPams();
752 
753  if( pOldAnchor )
754  {
755  if( pRet )
756  {
757  // calculate new position
758  // JP 24.03.97: also go via page links
759  // anchor should not lie in the shifted area
760  pRet->DelFrames();
761 
762  const SwFrame* pAnch = ::FindAnchor( GetLayout(), aPt );
763  SwPosition aPos( pAnch->IsTextFrame()
764  ? *static_cast<SwTextFrame const*>(pAnch)->GetTextNodeForParaProps()
765  : *static_cast<const SwNoTextFrame*>(pAnch)->GetNode() );
766 
767  if ( RndStdIds::FLY_AS_CHAR == eRndId )
768  {
769  assert(pAnch->IsTextFrame());
770  aPos = static_cast<SwTextFrame const*>(pAnch)->MapViewToModelPos(TextFrameIndex(0));
771  }
772  pOldAnchor->SetAnchor( &aPos );
773 
774  // shifting of table selection is not Undo-capable. therefore
775  // changing the anchors should not be recorded
776  bool const bDoesUndo =
778  SwUndoId nLastUndoId(SwUndoId::EMPTY);
779  if (bDoesUndo &&
781  & nLastUndoId))
782  {
783  if (SwUndoId::INSLAYFMT == nLastUndoId)
784  {
785  GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
786  }
787  }
788 
789  const_cast<SfxItemSet&>(rSet).Put( *pOldAnchor );
790 
791  if( bHOriChgd )
792  const_cast<SfxItemSet&>(rSet).Put( *aOldH );
793  if( bVOriChgd )
794  const_cast<SfxItemSet&>(rSet).Put( *aOldV );
795 
796  GetDoc()->SetFlyFrameAttr( *pRet, const_cast<SfxItemSet&>(rSet) );
797  GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
798  }
799  }
801  }
802  else
803  /* If called from a shell try to propagate an
804  existing adjust item from rPos to the content node of the
805  new frame. */
806  pRet = GetDoc()->MakeFlySection( eRndId, &rPos, &rSet, pParent, true );
807 
808  if( pRet )
809  {
810  SwFlyFrame* pFrame = pRet->GetFrame( &aPt );
811  if( pFrame )
812  SelectFlyFrame( *pFrame );
813  else
814  {
816  pRet = nullptr;
817  }
818  }
820 
821  return pRet;
822 }
823 
824 void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
825  const Graphic* pGraphic,
826  const SfxItemSet* pFlyAttrSet )
827 {
828  SwFlyFrameFormat* pFormat = nullptr;
829  CurrShell aCurr( this );
830  StartAllAction();
831  SwShellCursor *pStartCursor = dynamic_cast<SwShellCursor*>(GetSwCursor());
832  SwShellCursor *pCursor = pStartCursor;
833  do
834  {
835  if (!pCursor)
836  break;
837 
838  // Has the anchor not been set or been set incompletely?
839  if( pFlyAttrSet )
840  {
841  const SfxPoolItem* pItem;
842  if( SfxItemState::SET == pFlyAttrSet->GetItemState( RES_ANCHOR, false,
843  &pItem ) )
844  {
845  SwFormatAnchor* pAnchor = const_cast<SwFormatAnchor*>(static_cast<const SwFormatAnchor*>(pItem));
846  switch( pAnchor->GetAnchorId())
847  {
848  case RndStdIds::FLY_AT_PARA:
849  case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
850  case RndStdIds::FLY_AS_CHAR:
851  if( !pAnchor->GetContentAnchor() )
852  {
853  pAnchor->SetAnchor( pCursor->GetPoint() );
854  }
855  break;
856  case RndStdIds::FLY_AT_FLY:
857  if( !pAnchor->GetContentAnchor() )
858  {
859  lcl_SetNewFlyPos( pCursor->GetNode(),
860  *pAnchor, GetCursorDocPos() );
861  }
862  break;
863  case RndStdIds::FLY_AT_PAGE:
864  if( !pAnchor->GetPageNum() )
865  {
866  pAnchor->SetPageNum( pCursor->GetPageNum(
867  true, &pCursor->GetPtPos() ) );
868  }
869  break;
870  default :
871  break;
872  }
873  }
874  }
876  *pCursor, rGrfName,
877  rFltName, pGraphic,
878  pFlyAttrSet,
879  nullptr, nullptr );
880  OSL_ENSURE(pFormat, "IDocumentContentOperations::InsertGraphic failed.");
881 
882  pCursor = pCursor->GetNext();
883  } while( pCursor != pStartCursor );
884 
885  EndAllAction();
886 
887  if( !pFormat )
888  return;
889 
890  const Point aPt( GetCursorDocPos() );
891  SwFlyFrame* pFrame = pFormat->GetFrame( &aPt );
892 
893  if( pFrame )
894  {
895  // add a redline to the anchor point at tracked insertion of picture
896  if ( IsRedlineOn() )
897  {
898  SwPosition aPos(*pFormat->GetAnchor().GetContentAnchor());
899  SwPaM aPaM(aPos.nNode.GetNode(), aPos.nContent.GetIndex(),
900  aPos.nNode.GetNode(), aPos.nContent.GetIndex() + 1);
902  new SwRangeRedline( RedlineType::Insert, aPaM ), true);
903  }
904 
905  // fdo#36681: Invalidate the content and layout to refresh
906  // the picture anchoring properly
907  SwPageFrame* pPageFrame = pFrame->FindPageFrameOfAnchor();
908  pPageFrame->InvalidateFlyLayout();
909  pPageFrame->InvalidateContent();
910 
911  SelectFlyFrame( *pFrame );
912  }
913  else
915 }
916 
918  SfxItemSet* pFlyAttrSet )
919 {
920  SwFlyFrameFormat* pFormat = nullptr;
921  CurrShell aCurr( this );
922  StartAllAction();
923  {
924  for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
925  {
927  rPaM, xObj, pFlyAttrSet );
928  OSL_ENSURE(pFormat, "IDocumentContentOperations::InsertEmbObject failed.");
929  }
930  }
931  EndAllAction();
932 
933  if( pFormat )
934  {
935  const Point aPt( GetCursorDocPos() );
936  SwFlyFrame* pFrame = pFormat->GetFrame( &aPt );
937 
938  if( pFrame )
939  SelectFlyFrame( *pFrame );
940  else
942  }
943 
944  return pFormat;
945 }
946 
948  const Point& rInsertPosition )
949 {
950  CurrShell aCurr( this );
951 
952  SfxItemSet rFlyAttrSet( GetDoc()->GetAttrPool(), aFrameFormatSetRange );
953  rFlyAttrSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PARA ));
954  // #i89920#
955  rFlyAttrSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
956  rDrawObj.SetLayer( getIDocumentDrawModelAccess().GetHeavenId() );
957 
958  // find anchor position
959  SwPaM aPam( mxDoc->GetNodes() );
960  {
962  Point aTmpPt( rInsertPosition );
963  GetLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmpPt, &aState );
964  const SwFrame* pFrame = aPam.GetContentNode()->getLayoutFrame(GetLayout(), nullptr, nullptr);
965  const Point aRelPos( rInsertPosition.X() - pFrame->getFrameArea().Left(),
966  rInsertPosition.Y() - pFrame->getFrameArea().Top() );
967  rDrawObj.SetRelativePos( aRelPos );
968  ::lcl_FindAnchorPos( *GetDoc(), rInsertPosition, *pFrame, rFlyAttrSet );
969  }
970  // insert drawing object into the document creating a new <SwDrawFrameFormat> instance
971  SwDrawFrameFormat* pFormat = GetDoc()->getIDocumentContentOperations().InsertDrawObj( aPam, rDrawObj, rFlyAttrSet );
972 
973  // move object to visible layer
974  SwContact* pContact = static_cast<SwContact*>(rDrawObj.GetUserCall());
975  if ( pContact )
976  {
977  pContact->MoveObjToVisibleLayer( &rDrawObj );
978  }
979 
980  if (pFormat)
981  {
982  pFormat->SetName(rDrawObj.GetName());
983  // select drawing object
984  Imp()->GetDrawView()->MarkObj( &rDrawObj, Imp()->GetPageView() );
985  }
986  else
987  {
989  }
990 }
991 
992 void SwFEShell::GetPageObjs( std::vector<SwFrameFormat*>& rFillArr )
993 {
994  rFillArr.clear();
995 
996  for( auto pFormat : *mxDoc->GetSpzFrameFormats() )
997  {
998  if (RndStdIds::FLY_AT_PAGE == pFormat->GetAnchor().GetAnchorId())
999  {
1000  rFillArr.push_back( pFormat );
1001  }
1002  }
1003 }
1004 
1005 void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr )
1006 {
1007  if( rFillArr.empty() )
1008  return;
1009 
1010  StartAllAction();
1011  StartUndo();
1012 
1013  SwRootFrame* pTmpRootFrame = GetLayout();
1014  sal_uInt16 nMaxPage = pTmpRootFrame->GetPageNum();
1015  bool bTmpAssert = false;
1016  for( auto pFormat : rFillArr )
1017  {
1018  if (mxDoc->GetSpzFrameFormats()->IsAlive(pFormat))
1019  {
1020  // FlyFormat is still valid, therefore process
1021 
1022  SwFormatAnchor aNewAnchor( pFormat->GetAnchor() );
1023  if (RndStdIds::FLY_AT_PAGE != aNewAnchor.GetAnchorId())
1024  // Anchor has been changed, therefore: do not change!
1025  continue;
1026  sal_uInt16 nNewPage = aNewAnchor.GetPageNum() + 1;
1027  if (nNewPage > nMaxPage)
1028  {
1029  if ( RES_DRAWFRMFMT == pFormat->Which() )
1031  else
1032  pFormat->DelFrames();
1033  bTmpAssert = true;
1034  }
1035  aNewAnchor.SetPageNum(nNewPage);
1036  mxDoc->SetAttr( aNewAnchor, *pFormat );
1037  }
1038  }
1039 
1040  if( bTmpAssert )
1041  pTmpRootFrame->SetAssertFlyPages();
1042 
1043  EndUndo();
1044  EndAllAction();
1045 }
1046 
1047 // All attributes in the "baskets" will be filled with the attributes of the
1048 // current FlyFrames. Attributes which cannot be filled due to being at the
1049 // wrong place or which are ambiguous (multiple selections) will be removed.
1051 {
1053  if (!pFly)
1054  {
1055  OSL_ENSURE( false, "GetFlyFrameAttr, no Fly selected." );
1056  return false;
1057  }
1058 
1059  CurrShell aCurr( const_cast<SwFEShell*>(this) );
1060 
1061  if( !rSet.Set( pFly->GetFormat()->GetAttrSet() ) )
1062  return false;
1063 
1064  // now examine all attributes. Remove forbidden attributes, then
1065  // get all remaining attributes and enter them
1066  const SfxPoolItem* pItem;
1067  if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false, &pItem ) )
1068  {
1069  const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
1070  RndStdIds eType = pAnchor->GetAnchorId();
1071 
1072  if ( RndStdIds::FLY_AT_PAGE != eType )
1073  {
1074  // OD 12.11.2003 #i22341# - content anchor of anchor item is needed.
1075  // Thus, don't overwrite anchor item by default constructed anchor item.
1076  if ( RndStdIds::FLY_AS_CHAR == eType )
1077  {
1078  rSet.ClearItem( RES_OPAQUE );
1079  rSet.ClearItem( RES_SURROUND );
1080  }
1081  }
1082  }
1083  rSet.SetParent( pFly->GetFormat()->GetAttrSet().GetParent() );
1084  // attributes must be removed
1085  rSet.ClearItem( RES_FILL_ORDER );
1086  rSet.ClearItem( RES_CNTNT );
1087  //MA: remove first (Template by example etc.)
1088  rSet.ClearItem( RES_CHAIN );
1089  return true;
1090 }
1091 
1092 // Attributes of the current fly will change.
1094 {
1095  CurrShell aCurr( this );
1096  bool bRet = false;
1097 
1098  if( rSet.Count() )
1099  {
1101  OSL_ENSURE(pFly, "SetFlyFrameAttr, no Fly selected.");
1102  if (pFly)
1103  {
1104  StartAllAction();
1105  const Point aPt( pFly->getFrameArea().Pos() );
1106 
1107  if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
1108  sw_ChkAndSetNewAnchor( *pFly, rSet );
1109  SwFlyFrameFormat* pFlyFormat = pFly->GetFormat();
1110 
1111  if( GetDoc()->SetFlyFrameAttr( *pFlyFormat, rSet ))
1112  {
1113  bRet = true;
1114  SwFlyFrame* pFrame = pFlyFormat->GetFrame( &aPt );
1115  if( pFrame )
1116  SelectFlyFrame( *pFrame );
1117  else
1119  }
1120 
1122  }
1123  }
1124  return bRet;
1125 }
1126 
1128 {
1129  // The set also includes VERT/HORI_ORIENT, because the align
1130  // shall be changed in FEShell::SetFlyFrameAttr/SetFlyFrameAnchor,
1131  // possibly as a result of the anchor change.
1132  SfxItemSet aSet(rPool, svl::Items<RES_VERT_ORIENT, RES_ANCHOR>);
1133  aSet.Put(rAnchor);
1134  return aSet;
1135 }
1136 
1138 {
1139  bool bRet = false;
1140  CurrShell aCurr( this );
1141  if ( !rSet.Count() ||
1142  !Imp()->HasDrawView() )
1143  return bRet;
1144 
1145  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1146  if ( rMrkList.GetMarkCount() != 1 )
1147  return bRet;
1148 
1149  StartUndo();
1150  SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1151  SwFrameFormat *pFormat = FindFrameFormat( pObj );
1152  StartAllAction();
1153  if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
1154  {
1155  RndStdIds nNew = rSet.Get( RES_ANCHOR ).GetAnchorId();
1156  if ( nNew != pFormat->GetAnchor().GetAnchorId() )
1157  {
1158  ChgAnchor( nNew );
1159  // #i26791# - clear anchor attribute in item set,
1160  // because method <ChgAnchor(..)> takes care of it.
1161  rSet.ClearItem( RES_ANCHOR );
1162  }
1163  }
1164 
1165  if( GetDoc()->SetFlyFrameAttr( *pFormat, rSet ))
1166  {
1167  bRet = true;
1168  SelectObj( Point(), 0, pObj );
1169  }
1171  EndUndo();
1172  return bRet;
1173 }
1174 
1175 // Reset attributes contained in the set.
1177 {
1178  CurrShell aCurr( this );
1179 
1181  OSL_ENSURE( pFly, "SetFlyFrameAttr, no Fly selected." );
1182  if( !pFly )
1183  return;
1184 
1185  StartAllAction();
1186 
1187  SfxItemIter aIter( *pSet );
1188  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1189  {
1190  if( !IsInvalidItem( pItem ) )
1191  {
1192  sal_uInt16 nWhich = pItem->Which();
1193  if( RES_ANCHOR != nWhich && RES_CHAIN != nWhich && RES_CNTNT != nWhich )
1194  pFly->GetFormat()->ResetFormatAttr( nWhich );
1195  }
1196  }
1197 
1200 }
1201 
1202 // Returns frame-format if frame, otherwise 0
1204 {
1205  SwFrameFormat* pRet = nullptr;
1207  if( pFly && ( pRet = static_cast<SwFrameFormat*>(pFly->GetFormat()->DerivedFrom()) ) ==
1208  GetDoc()->GetDfltFrameFormat() )
1209  pRet = nullptr;
1210  return pRet;
1211 }
1212 
1213 void SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point const * pDocPos )
1214 {
1215  SwFlyFrame *pFly = nullptr;
1216  if(pDocPos)
1217  {
1218  const SwFrameFormat* pFormat = GetFormatFromObj( *pDocPos );
1219 
1220  if (const SwFlyFrameFormat* pFlyFormat = dynamic_cast<const SwFlyFrameFormat*>(pFormat))
1221  pFly = pFlyFormat->GetFrame();
1222  }
1223  else
1224  pFly = GetSelectedFlyFrame();
1225  OSL_ENSURE( pFly, "SetFrameFormat: no frame" );
1226  if( !pFly )
1227  return;
1228 
1229  StartAllAction();
1230  CurrShell aCurr( this );
1231 
1232  SwFlyFrameFormat* pFlyFormat = pFly->GetFormat();
1233  const Point aPt( pFly->getFrameArea().Pos() );
1234 
1235  std::unique_ptr<SfxItemSet> pSet;
1236  const SfxPoolItem* pItem;
1237  if( SfxItemState::SET == pNewFormat->GetItemState( RES_ANCHOR, false, &pItem ))
1238  {
1239  pSet.reset(new SfxItemSet( GetDoc()->GetAttrPool(), aFrameFormatSetRange ));
1240  pSet->Put( *pItem );
1241  if( !sw_ChkAndSetNewAnchor( *pFly, *pSet ))
1242  {
1243  pSet.reset();
1244  }
1245  }
1246 
1247  if( GetDoc()->SetFrameFormatToFly( *pFlyFormat, *pNewFormat, pSet.get(), bKeepOrient ))
1248  {
1249  SwFlyFrame* pFrame = pFlyFormat->GetFrame( &aPt );
1250  if( pFrame )
1251  SelectFlyFrame( *pFrame );
1252  else
1254  }
1255  pSet.reset();
1256 
1258 }
1259 
1261 {
1262  const SwFlyFrame* pFly = GetSelectedOrCurrFlyFrame();
1263  if (pFly)
1264  return pFly->GetFormat();
1265  return nullptr;
1266 }
1267 
1269 {
1271  if (pFly)
1272  return pFly->GetFormat();
1273  return nullptr;
1274 }
1275 
1277 {
1278  SwFlyFrame *pFly = GetCurrFlyFrame(false);
1279  if (!pFly)
1280  {
1281  SwRect aRect;
1282  return aRect;
1283  }
1284  else
1285  return pFly->getFrameArea();
1286 }
1287 
1289 {
1290  if( Imp()->HasDrawView() )
1291  return SwRect(Imp()->GetDrawView()->GetAllMarkedRect());
1292  else
1293  {
1294  SwRect aRect;
1295  return aRect;
1296  }
1297 }
1298 
1299 void SwFEShell::SetObjRect( const SwRect& rRect )
1300 {
1301  if ( Imp()->HasDrawView() )
1302  {
1303  Imp()->GetDrawView()->SetAllMarkedRect( rRect.SVRect() );
1304  CallChgLnk(); // call AttrChangeNotify on the UI-side.
1305  }
1306 }
1307 
1308 Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference < embed::XEmbeddedObject >& xObj )
1309 {
1310  Size aResult;
1311 
1312  SwFlyFrame *pFly = FindFlyFrame( xObj );
1313  if ( !pFly )
1314  {
1315  aResult = rRect.SSize();
1316  return aResult;
1317  }
1318 
1319  aResult = pFly->getFramePrintArea().SSize();
1320 
1321  bool bPosProt = pFly->GetFormat()->GetProtect().IsPosProtected();
1322  bool bSizeProt = pFly->GetFormat()->GetProtect().IsSizeProtected();
1323 
1324  StartAllAction();
1325 
1326  // MA we do not allow to clip the Fly, as the OLE server can
1327  // request various wishes. Clipping is done via the formatting.
1328  // Correct display is done by scaling.
1329  // Scaling is done by SwNoTextFrame::Format by calling
1330  // SwWrtShell::CalcAndSetScale()
1331  if ( rRect.SSize() != pFly->getFramePrintArea().SSize() && !bSizeProt )
1332  {
1333  Size aSz( rRect.SSize() );
1334 
1335  //JP 28.02.2001: Task 74707 - ask for fly in fly with automatic size
1336 
1337  const SwFrame* pAnchor;
1338  const SwFormatFrameSize& rFrameSz = pFly->GetFormat()->GetFrameSize();
1340  0 != rFrameSz.GetWidthPercent() &&
1341  nullptr != (pAnchor = pFly->GetAnchorFrame()) &&
1342  pAnchor->IsTextFrame() &&
1343  !pAnchor->GetNext() && !pAnchor->GetPrev() &&
1344  pAnchor->GetUpper()->IsFlyFrame())
1345  {
1346  // search for a sequence field:
1347  sw::MergedAttrIter iter(*static_cast<SwTextFrame const*>(pAnchor));
1348  for (SwTextAttr const* pHint = iter.NextAttr(); pHint; pHint = iter.NextAttr())
1349  {
1350  const SfxPoolItem* pItem = &pHint->GetAttr();
1351  if( RES_TXTATR_FIELD == pItem->Which()
1352  && SwFieldTypesEnum::Sequence == static_cast<const SwFormatField*>(pItem)->GetField()->GetTypeId() )
1353  {
1354  // sequence field found
1355  SwFlyFrame* pChgFly = const_cast<SwFlyFrame*>(static_cast<const SwFlyFrame*>(pAnchor->GetUpper()));
1356  // calculate the changed size:
1357  // width must change, height can change
1358  Size aNewSz( aSz.Width() + pChgFly->getFrameArea().Width() -
1359  pFly->getFramePrintArea().Width(), aSz.Height() );
1360 
1361  SwFrameFormat *pFormat = pChgFly->GetFormat();
1362  SwFormatFrameSize aFrameSz( pFormat->GetFrameSize() );
1363  aFrameSz.SetWidth( aNewSz.Width() );
1364  if( SwFrameSize::Minimum != aFrameSz.GetHeightSizeType() )
1365  {
1366  aNewSz.AdjustHeight(pChgFly->getFrameArea().Height() -
1367  pFly->getFramePrintArea().Height() );
1368  if( std::abs( aNewSz.Height() - pChgFly->getFrameArea().Height()) > 1 )
1369  aFrameSz.SetHeight( aNewSz.Height() );
1370  }
1371  // via Doc for the Undo!
1372  pFormat->GetDoc()->SetAttr( aFrameSz, *pFormat );
1373  break;
1374  }
1375  }
1376  }
1377 
1378  // set the new Size at the fly themself
1379  if ( !pFly->getFramePrintArea().IsEmpty() )
1380  {
1381  aSz.AdjustWidth(pFly->getFrameArea().Width() - pFly->getFramePrintArea().Width() );
1382  aSz.AdjustHeight(pFly->getFrameArea().Height()- pFly->getFramePrintArea().Height() );
1383  }
1384  aResult = pFly->ChgSize( aSz );
1385 
1386  // if the object changes, the contour is outside the object
1387  assert(pFly->Lower()->IsNoTextFrame());
1388  SwNoTextNode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetNoTextNode();
1389  assert(pNd);
1390  pNd->SetContour( nullptr );
1391  ClrContourCache();
1392  }
1393 
1394  // if only the size is to be adjusted, a position is transported with
1395  // allocated values
1396  Point aPt( pFly->getFramePrintArea().Pos() );
1397  aPt += pFly->getFrameArea().Pos();
1398  if ( rRect.Top() != LONG_MIN && rRect.Pos() != aPt && !bPosProt )
1399  {
1400  aPt = rRect.Pos();
1401  aPt.setX(aPt.getX() - pFly->getFramePrintArea().Left());
1402  aPt.setY(aPt.getY() - pFly->getFramePrintArea().Top());
1403 
1404  // in case of paragraph-bound Flys, starting from the new position,
1405  // a new anchor is to be set. The anchor and the new RelPos are
1406  // calculated by the Fly and set
1407  if( pFly->IsFlyAtContentFrame() )
1408  static_cast<SwFlyAtContentFrame*>(pFly)->SetAbsPos( aPt );
1409  else
1410  {
1411  const SwFrameFormat *pFormat = pFly->GetFormat();
1412  const SwFormatVertOrient &rVert = pFormat->GetVertOrient();
1413  const SwFormatHoriOrient &rHori = pFormat->GetHoriOrient();
1414  const tools::Long lXDiff = aPt.getX() - pFly->getFrameArea().Left();
1415  const tools::Long lYDiff = aPt.getY() - pFly->getFrameArea().Top();
1416  const Point aTmp( rHori.GetPos() + lXDiff,
1417  rVert.GetPos() + lYDiff );
1418  pFly->ChgRelPos( aTmp );
1419  }
1420  }
1421 
1422  SwFlyFrameFormat *pFlyFrameFormat = pFly->GetFormat();
1423  OSL_ENSURE( pFlyFrameFormat, "fly frame format missing!" );
1424  if ( pFlyFrameFormat )
1425  pFlyFrameFormat->SetLastFlyFramePrtRectPos( pFly->getFramePrintArea().Pos() ); //stores the value of last Prt rect
1426 
1427  EndAllAction();
1428 
1429  return aResult;
1430 }
1431 
1433 {
1434  // do not search the Fly via the layout. Now we can delete a frame
1435  // without a valid layout. ( e.g. for the wizards )
1436  SwFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats();
1437  if( !rSpzArr.empty() )
1438  {
1439  SwNodeIndex& rCursorNd = GetCursor()->GetPoint()->nNode;
1440  if( rCursorNd.GetIndex() > mxDoc->GetNodes().GetEndOfExtras().GetIndex() )
1441  // Cursor is in the body area!
1442  return nullptr;
1443 
1444  for( auto pFormat : rSpzArr )
1445  {
1446  const SwNodeIndex* pIdx = pFormat->GetContent( false ).GetContentIdx();
1447  SwStartNode* pSttNd;
1448  if( pIdx &&
1449  nullptr != ( pSttNd = pIdx->GetNode().GetStartNode() ) &&
1450  pSttNd->GetIndex() < rCursorNd.GetIndex() &&
1451  rCursorNd.GetIndex() < pSttNd->EndOfSectionIndex() )
1452  {
1453  // found: return immediately
1454  return pFormat;
1455  }
1456  }
1457  }
1458  return nullptr;
1459 }
1460 
1461 void SwFEShell::SetFlyName( const OUString& rName )
1462 {
1464  if( pFly )
1465  GetDoc()->SetFlyName( *static_cast<SwFlyFrameFormat*>(pFly->GetFormat()), rName );
1466  else {
1467  OSL_ENSURE( false, "no FlyFrame selected" );
1468  }
1469 }
1470 
1471 OUString SwFEShell::GetFlyName() const
1472 {
1474  if( pFly )
1475  return pFly->GetFormat()->GetName();
1476 
1477  OSL_ENSURE( false, "no FlyFrame selected" );
1478  return OUString();
1479 }
1480 
1481 uno::Reference < embed::XEmbeddedObject > SwFEShell::GetOleRef() const
1482 {
1483  uno::Reference < embed::XEmbeddedObject > xObj;
1484  SwFlyFrame * pFly = GetSelectedFlyFrame();
1485  if (pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame())
1486  {
1487  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
1488  if (pNd)
1489  xObj = pNd->GetOLEObj().GetOleRef();
1490  }
1491  return xObj;
1492 }
1493 
1495 {
1496  return GetDoc()->GetUniqueGrfName();
1497 }
1498 
1499 const SwFrameFormat* SwFEShell::IsURLGrfAtPos( const Point& rPt, OUString* pURL,
1500  OUString *pTargetFrameName,
1501  OUString *pDescription ) const
1502 {
1503  if( !Imp()->HasDrawView() )
1504  return nullptr;
1505 
1506  SdrPageView* pPV;
1507  const SwFrameFormat* pRet = nullptr;
1508  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1509 
1510  const auto nOld = pDView->GetHitTolerancePixel();
1511  pDView->SetHitTolerancePixel( 2 );
1512 
1513  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMACRO);
1514  SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1515  if (pFlyObj)
1516  {
1517  SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
1518  const SwFormatURL &rURL = pFly->GetFormat()->GetURL();
1519  if( !rURL.GetURL().isEmpty() || rURL.GetMap() )
1520  {
1521  bool bSetTargetFrameName = pTargetFrameName != nullptr;
1522  bool bSetDescription = pDescription != nullptr;
1523  if ( rURL.GetMap() )
1524  {
1525  IMapObject *pObject = pFly->GetFormat()->GetIMapObject( rPt, pFly );
1526  if ( pObject && !pObject->GetURL().isEmpty() )
1527  {
1528  if( pURL )
1529  *pURL = pObject->GetURL();
1530  if ( bSetTargetFrameName && !pObject->GetTarget().isEmpty() )
1531  {
1532  bSetTargetFrameName = false;
1533  *pTargetFrameName = pObject->GetTarget();
1534  }
1535  if ( bSetDescription )
1536  {
1537  bSetDescription = false;
1538  *pDescription = pObject->GetAltText();
1539  }
1540  pRet = pFly->GetFormat();
1541  }
1542  }
1543  else
1544  {
1545  if( pURL )
1546  {
1547  *pURL = rURL.GetURL();
1548  if( rURL.IsServerMap() )
1549  {
1550  // append the relative pixel position !!
1551  Point aPt( rPt );
1552  aPt -= pFly->getFrameArea().Pos();
1553  // without MapMode-Offset, without Offset, o ... !!!!!
1554  aPt = GetOut()->LogicToPixel(
1555  aPt, MapMode( MapUnit::MapTwip ) );
1556  *pURL = *pURL + "?" + OUString::number( aPt.getX() )
1557  + "," + OUString::number(aPt.getY() );
1558  }
1559  }
1560  pRet = pFly->GetFormat();
1561  }
1562  if ( bSetTargetFrameName )
1563  *pTargetFrameName = rURL.GetTargetFrameName();
1564  if ( bSetDescription )
1565  *pDescription = pFly->GetFormat()->GetName();
1566  }
1567  }
1568  pDView->SetHitTolerancePixel( nOld );
1569  return pRet;
1570 }
1571 
1572 const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
1573  OUString &rName, bool &rbLink ) const
1574 {
1575  if( !Imp()->HasDrawView() )
1576  return nullptr;
1577 
1578  SdrPageView* pPV;
1579  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1580 
1581  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV);
1582  SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1583  if (pFlyObj)
1584  {
1585  SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
1586  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1587  {
1588  SwGrfNode *const pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode();
1589  if ( pNd )
1590  {
1591  if ( pNd->IsGrfLink() )
1592  {
1593  // halfway ready graphic?
1594  ::sfx2::SvLinkSource* pLnkObj = pNd->GetLink()->GetObj();
1595  if( pLnkObj && pLnkObj->IsPending() )
1596  return nullptr;
1597  rbLink = true;
1598  }
1599 
1600  pNd->GetFileFilterNms( &rName, nullptr );
1601  if ( rName.isEmpty() )
1602  rName = pFly->GetFormat()->GetName();
1603  return &pNd->GetGrf(true);
1604  }
1605  }
1606  }
1607  return nullptr;
1608 }
1609 
1610 const SwFrameFormat* SwFEShell::GetFormatFromObj( const Point& rPt, SwRect** pRectToFill ) const
1611 {
1612  SwFrameFormat* pRet = nullptr;
1613 
1614  if( Imp()->HasDrawView() )
1615  {
1616  SdrPageView* pPView;
1617 
1618  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1619 
1620  const auto nOld = pDView->GetHitTolerancePixel();
1621  // tolerance for Drawing-SS
1622  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1623 
1624  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
1625  if (pObj)
1626  {
1627  // first check it:
1628  if (SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
1629  pRet = pFlyObj->GetFormat();
1630  else if ( pObj->GetUserCall() ) //not for group objects
1631  pRet = static_cast<SwDrawContact*>(pObj->GetUserCall())->GetFormat();
1632  if(pRet && pRectToFill)
1633  **pRectToFill = SwRect(pObj->GetCurrentBoundRect());
1634  }
1635  pDView->SetHitTolerancePixel( nOld );
1636  }
1637  return pRet;
1638 }
1639 
1640 // returns a format too, if the point is over the text of any fly
1641 const SwFrameFormat* SwFEShell::GetFormatFromAnyObj( const Point& rPt ) const
1642 {
1643  const SwFrameFormat* pRet = GetFormatFromObj( rPt );
1644  if( !pRet || RES_FLYFRMFMT == pRet->Which() )
1645  {
1646  SwPosition aPos( *GetCursor()->GetPoint() );
1647  Point aPt( rPt );
1648  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
1649  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
1650  std::pair<Point, bool> const tmp(rPt, false);
1651  SwFrame* pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp)->FindFlyFrame();
1652  pRet = pFrame ? static_cast<SwLayoutFrame*>(pFrame)->GetFormat() : nullptr;
1653  }
1654  return pRet;
1655 }
1656 
1658 {
1660 
1661  // investigate 'master' drawing object, if method
1662  // is called for a 'virtual' drawing object.
1663  const SdrObject* pInvestigatedObj;
1664  if (const SwDrawVirtObj* pDrawVirtObj = dynamic_cast<const SwDrawVirtObj*>( &rObj))
1665  {
1666  pInvestigatedObj = &(pDrawVirtObj->GetReferencedObj());
1667  }
1668  else
1669  {
1670  pInvestigatedObj = &rObj;
1671  }
1672 
1673  if( SdrInventor::FmForm == pInvestigatedObj->GetObjInventor() )
1674  {
1675  eType = OBJCNT_CONTROL;
1676  uno::Reference< awt::XControlModel > xModel =
1677  static_cast<const SdrUnoObj&>(*pInvestigatedObj).GetUnoControlModel();
1678  if( xModel.is() )
1679  {
1680  uno::Any aVal;
1681  OUString sName("ButtonType");
1682  uno::Reference< beans::XPropertySet > xSet(xModel, uno::UNO_QUERY);
1683 
1684  uno::Reference< beans::XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
1685  if(xInfo->hasPropertyByName( sName ))
1686  {
1687  aVal = xSet->getPropertyValue( sName );
1688  if( aVal.hasValue() && form::FormButtonType_URL == *o3tl::doAccess<form::FormButtonType>(aVal) )
1689  eType = OBJCNT_URLBUTTON;
1690  }
1691  }
1692  }
1693  else if (const SwVirtFlyDrawObj *pFlyObj = dynamic_cast<const SwVirtFlyDrawObj*>(pInvestigatedObj))
1694  {
1695  const SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
1696  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1697  {
1698  if (static_cast<const SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode())
1699  eType = OBJCNT_GRF;
1700  else
1701  eType = OBJCNT_OLE;
1702  }
1703  else
1704  eType = OBJCNT_FLY;
1705  }
1706  else if ( dynamic_cast<const SdrObjGroup*>( pInvestigatedObj) != nullptr )
1707  {
1708  SwDrawContact* pDrawContact( dynamic_cast<SwDrawContact*>(GetUserCall( pInvestigatedObj ) ) );
1709  if ( !pDrawContact )
1710  {
1711  OSL_FAIL( "<SwFEShell::GetObjCntType(..)> - missing draw contact object" );
1712  eType = OBJCNT_NONE;
1713  }
1714  else
1715  {
1716  SwFrameFormat* pFrameFormat( pDrawContact->GetFormat() );
1717  if ( !pFrameFormat )
1718  {
1719  OSL_FAIL( "<SwFEShell::GetObjCntType(..)> - missing frame format" );
1720  eType = OBJCNT_NONE;
1721  }
1722  else if ( RndStdIds::FLY_AS_CHAR != pFrameFormat->GetAnchor().GetAnchorId() )
1723  {
1724  eType = OBJCNT_GROUPOBJ;
1725  }
1726  }
1727  }
1728  else
1729  eType = OBJCNT_SIMPLE;
1730  return eType;
1731 }
1732 
1733 ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const
1734 {
1736 
1737  if( Imp()->HasDrawView() )
1738  {
1739  SdrPageView* pPView;
1740 
1741  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1742 
1743  const auto nOld = pDView->GetHitTolerancePixel();
1744  // tolerance for Drawing-SS
1745  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1746 
1747  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
1748  if (pObj)
1749  {
1750  rpObj = pObj;
1751  eType = GetObjCntType( *rpObj );
1752  }
1753 
1754  pDView->SetHitTolerancePixel( nOld );
1755  }
1756  return eType;
1757 }
1758 
1760 {
1762 
1763  if( Imp()->HasDrawView() )
1764  {
1765  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1766  for( size_t i = 0, nE = rMrkList.GetMarkCount(); i < nE; ++i )
1767  {
1768  SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1769  if( !pObj )
1770  continue;
1771  ObjCntType eTmp = GetObjCntType( *pObj );
1772  if( !i )
1773  {
1774  eType = eTmp;
1775  }
1776  else if( eTmp != eType )
1777  {
1778  eType = OBJCNT_DONTCARE;
1779  // once DontCare, always DontCare!
1780  break;
1781  }
1782  }
1783  }
1784  return eType;
1785 }
1786 
1787 void SwFEShell::ReplaceSdrObj( const OUString& rGrfName, const Graphic* pGrf )
1788 {
1789  CurrShell aCurr( this );
1790 
1791  const SdrMarkList *pMrkList;
1792  if( !(Imp()->HasDrawView() && 1 ==
1793  ( pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList())->GetMarkCount()) )
1794  return;
1795 
1796  SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1797  SwFrameFormat *pFormat = FindFrameFormat( pObj );
1798 
1799  // store attributes, then set the graphic
1800  SfxItemSet aFrameSet( mxDoc->GetAttrPool(),
1801  pFormat->GetAttrSet().GetRanges() );
1802  aFrameSet.Set( pFormat->GetAttrSet() );
1803 
1804  // set size and position?
1805  if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
1806  {
1807  // then let's do it:
1808  const tools::Rectangle &rBound = pObj->GetSnapRect();
1809  Point aRelPos( pObj->GetRelativePos() );
1810 
1811  const tools::Long nWidth = rBound.Right() - rBound.Left();
1812  const tools::Long nHeight= rBound.Bottom() - rBound.Top();
1813  aFrameSet.Put( SwFormatFrameSize( SwFrameSize::Minimum,
1814  std::max( nWidth, tools::Long(MINFLY) ),
1815  std::max( nHeight, tools::Long(MINFLY) )));
1816 
1817  if( SfxItemState::SET != aFrameSet.GetItemState( RES_HORI_ORIENT ))
1818  aFrameSet.Put( SwFormatHoriOrient( aRelPos.getX(), text::HoriOrientation::NONE, text::RelOrientation::FRAME ));
1819 
1820  if( SfxItemState::SET != aFrameSet.GetItemState( RES_VERT_ORIENT ))
1821  aFrameSet.Put( SwFormatVertOrient( aRelPos.getY(), text::VertOrientation::NONE, text::RelOrientation::FRAME ));
1822 
1823  }
1824 
1825  pObj->GetOrdNum();
1826 
1827  StartAllAction();
1828  StartUndo();
1829 
1830  // delete "Sdr-Object", insert the graphic instead
1831  DelSelectedObj();
1832 
1834  *GetCursor(), rGrfName, "", pGrf, &aFrameSet, nullptr, nullptr);
1835 
1836  EndUndo();
1837  EndAllAction();
1838 }
1839 
1840 static sal_uInt16 SwFormatGetPageNum(const SwFlyFrameFormat * pFormat)
1841 {
1842  OSL_ENSURE(pFormat != nullptr, "invalid argument");
1843 
1844  SwFlyFrame * pFrame = pFormat->GetFrame();
1845 
1846  sal_uInt16 aResult;
1847 
1848  if (pFrame != nullptr)
1849  aResult = pFrame->GetPhyPageNum();
1850  else
1851  aResult = pFormat->GetAnchor().GetPageNum();
1852 
1853  return aResult;
1854 }
1855 
1857  const OUString & rReference,
1858  bool bSuccessors,
1859  std::vector< OUString > & aPrevPageVec,
1860  std::vector< OUString > & aThisPageVec,
1861  std::vector< OUString > & aNextPageVec,
1862  std::vector< OUString > & aRestVec)
1863 {
1864  StartAction();
1865 
1866  SwFormatChain rChain = rFormat.GetChain();
1867  SwFrameFormat * pOldChainNext = rChain.GetNext();
1868  SwFrameFormat * pOldChainPrev = rChain.GetPrev();
1869 
1870  if (pOldChainNext)
1871  mxDoc->Unchain(rFormat);
1872 
1873  if (pOldChainPrev)
1874  mxDoc->Unchain(*pOldChainPrev);
1875 
1876  const size_t nCnt = mxDoc->GetFlyCount(FLYCNTTYPE_FRM);
1877 
1878  /* potential successors resp. predecessors */
1879  std::vector< const SwFrameFormat * > aTmpSpzArray;
1880 
1881  mxDoc->FindFlyByName(rReference);
1882 
1883  for (size_t n = 0; n < nCnt; ++n)
1884  {
1885  const SwFrameFormat & rFormat1 = *(mxDoc->GetFlyNum(n, FLYCNTTYPE_FRM));
1886 
1887  /*
1888  pFormat is a potential successor of rFormat if it is chainable after
1889  rFormat.
1890 
1891  pFormat is a potential predecessor of rFormat if rFormat is chainable
1892  after pFormat.
1893  */
1894 
1895  SwChainRet nChainState;
1896 
1897  if (bSuccessors)
1898  nChainState = mxDoc->Chainable(rFormat, rFormat1);
1899  else
1900  nChainState = mxDoc->Chainable(rFormat1, rFormat);
1901 
1902  if (nChainState == SwChainRet::OK)
1903  {
1904  aTmpSpzArray.push_back(&rFormat1);
1905 
1906  }
1907 
1908  }
1909 
1910  if (!aTmpSpzArray.empty())
1911  {
1912  aPrevPageVec.clear();
1913  aThisPageVec.clear();
1914  aNextPageVec.clear();
1915  aRestVec.clear();
1916 
1917  /* number of page rFormat resides on */
1918  sal_uInt16 nPageNum = SwFormatGetPageNum(static_cast<SwFlyFrameFormat *>(&rFormat));
1919 
1920  for (const auto& rpFormat : aTmpSpzArray)
1921  {
1922  const OUString aString = rpFormat->GetName();
1923 
1924  /* rFormat is not a valid successor or predecessor of
1925  itself */
1926  if (aString != rReference && aString != rFormat.GetName())
1927  {
1928  sal_uInt16 nNum1 =
1929  SwFormatGetPageNum(static_cast<const SwFlyFrameFormat *>(rpFormat));
1930 
1931  if (nNum1 == nPageNum -1)
1932  aPrevPageVec.push_back(aString);
1933  else if (nNum1 == nPageNum)
1934  aThisPageVec.push_back(aString);
1935  else if (nNum1 == nPageNum + 1)
1936  aNextPageVec.push_back(aString);
1937  else
1938  aRestVec.push_back(aString);
1939  }
1940  }
1941 
1942  }
1943 
1944  if (pOldChainNext)
1945  mxDoc->Chain(rFormat, *pOldChainNext);
1946 
1947  if (pOldChainPrev)
1948  mxDoc->Chain(*pOldChainPrev, rFormat);
1949 
1950  EndAction();
1951 }
1952 
1953 // #i73249#
1954 OUString SwFEShell::GetObjTitle() const
1955 {
1956  if ( Imp()->HasDrawView() )
1957  {
1958  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
1959  if ( pMrkList->GetMarkCount() == 1 )
1960  {
1961  const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1962  const SwFrameFormat* pFormat = FindFrameFormat( pObj );
1963  if ( pFormat->Which() == RES_FLYFRMFMT )
1964  {
1965  return static_cast<const SwFlyFrameFormat*>(pFormat)->GetObjTitle();
1966  }
1967  return pObj->GetTitle();
1968  }
1969  }
1970 
1971  return OUString();
1972 }
1973 
1974 void SwFEShell::SetObjTitle( const OUString& rTitle )
1975 {
1976  if ( !Imp()->HasDrawView() )
1977  return;
1978 
1979  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
1980  if ( pMrkList->GetMarkCount() != 1 )
1981  return;
1982 
1983  SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1984  SwFrameFormat* pFormat = FindFrameFormat( pObj );
1985  if ( pFormat->Which() == RES_FLYFRMFMT )
1986  {
1987  GetDoc()->SetFlyFrameTitle( dynamic_cast<SwFlyFrameFormat&>(*pFormat),
1988  rTitle );
1989  }
1990  else
1991  {
1992  pObj->SetTitle( rTitle );
1993  }
1994 }
1995 
1997 {
1998  if ( Imp()->HasDrawView() )
1999  {
2000  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2001  if ( pMrkList->GetMarkCount() == 1 )
2002  {
2003  const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2004  const SwFrameFormat* pFormat = FindFrameFormat( pObj );
2005  if ( pFormat->Which() == RES_FLYFRMFMT )
2006  {
2007  return dynamic_cast<const SwFlyFrameFormat&>(*pFormat).GetObjDescription();
2008  }
2009  return pObj->GetDescription();
2010  }
2011  }
2012 
2013  return OUString();
2014 }
2015 
2016 void SwFEShell::SetObjDescription( const OUString& rDescription )
2017 {
2018  if ( !Imp()->HasDrawView() )
2019  return;
2020 
2021  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2022  if ( pMrkList->GetMarkCount() != 1 )
2023  return;
2024 
2025  SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2026  SwFrameFormat* pFormat = FindFrameFormat( pObj );
2027  if ( pFormat->Which() == RES_FLYFRMFMT )
2028  {
2029  GetDoc()->SetFlyFrameDescription(dynamic_cast<SwFlyFrameFormat&>(*pFormat),
2030  rDescription);
2031  }
2032  else
2033  {
2034  pObj->SetDescription( rDescription );
2035  }
2036 }
2037 
2038 void SwFEShell::AlignFormulaToBaseline( const uno::Reference < embed::XEmbeddedObject >& xObj )
2039 {
2040 #if OSL_DEBUG_LEVEL > 0
2041  SvGlobalName aCLSID( xObj->getClassID() );
2042  const bool bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
2043  OSL_ENSURE( bStarMath, "AlignFormulaToBaseline should only be called for Math objects" );
2044 
2045  if ( !bStarMath )
2046  return;
2047 #endif
2048 
2049  SwFlyFrame * pFly = FindFlyFrame( xObj );
2050  OSL_ENSURE( pFly , "No fly frame!" );
2051  SwFrameFormat * pFrameFormat = pFly ? pFly->GetFormat() : nullptr;
2052 
2053  // baseline to baseline alignment should only be applied to formulas anchored as char
2054  if ( !pFly || !pFrameFormat || RndStdIds::FLY_AS_CHAR != pFrameFormat->GetAnchor().GetAnchorId() )
2055  return;
2056 
2057  // get baseline from Math object
2058  uno::Any aBaseline;
2060  {
2061  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
2062  if ( xSet.is() )
2063  {
2064  try
2065  {
2066  aBaseline = xSet->getPropertyValue("BaseLine");
2067  }
2068  catch ( uno::Exception& )
2069  {
2070  OSL_FAIL( "Baseline could not be retrieved from Starmath!" );
2071  }
2072  }
2073  }
2074 
2075  sal_Int32 nBaseline = ::comphelper::getINT32(aBaseline);
2076  const MapMode aSourceMapMode( MapUnit::Map100thMM );
2077  const MapMode aTargetMapMode( MapUnit::MapTwip );
2078  nBaseline = OutputDevice::LogicToLogic( nBaseline, aSourceMapMode.GetMapUnit(), aTargetMapMode.GetMapUnit() );
2079 
2080  OSL_ENSURE( nBaseline > 0, "Wrong value of Baseline while retrieving from Starmath!" );
2081  //nBaseline must be moved by aPrt position
2082  const SwFlyFrameFormat *pFlyFrameFormat = pFly->GetFormat();
2083  OSL_ENSURE( pFlyFrameFormat, "fly frame format missing!" );
2084  if ( pFlyFrameFormat )
2085  nBaseline += pFlyFrameFormat->GetLastFlyFramePrtRectPos().Y();
2086 
2087  const SwFormatVertOrient &rVert = pFrameFormat->GetVertOrient();
2088  SwFormatVertOrient aVert( rVert );
2089  aVert.SetPos( -nBaseline );
2091 
2092  pFrameFormat->LockModify();
2093  pFrameFormat->SetFormatAttr( aVert );
2094  pFrameFormat->UnlockModify();
2095  pFly->InvalidatePos();
2096 
2097 }
2098 
2100 {
2101  StartAllAction();
2102 
2103  SwStartNode *pStNd;
2104  SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
2105  while ( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
2106  {
2107  ++aIdx;
2108  SwOLENode *pOleNode = dynamic_cast< SwOLENode * >( &aIdx.GetNode() );
2109  if ( pOleNode )
2110  {
2111  const uno::Reference < embed::XEmbeddedObject > & xObj( pOleNode->GetOLEObj().GetOleRef() );
2112  if (xObj.is())
2113  {
2114  SvGlobalName aCLSID( xObj->getClassID() );
2115  if ( SotExchange::IsMath( aCLSID ) )
2116  AlignFormulaToBaseline( xObj );
2117  }
2118  }
2119 
2120  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
2121  }
2122 
2123  EndAllAction();
2124 }
2125 
2126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:338
SwFrame * FindFooterOrHeader()
Definition: findfrm.cxx:548
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:683
void GetPageObjs(std::vector< SwFrameFormat * > &rFillArr)
SS for envelopes: get all page-bound objects and set them to new page.
Definition: fefly1.cxx:992
SAL_DLLPRIVATE void EndAllActionAndCall()
Terminate actions for all shells and call ChangeLink.
Definition: fews.cxx:69
Starts a section of nodes in the document model.
Definition: node.hxx:312
void SetFlyName(const OUString &rName)
Set name at selected FlyFrame.
Definition: fefly1.cxx:1461
const OUString & GetTarget() const
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
const SwVirtFlyDrawObj * GetVirtDrawObj() const
Definition: fly.cxx:2783
Base class of the Writer layout elements.
Definition: frame.hxx:313
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:158
OUString GetUniqueGrfName() const
Definition: doclay.cxx:1369
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
constexpr TypedWhichId< SwFormatFillOrder > RES_FILL_ORDER(RES_FRMATR_BEGIN)
void KillPams()
Definition: crsrsh.cxx:1022
sal_uLong GetIndex() const
Definition: node.hxx:291
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
bool hasValue()
virtual const SwFlyFrameFormat * GetFormat() const override
Definition: fly.cxx:2877
size_t GetMarkCount() const
Marks a position in the document model.
Definition: pam.hxx:35
virtual const tools::Rectangle & GetCurrentBoundRect() const
void ChgAnchor(RndStdIds eAnchorId, bool bSameOnly=false, bool bPosCorr=true)
frmatr.hxx.
Definition: feshview.cxx:2348
const SwFrameFormat * IsURLGrfAtPos(const Point &rPt, OUString *pURL=nullptr, OUString *pTargetFrameName=nullptr, OUString *pURLDescription=nullptr) const
Position is a graphic with URL?
Definition: fefly1.cxx:1499
const SwNodes & GetNodes() const
Definition: viewsh.cxx:2086
const tools::SvRef< sfx2::SvBaseLink > & GetLink() const
Definition: ndgrf.hxx:132
void InsertDrawObj(SdrObject &rDrawObj, const Point &rInsertPosition)
Insertion of a drawing object which have to be already inserted in the DrawModel. ...
Definition: fefly1.cxx:947
bool IsMultiSelection() const
Definition: pam.hxx:272
SwContentNode * GetNode(SwPaM &rPam, bool &rbFirst, SwMoveFnCollection const &fnMove, bool const bInReadOnly, SwRootFrame const *const i_pLayout)
This function returns the next node in direction of search.
Definition: pam.cxx:823
SdrView * GetDrawView()
Definition: vnew.cxx:376
OUString GetObjDescription() const
Definition: atrfrm.cxx:3251
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
bool CheckControlLayer(const SdrObject *pObj)
Definition: dcontact.cxx:679
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
SwViewShellImp * Imp()
Definition: viewsh.hxx:182
bool Set(const SfxItemSet &, bool bDeep=true)
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual SwFlyFrameFormat * InsertGraphic(const SwPaM &rRg, const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet, const SfxItemSet *pGrfAttrSet, SwFrameFormat *)=0
Insert graphic or formula.
SwUndoId
Definition: swundo.hxx:29
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
SfxItemSet(const SfxItemSet &)
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
const Graphic * GetGrfAtPos(const Point &rDocPos, OUString &rName, bool &rbLink) const
Deliver graphic in rName besides graphic name.
Definition: fefly1.cxx:1572
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Left(const tools::Long nLeft)
Definition: swrect.hxx:194
SwNodeIndex nNode
Definition: pam.hxx:37
bool IsTableMode() const
Definition: crsrsh.hxx:643
SwFrameFormat * WizardGetFly()
Find/delete fly containing the cursor.
Definition: fefly1.cxx:1432
void SetCompletePaint() const
Definition: frame.hxx:991
void SetHitTolerancePixel(sal_uInt16 nVal)
bool AreObjectsMarked() const
sal_uInt16 GetPageNum() const
Definition: fmtanchr.hxx:66
SwRect GetFlyRect() const
For moving flys with keyboard.
Definition: fefly1.cxx:1276
#define MINFLY
Definition: swtypes.hxx:60
SwTwips GetPos() const
Definition: fmtornt.hxx:92
virtual void SetModified()=0
Must be called manually at changes of format.
long Long
constexpr::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
const SwRect & getFramePrintArea() const
Definition: frame.hxx:179
OUString GetDescription() const
bool GetLastUndoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const
Definition: edws.cxx:237
virtual Point GetRelativePos() const
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:915
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1213
sal_Int64 n
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
const WhichRangesContainer & GetRanges() const
SwCursor * GetSwCursor() const
Definition: crsrsh.hxx:868
Definition: doc.hxx:188
void InvalidatePos()
Definition: frame.hxx:1040
ObjCntType
Definition: fesh.hxx:120
bool HasDrawView() const
Definition: vnew.cxx:361
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
void SetLastFlyFramePrtRectPos(const Point &rPoint)
Definition: frmfmt.hxx:247
SwNode & GetNode() const
Definition: ndindex.hxx:119
virtual bool IsPending() const
SdrMark * GetMark(size_t nNum) const
constexpr TypedWhichId< SvxOpaqueItem > RES_OPAQUE(99)
void Pos(const Point &rNew)
Definition: swrect.hxx:168
RotateFlyFrame3: Helper class when you want to make your SwFrame derivate transformable.
Definition: frame.hxx:234
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
static SfxItemSet makeItemSetFromFormatAnchor(SfxItemPool &rPool, const SwFormatAnchor &rAnchor)
Definition: fefly1.cxx:1127
bool IsSizeProtected() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SwFlyFrame * GetSelectedFlyFrame() const
Definition: fefly1.cxx:277
void ClearCharRectAndTopOfLine()
reset members and
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
void SetPageNum(sal_uInt16 nNew)
Definition: fmtanchr.hxx:72
EmbeddedObjectRef * pObject
void EndAllAction()
Definition: edws.cxx:97
The root element of a Writer document layout.
Definition: rootfrm.hxx:82
SwContact * GetUserCall(const SdrObject *pObj)
Returns the UserCall if applicable from the group object.
Definition: dcontact.cxx:171
WhichRangesContainer const aFrameFormatSetRange(svl::Items< RES_FRMATR_BEGIN, RES_FRMATR_END-1, RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1, XATTR_FILL_FIRST, XATTR_FILL_LAST >)
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
Value in Var-direction gives minimum (can be exceeded but not be less).
bool IsInHeaderFooter(const SwNodeIndex &rIdx) const
Definition: doclay.cxx:1552
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
SwTextAttr const * NextAttr(SwTextNode const **ppNode=nullptr)
Definition: txtfrm.cxx:89
virtual const tools::Rectangle & GetSnapRect() const
sal_uInt16 GetPhyPageNum() const
Definition: pagefrm.hxx:204
void SelectFlyFrame(SwFlyFrame &rFrame)
Definition: fefly1.cxx:238
bool IsRedlineOn() const
Definition: edredln.cxx:43
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const
Definition: unusedf.cxx:47
bool IsFlyAtContentFrame() const
Definition: flyfrm.hxx:218
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
void SetAllMarkedRect(const tools::Rectangle &rRect)
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
bool IsFlyFrame() const
Definition: frame.hxx:1207
const SfxPoolItem * NextItem()
wrapper class for the positioning of Writer fly frames and drawing objects
SwFlyFrameFormat * MakeFlySection(RndStdIds eAnchorType, const SwPosition *pAnchorPos, const SfxItemSet *pSet=nullptr, SwFrameFormat *pParent=nullptr, bool bCalledFromShell=false)
Definition: doclay.cxx:288
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
const SwFrameFormat * IsFlyInFly()
Is selected frame within another frame?
Definition: fefly1.cxx:312
void SetPageObjsNewPage(std::vector< SwFrameFormat * > &rFillArr)
Definition: fefly1.cxx:1005
tools::Long Left() const
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
rtl::Reference< SwDoc > mxDoc
The document; never 0.
Definition: viewsh.hxx:171
SwIndex nContent
Definition: pam.hxx:38
const SwRect & getFrameArea() const
Definition: frame.hxx:178
size_t pos
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
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:451
const OUString & GetName() const
Definition: format.hxx:115
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
tools::Long Bottom() const
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2560
bool IsTextFrame() const
Definition: frame.hxx:1231
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
SwFlyFrameFormat * MakeFlyAndMove(const SwPaM &rPam, const SfxItemSet &rSet, const SwSelBoxes *pSelBoxes, SwFrameFormat *pParent)
Definition: doclay.cxx:343
void Width(tools::Long nNew)
Definition: swrect.hxx:186
void SetFlyName(SwFlyFrameFormat &rFormat, const OUString &rName)
Definition: doclay.cxx:1420
SwDoc * GetDoc() const
Definition: viewsh.hxx:281
bool empty() const
static sal_uInt16 SwFormatGetPageNum(const SwFlyFrameFormat *pFormat)
Definition: fefly1.cxx:1840
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1108
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:494
SwFrameFormat * FindFrameFormat(SdrObject *pObj)
The Get reverse way: seeks the format to the specified object.
Definition: dcontact.cxx:120
void UnmarkAll()
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: viewsh.cxx:2668
static sal_uInt16 IsMath(const SvGlobalName &rName)
void SetFlyPos(const Point &rAbsPos)
Definition: fefly1.cxx:373
bool IsFlyInContentFrame() const
Definition: flyfrm.hxx:215
bool IsEmpty() const
Definition: swrect.hxx:291
virtual bool DoesUndo() const =0
Is Undo enabled?
virtual void MoveObjToVisibleLayer(SdrObject *_pDrawObj)
method to move drawing object to corresponding visible layer
Definition: dcontact.cxx:209
const char * sName
css::uno::Reference< css::embed::XEmbeddedObject > GetOleRef() const
get reference to OLE object (if there is one) for selected FlyFrame
Definition: fefly1.cxx:1481
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
Specific frame formats (frames, DrawObjects).
void InvalidateContent() const
Definition: pagefrm.hxx:380
void MakeVisible(const SwRect &)
Definition: viewsh.cxx:571
DocumentType eType
bool GetFlyFrameAttr(SfxItemSet &rSet) const
Definition: fefly1.cxx:1050
OUString GetObjTitle() const
Definition: fefly1.cxx:1954
SdrObject * GetMarkedSdrObj() const
void SetObjDescription(const OUString &rDescription)
Definition: fefly1.cxx:2016
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
bool HasWrap(const SdrObject *pObj)
Definition: dcontact.cxx:139
SdrObject * PickObj(const Point &rPnt, short nTol, SdrPageView *&rpPV, SdrSearchOptions nOptions, SdrObject **ppRootObj, bool *pbHitPassDirect=nullptr) const
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
virtual void SetLayer(SdrLayerID nLayer)
void SetLineColor()
constexpr TypedWhichId< SwFormatField > RES_TXTATR_FIELD(RES_TXTATR_NOEND_BEGIN)
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:58
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
const SfxItemSet * GetParent() const
void AlignFormulaToBaseline(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj)
for starmath formulas anchored 'as char' it aligns it baseline to baseline changing the previous vert...
Definition: fefly1.cxx:2038
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
int i
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:149
SwDoc & GetDoc()
Definition: node.hxx:212
void SetVertOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:56
const SwPosition * GetPoint() const
Definition: pam.hxx:207
void SetAssertFlyPages()
Makes sure that all requested page-bound Flys find a Page.
Definition: rootfrm.hxx:278
const OUString & GetAltText() const
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
SwPageFrame * FindPageFrame()
Definition: frame.hxx:679
void ParkCursor(const SwNodeIndex &rIdx)
Remove selections and additional cursors of all shells.
Definition: crsrsh.cxx:2875
void GetConnectableFrameFormats(SwFrameFormat &rFormat, const OUString &rReference, bool bSuccessors, std::vector< OUString > &aPrevPageVec, std::vector< OUString > &aThisPageVec, std::vector< OUString > &aNextPageVec, std::vector< OUString > &aRestVec)
Definition: fefly1.cxx:1856
sal_uInt16 GetPhyPageNum() const
Phy: real page count.
Definition: fews.cxx:335
SwFlyFrame * GetSelectedOrCurrFlyFrame() const
Definition: fefly1.cxx:303
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
Definition: docfly.cxx:609
const SwFrame * Lower() const
Definition: layfrm.hxx:101
void SetPos(SwTwips nNew)
Definition: fmtornt.hxx:60
SwContentNode * GetContentNode()
Definition: node.hxx:616
void SelectionHasChanged(SwFEShell *pShell)
Definition: fly.cxx:1832
const SdrMarkList & GetMarkedObjectList() const
sal_uInt16 Count() const
FlyAnchors.
Definition: fmtanchr.hxx:34
bool SetFlyFrameAttr(SfxItemSet &rSet)
Definition: fefly1.cxx:1093
static bool lcl_SetNewFlyPos(const SwNode &rNode, SwFormatAnchor &rAnchor, const Point &rPt)
Definition: fefly1.cxx:82
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
SwNoTextNode * GetNoTextNode()
Definition: ndnotxt.hxx:96
const SwFormatURL & GetURL(bool=true) const
Definition: fmturl.hxx:78
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
bool HasArea() const
Definition: swrect.hxx:287
Not determinable - different objects are selected.
Definition: fesh.hxx:131
const Color & GetLineColor() const
virtual void DelFrames()
Destroys all Frames in aDepend (Frames are identified via dynamic_cast).
Definition: atrfrm.cxx:2733
::rtl::Reference< Content > pContent
OUString GetTitle() const
void UnlockModify()
Definition: calbck.hxx:204
sal_uInt32 GetOrdNum() const
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
void LockModify()
Definition: calbck.hxx:203
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
Definition: format.cxx:388
Connection (text flow) between two FlyFrames.
Definition: fmtcnct.hxx:31
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFlyFrame * GetCurrFlyFrame(const bool bCalcFrame=true) const
Definition: fefly1.cxx:296
ring_container GetRingContainer()
MapUnit GetMapUnit() const
virtual void SetRelativePos(const Point &rPnt)
bool empty() const
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
void SetObjRect(const SwRect &rRect)
Set size of draw objects.
Definition: fefly1.cxx:1299
void SSize(const Size &rNew)
Definition: swrect.hxx:177
tools::Long Top() const
SwStartNode * GetStartNode()
Definition: node.hxx:592
const SwFrameFormat * GetFormatFromAnyObj(const Point &rPt) const
Definition: fefly1.cxx:1641
virtual const SwAnchoredObject * GetAnchoredObj(const SdrObject *_pSdrObj) const =0
void InvalidateFlyLayout() const
Validate, invalidate and query the Page status Layout/Content and Fly/non-Fly respectively are inspec...
Definition: pagefrm.hxx:364
void Insert(const OUString &rGrfName, const OUString &rFltName, const Graphic *pGraphic, const SfxItemSet *pFlyAttrSet)
Definition: fefly1.cxx:824
A page of the document layout.
Definition: pagefrm.hxx:57
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
Definition: docfly.cxx:558
stay with the cursor inside text
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
OUString GetName() const
const SwPosition * Start() const
Definition: pam.hxx:212
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
SwFlyFrameFormat * GetNext() const
Definition: fmtcnct.hxx:54
virtual SdrInventor GetObjInventor() const
bool m_bCheckForOLEInCaption
Definition: fesh.hxx:207
void SetWidth(tools::Long n)
virtual SwFlyFrameFormat * InsertEmbObject(const SwPaM &rRg, const svt::EmbeddedObjectRef &xObj, SfxItemSet *pFlyAttrSet)=0
Insert OLE-objects.
constexpr Point TopLeft() const
SAL_DLLPRIVATE SwFlyFrame * FindFlyFrame(const css::uno::Reference< css::embed::XEmbeddedObject > &) const
Definition: feflyole.cxx:38
SwFrameFormat * GetSelectedFrameFormat() const
If frame then frame style, else 0.
Definition: fefly1.cxx:1203
void ReplaceSdrObj(const OUString &rGrfName, const Graphic *pGrf)
Definition: fefly1.cxx:1787
IMapObject * GetIMapObject(const Point &rPoint, const SwFlyFrame *pFly=nullptr) const
Definition: atrfrm.cxx:3546
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:747
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void StartAction()
Definition: crsrsh.cxx:227
void SetParent(const SfxItemSet *pNew)
const ImageMap * GetMap() const
Definition: fmturl.hxx:68
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
SwFlyFrameFormat * InsertObject(const svt::EmbeddedObjectRef &, SfxItemSet *pFlyAttrSet)
Definition: fefly1.cxx:917
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
void CallChgLnk()
Definition: crsrsh.cxx:2530
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2680
SwFormat * DerivedFrom() const
Definition: format.hxx:112
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:678
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:208
virtual bool ResetFormatAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: format.cxx:624
SwFlyFrame * GetFlyFrame()
Definition: dflyobj.hxx:128
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
virtual SwDrawFrameFormat * InsertDrawObj(const SwPaM &rRg, SdrObject &rDrawObj, const SfxItemSet &rFlyAttrSet)=0
Insert a DrawObject.
const SwFrameFormat * GetFormatFromObj(const Point &rPt, SwRect **pRectToFill=nullptr) const
Definition: fefly1.cxx:1610
const SwFrameFormat * NewFlyFrame(const SfxItemSet &rSet, bool bAnchValid=false, SwFrameFormat *pParent=nullptr)
Definition: fefly1.cxx:648
tools::Rectangle SVRect() const
Definition: swrect.hxx:279
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
SwDrawView * GetDrawView()
Definition: viewimp.hxx:154
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual SwFrameFormat & GetFrameFormat()=0
SwContentFrame * GetCurrFrame(const bool bCalcFrame=true) const
Get current frame in which the cursor is positioned.
Definition: crsrsh.cxx:2450
SwPageFrame * FindPageFrameOfAnchor()
method to determine the page frame, on which the 'anchor' of the given anchored object is...
sal_uInt16 GetPhyPageNum() const
Definition: trvlfrm.cxx:1695
void ClrContourCache(const SdrObject *pObj)
Definition: txtfly.cxx:134
vcl::Window * GetWin() const
Definition: viewsh.hxx:337
SwTwips GetPos() const
Definition: fmtornt.hxx:59
static sal_Int32 StartOfInputFieldAtPos(const SwPosition &rPos)
Definition: crstrvl.cxx:955
const OUString & GetTargetFrameName() const
Definition: fmturl.hxx:65
void AlignAllFormulasToBaseline()
aligns all formulas with anchor 'as char' to baseline
Definition: fefly1.cxx:2099
SwShellCursor * GetNext()
Definition: viscrs.hxx:164
OUString GetUniqueGrfName() const
Created unique name for frame.
Definition: fefly1.cxx:1494
ObjCntType GetObjCntTypeOfSelection() const
Definition: fefly1.cxx:1759
SwRect GetObjRect() const
For adjustment of PosAttr when anchor changes.
Definition: fefly1.cxx:1288
virtual Size ChgSize(const Size &aNewSize) override
Definition: fly.cxx:2122
bool IsNoTextFrame() const
Definition: frame.hxx:1235
bool IsFlyFreeFrame() const
Definition: flyfrm.hxx:216
SwNodes & GetNodes()
Definition: doc.hxx:409
static bool PosInsideInputField(const SwPosition &rPos)
Definition: crstrvl.cxx:939
SwRect getUntransformedFrameArea() const
Definition: wsfrm.cxx:165
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
Definition: dcontact.hxx:212
sal_uInt16 GetHitTolerancePixel() const
bool IsGrfLink() const
Query link-data.
Definition: ndgrf.hxx:129
void Top(const tools::Long nTop)
Definition: swrect.hxx:203
void SetDescription(const OUString &rStr)
void DelSelectedObj()
Definition: feshview.cxx:2366
const Point & GetPtPos() const
Definition: viscrs.hxx:141
Size RequestObjectResize(const SwRect &rRect, const css::uno::Reference< css::embed::XEmbeddedObject > &)
OLE.
Definition: fefly1.cxx:1308
bool SelectObj(const Point &rSelPt, sal_uInt8 nFlag=0, SdrObject *pObj=nullptr)
If an object has been given, exactly this object is selected (instead of searching over position)...
Definition: feshview.cxx:177
static bool lcl_FindAnchorPos(SwDoc &rDoc, const Point &rPt, const SwFrame &rFrame, SfxItemSet &rSet)
Definition: fefly1.cxx:108
bool HasDrawView() const
New Interface for StarView Drawing.
Definition: viewimp.hxx:153
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
Definition: docfly.cxx:586
void ClearMark()
Definition: crsrsh.cxx:939
const SwFrameFormat * SelFlyGrabCursor()
If a fly is selected, it draws cursor into the first ContentFrame.
Definition: feshview.cxx:788
void ResetFlyFrameAttr(const SfxItemSet *pSet)
Definition: fefly1.cxx:1176
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
void SetFrameFormat(SwFrameFormat *pFormat, bool bKeepOrient=false, Point const *pDocPos=nullptr)
If frame then set frame style.
Definition: fefly1.cxx:1213
const css::uno::Reference< css::awt::XControlModel > & GetUnoControlModel() const
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBody=false)
search an anchor for paragraph bound frames starting from pOldAnch
Definition: flycnt.cxx:1056
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:199
sal_uInt16 GetMarkHdlSizePixel() const
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
const SwFrameFormat * GetFlyFrameFormat() const
Get FlyFrameFormat; for UI macro linkage at Flys.
Definition: fefly1.cxx:1260
Reference< XModel > xModel
RndStdIds
const SvxProtectItem & GetProtect(bool=true) const
Definition: frmatr.hxx:82
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
void SetObjTitle(const OUString &rTitle)
Definition: fefly1.cxx:1974
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:246
A layout frame is a frame that contains other frames (m_pLower), e.g. SwPageFrame or SwTabFrame...
Definition: layfrm.hxx:35
static ObjCntType GetObjCntType(const SdrObject &rObj)
Definition: fefly1.cxx:1657
const SwFrame * GetAnchorFrame() const
SwGrfNode * GetGrfNode()
Definition: ndgrf.hxx:154
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:120
bool IsInvalidItem(const SfxPoolItem *pItem)
OUString GetObjDescription() const
Definition: fefly1.cxx:1996
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
SwFlyFrameFormat * GetPrev() const
Definition: fmtcnct.hxx:53
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2068
bool IsServerMap() const
Definition: fmturl.hxx:67
o3tl::strong_int< sal_Int32, struct Tag_TextFrameIndex > TextFrameIndex
Denotes a character index in a text frame at a layout level, after extent mapping from a text node at...
sal_uInt16 getHitTolLog() const
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
Definition: ssfrm.cxx:291
void ChgRelPos(const Point &rAbsPos)
Change the relative position.
Definition: fly.cxx:1120
void Height(tools::Long nNew)
Definition: swrect.hxx:190
SdrObjUserCall * GetUserCall() const
Point & GetCursorDocPos() const
Definition: crsrsh.hxx:899
OUString GetFlyName() const
Definition: fefly1.cxx:1471
SwChainRet
Definition: flyenum.hxx:33
const OUString & GetURL() const
void SetTitle(const OUString &rStr)
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:313
tools::Long Right() const
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:678
const Graphic & GetGrf(bool bWait=false) const
Definition: ndgrf.cxx:373
sal_uInt16 GetPageNum(bool bAtPoint=true, const Point *pLayPos=nullptr)
Get number of page which contains cursor.
Definition: pam.cxx:552
bool SetDrawingAttr(SfxItemSet &rSet)
Definition: fefly1.cxx:1137
bool sw_ChkAndSetNewAnchor(const SwFlyFrame &rFly, SfxItemSet &rSet)
also used in unoframe.cxx
Definition: fefly1.cxx:213
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
SdrPageView * GetPageView()
Definition: viewimp.hxx:156
bool IsPosProtected() const
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3154
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1583
SwNodeIndex & Assign(SwNodes const &rNds, sal_uLong)
Definition: ndindex.hxx:272
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:244
virtual const SwFrameFormat * GetFormat() const
Definition: ssfrm.cxx:395
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1628
const OUString & GetURL() const
Definition: fmturl.hxx:66
Point FindAnchorPos(const Point &rAbsPos, bool bMoveIt=false)
Definition: fefly1.cxx:421
Base class of the Writer document model elements.
Definition: node.hxx:80