sw/inc/unocrsrhelper.hxx                               |    4 +
 sw/source/core/unocore/unocrsrhelper.cxx               |   57 +++++++++++++++++
 sw/source/core/unocore/unotbl.cxx                      |   19 +++++
 writerfilter/source/dmapper/TablePropertiesHandler.cxx |   31 +++++++++
 4 files changed, 111 insertions(+)

New commits:
commit a8db386ad206029ab8c769856f8c452db8712c2b
Author: Adam Co <rattles2...@gmail.com>
Date:   Wed Feb 5 13:46:08 2014 +0200

    DOCX import sends 'table cell redline' to SW core, and core stores it
    
    This patch adds support in the DOCX importer for the 'table cell redline'
    to be sent from the DOCX importer, using UNO (as a property of the
    table cell) to the SW core. Once it reaches the 'table cell' - the
    'set property' detects this property - and creates an
    'SwTableCellRedline' object for it, and adds it to the
    'SwExtraRedlineTbl' object.
    
    Change-Id: Iba038f4109d5505b94cea548e73c614b5cc1b637
    Reviewed-on: https://gerrit.libreoffice.org/7875
    Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk>
    Tested-by: Miklos Vajna <vmik...@collabora.co.uk>

diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx
index 4515e7d..deb31f1 100644
--- a/sw/inc/unocrsrhelper.hxx
+++ b/sw/inc/unocrsrhelper.hxx
@@ -125,6 +125,10 @@ namespace SwUnoCursorHelper
             const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& RedlineProperties )
                 throw (::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::RuntimeException);
 
+    void    makeTableCellRedline( SwTableBox& rTableBox, const OUString& 
RedlineType,
+            const ::com::sun::star::uno::Sequence< 
::com::sun::star::beans::PropertyValue >& RedlineProperties )
+                throw (::com::sun::star::lang::IllegalArgumentException, 
::com::sun::star::uno::RuntimeException);
+
 
     /// @param bTableMode: attributes should be applied to a table selection
     void SetCrsrAttr(SwPaM & rPam, const SfxItemSet & rSet,
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx 
b/sw/source/core/unocore/unocrsrhelper.cxx
index bbbb640..ad11ac1 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -1349,6 +1349,63 @@ void makeTableRowRedline( SwTableLine& rTableLine,
         throw lang::IllegalArgumentException();
 }
 
+void makeTableCellRedline( SwTableBox& rTableBox,
+    const OUString& rRedlineType,
+    const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
+        throw (lang::IllegalArgumentException, uno::RuntimeException)
+{
+    IDocumentRedlineAccess* pRedlineAccess = rTableBox.GetFrmFmt()->GetDoc();
+
+    RedlineType_t eType;
+    if ( rRedlineType == "TableCellInsert" )
+    {
+        eType = nsRedlineType_t::REDLINE_TABLE_CELL_INSERT;
+    }
+    else if ( rRedlineType == "TableCellDelete" )
+    {
+        eType = nsRedlineType_t::REDLINE_TABLE_CELL_DELETE;
+    }
+    else
+    {
+        throw lang::IllegalArgumentException();
+    }
+
+    comphelper::SequenceAsHashMap aPropMap( rRedlineProperties );
+    uno::Any aAuthorValue;
+    aAuthorValue = aPropMap.getUnpackedValueOrDefault("RedlineAuthor", 
aAuthorValue);
+    sal_uInt16 nAuthor = 0;
+    OUString sAuthor;
+    if( aAuthorValue >>= sAuthor )
+        nAuthor = pRedlineAccess->InsertRedlineAuthor(sAuthor);
+
+    OUString sComment;
+    uno::Any aCommentValue;
+    aCommentValue = aPropMap.getUnpackedValueOrDefault("RedlineComment", 
aCommentValue);
+
+    SwRedlineData aRedlineData( eType, nAuthor );
+    if( aCommentValue >>= sComment )
+        aRedlineData.SetComment( sComment );
+
+    ::util::DateTime aStamp;
+    uno::Any aDateTimeValue;
+    aDateTimeValue = aPropMap.getUnpackedValueOrDefault("RedlineDateTime", 
aDateTimeValue);
+    if( aDateTimeValue >>= aStamp )
+    {
+       aRedlineData.SetTimeStamp(
+        DateTime( Date( aStamp.Day, aStamp.Month, aStamp.Year ), Time( 
aStamp.Hours, aStamp.Minutes, aStamp.Seconds ) ) );
+    }
+
+    SwTableCellRedline* pRedline = new SwTableCellRedline( aRedlineData, 
rTableBox );
+    RedlineMode_t nPrevMode = pRedlineAccess->GetRedlineMode( );
+    pRedline->SetExtraData( NULL );
+
+    pRedlineAccess->SetRedlineMode_intern(nsRedlineMode_t::REDLINE_ON);
+    bool bRet = pRedlineAccess->AppendTableCellRedline( pRedline, false );
+    pRedlineAccess->SetRedlineMode_intern( nPrevMode );
+    if( !bRet )
+        throw lang::IllegalArgumentException();
+}
+
 SwAnyMapHelper::~SwAnyMapHelper()
 {
     AnyMapHelper_t::iterator aIt = begin();
diff --git a/sw/source/core/unocore/unotbl.cxx 
b/sw/source/core/unocore/unotbl.cxx
index b265dd6..da659fd 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -1087,6 +1087,25 @@ void SwXCell::setPropertyValue(const OUString& 
rPropertyName, const uno::Any& aV
             SvxFrameDirectionItem aItem( eDir, RES_FRAMEDIR);
             pBox->GetFrmFmt()->SetFmtAttr(aItem);
         }
+        else if  ( rPropertyName == "TableRedlineParams" )
+        {
+            // Get the table row properties
+            uno::Sequence< beans::PropertyValue > tableCellProperties;
+            tableCellProperties = aValue.get< uno::Sequence< 
beans::PropertyValue > >();
+            comphelper::SequenceAsHashMap aPropMap( tableCellProperties );
+            OUString sRedlineType;
+            uno::Any sRedlineTypeValue;
+            sRedlineTypeValue = 
aPropMap.getUnpackedValueOrDefault("RedlineType", sRedlineTypeValue);
+            if( sRedlineTypeValue >>= sRedlineType )
+            {
+                // Create a 'Table Cell Redline' object
+                SwUnoCursorHelper::makeTableCellRedline( *pBox, sRedlineType, 
tableCellProperties);
+            }
+            else
+            {
+                throw beans::UnknownPropertyException(OUString( "No redline 
type property: " ), static_cast < cppu::OWeakObject * > ( this ) );
+            }
+        }
         else
         {
             const SfxItemPropertySimpleEntry* pEntry =
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx 
b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index 0500ddb..dcb0b76 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -138,6 +138,37 @@ namespace dmapper {
                 }
             }
             break;
+            case NS_ooxml::LN_CT_TcPrBase_cellIns:
+            case NS_ooxml::LN_CT_TcPrBase_cellDel:
+            {
+                writerfilter::Reference<Properties>::Pointer_t pProperties = 
rSprm.getProps();
+                if( pProperties.get())
+                {
+                    sal_Int32 nToken;
+                    switch( nSprmId )
+                    {
+                        case NS_ooxml::LN_CT_TcPrBase_cellIns:
+                            nToken = ooxml::OOXML_tableCellInsert;
+                            break;
+                        case NS_ooxml::LN_CT_TcPrBase_cellDel:
+                            nToken = ooxml::OOXML_tableCellDelete;
+                            break;
+                        default:
+                            throw 
::com::sun::star::lang::IllegalArgumentException("illegal redline token type", 
NULL, 0);
+                            break;
+                    };
+                    TrackChangesHandlerPtr pTrackChangesHandler( new 
TrackChangesHandler( nToken ) );
+                    pProperties->resolve(*pTrackChangesHandler);
+                    TablePropertyMapPtr pPropMap( new TablePropertyMap );
+
+                    // Add the 'track changes' properties to the 'table row' 
via UNO.
+                    // This way - in the SW core - when it receives this - it 
will create a new 'Table Redline' object for that row
+                    uno::Sequence<beans::PropertyValue> 
aTableRedlineProperties = pTrackChangesHandler->getRedlineProperties();
+                    pPropMap->Insert( PROP_TABLE_REDLINE_PARAMS , 
uno::makeAny( aTableRedlineProperties ));
+                    cellProps(pPropMap);
+                }
+            }
+            break;
             case 0x3403: // sprmTFCantSplit
             case NS_sprm::LN_TCantSplit: // 0x3644
             {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to