sw/source/core/unocore/unotbl.cxx | 460 +++++++++++++++----------------------- 1 file changed, 187 insertions(+), 273 deletions(-)
New commits: commit c8cf6766fd38d45b73d49cb85dd5fe2d7e3dba50 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 05:04:02 2015 +0200 use helpers some more Change-Id: Ia448046b41d6d7594b1ff6f630dbbd4217e13732 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 5c95be3..73a5f4e 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2108,9 +2108,7 @@ uno::Reference< table::XTableColumns > SwXTextTable::getColumns(void) throw( un uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellName) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt(GetFrmFmt()); - if(!pFmt) - throw uno::RuntimeException(); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); SwTable* pTable = SwTable::FindTable(pFmt); SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox(sCellName)); if(!pBox) @@ -2136,9 +2134,7 @@ uno::Reference<text::XTextTableCursor> SwXTextTable::createCursorByCellName(cons throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt(GetFrmFmt()); - if(!pFmt) - throw uno::RuntimeException(); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); uno::Reference<text::XTextTableCursor> xRet; SwTable* pTable = SwTable::FindTable(pFmt); SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox(sCellName)); @@ -2230,18 +2226,14 @@ uno::Reference<text::XTextRange> SwXTextTable::getAnchor(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt(GetFrmFmt()); - if(!pFmt) - throw uno::RuntimeException(); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); return new SwXTextRange(*pFmt); } void SwXTextTable::dispose(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt = GetFrmFmt(); - if(!pFmt) - throw uno::RuntimeException(); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); SwTable* pTable = SwTable::FindTable(pFmt); SwSelBoxes aSelBoxes; for(auto& rBox : pTable->GetTabSortBoxes() ) @@ -2345,31 +2337,24 @@ uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUStrin { SolarMutexGuard aGuard; uno::Reference< table::XCellRange > aRef; - SwFrmFmt* pFmt(GetFrmFmt()); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - if(!pTable->IsTblComplex()) - { - sal_Int32 nPos = 0; - const OUString sTLName(sRange.getToken(0, ':', nPos)); - const OUString sBRName(sRange.getToken(0, ':', nPos)); - if(sTLName.isEmpty() || sBRName.isEmpty()) - throw uno::RuntimeException(); - SwRangeDescriptor aDesc; - aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1; - sw_GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop ); - sw_GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom ); - - // we should normalize the range now (e.g. A5:C1 will become A1:C5) - // since (depending on what is done later) it will be troublesome - // elsewhere when the cursor in the implementation does not - // point to the top-left and bottom-right cells - aDesc.Normalize(); - return GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc); - } - } - throw uno::RuntimeException(); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); + SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFmt), static_cast<cppu::OWeakObject*>(this)); + sal_Int32 nPos = 0; + const OUString sTLName(sRange.getToken(0, ':', nPos)); + const OUString sBRName(sRange.getToken(0, ':', nPos)); + if(sTLName.isEmpty() || sBRName.isEmpty()) + throw uno::RuntimeException(); + SwRangeDescriptor aDesc; + aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1; + sw_GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop ); + sw_GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom ); + + // we should normalize the range now (e.g. A5:C1 will become A1:C5) + // since (depending on what is done later) it will be troublesome + // elsewhere when the cursor in the implementation does not + // point to the top-left and bottom-right cells + aDesc.Normalize(); + return GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc); } uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray() @@ -2573,32 +2558,24 @@ void SwXTextTable::autoFormat(const OUString& sAutoFmtName) std::exception) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - if(!pTable->IsTblComplex()) + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); + SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFmt), static_cast<cppu::OWeakObject*>(this)); + SwTableAutoFmtTbl aAutoFmtTbl; + aAutoFmtTbl.Load(); + for (size_t i = aAutoFmtTbl.size(); i;) + if( sAutoFmtName == aAutoFmtTbl[ --i ].GetName() ) { - SwTableAutoFmtTbl aAutoFmtTbl; - aAutoFmtTbl.Load(); - for (size_t i = aAutoFmtTbl.size(); i;) - if( sAutoFmtName == aAutoFmtTbl[ --i ].GetName() ) - { - SwSelBoxes aBoxes; - const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); - for (size_t n = 0; n < rTBoxes.size(); ++n) - { - SwTableBox* pBox = rTBoxes[ n ]; - aBoxes.insert( pBox ); - } - UnoActionContext aContext( pFmt->GetDoc() ); - pFmt->GetDoc()->SetTableAutoFmt( aBoxes, aAutoFmtTbl[i] ); - break; - } + SwSelBoxes aBoxes; + const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); + for (size_t n = 0; n < rTBoxes.size(); ++n) + { + SwTableBox* pBox = rTBoxes[ n ]; + aBoxes.insert( pBox ); + } + UnoActionContext aContext( pFmt->GetDoc() ); + pFmt->GetDoc()->SetTableAutoFmt( aBoxes, aAutoFmtTbl[i] ); + break; } - } - else - throw uno::RuntimeException(); } uno::Reference< beans::XPropertySetInfo > SwXTextTable::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception ) @@ -3622,24 +3599,16 @@ uno::Any SwXCellRange::getPropertyValue(const OUString& rPropertyName) } void SwXCellRange::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXCellRange::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXCellRange::GetDataSequence( uno::Sequence< uno::Any > *pAnySeq, //-> first pointer != 0 is used commit b878c2b833b0b4b951bd09edd2642267615b9be7 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 04:35:24 2015 +0200 condense item population code down a bit - the functor argument is likely overkill, but I havent checked yet if there are sideeffects from the item ctor in the previous late eval Change-Id: I439ac3095013945b725ad02ed04076bf008a71c0 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e2ce8a1..5c95be3 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1855,6 +1855,8 @@ public: void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal); bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny); + template<typename Tpoolitem> + inline void AddItemToSet(SfxItemSet& rSet, std::function<Tpoolitem()> aItemFactory, sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember); void ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc); }; @@ -1871,6 +1873,25 @@ void SwTableProperties_Impl::SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMember bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny ) { return aAnyMap.FillValue( nWhichId, nMemberId, rpAny ); } +template<typename Tpoolitem> +void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet, std::function<Tpoolitem()> aItemFactory, sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember) +{ + std::list< std::pair<sal_uInt16, const uno::Any* > > vMemberAndAny; + for(sal_uInt16 nMember : vMember) + { + const uno::Any* pAny = nullptr; + GetProperty(nWhich, nMember, pAny); + if(pAny) + vMemberAndAny.push_back(std::make_pair(nMember, pAny)); + } + if(!vMemberAndAny.empty()) + { + Tpoolitem aItem = aItemFactory(); + for(auto& aMemberAndAny : vMemberAndAny) + aItem.PutValue(*aMemberAndAny.second, aMemberAndAny.first); + rSet.Put(aItem); + } +} void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) { SfxItemSet aSet(rDoc.GetAttrPool(), @@ -1892,32 +1913,12 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) const_cast<SwTable&>(rTbl).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER } - const uno::Any* pBackColor = 0; - GetProperty(RES_BACKGROUND, MID_BACK_COLOR, pBackColor ); - const uno::Any* pBackTrans = 0; - GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENT, pBackTrans ); - const uno::Any* pGrLoc = 0; - GetProperty(RES_BACKGROUND, MID_GRAPHIC_POSITION, pGrLoc ); - const uno::Any* pGrURL = 0; - GetProperty(RES_BACKGROUND, MID_GRAPHIC_URL, pGrURL ); - const uno::Any* pGrFilter = 0; - GetProperty(RES_BACKGROUND, MID_GRAPHIC_FILTER, pGrFilter ); - - if(pBackColor||pBackTrans||pGrURL||pGrFilter||pGrLoc) - { - SvxBrushItem aBrush(rFrmFmt.makeBackgroundBrushItem()); - if(pBackColor) - aBrush.PutValue(*pBackColor, MID_BACK_COLOR); - if(pBackTrans) - aBrush.PutValue(*pBackTrans, MID_GRAPHIC_TRANSPARENT); - if(pGrURL) - aBrush.PutValue(*pGrURL, MID_GRAPHIC_URL); - if(pGrFilter) - aBrush.PutValue(*pGrFilter, MID_GRAPHIC_FILTER); - if(pGrLoc) - aBrush.PutValue(*pGrLoc, MID_GRAPHIC_POSITION); - aSet.Put(aBrush); - } + AddItemToSet<SvxBrushItem>(aSet, [rFrmFmt]() { return rFrmFmt.makeBackgroundBrushItem(); }, RES_BACKGROUND, { + MID_BACK_COLOR, + MID_GRAPHIC_TRANSPARENT, + MID_GRAPHIC_POSITION, + MID_GRAPHIC_URL, + MID_GRAPHIC_FILTER }); bool bPutBreak = true; const uno::Any* pPage; @@ -1942,27 +1943,17 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) } } - const uno::Any* pBreak; - if(bPutBreak && GetProperty(RES_BREAK, 0, pBreak)) - { - SvxFmtBreakItem aBreak(rFrmFmt.GetBreak()); - aBreak.PutValue(*pBreak, 0); - aSet.Put(aBreak); - } + + if(bPutBreak) + AddItemToSet<SvxFmtBreakItem>(aSet, [rFrmFmt]() { return rFrmFmt.GetBreak(); }, RES_BREAK, {0}); const uno::Any* pShadow; if(GetProperty(RES_SHADOW, 0, pShadow)) { SvxShadowItem aShd(rFrmFmt.GetShadow()); - aShd.PutValue(*pShadow, CONVERT_TWIPS); + aShd.PutValue(*pShadow, CONVERT_TWIPS); // putting to CONVERT_TWIPS, but getting from 0? aSet.Put(aShd); } - const uno::Any* pKeep; - if(GetProperty(RES_KEEP, 0, pKeep)) - { - SvxFmtKeepItem aKeep( rFrmFmt.GetKeep() ); - aKeep.PutValue(*pKeep, 0); - aSet.Put(aKeep); - } + AddItemToSet<SvxFmtKeepItem>(aSet, [rFrmFmt]() { return rFrmFmt.GetKeep(); }, RES_KEEP, {0}); const uno::Any* pHOrient; if(GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHOrient)) @@ -1997,32 +1988,12 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) aSz.SetWidth(MINLAY); aSet.Put(aSz); } - const uno::Any* pL(nullptr); - GetProperty(RES_LR_SPACE, MID_L_MARGIN|CONVERT_TWIPS, pL); - const uno::Any* pR(nullptr); - GetProperty(RES_LR_SPACE, MID_R_MARGIN|CONVERT_TWIPS, pR); - if(pL||pR) - { - SvxLRSpaceItem aLR(rFrmFmt.GetLRSpace()); - if(pL) - aLR.PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS); - if(pR) - aLR.PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS); - aSet.Put(aLR); - } - const uno::Any* pU(nullptr); - GetProperty(RES_UL_SPACE, MID_UP_MARGIN|CONVERT_TWIPS, pU); - const uno::Any* pLo(nullptr); - GetProperty(RES_UL_SPACE, MID_LO_MARGIN|CONVERT_TWIPS, pLo); - if(pU||pLo) - { - SvxULSpaceItem aUL(rFrmFmt.GetULSpace()); - if(pU) - aUL.PutValue(*pU, MID_UP_MARGIN|CONVERT_TWIPS); - if(pLo) - aUL.PutValue(*pLo, MID_LO_MARGIN|CONVERT_TWIPS); - aSet.Put(aUL); - } + AddItemToSet<SvxLRSpaceItem>(aSet, [rFrmFmt]() { return rFrmFmt.GetLRSpace(); }, RES_LR_SPACE, { + MID_L_MARGIN|CONVERT_TWIPS, + MID_R_MARGIN|CONVERT_TWIPS }); + AddItemToSet<SvxULSpaceItem>(aSet, [rFrmFmt]() { return rFrmFmt.GetULSpace(); }, RES_UL_SPACE, { + MID_UP_MARGIN|CONVERT_TWIPS, + MID_LO_MARGIN|CONVERT_TWIPS }); const::uno::Any* pSplit(nullptr); if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit)) { commit 86247236b78a31f701317df3c27dbc1d552e09af Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 11:39:14 2015 +0200 use helpers some more Change-Id: I596f25d3098edeef154917201ba6fd2f351517b3 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d7f182d..e2ce8a1 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1306,7 +1306,7 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno: std::exception) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt()); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); SwTable* pTable = SwTable::FindTable( pFmt ); SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine); if(pLn) @@ -1388,7 +1388,7 @@ uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName) throw( { SolarMutexGuard aGuard; uno::Any aRet; - SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt()); + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt(), static_cast<cppu::OWeakObject*>(this)); SwTable* pTable = SwTable::FindTable( pFmt ); SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine); if(pLn) commit e0e1577e54688914f1a44bdf842e650a509aa19f Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 03:09:31 2015 +0200 throw instead of returning an empty Any Change-Id: I299ac48e480517289348c651f28b5c7fc7653362 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 8a3fd0e..d7f182d 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1388,44 +1388,41 @@ uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName) throw( { SolarMutexGuard aGuard; uno::Any aRet; - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt()); + SwTable* pTable = SwTable::FindTable( pFmt ); + SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine); + if(pLn) { - SwTable* pTable = SwTable::FindTable( pFmt ); - SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine); - if(pLn) - { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap().getByName(rPropertyName); - if (!pEntry) - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); + const SfxItemPropertySimpleEntry* pEntry = + m_pPropSet->getPropertyMap().getByName(rPropertyName); + if (!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - switch(pEntry->nWID) + switch(pEntry->nWID) + { + case FN_UNO_ROW_HEIGHT: + case FN_UNO_ROW_AUTO_HEIGHT: { - case FN_UNO_ROW_HEIGHT: - case FN_UNO_ROW_AUTO_HEIGHT: + const SwFmtFrmSize& rSize = pLn->GetFrmFmt()->GetFrmSize(); + if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID) { - const SwFmtFrmSize& rSize = pLn->GetFrmFmt()->GetFrmSize(); - if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID) - { - aRet <<= ATT_VAR_SIZE == rSize.GetHeightSizeType(); - } - else - aRet <<= (sal_Int32)(convertTwipToMm100(rSize.GetSize().Height())); + aRet <<= ATT_VAR_SIZE == rSize.GetHeightSizeType(); } - break; + else + aRet <<= (sal_Int32)(convertTwipToMm100(rSize.GetSize().Height())); + } + break; - case FN_UNO_TABLE_COLUMN_SEPARATORS: - { - lcl_GetTblSeparators(aRet, pTable, pLine->GetTabBoxes()[0], true); - } - break; + case FN_UNO_TABLE_COLUMN_SEPARATORS: + { + lcl_GetTblSeparators(aRet, pTable, pLine->GetTabBoxes()[0], true); + } + break; - default: - { - const SwAttrSet& rSet = pLn->GetFrmFmt()->GetAttrSet(); - m_pPropSet->getPropertyValue(*pEntry, rSet, aRet); - } + default: + { + const SwAttrSet& rSet = pLn->GetFrmFmt()->GetAttrSet(); + m_pPropSet->getPropertyValue(*pEntry, rSet, aRet); } } } commit c78449c8a84923693731c7b0ad622e79f99af603 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 03:04:39 2015 +0200 throw instead of silent noop Change-Id: I47dddce1513a870c27844d88694295c5999c0c7f diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d36884a..8a3fd0e 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1306,81 +1306,78 @@ void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno: std::exception) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) + SwFrmFmt* pFmt = lcl_EnsureCoreConnected(GetFrmFmt()); + SwTable* pTable = SwTable::FindTable( pFmt ); + SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine); + if(pLn) { - SwTable* pTable = SwTable::FindTable( pFmt ); - SwTableLine* pLn = SwXTextTableRow::FindLine(pTable, pLine); - if(pLn) + // Check for a specific property + if ( rPropertyName == "TableRedlineParams" ) { - // 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 ) { - // 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 Row Redline' object - SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties); - } - else - { - throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) ); - } + // Create a 'Table Row Redline' object + SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties); } else { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap().getByName(rPropertyName); - SwDoc* pDoc = pFmt->GetDoc(); - if (!pEntry) - throw beans::UnknownPropertyException("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) + throw beans::UnknownPropertyException("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("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: { - case FN_UNO_ROW_HEIGHT: - case FN_UNO_ROW_AUTO_HEIGHT: + SwFmtFrmSize aFrmSize(pLn->GetFrmFmt()->GetFrmSize()); + if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID) { - SwFmtFrmSize aFrmSize(pLn->GetFrmFmt()->GetFrmSize()); - if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID) - { - bool bSet = *static_cast<sal_Bool const *>(aValue.getValue()); - aFrmSize.SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE); - } - else - { - sal_Int32 nHeight = 0; - aValue >>= nHeight; - Size aSz(aFrmSize.GetSize()); - aSz.Height() = convertMm100ToTwip(nHeight); - aFrmSize.SetSize(aSz); - } - pDoc->SetAttr(aFrmSize, *pLn->ClaimFrmFmt()); + bool bSet = *static_cast<sal_Bool const *>(aValue.getValue()); + aFrmSize.SetHeightSizeType(bSet ? ATT_VAR_SIZE : ATT_FIX_SIZE); } - break; - - case FN_UNO_TABLE_COLUMN_SEPARATORS: + else { - UnoActionContext aContext(pDoc); - SwTable* pTable2 = SwTable::FindTable( pFmt ); - lcl_SetTblSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], true, pDoc); + sal_Int32 nHeight = 0; + aValue >>= nHeight; + Size aSz(aFrmSize.GetSize()); + aSz.Height() = convertMm100ToTwip(nHeight); + aFrmSize.SetSize(aSz); } - break; + pDoc->SetAttr(aFrmSize, *pLn->ClaimFrmFmt()); + } + break; - default: - { - SwFrmFmt* pLnFmt = pLn->ClaimFrmFmt(); - SwAttrSet aSet(pLnFmt->GetAttrSet()); - m_pPropSet->setPropertyValue(*pEntry, aValue, aSet); - pDoc->SetAttr(aSet, *pLnFmt); - } + case FN_UNO_TABLE_COLUMN_SEPARATORS: + { + UnoActionContext aContext(pDoc); + SwTable* pTable2 = SwTable::FindTable( pFmt ); + lcl_SetTblSeparators(aValue, pTable2, pLine->GetTabBoxes()[0], true, pDoc); + } + break; + + default: + { + SwFrmFmt* pLnFmt = pLn->ClaimFrmFmt(); + SwAttrSet aSet(pLnFmt->GetAttrSet()); + m_pPropSet->setPropertyValue(*pEntry, aValue, aSet); + pDoc->SetAttr(aSet, *pLnFmt); } } } commit c34d3eb3eaae4076cf3de5d0cf76fdeaf02c66e8 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 02:58:46 2015 +0200 simplify UNO boilerplate Change-Id: I07538ae4b33a4fa1f07bc6bb4ce6b9af2159e40f diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 71a84eb..d36884a 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3307,27 +3307,21 @@ sal_Int64 SAL_CALL SwXCellRange::getSomething( const uno::Sequence< sal_Int8 >& TYPEINIT1(SwXCellRange, SwClient); OUString SwXCellRange::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXCellRange"); -} + { return OUString("SwXCellRange"); } sal_Bool SwXCellRange::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} + { return cppu::supportsService(this, rServiceName); } -uno::Sequence< OUString > SwXCellRange::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) +uno::Sequence<OUString> SwXCellRange::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) { - uno::Sequence< OUString > aRet(7); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.CellRange"; - pArray[1] = "com.sun.star.style.CharacterProperties"; - pArray[2] = "com.sun.star.style.CharacterPropertiesAsian"; - pArray[3] = "com.sun.star.style.CharacterPropertiesComplex"; - pArray[4] = "com.sun.star.style.ParagraphProperties"; - pArray[5] = "com.sun.star.style.ParagraphPropertiesAsian"; - pArray[6] = "com.sun.star.style.ParagraphPropertiesComplex"; - return aRet; + return { + "com.sun.star.text.CellRange", + "com.sun.star.style.CharacterProperties", + "com.sun.star.style.CharacterPropertiesAsian", + "com.sun.star.style.CharacterPropertiesComplex", + "com.sun.star.style.ParagraphProperties", + "com.sun.star.style.ParagraphPropertiesAsian", + "com.sun.star.style.ParagraphPropertiesComplex" }; } SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, commit 0315bdee186674fe5556442ab9f39cce45f72f39 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 02:56:28 2015 +0200 simplify UNO boilerplate Change-Id: Iec0f4bff0d32c79e3ee8b545abe30d03bddb162b diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 3e43296..71a84eb 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3268,24 +3268,18 @@ void SwXTextTable::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) } OUString SAL_CALL SwXTextTable::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXTextTable"); -} + { return OUString("SwXTextTable"); } sal_Bool SwXTextTable::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} + { return cppu::supportsService(this, rServiceName); } -uno::Sequence< OUString > SwXTextTable::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) +uno::Sequence<OUString> SwXTextTable::getSupportedServiceNames(void) throw(uno::RuntimeException, std::exception) { - uno::Sequence< OUString > aRet(4); - OUString* pArr = aRet.getArray(); - pArr[0] = "com.sun.star.document.LinkTarget"; - pArr[1] = "com.sun.star.text.TextTable"; - pArr[2] = "com.sun.star.text.TextContent"; - pArr[3] = "com.sun.star.text.TextSortable"; - return aRet; + return { + "com.sun.star.document.LinkTarget", + "com.sun.star.text.TextTable", + "com.sun.star.text.TextContent", + "com.sun.star.text.TextSortable" }; } namespace commit 924e88877c2d93e0ae05633b1a4307f6ca2d18e0 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Thu Apr 2 02:53:57 2015 +0200 be honest and throw about unimplemented functions Change-Id: I912297a79d3eb99700dce635ab606eee190350e5 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 2871b84..3e43296 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -3134,24 +3134,16 @@ uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName) } void SwXTextTable::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXTextTable::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXTextTable::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } void SwXTextTable::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); } OUString SwXTextTable::getName(void) throw( uno::RuntimeException, std::exception ) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits