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

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