diff options
author | Noel Power <noel.power@suse.com> | 2013-06-24 21:40:32 +0100 |
---|---|---|
committer | Noel Power <noel.power@suse.com> | 2013-06-24 21:40:32 +0100 |
commit | ee51444ed1f7003dafc93c8181b5f8c1b0fd165b (patch) | |
tree | fbe9f1aa3b27f33f112ddaecc67629de75ac63b5 | |
parent | 1680a8cd4f4393ec15c4f85cb63b6654117d56d1 (diff) |
fix borders unit test ( test values have changed )
Change-Id: I1205eddf83781bef655abe4a1293c691bc5f1c41
-rw-r--r-- | sc/qa/unit/subsequent_filters-test.cxx | 6 | ||||
-rw-r--r-- | sd/inc/drawdoc.hxx | 1 | ||||
-rw-r--r-- | sd/inc/shapelist.hxx | 21 | ||||
-rw-r--r-- | sd/source/core/drawdoc.cxx | 11 | ||||
-rw-r--r-- | sd/source/core/drawdoc4.cxx | 10 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 39 | ||||
-rw-r--r-- | sd/source/core/sdpage2.cxx | 6 | ||||
-rw-r--r-- | sd/source/core/shapelist.cxx | 49 | ||||
-rw-r--r-- | sd/source/ui/view/drviews1.cxx | 7 | ||||
-rw-r--r-- | sd/source/ui/view/sdview5.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/view/viewoverlaymanager.cxx | 5 |
11 files changed, 73 insertions, 87 deletions
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 17bfc3271eed..f4aa9ecf631a 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -766,19 +766,19 @@ void ScFiltersTest::testBorderXLS() CPPUNIT_ASSERT(pRight); CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(), table::BorderLineStyle::SOLID); - CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),4L); + CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),1L); pDoc->GetBorderLines( 3, 5, 0, &pLeft, &pTop, &pRight, &pBottom ); CPPUNIT_ASSERT(pRight); CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(), table::BorderLineStyle::SOLID); - CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),12L); + CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),20L); pDoc->GetBorderLines( 5, 7, 0, &pLeft, &pTop, &pRight, &pBottom ); CPPUNIT_ASSERT(pRight); CPPUNIT_ASSERT_EQUAL(pRight->GetBorderLineStyle(), table::BorderLineStyle::SOLID); - CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),16L); + CPPUNIT_ASSERT_EQUAL(pRight->GetWidth(),30L); } struct Border { diff --git a/sd/inc/drawdoc.hxx b/sd/inc/drawdoc.hxx index 77ac6b676b2a..1d05eb36115b 100644 --- a/sd/inc/drawdoc.hxx +++ b/sd/inc/drawdoc.hxx @@ -145,6 +145,7 @@ private: Timer* mpWorkStartupTimer; Timer* mpOnlineSpellingTimer; sd::ShapeList* mpOnlineSpellingList; + sd::ShapeList::const_iterator maShapeListIterator; SvxSearchItem* mpOnlineSearchItem; std::vector<sd::FrameView*> maFrameViewList; SdCustomShowList* mpCustomShowList; diff --git a/sd/inc/shapelist.hxx b/sd/inc/shapelist.hxx index f828ebc61d31..2d759a2bd493 100644 --- a/sd/inc/shapelist.hxx +++ b/sd/inc/shapelist.hxx @@ -29,6 +29,10 @@ namespace sd class ShapeList : public sdr::ObjectUser { public: + /** const_iterator guarantee only that the list itself is not + altered. The objects referenced by the list are still mutable. */ + typedef std::list< SdrObject* >::const_iterator const_iterator; + ShapeList(); virtual ~ShapeList(); @@ -48,26 +52,17 @@ namespace sd /** @return true if given shape is part of this list */ bool hasShape( SdrObject& rObject ) const; - /** returns the shape the internal iterator points to, or 0 if - * the list end is reached. moves the internal iterator to the - * next shape. */ - SdrObject* getNextShape(); - - /** Sets the internal iterator to the shape at given index. */ - void seekShape( sal_uInt32 nIndex ); - - /** - */ - bool hasMore() const; + /** @return const_iterator pointing to the first element */ + const_iterator cbegin() const; - const std::list< SdrObject* >& getList() const { return maShapeList; } + /** @return const_iterator pointing to the list termination element */ + const_iterator cend() const; private: virtual void ObjectInDestruction(const SdrObject& rObject); typedef std::list< SdrObject* > ListImpl; ListImpl maShapeList; - ListImpl::iterator maIter; }; } diff --git a/sd/source/core/drawdoc.cxx b/sd/source/core/drawdoc.cxx index aca4996aadae..ed8d1fcc5641 100644 --- a/sd/source/core/drawdoc.cxx +++ b/sd/source/core/drawdoc.cxx @@ -144,6 +144,7 @@ SdDrawDocument::SdDrawDocument(DocumentType eType, SfxObjectShell* pDrDocSh) , mpWorkStartupTimer(NULL) , mpOnlineSpellingTimer(NULL) , mpOnlineSpellingList(NULL) +, maShapeListIterator() , mpOnlineSearchItem(NULL) , mpCustomShowList(NULL) , mpDocSh(static_cast< ::sd::DrawDocShell*>(pDrDocSh)) @@ -694,7 +695,7 @@ void SdDrawDocument::UpdateAllLinks() */ void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool ) { - sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() ); + const sd::ShapeList& rPresentationShapes( pPage->GetPresentationShapeList() ); if(!rPresentationShapes.isEmpty()) { // Create lists of title and outline styles @@ -706,13 +707,13 @@ void SdDrawDocument::NewOrLoadCompleted( SdPage* pPage, SdStyleSheetPool* pSPool SfxStyleSheet* pTitleSheet = (SfxStyleSheet*)pSPool->GetTitleSheet(aName); - SdrObject* pObj = 0; - rPresentationShapes.seekShape(0); - // Now look for title and outline text objects, then make those objects // listeners. - while( (pObj = rPresentationShapes.getNextShape()) ) + for( ShapeList::const_iterator aIter (rPresentationShapes.cbegin() ); + aIter != rPresentationShapes.cend(); ++aIter ) { + SdrObject* pObj = *aIter; + if (pObj->GetObjInventor() == SdrInventor) { OutlinerParaObject* pOPO = pObj->GetOutlinerParaObject(); diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index 6954913a18a3..6c90cacdb240 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -755,6 +755,7 @@ void SdDrawDocument::StartOnlineSpelling(sal_Bool bForceSpelling) pOutl->SetDefaultLanguage( meLanguage ); mpOnlineSpellingList = new ShapeList; + maShapeListIterator = mpOnlineSpellingList->cend(); sal_uInt16 nPage; for ( nPage = 0; nPage < GetPageCount(); nPage++ ) @@ -769,7 +770,7 @@ void SdDrawDocument::StartOnlineSpelling(sal_Bool bForceSpelling) FillOnlineSpellingList((SdPage*) GetMasterPage(nPage)); } - mpOnlineSpellingList->seekShape(0); + maShapeListIterator = mpOnlineSpellingList->cbegin(); mpOnlineSpellingTimer = new Timer(); mpOnlineSpellingTimer->SetTimeoutHdl( LINK(this, SdDrawDocument, OnlineSpellingHdl) ); mpOnlineSpellingTimer->SetTimeout(250); @@ -823,11 +824,14 @@ void SdDrawDocument::FillOnlineSpellingList(SdPage* pPage) // OnlineSpelling in the background IMPL_LINK_NOARG(SdDrawDocument, OnlineSpellingHdl) { + bool bHasMore = maShapeListIterator != mpOnlineSpellingList->cend(); + if (mpOnlineSpellingList!=NULL - && ( !mbOnlineSpell || mpOnlineSpellingList->hasMore())) + && ( !mbOnlineSpell || bHasMore)) { // Spell next object - SdrObject* pObj = mpOnlineSpellingList->getNextShape(); + SdrObject* pObj = *maShapeListIterator; + ++maShapeListIterator; if (pObj) { diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 5f7041791f95..ed7e0223dda4 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -155,11 +155,11 @@ SdrObject* SdPage::GetPresObj(PresObjKind eObjKind, int nIndex, bool bFuzzySearc // first sort all matching shapes with z-order std::vector< SdrObject* > aMatches; - SdrObject* pObj = 0; - maPresentationShapeList.seekShape(0); - - while( (pObj = maPresentationShapeList.getNextShape()) ) + for( ShapeList::const_iterator aIter( maPresentationShapeList.cbegin() ); + aIter != maPresentationShapeList.cend(); ++aIter ) { + SdrObject* pObj = *aIter; + SdAnimationInfo* pInfo = SdDrawDocument::GetShapeUserData(*pObj); if( pInfo ) { @@ -1576,27 +1576,38 @@ void SdPage::SetAutoLayout(AutoLayout eLayout, sal_Bool bInit, sal_Bool bCreate // now delete all empty presentation objects that are no longer used by the new layout if( bInit ) { - SdrObject* pObj = 0; - maPresentationShapeList.seekShape(0); + std::list< SdrObject* > aRemoveList; - while( (pObj = maPresentationShapeList.getNextShape()) ) + for( ShapeList::const_iterator aIter = maPresentationShapeList.cbegin(); + aIter != maPresentationShapeList.cend(); ++aIter ) { + SdrObject* pObj = *aIter; + if( aUsedPresentationObjects.count(pObj) == 0 ) { if( pObj->IsEmptyPresObj() ) { - if( bUndo ) - pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); - - RemoveObject( pObj->GetOrdNum() ); - - if( !bUndo ) - SdrObject::Free( pObj ); + // remove the object now would invalidate the iterator and lead to a seg fault + aRemoveList.push_back(pObj); } /* #i108541# keep non empty pres obj as pres obj even if they are not part of the current layout */ } } + + for( std::list<SdrObject*>::iterator aIter = aRemoveList.begin(); + aIter != aRemoveList.end(); ++aIter ) + { + SdrObject* pObj = *aIter; + + if( bUndo ) + pUndoManager->AddUndoAction(pModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + + RemoveObject( pObj->GetOrdNum() ); + + if( !bUndo ) + SdrObject::Free( pObj ); + } } } diff --git a/sd/source/core/sdpage2.cxx b/sd/source/core/sdpage2.cxx index 1b4f9ab7fec9..ff88f061e66c 100644 --- a/sd/source/core/sdpage2.cxx +++ b/sd/source/core/sdpage2.cxx @@ -379,10 +379,8 @@ SdPage::SdPage(const SdPage& rSrcPage) mePageKind = rSrcPage.mePageKind; meAutoLayout = rSrcPage.meAutoLayout; - // use shape list directly to preserve constness of rSrcPage - const std::list< SdrObject* >& rShapeList = rSrcPage.maPresentationShapeList.getList(); - for( std::list< SdrObject* >::const_iterator aIter = rShapeList.begin(); - aIter != rShapeList.end(); ++aIter ) + for( ShapeList::const_iterator aIter( rSrcPage.maPresentationShapeList.cbegin() ); + aIter != rSrcPage.maPresentationShapeList.cend(); ++aIter ) { SdrObject* pObj = *aIter; InsertPresObj(GetObj(pObj->GetOrdNum()), rSrcPage.GetPresObjKind(pObj)); diff --git a/sd/source/core/shapelist.cxx b/sd/source/core/shapelist.cxx index a265e9c93eff..c3aedde725bc 100644 --- a/sd/source/core/shapelist.cxx +++ b/sd/source/core/shapelist.cxx @@ -26,7 +26,6 @@ using namespace sd; ShapeList::ShapeList() { - maIter = maShapeList.end(); } ShapeList::~ShapeList() @@ -55,14 +54,9 @@ SdrObject* ShapeList::removeShape( SdrObject& rObject ) ListImpl::iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), &rObject ) ); if( aIter != maShapeList.end() ) { - bool bIterErased = aIter == maIter; - (*aIter)->RemoveObjectUser(*this); aIter = maShapeList.erase( aIter ); - if( bIterErased ) - maIter = aIter; - if( aIter != maShapeList.end() ) return (*aIter); } @@ -83,8 +77,6 @@ void ShapeList::clear() ListImpl::iterator aIter( aShapeList.begin() ); while( aIter != aShapeList.end() ) (*aIter++)->RemoveObjectUser(*this); - - maIter = aShapeList.end(); } /** returns true if this list is empty */ @@ -99,46 +91,27 @@ bool ShapeList::hasShape( SdrObject& rObject ) const return std::find( maShapeList.begin(), maShapeList.end(), &rObject ) != maShapeList.end(); } -void ShapeList::ObjectInDestruction(const SdrObject& rObject) +ShapeList::const_iterator ShapeList::cbegin() const { - ListImpl::iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), &rObject ) ); - if( aIter != maShapeList.end() ) - { - bool bIterErased = aIter == maIter; - - aIter = maShapeList.erase( aIter ); + return maShapeList.begin(); +} - if( bIterErased ) - maIter = aIter; - } - else - { - OSL_FAIL("sd::ShapeList::ObjectInDestruction(), got a call from an unknown friend!"); - } +ShapeList::const_iterator ShapeList::cend() const +{ + return maShapeList.end(); } -SdrObject* ShapeList::getNextShape() +void ShapeList::ObjectInDestruction(const SdrObject& rObject) { - if( maIter != maShapeList.end() ) + ListImpl::iterator aIter( std::find( maShapeList.begin(), maShapeList.end(), &rObject ) ); + if( aIter != maShapeList.end() ) { - return (*maIter++); + maShapeList.erase( aIter ); } else { - return 0; + OSL_FAIL("sd::ShapeList::ObjectInDestruction(), got a call from an unknown friend!"); } } -void ShapeList::seekShape( sal_uInt32 nIndex ) -{ - maIter = maShapeList.begin(); - while( nIndex-- && (maIter != maShapeList.end()) ) - maIter++; -} - -bool ShapeList::hasMore() const -{ - return maIter != maShapeList.end(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx index fe0f1dd598d8..8ad0ce36ce80 100644 --- a/sd/source/ui/view/drviews1.cxx +++ b/sd/source/ui/view/drviews1.cxx @@ -1059,11 +1059,12 @@ sal_Bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage) { // set pages for all available handout presentation objects sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList(); - SdrObject* pObj = 0; - rShapeList.seekShape(0); - while( (pObj = rShapeList.getNextShape()) ) + for( ShapeList::const_iterator aIter( rShapeList.cbegin() ); + aIter != rShapeList.cend(); ++aIter ) { + SdrObject* pObj = *aIter; + if( pMaster->GetPresObjKind(pObj) == PRESOBJ_HANDOUT ) { // #i105146# We want no content to be displayed for PK_HANDOUT, diff --git a/sd/source/ui/view/sdview5.cxx b/sd/source/ui/view/sdview5.cxx index 9023d028ad49..3cb082970873 100644 --- a/sd/source/ui/view/sdview5.cxx +++ b/sd/source/ui/view/sdview5.cxx @@ -101,9 +101,10 @@ SdrObject* View::GetEmptyPresentationObject( PresObjKind eKind ) // last try to find empty pres obj of multiple type if( !pEmptyObj ) { - const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList(); + ShapeList& rShapeList = pPage->GetPresentationShapeList(); - for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter ) + for( ShapeList::const_iterator iter( rShapeList.cbegin() ); + iter != rShapeList.cend(); ++iter ) { if( (*iter)->IsEmptyPresObj() && implIsMultiPresObj(pPage->GetPresObjKind(*iter)) ) { diff --git a/sd/source/ui/view/viewoverlaymanager.cxx b/sd/source/ui/view/viewoverlaymanager.cxx index e834999a5350..f5c6bc688d22 100644 --- a/sd/source/ui/view/viewoverlaymanager.cxx +++ b/sd/source/ui/view/viewoverlaymanager.cxx @@ -546,9 +546,10 @@ bool ViewOverlayManager::CreateTags() if( pPage && !pPage->IsMasterPage() && (pPage->GetPageKind() == PK_STANDARD) ) { - const std::list< SdrObject* >& rShapes = pPage->GetPresentationShapeList().getList(); + ShapeList& rShapeList = pPage->GetPresentationShapeList(); - for( std::list< SdrObject* >::const_iterator iter( rShapes.begin() ); iter != rShapes.end(); ++iter ) + for( ShapeList::const_iterator iter( rShapeList.cbegin() ); + iter != rShapeList.cend(); ++iter ) { if( (*iter)->IsEmptyPresObj() && ((*iter)->GetObjIdentifier() == OBJ_OUTLINETEXT) && (mrBase.GetDrawView()->GetTextEditObject() != (*iter)) ) { |