summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-11-05 17:10:24 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-11-06 20:40:25 -0500
commit719c3fb46bb38c69daea617ea9aaafc72505684d (patch)
tree7a32909591a4adf8c3147f2ec4132e2acdd30476 /sc
parent112fb381299ed917b729b17066974a3dc9c3bafd (diff)
Add mutex for external source document meta-data container.
These get updated from reference parser code (ScAddress, ScRange etc) which may be run from multiple threads. Change-Id: I5a1aaa4b51d9b9fb032458eb5e89f0652887184e
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/externalrefmgr.hxx8
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx18
2 files changed, 24 insertions, 2 deletions
diff --git a/sc/inc/externalrefmgr.hxx b/sc/inc/externalrefmgr.hxx
index c5a73aea8a7a..6156abb06ac4 100644
--- a/sc/inc/externalrefmgr.hxx
+++ b/sc/inc/externalrefmgr.hxx
@@ -793,8 +793,12 @@ private:
NumFmtMap maNumFormatMap;
- /** original source file index. */
- ::std::vector<SrcFileData> maSrcFiles;
+ /**
+ * List of external source document meta-data, used to keep track of
+ * external document identifiers.
+ */
+ std::vector<SrcFileData> maSrcFiles;
+ mutable osl::Mutex maMtxSrcFiles;
/** Status whether in reference marking state. See isInReferenceMarking(). */
bool mbInReferenceMarking:1;
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index f7d026b2ca30..1561cbbd058a 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1594,6 +1594,7 @@ void ScExternalRefManager::getAllCachedNumberFormats(vector<sal_uInt32>& rNumFmt
sal_uInt16 ScExternalRefManager::getExternalFileCount() const
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
return static_cast< sal_uInt16 >( maSrcFiles.size() );
}
@@ -2360,6 +2361,7 @@ void ScExternalRefManager::SrcFileData::maybeCreateRealFileName(const OUString&
void ScExternalRefManager::maybeCreateRealFileName(sal_uInt16 nFileId)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
if (nFileId >= maSrcFiles.size())
return;
@@ -2404,6 +2406,8 @@ void ScExternalRefManager::convertToAbsName(OUString& rFile) const
sal_uInt16 ScExternalRefManager::getExternalFileId(const OUString& rFile)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
+
vector<SrcFileData>::const_iterator itrBeg = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
vector<SrcFileData>::const_iterator itr = find_if(itrBeg, itrEnd, FindSrcFileByName(rFile));
if (itr != itrEnd)
@@ -2420,6 +2424,8 @@ sal_uInt16 ScExternalRefManager::getExternalFileId(const OUString& rFile)
const OUString* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId, bool bForceOriginal)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
+
if (nFileId >= maSrcFiles.size())
return NULL;
@@ -2436,11 +2442,14 @@ const OUString* ScExternalRefManager::getExternalFileName(sal_uInt16 nFileId, bo
bool ScExternalRefManager::hasExternalFile(sal_uInt16 nFileId) const
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
return nFileId < maSrcFiles.size();
}
bool ScExternalRefManager::hasExternalFile(const OUString& rFile) const
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
+
vector<SrcFileData>::const_iterator itrBeg = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
vector<SrcFileData>::const_iterator itr = find_if(itrBeg, itrEnd, FindSrcFileByName(rFile));
return itr != itrEnd;
@@ -2539,6 +2548,8 @@ void ScExternalRefManager::breakLink(sal_uInt16 nFileId)
void ScExternalRefManager::switchSrcFile(sal_uInt16 nFileId, const OUString& rNewFile, const OUString& rNewFilter)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
+
maSrcFiles[nFileId].maFileName = rNewFile;
maSrcFiles[nFileId].maRelativeName = OUString();
maSrcFiles[nFileId].maRealFileName = OUString();
@@ -2553,6 +2564,8 @@ void ScExternalRefManager::switchSrcFile(sal_uInt16 nFileId, const OUString& rNe
void ScExternalRefManager::setRelativeFileName(sal_uInt16 nFileId, const OUString& rRelUrl)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
+
if (nFileId >= maSrcFiles.size())
return;
maSrcFiles[nFileId].maRelativeName = rRelUrl;
@@ -2560,6 +2573,8 @@ void ScExternalRefManager::setRelativeFileName(sal_uInt16 nFileId, const OUStrin
void ScExternalRefManager::setFilterData(sal_uInt16 nFileId, const OUString& rFilterName, const OUString& rOptions)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
+
if (nFileId >= maSrcFiles.size())
return;
maSrcFiles[nFileId].maFilterName = rFilterName;
@@ -2578,11 +2593,13 @@ void ScExternalRefManager::clear()
bool ScExternalRefManager::hasExternalData() const
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
return !maSrcFiles.empty();
}
void ScExternalRefManager::resetSrcFileData(const OUString& rBaseFileUrl)
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
for (vector<SrcFileData>::iterator itr = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
itr != itrEnd; ++itr)
{
@@ -2598,6 +2615,7 @@ void ScExternalRefManager::resetSrcFileData(const OUString& rBaseFileUrl)
void ScExternalRefManager::updateAbsAfterLoad()
{
+ osl::MutexGuard aGuard(&maMtxSrcFiles);
OUString aOwn( getOwnDocumentName() );
for (vector<SrcFileData>::iterator itr = maSrcFiles.begin(), itrEnd = maSrcFiles.end();
itr != itrEnd; ++itr)