View | Details | Raw Unified | Return to issue 8644
Collapse All | Expand All

(-)attr/format.cxx (+41 lines)
Lines 65-70 Link Here
65
65
66
#pragma hdrstop
66
#pragma hdrstop
67
67
68
#include <map>
69
68
#ifndef _HINTIDS_HXX
70
#ifndef _HINTIDS_HXX
69
#include <hintids.hxx> 			// fuer RES_..
71
#include <hintids.hxx> 			// fuer RES_..
70
#endif
72
#endif
Lines 533-548 Link Here
533
	return bRet;
535
	return bRet;
534
}
536
}
535
537
538
extern std::map<const void*, std::pair<const void*, int> > aGlobalCache;
536
539
537
BOOL SwFmt::SetAttr( const SfxItemSet& rSet )
540
BOOL SwFmt::SetAttr( const SfxItemSet& rSet )
538
{
541
{
539
	if( !rSet.Count() )
542
	if( !rSet.Count() )
540
		return FALSE;
543
		return FALSE;
541
544
545
    typedef std::map<const void*, std::pair<const void*, int> >
546
            ::const_iterator myciter;
547
548
    for (myciter aIter = aGlobalCache.begin();
549
        aIter != aGlobalCache.end(); ++aIter)
550
    {
551
        if ((this == aIter->first) && (!IsInCache()))
552
        {
553
            const std::pair<const void *, int> &rTest = aIter->second;
554
            ASSERT(rTest.first == 0, 
555
                "This fmt doesn't know that it's in the cache");
556
        }
557
    }
558
542
	if ( IsInCache() )
559
	if ( IsInCache() )
543
	{
560
	{
544
		SwFrm::GetCache().Delete( this );
561
		SwFrm::GetCache().Delete( this );
545
		SetInCache( FALSE );
562
		SetInCache( FALSE );
563
564
        for (aIter = aGlobalCache.begin(); aIter != aGlobalCache.end(); ++aIter)
565
        {
566
            if (this == aIter->first)
567
            {
568
                    const std::pair<const void *, int> &rTest = aIter->second;
569
                    ASSERT(rTest.first == 0, 
570
                        "Despite being removed this fmt is still in the cache");
571
            }
572
        }
573
546
	}
574
	}
547
	SetInSwFntCache( FALSE );
575
	SetInSwFntCache( FALSE );
548
576
Lines 636-641 Link Here
636
		SwAttrSetChg aChgOld( aSet, aOld );
664
		SwAttrSetChg aChgOld( aSet, aOld );
637
		SwAttrSetChg aChgNew( aSet, aNew );
665
		SwAttrSetChg aChgNew( aSet, aNew );
638
		Modify( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
666
		Modify( &aChgOld, &aChgNew );		// alle veraenderten werden verschickt
667
668
        typedef std::map<const void*, std::pair<const void*, int> >
669
            ::iterator myiter;
670
671
        for (myiter aIter = aGlobalCache.begin(); 
672
                aIter != aGlobalCache.end(); ++aIter)
673
            {
674
                std::pair<const void *, int> &rTest = aIter->second;
675
                if (rTest.first == &aSet)
676
                {
677
                    ASSERT(!(rTest.second & 0x02), "still using changed cached attrset!");
678
                }
679
            }
639
	}
680
	}
640
	return aNew.Count();
681
	return aNew.Count();
641
}
682
}
(-)attr/swatrset.cxx (+34 lines)
Lines 67-72 Link Here
67
67
68
#include <hintids.hxx>
68
#include <hintids.hxx>
69
69
70
#include <map>
71
70
#ifndef _SVX_COLRITEM_HXX //autogen
72
#ifndef _SVX_COLRITEM_HXX //autogen
71
#include <svx/colritem.hxx>
73
#include <svx/colritem.hxx>
72
#endif
74
#endif
Lines 232-242 Link Here
232
	return pNew ? pNew->Count() : ( pOld ? pOld->Count() : 0 );
