public void addInherited( final ElementStyleSheet sourceStyleSheet ) { super.addInherited( sourceStyleSheet ); setChangeTrackerHash( getChangeTrackerHash() * 31 + sourceStyleSheet.getChangeTrackerHash() ); setModificationCount( getModificationCount() * 31 + sourceStyleSheet.getModificationCount() ); }
public void addInherited( final SimpleStyleSheet sourceStyleSheet ) { super.addInherited( sourceStyleSheet ); setChangeTrackerHash( getChangeTrackerHash() * 31 + sourceStyleSheet.getChangeTrackerHash() ); setModificationCount( getModificationCount() * 31 + sourceStyleSheet.getModificationCount() ); }
public void resolveParent( final ReportElement element, final ElementStyleSheet resolverTarget ) { if ( designTime == false ) { final Section parentSection = element.getParentSection(); if ( parentSection == null ) { return; } final SimpleStyleSheet computedStyle = parentSection.getComputedStyle(); resolverTarget.addInherited( computedStyle ); } final FastStack<Section> parentSections = new FastStack<Section>(); ReportElement e = element; while ( e.getParentSection() != null ) { final Section section = e.getParentSection(); parentSections.push( section ); e = section; } while ( parentSections.isEmpty() == false ) { final Section section = parentSections.pop(); resolverTarget.addInherited( section.getStyle() ); } }
@Test public void addInherited_ElementSheet() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEveryInheritableKey( sheet, keys ); ElementStyleSheet another = new ElementStyleSheet(); another.addInherited( sheet ); for ( int i = 0; i < keys.size(); i++ ) { StyleKey key = keys.get( i ); if ( key.isInheritable() ) { Object property = another.getStyleProperty( key ); assertEquals( String.format( "Key[%d]: %s", i, key.name ), defaultValues.get( key.getValueType() ), property ); assertFalse( "addInherited() doesn't add properties as local", another.isLocalKey( key ) ); } } }
@Test public void addInherited_SimpleSheet() { List<StyleKey> keys = StyleKey.getDefinedStyleKeysList(); ElementStyleSheet sheet = new ElementStyleSheet(); setEveryInheritableKey( sheet, keys ); SimpleStyleSheet simpleStyleSheet = new SimpleStyleSheet( new ElementStyleSheet() ); sheet.addInherited( simpleStyleSheet ); for ( int i = 0; i < keys.size(); i++ ) { StyleKey key = keys.get( i ); if ( key.isInheritable() ) { Object property = sheet.getStyleProperty( key ); assertNull( "Previous values should be overriden", property ); assertFalse( "addInherited() doesn't add properties as local", sheet.isLocalKey( key ) ); } } }
subReport.getReportHeader().getStyle().addInherited( header.getStyle() ); buildLabelElementList( subReport.getReportHeader(), 5, 5, 25, 25 ); subReport2.getReportHeader().getStyle().addInherited( header.getStyle() ); buildLabelElementList( subReport2.getReportHeader(), 5, 5, 25, 25 ); assertEquals( subReport2.getReportHeader().getElementCount(), 25 );
@Test public void clone_DiscardsCacheEntries() { StyleKey key = null; List<StyleKey> keysList = StyleKey.getDefinedStyleKeysList(); for ( StyleKey styleKey : keysList ) { if ( styleKey.isInheritable() ) { key = styleKey; break; } } assumeFalse( key == null ); ElementStyleSheet parent = new ElementStyleSheet(); parent.setStyleProperty( key, valueFor( key ) ); ElementStyleSheet sheet = new ElementStyleSheet(); sheet.addInherited( parent ); assertEquals( valueFor( key ), sheet.getStyleProperty( key ) ); assertFalse( "Cached key should not be marked as local", sheet.isLocalKey( key ) ); ElementStyleSheet clone = sheet.clone(); assertNull( clone.getStyleProperty( key ) ); }