1 /* AbiWord
2  * Copyright (C) 2004 Luca Padovani <lpadovan@cs.unibo.it>
3  * Copyright (C) 2005 Martin Sevior <msevior@physics.unimelb.edu.au>
4  * Copyright (C) 2005 Jean Brefort <jean.brefort@normalesup.org>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
19  * USA
20  */
21 
22 #ifndef __gr_AbiGOComponentManager_h__
23 #define __gr_AbiGOComponentManager_h__
24 #include "gr_EmbedManager.h"
25 #include <goffice/component/goffice-component.h>
26 #include <goffice/component/go-component.h>
27 
28 
29 class GR_Graphics;
30 class PD_Document;
31 class AD_Document;
32 class GOComponentView;
33 class GR_AbiGOComponentItems;
34 
35 class GR_AbiGOComponentItems
36 {
37  public:
38   GR_AbiGOComponentItems();
39   virtual ~GR_AbiGOComponentItems();
40   UT_uint32 m_iAPI;
41   bool m_bHasSnapshot;
42 };
43 
44 class GR_GOComponentManager : public GR_EmbedManager
45 {
46 public:
47     GR_GOComponentManager(GR_Graphics * pG);
48     virtual ~GR_GOComponentManager();
49     virtual GR_EmbedManager *  create(GR_Graphics * pG);
50     virtual const char *   getObjectType(void) const;
51     virtual void           initialize(void);
52     virtual UT_sint32      makeEmbedView(AD_Document * pDoc, UT_uint32  api, const char * szDataID) ;
53     virtual void           setColor(UT_sint32 uid, UT_RGBColor c);
54     virtual UT_sint32      getWidth(UT_sint32 uid);
55     virtual UT_sint32      getAscent(UT_sint32 uid) ;
56     virtual UT_sint32      getDescent(UT_sint32 uid) ;
57     virtual void           loadEmbedData(UT_sint32 uid);
58     virtual void           setDefaultFontSize(UT_sint32 uid, UT_sint32 iSize);
59     virtual void           render(UT_sint32 uid, UT_Rect & rec);
60     virtual void           releaseEmbedView(UT_sint32 uid);
61     virtual void           initializeEmbedView(UT_sint32 uid);
62     virtual void           makeSnapShot(UT_sint32 uid, UT_Rect & rec);
63     virtual bool           isDefault(void);
64     virtual bool           modify(UT_sint32 uid);
65     virtual bool           convert(UT_uint32 iConv, UT_ByteBuf & From, UT_ByteBuf & To);
66     virtual bool           isEdittable(UT_sint32 uid);
67     virtual bool           isResizeable(UT_sint32 uid);
68 	virtual void		   setRun (UT_sint32 uid, fp_Run * run);
69 	virtual void		   updateData(UT_sint32 uid, UT_sint32 api);
70 	virtual bool           setFont(UT_sint32 uid, const GR_Font * pFont);
71 
72 private:
73     UT_sint32                              _makeGOComponentView(void);
74     UT_sint32                              _getNextUID(void);
75     UT_sint32                              m_CurrentUID;
76     UT_GenericVector<GOComponentView *>        m_vecGOComponentView;
77     UT_GenericVector<GR_AbiGOComponentItems *>    m_vecItems;
78     PD_Document *                          m_pDoc;
79 };
80 
81 // FIXME wrapper for libGNOMEOFFICEComponent object
82 class GOComponentView
83 {
84 friend class GR_GOComponentManager;
85 public:
86 	GOComponentView(GR_GOComponentManager  * pGOMan);
87 	virtual ~GOComponentView(void);
88 	void render(UT_Rect & rec);
89 	void loadBuffer(UT_ByteBuf const *sGOComponentData, const char *_mime_type);
90 	void setDefaultFontSize(UT_sint32 iSize);
91 	void modify(void);
92 	void update (void);
getComponent(void)93 	GOComponent *getComponent (void) {return component;}
IsEdittable()94 	bool IsEdittable () {return go_component_is_editable (component);}
IsResizable()95 	bool IsResizable () {return go_component_is_resizable (component);}
96 	UT_ByteBuf *getSnapShot (std::string &mime_type);
SetRun(fp_Run * pRun)97 	void SetRun (fp_Run *pRun) {m_pRun = pRun;}
98 	bool setFont(const GR_Font * pFont);
99 
100 private:
101 	GR_GOComponentManager  * m_pGOMan;
102 	GOComponent *component;
103 	std::string mime_type;
104 	GR_Image *m_Image;
105 	UT_sint32 width, ascent, descent;
106 	UT_sint32 pix_width, pix_height;
107 	GdkPixbuf *pixbuf;
108 	GdkWindowAttr attributes;
109 	fp_Run *m_pRun;
110 };
111 
112 bool AbiGOComponent_FileInsert(AV_View* v, EV_EditMethodCallData *d);
113 bool AbiGOComponent_Create(AV_View* v, EV_EditMethodCallData *d);
114 
115 #endif // __gr_AbiGOComponentManager_h__
116