xref: /aoo41x/main/sc/inc/tablink.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef SC_TABLINK_HXX
29*cdf0e10cSrcweir #define SC_TABLINK_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "scdllapi.h"
32*cdf0e10cSrcweir #include "refreshtimer.hxx"
33*cdf0e10cSrcweir #include <sfx2/lnkbase.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir #include <sfx2/objsh.hxx>
36*cdf0e10cSrcweir //REMOVE	#ifndef SO2_DECL_SVEMBEDDEDOBJECT_DEFINED
37*cdf0e10cSrcweir //REMOVE	#define SO2_DECL_SVEMBEDDEDOBJECT_DEFINED
38*cdf0e10cSrcweir //REMOVE	SO2_DECL_REF(SvEmbeddedObject)
39*cdf0e10cSrcweir //REMOVE	#endif
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir class ScDocShell;
42*cdf0e10cSrcweir struct TableLink_Impl;
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir class ScTableLink : public ::sfx2::SvBaseLink, public ScRefreshTimer
45*cdf0e10cSrcweir {
46*cdf0e10cSrcweir private:
47*cdf0e10cSrcweir     TableLink_Impl* pImpl;
48*cdf0e10cSrcweir     String          aFileName;
49*cdf0e10cSrcweir     String          aFilterName;
50*cdf0e10cSrcweir     String          aOptions;
51*cdf0e10cSrcweir     sal_Bool            bInCreate;
52*cdf0e10cSrcweir     sal_Bool            bInEdit;
53*cdf0e10cSrcweir     sal_Bool            bAddUndo;
54*cdf0e10cSrcweir     sal_Bool            bDoPaint;
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir public:
57*cdf0e10cSrcweir 	TYPEINFO();
58*cdf0e10cSrcweir 	ScTableLink( ScDocShell* pDocSh, const String& rFile,
59*cdf0e10cSrcweir 					const String& rFilter, const String& rOpt, sal_uLong nRefresh );
60*cdf0e10cSrcweir 	ScTableLink( SfxObjectShell* pShell, const String& rFile,
61*cdf0e10cSrcweir 					const String& rFilter, const String& rOpt, sal_uLong nRefresh );
62*cdf0e10cSrcweir 	virtual ~ScTableLink();
63*cdf0e10cSrcweir 	virtual void Closed();
64*cdf0e10cSrcweir 	virtual void DataChanged( const String& rMimeType,
65*cdf0e10cSrcweir 							  const ::com::sun::star::uno::Any & rValue );
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir     virtual void    Edit( Window*, const Link& rEndEditHdl );
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir 	sal_Bool	Refresh(const String& rNewFile, const String& rNewFilter,
70*cdf0e10cSrcweir 					const String* pNewOptions /* = NULL */, sal_uLong nNewRefresh );
71*cdf0e10cSrcweir 	void	SetInCreate(sal_Bool bSet)		{ bInCreate = bSet; }
72*cdf0e10cSrcweir 	void	SetAddUndo(sal_Bool bSet)		{ bAddUndo = bSet; }
73*cdf0e10cSrcweir 	void	SetPaint(sal_Bool bSet)			{ bDoPaint = bSet; }
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir 	const String& GetFileName() const	{ return aFileName; }
76*cdf0e10cSrcweir 	const String& GetFilterName() const	{ return aFilterName; }
77*cdf0e10cSrcweir 	const String& GetOptions() const	{ return aOptions; }
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir 	sal_Bool	IsUsed() const;
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir 	DECL_LINK( RefreshHdl, ScTableLink* );
82*cdf0e10cSrcweir     DECL_LINK( TableEndEditHdl, ::sfx2::SvBaseLink* );
83*cdf0e10cSrcweir };
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir class ScDocument;
86*cdf0e10cSrcweir class SfxMedium;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir class SC_DLLPUBLIC ScDocumentLoader
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir private:
91*cdf0e10cSrcweir 	ScDocShell*			pDocShell;
92*cdf0e10cSrcweir     SfxObjectShellRef   aRef;
93*cdf0e10cSrcweir 	SfxMedium*			pMedium;
94*cdf0e10cSrcweir 
95*cdf0e10cSrcweir public:
96*cdf0e10cSrcweir 						ScDocumentLoader( const String& rFileName,
97*cdf0e10cSrcweir 											String& rFilterName, String& rOptions,
98*cdf0e10cSrcweir 											sal_uInt32 nRekCnt = 0, sal_Bool bWithInteraction = sal_False );
99*cdf0e10cSrcweir 						~ScDocumentLoader();
100*cdf0e10cSrcweir 	ScDocument*			GetDocument();
101*cdf0e10cSrcweir 	ScDocShell*			GetDocShell()		{ return pDocShell; }
102*cdf0e10cSrcweir 	sal_Bool				IsError() const;
103*cdf0e10cSrcweir 	String				GetTitle() const;
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir 	void				ReleaseDocRef();	// without calling DoClose
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 	static String		GetOptions( SfxMedium& rMedium );
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     /** Returns the filter name and options from a file name.
110*cdf0e10cSrcweir         @param bWithContent
111*cdf0e10cSrcweir             true = Tries to detect the filter by looking at the file contents.
112*cdf0e10cSrcweir             false = Detects filter by file name extension only (should be used in filter code only).
113*cdf0e10cSrcweir         @return sal_True if a filter could be found, sal_False otherwise. */
114*cdf0e10cSrcweir 	static sal_Bool			GetFilterName( const String& rFileName,
115*cdf0e10cSrcweir 										String& rFilter, String& rOptions,
116*cdf0e10cSrcweir                                         sal_Bool bWithContent, sal_Bool bWithInteraction );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir 	static void			RemoveAppPrefix( String& rFilterName );
119*cdf0e10cSrcweir };
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir #endif
122