21 #include <editeng/editeng.hxx>
27 #include <osl/diagnose.h>
32 #include <viewimp.hxx>
34 #include <docfunc.hxx>
41 #include <drawdoc.hxx>
69 OSL_ENSURE( pContact,
"<lcl_AdjustPositioningAttr(..)> - missing contact object." );
76 OSL_ENSURE( !pAnchorFrame ||
78 !
static_cast<const SwTextFrame*
>(pAnchorFrame)->IsFollow(),
79 "<lcl_AdjustPositioningAttr(..)> - anchor frame is a follow." );
99 switch ( rDirItem.GetValue() )
101 case SvxFrameDirection::Vertical_LR_TB:
106 OSL_FAIL(
"<lcl_AdjustPositioningAttr(..)> - vertical from left-to-right not supported." );
109 case SvxFrameDirection::Vertical_RL_TB:
116 case SvxFrameDirection::Horizontal_RL_TB:
123 case SvxFrameDirection::Horizontal_LR_TB:
130 case SvxFrameDirection::Environment:
131 SAL_WARN(
"sw.core",
"lcl_AdjustPositioningAttr(..) SvxFrameDirection::Environment not supported");
144 nHoriRelPos = aObjRect.
Left() - aAnchorPos.getX();
145 nVertRelPos = aObjRect.
Top() - aAnchorPos.getY();
148 nHoriRelPos = aObjRect.
Top() - aAnchorPos.getY();
149 nVertRelPos = aAnchorPos.getX() - aObjRect.
Right();
154 nHoriRelPos = aAnchorPos.getX() - aObjRect.
Right();
155 nVertRelPos = aObjRect.
Top() - aAnchorPos.getY();
159 nHoriRelPos = aObjRect.
Left() - aAnchorPos.getX();
160 nVertRelPos = aObjRect.
Top() - aAnchorPos.getY();
173 if (
auto pAnchoredDrawObj = dynamic_cast<const SwAnchoredDrawObject*>( pAnchoredObj) )
177 ->SetLastObjRect( aObjRect );
200 std::unique_ptr<SwUndoDrawGroup> pUndo;
205 bool bGroupMembersNotPositioned(
false );
212 std::map<const SdrObject*, SwFrameFormat*> vSavedTextBoxes;
220 #if OSL_DEBUG_LEVEL > 0
223 OSL_ENSURE( bGroupMembersNotPositioned == pAnchoredDrawObj->
NotYetPositioned(),
224 "<SwDoc::GroupSelection(..)> - group members have different positioning status!" );
227 if (
auto pShapeFormat = pContact->
GetFormat())
228 if (
auto pTextBoxNode = pShapeFormat->GetOtherTextBoxFormats())
229 for (
const auto& rTextBoxElement : pTextBoxNode->GetAllTextBoxes())
230 vSavedTextBoxes.emplace(rTextBoxElement);
238 pUndo->AddObj(
i, pFormat, pObj );
247 pObj->
NbcMove(
Size( aAnchorPos.getX(), aAnchorPos.getY() ) );
255 text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
258 auto pTextBoxNode = std::make_shared<SwTextBoxNode>(
260 for (
const auto& pTextBoxEntry : vSavedTextBoxes)
262 pTextBoxNode->AddTextBox(const_cast<SdrObject*>(pTextBoxEntry.first),
263 pTextBoxEntry.second);
264 pTextBoxEntry.second->SetOtherTextBoxFormats(pTextBoxNode);
267 vSavedTextBoxes.clear();
270 OSL_ENSURE( rMrkList.
GetMarkCount() == 1,
"GroupMarked more or none groups." );
280 if ( !bGroupMembersNotPositioned )
288 pUndo->SetGroupFormat( pFormat );
300 OSL_ENSURE( rMrkList.
GetMarkCount() == 1,
"GroupMarked more or none groups." );
310 for (
size_t i = 0;
i < pChildrenObjs->GetObjCount(); ++
i)
314 if (
auto pTextBox = pTextBoxNode->GetTextBox(pSourceObjs))
340 std::unique_ptr<std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >[]> pFormatsAndObjs;
344 pFormatsAndObjs.reset(
new std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > >[nMarkCount] );
348 for (
size_t i = 0;
i < nMarkCount; ++
i )
351 if (
auto pObjGroup = dynamic_cast<SdrObjGroup*>(pObj) )
355 std::shared_ptr<SwTextBoxNode> pTextBoxNode;
356 if (
auto pGroupFormat = pContact->
GetFormat())
357 pTextBoxNode = pGroupFormat->GetOtherTextBoxFormats();
369 for (
size_t i2 = 0; i2 < pLst->GetObjCount(); ++i2 )
380 if (
auto pTextBoxFormat = pTextBoxNode->GetTextBox(pSubObj))
382 auto pNewTextBoxNode =std::make_shared<SwTextBoxNode>(
SwTextBoxNode(pFormat));
383 pNewTextBoxNode->AddTextBox(pSubObj, pTextBoxFormat);
385 pTextBoxFormat->SetOtherTextBoxFormats(pNewTextBoxNode);
395 text::PositionLayoutDir::PositionInLayoutDirOfAnchor );
396 if (pSubObj->
GetName().isEmpty())
398 pFormatsAndObjs[
i].emplace_back( pFormat, pSubObj );
401 pUndo->
AddObj( o3tl::narrowing<sal_uInt16>(i2), pFormat );
410 for (
size_t i = 0;
i < nMarkCount; ++
i )
419 while ( !pFormatsAndObjs[
i].empty() )
422 SdrObject* pObj( pFormatsAndObjs[
i].back().second );
423 pFormatsAndObjs[
i].pop_back();
440 bool bCallBase =
false;
445 bool bDelMarked =
true;
450 if(
auto pDrawObj = dynamic_cast<SwVirtFlyDrawObj*>( pObj) )
464 if( dynamic_cast<const SwVirtFlyDrawObj*>( pObj) ==
nullptr )
483 std::unique_ptr<SwUndoDrawDelete> pUndo;
500 if ( dynamic_cast<const SwDrawVirtObj*>( pObj) != nullptr )
502 OSL_FAIL(
"<SwDrawVirtObj> is still marked for delete. application will crash!" );
509 pUndo->AddObj( pFormat, rMark );
531 : m_pFormat(pFrameFormat)
533 , m_nOrdNum(nArrOrdNum)
554 if (
auto pDateField = dynamic_cast<const SvxDateField*>( pField))
557 pInfo->SetRepresentation(
558 pDateField->GetFormatted(
561 else if (
auto pURLField = dynamic_cast<const SvxURLField*>( pField))
564 switch ( pURLField->GetFormat() )
566 case SvxURLFormat::AppDefault:
567 case SvxURLFormat::Repr:
568 pInfo->SetRepresentation(pURLField->GetRepresentation());
571 case SvxURLFormat::Url:
572 pInfo->SetRepresentation(pURLField->GetURL());
576 sal_uInt16 nChrFormat;
578 if (IsVisitedURL(pURLField->GetURL()))
583 SwFormat *pFormat = getIDocumentStylePoolAccess().GetCharFormatFromPool(nChrFormat);
589 pInfo->SetTextColor(aColor);
591 else if (dynamic_cast<const SdrMeasureField*>( pField))
594 pInfo->SetFieldColor(std::optional<Color>());
596 else if (
auto pTimeField = dynamic_cast<const SvxExtTimeField*>( pField) )
599 pInfo->SetRepresentation(
604 OSL_FAIL(
"unknown field command");
605 pInfo->SetRepresentation( OUString(
'?' ) );
614 bool bExistsDrawObjs(
false );
625 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
628 bExistsDrawObjs =
true;
634 return bExistsDrawObjs;
639 bool bAllDrawObjsOnPage(
true );
650 if ( !dynamic_cast<SwVirtFlyDrawObj*>(pObj) &&
662 if ( !pAnchoredDrawObj )
664 OSL_FAIL(
"<docfunc::AllDrawObjsOnPage() - missing anchored draw object" );
665 bAllDrawObjsOnPage =
false;
674 bAllDrawObjsOnPage =
false;
679 bAllDrawObjsOnPage =
false;
688 bAllDrawObjsOnPage =
false;
695 return bAllDrawObjsOnPage;
#define LINK(Instance, Class, Member)
bool ExistsDrawObjs(SwDoc &p_rDoc)
method to check, if given Writer document contains at least one drawing object
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
static void lcl_AdjustPositioningAttr(SwDrawFrameFormat *_pFrameFormat, const SdrObject &_rSdrObj)
local method to determine positioning and alignment attributes for a drawing object, which is newly connected to the layout.
size_t GetMarkCount() const
class for the positioning of drawing objects
OUString GetUniqueDrawObjectName() const
const SwFrameFormat * m_pFormat
ZSortFly(const SwFrameFormat *pFrameFormat, const SwFormatAnchor *pFlyAnchor, sal_uInt32 nArrOrdNum)
void SetName(const OUString &rStr, const bool bSetChanged=true)
virtual SdrObjList * getChildrenOfSdrObject() const
virtual void SetModified()=0
Must be called manually at changes of format.
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
Textboxes are basically textframe + shape pairs.
void AddFormatAndObj(SwDrawFrameFormat *pDrawFrameFormat, SdrObject *pDrawObject)
void SetCalcFieldValueHdl(Outliner *pOutliner)
In the Outliner, set a link to the method for field display in edit objects.
bool DeleteSelection(SwDrawView &)
SdrMark * GetMark(size_t nNum) const
IDocumentUndoRedo & GetIDocumentUndoRedo()
SwDrawFrameFormat * MakeDrawFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom)
const SwViewShellImp & Imp() const
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
virtual const tools::Rectangle & GetSnapRect() const
wrapper class for the positioning of Writer fly frames and drawing objects
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
virtual void DelLayoutFormat(SwFrameFormat *pFormat)=0
virtual bool DoesUndo() const =0
Is Undo enabled?
SwAttrPool * GetPool() const
SwDrawContact * GroupSelection(SdrView &)
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.
const SdrMarkList & GetMarkedObjectList() const
const SdrPage * GetPage(sal_uInt16 nPgNum) const
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
void SetCalcFieldValueHdl(const Link< EditFieldInfo *, void > &rLink)
bool IsOutsidePage() const
void UnGroupSelection(SdrView &)
IDocumentState const & getIDocumentState() const
static void lcl_CollectTextBoxesForSubGroupObj(SwFrameFormat *pTargetFormat, std::shared_ptr< SwTextBoxNode > pTextBoxNode, SdrObject *pSourceObjs)
void SetUserCall(SdrObjUserCall *pUser)
const SfxPoolItem & GetDefaultItem(sal_uInt16 nWhich) const
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
OUString GetUniqueShapeName() const
const SwFrameFormat * GetDfltFrameFormat() const
virtual const tools::Rectangle & GetLastBoundRect() const
bool AllDrawObjsOnPage(SwDoc &p_rDoc)
method to check, if given Writer document contains only drawing objects, which are completely on its ...
static void ReplaceMarkedDrawVirtObjs(SdrMarkView &_rMarkView)
replace marked -objects by its reference object for delete marked objects.
void AddObj(sal_uInt16 nPos, SwDrawFrameFormat *)
#define SAL_WARN_IF(condition, area, stream)
virtual void NbcMove(const Size &rSiz)
bool NotYetPositioned() const
bool IsRightToLeft() const
const Point & GetAnchorPos() const
SdrObject * getParentSdrObjectFromSdrObject() const
virtual void CallSwClientNotify(const SfxHint &rHint) const override
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_LIGHTBLUE
void DelFrameFormat(SwFrameFormat *pFormat, bool bBroadcast=false)
#define SAL_WARN(area, stream)
virtual void NbcSetAnchorPos(const Point &rPnt)
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
const SwFrame * GetAnchorFrame() const
constexpr OUStringLiteral first
Point GetFrameAnchorPos(bool bIgnoreFlysAnchoredAtThisFrame) const
returns the position for anchors based on frame direction
SdrObjUserCall * GetUserCall() const
const OUString & GetName() const
IMPL_LINK(SwDoc, CalcFieldValueHdl, EditFieldInfo *, pInfo, void)
Recognise fields/URLs in the Outliner and set how they are displayed.
const Color & GetValue() const
SdrPageView * GetPageView()
const SvxFieldData * GetField() const