diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-02-05 10:44:12 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-02-18 11:06:27 +0000 |
commit | 29b9df16dfbf17bbe9c46cd268849e6bfa97c84d (patch) | |
tree | 8ec29a7fad837e70671fe282afc0155f271d277b | |
parent | 77d329a90f5c4ba22883b0756af112d8ebdf2599 (diff) |
[API CHANGE] add Author Initials to XAnnotation
and 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
Reviewed-on: https://gerrit.libreoffice.org/22143
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | offapi/com/sun/star/office/XAnnotation.idl | 3 | ||||
-rw-r--r-- | sd/source/core/annotations/Annotation.cxx | 22 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationtag.cxx | 8 | ||||
-rw-r--r-- | xmloff/source/draw/sdxmlexp.cxx | 12 | ||||
-rw-r--r-- | xmloff/source/draw/ximppage.cxx | 7 |
6 files changed, 51 insertions, 3 deletions
diff --git a/offapi/com/sun/star/office/XAnnotation.idl b/offapi/com/sun/star/office/XAnnotation.idl index da3a235ce48c..d305743f255c 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 c1b1065553e5..da351ff5f68d 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -82,6 +82,8 @@ public: virtual void SAL_CALL setSize( const css::geometry::RealSize2D& _size ) throw (css::uno::RuntimeException, std::exception) override; virtual OUString SAL_CALL getAuthor() throw (RuntimeException, std::exception) override; virtual void SAL_CALL setAuthor(const OUString & the_value) throw (RuntimeException, std::exception) override; + virtual OUString SAL_CALL getInitials() throw (RuntimeException, std::exception) override; + virtual void SAL_CALL setInitials(const OUString & the_value) throw (RuntimeException, std::exception) override; virtual util::DateTime SAL_CALL getDateTime() throw (RuntimeException, std::exception) override; virtual void SAL_CALL setDateTime(const util::DateTime & the_value) throw (RuntimeException, std::exception) override; virtual Reference< XText > SAL_CALL getTextRange() throw (RuntimeException, std::exception) override; @@ -102,6 +104,7 @@ private: RealPoint2D m_Position; RealSize2D m_Size; OUString m_Author; + OUString m_Initials; util::DateTime m_DateTime; rtl::Reference< TextApiObject > m_TextRange; }; @@ -125,6 +128,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 ) @@ -132,6 +136,7 @@ struct AnnotationData m_Position = xAnnotation->getPosition(); m_Size = xAnnotation->getSize(); m_Author = xAnnotation->getAuthor(); + m_Initials = xAnnotation->getInitials(); m_DateTime = xAnnotation->getDateTime(); } @@ -140,6 +145,7 @@ struct AnnotationData xAnnotation->setPosition(m_Position); xAnnotation->setSize(m_Size); xAnnotation->setAuthor(m_Author); + xAnnotation->setInitials(m_Initials); xAnnotation->setDateTime(m_DateTime); } }; @@ -289,6 +295,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 02f3ca3af02a..24d0e68d1394 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 0c3638f0db2f..827ece454c84 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()) + " " - + 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 ec6a0d42b640..04e257eab344 100644 --- a/xmloff/source/draw/sdxmlexp.cxx +++ b/xmloff/source/draw/sdxmlexp.cxx @@ -2705,6 +2705,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 css::util::DateTime aDate( xAnnotation->getDateTime() ); diff --git a/xmloff/source/draw/ximppage.cxx b/xmloff/source/draw/ximppage.cxx index 891276165390..15758d6ec517 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, nullptr, |