merge the formfield patch from ooo-build
[ooovba.git] / sw / inc / section.hxx
blob4d883e8464419b76fc764f6b012264d05d361a80
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: section.hxx,v $
10 * $Revision: 1.13.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SECTION_HXX
32 #define _SECTION_HXX
35 #include <com/sun/star/uno/Sequence.h>
36 #include <sfx2/lnkbase.hxx>
37 #include <tools/rtti.hxx>
38 #ifndef _TOOLS_REF_HXX
39 #include <tools/ref.hxx>
40 #endif
41 #include <svtools/svarray.hxx>
42 #include <frmfmt.hxx>
44 // Forward Deklaration
45 class SwSectionFmt;
46 class SwDoc;
47 class SwSection;
48 class SwSectionNode;
49 class SwTOXBase;
51 #ifndef SW_DECL_SWSERVEROBJECT_DEFINED
52 #define SW_DECL_SWSERVEROBJECT_DEFINED
53 SV_DECL_REF( SwServerObject )
54 #endif
56 SV_DECL_PTRARR( SwSections, SwSection*, 0, 4 )
58 enum SectionType { CONTENT_SECTION,
59 TOX_HEADER_SECTION,
60 TOX_CONTENT_SECTION,
61 DDE_LINK_SECTION = OBJECT_CLIENT_DDE,
62 FILE_LINK_SECTION = OBJECT_CLIENT_FILE
64 // verbleiben noch:
65 OBJECT_CLIENT_SO = 0x80,
66 OBJECT_CLIENT_OLE = 0x82,
67 OBJECT_CLIENT_OLE_CACHE = 0x83,
71 enum LinkCreateType
73 CREATE_NONE, // nichts weiter tun
74 CREATE_CONNECT, // Link gleich connecten
75 CREATE_UPDATE // Link connecten und updaten
79 class SW_DLLPUBLIC SwSection : public SwClient
81 // damit beim Anlegen/Loeschen von Frames das Flag richtig gepflegt wird!
82 friend class SwSectionNode;
83 // the "read CTOR" of SwSectionFrm have to change the Hiddenflag
84 friend class SwSectionFrm;
86 String sSectionNm;
87 String sCondition; // erstmal, vielleicht auch mal ein Feld ??
88 String sLinkFileName,
89 sLinkFilePassWd; // JP 27.02.2001: must later changed to Sequence
90 ::com::sun::star::uno::Sequence <sal_Int8> aPasswd;
92 SwServerObjectRef refObj; // falls DataServer -> Pointer gesetzt
93 ::sfx2::SvBaseLinkRef refLink;
95 SectionType eType;
97 BOOL bProtectFlag : 1; // Flags fuer schnelle Abfragen, wird ueber
98 // Attribut im Format gesetzt
99 BOOL bHiddenFlag : 1; // Flag: Absaetze versteckt ?
100 // --> FME 2004-06-22 #114856# edit in readonly sections
101 BOOL bEditInReadonlyFlag : 1;
102 // <--
103 BOOL bHidden : 1; // alle Absaetze nicht sichtbar ?
104 BOOL bCondHiddenFlag : 1; // Hiddenflag fuer die Bedingung ?
105 BOOL bConnectFlag : 1; // Flag: "Verbindung zum Server" vorhanden?
108 SW_DLLPRIVATE void _SetHiddenFlag( BOOL bHidden, BOOL bCondition );
109 SW_DLLPRIVATE void _SetProtectFlag( BOOL bFlag ) { bProtectFlag = bFlag; }
110 /* SW_DLLPUBLIC */ BOOL _IsProtect() const;
112 // --> FME 2004-06-22 #114856# edit in readonly sections
113 void _SetEditInReadonlyFlag( BOOL bFlag ) { bEditInReadonlyFlag = bFlag; }
114 BOOL _IsEditInReadonly() const;
115 // <--
117 public:
118 TYPEINFO(); // rtti
120 SwSection( SectionType eType, const String& rName,
121 SwSectionFmt* pFmt = 0 );
122 ~SwSection();
124 // kopiere nur die Daten der Section!
125 // Ableitung bleibt (beim Left) erhalten.
126 SwSection& operator=( const SwSection& );
127 BOOL operator==( const SwSection& rCmp ) const;
129 const String& GetName() const { return sSectionNm; }
130 void SetName( const String& rName ) { sSectionNm = rName; }
131 SectionType GetType() const { return eType; }
132 void SetType( SectionType eNew ) { eType = eNew; }
134 SwSectionFmt* GetFmt() { return (SwSectionFmt*)pRegisteredIn; }
135 SwSectionFmt* GetFmt() const { return (SwSectionFmt*)pRegisteredIn; }
137 virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew );
139 // setze die Hidden/Protected -> gesamten Baum updaten !
140 // (Attribute/Flags werden gesetzt/erfragt)
141 BOOL IsHidden() const { return bHidden; }
142 BOOL IsProtect() const { return GetFmt() ? _IsProtect()
143 : IsProtectFlag(); }
145 // --> FME 2004-06-22 #114856# edit in readonly sections
146 BOOL IsEditInReadonly()const { return GetFmt() ? _IsEditInReadonly() : IsEditInReadonlyFlag(); }
147 void SetEditInReadonly( BOOL bFlag = TRUE );
148 // <--
150 void SetHidden( BOOL bFlag = TRUE );
151 void SetProtect( BOOL bFlag = TRUE );
153 // erfrage die internen Flags (Zustand inklusive Parents nicht, was
154 // aktuell an der Section gesetzt ist!!)
155 BOOL IsHiddenFlag() const { return bHiddenFlag; }
156 BOOL IsProtectFlag() const { return bProtectFlag; }
157 // --> FME 2004-06-22 #114856# edit in readonly sections
158 BOOL IsEditInReadonlyFlag() const { return bEditInReadonlyFlag; }
159 // <--
161 void SetCondHidden( BOOL bFlag = TRUE );
162 BOOL IsCondHidden() const { return bCondHiddenFlag; }
163 // erfrage (auch ueber die Parents), ob diese Section versteckt sein soll.
164 BOOL CalcHiddenFlag() const;
167 inline SwSection* GetParent() const;
169 // setze/erfrage die Bedingung
170 const String& GetCondition() const { return sCondition; }
171 void SetCondition( const String& rNew ) { sCondition = rNew; }
173 // setze/erfrage den gelinkten FileNamen
174 const String& GetLinkFileName() const;
175 void SetLinkFileName( const String& rNew, const String* pPassWd = 0 );
176 // Passwort des gelinkten Files (nur waehrend der Laufzeit gueltig!)
177 const String& GetLinkFilePassWd() const { return sLinkFilePassWd; }
178 void SetLinkFilePassWd( const String& rS ) { sLinkFilePassWd = rS; }
180 // get / set password of this section
181 const ::com::sun::star::uno::Sequence <sal_Int8>&
182 GetPasswd() const { return aPasswd; }
183 void SetPasswd( const ::com::sun::star::uno::Sequence <sal_Int8>& rNew )
184 { aPasswd = rNew; }
186 // Daten Server-Methoden
187 void SetRefObject( SwServerObject* pObj );
188 const SwServerObject* GetObject() const { return &refObj; }
189 SwServerObject* GetObject() { return &refObj; }
190 BOOL IsServer() const { return refObj.Is(); }
192 // Methoden fuer gelinkte Bereiche
193 USHORT GetUpdateType() const { return refLink->GetUpdateMode(); }
194 void SetUpdateType( USHORT nType ) { refLink->SetUpdateMode( nType ); }
196 BOOL IsConnected() const { return refLink.Is(); }
197 void UpdateNow() { refLink->Update(); }
198 void Disconnect() { refLink->Disconnect(); }
200 const ::sfx2::SvBaseLink& GetBaseLink() const { return *refLink; }
201 ::sfx2::SvBaseLink& GetBaseLink() { return *refLink; }
203 void CreateLink( LinkCreateType eType );
205 void MakeChildLinksVisible( const SwSectionNode& rSectNd );
207 BOOL IsLinkType() const
208 { return DDE_LINK_SECTION == eType || FILE_LINK_SECTION == eType; }
210 // Flags fuer UI - Verbindung geklappt?
211 BOOL IsConnectFlag() const { return bConnectFlag; }
212 void SetConnectFlag( BOOL bFlag = TRUE ) { bConnectFlag = bFlag; }
214 // return the TOX base class if the section is a TOX section
215 const SwTOXBase* GetTOXBase() const;
217 // --> OD 2007-02-14 #b6521322#
218 void BreakLink();
219 // <--
220 private:
221 // privater Constructor, weil nie kopiert werden darf !!
222 SwSection( const SwSection& );
223 // @@@ but copy assignment "SwSection & operator= ( const SwSection& )" is public? @@@
227 enum SectionSort { SORTSECT_NOT, SORTSECT_NAME, SORTSECT_POS };
229 class SW_DLLPUBLIC SwSectionFmt : public SwFrmFmt
231 friend class SwDoc;
233 /* SW_DLLPUBLIC */ SwSection* _GetSection() const;
234 SW_DLLPRIVATE void UpdateParent(); // Parent wurde veraendert
236 protected:
237 SwSectionFmt( SwSectionFmt* pDrvdFrm, SwDoc *pDoc );
239 public:
240 TYPEINFO(); //Bereits in Basisklasse Client drin.
241 ~SwSectionFmt();
243 //Vernichtet alle Frms in aDepend (Frms werden per PTR_CAST erkannt).
244 virtual void DelFrms();
246 //Erzeugt die Ansichten
247 virtual void MakeFrms();
249 virtual void Modify( SfxPoolItem* pOld, SfxPoolItem* pNew );
250 // erfrage vom Format Informationen
251 virtual BOOL GetInfo( SfxPoolItem& ) const;
253 SwSection* GetSection() const { return (SwSection*)_GetSection(); }
254 inline SwSectionFmt* GetParent() const;
255 inline SwSection* GetParentSection() const;
257 // alle Sections, die von dieser abgeleitet sind
258 // - sortiert nach : Name oder Position oder unsortiert
259 // - alle oder nur die, die sich im normalten Nodes-Array befinden
260 USHORT GetChildSections( SwSections& rArr,
261 SectionSort eSort = SORTSECT_NOT,
262 BOOL bAllSections = TRUE ) const;
264 // erfrage, ob sich die Section im Nodes-Array oder UndoNodes-Array
265 // befindet.
266 BOOL IsInNodesArr() const;
268 SwSectionNode* GetSectionNode( BOOL bAlways = FALSE );
269 const SwSectionNode* GetSectionNode( BOOL bAlways = FALSE ) const
270 { return ((SwSectionFmt*)this)->GetSectionNode( bAlways ); }
272 // ist die Section eine gueltige fuers GlobalDocument?
273 const SwSection* GetGlobalDocSection() const;
276 // -------------- inlines ---------------------------------
278 inline SwSection* SwSection::GetParent() const
280 SwSectionFmt* pFmt = GetFmt();
281 SwSection* pRet = 0;
282 if( pFmt )
283 pRet = pFmt->GetParentSection();
284 return pRet;
287 inline SwSectionFmt* SwSectionFmt::GetParent() const
289 SwSectionFmt* pRet = 0;
290 if( GetRegisteredIn() )
291 pRet = PTR_CAST( SwSectionFmt, GetRegisteredIn() );
292 return pRet;
295 inline SwSection* SwSectionFmt::GetParentSection() const
297 SwSectionFmt* pParent = GetParent();
298 SwSection* pRet = 0;
299 if( pParent )
300 pRet = pParent->_GetSection();
301 return pRet;
305 #endif /* _SECTION_HXX */