24#include <osl/diagnose.h>
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;
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)
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:
230 std::pair<Point, bool>
const tmp(aRet,
false);
237 case RndStdIds::FLY_AT_FLY:
248 case RndStdIds::FLY_AT_PAGE:
252 for( sal_uInt16
i = 1; (
i <=
nPgNum) && pPage; ++
i,
268#define IGNOREANCHOR 1
269#define DONTMAKEFRMS 2
283 if( !aNewAnch.
GetAnchorNode() && (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." );
331 case RndStdIds::FLY_AS_CHAR:
337 OSL_ENSURE( pNd,
"Cursor does not point to TextNode." );
349 case text::VertOrientation::LINE_TOP: aOldV.
SetVertOrient( text::VertOrientation::TOP );
break;
350 case text::VertOrientation::LINE_CENTER: aOldV.
SetVertOrient( text::VertOrientation::CENTER);
break;
351 case text::VertOrientation::LINE_BOTTOM: aOldV.
SetVertOrient( text::VertOrientation::BOTTOM);
break;
361 case RndStdIds::FLY_AT_PARA:
362 case RndStdIds::FLY_AT_CHAR:
363 case RndStdIds::FLY_AT_FLY:
364 case RndStdIds::FLY_AT_PAGE:
373 bool bPutOldH(
false);
380 nPos += aOldAnchorPos.getX() - aNewAnchorPos.getX();
388 if (nNew == RndStdIds::FLY_AT_PAGE)
390 sal_Int16 nRelOrient(pHoriOrientItem
395 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
413 nPos += aOldAnchorPos.getY() - aNewAnchorPos.getY();
447 ? (rDoc.*pSetFlyFrameAnchor)( rFlyFormat,
rSet, false )
455 switch(pItemIter->
Which())
462 OSL_FAIL(
"Unknown Fly attribute." );
474 *pItem != *pItemIter))
475 aTmpSet.
Put(*pItemIter);
481 }
while (pItemIter && (0 != pItemIter->
Which()));
483 if( aTmpSet.
Count() )
501 std::unique_ptr<SfxPoolItem> pResult;
503 switch(pItem->Which())
507 pResult = pItem->StaticWhichCast(
XATTR_FILLBITMAP).checkForUniqueItem(pDrawModel);
512 pResult = pItem->StaticWhichCast(
XATTR_LINEDASH).checkForUniqueItem(pDrawModel);
517 pResult = pItem->StaticWhichCast(
XATTR_LINESTART).checkForUniqueItem(pDrawModel);
522 pResult = pItem->StaticWhichCast(
XATTR_LINEEND).checkForUniqueItem(pDrawModel);
537 pResult = pItem->StaticWhichCast(
XATTR_FILLHATCH).checkForUniqueItem(pDrawModel);
565 const OUString& sNewTitle )
588 const OUString& sNewDescription )
613 bool bChgAnchor =
false, bFrameSz =
false;
661 aFlySet.
Put( *pFormatAnchor );
708 const bool _bSameOnly,
709 const bool _bPosCorr )
721 bool bUnmark =
false;
735#if OSL_DEBUG_LEVEL > 0
737 bool bNoUserCallExcepted = pSwDrawVirtObj && !pSwDrawVirtObj->
IsConnected();
738 OSL_ENSURE( bNoUserCallExcepted,
"SwDoc::ChgAnchor(..) - no contact at selected drawing object" );
745 const SwFrame* pNewAnchorFrame = pOldAnchorFrame;
752 std::optional<SwPosition> oOldAsCharAnchorPos;
754 if ( !_bSameOnly && eOldAnchorType == RndStdIds::FLY_AS_CHAR )
760 _eAnchorType = eOldAnchorType;
767 switch ( _eAnchorType )
769 case RndStdIds::FLY_AT_PARA:
770 case RndStdIds::FLY_AT_CHAR:
778 pNewAnchorFrame =
::FindAnchor( pOldAnchorFrame, aNewPoint );
781 pNewAnchorFrame =
static_cast<const SwTextFrame*
>(pNewAnchorFrame)->FindMaster();
785 pNewAnchorFrame =
nullptr;
793 aNewAnch.
SetType( _eAnchorType );
799 case RndStdIds::FLY_AT_FLY:
807 aPoint.setX(aPoint.getX() - 1);
811 std::pair<Point, bool>
const tmp(aPt,
false);
819 if( pNewAnchorFrame && !pNewAnchorFrame->
IsProtected() )
828 aNewAnch.
SetType( RndStdIds::FLY_AT_PAGE );
831 case RndStdIds::FLY_AT_PAGE:
835 pNewAnchorFrame = pNewAnchorFrame->
GetNext();
836 if ( !pNewAnchorFrame )
842 case RndStdIds::FLY_AS_CHAR:
845 if( !pOldAnchorFrame )
858 pNewAnchorFrame =
nullptr;
862 bUnmark = ( 0 !=
i );
864 aPoint.setX(aPoint.getX() - 1);
865 aNewAnch.
SetType( RndStdIds::FLY_AS_CHAR );
895 OSL_ENSURE( pNd,
"Cursor not positioned at TextNode." );
909 OSL_ENSURE(
false,
"unexpected AnchorId." );
912 if ( (RndStdIds::FLY_AS_CHAR != _eAnchorType) &&
914 ( !_bSameOnly || pNewAnchorFrame != pOldAnchorFrame ) )
924 if ( pSwDrawVirtObj && !pSwDrawVirtObj->IsConnected() )
926 SwRect aNewObjRect( aObjRect );
928 ->AdjustPositioningAttr( pNewAnchorFrame,
934 ->AdjustPositioningAttr( pNewAnchorFrame );
937 if (aNewAnch.
GetAnchorId() == RndStdIds::FLY_AT_PAGE)
943 SAL_INFO(
"sw.ui",
"fixing horizontal RelOrientation for at-page anchor");
958 if (oOldAsCharAnchorPos)
960 if ( pNewAnchorFrame)
966 const sal_Int32 nIndx( oOldAsCharAnchorPos->GetContentIndex() );
967 SwTextNode* pTextNode( oOldAsCharAnchorPos->GetNode().GetTextNode() );
968 assert(pTextNode &&
"<SwDoc::ChgAnchor(..)> - missing previous anchor text node for as-character anchored object");
971 assert(pHint &&
"Missing FlyInCnt-Hint.");
997 if( pFormat == &rSource )
1000 }
while ( pFormat );
1023 pTextNd->
GetText().getLength() )
1032 if ( (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_PARA) &&
1033 (rAnchor.
GetAnchorId() != RndStdIds::FLY_AT_CHAR) )
1038 if( nFlySttNd <= nTstSttNd && nTstSttNd < nFlySttNd +
SwNodeOffset(2) )
1053 bool bAllowed =
false;
1054 if ( RndStdIds::FLY_AT_PAGE == rSrcAnchor.
GetAnchorId() )
1056 if ( (RndStdIds::FLY_AT_PAGE == rDstAnchor.GetAnchorId()) ||
1057 ( rDstAnchor.GetAnchorNode() &&
1058 rDstAnchor.GetAnchorNode()->GetIndex() > nEndOfExtras ))
1061 else if( rSrcAnchor.
GetAnchorNode() && rDstAnchor.GetAnchorNode() )
1064 &rDstNd = *rDstAnchor.GetAnchorNode();
1066 if( rSrcNd == rDstNd ||
1076 ( !pSttNd && rDstNd.
GetIndex() > nEndOfExtras &&
1077 rSrcNd.
GetIndex() > nEndOfExtras ))
1096 SetAttr( aChain, rDestFormat );
1103 SetAttr( aChain, rDestFormat );
1108 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.
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
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
const SwFrameFormats * GetSpzFrameFormats() const
bool SetFlyFrameAttr(SwFrameFormat &rFlyFormat, SfxItemSet &rSet)
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< 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)