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