[Libreoffice-commits] core.git: 4 commits - basic/source include/basic sfx2/source sw/source
Michael Stahl
mstahl at redhat.com
Thu Sep 3 07:35:01 PDT 2015
basic/source/basmgr/vbahelper.cxx | 55 ++++++-----------------
include/basic/vbahelper.hxx | 1
sfx2/source/notify/globalevents.cxx | 83 +++--------------------------------
sw/source/core/inc/noteurl.hxx | 9 ++-
sw/source/core/text/noteurl.cxx | 15 ++----
sw/source/filter/basflt/fltshell.cxx | 52 ++++++++++-----------
sw/source/filter/inc/fltshell.hxx | 14 +++--
7 files changed, 71 insertions(+), 158 deletions(-)
New commits:
commit 5ab60e85b1319e8bf0c698bc804bd78f3eb7a8ca
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Sep 3 15:16:59 2015 +0200
sw: replace boost::ptr_vector with std::vector
Change-Id: I477e7a809b572fd62b276afd44c8b140efb9d653
diff --git a/sw/source/core/inc/noteurl.hxx b/sw/source/core/inc/noteurl.hxx
index e6e3492..427802c 100644
--- a/sw/source/core/inc/noteurl.hxx
+++ b/sw/source/core/inc/noteurl.hxx
@@ -21,7 +21,10 @@
#define INCLUDED_SW_SOURCE_CORE_INC_NOTEURL_HXX
#include "swrect.hxx"
-#include <boost/ptr_container/ptr_vector.hpp>
+
+#include <rtl/ustring.hxx>
+
+#include <vector>
class ImageMap;
class MapMode;
@@ -44,7 +47,9 @@ public:
class SwNoteURL
{
- boost::ptr_vector<SwURLNote> aList;
+private:
+ std::vector<SwURLNote> m_List;
+
public:
SwNoteURL() {}
void InsertURLNote( const OUString& rURL, const OUString& rTarget,
diff --git a/sw/source/core/text/noteurl.cxx b/sw/source/core/text/noteurl.cxx
index 8057e1d..981a756 100644
--- a/sw/source/core/text/noteurl.cxx
+++ b/sw/source/core/text/noteurl.cxx
@@ -17,39 +17,38 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include "noteurl.hxx"
+
#include "swtypes.hxx"
#include <vcl/outdev.hxx>
#include <svtools/imaprect.hxx>
#include <svtools/imap.hxx>
-#include "noteurl.hxx"
-
// Global variable
SwNoteURL *pNoteURL = NULL;
void SwNoteURL::InsertURLNote( const OUString& rURL, const OUString& rTarget,
const SwRect& rRect )
{
- const size_t nCount = aList.size();
+ const size_t nCount = m_List.size();
for( size_t i = 0; i < nCount; ++i )
- if( rRect == aList[i].GetRect() )
+ if (rRect == m_List[i].GetRect())
return;
- SwURLNote *pNew = new SwURLNote( rURL, rTarget, rRect );
- aList.push_back( pNew );
+ m_List.push_back(SwURLNote(rURL, rTarget, rRect));
}
void SwNoteURL::FillImageMap( ImageMap *pMap, const Point &rPos,
const MapMode& rMap )
{
OSL_ENSURE( pMap, "FillImageMap: No ImageMap, no cookies!" );
- const size_t nCount = aList.size();
+ const size_t nCount = m_List.size();
if( nCount )
{
MapMode aMap( MAP_100TH_MM );
for( size_t i = 0; i < nCount; ++i )
{
- const SwURLNote &rNote = aList[i];
+ const SwURLNote &rNote = m_List[i];
SwRect aSwRect( rNote.GetRect() );
aSwRect -= rPos;
Rectangle aRect( OutputDevice::LogicToLogic( aSwRect.SVRect(),
commit fdc839390338f2882c1116362c39e197ce27b394
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Sep 3 15:08:35 2015 +0200
sw: replace boost::ptr_deque with std::deque<std::unique_ptr>
Change-Id: Ibb51b67d4d9568577b73a43411322fb5d09bb399
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index 6ef14e5..9c56334 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -172,7 +172,7 @@ SwFltControlStack::SwFltControlStack(SwDoc* pDo, sal_uLong nFieldFl)
SwFltControlStack::~SwFltControlStack()
{
- OSL_ENSURE(maEntries.empty(), "There are still Attributes on the stack");
+ OSL_ENSURE(m_Entries.empty(), "There are still Attributes on the stack");
}
// MoveAttrs() is meant to address the following problem:
@@ -184,13 +184,13 @@ SwFltControlStack::~SwFltControlStack()
// same paragraph further out by one character.
void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
{
- size_t nCnt = maEntries.size();
+ size_t nCnt = m_Entries.size();
sal_uLong nPosNd = rPos.nNode.GetIndex();
sal_uInt16 nPosCt = rPos.nContent.GetIndex() - 1;
for (size_t i=0; i < nCnt; ++i)
{
- SwFltStackEntry& rEntry = maEntries[i];
+ SwFltStackEntry& rEntry = *m_Entries[i];
if (
(rEntry.m_aMkPos.m_nNode.GetIndex()+1 == nPosNd) &&
(rEntry.m_aMkPos.m_nContent >= nPosCt)
@@ -216,9 +216,9 @@ void SwFltControlStack::MoveAttrs( const SwPosition& rPos )
void SwFltControlStack::MarkAllAttrsOld()
{
- size_t nCnt = maEntries.size();
+ size_t nCnt = m_Entries.size();
for (size_t i=0; i < nCnt; ++i)
- maEntries[i].bOld = true;
+ m_Entries[i]->bOld = true;
}
namespace
@@ -256,17 +256,17 @@ void SwFltControlStack::NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr
{
SwFltStackEntry *pTmp = new SwFltStackEntry(rPos, rAttr.Clone() );
pTmp->SetStartCP(GetCurrAttrCP());
- maEntries.push_back(pTmp);
+ m_Entries.push_back(std::unique_ptr<SwFltStackEntry>(pTmp));
}
}
void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
{
- OSL_ENSURE(nCnt < maEntries.size(), "Out of range!");
- if (nCnt < maEntries.size())
+ OSL_ENSURE(nCnt < m_Entries.size(), "Out of range!");
+ if (nCnt < m_Entries.size())
{
- myEIter aElement = maEntries.begin() + nCnt;
- maEntries.erase(aElement);
+ myEIter aElement = m_Entries.begin() + nCnt;
+ m_Entries.erase(aElement);
}
//Clear the para end position recorded in reader intermittently for the least impact on loading performance
//Because the attributes handled based on the unit of para
@@ -285,12 +285,12 @@ void SwFltControlStack::DeleteAndDestroy(Entries::size_type nCnt)
// graphic apos -> images.
void SwFltControlStack::StealAttr(const SwNodeIndex& rNode, sal_uInt16 nAttrId)
{
- size_t nCnt = maEntries.size();
+ size_t nCnt = m_Entries.size();
while (nCnt)
{
nCnt --;
- SwFltStackEntry& rEntry = maEntries[nCnt];
+ SwFltStackEntry& rEntry = *m_Entries[nCnt];
if (rEntry.m_aPtPos.m_nNode.GetIndex()+1 == rNode.GetIndex() &&
(!nAttrId || nAttrId == rEntry.pAttr->Which()))
{
@@ -307,11 +307,11 @@ void SwFltControlStack::KillUnlockedAttrs(const SwPosition& rPos)
{
SwFltPosition aFltPos(rPos);
- size_t nCnt = maEntries.size();
+ size_t nCnt = m_Entries.size();
while( nCnt )
{
nCnt --;
- SwFltStackEntry& rEntry = maEntries[nCnt];
+ SwFltStackEntry& rEntry = *m_Entries[nCnt];
if( !rEntry.bOld
&& !rEntry.bOpen
&& (rEntry.m_aMkPos == aFltPos)
@@ -338,12 +338,12 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
(RES_FLTRATTR_BEGIN <= nAttrId && RES_FLTRATTR_END > nAttrId),
"Wrong id for attribute");
- myEIter aI = maEntries.begin();
- while (aI != maEntries.end())
+ myEIter aI = m_Entries.begin();
+ while (aI != m_Entries.end())
{
- bool bLastEntry = aI == maEntries.end() - 1;
+ bool bLastEntry = aI == m_Entries.end() - 1;
- SwFltStackEntry& rEntry = *aI;
+ SwFltStackEntry& rEntry = **aI;
if (rEntry.bOpen)
{
// set end of attribute
@@ -413,7 +413,7 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
}
}
SetAttrInDoc(rPos, rEntry);
- aI = maEntries.erase(aI);
+ aI = m_Entries.erase(aI);
}
return pRet;
@@ -490,7 +490,7 @@ bool SwFltControlStack::HasSdOD()
{
bool bRet = false;
- for (Entries::iterator it = maEntries.begin(); it != maEntries.end(); ++it)
+ for (auto const& it : m_Entries)
{
SwFltStackEntry& rEntry = *it;
if ( rEntry.mnStartCP == rEntry.mnEndCP )
@@ -728,13 +728,13 @@ bool SwFltControlStack::CheckSdOD(sal_Int32 /*nStart*/, sal_Int32 /*nEnd*/)
SfxPoolItem* SwFltControlStack::GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16 * pPos)
{
- size_t nSize = maEntries.size();
+ size_t nSize = m_Entries.size();
while (nSize)
{
// is it the looked-for attribute ? (only applies to locked, meaning
// currently set attributes!!)
- SwFltStackEntry &rEntry = maEntries[--nSize];
+ SwFltStackEntry &rEntry = *m_Entries[--nSize];
if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich)
{
if (pPos)
@@ -749,11 +749,11 @@ const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, s
{
SwFltPosition aFltPos(rPos);
- size_t nSize = maEntries.size();
+ size_t nSize = m_Entries.size();
while (nSize)
{
- SwFltStackEntry &rEntry = maEntries[--nSize];
+ SwFltStackEntry &rEntry = *m_Entries[--nSize];
if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos)
{
return rEntry.pAttr;
@@ -779,9 +779,9 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
if (aEndNode != aStartNode)
return;
- for (size_t nSize = maEntries.size(); nSize > 0;)
+ for (size_t nSize = m_Entries.size(); nSize > 0;)
{
- SwFltStackEntry& rEntry = maEntries[--nSize];
+ SwFltStackEntry& rEntry = *m_Entries[--nSize];
bool bEntryStartAfterSelStart =
(rEntry.m_aMkPos.m_nNode == aStartNode &&
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index a406e7c..92235d9 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -33,7 +33,9 @@
#include <IDocumentRedlineAccess.hxx>
#include <boost/noncopyable.hpp>
-#include <boost/ptr_container/ptr_deque.hpp>
+
+#include <memory>
+#include <deque>
class SwTOXBase;
class SwField;
@@ -131,9 +133,9 @@ public:
class SW_DLLPUBLIC SwFltControlStack : private ::boost::noncopyable
{
- typedef boost::ptr_deque<SwFltStackEntry> Entries;
+ typedef std::deque<std::unique_ptr<SwFltStackEntry>> Entries;
typedef Entries::iterator myEIter;
- Entries maEntries;
+ Entries m_Entries;
sal_uLong nFieldFlags;
vcl::KeyCode aEmptyKeyCode; // fuer Bookmarks
@@ -186,10 +188,10 @@ public:
const SfxPoolItem* GetOpenStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
void Delete(const SwPaM &rPam);
- bool empty() const { return maEntries.empty(); }
- Entries::size_type size() const { return maEntries.size(); }
+ bool empty() const { return m_Entries.empty(); }
+ Entries::size_type size() const { return m_Entries.size(); }
SwFltStackEntry& operator[](Entries::size_type nIndex)
- { return maEntries[nIndex]; }
+ { return *m_Entries[nIndex]; }
void DeleteAndDestroy(Entries::size_type nCnt);
};
commit 327ab3c03343a52734980b26821e4ca7f6553f2e
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Sep 3 14:31:18 2015 +0200
sfx2: remove duplicative ModelCollectionEnumeration
Use the comphelper equivalent.
Change-Id: Iba0567948aeec1299191c759da6aa89b4aa014d8
diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx
index d1f4a47..1caafe1 100644
--- a/sfx2/source/notify/globalevents.cxx
+++ b/sfx2/source/notify/globalevents.cxx
@@ -33,6 +33,7 @@
#include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <rtl/ref.hxx>
+#include <comphelper/enumhelper.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objsh.hxx>
#include <sfx2/sfxbasemodel.hxx>
@@ -55,28 +56,6 @@ public:
typedef ::std::vector< css::uno::Reference< css::frame::XModel > > TModelList;
-class ModelCollectionEnumeration : public ModelCollectionMutexBase
- , public ::cppu::WeakImplHelper< css::container::XEnumeration >
-{
-private:
- TModelList m_lModels;
- TModelList::iterator m_pEnumerationIt;
-
-public:
- ModelCollectionEnumeration();
- virtual ~ModelCollectionEnumeration();
- void setModelList(const TModelList& rList);
-
- // css.container.XEnumeration
- virtual sal_Bool SAL_CALL hasMoreElements()
- throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
-
- virtual css::uno::Any SAL_CALL nextElement()
- throw(css::container::NoSuchElementException,
- css::lang::WrappedTargetException ,
- css::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
-};
-
//TODO: remove support of obsolete document::XEventBroadcaster/Listener
class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
@@ -178,55 +157,6 @@ private:
TModelList::iterator impl_searchDoc(const css::uno::Reference< css::frame::XModel >& xModel);
};
-ModelCollectionEnumeration::ModelCollectionEnumeration()
- : ModelCollectionMutexBase( )
- , m_pEnumerationIt (m_lModels.begin())
-{
-}
-
-ModelCollectionEnumeration::~ModelCollectionEnumeration()
-{
-}
-
-void ModelCollectionEnumeration::setModelList(const TModelList& rList)
-{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- m_lModels = rList;
- m_pEnumerationIt = m_lModels.begin();
- aLock.clear();
- // <- SAFE
-}
-
-sal_Bool SAL_CALL ModelCollectionEnumeration::hasMoreElements()
- throw(uno::RuntimeException, std::exception)
-{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- return (m_pEnumerationIt != m_lModels.end());
- // <- SAFE
-}
-
-uno::Any SAL_CALL ModelCollectionEnumeration::nextElement()
- throw(container::NoSuchElementException,
- lang::WrappedTargetException ,
- uno::RuntimeException, std::exception )
-{
- // SAFE ->
- ::osl::ResettableMutexGuard aLock(m_aLock);
- if (m_pEnumerationIt == m_lModels.end())
- throw container::NoSuchElementException(
- OUString("End of model enumeration reached."),
- static_cast< container::XEnumeration* >(this));
- uno::Reference< frame::XModel > xModel(*m_pEnumerationIt, uno::UNO_QUERY);
- ++m_pEnumerationIt;
- aLock.clear();
- // <- SAFE
-
- return uno::makeAny(xModel);
-}
-
-
SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const uno::Reference < uno::XComponentContext >& rxContext)
: ModelCollectionMutexBase( )
, m_xJobExecutorListener( task::theJobExecutor::get( rxContext ), uno::UNO_QUERY_THROW )
@@ -429,11 +359,14 @@ uno::Reference< container::XEnumeration > SAL_CALL SfxGlobalEvents_Impl::createE
{
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
- ModelCollectionEnumeration* pEnum = new ModelCollectionEnumeration();
- pEnum->setModelList(m_lModels);
+ uno::Sequence<uno::Any> models(m_lModels.size());
+ for (size_t i = 0; i < m_lModels.size(); ++i)
+ {
+ models[i] = uno::makeAny(m_lModels[i]);
+ }
uno::Reference< container::XEnumeration > xEnum(
- static_cast< container::XEnumeration* >(pEnum),
- uno::UNO_QUERY);
+ static_cast<container::XEnumeration*>(
+ new ::comphelper::OAnyEnumeration(models)));
aLock.clear();
// <- SAFE
commit 3fb50fbe2b4951034bbe5b75aef5c88e8cd22382
Author: Michael Stahl <mstahl at redhat.com>
Date: Thu Sep 3 13:54:47 2015 +0200
basic: remove over-engineered XEnumeration service
... that was causing duplicate WeakImplHelper symbols now.
Change-Id: Ibbf84a2059f30bfeb5c265adcafb4b56d2534dc8
diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx
index 09e07de..d62c79e 100644
--- a/basic/source/basmgr/vbahelper.cxx
+++ b/basic/source/basmgr/vbahelper.cxx
@@ -28,7 +28,6 @@
#include <com/sun/star/frame/ModuleManager.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
-#include <cppuhelper/implbase.hxx>
#include <rtl/instance.hxx>
namespace basic {
@@ -48,24 +47,12 @@ uno::Reference< frame::XModuleManager2 > lclCreateModuleManager()
return frame::ModuleManager::create(xContext);
}
+typedef ::std::vector<uno::Reference<frame::XModel>> ModelVector;
-
-/** Implementation of an enumeration of all open documents of the same type.
- */
-class DocumentsEnumeration : public ::cppu::WeakImplHelper< container::XEnumeration >
-{
-public:
- explicit DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel );
- virtual sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
- virtual uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
-private:
- typedef ::std::vector< uno::Reference< frame::XModel > > ModelVector;
- ModelVector maModels;
- ModelVector::iterator maModelIt;
-};
-
-DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel >& rxModel )
+static ModelVector CreateDocumentsEnumeration(
+ const uno::Reference< frame::XModel >& rxModel)
{
+ ModelVector models;
try
{
uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() );
@@ -77,29 +64,15 @@ DocumentsEnumeration::DocumentsEnumeration( const uno::Reference< frame::XModel
{
uno::Reference< frame::XModel > xCurrModel( xEnumeration->nextElement(), uno::UNO_QUERY_THROW );
if( xModuleManager->identify( xCurrModel ) == aIdentifier )
- maModels.push_back( xCurrModel );
+ models.push_back( xCurrModel );
}
}
catch(const uno::Exception& )
{
}
- maModelIt = maModels.begin();
-}
-
-sal_Bool SAL_CALL DocumentsEnumeration::hasMoreElements() throw (uno::RuntimeException, std::exception)
-{
- return maModelIt != maModels.end();
-}
-
-uno::Any SAL_CALL DocumentsEnumeration::nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
-{
- if( maModelIt == maModels.end() )
- throw container::NoSuchElementException();
- return uno::Any( *maModelIt++ );
+ return models;
}
-
-
/** Locks or unlocks the controllers of the specified document model.
*/
void lclLockControllers( const uno::Reference< frame::XModel >& rxModel, bool bLockControllers )
@@ -156,15 +129,17 @@ typedef void (*ModifyDocumentFunc)( const uno::Reference< frame::XModel >&, bool
*/
void lclIterateDocuments( ModifyDocumentFunc pModifyDocumentFunc, const uno::Reference< frame::XModel >& rxModel, bool bModificator )
{
- uno::Reference< container::XEnumeration > xDocumentsEnum( new DocumentsEnumeration( rxModel ) );
+ ModelVector models(CreateDocumentsEnumeration(rxModel));
// iterate over all open documents
- while( xDocumentsEnum->hasMoreElements() ) try
- {
- uno::Reference< frame::XModel > xCurrModel( xDocumentsEnum->nextElement(), uno::UNO_QUERY_THROW );
- pModifyDocumentFunc( xCurrModel, bModificator );
- }
- catch(const uno::Exception& )
+ for (auto const& xCurrModel : models)
{
+ try
+ {
+ pModifyDocumentFunc(xCurrModel, bModificator);
+ }
+ catch (const uno::Exception&)
+ {
+ }
}
}
diff --git a/include/basic/vbahelper.hxx b/include/basic/vbahelper.hxx
index ee2dea3..a4572fc 100644
--- a/include/basic/vbahelper.hxx
+++ b/include/basic/vbahelper.hxx
@@ -20,7 +20,6 @@
#ifndef INCLUDED_BASIC_VBAHELPER_HXX
#define INCLUDED_BASIC_VBAHELPER_HXX
-#include <com/sun/star/container/XEnumeration.hpp>
#include <com/sun/star/frame/XModel.hpp>
#include <rtl/ustring.hxx>
#include <basic/basicdllapi.h>
More information about the Libreoffice-commits
mailing list