summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAdam Co <rattles2013@gmail.com>2014-02-03 18:00:23 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-12 08:41:10 +0000
commit50eb0490e328e6d0ceb9b0550d97d5fc4220a82f (patch)
tree19caeda2326aaa70adf19b79a2c3a80c7e8472e5 /sw
parent257c82d924e9c6621c5e631aff29daacc8c4b8cd (diff)
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>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/unocrsrhelper.hxx4
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx57
-rw-r--r--sw/source/core/unocore/unotbl.cxx100
3 files changed, 123 insertions, 38 deletions
diff --git a/sw/inc/unocrsrhelper.hxx b/sw/inc/unocrsrhelper.hxx
index ae5ffd920f74..b50e372b7c84 100644
--- a/sw/inc/unocrsrhelper.hxx
+++ b/sw/inc/unocrsrhelper.hxx
@@ -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,
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index f08021c87f54..116b8b429cc2 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -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();
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index ac05c38801a5..e177150e1758 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -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;
@@ -1353,51 +1354,74 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName,
SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine);
if(pLn)
{
- const SfxItemPropertySimpleEntry* pEntry =
- m_pPropSet->getPropertyMap().getByName(rPropertyName);
- SwDoc* pDoc = pFmt->GetDoc();
- if (!pEntry)
- throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
- if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
- throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
-
- switch(pEntry->nWID)
+ // Check for a specific property
+ if ( rPropertyName == "TableRedlineParams" )
{
- case FN_UNO_ROW_HEIGHT:
- case FN_UNO_ROW_AUTO_HEIGHT:
+ // 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 )
{
- SwFmtFrmSize aFrmSize(pLn->GetFrmFmt()->GetFrmSize());
- if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
+ // 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);
+ SwDoc* pDoc = pFmt->GetDoc();
+ if (!pEntry)
+ throw beans::UnknownPropertyException(OUString( "Unknown property: " ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+ if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
+ throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
+
+ switch(pEntry->nWID)
+ {
+ case FN_UNO_ROW_HEIGHT:
+ case FN_UNO_ROW_AUTO_HEIGHT:
{
- sal_Bool bSet = *(sal_Bool*)aValue.getValue();
- aFrmSize.SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE);
+ SwFmtFrmSize aFrmSize(pLn->GetFrmFmt()->GetFrmSize());
+ if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
+ {
+ sal_Bool bSet = *(sal_Bool*)aValue.getValue();
+ aFrmSize.SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE);
+ }
+ else
+ {
+ sal_Int32 nHeight = 0;
+ aValue >>= nHeight;
+ Size aSz(aFrmSize.GetSize());
+ aSz.Height() = MM100_TO_TWIP(nHeight);
+ aFrmSize.SetSize(aSz);
+ }
+ pDoc->SetAttr(aFrmSize, *pLn->ClaimFrmFmt());
}
- else
+ break;
+
+ case FN_UNO_TABLE_COLUMN_SEPARATORS:
{
- sal_Int32 nHeight = 0;
- aValue >>= nHeight;
- Size aSz(aFrmSize.GetSize());
- aSz.Height() = MM100_TO_TWIP(nHeight);
- aFrmSize.SetSize(aSz);
+ UnoActionContext aContext(pDoc);
+ SwTable* pTable2 = SwTable::FindTable( pFmt );
+ lcl_SetTblSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], sal_True, pDoc);
}
- pDoc->SetAttr(aFrmSize, *pLn->ClaimFrmFmt());
- }
- break;
-
- case FN_UNO_TABLE_COLUMN_SEPARATORS:
- {
- UnoActionContext aContext(pDoc);
- SwTable* pTable2 = SwTable::FindTable( pFmt );
- lcl_SetTblSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], sal_True, pDoc);
- }
- break;
+ break;
- default:
- {
- SwFrmFmt* pLnFmt = pLn->ClaimFrmFmt();
- SwAttrSet aSet(pLnFmt->GetAttrSet());
- m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
- pDoc->SetAttr(aSet, *pLnFmt);
+ default:
+ {
+ SwFrmFmt* pLnFmt = pLn->ClaimFrmFmt();
+ SwAttrSet aSet(pLnFmt->GetAttrSet());
+ m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
+ pDoc->SetAttr(aSet, *pLnFmt);
+ }
}
}
}