Kaydet (Commit) 8e3c3adb authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

simplify, kill manual memory management

Change-Id: I1501cc9912ab555125933a3c5c9ffe9d1d7a9557
üst 0056e34a
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
#include <comphelper/servicehelper.hxx> #include <comphelper/servicehelper.hxx>
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <comphelper/sequence.hxx>
#include <comphelper/sequenceashashmap.hxx> #include <comphelper/sequenceashashmap.hxx>
#include <swtable.hxx> #include <swtable.hxx>
...@@ -593,19 +594,17 @@ static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRo ...@@ -593,19 +594,17 @@ static SwXCell* lcl_CreateXCell(SwFrmFmt* pFmt, sal_Int32 nColumn, sal_Int32 nRo
return pXCell; 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 pLine : rLines)
{ {
for(auto pBox : pLine->GetTabBoxes()) for(auto pBox : pLine->GetTabBoxes())
{ {
if(!pBox->GetName().isEmpty() && pBox->getRowSpan() > 0 ) if(!pBox->GetName().isEmpty() && pBox->getRowSpan() > 0)
rAllNames.push_back( new OUString(pBox->GetName()) ); rAllNames.push_back(pBox->GetName());
SwTableLines& rBoxLines = pBox->GetTabLines(); SwTableLines& rBoxLines = pBox->GetTabLines();
if(!rBoxLines.empty()) if(!rBoxLines.empty())
{
lcl_InspectLines(rBoxLines, rAllNames); lcl_InspectLines(rBoxLines, rAllNames);
}
} }
} }
} }
...@@ -2128,27 +2127,18 @@ uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellNa ...@@ -2128,27 +2127,18 @@ uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellNa
return SwXCell::CreateXCell(pFmt, pBox); 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; SolarMutexGuard aGuard;
SwFrmFmt* pFmt = GetFrmFmt(); SwFrmFmt* pFmt(GetFrmFmt());
if(pFmt) if(!pFmt)
{ return {};
SwTable* pTable = SwTable::FindTable( pFmt ); SwTable* pTable = SwTable::FindTable(pFmt);
// exists at the table and at all boxes // exists at the table and at all boxes
SwTableLines& rTblLines = pTable->GetTabLines(); SwTableLines& rTblLines = pTable->GetTabLines();
std::vector<OUString*> aAllNames; std::vector<OUString> aAllNames;
lcl_InspectLines(rTblLines, aAllNames); lcl_InspectLines(rTblLines, aAllNames);
uno::Sequence< OUString > aRet( static_cast<sal_Int32>(aAllNames.size()) ); return comphelper::containerToSequence<OUString>(aAllNames);
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 >();
} }
uno::Reference< text::XTextTableCursor > SwXTextTable::createCursorByCellName(const OUString& sCellName) uno::Reference< text::XTextTableCursor > SwXTextTable::createCursorByCellName(const OUString& sCellName)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment