Blame SOURCES/0001-use-the-users-preferred-initials-for-impress-annotat.patch

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