25#include <com/sun/star/drawing/XDrawPage.hpp>
35#include <LibreOfficeKit/LibreOfficeKitEnums.h>
52 UndoInsertOrRemoveAnnotation( Annotation& rAnnotation,
bool bInsert );
54 virtual void Undo()
override;
55 virtual void Redo()
override;
65 geometry::RealPoint2D m_Position;
66 geometry::RealSize2D m_Size;
69 util::DateTime m_DateTime;
74 m_Position = xAnnotation->getPosition();
75 m_Size = xAnnotation->getSize();
76 m_Author = xAnnotation->getAuthor();
77 m_Initials = xAnnotation->getInitials();
78 m_DateTime = xAnnotation->getDateTime();
79 uno::Reference<text::XText> xText(xAnnotation->getTextRange());
80 m_Text = xText->getString();
85 xAnnotation->setPosition(m_Position);
86 xAnnotation->setSize(m_Size);
87 xAnnotation->setAuthor(m_Author);
88 xAnnotation->setInitials(m_Initials);
89 xAnnotation->setDateTime(m_DateTime);
90 uno::Reference<text::XText> xText(xAnnotation->getTextRange());
91 xText->setString(m_Text);
98 explicit UndoAnnotation( Annotation& rAnnotation );
100 virtual void Undo()
override;
101 virtual void Redo()
override;
105 AnnotationData maUndoData;
106 AnnotationData maRedoData;
121 : ::
cppu::WeakComponentImplHelper<office::XAnnotation>(
m_aMutex)
122 , ::
cppu::PropertySetMixin<office::XAnnotation>(context, IMPLEMENTS_PROPERTY_SET,
126 , m_bIsFreeText(false)
134void SAL_CALL Annotation::disposing()
137 if( m_TextRange.is() )
139 m_TextRange->dispose();
144uno::Any Annotation::queryInterface(css::uno::Type
const & type)
146 return ::cppu::WeakComponentImplHelper<office::XAnnotation>::queryInterface(
type);
150uno::Reference<beans::XPropertySetInfo> SAL_CALL Annotation::getPropertySetInfo()
152 return ::cppu::PropertySetMixin<office::XAnnotation>::getPropertySetInfo();
155void SAL_CALL Annotation::setPropertyValue(
const OUString & aPropertyName,
const uno::Any & aValue)
160uno::Any SAL_CALL Annotation::getPropertyValue(
const OUString & aPropertyName)
162 return ::cppu::PropertySetMixin<office::XAnnotation>::getPropertyValue(aPropertyName);
165void SAL_CALL Annotation::addPropertyChangeListener(
const OUString & aPropertyName,
const uno::Reference<beans::XPropertyChangeListener> & xListener)
170void SAL_CALL Annotation::removePropertyChangeListener(
const OUString & aPropertyName,
const uno::Reference<beans::XPropertyChangeListener> & xListener)
175void SAL_CALL Annotation::addVetoableChangeListener(
const OUString & aPropertyName,
const uno::Reference<beans::XVetoableChangeListener> & xListener)
180void SAL_CALL Annotation::removeVetoableChangeListener(
const OUString & aPropertyName,
const uno::Reference<beans::XVetoableChangeListener> & xListener)
191 uno::Reference<drawing::XDrawPage> xPage(
mpPage->getUnoPage(), uno::UNO_QUERY );
198geometry::RealPoint2D SAL_CALL Annotation::getPosition()
204void SAL_CALL Annotation::setPosition(
const geometry::RealPoint2D & the_value)
210 m_Position = the_value;
215geometry::RealSize2D SAL_CALL Annotation::getSize()
221void SAL_CALL Annotation::setSize(
const geometry::RealSize2D & the_value)
231OUString SAL_CALL Annotation::getAuthor()
237void SAL_CALL Annotation::setAuthor(
const OUString & the_value)
243 m_Author = the_value;
253void SAL_CALL Annotation::setInitials(
const OUString & the_value)
259 m_Initials = the_value;
263util::DateTime SAL_CALL Annotation::getDateTime()
269void SAL_CALL Annotation::setDateTime(
const util::DateTime & the_value)
275 m_DateTime = the_value;
279void Annotation::createChangeUndo()
283 pModel->
AddUndo( std::make_unique<UndoAnnotation>( *
this ) );
288 uno::Reference< XInterface > xSource(
static_cast<uno::XWeak*
>(
this ) );
291 "OnAnnotationChanged" ,
296uno::Reference<text::XText> SAL_CALL Annotation::getTextRange()
299 if( !m_TextRange.is() && (
mpPage !=
nullptr) )
301 m_TextRange = TextApiObject::create(
static_cast< SdDrawDocument*
>( &
mpPage->getSdrModelFromSdrPage() ) );
311 return std::make_unique< UndoInsertOrRemoveAnnotation >( *pAnnotation, bInsert );
345OString lcl_LOKGetCommentPayload(
CommentNotificationType nType, uno::Reference<office::XAnnotation>
const & rxAnnotation)
349 auto aCommentNode = aJsonWriter.
startNode(
"comment");
351 aJsonWriter.
put(
"action", (nType == CommentNotificationType::Add ?
"Add" :
352 (nType == CommentNotificationType::Remove ?
"Remove" :
353 (nType == CommentNotificationType::Modify ?
"Modify" :
"???"))));
356 if (nType != CommentNotificationType::Remove && rxAnnotation.is())
359 aJsonWriter.
put(
"author", rxAnnotation->getAuthor());
361 uno::Reference<text::XText> xText(rxAnnotation->getTextRange());
362 aJsonWriter.
put(
"text", xText->getString());
364 aJsonWriter.
put(
"parthash", pPage ? OString::number(pPage->
GetHashCode()) : OString());
365 geometry::RealPoint2D
const & rPoint = rxAnnotation->getPosition();
366 geometry::RealSize2D
const & rSize = rxAnnotation->getSize();
369 OString sRectangle = aRectangle.toString();
370 aJsonWriter.
put(
"rectangle", sRectangle.getStr());
383 OString aPayload = lcl_LOKGetCommentPayload(
nType, rxAnnotation);
393 OString aPayload = lcl_LOKGetCommentPayload(
nType, rxAnnotation);
403UndoInsertOrRemoveAnnotation::UndoInsertOrRemoveAnnotation( Annotation& rAnnotation,
bool bInsert )
405, mxAnnotation( &rAnnotation )
409 SdPage* pPage = rAnnotation.GetPage();
412 uno::Reference<office::XAnnotation> xAnnotation( &rAnnotation );
415 auto iter = std::find(rVec.begin(), rVec.end(), xAnnotation);
416 mnIndex += std::distance(rVec.begin(), iter);
420void UndoInsertOrRemoveAnnotation::Undo()
422 SdPage* pPage = mxAnnotation->GetPage();
423 SdrModel* pModel = mxAnnotation->GetModel();
424 if( !(pPage && pModel) )
427 uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation );
439void UndoInsertOrRemoveAnnotation::Redo()
441 SdPage* pPage = mxAnnotation->GetPage();
442 SdrModel* pModel = mxAnnotation->GetModel();
443 if( !(pPage && pModel) )
446 uno::Reference<office::XAnnotation> xAnnotation( mxAnnotation );
459UndoAnnotation::UndoAnnotation( Annotation& rAnnotation )
461, mxAnnotation( &rAnnotation )
463 maUndoData.get( mxAnnotation );
466void UndoAnnotation::Undo()
468 maRedoData.get( mxAnnotation );
469 maUndoData.set( mxAnnotation );
473void UndoAnnotation::Redo()
475 maUndoData.get( mxAnnotation );
476 maRedoData.set( mxAnnotation );
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
const sd::AnnotationVector & getAnnotations() const
void removeAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation)
void addAnnotation(const css::uno::Reference< css::office::XAnnotation > &xAnnotation, int nIndex)
sal_Int64 GetHashCode() const
virtual void SetChanged(bool bFlg=true)
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
bool IsUndoEnabled() const
virtual void libreOfficeKitViewCallback(int nType, const OString &pPayload) const override
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SAL_WARN_UNUSED_RESULT SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
virtual void SAL_CALL removeVetoableChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XVetoableChangeListener > const &listener) SAL_OVERRIDE
virtual void SAL_CALL addPropertyChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XPropertyChangeListener > const &listener) SAL_OVERRIDE
virtual void SAL_CALL addVetoableChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XVetoableChangeListener > const &listener) SAL_OVERRIDE
virtual void SAL_CALL setPropertyValue(rtl::OUString const &propertyName, css::uno::Any const &value) SAL_OVERRIDE
virtual void SAL_CALL removePropertyChangeListener(rtl::OUString const &propertyName, css::uno::Reference< css::beans::XPropertyChangeListener > const &listener) SAL_OVERRIDE
Annotation(const css::uno::Reference< css::uno::XComponentContext > &context, SdPage *pPage)
static sal_uInt32 m_nLastId
static OUString getInitials(const OUString &rName)
void set(css::uno::UnoInterfaceReference const &value)
bool isTiledAnnotations()
Reference< XComponentContext > getProcessComponentContext()
std::vector< css::uno::Reference< css::office::XAnnotation > > AnnotationVector
sal_uInt32 getAnnotationId(const uno::Reference< office::XAnnotation > &xAnnotation)
void createAnnotation(uno::Reference< office::XAnnotation > &xAnnotation, SdPage *pPage)
void LOKCommentNotifyAll(CommentNotificationType nType, uno::Reference< office::XAnnotation > const &rxAnnotation)
const SdPage * getAnnotationPage(const uno::Reference< office::XAnnotation > &xAnnotation)
void CreateChangeUndo(const uno::Reference< office::XAnnotation > &xAnnotation)
std::unique_ptr< SdrUndoAction > CreateUndoInsertOrRemoveAnnotation(const uno::Reference< office::XAnnotation > &xAnnotation, bool bInsert)
void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell *pViewShell, uno::Reference< office::XAnnotation > const &rxAnnotation)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString toISO8601(const css::util::DateTime &rDateTime)
void NotifyDocumentEvent(SdDrawDocument const &rDocument, const OUString &rEventName)