[Libreoffice-commits] core.git: 2 commits - editeng/source forms/source include/editeng include/svtools svtools/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Fri Sep 6 19:41:19 UTC 2019
editeng/source/outliner/outliner.cxx | 10 +++++-----
editeng/source/outliner/overflowingtxt.cxx | 4 ++--
forms/source/component/imgprod.cxx | 2 +-
include/editeng/outliner.hxx | 4 ++--
include/editeng/overflowingtxt.hxx | 10 ++++------
include/svtools/imageresourceaccess.hxx | 2 +-
svtools/source/misc/imageresourceaccess.cxx | 14 +++++++-------
7 files changed, 22 insertions(+), 24 deletions(-)
New commits:
commit 374782be555c1d91628a098c3f1c5cd85f7b0b01
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 6 16:02:45 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 6 21:40:03 2019 +0200
use unique_ptr in Outliner
Change-Id: I022cf01f2c36f8846227a89418735271880d1f95
Reviewed-on: https://gerrit.libreoffice.org/78715
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 320dc6958355..515a9bcebe02 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -2012,7 +2012,7 @@ bool Outliner::IsPageOverflow()
return pEditEngine->IsPageOverflow();
}
-NonOverflowingText *Outliner::GetNonOverflowingText() const
+std::unique_ptr<NonOverflowingText> Outliner::GetNonOverflowingText() const
{
/* XXX:
* nCount should be the number of paragraphs of the non overflowing text
@@ -2076,7 +2076,7 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const
ESelection aEmptySel(0,0,0,0);
//EditTextObject *pTObj = pEditEngine->CreateTextObject(aEmptySel);
bool const bLastParaInterrupted = true; // Last Para was interrupted since everything overflew
- return new NonOverflowingText(aEmptySel, bLastParaInterrupted);
+ return std::make_unique<NonOverflowingText>(aEmptySel, bLastParaInterrupted);
} else { // Get the lines that of the overflowing para fit in the box
sal_Int32 nOverflowingPara = nCount;
@@ -2113,7 +2113,7 @@ NonOverflowingText *Outliner::GetNonOverflowingText() const
bool bLastParaInterrupted =
pEditEngine->GetOverflowingLineNum() > 0;
- return new NonOverflowingText(aOverflowingTextSelection, bLastParaInterrupted);
+ return std::make_unique<NonOverflowingText>(aOverflowingTextSelection, bLastParaInterrupted);
}
}
@@ -2125,7 +2125,7 @@ std::unique_ptr<OutlinerParaObject> Outliner::GetEmptyParaObject() const
return pPObj;
}
-OverflowingText *Outliner::GetOverflowingText() const
+std::unique_ptr<OverflowingText> Outliner::GetOverflowingText() const
{
if ( pEditEngine->GetOverflowingParaNum() < 0)
return nullptr;
@@ -2156,7 +2156,7 @@ OverflowingText *Outliner::GetOverflowingText() const
sal_Int32 nLastParaLen = GetText(GetParagraph(nLastPara)).getLength();
aOverflowingTextSel = ESelection(nOverflowingPara, nLen,
nLastPara, nLastParaLen);
- return new OverflowingText(pEditEngine->CreateTransferable(aOverflowingTextSel));
+ return std::make_unique<OverflowingText>(pEditEngine->CreateTransferable(aOverflowingTextSel));
}
diff --git a/editeng/source/outliner/overflowingtxt.cxx b/editeng/source/outliner/overflowingtxt.cxx
index 0181d93b2249..7d09dfb02acc 100644
--- a/editeng/source/outliner/overflowingtxt.cxx
+++ b/editeng/source/outliner/overflowingtxt.cxx
@@ -159,8 +159,8 @@ std::unique_ptr<OutlinerParaObject> OverflowingText::DeeplyMergeParaObject(Outli
OFlowChainedText::OFlowChainedText(Outliner const *pOutl, bool bIsDeepMerge)
{
- mpOverflowingTxt.reset( pOutl->GetOverflowingText() );
- mpNonOverflowingTxt.reset( pOutl->GetNonOverflowingText() );
+ mpOverflowingTxt = pOutl->GetOverflowingText();
+ mpNonOverflowingTxt = pOutl->GetNonOverflowingText();
mbIsDeepMerge = bIsDeepMerge;
}
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index f62f3e0fde15..acb484943bf7 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -733,8 +733,8 @@ public:
void SetParaRemovingHdl(const Link<ParagraphHdlParam,void>& rLink){aParaRemovingHdl=rLink;}
const Link<ParagraphHdlParam,void>& GetParaRemovingHdl() const { return aParaRemovingHdl; }
- NonOverflowingText *GetNonOverflowingText() const;
- OverflowingText *GetOverflowingText() const;
+ std::unique_ptr<NonOverflowingText> GetNonOverflowingText() const;
+ std::unique_ptr<OverflowingText> GetOverflowingText() const;
void ClearOverflowingParaNum();
bool IsPageOverflow();
diff --git a/include/editeng/overflowingtxt.hxx b/include/editeng/overflowingtxt.hxx
index b7835f175d61..e1f3637f46ff 100644
--- a/include/editeng/overflowingtxt.hxx
+++ b/include/editeng/overflowingtxt.hxx
@@ -68,27 +68,25 @@ public:
class OverflowingText
{
public:
+ OverflowingText(css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent);
+
std::unique_ptr<OutlinerParaObject> JuxtaposeParaObject(Outliner *, OutlinerParaObject const *);
std::unique_ptr<OutlinerParaObject> DeeplyMergeParaObject(Outliner *, OutlinerParaObject const *);
private:
- friend class Outliner;
- OverflowingText(css::uno::Reference< css::datatransfer::XTransferable > const & xOverflowingContent);
-
css::uno::Reference< css::datatransfer::XTransferable > mxOverflowingContent;
};
class NonOverflowingText
{
public:
+ NonOverflowingText(const ESelection &aSel, bool bLastParaInterrupted);
+
std::unique_ptr<OutlinerParaObject> RemoveOverflowingText(Outliner *) const;
ESelection GetOverflowPointSel() const;
bool IsLastParaInterrupted() const;
private:
- NonOverflowingText(const ESelection &aSel, bool bLastParaInterrupted);
-
- friend class Outliner;
const ESelection maContentSel;
const bool mbLastParaInterrupted;
};
commit f76a7bcc65343a4aa51d24b13c998bf04031d89f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Sep 6 16:34:45 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Sep 6 21:39:41 2019 +0200
return unique_ptr from :svt::GraphicAccess::getImageStream
Change-Id: Ie63259ce826101e553c1cb03a85e7c0ba5f0f9f5
Reviewed-on: https://gerrit.libreoffice.org/78719
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx
index 51961d86682d..c1b72d90daed 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -206,7 +206,7 @@ void ImageProducer::SetImage( const OUString& rPath )
if ( ::svt::GraphicAccess::isSupportedURL( maURL ) )
{
- mpStm.reset( ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL ) );
+ mpStm = ::svt::GraphicAccess::getImageStream( ::comphelper::getProcessComponentContext(), maURL );
}
else if( !maURL.isEmpty() )
{
diff --git a/include/svtools/imageresourceaccess.hxx b/include/svtools/imageresourceaccess.hxx
index 65806566936d..6adff39ae4aa 100644
--- a/include/svtools/imageresourceaccess.hxx
+++ b/include/svtools/imageresourceaccess.hxx
@@ -50,7 +50,7 @@ SVT_DLLPUBLIC bool isSupportedURL(OUString const & rURL);
the image must be copied), so you are strongly encouraged to only use it
when you know that the image is small enough.
*/
-SVT_DLLPUBLIC SvStream* getImageStream(
+SVT_DLLPUBLIC std::unique_ptr<SvStream> getImageStream(
css::uno::Reference<css::uno::XComponentContext> const & rxContext,
OUString const & rImageResourceURL);
diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx
index b8a27dd7a802..829ffdb5feb5 100644
--- a/svtools/source/misc/imageresourceaccess.cxx
+++ b/svtools/source/misc/imageresourceaccess.cxx
@@ -111,9 +111,9 @@ bool isSupportedURL(OUString const & rURL)
|| rURL.startsWith("vnd.sun.star.extension://");
}
-SvStream* getImageStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL)
+std::unique_ptr<SvStream> getImageStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL)
{
- SvStream* pReturn = nullptr;
+ std::unique_ptr<SvMemoryStream> pMemBuffer;
try
{
@@ -128,10 +128,10 @@ SvStream* getImageStream(uno::Reference<uno::XComponentContext> const & rxContex
OSL_ENSURE(xGraphic.is(), "GraphicAccess::getImageStream: the provider did not give us a graphic object!");
if (!xGraphic.is())
- return pReturn;
+ return pMemBuffer;
// copy the graphic to an in-memory buffer
- SvMemoryStream* pMemBuffer = new SvMemoryStream;
+ pMemBuffer.reset(new SvMemoryStream);
uno::Reference<io::XStream> xBufferAccess = new StreamSupplier(
new OSeekableInputStreamWrapper(*pMemBuffer),
new OSeekableOutputStreamWrapper(*pMemBuffer));
@@ -144,19 +144,19 @@ SvStream* getImageStream(uno::Reference<uno::XComponentContext> const & rxContex
xProvider->storeGraphic(xGraphic, aMediaProperties);
pMemBuffer->Seek(0);
- pReturn = pMemBuffer;
}
catch (const uno::Exception&)
{
OSL_FAIL("GraphicAccess::getImageStream: caught an exception!");
+ pMemBuffer.reset();
}
- return pReturn;
+ return pMemBuffer;
}
uno::Reference<io::XInputStream> getImageXStream(uno::Reference<uno::XComponentContext> const & rxContext, OUString const & rImageResourceURL)
{
- return new OSeekableInputStreamWrapper(getImageStream(rxContext, rImageResourceURL), true); // take ownership
+ return new OSeekableInputStreamWrapper(getImageStream(rxContext, rImageResourceURL).release(), true); // take ownership
}
} // namespace GraphicAccess
More information about the Libreoffice-commits
mailing list