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