Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /* ====================================================================
     Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed with
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License, Version 2.0
     (the "License"); you may not use this file except in compliance with
     the License.  You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
 
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
 package org.apache.poi.hwpf.usermodel;
 
 import java.util.List;
 
 
 
 public class OfficeDrawingsImpl implements OfficeDrawings
 {
     private final EscherRecordHolder _escherRecordHolder;
     private final FSPATable _fspaTable;
     private final byte[] _mainStream;
 
     public OfficeDrawingsImplFSPATable fspaTable,
             EscherRecordHolder escherRecordHolderbyte[] mainStream )
     {
         this. = fspaTable;
         this. = escherRecordHolder;
         this. = mainStream;
     }
 
     private EscherBlipRecord getBitmapRecordint bitmapIndex )
     {
         List<? extends EscherContainerRecordbContainers = 
                 .getBStoreContainers();
         if ( bContainers == null || bContainers.size() != 1 )
             return null;
 
         EscherContainerRecord bContainer = bContainers.get( 0 );
         final List<EscherRecordbitmapRecords = bContainer.getChildRecords();
 
         if ( bitmapRecords.size() < bitmapIndex )
             return null;
 
         EscherRecord imageRecord = bitmapRecords.getbitmapIndex - 1 );
 
         if ( imageRecord instanceof EscherBlipRecord )
         {
             return (EscherBlipRecordimageRecord;
         }
 
         if ( imageRecord instanceof EscherBSERecord )
         {
             EscherBSERecord bseRecord = (EscherBSERecordimageRecord;
 
             EscherBlipRecord blip = bseRecord.getBlipRecord();
             if ( blip != null )
             {
                 return blip;
             }
 
             if ( bseRecord.getOffset() > 0 )
             {
                 /*
                  * Blip stored in delay stream, which in a word doc, is the main
                  * stream
                  */
                 EscherRecordFactory recordFactory = new DefaultEscherRecordFactory();
                 EscherRecord record = recordFactory.createRecord,
                         bseRecord.getOffset() );
 
                 if ( record instanceof EscherBlipRecord )
                 {
                     record.fillFieldsbseRecord.getOffset(),
                             recordFactory );
                     return (EscherBlipRecordrecord;
                 }
            }
        }
        return null;
    }
            final int shapeId )
    {
        for ( EscherContainerRecord spContainer : 
                .getSpContainers() )
        {
            EscherSpRecord escherSpRecord = spContainer
                    .getChildById( (short) 0xF00A );
            if ( escherSpRecord != null
                    && escherSpRecord.getShapeId() == shapeId )
                return spContainer;
        }
        return null;
    }
    private OfficeDrawing getOfficeDrawingfinal FSPA fspa )
    {
        return new OfficeDrawing()
        {
            public HorizontalPositioning getHorizontalPositioning()
            {
                int value = getTertiaryPropertyValue(
                        ., -1 );
                switch ( value )
                {
                case 0:
                    return .;
                case 1:
                    return .;
                case 2:
                    return .;
                case 3:
                    return .;
                case 4:
                    return .;
                case 5:
                    return .;
                }
                return .;
            }
            public HorizontalRelativeElement getHorizontalRelative()
            {
                int value = getTertiaryPropertyValue(
                        ., -1 );
                switch ( value )
                {
                case 1:
                    return .;
                case 2:
                    return .;
                case 3:
                    return .;
                case 4:
                    return .;
                }
                return .;
            }
            public EscherContainerRecord getOfficeArtSpContainer()
            {
                return getEscherShapeRecordContainergetShapeId() );
            }
            public byte[] getPictureData()
            {
                EscherContainerRecord shapeDescription = getEscherShapeRecordContainergetShapeId() );
                if ( shapeDescription == null )
                    return null;
                EscherOptRecord escherOptRecord = shapeDescription
                        .getChildById. );
                if ( escherOptRecord == null )
                    return null;
                EscherSimpleProperty escherProperty = escherOptRecord
                        .lookup. );
                if ( escherProperty == null )
                    return null;
                int bitmapIndex = escherProperty.getPropertyValue();
                EscherBlipRecord escherBlipRecord = getBitmapRecordbitmapIndex );
                if ( escherBlipRecord == null )
                    return null;
                return escherBlipRecord.getPicturedata();
            }
            public int getRectangleBottom()
            {
                return fspa.getYaBottom();
            }
            public int getRectangleLeft()
            {
                return fspa.getXaLeft();
            }
            public int getRectangleRight()
            {
                return fspa.getXaRight();
            }
            public int getRectangleTop()
            {
                return fspa.getYaTop();
            }
            public int getShapeId()
            {
                return fspa.getSpid();
            }
            private int getTertiaryPropertyValueint propertyId,
                    int defaultValue )
            {
                EscherContainerRecord shapeDescription = getEscherShapeRecordContainergetShapeId() );
                if ( shapeDescription == null )
                    return defaultValue;
                EscherTertiaryOptRecord escherTertiaryOptRecord = shapeDescription
                        .getChildById. );
                if ( escherTertiaryOptRecord == null )
                    return defaultValue;
                EscherSimpleProperty escherProperty = escherTertiaryOptRecord
                        .lookuppropertyId );
                if ( escherProperty == null )
                    return defaultValue;
                int value = escherProperty.getPropertyValue();
                return value;
            }
            public VerticalPositioning getVerticalPositioning()
            {
                int value = getTertiaryPropertyValue(
                        ., -1 );
                switch ( value )
                {
                case 0:
                    return .;
                case 1:
                    return .;
                case 2:
                    return .;
                case 3:
                    return .;
                case 4:
                    return .;
                case 5:
                    return .;
                }
                return .;
            }
            public VerticalRelativeElement getVerticalRelativeElement()
            {
                int value = getTertiaryPropertyValue(
                        ., -1 );
                switch ( value )
                {
                case 1:
                    return .;
                case 2:
                    return .;
                case 3:
                    return .;
                case 4:
                    return .;
                }
                return .;
            }
            @Override
            public String toString()
            {
                return "OfficeDrawingImpl: " + fspa.toString();
            }
        };
    }
    public OfficeDrawing getOfficeDrawingAtint characterPosition )
    {
        final FSPA fspa = .getFspaFromCpcharacterPosition );
        if ( fspa == null )
            return null;
        return getOfficeDrawingfspa );
    }
    {
        List<OfficeDrawingresult = new ArrayList<OfficeDrawing>();
        for ( FSPA fspa : .getShapes() )
        {
            result.addgetOfficeDrawingfspa ) );
        }
        return Collections.unmodifiableListresult );
    }
New to GrepCode? Check out our FAQ X