1 /* AbiWord
2  * Copyright (C) 2002 Dom Lachowicz and others
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA.
18  */
19 
20 #ifndef AP_FRAME_H
21 #define AP_FRAME_H
22 
23 #include <vector>
24 #include "ut_types.h"
25 #include "xap_Frame.h"
26 #include "ie_types.h"
27 #include "ap_FrameListener.h"
28 
29 class AV_View;
30 class ap_Scrollbar_ViewListener;
31 class ap_ViewListener;
32 class FL_DocLayout;
33 
34 class ABI_EXPORT AP_Frame : public XAP_Frame
35 {
36  public:
AP_Frame(XAP_FrameImpl * pFrameImpl)37   AP_Frame(XAP_FrameImpl *pFrameImpl) : XAP_Frame(pFrameImpl),m_bShowMargin(false),m_bWordSelections(false) {}
AP_Frame(AP_Frame * pFrame)38     AP_Frame(AP_Frame *pFrame) : XAP_Frame(static_cast<XAP_Frame *>(pFrame)),m_bShowMargin(false){}
39 	virtual ~AP_Frame();
40 
41 	virtual bool				initialize(XAP_FrameMode frameMode=XAP_NormalFrame) = 0;
42 	virtual	XAP_Frame *			buildFrame(XAP_Frame * pFrame);
43 	virtual UT_Error   			loadDocument(AD_Document* pDoc);
44 	virtual UT_Error   			loadDocument(const char * szFilename, int ieft);
45 	virtual UT_Error			loadDocument(const char * szFilename, int ieft, bool createNew);
46 	virtual UT_Error			loadDocument(GsfInput * input, int ieft);
47 	virtual UT_Error			importDocument(const char * szFilename, int ieft, bool markClean);
48 	virtual bool				initFrameData(void);
49 	virtual void				killFrameData(void);
50 	UT_uint32                   getNewZoom(XAP_Frame::tZoomType * tZoom);
51 	virtual void				setZoomPercentage(UT_uint32 iZoom);
52 	virtual UT_uint32			getZoomPercentage(void);
53 	virtual void                quickZoom(UT_uint32 iZoom);
isShowMargin(void)54 	bool                        isShowMargin(void) const
55 	{ return m_bShowMargin;}
setShowMargin(bool b)56 	void                        setShowMargin(bool b)
57 	{ m_bShowMargin = b;}
setDoWordSelections(bool b)58 	void                        setDoWordSelections(bool b)
59 	{ m_bWordSelections = b;}
getDoWordSelections(void)60 	bool                        getDoWordSelections(void) const
61 	{ return m_bWordSelections;}
62 
63 	UT_sint32					registerListener(AP_FrameListener* pListener);
64 	void						unregisterListener(UT_sint32 iListenerId);
65 
66  protected:
67 
68 	UT_Error _loadDocument(const char * szFilename, IEFileType ieft, bool createNew);
69 	UT_Error _loadDocument(GsfInput * input, IEFileType ieft);
70 	virtual UT_Error _importDocument(const char * szFilename, int ieft, bool markClean);
71 	UT_Error _replaceDocument(AD_Document * pDoc);
72 	virtual UT_Error _showDocument(UT_uint32 iZoom = 100);
73 
74 	// helper methods for _showDocument
75 	virtual bool _createViewGraphics(GR_Graphics *& pG, UT_uint32 iZoom) = 0;
76 	virtual void _replaceView(GR_Graphics * pG, FL_DocLayout *pDocLayout,
77 			  AV_View *pView, AV_ScrollObj * pScrollObj,
78 			  ap_ViewListener *pViewListener, AD_Document *pOldDoc,
79 			  ap_Scrollbar_ViewListener *pScrollbarViewListener,
80 			  AV_ListenerId lid, AV_ListenerId lidScrollbarViewListener,
81 			  UT_uint32 iZoom);
82 	virtual bool _createScrollBarListeners(AV_View * pView, AV_ScrollObj *& pScrollObj,
83 				       ap_ViewListener *& pViewListener,
84 				       ap_Scrollbar_ViewListener *& pScrollbarViewListener,
85 				       AV_ListenerId &lid,
86 				       AV_ListenerId &lidScrollbarViewListener) = 0;
87 	virtual void _bindToolbars(AV_View *pView) = 0;
88 	virtual void _setViewFocus(AV_View *pView) = 0;
89 
90 	// helper methods for helper methods for _showDocument (meta-helper-methods?) :-)
91 	virtual UT_sint32 _getDocumentAreaWidth() = 0;
92 	virtual UT_sint32 _getDocumentAreaHeight() = 0;
93 
94 	void _signal(AP_FrameSignal sig);
95 
96  private:
97 	bool    m_bShowMargin;
98 	bool    m_bWordSelections;
99 	std::vector<AP_FrameListener*> m_listeners;
100 };
101 #endif // AP_FRAME_H
102