20 #include <config_feature_desktop.h>
31 #include <viewimp.hxx>
49 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
52 #include <boost/property_tree/json_parser.hpp>
54 #include <osl/diagnose.h>
77 : m_pCursorShell( pCShell )
121 OString buildHyperlinkJSON(
const OUString& sText,
const OUString& sLink)
123 boost::property_tree::ptree aTree;
124 aTree.put(
"text", sText);
125 aTree.put(
"link", sLink);
126 std::stringstream aStream;
127 boost::property_tree::write_json(aStream, aTree,
false);
146 aRect.
Pos().setY(aRect.
Pos().getY() + aRect.
Width());
175 CursorDirection::RTL :
176 CursorDirection::LTR );
184 Size aSize( nSize, nSize );
210 bool bPostItActive =
false;
215 bPostItActive = pPostItMgr->GetActiveSidebarWin() !=
nullptr;
221 sal_uInt16 nPage, nVirtPage;
228 OString aPayload = OString::number(nPage - 1);
245 LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
275 assert(nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
284 if(nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR)
288 bool bIsWrong =
false;
304 sal_Int32 nBegin = aPos.nContent.
GetIndex();
320 if (const_cast<SwCursorShell*>(
m_pCursorShell)->GetContentAtPos(aRect.
Pos(), aContentAtPos))
323 sHyperlink = buildHyperlinkJSON(aContentAtPos.
sStr, pItem->
GetValue());
325 else if (bIsSelection)
354 : m_pCursorShell( &rCSh )
355 #
if HAVE_FEATURE_DESKTOP
356 , m_bShowTextInputFieldOverlay(true)
357 , m_bShowContentControlOverlay(true)
370 SwRects::swap(rSwap);
372 #if HAVE_FEATURE_DESKTOP
374 std::swap(m_pCursorOverlay, rSwap.m_pCursorOverlay);
384 #if HAVE_FEATURE_DESKTOP
385 m_pCursorOverlay.reset();
404 std::pair<Point, bool>
const tmp(rPoint,
true);
431 #if HAVE_FEATURE_DESKTOP
433 std::vector< basegfx::B2DRange > aNewRanges;
434 aNewRanges.reserve(
size());
435 for(size_type
a = 0;
a <
size(); ++
a)
437 const SwRect aNextRect((*
this)[
a]);
440 aNewRanges.emplace_back(
441 aPntRect.Left(), aPntRect.Top(),
442 aPntRect.Right() + 1, aPntRect.Bottom() + 1);
445 if (m_pCursorOverlay)
447 if(!aNewRanges.empty())
453 m_pCursorOverlay.reset();
461 if (xTargetOverlay.is())
470 std::move(aNewRanges),
473 xTargetOverlay->add(*m_pCursorOverlay);
489 if (!empty() && !pSelectionRectangles)
501 std::vector<OString> aRect;
502 aRect.reserve(size());
503 for (size_type
i = 0;
i < size(); ++
i)
505 const SwRect& rRect = (*this)[
i];
509 if (!pSelectionRectangles)
515 pSelectionRectangles->push_back(sRect);
522 case LOK_CALLBACK_TEXT_SELECTION_START:
523 case LOK_CALLBACK_TEXT_SELECTION_END:
541 if( nType == LOK_CALLBACK_TEXT_SELECTION_START )
557 case LOK_CALLBACK_TEXT_SELECTION:
558 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
560 std::vector<OString> aRect;
561 aRect.reserve(
size());
562 for (size_type
i = 0;
i <
size(); ++
i)
564 const SwRect& rRect = (*this)[
i];
568 if( nType == LOK_CALLBACK_TEXT_SELECTION )
580 std::vector< basegfx::B2DRange > aInputFieldRanges;
586 if ( pCurTextInputFieldAtCursor !=
nullptr )
589 std::unique_ptr<SwShellCursor> pCursorForInputTextField(
591 pCursorForInputTextField->SetMark();
592 pCursorForInputTextField->GetMark()->nNode = *pTextNode;
593 pCursorForInputTextField->GetMark()->nContent.Assign( pTextNode, *(pCurTextInputFieldAtCursor->
End()) );
595 pCursorForInputTextField->FillRects();
596 SwRects* pRects = pCursorForInputTextField.get();
597 for (
const SwRect & rNextRect : *pRects)
601 aInputFieldRanges.emplace_back(
602 aPntRect.Left(), aPntRect.Top(),
603 aPntRect.Right() + 1, aPntRect.Bottom() + 1);
608 if ( !aInputFieldRanges.empty() )
620 if (xTargetOverlay.is())
627 aHighlight, std::move(aInputFieldRanges) ) );
640 std::vector<basegfx::B2DRange> aContentControlRanges;
641 std::vector<OString> aLOKRectangles;
642 SwRect aLastPortionPaintArea;
643 std::shared_ptr<SwContentControl> pContentControl;
661 if (pCurContentControlAtCursor)
663 auto pCursorForContentControl = std::make_unique<SwShellCursor>(
665 pCursorForContentControl->SetMark();
666 pCursorForContentControl->GetMark()->nNode = *pTextNode;
667 pCursorForContentControl->GetMark()->nContent.Assign(
668 pTextNode, *(pCurContentControlAtCursor->
End()));
670 pCursorForContentControl->FillRects();
671 SwRects* pRects = pCursorForContentControl.get();
672 for (
const auto& rRect : *pRects)
676 aContentControlRanges.emplace_back(aRect.Left(), aRect.Top(), aRect.Right() + 1,
680 aLOKRectangles.push_back(aRect.toString());
684 if (!pRects->empty())
686 aLastPortionPaintArea = (*pRects)[pRects->size() - 1];
692 if (!aContentControlRanges.empty())
698 aJson.
put(
"action",
"show");
699 aJson.
put(
"rectangles", aPayload);
701 if (pContentControl && pContentControl->HasListItems())
704 for (
const auto& rItem : pContentControl->GetListItems())
710 std::unique_ptr<char, o3tl::free_delete> pJson(aJson.
extractData());
724 if (xTargetOverlay.is())
731 aHighlight, std::move(aContentControlRanges)));
736 if (pContentControl && pContentControl->HasListItems())
741 auto& rEditWin =
const_cast<SwEditWin&
>(pWrtShell->GetView().GetEditWin());
750 &rEditWin, pContentControl);
762 aJson.
put(
"action",
"hide");
763 std::unique_ptr<char, o3tl::free_delete> pJson(aJson.
extractData());
777 size_type nSz =
size();
785 SwRects::insert(
begin(), aReg.begin(), aReg.end() );
791 if( !(
GetShell()->m_bVisPortChgd && 0 != ( nSz =
size())) )
795 iterator it =
begin();
837 , m_pInitialPoint(
SwPaM::GetPoint())
849 , m_pInitialPoint(
SwPaM::GetPoint())
855 , m_MarkPt(rICursor.GetMkPos())
856 , m_PointPt(rICursor.GetPtPos())
857 , m_pInitialPoint(
SwPaM::GetPoint())
881 GetPoint()->nNode.GetNode().IsContentNode() &&
891 std::vector<OString> aSelectionRectangles;
896 pShCursor->SwSelPaintRects::Show(&aSelectionRectangles);
902 std::vector<OString> aRect;
903 for (
const OString & rSelectionRectangle : aSelectionRectangles)
905 if (rSelectionRectangle.isEmpty())
907 aRect.push_back(rSelectionRectangle);
913 if (pViewShell !=
GetShell()->GetSfxViewShell())
933 pShCursor->SwSelPaintRects::Invalidate(rRect);
943 pShCursor->SwSelPaintRects::Hide();
960 std::vector<sal_uInt16> vActionCounts;
963 sal_uInt16 nActCnt = 0;
964 while(rShell.ActionPend())
969 vActionCounts.push_back(nActCnt);
971 std::unique_ptr<weld::Builder> xBuilder(
Application::CreateBuilder(pDlg->getDialog(),
"modules/swriter/ui/asksearchdialog.ui"));
972 std::unique_ptr<weld::MessageDialog> xDialog(xBuilder->weld_message_dialog(
"AskSearchDialog"));
973 nRet = xDialog->run();
974 auto pActionCount = vActionCounts.begin();
979 rShell.StartAction();
1008 GetShell()->GetViewOptions()->IsReadonly() ||
1009 (
GetShell()->Imp()->GetDrawView() &&
1010 GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
1023 const SwPosition& rMkPos,
const Point& rMkPt,
1024 const SwPosition& rPtPos,
const Point& rPtPt )
1060 ?
GetShell()->getIDocumentLayoutAccess().GetCurrentLayout()->getFrameArea()
1076 while ( pSelTableNd != pCurTableNd && pCurTableNd )
1086 std::pair<Point, bool>
const tmp(
GetSttPos(),
false);
1091 OSL_ENSURE( pFrame,
"Node not in a table" );
1112 insert(
begin(), aReg.begin(), aReg.end() );
1136 std::pair<Point, bool>
const tmp(
GetPtPos(),
true);
1140 OSL_ENSURE( pFrame,
"Node not in a table" );
1144 for (
SwCellFrame* pCellFrame = static_cast<SwCellFrame*>(pFrame); pCellFrame; pCellFrame = pCellFrame->
GetFollowCell() )
1146 if( pCellFrame->getFrameArea().Contains( rPt ) )
vcl::RenderContext * GetOut() const
static SwRect lcl_getLayoutRect(const Point &rPoint, const SwPosition &rPosition)
Return a layout rectangle (typically with minimal width) that represents a cursor at rPosition...
const Fraction & GetScaleX() const
virtual short MaxReplaceArived() override
Starts a section of nodes in the document model.
Base class of the Writer layout elements.
Represents the visualization of a paragraph.
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
void Right(const tools::Long nRight)
SwNodeOffset EndOfSectionIndex() const
Marks a position in the document model.
const SwRect & GetOrigin() const
const SwPosition * m_pInitialPoint
void SetOrientation(Degree10 nOrientation=0_deg10)
void SwCalcPixStatics(vcl::RenderContext const *pOut)
Set borders alignment statics Adjustment for 'small' twip-to-pixel relations: For 'small' twip-to-pix...
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
void SetPos(const Point &rNewPos)
void CalcPosAndSize(const SwRect &rPortionPaintArea)
virtual const SwRootFrame * GetCurrentLayout() const =0
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
SwDocShell * GetDocShell()
std::shared_ptr< SwContentControl > GetContentControl()
void Left(const tools::Long nLeft)
static void notifyUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
sal_uInt16 GetStyle() const
SdrTextObj * GetTextEditObject() const
virtual void SaveTableBoxContent(const SwPosition *pPos) override
const StyleSettings & GetStyleSettings() const
const SfxPoolItem * pAttr
const SwPosition * GetMark() const
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
static SvxSearchDialog * GetSearchDialog()
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
sal_uInt8 GetCursorBidiLevel() const
void HighlightContentControl()
const Point & GetSttPos() const
const MapMode & GetMapMode() const
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
SwTextNode * GetpTextNode() const
void Pos(const Point &rNew)
VclPtr< SwContentControlButton > m_pContentControlButton
Of course Writer needs its own rectangles.
SfxViewShell * GetSfxViewShell() const
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, enum GetTextAttrMode const eMode=DEFAULT) const
get the innermost text attribute covering position nIndex.
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
virtual void SaveTableBoxContent(const SwPosition *pPos) override
SwWrtShell & GetWrtShell() const
void Invalidate(const SwRect &rRect)
bool m_bShowTextInputFieldOverlay
Used by the UI to modify the document model.
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pContentControlOverlay
constexpr tools::Long Width() const
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
enumrange< T >::Iterator begin(enumrange< T >)
const SwRect & getFrameArea() const
OString join(std::string_view rSeparator, const std::vector< OString > &rSequence)
const Fraction & GetScaleY() const
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
void CalcFrameRects(SwShellCursor &)
static SfxViewShell * Current()
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
sal_Int32 GetStart() const
void Invert()
invert current rectangle
virtual void FillRects() override
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
void Width(tools::Long nNew)
OString getLOKPayload(int nType, int nViewId, bool *ignore) const
Point m_aOldRBPos
Right/Bottom of last VisArea.
union SwContentAtPos::@24 aFnd
virtual void FillRects() override
SwNodeOffset GetIndex() const
void SetStyle(sal_uInt16 nStyle)
virtual short MaxReplaceArived() override
void Show(SfxViewShell const *pViewShell)
void Invalidate(const SwRect &rRect)
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const =0
Fill rStart and rEnd with a rectangle that represents the start and end for selection handles...
SwLayoutFrame * GetNextCellLeaf()
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
SfxItemPool & GetPool() const
sal_uInt32 PaintWindowCount() const
SwShellCursor * GetCursor_()
static MapMode * s_pMapMode
SwVisibleCursor(const SwCursorShell *pCShell)
bool IsContentNode() const
PaM is Point and Mark: a selection of the document model.
bool m_bShowContentControlOverlay
virtual ~SwShellTableCursor() override
const SwCursorShell * m_pCursorShell
const SwCursorShell * GetShell() const
SwShellCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
void SetPosAndShow(SfxViewShell const *pViewShell)
void DecreaseLuminance(sal_uInt8 cLumDec)
const SwRect & VisArea() const
const SwPosition * GetPoint() const
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
bool UpDown(bool bUp, sal_uInt16 nCnt)
void AddBottom(const tools::Long nAdd)
bool Contains(const Point &rPt) const
const SwFormatContentControl & GetContentControl() const
SwContentNode * GetContentNode()
SwNodeOffset GetIndex() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
SwLayoutFrame * GetUpper()
virtual ~SwShellCursor() override
void SetWindow(vcl::Window *pWindow)
SwGrammarMarkUp * GetGrammarCheck()
void HighlightInputField()
static void notifyOtherViewsUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
bool IsCursorReadonly() const
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
const Point & GetMkPos() const
Marks a node in the document model.
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
void SetSize(const Size &rNewSize)
T static_txtattr_cast(S *s)
const AllSettings & GetSettings() const
bool IsOverwriteCursor() const
ring_container GetRingContainer()
MapUnit GetMapUnit() const
bool IsOnlineSpell() const
void AddRight(const tools::Long nAdd)
void SSize(const Size &rNew)
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
SwCellFrame * GetFollowCell() const
stay with the cursor inside text
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
enumrange< T >::Iterator end(enumrange< T >)
const SwPosition * Start() const
EXPAND : (Start < nIndex <= End)
bool Contains(const Point &rPOINT) const
bool IsInProtectSect() const
Is node in a protected area?
OString getLOKPayload(int nType, int nViewId, bool *ignore) const
SwSelPaintRects(const SwCursorShell &rCSh)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
virtual ~SwSelPaintRects()
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
virtual void FillRects()=0
void Bottom(const tools::Long nBottom)
SwTextNode is a paragraph in the document model.
SwSelBoxes m_SelectedBoxes
std::vector< SwRect > SwRects
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
bool IsReadOnlyAvailable() const
SwWrtShell * GetWrtShellPtr() const
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
tools::Rectangle SVRect() const
Point m_aCursorHeight
height & offset from visible Cursor
constexpr tools::Long Height() const
const SwViewOption * GetViewOptions() const
void SetCursor(vcl::Cursor *pCursor)
vcl::Window * GetWin() const
vcl::Cursor m_aTextCursor
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
OUString GetSelText() const
get selected text of a node at current cursor
sal_Int32 GetCursorSize() const
size_t CountDirChg() const
sal_Int32 GetIndex() const
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
::OutputDevice const * GetOutDev() const
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
std::u16string_view trim(std::u16string_view str)
static tools::Long s_nPixPtY
static VclPtr< reference_type > Create(Arg &&...arg)
const SwPosition * End() const
bool IsRightToLeft() const
void Top(const tools::Long nTop)
SwPostItMgr * GetPostItMgr()
const sal_Int32 * End() const
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
const Point & GetPtPos() const
static tools::Long s_nPixPtX
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
static OString makeVisCursorInvalidation(int nViewId, const OString &rRectangle, bool bMispelledWord=false, const OString &rHyperlink="")
SwTableNode * FindTableNode()
Search table node, in which it is.
virtual bool IsAtValidPos(bool bPoint=true) const
Return if cursor can be set to this position.
static void notifyUpdate(SfxViewShell const *pViewShell, int nType)
const std::shared_ptr< SwContentControl > & GetContentControl() const
const Point & GetEndPos() const
static OString makePayloadJSON(const SfxViewShell *pThisView, int nViewId, std::string_view rKey, const OString &rPayload)
SwRect m_aStart
Left edge of the selection start (top left cell).
SwContentNode * GoNextSection(SwNodeIndex *, bool bSkipHidden=true, bool bSkipProtect=true) const
Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!).
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
const SwCursorShell * m_pCursorShell
virtual bool IsReadOnlyAvailable() const override
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
const vcl::Cursor & GetTextCursor() const
SwRootFrame * GetLayout() const
void swapContent(SwSelPaintRects &rSwap)
void SetDirection(CursorDirection nDirection=CursorDirection::NONE)
void Height(tools::Long nNew)
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
bool Overlaps(const SwRect &rRect) const
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
void SetWidth(tools::Long nNewWidth)
SwCellFrame is one table cell in the document layout.
static void notifyOtherView(const SfxViewShell *pThisView, SfxViewShell const *pOtherView, int nType, std::string_view rKey, const OString &rPayload)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool IsSelectionInReadonly() const
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, const bool bIncludeInputFieldAtStart)
Base class of the Writer document model elements.