xref: /aoo4110/main/sc/inc/tablink.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_TABLINK_HXX
25 #define SC_TABLINK_HXX
26 
27 #include "scdllapi.h"
28 #include "refreshtimer.hxx"
29 #include <sfx2/lnkbase.hxx>
30 
31 #include <sfx2/objsh.hxx>
32 //REMOVE	#ifndef SO2_DECL_SVEMBEDDEDOBJECT_DEFINED
33 //REMOVE	#define SO2_DECL_SVEMBEDDEDOBJECT_DEFINED
34 //REMOVE	SO2_DECL_REF(SvEmbeddedObject)
35 //REMOVE	#endif
36 
37 class ScDocShell;
38 struct TableLink_Impl;
39 
40 class ScTableLink : public ::sfx2::SvBaseLink, public ScRefreshTimer
41 {
42 private:
43     TableLink_Impl* pImpl;
44     String          aFileName;
45     String          aFilterName;
46     String          aOptions;
47     sal_Bool            bInCreate;
48     sal_Bool            bInEdit;
49     sal_Bool            bAddUndo;
50     sal_Bool            bDoPaint;
51 
52 public:
53 	TYPEINFO();
54 	ScTableLink( ScDocShell* pDocSh, const String& rFile,
55 					const String& rFilter, const String& rOpt, sal_uLong nRefresh );
56 	ScTableLink( SfxObjectShell* pShell, const String& rFile,
57 					const String& rFilter, const String& rOpt, sal_uLong nRefresh );
58 	virtual ~ScTableLink();
59 	virtual void Closed();
60 	virtual void DataChanged( const String& rMimeType,
61 							  const ::com::sun::star::uno::Any & rValue );
62 
63     virtual void    Edit( Window*, const Link& rEndEditHdl );
64 
65 	sal_Bool	Refresh(const String& rNewFile, const String& rNewFilter,
66 					const String* pNewOptions /* = NULL */, sal_uLong nNewRefresh );
SetInCreate(sal_Bool bSet)67 	void	SetInCreate(sal_Bool bSet)		{ bInCreate = bSet; }
SetAddUndo(sal_Bool bSet)68 	void	SetAddUndo(sal_Bool bSet)		{ bAddUndo = bSet; }
SetPaint(sal_Bool bSet)69 	void	SetPaint(sal_Bool bSet)			{ bDoPaint = bSet; }
70 
GetFileName() const71 	const String& GetFileName() const	{ return aFileName; }
GetFilterName() const72 	const String& GetFilterName() const	{ return aFilterName; }
GetOptions() const73 	const String& GetOptions() const	{ return aOptions; }
74 
75 	sal_Bool	IsUsed() const;
76 
77 	DECL_LINK( RefreshHdl, ScTableLink* );
78     DECL_LINK( TableEndEditHdl, ::sfx2::SvBaseLink* );
79 };
80 
81 class ScDocument;
82 class SfxMedium;
83 
84 class SC_DLLPUBLIC ScDocumentLoader
85 {
86 private:
87 	ScDocShell*			pDocShell;
88     SfxObjectShellRef   aRef;
89 	SfxMedium*			pMedium;
90 
91 public:
92 						ScDocumentLoader( const String& rFileName,
93 											String& rFilterName, String& rOptions,
94 											sal_uInt32 nRekCnt = 0, sal_Bool bWithInteraction = sal_False );
95 						~ScDocumentLoader();
96 	ScDocument*			GetDocument();
GetDocShell()97 	ScDocShell*			GetDocShell()		{ return pDocShell; }
98 	sal_Bool				IsError() const;
99 	String				GetTitle() const;
100 
101 	void				ReleaseDocRef();	// without calling DoClose
102 
103 	static String		GetOptions( SfxMedium& rMedium );
104 
105     /** Returns the filter name and options from a file name.
106         @param bWithContent
107             true = Tries to detect the filter by looking at the file contents.
108             false = Detects filter by file name extension only (should be used in filter code only).
109         @return sal_True if a filter could be found, sal_False otherwise. */
110 	static sal_Bool			GetFilterName( const String& rFileName,
111 										String& rFilter, String& rOptions,
112                                         sal_Bool bWithContent, sal_Bool bWithInteraction );
113 
114 	static void			RemoveAppPrefix( String& rFilterName );
115 };
116 
117 #endif
118