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