20#include <config_feature_desktop.h>
49#include <LibreOfficeKit/LibreOfficeKitEnums.h>
52#include <boost/property_tree/json_parser.hpp>
54#include <osl/diagnose.h>
79 : m_pCursorShell( pCShell )
123OString buildHyperlinkJSON(
const OUString& sText,
const OUString& sLink)
125 boost::property_tree::ptree aTree;
126 aTree.put(
"text", sText);
127 aTree.put(
"link", sLink);
128 std::stringstream aStream;
129 boost::property_tree::write_json(aStream, aTree,
false);
148 aRect.
Pos().setY(aRect.
Pos().getY() + aRect.
Width());
177 CursorDirection::RTL :
178 CursorDirection::LTR );
185 tools::Long nSize =
pOut->GetSettings().GetStyleSettings().GetCursorSize();
186 Size aSize( nSize, nSize );
187 aSize =
pOut->PixelToLogic( aSize );
212 bool bPostItActive =
false;
217 bPostItActive = pPostItMgr->GetActiveSidebarWin() !=
nullptr;
223 sal_uInt16 nPage, nVirtPage;
230 OString aPayload = OString::number(nPage - 1);
247 LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
277 assert(
nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR ||
nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
286 if(
nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR)
290 bool bIsWrong =
false;
325 sHyperlink = buildHyperlinkJSON(aContentAtPos.
sStr, pItem->
GetValue());
327 else if (bIsSelection)
356 : m_pCursorShell( &rCSh )
357#
if HAVE_FEATURE_DESKTOP
358 , m_bShowTextInputFieldOverlay(true)
359 , m_bShowContentControlOverlay(true)
372 SwRects::swap(rSwap);
374#if HAVE_FEATURE_DESKTOP
376 std::swap(m_pCursorOverlay, rSwap.m_pCursorOverlay);
386#if HAVE_FEATURE_DESKTOP
387 m_pCursorOverlay.reset();
406 std::pair<Point, bool>
const tmp(rPoint,
true);
433#if HAVE_FEATURE_DESKTOP
435 std::vector< basegfx::B2DRange > aNewRanges;
436 aNewRanges.reserve(
size());
437 for(size_type
a = 0;
a <
size(); ++
a)
439 const SwRect aNextRect((*
this)[
a]);
442 aNewRanges.emplace_back(
443 aPntRect.
Left(), aPntRect.
Top(),
447 if (m_pCursorOverlay)
449 if(!aNewRanges.empty())
455 m_pCursorOverlay.reset();
463 if (xTargetOverlay.is())
472 std::move(aNewRanges),
475 xTargetOverlay->add(*m_pCursorOverlay);
491 if (!empty() && !pSelectionRectangles)
503 std::vector<OString> aRect;
504 aRect.reserve(
size());
505 for (size_type
i = 0;
i <
size(); ++
i)
507 const SwRect& rRect = (*this)[
i];
511 if (!pSelectionRectangles)
517 pSelectionRectangles->push_back(sRect);
524 case LOK_CALLBACK_TEXT_SELECTION_START:
525 case LOK_CALLBACK_TEXT_SELECTION_END:
540 if(
nType == LOK_CALLBACK_TEXT_SELECTION_START )
554 case LOK_CALLBACK_TEXT_SELECTION:
555 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
557 std::vector<OString> aRect;
558 aRect.reserve(
size());
559 for (size_type
i = 0;
i <
size(); ++
i)
561 const SwRect& rRect = (*this)[
i];
565 if(
nType == LOK_CALLBACK_TEXT_SELECTION )
577 std::vector< basegfx::B2DRange > aInputFieldRanges;
583 if ( pCurTextInputFieldAtCursor !=
nullptr )
586 std::unique_ptr<SwShellCursor> pCursorForInputTextField(
588 pCursorForInputTextField->SetMark();
589 pCursorForInputTextField->GetMark()->Assign(*pTextNode, *(pCurTextInputFieldAtCursor->
End()) );
591 pCursorForInputTextField->FillRects();
592 SwRects* pRects = pCursorForInputTextField.get();
593 for (
const SwRect & rNextRect : *pRects)
597 aInputFieldRanges.emplace_back(
598 aPntRect.
Left(), aPntRect.
Top(),
604 if ( !aInputFieldRanges.empty() )
616 if (xTargetOverlay.is())
623 aHighlight, std::move(aInputFieldRanges) ) );
636 std::vector<basegfx::B2DRange> aContentControlRanges;
637 std::vector<OString> aLOKRectangles;
638 SwRect aFirstPortionPaintArea;
639 SwRect aLastPortionPaintArea;
641 std::shared_ptr<SwContentControl> pContentControl;
656 pCurContentControlAtCursor = static_txtattr_cast<SwTextContentControl*>(pAttr);
659 if (pCurContentControlAtCursor)
661 auto pCursorForContentControl = std::make_unique<SwShellCursor>(
663 pCursorForContentControl->SetMark();
664 pCursorForContentControl->GetMark()->Assign(
665 *pTextNode, *(pCurContentControlAtCursor->
End()));
667 pCursorForContentControl->FillRects();
668 SwRects* pRects = pCursorForContentControl.get();
669 for (
const auto& rRect : *pRects)
673 aContentControlRanges.emplace_back(aRect.
Left(), aRect.
Top(), aRect.
Right() + 1,
677 aLOKRectangles.push_back(aRect.
toString());
681 if (!pRects->empty())
683 aFirstPortionPaintArea = (*pRects)[0];
684 aLastPortionPaintArea = (*pRects)[pRects->size() - 1];
700 if (!aContentControlRanges.empty())
706 aJson.
put(
"action",
"show");
707 aJson.
put(
"rectangles", aPayload);
709 if (pContentControl && (pContentControl->GetComboBox() || pContentControl->GetDropDown()))
712 for (
const auto& rItem : pContentControl->GetListItems())
718 if (pContentControl && pContentControl->GetDate())
720 aJson.
put(
"date",
"true");
723 if (pContentControl && !pContentControl->GetAlias().isEmpty())
725 aJson.
put(
"alias", pContentControl->GetAlias());
742 if (xTargetOverlay.is())
749 aHighlight, std::move(aContentControlRanges)));
754 if (pContentControl && (pContentControl->GetComboBox() || pContentControl->GetDropDown()))
758 auto& rEditWin =
const_cast<SwEditWin&
>(pWrtShell->GetView().GetEditWin());
767 &rEditWin, pContentControl);
781 if (pContentControl && pContentControl->GetDate())
785 auto& rEditWin =
const_cast<SwEditWin&
>(pWrtShell->GetView().GetEditWin());
794 &rEditWin, pContentControl, pWrtShell->GetDoc()->GetNumberFormatter());
803 auto& rEditWin =
const_cast<SwEditWin&
>(pWrtShell->GetView().GetEditWin());
805 if (pContentControl && !pContentControl->GetAlias().isEmpty())
807 Point aTopLeftPixel = rEditWin.LogicToPixel(aFirstPortionPaintArea.
TopLeft());
821 aJson.
put(
"action",
"hide");
834 auto& rEditWin =
const_cast<SwEditWin&
>(pWrtShell->GetView().GetEditWin());
848 size_type nSz =
size();
856 SwRects::insert(
begin(), aReg.begin(), aReg.end() );
862 if( !(
GetShell()->m_bVisPortChgd && 0 != ( nSz =
size())) )
866 iterator it =
begin();
893 aTmp =
pOut->PixelToLogic( aTmp );
908 , m_pInitialPoint(
SwPaM::GetPoint())
920 , m_pInitialPoint(
SwPaM::GetPoint())
926 , m_MarkPt(rICursor.GetMkPos())
927 , m_PointPt(rICursor.GetPtPos())
928 , m_pInitialPoint(
SwPaM::GetPoint())
962 std::vector<OString> aSelectionRectangles;
967 pShCursor->SwSelPaintRects::Show(&aSelectionRectangles);
973 std::vector<OString> aRect;
974 for (
const OString & rSelectionRectangle : aSelectionRectangles)
976 if (rSelectionRectangle.isEmpty())
978 aRect.push_back(rSelectionRectangle);
984 if (pViewShell !=
GetShell()->GetSfxViewShell())
1004 pShCursor->SwSelPaintRects::Invalidate(rRect);
1014 pShCursor->SwSelPaintRects::Hide();
1031 std::vector<sal_uInt16> vActionCounts;
1034 sal_uInt16 nActCnt = 0;
1035 while(rShell.ActionPend())
1040 vActionCounts.push_back(nActCnt);
1042 std::unique_ptr<weld::Builder> xBuilder(
Application::CreateBuilder(pDlg->getDialog(),
"modules/swriter/ui/asksearchdialog.ui"));
1043 std::unique_ptr<weld::MessageDialog> xDialog(xBuilder->weld_message_dialog(
"AskSearchDialog"));
1044 nRet = xDialog->run();
1045 auto pActionCount = vActionCounts.begin();
1048 while(*pActionCount)
1050 rShell.StartAction();
1106 GetShell()->GetViewOptions()->IsReadonly() ||
1107 (
GetShell()->Imp()->GetDrawView() &&
1108 GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
1158 ?
GetShell()->getIDocumentLayoutAccess().GetCurrentLayout()->getFrameArea()
1174 while ( pSelTableNd != pCurTableNd && pCurTableNd )
1184 std::pair<Point, bool>
const tmp(
GetSttPos(),
false);
1189 OSL_ENSURE( pFrame,
"Node not in a table" );
1210 insert(
begin(), aReg.begin(), aReg.end() );
1234 std::pair<Point, bool>
const tmp(
GetPtPos(),
true);
1238 OSL_ENSURE( pFrame,
"Node not in a table" );
1244 if( pCellFrame->getFrameArea().Contains( rPt ) )
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
void DecreaseLuminance(sal_uInt8 cLumDec)
virtual const SwRootFrame * GetCurrentLayout() const =0
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Fraction & GetScaleY() const
constexpr tools::Long getX() const
constexpr tools::Long getY() const
SdrTextObj * GetTextEditObject() const
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
void SetAnimationEnabled(bool bEnable=true)
sal_uInt32 PaintWindowCount() const
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
static OString makeVisCursorInvalidation(int nViewId, const OString &rRectangle, bool bMispelledWord=false, const OString &rHyperlink="")
static void notifyUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
static void notifyOtherView(const SfxViewShell *pThisView, SfxViewShell const *pOtherView, int nType, std::string_view rKey, const OString &rPayload)
static void notifyUpdate(SfxViewShell const *pViewShell, int nType)
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
static OString makePayloadJSON(const SfxViewShell *pThisView, int nViewId, std::string_view rKey, const OString &rPayload)
static void notifyOtherViewsUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
SfxItemPool & GetPool() const
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
constexpr tools::Long Height() const
constexpr tools::Long Width() const
SwCellFrame is one table cell in the document layout.
SwCellFrame * GetFollowCell() const
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, ::sw::GetTextAttrMode eMode)
bool IsReadOnlyAvailable() const
SwShellCursor * GetCursor_()
Point m_aCursorHeight
height & offset from visible Cursor
bool IsCursorReadonly() const
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
OUString GetSelText() const
get selected text of a node at current cursor
bool IsOverwriteCursor() const
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
virtual bool IsAtValidPos(bool bPoint=true) const
Return <true> if cursor can be set to this position.
sal_uInt8 GetCursorBidiLevel() const
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
SwDocShell * GetDocShell()
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
const std::shared_ptr< SwContentControl > & GetContentControl() const
const SwRect & getFrameArea() const
A container for the Header/Footer, PageBreak, and Outline Content Visibility controls.
void HideControls(FrameControlType eType)
void SetContentControlAliasButton(SwContentControl *pContentControl, Point aTopLeftPixel)
Base class of the Writer layout elements.
bool IsRightToLeft() const
SwLayoutFrame * GetNextCellLeaf()
SwLayoutFrame * GetUpper()
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Marks a node in the document model.
Base class of the Writer document model elements.
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool IsInProtectSect() const
Is node in a protected area?
SwTableNode * FindTableNode()
Search table node, in which it is.
SwNodeOffset EndOfSectionIndex() const
SwContentNode * GetContentNode()
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!...
PaM is Point and Mark: a selection of the document model.
const SwPosition * GetMark() const
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
const SwPosition * End() const
const SwPosition * GetPoint() const
const SwPosition * Start() const
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Of course Writer needs its own rectangles.
void Height(tools::Long nNew)
void Top(const tools::Long nTop)
void Right(const tools::Long nRight)
void Bottom(const tools::Long nBottom)
void Pos(const Point &rNew)
void SSize(const Size &rNew)
bool Contains(const Point &rPOINT) const
void AddBottom(const tools::Long nAdd)
void AddRight(const tools::Long nAdd)
bool Overlaps(const SwRect &rRect) const
tools::Rectangle SVRect() const
void Left(const tools::Long nLeft)
void Width(tools::Long nNew)
const SwRect & GetOrigin() const
void Invert()
invert current rectangle
void CalcFrameRects(SwShellCursor &)
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
size_t CountDirChg() const
SwSelPaintRects is a base class of SwShellCursor, which stores the overlay for the cursor/selection: ...
const SwCursorShell * GetShell() const
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
void Invalidate(const SwRect &rRect)
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
void swapContent(SwSelPaintRects &rSwap)
const VclPtr< SwContentControlButton > & GetContentControlButton() const
SwSelPaintRects(const SwCursorShell &rCSh)
std::optional< OString > getLOKPayload(int nType, int nViewId) const
virtual void FillRects()=0
VclPtr< SwContentControlButton > m_pContentControlButton
bool m_bShowTextInputFieldOverlay
static MapMode * s_pMapMode
void HighlightInputField()
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pContentControlOverlay
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
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.
const SwCursorShell * m_pCursorShell
void HighlightContentControl()
bool m_bShowContentControlOverlay
static tools::Long s_nPixPtX
virtual ~SwSelPaintRects()
static tools::Long s_nPixPtY
Represents the current text cursor of one opened edit window.
virtual void FillRects() override
const Point & GetEndPos() const
bool UpDown(bool bUp, sal_uInt16 nCnt)
void Show(SfxViewShell const *pViewShell)
virtual bool IsAtValidPos(bool bPoint=true) const override
Return <true> if cursor can be set to this position.
virtual bool IsReadOnlyAvailable() const override
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
virtual short MaxReplaceArived() override
virtual void SaveTableBoxContent(const SwPosition *pPos) override
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
SwShellCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
void Invalidate(const SwRect &rRect)
const SwPosition * m_pInitialPoint
const Point & GetSttPos() const
const Point & GetPtPos() const
virtual ~SwShellCursor() override
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
const Point & GetMkPos() const
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
virtual void FillRects() override
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
SwRect m_aStart
Left edge of the selection start (top left cell).
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
virtual ~SwShellTableCursor() override
virtual bool IsAtValidPos(bool bPoint=true) const override
Return <true> if cursor can be set to this position.
bool Contains(const Point &rPt) const
virtual void SaveTableBoxContent(const SwPosition *pPos) override
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
virtual short MaxReplaceArived() override
Starts a section of nodes in the document model.
SwSelBoxes m_SelectedBoxes
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
const sal_Int32 * End() const
sal_Int32 GetStart() const
const SwFormatContentControl & GetContentControl() const
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
SwTextNode * GetpTextNode() const
Represents the visualization of a paragraph.
SwRect AutoSpell_(SwTextNode &, sal_Int32)
Is called by DoIdleJob_(), ExecSpellPopup() and UpDown()
SwTextNode is a paragraph in the document model.
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
SwGrammarMarkUp * GetGrammarCheck()
sw::WrongState GetWrongDirty() const
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, ::sw::GetTextAttrMode const eMode=::sw::GetTextAttrMode::Default) const
get the innermost text attribute covering position nIndex.
bool IsSelectionInReadonly() const
bool IsOnlineSpell() const
bool IsViewLocked() const
vcl::RenderContext * GetOut() const
const SwViewOption * GetViewOptions() const
SwRootFrame * GetLayout() const
vcl::Window * GetWin() const
const SwRect & VisArea() const
void InvalidateWindows(const SwRect &rRect)
SfxViewShell * GetSfxViewShell() const
SwWrtShell & GetWrtShell() const
SwPostItMgr * GetPostItMgr()
static SvxSearchDialog * GetSearchDialog()
SwWrtShell * GetWrtShellPtr() const
vcl::Cursor m_aTextCursor
const vcl::Cursor & GetTextCursor() const
std::optional< OString > getLOKPayload(int nType, int nViewId) const
const SwCursorShell * m_pCursorShell
SwVisibleCursor(const SwCursorShell *pCShell)
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
void SetPosAndShow(SfxViewShell const *pViewShell)
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
Used by the UI to modify the document model.
bool IsSelFrameMode() const
static VclPtr< reference_type > Create(Arg &&... arg)
ring_container GetRingContainer()
sal_uInt16 GetStyle() const
void SetWindow(vcl::Window *pWindow)
void SetStyle(sal_uInt16 nStyle)
void SetPos(const Point &rNewPos)
void SetOrientation(Degree10 nOrientation=0_deg10)
void SetWidth(tools::Long nNewWidth)
void SetSize(const Size &rNewSize)
void SetDirection(CursorDirection nDirection=CursorDirection::NONE)
void SetCursor(vcl::Cursor *pCursor)
::OutputDevice const * GetOutDev() const
@ SetOnlyText
stay with the cursor inside text
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
OString join(std::string_view rSeparator, const std::vector< OString > &rSequence)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
enumrange< T >::Iterator begin(enumrange< T >)
@ Parent
EXPAND : (Start < nIndex <= End)
@ Expand
DEFAULT: (Start <= nIndex < End)
void SwCalcPixStatics(vcl::RenderContext const *pOut)
Set borders alignment statics Adjustment for 'small' twip-to-pixel relations: For 'small' twip-to-pix...
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.
union SwContentAtPos::@21 aFnd
const SfxPoolItem * pAttr
Marks a position in the document model.
sal_Int32 GetContentIndex() const
std::vector< SwRect > SwRects
static SwRect lcl_getLayoutRect(const Point &rPoint, const SwPosition &rPosition)
Return a layout rectangle (typically with minimal width) that represents a cursor at rPosition.