26#include <editeng/editeng.hxx>
31#include <svx/svxids.hrc>
51#include <com/sun/star/office/XAnnotation.hpp>
66#define METABUTTON_WIDTH 16
67#define METABUTTON_HEIGHT 18
68#define POSTIT_META_HEIGHT sal_Int32(30)
74 Size aSize = GetOutputSizePixel();
94 sal_uInt16 nKey = rKeyCode.
GetCode();
123 bDone = pEditView->PostKeyEvent(rKeyEvt);
132 sal_Int32 nLen = pEditEngine->
GetTextLen(nPar - 1);
133 pEditView->SetSelection(
ESelection(0, 0, nPar - 1, nLen));
151 : mrContents(rContents)
176 SetOutputSizePixel(aSize);
210 const Reference<XAnnotation>& xAnnotation)
211 : mxBuilder(
Application::CreateBuilder(pParent,
"modules/simpress/ui/annotation.ui"))
212 , mxPopover(mxBuilder->weld_popover(
"Annotation"))
214 , mpDocShell(pDocShell)
215 , mpDoc(pDocShell->GetDoc())
220 mxPopover->popup_at_rect(pParent, rRect);
285 nCntrl |= EEControlBits::PASTESPECIAL | EEControlBits::AUTOCORRECT | EEControlBits::USECHARATTRIBS | EEControlBits::NOCOLORS;
302 SfxDispatcher* pDispatcher = mpDocShell->GetViewShell()->GetViewFrame()->GetDispatcher();
306 if (rIdent ==
".uno:ReplyToAnnotation")
310 SfxCallMode::ASYNCHRON, { &aItem });
312 else if (rIdent ==
".uno:DeleteAnnotation")
315 pDispatcher->
ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON,
318 else if (rIdent ==
".uno:DeleteAllAnnotationByAuthor")
320 const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, mxAnnotation->getAuthor() );
321 pDispatcher->
ExecuteList( SID_DELETEALLBYAUTHOR_POSTIT,
322 SfxCallMode::ASYNCHRON, { &aItem });
324 else if (rIdent ==
".uno:DeleteAllAnnotation")
325 pDispatcher->
Execute( SID_DELETEALL_POSTIT );
331 OUString sCurrentAuthor( aUserOptions.
GetFullName() );
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);
341 bool bShowReply = sAuthor != sCurrentAuthor && !
mbReadonly;
342 mxMenuButton->set_item_visible(
".uno:ReplyToAnnotation", bShowReply);
343 mxMenuButton->set_item_visible(
"separator", bShowReply);
363 MapMode aMode(MapUnit::Map100thMM);
389 if( aTextHeight > aHeight )
391 const int nThickness =
mxVScrollbar->get_scroll_thickness();
395 aWidth -= nThickness;
406 if (
mxVScrollbar->get_vpolicy() == VclPolicyType::NEVER)
416 int nStepIncrement =
mpOutliner->GetTextHeight() / 10;
417 int nPageIncrement = rDevice.
PixelToLogic(
Size(0,aHeight)).Height() * 8 / 10;
428 nPageSize = std::min(nPageSize, nUpper);
430 mxVScrollbar->vadjustment_configure(nCurrentDocPos, 0, nUpper,
431 nStepIncrement, nPageIncrement, nPageSize);
441 if (aOldHeight != aNewHeight)
455 aEditAttr.
Put(aNewItem);
469 rBnd.
Update(SID_ATTR_INSERT);
481 ::tools::Long nDiff = GetOutlinerView()->GetEditView().GetVisArea().Top() - rScrolledWindow.vadjustment_get_value();
482 GetOutlinerView()->Scroll( 0, nDiff );
487 if( xAnnotation.is() )
489 Reference< XText > xText( xAnnotation->getTextRange() );
497 if( (xAnnotation ==
mxAnnotation) || !xAnnotation.is() )
521 OUString sMeta( xAnnotation->getAuthor() );
524 if( !sDateTime.isEmpty() )
526 if( !sMeta.isEmpty() )
604 if (rCEvt.
GetCommand() == CommandEventId::ContextMenu)
614 if (IsMouseCaptured())
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"));
629 OUString sCurrentAuthor( aUserOptions.
GetFullName() );
630 OUString sAuthor( xAnnotation->getAuthor() );
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);
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);
656 xMenu->insert(nInsertPos++,
".uno:Bold",
665 xMenu->set_active(
".uno:Bold",
true);
668 xMenu->insert(nInsertPos++,
".uno:Italic",
677 xMenu->set_active(
".uno:Italic",
true);
681 xMenu->insert(nInsertPos++,
".uno:Underline",
690 xMenu->set_active(
".uno:Underline",
true);
693 xMenu->insert(nInsertPos++,
".uno:Strikeout",
702 xMenu->set_active(
".uno:Strikeout",
true);
705 xMenu->insert_separator(nInsertPos++,
"separator2");
708 xMenu->insert(nInsertPos++,
".uno:Copy",
714 xMenu->insert(nInsertPos++,
".uno:Paste",
720 bool bCanPaste =
false;
727 xMenu->insert_separator(nInsertPos++,
"separator3");
730 xMenu->set_sensitive(
".uno:Paste", bCanPaste);
732 auto sId = xMenu->popup_at_rect(pPopupParent, aRect);
734 if (
sId ==
".uno:ReplyToAnnotation")
738 SfxCallMode::ASYNCHRON, { &aItem });
740 else if (
sId ==
".uno:DeleteAnnotation")
743 pDispatcher->
ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON,
746 else if (
sId ==
".uno:DeleteAllAnnotationByAuthor")
748 const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, sAuthor );
749 pDispatcher->
ExecuteList( SID_DELETEALLBYAUTHOR_POSTIT,
750 SfxCallMode::ASYNCHRON, { &aItem });
752 else if (
sId ==
".uno:DeleteAllAnnotation")
753 pDispatcher->
Execute( SID_DELETEALL_POSTIT );
754 else if (
sId ==
".uno:Copy")
758 else if (
sId ==
".uno:Paste")
763 else if (!
sId.isEmpty())
768 if (
sId ==
".uno:Bold")
773 else if (
sId ==
".uno:Italic")
778 else if (
sId ==
".uno:Underline")
783 else if (
sId ==
".uno:Strikeout")
#define METABUTTON_HEIGHT
#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 &)
bool HasSelection() const
ESelection GetSelection() const
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
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void DrawGradient(const tools::Rectangle &rRect, const Gradient &rGradient)
static SAL_DLLPRIVATE void SetCalcFieldValueHdl(::Outliner *pOutliner)
SAL_DLLPRIVATE sal_uInt16 GetAnnotationAuthorIndex(const OUString &rAuthor)
SAL_DLLPRIVATE LanguageType GetLanguage(const sal_uInt16 nId) const
OutputDevice * GetRefDevice() const
bool IsUndoEnabled() const
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
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
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
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
std::optional< OutlinerParaObject > CreateText()
void SetText(OutlinerParaObject const &rText)
static TextApiObject * getImplementation(const css::uno::Reference< css::text::XText > &)
SD_DLLPUBLIC SfxViewFrame * GetViewFrame() const
tools::Long GetFontHeight() const
void SetFontHeight(tools::Long nHeight)
sal_uInt16 GetCode() const
virtual OutputDevice & get_ref_device()=0
virtual void set_cursor(PointerStyle ePointerStyle)=0
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
ESelection aNewSelection(GetSelection())
#define EE_TEXTPOS_MAX_COUNT
#define EE_PARA_MAX_COUNT
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")
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
#define LINK(Instance, Class, Member)
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)
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)
Reference< XFrame > xFrame