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