xref: /AOO41X/main/sfx2/inc/sfx2/lnkbase.hxx (revision 353d8f4d17010cd2d0ea815067cad67e477f2bee)
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 #ifndef _LNKBASE_HXX
24 #define _LNKBASE_HXX
25 
26 #include <com/sun/star/io/XInputStream.hpp>
27 #include "sal/config.h"
28 #include "sfx2/dllapi.h"
29 #include <sot/exchange.hxx>
30 #ifndef _TOOLS_REF_HXX
31 #include <tools/ref.hxx>
32 #endif
33 #ifndef _LINKSOURCE_HXX
34 #include <sfx2/linksrc.hxx>
35 #endif
36 
37 namespace com { namespace sun { namespace star { namespace uno
38 {
39     class Any;
40     //class Type;
41 }}}}
42 
43 namespace sfx2
44 {
45 
46 struct ImplBaseLinkData;
47 class LinkManager;
48 class SvLinkSource;
49 class FileDialogHelper;
50 
51 #ifndef OBJECT_DDE_EXTERN
52 #define OBJECT_INTERN       0x00
53 //#define   OBJECT_SO_EXTERN    0x01
54 #define OBJECT_DDE_EXTERN   0x02
55 #endif
56 
57 #define OBJECT_CLIENT_SO            0x80 // ein Link
58 #define OBJECT_CLIENT_DDE           0x81
59 //#define   OBJECT_CLIENT_OLE           0x82 // ein Ole-Link
60 //#define   OBJECT_CLIENT_OLE_CACHE     0x83 // ein Ole-Link mit SvEmbeddedObject
61 #define OBJECT_CLIENT_FILE          0x90
62 #define OBJECT_CLIENT_GRF           0x91
63 #define OBJECT_CLIENT_OLE           0x92 // embedded link
64 
65 enum sfxlink {
66     // Ole2 compatibel und persistent
67     LINKUPDATE_ALWAYS = 1,
68     LINKUPDATE_ONCALL = 3,
69 
70     LINKUPDATE_END      // dummy!
71 };
72 
73 struct BaseLink_Impl;
74 
75 class SFX2_DLLPUBLIC SvBaseLink : public SvRefBase
76 {
77 private:
78     friend class LinkManager;
79     friend class SvLinkSource;
80 
81     SvLinkSourceRef         xObj;
82     String                  aLinkName;
83     BaseLink_Impl*          pImpl;
84     sal_uInt16                  nObjType;
85     sal_Bool                    bVisible : 1;
86     sal_Bool                    bSynchron : 1;
87     sal_Bool                    bUseCache : 1;      // fuer GrafikLinks!
88     sal_Bool                    bWasLastEditOK : 1;
89 
90     DECL_LINK( EndEditHdl, String* );
91 
92     bool                    ExecuteEdit( const String& _rNewName );
93 
94 protected:
95     void            SetObjType( sal_uInt16 );
96 
97                     // setzen des LinkSourceName ohne aktion
98     void            SetName( const String & rLn );
99                     // LinkSourceName der im SvLinkBase steht
100     String          GetName() const;
101 
102     ImplBaseLinkData* pImplData;
103 
104     sal_Bool            m_bIsReadOnly;
105     com::sun::star::uno::Reference<com::sun::star::io::XInputStream>
106                         m_xInputStreamToLoadFrom;
107 
108                     SvBaseLink();
109                     SvBaseLink( sal_uInt16 nLinkType, sal_uIntPtr nContentType = FORMAT_STRING );
110     virtual         ~SvBaseLink();
111 
112     void            _GetRealObject( sal_Bool bConnect = sal_True );
113 
GetRealObject()114     SvLinkSource*   GetRealObject()
115                     {
116                         if( !xObj.Is() )
117                             _GetRealObject();
118                         return xObj;
119                     }
120 
121 public:
122                     TYPEINFO();
123                     // ask JP
124     virtual void    Closed();
125                     SvBaseLink( const String& rNm, sal_uInt16 nObjectType,
126                                  SvLinkSource* );
127 
GetObjType() const128     sal_uInt16          GetObjType() const { return nObjType; }
129 
130     void            SetObj( SvLinkSource * pObj );
GetObj() const131     SvLinkSource*   GetObj() const  { return xObj; }
132 
133     void            SetLinkSourceName( const String & rName );
134     String          GetLinkSourceName() const;
135 
136     virtual void    DataChanged( const String & rMimeType,
137                                 const ::com::sun::star::uno::Any & rValue );
138 
139     void            SetUpdateMode( sal_uInt16 );
140     sal_uInt16          GetUpdateMode() const;
141     sal_uIntPtr             GetContentType() const;
142     sal_Bool            SetContentType( sal_uIntPtr nType );
143 
144     LinkManager*          GetLinkManager();
145     const LinkManager*    GetLinkManager() const;
146     void                    SetLinkManager( LinkManager* _pMgr );
147 
148     sal_Bool            Update();
149     void            Disconnect();
150 
151     // Link impl: DECL_LINK( MyEndDialogHdl, SvBaseLink* ); <= param is this
152     virtual void    Edit( Window*, const Link& rEndEditHdl );
153 
154         // soll der Link im Dialog angezeigt werden ? (Links im Link im ...)
IsVisible() const155     sal_Bool            IsVisible() const           { return bVisible; }
SetVisible(sal_Bool bFlag)156     void            SetVisible( sal_Bool bFlag )    { bVisible = bFlag; }
157         // soll der Link synchron oder asynchron geladen werden?
IsSynchron() const158     sal_Bool            IsSynchron() const          { return bSynchron; }
SetSynchron(sal_Bool bFlag)159     void            SetSynchron( sal_Bool bFlag )   { bSynchron = bFlag; }
160 
IsUseCache() const161     sal_Bool            IsUseCache() const          { return bUseCache; }
SetUseCache(sal_Bool bFlag)162     void            SetUseCache( sal_Bool bFlag )   { bUseCache = bFlag; }
163 
setStreamToLoadFrom(const com::sun::star::uno::Reference<com::sun::star::io::XInputStream> & xInputStream,sal_Bool bIsReadOnly)164     void            setStreamToLoadFrom(
165                         const com::sun::star::uno::Reference<com::sun::star::io::XInputStream>& xInputStream,
166                         sal_Bool bIsReadOnly )
167                             { m_xInputStreamToLoadFrom = xInputStream;
168                               m_bIsReadOnly = bIsReadOnly; }
169     // --> OD 2008-06-18 #i88291#
170     void            clearStreamToLoadFrom();
171     // <--
172 
WasLastEditOK() const173     inline sal_Bool         WasLastEditOK() const       { return bWasLastEditOK; }
174     FileDialogHelper*   GetFileDialog( sal_uInt32 nFlags, const String& rFactory ) const;
175 };
176 
177 SV_DECL_IMPL_REF(SvBaseLink);
178 
179 }
180 
181 #endif
182