[Libreoffice-commits] core.git: offapi/com sd/source xmloff/source

Caolán McNamara caolanm at redhat.com
Thu Feb 18 11:08:54 UTC 2016


 offapi/com/sun/star/office/XAnnotation.idl     |    3 +++
 sd/source/core/annotations/Annotation.cxx      |   22 ++++++++++++++++++++++
 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, 51 insertions(+), 3 deletions(-)

New commits:
commit 29b9df16dfbf17bbe9c46cd268849e6bfa97c84d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Feb 5 10:44:12 2016 +0000

    [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 at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

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 c1b1065..da351ff 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 02f3ca3..24d0e68 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 0c3638f..827ece4 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 ec6a0d4..04e257e 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 8912761..15758d6 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,


More information about the Libreoffice-commits mailing list