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