1 /* AbiWord
2  * Copyright (C) 1998 AbiSource, Inc.
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 /*****************************************************************
21 ******************************************************************
22 ** Only one of these is created by the application.
23 ******************************************************************
24 *****************************************************************/
25 
26 #ifndef AP_UNIXAPP_H
27 #define AP_UNIXAPP_H
28 
29 #include "ut_types.h"
30 #include "ut_bytebuf.h"
31 #include "ap_App.h"
32 #include "ap_UnixPrefs.h"
33 #include "ap_UnixClipboard.h"
34 #include "pt_Types.h"
35 
36 //#define LOGFILE
37 /* Define if your user name is msevior */
38 /* #undef LOGFILE */
39 
40 #ifdef LOGFILE
41 FILE * getlogfile(void);
42 #endif
43 
44 class XAP_StringSet;
45 class AV_View;
46 class GR_Image;
47 class AP_Args;
48 class AP_BuiltinStringSet;
49 class AP_DiskStringSet;
50 
51 class ABI_EXPORT AP_UnixApp : public AP_App
52 {
53 public:
54 	AP_UnixApp(const char * szAppName);
55 	virtual ~AP_UnixApp();
56 
57 	virtual bool					initialize(bool has_display);
58 	virtual XAP_Frame *				newFrame(void);
59 	virtual bool					forgetFrame(XAP_Frame * pFrame);
60 	virtual GR_Graphics *           newDefaultScreenGraphics() const;
61 
62 	virtual bool					shutdown(void);
63 	virtual bool					getPrefsValueDirectory(bool bAppSpecific,
64 									       const gchar * szKey, const gchar ** pszValue) const;
65 	virtual const XAP_StringSet *	                getStringSet(void) const;
66 	virtual const char *			        getAbiSuiteAppDir(void) const;
67 	virtual const std::string&			getAbiSuiteAppUIDir(void) const;
68 
69 	virtual void					copyToClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard = true);
70 	virtual void					pasteFromClipboard(PD_DocumentRange * pDocRange, bool bUseClipboard, bool bHonorFormatting = true);
71 	virtual bool					canPasteFromClipboard(void);
addClipboardFmt(const char * szFormat)72 	virtual void					addClipboardFmt (const char * szFormat) {m_pClipboard->addFormat(szFormat);}
deleteClipboardFmt(const char * szFormat)73 	virtual void					deleteClipboardFmt (const char * szFormat) {m_pClipboard->deleteFormat(szFormat);}
74 
75 	virtual void					setSelectionStatus(AV_View * pView);
76 
77 	/*!
78 	  Sets the view selection
79 	  \param pView The veiw the selection view is to be set to.
80 	*/
setViewSelection(AV_View * pView)81 	inline virtual void                             setViewSelection( AV_View * pView)
82 	{ m_pViewSelection = pView; }
83 
84 	/*!
85 	  Gets the View Selection
86 	  \return The View currently selected.
87 	*/
getViewSelection(void)88 	inline virtual AV_View *                        getViewSelection(void)
89 	{ return m_pViewSelection; }
90 	virtual void					clearSelection(void);
91 	virtual bool					getCurrentSelection(const char** formatList,
92 														void ** ppData, UT_uint32 * pLen,
93 														const char **pszFormatFound);
94 	virtual void					cacheCurrentSelection(AV_View *);
95 
96 	static int main (const char * szAppName, int argc, char ** argv);
97 
98 	void							catchSignals(int sig_num) ABI_NORETURN;
99 	void loadAllPlugins ();
100 
101 	virtual void errorMsgBadArg(const char *msg);
102 	virtual void errorMsgBadFile(XAP_Frame * pFrame, const char * file,
103 								 UT_Error error);
104 	virtual bool doWindowlessArgs (const AP_Args *, bool & bSuccess);
105 	bool makePngPreview(const char * pszInFile,const char * pszPNGFile,  UT_sint32 iWidth, UT_sint32 iHeight);
106 	AP_DiskStringSet * loadStringsFromDisk(const char 		   * szStringSet,
107 										   AP_BuiltinStringSet * pFallbackStringSet);
108 
getClipboard()109 	virtual XAP_UnixClipboard * getClipboard () { return m_pClipboard; }
110 
111 protected:	// JCA: Why in the hell we have so many (any) protected
112 		// variables?
113 	XAP_StringSet *			m_pStringSet;
114 	AP_UnixClipboard *		m_pClipboard;
115 
116 	bool					m_bHasSelection;
117 	bool					m_bSelectionInFlux;
118 	bool					m_cacheDeferClear;
119 	AV_View *				m_pViewSelection;
120 	AV_View *				m_cacheSelectionView;
121 	XAP_Frame *				m_pFrameSelection;
122 	UT_ByteBuf				m_selectionByteBuf;
123 	PD_DocumentRange		m_cacheDocumentRangeOfSelection;
124 };
125 
126 // HACK What follows is an ugly hack. It is neccessitated by the
127 // C/C++ conflict over pointers to member functions. It is,
128 // however, what the C++ FAQ reccommends.
129 
130 void signalWrapper(int);
131 
132 #endif /* AP_UNIXAPP_H */
133