sw/inc/swtable.hxx | 5 sw/inc/unoframe.hxx | 1 sw/inc/unotbl.hxx | 20 sw/source/core/access/accmap.cxx | 4 sw/source/core/doc/tblafmt.cxx | 4 sw/source/core/unocore/unoframe.cxx | 19 sw/source/core/unocore/unotbl.cxx | 1608 +++++++++++---------------- sw/source/filter/ww8/docxattributeoutput.cxx | 2 sw/source/filter/ww8/wrtw8nds.cxx | 2 sw/source/filter/ww8/wrtww8.cxx | 3 10 files changed, 706 insertions(+), 962 deletions(-)
New commits: commit 30b214b42385e7ef6024b35c0c18ad1cd6411f00 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 19:14:07 2015 +0100 simplify Change-Id: I7161786371adf3b3e719b3e77abf145550db1c44 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 9f0386a..6de9600 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -583,9 +583,9 @@ void SwRangeDescriptor::Normalize() static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRow) { - SwXCell* pXCell = 0; + SwXCell* pXCell = nullptr; const OUString sCellName = sw_GetCellName(nColumn, nRow); - SwTable* pTable = SwTable::FindTable( pFmt ); + SwTable* pTable = SwTable::FindTable(pFmt); SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox( sCellName )); if(pBox) { @@ -2390,48 +2390,30 @@ uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray() const sal_uInt16 nRowCount = getRowCount(); const sal_uInt16 nColCount = getColumnCount(); if(!nRowCount || !nColCount) - { - uno::RuntimeException aRuntime; - aRuntime.Message = "Table too complex"; - throw aRuntime; - } - SwFrmFmt* pFmt = GetFrmFmt(); + throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this)); + SwFrmFmt* pFmt(GetFrmFmt()); uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount); - if(pFmt) + if(!pFmt) + throw uno::RuntimeException(); + sal_uInt16 nRow = 0; + for(auto& rRow : aRowSeq) { - uno::Sequence< uno::Any > * pRowArray = aRowSeq.getArray(); - for(sal_uInt16 nRow = 0; nRow < nRowCount; nRow++) + rRow = uno::Sequence< uno::Any >(nColCount); + sal_uInt16 nCol = 0; + for(auto& rCellAny : rRow) { - uno::Sequence< uno::Any > aColSeq(nColCount); - uno::Any * pColArray = aColSeq.getArray(); - uno::Reference< table::XCell > xCellRef; - for(sal_uInt16 nCol = 0; nCol < nColCount; nCol++) - { - SwXCell* pXCell = lcl_CreateXCell(pFmt, nCol, nRow); - //! keep (additional) reference to object to prevent implicit destruction - //! in following UNO calls (when object will get referenced) - xCellRef = pXCell; - SwTableBox * pBox = pXCell ? pXCell->GetTblBox() : 0; - if(!pBox) - { - throw uno::RuntimeException(); - } - else - { - // check if table box value item is set - SwFrmFmt* pBoxFmt = pBox->GetFrmFmt(); - bool bIsNum = pBoxFmt->GetItemState( RES_BOXATR_VALUE, false ) == SfxItemState::SET; - if(!bIsNum) - pColArray[nCol] <<= lcl_getString(*pXCell); - else - pColArray[nCol] <<= sw_getValue(*pXCell); - } - } - pRowArray[nRow] = aColSeq; + SwXCell* pXCell(lcl_CreateXCell(pFmt, nCol++, nRow)); + uno::Reference<table::XCell> xCell = pXCell; // to prevent distruction in UNO calls + SwTableBox* pBox = pXCell ? pXCell->GetTblBox() : nullptr; + if(!pBox) + throw uno::RuntimeException(); + // check if table box value item is set + SwFrmFmt* pBoxFmt(pBox->GetFrmFmt()); + const bool bIsNum = pBoxFmt->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET; + rCellAny = bIsNum ? uno::makeAny(sw_getValue(*pXCell)) : uno::makeAny(lcl_getString(*pXCell)); } + ++nRow; } - else - throw uno::RuntimeException(); return aRowSeq; } commit 10469041783dcfe98b04d15492cb058b6bd911a8 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:54:18 2015 +0100 simplify a bit Change-Id: I8bafb5195f6c98a7e0e512aec947f0e5e2867c13 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 8d52a74..9f0386a 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2349,12 +2349,12 @@ uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int3 throw lang::IndexOutOfBoundsException(); } -uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByName(const OUString& sRange) +uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUString& sRange) throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; uno::Reference< table::XCellRange > aRef; - SwFrmFmt* pFmt = GetFrmFmt(); + SwFrmFmt* pFmt(GetFrmFmt()); if(pFmt) { SwTable* pTable = SwTable::FindTable( pFmt ); @@ -2375,13 +2375,10 @@ uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByName(const OUSt // elsewhere when the cursor in the implementation does not // point to the top-left and bottom-right cells aDesc.Normalize(); - - aRef = GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc); + return GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc); } } - if(!aRef.is()) - throw uno::RuntimeException(); - return aRef; + throw uno::RuntimeException(); } uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray() commit 690eb78e409665eca4b9e9e5a754459d524529e0 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:51:54 2015 +0100 simplify a bit Change-Id: I6c43307b8af29cef211a45fa568d11389501bb29 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d84dcde..8d52a74 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2322,20 +2322,16 @@ uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, return new SwXCellRange(pUnoCrsr, *pFmt, rDesc); } -uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, - sal_Int32 nRight, sal_Int32 nBottom) - throw (uno::RuntimeException, - lang::IndexOutOfBoundsException, - std::exception) +uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom) + throw(uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception) { SolarMutexGuard aGuard; - uno::Reference< table::XCellRange > aRef; - SwFrmFmt* pFmt = GetFrmFmt(); + SwFrmFmt* pFmt(GetFrmFmt()); if(pFmt && nRight < USHRT_MAX && nBottom < USHRT_MAX && - nLeft <= nRight && nTop <= nBottom && + nLeft <= nRight && nTop <= nBottom && nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 ) { - SwTable* pTable = SwTable::FindTable( pFmt ); + SwTable* pTable = SwTable::FindTable(pFmt); if(!pTable->IsTblComplex()) { SwRangeDescriptor aDesc; @@ -2345,16 +2341,12 @@ uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByPosition(sal_In aDesc.nRight = nRight; const OUString sTLName = sw_GetCellName(aDesc.nLeft, aDesc.nTop); const OUString sBRName = sw_GetCellName(aDesc.nRight, aDesc.nBottom); - // please note that according to the 'if' statement at the begin // sTLName:sBRName already denotes the normalized range string - - aRef = GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc); + return GetRangeByName(pFmt, pTable, sTLName, sBRName, aDesc); } } - if(!aRef.is()) - throw lang::IndexOutOfBoundsException(); - return aRef; + throw lang::IndexOutOfBoundsException(); } uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByName(const OUString& sRange) commit ee1d50f6fb4fd9cf6284b583caf68bf53bd7cf3b Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:49:00 2015 +0100 simplify a bit Change-Id: If0e5ec0d16290aa1934200711e0e894b662ff945 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 3235956..d84dcde 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2291,39 +2291,35 @@ uno::Reference<table::XCell> SwXTextTable::getCellByPosition(sal_Int32 nColumn, throw lang::IndexOutOfBoundsException(); } -uno::Reference< table::XCellRange > SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, SwTable* pTable, - const OUString& rTLName, const OUString& rBRName, - SwRangeDescriptor& rDesc) +uno::Reference<table::XCellRange> SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, SwTable* pTable, + const OUString& rTLName, const OUString& rBRName, + SwRangeDescriptor& rDesc) { SolarMutexGuard aGuard; - uno::Reference< table::XCellRange > aRef; - const SwTableBox* pTLBox = pTable->GetTblBox( rTLName ); - if(pTLBox) + const SwTableBox* pTLBox = pTable->GetTblBox(rTLName); + if(!pTLBox) + return nullptr; + // invalidate all actions + UnoActionRemoveContext aRemoveContext(pFmt->GetDoc()); + const SwStartNode* pSttNd = pTLBox->GetSttNd(); + SwPosition aPos(*pSttNd); + // set cursor to the upper-left cell of the range + SwUnoCrsr* pUnoCrsr = pFmt->GetDoc()->CreateUnoCrsr(aPos, true); + pUnoCrsr->Move(fnMoveForward, fnGoNode); + pUnoCrsr->SetRemainInSection(false); + const SwTableBox* pBRBox(pTable->GetTblBox(rBRName)); + if(!pBRBox) { - // invalidate all actions - UnoActionRemoveContext aRemoveContext(pFmt->GetDoc()); - const SwStartNode* pSttNd = pTLBox->GetSttNd(); - SwPosition aPos(*pSttNd); - // set cursor to the upper-left cell of the range - SwUnoCrsr* pUnoCrsr = pFmt->GetDoc()->CreateUnoCrsr(aPos, true); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); - pUnoCrsr->SetRemainInSection( false ); - const SwTableBox* pBRBox = pTable->GetTblBox( rBRName ); - if(pBRBox) - { - pUnoCrsr->SetMark(); - pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); - pUnoCrsr->Move( fnMoveForward, fnGoNode ); - SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); - pCrsr->MakeBoxSels(); - // pUnoCrsr will be provided and will not be deleted - SwXCellRange* pCellRange = new SwXCellRange(pUnoCrsr, *pFmt, rDesc); - aRef = pCellRange; - } - else - delete pUnoCrsr; + delete pUnoCrsr; + return nullptr; } - return aRef; + pUnoCrsr->SetMark(); + pUnoCrsr->GetPoint()->nNode = *pBRBox->GetSttNd(); + pUnoCrsr->Move( fnMoveForward, fnGoNode ); + SwUnoTableCrsr* pCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); + pCrsr->MakeBoxSels(); + // pUnoCrsr will be provided and will not be deleted + return new SwXCellRange(pUnoCrsr, *pFmt, rDesc); } uno::Reference< table::XCellRange > SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, commit 538e8006b66edff4455bf41cafb30251355b4c7d Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:44:43 2015 +0100 simplify a bit Change-Id: I28f9271783f38d99c452825572fbe858903c49d4 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index ec5ef7d..3235956 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2276,22 +2276,19 @@ throw (uno::RuntimeException, std::exception) cppu::UnoType<lang::XEventListener>::get(), xListener); } -uno::Reference< table::XCell > SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow) +uno::Reference<table::XCell> SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow) throw( uno::RuntimeException, lang::IndexOutOfBoundsException, std::exception ) { SolarMutexGuard aGuard; - uno::Reference< table::XCell > aRef; - SwFrmFmt* pFmt = GetFrmFmt(); + SwFrmFmt* pFmt(GetFrmFmt()); // sheet is unimportant if(nColumn >= 0 && nRow >= 0 && nColumn < USHRT_MAX && nRow < USHRT_MAX && pFmt) { - SwXCell* pXCell = lcl_CreateXCell(pFmt, nColumn, nRow); + auto pXCell = lcl_CreateXCell(pFmt, nColumn, nRow); if(pXCell) - aRef = pXCell; + return pXCell; } - if(!aRef.is()) - throw lang::IndexOutOfBoundsException(); - return aRef; + throw lang::IndexOutOfBoundsException(); } uno::Reference< table::XCellRange > SwXTextTable::GetRangeByName(SwFrmFmt* pFmt, SwTable* pTable, commit 21ce1aed94d7a4c5acdb0ca78d12cd73c67e9f1a Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:39:25 2015 +0100 simplify a bit Change-Id: Ibbc4929720003760a535fbaca38568198a09bba5 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 5fa3c25..ec5ef7d 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2249,17 +2249,13 @@ void SwXTextTable::dispose(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - SwTableSortBoxes& rBoxes = pTable->GetTabSortBoxes(); - SwSelBoxes aSelBoxes; - for(SwTableSortBoxes::const_iterator it = rBoxes.begin(); it != rBoxes.end(); ++it ) - aSelBoxes.insert( *it ); - pFmt->GetDoc()->DeleteRowCol(aSelBoxes); - } - else + if(!pFmt) throw uno::RuntimeException(); + SwTable* pTable = SwTable::FindTable(pFmt); + SwSelBoxes aSelBoxes; + for(auto& rBox : pTable->GetTabSortBoxes() ) + aSelBoxes.insert(rBox); + pFmt->GetDoc()->DeleteRowCol(aSelBoxes); } void SAL_CALL SwXTextTable::addEventListener( commit 48654dea7fa669dfcbddcb0d07cf814a04665dda Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:36:23 2015 +0100 simplify a bit Change-Id: I0329ce26eb080b0aa73302988f258d7c8e90fd6c diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 4ed2c26..5fa3c25 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2179,40 +2179,39 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex SwUnoInternalPaM aPam(*pDoc); // this now needs to return TRUE ::sw::XTextRangeToSwPaM(aPam, xTextRange); - { - UnoActionContext aCont( pDoc ); + UnoActionContext aCont(pDoc); pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); - const SwTable *pTable = 0; + const SwTable* pTable(nullptr); if( 0 != aPam.Start()->nContent.GetIndex() ) { - pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false ); + pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false); } //TODO: if it is the last paragraph than add another one! - if( aPam.HasMark() ) + if(aPam.HasMark()) { pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam); aPam.DeleteMark(); } - pTable = pDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ), - *aPam.GetPoint(), - nRows, - nColumns, - text::HoriOrientation::FULL ); + pTable = pDoc->InsertTable(SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ), + *aPam.GetPoint(), + nRows, + nColumns, + text::HoriOrientation::FULL); if(pTable) { // here, the properties of the descriptor need to be analyzed pTableProps->ApplyTblAttr(*pTable, *pDoc); - SwFrmFmt* pTblFmt = pTable->GetFrmFmt(); - lcl_FormatTable( pTblFmt ); + SwFrmFmt* pTblFmt(pTable->GetFrmFmt()); + lcl_FormatTable(pTblFmt); pTblFmt->Add(this); if(!m_sTableName.isEmpty()) { sal_uInt16 nIndex = 1; OUString sTmpNameIndex(m_sTableName); - while(pDoc->FindTblFmtByName( sTmpNameIndex, true ) && nIndex < USHRT_MAX) + while(pDoc->FindTblFmtByName(sTmpNameIndex, true) && nIndex < USHRT_MAX) { sTmpNameIndex = m_sTableName + OUString::number(nIndex++); } @@ -2221,11 +2220,7 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex const::uno::Any* pName; if(pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName)) - { - OUString sTmp; - (*pName) >>= sTmp; - setName(sTmp); - } + setName(pName->get<OUString>()); bIsDescriptor = false; DELETEZ(pTableProps); } @@ -2237,18 +2232,17 @@ void SwXTextTable::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - attachToRange( xTextRange ); + attachToRange(xTextRange); } -uno::Reference< text::XTextRange > SwXTextTable::getAnchor(void) +uno::Reference<text::XTextRange> SwXTextTable::getAnchor(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt = GetFrmFmt(); + SwFrmFmt* pFmt(GetFrmFmt()); if(!pFmt) throw uno::RuntimeException(); - uno::Reference< text::XTextRange > xRet = new SwXTextRange(*pFmt); - return xRet; + return new SwXTextRange(*pFmt); } void SwXTextTable::dispose(void) throw( uno::RuntimeException, std::exception ) commit c03713242ad9e00359e5a5186a381daa1062b285 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:35:27 2015 +0100 simplify a bit Change-Id: Idc98247f897b53f4837704d3361456ac790a2b3d diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 68e0512..4ed2c26 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2161,79 +2161,76 @@ void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTex { // attachToRange must only be called once if(!bIsDescriptor) /* already attached ? */ - throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast < cppu::OWeakObject * > ( this ) ); + throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this)); - uno::Reference<XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); - SwXTextRange* pRange = 0; - OTextCursorHelper* pCursor = 0; + uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY); + SwXTextRange* pRange(nullptr); + OTextCursorHelper* pCursor(nullptr); if(xRangeTunnel.is()) { - pRange = reinterpret_cast< SwXTextRange * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); - pCursor = reinterpret_cast< OTextCursorHelper * >( - sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); + pRange = reinterpret_cast<SwXTextRange*>( + sal::static_int_cast<sal_IntPtr>(xRangeTunnel->getSomething(SwXTextRange::getUnoTunnelId()))); + pCursor = reinterpret_cast<OTextCursorHelper*>( + sal::static_int_cast<sal_IntPtr>(xRangeTunnel->getSomething(OTextCursorHelper::getUnoTunnelId()))); } - SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; - if(pDoc && nRows && nColumns) + SwDoc* pDoc = pRange ? const_cast<SwDoc*>(pRange->GetDoc()) : pCursor ? const_cast<SwDoc*>(pCursor->GetDoc()) : nullptr; + if(!pDoc || !nRows || !nColumns) + throw lang::IllegalArgumentException(); + SwUnoInternalPaM aPam(*pDoc); + // this now needs to return TRUE + ::sw::XTextRangeToSwPaM(aPam, xTextRange); + { - SwUnoInternalPaM aPam(*pDoc); - // this now needs to return TRUE - ::sw::XTextRangeToSwPaM(aPam, xTextRange); + UnoActionContext aCont( pDoc ); + pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); + const SwTable *pTable = 0; + if( 0 != aPam.Start()->nContent.GetIndex() ) + { + pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false ); + } + //TODO: if it is the last paragraph than add another one! + if( aPam.HasMark() ) + { + pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam); + aPam.DeleteMark(); + } + pTable = pDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ), + *aPam.GetPoint(), + nRows, + nColumns, + text::HoriOrientation::FULL ); + if(pTable) { - UnoActionContext aCont( pDoc ); + // here, the properties of the descriptor need to be analyzed + pTableProps->ApplyTblAttr(*pTable, *pDoc); + SwFrmFmt* pTblFmt = pTable->GetFrmFmt(); + lcl_FormatTable( pTblFmt ); - pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_EMPTY, NULL); - const SwTable *pTable = 0; - if( 0 != aPam.Start()->nContent.GetIndex() ) - { - pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false ); - } - //TODO: if it is the last paragraph than add another one! - if( aPam.HasMark() ) - { - pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam); - aPam.DeleteMark(); - } - pTable = pDoc->InsertTable( SwInsertTableOptions( tabopts::HEADLINE | tabopts::DEFAULT_BORDER | tabopts::SPLIT_LAYOUT, 0 ), - *aPam.GetPoint(), - nRows, - nColumns, - text::HoriOrientation::FULL ); - if(pTable) + pTblFmt->Add(this); + if(!m_sTableName.isEmpty()) { - // here, the properties of the descriptor need to be analyzed - pTableProps->ApplyTblAttr(*pTable, *pDoc); - SwFrmFmt* pTblFmt = pTable->GetFrmFmt(); - lcl_FormatTable( pTblFmt ); - - pTblFmt->Add(this); - if(!m_sTableName.isEmpty()) + sal_uInt16 nIndex = 1; + OUString sTmpNameIndex(m_sTableName); + while(pDoc->FindTblFmtByName( sTmpNameIndex, true ) && nIndex < USHRT_MAX) { - sal_uInt16 nIndex = 1; - OUString sTmpNameIndex(m_sTableName); - while(pDoc->FindTblFmtByName( sTmpNameIndex, true ) && nIndex < USHRT_MAX) - { - sTmpNameIndex = m_sTableName + OUString::number(nIndex++); - } - pDoc->SetTableName( *pTblFmt, sTmpNameIndex); + sTmpNameIndex = m_sTableName + OUString::number(nIndex++); } + pDoc->SetTableName( *pTblFmt, sTmpNameIndex); + } - const::uno::Any* pName; - if(pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName)) - { - OUString sTmp; - (*pName) >>= sTmp; - setName(sTmp); - } - bIsDescriptor = false; - DELETEZ(pTableProps); + const::uno::Any* pName; + if(pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName)) + { + OUString sTmp; + (*pName) >>= sTmp; + setName(sTmp); } - pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); + bIsDescriptor = false; + DELETEZ(pTableProps); } + pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_END, NULL ); } - else - throw lang::IllegalArgumentException(); } void SwXTextTable::attach(const uno::Reference< text::XTextRange > & xTextRange) commit cd0a92f1d61c8653f158bf5c49912e1257c1fd05 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:24:48 2015 +0100 simplify Change-Id: I1893f53d1bc4996db862301fc4350339802858ff diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 0a1a57b..68e0512 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2141,24 +2141,19 @@ uno::Sequence<OUString> SwXTextTable::getCellNames(void) throw( uno::RuntimeExce return comphelper::containerToSequence<OUString>(aAllNames); } -uno::Reference< text::XTextTableCursor > SwXTextTable::createCursorByCellName(const OUString& sCellName) +uno::Reference<text::XTextTableCursor> SwXTextTable::createCursorByCellName(const OUString& sCellName) throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - uno::Reference< text::XTextTableCursor > xRet; - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox( sCellName )); - if(pBox && pBox->getRowSpan() > 0 ) - { - xRet = new SwXTextTableCursor(pFmt, pBox); - } - } - if(!xRet.is()) + SwFrmFmt* pFmt(GetFrmFmt()); + if(!pFmt) throw uno::RuntimeException(); - return xRet; + uno::Reference<text::XTextTableCursor> xRet; + SwTable* pTable = SwTable::FindTable(pFmt); + SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox(sCellName)); + if(!pBox || pBox->getRowSpan() == 0) + throw uno::RuntimeException(); + return new SwXTextTableCursor(pFmt, pBox); } void SwXTextTable::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) commit 8e3c3adbf0132fd0ce4f4bd113274392297c0b23 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 18:20:32 2015 +0100 simplify, kill manual memory management Change-Id: I1501cc9912ab555125933a3c5c9ffe9d1d7a9557 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d1ac85c..0a1a57b 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -98,6 +98,7 @@ #include <comphelper/servicehelper.hxx> #include <comphelper/string.hxx> #include <cppuhelper/supportsservice.hxx> +#include <comphelper/sequence.hxx> #include <comphelper/sequenceashashmap.hxx> #include <swtable.hxx> @@ -593,19 +594,17 @@ static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRo return pXCell; } -static void lcl_InspectLines(SwTableLines& rLines, std::vector<OUString*>& rAllNames) +static void lcl_InspectLines(SwTableLines& rLines, std::vector<OUString>& rAllNames) { for(auto pLine : rLines) { for(auto pBox : pLine->GetTabBoxes()) { - if(!pBox->GetName().isEmpty() && pBox->getRowSpan() > 0 ) - rAllNames.push_back( new OUString(pBox->GetName()) ); + if(!pBox->GetName().isEmpty() && pBox->getRowSpan() > 0) + rAllNames.push_back(pBox->GetName()); SwTableLines& rBoxLines = pBox->GetTabLines(); if(!rBoxLines.empty()) - { lcl_InspectLines(rBoxLines, rAllNames); - } } } } @@ -2128,27 +2127,18 @@ uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellNa return SwXCell::CreateXCell(pFmt, pBox); } -uno::Sequence< OUString > SwXTextTable::getCellNames(void) throw( uno::RuntimeException, std::exception ) +uno::Sequence<OUString> SwXTextTable::getCellNames(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - // exists at the table and at all boxes - SwTableLines& rTblLines = pTable->GetTabLines(); - std::vector<OUString*> aAllNames; - lcl_InspectLines(rTblLines, aAllNames); - uno::Sequence< OUString > aRet( static_cast<sal_Int32>(aAllNames.size()) ); - OUString* pArray = aRet.getArray(); - for( size_t i = 0; i < aAllNames.size(); ++i) - { - pArray[i] = *aAllNames[i]; - delete aAllNames[i]; - } - return aRet; - } - return uno::Sequence< OUString >(); + SwFrmFmt* pFmt(GetFrmFmt()); + if(!pFmt) + return {}; + SwTable* pTable = SwTable::FindTable(pFmt); + // exists at the table and at all boxes + SwTableLines& rTblLines = pTable->GetTabLines(); + std::vector<OUString> aAllNames; + lcl_InspectLines(rTblLines, aAllNames); + return comphelper::containerToSequence<OUString>(aAllNames); } uno::Reference< text::XTextTableCursor > SwXTextTable::createCursorByCellName(const OUString& sCellName) commit 0056e34ae80ef57daf0567020a147cc914b7ab4e Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:57:06 2015 +0100 flatten and simplify Change-Id: Ibc09d895714ba0ea44c3a73a13eb80ccff7415e6 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 80034e6..d1ac85c 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2115,23 +2115,17 @@ uno::Reference< table::XTableColumns > SwXTextTable::getColumns(void) throw( un return xResult; } -uno::Reference< table::XCell > SwXTextTable::getCellByName(const OUString& sCellName) throw( uno::RuntimeException, std::exception ) +uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellName) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - uno::Reference< table::XCell > xRet; - SwFrmFmt* pFmt = GetFrmFmt(); - if(pFmt) - { - SwTable* pTable = SwTable::FindTable( pFmt ); - SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox( sCellName )); - if(pBox) - { - xRet = SwXCell::CreateXCell(pFmt, pBox); - } - } - else + SwFrmFmt* pFmt(GetFrmFmt()); + if(!pFmt) throw uno::RuntimeException(); - return xRet; + SwTable* pTable = SwTable::FindTable(pFmt); + SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTblBox(sCellName)); + if(!pBox) + return nullptr; + return SwXCell::CreateXCell(pFmt, pBox); } uno::Sequence< OUString > SwXTextTable::getCellNames(void) throw( uno::RuntimeException, std::exception ) commit cb555c12a2aef08e9b53698f6b0e753d43142551 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:53:36 2015 +0100 simplify Change-Id: Id48493c820e8052730e3f13270b5071161ba9f26 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 6ceecbe..80034e6 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2065,26 +2065,19 @@ SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) SwXTextTable::~SwXTextTable() { delete pTableProps; } -uno::Reference<text::XTextTable> -SwXTextTable::CreateXTextTable(SwFrmFmt *const pFrmFmt) +uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrmFmt* const pFrmFmt) { uno::Reference<text::XTextTable> xTable; - if (pFrmFmt) - { + if(pFrmFmt) xTable.set(pFrmFmt->GetXObject(), uno::UNO_QUERY); // cached? - } - if (!xTable.is()) - { - SwXTextTable *const pNew( - (pFrmFmt) ? new SwXTextTable(*pFrmFmt) : new SwXTextTable()); - xTable.set(pNew); - if (pFrmFmt) - { - pFrmFmt->SetXObject(xTable); - } - // need a permanent Reference to initialize m_wThis - pNew->m_pImpl->m_wThis = xTable; - } + if(xTable.is()) + return xTable; + SwXTextTable* const pNew( (pFrmFmt) ? new SwXTextTable(*pFrmFmt) : new SwXTextTable()); + xTable.set(pNew); + if(pFrmFmt) + pFrmFmt->SetXObject(xTable); + // need a permanent Reference to initialize m_wThis + pNew->m_pImpl->m_wThis = xTable; return xTable; } @@ -2092,11 +2085,8 @@ void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC) throw( uno::RuntimeExc { if(!bIsDescriptor || nR <= 0 || nC <= 0 || nR >= USHRT_MAX || nC >= USHRT_MAX ) throw uno::RuntimeException(); - else - { - nRows = (sal_uInt16)nR; - nColumns = (sal_uInt16)nC; - } + nRows = static_cast<sal_uInt16>(nR); + nColumns = static_cast<sal_uInt16>(nC); } uno::Reference< table::XTableRows > SwXTextTable::getRows(void) throw( uno::RuntimeException, std::exception ) commit 2535e00ea70956ea56f2a3d9c0e80a40265d5f68 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:48:48 2015 +0100 formatting Change-Id: Idb189972e5d485bb0bf0655eb2b8e90c4cd21a53 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 8fc75d6..6ceecbe 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2022,18 +2022,15 @@ namespace } const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId() -{ - return theSwXTextTableUnoTunnelId::get().getSeq(); -} + { return theSwXTextTableUnoTunnelId::get().getSeq(); } sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId ) throw(uno::RuntimeException, std::exception) { - if( rId.getLength() == 16 - && 0 == memcmp( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) + if(rId.getLength() == 16 + && 0 == memcmp(getUnoTunnelId().getConstArray(), rId.getConstArray(), 16)) { - return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); + return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); } return 0; } @@ -2050,8 +2047,7 @@ SwXTextTable::SwXTextTable() nColumns(2), bFirstRowAsLabel(false), bFirstColumnAsLabel(false) -{ -} +{ } SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) : SwClient( &rFrmFmt ) @@ -2064,13 +2060,10 @@ SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) nColumns(0), bFirstRowAsLabel(false), bFirstColumnAsLabel(false) -{ -} +{ } SwXTextTable::~SwXTextTable() -{ - delete pTableProps; -} + { delete pTableProps; } uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrmFmt *const pFrmFmt) commit 91175c7ef111e49b13b8cd6c1f43ddc478eab5ee Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:46:29 2015 +0100 simplify a bit Change-Id: I885834add47a7ae18ae97c05794a5b6e7bc72aa7 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 985fd1d..8fc75d6 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1869,8 +1869,8 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) const SwFrmFmt &rFrmFmt = *rTbl.GetFrmFmt(); if(GetProperty(FN_TABLE_HEADLINE_REPEAT, 0xff, pRepHead )) { - bool bVal = *static_cast<sal_Bool const *>(pRepHead->getValue()); - ((SwTable&)rTbl).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER + bool bVal(pRepHead->get<bool>()); + const_cast<SwTable&>(rTbl).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER } const uno::Any* pBackColor = 0; @@ -1904,21 +1904,18 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) const uno::Any* pPage; if(GetProperty(FN_UNO_PAGE_STYLE, 0, pPage) || GetProperty(RES_PAGEDESC, 0xff, pPage)) { - OUString sPageStyle; - (*pPage) >>= sPageStyle; - if (!sPageStyle.isEmpty()) + OUString sPageStyle = pPage->get<OUString>(); + if(!sPageStyle.isEmpty()) { - SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true ); + SwStyleNameMapper::FillUIName(sPageStyle, sPageStyle, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true); const SwPageDesc* pDesc = SwPageDesc::GetByName(rDoc, sPageStyle); if(pDesc) { - SwFmtPageDesc aDesc( pDesc ); + SwFmtPageDesc aDesc(pDesc); const uno::Any* pPgNo; - if(GetProperty(RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET, pPgNo )) + if(GetProperty(RES_PAGEDESC, MID_PAGEDESC_PAGENUMOFFSET, pPgNo)) { - sal_Int16 nTmp = 0; - (*pPgNo) >>= nTmp; - aDesc.SetNumOffset( nTmp ); + aDesc.SetNumOffset(pPgNo->get<sal_Int16>()); } aSet.Put(aDesc); bPutBreak = false; @@ -1929,14 +1926,14 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) const uno::Any* pBreak; if(bPutBreak && GetProperty(RES_BREAK, 0, pBreak)) { - SvxFmtBreakItem aBreak ( rFrmFmt.GetBreak() ); + SvxFmtBreakItem aBreak(rFrmFmt.GetBreak()); aBreak.PutValue(*pBreak, 0); aSet.Put(aBreak); } const uno::Any* pShadow; if(GetProperty(RES_SHADOW, 0, pShadow)) { - SvxShadowItem aShd ( rFrmFmt.GetShadow() ); + SvxShadowItem aShd(rFrmFmt.GetShadow()); aShd.PutValue(*pShadow, CONVERT_TWIPS); aSet.Put(aShd); } @@ -1951,29 +1948,28 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) const uno::Any* pHOrient; if(GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHOrient)) { - SwFmtHoriOrient aOrient ( rFrmFmt.GetHoriOrient() ); - ((SfxPoolItem&)aOrient).PutValue(*pHOrient, MID_HORIORIENT_ORIENT|CONVERT_TWIPS); + SwFmtHoriOrient aOrient(rFrmFmt.GetHoriOrient()); + aOrient.PutValue(*pHOrient, MID_HORIORIENT_ORIENT|CONVERT_TWIPS); aSet.Put(aOrient); } - const uno::Any* pSzRel = 0; - GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel ); - const uno::Any* pRelWidth = 0; + const uno::Any* pSzRel(nullptr); + GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel); + const uno::Any* pRelWidth(nullptr); GetProperty(FN_TABLE_RELATIVE_WIDTH, 0xff, pRelWidth); - const uno::Any* pWidth = 0; - GetProperty(FN_TABLE_WIDTH, 0xff, pWidth ); + const uno::Any* pWidth(nullptr); + GetProperty(FN_TABLE_WIDTH, 0xff, pWidth); - bool bPutSize = pWidth != 0; - SwFmtFrmSize aSz( ATT_VAR_SIZE); + bool bPutSize = pWidth != nullptr; + SwFmtFrmSize aSz(ATT_VAR_SIZE); if(pWidth) { - ((SfxPoolItem&)aSz).PutValue(*pWidth, MID_FRMSIZE_WIDTH); + aSz.PutValue(*pWidth, MID_FRMSIZE_WIDTH); bPutSize = true; } - bool bTemp = pSzRel && *static_cast<sal_Bool const *>(pSzRel->getValue()); - if(pSzRel && bTemp && pRelWidth) + if(pSzRel && pSzRel->get<bool>() && pRelWidth) { - ((SfxPoolItem&)aSz).PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS); + aSz.PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS); bPutSize = true; } if(bPutSize) @@ -1982,43 +1978,41 @@ void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) aSz.SetWidth(MINLAY); aSet.Put(aSz); } - const uno::Any* pL = 0; + const uno::Any* pL(nullptr); GetProperty(RES_LR_SPACE, MID_L_MARGIN|CONVERT_TWIPS, pL); - const uno::Any* pR = 0; + const uno::Any* pR(nullptr); GetProperty(RES_LR_SPACE, MID_R_MARGIN|CONVERT_TWIPS, pR); if(pL||pR) { - SvxLRSpaceItem aLR ( rFrmFmt.GetLRSpace() ); + SvxLRSpaceItem aLR(rFrmFmt.GetLRSpace()); if(pL) - ((SfxPoolItem&)aLR).PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS); + aLR.PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS); if(pR) - ((SfxPoolItem&)aLR).PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS); + aLR.PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS); aSet.Put(aLR); } - const uno::Any* pU = 0; + const uno::Any* pU(nullptr); GetProperty(RES_UL_SPACE, MID_UP_MARGIN|CONVERT_TWIPS, pU); - const uno::Any* pLo = 0; + const uno::Any* pLo(nullptr); GetProperty(RES_UL_SPACE, MID_LO_MARGIN|CONVERT_TWIPS, pLo); if(pU||pLo) { - SvxULSpaceItem aUL ( rFrmFmt.GetULSpace() ); + SvxULSpaceItem aUL(rFrmFmt.GetULSpace()); if(pU) - ((SfxPoolItem&)aUL).PutValue(*pU, MID_UP_MARGIN|CONVERT_TWIPS); + aUL.PutValue(*pU, MID_UP_MARGIN|CONVERT_TWIPS); if(pLo) - ((SfxPoolItem&)aUL).PutValue(*pLo, MID_LO_MARGIN|CONVERT_TWIPS); + aUL.PutValue(*pLo, MID_LO_MARGIN|CONVERT_TWIPS); aSet.Put(aUL); } - const::uno::Any* pSplit; - if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit )) + const::uno::Any* pSplit(nullptr); + if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit)) { - bool bTmp = *static_cast<sal_Bool const *>(pSplit->getValue()); - SwFmtLayoutSplit aSp(bTmp); + SwFmtLayoutSplit aSp(pSplit->get<bool>()); aSet.Put(aSp); } - if(aSet.Count()) { - rDoc.SetAttr( aSet, *rTbl.GetFrmFmt() ); + rDoc.SetAttr(aSet, *rTbl.GetFrmFmt()); } } commit 0b0acbdd52e8d0cc4d97642c1dd90e852ee4ee4a Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:18:49 2015 +0100 formatting Change-Id: Icb8e4575d0768f43faa5db0ea66e9bfa17713e78 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index b3fa1a5..985fd1d 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1834,29 +1834,23 @@ public: SwTableProperties_Impl(); ~SwTableProperties_Impl(); - void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal); - bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny); + void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal); + bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny); - void ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc); + void ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc); }; SwTableProperties_Impl::SwTableProperties_Impl() -{ -} + { } SwTableProperties_Impl::~SwTableProperties_Impl() -{ -} + { } void SwTableProperties_Impl::SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rVal) -{ - aAnyMap.SetValue( nWhichId, nMemberId, rVal ); -} + { aAnyMap.SetValue( nWhichId, nMemberId, rVal ); } bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny ) -{ - return aAnyMap.FillValue( nWhichId, nMemberId, rpAny ); -} + { return aAnyMap.FillValue( nWhichId, nMemberId, rpAny ); } void SwTableProperties_Impl::ApplyTblAttr(const SwTable& rTbl, SwDoc& rDoc) { commit 9b6086bb33a39cd6b29a7035a139ca4208b0ec46 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:15:52 2015 +0100 be honest and throw exceptions when unimplemented Change-Id: I57cf702bda6be4e04f2bff8202e3b3e20286f872 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 673b882..b3fa1a5 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1801,29 +1801,19 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) } void SwXTextTableCursor::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 SwXTextTableCursor::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 SwXTextTableCursor::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 SwXTextTableCursor::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)); }; void SwXTextTableCursor::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} + { ClientModify(this, pOld, pNew); } class SwXTextTable::Impl { commit 3f97e6e03ac5180bfdbdaa768480bc6bc3ee5664 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:13:21 2015 +0100 flatten and simplify Change-Id: I7c1f2f92494d7d7339a75e38a003545ddc556549 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 9f532f3..673b882 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1658,25 +1658,23 @@ sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal) { SolarMutexGuard aGuard; if (Count <= 0) - throw uno::RuntimeException("Illegal first argument: needs to be > 0", static_cast < cppu::OWeakObject * > ( this ) ); - bool bRet = false; + throw uno::RuntimeException("Illegal first argument: needs to be > 0", static_cast<cppu::OWeakObject*>(this)); SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if(!pUnoCrsr) + return false; { - { - // here, all actions need to be revoked - UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); - } - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - rTblCrsr.MakeBoxSels(); - { - UnoActionContext aContext(pUnoCrsr->GetDoc()); - bRet = rTblCrsr.GetDoc()->SplitTbl( - rTblCrsr.GetSelectedBoxes(), !Horizontal, Count); - } - rTblCrsr.MakeBoxSels(); + // here, all actions need to be revoked + UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); } - return bRet; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + rTblCrsr.MakeBoxSels(); + bool bResult; + { + UnoActionContext aContext(pUnoCrsr->GetDoc()); + bResult = rTblCrsr.GetDoc()->SplitTbl(rTblCrsr.GetSelectedBoxes(), !Horizontal, Count); + } + rTblCrsr.MakeBoxSels(); + return bResult; } uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception ) commit 9196885f79d261d375036159a86aa47502093587 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:07:28 2015 +0100 flatten and simplify Change-Id: I4da01d589ba170e230aaa4db5d1336c5f93ad168 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index a05f063..9f532f3 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1629,32 +1629,28 @@ sal_Bool SwXTextTableCursor::mergeRange() throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - bool bRet = false; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if(!pUnoCrsr) + return false; { - { - // The Actions need to be revoked here - UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); - } - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - rTblCrsr.MakeBoxSels(); - - { - UnoActionContext aContext(pUnoCrsr->GetDoc()); - bRet = TBLMERGE_OK == rTblCrsr.GetDoc()->MergeTbl(rTblCrsr); - if(bRet) - { - size_t nCount = rTblCrsr.GetSelectedBoxesCount(); - while (nCount--) - { - rTblCrsr.DeleteBox(nCount); - } - } - } - rTblCrsr.MakeBoxSels(); + // The Actions need to be revoked here + UnoActionRemoveContext aRemoveContext(pUnoCrsr->GetDoc()); } - return bRet; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + rTblCrsr.MakeBoxSels(); + bool bResult; + { + UnoActionContext aContext(pUnoCrsr->GetDoc()); + bResult = TBLMERGE_OK == rTblCrsr.GetDoc()->MergeTbl(rTblCrsr); + } + if(bResult) + { + size_t nCount = rTblCrsr.GetSelectedBoxesCount(); + while (nCount--) + rTblCrsr.DeleteBox(nCount); + } + rTblCrsr.MakeBoxSels(); + return bResult; } sal_Bool SwXTextTableCursor::splitRange(sal_Int16 Count, sal_Bool Horizontal) commit 94db1357b1e50ece5b9ac1c5a123ce656aba1790 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:00:56 2015 +0100 flatten and simplify Change-Id: I7fb6774f0ebfbb65410ab441eb1195e5c7310756 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index f136f10..a05f063 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1614,16 +1614,15 @@ void SwXTextTableCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeExceptio rTblCrsr.MoveTable(fnTableCurr, fnTableStart); } -void SwXTextTableCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException, std::exception ) +void SwXTextTableCursor::gotoEnd(sal_Bool bExpand) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - rTblCrsr.MoveTable(fnTableCurr, fnTableEnd); - } + if(!pUnoCrsr) + return; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + rTblCrsr.MoveTable(fnTableCurr, fnTableEnd); } sal_Bool SwXTextTableCursor::mergeRange() commit 9ba21f6bf1fc369f41eb9454ec9df499159d783e Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 17:00:19 2015 +0100 flatten and simplify Change-Id: I0ef8e47de4b0f135b5e789f93efce2de1daac99a diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 771a524f..f136f10 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1603,16 +1603,15 @@ sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool bExpand) throw( un return rTblCrsr.UpDown(false, Count, 0, 0); } -void SwXTextTableCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException, std::exception ) +void SwXTextTableCursor::gotoStart(sal_Bool bExpand) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - rTblCrsr.MoveTable(fnTableCurr, fnTableStart); - } + if(!pUnoCrsr) + return; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + rTblCrsr.MoveTable(fnTableCurr, fnTableStart); } void SwXTextTableCursor::gotoEnd(sal_Bool Expand) throw( uno::RuntimeException, std::exception ) commit 63d47cd94df138d0f76961c8e370269e75d95745 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:59:39 2015 +0100 flatten and simplify Change-Id: I0a45f87ca77f3eb4dabbe3c8dc047ab5ce93f1aa diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index dc780df..771a524f 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1592,18 +1592,15 @@ sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool bExpand) throw( uno: return rTblCrsr.UpDown(true, Count, 0, 0); } -sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) +sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool bExpand) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - bool bRet = false; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - bRet = rTblCrsr.UpDown(false, Count, 0, 0); - } - return bRet; + if(!pUnoCrsr) + return false; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + return rTblCrsr.UpDown(false, Count, 0, 0); } void SwXTextTableCursor::gotoStart(sal_Bool Expand) throw( uno::RuntimeException, std::exception ) commit 336f29cab4c145a204b1dc44a083a32c49a93539 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:58:56 2015 +0100 flatten and simplify Change-Id: I1b2bdbc3aa6e6a803dd57a5e49412391c4bb46dc diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 2e94934..dc780df 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1581,18 +1581,15 @@ sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool bExpand) throw( u return rTblCrsr.Right(Count, CRSR_SKIP_CHARS, false, false); } -sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) +sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool bExpand) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - bool bRet = false; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - bRet = rTblCrsr.UpDown(true, Count, 0, 0); - } - return bRet; + if(!pUnoCrsr) + return false; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + return rTblCrsr.UpDown(true, Count, 0, 0); } sal_Bool SwXTextTableCursor::goDown(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) commit 647e461d0754f297e48d285b06351e0dabff96ed Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:57:59 2015 +0100 flatten and simplify Change-Id: I4de021c7fd4d1a22fd9cbbe3e391686d9684f1c6 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 10b2db7..2e94934 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1570,18 +1570,15 @@ sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool bExpand) throw( un return rTblCrsr.Left(Count, CRSR_SKIP_CHARS, false, false); } -sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) +sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool bExpand) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - bool bRet = false; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - bRet = rTblCrsr.Right(Count, CRSR_SKIP_CHARS, false, false); - } - return bRet; + if(!pUnoCrsr) + return false; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + return rTblCrsr.Right(Count, CRSR_SKIP_CHARS, false, false); } sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) commit bc0557001212e4a94e8123c46f643defcb85afa0 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:57:12 2015 +0100 flatten and simplify Change-Id: I198793d0ab9a91a7f6a3aebc5fafbb6d7de7b98f diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d983f72..10b2db7 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1559,18 +1559,15 @@ sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool return rTblCrsr.GotoTblBox(sCellName); } -sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) +sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool bExpand) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - bool bRet = false; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - bRet = rTblCrsr.Left(Count, CRSR_SKIP_CHARS, false, false); - } - return bRet; + if(!pUnoCrsr) + return false; + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + return rTblCrsr.Left(Count, CRSR_SKIP_CHARS, false, false); } sal_Bool SwXTextTableCursor::goRight(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) commit 48c99df39e6e66e3957b74ceedd0ed2cc6170143 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:53:37 2015 +0100 flatten and simplify Change-Id: I74746e6fc9f235d48dfe24f4713404f7e9d578d7 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 3db2f754..d983f72 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1547,19 +1547,16 @@ OUString SwXTextTableCursor::getRangeName() return pEndBox->GetName(); } -sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool Expand) - throw( uno::RuntimeException, std::exception ) +sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool bExpand) + throw(uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - bool bRet = false; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) - { - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - lcl_CrsrSelect(rTblCrsr, Expand); - bRet = rTblCrsr.GotoTblBox(sCellName); - } - return bRet; + if(!pUnoCrsr) + return false; + auto& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + lcl_CrsrSelect(rTblCrsr, bExpand); + return rTblCrsr.GotoTblBox(sCellName); } sal_Bool SwXTextTableCursor::goLeft(sal_Int16 Count, sal_Bool Expand) throw( uno::RuntimeException, std::exception ) commit 4e753823b1175927fbe84056f5831287c47f0211 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:51:35 2015 +0100 flatten and simplify Change-Id: Iefcbf2ab06dcf18cdd0f0d82e4389ec1766927f9 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index e002942..3db2f754 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1523,37 +1523,28 @@ OUString SwXTextTableCursor::getRangeName() throw (uno::RuntimeException, std::exception) { SolarMutexGuard aGuard; - OUString aRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); SwUnoTableCrsr* pTblCrsr = dynamic_cast<SwUnoTableCrsr*>(pUnoCrsr); //!! see also SwChartDataSequence::getSourceRangeRepresentation - if (pTblCrsr) - { - pTblCrsr->MakeBoxSels(); - const SwStartNode* pNode = pTblCrsr->GetPoint()->nNode.GetNode().FindTableBoxStartNode(); - const SwTable* pTable = SwTable::FindTable( GetFrmFmt() ); - const SwTableBox* pEndBox = pTable->GetTblBox( pNode->GetIndex()); - aRet = pEndBox->GetName(); - - if(pTblCrsr->HasMark()) + if(!pTblCrsr) + return OUString(); + pTblCrsr->MakeBoxSels(); + const SwStartNode* pNode = pTblCrsr->GetPoint()->nNode.GetNode().FindTableBoxStartNode(); + const SwTable* pTable = SwTable::FindTable(GetFrmFmt()); + const SwTableBox* pEndBox = pTable->GetTblBox(pNode->GetIndex()); + if(pTblCrsr->HasMark()) + { + pNode = pTblCrsr->GetMark()->nNode.GetNode().FindTableBoxStartNode(); + const SwTableBox* pStartBox = pTable->GetTblBox(pNode->GetIndex()); + if(pEndBox != pStartBox) { - pNode = pTblCrsr->GetMark()->nNode.GetNode().FindTableBoxStartNode(); - const SwTableBox* pStartBox = pTable->GetTblBox( pNode->GetIndex()); - if(pEndBox != pStartBox) - { - // need to switch start and end? - if (*pTblCrsr->GetPoint() < *pTblCrsr->GetMark()) - { - const SwTableBox* pTmpBox = pStartBox; - pStartBox = pEndBox; - pEndBox = pTmpBox; - } - - aRet = pStartBox->GetName() + ":" + pEndBox->GetName(); - } + // need to switch start and end? + if(*pTblCrsr->GetPoint() < *pTblCrsr->GetMark()) + std::swap(pStartBox, pEndBox); + return pStartBox->GetName() + ":" + pEndBox->GetName(); } } - return aRet; + return pEndBox->GetName(); } sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool Expand) commit 2049746aa5ab3a9e48f0cf45c6257cee6ef0186c Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:44:40 2015 +0100 use ranged for Change-Id: I7bf23c4fd2235125c3f9cbfd32027b98ff91ac3e diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 8d72ef5..e002942 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1505,11 +1505,8 @@ SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt& rTableFmt, const SwTableCursor* } const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes(); SwTableCursor& rTableCrsr = dynamic_cast<SwTableCursor&>(*pUnoCrsr); - for (size_t i = 0; i < rBoxes.size(); i++) - { - rTableCrsr.InsertBox( *rBoxes[i] ); - } - + for(auto pBox : rBoxes) + rTableCrsr.InsertBox(*pBox); pUnoCrsr->Add(&aCrsrDepend); SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); rTblCrsr.MakeBoxSels(); commit d28108fe2b85d1964d28846116dbdf6cfba24e94 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:40:47 2015 +0100 simplify UNO boilerplate Change-Id: Icb093f6db5df4dd4094c49202fce54de524aef94 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 0c6132a..8d72ef5 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1474,13 +1474,8 @@ SwDoc* SwXTextTableCursor::GetDoc() { return GetFrmFmt()->Ge const SwUnoCrsr* SwXTextTableCursor::GetCrsr() const { return static_cast<const SwUnoCrsr*>(aCrsrDepend.GetRegisteredIn()); } SwUnoCrsr* SwXTextTableCursor::GetCrsr() { return static_cast<SwUnoCrsr*>(aCrsrDepend.GetRegisteredIn()); } -uno::Sequence< OUString > SwXTextTableCursor::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) -{ - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.TextTableCursor"; - return aRet; -} +uno::Sequence<OUString> SwXTextTableCursor::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) + { return {"com.sun.star.text.TextTableCursor"}; } SwXTextTableCursor::SwXTextTableCursor(SwFrmFmt* pFmt, SwTableBox* pBox) : SwClient(pFmt), commit 99b1d7737a866a554c9746787e9e405d1719d802 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:37:24 2015 +0100 use ranged for Change-Id: I0ede4ea54746fbc1d90957d540d7ed1ef35623b3 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 47d22ac..0c6132a 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1452,28 +1452,19 @@ void SwXTextTableRow::SwClientNotify(const SwModify& rModify, const SfxHint& rHi SwTableLine* SwXTextTableRow::FindLine(SwTable* pTable, SwTableLine* pLine) { - SwTableLine* pRet = 0; - SwTableLines &rLines = pTable->GetTabLines(); - for(size_t i = 0; i < rLines.size(); ++i) - if(rLines[i] == pLine) - { - pRet = pLine; - break; - } - return pRet; + for(auto& pCurrentLine : pTable->GetTabLines()) + if(pCurrentLine == pLine) + return pCurrentLine; + return nullptr; } // SwXTextTableCursor OUString SwXTextTableCursor::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXTextTableCursor"); -} + { return OUString("SwXTextTableCursor"); } sal_Bool SwXTextTableCursor::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} + { return cppu::supportsService(this, rServiceName); } IMPLEMENT_FORWARD_XINTERFACE2(SwXTextTableCursor,SwXTextTableCursor_Base,OTextCursorHelper) const SwPaM* SwXTextTableCursor::GetPaM() const { return GetCrsr(); } commit 212a0bca30ebcfa312901be1370374419eb03a13 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:33:56 2015 +0100 be honest and throw exceptions when unimplemented Change-Id: I38bc4c15eabcbcfaf7183cb78e5f924986c0365f diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 5173b76..47d22ac 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1424,29 +1424,19 @@ uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName) throw( } void SwXTextTableRow::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 SwXTextTableRow::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 SwXTextTableRow::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 SwXTextTableRow::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)); }; void SwXTextTableRow::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) -{ - ClientModify(this, pOld, pNew); -} + { ClientModify(this, pOld, pNew); } void SwXTextTableRow::SwClientNotify(const SwModify& rModify, const SfxHint& rHint) { commit e2b58f2f586dd33229a53795159a11d8691f633f Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:32:25 2015 +0100 flatten and simplify Change-Id: I1dd846e27d15bb959ec65c90abfb33ab43788739 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 2342be7..5173b76 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1812,59 +1812,51 @@ uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName) std::exception) { SolarMutexGuard aGuard; - uno::Any aRet; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if(!pUnoCrsr) + return uno::Any(); { - SwStartNode* pSttNode = pUnoCrsr->GetNode().StartOfSectionNode(); + auto pSttNode = pUnoCrsr->GetNode().StartOfSectionNode(); const SwTableNode* pTblNode = pSttNode->FindTableNode(); - lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt()); - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap().getByName(rPropertyName); - if(pEntry) + lcl_FormatTable(pTblNode->GetTable().GetFrmFmt()); + } + SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName)); + if(!pEntry) + throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this)); + rTblCrsr.MakeBoxSels(); + uno::Any aResult; + switch(pEntry->nWID) + { + case FN_UNO_TABLE_CELL_BACKGROUND: { - rTblCrsr.MakeBoxSels(); - switch(pEntry->nWID ) - { - case FN_UNO_TABLE_CELL_BACKGROUND: - { - SvxBrushItem aBrush( RES_BACKGROUND ); - if (rTblCrsr.GetDoc()->GetBoxAttr( *pUnoCrsr, aBrush )) - aBrush.QueryValue(aRet, pEntry->nMemberId); - - } - break; - case RES_BOXATR_FORMAT: - // TODO: GetAttr for table selections in a Doc is missing - OSL_FAIL("not implemented"); - break; - case FN_UNO_PARA_STYLE: - { - SwFmtColl *const pFmt = - SwUnoCursorHelper::GetCurTxtFmtColl(*pUnoCrsr, false); - OUString sRet; - if(pFmt) - sRet = pFmt->GetName(); - aRet <<= sRet; - } - break; - default: - { - SfxItemSet aSet(rTblCrsr.GetDoc()->GetAttrPool(), - RES_CHRATR_BEGIN, RES_FRMATR_END -1, - RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, - 0L); - SwUnoCursorHelper::GetCrsrAttr(rTblCrsr.GetSelRing(), - aSet); - m_pPropSet->getPropertyValue(*pEntry, aSet, aRet); - } - } + SvxBrushItem aBrush(RES_BACKGROUND); + if (rTblCrsr.GetDoc()->GetBoxAttr(*pUnoCrsr, aBrush)) + aBrush.QueryValue(aResult, pEntry->nMemberId); + } + break; + case RES_BOXATR_FORMAT: + // TODO: GetAttr for table selections in a Doc is missing + throw uno::RuntimeException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this)); + break; + case FN_UNO_PARA_STYLE: + { + auto pFmt(SwUnoCursorHelper::GetCurTxtFmtColl(*pUnoCrsr, false)); + if(pFmt) + aResult = uno::makeAny(pFmt->GetName()); + } + break; + default: + { + SfxItemSet aSet(rTblCrsr.GetDoc()->GetAttrPool(), + RES_CHRATR_BEGIN, RES_FRMATR_END-1, + RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, + 0L); + SwUnoCursorHelper::GetCrsrAttr(rTblCrsr.GetSelRing(), aSet); + m_pPropSet->getPropertyValue(*pEntry, aSet, aResult); } - else - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); } - return aRet; + return aResult; } void SwXTextTableCursor::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) commit a1eeefa5c173332122a67fdcc0be070fb8f888c1 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:19:43 2015 +0100 fail early, limit scope Change-Id: I0acd496c6276c59c0c53b1ee9503897800771a44 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index b59aa17..2342be7 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1754,14 +1754,16 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const u SwUnoCrsr* pUnoCrsr = GetCrsr(); if(!pUnoCrsr) return; - auto pSttNode = pUnoCrsr->GetNode().StartOfSectionNode(); - const SwTableNode* pTblNode = pSttNode->FindTableNode(); - lcl_FormatTable(pTblNode->GetTable().GetFrmFmt()); auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName)); 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)); + { + auto pSttNode = pUnoCrsr->GetNode().StartOfSectionNode(); + const SwTableNode* pTblNode = pSttNode->FindTableNode(); + lcl_FormatTable(pTblNode->GetTable().GetFrmFmt()); + } auto& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); rTblCrsr.MakeBoxSels(); SwDoc* pDoc = pUnoCrsr->GetDoc(); commit c4fcf9100cc1a4ad2dfe7f83bb80b56ba070c0b4 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:17:35 2015 +0100 flatten and simplify Change-Id: I72d71c035b43fb3786390eb4a146ef379f547e69 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 9af7136..b59aa17 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1752,59 +1752,54 @@ void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const u { SolarMutexGuard aGuard; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr) + if(!pUnoCrsr) + return; + auto pSttNode = pUnoCrsr->GetNode().StartOfSectionNode(); + const SwTableNode* pTblNode = pSttNode->FindTableNode(); + lcl_FormatTable(pTblNode->GetTable().GetFrmFmt()); + auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName)); + 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)); + auto& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); + rTblCrsr.MakeBoxSels(); + SwDoc* pDoc = pUnoCrsr->GetDoc(); + switch(pEntry->nWID) { - SwStartNode* pSttNode = pUnoCrsr->GetNode().StartOfSectionNode(); - const SwTableNode* pTblNode = pSttNode->FindTableNode(); - lcl_FormatTable((SwFrmFmt*)pTblNode->GetTable().GetFrmFmt()); - SwUnoTableCrsr& rTblCrsr = dynamic_cast<SwUnoTableCrsr&>(*pUnoCrsr); - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap().getByName(rPropertyName); - if(pEntry) + case FN_UNO_TABLE_CELL_BACKGROUND: { - if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) - throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); - rTblCrsr.MakeBoxSels(); - SwDoc* pDoc = pUnoCrsr->GetDoc(); - switch(pEntry->nWID ) - { - case FN_UNO_TABLE_CELL_BACKGROUND: - { - SvxBrushItem aBrush( RES_BACKGROUND ); - pDoc->GetBoxAttr( *pUnoCrsr, aBrush ); - aBrush.PutValue(aValue, pEntry->nMemberId); - pDoc->SetBoxAttr( *pUnoCrsr, aBrush ); + SvxBrushItem aBrush(RES_BACKGROUND); + pDoc->GetBoxAttr(*pUnoCrsr, aBrush); + aBrush.PutValue(aValue, pEntry->nMemberId); + pDoc->SetBoxAttr(*pUnoCrsr, aBrush); - } - break; - case RES_BOXATR_FORMAT: - { - SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT); - aNumberFormat.PutValue(aValue, 0); - pDoc->SetBoxAttr( *pUnoCrsr, aNumberFormat); - } - break; - case FN_UNO_PARA_STYLE: - SwUnoCursorHelper::SetTxtFmtColl(aValue, *pUnoCrsr); - break; - default: - { - SfxItemSet aItemSet( pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID ); - SwUnoCursorHelper::GetCrsrAttr(rTblCrsr.GetSelRing(), - aItemSet); + } + break; + case RES_BOXATR_FORMAT: + { + SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT); + aNumberFormat.PutValue(aValue, 0); + pDoc->SetBoxAttr(*pUnoCrsr, aNumberFormat); + } + break; + case FN_UNO_PARA_STYLE: + SwUnoCursorHelper::SetTxtFmtColl(aValue, *pUnoCrsr); + break; + default: + { + SfxItemSet aItemSet(pDoc->GetAttrPool(), pEntry->nWID, pEntry->nWID); + SwUnoCursorHelper::GetCrsrAttr(rTblCrsr.GetSelRing(), + aItemSet); - if (!SwUnoCursorHelper::SetCursorPropertyValue( - *pEntry, aValue, rTblCrsr.GetSelRing(), aItemSet)) - { - m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); - } - SwUnoCursorHelper::SetCrsrAttr(rTblCrsr.GetSelRing(), - aItemSet, SetAttrMode::DEFAULT, true); - } + if (!SwUnoCursorHelper::SetCursorPropertyValue( + *pEntry, aValue, rTblCrsr.GetSelRing(), aItemSet)) + { + m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet); } + SwUnoCursorHelper::SetCrsrAttr(rTblCrsr.GetSelRing(), + aItemSet, SetAttrMode::DEFAULT, true); } - else - throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); } } commit dcb26ea845f86fdeace62ab3d8450b21c4fb103c Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 16:00:46 2015 +0100 formatting Change-Id: I80702d9f681e1ac62bb0d2c35d3fd99111349210 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 36d2358..9af7136 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1274,16 +1274,14 @@ SwXTextTableRow::SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLn) : SwClient(pFmt), m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_ROW)), pLine(pLn) -{ -} +{ } SwXTextTableRow::~SwXTextTableRow() -{ -} +{ } -uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception ) +uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo(void) throw( uno::RuntimeException, std::exception ) { - static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo(); + static uno::Reference<beans::XPropertySetInfo> xRef = m_pPropSet->getPropertySetInfo(); return xRef; } commit 943f537a1722e6b0835ef999f5371ba0c30fb813 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 15:59:20 2015 +0100 simplify SwXCell UNO boilerplate Change-Id: Ib0057ac18ff6d5db7cf3d19eace5b602778450d8 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 9aa1cdbb..36d2358 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1247,44 +1247,27 @@ SwTableBox* SwXCell::FindBox(SwTable* pTable, SwTableBox* pBox2) // box not found: reset nFndPos pointer nFndPos = NOTFOUND; - return 0; + return nullptr; } OUString SwXCell::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXCell"); -} + { return OUString("SwXCell"); } sal_Bool SwXCell::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} + { return cppu::supportsService(this, rServiceName); } uno::Sequence< OUString > SwXCell::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) -{ - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.CellProperties"; - return aRet; -} + { return {"com.sun.star.text.CellProperties"}; } OUString SwXTextTableRow::getImplementationName(void) throw( uno::RuntimeException, std::exception ) -{ - return OUString("SwXTextTableRow"); -} + { return OUString("SwXTextTableRow"); } sal_Bool SwXTextTableRow::supportsService(const OUString& rServiceName) throw( uno::RuntimeException, std::exception ) -{ - return cppu::supportsService(this, rServiceName); -} + { return cppu::supportsService(this, rServiceName); } uno::Sequence< OUString > SwXTextTableRow::getSupportedServiceNames(void) throw( uno::RuntimeException, std::exception ) -{ - uno::Sequence< OUString > aRet(1); - OUString* pArray = aRet.getArray(); - pArray[0] = "com.sun.star.text.TextTableRow"; - return aRet; -} + { return {"com.sun.star.text.TextTableRow"}; } + TYPEINIT1(SwXTextTableRow, SwClient); SwXTextTableRow::SwXTextTableRow(SwFrmFmt* pFmt, SwTableLine* pLn) : commit e66a55267464d7c5cd996af9b48ebed923eb16d2 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 15:54:49 2015 +0100 flatten and simplify Change-Id: I3ee1c48cf324c33515500d5e0bf73934ae994b94 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 78215da..9aa1cdbb 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1167,28 +1167,19 @@ void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); }; -uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) throw( uno::RuntimeException, std::exception ) +uno::Reference<container::XEnumeration> SwXCell::createEnumeration(void) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - uno::Reference< container::XEnumeration > aRef; - if(IsValid()) - { - const SwStartNode* pSttNd = pBox->GetSttNd(); - SwPosition aPos(*pSttNd); - ::std::unique_ptr<SwUnoCrsr> pUnoCursor( - GetDoc()->CreateUnoCrsr(aPos, false)); - pUnoCursor->Move(fnMoveForward, fnGoNode); - - // remember table and start node for later travelling - // (used in export of tables in tables) - SwTable const*const pTable( & pSttNd->FindTableNode()->GetTable() ); - SwXParagraphEnumeration *const pEnum = - new SwXParagraphEnumeration(this, std::move(pUnoCursor), CURSOR_TBLTEXT, - pSttNd, pTable); - - aRef = pEnum; - } - return aRef; + if(!IsValid()) + return uno::Reference<container::XEnumeration>(); + const SwStartNode* pSttNd = pBox->GetSttNd(); + SwPosition aPos(*pSttNd); + ::std::unique_ptr<SwUnoCrsr> pUnoCursor(GetDoc()->CreateUnoCrsr(aPos, false)); + pUnoCursor->Move(fnMoveForward, fnGoNode); + // remember table and start node for later travelling + // (used in export of tables in tables) + SwTable const*const pTable(&pSttNd->FindTableNode()->GetTable()); + return new SwXParagraphEnumeration(this, std::move(pUnoCursor), CURSOR_TBLTEXT, pSttNd, pTable); } uno::Type SAL_CALL SwXCell::getElementType(void) throw( uno::RuntimeException, std::exception ) commit 91a42a99b70bfb6c14a7f344aa7d38f1307e8286 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 15:54:29 2015 +0100 throw RuntimeExceptions to let API user know its a noop Change-Id: I37b12eba2f9cb918d196f8854ae61f5e81cd76e7 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 6767142..78215da 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1156,16 +1156,16 @@ uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName) } void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) - { throw RuntimeException("not implemented"); } + { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); }; void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) - { throw RuntimeException("not implemented"); } + { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); }; void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) - { throw RuntimeException("not implemented"); } + { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); }; void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) - { throw RuntimeException("not implemented"); } + { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); }; uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) throw( uno::RuntimeException, std::exception ) { commit 13de0eb8375bdbca93790c70efd791516d030a6c Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 15:35:04 2015 +0100 except on call to unimplemented functions for API users Change-Id: Icb22a9b8d8b2c55ddd00206d30a9fd4622cee95b diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d001c9c..6767142 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1156,24 +1156,16 @@ uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName) } void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw RuntimeException("not implemented"); } void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw RuntimeException("not implemented"); } void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw RuntimeException("not implemented"); } void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) -{ - OSL_FAIL("not implemented"); -} + { throw RuntimeException("not implemented"); } uno::Reference< container::XEnumeration > SwXCell::createEnumeration(void) throw( uno::RuntimeException, std::exception ) { commit b438648006c92a4633335cfe077104103a7c767f Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 15:34:15 2015 +0100 flatten and simplify Change-Id: I7339a7a54dcb6eb3a887416d05f8f78f38aa3c96 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index d74eca0..d001c9c 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1049,7 +1049,7 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV if(rPropertyName == "FRMDirection") { SvxFrameDirection eDir = FRMDIR_ENVIRONMENT; - sal_Int16 nNum = aValue.get<sal_Int16>(nNum); + sal_Int32 nNum = aValue.get<sal_Int32>(); SAL_INFO("sw.uno", "FRMDirection val " << nNum); switch (nNum) { @@ -1074,16 +1074,15 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV uno::Sequence<beans::PropertyValue> tableCellProperties; tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >(); comphelper::SequenceAsHashMap aPropMap(tableCellProperties); - uno::Any sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", makeAny()); - if(!sRedlineTypeValue.has(OUString)) - throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) ); + uno::Any sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", uno::Any()); + if(!sRedlineTypeValue.has<OUString>()) + throw beans::UnknownPropertyException("No redline type property: ", static_cast<cppu::OWeakObject*>(this)); // Create a 'Table Cell Redline' object - SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineTypeValue.get<OUString(), tableCellProperties); + SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineTypeValue.get<OUString>(), tableCellProperties); } else { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap().getByName(rPropertyName); + auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName)); if(!pEntry) { beans::UnknownPropertyException aEx; @@ -1110,56 +1109,50 @@ uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - uno::Any aRet; - if(IsValid()) + if(!IsValid()) + return uno::Any(); + auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName)); + if(!pEntry) { - const SfxItemPropertySimpleEntry* pEntry = - m_pPropSet->getPropertyMap().getByName(rPropertyName); - if( !pEntry ) + beans::UnknownPropertyException aEx; + aEx.Message = rPropertyName; + throw(aEx); + } + switch(pEntry->nWID) + { + case FN_UNO_CELL_ROW_SPAN: + return uno::makeAny(pBox->getRowSpan()); + break; + case FN_UNO_TEXT_SECTION: { - beans::UnknownPropertyException aEx; - aEx.Message = rPropertyName; - throw( aEx ); + SwFrmFmt* pTblFmt = GetFrmFmt(); + SwTable* pTable = SwTable::FindTable(pTblFmt); + SwTableNode* pTblNode = pTable->GetTableNode(); + SwSectionNode* pSectionNode = pTblNode->FindSectionNode(); + if(!pSectionNode) + return uno::Any(); + SwSection& rSect = pSectionNode->GetSection(); + return uno::makeAny(SwXTextSections::GetObject(*rSect.GetFmt())); } - switch( pEntry->nWID ) + break; + case FN_UNO_CELL_NAME: + return uno::makeAny(pBox->GetName()); + break; + case FN_UNO_REDLINE_NODE_START: + case FN_UNO_REDLINE_NODE_END: { - case FN_UNO_CELL_ROW_SPAN: - aRet <<= pBox->getRowSpan(); - break; - case FN_UNO_TEXT_SECTION: - { - SwFrmFmt* pTblFmt = GetFrmFmt(); - SwTable* pTable = SwTable::FindTable( pTblFmt ); - SwTableNode* pTblNode = pTable->GetTableNode(); - SwSectionNode* pSectionNode = pTblNode->FindSectionNode(); - if(pSectionNode) - { - SwSection& rSect = pSectionNode->GetSection(); - uno::Reference< text::XTextSection > xSect = - SwXTextSections::GetObject( *rSect.GetFmt() ); - aRet <<= xSect; - } - } - break; - case FN_UNO_CELL_NAME: - aRet <<= pBox->GetName(); - break; - case FN_UNO_REDLINE_NODE_START: - case FN_UNO_REDLINE_NODE_END: - { - //redline can only be returned if it's a living object - aRet = SwXText::getPropertyValue(rPropertyName); - } - break; - default: - { - const SwFrmFmt* pBoxFmt = pBox->GetFrmFmt(); - const SwAttrSet& rSet = pBoxFmt->GetAttrSet(); - m_pPropSet->getPropertyValue(rPropertyName, rSet, aRet); - } + //redline can only be returned if it's a living object + return makeAny(SwXText::getPropertyValue(rPropertyName)); + } + break; + default: + { + const SwAttrSet& rSet = pBox->GetFrmFmt()->GetAttrSet(); + uno::Any aResult; + m_pPropSet->getPropertyValue(rPropertyName, rSet, aResult); + return aResult; } } - return aRet; } void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/) throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) commit df384772bbcc28827619409d37912c458770c593 Author: Bjoern Michaelsen <bjoern.michael...@canonical.com> Date: Sat Mar 28 15:01:14 2015 +0100 simplify Change-Id: I211766d84f5b4ff0b295a896df01b5b13f665940 diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index 90fca88..d74eca0 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -1049,8 +1049,7 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV if(rPropertyName == "FRMDirection") { SvxFrameDirection eDir = FRMDIR_ENVIRONMENT; - sal_Int16 nNum = 0; - aValue >>= nNum; + sal_Int16 nNum = aValue.get<sal_Int16>(nNum); SAL_INFO("sw.uno", "FRMDirection val " << nNum); switch (nNum) { @@ -1075,18 +1074,11 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV 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 - { + uno::Any sRedlineTypeValue = aPropMap.getUnpackedValueOrDefault("RedlineType", makeAny()); + if(!sRedlineTypeValue.has(OUString)) throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) ); - } + // Create a 'Table Cell Redline' object + SwUnoCursorHelper::makeTableCellRedline(*pBox, sRedlineTypeValue.get<OUString(), tableCellProperties); } else { commit a36802f6b9e16e0f1d3c33ed03d19a6c7b61c705 ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits