DOCX import sends 'table row redline' to SW core, and core stores it

This patch adds support in the DOCX importer for the 'table row redline'
to be sent from the DOCX importer, using UNO (as a property of the
table row) to the SW core. Once it reaches the 'table row' - the
'set property' detects this property - and creates an
'SwTableRowRedline' object for it, and adds it to the 'SwExtraRedlineTbl'
object.

Change-Id: Ifd9ba680a722b54116b07dca54841dcba599c517
Reviewed-on: https://gerrit.libreoffice.org/7822
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
This commit is contained in:
Adam Co
2014-02-03 18:00:23 +02:00
committed by Miklos Vajna
parent 257c82d924
commit 50eb0490e3
4 changed files with 157 additions and 39 deletions

View File

@@ -121,6 +121,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 makeTableRedline( SwTableLine& rTableLine, 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,

View File

@@ -1292,6 +1292,63 @@ void makeRedline( SwPaM& rPaM,
throw lang::IllegalArgumentException();
}
void makeTableRedline( SwTableLine& rTableLine,
const OUString& rRedlineType,
const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
throw (lang::IllegalArgumentException, uno::RuntimeException)
{
IDocumentRedlineAccess* pRedlineAccess = rTableLine.GetFrmFmt()->GetDoc();
RedlineType_t eType;
if ( rRedlineType == "TableRowInsert" )
{
eType = nsRedlineType_t::REDLINE_TABLE_ROW_INSERT;
}
else if ( rRedlineType == "TableRowDelete" )
{
eType = nsRedlineType_t::REDLINE_TABLE_ROW_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 ) ) );
}
SwTableRowRedline* pRedline = new SwTableRowRedline( aRedlineData, rTableLine );
RedlineMode_t nPrevMode = pRedlineAccess->GetRedlineMode( );
pRedline->SetExtraData( NULL );
pRedlineAccess->SetRedlineMode_intern(nsRedlineMode_t::REDLINE_ON);
bool bRet = pRedlineAccess->AppendTableRowRedline( pRedline, false );
pRedlineAccess->SetRedlineMode_intern( nPrevMode );
if( !bRet )
throw lang::IllegalArgumentException();
}
SwAnyMapHelper::~SwAnyMapHelper()
{
AnyMapHelper_t::iterator aIt = begin();

View File

@@ -95,6 +95,7 @@
#include <comphelper/servicehelper.hxx>
#include <comphelper/string.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <comphelper/sequenceashashmap.hxx>
using namespace ::com::sun::star;
using ::editeng::SvxBorderLine;
@@ -1352,6 +1353,28 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName,
SwTable* pTable = SwTable::FindTable( pFmt );
SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
if(pLn)
{
// Check for a specific property
if ( rPropertyName == "TableRedlineParams" )
{
// Get the table row properties
uno::Sequence< beans::PropertyValue > tableRowProperties;
tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
OUString sRedlineType;
uno::Any sRedlineTypeValue;
sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", sRedlineTypeValue);
if( sRedlineTypeValue >>= sRedlineType )
{
// Create a 'Table Redline' object
SwUnoCursorHelper::makeTableRedline( *pLn, sRedlineType, tableRowProperties);
}
else
{
throw beans::UnknownPropertyException(OUString( "No redline type property: " ), static_cast < cppu::OWeakObject * > ( this ) );
}
}
else
{
const SfxItemPropertySimpleEntry* pEntry =
m_pPropSet->getPropertyMap().getByName(rPropertyName);
@@ -1402,6 +1425,7 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName,
}
}
}
}
}
uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )

View File

@@ -22,6 +22,7 @@
#include "CellMarginHandler.hxx"
#include "ConversionHelper.hxx"
#include "MeasureHandler.hxx"
#include "TrackChangesHandler.hxx"
#include "TablePropertiesHandler.hxx"
#include "TDefTableHandler.hxx"
#include "DomainMapperTableManager.hxx"
@@ -32,6 +33,7 @@
#include <com/sun/star/text/SizeType.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <dmapperLoggers.hxx>
#include <ooxml/OOXMLFastTokens.hxx>
namespace writerfilter {
@@ -105,6 +107,37 @@ namespace dmapper {
}
}
break;
case NS_ooxml::LN_CT_TrPr_ins:
case NS_ooxml::LN_CT_TrPr_del:
{
writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
if( pProperties.get())
{
sal_Int32 nToken;
switch( nSprmId )
{
case NS_ooxml::LN_CT_TrPr_ins:
nToken = ooxml::OOXML_tableRowInsert;
break;
case NS_ooxml::LN_CT_TrPr_del:
nToken = ooxml::OOXML_tableRowDelete;
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 ));
insertRowProps(pPropMap);
}
}
break;
case 0x3403: // sprmTFCantSplit
case NS_sprm::LN_TCantSplit: // 0x3644
{