Package net.sf.mpxj

Examples of net.sf.mpxj.GroupClause


            if (offset + 47 > groupVarData.length)
            {
               break;
            }

            GroupClause clause = new GroupClause();
            group.addGroupClause(clause);

            int fieldID = MPPUtility.getInt(groupVarData, offset);
            FieldType type = FieldTypeUtility.getInstance(fieldID);
            clause.setField(type);

            // from byte 0 2 byte short int - field type
            // byte 3 - entity type 0b/0c
            // 4th byte in clause is 1=asc 0=desc
            // offset+8=font index, from font bases
            // offset+12=color, byte
            // offset+13=pattern, byte           

            boolean ascending = (MPPUtility.getByte(groupVarData, offset + 4) != 0);
            clause.setAscending(ascending);

            int fontIndex = MPPUtility.getByte(groupVarData, offset + 8);
            FontBase fontBase = fontBases.get(Integer.valueOf(fontIndex));

            int style = MPPUtility.getByte(groupVarData, offset + 9);
            boolean bold = ((style & 0x01) != 0);
            boolean italic = ((style & 0x02) != 0);
            boolean underline = ((style & 0x04) != 0);

            int fontColorIndex = MPPUtility.getByte(groupVarData, offset + 10);
            ColorType fontColor = ColorType.getInstance(fontColorIndex);

            FontStyle fontStyle = new FontStyle(fontBase, italic, bold, underline, false, fontColor.getColor(), null, BackgroundPattern.SOLID);
            clause.setFont(fontStyle);

            int colorIndex = MPPUtility.getByte(groupVarData, offset + 12);
            ColorType color = ColorType.getInstance(colorIndex);
            clause.setCellBackgroundColor(color.getColor());
            clause.setPattern(BackgroundPattern.getInstance(MPPUtility.getByte(groupVarData, offset + 13) & 0x0F));

            // offset+14=group on
            int groupOn = MPPUtility.getShort(groupVarData, offset + 14);
            clause.setGroupOn(groupOn);
            // offset+24=start at
            // offset+40=group interval

            Object startAt = null;
            Object groupInterval = null;

            if (type != null)
            {
               switch (type.getDataType())
               {
                  case DURATION :
                  case NUMERIC :
                  case CURRENCY :
                  {
                     startAt = Double.valueOf(MPPUtility.getDouble(groupVarData, offset + 24));
                     groupInterval = Double.valueOf(MPPUtility.getDouble(groupVarData, offset + 40));
                     break;
                  }

                  case PERCENTAGE :
                  {
                     startAt = Integer.valueOf(MPPUtility.getInt(groupVarData, offset + 24));
                     groupInterval = Integer.valueOf(MPPUtility.getInt(groupVarData, offset + 40));
                     break;
                  }

                  case BOOLEAN :
                  {
                     startAt = (MPPUtility.getShort(groupVarData, offset + 24) == 1 ? Boolean.TRUE : Boolean.FALSE);
                     break;
                  }

                  case DATE :
                  {
                     startAt = MPPUtility.getTimestamp(groupVarData, offset + 24);
                     groupInterval = Integer.valueOf(MPPUtility.getInt(groupVarData, offset + 40));
                     break;
                  }

                  default :
                  {
                     break;
                  }
               }
            }
            clause.setStartAt(startAt);
            clause.setGroupInterval(groupInterval);

            offset += 48;
         }

         //System.out.println(group);
View Full Code Here


            }

            //System.out.println("Clause " + clauseIndex);
            //System.out.println(MPPUtility.hexdump(groupVarData, offset, 71, false, 16, ""));

            GroupClause clause = new GroupClause();
            group.addGroupClause(clause);

            int fieldID = MPPUtility.getInt(groupVarData, offset);
            FieldType type = FieldTypeUtility.getInstance14(fieldID);
            clause.setField(type);

            // from byte 0 2 byte short int - field type
            // byte 3 - entity type 0b/0c
            // 4th byte in clause is 1=asc 0=desc
            // offset+8=font index, from font bases
            // offset+12=color, byte
            // offset+13=pattern, byte           

            boolean ascending = (MPPUtility.getByte(groupVarData, offset + 4) != 0);
            clause.setAscending(ascending);

            int fontIndex = MPPUtility.getByte(groupVarData, offset + 8);
            FontBase fontBase = fontBases.get(Integer.valueOf(fontIndex));

            int style = MPPUtility.getByte(groupVarData, offset + 9);
            boolean bold = ((style & 0x01) != 0);
            boolean italic = ((style & 0x02) != 0);
            boolean underline = ((style & 0x04) != 0);
            Color fontColor = MPPUtility.getColor(groupVarData, offset + 10);

            FontStyle fontStyle = new FontStyle(fontBase, italic, bold, underline, false, fontColor, null, BackgroundPattern.SOLID);
            clause.setFont(fontStyle);
            clause.setCellBackgroundColor(MPPUtility.getColor(groupVarData, offset + 22));
            clause.setPattern(BackgroundPattern.getInstance(MPPUtility.getByte(groupVarData, offset + 34) & 0x0F));

            // offset+14=group on
            int groupOn = MPPUtility.getByte(groupVarData, offset + 38);
            clause.setGroupOn(groupOn);
            // offset+24=start at
            // offset+40=group interval

            Object startAt = null;
            Object groupInterval = null;
            if (type != null)
            {
               switch (type.getDataType())
               {
                  case DURATION :
                  case NUMERIC :
                  case CURRENCY :
                  {
                     startAt = Double.valueOf(MPPUtility.getDouble(groupVarData, offset + 47));
                     groupInterval = Double.valueOf(MPPUtility.getDouble(groupVarData, offset + 63));
                     break;
                  }

                  case PERCENTAGE :
                  {
                     startAt = Integer.valueOf(MPPUtility.getInt(groupVarData, offset + 47));
                     groupInterval = Integer.valueOf(MPPUtility.getInt(groupVarData, offset + 63));
                     break;
                  }

                  case BOOLEAN :
                  {
                     startAt = (MPPUtility.getShort(groupVarData, offset + 47) == 1 ? Boolean.TRUE : Boolean.FALSE);
                     break;
                  }

                  case DATE :
                  {
                     startAt = MPPUtility.getTimestamp(groupVarData, offset + 47);
                     groupInterval = Integer.valueOf(MPPUtility.getInt(groupVarData, offset + 63));
                     break;
                  }

                  default :
                  {
                     break;
                  }
               }
            }

            clause.setStartAt(startAt);
            clause.setGroupInterval(groupInterval);

            offset += 71;
         }

         //System.out.println(group);
View Full Code Here

TOP

Related Classes of net.sf.mpxj.GroupClause

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.