• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

fg_Graphic.h

Go to the documentation of this file.
00001 /* AbiWord -- Embedded graphics for layout
00002  * Copyright (C) 1999 Matt Kimball
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 
00021 #ifndef FG_GRAPHIC_H
00022 #define FG_GRAPHIC_H
00023 
00024 #include <memory>
00025 #include <string>
00026 
00027 #include "ut_types.h"
00028 #include "ut_bytebuf.h"
00029 #include "pt_Types.h"
00030 
00031 class UT_ByteBuf;
00032 class fl_ContainerLayout;
00033 class PX_ChangeRecord_Object;
00034 class PP_AttrProp;
00035 class PD_Document;
00036 class GR_Graphics;
00037 class GR_Image;
00038 
00039 
00040 
00041 enum FGType {
00042     FGT_Unknown,
00043     FGT_Raster,
00044     FGT_Vector
00045 };
00046 
00047 class FG_Graphic;
00048 
00049 typedef std::unique_ptr<FG_Graphic> FG_GraphicPtr;
00050 typedef std::unique_ptr<const FG_Graphic> FG_ConstGraphicPtr;
00051 // Use this one is only to be used as needed: sparsely.
00052 typedef std::shared_ptr<FG_Graphic> FG_SharedGraphicPtr;
00053 
00054 //  FG_Graphic is used throughout the fmt code where we want the same code
00055 //  to handle various types of graphics interchangably.  FG_Graphic objects
00056 //  aren't persistent in the formatting, but are constructed when needed
00057 //  and removed after the operating is finished, and they act as a proxy
00058 //  for the underlying representation.
00059 class ABI_EXPORT FG_Graphic
00060 {
00061 public:
00062     static FG_GraphicPtr createFromChangeRecord(const fl_ContainerLayout *pFL,
00063                                                const PX_ChangeRecord_Object* pcro);
00064         // layout objects need a mutable FG_Graphic
00065     static FG_GraphicPtr createFromStrux(const fl_ContainerLayout *pFL);
00066 
00067     virtual ~FG_Graphic();
00068 
00069     virtual FGType      getType(void) const = 0;
00070     // return the mime type.
00071     virtual const std::string & getMimeType() const = 0;
00072 
00073     //  width and height are returned in inches not pixels.
00074     virtual double      getWidth(void) const = 0;
00075     virtual double      getHeight(void) const = 0;
00076     virtual const char * getDataId(void) const = 0;
00077 //
00078 // Return the width and height properties of the span that contains this
00079 // Image
00080 //
00081     virtual const char * getWidthProp(void) = 0;
00082     virtual const char * getHeightProp(void) = 0;
00083     virtual GR_Image *     regenerateImage(GR_Graphics * pG) = 0;
00084     virtual FG_ConstGraphicPtr   clone(void) const = 0;
00085     // return the buffer behind the image
00086     virtual const UT_ConstByteBufPtr & getBuffer() const = 0;
00087     virtual const char * createDataItem(PD_Document *pDoc, const char * szName) const = 0;
00088     // Generate an image for display in the specified graphics object
00089         // Needs to be mutable.
00090     virtual GR_Image* generateImage(GR_Graphics* pG,
00091                                    const PP_AttrProp * pSpanAP,
00092                                    UT_sint32 maxW, UT_sint32 maxH) = 0;
00093 
00094     //  Insert the object at the specified point in a document
00095     virtual UT_Error    insertIntoDocument(PD_Document* pDoc, UT_uint32 res,
00096 
00097                                            UT_uint32 iPos, const char* szName) const = 0;
00098     //  Attach the object to a strux for a background image for the strux
00099     virtual UT_Error    insertAtStrux(PD_Document* pDoc,
00100                                       UT_uint32 res,
00101                                       UT_uint32 iPos,
00102                                       PTStruxType iStruxType,
00103                                       const char* szName) const = 0;
00104 };
00105 
00106 #endif /* FG_GRAPHIC_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1