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 
42 #include <svx/sdrpaintwindow.hxx>
43 #include <svx/srchdlg.hxx>
45 #include "overlayrangesoutline.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>
64 #include <textcontentcontrol.hxx>
66 
67 // Here static members are defined. They will get changed on alteration of the
68 // MapMode. This is done so that on ShowCursor the same size does not have to be
69 // expensively determined again and again.
70 
74 
75 // Starting from here: classes / methods for the non-text-cursor
77  : m_pCursorShell( pCShell )
78  , m_nPageLastTime(0)
79 {
80  pCShell->GetWin()->SetCursor( &m_aTextCursor );
82  m_bIsDragCursor = false;
84 }
85 
87 {
90 
91  m_pCursorShell->GetWin()->SetCursor( nullptr );
92 }
93 
95 {
96  if( !m_bIsVisible )
97  {
98  m_bIsVisible = true;
99 
100  // display at all?
102  SetPosAndShow(nullptr);
103  }
104 }
105 
107 {
108  if( m_bIsVisible )
109  {
110  m_bIsVisible = false;
111 
112  if( m_aTextCursor.IsVisible() ) // Shouldn't the flags be in effect?
114  }
115 }
116 
117 namespace
118 {
119 
120 // Build JSON message to be sent to Online
121 OString buildHyperlinkJSON(const OUString& sText, const OUString& sLink)
122 {
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);
128 
129  return OString(o3tl::trim(aStream.str()));
130 }
131 
132 }
133 
135 {
136  SwRect aRect;
138  if( 0 > nTmpY )
139  {
140  nTmpY = -nTmpY;
141  m_aTextCursor.SetOrientation( 900_deg10 );
142  aRect = SwRect( m_pCursorShell->m_aCharRect.Pos(),
143  Size( m_pCursorShell->m_aCharRect.Height(), nTmpY ) );
144  aRect.Pos().setX(aRect.Pos().getX() + m_pCursorShell->m_aCursorHeight.getX());
146  aRect.Pos().setY(aRect.Pos().getY() + aRect.Width());
147  }
148  else
149  {
151  aRect = SwRect( m_pCursorShell->m_aCharRect.Pos(),
152  Size( m_pCursorShell->m_aCharRect.Width(), nTmpY ) );
153  aRect.Pos().setY(aRect.Pos().getY() + m_pCursorShell->m_aCursorHeight.getX());
154  }
155 
156  // check if cursor should show the current cursor bidi level
158  const SwCursor* pTmpCursor = m_pCursorShell->GetCursor_();
159 
160  if ( pTmpCursor && !m_pCursorShell->IsOverwriteCursor() )
161  {
162  SwNode& rNode = pTmpCursor->GetPoint()->nNode.GetNode();
163  if( rNode.IsTextNode() )
164  {
165  const SwTextNode& rTNd = *rNode.GetTextNode();
166  const SwFrame* pFrame = rTNd.getLayoutFrame(m_pCursorShell->GetLayout(), nullptr, nullptr);
167  if ( pFrame )
168  {
169  const SwScriptInfo* pSI = static_cast<const SwTextFrame*>(pFrame)->GetScriptInfo();
170  // cursor level has to be shown
171  if ( pSI && pSI->CountDirChg() > 1 )
172  {
174  ( pTmpCursor->GetCursorBidiLevel() % 2 ) ?
175  CursorDirection::RTL :
176  CursorDirection::LTR );
177  }
178  if ( pFrame->IsRightToLeft() )
179  {
181  if ( pOut )
182  {
184  Size aSize( nSize, nSize );
185  aSize = pOut->PixelToLogic( aSize );
186  aRect.Left( aRect.Left() - aSize.Width() );
187  }
188  }
189  }
190  }
191  }
192 
193  if( aRect.Height())
194  {
196 
197  // Disable pixel alignment when tiled rendering, so that twip values of
198  // the cursor don't depend on statics.
200  ::SwAlignRect( aRect, static_cast<SwViewShell const *>(m_pCursorShell), m_pCursorShell->GetOut() );
201  }
204  aRect.Width( 0 );
205 
206  m_aTextCursor.SetSize( aRect.SSize() );
207 
208  m_aTextCursor.SetPos( aRect.Pos() );
209 
210  bool bPostItActive = false;
211  SwView* pView = dynamic_cast<SwView*>(m_pCursorShell->GetSfxViewShell());
212  if (pView)
213  {
214  if (SwPostItMgr* pPostItMgr = pView->GetPostItMgr())
215  bPostItActive = pPostItMgr->GetActiveSidebarWin() != nullptr;
216  }
217 
218  if (comphelper::LibreOfficeKit::isActive() && !bPostItActive)
219  {
220  // notify about page number change (if that happened)
221  sal_uInt16 nPage, nVirtPage;
222  // bCalcFrame=false is important to avoid calculating the layout when
223  // we're in the middle of doing that already.
224  const_cast<SwCursorShell*>(m_pCursorShell)->GetPageNum(nPage, nVirtPage, /*bAtCursorPos=*/true, /*bCalcFrame=*/false);
225  if (nPage != m_nPageLastTime)
226  {
227  m_nPageLastTime = nPage;
228  OString aPayload = OString::number(nPage - 1);
229  m_pCursorShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload.getStr());
230  }
231 
232  // This may get called often, so instead of sending data on each update, just notify
233  // that there's been an update, and the other side will pull the data using
234  // getLOKPayload() when it decides to.
235  m_aLastLOKRect = aRect;
236  if (pViewShell)
237  {
238  if (pViewShell == m_pCursorShell->GetSfxViewShell())
239  {
240  SfxLokHelper::notifyUpdatePerViewId(pViewShell, LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR);
241  }
242  else
243  {
245  LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
246  }
247  }
248  else
249  {
251  m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR);
252  SfxLokHelper::notifyOtherViewsUpdatePerViewId(m_pCursorShell->GetSfxViewShell(), LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
253  }
254  }
255 
257  return;
258 
259  if ( m_pCursorShell->GetDrawView() )
260  const_cast<SwDrawView*>(static_cast<const SwDrawView*>(m_pCursorShell->GetDrawView()))->SetAnimationEnabled(
262 
263  sal_uInt16 nStyle = m_bIsDragCursor ? CURSOR_SHADOW : 0;
264  if( nStyle != m_aTextCursor.GetStyle() )
265  {
266  m_aTextCursor.SetStyle( nStyle );
268  }
269 
271 }
272 
273 OString SwVisibleCursor::getLOKPayload(int nType, int nViewId, bool*) const
274 {
275  assert(nType == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR || nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR);
277  {
278  SwRect aRect = m_aLastLOKRect;
279 
280  // notify about the cursor position & size
281  tools::Rectangle aSVRect(aRect.Pos().getX(), aRect.Pos().getY(), aRect.Pos().getX() + aRect.SSize().Width(), aRect.Pos().getY() + aRect.SSize().Height());
282  OString sRect = aSVRect.toString();
283 
284  if(nType == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR)
285  return SfxLokHelper::makePayloadJSON(m_pCursorShell->GetSfxViewShell(), nViewId, "rectangle", sRect);
286 
287  // is cursor at a misspelled word ?
288  bool bIsWrong = false;
289  SwView* pView = dynamic_cast<SwView*>(m_pCursorShell->GetSfxViewShell());
290  if (pView && pView->GetWrtShellPtr())
291  {
292  const SwViewOption* pVOpt = pView->GetWrtShell().GetViewOptions();
293  if(pVOpt && pVOpt->IsOnlineSpell())
294  {
295  SwPaM* pCursor = m_pCursorShell->GetCursor();
296  SwPosition aPos(*pCursor->GetPoint());
297  Point aPt = aRect.Pos();
299  SwTextNode *pNode = nullptr;
300  if (m_pCursorShell->GetLayout()->GetModelPositionForViewPoint(&aPos, aPt, &eTmpState))
301  pNode = aPos.nNode.GetNode().GetTextNode();
302  if (pNode && !pNode->IsInProtectSect())
303  {
304  sal_Int32 nBegin = aPos.nContent.GetIndex();
305  sal_Int32 nLen = 1;
306 
307  SwWrongList *pWrong = pNode->GetWrong();
308  if (!pWrong)
309  pWrong = pNode->GetGrammarCheck();
310  if (pWrong)
311  bIsWrong = pWrong->InWrongWord(nBegin,nLen) && !pNode->IsSymbolAt(nBegin);
312  }
313  }
314  }
315 
316  OString sHyperlink;
317  SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr);
318  bool bIsSelection = m_pCursorShell->IsSelection();
319 
320  if (const_cast<SwCursorShell*>(m_pCursorShell)->GetContentAtPos(aRect.Pos(), aContentAtPos))
321  {
322  const SwFormatINetFormat* pItem = static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr);
323  sHyperlink = buildHyperlinkJSON(aContentAtPos.sStr, pItem->GetValue());
324  }
325  else if (bIsSelection)
326  {
328 
329  if (pShell)
330  {
333  pShell->GetCurAttr(aSet);
334  if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT ))
335  {
336  sHyperlink = buildHyperlinkJSON(m_pCursorShell->GetSelText(),
337  aSet.GetItem(RES_TXTATR_INETFMT)->GetValue());
338  }
339  }
340  }
341 
342  return SfxLokHelper::makeVisCursorInvalidation(nViewId, sRect, bIsWrong, sHyperlink);
343  }
344  else
345  abort();
346 }
347 
349 {
350  return m_aTextCursor;
351 }
352 
354  : m_pCursorShell( &rCSh )
355 #if HAVE_FEATURE_DESKTOP
356  , m_bShowTextInputFieldOverlay(true)
357  , m_bShowContentControlOverlay(true)
358 #endif
359 {
360 }
361 
363 {
364  Hide();
366 }
367 
369 {
370  SwRects::swap(rSwap);
371 
372 #if HAVE_FEATURE_DESKTOP
373  // #i75172# also swap m_pCursorOverlay
374  std::swap(m_pCursorOverlay, rSwap.m_pCursorOverlay);
379 #endif
380 }
381 
383 {
384 #if HAVE_FEATURE_DESKTOP
385  m_pCursorOverlay.reset();
386  m_pTextInputFieldOverlay.reset();
387  m_pContentControlOverlay.reset();
388 #endif
389 
390  SwRects::clear();
391 }
392 
401 static SwRect lcl_getLayoutRect(const Point& rPoint, const SwPosition& rPosition)
402 {
403  const SwContentNode* pNode = rPosition.nNode.GetNode().GetContentNode();
404  std::pair<Point, bool> const tmp(rPoint, true);
405  const SwContentFrame* pFrame = pNode->getLayoutFrame(
407  &rPosition, &tmp);
408  SwRect aRect;
409  pFrame->GetCharRect(aRect, rPosition);
410  return aRect;
411 }
412 
413 void SwShellCursor::FillStartEnd(SwRect& rStart, SwRect& rEnd) const
414 {
415  const SwShellCursor* pCursor = GetShell()->getShellCursor(false);
416  rStart = lcl_getLayoutRect(pCursor->GetSttPos(), *pCursor->Start());
417  rEnd = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End());
418 }
419 
420 void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
421 {
422  SdrView *const pView = const_cast<SdrView*>(m_pCursorShell->GetDrawView());
423 
424  if(!(pView && pView->PaintWindowCount()))
425  return;
426 
427  // reset rects
428  SwRects::clear();
429  FillRects();
430 
431 #if HAVE_FEATURE_DESKTOP
432  // get new rects
433  std::vector< basegfx::B2DRange > aNewRanges;
434  aNewRanges.reserve(size());
435  for(size_type a = 0; a < size(); ++a)
436  {
437  const SwRect aNextRect((*this)[a]);
438  const tools::Rectangle aPntRect(aNextRect.SVRect());
439 
440  aNewRanges.emplace_back(
441  aPntRect.Left(), aPntRect.Top(),
442  aPntRect.Right() + 1, aPntRect.Bottom() + 1);
443  }
444 
445  if (m_pCursorOverlay)
446  {
447  if(!aNewRanges.empty())
448  {
449  static_cast<sdr::overlay::OverlaySelection*>(m_pCursorOverlay.get())->setRanges(std::move(aNewRanges));
450  }
451  else
452  {
453  m_pCursorOverlay.reset();
454  }
455  }
456  else if(!empty())
457  {
458  SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
459  const rtl::Reference< sdr::overlay::OverlayManager >& xTargetOverlay = pCandidate->GetOverlayManager();
460 
461  if (xTargetOverlay.is())
462  {
463  // get the system's highlight color
465 
466  // create correct selection
467  m_pCursorOverlay.reset( new sdr::overlay::OverlaySelection(
469  aHighlight,
470  std::move(aNewRanges),
471  true) );
472 
473  xTargetOverlay->add(*m_pCursorOverlay);
474  }
475  }
476 
479 #endif
480 
481  // Tiled editing does not expose the draw and writer cursor, it just
482  // talks about "the" cursor at the moment. As long as that's true,
483  // don't say anything about the Writer cursor till a draw object is
484  // being edited.
486  return;
487 
488  // If pSelectionRectangles is set, we're just collecting the text selections -> don't emit start/end.
489  if (!empty() && !pSelectionRectangles)
490  {
491  SwRect aStartRect;
492  SwRect aEndRect;
493  FillStartEnd(aStartRect, aEndRect);
494 
495  if (aStartRect.HasArea())
496  SfxLokHelper::notifyUpdate(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_SELECTION_START);
497  if (aEndRect.HasArea())
498  SfxLokHelper::notifyUpdate(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_SELECTION_END);
499  }
500 
501  std::vector<OString> aRect;
502  aRect.reserve(size());
503  for (size_type i = 0; i < size(); ++i)
504  {
505  const SwRect& rRect = (*this)[i];
506  aRect.push_back(rRect.SVRect().toString());
507  }
508  OString sRect = comphelper::string::join("; ", aRect);
509  if (!pSelectionRectangles)
510  {
511  SfxLokHelper::notifyUpdate(GetShell()->GetSfxViewShell(),LOK_CALLBACK_TEXT_SELECTION);
512  SfxLokHelper::notifyOtherViewsUpdatePerViewId(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION);
513  }
514  else
515  pSelectionRectangles->push_back(sRect);
516 }
517 
518 OString SwSelPaintRects::getLOKPayload( int nType, int nViewId, bool* ignore ) const
519 {
520  switch( nType )
521  {
522  case LOK_CALLBACK_TEXT_SELECTION_START:
523  case LOK_CALLBACK_TEXT_SELECTION_END:
524  {
525  // The selection may be a complex polygon, emit the logical
526  // start/end cursor rectangle of the selection as separate
527  // events, if there is a real selection.
528  // This can be used to easily show selection handles on the
529  // client side.
530  SwRect aStartRect;
531  SwRect aEndRect;
532  FillStartEnd(aStartRect, aEndRect);
533 
534  // no selection rect
535  if (!size())
536  {
537  *ignore = true;
538  return OString();
539  }
540 
541  if( nType == LOK_CALLBACK_TEXT_SELECTION_START )
542  {
543  if (aStartRect.HasArea())
544  return aStartRect.SVRect().toString();
545  *ignore = true;
546  return OString();
547  }
548  else // LOK_CALLBACK_TEXT_SELECTION_END
549  {
550  if (aEndRect.HasArea())
551  return aEndRect.SVRect().toString();
552  *ignore = true;
553  return OString();
554  }
555  }
556  break;
557  case LOK_CALLBACK_TEXT_SELECTION:
558  case LOK_CALLBACK_TEXT_VIEW_SELECTION:
559  {
560  std::vector<OString> aRect;
561  aRect.reserve(size());
562  for (size_type i = 0; i < size(); ++i)
563  {
564  const SwRect& rRect = (*this)[i];
565  aRect.push_back(rRect.SVRect().toString());
566  }
567  OString sRect = comphelper::string::join("; ", aRect);
568  if( nType == LOK_CALLBACK_TEXT_SELECTION )
569  return sRect;
570  else // LOK_CALLBACK_TEXT_VIEW_SELECTION
571  return SfxLokHelper::makePayloadJSON(GetShell()->GetSfxViewShell(), nViewId, "selection", sRect);
572  }
573  break;
574  }
575  abort();
576 }
577 
579 {
580  std::vector< basegfx::B2DRange > aInputFieldRanges;
581 
583  {
584  SwTextInputField* pCurTextInputFieldAtCursor =
585  dynamic_cast<SwTextInputField*>(SwCursorShell::GetTextFieldAtPos( GetShell()->GetCursor()->Start(), false ));
586  if ( pCurTextInputFieldAtCursor != nullptr )
587  {
588  SwTextNode* pTextNode = pCurTextInputFieldAtCursor->GetpTextNode();
589  std::unique_ptr<SwShellCursor> pCursorForInputTextField(
590  new SwShellCursor( *GetShell(), SwPosition( *pTextNode, pCurTextInputFieldAtCursor->GetStart() ) ) );
591  pCursorForInputTextField->SetMark();
592  pCursorForInputTextField->GetMark()->nNode = *pTextNode;
593  pCursorForInputTextField->GetMark()->nContent.Assign( pTextNode, *(pCurTextInputFieldAtCursor->End()) );
594 
595  pCursorForInputTextField->FillRects();
596  SwRects* pRects = pCursorForInputTextField.get();
597  for (const SwRect & rNextRect : *pRects)
598  {
599  const tools::Rectangle aPntRect(rNextRect.SVRect());
600 
601  aInputFieldRanges.emplace_back(
602  aPntRect.Left(), aPntRect.Top(),
603  aPntRect.Right() + 1, aPntRect.Bottom() + 1);
604  }
605  }
606  }
607 
608  if ( !aInputFieldRanges.empty() )
609  {
610  if (m_pTextInputFieldOverlay != nullptr)
611  {
612  m_pTextInputFieldOverlay->setRanges( std::move(aInputFieldRanges) );
613  }
614  else
615  {
616  SdrView* pView = const_cast<SdrView*>(GetShell()->GetDrawView());
617  SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
618  const rtl::Reference<sdr::overlay::OverlayManager>& xTargetOverlay = pCandidate->GetOverlayManager();
619 
620  if (xTargetOverlay.is())
621  {
622  // use system's highlight color with decreased luminance as highlight color
624  aHighlight.DecreaseLuminance( 128 );
625 
627  aHighlight, std::move(aInputFieldRanges) ) );
628  xTargetOverlay->add( *m_pTextInputFieldOverlay );
629  }
630  }
631  }
632  else
633  {
634  m_pTextInputFieldOverlay.reset();
635  }
636 }
637 
639 {
640  std::vector<basegfx::B2DRange> aContentControlRanges;
641  std::vector<OString> aLOKRectangles;
642  SwRect aLastPortionPaintArea;
643  std::shared_ptr<SwContentControl> pContentControl;
644 
646  {
647  const SwPosition* pStart = GetShell()->GetCursor()->Start();
648  SwTextNode* pTextNode = pStart->nNode.GetNode().GetTextNode();
649  SwTextContentControl* pCurContentControlAtCursor = nullptr;
650  if (pTextNode)
651  {
652  // SwTextNode::PARENT because this way we highlight when the user will type inside the
653  // content control, not outside of it.
654  SwTextAttr* pAttr = pTextNode->GetTextAttrAt(
656  if (pAttr)
657  {
658  pCurContentControlAtCursor = static_txtattr_cast<SwTextContentControl*>(pAttr);
659  }
660  }
661  if (pCurContentControlAtCursor)
662  {
663  auto pCursorForContentControl = std::make_unique<SwShellCursor>(
664  *GetShell(), SwPosition(*pTextNode, pCurContentControlAtCursor->GetStart()));
665  pCursorForContentControl->SetMark();
666  pCursorForContentControl->GetMark()->nNode = *pTextNode;
667  pCursorForContentControl->GetMark()->nContent.Assign(
668  pTextNode, *(pCurContentControlAtCursor->End()));
669 
670  pCursorForContentControl->FillRects();
671  SwRects* pRects = pCursorForContentControl.get();
672  for (const auto& rRect : *pRects)
673  {
674  tools::Rectangle aRect(rRect.SVRect());
675 
676  aContentControlRanges.emplace_back(aRect.Left(), aRect.Top(), aRect.Right() + 1,
677  aRect.Bottom() + 1);
679  {
680  aLOKRectangles.push_back(aRect.toString());
681  }
682  }
683 
684  if (!pRects->empty())
685  {
686  aLastPortionPaintArea = (*pRects)[pRects->size() - 1];
687  }
688  pContentControl = pCurContentControlAtCursor->GetContentControl().GetContentControl();
689  }
690  }
691 
692  if (!aContentControlRanges.empty())
693  {
695  {
696  OString aPayload = comphelper::string::join("; ", aLOKRectangles);
697  tools::JsonWriter aJson;
698  aJson.put("action", "show");
699  aJson.put("rectangles", aPayload);
700 
701  if (pContentControl && pContentControl->HasListItems())
702  {
703  tools::ScopedJsonWriterArray aItems = aJson.startArray("items");
704  for (const auto& rItem : pContentControl->GetListItems())
705  {
706  aJson.putSimpleValue(rItem.ToString());
707  }
708  }
709 
710  std::unique_ptr<char, o3tl::free_delete> pJson(aJson.extractData());
711  GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CONTENT_CONTROL, pJson.get());
712  }
714  {
715  m_pContentControlOverlay->setRanges(std::move(aContentControlRanges));
716  }
717  else
718  {
719  SdrView* pView = const_cast<SdrView*>(GetShell()->GetDrawView());
720  SdrPaintWindow* pCandidate = pView->GetPaintWindow(0);
722  = pCandidate->GetOverlayManager();
723 
724  if (xTargetOverlay.is())
725  {
726  // Use the system's highlight color with decreased luminance as highlight color.
728  aHighlight.DecreaseLuminance(128);
729 
731  aHighlight, std::move(aContentControlRanges)));
732  xTargetOverlay->add(*m_pContentControlOverlay);
733  }
734  }
735 
736  if (pContentControl && pContentControl->HasListItems())
737  {
738  auto pWrtShell = dynamic_cast<const SwWrtShell*>(GetShell());
739  if (pWrtShell)
740  {
741  auto& rEditWin = const_cast<SwEditWin&>(pWrtShell->GetView().GetEditWin());
743  && m_pContentControlButton->GetContentControl() != pContentControl)
744  {
746  }
748  {
750  &rEditWin, pContentControl);
751  }
752  m_pContentControlButton->CalcPosAndSize(aLastPortionPaintArea);
754  }
755  }
756  }
757  else
758  {
760  {
761  tools::JsonWriter aJson;
762  aJson.put("action", "hide");
763  std::unique_ptr<char, o3tl::free_delete> pJson(aJson.extractData());
764  GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_CONTENT_CONTROL, pJson.get());
765  }
766  m_pContentControlOverlay.reset();
767 
769  {
771  }
772  }
773 }
774 
776 {
777  size_type nSz = size();
778  if( !nSz )
779  return;
780 
781  SwRegionRects aReg( GetShell()->VisArea() );
782  aReg.assign( begin(), end() );
783  aReg -= rRect;
784  SwRects::erase( begin(), begin() + nSz );
785  SwRects::insert( begin(), aReg.begin(), aReg.end() );
786 
787  // If the selection is to the right or at the bottom, outside the
788  // visible area, it is never aligned on one pixel at the right/bottom.
789  // This has to be determined here and if that is the case the
790  // rectangle has to be expanded.
791  if( !(GetShell()->m_bVisPortChgd && 0 != ( nSz = size())) )
792  return;
793 
795  iterator it = begin();
796  for( ; nSz--; ++it )
797  {
798  SwRect& rRectIt = *it;
799  if( rRectIt.Right() == GetShell()->m_aOldRBPos.X() )
800  rRectIt.AddRight( s_nPixPtX );
801  if( rRectIt.Bottom() == GetShell()->m_aOldRBPos.Y() )
802  rRectIt.AddBottom( s_nPixPtY );
803  }
804 }
805 
806 // check current MapMode of the shell and set possibly the static members.
807 // Optional set the parameters pX, pY
809  tools::Long* pX, tools::Long* pY )
810 {
811  const OutputDevice* pOut = rSh.GetWin()->GetOutDev();
812  if ( ! pOut )
813  pOut = rSh.GetOut();
814 
815  const MapMode& rMM = pOut->GetMapMode();
816  if (s_pMapMode->GetMapUnit() != rMM.GetMapUnit() ||
817  s_pMapMode->GetScaleX() != rMM.GetScaleX() ||
818  s_pMapMode->GetScaleY() != rMM.GetScaleY())
819  {
820  *s_pMapMode = rMM;
821  Size aTmp( 1, 1 );
822  aTmp = pOut->PixelToLogic( aTmp );
823  s_nPixPtX = aTmp.Width();
824  s_nPixPtY = aTmp.Height();
825  }
826  if( pX )
827  *pX = s_nPixPtX;
828  if( pY )
829  *pY = s_nPixPtY;
830 }
831 
833  const SwCursorShell& rCShell,
834  const SwPosition &rPos )
835  : SwCursor(rPos,nullptr)
836  , SwSelPaintRects(rCShell)
837  , m_pInitialPoint(SwPaM::GetPoint())
838 {}
839 
841  const SwCursorShell& rCShell,
842  const SwPosition &rPos,
843  const Point& rPtPos,
844  SwPaM* pRing )
845  : SwCursor(rPos, pRing)
846  , SwSelPaintRects(rCShell)
847  , m_MarkPt(rPtPos)
848  , m_PointPt(rPtPos)
849  , m_pInitialPoint(SwPaM::GetPoint())
850 {}
851 
853  : SwCursor(rICursor, &rICursor)
854  , SwSelPaintRects(*rICursor.GetShell())
855  , m_MarkPt(rICursor.GetMkPos())
856  , m_PointPt(rICursor.GetPtPos())
857  , m_pInitialPoint(SwPaM::GetPoint())
858 {}
859 
861 {}
862 
864 {
865  return GetShell()->IsReadOnlyAvailable();
866 }
867 
869 {
872  else
874  SwPaM::SetMark();
875 }
876 
878 {
879  // calculate the new rectangles
880  if( HasMark() &&
881  GetPoint()->nNode.GetNode().IsContentNode() &&
882  GetPoint()->nNode.GetNode().GetContentNode()->getLayoutFrame( GetShell()->GetLayout() ) &&
883  (GetMark()->nNode == GetPoint()->nNode ||
885  GetMark()->nNode.GetNode().GetContentNode()->getLayoutFrame( GetShell()->GetLayout() ) ) ))
886  GetShell()->GetLayout()->CalcFrameRects( *this );
887 }
888 
889 void SwShellCursor::Show(SfxViewShell const * pViewShell)
890 {
891  std::vector<OString> aSelectionRectangles;
892  for(SwPaM& rPaM : GetRingContainer())
893  {
894  SwShellCursor* pShCursor = dynamic_cast<SwShellCursor*>(&rPaM);
895  if(pShCursor)
896  pShCursor->SwSelPaintRects::Show(&aSelectionRectangles);
897  }
898 
900  return;
901 
902  std::vector<OString> aRect;
903  for (const OString & rSelectionRectangle : aSelectionRectangles)
904  {
905  if (rSelectionRectangle.isEmpty())
906  continue;
907  aRect.push_back(rSelectionRectangle);
908  }
909  OString sRect = comphelper::string::join("; ", aRect);
910  if (pViewShell)
911  {
912  // Just notify pViewShell about our existing selection.
913  if (pViewShell != GetShell()->GetSfxViewShell())
914  SfxLokHelper::notifyOtherView(GetShell()->GetSfxViewShell(), pViewShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
915  }
916  else
917  {
918  GetShell()->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
919  SfxLokHelper::notifyOtherViews(GetShell()->GetSfxViewShell(), LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRect);
920  }
921 }
922 
923 // This rectangle gets painted anew, therefore the SSelection in this
924 // area is invalid.
925 void SwShellCursor::Invalidate( const SwRect& rRect )
926 {
927  for(SwPaM& rPaM : GetRingContainer())
928  {
929  SwShellCursor* pShCursor = dynamic_cast<SwShellCursor*>(&rPaM);
930  // skip any non SwShellCursor objects in the ring
931  // see also: SwAutoFormat::DeleteSel()
932  if(pShCursor)
933  pShCursor->SwSelPaintRects::Invalidate(rRect);
934  }
935 }
936 
938 {
939  for(SwPaM& rPaM : GetRingContainer())
940  {
941  SwShellCursor* pShCursor = dynamic_cast<SwShellCursor*>(&rPaM);
942  if(pShCursor)
943  pShCursor->SwSelPaintRects::Hide();
944  }
945 }
946 
948 {
949  return new SwShellCursor( *GetShell(), *GetPoint(), GetPtPos(), pRing );
950 }
951 
953 {
954  short nRet = RET_YES;
956  if( pDlg )
957  {
958  // Terminate old actions. The table-frames get constructed and
959  // a SSelection can be created.
960  std::vector<sal_uInt16> vActionCounts;
961  for(SwViewShell& rShell : const_cast< SwCursorShell* >( GetShell() )->GetRingContainer())
962  {
963  sal_uInt16 nActCnt = 0;
964  while(rShell.ActionPend())
965  {
966  rShell.EndAction();
967  ++nActCnt;
968  }
969  vActionCounts.push_back(nActCnt);
970  }
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();
975  for(SwViewShell& rShell : const_cast< SwCursorShell* >( GetShell() )->GetRingContainer())
976  {
977  while(*pActionCount)
978  {
979  rShell.StartAction();
980  --(*pActionCount);
981  }
982  ++pActionCount;
983  }
984  }
985  else
986  // otherwise from the Basic, and then switch to RET_YES
987  nRet = RET_YES;
988 
989  return nRet;
990 }
991 
993 {
994  const_cast<SwCursorShell*>(GetShell())->SaveTableBoxContent( pPos );
995 }
996 
997 bool SwShellCursor::UpDown( bool bUp, sal_uInt16 nCnt )
998 {
999  return SwCursor::UpDown( bUp, nCnt,
1000  &GetPtPos(), GetShell()->GetUpDownX(),
1001  *GetShell()->GetLayout());
1002 }
1003 
1004 // if <true> than the cursor can be set to the position.
1005 bool SwShellCursor::IsAtValidPos( bool bPoint ) const
1006 {
1007  if( GetShell() && ( GetShell()->IsAllProtect() ||
1008  GetShell()->GetViewOptions()->IsReadonly() ||
1009  ( GetShell()->Imp()->GetDrawView() &&
1010  GetShell()->Imp()->GetDrawView()->GetMarkedObjectList().GetMarkCount() )))
1011  return true;
1012 
1013  return SwCursor::IsAtValidPos( bPoint );
1014 }
1015 
1017  const SwPosition& rPos )
1018  : SwCursor(rPos,nullptr), SwShellCursor(rCursorSh, rPos), SwTableCursor(rPos)
1019 {
1020 }
1021 
1023  const SwPosition& rMkPos, const Point& rMkPt,
1024  const SwPosition& rPtPos, const Point& rPtPt )
1025  : SwCursor(rPtPos,nullptr), SwShellCursor(rCursorSh, rPtPos), SwTableCursor(rPtPos)
1026 {
1027  SetMark();
1028  *GetMark() = rMkPos;
1029  GetMkPos() = rMkPt;
1030  GetPtPos() = rPtPt;
1031 }
1032 
1034 
1036 
1038 {
1039  return SwShellCursor::Create( pRing );
1040 }
1041 
1043 {
1045 }
1046 
1048 {
1050 }
1051 
1053 {
1054  // Calculate the new rectangles. If the cursor is still "parked" do nothing
1056  return;
1057 
1058  bool bStart = true;
1060  ? GetShell()->getIDocumentLayoutAccess().GetCurrentLayout()->getFrameArea()
1061  : GetShell()->VisArea() );
1062  SwNodes& rNds = GetDoc().GetNodes();
1063  SwFrame* pEndFrame = nullptr;
1064  for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
1065  {
1066  const SwStartNode* pSttNd = m_SelectedBoxes[n]->GetSttNd();
1067  const SwTableNode* pSelTableNd = pSttNd->FindTableNode();
1068 
1069  SwNodeIndex aIdx( *pSttNd );
1070  SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
1071 
1072  // table in table
1073  // (see also lcl_FindTopLevelTable in unoobj2.cxx for a different
1074  // version to do this)
1075  const SwTableNode* pCurTableNd = pCNd ? pCNd->FindTableNode() : nullptr;
1076  while ( pSelTableNd != pCurTableNd && pCurTableNd )
1077  {
1078  aIdx = pCurTableNd->EndOfSectionIndex();
1079  pCNd = rNds.GoNextSection( &aIdx, true, false );
1080  pCurTableNd = pCNd->FindTableNode();
1081  }
1082 
1083  if( !pCNd )
1084  continue;
1085 
1086  std::pair<Point, bool> const tmp(GetSttPos(), false);
1087  SwFrame* pFrame = pCNd->getLayoutFrame(GetShell()->GetLayout(), nullptr, &tmp);
1088  while( pFrame && !pFrame->IsCellFrame() )
1089  pFrame = pFrame->GetUpper();
1090 
1091  OSL_ENSURE( pFrame, "Node not in a table" );
1092 
1093  while ( pFrame )
1094  {
1095  if( aReg.GetOrigin().Overlaps( pFrame->getFrameArea() ) )
1096  {
1097  aReg -= pFrame->getFrameArea();
1098  if (bStart)
1099  {
1100  bStart = false;
1101  m_aStart = SwRect(pFrame->getFrameArea().Left(), pFrame->getFrameArea().Top(), 1, pFrame->getFrameArea().Height());
1102  }
1103  }
1104 
1105  pEndFrame = pFrame;
1106  pFrame = pFrame->GetNextCellLeaf();
1107  }
1108  }
1109  if (pEndFrame)
1110  m_aEnd = SwRect(pEndFrame->getFrameArea().Right(), pEndFrame->getFrameArea().Top(), 1, pEndFrame->getFrameArea().Height());
1111  aReg.Invert();
1112  insert( begin(), aReg.begin(), aReg.end() );
1113 }
1114 
1116 {
1117  rStart = m_aStart;
1118  rEnd = m_aEnd;
1119 }
1120 
1121 // Check if the SPoint is within the Table-SSelection.
1122 bool SwShellTableCursor::Contains( const Point& rPt ) const
1123 {
1124  // Calculate the new rectangles. If the cursor is still "parked" do nothing
1126  return false;
1127 
1128  SwNodes& rNds = GetDoc().GetNodes();
1129  for (size_t n = 0; n < m_SelectedBoxes.size(); ++n)
1130  {
1131  SwNodeIndex aIdx( *m_SelectedBoxes[n]->GetSttNd() );
1132  SwContentNode* pCNd = rNds.GoNextSection( &aIdx, true, false );
1133  if( !pCNd )
1134  continue;
1135 
1136  std::pair<Point, bool> const tmp(GetPtPos(), true);
1137  SwFrame* pFrame = pCNd->getLayoutFrame(GetShell()->GetLayout(), nullptr, &tmp);
1138  while( pFrame && !pFrame->IsCellFrame() )
1139  pFrame = pFrame->GetUpper();
1140  OSL_ENSURE( pFrame, "Node not in a table" );
1141  if( pFrame && pFrame->getFrameArea().Contains( rPt ) )
1142  return true;
1143 
1144  for ( SwCellFrame* pCellFrame = static_cast<SwCellFrame*>(pFrame); pCellFrame; pCellFrame = pCellFrame->GetFollowCell() )
1145  {
1146  if( pCellFrame->getFrameArea().Contains( rPt ) )
1147  return true;
1148  }
1149  }
1150  return false;
1151 }
1152 
1153 bool SwShellTableCursor::IsAtValidPos( bool bPoint ) const
1154 {
1155  return SwShellCursor::IsAtValidPos( bPoint );
1156 }
1157 
1158 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool m_bIsVisible
Definition: viscrs.hxx:49
vcl::RenderContext * GetOut() const
Definition: viewsh.hxx:339
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:401
const Fraction & GetScaleX() const
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:1042
Starts a section of nodes in the document model.
Definition: node.hxx:313
Base class of the Writer layout elements.
Definition: frame.hxx:314
Represents the visualization of a paragraph.
Definition: txtfrm.hxx:162
static void notifyOtherViews(const SfxViewShell *pThisView, int nType, std::string_view rKey, const OString &rPayload)
void Right(const tools::Long nRight)
Definition: swrect.hxx:202
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:687
Marks a position in the document model.
Definition: pam.hxx:36
const SwRect & GetOrigin() const
Definition: swregion.hxx:62
const SwPosition * m_pInitialPoint
Definition: viscrs.hxx:133
void SetOrientation(Degree10 nOrientation=0_deg10)
SdrView * GetDrawView()
Definition: vnew.cxx:373
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
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
Definition: viscrs.cxx:1005
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()
Definition: doc.hxx:1351
std::shared_ptr< SwContentControl > GetContentControl()
void Left(const tools::Long nLeft)
Definition: swrect.hxx:197
SwNodeIndex nNode
Definition: pam.hxx:38
static void notifyUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
SwShellCursor * getShellCursor(bool bBlock)
Delivers the current shell cursor.
Definition: crsrsh.cxx:3048
sal_uInt16 GetStyle() const
SdrTextObj * GetTextEditObject() const
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:1047
long Long
void disposeAndClear()
const StyleSettings & GetStyleSettings() const
const SfxPoolItem * pAttr
Definition: crsrsh.hxx:102
const SwPosition * GetMark() const
Definition: pam.hxx:210
ScopedJsonWriterArray startArray(const char *)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1210
sal_Int64 n
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:868
static SvxSearchDialog * GetSearchDialog()
Definition: viewsrch.cxx:820
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:1037
sal_uInt8 GetCursorBidiLevel() const
Definition: swcrsr.hxx:211
void HighlightContentControl()
Definition: viscrs.cxx:638
const Point & GetSttPos() const
Definition: viscrs.hxx:157
const MapMode & GetMapMode() const
SwNode & GetNode() const
Definition: ndindex.hxx:128
SwRect m_aEnd
Right edge of the selection end (bottom right cell).
Definition: viscrs.hxx:187
SwTextNode * GetpTextNode() const
Definition: txtfld.hxx:49
void Pos(const Point &rNew)
Definition: swrect.hxx:171
bool IsCellFrame() const
Definition: frame.hxx:1226
VclPtr< SwContentControlButton > m_pContentControlButton
Definition: viscrs.hxx:90
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:446
SwTextAttr * GetTextAttrAt(sal_Int32 const nIndex, sal_uInt16 const nWhich, enum GetTextAttrMode const eMode=DEFAULT) const
get the innermost text attribute covering position nIndex.
Definition: ndtxt.cxx:1746
void Hide()
Definition: viscrs.cxx:937
virtual bool IsAtValidPos(bool bPoint=true) const override
Return if cursor can be set to this position.
Definition: viscrs.cxx:1153
bool IsSymbolAt(sal_Int32 nBegin) const
in ndcopy.cxx
Definition: itratr.cxx:856
virtual void SaveTableBoxContent(const SwPosition *pPos) override
Definition: viscrs.cxx:992
SwWrtShell & GetWrtShell() const
Definition: view.hxx:413
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:775
bool m_bShowTextInputFieldOverlay
Definition: viscrs.hxx:86
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pContentControlOverlay
Definition: viscrs.hxx:89
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.
Definition: trvlfrm.cxx:425
const OUString & GetValue() const
Definition: fmtinfmt.hxx:75
char * extractData()
RET_YES
Point m_PointPt
Definition: viscrs.hxx:132
void SwAlignRect(SwRect &rRect, const SwViewShell *pSh, const vcl::RenderContext *pRenderContext)
Function is also used outside this file.
Definition: paintfrm.cxx:1126
SwIndex nContent
Definition: pam.hxx:39
enumrange< T >::Iterator begin(enumrange< T >)
const SwRect & getFrameArea() const
Definition: frame.hxx:179
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.
Definition: txatbase.hxx:43
void CalcFrameRects(SwShellCursor &)
Definition: trvlfrm.cxx:2008
static SfxViewShell * Current()
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
sal_Int32 GetStart() const
Definition: txatbase.hxx:88
void Invert()
invert current rectangle
Definition: swregion.cxx:126
oslFileHandle & pOut
virtual void FillRects() override
Definition: viscrs.cxx:1052
SwShellTableCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:1016
void Width(tools::Long nNew)
Definition: swrect.hxx:189
#define CURSOR_SHADOW
OUString sStr
Definition: crsrsh.hxx:109
OString getLOKPayload(int nType, int nViewId, bool *ignore) const
Definition: viscrs.cxx:518
Point m_aOldRBPos
Right/Bottom of last VisArea.
Definition: crsrsh.hxx:172
union SwContentAtPos::@24 aFnd
virtual void FillRects() override
Definition: viscrs.cxx:877
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:161
void SetStyle(sal_uInt16 nStyle)
virtual short MaxReplaceArived() override
Definition: viscrs.cxx:952
void Show(SfxViewShell const *pViewShell)
Definition: viscrs.cxx:889
size_type size() const
void Invalidate(const SwRect &rRect)
Definition: viscrs.cxx:925
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()
Definition: findfrm.cxx:1579
virtual bool GetCharRect(SwRect &, const SwPosition &, SwCursorMoveState *=nullptr, bool bAllowFarAway=true) const
Definition: unusedf.cxx:72
constexpr TypedWhichId< SwFormatINetFormat > RES_TXTATR_INETFMT(51)
SfxItemPool & GetPool() const
sal_uInt32 PaintWindowCount() const
SwShellCursor * GetCursor_()
Definition: crsrsh.hxx:333
static MapMode * s_pMapMode
Definition: viscrs.hxx:78
SwVisibleCursor(const SwCursorShell *pCShell)
Definition: viscrs.cxx:76
bool IsContentNode() const
Definition: node.hxx:638
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
bool m_bShowContentControlOverlay
Definition: viscrs.hxx:88
bool IsSelection() const
Definition: crsrsh.hxx:888
virtual ~SwShellTableCursor() override
Definition: viscrs.cxx:1033
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:80
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:118
SwShellCursor(const SwCursorShell &rCursorSh, const SwPosition &rPos)
Definition: viscrs.cxx:832
void SetPosAndShow(SfxViewShell const *pViewShell)
Definition: viscrs.cxx:134
Shell * GetShell()
void DecreaseLuminance(sal_uInt8 cLumDec)
int i
const SwRect & VisArea() const
Definition: viewsh.cxx:630
uno_Any a
SwDoc & GetDoc()
Definition: node.hxx:213
const SwPosition * GetPoint() const
Definition: pam.hxx:208
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:59
bool UpDown(bool bUp, sal_uInt16 nCnt)
Definition: viscrs.cxx:997
void AddBottom(const tools::Long nAdd)
Definition: swrect.cxx:130
bool Contains(const Point &rPt) const
Definition: viscrs.cxx:1122
const SwFormatContentControl & GetContentControl() const
Definition: txatbase.hxx:220
SwContentNode * GetContentNode()
Definition: node.hxx:625
SwNodeOffset GetIndex() const
Definition: node.hxx:292
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
virtual ~SwShellCursor() override
Definition: viscrs.cxx:860
bool HasArea() const
Definition: swrect.hxx:300
void SetWindow(vcl::Window *pWindow)
SwGrammarMarkUp * GetGrammarCheck()
Definition: txtedt.cxx:2257
void HighlightInputField()
Definition: viscrs.cxx:578
static void notifyOtherViewsUpdatePerViewId(SfxViewShell const *pViewShell, int nType)
bool IsCursorReadonly() const
Definition: crsrsh.cxx:3302
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:1115
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:1035
SwWrtShell * GetWrtShell()
Access to the SwWrtShell belonging to SwView.
Definition: docsh.hxx:225
const Point & GetMkPos() const
Definition: viscrs.hxx:155
size
Marks a node in the document model.
Definition: ndindex.hxx:30
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1997
void SetSize(const Size &rNewSize)
T static_txtattr_cast(S *s)
Definition: txatbase.hxx:257
const AllSettings & GetSettings() const
bool IsOverwriteCursor() const
Definition: crsrsh.hxx:464
ring_container GetRingContainer()
MapUnit GetMapUnit() const
bool IsOnlineSpell() const
Definition: viewopt.hxx:371
void AddRight(const tools::Long nAdd)
Definition: swrect.cxx:127
bool empty() const
void SSize(const Size &rNew)
Definition: swrect.hxx:180
void Show(std::vector< OString > *pSelectionRectangles=nullptr)
Definition: viscrs.cxx:420
SwCellFrame * GetFollowCell() const
Definition: findfrm.cxx:1647
stay with the cursor inside text
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
enumrange< T >::Iterator end(enumrange< T >)
const SwPosition * Start() const
Definition: pam.hxx:213
void put(const char *pPropName, const OUString &rPropValue)
EXPAND : (Start < nIndex <= End)
Definition: ndtxt.hxx:371
bool Contains(const Point &rPOINT) const
Definition: swrect.hxx:356
bool IsInProtectSect() const
Is node in a protected area?
Definition: node.cxx:417
OString getLOKPayload(int nType, int nViewId, bool *ignore) const
Definition: viscrs.cxx:273
SwSelPaintRects(const SwCursorShell &rCSh)
Definition: viscrs.cxx:353
SwRect m_aLastLOKRect
Definition: viscrs.hxx:47
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
virtual void FillStartEnd(SwRect &rStart, SwRect &rEnd) const override
Definition: viscrs.cxx:413
virtual ~SwSelPaintRects()
Definition: viscrs.cxx:362
static void Get1PixelInLogic(const SwViewShell &rSh, tools::Long *pX=nullptr, tools::Long *pY=nullptr)
Definition: viscrs.cxx:808
virtual void FillRects()=0
void Bottom(const tools::Long nBottom)
Definition: swrect.hxx:211
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
SwSelBoxes m_SelectedBoxes
Definition: swcrsr.hxx:261
std::vector< SwRect > SwRects
Definition: swregion.hxx:26
constexpr TypedWhichId< SwFormatContentControl > RES_TXTATR_CONTENTCONTROL(56)
bool IsReadOnlyAvailable() const
Definition: crsrsh.hxx:479
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:414
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
Point m_aCursorHeight
height & offset from visible Cursor
Definition: crsrsh.hxx:171
bool m_bIsDragCursor
Definition: viscrs.hxx:50
constexpr tools::Long Height() const
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:428
void SetCursor(vcl::Cursor *pCursor)
vcl::Window * GetWin() const
Definition: viewsh.hxx:338
vcl::Cursor m_aTextCursor
Definition: viscrs.hxx:43
SwTextAttr subclass that tracks the location of the wrapped SwFormatContentControl.
OUString GetSelText() const
get selected text of a node at current cursor
Definition: crsrsh.cxx:2552
sal_Int32 GetCursorSize() const
size_t CountDirChg() const
Definition: scriptinfo.hxx:139
sal_Int32 GetIndex() const
Definition: index.hxx:91
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:102
::OutputDevice const * GetOutDev() const
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
SwNodes & GetNodes()
Definition: doc.hxx:408
bool m_bParked
Definition: swcrsr.hxx:263
std::u16string_view trim(std::u16string_view str)
static tools::Long s_nPixPtY
Definition: viscrs.hxx:77
static VclPtr< reference_type > Create(Arg &&...arg)
const SwPosition * End() const
Definition: pam.hxx:218
bool IsRightToLeft() const
Definition: frame.hxx:987
void Top(const tools::Long nTop)
Definition: swrect.hxx:206
SwPostItMgr * GetPostItMgr()
Definition: view.hxx:639
const sal_Int32 * End() const
Definition: txatbase.hxx:156
virtual SwCursor * Create(SwPaM *pRing=nullptr) const override
Definition: viscrs.cxx:947
const Point & GetPtPos() const
Definition: viscrs.hxx:153
SwWrongList * GetWrong()
Definition: txtedt.cxx:2229
static tools::Long s_nPixPtX
Definition: viscrs.hxx:77
bool GetCurAttr(SfxItemSet &, const bool bMergeIndentValuesOfNumRule=false) const
Definition: edattr.cxx:171
void putSimpleValue(const OUString &rPropValue)
static OString makeVisCursorInvalidation(int nViewId, const OString &rRectangle, bool bMispelledWord=false, const OString &rHyperlink="")
bool IsVisible() const
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
void Show()
Definition: viscrs.cxx:94
virtual bool IsAtValidPos(bool bPoint=true) const
Return if cursor can be set to this position.
Definition: swcrsr.cxx:720
static void notifyUpdate(SfxViewShell const *pViewShell, int nType)
const std::shared_ptr< SwContentControl > & GetContentControl() const
const Point & GetEndPos() const
Definition: viscrs.hxx:159
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).
Definition: viscrs.hxx:185
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:1919
SwDoc & GetDoc() const
Definition: pam.hxx:244
sal_uInt16 m_nPageLastTime
For LibreOfficeKit only - remember what page we were at the last time.
Definition: viscrs.hxx:46
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:476
const SwCursorShell * m_pCursorShell
Definition: viscrs.hxx:42
virtual bool IsReadOnlyAvailable() const override
Definition: viscrs.cxx:863
SwRect m_aCharRect
Char-SRectangle on which the cursor is located.
Definition: crsrsh.hxx:170
Point m_MarkPt
Definition: viscrs.hxx:131
rtl::OString toString() const
const vcl::Cursor & GetTextCursor() const
Definition: viscrs.cxx:348
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2172
void swapContent(SwSelPaintRects &rSwap)
Definition: viscrs.cxx:368
void SetDirection(CursorDirection nDirection=CursorDirection::NONE)
bool IsTextNode() const
Definition: node.hxx:646
void Height(tools::Long nNew)
Definition: swrect.hxx:193
std::unique_ptr< sw::overlay::OverlayRangesOutline > m_pTextInputFieldOverlay
Definition: viscrs.hxx:87
bool Overlaps(const SwRect &rRect) const
Definition: swrect.hxx:374
SdrPaintWindow * GetPaintWindow(sal_uInt32 nIndex) const
void SetWidth(tools::Long nNewWidth)
SwCellFrame is one table cell in the document layout.
Definition: cellfrm.hxx:30
Definition: view.hxx:144
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.
Definition: ndtxt.hxx:864
bool IsSelectionInReadonly() const
Definition: viewopt.hxx:466
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
static SwTextField * GetTextFieldAtPos(const SwPosition *pPos, const bool bIncludeInputFieldAtStart)
Definition: crstrvl.cxx:926
Base class of the Writer document model elements.
Definition: node.hxx:81