[Libreoffice-commits] core.git: 2 commits - hwpfilter/source ucb/source
Noel Grandin
noel.grandin at collabora.co.uk
Tue Jan 17 06:42:52 UTC 2017
hwpfilter/source/formula.cxx | 60 ++++++++++++++++++++---------------------
hwpfilter/source/formula.h | 12 ++------
ucb/source/core/FileAccess.cxx | 60 +++++++++++++++++++----------------------
3 files changed, 62 insertions(+), 70 deletions(-)
New commits:
commit 2b458b67ebc3c3291f003f667480a1ccf376637d
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 16 14:29:48 2017 +0200
use rtl::Reference OFileAccess
instead of storing both a raw pointer and an uno::Reference
Change-Id: I36f1788510e7233ae3de4610370528e24ca03e1d
Reviewed-on: https://gerrit.libreoffice.org/33170
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/ucb/source/core/FileAccess.cxx b/ucb/source/core/FileAccess.cxx
index 545785c..481ac23 100644
--- a/ucb/source/core/FileAccess.cxx
+++ b/ucb/source/core/FileAccess.cxx
@@ -82,9 +82,8 @@ class OCommandEnvironment;
class OFileAccess : public FileAccessHelper
{
- Reference< XComponentContext > m_xContext;
- Reference< XCommandEnvironment > mxEnvironment;
- OCommandEnvironment* mpEnvironment;
+ Reference< XComponentContext > m_xContext;
+ rtl::Reference<OCommandEnvironment> mxEnvironment;
void transferImpl( const OUString& rSource, const OUString& rDest, bool bMoveData )
throw(CommandAbortedException, Exception, RuntimeException);
@@ -95,7 +94,7 @@ class OFileAccess : public FileAccessHelper
public:
explicit OFileAccess( const Reference< XComponentContext > & xContext )
- : m_xContext( xContext), mpEnvironment( nullptr ) {}
+ : m_xContext( xContext) {}
// Methods
virtual void SAL_CALL copy( const OUString& SourceURL, const OUString& DestURL ) throw(css::ucb::CommandAbortedException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
virtual void SAL_CALL move( const OUString& SourceURL, const OUString& DestURL ) throw(css::ucb::CommandAbortedException, css::uno::Exception, css::uno::RuntimeException, std::exception) override;
@@ -271,8 +270,8 @@ void OFileAccess::transferImpl( const OUString& rSource,
}
- ucbhelper::Content aDestPath( aDestURL, mxEnvironment, comphelper::getProcessComponentContext() );
- ucbhelper::Content aSrc ( aSourceURL, mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aDestPath( aDestURL, mxEnvironment.get(), comphelper::getProcessComponentContext() );
+ ucbhelper::Content aSrc ( aSourceURL, mxEnvironment.get(), comphelper::getProcessComponentContext() );
try
{
@@ -306,7 +305,7 @@ void OFileAccess::kill( const OUString& FileURL )
{
// SfxContentHelper::Kill
INetURLObject aDeleteObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aDeleteObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aDeleteObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
try
{
aCnt.executeCommand( "delete", makeAny( true ) );
@@ -324,7 +323,7 @@ sal_Bool OFileAccess::isFolder( const OUString& FileURL )
try
{
INetURLObject aURLObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
bRet = aCnt.isFolder();
}
catch (const Exception &) {}
@@ -335,7 +334,7 @@ sal_Bool OFileAccess::isReadOnly( const OUString& FileURL )
throw(CommandAbortedException, Exception, RuntimeException, std::exception)
{
INetURLObject aURLObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
Any aRetAny = aCnt.getPropertyValue("IsReadOnly");
bool bRet = false;
aRetAny >>= bRet;
@@ -346,7 +345,7 @@ void OFileAccess::setReadOnly( const OUString& FileURL, sal_Bool bReadOnly )
throw(CommandAbortedException, Exception, RuntimeException, std::exception)
{
INetURLObject aURLObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
aCnt.setPropertyValue("IsReadOnly", Any(bReadOnly) );
}
@@ -372,7 +371,7 @@ void OFileAccess::createFolder( const OUString& NewFolderURL )
}
}
- ucbhelper::Content aCnt( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
Sequence< ContentInfo > aInfo = aCnt.queryCreatableContentsInfo();
sal_Int32 nCount = aInfo.getLength();
@@ -423,7 +422,7 @@ sal_Int32 OFileAccess::getSize( const OUString& FileURL )
sal_Int32 nSize = 0;
sal_Int64 nTemp = 0;
INetURLObject aObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
aCnt.getPropertyValue( "Size" ) >>= nTemp;
nSize = (sal_Int32)nTemp;
return nSize;
@@ -433,7 +432,7 @@ OUString OFileAccess::getContentType( const OUString& FileURL )
throw(CommandAbortedException, Exception, RuntimeException, std::exception)
{
INetURLObject aObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
Reference< XContent > xContent = aCnt.get();
OUString aTypeStr = xContent->getContentType();
@@ -462,7 +461,7 @@ Sequence< OUString > OFileAccess::getFolderContents( const OUString& FolderURL,
StringList_Impl* pFiles = nullptr;
INetURLObject aFolderObj( FolderURL, INetProtocol::File );
- ucbhelper::Content aCnt( aFolderObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aFolderObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
Reference< XResultSet > xResultSet;
Sequence< OUString > aProps(0);
@@ -534,7 +533,7 @@ Reference< XInputStream > OFileAccess::openFileRead( const OUString& FileURL )
{
Reference< XInputStream > xRet;
INetURLObject aObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
Reference< XActiveDataSink > xSink = static_cast<XActiveDataSink*>(new OActiveDataSink());
@@ -578,14 +577,14 @@ Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL )
aCmdArg <<= aArg;
INetURLObject aFileObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
// Be silent...
Reference< XInteractionHandler > xIH;
- if ( mpEnvironment )
+ if ( mxEnvironment.is() )
{
- xIH = mpEnvironment->getInteractionHandler();
- mpEnvironment->setHandler( nullptr );
+ xIH = mxEnvironment->getInteractionHandler();
+ mxEnvironment->setHandler( nullptr );
}
try
@@ -594,8 +593,8 @@ Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL )
}
catch ( InteractiveIOException const & e )
{
- if ( xIH.is() && mpEnvironment )
- mpEnvironment->setHandler( xIH );
+ if ( xIH.is() && mxEnvironment.is() )
+ mxEnvironment->setHandler( xIH );
if ( e.Code == IOErrorCode_NOT_EXISTING )
{
@@ -617,8 +616,8 @@ Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL )
throw;
}
- if ( xIH.is() && mpEnvironment )
- mpEnvironment->setHandler( xIH );
+ if ( xIH.is() && mxEnvironment.is() )
+ mxEnvironment->setHandler( xIH );
Reference< XStream > xRet = xSink->getStream();
return xRet;
@@ -627,12 +626,11 @@ Reference< XStream > OFileAccess::openFileReadWrite( const OUString& FileURL )
void OFileAccess::setInteractionHandler( const Reference< XInteractionHandler >& Handler )
throw(RuntimeException, std::exception)
{
- if( !mpEnvironment )
+ if( !mxEnvironment.is() )
{
- mpEnvironment = new OCommandEnvironment();
- mxEnvironment = static_cast<XCommandEnvironment*>(mpEnvironment);
+ mxEnvironment = new OCommandEnvironment();
}
- mpEnvironment->setHandler( Handler );
+ mxEnvironment->setHandler( Handler );
}
bool OFileAccess::createNewFile( const OUString & rParentURL,
@@ -640,7 +638,7 @@ bool OFileAccess::createNewFile( const OUString & rParentURL,
const Reference< XInputStream >& data )
throw ( Exception )
{
- ucbhelper::Content aParentCnt( rParentURL, mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aParentCnt( rParentURL, mxEnvironment.get(), comphelper::getProcessComponentContext() );
Sequence< ContentInfo > aInfo = aParentCnt.queryCreatableContentsInfo();
sal_Int32 nCount = aInfo.getLength();
@@ -698,7 +696,7 @@ void SAL_CALL OFileAccess::writeFile( const OUString& FileURL,
try
{
ucbhelper::Content aCnt(
- aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment,
+ aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(),
comphelper::getProcessComponentContext() );
try
@@ -745,7 +743,7 @@ sal_Bool OFileAccess::isHidden( const OUString& FileURL )
throw(CommandAbortedException, Exception, RuntimeException, std::exception)
{
INetURLObject aURLObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
Any aRetAny = aCnt.getPropertyValue("IsHidden");
bool bRet = false;
aRetAny >>= bRet;
@@ -756,7 +754,7 @@ void OFileAccess::setHidden( const OUString& FileURL, sal_Bool bHidden )
throw(CommandAbortedException, Exception, RuntimeException, std::exception)
{
INetURLObject aURLObj( FileURL, INetProtocol::File );
- ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment, comphelper::getProcessComponentContext() );
+ ucbhelper::Content aCnt( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), mxEnvironment.get(), comphelper::getProcessComponentContext() );
aCnt.setPropertyValue("IsHidden", Any(bHidden) );
}
commit b936cf58387c103f025da35a2c698417aa72a85f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Mon Jan 16 14:24:22 2017 +0200
use rtl::Reference in Formula
instead of storing both a raw pointer and a uno::Reference
Change-Id: I7f8baae687e528e89c7cdea1a92099ff4a759878
Reviewed-on: https://gerrit.libreoffice.org/33169
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index 8b6ce28..c3d3b9c 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -35,7 +35,7 @@
#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
#define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(false)
-#define padd(x,y,z) pList->addAttribute(x,y,z)
+#define padd(x,y,z) mxList->addAttribute(x,y,z)
#else
static int indent = 0;
#define inds indent++; for(int i = 0 ; i < indent ; i++) fprintf(stderr," ")
@@ -52,9 +52,9 @@ void Formula::makeMathML(Node *res)
fprintf(stderr,"<math:math xmlns:math=\"http://www.w3.org/1998/Math/MathML\">\n");
#else
padd("xmlns:math", "CDATA", "http://www.w3.org/1998/Math/MathML");
- rstartEl("math:math", rList);
- pList->clear();
- rstartEl("math:semantics", rList);
+ rstartEl("math:math", mxList.get());
+ mxList->clear();
+ rstartEl("math:semantics", mxList.get());
#endif
if( tmp->child )
makeLines( tmp->child );
@@ -92,7 +92,7 @@ void Formula::makeLine(Node *res)
#ifdef DEBUG
inds; fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl("math:mrow", rList);
+ rstartEl("math:mrow", mxList.get());
#endif
if( res->child )
makeExprList( res->child );
@@ -131,7 +131,7 @@ void Formula::makeExpr(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl("math:mrow", rList);
+ rstartEl("math:mrow", mxList.get());
#endif
}
@@ -194,7 +194,7 @@ void Formula::makeIdentifier(Node *res)
fprintf(stderr,"<math:mi>%s</math:mi>\n",tmp->value);
indo;
#else
- rstartEl("math:mi", rList);
+ rstartEl("math:mi", mxList.get());
rchars(OUString::createFromAscii(tmp->value));
rendEl("math:mi");
#endif
@@ -203,7 +203,7 @@ void Formula::makeIdentifier(Node *res)
{
#ifdef DEBUG
#else
- rstartEl("math:mi", rList);
+ rstartEl("math:mi", mxList.get());
reucstr(tmp->value, strlen(tmp->value));
rendEl("math:mi");
#endif
@@ -216,7 +216,7 @@ void Formula::makeIdentifier(Node *res)
getMathMLEntity(tmp->value).c_str());
indo;
#else
- rstartEl("math:mi", rList);
+ rstartEl("math:mi", mxList.get());
runistr(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str()));
rendEl("math:mi");
#endif
@@ -227,7 +227,7 @@ void Formula::makeIdentifier(Node *res)
fprintf(stderr,"<math:mn>%s</math:mn>\n",tmp->value);
indo;
#else
- rstartEl("math:mn", rList);
+ rstartEl("math:mn", mxList.get());
rchars(OUString::createFromAscii(tmp->value));
rendEl("math:mn");
#endif
@@ -238,7 +238,7 @@ void Formula::makeIdentifier(Node *res)
#ifdef DEBUG
inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value); indo;
#else
- rstartEl("math:mo", rList);
+ rstartEl("math:mo", mxList.get());
runistr(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str()));
rendEl("math:mo");
#endif
@@ -278,11 +278,11 @@ void Formula::makeSubSup(Node *res)
fprintf(stderr,"<math:msubsup>\n");
#else
if( res->id == ID_SUBEXPR )
- rstartEl("math:msub", rList);
+ rstartEl("math:msub", mxList.get());
else if( res->id == ID_SUPEXPR )
- rstartEl("math:msup", rList);
+ rstartEl("math:msup", mxList.get());
else
- rstartEl("math:msubsup", rList);
+ rstartEl("math:msubsup", mxList.get());
#endif
tmp = tmp->child;
@@ -323,7 +323,7 @@ void Formula::makeFraction(Node *res)
inds;
fprintf(stderr,"<math:mfrac>\n");
#else
- rstartEl("math:mfrac", rList);
+ rstartEl("math:mfrac", mxList.get());
#endif
tmp = tmp->child;
@@ -331,7 +331,7 @@ void Formula::makeFraction(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl("math:mrow", rList);
+ rstartEl("math:mrow", mxList.get());
#endif
if( res->id == ID_FRACTIONEXPR )
@@ -346,7 +346,7 @@ void Formula::makeFraction(Node *res)
fprintf(stderr,"<math:mrow>\n");
#else
rendEl("math:mrow");
- rstartEl("math:mrow", rList);
+ rstartEl("math:mrow", mxList.get());
#endif
if( res->id == ID_FRACTIONEXPR )
@@ -382,13 +382,13 @@ void Formula::makeDecoration(Node *res)
/* FIXME: no idea when 'accent' is true or false. */
if( isover ){
padd("accent","CDATA","true");
- rstartEl("math:mover", rList);
+ rstartEl("math:mover", mxList.get());
}
else{
padd("accentunder","CDATA","true");
- rstartEl("math:munder", rList);
+ rstartEl("math:munder", mxList.get());
}
- pList->clear();
+ mxList->clear();
#endif
makeBlock(tmp->next);
@@ -399,7 +399,7 @@ void Formula::makeDecoration(Node *res)
getMathMLEntity(tmp->value).c_str());
indo;
#else
- rstartEl("math:mo", rList);
+ rstartEl("math:mo", mxList.get());
runistr(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str()));
rendEl("math:mo");
#endif
@@ -430,9 +430,9 @@ void Formula::makeRoot(Node *res)
fprintf(stderr,"<math:mroot>\n");
#else
if( tmp->id == ID_SQRTEXPR )
- rstartEl("math:msqrt", rList);
+ rstartEl("math:msqrt", mxList.get());
else
- rstartEl("math:mroot", rList);
+ rstartEl("math:mroot", mxList.get());
#endif
if( tmp->id == ID_SQRTEXPR ){
@@ -476,14 +476,14 @@ void Formula::makeParenth(Node *res)
indo; inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl("math:mrow", rList);
- rstartEl("math:mo", rList);
+ rstartEl("math:mrow", mxList.get());
+ rstartEl("math:mo", mxList.get());
if( tmp->id == ID_PARENTH )
rchars("(");
else
rchars("|");
rendEl("math:mo");
- rstartEl("math:mrow", rList);
+ rstartEl("math:mrow", mxList.get());
#endif
if( tmp->child )
@@ -502,7 +502,7 @@ void Formula::makeParenth(Node *res)
fprintf(stderr,"</math:mrow>\n");
#else
rendEl("math:mrow");
- rstartEl("math:mo", rList);
+ rstartEl("math:mo", mxList.get());
if( tmp->id == ID_PARENTH )
rchars(")");
else
@@ -525,8 +525,8 @@ void Formula::makeFence(Node *res)
OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str())));
padd("close", "CDATA",
OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->next->next->value).c_str())));
- rstartEl("math:mfenced", rList);
- pList->clear();
+ rstartEl("math:mfenced", mxList.get());
+ mxList->clear();
#endif
makeExprList(tmp->next);
@@ -550,7 +550,7 @@ void Formula::makeBlock(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl("math:mrow", rList);
+ rstartEl("math:mrow", mxList.get());
#endif
if( res->child )
diff --git a/hwpfilter/source/formula.h b/hwpfilter/source/formula.h
index 642e226..62f44c7 100644
--- a/hwpfilter/source/formula.h
+++ b/hwpfilter/source/formula.h
@@ -20,12 +20,9 @@
#ifndef INCLUDED_HWPFILTER_SOURCE_FORMULA_H
#define INCLUDED_HWPFILTER_SOURCE_FORMULA_H
-// DVO: remove DEBUG dependency
-// #ifndef DEBUG
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include "attributes.hxx"
-// DVO: remove DEBUG dependency
-// #endif
+#include <rtl/ref.hxx>
class Node;
@@ -35,7 +32,6 @@ class Formula final
{
public:
explicit Formula(char *_eq)
- : pList(nullptr)
{
eq = _eq;
trim();
@@ -48,8 +44,7 @@ public:
}
void setAttributeListImpl( AttributeListImpl *p )
{
- pList = p;
- rList = static_cast<XAttributeList *>(pList);
+ mxList = p;
}
void parse();
private:
@@ -73,8 +68,7 @@ private:
private:
Reference< XDocumentHandler > m_rxDocumentHandler;
- Reference< XAttributeList > rList;
- AttributeListImpl *pList;
+ rtl::Reference<AttributeListImpl> mxList;
char *eq;
};
More information about the Libreoffice-commits
mailing list