20#include <com/sun/star/drawing/XDrawView.hpp>
21#include <com/sun/star/frame/XController.hpp>
22#include <com/sun/star/geometry/RealPoint2D.hpp>
23#include <com/sun/star/text/XText.hpp>
24#include <com/sun/star/document/XEventBroadcaster.hpp>
25#include <com/sun/star/office/XAnnotationAccess.hpp>
27#include <svx/svxids.hrc>
41#include <tools/datetime.hxx>
50#include <editeng/editeng.hxx>
99 if( !s_pAnnotationPool )
108 return s_pAnnotationPool.get();
130 return css::util::DateTime( 0, aCurrentDate.
GetSec(),
133 aCurrentDate.
GetYear(),
false );
139 if( xAnnotation.is() )
144 css::util::DateTime aDateTime( xAnnotation->getDateTime() );
147 Date aDate( aDateTime.Day, aDateTime.Month, aDateTime.Year );
149 sRet =
SdResId(STR_ANNOTATION_TODAY);
150 else if (aDate == (aSysDate-1))
151 sRet =
SdResId(STR_ANNOTATION_YESTERDAY);
153 sRet = rLocalData.
getDate(aDate);
157 sRet +=
" " + rLocalData.
getTime( aTime,
false );
163: mrBase( rViewShellBase )
164, mpDoc( rViewShellBase.GetDocument() )
165, mbShowAnnotations( true )
166, mnUpdateTagsEvent( nullptr )
189 Reference<XEventListener> xListener(
this );
190 xModel->addEventListener( xListener );
203 Reference<XEventListener> xListener(
this );
204 xModel->removeEventListener( xListener );
226 if( !(
aEvent.EventName ==
"OnAnnotationInserted" ||
aEvent.EventName ==
"OnAnnotationRemoved" ||
aEvent.EventName ==
"OnAnnotationChanged") )
235 if (
aEvent.EventName ==
"OnAnnotationRemoved" )
237 Reference< XAnnotation > xAnnotation(
aEvent.Source, uno::UNO_QUERY );
238 if ( xAnnotation.is() )
260 auto iter = std::find_if(aAnnotations.begin(), aAnnotations.end(),
261 [nAnnotationId](
const Reference<XAnnotation>& xAnnotation) {
262 return sd::getAnnotationId(xAnnotation) == nAnnotationId;
264 if (iter != aAnnotations.end())
269 Reference<XAnnotation> xAnnotationEmpty;
270 return xAnnotationEmpty;
292 case SID_INSERT_POSTIT:
295 case SID_DELETE_POSTIT:
296 case SID_DELETEALL_POSTIT:
297 case SID_DELETEALLBYAUTHOR_POSTIT:
300 case SID_EDIT_POSTIT:
303 case SID_PREVIOUS_POSTIT:
304 case SID_NEXT_POSTIT:
307 case SID_REPLYTO_POSTIT:
310 case SID_TOGGLE_NOTES:
327 sText = pPoolItem->GetValue();
342 case SID_DELETEALL_POSTIT:
345 case SID_DELETEALLBYAUTHOR_POSTIT:
349 if( SfxItemState::SET == pArgs->
GetItemState( SID_DELETEALLBYAUTHOR_POSTIT,
true, &pPoolItem ) )
356 case SID_DELETE_POSTIT:
358 Reference< XAnnotation > xAnnotation;
363 if( SfxItemState::SET == pArgs->
GetItemState( SID_DELETE_POSTIT,
true, &pPoolItem ) )
365 if( SfxItemState::SET == pArgs->
GetItemState( SID_ATTR_POSTIT_ID,
true, &pPoolItem ) )
371 else if( !xAnnotation.is() )
385 Reference< XAnnotation > xAnnotation;
387 sal_Int32 nPositionX = -1;
388 sal_Int32 nPositionY = -1;
398 sal_uInt32
nId = pPoolItem->GetValue().toUInt32();
402 sText = pPoolItem->GetValue();
405 nPositionX = pPoolItem->GetValue();
408 nPositionY = pPoolItem->GetValue();
410 if (xAnnotation.is())
414 if (nPositionX >= 0 && nPositionY >= 0)
418 xAnnotation->setPosition({fX, fY});
421 if (!sText.isEmpty())
424 Reference<XText> xText(xAnnotation->getTextRange());
425 xText->setString(sText);
450 if( !aAnnotations.empty() )
453 const int width = 1000;
454 const int height = 800;
462 for(
const auto& rxAnnotation : aAnnotations )
464 RealPoint2D aPoint( rxAnnotation->getPosition() );
465 aTagRect.
SetLeft( sal::static_int_cast< ::tools::Long >( aPoint.X * 100.0 ) );
466 aTagRect.
SetTop( sal::static_int_cast< ::tools::Long >( aPoint.Y * 100.0 ) );
493 Reference< XAnnotation > xAnnotation;
503 xAnnotation->setInitials( aUserOptions.
GetID() );
506 if (!rText.isEmpty())
508 Reference<XText> xText(xAnnotation->getTextRange());
509 xText->setString(rText);
513 xAnnotation->setAuthor( sAuthor );
518 RealPoint2D aPos(
static_cast<double>(
x) / 100.0,
static_cast<double>(
y) / 100.0 );
519 xAnnotation->setPosition( aPos );
533 Reference< XAnnotation > xAnnotation;
539 if( SfxItemState::SET == pArgs->
GetItemState( SID_ATTR_POSTIT_ID,
true, &pPoolItem ) )
541 sal_uInt32 nReplyId = 0;
548 if( SfxItemState::SET == pArgs->
GetItemState( SID_ATTR_POSTIT_TEXT,
true, &pPoolItem ) )
562 OUString sAuthor( xAnnotation->getAuthor() );
563 if( sAuthor.isEmpty() )
564 sAuthor =
SdResId( STR_ANNOTATION_NOAUTHOR );
566 aStr =
aStr.replaceFirst(
"%1", sAuthor) +
575 for( sal_Int32 nIdx = 0; nIdx >= 0; )
590 if (!sReplyText.isEmpty())
591 aOutliner.
Insert(sReplyText);
596 OUString sReplyAuthor;
603 xAnnotation->setInitials( aUserOptions.
GetID() );
606 xAnnotation->setAuthor( sReplyAuthor );
621 if( xAnnotation.is() && pPage )
648 for( Reference< XAnnotation >& xAnnotation : aAnnotations )
650 if( xAnnotation->getAuthor() == sAuthor )
678 for(
const auto& rxAnnotation : aAnnotations )
706 Reference< XAnnotation > xAnnotation;
719 bool bHasAnnotations =
false;
725 bHasAnnotations =
true;
727 while( pPage && !bHasAnnotations );
734 if( bWrongPageKind || !bHasAnnotations )
745 Reference< XAnnotation > xCurrent;
757 auto iter = std::find(aAnnotations.begin(), aAnnotations.end(), xCurrent);
758 if (iter != aAnnotations.end())
761 if( iter != aAnnotations.end() )
768 else if( !aAnnotations.empty() )
778 auto iter = std::find(aAnnotations.begin(), aAnnotations.end(), xCurrent);
779 if (iter != aAnnotations.end() && iter != aAnnotations.begin())
786 else if( !aAnnotations.empty() )
788 AnnotationVector::iterator iter( aAnnotations.end() );
804 std::shared_ptr<DrawViewShell> pDrawViewShell(std::dynamic_pointer_cast<DrawViewShell>(
mrBase.
GetMainViewShell()));
805 if (pDrawViewShell !=
nullptr)
808 pDrawViewShell->SwitchPage((pPage->
GetPageNum() - 1) >> 1);
812 pDispatcher->
Execute( bForward ? SID_NEXT_POSTIT : SID_PREVIOUS_POSTIT );
824 pStringId = bImpress ? STR_ANNOTATION_WRAP_FORWARD : STR_ANNOTATION_WRAP_FORWARD_DRAW;
826 pStringId = bImpress ? STR_ANNOTATION_WRAP_BACKWARD : STR_ANNOTATION_WRAP_BACKWARD_DRAW;
831 VclMessageType::Question, VclButtonsType::YesNo,
833 xQueryBox->set_default_response(
RET_YES);
834 if (xQueryBox->run() !=
RET_YES)
865 (*iter)->OpenPopup( bEdit );
881 pBindings->
Invalidate( SID_DELETEALL_POSTIT );
896 Reference< XAnnotationAccess > xPage(
mxView->getCurrentPage(), UNO_QUERY );
918 UpdateTagsHdl(
nullptr);
929 mnUpdateTagsEvent =
nullptr;
932 if( mbShowAnnotations )
935 if( mrBase.GetDrawView() )
936 static_cast< ::
sd::View*
>( mrBase.GetDrawView() )->updateHandles();
957 Reference< XAnnotationEnumeration > xEnum(
mxCurrentPage->createAnnotationEnumeration() );
958 while( xEnum->hasMoreElements() )
960 Reference< XAnnotation > xAnnotation( xEnum->nextElement() );
971 if( xSelectedTag.is() )
1013 switch (rEvent.meEventId)
1017 onSelectionChanged();
1022 onSelectionChanged();
1026 mxView.set( mrBase.GetController(), UNO_QUERY );
1027 onSelectionChanged();
1046 std::unique_ptr<weld::Menu> xMenu(xBuilder->weld_menu(
"menu"));
1049 OUString sCurrentAuthor( aUserOptions.
GetFullName() );
1050 OUString sAuthor( xAnnotation->getAuthor() );
1052 OUString
aStr(xMenu->get_label(
".uno:DeleteAllAnnotationByAuthor"));
1053 OUString aReplace( sAuthor );
1054 if( aReplace.isEmpty() )
1055 aReplace =
SdResId( STR_ANNOTATION_NOAUTHOR );
1056 aStr =
aStr.replaceFirst(
"%1", aReplace);
1057 xMenu->set_label(
".uno:DeleteAllAnnotationByAuthor",
aStr);
1059 bool bShowReply = sAuthor != sCurrentAuthor;
1060 xMenu->set_visible(
".uno:ReplyToAnnotation", bShowReply);
1061 xMenu->set_visible(
"separator", bShowReply);
1062 xMenu->set_visible(
".uno:DeleteAnnotation", xAnnotation.is());
1064 auto sId = xMenu->popup_at_rect(pParent, rContextRect);
1066 if (
sId ==
".uno:ReplyToAnnotation")
1070 SfxCallMode::ASYNCHRON, { &aItem });
1072 else if (
sId ==
".uno:DeleteAnnotation")
1075 pDispatcher->
ExecuteList(SID_DELETE_POSTIT, SfxCallMode::ASYNCHRON,
1078 else if (
sId ==
".uno:DeleteAllAnnotationByAuthor")
1080 const SfxStringItem aItem( SID_DELETEALLBYAUTHOR_POSTIT, sAuthor );
1081 pDispatcher->
ExecuteList( SID_DELETEALLBYAUTHOR_POSTIT,
1082 SfxCallMode::ASYNCHRON, { &aItem });
1084 else if (
sId ==
".uno:DeleteAllAnnotation")
1085 pDispatcher->
Execute( SID_DELETEALL_POSTIT );
1092 static const Color aArrayNormal[] = {
1097 return aArrayNormal[ aAuthorIndex %
SAL_N_ELEMENTS( aArrayNormal ) ];
1107 static const Color aArrayLight[] = {
1112 return aArrayLight[ aAuthorIndex %
SAL_N_ELEMENTS( aArrayLight ) ];
1122 static const Color aArrayAnkor[] = {
1127 return aArrayAnkor[ aAuthorIndex %
SAL_N_ELEMENTS( aArrayAnkor ) ];
1135 if( pPage ==
nullptr )
1143 sal_uInt16 nPageNum = (pPage->
GetPageNum() - 1) >> 1;
1210 mxImpl->ExecuteAnnotation( rRequest );
1215 mxImpl->GetAnnotationState(rItemSet);
@ EditViewSelection
The selection in the center pane has changed.
@ MainViewRemoved
The current MainViewShell (the ViewShell displayed in the center pane) has been removed.
@ MainViewAdded
A new ViewShell has been made the MainViewShell.
@ CurrentPageChanged
The current page has changed.
constexpr auto convertTwipToMm100(N n)
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static std::unique_ptr< weld::Builder > CreateBuilder(weld::Widget *pParent, const OUString &rUIFile, bool bMobile=false, sal_uInt64 nLOKWindowId=0)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
bool IsValidAndGregorian() const
sal_Int16 GetYear() const
sal_uInt16 GetDay() const
sal_uInt16 GetMonth() const
static rtl::Reference< SfxItemPool > CreatePool()
OUString getDate(const Date &rDate) const
OUString getTime(const tools::Time &rTime, bool bSec=true, bool b100Sec=false) const
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
OUString GetText(Paragraph const *pPara, sal_Int32 nParaCount=1) const
const SfxItemSet & GetEmptyItemSet() const
Paragraph * GetParagraph(sal_Int32 nAbsPos) const
std::optional< OutlinerParaObject > CreateParaObject(sal_Int32 nStartPara=0, sal_Int32 nParaCount=EE_PARA_ALL) const
bool SetUpdateLayout(bool bUpdate)
Paragraph * Insert(const OUString &rText, sal_Int32 nAbsPos=EE_PARA_APPEND, sal_Int16 nDepth=0)
sal_Int32 GetParagraphCount() const
static SAL_DLLPRIVATE void SetCalcFieldValueHdl(::Outliner *pOutliner)
sal_uInt16 GetMasterSdPageCount(PageKind ePgKind) const
SAL_DLLPRIVATE sal_uInt16 GetAnnotationAuthorIndex(const OUString &rAuthor)
SdPage * GetSdPage(sal_uInt16 nPgNum, PageKind ePgKind) const
SdPage * GetMasterSdPage(sal_uInt16 nPgNum, PageKind ePgKind)
SAL_DLLPRIVATE DocumentType GetDocumentType() const
sal_uInt16 GetSdPageCount(PageKind ePgKind) const
bool IsShowComments() const
void SetShowComments(bool bShow)
PageKind GetPageKind() const
const sd::AnnotationVector & getAnnotations() const
void removeAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation)
void createAnnotation(css::uno::Reference< css::office::XAnnotation > &xAnnotation)
bool IsUndoEnabled() const
sal_uInt16 GetPageNum() const
bool IsMasterPage() const
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 T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
css::uno::Reference< css::frame::XModel3 > GetModel() const
sal_uInt16 GetSlot() const
const SfxItemSet * GetArgs() const
css::uno::Reference< css::frame::XController > GetController() const
constexpr tools::Long Width() const
const vcl::Font & GetAppFont() const
const LocaleDataWrapper & GetLocaleData() const
OUString GetFullName() const
css::uno::Reference< css::drawing::XDrawView > mxView
static Color GetColorLight(sal_uInt16 aAuthorIndex)
void onTagSelected(AnnotationTag const &rTag)
void onSelectionChanged()
css::uno::Reference< css::office::XAnnotation > mxSelectedAnnotation
css::uno::Reference< css::office::XAnnotationAccess > mxCurrentPage
void SelectAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation, bool bEdit=false)
void ShowAnnotations(bool bShow)
void ExecuteEditAnnotation(SfxRequest const &rReq)
SdPage * GetNextPage(SdPage const *pPage, bool bForward)
css::uno::Reference< css::office::XAnnotation > GetAnnotationById(sal_uInt32 nAnnotationId)
void DeleteAnnotationsByAuthor(std::u16string_view sAuthor)
void DeleteAllAnnotations()
void SelectNextAnnotation(bool bForward)
AnnotationManagerImpl(ViewShellBase &rViewShellBase)
void onTagDeselected(AnnotationTag const &rTag)
ImplSVEvent * mnUpdateTagsEvent
void DeleteAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation)
void ExecuteDeleteAnnotation(SfxRequest const &rReq)
void GetSelectedAnnotation(css::uno::Reference< css::office::XAnnotation > &xAnnotation)
virtual void disposing(std::unique_lock< std::mutex > &) override
void InsertAnnotation(const OUString &rText)
void ExecuteInsertAnnotation(SfxRequest const &rReq)
static Color GetColorDark(sal_uInt16 aAuthorIndex)
static Color GetColor(sal_uInt16 aAuthorIndex)
void ExecuteAnnotation(SfxRequest const &rRequest)
SdPage * GetCurrentPage()
void ExecuteAnnotationTagContextMenu(const css::uno::Reference< css::office::XAnnotation > &xAnnotation, weld::Widget *pParent, const ::tools::Rectangle &rContextRect)
void UpdateTags(bool bSynchron=false)
virtual void SAL_CALL notifyEvent(const css::document::EventObject &Event) override
std::vector< rtl::Reference< AnnotationTag > > maTagVector
void GetAnnotationState(SfxItemSet &rItemSet)
void ExecuteReplyToAnnotation(SfxRequest const &rReq)
void GetAnnotationState(SfxItemSet &rItemSet)
void ExecuteAnnotation(SfxRequest const &rRequest)
::rtl::Reference< AnnotationManagerImpl > mxImpl
AnnotationManager(ViewShellBase &rViewShellBase)
const css::uno::Reference< css::office::XAnnotation > & GetAnnotation() const
void SetText(OutlinerParaObject const &rText)
SfxViewShell descendant that the stacked Draw/Impress shells are based on.
std::shared_ptr< ViewShell > GetMainViewShell() const
Return the main view shell stacked on the called ViewShellBase object.
std::shared_ptr< tools::EventMultiplexer > const & GetEventMultiplexer() const
Return an event multiplexer.
DrawDocShell * GetDocShell() const
virtual SdrView * GetDrawView() const override
FontFamily GetFamilyType()
const OUString & GetFamilyName() const
constexpr ::Color COL_AUTHOR9_DARK(0xD1, 0x76, 0x00)
constexpr ::Color COL_AUTHOR7_LIGHT(0xF2, 0xFE, 0xB5)
constexpr ::Color COL_AUTHOR5_LIGHT(0xFF, 0xE3, 0xE5)
constexpr ::Color COL_AUTHOR8_DARK(0x35, 0x55, 0x6B)
constexpr ::Color COL_AUTHOR8_LIGHT(0xE2, 0xEA, 0xF1)
constexpr ::Color COL_AUTHOR7_NORMAL(0xED, 0xFC, 0xA3)
constexpr ::Color COL_AUTHOR2_LIGHT(0xE9, 0xF2, 0xFF)
constexpr ::Color COL_AUTHOR8_NORMAL(0xD3, 0xDE, 0xE8)
constexpr ::Color COL_AUTHOR1_NORMAL(0xFF, 0xFF, 0x9E)
constexpr ::Color COL_AUTHOR9_LIGHT(0xFF, 0xE7, 0xC7)
constexpr ::Color COL_AUTHOR2_DARK(0x06, 0x46, 0xA2)
constexpr ::Color COL_AUTHOR1_LIGHT(0xFF, 0xFF, 0xC3)
constexpr ::Color COL_AUTHOR3_DARK(0x57, 0x9D, 0x1C)
constexpr ::Color COL_AUTHOR6_DARK(0x00, 0x80, 0x80)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_AUTHOR4_NORMAL(0xE4, 0xD2, 0xF5)
constexpr ::Color COL_AUTHOR7_DARK(0x8C, 0x84, 0x00)
constexpr ::Color COL_AUTHOR3_LIGHT(0xE2, 0xFA, 0xCF)
constexpr ::Color COL_AUTHOR5_NORMAL(0xFE, 0xCD, 0xD0)
constexpr ::Color COL_AUTHOR9_NORMAL(0xFF, 0xE2, 0xB9)
constexpr ::Color COL_AUTHOR4_LIGHT(0xEF, 0xE4, 0xF8)
constexpr ::Color COL_AUTHOR5_DARK(0xC5, 0x00, 0x0B)
constexpr ::Color COL_AUTHOR6_NORMAL(0xD2, 0xF6, 0xF6)
constexpr ::Color COL_AUTHOR4_DARK(0x69, 0x2B, 0x9D)
constexpr ::Color COL_AUTHOR6_LIGHT(0xE6, 0xFA, 0xFA)
constexpr ::Color COL_AUTHOR2_NORMAL(0xD8, 0xE8, 0xFF)
constexpr ::Color COL_AUTHOR1_DARK(0xC6, 0x92, 0x00)
constexpr ::Color COL_AUTHOR3_NORMAL(0xDA, 0xF8, 0xC1)
#define TOOLS_WARN_EXCEPTION(area, stream)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
#define LINK(Instance, Class, Member)
#define SAL_N_ELEMENTS(arr)
bool isTiledAnnotations()
static SfxBindings * getBindings(ViewShellBase const &rBase)
IMPL_LINK_NOARG(MainSequence, onTimerHdl, Timer *, void)
std::vector< css::uno::Reference< css::office::XAnnotation > > AnnotationVector
void LOKCommentNotifyAll(CommentNotificationType nType, uno::Reference< office::XAnnotation > const &rxAnnotation)
SfxItemPool * GetAnnotationPool()
static SfxDispatcher * getDispatcher(ViewShellBase const &rBase)
void CreateChangeUndo(const uno::Reference< office::XAnnotation > &xAnnotation)
IMPL_LINK(SdCharHeightPropertyBox, implMenuSelectHdl, const OUString &, rIdent, void)
css::util::DateTime getCurrentDateTime()
OUString getAnnotationDateTimeString(const Reference< XAnnotation > &xAnnotation)
void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell *pViewShell, uno::Reference< office::XAnnotation > const &rxAnnotation)
TextApiObject * getTextApiObject(const Reference< XAnnotation > &xAnnotation)
UNOTOOLS_DLLPUBLIC SvtSaveOptions::ODFSaneDefaultVersion GetODFSaneDefaultVersion()
OUString SdResId(TranslateId aId)
uno::Reference< presentation::XSlideShowView > mxView
Reference< XModel > xModel