34 #include <drawdoc.hxx>
70 const size_t nSize = rFormats.
size();
74 for (
size_t i = 0;
i < nSize; ++
i)
118 const size_t nSize = rFormats.
size();
122 for(
size_t i = 0; !pRetFormat &&
i < nSize; ++
i )
139 pRetFormat = pFlyFormat;
142 if(pNd->
IsGrfNode() && nIdx == nCount++ )
143 pRetFormat = pFlyFormat;
147 pRetFormat = pFlyFormat;
151 pRetFormat = pFlyFormat;
159 FlyCntType const eType,
bool const bIgnoreTextBoxes)
162 const size_t nSize = rFormats.
size();
164 std::vector<SwFrameFormat const*> ret;
167 for (
size_t i = 0;
i < nSize; ++
i)
182 if (pIdx && pIdx->GetNodes().IsDocNodes())
189 ret.push_back(pFlyFormat);
193 ret.push_back(pFlyFormat);
197 ret.push_back(pFlyFormat);
200 ret.push_back(pFlyFormat);
215 case RndStdIds::FLY_AS_CHAR:
224 case RndStdIds::FLY_AT_PARA:
225 case RndStdIds::FLY_AT_CHAR:
230 std::pair<Point, bool>
const tmp(aRet,
false);
237 case RndStdIds::FLY_AT_FLY:
241 nNode.GetNode().GetFlyFormat());
248 case RndStdIds::FLY_AT_PAGE:
252 for( sal_uInt16
i = 1; (
i <=
nPgNum) && pPage; ++
i,
253 pPage =
static_cast<const SwPageFrame*
>(pPage->GetNext()) )
268 #define IGNOREANCHOR 1
269 #define DONTMAKEFRMS 2
283 if( !aNewAnch.GetContentAnchor() && (RndStdIds::FLY_AT_FLY == nNew ||
284 (RndStdIds::FLY_AT_PARA == nNew) || (RndStdIds::FLY_AS_CHAR == nNew) ||
285 (RndStdIds::FLY_AT_CHAR == nNew) ))
301 if ( RndStdIds::FLY_AS_CHAR == nOld )
309 OSL_ENSURE( pTextNode->
HasHints(),
"Missing FlyInCnt-Hint." );
314 "Missing FlyInCnt-Hint." );
316 "Wrong TextFlyCnt-Hint." );
332 case RndStdIds::FLY_AS_CHAR:
336 const SwPosition *pPos = aNewAnch.GetContentAnchor();
338 OSL_ENSURE( pNd,
"Cursor does not point to TextNode." );
340 SwFormatFlyCnt aFormat( static_cast<SwFlyFrameFormat*>(&rFormat) );
348 switch( aOldV.GetVertOrient() )
350 case text::VertOrientation::LINE_TOP: aOldV.
SetVertOrient( text::VertOrientation::TOP );
break;
351 case text::VertOrientation::LINE_CENTER: aOldV.SetVertOrient( text::VertOrientation::CENTER);
break;
352 case text::VertOrientation::LINE_BOTTOM: aOldV.SetVertOrient( text::VertOrientation::BOTTOM);
break;
362 case RndStdIds::FLY_AT_PARA:
363 case RndStdIds::FLY_AT_CHAR:
364 case RndStdIds::FLY_AT_FLY:
365 case RndStdIds::FLY_AT_PAGE:
375 bool bPutOldH(
false);
380 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos();
381 nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
389 aOldH.SetPos( nPos );
392 if (nNew == RndStdIds::FLY_AT_PAGE)
394 sal_Int16 nRelOrient(pItem
395 ? static_cast<const SwFormatHoriOrient*>(pItem)->GetRelationOrient()
396 : aOldH.GetRelationOrient());
399 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
400 aOldH.SetRelationOrient(nRelOrient);
418 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos();
419 nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
426 aOldV.SetPos( nPos );
455 ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat, rSet, false )
463 switch(pItemIter->Which())
470 OSL_FAIL(
"Unknown Fly attribute." );
473 rSet.ClearItem(pItemIter->Which());
482 *pItem != *pItemIter))
483 aTmpSet.Put(*pItemIter);
489 }
while (pItemIter && (0 != pItemIter->Which()));
491 if( aTmpSet.Count() )
497 return aTmpSet.Count() ||
MAKEFRMS == nMakeFrames;
509 std::unique_ptr<SfxPoolItem> pResult;
511 switch(pItem->Which())
515 pResult =
static_cast< const XFillBitmapItem*
>(pItem)->checkForUniqueItem(pDrawModel);
520 pResult =
static_cast< const XLineDashItem*
>(pItem)->checkForUniqueItem(pDrawModel);
525 pResult =
static_cast< const XLineStartItem*
>(pItem)->checkForUniqueItem(pDrawModel);
530 pResult =
static_cast< const XLineEndItem*
>(pItem)->checkForUniqueItem(pDrawModel);
535 pResult =
static_cast< const XFillGradientItem*
>(pItem)->checkForUniqueItem(pDrawModel);
545 pResult =
static_cast< const XFillHatchItem*
>(pItem)->checkForUniqueItem(pDrawModel);
562 std::unique_ptr<SwUndoFormatAttrHelper> pSaveUndo;
572 if (pSaveUndo && pSaveUndo->GetUndo() )
586 const OUString& sNewTitle )
609 const OUString& sNewDescription )
634 bool bChgAnchor =
false, bFrameSz =
false;
682 aFlySet.Put( *pItem );
711 pUndo->EndListeningAll();
723 if( pGrfNd && pGrfNd->IsLinkedFile() )
729 const bool _bSameOnly,
730 const bool _bPosCorr )
742 bool bUnmark =
false;
746 if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==
nullptr )
756 #if OSL_DEBUG_LEVEL > 0
757 bool bNoUserCallExcepted =
760 OSL_ENSURE( bNoUserCallExcepted,
"SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
767 const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
774 std::unique_ptr<const SwPosition> xOldAsCharAnchorPos;
776 if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
782 _eAnchorType = eOldAnchorType;
787 const Point aPt( aObjRect.TopLeft() );
789 switch ( _eAnchorType )
791 case RndStdIds::FLY_AT_PARA:
792 case RndStdIds::FLY_AT_CHAR:
796 ? aObjRect.TopRight()
800 pNewAnchorFrame =
::FindAnchor( pOldAnchorFrame, aNewPoint );
803 pNewAnchorFrame =
static_cast<const SwTextFrame*
>(pNewAnchorFrame)->FindMaster();
807 pNewAnchorFrame =
nullptr;
812 ? *
static_cast<SwTextFrame const*
>(pNewAnchorFrame)->GetTextNodeForParaProps()
815 aNewAnch.
SetType( _eAnchorType );
821 case RndStdIds::FLY_AT_FLY:
829 aPoint.setX(aPoint.getX() - 1);
833 std::pair<Point, bool>
const tmp(aPt,
false);
841 if( pNewAnchorFrame && !pNewAnchorFrame->
IsProtected() )
850 aNewAnch.
SetType( RndStdIds::FLY_AT_PAGE );
853 case RndStdIds::FLY_AT_PAGE:
857 pNewAnchorFrame = pNewAnchorFrame->
GetNext();
858 if ( !pNewAnchorFrame )
861 aNewAnch.
SetPageNum( static_cast<const SwPageFrame*>(pNewAnchorFrame)->GetPhyPageNum());
864 case RndStdIds::FLY_AS_CHAR:
867 if( !pOldAnchorFrame )
880 pNewAnchorFrame =
nullptr;
884 bUnmark = ( 0 !=
i );
886 aPoint.setX(aPoint.getX() - 1);
887 aNewAnch.
SetType( RndStdIds::FLY_AS_CHAR );
890 static_cast<SwTextFrame const*>(pNewAnchorFrame));
891 SwPosition aPos( *pFrame->GetTextNodeForParaProps() );
907 aPos = pFrame->MapViewToModelPos(
917 OSL_ENSURE( pNd,
"Cursor not positioned at TextNode." );
920 pNd->InsertItem( aFormat, aPos.nContent.GetIndex(), 0 );
932 OSL_ENSURE(
false,
"unexpected AnchorId." );
935 if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
937 ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
946 if ( dynamic_cast<const SwDrawVirtObj*>( pObj) !=
nullptr &&
947 !static_cast<SwDrawVirtObj*>(pObj)->IsConnected() )
949 SwRect aNewObjRect( aObjRect );
951 ->AdjustPositioningAttr( pNewAnchorFrame,
957 ->AdjustPositioningAttr( pNewAnchorFrame );
960 if (aNewAnch.
GetAnchorId() == RndStdIds::FLY_AT_PAGE)
963 sal_Int16 nRelOrient(item.GetRelationOrient());
966 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
967 item.SetRelationOrient(nRelOrient);
981 if (xOldAsCharAnchorPos)
983 if ( pNewAnchorFrame)
989 const sal_Int32 nIndx( xOldAsCharAnchorPos->nContent.GetIndex() );
990 SwTextNode* pTextNode( xOldAsCharAnchorPos->nNode.GetNode().GetTextNode() );
991 assert(pTextNode &&
"<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
994 assert(pHint &&
"Missing FlyInCnt-Hint.");
1020 if( pFormat == &rSource )
1023 }
while ( pFormat );
1046 pTextNd->
GetText().getLength() )
1055 if ( (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1056 (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1061 if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd + 2 )
1076 bool bAllowed =
false;
1077 if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.
GetAnchorId() )
1079 if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1080 ( rDstAnchor.GetContentAnchor() &&
1081 rDstAnchor.GetContentAnchor()->nNode.GetIndex() > nEndOfExtras ))
1087 &rDstIdx = rDstAnchor.GetContentAnchor()->nNode;
1089 if( rSrcIdx == rDstIdx ||
1099 ( !pSttNd && rDstIdx.
GetIndex() > nEndOfExtras &&
1100 rSrcIdx.
GetIndex() > nEndOfExtras ))
1118 aChain.
SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1119 SetAttr( aChain, rDestFormat );
1125 aChain.
SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1126 SetAttr( aChain, rDestFormat );
1131 aChain.
SetNext( &rDestFormat );
1153 if ( aChain.GetNext() )
1157 aChain.SetNext(
nullptr );
Starts a section of nodes in the document model.
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
virtual SwRect GetObjRect() const =0
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(101)
constexpr TypedWhichId< SwFormatFillOrder > RES_FILL_ORDER(RES_FRMATR_BEGIN)
sal_uLong GetIndex() const
const SwStartNode * FindHeaderStartNode() const
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
size_t GetMarkCount() const
Self-chaining is not allowed.
Destination already in chain.
Marks a position in the document model.
class for the positioning of drawing objects
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.
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(98)
const OUString & GetText() const
const SwStartNode * FindFooterStartNode() const
virtual const SwRootFrame * GetCurrentLayout() const =0
constexpr TypedWhichId< SwFormatEditInReadonly > RES_EDIT_IN_READONLY(112)
static SwContentNode * GetContentNode(SwDoc &rDoc, SwNodeIndex &rIdx, bool bNext)
constexpr TypedWhichId< SwFormatCol > RES_COL(109)
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
virtual void SetModified()=0
Must be called manually at changes of format.
virtual bool Prepare(const PrepareHint ePrep=PrepareHint::Clear, const void *pVoid=nullptr, bool bNotify=true) override
SwContentFrame: the shortcut for the Frames If the void* casts wrongly, it's its own fault! The void*...
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(57)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
Content, content of frame (header, footer, fly).
SdrMark * GetMark(size_t nNum) const
void Pos(const Point &rNew)
IDocumentUndoRedo & GetIDocumentUndoRedo()
Of course Writer needs its own rectangles.
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
Only empty frames may be connected.
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType)
If we have an associated TextFrame, then return that.
const SwFrameFormats * GetSpzFrameFormats() const
Destination in section where it shouldn't be (header, footer).
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
SwChainRet Chain(SwFrameFormat &rSource, const SwFrameFormat &rDest)
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
static bool lcl_SetFlyFrameAttr(SwDoc &rDoc, sal_Int8(SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool), SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
const SfxPoolItem * NextItem()
wrapper class for the positioning of Writer fly frames and drawing objects
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
Destination and/or source not found.
const SwRect & getFrameArea() const
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
sal_uLong GetIndex() const
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType)
Is the frame format a text box?
SwTextAttr * InsertItem(SfxPoolItem &rAttr, const sal_Int32 nStart, const sal_Int32 nEnd, const SetAttrMode nMode=SetAttrMode::DEFAULT)
create new text attribute from rAttr and insert it
SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false)
SwFlyFrame * FindFlyFrame()
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
void Unchain(SwFrameFormat &rFormat)
virtual bool DoesUndo() const =0
Is Undo enabled?
SwAttrPool * GetPool() const
static Point lcl_FindAnchorLayPos(SwDoc &rDoc, const SwFormatAnchor &rAnch, const SwFrameFormat *pFlyFormat)
bool GetAtPageRelOrientation(sal_Int16 &rOrientation, bool const isIgnorePrintArea)
SdrObject * GetMarkedSdrObj() const
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
virtual void ClearRedo()=0
Delete all Redo actions.
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< SwFormatURL > RES_URL(111)
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
const SwFrame * Lower() const
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
SwContentNode * GetContentNode()
void UpdateObjInSortedList()
method to update anchored object in the lists
IDocumentState const & getIDocumentState() const
sal_Int8 SetFlyFrameAnchor(SwFrameFormat &rFlyFormat, SfxItemSet &rSet, bool bNewFrames)
bool IsNoTextNode() const
Marks a node in the document model.
A page of the document layout.
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
static void GetGrfNms(const SwFlyFrameFormat &rFormat, OUString *pGrfName, OUString *pFltName)
stay with the cursor inside text
Frame cannot be moved in Var-direction.
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
const SwNodeIndex * GetContentIdx() const
sal_uInt16 const aFrameFormatSetRange[]
sal_uLong EndOfSectionIndex() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void Bottom(const tools::Long nBottom)
SwTextNode is a paragraph in the document model.
void DeleteAttributes(const sal_uInt16 nWhich, const sal_Int32 nStart, const sal_Int32 nEnd=0)
delete all attributes of type nWhich at nStart (opt. end nEnd)
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(114)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
tools::Rectangle SVRect() const
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
general base class for all free-flowing frames
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
const SwNodes & GetNodes() const
#define SAL_INFO(area, stream)
sal_Int32 GetIndex() const
bool IsInside(const Point &rPOINT) const
virtual SwDrawModel * GetOrCreateDrawModel()=0
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Access to frames.
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object...
bool IsRightToLeft() const
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(157)
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(154)
SdrObject * getParentSdrObjectFromSdrObject() const
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBody=false)
search an anchor for paragraph bound frames starting from pOldAnch
const SwStartNode * FindFlyStartNode() const
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
const sal_uInt16 * GetRanges() const
SwChainRet Chainable(const SwFrameFormat &rSource, const SwFrameFormat &rDest)
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc...
bool IsInvalidItem(const SfxPoolItem *pItem)
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Source already has a follow.
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...
void Height(tools::Long nNew)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
const SfxPoolItem * GetCurItem() const
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(104)
const SwAttrPool & GetAttrPool() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
const SwFormatFlyCnt & GetFlyCnt() const
Base class of the Writer document model elements.