2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <sal/config.h>
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2017-05-19 13:01:25 +02:00
|
|
|
#include <boost/property_tree/json_parser.hpp>
|
|
|
|
|
2009-09-16 13:55:36 +00:00
|
|
|
#include <com/sun/star/uno/XComponentContext.hpp>
|
|
|
|
#include <com/sun/star/office/XAnnotation.hpp>
|
|
|
|
#include <com/sun/star/drawing/XDrawPage.hpp>
|
|
|
|
|
|
|
|
#include <comphelper/processfactory.hxx>
|
2017-05-19 13:01:25 +02:00
|
|
|
#include <comphelper/lok.hxx>
|
2009-09-16 13:55:36 +00:00
|
|
|
#include <cppuhelper/propertysetmixin.hxx>
|
2015-08-30 21:24:35 +09:00
|
|
|
#include <cppuhelper/compbase.hxx>
|
2009-09-16 13:55:36 +00:00
|
|
|
#include <cppuhelper/basemutex.hxx>
|
|
|
|
|
2017-05-19 13:01:25 +02:00
|
|
|
#include <unotools/datetime.hxx>
|
|
|
|
#include <tools/datetime.hxx>
|
|
|
|
|
|
|
|
#include <sfx2/viewsh.hxx>
|
2018-05-27 16:44:14 +02:00
|
|
|
#include <svx/svdundo.hxx>
|
2017-05-19 13:01:25 +02:00
|
|
|
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
|
|
|
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <Annotation.hxx>
|
|
|
|
#include <drawdoc.hxx>
|
|
|
|
#include <notifydocumentevent.hxx>
|
|
|
|
#include <sdpage.hxx>
|
|
|
|
#include <textapi.hxx>
|
2009-09-16 13:55:36 +00:00
|
|
|
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::office;
|
|
|
|
using namespace ::com::sun::star::drawing;
|
|
|
|
using namespace ::com::sun::star::geometry;
|
|
|
|
using namespace ::com::sun::star::text;
|
|
|
|
using namespace ::com::sun::star::util;
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
namespace sd {
|
|
|
|
|
|
|
|
class Annotation : private ::cppu::BaseMutex,
|
2015-08-30 21:24:35 +09:00
|
|
|
public ::cppu::WeakComponentImplHelper< XAnnotation>,
|
2016-04-10 21:41:44 +02:00
|
|
|
public ::cppu::PropertySetMixin< XAnnotation >
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit Annotation( const Reference< XComponentContext >& context, SdPage* pPage );
|
2016-04-10 21:41:44 +02:00
|
|
|
Annotation(const Annotation&) = delete;
|
|
|
|
Annotation& operator=(const Annotation&) = delete;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2017-02-19 18:33:46 +05:30
|
|
|
static sal_uInt32 m_nLastId;
|
|
|
|
|
2009-09-16 13:55:36 +00:00
|
|
|
SdPage* GetPage() const { return mpPage; }
|
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects
Added need for SdrModel& in constructors of SdrModel,
SdrPage, SdrView and SdrObjList. Builds, not finished.
SOSAW080: removed and replaced old SdrModel
Removed and replaced GetModel()/SetModel() in all using
classes (SdrObject, SdrPage, SdrView), added accessors
to new referenced SdrModel, adapted all accessing places.
Refactored/Extended ::Clone and ::operator== for these
classes to allow cloning objects to a target SdrModel.
Adapted places where this is done AFAP. Added quite some
comments (tagged with 'TTTT') where possible further work
is needed. Builds completely, thus checking in. This does
not mean that this change is done yet.
SOSAW080: Adapted SdrPage/SdrModel relationship
Also needed to work on copy-construction of SdrPage and hierarchy,
quite some stuff removed, no copy-constructor anymore, no
MigrateItemPool stuff. Builds well, test stuck, will need
some cleanup/finetunung
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Debugging/Stabilizing/MakeUnitTestWork
SOSAW080: Stabilized for UnitTests, cleanups
SOSAW080: Adapted GetObjGraphic to just take a const SdrObject&
SOSAW080: Removed ChangeModel from classes
Classes SvxTextEditSource and SvxDrawPage (including
TextEditSource stuff) do not need change of SdrModel
anymore.
SOSAW080: Adapted some comments to make more readable
SOSAW080: Corrected constructor
SOSAW080: getSdrModelFromUnoModel added override marks
SOSAW080: Added missing includes
SOSAW080: Corrected SdrPage constructor
SOSAW080: Corrected some SdrObject::Clone scenarios
Especially when cloning to another SdrModel and taking
the sdr::properties into account.
SOSAW080: Added include for Mac-Build
SOSAW080: Added Scale to DefaultProperties
If a SdrModel change happens in DefaultProperties copy
constructor (used from Clone()), potentially a Scale
for the SfxItems has to be done.
SOSAW080: Added missing include for MacBuild
SOSAW080: Corrected CppunitTest_sc_anchor_test
An adaption of a SdrPathObj instantiation was missing,
added that. Seems as if that test is no tpart of the
usual 'make' scenario, but used/executed in gerrit builds
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Free SdrObjects when SdrModel goes down
In an UNO API test problem is that SvxShapes reference
SdrShapes, but these are not added to a SdrPage and not
'owned' by the SvxShape. Thus these do not get deleted
at all (same in master, memory leak). I extended
SvxShape::Notify the case for ModelCleared to also
Free the SdrObject when not owner and it's not added to
a SdrPage (in that case it gets deleted with deleting
the SdrModel)
SOSAW080: Solve UNO API calls that move SvxShapes to other Model
Due to UNO API tests I got a call to insert an xShape to a
xDrawPage which was constructed in another Model, this has now to
be done by Cloning the SdrObject to the new SdrModel, getting
rid of the old one and getting all the UNO implementation
stuff right (referemces SdrObject <-> xShape).
1cb7d573d323e98a89761fe662c10c4a654fdec0
24617494a0ef79f6e33dfcb02782a833a81c6434
763f39094b6a48b529a6952d01468f8776c97679
242b9e228a9a042c3a5bdd38b1ea6600144276d5
242b9e228a9a042c3a5bdd38b1ea6600144276d5
33a6f3f306b70c223171aef796dd5ee041ad14df
6878b33f8b05738a44c0910e40a60a0f0d1d58ed
0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2
8c4626274a5cc531dad27f27c0c45d4c528fb2fb
446685a49a6d67aedd01cfbbd5e87b07f97a4d7b
c1b5ed3c99bc7219a0061e4ece24ea42afd2889a
22de9a1c8af7c25be5c108671ddc548ba323ed47
4caf6b6fbbe6e8130741d793dffb560fd01d4ed5
488b9601735ec1822433f82f633990063951fe08
c366d60299f239e3df856ddffedb19e743e4be0c
c5137ba8c597c7b5f90318df50e87b93a39a28dc
f9e646242cf89f6fde1315046952252a2c429779
f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410
1694b54903df784385abaa8452e1201e12344238
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
7b5c241faec7488924e5935ae8b19f785846b5e4
bf097ee7467895823fbd158a2a9543da3b5a5078
Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c
Reviewed-on: https://gerrit.libreoffice.org/52526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-03-01 15:54:32 +01:00
|
|
|
SdrModel* GetModel() { return (mpPage != nullptr) ? &mpPage->getSdrModelFromSdrPage() : nullptr; }
|
2017-02-19 18:33:46 +05:30
|
|
|
sal_uInt32 GetId() const { return m_nId; }
|
2009-09-16 13:55:36 +00:00
|
|
|
|
|
|
|
// XInterface:
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Any SAL_CALL queryInterface(Type const & type) override;
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void SAL_CALL acquire() throw () override { ::cppu::WeakComponentImplHelper< XAnnotation >::acquire(); }
|
|
|
|
virtual void SAL_CALL release() throw () override { ::cppu::WeakComponentImplHelper< XAnnotation >::release(); }
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2015-10-28 12:01:32 +02:00
|
|
|
// css::beans::XPropertySet:
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
|
|
|
|
virtual void SAL_CALL setPropertyValue(const OUString & aPropertyName, const Any & aValue) override;
|
|
|
|
virtual Any SAL_CALL getPropertyValue(const OUString & PropertyName) override;
|
|
|
|
virtual void SAL_CALL addPropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & xListener) override;
|
|
|
|
virtual void SAL_CALL removePropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & aListener) override;
|
|
|
|
virtual void SAL_CALL addVetoableChangeListener(const OUString & PropertyName, const Reference< XVetoableChangeListener > & aListener) override;
|
|
|
|
virtual void SAL_CALL removeVetoableChangeListener(const OUString & PropertyName, const Reference< XVetoableChangeListener > & aListener) override;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2015-10-28 12:01:32 +02:00
|
|
|
// css::office::XAnnotation:
|
2017-01-26 12:28:58 +01:00
|
|
|
virtual css::uno::Any SAL_CALL getAnchor() override;
|
|
|
|
virtual RealPoint2D SAL_CALL getPosition() override;
|
|
|
|
virtual void SAL_CALL setPosition(const RealPoint2D & the_value) override;
|
|
|
|
virtual css::geometry::RealSize2D SAL_CALL getSize() override;
|
|
|
|
virtual void SAL_CALL setSize( const css::geometry::RealSize2D& _size ) override;
|
|
|
|
virtual OUString SAL_CALL getAuthor() override;
|
|
|
|
virtual void SAL_CALL setAuthor(const OUString & the_value) override;
|
|
|
|
virtual OUString SAL_CALL getInitials() override;
|
|
|
|
virtual void SAL_CALL setInitials(const OUString & the_value) override;
|
|
|
|
virtual util::DateTime SAL_CALL getDateTime() override;
|
|
|
|
virtual void SAL_CALL setDateTime(const util::DateTime & the_value) override;
|
|
|
|
virtual Reference< XText > SAL_CALL getTextRange() override;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2017-05-20 11:55:44 +02:00
|
|
|
void createChangeUndo();
|
|
|
|
|
2009-09-16 13:55:36 +00:00
|
|
|
private:
|
|
|
|
// destructor is private and will be called indirectly by the release call virtual ~Annotation() {}
|
|
|
|
|
2015-01-08 23:08:34 +01:00
|
|
|
// override WeakComponentImplHelperBase::disposing()
|
2009-09-16 13:55:36 +00:00
|
|
|
// This function is called upon disposing the component,
|
|
|
|
// if your component needs special work when it becomes
|
|
|
|
// disposed, do it here.
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void SAL_CALL disposing() override;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2017-02-19 18:33:46 +05:30
|
|
|
sal_uInt32 m_nId;
|
2009-09-16 13:55:36 +00:00
|
|
|
SdPage* mpPage;
|
|
|
|
RealPoint2D m_Position;
|
|
|
|
RealSize2D m_Size;
|
|
|
|
OUString m_Author;
|
2016-02-05 10:44:12 +00:00
|
|
|
OUString m_Initials;
|
2009-09-16 13:55:36 +00:00
|
|
|
util::DateTime m_DateTime;
|
|
|
|
rtl::Reference< TextApiObject > m_TextRange;
|
|
|
|
};
|
|
|
|
|
|
|
|
class UndoInsertOrRemoveAnnotation : public SdrUndoAction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
UndoInsertOrRemoveAnnotation( Annotation& rAnnotation, bool bInsert );
|
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void Undo() override;
|
|
|
|
virtual void Redo() override;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
rtl::Reference< Annotation > mxAnnotation;
|
|
|
|
bool mbInsert;
|
|
|
|
int mnIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AnnotationData
|
|
|
|
{
|
|
|
|
RealPoint2D m_Position;
|
|
|
|
RealSize2D m_Size;
|
|
|
|
OUString m_Author;
|
2016-02-05 10:44:12 +00:00
|
|
|
OUString m_Initials;
|
2009-09-16 13:55:36 +00:00
|
|
|
util::DateTime m_DateTime;
|
2017-05-20 11:55:44 +02:00
|
|
|
OUString m_Text;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
|
|
|
void get( const rtl::Reference< Annotation >& xAnnotation )
|
|
|
|
{
|
|
|
|
m_Position = xAnnotation->getPosition();
|
|
|
|
m_Size = xAnnotation->getSize();
|
|
|
|
m_Author = xAnnotation->getAuthor();
|
2016-02-05 10:44:12 +00:00
|
|
|
m_Initials = xAnnotation->getInitials();
|
2009-09-16 13:55:36 +00:00
|
|
|
m_DateTime = xAnnotation->getDateTime();
|
2017-05-20 11:55:44 +02:00
|
|
|
Reference<XText> xText(xAnnotation->getTextRange());
|
|
|
|
m_Text = xText->getString();
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void set( const rtl::Reference< Annotation >& xAnnotation )
|
|
|
|
{
|
|
|
|
xAnnotation->setPosition(m_Position);
|
|
|
|
xAnnotation->setSize(m_Size);
|
|
|
|
xAnnotation->setAuthor(m_Author);
|
2016-02-05 10:44:12 +00:00
|
|
|
xAnnotation->setInitials(m_Initials);
|
2009-09-16 13:55:36 +00:00
|
|
|
xAnnotation->setDateTime(m_DateTime);
|
2017-05-20 11:55:44 +02:00
|
|
|
Reference<XText> xText(xAnnotation->getTextRange());
|
|
|
|
xText->setString(m_Text);
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class UndoAnnotation : public SdrUndoAction
|
|
|
|
{
|
|
|
|
public:
|
2015-10-25 17:33:13 +02:00
|
|
|
explicit UndoAnnotation( Annotation& rAnnotation );
|
2009-09-16 13:55:36 +00:00
|
|
|
|
2015-10-12 16:04:04 +02:00
|
|
|
virtual void Undo() override;
|
|
|
|
virtual void Redo() override;
|
2009-09-16 13:55:36 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
rtl::Reference< Annotation > mxAnnotation;
|
|
|
|
AnnotationData maUndoData;
|
|
|
|
AnnotationData maRedoData;
|
|
|
|
};
|
|
|
|
|
|
|
|
void createAnnotation( Reference< XAnnotation >& xAnnotation, SdPage* pPage )
|
|
|
|
{
|
2013-10-22 23:48:51 +02:00
|
|
|
xAnnotation.set(
|
|
|
|
new Annotation(comphelper::getProcessComponentContext(), pPage));
|
2016-08-01 09:51:02 +02:00
|
|
|
pPage->addAnnotation(xAnnotation, -1);
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 18:33:46 +05:30
|
|
|
sal_uInt32 Annotation::m_nLastId = 1;
|
|
|
|
|
2009-09-16 13:55:36 +00:00
|
|
|
Annotation::Annotation( const Reference< XComponentContext >& context, SdPage* pPage )
|
2015-08-30 21:24:35 +09:00
|
|
|
: ::cppu::WeakComponentImplHelper< XAnnotation >(m_aMutex)
|
2017-04-06 18:31:39 +02:00
|
|
|
, ::cppu::PropertySetMixin< XAnnotation >(context, IMPLEMENTS_PROPERTY_SET, Sequence< OUString >())
|
2017-02-19 18:33:46 +05:30
|
|
|
, m_nId( m_nLastId++ )
|
2009-09-16 13:55:36 +00:00
|
|
|
, mpPage( pPage )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-08 23:08:34 +01:00
|
|
|
// override WeakComponentImplHelperBase::disposing()
|
2009-09-16 13:55:36 +00:00
|
|
|
// This function is called upon disposing the component,
|
|
|
|
// if your component needs special work when it becomes
|
|
|
|
// disposed, do it here.
|
|
|
|
void SAL_CALL Annotation::disposing()
|
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
mpPage = nullptr;
|
2009-09-16 13:55:36 +00:00
|
|
|
if( m_TextRange.is() )
|
|
|
|
{
|
|
|
|
m_TextRange->dispose();
|
|
|
|
m_TextRange.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any Annotation::queryInterface(Type const & type)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
2015-08-30 21:24:35 +09:00
|
|
|
return ::cppu::WeakComponentImplHelper< XAnnotation>::queryInterface(type);
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// com.sun.star.beans.XPropertySet:
|
2017-01-26 12:28:58 +01:00
|
|
|
Reference< XPropertySetInfo > SAL_CALL Annotation::getPropertySetInfo()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
return ::cppu::PropertySetMixin< XAnnotation >::getPropertySetInfo();
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::setPropertyValue(const OUString & aPropertyName, const Any & aValue)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
::cppu::PropertySetMixin< XAnnotation >::setPropertyValue(aPropertyName, aValue);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any SAL_CALL Annotation::getPropertyValue(const OUString & aPropertyName)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
return ::cppu::PropertySetMixin< XAnnotation >::getPropertyValue(aPropertyName);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::addPropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & xListener)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
::cppu::PropertySetMixin< XAnnotation >::addPropertyChangeListener(aPropertyName, xListener);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::removePropertyChangeListener(const OUString & aPropertyName, const Reference< XPropertyChangeListener > & xListener)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
::cppu::PropertySetMixin< XAnnotation >::removePropertyChangeListener(aPropertyName, xListener);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::addVetoableChangeListener(const OUString & aPropertyName, const Reference< XVetoableChangeListener > & xListener)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
::cppu::PropertySetMixin< XAnnotation >::addVetoableChangeListener(aPropertyName, xListener);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::removeVetoableChangeListener(const OUString & aPropertyName, const Reference< XVetoableChangeListener > & xListener)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
::cppu::PropertySetMixin< XAnnotation >::removeVetoableChangeListener(aPropertyName, xListener);
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Any SAL_CALL Annotation::getAnchor()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
Any aRet;
|
|
|
|
if( mpPage )
|
|
|
|
{
|
|
|
|
Reference< XDrawPage > xPage( mpPage->getUnoPage(), UNO_QUERY );
|
|
|
|
aRet <<= xPage;
|
|
|
|
}
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
2015-10-28 12:01:32 +02:00
|
|
|
// css::office::XAnnotation:
|
2017-01-26 12:28:58 +01:00
|
|
|
RealPoint2D SAL_CALL Annotation::getPosition()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
return m_Position;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::setPosition(const RealPoint2D & the_value)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
prepareSet("Position", Any(), Any(), nullptr);
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
createChangeUndo();
|
|
|
|
m_Position = the_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-28 12:01:32 +02:00
|
|
|
// css::office::XAnnotation:
|
2017-01-26 12:28:58 +01:00
|
|
|
RealSize2D SAL_CALL Annotation::getSize()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
return m_Size;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::setSize(const RealSize2D & the_value)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
prepareSet("Size", Any(), Any(), nullptr);
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
createChangeUndo();
|
|
|
|
m_Size = the_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
OUString SAL_CALL Annotation::getAuthor()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
return m_Author;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::setAuthor(const OUString & the_value)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
prepareSet("Author", Any(), Any(), nullptr);
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
createChangeUndo();
|
|
|
|
m_Author = the_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
OUString SAL_CALL Annotation::getInitials()
|
2016-02-05 10:44:12 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
return m_Initials;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::setInitials(const OUString & the_value)
|
2016-02-05 10:44:12 +00:00
|
|
|
{
|
|
|
|
prepareSet("Initials", Any(), Any(), nullptr);
|
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
createChangeUndo();
|
|
|
|
m_Initials = the_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
util::DateTime SAL_CALL Annotation::getDateTime()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
return m_DateTime;
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
void SAL_CALL Annotation::setDateTime(const util::DateTime & the_value)
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
prepareSet("DateTime", Any(), Any(), nullptr);
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
|
|
|
createChangeUndo();
|
|
|
|
m_DateTime = the_value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Annotation::createChangeUndo()
|
|
|
|
{
|
2018-04-09 15:14:44 +02:00
|
|
|
SdrModel* pModel = GetModel(); // TTTT should use reference
|
2009-09-16 13:55:36 +00:00
|
|
|
if( pModel && pModel->IsUndoEnabled() )
|
|
|
|
pModel->AddUndo( new UndoAnnotation( *this ) );
|
|
|
|
|
|
|
|
if( pModel )
|
|
|
|
{
|
|
|
|
pModel->SetChanged();
|
|
|
|
Reference< XInterface > xSource( static_cast<uno::XWeak*>( this ) );
|
2018-04-09 15:14:44 +02:00
|
|
|
NotifyDocumentEvent(
|
|
|
|
static_cast< SdDrawDocument& >( *pModel ),
|
|
|
|
"OnAnnotationChanged" ,
|
|
|
|
xSource );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 12:28:58 +01:00
|
|
|
Reference< XText > SAL_CALL Annotation::getTextRange()
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
osl::MutexGuard g(m_aMutex);
|
2015-11-10 10:23:02 +01:00
|
|
|
if( !m_TextRange.is() && (mpPage != nullptr) )
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects
Added need for SdrModel& in constructors of SdrModel,
SdrPage, SdrView and SdrObjList. Builds, not finished.
SOSAW080: removed and replaced old SdrModel
Removed and replaced GetModel()/SetModel() in all using
classes (SdrObject, SdrPage, SdrView), added accessors
to new referenced SdrModel, adapted all accessing places.
Refactored/Extended ::Clone and ::operator== for these
classes to allow cloning objects to a target SdrModel.
Adapted places where this is done AFAP. Added quite some
comments (tagged with 'TTTT') where possible further work
is needed. Builds completely, thus checking in. This does
not mean that this change is done yet.
SOSAW080: Adapted SdrPage/SdrModel relationship
Also needed to work on copy-construction of SdrPage and hierarchy,
quite some stuff removed, no copy-constructor anymore, no
MigrateItemPool stuff. Builds well, test stuck, will need
some cleanup/finetunung
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Debugging/Stabilizing/MakeUnitTestWork
SOSAW080: Stabilized for UnitTests, cleanups
SOSAW080: Adapted GetObjGraphic to just take a const SdrObject&
SOSAW080: Removed ChangeModel from classes
Classes SvxTextEditSource and SvxDrawPage (including
TextEditSource stuff) do not need change of SdrModel
anymore.
SOSAW080: Adapted some comments to make more readable
SOSAW080: Corrected constructor
SOSAW080: getSdrModelFromUnoModel added override marks
SOSAW080: Added missing includes
SOSAW080: Corrected SdrPage constructor
SOSAW080: Corrected some SdrObject::Clone scenarios
Especially when cloning to another SdrModel and taking
the sdr::properties into account.
SOSAW080: Added include for Mac-Build
SOSAW080: Added Scale to DefaultProperties
If a SdrModel change happens in DefaultProperties copy
constructor (used from Clone()), potentially a Scale
for the SfxItems has to be done.
SOSAW080: Added missing include for MacBuild
SOSAW080: Corrected CppunitTest_sc_anchor_test
An adaption of a SdrPathObj instantiation was missing,
added that. Seems as if that test is no tpart of the
usual 'make' scenario, but used/executed in gerrit builds
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Free SdrObjects when SdrModel goes down
In an UNO API test problem is that SvxShapes reference
SdrShapes, but these are not added to a SdrPage and not
'owned' by the SvxShape. Thus these do not get deleted
at all (same in master, memory leak). I extended
SvxShape::Notify the case for ModelCleared to also
Free the SdrObject when not owner and it's not added to
a SdrPage (in that case it gets deleted with deleting
the SdrModel)
SOSAW080: Solve UNO API calls that move SvxShapes to other Model
Due to UNO API tests I got a call to insert an xShape to a
xDrawPage which was constructed in another Model, this has now to
be done by Cloning the SdrObject to the new SdrModel, getting
rid of the old one and getting all the UNO implementation
stuff right (referemces SdrObject <-> xShape).
1cb7d573d323e98a89761fe662c10c4a654fdec0
24617494a0ef79f6e33dfcb02782a833a81c6434
763f39094b6a48b529a6952d01468f8776c97679
242b9e228a9a042c3a5bdd38b1ea6600144276d5
242b9e228a9a042c3a5bdd38b1ea6600144276d5
33a6f3f306b70c223171aef796dd5ee041ad14df
6878b33f8b05738a44c0910e40a60a0f0d1d58ed
0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2
8c4626274a5cc531dad27f27c0c45d4c528fb2fb
446685a49a6d67aedd01cfbbd5e87b07f97a4d7b
c1b5ed3c99bc7219a0061e4ece24ea42afd2889a
22de9a1c8af7c25be5c108671ddc548ba323ed47
4caf6b6fbbe6e8130741d793dffb560fd01d4ed5
488b9601735ec1822433f82f633990063951fe08
c366d60299f239e3df856ddffedb19e743e4be0c
c5137ba8c597c7b5f90318df50e87b93a39a28dc
f9e646242cf89f6fde1315046952252a2c429779
f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410
1694b54903df784385abaa8452e1201e12344238
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
7b5c241faec7488924e5935ae8b19f785846b5e4
bf097ee7467895823fbd158a2a9543da3b5a5078
Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c
Reviewed-on: https://gerrit.libreoffice.org/52526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-03-01 15:54:32 +01:00
|
|
|
m_TextRange = TextApiObject::create( static_cast< SdDrawDocument* >( &mpPage->getSdrModelFromSdrPage() ) );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
return Reference< XText >( m_TextRange.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const Reference< XAnnotation >& xAnnotation, bool bInsert )
|
|
|
|
{
|
|
|
|
Annotation* pAnnotation = dynamic_cast< Annotation* >( xAnnotation.get() );
|
|
|
|
if( pAnnotation )
|
|
|
|
{
|
|
|
|
return new UndoInsertOrRemoveAnnotation( *pAnnotation, bInsert );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-11-10 10:23:02 +01:00
|
|
|
return nullptr;
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-20 11:55:44 +02:00
|
|
|
void CreateChangeUndo(const css::uno::Reference< css::office::XAnnotation >& xAnnotation)
|
|
|
|
{
|
|
|
|
Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
|
|
|
|
if (pAnnotation)
|
|
|
|
pAnnotation->createChangeUndo();
|
|
|
|
}
|
|
|
|
|
2017-02-19 18:51:13 +05:30
|
|
|
sal_uInt32 getAnnotationId(const Reference<XAnnotation>& xAnnotation)
|
|
|
|
{
|
|
|
|
Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
|
|
|
|
sal_uInt32 nId = 0;
|
|
|
|
if (pAnnotation)
|
|
|
|
nId = pAnnotation->GetId();
|
|
|
|
return nId;
|
|
|
|
}
|
|
|
|
|
2017-02-21 15:20:45 +05:30
|
|
|
const SdPage* getAnnotationPage(const Reference<XAnnotation>& xAnnotation)
|
|
|
|
{
|
|
|
|
Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get());
|
|
|
|
if (pAnnotation)
|
|
|
|
return pAnnotation->GetPage();
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-05-19 13:01:25 +02:00
|
|
|
namespace
|
|
|
|
{
|
2017-08-03 10:23:01 +02:00
|
|
|
std::string lcl_LOKGetCommentPayload(CommentNotificationType nType, Reference<XAnnotation> const & rxAnnotation)
|
2017-05-19 13:01:25 +02:00
|
|
|
{
|
|
|
|
boost::property_tree::ptree aAnnotation;
|
|
|
|
aAnnotation.put("action", (nType == CommentNotificationType::Add ? "Add" :
|
|
|
|
(nType == CommentNotificationType::Remove ? "Remove" :
|
|
|
|
(nType == CommentNotificationType::Modify ? "Modify" : "???"))));
|
|
|
|
aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
|
|
|
|
if (nType != CommentNotificationType::Remove && rxAnnotation.is())
|
|
|
|
{
|
|
|
|
aAnnotation.put("id", sd::getAnnotationId(rxAnnotation));
|
|
|
|
aAnnotation.put("author", rxAnnotation->getAuthor());
|
|
|
|
aAnnotation.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime()));
|
|
|
|
uno::Reference<text::XText> xText(rxAnnotation->getTextRange());
|
|
|
|
aAnnotation.put("text", xText->getString());
|
|
|
|
const SdPage* pPage = sd::getAnnotationPage(rxAnnotation);
|
|
|
|
aAnnotation.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString());
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::property_tree::ptree aTree;
|
|
|
|
aTree.add_child("comment", aAnnotation);
|
|
|
|
std::stringstream aStream;
|
|
|
|
boost::property_tree::write_json(aStream, aTree);
|
|
|
|
|
|
|
|
return aStream.str();
|
|
|
|
}
|
2017-06-04 23:07:12 +02:00
|
|
|
} // anonymous ns
|
2017-05-19 13:01:25 +02:00
|
|
|
|
2017-08-03 10:23:01 +02:00
|
|
|
void LOKCommentNotify(CommentNotificationType nType, const SfxViewShell* pViewShell, Reference<XAnnotation> const & rxAnnotation)
|
2017-05-19 13:01:25 +02:00
|
|
|
{
|
|
|
|
// callbacks only if tiled annotations are explicitly turned off by LOK client
|
|
|
|
if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
|
|
|
|
return ;
|
|
|
|
|
|
|
|
std::string aPayload = lcl_LOKGetCommentPayload(nType, rxAnnotation);
|
|
|
|
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
|
|
|
|
}
|
|
|
|
|
2017-08-03 10:23:01 +02:00
|
|
|
void LOKCommentNotifyAll(CommentNotificationType nType, Reference<XAnnotation> const & rxAnnotation)
|
2017-05-19 13:01:25 +02:00
|
|
|
{
|
|
|
|
// callbacks only if tiled annotations are explicitly turned off by LOK client
|
|
|
|
if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations())
|
|
|
|
return ;
|
|
|
|
|
|
|
|
std::string aPayload = lcl_LOKGetCommentPayload(nType, rxAnnotation);
|
|
|
|
|
|
|
|
const SfxViewShell* pViewShell = SfxViewShell::GetFirst();
|
|
|
|
while (pViewShell)
|
|
|
|
{
|
|
|
|
pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str());
|
|
|
|
pViewShell = SfxViewShell::GetNext(*pViewShell);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-16 13:55:36 +00:00
|
|
|
UndoInsertOrRemoveAnnotation::UndoInsertOrRemoveAnnotation( Annotation& rAnnotation, bool bInsert )
|
|
|
|
: SdrUndoAction( *rAnnotation.GetModel() )
|
|
|
|
, mxAnnotation( &rAnnotation )
|
|
|
|
, mbInsert( bInsert )
|
|
|
|
, mnIndex( 0 )
|
|
|
|
{
|
|
|
|
SdPage* pPage = rAnnotation.GetPage();
|
|
|
|
if( pPage )
|
|
|
|
{
|
|
|
|
Reference< XAnnotation > xAnnotation( &rAnnotation );
|
|
|
|
|
|
|
|
const AnnotationVector& rVec = pPage->getAnnotations();
|
2011-01-01 21:29:08 +00:00
|
|
|
for( AnnotationVector::const_iterator iter = rVec.begin(); iter != rVec.end(); ++iter )
|
2009-09-16 13:55:36 +00:00
|
|
|
{
|
|
|
|
if( (*iter) == xAnnotation )
|
|
|
|
break;
|
|
|
|
|
|
|
|
mnIndex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoInsertOrRemoveAnnotation::Undo()
|
|
|
|
{
|
|
|
|
SdPage* pPage = mxAnnotation->GetPage();
|
|
|
|
SdrModel* pModel = mxAnnotation->GetModel();
|
|
|
|
if( pPage && pModel )
|
|
|
|
{
|
|
|
|
Reference< XAnnotation > xAnnotation( mxAnnotation.get() );
|
|
|
|
if( mbInsert )
|
|
|
|
{
|
|
|
|
pPage->removeAnnotation( xAnnotation );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pPage->addAnnotation( xAnnotation, mnIndex );
|
2017-05-19 13:01:25 +02:00
|
|
|
LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoInsertOrRemoveAnnotation::Redo()
|
|
|
|
{
|
|
|
|
SdPage* pPage = mxAnnotation->GetPage();
|
|
|
|
SdrModel* pModel = mxAnnotation->GetModel();
|
|
|
|
if( pPage && pModel )
|
|
|
|
{
|
|
|
|
Reference< XAnnotation > xAnnotation( mxAnnotation.get() );
|
|
|
|
|
|
|
|
if( mbInsert )
|
|
|
|
{
|
|
|
|
pPage->addAnnotation( xAnnotation, mnIndex );
|
2017-05-19 13:01:25 +02:00
|
|
|
LOKCommentNotifyAll( CommentNotificationType::Add, xAnnotation );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pPage->removeAnnotation( xAnnotation );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
UndoAnnotation::UndoAnnotation( Annotation& rAnnotation )
|
|
|
|
: SdrUndoAction( *rAnnotation.GetModel() )
|
|
|
|
, mxAnnotation( &rAnnotation )
|
|
|
|
{
|
|
|
|
maUndoData.get( mxAnnotation );
|
|
|
|
}
|
|
|
|
|
|
|
|
void UndoAnnotation::Undo()
|
|
|
|
{
|
|
|
|
maRedoData.get( mxAnnotation );
|
|
|
|
maUndoData.set( mxAnnotation );
|
2017-05-20 11:55:44 +02:00
|
|
|
Reference< XAnnotation > xAnnotation( mxAnnotation.get() );
|
|
|
|
LOKCommentNotifyAll( CommentNotificationType::Modify, xAnnotation );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UndoAnnotation::Redo()
|
|
|
|
{
|
|
|
|
maUndoData.get( mxAnnotation );
|
|
|
|
maRedoData.set( mxAnnotation );
|
2017-05-20 11:55:44 +02:00
|
|
|
Reference< XAnnotation > xAnnotation( mxAnnotation.get() );
|
|
|
|
LOKCommentNotifyAll( CommentNotificationType::Modify, xAnnotation );
|
2009-09-16 13:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace sd
|
|
|
|
|
2010-10-12 15:51:52 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|