24 #include <osl/diagnose.h>
35 #include <drawdoc.hxx>
71 const size_t nSize = rFormats.
size();
75 for (
size_t i = 0;
i < nSize; ++
i)
119 const size_t nSize = rFormats.
size();
123 for(
size_t i = 0; !pRetFormat &&
i < nSize; ++
i )
140 pRetFormat = pFlyFormat;
143 if(pNd->
IsGrfNode() && nIdx == nCount++ )
144 pRetFormat = pFlyFormat;
148 pRetFormat = pFlyFormat;
152 pRetFormat = pFlyFormat;
160 FlyCntType const eType,
bool const bIgnoreTextBoxes)
163 const size_t nSize = rFormats.
size();
165 std::vector<SwFrameFormat const*> ret;
168 for (
size_t i = 0;
i < nSize; ++
i)
183 if (pIdx && pIdx->GetNodes().IsDocNodes())
190 ret.push_back(pFlyFormat);
194 ret.push_back(pFlyFormat);
198 ret.push_back(pFlyFormat);
201 ret.push_back(pFlyFormat);
216 case RndStdIds::FLY_AS_CHAR:
225 case RndStdIds::FLY_AT_PARA:
226 case RndStdIds::FLY_AT_CHAR:
231 std::pair<Point, bool>
const tmp(aRet,
false);
238 case RndStdIds::FLY_AT_FLY:
242 nNode.GetNode().GetFlyFormat());
249 case RndStdIds::FLY_AT_PAGE:
253 for( sal_uInt16
i = 1; (
i <=
nPgNum) && pPage; ++
i,
254 pPage =
static_cast<const SwPageFrame*
>(pPage->GetNext()) )
269 #define IGNOREANCHOR 1
270 #define DONTMAKEFRMS 2
284 if( !aNewAnch.GetContentAnchor() && (RndStdIds::FLY_AT_FLY == nNew ||
285 (RndStdIds::FLY_AT_PARA == nNew) || (RndStdIds::FLY_AS_CHAR == nNew) ||
286 (RndStdIds::FLY_AT_CHAR == nNew) ))
302 if ( RndStdIds::FLY_AS_CHAR == nOld )
310 OSL_ENSURE( pTextNode->
HasHints(),
"Missing FlyInCnt-Hint." );
315 "Missing FlyInCnt-Hint." );
317 "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:
374 bool bPutOldH(
false);
379 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldH.GetPos();
380 nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
382 if( pHoriOrientItem )
387 aOldH.SetPos( nPos );
390 if (nNew == RndStdIds::FLY_AT_PAGE)
392 sal_Int16 nRelOrient(pHoriOrientItem
394 : aOldH.GetRelationOrient());
397 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
398 aOldH.SetRelationOrient(nRelOrient);
415 SwTwips nPos = (RndStdIds::FLY_AS_CHAR == nOld) ? 0 : aOldV.GetPos();
416 nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
417 if( pVertOrientItem )
423 aOldV.SetPos( nPos );
452 ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat, rSet,
false )
460 switch(pItemIter->Which())
467 OSL_FAIL(
"Unknown Fly attribute." );
470 rSet.ClearItem(pItemIter->Which());
479 *pItem != *pItemIter))
480 aTmpSet.Put(*pItemIter);
486 }
while (pItemIter && (0 != pItemIter->Which()));
488 if( aTmpSet.Count() )
494 return aTmpSet.Count() ||
MAKEFRMS == nMakeFrames;
506 std::unique_ptr<SfxPoolItem> pResult;
508 switch(pItem->Which())
512 pResult = pItem->StaticWhichCast(
XATTR_FILLBITMAP).checkForUniqueItem(pDrawModel);
517 pResult = pItem->StaticWhichCast(
XATTR_LINEDASH).checkForUniqueItem(pDrawModel);
522 pResult = pItem->StaticWhichCast(
XATTR_LINESTART).checkForUniqueItem(pDrawModel);
527 pResult = pItem->StaticWhichCast(
XATTR_LINEEND).checkForUniqueItem(pDrawModel);
542 pResult = pItem->StaticWhichCast(
XATTR_FILLHATCH).checkForUniqueItem(pDrawModel);
559 std::unique_ptr<SwUndoFormatAttrHelper> pSaveUndo;
569 if (pSaveUndo && pSaveUndo->GetUndo() )
583 const OUString& sNewTitle )
606 const OUString& sNewDescription )
631 bool bChgAnchor =
false, bFrameSz =
false;
679 aFlySet.
Put( *pFormatAnchor );
708 pUndo->EndListeningAll();
720 if( pGrfNd && pGrfNd->IsLinkedFile() )
726 const bool _bSameOnly,
727 const bool _bPosCorr )
739 bool bUnmark =
false;
743 if ( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==
nullptr )
753 #if OSL_DEBUG_LEVEL > 0
755 bool bNoUserCallExcepted = pSwDrawVirtObj && !pSwDrawVirtObj->
IsConnected();
756 OSL_ENSURE( bNoUserCallExcepted,
"SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
763 const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
770 std::unique_ptr<const SwPosition> xOldAsCharAnchorPos;
772 if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
778 _eAnchorType = eOldAnchorType;
783 const Point aPt( aObjRect.TopLeft() );
785 switch ( _eAnchorType )
787 case RndStdIds::FLY_AT_PARA:
788 case RndStdIds::FLY_AT_CHAR:
792 ? aObjRect.TopRight()
796 pNewAnchorFrame =
::FindAnchor( pOldAnchorFrame, aNewPoint );
799 pNewAnchorFrame =
static_cast<const SwTextFrame*
>(pNewAnchorFrame)->FindMaster();
803 pNewAnchorFrame =
nullptr;
808 ? *
static_cast<SwTextFrame const*
>(pNewAnchorFrame)->GetTextNodeForParaProps()
811 aNewAnch.
SetType( _eAnchorType );
817 case RndStdIds::FLY_AT_FLY:
825 aPoint.setX(aPoint.getX() - 1);
829 std::pair<Point, bool>
const tmp(aPt,
false);
837 if( pNewAnchorFrame && !pNewAnchorFrame->
IsProtected() )
846 aNewAnch.
SetType( RndStdIds::FLY_AT_PAGE );
849 case RndStdIds::FLY_AT_PAGE:
853 pNewAnchorFrame = pNewAnchorFrame->
GetNext();
854 if ( !pNewAnchorFrame )
857 aNewAnch.
SetPageNum( static_cast<const SwPageFrame*>(pNewAnchorFrame)->GetPhyPageNum());
860 case RndStdIds::FLY_AS_CHAR:
863 if( !pOldAnchorFrame )
876 pNewAnchorFrame =
nullptr;
880 bUnmark = ( 0 !=
i );
882 aPoint.setX(aPoint.getX() - 1);
883 aNewAnch.
SetType( RndStdIds::FLY_AS_CHAR );
886 static_cast<SwTextFrame const*>(pNewAnchorFrame));
887 SwPosition aPos( *pFrame->GetTextNodeForParaProps() );
903 aPos = pFrame->MapViewToModelPos(
913 OSL_ENSURE( pNd,
"Cursor not positioned at TextNode." );
916 pNd->InsertItem( aFormat, aPos.nContent.GetIndex(), 0 );
928 OSL_ENSURE(
false,
"unexpected AnchorId." );
931 if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
933 ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
943 if ( pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected() )
945 SwRect aNewObjRect( aObjRect );
947 ->AdjustPositioningAttr( pNewAnchorFrame,
953 ->AdjustPositioningAttr( pNewAnchorFrame );
956 if (aNewAnch.
GetAnchorId() == RndStdIds::FLY_AT_PAGE)
959 sal_Int16 nRelOrient(item.GetRelationOrient());
962 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
963 item.SetRelationOrient(nRelOrient);
977 if (xOldAsCharAnchorPos)
979 if ( pNewAnchorFrame)
985 const sal_Int32 nIndx( xOldAsCharAnchorPos->nContent.GetIndex() );
986 SwTextNode* pTextNode( xOldAsCharAnchorPos->nNode.GetNode().GetTextNode() );
987 assert(pTextNode &&
"<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
990 assert(pHint &&
"Missing FlyInCnt-Hint.");
1016 if( pFormat == &rSource )
1019 }
while ( pFormat );
1042 pTextNd->
GetText().getLength() )
1051 if ( (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1052 (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1057 if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd +
SwNodeOffset(2) )
1072 bool bAllowed =
false;
1073 if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.
GetAnchorId() )
1075 if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1076 ( rDstAnchor.GetContentAnchor() &&
1077 rDstAnchor.GetContentAnchor()->nNode.GetIndex() > nEndOfExtras ))
1083 &rDstIdx = rDstAnchor.GetContentAnchor()->nNode;
1085 if( rSrcIdx == rDstIdx ||
1095 ( !pSttNd && rDstIdx.
GetIndex() > nEndOfExtras &&
1096 rSrcIdx.
GetIndex() > nEndOfExtras ))
1114 aChain.
SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1115 SetAttr( aChain, rDestFormat );
1121 aChain.
SetPrev( &static_cast<SwFlyFrameFormat&>(rSource) );
1122 SetAttr( aChain, rDestFormat );
1127 aChain.
SetNext( &rDestFormat );
1149 if ( aChain.GetNext() )
1153 aChain.SetNext(
nullptr );
static SwFrameFormat * getOtherTextBoxFormat(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
If we have an associated TextFrame, then return that.
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)
SwNodeOffset EndOfSectionIndex() const
const SwStartNode * FindHeaderStartNode() const
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
size_t GetMarkCount() const
Self-chaining is not allowed.
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
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.
const WhichRangesContainer & GetRanges() const
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.
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 >)
const SwFrameFormats * GetSpzFrameFormats() const
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
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< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
Destination and/or source not found.
const SwRect & getFrameArea() const
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
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
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
SwNodeOffset GetIndex() const
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< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
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()
SwNodeOffset GetIndex() const
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
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(95)
bool Contains(const Point &rPOINT) const
const SwNodeIndex * GetContentIdx() 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
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)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
static void syncFlyFrameAttr(SwFrameFormat &rShape, SfxItemSet const &rSet, SdrObject *pObj)
Similar to syncProperty(), but used by the internal API (e.g. for UI purposes).
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
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 m_bDetectedRangeSegmentation false
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.