1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <stdlib.h>
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <svl/intitem.hxx>
30cdf0e10cSrcweir #include <svl/stritem.hxx>
31cdf0e10cSrcweir #include <sfx2/docfile.hxx>
32cdf0e10cSrcweir #include <sfx2/docfilt.hxx>
33cdf0e10cSrcweir #include <editeng/protitem.hxx>
34cdf0e10cSrcweir #include <sfx2/linkmgr.hxx>
35cdf0e10cSrcweir #include <tools/urlobj.hxx>
36cdf0e10cSrcweir #include <sfx2/sfxsids.hrc>
37cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
38cdf0e10cSrcweir #include <docary.hxx>
39cdf0e10cSrcweir #include <fmtcntnt.hxx>
40cdf0e10cSrcweir #include <fmtpdsc.hxx>
41cdf0e10cSrcweir #include <errhdl.hxx>
42cdf0e10cSrcweir #include <doc.hxx>
43cdf0e10cSrcweir #include <IDocumentUndoRedo.hxx>
44cdf0e10cSrcweir #include <node.hxx>
45cdf0e10cSrcweir #include <pam.hxx>
46cdf0e10cSrcweir #include <frmtool.hxx>
47cdf0e10cSrcweir #include <editsh.hxx>
48cdf0e10cSrcweir #include <hints.hxx>
49cdf0e10cSrcweir #include <docsh.hxx>
50cdf0e10cSrcweir #include <ndtxt.hxx>
51cdf0e10cSrcweir #include <section.hxx>
52cdf0e10cSrcweir #include <swserv.hxx>
53cdf0e10cSrcweir #include <shellio.hxx>
54cdf0e10cSrcweir #include <poolfmt.hxx>
55cdf0e10cSrcweir #include <expfld.hxx>
56cdf0e10cSrcweir #include <swbaslnk.hxx>
57cdf0e10cSrcweir #include <mvsave.hxx>
58cdf0e10cSrcweir #include <sectfrm.hxx>
59cdf0e10cSrcweir #include <fmtftntx.hxx>
60cdf0e10cSrcweir #include <ftnidx.hxx>
61cdf0e10cSrcweir #include <doctxm.hxx>
62cdf0e10cSrcweir #include <fmteiro.hxx>
63cdf0e10cSrcweir #include <swerror.h>
64cdf0e10cSrcweir #include <unosection.hxx>
65cdf0e10cSrcweir #include <switerator.hxx>
66cdf0e10cSrcweir #include <svl/smplhint.hxx>
67cdf0e10cSrcweir
68cdf0e10cSrcweir using namespace ::com::sun::star;
69cdf0e10cSrcweir
70cdf0e10cSrcweir
71cdf0e10cSrcweir SV_IMPL_REF( SwServerObject )
72cdf0e10cSrcweir
73cdf0e10cSrcweir //static const char __FAR_DATA sSectionFmtNm[] = "Section";
74cdf0e10cSrcweir #define sSectionFmtNm aEmptyStr
75cdf0e10cSrcweir
76cdf0e10cSrcweir class SwIntrnlSectRefLink : public SwBaseLink
77cdf0e10cSrcweir {
78cdf0e10cSrcweir SwSectionFmt& rSectFmt;
79cdf0e10cSrcweir public:
SwIntrnlSectRefLink(SwSectionFmt & rFmt,sal_uInt16 nUpdateType,sal_uInt16 nFmt)80cdf0e10cSrcweir SwIntrnlSectRefLink( SwSectionFmt& rFmt, sal_uInt16 nUpdateType, sal_uInt16 nFmt )
81cdf0e10cSrcweir : SwBaseLink( nUpdateType, nFmt ),
82cdf0e10cSrcweir rSectFmt( rFmt )
83cdf0e10cSrcweir {}
84cdf0e10cSrcweir
85cdf0e10cSrcweir virtual void Closed();
86cdf0e10cSrcweir virtual void DataChanged( const String& rMimeType,
87cdf0e10cSrcweir const uno::Any & rValue );
88cdf0e10cSrcweir
89cdf0e10cSrcweir virtual const SwNode* GetAnchor() const;
90cdf0e10cSrcweir virtual sal_Bool IsInRange( sal_uLong nSttNd, sal_uLong nEndNd, xub_StrLen nStt = 0,
91cdf0e10cSrcweir xub_StrLen nEnd = STRING_NOTFOUND ) const;
92cdf0e10cSrcweir
93cdf0e10cSrcweir // --> OD 2007-02-14 #b6521322#
GetSectNode()94cdf0e10cSrcweir inline SwSectionNode* GetSectNode()
95cdf0e10cSrcweir {
96cdf0e10cSrcweir const SwNode* pSectNd( const_cast<SwIntrnlSectRefLink*>(this)->GetAnchor() );
97cdf0e10cSrcweir return const_cast<SwSectionNode*>( dynamic_cast<const SwSectionNode*>( pSectNd ) );
98cdf0e10cSrcweir }
99cdf0e10cSrcweir // <--
100cdf0e10cSrcweir };
101cdf0e10cSrcweir
102cdf0e10cSrcweir
103cdf0e10cSrcweir TYPEINIT1(SwSectionFmt,SwFrmFmt );
104cdf0e10cSrcweir TYPEINIT1(SwSection,SwClient );
105cdf0e10cSrcweir
106cdf0e10cSrcweir typedef SwSection* SwSectionPtr;
107cdf0e10cSrcweir
SV_IMPL_PTRARR(SwSections,SwSection *)108cdf0e10cSrcweir SV_IMPL_PTRARR( SwSections, SwSection*)
109cdf0e10cSrcweir SV_IMPL_PTRARR(SwSectionFmts,SwSectionFmt*)
110cdf0e10cSrcweir
111cdf0e10cSrcweir
112cdf0e10cSrcweir SwSectionData::SwSectionData(SectionType const eType, String const& rName)
113cdf0e10cSrcweir : m_eType(eType)
114cdf0e10cSrcweir , m_sSectionName(rName)
115cdf0e10cSrcweir , m_bHiddenFlag(false)
116cdf0e10cSrcweir , m_bProtectFlag(false)
117cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
118cdf0e10cSrcweir , m_bEditInReadonlyFlag(false)
119cdf0e10cSrcweir // <--
120cdf0e10cSrcweir , m_bHidden(false)
121cdf0e10cSrcweir , m_bCondHiddenFlag(true)
122cdf0e10cSrcweir , m_bConnectFlag(true)
123cdf0e10cSrcweir {
124cdf0e10cSrcweir }
125cdf0e10cSrcweir
126cdf0e10cSrcweir // this must have the same semantics as operator=()
SwSectionData(SwSection const & rSection)127cdf0e10cSrcweir SwSectionData::SwSectionData(SwSection const& rSection)
128cdf0e10cSrcweir : m_eType(rSection.GetType())
129cdf0e10cSrcweir , m_sSectionName(rSection.GetSectionName())
130cdf0e10cSrcweir , m_sCondition(rSection.GetCondition())
131cdf0e10cSrcweir , m_sLinkFileName(rSection.GetLinkFileName())
132cdf0e10cSrcweir , m_sLinkFilePassword(rSection.GetLinkFilePassword())
133cdf0e10cSrcweir , m_Password(rSection.GetPassword())
134cdf0e10cSrcweir , m_bHiddenFlag(rSection.IsHiddenFlag())
135cdf0e10cSrcweir , m_bProtectFlag(rSection.IsProtect())
136cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
137cdf0e10cSrcweir , m_bEditInReadonlyFlag(rSection.IsEditInReadonly())
138cdf0e10cSrcweir // <--
139cdf0e10cSrcweir , m_bHidden(rSection.IsHidden())
140cdf0e10cSrcweir , m_bCondHiddenFlag(true)
141cdf0e10cSrcweir , m_bConnectFlag(rSection.IsConnectFlag())
142cdf0e10cSrcweir {
143cdf0e10cSrcweir }
144cdf0e10cSrcweir
145cdf0e10cSrcweir // this must have the same semantics as operator=()
SwSectionData(SwSectionData const & rOther)146cdf0e10cSrcweir SwSectionData::SwSectionData(SwSectionData const& rOther)
147cdf0e10cSrcweir : m_eType(rOther.m_eType)
148cdf0e10cSrcweir , m_sSectionName(rOther.m_sSectionName)
149cdf0e10cSrcweir , m_sCondition(rOther.m_sCondition)
150cdf0e10cSrcweir , m_sLinkFileName(rOther.m_sLinkFileName)
151cdf0e10cSrcweir , m_sLinkFilePassword(rOther.m_sLinkFilePassword)
152cdf0e10cSrcweir , m_Password(rOther.m_Password)
153cdf0e10cSrcweir , m_bHiddenFlag(rOther.m_bHiddenFlag)
154cdf0e10cSrcweir , m_bProtectFlag(rOther.m_bProtectFlag)
155cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
156cdf0e10cSrcweir , m_bEditInReadonlyFlag(rOther.m_bEditInReadonlyFlag)
157cdf0e10cSrcweir // <--
158cdf0e10cSrcweir , m_bHidden(rOther.m_bHidden)
159cdf0e10cSrcweir , m_bCondHiddenFlag(true)
160cdf0e10cSrcweir , m_bConnectFlag(rOther.m_bConnectFlag)
161cdf0e10cSrcweir {
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir // the semantics here are weird for reasons of backward compatibility
operator =(SwSectionData const & rOther)165cdf0e10cSrcweir SwSectionData & SwSectionData::operator= (SwSectionData const& rOther)
166cdf0e10cSrcweir {
167cdf0e10cSrcweir m_eType = rOther.m_eType;
168cdf0e10cSrcweir m_sSectionName = rOther.m_sSectionName;
169cdf0e10cSrcweir m_sCondition = rOther.m_sCondition;
170cdf0e10cSrcweir m_sLinkFileName = rOther.m_sLinkFileName;
171cdf0e10cSrcweir m_sLinkFilePassword = rOther.m_sLinkFilePassword;
172cdf0e10cSrcweir m_bConnectFlag = rOther.m_bConnectFlag;
173cdf0e10cSrcweir m_Password = rOther.m_Password;
174cdf0e10cSrcweir
175cdf0e10cSrcweir m_bEditInReadonlyFlag = rOther.m_bEditInReadonlyFlag;
176cdf0e10cSrcweir m_bProtectFlag = rOther.m_bProtectFlag;
177cdf0e10cSrcweir
178cdf0e10cSrcweir m_bHidden = rOther.m_bHidden;
179cdf0e10cSrcweir // FIXME: old code did not assign m_bHiddenFlag ?
180cdf0e10cSrcweir // FIXME: why should m_bCondHiddenFlag always default to true?
181cdf0e10cSrcweir m_bCondHiddenFlag = true;
182cdf0e10cSrcweir
183cdf0e10cSrcweir return *this;
184cdf0e10cSrcweir }
185cdf0e10cSrcweir
186cdf0e10cSrcweir // the semantics here are weird for reasons of backward compatibility
operator ==(SwSectionData const & rOther) const187cdf0e10cSrcweir bool SwSectionData::operator==(SwSectionData const& rOther) const
188cdf0e10cSrcweir {
189cdf0e10cSrcweir return (m_eType == rOther.m_eType)
190cdf0e10cSrcweir && (m_sSectionName == rOther.m_sSectionName)
191cdf0e10cSrcweir && (m_sCondition == rOther.m_sCondition)
192cdf0e10cSrcweir && (m_bHidden == rOther.m_bHidden)
193cdf0e10cSrcweir && (m_bProtectFlag == rOther.m_bProtectFlag)
194cdf0e10cSrcweir && (m_bEditInReadonlyFlag == rOther.m_bEditInReadonlyFlag)
195cdf0e10cSrcweir && (m_sLinkFileName == rOther.m_sLinkFileName)
196cdf0e10cSrcweir && (m_sLinkFilePassword == rOther.m_sLinkFilePassword)
197cdf0e10cSrcweir && (m_Password == rOther.m_Password);
198cdf0e10cSrcweir // FIXME: old code ignored m_bCondHiddenFlag m_bHiddenFlag m_bConnectFlag
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
201cdf0e10cSrcweir // SwSection ===========================================================
202cdf0e10cSrcweir
SwSection(SectionType const eType,String const & rName,SwSectionFmt & rFormat)203cdf0e10cSrcweir SwSection::SwSection(
204cdf0e10cSrcweir SectionType const eType, String const& rName, SwSectionFmt & rFormat)
205cdf0e10cSrcweir : SwClient(& rFormat)
206cdf0e10cSrcweir , m_Data(eType, rName)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir SwSection *const pParentSect = GetParent();
209cdf0e10cSrcweir if( pParentSect )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir if( pParentSect->IsHiddenFlag() )
212cdf0e10cSrcweir {
213cdf0e10cSrcweir SetHidden( true );
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir m_Data.SetProtectFlag( pParentSect->IsProtectFlag() );
217cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
218cdf0e10cSrcweir m_Data.SetEditInReadonlyFlag( pParentSect->IsEditInReadonlyFlag() );
219cdf0e10cSrcweir // <--
220cdf0e10cSrcweir }
221cdf0e10cSrcweir
222cdf0e10cSrcweir if (!m_Data.IsProtectFlag())
223cdf0e10cSrcweir {
224cdf0e10cSrcweir m_Data.SetProtectFlag( rFormat.GetProtect().IsCntntProtected() );
225cdf0e10cSrcweir }
226cdf0e10cSrcweir
227cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
228cdf0e10cSrcweir if (!m_Data.IsEditInReadonlyFlag())
229cdf0e10cSrcweir {
230cdf0e10cSrcweir m_Data.SetEditInReadonlyFlag( rFormat.GetEditInReadonly().GetValue() );
231cdf0e10cSrcweir }
232cdf0e10cSrcweir // <--
233cdf0e10cSrcweir }
234cdf0e10cSrcweir
235cdf0e10cSrcweir
~SwSection()236cdf0e10cSrcweir SwSection::~SwSection()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir SwSectionFmt* pFmt = GetFmt();
239cdf0e10cSrcweir if( !pFmt )
240cdf0e10cSrcweir return;
241cdf0e10cSrcweir
242cdf0e10cSrcweir SwDoc* pDoc = pFmt->GetDoc();
243cdf0e10cSrcweir if( pDoc->IsInDtor() )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir // dann melden wir noch schnell unser Format um ans dflt FrameFmt,
246cdf0e10cSrcweir // damit es keine Abhaengigkeiten gibt
247cdf0e10cSrcweir if( pFmt->DerivedFrom() != pDoc->GetDfltFrmFmt() )
248cdf0e10cSrcweir pFmt->RegisterToFormat( *pDoc->GetDfltFrmFmt() );
249cdf0e10cSrcweir }
250cdf0e10cSrcweir else
251cdf0e10cSrcweir {
252cdf0e10cSrcweir pFmt->Remove( this ); // austragen,
253cdf0e10cSrcweir
254cdf0e10cSrcweir if (CONTENT_SECTION != m_Data.GetType())
255cdf0e10cSrcweir {
256cdf0e10cSrcweir pDoc->GetLinkManager().Remove( m_RefLink );
257cdf0e10cSrcweir }
258cdf0e10cSrcweir
259cdf0e10cSrcweir if (m_RefObj.Is())
260cdf0e10cSrcweir {
261cdf0e10cSrcweir pDoc->GetLinkManager().RemoveServer( &m_RefObj );
262cdf0e10cSrcweir }
263cdf0e10cSrcweir
264cdf0e10cSrcweir // ist die Section der letzte Client im Format, kann dieses
265cdf0e10cSrcweir // geloescht werden
266cdf0e10cSrcweir SwPtrMsgPoolItem aMsgHint( RES_REMOVE_UNO_OBJECT, pFmt );
267cdf0e10cSrcweir pFmt->ModifyNotification( &aMsgHint, &aMsgHint );
268cdf0e10cSrcweir if( !pFmt->GetDepends() )
269cdf0e10cSrcweir {
270cdf0e10cSrcweir // Bug: 28191 - nicht ins Undo aufnehmen, sollte schon vorher
271cdf0e10cSrcweir // geschehen sein!!
272cdf0e10cSrcweir ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
273cdf0e10cSrcweir pDoc->DelSectionFmt( pFmt ); // und loeschen
274cdf0e10cSrcweir }
275cdf0e10cSrcweir }
276cdf0e10cSrcweir if (m_RefObj.Is())
277cdf0e10cSrcweir {
278cdf0e10cSrcweir m_RefObj->Closed();
279cdf0e10cSrcweir }
280cdf0e10cSrcweir }
281cdf0e10cSrcweir
SetSectionData(SwSectionData const & rData)282cdf0e10cSrcweir void SwSection::SetSectionData(SwSectionData const& rData)
283cdf0e10cSrcweir {
284cdf0e10cSrcweir bool const bOldHidden( m_Data.IsHidden() );
285cdf0e10cSrcweir m_Data = rData;
286cdf0e10cSrcweir // now update format and reflink with new data
287cdf0e10cSrcweir // SetLinkFileName(m_Data.GetLinkFileName()); // old code did not do this?
288cdf0e10cSrcweir // next 2 may actually overwrite m_Data.m_b{Protect,EditInReadonly}Flag
289cdf0e10cSrcweir // in Modify, which should result in same flag value as the old code!
290cdf0e10cSrcweir SetProtect(m_Data.IsProtectFlag());
291cdf0e10cSrcweir SetEditInReadonly(m_Data.IsEditInReadonlyFlag());
292cdf0e10cSrcweir if (bOldHidden != m_Data.IsHidden()) // check if changed...
293cdf0e10cSrcweir {
294cdf0e10cSrcweir ImplSetHiddenFlag(m_Data.IsHidden(), m_Data.IsCondHidden());
295cdf0e10cSrcweir }
296cdf0e10cSrcweir }
297cdf0e10cSrcweir
DataEquals(SwSectionData const & rCmp) const298cdf0e10cSrcweir bool SwSection::DataEquals(SwSectionData const& rCmp) const
299cdf0e10cSrcweir {
300cdf0e10cSrcweir // note that the old code compared the flags of the parameter with the
301cdf0e10cSrcweir // format attributes of this; the following mess should do the same...
302cdf0e10cSrcweir (void) GetLinkFileName(); // updates m_sLinkFileName
303cdf0e10cSrcweir bool const bProtect(m_Data.IsProtectFlag());
304cdf0e10cSrcweir bool const bEditInReadonly(m_Data.IsEditInReadonlyFlag());
305cdf0e10cSrcweir const_cast<SwSection*>(this)->m_Data.SetProtectFlag(IsProtect());
306cdf0e10cSrcweir const_cast<SwSection*>(this)->m_Data
307cdf0e10cSrcweir .SetEditInReadonlyFlag(IsEditInReadonly());
308cdf0e10cSrcweir bool const bResult( m_Data == rCmp );
309cdf0e10cSrcweir const_cast<SwSection*>(this)->m_Data.SetProtectFlag(bProtect);
310cdf0e10cSrcweir const_cast<SwSection*>(this)->m_Data.SetEditInReadonlyFlag(bEditInReadonly);
311cdf0e10cSrcweir return bResult;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir
314cdf0e10cSrcweir
ImplSetHiddenFlag(bool const bTmpHidden,bool const bCondition)315cdf0e10cSrcweir void SwSection::ImplSetHiddenFlag(bool const bTmpHidden, bool const bCondition)
316cdf0e10cSrcweir {
317cdf0e10cSrcweir SwSectionFmt* pFmt = GetFmt();
318cdf0e10cSrcweir ASSERT(pFmt, "ImplSetHiddenFlag: no format?");
319cdf0e10cSrcweir if( pFmt )
320cdf0e10cSrcweir {
321cdf0e10cSrcweir const bool bHide = bTmpHidden && bCondition;
322cdf0e10cSrcweir
323cdf0e10cSrcweir if (bHide) // should be hidden
324cdf0e10cSrcweir {
325cdf0e10cSrcweir if (!m_Data.IsHiddenFlag()) // is not hidden
326cdf0e10cSrcweir {
327cdf0e10cSrcweir // wie sieht es mit dem Parent aus, ist der versteckt ?
328cdf0e10cSrcweir // (eigentlich muesste das vom bHiddenFlag angezeigt werden!)
329cdf0e10cSrcweir
330cdf0e10cSrcweir // erstmal allen Childs sagen, das sie versteckt sind
331cdf0e10cSrcweir SwMsgPoolItem aMsgItem( RES_SECTION_HIDDEN );
332cdf0e10cSrcweir pFmt->ModifyNotification( &aMsgItem, &aMsgItem );
333cdf0e10cSrcweir
334cdf0e10cSrcweir // alle Frames loeschen
335cdf0e10cSrcweir pFmt->DelFrms();
336cdf0e10cSrcweir }
337cdf0e10cSrcweir }
338cdf0e10cSrcweir else if (m_Data.IsHiddenFlag()) // show Nodes again
339cdf0e10cSrcweir {
340cdf0e10cSrcweir // alle Frames sichtbar machen ( Childs Sections werden vom
341cdf0e10cSrcweir // MakeFrms beruecksichtigt). Aber nur wenn die ParentSection
342cdf0e10cSrcweir // nichts dagegen hat !
343cdf0e10cSrcweir SwSection* pParentSect = pFmt->GetParentSection();
344cdf0e10cSrcweir if( !pParentSect || !pParentSect->IsHiddenFlag() )
345cdf0e10cSrcweir {
346cdf0e10cSrcweir // erstmal allen Childs sagen, das der Parent nicht mehr
347cdf0e10cSrcweir // versteckt ist
348cdf0e10cSrcweir SwMsgPoolItem aMsgItem( RES_SECTION_NOT_HIDDEN );
349cdf0e10cSrcweir pFmt->ModifyNotification( &aMsgItem, &aMsgItem );
350cdf0e10cSrcweir
351cdf0e10cSrcweir pFmt->MakeFrms();
352cdf0e10cSrcweir }
353cdf0e10cSrcweir }
354cdf0e10cSrcweir }
355cdf0e10cSrcweir }
356cdf0e10cSrcweir
CalcHiddenFlag() const357cdf0e10cSrcweir sal_Bool SwSection::CalcHiddenFlag() const
358cdf0e10cSrcweir {
359cdf0e10cSrcweir const SwSection* pSect = this;
360cdf0e10cSrcweir do {
361cdf0e10cSrcweir if( pSect->IsHidden() && pSect->IsCondHidden() )
362cdf0e10cSrcweir return sal_True;
363cdf0e10cSrcweir } while( 0 != ( pSect = pSect->GetParent()) );
364cdf0e10cSrcweir
365cdf0e10cSrcweir return sal_False;
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
IsProtect() const368cdf0e10cSrcweir bool SwSection::IsProtect() const
369cdf0e10cSrcweir {
370cdf0e10cSrcweir SwSectionFmt *const pFmt( GetFmt() );
371cdf0e10cSrcweir ASSERT(pFmt, "SwSection::IsProtect: no format?");
372cdf0e10cSrcweir return (pFmt)
373cdf0e10cSrcweir ? pFmt->GetProtect().IsCntntProtected()
374cdf0e10cSrcweir : IsProtectFlag();
375cdf0e10cSrcweir }
376cdf0e10cSrcweir
377cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
IsEditInReadonly() const378cdf0e10cSrcweir bool SwSection::IsEditInReadonly() const
379cdf0e10cSrcweir {
380cdf0e10cSrcweir SwSectionFmt *const pFmt( GetFmt() );
381cdf0e10cSrcweir ASSERT(pFmt, "SwSection::IsEditInReadonly: no format?");
382cdf0e10cSrcweir return (pFmt)
383cdf0e10cSrcweir ? pFmt->GetEditInReadonly().GetValue()
384cdf0e10cSrcweir : IsEditInReadonlyFlag();
385cdf0e10cSrcweir }
386cdf0e10cSrcweir // <--
387cdf0e10cSrcweir
SetHidden(bool const bFlag)388cdf0e10cSrcweir void SwSection::SetHidden(bool const bFlag)
389cdf0e10cSrcweir {
390cdf0e10cSrcweir if (!m_Data.IsHidden() == !bFlag)
391cdf0e10cSrcweir return;
392cdf0e10cSrcweir
393cdf0e10cSrcweir m_Data.SetHidden(bFlag);
394cdf0e10cSrcweir ImplSetHiddenFlag(bFlag, m_Data.IsCondHidden());
395cdf0e10cSrcweir }
396cdf0e10cSrcweir
397cdf0e10cSrcweir
SetProtect(bool const bFlag)398cdf0e10cSrcweir void SwSection::SetProtect(bool const bFlag)
399cdf0e10cSrcweir {
400cdf0e10cSrcweir SwSectionFmt *const pFormat( GetFmt() );
401cdf0e10cSrcweir ASSERT(pFormat, "SwSection::SetProtect: no format?");
402cdf0e10cSrcweir if (pFormat)
403cdf0e10cSrcweir {
404cdf0e10cSrcweir SvxProtectItem aItem( RES_PROTECT );
405cdf0e10cSrcweir aItem.SetCntntProtect( (sal_Bool)bFlag );
406cdf0e10cSrcweir pFormat->SetFmtAttr( aItem );
407cdf0e10cSrcweir // note: this will call m_Data.SetProtectFlag via Modify!
408cdf0e10cSrcweir }
409cdf0e10cSrcweir else
410cdf0e10cSrcweir {
411cdf0e10cSrcweir m_Data.SetProtectFlag(bFlag);
412cdf0e10cSrcweir }
413cdf0e10cSrcweir }
414cdf0e10cSrcweir
415cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
SetEditInReadonly(bool const bFlag)416cdf0e10cSrcweir void SwSection::SetEditInReadonly(bool const bFlag)
417cdf0e10cSrcweir {
418cdf0e10cSrcweir SwSectionFmt *const pFormat( GetFmt() );
419cdf0e10cSrcweir ASSERT(pFormat, "SwSection::SetEditInReadonly: no format?");
420cdf0e10cSrcweir if (pFormat)
421cdf0e10cSrcweir {
422cdf0e10cSrcweir SwFmtEditInReadonly aItem;
423cdf0e10cSrcweir aItem.SetValue( (sal_Bool)bFlag );
424cdf0e10cSrcweir pFormat->SetFmtAttr( aItem );
425cdf0e10cSrcweir // note: this will call m_Data.SetEditInReadonlyFlag via Modify!
426cdf0e10cSrcweir }
427cdf0e10cSrcweir else
428cdf0e10cSrcweir {
429cdf0e10cSrcweir m_Data.SetEditInReadonlyFlag(bFlag);
430cdf0e10cSrcweir }
431cdf0e10cSrcweir }
432cdf0e10cSrcweir // <--
433cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)434cdf0e10cSrcweir void SwSection::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir bool bRemake = false;
437cdf0e10cSrcweir bool bUpdateFtn = false;
438cdf0e10cSrcweir switch( pOld ? pOld->Which() : pNew ? pNew->Which() : 0 )
439cdf0e10cSrcweir {
440cdf0e10cSrcweir case RES_ATTRSET_CHG:
441cdf0e10cSrcweir {
442cdf0e10cSrcweir SfxItemSet* pNewSet = ((SwAttrSetChg*)pNew)->GetChgSet();
443cdf0e10cSrcweir SfxItemSet* pOldSet = ((SwAttrSetChg*)pOld)->GetChgSet();
444cdf0e10cSrcweir const SfxPoolItem* pItem;
445cdf0e10cSrcweir
446cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
447cdf0e10cSrcweir RES_PROTECT, sal_False, &pItem ) )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir m_Data.SetProtectFlag( static_cast<SvxProtectItem const*>(pItem)
450cdf0e10cSrcweir ->IsCntntProtected() );
451cdf0e10cSrcweir pNewSet->ClearItem( RES_PROTECT );
452cdf0e10cSrcweir pOldSet->ClearItem( RES_PROTECT );
453cdf0e10cSrcweir }
454cdf0e10cSrcweir
455cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
456cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
457cdf0e10cSrcweir RES_EDIT_IN_READONLY, sal_False, &pItem ) )
458cdf0e10cSrcweir {
459cdf0e10cSrcweir m_Data.SetEditInReadonlyFlag(
460cdf0e10cSrcweir static_cast<SwFmtEditInReadonly const*>(pItem)->GetValue());
461cdf0e10cSrcweir pNewSet->ClearItem( RES_EDIT_IN_READONLY );
462cdf0e10cSrcweir pOldSet->ClearItem( RES_EDIT_IN_READONLY );
463cdf0e10cSrcweir }
464cdf0e10cSrcweir // <--
465cdf0e10cSrcweir
466cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
467cdf0e10cSrcweir RES_FTN_AT_TXTEND, sal_False, &pItem ) ||
468cdf0e10cSrcweir SFX_ITEM_SET == pNewSet->GetItemState(
469cdf0e10cSrcweir RES_END_AT_TXTEND, sal_False, &pItem ))
470cdf0e10cSrcweir {
471cdf0e10cSrcweir bUpdateFtn = true;
472cdf0e10cSrcweir }
473cdf0e10cSrcweir
474cdf0e10cSrcweir if( !pNewSet->Count() )
475cdf0e10cSrcweir return;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir break;
478cdf0e10cSrcweir
479cdf0e10cSrcweir case RES_PROTECT:
480cdf0e10cSrcweir if( pNew )
481cdf0e10cSrcweir {
482cdf0e10cSrcweir bool bNewFlag =
483cdf0e10cSrcweir static_cast<const SvxProtectItem*>(pNew)->IsCntntProtected();
484cdf0e10cSrcweir if( !bNewFlag )
485cdf0e10cSrcweir {
486cdf0e10cSrcweir // Abschalten: teste ob nicht vielleich ueber die Parents
487cdf0e10cSrcweir // doch ein Schutzt besteht!
488cdf0e10cSrcweir const SwSection* pSect = this;
489cdf0e10cSrcweir do {
490cdf0e10cSrcweir if( pSect->IsProtect() )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir bNewFlag = true;
493cdf0e10cSrcweir break;
494cdf0e10cSrcweir }
495cdf0e10cSrcweir pSect = pSect->GetParent();
496cdf0e10cSrcweir } while (pSect);
497cdf0e10cSrcweir }
498cdf0e10cSrcweir
499cdf0e10cSrcweir m_Data.SetProtectFlag( bNewFlag );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir return;
502cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
503cdf0e10cSrcweir case RES_EDIT_IN_READONLY:
504cdf0e10cSrcweir if( pNew )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir const bool bNewFlag =
507cdf0e10cSrcweir static_cast<const SwFmtEditInReadonly*>(pNew)->GetValue();
508cdf0e10cSrcweir m_Data.SetEditInReadonlyFlag( bNewFlag );
509cdf0e10cSrcweir }
510cdf0e10cSrcweir return;
511cdf0e10cSrcweir // <--
512cdf0e10cSrcweir
513cdf0e10cSrcweir case RES_SECTION_HIDDEN:
514cdf0e10cSrcweir m_Data.SetHiddenFlag(true);
515cdf0e10cSrcweir return;
516cdf0e10cSrcweir
517cdf0e10cSrcweir case RES_SECTION_NOT_HIDDEN:
518cdf0e10cSrcweir case RES_SECTION_RESETHIDDENFLAG:
519cdf0e10cSrcweir m_Data.SetHiddenFlag( m_Data.IsHidden() && m_Data.IsCondHidden() );
520cdf0e10cSrcweir return;
521cdf0e10cSrcweir
522cdf0e10cSrcweir case RES_COL:
523cdf0e10cSrcweir /* wird ggf. vom Layout erledigt */
524cdf0e10cSrcweir break;
525cdf0e10cSrcweir
526cdf0e10cSrcweir case RES_FTN_AT_TXTEND:
527cdf0e10cSrcweir if( pNew && pOld )
528cdf0e10cSrcweir {
529cdf0e10cSrcweir bUpdateFtn = true;
530cdf0e10cSrcweir }
531cdf0e10cSrcweir break;
532cdf0e10cSrcweir
533cdf0e10cSrcweir case RES_END_AT_TXTEND:
534cdf0e10cSrcweir if( pNew && pOld )
535cdf0e10cSrcweir {
536cdf0e10cSrcweir bUpdateFtn = true;
537cdf0e10cSrcweir }
538cdf0e10cSrcweir break;
539cdf0e10cSrcweir
540cdf0e10cSrcweir default:
541cdf0e10cSrcweir CheckRegistration( pOld, pNew );
542cdf0e10cSrcweir break;
543cdf0e10cSrcweir }
544cdf0e10cSrcweir
545cdf0e10cSrcweir if( bRemake )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir GetFmt()->DelFrms();
548cdf0e10cSrcweir GetFmt()->MakeFrms();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir
551cdf0e10cSrcweir if( bUpdateFtn )
552cdf0e10cSrcweir {
553cdf0e10cSrcweir SwSectionNode* pSectNd = GetFmt()->GetSectionNode( sal_False );
554cdf0e10cSrcweir if( pSectNd )
555cdf0e10cSrcweir pSectNd->GetDoc()->GetFtnIdxs().UpdateFtn(SwNodeIndex( *pSectNd ));
556cdf0e10cSrcweir }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir
SetRefObject(SwServerObject * pObj)559cdf0e10cSrcweir void SwSection::SetRefObject( SwServerObject* pObj )
560cdf0e10cSrcweir {
561cdf0e10cSrcweir m_RefObj = pObj;
562cdf0e10cSrcweir }
563cdf0e10cSrcweir
564cdf0e10cSrcweir
SetCondHidden(bool const bFlag)565cdf0e10cSrcweir void SwSection::SetCondHidden(bool const bFlag)
566cdf0e10cSrcweir {
567cdf0e10cSrcweir if (!m_Data.IsCondHidden() == !bFlag)
568cdf0e10cSrcweir return;
569cdf0e10cSrcweir
570cdf0e10cSrcweir m_Data.SetCondHidden(bFlag);
571cdf0e10cSrcweir ImplSetHiddenFlag(m_Data.IsHidden(), bFlag);
572cdf0e10cSrcweir }
573cdf0e10cSrcweir
574cdf0e10cSrcweir
575cdf0e10cSrcweir // setze/erfrage den gelinkten FileNamen
GetLinkFileName() const576cdf0e10cSrcweir const String& SwSection::GetLinkFileName() const
577cdf0e10cSrcweir {
578cdf0e10cSrcweir if (m_RefLink.Is())
579cdf0e10cSrcweir {
580cdf0e10cSrcweir String sTmp;
581cdf0e10cSrcweir switch (m_Data.GetType())
582cdf0e10cSrcweir {
583cdf0e10cSrcweir case DDE_LINK_SECTION:
584cdf0e10cSrcweir sTmp = m_RefLink->GetLinkSourceName();
585cdf0e10cSrcweir break;
586cdf0e10cSrcweir
587cdf0e10cSrcweir case FILE_LINK_SECTION:
588cdf0e10cSrcweir {
589cdf0e10cSrcweir String sRange, sFilter;
590cdf0e10cSrcweir if (m_RefLink->GetLinkManager() &&
591cdf0e10cSrcweir m_RefLink->GetLinkManager()->GetDisplayNames(
592cdf0e10cSrcweir m_RefLink, 0, &sTmp, &sRange, &sFilter ))
593cdf0e10cSrcweir {
594cdf0e10cSrcweir ( sTmp += sfx2::cTokenSeperator ) += sFilter;
595cdf0e10cSrcweir ( sTmp += sfx2::cTokenSeperator ) += sRange;
596cdf0e10cSrcweir }
597cdf0e10cSrcweir else if( GetFmt() && !GetFmt()->GetSectionNode() )
598cdf0e10cSrcweir {
599cdf0e10cSrcweir // ist die Section im UndoNodesArray, dann steht
600cdf0e10cSrcweir // der Link nicht im LinkManager, kann also auch nicht
601cdf0e10cSrcweir // erfragt werden. Dann returne den akt. Namen
602cdf0e10cSrcweir return m_Data.GetLinkFileName();
603cdf0e10cSrcweir }
604cdf0e10cSrcweir }
605cdf0e10cSrcweir break;
606cdf0e10cSrcweir default: break;
607cdf0e10cSrcweir }
608cdf0e10cSrcweir const_cast<SwSection*>(this)->m_Data.SetLinkFileName(sTmp);
609cdf0e10cSrcweir }
610cdf0e10cSrcweir return m_Data.GetLinkFileName();
611cdf0e10cSrcweir }
612cdf0e10cSrcweir
613cdf0e10cSrcweir
SetLinkFileName(const String & rNew,String const * const pPassWd)614cdf0e10cSrcweir void SwSection::SetLinkFileName(const String& rNew, String const*const pPassWd)
615cdf0e10cSrcweir {
616cdf0e10cSrcweir if (m_RefLink.Is())
617cdf0e10cSrcweir {
618cdf0e10cSrcweir m_RefLink->SetLinkSourceName( rNew );
619cdf0e10cSrcweir }
620cdf0e10cSrcweir m_Data.SetLinkFileName(rNew);
621cdf0e10cSrcweir if( pPassWd )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir SetLinkFilePassword( *pPassWd );
624cdf0e10cSrcweir }
625cdf0e10cSrcweir }
626cdf0e10cSrcweir
627cdf0e10cSrcweir // falls es ein gelinkter Bereich war, dann muessen alle
628cdf0e10cSrcweir // Child-Verknuepfungen sichtbar bemacht werden.
MakeChildLinksVisible(const SwSectionNode & rSectNd)629cdf0e10cSrcweir void SwSection::MakeChildLinksVisible( const SwSectionNode& rSectNd )
630cdf0e10cSrcweir {
631cdf0e10cSrcweir const SwNode* pNd;
632cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->GetLinkManager().GetLinks();
633cdf0e10cSrcweir for( sal_uInt16 n = rLnks.Count(); n; )
634cdf0e10cSrcweir {
635cdf0e10cSrcweir ::sfx2::SvBaseLink* pBLnk = &(*rLnks[ --n ]);
636cdf0e10cSrcweir if( pBLnk && !pBLnk->IsVisible() &&
637cdf0e10cSrcweir pBLnk->ISA( SwBaseLink ) &&
638cdf0e10cSrcweir 0 != ( pNd = ((SwBaseLink*)pBLnk)->GetAnchor() ) )
639cdf0e10cSrcweir {
640cdf0e10cSrcweir pNd = pNd->StartOfSectionNode(); // falls SectionNode ist!
641cdf0e10cSrcweir const SwSectionNode* pParent;
642cdf0e10cSrcweir while( 0 != ( pParent = pNd->FindSectionNode() ) &&
643cdf0e10cSrcweir ( CONTENT_SECTION == pParent->GetSection().GetType()
644cdf0e10cSrcweir || pNd == &rSectNd ))
645cdf0e10cSrcweir pNd = pParent->StartOfSectionNode();
646cdf0e10cSrcweir
647cdf0e10cSrcweir // steht nur noch in einer normalen Section, also
648cdf0e10cSrcweir // wieder anzeigen
649cdf0e10cSrcweir if( !pParent )
650cdf0e10cSrcweir pBLnk->SetVisible( sal_True );
651cdf0e10cSrcweir }
652cdf0e10cSrcweir }
653cdf0e10cSrcweir }
654cdf0e10cSrcweir
GetTOXBase() const655cdf0e10cSrcweir const SwTOXBase* SwSection::GetTOXBase() const
656cdf0e10cSrcweir {
657cdf0e10cSrcweir const SwTOXBase* pRet = 0;
658cdf0e10cSrcweir if( TOX_CONTENT_SECTION == GetType() )
659cdf0e10cSrcweir pRet = PTR_CAST( SwTOXBaseSection, this );
660cdf0e10cSrcweir return pRet;
661cdf0e10cSrcweir }
662cdf0e10cSrcweir
663cdf0e10cSrcweir // SwSectionFmt ========================================================
664cdf0e10cSrcweir
SwSectionFmt(SwSectionFmt * pDrvdFrm,SwDoc * pDoc)665cdf0e10cSrcweir SwSectionFmt::SwSectionFmt( SwSectionFmt* pDrvdFrm, SwDoc *pDoc )
666cdf0e10cSrcweir : SwFrmFmt( pDoc->GetAttrPool(), sSectionFmtNm, pDrvdFrm )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir LockModify();
669cdf0e10cSrcweir SetFmtAttr( *GetDfltAttr( RES_COL ) );
670cdf0e10cSrcweir UnlockModify();
671cdf0e10cSrcweir }
672cdf0e10cSrcweir
~SwSectionFmt()673cdf0e10cSrcweir SwSectionFmt::~SwSectionFmt()
674cdf0e10cSrcweir {
675cdf0e10cSrcweir if( !GetDoc()->IsInDtor() )
676cdf0e10cSrcweir {
677cdf0e10cSrcweir SwSectionNode* pSectNd;
678cdf0e10cSrcweir const SwNodeIndex* pIdx = GetCntnt( sal_False ).GetCntntIdx();
679cdf0e10cSrcweir if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
680cdf0e10cSrcweir 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
681cdf0e10cSrcweir {
682cdf0e10cSrcweir SwSection& rSect = pSectNd->GetSection();
683cdf0e10cSrcweir // falls es ein gelinkter Bereich war, dann muessen alle
684cdf0e10cSrcweir // Child-Verknuepfungen sichtbar bemacht werden.
685cdf0e10cSrcweir if( rSect.IsConnected() )
686cdf0e10cSrcweir rSect.MakeChildLinksVisible( *pSectNd );
687cdf0e10cSrcweir
688cdf0e10cSrcweir // vorm loeschen der Nodes pruefe, ob wir uns nicht
689cdf0e10cSrcweir // noch anzeigen muessen!
690cdf0e10cSrcweir if( rSect.IsHiddenFlag() )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir SwSectionPtr pParentSect = rSect.GetParent();
693cdf0e10cSrcweir if( !pParentSect || !pParentSect->IsHiddenFlag() )
694cdf0e10cSrcweir {
695cdf0e10cSrcweir // Nodes wieder anzeigen
696cdf0e10cSrcweir rSect.SetHidden(false);
697cdf0e10cSrcweir }
698cdf0e10cSrcweir }
699cdf0e10cSrcweir // mba: test iteration; objects are removed while iterating
700713b4dcdSMichael Stahl // --> OD #i117863#
701713b4dcdSMichael Stahl // use hint which allows to specify, if the content shall be saved or not
702713b4dcdSMichael Stahl CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_True ) );
703713b4dcdSMichael Stahl // <--
704cdf0e10cSrcweir
705cdf0e10cSrcweir // hebe die Section doch mal auf
706cdf0e10cSrcweir SwNodeRange aRg( *pSectNd, 0, *pSectNd->EndOfSectionNode() );
707cdf0e10cSrcweir GetDoc()->GetNodes().SectionUp( &aRg );
708cdf0e10cSrcweir }
709cdf0e10cSrcweir LockModify();
710cdf0e10cSrcweir ResetFmtAttr( RES_CNTNT );
711cdf0e10cSrcweir UnlockModify();
712cdf0e10cSrcweir }
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
715cdf0e10cSrcweir
GetSection() const716cdf0e10cSrcweir SwSection * SwSectionFmt::GetSection() const
717cdf0e10cSrcweir {
718cdf0e10cSrcweir return SwIterator<SwSection,SwSectionFmt>::FirstElement( *this );
719cdf0e10cSrcweir }
720cdf0e10cSrcweir
721cdf0e10cSrcweir extern void lcl_DeleteFtn( SwSectionNode *pNd, sal_uLong nStt, sal_uLong nEnd );
722cdf0e10cSrcweir
723cdf0e10cSrcweir //Vernichtet alle Frms in aDepend (Frms werden per PTR_CAST erkannt).
DelFrms()724cdf0e10cSrcweir void SwSectionFmt::DelFrms()
725cdf0e10cSrcweir {
726cdf0e10cSrcweir SwSectionNode* pSectNd;
727cdf0e10cSrcweir const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
728cdf0e10cSrcweir if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
729cdf0e10cSrcweir 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
730cdf0e10cSrcweir {
731cdf0e10cSrcweir // #147431# : First delete the <SwSectionFrm> of the <SwSectionFmt> instance
732cdf0e10cSrcweir // mba: test iteration as objects are removed in iteration
733713b4dcdSMichael Stahl // --> OD #i117863#
734713b4dcdSMichael Stahl // use hint which allows to specify, if the content shall be saved or not
735713b4dcdSMichael Stahl CallSwClientNotify( SwSectionFrmMoveAndDeleteHint( sal_False ) );
736713b4dcdSMichael Stahl // <--
737cdf0e10cSrcweir
738cdf0e10cSrcweir // Then delete frames of the nested <SwSectionFmt> instances
739cdf0e10cSrcweir SwIterator<SwSectionFmt,SwSectionFmt> aIter( *this );
740cdf0e10cSrcweir SwSectionFmt *pLast = aIter.First();
741cdf0e10cSrcweir while ( pLast )
742cdf0e10cSrcweir {
743cdf0e10cSrcweir pLast->DelFrms();
744cdf0e10cSrcweir pLast = aIter.Next();
745cdf0e10cSrcweir }
746cdf0e10cSrcweir
747cdf0e10cSrcweir sal_uLong nEnde = pSectNd->EndOfSectionIndex();
748cdf0e10cSrcweir sal_uLong nStart = pSectNd->GetIndex()+1;
749cdf0e10cSrcweir lcl_DeleteFtn( pSectNd, nStart, nEnde );
750cdf0e10cSrcweir }
751cdf0e10cSrcweir if( pIdx )
752cdf0e10cSrcweir {
753cdf0e10cSrcweir //JP 22.09.98:
754cdf0e10cSrcweir //Hint fuer Pagedesc versenden. Das mueste eigntlich das Layout im
755cdf0e10cSrcweir //Paste der Frames selbst erledigen, aber das fuehrt dann wiederum
756cdf0e10cSrcweir //zu weiteren Folgefehlern, die mit Laufzeitkosten geloest werden
757cdf0e10cSrcweir //muesten. #56977# #55001# #56135#
758cdf0e10cSrcweir SwNodeIndex aNextNd( *pIdx );
759cdf0e10cSrcweir SwCntntNode* pCNd = GetDoc()->GetNodes().GoNextSection( &aNextNd, sal_True, sal_False );
760cdf0e10cSrcweir if( pCNd )
761cdf0e10cSrcweir {
762cdf0e10cSrcweir const SfxPoolItem& rItem = pCNd->GetSwAttrSet().Get( RES_PAGEDESC );
763cdf0e10cSrcweir pCNd->ModifyNotification( (SfxPoolItem*)&rItem, (SfxPoolItem*)&rItem );
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir }
767cdf0e10cSrcweir
768cdf0e10cSrcweir
769cdf0e10cSrcweir //Erzeugt die Ansichten
MakeFrms()770cdf0e10cSrcweir void SwSectionFmt::MakeFrms()
771cdf0e10cSrcweir {
772cdf0e10cSrcweir SwSectionNode* pSectNd;
773cdf0e10cSrcweir const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
774cdf0e10cSrcweir
775cdf0e10cSrcweir if( pIdx && &GetDoc()->GetNodes() == &pIdx->GetNodes() &&
776cdf0e10cSrcweir 0 != (pSectNd = pIdx->GetNode().GetSectionNode() ))
777cdf0e10cSrcweir {
778cdf0e10cSrcweir SwNodeIndex aIdx( *pIdx );
779cdf0e10cSrcweir pSectNd->MakeFrms( &aIdx );
780cdf0e10cSrcweir }
781cdf0e10cSrcweir }
782cdf0e10cSrcweir
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)783cdf0e10cSrcweir void SwSectionFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
784cdf0e10cSrcweir {
785cdf0e10cSrcweir sal_Bool bClients = sal_False;
786cdf0e10cSrcweir sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
787cdf0e10cSrcweir switch( nWhich )
788cdf0e10cSrcweir {
789cdf0e10cSrcweir case RES_ATTRSET_CHG:
790cdf0e10cSrcweir if( GetDepends() )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir SfxItemSet* pNewSet = ((SwAttrSetChg*)pNew)->GetChgSet();
793cdf0e10cSrcweir SfxItemSet* pOldSet = ((SwAttrSetChg*)pOld)->GetChgSet();
794cdf0e10cSrcweir const SfxPoolItem *pItem;
795cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
796cdf0e10cSrcweir RES_PROTECT, sal_False, &pItem ))
797cdf0e10cSrcweir {
798cdf0e10cSrcweir ModifyBroadcast( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem );
799cdf0e10cSrcweir pNewSet->ClearItem( RES_PROTECT );
800cdf0e10cSrcweir pOldSet->ClearItem( RES_PROTECT );
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
803cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
804cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
805cdf0e10cSrcweir RES_EDIT_IN_READONLY, sal_False, &pItem ) )
806cdf0e10cSrcweir {
807cdf0e10cSrcweir ModifyBroadcast( (SfxPoolItem*)pItem, (SfxPoolItem*)pItem );
808cdf0e10cSrcweir pNewSet->ClearItem( RES_EDIT_IN_READONLY );
809cdf0e10cSrcweir pOldSet->ClearItem( RES_EDIT_IN_READONLY );
810cdf0e10cSrcweir }
811cdf0e10cSrcweir // <--
812cdf0e10cSrcweir
813cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
814cdf0e10cSrcweir RES_FTN_AT_TXTEND, sal_False, &pItem ))
815cdf0e10cSrcweir {
816cdf0e10cSrcweir ModifyBroadcast( (SfxPoolItem*)&pOldSet->Get( RES_FTN_AT_TXTEND ), (SfxPoolItem*)pItem );
817cdf0e10cSrcweir pNewSet->ClearItem( RES_FTN_AT_TXTEND );
818cdf0e10cSrcweir pOldSet->ClearItem( RES_FTN_AT_TXTEND );
819cdf0e10cSrcweir }
820cdf0e10cSrcweir if( SFX_ITEM_SET == pNewSet->GetItemState(
821cdf0e10cSrcweir RES_END_AT_TXTEND, sal_False, &pItem ))
822cdf0e10cSrcweir {
823cdf0e10cSrcweir ModifyBroadcast( (SfxPoolItem*)&pOldSet->Get( RES_END_AT_TXTEND ), (SfxPoolItem*)pItem );
824cdf0e10cSrcweir pNewSet->ClearItem( RES_END_AT_TXTEND );
825cdf0e10cSrcweir pOldSet->ClearItem( RES_END_AT_TXTEND );
826cdf0e10cSrcweir }
827cdf0e10cSrcweir if( !((SwAttrSetChg*)pOld)->GetChgSet()->Count() )
828cdf0e10cSrcweir return;
829cdf0e10cSrcweir }
830cdf0e10cSrcweir break;
831cdf0e10cSrcweir
832cdf0e10cSrcweir case RES_SECTION_RESETHIDDENFLAG:
833cdf0e10cSrcweir case RES_FTN_AT_TXTEND:
834cdf0e10cSrcweir case RES_END_AT_TXTEND : bClients = sal_True;
835cdf0e10cSrcweir // no break !!
836cdf0e10cSrcweir case RES_SECTION_HIDDEN:
837cdf0e10cSrcweir case RES_SECTION_NOT_HIDDEN:
838cdf0e10cSrcweir {
839cdf0e10cSrcweir SwSection* pSect = GetSection();
840cdf0e10cSrcweir if( pSect && ( bClients || ( RES_SECTION_HIDDEN == nWhich ?
841cdf0e10cSrcweir !pSect->IsHiddenFlag() : pSect->IsHiddenFlag() ) ) )
842cdf0e10cSrcweir {
843cdf0e10cSrcweir ModifyBroadcast( pOld, pNew );
844cdf0e10cSrcweir }
845cdf0e10cSrcweir }
846cdf0e10cSrcweir return ;
847cdf0e10cSrcweir
848cdf0e10cSrcweir
849cdf0e10cSrcweir case RES_PROTECT:
850cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
851cdf0e10cSrcweir case RES_EDIT_IN_READONLY:
852cdf0e10cSrcweir // <--
853cdf0e10cSrcweir // diese Messages bis zum Ende des Baums durchreichen !
854cdf0e10cSrcweir if( GetDepends() )
855cdf0e10cSrcweir {
856cdf0e10cSrcweir ModifyBroadcast( pOld, pNew );
857cdf0e10cSrcweir }
858cdf0e10cSrcweir return; // das wars
859cdf0e10cSrcweir
860cdf0e10cSrcweir case RES_OBJECTDYING:
861cdf0e10cSrcweir if( !GetDoc()->IsInDtor() &&
862cdf0e10cSrcweir ((SwPtrMsgPoolItem *)pOld)->pObject == (void*)GetRegisteredIn() )
863cdf0e10cSrcweir {
864cdf0e10cSrcweir // mein Parent wird vernichtet, dann an den Parent vom Parent
865cdf0e10cSrcweir // umhaengen und wieder aktualisieren
866cdf0e10cSrcweir SwFrmFmt::Modify( pOld, pNew ); // erst umhaengen !!!
867cdf0e10cSrcweir UpdateParent();
868cdf0e10cSrcweir return;
869cdf0e10cSrcweir }
870cdf0e10cSrcweir break;
871cdf0e10cSrcweir
872cdf0e10cSrcweir case RES_FMT_CHG:
873cdf0e10cSrcweir if( !GetDoc()->IsInDtor() &&
874cdf0e10cSrcweir ((SwFmtChg*)pNew)->pChangedFmt == (void*)GetRegisteredIn() &&
875cdf0e10cSrcweir ((SwFmtChg*)pNew)->pChangedFmt->IsA( TYPE( SwSectionFmt )) )
876cdf0e10cSrcweir {
877cdf0e10cSrcweir // mein Parent wird veraendert, muss mich aktualisieren
878cdf0e10cSrcweir SwFrmFmt::Modify( pOld, pNew ); // erst umhaengen !!!
879cdf0e10cSrcweir UpdateParent();
880cdf0e10cSrcweir return;
881cdf0e10cSrcweir }
882cdf0e10cSrcweir break;
883cdf0e10cSrcweir }
884cdf0e10cSrcweir SwFrmFmt::Modify( pOld, pNew );
885cdf0e10cSrcweir
886cdf0e10cSrcweir if (pOld && (RES_REMOVE_UNO_OBJECT == pOld->Which()))
887cdf0e10cSrcweir { // invalidate cached uno object
888cdf0e10cSrcweir SetXTextSection(uno::Reference<text::XTextSection>(0));
889cdf0e10cSrcweir }
890cdf0e10cSrcweir }
891cdf0e10cSrcweir
892cdf0e10cSrcweir // erfrage vom Format Informationen
GetInfo(SfxPoolItem & rInfo) const893cdf0e10cSrcweir sal_Bool SwSectionFmt::GetInfo( SfxPoolItem& rInfo ) const
894cdf0e10cSrcweir {
895cdf0e10cSrcweir switch( rInfo.Which() )
896cdf0e10cSrcweir {
897cdf0e10cSrcweir case RES_FINDNEARESTNODE:
898cdf0e10cSrcweir if( ((SwFmtPageDesc&)GetFmtAttr( RES_PAGEDESC )).GetPageDesc() )
899cdf0e10cSrcweir {
900cdf0e10cSrcweir const SwSectionNode* pNd = GetSectionNode();
901cdf0e10cSrcweir if( pNd )
902cdf0e10cSrcweir ((SwFindNearestNode&)rInfo).CheckNode( *pNd );
903cdf0e10cSrcweir }
904cdf0e10cSrcweir return sal_True;
905cdf0e10cSrcweir
906cdf0e10cSrcweir case RES_CONTENT_VISIBLE:
907cdf0e10cSrcweir {
908cdf0e10cSrcweir SwFrm* pFrm = SwIterator<SwFrm,SwFmt>::FirstElement(*this);
909cdf0e10cSrcweir // if the current section has no own frame search for the children
910cdf0e10cSrcweir if(!pFrm)
911cdf0e10cSrcweir {
912cdf0e10cSrcweir SwIterator<SwSectionFmt,SwSectionFmt> aFormatIter(*this);
913cdf0e10cSrcweir SwSectionFmt* pChild = aFormatIter.First();
914cdf0e10cSrcweir while(pChild && !pFrm)
915cdf0e10cSrcweir {
916cdf0e10cSrcweir pFrm = SwIterator<SwFrm,SwFmt>::FirstElement(*pChild);
917cdf0e10cSrcweir pChild = aFormatIter.Next();
918cdf0e10cSrcweir }
919cdf0e10cSrcweir }
920cdf0e10cSrcweir ((SwPtrMsgPoolItem&)rInfo).pObject = pFrm;
921cdf0e10cSrcweir }
922cdf0e10cSrcweir return sal_False;
923cdf0e10cSrcweir }
924cdf0e10cSrcweir return SwModify::GetInfo( rInfo );
925cdf0e10cSrcweir }
926cdf0e10cSrcweir
927cdf0e10cSrcweir extern "C" {
928cdf0e10cSrcweir
929cdf0e10cSrcweir int
930cdf0e10cSrcweir #if defined( WNT )
931cdf0e10cSrcweir __cdecl
932cdf0e10cSrcweir #endif
933cdf0e10cSrcweir #if defined( ICC )
934cdf0e10cSrcweir _Optlink
935cdf0e10cSrcweir #endif
lcl_SectionCmpPos(const void * pFirst,const void * pSecond)936cdf0e10cSrcweir lcl_SectionCmpPos( const void *pFirst, const void *pSecond)
937cdf0e10cSrcweir {
938cdf0e10cSrcweir const SwSectionFmt* pFSectFmt = (*(SwSectionPtr*)pFirst)->GetFmt();
939cdf0e10cSrcweir const SwSectionFmt* pSSectFmt = (*(SwSectionPtr*)pSecond)->GetFmt();
940cdf0e10cSrcweir ASSERT( pFSectFmt && pSSectFmt &&
941cdf0e10cSrcweir pFSectFmt->GetCntnt(sal_False).GetCntntIdx() &&
942cdf0e10cSrcweir pSSectFmt->GetCntnt(sal_False).GetCntntIdx(),
943cdf0e10cSrcweir "ungueltige Sections" );
944cdf0e10cSrcweir return (int)((long)pFSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex()) -
945cdf0e10cSrcweir pSSectFmt->GetCntnt(sal_False).GetCntntIdx()->GetIndex();
946cdf0e10cSrcweir }
947cdf0e10cSrcweir
948cdf0e10cSrcweir int
949cdf0e10cSrcweir #if defined( WNT )
950cdf0e10cSrcweir __cdecl
951cdf0e10cSrcweir #endif
952cdf0e10cSrcweir #if defined( ICC )
953cdf0e10cSrcweir _Optlink
954cdf0e10cSrcweir #endif
lcl_SectionCmpNm(const void * pFirst,const void * pSecond)955cdf0e10cSrcweir lcl_SectionCmpNm( const void *pFirst, const void *pSecond)
956cdf0e10cSrcweir {
957cdf0e10cSrcweir const SwSectionPtr pFSect = *(SwSectionPtr*)pFirst;
958cdf0e10cSrcweir const SwSectionPtr pSSect = *(SwSectionPtr*)pSecond;
959cdf0e10cSrcweir ASSERT( pFSect && pSSect, "ungueltige Sections" );
960cdf0e10cSrcweir StringCompare const eCmp =
961cdf0e10cSrcweir pFSect->GetSectionName().CompareTo( pSSect->GetSectionName() );
962cdf0e10cSrcweir return eCmp == COMPARE_EQUAL ? 0
963cdf0e10cSrcweir : eCmp == COMPARE_LESS ? 1 : -1;
964cdf0e10cSrcweir }
965cdf0e10cSrcweir }
966cdf0e10cSrcweir
967cdf0e10cSrcweir // alle Sections, die von dieser abgeleitet sind
GetChildSections(SwSections & rArr,SectionSort eSort,sal_Bool bAllSections) const968cdf0e10cSrcweir sal_uInt16 SwSectionFmt::GetChildSections( SwSections& rArr,
969cdf0e10cSrcweir SectionSort eSort,
970cdf0e10cSrcweir sal_Bool bAllSections ) const
971cdf0e10cSrcweir {
972cdf0e10cSrcweir rArr.Remove( 0, rArr.Count() );
973cdf0e10cSrcweir
974cdf0e10cSrcweir if( GetDepends() )
975cdf0e10cSrcweir {
976cdf0e10cSrcweir SwIterator<SwSectionFmt,SwSectionFmt> aIter(*this);
977cdf0e10cSrcweir const SwNodeIndex* pIdx;
978cdf0e10cSrcweir for( SwSectionFmt* pLast = aIter.First(); pLast; pLast = aIter.Next() )
979cdf0e10cSrcweir if( bAllSections ||
980cdf0e10cSrcweir ( 0 != ( pIdx = pLast->GetCntnt(sal_False).
981cdf0e10cSrcweir GetCntntIdx()) && &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
982cdf0e10cSrcweir {
983cdf0e10cSrcweir const SwSection* Dummy = pLast->GetSection();
984cdf0e10cSrcweir rArr.C40_INSERT( SwSection,
985cdf0e10cSrcweir Dummy,
986cdf0e10cSrcweir rArr.Count() );
987cdf0e10cSrcweir }
988cdf0e10cSrcweir
989cdf0e10cSrcweir // noch eine Sortierung erwuenscht ?
990cdf0e10cSrcweir if( 1 < rArr.Count() )
991cdf0e10cSrcweir switch( eSort )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir case SORTSECT_NAME:
994cdf0e10cSrcweir qsort( (void*)rArr.GetData(),
995cdf0e10cSrcweir rArr.Count(),
996cdf0e10cSrcweir sizeof( SwSectionPtr ),
997cdf0e10cSrcweir lcl_SectionCmpNm );
998cdf0e10cSrcweir break;
999cdf0e10cSrcweir
1000cdf0e10cSrcweir case SORTSECT_POS:
1001cdf0e10cSrcweir qsort( (void*)rArr.GetData(),
1002cdf0e10cSrcweir rArr.Count(),
1003cdf0e10cSrcweir sizeof( SwSectionPtr ),
1004cdf0e10cSrcweir lcl_SectionCmpPos );
1005cdf0e10cSrcweir break;
1006cdf0e10cSrcweir case SORTSECT_NOT: break;
1007cdf0e10cSrcweir }
1008cdf0e10cSrcweir }
1009cdf0e10cSrcweir return rArr.Count();
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir
1012cdf0e10cSrcweir // erfrage, ob sich die Section im Nodes-Array oder UndoNodes-Array
1013cdf0e10cSrcweir // befindet.
IsInNodesArr() const1014cdf0e10cSrcweir sal_Bool SwSectionFmt::IsInNodesArr() const
1015cdf0e10cSrcweir {
1016cdf0e10cSrcweir const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
1017cdf0e10cSrcweir return pIdx && &pIdx->GetNodes() == &GetDoc()->GetNodes();
1018cdf0e10cSrcweir }
1019cdf0e10cSrcweir
1020cdf0e10cSrcweir
UpdateParent()1021cdf0e10cSrcweir void SwSectionFmt::UpdateParent() // Parent wurde veraendert
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir if( !GetDepends() )
1024cdf0e10cSrcweir return;
1025cdf0e10cSrcweir
1026cdf0e10cSrcweir SwSectionPtr pSection = 0;
1027cdf0e10cSrcweir const SvxProtectItem* pProtect(0);
1028cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1029cdf0e10cSrcweir const SwFmtEditInReadonly* pEditInReadonly = 0;
1030cdf0e10cSrcweir // <--
1031cdf0e10cSrcweir bool bIsHidden = false;
1032cdf0e10cSrcweir
1033cdf0e10cSrcweir SwClientIter aIter( *this ); // TODO
1034cdf0e10cSrcweir ::SwClient * pLast = aIter.GoStart();
1035cdf0e10cSrcweir if( pLast ) // konnte zum Anfang gesprungen werden ??
1036cdf0e10cSrcweir do {
1037cdf0e10cSrcweir if( pLast->IsA( TYPE(SwSectionFmt) ) )
1038cdf0e10cSrcweir {
1039cdf0e10cSrcweir if( !pSection )
1040cdf0e10cSrcweir {
1041cdf0e10cSrcweir pSection = GetSection();
1042cdf0e10cSrcweir if( GetRegisteredIn() )
1043cdf0e10cSrcweir {
1044cdf0e10cSrcweir const SwSectionPtr pPS = GetParentSection();
1045cdf0e10cSrcweir pProtect = &pPS->GetFmt()->GetProtect();
1046cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1047cdf0e10cSrcweir pEditInReadonly = &pPS->GetFmt()->GetEditInReadonly();
1048cdf0e10cSrcweir // <--
1049cdf0e10cSrcweir bIsHidden = pPS->IsHiddenFlag();
1050cdf0e10cSrcweir }
1051cdf0e10cSrcweir else
1052cdf0e10cSrcweir {
1053cdf0e10cSrcweir pProtect = &GetProtect();
1054cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1055cdf0e10cSrcweir pEditInReadonly = &GetEditInReadonly();
1056cdf0e10cSrcweir // <--
1057cdf0e10cSrcweir bIsHidden = pSection->IsHidden();
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir }
1060cdf0e10cSrcweir if (!pProtect->IsCntntProtected() !=
1061cdf0e10cSrcweir !pSection->IsProtectFlag())
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir pLast->ModifyNotification( (SfxPoolItem*)pProtect,
1064cdf0e10cSrcweir (SfxPoolItem*)pProtect );
1065cdf0e10cSrcweir }
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1068cdf0e10cSrcweir if (!pEditInReadonly->GetValue() !=
1069cdf0e10cSrcweir !pSection->IsEditInReadonlyFlag())
1070cdf0e10cSrcweir {
1071cdf0e10cSrcweir pLast->ModifyNotification( (SfxPoolItem*)pEditInReadonly,
1072cdf0e10cSrcweir (SfxPoolItem*)pEditInReadonly );
1073cdf0e10cSrcweir }
1074cdf0e10cSrcweir // <--
1075cdf0e10cSrcweir
1076cdf0e10cSrcweir if( bIsHidden == pSection->IsHiddenFlag() )
1077cdf0e10cSrcweir {
1078cdf0e10cSrcweir SwMsgPoolItem aMsgItem( static_cast<sal_uInt16>(bIsHidden
1079cdf0e10cSrcweir ? RES_SECTION_HIDDEN
1080cdf0e10cSrcweir : RES_SECTION_NOT_HIDDEN ) );
1081cdf0e10cSrcweir pLast->ModifyNotification( &aMsgItem, &aMsgItem );
1082cdf0e10cSrcweir }
1083cdf0e10cSrcweir }
1084cdf0e10cSrcweir else if( !pSection &&
1085cdf0e10cSrcweir pLast->IsA( TYPE(SwSection) ) )
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir pSection = (SwSectionPtr)pLast;
1088cdf0e10cSrcweir if( GetRegisteredIn() )
1089cdf0e10cSrcweir {
1090cdf0e10cSrcweir const SwSectionPtr pPS = GetParentSection();
1091cdf0e10cSrcweir pProtect = &pPS->GetFmt()->GetProtect();
1092cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1093cdf0e10cSrcweir pEditInReadonly = &pPS->GetFmt()->GetEditInReadonly();
1094cdf0e10cSrcweir // <--
1095cdf0e10cSrcweir bIsHidden = pPS->IsHiddenFlag();
1096cdf0e10cSrcweir }
1097cdf0e10cSrcweir else
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir pProtect = &GetProtect();
1100cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1101cdf0e10cSrcweir pEditInReadonly = &GetEditInReadonly();
1102cdf0e10cSrcweir // <--
1103cdf0e10cSrcweir bIsHidden = pSection->IsHidden();
1104cdf0e10cSrcweir }
1105cdf0e10cSrcweir }
11062f121198SMathias Bauer } while( 0 != ( pLast = ++aIter ));
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir
GetSectionNode(bool const bAlways)1110cdf0e10cSrcweir SwSectionNode* SwSectionFmt::GetSectionNode(bool const bAlways)
1111cdf0e10cSrcweir {
1112cdf0e10cSrcweir const SwNodeIndex* pIdx = GetCntnt(sal_False).GetCntntIdx();
1113cdf0e10cSrcweir if( pIdx && ( bAlways || &pIdx->GetNodes() == &GetDoc()->GetNodes() ))
1114cdf0e10cSrcweir return pIdx->GetNode().GetSectionNode();
1115cdf0e10cSrcweir return 0;
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir // ist die Section eine gueltige fuers GlobalDocument?
GetGlobalDocSection() const1119cdf0e10cSrcweir const SwSection* SwSectionFmt::GetGlobalDocSection() const
1120cdf0e10cSrcweir {
1121cdf0e10cSrcweir const SwSectionNode* pNd = GetSectionNode();
1122cdf0e10cSrcweir if( pNd &&
1123cdf0e10cSrcweir ( FILE_LINK_SECTION == pNd->GetSection().GetType() ||
1124cdf0e10cSrcweir TOX_CONTENT_SECTION == pNd->GetSection().GetType() ) &&
1125cdf0e10cSrcweir pNd->GetIndex() > pNd->GetNodes().GetEndOfExtras().GetIndex() &&
1126cdf0e10cSrcweir !pNd->StartOfSectionNode()->IsSectionNode() &&
1127cdf0e10cSrcweir !pNd->StartOfSectionNode()->FindSectionNode() )
1128cdf0e10cSrcweir return &pNd->GetSection();
1129cdf0e10cSrcweir return 0;
1130cdf0e10cSrcweir }
1131cdf0e10cSrcweir
1132cdf0e10cSrcweir // sw::Metadatable
GetRegistry()1133cdf0e10cSrcweir ::sfx2::IXmlIdRegistry& SwSectionFmt::GetRegistry()
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir return GetDoc()->GetXmlIdRegistry();
1136cdf0e10cSrcweir }
1137cdf0e10cSrcweir
IsInClipboard() const1138cdf0e10cSrcweir bool SwSectionFmt::IsInClipboard() const
1139cdf0e10cSrcweir {
1140cdf0e10cSrcweir return GetDoc()->IsClipBoard();
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir
IsInUndo() const1143cdf0e10cSrcweir bool SwSectionFmt::IsInUndo() const
1144cdf0e10cSrcweir {
1145cdf0e10cSrcweir return !IsInNodesArr();
1146cdf0e10cSrcweir }
1147cdf0e10cSrcweir
IsInContent() const1148cdf0e10cSrcweir bool SwSectionFmt::IsInContent() const
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir SwNodeIndex const*const pIdx = GetCntnt(sal_False).GetCntntIdx();
1151cdf0e10cSrcweir OSL_ENSURE(pIdx, "SwSectionFmt::IsInContent: no index?");
1152cdf0e10cSrcweir return (pIdx) ? !GetDoc()->IsInHeaderFooter(*pIdx) : true;
1153cdf0e10cSrcweir }
1154cdf0e10cSrcweir
1155cdf0e10cSrcweir // n.b.: if the section format represents an index, then there is both a
1156cdf0e10cSrcweir // SwXDocumentIndex and a SwXTextSection instance for this single core object.
1157cdf0e10cSrcweir // these two can both implement XMetadatable and forward to the same core
1158cdf0e10cSrcweir // section format. but here only one UNO object can be returned,
1159cdf0e10cSrcweir // so always return the text section.
1160cdf0e10cSrcweir uno::Reference< rdf::XMetadatable >
MakeUnoObject()1161cdf0e10cSrcweir SwSectionFmt::MakeUnoObject()
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir uno::Reference<rdf::XMetadatable> xMeta;
1164cdf0e10cSrcweir SwSection *const pSection( GetSection() );
1165cdf0e10cSrcweir if (pSection)
1166cdf0e10cSrcweir {
1167cdf0e10cSrcweir xMeta.set( SwXTextSection::CreateXTextSection(this,
1168cdf0e10cSrcweir TOX_HEADER_SECTION == pSection->GetType()),
1169cdf0e10cSrcweir uno::UNO_QUERY );
1170cdf0e10cSrcweir }
1171cdf0e10cSrcweir return xMeta;
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir
1174cdf0e10cSrcweir
1175cdf0e10cSrcweir // --> OD 2007-02-14 #b6521322#
1176cdf0e10cSrcweir // Method to break section links inside a linked section
lcl_BreakSectionLinksInSect(const SwSectionNode & rSectNd)1177cdf0e10cSrcweir void lcl_BreakSectionLinksInSect( const SwSectionNode& rSectNd )
1178cdf0e10cSrcweir {
1179cdf0e10cSrcweir if ( !rSectNd.GetDoc() )
1180cdf0e10cSrcweir {
1181cdf0e10cSrcweir ASSERT( false,
1182cdf0e10cSrcweir "method <lcl_RemoveSectionLinksInSect(..)> - no Doc at SectionNode" );
1183cdf0e10cSrcweir return;
1184cdf0e10cSrcweir }
1185cdf0e10cSrcweir
1186cdf0e10cSrcweir if ( !rSectNd.GetSection().IsConnected() )
1187cdf0e10cSrcweir {
1188cdf0e10cSrcweir ASSERT( false,
1189cdf0e10cSrcweir "method <lcl_RemoveSectionLinksInSect(..)> - no Link at Section of SectionNode" );
1190cdf0e10cSrcweir return;
1191cdf0e10cSrcweir }
1192cdf0e10cSrcweir const ::sfx2::SvBaseLink* pOwnLink( &(rSectNd.GetSection().GetBaseLink() ) );
1193cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLnks = rSectNd.GetDoc()->GetLinkManager().GetLinks();
1194cdf0e10cSrcweir for ( sal_uInt16 n = rLnks.Count(); n > 0; )
1195cdf0e10cSrcweir {
1196cdf0e10cSrcweir SwIntrnlSectRefLink* pSectLnk = dynamic_cast<SwIntrnlSectRefLink*>(&(*rLnks[ --n ]));
1197cdf0e10cSrcweir if ( pSectLnk && pSectLnk != pOwnLink &&
1198cdf0e10cSrcweir pSectLnk->IsInRange( rSectNd.GetIndex(), rSectNd.EndOfSectionIndex() ) )
1199cdf0e10cSrcweir {
1200cdf0e10cSrcweir // break the link of the corresponding section.
1201cdf0e10cSrcweir // the link is also removed from the link manager
1202cdf0e10cSrcweir pSectLnk->GetSectNode()->GetSection().BreakLink();
1203cdf0e10cSrcweir
1204cdf0e10cSrcweir // for robustness, because link is removed from the link manager
1205cdf0e10cSrcweir if ( n > rLnks.Count() )
1206cdf0e10cSrcweir {
1207cdf0e10cSrcweir n = rLnks.Count();
1208cdf0e10cSrcweir }
1209cdf0e10cSrcweir }
1210cdf0e10cSrcweir }
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir // <--
1213cdf0e10cSrcweir
lcl_UpdateLinksInSect(SwBaseLink & rUpdLnk,SwSectionNode & rSectNd)1214cdf0e10cSrcweir void lcl_UpdateLinksInSect( SwBaseLink& rUpdLnk, SwSectionNode& rSectNd )
1215cdf0e10cSrcweir {
1216cdf0e10cSrcweir SwDoc* pDoc = rSectNd.GetDoc();
1217cdf0e10cSrcweir SwDocShell* pDShell = pDoc->GetDocShell();
1218cdf0e10cSrcweir if( !pDShell || !pDShell->GetMedium() )
1219cdf0e10cSrcweir return ;
1220cdf0e10cSrcweir
1221cdf0e10cSrcweir String sName( pDShell->GetMedium()->GetName() );
1222cdf0e10cSrcweir SwBaseLink* pBLink;
1223cdf0e10cSrcweir String sMimeType( SotExchange::GetFormatMimeType( FORMAT_FILE ));
1224cdf0e10cSrcweir uno::Any aValue;
1225cdf0e10cSrcweir aValue <<= ::rtl::OUString( sName ); // beliebiger Name
1226cdf0e10cSrcweir
1227cdf0e10cSrcweir const ::sfx2::SvBaseLinks& rLnks = pDoc->GetLinkManager().GetLinks();
1228cdf0e10cSrcweir for( sal_uInt16 n = rLnks.Count(); n; )
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir ::sfx2::SvBaseLink* pLnk = &(*rLnks[ --n ]);
1231cdf0e10cSrcweir if( pLnk && pLnk != &rUpdLnk &&
1232cdf0e10cSrcweir OBJECT_CLIENT_FILE == pLnk->GetObjType() &&
1233cdf0e10cSrcweir pLnk->ISA( SwBaseLink ) &&
1234cdf0e10cSrcweir ( pBLink = (SwBaseLink*)pLnk )->IsInRange( rSectNd.GetIndex(),
1235cdf0e10cSrcweir rSectNd.EndOfSectionIndex() ) )
1236cdf0e10cSrcweir {
1237cdf0e10cSrcweir // liegt in dem Bereich: also updaten. Aber nur wenns nicht
1238cdf0e10cSrcweir // im gleichen File liegt
1239cdf0e10cSrcweir String sFName;
1240cdf0e10cSrcweir pDoc->GetLinkManager().GetDisplayNames( pBLink, 0, &sFName, 0, 0 );
1241cdf0e10cSrcweir if( sFName != sName )
1242cdf0e10cSrcweir {
1243cdf0e10cSrcweir pBLink->DataChanged( sMimeType, aValue );
1244cdf0e10cSrcweir
1245cdf0e10cSrcweir // ggfs. neu den Link-Pointer wieder suchen, damit nicht einer
1246cdf0e10cSrcweir // ausgelassen oder doppelt gerufen wird.
1247cdf0e10cSrcweir if( n >= rLnks.Count() && 0 != ( n = rLnks.Count() ))
1248cdf0e10cSrcweir --n;
1249cdf0e10cSrcweir
1250cdf0e10cSrcweir if( n && pLnk != &(*rLnks[ n ]) )
1251cdf0e10cSrcweir {
1252cdf0e10cSrcweir // suchen - kann nur davor liegen!!
1253cdf0e10cSrcweir while( n )
1254cdf0e10cSrcweir if( pLnk == &(*rLnks[ --n ] ) )
1255cdf0e10cSrcweir break;
1256cdf0e10cSrcweir }
1257cdf0e10cSrcweir }
1258cdf0e10cSrcweir }
1259cdf0e10cSrcweir }
1260cdf0e10cSrcweir }
1261cdf0e10cSrcweir
1262cdf0e10cSrcweir
1263cdf0e10cSrcweir // sucht sich die richtige DocShell raus oder erzeugt eine neue:
1264cdf0e10cSrcweir // Der Return-Wert gibt an, was mit der Shell zu geschehen hat:
1265cdf0e10cSrcweir // 0 - Fehler, konnte DocShell nicht finden
1266cdf0e10cSrcweir // 1 - DocShell ist ein existieren Document
1267cdf0e10cSrcweir // 2 - DocShell wurde neu angelegt, muss also wieder geschlossen werden ( will be assigned to xLockRef additionaly )
1268cdf0e10cSrcweir
lcl_FindDocShell(SfxObjectShellRef & xDocSh,SfxObjectShellLock & xLockRef,const String & rFileName,const String & rPasswd,String & rFilter,sal_Int16 nVersion,SwDocShell * pDestSh)1269cdf0e10cSrcweir int lcl_FindDocShell( SfxObjectShellRef& xDocSh,
1270cdf0e10cSrcweir SfxObjectShellLock& xLockRef,
1271cdf0e10cSrcweir const String& rFileName,
1272cdf0e10cSrcweir const String& rPasswd,
1273cdf0e10cSrcweir String& rFilter,
1274cdf0e10cSrcweir sal_Int16 nVersion,
1275cdf0e10cSrcweir SwDocShell* pDestSh )
1276cdf0e10cSrcweir {
1277cdf0e10cSrcweir if( !rFileName.Len() )
1278cdf0e10cSrcweir return 0;
1279cdf0e10cSrcweir
1280cdf0e10cSrcweir // 1. existiert die Datei schon in der Liste aller Dokumente?
1281cdf0e10cSrcweir INetURLObject aTmpObj( rFileName );
1282cdf0e10cSrcweir aTmpObj.SetMark( aEmptyStr );
1283cdf0e10cSrcweir
1284cdf0e10cSrcweir // erstmal nur ueber die DocumentShells laufen und die mit dem
1285cdf0e10cSrcweir // Namen heraussuchen:
1286cdf0e10cSrcweir TypeId aType( TYPE(SwDocShell) );
1287cdf0e10cSrcweir
1288cdf0e10cSrcweir SfxObjectShell* pShell = pDestSh;
1289cdf0e10cSrcweir sal_Bool bFirst = 0 != pShell;
1290cdf0e10cSrcweir
1291cdf0e10cSrcweir if( !bFirst )
1292cdf0e10cSrcweir // keine DocShell uebergeben, also beginne mit der ersten aus der
1293cdf0e10cSrcweir // DocShell Liste
1294cdf0e10cSrcweir pShell = SfxObjectShell::GetFirst( &aType );
1295cdf0e10cSrcweir
1296cdf0e10cSrcweir while( pShell )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir // die wollen wir haben
1299cdf0e10cSrcweir SfxMedium* pMed = pShell->GetMedium();
1300cdf0e10cSrcweir if( pMed && pMed->GetURLObject() == aTmpObj )
1301cdf0e10cSrcweir {
1302cdf0e10cSrcweir const SfxPoolItem* pItem;
1303cdf0e10cSrcweir if( ( SFX_ITEM_SET == pMed->GetItemSet()->GetItemState(
1304cdf0e10cSrcweir SID_VERSION, sal_False, &pItem ) )
1305cdf0e10cSrcweir ? (nVersion == ((SfxInt16Item*)pItem)->GetValue())
1306cdf0e10cSrcweir : !nVersion )
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir // gefunden also returnen
1309cdf0e10cSrcweir xDocSh = pShell;
1310cdf0e10cSrcweir return 1;
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir
1314cdf0e10cSrcweir if( bFirst )
1315cdf0e10cSrcweir {
1316cdf0e10cSrcweir bFirst = sal_False;
1317cdf0e10cSrcweir pShell = SfxObjectShell::GetFirst( &aType );
1318cdf0e10cSrcweir }
1319cdf0e10cSrcweir else
1320cdf0e10cSrcweir pShell = SfxObjectShell::GetNext( *pShell, &aType );
1321cdf0e10cSrcweir }
1322cdf0e10cSrcweir
1323cdf0e10cSrcweir // 2. selbst die Date oeffnen
1324cdf0e10cSrcweir SfxMedium* pMed = new SfxMedium( aTmpObj.GetMainURL(
1325cdf0e10cSrcweir INetURLObject::NO_DECODE ), STREAM_READ, sal_True );
1326cdf0e10cSrcweir if( INET_PROT_FILE == aTmpObj.GetProtocol() )
1327cdf0e10cSrcweir pMed->DownLoad(); // nur mal das Medium anfassen (DownLoaden)
1328cdf0e10cSrcweir
1329cdf0e10cSrcweir const SfxFilter* pSfxFlt = 0;
1330cdf0e10cSrcweir if( !pMed->GetError() )
1331cdf0e10cSrcweir {
1332cdf0e10cSrcweir String sFactory(String::CreateFromAscii(SwDocShell::Factory().GetShortName()));
1333cdf0e10cSrcweir SfxFilterMatcher aMatcher( sFactory );
1334cdf0e10cSrcweir
1335cdf0e10cSrcweir // kein Filter, dann suche ihn. Ansonsten teste, ob der angegebene
1336cdf0e10cSrcweir // ein gueltiger ist
1337cdf0e10cSrcweir if( rFilter.Len() )
1338cdf0e10cSrcweir {
1339cdf0e10cSrcweir pSfxFlt = aMatcher.GetFilter4FilterName( rFilter );
1340cdf0e10cSrcweir }
1341cdf0e10cSrcweir
1342cdf0e10cSrcweir if( nVersion )
1343cdf0e10cSrcweir pMed->GetItemSet()->Put( SfxInt16Item( SID_VERSION, nVersion ));
1344cdf0e10cSrcweir
1345cdf0e10cSrcweir if( rPasswd.Len() )
1346cdf0e10cSrcweir pMed->GetItemSet()->Put( SfxStringItem( SID_PASSWORD, rPasswd ));
1347cdf0e10cSrcweir
1348cdf0e10cSrcweir if( !pSfxFlt )
1349cdf0e10cSrcweir aMatcher.DetectFilter( *pMed, &pSfxFlt, sal_False, sal_False );
1350cdf0e10cSrcweir
1351cdf0e10cSrcweir if( pSfxFlt )
1352cdf0e10cSrcweir {
1353cdf0e10cSrcweir // ohne Filter geht gar nichts
1354cdf0e10cSrcweir pMed->SetFilter( pSfxFlt );
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir // if the new shell is created, SfxObjectShellLock should be used to let it be closed later for sure
1357cdf0e10cSrcweir xLockRef = new SwDocShell( SFX_CREATE_MODE_INTERNAL );
1358cdf0e10cSrcweir xDocSh = (SfxObjectShell*)xLockRef;
1359cdf0e10cSrcweir if( xDocSh->DoLoad( pMed ) )
1360cdf0e10cSrcweir return 2;
1361cdf0e10cSrcweir }
1362cdf0e10cSrcweir }
1363cdf0e10cSrcweir
1364cdf0e10cSrcweir if( !xDocSh.Is() ) // Medium muss noch geloescht werden
1365cdf0e10cSrcweir delete pMed;
1366cdf0e10cSrcweir
1367cdf0e10cSrcweir return 0; // das war wohl nichts
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir
1370cdf0e10cSrcweir
DataChanged(const String & rMimeType,const uno::Any & rValue)1371cdf0e10cSrcweir void SwIntrnlSectRefLink::DataChanged( const String& rMimeType,
1372cdf0e10cSrcweir const uno::Any & rValue )
1373cdf0e10cSrcweir {
1374cdf0e10cSrcweir SwSectionNode* pSectNd = rSectFmt.GetSectionNode( sal_False );
1375cdf0e10cSrcweir SwDoc* pDoc = rSectFmt.GetDoc();
1376cdf0e10cSrcweir
1377cdf0e10cSrcweir sal_uLong nDataFormat = SotExchange::GetFormatIdFromMimeType( rMimeType );
1378cdf0e10cSrcweir
1379cdf0e10cSrcweir if( !pSectNd || !pDoc || pDoc->IsInDtor() || ChkNoDataFlag() ||
1380cdf0e10cSrcweir sfx2::LinkManager::RegisterStatusInfoId() == nDataFormat )
1381cdf0e10cSrcweir {
1382cdf0e10cSrcweir // sollten wir schon wieder im Undo stehen?
1383cdf0e10cSrcweir return ;
1384cdf0e10cSrcweir }
1385cdf0e10cSrcweir
1386cdf0e10cSrcweir // --> OD 2005-02-11 #i38810# - Due to possible existing signatures, the
1387cdf0e10cSrcweir // document has to be modified after updating a link.
1388cdf0e10cSrcweir pDoc->SetModified();
1389cdf0e10cSrcweir // set additional flag that links have been updated, in order to check this
1390cdf0e10cSrcweir // during load.
1391cdf0e10cSrcweir pDoc->SetLinksUpdated( sal_True );
1392cdf0e10cSrcweir // <--
1393cdf0e10cSrcweir
1394cdf0e10cSrcweir // Undo immer abschalten
1395cdf0e10cSrcweir bool const bWasUndo = pDoc->GetIDocumentUndoRedo().DoesUndo();
1396cdf0e10cSrcweir pDoc->GetIDocumentUndoRedo().DoUndo(false);
1397cdf0e10cSrcweir sal_Bool bWasVisibleLinks = pDoc->IsVisibleLinks();
1398cdf0e10cSrcweir pDoc->SetVisibleLinks( sal_False );
1399cdf0e10cSrcweir
1400cdf0e10cSrcweir SwPaM* pPam;
1401cdf0e10cSrcweir ViewShell* pVSh = 0;
1402cdf0e10cSrcweir SwEditShell* pESh = pDoc->GetEditShell( &pVSh );
1403cdf0e10cSrcweir pDoc->LockExpFlds();
1404cdf0e10cSrcweir {
1405cdf0e10cSrcweir // am Anfang des Bereichs einen leeren TextNode einfuegen
1406cdf0e10cSrcweir SwNodeIndex aIdx( *pSectNd, +1 );
1407cdf0e10cSrcweir SwNodeIndex aEndIdx( *pSectNd->EndOfSectionNode() );
1408cdf0e10cSrcweir SwTxtNode* pNewNd = pDoc->GetNodes().MakeTxtNode( aIdx,
1409cdf0e10cSrcweir pDoc->GetTxtCollFromPool( RES_POOLCOLL_TEXT ) );
1410cdf0e10cSrcweir
1411cdf0e10cSrcweir if( pESh )
1412cdf0e10cSrcweir pESh->StartAllAction();
1413cdf0e10cSrcweir else if( pVSh )
1414cdf0e10cSrcweir pVSh->StartAction();
1415cdf0e10cSrcweir
1416cdf0e10cSrcweir SwPosition aPos( aIdx, SwIndex( pNewNd, 0 ));
1417cdf0e10cSrcweir aPos.nNode--;
1418cdf0e10cSrcweir pDoc->CorrAbs( aIdx, aEndIdx, aPos, sal_True );
1419cdf0e10cSrcweir
1420cdf0e10cSrcweir pPam = new SwPaM( aPos );
1421cdf0e10cSrcweir
1422cdf0e10cSrcweir //und alles dahinter liegende loeschen
1423cdf0e10cSrcweir aIdx--;
1424cdf0e10cSrcweir DelFlyInRange( aIdx, aEndIdx );
1425cdf0e10cSrcweir _DelBookmarks(aIdx, aEndIdx);
1426cdf0e10cSrcweir aIdx++;
1427cdf0e10cSrcweir
1428cdf0e10cSrcweir pDoc->GetNodes().Delete( aIdx, aEndIdx.GetIndex() - aIdx.GetIndex() );
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir SwSection& rSection = pSectNd->GetSection();
1432cdf0e10cSrcweir rSection.SetConnectFlag(false);
1433cdf0e10cSrcweir
1434cdf0e10cSrcweir ::rtl::OUString sNewFileName;
1435cdf0e10cSrcweir Reader* pRead = 0;
1436cdf0e10cSrcweir switch( nDataFormat )
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir case FORMAT_STRING:
1439cdf0e10cSrcweir pRead = ReadAscii;
1440cdf0e10cSrcweir break;
1441cdf0e10cSrcweir
1442cdf0e10cSrcweir case FORMAT_RTF:
1443cdf0e10cSrcweir pRead = SwReaderWriter::GetReader( READER_WRITER_RTF );
1444cdf0e10cSrcweir break;
1445cdf0e10cSrcweir
1446cdf0e10cSrcweir case FORMAT_FILE:
1447cdf0e10cSrcweir if( rValue.hasValue() && ( rValue >>= sNewFileName ) )
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir String sFilter, sRange, sFileName( sNewFileName );
1450cdf0e10cSrcweir pDoc->GetLinkManager().GetDisplayNames( this, 0, &sFileName,
1451cdf0e10cSrcweir &sRange, &sFilter );
1452cdf0e10cSrcweir
1453cdf0e10cSrcweir RedlineMode_t eOldRedlineMode = nsRedlineMode_t::REDLINE_NONE;
1454cdf0e10cSrcweir SfxObjectShellRef xDocSh;
1455cdf0e10cSrcweir SfxObjectShellLock xLockRef;
1456cdf0e10cSrcweir int nRet;
1457cdf0e10cSrcweir if( !sFileName.Len() )
1458cdf0e10cSrcweir {
1459cdf0e10cSrcweir xDocSh = pDoc->GetDocShell();
1460cdf0e10cSrcweir nRet = 1;
1461cdf0e10cSrcweir }
1462cdf0e10cSrcweir else
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir nRet = lcl_FindDocShell( xDocSh, xLockRef, sFileName,
1465cdf0e10cSrcweir rSection.GetLinkFilePassword(),
1466cdf0e10cSrcweir sFilter, 0, pDoc->GetDocShell() );
1467cdf0e10cSrcweir if( nRet )
1468cdf0e10cSrcweir {
1469cdf0e10cSrcweir SwDoc* pSrcDoc = ((SwDocShell*)&xDocSh)->GetDoc();
1470cdf0e10cSrcweir eOldRedlineMode = pSrcDoc->GetRedlineMode();
1471cdf0e10cSrcweir pSrcDoc->SetRedlineMode( nsRedlineMode_t::REDLINE_SHOW_INSERT );
1472cdf0e10cSrcweir }
1473cdf0e10cSrcweir }
1474cdf0e10cSrcweir
1475cdf0e10cSrcweir if( nRet )
1476cdf0e10cSrcweir {
1477cdf0e10cSrcweir rSection.SetConnectFlag(true);
1478cdf0e10cSrcweir
1479cdf0e10cSrcweir SwNodeIndex aSave( pPam->GetPoint()->nNode, -1 );
1480cdf0e10cSrcweir SwNodeRange* pCpyRg = 0;
1481cdf0e10cSrcweir
1482cdf0e10cSrcweir if( xDocSh->GetMedium() &&
1483cdf0e10cSrcweir !rSection.GetLinkFilePassword().Len() )
1484cdf0e10cSrcweir {
1485cdf0e10cSrcweir const SfxPoolItem* pItem;
1486cdf0e10cSrcweir if( SFX_ITEM_SET == xDocSh->GetMedium()->GetItemSet()->
1487cdf0e10cSrcweir GetItemState( SID_PASSWORD, sal_False, &pItem ) )
1488cdf0e10cSrcweir rSection.SetLinkFilePassword(
1489cdf0e10cSrcweir ((SfxStringItem*)pItem)->GetValue() );
1490cdf0e10cSrcweir }
1491cdf0e10cSrcweir
1492cdf0e10cSrcweir SwDoc* pSrcDoc = ((SwDocShell*)&xDocSh)->GetDoc();
1493cdf0e10cSrcweir
1494cdf0e10cSrcweir if( sRange.Len() )
1495cdf0e10cSrcweir {
1496cdf0e10cSrcweir // Rekursionen abfangen
1497cdf0e10cSrcweir sal_Bool bRecursion = sal_False;
1498cdf0e10cSrcweir if( pSrcDoc == pDoc )
1499cdf0e10cSrcweir {
1500cdf0e10cSrcweir SwServerObjectRef refObj( (SwServerObject*)
1501cdf0e10cSrcweir pDoc->CreateLinkSource( sRange ));
1502cdf0e10cSrcweir if( refObj.Is() )
1503cdf0e10cSrcweir {
1504cdf0e10cSrcweir bRecursion = refObj->IsLinkInServer( this ) ||
1505cdf0e10cSrcweir ChkNoDataFlag();
1506cdf0e10cSrcweir }
1507cdf0e10cSrcweir }
1508cdf0e10cSrcweir
1509cdf0e10cSrcweir SwNodeIndex& rInsPos = pPam->GetPoint()->nNode;
1510cdf0e10cSrcweir
1511cdf0e10cSrcweir SwPaM* pCpyPam = 0;
1512cdf0e10cSrcweir if( !bRecursion &&
1513cdf0e10cSrcweir pSrcDoc->SelectServerObj( sRange, pCpyPam, pCpyRg )
1514cdf0e10cSrcweir && pCpyPam )
1515cdf0e10cSrcweir {
1516cdf0e10cSrcweir if( pSrcDoc != pDoc ||
1517cdf0e10cSrcweir pCpyPam->Start()->nNode > rInsPos ||
1518cdf0e10cSrcweir rInsPos >= pCpyPam->End()->nNode )
1519cdf0e10cSrcweir {
1520cdf0e10cSrcweir pSrcDoc->CopyRange( *pCpyPam, *pPam->GetPoint(),
1521cdf0e10cSrcweir false );
1522cdf0e10cSrcweir }
1523cdf0e10cSrcweir delete pCpyPam;
1524cdf0e10cSrcweir }
1525cdf0e10cSrcweir if( pCpyRg && pSrcDoc == pDoc &&
1526cdf0e10cSrcweir pCpyRg->aStart < rInsPos && rInsPos < pCpyRg->aEnd )
1527cdf0e10cSrcweir delete pCpyRg, pCpyRg = 0;
1528cdf0e10cSrcweir }
1529cdf0e10cSrcweir else if( pSrcDoc != pDoc )
1530cdf0e10cSrcweir pCpyRg = new SwNodeRange( pSrcDoc->GetNodes().GetEndOfExtras(), 2,
1531cdf0e10cSrcweir pSrcDoc->GetNodes().GetEndOfContent() );
1532cdf0e10cSrcweir
1533cdf0e10cSrcweir // --> OD 2007-11-30 #i81653#
1534cdf0e10cSrcweir // Update links of extern linked document or extern linked
1535cdf0e10cSrcweir // document section, if section is protected.
1536cdf0e10cSrcweir if ( pSrcDoc != pDoc &&
1537cdf0e10cSrcweir rSection.IsProtectFlag() )
1538cdf0e10cSrcweir {
1539cdf0e10cSrcweir pSrcDoc->GetLinkManager().UpdateAllLinks( sal_False, sal_True, sal_False, 0 );
1540cdf0e10cSrcweir }
1541cdf0e10cSrcweir // <--
1542cdf0e10cSrcweir if( pCpyRg )
1543cdf0e10cSrcweir {
1544cdf0e10cSrcweir SwNodeIndex& rInsPos = pPam->GetPoint()->nNode;
1545cdf0e10cSrcweir sal_Bool bCreateFrm = rInsPos.GetIndex() <=
1546cdf0e10cSrcweir pDoc->GetNodes().GetEndOfExtras().GetIndex() ||
1547cdf0e10cSrcweir rInsPos.GetNode().FindTableNode();
1548cdf0e10cSrcweir
1549cdf0e10cSrcweir SwTblNumFmtMerge aTNFM( *pSrcDoc, *pDoc );
1550cdf0e10cSrcweir
1551*dec99bbdSOliver-Rainer Wittmann pSrcDoc->CopyWithFlyInFly( *pCpyRg, 0, rInsPos, NULL, bCreateFrm );
1552cdf0e10cSrcweir aSave++;
1553cdf0e10cSrcweir
1554cdf0e10cSrcweir if( !bCreateFrm )
1555cdf0e10cSrcweir ::MakeFrms( pDoc, aSave, rInsPos );
1556cdf0e10cSrcweir
1557cdf0e10cSrcweir // den letzten Node noch loeschen, aber nur wenn
1558cdf0e10cSrcweir // erfolgreich kopiert werden konnte, also der Bereich
1559cdf0e10cSrcweir // mehr als 1 Node enthaelt
1560cdf0e10cSrcweir if( 2 < pSectNd->EndOfSectionIndex() - pSectNd->GetIndex() )
1561cdf0e10cSrcweir {
1562cdf0e10cSrcweir aSave = rInsPos;
1563cdf0e10cSrcweir pPam->Move( fnMoveBackward, fnGoNode );
1564cdf0e10cSrcweir pPam->SetMark(); // beide SwPositions ummelden!
1565cdf0e10cSrcweir
1566cdf0e10cSrcweir pDoc->CorrAbs( aSave, *pPam->GetPoint(), 0, sal_True );
1567cdf0e10cSrcweir pDoc->GetNodes().Delete( aSave, 1 );
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir delete pCpyRg;
1570cdf0e10cSrcweir }
1571cdf0e10cSrcweir
1572cdf0e10cSrcweir // --> OD 2007-02-14 #b6521322#
1573cdf0e10cSrcweir lcl_BreakSectionLinksInSect( *pSectNd );
1574cdf0e10cSrcweir // <--
1575cdf0e10cSrcweir
1576cdf0e10cSrcweir // update alle Links in diesem Bereich
1577cdf0e10cSrcweir lcl_UpdateLinksInSect( *this, *pSectNd );
1578cdf0e10cSrcweir }
1579cdf0e10cSrcweir if( xDocSh.Is() )
1580cdf0e10cSrcweir {
1581cdf0e10cSrcweir if( 2 == nRet )
1582cdf0e10cSrcweir xDocSh->DoClose();
1583cdf0e10cSrcweir else if( ((SwDocShell*)&xDocSh)->GetDoc() )
1584cdf0e10cSrcweir ((SwDocShell*)&xDocSh)->GetDoc()->SetRedlineMode(
1585cdf0e10cSrcweir eOldRedlineMode );
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir }
1588cdf0e10cSrcweir break;
1589cdf0e10cSrcweir }
1590cdf0e10cSrcweir
1591cdf0e10cSrcweir // !!!! DDE nur updaten wenn Shell vorhanden ist??
1592cdf0e10cSrcweir uno::Sequence< sal_Int8 > aSeq;
1593cdf0e10cSrcweir if( pRead && rValue.hasValue() && ( rValue >>= aSeq ) )
1594cdf0e10cSrcweir {
1595cdf0e10cSrcweir if( pESh )
1596cdf0e10cSrcweir {
1597cdf0e10cSrcweir pESh->Push();
1598cdf0e10cSrcweir SwPaM* pCrsr = pESh->GetCrsr();
1599cdf0e10cSrcweir *pCrsr->GetPoint() = *pPam->GetPoint();
1600cdf0e10cSrcweir delete pPam;
1601cdf0e10cSrcweir pPam = pCrsr;
1602cdf0e10cSrcweir }
1603cdf0e10cSrcweir
1604cdf0e10cSrcweir SvMemoryStream aStrm( (void*)aSeq.getConstArray(), aSeq.getLength(),
1605cdf0e10cSrcweir STREAM_READ );
1606cdf0e10cSrcweir aStrm.Seek( 0 );
1607cdf0e10cSrcweir
1608cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1609cdf0e10cSrcweir {
1610cdf0e10cSrcweir SvFileStream aDeb( String::CreateFromAscii(
1611cdf0e10cSrcweir "file:///d|/temp/update.txt" ), STREAM_WRITE );
1612cdf0e10cSrcweir aDeb << aStrm;
1613cdf0e10cSrcweir }
1614cdf0e10cSrcweir aStrm.Seek( 0 );
1615cdf0e10cSrcweir #endif
1616cdf0e10cSrcweir
1617cdf0e10cSrcweir // TODO/MBA: it's impossible to set a BaseURL here!
1618cdf0e10cSrcweir SwReader aTmpReader( aStrm, aEmptyStr, pDoc->GetDocShell()->GetMedium()->GetBaseURL(), *pPam );
1619cdf0e10cSrcweir
1620cdf0e10cSrcweir if( !IsError( aTmpReader.Read( *pRead ) ))
1621cdf0e10cSrcweir {
1622cdf0e10cSrcweir rSection.SetConnectFlag(true);
1623cdf0e10cSrcweir }
1624cdf0e10cSrcweir
1625cdf0e10cSrcweir if( pESh )
1626cdf0e10cSrcweir {
1627cdf0e10cSrcweir pESh->Pop( sal_False );
1628cdf0e10cSrcweir pPam = 0; // pam is deleted before
1629cdf0e10cSrcweir }
1630cdf0e10cSrcweir }
1631cdf0e10cSrcweir
1632cdf0e10cSrcweir
1633cdf0e10cSrcweir // remove all undo actions and turn undo on again
1634cdf0e10cSrcweir pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
1635cdf0e10cSrcweir pDoc->GetIDocumentUndoRedo().DoUndo(bWasUndo);
1636cdf0e10cSrcweir pDoc->SetVisibleLinks( bWasVisibleLinks );
1637cdf0e10cSrcweir
1638cdf0e10cSrcweir pDoc->UnlockExpFlds();
1639cdf0e10cSrcweir if( !pDoc->IsExpFldsLocked() )
1640cdf0e10cSrcweir pDoc->UpdateExpFlds(NULL, true);
1641cdf0e10cSrcweir
1642cdf0e10cSrcweir if( pESh )
1643cdf0e10cSrcweir pESh->EndAllAction();
1644cdf0e10cSrcweir else if( pVSh )
1645cdf0e10cSrcweir pVSh->EndAction();
1646cdf0e10cSrcweir delete pPam; // wurde am Anfang angelegt
1647cdf0e10cSrcweir }
1648cdf0e10cSrcweir
1649cdf0e10cSrcweir
Closed()1650cdf0e10cSrcweir void SwIntrnlSectRefLink::Closed()
1651cdf0e10cSrcweir {
1652cdf0e10cSrcweir SwDoc* pDoc = rSectFmt.GetDoc();
1653cdf0e10cSrcweir if( pDoc && !pDoc->IsInDtor() )
1654cdf0e10cSrcweir {
1655cdf0e10cSrcweir // Advise verabschiedet sich, den Bereich als nicht geschuetzt
1656cdf0e10cSrcweir // kennzeichnen und das Flag umsetzen
1657cdf0e10cSrcweir
1658cdf0e10cSrcweir const SwSectionFmts& rFmts = pDoc->GetSections();
1659cdf0e10cSrcweir for( sal_uInt16 n = rFmts.Count(); n; )
1660cdf0e10cSrcweir if( rFmts[ --n ] == &rSectFmt )
1661cdf0e10cSrcweir {
1662cdf0e10cSrcweir ViewShell* pSh;
1663cdf0e10cSrcweir SwEditShell* pESh = pDoc->GetEditShell( &pSh );
1664cdf0e10cSrcweir
1665cdf0e10cSrcweir if( pESh )
1666cdf0e10cSrcweir pESh->StartAllAction();
1667cdf0e10cSrcweir else
1668cdf0e10cSrcweir pSh->StartAction();
1669cdf0e10cSrcweir
1670cdf0e10cSrcweir SwSectionData aSectionData(*rSectFmt.GetSection());
1671cdf0e10cSrcweir aSectionData.SetType( CONTENT_SECTION );
1672cdf0e10cSrcweir aSectionData.SetLinkFileName( aEmptyStr );
1673cdf0e10cSrcweir aSectionData.SetHidden( false );
1674cdf0e10cSrcweir aSectionData.SetProtectFlag( false );
1675cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections
1676cdf0e10cSrcweir aSectionData.SetEditInReadonlyFlag( false );
1677cdf0e10cSrcweir // <--
1678cdf0e10cSrcweir
1679cdf0e10cSrcweir aSectionData.SetConnectFlag( false );
1680cdf0e10cSrcweir
1681cdf0e10cSrcweir pDoc->UpdateSection( n, aSectionData );
1682cdf0e10cSrcweir
1683cdf0e10cSrcweir // alle in der Section liegenden Links werden sichtbar
1684cdf0e10cSrcweir SwSectionNode* pSectNd = rSectFmt.GetSectionNode( sal_False );
1685cdf0e10cSrcweir if( pSectNd )
1686cdf0e10cSrcweir pSectNd->GetSection().MakeChildLinksVisible( *pSectNd );
1687cdf0e10cSrcweir
1688cdf0e10cSrcweir if( pESh )
1689cdf0e10cSrcweir pESh->EndAllAction();
1690cdf0e10cSrcweir else
1691cdf0e10cSrcweir pSh->EndAction();
1692cdf0e10cSrcweir break;
1693cdf0e10cSrcweir }
1694cdf0e10cSrcweir }
1695cdf0e10cSrcweir SvBaseLink::Closed();
1696cdf0e10cSrcweir }
1697cdf0e10cSrcweir
1698cdf0e10cSrcweir
CreateLink(LinkCreateType eCreateType)1699cdf0e10cSrcweir void SwSection::CreateLink( LinkCreateType eCreateType )
1700cdf0e10cSrcweir {
1701cdf0e10cSrcweir SwSectionFmt* pFmt = GetFmt();
1702cdf0e10cSrcweir ASSERT(pFmt, "SwSection::CreateLink: no format?");
1703cdf0e10cSrcweir if (!pFmt || (CONTENT_SECTION == m_Data.GetType()))
1704cdf0e10cSrcweir return ;
1705cdf0e10cSrcweir
1706cdf0e10cSrcweir sal_uInt16 nUpdateType = sfx2::LINKUPDATE_ALWAYS;
1707cdf0e10cSrcweir
1708cdf0e10cSrcweir if (!m_RefLink.Is())
1709cdf0e10cSrcweir {
1710cdf0e10cSrcweir // create BaseLink
1711cdf0e10cSrcweir m_RefLink = new SwIntrnlSectRefLink( *pFmt, nUpdateType, FORMAT_RTF );
1712cdf0e10cSrcweir }
1713cdf0e10cSrcweir else
1714cdf0e10cSrcweir {
1715cdf0e10cSrcweir pFmt->GetDoc()->GetLinkManager().Remove( m_RefLink );
1716cdf0e10cSrcweir }
1717cdf0e10cSrcweir
1718cdf0e10cSrcweir SwIntrnlSectRefLink *const pLnk =
1719cdf0e10cSrcweir static_cast<SwIntrnlSectRefLink*>(& m_RefLink);
1720cdf0e10cSrcweir
1721cdf0e10cSrcweir String sCmd( m_Data.GetLinkFileName() );
1722cdf0e10cSrcweir xub_StrLen nPos;
1723cdf0e10cSrcweir while( STRING_NOTFOUND != (nPos = sCmd.SearchAscii( " " )) )
1724cdf0e10cSrcweir sCmd.Erase( nPos, 1 );
1725cdf0e10cSrcweir
1726cdf0e10cSrcweir pLnk->SetUpdateMode( nUpdateType );
1727cdf0e10cSrcweir pLnk->SetVisible( pFmt->GetDoc()->IsVisibleLinks() );
1728cdf0e10cSrcweir
1729cdf0e10cSrcweir switch (m_Data.GetType())
1730cdf0e10cSrcweir {
1731cdf0e10cSrcweir case DDE_LINK_SECTION:
1732cdf0e10cSrcweir pLnk->SetLinkSourceName( sCmd );
1733cdf0e10cSrcweir pFmt->GetDoc()->GetLinkManager().InsertDDELink( pLnk );
1734cdf0e10cSrcweir break;
1735cdf0e10cSrcweir case FILE_LINK_SECTION:
1736cdf0e10cSrcweir {
1737cdf0e10cSrcweir pLnk->SetContentType( FORMAT_FILE );
1738cdf0e10cSrcweir String sFltr( sCmd.GetToken( 1, sfx2::cTokenSeperator ) );
1739cdf0e10cSrcweir String sRange( sCmd.GetToken( 2, sfx2::cTokenSeperator ) );
1740cdf0e10cSrcweir pFmt->GetDoc()->GetLinkManager().InsertFileLink( *pLnk,
1741cdf0e10cSrcweir static_cast<sal_uInt16>(m_Data.GetType()),
1742cdf0e10cSrcweir sCmd.GetToken( 0, sfx2::cTokenSeperator ),
1743cdf0e10cSrcweir ( sFltr.Len() ? &sFltr : 0 ),
1744cdf0e10cSrcweir ( sRange.Len() ? &sRange : 0 ) );
1745cdf0e10cSrcweir }
1746cdf0e10cSrcweir break;
1747cdf0e10cSrcweir default:
1748cdf0e10cSrcweir ASSERT( !this, "Was ist das fuer ein Link?" )
1749cdf0e10cSrcweir }
1750cdf0e10cSrcweir
1751cdf0e10cSrcweir switch( eCreateType )
1752cdf0e10cSrcweir {
1753cdf0e10cSrcweir case CREATE_CONNECT: // Link gleich connecten
1754cdf0e10cSrcweir pLnk->Connect();
1755cdf0e10cSrcweir break;
1756cdf0e10cSrcweir
1757cdf0e10cSrcweir case CREATE_UPDATE: // Link connecten und updaten
1758cdf0e10cSrcweir pLnk->Update();
1759cdf0e10cSrcweir break;
1760cdf0e10cSrcweir case CREATE_NONE: break;
1761cdf0e10cSrcweir }
1762cdf0e10cSrcweir }
1763cdf0e10cSrcweir
1764cdf0e10cSrcweir // --> OD 2007-02-14 #b6521322#
BreakLink()1765cdf0e10cSrcweir void SwSection::BreakLink()
1766cdf0e10cSrcweir {
1767cdf0e10cSrcweir const SectionType eCurrentType( GetType() );
1768cdf0e10cSrcweir if ( eCurrentType == CONTENT_SECTION ||
1769cdf0e10cSrcweir eCurrentType == TOX_HEADER_SECTION ||
1770cdf0e10cSrcweir eCurrentType == TOX_CONTENT_SECTION )
1771cdf0e10cSrcweir {
1772cdf0e10cSrcweir // nothing to do
1773cdf0e10cSrcweir return;
1774cdf0e10cSrcweir }
1775cdf0e10cSrcweir
1776cdf0e10cSrcweir // release link, if it exists
1777cdf0e10cSrcweir if (m_RefLink.Is())
1778cdf0e10cSrcweir {
1779cdf0e10cSrcweir SwSectionFmt *const pFormat( GetFmt() );
1780cdf0e10cSrcweir ASSERT(pFormat, "SwSection::BreakLink: no format?");
1781cdf0e10cSrcweir if (pFormat)
1782cdf0e10cSrcweir {
1783cdf0e10cSrcweir pFormat->GetDoc()->GetLinkManager().Remove( m_RefLink );
1784cdf0e10cSrcweir }
1785cdf0e10cSrcweir m_RefLink.Clear();
1786cdf0e10cSrcweir }
1787cdf0e10cSrcweir // change type
1788cdf0e10cSrcweir SetType( CONTENT_SECTION );
1789cdf0e10cSrcweir // reset linked file data
1790cdf0e10cSrcweir SetLinkFileName( aEmptyStr );
1791cdf0e10cSrcweir SetLinkFilePassword( aEmptyStr );
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir // <--
1794cdf0e10cSrcweir
GetAnchor() const1795cdf0e10cSrcweir const SwNode* SwIntrnlSectRefLink::GetAnchor() const
1796cdf0e10cSrcweir {
1797cdf0e10cSrcweir return rSectFmt.GetSectionNode( sal_False );
1798cdf0e10cSrcweir }
1799cdf0e10cSrcweir
1800cdf0e10cSrcweir
IsInRange(sal_uLong nSttNd,sal_uLong nEndNd,xub_StrLen,xub_StrLen) const1801cdf0e10cSrcweir sal_Bool SwIntrnlSectRefLink::IsInRange( sal_uLong nSttNd, sal_uLong nEndNd,
1802cdf0e10cSrcweir xub_StrLen , xub_StrLen ) const
1803cdf0e10cSrcweir {
1804cdf0e10cSrcweir SwStartNode* pSttNd = rSectFmt.GetSectionNode( sal_False );
1805cdf0e10cSrcweir return pSttNd &&
1806cdf0e10cSrcweir nSttNd < pSttNd->GetIndex() &&
1807cdf0e10cSrcweir pSttNd->EndOfSectionIndex() < nEndNd;
1808cdf0e10cSrcweir }
1809cdf0e10cSrcweir
1810cdf0e10cSrcweir
1811cdf0e10cSrcweir
1812