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, pObj);
450  }
451 
452  SwFlyFrame* pFly = nullptr;
453  const SwFrame* pFooterOrHeader = nullptr;
454 
455  if( bFlyFrame )
456  {
457  // Calculate reference point in document coordinates
458  SwContentFrame *pContent = GetCurrFrame( false );
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
476  &rFormat, RES_DRAWFRMFMT, pObj ? pObj : rFormat.FindRealSdrObject()));
477  if (pFlyFormat)
478  {
479  pFly = pFlyFormat->GetFrame();
480  }
481  }
482 
483  // set <pFooterOrHeader> also for drawing
484  // objects, but not for control objects.
485  // Necessary for moving 'anchor symbol' at the user interface inside header/footer.
486  else if ( !::CheckControlLayer( pObj ) )
487  {
488  SwContentFrame *pContent = GetCurrFrame( false );
489  if( !pContent )
490  return aRet;
491  pFooterOrHeader = pContent->FindFooterOrHeader();
492  }
493 
494  // Search nearest SwFlyFrame starting from the upper-left corner
495  // of the fly
496  SwContentFrame *pTextFrame = nullptr;
497  {
499  SwPosition aPos( GetDoc()->GetNodes().GetEndOfExtras() );
500  Point aTmpPnt( rAbsPos );
501  GetLayout()->GetModelPositionForViewPoint( &aPos, aTmpPnt, &aState );
502  if (aPos.nNode != GetDoc()->GetNodes().GetEndOfExtras().GetIndex()
503  && (nAnchorId != RndStdIds::FLY_AT_CHAR || !PosInsideInputField(aPos)))
504  {
505  SwContentNode* pCNode = aPos.nNode.GetNode().GetContentNode();
506  assert(pCNode);
507  pTextFrame = pCNode->getLayoutFrame(GetLayout(), &aPos, nullptr);
508  }
509  }
510  const SwFrame *pNewAnch = nullptr;
511  if( pTextFrame != nullptr )
512  {
513  if ( RndStdIds::FLY_AT_PAGE == nAnchorId )
514  {
515  pNewAnch = pTextFrame->FindPageFrame();
516  }
517  else
518  {
519  pNewAnch = ::FindAnchor( pTextFrame, rAbsPos );
520 
521  if( RndStdIds::FLY_AT_FLY == nAnchorId ) // LAYER_IMPL
522  {
523  pNewAnch = pNewAnch->FindFlyFrame();
524  }
525  }
526  }
527 
528  if( pNewAnch && !pNewAnch->IsProtected() )
529  {
530  const SwFlyFrame* pCheck = (bFlyFrame || bTextBox) ? pNewAnch->FindFlyFrame() : nullptr;
531  // If we land inside the frame, make sure
532  // that the frame does not land inside its own content
533  while( pCheck )
534  {
535  if( pCheck == pFly )
536  break;
537  const SwFrame *pTmp = pCheck->GetAnchorFrame();
538  pCheck = pTmp ? pTmp->FindFlyFrame() : nullptr;
539  }
540 
541  // Do not switch from header/footer to another area,
542  // do not switch to a header/footer
543  if( !pCheck &&
544  pFooterOrHeader == pNewAnch->FindFooterOrHeader() )
545  {
546  aRet = pNewAnch->GetFrameAnchorPos( ::HasWrap( pObj ) );
547 
548  if ( bMoveIt || (nAnchorId == RndStdIds::FLY_AT_CHAR) )
549  {
550  SwFormatAnchor aAnch( rFormat.GetAnchor() );
551  switch ( nAnchorId )
552  {
553  case RndStdIds::FLY_AT_PARA:
554  {
555  SwPosition pos = *aAnch.GetContentAnchor();
556  pos.nNode = pTextFrame->IsTextFrame()
557  ? *static_cast<SwTextFrame const*>(pTextFrame)->GetTextNodeForParaProps()
558  : *static_cast<const SwNoTextFrame*>(pTextFrame)->GetNode();
559  pos.nContent.Assign(nullptr,0);
560  aAnch.SetAnchor( &pos );
561  break;
562  }
563  case RndStdIds::FLY_AT_PAGE:
564  {
565  aAnch.SetPageNum( static_cast<const SwPageFrame*>(pNewAnch)->
566  GetPhyPageNum() );
567  break;
568  }
569 
570  case RndStdIds::FLY_AT_FLY:
571  {
572  SwPosition aPos( *static_cast<const SwFlyFrame*>(pNewAnch)->GetFormat()->
573  GetContent().GetContentIdx() );
574  aAnch.SetAnchor( &aPos );
575  break;
576  }
577 
578  case RndStdIds::FLY_AT_CHAR:
579  {
580  SwPosition pos = *aAnch.GetContentAnchor();
581  Point aTmpPnt( rAbsPos );
582  if( pTextFrame->GetModelPositionForViewPoint( &pos, aTmpPnt ) )
583  {
584  SwRect aTmpRect;
585  pTextFrame->GetCharRect( aTmpRect, pos );
586  aRet = aTmpRect.Pos();
587  }
588  else
589  {
590  pos = static_cast<SwTextFrame const*>(pTextFrame)->MapViewToModelPos(TextFrameIndex(0));
591  }
592  aAnch.SetAnchor( &pos );
593  break;
594  }
595  default:
596  break;
597 
598  }
599 
600  if( bMoveIt )
601  {
602  StartAllAction();
603  // --> handle change of anchor node:
604  // if count of the anchor frame also change, the fly frames have to be
605  // re-created. Thus, delete all fly frames except the <this> before the
606  // anchor attribute is change and re-create them afterwards.
607  {
608  std::unique_ptr<SwHandleAnchorNodeChg, o3tl::default_delete<SwHandleAnchorNodeChg>> pHandleAnchorNodeChg;
609  SwFlyFrameFormat* pFlyFrameFormat( dynamic_cast<SwFlyFrameFormat*>(&rFormat) );
610  if ( pFlyFrameFormat )
611  {
612  pHandleAnchorNodeChg.reset(
613  new SwHandleAnchorNodeChg( *pFlyFrameFormat, aAnch ));
614  }
615  rFormat.GetDoc()->SetAttr( aAnch, rFormat );
617  pObj ? pObj : rFormat.FindRealSdrObject()))
618  {
619  if (pObj->getChildrenOfSdrObject())
620  {
621  for (size_t i = 0;
622  i < pObj->getChildrenOfSdrObject()->GetObjCount(); ++i)
624  &rFormat, pObj->getChildrenOfSdrObject()->GetObj(i));
625  }
626  else
628  rFormat, rFormat.GetAttrSet(),
629  pObj ? pObj : rFormat.FindRealSdrObject());
630  }
631  }
632  // #i28701# - no call of method
633  // <CheckCharRectAndTopOfLine()> for to-character anchored
634  // Writer fly frame needed. This method call can cause a
635  // format of the anchor frame, which is no longer intended.
636  // Instead clear the anchor character rectangle and
637  // the top of line values for all to-character anchored objects.
638  pAnchoredObj->ClearCharRectAndTopOfLine();
639  EndAllAction();
640  }
641  }
642 
643  SwRect aTmpRect( aRet, rAbsPos );
644  if( aTmpRect.HasArea() )
645  MakeVisible( aTmpRect );
646 #if OSL_DEBUG_LEVEL > 0
647  //TODO: That doesn't seem to be intended
648  if( COL_TRANSPARENT != GetOut()->GetLineColor() )
649  {
650  OSL_FAIL( "Hey, Joe: Where's my Null Pen?" );
652  }
653 #endif
654  }
655  }
656 
657  return aRet;
658 }
659 
660 const SwFrameFormat *SwFEShell::NewFlyFrame( const SfxItemSet& rSet, bool bAnchValid,
661  SwFrameFormat *pParent )
662 {
663  CurrShell aCurr( this );
664  StartAllAction();
665 
666  SwPaM* pCursor = GetCursor();
667  const Point aPt( GetCursorDocPos() );
668 
669  SwSelBoxes aBoxes;
670  bool bMoveContent = true;
671  if( IsTableMode() )
672  {
673  GetTableSel( *this, aBoxes );
674  if( !aBoxes.empty() )
675  {
676  // Cursor should be removed from the removal area.
677  // Always put it after/on the table; via the
678  // document position they will be set to the old
679  // position
680  ParkCursor( SwNodeIndex( *aBoxes[0]->GetSttNd() ));
681 
682  // #i127787# pCurrentCursor will be deleted in ParkCursor,
683  // we better get the current pCurrentCursor instead of working with the
684  // deleted one:
685  pCursor = GetCursor();
686  }
687  else
688  bMoveContent = false;
689  }
690  else if( !pCursor->HasMark() && !pCursor->IsMultiSelection() )
691  bMoveContent = false;
692 
693  const SwPosition& rPos = *pCursor->Start();
694 
695  SwFormatAnchor& rAnch = const_cast<SwFormatAnchor&>(rSet.Get( RES_ANCHOR ));
696  RndStdIds eRndId = rAnch.GetAnchorId();
697  switch( eRndId )
698  {
699  case RndStdIds::FLY_AT_PAGE:
700  if( !rAnch.GetPageNum() ) //HotFix: Bug in UpdateByExample
701  rAnch.SetPageNum( 1 );
702  break;
703 
704  case RndStdIds::FLY_AT_FLY:
705  case RndStdIds::FLY_AT_PARA:
706  case RndStdIds::FLY_AT_CHAR:
707  case RndStdIds::FLY_AS_CHAR:
708  if( !bAnchValid )
709  {
710  if( RndStdIds::FLY_AT_FLY != eRndId )
711  {
712  rAnch.SetAnchor( &rPos );
713  }
714  else if( lcl_SetNewFlyPos( rPos.nNode.GetNode(), rAnch, aPt ) )
715  {
716  eRndId = RndStdIds::FLY_AT_PAGE;
717  }
718  }
719  break;
720 
721  default:
722  OSL_ENSURE( false, "What is the purpose of this Fly?" );
723  break;
724  }
725 
726  SwFlyFrameFormat *pRet;
727  if( bMoveContent )
728  {
730  std::unique_ptr<SwFormatAnchor> pOldAnchor;
731  bool bHOriChgd = false, bVOriChgd = false;
732  std::shared_ptr<SwFormatVertOrient> aOldV;
733  std::shared_ptr<SwFormatHoriOrient> aOldH;
734 
735  if ( RndStdIds::FLY_AT_PAGE != eRndId )
736  {
737  // First as with page link. Paragraph/character link on if
738  // everything was shifted. Then the position is valid!
739  // JP 13.05.98: if necessary also convert the horizontal/vertical
740  // orientation, to prevent correction during re-anchoring
741  pOldAnchor.reset(new SwFormatAnchor( rAnch ));
742  const_cast<SfxItemSet&>(rSet).Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 ) );
743 
744  const SfxPoolItem* pItem;
745  if( SfxItemState::SET == rSet.GetItemState( RES_HORI_ORIENT, false, &pItem )
746  && text::HoriOrientation::NONE == static_cast<const SwFormatHoriOrient*>(pItem)->GetHoriOrient() )
747  {
748  bHOriChgd = true;
749  aOldH.reset(static_cast<SwFormatHoriOrient*>(pItem->Clone()));
750  const_cast<SfxItemSet&>(rSet).Put( SwFormatHoriOrient( 0, text::HoriOrientation::LEFT ) );
751  }
752  if( SfxItemState::SET == rSet.GetItemState( RES_VERT_ORIENT, false, &pItem )
753  && text::VertOrientation::NONE == static_cast<const SwFormatVertOrient*>(pItem)->GetVertOrient() )
754  {
755  bVOriChgd = true;
756  aOldV.reset(static_cast<SwFormatVertOrient*>(pItem->Clone()));
757  const_cast<SfxItemSet&>(rSet).Put( SwFormatVertOrient( 0, text::VertOrientation::TOP ) );
758  }
759  }
760 
761  pRet = GetDoc()->MakeFlyAndMove( *pCursor, rSet, &aBoxes, pParent );
762 
763  KillPams();
764 
765  if( pOldAnchor )
766  {
767  if( pRet )
768  {
769  // calculate new position
770  // JP 24.03.97: also go via page links
771  // anchor should not lie in the shifted area
772  pRet->DelFrames();
773 
774  const SwFrame* pAnch = ::FindAnchor( GetLayout(), aPt );
775  SwPosition aPos( pAnch->IsTextFrame()
776  ? *static_cast<SwTextFrame const*>(pAnch)->GetTextNodeForParaProps()
777  : *static_cast<const SwNoTextFrame*>(pAnch)->GetNode() );
778 
779  if ( RndStdIds::FLY_AS_CHAR == eRndId )
780  {
781  assert(pAnch->IsTextFrame());
782  aPos = static_cast<SwTextFrame const*>(pAnch)->MapViewToModelPos(TextFrameIndex(0));
783  }
784  pOldAnchor->SetAnchor( &aPos );
785 
786  // shifting of table selection is not Undo-capable. therefore
787  // changing the anchors should not be recorded
788  bool const bDoesUndo =
790  SwUndoId nLastUndoId(SwUndoId::EMPTY);
791  if (bDoesUndo &&
793  & nLastUndoId))
794  {
795  if (SwUndoId::INSLAYFMT == nLastUndoId)
796  {
797  GetDoc()->GetIDocumentUndoRedo().DoUndo(false);
798  }
799  }
800 
801  const_cast<SfxItemSet&>(rSet).Put( *pOldAnchor );
802 
803  if( bHOriChgd )
804  const_cast<SfxItemSet&>(rSet).Put( *aOldH );
805  if( bVOriChgd )
806  const_cast<SfxItemSet&>(rSet).Put( *aOldV );
807 
808  GetDoc()->SetFlyFrameAttr( *pRet, const_cast<SfxItemSet&>(rSet) );
809  GetDoc()->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
810  }
811  }
813  }
814  else
815  /* If called from a shell try to propagate an
816  existing adjust item from rPos to the content node of the
817  new frame. */
818  pRet = GetDoc()->MakeFlySection( eRndId, &rPos, &rSet, pParent, true );
819 
820  if( pRet )
821  {
822  SwFlyFrame* pFrame = pRet->GetFrame( &aPt );
823  if( pFrame )
824  SelectFlyFrame( *pFrame );
825  else
826  {
828  pRet = nullptr;
829  }
830  }
832 
833  return pRet;
834 }
835 
836 void SwFEShell::Insert( const OUString& rGrfName, const OUString& rFltName,
837  const Graphic* pGraphic,
838  const SfxItemSet* pFlyAttrSet )
839 {
840  SwFlyFrameFormat* pFormat = nullptr;
841  CurrShell aCurr( this );
842  StartAllAction();
843  SwShellCursor *pStartCursor = dynamic_cast<SwShellCursor*>(GetCursor());
844  SwShellCursor *pCursor = pStartCursor;
845  do
846  {
847  if (!pCursor)
848  break;
849 
850  // Has the anchor not been set or been set incompletely?
851  if( pFlyAttrSet )
852  {
853  const SfxPoolItem* pItem;
854  if( SfxItemState::SET == pFlyAttrSet->GetItemState( RES_ANCHOR, false,
855  &pItem ) )
856  {
857  SwFormatAnchor* pAnchor = const_cast<SwFormatAnchor*>(static_cast<const SwFormatAnchor*>(pItem));
858  switch( pAnchor->GetAnchorId())
859  {
860  case RndStdIds::FLY_AT_PARA:
861  case RndStdIds::FLY_AT_CHAR: // LAYER_IMPL
862  case RndStdIds::FLY_AS_CHAR:
863  if( !pAnchor->GetContentAnchor() )
864  {
865  pAnchor->SetAnchor( pCursor->GetPoint() );
866  }
867  break;
868  case RndStdIds::FLY_AT_FLY:
869  if( !pAnchor->GetContentAnchor() )
870  {
871  lcl_SetNewFlyPos( pCursor->GetNode(),
872  *pAnchor, GetCursorDocPos() );
873  }
874  break;
875  case RndStdIds::FLY_AT_PAGE:
876  if( !pAnchor->GetPageNum() )
877  {
878  pAnchor->SetPageNum( pCursor->GetPageNum(
879  true, &pCursor->GetPtPos() ) );
880  }
881  break;
882  default :
883  break;
884  }
885  }
886  }
888  *pCursor, rGrfName,
889  rFltName, pGraphic,
890  pFlyAttrSet,
891  nullptr, nullptr );
892  OSL_ENSURE(pFormat, "IDocumentContentOperations::InsertGraphic failed.");
893 
894  pCursor = pCursor->GetNext();
895  } while( pCursor != pStartCursor );
896 
897  EndAllAction();
898 
899  if( !pFormat )
900  return;
901 
902  const Point aPt( GetCursorDocPos() );
903  SwFlyFrame* pFrame = pFormat->GetFrame( &aPt );
904 
905  if( pFrame )
906  {
907  // add a redline to the anchor point at tracked insertion of picture
908  if ( IsRedlineOn() )
909  {
910  SwPosition aPos(*pFormat->GetAnchor().GetContentAnchor());
911  SwPaM aPaM(aPos.nNode.GetNode(), aPos.nContent.GetIndex(),
912  aPos.nNode.GetNode(), aPos.nContent.GetIndex() + 1);
914  new SwRangeRedline( RedlineType::Insert, aPaM ), true);
915  }
916 
917  // fdo#36681: Invalidate the content and layout to refresh
918  // the picture anchoring properly
919  SwPageFrame* pPageFrame = pFrame->FindPageFrameOfAnchor();
920  pPageFrame->InvalidateFlyLayout();
921  pPageFrame->InvalidateContent();
922 
923  SelectFlyFrame( *pFrame );
924  }
925  else
927 }
928 
930  SfxItemSet* pFlyAttrSet )
931 {
932  SwFlyFrameFormat* pFormat = nullptr;
933  CurrShell aCurr( this );
934  StartAllAction();
935  {
936  for(const SwPaM& rPaM : GetCursor()->GetRingContainer())
937  {
939  rPaM, xObj, pFlyAttrSet );
940  OSL_ENSURE(pFormat, "IDocumentContentOperations::InsertEmbObject failed.");
941  }
942  }
943  EndAllAction();
944 
945  if( pFormat )
946  {
947  const Point aPt( GetCursorDocPos() );
948  SwFlyFrame* pFrame = pFormat->GetFrame( &aPt );
949 
950  if( pFrame )
951  SelectFlyFrame( *pFrame );
952  else
954  }
955 
956  return pFormat;
957 }
958 
960  const Point& rInsertPosition )
961 {
962  CurrShell aCurr( this );
963 
964  SfxItemSet rFlyAttrSet( GetDoc()->GetAttrPool(), aFrameFormatSetRange );
965  rFlyAttrSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PARA ));
966  // #i89920#
967  rFlyAttrSet.Put( SwFormatSurround( css::text::WrapTextMode_THROUGH ) );
968  rDrawObj.SetLayer( getIDocumentDrawModelAccess().GetHeavenId() );
969 
970  // find anchor position
971  SwPaM aPam( mxDoc->GetNodes() );
972  {
974  Point aTmpPt( rInsertPosition );
975  GetLayout()->GetModelPositionForViewPoint( aPam.GetPoint(), aTmpPt, &aState );
976  const SwFrame* pFrame = aPam.GetContentNode()->getLayoutFrame(GetLayout(), nullptr, nullptr);
977  const Point aRelPos( rInsertPosition.X() - pFrame->getFrameArea().Left(),
978  rInsertPosition.Y() - pFrame->getFrameArea().Top() );
979  rDrawObj.SetRelativePos( aRelPos );
980  ::lcl_FindAnchorPos( *GetDoc(), rInsertPosition, *pFrame, rFlyAttrSet );
981  }
982  // insert drawing object into the document creating a new <SwDrawFrameFormat> instance
983  SwDrawFrameFormat* pFormat = GetDoc()->getIDocumentContentOperations().InsertDrawObj( aPam, rDrawObj, rFlyAttrSet );
984 
985  // move object to visible layer
986  SwContact* pContact = static_cast<SwContact*>(rDrawObj.GetUserCall());
987  if ( pContact )
988  {
989  pContact->MoveObjToVisibleLayer( &rDrawObj );
990  }
991 
992  if (pFormat)
993  {
994  pFormat->SetName(rDrawObj.GetName());
995  // select drawing object
996  Imp()->GetDrawView()->MarkObj( &rDrawObj, Imp()->GetPageView() );
997  }
998  else
999  {
1001  }
1002 }
1003 
1004 void SwFEShell::GetPageObjs( std::vector<SwFrameFormat*>& rFillArr )
1005 {
1006  rFillArr.clear();
1007 
1008  for( auto pFormat : *mxDoc->GetSpzFrameFormats() )
1009  {
1010  if (RndStdIds::FLY_AT_PAGE == pFormat->GetAnchor().GetAnchorId())
1011  {
1012  rFillArr.push_back( pFormat );
1013  }
1014  }
1015 }
1016 
1017 void SwFEShell::SetPageObjsNewPage( std::vector<SwFrameFormat*>& rFillArr )
1018 {
1019  if( rFillArr.empty() )
1020  return;
1021 
1022  StartAllAction();
1023  StartUndo();
1024 
1025  SwRootFrame* pTmpRootFrame = GetLayout();
1026  sal_uInt16 nMaxPage = pTmpRootFrame->GetPageNum();
1027  bool bTmpAssert = false;
1028  for( auto pFormat : rFillArr )
1029  {
1030  if (mxDoc->GetSpzFrameFormats()->IsAlive(pFormat))
1031  {
1032  // FlyFormat is still valid, therefore process
1033 
1034  SwFormatAnchor aNewAnchor( pFormat->GetAnchor() );
1035  if (RndStdIds::FLY_AT_PAGE != aNewAnchor.GetAnchorId())
1036  // Anchor has been changed, therefore: do not change!
1037  continue;
1038  sal_uInt16 nNewPage = aNewAnchor.GetPageNum() + 1;
1039  if (nNewPage > nMaxPage)
1040  {
1041  if ( RES_DRAWFRMFMT == pFormat->Which() )
1043  else
1044  pFormat->DelFrames();
1045  bTmpAssert = true;
1046  }
1047  aNewAnchor.SetPageNum(nNewPage);
1048  mxDoc->SetAttr( aNewAnchor, *pFormat );
1049  }
1050  }
1051 
1052  if( bTmpAssert )
1053  pTmpRootFrame->SetAssertFlyPages();
1054 
1055  EndUndo();
1056  EndAllAction();
1057 }
1058 
1059 // All attributes in the "baskets" will be filled with the attributes of the
1060 // current FlyFrames. Attributes which cannot be filled due to being at the
1061 // wrong place or which are ambiguous (multiple selections) will be removed.
1063 {
1065  if (!pFly)
1066  {
1067  OSL_ENSURE( false, "GetFlyFrameAttr, no Fly selected." );
1068  return false;
1069  }
1070 
1071  CurrShell aCurr( const_cast<SwFEShell*>(this) );
1072 
1073  if( !rSet.Set( pFly->GetFormat()->GetAttrSet() ) )
1074  return false;
1075 
1076  // now examine all attributes. Remove forbidden attributes, then
1077  // get all remaining attributes and enter them
1078  const SfxPoolItem* pItem;
1079  if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false, &pItem ) )
1080  {
1081  const SwFormatAnchor* pAnchor = static_cast<const SwFormatAnchor*>(pItem);
1082  RndStdIds eType = pAnchor->GetAnchorId();
1083 
1084  if ( RndStdIds::FLY_AT_PAGE != eType )
1085  {
1086  // OD 12.11.2003 #i22341# - content anchor of anchor item is needed.
1087  // Thus, don't overwrite anchor item by default constructed anchor item.
1088  if ( RndStdIds::FLY_AS_CHAR == eType )
1089  {
1090  rSet.ClearItem( RES_OPAQUE );
1091  rSet.ClearItem( RES_SURROUND );
1092  }
1093  }
1094  }
1095  rSet.SetParent( pFly->GetFormat()->GetAttrSet().GetParent() );
1096  // attributes must be removed
1097  rSet.ClearItem( RES_FILL_ORDER );
1098  rSet.ClearItem( RES_CNTNT );
1099  //MA: remove first (Template by example etc.)
1100  rSet.ClearItem( RES_CHAIN );
1101  return true;
1102 }
1103 
1104 // Attributes of the current fly will change.
1106 {
1107  CurrShell aCurr( this );
1108  bool bRet = false;
1109 
1110  if( rSet.Count() )
1111  {
1113  OSL_ENSURE(pFly, "SetFlyFrameAttr, no Fly selected.");
1114  if (pFly)
1115  {
1116  StartAllAction();
1117  const Point aPt( pFly->getFrameArea().Pos() );
1118 
1119  if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
1120  sw_ChkAndSetNewAnchor( *pFly, rSet );
1121  SwFlyFrameFormat* pFlyFormat = pFly->GetFormat();
1122 
1123  if( GetDoc()->SetFlyFrameAttr( *pFlyFormat, rSet ))
1124  {
1125  bRet = true;
1126  SwFlyFrame* pFrame = pFlyFormat->GetFrame( &aPt );
1127  if( pFrame )
1128  SelectFlyFrame( *pFrame );
1129  else
1131  }
1132 
1134  }
1135  }
1136  return bRet;
1137 }
1138 
1140 {
1141  // The set also includes VERT/HORI_ORIENT, because the align
1142  // shall be changed in FEShell::SetFlyFrameAttr/SetFlyFrameAnchor,
1143  // possibly as a result of the anchor change.
1144  SfxItemSet aSet(rPool, svl::Items<RES_VERT_ORIENT, RES_ANCHOR>);
1145  aSet.Put(rAnchor);
1146  return aSet;
1147 }
1148 
1150 {
1151  bool bRet = false;
1152  CurrShell aCurr( this );
1153  if ( !rSet.Count() ||
1154  !Imp()->HasDrawView() )
1155  return bRet;
1156 
1157  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1158  if ( rMrkList.GetMarkCount() != 1 )
1159  return bRet;
1160 
1161  StartUndo();
1162  SdrObject *pObj = rMrkList.GetMark( 0 )->GetMarkedSdrObj();
1163  SwFrameFormat *pFormat = FindFrameFormat( pObj );
1164  StartAllAction();
1165  if( SfxItemState::SET == rSet.GetItemState( RES_ANCHOR, false ))
1166  {
1167  RndStdIds nNew = rSet.Get( RES_ANCHOR ).GetAnchorId();
1168  if ( nNew != pFormat->GetAnchor().GetAnchorId() )
1169  {
1170  ChgAnchor( nNew );
1171  // #i26791# - clear anchor attribute in item set,
1172  // because method <ChgAnchor(..)> takes care of it.
1173  rSet.ClearItem( RES_ANCHOR );
1174  }
1175  }
1176 
1177  if( GetDoc()->SetFlyFrameAttr( *pFormat, rSet ))
1178  {
1179  bRet = true;
1180  SelectObj( Point(), 0, pObj );
1181  }
1183  EndUndo();
1184  return bRet;
1185 }
1186 
1187 // Reset attributes contained in the set.
1189 {
1190  CurrShell aCurr( this );
1191 
1193  OSL_ENSURE( pFly, "SetFlyFrameAttr, no Fly selected." );
1194  if( !pFly )
1195  return;
1196 
1197  StartAllAction();
1198 
1199  SfxItemIter aIter( *pSet );
1200  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
1201  {
1202  if( !IsInvalidItem( pItem ) )
1203  {
1204  sal_uInt16 nWhich = pItem->Which();
1205  if( RES_ANCHOR != nWhich && RES_CHAIN != nWhich && RES_CNTNT != nWhich )
1206  pFly->GetFormat()->ResetFormatAttr( nWhich );
1207  }
1208  }
1209 
1212 }
1213 
1214 // Returns frame-format if frame, otherwise 0
1216 {
1217  SwFrameFormat* pRet = nullptr;
1219  if( pFly && ( pRet = static_cast<SwFrameFormat*>(pFly->GetFormat()->DerivedFrom()) ) ==
1220  GetDoc()->GetDfltFrameFormat() )
1221  pRet = nullptr;
1222  return pRet;
1223 }
1224 
1225 void SwFEShell::SetFrameFormat( SwFrameFormat *pNewFormat, bool bKeepOrient, Point const * pDocPos )
1226 {
1227  SwFlyFrame *pFly = nullptr;
1228  if(pDocPos)
1229  {
1230  const SwFrameFormat* pFormat = GetFormatFromObj( *pDocPos );
1231 
1232  if (const SwFlyFrameFormat* pFlyFormat = dynamic_cast<const SwFlyFrameFormat*>(pFormat))
1233  pFly = pFlyFormat->GetFrame();
1234  }
1235  else
1236  pFly = GetSelectedFlyFrame();
1237  OSL_ENSURE( pFly, "SetFrameFormat: no frame" );
1238  if( !pFly )
1239  return;
1240 
1241  StartAllAction();
1242  CurrShell aCurr( this );
1243 
1244  SwFlyFrameFormat* pFlyFormat = pFly->GetFormat();
1245  const Point aPt( pFly->getFrameArea().Pos() );
1246 
1247  std::optional<SfxItemSet> oSet;
1248  const SfxPoolItem* pItem;
1249  if( SfxItemState::SET == pNewFormat->GetItemState( RES_ANCHOR, false, &pItem ))
1250  {
1251  oSet.emplace( GetDoc()->GetAttrPool(), aFrameFormatSetRange );
1252  oSet->Put( *pItem );
1253  if( !sw_ChkAndSetNewAnchor( *pFly, *oSet ))
1254  {
1255  oSet.reset();
1256  }
1257  }
1258 
1259  if( GetDoc()->SetFrameFormatToFly( *pFlyFormat, *pNewFormat, oSet ? &*oSet : nullptr, bKeepOrient ))
1260  {
1261  SwFlyFrame* pFrame = pFlyFormat->GetFrame( &aPt );
1262  if( pFrame )
1263  SelectFlyFrame( *pFrame );
1264  else
1266  }
1267  oSet.reset();
1268 
1270 }
1271 
1273 {
1274  const SwFlyFrame* pFly = GetSelectedOrCurrFlyFrame();
1275  if (pFly)
1276  return pFly->GetFormat();
1277  return nullptr;
1278 }
1279 
1281 {
1283  if (pFly)
1284  return pFly->GetFormat();
1285  return nullptr;
1286 }
1287 
1289 {
1290  SwFlyFrame *pFly = GetCurrFlyFrame(false);
1291  if (!pFly)
1292  {
1293  SwRect aRect;
1294  return aRect;
1295  }
1296  else
1297  return pFly->getFrameArea();
1298 }
1299 
1301 {
1302  if( Imp()->HasDrawView() )
1303  return SwRect(Imp()->GetDrawView()->GetAllMarkedRect());
1304  else
1305  {
1306  SwRect aRect;
1307  return aRect;
1308  }
1309 }
1310 
1311 void SwFEShell::SetObjRect( const SwRect& rRect )
1312 {
1313  if ( Imp()->HasDrawView() )
1314  {
1315  Imp()->GetDrawView()->SetAllMarkedRect( rRect.SVRect() );
1316  CallChgLnk(); // call AttrChangeNotify on the UI-side.
1317  }
1318 }
1319 
1320 Size SwFEShell::RequestObjectResize( const SwRect &rRect, const uno::Reference < embed::XEmbeddedObject >& xObj )
1321 {
1322  Size aResult;
1323 
1324  SwFlyFrame *pFly = FindFlyFrame( xObj );
1325  if ( !pFly )
1326  {
1327  aResult = rRect.SSize();
1328  return aResult;
1329  }
1330 
1331  aResult = pFly->getFramePrintArea().SSize();
1332 
1333  bool bPosProt = pFly->GetFormat()->GetProtect().IsPosProtected();
1334  bool bSizeProt = pFly->GetFormat()->GetProtect().IsSizeProtected();
1335 
1336  StartAllAction();
1337 
1338  // MA we do not allow to clip the Fly, as the OLE server can
1339  // request various wishes. Clipping is done via the formatting.
1340  // Correct display is done by scaling.
1341  // Scaling is done by SwNoTextFrame::Format by calling
1342  // SwWrtShell::CalcAndSetScale()
1343  if ( rRect.SSize() != pFly->getFramePrintArea().SSize() && !bSizeProt )
1344  {
1345  Size aSz( rRect.SSize() );
1346 
1347  //JP 28.02.2001: Task 74707 - ask for fly in fly with automatic size
1348 
1349  const SwFrame* pAnchor;
1350  const SwFormatFrameSize& rFrameSz = pFly->GetFormat()->GetFrameSize();
1352  0 != rFrameSz.GetWidthPercent() &&
1353  nullptr != (pAnchor = pFly->GetAnchorFrame()) &&
1354  pAnchor->IsTextFrame() &&
1355  !pAnchor->GetNext() && !pAnchor->GetPrev() &&
1356  pAnchor->GetUpper()->IsFlyFrame())
1357  {
1358  // search for a sequence field:
1359  sw::MergedAttrIter iter(*static_cast<SwTextFrame const*>(pAnchor));
1360  for (SwTextAttr const* pHint = iter.NextAttr(); pHint; pHint = iter.NextAttr())
1361  {
1362  const SfxPoolItem* pItem = &pHint->GetAttr();
1363  if( RES_TXTATR_FIELD == pItem->Which()
1364  && SwFieldTypesEnum::Sequence == static_cast<const SwFormatField*>(pItem)->GetField()->GetTypeId() )
1365  {
1366  // sequence field found
1367  SwFlyFrame* pChgFly = const_cast<SwFlyFrame*>(static_cast<const SwFlyFrame*>(pAnchor->GetUpper()));
1368  // calculate the changed size:
1369  // width must change, height can change
1370  Size aNewSz( aSz.Width() + pChgFly->getFrameArea().Width() -
1371  pFly->getFramePrintArea().Width(), aSz.Height() );
1372 
1373  SwFrameFormat *pFormat = pChgFly->GetFormat();
1374  SwFormatFrameSize aFrameSz( pFormat->GetFrameSize() );
1375  aFrameSz.SetWidth( aNewSz.Width() );
1376  if( SwFrameSize::Minimum != aFrameSz.GetHeightSizeType() )
1377  {
1378  aNewSz.AdjustHeight(pChgFly->getFrameArea().Height() -
1379  pFly->getFramePrintArea().Height() );
1380  if( std::abs( aNewSz.Height() - pChgFly->getFrameArea().Height()) > 1 )
1381  aFrameSz.SetHeight( aNewSz.Height() );
1382  }
1383  // via Doc for the Undo!
1384  pFormat->GetDoc()->SetAttr( aFrameSz, *pFormat );
1385  break;
1386  }
1387  }
1388  }
1389 
1390  // set the new Size at the fly themself
1391  if ( !pFly->getFramePrintArea().IsEmpty() )
1392  {
1393  aSz.AdjustWidth(pFly->getFrameArea().Width() - pFly->getFramePrintArea().Width() );
1394  aSz.AdjustHeight(pFly->getFrameArea().Height()- pFly->getFramePrintArea().Height() );
1395  }
1396  aResult = pFly->ChgSize( aSz );
1397 
1398  // if the object changes, the contour is outside the object
1399  assert(pFly->Lower()->IsNoTextFrame());
1400  SwNoTextNode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetNoTextNode();
1401  assert(pNd);
1402  pNd->SetContour( nullptr );
1403  ClrContourCache();
1404  }
1405 
1406  // if only the size is to be adjusted, a position is transported with
1407  // allocated values
1408  Point aPt( pFly->getFramePrintArea().Pos() );
1409  aPt += pFly->getFrameArea().Pos();
1410  if ( rRect.Top() != LONG_MIN && rRect.Pos() != aPt && !bPosProt )
1411  {
1412  aPt = rRect.Pos();
1413  aPt.setX(aPt.getX() - pFly->getFramePrintArea().Left());
1414  aPt.setY(aPt.getY() - pFly->getFramePrintArea().Top());
1415 
1416  // in case of paragraph-bound Flys, starting from the new position,
1417  // a new anchor is to be set. The anchor and the new RelPos are
1418  // calculated by the Fly and set
1419  if( pFly->IsFlyAtContentFrame() )
1420  static_cast<SwFlyAtContentFrame*>(pFly)->SetAbsPos( aPt );
1421  else
1422  {
1423  const SwFrameFormat *pFormat = pFly->GetFormat();
1424  const SwFormatVertOrient &rVert = pFormat->GetVertOrient();
1425  const SwFormatHoriOrient &rHori = pFormat->GetHoriOrient();
1426  const tools::Long lXDiff = aPt.getX() - pFly->getFrameArea().Left();
1427  const tools::Long lYDiff = aPt.getY() - pFly->getFrameArea().Top();
1428  const Point aTmp( rHori.GetPos() + lXDiff,
1429  rVert.GetPos() + lYDiff );
1430  pFly->ChgRelPos( aTmp );
1431  }
1432  }
1433 
1434  SwFlyFrameFormat *pFlyFrameFormat = pFly->GetFormat();
1435  OSL_ENSURE( pFlyFrameFormat, "fly frame format missing!" );
1436  if ( pFlyFrameFormat )
1437  pFlyFrameFormat->SetLastFlyFramePrtRectPos( pFly->getFramePrintArea().Pos() ); //stores the value of last Prt rect
1438 
1439  EndAllAction();
1440 
1441  return aResult;
1442 }
1443 
1445 {
1446  // do not search the Fly via the layout. Now we can delete a frame
1447  // without a valid layout. ( e.g. for the wizards )
1448  SwFrameFormats& rSpzArr = *mxDoc->GetSpzFrameFormats();
1449  if( !rSpzArr.empty() )
1450  {
1451  SwNodeIndex& rCursorNd = GetCursor()->GetPoint()->nNode;
1452  if( rCursorNd.GetIndex() > mxDoc->GetNodes().GetEndOfExtras().GetIndex() )
1453  // Cursor is in the body area!
1454  return nullptr;
1455 
1456  for( auto pFormat : rSpzArr )
1457  {
1458  const SwNodeIndex* pIdx = pFormat->GetContent( false ).GetContentIdx();
1459  SwStartNode* pSttNd;
1460  if( pIdx &&
1461  nullptr != ( pSttNd = pIdx->GetNode().GetStartNode() ) &&
1462  pSttNd->GetIndex() < rCursorNd.GetIndex() &&
1463  rCursorNd.GetIndex() < pSttNd->EndOfSectionIndex() )
1464  {
1465  // found: return immediately
1466  return pFormat;
1467  }
1468  }
1469  }
1470  return nullptr;
1471 }
1472 
1473 void SwFEShell::SetFlyName( const OUString& rName )
1474 {
1476  if( pFly )
1477  GetDoc()->SetFlyName( *static_cast<SwFlyFrameFormat*>(pFly->GetFormat()), rName );
1478  else {
1479  OSL_ENSURE( false, "no FlyFrame selected" );
1480  }
1481 }
1482 
1483 OUString SwFEShell::GetFlyName() const
1484 {
1486  if( pFly )
1487  return pFly->GetFormat()->GetName();
1488 
1489  OSL_ENSURE( false, "no FlyFrame selected" );
1490  return OUString();
1491 }
1492 
1493 uno::Reference < embed::XEmbeddedObject > SwFEShell::GetOleRef() const
1494 {
1495  uno::Reference < embed::XEmbeddedObject > xObj;
1496  SwFlyFrame * pFly = GetSelectedFlyFrame();
1497  if (pFly && pFly->Lower() && pFly->Lower()->IsNoTextFrame())
1498  {
1499  SwOLENode *pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetOLENode();
1500  if (pNd)
1501  xObj = pNd->GetOLEObj().GetOleRef();
1502  }
1503  return xObj;
1504 }
1505 
1507 {
1508  return GetDoc()->GetUniqueGrfName();
1509 }
1510 
1511 const SwFrameFormat* SwFEShell::IsURLGrfAtPos( const Point& rPt, OUString* pURL,
1512  OUString *pTargetFrameName,
1513  OUString *pDescription ) const
1514 {
1515  if( !Imp()->HasDrawView() )
1516  return nullptr;
1517 
1518  SdrPageView* pPV;
1519  const SwFrameFormat* pRet = nullptr;
1520  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1521 
1522  const auto nOld = pDView->GetHitTolerancePixel();
1523  pDView->SetHitTolerancePixel( 2 );
1524 
1525  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV, SdrSearchOptions::PICKMACRO);
1526  SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1527  if (pFlyObj)
1528  {
1529  SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
1530  const SwFormatURL &rURL = pFly->GetFormat()->GetURL();
1531  if( !rURL.GetURL().isEmpty() || rURL.GetMap() )
1532  {
1533  bool bSetTargetFrameName = pTargetFrameName != nullptr;
1534  bool bSetDescription = pDescription != nullptr;
1535  if ( rURL.GetMap() )
1536  {
1537  IMapObject *pObject = pFly->GetFormat()->GetIMapObject( rPt, pFly );
1538  if ( pObject && !pObject->GetURL().isEmpty() )
1539  {
1540  if( pURL )
1541  *pURL = pObject->GetURL();
1542  if ( bSetTargetFrameName && !pObject->GetTarget().isEmpty() )
1543  {
1544  bSetTargetFrameName = false;
1545  *pTargetFrameName = pObject->GetTarget();
1546  }
1547  if ( bSetDescription )
1548  {
1549  bSetDescription = false;
1550  *pDescription = pObject->GetAltText();
1551  }
1552  pRet = pFly->GetFormat();
1553  }
1554  }
1555  else
1556  {
1557  if( pURL )
1558  {
1559  *pURL = rURL.GetURL();
1560  if( rURL.IsServerMap() )
1561  {
1562  // append the relative pixel position !!
1563  Point aPt( rPt );
1564  aPt -= pFly->getFrameArea().Pos();
1565  // without MapMode-Offset, without Offset, o ... !!!!!
1566  aPt = GetOut()->LogicToPixel(
1567  aPt, MapMode( MapUnit::MapTwip ) );
1568  *pURL = *pURL + "?" + OUString::number( aPt.getX() )
1569  + "," + OUString::number(aPt.getY() );
1570  }
1571  }
1572  pRet = pFly->GetFormat();
1573  }
1574  if ( bSetTargetFrameName )
1575  *pTargetFrameName = rURL.GetTargetFrameName();
1576  if ( bSetDescription )
1577  *pDescription = pFly->GetFormat()->GetName();
1578  }
1579  }
1580  pDView->SetHitTolerancePixel( nOld );
1581  return pRet;
1582 }
1583 
1584 const Graphic *SwFEShell::GetGrfAtPos( const Point &rPt,
1585  OUString &rName, bool &rbLink ) const
1586 {
1587  if( !Imp()->HasDrawView() )
1588  return nullptr;
1589 
1590  SdrPageView* pPV;
1591  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1592 
1593  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPV);
1594  SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj);
1595  if (pFlyObj)
1596  {
1597  SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
1598  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1599  {
1600  SwGrfNode *const pNd = static_cast<SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode();
1601  if ( pNd )
1602  {
1603  if ( pNd->IsGrfLink() )
1604  {
1605  // halfway ready graphic?
1606  ::sfx2::SvLinkSource* pLnkObj = pNd->GetLink()->GetObj();
1607  if( pLnkObj && pLnkObj->IsPending() )
1608  return nullptr;
1609  rbLink = true;
1610  }
1611 
1612  pNd->GetFileFilterNms( &rName, nullptr );
1613  if ( rName.isEmpty() )
1614  rName = pFly->GetFormat()->GetName();
1615  return &pNd->GetGrf(true);
1616  }
1617  }
1618  }
1619  return nullptr;
1620 }
1621 
1622 const SwFrameFormat* SwFEShell::GetFormatFromObj( const Point& rPt, SwRect** pRectToFill ) const
1623 {
1624  SwFrameFormat* pRet = nullptr;
1625 
1626  if( Imp()->HasDrawView() )
1627  {
1628  SdrPageView* pPView;
1629 
1630  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1631 
1632  const auto nOld = pDView->GetHitTolerancePixel();
1633  // tolerance for Drawing-SS
1634  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1635 
1636  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
1637  if (pObj)
1638  {
1639  // first check it:
1640  if (SwVirtFlyDrawObj* pFlyObj = dynamic_cast<SwVirtFlyDrawObj*>(pObj))
1641  pRet = pFlyObj->GetFormat();
1642  else if ( pObj->GetUserCall() ) //not for group objects
1643  pRet = static_cast<SwDrawContact*>(pObj->GetUserCall())->GetFormat();
1644  if(pRet && pRectToFill)
1645  **pRectToFill = SwRect(pObj->GetCurrentBoundRect());
1646  }
1647  pDView->SetHitTolerancePixel( nOld );
1648  }
1649  return pRet;
1650 }
1651 
1652 // returns a format too, if the point is over the text of any fly
1653 const SwFrameFormat* SwFEShell::GetFormatFromAnyObj( const Point& rPt ) const
1654 {
1655  const SwFrameFormat* pRet = GetFormatFromObj( rPt );
1656  if( !pRet || RES_FLYFRMFMT == pRet->Which() )
1657  {
1658  SwPosition aPos( *GetCursor()->GetPoint() );
1659  Point aPt( rPt );
1660  GetLayout()->GetModelPositionForViewPoint( &aPos, aPt );
1661  SwContentNode *pNd = aPos.nNode.GetNode().GetContentNode();
1662  std::pair<Point, bool> const tmp(rPt, false);
1663  SwFrame* pFrame = pNd->getLayoutFrame(GetLayout(), nullptr, &tmp)->FindFlyFrame();
1664  pRet = pFrame ? static_cast<SwLayoutFrame*>(pFrame)->GetFormat() : nullptr;
1665  }
1666  return pRet;
1667 }
1668 
1670 {
1672 
1673  // investigate 'master' drawing object, if method
1674  // is called for a 'virtual' drawing object.
1675  const SdrObject* pInvestigatedObj;
1676  if (const SwDrawVirtObj* pDrawVirtObj = dynamic_cast<const SwDrawVirtObj*>( &rObj))
1677  {
1678  pInvestigatedObj = &(pDrawVirtObj->GetReferencedObj());
1679  }
1680  else
1681  {
1682  pInvestigatedObj = &rObj;
1683  }
1684 
1685  if( SdrInventor::FmForm == pInvestigatedObj->GetObjInventor() )
1686  {
1687  eType = OBJCNT_CONTROL;
1688  uno::Reference< awt::XControlModel > xModel =
1689  static_cast<const SdrUnoObj&>(*pInvestigatedObj).GetUnoControlModel();
1690  if( xModel.is() )
1691  {
1692  uno::Any aVal;
1693  OUString sName("ButtonType");
1694  uno::Reference< beans::XPropertySet > xSet(xModel, uno::UNO_QUERY);
1695 
1696  uno::Reference< beans::XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
1697  if(xInfo->hasPropertyByName( sName ))
1698  {
1699  aVal = xSet->getPropertyValue( sName );
1700  if( aVal.hasValue() && form::FormButtonType_URL == *o3tl::doAccess<form::FormButtonType>(aVal) )
1701  eType = OBJCNT_URLBUTTON;
1702  }
1703  }
1704  }
1705  else if (const SwVirtFlyDrawObj *pFlyObj = dynamic_cast<const SwVirtFlyDrawObj*>(pInvestigatedObj))
1706  {
1707  const SwFlyFrame *pFly = pFlyObj->GetFlyFrame();
1708  if ( pFly->Lower() && pFly->Lower()->IsNoTextFrame() )
1709  {
1710  if (static_cast<const SwNoTextFrame*>(pFly->Lower())->GetNode()->GetGrfNode())
1711  eType = OBJCNT_GRF;
1712  else
1713  eType = OBJCNT_OLE;
1714  }
1715  else
1716  eType = OBJCNT_FLY;
1717  }
1718  else if ( dynamic_cast<const SdrObjGroup*>( pInvestigatedObj) != nullptr )
1719  {
1720  SwDrawContact* pDrawContact( dynamic_cast<SwDrawContact*>(GetUserCall( pInvestigatedObj ) ) );
1721  if ( !pDrawContact )
1722  {
1723  OSL_FAIL( "<SwFEShell::GetObjCntType(..)> - missing draw contact object" );
1724  eType = OBJCNT_NONE;
1725  }
1726  else
1727  {
1728  SwFrameFormat* pFrameFormat( pDrawContact->GetFormat() );
1729  if ( !pFrameFormat )
1730  {
1731  OSL_FAIL( "<SwFEShell::GetObjCntType(..)> - missing frame format" );
1732  eType = OBJCNT_NONE;
1733  }
1734  else if ( RndStdIds::FLY_AS_CHAR != pFrameFormat->GetAnchor().GetAnchorId() )
1735  {
1736  eType = OBJCNT_GROUPOBJ;
1737  }
1738  }
1739  }
1740  else
1741  eType = OBJCNT_SIMPLE;
1742  return eType;
1743 }
1744 
1745 ObjCntType SwFEShell::GetObjCntType( const Point &rPt, SdrObject *&rpObj ) const
1746 {
1748 
1749  if( Imp()->HasDrawView() )
1750  {
1751  SdrPageView* pPView;
1752 
1753  SwDrawView *pDView = const_cast<SwDrawView*>(Imp()->GetDrawView());
1754 
1755  const auto nOld = pDView->GetHitTolerancePixel();
1756  // tolerance for Drawing-SS
1757  pDView->SetHitTolerancePixel( pDView->GetMarkHdlSizePixel()/2 );
1758 
1759  SdrObject* pObj = pDView->PickObj(rPt, pDView->getHitTolLog(), pPView, SdrSearchOptions::PICKMARKABLE);
1760  if (pObj)
1761  {
1762  rpObj = pObj;
1763  eType = GetObjCntType( *rpObj );
1764  }
1765 
1766  pDView->SetHitTolerancePixel( nOld );
1767  }
1768  return eType;
1769 }
1770 
1772 {
1774 
1775  if( Imp()->HasDrawView() )
1776  {
1777  const SdrMarkList &rMrkList = Imp()->GetDrawView()->GetMarkedObjectList();
1778  for( size_t i = 0, nE = rMrkList.GetMarkCount(); i < nE; ++i )
1779  {
1780  SdrObject* pObj = rMrkList.GetMark( i )->GetMarkedSdrObj();
1781  if( !pObj )
1782  continue;
1783  ObjCntType eTmp = GetObjCntType( *pObj );
1784  if( !i )
1785  {
1786  eType = eTmp;
1787  }
1788  else if( eTmp != eType )
1789  {
1790  eType = OBJCNT_DONTCARE;
1791  // once DontCare, always DontCare!
1792  break;
1793  }
1794  }
1795  }
1796  return eType;
1797 }
1798 
1799 void SwFEShell::ReplaceSdrObj( const OUString& rGrfName, const Graphic* pGrf )
1800 {
1801  CurrShell aCurr( this );
1802 
1803  const SdrMarkList *pMrkList;
1804  if( !(Imp()->HasDrawView() && 1 ==
1805  ( pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList())->GetMarkCount()) )
1806  return;
1807 
1808  SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1809  SwFrameFormat *pFormat = FindFrameFormat( pObj );
1810 
1811  // store attributes, then set the graphic
1812  SfxItemSet aFrameSet( mxDoc->GetAttrPool(),
1813  pFormat->GetAttrSet().GetRanges() );
1814  aFrameSet.Set( pFormat->GetAttrSet() );
1815 
1816  // set size and position?
1817  if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) == nullptr )
1818  {
1819  // then let's do it:
1820  const tools::Rectangle &rBound = pObj->GetSnapRect();
1821  Point aRelPos( pObj->GetRelativePos() );
1822 
1823  const tools::Long nWidth = rBound.Right() - rBound.Left();
1824  const tools::Long nHeight= rBound.Bottom() - rBound.Top();
1825  aFrameSet.Put( SwFormatFrameSize( SwFrameSize::Minimum,
1826  std::max( nWidth, tools::Long(MINFLY) ),
1827  std::max( nHeight, tools::Long(MINFLY) )));
1828 
1829  if( SfxItemState::SET != aFrameSet.GetItemState( RES_HORI_ORIENT ))
1830  aFrameSet.Put( SwFormatHoriOrient( aRelPos.getX(), text::HoriOrientation::NONE, text::RelOrientation::FRAME ));
1831 
1832  if( SfxItemState::SET != aFrameSet.GetItemState( RES_VERT_ORIENT ))
1833  aFrameSet.Put( SwFormatVertOrient( aRelPos.getY(), text::VertOrientation::NONE, text::RelOrientation::FRAME ));
1834 
1835  }
1836 
1837  pObj->GetOrdNum();
1838 
1839  StartAllAction();
1840  StartUndo();
1841 
1842  // delete "Sdr-Object", insert the graphic instead
1843  DelSelectedObj();
1844 
1846  *GetCursor(), rGrfName, "", pGrf, &aFrameSet, nullptr, nullptr);
1847 
1848  EndUndo();
1849  EndAllAction();
1850 }
1851 
1852 static sal_uInt16 SwFormatGetPageNum(const SwFlyFrameFormat * pFormat)
1853 {
1854  OSL_ENSURE(pFormat != nullptr, "invalid argument");
1855 
1856  SwFlyFrame * pFrame = pFormat->GetFrame();
1857 
1858  sal_uInt16 aResult;
1859 
1860  if (pFrame != nullptr)
1861  aResult = pFrame->GetPhyPageNum();
1862  else
1863  aResult = pFormat->GetAnchor().GetPageNum();
1864 
1865  return aResult;
1866 }
1867 
1869  const OUString & rReference,
1870  bool bSuccessors,
1871  std::vector< OUString > & aPrevPageVec,
1872  std::vector< OUString > & aThisPageVec,
1873  std::vector< OUString > & aNextPageVec,
1874  std::vector< OUString > & aRestVec)
1875 {
1876  StartAction();
1877 
1878  SwFormatChain rChain = rFormat.GetChain();
1879  SwFrameFormat * pOldChainNext = rChain.GetNext();
1880  SwFrameFormat * pOldChainPrev = rChain.GetPrev();
1881 
1882  if (pOldChainNext)
1883  mxDoc->Unchain(rFormat);
1884 
1885  if (pOldChainPrev)
1886  mxDoc->Unchain(*pOldChainPrev);
1887 
1888  const size_t nCnt = mxDoc->GetFlyCount(FLYCNTTYPE_FRM);
1889 
1890  /* potential successors resp. predecessors */
1891  std::vector< const SwFrameFormat * > aTmpSpzArray;
1892 
1893  mxDoc->FindFlyByName(rReference);
1894 
1895  for (size_t n = 0; n < nCnt; ++n)
1896  {
1897  const SwFrameFormat & rFormat1 = *(mxDoc->GetFlyNum(n, FLYCNTTYPE_FRM));
1898 
1899  /*
1900  pFormat is a potential successor of rFormat if it is chainable after
1901  rFormat.
1902 
1903  pFormat is a potential predecessor of rFormat if rFormat is chainable
1904  after pFormat.
1905  */
1906 
1907  SwChainRet nChainState;
1908 
1909  if (bSuccessors)
1910  nChainState = mxDoc->Chainable(rFormat, rFormat1);
1911  else
1912  nChainState = mxDoc->Chainable(rFormat1, rFormat);
1913 
1914  if (nChainState == SwChainRet::OK)
1915  {
1916  aTmpSpzArray.push_back(&rFormat1);
1917 
1918  }
1919 
1920  }
1921 
1922  if (!aTmpSpzArray.empty())
1923  {
1924  aPrevPageVec.clear();
1925  aThisPageVec.clear();
1926  aNextPageVec.clear();
1927  aRestVec.clear();
1928 
1929  /* number of page rFormat resides on */
1930  sal_uInt16 nPageNum = SwFormatGetPageNum(static_cast<SwFlyFrameFormat *>(&rFormat));
1931 
1932  for (const auto& rpFormat : aTmpSpzArray)
1933  {
1934  const OUString aString = rpFormat->GetName();
1935 
1936  /* rFormat is not a valid successor or predecessor of
1937  itself */
1938  if (aString != rReference && aString != rFormat.GetName())
1939  {
1940  sal_uInt16 nNum1 =
1941  SwFormatGetPageNum(static_cast<const SwFlyFrameFormat *>(rpFormat));
1942 
1943  if (nNum1 == nPageNum -1)
1944  aPrevPageVec.push_back(aString);
1945  else if (nNum1 == nPageNum)
1946  aThisPageVec.push_back(aString);
1947  else if (nNum1 == nPageNum + 1)
1948  aNextPageVec.push_back(aString);
1949  else
1950  aRestVec.push_back(aString);
1951  }
1952  }
1953 
1954  }
1955 
1956  if (pOldChainNext)
1957  mxDoc->Chain(rFormat, *pOldChainNext);
1958 
1959  if (pOldChainPrev)
1960  mxDoc->Chain(*pOldChainPrev, rFormat);
1961 
1962  EndAction();
1963 }
1964 
1965 // #i73249#
1966 OUString SwFEShell::GetObjTitle() const
1967 {
1968  if ( Imp()->HasDrawView() )
1969  {
1970  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
1971  if ( pMrkList->GetMarkCount() == 1 )
1972  {
1973  const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1974  const SwFrameFormat* pFormat = FindFrameFormat( pObj );
1975  if ( pFormat->Which() == RES_FLYFRMFMT )
1976  {
1977  return static_cast<const SwFlyFrameFormat*>(pFormat)->GetObjTitle();
1978  }
1979  return pObj->GetTitle();
1980  }
1981  }
1982 
1983  return OUString();
1984 }
1985 
1986 void SwFEShell::SetObjTitle( const OUString& rTitle )
1987 {
1988  if ( !Imp()->HasDrawView() )
1989  return;
1990 
1991  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
1992  if ( pMrkList->GetMarkCount() != 1 )
1993  return;
1994 
1995  SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
1996  SwFrameFormat* pFormat = FindFrameFormat( pObj );
1997  if ( pFormat->Which() == RES_FLYFRMFMT )
1998  {
1999  GetDoc()->SetFlyFrameTitle( dynamic_cast<SwFlyFrameFormat&>(*pFormat),
2000  rTitle );
2001  }
2002  else
2003  {
2004  pObj->SetTitle( rTitle );
2005  }
2006 }
2007 
2009 {
2010  if ( Imp()->HasDrawView() )
2011  {
2012  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2013  if ( pMrkList->GetMarkCount() == 1 )
2014  {
2015  const SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2016  const SwFrameFormat* pFormat = FindFrameFormat( pObj );
2017  if ( pFormat->Which() == RES_FLYFRMFMT )
2018  {
2019  return dynamic_cast<const SwFlyFrameFormat&>(*pFormat).GetObjDescription();
2020  }
2021  return pObj->GetDescription();
2022  }
2023  }
2024 
2025  return OUString();
2026 }
2027 
2028 void SwFEShell::SetObjDescription( const OUString& rDescription )
2029 {
2030  if ( !Imp()->HasDrawView() )
2031  return;
2032 
2033  const SdrMarkList *pMrkList = &Imp()->GetDrawView()->GetMarkedObjectList();
2034  if ( pMrkList->GetMarkCount() != 1 )
2035  return;
2036 
2037  SdrObject* pObj = pMrkList->GetMark( 0 )->GetMarkedSdrObj();
2038  SwFrameFormat* pFormat = FindFrameFormat( pObj );
2039  if ( pFormat->Which() == RES_FLYFRMFMT )
2040  {
2041  GetDoc()->SetFlyFrameDescription(dynamic_cast<SwFlyFrameFormat&>(*pFormat),
2042  rDescription);
2043  }
2044  else
2045  {
2046  pObj->SetDescription( rDescription );
2047  }
2048 }
2049 
2050 void SwFEShell::AlignFormulaToBaseline( const uno::Reference < embed::XEmbeddedObject >& xObj )
2051 {
2052 #if OSL_DEBUG_LEVEL > 0
2053  SvGlobalName aCLSID( xObj->getClassID() );
2054  const bool bStarMath = ( SotExchange::IsMath( aCLSID ) != 0 );
2055  OSL_ENSURE( bStarMath, "AlignFormulaToBaseline should only be called for Math objects" );
2056 
2057  if ( !bStarMath )
2058  return;
2059 #endif
2060 
2061  SwFlyFrame * pFly = FindFlyFrame( xObj );
2062  OSL_ENSURE( pFly , "No fly frame!" );
2063  SwFrameFormat * pFrameFormat = pFly ? pFly->GetFormat() : nullptr;
2064 
2065  // baseline to baseline alignment should only be applied to formulas anchored as char
2066  if ( !pFly || !pFrameFormat || RndStdIds::FLY_AS_CHAR != pFrameFormat->GetAnchor().GetAnchorId() )
2067  return;
2068 
2069  // get baseline from Math object
2070  uno::Any aBaseline;
2072  {
2073  uno::Reference < beans::XPropertySet > xSet( xObj->getComponent(), uno::UNO_QUERY );
2074  if ( xSet.is() )
2075  {
2076  try
2077  {
2078  aBaseline = xSet->getPropertyValue("BaseLine");
2079  }
2080  catch ( uno::Exception& )
2081  {
2082  OSL_FAIL( "Baseline could not be retrieved from Starmath!" );
2083  }
2084  }
2085  }
2086 
2087  sal_Int32 nBaseline = ::comphelper::getINT32(aBaseline);
2088  const MapMode aSourceMapMode( MapUnit::Map100thMM );
2089  const MapMode aTargetMapMode( MapUnit::MapTwip );
2090  nBaseline = OutputDevice::LogicToLogic( nBaseline, aSourceMapMode.GetMapUnit(), aTargetMapMode.GetMapUnit() );
2091 
2092  OSL_ENSURE( nBaseline > 0, "Wrong value of Baseline while retrieving from Starmath!" );
2093  //nBaseline must be moved by aPrt position
2094  const SwFlyFrameFormat *pFlyFrameFormat = pFly->GetFormat();
2095  OSL_ENSURE( pFlyFrameFormat, "fly frame format missing!" );
2096  if ( pFlyFrameFormat )
2097  nBaseline += pFlyFrameFormat->GetLastFlyFramePrtRectPos().Y();
2098 
2099  const SwFormatVertOrient &rVert = pFrameFormat->GetVertOrient();
2100  SwFormatVertOrient aVert( rVert );
2101  aVert.SetPos( -nBaseline );
2103 
2104  pFrameFormat->LockModify();
2105  pFrameFormat->SetFormatAttr( aVert );
2106  pFrameFormat->UnlockModify();
2107  pFly->InvalidatePos();
2108 
2109 }
2110 
2112 {
2113  StartAllAction();
2114 
2115  SwStartNode *pStNd;
2116  SwNodeIndex aIdx( *GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
2117  while ( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
2118  {
2119  ++aIdx;
2120  SwOLENode *pOleNode = dynamic_cast< SwOLENode * >( &aIdx.GetNode() );
2121  if ( pOleNode )
2122  {
2123  const uno::Reference < embed::XEmbeddedObject > & xObj( pOleNode->GetOLEObj().GetOleRef() );
2124  if (xObj.is())
2125  {
2126  SvGlobalName aCLSID( xObj->getClassID() );
2127  if ( SotExchange::IsMath( aCLSID ) )
2128  AlignFormulaToBaseline( xObj );
2129  }
2130  }
2131 
2132  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
2133  }
2134 
2135  EndAllAction();
2136 }
2137 
2138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
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:1004
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:1473
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:315
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:2349
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:1511
const SwNodes & GetNodes() const
Definition: viewsh.cxx:2085
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:959
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:373
OUString GetObjDescription() const
Definition: atrfrm.cxx:3222
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 SdrObjList * getChildrenOfSdrObject() const
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
constexpr tools::Long Left() const
const Graphic * GetGrfAtPos(const Point &rDocPos, OUString &rName, bool &rbLink) const
Deliver graphic in rName besides graphic name.
Definition: fefly1.cxx:1584
const SwFormatVertOrient & GetVertOrient(bool=true) const
Definition: fmtornt.hxx:106
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
SwNodeIndex nNode
Definition: pam.hxx:37
bool IsTableMode() const
Definition: crsrsh.hxx:643
SwFrameFormat * WizardGetFly()
Find/delete fly containing the cursor.
Definition: fefly1.cxx:1444
void SetCompletePaint() const
Definition: frame.hxx:995
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:1288
#define MINFLY
Definition: swtypes.hxx:62
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:181
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:909
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
SdrObject * GetObj(size_t nNum) const
Definition: doc.hxx:188
size_t GetObjCount() const
void InvalidatePos()
Definition: frame.hxx:1044
ObjCntType
Definition: fesh.hxx:120
bool HasDrawView() const
Definition: vnew.cxx:358
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:249
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:171
RotateFlyFrame3: Helper class when you want to make your SwFrame derivate transformable.
Definition: frame.hxx:236
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
static SfxItemSet makeItemSetFromFormatAnchor(SfxItemPool &rPool, const SwFormatAnchor &rAnchor)
Definition: fefly1.cxx:1139
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 >)
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:1211
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:1017
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:180
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:453
const OUString & GetName() const
Definition: format.hxx:115
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2570
bool IsTextFrame() const
Definition: frame.hxx:1235
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:189
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
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:1852
SwFlyFrame * FindFlyFrame()
Definition: frame.hxx:1112
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
Definition: ndgrf.cxx:492
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:2667
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:304
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:1493
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:575
DocumentType eType
bool GetFlyFrameAttr(SfxItemSet &rSet) const
Definition: fefly1.cxx:1062
OUString GetObjTitle() const
Definition: fefly1.cxx:1966
SdrObject * GetMarkedSdrObj() const
void SetObjDescription(const OUString &rDescription)
Definition: fefly1.cxx:2028
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:59
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:2050
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:681
void ParkCursor(const SwNodeIndex &rIdx)
Remove selections and additional cursors of all shells.
Definition: crsrsh.cxx:2872
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:1868
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:1105
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:300
constexpr tools::Long Right() const
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:2704
OUString GetTitle() const
void UnlockModify()
Definition: calbck.hxx:210
sal_uInt32 GetOrdNum() const
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
void LockModify()
Definition: calbck.hxx:209
constexpr tools::Long Top() const
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:1311
void SSize(const Size &rNew)
Definition: swrect.hxx:180
static bool changeAnchor(SwFrameFormat *pShape, SdrObject *pObj)
Sets the anchor of the associated textframe of the given shape, and returns true on success...
SwStartNode * GetStartNode()
Definition: node.hxx:592
const SwFrameFormat * GetFormatFromAnyObj(const Point &rPt) const
Definition: fefly1.cxx:1653
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:836
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:1215
void ReplaceSdrObj(const OUString &rGrfName, const Graphic *pGrf)
Definition: fefly1.cxx:1799
IMapObject * GetIMapObject(const Point &rPoint, const SwFlyFrame *pFly=nullptr) const
Definition: atrfrm.cxx:3517
const SwFrameFormat * GetDfltFrameFormat() const
Definition: doc.hxx:747
constexpr tools::Long Bottom() const
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:929
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
void CallChgLnk()
Definition: crsrsh.cxx:2527
IDocumentUndoRedo const & GetIDocumentUndoRedo() const
Provides access to the document undo/redo interface.
Definition: viewsh.cxx:2679
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:211
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:1622
const SwFrameFormat * NewFlyFrame(const SfxItemSet &rSet, bool bAnchValid=false, SwFrameFormat *pParent=nullptr)
Definition: fefly1.cxx:660
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
const SwFormatChain & GetChain(bool=true) const
Definition: fmtcnct.hxx:70
SwDrawView * GetDrawView()
Definition: viewimp.hxx:156
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:2447
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:973
const OUString & GetTargetFrameName() const
Definition: fmturl.hxx:65
void AlignAllFormulasToBaseline()
aligns all formulas with anchor 'as char' to baseline
Definition: fefly1.cxx:2111
SwShellCursor * GetNext()
Definition: viscrs.hxx:164
OUString GetUniqueGrfName() const
Created unique name for frame.
Definition: fefly1.cxx:1506
ObjCntType GetObjCntTypeOfSelection() const
Definition: fefly1.cxx:1771
SwRect GetObjRect() const
For adjustment of PosAttr when anchor changes.
Definition: fefly1.cxx:1300
virtual Size ChgSize(const Size &aNewSize) override
Definition: fly.cxx:2122
bool IsNoTextFrame() const
Definition: frame.hxx:1239
bool IsFlyFreeFrame() const
Definition: flyfrm.hxx:216
SwNodes & GetNodes()
Definition: doc.hxx:409
static bool PosInsideInputField(const SwPosition &rPos)
Definition: crstrvl.cxx:957
SwRect getUntransformedFrameArea() const
Definition: wsfrm.cxx:164
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:206
void SetDescription(const OUString &rStr)
void DelSelectedObj()
Definition: feshview.cxx:2367
const Point & GetPtPos() const
Definition: viscrs.hxx:141
Size RequestObjectResize(const SwRect &rRect, const css::uno::Reference< css::embed::XEmbeddedObject > &)
OLE.
Definition: fefly1.cxx:1320
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:155
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
Definition: docfly.cxx:586
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet, SdrObject *pObj)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
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:1188
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:1225
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:1058
void SetType(RndStdIds nRndId)
Definition: fmtanchr.hxx:71
const SwStartNode * FindFlyStartNode() const
Definition: node.hxx:199
sal_uInt16 GetMarkHdlSizePixel() const
const SwFrameFormat * GetFlyFrameFormat() const
Get FlyFrameFormat; for UI macro linkage at Flys.
Definition: fefly1.cxx:1272
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:1986
const Point & GetLastFlyFramePrtRectPos() const
Definition: frmfmt.hxx:248
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:1669
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:2008
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:2067
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:193
SdrObjUserCall * GetUserCall() const
Point & GetCursorDocPos() const
Definition: crsrsh.hxx:896
OUString GetFlyName() const
Definition: fefly1.cxx:1483
SwChainRet
Definition: flyenum.hxx:33
const OUString & GetURL() const
void SetTitle(const OUString &rStr)
sal_uInt16 GetPageNum() const
Definition: rootfrm.hxx:313
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:680
SdrObject * FindRealSdrObject()
Definition: atrfrm.cxx:2773
const Graphic & GetGrf(bool bWait=false) const
Definition: ndgrf.cxx:371
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:1149
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:158
bool IsPosProtected() const
SwFlyFrame * GetFrame(const Point *pDocPos=nullptr) const
Definition: atrfrm.cxx:3125
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1584
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