From 9ba33206ca799d58fc18c0d320fa0e7c47eb00d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Fri, 5 Feb 2016 10:44:12 +0000
Subject: [PATCH] use the users preferred initials for impress annotations
i.e. the ones entered in the tools->options
and save and load those to/from odf similarly to
what we do for writer annotation initials
Change-Id: Iadc0e994bfaf58632ce25b8f7cdc737580ee97bc
---
offapi/com/sun/star/office/XAnnotation.idl | 3 +++
sd/source/core/annotations/Annotation.cxx | 23 +++++++++++++++++++++++
sd/source/ui/annotations/annotationmanager.cxx | 2 ++
sd/source/ui/annotations/annotationtag.cxx | 8 +++++---
xmloff/source/draw/sdxmlexp.cxx | 12 ++++++++++++
xmloff/source/draw/ximppage.cxx | 7 +++++++
6 files changed, 52 insertions(+), 3 deletions(-)
diff --git a/offapi/com/sun/star/office/XAnnotation.idl b/offapi/com/sun/star/office/XAnnotation.idl
index da3a235..d305743 100644
--- a/offapi/com/sun/star/office/XAnnotation.idl
+++ b/offapi/com/sun/star/office/XAnnotation.idl
@@ -58,6 +58,9 @@ interface XAnnotation
/** stores the full name of the author who created this annotation. */
[attribute] string Author;
+ /** stores the initials of the author who created this annotation. */
+ [attribute] string Initials;
+
/** stores the date and time this annotation was last edited. */
[attribute] ::com::sun::star::util::DateTime DateTime;
diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx
index 21a096b..9c2af42 100644
--- a/sd/source/core/annotations/Annotation.cxx
+++ b/sd/source/core/annotations/Annotation.cxx
@@ -82,6 +82,9 @@ public:
virtual void SAL_CALL setSize( const ::com::sun::star::geometry::RealSize2D& _size ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual OUString SAL_CALL getAuthor() throw (RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setAuthor(const OUString & the_value) throw (RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual OUString SAL_CALL getInitials() throw (RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL setInitials(const OUString & the_value) throw (RuntimeException, std::exception) SAL_OVERRIDE;
+
virtual util::DateTime SAL_CALL getDateTime() throw (RuntimeException, std::exception) SAL_OVERRIDE;
virtual void SAL_CALL setDateTime(const util::DateTime & the_value) throw (RuntimeException, std::exception) SAL_OVERRIDE;
virtual Reference< XText > SAL_CALL getTextRange() throw (RuntimeException, std::exception) SAL_OVERRIDE;
@@ -103,6 +106,7 @@ private:
RealPoint2D m_Position;
RealSize2D m_Size;
OUString m_Author;
+ OUString m_Initials;
util::DateTime m_DateTime;
rtl::Reference< TextApiObject > m_TextRange;
};
@@ -126,6 +130,7 @@ struct AnnotationData
RealPoint2D m_Position;
RealSize2D m_Size;
OUString m_Author;
+ OUString m_Initials;
util::DateTime m_DateTime;
void get( const rtl::Reference< Annotation >& xAnnotation )
@@ -133,6 +138,7 @@ struct AnnotationData
m_Position = xAnnotation->getPosition();
m_Size = xAnnotation->getSize();
m_Author = xAnnotation->getAuthor();
+ m_Initials = xAnnotation->getInitials();
m_DateTime = xAnnotation->getDateTime();
}
@@ -141,6 +147,7 @@ struct AnnotationData
xAnnotation->setPosition(m_Position);
xAnnotation->setSize(m_Size);
xAnnotation->setAuthor(m_Author);
+ xAnnotation->setInitials(m_Initials);
xAnnotation->setDateTime(m_DateTime);
}
};
@@ -290,6 +297,22 @@ void SAL_CALL Annotation::setAuthor(const OUString & the_value) throw (RuntimeEx
}
}
+OUString SAL_CALL Annotation::getInitials() throw (RuntimeException, std::exception)
+{
+ osl::MutexGuard g(m_aMutex);
+ return m_Initials;
+}
+
+void SAL_CALL Annotation::setInitials(const OUString & the_value) throw (RuntimeException, std::exception)
+{
+ prepareSet("Initials", Any(), Any(), nullptr);
+ {
+ osl::MutexGuard g(m_aMutex);
+ createChangeUndo();
+ m_Initials = the_value;
+ }
+}
+
util::DateTime SAL_CALL Annotation::getDateTime() throw (RuntimeException, std::exception)
{
osl::MutexGuard g(m_aMutex);
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
index 99451ab..ce5d487 100644
--- a/sd/source/ui/annotations/annotationmanager.cxx
+++ b/sd/source/ui/annotations/annotationmanager.cxx
@@ -396,6 +396,7 @@ void AnnotationManagerImpl::InsertAnnotation()
// set current author to new annotation
SvtUserOptions aUserOptions;
xAnnotation->setAuthor( aUserOptions.GetFullName() );
+ xAnnotation->setInitials( aUserOptions.GetID() );
// set current time to new annotation
xAnnotation->setDateTime( getCurrentDateTime() );
@@ -467,6 +468,7 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq )
SvtUserOptions aUserOptions;
xAnnotation->setAuthor( aUserOptions.GetFullName() );
+ xAnnotation->setInitials( aUserOptions.GetID() );
// set current time to reply
xAnnotation->setDateTime( getCurrentDateTime() );
diff --git a/sd/source/ui/annotations/annotationtag.cxx b/sd/source/ui/annotations/annotationtag.cxx
index 4faec96..86e4549 100644
--- a/sd/source/ui/annotations/annotationtag.cxx
+++ b/sd/source/ui/annotations/annotationtag.cxx
@@ -517,9 +517,11 @@ BitmapEx AnnotationTag::CreateAnnotationBitmap( bool bSelected )
{
ScopedVclPtrInstance< VirtualDevice > pVDev;
- OUString sAuthor( getInitials( mxAnnotation->getAuthor() ) );
- sAuthor += OUString( ' ' );
- sAuthor += OUString::number( mnIndex );
+ OUString sInitials(mxAnnotation->getInitials());
+ if (sInitials.isEmpty())
+ sInitials = getInitials(mxAnnotation->getAuthor());
+
+ OUString sAuthor(sInitials + " " + OUString::number(mnIndex));
pVDev->SetFont( mrFont );
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 9371913..3698f76 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -2718,6 +2718,18 @@ void SdXMLExport::exportAnnotations( const Reference<XDrawPage>& xDrawPage )
this->Characters(aAuthor);
}
+ if (SvtSaveOptions().GetODFDefaultVersion() > SvtSaveOptions::ODFVER_012)
+ {
+ // initials
+ OUString aInitials( xAnnotation->getInitials() );
+ if( !aInitials.isEmpty() )
+ {
+ SvXMLElementExport aInitialsElem( *this, XML_NAMESPACE_LO_EXT,
+ XML_SENDER_INITIALS, true, false );
+ this->Characters(aInitials);
+ }
+ }
+
{
// date time
com::sun::star::util::DateTime aDate( xAnnotation->getDateTime() );
diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx
index d60ed0f..26e3e7a 100644
--- a/xmloff/source/draw/ximppage.cxx
+++ b/xmloff/source/draw/ximppage.cxx
@@ -67,6 +67,7 @@ private:
Reference< XTextCursor > mxCursor;
OUStringBuffer maAuthorBuffer;
+ OUStringBuffer maInitialsBuffer;
OUStringBuffer maDateBuffer;
};
@@ -141,6 +142,11 @@ SvXMLImportContext * DrawAnnotationContext::CreateChildContext( sal_uInt16 nPref
else if( IsXMLToken( rLocalName, XML_DATE ) )
pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maDateBuffer);
}
+ else if( (XML_NAMESPACE_TEXT == nPrefix || XML_NAMESPACE_LO_EXT == nPrefix) &&
+ IsXMLToken(rLocalName, XML_SENDER_INITIALS) )
+ {
+ pContext = new XMLStringBufferImportContext(GetImport(), nPrefix, rLocalName, maInitialsBuffer);
+ }
else
{
// create text cursor on demand
@@ -188,6 +194,7 @@ void DrawAnnotationContext::EndElement()
if( mxAnnotation.is() )
{
mxAnnotation->setAuthor( maAuthorBuffer.makeStringAndClear() );
+ mxAnnotation->setInitials( maInitialsBuffer.makeStringAndClear() );
util::DateTime aDateTime;
if (::sax::Converter::parseDateTime(aDateTime, 0,
--
2.5.0