LibreOffice Module sw (master) 1
viscrs.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <config_feature_desktop.h>
21
22#include <vcl/weld.hxx>
23#include <vcl/svapp.hxx>
24#include <vcl/settings.hxx>
25#include <viewopt.hxx>
26#include <frmtool.hxx>
27#include <viscrs.hxx>
28#include <crsrsh.hxx>
29#include <doc.hxx>
30#include <swtable.hxx>
31#include <viewimp.hxx>
32#include <dview.hxx>
33#include <rootfrm.hxx>
34#include <txtfrm.hxx>
35#include <ndtxt.hxx>
36#include <txtfld.hxx>
37#include <scriptinfo.hxx>
38#include <view.hxx>
40
43#include <svx/srchdlg.hxx>
46
47#include <memory>
48
49#include <LibreOfficeKit/LibreOfficeKitEnums.h>
50#include <comphelper/lok.hxx>
51#include <sfx2/lokhelper.hxx>
52#include <boost/property_tree/json_parser.hpp>
53#include <comphelper/string.hxx>
54#include <osl/diagnose.h>
55#include <paintfrm.hxx>
56#include <PostItMgr.hxx>
57#include <SwGrammarMarkUp.hxx>
58#include <docsh.hxx>
60#include <o3tl/string_view.hxx>
61#include <tools/json_writer.hxx>
62#include <cellfrm.hxx>
63#include <wrtsh.hxx>
68
69// Here static members are defined. They will get changed on alteration of the
70// MapMode. This is done so that on ShowCursor the same size does not have to be
71// expensively determined again and again.
72
76
77// Starting from here: classes / methods for the non-text-cursor
79 : m_pCursorShell( pCShell )
80 , m_nPageLastTime(0)
81{
82 pCShell->GetWin()->SetCursor( &m_aTextCursor );
84 m_bIsDragCursor = false;
86}
87
89{
92
93 m_pCursorShell->GetWin()->SetCursor( nullptr );
94}
95
97{
98 if( !m_bIsVisible )
99 {
100 m_bIsVisible = true;
101
102 // display at all?
104 SetPosAndShow(nullptr);
105 }
106}
107
109{
110 if( m_bIsVisible )
111 {
112 m_bIsVisible = false;
113
114 if( m_aTextCursor.IsVisible() ) // Shouldn't the flags be in effect?
116 }
117}
118
119namespace
120{
121
122// Build JSON message to be sent to Online
123OString buildHyperlinkJSON(const OUString& sText, const OUString& sLink)
124{
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);
130
131 return OString(o3tl::trim(aStream.str()));
132}
133
134}
135
137{
138 SwRect aRect;
140 if( 0 > nTmpY )
141 {
142 nTmpY = -nTmpY;
143 m_aTextCursor.SetOrientation( 900_deg10 );
145 Size( m_pCursorShell->m_aCharRect.Height(), nTmpY ) );
146 aRect.Pos().setX(aRect.Pos().getX() + m_pCursorShell->m_aCursorHeight.getX());
148 aRect.Pos().setY(aRect.Pos().getY() + aRect.Width());
149 }
150 else
151 {
154 Size( m_pCursorShell->m_aCharRect.Width(), nTmpY ) );
155 aRect.Pos().setY(aRect.Pos().getY() + m_pCursorShell->m_aCursorHeight.getX());
156 }
157
158 // check if cursor should show the current cursor bidi level
160 const SwCursor* pTmpCursor = m_pCursorShell->GetCursor_();
161
162 if ( pTmpCursor && !m_pCursorShell->IsOverwriteCursor() )
163 {
164 SwNode& rNode = pTmpCursor->GetPoint()->GetNode();
165 if( rNode.IsTextNode() )
166 {
167 const SwTextNode& rTNd = *rNode.GetTextNode();
168 const SwFrame* pFrame = rTNd.getLayoutFrame(m_pCursorShell->GetLayout(), nullptr, nullptr);
169 if ( pFrame )
170 {
171 const SwScriptInfo* pSI = static_cast<const SwTextFrame*>(pFrame)->GetScriptInfo();
172 // cursor level has to be shown
173 if ( pSI && pSI->CountDirChg() > 1 )
174 {
176 ( pTmpCursor->GetCursorBidiLevel() % 2 ) ?
177 CursorDirection::RTL :
178 CursorDirection::LTR );
179 }
180 if ( pFrame->IsRightToLeft() )
181 {
183 if ( pOut )
184 {
185 tools::Long nSize = pOut->GetSettings().GetStyleSettings().GetCursorSize();
186 Size aSize( nSize, nSize );
187 aSize = pOut->PixelToLogic( aSize );
188 aRect.Left( aRect.Left() - aSize.Width() );
189 }
190 }
191 }
192 }
193 }
194
195 if( aRect.Height())
196 {
198
199 // Disable pixel alignment when tiled rendering, so that twip values of
200 // the cursor don't depend on statics.
202 ::SwAlignRect( aRect, static_cast<SwViewShell const *>(m_pCursorShell), m_pCursorShell->GetOut() );
203 }
206 aRect.Width( 0 );
207
208 m_aTextCursor.SetSize( aRect.SSize() );
209
210 m_aTextCursor.SetPos( aRect.Pos() );
211
212 bool bPostItActive = false;
213 SwView* pView = dynamic_cast<SwView*>(m_pCursorShell->GetSfxViewShell());
214 if (pView)
215 {
216 if (SwPostItMgr* pPostItMgr = pView->GetPostItMgr())
217 bPostItActive = pPostItMgr->GetActiveSidebarWin() != nullptr;
218 }
219
220 if (comphelper::LibreOfficeKit::isActive() && !bPostItActive)
221 {
222 // notify about page number change (if that happened)
223 sal_uInt16 nPage, nVirtPage;
224 // bCalcFrame=false is important to avoid calculating the layout when
225 // we're in the middle of doing that already.
226 const_cast<SwCursorShell*>(m_pCursorShell)->GetPageNum(nPage, nVirtPage, /*bAtCursorPos=*/true, /*bCalcFrame=*/false);
227 if (nPage != m_nPageLastTime)
228 {
229 m_nPageLastTime = nPage;
230 OString aPayload = OString::number(nPage - 1);
231 m_pCursorShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
232 }
233
234 // This may get called often, so instead of sending data on each update, just notify
235 // that there's been an update, and the other side will pull the data using
236 // getLOKPayload() when it decides to.
237 m_aLastLOKRect = aRect;
238 if (pViewShell)
239 {
240 if (pViewShell == m_pCursorShell->GetSfxViewShell())
241 {
242 SfxLokHelper::notifyUpdatePerViewId(pViewShell, LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR);
243 }
244 else
245 {
247 LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
248 }
249 }
250 else
251 {
253 m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR);
255 }
256 }
257
259 return;
260
262 const_cast<SwDrawView*>(static_cast<const SwDrawView*>(m_pCursorShell->GetDrawView()))->SetAnimationEnabled(
264
265 sal_uInt16 nStyle = m_bIsDragCursor ? CURSOR_SHADOW : 0;
266 if( nStyle != m_aTextCursor.GetStyle() )
267 {
268 m_aTextCursor.SetStyle( nStyle );
270 }
271
273}
274
275std::optional<OString> SwVisibleCursor::getLOKPayload(int nType, int nViewId) const
276{
277 assert(nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
279 {
280 SwRect aRect = m_aLastLOKRect;
281
282 // notify about the cursor position & size
283 tools::Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
284 OString sRect = aSVRect.toString();
285
286 if(nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR)
287 return SfxLokHelper::makePayloadJSON(m_pCursorShell->GetSfxViewShell(), nViewId, "rectangle", sRect);
288
289 // is cursor at a misspelled word ?
290 bool bIsWrong = false;
291 SwView* pView = dynamic_cast<SwView*>(m_pCursorShell->GetSfxViewShell());
292 if (pView && pView->GetWrtShellPtr())
293 {
294 const SwViewOption* pVOpt = pView->GetWrtShell().GetViewOptions();
295 if(pVOpt && pVOpt->IsOnlineSpell())
296 {
297 SwPaM* pCursor = m_pCursorShell->GetCursor();
298 SwPosition aPos(*pCursor->GetPoint());
299 Point aPt = aRect.Pos();
301 SwTextNode *pNode = nullptr;
302 if (m_pCursorShell->GetLayout()->GetModelPositionForViewPoint(&aPos, aPt, &eTmpState))
303 pNode = aPos.GetNode().GetTextNode();
304 if (pNode && !pNode->IsInProtectSect())
305 {
306 sal_Int32 nBegin = aPos.GetContentIndex();
307 sal_Int32 nLen = 1;
308
309 SwWrongList *pWrong = pNode->GetWrong();
310 if (!pWrong)
311 pWrong = pNode->GetGrammarCheck();
312 if (pWrong)
313 bIsWrong = pWrong->InWrongWord(nBegin,nLen) && !pNode->IsSymbolAt(nBegin);
314 }
315 }
316 }
317
318 OString sHyperlink;
320 bool bIsSelection = m_pCursorShell->IsSelection();
321
322 if (const_cast<SwCursorShell*>(m_pCursorShell)->GetContentAtPos(aRect.Pos(), aContentAtPos))
323 {
324 const SwFormatINetFormat* pItem = static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr);
325 sHyperlink = buildHyperlinkJSON(aContentAtPos.sStr, pItem->GetValue());
326 }
327 else if (bIsSelection)
328 {
330
331 if (pShell)
332 {
335 pShell->GetCurAttr(aSet);
336 if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT ))
337 {
338 sHyperlink = buildHyperlinkJSON(m_pCursorShell->GetSelText(),
339 aSet.GetItem(RES_TXTATR_INETFMT)->GetValue());
340 }
341 }
342 }
343
344 return SfxLokHelper::makeVisCursorInvalidation(nViewId, sRect, bIsWrong, sHyperlink);
345 }
346 else
347 abort();
348}
349
351{
352 return m_aTextCursor;
353}
354
356 : m_pCursorShell( &rCSh )
357#if HAVE_FEATURE_DESKTOP
358 , m_bShowTextInputFieldOverlay(true)
359 , m_bShowContentControlOverlay(true)
360#endif
361{
362}
363
365{
366 Hide();
368}
369
371{
372 SwRects::swap(rSwap);
373
374#if HAVE_FEATURE_DESKTOP
375 // #i75172# also swap m_pCursorOverlay
376 std::swap(m_pCursorOverlay, rSwap.m_pCursorOverlay);
381#endif
382}
383
385{
386#if HAVE_FEATURE_DESKTOP
387 m_pCursorOverlay.reset();
390#endif
391
392 SwRects::clear();
393}
394
403static SwRect lcl_getLayoutRect(const Point& rPoint, const SwPosition& rPosition)
404{
405 const SwContentNode* pNode = rPosition.GetNode().GetContentNode();
406 std::pair<Point, bool> const tmp(rPoint, true);
407 const SwContentFrame* pFrame = pNode->getLayoutFrame(
409 &rPosition, &tmp);
410 SwRect aRect;
411 pFrame->GetCharRect(aRect, rPosition);
412 return aRect;
413}
414
415void SwShellCursor::FillStartEnd(SwRect& rStart, SwRect& rEnd) const
416{
417 const SwShellCursor* pCursor = GetShell()->getShellCursor(false);
418 rStart = lcl_getLayoutRect(pCursor->GetSttPos(), *pCursor->Start());
419 rEnd = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End());
420}
421
422void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
423{
424 SdrView *const pView = const_cast<SdrView*>(m_pCursorShell->GetDrawView());
425
426 if(!(pView && pView->PaintWindowCount()))
427 return;
428
429 // reset rects
430 SwRects::clear();
431 FillRects();
432
433#if HAVE_FEATURE_DESKTOP
434 // get new rects
435 std::vector< basegfx::B2DRange > aNewRanges;
436 aNewRanges.reserve(size());
437 for(size_type a = 0; a < size(); ++a)
438 {
439 const SwRect aNextRect((*this)[a]);
440 const tools::Rectangle aPntRect(aNextRect.SVRect());
441
442 aNewRanges.emplace_back(
443 aPntRect.Left(), aPntRect.Top(),
444 aPntRect.Right() + 1, aPntRect.Bottom() + 1);
445 }
446
447 if (m_pCursorOverlay)
448 {
449 if(!aNewRanges.empty())
450 {
451 static_cast<sdr::overlay::OverlaySelection*>(m_pCursorOverlay.get())->setRanges(std::move(aNewRanges));
452 }
453 else
454 {
455 m_pCursorOverlay.reset();
456 }
457 }
458 else if(!empty())
459 {
460 SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
461 const rtl::Reference< sdr::overlay::OverlayManager >& xTargetOverlay = pCandidate->GetOverlayManager();
462
463 if (xTargetOverlay.is())
464 {
465 // get the system's highlight color
467
468 // create correct selection
469 m_pCursorOverlay.reset( new sdr::overlay::OverlaySelection(
471 aHighlight,
472 std::move(aNewRanges),
473 true) );
474
475 xTargetOverlay->add(*m_pCursorOverlay);
476 }
477 }
478
481#endif
482
483 // Tiled editing does not expose the draw and writer cursor, it just
484 // talks about "the" cursor at the moment. As long as that's true,
485 // don't say anything about the Writer cursor till a draw object is
486 // being edited.
488 return;
489
490 // If pSelectionRectangles is set, we're just collecting the text selections -> don't emit start/end.
491 if (!empty() && !pSelectionRectangles)
492 {
493 SwRect aStartRect;
494 SwRect aEndRect;
495 FillStartEnd(aStartRect, aEndRect);
496
497 if (aStartRect.HasArea())
498 SfxLokHelper::notifyUpdate(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_SELECTION_START);
499 if (aEndRect.HasArea())
500 SfxLokHelper::notifyUpdate(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_SELECTION_END);
501 }
502
503 std::vector<OString> aRect;
504 aRect.reserve(size());
505 for (size_type i = 0; i < size(); ++i)
506 {
507 const SwRect& rRect = (*this)[i];
508 aRect.push_back(rRect.SVRect().toString());
509 }
510 OString sRect = comphelper::string::join("; ", aRect);
511 if (!pSelectionRectangles)
512 {
513 SfxLokHelper::notifyUpdate(GetShell()->GetSfxViewShell(),LOK_CALLBACK_TEXT_SELECTION);
514 SfxLokHelper::notifyOtherViewsUpdatePerViewId(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION);
515 }
516 else
517 pSelectionRectangles->push_back(sRect);
518}
519
520std::optional<OString> SwSelPaintRects::getLOKPayload(int nType, int nViewId) const
521{
522 switch( nType )
523 {
524 case LOK_CALLBACK_TEXT_SELECTION_START:
525 case LOK_CALLBACK_TEXT_SELECTION_END:
526 {
527 // The selection may be a complex polygon, emit the logical
528 // start/end cursor rectangle of the selection as separate
529 // events, if there is a real selection.
530 // This can be used to easily show selection handles on the
531 // client side.
532 SwRect aStartRect;
533 SwRect aEndRect;
534 FillStartEnd(aStartRect, aEndRect);
535
536 // no selection rect
537 if (!size())
538 return {};
539
540 if( nType == LOK_CALLBACK_TEXT_SELECTION_START )
541 {
542 if (aStartRect.HasArea())
543 return aStartRect.SVRect().toString();
544 return {};
545 }
546 else // LOK_CALLBACK_TEXT_SELECTION_END
547 {
548 if (aEndRect.HasArea())
549 return aEndRect.SVRect().toString();
550 return {};
551 }
552 }
553 break;
554 case LOK_CALLBACK_TEXT_SELECTION:
555 case LOK_CALLBACK_TEXT_VIEW_SELECTION:
556 {
557 std::vector<OString> aRect;
558 aRect.reserve(size());
559 for (size_type i = 0; i < size(); ++i)
560 {
561 const SwRect& rRect = (*this)[i];
562 aRect.push_back(rRect.SVRect().toString());
563 }
564 OString sRect = comphelper::string::join("; ", aRect);
565 if( nType == LOK_CALLBACK_TEXT_SELECTION )
566 return sRect;
567 else // LOK_CALLBACK_TEXT_VIEW_SELECTION
568 return SfxLokHelper::makePayloadJSON(GetShell()->GetSfxViewShell(), nViewId, "selection", sRect);
569 }
570 break;
571 }
572 abort();
573}
574
576{
577 std::vector< basegfx::B2DRange > aInputFieldRanges;
578
580 {
581 SwTextInputField* pCurTextInputFieldAtCursor =
583 if ( pCurTextInputFieldAtCursor != nullptr )
584 {
585 SwTextNode* pTextNode = pCurTextInputFieldAtCursor->GetpTextNode();
586 std::unique_ptr<SwShellCursor> pCursorForInputTextField(
587 new SwShellCursor( *GetShell(), SwPosition( *pTextNode, pCurTextInputFieldAtCursor->GetStart() ) ) );
588 pCursorForInputTextField->SetMark();
589 pCursorForInputTextField->GetMark()->Assign(*pTextNode, *(pCurTextInputFieldAtCursor->End()) );
590
591 pCursorForInputTextField->FillRects();
592 SwRects* pRects = pCursorForInputTextField.get();
593 for (const SwRect & rNextRect : *pRects)
594 {
595 const tools::Rectangle aPntRect(rNextRect.SVRect());
596
597 aInputFieldRanges.emplace_back(
598 aPntRect.Left(), aPntRect.Top(),
599 aPntRect.Right() + 1, aPntRect.Bottom() + 1);
600 }
601 }
602 }
603
604 if ( !aInputFieldRanges.empty() )
605 {
606 if (m_pTextInputFieldOverlay != nullptr)
607 {
608 m_pTextInputFieldOverlay->setRanges( std::move(aInputFieldRanges) );
609 }
610 else
611 {
612 SdrView* pView = const_cast<SdrView*>(GetShell()->GetDrawView());
613 SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
614 const rtl::Reference<sdr::overlay::OverlayManager>& xTargetOverlay = pCandidate->GetOverlayManager();
615
616 if (xTargetOverlay.is())
617 {
618 // use system's highlight color with decreased luminance as highlight color
620 aHighlight.DecreaseLuminance( 128 );
621
623 aHighlight, std::move(aInputFieldRanges) ) );
624 xTargetOverlay->add( *m_pTextInputFieldOverlay );
625 }
626 }
627 }
628 else
629 {
631 }
632}
633
635{
636 std::vector<basegfx::B2DRange> aContentControlRanges;
637 std::vector<OString> aLOKRectangles;
638 SwRect aFirstPortionPaintArea;
639 SwRect aLastPortionPaintArea;
640 bool bRTL = false;
641 std::shared_ptr<SwContentControl> pContentControl;
642
644 {
645 const SwPosition* pStart = GetShell()->GetCursor()->Start();
646 SwTextNode* pTextNode = pStart->GetNode().GetTextNode();
647 SwTextContentControl* pCurContentControlAtCursor = nullptr;
648 if (pTextNode)
649 {
650 // GetTextAttrMode::Parent because this way we highlight when the user will type inside the
651 // content control, not outside of it.
652 SwTextAttr* pAttr = pTextNode->GetTextAttrAt(
654 if (pAttr)
655 {
656 pCurContentControlAtCursor = static_txtattr_cast<SwTextContentControl*>(pAttr);
657 }
658 }
659 if (pCurContentControlAtCursor)
660 {
661 auto pCursorForContentControl = std::make_unique<SwShellCursor>(
662 *GetShell(), SwPosition(*pTextNode, pCurContentControlAtCursor->GetStart()));
663 pCursorForContentControl->SetMark();
664 pCursorForContentControl->GetMark()->Assign(
665 *pTextNode, *(pCurContentControlAtCursor->End()));
666
667 pCursorForContentControl->FillRects();
668 SwRects* pRects = pCursorForContentControl.get();
669 for (const auto& rRect : *pRects)
670 {
671 tools::Rectangle aRect(rRect.SVRect());
672
673 aContentControlRanges.emplace_back(aRect.Left(), aRect.Top(), aRect.Right() + 1,
674 aRect.Bottom() + 1);
676 {
677 aLOKRectangles.push_back(aRect.toString());
678 }
679 }
680
681 if (!pRects->empty())
682 {
683 aFirstPortionPaintArea = (*pRects)[0];
684 aLastPortionPaintArea = (*pRects)[pRects->size() - 1];
685 }
686 pContentControl = pCurContentControlAtCursor->GetContentControl().GetContentControl();
687
688 // The layout knows if the text node is RTL (either set directly, or inherited from the
689 // environment).
691 SwTextFrame* pFrame = aFrames.First();
692 if (pFrame)
693 {
694 bRTL = pFrame->IsRightToLeft();
695 }
696 }
697 }
698
699 auto pWrtShell = dynamic_cast<const SwWrtShell*>(GetShell());
700 if (!aContentControlRanges.empty())
701 {
703 {
704 OString aPayload = comphelper::string::join("; ", aLOKRectangles);
705 tools::JsonWriter aJson;
706 aJson.put("action", "show");
707 aJson.put("rectangles", aPayload);
708
709 if (pContentControl && (pContentControl->GetComboBox() || pContentControl->GetDropDown()))
710 {
711 tools::ScopedJsonWriterArray aItems = aJson.startArray("items");
712 for (const auto& rItem : pContentControl->GetListItems())
713 {
714 aJson.putSimpleValue(rItem.ToString());
715 }
716 }
717
718 if (pContentControl && pContentControl->GetDate())
719 {
720 aJson.put("date", "true");
721 }
722
723 if (pContentControl && !pContentControl->GetAlias().isEmpty())
724 {
725 aJson.put("alias", pContentControl->GetAlias());
726 }
727
728 std::unique_ptr<char, o3tl::free_delete> pJson(aJson.extractData());
729 GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CONTENT_CONTROL, pJson.get());
730 }
732 {
733 m_pContentControlOverlay->setRanges(std::move(aContentControlRanges));
734 }
735 else
736 {
737 SdrView* pView = const_cast<SdrView*>(GetShell()->GetDrawView());
738 SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
740 = pCandidate->GetOverlayManager();
741
742 if (xTargetOverlay.is())
743 {
744 // Use the system's highlight color with decreased luminance as highlight color.
746 aHighlight.DecreaseLuminance(128);
747
749 aHighlight, std::move(aContentControlRanges)));
750 xTargetOverlay->add(*m_pContentControlOverlay);
751 }
752 }
753
754 if (pContentControl && (pContentControl->GetComboBox() || pContentControl->GetDropDown()))
755 {
756 if (pWrtShell)
757 {
758 auto& rEditWin = const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
760 && m_pContentControlButton->GetContentControl() != pContentControl)
761 {
763 }
765 {
767 &rEditWin, pContentControl);
768 }
769 m_pContentControlButton->SetRTL(bRTL);
770 if (bRTL)
771 {
772 m_pContentControlButton->CalcPosAndSize(aFirstPortionPaintArea);
773 }
774 else
775 {
776 m_pContentControlButton->CalcPosAndSize(aLastPortionPaintArea);
777 }
779 }
780 }
781 if (pContentControl && pContentControl->GetDate())
782 {
783 if (pWrtShell)
784 {
785 auto& rEditWin = const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
787 && m_pContentControlButton->GetContentControl() != pContentControl)
788 {
790 }
792 {
794 &rEditWin, pContentControl, pWrtShell->GetDoc()->GetNumberFormatter());
795 }
796 m_pContentControlButton->CalcPosAndSize(aLastPortionPaintArea);
798 }
799 }
800
801 if (pWrtShell)
802 {
803 auto& rEditWin = const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
804 SwFrameControlsManager& rMngr = rEditWin.GetFrameControlsManager();
805 if (pContentControl && !pContentControl->GetAlias().isEmpty())
806 {
807 Point aTopLeftPixel = rEditWin.LogicToPixel(aFirstPortionPaintArea.TopLeft());
808 rMngr.SetContentControlAliasButton(pContentControl.get(), aTopLeftPixel);
809 }
810 else
811 {
813 }
814 }
815 }
816 else
817 {
819 {
820 tools::JsonWriter aJson;
821 aJson.put("action", "hide");
822 std::unique_ptr<char, o3tl::free_delete> pJson(aJson.extractData());
823 GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CONTENT_CONTROL, pJson.get());
824 }
826
828 {
830 }
831
832 if (pWrtShell)
833 {
834 auto& rEditWin = const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
835 SwFrameControlsManager& rMngr = rEditWin.GetFrameControlsManager();
837 }
838 }
839}
840
842{
844}
845
847{
848 size_type nSz = size();
849 if( !nSz )
850 return;
851
852 SwRegionRects aReg( GetShell()->VisArea() );
853 aReg.assign( begin(), end() );
854 aReg -= rRect;
855 SwRects::erase( begin(), begin() + nSz );
856 SwRects::insert( begin(), aReg.begin(), aReg.end() );
857
858 // If the selection is to the right or at the bottom, outside the
859 // visible area, it is never aligned on one pixel at the right/bottom.
860 // This has to be determined here and if that is the case the
861 // rectangle has to be expanded.
862 if( !(GetShell()->m_bVisPortChgd && 0 != ( nSz = size())) )
863 return;
864
866 iterator it = begin();
867 for( ; nSz--; ++it )
868 {
869 SwRect& rRectIt = *it;
870 if( rRectIt.Right() == GetShell()->m_aOldRBPos.X() )
871 rRectIt.AddRight( s_nPixPtX );
872 if( rRectIt.Bottom() == GetShell()->m_aOldRBPos.Y() )
873 rRectIt.AddBottom( s_nPixPtY );
874 }
875}
876
877// check current MapMode of the shell and set possibly the static members.
878// Optional set the parameters pX, pY
880 tools::Long* pX, tools::Long* pY )
881{
882 const OutputDevice* pOut = rSh.GetWin()->GetOutDev();
883 if ( ! pOut )
884 pOut = rSh.GetOut();
885
886 const MapMode& rMM = pOut->GetMapMode();
887 if (s_pMapMode->GetMapUnit() != rMM.GetMapUnit() ||
888 s_pMapMode->GetScaleX() != rMM.GetScaleX() ||
889 s_pMapMode->GetScaleY() != rMM.GetScaleY())
890 {
891 *s_pMapMode = rMM;
892 Size aTmp( 1, 1 );
893 aTmp = pOut->PixelToLogic( aTmp );
894 s_nPixPtX = aTmp.Width();
895 s_nPixPtY = aTmp.Height();
896 }
897 if( pX )
898 *pX = s_nPixPtX;
899 if( pY )
900 *pY = s_nPixPtY;
901}
902
904 const SwCursorShell& rCShell,
905 const SwPosition &rPos )
906 : SwCursor(rPos,nullptr)
907 , SwSelPaintRects(rCShell)
908 , m_pInitialPoint(SwPaM::GetPoint())
909{}
910
912 const SwCursorShell& rCShell,
913 const SwPosition &rPos,
914 const Point& rPtPos,
915 SwPaM* pRing )
916 : SwCursor(rPos, pRing)
917 , SwSelPaintRects(rCShell)
918 , m_MarkPt(rPtPos)
919 , m_PointPt(rPtPos)
920 , m_pInitialPoint(SwPaM::GetPoint())
921{}
922
924 : SwCursor(rICursor, &rICursor)
925 , SwSelPaintRects(*rICursor.GetShell())
926 , m_MarkPt(rICursor.GetMkPos())
927 , m_PointPt(rICursor.GetPtPos())
928 , m_pInitialPoint(SwPaM::GetPoint())
929{}
930
932{}
933
935{
936 return GetShell()->IsReadOnlyAvailable();
937}
938
940{
943 else
946}
947
949{
950 // calculate the new rectangles
951 if( HasMark() &&
952 GetPoint()->GetNode().IsContentNode() &&
953 GetPoint()->GetNode().GetContentNode()->getLayoutFrame( GetShell()->GetLayout() ) &&
954 (GetMark()->GetNode() == GetPoint()->GetNode() ||
955 (GetMark()->GetNode().IsContentNode() &&
956 GetMark()->GetNode().GetContentNode()->getLayoutFrame( GetShell()->GetLayout() ) ) ))
957 GetShell()->GetLayout()->CalcFrameRects( *this );
958}
959
960void SwShellCursor::Show(SfxViewShell const * pViewShell)
961{
962 std::vector<OString> aSelectionRectangles;
963 for(SwPaM& rPaM : GetRingContainer())
964 {
965 SwShellCursor* pShCursor = dynamic_cast<SwShellCursor*>(&rPaM);
966 if(pShCursor)
967 pShCursor->SwSelPaintRects::Show(&aSelectionRectangles);
968 }
969
971 return;
972
973 std::vector<OString> aRect;
974 for (const OString & rSelectionRectangle : aSelectionRectangles)
975 {
976 if (rSelectionRectangle.isEmpty())
977 continue;
978 aRect.push_back(rSelectionRectangle);
979 }
980 OString sRect = comphelper::string::join("; ", aRect);
981 if (pViewShell)
982 {
983 // Just notify pViewShell about our existing selection.
984 if (pViewShell != GetShell()->GetSfxViewShell())
985 SfxLokHelper::notifyOtherView(GetShell()->GetSfxViewShell(), pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
986 }
987 else
988 {
989 GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
990 SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
991 }
992}
993
994// This rectangle gets painted anew, therefore the SSelection in this
995// area is invalid.
997{
998 for(SwPaM& rPaM : GetRingContainer())
999 {
1000 SwShellCursor* pShCursor = dynamic_cast<SwShellCursor*>(&rPaM);
1001 // skip any non SwShellCursor objects in the ring
1002 // see also: SwAutoFormat::DeleteSel()
1003 if(pShCursor)
1004 pShCursor->SwSelPaintRects::Invalidate(rRect);
1005 }
1006}
1007
1009{
1010 for(SwPaM& rPaM : GetRingContainer())
1011 {
1012 SwShellCursor* pShCursor = dynamic_cast<SwShellCursor*>(&rPaM);
1013 if(pShCursor)
1014 pShCursor->SwSelPaintRects::Hide();
1015 }
1016}
1017
1019{
1020 return new SwShellCursor( *GetShell(), *GetPoint(), GetPtPos(), pRing );
1021}
1022
1024{
1025 short nRet = RET_YES;
1027 if( pDlg )
1028 {
1029 // Terminate old actions. The table-frames get constructed and
1030 // a SSelection can be created.
1031 std::vector<sal_uInt16> vActionCounts;
1032 for(SwViewShell& rShell : const_cast< SwCursorShell* >( GetShell() )->GetRingContainer())
1033 {
1034 sal_uInt16 nActCnt = 0;
1035 while(rShell.ActionPend())
1036 {
1037 rShell.EndAction();
1038 ++nActCnt;
1039 }
1040 vActionCounts.push_back(nActCnt);
1041 }
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();
1046 for(SwViewShell& rShell : const_cast< SwCursorShell* >( GetShell() )->GetRingContainer())
1047 {
1048 while(*pActionCount)
1049 {
1050 rShell.StartAction();
1051 --(*pActionCount);
1052 }
1053 ++pActionCount;
1054 }
1055 }
1056 else
1057 // otherwise from the Basic, and then switch to RET_YES
1058 nRet = RET_YES;
1059
1060 return nRet;
1061}
1062
1064{
1065 const_cast<SwCursorShell*>(GetShell())->SaveTableBoxContent( pPos );
1066}
1067
1068bool SwShellCursor::UpDown( bool bUp, sal_uInt16 nCnt )
1069{
1070 // tdf#124603 trigger pending spell checking of the node
1071 if ( nCnt == 1 )
1072 {
1073 SwTextNode* pNode = GetPoint()->GetNode().GetTextNode();
1074 if( pNode && sw::WrongState::PENDING == pNode->GetWrongDirty() )
1075 {
1076 SwWrtShell* pShell = pNode->GetDoc().GetDocShell()->GetWrtShell();
1077 if ( pShell && !pShell->IsSelection() && !pShell->IsSelFrameMode() )
1078 {
1079 const SwViewOption* pVOpt = pShell->GetViewOptions();
1080 if ( pVOpt && pVOpt->IsOnlineSpell() )
1081 {
1082 const bool bOldViewLock = pShell->IsViewLocked();
1083 pShell->LockView( true );
1084
1085 SwTextFrame* pFrame(
1086 static_cast<SwTextFrame*>(pNode->getLayoutFrame(GetShell()->GetLayout())));
1087 SwRect aRepaint(pFrame->AutoSpell_(*pNode, 0));
1088 if (aRepaint.HasArea())
1089 pShell->InvalidateWindows(aRepaint);
1090
1091 pShell->LockView( bOldViewLock );
1092 }
1093 }
1094 }
1095 }
1096
1097 return SwCursor::UpDown( bUp, nCnt,
1098 &GetPtPos(), GetShell()->GetUpDownX(),
1099 *GetShell()->GetLayout());
1100}
1101
1102// if <true> than the cursor can be set to the position.
1103bool SwShellCursor::IsAtValidPos( bool bPoint ) const
1104{
1105 if( GetShell() && ( GetShell()->IsAllProtect() ||
1106 GetShell()->GetViewOptions()->IsReadonly() ||
1107 ( GetShell()->Imp()->GetDrawView() &&
1108 GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
1109 return true;
1110
1111 return SwCursor::IsAtValidPos( bPoint );
1112}
1113
1115 const SwPosition& rPos )
1116 : SwCursor(rPos,nullptr), SwShellCursor(rCursorSh, rPos), SwTableCursor(rPos)
1117{
1118}
1119
1121 const SwPosition& rMkPos, const Point& rMkPt,
1122 const SwPosition& rPtPos, const Point& rPtPt )
1123 : SwCursor(rPtPos,nullptr), SwShellCursor(rCursorSh, rPtPos), SwTableCursor(rPtPos)
1124{
1125 SetMark();
1126 *GetMark() = rMkPos;
1127 GetMkPos() = rMkPt;
1128 GetPtPos() = rPtPt;
1129}
1130
1132
1134
1136{
1137 return SwShellCursor::Create( pRing );
1138}
1139
1141{
1143}
1144
1146{
1148}
1149
1151{
1152 // Calculate the new rectangles. If the cursor is still "parked" do nothing
1153 if (m_SelectedBoxes.empty() || m_bParked || !GetPoint()->GetNodeIndex())
1154 return;
1155
1156 bool bStart = true;
1158 ? GetShell()->getIDocumentLayoutAccess().GetCurrentLayout()->getFrameArea()
1159 : GetShell()->VisArea() );
1160 SwNodes& rNds = GetDoc().GetNodes();
1161 SwFrame* pEndFrame = nullptr;
1162 for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
1163 {
1164 const SwStartNode* pSttNd = m_SelectedBoxes[n]->GetSttNd();
1165 const SwTableNode* pSelTableNd = pSttNd->FindTableNode();
1166
1167 SwNodeIndex aIdx( *pSttNd );
1168 SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
1169
1170 // table in table
1171 // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different
1172 // version to do this)
1173 const SwTableNode* pCurTableNd = pCNd ? pCNd->FindTableNode() : nullptr;
1174 while ( pSelTableNd != pCurTableNd && pCurTableNd )
1175 {
1176 aIdx = pCurTableNd->EndOfSectionIndex();
1177 pCNd = rNds.GoNextSection( &aIdx, true, false );
1178 pCurTableNd = pCNd->FindTableNode();
1179 }
1180
1181 if( !pCNd )
1182 continue;
1183
1184 std::pair<Point, bool> const tmp(GetSttPos(), false);
1185 SwFrame* pFrame = pCNd->getLayoutFrame(GetShell()->GetLayout(), nullptr, &tmp);
1186 while( pFrame && !pFrame->IsCellFrame() )
1187 pFrame = pFrame->GetUpper();
1188
1189 OSL_ENSURE( pFrame, "Node not in a table" );
1190
1191 while ( pFrame )
1192 {
1193 if( aReg.GetOrigin().Overlaps( pFrame->getFrameArea() ) )
1194 {
1195 aReg -= pFrame->getFrameArea();
1196 if (bStart)
1197 {
1198 bStart = false;
1199 m_aStart = SwRect(pFrame->getFrameArea().Left(), pFrame->getFrameArea().Top(), 1, pFrame->getFrameArea().Height());
1200 }
1201 }
1202
1203 pEndFrame = pFrame;
1204 pFrame = pFrame->GetNextCellLeaf();
1205 }
1206 }
1207 if (pEndFrame)
1208 m_aEnd = SwRect(pEndFrame->getFrameArea().Right(), pEndFrame->getFrameArea().Top(), 1, pEndFrame->getFrameArea().Height());
1209 aReg.Invert();
1210 insert( begin(), aReg.begin(), aReg.end() );
1211}
1212
1214{
1215 rStart = m_aStart;
1216 rEnd = m_aEnd;
1217}
1218
1219// Check if the SPoint is within the Table-SSelection.
1220bool SwShellTableCursor::Contains( const Point& rPt ) const
1221{
1222 // Calculate the new rectangles. If the cursor is still "parked" do nothing
1223 if (m_SelectedBoxes.empty() || m_bParked || !GetPoint()->GetNodeIndex())
1224 return false;
1225
1226 SwNodes& rNds = GetDoc().GetNodes();
1227 for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
1228 {
1229 SwNodeIndex aIdx( *m_SelectedBoxes[n]->GetSttNd() );
1230 SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
1231 if( !pCNd )
1232 continue;
1233
1234 std::pair<Point, bool> const tmp(GetPtPos(), true);
1235 SwFrame* pFrame = pCNd->getLayoutFrame(GetShell()->GetLayout(), nullptr, &tmp);
1236 while( pFrame && !pFrame->IsCellFrame() )
1237 pFrame = pFrame->GetUpper();
1238 OSL_ENSURE( pFrame, "Node not in a table" );
1239 if( pFrame && pFrame->getFrameArea().Contains( rPt ) )
1240 return true;
1241
1242 for ( SwCellFrame* pCellFrame = static_cast<SwCellFrame*>(pFrame); pCellFrame; pCellFrame = pCellFrame->GetFollowCell() )
1243 {
1244 if( pCellFrame->getFrameArea().Contains( rPt ) )
1245 return true;
1246 }
1247 }
1248 return false;
1249}
1250
1251bool SwShellTableCursor::IsAtValidPos( bool bPoint ) const
1252{
1253 return SwShellCursor::IsAtValidPos( bPoint );
1254}
1255
1256/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
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
static SAL_WARN_UNUSED_RESULT SfxViewShell * Current()
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
constexpr tools::Long Height() const
constexpr tools::Long Width() const
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:31
SwCellFrame * GetFollowCell() const
Definition: findfrm.cxx:1659
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1230
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, ::sw::GetTextAttrMode eMode)
Definition: crstrvl.cxx:1019
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:491
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:341
Point m_aCursorHeight
height & offset from visible Cursor
Definition: crsrsh.hxx:174
bool IsCursorReadonly() const
Definition: crsrsh.cxx:3320
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2573
bool IsSelection() const
Definition: crsrsh.hxx:902
bool IsOverwriteCursor() const
Definition: crsrsh.hxx:473
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3067
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
Definition: crsrsh.hxx:173
virtual bool IsAtValidPos(bool bPoint=true) const
Return <true> if cursor can be set to this position.
Definition: swcrsr.cxx:709
sal_uInt8 GetCursorBidiLevel() const
Definition: swcrsr.hxx:211
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1985
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:225
SwNodes & GetNodes()
Definition: doc.hxx:418
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:413
SwDocShell * GetDocShell()
Definition: doc.hxx:1362
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:171
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:61
const std::shared_ptr< SwContentControl > & GetContentControl() const
const OUString & GetValue() const
Definition: fmtinfmt.hxx:75
const SwRect & getFrameArea() const
Definition: frame.hxx:179
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.
Definition: frame.hxx:315
bool IsCellFrame() const
Definition: frame.hxx:1227
bool IsRightToLeft() const
Definition: frame.hxx:988
SwLayoutFrame * GetNextCellLeaf()
Definition: findfrm.cxx:1591
SwLayoutFrame * GetUpper()
Definition: frame.hxx:679
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
TElementType * First()
Definition: calbck.hxx:365
Marks a node in the document model.
Definition: ndindex.hxx:31
Base class of the Writer document model elements.
Definition: node.hxx:98
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
bool IsInProtectSect() const
Is node in a protected area?
Definition: node.cxx:439
SwDoc & GetDoc()
Definition: node.hxx:233
bool IsTextNode() const
Definition: node.hxx:687
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:728
SwContentNode * GetContentNode()
Definition: node.hxx:666
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!...
Definition: nodes.cxx:1948
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:642
const SwPosition * End() const
Definition: pam.hxx:271
SwDoc & GetDoc() const
Definition: pam.hxx:299
const SwPosition * GetPoint() const
Definition: pam.hxx:261
const SwPosition * Start() const
Definition: pam.hxx:266
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:259
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void Height(tools::Long nNew)
Definition: swrect.hxx:193
bool HasArea() const
Definition: swrect.hxx:300
Point TopLeft() const
Definition: swrect.hxx:254
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
void Pos(const Point &rNew)
Definition: swrect.hxx:171
void SSize(const Size &rNew)
Definition: swrect.hxx:180
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
void AddBottom(const tools::Long nAdd)
Definition: swrect.cxx:130
void AddRight(const tools::Long nAdd)
Definition: swrect.cxx:127
bool Overlaps(const SwRect &rRect) const
Definition: swrect.hxx:374
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
void Width(tools::Long nNew)
Definition: swrect.hxx:189
const SwRect & GetOrigin() const
Definition: swregion.hxx:62
void Invert()
invert current rectangle
Definition: swregion.cxx:126
void CalcFrameRects(SwShellCursor &)
Definition: trvlfrm.cxx:2019
virtual bool GetModelPositionForViewPoint(SwPosition *, Point &, SwCursorMoveState *=nullptr, bool bTestBackground=false) const override
Primary passes the call to the first page.
Definition: trvlfrm.cxx:425
size_t CountDirChg() const
Definition: scriptinfo.hxx:140
SwSelPaintRects is a base class of SwShellCursor, which stores the overlay for the cursor/selection: ...
Definition: viscrs.hxx:80
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:127
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
Definition: viscrs.cxx:422
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:846
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:94
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:370
const VclPtr< SwContentControlButton > & GetContentControlButton() const
Definition: viscrs.cxx:841
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:355
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: viscrs.cxx:520
virtual void FillRects()=0
VclPtr< SwContentControlButton > m_pContentControlButton
Definition: viscrs.hxx:97
bool m_bShowTextInputFieldOverlay
Definition: viscrs.hxx:93
static MapMode * s_pMapMode
Definition: viscrs.hxx:85
void HighlightInputField()
Definition: viscrs.cxx:575
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pContentControlOverlay
Definition: viscrs.hxx:96
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
Definition: viscrs.cxx:879
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
Definition: viscrs.hxx:87
void HighlightContentControl()
Definition: viscrs.cxx:634
bool m_bShowContentControlOverlay
Definition: viscrs.hxx:95
static tools::Long s_nPixPtX
Definition: viscrs.hxx:84
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:364
static tools::Long s_nPixPtY
Definition: viscrs.hxx:84
Represents the current text cursor of one opened edit window.
Definition: viscrs.hxx:140
virtual void FillRects() override
Definition: viscrs.cxx:948
const Point & GetEndPos() const
Definition: viscrs.hxx:171
bool UpDown(bool bUp, sal_uInt16 nCnt)
Definition: viscrs.cxx:1068
void Show(SfxViewShell const *pViewShell)
Definition: viscrs.cxx:960
virtual bool IsAtValidPos(bool bPoint=true) const override
Return <true> if cursor can be set to this position.
Definition: viscrs.cxx:1103
Point m_MarkPt
Definition: viscrs.hxx:143
virtual bool IsReadOnlyAvailable() const override
Definition: viscrs.cxx:934
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:415
void Hide()
Definition: viscrs.cxx:1008
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:1023
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:1063
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:1018
SwShellCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:903
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:996
Point m_PointPt
Definition: viscrs.hxx:144
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:145
const Point & GetSttPos() const
Definition: viscrs.hxx:169
const Point & GetPtPos() const
Definition: viscrs.hxx:165
virtual ~SwShellCursor() override
Definition: viscrs.cxx:931
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:939
const Point & GetMkPos() const
Definition: viscrs.hxx:167
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:1114
virtual void FillRects() override
Definition: viscrs.cxx:1150
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:199
SwRect m_aStart
Left edge of the selection start (top left cell).
Definition: viscrs.hxx:197
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:1135
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:1133
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:1131
virtual bool IsAtValidPos(bool bPoint=true) const override
Return <true> if cursor can be set to this position.
Definition: viscrs.cxx:1251
bool Contains(const Point &rPt) const
Definition: viscrs.cxx:1220
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:1145
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:1213
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:1140
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwSelBoxes m_SelectedBoxes
Definition: swcrsr.hxx:261
bool m_bParked
Definition: swcrsr.hxx:263
A wrapper around SfxPoolItem to store the start position of (usually) a text portion,...
Definition: txatbase.hxx:44
const sal_Int32 * End() const
Definition: txatbase.hxx:156
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
const SwFormatContentControl & GetContentControl() const
Definition: txatbase.hxx:220
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:165
SwRect AutoSpell_(SwTextNode &, sal_Int32)
Is called by DoIdleJob_(), ExecSpellPopup() and UpDown()
Definition: txtedt.cxx:1269
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
SwWrongList * GetWrong()
Definition: txtedt.cxx:2225
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
Definition: itratr.cxx:855
SwGrammarMarkUp * GetGrammarCheck()
Definition: txtedt.cxx:2251
sw::WrongState GetWrongDirty() const
Definition: txtedt.cxx:2304
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.
Definition: ndtxt.cxx:1802
bool IsSelectionInReadonly() const
Definition: viewopt.hxx:574
bool IsOnlineSpell() const
Definition: viewopt.hxx:481
bool IsViewLocked() const
Definition: viewsh.hxx:472
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:347
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:434
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2160
vcl::Window * GetWin() const
Definition: viewsh.hxx:346
const SwRect & VisArea() const
Definition: viewsh.cxx:630
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:556
SwDoc * GetDoc() const
Definition: viewsh.hxx:290
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:452
void LockView(bool b)
Definition: viewsh.hxx:473
SdrView * GetDrawView()
Definition: vnew.cxx:373
Definition: view.hxx:146
SwWrtShell & GetWrtShell() const
Definition: view.hxx:421
SwPostItMgr * GetPostItMgr()
Definition: view.hxx:648
static SvxSearchDialog * GetSearchDialog()
Definition: viewsrch.cxx:829
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:422
vcl::Cursor m_aTextCursor
Definition: viscrs.hxx:45
SwRect m_aLastLOKRect
Definition: viscrs.hxx:49
bool m_bIsDragCursor
Definition: viscrs.hxx:52
const vcl::Cursor & GetTextCursor() const
Definition: viscrs.cxx:350
std::optional< OString > getLOKPayload(int nType, int nViewId) const
Definition: viscrs.cxx:275
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:44
SwVisibleCursor(const SwCursorShell *pCShell)
Definition: viscrs.cxx:78
bool m_bIsVisible
Definition: viscrs.hxx:51
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
Definition: viscrs.hxx:48
void Show()
Definition: viscrs.cxx:96
void SetPosAndShow(SfxViewShell const *pViewShell)
Definition: viscrs.cxx:136
bool InWrongWord(sal_Int32 &rChk, sal_Int32 &rLn) const
If a word is incorrectly selected, this method returns begin and length of it.
Definition: wrong.cxx:103
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
bool IsSelFrameMode() const
Definition: wrtsh.hxx:177
void disposeAndClear()
static VclPtr< reference_type > Create(Arg &&... arg)
bool empty() const
size_type size() const
ring_container GetRingContainer()
Definition: ring.hxx:240
void put(const char *pPropName, const OUString &rPropValue)
ScopedJsonWriterArray startArray(const char *)
void putSimpleValue(const OUString &rPropValue)
char * extractData()
constexpr tools::Long Top() const
constexpr tools::Long Right() const
constexpr tools::Long Left() const
constexpr tools::Long Bottom() const
rtl::OString toString() const
sal_uInt16 GetStyle() const
bool IsVisible() 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
#define CURSOR_SHADOW
static SwContentNode * GetContentNode(SwDoc &rDoc, SwPosition &rPos, bool bNext)
Definition: fltshell.cxx:54
void SwAlignRect(SwRect &rRect, const SwViewShell *pSh, const vcl::RenderContext *pRenderContext)
Function <SwAlignRect(..)> is also used outside this file.
Definition: paintfrm.cxx:1126
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
sal_Int64 n
uno_Any a
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
Shell * GetShell()
size
OString join(std::string_view rSeparator, const std::vector< OString > &rSequence)
int i
std::u16string_view trim(std::u16string_view str)
enumrange< T >::Iterator begin(enumrange< T >)
end
@ Parent
EXPAND : (Start < nIndex <= End)
@ Expand
DEFAULT: (Start <= nIndex < End)
long Long
void SwCalcPixStatics(vcl::RenderContext const *pOut)
Set borders alignment statics Adjustment for 'small' twip-to-pixel relations: For 'small' twip-to-pix...
Definition: paintfrm.cxx:381
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.
Definition: pam.cxx:1020
QPRO_FUNC_TYPE nType
union SwContentAtPos::@24 aFnd
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:105
OUString sStr
Definition: crsrsh.hxx:112
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
std::vector< SwRect > SwRects
Definition: swregion.hxx:26
RET_YES
static SwRect lcl_getLayoutRect(const Point &rPoint, const SwPosition &rPosition)
Return a layout rectangle (typically with minimal width) that represents a cursor at rPosition.
Definition: viscrs.cxx:403
oslFileHandle & pOut