20 #include <config_feature_desktop.h>
31 #include <viewimp.hxx>
49 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
52 #include <boost/property_tree/json_parser.hpp>
72 : m_pCursorShell( pCShell )
116 OString buildHyperlinkJSON(
const OUString& sText,
const OUString& sLink)
118 boost::property_tree::ptree aTree;
119 aTree.put(
"text", sText);
120 aTree.put(
"link", sLink);
121 std::stringstream aStream;
122 boost::property_tree::write_json(aStream, aTree,
false);
124 return OString(aStream.str().c_str()).trim();
141 aRect.
Pos().setY(aRect.
Pos().getY() + aRect.
Width());
170 CursorDirection::RTL :
171 CursorDirection::LTR );
179 Size aSize( nSize, nSize );
205 bool bPostItActive =
false;
210 bPostItActive = pPostItMgr->GetActiveSidebarWin() !=
nullptr;
216 sal_uInt16 nPage, nVirtPage;
223 OString aPayload = OString::number(nPage - 1);
232 bool bIsWrong =
false;
247 sal_Int32 nBegin = aPos.nContent.
GetIndex();
264 if (const_cast<SwCursorShell*>(
m_pCursorShell)->GetContentAtPos(aRect.
Pos(), aContentAtPos))
267 sHyperlink = buildHyperlinkJSON(aContentAtPos.
sStr, pItem->
GetValue());
269 else if (bIsSelection)
277 RES_TXTATR_INETFMT>{});
279 if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT ))
282 aSet.GetItem(RES_TXTATR_INETFMT)->GetValue());
327 , m_pCursorShell( &rCSh )
328 #
if HAVE_FEATURE_DESKTOP
329 , m_bShowTextInputFieldOverlay(true)
341 SwRects::swap(rSwap);
343 #if HAVE_FEATURE_DESKTOP
345 std::swap(m_pCursorOverlay, rSwap.m_pCursorOverlay);
353 #if HAVE_FEATURE_DESKTOP
354 m_pCursorOverlay.reset();
372 std::pair<Point, bool>
const tmp(rPoint,
true);
399 #if HAVE_FEATURE_DESKTOP
401 std::vector< basegfx::B2DRange > aNewRanges;
402 aNewRanges.reserve(
size());
403 for(size_type
a = 0;
a <
size(); ++
a)
405 const SwRect aNextRect((*
this)[
a]);
408 aNewRanges.emplace_back(
409 aPntRect.Left(), aPntRect.Top(),
410 aPntRect.Right() + 1, aPntRect.Bottom() + 1);
413 if (m_pCursorOverlay)
415 if(!aNewRanges.empty())
421 m_pCursorOverlay.reset();
429 if (xTargetOverlay.is())
442 xTargetOverlay->add(*m_pCursorOverlay);
457 if (!empty() && !pSelectionRectangles)
480 std::vector<OString> aRect;
481 aRect.reserve(size());
482 for (size_type
i = 0;
i < size(); ++
i)
484 const SwRect& rRect = (*this)[
i];
488 if (!pSelectionRectangles)
494 pSelectionRectangles->push_back(sRect);
499 std::vector< basegfx::B2DRange > aInputFieldRanges;
505 if ( pCurTextInputFieldAtCursor !=
nullptr )
508 std::unique_ptr<SwShellCursor> pCursorForInputTextField(
510 pCursorForInputTextField->SetMark();
511 pCursorForInputTextField->GetMark()->nNode = *pTextNode;
512 pCursorForInputTextField->GetMark()->nContent.Assign( pTextNode, *(pCurTextInputFieldAtCursor->
End()) );
514 pCursorForInputTextField->FillRects();
515 SwRects* pRects =
static_cast<SwRects*
>(pCursorForInputTextField.get());
516 for (
const SwRect & rNextRect : *pRects)
520 aInputFieldRanges.emplace_back(
521 aPntRect.Left(), aPntRect.Top(),
522 aPntRect.Right() + 1, aPntRect.Bottom() + 1);
527 if ( !aInputFieldRanges.empty() )
539 if (xTargetOverlay.is())
547 aHighlight, aInputFieldRanges ) );
560 size_type nSz =
size();
568 SwRects::insert(
begin(), aReg.begin(), aReg.end() );
574 if( !(
GetShell()->m_bVisPortChgd && 0 != ( nSz =
size())) )
578 iterator it =
begin();
620 , m_pInitialPoint(
SwPaM::GetPoint())
632 , m_pInitialPoint(
SwPaM::GetPoint())
638 , m_MarkPt(rICursor.GetMkPos())
639 , m_PointPt(rICursor.GetPtPos())
640 , m_pInitialPoint(
SwPaM::GetPoint())
664 GetPoint()->nNode.GetNode().IsContentNode() &&
674 std::vector<OString> aSelectionRectangles;
679 pShCursor->SwSelPaintRects::Show(&aSelectionRectangles);
685 std::vector<OString> aRect;
686 for (
const OString & rSelectionRectangle : aSelectionRectangles)
688 if (rSelectionRectangle.isEmpty())
690 aRect.push_back(rSelectionRectangle);
696 if (pViewShell !=
GetShell()->GetSfxViewShell())
716 pShCursor->SwSelPaintRects::Invalidate(rRect);
726 pShCursor->SwSelPaintRects::Hide();
743 std::vector<sal_uInt16> vActionCounts;
746 sal_uInt16 nActCnt = 0;
747 while(rShell.ActionPend())
752 vActionCounts.push_back(nActCnt);
754 std::unique_ptr<weld::Builder> xBuilder(
Application::CreateBuilder(pDlg->getDialog(),
"modules/swriter/ui/asksearchdialog.ui"));
755 std::unique_ptr<weld::MessageDialog> xDialog(xBuilder->weld_message_dialog(
"AskSearchDialog"));
756 nRet = xDialog->run();
757 auto pActionCount = vActionCounts.begin();
762 rShell.StartAction();
791 GetShell()->GetViewOptions()->IsReadonly() ||
792 (
GetShell()->Imp()->GetDrawView() &&
793 GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
807 const SwPosition& rPtPos,
const Point& rPtPt )
859 while ( pSelTableNd != pCurTableNd && pCurTableNd )
869 std::pair<Point, bool>
const tmp(
GetSttPos(),
false);
874 OSL_ENSURE( pFrame,
"Node not in a table" );
895 insert(
begin(), aReg.begin(), aReg.end() );
919 std::pair<Point, bool>
const tmp(
GetPtPos(),
true);
923 OSL_ENSURE( pFrame,
"Node not in a table" );
927 for (
SwCellFrame* pCellFrame = static_cast<SwCellFrame*>(pFrame); pCellFrame; pCellFrame = pCellFrame->
GetFollowCell() )
929 if( pCellFrame->getFrameArea().IsInside( 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)
sal_uLong GetIndex() const
void Right(const tools::Long nRight)
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.
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
void SetPos(const Point &rNewPos)
virtual const SwRootFrame * GetCurrentLayout() const =0
rtl::Reference< sdr::overlay::OverlayManager > const & GetOverlayManager() const
SwDocShell * GetDocShell()
void Left(const tools::Long nLeft)
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()
static void notifyVisCursorInvalidation(OutlinerViewShell const *pThisView, const OString &rRectangle, bool bMispelledWord=false, const OString &rHyperlink="")
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false)
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
sal_uInt8 GetCursorBidiLevel() const
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)
OString join(const OString &rSeparator, const std::vector< OString > &rSequence)
Of course Writer needs its own rectangles.
SfxViewShell * GetSfxViewShell() const
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.
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
const Fraction & GetScaleY() const
sal_uLong GetIndex() const
void CalcFrameRects(SwShellCursor &)
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)
Point m_aOldRBPos
Right/Bottom of last VisArea.
union SwContentAtPos::@24 aFnd
virtual void FillRects() override
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.
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
bool UpDown(bool bUp, sal_uInt16 nCnt)
void AddBottom(const tools::Long nAdd)
SwContentNode * GetContentNode()
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
SwLayoutFrame * GetUpper()
virtual ~SwShellCursor() override
tools::Long Width() const
void SetWindow(vcl::Window *pWindow)
SwGrammarMarkUp * GetGrammarCheck()
void HighlightInputField()
bool IsCursorReadonly() const
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
bool IsInside(const Point &rPt) const
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)
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
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
enumrange< T >::Iterator end(enumrange< T >)
const SwPosition * Start() const
bool IsInProtectSect() const
Is node in a protected area?
SwSelPaintRects(const SwCursorShell &rCSh)
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
sal_uLong EndOfSectionIndex() const
void Bottom(const tools::Long nBottom)
SwTextNode is a paragraph in the document model.
SwSelBoxes m_SelectedBoxes
std::vector< SwRect > SwRects
bool IsReadOnlyAvailable() const
SwWrtShell * GetWrtShellPtr() const
tools::Rectangle SVRect() const
Point m_aCursorHeight
height & offset from visible Cursor
const SwViewOption * GetViewOptions() const
void SetCursor(vcl::Cursor *pCursor)
vcl::Window * GetWin() const
vcl::Cursor m_aTextCursor
OUString GetSelText() const
get selected text of a node at current cursor
size_t CountDirChg() const
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
bool IsInside(const Point &rPOINT) const
static tools::Long s_nPixPtY
tools::Long GetCursorSize() const
const SwPosition * End() const
bool IsRightToLeft() const
void Top(const tools::Long nTop)
SwPostItMgr * GetPostItMgr()
const sal_Int32 * End() const
tools::Long Height() 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
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.
const Point & GetEndPos() const
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.
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))
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.
bool IsOver(const SwRect &rRect) const
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
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)
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
bool IsSelectionInReadonly() const
Color getHilightColor() const
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, const bool bIncludeInputFieldAtStart)
Base class of the Writer document model elements.