LibreOffice Module sd (master) 1
annotationwindow.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 <editeng/eeitem.hxx>
21#include <editeng/udlnitem.hxx>
22#include <editeng/langitem.hxx>
23#include <editeng/editview.hxx>
24#include <editeng/editstat.hxx>
25#include <editeng/outliner.hxx>
26#include <editeng/editeng.hxx>
27#include <editeng/outlobj.hxx>
28#include <editeng/postitem.hxx>
29#include <editeng/wghtitem.hxx>
31#include <svx/svxids.hrc>
33
34#include <sfx2/viewfrm.hxx>
35#include <sfx2/bindings.hxx>
36#include <sfx2/dispatch.hxx>
37#include <svl/stritem.hxx>
38
39#include <vcl/commandevent.hxx>
41#include <vcl/vclenum.hxx>
42#include <vcl/svapp.hxx>
43#include <vcl/gradient.hxx>
44#include <vcl/settings.hxx>
45#include <vcl/ptrstyle.hxx>
46
47#include <strings.hrc>
48#include "annotationwindow.hxx"
50
51#include <com/sun/star/office/XAnnotation.hpp>
52#include <DrawDocShell.hxx>
53#include <ViewShell.hxx>
54#include <drawdoc.hxx>
55#include <textapi.hxx>
56#include <sdresid.hxx>
57
58#include <memory>
59
60using namespace ::sd;
61using namespace ::com::sun::star;
62using namespace ::com::sun::star::uno;
63using namespace ::com::sun::star::office;
64using namespace ::com::sun::star::text;
65
66#define METABUTTON_WIDTH 16
67#define METABUTTON_HEIGHT 18
68#define POSTIT_META_HEIGHT sal_Int32(30)
69
70namespace sd {
71
72void AnnotationTextWindow::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect)
73{
74 Size aSize = GetOutputSizePixel();
75
76 const bool bHighContrast = Application::GetSettings().GetStyleSettings().GetHighContrastMode();
77 if (!bHighContrast)
78 {
79 rRenderContext.DrawGradient(::tools::Rectangle(Point(0,0), rRenderContext.PixelToLogic(aSize)),
80 Gradient(css::awt::GradientStyle_LINEAR, mrContents.maColorLight, mrContents.maColor));
81 }
82
83 DoPaint(rRenderContext, rRect);
84}
85
87{
89}
90
92{
93 const vcl::KeyCode& rKeyCode = rKeyEvt.GetKeyCode();
94 sal_uInt16 nKey = rKeyCode.GetCode();
95
96 bool bDone = false;
97
98 if ((rKeyCode.IsMod1() && rKeyCode.IsMod2()) && ((nKey == KEY_PAGEUP) || (nKey == KEY_PAGEDOWN)))
99 {
101 if( pDispatcher )
102 pDispatcher->Execute( nKey == KEY_PAGEDOWN ? SID_NEXT_POSTIT : SID_PREVIOUS_POSTIT );
103 bDone = true;
104 }
105 else if (nKey == KEY_INSERT)
106 {
107 if (!rKeyCode.IsMod1() && !rKeyCode.IsMod2())
109 bDone = true;
110 }
111 else
112 {
114
116 if ( !( (nKey == KEY_Z || nKey == KEY_Y) && rKeyCode.IsMod1()) )
117 {
118 bool bIsProtected = mrContents.IsProtected();
119 if (!bIsProtected || !EditEngine::DoesKeyChangeText(rKeyEvt) )
120 {
121 if (EditView* pEditView = GetEditView())
122 {
123 bDone = pEditView->PostKeyEvent(rKeyEvt);
124 if (!bDone && rKeyEvt.GetKeyCode().IsMod1() && !rKeyEvt.GetKeyCode().IsMod2())
125 {
126 if (nKey == KEY_A)
127 {
128 EditEngine* pEditEngine = GetEditEngine();
129 sal_Int32 nPar = pEditEngine->GetParagraphCount();
130 if (nPar)
131 {
132 sal_Int32 nLen = pEditEngine->GetTextLen(nPar - 1);
133 pEditView->SetSelection(ESelection(0, 0, nPar - 1, nLen));
134 }
135 bDone = true;
136 }
137 }
138 }
139 }
140 }
141 if (bDone)
142 {
144 }
145 }
146
147 return bDone;
148}
149
151 : mrContents(rContents)
152{
153}
154
156{
157 OutlinerView* pOutlinerView = mrContents.GetOutlinerView();
158 if (!pOutlinerView)
159 return nullptr;
160 return &pOutlinerView->GetEditView();
161}
162
164{
165 OutlinerView* pOutlinerView = mrContents.GetOutlinerView();
166 if (!pOutlinerView)
167 return nullptr;
168 return pOutlinerView->GetEditView().GetEditEngine();
169}
170
172{
173 Size aSize(0, 0);
174 pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
175
176 SetOutputSizePixel(aSize);
177
179
180 EnableRTL(false);
181
182 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
183 Color aBgColor = rStyleSettings.GetWindowColor();
184
185 OutputDevice& rDevice = pDrawingArea->get_ref_device();
186
187 rDevice.SetMapMode(MapMode(MapUnit::Map100thMM));
188 rDevice.SetBackground(aBgColor);
189
190 Size aOutputSize(rDevice.PixelToLogic(aSize));
191
192 EditView* pEditView = GetEditView();
193 pEditView->setEditViewCallbacks(this);
194
195 EditEngine* pEditEngine = GetEditEngine();
196 pEditEngine->SetPaperSize(aOutputSize);
197 pEditEngine->SetRefDevice(&rDevice);
198
199 pEditView->SetOutputArea(::tools::Rectangle(Point(0, 0), aOutputSize));
200 pEditView->SetBackgroundColor(aBgColor);
201
202 pDrawingArea->set_cursor(PointerStyle::Text);
203
205}
206
207// see SwAnnotationWin in sw for something similar
208AnnotationWindow::AnnotationWindow(weld::Window* pParent, const ::tools::Rectangle& rRect,
209 DrawDocShell* pDocShell,
210 const Reference<XAnnotation>& xAnnotation)
211 : mxBuilder(Application::CreateBuilder(pParent, "modules/simpress/ui/annotation.ui"))
212 , mxPopover(mxBuilder->weld_popover("Annotation"))
213 , mxContainer(mxBuilder->weld_widget("container"))
214 , mpDocShell(pDocShell)
215 , mpDoc(pDocShell->GetDoc())
216 , mbReadonly(pDocShell->IsReadOnly())
217 , mbProtected(false)
218{
219 mxContainer->set_size_request(320, 240);
220 mxPopover->popup_at_rect(pParent, rRect);
221
222 InitControls();
223 setAnnotation(xAnnotation);
225
226 DoResize();
227
228 mxTextControl->GrabFocus();
229}
230
232{
233}
234
236{
237 // window control for author and date
238 mxMeta = mxBuilder->weld_label("meta");
239 mxMeta->set_direction(AllSettings::GetLayoutRTL());
240
243
244 // we should leave this setting alone, but for this we need a better layout algo
245 // with variable meta size height
246 mxMeta->set_font(maLabelFont);
247
248 mpOutliner.reset( new ::Outliner(GetAnnotationPool(),OutlinerMode::TextObject) );
250 mpOutliner->SetUpdateLayout( true );
251
252 if (OutputDevice* pDev = mpDoc->GetRefDevice())
253 mpOutliner->SetRefDevice( pDev );
254
255 mpOutlinerView.reset( new OutlinerView ( mpOutliner.get(), nullptr) );
256 mpOutliner->InsertView(mpOutlinerView.get() );
257
258 //create Scrollbars
259 mxVScrollbar = mxBuilder->weld_scrolled_window("scrolledwindow", true);
260
261 // actual window which holds the user text
262 mxTextControl.reset(new AnnotationTextWindow(*this));
263 mxTextControlWin.reset(new weld::CustomWeld(*mxBuilder, "editview", *mxTextControl));
264 mxTextControl->SetPointer(PointerStyle::Text);
265
266 Rescale();
267 OutputDevice& rDevice = mxTextControl->GetDrawingArea()->get_ref_device();
268
269 mxVScrollbar->set_direction(false);
270 mxVScrollbar->connect_vadjustment_changed(LINK(this, AnnotationWindow, ScrollHdl));
271
272 mpOutlinerView->SetBackgroundColor(COL_TRANSPARENT);
273 mpOutlinerView->SetOutputArea(rDevice.PixelToLogic(::tools::Rectangle(0, 0, 1, 1)));
274
275 mxMenuButton = mxBuilder->weld_menu_button("menubutton");
276 if (mbReadonly)
277 mxMenuButton->hide();
278 else
279 {
281 mxMenuButton->connect_selected(LINK(this, AnnotationWindow, MenuItemSelectedHdl));
282 }
283
284 EEControlBits nCntrl = mpOutliner->GetControlWord();
285 nCntrl |= EEControlBits::PASTESPECIAL | EEControlBits::AUTOCORRECT | EEControlBits::USECHARATTRIBS | EEControlBits::NOCOLORS;
286 mpOutliner->SetControlWord(nCntrl);
287
288 mpOutliner->SetModifyHdl( Link<LinkParamNone*,void>() );
289 mpOutliner->EnableUndo( false );
290
291 mpOutliner->ClearModifyFlag();
292 mpOutliner->GetUndoManager().Clear();
293 mpOutliner->EnableUndo( true );
294
296
297 mxTextControl->GrabFocus();
298}
299
300IMPL_LINK(AnnotationWindow, MenuItemSelectedHdl, const OUString&, rIdent, void)
301{
302 SfxDispatcher* pDispatcher = mpDocShell->GetViewShell()->GetViewFrame()->GetDispatcher();
303 if (!pDispatcher)
304 return;
305
306 if (rIdent == ".uno:ReplyToAnnotation")
307 {
308 const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( mxAnnotation ) );
309 pDispatcher->ExecuteList(SID_REPLYTO_POSTIT,
310 SfxCallMode::ASYNCHRON, { &aItem });
311 }
312 else if (rIdent == ".uno:DeleteAnnotation")
313 {
314 const SfxUnoAnyItem aItem( SID_DELETE_POSTIT, Any( mxAnnotation ) );
315 pDispatcher->ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON,
316 { &aItem });
317 }
318 else if (rIdent == ".uno:DeleteAllAnnotationByAuthor")
319 {
320 const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, mxAnnotation->getAuthor() );
321 pDispatcher->ExecuteList( SID_DELETEALLBYAUTHOR_POSTIT,
322 SfxCallMode::ASYNCHRON, { &aItem });
323 }
324 else if (rIdent == ".uno:DeleteAllAnnotation")
325 pDispatcher->Execute( SID_DELETEALL_POSTIT );
326}
327
329{
330 SvtUserOptions aUserOptions;
331 OUString sCurrentAuthor( aUserOptions.GetFullName() );
332 OUString sAuthor( mxAnnotation->getAuthor() );
333
334 OUString aStr(mxMenuButton->get_item_label(".uno:DeleteAllAnnotationByAuthor"));
335 OUString aReplace( sAuthor );
336 if( aReplace.isEmpty() )
337 aReplace = SdResId( STR_ANNOTATION_NOAUTHOR );
338 aStr = aStr.replaceFirst("%1", aReplace);
339 mxMenuButton->set_item_label(".uno:DeleteAllAnnotationByAuthor", aStr);
340
341 bool bShowReply = sAuthor != sCurrentAuthor && !mbReadonly;
342 mxMenuButton->set_item_visible(".uno:ReplyToAnnotation", bShowReply);
343 mxMenuButton->set_item_visible("separator", bShowReply);
344 mxMenuButton->set_item_visible(".uno:DeleteAnnotation", mxAnnotation.is() && !mbReadonly);
345 mxMenuButton->set_item_visible(".uno:DeleteAllAnnotationByAuthor", !mbReadonly);
346 mxMenuButton->set_item_visible(".uno:DeleteAllAnnotation", !mbReadonly);
347}
348
350{
353}
354
355void AnnotationWindow::SetMapMode(const MapMode& rNewMapMode)
356{
357 OutputDevice& rDevice = mxTextControl->GetDrawingArea()->get_ref_device();
358 rDevice.SetMapMode(rNewMapMode);
359}
360
362{
363 MapMode aMode(MapUnit::Map100thMM);
364 aMode.SetOrigin( Point() );
365 mpOutliner->SetRefMapMode( aMode );
366 SetMapMode( aMode );
367
368 if (mxMeta)
369 {
370 vcl::Font aFont = maLabelFont;
371 sal_Int32 nHeight = ::tools::Long(aFont.GetFontHeight() * aMode.GetScaleY());
372 aFont.SetFontHeight( nHeight );
373 mxMeta->set_font(aFont);
374 }
375}
376
378{
379 OutputDevice& rDevice = mxTextControl->GetDrawingArea()->get_ref_device();
380
381 ::tools::Long aHeight = mxContainer->get_preferred_size().Height();
382 ::tools::ULong aWidth = mxContainer->get_preferred_size().Width();
383
384 aHeight -= POSTIT_META_HEIGHT;
385
386 mpOutliner->SetPaperSize( rDevice.PixelToLogic( Size(aWidth, aHeight) ) ) ;
387 ::tools::Long aTextHeight = rDevice.LogicToPixel(mpOutliner->CalcTextSize()).Height();
388
389 if( aTextHeight > aHeight )
390 {
391 const int nThickness = mxVScrollbar->get_scroll_thickness();
392 if (nThickness)
393 {
394 // we need vertical scrollbars and have to reduce the width
395 aWidth -= nThickness;
396 mpOutliner->SetPaperSize(rDevice.PixelToLogic(Size(aWidth, aHeight)));
397 }
398 mxVScrollbar->set_vpolicy(VclPolicyType::ALWAYS);
399 }
400 else
401 {
402 mxVScrollbar->set_vpolicy(VclPolicyType::NEVER);
403 }
404
405 ::tools::Rectangle aOutputArea = rDevice.PixelToLogic(::tools::Rectangle(0, 0, aWidth, aHeight));
406 if (mxVScrollbar->get_vpolicy() == VclPolicyType::NEVER)
407 {
408 // if we do not have a scrollbar anymore, we want to see the complete text
409 mpOutlinerView->SetVisArea(aOutputArea);
410 }
411 mpOutlinerView->SetOutputArea(aOutputArea);
412 mpOutlinerView->ShowCursor(true, true);
413
414 int nUpper = mpOutliner->GetTextHeight();
415 int nCurrentDocPos = mpOutlinerView->GetVisArea().Top();
416 int nStepIncrement = mpOutliner->GetTextHeight() / 10;
417 int nPageIncrement = rDevice.PixelToLogic(Size(0,aHeight)).Height() * 8 / 10;
418 int nPageSize = rDevice.PixelToLogic(Size(0,aHeight)).Height();
419
420 /* limit the page size to below nUpper because gtk's gtk_scrolled_window_start_deceleration has
421 effectively...
422
423 lower = gtk_adjustment_get_lower
424 upper = gtk_adjustment_get_upper - gtk_adjustment_get_page_size
425
426 and requires that upper > lower or the deceleration animation never ends
427 */
428 nPageSize = std::min(nPageSize, nUpper);
429
430 mxVScrollbar->vadjustment_configure(nCurrentDocPos, 0, nUpper,
431 nStepIncrement, nPageIncrement, nPageSize);
432}
433
435{
436 mxVScrollbar->vadjustment_set_value(mpOutlinerView->GetVisArea().Top());
437}
438
440{
441 if (aOldHeight != aNewHeight)
442 DoResize();
443 else
444 SetScrollbar();
445}
446
448{
449 mpOutliner->SetModifyHdl( Link<LinkParamNone*,void>() );
451
452 ESelection aNewSelection( 0, 0, mpOutliner->GetParagraphCount()-1, EE_TEXTPOS_ALL );
454 SfxItemSet aEditAttr(GetOutlinerView()->GetAttribs());
455 aEditAttr.Put(aNewItem);
456 GetOutlinerView()->SetAttribs( aEditAttr );
457
459
460 mxTextControl->Invalidate();
461}
462
464{
465 if( mpOutlinerView )
466 {
468 rBnd.Invalidate(SID_ATTR_INSERT);
469 rBnd.Update(SID_ATTR_INSERT);
470 }
471}
472
474{
475 OutputDevice& rDevice = mxTextControl->GetDrawingArea()->get_ref_device();
476 return mpOutliner ? rDevice.LogicToPixel(mpOutliner->CalcTextSize()).Height() : 0;
477}
478
479IMPL_LINK(AnnotationWindow, ScrollHdl, weld::ScrolledWindow&, rScrolledWindow, void)
480{
481 ::tools::Long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - rScrolledWindow.vadjustment_get_value();
482 GetOutlinerView()->Scroll( 0, nDiff );
483}
484
485TextApiObject* getTextApiObject( const Reference< XAnnotation >& xAnnotation )
486{
487 if( xAnnotation.is() )
488 {
489 Reference< XText > xText( xAnnotation->getTextRange() );
490 return TextApiObject::getImplementation( xText );
491 }
492 return nullptr;
493}
494
495void AnnotationWindow::setAnnotation( const Reference< XAnnotation >& xAnnotation )
496{
497 if( (xAnnotation == mxAnnotation) || !xAnnotation.is() )
498 return;
499
500 mxAnnotation = xAnnotation;
501
502 SetColor();
503
504 SvtUserOptions aUserOptions;
505 mbProtected = aUserOptions.GetFullName() != xAnnotation->getAuthor();
506
507 mpOutliner->Clear();
509
510 if( pTextApi )
511 {
513 mpOutliner->SetText(*pOPO);
514 }
515
516 mpOutliner->ClearModifyFlag();
517 mpOutliner->GetUndoManager().Clear();
518
519//TODO Invalidate();
520
521 OUString sMeta( xAnnotation->getAuthor() );
522 OUString sDateTime( getAnnotationDateTimeString(xAnnotation) );
523
524 if( !sDateTime.isEmpty() )
525 {
526 if( !sMeta.isEmpty() )
527 sMeta += "\n";
528
529 sMeta += sDateTime;
530 }
531 mxMeta->set_label(sMeta);
532}
533
535{
536 sal_uInt16 nAuthorIdx = mpDoc->GetAnnotationAuthorIndex( mxAnnotation->getAuthor() );
537
538 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
539 const bool bHighContrast = rStyleSettings.GetHighContrastMode();
540 if( bHighContrast )
541 {
542 maColor = rStyleSettings.GetWindowColor();
544 maColorLight = rStyleSettings.GetWindowTextColor();
545 }
546 else
547 {
551 }
552
553 mpOutliner->ForceAutoColor( bHighContrast || SvtAccessibilityOptions::GetIsAutomaticFontColor() );
554
555 mxPopover->set_background(maColor);
556 mxMenuButton->set_background(maColor);
557
558 mxMeta->set_font_color(bHighContrast ? maColorLight : maColorDark);
559
560 mxVScrollbar->customize_scrollbars(maColorLight,
562 maColor);
563 mxVScrollbar->set_scroll_thickness(GetPrefScrollbarWidth());
564}
565
567{
568 Reference< XAnnotation > xAnnotation( mxAnnotation );
569
570 // write changed text back to annotation
571 if (mpOutliner->IsModified())
572 {
573 TextApiObject* pTextApi = getTextApiObject( xAnnotation );
574
575 if( pTextApi )
576 {
577 std::optional<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject();
578 if( pOPO )
579 {
580 if( mpDoc->IsUndoEnabled() )
581 mpDoc->BegUndo( SdResId( STR_ANNOTATION_UNDO_EDIT ) );
582
583 pTextApi->SetText( *pOPO );
584 pOPO.reset();
585
586 // set current time to changed annotation
587 xAnnotation->setDateTime( getCurrentDateTime() );
588
589 if( mpDoc->IsUndoEnabled() )
590 mpDoc->EndUndo();
591
593 }
594
595 }
596 }
597 mpOutliner->ClearModifyFlag();
598
599 mpOutliner->GetUndoManager().Clear();
600}
601
603{
604 if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
605 {
606 const bool bReadOnly = mrContents.DocShell()->IsReadOnly();
607 if (bReadOnly)
608 return true;
609
611 if( !pDispatcher )
612 return true;
613
614 if (IsMouseCaptured())
615 {
616 // so the menu can capture it and the EditView doesn't get the button release and change its
617 // selection on a successful button click
618 ReleaseMouse();
619 }
620
621 ::tools::Rectangle aRect(rCEvt.GetMousePosPixel(), Size(1, 1));
622 weld::Widget* pPopupParent = GetDrawingArea();
623 std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pPopupParent, "modules/simpress/ui/annotationtagmenu.ui"));
624 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu("menu"));
625
626 auto xAnnotation = mrContents.getAnnotation();
627
628 SvtUserOptions aUserOptions;
629 OUString sCurrentAuthor( aUserOptions.GetFullName() );
630 OUString sAuthor( xAnnotation->getAuthor() );
631
632 OUString aStr(xMenu->get_label(".uno:DeleteAllAnnotationByAuthor"));
633 OUString aReplace( sAuthor );
634 if( aReplace.isEmpty() )
635 aReplace = SdResId( STR_ANNOTATION_NOAUTHOR );
636 aStr = aStr.replaceFirst("%1", aReplace);
637 xMenu->set_label(".uno:DeleteAllAnnotationByAuthor", aStr);
638
639 bool bShowReply = sAuthor != sCurrentAuthor && !bReadOnly;
640 xMenu->set_visible(".uno:ReplyToAnnotation", bShowReply);
641 xMenu->set_visible("separator", bShowReply);
642 xMenu->set_visible(".uno:DeleteAnnotation", xAnnotation.is() && !bReadOnly);
643 xMenu->set_visible(".uno:DeleteAllAnnotationByAuthor", !bReadOnly);
644 xMenu->set_visible(".uno:DeleteAllAnnotation", !bReadOnly);
645
646 int nInsertPos = 2;
647
650
651 bool bEditable = !mrContents.IsProtected() && !bReadOnly;
652 if (bEditable)
653 {
655
656 xMenu->insert(nInsertPos++, ".uno:Bold",
658 vcl::CommandInfoProvider::GetCommandProperties(".uno:Bold", aModuleName)),
659 nullptr, nullptr, vcl::CommandInfoProvider::GetXGraphicForCommand(".uno:Bold", xFrame),
661
662 if ( aSet.GetItemState( EE_CHAR_WEIGHT ) == SfxItemState::SET )
663 {
664 if( aSet.Get( EE_CHAR_WEIGHT ).GetWeight() == WEIGHT_BOLD )
665 xMenu->set_active(".uno:Bold", true);
666 }
667
668 xMenu->insert(nInsertPos++, ".uno:Italic",
670 vcl::CommandInfoProvider::GetCommandProperties(".uno:Italic", aModuleName)),
671 nullptr, nullptr, vcl::CommandInfoProvider::GetXGraphicForCommand(".uno:Italic", xFrame),
673
674 if ( aSet.GetItemState( EE_CHAR_ITALIC ) == SfxItemState::SET )
675 {
676 if( aSet.Get( EE_CHAR_ITALIC ).GetPosture() != ITALIC_NONE )
677 xMenu->set_active(".uno:Italic", true);
678
679 }
680
681 xMenu->insert(nInsertPos++, ".uno:Underline",
683 vcl::CommandInfoProvider::GetCommandProperties(".uno:Underline", aModuleName)),
684 nullptr, nullptr, vcl::CommandInfoProvider::GetXGraphicForCommand(".uno:Underline", xFrame),
686
687 if ( aSet.GetItemState( EE_CHAR_UNDERLINE ) == SfxItemState::SET )
688 {
689 if( aSet.Get( EE_CHAR_UNDERLINE ).GetLineStyle() != LINESTYLE_NONE )
690 xMenu->set_active(".uno:Underline", true);
691 }
692
693 xMenu->insert(nInsertPos++, ".uno:Strikeout",
695 vcl::CommandInfoProvider::GetCommandProperties(".uno:Strikeout", aModuleName)),
696 nullptr, nullptr, vcl::CommandInfoProvider::GetXGraphicForCommand(".uno:Strikeout", xFrame),
698
699 if ( aSet.GetItemState( EE_CHAR_STRIKEOUT ) == SfxItemState::SET )
700 {
701 if( aSet.Get( EE_CHAR_STRIKEOUT ).GetStrikeout() != STRIKEOUT_NONE )
702 xMenu->set_active(".uno:Strikeout", true);
703 }
704
705 xMenu->insert_separator(nInsertPos++, "separator2");
706 }
707
708 xMenu->insert(nInsertPos++, ".uno:Copy",
710 vcl::CommandInfoProvider::GetCommandProperties(".uno:Copy", aModuleName)),
711 nullptr, nullptr, vcl::CommandInfoProvider::GetXGraphicForCommand(".uno:Copy", xFrame),
713
714 xMenu->insert(nInsertPos++, ".uno:Paste",
716 vcl::CommandInfoProvider::GetCommandProperties(".uno:Paste", aModuleName)),
717 nullptr, nullptr, vcl::CommandInfoProvider::GetXGraphicForCommand(".uno:Paste", xFrame),
719
720 bool bCanPaste = false;
721 if (bEditable)
722 {
724 bCanPaste = aDataHelper.GetFormatCount() != 0;
725 }
726
727 xMenu->insert_separator(nInsertPos++, "separator3");
728
729 xMenu->set_sensitive(".uno:Copy", mrContents.GetOutlinerView()->HasSelection());
730 xMenu->set_sensitive(".uno:Paste", bCanPaste);
731
732 auto sId = xMenu->popup_at_rect(pPopupParent, aRect);
733
734 if (sId == ".uno:ReplyToAnnotation")
735 {
736 const SfxUnoAnyItem aItem( SID_REPLYTO_POSTIT, Any( xAnnotation ) );
737 pDispatcher->ExecuteList(SID_REPLYTO_POSTIT,
738 SfxCallMode::ASYNCHRON, { &aItem });
739 }
740 else if (sId == ".uno:DeleteAnnotation")
741 {
742 const SfxUnoAnyItem aItem( SID_DELETE_POSTIT, Any( xAnnotation ) );
743 pDispatcher->ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON,
744 { &aItem });
745 }
746 else if (sId == ".uno:DeleteAllAnnotationByAuthor")
747 {
748 const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, sAuthor );
749 pDispatcher->ExecuteList( SID_DELETEALLBYAUTHOR_POSTIT,
750 SfxCallMode::ASYNCHRON, { &aItem });
751 }
752 else if (sId == ".uno:DeleteAllAnnotation")
753 pDispatcher->Execute( SID_DELETEALL_POSTIT );
754 else if (sId == ".uno:Copy")
755 {
757 }
758 else if (sId == ".uno:Paste")
759 {
762 }
763 else if (!sId.isEmpty())
764 {
767
768 if (sId == ".uno:Bold")
769 {
770 FontWeight eFW = aEditAttr.Get( EE_CHAR_WEIGHT ).GetWeight();
772 }
773 else if (sId == ".uno:Italic")
774 {
775 FontItalic eFI = aEditAttr.Get( EE_CHAR_ITALIC ).GetPosture();
777 }
778 else if (sId == ".uno:Underline")
779 {
780 FontLineStyle eFU = aEditAttr. Get( EE_CHAR_UNDERLINE ).GetLineStyle();
782 }
783 else if (sId == ".uno:Strikeout")
784 {
785 FontStrikeout eFSO = aEditAttr.Get( EE_CHAR_STRIKEOUT ).GetStrikeout();
787 }
788
790 }
791
792 return true;
793 }
794 return WeldEditView::Command(rCEvt);
795}
796
797}
798
799/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< container::XNameAccess > mxContainer
#define METABUTTON_HEIGHT
#define METABUTTON_WIDTH
#define POSTIT_META_HEIGHT
const StyleSettings & GetStyleSettings() const
static bool GetLayoutRTL()
static const AllSettings & GetSettings()
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
CommandEventId GetCommand() const
const Point & GetMousePosPixel() const
sal_Int32 GetParagraphCount() const
sal_Int32 GetTextLen() const
void SetRefDevice(OutputDevice *pRefDef)
void SetPaperSize(const Size &rSize)
static bool DoesKeyChangeText(const KeyEvent &rKeyEvent)
void SetOutputArea(const tools::Rectangle &rRect)
void SetBackgroundColor(const Color &rColor)
EditEngine * GetEditEngine() const
void setEditViewCallbacks(EditViewCallbacks *pEditViewCallbacks)
const vcl::KeyCode & GetKeyCode() const
void SetOrigin(const Point &rOrigin)
const Fraction & GetScaleY() const
void SetSelection(const ESelection &)
void PasteSpecial()
bool HasSelection() const
ESelection GetSelection() const
SfxItemSet GetAttribs()
void SetAttribs(const SfxItemSet &)
EditView & GetEditView() const
void ShowCursor(bool bGotoCursor=true, bool bActivate=false)
const SfxItemSet & GetEmptyItemSet() const
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
void SetMapMode()
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
void SetBackground()
static SAL_DLLPRIVATE void SetCalcFieldValueHdl(::Outliner *pOutliner)
Definition: drawdoc.cxx:1079
SAL_DLLPRIVATE sal_uInt16 GetAnnotationAuthorIndex(const OUString &rAuthor)
Definition: drawdoc.cxx:1084
SAL_DLLPRIVATE LanguageType GetLanguage(const sal_uInt16 nId) const
Definition: drawdoc2.cxx:875
void BegUndo()
OutputDevice * GetRefDevice() const
bool IsUndoEnabled() const
void EndUndo()
void Update(sal_uInt16 nId)
void Invalidate(sal_uInt16 nId)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool IsReadOnly() const
SfxBindings & GetBindings()
SfxDispatcher * GetDispatcher()
SfxFrame & GetFrame() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetWindowColor() const
bool GetHighContrastMode() const
const vcl::Font & GetLabelFont() const
const Color & GetWindowTextColor() const
static bool GetIsAutomaticFontColor()
OUString GetFullName() const
sal_uInt32 GetFormatCount() const
static TransferableDataHelper CreateFromClipboard(const css::uno::Reference< css::datatransfer::clipboard::XClipboard > &rClipboard)
void DoPaint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)
virtual bool Command(const CommandEvent &rCEvt) override
void InitAccessible()
virtual css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard() const override
static Color GetColorLight(sal_uInt16 aAuthorIndex)
static Color GetColorDark(sal_uInt16 aAuthorIndex)
static Color GetColor(sal_uInt16 aAuthorIndex)
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
virtual EditEngine * GetEditEngine() const override
virtual bool KeyInput(const KeyEvent &rKeyEvt) override
AnnotationWindow & mrContents
virtual EditView * GetEditView() const override
AnnotationTextWindow(AnnotationWindow &rContents)
virtual void EditViewScrollStateChange() override
void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
virtual bool Command(const CommandEvent &rCEvt) override
::tools::Long GetPostItTextHeight()
std::unique_ptr< weld::ScrolledWindow > mxVScrollbar
OutlinerView * GetOutlinerView()
DrawDocShell * DocShell()
const css::uno::Reference< css::office::XAnnotation > & getAnnotation() const
css::uno::Reference< css::office::XAnnotation > mxAnnotation
std::unique_ptr< weld::Widget > mxContainer
AnnotationWindow(weld::Window *pParent, const ::tools::Rectangle &rRect, DrawDocShell *pDocShell, const css::uno::Reference< css::office::XAnnotation > &xAnnotation)
std::unique_ptr< OutlinerView > mpOutlinerView
SdDrawDocument * mpDoc
std::unique_ptr<::Outliner > mpOutliner
std::unique_ptr< weld::Label > mxMeta
std::unique_ptr< WeldEditView > mxTextControl
DrawDocShell * mpDocShell
::Outliner * GetOutliner()
std::unique_ptr< weld::Builder > mxBuilder
std::unique_ptr< weld::Popover > mxPopover
std::unique_ptr< weld::MenuButton > mxMenuButton
std::unique_ptr< weld::CustomWeld > mxTextControlWin
static sal_Int32 GetPrefScrollbarWidth()
void SetMapMode(const MapMode &rNewMapMode)
void ResizeIfNecessary(::tools::Long aOldHeight, ::tools::Long aNewHeight)
void setAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation)
void SetLanguage(const SvxLanguageItem &aNewItem)
sd::ViewShell * GetViewShell()
virtual void SetModified(bool=true) override
Definition: docshell.cxx:421
std::optional< OutlinerParaObject > CreateText()
Definition: textapi.cxx:162
void SetText(OutlinerParaObject const &rText)
Definition: textapi.cxx:167
static TextApiObject * getImplementation(const css::uno::Reference< css::text::XText > &)
Definition: textapi.cxx:182
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
Definition: viewshel.cxx:118
tools::Long GetFontHeight() const
void SetFontHeight(tools::Long nHeight)
bool IsMod1() const
sal_uInt16 GetCode() const
bool IsMod2() const
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
virtual OutputDevice & get_ref_device()=0
virtual void set_cursor(PointerStyle ePointerStyle)=0
virtual void set_size_request(int nWidth, int nHeight)=0
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
ESelection aNewSelection(GetSelection())
#define EE_TEXTPOS_MAX_COUNT
#define EE_PARA_MAX_COUNT
#define EE_TEXTPOS_ALL
EEControlBits
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr OUStringLiteral IsReadOnly(u"IsReadOnly")
FontLineStyle
LINESTYLE_SINGLE
LINESTYLE_NONE
FontStrikeout
STRIKEOUT_SINGLE
STRIKEOUT_NONE
FontItalic
ITALIC_NORMAL
ITALIC_NONE
WEIGHT_BOLD
WEIGHT_NORMAL
bool bReadOnly
TRISTATE_INDET
TRISTATE_TRUE
constexpr sal_uInt16 KEY_PAGEDOWN
constexpr sal_uInt16 KEY_Z
constexpr sal_uInt16 KEY_A
constexpr sal_uInt16 KEY_Y
constexpr sal_uInt16 KEY_PAGEUP
constexpr sal_uInt16 KEY_INSERT
aStr
SVXCORE_DLLPUBLIC MSO_SPT Get(const OUString &)
SfxItemPool * GetAnnotationPool()
IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OUString &, rIdent, void)
css::util::DateTime getCurrentDateTime()
OUString getAnnotationDateTimeString(const Reference< XAnnotation > &xAnnotation)
TextApiObject * getTextApiObject(const Reference< XAnnotation > &xAnnotation)
FontWeight
unsigned long ULong
long Long
Sequence< beans::PropertyValue > GetCommandProperties(const OUString &rsCommandName, const OUString &rsModuleName)
Reference< graphic::XGraphic > GetXGraphicForCommand(const OUString &rsCommandName, const Reference< frame::XFrame > &rxFrame, vcl::ImageType eImageType)
OUString GetModuleIdentifier(const Reference< frame::XFrame > &rxFrame)
OUString GetMenuLabelForCommand(const css::uno::Sequence< css::beans::PropertyValue > &rProperties)
OUString SdResId(TranslateId aId)
Definition: sdmod.cxx:83
Reference< XFrame > xFrame
OUString sId