234
	return pNew ? pNew->Count() : ( pOld ? pOld->Count() : 0 );
233
}
235
}
234
236
237
extern std::map<const void*, std::pair<const void*, int> > aGlobalCache;
235
238
236
	// Notification-Callback
239
	// Notification-Callback
237
void  SwAttrSet::Changed( const SfxPoolItem& rOld,
240
void  SwAttrSet::Changed( const SfxPoolItem& rOld,
238
								const SfxPoolItem& rNew )
241
								const SfxPoolItem& rNew )
239
{
242
{
243
#if 1
244
    ASSERT(rOld.Which() == rNew.Which(), "impossible surely");
245
    switch (rOld.Which())
246
    {
247
        case RES_OBJECTDYING:
248
        case RES_FMT_CHG:
249
        case RES_ATTRSET_CHG:
250
        case RES_UL_SPACE:
251
        case RES_LR_SPACE:
252
        case RES_SHADOW:
253
        case RES_FRM_SIZE:
254
        case RES_KEEP:
255
        case RES_BREAK:
256
        case RES_BOX:
257
            {
258
                typedef std::map<const void*, std::pair<const void*, int> >
259
                    ::iterator myiter;
260
                
261
                for (myiter aIter = aGlobalCache.begin(); 
262
                    aIter != aGlobalCache.end(); ++aIter)
263
                {
264
                    std::pair<const void *, int> &rTest = aIter->second;
265
                    if (rTest.first == this)
266
                        rTest.second |= 0x2;    //Mark this attr as now invalid
267
                }
268
            }
269
            break;
270
        default:
271
            break;
272
    }
273
#endif
240
	if( pOldSet )
274
	if( pOldSet )
241
		pOldSet->PutChgd( rOld );
275
		pOldSet->PutChgd( rOld );
242
276
(-)bastyp/swcache.cxx (-1 / +14 lines)
Lines 65-70 Link Here
65
65
66
#pragma hdrstop
66
#pragma hdrstop
67
67
68
#include <map>
69
68
#ifndef _TOOLS_DEBUG_HXX
70
#ifndef _TOOLS_DEBUG_HXX
69
#include <tools/debug.hxx>
71
#include <tools/debug.hxx>
70
#endif
72
#endif
Lines 473-481 Link Here
473
*/
475
*/
474
476
475
477
476
478
extern std::map<const void*, std::pair<const void*, int> > aGlobalCache;
479
typedef std::map<const void*, std::pair<const void*, int> >::iterator myiter;
477
void SwCache::Delete( const void *pOwner )
480
void SwCache::Delete( const void *pOwner )
478
{
481
{
482
    for (myiter aIter = aGlobalCache.begin(); aIter != aGlobalCache.end(); 
483
        ++aIter)
484
    {
485
        if (aIter->first == pOwner)
486
        {
487
            std::pair<const void *, int> &rTest = aIter->second;
488
            rTest.second = rTest.second & 0x1; //Mark cache entry as deleted
489
        }
490
    }
491
479
	INCREMENT( nDelete );
492
	INCREMENT( nDelete );
480
	SwCacheObj *pObj;
493
	SwCacheObj *pObj;
481
	if ( 0 != (pObj = Get( pOwner, BOOL(FALSE) )) )
494
	if ( 0 != (pObj = Get( pOwner, BOOL(FALSE) )) )
(-)inc/frmtool.hxx (-1 / +2 lines)
Lines 308-314 Link Here
308
	inline const SwAttrSet		&GetAttrSet() const { return rAttrSet;	}
308
	inline const SwAttrSet		&GetAttrSet() const { return rAttrSet;	}
309
	inline const SvxULSpaceItem &GetULSpace() const { return rUL;		}
309
	inline const SvxULSpaceItem &GetULSpace() const { return rUL;		}
310
	inline const SvxLRSpaceItem &GetLRSpace() const { return rLR;	  	}
310
	inline const SvxLRSpaceItem &GetLRSpace() const { return rLR;	  	}
311
	inline const SvxBoxItem 	&GetBox()	  const { return rBox;		}
311
//	inline const SvxBoxItem 	&GetBox()	  const { return rBox;		}
312
	const SvxBoxItem 	&GetBox()	  const;
312
	inline const SvxShadowItem	&GetShadow()  const { return rShadow;	}
313
	inline const SvxShadowItem	&GetShadow()  const { return rShadow;	}
313
314
314
	inline USHORT CalcTopLine() const;
315
	inline USHORT CalcTopLine() const;
(-)layout/frmtool.cxx (+31 lines)
Lines 65-70 Link Here
65
65
66
#pragma hdrstop
66
#pragma hdrstop
67
67
68
#include <map>
69
68
#define ITEMID_BOXINFO      SID_ATTR_BORDER_INNER
70
#define ITEMID_BOXINFO      SID_ATTR_BORDER_INNER
69
#define ITEMID_SIZE			SID_ATTR_PAGE_SIZE
71
#define ITEMID_SIZE			SID_ATTR_PAGE_SIZE
70
#include <hintids.hxx>
72
#include <hintids.hxx>
Lines 1595-1600 Link Here
1595
|*
1597
|*
1596
|*************************************************************************/
1598
|*************************************************************************/
1597
1599
1600
std::map<const void*, std::pair<const void*, int> > aGlobalCache;
1601
1598
SwBorderAttrs::SwBorderAttrs( const SwModify *pMod, const SwFrm *pConstructor ) :
1602
SwBorderAttrs::SwBorderAttrs( const SwModify *pMod, const SwFrm *pConstructor ) :
1599
	SwCacheObj( pMod ),
1603
	SwCacheObj( pMod ),
1600
	rAttrSet( pConstructor->IsCntntFrm()
1604
	rAttrSet( pConstructor->IsCntntFrm()
Lines 1616-1625 Link Here
1616
	bCacheGetLine = bCachedGetTopLine = bCachedGetBottomLine = FALSE;
1620
	bCacheGetLine = bCachedGetTopLine = bCachedGetBottomLine = FALSE;
1617
1621
1618
	bBorderDist = 0 != (pConstructor->GetType() & (FRM_CELL));
1622
	bBorderDist = 0 != (pConstructor->GetType() & (FRM_CELL));
1623
1624
    std::pair<const void *, int> aTest(&rAttrSet, 0);
1625
    aGlobalCache[GetOwner()] = aTest;
1626
}
1627
1628
const SvxBoxItem &SwBorderAttrs::GetBox() const
1629
{
1630
    typedef std::map<const void*, std::pair<const void*, int> >
1631
        ::const_iterator myciter;
1632
1633
    for (myciter aIter = aGlobalCache.begin();
1634
    aIter != aGlobalCache.end(); ++aIter)
1635
    {
1636
        const std::pair<const void *, int> &rTest = aIter->second;
1637
        if ((rTest.first == &rAttrSet) && (rTest.second != 0))
1638
        {
1639
            ASSERT(!(rTest.second & 0x1), "use of deleted cache entry");
1640
            ASSERT(!(rTest.second & 0x2), "use of changed attrset");
1641
            return rAttrSet.GetBox();
1642
        }
1643
    }
1644
1645
    const SvxBoxItem *pTest = &rAttrSet.GetBox();
1646
    ASSERT(pTest == &rBox, 
1647
        "who changed my box without either cache knowing about it!");
1648
    return rBox;
1619
}
1649
}
1620
1650
1621
SwBorderAttrs::~SwBorderAttrs()
1651
SwBorderAttrs::~SwBorderAttrs()
1622
{
1652
{
1653
    aGlobalCache.erase(pOwner);
1623
	((SwModify*)pOwner)->SetInCache( FALSE );
1654
	((SwModify*)pOwner)->SetInCache( FALSE );
1624
}
1655
}
1625
1656

Return to issue 8644