24#include <osl/diagnose.h>
81 pIdx = pFlyFormat->GetContent().GetContentIdx();
125 pIdx = pFlyFormat->GetContent().GetContentIdx();
133 pRetFormat = pFlyFormat;
137 pRetFormat = pFlyFormat;
141 pRetFormat = pFlyFormat;
145 pRetFormat = pFlyFormat;
153 FlyCntType const eType,
bool const bIgnoreTextBoxes)
155 std::vector<SwFrameFormat const*> ret;
170 SwNodeIndex const*
const pIdx(pFlyFormat->GetContent().GetContentIdx());
178 ret.push_back(pFlyFormat);
182 ret.push_back(pFlyFormat);
186 ret.push_back(pFlyFormat);
189 ret.push_back(pFlyFormat);
204 case RndStdIds::FLY_AS_CHAR:
213 case RndStdIds::FLY_AT_PARA:
214 case RndStdIds::FLY_AT_CHAR:
218 std::pair<Point, bool>
const tmp(aRet,
false);
225 case RndStdIds::FLY_AT_FLY:
236 case RndStdIds::FLY_AT_PAGE:
240 for( sal_uInt16
i = 1; (
i <=
nPgNum) && pPage; ++
i,
256#define IGNOREANCHOR 1
257#define DONTMAKEFRMS 2
271 if( !aNewAnch.
GetAnchorNode() && (RndStdIds::FLY_AT_FLY == nNew ||
272 (RndStdIds::FLY_AT_PARA == nNew) || (RndStdIds::FLY_AS_CHAR == nNew) ||
273 (RndStdIds::FLY_AT_CHAR == nNew) ))
289 if ( RndStdIds::FLY_AS_CHAR == nOld )
297 OSL_ENSURE( pTextNode->
HasHints(),
"Missing FlyInCnt-Hint." );
302 "Missing FlyInCnt-Hint." );
304 "Wrong TextFlyCnt-Hint." );
319 case RndStdIds::FLY_AS_CHAR:
325 OSL_ENSURE( pNd,
"Cursor does not point to TextNode." );
337 case text::VertOrientation::LINE_TOP: aOldV.
SetVertOrient( text::VertOrientation::TOP );
break;
338 case text::VertOrientation::LINE_CENTER: aOldV.
SetVertOrient( text::VertOrientation::CENTER);
break;
339 case text::VertOrientation::LINE_BOTTOM: aOldV.
SetVertOrient( text::VertOrientation::BOTTOM);
break;
349 case RndStdIds::FLY_AT_PARA:
350 case RndStdIds::FLY_AT_CHAR:
351 case RndStdIds::FLY_AT_FLY:
352 case RndStdIds::FLY_AT_PAGE:
361 bool bPutOldH(
false);
376 if (nNew == RndStdIds::FLY_AT_PAGE)
378 sal_Int16 nRelOrient(pHoriOrientItem
383 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
435 ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat,
rSet, false )
443 switch(pItemIter->
Which())
450 OSL_FAIL(
"Unknown Fly attribute." );
462 *pItem != *pItemIter))
463 aTmpSet.
Put(*pItemIter);
469 }
while (pItemIter && (0 != pItemIter->
Which()));
471 if( aTmpSet.
Count() )
489 std::unique_ptr<SfxPoolItem> pResult;
491 switch(pItem->Which())
495 pResult = pItem->StaticWhichCast(
XATTR_FILLBITMAP).checkForUniqueItem(pDrawModel);
500 pResult = pItem->StaticWhichCast(
XATTR_LINEDASH).checkForUniqueItem(pDrawModel);
505 pResult = pItem->StaticWhichCast(
XATTR_LINESTART).checkForUniqueItem(pDrawModel);
510 pResult = pItem->StaticWhichCast(
XATTR_LINEEND).checkForUniqueItem(pDrawModel);
525 pResult = pItem->StaticWhichCast(
XATTR_FILLHATCH).checkForUniqueItem(pDrawModel);
553 const OUString& sNewTitle )
576 const OUString& sNewDescription )
599 bool const isDecorative)
611 std::make_unique<SwUndoFlyDecorative>(rFlyFrameFormat, isDecorative));
623 bool bChgAnchor =
false, bFrameSz =
false;
671 aFlySet.
Put( *pFormatAnchor );
718 const bool _bSameOnly,
719 const bool _bPosCorr )
731 bool bUnmark =
false;
745#if OSL_DEBUG_LEVEL > 0
747 bool bNoUserCallExcepted = pSwDrawVirtObj && !pSwDrawVirtObj->
IsConnected();
748 OSL_ENSURE( bNoUserCallExcepted,
"SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
755 const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
762 std::optional<SwPosition> oOldAsCharAnchorPos;
764 if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
770 _eAnchorType = eOldAnchorType;
777 switch ( _eAnchorType )
779 case RndStdIds::FLY_AT_PARA:
780 case RndStdIds::FLY_AT_CHAR:
788 pNewAnchorFrame =
::FindAnchor( pOldAnchorFrame, aNewPoint );
791 pNewAnchorFrame =
static_cast<const SwTextFrame*
>(pNewAnchorFrame)->FindMaster();
795 pNewAnchorFrame =
nullptr;
803 aNewAnch.
SetType( _eAnchorType );
809 case RndStdIds::FLY_AT_FLY:
821 std::pair<Point, bool>
const tmp(aPt,
false);
829 if( pNewAnchorFrame && !pNewAnchorFrame->
IsProtected() )
838 aNewAnch.
SetType( RndStdIds::FLY_AT_PAGE );
841 case RndStdIds::FLY_AT_PAGE:
845 pNewAnchorFrame = pNewAnchorFrame->
GetNext();
846 if ( !pNewAnchorFrame )
852 case RndStdIds::FLY_AS_CHAR:
855 if( !pOldAnchorFrame )
868 pNewAnchorFrame =
nullptr;
872 bUnmark = ( 0 !=
i );
875 aNewAnch.
SetType( RndStdIds::FLY_AS_CHAR );
905 OSL_ENSURE( pNd,
"Cursor not positioned at TextNode." );
919 OSL_ENSURE(
false,
"unexpected AnchorId." );
922 if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
924 ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
934 if ( pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected() )
936 SwRect aNewObjRect( aObjRect );
938 ->AdjustPositioningAttr( pNewAnchorFrame,
944 ->AdjustPositioningAttr( pNewAnchorFrame );
947 if (aNewAnch.
GetAnchorId() == RndStdIds::FLY_AT_PAGE)
953 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
968 if (oOldAsCharAnchorPos)
970 if ( pNewAnchorFrame)
976 const sal_Int32 nIndx( oOldAsCharAnchorPos->GetContentIndex() );
977 SwTextNode* pTextNode( oOldAsCharAnchorPos->GetNode().GetTextNode() );
978 assert(pTextNode &&
"<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
981 assert(pHint &&
"Missing FlyInCnt-Hint.");
1007 if( pFormat == &rSource )
1010 }
while ( pFormat );
1045 pTextNd->
GetText().getLength() )
1054 if ( (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1055 (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1060 if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd +
SwNodeOffset(2) )
1075 bool bAllowed =
false;
1076 if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.
GetAnchorId() )
1078 if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1079 ( rDstAnchor.GetAnchorNode() &&
1080 rDstAnchor.GetAnchorNode()->GetIndex() > nEndOfExtras ))
1083 else if( rSrcAnchor.
GetAnchorNode() && rDstAnchor.GetAnchorNode() )
1086 &rDstNd = *rDstAnchor.GetAnchorNode();
1088 if( rSrcNd == rDstNd ||
1098 ( !pSttNd && rDstNd.
GetIndex() > nEndOfExtras &&
1099 rSrcNd.
GetIndex() > nEndOfExtras ))
1118 SetAttr( aChain, rDestFormat );
1125 SetAttr( aChain, rDestFormat );
1130 aChain.
SetNext( &rDestFormat );
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 SwDrawModel * GetOrCreateDrawModel()=0
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual void SetModified()=0
Must be called manually at changes of format.
constexpr tools::Long Y() const
void setX(tools::Long nX)
constexpr tools::Long getX() const
constexpr tools::Long getY() const
size_t GetMarkCount() const
SdrMark * GetMark(size_t nNum) const
SdrObject * GetMarkedSdrObj() const
SdrObject * getParentSdrObjectFromSdrObject() const
const SfxPoolItem * GetCurItem() const
const SfxPoolItem * NextItem()
const WhichRangesContainer & GetRanges() const
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) 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
void SetHeight(tools::Long n)
class for the positioning of drawing objects
wrapper class for the positioning of Writer fly frames and drawing objects
virtual SwRect GetObjRect() const =0
void UpdateObjInSortedList()
method to update anchored object in the <SwSortedObjs> lists
SwAttrPool * GetPool() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
bool SetFrameFormatToFly(SwFrameFormat &rFlyFormat, SwFrameFormat &rNewFormat, SfxItemSet *pSet=nullptr, bool bKeepOrient=false)
void SetFlyFrameTitle(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewTitle)
SwChainRet Chainable(const SwFrameFormat &rSource, const SwFrameFormat &rDest)
IDocumentState const & getIDocumentState() const
void SetFlyFrameDecorative(SwFlyFrameFormat &rFlyFrameFormat, bool isDecorative)
SwChainRet Chain(SwFrameFormat &rSource, const SwFrameFormat &rDest)
void SetFlyFrameDescription(SwFlyFrameFormat &rFlyFrameFormat, const OUString &sNewDescription)
SwFrameFormat * GetFlyNum(size_t nIdx, FlyCntType eType, bool bIgnoreTextBoxes=false)
void Unchain(SwFrameFormat &rFormat)
void CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet &rSet)
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history.
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
IDocumentUndoRedo & GetIDocumentUndoRedo()
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Access to frames.
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
static void GetGrfNms(const SwFlyFrameFormat &rFormat, OUString *pGrfName, OUString *pFltName)
bool ChgAnchor(const SdrMarkList &_rMrkList, RndStdIds _eAnchorType, const bool _bSameOnly, const bool _bPosCorr)
const SwAttrPool & GetAttrPool() const
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
const sw::FrameFormats< sw::SpzFrameFormat * > * GetSpzFrameFormats() const
sal_Int8 SetFlyFrameAnchor(SwFrameFormat &rFlyFormat, SfxItemSet &rSet, bool bNewFrames)
new class for re-direct methods calls at a 'virtual' drawing object to its referenced object.
bool IsConnected() const
is 'virtual' drawing object connected to writer layout and / to drawing layer.
general base class for all free-flowing frames
Content, content of frame (header, footer, fly).
const SwNodeIndex * GetContentIdx() const
const SwRect & getFrameArea() const
Base class of the Writer layout elements.
SwFlyFrame * FindFlyFrame()
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
bool IsRightToLeft() const
bool IsLinkedFile() const
bool GetFileFilterNms(OUString *pFileNm, OUString *pFilterNm) const
const SwFrame * Lower() const
const SwContentNode * GetNode() const
Marks a node in the document model.
const SwNodes & GetNodes() const
SwNodeOffset GetIndex() const
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
SwNodeOffset GetIndex() const
const SwStartNode * FindFooterStartNode() const
bool IsNoTextNode() const
const SwStartNode * FindHeaderStartNode() const
const SwStartNode * FindFlyStartNode() const
SwNodeOffset EndOfSectionIndex() const
SwContentNode * GetContentNode()
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
A page of the document layout.
Of course Writer needs its own rectangles.
void Height(tools::Long nNew)
void Bottom(const tools::Long nBottom)
void Pos(const Point &rNew)
bool Contains(const Point &rPOINT) const
tools::Rectangle SVRect() const
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Starts a section of nodes in the document model.
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const SwFormatFlyCnt & GetFlyCnt() const
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 synchronizeGroupTextBoxProperty(bool pFunc(SwFrameFormat *, SdrObject *), SwFrameFormat *pFormat, SdrObject *pObj)
Calls the method given by pFunc with every textboxes of the group given by pFormat.
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.
SwPosition MapViewToModelPos(TextFrameIndex nIndex) const
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!...
const OUString & GetText() const
Returns the text portion we want to edit (for inline see underneath)
SwTextNode const * GetTextNodeForParaProps() const
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)
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
const OUString & GetText() const
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...
@ SetOnlyText
stay with the cursor inside text
virtual SotClipboardFormatId GetFormat(const TransferableDataHelper &aHelper) override
static Point lcl_FindAnchorLayPos(SwDoc &rDoc, const SwFormatAnchor &rAnch, const SwFrameFormat *pFlyFormat)
static bool lcl_SetFlyFrameAttr(SwDoc &rDoc, sal_Int8(SwDoc::*pSetFlyFrameAnchor)(SwFrameFormat &, SfxItemSet &, bool), SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
@ NOT_EMPTY
Only empty frames may be connected.
@ IS_IN_CHAIN
Destination already in chain.
@ SOURCE_CHAINED
Source already has a follow.
@ NOT_FOUND
Destination and/or source not found.
@ SELF
Self-chaining is not allowed.
@ WRONG_AREA
Destination in section where it shouldn't be (header, footer).
const SwContentFrame * FindAnchor(const SwFrame *pOldAnch, const Point &rNew, const bool bBody=false)
search an anchor for paragraph bound frames starting from pOldAnch
@ Fixed
Frame cannot be moved in Var-direction.
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
constexpr TypedWhichId< SwFormatCol > RES_COL(115)
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(109)
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(108)
constexpr TypedWhichId< SwFormatEditInReadonly > RES_EDIT_IN_READONLY(118)
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(111)
constexpr TypedWhichId< SwFormatFillOrder > RES_FILL_ORDER(RES_FRMATR_BEGIN)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(162)
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(103)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SwFormatAnchor > RES_ANCHOR(110)
constexpr TypedWhichId< SfxBoolItem > RES_DECORATIVE(140)
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(100)
constexpr TypedWhichId< SwFormatChain > RES_CHAIN(120)
constexpr TypedWhichId< SwFormatSurround > RES_SURROUND(107)
constexpr TypedWhichId< SwFormatContent > RES_CNTNT(101)
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(97)
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(98)
constexpr TypedWhichId< SvxPrintItem > RES_PRINT(104)
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 >)
#define SAL_INFO(area, stream)
bool GetAtPageRelOrientation(sal_Int16 &rOrientation, bool const isIgnorePrintArea)
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
bool IsInvalidItem(const SfxPoolItem *pItem)
Marks a position in the document model.
sal_Int32 GetContentIndex() const
constexpr TypedWhichId< XLineDashItem > XATTR_LINEDASH(XATTR_LINE_FIRST+1)
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
constexpr TypedWhichId< XFillHatchItem > XATTR_FILLHATCH(XATTR_FILL_FIRST+3)
constexpr TypedWhichId< XFillBitmapItem > XATTR_FILLBITMAP(XATTR_FILL_FIRST+4)
constexpr TypedWhichId< XFillFloatTransparenceItem > XATTR_FILLFLOATTRANSPARENCE(XATTR_FILL_FIRST+11)
constexpr TypedWhichId< XFillGradientItem > XATTR_FILLGRADIENT(XATTR_FILL_FIRST+2)