build fix
[LibreOffice.git] / sc / inc / tablink.hxx
blob6684a5ff3b439a9910f22a3b23d6082e7c876e51
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SC_INC_TABLINK_HXX
21 #define INCLUDED_SC_INC_TABLINK_HXX
23 #include "scdllapi.h"
24 #include "refreshtimer.hxx"
25 #include <sfx2/lnkbase.hxx>
27 #include <sfx2/objsh.hxx>
28 #include <memory>
30 class ScDocShell;
31 struct TableLink_Impl;
33 class ScTableLink : public ::sfx2::SvBaseLink, public ScRefreshTimer
35 private:
36 std::unique_ptr<TableLink_Impl> pImpl;
37 OUString aFileName;
38 OUString aFilterName;
39 OUString aOptions;
40 bool bInCreate:1;
41 bool bInEdit:1;
42 bool bAddUndo:1;
44 public:
45 ScTableLink( ScDocShell* pDocSh, const OUString& rFile,
46 const OUString& rFilter, const OUString& rOpt, sal_uLong nRefresh );
47 ScTableLink( SfxObjectShell* pShell, const OUString& rFile,
48 const OUString& rFilter, const OUString& rOpt, sal_uLong nRefresh );
49 virtual ~ScTableLink() override;
50 virtual void Closed() override;
51 virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
52 const OUString& rMimeType, const css::uno::Any & rValue ) override;
54 virtual void Edit( vcl::Window*, const Link<SvBaseLink&,void>& rEndEditHdl ) override;
56 bool Refresh(const OUString& rNewFile, const OUString& rNewFilter,
57 const OUString* pNewOptions /* = NULL */, sal_uLong nNewRefresh );
58 void SetInCreate(bool bSet) { bInCreate = bSet; }
59 void SetAddUndo(bool bSet) { bAddUndo = bSet; }
61 const OUString& GetFileName() const { return aFileName; }
62 const OUString& GetFilterName() const { return aFilterName; }
63 const OUString& GetOptions() const { return aOptions; }
65 bool IsUsed() const;
67 DECL_LINK( RefreshHdl, Timer*, void );
68 DECL_LINK( TableEndEditHdl, ::sfx2::SvBaseLink&, void );
71 class ScDocument;
72 class SfxMedium;
73 class SfxFilter;
75 class SC_DLLPUBLIC ScDocumentLoader
77 private:
78 ScDocShell* pDocShell;
79 SfxObjectShellRef aRef;
80 SfxMedium* pMedium;
82 public:
83 ScDocumentLoader( const OUString& rFileName,
84 OUString& rFilterName, OUString& rOptions,
85 sal_uInt32 nRekCnt = 0, bool bWithInteraction = false );
86 ~ScDocumentLoader();
87 ScDocument* GetDocument();
88 ScDocShell* GetDocShell() { return pDocShell; }
89 bool IsError() const;
90 OUString GetTitle() const;
92 void ReleaseDocRef(); // without calling DoClose
94 /** Create SfxMedium for stream read with SfxFilter and filter options set
95 at the medium's SfxItemSet.
97 static SfxMedium* CreateMedium( const OUString& rFileName, std::shared_ptr<const SfxFilter> const & pFilter, const OUString& rOptions );
99 static OUString GetOptions( SfxMedium& rMedium );
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. */
107 static bool GetFilterName( const OUString& rFileName,
108 OUString& rFilter, OUString& rOptions,
109 bool bWithContent, bool bWithInteraction );
111 static void RemoveAppPrefix( OUString& rFilterName );
114 #endif
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */