android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / uibase / docvw / edtwin2.cxx
blobbafd9570a726da6e2425a146e1fd95243bea8b1f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <doc.hxx>
21 #include <osl/diagnose.h>
22 #include <osl/thread.h>
23 #include <vcl/help.hxx>
24 #include <tools/urlobj.hxx>
25 #include <fmtrfmrk.hxx>
26 #include <svl/urihelper.hxx>
27 #include <sfx2/sfxhelp.hxx>
28 #include <svx/svdview.hxx>
29 #include <svx/svdpagv.hxx>
30 #include <swmodule.hxx>
31 #include <modcfg.hxx>
32 #include <view.hxx>
33 #include <wrtsh.hxx>
34 #include <docsh.hxx>
35 #include <edtwin.hxx>
36 #include <dpage.hxx>
37 #include <docufld.hxx>
38 #include <reffld.hxx>
39 #include <cellatr.hxx>
40 #include <shdwcrsr.hxx>
41 #include <fmtinfmt.hxx>
42 #include <fmtftn.hxx>
43 #include <redline.hxx>
44 #include <tox.hxx>
45 #include <txatbase.hxx>
46 #include <uitool.hxx>
47 #include <viewopt.hxx>
48 #include <strings.hrc>
50 #include <IDocumentMarkAccess.hxx>
51 #include <IDocumentRedlineAccess.hxx>
52 #include <txtfrm.hxx>
53 #include <ndtxt.hxx>
54 #include <comphelper/lok.hxx>
55 #include <authfld.hxx>
57 #include <com/sun/star/text/XTextRange.hpp>
58 #include <unotextrange.hxx>
59 #include <SwStyleNameMapper.hxx>
60 #include <unoprnms.hxx>
61 #include <editeng/unoprnms.hxx>
62 #include <rootfrm.hxx>
63 #include <unomap.hxx>
64 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
66 namespace {
68 bool HasValidPropertyValue(const uno::Any& rAny)
70 if (bool bValue; rAny >>= bValue)
72 return true;
74 else if (OUString aValue; (rAny >>= aValue) && !(aValue.isEmpty()))
76 return true;
78 else if (awt::FontSlant eValue; rAny >>= eValue)
80 return true;
82 else if (tools::Long nValueLong; rAny >>= nValueLong)
84 return true;
86 else if (double fValue; rAny >>= fValue)
88 return true;
90 else if (short nValueShort; rAny >>= nValueShort)
92 return true;
94 else
95 return false;
98 bool PSCSDFPropsQuickHelp(const HelpEvent &rEvt, SwWrtShell& rSh)
100 OUString sText;
101 SwView& rView = rSh.GetView();
103 if (rView.IsHighlightCharDF() || rView.GetStylesHighlighterParaColorMap().size()
104 || rView.GetStylesHighlighterCharColorMap().size())
106 SwPosition aPos(rSh.GetDoc()->GetNodes());
107 Point aPt(rSh.GetWin()->PixelToLogic(
108 rSh.GetWin()->ScreenToOutputPixel(rEvt.GetMousePosPixel())));
110 rSh.GetLayout()->GetModelPositionForViewPoint(&aPos, aPt);
112 if (!aPos.GetContentNode()->IsTextNode())
113 return false;
115 uno::Reference<text::XTextRange> xRange(
116 SwXTextRange::CreateXTextRange(*(rView.GetDocShell()->GetDoc()),
117 aPos, &aPos));
118 uno::Reference<beans::XPropertySet> xPropertySet(xRange, uno::UNO_QUERY_THROW);
120 SwContentFrame* pContentFrame = aPos.GetContentNode()->GetTextNode()->getLayoutFrame(
121 rSh.GetLayout());
123 SwRect aFrameAreaRect;
125 bool bContainsPt = false;
128 aFrameAreaRect = pContentFrame->getFrameArea();
129 if (aFrameAreaRect.Contains(aPt))
131 bContainsPt = true;
132 break;
134 } while((pContentFrame = pContentFrame->GetFollow()));
136 if (bContainsPt)
138 if (rView.GetStylesHighlighterCharColorMap().size())
140 // check if in CS formatting highlighted area
141 OUString sCharStyle;
142 xPropertySet->getPropertyValue("CharStyleName") >>= sCharStyle;
143 if (!sCharStyle.isEmpty())
144 sText = SwStyleNameMapper::GetUIName(sCharStyle, SwGetPoolIdFromName::ChrFmt);
147 if (sText.isEmpty() && rView.IsHighlightCharDF())
149 // check if in direct formatting highlighted area
150 const std::vector<OUString> aHiddenProperties{ UNO_NAME_RSID,
151 UNO_NAME_PARA_IS_NUMBERING_RESTART,
152 UNO_NAME_PARA_STYLE_NAME,
153 UNO_NAME_PARA_CONDITIONAL_STYLE_NAME,
154 UNO_NAME_PAGE_STYLE_NAME,
155 UNO_NAME_NUMBERING_START_VALUE,
156 UNO_NAME_NUMBERING_IS_NUMBER,
157 UNO_NAME_PARA_CONTINUEING_PREVIOUS_SUB_TREE,
158 UNO_NAME_CHAR_STYLE_NAME,
159 UNO_NAME_NUMBERING_LEVEL,
160 UNO_NAME_SORTED_TEXT_ID,
161 UNO_NAME_PARRSID,
162 UNO_NAME_CHAR_COLOR_THEME,
163 UNO_NAME_CHAR_COLOR_TINT_OR_SHADE };
165 SfxItemPropertySet const& rPropSet(
166 *aSwMapProvider.GetPropertySet(PROPERTY_MAP_CHAR_AUTO_STYLE));
167 SfxItemPropertyMap const& rMap(rPropSet.getPropertyMap());
169 uno::Reference<beans::XPropertyState> xPropertiesState(xRange, uno::UNO_QUERY_THROW);
170 const uno::Sequence<beans::Property> aProperties
171 = xPropertySet->getPropertySetInfo()->getProperties();
173 for (const beans::Property& rProperty : aProperties)
175 const OUString& rPropName = rProperty.Name;
177 if (!rMap.hasPropertyByName(rPropName))
178 continue;
180 if (std::find(aHiddenProperties.begin(), aHiddenProperties.end(), rPropName)
181 != aHiddenProperties.end())
182 continue;
184 if (xPropertiesState->getPropertyState(rPropName)
185 == beans::PropertyState_DIRECT_VALUE)
187 const uno::Any aAny = xPropertySet->getPropertyValue(rPropName);
188 if (HasValidPropertyValue(aAny))
190 sText = SwResId(STR_CHARACTER_DIRECT_FORMATTING);
191 break;
197 else if (rView.GetStylesHighlighterParaColorMap().size())
199 // check if in paragraph style formatting highlighted area
200 pContentFrame = aPos.GetContentNode()->GetTextNode()->getLayoutFrame(
201 rSh.GetLayout());
204 aFrameAreaRect = pContentFrame->getFrameArea();
205 if (pContentFrame->IsRightToLeft())
207 aFrameAreaRect.AddRight(375);
208 aFrameAreaRect.Left(aFrameAreaRect.Right() - 300);
210 else
212 aFrameAreaRect.AddLeft(-375);
213 aFrameAreaRect.Right(aFrameAreaRect.Left() + 300);
215 if (aFrameAreaRect.Contains(aPt))
217 OUString sParaStyle;
218 xPropertySet->getPropertyValue("ParaStyleName") >>= sParaStyle;
219 sText = SwStyleNameMapper::GetUIName(sParaStyle, SwGetPoolIdFromName::TxtColl);
220 // check for paragraph direct formatting
221 if (SwDoc::HasParagraphDirectFormatting(aPos))
222 sText = sText + " + " + SwResId(STR_PARAGRAPH_DIRECT_FORMATTING);
223 break;
225 } while((pContentFrame = pContentFrame->GetFollow()));
229 if (!sText.isEmpty())
231 tools::Rectangle aRect(rSh.GetWin()->PixelToLogic(
232 rSh.GetWin()->ScreenToOutputPixel(rEvt.GetMousePosPixel())),
233 Size(1, 1));
234 Point aPt(rSh.GetWin()->OutputToScreenPixel(rSh.GetWin()->LogicToPixel(aRect.TopLeft())));
235 aRect.SetLeft(aPt.X());
236 aRect.SetTop(aPt.Y());
237 aPt = rSh.GetWin()->OutputToScreenPixel(rSh.GetWin()->LogicToPixel(aRect.BottomRight()));
238 aRect.SetRight(aPt.X());
239 aRect.SetBottom(aPt.Y());
241 // tdf#136336 ensure tooltip area surrounds the current mouse position with at least a pixel margin
242 aRect.Union(tools::Rectangle(rEvt.GetMousePosPixel(), Size(1, 1)));
243 aRect.AdjustLeft(-1);
244 aRect.AdjustRight(1);
245 aRect.AdjustTop(-1);
246 aRect.AdjustBottom(1);
248 QuickHelpFlags nStyle = QuickHelpFlags::NONE; //TipStyleBalloon;
249 Help::ShowQuickHelp(rSh.GetWin(), aRect, sText, nStyle);
252 return !sText.isEmpty();
256 static OUString lcl_GetRedlineHelp( const SwRangeRedline& rRedl, bool bBalloon,
257 bool bTableChange, bool bTableColChange )
259 TranslateId pResId;
260 switch( rRedl.GetType() )
262 case RedlineType::Insert: pResId = bTableChange
263 ? !bTableColChange
264 ? STR_REDLINE_TABLE_ROW_INSERT
265 : STR_REDLINE_TABLE_COLUMN_INSERT
266 : rRedl.IsMoved()
267 ? STR_REDLINE_INSERT_MOVED
268 : STR_REDLINE_INSERT;
269 break;
270 case RedlineType::Delete: pResId = bTableChange
271 ? !bTableColChange
272 ? STR_REDLINE_TABLE_ROW_DELETE
273 : STR_REDLINE_TABLE_COLUMN_DELETE
274 : rRedl.IsMoved()
275 ? STR_REDLINE_DELETE_MOVED
276 : STR_REDLINE_DELETE;
277 break;
278 case RedlineType::Format: pResId = STR_REDLINE_FORMAT; break;
279 case RedlineType::Table: pResId = STR_REDLINE_TABLE; break;
280 case RedlineType::FmtColl: pResId = STR_REDLINE_FMTCOLL; break;
281 case RedlineType::ParagraphFormat: pResId = STR_REDLINE_PARAGRAPH_FORMAT; break;
282 case RedlineType::TableRowInsert: pResId = STR_REDLINE_TABLE_ROW_INSERT; break;
283 case RedlineType::TableRowDelete: pResId = STR_REDLINE_TABLE_ROW_DELETE; break;
284 case RedlineType::TableCellInsert: pResId = STR_REDLINE_TABLE_CELL_INSERT; break;
285 case RedlineType::TableCellDelete: pResId = STR_REDLINE_TABLE_CELL_DELETE; break;
286 default: break;
289 if (!pResId)
290 return OUString();
291 OUStringBuffer sBuf(SwResId(pResId)
292 + ": "
293 + rRedl.GetAuthorString()
294 + " - "
295 + GetAppLangDateTimeString(rRedl.GetTimeStamp()));
296 if( bBalloon && !rRedl.GetComment().isEmpty() )
297 sBuf.append("\n" + rRedl.GetComment());
298 return sBuf.makeStringAndClear();
301 OUString SwEditWin::ClipLongToolTip(const OUString& rText)
303 OUString sDisplayText(rText);
304 tools::Long nTextWidth = GetTextWidth(sDisplayText);
305 tools::Long nMaxWidth = GetDesktopRectPixel().GetWidth() * 2 / 3;
306 nMaxWidth = PixelToLogic(Size(nMaxWidth, 0)).Width();
307 if (nTextWidth > nMaxWidth)
308 sDisplayText = GetOutDev()->GetEllipsisString(sDisplayText, nMaxWidth, DrawTextFlags::CenterEllipsis);
309 return sDisplayText;
312 void SwEditWin::RequestHelp(const HelpEvent &rEvt)
314 SwWrtShell &rSh = m_rView.GetWrtShell();
316 if (PSCSDFPropsQuickHelp(rEvt, rSh))
317 return;
319 bool bQuickBalloon = bool(rEvt.GetMode() & ( HelpEventMode::QUICK | HelpEventMode::BALLOON ));
320 if(bQuickBalloon && !rSh.GetViewOptions()->IsShowContentTips())
321 return;
322 bool bContinue = true;
323 CurrShell aCurr(&rSh);
324 OUString sText;
325 Point aPos( PixelToLogic( ScreenToOutputPixel( rEvt.GetMousePosPixel() ) ));
326 bool bBalloon = bool(rEvt.GetMode() & HelpEventMode::BALLOON);
328 SdrView *pSdrView = rSh.GetDrawView();
330 if( bQuickBalloon && pSdrView )
332 SdrPageView* pPV = pSdrView->GetSdrPageView();
333 SwDPage* pPage = pPV ? static_cast<SwDPage*>(pPV->GetPage()) : nullptr;
334 bContinue = pPage && pPage->RequestHelp(this, pSdrView, rEvt);
337 if( bContinue && bQuickBalloon)
339 SwRect aFieldRect;
340 SwContentAtPos aContentAtPos( IsAttrAtPos::Field |
341 IsAttrAtPos::InetAttr |
342 IsAttrAtPos::Ftn |
343 IsAttrAtPos::Redline |
344 IsAttrAtPos::ToxMark |
345 IsAttrAtPos::RefMark |
346 IsAttrAtPos::SmartTag |
347 #ifdef DBG_UTIL
348 IsAttrAtPos::TableBoxValue |
349 ( bBalloon ? IsAttrAtPos::CurrAttrs : IsAttrAtPos::NONE) |
350 #endif
351 IsAttrAtPos::TableBoxFml |
352 IsAttrAtPos::TableRedline |
353 IsAttrAtPos::TableColRedline );
355 if( rSh.GetContentAtPos( aPos, aContentAtPos, false, &aFieldRect ) )
357 QuickHelpFlags nStyle = QuickHelpFlags::NONE; // style of quick help
358 switch( aContentAtPos.eContentAtPos )
360 case IsAttrAtPos::TableBoxFml:
361 sText = "= " + static_cast<const SwTableBoxFormula*>(aContentAtPos.aFnd.pAttr)->GetFormula();
362 break;
363 #ifdef DBG_UTIL
364 case IsAttrAtPos::TableBoxValue:
366 if(aContentAtPos.aFnd.pAttr)
368 sText = OUString::number(
369 static_cast<const SwTableBoxValue*>(aContentAtPos.aFnd.pAttr)->GetValue());
371 break;
373 case IsAttrAtPos::CurrAttrs:
374 sText = aContentAtPos.sStr;
375 break;
376 #endif
378 case IsAttrAtPos::InetAttr:
380 sText = static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr)->GetValue();
381 sText = URIHelper::removePassword( sText,
382 INetURLObject::EncodeMechanism::WasEncoded,
383 INetURLObject::DecodeMechanism::Unambiguous);
384 //#i63832# remove the link target type
385 sal_Int32 nFound = sText.indexOf(cMarkSeparator);
386 if( nFound != -1 && (++nFound) < sText.getLength() )
388 std::u16string_view sSuffix( sText.subView(nFound) );
389 if( sSuffix == u"table" ||
390 sSuffix == u"frame" ||
391 sSuffix == u"region" ||
392 sSuffix == u"outline" ||
393 sSuffix == u"text" ||
394 sSuffix == u"graphic" ||
395 sSuffix == u"ole" ||
396 sSuffix == u"drawingobject" )
397 sText = sText.copy( 0, nFound - 1);
399 // #i104300#
400 // special handling if target is a cross-reference bookmark
402 OUString sTmpSearchStr = sText.copy( 1 );
403 IDocumentMarkAccess* pMarkAccess = rSh.getIDocumentMarkAccess();
404 IDocumentMarkAccess::const_iterator_t ppBkmk =
405 pMarkAccess->findBookmark( sTmpSearchStr );
406 if ( ppBkmk != pMarkAccess->getBookmarksEnd() &&
407 IDocumentMarkAccess::GetType(**ppBkmk)
408 == IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK )
410 SwTextNode* pTextNode = (*ppBkmk)->GetMarkStart().GetNode().GetTextNode();
411 if ( pTextNode )
413 sText = sw::GetExpandTextMerged(rSh.GetLayout(), *pTextNode, true, false, ExpandMode(0));
415 if( !sText.isEmpty() )
417 OUStringBuffer sTmp(sText.replaceAll(u"\u00ad", ""));
418 for (sal_Int32 i = 0; i < sTmp.getLength(); ++i)
420 if (sTmp[i] < 0x20)
421 sTmp[i] = 0x20;
422 else if (sTmp[i] == 0x2011)
423 sTmp[i] = '-';
425 sText = sTmp.makeStringAndClear();
430 // #i80029#
431 bool bExecHyperlinks = m_rView.GetDocShell()->IsReadOnly();
432 if ( !bExecHyperlinks )
434 sText = SfxHelp::GetURLHelpText(sText);
436 break;
438 case IsAttrAtPos::SmartTag:
440 vcl::KeyCode aCode( KEY_SPACE );
441 vcl::KeyCode aModifiedCode( KEY_SPACE, KEY_MOD1 );
442 OUString aModStr( aModifiedCode.GetName() );
443 aModStr = aModStr.replaceFirst(aCode.GetName(), "");
444 aModStr = aModStr.replaceAll("+", "");
445 sText = SwResId(STR_SMARTTAG_CLICK).replaceAll("%s", aModStr);
446 break;
449 case IsAttrAtPos::Ftn:
450 if( aContentAtPos.pFndTextAttr && aContentAtPos.aFnd.pAttr )
452 const SwFormatFootnote* pFootnote = static_cast<const SwFormatFootnote*>(aContentAtPos.aFnd.pAttr);
453 OUString sTmp(pFootnote->GetFootnoteText(*rSh.GetLayout()));
454 sText = SwResId( pFootnote->IsEndNote()
455 ? STR_ENDNOTE : STR_FTNNOTE ) + sTmp;
456 bBalloon = true;
457 if( aContentAtPos.IsInRTLText() )
458 nStyle |= QuickHelpFlags::BiDiRtl;
460 break;
462 case IsAttrAtPos::TableRedline:
463 case IsAttrAtPos::TableColRedline:
464 case IsAttrAtPos::Redline:
466 const bool bShowTrackChanges = IDocumentRedlineAccess::IsShowChanges( m_rView.GetDocShell()->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags() );
467 const bool bShowInlineTooltips = rSh.GetViewOptions()->IsShowInlineTooltips();
468 if ( bShowTrackChanges && bShowInlineTooltips )
470 sText = lcl_GetRedlineHelp(*aContentAtPos.aFnd.pRedl, bBalloon,
471 IsAttrAtPos::TableRedline == aContentAtPos.eContentAtPos ||
472 IsAttrAtPos::TableColRedline == aContentAtPos.eContentAtPos,
473 IsAttrAtPos::TableColRedline == aContentAtPos.eContentAtPos);
475 break;
478 case IsAttrAtPos::ToxMark:
479 sText = aContentAtPos.sStr;
480 if( !sText.isEmpty() && aContentAtPos.pFndTextAttr )
482 const SwTOXType* pTType = aContentAtPos.pFndTextAttr->
483 GetTOXMark().GetTOXType();
484 if( pTType && !pTType->GetTypeName().isEmpty() )
486 sText = ": " + sText;
487 sText = pTType->GetTypeName() + sText;
490 break;
492 case IsAttrAtPos::RefMark:
493 if(aContentAtPos.aFnd.pAttr)
495 sText = SwResId(STR_CONTENT_TYPE_SINGLE_REFERENCE) + ": " +
496 static_cast<const SwFormatRefMark*>(aContentAtPos.aFnd.pAttr)->GetRefName();
498 break;
500 default:
502 SwModuleOptions* pModOpt = SW_MOD()->GetModuleConfig();
503 if(!pModOpt->IsHideFieldTips())
505 const SwField* pField = aContentAtPos.aFnd.pField;
506 switch( pField->Which() )
508 case SwFieldIds::SetExp:
509 case SwFieldIds::Table:
510 case SwFieldIds::GetExp:
512 sal_uInt16 nOldSubType = pField->GetSubType();
513 const_cast<SwField*>(pField)->SetSubType(nsSwExtendedSubType::SUB_CMD);
514 sText = pField->ExpandField(true, rSh.GetLayout());
515 const_cast<SwField*>(pField)->SetSubType(nOldSubType);
517 break;
519 case SwFieldIds::Postit:
521 break;
523 case SwFieldIds::Input: // BubbleHelp, because the suggestion could be quite long
524 bBalloon = true;
525 [[fallthrough]];
526 case SwFieldIds::Dropdown:
527 case SwFieldIds::JumpEdit:
528 sText = pField->GetPar2();
529 break;
531 case SwFieldIds::Database:
532 sText = pField->GetFieldName();
533 break;
535 case SwFieldIds::User:
537 OUString aTitle = pField->GetTitle();
538 if (!aTitle.isEmpty())
540 sText = aTitle;
542 else
544 sText = pField->GetPar1();
546 break;
548 case SwFieldIds::HiddenText:
549 sText = pField->GetPar1();
550 break;
552 case SwFieldIds::DocStat:
553 break;
555 case SwFieldIds::Macro:
556 sText = static_cast<const SwMacroField*>(pField)->GetMacro();
557 break;
559 case SwFieldIds::GetRef:
561 // #i85090#
562 const SwGetRefField* pRefField( dynamic_cast<const SwGetRefField*>(pField) );
563 OSL_ENSURE( pRefField,
564 "<SwEditWin::RequestHelp(..)> - unexpected type of <pField>" );
565 if ( pRefField )
567 if ( pRefField->IsRefToHeadingCrossRefBookmark() ||
568 pRefField->IsRefToNumItemCrossRefBookmark() )
570 sText = pRefField->GetExpandedTextOfReferencedTextNode(*rSh.GetLayout());
571 if ( sText.getLength() > 80 )
573 sText = OUString::Concat(sText.subView(0, 80)) + "...";
576 else
578 sText = pRefField->GetSetRefName();
581 break;
583 case SwFieldIds::TableOfAuthorities:
585 const auto pAuthorityField = static_cast<const SwAuthorityField*>(pField);
586 sText = pAuthorityField->GetAuthority(rSh.GetLayout());
588 if (auto t = pAuthorityField->GetTargetType();
589 t == SwAuthorityField::TargetType::UseDisplayURL
590 || t == SwAuthorityField::TargetType::UseTargetURL)
592 const OUString& rURL = pAuthorityField->GetAbsoluteURL();
593 sText += "\n" + SfxHelp::GetURLHelpText(rURL);
596 break;
599 default: break;
603 if( sText.isEmpty() )
605 const bool bShowTrackChanges = IDocumentRedlineAccess::IsShowChanges( m_rView.GetDocShell()->GetDoc()->getIDocumentRedlineAccess().GetRedlineFlags() );
606 const bool bShowInlineTooltips = rSh.GetViewOptions()->IsShowInlineTooltips();
607 if ( bShowTrackChanges && bShowInlineTooltips )
609 aContentAtPos.eContentAtPos = IsAttrAtPos::Redline;
610 if( rSh.GetContentAtPos( aPos, aContentAtPos, false, &aFieldRect ) )
611 sText = lcl_GetRedlineHelp(*aContentAtPos.aFnd.pRedl, bBalloon, /*bTableChange=*/false, /*bTableColChange=*/false);
616 if (!sText.isEmpty())
618 tools::Rectangle aRect( aFieldRect.SVRect() );
619 Point aPt( OutputToScreenPixel( LogicToPixel( aRect.TopLeft() )));
620 aRect.SetLeft( aPt.X() );
621 aRect.SetTop( aPt.Y() );
622 aPt = OutputToScreenPixel( LogicToPixel( aRect.BottomRight() ));
623 aRect.SetRight( aPt.X() );
624 aRect.SetBottom( aPt.Y() );
626 // tdf#136336 ensure tooltip area surrounds the current mouse position with at least a pixel margin
627 aRect.Union(tools::Rectangle(rEvt.GetMousePosPixel(), Size(1, 1)));
628 aRect.AdjustLeft(-1);
629 aRect.AdjustRight(1);
630 aRect.AdjustTop(-1);
631 aRect.AdjustBottom(1);
633 if( bBalloon )
634 Help::ShowBalloon( this, rEvt.GetMousePosPixel(), aRect, sText );
635 else
637 // the show the help
638 OUString sDisplayText(ClipLongToolTip(sText));
639 Help::ShowQuickHelp(this, aRect, sDisplayText, nStyle);
643 bContinue = false;
648 if( bContinue )
649 Window::RequestHelp( rEvt );
652 void SwEditWin::PrePaint(vcl::RenderContext& /*rRenderContext*/)
654 if (SwWrtShell* pWrtShell = GetView().GetWrtShellPtr())
655 pWrtShell->PrePaint();
658 void SwEditWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect)
660 SwWrtShell* pWrtShell = GetView().GetWrtShellPtr();
661 if(!pWrtShell)
662 return;
663 bool bPaintShadowCursor = false;
664 if( m_pShadCursor )
666 tools::Rectangle aRect( m_pShadCursor->GetRect());
667 // fully resides inside?
668 if( rRect.Contains( aRect ) )
670 // then cancel
671 m_pShadCursor.reset();
673 else if( rRect.Overlaps( aRect ))
675 // resides somewhat above, then everything is clipped outside
676 // and we have to make the "inner part" at the end of the
677 // Paint visible again. Otherwise Paint errors occur!
678 bPaintShadowCursor = true;
682 if ( GetView().GetVisArea().GetWidth() <= 0 ||
683 GetView().GetVisArea().GetHeight() <= 0 )
684 Invalidate( rRect );
685 else
687 pWrtShell->setOutputToWindow(true);
688 bool bTiledPainting = false;
689 if (comphelper::LibreOfficeKit::isActive())
691 bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting();
692 comphelper::LibreOfficeKit::setTiledPainting(true);
694 pWrtShell->Paint(rRenderContext, rRect);
695 if (comphelper::LibreOfficeKit::isActive())
697 comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting);
699 pWrtShell->setOutputToWindow(false);
702 if( bPaintShadowCursor )
703 m_pShadCursor->Paint();
706 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */