[Libreoffice-commits] core.git: framework/inc framework/source
Matthew Pottage
matthewpottage at invincitech.com
Wed Jan 7 07:48:19 PST 2015
framework/inc/classes/filtercachedata.hxx | 22 +++++------
framework/inc/jobs/jobdata.hxx | 2 -
framework/inc/stdtypes.h | 48 +++++++++---------------
framework/source/accelerators/storageholder.cxx | 2 +
framework/source/jobs/jobdata.cxx | 2 -
framework/source/jobs/jobexecutor.cxx | 16 ++++----
framework/source/services/pathsettings.cxx | 48 +++++++++++++-----------
7 files changed, 67 insertions(+), 73 deletions(-)
New commits:
commit 2c71f383019e0ac13b83aabd3011d7f7b55a62b3
Author: Matthew Pottage <matthewpottage at invincitech.com>
Date: Mon Dec 22 17:35:47 2014 +0000
fdo#75757: Remove inheritance from std::vector.
In framework/inc/stdtypes.h. class OUStringList.
Removed inheritance and separated additional functionality into more general
functions. Changed to using std::vector<OUString> rather than SequenceAsVector.
The functions now work for any vector. Although they could be made more general
and support any container by altering the arguments.
Change-Id: I472267029dc69da1ad0a98d55e26e3784f6b07cd
Reviewed-on: https://gerrit.libreoffice.org/13612
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/framework/inc/classes/filtercachedata.hxx b/framework/inc/classes/filtercachedata.hxx
index 8825a6b..ad82d07 100644
--- a/framework/inc/classes/filtercachedata.hxx
+++ b/framework/inc/classes/filtercachedata.hxx
@@ -90,8 +90,8 @@ struct FileType
sClipboardFormat.clear();
nDocumentIconID = 0;
lUINames.free ();
- lURLPattern.free();
- lExtensions.free();
+ framework::free(lURLPattern);
+ framework::free(lExtensions);
}
inline FileType& impl_copy( const FileType& rCopy )
@@ -153,8 +153,8 @@ struct Filter
nFlags = 0;
nFileFormatVersion = 0;
sTemplateName.clear();
- lUINames.free ();
- lUserData.free ();
+ lUINames.free();
+ framework::free(lUserData);
}
inline Filter& impl_copy( const Filter& rCopy )
@@ -213,7 +213,7 @@ struct Detector
inline void impl_clear()
{
sName.clear();
- lTypes.free();
+ framework::free(lTypes);
}
inline Detector& impl_copy( const Detector& rCopy )
@@ -254,8 +254,8 @@ struct Loader
inline void impl_clear()
{
sName.clear();
- lUINames.free ();
- lTypes.free ();
+ lUINames.free();
+ framework::free(lTypes);
}
inline Loader& impl_copy( const Loader& rCopy )
@@ -297,7 +297,7 @@ struct ContentHandler
inline void impl_clear()
{
sName.clear();
- lTypes.free();
+ framework::free(lTypes);
}
inline ContentHandler& impl_copy( const ContentHandler& rCopy )
@@ -335,9 +335,9 @@ class SetNodeHash : public std::unordered_map< OUString ,
inline void free()
{
SetNodeHash().swap( *this ); // get rid of reserved capacity
- lAddedItems.free ();
- lChangedItems.free();
- lRemovedItems.free();
+ framework::free(lAddedItems);
+ framework::free(lChangedItems);
+ framework::free(lRemovedItems);
}
// Append changed, added or removed items to special lists
diff --git a/framework/inc/jobs/jobdata.hxx b/framework/inc/jobs/jobdata.hxx
index 18d01e8..d60256f 100644
--- a/framework/inc/jobs/jobdata.hxx
+++ b/framework/inc/jobs/jobdata.hxx
@@ -209,7 +209,7 @@ class JobData
static void appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
const OUString& sEvent ,
- ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding >& lJobs );
+ ::std::vector< JobData::TJob2DocEventBinding >& lJobs );
// private helper
diff --git a/framework/inc/stdtypes.h b/framework/inc/stdtypes.h
index 8e9dfaf..faf2c73 100644
--- a/framework/inc/stdtypes.h
+++ b/framework/inc/stdtypes.h
@@ -20,6 +20,7 @@
#ifndef INCLUDED_FRAMEWORK_INC_STDTYPES_H
#define INCLUDED_FRAMEWORK_INC_STDTYPES_H
+#include <algorithm>
#include <queue>
#include <unordered_map>
#include <vector>
@@ -28,7 +29,6 @@
#include <com/sun/star/awt/KeyEvent.hpp>
-#include <comphelper/sequenceasvector.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include <rtl/ustring.hxx>
@@ -79,38 +79,26 @@ struct KeyEventEqualsFunc
}
};
-/**
- Basic string list based on a std::vector()
- It implements some additional funtionality which can be useful but
- is missing at the normal vector implementation.
-*/
-class OUStringList : public ::comphelper::SequenceAsVector< OUString >
-{
- public:
+typedef ::std::vector< OUString > OUStringList;
- // insert given element as the first one into the vector
- void push_front( const OUString& sElement )
- {
- insert( begin(), sElement );
- }
-
- // search for given element
- iterator find( const OUString& sElement )
- {
- return ::std::find(begin(), end(), sElement);
- }
+// search for given element
+template <class T>
+typename std::vector<T>::iterator find( std::vector<T>& vec, const T& sElement )
+{
+ return ::std::find(vec.begin(), vec.end(), sElement);
+}
- const_iterator findConst( const OUString& sElement ) const
- {
- return ::std::find(begin(), end(), sElement);
- }
+template <class T>
+typename std::vector<T>::const_iterator find( const std::vector<T>& vec, const T& sElement )
+{
+ return ::std::find(vec.begin(), vec.end(), sElement);
+}
- // the only way to free used memory really!
- void free()
- {
- OUStringList().swap( *this );// get rid of reserved capacity
- }
-};
+template <class T>
+void free(std::vector<T>& vec)
+{
+ OUStringList().swap(vec);
+}
/**
Basic string queue based on a std::queue()
diff --git a/framework/source/accelerators/storageholder.cxx b/framework/source/accelerators/storageholder.cxx
index 7f05035..2dc2731 100644
--- a/framework/source/accelerators/storageholder.cxx
+++ b/framework/source/accelerators/storageholder.cxx
@@ -37,6 +37,8 @@
#include <com/sun/star/io/XSeekable.hpp>
+#include <algorithm>
+
#define PATH_SEPARATOR_ASCII "/"
#define PATH_SEPARATOR_UNICODE ((sal_Unicode)'/')
#define PATH_SEPARATOR OUString(PATH_SEPARATOR_ASCII)
diff --git a/framework/source/jobs/jobdata.cxx b/framework/source/jobs/jobdata.cxx
index 91f96ca..814da4a 100644
--- a/framework/source/jobs/jobdata.cxx
+++ b/framework/source/jobs/jobdata.cxx
@@ -469,7 +469,7 @@ bool isEnabled( const OUString& sAdminTime ,
*/
void JobData::appendEnabledJobsForEvent( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
const OUString& sEvent ,
- ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding >& lJobs )
+ ::std::vector< JobData::TJob2DocEventBinding >& lJobs )
{
css::uno::Sequence< OUString > lAdditionalJobs = JobData::getEnabledJobsForEvent(rxContext, sEvent);
sal_Int32 c = lAdditionalJobs.getLength();
diff --git a/framework/source/jobs/jobexecutor.cxx b/framework/source/jobs/jobexecutor.cxx
index 6013090..1a19b98 100644
--- a/framework/source/jobs/jobexecutor.cxx
+++ b/framework/source/jobs/jobexecutor.cxx
@@ -210,7 +210,7 @@ void SAL_CALL JobExecutor::trigger( const OUString& sEvent ) throw(css::uno::Run
// Optimization!
// Check if the given event name exist inside configuration and reject wrong requests.
// This optimization suppress using of the cfg api for getting event and job descriptions ...
- if (m_lEvents.find(sEvent) == m_lEvents.end())
+ if (framework::find(m_lEvents, sEvent) == m_lEvents.end())
return;
// get list of all enabled jobs
@@ -255,7 +255,7 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
OUString EVENT_ON_DOCUMENT_ADDED("onDocumentAdded"); // Job API event : OnCreate or OnLoadFinished
OUString aModuleIdentifier;
- ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding > lJobs;
+ ::std::vector< JobData::TJob2DocEventBinding > lJobs;
/* SAFE */ {
osl::MutexGuard g(rBHelper.rMutex);
@@ -279,7 +279,7 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
(aEvent.EventName == EVENT_ON_LOAD)
)
{
- if (m_lEvents.find(EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
+ if (find(m_lEvents, EVENT_ON_DOCUMENT_OPENED) != m_lEvents.end())
JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_OPENED, lJobs);
}
@@ -289,17 +289,17 @@ void SAL_CALL JobExecutor::notifyEvent( const css::document::EventObject& aEvent
(aEvent.EventName == EVENT_ON_LOAD_FINISHED)
)
{
- if (m_lEvents.find(EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
+ if (find(m_lEvents, EVENT_ON_DOCUMENT_ADDED) != m_lEvents.end())
JobData::appendEnabledJobsForEvent(m_xContext, EVENT_ON_DOCUMENT_ADDED, lJobs);
}
// Add all jobs for "real" notified event too .-)
- if (m_lEvents.find(aEvent.EventName) != m_lEvents.end())
+ if (find(m_lEvents, aEvent.EventName) != m_lEvents.end())
JobData::appendEnabledJobsForEvent(m_xContext, aEvent.EventName, lJobs);
} /* SAFE */
// step over all enabled jobs and execute it
- ::comphelper::SequenceAsVector< JobData::TJob2DocEventBinding >::const_iterator pIt;
+ ::std::vector< JobData::TJob2DocEventBinding >::const_iterator pIt;
for ( pIt = lJobs.begin();
pIt != lJobs.end();
++pIt )
@@ -340,7 +340,7 @@ void SAL_CALL JobExecutor::elementInserted( const css::container::ContainerEvent
OUString sEvent = ::utl::extractFirstFromConfigurationPath(sValue);
if (!sEvent.isEmpty())
{
- OUStringList::iterator pEvent = m_lEvents.find(sEvent);
+ OUStringList::iterator pEvent = find(m_lEvents, sEvent);
if (pEvent == m_lEvents.end())
m_lEvents.push_back(sEvent);
}
@@ -355,7 +355,7 @@ void SAL_CALL JobExecutor::elementRemoved ( const css::container::ContainerEvent
OUString sEvent = ::utl::extractFirstFromConfigurationPath(sValue);
if (!sEvent.isEmpty())
{
- OUStringList::iterator pEvent = m_lEvents.find(sEvent);
+ OUStringList::iterator pEvent = find(m_lEvents, sEvent);
if (pEvent != m_lEvents.end())
m_lEvents.erase(pEvent);
}
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index 6b53a47..3dbaaf0 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -600,7 +600,7 @@ OUStringList PathSettings::impl_readOldFormat(const OUString& sPath)
}
else if (aVal >>= lStringListVal)
{
- aPathVal << lStringListVal;
+ aPathVal = comphelper::sequenceToContainer<OUStringList>(lStringListVal);
}
}
@@ -624,17 +624,19 @@ PathSettings::PathInfo PathSettings::impl_readNewFormat(const OUString& sPath)
// read internal path list
css::uno::Reference< css::container::XNameAccess > xIPath;
xPath->getByName(CFGPROP_INTERNALPATHS) >>= xIPath;
- aPathVal.lInternalPaths << xIPath->getElementNames();
+ aPathVal.lInternalPaths = comphelper::sequenceToContainer<OUStringList>(xIPath->getElementNames());
// read user defined path list
- aPathVal.lUserPaths << xPath->getByName(CFGPROP_USERPATHS);
+ css::uno::Sequence<OUString> vTmpUserPathsSeq;
+ xPath->getByName(CFGPROP_USERPATHS) >>= vTmpUserPathsSeq;
+ aPathVal.lUserPaths = comphelper::sequenceToContainer<OUStringList>(vTmpUserPathsSeq);
// read the writeable path
xPath->getByName(CFGPROP_WRITEPATH) >>= aPathVal.sWritePath;
// avoid duplicates, by removing the writeable path from
// the user defined path list if it happens to be there too
- OUStringList::iterator aI = aPathVal.lUserPaths.find(aPathVal.sWritePath);
+ OUStringList::iterator aI = find(aPathVal.lUserPaths, aPathVal.sWritePath);
if (aI != aPathVal.lUserPaths.end())
aPathVal.lUserPaths.erase(aI);
@@ -677,7 +679,7 @@ void PathSettings::impl_storePath(const PathSettings::PathInfo& aPath)
::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew,
aResubstPath.sPathName,
CFGPROP_USERPATHS,
- css::uno::makeAny(aResubstPath.lUserPaths.getAsConstList()));
+ css::uno::makeAny(comphelper::containerToSequence(aResubstPath.lUserPaths)));
}
::comphelper::ConfigurationHelper::writeRelativeKey(xCfgNew,
@@ -722,8 +724,8 @@ void PathSettings::impl_mergeOldUserPaths( PathSettings::PathInfo& rPath,
else
{
if (
- ( rPath.lInternalPaths.findConst(sOld) == rPath.lInternalPaths.end()) &&
- ( rPath.lUserPaths.findConst(sOld) == rPath.lUserPaths.end() ) &&
+ ( find(rPath.lInternalPaths, sOld) == rPath.lInternalPaths.end()) &&
+ ( find(rPath.lUserPaths, sOld) == rPath.lUserPaths.end() ) &&
(! rPath.sWritePath.equals(sOld) )
)
rPath.lUserPaths.push_back(sOld);
@@ -924,18 +926,18 @@ void PathSettings::impl_notifyPropListener( PathSettings::EChangeOp /*eOp*/
case IDGROUP_INTERNAL_PATHS :
{
if (pPathOld)
- lOldVals[0] <<= pPathOld->lInternalPaths.getAsConstList();
+ lOldVals[0] <<= comphelper::containerToSequence(pPathOld->lInternalPaths);
if (pPathNew)
- lNewVals[0] <<= pPathNew->lInternalPaths.getAsConstList();
+ lNewVals[0] <<= comphelper::containerToSequence(pPathNew->lInternalPaths);
}
break;
case IDGROUP_USER_PATHS :
{
if (pPathOld)
- lOldVals[0] <<= pPathOld->lUserPaths.getAsConstList();
+ lOldVals[0] <<= comphelper::containerToSequence(pPathOld->lUserPaths);
if (pPathNew)
- lNewVals[0] <<= pPathNew->lUserPaths.getAsConstList();
+ lNewVals[0] <<= comphelper::containerToSequence(pPathNew->lUserPaths);
}
break;
@@ -1054,10 +1056,10 @@ void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
++pIt )
{
const OUString& rItem = *pIt;
- OUStringList::iterator pItem = lList.find(rItem);
+ OUStringList::iterator pItem = find(lList, rItem);
if (pItem != lList.end())
lList.erase(pItem);
- pItem = rPath.lUserPaths.find(rItem);
+ pItem = find(rPath.lUserPaths, rItem);
if (pItem != rPath.lUserPaths.end())
rPath.lUserPaths.erase(pItem);
}
@@ -1067,7 +1069,7 @@ void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
while ( pIt != rPath.lUserPaths.end() )
{
const OUString& rItem = *pIt;
- OUStringList::iterator pItem = lList.find(rItem);
+ OUStringList::iterator pItem = find(lList, rItem);
if ( pItem == lList.end() )
{
rPath.lUserPaths.erase(pIt);
@@ -1085,13 +1087,13 @@ void PathSettings::impl_purgeKnownPaths(PathSettings::PathInfo& rPath,
++pIt )
{
const OUString& rItem = *pIt;
- OUStringList::iterator pItem = lList.find(rItem);
+ OUStringList::iterator pItem = find(lList, rItem);
if (pItem != lList.end())
lList.erase(pItem);
}
// Erase the write path from lList
- OUStringList::iterator pItem = lList.find(rPath.sWritePath);
+ OUStringList::iterator pItem = find(lList, rPath.sWritePath);
if (pItem != lList.end())
lList.erase(pItem);
}
@@ -1173,13 +1175,13 @@ css::uno::Any PathSettings::impl_getPathValue(sal_Int32 nID) const
case IDGROUP_INTERNAL_PATHS :
{
- aVal <<= pPath->lInternalPaths.getAsConstList();
+ aVal <<= comphelper::containerToSequence(pPath->lInternalPaths);
}
break;
case IDGROUP_USER_PATHS :
{
- aVal <<= pPath->lUserPaths.getAsConstList();
+ aVal <<= comphelper::containerToSequence(pPath->lUserPaths);
}
break;
@@ -1249,8 +1251,9 @@ void PathSettings::impl_setPathValue( sal_Int32 nID ,
static_cast< ::cppu::OWeakObject* >(this));
}
- OUStringList lList;
- lList << aVal;
+ css::uno::Sequence<OUString> lTmpList;
+ aVal >>= lTmpList;
+ OUStringList lList = comphelper::sequenceToContainer<OUStringList>(lTmpList);
if (! impl_isValidPath(lList))
throw css::lang::IllegalArgumentException();
aChangePath.lInternalPaths = lList;
@@ -1269,8 +1272,9 @@ void PathSettings::impl_setPathValue( sal_Int32 nID ,
static_cast< ::cppu::OWeakObject* >(this));
}
- OUStringList lList;
- lList << aVal;
+ css::uno::Sequence<OUString> lTmpList;
+ aVal >>= lTmpList;
+ OUStringList lList = comphelper::sequenceToContainer<OUStringList>(lTmpList);
if (! impl_isValidPath(lList))
throw css::lang::IllegalArgumentException();
aChangePath.lUserPaths = lList;
More information about the Libreoffice-commits
mailing list