summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-28 18:20:32 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-03-28 22:14:40 +0100
commit8e3c3adbf0132fd0ce4f4bd113274392297c0b23 (patch)
treebb493bdd245d0b5139cf914a3ee3e5ef26690a89
parent0056e34ae80ef57daf0567020a147cc914b7ab4e (diff)
simplify, kill manual memory management
Change-Id: I1501cc9912ab555125933a3c5c9ffe9d1d7a9557
-rw-r--r--sw/source/core/unocore/unotbl.cxx38
1 files changed, 14 insertions, 24 deletions
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index d1ac85c7d248..0a1a57bae741 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)