starmath/source/view.cxx | 13 +++++-------- writerfilter/source/dmapper/StyleSheetTable.cxx | 16 +++++----------- 2 files changed, 10 insertions(+), 19 deletions(-)
New commits: commit d7194ade91c1ca80065ec6e9ad6f801a097f8cd6 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jul 10 09:10:21 2015 +0200 Use std::unique_ptr in SmViewShell::Execute() Change-Id: I8593c87f7a580e09d689df4cfdfecc8947f86159 diff --git a/starmath/source/view.cxx b/starmath/source/view.cxx index c5ffc39..f9bb00c 100644 --- a/starmath/source/view.cxx +++ b/starmath/source/view.cxx @@ -1666,7 +1666,7 @@ void SmViewShell::Execute(SfxRequest& rReq) xStrm = aDataHelper.GetInputStream(nId, ""); if (xStrm.is()) { - SfxMedium* pClipboardMedium = new SfxMedium(); + std::unique_ptr<SfxMedium> pClipboardMedium(new SfxMedium()); pClipboardMedium->GetItemSet(); //generate initial itemset, not sure if necessary const SfxFilter* pMathFilter = SfxFilter::GetFilterByName(MATHML_XML); @@ -1674,7 +1674,6 @@ void SmViewShell::Execute(SfxRequest& rReq) pClipboardMedium->setStreamToLoadFrom(xStrm, true /*bIsReadOnly*/); InsertFrom(*pClipboardMedium); GetDoc()->UpdateText(); - delete pClipboardMedium; } } else @@ -1685,13 +1684,13 @@ void SmViewShell::Execute(SfxRequest& rReq) ::rtl::OUString aString; if (aDataHelper.GetString( nId, aString)) { - SfxMedium* pClipboardMedium = new SfxMedium(); + std::unique_ptr<SfxMedium> pClipboardMedium(new SfxMedium()); pClipboardMedium->GetItemSet(); //generates initial itemset, not sure if necessary const SfxFilter* pMathFilter = SfxFilter::GetFilterByName(MATHML_XML); pClipboardMedium->SetFilter(pMathFilter); - SvMemoryStream * pStrm; + std::unique_ptr<SvMemoryStream> pStrm; // The text to be imported might asserts encoding like 'encoding="utf-8"' but FORMAT_STRING is UTF-16. // Force encoding to UTF-16, if encoding exists. bool bForceUTF16 = false; @@ -1709,18 +1708,16 @@ void SmViewShell::Execute(SfxRequest& rReq) if ( bForceUTF16 ) { OUString aNewString = aString.replaceAt( nPosL,nPosU-nPosL,"UTF-16"); - pStrm = new SvMemoryStream( const_cast<sal_Unicode *>(aNewString.getStr()), aNewString.getLength() * sizeof(sal_Unicode), StreamMode::READ); + pStrm.reset(new SvMemoryStream( const_cast<sal_Unicode *>(aNewString.getStr()), aNewString.getLength() * sizeof(sal_Unicode), StreamMode::READ)); } else { - pStrm = new SvMemoryStream( const_cast<sal_Unicode *>(aString.getStr()), aString.getLength() * sizeof(sal_Unicode), StreamMode::READ); + pStrm.reset(new SvMemoryStream( const_cast<sal_Unicode *>(aString.getStr()), aString.getLength() * sizeof(sal_Unicode), StreamMode::READ)); } uno::Reference<io::XInputStream> xStrm2( new ::utl::OInputStreamWrapper(*pStrm) ); pClipboardMedium->setStreamToLoadFrom(xStrm2, true /*bIsReadOnly*/); InsertFrom(*pClipboardMedium); GetDoc()->UpdateText(); - delete pClipboardMedium; - delete pStrm; } } } commit ebb5068a43c3ac8362225c1762d2a8eb74cf0eba Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Jul 10 09:07:05 2015 +0200 Use std::transform Change-Id: If3b361d4ba7155547316796265cbd3955a4b8071 diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 635b198..bc6d88e 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -891,19 +891,14 @@ void PropValVector::Insert(const beans::PropertyValue& rVal) } m_aValues.push_back(rVal); } + uno::Sequence< uno::Any > PropValVector::getValues() { - uno::Sequence< uno::Any > aRet( m_aValues.size() ); - uno::Any* pValues = aRet.getArray(); - sal_Int32 nVal = 0; - auto aIt = m_aValues.begin(); - while (aIt != m_aValues.end()) - { - pValues[nVal++] = aIt->Value; - ++aIt; - } - return aRet; + std::vector<uno::Any> aRet; + std::transform(m_aValues.begin(), m_aValues.end(), std::back_inserter(aRet), [](const beans::PropertyValue& rValue) { return rValue.Value; }); + return comphelper::containerToSequence(aRet); } + uno::Sequence< OUString > PropValVector::getNames() { std::vector<OUString> aRet; @@ -911,7 +906,6 @@ uno::Sequence< OUString > PropValVector::getNames() return comphelper::containerToSequence(aRet); } - void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) { try _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits