Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef SC_TABLINK_HXX
21 : #define SC_TABLINK_HXX
22 :
23 : #include "scdllapi.h"
24 : #include "refreshtimer.hxx"
25 : #include <sfx2/lnkbase.hxx>
26 :
27 : #include <sfx2/objsh.hxx>
28 :
29 : class ScDocShell;
30 : struct TableLink_Impl;
31 :
32 : class ScTableLink : public ::sfx2::SvBaseLink, public ScRefreshTimer
33 : {
34 : private:
35 : TableLink_Impl* pImpl;
36 : rtl::OUString aFileName;
37 : rtl::OUString aFilterName;
38 : rtl::OUString aOptions;
39 : bool bInCreate:1;
40 : bool bInEdit:1;
41 : bool bAddUndo:1;
42 : bool bDoPaint:1;
43 :
44 : public:
45 : TYPEINFO();
46 : ScTableLink( ScDocShell* pDocSh, const String& rFile,
47 : const String& rFilter, const String& rOpt, sal_uLong nRefresh );
48 : ScTableLink( SfxObjectShell* pShell, const String& rFile,
49 : const String& rFilter, const String& rOpt, sal_uLong nRefresh );
50 : virtual ~ScTableLink();
51 : virtual void Closed();
52 : virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
53 : const String& rMimeType, const ::com::sun::star::uno::Any & rValue );
54 :
55 : virtual void Edit( Window*, const Link& rEndEditHdl );
56 :
57 : sal_Bool Refresh(const String& rNewFile, const String& rNewFilter,
58 : const String* pNewOptions /* = NULL */, sal_uLong nNewRefresh );
59 0 : void SetInCreate(bool bSet) { bInCreate = bSet; }
60 0 : void SetAddUndo(bool bSet) { bAddUndo = bSet; }
61 : void SetPaint(bool bSet) { bDoPaint = bSet; }
62 :
63 0 : const rtl::OUString& GetFileName() const { return aFileName; }
64 0 : const rtl::OUString& GetFilterName() const { return aFilterName; }
65 0 : const rtl::OUString& GetOptions() const { return aOptions; }
66 :
67 : sal_Bool IsUsed() const;
68 :
69 : DECL_LINK( RefreshHdl, void* );
70 : DECL_LINK( TableEndEditHdl, ::sfx2::SvBaseLink* );
71 : };
72 :
73 : class ScDocument;
74 : class SfxMedium;
75 :
76 : class SC_DLLPUBLIC ScDocumentLoader
77 : {
78 : private:
79 : ScDocShell* pDocShell;
80 : SfxObjectShellRef aRef;
81 : SfxMedium* pMedium;
82 :
83 : static bool GetFilterName( const String& rFileName,
84 : String& rFilter, String& rOptions,
85 : bool bWithContent, bool bWithInteraction );
86 :
87 : public:
88 : ScDocumentLoader( const rtl::OUString& rFileName,
89 : rtl::OUString& rFilterName, rtl::OUString& rOptions,
90 : sal_uInt32 nRekCnt = 0, bool bWithInteraction = false );
91 : ~ScDocumentLoader();
92 : ScDocument* GetDocument();
93 0 : ScDocShell* GetDocShell() { return pDocShell; }
94 : bool IsError() const;
95 : rtl::OUString GetTitle() const;
96 :
97 : void ReleaseDocRef(); // without calling DoClose
98 :
99 : static rtl::OUString GetOptions( SfxMedium& rMedium );
100 :
101 : /** Returns the filter name and options from a file name.
102 : @param bWithContent
103 : true = Tries to detect the filter by looking at the file contents.
104 : false = Detects filter by file name extension only (should be used in filter code only).
105 : @return sal_True if a filter could be found, sal_False otherwise. */
106 :
107 : static bool GetFilterName( const ::rtl::OUString& rFileName,
108 : ::rtl::OUString& rFilter, ::rtl::OUString& rOptions,
109 : bool bWithContent, bool bWithInteraction );
110 :
111 : static void RemoveAppPrefix( rtl::OUString& rFilterName );
112 : };
113 :
114 : #endif
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|